"use strict"
Object.defineProperty(exports, "__esModule", { value: true })
exports.filterOrDieMessage_ =
  exports.filterOrDieMessage =
  exports.filterOrElse_ =
  exports.filterOrElse =
  exports.filterOrFail_ =
  exports.filterOrFail =
  exports.filterOrDie_ =
  exports.filterOrDie =
    void 0
// tracing: off
const Cause_1 = require("../Cause")
const Function_1 = require("../Function")
const core_1 = require("./core")
const die_1 = require("./die")
const fail_1 = require("./fail")
function filterOrDie(p, dieWith, __trace) {
  return (fa) => filterOrDie_(fa, p, dieWith, __trace)
}
exports.filterOrDie = filterOrDie
function filterOrDie_(fa, p, dieWith, __trace) {
  return filterOrElse_(fa, p, (x) => (0, die_1.die)(dieWith(x)), __trace)
}
exports.filterOrDie_ = filterOrDie_
function filterOrFail(p, failWith, __trace) {
  return (fa) => filterOrFail_(fa, p, failWith, __trace)
}
exports.filterOrFail = filterOrFail
function filterOrFail_(fa, p, failWith, __trace) {
  return filterOrElse_(fa, p, (x) => (0, fail_1.fail)(failWith(x)), __trace)
}
exports.filterOrFail_ = filterOrFail_
function filterOrElse(p, or, __trace) {
  return (fa) => filterOrElse_(fa, p, or, __trace)
}
exports.filterOrElse = filterOrElse
function filterOrElse_(fa, p, or, __trace) {
  return (0, core_1.chain_)(fa, (a) =>
    p(a) ? (0, core_1.succeed)(a, __trace) : (0, core_1.suspend)(() => or(a), __trace)
  )
}
exports.filterOrElse_ = filterOrElse_
function filterOrDieMessage(p, message, __trace) {
  return (fa) => filterOrDieMessage_(fa, p, message, __trace)
}
exports.filterOrDieMessage = filterOrDieMessage
function filterOrDieMessage_(fa, p, message, __trace) {
  return filterOrDie_(fa, p, (a) => new Cause_1.RuntimeError(message(a)), __trace)
}
exports.filterOrDieMessage_ = filterOrDieMessage_
//# sourceMappingURL=filterOr.js.map
