import { Exit } from "@effect/core/io/Exit/definition";
import { Effect } from "@effect/core/io/Effect/definition";
import { ImmutableQueue } from "@tsplus/stdlib/collections/ImmutableQueue/definition";
import type { ErasedChannel, ErasedExecutor } from "@effect/core/stream/Channel/ChannelExecutor";
import type { ChildExecutorDecision } from "@effect/core/stream/Channel/ChildExecutorDecision";
import type { UpstreamPullRequest } from "@effect/core/stream/Channel/UpstreamPullRequest";
import type { UpstreamPullStrategy } from "@effect/core/stream/Channel/UpstreamPullStrategy";
export declare const SubexecutorSym: unique symbol;
export declare type SubexecutorSym = typeof SubexecutorSym;
/**
 * @tsplus type ets/Channel/Subexecutor
 */
export interface Subexecutor<R> {
    readonly [SubexecutorSym]: SubexecutorSym;
    readonly close: (exit: Exit<unknown, unknown>, __tsplusTrace?: string) => Effect<R, never, unknown> | undefined;
    readonly enqueuePullFromChild: (child: PullFromChild<R>) => Subexecutor<R>;
}
/**
 * @tsplus type ets/Channel/Subexecutor/Ops
 */
export interface SubexecutorOps {
}
export declare const Subexecutor: SubexecutorOps;
/**
 * Execute upstreamExecutor and for each emitted element, spawn a child
 * channel and continue with processing it by `PullFromChild`.
 */
export declare class PullFromUpstream<R> implements Subexecutor<R> {
    readonly upstreamExecutor: ErasedExecutor<R>;
    readonly createChild: (_: unknown) => ErasedChannel<R>;
    readonly lastDone: unknown;
    readonly activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>;
    readonly combineChildResults: (x: unknown, y: unknown) => unknown;
    readonly combineWithChildResult: (x: unknown, y: unknown) => unknown;
    readonly onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>;
    readonly onEmit: (_: unknown) => ChildExecutorDecision;
    readonly _tag = "PullFromUpstream";
    readonly [SubexecutorSym]: SubexecutorSym;
    constructor(upstreamExecutor: ErasedExecutor<R>, createChild: (_: unknown) => ErasedChannel<R>, lastDone: unknown, activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>, combineChildResults: (x: unknown, y: unknown) => unknown, combineWithChildResult: (x: unknown, y: unknown) => unknown, onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>, onEmit: (_: unknown) => ChildExecutorDecision);
    close(exit: Exit<unknown, unknown>, __tsplusTrace?: string): Effect<R, never, unknown> | undefined;
    enqueuePullFromChild(child: PullFromChild<R>): Subexecutor<R>;
}
/**
 * Execute the childExecutor and on each emitted value, decide what to do by
 * `onEmit`.
 */
export declare class PullFromChild<R> implements Subexecutor<R> {
    readonly childExecutor: ErasedExecutor<R>;
    readonly parentSubexecutor: Subexecutor<R>;
    readonly onEmit: (_: unknown) => ChildExecutorDecision;
    readonly _tag = "PullFromChild";
    readonly [SubexecutorSym]: SubexecutorSym;
    constructor(childExecutor: ErasedExecutor<R>, parentSubexecutor: Subexecutor<R>, onEmit: (_: unknown) => ChildExecutorDecision);
    close(exit: Exit<unknown, unknown>, __tsplusTrace?: string): Effect<R, never, unknown> | undefined;
    enqueuePullFromChild(_: PullFromChild<R>): Subexecutor<R>;
}
export declare class DrainChildExecutors<R> implements Subexecutor<R> {
    readonly upstreamExecutor: ErasedExecutor<R>;
    readonly lastDone: unknown;
    readonly activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>;
    readonly upstreamDone: Exit<unknown, unknown>;
    readonly combineChildResults: (x: unknown, y: unknown) => unknown;
    readonly combineWithChildResult: (x: unknown, y: unknown) => unknown;
    readonly onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>;
    readonly _tag = "DrainChildExecutors";
    readonly [SubexecutorSym]: SubexecutorSym;
    constructor(upstreamExecutor: ErasedExecutor<R>, lastDone: unknown, activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>, upstreamDone: Exit<unknown, unknown>, combineChildResults: (x: unknown, y: unknown) => unknown, combineWithChildResult: (x: unknown, y: unknown) => unknown, onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>);
    close(exit: Exit<unknown, unknown>, __tsplusTrace?: string): Effect<R, never, unknown> | undefined;
    enqueuePullFromChild(child: PullFromChild<R>): Subexecutor<R>;
}
export declare class Emit<R> implements Subexecutor<R> {
    readonly value: unknown;
    readonly next: Subexecutor<R>;
    readonly _tag = "Emit";
    readonly [SubexecutorSym]: SubexecutorSym;
    constructor(value: unknown, next: Subexecutor<R>);
    close(exit: Exit<unknown, unknown>, __tsplusTrace?: string): Effect<R, never, unknown> | undefined;
    enqueuePullFromChild(_child: PullFromChild<R>): Subexecutor<R>;
}
/**
 * @tsplus macro remove
 */
export declare function concreteSubexecutor<R>(_: Subexecutor<R>): asserts _ is PullFromUpstream<R> | PullFromChild<R> | DrainChildExecutors<R> | Emit<R>;
/**
 * @tsplus static ets/Channel/Subexecutor/Ops PullFromUpstream
 * @tsplus location "@effect/core/stream/Channel/Subexecutor"
 */
export declare function pullFromUpstream<R>(upstreamExecutor: ErasedExecutor<R>, createChild: (_: unknown) => ErasedChannel<R>, lastDone: unknown, activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>, combineChildResults: (x: unknown, y: unknown) => unknown, combineWithChildResult: (x: unknown, y: unknown) => unknown, onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>, onEmit: (_: unknown) => ChildExecutorDecision): Subexecutor<R>;
/**
 * @tsplus static ets/Channel/Subexecutor/Ops PullFromChild
 * @tsplus location "@effect/core/stream/Channel/Subexecutor"
 */
export declare function pullFromChild<R>(childExecutor: ErasedExecutor<R>, parentSubexecutor: Subexecutor<R>, onEmit: (_: unknown) => ChildExecutorDecision): Subexecutor<R>;
/**
 * @tsplus static ets/Channel/Subexecutor/Ops DrainChildExecutors
 * @tsplus location "@effect/core/stream/Channel/Subexecutor"
 */
export declare function drainChildExecutors<R>(upstreamExecutor: ErasedExecutor<R>, lastDone: unknown, activeChildExecutors: ImmutableQueue<PullFromChild<R> | undefined>, upstreamDone: Exit<unknown, unknown>, combineChildResults: (x: unknown, y: unknown) => unknown, combineWithChildResult: (x: unknown, y: unknown) => unknown, onPull: (_: UpstreamPullRequest<unknown>) => UpstreamPullStrategy<unknown>): Subexecutor<R>;
/**
 * @tsplus static ets/Channel/Subexecutor/Ops Emit
 * @tsplus location "@effect/core/stream/Channel/Subexecutor"
 */
export declare function emit<R>(value: unknown, next: Subexecutor<R>): Subexecutor<R>;
//# sourceMappingURL=Subexecutor.d.ts.map