(()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,n=window.wp.blockEditor,a=window.wp.components,l=window.wp.data;var o=["frontend-admin/step"];var i=function(o){var i=o.clientId,c=(0,l.useDispatch)("core/block-editor"),r=c.insertBlock,s=c.removeBlock,d=c.updateBlockAttributes,p=c.selectBlock,u=(0,l.useSelect)((function(e){return e("core/block-editor").getBlocks(i)}),[i]);return React.createElement(n.InspectorControls,null,React.createElement(a.PanelBody,{title:(0,t.__)("Steps","frontend-admin"),initialOpen:!0},u.map((function(e,n){return React.createElement("div",{key:e.clientId,style:{display:"flex",justifyContent:"space-between",marginBottom:"10px"}},React.createElement(a.TextControl,{value:e.attributes.title,onChange:function(t){d(e.clientId,{title:t})},placeholder:(0,t.__)("Step Title","frontend-admin")}),u.length>1&&React.createElement(a.Button,{isDestructive:!0,onClick:function(){return t=e.clientId,s(t),void p(i);var t}},(0,t.__)("Remove","frontend-admin")))})),React.createElement(a.Button,{variant:"primary",onClick:function(){var t=(0,e.createBlock)("frontend-admin/step");r(t,u.length,i),setAttributes({active_step:u.length}),p(i)}},(0,t.__)("Add Step","frontend-admin"))))};const c=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"frontend-admin/steps","title":"FEA Form Steps","description":"Groups content into steps.","category":"frontend-admin","textdomain":"frontend-admin","icon":"list-view","supports":{"align":["wide"]},"providesContext":{"frontend-admin/steps/active_step":"active_step"},"attributes":{"active_step":{"type":"number","default":0},"validate_steps":{"type":"boolean","default":false},"steps_display":{"type":"string","default":false},"steps_tabs_display":{"type":"string","default":false},"steps_counter_display":{"type":"string","default":false},"tabs_align":{"type":"string","default":false},"tab_links":{"type":"boolean","default":false}},"editorScript":"file:../../steps/index.js"}');(0,e.registerBlockType)(c,{edit:function(c){var r=c.clientId,s=(0,l.useSelect)((function(e){return e("core/block-editor").getBlocks(r)}),[r]),d=(0,l.useDispatch)("core/block-editor"),p=d.insertBlock,u=d.removeBlock,m=d.updateBlockAttributes,f=d.selectBlock,_=c.attributes,b=_.validate_steps,v=_.steps_display,k=_.steps_tabs_display,g=_.steps_counter_display,y=_.tabs_align,h=(_.nextButtonLabel,_.width,_.color,c.setAttributes);return React.createElement(React.Fragment,null,React.createElement("div",{className:"fe-form-steps-tabs"},s.map((function(e,t){return React.createElement(n.RichText,{key:e.clientId,tagName:"button",value:e.attributes.title||"Step ".concat(t+1),onChange:function(t){return m(e.clientId,{title:t})},onClick:function(){h({active_step:t})},placeholder:"Step ".concat(t+1),allowedFormats:[]})})),React.createElement("button",{className:"fe-add-step-button",onClick:function(){var t=(0,e.createBlock)("frontend-admin/step");p(t,s.length,r),h({active_step:s.length}),f(r)},onKeyDown:function(e){if("Backspace"===e.key||"Delete"===e.key){var t=s[s.length-1];t&&(u(t.clientId),h({active_step:s.length-2}),f(r))}}},(0,t.__)("Add Step","frontend-admin"))),React.createElement(n.InnerBlocks,{allowedBlocks:o,orientation:"vertical",template:[["frontend-admin/step"]]}),React.createElement(i,{clientId:r}),React.createElement(n.InspectorControls,null,React.createElement(a.PanelBody,{title:(0,t.__)("Step Settings","frontend-admin")},React.createElement(a.ToggleControl,{label:(0,t.__)("Validate Each Step","frontend-admin"),checked:b,onChange:function(){return h({validate_steps:!b})}}),React.createElement(a.SelectControl,{label:(0,t.__)("Steps Display","frontend-admin"),value:v,options:[{value:"tabs",label:(0,t.__)("Tabs","frontend-admin")},{value:"counter",label:(0,t.__)("Counter","frontend-admin")}],onChange:function(e){return h({steps_display:e})}}),React.createElement(a.CheckboxControl,{label:(0,t.__)("Display Tabs","frontend-admin"),checked:k,onChange:function(e){return h({steps_tabs_display:e})}}),React.createElement(a.CheckboxControl,{label:(0,t.__)("Display Counter","frontend-admin"),checked:g,onChange:function(e){return h({steps_counter_display:e})}}),React.createElement(a.RadioControl,{label:(0,t.__)("Tabs Align","frontend-admin"),selected:y,options:[{value:"left",label:(0,t.__)("Left","frontend-admin")},{value:"center",label:(0,t.__)("Center","frontend-admin")},{value:"right",label:(0,t.__)("Right","frontend-admin")}],onChange:function(e){return h({tabs_align:e})}}))))},save:function(){var e=n.useBlockProps.save(),t=n.useInnerBlocksProps.save(e);return React.createElement("div",t)}})})();