(()=>{"use strict";const e=window.wp.element,t=function(t){let{icon:o,size:l=24,...n}=t;return(0,e.cloneElement)(o,{width:l,height:l,...n})},o=window.wp.primitives,l=(0,e.createElement)(o.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,e.createElement)(o.Path,{fillRule:"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",clipRule:"evenodd"})),n=window.wp.blocks,i=window.wp.i18n,a=window.wp.blockEditor,r=window.wc.blocksCheckout,c=window.wc.wcSettings,s=window.wp.components,m=(0,c.getSetting)("adminUrl"),{optinEnabled:p,defaultText:w}=(0,c.getSetting)("mailpoet_data");function d(){return(0,e.createElement)(s.Placeholder,{icon:(0,e.createElement)(t,{icon:l}),label:(0,i.__)("Marketing opt-in","mailpoet"),className:"wp-block-mailpoet-newsletter-block-placeholder"},(0,e.createElement)("span",{className:"wp-block-mailpoet-newsletter-block-placeholder__description"},(0,i.__)("MailPoet marketing opt-in would be shown here if enabled. You can enable from the settings page.","mailpoet")),(0,e.createElement)(s.Button,{isPrimary:!0,href:`${m}admin.php?page=mailpoet-settings#/woocommerce`,target:"_blank",rel:"noopener noreferrer",className:"wp-block-mailpoet-newsletter-block-placeholder__button"},(0,i.__)("Enable opt-in for Checkout","mailpoet")))}const{defaultText:u}=(0,c.getSetting)("mailpoet_data"),g={text:{type:"string",default:u}},k=JSON.parse('{"apiVersion":2,"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"}'),b=(0,n.getCategories)();(0,n.setCategories)([...b,{slug:"mailpoet",title:"MailPoet"}]),(0,n.registerBlockType)(k,{icon:{src:(0,e.createElement)(t,{icon:l}),foreground:"#7f54b3"},attributes:{...k.attributes,...g},edit:function(t){let{attributes:{text:o},setAttributes:l}=t;const n=(0,a.useBlockProps)(),i=o||w;return(0,e.createElement)("div",n,p?(0,e.createElement)("div",{className:"wc-block-checkout__marketing"},(0,e.createElement)(r.CheckboxControl,{id:"mailpoet-marketing-optin",checked:!1}),(0,e.createElement)(a.RichText,{value:i,onChange:e=>l({text:e})})):(0,e.createElement)(d,null))},save:function(){return(0,e.createElement)("div",a.useBlockProps.save())}})})();