"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("react"),u=require("react-router"),m=require("semantic-ui-react"),w=require("@devgateway/wp-react-lib"),f=require("../embeddable/index.js"),P=()=>{const d=u.useParams(),[p]=u.useSearchParams(),[o]=r.useState(()=>f.getComponentByNameIgnoreCase(d.name??"")),[n,l]=r.useState(()=>Object.fromEntries(p.entries())),i=r.useRef(n);i.current=n;const a=r.useCallback(g=>{const t=g.data;if(t.messageType&&t.messageType==="component-attributes"){const c={...i.current};Object.keys(t).forEach(s=>{c["data-"+s.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()]=typeof t[s]=="object"?JSON.stringify(t[s]):t[s]}),l(c)}},[]);return r.useEffect(()=>(window.addEventListener("message",a,!1),window.parent&&window.parent.postMessage({type:"componentReady",value:!0},"*"),window.top&&window.top.postMessage({type:"componentReady",value:!0},"*"),()=>{window.removeEventListener("message",a)}),[a]),e.jsx("div",{children:e.jsx(m.Container,{fluid:!0,className:"editing",children:o?e.jsx(o,{...n,editing:!0}):e.jsx(m.Segment.Group,{color:"red",textAlign:"center",children:e.jsx("h1",{children:"Wrong Component Name"})})})})},j=()=>e.jsx(w.SettingsConsumer,{children:e.jsx(P,{})});exports.default=j;
