(()=>{"use strict";const e=window.wp.element;var t=(0,e.forwardRef)(({icon:t,size:o=24,...i},n)=>(0,e.cloneElement)(t,{width:o,height:o,...i,ref:n}));const o=window.wp.primitives,i=window.ReactJSXRuntime;var n=(0,i.jsx)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(o.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M6.863 13.644L5 13.25h-.5a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5H5L18 6.5h2V16h-2l-3.854-.815.026.008a3.75 3.75 0 01-7.31-1.549zm1.477.313a2.251 2.251 0 004.356.921l-4.356-.921zm-2.84-3.28L18.157 8h.343v6.5h-.343L5.5 11.823v-1.146z"})});const l=window.wp.blocks,a=window.wp.i18n,s=window.wp.blockEditor,r=window.wc.blocksCheckout,c=window.wc.wcSettings,p=window.wp.components,d=(0,c.getSetting)("adminUrl"),{optinEnabled:m,defaultText:w}=(0,c.getSetting)("mailpoet_data");function u(){const e=`${d}admin.php?page=mailpoet-settings#/woocommerce`;return(0,i.jsxs)(p.Placeholder,{icon:(0,i.jsx)(t,{icon:n}),label:(0,a.__)("Marketing opt-in","mailpoet"),className:"wp-block-mailpoet-newsletter-block-placeholder",children:[(0,i.jsx)("span",{className:"wp-block-mailpoet-newsletter-block-placeholder__description",children:(0,a.__)("MailPoet marketing opt-in would be shown here if enabled. You can enable from the settings page.","mailpoet")}),(0,i.jsx)(p.Button,{variant:"primary",className:"wp-block-mailpoet-newsletter-block-placeholder__button",onClick:()=>{window.open(e,"_blank","noopener noreferrer")},children:(0,a.__)("Enable opt-in for Checkout","mailpoet")})]})}const{optinEnabled:k,defaultText:h}=(0,c.getSetting)("mailpoet_data"),b={text:{type:"string",default:h},lock:{type:"object",default:{remove:!!k,move:!1}}},g=JSON.parse('{"apiVersion":3,"name":"mailpoet/marketing-optin-block","version":"0.1.0","title":"MailPoet Marketing Opt-in","category":"mailpoet","textdomain":"mailpoet","supports":{"align":false,"html":false,"multiple":false,"reusable":false,"inserter":false},"attributes":{"lock":{"type":"object","default":{"remove":true,"move":false}}},"parent":["woocommerce/checkout-contact-information-block"],"editorScript":"file:./marketing-optin-block.js","editorStyle":"file:./marketing-optin-block.css"}'),f=(0,l.getCategories)();(0,l.setCategories)([...f,{slug:"mailpoet",title:"MailPoet"}]),(0,l.registerBlockType)(g,{icon:{src:(0,i.jsx)(t,{icon:n}),foreground:"#7f54b3"},attributes:{...g.attributes,...b},edit:function({attributes:{text:e},setAttributes:t}){const o=(0,s.useBlockProps)(),n=e||w;return(0,i.jsx)("div",{...o,children:m?(0,i.jsxs)("div",{className:"wc-block-checkout__marketing",children:[(0,i.jsx)(r.CheckboxControl,{id:"mailpoet-marketing-optin",checked:!1,onChange:()=>{}}),(0,i.jsx)(s.RichText,{value:n,onChange:e=>t({text:e})})]}):(0,i.jsx)(u,{})})},save:function(){return(0,i.jsx)("div",{...s.useBlockProps.save()})}})})();