import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/fail";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Maybe/fold";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/catchAll";
/**
 * Returns an effect that will produce the value of this effect, unless it
 * fails with the `None` value, in which case it will produce the value of the
 * specified effect.
 *
 * @tsplus fluent ets/STM orElseOptional
 */

export function orElseOptional_(self, that) {
  return tsplus_module_4.catchAll_(self, option => tsplus_module_3.fold_(option, that, e => tsplus_module_2.fail(() => tsplus_module_1.some(e))));
}
/**
 * Returns an effect that will produce the value of this effect, unless it
 * fails with the `None` value, in which case it will produce the value of the
 * specified effect.
 *
 * @tsplus static ets/STM/Aspects orElseOptional
 */

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