Server IP : 192.64.112.168 / Your IP : 18.119.157.233 Web Server : Apache System : Linux nc-ph-2300-85.bluforrest.com 4.18.0-513.9.1.el8_9.x86_64 #1 SMP Sat Dec 2 05:23:44 EST 2023 x86_64 User : expressoneac ( 1128) PHP Version : 8.0.30 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/expressoneac/www/wp-content/plugins/woocommerce/assets/client/blocks/ |
Upload File : |
(()=>{var e,t,o,r={2303:(e,t,o)=>{"use strict";o.r(t);const r=window.wp.blocks,c=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"woocommerce/product-collection","version":"1.0.0","title":"Product Collection","description":"Display a collection of products from your store.","category":"woocommerce","keywords":["WooCommerce","Products (Beta)","all products","by category","by tag","by attribute"],"textdomain":"woocommerce","attributes":{"queryId":{"type":"number"},"query":{"type":"object"},"tagName":{"type":"string"},"displayLayout":{"type":"object"},"dimensions":{"type":"object"},"convertedFromProducts":{"type":"boolean","default":false},"collection":{"type":"string"},"hideControls":{"default":[],"type":"array"},"queryContextIncludes":{"type":"array"},"forcePageReload":{"type":"boolean","default":false},"__privatePreviewState":{"type":"object"}},"providesContext":{"queryId":"queryId","query":"query","displayLayout":"displayLayout","dimensions":"dimensions","queryContextIncludes":"queryContextIncludes","collection":"collection","__privateProductCollectionPreviewState":"__privatePreviewState"},"usesContext":["templateSlug","postId"],"supports":{"align":["wide","full"],"anchor":true,"html":false,"__experimentalLayout":true,"interactivity":true}}');var n=o(1609);const l=window.wp.blockEditor;var a=o(6087);const i=window.wp.data,s=window.wp.coreData;let u=function(e){return e.Product="product",e.Archive="archive",e.Cart="cart",e.Order="order",e.Site="site",e}({});const m="single-product",d="taxonomy-product_cat",p="taxonomy-product_tag",_=async(e,t,o,r)=>{var c,n;r((c=await(0,i.resolveSelect)(s.store).getEntityRecords(e,t,{_fields:["id"],slug:o}))&&c.length&&null!==(n=c[0])&&void 0!==n&&n.id?c[0].id:null)},g=(e,t={})=>({type:e,sourceData:t}),w=window.wp.components;let E=function(e){return e.COLLECTION_PICKER="collection_chooser",e.PRODUCT_REFERENCE_PICKER="product_context_picker",e.VALID_WITH_PREVIEW="uses_reference_preview_mode",e.VALID="valid",e.DELETED_PRODUCT_REFERENCE="deleted_product_reference",e}({}),h=function(e){return e.GRID="flex",e.STACK="list",e}({}),b=function(e){return e.FILL="fill",e.FIXED="fixed",e}({}),y=function(e){return e.IN="in",e.NOT_IN="not-in",e}({}),v=function(e){return e.PRODUCT_CATALOG="woocommerce/product-collection/product-catalog",e.BEST_SELLERS="woocommerce/product-collection/best-sellers",e.FEATURED="woocommerce/product-collection/featured",e.NEW_ARRIVALS="woocommerce/product-collection/new-arrivals",e.ON_SALE="woocommerce/product-collection/on-sale",e.TOP_RATED="woocommerce/product-collection/top-rated",e.HAND_PICKED="woocommerce/product-collection/hand-picked",e.RELATED="woocommerce/product-collection/related",e.UPSELLS="woocommerce/product-collection/upsells",e.CROSS_SELLS="woocommerce/product-collection/cross-sells",e}({}),f=function(e){return e.ATTRIBUTES="attributes",e.CREATED="created",e.FEATURED="featured",e.HAND_PICKED="hand-picked",e.INHERIT="inherit",e.KEYWORD="keyword",e.ON_SALE="on-sale",e.ORDER="order",e.STOCK_STATUS="stock-status",e.TAXONOMY="taxonomy",e.PRICE_RANGE="price-range",e.FILTERABLE="filterable",e.RELATED_BY="related-by",e}({});var C=o(7723),k=o(4922),S=o.n(k);S()("wc-admin:tracks:stats");const A=S()("wc-admin:tracks");function R(e,t){return A("recordevent %s %o","wcadmin_"+e,t,{_tqk:window._tkq,shouldRecord:!(!window._tkq||!window.wcTracks||!window.wcTracks.isEnabled)}),!(!window.wcTracks||"function"!=typeof window.wcTracks.recordEvent)&&void window.wcTracks.recordEvent(e,t)}var I=o(9491);const T=window.wc.wcBlocksRegistry;var P=o(7104),x=o(9744);const N=window.wc.wcSettings;let O=function(e){return e.SINGLE="single",e.THUMBNAIL="thumbnail",e}({});const L=`${c.name}/product-title`,D=(0,N.getSetting)("stockStatusOptions",[]),B=(0,N.getSetting)("hideOutOfStockItems",!1),F=()=>B?Object.keys(function(e,t){const{[t]:o,...r}=e;return r}(D,"outofstock")):Object.keys(D),q={perPage:9,pages:0,offset:0,postType:"product",order:"asc",orderBy:"title",search:"",exclude:[],inherit:!1,taxQuery:{},isProductCollectionBlock:!0,featured:!1,woocommerceOnSale:!1,woocommerceStockStatus:F(),woocommerceAttributes:[],woocommerceHandPickedProducts:[],timeFrame:void 0,priceRange:void 0,filterable:!1,relatedBy:{categories:!0,tags:!0}},U={query:q,tagName:"div",displayLayout:{type:h.GRID,columns:3,shrinkColumns:!0},dimensions:{widthType:b.FILL},queryContextIncludes:["collection"],forcePageReload:!1},V={woocommerceOnSale:q.woocommerceOnSale,woocommerceStockStatus:q.woocommerceStockStatus,woocommerceAttributes:q.woocommerceAttributes,woocommerceHandPickedProducts:q.woocommerceHandPickedProducts,taxQuery:q.taxQuery,featured:q.featured,timeFrame:q.timeFrame,priceRange:q.priceRange},M=["woocommerce/product-template",{},[["woocommerce/product-image",{imageSizing:O.THUMBNAIL}],["core/post-title",{textAlign:"center",level:3,fontSize:"medium",style:{spacing:{margin:{bottom:"0.75rem",top:"0"}}},isLink:!0,__woocommerceNamespace:L}],["woocommerce/product-price",{textAlign:"center",fontSize:"small"}],["woocommerce/product-button",{textAlign:"center",fontSize:"small"}]]],H="core/query-pagination",$=[M,[H,{layout:{type:"flex",justifyContent:"center"}}],["woocommerce/product-collection-no-results"]],G={name:v.BEST_SELLERS,title:(0,C.__)("Best Sellers","woocommerce"),icon:(0,n.createElement)(P.A,{icon:x.A}),description:(0,C.__)("Recommend your best-selling products.","woocommerce"),keywords:["best selling"],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"popularity",order:"desc",perPage:5,pages:1},hideControls:[f.ORDER,f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("Best selling products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var j=o(8635);const K={name:v.CROSS_SELLS,title:(0,C.__)("Cross-Sells","woocommerce"),icon:(0,n.createElement)(P.A,{icon:j.A}),description:(0,C.__)("By suggesting complementary products in the cart using cross-sells, you can significantly increase the average order value.","woocommerce"),keywords:["boost","promotion"],scope:["inserter","block"],usesReference:["product","cart","order"],attributes:{displayLayout:{type:"flex",columns:4,shrinkColumns:!0},query:{perPage:8,pages:1},hideControls:[f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("You may be interested in…","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var W=o(43);const Q={name:v.FEATURED,title:(0,C.__)("Featured Products","woocommerce"),icon:(0,n.createElement)(P.A,{icon:W.A}),description:(0,C.__)("Showcase your featured products.","woocommerce"),keywords:[],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{featured:!0,perPage:5,pages:1},hideControls:[f.FEATURED,f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("Featured products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var Y=o(5573);const Z=(0,n.createElement)(Y.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.createElement)(Y.Path,{d:"M8.85074 4.8213L7.64702 3.92627L5.56365 6.72818L4.44959 5.89735L3.55286 7.0998L5.87107 8.82862L8.85074 4.8213Z",fill:"currentColor"}),(0,n.createElement)(Y.Path,{d:"M20 7.75004H11.1111V6.25004H20V7.75004Z",fill:"currentColor"}),(0,n.createElement)(Y.Path,{d:"M20 12.75H11.1111V11.25H20V12.75Z",fill:"currentColor"}),(0,n.createElement)(Y.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6 14C7.10457 14 8 13.1046 8 12C8 10.8955 7.10457 10 6 10C4.89543 10 4 10.8955 4 12C4 13.1046 4.89543 14 6 14ZM6 13C6.55229 13 7 12.5523 7 12C7 11.4478 6.55229 11 6 11C5.44772 11 5 11.4478 5 12C5 12.5523 5.44772 13 6 13Z",fill:"currentColor"}),(0,n.createElement)(Y.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M8 17C8 18.1046 7.10457 19 6 19C4.89543 19 4 18.1046 4 17C4 15.8955 4.89543 15 6 15C7.10457 15 8 15.8955 8 17ZM7 17C7 17.5523 6.55229 18 6 18C5.44772 18 5 17.5523 5 17C5 16.4478 5.44772 16 6 16C6.55229 16 7 16.4478 7 17Z",fill:"currentColor"}),(0,n.createElement)(Y.Path,{d:"M11.1111 17.75H20V16.25H11.1111V17.75Z",fill:"currentColor"})),z={name:v.HAND_PICKED,title:(0,C.__)("Hand-Picked Products","woocommerce"),icon:(0,n.createElement)(P.A,{icon:Z}),description:(0,C.__)("Select specific products to recommend to customers.","woocommerce"),keywords:["specific","choose","recommend","handpicked","hand picked"],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"post__in"},hideControls:[f.HAND_PICKED,f.FILTERABLE,f.ORDER]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("Recommended products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M,["core/query-pagination",{layout:{type:"flex",justifyContent:"center"}}]]};var X=o(9948);const J={name:v.NEW_ARRIVALS,title:(0,C.__)("New Arrivals","woocommerce"),icon:(0,n.createElement)(P.A,{icon:X.A}),description:(0,C.__)("Recommend your newest products.","woocommerce"),keywords:["newest"],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"date",order:"desc",perPage:5,pages:1,timeFrame:{operator:y.IN,value:"-7 days"}},hideControls:[f.ORDER,f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("New arrivals","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var ee=o(1173);const te={name:v.ON_SALE,title:(0,C.__)("On Sale Products","woocommerce"),icon:(0,n.createElement)(P.A,{icon:ee.A}),description:(0,C.__)("Highlight products that are currently on sale.","woocommerce"),keywords:["discount","promotion","onsale"],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{woocommerceOnSale:!0,perPage:5,pages:1},hideControls:[f.ON_SALE,f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("On sale products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var oe=o(4552);const re={name:v.PRODUCT_CATALOG,title:(0,C.__)("Product Catalog","woocommerce"),icon:(0,n.createElement)(P.A,{icon:oe.A}),description:"Display all products in your catalog. Results can (change to) match the current template, page, or search term.",keywords:["all products"],scope:[],innerBlocks:$},ce={name:v.RELATED,title:(0,C.__)("Related Products","woocommerce"),icon:(0,n.createElement)(P.A,{icon:oe.A}),description:(0,C.__)("Recommend products like this one.","woocommerce"),keywords:[],scope:["inserter","block"],usesReference:["product"],attributes:{displayLayout:{type:h.GRID,columns:4,shrinkColumns:!0},query:{perPage:4,pages:1}},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("Related Products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var ne=o(846);const le={name:v.TOP_RATED,title:(0,C.__)("Top Rated Products","woocommerce"),icon:(0,n.createElement)(P.A,{icon:ne.A}),description:(0,C.__)("Recommend products with the highest review ratings.","woocommerce"),keywords:[],scope:["inserter","block"],attributes:{displayLayout:{type:"flex",columns:5,shrinkColumns:!0},query:{orderBy:"rating",order:"desc",perPage:5,pages:1},hideControls:[f.ORDER,f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("Top rated products","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]};var ae=o(9093);const ie=[re,Q,J,te,G,le,z,ce,{name:v.UPSELLS,title:(0,C.__)("Upsells","woocommerce"),icon:(0,n.createElement)(P.A,{icon:ae.A}),description:(0,C.__)("Upsells are typically products that are extra profitable or better quality or more expensive. Experiment with combinations to boost sales.","woocommerce"),keywords:["boost","promotion"],scope:["inserter","block"],usesReference:["product","cart","order"],attributes:{displayLayout:{type:"flex",columns:4,shrinkColumns:!0},query:{perPage:8,pages:1},hideControls:[f.FILTERABLE]},innerBlocks:[["core/heading",{textAlign:"center",level:2,content:(0,C.__)("You may also like","woocommerce"),style:{spacing:{margin:{bottom:"1rem"}}}}],M]},K],se=e=>e?(0,i.select)(r.store).getBlockVariations(c.name).find((({name:t})=>t===e)):null,ue=window.wp.hooks,me=window.wp.url,de=window.wp.apiFetch;var pe,_e,ge,we,Ee,he,be,ye,ve,fe,Ce=o.n(de);const ke=(0,N.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),Se=ke.pluginUrl+"assets/images/",Ae=(ke.pluginUrl,null===(pe=N.STORE_PAGES.shop)||void 0===pe||pe.permalink,null===(_e=N.STORE_PAGES.checkout)||void 0===_e||_e.id,null===(ge=N.STORE_PAGES.checkout)||void 0===ge||ge.permalink,null===(we=N.STORE_PAGES.privacy)||void 0===we||we.permalink,null===(Ee=N.STORE_PAGES.privacy)||void 0===Ee||Ee.title,null===(he=N.STORE_PAGES.terms)||void 0===he||he.permalink,null===(be=N.STORE_PAGES.terms)||void 0===be||be.title,null===(ye=N.STORE_PAGES.cart)||void 0===ye||ye.id,null===(ve=N.STORE_PAGES.cart)||void 0===ve||ve.permalink,null!==(fe=N.STORE_PAGES.myaccount)&&void 0!==fe&&fe.permalink?N.STORE_PAGES.myaccount.permalink:(0,N.getSetting)("wpLoginUrl","/wp-login.php"),(0,N.getSetting)("localPickupEnabled",!1),(0,N.getSetting)("countries",{})),Re=(0,N.getSetting)("countryData",{}),Ie=(Object.fromEntries(Object.keys(Re).filter((e=>!0===Re[e].allowBilling)).map((e=>[e,Ae[e]||""]))),Object.fromEntries(Object.keys(Re).filter((e=>!0===Re[e].allowBilling)).map((e=>[e,Re[e].states||[]]))),Object.fromEntries(Object.keys(Re).filter((e=>!0===Re[e].allowShipping)).map((e=>[e,Ae[e]||""]))),Object.fromEntries(Object.keys(Re).filter((e=>!0===Re[e].allowShipping)).map((e=>[e,Re[e].states||[]]))),Object.fromEntries(Object.keys(Re).map((e=>[e,Re[e].locale||[]]))),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),Te=((0,N.getSetting)("addressFieldsLocations",Ie).address,(0,N.getSetting)("addressFieldsLocations",Ie).contact,(0,N.getSetting)("addressFieldsLocations",Ie).order,(0,N.getSetting)("additionalOrderFields",{}),(0,N.getSetting)("additionalContactFields",{}),(0,N.getSetting)("additionalAddressFields",{}),(e,t)=>{const o=new Map;return e.filter((e=>{const r=t(e);return!o.has(r)&&(o.set(r,e),!0)}))}),Pe=({selected:e=[],search:t="",queryArgs:o={}})=>{const r=(({selected:e=[],search:t="",queryArgs:o={}})=>{const r=ke.productCount>100,c={per_page:r?100:0,catalog_visibility:"any",search:t,orderby:"title",order:"asc"},n=[(0,me.addQueryArgs)("/wc/store/v1/products",{...c,...o})];return r&&e.length&&n.push((0,me.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:0})),n})({selected:e,search:t,queryArgs:o});return Promise.all(r.map((e=>Ce()({path:e})))).then((e=>{const t=e.flat(),o=Te(t,(e=>e.id));return o.map((e=>({...e,parent:0})))})).catch((e=>{throw e}))},xe=e=>Ce()({path:`wc/store/v1/products/attributes/${e}/terms`});function Ne(e,t){const{query:o}=e.attributes;e.setAttributes({query:{...o,...t}})}const Oe=()=>{var e;const t=null===(e=(0,i.select)("core/edit-site"))||void 0===e?void 0:e.getEditedPostId();return!!t&&["woocommerce/woocommerce//archive-product","woocommerce/woocommerce//taxonomy-product_attribute","woocommerce/woocommerce//product-search-results","//taxonomy-product_cat","//taxonomy-product_tag"].some((e=>t.includes(e)))},Le=e=>{const{getBlocksByName:t,getBlock:o}=(0,i.select)(l.store);return!t("woocommerce/product-collection").find((t=>{var r,c;return null===(r=o(t).attributes)||void 0===r||null===(c=r.query)||void 0===c?void 0:c[e]}))};function De(){return!!Oe()&&Le("inherit")}function Be(){return!Oe()&&Le("filterable")}const Fe=e=>({...e,orderBy:q.orderBy,order:q.order,inherit:De(),filterable:Be()}),qe=()=>U.displayLayout,Ue=e=>({displayLayout:qe(),query:Fe(e.query)}),Ve=(e,t,o)=>{const n=se(e);n&&o(t,n.name===v.PRODUCT_CATALOG?(0,r.createBlock)(c.name,{...U,query:{...U.query,inherit:De(),filterable:Be()}},(0,r.createBlocksFromInnerBlocksTemplate)($)):(0,r.createBlock)(c.name,n.attributes,(0,r.createBlocksFromInnerBlocksTemplate)(n.innerBlocks)))},Me=({title:e,icon:t,description:o,onClick:r})=>(0,n.createElement)(w.Tooltip,{text:o,placement:"top"},(0,n.createElement)(w.Button,{className:"wc-blocks-product-collection__collection-button",onClick:r},(0,n.createElement)("div",{className:"wc-blocks-product-collection__collection-button-icon"},(0,n.createElement)(w.Icon,{icon:t})),(0,n.createElement)("p",{className:"wc-blocks-product-collection__collection-button-title"},e))),He=e=>{const{description:t,onClick:o}=e;return(0,n.createElement)("div",{className:"wc-blocks-product-collection__collections-create"},(0,n.createElement)("span",null,(0,C.__)("or","woocommerce")),(0,n.createElement)(w.Tooltip,{text:t,placement:"top"},(0,n.createElement)(w.Button,{onClick:o},(0,C.__)("create your own","woocommerce"))))},$e=e=>{const{onCollectionClick:t,catalogVariation:o,collectionVariations:r}=e;return(0,n.createElement)("div",{className:"wc-blocks-product-collection__collections-grid"},(0,n.createElement)("div",{className:"wc-blocks-product-collection__collections-section"},r.map((({name:e,title:o,icon:r,description:c})=>(0,n.createElement)(Me,{key:e,title:o,description:c,icon:r,onClick:()=>t(e)})))),(0,n.createElement)(He,{title:o.title,description:o.description,icon:o.icon,onClick:()=>t(o.name)}))},Ge=e=>{const{onCollectionClick:t,catalogVariation:o,collectionVariations:r}=e;return(0,n.createElement)("div",{className:"wc-blocks-product-collection__collections-dropdown"},(0,n.createElement)(w.Dropdown,{className:"wc-blocks-product-collection__collections-dropdown-toggle",contentClassName:"wc-blocks-product-collection__collections-dropdown-content",renderToggle:({isOpen:e,onToggle:t})=>(0,n.createElement)(w.Button,{variant:"secondary",onClick:t,"aria-expanded":e},(0,C.__)("Choose collection","woocommerce")),renderContent:()=>(0,n.createElement)(n.Fragment,null,r.map((({name:e,title:o,icon:r,description:c})=>(0,n.createElement)(Me,{key:e,title:o,description:c,icon:r,onClick:()=>t(e)}))))}),(0,n.createElement)(He,{title:o.title,description:o.description,icon:o.icon,onClick:()=>t(o.name)}))},je=e=>{const t=(0,i.useSelect)((e=>{const{getBlockVariations:t}=e(r.store);return t(c.name)}),[]),o=(0,a.useMemo)((()=>t.find((({name:e})=>e===v.PRODUCT_CATALOG))),[t]),l=(0,a.useMemo)((()=>t.filter((({name:e,scope:t})=>e!==v.PRODUCT_CATALOG&&(void 0===t||(null==t?void 0:t.includes("block")))))),[t]),[s,{width:u}]=(0,I.useResizeObserver)();let m;return m=null!==u&&u>=600?$e:Ge,(0,n.createElement)(n.Fragment,null,s,!!u&&(0,n.createElement)(m,{...e,catalogVariation:o,collectionVariations:l}))},Ke=e=>{const t=(0,l.useBlockProps)(),{clientId:o,tracksLocation:r}=e,{replaceBlock:c}=(0,i.useDispatch)(l.store);return(0,n.createElement)("div",{...t},(0,n.createElement)(w.Placeholder,{className:"wc-blocks-product-collection__placeholder",instructions:(0,C.__)("What products do you want to show?","woocommerce")},(0,n.createElement)(je,{onCollectionClick:e=>{R("blocks_product_collection_collection_chosen_from_placeholder",{collection:e,location:r}),Ve(e,o,c)}})))};var We=o(458),Qe=o.n(We),Ye=o(361),Ze=o(4133);o(1598);const ze=({text:e,title:t=(0,C.__)("Feedback?","woocommerce"),url:o})=>{const[r,c]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{c(!0)}),[]),(0,n.createElement)(n.Fragment,null,r&&(0,n.createElement)("div",{className:"wc-block-feedback-prompt"},(0,n.createElement)(P.A,{icon:Ye.A}),(0,n.createElement)("h2",{className:"wc-block-feedback-prompt__title"},t),(0,n.createElement)("p",{className:"wc-block-feedback-prompt__text"},e),(0,n.createElement)("a",{href:o,className:"wc-block-feedback-prompt__link",rel:"noreferrer noopener",target:"_blank"},(0,C.__)("Give us your feedback.","woocommerce"),(0,n.createElement)(P.A,{icon:Ze.A,size:16}))))},Xe=()=>(0,n.createElement)(ze,{text:(0,C.__)("Thanks for trying out the Product Collection block! Help us make it better by sharing your feedback.","woocommerce"),title:(0,C.__)("Share your feedback!","woocommerce"),url:"https://airtable.com/shrqsMSDPvAKoY99u"}),Je="wc-blocks_upgraded-products-to-product-collection",et=()=>({status:"notseen",time:Date.now(),displayCount:0}),tt=window.wc.wcTypes,ot=e=>"woocommerce/product-collection"===e.name&&e.attributes.convertedFromProducts,rt=(e,t)=>{let o=[];return e.forEach((e=>{t(e)&&(o=[...o,e.clientId]),o=[...o,...rt(e.innerBlocks,t)]})),o},ct=(0,N.getSettingWithCoercion)("postTemplateHasSupportForGridView",!1,tt.isBoolean),nt=()=>{const e=window.localStorage.getItem(Je);return e?JSON.parse(e):et()},lt=e=>{window.localStorage.setItem(Je,JSON.stringify(e))},at=e=>"flex"===e?"grid":"list"===e?"default":"grid",it=e=>{const{type:t,columns:o}=e;return{type:at(t),columnCount:o}},st=(e,t)=>{const o=e.map((e=>{const{name:o,attributes:c}=e,n=st(e.innerBlocks);return(({name:e})=>"woocommerce/product-template"===e)(e)?((e,t,o)=>(0,r.createBlock)("core/post-template",{className:"products-block-post-template",layout:ct?it(o):void 0,__woocommerceNamespace:"woocommerce/product-query/product-template",...e.attributes},t))(e,n,t):(({name:e,attributes:t})=>"core/post-title"===e&&"woocommerce/product-collection/product-title"===t.__woocommerceNamespace)(e)?((e,t)=>{const{__woocommerceNamespace:o,...c}=e.attributes;return(0,r.createBlock)("core/post-title",{__woocommerceNamespace:"woocommerce/product-collection/product-title",...c},t)})(e,n):(({name:e,attributes:t})=>"core/post-excerpt"===e&&"woocommerce/product-collection/product-summary"===t.__woocommerceNamespace)(e)?((e,t)=>{const{__woocommerceNamespace:o,...c}=e.attributes;return(0,r.createBlock)("core/post-excerpt",{__woocommerceNamespace:"woocommerce/product-collection/product-summary",...c},t)})(e,n):(0,r.createBlock)(o,c,n)}));return o},ut=e=>{const t=(0,i.select)("core/block-editor").getBlock(e),o=((e,t)=>{const o=(0,i.select)("core/block-editor").getBlockRootClientId(e)||void 0;return(0,i.select)("core/block-editor").canInsertBlockType("core/query",o)})(e);if(t&&o){const{attributes:o={},innerBlocks:c=[]}=t,{displayLayout:n,...l}=o,a=(e=>{const{query:t,...o}=e,{woocommerceAttributes:r,woocommerceStockStatus:c,woocommerceOnSale:n,woocommerceHandPickedProducts:l,taxQuery:a,isProductCollectionBlock:i,...s}=t,u={...s};return l&&(u.include=l),n&&(u.__woocommerceOnSale=n),a&&(u.taxQuery=a),{...o,namespace:"woocommerce/product-query",query:{__woocommerceAttributes:r||[],__woocommerceStockStatus:c||[],...u}}})(ct?l:o),s=st(c,n),u=(0,r.createBlock)("core/query",a,s);return(0,i.dispatch)("core/block-editor").replaceBlock(e,u),!0}return!1},mt=()=>{var e;lt({status:"reverted",time:Date.now()}),(e=(0,i.select)("core/block-editor").getBlocks(),rt(e,ot)).map(ut)},dt=window.wp.editor;var pt=function(e){return e.SINGLE_PRODUCT="single-product",e.PRODUCT_CATALOG="product-catalog",e.PRODUCT_ARCHIVE="product-archive",e.ORDER_CONFIRMATION="order-confirmation",e.CART="cart",e.CHECKOUT="checkout",e.POST="post",e.PAGE="page",e.OTHER="other",e}(pt||{});const _t={"single-product":pt.SINGLE_PRODUCT,"archive-product":pt.PRODUCT_CATALOG,"taxonomy-product_cat":pt.PRODUCT_ARCHIVE,"taxonomy-product_tag":pt.PRODUCT_ARCHIVE,"taxonomy-product_attribute":pt.PRODUCT_ARCHIVE,"product-search-results":pt.PRODUCT_ARCHIVE,"order-confirmation":pt.ORDER_CONFIRMATION,"page-cart":pt.CART,"page-checkout":pt.CHECKOUT},gt=e=>{const t=(0,i.useSelect)((e=>e(dt.store).getCurrentPostType()),[]);if(t===pt.PAGE||t===pt.POST)return t;if(!e)return pt.OTHER;return _t[e]||(e.includes("single-product")?pt.SINGLE_PRODUCT:e.includes("taxonomy-product_cat")||e.includes("taxonomy-product_tag")?pt.PRODUCT_ARCHIVE:pt.OTHER)},wt=(0,a.createInterpolateElement)((0,C.__)("Products (Beta) block was upgraded to <strongText />, an updated version with new features and simplified settings.","woocommerce"),{strongText:(0,n.createElement)("strong",null,(0,C.__)("Product Collection","woocommerce"))}),Et=(0,C.__)("Revert to Products (Beta)","woocommerce"),ht=({revertMigration:e})=>{const[t,o]=((e,t)=>{const[o,r]=(0,a.useState)((()=>{const o=window.localStorage.getItem(e);if(o)try{return JSON.parse(o)}catch{console.error(`Value for key '${e}' could not be retrieved from localStorage because it can't be parsed.`)}return t}));return(0,a.useEffect)((()=>{try{window.localStorage.setItem(e,JSON.stringify(o))}catch{console.error(`Value for key '${e}' could not be saved in localStorage because it can't be converted into a string.`)}}),[e,o]),[o,r]})(Je,et()),r=(0,a.useRef)(!0),{status:c}=t;return(0,a.useEffect)((()=>()=>{r.current&&((()=>{const e=nt(),t=(0,tt.isNumber)(e.displayCount)?e.displayCount+1:0;lt({...e,displayCount:t})})(),r.current=!1)}),[r]),"notseen"===c?(0,n.createElement)(w.Notice,{onRemove:()=>{o({status:"seen",time:Date.now()})}},(0,n.createElement)(n.Fragment,null,wt," "),(0,n.createElement)("br",null),(0,n.createElement)("br",null),(0,n.createElement)(w.Button,{variant:"link",onClick:()=>{e(),R("blocks_product_collection_migration_between_products_beta",{transform_to:"products_beta"})}},Et)):null},bt=(0,C.__)("Columns","woocommerce"),yt=(0,C.__)("Responsive","woocommerce"),vt=(0,C.__)("Automatically adjust the number of columns to better fit smaller screens.","woocommerce"),ft=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,c="flex"===t,l=qe(),a=()=>{e.setAttributes({displayLayout:l})};return c?(0,n.createElement)(n.Fragment,null,(0,n.createElement)(w.__experimentalToolsPanelItem,{label:bt,hasValue:()=>(null==l?void 0:l.columns)!==o,isShownByDefault:!0,onDeselect:a},(0,n.createElement)(w.RangeControl,{label:bt,onChange:t=>e.setAttributes({displayLayout:{...e.displayLayout,columns:t}}),value:o,min:2,max:Math.max(6,o)})),(0,n.createElement)(w.__experimentalToolsPanelItem,{label:yt,hasValue:()=>(null==l?void 0:l.shrinkColumns)!==r,isShownByDefault:!0,onDeselect:a},(0,n.createElement)(w.ToggleControl,{checked:!!r,label:yt,help:vt,onChange:t=>{e.setAttributes({displayLayout:{...e.displayLayout,shrinkColumns:t}})}}))):null},Ct=(0,C.__)("Query type","woocommerce"),kt=(0,C.__)("Default","woocommerce"),St=(0,C.__)("Custom","woocommerce"),At=(0,C.__)("Display products based on the current template and allow shoppers to filter.","woocommerce"),Rt=(0,C.__)("Show products based on specific criteria and allow shoppers to filter.","woocommerce"),It=(0,C.__)("Show a list of products based on fixed criteria.","woocommerce"),Tt=({setQueryAttribute:e,trackInteraction:t,query:o})=>{const r=null==o?void 0:o.inherit,c=function(e,t){const o=(0,a.useRef)();return(0,a.useEffect)((()=>{o.current===e||t&&!t(e,o.current)||(o.current=e)}),[e,t]),o.current}(o,(e=>!1===(null==e?void 0:e.inherit))),l=(0,a.useMemo)((()=>De()),[]);return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:Ct,hasValue:()=>r!==l,isShownByDefault:!0,onDeselect:()=>{e({inherit:l}),t(f.INHERIT)}},(0,n.createElement)(w.__experimentalToggleGroupControl,{className:"wc-block-product-collection__inherit-query-control",isBlock:!0,label:Ct,help:r?At:It,value:!!r,onChange:o=>{e(o?{...q,inherit:o}:{...q,...c,inherit:o}),t(f.INHERIT)}},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:!0,label:kt}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:!1,label:St})))},Pt=({setQueryAttribute:e,trackInteraction:t,query:o})=>{const r=null==o?void 0:o.filterable,c=(0,a.useMemo)((()=>Be()),[]);return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:Ct,hasValue:()=>r!==c,isShownByDefault:!0,onDeselect:()=>{e({filterable:c}),t(f.FILTERABLE)}},(0,n.createElement)(w.__experimentalToggleGroupControl,{className:"wc-block-product-collection__inherit-query-control",isBlock:!0,label:Ct,help:r?Rt:It,value:!!r,onChange:o=>{e({filterable:o}),t(f.FILTERABLE)}},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:!0,label:kt}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:!1,label:St})))},xt=[{label:(0,C.__)("A → Z","woocommerce"),value:"title/asc"},{label:(0,C.__)("Z → A","woocommerce"),value:"title/desc"},{label:(0,C.__)("Newest to oldest","woocommerce"),value:"date/desc"},{label:(0,C.__)("Oldest to newest","woocommerce"),value:"date/asc"},{label:(0,C.__)("Price, high to low","woocommerce"),value:"price/desc"},{label:(0,C.__)("Price, low to high","woocommerce"),value:"price/asc"},{label:(0,C.__)("Sales, high to low","woocommerce"),value:"sales/desc"},{label:(0,C.__)("Sales, low to high","woocommerce"),value:"sales/asc"},{value:"rating/desc",label:(0,C.__)("Rating, high to low","woocommerce")},{value:"rating/asc",label:(0,C.__)("Rating, low to high","woocommerce")},{value:"menu_order/asc",label:(0,C.__)("Manual (menu order)","woocommerce")},{value:"random",label:(0,C.__)("Random","woocommerce")}],Nt=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,{order:c,orderBy:l}=t,a=Fe(t),i=()=>{r({orderBy:a.orderBy}),o(f.ORDER)};let s=c?`${l}/${c}`:l;return"popularity"===l&&(s=`sales/${c}`),(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Order by","woocommerce"),hasValue:()=>c!==(null==a?void 0:a.order)||l!==(null==a?void 0:a.orderBy),isShownByDefault:!0,onDeselect:i,resetAllFilter:i},(0,n.createElement)(w.SelectControl,{value:s,options:xt,label:(0,C.__)("Order by","woocommerce"),onChange:e=>{const[t,c]=e.split("/");r({orderBy:t,order:c||void 0}),o(f.ORDER)}}))},Ot=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,c=()=>{r({woocommerceOnSale:V.woocommerceOnSale}),o(f.ON_SALE)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("On Sale","woocommerce"),hasValue:()=>!0===t.woocommerceOnSale,isShownByDefault:!0,onDeselect:c,resetAllFilter:c},(0,n.createElement)(w.ToggleControl,{label:(0,C.__)("Show only products on sale","woocommerce"),checked:t.woocommerceOnSale||!1,onChange:e=>{r({woocommerceOnSale:e}),o(f.ON_SALE)}}))};function Lt(e){var t;const o="string"==typeof e?e:e.value;return null===(t=Object.entries(D).find((([,e])=>e===o)))||void 0===t?void 0:t[0]}const Dt=e=>{var t;const{query:o,trackInteraction:r,setQueryAttribute:c}=e,l=()=>{c({woocommerceStockStatus:V.woocommerceStockStatus}),r(f.STOCK_STATUS)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Stock Status","woocommerce"),hasValue:()=>!Qe()(o.woocommerceStockStatus,F()),onDeselect:l,resetAllFilter:l,isShownByDefault:!0},(0,n.createElement)(w.FormTokenField,{label:(0,C.__)("Stock Status","woocommerce"),onChange:e=>{const t=e.map(Lt).filter(Boolean);c({woocommerceStockStatus:t}),r(f.STOCK_STATUS)},suggestions:Object.values(D),validateInput:e=>Object.values(D).includes(e),value:(null==o||null===(t=o.woocommerceStockStatus)||void 0===t?void 0:t.map((e=>D[e])))||[],__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1}))},Bt=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,[c,l]=(0,a.useState)(t.search),i=(0,I.useDebounce)((()=>{t.search!==c&&(r({search:c}),o(f.KEYWORD))}),250);(0,a.useEffect)((()=>(i(),i.cancel)),[c,i]);const s=()=>{l(""),o(f.KEYWORD)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{hasValue:()=>!!c,label:(0,C.__)("Keyword","woocommerce"),onDeselect:s,resetAllFilter:s},(0,n.createElement)(w.TextControl,{label:(0,C.__)("Keyword","woocommerce"),value:c,onChange:l}))};var Ft=o(851);function qt(e,t,o){const r=new Set(t.map((e=>e[o])));return e.filter((e=>!r.has(e[o])))}const Ut=window.wp.htmlEntities,Vt={clear:(0,C.__)("Clear all selected items","woocommerce"),noItems:(0,C.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,C.__)("No results for %s","woocommerce"),search:(0,C.__)("Search for items","woocommerce"),selected:e=>(0,C.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,C._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,C.__)("Search results updated.","woocommerce")},Mt=(e,t=e)=>{const o=e.reduce(((e,t)=>{const o=t.parent||0;return e[o]||(e[o]=[]),e[o].push(t),e}),{}),r=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const c=["0"],n=(e={})=>e.parent?[...n(r[e.parent]),e.name]:e.name?[e.name]:[],l=e=>e.map((e=>{const t=o[e.id];return c.push(""+e.id),{...e,breadcrumbs:n(r[e.parent]),children:t&&t.length?l(t):[]}})),a=l(o[0]||[]);return Object.entries(o).forEach((([e,t])=>{c.includes(e)||a.push(...l(t||[]))})),a},Ht=(e,t)=>{if(!t)return e;const o=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(o).map(((e,t)=>o.test(e)?(0,n.createElement)("strong",{key:t},e):(0,n.createElement)(a.Fragment,{key:t},e)))},$t=({label:e})=>(0,n.createElement)("span",{className:"woocommerce-search-list__item-count"},e),Gt=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,n.createElement)("span",{className:"woocommerce-search-list__item-label"},r?(0,n.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(c=t.breadcrumbs).length?c.slice(0,1).toString():2===c.length?c.slice(0,1).toString()+" › "+c.slice(-1).toString():c.slice(0,1).toString()+" … "+c.slice(-1).toString()):null,(0,n.createElement)("span",{className:"woocommerce-search-list__item-name"},Ht((0,Ut.decodeEntities)(t.name),o)));var c},jt=({countLabel:e,className:t,depth:o=0,controlId:r="",item:c,isSelected:l,isSingle:i,onSelect:s,search:u="",selected:m,useExpandedPanelId:d,...p})=>{var _,g;const[E,h]=d,b=null!=e&&void 0!==c.count&&null!==c.count,y=!(null===(_=c.breadcrumbs)||void 0===_||!_.length),v=!(null===(g=c.children)||void 0===g||!g.length),f=E===c.id,C=(0,Ft.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":y,"has-children":v,"has-count":b,"is-expanded":f,"is-radio-button":i});(0,a.useEffect)((()=>{v&&l&&h(c.id)}),[c,v,l,h]);const k=p.name||`search-list-item-${r}`,S=`${k}-${c.id}`,A=(0,a.useCallback)((()=>{h(f?-1:Number(c.id))}),[f,c.id,h]);return v?(0,n.createElement)("div",{className:C,onClick:A,onKeyDown:e=>"Enter"===e.key||" "===e.key?A():null,role:"treeitem",tabIndex:0},i?(0,n.createElement)(n.Fragment,null,(0,n.createElement)("input",{type:"radio",id:S,name:k,value:c.value,onChange:s(c),onClick:e=>e.stopPropagation(),checked:l,className:"woocommerce-search-list__item-input",...p}),(0,n.createElement)(Gt,{item:c,search:u}),b?(0,n.createElement)($t,{label:e||c.count}):null):(0,n.createElement)(n.Fragment,null,(0,n.createElement)(w.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:l,...!l&&c.children.some((e=>m.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:Ht((0,Ut.decodeEntities)(c.name),u),onChange:()=>{l?s(qt(m,c.children,"id"))():s(function(e,t,o){const r=qt(t,e,"id");return[...e,...r]}(m,c.children))()},onClick:e=>e.stopPropagation()}),b?(0,n.createElement)($t,{label:e||c.count}):null)):(0,n.createElement)("label",{htmlFor:S,className:C},i?(0,n.createElement)(n.Fragment,null,(0,n.createElement)("input",{...p,type:"radio",id:S,name:k,value:c.value,onChange:s(c),checked:l,className:"woocommerce-search-list__item-input"}),(0,n.createElement)(Gt,{item:c,search:u})):(0,n.createElement)(w.CheckboxControl,{...p,id:S,name:k,className:"woocommerce-search-list__item-input",value:(0,Ut.decodeEntities)(c.value),label:Ht((0,Ut.decodeEntities)(c.name),u),onChange:s(c),checked:l}),b?(0,n.createElement)($t,{label:e||c.count}):null)},Kt=jt;var Wt=o(2478),Qt=o(2370);o(6636);const Yt=({id:e,label:t,popoverContents:o,remove:r,screenReaderLabel:c,className:l=""})=>{const[i,s]=(0,a.useState)(!1),u=(0,I.useInstanceId)(Yt);if(c=c||t,!t)return null;t=(0,Ut.decodeEntities)(t);const m=(0,Ft.A)("woocommerce-tag",l,{"has-remove":!!r}),d=`woocommerce-tag__label-${u}`,p=(0,n.createElement)(n.Fragment,null,(0,n.createElement)("span",{className:"screen-reader-text"},c),(0,n.createElement)("span",{"aria-hidden":"true"},t));return(0,n.createElement)("span",{className:m},o?(0,n.createElement)(w.Button,{className:"woocommerce-tag__text",id:d,onClick:()=>s(!0)},p):(0,n.createElement)("span",{className:"woocommerce-tag__text",id:d},p),o&&i&&(0,n.createElement)(w.Popover,{onClose:()=>s(!1)},o),r&&(0,n.createElement)(w.Button,{className:"woocommerce-tag__remove",onClick:r(e),label:(0,C.sprintf)( // Translators: %s label. // Translators: %s label. (0,C.__)("Remove %s","woocommerce"),t),"aria-describedby":d},(0,n.createElement)(P.A,{icon:Qt.A,size:20,className:"clear-icon",role:"img"})))},Zt=Yt;o(8137);const zt=e=>(0,n.createElement)(Kt,{...e}),Xt=e=>{const{list:t,selected:o,renderItem:r,depth:c=0,onSelect:l,instanceId:i,isSingle:s,search:u,useExpandedPanelId:m}=e,[d]=m;return t?(0,n.createElement)(a.Fragment,null,t.map((t=>{var p,_;const g=null!==(p=t.children)&&void 0!==p&&p.length&&!s?t.children.every((({id:e})=>o.find((t=>t.id===e)))):!!o.find((({id:e})=>e===t.id)),w=(null===(_=t.children)||void 0===_?void 0:_.length)&&d===t.id;return(0,n.createElement)(a.Fragment,{key:t.id},(0,n.createElement)("li",null,r({item:t,isSelected:g,onSelect:l,isSingle:s,selected:o,search:u,depth:c,useExpandedPanelId:m,controlId:i})),w?(0,n.createElement)(Xt,{...e,list:t.children,depth:c+1}):null)}))):null},Jt=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:c,onRemove:l})=>{if(e||t||!o)return null;const a=o.length;return(0,n.createElement)("div",{className:"woocommerce-search-list__selected"},(0,n.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,n.createElement)("strong",null,r.selected(a)),a>0?(0,n.createElement)(w.Button,{variant:"link",isDestructive:!0,onClick:()=>c([]),"aria-label":r.clear},(0,C.__)("Clear all","woocommerce")):null),a>0?(0,n.createElement)("ul",null,o.map(((e,t)=>(0,n.createElement)("li",{key:t},(0,n.createElement)(Zt,{label:e.name,id:e.id,remove:l}))))):null)},eo=({filteredList:e,search:t,onSelect:o,instanceId:r,useExpandedPanelId:c,...l})=>{const{messages:a,renderItem:i,selected:s,isSingle:u}=l,m=i||zt;return 0===e.length?(0,n.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,n.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,n.createElement)(P.A,{icon:Wt.A,role:"img"})),(0,n.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,C.sprintf)(a.noResults,t):a.noItems)):(0,n.createElement)("ul",{className:"woocommerce-search-list__list"},(0,n.createElement)(Xt,{useExpandedPanelId:c,list:e,selected:s,renderItem:m,onSelect:o,instanceId:r,isSingle:u,search:t}))},to=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:c,isSingle:l,list:i,messages:s=Vt,onChange:u,onSearch:m,selected:d,type:p="text",debouncedSpeak:_}=e,[g,E]=(0,a.useState)(""),h=(0,a.useState)(-1),b=(0,I.useInstanceId)(to),y=(0,a.useMemo)((()=>({...Vt,...s})),[s]),v=(0,a.useMemo)((()=>((e,t,o)=>{if(!t)return o?Mt(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),c=e.map((e=>!!r.test(e.name)&&e)).filter(Boolean);return o?Mt(c,e):c})(i,g,r)),[i,g,r]);(0,a.useEffect)((()=>{_&&_(y.updated)}),[_,y]),(0,a.useEffect)((()=>{"function"==typeof m&&m(g)}),[g,m]);const f=(0,a.useCallback)((e=>()=>{l&&u([]);const t=d.findIndex((({id:t})=>t===e));u([...d.slice(0,t),...d.slice(t+1)])}),[l,d,u]),k=(0,a.useCallback)((e=>()=>{Array.isArray(e)?u(e):-1===d.findIndex((({id:t})=>t===e.id))?u(l?[e]:[...d,e]):f(e.id)()}),[l,f,u,d]),S=(0,a.useCallback)((e=>{const[t]=d.filter((t=>!e.find((e=>t.id===e.id))));f(t.id)()}),[f,d]);return(0,n.createElement)("div",{className:(0,Ft.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":c,"is-token":"token"===p})},"text"===p&&(0,n.createElement)(Jt,{...e,onRemove:f,messages:y}),(0,n.createElement)("div",{className:"woocommerce-search-list__search"},"text"===p?(0,n.createElement)(w.TextControl,{label:y.search,type:"search",value:g,onChange:e=>E(e)}):(0,n.createElement)(w.FormTokenField,{disabled:c,label:y.search,onChange:S,onInputChange:e=>E(e),suggestions:[],__experimentalValidateInput:()=>!1,value:c?[(0,C.__)("Loading…","woocommerce")]:d.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),c?(0,n.createElement)("div",{className:"woocommerce-search-list__list"},(0,n.createElement)(w.Spinner,null)):(0,n.createElement)(eo,{...e,search:g,filteredList:v,messages:y,onSelect:k,instanceId:b,useExpandedPanelId:h}))},oo=((0,w.withSpokenMessages)(to),async e=>{if(!("json"in e))return{message:e.message,type:e.type||"general"};try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}});const ro=window.wp.escapeHtml,co=({error:e})=>(0,n.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,n.createElement)("span",null,(0,C.__)("The following error was returned","woocommerce"),(0,n.createElement)("br",null),(0,n.createElement)("code",null,(0,ro.escapeHTML)(e))):"api"===t?(0,n.createElement)("span",null,(0,C.__)("The following error was returned from the API","woocommerce"),(0,n.createElement)("br",null),(0,n.createElement)("code",null,(0,ro.escapeHTML)(e))):e:(0,C.__)("An error has prevented the block from being updated.","woocommerce"))(e)),no=({className:e,item:t,isSelected:o,isLoading:r,onSelect:c,disabled:l,...a})=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)(jt,{...a,key:t.id,className:e,isSelected:o,item:t,onSelect:c,disabled:l}),o&&r&&(0,n.createElement)("div",{key:"loading",className:(0,Ft.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},(0,n.createElement)(w.Spinner,null))),lo=((0,N.getSetting)("attributes",[]).reduce(((e,t)=>{const o=(r=t)&&r.attribute_name?{id:parseInt(r.attribute_id,10),name:r.attribute_name,taxonomy:"pa_"+r.attribute_name,label:r.attribute_label,orderby:r.attribute_orderby}:null;var r;return o&&o.id&&e.push(o),e}),[]),e=>{const{count:t,id:o,name:r,parent:c}=e;return{count:t,id:o,name:r,parent:c,breadcrumbs:[],children:[],value:(0,tt.isAttributeTerm)(e)?e.attr_slug:""}});o(2777);const ao=(0,I.withInstanceId)((({onChange:e,onOperatorChange:t,instanceId:o,isCompact:r=!1,messages:c={},operator:l="any",selected:i,type:s="text"})=>{const{errorLoadingAttributes:u,isLoadingAttributes:m,productsAttributes:d}=function(e){const[t,o]=(0,a.useState)(null),[r,c]=(0,a.useState)(!1),[n,l]=(0,a.useState)([]),i=(0,a.useRef)(!1);return(0,a.useEffect)((()=>{if(e&&!r&&!i.current)return async function(){c(!0);try{const e=await Ce()({path:"wc/store/v1/products/attributes"}),t=[];for(const o of e){const e=await xe(o.id);t.push({...o,parent:0,terms:e.map((e=>({...e,attr_slug:o.taxonomy,parent:o.id})))})}l(t),i.current=!0}catch(e){e instanceof Error&&o(await oo(e))}finally{c(!1)}}(),()=>{i.current=!0}}),[r,e]),{errorLoadingAttributes:t,isLoadingAttributes:r,productsAttributes:n}}(!0),p=d.reduce(((e,t)=>{const{terms:o,...r}=t;return[...e,lo(r),...o.map(lo)]}),[]);return c={clear:(0,C.__)("Clear all product attributes","woocommerce"),noItems:(0,C.__)("Your store doesn't have any product attributes.","woocommerce"),search:(0,C.__)("Search for product attributes","woocommerce"),selected:e=>(0,C.sprintf)(/* translators: %d is the count of attributes selected. */ /* translators: %d is the count of attributes selected. */ (0,C._n)("%d attribute selected","%d attributes selected",e,"woocommerce"),e),updated:(0,C.__)("Product attribute search results updated.","woocommerce"),...c},u?(0,n.createElement)(co,{error:u}):(0,n.createElement)(n.Fragment,null,(0,n.createElement)(to,{className:"woocommerce-product-attributes",isCompact:r,isHierarchical:!0,isLoading:m,isSingle:!1,list:p,messages:c,onChange:e,renderItem:e=>{const{item:t,search:r,depth:c=0}=e,l=t.count||0,a=["woocommerce-product-attributes__item","woocommerce-search-list__item",{"is-searching":r.length>0,"is-skip-level":0===c&&0!==t.parent}];if(!t.breadcrumbs.length)return(0,n.createElement)(no,{...e,className:(0,Ft.A)(a),item:t,isLoading:m,disabled:0===t.count,name:`attributes-${o}`,countLabel:(0,C.sprintf)(/* translators: %d is the count of terms. */ /* translators: %d is the count of terms. */ (0,C._n)("%d term","%d terms",l,"woocommerce"),l),"aria-label":(0,C.sprintf)(/* translators: %1$s is the item name, %2$d is the count of terms for the item. */ /* translators: %1$s is the item name, %2$d is the count of terms for the item. */ (0,C._n)("%1$s, has %2$d term","%1$s, has %2$d terms",l,"woocommerce"),t.name,l)});const i=`${t.breadcrumbs[0]}: ${t.name}`;return(0,n.createElement)(jt,{...e,name:`terms-${o}`,className:(0,Ft.A)(...a,"has-count"),countLabel:(0,C.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,C._n)("%d product","%d products",l,"woocommerce"),l),"aria-label":(0,C.sprintf)(/* translators: %1$s is the attribute name, %2$d is the count of products for that attribute. */ /* translators: %1$s is the attribute name, %2$d is the count of products for that attribute. */ (0,C._n)("%1$s, has %2$d product","%1$s, has %2$d products",l,"woocommerce"),i,l)})},selected:i.map((({id:e})=>p.find((t=>t.id===e)))).filter(Boolean),type:s}),!!t&&(0,n.createElement)("div",{hidden:i.length<2},(0,n.createElement)(w.SelectControl,{className:"woocommerce-product-attributes__operator",label:(0,C.__)("Display products matching","woocommerce"),help:(0,C.__)("Pick at least two attributes to use this setting.","woocommerce"),value:l,onChange:t,options:[{label:(0,C.__)("Any selected attributes","woocommerce"),value:"any"},{label:(0,C.__)("All selected attributes","woocommerce"),value:"all"}]})))})),io=`${N.ADMIN_URL}edit.php?post_type=product&page=product_attributes`,so=({query:e,trackInteraction:t,setQueryAttribute:o})=>{const r=e.woocommerceAttributes||[],c=null==r?void 0:r.map((({termId:e})=>({id:e}))),l=()=>{o({woocommerceAttributes:V.woocommerceAttributes}),t(f.ATTRIBUTES)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Product Attributes","woocommerce"),hasValue:()=>!(null==r||!r.length),onDeselect:l,resetAllFilter:l},(0,n.createElement)(ao,{messages:{search:(0,C.__)("Attributes","woocommerce")},selected:c||[],onChange:e=>{const r=e.map((({id:e,value:t})=>({termId:e,taxonomy:t})));o({woocommerceAttributes:r}),t(f.ATTRIBUTES)},operator:"any",isCompact:!0,type:"token"}),(0,n.createElement)(w.ExternalLink,{className:"wc-block-editor-product-collection-panel__manage-attributes-link",href:io},(0,C.__)("Manage attributes","woocommerce")))},uo={_fields:"id,name",order:"asc",orderby:"name",context:"view"},mo=e=>{var t;const o=e.match(/^(?:(.+) )?\(#(\d+)\)$/);return!!o&&{name:null!==(t=o[1])&&void 0!==t?t:"",id:parseInt(o[2],10)}},po=({taxonomy:e,termIds:t,onChange:o})=>{const{existingTerms:r,isLoadingExistingTerms:c}=(0,i.useSelect)((o=>{if(!t||!t.length)return{existingTerms:[],isLoadingExistingTerms:!1};const{getEntityRecords:r,hasFinishedResolution:c}=o("core"),n=["taxonomy",e.slug,{...uo,include:t}];return{existingTerms:r(...n),isLoadingExistingTerms:!c("getEntityRecords",n)}}),[e,t]),[l,s]=(0,a.useState)(""),{searchTerms:u}=(0,i.useSelect)((o=>{if(l.length<=1)return{searchTerms:[]};const{getEntityRecords:r}=o("core");return{searchTerms:r("taxonomy",e.slug,{...uo,exclude:t,search:l})}}),[e,t,l]),m=(0,I.useDebounce)(s,250),d=new Set,p=new Set,_=e=>(d.has(e.name)&&p.add(e.name),d.add(e.name),(e=>`${e.name} (#${e.id})`)(e)),g=r?r.map(_):[],E=u?u.map(_):[];if(r&&t.length!==r.length){const e=r.reduce(((e,t)=>(e[t.id]=t,e)),{});t.forEach((t=>{e[t]||g.push(`(#${t})`)}))}return(0,n.createElement)("div",{className:"wc-block-editor-product-collection-inspector__taxonomy-control"},(0,n.createElement)(w.FormTokenField,{label:e.name,value:g,onInputChange:m,onChange:e=>{const t=[];e.forEach((e=>{const o=mo(e);o&&t.push(o.id)})),o(t)},suggestions:E,disabled:c,displayTransform:e=>{const t=mo(e);return t&&(e=t.name?p.has(t.name)?`${t.name} (#${t.id})`:t.name:`(#${t.id} ${(0,C.__)("Missing","woocommerce")})`),(0,Ut.decodeEntities)(e)||""},__experimentalShowHowTo:!1}))},_o=function({setQueryAttribute:e,trackInteraction:t,query:o}){const{taxQuery:r}=o,c=(()=>{const e=(0,i.useSelect)((e=>{const{getTaxonomies:t}=e(s.store);return t({type:"product",per_page:-1})}),[]);return(0,a.useMemo)((()=>null==e?void 0:e.filter((({visibility:e})=>!(null==e||!e.publicly_queryable)))),[e])})();if(!c||0===c.length)return null;const l=e=>e?e.split(" ").map((e=>e.charAt(0).toUpperCase()+e.slice(1))).join(" "):"";return(0,n.createElement)(n.Fragment,null,c.map((o=>{const{slug:c,name:a}=o,i=(null==r?void 0:r[c])||[],s=o=>{e({taxQuery:{...r,[c]:o}}),t(`${f.TAXONOMY}__${c}`)},u=()=>{s([]),t(`${f.TAXONOMY}__${c}`)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{key:c,label:l(a),hasValue:()=>i.length,onDeselect:u,resetAllFilter:u},(0,n.createElement)(po,{key:c,taxonomy:o,termIds:i,onChange:s}))})))},go=({query:e,trackInteraction:t,setQueryAttribute:o})=>{const r=(ke.productCount||0)>100,c=e.woocommerceHandPickedProducts,[l,i]=(0,a.useState)(""),{productsMap:s,productsList:u}=function(e,t,o=[]){const[r,c]=(0,a.useState)(new Map),[n,l]=(0,a.useState)([]);return(0,a.useEffect)((()=>{const r={selected:e?o.map(Number):[],queryArgs:e?{search:t,per_page:40}:{per_page:0}};Pe(r).then((e=>{const t=new Map;e.forEach((e=>{t.set(e.id,e),t.set(e.name,e)})),l(e),c(t)}))}),[e,t,o]),{productsMap:r,productsList:n}}(r,l,c),m=(0,I.useDebounce)(i,250),d=(0,a.useCallback)((e=>{const r=e.reduce(((e,t)=>{const o=s.get(t)||s.get(Number(t));return o&&e.add(String(o.id)),e}),new Set);o({woocommerceHandPickedProducts:Array.from(r)}),t(f.HAND_PICKED)}),[o,t,s]),p=(0,a.useMemo)((()=>u.filter((e=>!(null!=c&&c.includes(String(e.id))))).map((e=>e.name))),[u,c]);return(0,n.createElement)(w.FormTokenField,{displayTransform:e=>{const t=Number(e);if(Number.isNaN(t))return(0,Ut.decodeEntities)(e)||"";const o=s.get(t);return(0,Ut.decodeEntities)(null==o?void 0:o.name)||""},label:(0,C.__)("Hand-Picked","woocommerce"),onChange:d,onInputChange:r?m:void 0,suggestions:p,__experimentalValidateInput:e=>s.has(e),value:s.size?c||[]:[(0,C.__)("Loading…","woocommerce")],__experimentalExpandOnFocus:!0,__experimentalShowHowTo:!1,placeholder:(0,C.__)("Search for products to display…","woocommerce")})},wo=({query:e,trackInteraction:t,setQueryAttribute:o})=>{const r=e.woocommerceHandPickedProducts,c=()=>{o({woocommerceHandPickedProducts:V.woocommerceHandPickedProducts}),t(f.HAND_PICKED)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Hand-Picked","woocommerce"),hasValue:()=>!(null==r||!r.length),onDeselect:c,resetAllFilter:c},(0,n.createElement)(go,{query:e,trackInteraction:t,setQueryAttribute:o}))},Eo=e=>{switch(e){case h.GRID:return(0,C.__)("Display products using rows and columns.","woocommerce");case h.STACK:return(0,C.__)("Display products in a single column.","woocommerce");default:return""}},ho=h.GRID,bo=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,c=t=>{e.setAttributes({displayLayout:{type:t,columns:o,shrinkColumns:r}})};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Layout","woocommerce"),hasValue:()=>t!==ho,isShownByDefault:!0,onDeselect:()=>{c(h.GRID)}},(0,n.createElement)(w.__experimentalToggleGroupControl,{label:(0,C.__)("Layout","woocommerce"),isBlock:!0,onChange:e=>{c(e)},help:Eo(t),value:t},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:h.STACK,label:(0,C.__)("Stack","woocommerce")}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:h.GRID,label:(0,C.__)("Grid","woocommerce")})))},yo=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,c=()=>{r({featured:V.featured}),o(f.FEATURED)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Featured","woocommerce"),hasValue:()=>!0===t.featured,onDeselect:c,resetAllFilter:c},(0,n.createElement)(w.BaseControl,{id:"product-collection-featured-products-control",label:(0,C.__)("Featured","woocommerce")},(0,n.createElement)(w.ToggleControl,{label:(0,C.__)("Show only featured products","woocommerce"),checked:t.featured||!1,onChange:e=>{r({featured:e}),o(f.FEATURED)}})))},vo=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,{timeFrame:c}=t,l=()=>{r({timeFrame:V.timeFrame}),o(f.CREATED)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Created","woocommerce"),hasValue:()=>(null==c?void 0:c.operator)&&(null==c?void 0:c.value),onDeselect:l,resetAllFilter:l},(0,n.createElement)(w.Flex,{direction:"column",gap:3},(0,n.createElement)(w.FlexItem,null,(0,n.createElement)(w.__experimentalToggleGroupControl,{label:(0,C.__)("Created","woocommerce"),isBlock:!0,onChange:e=>{r({timeFrame:{...c,operator:e}}),o(f.CREATED)},value:(null==c?void 0:c.operator)||y.IN},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:y.IN,label:(0,C._x)("Within","Product Collection query operator","woocommerce")}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:y.NOT_IN,label:(0,C._x)("Before","Product Collection query operator","woocommerce")}))),(0,n.createElement)(w.FlexItem,null,(0,n.createElement)(w.RadioControl,{onChange:e=>{r({timeFrame:{operator:y.IN,...c,value:e}}),o(f.CREATED)},options:[{label:"last 24 hours",value:"-1 day"},{label:"last 7 days",value:"-7 days"},{label:"last 30 days",value:"-30 days"},{label:"last 3 months",value:"-3 months"}],selected:null==c?void 0:c.value}))))},fo=window.wc.priceFormat,Co=({value:e,onChange:t,label:o})=>{const[r,c]=(0,a.useState)(`${e||""}`),l=(0,fo.getCurrency)(),i=((e="",t)=>{const o=e.replace(new RegExp(`[^0-9\\${t.decimalSeparator||""}]`,"g"),"").replace(new RegExp(`\\${t.decimalSeparator}`,"g"),"."),r=Number(o);if(""!==o&&!isNaN(r))return r<0?0:r})(r,l),s=((e,t)=>{if(void 0===e||isNaN(e))return;let o=((e,t)=>{const o=Math.pow(10,t.minorUnit),r=""+Math.round(e*o)/o;let[c,n]=r.split(".");return t.thousandSeparator&&(c=c.replace(/\B(?=(\d{3})+(?!\d))/g,t.thousandSeparator)),n?`${c}${t.decimalSeparator||"."}${n}`:c})(e,t);return null!=t&&t.prefix&&(o=`${t.prefix}${o}`),null!=t&&t.suffix&&(o=`${o}${t.suffix}`),o})(i,l);return(0,n.createElement)(w.__experimentalInputControl,{value:s,onChange:e=>{c(e)},onBlur:()=>{t(i)},onKeyDown:e=>{"Enter"===e.key&&t(i)},label:o,prefix:(0,n.createElement)(w.__experimentalInputControlPrefixWrapper,null,o),placeholder:(0,C.__)("Auto","woocommerce"),hideLabelFromVision:!0,type:"text",style:{textAlign:"right"},__next40pxDefaultSize:!0})},ko=e=>{const{query:t,trackInteraction:o,setQueryAttribute:r}=e,c=t.priceRange,l=()=>{r({priceRange:V.priceRange}),o(f.PRICE_RANGE)};return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Price Range","woocommerce"),hasValue:()=>void 0!==(null==c?void 0:c.min)||void 0!==(null==c?void 0:c.max),onDeselect:l,resetAllFilter:l,className:"wc-block-product-price-range-control"},(0,n.createElement)(w.BaseControl.VisualLabel,null,(0,C.__)("PRICE RANGE","woocommerce")),(0,n.createElement)(w.__experimentalHStack,{spacing:"2"},(0,n.createElement)(Co,{label:(0,C.__)("MIN","woocommerce"),value:null==c?void 0:c.min,onChange:e=>{r({priceRange:{min:0===e?void 0:e,max:null==c?void 0:c.max}}),o(f.PRICE_RANGE)}}),(0,n.createElement)(Co,{label:(0,C.__)("MAX","woocommerce"),value:null==c?void 0:c.max,onChange:e=>{const t=0===e?void 0:e;r({priceRange:{min:null==c?void 0:c.min,max:t}}),o(f.PRICE_RANGE)}})))};var So=o(4717);var Ao=o(2294),Ro=o(923),Io=o.n(Ro);const To=(0,I.createHigherOrderComponent)((e=>{class t extends a.Component{constructor(...e){super(...e),(0,Ao.A)(this,"state",{error:null,loading:!1,variations:{}}),(0,Ao.A)(this,"prevSelectedItem",void 0),(0,Ao.A)(this,"loadVariations",(()=>{const{products:e}=this.props,{loading:t,variations:o}=this.state;if(t)return;const r=this.getExpandedProduct();if(!r||o[r])return;const c=e.find((e=>e.id===r));var n;null!=c&&c.variations&&0!==c.variations.length?(this.setState({loading:!0}),(n=r,Ce()({path:(0,me.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:n})})).then((e=>{const t=e.map((e=>({...e,parent:r})));this.setState({variations:{...this.state.variations,[r]:t},loading:!1,error:null})})).catch((async e=>{const t=await oo(e);this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:t})}))):this.setState({variations:{...this.state.variations,[r]:null},loading:!1,error:null})}))}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:o,showVariations:r}=this.props;r&&(!Io()(e.selected,o)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){var t;const{products:o}=this.props;return null===(t=o.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:o}=this.props;if(!o)return null;let r=t&&t.length?t[0]:null;return r?this.prevSelectedItem=r:!this.prevSelectedItem||e||this.isProductId(this.prevSelectedItem)||(r=this.prevSelectedItem),!e&&r?this.isProductId(r)?r:this.findParentProduct(r):null}render(){const{error:t,isLoading:o}=this.props,{error:r,loading:c,variations:l}=this.state;return(0,n.createElement)(e,{...this.props,error:r||t,expandedProduct:this.getExpandedProduct(),isLoading:o,variations:l,variationsLoading:c})}}return t}),"withProductVariations"),Po=e=>{const{id:t,name:o,parent:r}=e;return{id:t,name:o,parent:r,breadcrumbs:[],children:[],details:e,value:e.slug}};o(7369);const xo={list:(0,C.__)("Products","woocommerce"),noItems:(0,C.__)("Your store doesn't have any products.","woocommerce"),search:(0,C.__)("Search for a product to display","woocommerce"),updated:(0,C.__)("Product search results updated.","woocommerce")},No=(e=>t=>{let{selected:o}=t;o=void 0===o?null:o;const r=null===o;return Array.isArray(o)?(0,n.createElement)(e,{...t}):(0,n.createElement)(e,{...t,selected:r?[]:[o]})})((qo=To((0,I.withInstanceId)((e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:c=!1,isLoading:l,onChange:a,onSearch:i,products:s,renderItem:u,selected:m=[],showVariations:d=!1,variations:p,variationsLoading:_}=e;if(o)return(0,n.createElement)(co,{error:o});const g=[...s,...p&&t&&p[t]?p[t]:[]].map(Po);return(0,n.createElement)(to,{className:"woocommerce-products",list:g,isCompact:c,isLoading:l,isSingle:!0,selected:g.filter((({id:e})=>m.includes(Number(e)))),onChange:a,renderItem:u||(d?e=>{var t,o,c,a;const{item:i,search:s,depth:u=0,isSelected:m,onSelect:d}=e,p=null!==(t=i.details)&&void 0!==t&&t.variations&&Array.isArray(i.details.variations)?i.details.variations.length:0,g=(0,Ft.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${u}`,"has-count",{"is-searching":s.length>0,"is-skip-level":0===u&&0!==i.parent,"is-variable":p>0});if(!i.breadcrumbs.length){var w,E,h,b,y;const t=(null===(w=i.details)||void 0===w?void 0:w.variations)&&i.details.variations.length>0;return(0,n.createElement)(no,{...e,className:(0,Ft.A)(g,{"is-selected":m}),isSelected:m,item:i,onSelect:()=>()=>{d(i)()},isLoading:l||_,countLabel:t?(0,C.sprintf)(/* translators: %1$d is the number of variations of a product product. */ /* translators: %1$d is the number of variations of a product product. */ (0,C.__)("%1$d variations","woocommerce"),null===(E=i.details)||void 0===E?void 0:E.variations.length):null,name:`products-${r}`,"aria-label":t?(0,C.sprintf)(/* translators: %1$s is the product name, %2$d is the number of variations of that product. */ /* translators: %1$s is the product name, %2$d is the number of variations of that product. */ (0,C._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",null===(h=i.details)||void 0===h||null===(b=h.variations)||void 0===b?void 0:b.length,"woocommerce"),i.name,null===(y=i.details)||void 0===y?void 0:y.variations.length):void 0})}const v=(0,tt.isEmpty)(null===(o=i.details)||void 0===o?void 0:o.variation)?e:{...e,item:{...e.item,name:null===(c=i.details)||void 0===c?void 0:c.variation},"aria-label":`${i.breadcrumbs[0]}: ${null===(a=i.details)||void 0===a?void 0:a.variation}`};return(0,n.createElement)(jt,{...v,className:g,name:`variations-${r}`})}:void 0),onSearch:i,messages:{...xo,...e.messages},isHierarchical:!0})}))),({selected:e,...t})=>{const[o,r]=(0,a.useState)(!0),[c,l]=(0,a.useState)(null),[i,s]=(0,a.useState)([]),u=ke.productCount>100,m=async e=>{const t=await oo(e);l(t),r(!1)},d=(0,a.useRef)(e);(0,a.useEffect)((()=>{Pe({selected:d.current}).then((e=>{s(e),r(!1)})).catch(m)}),[d]);const p=(0,So.YQ)((t=>{Pe({selected:e,search:t}).then((e=>{s(e),r(!1)})).catch(m)}),400),_=(0,a.useCallback)((e=>{r(!0),p(e)}),[r,p]);return(0,n.createElement)(qo,{...t,selected:e,error:c,products:i,isLoading:o,onSearch:u?_:null})})),Oo="product",Lo="cart",Do="order",Bo=({isOpen:e,onToggle:t,product:o,isLoading:r})=>{var c,l;if(r&&!o)return(0,n.createElement)(w.Spinner,null);const a=!o,i=a||!(null!=o&&null!==(c=o.images)&&void 0!==c&&null!==(l=c[0])&&void 0!==l&&l.src),s=i?`${Se}/blocks/product-collection/placeholder.svg`:o.images[0].src,u=i?"":null==o?void 0:o.name;return(0,n.createElement)(w.Button,{className:"wc-block-product-collection-linked-product-control__button",onClick:t,"aria-expanded":e,disabled:r},(0,n.createElement)(w.Flex,{direction:"row",expanded:!0,justify:"flex-start"},(0,n.createElement)(w.FlexItem,{className:"wc-block-product-collection-linked-product-control__image-container"},(0,n.createElement)("img",{src:s,alt:u})),(0,n.createElement)(w.Flex,{direction:"column",align:"flex-start",gap:1,className:"wc-block-product-collection-linked-product-control__content"},a?(0,n.createElement)(w.FlexItem,null,(0,n.createElement)(w.__experimentalText,{color:"inherit",lineHeight:1},(0,C.__)("Select product","woocommerce"))):(0,n.createElement)(n.Fragment,null,(0,n.createElement)(w.FlexItem,null,(0,n.createElement)(w.__experimentalText,{color:"inherit",lineHeight:1},null!=o&&o.name?(0,Ut.decodeEntities)(o.name):"")),(0,n.createElement)(w.FlexItem,null,(0,n.createElement)(w.__experimentalText,{color:"inherit",lineHeight:1},null==o?void 0:o.sku))))))},Fo=({query:e,setAttributes:t,setIsDropdownOpen:o})=>(0,n.createElement)(No,{selected:null==e?void 0:e.productReference,onChange:(r=[])=>{var c,n;const l=null!==(c=null===(n=r[0])||void 0===n?void 0:n.id)&&void 0!==c?c:null;null!==l&&(t({query:{...e,productReference:l}}),o(!1))},messages:{search:(0,C.__)("Select a product","woocommerce")}});var qo,Uo=function(e){return e.CURRENT_PRODUCT="CURRENT_PRODUCT",e.SPECIFIC_PRODUCT="SPECIFIC_PRODUCT",e}(Uo||{});const Vo=({query:e,setAttributes:t,location:o,usesReference:r})=>{const c=o.type===Oo,l=!(null==r||!r.includes(Oo)),i=o.type===Lo,s=!(null==r||!r.includes(Lo)),u=o.type===Do,m=!(null==r||!r.includes(Do)),{productReference:d}=e,{product:p,isLoading:_}=(e=>{const[t,o]=(0,a.useState)(null),[r,c]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{(async()=>{if(e){c(!0);try{const t=await(e=>Ce()({path:`/wc/store/v1/products/${e}`}))(e);o(t)}catch(e){o(null)}finally{c(!1)}}else o(null),c(!1)})()}),[e]),{product:t,isLoading:r}})(d),[g,E]=(0,a.useState)(!1),[h,b]=(0,a.useState)((c||i||u)&&(0,tt.isEmpty)(d)?Uo.CURRENT_PRODUCT:Uo.SPECIFIC_PRODUCT),y=(0,a.useRef)(void 0),v=c&&l||i&&s||u&&m,f=v?h===Uo.SPECIFIC_PRODUCT:!(0,tt.isEmpty)(d);if(!v&&!f||!(l||s||m))return null;const k=h===Uo.CURRENT_PRODUCT?(0,C.__)("Linked products will be pulled from the product a shopper is currently viewing","woocommerce"):(0,C.__)("Select a product to pull the linked products from","woocommerce"),S=((e,t,o)=>e===Lo&&t?(0,C.__)("From products in the cart","woocommerce"):e===Do&&o?(0,C.__)("From products in the order","woocommerce"):(0,C.__)("From the current product","woocommerce"))(o.type,s,m);return(0,n.createElement)(w.PanelBody,{title:(0,C.__)("Linked Product","woocommerce")},v&&(0,n.createElement)(w.PanelRow,null,(0,n.createElement)(w.RadioControl,{className:"wc-block-product-collection-product-reference-radio",label:(0,C.__)("Products to show","woocommerce"),help:k,selected:h,options:[{label:S,value:Uo.CURRENT_PRODUCT},{label:(0,C.__)("From a specific product","woocommerce"),value:Uo.SPECIFIC_PRODUCT}],onChange:o=>{if(o===Uo.CURRENT_PRODUCT){const{productReference:o,...r}=e;y.current=o,t({query:r})}else t({query:y.current?{...e,productReference:y.current}:e});b(o)}})),f&&(0,n.createElement)(w.PanelRow,null,(0,n.createElement)(w.Dropdown,{className:"wc-block-product-collection-linked-product-control",contentClassName:"wc-block-product-collection-linked-product__popover-content",popoverProps:{placement:"left-start"},renderToggle:({isOpen:e,onToggle:t})=>(0,n.createElement)(Bo,{isOpen:e,onToggle:t,product:p,isLoading:_}),renderContent:()=>(0,n.createElement)(Fo,{query:e,setAttributes:t,setIsDropdownOpen:E}),open:g,onToggle:()=>E(!g)})))},Mo=({dimensions:e,setAttributes:t})=>{const{widthType:o,fixedWidth:r=""}=e;return(0,n.createElement)(w.__experimentalToolsPanelItem,{label:(0,C.__)("Width","woocommerce"),hasValue:()=>o!==b.FILL,isShownByDefault:!0},(0,n.createElement)(w.__experimentalToggleGroupControl,{label:(0,C.__)("Width","woocommerce"),value:o,help:(c=o,c===b.FILL?(0,C.__)("Stretch to fill available space.","woocommerce"):(0,C.__)("Specify a fixed width.","woocommerce")),onChange:o=>(o=>{t({dimensions:{...e,widthType:o}})})(o),isBlock:!0},(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:b.FILL,label:(0,C.__)("Fill","woocommerce")}),(0,n.createElement)(w.__experimentalToggleGroupControlOption,{value:b.FIXED,label:(0,C.__)("Fixed","woocommerce")})),o===b.FIXED&&(0,n.createElement)(w.__experimentalUnitControl,{onChange:o=>{t({dimensions:{...e,fixedWidth:o}})},value:r}));var c},Ho=({query:e,setQueryAttribute:t,trackInteraction:o})=>{const r=null==e?void 0:e.relatedBy,c=(e,c)=>{const n={...r,[c]:e};t({relatedBy:n}),o(f.RELATED_BY)};return(0,n.createElement)(w.PanelBody,{title:(0,C.__)("Related by","woocommerce")},(0,n.createElement)("div",{className:"wc-block-editor-product-collection-inspector-controls__relate-by"},(0,n.createElement)(w.CheckboxControl,{label:(0,C.__)("Categories","woocommerce"),checked:null==r?void 0:r.categories,onChange:e=>{c(e,"categories")}}),(0,n.createElement)(w.CheckboxControl,{label:(0,C.__)("Tags","woocommerce"),checked:null==r?void 0:r.tags,onChange:e=>{c(e,"tags")}})))},$o=e=>{const{attributes:t,context:o,setAttributes:r}=e,{query:c,hideControls:i,dimensions:s,displayLayout:u}=t,m=gt(o.templateSlug),d=(null==c?void 0:c.inherit)||!1,p=(e=>t=>!e.includes(t))(i),_="product-catalog"===m||"product-archive"===m,g=!1===d,E=_&&p(f.INHERIT),h=!_&&p(f.FILTERABLE),b=g&&p(f.ORDER),y=p(f.ON_SALE),v=p(f.STOCK_STATUS),k=p(f.HAND_PICKED),S=p(f.KEYWORD),A=p(f.ATTRIBUTES),I=p(f.TAXONOMY),T=p(f.FEATURED),P=p(f.CREATED),x=p(f.PRICE_RANGE),N={setAttributes:r,displayLayout:u},O={setAttributes:r,dimensions:s},L={setQueryAttribute:(0,a.useMemo)((()=>Ne.bind(null,e)),[e]),trackInteraction:e=>R("blocks_product_collection_inspector_control_clicked",{collection:t.collection,location:m,filter:e}),query:c};return(0,n.createElement)(l.InspectorControls,null,(0,n.createElement)(Vo,{query:e.attributes.query,setAttributes:e.setAttributes,usesReference:e.usesReference,location:e.location}),(0,n.createElement)(w.__experimentalToolsPanel,{label:(0,C.__)("Settings","woocommerce"),resetAll:()=>{const t=Ue(e.attributes);e.setAttributes(t)}},E&&(0,n.createElement)(Tt,{...L}),h&&(0,n.createElement)(Pt,{...L}),(0,n.createElement)(bo,{...N}),(0,n.createElement)(ft,{...N}),b&&(0,n.createElement)(Nt,{...L})),(0,n.createElement)(w.__experimentalToolsPanel,{label:(0,C.__)("Dimensions","woocommerce"),resetAll:()=>{const t=Ue(e.attributes);e.setAttributes(t)}},(0,n.createElement)(Mo,{...O})),g?(0,n.createElement)(w.__experimentalToolsPanel,{label:(0,C.__)("Filters","woocommerce"),resetAll:e=>{e.forEach((e=>{e()}))},className:"wc-block-editor-product-collection-inspector-toolspanel__filters"},y&&(0,n.createElement)(Ot,{...L}),v&&(0,n.createElement)(Dt,{...L}),k&&(0,n.createElement)(wo,{...L}),S&&(0,n.createElement)(Bt,{...L}),A&&(0,n.createElement)(so,{...L}),I&&(0,n.createElement)(_o,{...L}),T&&(0,n.createElement)(yo,{...L}),P&&(0,n.createElement)(vo,{...L}),x&&(0,n.createElement)(ko,{...L})):null,(0,n.createElement)(Xe,null))},Go=e=>e===c.name,jo=e=>{const t=e+2592e5;return Date.now()<t},Ko=(e=0)=>e<=4,Wo=e=>{const t=(0,a.useMemo)((()=>Ne.bind(null,e)),[e]),o=gt(e.context.templateSlug),r={setQueryAttribute:t,trackInteraction:t=>R("blocks_product_collection_inspector_control_clicked",{collection:e.attributes.collection,location:o,filter:t}),query:e.attributes.query};return(0,n.createElement)(l.InspectorControls,null,"woocommerce/product-collection/hand-picked"===e.attributes.collection&&(0,n.createElement)(w.PanelBody,null,(0,n.createElement)(go,{...r})),"woocommerce/product-collection/related"===e.attributes.collection&&(0,n.createElement)(Ho,{...r}))};(0,ue.addFilter)("editor.BlockEdit",c.name,(e=>t=>Go(t.name)&&t.isSelected?(0,n.createElement)(n.Fragment,null,(0,n.createElement)(Wo,{...t}),(0,n.createElement)(e,{...t})):(0,n.createElement)(e,{...t}))),(0,ue.addFilter)("editor.BlockEdit",c.name,(e=>t=>{if(!Go(t.name))return(0,n.createElement)(e,{...t});const o=(e=>{const{attributes:t}=e,{convertedFromProducts:o}=t,{status:r,time:c,displayCount:n}=nt();return o&&"notseen"===r&&jo(c)&&Ko(n)})(t),r=(e=>{const{attributes:t}=e,{convertedFromProducts:o}=t,{status:r,time:c,displayCount:n}=nt();return o&&("seen"===r||!jo(c)||!Ko(n))})(t);return r&&t.setAttributes({convertedFromProducts:!1}),(0,n.createElement)(n.Fragment,null,o&&(0,n.createElement)(l.InspectorControls,null,(0,n.createElement)(ht,{revertMigration:mt})),(0,n.createElement)(e,{...t}))}));const Qo=["core/post-content","woocommerce/mini-cart","woocommerce/featured-product"],Yo=["core/","woocommerce/"],Zo=(0,C.__)("Enable to enforce full page reload on certain interactions, like using paginations controls.","woocommerce"),zo=(0,C.__)("Browsing between pages requires a full page reload.","woocommerce"),Xo=(0,C.__)("Reload full page can't be disabled because there are incompatible blocks inside the Product Collection block.","woocommerce"),Jo=e=>{const{clientId:t,forcePageReload:o,setAttributes:r}=e,c=(e=>(0,i.useSelect)((t=>{const{getClientIdsOfDescendants:o,getBlockName:r}=t(l.store);return o(e).find((e=>{var t;return t=r(e),!(!Qo.includes(t)&&Yo.find((e=>t.startsWith(e))))}))||!1}),[e]))(t);(0,a.useEffect)((()=>{!o&&c&&r({forcePageReload:!0})}),[o,c,r]);let s=Zo;return o&&(s=zo),c&&(s=Xo),(0,n.createElement)(w.ToggleControl,{label:(0,C.__)("Reload full page","woocommerce"),help:s,checked:o,onChange:()=>r({forcePageReload:!o}),disabled:c})};function er(e){const{clientId:t,attributes:o,setAttributes:r}=e,{forcePageReload:c}=o;return(0,n.createElement)(l.InspectorAdvancedControls,null,(0,n.createElement)(Jo,{clientId:t,forcePageReload:c,setAttributes:r}))}var tr=o(6287);const or=({onToggle:e})=>(0,n.createElement)(w.ToolbarButton,{icon:tr.A,label:(0,C.__)("Display settings","woocommerce"),onClick:e}),rr=({query:e,setQueryAttribute:t})=>{const o=e=>{const o=Number(e);!isNaN(o)&&o>=1&&o<=100&&t({perPage:o})},r=e=>{const o=Number(e);!isNaN(o)&&o>=0&&o<=100&&t({offset:o})},c=e=>{const o=Number(e);!isNaN(o)&&o>=0&&t({pages:o})},l={__unstableInputWidth:"60px",labelPosition:"edge",step:"1",isDragEnabled:!1};return(0,n.createElement)(w.ToolbarGroup,null,(0,n.createElement)(w.Dropdown,{contentClassName:"wc-block-editor-product-collection__display-settings",renderToggle:({onToggle:e})=>(0,n.createElement)(or,{onToggle:e}),renderContent:()=>(0,n.createElement)(n.Fragment,null,(0,n.createElement)(w.__experimentalNumberControl,{...l,label:(0,C.__)("Items per Page","woocommerce"),min:1,max:100,onChange:o,value:e.perPage}),(0,n.createElement)(w.__experimentalNumberControl,{...l,label:(0,C.__)("Offset","woocommerce"),min:0,max:100,onChange:r,value:e.offset}),(0,n.createElement)(w.BaseControl,{help:(0,C.__)("Limit the pages you want to show, even if the query has more results. To show all pages use 0 (zero).","woocommerce"),id:"woocommerce-products-block__display-settings-pages"},(0,n.createElement)(w.__experimentalNumberControl,{...l,label:(0,C.__)("Max page to show","woocommerce"),min:0,onChange:c,value:e.pages})))}))};var cr=o(5866),nr=o(6554);const lr=e=>{const{type:t,columns:o,shrinkColumns:r}=e.displayLayout,c=t=>{e.setAttributes({displayLayout:t})},l=[{icon:cr.A,title:(0,C.__)("List view","woocommerce"),onClick:()=>c({type:h.STACK,columns:o,shrinkColumns:r}),isActive:t===h.STACK},{icon:nr.A,title:(0,C.__)("Grid view","woocommerce"),onClick:()=>c({type:h.GRID,columns:o,shrinkColumns:r}),isActive:t===h.GRID}];return(0,n.createElement)(w.ToolbarGroup,{controls:l})},ar=e=>(0,n.createElement)(w.ToolbarGroup,null,(0,n.createElement)(w.ToolbarButton,{onClick:e.openCollectionSelectionModal},(0,C.__)("Choose collection","woocommerce")));function ir(e){var t;const{attributes:o,openCollectionSelectionModal:r,setAttributes:c}=e,{query:i,displayLayout:s}=o,u=(0,a.useMemo)((()=>Ne.bind(null,e)),[e]),m=se(e.attributes.collection),d=(null==m||null===(t=m.scope)||void 0===t?void 0:t.includes("block"))||void 0===(null==m?void 0:m.scope);return(0,n.createElement)(l.BlockControls,null,d&&(0,n.createElement)(ar,{openCollectionSelectionModal:r}),!i.inherit&&(0,n.createElement)(n.Fragment,null,(0,n.createElement)(rr,{query:i,setQueryAttribute:u}),(0,n.createElement)(lr,{displayLayout:s,setAttributes:c})))}const sr=({preview:{setPreviewState:e,initialPreviewState:t}={},...o})=>{var r,c,s,m;const d=(0,a.useRef)(!1),{clientId:p,attributes:_,setAttributes:g,location:E,isUsingReferencePreviewMode:h}=o;(({setPreviewState:e,location:t,attributes:o,setAttributes:r,isUsingReferencePreviewMode:c})=>{var n,l;const i=e=>{r({__privatePreviewState:{...o.__privatePreviewState,...e}})},s=((e,t)=>t?e.type===u.Product?(0,C.__)("Actual products will vary depending on the product being viewed.","woocommerce"):(0,C.__)("Actual products will vary depending on the page being viewed.","woocommerce"):"")(t,c);(0,a.useLayoutEffect)((()=>{c&&r({__privatePreviewState:{isPreview:s.length>0,previewMessage:s}})}),[r,s,c]),(0,a.useLayoutEffect)((()=>{if(e||c)return(null==e?void 0:e({setState:i,location:t,attributes:o}))||void 0}),[e]);const m=t.type===u.Archive?null===(n=t.sourceData)||void 0===n?void 0:n.termId:null;(0,a.useLayoutEffect)((()=>{if(!e&&!c){var n;const e=t.type===u.Archive&&null===m;r({__privatePreviewState:{isPreview:!!e&&!(null==o||null===(n=o.query)||void 0===n||!n.inherit),previewMessage:(0,C.__)("Actual products will vary depending on the page being viewed.","woocommerce")}})}}),[null==o||null===(l=o.query)||void 0===l?void 0:l.inherit,s,m,t.type,r,e,c])})({setPreviewState:e,setAttributes:g,location:E,attributes:_,isUsingReferencePreviewMode:h});const y=(0,l.useBlockProps)(),v=(0,l.useInnerBlocksProps)(y,{template:$}),f=((e,t,o)=>{const r=(0,I.useInstanceId)(o),{getBlockParentsByBlockName:c}=(0,i.useSelect)(l.store);let n=r;return(0,a.useMemo)((()=>c(e,"core/block")),[c,e]).length>0&&(n=t.queryId),n})(p,_,sr),k={...U,query:{...U.query,inherit:De(),filterable:Be()},..._,queryId:f,...!!_.collection&&t&&{__privatePreviewState:t}};let S={};return b.FIXED===(null==_||null===(r=_.dimensions)||void 0===r?void 0:r.widthType)&&null!=_&&null!==(c=_.dimensions)&&void 0!==c&&c.fixedWidth&&(S={maxWidth:_.dimensions.fixedWidth,margin:"0 auto"}),(0,a.useEffect)((()=>{g(k),d.current=!0}),[]),d.current=d.current||Qe()(_,k),d.current?(0,n.createElement)("div",{...y},(null===(s=_.__privatePreviewState)||void 0===s?void 0:s.isPreview)&&o.isSelected&&(0,n.createElement)(w.Button,{variant:"primary",size:"small",showTooltip:!0,label:null===(m=_.__privatePreviewState)||void 0===m?void 0:m.previewMessage,className:"wc-block-product-collection__preview-button","data-testid":"product-collection-preview-button"},"Preview"),(0,n.createElement)($o,{...o}),(0,n.createElement)(er,{...o}),(0,n.createElement)(ir,{...o}),(0,n.createElement)("div",{...v,style:S})):null},ur=sr,mr=e=>{const{clientId:t,attributes:o,tracksLocation:r,closePatternSelectionModal:c}=e,{collection:s}=o,{replaceBlock:u}=(0,i.useDispatch)(l.store),[m,d]=(0,a.useState)(s),p=e=>{R("blocks_product_collection_collection_replaced_from_placeholder",{action:e,location:r}),c()};return(0,n.createElement)(w.Modal,{overlayClassName:"wc-blocks-product-collection__modal",title:(0,C.__)("What products do you want to show?","woocommerce"),onRequestClose:()=>p("close"),size:"large"},(0,n.createElement)("div",{className:"wc-blocks-product-collection__content"},(0,n.createElement)(je,{chosenCollection:m,onCollectionClick:d}),(0,n.createElement)("div",{className:"wc-blocks-product-collection__footer"},(0,n.createElement)(w.Button,{variant:"tertiary",onClick:()=>p("cancel")},(0,C.__)("Cancel","woocommerce")),(0,n.createElement)(w.Button,{variant:"primary",onClick:()=>{m&&(R("blocks_product_collection_collection_replaced_from_placeholder",{from:s,to:m,location:r}),Ve(m,t,u))}},(0,C.__)("Continue","woocommerce")))))};o(6818);const dr=e=>{var t;const o=(0,l.useBlockProps)(),{attributes:r,isDeletedProductReference:c}=e,i=se(r.collection);if(!i)return null;const s=c?(0,C.__)("Previously selected product is no longer available.","woocommerce"):(0,a.createInterpolateElement)((0,C.sprintf)(/* translators: %s: collection title */ /* translators: %s: collection title */ (0,C.__)("<strong>%s</strong> requires a product to be selected in order to display associated items.","woocommerce"),i.title),{strong:(0,n.createElement)("strong",null)});return(0,n.createElement)("div",{...o},(0,n.createElement)(w.Placeholder,{className:"wc-blocks-product-collection__editor-product-picker"},(0,n.createElement)(w.__experimentalHStack,{alignment:"center"},(0,n.createElement)(P.A,{icon:Wt.A,className:"wc-blocks-product-collection__info-icon"}),(0,n.createElement)(w.__experimentalText,null,s)),(0,n.createElement)(No,{selected:null===(t=r.query)||void 0===t?void 0:t.productReference,onChange:(t=[])=>{var o,c;null!==(null!==(o=null===(c=t[0])||void 0===c?void 0:c.id)&&void 0!==o?o:null)&&e.setAttributes({query:{...r.query,productReference:t[0].id}})},messages:{search:(0,C.__)("Select a product","woocommerce")}})))};var pr=o(6465);function _r(e,{blockDescription:t,blockIcon:o,blockTitle:c,variationName:n}){(0,r.registerBlockVariation)(e,{description:t,name:n,title:c,isActive:e=>e.__woocommerceNamespace===n,icon:{src:o},attributes:{__woocommerceNamespace:n},scope:["block","inserter"]})}const gr=(0,C.__)("Product Summary","woocommerce"),wr=((0,n.createElement)(P.A,{icon:pr.A,className:"wc-block-editor-components-block-icon"}),(0,C.__)("Display a short description about a product.","woocommerce")),Er=`${c.name}/product-summary`;var hr=o(4478);const br=(0,C.__)("Product Title","woocommerce"),yr=((0,n.createElement)(P.A,{icon:hr.A,className:"wc-block-editor-components-block-icon"}),(0,C.__)("Display the title of a product.","woocommerce")),vr=`${c.name}/product-title`;(0,r.registerBlockType)(c,{icon:()=>(0,n.createElement)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},(0,n.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M19 11H5C4.72386 11 4.5 11.2239 4.5 11.5V17.5C4.5 17.7761 4.72386 18 5 18H19C19.2761 18 19.5 17.7761 19.5 17.5V11.5C19.5 11.2239 19.2761 11 19 11ZM5 9.5H19C20.1046 9.5 21 10.3954 21 11.5V17.5C21 18.6046 20.1046 19.5 19 19.5H5C3.89543 19.5 3 18.6046 3 17.5V11.5C3 10.3954 3.89543 9.5 5 9.5Z",fill:"currentColor"}),(0,n.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 7.5C18 7.77614 17.7761 8 17.5 8L6.5 8C6.22386 8 6 7.77614 6 7.5V7.5C6 7.22386 6.22386 7 6.5 7L17.5 7C17.7761 7 18 7.22386 18 7.5V7.5Z",fill:"currentColor"}),(0,n.createElement)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16 5C16 5.27614 15.7761 5.5 15.5 5.5L8.5 5.5C8.22386 5.5 8 5.27614 8 5V5C8 4.72386 8.22386 4.5 8.5 4.5L15.5 4.5C15.7761 4.5 16 4.72386 16 5V5Z",fill:"currentColor"})),edit:e=>{const{clientId:t,attributes:o,context:r}=e,c=((e,t)=>{const o=e.templateSlug||"",r=e.postId||null,c=(e=>t=>e.replace(`${t}-`,""))(o),n=(e=>t=>e.includes(t)&&e!==t)(o),s=n(m),w=n(d),E=n(p),[h,b]=(0,a.useState)(null),[y,v]=(0,a.useState)(null),[f,C]=(0,a.useState)(null);(0,a.useEffect)((()=>{if(s){const e=c(m);_("postType","product",e,b)}if(w){const e=c(d);_("taxonomy","product_cat",e,v)}if(E){const e=c(p);_("taxonomy","product_tag",e,C)}}),[s,w,E,c]);const{isInSingleProductBlock:k,isInSomeCartCheckoutBlock:S}=(0,i.useSelect)((e=>{const{getBlockParentsByBlockName:o}=e(l.store),r=e=>o(t,e).length>0;return{isInSingleProductBlock:r(["woocommerce/single-product"]),isInSomeCartCheckoutBlock:r(["woocommerce/cart","woocommerce/checkout","woocommerce/mini-cart-contents"])}}),[t]);if(k)return g(u.Product,{productId:r});if(S)return g(u.Cart);if(s)return g(u.Product,{productId:h});const A=(e=>t=>e===t)(o);if(A(m))return g(u.Product,{productId:null});if(w)return g(u.Archive,{taxonomy:"product_cat",termId:y});if(E)return g(u.Archive,{taxonomy:"product_tag",termId:f});if(A(d))return g(u.Archive,{taxonomy:"product_cat",termId:null});if(A(p))return g(u.Archive,{taxonomy:"product_tag",termId:null});if(A("taxonomy-product_attribute"))return g(u.Archive,{taxonomy:null,termId:null});if("page-cart"===o||"page-checkout"===o)return g(u.Cart);const R=A("order-confirmation");return g(R?u.Order:u.Site)})(r,t),h=gt(r.templateSlug),[b,y]=(0,a.useState)(!1),v=(0,i.useSelect)((e=>!!e(l.store).getBlocks(t).length),[t]),{productCollectionUIStateInEditor:f,isLoading:C}=(({location:e,usesReference:t,attributes:o,hasInnerBlocks:r})=>{var c,n,l,m;const d=null===(c=o.query)||void 0===c?void 0:c.productReference,{product:p,hasResolved:_}=(0,i.useSelect)((e=>{if(!d)return{product:null,hasResolved:!0};const{getEntityRecord:t,hasFinishedResolution:o}=e(s.store),r=["postType","product",d];return{product:t(...r),hasResolved:o("getEntityRecord",r)}}),[d]);return{productCollectionUIStateInEditor:(0,a.useMemo)((()=>{var c,n;const l=null==t?void 0:t.includes(e.type),a=!!o.collection,i=null==t?void 0:t.includes("product"),s=null!==(null!==(c=null===(n=o.query)||void 0===n?void 0:n.productReference)&&void 0!==c?c:null);if(a&&i&&!l&&!s)return E.PRODUCT_REFERENCE_PICKER;if(a&&i&&!l&&s&&d&&(void 0===p||"trash"===(null==p?void 0:p.status)))return E.DELETED_PRODUCT_REFERENCE;if(l){var m,_,g,w;const t=e.type===u.Archive&&null!==(null!==(m=null===(_=e.sourceData)||void 0===_?void 0:_.termId)&&void 0!==m?m:null),o=e.type===u.Product&&null!==(null!==(g=null===(w=e.sourceData)||void 0===w?void 0:w.productId)&&void 0!==g?g:null);if(!t&&!o&&!d)return E.VALID_WITH_PREVIEW}return r||a?E.VALID:E.COLLECTION_PICKER}),[e.type,null===(n=e.sourceData)||void 0===n?void 0:n.termId,null===(l=e.sourceData)||void 0===l?void 0:l.productId,t,o.collection,d,p,r,null===(m=o.query)||void 0===m?void 0:m.productReference]),isLoading:!_}})({location:c,attributes:o,hasInnerBlocks:v,usesReference:e.usesReference});if(C)return(0,n.createElement)(w.Flex,{justify:"center",align:"center"},(0,n.createElement)(w.Spinner,null));const k={...e,openCollectionSelectionModal:()=>y(!0),location:c,isUsingReferencePreviewMode:f===E.VALID_WITH_PREVIEW};return(0,n.createElement)(n.Fragment,null,(()=>{switch(f){case E.COLLECTION_PICKER:return(0,n.createElement)(Ke,{...e,tracksLocation:h});case E.PRODUCT_REFERENCE_PICKER:return(0,n.createElement)(dr,{...e,isDeletedProductReference:!1});case E.DELETED_PRODUCT_REFERENCE:return(0,n.createElement)(dr,{...e,isDeletedProductReference:!0});case E.VALID:case E.VALID_WITH_PREVIEW:return(0,n.createElement)(ur,{...k});default:return(0,n.createElement)(Ke,{...e,tracksLocation:h})}})(),b&&(0,n.createElement)(mr,{clientId:t,attributes:o,tracksLocation:h,closePatternSelectionModal:()=>y(!1)}))},save:function({attributes:{tagName:e="div"}}){const t=l.useBlockProps.save(),o=l.useInnerBlocksProps.save(t);return(0,n.createElement)(e,{...o})}}),_r("core/post-excerpt",{blockDescription:wr,blockIcon:(0,n.createElement)(w.Icon,{icon:pr.A}),blockTitle:gr,variationName:Er}),_r("core/post-title",{blockDescription:yr,blockIcon:(0,n.createElement)(w.Icon,{icon:hr.A}),blockTitle:br,variationName:vr}),ie.forEach((e=>(0,T.__experimentalRegisterProductCollection)(e))),(0,N.isWpVersion)("6.1",">=")&&(0,ue.addFilter)("blocks.registerBlockType","woocommerce/add-product-collection-block-to-parent-array-of-pagination-block",((e,t)=>t!==H?e:null!=e&&e.ancestor?{...e,ancestor:[...e.ancestor,c.name]}:null!=e&&e.parent?{...e,parent:[...e.parent,c.name]}:e))},6818:()=>{},1598:()=>{},2777:()=>{},7369:()=>{},8137:()=>{},6636:()=>{},1609:e=>{"use strict";e.exports=window.React},9491:e=>{"use strict";e.exports=window.wp.compose},6087:e=>{"use strict";e.exports=window.wp.element},7723:e=>{"use strict";e.exports=window.wp.i18n},923:e=>{"use strict";e.exports=window.wp.isShallowEqual},5573:e=>{"use strict";e.exports=window.wp.primitives}},c={};function n(e){var t=c[e];if(void 0!==t)return t.exports;var o=c[e]={exports:{}};return r[e].call(o.exports,o,o.exports,n),o.exports}n.m=r,e=[],n.O=(t,o,r,c)=>{if(!o){var l=1/0;for(u=0;u<e.length;u++){for(var[o,r,c]=e[u],a=!0,i=0;i<o.length;i++)(!1&c||l>=c)&&Object.keys(n.O).every((e=>n.O[e](o[i])))?o.splice(i--,1):(a=!1,c<l&&(l=c));if(a){e.splice(u--,1);var s=r();void 0!==s&&(t=s)}}return t}c=c||0;for(var u=e.length;u>0&&e[u-1][2]>c;u--)e[u]=e[u-1];e[u]=[o,r,c]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var c=Object.create(null);n.r(c);var l={};t=t||[null,o({}),o([]),o(o)];for(var a=2&r&&e;"object"==typeof a&&!~t.indexOf(a);a=o(a))Object.getOwnPropertyNames(a).forEach((t=>l[t]=()=>e[t]));return l.default=()=>e,n.d(c,l),c},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.j=5201,(()=>{var e={5201:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var r,c,[l,a,i]=o,s=0;if(l.some((t=>0!==e[t]))){for(r in a)n.o(a,r)&&(n.m[r]=a[r]);if(i)var u=i(n)}for(t&&t(o);s<l.length;s++)c=l[s],n.o(e,c)&&e[c]&&e[c][0](),e[c]=0;return n.O(u)},o=self.webpackChunkwebpackWcBlocksMainJsonp=self.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var l=n.O(void 0,[94],(()=>n(2303)));l=n.O(l),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-collection"]=l})();