(()=>{"use strict";var e=jQuery,t=e("body"),i=function(t){var i;if(void 0!==e.fn.block){var r="#fff center center no-repeat";"undefined"!=typeof yith_wcan_shortcodes&&null!==(i=yith_wcan_shortcodes)&&void 0!==i&&i.loader&&(r="url('".concat(yith_wcan_shortcodes.loader,"') ").concat(r)),t.block({message:null,overlayCSS:{background:r,opacity:.7}})}},r=function(t){void 0!==e.fn.unblock&&t.unblock()};function n(e){return n="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},n(e)}function a(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,l(r.key),r)}}function o(e,t,i){return(t=l(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:String(t)}var s=function(){function l(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),o(this,"xhr",null),o(this,"doingAjax",!1),o(this,"originalSearch",location.search),o(this,"initialized",!1),o(this,"filtered",!1),this.initPopState(),this.initialized=!0}var s,c,u;return s=l,c=[{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,r){var n,a,o=this,l=e(i||"body");return(a=e(document).triggerHandler("yith_wcan_filters_parameters",[t]))&&(t=a),l&&this.block(l),n=this.buildUrl(t),yith_wcan_shortcodes.ajax_filters?(this.doingAjax=!0,this._doAjax(n).done((function(e){n=o.searchAlternativeUrl(e,n),o._beforeFilter(e,t),o.refreshFragments(i,r,e),o.pushUrlToHistory(n,e.pageTitle,t),o.originalSearch=location.search,l&&o.unblock(l),o._afterFilter(e,t),o.doingAjax=!1}))):(this.pushUrlToHistory(n,document.title,t),void(window.location=n))}},{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,r){e(".woocommerce-ordering").on("change","select.orderby",(function(){e(this).closest("form").submit()})),this.filtered=r&&!!Object.keys(r).length,this.filtered?t.addClass("filtered"):t.removeClass("filtered"),e(window).trigger("scroll"),e(document).trigger("yith-wcan-ajax-filtered",[i,r]).trigger("yith_wcwl_reload_after_ajax")}},{key:"buildUrl",value:function(t){var i,r=this,a=yith_wcan_shortcodes.query_param,o={},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"===n(t)&&Object.keys(t).length;if(yith_wcan_shortcodes.session_param&&(s=s.replace(new RegExp("/"+yith_wcan_shortcodes.session_param+"/[^/]*/"),"")),u&&(o[a]=1),this.originalSearch){var h=this.originalSearch.replace("?","").split("&").reduce((function(e,t){var i=t.split("=");if(2===i.length){if(r.isFilterParam(i[0]))return e;e[i[0]]=i[1]}return e}),{});o=e.extend(o,h)}return u&&(o=e.extend(o,t)),(i=Object.keys(o).reduce((function(e,t){var i=o[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,r){if(yith_wcan_shortcodes.change_browser_url&&!navigator.userAgent.match(/msie/i)){var n="pushState";r&&(n="replaceState"),window.history[n]({_yithWcan:!0,pageTitle:t,filters:i},"",e)}}},{key:"refreshFragments",value:function(t,i,r){var n=document.createElement("html"),a=e(n);if(n.innerHTML=r,t){var o,l=e(i),s=e(t);l.length&&(o=a.find(i)).length&&l.replaceWith(o.first()),s.length&&(o=a.find(t)).length&&s.replaceWith(o.first())}else{var c=e(yith_wcan_shortcodes.content);c.length?c.replaceWith(a.find(yith_wcan_shortcodes.content)):e("body").replaceWith(a.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 r(e)}},{key:"isFilterParam",value:function(t){var i,r=["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",[r]))&&(r=i),-1!==(r=r.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_")}}],c&&a(s.prototype,c),u&&a(s,u),Object.defineProperty(s,"prototype",{writable:!1}),l}();function c(e){return c="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},c(e)}function u(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,d(r.key),r)}}function h(e,t,i){return t&&u(e.prototype,t),i&&u(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function d(e){var t=function(e,t){if("object"!==c(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==c(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===c(t)?t:String(t)}var f=h((function t(i){var r,n,a;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,a=null,(n=d(n="$reset"))in r?Object.defineProperty(r,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):r[n]=a,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 p(e){return p="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},p(e)}function v(e){return function(e){if(Array.isArray(e))return y(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)return;if("string"==typeof e)return y(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return y(e,t)}(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 y(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function m(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */m=function(){return e};var e={},t=Object.prototype,i=t.hasOwnProperty,r=Object.defineProperty||function(e,t,i){e[t]=i.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function s(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,i){return e[t]=i}}function c(e,t,i,n){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),l=new $(n||[]);return r(o,"_invoke",{value:x(e,i,l)}),o}function u(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function f(){}function v(){}var y={};s(y,a,(function(){return this}));var g=Object.getPrototypeOf,_=g&&g(g(j([])));_&&_!==t&&i.call(_,a)&&(y=_);var b=v.prototype=d.prototype=Object.create(y);function w(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function n(r,a,o,l){var s=u(e[r],e,a);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==p(h)&&i.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(h).then((function(e){c.value=e,o(c)}),(function(e){return n("throw",e,o,l)}))}l(s.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function x(e,t,i){var r="suspendedStart";return function(n,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===n)throw a;return O()}for(i.method=n,i.arg=a;;){var o=i.delegate;if(o){var l=F(o,i);if(l){if(l===h)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===r)throw r="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r="executing";var s=u(e,t,i);if("normal"===s.type){if(r=i.done?"completed":"suspendedYield",s.arg===h)continue;return{value:s.arg,done:i.done}}"throw"===s.type&&(r="completed",i.method="throw",i.arg=s.arg)}}}function F(e,t){var i=t.method,r=e.iterator[i];if(void 0===r)return t.delegate=null,"throw"===i&&e.iterator.return&&(t.method="return",t.arg=void 0,F(e,t),"throw"===t.method)||"return"!==i&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+i+"' method")),h;var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function C(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function $(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:O}}function O(){return{value:void 0,done:!0}}return f.prototype=v,r(b,"constructor",{value:v,configurable:!0}),r(v,"constructor",{value:f,configurable:!0}),f.displayName=s(v,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,v):(e.__proto__=v,s(e,l,"GeneratorFunction")),e.prototype=Object.create(b),e},e.awrap=function(e){return{__await:e}},w(k.prototype),s(k.prototype,o,(function(){return this})),e.AsyncIterator=k,e.async=function(t,i,r,n,a){void 0===a&&(a=Promise);var o=new k(c(t,i,r,n),a);return e.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},w(b),s(b,l,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),i=[];for(var r in t)i.push(r);return i.reverse(),function e(){for(;i.length;){var r=i.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=j,$.prototype={constructor:$,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(C),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(i,r){return o.type="throw",o.arg=e,t.next=i,r&&(t.method="next",t.arg=void 0),!!r}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(l&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),C(i),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;C(i)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:j(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),h}},e}function g(e,t,i,r,n,a,o){try{var l=e[a](o),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(r,n)}function _(e){return function(){var t=this,i=arguments;return new Promise((function(r,n){var a=e.apply(t,i);function o(e){g(a,r,n,o,l,"next",e)}function l(e){g(a,r,n,o,l,"throw",e)}o(void 0)}))}}function b(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,k(r.key),r)}}function w(e,t,i){return(t=k(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function k(e){var t=function(e,t){if("object"!==p(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==p(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===p(t)?t:String(t)}var x=function(){function t(i,r){var n,a,o,l;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),w(this,"$originalSelect",null),w(this,"_items",[]),w(this,"$_main",null),w(this,"$_label",null),w(this,"$_dropdown",null),w(this,"$_search",null),w(this,"$_showMore",null),w(this,"$_items",null),w(this,"paginate",!1),w(this,"hasMore",!1),w(this,"needsRefresh",!0),w(this,"multiple",!1),w(this,"currentPage",1),w(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===(n=yith_wcan_shortcodes.labels)||void 0===n?void 0:n.empty_option),searchPlaceholder:null===(a=yith_wcan_shortcodes.labels)||void 0===a?void 0:a.search_placeholder,noItemsFound:null===(o=yith_wcan_shortcodes.labels)||void 0===o?void 0:o.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,r),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")}}var i,r,n,a,o;return i=t,r=[{key:"_hideSelect",value:function(){this.$originalSelect.hide()}},{key:"_initTemplate",value:function(){var t=e("<div/>",{class:"yith-wcan-dropdown closed"}),i=e("<div/>",{class:"dropdown-label",html:this.getLabel()}),r=e("<div>",{class:"dropdown-wrapper"}),n=e("<ul/>",{class:"matching-items filter-items"});r.append(n),t.append(i).append(r),this.options.showSearch&&this._initSearchTemplate(r),this.options.paginate&&this._initShowMoreTemplate(r),this.$originalSelect.after(t),this.$_main=t,this.$_label=i,this.$_dropdown=r,this.$_items=n}},{key:"_initSearchTemplate",value:function(t){var i=e("<div/>",{class:"search-field-container"}),r=e("<input/>",{name:"s",class:"search-field",type:"search",placeholder:this.options.labels.searchPlaceholder}).attr("autocomplete","off");i.append(r).prependTo(t),this.$_search=r}},{key:"_initShowMoreTemplate",value:function(t){var i,r=e("<a/>",{class:"show-more",text:null===(i=this.options.labels.showMore)||void 0===i?void 0:i.replace("%d",this.options.perPage)});r.on("click",this.loadNextPage.bind(this)).hide(),t.append(r),this.$_showMore=r}},{key:"_initActions",value:function(){var t,i,r=this,n=this;null===(t=this.$_main)||void 0===t||t.on("click",(function(e){e.stopPropagation(),n.toggleDropdown()})),this.$_dropdown.on("click",(function(e){e.stopPropagation()})),null===(i=this.$_search)||void 0===i||i.on("keyup search change",(function(){return r.paginate=!1,r._populateItems().then((function(){r.needsRefresh=!0})),!1})),this.$_items.on("change",":input",(function(){var t,i=e(this).closest("li"),r=i.data("value");if(i.hasClass("disabled")&&!n.isValueSelected(r))return!1;i.toggleClass("active"),t=i.hasClass("active"),n._changeItemStatus(r,t)})),this.$_items.on("click","li:not(.checkbox) a",(function(t){var i,r=e(this).closest("li"),a=r.data("value");if(t.preventDefault(),r.hasClass("disabled")&&!n.isValueSelected(a))return!1;r.toggleClass("active"),(i=r.hasClass("active"))&&r.siblings().removeClass("active"),n._changeItemStatus(a,i)})),this.$_items.on("click","label > a",(function(t){var i=e(this).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,r){var n=e(r);return!!n.data("dropdown")&&!n.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:(o=_(m().mark((function t(i){var r,n,a=this;return m().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._items.length||this.getOptions().each((function(t,i){var r=e(i),n=r.val(),o=r.html();a._items.push({value:n,label:o})})),t.next=3,this.getMatchingElements(i);case 3:return r=t.sent,(n=this.paginate?this.options.perPage:0)&&r.length>n&&(this.hasMore=!0,r=r.slice(0,n)),t.abrupt("return",r);case 7:case"end":return t.stop()}}),t,this)}))),function(e){return o.apply(this,arguments)})},{key:"getMatchingElements",value:function(e){var t=this,i=this._items;return new Promise((function(r){i=e?i.filter((function(t){var i=t.label,r=t.value,n=new RegExp(".*"+e+".*","i");return n.test(r)||n.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(v(i),v(e))),r(t._formatItems(i))})):r(t._formatItems(i))}))}},{key:"_formatItems",value:function(e){var t=this,i=[];return e.filter((function(e){var r=e.value,n=e.label;return-1===i.indexOf(r)&&(i.push(r),t.getOptionByValue(r).length||t.$originalSelect.append('<option class="filter-item" value="'.concat(r,'">').concat(n,"</option>")),!0)}))}},{key:"_generateItem",value:function(t,i){var r,n=this.isValueSelected(t),a=this.getOptionByValue(t),o=e("<li/>",{"data-value":t,class:a.length?a.attr("class"):""});if(a.length){var l=a.data("template"),s=a.data("count");i=l||i,s&&(i+=s)}if(r=e("<a/>",{href:a.length?a.data("filter_url"):"#",html:i,rel:"nofollow","data-title":a.length?a.data("title"):""}),this.multiple){var c=e("<input/>",{type:"checkbox",value:t}),u=e("<label>");c.prop("checked",n),u.prepend(c).append(r),o.append(u).addClass("checkbox")}else o.append(r);return n?o.addClass("active"):o.removeClass("active"),o}},{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,r=e.value;return t._generateItem(r,i)}))),t.$originalSelect.trigger("yith_wcan_dropdown_updated"),t.needsRefresh=!1,t.paginate&&t.hasMore&&t._showLoadMore()}))}},{key:"loadNextPage",value:(a=_(m().mark((function e(){var t=this;return m().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.paginate=!1,this._populateItems().then((function(){t.hasMore=!1}));case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.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),r=i.data("template");r=r||i.html().replace(/\([0-9]*\)/,""),t.push(r)})),t}},{key:"getSelectedValues",value:function(){var t=[];return this.getSelectedOptions().each((function(){t.push(e(this).val())})),t}},{key:"destroy",value:function(){}}],r&&b(i.prototype,r),n&&b(i,n),Object.defineProperty(i,"prototype",{writable:!1}),t}();function F(e,t){var i="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!i){if(Array.isArray(e)||(i=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);"Object"===i&&e.constructor&&(i=e.constructor.name);if("Map"===i||"Set"===i)return Array.from(e);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){i&&(e=i);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}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 a,o=!0,l=!1;return{s:function(){i=i.call(e)},n:function(){var e=i.next();return o=e.done,e},e:function(e){l=!0,a=e},f:function(){try{o||null==i.return||i.return()}finally{if(l)throw a}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function C(e){return C="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},C(e)}function $(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */$=function(){return e};var e={},t=Object.prototype,i=t.hasOwnProperty,r=Object.defineProperty||function(e,t,i){e[t]=i.value},n="function"==typeof Symbol?Symbol:{},a=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",l=n.toStringTag||"@@toStringTag";function s(e,t,i){return Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,i){return e[t]=i}}function c(e,t,i,n){var a=t&&t.prototype instanceof d?t:d,o=Object.create(a.prototype),l=new S(n||[]);return r(o,"_invoke",{value:w(e,i,l)}),o}function u(e,t,i){try{return{type:"normal",arg:e.call(t,i)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var h={};function d(){}function f(){}function p(){}var v={};s(v,a,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(j([])));m&&m!==t&&i.call(m,a)&&(v=m);var g=p.prototype=d.prototype=Object.create(v);function _(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function n(r,a,o,l){var s=u(e[r],e,a);if("throw"!==s.type){var c=s.arg,h=c.value;return h&&"object"==C(h)&&i.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,o,l)}),(function(e){n("throw",e,o,l)})):t.resolve(h).then((function(e){c.value=e,o(c)}),(function(e){return n("throw",e,o,l)}))}l(s.arg)}var a;r(this,"_invoke",{value:function(e,i){function r(){return new t((function(t,r){n(e,i,t,r)}))}return a=a?a.then(r,r):r()}})}function w(e,t,i){var r="suspendedStart";return function(n,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===n)throw a;return O()}for(i.method=n,i.arg=a;;){var o=i.delegate;if(o){var l=k(o,i);if(l){if(l===h)continue;return l}}if("next"===i.method)i.sent=i._sent=i.arg;else if("throw"===i.method){if("suspendedStart"===r)throw r="completed",i.arg;i.dispatchException(i.arg)}else"return"===i.method&&i.abrupt("return",i.arg);r="executing";var s=u(e,t,i);if("normal"===s.type){if(r=i.done?"completed":"suspendedYield",s.arg===h)continue;return{value:s.arg,done:i.done}}"throw"===s.type&&(r="completed",i.method="throw",i.arg=s.arg)}}}function k(e,t){var i=t.method,r=e.iterator[i];if(void 0===r)return t.delegate=null,"throw"===i&&e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method)||"return"!==i&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+i+"' method")),h;var n=u(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,h;var a=n.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function F(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function j(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,n=function t(){for(;++r<e.length;)if(i.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return n.next=n}}return{next:O}}function O(){return{value:void 0,done:!0}}return f.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:f,configurable:!0}),f.displayName=s(p,l,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,s(e,l,"GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},_(b.prototype),s(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,i,r,n,a){void 0===a&&(a=Promise);var o=new b(c(t,i,r,n),a);return e.isGeneratorFunction(i)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},_(g),s(g,l,"Generator"),s(g,a,(function(){return this})),s(g,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),i=[];for(var r in t)i.push(r);return i.reverse(),function e(){for(;i.length;){var r=i.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=j,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(F),!e)for(var t in this)"t"===t.charAt(0)&&i.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(i,r){return o.type="throw",o.arg=e,t.next=i,r&&(t.method="next",t.arg=void 0),!!r}for(var n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var l=i.call(a,"catchLoc"),s=i.call(a,"finallyLoc");if(l&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(l){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.finallyLoc===e)return this.complete(i.completion,i.afterLoc),F(i),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc===e){var r=i.completion;if("throw"===r.type){var n=r.arg;F(i)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,i){return this.delegate={iterator:j(e),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=void 0),h}},e}function j(e,t,i,r,n,a,o){try{var l=e[a](o),s=l.value}catch(e){return void i(e)}l.done?t(s):Promise.resolve(s).then(r,n)}function O(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function P(e){for(var t=1;t<arguments.length;t++){var i=null!=arguments[t]?arguments[t]:{};t%2?O(Object(i),!0).forEach((function(t){E(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):O(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function A(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,L(r.key),r)}}function E(e,t,i){return(t=L(t))in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function L(e){var t=function(e,t){if("object"!==C(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==C(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===C(t)?t:String(t)}var T=function(){function t(i){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),E(this,"preset",!1),E(this,"$preset",!1),E(this,"target",!1),E(this,"$target",!1),E(this,"$filters",!1),E(this,"$filterButtons",!1),E(this,"modalElements",{}),E(this,"activeFilters",!1),E(this,"isMobile",!1),E(this,"sliderTimeout",!1),E(this,"originalFilters",null),E(this,"dirty",!1),E(this,"loaded",void 0),E(this,"inhibitFilters",!1),this.preset="#"+i.attr("id"),this.$preset=i,this.target=this.$preset.data("target"),this.$target=!!this.target&&e(this.target),this._regiterStatus(),this._initFilterButton(),this._initFilters(),this._initResponsive(),this._initActions(),this.$preset.data("preset",this).addClass("enhanced").trigger("yith_wcan_preset_initialized",[this])}var n,a,o;return n=t,a=[{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,r=this,n=function(i){var n=e(this),a=n.closest(".yith-wcan-filter"),o=!!a.length&&"yes"===a.data("multiple"),l=n.closest(".filter-item"),s=l.length?a.find(".filter-item").not(l):[];return!a.is(".filter-price-slider")&&!(l.is(".disabled")&&!l.is(".active"))&&(i.preventDefault(),s.length&&!o&&s.removeClass("active").children("label").find(":input").prop("checked",!1).parent(".checked").removeClass("checked"),l.length&&l.toggleClass("active"),r.activeFilters=!1,r.maybeFilter(t),r.maybeToggleClearAllFilters(),void r.maybeToggleClearFilter(a))};return 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")||n.call(this,t)})),t.on("change",":input",(function(t){var i=e(this),r=i.closest(".filter-item");if(r.is(".disabled")&&!r.is(".active"))return i.prop("checked",!1),!1;n.call(this,t)})),t.on("click","label > a",(function(t){var i=e(this),r=i.closest(".filter-item");if(t.preventDefault(),r.is(".disabled")&&!r.is(".active"))return!1;var n=i.parent().find(":input");(n.is('[type="radio"]')||n.is('[type="checkbox"]'))&&n.prop("checked",!n.prop("checked")),n.change()})),i._initFilterChildren(t),i.maybeShowClearFilter(t),t}))}},{key:"_initFilterChildren",value:function(t){var i,r=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");r._initCustomInput(i)})))}},{key:"_maybeLoadFilter",value:function(t){var i=this;return t.hasClass("filter-placeholder")?new Promise((function(r){var n;e.ajax({method:"GET",url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_render_filter",_preset_id:i.getId(),_filter_id:t.data("filter-id"),security:null===(n=yith_wcan_shortcodes.nonces)||void 0===n?void 0:n.render_filter},i.originalFilters)}).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:""))}))})):Promise.resolve(t)}},{key:"_loadFilter",value:function(t,i){if(!i)return t.remove();var r=e(i);return t.replaceWith(r),this.$filters=!1,r}},{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,r=e(this),n=null,a=r.outerWidth(),o=0;if(!i||"top"!==i&&"right"!==i){var l=r.closest(".filter-item");i=l.hasClass("color")||l.hasClass("label")?"top":"right"}n=e("<span>",{class:"yith-wcan-tooltip",html:r.data("title")}),r.append(n),t=n.outerWidth()+6,n.outerWidth(t),o="top"===i?(a-t)/2:a+15,n.css({left:o.toFixed(0)+"px"}).fadeIn(200),r.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 r=this,n=i.data("has-more");this._initDropdownObject(i,P({paginate:!0,hasMore:n,perPage:parseInt(yith_wcan_shortcodes.terms_per_page)},n?{getElements:function(e){var i,n=this;return(i=$().mark((function i(){return $().wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(!n.paginate&&n.hasMore||e){i.next=2;break}return i.abrupt("return",n._items);case 2:return i.abrupt("return",r._getTerms(t,e));case 3:case"end":return i.stop()}}),i)})),function(){var e=this,t=arguments;return new Promise((function(r,n){var a=i.apply(e,t);function o(e){j(a,r,n,o,l,"next",e)}function l(e){j(a,r,n,o,l,"throw",e)}o(void 0)}))})()}}:{}))}}},{key:"_initDropdownObject",value:function(e,t){return new x(e,t)}},{key:"_initPriceSlider",value:function(e){var t=this;if(e.hasClass("filter-price-slider")){var i=this,r=e.find(".price-slider"),n=r.find(".price-slider-min"),a=r.find(".price-slider-max"),o=parseFloat(r.data("min")),l=parseFloat(r.data("max")),s=parseFloat(n.val()),c=parseFloat(a.val()),u=parseFloat(r.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:o,max:l,step:u,from:s,to:c,min_interval:u,values_separator:" - ",prettify:function(e){return t.formatPrice(e)},onChange:function(e){n.val(e.from),a.val(e.to)},onFinish:h}),n.add(a).off("change").on("change",h).on("keyup",(function(e){if(!e.key.match(/[0-9,.]/))return e.preventDefault(),!1;n.val()&&a.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,n){var a=this;return new Promise((function(o){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return r(t)},url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_get_filter_terms",_preset_id:a.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.get_filter_terms,search:n},a.originalFilters)}).then((function(e){var t,i=e.success?null==e||null===(t=e.data)||void 0===t?void 0:t.items:{};o(i)}))}))}},{key:"_loadItems",value:function(t){var n=this;return new Promise((function(a){e.ajax({method:"GET",beforeSend:function(){return i(t)},complete:function(){return r(t)},url:yith_wcan_shortcodes.base_url,data:P({"wc-ajax":"yith_wcan_render_remaining_terms",_preset_id:n.getId(),_filter_id:t.data("filter-id"),security:yith_wcan_shortcodes.nonces.render_remaining_terms},n.originalFilters)}).then((function(e){var i,r=t.find(".filter-content").children(".filter-items");r.append(e.success?null==e||null===(i=e.data)||void 0===i?void 0:i.html:""),n._initFilterChildren(t),a(r)}))}))}},{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 r=this,n=t.find(".active");n.length&&(n.parents(".hierarchy-collapsable").removeClass("closed").addClass("opened"),n.hasClass("hierarchy-collapsable")&&yith_wcan_shortcodes.show_current_children&&n.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),r._initToggle(i,t,t.children("ul.filter-items"))}}))}}},{key:"_initToggle",value:function(e,t,i){var r=this;t.hasClass("toggle-initialized")||(t.hasClass("closed")&&i.hide(),e.off("click").on("click",(function(e){e.stopPropagation(),e.preventDefault(),r.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),r=i.attr("type"),n="".concat(r,"button");"checkbox"!==r&&"radio"!==r||i.closest(".".concat(n)).length||(i.is(":checked")&&(n+=" checked"),t=e("<span/>",{class:n}),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(){this.originalFilters=this.mergeProperties(yith_wcan_shortcodes.query_vars,this.getFiltersProperties())}},{key:"_afterLayoutChange",value:function(){var t,i,r=this;this.isMobile?(this.$preset.addClass("filters-modal").attr("role","dialog").attr("tabindex","-1").hide(),this._addCloseModalButton(),this._addApplyFiltersModalButton(),this.loaded.then((function(){return r._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 r._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,t;null===(e=this.modalElements)||void 0===e||null===(t=e.closeButton)||void 0===t||t.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,t;null===(e=this.modalElements)||void 0===e||null===(t=e.applyFiltersButton)||void 0===t||t.remove()}},{key:"_switchToCollapsables",value:function(){var t=this;this.getFilters().each((function(){var i=e(this),r=i.find(".filter-title");r.length&&!r.hasClass("collapsable")&&(r.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,r){return t.isFilterActive(e(r))})).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,r){return t.isFilterActive(e(r))})).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,r;this.dirty?null===(i=this.$filterButtons)||void 0===i||i.show():null===(r=this.$filterButtons)||void 0===r||r.hide()}}},{key:"filter",value:function(){var t,i,r,n=this,a=null===(t=window)||void 0===t?void 0:t.product_filter;null==a||null===(i=a.doFilter(this.getFiltersProperties(),this.target,this.preset))||void 0===i||i.done((function(){var t=e(n.preset);if(t.length&&yith_wcan_shortcodes.scroll_top){var i=t.offset().top;if(yith_wcan_shortcodes.scroll_target){var r=e(yith_wcan_shortcodes.scroll_target);i=r.length?r.offset().top:i}else n.isMobile&&(i=100);e("body, html").animate({scrollTop:i-100})}n._regiterStatus(),n.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 r=e.find(".filter-dropdown");if(r.length){var n=r.val();t="object"===C(n)?!(null==n||!n.length):!!n;break}case"stock_sale":t=e.find(".filter-item").filter(".active").length;break;case"price_slider":var a=parseFloat(e.find(".price-slider").data("step")),o=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-o)>=a||Math.abs(c-l)>=a;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 r=i.val();t="object"===C(r)?null==r?void 0:r.length:+!!r;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,r,n=t.data("filter-type"),a="yes"===t.data("multiple"),o=t.find(".filter-dropdown"),l={};switch(n){case"tax":var s=[],c=t.data("taxonomy"),u=0===c.indexOf("filter"),h=t.data("relation");if(o.length?a?s=o.val():s.push(o.val()):s=(r=t.find(".filter-item").filter(".active").children("a, label")).get().reduce((function(t,i){var r;return(r=(i=e(i)).is("label")?i.find(":input").val():i.data("term-slug"))?(t.push(r),t):t}),s),a){var d=u||"and"!==h?",":"+";l[c]=s.join(d)}else l[c]=s.pop();u&&(l[c.replace("filter_","query_type_")]=h);break;case"review":o.length?l.rating_filter=o.val():(r=t.find(".filter-item").filter(".active").children("a, label"),a?l.rating_filter=r.get().reduce((function(t,i){var r;return(r=(i=e(i)).is("label")?i.find(":input").val():i.data("rating"))?(t.push(r),t):t}),[]).join(","):(r=r.first(),l.rating_filter=r.is("label")?r.find(":input").val():r.data("rating")));break;case"price_range":o.length?a?l.price_ranges=o.val().join(","):(l.min_price=o.val().split("-")[0],l.max_price=o.val().split("-")[1]):(r=t.find(".filter-item").filter(".active").children("a, label"),a?l.price_ranges=r.get().reduce((function(t,i){var r=e(i).data("range-min"),n=e(i).data("range-max");return t+=(n?"".concat(r,"-").concat(n):r)+","}),"").replace(/^(.*),$/,"$1"):(l.min_price=parseFloat(r.first().data("range-min")),l.max_price=parseFloat(r.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 r=e(this);if(i.isFilterActive(r)){var n=i.getFilterProperties(r);t=i.mergeProperties(t,n,r)}})),t}},{key:"getFiltersByProperties",value:function(t){var i=this;return this.getFilters().filter((function(){var r=e(this);if(i.isFilterActive(r)){var n,a=i.getFilterProperties(r),o=!1,l=F(t);try{for(l.s();!(n=l.n()).done;){var s=n.value;if(["min_price","max_price","price_ranges"].includes(s)&&(a.min_price||a.price_ranges)){o=!0;break}if(a[s]){o=!0;break}}}catch(e){l.e(e)}finally{l.f()}return o}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,r){var n=t.data("filter-type"),a=t.find(".filter-item"),o=a.filter(".active"),l=t.find(".filter-dropdown");switch(this.inhibitFilters=!0,n){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?o.each((function(){var t=e(this),r=t.children("label"),n=t.children("a");(r.length?r.find(":input").val():n.data("term-slug")).toString()===i[s].toString()&&(t.children("label").children("a").click(),t.removeClass("active"))})):(o.children("label").children("a").click(),o.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?o.each((function(){var t=e(this),r=t.children("label"),n=t.children("a");(r.length?r.find(":input").val():n.data("rating"))===i.rating_filter&&(t.children("label").children("a").click(),t.removeClass("active"))})):(o.children("label").children("a").click(),o.removeClass("active"));break;case"price_range":l.length?(i?l.find("option").each((function(){var t=e(this),r=i.min_price+(i.max_price?"-".concat(i.max_price):"");t.val()===r&&t.prop("selected",!1)})):l.find("option").prop("selected",!1),l.change()):i?o.each((function(){var t,r,n=e(this),a=n.children("label"),o=n.children("a");r=a.length?a.find(":input").val():o.data("min_price")+(o.data("max_price")?"-"+o.data("max_price"):""),i.min_price?t=i.min_price+(i.max_price?"-"+i.max_price:""):i.price_ranges&&(t=i.price_ranges),r===t&&(n.children("label").children("a").click(),n.removeClass("active"))})):(o.children("label").children("a").click(),o.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(),a.removeClass("active"));break;default:a.removeClass("active")}this.inhibitFilters=!1,this.activeFilters=!1,r&&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 r=this,n=this.getFiltersByProperties(Object.keys(t));return!!n.length&&(n.each((function(){var n=e(this);r.deactivateFilter(n,t,i)})),!0)}},{key:"toggle",value:function(e,t,i){void 0===i&&(i=t.hasClass("closed"));var r=i?"opened":"closed",n=i?"closed":"opened";e[i?"slideDown":"slideUp"](400,(function(){t.addClass(r).removeClass(n),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,r,n;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===(r=yith_wcan_shortcodes.currency_format)||void 0===r?void 0:r.thousand,precision:0,format:null===(n=yith_wcan_shortcodes.currency_format)||void 0===n?void 0:n.format})),e}},{key:"mergeProperties",value:function(t,i,r){for(var n in i)if(i.hasOwnProperty(n)&&t[n]){switch(n){case"rating_filter":case"min_price":case"max_price":case"onsale_filter":case"instock_filter":case"orderby":t[n]=i[n];break;default:if(0===n.indexOf("query_type_"))t[n]=i[n];else{var a=(null==r?void 0:r.data("relation"))||"and",o=0===n.indexOf("filter_"),l=o||"and"!==a?",":"+",s=t[n].replace(",",l)+l+i[n].replace(",",l);if(s=s.split(l).filter((function(e,t,i){return i.indexOf(e)===t})).join(l),t[n]=s,o){var c=n.replace("filter_","query_type_");t[c]="and",i[c]="and"}}}delete i[n]}return e.extend(t,i),t}}],a&&A(n.prototype,a),o&&A(n,o),Object.defineProperty(n,"prototype",{writable:!1}),t}();jQuery((function(e){e(document).on("yith_wcan_init_shortcodes yith_plugin_fw_gutenberg_success_do_shortcode",(function(){e(".yith-wcan-filters").not(".enhanced").each((function(){new T(e(this))})),e(".yith-wcan-reset-filters").not(".enhanced").each((function(){new f(e(this))}))})).trigger("yith_wcan_init_shortcodes"),globalThis.product_filter=new s}))})();