import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/flatMap";
import * as tsplus_module_2 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_3 from "@effect/core/stm/TArray/operations/find";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/map";
/**
 * Finds the result of applying a partial function to the first value in its
 * domain.
 *
 * @tsplus fluent ets/TArray collectFirst
 */

export function collectFirst_(self, pf) {
  return tsplus_module_4.map_(tsplus_module_3.find_(self, a => tsplus_module_2.isSome(pf(a))), option => tsplus_module_1.flatMap_(option, pf));
}
/**
 * Finds the result of applying a partial function to the first value in its
 * domain.
 *
 * @tsplus static ets/TArray/Aspects collectFirst
 */

export const collectFirst = pf => self => collectFirst_(self, pf);
//# sourceMappingURL=collectFirst.mjs.map