JezK
Edit File: featured-product.js
(()=>{var e,t,o,r={36301:(e,t,o)=>{"use strict";var r=o(93450),a=o(77092),s=(o(76388),o(90210),o(86087)),n=o(29491);const i=window.wp.url,c=window.wp.apiFetch;var l=o.n(c);const d=window.wc.wcSettings,u=window.wc.wcTypes,m=(0,d.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),g=m.pluginUrl+"assets/images/",p=(m.pluginUrl,d.STORE_PAGES.shop,d.STORE_PAGES.checkout,d.STORE_PAGES.checkout,d.STORE_PAGES.privacy,d.STORE_PAGES.privacy,d.STORE_PAGES.terms,d.STORE_PAGES.terms,d.STORE_PAGES.cart,d.STORE_PAGES.cart,d.STORE_PAGES.myaccount?.permalink?d.STORE_PAGES.myaccount.permalink:(0,d.getSetting)("wpLoginUrl","/wp-login.php"),(0,d.getSetting)("localPickupEnabled",!1),(0,d.getSetting)("shippingMethodsExist",!1),(0,d.getSetting)("shippingEnabled",!0),(0,d.getSettingWithCoercion)("countries",{},u.isObject)),h=(0,d.getSetting)("countryData",{}),b={...Object.fromEntries(Object.keys(h).filter(e=>!0===h[e].allowBilling).map(e=>{const t=p[e];return[e,(0,u.isString)(t)?t:""]})),...Object.fromEntries(Object.keys(h).filter(e=>!0===h[e].allowShipping).map(e=>{const t=p[e];return[e,(0,u.isString)(t)?t:""]}))},_=(Object.fromEntries(Object.keys(b).map(e=>[e,h[e].states||{}])),Object.fromEntries(Object.keys(b).map(e=>[e,h[e].locale||{}])),{address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]}),w=((0,d.getSetting)("addressFieldsLocations",_).address,(0,d.getSetting)("addressFieldsLocations",_).contact,(0,d.getSetting)("addressFieldsLocations",_).order,(0,d.getSetting)("additionalOrderFields",{}),(0,d.getSetting)("additionalContactFields",{}),(0,d.getSetting)("additionalAddressFields",{}),({selected:e=[],search:t="",queryArgs:o={}})=>{const r=(({selected:e=[],search:t="",queryArgs:o={}})=>{const r=m.productCount>100&&e.length>0,a=[(0,i.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,i.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=>l()({path:e}))).then(e=>[...new Map(e.flatMap(e=>e.map(e=>[e.id,{...e,parent:0}]))).values()])}),x=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"}}};var f=o(10790);const y=(0,n.createHigherOrderComponent)(e=>class extends s.Component{state={error:null,loading:!1,product:"preview"===this.props.attributes.productId?this.props.attributes.previewProduct:null};componentDidMount(){this.loadProduct()}componentDidUpdate(e){e.attributes.productId!==this.props.attributes.productId&&this.loadProduct()}loadProduct=()=>{const{productId:e}=this.props.attributes;"preview"!==e&&(e?(this.setState({loading:!0}),(e=>l()({path:`/wc/store/v1/products/${e}`}))(e).then(e=>{this.setState({product:e,loading:!1,error:null})}).catch(async e=>{const t=await x(e);this.setState({product:null,loading:!1,error:t})})):this.setState({product:null,loading:!1,error:null}))};render(){const{error:t,loading:o,product:r}=this.state;return(0,f.jsx)(e,{...this.props,error:t,getProduct:this.loadProduct,isLoading:o,product:r})}},"withProduct"),v=window.wp.components;var S=o(27723);const j=window.wp.blockEditor;var k=o(92542);const I=e=>{const{id:t,name:o,parent:r}=e;return{id:t,name:o,parent:r,breadcrumbs:[],children:[],details:e,value:e.slug}},C=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}},P=`${JSON.parse('{"name":"woocommerce/product-collection"}').name}/product-title`,E="woocommerce/featured-category",A="woocommerce/featured-product",N=e=>[["woocommerce/category-title",{level:2,textAlign:"center"}],["woocommerce/category-description",{textAlign:"center"}],["core/buttons",{layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,S.__)("Shop now","woocommerce"),url:e.permalink}]]]];function R(e){return!!e&&(0,u.isNumber)(e.id)&&"string"==typeof e.src}function L({blockName:e,item:t,mediaId:o,mediaSrc:r}){const[a,n]=(0,s.useState)(0),[i,c]=(0,s.useState)(""),[l,d]=(0,s.useState)(!1),[u,m]=(0,s.useState)({height:0,width:0}),g=(0,s.useRef)(null),p=(0,s.useRef)(null);return(0,s.useEffect)(()=>{var r,a;n(o||(e===A?(a=t)&&a.images&&a.images.length&&a.images[0].id||0:(r=t)&&R(r.image)?r.image.id:0))},[e,t,o]),(0,s.useEffect)(()=>{var o,a;c(r||(e===A?(a=t)&&a.images&&a.images.length&&a.images[0].src||"":(o=t)&&R(o.image)?o.image.src:""))},[e,t,r]),(0,s.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&&m({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,n=(()=>{for(let e=3;e<s.length;e+=4)if(s[e]<255)return!0;return!1})();d(n)}}else d(!0);return()=>{g.current&&(g.current.onload=null)}},[i]),{backgroundImageId:a,backgroundImageSrc:i,isImageBgTransparent:l,originalImgDimension:u}}const F=({backgroundImageId:e,backgroundImageSrc:t,contentAlign:o,cropLabel:r,editLabel:a,editMode:s,isEditingImage:n,mediaSrc:i,setAttributes:c,setIsEditingImage:l,setEditMode:d})=>(0,f.jsxs)(j.BlockControls,{children:[(0,f.jsx)(j.AlignmentToolbar,{value:o,onChange:e=>{c({contentAlign:e})}}),(0,f.jsxs)(v.ToolbarGroup,{children:[t&&!n&&(0,f.jsx)(v.ToolbarButton,{onClick:()=>l(!0),icon:k.A,label:r}),(0,f.jsx)(j.MediaReplaceFlow,{mediaId:e,mediaURL:i,accept:"image/*",onSelect:e=>{c({mediaId:e.id,mediaSrc:e.url})},allowedTypes:["image"]}),e&&i?(0,f.jsx)(v.ToolbarButton,{onClick:()=>c({mediaId:0,mediaSrc:""}),children:(0,S.__)("Reset","woocommerce")}):null]}),(0,f.jsx)(v.ToolbarGroup,{controls:[{icon:"edit",title:a,onClick:()=>d(!s),isActive:s}]})]}),O=({align:e,backgroundImageId:t,backgroundImageSize:o,backgroundImageSrc:r,containerRef:a,originalImgDimension:n,setAttributes:i,setIsEditingImage:c})=>{const l=function(e,t){const[o,r]=(0,s.useState)(),a=(0,s.useCallback)(()=>{r(e.current?.clientWidth)},[e]);return(0,s.useEffect)(a,[a,...t]),(0,s.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}(a,[e]),d=o.height||n.height||500,u=o.width||n.width||500;return(0,f.jsx)(j.__experimentalImageEditor,{id:t,url:r,height:d,width:u,naturalHeight:d,naturalWidth:u,onSaveImage:({id:e,url:t})=>{i({mediaId:e,mediaSrc:t})},onFinishEditing:()=>c(!1),clientWidth:l})},T=({alt:e,backgroundColor:t,backgroundColorVisibilityStatus:o,backgroundImageSrc:r,clientId:a,dimRatio:s,focalPoint:n,hasParallax:i,imageFit:c,isRepeated:l,overlayColor:d,overlayGradient:u,setAttributes:m,setGradient:g})=>{const p="function"==typeof v.FocalPointPicker,h=!l&&!i,b=(0,j.__experimentalUseMultipleOriginColorsAndGradients)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(j.InspectorControls,{children:!!r&&(0,f.jsx)(f.Fragment,{children:p&&(0,f.jsxs)(v.PanelBody,{title:(0,S.__)("Media settings","woocommerce"),children:[(0,f.jsx)(v.ToggleControl,{label:(0,S.__)("Fixed background","woocommerce"),checked:i,onChange:()=>{m({hasParallax:!i})}}),(0,f.jsx)(v.ToggleControl,{label:(0,S.__)("Repeated background","woocommerce"),checked:l,onChange:()=>{m({isRepeated:!l})}}),!l&&(0,f.jsxs)(v.__experimentalToggleGroupControl,{help:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("span",{style:{display:"block",marginBottom:"1em"},children:(0,S.__)("Select “Cover” to have the image automatically fit its container.","woocommerce")}),(0,f.jsx)("span",{children:(0,S.__)("This may affect your ability to freely move the focal point of the image.","woocommerce")})]}),label:(0,S.__)("Image fit","woocommerce"),isBlock:!0,value:c,onChange:e=>m({imageFit:e}),children:[(0,f.jsx)(v.__experimentalToggleGroupControlOption,{label:(0,S.__)("None","woocommerce"),value:"none"}),(0,f.jsx)(v.__experimentalToggleGroupControlOption /* translators: "Cover" is a verb that indicates an image covering the entire container. */,{label:(0,S.__)("Cover","woocommerce"),value:"cover"})]}),(0,f.jsx)(v.FocalPointPicker,{label:(0,S.__)("Focal Point Picker","woocommerce"),url:r,value:n,onChange:e=>m({focalPoint:e})}),h&&(0,f.jsx)(v.TextareaControl,{label:(0,S.__)("Alt text (alternative text)","woocommerce"),value:e,onChange:e=>{m({alt:e})},help:(0,f.jsx)(f.Fragment,{children:(0,f.jsx)(v.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree",children:(0,S.__)("Describe the purpose of the image","woocommerce")})})})]})})},"inspector"),b.hasColorsOrGradients&&(0,f.jsxs)(j.InspectorControls,{group:"color",children:[!!r&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(j.__experimentalColorGradientSettingsDropdown,{__experimentalIsRenderedInSidebar:!0,settings:[{clearable:!0,colorValue:d,gradientValue:u,label:(0,S.__)("Overlay","woocommerce"),onColorChange:e=>m({overlayColor:e}),onGradientChange:e=>{g(e),m({overlayGradient:e})},isShownByDefault:!0,resetAllFilter:()=>({overlayColor:void 0,overlayGradient:void 0})}],panelId:a,...b}),(0,f.jsx)(v.__experimentalToolsPanelItem,{isShownByDefault:!0,hasValue:()=>50!==s,label:(0,S.__)("Overlay opacity","woocommerce"),onDeselect:()=>m({dimRatio:50}),panelId:a,resetAllFilter:()=>({dimRatio:50}),children:(0,f.jsx)(v.RangeControl,{required:!0,label:(0,S.__)("Overlay opacity","woocommerce"),max:100,min:0,onChange:e=>m({dimRatio:e}),step:10,value:s})})]}),!1===o?.isBackgroundVisible&&o?.message&&t&&(0,f.jsx)("div",{className:"image-bg-color-warning",children:(0,f.jsx)(v.Notice,{status:"warning",isDismissible:!1,children:o.message})})]})]})};var B=o(62748),M=o(4921);const $=window.wp.escapeHtml,D=({message:e,type:t})=>e?"general"===t?(0,f.jsxs)("span",{children:[(0,S.__)("The following error was returned","woocommerce"),(0,f.jsx)("br",{}),(0,f.jsx)("code",{children:(0,$.escapeHTML)(e)})]}):"api"===t?(0,f.jsxs)("span",{children:[(0,S.__)("The following error was returned from the API","woocommerce"),(0,f.jsx)("br",{}),(0,f.jsx)("code",{children:(0,$.escapeHTML)(e)})]}):e:(0,S.__)("An error has prevented the block from being updated.","woocommerce"),V=({error:e})=>(0,f.jsx)("div",{className:"wc-block-error-message",children:D(e)});o(63120);const G=({className:e="",error:t,isLoading:o=!1,onRetry:a})=>(0,f.jsxs)(v.Placeholder,{icon:(0,f.jsx)(r.A,{icon:B.A}),label:(0,S.__)("Sorry, an error occurred","woocommerce"),className:(0,M.A)("wc-block-api-error",e),children:[(0,f.jsx)(V,{error:t}),a&&(0,f.jsx)(f.Fragment,{children:o?(0,f.jsx)(v.Spinner,{}):(0,f.jsx)(v.Button,{variant:"secondary",onClick:a,children:(0,S.__)("Retry","woocommerce")})})]});function H(e){return e?`${Math.round(100*e.x)}% ${Math.round(100*e.y)}%`:""}function z(e){return`wc-block-${e.split("/")[1]}`}function W(e){return e===A?(0,S.__)("Previously selected product is no longer available","woocommerce"):(0,S.__)("Previously selected category is no longer available","woocommerce")}const U=window.wp.data;var q=o(19432);function J(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,Q={clear:(0,S.__)("Clear all selected items","woocommerce"),noItems:(0,S.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,S.__)("No results for %s","woocommerce"),search:(0,S.__)("Search for items","woocommerce"),selected:e=>(0,S.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,S._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,S.__)("Search results updated.","woocommerce")},K=(e,t)=>null!==t&&(e.id===t||!!(Array.isArray(e.children)&&e.children.length>0)&&e.children.some(e=>K(e,t))),X=(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]:[],n=e=>e.map(e=>{const t=o[e.id];return a.push(""+e.id),{...e,breadcrumbs:s(r[e.parent]),children:t&&t.length?n(t):[]}}),i=n(o[0]||[]);return Object.entries(o).forEach(([e,t])=>{a.includes(e)||i.push(...n(t||[]))}),i},Z=(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,f.jsx)("strong",{children:e},t):(0,f.jsx)(s.Fragment,{children:e},t))},ee=e=>{const t=e.children?.map(e=>[e,...ee(e)]);return t?t.flat():[]},te=(e,t)=>ee(e).some(e=>t.find(t=>t.id===e.id)),oe=(e,t)=>ee(e).every(e=>t.find(t=>t.id===e.id)),re=({label:e})=>(0,f.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),ae=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,f.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[r?(0,f.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(a=t.breadcrumbs,1===a.length?a.slice(0,1).toString():2===a.length?a.slice(0,1).toString()+" › "+a.slice(-1).toString():a.slice(0,1).toString()+" … "+a.slice(-1).toString())}):null,(0,f.jsx)("span",{className:"woocommerce-search-list__item-name",children:Z((0,Y.decodeEntities)(t.name),o)})]});var a},se=({countLabel:e,className:t,depth:o=0,controlId:r="",disabled:a=!1,item:n,isSelected:i,isSelectable:c=!0,isSingle:l,onSelect:d,search:u="",selected:m,useExpandedPanelId:g,...p})=>{const[h,b]=g,_=null!=e&&void 0!==n.count&&null!==n.count,w=!!n.breadcrumbs?.length,x=!!n.children?.length,y=K(n,h),S=(0,M.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":w,"has-children":x,"has-count":_,"is-expanded":y,"is-radio-button":l}),j=p.name||`search-list-item-${r}`,k=`${j}-${n.id}`,I=(0,s.useCallback)(()=>{y||"number"!=typeof n.id&&"string"!=typeof n.id?!n.parent||"number"!=typeof n.parent&&"string"!=typeof n.parent?b(null):b(n.parent):b(n.id)},[y,n.id,n.parent,b]),C=(i||!c)&&oe(n,m);return x?(0,f.jsx)("div",{className:S,onClick:I,onKeyDown:e=>"Enter"===e.key||" "===e.key?I():null,role:"treeitem",tabIndex:0,children:l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("input",{type:"radio",id:k,name:j,value:n.value,onChange:()=>{d(n)(),y||b(n.id)},onClick:e=>e.stopPropagation(),checked:i,disabled:a,className:"woocommerce-search-list__item-input",...p}),(0,f.jsx)(ae,{item:n,search:u}),_?(0,f.jsx)(re,{label:e||n.count}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(v.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:C,disabled:a,indeterminate:!C&&(i||te(n,m)),label:Z((0,Y.decodeEntities)(n.name),u),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:()=>{const e=ee(n),t=c?[n,...e]:[...e],o=oe(n,m);c&&i||!c&&o?d(J(m,t,"id"))():(d(function(e,t){const o=J(t,e,"id");return[...e,...o]}(m,t))(),y||b(n.id))},__nextHasNoMarginBottom:!0}),_?(0,f.jsx)(re,{label:e||n.count}):null]})}):(0,f.jsxs)("div",{className:S,onClick:a?void 0:d(n),children:[l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("input",{...p,type:"radio",id:k,name:j,value:n.value,onChange:d(n),checked:i,disabled:a,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,f.jsx)("label",{htmlFor:k,children:(0,f.jsx)(ae,{item:n,search:u})})]}):(0,f.jsx)(v.CheckboxControl,{...p,id:k,name:j,className:"woocommerce-search-list__item-input",value:(0,Y.decodeEntities)(n.value),label:Z((0,Y.decodeEntities)(n.name),u),onChange:()=>{d(n)(),y||b(n.id)},checked:i,disabled:a,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),_?(0,f.jsx)(re,{label:e||n.count}):null]})},ne=se;var ie=o(31884);o(75022);const ce=({id:e,label:t,popoverContents:o,remove:a,screenReaderLabel:i,className:c=""})=>{const[l,d]=(0,s.useState)(!1),u=(0,n.useInstanceId)(ce);if(i=i||t,!t)return null;t=(0,Y.decodeEntities)(t);const m=(0,M.A)("woocommerce-tag",c,{"has-remove":!!a}),g=`woocommerce-tag__label-${u}`,p=(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("span",{className:"screen-reader-text",children:i}),(0,f.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,f.jsxs)("span",{className:m,children:[o?(0,f.jsx)(v.Button,{className:"woocommerce-tag__text",id:g,onClick:()=>d(!0),children:p}):(0,f.jsx)("span",{className:"woocommerce-tag__text",id:g,children:p}),o&&l&&(0,f.jsx)(v.Popover,{onClose:()=>d(!1),children:o}),a&&(0,f.jsx)(v.Button,{className:"woocommerce-tag__remove",onClick:a(e),label:(0,S.sprintf)( // Translators: %s label. // Translators: %s label. (0,S.__)("Remove %s","woocommerce"),t),"aria-describedby":g,children:(0,f.jsx)(r.A,{icon:ie.A,size:20,className:"clear-icon",role:"img"})})]})},le=ce;o(71939);const de=e=>(0,f.jsx)(ne,{...e}),ue=e=>{const{list:t,selected:o,renderItem:r,depth:a=0,loadMoreChildrenText:n,onLoadMoreChildren:i,totalChildren:c,onSelect:l,instanceId:d,isSingle:u,search:m,useExpandedPanelId:g}=e,[p]=g;return t?(0,f.jsx)(f.Fragment,{children:t.map(t=>{const h=t.children?.length??0,b=!!o.find(({id:e})=>e===t.id),_=K(t,p),w=c?.[t.id],x="number"==typeof w&&h<w;return(0,f.jsxs)(s.Fragment,{children:[(0,f.jsx)("li",{children:r({item:t,isSelected:b,onSelect:l,isSingle:u,selected:o,search:m,depth:a,useExpandedPanelId:g,controlId:d})}),_?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ue,{...e,list:t.children,depth:a+1}),i&&x?(0,f.jsx)("li",{children:(0,f.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>i(),children:n||(0,S.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},me=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:a,onRemove:s})=>{if(e||t||!o)return null;const n=o.length;return(0,f.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,f.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,f.jsx)("strong",{children:r.selected(n)}),n>0?(0,f.jsx)(v.Button,{variant:"link",isDestructive:!0,onClick:()=>a([]),"aria-label":r.clear,children:(0,S.__)("Clear all","woocommerce")}):null]}),n>0?(0,f.jsx)("ul",{children:o.map((e,t)=>(0,f.jsx)("li",{children:(0,f.jsx)(le,{label:e.name,id:e.id,remove:s})},t))}):null]})},ge=({filteredList:e,search:t,onSelect:o,instanceId:a,useExpandedPanelId:s,...n})=>{const{messages:i,renderItem:c,selected:l,isSingle:d,loadMoreChildrenText:u,onLoadMoreChildren:m,totalChildren:g}=n,p=c||de;return 0===e.length?(0,f.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,f.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,f.jsx)(r.A,{icon:q.A,role:"img"})}),(0,f.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,S.sprintf)(i.noResults,t):i.noItems})]}):(0,f.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,f.jsx)(ue,{useExpandedPanelId:s,list:e,selected:l,renderItem:p,loadMoreChildrenText:u,onLoadMoreChildren:m,totalChildren:g,onSelect:o,instanceId:a,isSingle:d,search:t})})},pe=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:a,isSingle:i,list:c,messages:l=Q,onChange:d,onSearch:u,selected:m,type:g="text",debouncedSpeak:p}=e,[h,b]=(0,s.useState)(""),_=(0,s.useState)(null),w=(0,n.useInstanceId)(pe),x=(0,s.useMemo)(()=>({...Q,...l}),[l]),y=(0,s.useMemo)(()=>((e,t,o)=>{if(!t)return o?X(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),a=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return o?X(a,e):a})(c,h,r),[c,h,r]);(0,s.useEffect)(()=>{p&&p(x.updated)},[p,x]),(0,s.useEffect)(()=>{"function"==typeof u&&u(h)},[h,u]);const j=(0,s.useCallback)(e=>()=>{i&&d([]);const t=m.findIndex(({id:t})=>t===e);d([...m.slice(0,t),...m.slice(t+1)])},[i,m,d]),k=(0,s.useCallback)(e=>()=>{Array.isArray(e)?d(e):-1===m.findIndex(({id:t})=>t===e.id)?d(i?[e]:[...m,e]):j(e.id)()},[i,j,d,m]),I=(0,s.useCallback)(e=>{const[t]=m.filter(t=>!e.find(e=>t.id===e.id));j(t.id)()},[j,m]);return(0,f.jsxs)("div",{className:(0,M.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":a,"is-token":"token"===g}),children:["text"===g&&(0,f.jsx)(me,{...e,onRemove:j,messages:x}),(0,f.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===g?(0,f.jsx)(v.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:x.search,type:"search",value:h,onChange:e=>b(e)}):(0,f.jsx)(v.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:a,label:x.search,onChange:I,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:a?[(0,S.__)("Loading…","woocommerce")]:m.map(e=>({...e,value:e.name})),__experimentalShowHowTo:!1})}),a?(0,f.jsx)("div",{className:"woocommerce-search-list__list",children:(0,f.jsx)(v.Spinner,{})}):(0,f.jsx)(ge,{...e,search:h,filteredList:y,messages:x,onSelect:k,instanceId:w,useExpandedPanelId:_})]})},he=((0,v.withSpokenMessages)(pe),e=>({selected:t,...o})=>{const[r,a]=(0,s.useState)(!0),[n,c]=(0,s.useState)(null),[d,u]=(0,s.useState)([]),m=async e=>{const t=await x(e);c(t),a(!1)},g=(0,s.useRef)(t);return(0,s.useEffect)(()=>{var e;(e={selected:g.current},l()({path:(0,i.addQueryArgs)("wc/store/v1/products/categories",{per_page:0,...e})})).then(e=>{u(e),a(!1)}).catch(m)},[g]),(0,f.jsx)(e,{...o,selected:t,error:n,categories:d,isLoading:r})});o(66982);const be=he(({categories:e=[],error:t=null,isLoading:o=!1,onChange:r,onOperatorChange:a,operator:s="any",selected:n,isCompact:i=!1,isSingle:c=!1,showReviewCount:l})=>{const d={clear:(0,S.__)("Clear all product categories","woocommerce"),list:(0,S.__)("Product Categories","woocommerce"),noItems:(0,S.__)("Your store doesn't have any product categories.","woocommerce"),search:(0,S.__)("Search for product categories","woocommerce"),selected:e=>(0,S.sprintf)(/* translators: %d is the count of selected categories. */ /* translators: %d is the count of selected categories. */ (0,S._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,S.__)("Category search results updated.","woocommerce")};if(t)return(0,f.jsx)(V,{error:t});const u=e.map(C);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(pe,{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,a=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,s=l?(0,S.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,S._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.details?.review_count||0,"woocommerce"),a,t.details?.review_count||0):(0,S.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,S._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.details?.count||0,"woocommerce"),a,t.details?.count||0),n=l?(0,S.sprintf)(/* translators: %d is the count of reviews. */ /* translators: %d is the count of reviews. */ (0,S._n)("%d review","%d reviews",t.details?.review_count||0,"woocommerce"),t.details?.review_count||0):(0,S.sprintf)(/* translators: %d is the count of products. */ /* translators: %d is the count of products. */ (0,S._n)("%d product","%d products",t.details?.count||0,"woocommerce"),t.details?.count||0);return(0,f.jsx)(se,{className:(0,M.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":s})},messages:d,isCompact:i,isHierarchical:!0,isSingle:c}),!!a&&(0,f.jsx)("div",{hidden:n.length<2,children:(0,f.jsx)(v.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,S.__)("Display products matching","woocommerce"),help:(0,S.__)("Pick at least two categories to use this setting.","woocommerce"),value:s,onChange:a,options:[{label:(0,S.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,S.__)("All selected categories","woocommerce"),value:"all"}]})})]})});var _e=o(64347);var we=o(20923),xe=o.n(we);const fe=(0,n.createHigherOrderComponent)(e=>{class t extends s.Component{state={error:null,loading:!1,variations:{},totalVariations:{}};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=({offset:e=0}={})=>{const{products:t}=this.props,{loading:o,variations:r,totalVariations:a}=this.state;if(o)return;const s=this.getExpandedProduct();if(!s)return;if(!e&&r?.[s])return;if(r?.[s]&&a?.[s]&&r[s].length>=a[s])return;const n=t.find(e=>e.id===s);if(!n?.variations||0===n.variations.length)return void this.setState({variations:{...this.state.variations,[s]:null},loading:!1,error:null});this.setState({loading:!0});const c=this.state.variations[s]||[];((e,t={})=>l()({path:(0,i.addQueryArgs)("wc/store/v1/products",{type:"variation",parent:e,orderby:"title",per_page:25,...t}),parse:!1}).then(e=>e.json().then(t=>{const o=e.headers.get("x-wp-total");return{variations:t,total:o?Number(o):null}})))(s,{offset:e}).then(({variations:e,total:t})=>{const o=e.map(e=>({...e,parent:s}));this.setState({variations:{...this.state.variations,[s]:[...c,...o]},totalVariations:{...this.state.totalVariations,[s]:t},loading:!1,error:null})}).catch(async e=>{const t=await x(e);this.setState({variations:{...this.state.variations,[s]:null},totalVariations:{...this.state.totalVariations,[s]:null},loading:!1,error:t})})};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:a,variations:s,totalVariations:n}=this.state,i=this.getExpandedProduct(),c=i&&s[i]?.length||0;return(0,f.jsx)(e,{...this.props,error:r||t,onLoadMoreVariations:()=>this.loadVariations({offset:c}),expandedProduct:this.getExpandedProduct(),isLoading:o,totalVariations:n,variations:s,variationsLoading:a})}}return t},"withProductVariations");var ye=o(51609);const ve=({className:e,item:t,isSelected:o,isLoading:r,onSelect:a,disabled:s,...n})=>(0,f.jsxs)(f.Fragment,{children:[(0,ye.createElement)(se,{...n,key:t.id,...e&&{className:e},isSelected:o,item:t,onSelect:a,...s&&{disabled:s}}),o&&r&&(0,f.jsx)("div",{className:(0,M.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active"),children:(0,f.jsx)(v.Spinner,{})},"loading")]});o(20415);const Se={list:(0,S.__)("Products","woocommerce"),noItems:(0,S.__)("Your store doesn't have any products.","woocommerce"),search:(0,S.__)("Search for a product to display","woocommerce"),updated:(0,S.__)("Product search results updated.","woocommerce")},je=(e=>t=>{let{selected:o}=t;o=void 0===o?null:o;const r=null===o;return Array.isArray(o)?(0,f.jsx)(e,{...t}):(0,f.jsx)(e,{...t,selected:r?[]:[o]})})((Pe=fe((0,n.withInstanceId)(e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:a=!1,isLoading:s,onChange:n,onLoadMoreVariations:i,totalVariations:c,onSearch:l,products:d,renderItem:m,selected:g=[],showVariations:p=!1,variations:h,variationsLoading:b}=e;if(o)return(0,f.jsx)(V,{error:o});const _=[...d,...h&&t&&h[t]?h[t]:[]].map(I);return(0,f.jsx)(pe,{className:"woocommerce-products",list:_,isCompact:a,isLoading:s,isSingle:!0,selected:_.filter(({id:e})=>g.includes(Number(e))),onChange:n,loadMoreChildrenText:p?(0,S.__)("Load more variations","woocommerce"):void 0,onLoadMoreChildren:p?i:void 0,totalChildren:p?c:void 0,renderItem:m||(p?e=>{const{item:t,search:o,depth:a=0,isSelected:n,onSelect:i,useExpandedPanelId:c}=e,[l,d]=c??[null,()=>{}],m=K(t,l),g=t.details?.variations&&Array.isArray(t.details.variations)?t.details.variations.length:0,p=(0,M.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${a}`,"has-count",{"is-searching":o.length>0,"is-skip-level":0===a&&0!==t.parent,"is-variable":g>0});if(!t.breadcrumbs.length){const o=t.details?.variations&&t.details.variations.length>0;return(0,f.jsx)(ve,{...e,className:(0,M.A)(p,{"is-selected":n}),isSelected:n,item:t,onSelect:()=>()=>{i(t)(),m||d(t.id)},isLoading:s||b,countLabel:o?(0,S.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,S.__)("%1$d variations","woocommerce"),t.details?.variations.length):null,name:`products-${r}`,"aria-label":o?(0,S.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,S._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 h=(0,u.isEmpty)(t.details?.variation)?e:{...e,item:{...e.item,name:t.details?.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.details?.variation}`};return(0,f.jsx)(se,{...h,className:p,name:`variations-${r}`})}:void 0),onSearch:l,messages:{...Se,...e.messages},isHierarchical:!0})})),({selected:e,...t})=>{const[o,r]=(0,s.useState)(!0),[a,n]=(0,s.useState)(null),[i,c]=(0,s.useState)([]),l=m.productCount>100,d=async e=>{const t=await x(e);n(t),r(!1)},u=(0,s.useRef)(e);(0,s.useEffect)(()=>{w({selected:u.current}).then(e=>{c(e),r(!1)}).catch(d)},[u]);const g=(0,_e.YQ)(t=>{w({selected:e,search:t}).then(e=>{c(e),r(!1)}).catch(d)},400),p=(0,s.useCallback)(e=>{r(!0),g(e)},[r,g]);return(0,f.jsx)(Pe,{...t,selected:e,error:a,products:i,isLoading:o,onSearch:l?p:null})})),ke=window.wp.coreData,Ie=window.wc.wcEntities,Ce=window.wc.wcBlocksSharedContext;var Pe,Ee=o(67356);const Ae=window.wp.styleEngine;function Ne(e={}){const t={};return(0,Ae.getCSSRules)(e,{selector:""}).forEach(e=>{t[e.key]=e.value}),t}function Re(e,t){return e&&t?`has-${(0,Ee.c)(t)}-${e}`:""}const Le=e=>{const t=(e=>{const t=(0,u.isObject)(e)?e:{style:{}};let o=t.style;return(0,u.isString)(o)&&(o=JSON.parse(o)||{}),(0,u.isObject)(o)||(o={}),{...t,style:o}})(e),o=function(e){const{backgroundColor:t,textColor:o,gradient:r,style:a}=e,s=Re("background-color",t),n=Re("color",o),i=function(e){if(e)return`has-${e}-gradient-background`}(r),c=i||a?.color?.gradient;return{className:(0,M.A)(n,i,{[s]:!c&&!!s,"has-text-color":o||a?.color?.text,"has-background":t||a?.color?.background||r||a?.color?.gradient,"has-link-color":(0,u.isObject)(a?.elements?.link)?a?.elements?.link?.color:void 0}),style:Ne({color:a?.color||{}})}}(t),r=function(e){const t=e.style?.border||{};return{className:function(e){const{borderColor:t,style:o}=e,r=t?Re("border-color",t):"";return(0,M.A)({"has-border-color":!!t||!!o?.border?.color,[r]:!!r})}(e),style:Ne({border:t})}}(t),a=function(e){return{className:void 0,style:Ne({spacing:e.style?.spacing||{}})}}(t),s=(e=>{const t=(0,u.isObject)(e.style.typography)?e.style.typography:{},o=(0,u.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,M.A)(s.className,o.className,r.className,a.className),style:{...s.style,...o.style,...r.style,...a.style}}},Fe=({className:e="",onResize:t,...o})=>{const[r,a]=(0,s.useState)(!1),n=(0,M.A)(e,{"is-resizing":r}),i=(0,_e.dh)((e,o,s,n)=>{r||a(!0),t?.(e,o,s,n)},50,{leading:!0});return(0,f.jsx)(v.ResizableBox,{className:n,enable:{bottom:!0},onResize:i,onResizeStop:(...e)=>{t?.(...e),a(!1)},...o})},Oe={icon:a.A,label:(0,S.__)("Featured Product","woocommerce")},Te={...Oe,cropLabel:(0,S.__)("Edit product image","woocommerce"),editLabel:(0,S.__)("Edit selected product","woocommerce")},Be={...Oe,emptyMessage:(0,S.__)("No product is selected.","woocommerce"),noSelectionButtonLabel:(0,S.__)("Select a product","woocommerce")},Me={...Oe,description:(0,S.__)("Highlight a product or variation.","woocommerce"),editLabel:(0,S.__)("Showing Featured Product block preview.","woocommerce")},$e=(0,n.compose)([y,v.withSpokenMessages,e=>t=>{const[o,r]=(0,s.useState)(!1),{category:a,clientId:n,editMode:i,product:c}=t,l=a||c,d=l?.link||l?.permalink,u=(0,U.useSelect)(e=>e("core/block-editor").getBlock(n),[n]),m=e=>{if(!e)return;if("core/button"===e.name)return e;const t=e.innerBlocks||[];for(const e of t){const t=m(e);if(t)return t}},g=u?.innerBlocks?.[0],p=m(g),h=p?.clientId||"",b=(0,s.useMemo)(()=>p?.attributes||{},[p]),{url:_}=b,{updateBlockAttributes:w}=(0,U.useDispatch)("core/block-editor");return(0,s.useEffect)(()=>{o&&h&&!i&&d&&_&&d!==_&&(w(h,{url:d}),r(!1))},[h,o,i,d,w,_]),(0,f.jsx)(e,{...t,triggerUrlUpdate:()=>r(!0)})},e=>t=>{const[o,r]=(0,s.useState)(!1),{isSelected:a}=t;return(0,s.useEffect)(()=>{r(!1)},[a]),(0,f.jsx)(e,{...t,useEditingImage:[o,r]})},(({description:e,editLabel:t,icon:o,label:r})=>a=>n=>{const{attributes:i,debouncedSpeak:c,name:l,setAttributes:d,triggerUrlUpdate:u=()=>{},error:m}=n,g=z(l),[p,h]=(0,s.useState)(),b=l===A&&i.productId||l===E&&i.categoryId,[_,w]=(0,s.useState)(!b),x=l===A?i?.productId:i?.categoryId,{status:y,isDeleted:k,isLoading:I}=(({itemId:e,itemType:t})=>{const{product:o,isResolutionFinished:r}=(0,Ie.useProduct)(e);return(0,U.useSelect)(a=>{if(!e)return{status:null,isDeleted:!1,isLoading:!1};if(t===A){const e=!r,t="trash"===o?.status||!e&&!o;return{status:o?.status??null,isDeleted:t,isLoading:e}}if(t===E){const{getEntityRecords:t,hasFinishedResolution:o}=a(ke.store),r=["taxonomy","product_cat",{include:[e]}],s=t(...r),n=o("getEntityRecords",r),i=!s?.length;return{status:i?"deleted":null,isDeleted:i,isLoading:!n}}return{status:null,isDeleted:!0,isLoading:!1}},[e,t,o,r])})({itemId:x,itemType:l}),C=(0,U.useSelect)(e=>{const{getSettings:t}=e(j.store);return Boolean(t()?.isPreviewMode??!1)},[]);return(0,s.useEffect)(()=>{if(!C&&!I){const e=l===A&&"publish"!==y||k;e&&w(e)}},[y,k,l,I,C]),_?(0,f.jsxs)(v.Placeholder,{icon:(0,f.jsx)(v.Icon,{icon:o}),label:r,className:g,children:[(0,f.jsxs)(v.__experimentalHStack,{alignment:"center",children:[k?(0,f.jsx)(v.Icon,{icon:q.A,className:"wc-blocks-featured-items__orange-info-icon"}):(0,f.jsx)(v.Icon,{icon:q.A}),(0,f.jsx)(v.__experimentalText,{children:k?W(l):e})]}),(0,f.jsxs)("div",{className:`${g}__selection`,children:[l===E&&(0,f.jsx)(be,{selected:p?.categoryId?[p.categoryId]:[],onChange:(e=[])=>{const t=e[0]?e[0].id:0;h({categoryId:t,mediaId:0,mediaSrc:""}),u()},isSingle:!0}),l===A&&(0,f.jsx)(je,{selected:p?.productId?[p.productId]:[],showVariations:!0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;h({productId:t,mediaId:0,mediaSrc:""}),u()}}),(0,f.jsx)(v.Button,{variant:"primary",onClick:()=>{p&&(d(p),w(!1),c(t))},children:(0,S.__)("Done","woocommerce")})]})]}):(0,f.jsx)(a,{...n,isLoading:I,error:I?null:m,useEditMode:[_,w]})})(Me),(({emptyMessage:e,icon:t,label:o,noSelectionButtonLabel:r})=>a=>n=>{const[i]=n.useEditingImage,[,c]=n.useEditMode,{attributes:l,category:d,isLoading:u,isSelected:m,name:g,product:p,setAttributes:h}=n,{mediaId:b,mediaSrc:_,isRepeated:w,imageFit:x}=l,y=d||p,[k,I]=(0,s.useState)({}),{backgroundImageSrc:C,isImageBgTransparent:E,originalImgDimension:A}=L({item:y,mediaId:b,mediaSrc:_,blockName:g}),R=(0,s.useRef)(null),[F,O]=(0,s.useState)({height:0,width:0});(0,s.useEffect)(()=>{const e=new ResizeObserver(e=>{O({height:e[0].contentRect.height,width:e[0].contentRect.width})});if(!1===u){const t=R.current;if(!t)return;e.observe(t)}return()=>e.disconnect()},[u]);const T=(0,s.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,S.__)("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,S.__)("You’ve set a background color behind an image set to repeat, the background color cannot be seen.","woocommerce")}:{isBackgroundVisible:!1,message:(0,S.__)("You’ve set a background color behind an image set to cover, the background color cannot be seen.","woocommerce")})({isImageBgTransparent:E,originalImgDimension:A,parentContainerDimension:F,isRepeated:w,imageFit:x}),[F,A,w,x,E]),B=z(g),$=(0,s.useCallback)((e,t,o)=>{h({minHeight:parseInt(o.style.height,10)})},[h]),D=()=>{if(p){const e=(e=>[["core/post-title",{isLink:!0,level:2,textAlign:"center",__woocommerceNamespace:P}],["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,S.__)("Shop now","woocommerce"),url:e.permalink}]]]])(p);return(0,f.jsx)(j.BlockContextProvider,{value:{postId:p.id,postType:"product"},children:(0,f.jsx)(Ce.ProductDataContextProvider,{product:p,isLoading:u,children:(0,f.jsx)("div",{className:`${B}__inner-blocks`,children:(0,f.jsx)(j.InnerBlocks,{template:e,templateLock:!1})})})})}return(0,f.jsx)(j.BlockContextProvider,{value:{termId:d.term_id,termTaxonomy:"product_cat"},children:(0,f.jsx)("div",{className:`${B}__inner-blocks`,children:(0,f.jsx)(j.InnerBlocks,{template:N(d),templateLock:!1})})})},V=Le(l);return i?(0,f.jsx)(a,{...n,backgroundImageSize:k,backgroundColorVisibilityStatus:T}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a,{...n,backgroundImageSize:k,backgroundColorVisibilityStatus:T}),y?(()=>{const{contentAlign:e,dimRatio:t,focalPoint:o,hasParallax:r,minHeight:a,overlayColor:s,overlayGradient:n,style:i,textColor:c}=l,d=(0,M.A)(B,{"is-selected":m&&"preview"!==l.categoryId&&"preview"!==l.productId,"is-loading":!y&&u,"is-not-found":!y&&!u,"has-background-dim":0!==t,"is-repeated":w},0===(g=t)||50===g?null:"has-background-dim-"+10*Math.round(g/10),"center"!==e&&`has-${e}-content`,V.className);var g;const p={borderRadius:i?.border?.radius,color:c?`var(--wp--preset--color--${c})`:i?.color?.text,boxSizing:"border-box",minHeight:a,...V.style},h=!w&&!r,b=function({focalPoint:e,imageFit:t,isImgElement:o,isRepeated:r,url:a}){let s={};var n;return s=o?{...s,...(n=e,n?{objectPosition:H(n)}:{}),objectFit:t}:{...s,...a&&{backgroundImage:`url(${a})`},backgroundPosition:H(e),...!r&&{backgroundRepeat:"no-repeat",backgroundSize:"cover"===t?t:"auto"}},s}({focalPoint:o,imageFit:x,isImgElement:h,isRepeated:w,url:C}),_={background:n,backgroundColor:s};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(Fe,{enable:{bottom:!0},onResize:$,showHandle:m,style:{minHeight:a}}),(0,f.jsx)("div",{className:d,ref:R,style:p,children:(0,f.jsxs)("div",{className:`${B}__wrapper`,children:[(0,f.jsx)("div",{className:"background-dim__overlay",style:_}),C&&(h?(0,f.jsx)("img",{alt:y.name,className:`${B}__background-image`,src:C,style:b,onLoad:e=>{I({height:e.currentTarget?.naturalHeight,width:e.currentTarget?.naturalWidth})}}):(0,f.jsx)("div",{className:(0,M.A)(`${B}__background-image`,{"has-parallax":r}),style:b})),D()]})})]})})():(0,f.jsx)(v.Placeholder,{className:B,icon:(0,f.jsx)(v.Icon,{icon:t}),label:o,children:u?(0,f.jsx)(v.Spinner,{}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("p",{children:e}),(0,f.jsx)("div",{style:{flexBasis:"100%",height:"0"}}),(0,f.jsx)("button",{type:"button",className:"components-button is-secondary",onClick:()=>c(!0),children:r})]})})]})})(Be),e=>t=>{const{error:o,isLoading:r,name:a}=t,s=z(a),n=a===E?t.getCategory:t.getProduct;return o?(0,f.jsx)(G,{className:`${s}-error`,error:o,isLoading:r,onRetry:n}):(0,f.jsx)(e,{...t})},e=>t=>{const[o,r]=t.useEditingImage,a=(0,s.useRef)(null),{attributes:n,backgroundImageSize:i,name:c,setAttributes:l}=t,{mediaId:d,mediaSrc:u}=n,m=c===A?t.product:t.category,{backgroundImageId:g,backgroundImageSrc:p,originalImgDimension:h}=L({item:m,mediaId:d,mediaSrc:u,blockName:c});return o?(0,f.jsx)("div",{ref:a,children:(0,f.jsx)(O,{align:n.align,backgroundImageId:g,backgroundImageSize:i,backgroundImageSrc:p,containerRef:a,originalImgDimension:h,setAttributes:l,setIsEditingImage:r})}):(0,f.jsx)(e,{...t})},e=>t=>{const{attributes:o,backgroundColorVisibilityStatus:r,clientId:a,name:s,setAttributes:n}=t,{alt:i,dimRatio:c,focalPoint:l,hasParallax:d,isRepeated:u,imageFit:m,mediaId:g,mediaSrc:p,overlayColor:h,overlayGradient:b,backgroundColor:_,style:w}=o,x=s===A?t.product:t.category,{setGradient:y}=(0,j.__experimentalUseGradient)({gradientAttribute:"overlayGradient",customGradientAttribute:"overlayGradient"}),{backgroundImageSrc:v}=L({item:x,mediaId:g,mediaSrc:p,blockName:s});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(T,{alt:i,backgroundImageSrc:v,dimRatio:c,focalPoint:l,hasParallax:d,isRepeated:u,imageFit:m,overlayColor:h,overlayGradient:b,setAttributes:n,setGradient:y,backgroundColorVisibilityStatus:r,backgroundColor:_||w?.color?.background,clientId:a}),(0,f.jsx)(e,{...t})]})},(({cropLabel:e,editLabel:t})=>o=>r=>{const[a,s]=r.useEditingImage,[n,i]=r.useEditMode,{attributes:c,category:l,name:d,product:u,setAttributes:m}=r,{contentAlign:g,mediaId:p,mediaSrc:h}=c,b=l||u,{backgroundImageId:_,backgroundImageSrc:w}=L({item:b,mediaId:p,mediaSrc:h,blockName:d});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(F,{backgroundImageId:_,backgroundImageSrc:w,contentAlign:g,cropLabel:e,editLabel:t,editMode:n,isEditingImage:a,mediaSrc:h,setAttributes:m,setIsEditingImage:s,setEditMode:i}),(0,f.jsx)(o,{...r})]})})(Te)])(()=>(0,f.jsx)(f.Fragment,{})),De=window.wp.blocks;function Ve(e){return function(t){const o=(0,j.useBlockProps)(),{color:r,...a}=o.style;return(0,f.jsx)("div",{...o,style:a,children:(0,f.jsx)(e,{...t})})}}const Ge={attributes:{productId:"preview",previewProduct:{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:(0,S.__)("Fly your WordPress banner with this beauty! Deck out your office space or add it to your kids walls. This banner will spruce up any space it’s hung!","woocommerce"),description:"Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",price:"7.99",price_html:'<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol" translate="no">$</span>7.99</span>',images:[{id:1,src:g+"previews/pennant.jpg",thumbnail:g+"previews/pennant.jpg",name:"pennant-1.jpg",alt:"WordPress Pennant",srcset:"",sizes:""}],average_rating:5,categories:[{id:1,name:"Decor",slug:"decor",link:"https://example.org"}],review_count:1,prices:{currency_code:"GBP",decimal_separator:".",thousand_separator:",",decimals:2,price_prefix:"£",price_suffix:"",price:"7.99",regular_price:"9.99",sale_price:"7.99",price_range:null},add_to_cart:{text:(0,S.__)("Add to cart","woocommerce"),description:(0,S.__)("Add to cart","woocommerce")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}}},He=JSON.parse('{"name":"woocommerce/featured-product","title":"Featured Product","description":"Highlight a product or variation.","category":"woocommerce","keywords":["WooCommerce"],"supports":{"interactivity":{"clientNavigation":true},"align":["wide","full"],"ariaLabel":true,"html":false,"filter":{"duotone":true},"color":{"background":true,"text":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},"multiple":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":{"type":"string","default":"Shop now"},"overlayColor":{"type":"string","default":"#000000"},"overlayGradient":{"type":"string"},"productId":{"type":"number"},"previewProduct":{"type":"object","default":null}},"selectors":{"filter":{"duotone":".wp-block-woocommerce-featured-product .wc-block-featured-product__background-image"}},"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}');!function(e,t,o,r){const a={attributes:{...o.attributes,minHeight:{type:"number",default:(0,d.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}},s={attributes:{alt:"",contentAlign:"center",dimRatio:50,hasParallax:!1,isRepeated:!1,height:(0,d.getSetting)("defaultHeight",500),mediaSrc:"",overlayColor:"#000000",showDesc:!0}};(0,De.registerBlockType)(o,{...a,example:{...s,...t},edit:Ve(e),save:()=>(0,f.jsx)(j.InnerBlocks.Content,{}),...r})}($e,Ge,He,{deprecated:[{attributes:{...He.attributes,showDesc:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0}},save:()=>(0,f.jsx)(j.InnerBlocks.Content,{}),isEligible:e=>"boolean"==typeof e.editMode,migrate:(e,t)=>{const{editMode:o,showDesc:r,showPrice:a,...s}=e;return!1!==a&&t.unshift((0,De.createBlock)("woocommerce/product-price",{style:{spacing:{padding:{bottom:"16px"}}},textAlign:"center"})),!1!==r&&t.unshift((0,De.createBlock)("woocommerce/product-summary",{showDescriptionIfEmpty:!0,summaryLength:80,style:{typography:{textAlign:"center"}}})),t.unshift((0,De.createBlock)("core/post-title",{level:2,isLink:!1,textAlign:"center",__woocommerceNamespace:"woocommerce/product-collection/product-title"})),[s,t]}}],icon:{src:(0,f.jsx)(r.A,{icon:a.A,className:"wc-block-editor-components-block-icon"})}})},90210:()=>{},76388:()=>{},63120:()=>{},66982:()=>{},20415:()=>{},71939:()=>{},75022:()=>{},51609:e=>{"use strict";e.exports=window.React},10790:e=>{"use strict";e.exports=window.ReactJSXRuntime},29491:e=>{"use strict";e.exports=window.wp.compose},86087:e=>{"use strict";e.exports=window.wp.element},27723:e=>{"use strict";e.exports=window.wp.i18n},20923: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 n=1/0;for(d=0;d<e.length;d++){for(var[o,r,a]=e[d],i=!0,c=0;c<o.length;c++)(!1&a||n>=a)&&Object.keys(s.O).every(e=>s.O[e](o[c]))?o.splice(c--,1):(i=!1,a<n&&(n=a));if(i){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 n={};t=t||[null,o({}),o([]),o(o)];for(var i=2&r&&e;"object"==typeof i&&!~t.indexOf(i);i=o(i))Object.getOwnPropertyNames(i).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,s.d(a,n),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.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),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=8931,(()=>{var e={8931:0};s.O.j=t=>0===e[t];var t=(t,o)=>{var r,a,[n,i,c]=o,l=0;if(n.some(t=>0!==e[t])){for(r in i)s.o(i,r)&&(s.m[r]=i[r]);if(c)var d=c(s)}for(t&&t(o);l<n.length;l++)a=n[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 n=s.O(void 0,[94],()=>s(36301));n=s.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["featured-product"]=n})();