import type { IMatrixContext } from '../engine/core/IMatrixContext';
import type { IComponentDescriptor } from '../engine/core/IComponentDescriptor';
import type { IMatrixRuntime, ICreateOrGetResult } from '../engine/core/IMatrixRuntime';
import type { IChildDescriptor } from '../engine/core/IChildDescriptor';
import type { MatrixActor } from '../core/MatrixActor';
import type { IExternalAdapterOptions } from '../core/composite/IExternalAdapterOptions';
import type { ITransportAdapter } from '../engine/remoting/ITransportAdapter';
import type { IMailbox } from '../engine/mailbox/IMailbox';
import type { IRuntimeConfig } from './IRuntimeConfig';
import type { IDomStrategy } from './IDomStrategy';
import type { IRuntimeHost } from './IRuntimeHost';
import type { IRuntimeStats } from './IRuntimeStats';
import type { RuntimeEventListener } from './IRuntimeEvent';
import type { ITopicClaimRegistry } from '../core/security/ITopicClaimRegistry';
/**
 * MatrixRuntime — the ONE unified runtime for Matrix-3.
 *
 * Supports both headless (no DOM) and browser (with IDomStrategy) modes.
 *
 * Headless mode: `new MatrixRuntime({ transport })`
 * Browser mode:  `new MatrixRuntime({ transport, domStrategy: new BrowserDomStrategy() })`
 */
