(()=>{"use strict";var e,s={748:()=>{const e=window.wp.blocks,s=window.wp.element,r=window.wp.blockEditor,t=window.wp.components,n=JSON.parse('{"UU":"equalstrue/newsletter"}'),o=window.ReactJSXRuntime;(0,e.registerBlockType)(n.UU,{edit:({attributes:e,setAttributes:n})=>{const{successMessage:a,errorMessage:l}=e,i=(0,r.useBlockProps)(),[c,u]=(0,s.useState)(""),[p,d]=(0,s.useState)(null);return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(r.InspectorControls,{children:(0,o.jsxs)(t.PanelBody,{title:"Messages",initialOpen:!0,children:[(0,o.jsx)(t.TextControl,{label:"Success Message",value:a,onChange:e=>n({successMessage:e})}),(0,o.jsx)(t.TextControl,{label:"Error Message",value:l,onChange:e=>n({errorMessage:e})})]})}),(0,o.jsxs)("div",{...i,children:[(0,o.jsxs)("form",{onSubmit:async e=>{e.preventDefault(),d(null);const s=await fetch("/wp-json/equalstrue/v1/newsletter",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:c})}),r=await s.json();d(r.success?"success":"error")},children:[(0,o.jsx)("input",{type:"email",required:!0,placeholder:"Your email",value:c,onChange:e=>u(e.target.value)}),(0,o.jsx)("button",{type:"submit",children:"Subscribe"})]}),"success"===p&&(0,o.jsx)("p",{className:"success",children:a}),"error"===p&&(0,o.jsx)("p",{className:"error",children:l})]})]})},save:()=>{const e=r.useBlockProps.save();return(0,o.jsx)("div",{...e,children:(0,o.jsxs)("form",{children:[(0,o.jsx)("input",{type:"email",required:!0,placeholder:"Your email"}),(0,o.jsx)("button",{type:"submit",children:"Subscribe"})]})})}})}},r={};function t(e){var n=r[e];if(void 0!==n)return n.exports;var o=r[e]={exports:{}};return s[e](o,o.exports,t),o.exports}t.m=s,e=[],t.O=(s,r,n,o)=>{if(!r){var a=1/0;for(u=0;u<e.length;u++){for(var[r,n,o]=e[u],l=!0,i=0;i<r.length;i++)(!1&o||a>=o)&&Object.keys(t.O).every((e=>t.O[e](r[i])))?r.splice(i--,1):(l=!1,o<a&&(a=o));if(l){e.splice(u--,1);var c=n();void 0!==c&&(s=c)}}return s}o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[r,n,o]},t.o=(e,s)=>Object.prototype.hasOwnProperty.call(e,s),(()=>{var e={495:0,375:0};t.O.j=s=>0===e[s];var s=(s,r)=>{var n,o,[a,l,i]=r,c=0;if(a.some((s=>0!==e[s]))){for(n in l)t.o(l,n)&&(t.m[n]=l[n]);if(i)var u=i(t)}for(s&&s(r);c<a.length;c++)o=a[c],t.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return t.O(u)},r=globalThis.webpackChunk=globalThis.webpackChunk||[];r.forEach(s.bind(null,0)),r.push=s.bind(null,r.push.bind(r))})();var n=t.O(void 0,[375],(()=>t(748)));n=t.O(n)})();