(()=>{"use strict";var e=jQuery,t=e("body"),i=function(t){var i;if(void 0!==e.fn.block){var n="#fff center center no-repeat";"undefined"!=typeof yith_wcan_shortcodes&&null!==(i=yith_wcan_shortcodes)&&void 0!==i&&i.loader&&(n="url('".concat(yith_wcan_shortcodes.loader,"') ").concat(n)),t.block({message:null,overlayCSS:{background:n,opacity:.7}})}},n=function(t){void 0!==e.fn.unblock&&t.unblock()},r={esc:27,enter:32,space:13,up:38,down:40};function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function a(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,s(n.key),n)}}function l(e,t,i){return(t=s(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e){var t=function(e,t){if("object"!=o(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=o(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==o(t)?t:t+""}var c=function(){return r=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),l(this,"xhr",null),l(this,"doingAjax",!1),l(this,"originalSearch",location.search),l(this,"initialized",!1),l(this,"filtered",!1),this.initPopState(),this.initialized=!0},s=[{key:"initPopState",value:function(){yith_wcan_shortcodes.reload_on_back&&(this.pushUrlToHistory(window.location,document.title,null,!0),e(window).on("popstate",function(){var e;null!==(e=window.history.state)&&void 0!==e&&e._yithWcan&&window.location.reload(!0)}))}},{key:"doFilter",value:function(t,i,n){var r,o,a=this,l=e(i||"body");return(o=e(document).triggerHandler("yith_wcan_filters_parameters",[t]))&&(t=o),l&&this.block(l),r=this.buildUrl(t),yith_wcan_shortcodes.ajax_filters?(this.doingAjax=!0,this._doAjax(r).done(function(e){r=a.searchAlternativeUrl(e,r),a._beforeFilter(e,t),a.refreshFragments(i,n,e),a.pushUrlToHistory(r,e.pageTitle,t),a.originalSearch=location.search,l&&a.unblock(l),a._afterFilter(e,t),a.doingAjax=!1})):(this.pushUrlToHistory(r,document.title,t),void(window.location=r))}},{key:"_beforeFilter",value:function(t,i){e(document).trigger("yith-wcan-ajax-loading",[t,i]),yith_wcan_shortcodes.query_vars=i}},{key:"_afterFilter",value:function(i,n){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").submit()}),this.filtered=n&&!!Object.keys(n).length,this.filtered?t.addClass("filtered"):t.removeClass("filtered"),e(window).trigger("scroll"),e(document).trigger("yith-wcan-ajax-filtered",[i,n]).trigger("yith_wcwl_reload_after_ajax")}},{key:"buildUrl",value:function(t){var i,n=this,r=yith_wcan_shortcodes.query_param,a={},l=window.location,s=yith_wcan_shortcodes.base_url?yith_wcan_shortcodes.base_url:(null==l?void 0:l.origin)+(null==l?void 0:l.pathname),c=this,u="object"===o(t)&&Object.keys(t).length;if(yith_wcan_shortcodes.session_param&&(s=s.replace(new RegExp("/"+yith_wcan_shortcodes.session_param+"/[^/]*/"),"")),u&&(a[r]=1),this.originalSearch){var h=this.originalSearch.replace("?","").split("&").reduce(function(e,t){var i=t.split("=");if(2===i.length){if(n.isFilterParam(i[0]))return e;e[i[0]]=i[1]}return e},{});a=e.extend(a,h)}return u&&(a=e.extend(a,t)),(i=Object.keys(a).reduce(function(e,t){var i=a[t];return i&&t?e+=c._cleanParam(t)+"="+c._cleanParam(i)+"&":e},"?").replace(/&$/g,"").replace(/%2B/g,"+").replace(/%2C/g,",")).length>1&&(s+=i),s}},{key:"searchAlternativeUrl",value:function(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return-1===e.indexOf("yith_wcan:sharing_url")?i:i=(t=e.match(/<meta name="yith_wcan:sharing_url" content="([^"]*)">/))&&1 in t?t[1]:i}},{key:"pushUrlToHistory",value:function(e,t,i,n){if(yith_wcan_shortcodes.change_browser_url&&!navigator.userAgent.match(/msie/i)){var r="pushState";n&&(r="replaceState"),window.history[r]({_yithWcan:!0,pageTitle:t,filters:i},"",e)}}},{key:"refreshFragments",value:function(t,i,n){var r=document.createElement("html"),o=e(r);if(r.innerHTML=n,t){var a,l=e(i),s=e(t);l.length&&(a=o.find(i)).length&&l.replaceWith(a.first()),s.length&&(a=o.find(t)).length&&s.replaceWith(a.first())}else{var c=e(yith_wcan_shortcodes.content);c.length?c.replaceWith(o.find(yith_wcan_shortcodes.content)):e("body").replaceWith(o.find("body"))}e(document).trigger("yith_wcan_init_shortcodes")}},{key:"_cleanParam",value:function(e){var t,i;return null===(t=yith_wcan_shortcodes)||void 0===t||!t.process_sanitize||null!==(i=yith_wcan_shortcodes)&&void 0!==i&&i.skip_sanitize?e:encodeURIComponent(e)}},{key:"_doAjax",value:function(t,i){return this.xhr&&this.xhr.abort(),i=e.extend({url:t,headers:{"X-YITH-WCAN":1}},i),this.xhr=e.ajax(i),this.xhr}},{key:"block",value:function(e){return i(e)}},{key:"unblock",value:function(e){return n(e)}},{key:"isFilterParam",value:function(t){var i,n=["rating_filter","min_price","max_price","price_ranges","onsale_filter","instock_filter","featured_filter","orderby","product-page",yith_wcan_shortcodes.query_param];return(i=e(document).triggerHandler("yith_wcan_supported_filters_parameters",[n]))&&(n=i),-1!==(n=n.concat(yith_wcan_shortcodes.supported_taxonomies.map(function(e){return e.replace("pa_","filter_")}))).indexOf(t)||-1!==t.indexOf("filter_")||-1!==t.indexOf("query_type_")}}],s&&a(r.prototype,s),c&&a(r,c),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,s,c}();function u(e){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u(e)}function h(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function f(e,t,i){return(t=d(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function d(e){var t=function(e,t){if("object"!=u(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=u(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==u(t)?t:t+""}var p=function(){return t=function e(t){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),f(this,"$label_set",null),f(this,"$labels",!1),f(this,"withAjaxSearch",!1),this.$label_set=t,this._initLabels(),this.withAjaxSearch=!1!==i,this.$label_set.data("filter_labels",this).addClass("enhanced")},(i=[{key:"_initLabels",value:function(){var t=this;this.getLabels().each(function(){var i=e(this);t._initLabel(i)})}},{key:"_initLabel",value:function(e){var t=this;e.on("click",function(i){t.disableLabel(e)&&i.preventDefault()})}},{key:"getLabels",value:function(){return!1===this.$labels&&(this.$labels=this.$label_set.find(".active-filter-label")),this.$labels}},{key:"disableLabel",value:function(t){var i=t.data("filters"),n=!1;return e(".yith-wcan-filters").each(function(){var t=e(this).data("preset");n=n||t.deactivateFilterByProperties(i,!0)}),n}}])&&h(t.prototype,i),n&&h(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,n}();function v(e){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},v(e)}function y(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,m(n.key),n)}}function _(e,t,i){return t&&y(e.prototype,t),i&&y(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function m(e){var t=function(e,t){if("object"!=v(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==v(t)?t:t+""}var b=_(function t(i){var n,r,o;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),n=this,o=null,(r=m(r="$reset"))in n?Object.defineProperty(n,r,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[r]=o,this.$reset=i,this.$reset.on("click",function(t){t.preventDefault(),e(".yith-wcan-filters").each(function(){var t=e(this).data("preset");t.deactivateAllFilters(!0),t.closeModal()})}),this.$reset.data("reset",this).addClass("enhanced")});function g(e){return g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},g(e)}function w(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,C(n.key),n)}}function k(e,t,i){return(t=C(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function C(e){var t=function(e,t){if("object"!=g(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=g(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==g(t)?t:t+""}var S=function(){return t=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),k(this,"$button",null),k(this,"preset",null),k(this,"$preset",null),k(this,"isMobile",!1),this.$button=t,this._initPreset(),this._initResponsive(),this._initActions(),this.$button.data("modalOpener",this).addClass("enhanced")},(i=[{key:"_initPreset",value:function(){var t,i=this.$button.data("target");(t=e(i?"#".concat(i):".yith-wcan-filters")).length&&(this.$preset=t.first(),this.preset=this.$preset.data("preset"))}},{key:"_initResponsive",value:function(){var t=this;if(yith_wcan_shortcodes.modal_on_mobile&&this.preset){var i=window.matchMedia("(max-width: ".concat(yith_wcan_shortcodes.mobile_media_query,"px)"));e(window).on("resize",function(){var e=!!i.matches;e!==t.isMobile&&(t.isMobile=e,t._afterLayoutChange())}).resize()}else this.$button.hide()}},{key:"_initActions",value:function(){var e;if(null!==(e=this.$preset)&&void 0!==e&&e.length){var t=this;this.$button.on("click",function(e){e.preventDefault(),t.preset.openModal()})}}},{key:"_afterLayoutChange",value:function(){this.isMobile?this.$button.show():this.$button.hide()}}])&&w(t.prototype,i),n&&w(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,n}();function F(e){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F(e)}function j(e){return function(e){if(Array.isArray(e))return O(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?O(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function P(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,i="function"==typeof Symbol?Symbol:{},n=i.iterator||"@@iterator",r=i.toStringTag||"@@toStringTag";function o(i,n,r,o){var s=n&&n.prototype instanceof l?n:l,c=Object.create(s.prototype);return $(c,"_invoke",function(i,n,r){var o,l,s,c=0,u=r||[],h=!1,f={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,i){return o=t,l=0,s=e,f.n=i,a}};function d(i,n){for(l=i,s=n,t=0;!h&&c&&!r&&t<u.length;t++){var r,o=u[t],d=f.p,p=o[2];i>3?(r=p===n)&&(s=o[(l=o[4])?5:(l=3,3)],o[4]=o[5]=e):o[0]<=d&&((r=i<2&&d<o[1])?(l=0,f.v=n,f.n=o[1]):d<p&&(r=i<3||o[0]>n||n>p)&&(o[4]=i,o[5]=n,f.n=p,l=0))}if(r||i>1)return a;throw h=!0,n}return function(r,u,p){if(c>1)throw TypeError("Generator is already running");for(h&&1===u&&d(u,p),l=u,s=p;(t=l<2?e:s)||!h;){o||(l?l<3?(l>1&&(f.n=-1),d(l,s)):f.n=s:f.v=s);try{if(c=2,o){if(l||(r="next"),t=o[r]){if(!(t=t.call(o,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,l<2&&(l=0)}else 1===l&&(t=o.return)&&t.call(o),l<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),l=1);o=e}else if((t=(h=f.n<0)?s:i.call(n,f))!==a)break}catch(t){o=e,l=1,s=t}finally{c=1}}return{value:t,done:h}}}(i,r,o),!0),c}var a={};function l(){}function s(){}function c(){}t=Object.getPrototypeOf;var u=[][n]?t(t([][n]())):($(t={},n,function(){return this}),t),h=c.prototype=l.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,$(e,r,"GeneratorFunction")),e.prototype=Object.create(h),e}return s.prototype=c,$(h,"constructor",c),$(c,"constructor",s),s.displayName="GeneratorFunction",$(c,r,"GeneratorFunction"),$(h),$(h,r,"Generator"),$(h,n,function(){return this}),$(h,"toString",function(){return"[object Generator]"}),(P=function(){return{w:o,m:f}})()}function $(e,t,i,n){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}$=function(e,t,i,n){function o(t,i){$(e,t,function(e){return this._invoke(t,i,e)})}t?r?r(e,t,{value:i,enumerable:!n,configurable:!n,writable:!n}):e[t]=i:(o("next",0),o("throw",1),o("return",2))},$(e,t,i,n)}function x(e,t,i,n,r,o,a){try{var l=e[o](a),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(n,r)}function T(e){return function(){var t=this,i=arguments;return new Promise(function(n,r){var o=e.apply(t,i);function a(e){x(o,n,r,a,l,"next",e)}function l(e){x(o,n,r,a,l,"throw",e)}a(void 0)})}}function A(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,E(n.key),n)}}function M(e,t,i){return(t=E(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function E(e){var t=function(e,t){if("object"!=F(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=F(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==F(t)?t:t+""}var z=function(){return t=function t(i,n){var r,o,a,l;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),M(this,"$originalSelect",null),M(this,"_items",[]),M(this,"$_main",null),M(this,"$_label",null),M(this,"$_dropdown",null),M(this,"$_search",null),M(this,"$_showMore",null),M(this,"$_items",null),M(this,"paginate",!1),M(this,"hasMore",!1),M(this,"needsRefresh",!0),M(this,"multiple",!1),M(this,"currentPage",1),M(this,"options",{}),this.$originalSelect=i,this.$originalSelect.is("select")){var s=this.$originalSelect.data("per_page"),c=this.$originalSelect.data("order"),u=this.$originalSelect.data("all-label"),h={showSearch:this.$originalSelect.data("show_search"),paginate:this.$originalSelect.data("paginate"),perPage:s||10,hasMore:!1,order:c||"ASC",getElements:null,labels:{emptyLabel:u||(null===(r=yith_wcan_shortcodes.labels)||void 0===r?void 0:r.empty_option),searchPlaceholder:null===(o=yith_wcan_shortcodes.labels)||void 0===o?void 0:o.search_placeholder,noItemsFound:null===(a=yith_wcan_shortcodes.labels)||void 0===a?void 0:a.no_items,showMore:null===(l=yith_wcan_shortcodes.labels)||void 0===l?void 0:l.show_more}};this.multiple=this.$originalSelect.prop("multiple"),this.options=e.extend(h,n),this.paginate=this.options.paginate||!1,this.hasMore=this.options.hasMore||!1,this._hideSelect(),this._initTemplate(),this._initActions(),this.$originalSelect.data("dropdown",this).addClass("enhanced")}},i=[{key:"_hideSelect",value:function(){this.$originalSelect.hide()}},{key:"_initTemplate",value:function(){var t=e("<div/>",{class:"yith-wcan-dropdown closed","aria-label":this.$originalSelect.attr("aria-label"),tabindex:0}),i=e("<div/>",{class:"dropdown-label",html:this.getLabel()}),n=e("<div>",{class:"dropdown-wrapper"}),r=e("<ul/>",{class:"matching-items filter-items"});n.append(r),t.append(i).append(n),this.options.showSearch&&this._initSearchTemplate(n),this.options.paginate&&this._initShowMoreTemplate(n),this.$originalSelect.after(t),this.$_main=t,this.$_label=i,this.$_dropdown=n,this.$_items=r}},{key:"_initSearchTemplate",value:function(t){var i=e("<div/>",{class:"search-field-container"}),n=e("<input/>",{name:"s",class:"search-field",type:"search",placeholder:this.options.labels.searchPlaceholder}).attr("autocomplete","off");i.append(n).prependTo(t),this.$_search=n}},{key:"_initShowMoreTemplate",value:function(t){var i,n=e("<a/>",{class:"show-more",text:null===(i=this.options.labels.showMore)||void 0===i?void 0:i.replace("%d",this.options.perPage)});n.on("click",this.loadNextPage.bind(this)).hide(),t.append(n),this.$_showMore=n}},{key:"_initActions",value:function(){var t,i,n=this;null===(t=this.$_main)||void 0===t||null===(t=t.on("click",function(e){e.stopPropagation(),n.toggleDropdown()}))||void 0===t||t.on("keyup",function(e){if(Object.values(r).includes(e.keyCode))return e.preventDefault(),[r.enter,r.space].includes(e.keyCode)?(n.toggleDropdown(),!1):r.esc===e.keyCode?(n.closeDropdown(),!1):void 0}),this.$_dropdown.on("click",function(e){e.stopPropagation()}),null===(i=this.$_search)||void 0===i||i.on("keyup search",function(e){var t=e.keyCode;if(!t||t!==r.esc)return n.paginate=!1,n._populateItems().then(function(){n.needsRefresh=!0}),!1}).on("change",function(){return!1}),this.$_items.on("change",":input",function(t){var i,r=e(t.target).closest("li"),o=r.data("value");return r.hasClass("disabled")&&!n.isValueSelected(o)||(r.toggleClass("active"),i=r.hasClass("active"),n._changeItemStatus(o,i)),!1}),this.$_items.on("click","li:not(.checkbox) a",function(t){var i,r=e(t.target).closest("li"),o=r.data("value");return t.preventDefault(),r.hasClass("disabled")&&!n.isValueSelected(o)||(r.toggleClass("active"),(i=r.hasClass("active"))&&r.siblings().removeClass("active"),n._changeItemStatus(o,i)),!1}),this.$_items.on("click","label > a",function(t){var i=e(t.target).parent().find(":input");t.preventDefault(),(i.is('[type="radio"]')||i.is('[type="checkbox"]'))&&i.prop("checked",!i.prop("checked")),i.change()}),this.$originalSelect.on("change",function(e,t){t||n.updateLabel()}),null!==globalThis&&void 0!==globalThis&&globalThis.yith_wcan_dropdown_init||(e(document).on("click",this._closeAllDropdowns),globalThis.yith_wcan_dropdown_init=!0)}},{key:"openDropdown",value:function(){var e;null===(e=this.$_main)||void 0===e||e.addClass("open").removeClass("closed"),this._afterDropdownOpen()}},{key:"closeDropdown",value:function(){var e;null===(e=this.$_main)||void 0===e||e.removeClass("open").addClass("closed")}},{key:"_closeAllDropdowns",value:function(){e(document).find("select.enhanced").filter(function(t,i){return!!e(i).data("dropdown")}).each(function(){e(this).data("dropdown").closeDropdown()})}},{key:"_closeOtherDropdowns",value:function(){var t=this;e(document).find("select.enhanced").filter(function(i,n){var r=e(n);return!!r.data("dropdown")&&!r.is(t.$originalSelect)}).each(function(){e(this).data("dropdown").closeDropdown()})}},{key:"toggleDropdown",value:function(){var e,t;null===(e=this.$_main)||void 0===e||e.toggleClass("open").toggleClass("closed"),null!==(t=this.$_main)&&void 0!==t&&t.hasClass("open")&&this._afterDropdownOpen()}},{key:"_afterDropdownOpen",value:function(){var e;this._closeOtherDropdowns(),null!==(e=this.$_search)&&void 0!==e&&e.length&&this.$_search.val(""),this._maybePopulateItems()}},{key:"getItems",value:(a=T(P().m(function t(i){var n,r,o=this;return P().w(function(t){for(;;)switch(t.n){case 0:return this._items.length||this.getOptions().each(function(t,i){var n=e(i),r=n.val(),a=n.html();o._items.push({value:r,label:a})}),t.n=1,this.getMatchingElements(i);case 1:return n=t.v,(r=this.paginate?this.options.perPage:0)&&n.length>r&&(this.hasMore=!0,n=n.slice(0,r)),t.a(2,n)}},t,this)})),function(e){return a.apply(this,arguments)})},{key:"getMatchingElements",value:function(e){var t=this,i=this._items;return new Promise(function(n){i=e?i.filter(function(t){var i=t.label,n=t.value,r=new RegExp(".*"+e+".*","i");return r.test(n)||r.test(i)}):i,t.options.getElements?t.options.getElements.call(t,e).then(function(e){e&&(e=Object.keys(e).reduce(function(t,i){return e[i].label?(t.push(e[i]),t):(t.push({label:e[i],value:i}),t)},[]),i=[].concat(j(i),j(e))),n(t._formatItems(i))}):n(t._formatItems(i))})}},{key:"_formatItems",value:function(e){var t=this,i=[];return e.filter(function(e){var n=e.value,r=e.label;return-1===i.indexOf(n)&&(i.push(n),t.getOptionByValue(n).length||t.$originalSelect.append('<option class="filter-item" value="'.concat(n,'">').concat(r,"</option>")),!0)})}},{key:"_generateItem",value:function(t,i){var n,o=this.isValueSelected(t),a=this.getOptionByValue(t),l=e("<li/>",{"data-value":t,class:a.length?a.attr("class"):"",tabindex:0});if(a.length){var s=a.data("template"),c=a.data("count");i=s||i,c&&(i+=c)}if(n=e("<a/>",{href:a.length?a.data("filter_url"):"#",html:i,rel:"nofollow","data-title":a.length?a.data("title"):"",tabindex:-1}),l.on("keyup",function(e){Object.values(r).includes(null==e?void 0:e.keyCode)&&(e.preventDefault(),[r.space,r.enter].includes(null==e?void 0:e.keyCode)?n.click():r.next===e.keyCode?l.next().focus():r.prev===e.keyCode&&l.prev().focus())}),this.multiple){var u=e("<input/>",{type:"checkbox",tabindex:-1,value:t}),h=e("<label>");u.prop("checked",o),h.prepend(u).append(n),l.append(h).addClass("checkbox")}else l.append(n);return o?l.addClass("active"):l.removeClass("active"),l}},{key:"_maybePopulateItems",value:function(){this.needsRefresh&&this._populateItems()}},{key:"_populateItems",value:function(){var e,t=this,i=!(null===(e=this.$_search)||void 0===e||!e.length)&&this.$_search.val();return this.getItems(i).then(function(e){t._emptyItems(),t._hideLoadMore(),t.$_items.append(e.map(function(e){var i=e.label,n=e.value;return t._generateItem(n,i)})),t.$originalSelect.trigger("yith_wcan_dropdown_updated"),t.needsRefresh=!1,t.paginate&&t.hasMore&&t._showLoadMore()})}},{key:"loadNextPage",value:(o=T(P().m(function e(){var t=this;return P().w(function(e){for(;;)switch(e.n){case 0:this.paginate=!1,this._populateItems().then(function(){t.hasMore=!1});case 1:return e.a(2)}},e,this)})),function(){return o.apply(this,arguments)})},{key:"_selectItem",value:function(e){return this._changeItemStatus(e,!0)}},{key:"_deselectItem",value:function(e){return this._changeItemStatus(e,!1)}},{key:"_changeItemStatus",value:function(e,t){var i=this.$originalSelect.find('option[value="'.concat(e,'"]'));return!!i.length&&(i.prop("selected",t),!yith_wcan_shortcodes.instant_filters&&this.multiple||this.closeDropdown(),this.updateLabel(),this.$originalSelect.trigger("change",[!0]),!0)}},{key:"_emptyItems",value:function(){this.$_items.html("")}},{key:"_showLoadMore",value:function(){this.$_showMore.show()}},{key:"_hideLoadMore",value:function(){this.$_showMore.hide()}},{key:"getLabel",value:function(){return this.hasSelectedValues()?this.getSelectedLabels().join(", "):this.options.labels.emptyLabel}},{key:"updateLabel",value:function(){var e,t=this.getLabel();null===(e=this.$_label)||void 0===e||e.html(t)}},{key:"getOptions",value:function(){return this.$originalSelect.find("option")}},{key:"hasSelectedValues",value:function(){return this.getSelectedOptions().length}},{key:"isValueSelected",value:function(e){return-1!==this.getSelectedValues().indexOf(e.toString())}},{key:"getSelectedOptions",value:function(){return this.$originalSelect.find("option").filter(":selected")}},{key:"getOptionByValue",value:function(e){return this.$originalSelect.find('option[value="'.concat(e,'"]'))}},{key:"getSelectedLabels",value:function(){var t=[];return this.getSelectedOptions().each(function(){var i=e(this),n=i.data("template");n=n||i.html().replace(/\([0-9]*\)/,""),t.push(n)}),t}},{key:"getSelectedValues",value:function(){var t=[];return this.getSelectedOptions().each(function(){t.push(e(this).val())}),t}},{key:"destroy",value:function(){}}],i&&A(t.prototype,i),n&&A(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,i,n,o,a}();function H(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(e){if("string"==typeof e)return I(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?I(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,l=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==i.return||i.return()}finally{if(l)throw o}}}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function D(e){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},D(e)}function B(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,i="function"==typeof Symbol?Symbol:{},n=i.iterator||"@@iterator",r=i.toStringTag||"@@toStringTag";function o(i,n,r,o){var s=n&&n.prototype instanceof l?n:l,c=Object.create(s.prototype);return L(c,"_invoke",function(i,n,r){var o,l,s,c=0,u=r||[],h=!1,f={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,i){return o=t,l=0,s=e,f.n=i,a}};function d(i,n){for(l=i,s=n,t=0;!h&&c&&!r&&t<u.length;t++){var r,o=u[t],d=f.p,p=o[2];i>3?(r=p===n)&&(s=o[(l=o[4])?5:(l=3,3)],o[4]=o[5]=e):o[0]<=d&&((r=i<2&&d<o[1])?(l=0,f.v=n,f.n=o[1]):d<p&&(r=i<3||o[0]>n||n>p)&&(o[4]=i,o[5]=n,f.n=p,l=0))}if(r||i>1)return a;throw h=!0,n}return function(r,u,p){if(c>1)throw TypeError("Generator is already running");for(h&&1===u&&d(u,p),l=u,s=p;(t=l<2?e:s)||!h;){o||(l?l<3?(l>1&&(f.n=-1),d(l,s)):f.n=s:f.v=s);try{if(c=2,o){if(l||(r="next"),t=o[r]){if(!(t=t.call(o,s)))throw TypeError("iterator result is not an object");if(!t.done)return t;s=t.value,l<2&&(l=0)}else 1===l&&(t=o.return)&&t.call(o),l<2&&(s=TypeError("The iterator does not provide a '"+r+"' method"),l=1);o=e}else if((t=(h=f.n<0)?s:i.call(n,f))!==a)break}catch(t){o=e,l=1,s=t}finally{c=1}}return{value:t,done:h}}}(i,r,o),!0),c}var a={};function l(){}function s(){}function c(){}t=Object.getPrototypeOf;var u=[][n]?t(t([][n]())):(L(t={},n,function(){return this}),t),h=c.prototype=l.prototype=Object.create(u);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,L(e,r,"GeneratorFunction")),e.prototype=Object.create(h),e}return s.prototype=c,L(h,"constructor",c),L(c,"constructor",s),s.displayName="GeneratorFunction",L(c,r,"GeneratorFunction"),L(h),L(h,r,"Generator"),L(h,n,function(){return this}),L(h,"toString",function(){return"[object Generator]"}),(B=function(){return{w:o,m:f}})()}function L(e,t,i,n){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}L=function(e,t,i,n){function o(t,i){L(e,t,function(e){return this._invoke(t,i,e)})}t?r?r(e,t,{value:i,enumerable:!n,configurable:!n,writable:!n}):e[t]=i:(o("next",0),o("throw",1),o("return",2))},L(e,t,i,n)}function R(e,t,i,n,r,o,a){try{var l=e[o](a),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(n,r)}function G(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),i.push.apply(i,n)}return i}function U(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?G(Object(i),!0).forEach(function(t){W(e,t,i[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):G(Object(i)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))})}return e}function N(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,q(n.key),n)}}function W(e,t,i){return(t=q(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function q(e){var t=function(e,t){if("object"!=D(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==D(t)?t:t+""}var Q=function(){return t=function t(i){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),W(this,"preset",!1),W(this,"$preset",!1),W(this,"target",!1),W(this,"$target",!1),W(this,"$filters",!1),W(this,"$filterButtons",!1),W(this,"modalElements",{}),W(this,"activeFilters",!1),W(this,"isMobile",!1),W(this,"sliderTimeout",!1),W(this,"originalFilters",null),W(this,"dirty",!1),W(this,"loaded",void 0),W(this,"inhibitFilters",!1),W(this,"productIds",[]),W(this,"withAjaxSearch",!1),W(this,"search",""),this.preset="#"+i.attr("id"),this.$preset=i,this.target=this.$preset.data("target"),this.$target=!!this.target&&e(this.target),this.productIds=null!=n&&n.productIds?n.productIds:[],this.withAjaxSearch=!1!==n,this.search=null!=n&&n.query?n.query:"",this._regiterStatus(),this._initFilterButton(),this._initFilters(),this._initResponsive(),this._initActions(),this.$preset.data("preset",this).addClass("enhanced").trigger("yith_wcan_preset_initialized",[this])},r=[{key:"_initFilters",value:function(){var t=this,i=this.getFilters().get().map(function(i){return t._initFilter(e(i))});this.loaded=Promise.all(i),this.maybeShowClearAllFilters()}},{key:"_initFilterButton",value:function(){var e=this;this.$filterButtons=this.$preset.find(".apply-filters"),this.$filterButtons.length&&this.$filterButtons.on("click",function(t){t.preventDefault(),e.filter()}).hide()}},{key:"_initActions",value:function(){this.$preset.find("form").on("submit",function(e){e.preventDefault()})}},{key:"_initResponsive",value:function(){var t=this;if(yith_wcan_shortcodes.modal_on_mobile){var i=window.matchMedia("(max-width: ".concat(yith_wcan_shortcodes.mobile_media_query,"px)"));e(window).on("resize",function(){var e=!!i.matches;e!==t.isMobile&&(t.isMobile=e,t._afterLayoutChange())}).resize()}}},{key:"_initFilter",value:function(t){var i=this,n=this,r=function(t){var i=e(this),r=i.closest(".yith-wcan-filter"),o=!!r.length&&"yes"===r.data("multiple"),a=i.closest(".filter-item"),l=a.length?r.find(".filter-item").not(a):[];return!r.is(".filter-price-slider")&&!(a.is(".disabled")&&!a.is(".active"))&&(t.preventDefault(),l.length&&!o&&l.removeClass("active").children("label").find(":input").prop("checked",!1).parent(".checked").removeClass("checked"),a.length&&a.toggleClass("active"),n.activeFilters=!1,n.maybeFilter(r),n.maybeToggleClearAllFilters(),void n.maybeToggleClearFilter(r))};return n.withAjaxSearch&&(t.addClass("filter-placeholder"),t.hasClass("filter-tax")&&t.find(".filter-items li a").addClass("item-placeholder"),t.hasClass("filter-price-slider")&&t.find(".price-slider").addClass("slider-placeholder")),this._maybeLoadFilter(t).then(function(t){return t.on("click","a",function(t){var i=e(this).closest(".filter-item");!i.length||i.is(".checkbox")||i.is(".radio")||r.call(this,t)}),t.on("change",":input",function(t){var i=e(this),n=i.closest(".filter-item");if(n.is(".disabled")&&!n.is(".active"))return i.prop("checked",!1),!1;r.call(this,t)}),t.on("click","label > a",function(t){var i=e(this),n=i.closest(".filter-item");if(t.preventDefault(),n.is(".disabled")&&!n.is(".active"))return!1;var r=i.parent().find(":input");(r.is('[type="radio"]')||r.is('[type="checkbox"]'))&&r.prop("checked",!r.prop("checked")),r.change()}),i._initFilterChildren(t),i.maybeShowClearFilter(t),t})}},{key:"_initFilterChildren",value:function(t){var i,n=this;this._initTooltip(t),this._initPriceSlider(t),this._initDropdown(t),this._initCollapsable(t),this._initShowMore(t),null!==(i=this.$preset)&&void 0!==i&&i.hasClass("custom-style")&&(this._initCustomInput(t),t.on("yith_wcan_dropdown_updated",function(t){var i=e(t.target).closest(".yith-wcan-filter");n._initCustomInput(i)}))}},{key:"_maybeLoadFilter",value:function(t){var i=this;if(!t.hasClass("filter-placeholder"))return Promise.resolve(t);var n={_preset_id:this.getId(),_filter_id:t.data("filter-id")};return this.withAjaxSearch&&(n=U(U({},n),{},{_product_ids:this.productIds,_ywcas_search:this.search})),new Promise(function(r){var o;e.ajax({method:"GET",url:yith_wcan_shortcodes.base_url,data:U(U({"wc-ajax":"yith_wcan_render_filter",security:null===(o=yith_wcan_shortcodes.nonces)||void 0===o?void 0:o.render_filter},i.originalFilters),n)}).then(function(e){var n;return r(i._loadFilter(t,e.success?null==e||null===(n=e.data)||void 0===n?void 0:n.html:""))})})}},{key:"_loadFilter",value:function(t,i){if(!i)return this.withAjaxSearch?t.hide():t.remove();var n=e(i);return t.replaceWith(n),this.$filters=!1,n}},{key:"_initTooltip",value:function(t,i){t.find("[data-title]").each(function(){var t=e(this);!t.hasClass("tooltip-added")&&t.data("title")&&(t.on("mouseenter",function(){var t,n=e(this),r=null,o=n.outerWidth(),a=0;if(!i||"top"!==i&&"right"!==i){var l=n.closest(".filter-item");i=l.hasClass("color")||l.hasClass("label")?"top":"right"}r=e("<span>",{class:"yith-wcan-tooltip",html:n.data("title")}),n.append(r),t=r.outerWidth()+6,r.outerWidth(t),a="top"===i?(o-t)/2:o+15,r.css({left:a.toFixed(0)+"px"}).fadeIn(200),n.addClass("with-tooltip")}).on("mouseleave",function(){var t=e(this);t.find(".yith-wcan-tooltip").fadeOut(200,function(){t.removeClass("with-tooltip").find(".yith-wcan-tooltip").remove()})}),t.addClass("tooltip-added"))})}},{key:"_initDropdown",value:function(t){var i=t.find("select.filter-dropdown");if(i.length&&!i.hasClass("enhanced")){i.hasClass("select2-hidden-accessible")&&void 0!==e.fn.selectWoo&&i.selectWoo("destroy");var n=this,r=i.data("has-more");this._initDropdownObject(i,U({paginate:!0,hasMore:r,perPage:parseInt(yith_wcan_shortcodes.terms_per_page)},r?{getElements:function(e){var i,r=this;return(i=B().m(function i(){return B().w(function(i){for(;;)switch(i.n){case 0:if(!r.paginate&&r.hasMore||e){i.n=1;break}return i.a(2,r._items);case 1:return i.a(2,n._getTerms(t,e))}},i)}),function(){var e=this,t=arguments;return new Promise(function(n,r){var o=i.apply(e,t);function a(e){R(o,n,r,a,l,"next",e)}function l(e){R(o,n,r,a,l,"throw",e)}a(void 0)})})()}}:{}))}}},{key:"_initDropdownObject",value:function(e,t){return new z(e,t)}},{key:"_initPriceSlider",value:function(e){var t=this;if(e.hasClass("filter-price-slider")){var i=this,n=e.find(".price-slider"),r=n.find(".price-slider-min"),o=n.find(".price-slider-max"),a=parseFloat(n.data("min")),l=parseFloat(n.data("max")),s=parseFloat(r.val()),c=parseFloat(o.val()),u=parseFloat(n.data("step")),h=function(){i.sliderTimeout&&clearTimeout(i.sliderTimeout),i.sliderTimeout=setTimeout(function(){i.maybeFilter(e)},300)};e.find(".price-slider-ui").off("change").ionRangeSlider({skin:"round",type:"double",min:a,max:l,step:u,from:s,to:c,min_interval:u,values_separator:" - ",prettify:function(e){return t.formatPrice(e)},onChange:function(e){r.val(e.from),o.val(e.to)},onFinish:h}),r.add(o).off("change").on("change",h).on("keyup",function(e){if(!e.key.match(/[0-9,.]/))return e.preventDefault(),!1;r.val()&&o.val()&&h()})}}},{key:"_initCollapsable",value:function(e){this._initTitleCollapsable(e),this._initHierarchyCollapsable(e)}},{key:"_initShowMore",value:function(e){var t=this,i=e.find(".filter-content").children(".show-more");i.length&&!i.hasClass("initialized")&&i.addClass("initialized").on("click",function(){return t._loadItems(e).then(function(){return i.remove()})})}},{key:"_getTerms",value:function(t,r){var o=this;return new Promise(function(a){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return n(t)},url:yith_wcan_shortcodes.base_url,data:U({"wc-ajax":"yith_wcan_get_filter_terms",_preset_id:o.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.get_filter_terms,search:r},o.originalFilters)}).then(function(e){var t,i=e.success?null==e||null===(t=e.data)||void 0===t?void 0:t.items:{};a(i)})})}},{key:"_loadItems",value:function(t){var r=this;return new Promise(function(o){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return n(t)},url:yith_wcan_shortcodes.base_url,data:U({"wc-ajax":"yith_wcan_render_remaining_terms",_preset_id:r.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.render_remaining_terms},r.originalFilters)}).then(function(e){var i,n=t.find(".filter-content .filter-items.level-0");n.append(e.success?null==e||null===(i=e.data)||void 0===i?void 0:i.html:""),r._initFilterChildren(t),o(n)})})}},{key:"_initTitleCollapsable",value:function(e){var t=e.find(".collapsable");t.length&&!t.hasClass("toggle-initialized")&&this._initToggle(t,t,e.find(".filter-content"))}},{key:"_initHierarchyCollapsable",value:function(t){var i=t.find(".hierarchy-collapsable");if(i.length){var n=this,r=t.find(".active");r.length&&(r.parents(".hierarchy-collapsable").removeClass("closed").addClass("opened"),r.hasClass("hierarchy-collapsable")&&yith_wcan_shortcodes.show_current_children&&r.removeClass("closed").addClass("opened")),i.each(function(){var t=e(this);if(!t.hasClass("toggle-initialized")){var i=e("<span/>",{class:"toggle-handle"});i.appendTo(t),n._initToggle(i,t,t.children("ul.filter-items"))}})}}},{key:"_initToggle",value:function(e,t,i){var n=this;t.hasClass("toggle-initialized")||(t.hasClass("closed")&&i.hide(),e.off("click").on("click",function(e){e.stopPropagation(),e.preventDefault(),n.toggle(i,t),i.trigger("yith_wcan_after_toggle_element",[t])}),t.addClass("toggle-initialized"))}},{key:"_initCustomInput",value:function(t){t.find(":input").each(function(){var t,i=e(this),n=i.attr("type"),r="".concat(n,"button");"checkbox"!==n&&"radio"!==n||i.closest(".".concat(r)).length||(i.is(":checked")&&(r+=" checked"),t=e("<span/>",{class:r}),i.wrap(t).on("change",function(){var t=e(this);t.prop("checked")?t.parent().addClass("checked"):t.parent().removeClass("checked")}))})}},{key:"_regiterStatus",value:function(){var e,t=null!==(e=yith_wcan_shortcodes.query_vars)&&void 0!==e?e:[];this.originalFilters=this.mergeProperties(this.withAjaxSearch?[]:t,this.getFiltersProperties())}},{key:"_afterLayoutChange",value:function(){var t,i,n=this;this.isMobile?(this.$preset.addClass("filters-modal").attr("role","dialog").attr("tabindex","-1").hide(),this._addCloseModalButton(),this._addApplyFiltersModalButton(),this.loaded.then(function(){return n._switchToCollapsables()}),null===(t=this.$filterButtons)||void 0===t||t.hide()):(this.$preset.removeClass("filters-modal").removeClass("open").removeAttr("role").removeAttr("tabindex").show(),e("body").css("overflow","auto").removeClass("yith-wcan-preset-modal-open"),this._removeCloseModalButton(),this._removeApplyFiltersModalButton(),this.loaded.then(function(){return n._switchBackCollapsables()}),null===(i=this.$filterButtons)||void 0===i||i.show())}},{key:"_addCloseModalButton",value:function(){var t=e("<a/>",{class:"close-button",html:"&times;","data-dismiss":"modal","aria-label":yith_wcan_shortcodes.labels.close});t.prependTo(this.$preset).on("click",this.closeModal.bind(this)),this.modalElements.closeButton=t}},{key:"_removeCloseModalButton",value:function(){var e;null===(e=this.modalElements)||void 0===e||null===(e=e.closeButton)||void 0===e||e.remove()}},{key:"_addApplyFiltersModalButton",value:function(){var t=this,i=e("<button/>",{class:"apply-filters main-modal-button",html:yith_wcan_shortcodes.labels.show_results,"data-dismiss":"modal"});i.appendTo(this.$preset).on("click",function(){t.filter(),t.closeModal()}),this.modalElements.applyFiltersButton=i}},{key:"_removeApplyFiltersModalButton",value:function(){var e;null===(e=this.modalElements)||void 0===e||null===(e=e.applyFiltersButton)||void 0===e||e.remove()}},{key:"_switchToCollapsables",value:function(){var t=this;this.getFilters().each(function(){var i=e(this),n=i.find(".filter-title");n.length&&!n.hasClass("collapsable")&&(n.addClass("collapsable").data("disable-collapse",!0),t._initTitleCollapsable(i))})}},{key:"_switchBackCollapsables",value:function(){this.getFilters().each(function(){var t=e(this),i=t.find(".filter-title");i.length&&i.hasClass("collapsable")&&i.data("disable-collapse")&&(i.removeClass("collapsable").removeData("disable-collapse",!0).off("click"),t.find(".filter-content").show())})}},{key:"_openAllCollapsables",value:function(){var t=this;this.getFilters().not(".no-title").not(function(i,n){return t.isFilterActive(e(n))}).find(".filter-content").show().end().find(".filter-title").removeClass("closed").addClass("opened")}},{key:"_closeAllCollapsables",value:function(){var t=this;this.getFilters().not(".no-title").not(function(i,n){return t.isFilterActive(e(n))}).find(".filter-content").hide().end().find(".filter-title").addClass("closed").removeClass("opened")}},{key:"maybeRegisterStatusChange",value:function(){var e=this.getFiltersProperties(),t=JSON.stringify(e),i=JSON.stringify(this.originalFilters);this.dirty=t!==i}},{key:"maybeFilter",value:function(e){if(this.maybeRegisterStatusChange(),!this.inhibitFilters)if(yith_wcan_shortcodes.instant_filters&&!this.isMobile)this.filter();else if(yith_wcan_shortcodes.instant_filters||this.isMobile){if(this.isMobile&&this.dirty){var t;this.$preset.addClass("with-filter-button"),null===(t=this.modalElements.applyFiltersButton)||void 0===t||t.show()}}else{var i,n;this.dirty?null===(i=this.$filterButtons)||void 0===i||i.show():null===(n=this.$filterButtons)||void 0===n||n.hide()}}},{key:"filter",value:function(){var t=this;if(this.withAjaxSearch)this._regiterStatus(),e(document).trigger("yith_wcan_filter_updated",[this]);else{var i,n,r,o=null===(i=window)||void 0===i?void 0:i.product_filter;null==o||null===(n=o.doFilter(this.getFiltersProperties(),this.target,this.preset))||void 0===n||n.done(function(){var i=e(t.preset);if(i.length&&yith_wcan_shortcodes.scroll_top){var n=i.offset().top;if(yith_wcan_shortcodes.scroll_target){var r=e(yith_wcan_shortcodes.scroll_target);n=r.length?r.offset().top:n}else t.isMobile&&(n=100);e("body, html").animate({scrollTop:n-100})}t._regiterStatus(),t.dirty=!1}),this.isMobile&&(this.$preset.removeClass("with-filter-button"),null===(r=this.modalElements.applyFiltersButton)||void 0===r||r.hide(),this.closeModal())}}},{key:"getId",value:function(){return this.$preset.data("preset-id")}},{key:"getFilters",value:function(){return!1===this.$filters&&(this.$filters=this.$preset.find(".yith-wcan-filter")),this.$filters}},{key:"getActiveFilters",value:function(){return!1===this.activeFilters&&(this.activeFilters=this.getFiltersProperties()),this.activeFilters}},{key:"isAnyFilterActive",value:function(){return!!Object.keys(this.getActiveFilters()).length}},{key:"isFilterActive",value:function(e){var t,i;switch(e.data("filter-type")){case"tax":case"review":case"price_range":var n=e.find(".filter-dropdown");if(n.length){var r=n.val();t="object"===D(r)?!(null==r||!r.length):!!r;break}case"stock_sale":t=e.find(".filter-item").filter(".active").length;break;case"price_slider":var o=parseFloat(e.find(".price-slider").data("step")),a=parseFloat(e.find(".price-slider").data("min")),l=parseFloat(e.find(".price-slider").data("max")),s=parseFloat(e.find(".price-slider-min").val()),c=parseFloat(e.find(".price-slider-max").val());t=Math.abs(s-a)>=o||Math.abs(c-l)>=o;break;case"orderby":t="menu_order"!==e.find(".filter-order-by").val();break;default:t=!1}return t=void 0!==(i=e.triggerHandler("yith_wcan_is_filter_active",[t,this]))?i:t}},{key:"countActiveItems",value:function(e){var t;switch(e.data("filter-type")){case"tax":case"review":case"price_range":var i=e.find(".filter-dropdown");if(i.length){var n=i.val();t="object"===D(n)?null==n?void 0:n.length:+!!n;break}case"stock_sale":t=e.find(".filter-items").find(".active").length;break;case"orderby":this.isFilterActive(e)&&(t=1);break;default:t=0}return t}},{key:"getFilterProperties",value:function(t){var i,n,r=t.data("filter-type"),o="yes"===t.data("multiple"),a=t.find(".filter-dropdown"),l={};switch(r){case"tax":var s=[],c=t.data("taxonomy"),u=0===c.indexOf("filter"),h=t.data("relation");if(a.length?o?s=a.val():s.push(a.val()):s=(n=t.find(".filter-item").filter(".active").children("a, label")).get().reduce(function(t,i){var n;return(n=(i=e(i)).is("label")?i.find(":input").val():i.data("term-slug"))?(t.push(n),t):t},s),o){var f=u||"and"!==h?",":"+";l[c]=s.join(f)}else l[c]=s.pop();u&&(l[c.replace("filter_","query_type_")]=h);break;case"review":a.length?l.rating_filter=a.val():(n=t.find(".filter-item").filter(".active").children("a, label"),o?l.rating_filter=n.get().reduce(function(t,i){var n;return(n=(i=e(i)).is("label")?i.find(":input").val():i.data("rating"))?(t.push(n),t):t},[]).join(","):(n=n.first(),l.rating_filter=n.is("label")?n.find(":input").val():n.data("rating")));break;case"price_range":a.length?o?l.price_ranges=a.val().join(","):(l.min_price=a.val().split("-")[0],l.max_price=a.val().split("-")[1]):(n=t.find(".filter-item").filter(".active").children("a, label"),o?l.price_ranges=n.get().reduce(function(t,i){var n=e(i).data("range-min"),r=e(i).data("range-max");return t+=(r?"".concat(n,"-").concat(r):n)+","},"").replace(/^(.*),$/,"$1"):(l.min_price=parseFloat(n.first().data("range-min")),l.max_price=parseFloat(n.first().data("range-max"))));break;case"price_slider":l.min_price=parseFloat(t.find(".price-slider-min").val()),l.max_price=parseFloat(t.find(".price-slider-max").val());break;case"stock_sale":t.find(".filter-on-sale").is(".active")&&(l.onsale_filter=1),t.find(".filter-in-stock").is(".active")&&(l.instock_filter=1),t.find(".filter-featured").is(".active")&&(l.featured_filter=1);break;case"orderby":l.orderby=t.find(".filter-order-by").val()}return l=void 0!==(i=t.triggerHandler("yith_wcan_filter_properties",[l,self]))?i:l}},{key:"getFiltersProperties",value:function(){var t={},i=this;return this.getFilters().each(function(){var n=e(this);if(i.isFilterActive(n)){var r=i.getFilterProperties(n);t=i.mergeProperties(t,r,n)}}),t}},{key:"getFiltersByProperties",value:function(t){var i=this;return this.getFilters().filter(function(){var n=e(this);if(i.isFilterActive(n)){var r,o=i.getFilterProperties(n),a=!1,l=H(t);try{for(l.s();!(r=l.n()).done;){var s=r.value;if(["min_price","max_price","price_ranges"].includes(s)&&(o.min_price||o.price_ranges)){a=!0;break}if(o[s]){a=!0;break}}}catch(e){l.e(e)}finally{l.f()}return a}return!1})}},{key:"maybeToggleClearFilter",value:function(e){this.isFilterActive(e)?this.maybeShowClearFilter(e):this.maybeHideClearFilter(e)}},{key:"maybeToggleClearAllFilters",value:function(){this.isAnyFilterActive()?this.maybeShowClearAllFilters():this.maybeHideClearAllFilters()}},{key:"maybeShowClearFilter",value:function(t){var i=this;this.isFilterActive(t)&&yith_wcan_shortcodes.show_clear_filter&&(t.find(".clear-selection").remove(),e("<a/>",{class:"clear-selection",text:yith_wcan_shortcodes.labels.clear_selection,role:"button"}).prependTo(t.find(".filter-content")).on("click",function(e){e.preventDefault(),i.deactivateFilter(t,!1,yith_wcan_shortcodes.instant_filters),i.maybeHideClearFilter(t),yith_wcan_shortcodes.instant_filters&&i.closeModal()}))}},{key:"maybeShowClearAllFilters",value:function(){var t=this;this.isAnyFilterActive()&&this.isMobile&&(this.$preset.find(".clear-selection").remove(),e("<a/>",{class:"clear-selection",text:yith_wcan_shortcodes.labels.clear_all_selections,role:"button"}).prependTo(this.$preset.find(".filters-container")).on("click",function(e){e.preventDefault(),t.deactivateAllFilters(yith_wcan_shortcodes.instant_filters),t.maybeHideClearAllFilters(),yith_wcan_shortcodes.instant_filters&&t.closeModal()}))}},{key:"maybeHideClearFilter",value:function(e){!this.isFilterActive(e)&&yith_wcan_shortcodes.show_clear_filter&&e.find(".clear-selection").remove()}},{key:"maybeHideClearAllFilters",value:function(){this.isAnyFilterActive()||this.$preset.find(".filters-container").children(".clear-selection").remove()}},{key:"deactivateFilter",value:function(t,i,n){var r=t.data("filter-type"),o=t.find(".filter-item"),a=o.filter(".active"),l=t.find(".filter-dropdown");switch(this.inhibitFilters=!0,r){case"tax":var s=t.data("taxonomy");l.length?(i?l.find("option").each(function(){var t=e(this);t.val().toString()===i[s].toString()&&t.prop("selected",!1)}):l.find("option").prop("selected",!1),l.change()):i?a.each(function(){var t=e(this),n=t.children("label"),r=t.children("a");(n.length?n.find(":input").val():r.data("term-slug")).toString()===i[s].toString()&&(t.children("label").children("a").click(),t.removeClass("active"))}):(a.children("label").children("a").click(),a.removeClass("active"));break;case"review":l.length?(i?l.find("option").each(function(){var t=e(this);t.val()===i.rating_filter&&t.prop("selected",!1)}):l.find("option").prop("selected",!1),l.change()):i?a.each(function(){var t=e(this),n=t.children("label"),r=t.children("a");(n.length?n.find(":input").val():r.data("rating"))===i.rating_filter&&(t.children("label").children("a").click(),t.removeClass("active"))}):(a.children("label").children("a").click(),a.removeClass("active"));break;case"price_range":l.length?(i?l.find("option").each(function(){var t=e(this),n=i.min_price+(i.max_price?"-".concat(i.max_price):"");t.val()===n&&t.prop("selected",!1)}):l.find("option").prop("selected",!1),l.change()):i?a.each(function(){var t,n,r=e(this),o=r.children("label"),a=r.children("a");n=o.length?o.find(":input").val():a.data("min_price")+(a.data("max_price")?"-"+a.data("max_price"):""),i.min_price?t=i.min_price+(i.max_price?"-"+i.max_price:""):i.price_ranges&&(t=i.price_ranges),n===t&&(r.children("label").children("a").click(),r.removeClass("active"))}):(a.children("label").children("a").click(),a.removeClass("active"));break;case"price_slider":var c=t.find(".price-slider");t.find(".price-slider-min").val(c.data("min")),t.find(".price-slider-max").val(c.data("max")).change();break;case"orderby":t.find("select").val("menu_order");break;case"stock_sale":i?(null!=i&&i.instock_filter&&t.find(".filter-in-stock").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active"),null!=i&&i.onsale_filter&&t.find(".filter-on-sale").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active"),null!=i&&i.featured_filter&&t.find(".filter-featured").find(":input").prop("checked",!1).change().closest(".filter-item").removeClass("active")):(t.find(".filter-in-stock").find(":input").prop("checked",!1).change(),t.find(".filter-on-sale").find(":input").prop("checked",!1).change(),t.find(".filter-featured").find(":input").prop("checked",!1).change(),o.removeClass("active"));break;default:o.removeClass("active")}this.inhibitFilters=!1,this.activeFilters=!1,n&&this.filter()}},{key:"deactivateAllFilters",value:function(t){var i=this;return this.getFilters().each(function(){var t=e(this);i.deactivateFilter(t)}),this.activeFilters=!1,t&&this.filter(),!0}},{key:"deactivateFilterByProperties",value:function(t,i){var n=this,r=this.getFiltersByProperties(Object.keys(t));return!!r.length&&(r.each(function(){var r=e(this);n.deactivateFilter(r,t,i)}),!0)}},{key:"toggle",value:function(e,t,i){void 0===i&&(i=t.hasClass("closed"));var n=i?"opened":"closed",r=i?"closed":"opened";e[i?"slideDown":"slideUp"](400,function(){t.addClass(n).removeClass(r),e.trigger("yith_wcan_toggle_element",[t,i])})}},{key:"openFilter",value:function(e){var t=e.find(".collapsable");t.length&&this.toggle(e.find(".filter-content"),t,!0)}},{key:"openAllFilters",value:function(t){var i=this;this.getFilters().each(function(){i.openFilter(e(this))})}},{key:"closeFilter",value:function(e){var t=e.find(".collapsable");t.length&&this.toggle(e.find(".filter-content"),t,!1)}},{key:"closeAllFilters",value:function(t){var i=this;this.getFilters().each(function(){i.closeFilter(e(this))}),void 0!==t&&this.openFilter(t)}},{key:"openModal",value:function(){var t=this;this.isMobile&&(yith_wcan_shortcodes.toggles_open_on_modal?this._openAllCollapsables():this._closeAllCollapsables(),e("body").css("overflow","hidden").addClass("yith-wcan-preset-modal-open"),this.$preset.show(),setTimeout(function(){t.$preset.addClass("open")},100))}},{key:"closeModal",value:function(){var t=this;this.isMobile&&(this.$preset.removeClass("open"),setTimeout(function(){t.$preset.hide(),e("body").css("overflow","auto").removeClass("yith-wcan-preset-modal-open")},300))}},{key:"formatPrice",value:function(e){var t,i,n,r;return"undefined"!=typeof accounting&&(e=accounting.formatMoney(e,{symbol:null===(t=yith_wcan_shortcodes.currency_format)||void 0===t?void 0:t.symbol,decimal:null===(i=yith_wcan_shortcodes.currency_format)||void 0===i?void 0:i.decimal,thousand:null===(n=yith_wcan_shortcodes.currency_format)||void 0===n?void 0:n.thousand,precision:0,format:null===(r=yith_wcan_shortcodes.currency_format)||void 0===r?void 0:r.format})),e}},{key:"mergeProperties",value:function(t,i,n){for(var r in i)if(i.hasOwnProperty(r)&&t[r]){switch(r){case"rating_filter":case"min_price":case"max_price":case"onsale_filter":case"instock_filter":case"orderby":t[r]=i[r];break;default:if(0===r.indexOf("query_type_"))t[r]=i[r];else{var o=(null==n?void 0:n.data("relation"))||"and",a=0===r.indexOf("filter_"),l=a||"and"!==o?",":"+",s=t[r].replace(",",l)+l+i[r].replace(",",l);if(s=s.split(l).filter(function(e,t,i){return i.indexOf(e)===t}).join(l),t[r]=s,a){var c=r.replace("filter_","query_type_");t[c]="and",i[c]="and"}}}delete i[r]}return e.extend(t,i),t}}],r&&N(t.prototype,r),o&&N(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,r,o}();function V(e){return V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},V(e)}function J(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,te(n.key),n)}}function X(e,t,i){return t=Z(t),function(e,t){if(t&&("object"==V(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Y()?Reflect.construct(t,i||[],Z(e).constructor):t.apply(e,i))}function Y(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Y=function(){return!!e})()}function K(){return K="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=Z(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},K.apply(null,arguments)}function Z(e){return Z=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Z(e)}function ee(e,t){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ee(e,t)}function te(e){var t=function(e,t){if("object"!=V(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==V(t)?t:t+""}var ie=function(t){function i(){var e,t,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i);for(var o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return e=X(this,i,[].concat(a)),t=e,r=!1,(n=te(n="$preset"))in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ee(e,t)}(i,t),n=i,r=[{key:"getPreset",value:function(){return this.preset?this.preset:(this.$preset=this.$originalSelect.closest(".yith-wcan-filters"),!!this.$preset.length&&this.$preset)}},{key:"_initTemplate",value:function(){var t,n,r,o,a,l;if(null!==(t=this.getPreset())&&void 0!==t&&t.hasClass("horizontal")){var s=e("<div>",{class:"dropdown-wrapper"}),c=e("<ul/>",{class:"matching-items filter-items"});s.append(c),this.options.showSearch&&this._initSearchTemplate(s),this.options.paginate&&this._initShowMoreTemplate(s),this.$originalSelect.after(s),this.$_main=null,this.$_label=null,this.$_dropdown=s,this.$_items=c,this._populateItems()}else(n=i,r="_initTemplate",o=this,l=K(Z(1&(a=3)?n.prototype:n),r,o),2&a&&"function"==typeof l?function(e){return l.apply(o,e)}:l)([])}}],r&&J(n.prototype,r),o&&J(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(z);function ne(e){return ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ne(e)}function re(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,oe(n.key),n)}}function oe(e){var t=function(e,t){if("object"!=ne(e)||!e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ne(t)?t:t+""}function ae(e,t,i){return t=ue(t),function(e,t){if(t&&("object"==ne(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,le()?Reflect.construct(t,i||[],ue(e).constructor):t.apply(e,i))}function le(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(le=function(){return!!e})()}function se(e,t,i,n){var r=ce(ue(1&n?e.prototype:e),t,i);return 2&n&&"function"==typeof r?function(e){return r.apply(i,e)}:r}function ce(){return ce="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,i){var n=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=ue(e)););return e}(e,t);if(n){var r=Object.getOwnPropertyDescriptor(n,t);return r.get?r.get.call(arguments.length<3?e:i):r.value}},ce.apply(null,arguments)}function ue(e){return ue=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ue(e)}function he(e,t){return he=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},he(e,t)}var fe=function(t){function i(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=ae(this,i,[e,n])).isHorizontal()&&!globalThis.yith_wcan_backdrop_init&&(t._initBackdropClick(),globalThis.yith_wcan_backdrop_init=!0),t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&he(e,t)}(i,t),n=i,(r=[{key:"_initBackdropClick",value:function(){var t=this;this.isHorizontal()&&(this.getFilters().on("click",function(e){return e.stopPropagation()}),e(document).on("click",function(){t.isMobile||t.maybeCloseAllHorizontalToggles()}))}},{key:"isHorizontal",value:function(){var e;return null===(e=this.$preset)||void 0===e?void 0:e.hasClass("horizontal")}},{key:"maybeFilter",value:function(e){var t=e.closest(".yith-wcan-filter");this.maybeRegisterStatusChange(),(!this.isHorizontal()||this.isMobile||!this.isHorizontalToggle(t.find(".filter-title"))||(this.maybeUpdateFiltersCount(t),e.hasClass("apply-filters")||e.hasClass("clear-selection")||yith_wcan_shortcodes.instant_horizontal_filter))&&(yith_wcan_shortcodes.instant_filters&&yith_wcan_shortcodes.instant_horizontal_filter&&this.maybeCloseAllHorizontalToggles(),se(i,"maybeFilter",this,3)([]))}},{key:"maybeShowClearFilter",value:function(t){var n=this;if(this.isFilterActive(t)&&yith_wcan_shortcodes.show_clear_filter)if(!this.isHorizontal()||this.isMobile)se(i,"maybeShowClearFilter",this,3)([t]);else{t.find(".clear-selection").remove();var r=e("<a/>",{class:"clear-selection button",text:yith_wcan_shortcodes.labels.clear_selection,role:"button"});r.prependTo(t.find(".filter-content-footer")).on("click",function(e){e.preventDefault(),n.deactivateFilter(t,!1,yith_wcan_shortcodes.instant_filters),n.maybeUpdateFiltersCount(t),n.maybeHideClearFilter(t),n.maybeFilter(r),n.maybeCloseHorizontalToggle(t.find(".filter-title.collapsable"))})}}},{key:"_initFilter",value:function(e){var t=this;return se(i,"_initFilter",this,3)([e]).then(function(e){t.maybeUpdateFiltersCount(e),t.isHorizontal()&&e.on("click",function(e){return e.stopPropagation()})})}},{key:"_initTooltip",value:function(e,t){this.isHorizontal()||se(i,"_initTooltip",this,3)([e,t])}},{key:"_afterLayoutChange",value:function(){se(i,"_afterLayoutChange",this,3)([]),this.isMobile?this._removeAllHorizontalTogglesFooter():this._addAllHorizontalTogglesFooter()}},{key:"_initDropdownObject",value:function(e,t){return new ie(e,t)}},{key:"_initToggle",value:function(e,t,i){var n=this,r=this.isHorizontal();t.hasClass("closed")&&i.hide(),r&&this._addHorizontalToggleFooter(e),e.off("click").on("click",function(o){o.stopPropagation(),r&&!n.isMobile&&e.hasClass("filter-title")?(n.maybeCloseAllHorizontalToggles(i),i.toggle(0,function(){t.toggleClass("opened").toggleClass("closed")})):n.toggle(i,t),i.trigger("yith_wcan_after_toggle_element",[t])})}},{key:"isHorizontalToggle",value:function(e){return!!this.isHorizontal()&&e.is(".collapsable")}},{key:"maybeCloseHorizontalToggle",value:function(e){var t=e.next(".filter-content");t.length&&this.isHorizontal()&&!this.isMobile&&e.hasClass("filter-title")&&this.isHorizontalToggle(e)&&(t.hide(),e.toggleClass("opened").toggleClass("closed"))}},{key:"maybeCloseAllHorizontalToggles",value:function(t){e(".yith-wcan-filters.horizontal.enhanced").find(".filter-title.collapsable").next(".filter-content").not(t).hide().prev(".filter-title").removeClass("opened").addClass("closed")}},{key:"_addHorizontalToggleFooter",value:function(t){var i=this,n=t.next(".filter-content");if(n.length&&this.isHorizontal()&&!this.isMobile&&t.hasClass("filter-title")&&this.isHorizontalToggle(t)&&!yith_wcan_shortcodes.instant_horizontal_filter){t.closest(".yith-wcan-filter");var r=e("<div/>",{class:"filter-content-footer"}),o=e("<a/>",{class:"apply-filters button alt",text:yith_wcan_shortcodes.labels.save});o.on("click",function(){i.maybeFilter(o),i.maybeCloseAllHorizontalToggles(t)}),r.append(o).appendTo(n)}}},{key:"_addAllHorizontalTogglesFooter",value:function(){var t=this;this.getFilters().each(function(){var i=e(this).find(".filter-title.collapsable");i.length&&t._addHorizontalToggleFooter(i)})}},{key:"_removeHorizontalToggleFooter",value:function(e){var t=e.next(".filter-content");t.length&&t.find(".filter-content-footer").remove()}},{key:"_removeAllHorizontalTogglesFooter",value:function(){var t=this;this.getFilters().each(function(){var i=e(this).find(".filter-title.collapsable");i.length&&t._removeHorizontalToggleFooter(i)})}},{key:"maybeUpdateFiltersCount",value:function(t){var i=t.find(".filter-title.collapsable");if(i.find(".filter-count").remove(),i.length&&this.isHorizontalToggle(i)&&this.isFilterActive(t)){var n=this.countActiveItems(t);if(n){var r=e("<span/>",{class:"filter-count",text:n});i.append(r)}}}}])&&re(n.prototype,r),o&&re(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o}(Q);jQuery(function(e){var t=[],i=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];e?n(e):(jQuery(".yith-wcan-filters").not(".enhanced").each(function(){new fe(jQuery(this))}),jQuery(".yith-wcan-active-filters").not(".enhanced").each(function(){new p(jQuery(this))}),jQuery(".yith-wcan-reset-filters").not(".enhanced").each(function(){new b(jQuery(this))}),jQuery(".yith-wcan-filters-opener").not(".enhanced").each(function(){new S(jQuery(this))}))},n=function(i){var n,a=e(document).find(".ywcas-overlay-wrapper-search");a.find(".yith-wcan-filters").not(".enhanced").each(function(){t.push(new fe(e(this),i))}),e.ajax({method:"GET",url:yith_wcan_shortcodes.base_url,data:{"wc-ajax":"yith_wcan_render_active_filters",security:yith_wcan_shortcodes.nonces.render_active_filters,_preset_filters:null!==(n=null==i?void 0:i.filters)&&void 0!==n?n:[]},success:function(e){if(e.success){var t=r(e.data,a);o(e.data,a,t>0)}}})},r=function(e,t){var i=yith_wcan_shortcodes.active_filters_position,n=e.active_filters,r=Object.keys(n);return r.forEach(function(e){var r=n[e],o="before_products"!==i?t.find("#preset_"+e).find(".filters-container form"):t.find(".ywcas-overlay-filled-content .ywcas-overlay-grid-block");o&&("before_filters"===i||"before_products"===i?o.prepend(r):o.append(r))}),t.find(".yith-wcan-active-filters").not(".enhanced").each(function(){new p(jQuery(this))}),r.length},o=function(e,t,i){var n=yith_wcan_shortcodes.reset_button_position,r=e.reset_button,o="before_products"!==n?t.find(".filters-container form"):t.find(".ywcas-overlay-filled-content .ywcas-overlay-grid-block");t.find(".yith-wcan-reset-filters").remove(),o&&i&&("before_filters"===n||"before_products"===n?o.prepend(r):"after_filters"===n?o.append(r):t.find(".yith-wcan-active-filters").append(r)),t.find(".yith-wcan-reset-filters").not(".enhanced").each(function(){new b(jQuery(this))})};e(document).on("yith_wcan_init_shortcodes",function(e){console.log(e),i()}).trigger("yith_wcan_init_shortcodes"),e(document).on("yith_plugin_fw_gutenberg_success_do_shortcode",function(e,t){t.startsWith("[yith_wcan_")&&i()}),globalThis.product_filter=new c,window.addEventListener("ywcasSearchCompleted",function(n){var r;n.detail.isSearching||((r=e(document).find(".ywcas-overlay-filled-content")).find(".yith-wcan-filters").removeClass("enhanced"),r.find(".yith-wcan-active-filters").remove(),r.find(".yith-wcan-reset-filters").remove(),t=[],i(n.detail))}),e(document).on("yith_wcan_filter_updated",function(i){var n={};t.forEach(function(t){n=e.extend(n,t.getFiltersProperties())});var r=new CustomEvent("ywcanFilterChanged",{detail:{filters:n}});window.dispatchEvent(r)})})})();