/**
 * FlagResolver - Unified flag resolution for human and machine interactive modes
 *
 * This abstraction unifies the two interaction patterns in the CLI:
 * - Human interactive mode: Uses inquirer prompts, collects input, returns flags
 * - Machine/JSON mode: Outputs prompt schema as JSON, exits for agent to process
 *
 * Both modes use the same underlying pattern: prompts PRODUCE flags.
 * The execution logic only sees flags, not prompt results.
 *
 * @example
 * ```typescript
 * // Define prompts for missing flags
 * const resolver = new FlagResolver({
 *   commandName: 'ticket create',
 *   baseCommand: 'prlt ticket create',
 *   jsonMode: shouldOutputJson(flags),
 *   flags,
 * });
 *
 * // Add prompts - they execute in order, can depend on previously resolved flags
 * resolver.addPrompt({
 *   flagName: 'column',
 *   type: 'list',
 *   message: 'Select column:',
 *   choices: async () => columns.map(c => ({ name: c, value: c })),
 * });
 *
 * resolver.addPrompt({
 *   flagName: 'title',
 *   type: 'input',
 *   message: 'Enter title:',
 *   when: (ctx) => ctx.flags.column !== undefined, // Only after column is selected
 * });
 *
 * // Resolve all missing flags
 * const resolved = await resolver.resolve();
 * // resolved.column and resolved.title are now guaranteed to have values
 * ```
 */
/**
 * Context available during prompt resolution
 */
export interface ResolverContext<TFlags = Record<string, unknown>> {
    /** Currently resolved flags (includes original flags + newly resolved) */
    flags: TFlags;
    /** Command args */
    args: Record<string, unknown>;
    /** Command name for metadata */
    commandName: string;
    /** Base command for building follow-up commands (e.g., "prlt ticket create") */
    baseCommand: string;
    /** Project ID if available */
    projectId?: string;
    /** Any additional custom context */
    [key: string]: unknown;
}
/**
 * Choice item for list/checkbox prompts
 */
export interface ResolverChoice<T = string> {
    /** Display text */
    name: string;
    /** Value returned when selected */
    value: T;
    /** Whether this choice is disabled */
    disabled?: boolean | string;
    /** Full CLI command for this choice (for JSON mode) - if not provided, auto-generated */
    command?: string;
}
/**
 * Definition for a single prompt that resolves a flag
 */
export interface PromptDefinition<TValue = unknown, TFlags = Record<string, unknown>> {
    /** The flag name this prompt resolves (e.g., 'column', 'title') */
    flagName: string;
    /** Prompt type. Use 'multiline' for inline multi-line text input (replaces 'editor') */
    type: 'list' | 'checkbox' | 'input' | 'confirm' | 'editor' | 'multiline';
    /** User-facing prompt message */
    message: string | ((ctx: ResolverContext<TFlags>) => string);
    /**
     * Get choices for list/checkbox prompts.
     * Can be async to fetch dynamic data.
     */
    choices?: (ctx: ResolverContext<TFlags>) => Promise<ResolverChoice<TValue>[]> | ResolverChoice<TValue>[];
    /**
     * Default value for the prompt.
     * Can be a function to compute based on context.
     */
    default?: TValue | ((ctx: ResolverContext<TFlags>) => TValue | undefined);
    /**
     * Validation function for input prompts.
     * Return true if valid, or error message string if invalid.
     */
    validate?: (value: TValue, ctx: ResolverContext<TFlags>) => boolean | string;
    /**
     * Conditional function - prompt is skipped if this returns false.
     * Use for prompts that depend on other flags.
     */
    when?: (ctx: ResolverContext<TFlags>) => boolean;
    /**
     * Transform the flag value before storing.
     * Useful for parsing/formatting.
     */
    transform?: (value: TValue, ctx: ResolverContext<TFlags>) => unknown;
    /**
     * For JSON mode: additional context to include in the prompt output.
     * Useful for providing hints, examples, etc.
     */
    context?: Record<string, unknown> | ((ctx: ResolverContext<TFlags>) => Record<string, unknown>);
    /**
     * For JSON mode: generate the command string for a specific choice.
     * If not provided, auto-generates based on flagName and value.
     */
    getCommand?: (value: TValue, ctx: ResolverContext<TFlags>) => string;
    /**
     * Skip auto-generating commands for choices (useful when choices already have custom commands)
     */
    skipAutoCommand?: boolean;
}
/**
 * Options for creating a FlagResolver
 */
