import * as tsplus_module_1 from "@effect/core/stream/Channel/operations/unit";
import * as tsplus_module_2 from "@effect/core/stream/Channel/operations/zipRight";
import * as tsplus_module_3 from "@tsplus/stdlib/collections/Chunk/map";
import * as tsplus_module_4 from "@tsplus/stdlib/collections/Chunk/reduce";
import * as tsplus_module_5 from "@effect/core/stream/Channel/operations/concatMap";
import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal";
/**
 * Returns a stream made of the concatenation in strict order of all the
 * streams produced by passing each element of this stream to `f0`
 *
 * @tsplus fluent ets/Stream flatMap
 */

export function flatMap_(self, f, __tsplusTrace) {
  void 0;
  return new StreamInternal(tsplus_module_5.concatMap_(self.channel, as => tsplus_module_4.reduce_(tsplus_module_3.map_(tsplus_module_3.map_(as, f), stream => {
    void 0;
    return stream.channel;
  }), tsplus_module_1.unit, (c1, c2) => tsplus_module_2.zipRight_(c1, () => c2))));
}
/**
 * Returns a stream made of the concatenation in strict order of all the
 * streams produced by passing each element of this stream to `f0`
 *
 * @tsplus static ets/Stream/Aspects flatMap
 */

export const flatMap = (f, __tsplusTrace) => self => flatMap_(self, f, __tsplusTrace);
//# sourceMappingURL=flatMap.mjs.map