1"use strict";(self.webpackChunkwoocommerce_filters=self.webpackChunkwoocommerce_filters||[]).push([[4820],{1106:function(e,t,n){n.r(t),n.d(t,{default:function(){return x}});var i=n(9307),s=n(2819),r=n(2694),o=n(4376),a=n(9196),u="undefined"==typeof window?a.useEffect:a.useLayoutEffect;function l(e,t,n,i,s,r){void 0===i&&(i={}),void 0===s&&(s=!0),void 0===r&&(r=!1);var o=function(e){var t=function(e,t){void 0===t&&(t=!1);var n=t?u:a.useEffect,i=(0,a.useRef)(e);return n((function(){i.current=e})),i}(e);return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];"function"==typeof t.current&&t.current.apply(t,e)}}(n);(r?u:a.useEffect)((function(){return void 0!==e&&s?(e.addEventListener(t,o,i),function(){e.removeEventListener(t,o,i)}):function(){}}),[t,i])}var c=[void 0,null,null],f=function(e){var t,n,i=void 0===e?{}:e,s=i.updateOnScroll,r=void 0===s||s,o=i.updateOnResize,u=void 0===o||o,f=(0,a.useState)(null),d=f[0],v=f[1],h=(0,a.useState)(null),w=h[0],m=h[1],p=(0,a.useCallback)((function(e){m(e)}),[]),y=(0,a.useCallback)((function(){window.requestAnimationFrame((function(){w&&v(function(e){var t=e.getBoundingClientRect();return{bottom:t.bottom,height:t.height,left:t.left,right:t.right,top:t.top,width:t.width,x:t.left,y:t.top}}(w))}))}),[w]);return(0,a.useLayoutEffect)((function(){y()}),[y]),void 0===(t=u)&&(t=!0),void 0===(n=!0)&&(n=!1),"undefined"!=typeof window?l(window,"resize",(function(){y()}),{passive:!0},t,n):console.warn("useOnWindowResize can't attach an event listener as window is undefined."),function(e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!1),"undefined"!=typeof window?l(window,"scroll",(function(){y()}),{passive:!0},t,n):console.warn("useOnWindowScroll can't attach an event listener as window is undefined.")}(0,r,!0),"undefined"==typeof window?(console.warn("useDimensionsRef: window is undefined."),c):[p,d,w]},d=n(5236),v=n(4548),h=n(389),w=n(4271),m=n(4184),p=n.n(m),y=n(5893);const g=(0,i.lazy)((()=>n.e(98).then(n.bind(n,482)))),b=WCF_Frontend,E=b.clear_btn_text;var x=e=>{const{horizontal:t}=e,{filters:n,pluckTaxonomyData:a,clearForms:u,submittedValues:l}=(0,h.CR)(),c="yes"===b.slideout_desktop,m="yes"===b.slideout_mobile,x=(0,o.Lm)()<960,[_,C,j]=f(),[k,L]=(0,i.useState)(0),A=e=>{const t=[],i=["categories","tags","attributes","colors","taxonomy"];return(0,s.forEach)(e,((e,s)=>{const r=n.find((e=>e.slug===s)),o=r.filter_by;if((i.includes(o)||o.startsWith("tax_"))&&"range"!==r.options.filter_type){const n=Array.isArray(e)?e:"string"==typeof e?e.split(",").map((e=>e.trim())):[],i=a(r.slug,n);t.push({filter:r,slug:s,value:i})}else t.push({filter:r,slug:s,value:null})})),t},[F,R]=(0,i.useState)((0,w.w2)()?A(l):[]),S=document.getElementById("wcf-sorting-bar"),z=()=>(0,s.isEmpty)(F)&&(!m||!c)&&!x;(0,d.H)((()=>{const e=A(l);(0,s.isEmpty)(e)||R(e),z()?S.classList.add("is-hidden"):S.classList.remove("is-hidden")}));const D=()=>{let e=!1;return j?.clientHeight>40&&(e=!0),e};
1if((0,v.l)((async()=>{z()?S.classList.add("is-hidden"):S.classList.remove("is-hidden"),await(0,w._S)(".wcf-active-filter").then((e=>{const t=document.getElementsByClassName("wcf-active-filter");t?.length>0&&L(t.length)}))}),[F]),(0,i.useEffect)((()=>{const e=h.Gd.subscribe((e=>e.submittedValues),(e=>{(0,s.isEmpty)(e)?F!==[]&&(0,s.isEmpty)(e)&&R([]):R(A(e))}));return()=>{e()}}),[]),(0,s.isEmpty)(F))return null;const N=()=>(0,y.jsx)("a",{href:"#",onClick:e=>{e.preventDefault(),(0,r.doAction)("wcpf.beforeClearingFilters"),(0,w.w2)()?(0,w.sq)({},!1):"instant"!==WCF_Frontend.filter_mode?u():(0,w.sq)({},!1)},className:"wcf-reset-filters-btn",style:{},children:(0,y.jsx)("span",{children:E})});if(!0===t){const e=p()("wcf-active-filters","horizontal",{"is-long-list":D()});return(0,y.jsxs)("div",{className:e,ref:_,children:[!D()&&(0,y.jsx)(N,{}),F.map((({filter:e,slug:t,value:n},i)=>(0,y.jsx)(g,{filter:e,value:n,filters:F},i))),D()&&(0,y.jsx)(N,{})]})}return(0,y.jsxs)(y.Fragment,{children:[F.map((({filter:e,slug:t,value:n},i)=>(0,y.jsx)(g,{filter:e,value:n,filters:F},i))),(0,y.jsx)("div",{className:"wcf-active-filters",children:(0,y.jsx)("a",{href:"#",onClick:e=>(e.preventDefault(),(0,w.sq)({},!1)),className:"wcf-reset-filters-btn",children:(0,y.jsx)("span",{children:E})})})]})}},4548:function(e,t,n){n.d(t,{l:function(){return s}});var i=n(9196);function s(e,t){var n=(0,i.useRef)(!1);void 0===t||Array.isArray(t)?Array.isArray(t)&&0===t.length&&console.warn("Using [] as the second argument makes useDidUpdate a noop. The second argument should either be `undefined` or an array of length greater than 0."):t=[t],(0,i.useEffect)((function(){n.current?e():n.current=!0}),t),(0,i.useEffect)((function(){return function(){n.current=!1}}),[])}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.