(()=>{"use strict";var e,t,n={855(e){e.exports=import("../../../../Html/JSModules/build/FormBuilder/FormBuilder.js")}},r={};function o(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return n[e](i,i.exports,o),i.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"==typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"==typeof n.then)return n}var i=Object.create(null);o.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var l=2&r&&n;("object"==typeof l||"function"==typeof l)&&!~e.indexOf(l);l=t(l))Object.getOwnPropertyNames(l).forEach(e=>a[e]=()=>n[e]);return a.default=()=>n,o.d(i,a),i},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};const i=window.wp.blocks,a=window.wp.blockEditor,l=window.wp.components,s=window.React,c=window.wp.serverSideRender;var d=o.n(c);const u=window.ReactJSXRuntime;function p({options:e,uuid:t,setAttributes:n,attributes:r}){const[i,a]=(0,s.useState)(document.createElement("div")),[c,d]=(0,s.useState)((0,u.jsx)(l.Spinner,{})),p=(0,s.useRef)(null);return(0,s.useLayoutEffect)(()=>{null!==p.current&&p.current.appendChild(i)},[p]),(0,s.useEffect)(()=>{if(null==e)return;let a;return Promise.resolve().then(o.t.bind(o,855,23)).then(({default:o})=>{i.innerHTML="";let l=r.config??{};a=new o(e),a.loadData(l).placeHtml(i).runValidate(),a.onValidChange.add(e=>{e.isValid?(wp.data.dispatch("core/editor").unlockPostSaving("pad-block-"+t),wp.data.dispatch("core/notices").removeNotice("pad-block-"+t)):(wp.data.dispatch("core/editor").lockPostSaving("pad-block-"+t),wp.data.dispatch("core/notices").createNotice("error","Please check the Planaday Blocks for errors in the settings",{id:"pad-block-"+t,isDismissible:!1}))}),a.onChange.add(()=>n({config:a.getData(!1)})),d((0,u.jsx)(u.Fragment,{})),null!==p.current&&p.current.appendChild(i)}),()=>{void 0!==a&&(a.runValidate(),a.clean())}},[e,i]),(0,u.jsx)(u.Fragment,{children:(0,u.jsx)("div",{ref:p,className:"planaday",children:c})})}function h({attributes:e,setAttributes:t,tagName:n,allowedTemplates:r,renderEndpoint:o,title:i}){const c=[];for(const e in r)c.push({label:e,value:r[e]});let h=e.UUID??crypto.randomUUID();void 0!==e.UUID&&null!==e.UUID||t({UUID:h});let f=e.template??c[0].value;const[v,m]=(0,s.useState)([(0,u.jsxs)("div",{children:[(0,u.jsx)(l.Spinner,{})," instellingen aan het laden"]})]),[b,w]=(0,s.useState)(null);return(0,s.useEffect)(()=>{m([(0,u.jsxs)("div",{children:[(0,u.jsx)(l.Spinner,{})," instellingen aan het laden"]})]),fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).then(e=>e.json()).then(e=>{e.hasOwnProperty("options")?w(e):m([(0,u.jsx)("div",{children:(0,u.jsx)("p",{children:"Sorry, iets is mis gegaan. Kan niet de instellingen tonen momenteel."})})])}).catch(e=>{console.warn(e)})},[f]),(0,s.useEffect)(()=>{b&&m([(0,u.jsx)(p,{attributes:e,uuid:h,setAttributes:t,options:b?.options,children:" "})])},[b,e]),(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(a.InspectorControls,{children:[(0,u.jsx)(l.PanelBody,{title:"Template",children:(0,u.jsx)(l.SelectControl,{label:"Template",value:f,options:c,onChange:e=>t({template:e})})}),v]}),(0,u.jsx)("div",{...(0,a.useBlockProps)(),children:(0,u.jsx)(d(),{block:n,attributes:e})})]})}const f=(0,u.jsx)("svg",{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",focusable:"false",children:(0,u.jsx)("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm.5 16c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V7h15v12zM9 10H7v2h2v-2zm0 4H7v2h2v-2zm4-4h-2v2h2v-2zm4 0h-2v2h2v-2zm-4 4h-2v2h2v-2zm4 0h-2v2h2v-2z"})});setInterval(()=>{document.querySelectorAll("script.pad-script").forEach(e=>{const t=e.innerText,n=document.createElement("script");n.type="module",n.innerText=t,e.parentNode.replaceChild(n,e)})},500),window.planadayRegisterBlock=function(e,t,n,r){(0,i.registerBlockType)(e,{icon:f,edit:o=>(0,u.jsx)(h,{...o,tagName:e,allowedTemplates:n,renderEndpoint:r,title:t}),title:t})}})();