export declare class MatrixRuntime implements IMatrixRuntime {
    private readonly logger;
    private readonly rootContext;
    private readonly mailboxFactory;
    private readonly _components;
    private readonly _subs;
    private readonly eventListeners;
    private readonly startTime;
    private readonly domStrategy?;
    /** @deprecated Legacy host — kept during migration, will be removed */
    private readonly host?;
    private readonly registry?;
    private readonly _allowDynamicCompilation;
    private readonly _enableTopicClaiming;
    private readonly _topicClaimRegistry;
    /** Blueprints for supervised root actors — class + props for restart */
    private readonly _rootBlueprints;
    /** Restart timestamps per mount — mirrors SupervisorBehavior._tooManyRestarts */
    private readonly _rootRestartTracking;
    /** Unsub functions for $exit monitors */
    private readonly _rootExitUnsubs;
    /** Supervision policy for root actors */
    private readonly _rootSupervisionPolicy;
    private running;
    private mountCounter;
    private _rootJoinUnsub?;
    /** Tracks registered external adapters */
    private _adapters;
    constructor(config?: IRuntimeConfig);
    get type(): 'headless' | 'browser';
    get supportsDom(): boolean;
    /**
     * Create a child component (UI Control Inversion).
     * Supports 5 instantiation modes: create_new, reuse_existing, singleton, replace, create_unique.
     */
    createChild(parentContext: IMatrixContext, id: string, descriptor: IComponentDescriptor): Promise<string>;
    /**
     * Create or get existing child (Vision 21 Pillar 6: createOrGet semantics).
     */
    createOrGetChild(parentContext: IMatrixContext, id: string, descriptor: IComponentDescriptor): Promise<ICreateOrGetResult>;
    /**
     * Convenience method — create a component directly at root level.
     */
    create<T extends MatrixActor>(ComponentClass: new () => T, id?: string, props?: Record<string, unknown>): Promise<T>;
    /**
     * Create a supervised root-level actor.
     * The runtime stores a blueprint (class + props) and monitors the actor's
     * $exit signal. On crash, restarts from blueprint if within restart budget.
     * Follows OTP: runtime is init/PID 0, supervision is orthogonal to naming.
     */
    createSupervised<T extends MatrixActor>(ComponentClass: new () => T, id: string, props?: Record<string, unknown>): Promise<T>;
    /**
     * Subscribe to a root actor's $exit topic for supervision.
     */
    private _monitorRootActor;
    /**
     * Handle a root actor crash. Check restart budget, then recreate from blueprint.
     * Mirrors SupervisorBehavior._restartChild + _tooManyRestarts.
     */
    private _handleRootActorExit;
    /**
     * Internal createChild with full instantiation mode support.
     */
    private _createChildInternal;
    private _createNewComponent;
    private _generateUniqueId;
    private _assignProps;
    private _getPropertyDescriptor;
    createMailbox(mount: string): IMailbox;
    remove(mount: string): Promise<void>;
    hasComponent(mount: string): boolean;
    /**
     * @deprecated Use transport-based communication instead.
     */
    getComponent<T extends MatrixActor>(id: string): T | undefined;
    getAllComponents(): MatrixActor[];
    waitForReady(id: string, timeoutMs?: number): Promise<void>;
    subscribe(topic: string, handler: (payload: unknown, meta: {
        topic: string;
        ts: number;
    }) => void): () => void;
    publish(topic: string, payload?: unknown): void;
    sendTo(mount: string, command: string, payload?: unknown): void;
    /**
     * Register a well-known service on the root context.
     * All child contexts inherit services from their parent chain,
     * so any actor in this runtime can discover the service via context.getService().
     */
    registerService<T>(key: string | symbol, service: T): void;
    onEvent(mount: string, event: string, handler: (payload: unknown) => void): () => void;
    parseTemplate(_html: string): Promise<IChildDescriptor[]>;
    registerComponent(tag: string, constructor: CustomElementConstructor): void;
    registerComponents(components: Record<string, CustomElementConstructor>): void;
    createElement<T extends HTMLElement = HTMLElement>(tag: string, attributes?: Record<string, string>): Promise<T>;
    mount(element: HTMLElement, parentContext?: IMatrixContext): Promise<void>;
    unmount(element: HTMLElement): Promise<void>;
    get isRunning(): boolean;
    shutdown(): Promise<void>;
    getRootContext(): IMatrixContext;
    getHost(): IRuntimeHost | undefined;
    getDomStrategy(): IDomStrategy | undefined;
    get transport(): ITransportAdapter;
    get rootMount(): string;
    getStats(): IRuntimeStats;
    getActiveComponents(): import("./IRuntimeComponent").IRuntimeComponent[];
    getComponentsByTag(tag: string): import("./IRuntimeComponent").IRuntimeComponent[];
    whenComponentDefined(tag: string): Promise<void>;
    isDynamicCompilationAllowed(): boolean;
    isTopicClaimingEnabled(): boolean;
    getTopicClaimRegistry(): ITopicClaimRegistry;
    private _registerTopicClaim;
    private _releaseTopicClaim;
    private _canCreateChild;
    registerExternalAdapter(id: string, componentClass: new () => unknown, options?: IExternalAdapterOptions): string | undefined;
    /**
     * Register a foreign web component class as a Matrix actor (M1: FP-1.3).
     *
     * Applies MatrixActorMixin to the foreign class, copies static metadata,
     * and defines a custom element. The resulting element has both the foreign
     * class's behavior AND the Matrix protocol (`.mx` facade).
     *
     * @param tagName - Custom element tag (e.g., 'mx-sl-button')
     * @param ForeignClass - Any HTMLElement subclass (e.g., SlButton)
     * @param config - Matrix metadata: accepts, emits, description
     * @returns The tag name, or undefined if custom elements unavailable
     *
     * @example
     * ```typescript
     * runtime.registerExternalComponent('mx-sl-button', SlButton, {
     *   accepts: { 'button.click': {} },
     *   emits: { 'button.clicked': {} },
     *   description: 'Shoelace button with Matrix protocol',
     * });
     * ```
     */
    registerExternalComponent(tagName: string, ForeignClass: new (...args: any[]) => HTMLElement, config?: {
        accepts?: Record<string, unknown>;
        emits?: Record<string, unknown>;
        description?: string;
    }): string | undefined;
    unregisterExternalAdapter(id: string): void;
    hasExternalAdapter(id: string): boolean;
    on(listener: RuntimeEventListener): () => void;
    private emit;
    private createChildContext;
    private ensureRunning;
    private _buildAdapterTemplate;
    private _registerBasicAdapter;
}
//# sourceMappingURL=MatrixRuntime.d.ts.map