"use strict";
/**
 * Prompt Answer Input - Converts user answers to tmux input strings.
 *
 * Extracted from prompt-detector.ts (Issue #479) to separate prompt detection
 * from answer input transformation.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAnswerInput = getAnswerInput;
/**
 * Get tmux input string for an answer
 *
 * @param answer - User's answer ('yes', 'no', 'y', 'n', or number for multiple choice)
 * @param promptType - Type of prompt (defaults to 'yes_no')
 * @returns tmux input string ('y', 'n', or the number as string)
 * @throws Error if answer is invalid
 *
 * @example
 * ```typescript
 * getAnswerInput('yes'); // => 'y'
 * getAnswerInput('no');  // => 'n'
 * getAnswerInput('Y');   // => 'y'
 * getAnswerInput('1', 'multiple_choice'); // => '1'
 * ```
 */
function getAnswerInput(answer, promptType = 'yes_no') {
    const normalized = answer.toLowerCase().trim();
    // Handle multiple choice - just return the number
    if (promptType === 'multiple_choice') {
        // Validate it's a number
        if (/^\d+$/.test(normalized)) {
            return normalized;
        }
        // SEC-003: Fixed error message without user input to prevent log injection
        throw new Error('Invalid answer for multiple choice prompt. Expected a number.');
    }
    // Handle yes/no prompts
    if (normalized === 'yes' || normalized === 'y') {
        return 'y';
    }
    if (normalized === 'no' || normalized === 'n') {
        return 'n';
    }
    // SEC-003: Fixed error message without user input to prevent log injection
    throw new Error("Invalid answer for yes/no prompt. Expected 'yes', 'no', 'y', or 'n'.");
}
