import{b as n,j as t}from"./BlockEditorTranslator.js?ver=1.5.3";import{u as f}from"./SingleProductContext.js?ver=1.5.3";const{useBlockProps:_,InspectorControls:P}=wp.blockEditor,{PanelBody:j,ToggleControl:b}=wp.components,T={attributes:{isLink:{type:"boolean",default:!0},linkTarget:{type:"string",default:"_self"}},edit:o=>{var g,m;const{attributes:s,setAttributes:r}=o,{isLink:e,linkTarget:l}=s,i=_({className:"fct-product-block-editor-product-card-title"}),c=f(),a=((g=c==null?void 0:c.product)==null?void 0:g.post_title)||n("Product Title"),u=((m=c==null?void 0:c.product)==null?void 0:m.view_url)||"#",d=e?"a":"h5",p=e?{href:u,target:l,rel:l==="_blank"?"noopener noreferrer":void 0,onClick:k=>k.preventDefault()}:{};return t.jsxs(t.Fragment,{children:[t.jsx(P,{children:t.jsxs(j,{title:n("Settings"),children:[t.jsx(b,{label:n("Make title a link"),checked:e,onChange:k=>r({isLink:k})}),e&&t.jsx(b,{label:n("Open in new tab"),checked:l==="_blank",onChange:k=>r({linkTarget:k?"_blank":"_self"})})]})}),t.jsx(d,{...i,...p,children:a})]})},save:o=>null,supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0},spacing:{margin:!0},color:{text:!0,link:!0}}},{useBlockProps:v}=wp.blockEditor,S={edit:o=>{var e,l,i,c,a,u,d,p;const s=v({className:"fct-product-block-editor-product-card-sub-title"}),r=f();return t.jsx("div",{...o,...s,children:r?t.jsxs(t.Fragment,{children:[t.jsx("div",{dangerouslySetInnerHTML:{__html:(l=(e=r.product)==null?void 0:e.detail)==null?void 0:l.formatted_min_price}}),((c=(i=r.product)==null?void 0:i.detail)==null?void 0:c.min_price)!==((u=(a=r.product)==null?void 0:a.detail)==null?void 0:u.max_price)&&t.jsxs("div",{children:[" - ",t.jsx("span",{dangerouslySetInnerHTML:{__html:(p=(d=r.product)==null?void 0:d.detail)==null?void 0:p.formatted_max_price}})]})]}):"$0.00"})},save:o=>null,supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0},spacing:{margin:!0},color:{text:!0,background:!0}},usesContext:["fluent-cart/price_format"]},{InnerBlocks:h,useBlockProps:x}=wp.blockEditor,E={edit:o=>{const s=x({className:"fct-product-block-editor-product-card-image group-[.list]:flex-shrink-0"}),{context:r}=o,e=f(),l=()=>{const i=window.fluent_cart_block_editor_asset.placeholder_image;return e.product&&e.product.detail&&e.product.detail.featured_media&&e.product.detail.featured_media!==null&&typeof e.product.detail.featured_media=="object"&&e.product.detail.featured_media.url?e.product.detail.featured_media.url:i};return t.jsx("div",{...s,children:t.jsxs("div",{className:"group-[.list]:flex-shrink-0 relative",children:[t.jsx("img",{src:l(),className:"w-full aspect-square object-cover rounded-md group-[.list]:w-[214px] pointer-events-none",alt:e.product?e.product.post_title:"Product"}),t.jsx("div",{className:"absolute inset-0",style:{pointerEvents:"auto"},children:t.jsx(h,{allowedBlocks:["fluent-cart/sold-out-badge","fluent-cart/sale-badge"],renderAppender:!1})})]})})},save:o=>{const s=x.save();return t.jsx("div",{...s,className:"fluent-cart-product-image",children:t.jsx(h.Content,{})})}},{useBlockProps:y}=wp.blockEditor,C={edit:o=>{var a,u,d,p,g;const s=y({className:"fct-product-block-editor-product-card-primary-button"}),r=f();if(!r.product)return t.jsx("button",{...o,...s,children:n("View")});if(((u=(a=r.product)==null?void 0:a.detail)==null?void 0:u.stock_availability)==="out-of-stock")return t.jsx("button",{...o,...s,disabled:!0,className:`${s.className||""} out-of-stock`,style:{background:"#fff",boxShadow:"none",border:"1px solid #d6dae1",color:"#2F3448",fontWeight:"600",cursor:"not-allowed",pointerEvents:"none"},children:n("Out of Stock")});const l=((p=(d=r.product)==null?void 0:d.detail)==null?void 0:p.variation_type)==="simple",i=!!((g=r.product)!=null&&g.has_subscription);let c=n("View Options");return l&&(i?c=n("Buy Now"):c=n("View")),t.jsx("button",{...o,...s,children:c})},save:o=>null,supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0},spacing:{margin:!0,padding:!0},color:{text:!0},__experimentalBorder:{radius:!0,color:!0,width:!0,style:!0}}},{useBlockProps:w}=wp.blockEditor,I={edit:o=>{var e;const s=w({className:"fct-product-block-editor-product-card-excerpt"}),r=f();return t.jsx("p",{...o,...s,children:r&&((e=r.product)==null?void 0:e.post_excerpt)||n("(empty)")})},save:o=>null,supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0},spacing:{margin:!0,padding:!0},color:{text:!0}}};export{I as P,C as a,E as b,S as c,T as d};
