import*as e from"@wordpress/interactivity";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const r=(m={getContext:()=>e.getContext,store:()=>e.store},c={},t.d(c,m),c),n=window.wc.wcSettings.SITE_CURRENCY,a=(e={})=>({...n,...e}),i=(e,t)=>{if(""===e||void 0===e)return"";const r="number"==typeof e?e:parseInt(e,10);if(!Number.isFinite(r))return"";const n=a(t),{minorUnit:i,prefix:m,suffix:c,decimalSeparator:o,thousandSeparator:s}=n,l=r/10**i,{beforeDecimal:p,afterDecimal:x}=(e=>{const t=e.split(".");return{beforeDecimal:t[0],afterDecimal:t[1]||""}})(l.toString()),g=`${m}${((e,t)=>e.replace(/\B(?=(\d{3})+(?!\d))/g,t))(p,s)}${((e,t,r)=>e?`${t}${e.padEnd(r,"0")}`:r>0?`${t}${"0".repeat(r)}`:"")(x,o,i)}${c}`;return g};var m,c;function o(e,t,r){return e>=t&&e<=r}const{state:s,actions:l}=(0,r.store)("woocommerce/product-filter-price",{state:{get minPrice(){const e=(0,r.getContext)(),t=(0,r.store)("woocommerce/product-filters");return t.state.params?.min_price?parseInt(t.state.params.min_price,10):e.minRange},get maxPrice(){const e=(0,r.getContext)(),t=(0,r.store)("woocommerce/product-filters");return t.state.params?.max_price?parseInt(t.state.params.max_price,10):e.maxRange},get formattedMinPrice(){return i(s.minPrice,a({minorUnit:0}))},get formattedMaxPrice(){return i(s.maxPrice,a({minorUnit:0}))},get hasSelectedFilters(){const e=(0,r.getContext)();return s.minPrice>e.minRange||s.maxPrice<e.maxRange}},actions:{getActiveLabel(e,t){const n=(0,r.getContext)();return e&&e>n.minRange&&t&&t<n.maxRange?n.activeLabelTemplates.minAndMax.replace("{{min}}",i(e,a({minorUnit:0}))).replace("{{max}}",i(t,a({minorUnit:0}))):e&&e>n.minRange?n.activeLabelTemplates.minOnly.replace("{{min}}",i(e,a({minorUnit:0}))):t&&t<n.maxRange?n.activeLabelTemplates.maxOnly.replace("{{max}}",i(t,a({minorUnit:0}))):""},setPrice:(e,t)=>{const n=(0,r.getContext)(),a=(0,r.store)("woocommerce/product-filters"),i={min:s.minPrice,max:s.maxPrice};var m,c;"min"===e&&t&&o(t,n.minRange,n.maxRange)&&t<s.maxPrice&&(i.min=t),"max"===e&&t&&o(t,n.minRange,n.maxRange)&&t>s.minPrice&&(i.max=t),i.min===n.minRange&&(i.min=null),i.max===n.maxRange&&(i.max=null),a.actions.removeActiveFiltersByType("price"),a.actions.setActiveFilter({type:"price",value:(m=i.min,c=i.max,null===m&&null===c?null:null===c?`${m}-`:null===m?`-${c}`:`${m}-${c}`),label:l.getActiveLabel(i.min,i.max),price:i})},setMinPrice:e=>{const t=parseInt(e.target.value,10);l.setPrice("min",t)},setMaxPrice:e=>{const t=parseInt(e.target.value,10);l.setPrice("max",t)},clearFilters:()=>{const e=(0,r.store)("woocommerce/product-filters");e.actions.removeActiveFiltersByType("price"),e.actions.navigate()}}});