import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
import { Box, Text } from 'ink';
import SelectInput from 'ink-select-input';
import TextInput from '../../components/text-input.js';
/**
 * Renders a single field within the provider wizard's field-input mode.
 *
 * The widget chosen depends on `currentField.type`:
 *   - 'boolean': Yes / No / Skip select with the previous answer highlighted.
 *   - 'array' or 'string' (default): TextInput; the prompt itself signals
 *     that array fields accept a comma-separated list.
 *   - 'sensitive' fields render a masked TextInput regardless of type.
 *
 * Extracted from ProviderStep so the rendering branches can be unit-tested
 * without driving the entire wizard state machine.
 */
export function FieldInputView({ templateName, currentField, fieldIndex, fieldCount, currentValue, error, isNarrow, inputKey, colors, onChange, onSubmit, }) {
    const isBoolean = currentField.type === 'boolean';
    return (_jsxs(Box, { flexDirection: "column", children: [_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { bold: true, color: colors.primary, children: [templateName, " Configuration"] }), _jsxs(Text, { children: [' ', "(Field ", fieldIndex + 1, "/", fieldCount, ")"] })] }), _jsx(Box, { children: _jsxs(Text, { children: [currentField.prompt, currentField.required && _jsx(Text, { color: colors.error, children: " *" }), ":", ' ', currentField.sensitive && '****'] }) }), isBoolean && (_jsx(Box, { marginBottom: 1, children: _jsx(SelectInput, { items: [
                        { label: 'Yes', value: 'true' },
                        { label: 'No', value: 'false' },
                        { label: 'Skip (use OpenRouter default)', value: '' },
                    ], initialIndex: currentValue === 'true' ? 0 : currentValue === 'false' ? 1 : 2, onSelect: item => onSubmit(item.value) }) })), !isBoolean && !currentField.sensitive && (_jsx(Box, { marginBottom: 1, borderStyle: "round", borderColor: colors.secondary, children: _jsx(TextInput, { value: currentValue, onChange: onChange, onSubmit: () => onSubmit() }, inputKey) })), !isBoolean && currentField.sensitive && (_jsx(Box, { marginBottom: 1, borderStyle: "round", borderColor: colors.secondary, children: _jsx(TextInput, { value: currentValue, onChange: onChange, onSubmit: () => onSubmit(), mask: "*" }, inputKey) })), error && (_jsx(Box, { marginBottom: 1, children: _jsx(Text, { color: colors.error, children: error }) })), isNarrow ? (_jsxs(Box, { flexDirection: "column", children: [_jsx(Text, { color: colors.secondary, children: "Enter: continue" }), _jsx(Text, { color: colors.secondary, children: "Shift+Tab: go back" })] })) : (_jsx(Box, { children: _jsx(Text, { color: colors.secondary, children: "Press Enter to continue | Shift+Tab to go back" }) }))] }));
}
//# sourceMappingURL=field-input-view.js.map