function renderFieldPrompt(field) {
    const requiredMark = field.required ? ' (required)' : ' (optional)';
    switch (field.type) {
        case 'text': {
            const maxNote = field.maxLength ? ` — max ${field.maxLength} chars` : '';
            const defaultNote = field.defaultValue ? ` [default: ${String(field.defaultValue)}]` : '';
            return `• ${field.label}${requiredMark}${maxNote}${defaultNote}`;
        }
        case 'number': {
            const rangeNote = field.min !== undefined || field.max !== undefined
                ? ` — range: ${field.min ?? '∞'} to ${field.max ?? '∞'}`
                : '';
            const defaultNote = field.defaultValue !== undefined ? ` [default: ${String(field.defaultValue)}]` : '';
            return `• ${field.label}${requiredMark}${rangeNote}${defaultNote} (number)`;
        }
        case 'boolean': {
            const defaultNote = field.defaultValue !== undefined ? ` [default: ${String(field.defaultValue)}]` : '';
            return `• ${field.label}${requiredMark}${defaultNote} (yes/no)`;
        }
        case 'enum': {
            const optionsList = field.options.map((o) => `"${o}"`).join(', ');
            const defaultNote = field.defaultValue ? ` [default: ${String(field.defaultValue)}]` : '';
            return `• ${field.label}${requiredMark}${defaultNote}\n  Options: ${optionsList}`;
        }
        case 'multi-select': {
            const optionsList = field.options.map((o) => `"${o}"`).join(', ');
            const defaultNote = field.defaultValue && Array.isArray(field.defaultValue) && field.defaultValue.length > 0
                ? ` [default: ${field.defaultValue.join(', ')}]`
                : '';
            return `• ${field.label}${requiredMark}${defaultNote}\n  Options (select one or more): ${optionsList}`;
        }
    }
}
/**
 * Generate a text-based fallback prompt for clients that do not support
 * the MCP elicitation protocol.
 *
 * The output is a human-readable string describing all form fields so that
 * the user can provide answers as free text.
 */
export function generateFallbackPrompt(request) {
    const lines = [];
    lines.push(`## ${request.title}`);
    if (request.description) {
        lines.push('');
        lines.push(request.description);
    }
    lines.push('');
    lines.push('Your client does not support interactive forms. Please answer the following questions:');
    lines.push('');
    for (const field of request.fields) {
        lines.push(renderFieldPrompt(field));
    }
    return lines.join('\n');
}
/**
 * Check whether the given MCP server capabilities object declares support for
 * elicitation. Pass the `capabilities` object from your McpServer instance.
 *
 * @example
 * ```ts
 * const capable = supportsElicitation(server.getClientCapabilities());
 * ```
 */
export function supportsElicitation(capabilities) {
    if (!capabilities) {
        return false;
    }
    // MCP 2025-06: elicitation support is declared under capabilities.elicitation
    return typeof capabilities.elicitation === 'object' && capabilities.elicitation !== null;
}
//# sourceMappingURL=fallback.js.map