import{j as i}from"./tanstack-1.0.74-aU0azVkW.js";import{l as a,bx as c,by as b,bD as C,ad as S,bE as x,bF as F}from"./lib-1.0.74-B5IEqfHg.js";import{r as d}from"./redux-1.0.74-D8bIc6ki.js";import{A as h,u as w}from"./useTheme-1.0.74-CW3awVDs.js";import{u as j}from"./useTableSettings-1.0.74-DOrceZPc.js";import{u as y}from"./useStoreFormSettings-1.0.74-3dBRbl0S.js";import{u as I}from"./useMetadata-1.0.74--jxfVI7W.js";import{u as M}from"./useGlobalCode-1.0.74-D0fKEv_n.js";import{u as O}from"./useAppFunctions-1.0.74-YEA5Kc-A.js";import{T as v}from"./ThemeProvider-1.0.74-4uzbYYLM.js";import"./vendor-1.0.74-CN03Eozo.js";import"./utils-1.0.74-7xWhx9mc.js";import"./index-1.0.74-iJ_9eGZx.js";import"./CircularProgress-1.0.74-QfwfRJ7i.js";import"./Typography-1.0.74-B4mhsevh.js";import"./getThemeProps-1.0.74-DOfDN6_V.js";import"./useEnhancedEffect-1.0.74-B56M26dS.js";import"./hooks-1.0.74-NYCTWeI9.js";const W=({appId:n,children:l})=>{a.debug(n);const g=j(n),E=y(),T=w(),s=I(n);let p;(s==null?void 0:s.appRootId)===void 0&&(p=h(T,g,E));const e=M(),u=`pp-global-code-${n}`,{app:f}=O(n);return d.useEffect(()=>{var o,t,r;a.debug("open app",(o=e.onAppOpen)==null?void 0:o.code),(t=e.onAppOpen)!=null&&t.enabled&&c(((r=e.onAppOpen)==null?void 0:r.code)??"",b(s),!1,{app:f,loadScript:F,loadStyle:x})},[]),d.useEffect(()=>()=>{var o,t;a.debug("close app"),(o=e.onAppClose)!=null&&o.enabled&&c(((t=e.onAppClose)==null?void 0:t.code)??"",b(s),!1,{app:f})},[]),d.useEffect(()=>{var o,t,r;if(e!==void 0&&C(s)){(o=window.document.getElementById(u))==null||o.remove();const m=window.document.createElement("script");m.id=u,m.innerHTML=((t=e.global)==null?void 0:t.code)??"";const A=S(n,"pp_app_");(r=window.document.getElementById(A))==null||r.appendChild(m)}},[e]),p!==void 0?i.jsx(v,{theme:p,children:l}):i.jsx(i.Fragment,{children:l})};export{W as default};
