import React from "react"; import { Cpu } from "lucide-react"; import { useTranslation } from "react-i18next"; import type { ServerMetrics } from "@/main-axios.ts"; import { SectionCard } from "@/components/section-card"; interface CpuWidgetProps { metrics: ServerMetrics | null; metricsHistory: ServerMetrics[]; } function Sparkline({ history, current, }: { history: ServerMetrics[]; current: number | null; }) { const points = [ ...history.map((m) => m?.cpu?.percent ?? 0), current ?? 0, ].slice(-20); if (points.length < 2) return null; const w = 300; const h = 48; const max = Math.max(...points, 1); const coords = points.map((v, i) => { const x = (i / (points.length - 1)) * w; const y = h - (v / max) * h; return `${x},${y}`; }); const d = `M ${coords.join(" L ")}`; const fill = `M 0,${h} L ${coords.join(" L ")} L ${w},${h} Z`; return (