// @bun
// src/components/shell/WorkspaceHeader.tsx
import * as React from "react";
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue
} from "@contractspec/lib.ui-kit-web/ui/select";
import { jsx, jsxs } from "react/jsx-runtime";
function WorkspaceHeader({
  title,
  subtitle,
  workspaceSelect,
  projectSelect,
  environmentSelect,
  stickyHeaderOffsetPx,
  headerRight
}) {
  return /* @__PURE__ */ jsx("div", {
    className: "border-border bg-card sticky top-0 z-10 border-b",
    style: { top: stickyHeaderOffsetPx ?? 0 },
    children: /* @__PURE__ */ jsxs("div", {
      className: "mx-auto flex w-full max-w-7xl flex-col gap-3 px-4 py-3 md:flex-row md:items-center md:justify-between",
      children: [
        /* @__PURE__ */ jsxs("div", {
          className: "min-w-0",
          children: [
            /* @__PURE__ */ jsxs("div", {
              className: "flex items-center gap-2",
              children: [
                /* @__PURE__ */ jsx("p", {
                  className: "truncate text-base font-semibold",
                  children: title
                }),
                subtitle ? /* @__PURE__ */ jsx("p", {
                  className: "text-muted-foreground hidden text-sm md:block",
                  children: subtitle
                }) : null
              ]
            }),
            /* @__PURE__ */ jsxs("div", {
              className: "mt-2 flex flex-wrap gap-2",
              children: [
                workspaceSelect ? /* @__PURE__ */ jsx(ShellSelectControl, {
                  select: workspaceSelect
                }) : null,
                projectSelect ? /* @__PURE__ */ jsx(ShellSelectControl, {
                  select: projectSelect
                }) : null,
                environmentSelect ? /* @__PURE__ */ jsx(ShellSelectControl, {
                  select: environmentSelect
                }) : null
              ]
            })
          ]
        }),
        /* @__PURE__ */ jsx("div", {
          className: "flex items-center justify-between gap-2 md:justify-end",
          children: headerRight
        })
      ]
    })
  });
}
function ShellSelectControl({ select }) {
  const labelId = React.useId();
  return /* @__PURE__ */ jsxs("div", {
    className: "flex min-w-[220px] flex-col gap-1",
    children: [
      /* @__PURE__ */ jsx("span", {
        id: labelId,
        className: "text-muted-foreground text-xs",
        children: select.label
      }),
      /* @__PURE__ */ jsxs(Select, {
        value: select.value,
        onValueChange: select.onChange,
        children: [
          /* @__PURE__ */ jsx(SelectTrigger, {
            "aria-labelledby": labelId,
            className: "w-full",
            children: /* @__PURE__ */ jsx(SelectValue, {
              placeholder: select.placeholder ?? select.label
            })
          }),
          /* @__PURE__ */ jsx(SelectContent, {
            children: select.options.map((o) => /* @__PURE__ */ jsx(SelectItem, {
              value: o.value,
              children: o.label
            }, o.value))
          })
        ]
      })
    ]
  });
}

// src/components/shell/WorkspaceSidebar.tsx
import { Settings } from "lucide-react";
import {
  Sidebar,
  SidebarContent,
  SidebarFooter,
  SidebarHeader,
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  SidebarRail
} from "@contractspec/lib.ui-kit-web/ui/sidebar";
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
function WorkspaceSidebar({
  modules,
  activeModuleId,
  onModuleChange,
  sidebarFooter
}) {
  return /* @__PURE__ */ jsxs2(Sidebar, {
    children: [
      /* @__PURE__ */ jsx2(SidebarRail, {}),
      /* @__PURE__ */ jsx2(SidebarHeader, {}),
      /* @__PURE__ */ jsx2(SidebarContent, {
        children: /* @__PURE__ */ jsxs2(SidebarMenu, {
          children: [
            modules.map((m) => /* @__PURE__ */ jsx2(SidebarMenuItem, {
              children: /* @__PURE__ */ jsxs2(SidebarMenuButton, {
                isActive: m.id === activeModuleId,
                onClick: () => onModuleChange(m.id),
                children: [
                  m.icon,
                  /* @__PURE__ */ jsx2("span", {
                    children: m.label
                  }),
                  m.badge != null ? /* @__PURE__ */ jsx2("span", {
                    className: "text-muted-foreground ml-auto text-xs",
                    children: String(m.badge)
                  }) : null
                ]
              })
            }, m.id)),
            /* @__PURE__ */ jsx2(SidebarMenuItem, {
              children: /* @__PURE__ */ jsxs2(SidebarMenuButton, {
                isActive: activeModuleId === "settings",
                onClick: () => onModuleChange("settings"),
                children: [
                  /* @__PURE__ */ jsx2(Settings, {
                    className: "size-4"
                  }),
                  /* @__PURE__ */ jsx2("span", {
                    children: "Settings"
                  })
                ]
              })
            })
          ]
        })
      }),
      /* @__PURE__ */ jsx2(SidebarFooter, {
        children: sidebarFooter
      })
    ]
  });
}

