import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import { Box, Text } from "ink";
import { useTheme } from "../theme/theme.js";
import { presentDuration, presentError, presentQueued, presentSetupHint, presentStepDone, presentStylePack, presentUpdateNotice, } from "./presentation.js";
export function StylePackRow({ item }) {
    const theme = useTheme();
    const presentation = presentStylePack(item);
    return (_jsx(Box, { paddingLeft: 1, flexShrink: 1, children: _jsxs(Box, { flexShrink: 1, flexDirection: "column", borderStyle: "round", borderColor: theme.language, paddingX: 1, children: [_jsxs(Text, { wrap: "wrap", children: [_jsx(Text, { color: theme.language, bold: true, children: "◆ " }), _jsx(Text, { color: theme.language, bold: true, children: presentation.headerLabel })] }), _jsx(Text, { color: theme.text, bold: true, wrap: "wrap", children: presentation.names }), presentation.showSetupHint && (_jsx(Box, { marginTop: 1, children: _jsxs(Text, { wrap: "wrap", children: [_jsx(Text, { color: theme.textMuted, children: "Tip: run " }), _jsx(Text, { color: theme.language, bold: true, children: "/setup" }), _jsx(Text, { color: theme.textMuted, children: presentation.setupHint })] }) }))] }) }, item.id));
}
export function SetupHintRow({ item }) {
    const theme = useTheme();
    const presentation = presentSetupHint(item);
    return (_jsx(Box, { paddingLeft: 1, flexShrink: 1, children: _jsxs(Box, { flexShrink: 1, flexDirection: "column", borderStyle: "round", borderColor: theme.language, paddingX: 1, children: [_jsxs(Text, { wrap: "wrap", children: [_jsx(Text, { color: theme.language, bold: true, children: "◆ " }), _jsx(Text, { color: theme.language, bold: true, children: presentation.headerLabel })] }), _jsx(Text, { color: theme.textMuted, wrap: "wrap", children: presentation.body }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { wrap: "wrap", children: [_jsx(Text, { color: theme.textMuted, children: "Tip: run " }), _jsx(Text, { color: theme.language, bold: true, children: "/setup" }), _jsx(Text, { color: theme.textMuted, children: presentation.setupHint })] }) })] }) }, item.id));
}
export function ErrorRow({ item }) {
    const theme = useTheme();
    const presentation = presentError(item);
    return (_jsxs(Box, { flexDirection: "row", paddingLeft: 1, flexShrink: 1, children: [_jsx(Box, { width: 2, flexShrink: 0, children: _jsx(Text, { color: theme.error, bold: true, children: presentation.glyph }) }), _jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsx(Text, { color: theme.error, wrap: "wrap", children: presentation.headline }), presentation.message && (_jsx(Text, { color: theme.textDim, wrap: "wrap", children: presentation.message })), _jsx(Text, { color: theme.textDim, wrap: "wrap", children: presentation.guidance })] })] }, item.id));
}
export function UpdateNoticeRow({ item }) {
    const theme = useTheme();
    const presentation = presentUpdateNotice(item);
    return (_jsx(Box, { paddingLeft: 1, flexShrink: 1, children: _jsx(Box, { flexShrink: 1, borderStyle: "round", borderColor: theme.commandColor, paddingX: 1, children: _jsx(Text, { color: theme.commandColor, bold: true, wrap: "wrap", children: presentation.text }) }) }, item.id));
}
export function StepDoneRow({ item }) {
    const theme = useTheme();
    const presentation = presentStepDone(item);
    return (_jsx(Box, { paddingLeft: 1, flexShrink: 1, children: _jsxs(Text, { wrap: "wrap", children: [_jsx(Text, { color: theme.planPrimary, bold: true, children: presentation.glyph }), _jsx(Text, { color: theme.planPrimary, bold: true, children: presentation.text }), presentation.description ? (_jsx(Text, { color: theme.accent, children: presentation.description })) : null] }) }, item.id));
}
function goalProgressColor(item, theme) {
    if (item.status === "failed" || item.status === "fail" || item.status === "blocked") {
        return theme.error;
    }
    if (item.phase === "worker_finished" || item.phase === "terminal")
        return theme.success;
    if (item.phase === "verifier_started" || item.phase === "verifier_finished")
        return theme.accent;
    if (item.phase === "orchestrator_reviewing" || item.phase === "orchestrator_working") {
        return theme.secondary;
    }
    if (item.phase === "continuing")
        return theme.warning;
    return theme.primary;
}
export function GoalProgressRow({ item }) {
    const theme = useTheme();
    const color = goalProgressColor(item, theme);
    const glyph = item.phase === "worker_finished" || item.phase === "verifier_finished"
        ? "✓ "
        : item.phase === "terminal"
            ? item.status === "passed"
                ? "◆ "
                : "! "
            : "↻ ";
    return (_jsxs(Box, { flexDirection: "column", flexShrink: 1, children: [_jsxs(Text, { wrap: "wrap", children: [_jsxs(Text, { color: color, bold: true, children: [glyph, item.title] }), item.workerId ? _jsxs(Text, { color: theme.textDim, children: [" \u00B7 worker ", item.workerId] }) : null] }), item.detail ? (_jsx(Text, { color: theme.textDim, wrap: "wrap", children: `  ${item.detail}` })) : null, item.summaryRows && item.summaryRows.length > 0 ? (_jsx(Box, { flexDirection: "column", marginTop: 1, marginLeft: 2, flexShrink: 1, children: item.summaryRows.map((row) => (_jsxs(Text, { wrap: "truncate", children: [_jsx(Text, { color: theme.textDim, children: row.label.padEnd(10) }), _jsx(Text, { color: theme.text, children: row.value }), row.detail ? _jsxs(Text, { color: theme.textDim, children: [" \u00B7 ", row.detail] }) : null] }, row.label))) })) : null, item.summarySections && item.summarySections.length > 0 ? (_jsx(Box, { flexDirection: "column", marginTop: 1, marginLeft: 2, flexShrink: 1, children: item.summarySections.map((section) => (_jsxs(Box, { flexDirection: "column", marginBottom: 1, flexShrink: 1, children: [_jsx(Text, { color: theme.textDim, bold: true, children: section.title }), section.lines.map((line, index) => (_jsx(Text, { color: theme.text, wrap: "wrap", children: `• ${line}` }, `${section.title}-${index}`)))] }, section.title))) })) : null] }));
}
export function QueuedRow({ item }) {
    const theme = useTheme();
    const presentation = presentQueued(item);
    return (_jsxs(Box, { flexDirection: "row", paddingLeft: 1, flexShrink: 1, children: [_jsx(Box, { width: 2, flexShrink: 0, children: _jsx(Text, { color: theme.warning, bold: true, children: presentation.glyph }) }), _jsx(Box, { flexDirection: "column", flexGrow: 1, children: _jsxs(Text, { color: theme.text, wrap: "wrap", children: [_jsx(Text, { color: theme.textDim, children: presentation.label }), presentation.text, presentation.suffix] }) })] }, item.id));
}
export function DurationRow({ item }) {
    const theme = useTheme();
    const presentation = presentDuration(item);
    return (_jsx(Box, { paddingLeft: 1, children: _jsxs(Text, { color: theme.textDim, children: [presentation.glyph, presentation.text] }) }, item.id));
}
//# sourceMappingURL=MiscRows.js.map