import { useEffect, useState } from 'react' import { AppShell, ActionIcon, Box, Burger, Drawer, Group, NavLink, Stack, Text, Tooltip, rem, useMantineTheme, } from '@mantine/core' import { useDisclosure, useMediaQuery } from '@mantine/hooks' import { SidebarSimpleIcon } from '@phosphor-icons/react' import { NavLink as RouterNavLink, Outlet, useLocation, useMatches } from 'react-router' import { pageRoutes } from '../routes.ts' import type { PageRoute } from '../routes.ts' import classes from './BasicLayout.module.css' import { SiteSettings } from './SiteSettings.tsx' const collapsedNavbarWidth = rem(64) type NavigationProps = { onNavigate?: () => void collapsed?: boolean routes?: PageRoute[] parentPath?: string } function NavigationItem({ route, parentPath, collapsed, onNavigate, }: { route: PageRoute parentPath: string collapsed: boolean onNavigate?: () => void }) { const matches = useMatches() const active = matches.some((match) => match.id === route.id) const selected = matches.at(-1)?.id === route.id const [opened, setOpened] = useState(active) if (!route.handle) return null const { title: label, icon: Icon } = route.handle const to = !route.path ? parentPath : route.path.startsWith('/') ? route.path : `${parentPath.replace(/\/$/, '')}/${route.path}` const hasChildren = route.children?.some((child) => child.handle) const sharedProps = { label, noWrap: true, p: 'xs', 'aria-label': label, leftSection: