import * as tsplus_module_1 from "@effect/core/io/Queue/operations/dropping";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/acquireRelease";
import * as tsplus_module_3 from "@effect/core/stream/Stream/operations/rechunk";
import * as tsplus_module_4 from "@effect/core/stream/Stream/operations/via";
import { bufferSignal } from "@effect/core/stream/Stream/operations/_internal/bufferSignal";
import { concreteStream, StreamInternal } from "@effect/core/stream/Stream/operations/_internal/StreamInternal";
/**
 * Allows a faster producer to progress independently of a slower consumer by
 * buffering up to `capacity` elements in a dropping queue.
 *
 * This combinator destroys the chunking structure. It's recommended to use
 * rechunk afterwards.
 *
 * Note: prefer capacities that are powers of 2 for better performance.
 *
 * @tsplus fluent ets/Stream bufferDropping
 */

export function bufferDropping_(self, capacity, __tsplusTrace) {
  const queue = tsplus_module_2.acquireRelease(() => tsplus_module_1.dropping(capacity, __tsplusTrace), queue => queue.shutdown, __tsplusTrace);
  const stream = tsplus_module_4.via_(self, tsplus_module_3.rechunk(1, __tsplusTrace));
  void 0;
  return new StreamInternal(bufferSignal(() => queue, () => stream.channel, __tsplusTrace));
}
/**
 * Allows a faster producer to progress independently of a slower consumer by
 * buffering up to `capacity` elements in a dropping queue.
 *
 * This combinator destroys the chunking structure. It's recommended to use
 * rechunk afterwards.
 *
 * Note: prefer capacities that are powers of 2 for better performance.
 *
 * @tsplus static ets/Stream/Aspects bufferDropping
 */

export const bufferDropping = (capacity, __tsplusTrace) => self => bufferDropping_(self, capacity, __tsplusTrace);
//# sourceMappingURL=bufferDropping.mjs.map