(()=>{"use strict";const e=window.wp.blocks,t=window.wp.blockEditor,r=window.wp.i18n,s=window.wp.components,a=window.wp.element,n=window.wp.data,o=[["core/buttons",{align:"center",layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,r.__)("Click Me!","gatherpress"),className:"gatherpress-modal--trigger-open",tagName:"button"}]]],["gatherpress/modal",{},[["gatherpress/modal-content",{},[["core/paragraph",{content:(0,r.__)("Hello! This is a modal. You can customize this content or add blocks here.","gatherpress")}],["core/buttons",{align:"center",layout:{type:"flex",justifyContent:"center"}},[["core/button",{text:(0,r.__)("Close","gatherpress"),className:"gatherpress-modal--trigger-close",tagName:"button"}]]]]]]]],l=window.ReactJSXRuntime,i=JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"gatherpress/modal-manager","version":"1.0.0","title":"Modal Manager","category":"gatherpress","icon":"external","example":{},"description":"Manage modals and their triggers with ease.","attributes":{},"supports":{"layout":{"allowSwitching":false,"allowInheriting":false,"default":{"justifyContent":"center","type":"flex"}},"spacing":{"padding":true,"margin":true,"blockGap":true},"html":false,"interactivity":true},"textdomain":"gatherpress","editorScript":"file:./index.js","viewScriptModule":"file:./view.js"}');(0,e.registerBlockType)(i,{edit:({clientId:e})=>{const i=(0,t.useBlockProps)(),[c,d]=(0,a.useState)(null),p=(0,n.select)("core/block-editor").getBlocks(e);return(0,a.useEffect)(()=>{const e=(0,n.subscribe)(()=>{const e=(0,n.select)("core/block-editor").getSelectedBlockClientId();c&&e!==c&&d(null)});return()=>e()},[c]),(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(t.InspectorControls,{children:(0,l.jsx)(s.PanelBody,{title:(0,r.__)("Open a Modal","gatherpress"),children:(0,l.jsx)("fieldset",{"aria-label":(0,r.__)("Modal selection","gatherpress"),style:{display:"flex",gap:"0.5rem",flexWrap:"wrap",border:"none",padding:0,margin:0},children:p.map(e=>{if("gatherpress/modal"===e.name){const t=e?.attributes?.metadata?.name||(0,r.__)("Modal","gatherpress"),a=c===e.clientId;return(0,l.jsx)(s.Button,{variant:a?"primary":"secondary",onClick:()=>{return t=e.clientId,void(c===t?(d(null),(0,n.dispatch)("core/block-editor").clearSelectedBlock()):(d(t),(0,n.dispatch)("core/block-editor").selectBlock(t)));var t},"aria-pressed":a,children:t},e.clientId)}return null})})})}),(0,l.jsx)("div",{...i,children:(0,l.jsx)(t.InnerBlocks,{template:o})})]})},save:()=>(0,l.jsx)("div",{...t.useBlockProps.save(),children:(0,l.jsx)(t.InnerBlocks.Content,{})})})})();