import*as t from"@wordpress/interactivity";var e={d:(t,r)=>{for(var l in r)e.o(r,l)&&!e.o(t,l)&&Object.defineProperty(t,l,{enumerable:!0,get:r[l]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const r=(i={getContext:()=>t.getContext,getElement:()=>t.getElement,store:()=>t.store},o={},e.d(o,i),o),{state:l,actions:a}=(0,r.store)("woocommerce/product-filter-attribute",{state:{get selectedFilters(){const t=(0,r.getContext)();return((0,r.store)("woocommerce/product-filters").state.activeFilters||[]).filter((e=>"attribute"===e.type&&e.attribute?.slug===t.attributeSlug)).map((t=>t.value)).filter(Boolean)},get hasSelectedFilters(){return l.selectedFilters.length>0},get isItemSelected(){const{attributes:t}=(0,r.getElement)();return!!t.value&&l.selectedFilters.includes(t.value)}},actions:{getActiveLabel(t){const{activeLabelTemplate:e}=(0,r.getContext)();return e.replace("{{label}}",t)},toggleFilter:()=>{const{attributes:t}=(0,r.getElement)();let e=t["data-filter-item"];"string"==typeof e&&(e=JSON.parse(e));const{ariaLabel:i,value:o}=e;if(!o||!i)return;const s=(0,r.getContext)(),c=(0,r.store)("woocommerce/product-filters");l.selectedFilters.includes(o)?c.actions.removeActiveFiltersBy((t=>t.value===o&&"attribute"===t.type&&t.attribute?.slug===s.attributeSlug)):c.actions.setActiveFilter({type:"attribute",value:o,label:a.getActiveLabel(i),attribute:{slug:s.attributeSlug,queryType:"or"}}),c.actions.navigate()}}});var i,o;