JezK
Edit File: product-category.js
(()=>{var e,t,o,r={4092:(e,t,o)=>{"use strict";const r=window.wp.blocks;var s=o(3450),i=o(8242);o(9312);const c=JSON.parse('{"name":"woocommerce/product-category","title":"Products by Category","category":"woocommerce","keywords":["WooCommerce"],"description":"Display a grid of products from your selected categories.","supports":{"interactivity":{"clientNavigation":false},"align":["wide","full"],"html":false,"inserter":false},"attributes":{"columns":{"type":"number","default":3},"rows":{"type":"number","default":3},"alignButtons":{"type":"boolean","default":false},"contentVisibility":{"type":"object","default":{"image":true,"title":true,"price":true,"rating":true,"button":true},"properties":{"image":{"type":"boolean","default":true},"title":{"type":"boolean","default":true},"price":{"type":"boolean","default":true},"rating":{"type":"boolean","default":true},"button":{"type":"boolean","default":true}}},"categories":{"type":"array","default":[]},"catOperator":{"type":"string","default":"any"},"isPreview":{"type":"boolean","default":false},"stockStatus":{"type":"array"},"editMode":{"type":"boolean","default":true},"orderby":{"type":"string","enum":["date","popularity","price_asc","price_desc","rating","title","menu_order"],"default":"date"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),n=window.wc.wcSettings,l={columns:{type:"number",default:(0,n.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,n.getSetting)("defaultRows",3)},alignButtons:{type:"boolean",default:!1},categories:{type:"array",default:[]},catOperator:{type:"string",default:"any"},contentVisibility:{type:"object",default:{image:!0,title:!0,price:!0,rating:!0,button:!0}},isPreview:{type:"boolean",default:!1},stockStatus:{type:"array",default:Object.keys((0,n.getSetting)("stockStatusOptions",[]))}},a=window.wp.blockEditor;var d=o(6087);const m=window.wp.components;var h=o(7723);const u=window.wp.serverSideRender;var g=o.n(u),x=o(790);const p=(0,x.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"},children:[(0,x.jsx)("title",{children:"Grid Block Preview"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,x.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,x.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})]}),w=()=>(0,x.jsx)(m.Placeholder,{icon:(0,x.jsx)(s.A,{icon:i.A}),label:(0,h.__)("Products by Category","woocommerce"),className:"wc-block-products-grid wc-block-products-category",children:(0,h.__)("No products were found that matched your selection.","woocommerce")}),_=e=>{const{name:t,attributes:o}=e,r=o.categories.length;return o.isPreview?p:r?(0,x.jsx)(g(),{block:t,attributes:o,EmptyResponsePlaceholder:w}):(0,x.jsx)(x.Fragment,{children:(0,h.__)("Select at least one category to display its products.","woocommerce")})};var b=o(4921);function f(e,t,o){const r=new Set(t.map(e=>e[o]));return e.filter(e=>!r.has(e[o]))}const y=window.wp.htmlEntities,j={clear:(0,h.__)("Clear all selected items","woocommerce"),noItems:(0,h.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,h.__)("No results for %s","woocommerce"),search:(0,h.__)("Search for items","woocommerce"),selected:e=>(0,h.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,h._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,h.__)("Search results updated.","woocommerce")},E=(e,t)=>null!==t&&(e.id===t||!!(Array.isArray(e.children)&&e.children.length>0)&&e.children.some(e=>E(e,t))),v=(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=t.reduce((e,t)=>(e[String(t.id)]=t,e),{});const s=["0"],i=(e={})=>e.parent?[...i(r[e.parent]),e.name]:e.name?[e.name]:[],c=e=>e.map(e=>{const t=o[e.id];return s.push(""+e.id),{...e,breadcrumbs:i(r[e.parent]),children:t&&t.length?c(t):[]}}),n=c(o[0]||[]);return Object.entries(o).forEach(([e,t])=>{s.includes(e)||n.push(...c(t||[]))}),n},C=(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,x.jsx)("strong",{children:e},t):(0,x.jsx)(d.Fragment,{children:e},t))},k=e=>{const t=e.children?.map(e=>[e,...k(e)]);return t?t.flat():[]},S=(e,t)=>k(e).some(e=>t.find(t=>t.id===e.id)),N=(e,t)=>k(e).every(e=>t.find(t=>t.id===e.id)),O=({label:e})=>(0,x.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),P=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,x.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[r?(0,x.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(s=t.breadcrumbs,1===s.length?s.slice(0,1).toString():2===s.length?s.slice(0,1).toString()+" › "+s.slice(-1).toString():s.slice(0,1).toString()+" … "+s.slice(-1).toString())}):null,(0,x.jsx)("span",{className:"woocommerce-search-list__item-name",children:C((0,y.decodeEntities)(t.name),o)})]});var s},A=({countLabel:e,className:t,depth:o=0,controlId:r="",disabled:s=!1,item:i,isSelected:c,isSelectable:n=!0,isSingle:l,onSelect:a,search:h="",selected:u,useExpandedPanelId:g,...p})=>{const[w,_]=g,j=null!=e&&void 0!==i.count&&null!==i.count,v=!!i.breadcrumbs?.length,A=!!i.children?.length,B=E(i,w),I=(0,b.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":v,"has-children":A,"has-count":j,"is-expanded":B,"is-radio-button":l}),M=p.name||`search-list-item-${r}`,T=`${M}-${i.id}`,R=(0,d.useCallback)(()=>{B||"number"!=typeof i.id&&"string"!=typeof i.id?!i.parent||"number"!=typeof i.parent&&"string"!=typeof i.parent?_(null):_(i.parent):_(i.id)},[B,i.id,i.parent,_]),$=(c||!n)&&N(i,u);return A?(0,x.jsx)("div",{className:I,onClick:R,onKeyDown:e=>"Enter"===e.key||" "===e.key?R():null,role:"treeitem",tabIndex:0,children:l?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("input",{type:"radio",id:T,name:M,value:i.value,onChange:()=>{a(i)(),B||_(i.id)},onClick:e=>e.stopPropagation(),checked:c,disabled:s,className:"woocommerce-search-list__item-input",...p}),(0,x.jsx)(P,{item:i,search:h}),j?(0,x.jsx)(O,{label:e||i.count}):null]}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(m.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:$,disabled:s,indeterminate:!$&&(c||S(i,u)),label:C((0,y.decodeEntities)(i.name),h),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:()=>{const e=k(i),t=n?[i,...e]:[...e],o=N(i,u);n&&c||!n&&o?a(f(u,t,"id"))():(a(function(e,t){const o=f(t,e,"id");return[...e,...o]}(u,t))(),B||_(i.id))},__nextHasNoMarginBottom:!0}),j?(0,x.jsx)(O,{label:e||i.count}):null]})}):(0,x.jsxs)("div",{className:I,onClick:s?void 0:a(i),children:[l?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("input",{...p,type:"radio",id:T,name:M,value:i.value,onChange:a(i),checked:c,disabled:s,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,x.jsx)("label",{htmlFor:T,children:(0,x.jsx)(P,{item:i,search:h})})]}):(0,x.jsx)(m.CheckboxControl,{...p,id:T,name:M,className:"woocommerce-search-list__item-input",value:(0,y.decodeEntities)(i.value),label:C((0,y.decodeEntities)(i.name),h),onChange:()=>{a(i)(),B||_(i.id)},checked:c,disabled:s,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),j?(0,x.jsx)(O,{label:e||i.count}):null]})},B=A;var I=o(7051),M=o(9491),T=o(1884);o(5022);const R=({id:e,label:t,popoverContents:o,remove:r,screenReaderLabel:i,className:c=""})=>{const[n,l]=(0,d.useState)(!1),a=(0,M.useInstanceId)(R);if(i=i||t,!t)return null;t=(0,y.decodeEntities)(t);const u=(0,b.A)("woocommerce-tag",c,{"has-remove":!!r}),g=`woocommerce-tag__label-${a}`,p=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)("span",{className:"screen-reader-text",children:i}),(0,x.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,x.jsxs)("span",{className:u,children:[o?(0,x.jsx)(m.Button,{className:"woocommerce-tag__text",id:g,onClick:()=>l(!0),children:p}):(0,x.jsx)("span",{className:"woocommerce-tag__text",id:g,children:p}),o&&n&&(0,x.jsx)(m.Popover,{onClose:()=>l(!1),children:o}),r&&(0,x.jsx)(m.Button,{className:"woocommerce-tag__remove",onClick:r(e),label:(0,h.sprintf)( // Translators: %s label. // Translators: %s label. (0,h.__)("Remove %s","woocommerce"),t),"aria-describedby":g,children:(0,x.jsx)(s.A,{icon:T.A,size:20,className:"clear-icon",role:"img"})})]})},$=R;o(1939);const F=e=>(0,x.jsx)(B,{...e}),L=e=>{const{list:t,selected:o,renderItem:r,depth:s=0,loadMoreChildrenText:i,onLoadMoreChildren:c,totalChildren:n,onSelect:l,instanceId:a,isSingle:m,search:u,useExpandedPanelId:g}=e,[p]=g;return t?(0,x.jsx)(x.Fragment,{children:t.map(t=>{const w=t.children?.length??0,_=!!o.find(({id:e})=>e===t.id),b=E(t,p),f=n?.[t.id],y="number"==typeof f&&w<f;return(0,x.jsxs)(d.Fragment,{children:[(0,x.jsx)("li",{children:r({item:t,isSelected:_,onSelect:l,isSingle:m,selected:o,search:u,depth:s,useExpandedPanelId:g,controlId:a})}),b?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(L,{...e,list:t.children,depth:s+1}),c&&y?(0,x.jsx)("li",{children:(0,x.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>c(),children:i||(0,h.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},H=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:s,onRemove:i})=>{if(e||t||!o)return null;const c=o.length;return(0,x.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,x.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,x.jsx)("strong",{children:r.selected(c)}),c>0?(0,x.jsx)(m.Button,{variant:"link",isDestructive:!0,onClick:()=>s([]),"aria-label":r.clear,children:(0,h.__)("Clear all","woocommerce")}):null]}),c>0?(0,x.jsx)("ul",{children:o.map((e,t)=>(0,x.jsx)("li",{children:(0,x.jsx)($,{label:e.name,id:e.id,remove:i})},t))}):null]})},D=({filteredList:e,search:t,onSelect:o,instanceId:r,useExpandedPanelId:i,...c})=>{const{messages:n,renderItem:l,selected:a,isSingle:d,loadMoreChildrenText:m,onLoadMoreChildren:u,totalChildren:g}=c,p=l||F;return 0===e.length?(0,x.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,x.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,x.jsx)(s.A,{icon:I.A,role:"img"})}),(0,x.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,h.sprintf)(n.noResults,t):n.noItems})]}):(0,x.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,x.jsx)(L,{useExpandedPanelId:i,list:e,selected:a,renderItem:p,loadMoreChildrenText:m,onLoadMoreChildren:u,totalChildren:g,onSelect:o,instanceId:r,isSingle:d,search:t})})},V=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:s,isSingle:i,list:c,messages:n=j,onChange:l,onSearch:a,selected:u,type:g="text",debouncedSpeak:p}=e,[w,_]=(0,d.useState)(""),f=(0,d.useState)(null),y=(0,M.useInstanceId)(V),E=(0,d.useMemo)(()=>({...j,...n}),[n]),C=(0,d.useMemo)(()=>((e,t,o)=>{if(!t)return o?v(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),s=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return o?v(s,e):s})(c,w,r),[c,w,r]);(0,d.useEffect)(()=>{p&&p(E.updated)},[p,E]),(0,d.useEffect)(()=>{"function"==typeof a&&a(w)},[w,a]);const k=(0,d.useCallback)(e=>()=>{i&&l([]);const t=u.findIndex(({id:t})=>t===e);l([...u.slice(0,t),...u.slice(t+1)])},[i,u,l]),S=(0,d.useCallback)(e=>()=>{Array.isArray(e)?l(e):-1===u.findIndex(({id:t})=>t===e.id)?l(i?[e]:[...u,e]):k(e.id)()},[i,k,l,u]),N=(0,d.useCallback)(e=>{const[t]=u.filter(t=>!e.find(e=>t.id===e.id));k(t.id)()},[k,u]);return(0,x.jsxs)("div",{className:(0,b.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":s,"is-token":"token"===g}),children:["text"===g&&(0,x.jsx)(H,{...e,onRemove:k,messages:E}),(0,x.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===g?(0,x.jsx)(m.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:E.search,type:"search",value:w,onChange:e=>_(e)}):(0,x.jsx)(m.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:s,label:E.search,onChange:N,onInputChange:e=>_(e),suggestions:[],__experimentalValidateInput:()=>!1,value:s?[(0,h.__)("Loading…","woocommerce")]:u.map(e=>({...e,value:e.name})),__experimentalShowHowTo:!1})}),s?(0,x.jsx)("div",{className:"woocommerce-search-list__list",children:(0,x.jsx)(m.Spinner,{})}):(0,x.jsx)(D,{...e,search:w,filteredList:C,messages:E,onSelect:S,instanceId:y,useExpandedPanelId:f})]})},z=((0,m.withSpokenMessages)(V),window.wp.url),J=window.wp.apiFetch;var W=o.n(J);const G=window.wp.escapeHtml,K=({message:e,type:t})=>e?"general"===t?(0,x.jsxs)("span",{children:[(0,h.__)("The following error was returned","woocommerce"),(0,x.jsx)("br",{}),(0,x.jsx)("code",{children:(0,G.escapeHTML)(e)})]}):"api"===t?(0,x.jsxs)("span",{children:[(0,h.__)("The following error was returned from the API","woocommerce"),(0,x.jsx)("br",{}),(0,x.jsx)("code",{children:(0,G.escapeHTML)(e)})]}):e:(0,h.__)("An error has prevented the block from being updated.","woocommerce"),Q=({error:e})=>(0,x.jsx)("div",{className:"wc-block-error-message",children:K(e)}),X=e=>{const{id:t,name:o,parent:r,count:s}=e;return{id:t,name:o,parent:r,count:s,breadcrumbs:[],children:[],details:e,value:e.slug}};o(6982);const Y=(ne=({categories:e=[],error:t=null,isLoading:o=!1,onChange:r,onOperatorChange:s,operator:i="any",selected:c,isCompact:n=!1,isSingle:l=!1,showReviewCount:a})=>{const d={clear:(0,h.__)("Clear all product categories","woocommerce"),list:(0,h.__)("Product Categories","woocommerce"),noItems:(0,h.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,h.__)("Search for product categories","woocommerce"),selected:e=>(0,h.sprintf)(/* translators: %d is the count of selected categories. */ /* translators: %d is the count of selected categories. */ (0,h._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,h.__)("Category search results updated.","woocommerce")};if(t)return(0,x.jsx)(Q,{error:t});const u=e.map(X);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(V,{className:"woocommerce-product-categories",list:u,isLoading:o,selected:u.filter(({id:e})=>c.includes(Number(e))),onChange:r,renderItem:e=>{const{item:t,search:o,depth:r=0}=e,s=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,i=a?(0,h.sprintf)(/* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ /* translators: %1$s is the item name, %2$d is the count of reviews for the item. */ (0,h._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.details?.review_count||0,"woocommerce"),s,t.details?.review_count||0):(0,h.sprintf)(/* translators: %1$s is the item name, %2$d is the count of products for the item. */ /* translators: %1$s is the item name, %2$d is the count of products for the item. */ (0,h._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.details?.count||0,"woocommerce"),s,t.details?.count||0),c=a?(0,h.sprintf)(/* translators: %d is the count of reviews. */ /* translators: %d is the count of reviews. */ (0,h._n)("%d review","%d reviews",t.details?.review_count||0,"woocommerce"),t.details?.review_count||0):(0,h.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,h._n)("%d product","%d products",t.details?.count||0,"woocommerce"),t.details?.count||0);return(0,x.jsx)(A,{className:(0,b.A)("woocommerce-product-categories__item","has-count",{"is-searching":o.length>0,"is-skip-level":0===r&&0!==t.parent}),...e,countLabel:c,"aria-label":i})},messages:d,isCompact:n,isHierarchical:!0,isSingle:l}),!!s&&(0,x.jsx)("div",{hidden:c.length<2,children:(0,x.jsx)(m.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,h.__)("Display products matching","woocommerce"),help:(0,h.__)("Pick at least two categories to use this setting.","woocommerce"),value:i,onChange:s,options:[{label:(0,h.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,h.__)("All selected categories","woocommerce"),value:"all"}]})})]})},({selected:e,...t})=>{const[o,r]=(0,d.useState)(!0),[s,i]=(0,d.useState)(null),[c,n]=(0,d.useState)([]),l=async e=>{const t=await(async e=>{if(!("json"in e))return{code:e.code||"",message:e.message,type:e.type||"general"};try{const t=await e.json();return{code:t.code||"",message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}})(e);i(t),r(!1)},a=(0,d.useRef)(e);return(0,d.useEffect)(()=>{var e;(e={selected:a.current},W()({path:(0,z.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})})).then(e=>{n(e),r(!1)}).catch(l)},[a]),(0,x.jsx)(ne,{...t,selected:e,error:s,categories:c,isLoading:o})}),q=(e,t,o)=>o?Math.min(e,t)===e?t:Math.max(e,o)===e?o:e:Math.max(e,t)===t?e:t,U=({columns:e,rows:t,setAttributes:o,alignButtons:r,minColumns:s=1,maxColumns:i=6,minRows:c=1,maxRows:n=6})=>(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(m.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,h.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=q(e,s,i);o({columns:Number.isNaN(t)?"":t})},min:s,max:i}),(0,x.jsx)(m.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,h.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=q(e,c,n);o({rows:Number.isNaN(t)?"":t})},min:c,max:n}),(0,x.jsx)(m.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,h.__)("Align the last block to the bottom","woocommerce"),help:r?(0,h.__)("Align the last block to the bottom.","woocommerce"):(0,h.__)("The last inner block will follow other content.","woocommerce"),checked:r,onChange:()=>o({alignButtons:!r})})]}),Z=({onChange:e,settings:t})=>{const{image:o,button:r,price:s,rating:i,title:c}=t,n=!1!==o;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(m.ToggleControl,{label:(0,h.__)("Product image","woocommerce"),checked:n,onChange:()=>e({...t,image:!n})}),(0,x.jsx)(m.ToggleControl,{label:(0,h.__)("Product title","woocommerce"),checked:c,onChange:()=>e({...t,title:!c})}),(0,x.jsx)(m.ToggleControl,{label:(0,h.__)("Product price","woocommerce"),checked:s,onChange:()=>e({...t,price:!s})}),(0,x.jsx)(m.ToggleControl,{label:(0,h.__)("Product rating","woocommerce"),checked:i,onChange:()=>e({...t,rating:!i})}),(0,x.jsx)(m.ToggleControl,{label:(0,h.__)("Add to Cart button","woocommerce"),checked:r,onChange:()=>e({...t,button:!r})})]})},ee=({value:e,setAttributes:t})=>(0,x.jsx)(m.SelectControl,{label:(0,h.__)("Order products by","woocommerce"),value:e,options:[{label:(0,h.__)("Newness - newest first","woocommerce"),value:"date"},{label:(0,h.__)("Price - low to high","woocommerce"),value:"price_asc"},{label:(0,h.__)("Price - high to low","woocommerce"),value:"price_desc"},{label:(0,h.__)("Rating - highest first","woocommerce"),value:"rating"},{label:(0,h.__)("Sales - most first","woocommerce"),value:"popularity"},{label:(0,h.__)("Title - alphabetical","woocommerce"),value:"title"},{label:(0,h.__)("Menu Order","woocommerce"),value:"menu_order"}],onChange:e=>t({orderby:e})}),te=(0,n.getSetting)("hideOutOfStockItems",!1),oe=(0,n.getSetting)("stockStatusOptions",{}),re=({value:e,setAttributes:t})=>{const{outofstock:o,...r}=oe,s=te?r:oe,i=Object.entries(s).map(([e,t])=>({value:e,label:t})).filter(e=>!!e.label),c=Object.keys(s).filter(e=>!!e),[n,l]=(0,d.useState)(e||c);(0,d.useEffect)(()=>{t({stockStatus:["",...n]})},[n,t]);const a=(0,d.useCallback)(e=>{const t=n.includes(e),o=n.filter(t=>t!==e);t||(o.push(e),o.sort()),l(o)},[n]);return(0,x.jsx)(x.Fragment,{children:i.map(e=>{const t=n.includes(e.value)?/* translators: %s stock status. */ /* translators: %s stock status. */(0,h.__)('Stock status "%s" visible.',"woocommerce"):/* translators: %s stock status. */ /* translators: %s stock status. */(0,h.__)('Stock status "%s" hidden.',"woocommerce");return(0,x.jsx)(m.ToggleControl,{label:e.label,help:(0,h.sprintf)(t,e.label),checked:n.includes(e.value),onChange:()=>a(e.value)},e.value)})})},se=e=>{const{isEditing:t,attributes:o,setAttributes:r,setChangedAttributes:s}=e,{columns:i,catOperator:c,contentVisibility:l,orderby:d,rows:u,alignButtons:g,stockStatus:p}=o;return(0,x.jsxs)(a.InspectorControls,{children:[(0,x.jsx)(m.PanelBody,{title:(0,h.__)("Product Category","woocommerce"),initialOpen:!o.categories.length&&!t,children:(0,x.jsx)(Y,{selected:o.categories,onChange:(e=[])=>{const t={categories:e.map(({id:e})=>e)};r(t),s(t)},operator:c,onOperatorChange:(e="any")=>{const t={catOperator:e};r(t),s(t)},isCompact:!0})}),(0,x.jsx)(m.PanelBody,{title:(0,h.__)("Layout","woocommerce"),initialOpen:!0,children:(0,x.jsx)(U,{columns:i,rows:u,alignButtons:g,setAttributes:r,minColumns:(0,n.getSetting)("minColumns",1),maxColumns:(0,n.getSetting)("maxColumns",6),minRows:(0,n.getSetting)("minRows",1),maxRows:(0,n.getSetting)("maxRows",6)})}),(0,x.jsx)(m.PanelBody,{title:(0,h.__)("Content","woocommerce"),initialOpen:!0,children:(0,x.jsx)(Z,{settings:l,onChange:e=>r({contentVisibility:e})})}),(0,x.jsx)(m.PanelBody,{title:(0,h.__)("Order By","woocommerce"),initialOpen:!1,children:(0,x.jsx)(ee,{setAttributes:r,value:d})}),(0,x.jsx)(m.PanelBody,{title:(0,h.__)("Filter by stock status","woocommerce"),initialOpen:!1,children:(0,x.jsx)(re,{setAttributes:r,value:p})})]},"inspector")},ie=e=>{const{debouncedSpeak:t,setIsEditing:o,changedAttributes:r,setChangedAttributes:c,attributes:n}=e,l={...n,...r},a=()=>{o(!1),c({})};return(0,x.jsxs)(m.Placeholder,{icon:(0,x.jsx)(s.A,{icon:i.A}),label:(0,h.__)("Products by Category","woocommerce"),className:"wc-block-products-grid wc-block-products-category",children:[(0,h.__)("Display a grid of products from your selected categories.","woocommerce"),(0,x.jsxs)("div",{className:"wc-block-products-category__selection",children:[(0,x.jsx)(Y,{selected:l.categories,onChange:(e=[])=>{const t=e.map(({id:e})=>e);c({categories:t})},operator:l.catOperator,onOperatorChange:(e="any")=>c({catOperator:e})}),(0,x.jsx)(m.Button,{variant:"primary",onClick:()=>{(()=>{const{setAttributes:t}=e;t(r),a()})(),t((0,h.__)("Now displaying a preview of the reviews for the products in the selected categories.","woocommerce"))},children:(0,h.__)("Done","woocommerce")}),(0,x.jsx)(m.Button,{className:"wc-block-products-category__cancel-button",variant:"tertiary",onClick:()=>{a(),t((0,h.__)("Now displaying a preview of the reviews for the products in the selected categories.","woocommerce"))},children:(0,h.__)("Cancel","woocommerce")})]})]})},ce=(0,m.withSpokenMessages)(e=>{const t=(0,a.useBlockProps)(),{attributes:o}=e,[r,s]=(0,d.useState)(!o.categories.length),[i,c]=(0,d.useState)({});return(0,x.jsxs)("div",{...t,children:[(0,x.jsx)(a.BlockControls,{children:(0,x.jsx)(m.ToolbarGroup,{controls:[{icon:"edit",title:(0,h.__)("Edit selected categories","woocommerce"),onClick:()=>s(!r),isActive:r}]})}),(0,x.jsx)(se,{isEditing:r,setChangedAttributes:c,...e}),r?(0,x.jsx)(ie,{isEditing:r,setIsEditing:s,changedAttributes:i,setChangedAttributes:c,...e}):(0,x.jsx)(m.Disabled,{children:(0,x.jsx)(_,{...e})})]})});var ne;(0,r.registerBlockType)(c,{icon:{src:(0,x.jsx)(s.A,{icon:i.A,className:"wc-block-editor-components-block-icon"})},attributes:{...c.attributes,...l},transforms:{from:[{type:"block",blocks:["woocommerce/product-best-sellers","woocommerce/product-category","woocommerce/product-new","woocommerce/product-on-sale","woocommerce/product-top-rated"].filter(e=>"woocommerce/product-category"!==e),transform:e=>(0,r.createBlock)("woocommerce/product-category",{...e,editMode:!1})}]},edit:ce,save:()=>null})},9312:()=>{},6982:()=>{},1939:()=>{},5022:()=>{},790:e=>{"use strict";e.exports=window.ReactJSXRuntime},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},5573:e=>{"use strict";e.exports=window.wp.primitives}},s={};function i(e){var t=s[e];if(void 0!==t)return t.exports;var o=s[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.m=r,e=[],i.O=(t,o,r,s)=>{if(!o){var c=1/0;for(d=0;d<e.length;d++){for(var[o,r,s]=e[d],n=!0,l=0;l<o.length;l++)(!1&s||c>=s)&&Object.keys(i.O).every(e=>i.O[e](o[l]))?o.splice(l--,1):(n=!1,s<c&&(c=s));if(n){e.splice(d--,1);var a=r();void 0!==a&&(t=a)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[o,r,s]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.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 s=Object.create(null);i.r(s);var c={};t=t||[null,o({}),o([]),o(o)];for(var n=2&r&&e;"object"==typeof n&&!~t.indexOf(n);n=o(n))Object.getOwnPropertyNames(n).forEach(t=>c[t]=()=>e[t]);return c.default=()=>e,i.d(s,c),s},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=4101,(()=>{var e={4101:0};i.O.j=t=>0===e[t];var t=(t,o)=>{var r,s,[c,n,l]=o,a=0;if(c.some(t=>0!==e[t])){for(r in n)i.o(n,r)&&(i.m[r]=n[r]);if(l)var d=l(i)}for(t&&t(o);a<c.length;a++)s=c[a],i.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return i.O(d)},o=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var c=i.O(void 0,[94],()=>i(4092));c=i.O(c),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-category"]=c})();