import { useEffect, useMemo, useRef, useState, type DragEvent, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react'; import { ArrowDownWideNarrow, Bell, CalendarClock, Cast, Check, ChevronDown, Clapperboard, CircleHelp, Clock, ClipboardCopy, Copy, Crosshair, Film, FileImage, Folder, FolderInput, FolderTree, GripVertical, Hash, HardDrive, Info, LayoutDashboard, LayoutGrid, Library, ListVideo, MonitorPlay, Music, Plus, Pencil, Play, Radio, RefreshCw, Search, Server, Settings, Shuffle, Sparkles, Stethoscope, Timer, Trash2, TriangleAlert, Tv } from 'lucide-react'; import chicoryMarkUrl from '../../design-system/assets/chicory-mark.svg'; import { ChannelBuilderScreen } from './builder/ChannelBuilder'; import { ChannelEditScreen } from './screens/ChannelEditScreen'; import { SettingsScreen } from './screens/SettingsScreen'; import { navigateToPath } from './routing'; import { Badge, Button, Card, Checkbox, ChannelLogo, IconButton, Input, NavItem, NavSection, ProgressBar, Select, Spinner, Stat, StatusDot, Switch, Tabs } from './components'; import { useChannelsQuery, useChannelsScreenQuery, bulkDeleteChannels, bulkMoveChannelsToGroup, bulkRenumberChannels, deleteChannel, messageFromError, addScheduleItem, deleteScheduleItem, resetAllPlayouts, replaceScheduleItems, usePlayoutsScreenQuery, useScheduleScreenQuery, useDashboardHealthQuery, useDashboardQuery, useDashboardVersionQuery, defaultGuideWindowStart, GUIDE_WINDOW_MS, useGuideScreenQuery, useLibrariesScreenQuery, type ChannelState, type ChannelSummary, type ChannelGuideChannel, type ChannelGuideProgramme, type DashboardChannel, type SchedulePickerData, type DashboardChannelState, type DashboardHealthQueryState, type LibraryScanStatus, type MediaSource, type MediaSourceLibrary, type MediaCollection, type ProgramSchedule, type ProgramScheduleItem, type PlayoutItem, type PlayoutSummary, type ScheduleItemRequest } from './api'; import { applyDesignSystemTheme, designSystemThemes, getStoredDesignSystemTheme, type DesignSystemThemeId } from './designSystem'; type ScreenId = | 'dashboard' | 'channels' | 'builder' | 'editChannel' | 'guide' | 'schedules' | 'playouts' | 'collections' | 'libraries' | 'settings'; interface ScreenRoute { id: ScreenId; path: string; label: string; title: string; kicker: string; description: string; icon: ReactNode; primaryAction: string; placeholder: string; badge?: number; // Screens that own linkable sub-sections (e.g. /app/settings/streaming) opt in here; // the sub-path is otherwise unowned and 404s (see routeFromLocation). allowSubPaths?: boolean; } const routes: ScreenRoute[] = [ { id: 'dashboard', path: '/app', label: 'Dashboard', title: 'Dashboard', kicker: 'Overview', description: 'On-air status, health checks, and recent server activity.', icon: