/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** * IDSAuditSummary — surfaces the auditor's verdict on a loaded IDS * document. * * Visual language: refined-technical instrument. Restraint over * decoration. The hierarchy is carried by: * - **Severity rails** — 2px tinted left border on each issue row. * - **Codes as machine output** — monospace uppercase chips with * severity-tinted backgrounds; treat them like log lines. * - **Counts strip** — compact `▪ 3 errors ▪ 2 warnings ▪ 0 info` * bar with colored dots, similar to a developer-tool status line. * - **Empty state** — single line with a check icon, no flair. * * Interactions: * - Click counts strip to toggle the issue list. * - Click an individual row to expose its `path` and `detail` payload. * - Filter tabs (All / Errors / Warnings) when any issues exist. */ import React, { useMemo, useState } from 'react'; import { AlertCircle, AlertTriangle, CheckCircle2, ChevronDown, ChevronRight, Info, Loader2, } from 'lucide-react'; import type { IDSAuditIssue, IDSAuditReport, IDSAuditSeverity } from '@ifc-lite/ids'; import { cn } from '@/lib/utils'; interface IDSAuditSummaryProps { report: IDSAuditReport | null; /** True while the auditor is running. */ auditing?: boolean; /** Optional className passed to the outer container. */ className?: string; } type SeverityFilter = 'all' | IDSAuditSeverity; // --------------------------------------------------------------------------- // Severity tokens // --------------------------------------------------------------------------- const SEVERITY_ORDER: Record = { error: 0, warning: 1, info: 2, }; const SEVERITY_TOKENS: Record< IDSAuditSeverity, { label: string; pluralLabel: string; dot: string; rail: string; chipBg: string; chipFg: string; chipBorder: string; icon: React.ReactNode; iconClass: string; } > = { error: { label: 'error', pluralLabel: 'errors', dot: 'bg-red-500', rail: 'border-l-red-500', chipBg: 'bg-red-500/10', chipFg: 'text-red-600 dark:text-red-400', chipBorder: 'border-red-500/30', icon: