import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from "ink";
import { SelectList } from "./design/SelectList.js";
import { StatusBadge } from "./design/StatusBadge.js";
import { truncateCells } from "./design/textLayout.js";
import { DEEPSEEK_MODEL_OPTIONS } from "../services/deepseek/models.js";
export function ModelPicker(props) {
    const width = props.width ?? 96;
    return (_jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Box, { flexDirection: "row", children: [_jsxs(Text, { color: "gray", children: [props.model.title, " "] }), _jsx(StatusBadge, { label: `${props.model.options.length}`, tone: "brand" }), _jsxs(Text, { color: "gray", children: [" ", truncateCells(props.model.subtitle, Math.max(16, width - 24))] })] }), _jsx(SelectList, { options: props.model.options.map(modelPickerSelectOption), selectedIndex: props.model.selectedIndex, visibleCount: 5, width: width }), _jsx(Text, { color: "gray", children: truncateCells(props.model.footer, Math.max(18, width - 4)) })] }));
}
export function modelPickerModel(input) {
    const active = input.verifiedModel || input.activeModel;
    const knownIds = new Set(DEEPSEEK_MODEL_OPTIONS.map((option) => option.id));
    const options = [
        ...(!knownIds.has(active) ? [{
                id: active,
                label: active,
                status: "current",
                tone: "brand",
                detail: "current project model",
                description: "This model is configured locally; keep using it if your provider profile requires it.",
                selected: true,
            }] : []),
        ...DEEPSEEK_MODEL_OPTIONS.map((option) => ({
            ...option,
            tone: option.id.includes("flash") ? "success" : "warning",
            selected: option.id === active,
        })),
    ];
    const selectedIndex = Math.max(0, options.findIndex((option) => option.selected));
    return {
        title: "model picker",
        subtitle: input.providerReady
            ? `provider ${input.providerName ?? "deepseek"} ready`
            : "provider missing; configure API key before verifying",
        options,
        selectedIndex: input.selectedIndex ?? selectedIndex,
        footer: "Up/Down select | Enter switch | Esc close | /model flash | /model pro | /model verify",
    };
}
function modelPickerSelectOption(option) {
    return {
        id: option.id,
        label: option.label,
        detail: `${option.status} | ${option.detail}`,
        description: option.description,
        selected: option.selected,
        tone: option.tone,
    };
}
