/* ============================================ SHARED COMPONENTS — Sidebar, Topbar, Card primitives ============================================ */ const { useState, useEffect, useRef, useMemo, useCallback } = React; // Expose hooks globally so screen files can use bare names Object.assign(window, { useState: React.useState, useEffect: React.useEffect, useRef: React.useRef, useMemo: React.useMemo, useCallback: React.useCallback }); /* ----- NAV STRUCTURE ----- */ const NAV = [ { key: "workspace", label: "Workspace", icon: "Workspace" }, { key: "chat-history", label: "Chat History", icon: "History" }, { key: "content", label: "Content Management", icon: "Content", children: [ { key: "knowledge", label: "Knowledge Management" }, { key: "ingestion", label: "Ingestion Dashboard" }, { key: "inspector", label: "Document Inspector" }] }, { key: "governance", label: "Governance", icon: "Governance", children: [ { key: "analytics", label: "Analytics & Audit" }, { key: "cost", label: "Cost Tracking" }, { key: "system-health", label: "System Health" }, { key: "users", label: "User Management" }, { key: "prompt-tuning", label: "System Configuration" }] }]; const SCREEN_META = { "login": { title: "Sign In", crumbs: ["Account", "Sign In"] }, "profile": { title: "User Profile", crumbs: ["Account", "Profile"] }, "workspace": { title: "Workspace", crumbs: ["Workspace"] }, "chat-history": { title: "Chat History", crumbs: ["Chat History"] }, "knowledge": { title: "Knowledge Management", crumbs: ["Content Management", "Knowledge"] }, "ingestion": { title: "Ingestion Dashboard", crumbs: ["Content Management", "Ingestion"] }, "inspector": { title: "Document Inspector", crumbs: ["Content Management", "Inspector"] }, "analytics": { title: "Analytics & Audit", crumbs: ["Governance", "Analytics"] }, "cost": { title: "Cost Tracking", crumbs: ["Governance", "Cost"] }, "system-health": { title: "System Health", crumbs: ["Governance", "System Health"] }, "users": { title: "User Management", crumbs: ["Governance", "Users"] }, "prompt-tuning": { title: "System Configuration", crumbs: ["Governance", "System Configuration"] } }; /* ----- SIDEBAR ----- */ function _initials(name) { if (!name) return "?"; return name.trim().split(/\s+/).map(s => s[0] || "").slice(0, 2).join("").toUpperCase(); } function Sidebar({ active, onNavigate, user, onLogout }) { const [expanded, setExpanded] = useState(() => { // auto-expand parent of active route const init = new Set(["content", "governance"]); return init; }); const toggle = (key) => { setExpanded((prev) => { const next = new Set(prev); if (next.has(key)) next.delete(key);else next.add(key); return next; }); }; return ( ); } /* ----- TOPBAR ----- */ function Topbar({ screen, rightSlot, onNavigate }) { const meta = SCREEN_META[screen] || { crumbs: [screen] }; return (
{meta.crumbs.map((c, i) => {i > 0 && /} {c} )}
{rightSlot}
⌘K
); } /* ----- SHELL ----- */ function Shell({ screen, onNavigate, children, topbarRight, user, onLogout }) { return (
{children}
); } /* ----- Reusable bits ----- */ function Card({ title, subtitle, right, children, bodyFlush, style, className = "" }) { return (
{(title || right) &&
{title &&

{title}

} {subtitle &&

{subtitle}

}
{right}
}
{children}
); } function Badge({ kind = "neutral", children, dot = true }) { return ( {dot && } {children} ); } function Checkbox({ checked, onChange }) { return (