const fileName_1 = "(@effect/core) _src/stream/Channel/operations/interruptWhen.ts";
import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/fromEffect";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/done";
import * as tsplus_module_3 from "@effect/core/stream/Channel/MergeDecision";
import * as tsplus_module_4 from "@effect/core/stream/Channel/operations/mergeWith";
/**
 * Returns a new channel, which is the same as this one, except it will be
 * interrupted when the specified effect completes. If the effect completes
 * successfully before the underlying channel is done, then the returned
 * channel will yield the success value of the effect as its terminal value.
 * On the other hand, if the underlying channel finishes first, then the
 * returned channel will yield the success value of the underlying channel as
 * its terminal value.
 *
 * @tsplus fluent ets/Channel interruptWhen
 */

export function interruptWhen_(self, io) {
  return tsplus_module_4.mergeWith_(self, () => tsplus_module_1.fromEffect(io), selfDone => tsplus_module_3.done(tsplus_module_2.done(() => selfDone, fileName_1 + ":39:49")), ioDone => tsplus_module_3.done(tsplus_module_2.done(() => ioDone, fileName_1 + ":40:47")));
}
/**
 * Returns a new channel, which is the same as this one, except it will be
 * interrupted when the specified effect completes. If the effect completes
 * successfully before the underlying channel is done, then the returned
 * channel will yield the success value of the effect as its terminal value.
 * On the other hand, if the underlying channel finishes first, then the
 * returned channel will yield the success value of the underlying channel as
 * its terminal value.
 *
 * @tsplus static ets/Channel/Aspects interruptWhen
 */

export const interruptWhen = io => self => interruptWhen_(self, io);
//# sourceMappingURL=interruptWhen.mjs.map