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