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 { getModel } from "../../core/model-registry.js";
import { useTerminalSize } from "../hooks/useTerminalSize.js";
const LOGO_LINES = [
    " \u2588\u2580\u2580\u2580 \u2580\u2580\u2580\u2588",
    " \u2588\u2580\u2580   \u2584\u2580 ",
    " \u2588\u2584\u2584\u2584 \u2588\u2584\u2584\u2584",
];
// Extended gradient with reverse path for smooth animation loop
const GRADIENT = [
    "#60a5fa",
    "#6da1f9",
    "#7a9df7",
    "#8799f5",
    "#9495f3",
    "#a18ff1",
    "#a78bfa",
    "#a18ff1",
    "#9495f3",
    "#8799f5",
    "#7a9df7",
    "#6da1f9",
];
const GAP = "   ";
// Logo is 9 visible chars wide + GAP (3) = 12 chars before info text
const LOGO_WIDTH = 9;
const SIDE_BY_SIDE_MIN = LOGO_WIDTH + GAP.length + 62; // room for the shortcut hint row
export function Banner({ version, model, cwd, taskCount }) {
    const theme = useTheme();
    const { columns } = useTerminalSize();
    const modelInfo = getModel(model);
    const modelName = modelInfo?.name ?? model;
    const home = process.env.HOME ?? "";
    const displayPath = home && cwd.startsWith(home) ? "~" + cwd.slice(home.length) : cwd;
    // Static gradient — no animation needed since the banner is rendered once
    // into Ink's Static area. Animating here would waste CPU and could cause
    // visual duplicates on terminal resize.
    const shift = 0;
    // At narrow widths, stack logo above info instead of side-by-side
    if (columns < SIDE_BY_SIDE_MIN) {
        return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, width: columns, children: [_jsx(GradientText, { text: LOGO_LINES[0], shift: shift }), _jsx(GradientText, { text: LOGO_LINES[1], shift: shift }), _jsx(GradientText, { text: LOGO_LINES[2], shift: shift }), _jsxs(Box, { marginTop: 1, children: [_jsx(Text, { color: theme.primary, bold: true, children: "EZ Coder" }), _jsxs(Text, { color: theme.textDim, children: [" v", version] })] }), _jsxs(Box, { children: [_jsx(Text, { color: theme.secondary, children: modelName }), _jsx(Text, { color: theme.textDim, children: "  " }), _jsx(Text, { color: theme.textDim, wrap: "truncate", children: displayPath })] }), _jsx(ShortcutHints, { taskCount: taskCount })] }));
    }
    return (_jsxs(Box, { flexDirection: "column", marginTop: 1, marginBottom: 1, width: columns, children: [_jsxs(Box, { children: [_jsx(GradientText, { text: LOGO_LINES[0], shift: shift }), _jsx(Text, { children: GAP }), _jsx(Text, { color: theme.primary, bold: true, children: "EZ Coder" }), _jsxs(Text, { color: theme.textDim, children: [" v", version] }), _jsx(Text, { color: theme.textDim, children: " \u00B7 By " }), _jsx(Text, { color: theme.text, bold: true, children: "Nolan Grout" })] }), _jsxs(Box, { children: [_jsx(GradientText, { text: LOGO_LINES[1], shift: shift }), _jsx(Text, { children: GAP }), _jsx(Text, { color: theme.secondary, children: modelName }), _jsx(Text, { color: theme.textDim, children: "  " }), _jsx(Text, { color: theme.textDim, wrap: "truncate", children: displayPath })] }), _jsxs(Box, { children: [_jsx(GradientText, { text: LOGO_LINES[2], shift: shift }), _jsx(Text, { children: GAP }), _jsx(ShortcutHints, { taskCount: taskCount })] })] }));
}
function ShortcutHints({ taskCount }) {
    const theme = useTheme();
    const taskLabel = taskCount && taskCount > 0 ? ` tasks (${taskCount})` : " tasks";
    return (_jsxs(Box, { children: [_jsx(Text, { color: theme.primary, children: "Ctrl+T" }), _jsx(Text, { color: theme.textDim, children: taskLabel }), _jsx(Text, { color: theme.textDim, children: " \u00B7 " }), _jsx(Text, { color: theme.primary, children: "Ctrl+S" }), _jsx(Text, { color: theme.textDim, children: " skills" }), _jsx(Text, { color: theme.textDim, children: " \u00B7 " }), _jsx(Text, { color: theme.primary, children: "Shift+Tab" }), _jsx(Text, { color: theme.textDim, children: " toggle thinking" })] }));
}
function GradientText({ text, shift = 0 }) {
    const chars = [];
    let colorIdx = 0;
    for (let i = 0; i < text.length; i++) {
        const ch = text[i];
        if (ch === " ") {
            chars.push(ch);
        }
        else {
            const color = GRADIENT[(colorIdx + shift) % GRADIENT.length];
            chars.push(_jsx(Text, { color: color, children: ch }, i));
            colorIdx++;
        }
    }
    return _jsx(Text, { children: chars });
}
//# sourceMappingURL=Banner.js.map