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 "@effect/core/stm/STM/operations/effect";
import { concreteTArray } from "@effect/core/stm/TArray/operations/_internal/InternalTArray";
/**
 * Atomically folds using a pure function.
 *
 * @tsplus fluent ets/TArray reduce
 */

export function reduce_(self, zero, f) {
  return tsplus_module_3.effect(journal => {
    let result = zero;
    let i = 0;
    void 0;

    while (i < self.chunk.length) {
      const value = tsplus_module_2.unsafeGet_(tsplus_module_1.unsafeGet_(self.chunk, i), journal);
      result = f(result, value);
      i = i + 1;
    }

    return result;
  });
}
/**
 * Atomically folds using a pure function.
 *
 * @tsplus static ets/TArray/Aspects reduce
 */

export const reduce = (zero, f) => self => reduce_(self, zero, f);
//# sourceMappingURL=reduce.mjs.map