'use client';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
 * DoctorSummary — spec 097, task-46.
 *
 * Renders an inline DoctorReport summary on the contributor view: counts
 * of ok/warn/fail and per-diagnostic detail. Pure presentation; data
 * comes via props.
 */
import { CheckCircle2, AlertTriangle, XCircle, Stethoscope } from 'lucide-react';
import { Skeleton } from '../ui/skeleton.js';
import { DiagnosticStatus } from '../../../../../packages/core/src/domain/generated/output.js';
export function DoctorSummary({ report, loading }) {
    return (_jsxs("section", { className: "flex flex-col gap-3", "data-testid": "doctor-summary", "aria-label": "Environment diagnostic summary", children: [_jsxs("header", { className: "flex items-center gap-2", children: [_jsx(Stethoscope, { className: "text-primary size-5", "aria-hidden": true }), _jsx("h2", { className: "text-lg font-semibold", children: "Environment health" })] }), loading || !report ? (_jsx(LoadingState, {})) : (_jsxs(_Fragment, { children: [_jsx(Counts, { summary: report.summary }), _jsx("ul", { className: "flex flex-col divide-y rounded-lg border", "data-testid": "doctor-summary-list", children: report.results.map((r) => (_jsx(DiagnosticRow, { result: r }, r.name))) })] }))] }));
}
function Counts({ summary }) {
    return (_jsxs("div", { className: "flex flex-wrap gap-4 text-sm", "data-testid": "doctor-summary-counts", children: [_jsxs("span", { className: "inline-flex items-center gap-1.5", "data-testid": "doctor-summary-ok", children: [_jsx(CheckCircle2, { className: "size-4 text-emerald-600", "aria-hidden": true }), _jsx("span", { className: "font-medium", children: summary.ok }), _jsx("span", { className: "text-muted-foreground", children: "ok" })] }), _jsxs("span", { className: "inline-flex items-center gap-1.5", "data-testid": "doctor-summary-warn", children: [_jsx(AlertTriangle, { className: "size-4 text-amber-600", "aria-hidden": true }), _jsx("span", { className: "font-medium", children: summary.warn }), _jsx("span", { className: "text-muted-foreground", children: "warn" })] }), _jsxs("span", { className: "inline-flex items-center gap-1.5", "data-testid": "doctor-summary-fail", children: [_jsx(XCircle, { className: "size-4 text-red-600", "aria-hidden": true }), _jsx("span", { className: "font-medium", children: summary.fail }), _jsx("span", { className: "text-muted-foreground", children: "fail" })] })] }));
}
function DiagnosticRow({ result }) {
    return (_jsxs("li", { className: "flex items-start gap-3 px-3 py-2", "data-testid": `doctor-row-${result.name}`, children: [_jsx(StatusIcon, { status: result.status }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx("p", { className: "text-sm font-medium", "data-testid": `doctor-row-name-${result.name}`, children: result.name }), _jsx("p", { className: "text-muted-foreground text-xs", children: result.detail }), result.fixHint ? (_jsxs("p", { className: "text-muted-foreground/80 text-xs italic", "data-testid": `doctor-row-fix-${result.name}`, children: ["Hint: ", result.fixHint] })) : null] })] }));
}
function StatusIcon({ status }) {
    if (status === DiagnosticStatus.Ok) {
        return _jsx(CheckCircle2, { className: "mt-0.5 size-4 shrink-0 text-emerald-600", "aria-hidden": true });
    }
    if (status === DiagnosticStatus.Warn) {
        return _jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0 text-amber-600", "aria-hidden": true });
    }
    return _jsx(XCircle, { className: "mt-0.5 size-4 shrink-0 text-red-600", "aria-hidden": true });
}
function LoadingState() {
    return (_jsx("ul", { className: "flex flex-col divide-y rounded-lg border", "data-testid": "doctor-summary-loading", children: ['l1', 'l2', 'l3'].map((k) => (_jsxs("li", { className: "flex items-start gap-3 px-3 py-2", children: [_jsx(Skeleton, { className: "size-4 rounded-full" }), _jsxs("div", { className: "flex flex-1 flex-col gap-1.5", children: [_jsx(Skeleton, { className: "h-3 w-1/3" }), _jsx(Skeleton, { className: "h-2 w-2/3" })] })] }, k))) }));
}
