import { hM as V, R as x, e0 as E, hN as I, fG as R, ad as w, hO as A, H as r, hP as C, hQ as H, hR as P, hS as T, hT as g, hU as v } from "./56c67d3b.js";
import { useRef as G, useMemo as L, useEffect as u } from "react";
import "react-dom";
const M = V();
function b(p) {
  const {
    dsl: h,
    moduleDsl: m,
    appId: o,
    moduleInputs: n,
    onCompChange: s,
    onModuleEventTriggered: l
  } = p, a = G(l);
  a.current = l;
  const f = L(
    () => ({
      Comp: x,
      initialValue: h,
      reduceContext: {
        readOnly: !0,
        applicationId: o,
        parentApplicationPath: [],
        moduleDSL: m || {}
      },
      initHandler: (t) => t.preload(`app-${o}`),
      actionPreInterceptor: (t) => {
        var i;
        return t.type === E.TRIGGER_MODULE_EVENT ? ((i = a.current) == null || i.call(a, t.name), !1) : !0;
      }
    }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [o]
  ), [e] = I(f);
  return u(() => {
    s == null || s(e);
  }, [e]), u(() => {
    const t = e == null ? void 0 : e.children.ui.getModuleLayoutComp();
    if (!t || !n)
      return;
    t.children.io.children.inputs.getView().forEach((d) => {
      const {
        name: y
      } = d.getView(), c = n[y];
      c !== void 0 && d.children.defaultValue.children.comp.dispatch(R(d.children.defaultValue.children.comp.changeValueAction(c)));
    });
  }, [n]), /* @__PURE__ */ w(A, {
    children: [/* @__PURE__ */ r(C, {}), /* @__PURE__ */ r(H, {
      store: P,
      children: /* @__PURE__ */ r(T.Provider, {
        value: {
          applicationId: o,
          appType: 1,
          readOnly: !0,
          hideHeader: !0
        },
        children: /* @__PURE__ */ r(g, {
          history: M,
          children: /* @__PURE__ */ r(v, {
            path: "/",
            render: () => e == null ? void 0 : e.getView()
          })
        })
      })
    })]
  });
}
export {
  b as AppView
};
