(()=>{"use strict";var t,r,e=function(t){!function(t){var r=t(".rtsb-active-filters-wrapper");if(!r.length)return;if(t(".rtsb-archive-filters-wrapper").length)return;r.off("click.rtsbDefaultChips"),r.on("click.rtsbDefaultChips",".remove-filter",function(r){r.preventDefault();var e=t(this).attr("data-filter-name"),i=t(this).attr("data-filter-value");e&&function(t,r){var e=new URLSearchParams(window.location.search);if("price_filter"===t)e.delete("min_price"),e.delete("max_price");else if(e.has(t)){var i=(e.get(t)||"").split(",").map(function(t){return t.trim()}).filter(function(t){return""!==t&&t!==r});i.length?e.set(t,i.join(",")):e.delete(t)}var a=e.toString();window.location.href=n(a?"?"+decodeURIComponent(a):"")}(e,i)}),r.on("click.rtsbDefaultChips",".rtsb-clear-filters",function(t){t.preventDefault(),i()})}(t);var r=t(".rtsb-archive-default-filters-wrapper");r.parent().hasClass("default-filter-has-toggle")&&t(".rtsb-default-archive-filters ").on("click",".rtsb-filter-mobile-toggle",function(){t(".rtsb-archive-default-filters-wrapper").slideToggle()});var e=t(".rtsb-apply-filters-btn");if(r.length){var a;if(t("#rtsb-product-default-filter-form").on("submit",function(r){r.preventDefault();t(this).serialize(),t(this).serializeArray();var e=function(t,r){var e=function(){var t={},r=window.location.search.substring(1);r&&r.split("&").forEach(function(r){var e=r.split("="),i=decodeURIComponent(e[0]),n=decodeURIComponent(e[1]||"").trim();""!==n&&(t[i]?t[i]+=","+n:t[i]=n)});return t}(),i=r(".rtsb-default-filter-search .rtsb-default-search-field"),n=i.length?i.val().trim():"",a={"rtsb-filter-product_cat":"product_cat","rtsb-filter-product_brand":"product_brand","rtsb-filter-product_tag":"product_tag","rtsb-filter-rating":"rating_filter","rtsb-filter-sale_filter":"sale_filter","rtsb-price-filter-min":"min_price","rtsb-price-filter-max":"max_price"},l={},o=/^rtsb-filter-pa_(.+)$/,f=r("#rtsb-product-default-filter-form").serializeArray();Object.keys(e).forEach(function(t){var r=a[t]||t,i=t.match(o);i&&(r="filter_"+i[1]),f.some(function(r){return r.name.replace(/\[\]/g,"")===t})&&(l[r]=e[t].split(","))}),f.forEach(function(t){var r=t.name.replace(/\[\]/g,""),e=t.value.trim(),i=a[r]||r,n=r.match(o);n&&(i="filter_"+n[1]),""!==e&&(l[i]||(l[i]=[]),l[i].includes(e)||l[i].push(e))}),""!==n?l.s=[n]:delete l.s;var c=Object.keys(l).map(function(t){return l[t].length>0?t+"="+l[t].join(","):null}).filter(Boolean).join("&");return c?"?"+c:""}(0,t);window.location.href=n(e)}),!e.length)t('#rtsb-product-default-filter-form input[type="checkbox"], #rtsb-product-default-filter-form input[type="radio"]').on("change",function(){t("#rtsb-product-default-filter-form").submit()}),t('#rtsb-product-default-filter-form input[name="rtsb-price-filter-min"], #rtsb-product-default-filter-form input[name="rtsb-price-filter-max"]').on("input",function(){clearTimeout(a),a=setTimeout(function(){var r=t('input[name="rtsb-price-filter-min"]').val(),e=t('input[name="rtsb-price-filter-max"]').val();r&&e&&t("#rtsb-product-default-filter-form").submit()},1e3)});t(".product-default-filter-reset").on("click",function(t){t.preventDefault(),i()}),function(t,r){var e=".rtsb-product-default-filters .term-has-children i";if(0===e.length)return!1;r.on("click",e,function(r){var e=t(r.currentTarget),i=e.closest(".rtsb-default-filter-term-item").find(".filter-child");e.toggleClass("active");var n=i.css("max-height"),a=0;i.children().each(function(t,r){a+=r.getBoundingClientRect().height}),"0px"===n?(i.css("max-height","".concat(a,"px")),i.css("margin-bottom","10px")):i.css("max-height","")})}(t,r)}};function i(){window.location.href=n("")}function n(t){var r=window.location.pathname.replace(/\/page\/\d+\/?$/,"/");return window.location.origin+r+(t||"")}t=jQuery,window.RTSB&&window.RTSB._initialized&&(null===(r=window.RTSB.modules.registerAfterElementor("productFilters",function(){var r=(window.RTSB||{}).helpers;return{name:"productFilters",version:"1.0.0",init:function(){return this.run(),this},refresh:function(){this.run()},run:function(){r.rAF(function(){return e(t)})}}}))||void 0===r||r.init())})();