// src/components/shell/WorkspaceProjectShellLayout.tsx
import { cn } from "@contractspec/lib.ui-kit-web/ui/utils";
import {
  SidebarProvider,
  SidebarInset
} from "@contractspec/lib.ui-kit-web/ui/sidebar";
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
function WorkspaceProjectShellLayout({
  title,
  subtitle,
  workspaceSelect,
  projectSelect,
  environmentSelect,
  stickyHeaderOffsetPx,
  headerRight,
  modules,
  activeModuleId,
  onModuleChange,
  sidebarFooter,
  assistant,
  children,
  className
}) {
  return /* @__PURE__ */ jsxs3(SidebarProvider, {
    children: [
      /* @__PURE__ */ jsx3(WorkspaceSidebar, {
        modules,
        activeModuleId,
        onModuleChange,
        sidebarFooter
      }),
      /* @__PURE__ */ jsx3(SidebarInset, {
        children: /* @__PURE__ */ jsxs3("div", {
          className: cn("bg-background min-h-svh", className),
          children: [
            /* @__PURE__ */ jsx3(WorkspaceHeader, {
              title,
              subtitle,
              workspaceSelect,
              projectSelect,
              environmentSelect,
              stickyHeaderOffsetPx,
              headerRight
            }),
            /* @__PURE__ */ jsx3("main", {
              className: "m-4",
              children
            })
          ]
        })
      }),
      assistant
    ]
  });
}

// src/components/shell/WorkspaceShellRenderer.tsx
import { SidebarProvider as SidebarProvider2 } from "@contractspec/lib.ui-kit-web/ui/sidebar";
import {
  BundleProvider,
  BundleRenderer
} from "@contractspec/lib.surface-runtime/react";
import { jsx as jsx4 } from "react/jsx-runtime";
"use client";
function WorkspaceShellRenderer({
  plan,
  title,
  subtitle,
  workspaceSelect,
  projectSelect,
  environmentSelect,
  stickyHeaderOffsetPx,
  headerRight,
  modules,
  activeModuleId,
  onModuleChange,
  sidebarFooter,
  assistant,
  children,
  className
}) {
  const slotContent = {
    header: /* @__PURE__ */ jsx4(WorkspaceHeader, {
      title,
      subtitle,
      workspaceSelect,
      projectSelect,
      environmentSelect,
      stickyHeaderOffsetPx,
      headerRight
    }),
    sidebar: /* @__PURE__ */ jsx4(WorkspaceSidebar, {
      modules,
      activeModuleId,
      onModuleChange,
      sidebarFooter
    }),
    primary: /* @__PURE__ */ jsx4("main", {
      className: className ? `m-4 ${className}` : "m-4",
      children
    })
  };
  if (assistant != null) {
    slotContent.assistant = assistant;
  }
  return /* @__PURE__ */ jsx4(SidebarProvider2, {
    children: /* @__PURE__ */ jsx4(BundleProvider, {
      plan,
      children: /* @__PURE__ */ jsx4("div", {
        className: "bg-background min-h-svh",
        children: /* @__PURE__ */ jsx4(BundleRenderer, {
          slotContent
        })
      })
    })
  });
}
export {
  WorkspaceSidebar,
  WorkspaceShellRenderer,
  WorkspaceProjectShellLayout,
  WorkspaceHeader
};
