import { jsx as m } from "@emotion/react/jsx-runtime";
import R from "react";
import { MemonizedWindowBaseMicroFrontend as C } from "../../../../../../../WindowBase/subcomponents/MicroFrontend/MicroFrontend.js";
import { WindowBaseComponent as D } from "../../../../../../../WindowBase/subcomponents/Component/index.js";
import { TEST_PROP_ID as N } from "../../../../../../../../test/constants_no_mock.js";
import { getNameDataTestId as $ } from "../../../../../../../../test/getNameDataTestId.js";
import { AREAS_VIEWER_CLASS_NAME as k } from "../../../../../../constants.js";
import { useWindow as P } from "./hooks/useWindow.js";
import { WindowBaseStyled as b } from "../../../../slots/AreasViewerSlots.js";
import { shallow as u } from "zustand/shallow";
import { useAreasStore as f } from "../../../../../../hooks/useAreas/index.js";
const F = (w) => {
  const { areaId: e, windowId: r } = w, {
    emergeType: i,
    moduleId: I,
    winType: d,
    title: T,
    subTitle: A,
    editionInfo: h,
    iconUrl: y,
    version: E,
    buildTime: S,
    moduleCount: s,
    selected: g,
    mfProps: a,
    component: l,
    loading: B,
    status: c,
    dynamicMFStore: p,
    windowTools: n,
    onTouch: W,
    memoizedActions: _,
    loggedUser: v
  } = P(r, e), x = f(
    (t) => e ? t.hashAreas[e]?.maximizedId : void 0,
    u
  ), z = f(
    (t) => {
      const o = e ? t.hashAreas[e] : void 0;
      return o && o.currentBreakpoint && o.layouts && o.layouts[o.currentBreakpoint] && o.layouts[o.currentBreakpoint].find(
        (M) => M.i === r
      )?.colapsed || !1;
    },
    u
  );
  return c === void 0 ? null : /* @__PURE__ */ m(
    b,
    {
      title: `${T}${s ? `:${s}` : ""}`,
      subTitle: A,
      editionInfo: h,
      iconUrl: y,
      isLoading: B,
      onClose: () => n.close(),
      version: E,
      buildTime: S,
      actions: _,
      windowId: r,
      selected: g,
      maximized: !!x,
      onMouseDown: W,
      emergeType: i,
      collapsed: z,
      ...process.env.NODE_ENV !== "production" ? {
        [N]: $(
          k,
          "windowRoot",
          `${i}`
        )
      } : {},
      children: c === "loaded" ? d === "microfrontend" && a ? /* @__PURE__ */ m(
        C,
        {
          emergeType: i,
          moduleId: I,
          dynamicMFStore: p,
          windowTools: n,
          loggedUser: v,
          ...a
        }
      ) : d === "component" && l ? /* @__PURE__ */ m(
        D,
        {
          id: r,
          emergeType: i,
          dynamicMFStore: p,
          windowTools: n,
          component: l
        }
      ) : null : null
    }
  );
};
R.memo(F);
export {
  F as Window
};
