'use client' import { useState, useEffect } from 'react' import Link from 'next/link' import Image from 'next/image' import { usePathname } from 'next/navigation' import { cn } from '@/lib/utils' import { Button } from '@/components/ui/button' import { useAuth } from '@/lib/hooks/use-auth' import { useSidebarStore } from '@/lib/stores/sidebar-store' import { useCreateDialogs } from '@/lib/hooks/use-create-dialogs' import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from '@/components/ui/tooltip' import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu' import { ThemeToggle } from '@/components/common/ThemeToggle' import { LanguageToggle } from '@/components/common/LanguageToggle' import { TranslationKeys } from '@/lib/locales' import { useTranslation } from '@/lib/hooks/use-translation' import { Separator } from '@/components/ui/separator' import { Book, Search, Mic, Bot, Shuffle, Settings, LogOut, ChevronLeft, Menu, FileText, Plus, Wrench, Command, } from 'lucide-react' const getNavigation = (t: TranslationKeys) => [ { title: t.navigation.collect, items: [ { name: t.navigation.sources, href: '/sources', icon: FileText }, ], }, { title: t.navigation.process, items: [ { name: t.navigation.notebooks, href: '/notebooks', icon: Book }, { name: t.navigation.askAndSearch, href: '/search', icon: Search }, ], }, { title: t.navigation.create, items: [ { name: t.navigation.podcasts, href: '/podcasts', icon: Mic }, ], }, { title: t.navigation.manage, items: [ { name: t.navigation.models, href: '/models', icon: Bot }, { name: t.navigation.transformations, href: '/transformations', icon: Shuffle }, { name: t.navigation.settings, href: '/settings', icon: Settings }, { name: t.navigation.advanced, href: '/advanced', icon: Wrench }, ], }, ] as const type CreateTarget = 'source' | 'notebook' | 'podcast' export function AppSidebar() { const { t } = useTranslation() const navigation = getNavigation(t) const pathname = usePathname() const { logout } = useAuth() const { isCollapsed, toggleCollapse } = useSidebarStore() const { openSourceDialog, openNotebookDialog, openPodcastDialog } = useCreateDialogs() const [createMenuOpen, setCreateMenuOpen] = useState(false) const [isMac, setIsMac] = useState(true) // Default to Mac for SSR // Detect platform for keyboard shortcut display useEffect(() => { setIsMac(navigator.platform.toLowerCase().includes('mac')) }, []) const handleCreateSelection = (target: CreateTarget) => { setCreateMenuOpen(false) if (target === 'source') { openSourceDialog() } else if (target === 'notebook') { openNotebookDialog() } else if (target === 'podcast') { openPodcastDialog() } } return (
{isCollapsed ? (
Open Notebook
) : ( <>
{t.common.appName} {t.common.appName}
)}
{/* Command Palette hint */} {!isCollapsed && (
{t.common.quickActions} {isMac ? : Ctrl+}K

{t.common.quickActionsDesc}

)}
{isCollapsed ? ( <>
{t.common.theme}
{t.common.language}
) : ( <> )}
{isCollapsed ? ( {t.common.signOut} ) : ( )}
) }