← Back
Editing: featured-product.js
(()=>{var e,t,o,r={20759:(e,t,o)=>{"use strict";var r=o(11789),a=o(98203),i=(o(76388),o(90210),o(86087)),n=o(29491);const s=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:""]}))},w=(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:[]}),_=((0,d.getSetting)("addressFieldsLocations",w).address,(0,d.getSetting)("addressFieldsLocations",w).contact,(0,d.getSetting)("addressFieldsLocations",w).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,s.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,s.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 v=(0,n.createHigherOrderComponent)(e=>class extends i.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"),y=window.wp.components;var j=o(27723);const k=window.wp.blockEditor;var S=o(33897);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,t=!1)=>[["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,...t&&{metadata:{bindings:{url:{source:"core/term-data",args:{field:"link"}}}}}}]]]];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,i.useState)(0),[s,c]=(0,i.useState)(""),[l,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)({height:0,width:0}),g=(0,i.useRef)(null),p=(0,i.useRef)(null);return(0,i.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,i.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,i.useEffect)(()=>{if(s){g.current||(g.current=new Image),p.current||(p.current=document.createElement("canvas"));const e=g.current,t=p.current;e.src=s,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 i=a.getImageData(0,0,o,r).data,n=(()=>{for(let e=3;e<i.length;e+=4)if(i[e]<255)return!0;return!1})();d(n)}}else d(!0);return()=>{g.current&&(g.current.onload=null)}},[s]),{backgroundImageId:a,backgroundImageSrc:s,isImageBgTransparent:l,originalImgDimension:u}}const T=({canEditItem:e=!0,backgroundImageId:t,backgroundImageSrc:o,contentAlign:r,verticalAlignment:a,cropLabel:i,editLabel:n,editMode:s,isEditingImage:c,mediaSrc:l,setAttributes:d,setIsEditingImage:u,setEditMode:m})=>(0,f.jsxs)(k.BlockControls,{children:[(0,f.jsx)(k.BlockVerticalAlignmentToolbar,{value:a||"center",onChange:e=>d({verticalAlignment:e})}),(0,f.jsx)(k.AlignmentToolbar,{value:r,onChange:e=>{d({contentAlign:e})}}),(0,f.jsxs)(y.ToolbarGroup,{children:[o&&!c&&(0,f.jsx)(y.ToolbarButton,{onClick:()=>u(!0),icon:S.A,label:i}),(0,f.jsx)(k.MediaReplaceFlow,{mediaId:t,mediaURL:l,accept:"image/*",onSelect:e=>{d({mediaId:e.id,mediaSrc:e.url})},allowedTypes:["image"]}),t&&l?(0,f.jsx)(y.ToolbarButton,{onClick:()=>d({mediaId:0,mediaSrc:""}),children:(0,j.__)("Reset","woocommerce")}):null]}),e&&(0,f.jsx)(y.ToolbarGroup,{controls:[{icon:"edit",title:n,onClick:()=>m(!s),isActive:s}]})]}),F=({align:e,backgroundImageId:t,backgroundImageSize:o,backgroundImageSrc:r,containerRef:a,originalImgDimension:n,setAttributes:s,setIsEditingImage:c})=>{const l=function(e,t){const[o,r]=(0,i.useState)(),a=(0,i.useCallback)(()=>{r(e.current?.clientWidth)},[e]);return(0,i.useEffect)(a,[a,...t]),(0,i.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)(k.__experimentalImageEditor,{id:t,url:r,height:d,width:u,naturalHeight:d,naturalWidth:u,onSaveImage:({id:e,url:t})=>{s({mediaId:e,mediaSrc:t})},onFinishEditing:()=>c(!1),clientWidth:l})},B=({alt:e,backgroundColor:t,backgroundColorVisibilityStatus:o,backgroundImageSrc:r,clientId:a,dimRatio:i,focalPoint:n,hasParallax:s,imageFit:c,isRepeated:l,overlayColor:d,overlayGradient:u,setAttributes:m,setGradient:g})=>{const p="function"==typeof y.FocalPointPicker,h=!l&&!s,b=(0,k.__experimentalUseMultipleOriginColorsAndGradients)();return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(k.InspectorControls,{children:!!r&&(0,f.jsx)(f.Fragment,{children:p&&(0,f.jsxs)(y.PanelBody,{title:(0,j.__)("Media settings","woocommerce"),children:[(0,f.jsx)(y.ToggleControl,{label:(0,j.__)("Fixed background","woocommerce"),checked:s,onChange:()=>{m({hasParallax:!s})}}),(0,f.jsx)(y.ToggleControl,{label:(0,j.__)("Repeated background","woocommerce"),checked:l,onChange:()=>{m({isRepeated:!l})}}),!l&&(0,f.jsxs)(y.__experimentalToggleGroupControl,{help:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("span",{style:{display:"block",marginBottom:"1em"},children:(0,j.__)("Select “Cover” to have the image automatically fit its container.","woocommerce")}),(0,f.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:c,onChange:e=>m({imageFit:e}),children:[(0,f.jsx)(y.__experimentalToggleGroupControlOption,{label:(0,j.__)("None","woocommerce"),value:"none"}),(0,f.jsx)(y.__experimentalToggleGroupControlOption /* translators: "Cover" is a verb that indicates an image covering the entire container. */,{label:(0,j.__)("Cover","woocommerce"),value:"cover"})]}),(0,f.jsx)(y.FocalPointPicker,{label:(0,j.__)("Focal Point Picker","woocommerce"),url:r,value:n,onChange:e=>m({focalPoint:e})}),h&&(0,f.jsx)(y.TextareaControl,{label:(0,j.__)("Alt text (alternative text)","woocommerce"),value:e,onChange:e=>{m({alt:e})},help:(0,f.jsx)(f.Fragment,{children:(0,f.jsx)(y.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree",children:(0,j.__)("Describe the purpose of the image","woocommerce")})})})]})})},"inspector"),b.hasColorsOrGradients&&(0,f.jsxs)(k.InspectorControls,{group:"color",children:[!!r&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(k.__experimentalColorGradientSettingsDropdown,{__experimentalIsRenderedInSidebar:!0,settings:[{clearable:!0,colorValue:d,gradientValue:u,label:(0,j.__)("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)(y.__experimentalToolsPanelItem,{isShownByDefault:!0,hasValue:()=>50!==i,label:(0,j.__)("Overlay opacity","woocommerce"),onDeselect:()=>m({dimRatio:50}),panelId:a,resetAllFilter:()=>({dimRatio:50}),children:(0,f.jsx)(y.RangeControl,{required:!0,label:(0,j.__)("Overlay opacity","woocommerce"),max:100,min:0,onChange:e=>m({dimRatio:e}),step:10,value:i})})]}),!1===o?.isBackgroundVisible&&o?.message&&t&&(0,f.jsx)("div",{className:"image-bg-color-warning",children:(0,f.jsx)(y.Notice,{status:"warning",isDismissible:!1,children:o.message})})]})]})};var O=o(54331),M=o(4921);const D=window.wp.escapeHtml,$=({message:e,type:t})=>e?"general"===t?(0,f.jsxs)("span",{children:[(0,j.__)("The following error was returned","woocommerce"),(0,f.jsx)("br",{}),(0,f.jsx)("code",{children:(0,D.escapeHTML)(e)})]}):"api"===t?(0,f.jsxs)("span",{children:[(0,j.__)("The following error was returned from the API","woocommerce"),(0,f.jsx)("br",{}),(0,f.jsx)("code",{children:(0,D.escapeHTML)(e)})]}):e:(0,j.__)("An error has prevented the block from being updated.","woocommerce"),V=({error:e})=>(0,f.jsx)("div",{className:"wc-block-error-message",children:$(e)});o(63120);const G=({className:e="",error:t,isLoading:o=!1,onRetry:a})=>(0,f.jsxs)(y.Placeholder,{icon:(0,f.jsx)(r.A,{icon:O.A}),label:(0,j.__)("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)(y.Spinner,{}):(0,f.jsx)(y.Button,{variant:"secondary",onClick:a,children:(0,j.__)("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 U(e){return e===A?(0,j.__)("Previously selected product is no longer available","woocommerce"):(0,j.__)("Previously selected category is no longer available","woocommerce")}const W=window.wp.data;var q=o(74515);function Y(e,t,o){const r=new Set(t.map(e=>e[o]));return e.filter(e=>!r.has(e[o]))}const J=window.wp.htmlEntities,Q={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")},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"],i=(e={})=>e.parent?[...i(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:i(r[e.parent]),children:t&&t.length?n(t):[]}}),s=n(o[0]||[]);return Object.entries(o).forEach(([e,t])=>{a.includes(e)||s.push(...n(t||[]))}),s},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)(i.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,J.decodeEntities)(t.name),o)})]});var a},ie=({countLabel:e,className:t,depth:o=0,controlId:r="",disabled:a=!1,item:n,isSelected:s,isSelectable:c=!0,isSingle:l,onSelect:d,search:u="",selected:m,useExpandedPanelId:g,...p})=>{const[h,b]=g,w=null!=e&&void 0!==n.count&&null!==n.count,_=!!n.breadcrumbs?.length,x=!!n.children?.length,v=K(n,h),j=(0,M.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":_,"has-children":x,"has-count":w,"is-expanded":v,"is-radio-button":l}),k=p.name||`search-list-item-${r}`,S=`${k}-${n.id}`,I=(0,i.useCallback)(()=>{v||"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)},[v,n.id,n.parent,b]),C=(s||!c)&&oe(n,m);return x?(0,f.jsx)("div",{className:j,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:S,name:k,value:n.value,onChange:()=>{d(n)(),v||b(n.id)},onClick:e=>e.stopPropagation(),checked:s,disabled:a,className:"woocommerce-search-list__item-input",...p}),(0,f.jsx)(ae,{item:n,search:u}),w?(0,f.jsx)(re,{label:e||n.count}):null]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(y.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:C,disabled:a,indeterminate:!C&&(s||te(n,m)),label:Z((0,J.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&&s||!c&&o?d(Y(m,t,"id"))():(d(function(e,t){const o=Y(t,e,"id");return[...e,...o]}(m,t))(),v||b(n.id))},__nextHasNoMarginBottom:!0}),w?(0,f.jsx)(re,{label:e||n.count}):null]})}):(0,f.jsxs)("div",{className:j,onClick:a?void 0:d(n),children:[l?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("input",{...p,type:"radio",id:S,name:k,value:n.value,onChange:d(n),checked:s,disabled:a,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,f.jsx)("label",{htmlFor:S,children:(0,f.jsx)(ae,{item:n,search:u})})]}):(0,f.jsx)(y.CheckboxControl,{...p,id:S,name:k,className:"woocommerce-search-list__item-input",value:(0,J.decodeEntities)(n.value),label:Z((0,J.decodeEntities)(n.name),u),onChange:()=>{d(n)(),v||b(n.id)},checked:s,disabled:a,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),w?(0,f.jsx)(re,{label:e||n.count}):null]})},ne=ie;var se=o(13739);o(75022);const ce=({id:e,label:t,popoverContents:o,remove:a,screenReaderLabel:s,className:c=""})=>{const[l,d]=(0,i.useState)(!1),u=(0,n.useInstanceId)(ce);if(s=s||t,!t)return null;t=(0,J.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:s}),(0,f.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,f.jsxs)("span",{className:m,children:[o?(0,f.jsx)(y.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)(y.Popover,{onClose:()=>d(!1),children:o}),a&&(0,f.jsx)(y.Button,{className:"woocommerce-tag__remove",onClick:a(e),label:(0,j.sprintf)( // Translators: %s label. // Translators: %s label. (0,j.__)("Remove %s","woocommerce"),t),"aria-describedby":g,children:(0,f.jsx)(r.A,{icon:se.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:s,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),w=K(t,p),_=c?.[t.id],x="number"==typeof _&&h<_;return(0,f.jsxs)(i.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})}),w?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(ue,{...e,list:t.children,depth:a+1}),s&&x?(0,f.jsx)("li",{children:(0,f.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>s(),children:n||(0,j.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},me=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:a,onRemove:i})=>{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)(y.Button,{variant:"link",isDestructive:!0,onClick:()=>a([]),"aria-label":r.clear,children:(0,j.__)("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:i})},t))}):null]})},ge=({filteredList:e,search:t,onSelect:o,instanceId:a,useExpandedPanelId:i,...n})=>{const{messages:s,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,j.sprintf)(s.noResults,t):s.noItems})]}):(0,f.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,f.jsx)(ue,{useExpandedPanelId:i,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:s,list:c,messages:l=Q,onChange:d,onSearch:u,selected:m,type:g="text",debouncedSpeak:p}=e,[h,b]=(0,i.useState)(""),w=(0,i.useState)(null),_=(0,n.useInstanceId)(pe),x=(0,i.useMemo)(()=>({...Q,...l}),[l]),v=(0,i.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,i.useEffect)(()=>{p&&p(x.updated)},[p,x]),(0,i.useEffect)(()=>{"function"==typeof u&&u(h)},[h,u]);const k=(0,i.useCallback)(e=>()=>{s&&d([]);const t=m.findIndex(({id:t})=>t===e);d([...m.slice(0,t),...m.slice(t+1)])},[s,m,d]),S=(0,i.useCallback)(e=>()=>{Array.isArray(e)?d(e):-1===m.findIndex(({id:t})=>t===e.id)?d(s?[e]:[...m,e]):k(e.id)()},[s,k,d,m]),I=(0,i.useCallback)(e=>{const[t]=m.filter(t=>!e.find(e=>t.id===e.id));k(t.id)()},[k,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:k,messages:x}),(0,f.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===g?(0,f.jsx)(y.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:x.search,type:"search",value:h,onChange:e=>b(e)}):(0,f.jsx)(y.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:a,label:x.search,onChange:I,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:a?[(0,j.__)("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)(y.Spinner,{})}):(0,f.jsx)(ge,{...e,search:h,filteredList:v,messages:x,onSelect:S,instanceId:_,useExpandedPanelId:w})]})},he=((0,y.withSpokenMessages)(pe),e=>({selected:t,...o})=>{const[r,a]=(0,i.useState)(!0),[n,c]=(0,i.useState)(null),[d,u]=(0,i.useState)([]),m=async e=>{const t=await x(e);c(t),a(!1)},g=(0,i.useRef)(t);return(0,i.useEffect)(()=>{var e;(e={selected:g.current},l()({path:(0,s.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:i="any",selected:n,isCompact:s=!1,isSingle:c=!1,showReviewCount:l})=>{const d={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,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,i=l?(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"),a,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"),a,t.details?.count||0),n=l?(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,f.jsx)(ie,{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":i})},messages:d,isCompact:s,isHierarchical:!0,isSingle:c}),!!a&&(0,f.jsx)("div",{hidden:n.length<2,children:(0,f.jsx)(y.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:a,options:[{label:(0,j.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,j.__)("All selected categories","woocommerce"),value:"all"}]})})]})});var we=o(64347);var _e=o(20923),xe=o.n(_e);const fe=(0,n.createHigherOrderComponent)(e=>{class t extends i.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 i=this.getExpandedProduct();if(!i)return;if(!e&&r?.[i])return;if(r?.[i]&&a?.[i]&&r[i].length>=a[i])return;const n=t.find(e=>e.id===i);if(!n?.variations||0===n.variations.length)return void this.setState({variations:{...this.state.variations,[i]:null},loading:!1,error:null});this.setState({loading:!0});const c=this.state.variations[i]||[];((e,t={})=>l()({path:(0,s.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}})))(i,{offset:e}).then(({variations:e,total:t})=>{const o=e.map(e=>({...e,parent:i}));this.setState({variations:{...this.state.variations,[i]:[...c,...o]},totalVariations:{...this.state.totalVariations,[i]:t},loading:!1,error:null})}).catch(async e=>{const t=await x(e);this.setState({variations:{...this.state.variations,[i]:null},totalVariations:{...this.state.totalVariations,[i]: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:i,totalVariations:n}=this.state,s=this.getExpandedProduct(),c=s&&i[s]?.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:i,variationsLoading:a})}}return t},"withProductVariations");var ve=o(51609);const ye=({className:e,item:t,isSelected:o,isLoading:r,onSelect:a,disabled:i,...n})=>(0,f.jsxs)(f.Fragment,{children:[(0,ve.createElement)(ie,{...n,key:t.id,...e&&{className:e},isSelected:o,item:t,onSelect:a,...i&&{disabled:i}}),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)(y.Spinner,{})},"loading")]});o(20415);const je={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")},ke=(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]})})((Ee=fe((0,n.withInstanceId)(e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:a=!1,isLoading:i,onChange:n,onLoadMoreVariations:s,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 w=[...d,...h&&t&&h[t]?h[t]:[]].map(I);return(0,f.jsx)(pe,{className:"woocommerce-products",list:w,isCompact:a,isLoading:i,isSingle:!0,selected:w.filter(({id:e})=>g.includes(Number(e))),onChange:n,loadMoreChildrenText:p?(0,j.__)("Load more variations","woocommerce"):void 0,onLoadMoreChildren:p?s:void 0,totalChildren:p?c:void 0,renderItem:m||(p?e=>{const{item:t,search:o,depth:a=0,isSelected:n,onSelect:s,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)(ye,{...e,className:(0,M.A)(p,{"is-selected":n}),isSelected:n,item:t,onSelect:()=>()=>{s(t)(),m||d(t.id)},isLoading:i||b,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 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)(ie,{...h,className:p,name:`variations-${r}`})}:void 0),onSearch:l,messages:{...je,...e.messages},isHierarchical:!0})})),({selected:e,...t})=>{const[o,r]=(0,i.useState)(!0),[a,n]=(0,i.useState)(null),[s,c]=(0,i.useState)([]),l=m.productCount>100,d=async e=>{const t=await x(e);n(t),r(!1)},u=(0,i.useRef)(e);(0,i.useEffect)(()=>{_({selected:u.current}).then(e=>{c(e),r(!1)}).catch(d)},[u]);const g=(0,we.YQ)(t=>{_({selected:e,search:t}).then(e=>{c(e),r(!1)}).catch(d)},400),p=(0,i.useCallback)(e=>{r(!0),g(e)},[r,g]);return(0,f.jsx)(Ee,{...t,selected:e,error:a,products:s,isLoading:o,onSearch:l?p:null})})),Se=window.wp.coreData,Ie=window.wc.wcEntities,Ce=window.wc.wcBlocksSharedContext,Pe=({className:e="",onResize:t,...o})=>{const[r,a]=(0,i.useState)(!1),n=(0,M.A)(e,{"is-resizing":r}),s=(0,we.dh)((e,o,i,n)=>{r||a(!0),t?.(e,o,i,n)},50,{leading:!0});return(0,f.jsx)(y.ResizableBox,{className:n,enable:{bottom:!0},onResize:s,onResizeStop:(...e)=>{t?.(...e),a(!1)},...o})};var Ee;function Ae({className:e,template:t,attributes:o}){const r=o.style?.spacing?.blockGap,a="object"==typeof r?r?.top:r,i=null!=a&&""!==a,n=(0,k.useInnerBlocksProps)({className:(0,M.A)(e,{"has-custom-gap":i}),style:{"--wc-featured-item-block-gap":i?(0,k.getSpacingPresetCssVar)(String(a)):void 0}},{template:t,templateLock:!1,allowedBlocks:o.allowedBlocks,orientation:"vertical"});return(0,f.jsx)("div",{...n})}const Ne={icon:a.A,label:(0,j.__)("Featured Product","woocommerce")},Re={...Ne,cropLabel:(0,j.__)("Edit product image","woocommerce"),editLabel:(0,j.__)("Edit selected product","woocommerce")},Le={...Ne,emptyMessage:(0,j.__)("No product is selected.","woocommerce"),noSelectionButtonLabel:(0,j.__)("Select a product","woocommerce")},Te={...Ne,description:(0,j.__)("Highlight a product or variation.","woocommerce"),editLabel:(0,j.__)("Showing Featured Product block preview.","woocommerce")},Fe=(0,n.compose)([v,y.withSpokenMessages,e=>t=>{const[o,r]=(0,i.useState)(!1),{category:a,clientId:n,editMode:s,product:c}=t,l=a||c,d=l?.link||l?.permalink,u=(0,W.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,i.useMemo)(()=>p?.attributes||{},[p]),{url:w}=b,{updateBlockAttributes:_}=(0,W.useDispatch)("core/block-editor");return(0,i.useEffect)(()=>{o&&h&&!s&&d&&w&&d!==w&&(_(h,{url:d}),r(!1))},[h,o,s,d,_,w]),(0,f.jsx)(e,{...t,triggerUrlUpdate:()=>r(!0)})},e=>t=>{const[o,r]=(0,i.useState)(!1),{isSelected:a}=t;return(0,i.useEffect)(()=>{r(!1)},[a]),(0,f.jsx)(e,{...t,useEditingImage:[o,r]})},(({description:e,editLabel:t,icon:o,label:r})=>a=>n=>{const{attributes:s,effectiveCategoryId:c,debouncedSpeak:l,name:d,setAttributes:u,triggerUrlUpdate:m=()=>{},error:g,isLoading:p}=n,h=z(d),[b,w]=(0,i.useState)(),_=d===A&&s.productId||d===E&&(s.categoryId||c),x=!(d===E&&!s.categoryId&&c),[v,S]=(0,i.useState)(!_),I=d===A?s?.productId:s?.categoryId||c,{status:C,isDeleted:P,isLoading:N}=(({itemId:e,itemType:t})=>{const{product:o,isResolutionFinished:r}=(0,Ie.useProduct)(t===A?e:void 0);return(0,W.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(Se.store),r=["taxonomy","product_cat",{include:[e]}],i=t(...r),n=o("getEntityRecords",r),s=!i?.length;return{status:s?"deleted":null,isDeleted:s,isLoading:!n}}return{status:null,isDeleted:!0,isLoading:!1}},[e,t,o,r])})({itemId:I,itemType:d}),R=p||N,L=(0,W.useSelect)(e=>{const{getSettings:t}=e(k.store);return Boolean(t()?.isPreviewMode??!1)},[]);return(0,i.useEffect)(()=>{if(!L&&x&&!R){const e=d===A&&"publish"!==C||P;e&&S(e)}},[C,P,d,R,L,x]),v&&x?(0,f.jsx)("div",{...n.blockProps,children:(0,f.jsxs)(y.Placeholder,{icon:(0,f.jsx)(y.Icon,{icon:o}),label:r,className:h,children:[(0,f.jsxs)(y.__experimentalHStack,{alignment:"center",children:[P?(0,f.jsx)(y.Icon,{icon:q.A,className:"wc-blocks-featured-items__orange-info-icon"}):(0,f.jsx)(y.Icon,{icon:q.A}),(0,f.jsx)(y.__experimentalText,{children:P?U(d):e})]}),(0,f.jsxs)("div",{className:`${h}__selection`,children:[d===E&&(0,f.jsx)(be,{selected:b?.categoryId?[b.categoryId]:[],onChange:(e=[])=>{const t=e[0]?e[0].id:0;w({categoryId:t,mediaId:0,mediaSrc:""}),m()},isSingle:!0}),d===A&&(0,f.jsx)(ke,{selected:b?.productId?[b.productId]:[],showVariations:!0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;w({productId:t,mediaId:0,mediaSrc:""}),m()}}),(0,f.jsx)(y.Button,{variant:"primary",onClick:()=>{b&&(u(b),S(!1),l(t))},children:(0,j.__)("Done","woocommerce")})]})]})}):(0,f.jsx)(a,{...n,canEditItem:x,isLoading:R,error:R?null:g,useEditMode:[v,S]})})(Te),(({emptyMessage:e,icon:t,label:o,noSelectionButtonLabel:r})=>a=>s=>{const[c]=s.useEditingImage,[,l]=s.useEditMode,{attributes:u,canEditItem:m,category:g,isLoading:p,isSelected:h,name:b,product:w,setAttributes:_}=s,{mediaId:x,mediaSrc:v,isRepeated:S,imageFit:I}=u,C=g||w,[E,A]=(0,i.useState)({}),{backgroundImageSrc:R,isImageBgTransparent:T,originalImgDimension:F}=L({item:C,mediaId:x,mediaSrc:v,blockName:b}),B=(0,i.useRef)(null),O=(0,n.useMergeRefs)([s.blockProps.ref,B]),[D,$]=(0,i.useState)({height:0,width:0});(0,i.useEffect)(()=>{const e=new ResizeObserver(e=>{$({height:e[0].contentRect.height,width:e[0].contentRect.width})});if(!1===p){const t=B.current;if(!t)return;e.observe(t)}return()=>e.disconnect()},[p]);const V=(0,i.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:T,originalImgDimension:F,parentContainerDimension:D,isRepeated:S,imageFit:I}),[D,F,S,I,T]),G=z(b),U=(0,i.useCallback)((e,t,o)=>{_({minHeight:parseInt(o.style.height,10)})},[_]),W=()=>{if(w){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,j.__)("Shop now","woocommerce"),url:e.permalink}]]]])(w);return(0,f.jsx)(k.BlockContextProvider,{value:{postId:w.id,postType:"product"},children:(0,f.jsx)(Ce.ProductDataContextProvider,{product:w,isLoading:p,children:(0,f.jsx)(Ae,{className:`${G}__inner-blocks`,template:e,attributes:u})})})}return(0,f.jsx)(k.BlockContextProvider,{value:{termId:"preview"===u.categoryId?void 0:g.id,termTaxonomy:"product_cat",taxonomy:"product_cat"},children:(0,f.jsx)(Ae,{className:`${G}__inner-blocks`,template:N(g,!u.categoryId),attributes:u})})};return C||!p||m?c?(0,f.jsx)("div",{...s.blockProps,children:(0,f.jsx)(a,{...s,backgroundImageSize:E,backgroundColorVisibilityStatus:V})}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(a,{...s,backgroundImageSize:E,backgroundColorVisibilityStatus:V}),C?(()=>{const{contentAlign:e,dimRatio:t,focalPoint:o,hasParallax:r,minHeight:a,overlayColor:i,overlayGradient:n,style:c}=u,l=(0,M.A)(G,{"is-selected":h&&"preview"!==u.categoryId&&"preview"!==u.productId,"is-loading":!C&&p,"is-not-found":!C&&!p,"has-background-dim":0!==t,"is-repeated":S},0===(m=t)||50===m?null:"has-background-dim-"+10*Math.round(m/10),"center"!==e&&`has-${e}-content`,s.blockProps.className,u.verticalAlignment&&`is-vertically-aligned-${u.verticalAlignment}`);var m;const g=!!c?.dimensions?.aspectRatio,b={"--wc-featured-item-min-height":`${(0,d.getSetting)("defaultHeight",500)}px`,minHeight:g?void 0:a,...s.blockProps.style},w=!S&&!r,_=function({focalPoint:e,imageFit:t,isImgElement:o,isRepeated:r,url:a}){let i={};var n;return i=o?{...i,...(n=e,n?{objectPosition:H(n)}:{}),objectFit:t}:{...i,...a&&{backgroundImage:`url(${a})`},backgroundPosition:H(e),...!r&&{backgroundRepeat:"no-repeat",backgroundSize:"cover"===t?t:"auto"}},i}({focalPoint:o,imageFit:I,isImgElement:w,isRepeated:S,url:R}),x={background:n,backgroundColor:i};return(0,f.jsx)(f.Fragment,{children:(0,f.jsxs)("div",{...s.blockProps,className:l,ref:O,style:b,children:[(0,f.jsx)(Pe,{enable:{bottom:!0},onResize:U,showHandle:h&&!g&&!c?.dimensions?.minHeight,style:{minHeight:g?void 0:a}}),(0,f.jsxs)("div",{className:`${G}__wrapper`,children:[(0,f.jsx)("div",{className:"background-dim__overlay",style:x}),R&&(w?(0,f.jsx)("img",{alt:C.name,className:`${G}__background-image`,src:R,style:_,onLoad:e=>{A({height:e.currentTarget?.naturalHeight,width:e.currentTarget?.naturalWidth})}}):(0,f.jsx)("div",{className:(0,M.A)(`${G}__background-image`,{"has-parallax":r}),style:_})),W()]})]})})})():(0,f.jsx)("div",{...s.blockProps,children:(0,f.jsx)(y.Placeholder,{className:G,icon:(0,f.jsx)(y.Icon,{icon:t}),label:o,children:p?(0,f.jsx)(y.Spinner,{}):m?(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:()=>l(!0),children:r})]}):(0,f.jsx)("p",{children:(0,j.__)("No product category is available.","woocommerce")})})})]}):null})(Le),e=>t=>{const{error:o,isLoading:r,name:a}=t,i=z(a),n=a===E?t.getCategory:t.getProduct;return o?(0,f.jsx)(G,{className:`${i}-error`,error:o,isLoading:r,onRetry:n}):(0,f.jsx)(e,{...t})},e=>t=>{const[o,r]=t.useEditingImage,a=(0,i.useRef)(null),{attributes:n,backgroundImageSize:s,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)(F,{align:n.align,backgroundImageId:g,backgroundImageSize:s,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:i,setAttributes:n}=t,{alt:s,dimRatio:c,focalPoint:l,hasParallax:d,isRepeated:u,imageFit:m,mediaId:g,mediaSrc:p,overlayColor:h,overlayGradient:b,backgroundColor:w,style:_}=o,x=i===A?t.product:t.category,{setGradient:v}=(0,k.__experimentalUseGradient)({gradientAttribute:"overlayGradient",customGradientAttribute:"overlayGradient"}),{backgroundImageSrc:y}=L({item:x,mediaId:g,mediaSrc:p,blockName:i});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(B,{alt:s,backgroundImageSrc:y,dimRatio:c,focalPoint:l,hasParallax:d,isRepeated:u,imageFit:m,overlayColor:h,overlayGradient:b,setAttributes:n,setGradient:v,backgroundColorVisibilityStatus:r,backgroundColor:w||_?.color?.background,clientId:a}),(0,f.jsx)(e,{...t})]})},(({cropLabel:e,editLabel:t})=>o=>r=>{const[a,i]=r.useEditingImage,[n,s]=r.useEditMode,{attributes:c,category:l,name:d,product:u,setAttributes:m}=r,{contentAlign:g,verticalAlignment:p,mediaId:h,mediaSrc:b}=c,w=l||u,{backgroundImageId:_,backgroundImageSrc:x}=L({item:w,mediaId:h,mediaSrc:b,blockName:d});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(T,{canEditItem:r.canEditItem,backgroundImageId:_,backgroundImageSrc:x,contentAlign:g,verticalAlignment:p,cropLabel:e,editLabel:t,editMode:n,isEditingImage:a,mediaSrc:b,setAttributes:m,setIsEditingImage:i,setEditMode:s}),(0,f.jsx)(o,{...r})]})})(Re)])(()=>(0,f.jsx)(f.Fragment,{})),Be=window.wp.blocks;function Oe(e){return function(t){const o=(0,k.useBlockProps)();return(0,f.jsx)(e,{...t,blockProps:o})}}const Me={attributes:{productId:"preview",previewProduct:{id:1,name:"WordPress Pennant",variation:"",permalink:"https://example.org",sku:"wp-pennant",short_description:(0,j.__)("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,j.__)("Add to cart","woocommerce"),description:(0,j.__)("Add to cart","woocommerce")},has_options:!1,is_purchasable:!0,is_in_stock:!0,on_sale:!0}}},De=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,"gradients":true,"link":true,"enableContrastChecker":false},"spacing":{"padding":true,"margin":["top","bottom"],"blockGap":true,"__experimentalDefaultControls":{"padding":true,"blockGap":true}},"__experimentalBorder":{"color":true,"radius":true,"style":true,"width":true,"__experimentalDefaultControls":{"color":true,"radius":true,"style":true,"width":true}},"multiple":true,"anchor":true,"shadow":true,"typography":{"__experimentalTextTransform":true,"__experimentalTextDecoration":true},"dimensions":{"aspectRatio":true,"minHeight":true},"allowedBlocks":true},"attributes":{"verticalAlignment":{"type":"string","enum":["top","center","bottom"]},"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"},"linkText":{"type":"string","default":"Shop now"},"overlayColor":{"type":"string","default":"#000000"},"overlayGradient":{"type":"string"},"productId":{"type":"number"},"previewProduct":{"type":"object","default":null},"anchor":{"type":"string"}},"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:{alt:"",contentAlign:"center",dimRatio:50,hasParallax:!1,isRepeated:!1,height:(0,d.getSetting)("defaultHeight",500),mediaSrc:"",overlayColor:"#000000",showDesc:!0}};(0,Be.registerBlockType)(o,{example:{...a,...t},edit:Oe(e),save:()=>(0,f.jsx)(k.InnerBlocks.Content,{}),...r})}(Fe,Me,De,{deprecated:[{attributes:{...De.attributes,showDesc:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0}},save:()=>(0,f.jsx)(k.InnerBlocks.Content,{}),isEligible:e=>"boolean"==typeof e.editMode,migrate:(e,t)=>{const{editMode:o,showDesc:r,showPrice:a,...i}=e;return!1!==a&&t.unshift((0,Be.createBlock)("woocommerce/product-price",{style:{spacing:{padding:{bottom:"16px"}}},textAlign:"center"})),!1!==r&&t.unshift((0,Be.createBlock)("woocommerce/product-summary",{showDescriptionIfEmpty:!0,summaryLength:80,style:{typography:{textAlign:"center"}}})),t.unshift((0,Be.createBlock)("core/post-title",{level:2,isLink:!1,textAlign:"center",__woocommerceNamespace:"woocommerce/product-collection/product-title"})),[i,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 i(e){var t=a[e];if(void 0!==t)return t.exports;var o=a[e]={exports:{}};return r[e](o,o.exports,i),o.exports}i.m=r,e=[],i.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],s=!0,c=0;c<o.length;c++)(!1&a||n>=a)&&Object.keys(i.O).every(e=>i.O[e](o[c]))?o.splice(c--,1):(s=!1,a<n&&(n=a));if(s){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]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},o=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var a=Object.create(null);i.r(a);var n={};t=t||[null,o({}),o([]),o(o)];for(var s=2&r&&e;"object"==typeof s&&!~t.indexOf(s);s=o(s))Object.getOwnPropertyNames(s).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,i.d(a,n),a},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=8931,(()=>{var e={8931:0};i.O.j=t=>0===e[t];var t=(t,o)=>{var r,a,[n,s,c]=o,l=0;if(n.some(t=>0!==e[t])){for(r in s)i.o(s,r)&&(i.m[r]=s[r]);if(c)var d=c(i)}for(t&&t(o);l<n.length;l++)a=n[l],i.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return i.O(d)},o=globalThis.webpackChunkwebpackWcBlocksMainJsonp=globalThis.webpackChunkwebpackWcBlocksMainJsonp||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var n=i.O(void 0,[94],()=>i(20759));n=i.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["featured-product"]=n})();
Save File
Cancel