(()=>{"use strict";const e=window.wp.blocks,t=window.wp.i18n,n=window.wp.blockEditor,a=window.wp.components,r=window.React;var l="frontend-admin";const o=function(e){var r=e.attributes,o=e.setAttributes,i=r.label,c=r.hide_label,s=r.required,d=r.instructions,u=function(e){return e.toLowerCase().replace(/[^a-z0-9 _]/g,"").replace(/\s+/g,"_")};return React.createElement(n.InspectorControls,{field_key:"fea-inspector-controls"},React.createElement(a.PanelBody,{title:(0,t.__)("General",l),initialOpen:!0},React.createElement(a.TextControl,{label:(0,t.__)("Label",l),value:i,onChange:function(e){return o({label:e})}}),React.createElement(a.ToggleControl,{label:(0,t.__)("Hide Label",l),checked:c,onChange:function(e){return o({hide_label:e})}}),"name"in r&&React.createElement(a.TextControl,{label:(0,t.__)("Name",l),value:r.name||u(i),onChange:function(e){return o({name:u(e)})}}),"field_key"in r&&React.createElement(a.TextControl,{label:(0,t.__)("Field Key",l),value:r.field_key,readOnly:!0,onChange:function(e){}}),React.createElement(a.TextareaControl,{label:(0,t.__)("Instructions",l),rows:"3",value:d,onChange:function(e){return o({instructions:e})}}),React.createElement(a.ToggleControl,{label:(0,t.__)("Required",l),checked:s,onChange:function(e){return o({required:e})}}),e.children))},i=function(e){var a=e.attributes,l=e.setAttributes,o=a.label,i=a.hide_label,c=a.required,s=a.instructions,d=function(){return Math.random().toString(36).substring(2,10)};return(0,r.useEffect)((function(){if(!(!1 in a)){a.field_key||l({field_key:d()});var e=a.field_key;if(Array.from(document.querySelectorAll(".fea-field-key")).filter((function(t){return t.textContent===e})).length>1){var t=d();l({field_key:t})}}}),[]),React.createElement("div",{className:"acf-field"},React.createElement("span",{hidden:!0,className:"fea-field-key"},a.field_key),React.createElement("div",{className:"acf-label"},React.createElement("label",null,!i&&React.createElement(n.RichText,{tagName:"span",onChange:function(e){return l({label:e})},withoutInteractiveFormatting:!0,placeholder:(0,t.__)("Text Field","frontend-admin"),value:o}),c&&React.createElement("span",{className:"acf-required"},"*"))),React.createElement("div",{className:"acf-input"},s&&React.createElement(n.RichText,{tagName:"p",className:"description",onChange:function(e){return l({instructions:e})},withoutInteractiveFormatting:!0,value:s}),React.createElement("div",{className:"acf-input-wrap"+(e.wrapperClass?" "+e.wrapperClass:""),style:{display:"flex",width:"100%"}},e.children)))};var c=[["frontend-admin/repeater-item"]],s=["frontend-admin/repeater-item"];const d=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"frontend-admin/repeater","title":"FEA Form Repeater","description":"Groups content into repeaters.","category":"frontend-admin","textdomain":"frontend-admin","icon":"list-view","supports":{"align":["wide"]},"providesContext":{"frontend-admin/repeater/active_row":"active_row"},"attributes":{"label":{"type":"string","default":"Repeater"},"active_row":{"type":"number","default":0},"repeater_layout":{"type":"string","default":"table"},"add_button_text":{"type":"string","default":"Add Row"},"remove_button_text":{"type":"string","default":"Remove Row"},"min_rows":{"type":"number"},"max_rows":{"type":"number"}},"editorScript":"file:../../repeater/index.js"}');(0,e.registerBlockType)(d,{edit:function(e){var r=e.attributes,l=e.setAttributes;return r.label,React.createElement(React.Fragment,null,React.createElement(i,e,React.createElement("div",{className:"fe-repeater-editor"},React.createElement(n.InnerBlocks,{template:c,allowedBlocks:s}))),React.createElement(n.InspectorControls,null,React.createElement(o,e,React.createElement(a.TextControl,{label:(0,t.__)("Max Rows","frontend-admin"),type:"number",value:0==r.max_rows?"":r.max_rows,min:r.min_rows>0?r.min_rows:0,onChange:function(e){return l({max_rows:parseInt(e)||0})},help:(0,t.__)("Set to 0 for unlimited rows","frontend-admin")}),React.createElement(a.TextControl,{label:(0,t.__)("Min Rows","frontend-admin"),type:"number",value:0==r.min_rows?"":r.min_rows,max:r.max_rows>0?r.max_rows:void 0,min:0,onChange:function(e){return l({min_rows:parseInt(e)||0})}}))))},save:function(){var e=n.useBlockProps.save(),t=n.useInnerBlocksProps.save(e);return React.createElement("div",t)}})})();