/**
 * Coordinator bridge for the section runtime engine adapter (M7 —
 * Variant C, layered).
 *
 * Unlike the DOM / framework-error bridges (which translate
 * **outputs** into I/O), the coordinator bridge is an **input source**:
 * it listens to a `ToolkitCoordinator` and feeds the resulting events
 * into the core via the `dispatchCoreInput` callback supplied by the
 * adapter.
 *
 * Responsibilities:
 *   1. **Framework-error subscription.** When the coordinator reports
 *      a framework error through its bus, dispatch a
 *      `{ kind: "framework-error" }` core input. Listener isolation
 *      matches `FrameworkErrorBus`: a throwing bridge handler is
 *      caught and `console.warn`-logged so the original fan-out is
 *      not interrupted.
 *
 *   2. **Section-controller resolution.** When the host calls
 *      `resolveSectionController({ ... })`, the bridge invokes
 *      `coordinator.getOrCreateSectionController({ ... })` and, on
 *      successful resolution, dispatches
 *      `{ kind: "section-controller-resolved" }` to the core. Init
 *      tokens guard against late resolutions overwriting a more
 *      recent cohort (mirrors `SectionRuntimeEngine.initialize`'s
 *      `activeInitToken` pattern).
 *
 *   3. **Disposal.** On `dispose()`, the bridge unsubscribes from the
 *      framework-error bus and (if the engine owns the section
 *      controller for the cohort) calls
 *      `coordinator.disposeSectionController({ ... })`. It does
 *      **not** dispose the coordinator itself — the coordinator's
 *      lifetime is owned by the toolkit CE / host, not by the engine.
 *
 * Disposal is idempotent: calling `dispose()` twice is a no-op.
 *
 * The bridge **must not** import `svelte`.
 */
import type { SectionControllerHandle } from "../../services/section-controller-types.js";
import type { CohortKey } from "../core/cohort.js";
import type { SectionEngineInput } from "../core/engine-input.js";
/**
 * Subset of the `ToolkitCoordinator` surface the bridge consumes. Kept
 * structural so tests can pass a fake without pulling the full
 * coordinator.
 */
export interface CoordinatorPort {
    subscribeFrameworkErrors(listener: (model: import("../../services/framework-error.js").FrameworkErrorModel) => void): () => void;
    getOrCreateSectionController(args: {
        sectionId: string;
        attemptId?: string;
        input?: unknown;
        updateExisting?: boolean;
        createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
    }): Promise<SectionControllerHandle>;
    disposeSectionController(args: {
        sectionId: string;
        attemptId?: string;
    }): Promise<void>;
}
export interface ResolveSectionControllerArgs {
    cohort: CohortKey;
    assessmentId: string;
    view: string;
    section: unknown;
    createDefaultController: () => SectionControllerHandle | Promise<SectionControllerHandle>;
    /**
     * Optional callback invoked when the controller resolves and on
     * every controller `subscribe` event. The kernel uses this to keep
     * its composition snapshot in sync with the controller's view.
     *
     * The bridge is responsible for unsubscribing on dispose / cohort
     * change so a stale controller doesn't keep emitting after rollover.
     */
    onCompositionChanged?: (composition: unknown) => void;
    /**
     * Optional callback invoked once with the resolved controller handle
     * the moment it is available. Lets the host keep a reference for
     * direct method calls (e.g. `navigateToItem`, `applySession`)
     * without re-querying the coordinator.
     */
    onControllerResolved?: (controller: SectionControllerHandle) => void;
}
export interface CoordinatorBridgeOptions {
    coordinator: CoordinatorPort;
    dispatchCoreInput: (input: SectionEngineInput) => void;
}
export interface CoordinatorBridgeHandle {
    resolveSectionController(args: ResolveSectionControllerArgs): Promise<void>;
    dispose(): Promise<void>;
}
export declare function createCoordinatorBridge(options: CoordinatorBridgeOptions): CoordinatorBridgeHandle;
