import*as e from"@wordpress/interactivity";var t={d:(e,i)=>{for(var r in i)t.o(i,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:i[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const i=(n={getConfig:()=>e.getConfig,getContext:()=>e.getContext,getServerContext:()=>e.getServerContext,store:()=>e.store},c={},t.d(c,n),c),r=(0,i.getConfig)("woocommerce").currency,a={...r,suffix:(o=r.symbol,m=r.symbolPosition,{left:"",left_space:"",right:o,right_space:" "+o}[m]||""),prefix:(e=>({left:e,left_space:e+" ",right:"",right_space:""}[r.symbolPosition]||""))(r.symbol)};var n,c,o,m;const s=(e={})=>({...a,...e}),l=(e,t)=>{if(""===e||void 0===e)return"";const i="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(i))return"";const r=s(t),{minorUnit:a,prefix:n,suffix:c,decimalSeparator:o,thousandSeparator:m}=r,l=i/10**a,{beforeDecimal:p,afterDecimal:g}=(e=>{const t=e.split(".");return{beforeDecimal:t[0],afterDecimal:t[1]||""}})(l.toString()),f=`${n}${((e,t)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,t))(p,m)}${((e,t,i)=>e?`${t}${e.padEnd(i,"0")}`:i>0?`${t}${"0".repeat(i)}`:"")(g,o,a)}${c}`;return f},{store:p,getContext:g,getServerContext:f,getConfig:u}=i;function v(e,t,i){return e>=t&&e<=i}const x={state:{get minPrice(){const{activeFilters:e}=g(),{minRange:t}=f?f():g(),i=e.find((e=>"price"===e.type));if(i){const[e]=i.value.split("|");return e?parseInt(e,10):t}return t},get maxPrice(){const{activeFilters:e}=g(),{maxRange:t}=f?f():g(),i=e.find((e=>"price"===e.type));if(i){const[,e]=i.value.split("|");return e?parseInt(e,10):t}return t},get formattedMinPrice(){return l(P.minPrice,s({minorUnit:0}))},get formattedMaxPrice(){return l(P.maxPrice,s({minorUnit:0}))}},actions:{getActivePriceAndLabel(e,t){const{minRange:i,maxRange:r}=f?f():g(),{activePriceLabelTemplates:a}=u();return e&&e>i&&t&&t<r?{activeValue:`${e}|${t}`,activeLabel:a.minAndMax.replace("{{min}}",l(e,s({minorUnit:0}))).replace("{{max}}",l(t,s({minorUnit:0})))}:e&&e>i?{activeValue:`${e}|`,activeLabel:a.minOnly.replace("{{min}}",l(e,s({minorUnit:0})))}:t&&t<r?{activeValue:`|${t}`,activeLabel:a.maxOnly.replace("{{max}}",l(t,s({minorUnit:0})))}:{activeValue:"",activeLabel:""}},setPrice:(e,t)=>{const i=g(),{minRange:r,maxRange:a}=f?f():g(),n={min:P.minPrice,max:P.maxPrice};"min"===e&&t&&v(t,r,a)&&t<P.maxPrice&&(n.min=t),"max"===e&&t&&v(t,r,a)&&t>P.minPrice&&(n.max=t),n.min===r&&(n.min=0),n.max===a&&(n.max=0),i.activeFilters=i.activeFilters.filter((e=>"price"!==e.type));const{activeValue:c,activeLabel:o}=b.getActivePriceAndLabel(n.min,n.max);if(c){const e={type:"price",value:c,activeLabel:o};i.activeFilters.push(e)}},setMinPrice:e=>{const t=parseInt(e.target.value,10);b.setPrice("min",t)},setMaxPrice:e=>{const t=parseInt(e.target.value,10);b.setPrice("max",t)}}},{state:P,actions:b}=p("woocommerce/product-filters",x);