import type Transform from './Transform.ts';
import type Sink from './Sink.ts';
interface WarpStreamOptions {
    signal?: AbortSignal;
}
/**
 * Composable async stream built on AsyncIterable.
 *
 * WarpStream is the domain concept for "data flow over time." It wraps
 * an AsyncIterable<T> and provides composable operations: pipe, tee,
 * mux, demux, drain.
 *
 * Backpressure is natural via `for await` (pull-based). Error propagation
 * uses the async iterator protocol: downstream throws trigger upstream
 * `return()` for cleanup. Cooperative cancellation via AbortSignal.
 *
 * When the dataset is unbounded, stream-first is not an optimization —
 * it is the honest API.
 */
export default class WarpStream<T> {
    _source: AsyncIterable<T>;
    _signal: AbortSignal | undefined;
    /**
     * Creates a WarpStream wrapping an async iterable source.
     */
    constructor(source: AsyncIterable<T>, options?: WarpStreamOptions);
    /**
     * Creates a WarpStream from any iterable or async iterable.
     */
    static from<V>(iterable: AsyncIterable<V> | Iterable<V>, options?: WarpStreamOptions): WarpStream<V>;
    /**
     * Creates a WarpStream from explicit values.
     */
    static of<V>(...items: V[]): WarpStream<V>;
    /**
     * Merges multiple streams into one (fan-in).
     *
     * Elements are interleaved in arrival order — whichever source yields
     * next gets emitted next. All sources are consumed concurrently.
     */
    static mux<V>(...streams: WarpStream<V>[]): WarpStream<V>;
    /**
     * Pipes this stream through a Transform, producing a new WarpStream.
     */
    pipe<U>(transform: Transform<T, U>): WarpStream<U>;
    /**
     * Splits this stream into two independent branches.
     *
     * Both branches receive all elements. Elements are buffered for the
     * slower branch (one element at a time via the pull protocol).
     */
    tee(): [WarpStream<T>, WarpStream<T>];
    /**
     * Splits this stream into named branches by a classifier function.
     *
     * Elements are routed to the branch whose key matches the classifier
     * result. Unknown keys are dropped.
     *
     * Note: demux eagerly consumes the source. All branches must be
     * consumed to avoid deadlock. Use for bounded fan-out where you know
     * the key space upfront.
     */
    demux(classify: (item: T) => string, keys: string[]): Map<string, WarpStream<T>>;
    /**
     * Drains this stream into a Sink and returns the accumulated result.
     */
    drain<R>(sink: Sink<T, R>): Promise<R>;
    /**
     * Reduces the stream to a single accumulated value.
     */
    reduce<R>(fn: (acc: R, item: T) => R | Promise<R>, init: R): Promise<R>;
    /**
     * Executes a function for each element. Returns when the stream ends.
     */
    forEach(fn: (item: T) => void | Promise<void>): Promise<void>;
    /**
     * Collects all elements into an array.
     *
     * **DANGER**: This materializes the entire stream. Use only when the
     * result is known to be bounded. For unbounded streams, use forEach(),
     * reduce(), or drain() instead.
     */
    collect(): Promise<T[]>;
    /** Makes WarpStream directly usable in `for await` loops. */
    [Symbol.asyncIterator](): AsyncIterator<T>;
    /**
     * Wraps the source with AbortSignal checking if a signal is set.
     */
    _withCancellation(): AsyncIterable<T>;
}
export {};
