(()=>{"use strict";const e=window.wc.blocksCheckout,t=window.wc.wcBlocksSharedHocs,n=window.wp.element,i=window.wp.i18n,o=window.wc.wcSettings,{optinDefaultText:c,gdprHeadline:r,gdprFields:s,gdprStatus:a}=(0,o.getSetting)("mailchimp-newsletter_data",""),l={text:{type:"string",default:c},gdprHeadline:{type:"string",default:r},gdpr:{type:"array",default:s},gdprStatus:{type:"string",default:a}},m=JSON.parse('{"apiVersion":2,"name":"woocommerce/mailchimp-newsletter-subscription","version":"1.0.0","title":"Mailchimp Newsletter!","category":"woocommerce","description":"Adds a newsletter subscription checkbox to the checkout.","supports":{"html":true,"align":false,"multiple":false,"reusable":false},"parent":["woocommerce/checkout-contact-information-block"],"attributes":{"lock":{"type":"object","default":{"remove":true,"move":true}}},"textdomain":"mailchimp-woocommerce","editorStyle":"file:../../../build/style-newsletter-block.css"}');(0,e.registerCheckoutBlock)({metadata:m,component:(0,t.withFilteredAttributes)(l)((({cart:t,extensions:o,text:c,gdprHeadline:r,gdprStatus:s,gdpr:a,checkoutExtensionData:l})=>{let m={};a&&a.length&&a.forEach((e=>{m[e.marketing_permission_id]=!1}));const d="check"===s,[p,u]=(0,n.useState)(d),[h]=(0,n.useState)({}),{setExtensionData:w}=l;return(0,n.useEffect)((()=>{w("mailchimp-newsletter","optin",p)}),[p,w]),(0,n.createElement)("div",{className:"wc-block-components-checkout-step__container"},(0,n.createElement)("div",{style:{display:"hide"===s?"none":""},className:"wc-block-components-checkout-step__content"},(0,n.createElement)(e.CheckboxControl,{id:"subscribe-to-newsletter",checked:p,onChange:u},(0,n.createElement)("span",{dangerouslySetInnerHTML:{__html:c}})),a&&a.length?(0,i.__)(r,"mailchimp-for-woocommerce"):"",a&&a.length?a.map((t=>(0,n.createElement)(e.CheckboxControl,{id:"gdpr_"+t.marketing_permission_id,checked:h[t.marketing_permission_id],onChange:e=>{h[t.marketing_permission_id]=!h[t.marketing_permission_id],w("mailchimp-newsletter","gdprFields",h)}},(0,n.createElement)("span",{dangerouslySetInnerHTML:{__html:t.text}})))):""))}))})})();