import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Box, Text } from "ink";
import { ActivityIndicator } from "./ActivityIndicator.js";
import { toolTonePalette } from "../transcript/tool-presentation.js";
import { formatTokenCount } from "../terminal-history-format.js";
import { DOWN_ARROW } from "../constants/figures.js";
export function ChatStatusRow({ visible, activityVisible, stallStatusVisible, doneStatus, columns, theme, activityPhase, elapsedMs, runStartRef, thinkingMs, isThinking, thinkingLevel, tokenEstimate, charCountRef, realTokensAccumRef, userMessage, activeToolNames, retryInfo, planDone, planTotal, renderMarkdown, formatDuration, }) {
    return (_jsx(Box, { paddingLeft: 1, paddingRight: 1, width: columns, children: visible ? (activityVisible ? (_jsx(ActivityIndicator, { phase: activityPhase, elapsedMs: elapsedMs, runStartRef: runStartRef, thinkingMs: thinkingMs, isThinking: isThinking, thinkingEnabled: !!thinkingLevel, tokenEstimate: tokenEstimate, charCountRef: charCountRef, realTokensAccumRef: realTokensAccumRef, userMessage: userMessage, activeToolNames: activeToolNames, retryInfo: retryInfo, planDone: planDone, planTotal: planTotal, staticDisplay: true })) : stallStatusVisible ? (_jsx(Text, { color: theme.warning, wrap: "truncate", children: "⚠ API provider stream interrupted — retries exhausted. Your conversation is preserved." })) : doneStatus ? (_jsxs(Text, { children: [_jsxs(Text, { color: theme.success, children: ["✻ ", doneStatus.verb, " ", formatDuration(doneStatus.durationMs)] }), _jsx(VitalSigns, { counts: doneStatus.counts, tokens: doneStatus.tokens, theme: theme })] })) : (_jsx(ReadyStatus, { theme: theme, renderMarkdown: renderMarkdown }))) : (_jsx(ReadyStatus, { theme: theme, renderMarkdown: true })) }));
}
/** Category → (tone for coloring, tool names that roll up into it). */
const VITAL_CATEGORIES = [
    { label: (n) => `${n} edit${n !== 1 ? "s" : ""}`, tone: "write", tools: ["edit", "write"] },
    { label: (n) => `${n} run${n !== 1 ? "s" : ""}`, tone: "run", tools: ["bash"] },
    {
        label: (n) => `${n} read${n !== 1 ? "s" : ""}`,
        tone: "read",
        tools: ["read", "grep", "find", "ls"],
    },
    {
        label: (n) => `${n} web`,
        tone: "web",
        tools: ["web_fetch", "web_search"],
    },
    { label: (n) => `${n} agent${n !== 1 ? "s" : ""}`, tone: "agent", tools: ["subagent"] },
];
/**
 * Per-run "vital signs" tail: tone-colored category chips + `↓ tokens`.
 * Omits the tail entirely when there are no counts (preserves the bare
 * `✻ {verb} {duration}` for chat-only turns).
 */
function VitalSigns({ counts, tokens, theme, }) {
    const chips = [];
    if (counts) {
        for (const cat of VITAL_CATEGORIES) {
            const total = cat.tools.reduce((sum, t) => sum + (counts[t] ?? 0), 0);
            if (total === 0)
                continue;
            chips.push(_jsxs(Text, { color: toolTonePalette(theme, cat.tone).primary, children: [" · ", cat.label(total)] }, cat.tone));
        }
    }
    const showTokens = typeof tokens === "number" && tokens > 0;
    if (chips.length === 0 && !showTokens)
        return null;
    return (_jsxs(Text, { children: [chips, showTokens && (_jsxs(Text, { color: theme.accent, children: [" · ", DOWN_ARROW, " ", formatTokenCount(tokens), " tokens"] }))] }));
}
function ReadyStatus({ theme, renderMarkdown, }) {
    return (_jsxs(Text, { children: [_jsx(Text, { color: theme.commandColor, children: "⠿ " }), _jsx(Text, { color: theme.textDim, children: "Ready to go.." }), !renderMarkdown && _jsx(Text, { color: theme.warning, children: " · raw markdown mode" })] }));
}
//# sourceMappingURL=ChatStatusRow.js.map