import { Effect } from "@effect/core/io/Effect/definition";
import { Cause } from "@effect/core/io/Cause/definition";
import { ImmutableMap } from "@tsplus/stdlib/collections/ImmutableMap/definition";
import { FiberRef } from "@effect/core/io/FiberRef/definition";
import { List } from "@tsplus/stdlib/collections/List/definition";
import { Tuple } from "@tsplus/stdlib/data/Tuple/definition";
import { FiberId } from "@effect/core/io/FiberId/definition";
import { Fiber } from "@effect/core/io/Fiber/definition";
import { AtomicReference } from "@tsplus/stdlib/data/AtomicReference";
import { Stack } from "@tsplus/stdlib/data/Stack";
import { RuntimeConfig } from "@effect/core/io/RuntimeConfig/definition";
import { HashSet } from "@tsplus/stdlib/collections/HashSet/definition";
import { Exit } from "@effect/core/io/Exit/definition";
import { Either } from "@tsplus/stdlib/data/Either/definition";
import { Chunk } from "@tsplus/stdlib/collections/Chunk/definition";
import { FiberRefs } from "@effect/core/io/FiberRefs/definition";
import { Maybe } from "@tsplus/stdlib/data/Maybe/definition";
import { TraceElement } from "@effect/core/io/TraceElement/definition";
import { FiberScope } from "@effect/core/io/FiberScope/definition";
import { Trace } from "@effect/core/io/Trace/definition";
import { Deferred } from "@effect/core/io/Deferred/definition";
import { InterruptStatus } from "@effect/core/io/InterruptStatus/definition";
import { RuntimeConfigFlag } from "@effect/core/io/RuntimeConfig/Flag";
import { Lazy } from "@tsplus/stdlib/data/Function";
import { LogLevel } from "@effect/core/io/LogLevel/definition";
import { IllegalStateException, InterruptedException } from "@effect/core/io/Cause/errors";
import { Supervisor } from "@effect/core/io/Supervisor/definition";
import { AtomicBoolean } from "@tsplus/stdlib/data/AtomicBoolean";
import type { IFold, Instruction, IRaceWith } from "@effect/core/io/Effect/definition/primitives";
import type { Callback } from "@effect/core/io/Fiber/_internal/fiberState";
import { FiberState } from "@effect/core/io/Fiber/_internal/fiberState";
import { _A, _E, FiberSym } from "@effect/core/io/Fiber/definition";
import { FiberStatus } from "@effect/core/io/Fiber/status";
export declare class InterruptExit {
    readonly apply: (a: any) => Effect<any, any, any>;
    readonly trace?: string | undefined;
    readonly _tag = "InterruptExit";
    constructor(apply: (a: any) => Effect<any, any, any>, trace?: string | undefined);
}
export declare class Finalizer {
    readonly finalizer: Effect<never, never, any>;
    readonly handleInterrupts: () => void;
    readonly trace?: string | undefined;
    readonly _tag = "Finalizer";
    constructor(finalizer: Effect<never, never, any>, handleInterrupts: () => void, trace?: string | undefined);
    apply<X>(a: X): Effect<any, any, any>;
}
export declare class ApplyFrame {
    readonly apply: <X>(a: Cause<X>) => Effect<any, any, any>;
    readonly trace?: string | undefined;
    readonly _tag = "ApplyFrame";
    constructor(apply: <X>(a: Cause<X>) => Effect<any, any, any>, trace?: string | undefined);
}
export declare type Frame = InterruptExit | Finalizer | IFold<any, any, any, any, any, any, any, any, any> | ApplyFrame;
export declare type FiberRefLocals = ImmutableMap<FiberRef<unknown, unknown>, List.NonEmpty<Tuple<[FiberId.Runtime, unknown]>>>;
export declare const catastrophicFailure: import("@tsplus/stdlib/data/AtomicBoolean").AtomicBoolean;
export declare const currentFiber: import("@tsplus/stdlib/data/AtomicReference").AtomicReference<FiberContext<any, any> | null>;
export declare class FiberContext<E, A> implements Fiber.Runtime<E, A> {
    readonly _id: FiberId.Runtime;
    readonly childFibers: Set<FiberContext<any, any>>;
    readonly _tag = "RuntimeFiber";
    readonly [FiberSym]: FiberSym;
    readonly [_E]: () => E;
    readonly [_A]: () => A;
    readonly state: import("@tsplus/stdlib/data/AtomicReference").AtomicReference<FiberState<E, A>>;
    asyncEpoch: number;
    stack: Stack<Frame> | undefined;
    nextEffect: Effect<any, any, any> | undefined;
    runtimeConfig: RuntimeConfig;
    interruptStatus?: Stack<boolean> | undefined;
    fiberRefLocals: FiberRefLocals;
    constructor(_id: FiberId.Runtime, childFibers: Set<FiberContext<any, any>>, fiberRefLocals: FiberRefLocals, runtimeConfig: RuntimeConfig, interruptStatus?: Stack<boolean>);
    get fiberId(): FiberId;
    get _await(): Effect<never, never, Exit<E, A>>;
    get _children(): Effect<never, never, Chunk<Fiber.Runtime<any, any>>>;
    get _inheritRefs(): Effect<never, never, void>;
    get _poll(): Effect<never, never, Maybe<Exit<E, A>>>;
    _interruptAs(fiberId: FiberId): Effect<never, never, Exit<E, A>>;
    _location: TraceElement;
    get _scope(): FiberScope;
    get _status(): Effect<never, never, FiberStatus>;
    get _trace(): Effect<never, never, Trace>;
    _evalOn(effect: Effect<never, never, any>, orElse: Effect<never, never, any>): Effect<never, never, any>;
    _evalOnEffect<R, E2, A2>(effect: Effect<R, E2, A2>, orElse: Effect<R, E2, A2>): Effect<R, E2, A2>;
    unsafeGetDescriptor(): Fiber.Descriptor;
    get trackMetrics(): boolean;
    observeFailure(failure: string): void;
    unsafeLog(message: () => string, trace?: string): void;
    unsafeLogWith(message: Lazy<string>, cause: Lazy<Cause<unknown>>, overrideLogLevel: Maybe<LogLevel>, overrideRef1?: FiberRef<unknown, unknown> | null, overrideValue1?: unknown, trace?: string): void;
    get isStackEmpty(): boolean;
    pushContinuation(k: Frame): void;
    popContinuation(): Frame | undefined;
    unsafeNextEffect(previousSuccess: any): Instruction | undefined;
    /**
     * Unwinds the stack, leaving the first error handler on the top of the stack
     * (assuming one is found), and returning whether or not some folds had to be
     * discarded (indicating a change in the error type).
     */
    unsafeUnwindStack(): boolean;
    interruptExit: InterruptExit;
    pushInterruptStatus(flag: boolean): void;
    popInterruptStatus(): boolean | undefined;
    private unsafeInterruptAs;
    private unsafeSetInterrupting;
    /**
     * Disables interruption for the fiber.
     */
    private unsafeDisableInterrupting;
    private unsafeRestoreInterrupt;
    get unsafeIsInterrupted(): boolean;
    get unsafeIsInterruptible(): boolean;
    get unsafeIsInterrupting(): boolean;
    get unsafeShouldInterrupt(): boolean;
    unsafeGetRef<A, P>(fiberRef: FiberRef<A, P>): A;
    unsafeGetRefs(fiberRefLocals: FiberRefLocals): ImmutableMap<FiberRef<unknown, unknown>, unknown>;
    unsafeSetRef<A, P>(fiberRef: FiberRef<A, P>, value: A): void;
    unsafeDeleteRef<A, P>(fiberRef: FiberRef<A, P>): void;
    unsafeAddObserverMaybe(k: Callback<never, Exit<E, A>>): Exit<E, A> | undefined;
    unsafeRemoveObserver(k: Callback<never, Exit<E, A>>): void;
    unsafeNotifyObservers(v: Exit<E, A>, observers: List<Callback<never, Exit<E, A>>>): void;
    unsafeReportUnhandled(exit: Exit<E, A>, trace?: string): void;
    private unsafeAddSuppressed;
    private unsafeClearSuppressed;
    unsafeAddChild(child: FiberContext<any, any>): boolean;
    unsafePoll(): Maybe<Exit<E, A>>;
    unsafeCaptureTrace(prefix: Array<TraceElement>): Trace;
    unsafeEnterAsync(epoch: number, blockingOn: FiberId, trace: TraceElement): void;
    unsafeExitAsync(epoch: number): boolean;
    unsafeCreateAsyncResume(epoch: number): (_: Effect<any, any, any>) => void;
    unsafeSetAsyncCanceler(epoch: number, asyncCanceler0: Effect<any, any, any> | undefined): void;
    unsafeAddFinalizer(finalizer: Effect<never, never, any>): void;
    unsafeEvalOn(effect: Effect<never, never, any>): boolean;
    unsafeTryDone(exit: Exit<E, A>): Instruction | undefined;
    unsafeDrainMailbox(): Effect<never, never, any> | undefined;
    unsafeOnDone(k: Callback<never, Exit<E, A>>): void;
    /**
     * Forks an `IO` with the specified failure handler.
     */
    unsafeFork(effect: Instruction, trace: TraceElement, forkScope?: Maybe<FiberScope>): FiberContext<any, any>;
    complete<R, R1, R2, E2, A2, R3, E3, A3>(winner: Fiber<any, any>, loser: Fiber<any, any>, cont: (winner: Fiber<any, any>, loser: Fiber<any, any>) => Effect<any, any, any>, ab: AtomicReference<boolean>, cb: (_: Effect<R | R1 | R2 | R3, E2 | E3, A2 | A3>) => void): void;
    unsafeRace<R, E, A, R1, E1, A1, R2, E2, A2, R3, E3, A3>(race: IRaceWith<R, E, A, R1, E1, A1, R2, E2, A2, R3, E3, A3>, trace: TraceElement): Effect<R | R1 | R2 | R3, E2 | E3, A2 | A3>;
    unsafeRunLater(instr: Instruction): void;
    /**
     * The main evaluator loop for the fiber. For purely synchronous effects, this
     * will run either to completion, or for the specified maximum operation
     * count. For effects with asynchronous callbacks, the loop will proceed no
     * further than the first asynchronous boundary.
     */
    runUntil(maxOpCount: number): void;
    run(): void;
}
//# sourceMappingURL=context.d.ts.map