(function(c){let k=window.WPD.ajaxsearchpro.helpers;window.WPD.ajaxsearchpro.addons.add(new function(){this.name="Elementor Widget Fixes";this.init=function(){k.Hooks.addFilter("asp/init/etc",this.fixElementorPostPagination,10,this);k.Hooks.addFilter("asp/live_load/selector",this.fixSelector,10,this);k.Hooks.addFilter("asp/live_load/url",this.url,10,this);k.Hooks.addFilter("asp/live_load/start",this.start,10,this);k.Hooks.addFilter("asp/live_load/replacement_node",this.fixElementorLoadMoreResults,
10,this);k.Hooks.addFilter("asp/live_load/finished",this.finished,10,this)};this.fixSelector=function(a){-1<a.indexOf("asp_es_")&&(a+=" .elementor-widget-container");return a};this.url=function(a,d,e,b){0<=a.indexOf("asp_force_reset_pagination=1")&&(a=a.replace(/\?product\-page=[0-9]+&/,"?"));return a};this.start=function(a,d,e,b){c("form",d.n("searchsettings")).serialize()+d.n("text").val().trim()==d.lastSuccesfulSearch&&0<c(b).find(".e-load-more-spinner").length&&c(b).css("opacity",1)};this.finished=
function(a,d,e,b){b=c(b);!1!==e.indexOf("asp_es_")&&"undefined"!=typeof elementorFrontend&&"undefined"!=typeof elementorFrontend.init&&0==b.find(".asp_elementor_nores").length&&(e=b.parent().data("widget_type"),""!=e&&"undefined"!=typeof jQuery&&elementorFrontend.hooks.doAction("frontend/element_ready/"+e,jQuery(b.parent().get(0))),this.fixElementorPostPagination(d,a),d.o.scrollToResults.enabled&&this.scrollToResultsIfNeeded(b),d.n("s").trigger("asp_elementor_results",[d.o.id,d.o.iid,b.parent().get(0)],
!0,!0))};this.scrollToResultsIfNeeded=function(a){a=a.find(".elementor-post, .product").first();a.length&&!a.inViewPort(40)&&a.get(0).scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})};this.fixElementorPostPagination=function(a,d){let e=this,b=c(".asp_es_"+a.o.id);d="undefined"==typeof d?location.href:d;if(0<b.length){e.elementorHideSpinner(b.get(0));var g=d.indexOf("?");if(0<=g){let h=d.substring(g+1);h&&(h=h.replace(/&asp_force_reset_pagination=1/gmi,""),0<b.find(".e-load-more-anchor").length&&
0==b.find(".elementor-pagination a").length?(g=function(f){f.preventDefault();f.stopPropagation();if(!a.searching){f=""==b.data("page")?2:parseInt(b.data("page"))+1;let l=h.split("&page=");b.data("page",f);a.showLoader();e.elementorShowSpinner(b.get(0));a.liveLoad(".asp_es_"+a.o.id,d.split("?")[0]+"?"+l[0]+"&page="+f,!1,!0)}},b.find(".e-load-more-anchor").next(".elementor-button-wrapper").find("a").attr("href",""),b.find(".e-load-more-anchor").next(".elementor-button-wrapper").offForced().on("click",
g),b.find(".asp_e_load_more_anchor").on("asp_e_load_more",g)):(b.find(".elementor-pagination a, .elementor-widget-container .woocommerce-pagination a").each(function(){let f=c(this).attr("href");0>f.indexOf("asp_ls=")&&0>f.indexOf("asp_ls&")?0>f.indexOf("?")?c(this).attr("href",f+"?"+h):c(this).attr("href",f+"&"+h):c(this).attr("href",c(this).attr("href").replace(/&asp_force_reset_pagination=1/gmi,""))}),b.find(".elementor-pagination a, .elementor-widget-container .woocommerce-pagination a").on("click",
function(f){f.preventDefault();f.stopImmediatePropagation();f.stopPropagation();a.showLoader();a.liveLoad(".asp_es_"+a.o.id,c(this).attr("href"),!1,!0)})))}}return a};this.fixElementorLoadMoreResults=function(a,d,e,b){b=c(e).closest("div[data-settings]").data("settings");let g=c(e).find(".asp_e_load_more_anchor");if(null!=b&&""!=b&&(b=JSON.parse(b),"load_more_infinite_scroll"==b.pagination_type&&0==g.length&&(c(".e-load-more-anchor").css("display","none"),c(e).append('<div class="asp_e_load_more_anchor"></div>'),
g=c(e).find(".asp_e_load_more_anchor"),b=function(){g.inViewPort(50)&&(g.trigger("asp_e_load_more"),g.remove())},d.documentEventHandlers.push({node:window,event:"scroll",handler:b}),c(window).on("scroll",b)),0<c(a).find(".e-load-more-spinner").length)){c(e).removeClass("e-load-more-pagination-loading");d=c("form",d.n("searchsettings")).serialize()+d.n("text").val().trim()!=d.lastSuccesfulSearch;b=c(e).find(".e-load-more-anchor").next(".elementor-button-wrapper");let h=c(e).find(".e-load-more-message");
a=c(a).find("article");if(0<a.length&&0<a.parent().length&&0<c(e).find("article").parent().length){a=a.get(0).innerHTML;let f=c(e).data("asp-previous-data");""==f||d?(c(e).find("article").parent().get(0).innerHTML=a,c(e).data("asp-previous-data",a),b.css("display","block"),h.css("display","none")):f==a?(b.css("display","none"),h.css("display","block"),g.remove()):(c(e).find("article").parent().get(0).innerHTML+=a,c(e).data("asp-previous-data",a))}else b.css("display","none"),h.css("display","block"),
g.remove();return null}return a};this.elementorShowSpinner=function(a){c(a).addClass("e-load-more-pagination-loading");c(a).find(".e-load-more-spinner>*").addClass("eicon-animation-spin");c(a).css("opacity",1)};this.elementorHideSpinner=function(a){c(a).removeClass("e-load-more-pagination-loading");c(a).find(".eicon-animation-spin").removeClass("eicon-animation-spin")}})})(WPD.dom);
