(()=>{"use strict";var e,t={7066:(e,t,o)=>{o.r(t);var r=o(9196);const c=window.wp.blocks;var n=o(1984),l=o(3378);const i=window.wc.wcSettings;var a,s,u,p,d,m,b,w,v,f;const k=(0,i.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),g=(k.pluginUrl,k.pluginUrl,k.buildPhase),S=(null===(a=i.STORE_PAGES.shop)||void 0===a||a.permalink,null===(s=i.STORE_PAGES.checkout)||void 0===s||s.id,null===(u=i.STORE_PAGES.checkout)||void 0===u||u.permalink,null===(p=i.STORE_PAGES.privacy)||void 0===p||p.permalink,null===(d=i.STORE_PAGES.privacy)||void 0===d||d.title,null===(m=i.STORE_PAGES.terms)||void 0===m||m.permalink,null===(b=i.STORE_PAGES.terms)||void 0===b||b.title,null===(w=i.STORE_PAGES.cart)||void 0===w||w.id,null===(v=i.STORE_PAGES.cart)||void 0===v||v.permalink,null!==(f=i.STORE_PAGES.myaccount)&&void 0!==f&&f.permalink?i.STORE_PAGES.myaccount.permalink:(0,i.getSetting)("wpLoginUrl","/wp-login.php"),(0,i.getSetting)("localPickupEnabled",!1),(0,i.getSetting)("countries",{})),y=(0,i.getSetting)("countryData",{}),E=(Object.fromEntries(Object.keys(y).filter((e=>!0===y[e].allowBilling)).map((e=>[e,S[e]||""]))),Object.fromEntries(Object.keys(y).filter((e=>!0===y[e].allowBilling)).map((e=>[e,y[e].states||[]]))),Object.fromEntries(Object.keys(y).filter((e=>!0===y[e].allowShipping)).map((e=>[e,S[e]||""]))),Object.fromEntries(Object.keys(y).filter((e=>!0===y[e].allowShipping)).map((e=>[e,y[e].states||[]]))),Object.fromEntries(Object.keys(y).map((e=>[e,y[e].locale||[]]))),JSON.parse('{"name":"woocommerce/collection-filters","version":"1.0.0","title":"Collection Filters","description":"A block that adds product filters to the product collection.","category":"woocommerce","keywords":["WooCommerce","Filters"],"textdomain":"woo-gutenberg-products-block","supports":{"html":false,"reusable":false},"usesContext":["query"],"providesContext":{"collectionData":"collectionData"},"ancestor":["woocommerce/product-collection"],"attributes":{"collectionData":{"type":"object","default":{}}},"apiVersion":2,"$schema":"https://schemas.wp.org/trunk/block.json"}')),_=window.wp.blockEditor,h=window.wp.data;var O=o(9307);const P=window.wc.wcBlocksData;var j=o(9127),T=o.n(j);function x(e){const t=(0,O.useRef)(e);return T()(e,t.current)||(t.current=e),t.current}var R=o(5736);function A(e,t={}){return e.innerBlocks.reduce(((e,t)=>{var o,r,c;return r=t.attributes.queryParam,"calculate_attribute_counts",A(t,e=!(e=>null===e)(c=r)&&c instanceof Object&&c.constructor===Object&&"calculate_attribute_counts"in r?function(e,t){var o;const r=null!==(o=null==e?void 0:e.calculate_attribute_counts)&&void 0!==o?o:[];return e.calculate_attribute_counts=[...r,t.attributes.queryParam.calculate_attribute_counts],e}(e,t):{...e,...null===(o=t.attributes)||void 0===o?void 0:o.queryParam})}),t)}const C=["exclude","offset","search"],B=[{key:"woocommerceStockStatus",map:"stock_status"},{key:"woocommerceOnSale",map:"on_sale"},{key:"woocommerceHandPickedProducts",map:"include"}];function G(e){return{product_tag:"tag",product_cat:"cat"}[e]||`_unstable_tax_${e}`}const q=(0,i.getSetting)("attributes",[]),I=[["core/heading",{content:(0,R.__)("Filter by Price","woo-gutenberg-products-block"),level:3}],["woocommerce/collection-price-filter",{}],["core/heading",{content:(0,R.__)("Filter by Stock status","woo-gutenberg-products-block"),level:3}],["woocommerce/collection-stock-filter",{}]],D=q.find(Boolean);D&&I.push(["core/heading",{content:(0,R.sprintf)(
// translators: %s is the attribute label.
(0,R.__)("Filter by %s","woo-gutenberg-products-block"),D.attribute_label),level:3}],["woocommerce/collection-attribute-filter",{attributeId:parseInt(null==D?void 0:D.attribute_id,10)}]);g>2&&(0,c.registerBlockType)(E,{icon:{src:(0,r.createElement)(n.Z,{icon:l.Z,className:"wc-block-editor-components-block-icon"})},edit:({clientId:e,setAttributes:t,context:o})=>{const c=(0,_.useBlockProps)(),n=(0,_.useInnerBlocksProps)(c,{template:I}),l=(0,h.useSelect)((t=>t("core/block-editor").getBlock(e))),{results:i}=(e=>{const{namespace:t,resourceName:o,resourceValues:r=[],query:c={},shouldSelect:n=!0}=e;if(!t||!o)throw new Error("The options object must have valid values for the namespace and the resource properties.");const l=(0,O.useRef)({results:[],isLoading:!0}),i=x(c),a=x(r),s=(()=>{const[,e]=(0,O.useState)();return(0,O.useCallback)((t=>{e((()=>{throw t}))}),[])})(),u=(0,h.useSelect)((e=>{if(!n)return null;const r=e(P.COLLECTIONS_STORE_KEY),c=[t,o,i,a],l=r.getCollectionError(...c);if(l){if(!(l instanceof Error))throw new Error("TypeError: `error` object is not an instance of Error constructor");s(l)}return{results:r.getCollection(...c),isLoading:!r.hasFinishedResolution("getCollection",c)}}),[t,o,a,i,n]);return null!==u&&(l.current=u),l.current})({namespace:"/wc/store/v1",resourceName:"products/collection-data",query:{...(a=o.query,a?Object.assign({attributes:(u=a.woocommerceAttributes,u?u.map((e=>({attribute:e.taxonomy,term_id:e.termId}))):{}),catalog_visibility:"visible"},...C.map((e=>e in a&&{[e]:a[e]})),...B.map((e=>e.key in a&&{[e.map]:a[e.key]})),...(s=a.taxQuery,Object.entries(s).map((([e,t])=>({[G(e)]:t}))))):{}),...(p=l,p?A(p):{})}});var a,s,u,p;return(0,O.useEffect)((()=>{t({collectionData:i})}),[i,t]),(0,r.createElement)("nav",{...n})},save:function(){const e=_.useBlockProps.save(),t=_.useInnerBlocksProps.save(e);return(0,r.createElement)("nav",{...t})}})},9196:e=>{e.exports=window.React},9307:e=>{e.exports=window.wp.element},5736:e=>{e.exports=window.wp.i18n},9127:e=>{e.exports=window.wp.isShallowEqual},444:e=>{e.exports=window.wp.primitives}},o={};function r(e){var c=o[e];if(void 0!==c)return c.exports;var n=o[e]={exports:{}};return t[e].call(n.exports,n,n.exports,r),n.exports}r.m=t,e=[],r.O=(t,o,c,n)=>{if(!o){var l=1/0;for(u=0;u<e.length;u++){for(var[o,c,n]=e[u],i=!0,a=0;a<o.length;a++)(!1&n||l>=n)&&Object.keys(r.O).every((e=>r.O[e](o[a])))?o.splice(a--,1):(i=!1,n<l&&(l=n));if(i){e.splice(u--,1);var s=c();void 0!==s&&(t=s)}}return t}n=n||0;for(var u=e.length;u>0&&e[u-1][2]>n;u--)e[u]=e[u-1];e[u]=[o,c,n]},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.j=3418,(()=>{var e={3418:0};r.O.j=t=>0===e[t];var t=(t,o)=>{var c,n,[l,i,a]=o,s=0;if(l.some((t=>0!==e[t]))){for(c in i)r.o(i,c)&&(r.m[c]=i[c]);if(a)var u=a(r)}for(t&&t(o);s<l.length;s++)n=l[s],r.o(e,n)&&e[n]&&e[n][0](),e[n]=0;return r.O(u)},o=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var c=r.O(void 0,[2869],(()=>r(7066)));c=r.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["collection-filters"]=c})();