"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { memo, useCallback } from "react";
import { cn } from "@stigmer/theme";
import { FileReviewCard } from "./FileReviewCard.js";
/**
 * The composer-docked decision surface for pending file reviews: renders each
 * AWAITING_REVIEW {@link FileChangeSet} as an interactive {@link FileReviewCard}
 * decision bar, pinned in the fixed strip above the composer.
 *
 * WHY DOCKED, NOT IN-THREAD. The transcript's stamped edit rows are
 * observational — they show what changed, badged with the live review state —
 * but a *decision* the agent is blocked on must never scroll out of view. An
 * in-thread card does exactly that on a long conversation. Docking the bar to
 * the composer keeps the pending decision visible regardless of scroll
 * position, matching the shape of Cursor's own review bar. Once decided, the
 * dock empties and the thread's read-only record (and the rows' Kept/Discarded
 * badges) carry the history.
 *
 * This placement deliberately diverges from tool approvals, which stay inline
 * on their rows (with `ApprovalPeekBar` as the scroll backstop): an approval is
 * call-anchored — "run *this* command" — while a file review is a turn-scoped
 * aggregate over many calls, with no single row that owns it.
 *
 * The expanded per-file body is height-capped with internal scroll: a set that
 * needs per-file attention starts expanded (see {@link FileReviewCard}), and an
 * unconstrained list in a fixed strip would swallow the viewport.
 *
 * Purely presentational — the data and decision routing live in
 * `useSessionConversation` (headless-first, DD-003). `SessionViewer` wires it
 * in by default; platform builders composing a custom layout mount it over the
 * same seam.
 *
 * @example
 * ```tsx
 * const conv = useSessionConversation(sessionId);
 * <FileReviewDock
 *   changeSets={conv.fileChangeSets}
 *   onSubmit={conv.submitFileDecision}
 *   submittingDecisionKeys={conv.submittingFileDecisionKeys}
 *   decisionErrors={conv.fileDecisionErrors}
 * />
 * ```
 */
export function FileReviewDock({ changeSets, onSubmit, submittingDecisionKeys, decisionErrors, className, }) {
    if (changeSets.length === 0)
        return null;
    return (_jsx("div", { role: "region", "aria-label": "File changes awaiting review", "data-cursor-target": "file-review-dock", className: cn("border-t border-border-muted", className), children: _jsx("div", { className: "max-h-[40vh] space-y-2 overflow-y-auto px-4 py-2", children: changeSets.map((changeSet) => (_jsx(DockedChangeSet, { changeSet: changeSet, onSubmit: onSubmit, submittingDecisionKeys: submittingDecisionKeys, decisionErrors: decisionErrors }, changeSet.id))) }) }));
}
/**
 * One docked set — binds the set id into the card's `(action, options)` submit
 * signature with a stable callback so `FileReviewCard`'s `React.memo` holds
 * across unrelated stream frames.
 */
const DockedChangeSet = memo(function DockedChangeSet({ changeSet, onSubmit, submittingDecisionKeys, decisionErrors, }) {
    const handleSubmit = useCallback((action, options) => {
        onSubmit(changeSet.id, action, options);
    }, [onSubmit, changeSet.id]);
    return (_jsx(FileReviewCard, { fileChangeSet: changeSet, onSubmit: handleSubmit, submittingDecisionKeys: submittingDecisionKeys, decisionErrors: decisionErrors, 
        // The transcript's stamped edit rows show every diff in place, so the
        // docked card renders the compact file list — the decision surface never
        // duplicates the thread's diffs.
        showDiffs: false }));
});
//# sourceMappingURL=FileReviewDock.js.map