import e from"../../_virtual/_node_stream.mjs";var r,n;function t(){if(n)return r;n=1;const t=e.PassThrough,i=Array.prototype.slice;function o(e,r){if(Array.isArray(e))for(let n=0,t=e.length;n<t;n++)e[n]=o(e[n],r);else{if(!e._readableState&&e.pipe&&(e=e.pipe(t(r))),!e._readableState||!e.pause||!e.pipe)throw new Error("Only readable stream can be merged.");e.pause()}return e}return r=function(){const e=[],r=i.call(arguments);let n=!1,a=r[r.length-1];a&&!Array.isArray(a)&&null==a.pipe?r.pop():a={};const u=!1!==a.end,p=!0===a.pipeError;null==a.objectMode&&(a.objectMode=!0);null==a.highWaterMark&&(a.highWaterMark=65536);const l=t(a);function s(){for(let r=0,n=arguments.length;r<n;r++)e.push(o(arguments[r],a));return c(),this}function c(){if(n)return;n=!0;let r=e.shift();if(!r)return void process.nextTick(f);Array.isArray(r)||(r=[r]);let t=r.length+1;function i(){--t>0||(n=!1,c())}function o(e){function r(){e.removeListener("merge2UnpipeEnd",r),e.removeListener("end",r),p&&e.removeListener("error",n),i()}function n(e){l.emit("error",e)}if(e._readableState.endEmitted)return i();e.on("merge2UnpipeEnd",r),e.on("end",r),p&&e.on("error",n),e.pipe(l,{end:!1}),e.resume()}for(let e=0;e<r.length;e++)o(r[e]);i()}function f(){n=!1,l.emit("queueDrain"),u&&l.end()}l.setMaxListeners(0),l.add=s,l.on("unpipe",function(e){e.emit("merge2UnpipeEnd")}),r.length&&s.apply(null,r);return l},r}export{t as __require};