import { THINKING_DESCRIPTIONS } from "@sheason/pi-coding-agent";
import { SelectList, truncateToWidth } from "@sheason/pi-tui";
import { theme } from "../../components/index.js";
import { getForkedSelectListTheme, renderForkedPanelBorder } from "./selector-themes.js";
export class RemoteSettingsSelectorComponent {
    onSelectThinkingLevel;
    onCancelSelection;
    selectList;
    focused = false;
    constructor(_currentThinkingLevel, availableThinkingLevels, onSelectThinkingLevel, onCancelSelection) {
        this.onSelectThinkingLevel = onSelectThinkingLevel;
        this.onCancelSelection = onCancelSelection;
        this.selectList = new SelectList(availableThinkingLevels.map((level) => ({
            value: level,
            label: level,
            description: THINKING_DESCRIPTIONS[level] ?? level,
        })), Math.min(availableThinkingLevels.length, 10), getForkedSelectListTheme(), { minPrimaryColumnWidth: 12, maxPrimaryColumnWidth: 32 });
        const currentIndex = availableThinkingLevels.indexOf(_currentThinkingLevel);
        if (currentIndex >= 0) {
            this.selectList.setSelectedIndex(currentIndex);
        }
        this.selectList.onSelect = (item) => {
            void this.onSelectThinkingLevel(item.value);
        };
        this.selectList.onCancel = () => this.onCancelSelection();
    }
    getFocusTarget() {
        return this.selectList;
    }
    render(width) {
        const lines = [
            renderForkedPanelBorder(width),
            "",
            theme.bold(theme.fg("accent", "Thinking Level")),
            theme.fg("muted", "Select reasoning depth for thinking-capable models"),
            "",
            ...this.selectList.render(width),
            "",
            theme.fg("dim", "  Enter to select · Esc to go back"),
            "",
            renderForkedPanelBorder(width),
        ];
        return lines.map((line) => truncateToWidth(line, width, ""));
    }
    handleInput(data) {
        this.selectList.handleInput(data);
    }
    invalidate() {
        this.selectList.invalidate();
    }
}
//# sourceMappingURL=settings-selector.js.map