File: /home/infowars/www/wp-content/plugins/woocommerce/assets/client/blocks/featured-category.js
(()=>{var e,t,o,r={2798:(e,t,o)=>{"use strict";var r=o(5573),a=o(790);const s=(0,a.jsxs)(r.SVG,{xmlns:"http://www.w3.org/2000/SVG",viewBox:"0 0 24 24",children:[(0,a.jsx)("path",{fill:"none",d:"M0 0h24v24H0V0z"}),(0,a.jsx)("path",{d:"M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10zm-6.92-3.96L12.39 17 15 15.47 17.61 17l-.69-2.96 2.3-1.99-3.03-.26L15 9l-1.19 2.79-3.03.26z"})]});var i=o(4530),n=(o(9926),o(1117),o(6087)),c=o(9491);const l=window.wp.url,d=window.wp.apiFetch;var m=o.n(d);const u=window.wc.wcSettings,g=(0,u.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),p=g.pluginUrl+"assets/images/",h=(g.pluginUrl,u.STORE_PAGES.shop,u.STORE_PAGES.checkout,u.STORE_PAGES.checkout,u.STORE_PAGES.privacy,u.STORE_PAGES.privacy,u.STORE_PAGES.terms,u.STORE_PAGES.terms,u.STORE_PAGES.cart,u.STORE_PAGES.cart,u.STORE_PAGES.myaccount?.permalink?u.STORE_PAGES.myaccount.permalink:(0,u.getSetting)("wpLoginUrl","/wp-login.php"),(0,u.getSetting)("localPickupEnabled",!1),(0,u.getSetting)("shippingMethodsExist",!1),(0,u.getSetting)("shippingEnabled",!0),(0,u.getSetting)("countries",{})),b=(0,u.getSetting)("countryData",{}),x={...Object.fromEntries(Object.keys(b).filter((e=>!0===b[e].allowBilling)).map((e=>[e,h[e]||""]))),...Object.fromEntries(Object.keys(b).filter((e=>!0===b[e].allowShipping)).map((e=>[e,h[e]||""])))},w=(Object.fromEntries(Object.keys(x).map((e=>[e,b[e].states||{}]))),Object.fromEntries(Object.keys(x).map((e=>[e,b[e].locale||{}]))),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),_=((0,u.getSetting)("addressFieldsLocations",w).address,(0,u.getSetting)("addressFieldsLocations",w).contact,(0,u.getSetting)("addressFieldsLocations",w).order,(0,u.getSetting)("additionalOrderFields",{}),(0,u.getSetting)("additionalContactFields",{}),(0,u.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)}))}),y=({selected:e=[],search:t="",queryArgs:o={}})=>{const r=(({selected:e=[],search:t="",queryArgs:o={}})=>{const r=g.productCount>100&&e.length>0,a=[(0,l.addQueryArgs)("/wc/store/v1/products",{per_page:100,catalog_visibility:"any",search:t,orderby:"title",order:"asc",exclude:r?e:[],...o})];if(r){const t=Math.ceil(e.length/100);for(let o=1;o<=t;o++)a.push((0,l.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:100,page:o}))}return a})({selected:e,search:t,queryArgs:o});return Promise.all(r.map((e=>m()({path:e})))).then((e=>{const t=e.flat(),o=_(t,(e=>e.id));return o.map((e=>({...e,parent:0})))})).catch((e=>{throw e}))},f=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"}}},v=(0,c.createHigherOrderComponent)((e=>class extends n.Component{constructor(){super(...arguments),this.state={error:null,loading:!1,category:"preview"===this.props.attributes.categoryId?this.props.attributes.previewCategory:null},this.loadCategory=this.loadCategory.bind(this)}componentDidMount(){this.loadCategory()}componentDidUpdate(e){e.attributes.categoryId!==this.props.attributes.categoryId&&this.loadCategory()}loadCategory(){const{categoryId:e}=this.props.attributes;"preview"!==e&&(e?(this.setState({loading:!0}),(e=>m()({path:`wc/store/v1/products/categories/${e}`}))(e).then((e=>{this.setState({category:e,loading:!1,error:null})})).catch((async e=>{const t=await f(e);this.setState({category:null,loading:!1,error:t})}))):this.setState({category:null,loading:!1,error:null}))}render(){const{error:t,loading:o,category:r}=this.state;return(0,a.jsx)(e,{...this.props,error:t,getCategory:this.loadCategory,isLoading:o,category:r})}}),"withCategory"),S=window.wp.components;var j=o(7723);const k=window.wp.blockEditor;var I=o(3462);const C=e=>{const{id:t,name:o,parent:r}=e;return{id:t,name:o,parent:r,breadcrumbs:[],children:[],details:e,value:e.slug}},E=e=>{const{id:t,name:o,parent:r,count:a}=e;return{id:t,name:o,parent:r,count:a,breadcrumbs:[],children:[],details:e,value:e.slug}},A=`${JSON.parse('{"name":"woocommerce/product-collection"}').name}/product-title`,N="woocommerce/featured-category",P="woocommerce/featured-product",R=e=>[["woocommerce/category-title",{level:2,textAlign:"center"}],["woocommerce/category-description",{textAlign:"center"}],["core/buttons",{layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,j.__)("Shop now","woocommerce"),url:e.permalink}]]]],L=e=>[["core/post-title",{isLink:!0,level:2,textAlign:"center",__woocommerceNamespace:A}],["woocommerce/product-summary",{showDescriptionIfEmpty:!0,style:{typography:{textAlign:"center"}},summaryLength:80}],["woocommerce/product-price",{style:{spacing:{padding:{bottom:"16px"}}},textAlign:"center"}],["core/buttons",{layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,j.__)("Shop now","woocommerce"),url:e.permalink}]]]],F=window.wc.wcTypes;function O(e){return!!e&&(0,F.isNumber)(e.id)&&"string"==typeof e.src}function T({blockName:e,item:t,mediaId:o,mediaSrc:r}){const[a,s]=(0,n.useState)(0),[i,c]=(0,n.useState)(""),[l,d]=(0,n.useState)(!1),[m,u]=(0,n.useState)({height:0,width:0}),g=(0,n.useRef)(null),p=(0,n.useRef)(null);return(0,n.useEffect)((()=>{var r,a;s(o||(e===P?(a=t)&&a.images&&a.images.length&&a.images[0].id||0:(r=t)&&O(r.image)?r.image.id:0))}),[e,t,o]),(0,n.useEffect)((()=>{var o,a;c(r||(e===P?(a=t)&&a.images&&a.images.length&&a.images[0].src||"":(o=t)&&O(o.image)?o.image.src:""))}),[e,t,r]),(0,n.useEffect)((()=>{if(i){g.current||(g.current=new Image),p.current||(p.current=document.createElement("canvas"));const e=g.current,t=p.current;e.src=i,e.onload=()=>{const o=e.naturalWidth,r=e.naturalHeight;null!==r&&null!==o&&u({height:r,width:o}),t.width=o,t.height=r;const a=t.getContext("2d",{willReadFrequently:!0});if(!a)return;a.drawImage(e,0,0,o,r);const s=a.getImageData(0,0,o,r).data,i=(()=>{for(let e=3;e<s.length;e+=4)if(s[e]<255)return!0;return!1})();l!==i&&d(i)}}else d(!0);return()=>{g.current&&(g.current.onload=null)}}),[i]),{backgroundImageId:a,backgroundImageSrc:i,isImageBgTransparent:l,originalImgDimension:m}}const B=({backgroundImageId:e,backgroundImageSrc:t,contentAlign:o,cropLabel:r,editLabel:s,editMode:i,isEditingImage:n,mediaSrc:c,setAttributes:l,setIsEditingImage:d,setEditMode:m})=>(0,a.jsxs)(k.BlockControls,{children:[(0,a.jsx)(k.AlignmentToolbar,{value:o,onChange:e=>{l({contentAlign:e})}}),(0,a.jsxs)(S.ToolbarGroup,{children:[t&&!n&&(0,a.jsx)(S.ToolbarButton,{onClick:()=>d(!0),icon:I.A,label:r}),(0,a.jsx)(k.MediaReplaceFlow,{mediaId:e,mediaURL:c,accept:"image/*",onSelect:e=>{l({mediaId:e.id,mediaSrc:e.url})},allowedTypes:["image"]}),e&&c?(0,a.jsx)(S.ToolbarButton,{onClick:()=>l({mediaId:0,mediaSrc:""}),children:(0,j.__)("Reset","woocommerce")}):null]}),(0,a.jsx)(S.ToolbarGroup,{controls:[{icon:"edit",title:s,onClick:()=>m(!i),isActive:i}]})]}),$=({align:e,backgroundImageId:t,backgroundImageSize:o,backgroundImageSrc:r,containerRef:s,isEditingImage:i,setAttributes:c,setIsEditingImage:l})=>{const d=function(e,t){const[o,r]=(0,n.useState)(),a=(0,n.useCallback)((()=>{r(e.current?.clientWidth)}),[e]);return(0,n.useEffect)(a,[a,...t]),(0,n.useEffect)((()=>{if(!e.current)return;const{defaultView:t}=e.current.ownerDocument;return t?(t.addEventListener("resize",a),()=>{t.removeEventListener("resize",a)}):void 0}),[e,a]),o}(s,[e]);return"function"==typeof k.__experimentalImageEditingProvider?(0,a.jsx)(k.__experimentalImageEditingProvider,{id:t,url:r,naturalHeight:o.height||500,naturalWidth:o.width||500,onSaveImage:({id:e,url:t})=>{c({mediaId:e,mediaSrc:t})},isEditing:i,onFinishEditing:()=>l(!1),children:(0,a.jsx)(k.__experimentalImageEditor,{url:r,height:o.height||500,width:o.width||500})}):(0,a.jsx)(k.__experimentalImageEditor,{id:t,url:r,height:o.height||500,width:o.width||500,naturalHeight:o.height,naturalWidth:o.width,onSaveImage:({id:e,url:t})=>{c({mediaId:e,mediaSrc:t})},onFinishEditing:()=>l(!1),clientWidth:d})},D=({alt:e,backgroundColor:t,backgroundColorVisibilityStatus:o,backgroundImageSrc:r,clientId:s,dimRatio:i,focalPoint:n,hasParallax:c,imageFit:l,isRepeated:d,overlayColor:m,overlayGradient:u,setAttributes:g,setGradient:p})=>{const h="function"==typeof S.FocalPointPicker,b=!d&&!c,x=(0,k.__experimentalUseMultipleOriginColorsAndGradients)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.InspectorControls,{children:!!r&&(0,a.jsx)(a.Fragment,{children:h&&(0,a.jsxs)(S.PanelBody,{title:(0,j.__)("Media settings","woocommerce"),children:[(0,a.jsx)(S.ToggleControl,{label:(0,j.__)("Fixed background","woocommerce"),checked:c,onChange:()=>{g({hasParallax:!c})}}),(0,a.jsx)(S.ToggleControl,{label:(0,j.__)("Repeated background","woocommerce"),checked:d,onChange:()=>{g({isRepeated:!d})}}),!d&&(0,a.jsxs)(S.__experimentalToggleGroupControl,{help:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{style:{display:"block",marginBottom:"1em"},children:(0,j.__)("Select “Cover” to have the image automatically fit its container.","woocommerce")}),(0,a.jsx)("span",{children:(0,j.__)("This may affect your ability to freely move the focal point of the image.","woocommerce")})]}),label:(0,j.__)("Image fit","woocommerce"),isBlock:!0,value:l,onChange:e=>g({imageFit:e}),children:[(0,a.jsx)(S.__experimentalToggleGroupControlOption,{label:(0,j.__)("None","woocommerce"),value:"none"}),(0,a.jsx)(S.__experimentalToggleGroupControlOption
/* translators: "Cover" is a verb that indicates an image covering the entire container. */,{label:(0,j.__)("Cover","woocommerce"),value:"cover"})]}),(0,a.jsx)(S.FocalPointPicker,{label:(0,j.__)("Focal Point Picker","woocommerce"),url:r,value:n,onChange:e=>g({focalPoint:e})}),b&&(0,a.jsx)(S.TextareaControl,{label:(0,j.__)("Alt text (alternative text)","woocommerce"),value:e,onChange:e=>{g({alt:e})},help:(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(S.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree",children:(0,j.__)("Describe the purpose of the image","woocommerce")})})})]})})},"inspector"),x.hasColorsOrGradients&&(0,a.jsxs)(k.InspectorControls,{group:"color",children:[!!r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(k.__experimentalColorGradientSettingsDropdown,{__experimentalIsRenderedInSidebar:!0,settings:[{clearable:!0,colorValue:m,gradientValue:u,label:(0,j.__)("Overlay","woocommerce"),onColorChange:e=>g({overlayColor:e}),onGradientChange:e=>{p(e),g({overlayGradient:e})},isShownByDefault:!0,resetAllFilter:()=>({overlayColor:void 0,overlayGradient:void 0})}],panelId:s,...x}),(0,a.jsx)(S.__experimentalToolsPanelItem,{isShownByDefault:!0,hasValue:()=>50!==i,label:(0,j.__)("Overlay opacity","woocommerce"),onDeselect:()=>g({dimRatio:50}),panelId:s,resetAllFilter:()=>({dimRatio:50}),children:(0,a.jsx)(S.RangeControl,{required:!0,label:(0,j.__)("Overlay opacity","woocommerce"),max:100,min:0,onChange:e=>g({dimRatio:e}),step:10,value:i})})]}),!1===o?.isBackgroundVisible&&o?.message&&t&&(0,a.jsx)("div",{className:"image-bg-color-warning",children:(0,a.jsx)(S.Notice,{status:"warning",isDismissible:!1,children:o.message})})]})]})};var M=o(2098),G=o(4921);const V=window.wp.escapeHtml,z=({message:e,type:t})=>e?"general"===t?(0,a.jsxs)("span",{children:[(0,j.__)("The following error was returned","woocommerce"),(0,a.jsx)("br",{}),(0,a.jsx)("code",{children:(0,V.escapeHTML)(e)})]}):"api"===t?(0,a.jsxs)("span",{children:[(0,j.__)("The following error was returned from the API","woocommerce"),(0,a.jsx)("br",{}),(0,a.jsx)("code",{children:(0,V.escapeHTML)(e)})]}):e:(0,j.__)("An error has prevented the block from being updated.","woocommerce"),H=({error:e})=>(0,a.jsx)("div",{className:"wc-block-error-message",children:z(e)});o(3120);const U=({className:e="",error:t,isLoading:o=!1,onRetry:r})=>(0,a.jsxs)(S.Placeholder,{icon:(0,a.jsx)(i.A,{icon:M.A}),label:(0,j.__)("Sorry, an error occurred","woocommerce"),className:(0,G.A)("wc-block-api-error",e),children:[(0,a.jsx)(H,{error:t}),r&&(0,a.jsx)(a.Fragment,{children:o?(0,a.jsx)(S.Spinner,{}):(0,a.jsx)(S.Button,{variant:"secondary",onClick:r,children:(0,j.__)("Retry","woocommerce")})})]});function W(e){return e?`${Math.round(100*e.x)}% ${Math.round(100*e.y)}%`:""}function q(e){return`wc-block-${e.split("/")[1]}`}function J(e){return e===P?(0,j.__)("Previously selected product is no longer available","woocommerce"):(0,j.__)("Previously selected category is no longer available","woocommerce")}var Y=o(2624);function Q(e,t,o){const r=new Set(t.map((e=>e[o])));return e.filter((e=>!r.has(e[o])))}const K=window.wp.htmlEntities,X={clear:(0,j.__)("Clear all selected items","woocommerce"),noItems:(0,j.__)("No items found.","woocommerce"),
/* Translators: %s search term */
noResults:(0,j.__)("No results for %s","woocommerce"),search:(0,j.__)("Search for items","woocommerce"),selected:e=>(0,j.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */
(0,j._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,j.__)("Search results updated.","woocommerce")},Z=(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 a=["0"],s=(e={})=>e.parent?[...s(r[e.parent]),e.name]:e.name?[e.name]:[],i=e=>e.map((e=>{const t=o[e.id];return a.push(""+e.id),{...e,breadcrumbs:s(r[e.parent]),children:t&&t.length?i(t):[]}})),n=i(o[0]||[]);return Object.entries(o).forEach((([e,t])=>{a.includes(e)||n.push(...i(t||[]))})),n},ee=(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,a.jsx)("strong",{children:e},t):(0,a.jsx)(n.Fragment,{children:e},t)))},te=({label:e})=>(0,a.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),oe=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,a.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[r?(0,a.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,a.jsx)("span",{className:"woocommerce-search-list__item-name",children:ee((0,K.decodeEntities)(t.name),o)})]});var s},re=({countLabel:e,className:t,depth:o=0,controlId:r="",item:s,isSelected:i,isSingle:c,onSelect:l,search:d="",selected:m,useExpandedPanelId:u,...g})=>{const[p,h]=u,b=null!=e&&void 0!==s.count&&null!==s.count,x=!!s.breadcrumbs?.length,w=!!s.children?.length,_=p===s.id,y=(0,G.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":x,"has-children":w,"has-count":b,"is-expanded":_,"is-radio-button":c});(0,n.useEffect)((()=>{w&&i&&h(s.id)}),[s,w,i,h]);const f=g.name||`search-list-item-${r}`,v=`${f}-${s.id}`,j=(0,n.useCallback)((()=>{h(_?-1:Number(s.id))}),[_,s.id,h]);return w?(0,a.jsx)("div",{className:y,onClick:j,onKeyDown:e=>"Enter"===e.key||" "===e.key?j():null,role:"treeitem",tabIndex:0,children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{type:"radio",id:v,name:f,value:s.value,onChange:l(s),onClick:e=>e.stopPropagation(),checked:i,className:"woocommerce-search-list__item-input",...g}),(0,a.jsx)(oe,{item:s,search:d}),b?(0,a.jsx)(te,{label:e||s.count}):null]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(S.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:i,...!i&&s.children.some((e=>m.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:ee((0,K.decodeEntities)(s.name),d),onChange:()=>{i?l(Q(m,s.children,"id"))():l(function(e,t){const o=Q(t,e,"id");return[...e,...o]}(m,s.children))()},onClick:e=>e.stopPropagation()}),b?(0,a.jsx)(te,{label:e||s.count}):null]})}):(0,a.jsxs)("label",{htmlFor:v,className:y,children:[c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("input",{...g,type:"radio",id:v,name:f,value:s.value,onChange:l(s),checked:i,className:"woocommerce-search-list__item-input"}),(0,a.jsx)(oe,{item:s,search:d})]}):(0,a.jsx)(S.CheckboxControl,{...g,id:v,name:f,className:"woocommerce-search-list__item-input",value:(0,K.decodeEntities)(s.value),label:ee((0,K.decodeEntities)(s.name),d),onChange:l(s),checked:i}),b?(0,a.jsx)(te,{label:e||s.count}):null]})},ae=re;var se=o(3028);o(5022);const ie=({id:e,label:t,popoverContents:o,remove:r,screenReaderLabel:s,className:l=""})=>{const[d,m]=(0,n.useState)(!1),u=(0,c.useInstanceId)(ie);if(s=s||t,!t)return null;t=(0,K.decodeEntities)(t);const g=(0,G.A)("woocommerce-tag",l,{"has-remove":!!r}),p=`woocommerce-tag__label-${u}`,h=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"screen-reader-text",children:s}),(0,a.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,a.jsxs)("span",{className:g,children:[o?(0,a.jsx)(S.Button,{className:"woocommerce-tag__text",id:p,onClick:()=>m(!0),children:h}):(0,a.jsx)("span",{className:"woocommerce-tag__text",id:p,children:h}),o&&d&&(0,a.jsx)(S.Popover,{onClose:()=>m(!1),children:o}),r&&(0,a.jsx)(S.Button,{className:"woocommerce-tag__remove",onClick:r(e),label:(0,j.sprintf)(
// Translators: %s label.
// Translators: %s label.
(0,j.__)("Remove %s","woocommerce"),t),"aria-describedby":p,children:(0,a.jsx)(i.A,{icon:se.A,size:20,className:"clear-icon",role:"img"})})]})},ne=ie;o(1939);const ce=e=>(0,a.jsx)(ae,{...e}),le=e=>{const{list:t,selected:o,renderItem:r,depth:s=0,onSelect:i,instanceId:c,isSingle:l,search:d,useExpandedPanelId:m}=e,[u]=m;return t?(0,a.jsx)(a.Fragment,{children:t.map((t=>{const g=t.children?.length&&!l?t.children.every((({id:e})=>o.find((t=>t.id===e)))):!!o.find((({id:e})=>e===t.id)),p=t.children?.length&&u===t.id;return(0,a.jsxs)(n.Fragment,{children:[(0,a.jsx)("li",{children:r({item:t,isSelected:g,onSelect:i,isSingle:l,selected:o,search:d,depth:s,useExpandedPanelId:m,controlId:c})}),p?(0,a.jsx)(le,{...e,list:t.children,depth:s+1}):null]},t.id)}))}):null},de=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:s,onRemove:i})=>{if(e||t||!o)return null;const n=o.length;return(0,a.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,a.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,a.jsx)("strong",{children:r.selected(n)}),n>0?(0,a.jsx)(S.Button,{variant:"link",isDestructive:!0,onClick:()=>s([]),"aria-label":r.clear,children:(0,j.__)("Clear all","woocommerce")}):null]}),n>0?(0,a.jsx)("ul",{children:o.map(((e,t)=>(0,a.jsx)("li",{children:(0,a.jsx)(ne,{label:e.name,id:e.id,remove:i})},t)))}):null]})},me=({filteredList:e,search:t,onSelect:o,instanceId:r,useExpandedPanelId:s,...n})=>{const{messages:c,renderItem:l,selected:d,isSingle:m}=n,u=l||ce;return 0===e.length?(0,a.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,a.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,a.jsx)(i.A,{icon:Y.A,role:"img"})}),(0,a.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,j.sprintf)(c.noResults,t):c.noItems})]}):(0,a.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,a.jsx)(le,{useExpandedPanelId:s,list:e,selected:d,renderItem:u,onSelect:o,instanceId:r,isSingle:m,search:t})})},ue=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:s,isSingle:i,list:l,messages:d=X,onChange:m,onSearch:u,selected:g,type:p="text",debouncedSpeak:h}=e,[b,x]=(0,n.useState)(""),w=(0,n.useState)(-1),_=(0,c.useInstanceId)(ue),y=(0,n.useMemo)((()=>({...X,...d})),[d]),f=(0,n.useMemo)((()=>((e,t,o)=>{if(!t)return o?Z(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),a=e.map((e=>!!r.test(e.name)&&e)).filter(Boolean);return o?Z(a,e):a})(l,b,r)),[l,b,r]);(0,n.useEffect)((()=>{h&&h(y.updated)}),[h,y]),(0,n.useEffect)((()=>{"function"==typeof u&&u(b)}),[b,u]);const v=(0,n.useCallback)((e=>()=>{i&&m([]);const t=g.findIndex((({id:t})=>t===e));m([...g.slice(0,t),...g.slice(t+1)])}),[i,g,m]),k=(0,n.useCallback)((e=>()=>{Array.isArray(e)?m(e):-1===g.findIndex((({id:t})=>t===e.id))?m(i?[e]:[...g,e]):v(e.id)()}),[i,v,m,g]),I=(0,n.useCallback)((e=>{const[t]=g.filter((t=>!e.find((e=>t.id===e.id))));v(t.id)()}),[v,g]);return(0,a.jsxs)("div",{className:(0,G.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":s,"is-token":"token"===p}),children:["text"===p&&(0,a.jsx)(de,{...e,onRemove:v,messages:y}),(0,a.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===p?(0,a.jsx)(S.TextControl,{label:y.search,type:"search",value:b,onChange:e=>x(e)}):(0,a.jsx)(S.FormTokenField,{disabled:s,label:y.search,onChange:I,onInputChange:e=>x(e),suggestions:[],__experimentalValidateInput:()=>!1,value:s?[(0,j.__)("Loading…","woocommerce")]:g.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})}),s?(0,a.jsx)("div",{className:"woocommerce-search-list__list",children:(0,a.jsx)(S.Spinner,{})}):(0,a.jsx)(me,{...e,search:b,filteredList:f,messages:y,onSelect:k,instanceId:_,useExpandedPanelId:w})]})},ge=((0,S.withSpokenMessages)(ue),e=>({selected:t,...o})=>{const[r,s]=(0,n.useState)(!0),[i,c]=(0,n.useState)(null),[d,u]=(0,n.useState)([]),g=async e=>{const t=await f(e);c(t),s(!1)},p=(0,n.useRef)(t);return(0,n.useEffect)((()=>{var e;(e={selected:p.current},m()({path:(0,l.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})})).then((e=>{u(e),s(!1)})).catch(g)}),[p]),(0,a.jsx)(e,{...o,selected:t,error:i,categories:d,isLoading:r})});o(6982);const pe=ge((({categories:e=[],error:t=null,isLoading:o=!1,onChange:r,onOperatorChange:s,operator:i="any",selected:n,isCompact:c=!1,isSingle:l=!1,showReviewCount:d})=>{const m={clear:(0,j.__)("Clear all product categories","woocommerce"),list:(0,j.__)("Product Categories","woocommerce"),noItems:(0,j.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,j.__)("Search for product categories","woocommerce"),selected:e=>(0,j.sprintf)(/* translators: %d is the count of selected categories. */ /* translators: %d is the count of selected categories. */
(0,j._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,j.__)("Category search results updated.","woocommerce")};if(t)return(0,a.jsx)(H,{error:t});const u=e.map(E);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ue,{className:"woocommerce-product-categories",list:u,isLoading:o,selected:u.filter((({id:e})=>n.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=d?(0,j.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,j._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,j.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,j._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,j.sprintf)(/* translators: %d is the count of reviews. */ /* translators: %d is the count of reviews. */
(0,j._n)("%d review","%d reviews",t.details?.review_count||0,"woocommerce"),t.details?.review_count||0):(0,j.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */
(0,j._n)("%d product","%d products",t.details?.count||0,"woocommerce"),t.details?.count||0);return(0,a.jsx)(re,{className:(0,G.A)("woocommerce-product-categories__item","has-count",{"is-searching":o.length>0,"is-skip-level":0===r&&0!==t.parent}),...e,countLabel:n,"aria-label":i})},messages:m,isCompact:c,isHierarchical:!0,isSingle:l}),!!s&&(0,a.jsx)("div",{hidden:n.length<2,children:(0,a.jsx)(S.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,j.__)("Display products matching","woocommerce"),help:(0,j.__)("Pick at least two categories to use this setting.","woocommerce"),value:i,onChange:s,options:[{label:(0,j.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,j.__)("All selected categories","woocommerce"),value:"all"}]})})]})}));var he=o(4347);var be=o(923),xe=o.n(be);const we=(0,c.createHigherOrderComponent)((e=>{class t extends n.Component{state={error:null,loading:!1,variations:{}};componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:o,showVariations:r}=this.props;r&&(!xe()(e.selected,o)||e.isLoading&&!t)&&this.loadVariations()}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 a=e.find((e=>e.id===r));var s;a?.variations&&0!==a.variations.length?(this.setState({loading:!0}),(s=r,m()({path:(0,l.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:s})})).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 f(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})};isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){const{products:t}=this.props,o=t.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))));return o[0]?.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:s,variations:i}=this.state;return(0,a.jsx)(e,{...this.props,error:r||t,expandedProduct:this.getExpandedProduct(),isLoading:o,variations:i,variationsLoading:s})}}return t}),"withProductVariations");var _e=o(1609);const ye=({className:e,item:t,isSelected:o,isLoading:r,onSelect:s,disabled:i,...n})=>(0,a.jsxs)(a.Fragment,{children:[(0,_e.createElement)(re,{...n,key:t.id,className:e,isSelected:o,item:t,onSelect:s,disabled:i}),o&&r&&(0,a.jsx)("div",{className:(0,G.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active"),children:(0,a.jsx)(S.Spinner,{})},"loading")]});o(5653);const fe={list:(0,j.__)("Products","woocommerce"),noItems:(0,j.__)("Your store doesn't have any products.","woocommerce"),search:(0,j.__)("Search for a product to display","woocommerce"),updated:(0,j.__)("Product search results updated.","woocommerce")},ve=(e=>t=>{let{selected:o}=t;o=void 0===o?null:o;const r=null===o;return Array.isArray(o)?(0,a.jsx)(e,{...t}):(0,a.jsx)(e,{...t,selected:r?[]:[o]})})((Ie=we((0,c.withInstanceId)((e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:s=!1,isLoading:i,onChange:n,onSearch:c,products:l,renderItem:d,selected:m=[],showVariations:u=!1,variations:g,variationsLoading:p}=e;if(o)return(0,a.jsx)(H,{error:o});const h=[...l,...g&&t&&g[t]?g[t]:[]].map(C);return(0,a.jsx)(ue,{className:"woocommerce-products",list:h,isCompact:s,isLoading:i,isSingle:!0,selected:h.filter((({id:e})=>m.includes(Number(e)))),onChange:n,renderItem:d||(u?e=>{const{item:t,search:o,depth:s=0,isSelected:n,onSelect:c}=e,l=t.details?.variations&&Array.isArray(t.details.variations)?t.details.variations.length:0,d=(0,G.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${s}`,"has-count",{"is-searching":o.length>0,"is-skip-level":0===s&&0!==t.parent,"is-variable":l>0});if(!t.breadcrumbs.length){const o=t.details?.variations&&t.details.variations.length>0;return(0,a.jsx)(ye,{...e,className:(0,G.A)(d,{"is-selected":n}),isSelected:n,item:t,onSelect:()=>()=>{c(t)()},isLoading:i||p,countLabel:o?(0,j.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,j.__)("%1$d variations","woocommerce"),t.details?.variations.length):null,name:`products-${r}`,"aria-label":o?(0,j.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,j._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",t.details?.variations?.length,"woocommerce"),t.name,t.details?.variations.length):void 0})}const m=(0,F.isEmpty)(t.details?.variation)?e:{...e,item:{...e.item,name:t.details?.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.details?.variation}`};return(0,a.jsx)(re,{...m,className:d,name:`variations-${r}`})}:void 0),onSearch:c,messages:{...fe,...e.messages},isHierarchical:!0})}))),({selected:e,...t})=>{const[o,r]=(0,n.useState)(!0),[s,i]=(0,n.useState)(null),[c,l]=(0,n.useState)([]),d=g.productCount>100,m=async e=>{const t=await f(e);i(t),r(!1)},u=(0,n.useRef)(e);(0,n.useEffect)((()=>{y({selected:u.current}).then((e=>{l(e),r(!1)})).catch(m)}),[u]);const p=(0,he.YQ)((t=>{y({selected:e,search:t}).then((e=>{l(e),r(!1)})).catch(m)}),400),h=(0,n.useCallback)((e=>{r(!0),p(e)}),[r,p]);return(0,a.jsx)(Ie,{...t,selected:e,error:s,products:c,isLoading:o,onSearch:d?h:null})})),Se=window.wp.data,je=window.wp.coreData,ke=window.wc.wcBlocksSharedContext;var Ie,Ce=o(7356);const Ee=window.wp.styleEngine;function Ae(e={}){const t={};return(0,Ee.getCSSRules)(e,{selector:""}).forEach((e=>{t[e.key]=e.value})),t}function Ne(e,t){return e&&t?`has-${(0,Ce.c)(t)}-${e}`:""}const Pe=e=>{const t=(e=>{const t=(0,F.isObject)(e)?e:{style:{}};let o=t.style;return(0,F.isString)(o)&&(o=JSON.parse(o)||{}),(0,F.isObject)(o)||(o={}),{...t,style:o}})(e),o=function(e){const{backgroundColor:t,textColor:o,gradient:r,style:a}=e,s=Ne("background-color",t),i=Ne("color",o),n=function(e){if(e)return`has-${e}-gradient-background`}(r),c=n||a?.color?.gradient;return{className:(0,G.A)(i,n,{[s]:!c&&!!s,"has-text-color":o||a?.color?.text,"has-background":t||a?.color?.background||r||a?.color?.gradient,"has-link-color":(0,F.isObject)(a?.elements?.link)?a?.elements?.link?.color:void 0}),style:Ae({color:a?.color||{}})}}(t),r=function(e){const t=e.style?.border||{};return{className:function(e){const{borderColor:t,style:o}=e,r=t?Ne("border-color",t):"";return(0,G.A)({"has-border-color":!!t||!!o?.border?.color,[r]:!!r})}(e),style:Ae({border:t})}}(t),a=function(e){return{className:void 0,style:Ae({spacing:e.style?.spacing||{}})}}(t),s=(e=>{const t=(0,F.isObject)(e.style.typography)?e.style.typography:{},o=(0,F.isString)(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:o,style:{fontSize:e.fontSize?`var(--wp--preset--font-size--${e.fontSize})`:t.fontSize,fontStyle:t.fontStyle,fontWeight:t.fontWeight,letterSpacing:t.letterSpacing,lineHeight:t.lineHeight,textDecoration:t.textDecoration,textTransform:t.textTransform}}})(t);return{className:(0,G.A)(s.className,o.className,r.className,a.className),style:{...s.style,...o.style,...r.style,...a.style}}},Re=({className:e="",onResize:t,...o})=>{const[r,s]=(0,n.useState)(!1),i=(0,G.A)(e,{"is-resizing":r}),c=(0,he.dh)(((e,o,a,i)=>{r||s(!0),t?.(e,o,a,i)}),50,{leading:!0});return(0,a.jsx)(S.ResizableBox,{className:i,enable:{bottom:!0},onResize:c,onResizeStop:(...e)=>{t?.(...e),s(!1)},...o})},Le={icon:s,label:(0,j.__)("Featured Category","woocommerce")},Fe={...Le,cropLabel:(0,j.__)("Edit category image","woocommerce"),editLabel:(0,j.__)("Edit selected category","woocommerce")},Oe={...Le,emptyMessage:(0,j.__)("No product category is selected.","woocommerce"),noSelectionButtonLabel:(0,j.__)("Select a category","woocommerce")},Te={...Le,description:(0,j.__)("Visually highlight a product category and encourage prompt action.","woocommerce"),editLabel:(0,j.__)("Showing Featured Product block preview.","woocommerce")},Be=(0,c.compose)([v,S.withSpokenMessages,e=>t=>{const[o,r]=(0,n.useState)(!1),{category:s,clientId:i,editMode:c,product:l}=t,d=s||l,m=d?.link||d?.permalink,u=(0,Se.useSelect)((e=>e("core/block-editor").getBlock(i)),[i]),g=e=>{if(!e)return;if("core/button"===e.name)return e;const t=e.innerBlocks||[];for(const e of t){const t=g(e);if(t)return t}},p=u?.innerBlocks?.[0],h=g(p),b=h?.clientId||"",x=(0,n.useMemo)((()=>h?.attributes||{}),[h]),{url:w}=x,{updateBlockAttributes:_}=(0,Se.useDispatch)("core/block-editor");return(0,n.useEffect)((()=>{o&&b&&!c&&m&&w&&m!==w&&(_(b,{url:m}),r(!1))}),[b,o,c,m,_,w]),(0,a.jsx)(e,{...t,triggerUrlUpdate:()=>r(!0)})},e=>t=>{const[o,r]=(0,n.useState)(!1),{isSelected:s}=t;return(0,n.useEffect)((()=>{r(!1)}),[s]),(0,a.jsx)(e,{...t,useEditingImage:[o,r]})},(({description:e,editLabel:t,icon:o,label:r})=>s=>i=>{const{attributes:c,debouncedSpeak:l,name:d,setAttributes:m,triggerUrlUpdate:u=()=>{},error:g}=i,p=q(d),[h,b]=(0,n.useState)(),x=d===P&&c.productId||d===N&&c.categoryId,[w,_]=(0,n.useState)(!x),y=d===P?c?.productId:c?.categoryId,{status:f,isDeleted:v,isLoading:k}=(({itemId:e,itemType:t})=>{const{product:o,isResolutionFinished:r}=(a=e,(0,Se.useSelect)((e=>{if(!a)return{product:void 0,isResolving:!1};const t="string"==typeof a?parseInt(a,10):a;return{product:e(je.store).getEditedEntityRecord("root","product",t),isResolving:e(je.store).isResolving("getEditedEntityRecord",["root","product",t]),isResolutionFinished:e(je.store).hasFinishedResolution("getEditedEntityRecord",["root","product",t])}}),[a]));var a;return(0,Se.useSelect)((a=>{if(!e)return{status:null,isDeleted:!1,isLoading:!1};if(t===P){var s;const e=!r,t="trash"===o?.status||!e&&!o;return{status:null!==(s=o?.status)&&void 0!==s?s:null,isDeleted:t,isLoading:e}}if(t===N){const{getEntityRecords:t,hasFinishedResolution:o}=a(je.store),r=["taxonomy","product_cat",{include:[e]}],s=t(...r),i=o("getEntityRecords",r),n=!s?.length;return{status:n?"deleted":null,isDeleted:n,isLoading:!i}}return{status:null,isDeleted:!0,isLoading:!1}}),[e,t,o,r])})({itemId:y,itemType:d});return(0,n.useEffect)((()=>{if(!k){const e=d===P&&"publish"!==f||v;e&&_(e)}}),[f,v,d,k]),w?(0,a.jsxs)(S.Placeholder,{icon:(0,a.jsx)(S.Icon,{icon:o}),label:r,className:p,children:[(0,a.jsxs)(S.__experimentalHStack,{alignment:"center",children:[v?(0,a.jsx)(S.Icon,{icon:Y.A,className:"wc-blocks-featured-items__orange-info-icon"}):(0,a.jsx)(S.Icon,{icon:Y.A}),(0,a.jsx)(S.__experimentalText,{children:v?J(d):e})]}),(0,a.jsxs)("div",{className:`${p}__selection`,children:[d===N&&(0,a.jsx)(pe,{selected:h?.categoryId?[h.categoryId]:[],onChange:(e=[])=>{const t=e[0]?e[0].id:0;b({categoryId:t,mediaId:0,mediaSrc:""}),u()},isSingle:!0}),d===P&&(0,a.jsx)(ve,{selected:h?.productId?[h.productId]:[],showVariations:!0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;b({productId:t,mediaId:0,mediaSrc:""}),u()}}),(0,a.jsx)(S.Button,{variant:"primary",onClick:()=>{h&&(m(h),_(!1),l(t))},children:(0,j.__)("Done","woocommerce")})]})]}):(0,a.jsx)(s,{...i,isLoading:k,error:k?null:g,useEditMode:[w,_]})})(Te),(({emptyMessage:e,icon:t,label:o,noSelectionButtonLabel:r})=>s=>i=>{const[c]=i.useEditingImage,[,l]=i.useEditMode,{attributes:d,category:m,isLoading:u,isSelected:g,name:p,product:h,setAttributes:b}=i,{mediaId:x,mediaSrc:w,isRepeated:_,imageFit:y}=d,f=m||h,[v,I]=(0,n.useState)({}),{backgroundImageSrc:C,isImageBgTransparent:E,originalImgDimension:A}=T({item:f,mediaId:x,mediaSrc:w,blockName:p}),N=(0,n.useRef)(null),[P,F]=(0,n.useState)({height:0,width:0});(0,n.useEffect)((()=>{const e=new ResizeObserver((e=>{F({height:e[0].contentRect.height,width:e[0].contentRect.width})}));if(!1===u){const t=N.current;if(!t)return;e.observe(t)}return()=>e.disconnect()}),[u]);const O=(0,n.useMemo)((()=>(({isImageBgTransparent:e,originalImgDimension:t,parentContainerDimension:o,isRepeated:r,imageFit:a})=>e?{isBackgroundVisible:!0,message:null}:e||!r&&"cover"!==a?!e&&t.height>=o.height&&t.width>=o.width?{isBackgroundVisible:!1,message:(0,j.__)("You've set background color to an opaque image, the background color cannot be seen.","woocommerce")}:(t.height<o.height||(t.width,o.width),{isBackgroundVisible:!0,message:null}):r?{isBackgroundVisible:!1,message:(0,j.__)("You’ve set a background color behind an image set to repeat, the background color cannot be seen.","woocommerce")}:{isBackgroundVisible:!1,message:(0,j.__)("You’ve set a background color behind an image set to cover, the background color cannot be seen.","woocommerce")})({isImageBgTransparent:E,originalImgDimension:A,parentContainerDimension:P,isRepeated:_,imageFit:y})),[P,A,_,y,E]),B=q(p),$=(0,n.useCallback)(((e,t,o)=>{b({minHeight:parseInt(o.style.height,10)})}),[b]),D=Pe(d);return c?(0,a.jsx)(s,{...i,backgroundImageSize:v,backgroundColorVisibilityStatus:O}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s,{...i,backgroundImageSize:v,backgroundColorVisibilityStatus:O}),f?(()=>{const{contentAlign:e,dimRatio:t,focalPoint:o,hasParallax:r,minHeight:s,overlayColor:i,overlayGradient:n,style:c,textColor:l}=d,p=(0,G.A)(B,{"is-selected":g&&"preview"!==d.categoryId&&"preview"!==d.productId,"is-loading":!f&&u,"is-not-found":!f&&!u,"has-background-dim":0!==t,"is-repeated":_},0===(b=t)||50===b?null:"has-background-dim-"+10*Math.round(b/10),"center"!==e&&`has-${e}-content`,D.className);var b;const x={borderRadius:c?.border?.radius,color:l?`var(--wp--preset--color--${l})`:c?.color?.text,boxSizing:"border-box",minHeight:s,...D.style},w=!_&&!r,v=function({focalPoint:e,imageFit:t,isImgElement:o,isRepeated:r,url:a}){let s={};var i;return s=o?{...s,...(i=e,i?{objectPosition:W(i)}:{}),objectFit:t}:{...s,...a&&{backgroundImage:`url(${a})`},backgroundPosition:W(e),...!r&&{backgroundRepeat:"no-repeat",backgroundSize:"cover"===t?t:"auto"}},s}({focalPoint:o,imageFit:y,isImgElement:w,isRepeated:_,url:C}),S={background:n,backgroundColor:i};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Re,{enable:{bottom:!0},onResize:$,showHandle:g,style:{minHeight:s}}),(0,a.jsx)("div",{className:p,ref:N,style:x,children:(0,a.jsxs)("div",{className:`${B}__wrapper`,children:[(0,a.jsx)("div",{className:"background-dim__overlay",style:S}),C&&(w?(0,a.jsx)("img",{alt:f.name,className:`${B}__background-image`,src:C,style:v,onLoad:e=>{I({height:e.currentTarget?.naturalHeight,width:e.currentTarget?.naturalWidth})}}):(0,a.jsx)("div",{className:(0,G.A)(`${B}__background-image`,{"has-parallax":r}),style:v})),h?(0,a.jsx)(k.BlockContextProvider,{value:{postId:h.id,postType:"product"},children:(0,a.jsx)(ke.ProductDataContextProvider,{product:h,isLoading:u,children:(0,a.jsx)("div",{className:`${B}__inner-blocks`,children:(0,a.jsx)(k.InnerBlocks,{template:L(h),templateLock:!1})})})}):(0,a.jsx)(k.BlockContextProvider,{value:{termId:m.term_id,termTaxonomy:"product_cat"},children:(0,a.jsx)("div",{className:`${B}__inner-blocks`,children:(0,a.jsx)(k.InnerBlocks,{template:R(m),templateLock:!1})})})]})})]})})():(0,a.jsx)(S.Placeholder,{className:B,icon:(0,a.jsx)(S.Icon,{icon:t}),label:o,children:u?(0,a.jsx)(S.Spinner,{}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("p",{children:e}),(0,a.jsx)("div",{style:{flexBasis:"100%",height:"0"}}),(0,a.jsx)("button",{type:"button",className:"components-button is-secondary",onClick:()=>l(!0),children:r})]})})]})})(Oe),e=>t=>{const{error:o,isLoading:r,name:s}=t,i=q(s),n=s===N?t.getCategory:t.getProduct;return o?(0,a.jsx)(U,{className:`${i}-error`,error:o,isLoading:r,onRetry:n}):(0,a.jsx)(e,{...t})},e=>t=>{const[o,r]=t.useEditingImage,s=(0,n.useRef)(null),{attributes:i,backgroundImageSize:c,name:l,setAttributes:d}=t,{mediaId:m,mediaSrc:u}=i,g=l===P?t.product:t.category,{backgroundImageId:p,backgroundImageSrc:h}=T({item:g,mediaId:m,mediaSrc:u,blockName:l});return o?(0,a.jsx)("div",{ref:s,children:(0,a.jsx)($,{align:i.align,backgroundImageId:p,backgroundImageSize:c,backgroundImageSrc:h,containerRef:s,isEditingImage:o,setAttributes:d,setIsEditingImage:r})}):(0,a.jsx)(e,{...t})},e=>t=>{const{attributes:o,backgroundColorVisibilityStatus:r,clientId:s,name:i,setAttributes:n}=t,{alt:c,dimRatio:l,focalPoint:d,hasParallax:m,isRepeated:u,imageFit:g,mediaId:p,mediaSrc:h,overlayColor:b,overlayGradient:x,backgroundColor:w,style:_}=o,y=i===P?t.product:t.category,{setGradient:f}=(0,k.__experimentalUseGradient)({gradientAttribute:"overlayGradient",customGradientAttribute:"overlayGradient"}),{backgroundImageSrc:v}=T({item:y,mediaId:p,mediaSrc:h,blockName:i});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(D,{alt:c,backgroundImageSrc:v,dimRatio:l,focalPoint:d,hasParallax:m,isRepeated:u,imageFit:g,overlayColor:b,overlayGradient:x,setAttributes:n,setGradient:f,backgroundColorVisibilityStatus:r,backgroundColor:w||_?.color?.background,clientId:s}),(0,a.jsx)(e,{...t})]})},(({cropLabel:e,editLabel:t})=>o=>r=>{const[s,i]=r.useEditingImage,[n,c]=r.useEditMode,{attributes:l,category:d,name:m,product:u,setAttributes:g}=r,{contentAlign:p,mediaId:h,mediaSrc:b}=l,x=d||u,{backgroundImageId:w,backgroundImageSrc:_}=T({item:x,mediaId:h,mediaSrc:b,blockName:m});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{backgroundImageId:w,backgroundImageSrc:_,contentAlign:p,cropLabel:e,editLabel:t,editMode:n,isEditingImage:s,mediaSrc:b,setAttributes:g,setIsEditingImage:i,setEditMode:c}),(0,a.jsx)(o,{...r})]})})(Fe)])((()=>(0,a.jsx)(a.Fragment,{}))),$e=JSON.parse('{"name":"woocommerce/featured-category","title":"Featured Category","category":"woocommerce","keywords":["WooCommerce"],"description":"Visually highlight a product category and encourage prompt action.","supports":{"interactivity":{"clientNavigation":true},"align":["wide","full"],"ariaLabel":true,"color":{"background":true,"text":true},"html":false,"filter":{"duotone":true},"spacing":{"padding":true,"__experimentalDefaultControls":{"padding":true},"__experimentalSkipSerialization":true},"__experimentalBorder":{"color":true,"radius":true,"width":true,"__experimentalDefaultControls":{"color":true,"radius":true,"width":true},"__experimentalSkipSerialization":true}},"attributes":{"alt":{"type":"string","default":""},"contentAlign":{"type":"string","default":"center"},"dimRatio":{"type":"number","default":50},"focalPoint":{"type":"object","default":{"x":0.5,"y":0.5}},"imageFit":{"type":"string","default":"none"},"hasParallax":{"type":"boolean","default":false},"isRepeated":{"type":"boolean","default":false},"mediaId":{"type":"number","default":0},"mediaSrc":{"type":"string","default":""},"minHeight":{"type":"number","default":500},"linkText":{"default":"Shop now","type":"string"},"categoryId":{"type":"number"},"overlayColor":{"type":"string","default":"#000000"},"overlayGradient":{"type":"string"},"previewCategory":{"type":"object","default":null}},"selectors":{"filter":{"duotone":".wp-block-woocommerce-featured-category .wc-block-featured-category__background-image"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json","usesContext":["termId","termTaxonomy"],"providesContext":{"termId":"categoryId","termTaxonomy":"termTaxonomy"}}'),De=window.wp.blocks;function Me(e){return function(t){const o=(0,k.useBlockProps)(),{color:r,...s}=o.style;return(0,a.jsx)("div",{...o,style:s,children:(0,a.jsx)(e,{...t})})}}!function(e,t,o,r){const s={attributes:{...o.attributes,minHeight:{type:"number",default:(0,u.getSetting)("defaultHeight",500)}},supports:{...o.supports,color:{background:o.supports?.color?.background,text:o.supports?.color?.text},spacing:{padding:o.supports?.spacing?.padding,__experimentalDefaultControls:{padding:o.supports?.spacing?.__experimentalDefaultControls},__experimentalSkipSerialization:o.supports?.spacing?.__experimentalSkipSerialization},__experimentalBorder:o?.supports?.__experimentalBorder}},i={attributes:{alt:"",contentAlign:"center",dimRatio:50,hasParallax:!1,isRepeated:!1,height:(0,u.getSetting)("defaultHeight",500),mediaSrc:"",overlayColor:"#000000",showDesc:!0}};(0,De.registerBlockType)(o,{...s,example:{...i,...t},edit:Me(e),save:()=>(0,a.jsx)(k.InnerBlocks.Content,{}),...r})}(Be,{attributes:{categoryId:"preview",previewCategory:{id:1,name:(0,j.__)("Clothing","woocommerce"),slug:"clothing",parent:0,count:10,description:`<p>${(0,j.__)("Branded t-shirts, jumpers, pants and more!","woocommerce")}</p>\n`,image:{id:1,date_created:"2019-07-15T17:05:04",date_created_gmt:"2019-07-15T17:05:04",date_modified:"2019-07-15T17:05:04",date_modified_gmt:"2019-07-15T17:05:04",src:p+"previews/collection.jpg",name:"",alt:""},permalink:"#"}}},$e,{deprecated:[{attributes:{...$e.attributes,showDesc:{type:"boolean",default:!0}},save:()=>(0,a.jsx)(k.InnerBlocks.Content,{}),isEligible:e=>"boolean"==typeof e.editMode,migrate:(e,t)=>{const{editMode:o,showDesc:r,...a}=e,s="16px";return r&&t.unshift((0,De.createBlock)("woocommerce/category-description",{textAlign:"center",style:{padding:{bottom:s}}})),t.unshift((0,De.createBlock)("woocommerce/category-title",{level:2,isLink:!1,textAlign:"center",style:{padding:{bottom:s}}})),[a,t]}}],icon:{src:(0,a.jsx)(i.A,{icon:s,className:"wc-block-editor-components-block-icon"})}})},1117:()=>{},9926:()=>{},3120:()=>{},6982:()=>{},5653:()=>{},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},923:e=>{"use strict";e.exports=window.wp.isShallowEqual},5573:e=>{"use strict";e.exports=window.wp.primitives}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var o=a[e]={exports:{}};return r[e](o,o.exports,s),o.exports}s.m=r,e=[],s.O=(t,o,r,a)=>{if(!o){var i=1/0;for(d=0;d<e.length;d++){for(var[o,r,a]=e[d],n=!0,c=0;c<o.length;c++)(!1&a||i>=a)&&Object.keys(s.O).every((e=>s.O[e](o[c])))?o.splice(c--,1):(n=!1,a<i&&(i=a));if(n){e.splice(d--,1);var l=r();void 0!==l&&(t=l)}}return t}a=a||0;for(var d=e.length;d>0&&e[d-1][2]>a;d--)e[d]=e[d-1];e[d]=[o,r,a]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.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 a=Object.create(null);s.r(a);var i={};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=>i[t]=()=>e[t]));return i.default=()=>e,s.d(a,i),a},s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.j=9918,(()=>{var e={9918:0};s.O.j=t=>0===e[t];var t=(t,o)=>{var r,a,[i,n,c]=o,l=0;if(i.some((t=>0!==e[t]))){for(r in n)s.o(n,r)&&(s.m[r]=n[r]);if(c)var d=c(s)}for(t&&t(o);l<i.length;l++)a=i[l],s.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return s.O(d)},o=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var i=s.O(void 0,[94],(()=>s(2798)));i=s.O(i),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["featured-category"]=i})();