import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Cpu, MemoryStick, HardDrive, Container, Network } from 'lucide-react'; import { CursorProvider, Cursor, CursorContainer, CursorFollow, } from '@/components/animate-ui/primitives/animate/cursor'; import type { Stats, SystemStats } from './types'; interface ResourceGaugesProps { stats: Stats; systemStats: SystemStats | null; } const formatBytes = (bytes: number): string => { if (bytes === 0) return '0 B'; const k = 1024; const sizes = ['B', 'KB', 'MB', 'GB', 'TB']; const i = Math.floor(Math.log(bytes) / Math.log(k)); return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i]; }; const getValueColor = (value: number, warn = 80, crit = 90): string => { if (value >= crit) return 'text-destructive/80'; if (value >= warn) return 'text-warning/80'; return 'text-stat-value'; }; const getBarColor = (value: number, warn = 80, crit = 90): string => { if (value >= crit) return 'var(--destructive)'; if (value >= warn) return 'var(--warning)'; return 'var(--brand)'; }; function GaugeBar({ value, warn = 80, crit = 90 }: { value: number; warn?: number; crit?: number }) { return (
{systemStats ? `${systemStats.cpu.cores} cores` : '\u00A0'}
{systemStats &&{systemStats ? `${formatBytes(systemStats.memory.used)} / ${formatBytes(systemStats.memory.total)}` : '\u00A0'}
{systemStats &&{systemStats?.disk ? `${formatBytes(systemStats.disk.used)} / ${formatBytes(systemStats.disk.total)}` : '\u00A0'}
{systemStats?.disk &&{stats.exited} exited