import { useRef } from "react"; import { Activity, Check, ChevronDown, ChevronLeft, Globe2, ImageIcon, LogOut, MessageCircle, Mic, Palette, Server, ShieldCheck, SlidersHorizontal, type LucideIcon, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { SIDEBAR_SELECTION_ITEM_CLASS, SidebarSelectionHighlight, } from "@/components/SidebarSelectionHighlight"; import type { SettingsSectionKey } from "@/components/settings/contracts"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { cn } from "@/lib/utils"; const SETTINGS_NAV_ITEMS: Array<{ key: SettingsSectionKey; icon: LucideIcon; fallback: string }> = [ { key: "overview", icon: Activity, fallback: "Overview" }, { key: "appearance", icon: Palette, fallback: "Appearance" }, { key: "models", icon: SlidersHorizontal, fallback: "Models" }, { key: "image", icon: ImageIcon, fallback: "Image" }, { key: "voice", icon: Mic, fallback: "Voice" }, { key: "browser", icon: Globe2, fallback: "Web" }, { key: "channels", icon: MessageCircle, fallback: "Channels" }, { key: "runtime", icon: Server, fallback: "System" }, { key: "advanced", icon: ShieldCheck, fallback: "Security" }, ]; export function standaloneSectionTitle(section: SettingsSectionKey): string { if (section === "apps") return "Apps"; if (section === "automations") return "Automations"; if (section === "skills") return "Skills"; return SETTINGS_NAV_ITEMS.find((item) => item.key === section)?.fallback ?? "Settings"; } export function SettingsSidebar({ activeSection, onSelectSection, onBackToChat, onLogout, hostChromeInset, }: { activeSection: SettingsSectionKey; onSelectSection: (section: SettingsSectionKey) => void; onBackToChat: () => void; onLogout?: () => void; hostChromeInset?: boolean; }) { const { t } = useTranslation(); const activeNavItemRef = useRef(null); const activeItem = SETTINGS_NAV_ITEMS.find((item) => item.key === activeSection) ?? SETTINGS_NAV_ITEMS[0]; const ActiveIcon = activeItem.icon; const activeLabel = t(`settings.nav.${activeItem.key}`, { defaultValue: activeItem.fallback, }); return ( ); }