(()=>{"use strict";var t,r,e=function(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 i;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_(.+)$/,c=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]),c.some(function(r){return r.name.replace(/\[\]/g,"")===t})&&(l[r]=e[t].split(","))}),c.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 f=Object.keys(l).map(function(t){return l[t].length>0?t+"="+l[t].join(","):null}).filter(Boolean).join("&");return f?"?"+f:""}(0,t),i=window.location.origin+window.location.pathname;window.location.href=i+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(i),i=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){var r;t.preventDefault(),r=window.location.origin+window.location.pathname,window.location.href=r}),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)}};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())})();