import { CheckCircle2, AlertTriangle, AlertCircle, CircleDashed, type LucideIcon, } from 'lucide-react' /** * Shared status vocabulary for the SystemHealth blocks (768w.16.8.2). * * Every health signal collapses to one of four tones. The tone is always * encoded REDUNDANTLY — a colored dot AND an icon AND a text label — so the * signal never depends on color alone (accessibility), matching the rest of the * @startsimpli/ui dashboard kit's static semantic palette. */ export type HealthStatus = 'ok' | 'warn' | 'critical' | 'neutral' export interface HealthTone { /** Default human label for the tone (composers may override). */ label: string /** Solid dot / bar fill. */ dot: string /** Foreground text for the tone. */ text: string /** Soft background for pills / accents. */ softBg: string /** Left-accent border color for HealthCard. */ border: string /** The lucide icon that stands in for the tone. */ Icon: LucideIcon } export const HEALTH_TONE: Record = { ok: { label: 'Healthy', dot: 'bg-emerald-500', text: 'text-emerald-700', softBg: 'bg-emerald-50', border: 'border-l-emerald-500', Icon: CheckCircle2, }, warn: { label: 'Needs attention', dot: 'bg-amber-500', text: 'text-amber-700', softBg: 'bg-amber-50', border: 'border-l-amber-500', Icon: AlertTriangle, }, critical: { label: 'Critical', dot: 'bg-red-500', text: 'text-red-700', softBg: 'bg-red-50', border: 'border-l-red-500', Icon: AlertCircle, }, neutral: { label: 'No data', dot: 'bg-gray-400', text: 'text-gray-600', softBg: 'bg-gray-50', border: 'border-l-gray-300', Icon: CircleDashed, }, } const SEVERITY: Record = { neutral: 0, ok: 1, warn: 2, critical: 3 } /** * Roll several signals up to the single worst tone — the accent a HealthCard * shows. `critical` beats `warn` beats `ok`; `neutral` (no data) only wins when * there is nothing else to report. */ export function worstStatus(statuses: HealthStatus[]): HealthStatus { if (statuses.length === 0) return 'neutral' return statuses.reduce((worst, s) => (SEVERITY[s] > SEVERITY[worst] ? s : worst), 'neutral') }