import "../../../Operator"
import * as Cause from "../../../Cause"
import * as T from "../../../Effect"
import type * as Exit from "../../../Exit"
import type * as M from "../../../Managed"
import * as P from "./_internal/primitives"
import type { AsyncInputProducer } from "./_internal/producer"
export type { Channel } from "./_internal/primitives"
export type {
  SingleProducerAsyncInput,
  makeSingleProducerAsyncInput
} from "./_internal/producer"
/**
 * Pipe the output of a channel into the input of another
 */
export declare function pipeTo_<
  Env,
  Env2,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone,
  OutErr2,
  OutElem2,
  OutDone2
>(
  left: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  right: P.Channel<Env2, OutErr, OutElem, OutDone, OutErr2, OutElem2, OutDone2>
): P.Channel<Env & Env2, InErr, InElem, InDone, OutErr2, OutElem2, OutDone2>
/**
 * Pipe the output of a channel into the input of another
 *
 * @dataFirst pipeTo_
 */
export declare function pipeTo<
  Env2,
  OutErr,
  OutElem,
  OutDone,
  OutErr2,
  OutElem2,
  OutDone2
>(
  right: P.Channel<Env2, OutErr, OutElem, OutDone, OutErr2, OutElem2, OutDone2>
): <Env, InErr, InElem, InDone>(
  left: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
) => P.Channel<Env & Env2, InErr, InElem, InDone, OutErr2, OutElem2, OutDone2>
/**
 * Reads an input and continue exposing both full error cause and completion
 */
export declare function readWithCause<
  Env,
  Env1,
  Env2,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutErr1,
  OutErr2,
  OutElem,
  OutElem1,
  OutElem2,
  OutDone,
  OutDone1,
  OutDone2
>(
  inp: (i: InElem) => P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  halt: (
    e: Cause.Cause<InErr>
  ) => P.Channel<Env1, InErr, InElem, InDone, OutErr1, OutElem1, OutDone1>,
  done: (
    d: InDone
  ) => P.Channel<Env2, InErr, InElem, InDone, OutErr2, OutElem2, OutDone2>
): P.Channel<
  Env & Env1 & Env2,
  InErr,
  InElem,
  InDone,
  OutErr | OutErr1 | OutErr2,
  OutElem | OutElem1 | OutElem2,
  OutDone | OutDone1 | OutDone2
>
/**
 * Reads an input and continue exposing both error and completion
 */
export declare function readWith<
  Env,
  Env1,
  Env2,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutErr1,
  OutErr2,
  OutElem,
  OutElem1,
  OutElem2,
  OutDone,
  OutDone1,
  OutDone2
>(
  inp: (i: InElem) => P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  error: (
    e: InErr
  ) => P.Channel<Env1, InErr, InElem, InDone, OutErr1, OutElem1, OutDone1>,
  done: (
    d: InDone
  ) => P.Channel<Env2, InErr, InElem, InDone, OutErr2, OutElem2, OutDone2>
): P.Channel<
  Env & Env1 & Env2,
  InErr,
  InElem,
  InDone,
  OutErr | OutErr1 | OutErr2,
  OutElem | OutElem1 | OutElem2,
  OutDone | OutDone1 | OutDone2
>
/**
 * End a channel with the specified result
 */
export declare function endWith<OutDone>(
  result: () => OutDone
): P.Channel<unknown, unknown, unknown, unknown, never, never, OutDone>
/**
 * End a channel with the specified result
 */
export declare function end<OutDone>(
  result: OutDone
): P.Channel<unknown, unknown, unknown, unknown, never, never, OutDone>
/**
 * Halt a channel with the specified cause
 */
export declare function haltWith<E>(
  result: () => Cause.Cause<E>
): P.Channel<unknown, unknown, unknown, unknown, E, never, never>
/**
 * Halt a channel with the specified cause
 */
export declare function halt<E>(
  result: Cause.Cause<E>
): P.Channel<unknown, unknown, unknown, unknown, E, never, never>
/**
 * Halt a channel with the specified error
 */
export declare function failWith<E>(
  error: () => E
): P.Channel<unknown, unknown, unknown, unknown, E, never, never>
/**
 * Halt a channel with the specified error
 */
export declare function fail<E>(
  error: E
): P.Channel<unknown, unknown, unknown, unknown, E, never, never>
/**
 * Halt a channel with the specified exception
 */
export declare function die(
  defect: unknown
): P.Channel<unknown, unknown, unknown, unknown, never, never, never>
/**
 * Halt a channel with the specified exception
 */
