JezK
Edit File: single-product.js
(()=>{var e,t,o,r,s,n={8803:(e,t,o)=>{"use strict";const r=window.wp.blocks;var s=o(3450),n=o(3836);const c=window.wc.wcBlocksRegistry;var i=o(6087),a=o(8146);o.p=a.XK,(0,c.registerBlockComponent)({blockName:"woocommerce/product-price",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(2388)]).then(o.bind(o,3805)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-image",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(4232)]).then(o.bind(o,7156)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-title",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(2105)]).then(o.bind(o,3777)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-rating",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(462)]).then(o.bind(o,5547)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-rating-stars",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(8578)]).then(o.bind(o,3895)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-rating-counter",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(8553)]).then(o.bind(o,7924)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-average-rating",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(8647)]).then(o.bind(o,4765)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-button",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(7409)]).then(o.bind(o,8396)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-summary",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(3895)]).then(o.bind(o,7695)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-sale-badge",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(4442)]).then(o.bind(o,4927)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-sku",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(2724)]).then(o.bind(o,3277)))}),(0,c.registerBlockComponent)({blockName:"woocommerce/product-stock-indicator",component:(0,i.lazy)(()=>Promise.all([o.e(94),o.e(345)]).then(o.bind(o,964)))});var l=o(5703);const d=JSON.parse('{"name":"woocommerce/single-product","icon":"info","title":"Product","description":"Display a single product of your choice with full control over its presentation.","category":"woocommerce","keywords":["WooCommerce","single product"],"supports":{"interactivity":true,"align":["wide","full"]},"attributes":{"productId":{"type":"number"}},"example":{},"usesContext":["postId","postType","queryId"],"textdomain":"woocommerce","apiVersion":3,"$schema":"https://schemas.wp.org/trunk/block.json"}');var m=o(6427),p=o(3925),u=o(9544),h=o(790);const g="woocommerce/product-query/product-title";!function(e,{blockDescription:t,blockIcon:o,blockTitle:s,variationName:n,scope:c}){(0,r.registerBlockVariation)(e,{description:t,name:n,title:s,isActive:e=>e.__woocommerceNamespace===n,icon:{src:o},attributes:{__woocommerceNamespace:n},scope:c})}("core/post-title",{blockDescription:p.description,blockIcon:(0,h.jsx)(m.Icon,{icon:u.A}),blockTitle:p.title,variationName:g,scope:["block"]});const w=(0,h.jsx)(s.A,{icon:n.A,className:"wc-block-editor-components-block-icon"}),b=[["core/columns",{},[["core/column",{},[["woocommerce/product-gallery"]]],["core/column",{},[["core/post-title",{headingLevel:2,isLink:!0,__woocommerceNamespace:g}],["woocommerce/product-rating",{isDescendentOfSingleProductBlock:!0}],["woocommerce/product-price",{isDescendentOfSingleProductBlock:!0}],["woocommerce/product-summary",{isDescendentOfSingleProductBlock:!0}],[(0,l.getSetting)("isBlockTheme",!1)?"woocommerce/add-to-cart-with-options":"woocommerce/add-to-cart-form"],["woocommerce/product-meta"]]]]]],x=["core/columns","core/column","core/post-title","core/post-excerpt","woocommerce/add-to-cart-form","woocommerce/add-to-cart-with-options","woocommerce/product-meta","woocommerce/product-gallery","woocommerce/product-reviews","woocommerce/product-details",...Object.keys((_=d.name,(0,c.getRegisteredBlockComponents)(_)))];var _,v=o(7723),f=o(9491);const k=window.wp.url,j=window.wp.apiFetch;var y=o.n(j);const S=({selected:e=[],search:t="",queryArgs:o={}})=>{const r=(({selected:e=[],search:t="",queryArgs:o={}})=>{const r=a.r7.productCount>100&&e.length>0,s=[(0,k.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++)s.push((0,k.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:100,page:o}))}return s})({selected:e,search:t,queryArgs:o});return Promise.all(r.map(e=>y()({path:e}))).then(e=>[...new Map(e.flatMap(e=>e.map(e=>[e.id,{...e,parent:0}]))).values()])},C=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"}}},P=(0,f.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=>y()({path:`/wc/store/v1/products/${e}`}))(e).then(e=>{this.setState({product:e,loading:!1,error:null})}).catch(async e=>{const t=await C(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,h.jsx)(e,{...this.props,error:t,getProduct:this.loadProduct,isLoading:o,product:r})}},"withProduct"),N=({imageUrl:e=`${a.sW}/block-error.svg`,header:t=(0,v.__)("Oops!","woocommerce"),text:o=(0,v.__)("There was an error loading the content.","woocommerce"),errorMessage:r,errorMessagePrefix:s=(0,v.__)("Error:","woocommerce"),button:n,showErrorBlock:c=!0})=>c?(0,h.jsxs)("div",{className:"wc-block-error wc-block-components-error",children:[e&&(0,h.jsx)("img",{className:"wc-block-error__image wc-block-components-error__image",src:e,alt:""}),(0,h.jsxs)("div",{className:"wc-block-error__content wc-block-components-error__content",children:[t&&(0,h.jsx)("p",{className:"wc-block-error__header wc-block-components-error__header",children:t}),o&&(0,h.jsx)("p",{className:"wc-block-error__text wc-block-components-error__text",children:o}),r&&(0,h.jsxs)("p",{className:"wc-block-error__message wc-block-components-error__message",children:[s?s+" ":"",r]}),n&&(0,h.jsx)("p",{className:"wc-block-error__button wc-block-components-error__button",children:n})]})]}):null;o(5893);class E extends i.Component{state={errorMessage:"",hasError:!1};static getDerivedStateFromError(e){return void 0!==e.statusText&&void 0!==e.status?{errorMessage:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("strong",{children:e.status}),": ",e.statusText]}),hasError:!0}:{errorMessage:e.message,hasError:!0}}render(){const{header:e,imageUrl:t,showErrorMessage:o=!0,showErrorBlock:r=!0,text:s,errorMessagePrefix:n,renderError:c,button:i}=this.props,{errorMessage:a,hasError:l}=this.state;return l?"function"==typeof c?c({errorMessage:a}):(0,h.jsx)(N,{showErrorBlock:r,errorMessage:o?a:null,header:e,imageUrl:t,text:s,errorMessagePrefix:n,button:i}):this.props.children}}const I=E;var A=o(3907),B=o(4715),O=o(415);const T=e=>{const t=((0,O.useProductDataContext)().product||{}).id||e.productId||0;return t&&1!==t?(0,h.jsx)(B.InspectorControls,{children:(0,h.jsxs)("div",{className:"wc-block-single-product__edit-card",children:[(0,h.jsx)("div",{className:"wc-block-single-product__edit-card-title",children:(0,h.jsxs)("a",{href:`${l.ADMIN_URL}post.php?post=${t}&action=edit`,target:"_blank",rel:"noopener noreferrer",children:[(0,v.__)("Edit this product's details","woocommerce"),(0,h.jsx)(s.A,{icon:A.A,size:16})]})}),(0,h.jsx)("div",{className:"wc-block-single-product__edit-card-description",children:(0,v.__)("Edit details such as title, price, description and more.","woocommerce")})]})}):null};var L=o(2748),M=o(4921);const R=window.wp.escapeHtml,V=({message:e,type:t})=>e?"general"===t?(0,h.jsxs)("span",{children:[(0,v.__)("The following error was returned","woocommerce"),(0,h.jsx)("br",{}),(0,h.jsx)("code",{children:(0,R.escapeHTML)(e)})]}):"api"===t?(0,h.jsxs)("span",{children:[(0,v.__)("The following error was returned from the API","woocommerce"),(0,h.jsx)("br",{}),(0,h.jsx)("code",{children:(0,R.escapeHTML)(e)})]}):e:(0,v.__)("An error has prevented the block from being updated.","woocommerce"),$=({error:e})=>(0,h.jsx)("div",{className:"wc-block-error-message",children:V(e)});o(3120);const F=({className:e="",error:t,isLoading:o=!1,onRetry:r})=>(0,h.jsxs)(m.Placeholder,{icon:(0,h.jsx)(s.A,{icon:L.A}),label:(0,v.__)("Sorry, an error occurred","woocommerce"),className:(0,M.A)("wc-block-api-error",e),children:[(0,h.jsx)($,{error:t}),r&&(0,h.jsx)(h.Fragment,{children:o?(0,h.jsx)(m.Spinner,{}):(0,h.jsx)(m.Button,{variant:"secondary",onClick:r,children:(0,v.__)("Retry","woocommerce")})})]}),D=window.wc.data;var z=o(7143),H=o(7051);o(7539);var G=o(3993);function U(e,t,o){const r=new Set(t.map(e=>e[o]));return e.filter(e=>!r.has(e[o]))}var W=o(8537);const q={clear:(0,v.__)("Clear all selected items","woocommerce"),noItems:(0,v.__)("No items found.","woocommerce"), /* Translators: %s search term */ noResults:(0,v.__)("No results for %s","woocommerce"),search:(0,v.__)("Search for items","woocommerce"),selected:e=>(0,v.sprintf)(/* translators: Number of items selected from list. */ /* translators: Number of items selected from list. */ (0,v._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,v.__)("Search results updated.","woocommerce")},J=(e,t)=>null!==t&&(e.id===t||!!(Array.isArray(e.children)&&e.children.length>0)&&e.children.some(e=>J(e,t))),K=(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 s=["0"],n=(e={})=>e.parent?[...n(r[e.parent]),e.name]:e.name?[e.name]:[],c=e=>e.map(e=>{const t=o[e.id];return s.push(""+e.id),{...e,breadcrumbs:n(r[e.parent]),children:t&&t.length?c(t):[]}}),i=c(o[0]||[]);return Object.entries(o).forEach(([e,t])=>{s.includes(e)||i.push(...c(t||[]))}),i},X=(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,h.jsx)("strong",{children:e},t):(0,h.jsx)(i.Fragment,{children:e},t))},Q=e=>{const t=e.children?.map(e=>[e,...Q(e)]);return t?t.flat():[]},Y=(e,t)=>Q(e).some(e=>t.find(t=>t.id===e.id)),Z=(e,t)=>Q(e).every(e=>t.find(t=>t.id===e.id)),ee=({label:e})=>(0,h.jsx)("span",{className:"woocommerce-search-list__item-count",children:e}),te=e=>{const{item:t,search:o}=e,r=t.breadcrumbs&&t.breadcrumbs.length;return(0,h.jsxs)("span",{className:"woocommerce-search-list__item-label",children:[r?(0,h.jsx)("span",{className:"woocommerce-search-list__item-prefix",children:(s=t.breadcrumbs,1===s.length?s.slice(0,1).toString():2===s.length?s.slice(0,1).toString()+" › "+s.slice(-1).toString():s.slice(0,1).toString()+" … "+s.slice(-1).toString())}):null,(0,h.jsx)("span",{className:"woocommerce-search-list__item-name",children:X((0,W.decodeEntities)(t.name),o)})]});var s},oe=({countLabel:e,className:t,depth:o=0,controlId:r="",disabled:s=!1,item:n,isSelected:c,isSelectable:a=!0,isSingle:l,onSelect:d,search:p="",selected:u,useExpandedPanelId:g,...w})=>{const[b,x]=g,_=null!=e&&void 0!==n.count&&null!==n.count,v=!!n.breadcrumbs?.length,f=!!n.children?.length,k=J(n,b),j=(0,M.A)(["woocommerce-search-list__item",`depth-${o}`,t],{"has-breadcrumbs":v,"has-children":f,"has-count":_,"is-expanded":k,"is-radio-button":l}),y=w.name||`search-list-item-${r}`,S=`${y}-${n.id}`,C=(0,i.useCallback)(()=>{k||"number"!=typeof n.id&&"string"!=typeof n.id?!n.parent||"number"!=typeof n.parent&&"string"!=typeof n.parent?x(null):x(n.parent):x(n.id)},[k,n.id,n.parent,x]),P=(c||!a)&&Z(n,u);return f?(0,h.jsx)("div",{className:j,onClick:C,onKeyDown:e=>"Enter"===e.key||" "===e.key?C():null,role:"treeitem",tabIndex:0,children:l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("input",{type:"radio",id:S,name:y,value:n.value,onChange:()=>{d(n)(),k||x(n.id)},onClick:e=>e.stopPropagation(),checked:c,disabled:s,className:"woocommerce-search-list__item-input",...w}),(0,h.jsx)(te,{item:n,search:p}),_?(0,h.jsx)(ee,{label:e||n.count}):null]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(m.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:P,disabled:s,indeterminate:!P&&(c||Y(n,u)),label:X((0,W.decodeEntities)(n.name),p),onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),onChange:()=>{const e=Q(n),t=a?[n,...e]:[...e],o=Z(n,u);a&&c||!a&&o?d(U(u,t,"id"))():(d(function(e,t){const o=U(t,e,"id");return[...e,...o]}(u,t))(),k||x(n.id))},__nextHasNoMarginBottom:!0}),_?(0,h.jsx)(ee,{label:e||n.count}):null]})}):(0,h.jsxs)("div",{className:j,onClick:s?void 0:d(n),children:[l?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("input",{...w,type:"radio",id:S,name:y,value:n.value,onChange:d(n),checked:c,disabled:s,className:"woocommerce-search-list__item-input",onClick:e=>e.stopPropagation()}),(0,h.jsx)("label",{htmlFor:S,children:(0,h.jsx)(te,{item:n,search:p})})]}):(0,h.jsx)(m.CheckboxControl,{...w,id:S,name:y,className:"woocommerce-search-list__item-input",value:(0,W.decodeEntities)(n.value),label:X((0,W.decodeEntities)(n.name),p),onChange:()=>{d(n)(),k||x(n.id)},checked:c,disabled:s,__nextHasNoMarginBottom:!0,onClick:e=>e.stopPropagation()}),_?(0,h.jsx)(ee,{label:e||n.count}):null]})},re=oe;var se=o(1884);o(5022);const ne=({id:e,label:t,popoverContents:o,remove:r,screenReaderLabel:n,className:c=""})=>{const[a,l]=(0,i.useState)(!1),d=(0,f.useInstanceId)(ne);if(n=n||t,!t)return null;t=(0,W.decodeEntities)(t);const p=(0,M.A)("woocommerce-tag",c,{"has-remove":!!r}),u=`woocommerce-tag__label-${d}`,g=(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)("span",{className:"screen-reader-text",children:n}),(0,h.jsx)("span",{"aria-hidden":"true",children:t})]});return(0,h.jsxs)("span",{className:p,children:[o?(0,h.jsx)(m.Button,{className:"woocommerce-tag__text",id:u,onClick:()=>l(!0),children:g}):(0,h.jsx)("span",{className:"woocommerce-tag__text",id:u,children:g}),o&&a&&(0,h.jsx)(m.Popover,{onClose:()=>l(!1),children:o}),r&&(0,h.jsx)(m.Button,{className:"woocommerce-tag__remove",onClick:r(e),label:(0,v.sprintf)( // Translators: %s label. // Translators: %s label. (0,v.__)("Remove %s","woocommerce"),t),"aria-describedby":u,children:(0,h.jsx)(s.A,{icon:se.A,size:20,className:"clear-icon",role:"img"})})]})},ce=ne;o(1939);const ie=e=>(0,h.jsx)(re,{...e}),ae=e=>{const{list:t,selected:o,renderItem:r,depth:s=0,loadMoreChildrenText:n,onLoadMoreChildren:c,totalChildren:a,onSelect:l,instanceId:d,isSingle:m,search:p,useExpandedPanelId:u}=e,[g]=u;return t?(0,h.jsx)(h.Fragment,{children:t.map(t=>{const w=t.children?.length??0,b=!!o.find(({id:e})=>e===t.id),x=J(t,g),_=a?.[t.id],f="number"==typeof _&&w<_;return(0,h.jsxs)(i.Fragment,{children:[(0,h.jsx)("li",{children:r({item:t,isSelected:b,onSelect:l,isSingle:m,selected:o,search:p,depth:s,useExpandedPanelId:u,controlId:d})}),x?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ae,{...e,list:t.children,depth:s+1}),c&&f?(0,h.jsx)("li",{children:(0,h.jsx)("button",{type:"button",className:"woocommerce-search-list__item woocommerce-search-list__item-load-more",onClick:()=>c(),children:n||(0,v.__)("Load more","woocommerce")})}):null]}):null]},t.id)})}):null},le=({isLoading:e,isSingle:t,selected:o,messages:r,onChange:s,onRemove:n})=>{if(e||t||!o)return null;const c=o.length;return(0,h.jsxs)("div",{className:"woocommerce-search-list__selected",children:[(0,h.jsxs)("div",{className:"woocommerce-search-list__selected-header",children:[(0,h.jsx)("strong",{children:r.selected(c)}),c>0?(0,h.jsx)(m.Button,{variant:"link",isDestructive:!0,onClick:()=>s([]),"aria-label":r.clear,children:(0,v.__)("Clear all","woocommerce")}):null]}),c>0?(0,h.jsx)("ul",{children:o.map((e,t)=>(0,h.jsx)("li",{children:(0,h.jsx)(ce,{label:e.name,id:e.id,remove:n})},t))}):null]})},de=({filteredList:e,search:t,onSelect:o,instanceId:r,useExpandedPanelId:n,...c})=>{const{messages:i,renderItem:a,selected:l,isSingle:d,loadMoreChildrenText:m,onLoadMoreChildren:p,totalChildren:u}=c,g=a||ie;return 0===e.length?(0,h.jsxs)("div",{className:"woocommerce-search-list__list is-not-found",children:[(0,h.jsx)("span",{className:"woocommerce-search-list__not-found-icon",children:(0,h.jsx)(s.A,{icon:H.A,role:"img"})}),(0,h.jsx)("span",{className:"woocommerce-search-list__not-found-text",children:t?(0,v.sprintf)(i.noResults,t):i.noItems})]}):(0,h.jsx)("ul",{className:"woocommerce-search-list__list",children:(0,h.jsx)(ae,{useExpandedPanelId:n,list:e,selected:l,renderItem:g,loadMoreChildrenText:m,onLoadMoreChildren:p,totalChildren:u,onSelect:o,instanceId:r,isSingle:d,search:t})})},me=e=>{const{className:t="",isCompact:o,isHierarchical:r,isLoading:s,isSingle:n,list:c,messages:a=q,onChange:l,onSearch:d,selected:p,type:u="text",debouncedSpeak:g}=e,[w,b]=(0,i.useState)(""),x=(0,i.useState)(null),_=(0,f.useInstanceId)(me),k=(0,i.useMemo)(()=>({...q,...a}),[a]),j=(0,i.useMemo)(()=>((e,t,o)=>{if(!t)return o?K(e):e;const r=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),s=e.map(e=>!!r.test(e.name)&&e).filter(Boolean);return o?K(s,e):s})(c,w,r),[c,w,r]);(0,i.useEffect)(()=>{g&&g(k.updated)},[g,k]),(0,i.useEffect)(()=>{"function"==typeof d&&d(w)},[w,d]);const y=(0,i.useCallback)(e=>()=>{n&&l([]);const t=p.findIndex(({id:t})=>t===e);l([...p.slice(0,t),...p.slice(t+1)])},[n,p,l]),S=(0,i.useCallback)(e=>()=>{Array.isArray(e)?l(e):-1===p.findIndex(({id:t})=>t===e.id)?l(n?[e]:[...p,e]):y(e.id)()},[n,y,l,p]),C=(0,i.useCallback)(e=>{const[t]=p.filter(t=>!e.find(e=>t.id===e.id));y(t.id)()},[y,p]);return(0,h.jsxs)("div",{className:(0,M.A)("woocommerce-search-list",t,{"is-compact":o,"is-loading":s,"is-token":"token"===u}),children:["text"===u&&(0,h.jsx)(le,{...e,onRemove:y,messages:k}),(0,h.jsx)("div",{className:"woocommerce-search-list__search",children:"text"===u?(0,h.jsx)(m.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:k.search,type:"search",value:w,onChange:e=>b(e)}):(0,h.jsx)(m.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,disabled:s,label:k.search,onChange:C,onInputChange:e=>b(e),suggestions:[],__experimentalValidateInput:()=>!1,value:s?[(0,v.__)("Loading…","woocommerce")]:p.map(e=>({...e,value:e.name})),__experimentalShowHowTo:!1})}),s?(0,h.jsx)("div",{className:"woocommerce-search-list__list",children:(0,h.jsx)(m.Spinner,{})}):(0,h.jsx)(de,{...e,search:w,filteredList:j,messages:k,onSelect:S,instanceId:_,useExpandedPanelId:x})]})},pe=((0,m.withSpokenMessages)(me),e=>t=>{let{selected:o}=t;o=void 0===o?null:o;const r=null===o;return Array.isArray(o)?(0,h.jsx)(e,{...t}):(0,h.jsx)(e,{...t,selected:r?[]:[o]})});var ue=o(4347);var he=o(923),ge=o.n(he);const we=(0,f.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&&(!ge()(e.selected,o)||e.isLoading&&!t)&&this.loadVariations()}loadVariations=({offset:e=0}={})=>{const{products:t}=this.props,{loading:o,variations:r,totalVariations:s}=this.state;if(o)return;const n=this.getExpandedProduct();if(!n)return;if(!e&&r?.[n])return;if(r?.[n]&&s?.[n]&&r[n].length>=s[n])return;const c=t.find(e=>e.id===n);if(!c?.variations||0===c.variations.length)return void this.setState({variations:{...this.state.variations,[n]:null},loading:!1,error:null});this.setState({loading:!0});const i=this.state.variations[n]||[];((e,t={})=>y()({path:(0,k.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}})))(n,{offset:e}).then(({variations:e,total:t})=>{const o=e.map(e=>({...e,parent:n}));this.setState({variations:{...this.state.variations,[n]:[...i,...o]},totalVariations:{...this.state.totalVariations,[n]:t},loading:!1,error:null})}).catch(async e=>{const t=await C(e);this.setState({variations:{...this.state.variations,[n]:null},totalVariations:{...this.state.totalVariations,[n]: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:s,variations:n,totalVariations:c}=this.state,i=this.getExpandedProduct(),a=i&&n[i]?.length||0;return(0,h.jsx)(e,{...this.props,error:r||t,onLoadMoreVariations:()=>this.loadVariations({offset:a}),expandedProduct:this.getExpandedProduct(),isLoading:o,totalVariations:c,variations:n,variationsLoading:s})}}return t},"withProductVariations"),be=e=>{const{id:t,name:o,parent:r}=e;return{id:t,name:o,parent:r,breadcrumbs:[],children:[],details:e,value:e.slug}};var xe=o(1609);const _e=({className:e,item:t,isSelected:o,isLoading:r,onSelect:s,disabled:n,...c})=>(0,h.jsxs)(h.Fragment,{children:[(0,xe.createElement)(oe,{...c,key:t.id,...e&&{className:e},isSelected:o,item:t,onSelect:s,...n&&{disabled:n}}),o&&r&&(0,h.jsx)("div",{className:(0,M.A)("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active"),children:(0,h.jsx)(m.Spinner,{})},"loading")]});o(5653);const ve={list:(0,v.__)("Products","woocommerce"),noItems:(0,v.__)("Your store doesn't have any products.","woocommerce"),search:(0,v.__)("Search for a product to display","woocommerce"),updated:(0,v.__)("Product search results updated.","woocommerce")},fe=pe((ye=we((0,f.withInstanceId)(e=>{const{expandedProduct:t=null,error:o,instanceId:r,isCompact:s=!1,isLoading:n,onChange:c,onLoadMoreVariations:i,totalVariations:a,onSearch:l,products:d,renderItem:m,selected:p=[],showVariations:u=!1,variations:g,variationsLoading:w}=e;if(o)return(0,h.jsx)($,{error:o});const b=[...d,...g&&t&&g[t]?g[t]:[]].map(be);return(0,h.jsx)(me,{className:"woocommerce-products",list:b,isCompact:s,isLoading:n,isSingle:!0,selected:b.filter(({id:e})=>p.includes(Number(e))),onChange:c,loadMoreChildrenText:u?(0,v.__)("Load more variations","woocommerce"):void 0,onLoadMoreChildren:u?i:void 0,totalChildren:u?a:void 0,renderItem:m||(u?e=>{const{item:t,search:o,depth:s=0,isSelected:c,onSelect:i,useExpandedPanelId:a}=e,[l,d]=a??[null,()=>{}],m=J(t,l),p=t.details?.variations&&Array.isArray(t.details.variations)?t.details.variations.length:0,u=(0,M.A)("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${s}`,"has-count",{"is-searching":o.length>0,"is-skip-level":0===s&&0!==t.parent,"is-variable":p>0});if(!t.breadcrumbs.length){const o=t.details?.variations&&t.details.variations.length>0;return(0,h.jsx)(_e,{...e,className:(0,M.A)(u,{"is-selected":c}),isSelected:c,item:t,onSelect:()=>()=>{i(t)(),m||d(t.id)},isLoading:n||w,countLabel:o?(0,v.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,v.__)("%1$d variations","woocommerce"),t.details?.variations.length):null,name:`products-${r}`,"aria-label":o?(0,v.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,v._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 g=(0,G.isEmpty)(t.details?.variation)?e:{...e,item:{...e.item,name:t.details?.variation},"aria-label":`${t.breadcrumbs[0]}: ${t.details?.variation}`};return(0,h.jsx)(oe,{...g,className:u,name:`variations-${r}`})}:void 0),onSearch:l,messages:{...ve,...e.messages},isHierarchical:!0})})),({selected:e,...t})=>{const[o,r]=(0,i.useState)(!0),[s,n]=(0,i.useState)(null),[c,l]=(0,i.useState)([]),d=a.r7.productCount>100,m=async e=>{const t=await C(e);n(t),r(!1)},p=(0,i.useRef)(e);(0,i.useEffect)(()=>{S({selected:p.current}).then(e=>{l(e),r(!1)}).catch(m)},[p]);const u=(0,ue.YQ)(t=>{S({selected:e,search:t}).then(e=>{l(e),r(!1)}).catch(m)},400),g=(0,i.useCallback)(e=>{r(!0),u(e)},[r,u]);return(0,h.jsx)(ye,{...t,selected:e,error:s,products:c,isLoading:o,onSearch:d?g:null})})),ke=({attributes:e,setAttributes:t,onChange:o})=>(0,h.jsx)(fe,{selected:e.productId||0,showVariations:!0,onChange:(e=[])=>{const r=e[0]?e[0].id:0;t({productId:r}),o&&o()}}),je=({isEditing:e,setIsEditing:t})=>(0,h.jsx)(B.BlockControls,{children:(0,h.jsx)(m.ToolbarGroup,{controls:[{icon:"edit",title:(0,v.__)("Edit selected product","woocommerce"),onClick:()=>t(!e),isActive:e}]})});var ye,Se=o(4462);const Ce=({isLoading:e,product:t,clientId:o})=>{const s="wc-block-editor-single-product",{replaceInnerBlocks:n}=(0,z.useDispatch)("core/block-editor"),c=(0,i.useCallback)(()=>{n(o,(0,r.createBlocksFromInnerBlocksTemplate)(b),!1)},[o,n]);return(0,h.jsx)(O.InnerBlockLayoutContextProvider,{parentName:d.name,parentClassName:s,children:(0,h.jsxs)(O.ProductDataContextProvider,{product:t,isLoading:e,children:[(0,h.jsx)(B.InspectorControls,{children:(0,h.jsx)(m.PanelBody,{title:(0,v.__)("Layout","woocommerce"),initialOpen:!0,children:(0,h.jsx)(m.Button,{label:(0,v.__)("Reset layout to default","woocommerce"),onClick:c,variant:"tertiary",className:"wc-block-editor-single-product__reset-layout",icon:Se.A,children:(0,v.__)("Reset layout","woocommerce")})})}),(0,h.jsx)("div",{className:s,children:(0,h.jsx)(B.BlockContextProvider,{value:{postId:t?.id,postType:"product"},children:(0,h.jsx)(B.InnerBlocks,{template:b,allowedBlocks:x,templateLock:!1})})})]})})},Pe=P(({attributes:e,setAttributes:t,error:o,getProduct:r,product:n,isLoading:c,clientId:a})=>{const{productId:l}=e,p=(0,z.useSelect)(e=>{const{getSettings:t}=e(B.store);return Boolean(t()?.isPreviewMode??!1)},[]),[u,g]=(0,i.useState)(!l),b=(0,B.useBlockProps)(),x=(0,z.useSelect)(e=>e("core/blocks").getBlockType(d.name),[]),_=(0,z.useSelect)(e=>p?e(D.PRODUCTS_STORE_NAME).getProducts({per_page:1}):null),f="object"==typeof o&&"woocommerce_rest_product_invalid_id"===o?.code;if((0,i.useEffect)(()=>{const o=_?_[0]?.id:null;o&&!l&&(t({...e,productId:o}),g(!1))},[e,l,_,t]),(0,i.useEffect)(()=>{f&&!u&&g(!0)},[f]),o&&!f)return(0,h.jsx)(F,{className:"wc-block-editor-single-product-error",error:o,isLoading:c,onRetry:r});const k=f?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.A,{icon:H.A,className:"wc-block-editor-single-product__info-icon"}),(0,h.jsx)(m.__experimentalText,{children:(0,v.__)("Previously selected product is no longer available.","woocommerce")})]}):(0,h.jsx)(m.__experimentalText,{children:x.description}),j=f?()=>g(!1):void 0;return(0,h.jsx)("div",{...b,children:(0,h.jsxs)(I,{header:(0,v.__)("Single Product Block Error","woocommerce"),children:[(0,h.jsx)(je,{setIsEditing:g,isEditing:u}),u?(0,h.jsxs)(m.Placeholder,{icon:w,label:x.title,className:"wc-block-editor-single-product",children:[(0,h.jsxs)(m.__experimentalHStack,{alignment:"center",children:[" ",k," "]}),(0,h.jsxs)("div",{className:"wc-block-editor-single-product__selection",children:[(0,h.jsx)(ke,{attributes:e,setAttributes:t,onChange:j}),!f&&(0,h.jsx)(m.Button,{variant:"secondary",onClick:()=>{g(!1)},children:(0,v.__)("Done","woocommerce")})]})]}):(0,h.jsxs)("div",{children:[(0,h.jsx)(B.InspectorControls,{children:(0,h.jsx)(m.PanelBody,{title:(0,v.__)("Product","woocommerce"),initialOpen:!1,children:(0,h.jsx)(ke,{attributes:e,setAttributes:t})})}),(0,h.jsx)(T,{productId:l}),(0,h.jsx)(Ce,{clientId:a,product:n,isLoading:c})]})]})})}),Ne=[{attributes:d.attributes,supports:d.supports,save:()=>{const e=B.useBlockProps.save();return(0,h.jsx)("div",{...e,children:(0,h.jsx)(B.InnerBlocks.Content,{})})}}];(0,r.registerBlockType)(d,{icon:w,edit:Pe,save:()=>{const e=B.useBlockProps.save({className:"woocommerce"});return(0,h.jsx)("div",{...e,children:(0,h.jsx)(B.InnerBlocks.Content,{})})},deprecated:Ne})},3707:(e,t,o)=>{"use strict";o.d(t,{Hw:()=>u,Vo:()=>i,XK:()=>c,iI:()=>m,r7:()=>s,sW:()=>n});var r=o(5703);const s=(0,r.getSetting)("wcBlocksConfig",{pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),n=s.pluginUrl+"assets/images/",c=s.pluginUrl+"assets/client/blocks/",i=(r.STORE_PAGES.shop,r.STORE_PAGES.checkout,r.STORE_PAGES.checkout,r.STORE_PAGES.privacy,r.STORE_PAGES.privacy,r.STORE_PAGES.terms,r.STORE_PAGES.terms,r.STORE_PAGES.cart,r.STORE_PAGES.cart?.permalink),a=(r.STORE_PAGES.myaccount?.permalink?r.STORE_PAGES.myaccount.permalink:(0,r.getSetting)("wpLoginUrl","/wp-login.php"),(0,r.getSetting)("localPickupEnabled",!1),(0,r.getSetting)("shippingMethodsExist",!1),(0,r.getSetting)("shippingEnabled",!0),(0,r.getSetting)("countries",{})),l=(0,r.getSetting)("countryData",{}),d={...Object.fromEntries(Object.keys(l).filter(e=>!0===l[e].allowBilling).map(e=>[e,a[e]||""])),...Object.fromEntries(Object.keys(l).filter(e=>!0===l[e].allowShipping).map(e=>[e,a[e]||""]))},m=(Object.fromEntries(Object.keys(d).map(e=>[e,l[e].states||{}])),Object.fromEntries(Object.keys(d).map(e=>[e,l[e].locale||{}]))),p={address:["first_name","last_name","company","address_1","address_2","city","postcode","country","state","phone"],contact:["email"],order:[]},u=(0,r.getSetting)("addressFieldsLocations",p).address;(0,r.getSetting)("addressFieldsLocations",p).contact,(0,r.getSetting)("addressFieldsLocations",p).order,(0,r.getSetting)("additionalOrderFields",{}),(0,r.getSetting)("additionalContactFields",{}),(0,r.getSetting)("additionalAddressFields",{})},8346:(e,t,o)=>{"use strict";o.d(t,{S:()=>s});var r=o(5703);const s=()=>(0,r.getSetting)("experimentalWcRestApiV4",!1)},8146:(e,t,o)=>{"use strict";o.d(t,{Hw:()=>r.Hw,Sc:()=>s.S,Vo:()=>r.Vo,XK:()=>r.XK,iI:()=>r.iI,r7:()=>r.r7,sW:()=>r.sW});var r=o(3707),s=o(8346)},5893:()=>{},7539:()=>{},3120:()=>{},5653:()=>{},1939:()=>{},5022:()=>{},1609:e=>{"use strict";e.exports=window.React},790:e=>{"use strict";e.exports=window.ReactJSXRuntime},4656:e=>{"use strict";e.exports=window.wc.blocksComponents},910:e=>{"use strict";e.exports=window.wc.priceFormat},2435:e=>{"use strict";e.exports=window.wc.sanitize},7594:e=>{"use strict";e.exports=window.wc.wcBlocksData},415:e=>{"use strict";e.exports=window.wc.wcBlocksSharedContext},1616:e=>{"use strict";e.exports=window.wc.wcBlocksSharedHocs},5703:e=>{"use strict";e.exports=window.wc.wcSettings},3993:e=>{"use strict";e.exports=window.wc.wcTypes},6004:e=>{"use strict";e.exports=window.wp.autop},4715:e=>{"use strict";e.exports=window.wp.blockEditor},6427:e=>{"use strict";e.exports=window.wp.components},9491:e=>{"use strict";e.exports=window.wp.compose},7143:e=>{"use strict";e.exports=window.wp.data},6087:e=>{"use strict";e.exports=window.wp.element},2619:e=>{"use strict";e.exports=window.wp.hooks},8537:e=>{"use strict";e.exports=window.wp.htmlEntities},7723:e=>{"use strict";e.exports=window.wp.i18n},923:e=>{"use strict";e.exports=window.wp.isShallowEqual},5573:e=>{"use strict";e.exports=window.wp.primitives},9786:e=>{"use strict";e.exports=window.wp.styleEngine},9446:e=>{"use strict";e.exports=window.wp.wordcount},3925:e=>{"use strict";e.exports=JSON.parse('{"title":"Product Title","description":"Display the title of a product.","attributes":{"headingLevel":{"type":"number","default":2},"showProductLink":{"type":"boolean","default":true},"linkTarget":{"type":"string"},"productId":{"type":"number","default":0},"align":{"type":"string"}}}')}},c={};function i(e){var t=c[e];if(void 0!==t)return t.exports;var o=c[e]={exports:{}};return n[e](o,o.exports,i),o.exports}i.m=n,e=[],i.O=(t,o,r,s)=>{if(!o){var n=1/0;for(d=0;d<e.length;d++){for(var[o,r,s]=e[d],c=!0,a=0;a<o.length;a++)(!1&s||n>=s)&&Object.keys(i.O).every(e=>i.O[e](o[a]))?o.splice(a--,1):(c=!1,s<n&&(n=s));if(c){e.splice(d--,1);var l=r();void 0!==l&&(t=l)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[o,r,s]},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 s=Object.create(null);i.r(s);var n={};t=t||[null,o({}),o([]),o(o)];for(var c=2&r&&e;"object"==typeof c&&!~t.indexOf(c);c=o(c))Object.getOwnPropertyNames(c).forEach(t=>n[t]=()=>e[t]);return n.default=()=>e,i.d(s,n),s},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.f={},i.e=e=>Promise.all(Object.keys(i.f).reduce((t,o)=>(i.f[o](e,t),t),[])),i.u=e=>({345:"product-stock-indicator",462:"product-rating",2105:"product-title",2388:"product-price",2724:"product-sku",3895:"product-summary",4232:"product-image",4442:"product-sale-badge",7409:"product-button",8553:"product-rating-counter",8578:"product-rating-stars",8647:"product-average-rating"}[e]+".js?ver="+{345:"8442d882f77df85c8766",462:"c9471a7ce88241585a4e",2105:"a975d6be5fee0c0e4c93",2388:"1b9538c1d5dd4a2c593d",2724:"8077c04ee61be4683cba",3895:"9d5fe127071e3b81ea9e",4232:"b9b3862f8f0e66df3915",4442:"388791516f2fcdb56794",7409:"fb1c551a70edb855ded5",8553:"2406755dfe1bf30ed856",8578:"c25390d12acf88b0e4e0",8647:"28e44a965858fc8e226e"}[e]),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),r={},s="webpackWcBlocksMainJsonp:",i.l=(e,t,o,n)=>{if(r[e])r[e].push(t);else{var c,a;if(void 0!==o)for(var l=document.getElementsByTagName("script"),d=0;d<l.length;d++){var m=l[d];if(m.getAttribute("src")==e||m.getAttribute("data-webpack")==s+o){c=m;break}}c||(a=!0,(c=document.createElement("script")).charset="utf-8",c.timeout=120,i.nc&&c.setAttribute("nonce",i.nc),c.setAttribute("data-webpack",s+o),c.src=e),r[e]=[t];var p=(t,o)=>{c.onerror=c.onload=null,clearTimeout(u);var s=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),s&&s.forEach(e=>e(o)),t)return t(o)},u=setTimeout(p.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=p.bind(null,c.onerror),c.onload=p.bind(null,c.onload),a&&document.head.appendChild(c)}},i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.j=5065,(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var o=t.getElementsByTagName("script");if(o.length)for(var r=o.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=o[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={5065:0};i.f.j=(t,o)=>{var r=i.o(e,t)?e[t]:void 0;if(0!==r)if(r)o.push(r[2]);else{var s=new Promise((o,s)=>r=e[t]=[o,s]);o.push(r[2]=s);var n=i.p+i.u(t),c=new Error;i.l(n,o=>{if(i.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var s=o&&("load"===o.type?"missing":o.type),n=o&&o.target&&o.target.src;c.message="Loading chunk "+t+" failed.\n("+s+": "+n+")",c.name="ChunkLoadError",c.type=s,c.request=n,r[1](c)}},"chunk-"+t,t)}},i.O.j=t=>0===e[t];var t=(t,o)=>{var r,s,[n,c,a]=o,l=0;if(n.some(t=>0!==e[t])){for(r in c)i.o(c,r)&&(i.m[r]=c[r]);if(a)var d=a(i)}for(t&&t(o);l<n.length;l++)s=n[l],i.o(e,s)&&e[s]&&e[s][0](),e[s]=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 a=i.O(void 0,[94],()=>i(8803));a=i.O(a),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["single-product"]=a})();