/**
 * A live, per-interaction scratch space owned by the chat host (keyed by
 * `interactionId`) and handed to a widget on every (re)mount.
 *
 * WHY: an interaction widget element is destroyed+recreated on layout reflow
 * (GoldenLayout rebuilds/reparents on panel add/remove AND on drag), on
 * dock/undock, and on transcript re-render (the keyless `repeat`). The element
 * cannot hold anything live across that; this object can, because the host keeps
 * it alive for the interaction's lifetime, independent of the element. (GENC-1390)
 *
 * LIVE-ONLY — never persisted. A reload / project switch / session restore wipes
 * it; the interaction is then rebuilt purely from the serialisable `data` +
 * `result`. Never store here anything that must survive a reload: durable inputs
 * belong in the interaction's `data`, the outcome in its resolved payload.
 *
 * LIFETIME — created lazily when the interaction is requested, reused for every
 * remount of that same `interactionId`. Torn down (its `onDispose` callbacks fire
 * once) when the interaction RESOLVES or is evicted — NOT when the element
 * unmounts. That inversion is the point: a transient unmount (drag, re-render)
 * must leave context-owned resources (sockets, timers) untouched; only completion
 * ends them.
 *
 * NOTE: `subscribe`/`notify` are a plain observer list, not a reactivity engine
 * and not a FAST dependency. `notify()` renders nothing — it signals the
 * currently-mounted element "state changed, re-read", and the element updates its
 * own observables and re-renders with whatever primitives it has.
 *
 * @beta
 */
export interface InteractionContext<TState extends object = Record<string, unknown>> {
    /** Stable id of the interaction this context belongs to. */
    readonly interactionId: string;
    /**
     * Durable, remount-surviving source of truth for the interaction — a socket
     * handle, the current phase, a half-typed draft. A plain object, deliberately
     * NOT reactive: a widget renders from its own observables and reads/writes this
     * on mount and on change so the next remount can recover.
     */
    readonly state: TState;
    /**
     * Run `factory` at most once for this interaction's lifetime and memoise the
     * result; every later call with the same `key` (including after a remount)
     * returns the stored value without re-running. Covers one-shot side effects and
     * create-once live resources alike:
     *
     * ```ts
     * ctx.once('open-panel', () => this.dispatchEvent(openPanelEvent)); // fires once, ever
     * const ws = ctx.once('ws', () => new TestDataWebSocketService());  // same instance each remount
     * ```
     *
     * Returns `null` once the interaction has ended (resolve/timeout/evict): the
     * factory is NOT run, because a resource created on a disposed context would
     * never be torn down (its `onDispose` has already fired). A widget that opens a
     * live resource here must guard on the resolved state and stop touching `once`
     * when the interaction completes — a stray late call (e.g. an async callback
     * landing after a `timeoutMs` timeout) gets `null` rather than a leaked resource.
     */
    once<T>(key: string, factory: () => T): T | null;
    /**
     * Signal that `state` changed so subscribers re-read. NOT a renderer —
     * just a change ping; the subscribing element updates its own observables.
     */
    notify(): void;
    /**
     * Observe `state` changes. Call in `connectedCallback`; call the returned
     * unsubscribe in `disconnectedCallback`.
     */
    subscribe(listener: () => void): () => void;
    /**
     * Register a teardown run exactly once when the interaction ends (resolve or
     * evict) — the correct home for closing sockets/timers created via `once`.
     * Decoupled from the element's `disconnectedCallback`, which fires on every
     * transient unmount and must NOT tear these down. Registering after the context
     * has already been disposed runs `fn` immediately.
     */
    onDispose(fn: () => void): void;
}
//# sourceMappingURL=interaction-context.d.ts.map