(()=>{"use strict";const e={n:r=>{const t=r&&r.__esModule?()=>r.default:()=>r;return e.d(t,{a:t}),t},d:(r,t)=>{if(Array.isArray(t))for(var o=0;o<t.length;){var n=t[o++],a=t[o++];e.o(r,n)?0===a&&o++:0===a?Object.defineProperty(r,n,{enumerable:!0,value:t[o++]}):Object.defineProperty(r,n,{enumerable:!0,get:a})}else for(var n in t)e.o(t,n)&&!e.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:t[n]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)},r=window.wp.blocks,t=window.wp.blockEditor,o=window.wp.components,n=window.wp.serverSideRender;var a=e.n(n);const l=window.wp.i18n,i=window.React;var d=e.n(i);function m(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,o=Array(r);t<r;t++)o[t]=e[t];return o}var s=function(){return d().createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},d().createElement("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3",stroke:"currentColor",strokeWidth:"2",fill:"none"}),d().createElement("line",{x1:"7",y1:"8",x2:"17",y2:"8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),d().createElement("line",{x1:"7",y1:"12",x2:"14",y2:"12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),d().createElement("line",{x1:"7",y1:"16",x2:"11",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}))};(0,r.registerBlockType)("dragwyb/form",{apiVersion:2,title:(0,l.__)("Smart Form","smart-form-builder-by-dragwyb"),description:(0,l.__)("Display a form created with Smart Form Builder.","smart-form-builder-by-dragwyb"),category:"widgets",icon:s,keywords:[(0,l.__)("form","smart-form-builder-by-dragwyb"),(0,l.__)("contact form","smart-form-builder-by-dragwyb"),(0,l.__)("smart form","smart-form-builder-by-dragwyb"),(0,l.__)("dragwyb","smart-form-builder-by-dragwyb")],attributes:{formId:{type:"string",default:""}},edit:function(e){var r,n,i=e.attributes,c=e.setAttributes,b=(0,t.useBlockProps)({className:"dragwyb-gutenberg-block-wrapper"}),u=i.formId,y=(null===(r=window.dragwybBlockData)||void 0===r?void 0:r.forms)||[],f=[{label:(0,l.__)("— Select a Form —","smart-form-builder-by-dragwyb"),value:""}].concat(function(e){if(Array.isArray(e))return m(e)}(n=y.map(function(e){return{label:e.label,value:String(e.value)}}))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,r){if(e){if("string"==typeof e)return m(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?m(e,r):void 0}}(n)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),w=d().createElement(o.SelectControl,{label:(0,l.__)("Select Form","smart-form-builder-by-dragwyb"),value:u||"",options:f,onChange:function(e){c({formId:String(e||"")})},help:(0,l.__)("Choose the form you want to display on this page.","smart-form-builder-by-dragwyb")});return d().createElement("div",b,d().createElement(t.InspectorControls,null,d().createElement(o.PanelBody,{title:(0,l.__)("Form Settings","smart-form-builder-by-dragwyb"),initialOpen:!0},w)),u?d().createElement("div",{className:"dragwyb-block-rendered-form"},d().createElement(a(),{block:"dragwyb/form",attributes:{formId:u},LoadingResponsePlaceholder:function(){return d().createElement(o.Placeholder,{icon:s,label:(0,l.__)("Loading Form Preview...","smart-form-builder-by-dragwyb")},d().createElement(o.Spinner,null))},EmptyResponsePlaceholder:function(){return d().createElement(o.Placeholder,{icon:s,label:(0,l.__)("Smart Form Builder","smart-form-builder-by-dragwyb"),instructions:(0,l.__)("Form not found or has no published fields.","smart-form-builder-by-dragwyb")},d().createElement("div",{style:{width:"100%",maxWidth:"380px",marginTop:"10px"}},w))}})):d().createElement(o.Placeholder,{icon:s,label:(0,l.__)("Smart Form Builder","smart-form-builder-by-dragwyb"),instructions:(0,l.__)("Select a form from the dropdown to embed and preview it here.","smart-form-builder-by-dragwyb"),className:"dragwyb-block-placeholder"},d().createElement("div",{style:{width:"100%",maxWidth:"380px",marginTop:"10px"}},w)))},save:function(){return null}})})();