"use client";
import React, { useState, useEffect } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import {
PanelLeft, Home, Cpu, Zap, Atom, BarChart3, PlayCircle, Lightbulb,
Replace, Cog, Scaling, Box, Share2, Wrench, Moon, Sun, BrainCircuit, Globe,
ScatterChart, IterationCw, MessageSquare, Signal, SlidersHorizontal, Monitor, TrendingUp, Wand2, Rocket, ArrowRight, Settings2, ListChecks, Database
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Toaster } from "@/components/ui/toaster";
import { cn } from "@/lib/utils";
import {
SidebarProvider,
Sidebar,
SidebarHeader,
SidebarContent,
SidebarFooter,
SidebarTrigger,
SidebarInset,
SidebarMenu,
SidebarMenuItem,
SidebarMenuButton,
SidebarGroup,
SidebarGroupLabel,
useSidebar,
} from "@/components/ui/sidebar";
import FloatingMiniAdvisor from "@/components/FloatingMiniAdvisor";
import { AdvisorProvider } from "@/components/mini-hs-qnn-advisor";
const mainNavItems = [
{ href: "/deep-learning/dataset-architect", label: "🔥 Dataset Architect", icon: Database },
{ href: "/deep-learning/introduction", label: "Introduction", icon: ArrowRight },
{ href: "/deep-learning/dashboard", label: "Dashboard", icon: Home },
{ href: "/deep-learning/ai-architect", label: "AI Architect", icon: BrainCircuit },
{ href: "/deep-learning/data-portal", label: "Data Portal", icon: Globe },
];
// DEBUG: Check if this file is being loaded
console.log("AppLayout loaded with mainNavItems:", mainNavItems.length);
const advancedToolsNavItems = [
{ href: "/deep-learning/zpe-flow-analysis", label: "ZPE Flow Analysis", icon: SlidersHorizontal },
{ href: "/deep-learning/zpe-flow", label: "HS-QNN Advisor", icon: BrainCircuit },
{ href: "/deep-learning/quantum-noise", label: "Quantum Noise", icon: Atom },
{ href: "/deep-learning/rf-generator", label: "RF Generator", icon: Signal },
{ href: "/deep-learning/ai-analysis", label: "AI Assistant", icon: MessageSquare },
{ href: "/deep-learning/cloud-gpu", label: "Cloud GPU Connect", icon: Settings2 },
];
const visNavItems = [
{ href: "/vis/bloch-sphere", label: "Bloch Sphere", icon: Globe },
{ href: "/vis/dynamic-formation", label: "Dynamic Formation", icon: IterationCw },
{ href: "/vis/zpe-particle-simulation", label: "ZPE Particle Sim", icon: ScatterChart },
];
const aiFlowsNavItems = [
{ href: "/ai", label: "AI Flows Hub", icon: Rocket },
{ href: "/ai/implement-zpe", label: "Simulate ZPE", icon: Lightbulb },
{ href: "/ai/approximate-zpe", label: "Approximate Flow", icon: Replace },
{ href: "/ai/adapt-zpe", label: "Adapt ZPE", icon: Cog },
{ href: "/ai/show-scaled-output", label: "Scaled Output", icon: Scaling },
{ href: "/ai/quantize-model", label: "Quantize Model", icon: Box },
{ href: "/ai/extract-components", label: "Extract Components", icon: Share2 },
{ href: "/ai/configure-model", label: "Configure Model", icon: Wrench },
{ href: "/ai/invoke-llm", label: "Generic LLM", icon: Wand2 },
];
interface NavItem {
href: string;
label: string;
icon: React.ElementType;
}
const NavLinkWrapper = ({
item,
pathname,
onClick,
}: {
item: NavItem;
pathname: string;
onClick: () => void;
}) => {
const Icon = item.icon;
const isActive =
(pathname === item.href ||
(pathname.startsWith(item.href + "/") &&
item.href !== "/dashboard" &&
item.href !== "/" &&
item.href !== "/ai")) ||
(pathname === "/" && item.href === "/introduction") ||
(pathname === "/ai" && item.href === "/ai");
return (
{item.label}
);
};
const AppSidebarContent = () => {
const pathname = usePathname();
const { isMobile, setOpenMobile } = useSidebar();
const [isDarkMode, setIsDarkMode] = useState(true);
useEffect(() => {
const storedTheme = localStorage.getItem("theme");
if (storedTheme) {
setIsDarkMode(storedTheme === "dark");
} else {
setIsDarkMode(window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true);
}
}, []);
useEffect(() => {
if (isDarkMode) {
document.documentElement.classList.add("dark");
localStorage.setItem("theme", "dark");
} else {
document.documentElement.classList.remove("dark");
localStorage.setItem("theme", "light");
}
}, [isDarkMode]);
const toggleDarkMode = () => setIsDarkMode(prev => !prev);
const handleLinkClick = () => {
if (isMobile) {
setOpenMobile(false);
}
};
const renderNavSection = (title: string, items: NavItem[]) => (
{title}
{items.map((item) => (
))}
);
return (
<>
Quantum Weaver
{renderNavSection("Main", mainNavItems)}
{renderNavSection("Advanced Tools", advancedToolsNavItems)}
{renderNavSection("Visualizations", visNavItems)}
{renderNavSection("AI Flows", aiFlowsNavItems)}
{isDarkMode ? : }
{isDarkMode ? "Light Mode" : "Dark Mode"}
>
);
};
export default function AppLayout({ children }: { children: React.ReactNode }) {
const [isDarkMode, setIsDarkMode] = useState(true);
useEffect(() => {
const storedTheme = localStorage.getItem("theme");
if (storedTheme) {
setIsDarkMode(storedTheme === "dark");
} else {
setIsDarkMode(window.matchMedia?.("(prefers-color-scheme: dark)").matches ?? true);
}
}, []);
useEffect(() => {
if (isDarkMode) {
document.documentElement.classList.add("dark");
localStorage.setItem("theme", "dark");
} else {
document.documentElement.classList.remove("dark");
localStorage.setItem("theme", "light");
}
}, [isDarkMode]);
return (
{children}
{/* FloatingMiniAdvisor overlays all pages */}
{}}
onSaveConfig={() => {}}
defaultMinimized={false}
/>
);
}