import { JSBackendBase } from './backends';
import { ONNXRuntimeWebBackend } from './backends/ONNXRuntimeWebBackend';
import { AniraWasmConfig, AniraWasmInstance } from './factory';
import { Factory } from './utils';
import { AudioWorkletIOConfig } from './workers/messages';
import { BufferF, HostConfig, InferenceConfig, InferenceHandler, JSPrePostProcessor, ModelData, PrePostProcessor, ProcessingSpec, RingBuffer, TensorShape, TensorShapeList, VectorBufferF, VectorFloat, VectorInt64T, VectorModelData, VectorRingBuffer, VectorSizeT, VectorTensorShape, VectorUnsignedInt, VectorVectorInt64, InferenceBackendValues } from './wrappers';
import { PossiblePointer } from './wrappers/BaseWrapper';
import { InferenceThread } from './wrappers/system/InferenceThread';
export type ConfigureAudioWorkletIOOptions = Partial<AudioWorkletIOConfig> & {
    /**
     * Overrides for the underlying `AudioWorkletNode` constructor options.
     *
     * By default, the Web Audio node topology is derived from `inputChannels` /
     * `outputChannels` (i.e. `channelCount`, `channelCountMode: 'explicit'`, and
     * `outputChannelCount`). When anira's internal buffer shape does not match
     * the Web Audio channel layout (e.g. extra scratch channels for auxiliary
     * tensors), pass overrides here. Provided fields are merged on top of the
     * library defaults.
     */
    audioWorkletNodeOptions?: AudioWorkletNodeOptions;
};
export type ProcessorDescriptor = {
    backend: JSBackendBase;
    className: string;
};
export type InferenceWorker = {
    worker: Worker;
    registerProcessor: (descriptor: ProcessorDescriptor) => Promise<void>;
    unregisterProcessor: (backend: JSBackendBase) => Promise<void>;
    stop: () => Promise<void>;
};
export declare class AniraWeb {
    protected wasmInstance: AniraWasmInstance;
    protected memory: WebAssembly.Memory;
    protected wasmBinary: ArrayBuffer | null;
    private registeredProcessors;
    private activeWorkers;
    InferenceBackend: InferenceBackendValues;
    Buffer: Factory<typeof BufferF>;
    HostConfig: Factory<typeof HostConfig>;
    InferenceConfig: Factory<typeof InferenceConfig>;
    InferenceHandler: Factory<typeof InferenceHandler>;
    JSBackendBase: Factory<typeof JSBackendBase>;
    ONNXRuntimeWebBackend: Factory<typeof ONNXRuntimeWebBackend>;
    JSPrePostProcessor: Factory<typeof JSPrePostProcessor>;
    ModelData: Factory<typeof ModelData>;
    PrePostProcessor: Factory<typeof PrePostProcessor>;
    ProcessingSpec: Factory<typeof ProcessingSpec>;
    RingBuffer: Factory<typeof RingBuffer>;
    TensorShape: Factory<typeof TensorShape>;
    InferenceThread: Factory<typeof InferenceThread>;
    VectorBufferF: Factory<typeof VectorBufferF>;
    VectorFloat: Factory<typeof VectorFloat>;
    VectorInt64T: Factory<typeof VectorInt64T>;
    VectorModelData: Factory<typeof VectorModelData>;
    VectorRingBuffer: Factory<typeof VectorRingBuffer>;
    VectorSizeT: Factory<typeof VectorSizeT>;
    VectorTensorShape: Factory<typeof VectorTensorShape>;
    VectorUnsignedInt: Factory<typeof VectorUnsignedInt>;
    VectorVectorInt64: Factory<typeof VectorVectorInt64>;
    TensorShapeList: Factory<typeof TensorShapeList>;
    private static initWasm;
    /**
     * Instantiate the WASM module and return a ready-to-use ``AniraWeb``.
     * This is the standard entry point — see :doc:`../../basic_usage`.
     *
     * @param config - Optional Emscripten module overrides plus an
     *   ``processPrePost`` hook for users running their own JS pre/post
     *   dispatch outside the registry. Most callers pass nothing.
     * @param memory - Optional pre-allocated shared
     *   ``WebAssembly.Memory``. Used when reusing memory across
     *   multiple ``AniraWeb`` instances; defaults to a fresh 8192-page
     *   shared memory.
     */
    static create(config?: AniraWasmConfig & Record<string, unknown>, memory?: WebAssembly.Memory): Promise<AniraWeb>;
    constructor(module: AniraWasmInstance, memory: WebAssembly.Memory);
    /**
     * Restore Emscripten's stack pointer to a previously saved value.
     * Used internally when re-entering WASM from a worker thread; rarely
     * needed in user code.
     */
    stackRestore(ptr: number): void;
    /** Allocate ``size`` bytes in the WASM heap and return the pointer. */
    malloc(size: number): number;
    /** Free a pointer previously returned by :js:meth:`malloc`. */
    free(ptr: number): void;
    /** Return the shared ``WebAssembly.Memory`` backing the WASM module. */
    getMemory(): WebAssembly.Memory;
    /**
     * Return the underlying Emscripten module instance. Use this to call
     * raw WASM exports directly when the high-level wrappers don't cover
     * what you need.
     */
    getWasmInstance(): AniraWasmInstance;
    /**
     * Return a ``Float32Array`` view over the WASM module's ``HEAPF32``
     * buffer. Useful for reading or writing float32 data at raw heap
     * offsets.
     */
    getHeapF32(): Float32Array;
    /**
     * Return a ``Uint32Array`` view over the WASM module's ``HEAPU32``
     * buffer. Useful for reading or writing pointer-sized values at raw
     * heap offsets — for example the channel pointer arrays referenced
     * by :js:meth:`AniraAudioWorkletBase.buildMultiTensorPointers`.
     */
    getHeapU32(): Uint32Array;
    /**
     * Encode ``str`` as a null-terminated UTF-8 string in the WASM
     * heap and return the pointer. The caller is responsible for
     * :js:meth:`free`-ing the returned pointer when done.
     */
    allocWasmString(str: string): number;
    protected ensureWasmBinary(): Promise<ArrayBuffer>;
    protected allocateWorkerStack(): number;
    /**
     * Register a custom JS inference backend so the inference worker
     * can dispatch into it. Required for any backend that uses
     * ``InferenceBackend.CUSTOM`` — see :doc:`../../custom_inference_backends`.
     * The descriptor is also forwarded to all currently-running
     * inference workers so they can construct the backend on their side.
     */
    registerProcessor(backend: JSBackendBase, className: string): Promise<void>;
    /**
     * Inverse of :js:meth:`registerProcessor`. Removes the descriptor from the
     * main-thread registry and instructs all active inference workers to destroy
     * and deregister the backend (releasing any resources such as ORT sessions).
     */
    unregisterProcessor(backend: JSBackendBase): Promise<void>;
    /**
     * Return the inference workers currently spawned by this
     * ``AniraWeb``. The list is updated automatically when
     * :js:meth:`spinUpInferenceWorker` adds a worker or
     * ``InferenceWorker.stop`` removes one.
     */
    getActiveWorkers(): readonly InferenceWorker[];
    /**
     * Spawn a new inference worker (a Web Worker hosting an
     * ``InferenceThread``) and return its handle. Inference runs there
     * instead of on the audio thread, keeping the audio worklet
     * real-time-safe. Spin up multiple workers to run inference on
     * multiple batches in parallel — see :doc:`../../architecture`.
     *
     * @param workerOrUrl - Optional override for the worker entry point.
     *   Pass a ``URL`` to load a custom worker file (used by user-written
     *   JS backends, see :doc:`../../custom_inference_backends`), or an
     *   already-constructed ``Worker`` instance to take ownership of one
     *   you spawned yourself. Omit to use anira's bundled default worker.
     */
    spinUpInferenceWorker(workerOrUrl?: Worker | URL): Promise<InferenceWorker>;
    /**
     * Install anira's audio worklet module on the given ``AudioContext``.
     * Must be called once per context before
     * :js:meth:`configureAudioWorklet`.
     *
     * @param audioContext - The Web Audio context to install the
     *   worklet on.
     * @param workletUrl - Optional URL of a custom worklet file (a
     *   subclass of :js:class:`AniraAudioWorkletBase`, see
     *   :doc:`../../custom_audio_worklets`). Omit to use anira's bundled
     *   default worklet, which handles the simple single-tensor case.
     */
    registerAudioWorkletForContext(audioContext: AudioContext, workletUrl?: string | URL): Promise<void>;
    /**
     * Construct an ``AudioWorkletNode`` wired to ``inferenceHandlerPtr``
     * and ``prePostProcessorPtr`` and complete the configure handshake
     * so the worklet is ready to process audio. Allocates the input /
     * output scratch buffers in WASM memory and posts them to the
     * worklet thread.
     *
     * @param audioContext - The Web Audio context to attach the node to.
     * @param inferenceHandlerPtr - The :js:class:`InferenceHandler` (or
     *   its raw pointer) that will run inference for this worklet.
     * @param prePostProcessorPtr - The :js:class:`PrePostProcessor`
     *   used during inference.
     * @param audioWorkletNodeName - Processor name registered via
     *   ``registerProcessor`` inside the worklet file. Defaults to
     *   ``'inference-processor'`` (the bundled default worklet's name).
     * @param ioOptions - Channel counts, ``maxBufferSize``, and
     *   optional ``audioWorkletNodeOptions`` overrides. See
     *   :doc:`../../custom_audio_worklets` for the multi-tensor and
     *   custom-buffer-size cases.
     * @returns The connected, ready-to-use ``AudioWorkletNode``.
     */
    configureAudioWorklet(audioContext: AudioContext, inferenceHandlerPtr: PossiblePointer<InferenceHandler>, prePostProcessorPtr: PossiblePointer<PrePostProcessor>, audioWorkletNodeName?: string, ioOptions?: ConfigureAudioWorkletIOOptions): Promise<AudioWorkletNode>;
}
//# sourceMappingURL=AniraWeb.d.ts.map