"use client";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { cn } from "@stigmer/theme";
import { useSessionWriteBacks } from "../session/useSessionWriteBacks";
import { WriteBackCard } from "./WriteBackCard";
/**
 * Right-sidebar widget that surfaces pull requests created by the
 * platform's incremental git write-back workflow.
 *
 * Write-backs from multiple executions are aggregated and
 * deduplicated by `workspace_entry_name` (latest execution wins),
 * presenting the user with a flat list of PRs — one per workspace
 * entry.
 *
 * Returns `null` when no execution has write-backs, matching the
 * conditional-render pattern of {@link ArtifactsWidget} and
 * {@link ExecutionProgress}.
 *
 * All visual properties flow through `--stgm-*` tokens.  Zero
 * Console dependencies.
 *
 * @example
 * ```tsx
 * const conv = useSessionConversation(sessionId, org);
 *
 * <WriteBacksWidget
 *   executions={[
 *     ...conv.completedExecutions,
 *     ...(conv.activeStreamExecution ? [conv.activeStreamExecution] : []),
 *   ]}
 * />
 * ```
 *
 * @see {@link WriteBackCard} — compact card per write-back
 * @see {@link useSessionWriteBacks} — headless session-level write-back aggregation hook
 * @see {@link useWorkspaceWriteBacks} — headless single-execution write-back extraction hook
 */
export function WriteBacksWidget({ executions, className, }) {
    const { writeBacks, hasWriteBacks, writeBackCount } = useSessionWriteBacks(executions);
    if (!hasWriteBacks)
        return null;
    return (_jsxs("section", { "aria-label": "Pull Requests", className: cn(className), children: [_jsxs("div", { className: "mb-2 flex items-center gap-2", children: [_jsx("h3", { className: "text-sm font-medium text-foreground", children: "Pull Requests" }), _jsx("span", { className: "inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-muted px-1.5 text-xs tabular-nums text-muted-foreground", children: writeBackCount })] }), _jsx("div", { role: "list", className: "space-y-2", children: writeBacks.map((entry) => (_jsx("div", { role: "listitem", children: _jsx(WriteBackCard, { writeBack: entry.writeBack }) }, entry.writeBack.workspaceEntryName))) })] }));
}
//# sourceMappingURL=WriteBacksWidget.js.map