const fileName_1 = "(@effect/core) _src/io/Fiber/operations/orElse.ts";
import * as tsplus_module_1 from "@effect/core/io/Fiber/operations/id";
import * as tsplus_module_2 from "@effect/core/io/FiberId/operations/getOrElse";
import * as tsplus_module_3 from "@effect/core/io/Fiber/operations/await";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/zipWith";
import * as tsplus_module_5 from "@effect/core/io/Fiber/operations/children";
import * as tsplus_module_6 from "@effect/core/io/Fiber/operations/inheritRefs";
import * as tsplus_module_7 from "@effect/core/io/Effect/operations/zipRight";
import * as tsplus_module_8 from "@effect/core/io/Fiber/operations/interruptAs";
import * as tsplus_module_9 from "@effect/core/io/Fiber/operations/poll";
import * as tsplus_module_10 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_11 from "@tsplus/stdlib/data/Maybe/fold";
import { makeSynthetic } from "@effect/core/io/Fiber/definition";
/**
 * Returns a fiber that prefers `this` fiber, but falls back to the `that` one
 * when `this` one fails. Interrupting the returned fiber will interrupt both
 * fibers, sequentially, from left to right.
 *
 * @tsplus operator ets/Fiber |
 * @tsplus operator ets/RuntimeFiber |
 * @tsplus fluent ets/Fiber orElse
 * @tsplus fluent ets/RuntimeFiber orElse
 */

export function orElse_(self, that) {
  return makeSynthetic({
    id: tsplus_module_2.getOrElse_(tsplus_module_1.id(self), () => tsplus_module_1.id(that)),
    await: tsplus_module_4.zipWith_(tsplus_module_3._await(self, fileName_1 + ":20:13"), () => tsplus_module_3._await(that, fileName_1 + ":21:26"), (e1, e2) => e1._tag === "Success" ? e1 : e2, fileName_1 + ":21:15"),
    children: tsplus_module_5.children(self, fileName_1 + ":22:28"),
    inheritRefs: tsplus_module_7.zipRight_(tsplus_module_6.inheritRefs(that, fileName_1 + ":23:34"), () => tsplus_module_6.inheritRefs(self, fileName_1 + ":23:55"), fileName_1 + ":23:38"),
    interruptAs: id => tsplus_module_7.zipRight_(tsplus_module_8.interruptAsNow_(self, id, fileName_1 + ":24:42"), () => tsplus_module_8.interruptAsNow_(that, id, fileName_1 + ":24:65"), fileName_1 + ":24:48"),
    poll: tsplus_module_4.zipWith_(tsplus_module_9.poll(self, fileName_1 + ":26:12"), () => tsplus_module_9.poll(that, fileName_1 + ":27:25"), (o1, o2) => tsplus_module_11.fold_(o1, () => tsplus_module_10.none, _ => _._tag === "Success" ? o1 : o2), fileName_1 + ":27:15")
  });
}
/**
 * Returns a fiber that prefers `this` fiber, but falls back to the `that` one
 * when `this` one fails. Interrupting the returned fiber will interrupt both
 * fibers, sequentially, from left to right.
 *
 * @tsplus static ets/Fiber/Aspects orElse
 */

export const orElse = that => self => orElse_(self, that);
//# sourceMappingURL=orElse.mjs.map