"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useCallback, useState } from "react";
import { cn } from "@stigmer/theme";
import { DiffViewer } from "./DiffViewer";
import { DiffFileList } from "./DiffFileList";
import { DiffSummary } from "./DiffSummary";
/**
 * Composed multi-file diff view with file list and per-file unified diff.
 *
 * Layout: summary bar at top, file list as a horizontal scrollable bar,
 * and the full unified diff for the selected file below. Designed to
 * work within a dialog or a detail page panel.
 *
 * Zero Console dependencies — safe for platform builder embedding.
 *
 * @example
 * ```tsx
 * const diff = computeMultiFileDiff(oldFiles, newFiles);
 * <MultiFileDiffView diff={diff} />
 * ```
 */
export function MultiFileDiffView({ diff, initialSelectedPath, className, }) {
    const [selectedPath, setSelectedPath] = useState(initialSelectedPath ?? diff.files[0]?.path ?? null);
    const handleSelect = useCallback((path) => {
        setSelectedPath(path);
    }, []);
    const hunks = selectedPath ? diff.getDiff(selectedPath) : [];
    if (diff.files.length === 0) {
        return (_jsxs("div", { role: "status", className: cn("flex flex-col items-center gap-2 py-12 text-center", className), children: [_jsx(NoDiffIcon, { className: "size-8 text-muted-foreground-faint" }), _jsx("p", { className: "text-sm text-muted-foreground", children: "No differences found" }), _jsx("p", { className: "text-xs text-muted-foreground-subtle", children: "These two versions have identical content." })] }));
    }
    return (_jsxs("div", { className: cn("flex flex-col gap-3", className), children: [_jsx(DiffSummary, { fileCount: diff.files.length, additions: diff.totalAdditions, deletions: diff.totalDeletions }), diff.files.length > 1 && (_jsx("div", { className: "overflow-hidden rounded-lg border border-border", children: _jsx(DiffFileList, { files: diff.files, selectedPath: selectedPath, onSelect: handleSelect }) })), _jsx(DiffViewer, { hunks: hunks, filePath: selectedPath ?? undefined })] }));
}
// ---------------------------------------------------------------------------
// Icons
// ---------------------------------------------------------------------------
function NoDiffIcon({ className }) {
    return (_jsxs("svg", { className: className, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M8 3v10M3 8h10" }), _jsx("circle", { cx: "8", cy: "8", r: "7" })] }));
}
//# sourceMappingURL=MultiFileDiffView.js.map