export declare function dieWith(
  defect: () => unknown
): P.Channel<unknown, unknown, unknown, unknown, never, never, never>
/**
 * Writes an output to the channel
 */
export declare function writeWith<OutElem>(
  out: () => OutElem
): P.Channel<unknown, unknown, unknown, unknown, never, OutElem, void>
/**
 * Writes an output to the channel
 */
export declare function write<OutElem>(
  out: OutElem
): P.Channel<unknown, unknown, unknown, unknown, never, OutElem, void>
/**
 * Returns a new channel with an attached finalizer. The finalizer is guaranteed to be executed
 * so long as the channel begins execution (and regardless of whether or not it completes).
 */
export declare function ensuringWith_<
  Env,
  Env2,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  channel: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  finalizer: (e: Exit.Exit<OutErr, OutDone>) => T.Effect<Env2, never, unknown>
): P.Channel<Env & Env2, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Returns a new channel with an attached finalizer. The finalizer is guaranteed to be executed
 * so long as the channel begins execution (and regardless of whether or not it completes).
 *
 * @dataFirst ensuringWith_
 */
export declare function ensuringWith<Env2, OutErr, OutDone>(
  finalizer: (e: Exit.Exit<OutErr, OutDone>) => T.Effect<Env2, never, unknown>
): <Env, InErr, InElem, InDone, OutElem>(
  channel: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
) => P.Channel<Env & Env2, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Returns a new channel whose outputs are fed to the specified factory function, which creates
 * new channels in response. These new channels are sequentially concatenated together, and all
 * their outputs appear as outputs of the newly returned channel. The provided merging function
 * is used to merge the terminal values of all channels into the single terminal value of the
 * returned channel.
 */
export declare function concatMapWith_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutElem2,
  OutDone,
  OutDone2,
  OutDone3,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2
>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone2>,
  f: (
    o: OutElem
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem2, OutDone>,
  g: (o: OutDone, o1: OutDone) => OutDone,
  h: (o: OutDone, o2: OutDone2) => OutDone3
): P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem2,
  OutDone3
>
/**
 * Returns a new channel whose outputs are fed to the specified factory function, which creates
 * new channels in response. These new channels are sequentially concatenated together, and all
 * their outputs appear as outputs of the newly returned channel. The provided merging function
 * is used to merge the terminal values of all channels into the single terminal value of the
 * returned channel.
 *
 * @dataFirst concatMapWith_
 */
export declare function concatMapWith<
  OutDone,
  OutElem,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2,
  OutElem2,
  OutDone2,
  OutDone3
>(
  f: (
    o: OutElem
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem2, OutDone>,
  g: (o: OutDone, o1: OutDone) => OutDone,
  h: (o: OutDone, o2: OutDone2) => OutDone3
): <Env, InErr, InElem, InDone, OutErr>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone2>
) => P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem2,
  OutDone3
>
/**
 * Concat sequentially a channel of channels
 */
export declare function concatAllWith_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone,
  OutDone2,
  OutDone3,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2
>(
  channels: P.Channel<
    Env,
    InErr,
    InElem,
    InDone,
    OutErr,
    P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem, OutDone>,
    OutDone2
  >,
  f: (o: OutDone, o1: OutDone) => OutDone,
  g: (o: OutDone, o2: OutDone2) => OutDone3
): P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem,
  OutDone3
>
/**
 * Concat sequentially a channel of channels
 *
 * @dataFirst concatAllWith_
 */
export declare function concatAllWith<OutDone, OutDone2, OutDone3>(
  f: (o: OutDone, o1: OutDone) => OutDone,
  g: (o: OutDone, o2: OutDone2) => OutDone3
): <
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2
>(
  channels: P.Channel<
    Env,
    InErr,
    InElem,
    InDone,
    OutErr,
    P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem, OutDone>,
    OutDone2
  >
) => P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem,
  OutDone3
>
/**
 * Returns a new channel whose outputs are fed to the specified factory function, which creates
 * new channels in response. These new channels are sequentially concatenated together, and all
 * their outputs appear as outputs of the newly returned channel.
 */
export declare function concatMap_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutElem2,
  OutDone,
  OutDone2,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2
>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone2>,
  f: (
    o: OutElem
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem2, OutDone>
): P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem2,
  unknown
>
/**
 * Returns a new channel whose outputs are fed to the specified factory function, which creates
 * new channels in response. These new channels are sequentially concatenated together, and all
 * their outputs appear as outputs of the newly returned channel.
 *
 * @dataFirst concatMap_
 */
