import * as tsplus_module_1 from "@effect/core/stream/Sink/operations/foldUntil";
import * as tsplus_module_2 from "@tsplus/stdlib/collections/Chunk/builder";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/succeed";
import * as tsplus_module_4 from "@effect/core/stream/Sink/operations/fromEffect";
import * as tsplus_module_5 from "@effect/core/stream/Sink/operations/flatMap";
import * as tsplus_module_6 from "@effect/core/stream/Sink/operations/map";
/**
 * A sink that collects first `n` elements into a chunk.
 *
 * @tsplus static ets/Sink/Ops collectAllN
 */

export function collectAllN(n, __tsplusTrace) {
  return tsplus_module_6.map_(tsplus_module_5.flatMap_(tsplus_module_4.fromEffect(() => tsplus_module_3.succeed(() => tsplus_module_2.builder(), __tsplusTrace), __tsplusTrace), cb => tsplus_module_1.foldUntil(() => cb, n, (builder, input) => builder.append(input), __tsplusTrace)), builder => builder.build(), __tsplusTrace);
}
//# sourceMappingURL=collectAllN.mjs.map