@dpuse/dpuse-tool-adaltas-csv-parser 0.0.153

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,2784 @@
1
+ //#region node_modules/csv-parse/dist/esm/index.js
2
+ var e = typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {}, t = [], n = [], r = typeof Uint8Array < "u" ? Uint8Array : Array, i = !1;
3
+ function a() {
4
+ i = !0;
5
+ for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", r = 0, a = e.length; r < a; ++r) t[r] = e[r], n[e.charCodeAt(r)] = r;
6
+ n[45] = 62, n[95] = 63;
7
+ }
8
+ function o(e) {
9
+ i || a();
10
+ var t, o, s, c, l, u, d = e.length;
11
+ if (d % 4 > 0) throw Error("Invalid string. Length must be a multiple of 4");
12
+ l = e[d - 2] === "=" ? 2 : +(e[d - 1] === "="), u = new r(d * 3 / 4 - l), s = l > 0 ? d - 4 : d;
13
+ var f = 0;
14
+ for (t = 0, o = 0; t < s; t += 4, o += 3) c = n[e.charCodeAt(t)] << 18 | n[e.charCodeAt(t + 1)] << 12 | n[e.charCodeAt(t + 2)] << 6 | n[e.charCodeAt(t + 3)], u[f++] = c >> 16 & 255, u[f++] = c >> 8 & 255, u[f++] = c & 255;
15
+ return l === 2 ? (c = n[e.charCodeAt(t)] << 2 | n[e.charCodeAt(t + 1)] >> 4, u[f++] = c & 255) : l === 1 && (c = n[e.charCodeAt(t)] << 10 | n[e.charCodeAt(t + 1)] << 4 | n[e.charCodeAt(t + 2)] >> 2, u[f++] = c >> 8 & 255, u[f++] = c & 255), u;
16
+ }
17
+ function s(e) {
18
+ return t[e >> 18 & 63] + t[e >> 12 & 63] + t[e >> 6 & 63] + t[e & 63];
19
+ }
20
+ function c(e, t, n) {
21
+ for (var r, i = [], a = t; a < n; a += 3) r = (e[a] << 16) + (e[a + 1] << 8) + e[a + 2], i.push(s(r));
22
+ return i.join("");
23
+ }
24
+ function l(e) {
25
+ i || a();
26
+ for (var n, r = e.length, o = r % 3, s = "", l = [], u = 16383, d = 0, f = r - o; d < f; d += u) l.push(c(e, d, d + u > f ? f : d + u));
27
+ return o === 1 ? (n = e[r - 1], s += t[n >> 2], s += t[n << 4 & 63], s += "==") : o === 2 && (n = (e[r - 2] << 8) + e[r - 1], s += t[n >> 10], s += t[n >> 4 & 63], s += t[n << 2 & 63], s += "="), l.push(s), l.join("");
28
+ }
29
+ function u(e, t, n, r, i) {
30
+ var a, o, s = i * 8 - r - 1, c = (1 << s) - 1, l = c >> 1, u = -7, d = n ? i - 1 : 0, f = n ? -1 : 1, p = e[t + d];
31
+ for (d += f, a = p & (1 << -u) - 1, p >>= -u, u += s; u > 0; a = a * 256 + e[t + d], d += f, u -= 8);
32
+ for (o = a & (1 << -u) - 1, a >>= -u, u += r; u > 0; o = o * 256 + e[t + d], d += f, u -= 8);
33
+ if (a === 0) a = 1 - l;
34
+ else if (a === c) return o ? NaN : (p ? -1 : 1) * Infinity;
35
+ else o += 2 ** r, a -= l;
36
+ return (p ? -1 : 1) * o * 2 ** (a - r);
37
+ }
38
+ function d(e, t, n, r, i, a) {
39
+ var o, s, c, l = a * 8 - i - 1, u = (1 << l) - 1, d = u >> 1, f = i === 23 ? 2 ** -24 - 2 ** -77 : 0, p = r ? 0 : a - 1, m = r ? 1 : -1, h = +(t < 0 || t === 0 && 1 / t < 0);
40
+ for (t = Math.abs(t), isNaN(t) || t === Infinity ? (s = +!!isNaN(t), o = u) : (o = Math.floor(Math.log(t) / Math.LN2), t * (c = 2 ** -o) < 1 && (o--, c *= 2), o + d >= 1 ? t += f / c : t += f * 2 ** (1 - d), t * c >= 2 && (o++, c /= 2), o + d >= u ? (s = 0, o = u) : o + d >= 1 ? (s = (t * c - 1) * 2 ** i, o += d) : (s = t * 2 ** (d - 1) * 2 ** i, o = 0)); i >= 8; e[n + p] = s & 255, p += m, s /= 256, i -= 8);
41
+ for (o = o << i | s, l += i; l > 0; e[n + p] = o & 255, p += m, o /= 256, l -= 8);
42
+ e[n + p - m] |= h * 128;
43
+ }
44
+ var f = {}.toString, p = Array.isArray || function(e) {
45
+ return f.call(e) == "[object Array]";
46
+ }, m = 50;
47
+ _.TYPED_ARRAY_SUPPORT = e.TYPED_ARRAY_SUPPORT === void 0 || e.TYPED_ARRAY_SUPPORT, h();
48
+ function h() {
49
+ return _.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
50
+ }
51
+ function g(e, t) {
52
+ if (h() < t) throw RangeError("Invalid typed array length");
53
+ return _.TYPED_ARRAY_SUPPORT ? (e = new Uint8Array(t), e.__proto__ = _.prototype) : (e === null && (e = new _(t)), e.length = t), e;
54
+ }
55
+ function _(e, t, n) {
56
+ if (!_.TYPED_ARRAY_SUPPORT && !(this instanceof _)) return new _(e, t, n);
57
+ if (typeof e == "number") {
58
+ if (typeof t == "string") throw Error("If encoding is specified then the first argument must be a string");
59
+ return x(this, e);
60
+ }
61
+ return v(this, e, t, n);
62
+ }
63
+ _.poolSize = 8192, _._augment = function(e) {
64
+ return e.__proto__ = _.prototype, e;
65
+ };
66
+ function v(e, t, n, r) {
67
+ if (typeof t == "number") throw TypeError("\"value\" argument must not be a number");
68
+ return typeof ArrayBuffer < "u" && t instanceof ArrayBuffer ? S(e, t, n, r) : typeof t == "string" ? ee(e, t, n) : ne(e, t);
69
+ }
70
+ _.from = function(e, t, n) {
71
+ return v(null, e, t, n);
72
+ }, _.TYPED_ARRAY_SUPPORT && (_.prototype.__proto__ = Uint8Array.prototype, _.__proto__ = Uint8Array, typeof Symbol < "u" && Symbol.species && _[Symbol.species]);
73
+ function y(e) {
74
+ if (typeof e != "number") throw TypeError("\"size\" argument must be a number");
75
+ if (e < 0) throw RangeError("\"size\" argument must not be negative");
76
+ }
77
+ function b(e, t, n, r) {
78
+ return y(t), t <= 0 || n === void 0 ? g(e, t) : typeof r == "string" ? g(e, t).fill(n, r) : g(e, t).fill(n);
79
+ }
80
+ _.alloc = function(e, t, n) {
81
+ return b(null, e, t, n);
82
+ };
83
+ function x(e, t) {
84
+ if (y(t), e = g(e, t < 0 ? 0 : re(t) | 0), !_.TYPED_ARRAY_SUPPORT) for (var n = 0; n < t; ++n) e[n] = 0;
85
+ return e;
86
+ }
87
+ _.allocUnsafe = function(e) {
88
+ return x(null, e);
89
+ }, _.allocUnsafeSlow = function(e) {
90
+ return x(null, e);
91
+ };
92
+ function ee(e, t, n) {
93
+ if ((typeof n != "string" || n === "") && (n = "utf8"), !_.isEncoding(n)) throw TypeError("\"encoding\" must be a valid string encoding");
94
+ var r = w(t, n) | 0;
95
+ e = g(e, r);
96
+ var i = e.write(t, n);
97
+ return i !== r && (e = e.slice(0, i)), e;
98
+ }
99
+ function te(e, t) {
100
+ var n = t.length < 0 ? 0 : re(t.length) | 0;
101
+ e = g(e, n);
102
+ for (var r = 0; r < n; r += 1) e[r] = t[r] & 255;
103
+ return e;
104
+ }
105
+ function S(e, t, n, r) {
106
+ if (t.byteLength, n < 0 || t.byteLength < n) throw RangeError("'offset' is out of bounds");
107
+ if (t.byteLength < n + (r || 0)) throw RangeError("'length' is out of bounds");
108
+ return t = n === void 0 && r === void 0 ? new Uint8Array(t) : r === void 0 ? new Uint8Array(t, n) : new Uint8Array(t, n, r), _.TYPED_ARRAY_SUPPORT ? (e = t, e.__proto__ = _.prototype) : e = te(e, t), e;
109
+ }
110
+ function ne(e, t) {
111
+ if (C(t)) {
112
+ var n = re(t.length) | 0;
113
+ return e = g(e, n), e.length === 0 || t.copy(e, 0, 0, n), e;
114
+ }
115
+ if (t) {
116
+ if (typeof ArrayBuffer < "u" && t.buffer instanceof ArrayBuffer || "length" in t) return typeof t.length != "number" || Fe(t.length) ? g(e, 0) : te(e, t);
117
+ if (t.type === "Buffer" && p(t.data)) return te(e, t.data);
118
+ }
119
+ throw TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
120
+ }
121
+ function re(e) {
122
+ if (e >= h()) throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + h().toString(16) + " bytes");
123
+ return e | 0;
124
+ }
125
+ _.isBuffer = O;
126
+ function C(e) {
127
+ return !!(e != null && e._isBuffer);
128
+ }
129
+ _.compare = function(e, t) {
130
+ if (!C(e) || !C(t)) throw TypeError("Arguments must be Buffers");
131
+ if (e === t) return 0;
132
+ for (var n = e.length, r = t.length, i = 0, a = Math.min(n, r); i < a; ++i) if (e[i] !== t[i]) {
133
+ n = e[i], r = t[i];
134
+ break;
135
+ }
136
+ return n < r ? -1 : +(r < n);
137
+ }, _.isEncoding = function(e) {
138
+ switch (String(e).toLowerCase()) {
139
+ case "hex":
140
+ case "utf8":
141
+ case "utf-8":
142
+ case "ascii":
143
+ case "latin1":
144
+ case "binary":
145
+ case "base64":
146
+ case "ucs2":
147
+ case "ucs-2":
148
+ case "utf16le":
149
+ case "utf-16le": return !0;
150
+ default: return !1;
151
+ }
152
+ }, _.concat = function(e, t) {
153
+ if (!p(e)) throw TypeError("\"list\" argument must be an Array of Buffers");
154
+ if (e.length === 0) return _.alloc(0);
155
+ var n;
156
+ if (t === void 0) for (t = 0, n = 0; n < e.length; ++n) t += e[n].length;
157
+ var r = _.allocUnsafe(t), i = 0;
158
+ for (n = 0; n < e.length; ++n) {
159
+ var a = e[n];
160
+ if (!C(a)) throw TypeError("\"list\" argument must be an Array of Buffers");
161
+ a.copy(r, i), i += a.length;
162
+ }
163
+ return r;
164
+ };
165
+ function w(e, t) {
166
+ if (C(e)) return e.length;
167
+ if (typeof ArrayBuffer < "u" && typeof ArrayBuffer.isView == "function" && (ArrayBuffer.isView(e) || e instanceof ArrayBuffer)) return e.byteLength;
168
+ typeof e != "string" && (e = "" + e);
169
+ var n = e.length;
170
+ if (n === 0) return 0;
171
+ for (var r = !1;;) switch (t) {
172
+ case "ascii":
173
+ case "latin1":
174
+ case "binary": return n;
175
+ case "utf8":
176
+ case "utf-8":
177
+ case void 0: return Ae(e).length;
178
+ case "ucs2":
179
+ case "ucs-2":
180
+ case "utf16le":
181
+ case "utf-16le": return n * 2;
182
+ case "hex": return n >>> 1;
183
+ case "base64": return Ne(e).length;
184
+ default:
185
+ if (r) return Ae(e).length;
186
+ t = ("" + t).toLowerCase(), r = !0;
187
+ }
188
+ }
189
+ _.byteLength = w;
190
+ function ie(e, t, n) {
191
+ var r = !1;
192
+ if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((n === void 0 || n > this.length) && (n = this.length), n <= 0) || (n >>>= 0, t >>>= 0, n <= t)) return "";
193
+ for (e ||= "utf8";;) switch (e) {
194
+ case "hex": return ye(this, t, n);
195
+ case "utf8":
196
+ case "utf-8": return me(this, t, n);
197
+ case "ascii": return _e(this, t, n);
198
+ case "latin1":
199
+ case "binary": return ve(this, t, n);
200
+ case "base64": return pe(this, t, n);
201
+ case "ucs2":
202
+ case "ucs-2":
203
+ case "utf16le":
204
+ case "utf-16le": return be(this, t, n);
205
+ default:
206
+ if (r) throw TypeError("Unknown encoding: " + e);
207
+ e = (e + "").toLowerCase(), r = !0;
208
+ }
209
+ }
210
+ _.prototype._isBuffer = !0;
211
+ function T(e, t, n) {
212
+ var r = e[t];
213
+ e[t] = e[n], e[n] = r;
214
+ }
215
+ _.prototype.swap16 = function() {
216
+ var e = this.length;
217
+ if (e % 2 != 0) throw RangeError("Buffer size must be a multiple of 16-bits");
218
+ for (var t = 0; t < e; t += 2) T(this, t, t + 1);
219
+ return this;
220
+ }, _.prototype.swap32 = function() {
221
+ var e = this.length;
222
+ if (e % 4 != 0) throw RangeError("Buffer size must be a multiple of 32-bits");
223
+ for (var t = 0; t < e; t += 4) T(this, t, t + 3), T(this, t + 1, t + 2);
224
+ return this;
225
+ }, _.prototype.swap64 = function() {
226
+ var e = this.length;
227
+ if (e % 8 != 0) throw RangeError("Buffer size must be a multiple of 64-bits");
228
+ for (var t = 0; t < e; t += 8) T(this, t, t + 7), T(this, t + 1, t + 6), T(this, t + 2, t + 5), T(this, t + 3, t + 4);
229
+ return this;
230
+ }, _.prototype.toString = function() {
231
+ var e = this.length | 0;
232
+ return e === 0 ? "" : arguments.length === 0 ? me(this, 0, e) : ie.apply(this, arguments);
233
+ }, _.prototype.equals = function(e) {
234
+ if (!C(e)) throw TypeError("Argument must be a Buffer");
235
+ return this === e || _.compare(this, e) === 0;
236
+ }, _.prototype.inspect = function() {
237
+ var e = "", t = m;
238
+ return this.length > 0 && (e = this.toString("hex", 0, t).match(/.{2}/g).join(" "), this.length > t && (e += " ... ")), "<Buffer " + e + ">";
239
+ }, _.prototype.compare = function(e, t, n, r, i) {
240
+ if (!C(e)) throw TypeError("Argument must be a Buffer");
241
+ if (t === void 0 && (t = 0), n === void 0 && (n = e ? e.length : 0), r === void 0 && (r = 0), i === void 0 && (i = this.length), t < 0 || n > e.length || r < 0 || i > this.length) throw RangeError("out of range index");
242
+ if (r >= i && t >= n) return 0;
243
+ if (r >= i) return -1;
244
+ if (t >= n) return 1;
245
+ if (t >>>= 0, n >>>= 0, r >>>= 0, i >>>= 0, this === e) return 0;
246
+ for (var a = i - r, o = n - t, s = Math.min(a, o), c = this.slice(r, i), l = e.slice(t, n), u = 0; u < s; ++u) if (c[u] !== l[u]) {
247
+ a = c[u], o = l[u];
248
+ break;
249
+ }
250
+ return a < o ? -1 : +(o < a);
251
+ };
252
+ function ae(e, t, n, r, i) {
253
+ if (e.length === 0) return -1;
254
+ if (typeof n == "string" ? (r = n, n = 0) : n > 2147483647 ? n = 2147483647 : n < -2147483648 && (n = -2147483648), n = +n, isNaN(n) && (n = i ? 0 : e.length - 1), n < 0 && (n = e.length + n), n >= e.length) {
255
+ if (i) return -1;
256
+ n = e.length - 1;
257
+ } else if (n < 0) if (i) n = 0;
258
+ else return -1;
259
+ if (typeof t == "string" && (t = _.from(t, r)), C(t)) return t.length === 0 ? -1 : oe(e, t, n, r, i);
260
+ if (typeof t == "number") return t &= 255, _.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf == "function" ? i ? Uint8Array.prototype.indexOf.call(e, t, n) : Uint8Array.prototype.lastIndexOf.call(e, t, n) : oe(e, [t], n, r, i);
261
+ throw TypeError("val must be string, number or Buffer");
262
+ }
263
+ function oe(e, t, n, r, i) {
264
+ var a = 1, o = e.length, s = t.length;
265
+ if (r !== void 0 && (r = String(r).toLowerCase(), r === "ucs2" || r === "ucs-2" || r === "utf16le" || r === "utf-16le")) {
266
+ if (e.length < 2 || t.length < 2) return -1;
267
+ a = 2, o /= 2, s /= 2, n /= 2;
268
+ }
269
+ function c(e, t) {
270
+ return a === 1 ? e[t] : e.readUInt16BE(t * a);
271
+ }
272
+ var l;
273
+ if (i) {
274
+ var u = -1;
275
+ for (l = n; l < o; l++) if (c(e, l) === c(t, u === -1 ? 0 : l - u)) {
276
+ if (u === -1 && (u = l), l - u + 1 === s) return u * a;
277
+ } else u !== -1 && (l -= l - u), u = -1;
278
+ } else for (n + s > o && (n = o - s), l = n; l >= 0; l--) {
279
+ for (var d = !0, f = 0; f < s; f++) if (c(e, l + f) !== c(t, f)) {
280
+ d = !1;
281
+ break;
282
+ }
283
+ if (d) return l;
284
+ }
285
+ return -1;
286
+ }
287
+ _.prototype.includes = function(e, t, n) {
288
+ return this.indexOf(e, t, n) !== -1;
289
+ }, _.prototype.indexOf = function(e, t, n) {
290
+ return ae(this, e, t, n, !0);
291
+ }, _.prototype.lastIndexOf = function(e, t, n) {
292
+ return ae(this, e, t, n, !1);
293
+ };
294
+ function se(e, t, n, r) {
295
+ n = Number(n) || 0;
296
+ var i = e.length - n;
297
+ r ? (r = Number(r), r > i && (r = i)) : r = i;
298
+ var a = t.length;
299
+ if (a % 2 != 0) throw TypeError("Invalid hex string");
300
+ r > a / 2 && (r = a / 2);
301
+ for (var o = 0; o < r; ++o) {
302
+ var s = parseInt(t.substr(o * 2, 2), 16);
303
+ if (isNaN(s)) return o;
304
+ e[n + o] = s;
305
+ }
306
+ return o;
307
+ }
308
+ function ce(e, t, n, r) {
309
+ return Pe(Ae(t, e.length - n), e, n, r);
310
+ }
311
+ function le(e, t, n, r) {
312
+ return Pe(je(t), e, n, r);
313
+ }
314
+ function ue(e, t, n, r) {
315
+ return le(e, t, n, r);
316
+ }
317
+ function de(e, t, n, r) {
318
+ return Pe(Ne(t), e, n, r);
319
+ }
320
+ function fe(e, t, n, r) {
321
+ return Pe(Me(t, e.length - n), e, n, r);
322
+ }
323
+ _.prototype.write = function(e, t, n, r) {
324
+ if (t === void 0) r = "utf8", n = this.length, t = 0;
325
+ else if (n === void 0 && typeof t == "string") r = t, n = this.length, t = 0;
326
+ else if (isFinite(t)) t |= 0, isFinite(n) ? (n |= 0, r === void 0 && (r = "utf8")) : (r = n, n = void 0);
327
+ else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");
328
+ var i = this.length - t;
329
+ if ((n === void 0 || n > i) && (n = i), e.length > 0 && (n < 0 || t < 0) || t > this.length) throw RangeError("Attempt to write outside buffer bounds");
330
+ r ||= "utf8";
331
+ for (var a = !1;;) switch (r) {
332
+ case "hex": return se(this, e, t, n);
333
+ case "utf8":
334
+ case "utf-8": return ce(this, e, t, n);
335
+ case "ascii": return le(this, e, t, n);
336
+ case "latin1":
337
+ case "binary": return ue(this, e, t, n);
338
+ case "base64": return de(this, e, t, n);
339
+ case "ucs2":
340
+ case "ucs-2":
341
+ case "utf16le":
342
+ case "utf-16le": return fe(this, e, t, n);
343
+ default:
344
+ if (a) throw TypeError("Unknown encoding: " + r);
345
+ r = ("" + r).toLowerCase(), a = !0;
346
+ }
347
+ }, _.prototype.toJSON = function() {
348
+ return {
349
+ type: "Buffer",
350
+ data: Array.prototype.slice.call(this._arr || this, 0)
351
+ };
352
+ };
353
+ function pe(e, t, n) {
354
+ return t === 0 && n === e.length ? l(e) : l(e.slice(t, n));
355
+ }
356
+ function me(e, t, n) {
357
+ n = Math.min(e.length, n);
358
+ for (var r = [], i = t; i < n;) {
359
+ var a = e[i], o = null, s = a > 239 ? 4 : a > 223 ? 3 : a > 191 ? 2 : 1;
360
+ if (i + s <= n) {
361
+ var c, l, u, d;
362
+ switch (s) {
363
+ case 1:
364
+ a < 128 && (o = a);
365
+ break;
366
+ case 2:
367
+ c = e[i + 1], (c & 192) == 128 && (d = (a & 31) << 6 | c & 63, d > 127 && (o = d));
368
+ break;
369
+ case 3:
370
+ c = e[i + 1], l = e[i + 2], (c & 192) == 128 && (l & 192) == 128 && (d = (a & 15) << 12 | (c & 63) << 6 | l & 63, d > 2047 && (d < 55296 || d > 57343) && (o = d));
371
+ break;
372
+ case 4: c = e[i + 1], l = e[i + 2], u = e[i + 3], (c & 192) == 128 && (l & 192) == 128 && (u & 192) == 128 && (d = (a & 15) << 18 | (c & 63) << 12 | (l & 63) << 6 | u & 63, d > 65535 && d < 1114112 && (o = d));
373
+ }
374
+ }
375
+ o === null ? (o = 65533, s = 1) : o > 65535 && (o -= 65536, r.push(o >>> 10 & 1023 | 55296), o = 56320 | o & 1023), r.push(o), i += s;
376
+ }
377
+ return ge(r);
378
+ }
379
+ var he = 4096;
380
+ function ge(e) {
381
+ var t = e.length;
382
+ if (t <= he) return String.fromCharCode.apply(String, e);
383
+ for (var n = "", r = 0; r < t;) n += String.fromCharCode.apply(String, e.slice(r, r += he));
384
+ return n;
385
+ }
386
+ function _e(e, t, n) {
387
+ var r = "";
388
+ n = Math.min(e.length, n);
389
+ for (var i = t; i < n; ++i) r += String.fromCharCode(e[i] & 127);
390
+ return r;
391
+ }
392
+ function ve(e, t, n) {
393
+ var r = "";
394
+ n = Math.min(e.length, n);
395
+ for (var i = t; i < n; ++i) r += String.fromCharCode(e[i]);
396
+ return r;
397
+ }
398
+ function ye(e, t, n) {
399
+ var r = e.length;
400
+ (!t || t < 0) && (t = 0), (!n || n < 0 || n > r) && (n = r);
401
+ for (var i = "", a = t; a < n; ++a) i += ke(e[a]);
402
+ return i;
403
+ }
404
+ function be(e, t, n) {
405
+ for (var r = e.slice(t, n), i = "", a = 0; a < r.length; a += 2) i += String.fromCharCode(r[a] + r[a + 1] * 256);
406
+ return i;
407
+ }
408
+ _.prototype.slice = function(e, t) {
409
+ var n = this.length;
410
+ e = ~~e, t = t === void 0 ? n : ~~t, e < 0 ? (e += n, e < 0 && (e = 0)) : e > n && (e = n), t < 0 ? (t += n, t < 0 && (t = 0)) : t > n && (t = n), t < e && (t = e);
411
+ var r;
412
+ if (_.TYPED_ARRAY_SUPPORT) r = this.subarray(e, t), r.__proto__ = _.prototype;
413
+ else {
414
+ var i = t - e;
415
+ r = new _(i, void 0);
416
+ for (var a = 0; a < i; ++a) r[a] = this[a + e];
417
+ }
418
+ return r;
419
+ };
420
+ function E(e, t, n) {
421
+ if (e % 1 != 0 || e < 0) throw RangeError("offset is not uint");
422
+ if (e + t > n) throw RangeError("Trying to access beyond buffer length");
423
+ }
424
+ _.prototype.readUIntLE = function(e, t, n) {
425
+ e |= 0, t |= 0, n || E(e, t, this.length);
426
+ for (var r = this[e], i = 1, a = 0; ++a < t && (i *= 256);) r += this[e + a] * i;
427
+ return r;
428
+ }, _.prototype.readUIntBE = function(e, t, n) {
429
+ e |= 0, t |= 0, n || E(e, t, this.length);
430
+ for (var r = this[e + --t], i = 1; t > 0 && (i *= 256);) r += this[e + --t] * i;
431
+ return r;
432
+ }, _.prototype.readUInt8 = function(e, t) {
433
+ return t || E(e, 1, this.length), this[e];
434
+ }, _.prototype.readUInt16LE = function(e, t) {
435
+ return t || E(e, 2, this.length), this[e] | this[e + 1] << 8;
436
+ }, _.prototype.readUInt16BE = function(e, t) {
437
+ return t || E(e, 2, this.length), this[e] << 8 | this[e + 1];
438
+ }, _.prototype.readUInt32LE = function(e, t) {
439
+ return t || E(e, 4, this.length), (this[e] | this[e + 1] << 8 | this[e + 2] << 16) + this[e + 3] * 16777216;
440
+ }, _.prototype.readUInt32BE = function(e, t) {
441
+ return t || E(e, 4, this.length), this[e] * 16777216 + (this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3]);
442
+ }, _.prototype.readIntLE = function(e, t, n) {
443
+ e |= 0, t |= 0, n || E(e, t, this.length);
444
+ for (var r = this[e], i = 1, a = 0; ++a < t && (i *= 256);) r += this[e + a] * i;
445
+ return i *= 128, r >= i && (r -= 2 ** (8 * t)), r;
446
+ }, _.prototype.readIntBE = function(e, t, n) {
447
+ e |= 0, t |= 0, n || E(e, t, this.length);
448
+ for (var r = t, i = 1, a = this[e + --r]; r > 0 && (i *= 256);) a += this[e + --r] * i;
449
+ return i *= 128, a >= i && (a -= 2 ** (8 * t)), a;
450
+ }, _.prototype.readInt8 = function(e, t) {
451
+ return t || E(e, 1, this.length), this[e] & 128 ? (255 - this[e] + 1) * -1 : this[e];
452
+ }, _.prototype.readInt16LE = function(e, t) {
453
+ t || E(e, 2, this.length);
454
+ var n = this[e] | this[e + 1] << 8;
455
+ return n & 32768 ? n | 4294901760 : n;
456
+ }, _.prototype.readInt16BE = function(e, t) {
457
+ t || E(e, 2, this.length);
458
+ var n = this[e + 1] | this[e] << 8;
459
+ return n & 32768 ? n | 4294901760 : n;
460
+ }, _.prototype.readInt32LE = function(e, t) {
461
+ return t || E(e, 4, this.length), this[e] | this[e + 1] << 8 | this[e + 2] << 16 | this[e + 3] << 24;
462
+ }, _.prototype.readInt32BE = function(e, t) {
463
+ return t || E(e, 4, this.length), this[e] << 24 | this[e + 1] << 16 | this[e + 2] << 8 | this[e + 3];
464
+ }, _.prototype.readFloatLE = function(e, t) {
465
+ return t || E(e, 4, this.length), u(this, e, !0, 23, 4);
466
+ }, _.prototype.readFloatBE = function(e, t) {
467
+ return t || E(e, 4, this.length), u(this, e, !1, 23, 4);
468
+ }, _.prototype.readDoubleLE = function(e, t) {
469
+ return t || E(e, 8, this.length), u(this, e, !0, 52, 8);
470
+ }, _.prototype.readDoubleBE = function(e, t) {
471
+ return t || E(e, 8, this.length), u(this, e, !1, 52, 8);
472
+ };
473
+ function D(e, t, n, r, i, a) {
474
+ if (!C(e)) throw TypeError("\"buffer\" argument must be a Buffer instance");
475
+ if (t > i || t < a) throw RangeError("\"value\" argument is out of bounds");
476
+ if (n + r > e.length) throw RangeError("Index out of range");
477
+ }
478
+ _.prototype.writeUIntLE = function(e, t, n, r) {
479
+ if (e = +e, t |= 0, n |= 0, !r) {
480
+ var i = 2 ** (8 * n) - 1;
481
+ D(this, e, t, n, i, 0);
482
+ }
483
+ var a = 1, o = 0;
484
+ for (this[t] = e & 255; ++o < n && (a *= 256);) this[t + o] = e / a & 255;
485
+ return t + n;
486
+ }, _.prototype.writeUIntBE = function(e, t, n, r) {
487
+ if (e = +e, t |= 0, n |= 0, !r) {
488
+ var i = 2 ** (8 * n) - 1;
489
+ D(this, e, t, n, i, 0);
490
+ }
491
+ var a = n - 1, o = 1;
492
+ for (this[t + a] = e & 255; --a >= 0 && (o *= 256);) this[t + a] = e / o & 255;
493
+ return t + n;
494
+ }, _.prototype.writeUInt8 = function(e, t, n) {
495
+ return e = +e, t |= 0, n || D(this, e, t, 1, 255, 0), _.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), this[t] = e & 255, t + 1;
496
+ };
497
+ function xe(e, t, n, r) {
498
+ t < 0 && (t = 65535 + t + 1);
499
+ for (var i = 0, a = Math.min(e.length - n, 2); i < a; ++i) e[n + i] = (t & 255 << 8 * (r ? i : 1 - i)) >>> (r ? i : 1 - i) * 8;
500
+ }
501
+ _.prototype.writeUInt16LE = function(e, t, n) {
502
+ return e = +e, t |= 0, n || D(this, e, t, 2, 65535, 0), _.TYPED_ARRAY_SUPPORT ? (this[t] = e & 255, this[t + 1] = e >>> 8) : xe(this, e, t, !0), t + 2;
503
+ }, _.prototype.writeUInt16BE = function(e, t, n) {
504
+ return e = +e, t |= 0, n || D(this, e, t, 2, 65535, 0), _.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = e & 255) : xe(this, e, t, !1), t + 2;
505
+ };
506
+ function Se(e, t, n, r) {
507
+ t < 0 && (t = 4294967295 + t + 1);
508
+ for (var i = 0, a = Math.min(e.length - n, 4); i < a; ++i) e[n + i] = t >>> (r ? i : 3 - i) * 8 & 255;
509
+ }
510
+ _.prototype.writeUInt32LE = function(e, t, n) {
511
+ return e = +e, t |= 0, n || D(this, e, t, 4, 4294967295, 0), _.TYPED_ARRAY_SUPPORT ? (this[t + 3] = e >>> 24, this[t + 2] = e >>> 16, this[t + 1] = e >>> 8, this[t] = e & 255) : Se(this, e, t, !0), t + 4;
512
+ }, _.prototype.writeUInt32BE = function(e, t, n) {
513
+ return e = +e, t |= 0, n || D(this, e, t, 4, 4294967295, 0), _.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255) : Se(this, e, t, !1), t + 4;
514
+ }, _.prototype.writeIntLE = function(e, t, n, r) {
515
+ if (e = +e, t |= 0, !r) {
516
+ var i = 2 ** (8 * n - 1);
517
+ D(this, e, t, n, i - 1, -i);
518
+ }
519
+ var a = 0, o = 1, s = 0;
520
+ for (this[t] = e & 255; ++a < n && (o *= 256);) e < 0 && s === 0 && this[t + a - 1] !== 0 && (s = 1), this[t + a] = (e / o >> 0) - s & 255;
521
+ return t + n;
522
+ }, _.prototype.writeIntBE = function(e, t, n, r) {
523
+ if (e = +e, t |= 0, !r) {
524
+ var i = 2 ** (8 * n - 1);
525
+ D(this, e, t, n, i - 1, -i);
526
+ }
527
+ var a = n - 1, o = 1, s = 0;
528
+ for (this[t + a] = e & 255; --a >= 0 && (o *= 256);) e < 0 && s === 0 && this[t + a + 1] !== 0 && (s = 1), this[t + a] = (e / o >> 0) - s & 255;
529
+ return t + n;
530
+ }, _.prototype.writeInt8 = function(e, t, n) {
531
+ return e = +e, t |= 0, n || D(this, e, t, 1, 127, -128), _.TYPED_ARRAY_SUPPORT || (e = Math.floor(e)), e < 0 && (e = 255 + e + 1), this[t] = e & 255, t + 1;
532
+ }, _.prototype.writeInt16LE = function(e, t, n) {
533
+ return e = +e, t |= 0, n || D(this, e, t, 2, 32767, -32768), _.TYPED_ARRAY_SUPPORT ? (this[t] = e & 255, this[t + 1] = e >>> 8) : xe(this, e, t, !0), t + 2;
534
+ }, _.prototype.writeInt16BE = function(e, t, n) {
535
+ return e = +e, t |= 0, n || D(this, e, t, 2, 32767, -32768), _.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 8, this[t + 1] = e & 255) : xe(this, e, t, !1), t + 2;
536
+ }, _.prototype.writeInt32LE = function(e, t, n) {
537
+ return e = +e, t |= 0, n || D(this, e, t, 4, 2147483647, -2147483648), _.TYPED_ARRAY_SUPPORT ? (this[t] = e & 255, this[t + 1] = e >>> 8, this[t + 2] = e >>> 16, this[t + 3] = e >>> 24) : Se(this, e, t, !0), t + 4;
538
+ }, _.prototype.writeInt32BE = function(e, t, n) {
539
+ return e = +e, t |= 0, n || D(this, e, t, 4, 2147483647, -2147483648), e < 0 && (e = 4294967295 + e + 1), _.TYPED_ARRAY_SUPPORT ? (this[t] = e >>> 24, this[t + 1] = e >>> 16, this[t + 2] = e >>> 8, this[t + 3] = e & 255) : Se(this, e, t, !1), t + 4;
540
+ };
541
+ function Ce(e, t, n, r, i, a) {
542
+ if (n + r > e.length || n < 0) throw RangeError("Index out of range");
543
+ }
544
+ function we(e, t, n, r, i) {
545
+ return i || Ce(e, t, n, 4), d(e, t, n, r, 23, 4), n + 4;
546
+ }
547
+ _.prototype.writeFloatLE = function(e, t, n) {
548
+ return we(this, e, t, !0, n);
549
+ }, _.prototype.writeFloatBE = function(e, t, n) {
550
+ return we(this, e, t, !1, n);
551
+ };
552
+ function Te(e, t, n, r, i) {
553
+ return i || Ce(e, t, n, 8), d(e, t, n, r, 52, 8), n + 8;
554
+ }
555
+ _.prototype.writeDoubleLE = function(e, t, n) {
556
+ return Te(this, e, t, !0, n);
557
+ }, _.prototype.writeDoubleBE = function(e, t, n) {
558
+ return Te(this, e, t, !1, n);
559
+ }, _.prototype.copy = function(e, t, n, r) {
560
+ if (n ||= 0, !r && r !== 0 && (r = this.length), t >= e.length && (t = e.length), t ||= 0, r > 0 && r < n && (r = n), r === n || e.length === 0 || this.length === 0) return 0;
561
+ if (t < 0) throw RangeError("targetStart out of bounds");
562
+ if (n < 0 || n >= this.length) throw RangeError("sourceStart out of bounds");
563
+ if (r < 0) throw RangeError("sourceEnd out of bounds");
564
+ r > this.length && (r = this.length), e.length - t < r - n && (r = e.length - t + n);
565
+ var i = r - n, a;
566
+ if (this === e && n < t && t < r) for (a = i - 1; a >= 0; --a) e[a + t] = this[a + n];
567
+ else if (i < 1e3 || !_.TYPED_ARRAY_SUPPORT) for (a = 0; a < i; ++a) e[a + t] = this[a + n];
568
+ else Uint8Array.prototype.set.call(e, this.subarray(n, n + i), t);
569
+ return i;
570
+ }, _.prototype.fill = function(e, t, n, r) {
571
+ if (typeof e == "string") {
572
+ if (typeof t == "string" ? (r = t, t = 0, n = this.length) : typeof n == "string" && (r = n, n = this.length), e.length === 1) {
573
+ var i = e.charCodeAt(0);
574
+ i < 256 && (e = i);
575
+ }
576
+ if (r !== void 0 && typeof r != "string") throw TypeError("encoding must be a string");
577
+ if (typeof r == "string" && !_.isEncoding(r)) throw TypeError("Unknown encoding: " + r);
578
+ } else typeof e == "number" && (e &= 255);
579
+ if (t < 0 || this.length < t || this.length < n) throw RangeError("Out of range index");
580
+ if (n <= t) return this;
581
+ t >>>= 0, n = n === void 0 ? this.length : n >>> 0, e ||= 0;
582
+ var a;
583
+ if (typeof e == "number") for (a = t; a < n; ++a) this[a] = e;
584
+ else {
585
+ var o = C(e) ? e : Ae(new _(e, r).toString()), s = o.length;
586
+ for (a = 0; a < n - t; ++a) this[a + t] = o[a % s];
587
+ }
588
+ return this;
589
+ };
590
+ var Ee = /[^+\/0-9A-Za-z-_]/g;
591
+ function De(e) {
592
+ if (e = Oe(e).replace(Ee, ""), e.length < 2) return "";
593
+ for (; e.length % 4 != 0;) e += "=";
594
+ return e;
595
+ }
596
+ function Oe(e) {
597
+ return e.trim ? e.trim() : e.replace(/^\s+|\s+$/g, "");
598
+ }
599
+ function ke(e) {
600
+ return e < 16 ? "0" + e.toString(16) : e.toString(16);
601
+ }
602
+ function Ae(e, t) {
603
+ t ||= Infinity;
604
+ for (var n, r = e.length, i = null, a = [], o = 0; o < r; ++o) {
605
+ if (n = e.charCodeAt(o), n > 55295 && n < 57344) {
606
+ if (!i) {
607
+ if (n > 56319) {
608
+ (t -= 3) > -1 && a.push(239, 191, 189);
609
+ continue;
610
+ }
611
+ if (o + 1 === r) {
612
+ (t -= 3) > -1 && a.push(239, 191, 189);
613
+ continue;
614
+ }
615
+ i = n;
616
+ continue;
617
+ }
618
+ if (n < 56320) {
619
+ (t -= 3) > -1 && a.push(239, 191, 189), i = n;
620
+ continue;
621
+ }
622
+ n = (i - 55296 << 10 | n - 56320) + 65536;
623
+ } else i && (t -= 3) > -1 && a.push(239, 191, 189);
624
+ if (i = null, n < 128) {
625
+ if (--t < 0) break;
626
+ a.push(n);
627
+ } else if (n < 2048) {
628
+ if ((t -= 2) < 0) break;
629
+ a.push(n >> 6 | 192, n & 63 | 128);
630
+ } else if (n < 65536) {
631
+ if ((t -= 3) < 0) break;
632
+ a.push(n >> 12 | 224, n >> 6 & 63 | 128, n & 63 | 128);
633
+ } else if (n < 1114112) {
634
+ if ((t -= 4) < 0) break;
635
+ a.push(n >> 18 | 240, n >> 12 & 63 | 128, n >> 6 & 63 | 128, n & 63 | 128);
636
+ } else throw Error("Invalid code point");
637
+ }
638
+ return a;
639
+ }
640
+ function je(e) {
641
+ for (var t = [], n = 0; n < e.length; ++n) t.push(e.charCodeAt(n) & 255);
642
+ return t;
643
+ }
644
+ function Me(e, t) {
645
+ for (var n, r, i, a = [], o = 0; o < e.length && !((t -= 2) < 0); ++o) n = e.charCodeAt(o), r = n >> 8, i = n % 256, a.push(i), a.push(r);
646
+ return a;
647
+ }
648
+ function Ne(e) {
649
+ return o(De(e));
650
+ }
651
+ function Pe(e, t, n, r) {
652
+ for (var i = 0; i < r && !(i + n >= t.length || i >= e.length); ++i) t[i + n] = e[i];
653
+ return i;
654
+ }
655
+ function Fe(e) {
656
+ return e !== e;
657
+ }
658
+ function O(e) {
659
+ return e != null && (!!e._isBuffer || Ie(e) || Le(e));
660
+ }
661
+ function Ie(e) {
662
+ return !!e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
663
+ }
664
+ function Le(e) {
665
+ return typeof e.readFloatLE == "function" && typeof e.slice == "function" && Ie(e.slice(0, 0));
666
+ }
667
+ var Re;
668
+ function k() {}
669
+ k.prototype = Object.create(null);
670
+ function A() {
671
+ A.init.call(this);
672
+ }
673
+ A.EventEmitter = A, A.usingDomains = !1, A.prototype.domain = void 0, A.prototype._events = void 0, A.prototype._maxListeners = void 0, A.defaultMaxListeners = 10, A.init = function() {
674
+ this.domain = null, A.usingDomains && Re.active && !(this instanceof Re.Domain) && (this.domain = Re.active), (!this._events || this._events === Object.getPrototypeOf(this)._events) && (this._events = new k(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
675
+ }, A.prototype.setMaxListeners = function(e) {
676
+ if (typeof e != "number" || e < 0 || isNaN(e)) throw TypeError("\"n\" argument must be a positive number");
677
+ return this._maxListeners = e, this;
678
+ };
679
+ function ze(e) {
680
+ return e._maxListeners === void 0 ? A.defaultMaxListeners : e._maxListeners;
681
+ }
682
+ A.prototype.getMaxListeners = function() {
683
+ return ze(this);
684
+ };
685
+ function Be(e, t, n) {
686
+ if (t) e.call(n);
687
+ else for (var r = e.length, i = j(e, r), a = 0; a < r; ++a) i[a].call(n);
688
+ }
689
+ function Ve(e, t, n, r) {
690
+ if (t) e.call(n, r);
691
+ else for (var i = e.length, a = j(e, i), o = 0; o < i; ++o) a[o].call(n, r);
692
+ }
693
+ function He(e, t, n, r, i) {
694
+ if (t) e.call(n, r, i);
695
+ else for (var a = e.length, o = j(e, a), s = 0; s < a; ++s) o[s].call(n, r, i);
696
+ }
697
+ function Ue(e, t, n, r, i, a) {
698
+ if (t) e.call(n, r, i, a);
699
+ else for (var o = e.length, s = j(e, o), c = 0; c < o; ++c) s[c].call(n, r, i, a);
700
+ }
701
+ function We(e, t, n, r) {
702
+ if (t) e.apply(n, r);
703
+ else for (var i = e.length, a = j(e, i), o = 0; o < i; ++o) a[o].apply(n, r);
704
+ }
705
+ A.prototype.emit = function(e) {
706
+ var t, n, r, i, a, o, s, c = e === "error";
707
+ if (o = this._events, o) c &&= o.error == null;
708
+ else if (!c) return !1;
709
+ if (s = this.domain, c) {
710
+ if (t = arguments[1], s) t ||= /* @__PURE__ */ Error("Uncaught, unspecified \"error\" event"), t.domainEmitter = this, t.domain = s, t.domainThrown = !1, s.emit("error", t);
711
+ else if (t instanceof Error) throw t;
712
+ else {
713
+ var l = /* @__PURE__ */ Error("Uncaught, unspecified \"error\" event. (" + t + ")");
714
+ throw l.context = t, l;
715
+ }
716
+ return !1;
717
+ }
718
+ if (n = o[e], !n) return !1;
719
+ var u = typeof n == "function";
720
+ switch (r = arguments.length, r) {
721
+ case 1:
722
+ Be(n, u, this);
723
+ break;
724
+ case 2:
725
+ Ve(n, u, this, arguments[1]);
726
+ break;
727
+ case 3:
728
+ He(n, u, this, arguments[1], arguments[2]);
729
+ break;
730
+ case 4:
731
+ Ue(n, u, this, arguments[1], arguments[2], arguments[3]);
732
+ break;
733
+ default:
734
+ for (i = Array(r - 1), a = 1; a < r; a++) i[a - 1] = arguments[a];
735
+ We(n, u, this, i);
736
+ }
737
+ return !0;
738
+ };
739
+ function Ge(e, t, n, r) {
740
+ var i, a, o;
741
+ if (typeof n != "function") throw TypeError("\"listener\" argument must be a function");
742
+ if (a = e._events, a ? (a.newListener && (e.emit("newListener", t, n.listener ? n.listener : n), a = e._events), o = a[t]) : (a = e._events = new k(), e._eventsCount = 0), !o) o = a[t] = n, ++e._eventsCount;
743
+ else if (typeof o == "function" ? o = a[t] = r ? [n, o] : [o, n] : r ? o.unshift(n) : o.push(n), !o.warned && (i = ze(e), i && i > 0 && o.length > i)) {
744
+ o.warned = !0;
745
+ var s = /* @__PURE__ */ Error("Possible EventEmitter memory leak detected. " + o.length + " " + t + " listeners added. Use emitter.setMaxListeners() to increase limit");
746
+ s.name = "MaxListenersExceededWarning", s.emitter = e, s.type = t, s.count = o.length, Ke(s);
747
+ }
748
+ return e;
749
+ }
750
+ function Ke(e) {
751
+ typeof console.warn == "function" ? console.warn(e) : console.log(e);
752
+ }
753
+ A.prototype.addListener = function(e, t) {
754
+ return Ge(this, e, t, !1);
755
+ }, A.prototype.on = A.prototype.addListener, A.prototype.prependListener = function(e, t) {
756
+ return Ge(this, e, t, !0);
757
+ };
758
+ function qe(e, t, n) {
759
+ var r = !1;
760
+ function i() {
761
+ e.removeListener(t, i), r || (r = !0, n.apply(e, arguments));
762
+ }
763
+ return i.listener = n, i;
764
+ }
765
+ A.prototype.once = function(e, t) {
766
+ if (typeof t != "function") throw TypeError("\"listener\" argument must be a function");
767
+ return this.on(e, qe(this, e, t)), this;
768
+ }, A.prototype.prependOnceListener = function(e, t) {
769
+ if (typeof t != "function") throw TypeError("\"listener\" argument must be a function");
770
+ return this.prependListener(e, qe(this, e, t)), this;
771
+ }, A.prototype.removeListener = function(e, t) {
772
+ var n, r, i, a, o;
773
+ if (typeof t != "function") throw TypeError("\"listener\" argument must be a function");
774
+ if (r = this._events, !r || (n = r[e], !n)) return this;
775
+ if (n === t || n.listener && n.listener === t) --this._eventsCount === 0 ? this._events = new k() : (delete r[e], r.removeListener && this.emit("removeListener", e, n.listener || t));
776
+ else if (typeof n != "function") {
777
+ for (i = -1, a = n.length; a-- > 0;) if (n[a] === t || n[a].listener && n[a].listener === t) {
778
+ o = n[a].listener, i = a;
779
+ break;
780
+ }
781
+ if (i < 0) return this;
782
+ if (n.length === 1) {
783
+ if (n[0] = void 0, --this._eventsCount === 0) return this._events = new k(), this;
784
+ delete r[e];
785
+ } else Ye(n, i);
786
+ r.removeListener && this.emit("removeListener", e, o || t);
787
+ }
788
+ return this;
789
+ }, A.prototype.removeAllListeners = function(e) {
790
+ var t, n = this._events;
791
+ if (!n) return this;
792
+ if (!n.removeListener) return arguments.length === 0 ? (this._events = new k(), this._eventsCount = 0) : n[e] && (--this._eventsCount === 0 ? this._events = new k() : delete n[e]), this;
793
+ if (arguments.length === 0) {
794
+ for (var r = Object.keys(n), i = 0, a; i < r.length; ++i) a = r[i], a !== "removeListener" && this.removeAllListeners(a);
795
+ return this.removeAllListeners("removeListener"), this._events = new k(), this._eventsCount = 0, this;
796
+ }
797
+ if (t = n[e], typeof t == "function") this.removeListener(e, t);
798
+ else if (t) do
799
+ this.removeListener(e, t[t.length - 1]);
800
+ while (t[0]);
801
+ return this;
802
+ }, A.prototype.listeners = function(e) {
803
+ var t, n, r = this._events;
804
+ return r ? (t = r[e], n = t ? typeof t == "function" ? [t.listener || t] : Xe(t) : []) : n = [], n;
805
+ }, A.listenerCount = function(e, t) {
806
+ return typeof e.listenerCount == "function" ? e.listenerCount(t) : Je.call(e, t);
807
+ }, A.prototype.listenerCount = Je;
808
+ function Je(e) {
809
+ var t = this._events;
810
+ if (t) {
811
+ var n = t[e];
812
+ if (typeof n == "function") return 1;
813
+ if (n) return n.length;
814
+ }
815
+ return 0;
816
+ }
817
+ A.prototype.eventNames = function() {
818
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
819
+ };
820
+ function Ye(e, t) {
821
+ for (var n = t, r = n + 1, i = e.length; r < i; n += 1, r += 1) e[n] = e[r];
822
+ e.pop();
823
+ }
824
+ function j(e, t) {
825
+ for (var n = Array(t); t--;) n[t] = e[t];
826
+ return n;
827
+ }
828
+ function Xe(e) {
829
+ for (var t = Array(e.length), n = 0; n < t.length; ++n) t[n] = e[n].listener || e[n];
830
+ return t;
831
+ }
832
+ function Ze() {
833
+ throw Error("setTimeout has not been defined");
834
+ }
835
+ function Qe() {
836
+ throw Error("clearTimeout has not been defined");
837
+ }
838
+ var M = Ze, N = Qe;
839
+ typeof e.setTimeout == "function" && (M = setTimeout), typeof e.clearTimeout == "function" && (N = clearTimeout);
840
+ function $e(e) {
841
+ if (M === setTimeout) return setTimeout(e, 0);
842
+ if ((M === Ze || !M) && setTimeout) return M = setTimeout, setTimeout(e, 0);
843
+ try {
844
+ return M(e, 0);
845
+ } catch {
846
+ try {
847
+ return M.call(null, e, 0);
848
+ } catch {
849
+ return M.call(this, e, 0);
850
+ }
851
+ }
852
+ }
853
+ function et(e) {
854
+ if (N === clearTimeout) return clearTimeout(e);
855
+ if ((N === Qe || !N) && clearTimeout) return N = clearTimeout, clearTimeout(e);
856
+ try {
857
+ return N(e);
858
+ } catch {
859
+ try {
860
+ return N.call(null, e);
861
+ } catch {
862
+ return N.call(this, e);
863
+ }
864
+ }
865
+ }
866
+ var P = [], F = !1, I, tt = -1;
867
+ function nt() {
868
+ !F || !I || (F = !1, I.length ? P = I.concat(P) : tt = -1, P.length && rt());
869
+ }
870
+ function rt() {
871
+ if (!F) {
872
+ var e = $e(nt);
873
+ F = !0;
874
+ for (var t = P.length; t;) {
875
+ for (I = P, P = []; ++tt < t;) I && I[tt].run();
876
+ tt = -1, t = P.length;
877
+ }
878
+ I = null, F = !1, et(e);
879
+ }
880
+ }
881
+ function L(e) {
882
+ var t = Array(arguments.length - 1);
883
+ if (arguments.length > 1) for (var n = 1; n < arguments.length; n++) t[n - 1] = arguments[n];
884
+ P.push(new it(e, t)), P.length === 1 && !F && $e(rt);
885
+ }
886
+ function it(e, t) {
887
+ this.fun = e, this.array = t;
888
+ }
889
+ it.prototype.run = function() {
890
+ this.fun.apply(null, this.array);
891
+ };
892
+ var at = {}, R = e.performance || {};
893
+ R.now || R.mozNow || R.msNow || R.oNow || R.webkitNow;
894
+ var ot = { env: at }, z = typeof Object.create == "function" ? function(e, t) {
895
+ e.super_ = t, e.prototype = Object.create(t.prototype, { constructor: {
896
+ value: e,
897
+ enumerable: !1,
898
+ writable: !0,
899
+ configurable: !0
900
+ } });
901
+ } : function(e, t) {
902
+ e.super_ = t;
903
+ var n = function() {};
904
+ n.prototype = t.prototype, e.prototype = new n(), e.prototype.constructor = e;
905
+ }, st = /%[sdj%]/g;
906
+ function ct(e) {
907
+ if (!Et(e)) {
908
+ for (var t = [], n = 0; n < arguments.length; n++) t.push(B(arguments[n]));
909
+ return t.join(" ");
910
+ }
911
+ for (var n = 1, r = arguments, i = r.length, a = String(e).replace(st, function(e) {
912
+ if (e === "%%") return "%";
913
+ if (n >= i) return e;
914
+ switch (e) {
915
+ case "%s": return String(r[n++]);
916
+ case "%d": return Number(r[n++]);
917
+ case "%j": try {
918
+ return JSON.stringify(r[n++]);
919
+ } catch {
920
+ return "[Circular]";
921
+ }
922
+ default: return e;
923
+ }
924
+ }), o = r[n]; n < i; o = r[++n]) wt(o) || !H(o) ? a += " " + o : a += " " + B(o);
925
+ return a;
926
+ }
927
+ function lt(t, n) {
928
+ if (V(e.process)) return function() {
929
+ return lt(t, n).apply(this, arguments);
930
+ };
931
+ if (ot.noDeprecation === !0) return t;
932
+ var r = !1;
933
+ function i() {
934
+ if (!r) {
935
+ if (ot.throwDeprecation) throw Error(n);
936
+ ot.traceDeprecation ? console.trace(n) : console.error(n), r = !0;
937
+ }
938
+ return t.apply(this, arguments);
939
+ }
940
+ return i;
941
+ }
942
+ var ut = {}, dt;
943
+ function ft(e) {
944
+ if (V(dt) && (dt = ot.env.NODE_DEBUG || ""), e = e.toUpperCase(), !ut[e]) if (RegExp("\\b" + e + "\\b", "i").test(dt)) {
945
+ var t = 0;
946
+ ut[e] = function() {
947
+ var n = ct.apply(null, arguments);
948
+ console.error("%s %d: %s", e, t, n);
949
+ };
950
+ } else ut[e] = function() {};
951
+ return ut[e];
952
+ }
953
+ function B(e, t) {
954
+ var n = {
955
+ seen: [],
956
+ stylize: mt
957
+ };
958
+ return arguments.length >= 3 && (n.depth = arguments[2]), arguments.length >= 4 && (n.colors = arguments[3]), Ct(t) ? n.showHidden = t : t && Mt(n, t), V(n.showHidden) && (n.showHidden = !1), V(n.depth) && (n.depth = 2), V(n.colors) && (n.colors = !1), V(n.customInspect) && (n.customInspect = !0), n.colors && (n.stylize = pt), gt(n, e, n.depth);
959
+ }
960
+ B.colors = {
961
+ bold: [1, 22],
962
+ italic: [3, 23],
963
+ underline: [4, 24],
964
+ inverse: [7, 27],
965
+ white: [37, 39],
966
+ grey: [90, 39],
967
+ black: [30, 39],
968
+ blue: [34, 39],
969
+ cyan: [36, 39],
970
+ green: [32, 39],
971
+ magenta: [35, 39],
972
+ red: [31, 39],
973
+ yellow: [33, 39]
974
+ }, B.styles = {
975
+ special: "cyan",
976
+ number: "yellow",
977
+ boolean: "yellow",
978
+ undefined: "grey",
979
+ null: "bold",
980
+ string: "green",
981
+ date: "magenta",
982
+ regexp: "red"
983
+ };
984
+ function pt(e, t) {
985
+ var n = B.styles[t];
986
+ return n ? "\x1B[" + B.colors[n][0] + "m" + e + "\x1B[" + B.colors[n][1] + "m" : e;
987
+ }
988
+ function mt(e, t) {
989
+ return e;
990
+ }
991
+ function ht(e) {
992
+ var t = {};
993
+ return e.forEach(function(e, n) {
994
+ t[e] = !0;
995
+ }), t;
996
+ }
997
+ function gt(e, t, n) {
998
+ if (e.customInspect && t && At(t.inspect) && t.inspect !== B && !(t.constructor && t.constructor.prototype === t)) {
999
+ var r = t.inspect(n, e);
1000
+ return Et(r) || (r = gt(e, r, n)), r;
1001
+ }
1002
+ var i = _t(e, t);
1003
+ if (i) return i;
1004
+ var a = Object.keys(t), o = ht(a);
1005
+ if (e.showHidden && (a = Object.getOwnPropertyNames(t)), kt(t) && (a.indexOf("message") >= 0 || a.indexOf("description") >= 0)) return vt(t);
1006
+ if (a.length === 0) {
1007
+ if (At(t)) {
1008
+ var s = t.name ? ": " + t.name : "";
1009
+ return e.stylize("[Function" + s + "]", "special");
1010
+ }
1011
+ if (Dt(t)) return e.stylize(RegExp.prototype.toString.call(t), "regexp");
1012
+ if (Ot(t)) return e.stylize(Date.prototype.toString.call(t), "date");
1013
+ if (kt(t)) return vt(t);
1014
+ }
1015
+ var c = "", l = !1, u = ["{", "}"];
1016
+ if (St(t) && (l = !0, u = ["[", "]"]), At(t) && (c = " [Function" + (t.name ? ": " + t.name : "") + "]"), Dt(t) && (c = " " + RegExp.prototype.toString.call(t)), Ot(t) && (c = " " + Date.prototype.toUTCString.call(t)), kt(t) && (c = " " + vt(t)), a.length === 0 && (!l || t.length == 0)) return u[0] + c + u[1];
1017
+ if (n < 0) return Dt(t) ? e.stylize(RegExp.prototype.toString.call(t), "regexp") : e.stylize("[Object]", "special");
1018
+ e.seen.push(t);
1019
+ var d = l ? yt(e, t, n, o, a) : a.map(function(r) {
1020
+ return bt(e, t, n, o, r, l);
1021
+ });
1022
+ return e.seen.pop(), xt(d, c, u);
1023
+ }
1024
+ function _t(e, t) {
1025
+ if (V(t)) return e.stylize("undefined", "undefined");
1026
+ if (Et(t)) {
1027
+ var n = "'" + JSON.stringify(t).replace(/^"|"$/g, "").replace(/'/g, "\\'").replace(/\\"/g, "\"") + "'";
1028
+ return e.stylize(n, "string");
1029
+ }
1030
+ if (Tt(t)) return e.stylize("" + t, "number");
1031
+ if (Ct(t)) return e.stylize("" + t, "boolean");
1032
+ if (wt(t)) return e.stylize("null", "null");
1033
+ }
1034
+ function vt(e) {
1035
+ return "[" + Error.prototype.toString.call(e) + "]";
1036
+ }
1037
+ function yt(e, t, n, r, i) {
1038
+ for (var a = [], o = 0, s = t.length; o < s; ++o) Nt(t, String(o)) ? a.push(bt(e, t, n, r, String(o), !0)) : a.push("");
1039
+ return i.forEach(function(i) {
1040
+ i.match(/^\d+$/) || a.push(bt(e, t, n, r, i, !0));
1041
+ }), a;
1042
+ }
1043
+ function bt(e, t, n, r, i, a) {
1044
+ var o, s, c = Object.getOwnPropertyDescriptor(t, i) || { value: t[i] };
1045
+ if (c.get ? s = c.set ? e.stylize("[Getter/Setter]", "special") : e.stylize("[Getter]", "special") : c.set && (s = e.stylize("[Setter]", "special")), Nt(r, i) || (o = "[" + i + "]"), s || (e.seen.indexOf(c.value) < 0 ? (s = wt(n) ? gt(e, c.value, null) : gt(e, c.value, n - 1), s.indexOf("\n") > -1 && (s = a ? s.split("\n").map(function(e) {
1046
+ return " " + e;
1047
+ }).join("\n").substr(2) : "\n" + s.split("\n").map(function(e) {
1048
+ return " " + e;
1049
+ }).join("\n"))) : s = e.stylize("[Circular]", "special")), V(o)) {
1050
+ if (a && i.match(/^\d+$/)) return s;
1051
+ o = JSON.stringify("" + i), o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/) ? (o = o.substr(1, o.length - 2), o = e.stylize(o, "name")) : (o = o.replace(/'/g, "\\'").replace(/\\"/g, "\"").replace(/(^"|"$)/g, "'"), o = e.stylize(o, "string"));
1052
+ }
1053
+ return o + ": " + s;
1054
+ }
1055
+ function xt(e, t, n) {
1056
+ return e.reduce(function(e, t) {
1057
+ return t.indexOf("\n"), e + t.replace(/\u001b\[\d\d?m/g, "").length + 1;
1058
+ }, 0) > 60 ? n[0] + (t === "" ? "" : t + "\n ") + " " + e.join(",\n ") + " " + n[1] : n[0] + t + " " + e.join(", ") + " " + n[1];
1059
+ }
1060
+ function St(e) {
1061
+ return Array.isArray(e);
1062
+ }
1063
+ function Ct(e) {
1064
+ return typeof e == "boolean";
1065
+ }
1066
+ function wt(e) {
1067
+ return e === null;
1068
+ }
1069
+ function Tt(e) {
1070
+ return typeof e == "number";
1071
+ }
1072
+ function Et(e) {
1073
+ return typeof e == "string";
1074
+ }
1075
+ function V(e) {
1076
+ return e === void 0;
1077
+ }
1078
+ function Dt(e) {
1079
+ return H(e) && jt(e) === "[object RegExp]";
1080
+ }
1081
+ function H(e) {
1082
+ return typeof e == "object" && !!e;
1083
+ }
1084
+ function Ot(e) {
1085
+ return H(e) && jt(e) === "[object Date]";
1086
+ }
1087
+ function kt(e) {
1088
+ return H(e) && (jt(e) === "[object Error]" || e instanceof Error);
1089
+ }
1090
+ function At(e) {
1091
+ return typeof e == "function";
1092
+ }
1093
+ function jt(e) {
1094
+ return Object.prototype.toString.call(e);
1095
+ }
1096
+ function Mt(e, t) {
1097
+ if (!t || !H(t)) return e;
1098
+ for (var n = Object.keys(t), r = n.length; r--;) e[n[r]] = t[n[r]];
1099
+ return e;
1100
+ }
1101
+ function Nt(e, t) {
1102
+ return Object.prototype.hasOwnProperty.call(e, t);
1103
+ }
1104
+ function U() {
1105
+ this.head = null, this.tail = null, this.length = 0;
1106
+ }
1107
+ U.prototype.push = function(e) {
1108
+ var t = {
1109
+ data: e,
1110
+ next: null
1111
+ };
1112
+ this.length > 0 ? this.tail.next = t : this.head = t, this.tail = t, ++this.length;
1113
+ }, U.prototype.unshift = function(e) {
1114
+ var t = {
1115
+ data: e,
1116
+ next: this.head
1117
+ };
1118
+ this.length === 0 && (this.tail = t), this.head = t, ++this.length;
1119
+ }, U.prototype.shift = function() {
1120
+ if (this.length !== 0) {
1121
+ var e = this.head.data;
1122
+ return this.head = this.length === 1 ? this.tail = null : this.head.next, --this.length, e;
1123
+ }
1124
+ }, U.prototype.clear = function() {
1125
+ this.head = this.tail = null, this.length = 0;
1126
+ }, U.prototype.join = function(e) {
1127
+ if (this.length === 0) return "";
1128
+ for (var t = this.head, n = "" + t.data; t = t.next;) n += e + t.data;
1129
+ return n;
1130
+ }, U.prototype.concat = function(e) {
1131
+ if (this.length === 0) return _.alloc(0);
1132
+ if (this.length === 1) return this.head.data;
1133
+ for (var t = _.allocUnsafe(e >>> 0), n = this.head, r = 0; n;) n.data.copy(t, r), r += n.data.length, n = n.next;
1134
+ return t;
1135
+ };
1136
+ var Pt = _.isEncoding || function(e) {
1137
+ switch (e && e.toLowerCase()) {
1138
+ case "hex":
1139
+ case "utf8":
1140
+ case "utf-8":
1141
+ case "ascii":
1142
+ case "binary":
1143
+ case "base64":
1144
+ case "ucs2":
1145
+ case "ucs-2":
1146
+ case "utf16le":
1147
+ case "utf-16le":
1148
+ case "raw": return !0;
1149
+ default: return !1;
1150
+ }
1151
+ };
1152
+ function Ft(e) {
1153
+ if (e && !Pt(e)) throw Error("Unknown encoding: " + e);
1154
+ }
1155
+ function W(e) {
1156
+ switch (this.encoding = (e || "utf8").toLowerCase().replace(/[-_]/, ""), Ft(e), this.encoding) {
1157
+ case "utf8":
1158
+ this.surrogateSize = 3;
1159
+ break;
1160
+ case "ucs2":
1161
+ case "utf16le":
1162
+ this.surrogateSize = 2, this.detectIncompleteChar = Lt;
1163
+ break;
1164
+ case "base64":
1165
+ this.surrogateSize = 3, this.detectIncompleteChar = Rt;
1166
+ break;
1167
+ default:
1168
+ this.write = It;
1169
+ return;
1170
+ }
1171
+ this.charBuffer = new _(6), this.charReceived = 0, this.charLength = 0;
1172
+ }
1173
+ W.prototype.write = function(e) {
1174
+ for (var t = ""; this.charLength;) {
1175
+ var n = e.length >= this.charLength - this.charReceived ? this.charLength - this.charReceived : e.length;
1176
+ if (e.copy(this.charBuffer, this.charReceived, 0, n), this.charReceived += n, this.charReceived < this.charLength) return "";
1177
+ e = e.slice(n, e.length), t = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
1178
+ var r = t.charCodeAt(t.length - 1);
1179
+ if (r >= 55296 && r <= 56319) {
1180
+ this.charLength += this.surrogateSize, t = "";
1181
+ continue;
1182
+ }
1183
+ if (this.charReceived = this.charLength = 0, e.length === 0) return t;
1184
+ break;
1185
+ }
1186
+ this.detectIncompleteChar(e);
1187
+ var i = e.length;
1188
+ this.charLength && (e.copy(this.charBuffer, 0, e.length - this.charReceived, i), i -= this.charReceived), t += e.toString(this.encoding, 0, i);
1189
+ var i = t.length - 1, r = t.charCodeAt(i);
1190
+ if (r >= 55296 && r <= 56319) {
1191
+ var a = this.surrogateSize;
1192
+ return this.charLength += a, this.charReceived += a, this.charBuffer.copy(this.charBuffer, a, 0, a), e.copy(this.charBuffer, 0, 0, a), t.substring(0, i);
1193
+ }
1194
+ return t;
1195
+ }, W.prototype.detectIncompleteChar = function(e) {
1196
+ for (var t = e.length >= 3 ? 3 : e.length; t > 0; t--) {
1197
+ var n = e[e.length - t];
1198
+ if (t == 1 && n >> 5 == 6) {
1199
+ this.charLength = 2;
1200
+ break;
1201
+ }
1202
+ if (t <= 2 && n >> 4 == 14) {
1203
+ this.charLength = 3;
1204
+ break;
1205
+ }
1206
+ if (t <= 3 && n >> 3 == 30) {
1207
+ this.charLength = 4;
1208
+ break;
1209
+ }
1210
+ }
1211
+ this.charReceived = t;
1212
+ }, W.prototype.end = function(e) {
1213
+ var t = "";
1214
+ if (e && e.length && (t = this.write(e)), this.charReceived) {
1215
+ var n = this.charReceived, r = this.charBuffer, i = this.encoding;
1216
+ t += r.slice(0, n).toString(i);
1217
+ }
1218
+ return t;
1219
+ };
1220
+ function It(e) {
1221
+ return e.toString(this.encoding);
1222
+ }
1223
+ function Lt(e) {
1224
+ this.charReceived = e.length % 2, this.charLength = this.charReceived ? 2 : 0;
1225
+ }
1226
+ function Rt(e) {
1227
+ this.charReceived = e.length % 3, this.charLength = this.charReceived ? 3 : 0;
1228
+ }
1229
+ K.ReadableState = Vt;
1230
+ var G = ft("stream");
1231
+ z(K, A);
1232
+ function zt(e, t, n) {
1233
+ if (typeof e.prependListener == "function") return e.prependListener(t, n);
1234
+ !e._events || !e._events[t] ? e.on(t, n) : Array.isArray(e._events[t]) ? e._events[t].unshift(n) : e._events[t] = [n, e._events[t]];
1235
+ }
1236
+ function Bt(e, t) {
1237
+ return e.listeners(t).length;
1238
+ }
1239
+ function Vt(e, t) {
1240
+ e ||= {}, this.objectMode = !!e.objectMode, t instanceof J && (this.objectMode = this.objectMode || !!e.readableObjectMode);
1241
+ var n = e.highWaterMark, r = this.objectMode ? 16 : 16384;
1242
+ this.highWaterMark = n || n === 0 ? n : r, this.highWaterMark = ~~this.highWaterMark, this.buffer = new U(), this.length = 0, this.pipes = null, this.pipesCount = 0, this.flowing = null, this.ended = !1, this.endEmitted = !1, this.reading = !1, this.sync = !0, this.needReadable = !1, this.emittedReadable = !1, this.readableListening = !1, this.resumeScheduled = !1, this.defaultEncoding = e.defaultEncoding || "utf8", this.ranOut = !1, this.awaitDrain = 0, this.readingMore = !1, this.decoder = null, this.encoding = null, e.encoding && (this.decoder = new W(e.encoding), this.encoding = e.encoding);
1243
+ }
1244
+ function K(e) {
1245
+ if (!(this instanceof K)) return new K(e);
1246
+ this._readableState = new Vt(e, this), this.readable = !0, e && typeof e.read == "function" && (this._read = e.read), A.call(this);
1247
+ }
1248
+ K.prototype.push = function(e, t) {
1249
+ var n = this._readableState;
1250
+ return !n.objectMode && typeof e == "string" && (t ||= n.defaultEncoding, t !== n.encoding && (e = _.from(e, t), t = "")), Ht(this, n, e, t, !1);
1251
+ }, K.prototype.unshift = function(e) {
1252
+ var t = this._readableState;
1253
+ return Ht(this, t, e, "", !0);
1254
+ }, K.prototype.isPaused = function() {
1255
+ return this._readableState.flowing === !1;
1256
+ };
1257
+ function Ht(e, t, n, r, i) {
1258
+ var a = qt(t, n);
1259
+ if (a) e.emit("error", a);
1260
+ else if (n === null) t.reading = !1, Jt(e, t);
1261
+ else if (t.objectMode || n && n.length > 0) if (t.ended && !i) {
1262
+ var o = /* @__PURE__ */ Error("stream.push() after EOF");
1263
+ e.emit("error", o);
1264
+ } else if (t.endEmitted && i) {
1265
+ var s = /* @__PURE__ */ Error("stream.unshift() after end event");
1266
+ e.emit("error", s);
1267
+ } else {
1268
+ var c;
1269
+ t.decoder && !i && !r && (n = t.decoder.write(n), c = !t.objectMode && n.length === 0), i || (t.reading = !1), c || (t.flowing && t.length === 0 && !t.sync ? (e.emit("data", n), e.read(0)) : (t.length += t.objectMode ? 1 : n.length, i ? t.buffer.unshift(n) : t.buffer.push(n), t.needReadable && Yt(e))), Zt(e, t);
1270
+ }
1271
+ else i || (t.reading = !1);
1272
+ return Ut(t);
1273
+ }
1274
+ function Ut(e) {
1275
+ return !e.ended && (e.needReadable || e.length < e.highWaterMark || e.length === 0);
1276
+ }
1277
+ K.prototype.setEncoding = function(e) {
1278
+ return this._readableState.decoder = new W(e), this._readableState.encoding = e, this;
1279
+ };
1280
+ var Wt = 8388608;
1281
+ function Gt(e) {
1282
+ return e >= Wt ? e = Wt : (e--, e |= e >>> 1, e |= e >>> 2, e |= e >>> 4, e |= e >>> 8, e |= e >>> 16, e++), e;
1283
+ }
1284
+ function Kt(e, t) {
1285
+ return e <= 0 || t.length === 0 && t.ended ? 0 : t.objectMode ? 1 : e === e ? (e > t.highWaterMark && (t.highWaterMark = Gt(e)), e <= t.length ? e : t.ended ? t.length : (t.needReadable = !0, 0)) : t.flowing && t.length ? t.buffer.head.data.length : t.length;
1286
+ }
1287
+ K.prototype.read = function(e) {
1288
+ G("read", e), e = parseInt(e, 10);
1289
+ var t = this._readableState, n = e;
1290
+ if (e !== 0 && (t.emittedReadable = !1), e === 0 && t.needReadable && (t.length >= t.highWaterMark || t.ended)) return G("read: emitReadable", t.length, t.ended), t.length === 0 && t.ended ? ln(this) : Yt(this), null;
1291
+ if (e = Kt(e, t), e === 0 && t.ended) return t.length === 0 && ln(this), null;
1292
+ var r = t.needReadable;
1293
+ G("need readable", r), (t.length === 0 || t.length - e < t.highWaterMark) && (r = !0, G("length less than watermark", r)), t.ended || t.reading ? (r = !1, G("reading or ended", r)) : r && (G("do read"), t.reading = !0, t.sync = !0, t.length === 0 && (t.needReadable = !0), this._read(t.highWaterMark), t.sync = !1, t.reading || (e = Kt(n, t)));
1294
+ var i = e > 0 ? an(e, t) : null;
1295
+ return i === null ? (t.needReadable = !0, e = 0) : t.length -= e, t.length === 0 && (t.ended || (t.needReadable = !0), n !== e && t.ended && ln(this)), i !== null && this.emit("data", i), i;
1296
+ };
1297
+ function qt(e, t) {
1298
+ var n = null;
1299
+ return !O(t) && typeof t != "string" && t != null && !e.objectMode && (n = /* @__PURE__ */ TypeError("Invalid non-string/buffer chunk")), n;
1300
+ }
1301
+ function Jt(e, t) {
1302
+ if (!t.ended) {
1303
+ if (t.decoder) {
1304
+ var n = t.decoder.end();
1305
+ n && n.length && (t.buffer.push(n), t.length += t.objectMode ? 1 : n.length);
1306
+ }
1307
+ t.ended = !0, Yt(e);
1308
+ }
1309
+ }
1310
+ function Yt(e) {
1311
+ var t = e._readableState;
1312
+ t.needReadable = !1, t.emittedReadable || (G("emitReadable", t.flowing), t.emittedReadable = !0, t.sync ? L(Xt, e) : Xt(e));
1313
+ }
1314
+ function Xt(e) {
1315
+ G("emit readable"), e.emit("readable"), rn(e);
1316
+ }
1317
+ function Zt(e, t) {
1318
+ t.readingMore || (t.readingMore = !0, L(Qt, e, t));
1319
+ }
1320
+ function Qt(e, t) {
1321
+ for (var n = t.length; !t.reading && !t.flowing && !t.ended && t.length < t.highWaterMark && (G("maybeReadMore read 0"), e.read(0), n !== t.length);) n = t.length;
1322
+ t.readingMore = !1;
1323
+ }
1324
+ K.prototype._read = function(e) {
1325
+ this.emit("error", /* @__PURE__ */ Error("not implemented"));
1326
+ }, K.prototype.pipe = function(e, t) {
1327
+ var n = this, r = this._readableState;
1328
+ switch (r.pipesCount) {
1329
+ case 0:
1330
+ r.pipes = e;
1331
+ break;
1332
+ case 1:
1333
+ r.pipes = [r.pipes, e];
1334
+ break;
1335
+ default: r.pipes.push(e);
1336
+ }
1337
+ r.pipesCount += 1, G("pipe count=%d opts=%j", r.pipesCount, t);
1338
+ var i = !t || t.end !== !1 ? o : l;
1339
+ r.endEmitted ? L(i) : n.once("end", i), e.on("unpipe", a);
1340
+ function a(e) {
1341
+ G("onunpipe"), e === n && l();
1342
+ }
1343
+ function o() {
1344
+ G("onend"), e.end();
1345
+ }
1346
+ var s = $t(n);
1347
+ e.on("drain", s);
1348
+ var c = !1;
1349
+ function l() {
1350
+ G("cleanup"), e.removeListener("close", p), e.removeListener("finish", m), e.removeListener("drain", s), e.removeListener("error", f), e.removeListener("unpipe", a), n.removeListener("end", o), n.removeListener("end", l), n.removeListener("data", d), c = !0, r.awaitDrain && (!e._writableState || e._writableState.needDrain) && s();
1351
+ }
1352
+ var u = !1;
1353
+ n.on("data", d);
1354
+ function d(t) {
1355
+ G("ondata"), u = !1, !1 === e.write(t) && !u && ((r.pipesCount === 1 && r.pipes === e || r.pipesCount > 1 && fn(r.pipes, e) !== -1) && !c && (G("false write response, pause", n._readableState.awaitDrain), n._readableState.awaitDrain++, u = !0), n.pause());
1356
+ }
1357
+ function f(t) {
1358
+ G("onerror", t), h(), e.removeListener("error", f), Bt(e, "error") === 0 && e.emit("error", t);
1359
+ }
1360
+ zt(e, "error", f);
1361
+ function p() {
1362
+ e.removeListener("finish", m), h();
1363
+ }
1364
+ e.once("close", p);
1365
+ function m() {
1366
+ G("onfinish"), e.removeListener("close", p), h();
1367
+ }
1368
+ e.once("finish", m);
1369
+ function h() {
1370
+ G("unpipe"), n.unpipe(e);
1371
+ }
1372
+ return e.emit("pipe", n), r.flowing || (G("pipe resume"), n.resume()), e;
1373
+ };
1374
+ function $t(e) {
1375
+ return function() {
1376
+ var t = e._readableState;
1377
+ G("pipeOnDrain", t.awaitDrain), t.awaitDrain && t.awaitDrain--, t.awaitDrain === 0 && e.listeners("data").length && (t.flowing = !0, rn(e));
1378
+ };
1379
+ }
1380
+ K.prototype.unpipe = function(e) {
1381
+ var t = this._readableState;
1382
+ if (t.pipesCount === 0) return this;
1383
+ if (t.pipesCount === 1) return e && e !== t.pipes ? this : (e ||= t.pipes, t.pipes = null, t.pipesCount = 0, t.flowing = !1, e && e.emit("unpipe", this), this);
1384
+ if (!e) {
1385
+ var n = t.pipes, r = t.pipesCount;
1386
+ t.pipes = null, t.pipesCount = 0, t.flowing = !1;
1387
+ for (var i = 0; i < r; i++) n[i].emit("unpipe", this);
1388
+ return this;
1389
+ }
1390
+ var a = fn(t.pipes, e);
1391
+ return a === -1 ? this : (t.pipes.splice(a, 1), --t.pipesCount, t.pipesCount === 1 && (t.pipes = t.pipes[0]), e.emit("unpipe", this), this);
1392
+ }, K.prototype.on = function(e, t) {
1393
+ var n = A.prototype.on.call(this, e, t);
1394
+ if (e === "data") this._readableState.flowing !== !1 && this.resume();
1395
+ else if (e === "readable") {
1396
+ var r = this._readableState;
1397
+ !r.endEmitted && !r.readableListening && (r.readableListening = r.needReadable = !0, r.emittedReadable = !1, r.reading ? r.length && Yt(this) : L(en, this));
1398
+ }
1399
+ return n;
1400
+ }, K.prototype.addListener = K.prototype.on;
1401
+ function en(e) {
1402
+ G("readable nexttick read 0"), e.read(0);
1403
+ }
1404
+ K.prototype.resume = function() {
1405
+ var e = this._readableState;
1406
+ return e.flowing || (G("resume"), e.flowing = !0, tn(this, e)), this;
1407
+ };
1408
+ function tn(e, t) {
1409
+ t.resumeScheduled || (t.resumeScheduled = !0, L(nn, e, t));
1410
+ }
1411
+ function nn(e, t) {
1412
+ t.reading || (G("resume read 0"), e.read(0)), t.resumeScheduled = !1, t.awaitDrain = 0, e.emit("resume"), rn(e), t.flowing && !t.reading && e.read(0);
1413
+ }
1414
+ K.prototype.pause = function() {
1415
+ return G("call pause flowing=%j", this._readableState.flowing), !1 !== this._readableState.flowing && (G("pause"), this._readableState.flowing = !1, this.emit("pause")), this;
1416
+ };
1417
+ function rn(e) {
1418
+ var t = e._readableState;
1419
+ for (G("flow", t.flowing); t.flowing && e.read() !== null;);
1420
+ }
1421
+ K.prototype.wrap = function(e) {
1422
+ var t = this._readableState, n = !1, r = this;
1423
+ for (var i in e.on("end", function() {
1424
+ if (G("wrapped end"), t.decoder && !t.ended) {
1425
+ var e = t.decoder.end();
1426
+ e && e.length && r.push(e);
1427
+ }
1428
+ r.push(null);
1429
+ }), e.on("data", function(i) {
1430
+ G("wrapped data"), t.decoder && (i = t.decoder.write(i)), !(t.objectMode && i == null) && (!t.objectMode && (!i || !i.length) || r.push(i) || (n = !0, e.pause()));
1431
+ }), e) this[i] === void 0 && typeof e[i] == "function" && (this[i] = function(t) {
1432
+ return function() {
1433
+ return e[t].apply(e, arguments);
1434
+ };
1435
+ }(i));
1436
+ return dn([
1437
+ "error",
1438
+ "close",
1439
+ "destroy",
1440
+ "pause",
1441
+ "resume"
1442
+ ], function(t) {
1443
+ e.on(t, r.emit.bind(r, t));
1444
+ }), r._read = function(t) {
1445
+ G("wrapped _read", t), n && (n = !1, e.resume());
1446
+ }, r;
1447
+ }, K._fromList = an;
1448
+ function an(e, t) {
1449
+ if (t.length === 0) return null;
1450
+ var n;
1451
+ return t.objectMode ? n = t.buffer.shift() : !e || e >= t.length ? (n = t.decoder ? t.buffer.join("") : t.buffer.length === 1 ? t.buffer.head.data : t.buffer.concat(t.length), t.buffer.clear()) : n = on(e, t.buffer, t.decoder), n;
1452
+ }
1453
+ function on(e, t, n) {
1454
+ var r;
1455
+ return e < t.head.data.length ? (r = t.head.data.slice(0, e), t.head.data = t.head.data.slice(e)) : r = e === t.head.data.length ? t.shift() : n ? sn(e, t) : cn(e, t), r;
1456
+ }
1457
+ function sn(e, t) {
1458
+ var n = t.head, r = 1, i = n.data;
1459
+ for (e -= i.length; n = n.next;) {
1460
+ var a = n.data, o = e > a.length ? a.length : e;
1461
+ if (o === a.length ? i += a : i += a.slice(0, e), e -= o, e === 0) {
1462
+ o === a.length ? (++r, t.head = n.next ? n.next : t.tail = null) : (t.head = n, n.data = a.slice(o));
1463
+ break;
1464
+ }
1465
+ ++r;
1466
+ }
1467
+ return t.length -= r, i;
1468
+ }
1469
+ function cn(e, t) {
1470
+ var n = _.allocUnsafe(e), r = t.head, i = 1;
1471
+ for (r.data.copy(n), e -= r.data.length; r = r.next;) {
1472
+ var a = r.data, o = e > a.length ? a.length : e;
1473
+ if (a.copy(n, n.length - e, 0, o), e -= o, e === 0) {
1474
+ o === a.length ? (++i, t.head = r.next ? r.next : t.tail = null) : (t.head = r, r.data = a.slice(o));
1475
+ break;
1476
+ }
1477
+ ++i;
1478
+ }
1479
+ return t.length -= i, n;
1480
+ }
1481
+ function ln(e) {
1482
+ var t = e._readableState;
1483
+ if (t.length > 0) throw Error("\"endReadable()\" called on non-empty stream");
1484
+ t.endEmitted || (t.ended = !0, L(un, t, e));
1485
+ }
1486
+ function un(e, t) {
1487
+ !e.endEmitted && e.length === 0 && (e.endEmitted = !0, t.readable = !1, t.emit("end"));
1488
+ }
1489
+ function dn(e, t) {
1490
+ for (var n = 0, r = e.length; n < r; n++) t(e[n], n);
1491
+ }
1492
+ function fn(e, t) {
1493
+ for (var n = 0, r = e.length; n < r; n++) if (e[n] === t) return n;
1494
+ return -1;
1495
+ }
1496
+ q.WritableState = hn, z(q, A);
1497
+ function pn() {}
1498
+ function mn(e, t, n) {
1499
+ this.chunk = e, this.encoding = t, this.callback = n, this.next = null;
1500
+ }
1501
+ function hn(e, t) {
1502
+ Object.defineProperty(this, "buffer", { get: lt(function() {
1503
+ return this.getBuffer();
1504
+ }, "_writableState.buffer is deprecated. Use _writableState.getBuffer instead.") }), e ||= {}, this.objectMode = !!e.objectMode, t instanceof J && (this.objectMode = this.objectMode || !!e.writableObjectMode);
1505
+ var n = e.highWaterMark, r = this.objectMode ? 16 : 16384;
1506
+ this.highWaterMark = n || n === 0 ? n : r, this.highWaterMark = ~~this.highWaterMark, this.needDrain = !1, this.ending = !1, this.ended = !1, this.finished = !1;
1507
+ var i = e.decodeStrings === !1;
1508
+ this.decodeStrings = !i, this.defaultEncoding = e.defaultEncoding || "utf8", this.length = 0, this.writing = !1, this.corked = 0, this.sync = !0, this.bufferProcessing = !1, this.onwrite = function(e) {
1509
+ Cn(t, e);
1510
+ }, this.writecb = null, this.writelen = 0, this.bufferedRequest = null, this.lastBufferedRequest = null, this.pendingcb = 0, this.prefinished = !1, this.errorEmitted = !1, this.bufferedRequestCount = 0, this.corkedRequestsFree = new jn(this);
1511
+ }
1512
+ hn.prototype.getBuffer = function() {
1513
+ for (var e = this.bufferedRequest, t = []; e;) t.push(e), e = e.next;
1514
+ return t;
1515
+ };
1516
+ function q(e) {
1517
+ if (!(this instanceof q) && !(this instanceof J)) return new q(e);
1518
+ this._writableState = new hn(e, this), this.writable = !0, e && (typeof e.write == "function" && (this._write = e.write), typeof e.writev == "function" && (this._writev = e.writev)), A.call(this);
1519
+ }
1520
+ q.prototype.pipe = function() {
1521
+ this.emit("error", /* @__PURE__ */ Error("Cannot pipe, not readable"));
1522
+ };
1523
+ function gn(e, t) {
1524
+ var n = /* @__PURE__ */ Error("write after end");
1525
+ e.emit("error", n), L(t, n);
1526
+ }
1527
+ function _n(e, t, n, r) {
1528
+ var i = !0, a = !1;
1529
+ return n === null ? a = /* @__PURE__ */ TypeError("May not write null values to stream") : !_.isBuffer(n) && typeof n != "string" && n !== void 0 && !t.objectMode && (a = /* @__PURE__ */ TypeError("Invalid non-string/buffer chunk")), a && (e.emit("error", a), L(r, a), i = !1), i;
1530
+ }
1531
+ q.prototype.write = function(e, t, n) {
1532
+ var r = this._writableState, i = !1;
1533
+ return typeof t == "function" && (n = t, t = null), _.isBuffer(e) ? t = "buffer" : t ||= r.defaultEncoding, typeof n != "function" && (n = pn), r.ended ? gn(this, n) : _n(this, r, e, n) && (r.pendingcb++, i = yn(this, r, e, t, n)), i;
1534
+ }, q.prototype.cork = function() {
1535
+ var e = this._writableState;
1536
+ e.corked++;
1537
+ }, q.prototype.uncork = function() {
1538
+ var e = this._writableState;
1539
+ e.corked && (e.corked--, !e.writing && !e.corked && !e.finished && !e.bufferProcessing && e.bufferedRequest && En(this, e));
1540
+ }, q.prototype.setDefaultEncoding = function(e) {
1541
+ if (typeof e == "string" && (e = e.toLowerCase()), !([
1542
+ "hex",
1543
+ "utf8",
1544
+ "utf-8",
1545
+ "ascii",
1546
+ "binary",
1547
+ "base64",
1548
+ "ucs2",
1549
+ "ucs-2",
1550
+ "utf16le",
1551
+ "utf-16le",
1552
+ "raw"
1553
+ ].indexOf((e + "").toLowerCase()) > -1)) throw TypeError("Unknown encoding: " + e);
1554
+ return this._writableState.defaultEncoding = e, this;
1555
+ };
1556
+ function vn(e, t, n) {
1557
+ return !e.objectMode && e.decodeStrings !== !1 && typeof t == "string" && (t = _.from(t, n)), t;
1558
+ }
1559
+ function yn(e, t, n, r, i) {
1560
+ n = vn(t, n, r), _.isBuffer(n) && (r = "buffer");
1561
+ var a = t.objectMode ? 1 : n.length;
1562
+ t.length += a;
1563
+ var o = t.length < t.highWaterMark;
1564
+ if (o || (t.needDrain = !0), t.writing || t.corked) {
1565
+ var s = t.lastBufferedRequest;
1566
+ t.lastBufferedRequest = new mn(n, r, i), s ? s.next = t.lastBufferedRequest : t.bufferedRequest = t.lastBufferedRequest, t.bufferedRequestCount += 1;
1567
+ } else bn(e, t, !1, a, n, r, i);
1568
+ return o;
1569
+ }
1570
+ function bn(e, t, n, r, i, a, o) {
1571
+ t.writelen = r, t.writecb = o, t.writing = !0, t.sync = !0, n ? e._writev(i, t.onwrite) : e._write(i, a, t.onwrite), t.sync = !1;
1572
+ }
1573
+ function xn(e, t, n, r, i) {
1574
+ --t.pendingcb, n ? L(i, r) : i(r), e._writableState.errorEmitted = !0, e.emit("error", r);
1575
+ }
1576
+ function Sn(e) {
1577
+ e.writing = !1, e.writecb = null, e.length -= e.writelen, e.writelen = 0;
1578
+ }
1579
+ function Cn(e, t) {
1580
+ var n = e._writableState, r = n.sync, i = n.writecb;
1581
+ if (Sn(n), t) xn(e, n, r, t, i);
1582
+ else {
1583
+ var a = Dn(n);
1584
+ !a && !n.corked && !n.bufferProcessing && n.bufferedRequest && En(e, n), r ? L(wn, e, n, a, i) : wn(e, n, a, i);
1585
+ }
1586
+ }
1587
+ function wn(e, t, n, r) {
1588
+ n || Tn(e, t), t.pendingcb--, r(), kn(e, t);
1589
+ }
1590
+ function Tn(e, t) {
1591
+ t.length === 0 && t.needDrain && (t.needDrain = !1, e.emit("drain"));
1592
+ }
1593
+ function En(e, t) {
1594
+ t.bufferProcessing = !0;
1595
+ var n = t.bufferedRequest;
1596
+ if (e._writev && n && n.next) {
1597
+ var r = t.bufferedRequestCount, i = Array(r), a = t.corkedRequestsFree;
1598
+ a.entry = n;
1599
+ for (var o = 0; n;) i[o] = n, n = n.next, o += 1;
1600
+ bn(e, t, !0, t.length, i, "", a.finish), t.pendingcb++, t.lastBufferedRequest = null, a.next ? (t.corkedRequestsFree = a.next, a.next = null) : t.corkedRequestsFree = new jn(t);
1601
+ } else {
1602
+ for (; n;) {
1603
+ var s = n.chunk, c = n.encoding, l = n.callback;
1604
+ if (bn(e, t, !1, t.objectMode ? 1 : s.length, s, c, l), n = n.next, t.writing) break;
1605
+ }
1606
+ n === null && (t.lastBufferedRequest = null);
1607
+ }
1608
+ t.bufferedRequestCount = 0, t.bufferedRequest = n, t.bufferProcessing = !1;
1609
+ }
1610
+ q.prototype._write = function(e, t, n) {
1611
+ n(/* @__PURE__ */ Error("not implemented"));
1612
+ }, q.prototype._writev = null, q.prototype.end = function(e, t, n) {
1613
+ var r = this._writableState;
1614
+ typeof e == "function" ? (n = e, e = null, t = null) : typeof t == "function" && (n = t, t = null), e != null && this.write(e, t), r.corked && (r.corked = 1, this.uncork()), !r.ending && !r.finished && An(this, r, n);
1615
+ };
1616
+ function Dn(e) {
1617
+ return e.ending && e.length === 0 && e.bufferedRequest === null && !e.finished && !e.writing;
1618
+ }
1619
+ function On(e, t) {
1620
+ t.prefinished || (t.prefinished = !0, e.emit("prefinish"));
1621
+ }
1622
+ function kn(e, t) {
1623
+ var n = Dn(t);
1624
+ return n && (t.pendingcb === 0 ? (On(e, t), t.finished = !0, e.emit("finish")) : On(e, t)), n;
1625
+ }
1626
+ function An(e, t, n) {
1627
+ t.ending = !0, kn(e, t), n && (t.finished ? L(n) : e.once("finish", n)), t.ended = !0, e.writable = !1;
1628
+ }
1629
+ function jn(e) {
1630
+ var t = this;
1631
+ this.next = null, this.entry = null, this.finish = function(n) {
1632
+ var r = t.entry;
1633
+ for (t.entry = null; r;) {
1634
+ var i = r.callback;
1635
+ e.pendingcb--, i(n), r = r.next;
1636
+ }
1637
+ e.corkedRequestsFree ? e.corkedRequestsFree.next = t : e.corkedRequestsFree = t;
1638
+ };
1639
+ }
1640
+ z(J, K);
1641
+ for (var Mn = Object.keys(q.prototype), Nn = 0; Nn < Mn.length; Nn++) {
1642
+ var Pn = Mn[Nn];
1643
+ J.prototype[Pn] || (J.prototype[Pn] = q.prototype[Pn]);
1644
+ }
1645
+ function J(e) {
1646
+ if (!(this instanceof J)) return new J(e);
1647
+ K.call(this, e), q.call(this, e), e && e.readable === !1 && (this.readable = !1), e && e.writable === !1 && (this.writable = !1), this.allowHalfOpen = !0, e && e.allowHalfOpen === !1 && (this.allowHalfOpen = !1), this.once("end", Fn);
1648
+ }
1649
+ function Fn() {
1650
+ this.allowHalfOpen || this._writableState.ended || L(In, this);
1651
+ }
1652
+ function In(e) {
1653
+ e.end();
1654
+ }
1655
+ z(Y, J);
1656
+ function Ln(e) {
1657
+ this.afterTransform = function(t, n) {
1658
+ return Rn(e, t, n);
1659
+ }, this.needTransform = !1, this.transforming = !1, this.writecb = null, this.writechunk = null, this.writeencoding = null;
1660
+ }
1661
+ function Rn(e, t, n) {
1662
+ var r = e._transformState;
1663
+ r.transforming = !1;
1664
+ var i = r.writecb;
1665
+ if (!i) return e.emit("error", /* @__PURE__ */ Error("no writecb in Transform class"));
1666
+ r.writechunk = null, r.writecb = null, n != null && e.push(n), i(t);
1667
+ var a = e._readableState;
1668
+ a.reading = !1, (a.needReadable || a.length < a.highWaterMark) && e._read(a.highWaterMark);
1669
+ }
1670
+ function Y(e) {
1671
+ if (!(this instanceof Y)) return new Y(e);
1672
+ J.call(this, e), this._transformState = new Ln(this);
1673
+ var t = this;
1674
+ this._readableState.needReadable = !0, this._readableState.sync = !1, e && (typeof e.transform == "function" && (this._transform = e.transform), typeof e.flush == "function" && (this._flush = e.flush)), this.once("prefinish", function() {
1675
+ typeof this._flush == "function" ? this._flush(function(e) {
1676
+ zn(t, e);
1677
+ }) : zn(t);
1678
+ });
1679
+ }
1680
+ Y.prototype.push = function(e, t) {
1681
+ return this._transformState.needTransform = !1, J.prototype.push.call(this, e, t);
1682
+ }, Y.prototype._transform = function(e, t, n) {
1683
+ throw Error("Not implemented");
1684
+ }, Y.prototype._write = function(e, t, n) {
1685
+ var r = this._transformState;
1686
+ if (r.writecb = n, r.writechunk = e, r.writeencoding = t, !r.transforming) {
1687
+ var i = this._readableState;
1688
+ (r.needTransform || i.needReadable || i.length < i.highWaterMark) && this._read(i.highWaterMark);
1689
+ }
1690
+ }, Y.prototype._read = function(e) {
1691
+ var t = this._transformState;
1692
+ t.writechunk !== null && t.writecb && !t.transforming ? (t.transforming = !0, this._transform(t.writechunk, t.writeencoding, t.afterTransform)) : t.needTransform = !0;
1693
+ };
1694
+ function zn(e, t) {
1695
+ if (t) return e.emit("error", t);
1696
+ var n = e._writableState, r = e._transformState;
1697
+ if (n.length) throw Error("Calling transform done when ws.length != 0");
1698
+ if (r.transforming) throw Error("Calling transform done when still transforming");
1699
+ return e.push(null);
1700
+ }
1701
+ z(X, Y);
1702
+ function X(e) {
1703
+ if (!(this instanceof X)) return new X(e);
1704
+ Y.call(this, e);
1705
+ }
1706
+ X.prototype._transform = function(e, t, n) {
1707
+ n(null, e);
1708
+ }, z(Z, A), Z.Readable = K, Z.Writable = q, Z.Duplex = J, Z.Transform = Y, Z.PassThrough = X, Z.Stream = Z;
1709
+ function Z() {
1710
+ A.call(this);
1711
+ }
1712
+ Z.prototype.pipe = function(e, t) {
1713
+ var n = this;
1714
+ function r(t) {
1715
+ e.writable && !1 === e.write(t) && n.pause && n.pause();
1716
+ }
1717
+ n.on("data", r);
1718
+ function i() {
1719
+ n.readable && n.resume && n.resume();
1720
+ }
1721
+ e.on("drain", i), !e._isStdio && (!t || t.end !== !1) && (n.on("end", o), n.on("close", s));
1722
+ var a = !1;
1723
+ function o() {
1724
+ a || (a = !0, e.end());
1725
+ }
1726
+ function s() {
1727
+ a || (a = !0, typeof e.destroy == "function" && e.destroy());
1728
+ }
1729
+ function c(e) {
1730
+ if (l(), A.listenerCount(this, "error") === 0) throw e;
1731
+ }
1732
+ n.on("error", c), e.on("error", c);
1733
+ function l() {
1734
+ n.removeListener("data", r), e.removeListener("drain", i), n.removeListener("end", o), n.removeListener("close", s), n.removeListener("error", c), e.removeListener("error", c), n.removeListener("end", l), n.removeListener("close", l), e.removeListener("close", l);
1735
+ }
1736
+ return n.on("end", l), n.on("close", l), e.on("close", l), e.emit("pipe", n), e;
1737
+ };
1738
+ var Bn = function(e) {
1739
+ return typeof e == "object" && !!e && !Array.isArray(e);
1740
+ }, Q = class e extends Error {
1741
+ constructor(t, n, r, ...i) {
1742
+ Array.isArray(n) && (n = n.join(" ").trim()), super(n), Error.captureStackTrace !== void 0 && Error.captureStackTrace(this, e), this.code = t;
1743
+ for (let e of i) for (let t in e) {
1744
+ let n = e[t];
1745
+ this[t] = O(n) ? n.toString(r.encoding) : n == null ? n : JSON.parse(JSON.stringify(n));
1746
+ }
1747
+ }
1748
+ }, Vn = function(e) {
1749
+ let t = [];
1750
+ for (let n = 0, r = e.length; n < r; n++) {
1751
+ let r = e[n];
1752
+ if (r == null || r === !1) t[n] = { disabled: !0 };
1753
+ else if (typeof r == "string" || typeof r == "number") t[n] = { name: `${r}` };
1754
+ else if (Bn(r)) {
1755
+ if (typeof r.name != "string") throw new Q("CSV_OPTION_COLUMNS_MISSING_NAME", [
1756
+ "Option columns missing name:",
1757
+ `property "name" is required at position ${n}`,
1758
+ "when column is an object literal"
1759
+ ]);
1760
+ t[n] = r;
1761
+ } else throw new Q("CSV_INVALID_COLUMN_DEFINITION", [
1762
+ "Invalid column definition:",
1763
+ "expect a string or a literal object,",
1764
+ `got ${JSON.stringify(r)} at position ${n}`
1765
+ ]);
1766
+ }
1767
+ return t;
1768
+ }, Hn = class {
1769
+ constructor(e = 100) {
1770
+ this.size = e, this.length = 0, this.buf = _.allocUnsafe(e);
1771
+ }
1772
+ prepend(e) {
1773
+ if (O(e)) {
1774
+ let t = this.length + e.length;
1775
+ if (t >= this.size && (this.resize(), t >= this.size)) throw Error("INVALID_BUFFER_STATE");
1776
+ let n = this.buf;
1777
+ this.buf = _.allocUnsafe(this.size), e.copy(this.buf, 0), n.copy(this.buf, e.length), this.length += e.length;
1778
+ } else {
1779
+ let t = this.length++;
1780
+ t === this.size && this.resize();
1781
+ let n = this.clone();
1782
+ this.buf[0] = e, n.copy(this.buf, 1, 0, t);
1783
+ }
1784
+ }
1785
+ append(e) {
1786
+ let t = this.length++;
1787
+ t === this.size && this.resize(), this.buf[t] = e;
1788
+ }
1789
+ clone() {
1790
+ return _.from(this.buf.slice(0, this.length));
1791
+ }
1792
+ resize() {
1793
+ let e = this.length;
1794
+ this.size *= 2;
1795
+ let t = _.allocUnsafe(this.size);
1796
+ this.buf.copy(t, 0, 0, e), this.buf = t;
1797
+ }
1798
+ toString(e) {
1799
+ return e ? this.buf.slice(0, this.length).toString(e) : Uint8Array.prototype.slice.call(this.buf.slice(0, this.length));
1800
+ }
1801
+ toJSON() {
1802
+ return this.toString("utf8");
1803
+ }
1804
+ reset() {
1805
+ this.length = 0;
1806
+ }
1807
+ }, Un = function(e) {
1808
+ let t = [
1809
+ 32,
1810
+ 9,
1811
+ 10,
1812
+ 13,
1813
+ 12,
1814
+ 11,
1815
+ 160,
1816
+ 5760,
1817
+ 8192,
1818
+ 8193,
1819
+ 8194,
1820
+ 8195,
1821
+ 8196,
1822
+ 8197,
1823
+ 8198,
1824
+ 8199,
1825
+ 8200,
1826
+ 8201,
1827
+ 8202,
1828
+ 8232,
1829
+ 8233,
1830
+ 8239,
1831
+ 8287,
1832
+ 12288,
1833
+ 65279
1834
+ ].reduce((t, n) => {
1835
+ let r = _.from(String.fromCharCode(n), e.encoding);
1836
+ return n !== 63 && r.length === 1 && r[0] === 63 || t.push(r), t;
1837
+ }, []), n = /* @__PURE__ */ new Uint8Array(256);
1838
+ for (let e of t) n[e[0]] = 1;
1839
+ return {
1840
+ bomSkipped: !1,
1841
+ bufBytesStart: 0,
1842
+ castField: e.cast_function,
1843
+ commenting: !1,
1844
+ delimiterBufPrevious: void 0,
1845
+ delimiterDiscovered: !1,
1846
+ error: void 0,
1847
+ enabled: e.from_line === 1,
1848
+ escaping: !1,
1849
+ escapeIsQuote: O(e.escape) && O(e.quote) && _.compare(e.escape, e.quote) === 0,
1850
+ expectedRecordLength: Array.isArray(e.columns) ? e.columns.length : void 0,
1851
+ field: new Hn(20),
1852
+ firstLineToHeaders: e.cast_first_line_to_header,
1853
+ needMoreDataSize: Math.max(e.comment === null ? 0 : e.comment.length, ...e.delimiter ? e.delimiter.map((e) => e.length) : [], +!!e.delimiter_auto, e.quote === null ? 0 : e.quote.length, ...t.map((e) => e.length)),
1854
+ previousBuf: void 0,
1855
+ quoting: !1,
1856
+ stop: !1,
1857
+ rawBuffer: new Hn(100),
1858
+ record: [],
1859
+ recordHasError: !1,
1860
+ record_length: 0,
1861
+ recordDelimiterMaxLength: e.record_delimiter.length === 0 ? 0 : Math.max(...e.record_delimiter.map((e) => e.length)),
1862
+ trimChars: [_.from(" ", e.encoding)[0], _.from(" ", e.encoding)[0]],
1863
+ wasQuoting: !1,
1864
+ wasRowDelimiter: !1,
1865
+ timchars: t,
1866
+ timcharFirstBytes: n
1867
+ };
1868
+ }, Wn = function(e) {
1869
+ return e.replace(/([A-Z])/g, function(e, t) {
1870
+ return "_" + t.toLowerCase();
1871
+ });
1872
+ }, Gn = function(e) {
1873
+ let t = {};
1874
+ for (let n in e) t[Wn(n)] = e[n];
1875
+ if (t.encoding === void 0 || t.encoding === !0) t.encoding = "utf8";
1876
+ else if (t.encoding === null || t.encoding === !1) t.encoding = null;
1877
+ else if (typeof t.encoding != "string" && t.encoding !== null) throw new Q("CSV_INVALID_OPTION_ENCODING", [
1878
+ "Invalid option encoding:",
1879
+ "encoding must be a string or null to return a buffer,",
1880
+ `got ${JSON.stringify(t.encoding)}`
1881
+ ], t);
1882
+ if (t.bom === void 0 || t.bom === null || t.bom === !1) t.bom = !1;
1883
+ else if (t.bom !== !0) throw new Q("CSV_INVALID_OPTION_BOM", [
1884
+ "Invalid option bom:",
1885
+ "bom must be true,",
1886
+ `got ${JSON.stringify(t.bom)}`
1887
+ ], t);
1888
+ if (t.cast_function = null, t.cast === void 0 || t.cast === null || t.cast === !1 || t.cast === "") t.cast = void 0;
1889
+ else if (typeof t.cast == "function") t.cast_function = t.cast, t.cast = !0;
1890
+ else if (t.cast !== !0) throw new Q("CSV_INVALID_OPTION_CAST", [
1891
+ "Invalid option cast:",
1892
+ "cast must be true or a function,",
1893
+ `got ${JSON.stringify(t.cast)}`
1894
+ ], t);
1895
+ if (t.cast_date === void 0 || t.cast_date === null || t.cast_date === !1 || t.cast_date === "") t.cast_date = !1;
1896
+ else if (t.cast_date === !0) t.cast_date = function(e) {
1897
+ let t = Date.parse(e);
1898
+ return isNaN(t) ? e : new Date(t);
1899
+ };
1900
+ else if (typeof t.cast_date != "function") throw new Q("CSV_INVALID_OPTION_CAST_DATE", [
1901
+ "Invalid option cast_date:",
1902
+ "cast_date must be true or a function,",
1903
+ `got ${JSON.stringify(t.cast_date)}`
1904
+ ], t);
1905
+ if (t.cast_first_line_to_header = void 0, t.columns === !0) t.cast_first_line_to_header = void 0;
1906
+ else if (typeof t.columns == "function") t.cast_first_line_to_header = t.columns, t.columns = !0;
1907
+ else if (Array.isArray(t.columns)) t.columns = Vn(t.columns);
1908
+ else if (t.columns === void 0 || t.columns === null || t.columns === !1) t.columns = !1;
1909
+ else throw new Q("CSV_INVALID_OPTION_COLUMNS", [
1910
+ "Invalid option columns:",
1911
+ "expect an array, a function or true,",
1912
+ `got ${JSON.stringify(t.columns)}`
1913
+ ], t);
1914
+ if (t.group_columns_by_name === void 0 || t.group_columns_by_name === null || t.group_columns_by_name === !1) t.group_columns_by_name = !1;
1915
+ else if (t.group_columns_by_name !== !0) throw new Q("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME", [
1916
+ "Invalid option group_columns_by_name:",
1917
+ "expect an boolean,",
1918
+ `got ${JSON.stringify(t.group_columns_by_name)}`
1919
+ ], t);
1920
+ else if (t.columns === !1) throw new Q("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME", ["Invalid option group_columns_by_name:", "the `columns` mode must be activated."], t);
1921
+ if (t.comment === void 0 || t.comment === null || t.comment === !1 || t.comment === "") t.comment = null;
1922
+ else if (typeof t.comment == "string" && (t.comment = _.from(t.comment, t.encoding)), !O(t.comment)) throw new Q("CSV_INVALID_OPTION_COMMENT", [
1923
+ "Invalid option comment:",
1924
+ "comment must be a buffer or a string,",
1925
+ `got ${JSON.stringify(t.comment)}`
1926
+ ], t);
1927
+ if (t.comment_no_infix === void 0 || t.comment_no_infix === null || t.comment_no_infix === !1) t.comment_no_infix = !1;
1928
+ else if (t.comment_no_infix !== !0) throw new Q("CSV_INVALID_OPTION_COMMENT", [
1929
+ "Invalid option comment_no_infix:",
1930
+ "value must be a boolean,",
1931
+ `got ${JSON.stringify(t.comment_no_infix)}`
1932
+ ], t);
1933
+ if (t.delimiter_auto === void 0 || t.delimiter_auto === null || t.delimiter_auto === !1) t.delimiter_auto = !1;
1934
+ else if (t.delimiter_auto === !0) t.delimiter_auto = {};
1935
+ else if (!Bn(t.delimiter_auto)) throw new Q("CSV_INVALID_OPTION_DELIMITER_AUTO", [
1936
+ "Invalid option delimiter_auto:",
1937
+ "delimiter_auto must be a boolean or a configuration object,",
1938
+ `got ${JSON.stringify(t.delimiter_auto)}`
1939
+ ], t);
1940
+ if (t.delimiter_auto) {
1941
+ if (t.delimiter_auto.preferred === void 0) t.delimiter_auto.preferred = {
1942
+ 44: 1.8,
1943
+ 9: 1.8,
1944
+ 59: 1.6,
1945
+ 32: 1.6,
1946
+ 58: 1.5,
1947
+ 46: 1.4,
1948
+ 47: 1.4
1949
+ };
1950
+ else if (!Bn(t.delimiter_auto.preferred)) throw new Q("CSV_INVALID_OPTION_DELIMITER_AUTO", [
1951
+ "Invalid option delimiter_auto:",
1952
+ "preferred must be an object,",
1953
+ `got ${JSON.stringify(t.delimiter_auto.preferred)}`
1954
+ ], t);
1955
+ if (t.delimiter_auto.score === void 0) t.delimiter_auto.score = (e, t) => (e.total - e.std) * (t.preferred[e.char_code] || 1);
1956
+ else if (typeof t.delimiter_auto.score != "function") throw new Q("CSV_INVALID_OPTION_DELIMITER_AUTO", [
1957
+ "Invalid option delimiter_auto:",
1958
+ "score must be a function,",
1959
+ `got ${JSON.stringify(t.delimiter_auto.score)}`
1960
+ ], t);
1961
+ if (t.delimiter_auto.size === void 0) t.delimiter_auto.size = 2048;
1962
+ else if (typeof t.delimiter_auto.size != "number") throw new Q("CSV_INVALID_OPTION_DELIMITER_AUTO", [
1963
+ "Invalid option delimiter_auto:",
1964
+ "size must be a number,",
1965
+ `got ${JSON.stringify(t.delimiter_auto.size)}`
1966
+ ], t);
1967
+ }
1968
+ let n = JSON.stringify(t.delimiter);
1969
+ if (t.delimiter_auto !== !1 && (t.delimiter = []), Array.isArray(t.delimiter) || ((t.delimiter === void 0 || t.delimiter === null || t.delimiter === !1) && (t.delimiter = _.from(",", t.encoding)), t.delimiter = [t.delimiter]), t.delimiter = t.delimiter.map(function(e) {
1970
+ if (typeof e == "string" && (e = _.from(e, t.encoding)), !O(e) || e.length === 0) throw new Q("CSV_INVALID_OPTION_DELIMITER", [
1971
+ "Invalid option delimiter:",
1972
+ "delimiter must be a non empty string or buffer or array of string|buffer,",
1973
+ `got ${n}`
1974
+ ], t);
1975
+ return e;
1976
+ }), t.escape === void 0 || t.escape === !0 ? t.escape = _.from("\"", t.encoding) : typeof t.escape == "string" ? t.escape = _.from(t.escape, t.encoding) : (t.escape === null || t.escape === !1) && (t.escape = null), t.escape !== null && !O(t.escape)) throw Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(t.escape)}`);
1977
+ if (t.from === void 0 || t.from === null) t.from = 1;
1978
+ else if (typeof t.from == "string" && /\d+/.test(t.from) && (t.from = parseInt(t.from)), Number.isInteger(t.from)) {
1979
+ if (t.from < 0) throw Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(e.from)}`);
1980
+ } else throw Error(`Invalid Option: from must be an integer, got ${JSON.stringify(t.from)}`);
1981
+ if (t.from_line === void 0 || t.from_line === null) t.from_line = 1;
1982
+ else if (typeof t.from_line == "string" && /\d+/.test(t.from_line) && (t.from_line = parseInt(t.from_line)), Number.isInteger(t.from_line)) {
1983
+ if (t.from_line <= 0) throw Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(e.from_line)}`);
1984
+ } else throw Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(e.from_line)}`);
1985
+ if (t.ignore_last_delimiters === void 0 || t.ignore_last_delimiters === null) t.ignore_last_delimiters = !1;
1986
+ else if (typeof t.ignore_last_delimiters == "number") t.ignore_last_delimiters = Math.floor(t.ignore_last_delimiters), t.ignore_last_delimiters === 0 && (t.ignore_last_delimiters = !1);
1987
+ else if (typeof t.ignore_last_delimiters != "boolean") throw new Q("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS", [
1988
+ "Invalid option `ignore_last_delimiters`:",
1989
+ "the value must be a boolean value or an integer,",
1990
+ `got ${JSON.stringify(t.ignore_last_delimiters)}`
1991
+ ], t);
1992
+ if (t.ignore_last_delimiters === !0 && t.columns === !1) throw new Q("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS", ["The option `ignore_last_delimiters`", "requires the activation of the `columns` option"], t);
1993
+ if (t.info === void 0 || t.info === null || t.info === !1) t.info = !1;
1994
+ else if (t.info !== !0) throw Error(`Invalid Option: info must be true, got ${JSON.stringify(t.info)}`);
1995
+ if (t.max_record_size === void 0 || t.max_record_size === null || t.max_record_size === !1) t.max_record_size = 0;
1996
+ else if (!(Number.isInteger(t.max_record_size) && t.max_record_size >= 0)) if (typeof t.max_record_size == "string" && /\d+/.test(t.max_record_size)) t.max_record_size = parseInt(t.max_record_size);
1997
+ else throw Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(t.max_record_size)}`);
1998
+ if (t.objname === void 0 || t.objname === null || t.objname === !1) t.objname = void 0;
1999
+ else if (O(t.objname)) {
2000
+ if (t.objname.length === 0) throw Error("Invalid Option: objname must be a non empty buffer");
2001
+ t.encoding === null || (t.objname = t.objname.toString(t.encoding));
2002
+ } else if (typeof t.objname == "string") {
2003
+ if (t.objname.length === 0) throw Error("Invalid Option: objname must be a non empty string");
2004
+ } else if (typeof t.objname != "number") throw Error(`Invalid Option: objname must be a string or a buffer, got ${t.objname}`);
2005
+ if (t.objname !== void 0) {
2006
+ if (typeof t.objname == "number") {
2007
+ if (t.columns !== !1) throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field");
2008
+ } else if (t.columns === !1) throw Error("Invalid Option: objname field must be combined with columns or be defined as an index");
2009
+ }
2010
+ if (t.on_record === void 0 || t.on_record === null) t.on_record = void 0;
2011
+ else if (typeof t.on_record != "function") throw new Q("CSV_INVALID_OPTION_ON_RECORD", [
2012
+ "Invalid option `on_record`:",
2013
+ "expect a function,",
2014
+ `got ${JSON.stringify(t.on_record)}`
2015
+ ], t);
2016
+ if (t.on_skip !== void 0 && t.on_skip !== null && typeof t.on_skip != "function") throw Error(`Invalid Option: on_skip must be a function, got ${JSON.stringify(t.on_skip)}`);
2017
+ if (t.quote === null || t.quote === !1 || t.quote === "") t.quote = null;
2018
+ else if (t.quote === void 0 || t.quote === !0 ? t.quote = _.from("\"", t.encoding) : typeof t.quote == "string" && (t.quote = _.from(t.quote, t.encoding)), !O(t.quote)) throw Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(t.quote)}`);
2019
+ if (t.raw === void 0 || t.raw === null || t.raw === !1) t.raw = !1;
2020
+ else if (t.raw !== !0) throw Error(`Invalid Option: raw must be true, got ${JSON.stringify(t.raw)}`);
2021
+ if (t.record_delimiter === void 0) t.record_delimiter = [];
2022
+ else if (typeof t.record_delimiter == "string" || O(t.record_delimiter)) {
2023
+ if (t.record_delimiter.length === 0) throw new Q("CSV_INVALID_OPTION_RECORD_DELIMITER", [
2024
+ "Invalid option `record_delimiter`:",
2025
+ "value must be a non empty string or buffer,",
2026
+ `got ${JSON.stringify(t.record_delimiter)}`
2027
+ ], t);
2028
+ t.record_delimiter = [t.record_delimiter];
2029
+ } else if (!Array.isArray(t.record_delimiter)) throw new Q("CSV_INVALID_OPTION_RECORD_DELIMITER", [
2030
+ "Invalid option `record_delimiter`:",
2031
+ "value must be a string, a buffer or array of string|buffer,",
2032
+ `got ${JSON.stringify(t.record_delimiter)}`
2033
+ ], t);
2034
+ if (t.record_delimiter = t.record_delimiter.map(function(e, n) {
2035
+ if (typeof e != "string" && !O(e)) throw new Q("CSV_INVALID_OPTION_RECORD_DELIMITER", [
2036
+ "Invalid option `record_delimiter`:",
2037
+ "value must be a string, a buffer or array of string|buffer",
2038
+ `at index ${n},`,
2039
+ `got ${JSON.stringify(e)}`
2040
+ ], t);
2041
+ if (e.length === 0) throw new Q("CSV_INVALID_OPTION_RECORD_DELIMITER", [
2042
+ "Invalid option `record_delimiter`:",
2043
+ "value must be a non empty string or buffer",
2044
+ `at index ${n},`,
2045
+ `got ${JSON.stringify(e)}`
2046
+ ], t);
2047
+ return typeof e == "string" && (e = _.from(e, t.encoding)), e;
2048
+ }), typeof t.relax_column_count != "boolean") if (t.relax_column_count === void 0 || t.relax_column_count === null) t.relax_column_count = !1;
2049
+ else throw Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(t.relax_column_count)}`);
2050
+ if (typeof t.relax_column_count_less != "boolean") if (t.relax_column_count_less === void 0 || t.relax_column_count_less === null) t.relax_column_count_less = !1;
2051
+ else throw Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(t.relax_column_count_less)}`);
2052
+ if (typeof t.relax_column_count_more != "boolean") if (t.relax_column_count_more === void 0 || t.relax_column_count_more === null) t.relax_column_count_more = !1;
2053
+ else throw Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(t.relax_column_count_more)}`);
2054
+ if (typeof t.relax_quotes != "boolean") if (t.relax_quotes === void 0 || t.relax_quotes === null) t.relax_quotes = !1;
2055
+ else throw Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(t.relax_quotes)}`);
2056
+ if (typeof t.skip_empty_lines != "boolean") if (t.skip_empty_lines === void 0 || t.skip_empty_lines === null) t.skip_empty_lines = !1;
2057
+ else throw Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(t.skip_empty_lines)}`);
2058
+ if (typeof t.skip_records_with_empty_values != "boolean") if (t.skip_records_with_empty_values === void 0 || t.skip_records_with_empty_values === null) t.skip_records_with_empty_values = !1;
2059
+ else throw Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(t.skip_records_with_empty_values)}`);
2060
+ if (typeof t.skip_records_with_error != "boolean") if (t.skip_records_with_error === void 0 || t.skip_records_with_error === null) t.skip_records_with_error = !1;
2061
+ else throw Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(t.skip_records_with_error)}`);
2062
+ if (t.rtrim === void 0 || t.rtrim === null || t.rtrim === !1) t.rtrim = !1;
2063
+ else if (t.rtrim !== !0) throw Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(t.rtrim)}`);
2064
+ if (t.ltrim === void 0 || t.ltrim === null || t.ltrim === !1) t.ltrim = !1;
2065
+ else if (t.ltrim !== !0) throw Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(t.ltrim)}`);
2066
+ if (t.trim === void 0 || t.trim === null || t.trim === !1) t.trim = !1;
2067
+ else if (t.trim !== !0) throw Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(t.trim)}`);
2068
+ if (t.trim === !0 && e.ltrim !== !1 ? t.ltrim = !0 : t.ltrim !== !0 && (t.ltrim = !1), t.trim === !0 && e.rtrim !== !1 ? t.rtrim = !0 : t.rtrim !== !0 && (t.rtrim = !1), t.to === void 0 || t.to === null) t.to = -1;
2069
+ else if (t.to !== -1) if (typeof t.to == "string" && /\d+/.test(t.to) && (t.to = parseInt(t.to)), Number.isInteger(t.to)) {
2070
+ if (t.to <= 0) throw Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(e.to)}`);
2071
+ } else throw Error(`Invalid Option: to must be an integer, got ${JSON.stringify(e.to)}`);
2072
+ if (t.to_line === void 0 || t.to_line === null) t.to_line = -1;
2073
+ else if (t.to_line !== -1) if (typeof t.to_line == "string" && /\d+/.test(t.to_line) && (t.to_line = parseInt(t.to_line)), Number.isInteger(t.to_line)) {
2074
+ if (t.to_line <= 0) throw Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(e.to_line)}`);
2075
+ } else throw Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(e.to_line)}`);
2076
+ return t;
2077
+ }, Kn = function(e, t) {
2078
+ t || ({delimiter_auto: t} = Gn({ delimiter_auto: !0 })), typeof e == "string" && (e = _.from(e)), O(e) && (e = ((e) => {
2079
+ let t = [], n = Zn({ delimiter: [] }).parse(e, !0, (e) => t.push(e), () => {});
2080
+ if (n !== void 0) throw n;
2081
+ return t;
2082
+ })(e));
2083
+ let n = Array(127).fill().map(() => ({ lines: [] }));
2084
+ e.map(([e], t) => {
2085
+ for (let r = 0, i = e.length; r < i; r++) {
2086
+ let i = e.charCodeAt(r);
2087
+ n[i].lines[t] === void 0 && (n[i].lines[t] = 0), n[i].lines[t]++;
2088
+ }
2089
+ }), n.map((e, n) => {
2090
+ e.char_code = n, e.std = qn(e.lines), e.total = e.lines.reduce((e, t) => e + t, 0), e.preferred = !!t.preferred[n], e.score = t.score(e, t);
2091
+ });
2092
+ let r = n.reduce((e, t) => e.score > t.score ? e : t, {});
2093
+ return String.fromCharCode(r.char_code);
2094
+ }, qn = function(e) {
2095
+ let t = e.length;
2096
+ if (t === 0) return 0;
2097
+ let n = e.reduce((e, t) => e + t) / t;
2098
+ return Math.sqrt(e.map((e) => (e - n) ** 2).reduce((e, t) => e + t) / t);
2099
+ }, Jn = function(e) {
2100
+ return e.every((e) => e == null || e.toString && e.toString().trim() === "");
2101
+ }, Yn = 13, Xn = 10, $ = {
2102
+ utf8: _.from([
2103
+ 239,
2104
+ 187,
2105
+ 191
2106
+ ]),
2107
+ utf16le: _.from([255, 254])
2108
+ }, Zn = function(e = {}) {
2109
+ let t = {
2110
+ bytes: 0,
2111
+ bytes_records: 0,
2112
+ comment_lines: 0,
2113
+ empty_lines: 0,
2114
+ invalid_field_length: 0,
2115
+ lines: 1,
2116
+ records: 0
2117
+ }, n = Gn(e);
2118
+ return {
2119
+ info: t,
2120
+ original_options: e,
2121
+ options: n,
2122
+ state: Un(n),
2123
+ __needMoreData: function(e, t, n) {
2124
+ if (n) return !1;
2125
+ let { encoding: r, escape: i, quote: a } = this.options, { quoting: o, needMoreDataSize: s, recordDelimiterMaxLength: c } = this.state;
2126
+ return t - e - 1 < Math.max(s, c === 0 ? _.from("\r\n", r).length : c, o ? (i === null ? 0 : i.length) + a.length : 0, o ? a.length + c : 0);
2127
+ },
2128
+ parse: function(e, t, n, r) {
2129
+ let { bom: i, comment_no_infix: a, delimiter_auto: o, encoding: s, from_line: c, ltrim: l, max_record_size: u, raw: d, relax_quotes: f, rtrim: p, skip_empty_lines: m, to: h, to_line: g } = this.options, { comment: v, escape: y, quote: b, record_delimiter: x } = this.options, { bomSkipped: ee, delimiterDiscovered: te, delimiterBufPrevious: S, rawBuffer: ne, escapeIsQuote: re } = this.state;
2130
+ if (!te && o) {
2131
+ let n;
2132
+ if (n = S === void 0 ? e : S !== void 0 && e === void 0 ? S : _.concat([S, e]), e = void 0, t || n.length > o.size) this.options.delimiter = [_.from(Kn(n, this.options.delimiter_auto))], this.state.previousBuf = n, this.state.delimiterBufPrevious = void 0, this.state.delimiterDiscovered = !0;
2133
+ else {
2134
+ this.state.delimiterBufPrevious = n;
2135
+ return;
2136
+ }
2137
+ }
2138
+ let { previousBuf: C } = this.state, w;
2139
+ if (C === void 0) if (e === void 0) {
2140
+ r();
2141
+ return;
2142
+ } else w = e;
2143
+ else w = C !== void 0 && e === void 0 ? C : _.concat([C, e]);
2144
+ if (ee === !1) if (i === !1) this.state.bomSkipped = !0;
2145
+ else if (w.length < 3) {
2146
+ if (t === !1) {
2147
+ this.state.previousBuf = w;
2148
+ return;
2149
+ }
2150
+ } else {
2151
+ for (let e in $) if ($[e].compare(w, 0, $[e].length) === 0) {
2152
+ let t = $[e].length;
2153
+ this.state.bufBytesStart += t, w = w.slice(t);
2154
+ let n = Gn({
2155
+ ...this.original_options,
2156
+ encoding: e
2157
+ });
2158
+ for (let e in n) this.options[e] = n[e];
2159
+ ({comment: v, escape: y, quote: b} = this.options);
2160
+ break;
2161
+ }
2162
+ this.state.bomSkipped = !0;
2163
+ }
2164
+ let ie = w.length, T;
2165
+ for (T = 0; T < ie && !this.__needMoreData(T, ie, t); T++) {
2166
+ if (this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1), g !== -1 && this.info.lines > g) {
2167
+ this.state.stop = !0, r();
2168
+ return;
2169
+ }
2170
+ this.state.quoting === !1 && x.length === 0 && this.__autoDiscoverRecordDelimiter(w, T) && (x = this.options.record_delimiter);
2171
+ let e = w[T];
2172
+ if (d === !0 && ne.append(e), (e === Yn || e === Xn) && this.state.wasRowDelimiter === !1 && (this.state.wasRowDelimiter = !0), this.state.escaping === !0) this.state.escaping = !1;
2173
+ else {
2174
+ if (y !== null && this.state.quoting === !0 && this.__isEscape(w, T, e) && T + y.length < ie) if (re) {
2175
+ if (this.__isQuote(w, T + y.length)) {
2176
+ this.state.escaping = !0, T += y.length - 1;
2177
+ continue;
2178
+ }
2179
+ } else {
2180
+ this.state.escaping = !0, T += y.length - 1;
2181
+ continue;
2182
+ }
2183
+ if (this.state.commenting === !1 && this.__isQuote(w, T)) if (this.state.quoting === !0) {
2184
+ let t = w[T + b.length], n = p && this.__isCharTrimable(w, T + b.length), r = v !== null && this.__compareBytes(v, w, T + b.length, t), i = this.__isDelimiter(w, T + b.length, t), a = x.length === 0 ? this.__autoDiscoverRecordDelimiter(w, T + b.length) : this.__isRecordDelimiter(t, w, T + b.length);
2185
+ if (y !== null && this.__isEscape(w, T, e) && this.__isQuote(w, T + y.length)) T += y.length - 1;
2186
+ else if (!t || i || a || r || n) {
2187
+ this.state.quoting = !1, this.state.wasQuoting = !0, T += b.length - 1;
2188
+ continue;
2189
+ } else if (f === !1) {
2190
+ let e = this.__error(new Q("CSV_INVALID_CLOSING_QUOTE", [
2191
+ "Invalid Closing Quote:",
2192
+ `got "${String.fromCharCode(t)}"`,
2193
+ `at line ${this.info.lines}`,
2194
+ "instead of delimiter, record delimiter, trimable character",
2195
+ "(if activated) or comment"
2196
+ ], this.options, this.__infoField()));
2197
+ if (e !== void 0) return e;
2198
+ } else this.state.quoting = !1, this.state.wasQuoting = !0, this.state.field.prepend(b), T += b.length - 1;
2199
+ } else if (this.state.field.length !== 0) {
2200
+ if (f === !1) {
2201
+ let e = this.__infoField(), t = Object.keys($).map((e) => $[e].equals(this.state.field.toString()) ? e : !1).filter(Boolean)[0], n = this.__error(new Q("INVALID_OPENING_QUOTE", [
2202
+ "Invalid Opening Quote:",
2203
+ `a quote is found on field ${JSON.stringify(e.column)} at line ${e.lines}, value is ${JSON.stringify(this.state.field.toString(s))}`,
2204
+ t ? `(${t} bom)` : void 0
2205
+ ], this.options, e, { field: this.state.field }));
2206
+ if (n !== void 0) return n;
2207
+ }
2208
+ } else {
2209
+ this.state.quoting = !0, T += b.length - 1;
2210
+ continue;
2211
+ }
2212
+ if (this.state.quoting === !1) {
2213
+ let t = this.__isRecordDelimiter(e, w, T);
2214
+ if (t !== 0) {
2215
+ if (this.state.commenting && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0) this.info.comment_lines++;
2216
+ else {
2217
+ if (this.state.enabled === !1 && this.info.lines + +(this.state.wasRowDelimiter === !0) >= c) {
2218
+ this.state.enabled = !0, this.__resetField(), this.__resetRecord(), T += t - 1;
2219
+ continue;
2220
+ }
2221
+ if (m === !0 && this.state.wasQuoting === !1 && this.state.record.length === 0 && this.state.field.length === 0) {
2222
+ this.info.empty_lines++, T += t - 1;
2223
+ continue;
2224
+ }
2225
+ this.info.bytes = this.state.bufBytesStart + T;
2226
+ let e = this.__onField();
2227
+ if (e !== void 0) return e;
2228
+ this.info.bytes = this.state.bufBytesStart + T + t;
2229
+ let i = this.__onRecord(n);
2230
+ if (i !== void 0) return i;
2231
+ if (h !== -1 && this.info.records >= h) {
2232
+ this.state.stop = !0, r();
2233
+ return;
2234
+ }
2235
+ }
2236
+ this.state.commenting = !1, T += t - 1;
2237
+ continue;
2238
+ }
2239
+ if (this.state.commenting) continue;
2240
+ if (v !== null && (a === !1 || this.state.record.length === 0 && this.state.field.length === 0) && this.__compareBytes(v, w, T, e) !== 0) {
2241
+ this.state.commenting = !0;
2242
+ continue;
2243
+ }
2244
+ let i = this.__isDelimiter(w, T, e);
2245
+ if (i !== 0) {
2246
+ this.info.bytes = this.state.bufBytesStart + T;
2247
+ let e = this.__onField();
2248
+ if (e !== void 0) return e;
2249
+ T += i - 1;
2250
+ continue;
2251
+ }
2252
+ }
2253
+ }
2254
+ if (this.state.commenting === !1 && u !== 0 && this.state.record_length + this.state.field.length > u) return this.__error(new Q("CSV_MAX_RECORD_SIZE", [
2255
+ "Max Record Size:",
2256
+ "record exceed the maximum number of tolerated bytes",
2257
+ `of ${u}`,
2258
+ `at line ${this.info.lines}`
2259
+ ], this.options, this.__infoField()));
2260
+ let t = l === !1 || this.state.quoting === !0 || this.state.field.length !== 0 || !this.__isCharTrimable(w, T), i = p === !1 || this.state.wasQuoting === !1;
2261
+ if (t === !0 && i === !0) this.state.field.append(e);
2262
+ else if (p === !0 && !this.__isCharTrimable(w, T)) return this.__error(new Q("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE", [
2263
+ "Invalid Closing Quote:",
2264
+ "found non trimable byte after quote",
2265
+ `at line ${this.info.lines}`
2266
+ ], this.options, this.__infoField()));
2267
+ else {
2268
+ t === !1 && (T += this.__isCharTrimable(w, T) - 1);
2269
+ continue;
2270
+ }
2271
+ }
2272
+ if (t === !0) if (this.state.quoting === !0) {
2273
+ let e = this.__error(new Q("CSV_QUOTE_NOT_CLOSED", ["Quote Not Closed:", `the parsing is finished with an opening quote at line ${this.info.lines}`], this.options, this.__infoField()));
2274
+ if (e !== void 0) return e;
2275
+ } else if (this.state.wasQuoting === !0 || this.state.record.length !== 0 || this.state.field.length !== 0) {
2276
+ this.info.bytes = this.state.bufBytesStart + T;
2277
+ let e = this.__onField();
2278
+ if (e !== void 0) return e;
2279
+ let t = this.__onRecord(n);
2280
+ if (t !== void 0) return t;
2281
+ } else this.state.wasRowDelimiter === !0 ? this.info.empty_lines++ : this.state.commenting === !0 && this.info.comment_lines++;
2282
+ else this.state.bufBytesStart += T, this.state.previousBuf = w.slice(T);
2283
+ this.state.wasRowDelimiter === !0 && (this.info.lines++, this.state.wasRowDelimiter = !1);
2284
+ },
2285
+ __onRecord: function(e) {
2286
+ let { columns: t, group_columns_by_name: n, encoding: r, info: i, from: a, relax_column_count: o, relax_column_count_less: s, relax_column_count_more: c, raw: l, skip_records_with_empty_values: u } = this.options, { enabled: d, record: f } = this.state;
2287
+ if (d === !1) return this.__resetRecord();
2288
+ let p = f.length;
2289
+ if (t === !0) {
2290
+ if (u === !0 && Jn(f)) {
2291
+ this.__resetRecord();
2292
+ return;
2293
+ }
2294
+ return this.__firstLineToColumns(f);
2295
+ }
2296
+ if (t === !1 && this.info.records === 0 && (this.state.expectedRecordLength = p), p !== this.state.expectedRecordLength) {
2297
+ let e = t === !1 ? new Q("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH", [
2298
+ "Invalid Record Length:",
2299
+ `expect ${this.state.expectedRecordLength},`,
2300
+ `got ${p} on line ${this.info.lines}`
2301
+ ], this.options, this.__infoField(), { record: f }) : new Q("CSV_RECORD_INCONSISTENT_COLUMNS", [
2302
+ "Invalid Record Length:",
2303
+ `columns length is ${t.length},`,
2304
+ `got ${p} on line ${this.info.lines}`
2305
+ ], this.options, this.__infoField(), { record: f });
2306
+ if (o === !0 || s === !0 && p < this.state.expectedRecordLength || c === !0 && p > this.state.expectedRecordLength) this.info.invalid_field_length++, this.state.error = e;
2307
+ else {
2308
+ let t = this.__error(e);
2309
+ if (t) return t;
2310
+ }
2311
+ }
2312
+ if (u === !0 && Jn(f)) {
2313
+ this.__resetRecord();
2314
+ return;
2315
+ }
2316
+ if (this.state.recordHasError === !0) {
2317
+ this.__resetRecord(), this.state.recordHasError = !1;
2318
+ return;
2319
+ }
2320
+ if (this.info.records++, a === 1 || this.info.records >= a) {
2321
+ let { objname: a } = this.options;
2322
+ if (t !== !1) {
2323
+ let o = {};
2324
+ for (let e = 0, r = f.length; e < r; e++) t[e] === void 0 || t[e].disabled || (n === !0 && o[t[e].name] !== void 0 ? Array.isArray(o[t[e].name]) ? o[t[e].name] = o[t[e].name].concat(f[e]) : o[t[e].name] = [o[t[e].name], f[e]] : o[t[e].name] = f[e]);
2325
+ if (l === !0 || i === !0) {
2326
+ let t = Object.assign({ record: o }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [o[a], t], e);
2327
+ if (n) return n;
2328
+ } else {
2329
+ let t = this.__push(a === void 0 ? o : [o[a], o], e);
2330
+ if (t) return t;
2331
+ }
2332
+ } else if (l === !0 || i === !0) {
2333
+ let t = Object.assign({ record: f }, l === !0 ? { raw: this.state.rawBuffer.toString(r) } : {}, i === !0 ? { info: this.__infoRecord() } : {}), n = this.__push(a === void 0 ? t : [f[a], t], e);
2334
+ if (n) return n;
2335
+ } else {
2336
+ let t = this.__push(a === void 0 ? f : [f[a], f], e);
2337
+ if (t) return t;
2338
+ }
2339
+ }
2340
+ this.__resetRecord();
2341
+ },
2342
+ __firstLineToColumns: function(e) {
2343
+ let { firstLineToHeaders: t } = this.state;
2344
+ try {
2345
+ let n = t === void 0 ? e : t.call(null, e);
2346
+ if (!Array.isArray(n)) return this.__error(new Q("CSV_INVALID_COLUMN_MAPPING", [
2347
+ "Invalid Column Mapping:",
2348
+ "expect an array from column function,",
2349
+ `got ${JSON.stringify(n)}`
2350
+ ], this.options, this.__infoField(), { headers: n }));
2351
+ let r = Vn(n);
2352
+ this.state.expectedRecordLength = r.length, this.options.columns = r, this.__resetRecord();
2353
+ return;
2354
+ } catch (e) {
2355
+ return e;
2356
+ }
2357
+ },
2358
+ __resetRecord: function() {
2359
+ this.options.raw === !0 && this.state.rawBuffer.reset(), this.state.error = void 0, this.state.record = [], this.state.record_length = 0;
2360
+ },
2361
+ __onField: function() {
2362
+ let { cast: e, encoding: t, rtrim: n, max_record_size: r } = this.options, { enabled: i, wasQuoting: a } = this.state;
2363
+ if (i === !1) return this.__resetField();
2364
+ let o = this.state.field.toString(t);
2365
+ if (n === !0 && a === !1 && (o = o.trimRight()), e === !0) {
2366
+ let [e, t] = this.__cast(o);
2367
+ if (e !== void 0) return e;
2368
+ o = t;
2369
+ }
2370
+ this.state.record.push(o), r !== 0 && typeof o == "string" && (this.state.record_length += o.length), this.__resetField();
2371
+ },
2372
+ __resetField: function() {
2373
+ this.state.field.reset(), this.state.wasQuoting = !1;
2374
+ },
2375
+ __push: function(e, t) {
2376
+ let { on_record: n } = this.options;
2377
+ if (n !== void 0) {
2378
+ let t = this.__infoRecord();
2379
+ try {
2380
+ e = n.call(null, e, t);
2381
+ } catch (e) {
2382
+ return e;
2383
+ }
2384
+ if (e == null) return;
2385
+ }
2386
+ this.info.bytes_records += this.info.bytes, t(e);
2387
+ },
2388
+ __cast: function(e) {
2389
+ let { columns: t, relax_column_count: n } = this.options;
2390
+ if (Array.isArray(t) === !0 && n && this.options.columns.length <= this.state.record.length) return [void 0, void 0];
2391
+ if (this.state.castField !== null) try {
2392
+ let t = this.__infoField();
2393
+ return [void 0, this.state.castField.call(null, e, t)];
2394
+ } catch (e) {
2395
+ return [e];
2396
+ }
2397
+ if (this.__isFloat(e)) return [void 0, parseFloat(e)];
2398
+ if (this.options.cast_date !== !1) {
2399
+ let t = this.__infoField();
2400
+ return [void 0, this.options.cast_date.call(null, e, t)];
2401
+ }
2402
+ return [void 0, e];
2403
+ },
2404
+ __compareBytes: function(e, t, n, r) {
2405
+ if (e[0] !== r) return 0;
2406
+ let i = e.length;
2407
+ for (let r = 1; r < i; r++) if (e[r] !== t[n + r]) return 0;
2408
+ return i;
2409
+ },
2410
+ __isCharTrimable: function(e, t) {
2411
+ let { timchars: n, timcharFirstBytes: r } = this.state, i = e[t];
2412
+ if (i === void 0 || r[i] === 0) return 0;
2413
+ loop1: for (let r = 0; r < n.length; r++) {
2414
+ let i = n[r];
2415
+ for (let n = 0; n < i.length; n++) if (i[n] !== e[t + n]) continue loop1;
2416
+ return i.length;
2417
+ }
2418
+ return 0;
2419
+ },
2420
+ __isDelimiter: function(e, t, n) {
2421
+ let { delimiter: r, ignore_last_delimiters: i } = this.options;
2422
+ if (i === !0 && this.state.record.length === this.options.columns.length - 1 || i !== !1 && typeof i == "number" && this.state.record.length === i - 1) return 0;
2423
+ loop1: for (let i = 0; i < r.length; i++) {
2424
+ let a = r[i];
2425
+ if (a[0] === n) {
2426
+ for (let n = 1; n < a.length; n++) if (a[n] !== e[t + n]) continue loop1;
2427
+ return a.length;
2428
+ }
2429
+ }
2430
+ return 0;
2431
+ },
2432
+ __isEscape: function(e, t, n) {
2433
+ let { escape: r } = this.options;
2434
+ if (r === null) return !1;
2435
+ let i = r.length;
2436
+ if (r[0] === n) {
2437
+ for (let n = 0; n < i; n++) if (r[n] !== e[t + n]) return !1;
2438
+ return !0;
2439
+ }
2440
+ return !1;
2441
+ },
2442
+ __isFloat: function(e) {
2443
+ return e - parseFloat(e) + 1 >= 0;
2444
+ },
2445
+ __isQuote: function(e, t) {
2446
+ let { quote: n } = this.options;
2447
+ if (n === null) return !1;
2448
+ let r = n.length;
2449
+ for (let i = 0; i < r; i++) if (n[i] !== e[t + i]) return !1;
2450
+ return !0;
2451
+ },
2452
+ __isRecordDelimiter: function(e, t, n) {
2453
+ let { record_delimiter: r } = this.options, i = r.length;
2454
+ loop1: for (let a = 0; a < i; a++) {
2455
+ let i = r[a], o = i.length;
2456
+ if (i[0] === e) {
2457
+ for (let e = 1; e < o; e++) if (i[e] !== t[n + e]) continue loop1;
2458
+ return i.length;
2459
+ }
2460
+ }
2461
+ return 0;
2462
+ },
2463
+ __autoDiscoverRecordDelimiter: function(e, t) {
2464
+ let { encoding: n } = this.options, r = [
2465
+ _.from("\r\n", n),
2466
+ _.from("\n", n),
2467
+ _.from("\r", n)
2468
+ ];
2469
+ loop: for (let n = 0; n < r.length; n++) {
2470
+ let i = r[n].length;
2471
+ for (let a = 0; a < i; a++) if (r[n][a] !== e[t + a]) continue loop;
2472
+ return this.options.record_delimiter.push(r[n]), this.state.recordDelimiterMaxLength = r[n].length, r[n].length;
2473
+ }
2474
+ return 0;
2475
+ },
2476
+ __error: function(e) {
2477
+ let { encoding: t, raw: n, skip_records_with_error: r } = this.options, i = typeof e == "string" ? Error(e) : e;
2478
+ if (r) {
2479
+ if (this.state.recordHasError = !0, this.options.on_skip !== void 0) try {
2480
+ this.options.on_skip(i, n ? this.state.rawBuffer.toString(t) : void 0);
2481
+ } catch (e) {
2482
+ return e;
2483
+ }
2484
+ return;
2485
+ }
2486
+ return i;
2487
+ },
2488
+ __infoDataSet: function() {
2489
+ return {
2490
+ ...this.info,
2491
+ columns: this.options.columns
2492
+ };
2493
+ },
2494
+ __infoRecord: function() {
2495
+ let { columns: e, raw: t, encoding: n } = this.options;
2496
+ return {
2497
+ ...this.__infoDataSet(),
2498
+ bytes_records: this.info.bytes,
2499
+ error: this.state.error,
2500
+ header: e === !0,
2501
+ index: this.state.record.length,
2502
+ raw: t ? this.state.rawBuffer.toString(n) : void 0
2503
+ };
2504
+ },
2505
+ __infoField: function() {
2506
+ let { columns: e } = this.options, t = Array.isArray(e), n = this.info.bytes_records;
2507
+ return {
2508
+ ...this.__infoRecord(),
2509
+ bytes_records: n,
2510
+ column: t === !0 ? e.length > this.state.record.length ? e[this.state.record.length].name : null : this.state.record.length,
2511
+ quoting: this.state.wasQuoting
2512
+ };
2513
+ }
2514
+ };
2515
+ }, Qn = class extends Y {
2516
+ constructor(e = {}) {
2517
+ super({
2518
+ readableObjectMode: !0,
2519
+ ...e,
2520
+ encoding: null
2521
+ }), this.api = Zn({
2522
+ on_skip: (e, t) => {
2523
+ this.emit("skip", e, t);
2524
+ },
2525
+ ...e
2526
+ }), this.state = this.api.state, this.options = this.api.options, this.info = this.api.info;
2527
+ }
2528
+ _transform(e, t, n) {
2529
+ if (this.state.stop === !0) return;
2530
+ let r = this.api.parse(e, !1, (e) => {
2531
+ this.push(e);
2532
+ }, () => {
2533
+ this.push(null), this.end(), this.on("end", this.destroy);
2534
+ });
2535
+ r !== void 0 && (this.state.stop = !0), n(r);
2536
+ }
2537
+ _flush(e) {
2538
+ this.state.stop !== !0 && e(this.api.parse(void 0, !0, (e) => {
2539
+ this.push(e);
2540
+ }, () => {
2541
+ this.push(null), this.on("end", this.destroy);
2542
+ }));
2543
+ }
2544
+ }, $n = function() {
2545
+ let e, t, n;
2546
+ for (let r in arguments) {
2547
+ let i = arguments[r], a = typeof i;
2548
+ if (e === void 0 && (typeof i == "string" || O(i))) e = i;
2549
+ else if (t === void 0 && Bn(i)) t = i;
2550
+ else if (n === void 0 && a === "function") n = i;
2551
+ else throw new Q("CSV_INVALID_ARGUMENT", ["Invalid argument:", `got ${JSON.stringify(i)} at index ${r}`], t || {});
2552
+ }
2553
+ let r = new Qn(t);
2554
+ if (n) {
2555
+ let e = t === void 0 || t.objname === void 0 ? [] : Object.create(null);
2556
+ r.on("readable", function() {
2557
+ let n;
2558
+ for (; (n = this.read()) !== null;) t === void 0 || t.objname === void 0 ? e.push(n) : Object.assign(e, { [n[0]]: n[1] });
2559
+ }), r.on("error", function(e) {
2560
+ n(e, void 0, r.api.__infoDataSet());
2561
+ }), r.on("end", function() {
2562
+ n(void 0, e, r.api.__infoDataSet());
2563
+ });
2564
+ }
2565
+ if (e !== void 0) {
2566
+ let t = function() {
2567
+ r.write(e), r.end();
2568
+ };
2569
+ typeof setImmediate == "function" ? setImmediate(t) : setTimeout(t, 0);
2570
+ }
2571
+ return r;
2572
+ }, er = 2048, tr = class extends Error {
2573
+ data;
2574
+ locator;
2575
+ constructor(e, t, n, r) {
2576
+ super(e, r), this.name = "DPUseError", this.data = n, this.locator = t;
2577
+ }
2578
+ }, nr = class extends tr {
2579
+ constructor(e, t, n, r) {
2580
+ super(e, t, n, r), this.name = "FetchError";
2581
+ }
2582
+ };
2583
+ async function rr(e, t, n) {
2584
+ let r = ` - ${e.statusText}`, i = `${t} Response status '${String(e.status)}${e.statusText ? r : ""}' received.`, a;
2585
+ try {
2586
+ a = await e.text();
2587
+ } catch (e) {
2588
+ a = `<body unavailable: ${ar(e).message}>`;
2589
+ }
2590
+ return new nr(i, n, { body: or(a) });
2591
+ }
2592
+ function ir(e) {
2593
+ try {
2594
+ e();
2595
+ } catch {}
2596
+ }
2597
+ function ar(e) {
2598
+ if (e instanceof Error) return e;
2599
+ if (typeof e == "string") return Error(e);
2600
+ if (typeof e == "number" || typeof e == "boolean" || typeof e == "bigint") return Error(String(e));
2601
+ if (typeof e == "symbol") return Error(e.description ?? "Unknown error");
2602
+ if (typeof e == "object") try {
2603
+ return Error(JSON.stringify(e));
2604
+ } catch {
2605
+ return /* @__PURE__ */ Error("Unknown error");
2606
+ }
2607
+ return /* @__PURE__ */ Error("Unknown error");
2608
+ }
2609
+ function or(e) {
2610
+ if (e != null && e !== "") return e.length > er ? `${e.slice(0, er)}... [truncated]` : e;
2611
+ }
2612
+ //#endregion
2613
+ //#region src/index.ts
2614
+ var sr = {
2615
+ bom: !1,
2616
+ cast_date: !1,
2617
+ columns: !1,
2618
+ comment: "",
2619
+ comment_no_infix: !1,
2620
+ delimiter: ",",
2621
+ encoding: "utf8",
2622
+ escape: "\"",
2623
+ from: 1,
2624
+ from_line: 1,
2625
+ group_columns_by_name: !1,
2626
+ ignore_last_delimiters: !1,
2627
+ info: !1,
2628
+ ltrim: !1,
2629
+ max_record_size: 0,
2630
+ quote: "\"",
2631
+ raw: !1,
2632
+ record_delimiter: [],
2633
+ relax_column_count: !1,
2634
+ relax_column_count_less: !1,
2635
+ relax_column_count_more: !1,
2636
+ relax_quotes: !1,
2637
+ rtrim: !1,
2638
+ skip_empty_lines: !1,
2639
+ skip_records_with_empty_values: !1,
2640
+ skip_records_with_error: !1,
2641
+ to_line: -1,
2642
+ trim: !1
2643
+ }, cr = 4, lr = 1e4, ur = class {
2644
+ async parseStream(e, t, n, r, i) {
2645
+ return new Promise((a, o) => {
2646
+ let s, c, l, u = !1, d = !1, f = () => {
2647
+ if (d) return;
2648
+ d = !0;
2649
+ let e = s;
2650
+ s = void 0, l = void 0, e != null && (ir(() => e.removeAllListeners()), ir(() => e.end())), ir(() => void c?.cancel()), c = void 0;
2651
+ };
2652
+ r.signal.addEventListener("abort", f, { once: !0 });
2653
+ let p = (e) => {
2654
+ u || (u = !0, f(), r.signal.aborted || r.abort(e), o(e instanceof Error ? e : Error(String(e))));
2655
+ };
2656
+ (async () => {
2657
+ s = $n({
2658
+ ...sr,
2659
+ ...t,
2660
+ cast: (e, t) => ({
2661
+ value: e,
2662
+ wasValueQuoted: t.quoting
2663
+ })
2664
+ }), l = dr({
2665
+ chunk: i,
2666
+ chunkSize: e.chunkSize ?? lr
2667
+ }), s.on("readable", () => {
2668
+ try {
2669
+ if (s == null || l == null) return;
2670
+ let e;
2671
+ for (; (e = s.read()) != null;) {
2672
+ if (u) return;
2673
+ r.signal.throwIfAborted(), l.push(e);
2674
+ }
2675
+ } catch (e) {
2676
+ p(e);
2677
+ }
2678
+ }), s.on("error", (e) => {
2679
+ p(e);
2680
+ }), s.on("end", () => {
2681
+ u || (l?.flush(), a(fr(s)));
2682
+ });
2683
+ let o = await fetch(encodeURI(n), { signal: r.signal });
2684
+ if (!o.ok || o.body == null) throw await rr(o, `Failed to fetch '${n}' file.`, "dpuse-connector-file-store-emulator|Connector|retrieve");
2685
+ c = o.body.getReader();
2686
+ let d = new TextDecoder(e.encodingId), f = await c.read();
2687
+ for (; !f.done;) {
2688
+ if (u) return;
2689
+ r.signal.throwIfAborted();
2690
+ let e = d.decode(f.value, { stream: !0 });
2691
+ e.length > 0 && s.write(e), f = await c.read();
2692
+ }
2693
+ if (u) return;
2694
+ let m = d.decode();
2695
+ m.length > 0 && s.write(m), s.end();
2696
+ })().catch((e) => {
2697
+ p(e);
2698
+ });
2699
+ });
2700
+ }
2701
+ async parseText(e, t) {
2702
+ let n = pr(e), { parsedRecords: r, valueDelimiterId: i } = await mr(e, t);
2703
+ return {
2704
+ parsedRecords: r,
2705
+ recordDelimiterId: n,
2706
+ valueDelimiterId: i
2707
+ };
2708
+ }
2709
+ };
2710
+ function dr(e) {
2711
+ let t = Math.max(1, Math.floor(e.chunkSize)), n = [], r = o(), i = 0, a = () => {
2712
+ if (i === 0) return;
2713
+ let t = r;
2714
+ t.length = i, r = o(), i = 0, e.chunk("parsingRecordArray", t), n.length < cr && n.push(t);
2715
+ };
2716
+ return {
2717
+ flush: a,
2718
+ push: (e) => {
2719
+ r[i++] = e, i >= t && a();
2720
+ }
2721
+ };
2722
+ function o() {
2723
+ let e = n.pop();
2724
+ if (e != null) return e.length = 0, e;
2725
+ let r = Array.from({ length: t });
2726
+ return r.length = 0, r;
2727
+ }
2728
+ }
2729
+ function fr(e) {
2730
+ return {
2731
+ byteCount: e?.info.bytes ?? -1,
2732
+ commentLineCount: e?.info.comment_lines ?? -1,
2733
+ emptyLineCount: e?.info.empty_lines ?? -1,
2734
+ nonUniformRecordCount: e?.info.invalid_field_length ?? -1,
2735
+ lineCount: e?.info.lines ?? -1,
2736
+ recordCount: e?.info.records ?? -1
2737
+ };
2738
+ }
2739
+ function pr(e) {
2740
+ let t = (e.match(/\r\n/g) ?? []).length, n = (e.match(/(?<!\r)\n/g) ?? []).length, r = (e.match(/\r(?!\n)/g) ?? []).length;
2741
+ return t >= n && t >= r ? "\r\n" : n >= t && n >= r ? "\n" : r >= t && r >= n ? "\r" : "\n";
2742
+ }
2743
+ async function mr(e, t) {
2744
+ let n, r, i, a = [];
2745
+ for (let o of t) try {
2746
+ let t = 0, s, c = 0, l = 0, u = $n({
2747
+ ...sr,
2748
+ cast: (e, t) => ({
2749
+ value: e,
2750
+ wasValueQuoted: t.quoting
2751
+ }),
2752
+ delimiter: o,
2753
+ relax_column_count: !0
2754
+ });
2755
+ await new Promise((d) => {
2756
+ try {
2757
+ let f = [];
2758
+ u.on("readable", () => {
2759
+ let e;
2760
+ for (; (e = u.read()) != null;) {
2761
+ c++;
2762
+ let n = e.length;
2763
+ s != null && (l += Math.abs(n - s)), s = n, t += n, f.push(e);
2764
+ }
2765
+ }), u.on("error", () => {
2766
+ d();
2767
+ }), u.on("end", () => {
2768
+ let e = t / c;
2769
+ (!i || l <= i) && (!r || e > r) && (n = o, r = e, i = l, a = [...f]), d();
2770
+ }), u.write(e), u.end();
2771
+ } catch {
2772
+ d();
2773
+ }
2774
+ });
2775
+ } catch {}
2776
+ return {
2777
+ parsedRecords: a,
2778
+ valueDelimiterId: n ?? ","
2779
+ };
2780
+ }
2781
+ //#endregion
2782
+ export { ur as Tool };
2783
+
2784
+ //# sourceMappingURL=dpuse-tool-adaltas-csv-parser.es.js.map