export declare function concatMap<
  OutElem,
  OutElem2,
  OutDone,
  Env2,
  InErr2,
  InElem2,
  InDone2,
  OutErr2
>(
  f: (
    o: OutElem
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr2, OutElem2, OutDone>
): <Env, InErr, InElem, InDone, OutErr, OutDone2>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone2>
) => P.Channel<
  Env & Env2,
  InErr & InErr2,
  InElem & InElem2,
  InDone & InDone2,
  OutErr | OutErr2,
  OutElem2,
  unknown
>
/**
 * Fold the channel exposing success and full error cause
 */
export declare function foldCauseM_<
  Env,
  Env1,
  Env2,
  InErr,
  InErr1,
  InErr2,
  InElem,
  InElem1,
  InElem2,
  InDone,
  InDone1,
  InDone2,
  OutErr,
  OutErr2,
  OutErr3,
  OutElem,
  OutElem1,
  OutElem2,
  OutDone,
  OutDone2,
  OutDone3
>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  onErr: (
    c: Cause.Cause<OutErr>
  ) => P.Channel<Env1, InErr1, InElem1, InDone1, OutErr2, OutElem1, OutDone2>,
  onSucc: (
    o: OutDone
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr3, OutElem2, OutDone3>
): P.Channel<
  Env & Env1 & Env2,
  InErr & InErr1 & InErr2,
  InElem & InElem1 & InElem2,
  InDone & InDone1 & InDone2,
  OutErr2 | OutErr3,
  OutElem | OutElem1 | OutElem2,
  OutDone2 | OutDone3
>
/**
 * Fold the channel exposing success and full error cause
 *
 * @dataFirst foldCauseM_
 */
export declare function foldCauseM<
  Env1,
  Env2,
  InErr1,
  InErr2,
  InElem1,
  InElem2,
  InDone1,
  InDone2,
  OutErr,
  OutErr2,
  OutErr3,
  OutElem1,
  OutElem2,
  OutDone,
  OutDone2,
  OutDone3
>(
  onErr: (
    c: Cause.Cause<OutErr>
  ) => P.Channel<Env1, InErr1, InElem1, InDone1, OutErr2, OutElem1, OutDone2>,
  onSucc: (
    o: OutDone
  ) => P.Channel<Env2, InErr2, InElem2, InDone2, OutErr3, OutElem2, OutDone3>
): <Env, InErr, InElem, InDone, OutElem>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
) => P.Channel<
  Env & Env1 & Env2,
  InErr & InErr1 & InErr2,
  InElem & InElem1 & InElem2,
  InDone & InDone1 & InDone2,
  OutErr2 | OutErr3,
  OutElem | OutElem1 | OutElem2,
  OutDone2 | OutDone3
>
/**
 * Embed inputs from continuos pulling of a producer
 */
export declare function embedInput_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  self: P.Channel<Env, unknown, unknown, unknown, OutErr, OutElem, OutDone>,
  input: AsyncInputProducer<InErr, InElem, InDone>
): P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Embed inputs from continuos pulling of a producer
 *
 * @dataFirst embedInput_
 */
export declare function embedInput<InErr, InElem, InDone>(
  input: AsyncInputProducer<InErr, InElem, InDone>
): <Env, OutErr, OutElem, OutDone>(
  self: P.Channel<Env, unknown, unknown, unknown, OutErr, OutElem, OutDone>
) => P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Construct a resource Channel with Acquire / Release
 */
export declare function bracketOutExit_<R, R2, E, Z>(
  self: T.Effect<R, E, Z>,
  release: (z: Z, e: Exit.Exit<unknown, unknown>) => T.RIO<R2, unknown>
): P.Channel<R & R2, unknown, unknown, unknown, E, Z, void>
/**
 * Construct a resource Channel with Acquire / Release
 *
 * @dataFirst bracketOutExit_
 */
export declare function bracketOutExit<R2, Z>(
  release: (z: Z, e: Exit.Exit<unknown, unknown>) => T.RIO<R2, unknown>
): <R, E>(
  self: T.Effect<R, E, Z>
) => P.Channel<R & R2, unknown, unknown, unknown, E, Z, void>
/**
 * Provides the channel with its required environment, which eliminates
 * its dependency on `Env`.
 */
export declare function provideAll_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  env: Env
): P.Channel<unknown, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Provides the channel with its required environment, which eliminates
 * its dependency on `Env`.
 *
 * @dataFirst provideAll_
 */
