@mcp-s/skills 1.0.5 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1726 @@
1
+ import { n as __require, t as __commonJSMin } from "../rolldown-runtime.mjs";
2
+ import { t as require_util } from "./core-util-is.mjs";
3
+ var require_process_nextick_args = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4
+ if (typeof process === "undefined" || !process.version || process.version.indexOf("v0.") === 0 || process.version.indexOf("v1.") === 0 && process.version.indexOf("v1.8.") !== 0) module.exports = { nextTick };
5
+ else module.exports = process;
6
+ function nextTick(fn, arg1, arg2, arg3) {
7
+ if (typeof fn !== "function") throw new TypeError("\"callback\" argument must be a function");
8
+ var len = arguments.length;
9
+ var args, i;
10
+ switch (len) {
11
+ case 0:
12
+ case 1: return process.nextTick(fn);
13
+ case 2: return process.nextTick(function afterTickOne() {
14
+ fn.call(null, arg1);
15
+ });
16
+ case 3: return process.nextTick(function afterTickTwo() {
17
+ fn.call(null, arg1, arg2);
18
+ });
19
+ case 4: return process.nextTick(function afterTickThree() {
20
+ fn.call(null, arg1, arg2, arg3);
21
+ });
22
+ default:
23
+ args = new Array(len - 1);
24
+ i = 0;
25
+ while (i < args.length) args[i++] = arguments[i];
26
+ return process.nextTick(function afterTick() {
27
+ fn.apply(null, args);
28
+ });
29
+ }
30
+ }
31
+ }));
32
+ var require_isarray = /* @__PURE__ */ __commonJSMin(((exports, module) => {
33
+ var toString = {}.toString;
34
+ module.exports = Array.isArray || function(arr) {
35
+ return toString.call(arr) == "[object Array]";
36
+ };
37
+ }));
38
+ var require_stream = /* @__PURE__ */ __commonJSMin(((exports, module) => {
39
+ module.exports = __require("stream");
40
+ }));
41
+ var require_safe_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
42
+ var buffer = __require("buffer");
43
+ var Buffer = buffer.Buffer;
44
+ function copyProps(src, dst) {
45
+ for (var key in src) dst[key] = src[key];
46
+ }
47
+ if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) module.exports = buffer;
48
+ else {
49
+ copyProps(buffer, exports);
50
+ exports.Buffer = SafeBuffer;
51
+ }
52
+ function SafeBuffer(arg, encodingOrOffset, length) {
53
+ return Buffer(arg, encodingOrOffset, length);
54
+ }
55
+ copyProps(Buffer, SafeBuffer);
56
+ SafeBuffer.from = function(arg, encodingOrOffset, length) {
57
+ if (typeof arg === "number") throw new TypeError("Argument must not be a number");
58
+ return Buffer(arg, encodingOrOffset, length);
59
+ };
60
+ SafeBuffer.alloc = function(size, fill, encoding) {
61
+ if (typeof size !== "number") throw new TypeError("Argument must be a number");
62
+ var buf = Buffer(size);
63
+ if (fill !== void 0) if (typeof encoding === "string") buf.fill(fill, encoding);
64
+ else buf.fill(fill);
65
+ else buf.fill(0);
66
+ return buf;
67
+ };
68
+ SafeBuffer.allocUnsafe = function(size) {
69
+ if (typeof size !== "number") throw new TypeError("Argument must be a number");
70
+ return Buffer(size);
71
+ };
72
+ SafeBuffer.allocUnsafeSlow = function(size) {
73
+ if (typeof size !== "number") throw new TypeError("Argument must be a number");
74
+ return buffer.SlowBuffer(size);
75
+ };
76
+ }));
77
+ var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
78
+ if (typeof Object.create === "function") module.exports = function inherits(ctor, superCtor) {
79
+ if (superCtor) {
80
+ ctor.super_ = superCtor;
81
+ ctor.prototype = Object.create(superCtor.prototype, { constructor: {
82
+ value: ctor,
83
+ enumerable: false,
84
+ writable: true,
85
+ configurable: true
86
+ } });
87
+ }
88
+ };
89
+ else module.exports = function inherits(ctor, superCtor) {
90
+ if (superCtor) {
91
+ ctor.super_ = superCtor;
92
+ var TempCtor = function() {};
93
+ TempCtor.prototype = superCtor.prototype;
94
+ ctor.prototype = new TempCtor();
95
+ ctor.prototype.constructor = ctor;
96
+ }
97
+ };
98
+ }));
99
+ var require_inherits = /* @__PURE__ */ __commonJSMin(((exports, module) => {
100
+ try {
101
+ var util$1 = __require("util");
102
+ /* istanbul ignore next */
103
+ if (typeof util$1.inherits !== "function") throw "";
104
+ module.exports = util$1.inherits;
105
+ } catch (e) {
106
+ /* istanbul ignore next */
107
+ module.exports = require_inherits_browser();
108
+ }
109
+ }));
110
+ var require_BufferList = /* @__PURE__ */ __commonJSMin(((exports, module) => {
111
+ function _classCallCheck(instance, Constructor) {
112
+ if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
113
+ }
114
+ var Buffer = require_safe_buffer().Buffer;
115
+ var util = __require("util");
116
+ function copyBuffer(src, target, offset) {
117
+ src.copy(target, offset);
118
+ }
119
+ module.exports = function() {
120
+ function BufferList() {
121
+ _classCallCheck(this, BufferList);
122
+ this.head = null;
123
+ this.tail = null;
124
+ this.length = 0;
125
+ }
126
+ BufferList.prototype.push = function push(v) {
127
+ var entry = {
128
+ data: v,
129
+ next: null
130
+ };
131
+ if (this.length > 0) this.tail.next = entry;
132
+ else this.head = entry;
133
+ this.tail = entry;
134
+ ++this.length;
135
+ };
136
+ BufferList.prototype.unshift = function unshift(v) {
137
+ var entry = {
138
+ data: v,
139
+ next: this.head
140
+ };
141
+ if (this.length === 0) this.tail = entry;
142
+ this.head = entry;
143
+ ++this.length;
144
+ };
145
+ BufferList.prototype.shift = function shift() {
146
+ if (this.length === 0) return;
147
+ var ret = this.head.data;
148
+ if (this.length === 1) this.head = this.tail = null;
149
+ else this.head = this.head.next;
150
+ --this.length;
151
+ return ret;
152
+ };
153
+ BufferList.prototype.clear = function clear() {
154
+ this.head = this.tail = null;
155
+ this.length = 0;
156
+ };
157
+ BufferList.prototype.join = function join(s) {
158
+ if (this.length === 0) return "";
159
+ var p = this.head;
160
+ var ret = "" + p.data;
161
+ while (p = p.next) ret += s + p.data;
162
+ return ret;
163
+ };
164
+ BufferList.prototype.concat = function concat(n) {
165
+ if (this.length === 0) return Buffer.alloc(0);
166
+ var ret = Buffer.allocUnsafe(n >>> 0);
167
+ var p = this.head;
168
+ var i = 0;
169
+ while (p) {
170
+ copyBuffer(p.data, ret, i);
171
+ i += p.data.length;
172
+ p = p.next;
173
+ }
174
+ return ret;
175
+ };
176
+ return BufferList;
177
+ }();
178
+ if (util && util.inspect && util.inspect.custom) module.exports.prototype[util.inspect.custom] = function() {
179
+ var obj = util.inspect({ length: this.length });
180
+ return this.constructor.name + " " + obj;
181
+ };
182
+ }));
183
+ var require_destroy = /* @__PURE__ */ __commonJSMin(((exports, module) => {
184
+ var pna = require_process_nextick_args();
185
+ function destroy(err, cb) {
186
+ var _this = this;
187
+ var readableDestroyed = this._readableState && this._readableState.destroyed;
188
+ var writableDestroyed = this._writableState && this._writableState.destroyed;
189
+ if (readableDestroyed || writableDestroyed) {
190
+ if (cb) cb(err);
191
+ else if (err) {
192
+ if (!this._writableState) pna.nextTick(emitErrorNT, this, err);
193
+ else if (!this._writableState.errorEmitted) {
194
+ this._writableState.errorEmitted = true;
195
+ pna.nextTick(emitErrorNT, this, err);
196
+ }
197
+ }
198
+ return this;
199
+ }
200
+ if (this._readableState) this._readableState.destroyed = true;
201
+ if (this._writableState) this._writableState.destroyed = true;
202
+ this._destroy(err || null, function(err) {
203
+ if (!cb && err) {
204
+ if (!_this._writableState) pna.nextTick(emitErrorNT, _this, err);
205
+ else if (!_this._writableState.errorEmitted) {
206
+ _this._writableState.errorEmitted = true;
207
+ pna.nextTick(emitErrorNT, _this, err);
208
+ }
209
+ } else if (cb) cb(err);
210
+ });
211
+ return this;
212
+ }
213
+ function undestroy() {
214
+ if (this._readableState) {
215
+ this._readableState.destroyed = false;
216
+ this._readableState.reading = false;
217
+ this._readableState.ended = false;
218
+ this._readableState.endEmitted = false;
219
+ }
220
+ if (this._writableState) {
221
+ this._writableState.destroyed = false;
222
+ this._writableState.ended = false;
223
+ this._writableState.ending = false;
224
+ this._writableState.finalCalled = false;
225
+ this._writableState.prefinished = false;
226
+ this._writableState.finished = false;
227
+ this._writableState.errorEmitted = false;
228
+ }
229
+ }
230
+ function emitErrorNT(self, err) {
231
+ self.emit("error", err);
232
+ }
233
+ module.exports = {
234
+ destroy,
235
+ undestroy
236
+ };
237
+ }));
238
+ var require_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
239
+ module.exports = __require("util").deprecate;
240
+ }));
241
+ var require__stream_writable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
242
+ var pna = require_process_nextick_args();
243
+ module.exports = Writable;
244
+ function CorkedRequest(state) {
245
+ var _this = this;
246
+ this.next = null;
247
+ this.entry = null;
248
+ this.finish = function() {
249
+ onCorkedFinish(_this, state);
250
+ };
251
+ }
252
+ var asyncWrite = !process.browser && ["v0.10", "v0.9."].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
253
+ var Duplex;
254
+ Writable.WritableState = WritableState;
255
+ var util = Object.create(require_util());
256
+ util.inherits = require_inherits();
257
+ var internalUtil = { deprecate: require_node() };
258
+ var Stream = require_stream();
259
+ var Buffer = require_safe_buffer().Buffer;
260
+ var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {};
261
+ function _uint8ArrayToBuffer(chunk) {
262
+ return Buffer.from(chunk);
263
+ }
264
+ function _isUint8Array(obj) {
265
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
266
+ }
267
+ var destroyImpl = require_destroy();
268
+ util.inherits(Writable, Stream);
269
+ function nop() {}
270
+ function WritableState(options, stream) {
271
+ Duplex = Duplex || require__stream_duplex();
272
+ options = options || {};
273
+ var isDuplex = stream instanceof Duplex;
274
+ this.objectMode = !!options.objectMode;
275
+ if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
276
+ var hwm = options.highWaterMark;
277
+ var writableHwm = options.writableHighWaterMark;
278
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
279
+ if (hwm || hwm === 0) this.highWaterMark = hwm;
280
+ else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;
281
+ else this.highWaterMark = defaultHwm;
282
+ this.highWaterMark = Math.floor(this.highWaterMark);
283
+ this.finalCalled = false;
284
+ this.needDrain = false;
285
+ this.ending = false;
286
+ this.ended = false;
287
+ this.finished = false;
288
+ this.destroyed = false;
289
+ this.decodeStrings = !(options.decodeStrings === false);
290
+ this.defaultEncoding = options.defaultEncoding || "utf8";
291
+ this.length = 0;
292
+ this.writing = false;
293
+ this.corked = 0;
294
+ this.sync = true;
295
+ this.bufferProcessing = false;
296
+ this.onwrite = function(er) {
297
+ onwrite(stream, er);
298
+ };
299
+ this.writecb = null;
300
+ this.writelen = 0;
301
+ this.bufferedRequest = null;
302
+ this.lastBufferedRequest = null;
303
+ this.pendingcb = 0;
304
+ this.prefinished = false;
305
+ this.errorEmitted = false;
306
+ this.bufferedRequestCount = 0;
307
+ this.corkedRequestsFree = new CorkedRequest(this);
308
+ }
309
+ WritableState.prototype.getBuffer = function getBuffer() {
310
+ var current = this.bufferedRequest;
311
+ var out = [];
312
+ while (current) {
313
+ out.push(current);
314
+ current = current.next;
315
+ }
316
+ return out;
317
+ };
318
+ (function() {
319
+ try {
320
+ Object.defineProperty(WritableState.prototype, "buffer", { get: internalUtil.deprecate(function() {
321
+ return this.getBuffer();
322
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.", "DEP0003") });
323
+ } catch (_) {}
324
+ })();
325
+ var realHasInstance;
326
+ if (typeof Symbol === "function" && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === "function") {
327
+ realHasInstance = Function.prototype[Symbol.hasInstance];
328
+ Object.defineProperty(Writable, Symbol.hasInstance, { value: function(object) {
329
+ if (realHasInstance.call(this, object)) return true;
330
+ if (this !== Writable) return false;
331
+ return object && object._writableState instanceof WritableState;
332
+ } });
333
+ } else realHasInstance = function(object) {
334
+ return object instanceof this;
335
+ };
336
+ function Writable(options) {
337
+ Duplex = Duplex || require__stream_duplex();
338
+ if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) return new Writable(options);
339
+ this._writableState = new WritableState(options, this);
340
+ this.writable = true;
341
+ if (options) {
342
+ if (typeof options.write === "function") this._write = options.write;
343
+ if (typeof options.writev === "function") this._writev = options.writev;
344
+ if (typeof options.destroy === "function") this._destroy = options.destroy;
345
+ if (typeof options.final === "function") this._final = options.final;
346
+ }
347
+ Stream.call(this);
348
+ }
349
+ Writable.prototype.pipe = function() {
350
+ this.emit("error", /* @__PURE__ */ new Error("Cannot pipe, not readable"));
351
+ };
352
+ function writeAfterEnd(stream, cb) {
353
+ var er = /* @__PURE__ */ new Error("write after end");
354
+ stream.emit("error", er);
355
+ pna.nextTick(cb, er);
356
+ }
357
+ function validChunk(stream, state, chunk, cb) {
358
+ var valid = true;
359
+ var er = false;
360
+ if (chunk === null) er = /* @__PURE__ */ new TypeError("May not write null values to stream");
361
+ else if (typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
362
+ if (er) {
363
+ stream.emit("error", er);
364
+ pna.nextTick(cb, er);
365
+ valid = false;
366
+ }
367
+ return valid;
368
+ }
369
+ Writable.prototype.write = function(chunk, encoding, cb) {
370
+ var state = this._writableState;
371
+ var ret = false;
372
+ var isBuf = !state.objectMode && _isUint8Array(chunk);
373
+ if (isBuf && !Buffer.isBuffer(chunk)) chunk = _uint8ArrayToBuffer(chunk);
374
+ if (typeof encoding === "function") {
375
+ cb = encoding;
376
+ encoding = null;
377
+ }
378
+ if (isBuf) encoding = "buffer";
379
+ else if (!encoding) encoding = state.defaultEncoding;
380
+ if (typeof cb !== "function") cb = nop;
381
+ if (state.ended) writeAfterEnd(this, cb);
382
+ else if (isBuf || validChunk(this, state, chunk, cb)) {
383
+ state.pendingcb++;
384
+ ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
385
+ }
386
+ return ret;
387
+ };
388
+ Writable.prototype.cork = function() {
389
+ var state = this._writableState;
390
+ state.corked++;
391
+ };
392
+ Writable.prototype.uncork = function() {
393
+ var state = this._writableState;
394
+ if (state.corked) {
395
+ state.corked--;
396
+ if (!state.writing && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
397
+ }
398
+ };
399
+ Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
400
+ if (typeof encoding === "string") encoding = encoding.toLowerCase();
401
+ if (!([
402
+ "hex",
403
+ "utf8",
404
+ "utf-8",
405
+ "ascii",
406
+ "binary",
407
+ "base64",
408
+ "ucs2",
409
+ "ucs-2",
410
+ "utf16le",
411
+ "utf-16le",
412
+ "raw"
413
+ ].indexOf((encoding + "").toLowerCase()) > -1)) throw new TypeError("Unknown encoding: " + encoding);
414
+ this._writableState.defaultEncoding = encoding;
415
+ return this;
416
+ };
417
+ function decodeChunk(state, chunk, encoding) {
418
+ if (!state.objectMode && state.decodeStrings !== false && typeof chunk === "string") chunk = Buffer.from(chunk, encoding);
419
+ return chunk;
420
+ }
421
+ Object.defineProperty(Writable.prototype, "writableHighWaterMark", {
422
+ enumerable: false,
423
+ get: function() {
424
+ return this._writableState.highWaterMark;
425
+ }
426
+ });
427
+ function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
428
+ if (!isBuf) {
429
+ var newChunk = decodeChunk(state, chunk, encoding);
430
+ if (chunk !== newChunk) {
431
+ isBuf = true;
432
+ encoding = "buffer";
433
+ chunk = newChunk;
434
+ }
435
+ }
436
+ var len = state.objectMode ? 1 : chunk.length;
437
+ state.length += len;
438
+ var ret = state.length < state.highWaterMark;
439
+ if (!ret) state.needDrain = true;
440
+ if (state.writing || state.corked) {
441
+ var last = state.lastBufferedRequest;
442
+ state.lastBufferedRequest = {
443
+ chunk,
444
+ encoding,
445
+ isBuf,
446
+ callback: cb,
447
+ next: null
448
+ };
449
+ if (last) last.next = state.lastBufferedRequest;
450
+ else state.bufferedRequest = state.lastBufferedRequest;
451
+ state.bufferedRequestCount += 1;
452
+ } else doWrite(stream, state, false, len, chunk, encoding, cb);
453
+ return ret;
454
+ }
455
+ function doWrite(stream, state, writev, len, chunk, encoding, cb) {
456
+ state.writelen = len;
457
+ state.writecb = cb;
458
+ state.writing = true;
459
+ state.sync = true;
460
+ if (writev) stream._writev(chunk, state.onwrite);
461
+ else stream._write(chunk, encoding, state.onwrite);
462
+ state.sync = false;
463
+ }
464
+ function onwriteError(stream, state, sync, er, cb) {
465
+ --state.pendingcb;
466
+ if (sync) {
467
+ pna.nextTick(cb, er);
468
+ pna.nextTick(finishMaybe, stream, state);
469
+ stream._writableState.errorEmitted = true;
470
+ stream.emit("error", er);
471
+ } else {
472
+ cb(er);
473
+ stream._writableState.errorEmitted = true;
474
+ stream.emit("error", er);
475
+ finishMaybe(stream, state);
476
+ }
477
+ }
478
+ function onwriteStateUpdate(state) {
479
+ state.writing = false;
480
+ state.writecb = null;
481
+ state.length -= state.writelen;
482
+ state.writelen = 0;
483
+ }
484
+ function onwrite(stream, er) {
485
+ var state = stream._writableState;
486
+ var sync = state.sync;
487
+ var cb = state.writecb;
488
+ onwriteStateUpdate(state);
489
+ if (er) onwriteError(stream, state, sync, er, cb);
490
+ else {
491
+ var finished = needFinish(state);
492
+ if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) clearBuffer(stream, state);
493
+ if (sync) asyncWrite(afterWrite, stream, state, finished, cb);
494
+ else afterWrite(stream, state, finished, cb);
495
+ }
496
+ }
497
+ function afterWrite(stream, state, finished, cb) {
498
+ if (!finished) onwriteDrain(stream, state);
499
+ state.pendingcb--;
500
+ cb();
501
+ finishMaybe(stream, state);
502
+ }
503
+ function onwriteDrain(stream, state) {
504
+ if (state.length === 0 && state.needDrain) {
505
+ state.needDrain = false;
506
+ stream.emit("drain");
507
+ }
508
+ }
509
+ function clearBuffer(stream, state) {
510
+ state.bufferProcessing = true;
511
+ var entry = state.bufferedRequest;
512
+ if (stream._writev && entry && entry.next) {
513
+ var l = state.bufferedRequestCount;
514
+ var buffer = new Array(l);
515
+ var holder = state.corkedRequestsFree;
516
+ holder.entry = entry;
517
+ var count = 0;
518
+ var allBuffers = true;
519
+ while (entry) {
520
+ buffer[count] = entry;
521
+ if (!entry.isBuf) allBuffers = false;
522
+ entry = entry.next;
523
+ count += 1;
524
+ }
525
+ buffer.allBuffers = allBuffers;
526
+ doWrite(stream, state, true, state.length, buffer, "", holder.finish);
527
+ state.pendingcb++;
528
+ state.lastBufferedRequest = null;
529
+ if (holder.next) {
530
+ state.corkedRequestsFree = holder.next;
531
+ holder.next = null;
532
+ } else state.corkedRequestsFree = new CorkedRequest(state);
533
+ state.bufferedRequestCount = 0;
534
+ } else {
535
+ while (entry) {
536
+ var chunk = entry.chunk;
537
+ var encoding = entry.encoding;
538
+ var cb = entry.callback;
539
+ doWrite(stream, state, false, state.objectMode ? 1 : chunk.length, chunk, encoding, cb);
540
+ entry = entry.next;
541
+ state.bufferedRequestCount--;
542
+ if (state.writing) break;
543
+ }
544
+ if (entry === null) state.lastBufferedRequest = null;
545
+ }
546
+ state.bufferedRequest = entry;
547
+ state.bufferProcessing = false;
548
+ }
549
+ Writable.prototype._write = function(chunk, encoding, cb) {
550
+ cb(/* @__PURE__ */ new Error("_write() is not implemented"));
551
+ };
552
+ Writable.prototype._writev = null;
553
+ Writable.prototype.end = function(chunk, encoding, cb) {
554
+ var state = this._writableState;
555
+ if (typeof chunk === "function") {
556
+ cb = chunk;
557
+ chunk = null;
558
+ encoding = null;
559
+ } else if (typeof encoding === "function") {
560
+ cb = encoding;
561
+ encoding = null;
562
+ }
563
+ if (chunk !== null && chunk !== void 0) this.write(chunk, encoding);
564
+ if (state.corked) {
565
+ state.corked = 1;
566
+ this.uncork();
567
+ }
568
+ if (!state.ending) endWritable(this, state, cb);
569
+ };
570
+ function needFinish(state) {
571
+ return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
572
+ }
573
+ function callFinal(stream, state) {
574
+ stream._final(function(err) {
575
+ state.pendingcb--;
576
+ if (err) stream.emit("error", err);
577
+ state.prefinished = true;
578
+ stream.emit("prefinish");
579
+ finishMaybe(stream, state);
580
+ });
581
+ }
582
+ function prefinish(stream, state) {
583
+ if (!state.prefinished && !state.finalCalled) if (typeof stream._final === "function") {
584
+ state.pendingcb++;
585
+ state.finalCalled = true;
586
+ pna.nextTick(callFinal, stream, state);
587
+ } else {
588
+ state.prefinished = true;
589
+ stream.emit("prefinish");
590
+ }
591
+ }
592
+ function finishMaybe(stream, state) {
593
+ var need = needFinish(state);
594
+ if (need) {
595
+ prefinish(stream, state);
596
+ if (state.pendingcb === 0) {
597
+ state.finished = true;
598
+ stream.emit("finish");
599
+ }
600
+ }
601
+ return need;
602
+ }
603
+ function endWritable(stream, state, cb) {
604
+ state.ending = true;
605
+ finishMaybe(stream, state);
606
+ if (cb) if (state.finished) pna.nextTick(cb);
607
+ else stream.once("finish", cb);
608
+ state.ended = true;
609
+ stream.writable = false;
610
+ }
611
+ function onCorkedFinish(corkReq, state, err) {
612
+ var entry = corkReq.entry;
613
+ corkReq.entry = null;
614
+ while (entry) {
615
+ var cb = entry.callback;
616
+ state.pendingcb--;
617
+ cb(err);
618
+ entry = entry.next;
619
+ }
620
+ state.corkedRequestsFree.next = corkReq;
621
+ }
622
+ Object.defineProperty(Writable.prototype, "destroyed", {
623
+ get: function() {
624
+ if (this._writableState === void 0) return false;
625
+ return this._writableState.destroyed;
626
+ },
627
+ set: function(value) {
628
+ if (!this._writableState) return;
629
+ this._writableState.destroyed = value;
630
+ }
631
+ });
632
+ Writable.prototype.destroy = destroyImpl.destroy;
633
+ Writable.prototype._undestroy = destroyImpl.undestroy;
634
+ Writable.prototype._destroy = function(err, cb) {
635
+ this.end();
636
+ cb(err);
637
+ };
638
+ }));
639
+ var require__stream_duplex = /* @__PURE__ */ __commonJSMin(((exports, module) => {
640
+ var pna = require_process_nextick_args();
641
+ var objectKeys = Object.keys || function(obj) {
642
+ var keys = [];
643
+ for (var key in obj) keys.push(key);
644
+ return keys;
645
+ };
646
+ module.exports = Duplex;
647
+ var util = Object.create(require_util());
648
+ util.inherits = require_inherits();
649
+ var Readable = require__stream_readable();
650
+ var Writable = require__stream_writable();
651
+ util.inherits(Duplex, Readable);
652
+ var keys = objectKeys(Writable.prototype);
653
+ for (var v = 0; v < keys.length; v++) {
654
+ var method = keys[v];
655
+ if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
656
+ }
657
+ function Duplex(options) {
658
+ if (!(this instanceof Duplex)) return new Duplex(options);
659
+ Readable.call(this, options);
660
+ Writable.call(this, options);
661
+ if (options && options.readable === false) this.readable = false;
662
+ if (options && options.writable === false) this.writable = false;
663
+ this.allowHalfOpen = true;
664
+ if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
665
+ this.once("end", onend);
666
+ }
667
+ Object.defineProperty(Duplex.prototype, "writableHighWaterMark", {
668
+ enumerable: false,
669
+ get: function() {
670
+ return this._writableState.highWaterMark;
671
+ }
672
+ });
673
+ function onend() {
674
+ if (this.allowHalfOpen || this._writableState.ended) return;
675
+ pna.nextTick(onEndNT, this);
676
+ }
677
+ function onEndNT(self) {
678
+ self.end();
679
+ }
680
+ Object.defineProperty(Duplex.prototype, "destroyed", {
681
+ get: function() {
682
+ if (this._readableState === void 0 || this._writableState === void 0) return false;
683
+ return this._readableState.destroyed && this._writableState.destroyed;
684
+ },
685
+ set: function(value) {
686
+ if (this._readableState === void 0 || this._writableState === void 0) return;
687
+ this._readableState.destroyed = value;
688
+ this._writableState.destroyed = value;
689
+ }
690
+ });
691
+ Duplex.prototype._destroy = function(err, cb) {
692
+ this.push(null);
693
+ this.end();
694
+ pna.nextTick(cb, err);
695
+ };
696
+ }));
697
+ var require_string_decoder = /* @__PURE__ */ __commonJSMin(((exports) => {
698
+ var Buffer = require_safe_buffer().Buffer;
699
+ var isEncoding = Buffer.isEncoding || function(encoding) {
700
+ encoding = "" + encoding;
701
+ switch (encoding && encoding.toLowerCase()) {
702
+ case "hex":
703
+ case "utf8":
704
+ case "utf-8":
705
+ case "ascii":
706
+ case "binary":
707
+ case "base64":
708
+ case "ucs2":
709
+ case "ucs-2":
710
+ case "utf16le":
711
+ case "utf-16le":
712
+ case "raw": return true;
713
+ default: return false;
714
+ }
715
+ };
716
+ function _normalizeEncoding(enc) {
717
+ if (!enc) return "utf8";
718
+ var retried;
719
+ while (true) switch (enc) {
720
+ case "utf8":
721
+ case "utf-8": return "utf8";
722
+ case "ucs2":
723
+ case "ucs-2":
724
+ case "utf16le":
725
+ case "utf-16le": return "utf16le";
726
+ case "latin1":
727
+ case "binary": return "latin1";
728
+ case "base64":
729
+ case "ascii":
730
+ case "hex": return enc;
731
+ default:
732
+ if (retried) return;
733
+ enc = ("" + enc).toLowerCase();
734
+ retried = true;
735
+ }
736
+ }
737
+ function normalizeEncoding(enc) {
738
+ var nenc = _normalizeEncoding(enc);
739
+ if (typeof nenc !== "string" && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error("Unknown encoding: " + enc);
740
+ return nenc || enc;
741
+ }
742
+ exports.StringDecoder = StringDecoder;
743
+ function StringDecoder(encoding) {
744
+ this.encoding = normalizeEncoding(encoding);
745
+ var nb;
746
+ switch (this.encoding) {
747
+ case "utf16le":
748
+ this.text = utf16Text;
749
+ this.end = utf16End;
750
+ nb = 4;
751
+ break;
752
+ case "utf8":
753
+ this.fillLast = utf8FillLast;
754
+ nb = 4;
755
+ break;
756
+ case "base64":
757
+ this.text = base64Text;
758
+ this.end = base64End;
759
+ nb = 3;
760
+ break;
761
+ default:
762
+ this.write = simpleWrite;
763
+ this.end = simpleEnd;
764
+ return;
765
+ }
766
+ this.lastNeed = 0;
767
+ this.lastTotal = 0;
768
+ this.lastChar = Buffer.allocUnsafe(nb);
769
+ }
770
+ StringDecoder.prototype.write = function(buf) {
771
+ if (buf.length === 0) return "";
772
+ var r;
773
+ var i;
774
+ if (this.lastNeed) {
775
+ r = this.fillLast(buf);
776
+ if (r === void 0) return "";
777
+ i = this.lastNeed;
778
+ this.lastNeed = 0;
779
+ } else i = 0;
780
+ if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
781
+ return r || "";
782
+ };
783
+ StringDecoder.prototype.end = utf8End;
784
+ StringDecoder.prototype.text = utf8Text;
785
+ StringDecoder.prototype.fillLast = function(buf) {
786
+ if (this.lastNeed <= buf.length) {
787
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
788
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
789
+ }
790
+ buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
791
+ this.lastNeed -= buf.length;
792
+ };
793
+ function utf8CheckByte(byte) {
794
+ if (byte <= 127) return 0;
795
+ else if (byte >> 5 === 6) return 2;
796
+ else if (byte >> 4 === 14) return 3;
797
+ else if (byte >> 3 === 30) return 4;
798
+ return byte >> 6 === 2 ? -1 : -2;
799
+ }
800
+ function utf8CheckIncomplete(self, buf, i) {
801
+ var j = buf.length - 1;
802
+ if (j < i) return 0;
803
+ var nb = utf8CheckByte(buf[j]);
804
+ if (nb >= 0) {
805
+ if (nb > 0) self.lastNeed = nb - 1;
806
+ return nb;
807
+ }
808
+ if (--j < i || nb === -2) return 0;
809
+ nb = utf8CheckByte(buf[j]);
810
+ if (nb >= 0) {
811
+ if (nb > 0) self.lastNeed = nb - 2;
812
+ return nb;
813
+ }
814
+ if (--j < i || nb === -2) return 0;
815
+ nb = utf8CheckByte(buf[j]);
816
+ if (nb >= 0) {
817
+ if (nb > 0) if (nb === 2) nb = 0;
818
+ else self.lastNeed = nb - 3;
819
+ return nb;
820
+ }
821
+ return 0;
822
+ }
823
+ function utf8CheckExtraBytes(self, buf, p) {
824
+ if ((buf[0] & 192) !== 128) {
825
+ self.lastNeed = 0;
826
+ return "�";
827
+ }
828
+ if (self.lastNeed > 1 && buf.length > 1) {
829
+ if ((buf[1] & 192) !== 128) {
830
+ self.lastNeed = 1;
831
+ return "�";
832
+ }
833
+ if (self.lastNeed > 2 && buf.length > 2) {
834
+ if ((buf[2] & 192) !== 128) {
835
+ self.lastNeed = 2;
836
+ return "�";
837
+ }
838
+ }
839
+ }
840
+ }
841
+ function utf8FillLast(buf) {
842
+ var p = this.lastTotal - this.lastNeed;
843
+ var r = utf8CheckExtraBytes(this, buf, p);
844
+ if (r !== void 0) return r;
845
+ if (this.lastNeed <= buf.length) {
846
+ buf.copy(this.lastChar, p, 0, this.lastNeed);
847
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
848
+ }
849
+ buf.copy(this.lastChar, p, 0, buf.length);
850
+ this.lastNeed -= buf.length;
851
+ }
852
+ function utf8Text(buf, i) {
853
+ var total = utf8CheckIncomplete(this, buf, i);
854
+ if (!this.lastNeed) return buf.toString("utf8", i);
855
+ this.lastTotal = total;
856
+ var end = buf.length - (total - this.lastNeed);
857
+ buf.copy(this.lastChar, 0, end);
858
+ return buf.toString("utf8", i, end);
859
+ }
860
+ function utf8End(buf) {
861
+ var r = buf && buf.length ? this.write(buf) : "";
862
+ if (this.lastNeed) return r + "�";
863
+ return r;
864
+ }
865
+ function utf16Text(buf, i) {
866
+ if ((buf.length - i) % 2 === 0) {
867
+ var r = buf.toString("utf16le", i);
868
+ if (r) {
869
+ var c = r.charCodeAt(r.length - 1);
870
+ if (c >= 55296 && c <= 56319) {
871
+ this.lastNeed = 2;
872
+ this.lastTotal = 4;
873
+ this.lastChar[0] = buf[buf.length - 2];
874
+ this.lastChar[1] = buf[buf.length - 1];
875
+ return r.slice(0, -1);
876
+ }
877
+ }
878
+ return r;
879
+ }
880
+ this.lastNeed = 1;
881
+ this.lastTotal = 2;
882
+ this.lastChar[0] = buf[buf.length - 1];
883
+ return buf.toString("utf16le", i, buf.length - 1);
884
+ }
885
+ function utf16End(buf) {
886
+ var r = buf && buf.length ? this.write(buf) : "";
887
+ if (this.lastNeed) {
888
+ var end = this.lastTotal - this.lastNeed;
889
+ return r + this.lastChar.toString("utf16le", 0, end);
890
+ }
891
+ return r;
892
+ }
893
+ function base64Text(buf, i) {
894
+ var n = (buf.length - i) % 3;
895
+ if (n === 0) return buf.toString("base64", i);
896
+ this.lastNeed = 3 - n;
897
+ this.lastTotal = 3;
898
+ if (n === 1) this.lastChar[0] = buf[buf.length - 1];
899
+ else {
900
+ this.lastChar[0] = buf[buf.length - 2];
901
+ this.lastChar[1] = buf[buf.length - 1];
902
+ }
903
+ return buf.toString("base64", i, buf.length - n);
904
+ }
905
+ function base64End(buf) {
906
+ var r = buf && buf.length ? this.write(buf) : "";
907
+ if (this.lastNeed) return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
908
+ return r;
909
+ }
910
+ function simpleWrite(buf) {
911
+ return buf.toString(this.encoding);
912
+ }
913
+ function simpleEnd(buf) {
914
+ return buf && buf.length ? this.write(buf) : "";
915
+ }
916
+ }));
917
+ var require__stream_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
918
+ var pna = require_process_nextick_args();
919
+ module.exports = Readable;
920
+ var isArray = require_isarray();
921
+ var Duplex;
922
+ Readable.ReadableState = ReadableState;
923
+ __require("events").EventEmitter;
924
+ var EElistenerCount = function(emitter, type) {
925
+ return emitter.listeners(type).length;
926
+ };
927
+ var Stream = require_stream();
928
+ var Buffer = require_safe_buffer().Buffer;
929
+ var OurUint8Array = (typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : typeof self !== "undefined" ? self : {}).Uint8Array || function() {};
930
+ function _uint8ArrayToBuffer(chunk) {
931
+ return Buffer.from(chunk);
932
+ }
933
+ function _isUint8Array(obj) {
934
+ return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
935
+ }
936
+ var util = Object.create(require_util());
937
+ util.inherits = require_inherits();
938
+ var debugUtil = __require("util");
939
+ var debug = void 0;
940
+ if (debugUtil && debugUtil.debuglog) debug = debugUtil.debuglog("stream");
941
+ else debug = function() {};
942
+ var BufferList = require_BufferList();
943
+ var destroyImpl = require_destroy();
944
+ var StringDecoder;
945
+ util.inherits(Readable, Stream);
946
+ var kProxyEvents = [
947
+ "error",
948
+ "close",
949
+ "destroy",
950
+ "pause",
951
+ "resume"
952
+ ];
953
+ function prependListener(emitter, event, fn) {
954
+ if (typeof emitter.prependListener === "function") return emitter.prependListener(event, fn);
955
+ if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);
956
+ else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);
957
+ else emitter._events[event] = [fn, emitter._events[event]];
958
+ }
959
+ function ReadableState(options, stream) {
960
+ Duplex = Duplex || require__stream_duplex();
961
+ options = options || {};
962
+ var isDuplex = stream instanceof Duplex;
963
+ this.objectMode = !!options.objectMode;
964
+ if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
965
+ var hwm = options.highWaterMark;
966
+ var readableHwm = options.readableHighWaterMark;
967
+ var defaultHwm = this.objectMode ? 16 : 16 * 1024;
968
+ if (hwm || hwm === 0) this.highWaterMark = hwm;
969
+ else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;
970
+ else this.highWaterMark = defaultHwm;
971
+ this.highWaterMark = Math.floor(this.highWaterMark);
972
+ this.buffer = new BufferList();
973
+ this.length = 0;
974
+ this.pipes = null;
975
+ this.pipesCount = 0;
976
+ this.flowing = null;
977
+ this.ended = false;
978
+ this.endEmitted = false;
979
+ this.reading = false;
980
+ this.sync = true;
981
+ this.needReadable = false;
982
+ this.emittedReadable = false;
983
+ this.readableListening = false;
984
+ this.resumeScheduled = false;
985
+ this.destroyed = false;
986
+ this.defaultEncoding = options.defaultEncoding || "utf8";
987
+ this.awaitDrain = 0;
988
+ this.readingMore = false;
989
+ this.decoder = null;
990
+ this.encoding = null;
991
+ if (options.encoding) {
992
+ if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
993
+ this.decoder = new StringDecoder(options.encoding);
994
+ this.encoding = options.encoding;
995
+ }
996
+ }
997
+ function Readable(options) {
998
+ Duplex = Duplex || require__stream_duplex();
999
+ if (!(this instanceof Readable)) return new Readable(options);
1000
+ this._readableState = new ReadableState(options, this);
1001
+ this.readable = true;
1002
+ if (options) {
1003
+ if (typeof options.read === "function") this._read = options.read;
1004
+ if (typeof options.destroy === "function") this._destroy = options.destroy;
1005
+ }
1006
+ Stream.call(this);
1007
+ }
1008
+ Object.defineProperty(Readable.prototype, "destroyed", {
1009
+ get: function() {
1010
+ if (this._readableState === void 0) return false;
1011
+ return this._readableState.destroyed;
1012
+ },
1013
+ set: function(value) {
1014
+ if (!this._readableState) return;
1015
+ this._readableState.destroyed = value;
1016
+ }
1017
+ });
1018
+ Readable.prototype.destroy = destroyImpl.destroy;
1019
+ Readable.prototype._undestroy = destroyImpl.undestroy;
1020
+ Readable.prototype._destroy = function(err, cb) {
1021
+ this.push(null);
1022
+ cb(err);
1023
+ };
1024
+ Readable.prototype.push = function(chunk, encoding) {
1025
+ var state = this._readableState;
1026
+ var skipChunkCheck;
1027
+ if (!state.objectMode) {
1028
+ if (typeof chunk === "string") {
1029
+ encoding = encoding || state.defaultEncoding;
1030
+ if (encoding !== state.encoding) {
1031
+ chunk = Buffer.from(chunk, encoding);
1032
+ encoding = "";
1033
+ }
1034
+ skipChunkCheck = true;
1035
+ }
1036
+ } else skipChunkCheck = true;
1037
+ return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
1038
+ };
1039
+ Readable.prototype.unshift = function(chunk) {
1040
+ return readableAddChunk(this, chunk, null, true, false);
1041
+ };
1042
+ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
1043
+ var state = stream._readableState;
1044
+ if (chunk === null) {
1045
+ state.reading = false;
1046
+ onEofChunk(stream, state);
1047
+ } else {
1048
+ var er;
1049
+ if (!skipChunkCheck) er = chunkInvalid(state, chunk);
1050
+ if (er) stream.emit("error", er);
1051
+ else if (state.objectMode || chunk && chunk.length > 0) {
1052
+ if (typeof chunk !== "string" && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) chunk = _uint8ArrayToBuffer(chunk);
1053
+ if (addToFront) if (state.endEmitted) stream.emit("error", /* @__PURE__ */ new Error("stream.unshift() after end event"));
1054
+ else addChunk(stream, state, chunk, true);
1055
+ else if (state.ended) stream.emit("error", /* @__PURE__ */ new Error("stream.push() after EOF"));
1056
+ else {
1057
+ state.reading = false;
1058
+ if (state.decoder && !encoding) {
1059
+ chunk = state.decoder.write(chunk);
1060
+ if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);
1061
+ else maybeReadMore(stream, state);
1062
+ } else addChunk(stream, state, chunk, false);
1063
+ }
1064
+ } else if (!addToFront) state.reading = false;
1065
+ }
1066
+ return needMoreData(state);
1067
+ }
1068
+ function addChunk(stream, state, chunk, addToFront) {
1069
+ if (state.flowing && state.length === 0 && !state.sync) {
1070
+ stream.emit("data", chunk);
1071
+ stream.read(0);
1072
+ } else {
1073
+ state.length += state.objectMode ? 1 : chunk.length;
1074
+ if (addToFront) state.buffer.unshift(chunk);
1075
+ else state.buffer.push(chunk);
1076
+ if (state.needReadable) emitReadable(stream);
1077
+ }
1078
+ maybeReadMore(stream, state);
1079
+ }
1080
+ function chunkInvalid(state, chunk) {
1081
+ var er;
1082
+ if (!_isUint8Array(chunk) && typeof chunk !== "string" && chunk !== void 0 && !state.objectMode) er = /* @__PURE__ */ new TypeError("Invalid non-string/buffer chunk");
1083
+ return er;
1084
+ }
1085
+ function needMoreData(state) {
1086
+ return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
1087
+ }
1088
+ Readable.prototype.isPaused = function() {
1089
+ return this._readableState.flowing === false;
1090
+ };
1091
+ Readable.prototype.setEncoding = function(enc) {
1092
+ if (!StringDecoder) StringDecoder = require_string_decoder().StringDecoder;
1093
+ this._readableState.decoder = new StringDecoder(enc);
1094
+ this._readableState.encoding = enc;
1095
+ return this;
1096
+ };
1097
+ var MAX_HWM = 8388608;
1098
+ function computeNewHighWaterMark(n) {
1099
+ if (n >= MAX_HWM) n = MAX_HWM;
1100
+ else {
1101
+ n--;
1102
+ n |= n >>> 1;
1103
+ n |= n >>> 2;
1104
+ n |= n >>> 4;
1105
+ n |= n >>> 8;
1106
+ n |= n >>> 16;
1107
+ n++;
1108
+ }
1109
+ return n;
1110
+ }
1111
+ function howMuchToRead(n, state) {
1112
+ if (n <= 0 || state.length === 0 && state.ended) return 0;
1113
+ if (state.objectMode) return 1;
1114
+ if (n !== n) if (state.flowing && state.length) return state.buffer.head.data.length;
1115
+ else return state.length;
1116
+ if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
1117
+ if (n <= state.length) return n;
1118
+ if (!state.ended) {
1119
+ state.needReadable = true;
1120
+ return 0;
1121
+ }
1122
+ return state.length;
1123
+ }
1124
+ Readable.prototype.read = function(n) {
1125
+ debug("read", n);
1126
+ n = parseInt(n, 10);
1127
+ var state = this._readableState;
1128
+ var nOrig = n;
1129
+ if (n !== 0) state.emittedReadable = false;
1130
+ if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
1131
+ debug("read: emitReadable", state.length, state.ended);
1132
+ if (state.length === 0 && state.ended) endReadable(this);
1133
+ else emitReadable(this);
1134
+ return null;
1135
+ }
1136
+ n = howMuchToRead(n, state);
1137
+ if (n === 0 && state.ended) {
1138
+ if (state.length === 0) endReadable(this);
1139
+ return null;
1140
+ }
1141
+ var doRead = state.needReadable;
1142
+ debug("need readable", doRead);
1143
+ if (state.length === 0 || state.length - n < state.highWaterMark) {
1144
+ doRead = true;
1145
+ debug("length less than watermark", doRead);
1146
+ }
1147
+ if (state.ended || state.reading) {
1148
+ doRead = false;
1149
+ debug("reading or ended", doRead);
1150
+ } else if (doRead) {
1151
+ debug("do read");
1152
+ state.reading = true;
1153
+ state.sync = true;
1154
+ if (state.length === 0) state.needReadable = true;
1155
+ this._read(state.highWaterMark);
1156
+ state.sync = false;
1157
+ if (!state.reading) n = howMuchToRead(nOrig, state);
1158
+ }
1159
+ var ret;
1160
+ if (n > 0) ret = fromList(n, state);
1161
+ else ret = null;
1162
+ if (ret === null) {
1163
+ state.needReadable = true;
1164
+ n = 0;
1165
+ } else state.length -= n;
1166
+ if (state.length === 0) {
1167
+ if (!state.ended) state.needReadable = true;
1168
+ if (nOrig !== n && state.ended) endReadable(this);
1169
+ }
1170
+ if (ret !== null) this.emit("data", ret);
1171
+ return ret;
1172
+ };
1173
+ function onEofChunk(stream, state) {
1174
+ if (state.ended) return;
1175
+ if (state.decoder) {
1176
+ var chunk = state.decoder.end();
1177
+ if (chunk && chunk.length) {
1178
+ state.buffer.push(chunk);
1179
+ state.length += state.objectMode ? 1 : chunk.length;
1180
+ }
1181
+ }
1182
+ state.ended = true;
1183
+ emitReadable(stream);
1184
+ }
1185
+ function emitReadable(stream) {
1186
+ var state = stream._readableState;
1187
+ state.needReadable = false;
1188
+ if (!state.emittedReadable) {
1189
+ debug("emitReadable", state.flowing);
1190
+ state.emittedReadable = true;
1191
+ if (state.sync) pna.nextTick(emitReadable_, stream);
1192
+ else emitReadable_(stream);
1193
+ }
1194
+ }
1195
+ function emitReadable_(stream) {
1196
+ debug("emit readable");
1197
+ stream.emit("readable");
1198
+ flow(stream);
1199
+ }
1200
+ function maybeReadMore(stream, state) {
1201
+ if (!state.readingMore) {
1202
+ state.readingMore = true;
1203
+ pna.nextTick(maybeReadMore_, stream, state);
1204
+ }
1205
+ }
1206
+ function maybeReadMore_(stream, state) {
1207
+ var len = state.length;
1208
+ while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
1209
+ debug("maybeReadMore read 0");
1210
+ stream.read(0);
1211
+ if (len === state.length) break;
1212
+ else len = state.length;
1213
+ }
1214
+ state.readingMore = false;
1215
+ }
1216
+ Readable.prototype._read = function(n) {
1217
+ this.emit("error", /* @__PURE__ */ new Error("_read() is not implemented"));
1218
+ };
1219
+ Readable.prototype.pipe = function(dest, pipeOpts) {
1220
+ var src = this;
1221
+ var state = this._readableState;
1222
+ switch (state.pipesCount) {
1223
+ case 0:
1224
+ state.pipes = dest;
1225
+ break;
1226
+ case 1:
1227
+ state.pipes = [state.pipes, dest];
1228
+ break;
1229
+ default:
1230
+ state.pipes.push(dest);
1231
+ break;
1232
+ }
1233
+ state.pipesCount += 1;
1234
+ debug("pipe count=%d opts=%j", state.pipesCount, pipeOpts);
1235
+ var endFn = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr ? onend : unpipe;
1236
+ if (state.endEmitted) pna.nextTick(endFn);
1237
+ else src.once("end", endFn);
1238
+ dest.on("unpipe", onunpipe);
1239
+ function onunpipe(readable, unpipeInfo) {
1240
+ debug("onunpipe");
1241
+ if (readable === src) {
1242
+ if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
1243
+ unpipeInfo.hasUnpiped = true;
1244
+ cleanup();
1245
+ }
1246
+ }
1247
+ }
1248
+ function onend() {
1249
+ debug("onend");
1250
+ dest.end();
1251
+ }
1252
+ var ondrain = pipeOnDrain(src);
1253
+ dest.on("drain", ondrain);
1254
+ var cleanedUp = false;
1255
+ function cleanup() {
1256
+ debug("cleanup");
1257
+ dest.removeListener("close", onclose);
1258
+ dest.removeListener("finish", onfinish);
1259
+ dest.removeListener("drain", ondrain);
1260
+ dest.removeListener("error", onerror);
1261
+ dest.removeListener("unpipe", onunpipe);
1262
+ src.removeListener("end", onend);
1263
+ src.removeListener("end", unpipe);
1264
+ src.removeListener("data", ondata);
1265
+ cleanedUp = true;
1266
+ if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
1267
+ }
1268
+ var increasedAwaitDrain = false;
1269
+ src.on("data", ondata);
1270
+ function ondata(chunk) {
1271
+ debug("ondata");
1272
+ increasedAwaitDrain = false;
1273
+ if (false === dest.write(chunk) && !increasedAwaitDrain) {
1274
+ if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
1275
+ debug("false write response, pause", state.awaitDrain);
1276
+ state.awaitDrain++;
1277
+ increasedAwaitDrain = true;
1278
+ }
1279
+ src.pause();
1280
+ }
1281
+ }
1282
+ function onerror(er) {
1283
+ debug("onerror", er);
1284
+ unpipe();
1285
+ dest.removeListener("error", onerror);
1286
+ if (EElistenerCount(dest, "error") === 0) dest.emit("error", er);
1287
+ }
1288
+ prependListener(dest, "error", onerror);
1289
+ function onclose() {
1290
+ dest.removeListener("finish", onfinish);
1291
+ unpipe();
1292
+ }
1293
+ dest.once("close", onclose);
1294
+ function onfinish() {
1295
+ debug("onfinish");
1296
+ dest.removeListener("close", onclose);
1297
+ unpipe();
1298
+ }
1299
+ dest.once("finish", onfinish);
1300
+ function unpipe() {
1301
+ debug("unpipe");
1302
+ src.unpipe(dest);
1303
+ }
1304
+ dest.emit("pipe", src);
1305
+ if (!state.flowing) {
1306
+ debug("pipe resume");
1307
+ src.resume();
1308
+ }
1309
+ return dest;
1310
+ };
1311
+ function pipeOnDrain(src) {
1312
+ return function() {
1313
+ var state = src._readableState;
1314
+ debug("pipeOnDrain", state.awaitDrain);
1315
+ if (state.awaitDrain) state.awaitDrain--;
1316
+ if (state.awaitDrain === 0 && EElistenerCount(src, "data")) {
1317
+ state.flowing = true;
1318
+ flow(src);
1319
+ }
1320
+ };
1321
+ }
1322
+ Readable.prototype.unpipe = function(dest) {
1323
+ var state = this._readableState;
1324
+ var unpipeInfo = { hasUnpiped: false };
1325
+ if (state.pipesCount === 0) return this;
1326
+ if (state.pipesCount === 1) {
1327
+ if (dest && dest !== state.pipes) return this;
1328
+ if (!dest) dest = state.pipes;
1329
+ state.pipes = null;
1330
+ state.pipesCount = 0;
1331
+ state.flowing = false;
1332
+ if (dest) dest.emit("unpipe", this, unpipeInfo);
1333
+ return this;
1334
+ }
1335
+ if (!dest) {
1336
+ var dests = state.pipes;
1337
+ var len = state.pipesCount;
1338
+ state.pipes = null;
1339
+ state.pipesCount = 0;
1340
+ state.flowing = false;
1341
+ for (var i = 0; i < len; i++) dests[i].emit("unpipe", this, { hasUnpiped: false });
1342
+ return this;
1343
+ }
1344
+ var index = indexOf(state.pipes, dest);
1345
+ if (index === -1) return this;
1346
+ state.pipes.splice(index, 1);
1347
+ state.pipesCount -= 1;
1348
+ if (state.pipesCount === 1) state.pipes = state.pipes[0];
1349
+ dest.emit("unpipe", this, unpipeInfo);
1350
+ return this;
1351
+ };
1352
+ Readable.prototype.on = function(ev, fn) {
1353
+ var res = Stream.prototype.on.call(this, ev, fn);
1354
+ if (ev === "data") {
1355
+ if (this._readableState.flowing !== false) this.resume();
1356
+ } else if (ev === "readable") {
1357
+ var state = this._readableState;
1358
+ if (!state.endEmitted && !state.readableListening) {
1359
+ state.readableListening = state.needReadable = true;
1360
+ state.emittedReadable = false;
1361
+ if (!state.reading) pna.nextTick(nReadingNextTick, this);
1362
+ else if (state.length) emitReadable(this);
1363
+ }
1364
+ }
1365
+ return res;
1366
+ };
1367
+ Readable.prototype.addListener = Readable.prototype.on;
1368
+ function nReadingNextTick(self) {
1369
+ debug("readable nexttick read 0");
1370
+ self.read(0);
1371
+ }
1372
+ Readable.prototype.resume = function() {
1373
+ var state = this._readableState;
1374
+ if (!state.flowing) {
1375
+ debug("resume");
1376
+ state.flowing = true;
1377
+ resume(this, state);
1378
+ }
1379
+ return this;
1380
+ };
1381
+ function resume(stream, state) {
1382
+ if (!state.resumeScheduled) {
1383
+ state.resumeScheduled = true;
1384
+ pna.nextTick(resume_, stream, state);
1385
+ }
1386
+ }
1387
+ function resume_(stream, state) {
1388
+ if (!state.reading) {
1389
+ debug("resume read 0");
1390
+ stream.read(0);
1391
+ }
1392
+ state.resumeScheduled = false;
1393
+ state.awaitDrain = 0;
1394
+ stream.emit("resume");
1395
+ flow(stream);
1396
+ if (state.flowing && !state.reading) stream.read(0);
1397
+ }
1398
+ Readable.prototype.pause = function() {
1399
+ debug("call pause flowing=%j", this._readableState.flowing);
1400
+ if (false !== this._readableState.flowing) {
1401
+ debug("pause");
1402
+ this._readableState.flowing = false;
1403
+ this.emit("pause");
1404
+ }
1405
+ return this;
1406
+ };
1407
+ function flow(stream) {
1408
+ var state = stream._readableState;
1409
+ debug("flow", state.flowing);
1410
+ while (state.flowing && stream.read() !== null);
1411
+ }
1412
+ Readable.prototype.wrap = function(stream) {
1413
+ var _this = this;
1414
+ var state = this._readableState;
1415
+ var paused = false;
1416
+ stream.on("end", function() {
1417
+ debug("wrapped end");
1418
+ if (state.decoder && !state.ended) {
1419
+ var chunk = state.decoder.end();
1420
+ if (chunk && chunk.length) _this.push(chunk);
1421
+ }
1422
+ _this.push(null);
1423
+ });
1424
+ stream.on("data", function(chunk) {
1425
+ debug("wrapped data");
1426
+ if (state.decoder) chunk = state.decoder.write(chunk);
1427
+ if (state.objectMode && (chunk === null || chunk === void 0)) return;
1428
+ else if (!state.objectMode && (!chunk || !chunk.length)) return;
1429
+ if (!_this.push(chunk)) {
1430
+ paused = true;
1431
+ stream.pause();
1432
+ }
1433
+ });
1434
+ for (var i in stream) if (this[i] === void 0 && typeof stream[i] === "function") this[i] = function(method) {
1435
+ return function() {
1436
+ return stream[method].apply(stream, arguments);
1437
+ };
1438
+ }(i);
1439
+ for (var n = 0; n < kProxyEvents.length; n++) stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
1440
+ this._read = function(n) {
1441
+ debug("wrapped _read", n);
1442
+ if (paused) {
1443
+ paused = false;
1444
+ stream.resume();
1445
+ }
1446
+ };
1447
+ return this;
1448
+ };
1449
+ Object.defineProperty(Readable.prototype, "readableHighWaterMark", {
1450
+ enumerable: false,
1451
+ get: function() {
1452
+ return this._readableState.highWaterMark;
1453
+ }
1454
+ });
1455
+ Readable._fromList = fromList;
1456
+ function fromList(n, state) {
1457
+ if (state.length === 0) return null;
1458
+ var ret;
1459
+ if (state.objectMode) ret = state.buffer.shift();
1460
+ else if (!n || n >= state.length) {
1461
+ if (state.decoder) ret = state.buffer.join("");
1462
+ else if (state.buffer.length === 1) ret = state.buffer.head.data;
1463
+ else ret = state.buffer.concat(state.length);
1464
+ state.buffer.clear();
1465
+ } else ret = fromListPartial(n, state.buffer, state.decoder);
1466
+ return ret;
1467
+ }
1468
+ function fromListPartial(n, list, hasStrings) {
1469
+ var ret;
1470
+ if (n < list.head.data.length) {
1471
+ ret = list.head.data.slice(0, n);
1472
+ list.head.data = list.head.data.slice(n);
1473
+ } else if (n === list.head.data.length) ret = list.shift();
1474
+ else ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
1475
+ return ret;
1476
+ }
1477
+ function copyFromBufferString(n, list) {
1478
+ var p = list.head;
1479
+ var c = 1;
1480
+ var ret = p.data;
1481
+ n -= ret.length;
1482
+ while (p = p.next) {
1483
+ var str = p.data;
1484
+ var nb = n > str.length ? str.length : n;
1485
+ if (nb === str.length) ret += str;
1486
+ else ret += str.slice(0, n);
1487
+ n -= nb;
1488
+ if (n === 0) {
1489
+ if (nb === str.length) {
1490
+ ++c;
1491
+ if (p.next) list.head = p.next;
1492
+ else list.head = list.tail = null;
1493
+ } else {
1494
+ list.head = p;
1495
+ p.data = str.slice(nb);
1496
+ }
1497
+ break;
1498
+ }
1499
+ ++c;
1500
+ }
1501
+ list.length -= c;
1502
+ return ret;
1503
+ }
1504
+ function copyFromBuffer(n, list) {
1505
+ var ret = Buffer.allocUnsafe(n);
1506
+ var p = list.head;
1507
+ var c = 1;
1508
+ p.data.copy(ret);
1509
+ n -= p.data.length;
1510
+ while (p = p.next) {
1511
+ var buf = p.data;
1512
+ var nb = n > buf.length ? buf.length : n;
1513
+ buf.copy(ret, ret.length - n, 0, nb);
1514
+ n -= nb;
1515
+ if (n === 0) {
1516
+ if (nb === buf.length) {
1517
+ ++c;
1518
+ if (p.next) list.head = p.next;
1519
+ else list.head = list.tail = null;
1520
+ } else {
1521
+ list.head = p;
1522
+ p.data = buf.slice(nb);
1523
+ }
1524
+ break;
1525
+ }
1526
+ ++c;
1527
+ }
1528
+ list.length -= c;
1529
+ return ret;
1530
+ }
1531
+ function endReadable(stream) {
1532
+ var state = stream._readableState;
1533
+ if (state.length > 0) throw new Error("\"endReadable()\" called on non-empty stream");
1534
+ if (!state.endEmitted) {
1535
+ state.ended = true;
1536
+ pna.nextTick(endReadableNT, state, stream);
1537
+ }
1538
+ }
1539
+ function endReadableNT(state, stream) {
1540
+ if (!state.endEmitted && state.length === 0) {
1541
+ state.endEmitted = true;
1542
+ stream.readable = false;
1543
+ stream.emit("end");
1544
+ }
1545
+ }
1546
+ function indexOf(xs, x) {
1547
+ for (var i = 0, l = xs.length; i < l; i++) if (xs[i] === x) return i;
1548
+ return -1;
1549
+ }
1550
+ }));
1551
+ var require__stream_transform = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1552
+ module.exports = Transform;
1553
+ var Duplex = require__stream_duplex();
1554
+ var util = Object.create(require_util());
1555
+ util.inherits = require_inherits();
1556
+ util.inherits(Transform, Duplex);
1557
+ function afterTransform(er, data) {
1558
+ var ts = this._transformState;
1559
+ ts.transforming = false;
1560
+ var cb = ts.writecb;
1561
+ if (!cb) return this.emit("error", /* @__PURE__ */ new Error("write callback called multiple times"));
1562
+ ts.writechunk = null;
1563
+ ts.writecb = null;
1564
+ if (data != null) this.push(data);
1565
+ cb(er);
1566
+ var rs = this._readableState;
1567
+ rs.reading = false;
1568
+ if (rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
1569
+ }
1570
+ function Transform(options) {
1571
+ if (!(this instanceof Transform)) return new Transform(options);
1572
+ Duplex.call(this, options);
1573
+ this._transformState = {
1574
+ afterTransform: afterTransform.bind(this),
1575
+ needTransform: false,
1576
+ transforming: false,
1577
+ writecb: null,
1578
+ writechunk: null,
1579
+ writeencoding: null
1580
+ };
1581
+ this._readableState.needReadable = true;
1582
+ this._readableState.sync = false;
1583
+ if (options) {
1584
+ if (typeof options.transform === "function") this._transform = options.transform;
1585
+ if (typeof options.flush === "function") this._flush = options.flush;
1586
+ }
1587
+ this.on("prefinish", prefinish);
1588
+ }
1589
+ function prefinish() {
1590
+ var _this = this;
1591
+ if (typeof this._flush === "function") this._flush(function(er, data) {
1592
+ done(_this, er, data);
1593
+ });
1594
+ else done(this, null, null);
1595
+ }
1596
+ Transform.prototype.push = function(chunk, encoding) {
1597
+ this._transformState.needTransform = false;
1598
+ return Duplex.prototype.push.call(this, chunk, encoding);
1599
+ };
1600
+ Transform.prototype._transform = function(chunk, encoding, cb) {
1601
+ throw new Error("_transform() is not implemented");
1602
+ };
1603
+ Transform.prototype._write = function(chunk, encoding, cb) {
1604
+ var ts = this._transformState;
1605
+ ts.writecb = cb;
1606
+ ts.writechunk = chunk;
1607
+ ts.writeencoding = encoding;
1608
+ if (!ts.transforming) {
1609
+ var rs = this._readableState;
1610
+ if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
1611
+ }
1612
+ };
1613
+ Transform.prototype._read = function(n) {
1614
+ var ts = this._transformState;
1615
+ if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
1616
+ ts.transforming = true;
1617
+ this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
1618
+ } else ts.needTransform = true;
1619
+ };
1620
+ Transform.prototype._destroy = function(err, cb) {
1621
+ var _this2 = this;
1622
+ Duplex.prototype._destroy.call(this, err, function(err2) {
1623
+ cb(err2);
1624
+ _this2.emit("close");
1625
+ });
1626
+ };
1627
+ function done(stream, er, data) {
1628
+ if (er) return stream.emit("error", er);
1629
+ if (data != null) stream.push(data);
1630
+ if (stream._writableState.length) throw new Error("Calling transform done when ws.length != 0");
1631
+ if (stream._transformState.transforming) throw new Error("Calling transform done when still transforming");
1632
+ return stream.push(null);
1633
+ }
1634
+ }));
1635
+ var require__stream_passthrough = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1636
+ module.exports = PassThrough;
1637
+ var Transform = require__stream_transform();
1638
+ var util = Object.create(require_util());
1639
+ util.inherits = require_inherits();
1640
+ util.inherits(PassThrough, Transform);
1641
+ function PassThrough(options) {
1642
+ if (!(this instanceof PassThrough)) return new PassThrough(options);
1643
+ Transform.call(this, options);
1644
+ }
1645
+ PassThrough.prototype._transform = function(chunk, encoding, cb) {
1646
+ cb(null, chunk);
1647
+ };
1648
+ }));
1649
+ var require_readable = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1650
+ var Stream = __require("stream");
1651
+ if (process.env.READABLE_STREAM === "disable" && Stream) {
1652
+ module.exports = Stream;
1653
+ exports = module.exports = Stream.Readable;
1654
+ exports.Readable = Stream.Readable;
1655
+ exports.Writable = Stream.Writable;
1656
+ exports.Duplex = Stream.Duplex;
1657
+ exports.Transform = Stream.Transform;
1658
+ exports.PassThrough = Stream.PassThrough;
1659
+ exports.Stream = Stream;
1660
+ } else {
1661
+ exports = module.exports = require__stream_readable();
1662
+ exports.Stream = Stream || exports;
1663
+ exports.Readable = exports;
1664
+ exports.Writable = require__stream_writable();
1665
+ exports.Duplex = require__stream_duplex();
1666
+ exports.Transform = require__stream_transform();
1667
+ exports.PassThrough = require__stream_passthrough();
1668
+ }
1669
+ }));
1670
+ var require_duplexer2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
1671
+ var stream = require_readable();
1672
+ function DuplexWrapper(options, writable, readable) {
1673
+ if (typeof readable === "undefined") {
1674
+ readable = writable;
1675
+ writable = options;
1676
+ options = null;
1677
+ }
1678
+ stream.Duplex.call(this, options);
1679
+ if (typeof readable.read !== "function") readable = new stream.Readable(options).wrap(readable);
1680
+ this._writable = writable;
1681
+ this._readable = readable;
1682
+ this._waiting = false;
1683
+ var self = this;
1684
+ writable.once("finish", function() {
1685
+ self.end();
1686
+ });
1687
+ this.once("finish", function() {
1688
+ writable.end();
1689
+ });
1690
+ readable.on("readable", function() {
1691
+ if (self._waiting) {
1692
+ self._waiting = false;
1693
+ self._read();
1694
+ }
1695
+ });
1696
+ readable.once("end", function() {
1697
+ self.push(null);
1698
+ });
1699
+ if (!options || typeof options.bubbleErrors === "undefined" || options.bubbleErrors) {
1700
+ writable.on("error", function(err) {
1701
+ self.emit("error", err);
1702
+ });
1703
+ readable.on("error", function(err) {
1704
+ self.emit("error", err);
1705
+ });
1706
+ }
1707
+ }
1708
+ DuplexWrapper.prototype = Object.create(stream.Duplex.prototype, { constructor: { value: DuplexWrapper } });
1709
+ DuplexWrapper.prototype._write = function _write(input, encoding, done) {
1710
+ this._writable.write(input, encoding, done);
1711
+ };
1712
+ DuplexWrapper.prototype._read = function _read() {
1713
+ var buf;
1714
+ var reads = 0;
1715
+ while ((buf = this._readable.read()) !== null) {
1716
+ this.push(buf);
1717
+ reads++;
1718
+ }
1719
+ if (reads === 0) this._waiting = true;
1720
+ };
1721
+ module.exports = function duplex2(options, writable, readable) {
1722
+ return new DuplexWrapper(options, writable, readable);
1723
+ };
1724
+ module.exports.DuplexWrapper = DuplexWrapper;
1725
+ }));
1726
+ export { require_readable as n, require_duplexer2 as t };