geno/wp-content/plugins/woocommerce/packages/woocommerce-blocks/build/featured-product.js

14 lines
43 KiB
JavaScript
Raw Normal View History

2024-02-01 17:24:18 +05:30
(()=>{var e,t={4748:(e,t,r)=>{"use strict";r.r(t);var o=r(9196),n=r(1984),a=r(4734),l=(r(1887),r(2611),r(4942)),i=r(9307),s=r(4333);const c=window.wp.url,d=window.wp.apiFetch;var u=r.n(d);const m=window.wc.wcSettings;var g,p,h,b,v,_,w,E,k,f;const y=(0,m.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),S=y.pluginUrl+"images/",I=(y.pluginUrl,y.buildPhase),C=(null===(g=m.STORE_PAGES.shop)||void 0===g||g.permalink,null===(p=m.STORE_PAGES.checkout)||void 0===p||p.id,null===(h=m.STORE_PAGES.checkout)||void 0===h||h.permalink,null===(b=m.STORE_PAGES.privacy)||void 0===b||b.permalink,null===(v=m.STORE_PAGES.privacy)||void 0===v||v.title,null===(_=m.STORE_PAGES.terms)||void 0===_||_.permalink,null===(w=m.STORE_PAGES.terms)||void 0===w||w.title,null===(E=m.STORE_PAGES.cart)||void 0===E||E.id,null===(k=m.STORE_PAGES.cart)||void 0===k||k.permalink,null!==(f=m.STORE_PAGES.myaccount)&&void 0!==f&&f.permalink?m.STORE_PAGES.myaccount.permalink:(0,m.getSetting)("wpLoginUrl","/wp-login.php"),(0,m.getSetting)("localPickupEnabled",!1),(0,m.getSetting)("countries",{})),x=(0,m.getSetting)("countryData",{}),P=(Object.fromEntries(Object.keys(x).filter((e=>!0===x[e].allowBilling)).map((e=>[e,C[e]||""]))),Object.fromEntries(Object.keys(x).filter((e=>!0===x[e].allowBilling)).map((e=>[e,x[e].states||[]]))),Object.fromEntries(Object.keys(x).filter((e=>!0===x[e].allowShipping)).map((e=>[e,C[e]||""]))),Object.fromEntries(Object.keys(x).filter((e=>!0===x[e].allowShipping)).map((e=>[e,x[e].states||[]]))),Object.fromEntries(Object.keys(x).map((e=>[e,x[e].locale||[]]))),window.wp.blocks),N=()=>I>1,R=({selected:e=[],search:t="",queryArgs:r={}})=>{const o=(({selected:e=[],search:t="",queryArgs:r={}})=>{const o=y.productCount>100,n={per_page:o?100:0,catalog_visibility:"any",search:t,orderby:"title",order:"asc"},a=[(0,c.addQueryArgs)("/wc/store/v1/products",{...n,...r})];return o&&e.length&&a.push((0,c.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:0})),a})({selected:e,search:t,queryArgs:r});return Promise.all(o.map((e=>u()({path:e})))).then((e=>{const t=((e,t)=>{const r=new Map;return e.filter((e=>{const o=t(e);return!r.has(o)&&(r.set(o,e),!0)}))})(e.flat(),(e=>e.id));return t.map((e=>({...e,parent:0})))})).catch((e=>{throw e}))},A=async e=>{if(!("json"in e))return{message:e.message,type:e.type||"general"};try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}},L=(0,s.createHigherOrderComponent)((e=>class extends i.Component{constructor(...e){super(...e),(0,l.Z)(this,"state",{error:null,loading:!1,product:"preview"===this.props.attributes.productId?this.props.attributes.previewProduct:null}),(0,l.Z)(this,"loadProduct",(()=>{const{productId:e}=this.props.attributes;"preview"!==e&&(e?(this.setState({loading:!0}),(e=>u()({path:`/wc/store/v1/products/${e}`}))(e).then((e=>{this.setState({product:e,loading:!1,error:null})})).catch((async e=>{const t=await A(e);this.setState({product:null,loading:!1,error:t})}))):this.setState({product:null,loading:!1,error:null}))}))}componentDidMount(){this.loadProduct()}componentDidUpdate(e){e.attributes.productId!==this.props.attributes.productId&&this.loadProduct()}render(){const{error:t,loading:r,product:n}=this.state;return(0,o.createElement)(e,{...this.props,error:t,getProduct:this.loadProduct,isLoading:r,product:n})}}),"withProduct"),$=window.wp.components;var T=r(5736);const O=window.wp.blockEditor;var F=r(1525);const M=e=>{const{id:t,name:r,parent:o}=e;return{id:t,name:r,parent:o,breadcrumbs:[],children:[],details:e,value:e.slug}},j="woocommerce/featured-category",B="woocommerce/featured-product",G=e=>"number"==typeof e;function H(e){return!!e&&G(e.id)&&"string"==typeof e.src}function D({blockName:e,item:t,mediaId:r,mediaSrc:o}){const[n,a]=(0,i.useState)(0),[l,s]=(0,i.useState)("");return(0,i.useEffect)((()=>{var o,n;a(r||(e===B?(n=t)&&n.images&&n.images.length&&n.images[0].id||0:(o=t)&&H(o.image)?o.image.id:0))}),[e,t,r]),(0,i.useEffect)(
/* translators: "Cover" is a verb that indicates an image covering the entire container. */,{label:(0,T.__)("Cover","woocommerce"),value:"cover"})),(0,o.createElement)($.FocalPointPicker,{label:(0,T.__)("Focal Point Picker","woocommerce"),url:t,value:a,onChange:e=>u({focalPoint:e})}),h&&(0,o.createElement)($.TextareaControl,{label:(0,T.__)("Alt text (alternative text)","woocommerce"),value:e,onChange:e=>{u({alt:e})},help:(0,o.createElement)(o.Fragment,null,(0,o.createElement)($.ExternalLink,{href:"https://www.w3.org/WAI/tutorials/images/decision-tree"},(0,T.__)("Describe the purpose of the image","woocommerce")))})),(0,o.createElement)(O.__experimentalPanelColorGradientSettings,{__experimentalHasMultipleOrigins:!0,__experimentalIsRenderedInSidebar:!0,title:(0,T.__)("Overlay","woocommerce"),initialOpen:!0,settings:[{colorValue:c,gradientValue:d,onColorChange:e=>u({overlayColor:e}),onGradientChange:e=>{m(e),u({overlayGradient:e})},label:(0,T.__)("Color","woocommerce")}]},(0,o.createElement)($.RangeControl,{label:(0,T.__)("Opacity","woocommerce"),value:n,onChange:e=>u({dimRatio:e}),min:0,max:100,step:10,required:!0}))))};var W=r(7329),U=r(4184),q=r.n(U);const J=window.wp.escapeHtml,Q=({error:e})=>(0,o.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,o.createElement)("span",null,(0,T.__)("The following error was returned","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,J.escapeHTML)(e))):"api"===t?(0,o.createElement)("span",null,(0,T.__)("The following error was returned from the API","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,J.escapeHTML)(e))):e:(0,T.__)("An error has prevented the block from being updated.","woocommerce"))(e));r(2513);const Y=({className:e="",error:t,isLoading:r=!1,onRetry:a})=>(0,o.createElement)($.Placeholder,{icon:(0,o.createElement)(n.Z,{icon:W.Z}),label:(0,T.__)("Sorry, an error occurred","woocommerce"),className:q()("wc-block-api-error",e)},(0,o.createElement)(Q,{error:t}),a&&(0,o.createElement)(o.Fragment,null,r?(0,o.createElement)($.Spinner,null):(0,o.createElement)($.Button,{isSecondary:!0,onClick:a},(0,T.__)("Retry","woocommerce"))));function K(e){return e?`${Math.round(100*e.x)}% ${Math.round(100*e.y)}%`:""}function X(e){return`wc-block-${e.split("/")[1]}`}function ee(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const te=window.wp.htmlEntities,re={clear:(0,T.__)("Clear all selected items","woocommerce"),noItems:(0,T.__)("No items found.","woocommerce"),
/* Translators: %s search term */
noResults:(0,T.__)("No results for %s","woocommerce"),search:(0,T.__)("Search for items","woocommerce"),selected:e=>(0,T.sprintf)(/* translators: Number of items selected from list. */
(0,T._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,T.__)("Search results updated.","woocommerce")},oe=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const n=["0"],a=(e={})=>e.parent?[...a(o[e.parent]),e.name]:e.name?[e.name]:[],l=e=>e.map((e=>{const t=r[e.id];return n.push(""+e.id),{...e,breadcrumbs:a(o[e.parent]),children:t&&t.length?l(t):[]}})),i=l(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{n.includes(e)||i.push(...l(t||[]))})),i},ne=(e,t)=>{if(!t)return e;const r=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(r).map(((e,t)=>r.test(e)?(0,o.createElement)("strong",{key:t},e):(0,o.createElement)(i.Fragment,{key:t},e)))},ae=({label:e})=>(0,o.createElement)("span",{className:"woocommerce-search-list__item-count"},e),le=e=>{const{item:t,search:r}=e,n=t.breadcrumbs&&t.breadcrumbs.length;return(0,o.createElement)("span",{className:"woocommerce-search-list__item-label"},n?(0,o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(a=t.breadcrumbs).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,o.createElement)("span",{className:"woocommerce-search-list__item-name"},ne((0,te.decodeEntities)(t.name),r)));var a},ie=({countLabel:e,className:t,depth:r=0,controlId:n="",item:a,isSelected:l,isSingle:s,onSelect:c,search:d="",selected:u,useExpandedPanelId:m,...g})=>{var p,h;const[b,v]=m,_=null!=e&&void 0!==a.count&&null!==a.count,w=!(null===(p=a.breadcrumbs)||void 0===p||!p.length),E=!(null===(h=a.children)||void 0===h||!h.length),k=b===a.id,f=q()(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":w,"has-children":E,"has-count":_,"is-expanded":k,"is-radio-button":s}),y=g.name||`search-list-item-${n}`,S=`${y}-${a.id}`,I=(0,i.useCallback)((()=>{v(k?-1:Number(a.id))}),[k,a.id,v]);return E?(0,o.createElement)("div",{className:f,onClick:I,onKeyDown:e=>"Enter"===e.key||" "===e.key?I():null,role:"treeitem",tabIndex:0},s?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{type:"radio",id:S,name:y,value:a.value,onChange:c(a),onClick:e=>e.stopPropagation(),checked:l,className:"woocommerce-search-list__item-input",...g}),(0,o.createElement)(le,{item:a,search:d}),_?(0,o.createElement)(ae,{label:e||a.count}):null):(0,o.createElement)(o.Fragment,null,(0,o.createElement)($.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:l,...!l&&a.children.some((e=>u.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:ne((0,te.decodeEntities)(a.name),d),onChange:()=>{l?c(ee(u,a.children,"id"))():c(function(e,t,r){const o=ee(t,e,"id");return[...e,...o]}(u,a.children))()},onClick:e=>e.stopPropagation()}),_?(0,o.createElement)(ae,{label:e||a.count}):null)):(0,o.createElement)("label",{htmlFor:S,className:f},s?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{...g,type:"radio",id:S,name:y,value:a.value,onChange:c(a),checked:l,className:"woocommerce-search-list__item-input"}),(0,o.createElement)(le,{item:a,search:d})):(0,o.createElement)($.CheckboxControl,{...g,id:S,name:y,className:"woocommerce-search-list__item-input",value:(0,te.decodeEntities)(a.value),label:ne((0,te.decodeEntities)(a.name),d),onChange:c(a),checked:l}),_?(0,o.createElement)(ae,{label:e||a.count}):null)},se=ie;var ce=r(5430),de=r(906);r(5932);const ue=({id:e,label:t,popoverContents:r,remove:a,screenReaderLabel:l,className:c=""})=>{const[d,u]=(0,i.useState)(!1),m=(0,s.useInstanceId)(ue);if(l=l||t,!t)return null;t=(0,te.decodeEntities)(t);const g=q()("woocommerce-tag",c,{"has-remove":!!a}),p=`woocommerce-tag__label-${m}`,h=(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"screen-reader-text"},l),(0,o.createElement)("span",{"aria-hidden":"true"},t));return(0,o.createElement)("span",{className:g},r?(0,o.createElement)($.Button,{className:"woocommerce-tag__text",id:p,onClick:()=>u(!0)},h):(0,o.create
// Translators: %s label.
(0,T.__)("Remove %s","woocommerce"),t),"aria-describedby":p},(0,o.createElement)(n.Z,{icon:de.Z,size:20,className:"clear-icon",role:"img"})))},me=ue;r(8462);const ge=e=>(0,o.createElement)(se,{...e}),pe=e=>{const{list:t,selected:r,renderItem:n,depth:a=0,onSelect:l,instanceId:s,isSingle:c,search:d,useExpandedPanelId:u}=e,[m]=u;return t?(0,o.createElement)(i.Fragment,null,t.map((t=>{var g,p;const h=null!==(g=t.children)&&void 0!==g&&g.length&&!c?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),b=(null===(p=t.children)||void 0===p?void 0:p.length)&&m===t.id;return(0,o.createElement)(i.Fragment,{key:t.id},(0,o.createElement)("li",null,n({item:t,isSelected:h,onSelect:l,isSingle:c,selected:r,search:d,depth:a,useExpandedPanelId:u,controlId:s})),b?(0,o.createElement)(pe,{...e,list:t.children,depth:a+1}):null)}))):null},he=({isLoading:e,isSingle:t,selected:r,messages:n,onChange:a,onRemove:l})=>{if(e||t||!r)return null;const i=r.length;return(0,o.createElement)("div",{className:"woocommerce-search-list__selected"},(0,o.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,o.createElement)("strong",null,n.selected(i)),i>0?(0,o.createElement)($.Button,{isLink:!0,isDestructive:!0,onClick:()=>a([]),"aria-label":n.clear},(0,T.__)("Clear all","woocommerce")):null),i>0?(0,o.createElement)("ul",null,r.map(((e,t)=>(0,o.createElement)("li",{key:t},(0,o.createElement)(me,{label:e.name,id:e.id,remove:l}))))):null)},be=({filteredList:e,search:t,onSelect:r,instanceId:a,useExpandedPanelId:l,...i})=>{const{messages:s,renderItem:c,selected:d,isSingle:u}=i,m=c||ge;return 0===e.length?(0,o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,o.createElement)(n.Z,{icon:ce.Z,role:"img"})),(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,T.sprintf)(s.noResults,t):s.noItems)):(0,o.createElement)("ul",{className:"woocommerce-search-list__list"},(0,o.createElement)(pe,{useExpandedPanelId:l,list:e,selected:d,renderItem:m,onSelect:r,instanceId:a,isSingle:u,search:t}))},ve=e=>{const{className:t="",isCompact:r,isHierarchical:n,isLoading:a,isSingle:l,list:c,messages:d=re,onChange:u,onSearch:m,selected:g,type:p="text",debouncedSpeak:h}=e,[b,v]=(0,i.useState)(""),_=(0,i.useState)(-1),w=(0,s.useInstanceId)(ve),E=(0,i.useMemo)((()=>({...re,...d})),[d]),k=(0,i.useMemo)((()=>((e,t,r)=>{if(!t)return r?oe(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),n=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?oe(n,e):n})(c,b,n)),[c,b,n]);(0,i.useEffect)((()=>{h&&h(E.updated)}),[h,E]),(0,i.useEffect)((()=>{"function"==typeof m&&m(b)}),[b,m]);const f=(0,i.useCallback)((e=>()=>{l&&u([]);const t=g.findIndex((({id:t})=>t===e));u([...g.slice(0,t),...g.slice(t+1)])}),[l,g,u]),y=(0,i.useCallback)((e=>()=>{Array.isArray(e)?u(e):-1===g.findIndex((({id:t})=>t===e.id))?u(l?[e]:[...g,e]):f(e.id)()}),[l,f,u,g]),S=(0,i.useCallback)((e=>{const[t]=g.filter((t=>!e.find((e=>t.id===e.id))));f(t.id)()}),[f,g]);return(0,o.createElement)("div",{className:q()("woocommerce-search-list",t,{"is-compact":r,"is-loading":a,"is-token":"token"===p})},"text"===p&&(0,o.createElement)(he,{...e,onRemove:f,messages:E}),(0,o.createElement)("div",{className:"woocommerce-search-list__search"},"text"===p?(0,o.createElement)($.TextControl,{label:E.search,type:"search",value:b,onChange:e=>v(e)}):(0,o.createElement)($.FormTokenField,{disabled:a,label:E.search,onChange:S,onInputChange:e=>v(e),suggestions:[],__experimentalValidateInput:()=>!1,value:a?[(0,T.__)("Loading…","woocommerce")]:g.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),a?(0,o.createElement)("div",{className:"woocommerce-search-list__list"},(0,o.createElement)($.Spinner,null)):(0,o.createElement)(be,{...e,search:b,filteredList:k,messages:E,onSelect:y,instanceId:w,useExpandedPanelId:_}))},_e=((0,$.withSpokenMessages)(ve),(0,s.createHigherOrderComponent)((e=>class extends i.Component{constructor(){super(...
(0,T._n)("%d category selected","%d categories selected",e,"woocommerce"),e),updated:(0,T.__)("Category search results updated.","woocommerce")};return t?(0,o.createElement)(Q,{error:t}):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(ve,{className:"woocommerce-product-categories",list:e,isLoading:r,selected:i.map((t=>e.find((e=>e.id===t)))).filter(Boolean),onChange:n,renderItem:e=>{const{item:t,search:r,depth:n=0}=e,a=t.breadcrumbs.length?`${t.breadcrumbs.join(", ")}, ${t.name}`:t.name,l=d?(0,T.sprintf)(/* translators: %1$s is the item name, %2$d is the count of reviews for the item. */
(0,T._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.review_count,"woocommerce"),a,t.review_count):(0,T.sprintf)(/* translators: %1$s is the item name, %2$d is the count of products for the item. */
(0,T._n)("%1$s, has %2$d product","%1$s, has %2$d products",t.count,"woocommerce"),a,t.count),i=d?(0,T.sprintf)(/* translators: %d is the count of reviews. */
(0,T._n)("%d review","%d reviews",t.review_count,"woocommerce"),t.review_count):(0,T.sprintf)(/* translators: %d is the count of products. */
(0,T._n)("%d product","%d products",t.count,"woocommerce"),t.count);return(0,o.createElement)(ie,{className:q()("woocommerce-product-categories__item","has-count",{"is-searching":r.length>0,"is-skip-level":0===n&&0!==t.parent}),...e,countLabel:i,"aria-label":l})},messages:u,isCompact:s,isHierarchical:!0,isSingle:c}),!!a&&(0,o.createElement)("div",{hidden:i.length<2},(0,o.createElement)($.SelectControl,{className:"woocommerce-product-categories__operator",label:(0,T.__)("Display products matching","woocommerce"),help:(0,T.__)("Pick at least two categories to use this setting.","woocommerce"),value:l,onChange:a,options:[{label:(0,T.__)("Any selected categories","woocommerce"),value:"any"},{label:(0,T.__)("All selected categories","woocommerce"),value:"all"}]})))};we.defaultProps={operator:"any",isCompact:!1,isSingle:!1};const Ee=_e(we),ke=e=>null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length;var fe=r(4697);var ye=r(9127),Se=r.n(ye);const Ie=(0,s.createHigherOrderComponent)((e=>{class t extends i.Component{constructor(...e){super(...e),(0,l.Z)(this,"state",{error:null,loading:!1,variations:{}}),(0,l.Z)(this,"loadVariations",(()=>{const{products:e}=this.props,{loading:t,variations:r}=this.state;if(t)return;const o=this.getExpandedProduct();if(!o||r[o])return;const n=e.find((e=>e.id===o));var a;n.variations&&0!==n.variations.length?(this.setState({loading:!0}),(a=o,u()({path:(0,c.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:a})})).then((e=>{const t=e.map((e=>({...e,parent:o})));this.setState({variations:{...this.state.variations,[o]:t},loading:!1,error:null})})).catch((async e=>{const t=await A(e);this.setState({variations:{...this.state.variations,[o]:null},loading:!1,error:t})}))):this.setState({variations:{...this.state.variations,[o]:null},loading:!1,error:null})}))}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:r,showVariations:o}=this.props;o&&(!Se()(e.selected,r)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){var t;const{products:r}=this.props;return null===(t=r.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:r}=this.props;if(!r)return null;let o=t&&t.length?t[0]:null;return o?this.prevSelectedItem=o:this.prevSelectedItem&&(e||this.isProductId(this.prevSelectedItem)||(o=this.prevSelectedItem)),!e&&o?this.isProductId(o)?o:this.findParentProduct(o):null}render(){const{error:t,isLoading:r}=this.props,{error:n,loading:a,variations:l}=this.state;return(0,o.createElement)(e,{...this.props,error:n||t,expandedProduct:this.getExpandedProduct(),isLoading:r,variations:l,variationsLoading:a})}}return(0,l.Z)(t,"defaultProps",{selected:[],showVariations:!1}),t}),"withProductVariations"),Ce=({className:e,item:t,isSelected:r,isLoading:n,onSelect:a,disabled:l,...i})=>(0,o.createElement)(o.Fragment,null,(0,o.createElement)(ie,{...i,key:t.id,className:e,isSelected:r,item:t,onSelect:a,disabled:l}),r&&n&&(0,o.createElement)("div",{key:"loading",className:q()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},(0,o.createElement)($.Spinner,null)));r(5301);const xe={list:(0,T.__)("Products","woocommerce"),noItems:(0,T.__)("Your store doesn't have any products.","woocommerce"),search:(0,T.__)("Search for a product to display","woocommerce"),updated:(0,T.__)("Product search results updated.","woocommerce")},Pe=(e=>t=>{let{selected:r}=t;r=void 0===r?null:r;const n=null===r;return Array.isArray(r)?(0,o.createElement)(e,{...t}):(0,o.createElement)(e,{...t,selected:n?[]:[r]})})((Re=Ie((0,s.withInstanceId)((e=>{const{expandedProduct:t=null,error:r,instanceId:n,isCompact:a=!1,isLoading:l,onChange:i,onSearch:s,products:c,renderItem:d,selected:u=[],showVariations:m=!1,variations:g,variationsLoading:p}=e;if(r)return(0,o.createElement
(0,T.__)("%1$d variations","woocommerce"),null===(v=s.details)||void 0===v?void 0:v.variations.length):null,name:`products-${n}`,"aria-label":t?(0,T.sprintf)(/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
(0,T._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",null===(_=s.details)||void 0===_||null===(w=_.variations)||void 0===w?void 0:w.length,"woocommerce"),s.name,null===(E=s.details)||void 0===E?void 0:E.variations.length):void 0})}const k=ke(null===(r=s.details)||void 0===r?void 0:r.variation)?e:{...e,item:{...e.item,name:null===(a=s.details)||void 0===a?void 0:a.variation},"aria-label":`${s.breadcrumbs[0]}: ${null===(i=s.details)||void 0===i?void 0:i.variation}`};return(0,o.createElement)(ie,{...k,className:h,name:`variations-${n}`})}:()=>null),onSearch:s,messages:xe,isHierarchical:!0})}))),({selected:e,...t})=>{const[r,n]=(0,i.useState)(!0),[a,l]=(0,i.useState)(null),[s,c]=(0,i.useState)([]),d=y.productCount>100,u=async e=>{const t=await A(e);l(t),n(!1)},m=(0,i.useRef)(e);(0,i.useEffect)((()=>{R({selected:m.current}).then((e=>{c(e),n(!1)})).catch(u)}),[m]);const g=(0,fe.y1)((t=>{R({selected:e,search:t}).then((e=>{c(e),n(!1)})).catch(u)}),400),p=(0,i.useCallback)((e=>{n(!0),g(e)}),[n,g]);return(0,o.createElement)(Re,{...t,selected:e,error:a,products:s,isLoading:r,onSearch:d?p:null})})),Ne=e=>!(e=>null===e)(e)&&e instanceof Object&&e.constructor===Object;var Re;const Ae=e=>"string"==typeof e;var Le=r(9784);const $e=window.wp.styleEngine;function Te(e={}){const t={};return(0,$e.getCSSRules)(e,{selector:""}).forEach((e=>{t[e.key]=e.value})),t}function Oe(e,t){return e&&t?`has-${(0,Le.o)(t)}-${e}`:""}const Fe=e=>{const t=(e=>{const t=Ne(e)?e:{style:{}};let r=t.style;return Ae(r)&&(r=JSON.parse(r)||{}),Ne(r)||(r={}),{...t,style:r}})(e),r=function(e){var t,r,o,n,a,l,i;const{backgroundColor:s,textColor:c,gradient:d,style:u}=e,m=Oe("background-color",s),g=Oe("color",c),p=function(e){if(e)return`has-${e}-gradient-background`}(d),h=p||(null==u||null===(t=u.color)||void 0===t?void 0:t.gradient);return{className:q()(g,p,{[m]:!h&&!!m,"has-text-color":c||(null==u||null===(r=u.color)||void 0===r?void 0:r.text),"has-background":s||(null==u||null===(o=u.color)||void 0===o?void 0:o.background)||d||(null==u||null===(n=u.color)||void 0===n?void 0:n.gradient),"has-link-color":Ne(null==u||null===(a=u.elements)||void 0===a?void 0:a.link)?null==u||null===(l=u.elements)||void 0===l||null===(i=l.link)||void 0===i?void 0:i.color:void 0}),style:Te({color:(null==u?void 0:u.color)||{}})}}(t),o=function(e){var t;const r=(null===(t=e.style)||void 0===t?void 0:t.border)||{};return{className:function(e){var t;const{borderColor:r,style:o}=e,n=r?Oe("border-color",r):"";return q()({"has-border-color":!!r||!(null==o||null===(t=o.border)||void 0===t||!t.color),[n]:!!n})}(e),style:Te({border:r})}}(t),n=function(e){var t;return{className:void 0,style:Te({spacing:(null===(t=e.style)||void 0===t?void 0:t.spacing)||{}})}}(t),a=(e=>{const t=Ne(e.style.typography)?e.style.typography:{},r=Ae(t.fontFamily)?t.fontFamily:"";return{className:e.fontFamily?`has-${e.fontFamily}-font-family`:r,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:q()(a.className,r.className,o.className,n.className),style:{...a.style,...r.style,...o.style,...n.style}}},Me=({itemId:e,linkText:t,permalink:r})=>{const n=q()("wp-block-button__link","is-style-fill");return"preview"===e?(0,o.createElement)("div",{className:"wp-block-button aligncenter",style:{width:"100%"}},(0,o.createElement)(O.RichText.Content,{tagName:"a",className:n,href:r,title:t,style:{backgroundColor:"vivid-green-cyan",borderRadius:"5px"},value:t,target:r})):(0,o.createElement)(O.InnerBlocks,{template:[["core/buttons",{layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,T.__)("Shop now","woocommerce"),url:r}]]]],templateLock:"all"})},je=({className:e="",onResize:t,...r})=>{const[n,a]=(0,i.useState)(!1),l=q()(e,{"is-resizing":n}),s=(0,fe.zl)(((e,r,o,l)=>{n||a(!0),null==t||t(e,r,o,l)}),50,{leading:!0});return(0,o.createElement)($.ResizableBox,{className:l,enable:{bottom:!0},onResize: