/** @jsxImportSource @opentui/react */
/**
 * WorkflowPickerPanel — interactive TUI for `atomic workflow -a <agent>`.
 *
 * Telescope-style fuzzy picker with a two-phase flow:
 *
 *   1. PICK   — filter workflows scoped to the current agent, navigate with
 *               ↑/↓ or ⌃j/⌃k, press ↵ to lock in a selection.
 *   2. PROMPT — fill the workflow's declared input schema (one field per
 *               declared `WorkflowInput`). Free-form workflows fall back to
 *               a single `prompt` text field.
 *
 * Pressing ⌃d in the prompt phase validates required fields and opens a
 * CONFIRM modal that shows the fully-composed shell command before
 * submission. y/↵ confirms, n/esc cancels back to the form.
 *
 * Lifecycle:
 *
 *   const panel = await WorkflowPickerPanel.create({ agent, registry });
 *   const result = await panel.waitForSelection();
 *   panel.destroy();
 *   if (result) await executeWorkflow({ ... });
 *
 * `waitForSelection()` resolves with `null` if the user exits without
 * committing (esc in PICK phase, or ⌃c anywhere) and with a
 * `{ workflow, inputs }` record if they confirm the run.
 */
import { type CliRenderer } from "@opentui/core";
import { type TerminalTheme } from "../runtime/theme.ts";
import type { AgentType, WorkflowInput, WorkflowDefinition, Registry } from "../types.ts";
export interface PickerTheme {
    background: string;
    backgroundPanel: string;
    backgroundElement: string;
    surface: string;
    text: string;
    textMuted: string;
    textDim: string;
    primary: string;
    success: string;
    error: string;
    warning: string;
    info: string;
    mauve: string;
    border: string;
    borderActive: string;
}
export declare function buildPickerTheme(base: TerminalTheme): PickerTheme;
/** The payload the picker resolves with on successful submission. */
export interface WorkflowPickerResult {
    /** The workflow the user committed to running. */
    workflow: WorkflowDefinition;
    /** Populated form values, one per declared input (or { prompt } for free-form). */
    inputs: Record<string, string>;
}
/**
 * Subsequence fuzzy match — Telescope-style. Returns a score (lower =
 * better) or null for no match. Adjacent matches are rewarded; jumps over
 * non-matching characters are penalized proportionally to the gap.
 */
export declare function fuzzyMatch(query: string, target: string): number | null;
interface ListEntry {
    workflow: WorkflowDefinition;
    /** Agent the workflow belongs to — used for section grouping. */
    section: AgentType;
}
type ListRow = {
    kind: "section";
    agent: AgentType;
} | {
    kind: "entry";
    entry: ListEntry;
};
export declare function buildEntries(query: string, workflows: WorkflowDefinition[]): ListEntry[];
export declare function buildRows(entries: ListEntry[], query: string): ListRow[];
export declare function isFieldValid(field: WorkflowInput, value: string): boolean;
interface PickerAppProps {
    theme: PickerTheme;
    agent: AgentType;
    workflows: WorkflowDefinition[];
    onSubmit: (result: WorkflowPickerResult) => void;
    onCancel: () => void;
}
export declare function WorkflowPicker({ theme, agent, workflows, onSubmit, onCancel, }: PickerAppProps): import("react").ReactNode;
export interface WorkflowPickerPanelOptions {
    agent: AgentType;
    /**
     * Registry of compiled workflow definitions. The panel calls
     * `registry.list()` and filters to the selected `agent`.
     */
    registry: Registry<Record<string, WorkflowDefinition>>;
}
/**
 * Imperative shell around the React picker tree — mirrors the
 * {@link OrchestratorPanel} lifecycle so both panels can be used
 * interchangeably by the CLI command layer.
 */
export declare class WorkflowPickerPanel {
    private renderer;
    private root;
    private destroyed;
    private terminalBackgroundSynced;
    private resolveSelection;
    private selectionPromise;
    private constructor();
    /**
     * Create a new WorkflowPickerPanel. Initialises a CLI renderer and
     * mounts the interactive tree. The caller should `await
     * waitForSelection()` and then call `destroy()` regardless of outcome.
     */
    static create(options: WorkflowPickerPanelOptions): Promise<WorkflowPickerPanel>;
    /** Create with an externally-provided renderer (e.g. a test renderer). */
    static createWithRenderer(renderer: CliRenderer, options: WorkflowPickerPanelOptions): WorkflowPickerPanel;
    /**
     * Resolve with the user's selection once they confirm, or `null` if
     * they exit the picker without committing. Idempotent — subsequent
     * calls return the same promise.
     */
    waitForSelection(): Promise<WorkflowPickerResult | null>;
    /** Tear down the CLI renderer. Idempotent. */
    destroy(): void;
    private handleSubmit;
    private handleCancel;
}
export {};
//# sourceMappingURL=workflow-picker-panel.d.ts.map