File: /home/shrsglobal/www/wp-content/plugins/woocommerce/assets/client/blocks/product-best-sellers.js
(()=>{var e,t,r,o={9955:(e,t,r)=>{"use strict";var o=r(4530),s=r(4807);const i=window.wp.blocks,n=JSON.parse('{"name":"woocommerce/product-best-sellers","title":"Best Selling Products","category":"woocommerce","keywords":["WooCommerce"],"description":"Display a grid of your all-time best selling products.","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":"popularity"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}'),c=window.wp.blockEditor,l=window.wp.components,a=window.wp.serverSideRender;var d=r.n(a),m=r(790);const h=(0,m.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 230 250",style:{width:"100%"},children:[(0,m.jsx)("title",{children:"Grid Block Preview"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:".162",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"9.216",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"1.565",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"82.478",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"91.532",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"83.882",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:".779",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"76.153",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"101.448",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"65.374",height:"65.374",x:"164.788",y:"136.277",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"47.266",height:"5.148",x:"173.843",y:"211.651",fill:"#E1E3E6",rx:"2.574"}),(0,m.jsx)("rect",{width:"62.8",height:"15",x:"166.192",y:"236.946",fill:"#E1E3E6",rx:"5"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"86.301",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"13.283",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"21.498",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"29.713",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"37.927",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"46.238",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"95.599",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"103.814",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"112.029",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"120.243",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"128.554",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"177.909",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"186.124",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"194.339",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"202.553",y:"221.798",fill:"#E1E3E6",rx:"3"}),(0,m.jsx)("rect",{width:"6.177",height:"6.177",x:"210.864",y:"221.798",fill:"#E1E3E6",rx:"3"})]});var u=r(7723);const x=(e,t,r)=>r?Math.min(e,t)===e?t:Math.max(e,r)===e?r:e:Math.max(e,t)===t?e:t,g=({columns:e,rows:t,setAttributes:r,alignButtons:o,minColumns:s=1,maxColumns:i=6,minRows:n=1,maxRows:c=6})=>(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,u.__)("Columns","woocommerce"),value:e,onChange:e=>{const t=x(e,s,i);r({columns:Number.isNaN(t)?"":t})},min:s,max:i}),(0,m.jsx)(l.RangeControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,u.__)("Rows","woocommerce"),value:t,onChange:e=>{const t=x(e,n,c);r({rows:Number.isNaN(t)?"":t})},min:n,max:c}),(0,m.jsx)(l.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,u.__)("Align the last block to the bottom","woocommerce"),help:o?(0,u.__)("Align the last block to the bottom.","woocommerce"):(0,u.__)("The last inner block will follow other content.","woocommerce"),checked:o,onChange:()=>r({alignButtons:!o})})]}),p=window.wc.wcSettings,w=({onChange:e,settings:t})=>{const{image:r,button:o,price:s,rating:i,title:n}=t,c=!1!==r;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.ToggleControl,{label:(0,u.__)("Product image","woocommerce"),checked:c,onChange:()=>e({...t,image:!c})}),(0,m.jsx)(l.ToggleControl,{label:(0,u.__)("Product title","woocommerce"),checked:n,onChange:()=>e({...t,title:!n})}),(0,m.jsx)(l.ToggleControl,{label:(0,u.__)("Product price","woocommerce"),checked:s,onChange:()=>e({...t,price:!s})}),(0,m.jsx)(l.ToggleControl,{label:(0,u.__)("Product rating","woocommerce"),checked:i,onChange:()=>e({...t,rating:!i})}),(0,m.jsx)(l.ToggleControl,{label:(0,u.__)("Add to Cart button","woocommerce"),checked:o,onChange:()=>e({...t,button:!o})})]})};var f=r(4921),j=r(6087);function E(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const _=window.wp.htmlEntities,b={clear:(0,u.__)("Clear all selected items","woocommerce"),noItems:(0,u.__)("No items found.","woocommerce"),
/* Translators: %s search term */
noResults:(0,u.__)("No results for %s","woocommerce"),search:(0,u.__)("Search for items","woocommerce"),selected:e=>(0,u.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */
(0,u._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,u.__)("Search results updated.","woocommerce")},y=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{});const s=["0"],i=(e={})=>e.parent?[...i(o[e.parent]),e.name]:e.name?[e.name]:[],n=e=>e.map((e=>{const t=r[e.id];return s.push(""+e.id),{...e,breadcrumbs:i(o[e.parent]),children:t&&t.length?n(t):[]}})),c=n(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{s.includes(e)||c.push(...n(t||[]))})),c},v=(e,t)=>{if(!t)return e;const r=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(r).map(((e,t)=>r.test(e)?(0,m.jsx)("strong",{children:e},t):(0,m.jsx)(j.Fragment,{children:e},t)))},C=({label:e})=>(0,m.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),k=e=>{const{item:t,search:r}=e,o=t.breadcrumbs&&t.breadcrumbs.length;return(0,m.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[o?(0,m.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,m.jsx)("span",{className:"woocommerce-search-list__item-name",children:v((0,_.decodeEntities)(t.name),r)})]});var s},S=({countLabel:e,className:t,depth:r=0,controlId:o="",item:s,isSelected:i,isSingle:n,onSelect:c,search:a="",selected:d,useExpandedPanelId:h,...u})=>{const[x,g]=h,p=null!=e&&void 0!==s.count&&null!==s.count,w=!!s.breadcrumbs?.length,b=!!s.children?.length,y=x===s.id,S=(0,f.A)(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":w,"has-children":b,"has-count":p,"is-expanded":y,"is-radio-button":n});(0,j.useEffect)((()=>{b&&i&&g(s.id)}),[s,b,i,g]);const N=u.name||`search-list-item-${o}`,O=`${N}-${s.id}`,P=(0,j.useCallback)((()=>{g(y?-1:Number(s.id))}),[y,s.id,g]);return b?(0,m.jsx)("div",{className:S,onClick:P,onKeyDown:e=>"Enter"===e.key||" "===e.key?P():null,role:"treeitem",tabIndex:0,children:n?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("input",{type:"radio",id:O,name:N,value:s.value,onChange:c(s),onClick:e=>e.stopPropagation(),checked:i,className:"woocommerce-search-list__item-input",...u}),(0,m.jsx)(k,{item:s,search:a}),p?(0,m.jsx)(C,{label:e||s.count}):null]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(l.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:i,...!i&&s.children.some((e=>d.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:v((0,_.decodeEntities)(s.name),a),onChange:()=>{i?c(E(d,s.children,"id"))():c(function(e,t){const r=E(t,e,"id");return[...e,...r]}(d,s.children))()},onClick:e=>e.stopPropagation()}),p?(0,m.jsx)(C,{label:e||s.count}):null]})}):(0,m.jsxs)("label",{htmlFor:O,className:S,children:[n?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("input",{...u,type:"radio",id:O,name:N,value:s.value,onChange:c(s),checked:i,className:"woocommerce-search-list__item-input"}),(0,m.jsx)(k,{item:s,search:a})]}):(0,m.jsx)(l.CheckboxControl,{...u,id:O,name:N,className:"woocommerce-search-list__item-input",value:(0,_.decodeEntities)(s.value),label:v((0,_.decodeEntities)(s.name),a),onChange:c(s),checked:i}),p?(0,m.jsx)(C,{label:e||s.count}):null]})},N=S;var O=r(2624),P=r(9491),I=r(3028);r(5022);const B=({id:e,label:t,popoverContents:r,remove:s,screenReaderLabel:i,className:n=""})=>{const[c,a]=(0,j.useState)(!1),d=(0,P.useInstanceId)(B);if(i=i||t,!t)return null;t=(0,_.decodeEntities)(t);const h=(0,f.A)("woocommerce-tag",n,{"has-remove":!!s}),x=`woocommerce-tag__label-${d}`,g=(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("span",{className:"screen-reader-text",children:i}),(0,m.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,m.jsxs)("span",{className:h,children:[r?(0,m.jsx)(l.Button,{className:"woocommerce-tag__text",id:x,onClick:()=>a(!0),children:g}):(0,m.jsx)("span",{className:"woocommerce-tag__text",id:x,children:g}),r&&c&&(0,m.jsx)(l.Popover,{onClose:()=>a(!1),children:r}),s&&(0,m.jsx)(l.Button,{className:"woocommerce-tag__remove",onClick:s(e),label:(0,u.sprintf)(
// Translators: %s label.
// Translators: %s label.
(0,u.__)("Remove %s","woocommerce"),t),"aria-describedby":x,children:(0,m.jsx)(o.A,{icon:I.A,size:20,className:"clear-icon",role:"img"})})]})},M=B;r(1939);const R=e=>(0,m.jsx)(N,{...e}),A=e=>{const{list:t,selected:r,renderItem:o,depth:s=0,loadMoreChildrenText:i,onLoadMoreChildren:n,totalChildren:c,onSelect:l,instanceId:a,isSingle:d,search:h,useExpandedPanelId:x}=e,[g]=x;return t?(0,m.jsx)(m.Fragment,{children:t.map((t=>{var p;const w=null!==(p=t.children?.length)&&void 0!==p?p:0,f=w&&!d?t.children?.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),E=w&&g===t.id,_=c?.[t.id],b="number"==typeof _&&w<_;return(0,m.jsxs)(j.Fragment,{children:[(0,m.jsx)("li",{children:o({item:t,isSelected:f,onSelect:l,isSingle:d,selected:r,search:h,depth:s,useExpandedPanelId:x,controlId:a})}),E?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(A,{...e,list:t.children,depth:s+1}),n&&b?(0,m.jsx)("li",{children:(0,m.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>n(),children:i||(0,u.__)("Load more","woocommerce")})}):null]}):null]},t.id)}))}):null},T=({isLoading:e,isSingle:t,selected:r,messages:o,onChange:s,onRemove:i})=>{if(e||t||!r)return null;const n=r.length;return(0,m.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,m.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,m.jsx)("strong",{children:o.selected(n)}),n>0?(0,m.jsx)(l.Button,{variant:"link",isDestructive:!0,onClick:()=>s([]),"aria-label":o.clear,children:(0,u.__)("Clear all","woocommerce")}):null]}),n>0?(0,m.jsx)("ul",{children:r.map(((e,t)=>(0,m.jsx)("li",{children:(0,m.jsx)(M,{label:e.name,id:e.id,remove:i})},t)))}):null]})},$=({filteredList:e,search:t,onSelect:r,instanceId:s,useExpandedPanelId:i,...n})=>{const{messages:c,renderItem:l,selected:a,isSingle:d,loadMoreChildrenText:h,onLoadMoreChildren:x,totalChildren:g}=n,p=l||R;return 0===e.length?(0,m.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,m.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,m.jsx)(o.A,{icon:O.A,role:"img"})}),(0,m.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,u.sprintf)(c.noResults,t):c.noItems})]}):(0,m.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,m.jsx)(A,{useExpandedPanelId:i,list:e,selected:a,renderItem:p,loadMoreChildrenText:h,onLoadMoreChildren:x,totalChildren:g,onSelect:r,instanceId:s,isSingle:d,search:t})})},L=e=>{const{className:t="",isCompact:r,isHierarchical:o,isLoading:s,isSingle:i,list:n,messages:c=b,onChange:a,onSearch:d,selected:h,type:x="text",debouncedSpeak:g}=e,[p,w]=(0,j.useState)(""),E=(0,j.useState)(-1),_=(0,P.useInstanceId)(L),v=(0,j.useMemo)((()=>({...b,...c})),[c]),C=(0,j.useMemo)((()=>((e,t,r)=>{if(!t)return r?y(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),s=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?y(s,e):s})(n,p,o)),[n,p,o]);(0,j.useEffect)((()=>{g&&g(v.updated)}),[g,v]),(0,j.useEffect)((()=>{"function"==typeof d&&d(p)}),[p,d]);const k=(0,j.useCallback)((e=>()=>{i&&a([]);const t=h.findIndex((({id:t})=>t===e));a([...h.slice(0,t),...h.slice(t+1)])}),[i,h,a]),S=(0,j.useCallback)((e=>()=>{Array.isArray(e)?a(e):-1===h.findIndex((({id:t})=>t===e.id))?a(i?[e]:[...h,e]):k(e.id)()}),[i,k,a,h]),N=(0,j.useCallback)((e=>{const[t]=h.filter((t=>!e.find((e=>t.id===e.id))));k(t.id)()}),[k,h]);return(0,m.jsxs)("div",{className:(0,f.A)("woocommerce-search-list",t,{"is-compact":r,"is-loading":s,"is-token":"token"===x}),children:["text"===x&&(0,m.jsx)(T,{...e,onRemove:k,messages:v}),(0,m.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===x?(0,m.jsx)(l.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:v.search,type:"search",value:p,onChange:e=>w(e)}):(0,m.jsx)(l.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:s,label:v.search,onChange:N,onInputChange:e=>w(e),suggestions:[],__experimentalValidateInput:()=>!1,value:s?[(0,u.__)("Loading…","woocommerce")]:h.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})}),s?(0,m.jsx)("div",{className:"woocommerce-search-list__list",children:(0,m.jsx)(l.Spinner,{})}):(0,m.jsx)($,{...e,search:p,filteredList:C,messages:v,onSelect:S,instanceId:_,useExpandedPanelId:E})]})},F=((0,l.withSpokenMessages)(L),window.wp.url),H=window.wp.apiFetch;var D=r.n(H);const V=window.wp.escapeHtml,z=({message:e,type:t})=>e?"general"===t?(0,m.jsxs)("span",{children:[(0,u.__)("The following error was returned","woocommerce"),(0,m.jsx)("br",{}),(0,m.jsx)("code",{children:(0,V.escapeHTML)(e)})]}):"api"===t?(0,m.jsxs)("span",{children:[(0,u.__)("The following error was returned from the API","woocommerce"),(0,m.jsx)("br",{}),(0,m.jsx)("code",{children:(0,V.escapeHTML)(e)})]}):e:(0,u.__)("An error has prevented the block from being updated.","woocommerce"),J=({error:e})=>(0,m.jsx)("div",{className:"wc-block-error-message",children:z(e)}),W=e=>{const{id:t,name:r,parent:o,count:s}=e;return{id:t,name:r,parent:o,count:s,breadcrumbs:[],children:[],details:e,value:e.slug}};r(6982);const G=(Y=({categories:e=[],error:t=null,isLoading:r=!1,onChange:o,onOperatorChange:s,operator:i="any",selected:n,isCompact:c=!1,isSingle:a=!1,showReviewCount:d})=>{const h={clear:(0,u.__)("Clear all product categories","woocommerce"),list:(0,u.__)("Product Categories","woocommerce"),noItems:(0,u.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,u.__)("Search for product categories","woocommerce"),selected:e=>(0,u.sprintf)(/* translators: %d is the count of selected categories. */ /* translators: %d is the count of selected categories. */
(0,u._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,u.__)("Category search results updated.","woocommerce")};if(t)return(0,m.jsx)(J,{error:t});const x=e.map(W);return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(L,{className:"woocommerce-product-categories",list:x,isLoading:r,selected:x.filter((({id:e})=>n.includes(Number(e)))),onChange:o,renderItem:e=>{const{item:t,search:r,depth:o=0}=e,s=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,i=d?(0,u.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,u._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,u.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,u._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.details?.count||0,"woocommerce"),s,t.details?.count||0),n=d?(0,u.sprintf)(/* translators: %d is the count of reviews. */ /* translators: %d is the count of reviews. */
(0,u._n)("%d review","%d reviews",t.details?.review_count||0,"woocommerce"),t.details?.review_count||0):(0,u.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */
(0,u._n)("%d product","%d products",t.details?.count||0,"woocommerce"),t.details?.count||0);return(0,m.jsx)(S,{className:(0,f.A)("woocommerce-product-categories__item","has-count",{"is-searching":r.length>0,"is-skip-level":0===o&&0!==t.parent}),...e,countLabel:n,"aria-label":i})},messages:h,isCompact:c,isHierarchical:!0,isSingle:a}),!!s&&(0,m.jsx)("div",{hidden:n.length<2,children:(0,m.jsx)(l.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,u.__)("Display products matching","woocommerce"),help:(0,u.__)("Pick at least two categories to use this setting.","woocommerce"),value:i,onChange:s,options:[{label:(0,u.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,u.__)("All selected categories","woocommerce"),value:"all"}]})})]})},({selected:e,...t})=>{const[r,o]=(0,j.useState)(!0),[s,i]=(0,j.useState)(null),[n,c]=(0,j.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),o(!1)},a=(0,j.useRef)(e);return(0,j.useEffect)((()=>{var e;(e={selected:a.current},D()({path:(0,F.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})})).then((e=>{c(e),o(!1)})).catch(l)}),[a]),(0,m.jsx)(Y,{...t,selected:e,error:s,categories:n,isLoading:r})}),K=e=>{const{attributes:t,setAttributes:r}=e,{categories:o,catOperator:s,columns:i,contentVisibility:n,rows:a,alignButtons:d}=t;return(0,m.jsxs)(c.InspectorControls,{children:[(0,m.jsx)(l.PanelBody,{title:(0,u.__)("Layout","woocommerce"),initialOpen:!0,children:(0,m.jsx)(g,{columns:i,rows:a,alignButtons:d,setAttributes:r,minColumns:(0,p.getSetting)("minColumns",1),maxColumns:(0,p.getSetting)("maxColumns",6),minRows:(0,p.getSetting)("minRows",1),maxRows:(0,p.getSetting)("maxRows",6)})}),(0,m.jsx)(l.PanelBody,{title:(0,u.__)("Content","woocommerce"),initialOpen:!0,children:(0,m.jsx)(w,{settings:n,onChange:e=>r({contentVisibility:e})})}),(0,m.jsx)(l.PanelBody,{title:(0,u.__)("Filter by Product Category","woocommerce"),initialOpen:!1,children:(0,m.jsx)(G,{selected:o,onChange:(e=[])=>{const t=e.map((({id:e})=>e));r({categories:t})},operator:s,onOperatorChange:(e="any")=>r({catOperator:e})})})]},"inspector")},Q=e=>{const{attributes:t,name:r}=e;return t.isPreview?h:(0,m.jsxs)("div",{className:"wc-block-product-best-sellers",children:[(0,m.jsx)(K,{...e}),(0,m.jsx)(l.Disabled,{children:(0,m.jsx)(d(),{block:r,attributes:t})})]})},X={columns:{type:"number",default:(0,p.getSetting)("defaultColumns",3)},rows:{type:"number",default:(0,p.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,p.getSetting)("stockStatusOptions",[]))}};var Y;(0,i.registerBlockType)(n,{icon:{src:(0,m.jsx)(o.A,{icon:s.A,className:"wc-block-editor-components-block-icon"})},attributes:{...X,...n.attributes},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-best-sellers"!==e)),transform:e=>(0,i.createBlock)("woocommerce/product-best-sellers",e)}]},edit:e=>{const t=(0,c.useBlockProps)();return(0,m.jsx)("div",{...t,children:(0,m.jsx)(Q,{...e})})},save:()=>null})},6982:()=>{},1939:()=>{},5022:()=>{},1609:e=>{"use strict";e.exports=window.React},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 r=s[e]={exports:{}};return o[e](r,r.exports,i),r.exports}i.m=o,e=[],i.O=(t,r,o,s)=>{if(!r){var n=1/0;for(d=0;d<e.length;d++){for(var[r,o,s]=e[d],c=!0,l=0;l<r.length;l++)(!1&s||n>=s)&&Object.keys(i.O).every((e=>i.O[e](r[l])))?r.splice(l--,1):(c=!1,s<n&&(n=s));if(c){e.splice(d--,1);var a=o();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]=[r,o,s]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var s=Object.create(null);i.r(s);var n={};t=t||[null,r({}),r([]),r(r)];for(var c=2&o&&e;"object"==typeof c&&!~t.indexOf(c);c=r(c))Object.getOwnPropertyNames(c).forEach((t=>n[t]=()=>e[t]));return n.default=()=>e,i.d(s,n),s},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},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=2272,(()=>{var e={2272:0};i.O.j=t=>0===e[t];var t=(t,r)=>{var o,s,[n,c,l]=r,a=0;if(n.some((t=>0!==e[t]))){for(o in c)i.o(c,o)&&(i.m[o]=c[o]);if(l)var d=l(i)}for(t&&t(r);a<n.length;a++)s=n[a],i.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return i.O(d)},r=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n=i.O(void 0,[94],(()=>i(9955)));n=i.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["product-best-sellers"]=n})();