export interface FlagResolverOptions<TFlags extends Record<string, unknown>> {
    /** Command name for metadata (e.g., "ticket create") */
    commandName: string;
    /** Base command for building commands (e.g., "prlt ticket create") */
    baseCommand: string;
    /** Whether JSON mode is active */
    jsonMode: boolean;
    /** Initial flags from CLI parsing */
    flags: Partial<TFlags>;
    /** Command args */
    args?: Record<string, unknown>;
    /** Additional custom context */
    context?: Record<string, unknown>;
}
/**
 * Result of flag resolution
 */
export interface ResolveResult<TFlags> {
    /** The fully resolved flags */
    flags: TFlags;
    /** Whether all required prompts were resolved (false if user cancelled) */
    complete: boolean;
}
/**
 * FlagResolver handles unified flag resolution for both human and machine modes.
 *
 * Usage pattern:
 * 1. Create resolver with command info and current flags
 * 2. Add prompt definitions for flags that may need resolution
 * 3. Call resolve() to get complete flags
 *
 * In JSON mode, resolve() outputs the first unresolved prompt and exits.
 * In interactive mode, resolve() prompts for each unresolved flag sequentially.
 */
export declare class FlagResolver<TFlags extends Record<string, unknown> = Record<string, unknown>> {
    private prompts;
    private options;
    private resolvedFlags;
    private resolverContext;
    constructor(options: FlagResolverOptions<TFlags>);
    /**
     * Add a prompt definition for resolving a flag.
     * Prompts are processed in the order they are added.
     */
    addPrompt<TValue = unknown>(prompt: PromptDefinition<TValue, TFlags>): this;
    /**
     * Add multiple prompt definitions at once.
     */
    addPrompts(prompts: PromptDefinition<unknown, TFlags>[]): this;
    /**
     * Update the context with additional data.
     * Useful for adding computed values that prompts might need.
     */
    setContext(key: string, value: unknown): this;
    /**
     * Get current context value
     */
    getContext<T = unknown>(key: string): T | undefined;
    /**
     * Check if a flag has a value (not undefined)
     */
    hasFlag(flagName: keyof TFlags): boolean;
    /**
     * Get current flag value
     */
    getFlag<K extends keyof TFlags>(flagName: K): TFlags[K] | undefined;
    /**
     * Set a flag value directly (bypasses prompting)
     */
    setFlag<K extends keyof TFlags>(flagName: K, value: TFlags[K]): this;
    /**
     * Resolve all prompts and return complete flags.
     *
     * In JSON mode: outputs the first unresolved prompt as JSON and exits (never returns).
     * In interactive mode: prompts for each unresolved flag and returns all flags.
     *
     * @returns The fully resolved flags
     */
    resolve(): Promise<TFlags>;
    /**
     * Output prompt as JSON for machine mode
     */
    private outputJsonPrompt;
    /**
     * Prompt for value in interactive mode
     */
    private promptInteractive;
    /**
     * Build a command string for a flag value
     */
    private buildCommand;
}
/**
 * Convenience function to create a FlagResolver from command context
 */
export declare function createFlagResolver<TFlags extends Record<string, unknown>>(options: FlagResolverOptions<TFlags>): FlagResolver<TFlags>;
/**
 * Helper to check if we should use JSON mode
 * Re-exported from prompt-json for convenience
 */
export { shouldOutputJson, isMachineOutput } from '../prompt-json.js';
