"use client";
import { jsx, jsxs } from "react/jsx-runtime";
import { Sidebar } from "./Sidebar.js";
import { TopNavbar } from "./TopNavbar.js";
import { MobileTopBar } from "../mobile/MobileTopBar.js";
import { MobileBottomNav } from "../mobile/MobileBottomNav.js";
import { SidebarProvider, useSidebar } from "../../../contexts/sidebar-context.js";
import { cn } from "../../../lib/utils/index.js";
import { sel } from "../../../lib/test/index.js";
import { deserializeEntityConfig } from "../../../lib/entities/serialization.js";
import { setServerEntities } from "../../../lib/entities/registry.client.js";
let clientHydrated = false;
function DashboardShellContent({ children, entities }) {
  const { isCollapsed } = useSidebar();
  if (!clientHydrated && entities.length > 0) {
    const deserializedEntities = entities.map(deserializeEntityConfig);
    setServerEntities(deserializedEntities);
    clientHydrated = true;
  }
  return /* @__PURE__ */ jsxs("div", { className: "min-h-screen", "data-cy": sel("dashboard.container"), children: [
    /* @__PURE__ */ jsx(Sidebar, { className: "hidden lg:flex", entities }),
    /* @__PURE__ */ jsx(TopNavbar, { className: "hidden lg:flex", entities }),
    /* @__PURE__ */ jsx(MobileTopBar, {}),
    /* @__PURE__ */ jsx(MobileBottomNav, {}),
    /* @__PURE__ */ jsx(
      "div",
      {
        className: cn(
          "transition-all duration-300 min-h-screen",
          // Mobile: padding for top bar and bottom nav
          "pt-14 pb-20",
          // Desktop: padding for top navbar and margin for sidebar
          "lg:pt-16 lg:pb-0 lg:ml-64",
          // Desktop collapsed sidebar
          isCollapsed && "lg:ml-16"
        ),
        children: /* @__PURE__ */ jsx("main", { className: "flex-1", children })
      }
    )
  ] });
}
function DashboardShell({ children, entities }) {
  return /* @__PURE__ */ jsx(SidebarProvider, { children: /* @__PURE__ */ jsx(DashboardShellContent, { entities, children }) });
}
export {
  DashboardShell
};
