import type { IMatrixContext } from '../engine/core/IMatrixContext';
/**
 * Metadata about a Matrix component.
 */
export interface IComponentMetadata {
    /** Component's mount path (e.g., "app.tree.node1") */
    mount: string;
    /** Component class name (e.g., "FractalTree") */
    componentClass: string;
    /** List of accepted command names */
    accepts: string[];
    /** List of emitted event names */
    emits: string[];
    /** Custom element tag name for rendering */
    shellTag?: string;
    /** Module URL for dynamic shell loading */
    moduleUrl?: string;
    /** Schema definitions for accepts */
    acceptsSchema?: Record<string, unknown>;
    /** Schema definitions for emits */
    emitsSchema?: Record<string, unknown>;
}
/**
 * IMatrixComponent - The fundamental interface for Matrix components in Flow DSL.
 *
 * Like LINQ's IEnumerable<T> or Rx's IObservable<T>, this interface provides:
 * - A consistent return type for fluent chaining
 * - Strongly-typed operations on Matrix components
 * - Navigation to children via Matrix protocol
 *
 * Example:
 * ```typescript
 * // Get a component
 * const tree: IMatrixComponent = await flow()
 *   .fromValue({})
 *   .viaRemote("app.tree", "introspect")
 *   .asComponent();
 *
 * // Chain operations - each returns IMatrixComponent
 * const node = await tree.child("root-1");
 * await node.send("setLabel", { label: "New Label" });
 *
 * // Navigate deeper
 * const grandchild = await tree.child("root-1").then(n => n.child("sub-1"));
 * ```
 */
export interface IMatrixComponent {
    /** Component's mount path */
    readonly mount: string;
    /** Component class name */
    readonly componentClass: string;
    /** Commands this component accepts */
    readonly accepts: string[];
    /** Events this component emits */
    readonly emits: string[];
    /** Shell tag for rendering (if available) */
    readonly shellTag?: string;
    /** Full metadata object */
    readonly metadata: IComponentMetadata;
    /** Whether this component can be rendered (has shellTag) */
    readonly canRender: boolean;
    /**
     * Get a child component by name.
     * Returns another IMatrixComponent, enabling fluent chaining.
     *
     * @param name - Child name (appended to mount: "parent.child")
     * @returns Promise resolving to child as IMatrixComponent
     *
     * @example
     * const child = await tree.child("root-1");
     * const grandchild = await child.child("sub-1");
     */
    child(name: string): Promise<IMatrixComponent>;
    /**
     * Get the parent component (if this is a child).
     * Returns another IMatrixComponent.
     *
     * @returns Promise resolving to parent as IMatrixComponent, or null if root
     */
    parent(): Promise<IMatrixComponent | null>;
    /**
     * Refresh metadata by calling introspect again.
     * Returns the same component with updated metadata.
     */
    refresh(): Promise<IMatrixComponent>;
    /**
     * Send a command to this component and get the result.
     *
     * @param command - Command name (must be in accepts)
     * @param params - Command parameters
     * @returns Promise resolving to command result
     *
     * @example
     * const result = await component.send("addChild", { label: "New" });
     */
    send<TParams = unknown, TResult = unknown>(command: string, params?: TParams): Promise<TResult>;
    /**
     * Fire-and-forget publish to this component.
     *
     * @param command - Command name
     * @param payload - Command payload
     */
    publish(command: string, payload?: unknown): void;
    /**
     * Subscribe to an event from this component.
     *
     * @param event - Event name (must be in emits)
     * @param handler - Event handler
     * @returns Unsubscribe function
     */
    subscribe(event: string, handler: (payload: unknown, meta: {
        topic: string;
        ts: number;
    }) => void): () => void;
    /**
     * Render this component into a container as a proxy (ghost mode).
     * The rendered shell forwards commands to the remote component.
     *
     * @param container - DOM element to render into
     * @returns The created shell element, or null if cannot render
     */
    render(container: HTMLElement): Promise<HTMLElement | null>;
    /**
     * Render this component as a full clone with state replication.
     *
     * @param container - DOM element to render into
     * @returns The created shell element, or null if cannot render
     */
    renderClone(container: HTMLElement): Promise<HTMLElement | null>;
    /**
     * Get a proxy that allows calling accepts commands directly as methods.
     *
     * @example
     * const proxy = component.asProxy();
     * await proxy.setLabel({ label: "New" }); // Calls send("setLabel", {...})
     * await proxy.addChild({ label: "Child" });
     */
    asProxy(): this & Record<string, (...args: unknown[]) => Promise<unknown>>;
    /**
     * Get the raw introspect data.
     */
    toJSON(): IComponentMetadata;
    /**
     * String representation.
     */
    toString(): string;
}
/**
 * Type guard to check if a value is an IMatrixComponent.
 */
export declare function isMatrixComponent(value: unknown): value is IMatrixComponent;
/**
 * Options for creating a MatrixComponentImpl.
 */
export interface IMatrixComponentOptions {
    /** The Matrix context for transport */
    context: IMatrixContext;
    /** Component metadata (from introspect or provided) */
    metadata: IComponentMetadata;
}
//# sourceMappingURL=IMatrixComponent.d.ts.map