import type { EnvVarInput, McpServerUsageInput, ResourceRef } from "@stigmer/sdk";
import type { EnvVarFormSubmitOptions } from "../environment/EnvVarForm";
import type { McpServerSetupEntry } from "./mcpServerSetupReducer";
/**
 * Props for the setup-integrated mode of {@link McpServerPicker}.
 *
 * When the `setup` prop is provided, the picker gains per-server status
 * indicators, credential collection via drill-in to
 * {@link McpServerConfigPanel}, and per-tool selection. Selection is
 * managed through `entries` and the setup callbacks instead of the
 * simple `value`/`onChange` pair.
 *
 * All callbacks are required when setup is enabled — this prevents
 * invalid partial states where entries exist but no handler can
 * respond to user actions.
 *
 * Matches the `credentials?` sub-object pattern established on
 * {@link McpServerConfigPanel} (DD-R13): the presence/absence of
 * the object cleanly communicates which mode the component operates in.
 */
export interface McpServerSetupIntegration {
    /**
     * Per-server setup state, keyed by `"org/slug"`.
     *
     * Typically sourced from `useMcpServerSetup().entries`. Each entry
     * tracks an individual server through the setup lifecycle:
     * `loading → needsSetup → submitting → ready`.
     */
    readonly entries: Readonly<Record<string, McpServerSetupEntry>>;
    /** Called when the user selects a server from search results. */
    readonly onServerAdded: (ref: ResourceRef) => void;
    /** Called when the user removes a server from the selected list. */
    readonly onServerRemoved: (ref: ResourceRef) => void;
    /** Called when the user submits credentials for a server. */
    readonly onSubmitEnvVars: (ref: ResourceRef, values: Record<string, EnvVarInput>, options: EnvVarFormSubmitOptions) => void;
    /** Called when the user changes the enabled tools for a server. */
    readonly onEnabledToolsChange: (ref: ResourceRef, tools: string[]) => void;
}
/** Props for {@link McpServerPicker}. */
export interface McpServerPickerProps {
    /** Organization slug used as the default search scope. */
    readonly org: string;
    /**
     * Controls search scope.
     *
     * - `"org"` — search only within the provided organization.
     * - `"all"` — search all organizations the caller can access,
     *   including public/platform MCP servers from other orgs.
     *
     * @default "org"
     */
    readonly scope?: "org" | "all";
    /**
     * Currently selected MCP server usages.
     *
     * Required in simple mode (when `setup` is not provided). In setup
     * mode, selection is derived from `setup.entries` and this prop is
     * not needed.
     */
    readonly value?: McpServerUsageInput[];
    /**
     * Called when the selection changes in simple mode.
     *
     * Required when `setup` is not provided. Not called when `setup`
     * is provided — selection goes through `setup.onServerAdded` and
     * `setup.onServerRemoved` instead.
     */
    readonly onChange?: (usages: McpServerUsageInput[]) => void;
    /** Called with the display name when an item is added (for chip rendering). */
    readonly onDisplayNameResolved?: (key: string, name: string) => void;
    /** Disables all interaction. */
    readonly disabled?: boolean;
    /** Additional CSS class names for the root container. */
    readonly className?: string;
    /**
     * When provided, enables setup-integrated mode: per-server status
     * indicators, credential collection, tool selection, and drill-in
     * to {@link McpServerConfigPanel}.
     *
     * In this mode, `value` and `onChange` are not needed — selection
     * is managed through `setup.entries` and the setup callbacks.
     *
     * When omitted, the picker operates in simple mode (current
     * behavior): toggle servers on/off with `value`/`onChange`.
     *
     * @see {@link McpServerSetupIntegration}
     *
     * @example
     * ```tsx
     * const mcpSetup = useMcpServerSetup("acme");
     *
     * <McpServerPicker
     *   org="acme"
     *   setup={{
     *     entries: mcpSetup.entries,
     *     onServerAdded: (ref) => mcpSetup.addServer(ref),
     *     onServerRemoved: (ref) => mcpSetup.removeServer(ref),
     *     onSubmitEnvVars: (ref, v, o) => mcpSetup.submitEnvVars(ref, v, o),
     *     onEnabledToolsChange: (ref, t) => mcpSetup.setEnabledTools(ref, t),
     *   }}
     * />
     * ```
     */
    readonly setup?: McpServerSetupIntegration;
    /**
     * When provided, the picker opens directly to the configure view for
     * the given server key (`"org/slug"`) instead of showing the list.
     *
     * Intended for flows where the caller already knows which server
     * needs configuration (e.g. a warning banner for a single
     * unconfigured server, or a chip click on a specific server).
     *
     * Only used as the initial view — subsequent navigation within the
     * picker is unaffected. Ignored if the key does not match any entry
     * in `setup.entries`.
     */
    readonly initialServerKey?: string;
    /**
     * Lookup function for pre-filling credential fields from the session
     * env pool. Passed through to {@link McpServerConfigPanel}'s
     * credentials form. When a field's key returns a value, the field is
     * pre-populated.
     */
    readonly poolValues?: (key: string) => EnvVarInput | undefined;
    /**
     * The authenticated user's active organization slug.
     * Used for OAuth token storage — tokens are stored in the user's personal
     * environment within this org, not the MCP server's org.
     * When omitted, falls back to the `org` prop.
     */
    readonly activeOrg?: string;
}
/**
 * Searchable picker for selecting MCP servers from the platform.
 *
 * Renders a search input and scrollable list of available MCP servers.
 * Designed to be placed inside a popover container — this component
 * renders the picker content, not the popover shell.
 *
 * Operates in two modes:
 *
 * **Simple mode** (default) — toggle servers on/off. Selected servers
 * produce `McpServerUsageInput[]` via `value`/`onChange`. No setup
 * flow, no per-tool selection.
 *
 * **Setup mode** (when `setup` is provided) — each selected server
 * shows its setup status (loading, needs credentials, ready). Users
 * can drill into a per-server configuration panel to provide
 * credentials and customize which tools to enable. Selection is
 * managed through `setup.entries` and the setup callbacks.
 *
 * All visual properties flow through `--stgm-*` tokens.
 *
 * @example
 * ```tsx
 * // Simple mode:
 * <McpServerPicker
 *   org="acme"
 *   value={mcpUsages}
 *   onChange={setMcpUsages}
 * />
 *
 * // Setup mode:
 * const mcpSetup = useMcpServerSetup("acme");
 * <McpServerPicker
 *   org="acme"
 *   setup={{
 *     entries: mcpSetup.entries,
 *     onServerAdded: (ref) => mcpSetup.addServer(ref),
 *     onServerRemoved: (ref) => mcpSetup.removeServer(ref),
 *     onSubmitEnvVars: (ref, v, o) => mcpSetup.submitEnvVars(ref, v, o),
 *     onEnabledToolsChange: (ref, t) => mcpSetup.setEnabledTools(ref, t),
 *   }}
 * />
 * ```
 */
export declare function McpServerPicker({ org, scope, value, onChange, onDisplayNameResolved, disabled, className, setup, initialServerKey, poolValues, activeOrg, }: McpServerPickerProps): import("react/jsx-runtime").JSX.Element | null;
//# sourceMappingURL=McpServerPicker.d.ts.map