"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { memo, useState } from "react";
import { cn } from "@stigmer/theme";
import { FileKindBadge, FileLineStats } from "./FileReviewAtoms.js";
import { FilePathLink } from "./FilePathLink.js";
/**
 * The live "N files changed so far" strip for a turn that is still running.
 *
 * WHY IT EXISTS. The transcript streams per-edit tool rows, but a change made by
 * a shell command (a `sed`, a build step) has no tool row, and there is no
 * running net-of-many-edits rollup until the turn ends. This bar fills that gap:
 * a compact, NON-INTERACTIVE count of the workspace delta accumulating during
 * the turn, pinned above the composer where the {@link FileReviewDock} will later
 * appear. The two are mutually exclusive per turn (progress shows while CAPTURING;
 * the dock shows once AWAITING_REVIEW), so the bar hands off cleanly to the dock.
 *
 * NEVER A DECISION SURFACE. Progress is non-authoritative and carries no file
 * bodies — it is never reviewable or decidable. The reviewed diff is the
 * turn-boundary candidate ({@link FileReviewDock} / the stamped transcript rows).
 * A secret-like path is surfaced by name with its counts withheld (zeroed), so
 * `FileLineStats` renders nothing for it.
 *
 * A11Y. Only the summary count is an `aria-live` region — the per-file list is
 * not — so a screen reader hears "3 files changing" as the count moves, not a
 * per-file barrage on every ~2s refresh.
 *
 * Purely presentational (headless-first, DD-003): the data lives in
 * `useSessionConversation().fileChangeProgress`. `SessionViewer` mounts it above
 * the dock by default.
 *
 * @example
 * ```tsx
 * const conv = useSessionConversation(sessionId);
 * <FileChangeProgressBar progress={conv.fileChangeProgress} />
 * ```
 */
export const FileChangeProgressBar = memo(function FileChangeProgressBar({ progress, className, }) {
    const [expanded, setExpanded] = useState(false);
    if (!progress || progress.filesChanged === 0)
        return null;
    const { filesChanged, linesAdded, linesRemoved, entries } = progress;
    const hiddenCount = filesChanged - entries.length;
    return (_jsxs("div", { role: "region", "aria-label": "File changes in progress", "data-cursor-target": "file-change-progress-bar", className: cn("border-t border-border-muted px-4 py-2", className), children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("button", { type: "button", onClick: () => setExpanded((prev) => !prev), "aria-expanded": expanded, className: "flex min-w-0 flex-1 items-center gap-2 text-left text-xs text-muted-foreground hover:text-foreground", children: [_jsx("span", { "aria-hidden": "true", className: cn("shrink-0 transition-transform", expanded && "rotate-90"), children: "\u25B8" }), _jsxs("span", { "aria-live": "polite", className: "min-w-0 truncate", children: [filesChanged, " ", filesChanged === 1 ? "file" : "files", " changing\u2026"] })] }), _jsx(FileLineStats, { linesAdded: linesAdded, linesRemoved: linesRemoved })] }), expanded && (_jsxs("ul", { className: "mt-2 max-h-[30vh] space-y-1 overflow-y-auto", children: [entries.map((entry) => {
                        const path = entry.pathAfter || entry.pathBefore;
                        return (_jsxs("li", { className: "flex items-center gap-2", children: [_jsx(FileKindBadge, { kind: entry.kind }), _jsx(FilePathLink, { path: path, dirDisplay: "dim", className: "min-w-0 flex-1 text-xs" }), _jsx(FileLineStats, { linesAdded: entry.linesAdded, linesRemoved: entry.linesRemoved })] }, path));
                    }), hiddenCount > 0 && (_jsxs("li", { className: "text-xs text-muted-foreground-faint", children: ["\u2026 and ", hiddenCount, " more"] }))] }))] }));
});
//# sourceMappingURL=FileChangeProgressBar.js.map