"use strict";null==typeof woostifyEvent&&(woostifyEvent={}),woostifyEvent.ajax_call=0;let listFilter={};const woostifyFormatPrice=function(e){const t={currency_symbol:"$",price_format:"right_space",decimal_separator:".",thousand_separator:",",decimals:2,...{currency:woostify_product_filter.currency,currency_symbol:woostify_product_filter.currency_symbol,price_format:woostify_product_filter.currency_format,decimal_separator:woostify_product_filter.currency_format_decimal_sep,thousand_separator:woostify_product_filter.currency_format_thousand_sep,decimals:woostify_product_filter.currency_format_num_decimals,locale:woostify_product_filter.locale.replace("_","-")}};let[o,r]=e.toFixed(t.decimals).split(".");o=o.replace(/\B(?=(\d{3})+(?!\d))/g,t.thousand_separator);let i=t.decimals>0?`${o}${t.decimal_separator}${r}`:o;switch(t.price_format){case"left":i=t.currency_symbol+i;break;case"right":i+=t.currency_symbol;break;case"left_space":i=t.currency_symbol+" "+i;break;case"right_space":i=i+" "+t.currency_symbol}return i},woostifyFilterDatePicker=function(){let e=document.querySelector(".w-product-filter[data-type=date-range] .w-product-filter-inner");if(!e)return;let t={mode:"dp-below"};"undefined"!=typeof woostify_datepicker_data&&(t.lang={},t.lang.months=woostify_datepicker_data.months,t.lang.days=woostify_datepicker_data.days,t.lang.today=woostify_datepicker_data.today,t.lang.clear=woostify_datepicker_data.clear,t.lang.close=woostify_datepicker_data.close);let o=e.querySelectorAll(".w-filter-date-picker");for(let e=0,r=o.length;e";t.insertAdjacentHTML("beforeend",o)}));let t=document.querySelectorAll('[data-type="checkbox"] .expand-btn');t.length&&t.forEach((function(e){let t=e.closest(".w-filter-item-wrap");t&&(t.classList.add("is-parent-item"),e.onclick=function(){e.innerHTML=woostify_product_filter.expand_icon===e.innerHTML?woostify_product_filter.collapse_icon:woostify_product_filter.expand_icon;let t=e.closest(".w-filter-item-wrap");if(!t)return;let o=t.nextElementSibling;if(!o||!o.classList.contains("w-filter-item-depth"))return;o.classList.contains("visible")?o.classList.remove("visible"):o.classList.add("visible");let r=e.closest(".w-product-filter ");r.style.height="auto";let i=r.getBoundingClientRect().height;r.style.height=i+"px"})}))},woostifyToggleSoftLimit=function(){let e=document.querySelectorAll(".w-product-filter .w-filter-toggle-btn");e.length&&e.forEach((function(e){e.onclick=function(){let t=e.parentNode.querySelector(".w-filter-item-overflow");if(!t)return;let o=e.parentNode.querySelector(".w-filter-toggle-btn.w-filter-hidden");o&&o.classList.remove("w-filter-hidden"),e.classList.add("w-filter-hidden"),t.classList.contains("w-filter-hidden")?t.classList.remove("w-filter-hidden"):t.classList.add("w-filter-hidden");let r=e.closest(".w-product-filter ");r.style.height="auto";let i=r.getBoundingClientRect().height;r.style.height=i+"px"}}))},woostifyUpdateFilters=function(e){for(let t in e)Array.isArray(e[t])&&!e[t].length&&delete e[t];if(!Object.keys(e).length)return{};if(1===Object.keys(e).length)void 0===e.first_active_filter?e.first_active_filter=Object.keys(e)[0]:delete e.first_active_filter;else{let t=e.first_active_filter;void 0!==t&&void 0===e[t]&&delete e.first_active_filter}return e},woostifyBuildQueryString=function(e){let t=woostify_product_filter.filters_url,o=Object.keys(e),r={};for(let i=0,n=o.length;i=d.length?(d.forEach((function(e,t){var r=(u[t][0]+u[t][1])/2,i=f[t].filter(((e,t,o)=>o.indexOf(e)===t));s.innerHTML=i.join(o),s.style.visibility="visible",s.style.transform="translate(-50%, -44%)",s.style.left=r+"%",s.style.transition="none"})),r.forEach((function(e){e.style.visibility="hidden"}))):(s.style.visibility="hidden",r.forEach((function(e){e.style.visibility="visible"})))}))},filterData=function(e,t){let o=document.querySelectorAll(".w-product-filter[data-type]");o.length&&o.forEach((function(o){let r=o.getAttribute("data-type"),i=o.getAttribute("data-id"),n="tmp_"+i;switch(window[n]||(window[n]=void 0===e[i]?[]:e[i]),listFilter[i]=r,r){case"search":let r=o.querySelector(".w-product-filter-text-field"),l=o.querySelector(".w-product-filter-search-icon");if(!r||!l)return;r.onkeyup=function(e){13===e.keyCode&&l.click()},l.onclick=function(){let o=r.value.trim(),n=r.getAttribute("data-value")||"";o&&n!=o&&(r.setAttribute("data-value",o),e[i]=o,document.body.dispatchEvent(t))};break;case"date-range":let c=o.querySelector("[data-from]"),a=o.querySelector("[data-to]"),s=o.querySelector(".w-filter-item-submit");if(!c||!a||!s)return;s.onclick=function(){if(!c.value||!a.value)return;let o=[];o[0]=c.value,o[1]=a.value,e[i]=o,document.body.dispatchEvent(t)};break;case"rating":let d=o.querySelectorAll(".w-filter-rating-item");if(!d.length)return;for(let r=0,n=d.length;r=m.max)break;let b={tooltips:[{to:function(e){return woostifyFormatPrice(e)},from:function(e){return woostifyFormatPrice(e)}},{to:function(e){return woostifyFormatPrice(e)},from:function(e){return woostifyFormatPrice(e)}}],connect:!0,start:w,step:1,range:m,format:{from:function(e){return Math.round(e)},to:function(e){return Math.round(e)}}};noUiSlider.create(p,b).on("change",(function(r,n,l,c,a,s){if(o.querySelector(".w-filter-range-slider-reset").style.display="block",woostifyToggleFilter(),h){let t=[],o=r[0]-m.min,n=m.max-r[1];t[0]=h[0]+o,t[1]=h[1]-n,e["origin_"+i]=t}e[i]=r,document.body.dispatchEvent(t)})),g&&(g.onclick=function(){let e=g.previousElementSibling;if(!e)return;if(!e.querySelector(".noUi-handle-upper"))return;let t=document.querySelector('.w-filter-key-remove[data-id="'+i+'"]');t&&t.click()}),mergeTooltips(p,2," - ");break;case"check-range":let S=o.querySelectorAll('[type="checkbox"]');if(!S.length)return;for(let o=0,r=S.length;o');if(document.body.classList.contains("filter-updating"))return;document.body.classList.add("filter-updating");let{responseBody:f,domParseResponse:y,fetchOptions:p}=infScroll.options;"function"==typeof p&&(p=p());let g=new DOMParser;history.pushState(null,"",n),fetch(n,p).then((e=>{if(!e.ok){let t=new Error(e.statusText);return infScroll.onPageError(t,n,e),{response:e}}return e[f]().then((t=>{"text"==f&&y&&(t=g.parseFromString(t,"text/html"));var r=t.getElementById("view").innerHTML;jQuery("#view").empty().append(r);var i={top:0,path:n,title:e.title};infScroll.scrollPages.unshift(i);for(var u=1;u{console.log(e)}))}():function(e){let r=document.body.getBoundingClientRect().top,i=t.getBoundingClientRect().top,u=-1*r- -1*i-n;i');e.detail&&(c=1);document.body.classList.add("filter-updating");let y=woostifyBuildQueryString(l),p=Object.fromEntries(new URLSearchParams(location.search));for(const e in y)!y[e].length&&e in p&&(delete p[e],delete y[e]);let g={...p,...y},w=new URLSearchParams(g).toString();if(history.pushState){let e=void 0!==g.lang?"?lang="+g.lang:"";history.pushState(null,null,w?"?"+w:window.location.pathname+e)}let m=document.querySelector(".orderby, .w-product-filter-select-field.w-filter-ordering"),h=m&&0!=m.length?m.value:"",b=p.orderby||t.getAttribute("data-posts-orderby");b=""!=h?h:b;let S={action:"woostify_product_filter",ajax_nonce:woostify_product_filter.ajax_nonce,per_page:t.getAttribute("data-posts")||"",paged:c,term_id:woostify_product_filter.term_id,taxonomy:woostify_product_filter.taxonomy,list_filter:JSON.stringify(listFilter),search_param:p.s||"",data:JSON.stringify(woostifyUpdateFilters(l)),orderby:b||"menu_order title",order:t.getAttribute("data-posts-order")||"",exclude_products:t.getAttribute("data-exclude-products")||"",include_terms:t.getAttribute("data-include-terms")||"",exclude_terms:t.getAttribute("data-exclude-terms")||"",page_id:t.getAttribute("data-page-id")||""};S=new URLSearchParams(S).toString();let v=new Request(woostify_product_filter.ajax_url+location.search,{method:"POST",body:S,credentials:"same-origin",headers:new Headers({"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"})});woostifyEvent.ajax_call=1,fetch(v).then((function(e){if(200!==e.status)throw console.log("Status Code: "+e.status),e;return e.json()})).then((function(e){if(!e.success)return;let r=e.data,i=t.querySelector(".woostify-sorting .woocommerce-result-count"),n=t.querySelector(".products"),s=t.querySelector(".woocommerce-pagination"),d=(document.querySelector(".shop-widget"),jQuery("#woostify-overlay"),jQuery("html"),jQuery("form.woocommerce-ordering")),u=r.query.orderby,f=r.query.order;if(d.length&&r.ordering){var y=jQuery(r.ordering);d.find(":not(.orderby)").remove(),y.find("option").appendTo(d.find("select")),y.find("input").appendTo(d),d.find("select").val(d.find("select [selected=selected]").val())}i&&r.result_count&&(i.innerHTML=r.result_count),n&&(n.innerHTML=r.content);let p=/href="([^\'\"]+)/g;if(s){let e="";if((window.elementorFrontend||document.querySelector("body").classList.contains("woobuilder-active"))&&(e=!0),r.pagination){let e=r.pagination,t=window.location.pathname;e=e.replace(p,(function(e){let o=e.split("?"),r="";var i=o[0].match(/\page\/\d+/);if(i){let e=t.match(/\/page\/\d+/);r=e?t.replace(e[0],i[0])+"?":t+i[0]+"?"}for(let e=1;e0&&""!==e&&jQuery(".page-numbers").each((function(t,o){var r=jQuery(o).attr("href");if(void 0!==r){var i=r.split("?");jQuery(o).attr("href",i[0]+"?"+e)}}))},select_ordering_top=function(){document.querySelector('select[name="orderby"]')&&document.querySelector('select[name="orderby"]').addEventListener("change",(function(){document.querySelector("form.woocommerce-ordering").submit()}))},deactive_mobile_sidebar=function(){var e=document.querySelector("#secondary.shop-widget"),t=document.querySelector("#toggle-sidebar-mobile-button"),o=document.getElementById("woostify-overlay"),r=document.getElementById("sidebar-widgets"),i=document.documentElement;t&&!document.querySelector("#toggle-sidebar-button")&&(t.classList.add("show"),t.classList.remove("active")),o&&(e&&e.classList.remove("active"),r&&r.classList.remove("show"),o.classList.remove("active"),i.classList.remove("sidebar-mobile-open"),document.body.classList.remove("sidebar-mobile-open"))};var woostify_swatch_list=function(){var e=document.querySelectorAll(".swatch-list");e.length&&e.forEach((function(e){var t=e.closest(".product"),o=t.querySelector(".product-loop-image-wrapper"),r=t.querySelector(".product-loop-image"),i=e.querySelectorAll(".swatch");i.length&&i.forEach((function(e){var t=siblings(e),i=e.getAttribute("data-slug");e.classList.contains("selected")&&(r.setAttribute("srcset",""),r.src=i),e.onclick=function(){r.getAttribute("data-swatch")||r.setAttribute("data-swatch",r.src),o.classList.add("circle-loading"),r.setAttribute("srcset",""),t.length&&t.forEach((function(e){e.classList.remove("selected")})),e.classList.contains("selected")?(e.classList.remove("selected"),r.src=r.getAttribute("data-swatch")):(e.classList.add("selected"),r.src=i);var n=new Image;n.src=i,n.onload=function(){o.classList.remove("circle-loading")}}}))}))};const woostifyFilterOrdering=function(){let e=document.querySelector("form.woocommerce-ordering"),t=!!e&&e.querySelector("select.orderby"),o=document.querySelector("select.w-filter-ordering");if(!t||!o)return;let r=new CustomEvent("change");t.addEventListener("change",(function(e){e.preventDefault(),o.value=t.value,o.dispatchEvent(r)})),jQuery(".woocommerce-ordering").on("submit",(function(e){e.preventDefault()}))};document.addEventListener("DOMContentLoaded",(function(){woostifyAjaxFilter(),woostifyFilterDatePicker(),woostifyToggleFilter(),woostifyToggleFilterHorizontal(),woostifyToggleChildTerm(),woostifyToggleSoftLimit(),woostifyFilterQuickSearch(),woostifyFilterOrdering(),window.addEventListener("click",(function(e){var t=document.querySelectorAll(".filter-area.filter-horizontal .w-product-filter, .w-pro-smart-filter-layout-horizontal .w-product-filter");if(!t.length||t.length<1)return!1;t.forEach((function(t){t.contains(e.target)||t.classList.remove("open")}))})),"function"==typeof onElementorLoaded&&onElementorLoaded((function(){window.elementorFrontend.hooks.addAction("frontend/element_ready/woostify-filter-date-range.default",(function(){woostifyFilterDatePicker()})),window.elementorFrontend.hooks.addAction("frontend/element_ready/woostify-filter-range-slider.default",(function(){let e=document.querySelectorAll(".w-product-filter-type-range-slider");e.length&&e.forEach((function(e){if("object"==typeof e.noUiSlider)return;let t=Number(e.getAttribute("data-from"))||0,o=Number(e.getAttribute("data-to"))||100;noUiSlider.create(e,{tooltips:!0,connect:!0,start:[t,o],step:1,range:{min:t,max:o},format:{from:function(e){return Math.round(e)},to:function(e){return Math.round(e)}}})}))}))}))}));