(function(e){let h=window.WPD.ajaxsearchpro.helpers;e.fn.extend(window.WPD.ajaxsearchpro.plugin,{liveLoad:function(b,d,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=e(t);a.o.statistics&&a.stat_addKeyword(a.o.id,a.n("text").val());if(""!=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=e(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=e(g).first();c&&(document.title=t.title,history.pushState({},null,d));e(g).first().find(".woocommerce-ordering select.orderby").on("change",
function(){0<e(this).closest("form").length&&e(this).closest("form").get(0).submit()});if(1==a.o.singleHighlight)e(g).find("a").on("click",function(){localStorage.removeItem("asp_phrase_highlight");""!=h.unqoutePhrase(a.n("text").val())&&localStorage.setItem("asp_phrase_highlight",JSON.stringify({phrase:h.unqoutePhrase(a.n("text").val()),id:a.o.id}))});h.Hooks.applyFilters("asp/live_load/finished",d,a,g,k.get(0));ASP.initialize();a.lastSuccesfulSearch=e("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"});let w,x;null==(x=(w=a).gaPageview)||x.call(w,a.n("text").val());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 y=".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&&y.unshift("#main");if(1>e(g).length&&(y.forEach(function(l,f){if(0<e(l).length)return g=l,!1}),1>e(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=e(g).first();a.searchAbort();k.css("opacity",.4);d=h.Hooks.applyFilters("asp/live_load/url",d,a,g,k.get(0));h.Hooks.applyFilters("asp/live_load/start",d,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=e.fn.ajax({url:d,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<e(".asp_es_"+this.o.id).length||this.o.resPage.useAjax&&0<e(this.o.resPage.selector).length||this.o.wooShop.useAjax&&0<e(this.o.wooShop.selector).length||this.o.taxArchive.useAjax&&0<e(this.o.taxArchive.selector).length:
this._usingLiveLoader},getLiveURLbyBaseLocation(b){let d="asp_ls="+h.nicePhrase(this.n("text").val()),c="&";-1===b.indexOf("?")&&(c="?");b=b+c+d+"&asp_active=1&asp_force_reset_pagination=1&p_asid="+this.o.id+"&p_asp_data=1&"+e("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 d="&",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("?")&&(d="?");b=c+d+b+"&asp_active=1&asp_force_reset_pagination=1&p_asid="+this.o.id+"&p_asp_data=1&"+e("form",this.n("searchsettings")).serialize();b=b.replace("?&","?");return b=b.replace("&&","&")},initLiveLoaderPopState:function(){let b=this;b.liveLoadCache=[];window.addEventListener("popstate",d=>{d=b.getLiveLoadCache();
!1!==d&&(b.n("text").val(d.phrase),h.formData(e("form",b.n("searchsettings")),d.settings),b.resetNoUISliderFilters(),b.liveLoad(d.selector,document.location.href,!1,!1,d))});""==ASP.pageHTML&&"undefined"===typeof ASP._ajax_page_html&&(ASP._ajax_page_html=!0,e.fn.ajax({url:b.currentPageURL,method:"GET",success:function(d){ASP.pageHTML=d},dataType:"html"}))},setLiveLoadCache:function(b,d){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:d,html:b,settings:b==ASP.pageHTML?this.originalFormData:h.formData(e("form",this.n("searchsettings")))})},getLiveLoadCache:function(){let b=this.liveLoadCache.filter(d=>d.href==document.location.href);return 0<b.length?b[0]:!1}})})(WPD.dom);
