"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.bufferDropping = void 0;
exports.bufferDropping_ = bufferDropping_;

var tsplus_module_1 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Queue/operations/dropping"));

var tsplus_module_2 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/io/Effect/operations/acquireRelease"));

var tsplus_module_3 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/stream/Stream/operations/rechunk"));

var tsplus_module_4 = /*#__PURE__*/_interopRequireWildcard( /*#__PURE__*/require("@effect/core/stream/Stream/operations/via"));

var _bufferSignal = /*#__PURE__*/require("@effect/core/stream/Stream/operations/_internal/bufferSignal");

var _StreamInternal = /*#__PURE__*/require("@effect/core/stream/Stream/operations/_internal/StreamInternal");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

/**
 * 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
 */
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.StreamInternal((0, _bufferSignal.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
 */


const bufferDropping = (capacity, __tsplusTrace) => self => bufferDropping_(self, capacity, __tsplusTrace);

exports.bufferDropping = bufferDropping;
//# sourceMappingURL=bufferDropping.js.map