import * as tsplus_module_1 from "@effect/core/stm/STM/operations/dieNow";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/failNow";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Maybe/fold";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/catchAll";
/**
 * Keeps some of the errors, and terminates the fiber with the rest, using
 * the specified function to convert the `E` into a `Throwable`.
 *
 * @tsplus fluent ets/STM refineOrDieWith
 */

export function refineOrDieWith_(self, pf, f) {
  return tsplus_module_4.catchAll_(self, e => tsplus_module_3.fold_(pf(e), () => tsplus_module_1.dieNow(f(e)), e1 => tsplus_module_2.failNow(e1)));
}
/**
 * Keeps some of the errors, and terminates the fiber with the rest, using
 * the specified function to convert the `E` into a `Throwable`.
 *
 * @tsplus static ets/STM/Aspects refineOrDieWith
 */

export const refineOrDieWith = (pf, f) => self => refineOrDieWith_(self, pf, f);
//# sourceMappingURL=refineOrDieWith.mjs.map