export declare function provideAll<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  env: Env
): (
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
) => P.Channel<unknown, InErr, InElem, InDone, OutErr, OutElem, OutDone>
/**
 * Returns a new channel, which sequentially combines this channel, together with the provided
 * factory function, which creates a second channel based on the terminal value of this channel.
 * The result is a channel that will first perform the functions of this channel, before
 * performing the functions of the created channel (including yielding its terminal value).
 */
export declare function chain_<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone,
  Env1,
  InErr1,
  InElem1,
  InDone1,
  OutErr1,
  OutElem1,
  OutDone2
>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>,
  f: (
    d: OutDone
  ) => P.Channel<Env1, InErr1, InElem1, InDone1, OutErr1, OutElem1, OutDone2>
): P.Channel<
  Env & Env1,
  InErr & InErr1,
  InElem & InElem1,
  InDone & InDone1,
  OutErr | OutErr1,
  OutElem | OutElem1,
  OutDone2
>
/**
 * Returns a new channel, which sequentially combines this channel, together with the provided
 * factory function, which creates a second channel based on the terminal value of this channel.
 * The result is a channel that will first perform the functions of this channel, before
 * performing the functions of the created channel (including yielding its terminal value).
 *
 * @dataFirst chain_
 */
export declare function chain<
  OutDone,
  Env1,
  InErr1,
  InElem1,
  InDone1,
  OutErr1,
  OutElem1,
  OutDone2
>(
  f: (
    d: OutDone
  ) => P.Channel<Env1, InErr1, InElem1, InDone1, OutErr1, OutElem1, OutDone2>
): <Env, InErr, InElem, InDone, OutErr, OutElem>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
) => P.Channel<
  Env & Env1,
  InErr & InErr1,
  InElem & InElem1,
  InDone & InDone1,
  OutErr | OutErr1,
  OutElem | OutElem1,
  OutDone2
>
/**
 * Returns a new channel which reads all the elements from upstream's output channel
 * and ignores them, then terminates with the upstream result value.
 */
export declare function drain<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>(
  self: P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
): P.Channel<Env, InErr, InElem, InDone, OutErr, never, OutDone>
/**
 * Use an effect to end a channel
 */
export declare function fromEffect<R, E, A>(
  self: T.Effect<R, E, A>
): P.Channel<R, unknown, unknown, unknown, E, never, A>
/**
 * Use a managed to emit an output element
 */
export declare function managedOut<R, E, A>(
  self: M.Managed<R, E, A>
): P.Channel<R, unknown, unknown, unknown, E, A, unknown>
/**
 * Returns a new channel, which flattens the terminal value of this channel. This function may
 * only be called if the terminal value of this channel is another channel of compatible types.
 */
export declare function flatten<
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  Env1,
  InErr1,
  InElem1,
  InDone1,
  OutErr1,
  OutElem1,
  OutDone2
>(
  self: P.Channel<
    Env,
    InErr,
    InElem,
    InDone,
    OutErr,
    OutElem,
    P.Channel<Env1, InErr1, InElem1, InDone1, OutErr1, OutElem1, OutDone2>
  >
): P.Channel<
  Env & Env1,
  InErr & InErr1,
  InElem & InElem1,
  InDone & InDone1,
  OutErr | OutErr1,
  OutElem | OutElem1,
  OutDone2
>
/**
 * Makes a channel from an effect that returns a channel in case of success
 */
export declare function unwrap<
  R,
  E,
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  self: T.Effect<R, E, P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>>
): P.Channel<R & Env, InErr, InElem, InDone, E | OutErr, OutElem, OutDone>
/**
 * Makes a channel from a managed that returns a channel in case of success
 */
export declare function unwrapManaged<
  R,
  E,
  Env,
  InErr,
  InElem,
  InDone,
  OutErr,
  OutElem,
  OutDone
>(
  self: M.Managed<R, E, P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>>
): P.Channel<R & Env, InErr, InElem, InDone, E | OutErr, OutElem, OutDone>
/**
 * Unit channel
 */
export declare const unit: P.Channel<
  unknown,
  unknown,
  unknown,
  unknown,
  never,
  never,
  void
>
export declare function succeedWith<OutDone>(
  effect: () => OutDone
): P.Channel<unknown, unknown, unknown, unknown, never, never, OutDone>
export declare function suspend<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>(
  effect: () => P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
): P.Channel<Env, InErr, InElem, InDone, OutErr, OutElem, OutDone>
//# sourceMappingURL=core.d.ts.map
