(function(d){let h=window.WPD.ajaxsearchpro.helpers;d.fn.extend(window.WPD.ajaxsearchpro.plugin,{liveLoad:function(b,e,c,n,r){function q(l){let f=h.Hooks.applyFilters("asp/live_load/raw_data",l,a);var m=new DOMParser;let t=m.parseFromString(f,"text/html"),p=d(t);a.o.statistics&&a.stat_addKeyword(a.o.id,a.n("text").val());""!=f&&0<p.length&&0<p.find(g).length&&(f=f.replace(/&asp_force_reset_pagination=1/gmi,""),f=f.replace(/%26asp_force_reset_pagination%3D1/gmi,""),f=f.replace(/&#038;asp_force_reset_pagination=1/gmi,
""),h.isSafari()&&(f=f.replace(/srcset/gmi,"nosrcset")),f=h.Hooks.applyFilters("asp_live_load_html",f,a.o.id,a.o.iid),f=h.wp_hooks_apply_filters("asp_live_load_html",f,a.o.id,a.o.iid),p=d(m.parseFromString(f,"text/html")),m=p.find(g).get(0),m=h.Hooks.applyFilters("asp/live_load/replacement_node",m,a,k.get(0),f),null!=m&&k.get(0).parentNode.replaceChild(m,k.get(0)),k=d(g).first(),c&&(document.title=t.title,history.pushState({},null,e)),d(g).first().find(".woocommerce-ordering select.orderby").on("change",
function(){0<d(this).closest("form").length&&d(this).closest("form").get(0).submit()}),a.addHighlightString(d(g).find("a")),h.Hooks.applyFilters("asp/live_load/finished",e,a,g,k.get(0)),ASP.initialize(),a.lastSuccesfulSearch=d("form",a.n("searchsettings")).serialize()+a.n("text").val().trim(),a.lastSearchData=f,a.setLiveLoadCache(l,b));a.n("s").trigger("asp_search_end",[a.o.id,a.o.iid,a.n("text").val(),f],!0,!0);let u,v;null==(v=(u=a).gaEvent)||v.call(u,"search_end",{results_count:"unknown"});a.hideLoader();
k.css("opacity",1);a.searching=!1;""!=a.n("text").val()&&a.n("proclose").css({display:"block"})}let g=b;if("body"==g||"html"==g)return console.log("Ajax Search Pro: Do not use html or body as the live loader selector."),!1;let a=this;""!=ASP.pageHTML&&a.setLiveLoadCache(ASP.pageHTML,b);c="undefined"==typeof c?!0:c;n="undefined"==typeof n?!1:n;let w=".search-content #content #Content div[role=main] main[role=main] div.theme-content div.td-ss-main-content main.l-content #primary".split(" ");"#main"!=
g&&w.unshift("#main");if(1>d(g).length&&(w.forEach(function(l,f){if(0<d(l).length)return g=l,!1}),1>d(g).length))return console.log("Ajax Search Pro: The live search selector does not exist on the page."),!1;g=h.Hooks.applyFilters("asp/live_load/selector",g,this);let k=d(g).first();a.searchAbort();k.css("opacity",.4);e=h.Hooks.applyFilters("asp/live_load/url",e,a,g,k.get(0));h.Hooks.applyFilters("asp/live_load/start",e,a,g,k.get(0));n||1!=a.n("searchsettings").find("input[name=filters_initial]").val()||
""!=a.n("text").val()?"undefined"!=typeof r?q(r.html):(a.searching=!0,a.post=d.fn.ajax({url:e,method:"GET",success:function(l){q(l);a.isAutoP=!1},dataType:"html",fail:function(l){k.css("opacity",1);l.aborted||(k.html("This request has failed. Please check your connection."),a.hideLoader(),a.searching=!1,a.n("proclose").css({display:"block"}),a.isAutoP=!1)}})):window.WPD.intervalUntilExecute(function(){q(ASP.pageHTML)},function(){return""!=ASP.pageHTML})},usingLiveLoader:function(){return this._usingLiveLoader=
"undefined"==typeof this._usingLiveLoader?0<d(".asp_es_"+this.o.id).length||this.o.resPage.useAjax&&0<d(this.o.resPage.selector).length||this.o.wooShop.useAjax&&0<d(this.o.wooShop.selector).length||this.o.cptArchive.useAjax&&0<d(this.o.cptArchive.selector).length||this.o.taxArchive.useAjax&&0<d(this.o.taxArchive.selector).length:this._usingLiveLoader},getLiveURLbyBaseLocation(b){let e="asp_ls="+h.nicePhrase(this.n("text").val()),c="&";-1===b.indexOf("?")&&(c="?");b=b+c+e+"&asp_active=1&asp_force_reset_pagination=1&p_asid="+
this.o.id+"&p_asp_data=1&"+d("form",this.n("searchsettings")).serialize();b=b.replace("?&","?");return b=b.replace("&&","&")},getCurrentLiveURL:function(){var b="asp_ls="+h.nicePhrase(this.n("text").val());let e="&",c=window.location.href;c=-1<c.indexOf("asp_ls=")?c.slice(0,c.indexOf("asp_ls=")):c;c=-1<c.indexOf("asp_ls&")?c.slice(0,c.indexOf("asp_ls&")):c;c=-1<c.indexOf("p_asid=")?c.slice(0,c.indexOf("p_asid=")):c;c=-1<c.indexOf("asp_")?c.slice(0,c.indexOf("asp_")):c;-1===c.indexOf("?")&&(e="?");
b=c+e+b+"&asp_active=1&asp_force_reset_pagination=1&p_asid="+this.o.id+"&p_asp_data=1&"+d("form",this.n("searchsettings")).serialize();b=b.replace("?&","?");return b=b.replace("&&","&")},initLiveLoaderPopState:function(){let b=this;b.liveLoadCache=[];window.addEventListener("popstate",e=>{e=b.getLiveLoadCache();!1!==e&&(b.n("text").val(e.phrase),h.formData(d("form",b.n("searchsettings")),e.settings),b.resetNoUISliderFilters(),b.liveLoad(e.selector,document.location.href,!1,!1,e))});""==ASP.pageHTML&&
"undefined"===typeof ASP._ajax_page_html&&(ASP._ajax_page_html=!0,d.fn.ajax({url:b.currentPageURL,method:"GET",success:function(e){ASP.pageHTML=e},dataType:"html"}))},setLiveLoadCache:function(b,e){0==this.liveLoadCache.filter(c=>c.href==document.location.href).length&&this.liveLoadCache.push({href:b==ASP.pageHTML?this.currentPageURL:document.location.href,phrase:b==ASP.pageHTML?"":this.n("text").val(),selector:e,html:b,settings:b==ASP.pageHTML?this.originalFormData:h.formData(d("form",this.n("searchsettings")))})},
getLiveLoadCache:function(){let b=this.liveLoadCache.filter(e=>e.href==document.location.href);return 0<b.length?b[0]:!1}})})(WPD.dom);
