!function(a){"use strict";window.avadaWooAjax=window.avadaWooAjax||{},a(document).on("submit",".widget_price_filter form",(function(e){e.preventDefault();const o=new URLSearchParams(a(this).serialize());window.avadaWooAjax.load(window.avadaWooAjax.mergeQueryParams(window.location.href,o))})),a(document).on("click",".widget_layered_nav_filters a",(function(e){e.preventDefault();const o=new URLSearchParams(new URL(a(this).attr("href"),window.location.origin).search);window.avadaWooAjax.load(window.avadaWooAjax.mergeQueryParams(window.location.href,o))})),a(document).on("click",".woocommerce-widget-layered-nav a, .widget_rating_filter a, .widget_brand_nav a, .awb-woo-filters-brands a, .awb-woo-filters-attribute a, .awb-woo-filters-rating a",(function(e){e.preventDefault();const o=a(this),t=new URLSearchParams(new URL(o.attr("href"),window.location.origin).search);if(!o.closest(".widget_rating_filter").length&&!o.closest(".awb-woo-filters-rating").length||t.has("rating_filter")||t.set("rating_filter",""),!o.closest(".widget_brand_nav").length&&!o.closest(".awb-woo-filters-brands").length||t.has("filter_product_brand")||t.set("filter_product_brand",""),o.closest(".awb-woo-filters-attribute").length){const a=o.closest(".awb-woo-filters-attribute").attr("class").split(" ").find(a=>a.startsWith("awb-attribute-type-"));if(a){const e=a.replace("awb-attribute-type-","");t.has("filter_"+e)||t.set("filter_"+e,"")}}if(o.closest(".woocommerce-widget-layered-nav").length){const a=o.closest(".woocommerce-widget-layered-nav").attr("class").split(" ").find(a=>a.startsWith("widget_layered_nav-"));if(a){const e=a.replace("widget_layered_nav-","");t.has("filter_"+e)||t.set("filter_"+e,"")}}window.avadaWooAjax.load(window.avadaWooAjax.mergeQueryParams(window.location.href,t))})),"off"!==avadaWooCommerceVars.woo_ajax_categories&&a(document).on("click",".widget_product_categories a, .awb-woo-filters-categories a",(function(e){const o=a(this),t=o.data("slug");if("filter_directly"===avadaWooCommerceVars.woo_ajax_categories&&t){e.preventDefault();const r=new URLSearchParams(window.location.search),i=new URLSearchParams;return r.get("product_cat")===t?(i.set("product_cat",""),o.closest("li").removeClass("chosen")):(i.set("product_cat",t),a(".awb-woo-filters-categories li").removeClass("chosen"),o.closest("li").addClass("chosen")),void window.avadaWooAjax.load(window.avadaWooAjax.mergeQueryParams(window.location.href,i,!0),!0)}if("page_change"===avadaWooCommerceVars.woo_ajax_categories){e.preventDefault();const a=new URLSearchParams(window.location.search),t=["filter_","query_type_","min_price","max_price","rating_filter","product_brand","orderby"],r=new URLSearchParams;a.forEach((a,e)=>{t.some(a=>e.startsWith(a))&&r.set(e,a)});const i=window.avadaWooAjax.mergeQueryParams(o.attr("href"),r);window.avadaWooAjax.load(i,!0,!0)}})),a(document).on("submit",".woocommerce-widget-layered-nav-dropdown",(function(e){e.preventDefault();const o=new URLSearchParams(a(this).serialize());let t=null;if(o.has("filter")&&o.has("taxonomy")){const a=o.get("taxonomy").replace("pa_",""),e=new URLSearchParams;e.set("filter_"+a,o.get("filter")),t=window.avadaWooAjax.mergeQueryParams(window.location.href,e)}else for(const[a,e]of o.entries())if(a.startsWith("filter_")){let o=e;if(e.includes("?")||e.includes("/"))try{o=new URL(e,window.location.origin).searchParams.get(a)||""}catch(a){o=""}o||(t=window.avadaWooAjax.mergeQueryParams(window.location.href,new URLSearchParams(a+"=")));break}t?window.avadaWooAjax.load(t):window.avadaWooAjax.load(window.avadaWooAjax.mergeQueryParams(window.location.href,o))}))}(jQuery);