import * as tsplus_module_1 from "@tsplus/stdlib/collections/Chunk/unsafeGet";
import * as tsplus_module_2 from "@effect/core/stm/TRef/operations/unsafeGet";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/effect";
import { concreteTArray } from "@effect/core/stm/TArray/operations/_internal/InternalTArray";
/**
 * Find the first element in the array matching a predicate.
 *
 * @tsplus fluent ets/TArray find
 */

export function find_(self, p) {
  return tsplus_module_4.effect(journal => {
    let i = 0;
    void 0;

    while (i < self.chunk.length) {
      const a = tsplus_module_2.unsafeGet_(tsplus_module_1.unsafeGet_(self.chunk, i), journal);

      if (p(a)) {
        return tsplus_module_3.some(a);
      }

      i++;
    }

    return tsplus_module_3.none;
  });
}
/**
 * Find the first element in the array matching a predicate.
 *
 * @tsplus static ets/TArray/Aspects find
 */

export const find = p => self => find_(self, p);
//# sourceMappingURL=find.mjs.map