import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { c } from "../theme.js";
function formatInput(input, maxLen = 60) {
    const s = JSON.stringify(input);
    return s.length > maxLen ? s.slice(0, maxLen) + "..." : s;
}
export function ToolTimelineItem({ item }) {
    const { name, input, state, elapsedMs } = item;
    const argsStr = formatInput(input);
    let icon;
    let colorFn;
    switch (state) {
        case "running":
        case "queued":
            icon = "▶";
            colorFn = c.cyan;
            break;
        case "success":
            icon = "✓";
            colorFn = c.green;
            break;
        case "error":
            icon = "✗";
            colorFn = c.red;
            break;
        case "cancelled":
            icon = "—";
            colorFn = c.dim;
            break;
        default:
            icon = "?";
            colorFn = c.dim;
    }
    const timeStr = elapsedMs !== undefined ? ` (${elapsedMs}ms)` : "";
    return (_jsxs(Box, { children: [_jsx(Text, { children: colorFn(`  ${icon} `) }), _jsx(Text, { children: colorFn(`${name}(${argsStr})${timeStr}`) })] }));
}
