sub-store-convert 2.36.27 → 2.39.6

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.
Files changed (2) hide show
  1. package/index.js +2313 -454
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,3 +1,1809 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ try {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ } catch (e) {
11
+ throw mod = 0, e;
12
+ }
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+
31
+ // ../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js
32
+ var require_base64_js = __commonJS({
33
+ "../../node_modules/.pnpm/base64-js@1.5.1/node_modules/base64-js/index.js"(exports) {
34
+ "use strict";
35
+ exports.byteLength = byteLength;
36
+ exports.toByteArray = toByteArray;
37
+ exports.fromByteArray = fromByteArray;
38
+ var lookup = [];
39
+ var revLookup = [];
40
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
41
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
42
+ for (i = 0, len = code.length; i < len; ++i) {
43
+ lookup[i] = code[i];
44
+ revLookup[code.charCodeAt(i)] = i;
45
+ }
46
+ var i;
47
+ var len;
48
+ revLookup["-".charCodeAt(0)] = 62;
49
+ revLookup["_".charCodeAt(0)] = 63;
50
+ function getLens(b64) {
51
+ var len2 = b64.length;
52
+ if (len2 % 4 > 0) {
53
+ throw new Error("Invalid string. Length must be a multiple of 4");
54
+ }
55
+ var validLen = b64.indexOf("=");
56
+ if (validLen === -1) validLen = len2;
57
+ var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
58
+ return [validLen, placeHoldersLen];
59
+ }
60
+ function byteLength(b64) {
61
+ var lens = getLens(b64);
62
+ var validLen = lens[0];
63
+ var placeHoldersLen = lens[1];
64
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
65
+ }
66
+ function _byteLength(b64, validLen, placeHoldersLen) {
67
+ return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
68
+ }
69
+ function toByteArray(b64) {
70
+ var tmp;
71
+ var lens = getLens(b64);
72
+ var validLen = lens[0];
73
+ var placeHoldersLen = lens[1];
74
+ var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen));
75
+ var curByte = 0;
76
+ var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
77
+ var i2;
78
+ for (i2 = 0; i2 < len2; i2 += 4) {
79
+ tmp = revLookup[b64.charCodeAt(i2)] << 18 | revLookup[b64.charCodeAt(i2 + 1)] << 12 | revLookup[b64.charCodeAt(i2 + 2)] << 6 | revLookup[b64.charCodeAt(i2 + 3)];
80
+ arr[curByte++] = tmp >> 16 & 255;
81
+ arr[curByte++] = tmp >> 8 & 255;
82
+ arr[curByte++] = tmp & 255;
83
+ }
84
+ if (placeHoldersLen === 2) {
85
+ tmp = revLookup[b64.charCodeAt(i2)] << 2 | revLookup[b64.charCodeAt(i2 + 1)] >> 4;
86
+ arr[curByte++] = tmp & 255;
87
+ }
88
+ if (placeHoldersLen === 1) {
89
+ tmp = revLookup[b64.charCodeAt(i2)] << 10 | revLookup[b64.charCodeAt(i2 + 1)] << 4 | revLookup[b64.charCodeAt(i2 + 2)] >> 2;
90
+ arr[curByte++] = tmp >> 8 & 255;
91
+ arr[curByte++] = tmp & 255;
92
+ }
93
+ return arr;
94
+ }
95
+ function tripletToBase64(num) {
96
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
97
+ }
98
+ function encodeChunk(uint8, start, end) {
99
+ var tmp;
100
+ var output = [];
101
+ for (var i2 = start; i2 < end; i2 += 3) {
102
+ tmp = (uint8[i2] << 16 & 16711680) + (uint8[i2 + 1] << 8 & 65280) + (uint8[i2 + 2] & 255);
103
+ output.push(tripletToBase64(tmp));
104
+ }
105
+ return output.join("");
106
+ }
107
+ function fromByteArray(uint8) {
108
+ var tmp;
109
+ var len2 = uint8.length;
110
+ var extraBytes = len2 % 3;
111
+ var parts = [];
112
+ var maxChunkLength = 16383;
113
+ for (var i2 = 0, len22 = len2 - extraBytes; i2 < len22; i2 += maxChunkLength) {
114
+ parts.push(encodeChunk(uint8, i2, i2 + maxChunkLength > len22 ? len22 : i2 + maxChunkLength));
115
+ }
116
+ if (extraBytes === 1) {
117
+ tmp = uint8[len2 - 1];
118
+ parts.push(
119
+ lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
120
+ );
121
+ } else if (extraBytes === 2) {
122
+ tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
123
+ parts.push(
124
+ lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
125
+ );
126
+ }
127
+ return parts.join("");
128
+ }
129
+ }
130
+ });
131
+
132
+ // ../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js
133
+ var require_ieee754 = __commonJS({
134
+ "../../node_modules/.pnpm/ieee754@1.2.1/node_modules/ieee754/index.js"(exports) {
135
+ exports.read = function(buffer, offset, isLE, mLen, nBytes) {
136
+ var e, m;
137
+ var eLen = nBytes * 8 - mLen - 1;
138
+ var eMax = (1 << eLen) - 1;
139
+ var eBias = eMax >> 1;
140
+ var nBits = -7;
141
+ var i = isLE ? nBytes - 1 : 0;
142
+ var d = isLE ? -1 : 1;
143
+ var s = buffer[offset + i];
144
+ i += d;
145
+ e = s & (1 << -nBits) - 1;
146
+ s >>= -nBits;
147
+ nBits += eLen;
148
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
149
+ }
150
+ m = e & (1 << -nBits) - 1;
151
+ e >>= -nBits;
152
+ nBits += mLen;
153
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
154
+ }
155
+ if (e === 0) {
156
+ e = 1 - eBias;
157
+ } else if (e === eMax) {
158
+ return m ? NaN : (s ? -1 : 1) * Infinity;
159
+ } else {
160
+ m = m + Math.pow(2, mLen);
161
+ e = e - eBias;
162
+ }
163
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
164
+ };
165
+ exports.write = function(buffer, value, offset, isLE, mLen, nBytes) {
166
+ var e, m, c;
167
+ var eLen = nBytes * 8 - mLen - 1;
168
+ var eMax = (1 << eLen) - 1;
169
+ var eBias = eMax >> 1;
170
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
171
+ var i = isLE ? 0 : nBytes - 1;
172
+ var d = isLE ? 1 : -1;
173
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
174
+ value = Math.abs(value);
175
+ if (isNaN(value) || value === Infinity) {
176
+ m = isNaN(value) ? 1 : 0;
177
+ e = eMax;
178
+ } else {
179
+ e = Math.floor(Math.log(value) / Math.LN2);
180
+ if (value * (c = Math.pow(2, -e)) < 1) {
181
+ e--;
182
+ c *= 2;
183
+ }
184
+ if (e + eBias >= 1) {
185
+ value += rt / c;
186
+ } else {
187
+ value += rt * Math.pow(2, 1 - eBias);
188
+ }
189
+ if (value * c >= 2) {
190
+ e++;
191
+ c /= 2;
192
+ }
193
+ if (e + eBias >= eMax) {
194
+ m = 0;
195
+ e = eMax;
196
+ } else if (e + eBias >= 1) {
197
+ m = (value * c - 1) * Math.pow(2, mLen);
198
+ e = e + eBias;
199
+ } else {
200
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
201
+ e = 0;
202
+ }
203
+ }
204
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
205
+ }
206
+ e = e << mLen | m;
207
+ eLen += mLen;
208
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
209
+ }
210
+ buffer[offset + i - d] |= s * 128;
211
+ };
212
+ }
213
+ });
214
+
215
+ // ../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js
216
+ var require_buffer = __commonJS({
217
+ "../../node_modules/.pnpm/buffer@6.0.3/node_modules/buffer/index.js"(exports) {
218
+ "use strict";
219
+ var base64 = require_base64_js();
220
+ var ieee754 = require_ieee754();
221
+ var customInspectSymbol = typeof Symbol === "function" && typeof Symbol["for"] === "function" ? Symbol["for"]("nodejs.util.inspect.custom") : null;
222
+ exports.Buffer = Buffer4;
223
+ exports.SlowBuffer = SlowBuffer;
224
+ exports.INSPECT_MAX_BYTES = 50;
225
+ var K_MAX_LENGTH = 2147483647;
226
+ exports.kMaxLength = K_MAX_LENGTH;
227
+ Buffer4.TYPED_ARRAY_SUPPORT = typedArraySupport();
228
+ if (!Buffer4.TYPED_ARRAY_SUPPORT && typeof console !== "undefined" && typeof console.error === "function") {
229
+ console.error(
230
+ "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
231
+ );
232
+ }
233
+ function typedArraySupport() {
234
+ try {
235
+ const arr = new Uint8Array(1);
236
+ const proto = { foo: function() {
237
+ return 42;
238
+ } };
239
+ Object.setPrototypeOf(proto, Uint8Array.prototype);
240
+ Object.setPrototypeOf(arr, proto);
241
+ return arr.foo() === 42;
242
+ } catch (e) {
243
+ return false;
244
+ }
245
+ }
246
+ Object.defineProperty(Buffer4.prototype, "parent", {
247
+ enumerable: true,
248
+ get: function() {
249
+ if (!Buffer4.isBuffer(this)) return void 0;
250
+ return this.buffer;
251
+ }
252
+ });
253
+ Object.defineProperty(Buffer4.prototype, "offset", {
254
+ enumerable: true,
255
+ get: function() {
256
+ if (!Buffer4.isBuffer(this)) return void 0;
257
+ return this.byteOffset;
258
+ }
259
+ });
260
+ function createBuffer(length) {
261
+ if (length > K_MAX_LENGTH) {
262
+ throw new RangeError('The value "' + length + '" is invalid for option "size"');
263
+ }
264
+ const buf = new Uint8Array(length);
265
+ Object.setPrototypeOf(buf, Buffer4.prototype);
266
+ return buf;
267
+ }
268
+ function Buffer4(arg, encodingOrOffset, length) {
269
+ if (typeof arg === "number") {
270
+ if (typeof encodingOrOffset === "string") {
271
+ throw new TypeError(
272
+ 'The "string" argument must be of type string. Received type number'
273
+ );
274
+ }
275
+ return allocUnsafe(arg);
276
+ }
277
+ return from(arg, encodingOrOffset, length);
278
+ }
279
+ Buffer4.poolSize = 8192;
280
+ function from(value, encodingOrOffset, length) {
281
+ if (typeof value === "string") {
282
+ return fromString(value, encodingOrOffset);
283
+ }
284
+ if (ArrayBuffer.isView(value)) {
285
+ return fromArrayView(value);
286
+ }
287
+ if (value == null) {
288
+ throw new TypeError(
289
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
290
+ );
291
+ }
292
+ if (isInstance(value, ArrayBuffer) || value && isInstance(value.buffer, ArrayBuffer)) {
293
+ return fromArrayBuffer(value, encodingOrOffset, length);
294
+ }
295
+ if (typeof SharedArrayBuffer !== "undefined" && (isInstance(value, SharedArrayBuffer) || value && isInstance(value.buffer, SharedArrayBuffer))) {
296
+ return fromArrayBuffer(value, encodingOrOffset, length);
297
+ }
298
+ if (typeof value === "number") {
299
+ throw new TypeError(
300
+ 'The "value" argument must not be of type number. Received type number'
301
+ );
302
+ }
303
+ const valueOf = value.valueOf && value.valueOf();
304
+ if (valueOf != null && valueOf !== value) {
305
+ return Buffer4.from(valueOf, encodingOrOffset, length);
306
+ }
307
+ const b = fromObject(value);
308
+ if (b) return b;
309
+ if (typeof Symbol !== "undefined" && Symbol.toPrimitive != null && typeof value[Symbol.toPrimitive] === "function") {
310
+ return Buffer4.from(value[Symbol.toPrimitive]("string"), encodingOrOffset, length);
311
+ }
312
+ throw new TypeError(
313
+ "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value
314
+ );
315
+ }
316
+ Buffer4.from = function(value, encodingOrOffset, length) {
317
+ return from(value, encodingOrOffset, length);
318
+ };
319
+ Object.setPrototypeOf(Buffer4.prototype, Uint8Array.prototype);
320
+ Object.setPrototypeOf(Buffer4, Uint8Array);
321
+ function assertSize(size) {
322
+ if (typeof size !== "number") {
323
+ throw new TypeError('"size" argument must be of type number');
324
+ } else if (size < 0) {
325
+ throw new RangeError('The value "' + size + '" is invalid for option "size"');
326
+ }
327
+ }
328
+ function alloc(size, fill, encoding) {
329
+ assertSize(size);
330
+ if (size <= 0) {
331
+ return createBuffer(size);
332
+ }
333
+ if (fill !== void 0) {
334
+ return typeof encoding === "string" ? createBuffer(size).fill(fill, encoding) : createBuffer(size).fill(fill);
335
+ }
336
+ return createBuffer(size);
337
+ }
338
+ Buffer4.alloc = function(size, fill, encoding) {
339
+ return alloc(size, fill, encoding);
340
+ };
341
+ function allocUnsafe(size) {
342
+ assertSize(size);
343
+ return createBuffer(size < 0 ? 0 : checked(size) | 0);
344
+ }
345
+ Buffer4.allocUnsafe = function(size) {
346
+ return allocUnsafe(size);
347
+ };
348
+ Buffer4.allocUnsafeSlow = function(size) {
349
+ return allocUnsafe(size);
350
+ };
351
+ function fromString(string, encoding) {
352
+ if (typeof encoding !== "string" || encoding === "") {
353
+ encoding = "utf8";
354
+ }
355
+ if (!Buffer4.isEncoding(encoding)) {
356
+ throw new TypeError("Unknown encoding: " + encoding);
357
+ }
358
+ const length = byteLength(string, encoding) | 0;
359
+ let buf = createBuffer(length);
360
+ const actual = buf.write(string, encoding);
361
+ if (actual !== length) {
362
+ buf = buf.slice(0, actual);
363
+ }
364
+ return buf;
365
+ }
366
+ function fromArrayLike(array) {
367
+ const length = array.length < 0 ? 0 : checked(array.length) | 0;
368
+ const buf = createBuffer(length);
369
+ for (let i = 0; i < length; i += 1) {
370
+ buf[i] = array[i] & 255;
371
+ }
372
+ return buf;
373
+ }
374
+ function fromArrayView(arrayView) {
375
+ if (isInstance(arrayView, Uint8Array)) {
376
+ const copy = new Uint8Array(arrayView);
377
+ return fromArrayBuffer(copy.buffer, copy.byteOffset, copy.byteLength);
378
+ }
379
+ return fromArrayLike(arrayView);
380
+ }
381
+ function fromArrayBuffer(array, byteOffset, length) {
382
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
383
+ throw new RangeError('"offset" is outside of buffer bounds');
384
+ }
385
+ if (array.byteLength < byteOffset + (length || 0)) {
386
+ throw new RangeError('"length" is outside of buffer bounds');
387
+ }
388
+ let buf;
389
+ if (byteOffset === void 0 && length === void 0) {
390
+ buf = new Uint8Array(array);
391
+ } else if (length === void 0) {
392
+ buf = new Uint8Array(array, byteOffset);
393
+ } else {
394
+ buf = new Uint8Array(array, byteOffset, length);
395
+ }
396
+ Object.setPrototypeOf(buf, Buffer4.prototype);
397
+ return buf;
398
+ }
399
+ function fromObject(obj) {
400
+ if (Buffer4.isBuffer(obj)) {
401
+ const len = checked(obj.length) | 0;
402
+ const buf = createBuffer(len);
403
+ if (buf.length === 0) {
404
+ return buf;
405
+ }
406
+ obj.copy(buf, 0, 0, len);
407
+ return buf;
408
+ }
409
+ if (obj.length !== void 0) {
410
+ if (typeof obj.length !== "number" || numberIsNaN(obj.length)) {
411
+ return createBuffer(0);
412
+ }
413
+ return fromArrayLike(obj);
414
+ }
415
+ if (obj.type === "Buffer" && Array.isArray(obj.data)) {
416
+ return fromArrayLike(obj.data);
417
+ }
418
+ }
419
+ function checked(length) {
420
+ if (length >= K_MAX_LENGTH) {
421
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + K_MAX_LENGTH.toString(16) + " bytes");
422
+ }
423
+ return length | 0;
424
+ }
425
+ function SlowBuffer(length) {
426
+ if (+length != length) {
427
+ length = 0;
428
+ }
429
+ return Buffer4.alloc(+length);
430
+ }
431
+ Buffer4.isBuffer = function isBuffer(b) {
432
+ return b != null && b._isBuffer === true && b !== Buffer4.prototype;
433
+ };
434
+ Buffer4.compare = function compare(a, b) {
435
+ if (isInstance(a, Uint8Array)) a = Buffer4.from(a, a.offset, a.byteLength);
436
+ if (isInstance(b, Uint8Array)) b = Buffer4.from(b, b.offset, b.byteLength);
437
+ if (!Buffer4.isBuffer(a) || !Buffer4.isBuffer(b)) {
438
+ throw new TypeError(
439
+ 'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
440
+ );
441
+ }
442
+ if (a === b) return 0;
443
+ let x = a.length;
444
+ let y = b.length;
445
+ for (let i = 0, len = Math.min(x, y); i < len; ++i) {
446
+ if (a[i] !== b[i]) {
447
+ x = a[i];
448
+ y = b[i];
449
+ break;
450
+ }
451
+ }
452
+ if (x < y) return -1;
453
+ if (y < x) return 1;
454
+ return 0;
455
+ };
456
+ Buffer4.isEncoding = function isEncoding(encoding) {
457
+ switch (String(encoding).toLowerCase()) {
458
+ case "hex":
459
+ case "utf8":
460
+ case "utf-8":
461
+ case "ascii":
462
+ case "latin1":
463
+ case "binary":
464
+ case "base64":
465
+ case "ucs2":
466
+ case "ucs-2":
467
+ case "utf16le":
468
+ case "utf-16le":
469
+ return true;
470
+ default:
471
+ return false;
472
+ }
473
+ };
474
+ Buffer4.concat = function concat(list, length) {
475
+ if (!Array.isArray(list)) {
476
+ throw new TypeError('"list" argument must be an Array of Buffers');
477
+ }
478
+ if (list.length === 0) {
479
+ return Buffer4.alloc(0);
480
+ }
481
+ let i;
482
+ if (length === void 0) {
483
+ length = 0;
484
+ for (i = 0; i < list.length; ++i) {
485
+ length += list[i].length;
486
+ }
487
+ }
488
+ const buffer = Buffer4.allocUnsafe(length);
489
+ let pos = 0;
490
+ for (i = 0; i < list.length; ++i) {
491
+ let buf = list[i];
492
+ if (isInstance(buf, Uint8Array)) {
493
+ if (pos + buf.length > buffer.length) {
494
+ if (!Buffer4.isBuffer(buf)) buf = Buffer4.from(buf);
495
+ buf.copy(buffer, pos);
496
+ } else {
497
+ Uint8Array.prototype.set.call(
498
+ buffer,
499
+ buf,
500
+ pos
501
+ );
502
+ }
503
+ } else if (!Buffer4.isBuffer(buf)) {
504
+ throw new TypeError('"list" argument must be an Array of Buffers');
505
+ } else {
506
+ buf.copy(buffer, pos);
507
+ }
508
+ pos += buf.length;
509
+ }
510
+ return buffer;
511
+ };
512
+ function byteLength(string, encoding) {
513
+ if (Buffer4.isBuffer(string)) {
514
+ return string.length;
515
+ }
516
+ if (ArrayBuffer.isView(string) || isInstance(string, ArrayBuffer)) {
517
+ return string.byteLength;
518
+ }
519
+ if (typeof string !== "string") {
520
+ throw new TypeError(
521
+ 'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof string
522
+ );
523
+ }
524
+ const len = string.length;
525
+ const mustMatch = arguments.length > 2 && arguments[2] === true;
526
+ if (!mustMatch && len === 0) return 0;
527
+ let loweredCase = false;
528
+ for (; ; ) {
529
+ switch (encoding) {
530
+ case "ascii":
531
+ case "latin1":
532
+ case "binary":
533
+ return len;
534
+ case "utf8":
535
+ case "utf-8":
536
+ return utf8ToBytes(string).length;
537
+ case "ucs2":
538
+ case "ucs-2":
539
+ case "utf16le":
540
+ case "utf-16le":
541
+ return len * 2;
542
+ case "hex":
543
+ return len >>> 1;
544
+ case "base64":
545
+ return base64ToBytes(string).length;
546
+ default:
547
+ if (loweredCase) {
548
+ return mustMatch ? -1 : utf8ToBytes(string).length;
549
+ }
550
+ encoding = ("" + encoding).toLowerCase();
551
+ loweredCase = true;
552
+ }
553
+ }
554
+ }
555
+ Buffer4.byteLength = byteLength;
556
+ function slowToString(encoding, start, end) {
557
+ let loweredCase = false;
558
+ if (start === void 0 || start < 0) {
559
+ start = 0;
560
+ }
561
+ if (start > this.length) {
562
+ return "";
563
+ }
564
+ if (end === void 0 || end > this.length) {
565
+ end = this.length;
566
+ }
567
+ if (end <= 0) {
568
+ return "";
569
+ }
570
+ end >>>= 0;
571
+ start >>>= 0;
572
+ if (end <= start) {
573
+ return "";
574
+ }
575
+ if (!encoding) encoding = "utf8";
576
+ while (true) {
577
+ switch (encoding) {
578
+ case "hex":
579
+ return hexSlice(this, start, end);
580
+ case "utf8":
581
+ case "utf-8":
582
+ return utf8Slice(this, start, end);
583
+ case "ascii":
584
+ return asciiSlice(this, start, end);
585
+ case "latin1":
586
+ case "binary":
587
+ return latin1Slice(this, start, end);
588
+ case "base64":
589
+ return base64Slice(this, start, end);
590
+ case "ucs2":
591
+ case "ucs-2":
592
+ case "utf16le":
593
+ case "utf-16le":
594
+ return utf16leSlice(this, start, end);
595
+ default:
596
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
597
+ encoding = (encoding + "").toLowerCase();
598
+ loweredCase = true;
599
+ }
600
+ }
601
+ }
602
+ Buffer4.prototype._isBuffer = true;
603
+ function swap(b, n, m) {
604
+ const i = b[n];
605
+ b[n] = b[m];
606
+ b[m] = i;
607
+ }
608
+ Buffer4.prototype.swap16 = function swap16() {
609
+ const len = this.length;
610
+ if (len % 2 !== 0) {
611
+ throw new RangeError("Buffer size must be a multiple of 16-bits");
612
+ }
613
+ for (let i = 0; i < len; i += 2) {
614
+ swap(this, i, i + 1);
615
+ }
616
+ return this;
617
+ };
618
+ Buffer4.prototype.swap32 = function swap32() {
619
+ const len = this.length;
620
+ if (len % 4 !== 0) {
621
+ throw new RangeError("Buffer size must be a multiple of 32-bits");
622
+ }
623
+ for (let i = 0; i < len; i += 4) {
624
+ swap(this, i, i + 3);
625
+ swap(this, i + 1, i + 2);
626
+ }
627
+ return this;
628
+ };
629
+ Buffer4.prototype.swap64 = function swap64() {
630
+ const len = this.length;
631
+ if (len % 8 !== 0) {
632
+ throw new RangeError("Buffer size must be a multiple of 64-bits");
633
+ }
634
+ for (let i = 0; i < len; i += 8) {
635
+ swap(this, i, i + 7);
636
+ swap(this, i + 1, i + 6);
637
+ swap(this, i + 2, i + 5);
638
+ swap(this, i + 3, i + 4);
639
+ }
640
+ return this;
641
+ };
642
+ Buffer4.prototype.toString = function toString() {
643
+ const length = this.length;
644
+ if (length === 0) return "";
645
+ if (arguments.length === 0) return utf8Slice(this, 0, length);
646
+ return slowToString.apply(this, arguments);
647
+ };
648
+ Buffer4.prototype.toLocaleString = Buffer4.prototype.toString;
649
+ Buffer4.prototype.equals = function equals(b) {
650
+ if (!Buffer4.isBuffer(b)) throw new TypeError("Argument must be a Buffer");
651
+ if (this === b) return true;
652
+ return Buffer4.compare(this, b) === 0;
653
+ };
654
+ Buffer4.prototype.inspect = function inspect() {
655
+ let str = "";
656
+ const max = exports.INSPECT_MAX_BYTES;
657
+ str = this.toString("hex", 0, max).replace(/(.{2})/g, "$1 ").trim();
658
+ if (this.length > max) str += " ... ";
659
+ return "<Buffer " + str + ">";
660
+ };
661
+ if (customInspectSymbol) {
662
+ Buffer4.prototype[customInspectSymbol] = Buffer4.prototype.inspect;
663
+ }
664
+ Buffer4.prototype.compare = function compare(target, start, end, thisStart, thisEnd) {
665
+ if (isInstance(target, Uint8Array)) {
666
+ target = Buffer4.from(target, target.offset, target.byteLength);
667
+ }
668
+ if (!Buffer4.isBuffer(target)) {
669
+ throw new TypeError(
670
+ 'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof target
671
+ );
672
+ }
673
+ if (start === void 0) {
674
+ start = 0;
675
+ }
676
+ if (end === void 0) {
677
+ end = target ? target.length : 0;
678
+ }
679
+ if (thisStart === void 0) {
680
+ thisStart = 0;
681
+ }
682
+ if (thisEnd === void 0) {
683
+ thisEnd = this.length;
684
+ }
685
+ if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
686
+ throw new RangeError("out of range index");
687
+ }
688
+ if (thisStart >= thisEnd && start >= end) {
689
+ return 0;
690
+ }
691
+ if (thisStart >= thisEnd) {
692
+ return -1;
693
+ }
694
+ if (start >= end) {
695
+ return 1;
696
+ }
697
+ start >>>= 0;
698
+ end >>>= 0;
699
+ thisStart >>>= 0;
700
+ thisEnd >>>= 0;
701
+ if (this === target) return 0;
702
+ let x = thisEnd - thisStart;
703
+ let y = end - start;
704
+ const len = Math.min(x, y);
705
+ const thisCopy = this.slice(thisStart, thisEnd);
706
+ const targetCopy = target.slice(start, end);
707
+ for (let i = 0; i < len; ++i) {
708
+ if (thisCopy[i] !== targetCopy[i]) {
709
+ x = thisCopy[i];
710
+ y = targetCopy[i];
711
+ break;
712
+ }
713
+ }
714
+ if (x < y) return -1;
715
+ if (y < x) return 1;
716
+ return 0;
717
+ };
718
+ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
719
+ if (buffer.length === 0) return -1;
720
+ if (typeof byteOffset === "string") {
721
+ encoding = byteOffset;
722
+ byteOffset = 0;
723
+ } else if (byteOffset > 2147483647) {
724
+ byteOffset = 2147483647;
725
+ } else if (byteOffset < -2147483648) {
726
+ byteOffset = -2147483648;
727
+ }
728
+ byteOffset = +byteOffset;
729
+ if (numberIsNaN(byteOffset)) {
730
+ byteOffset = dir ? 0 : buffer.length - 1;
731
+ }
732
+ if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
733
+ if (byteOffset >= buffer.length) {
734
+ if (dir) return -1;
735
+ else byteOffset = buffer.length - 1;
736
+ } else if (byteOffset < 0) {
737
+ if (dir) byteOffset = 0;
738
+ else return -1;
739
+ }
740
+ if (typeof val === "string") {
741
+ val = Buffer4.from(val, encoding);
742
+ }
743
+ if (Buffer4.isBuffer(val)) {
744
+ if (val.length === 0) {
745
+ return -1;
746
+ }
747
+ return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
748
+ } else if (typeof val === "number") {
749
+ val = val & 255;
750
+ if (typeof Uint8Array.prototype.indexOf === "function") {
751
+ if (dir) {
752
+ return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
753
+ } else {
754
+ return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
755
+ }
756
+ }
757
+ return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
758
+ }
759
+ throw new TypeError("val must be string, number or Buffer");
760
+ }
761
+ function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
762
+ let indexSize = 1;
763
+ let arrLength = arr.length;
764
+ let valLength = val.length;
765
+ if (encoding !== void 0) {
766
+ encoding = String(encoding).toLowerCase();
767
+ if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
768
+ if (arr.length < 2 || val.length < 2) {
769
+ return -1;
770
+ }
771
+ indexSize = 2;
772
+ arrLength /= 2;
773
+ valLength /= 2;
774
+ byteOffset /= 2;
775
+ }
776
+ }
777
+ function read(buf, i2) {
778
+ if (indexSize === 1) {
779
+ return buf[i2];
780
+ } else {
781
+ return buf.readUInt16BE(i2 * indexSize);
782
+ }
783
+ }
784
+ let i;
785
+ if (dir) {
786
+ let foundIndex = -1;
787
+ for (i = byteOffset; i < arrLength; i++) {
788
+ if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
789
+ if (foundIndex === -1) foundIndex = i;
790
+ if (i - foundIndex + 1 === valLength) return foundIndex * indexSize;
791
+ } else {
792
+ if (foundIndex !== -1) i -= i - foundIndex;
793
+ foundIndex = -1;
794
+ }
795
+ }
796
+ } else {
797
+ if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength;
798
+ for (i = byteOffset; i >= 0; i--) {
799
+ let found = true;
800
+ for (let j = 0; j < valLength; j++) {
801
+ if (read(arr, i + j) !== read(val, j)) {
802
+ found = false;
803
+ break;
804
+ }
805
+ }
806
+ if (found) return i;
807
+ }
808
+ }
809
+ return -1;
810
+ }
811
+ Buffer4.prototype.includes = function includes(val, byteOffset, encoding) {
812
+ return this.indexOf(val, byteOffset, encoding) !== -1;
813
+ };
814
+ Buffer4.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
815
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
816
+ };
817
+ Buffer4.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
818
+ return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
819
+ };
820
+ function hexWrite(buf, string, offset, length) {
821
+ offset = Number(offset) || 0;
822
+ const remaining = buf.length - offset;
823
+ if (!length) {
824
+ length = remaining;
825
+ } else {
826
+ length = Number(length);
827
+ if (length > remaining) {
828
+ length = remaining;
829
+ }
830
+ }
831
+ const strLen = string.length;
832
+ if (length > strLen / 2) {
833
+ length = strLen / 2;
834
+ }
835
+ let i;
836
+ for (i = 0; i < length; ++i) {
837
+ const parsed = parseInt(string.substr(i * 2, 2), 16);
838
+ if (numberIsNaN(parsed)) return i;
839
+ buf[offset + i] = parsed;
840
+ }
841
+ return i;
842
+ }
843
+ function utf8Write(buf, string, offset, length) {
844
+ return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length);
845
+ }
846
+ function asciiWrite(buf, string, offset, length) {
847
+ return blitBuffer(asciiToBytes(string), buf, offset, length);
848
+ }
849
+ function base64Write(buf, string, offset, length) {
850
+ return blitBuffer(base64ToBytes(string), buf, offset, length);
851
+ }
852
+ function ucs2Write(buf, string, offset, length) {
853
+ return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length);
854
+ }
855
+ Buffer4.prototype.write = function write(string, offset, length, encoding) {
856
+ if (offset === void 0) {
857
+ encoding = "utf8";
858
+ length = this.length;
859
+ offset = 0;
860
+ } else if (length === void 0 && typeof offset === "string") {
861
+ encoding = offset;
862
+ length = this.length;
863
+ offset = 0;
864
+ } else if (isFinite(offset)) {
865
+ offset = offset >>> 0;
866
+ if (isFinite(length)) {
867
+ length = length >>> 0;
868
+ if (encoding === void 0) encoding = "utf8";
869
+ } else {
870
+ encoding = length;
871
+ length = void 0;
872
+ }
873
+ } else {
874
+ throw new Error(
875
+ "Buffer.write(string, encoding, offset[, length]) is no longer supported"
876
+ );
877
+ }
878
+ const remaining = this.length - offset;
879
+ if (length === void 0 || length > remaining) length = remaining;
880
+ if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
881
+ throw new RangeError("Attempt to write outside buffer bounds");
882
+ }
883
+ if (!encoding) encoding = "utf8";
884
+ let loweredCase = false;
885
+ for (; ; ) {
886
+ switch (encoding) {
887
+ case "hex":
888
+ return hexWrite(this, string, offset, length);
889
+ case "utf8":
890
+ case "utf-8":
891
+ return utf8Write(this, string, offset, length);
892
+ case "ascii":
893
+ case "latin1":
894
+ case "binary":
895
+ return asciiWrite(this, string, offset, length);
896
+ case "base64":
897
+ return base64Write(this, string, offset, length);
898
+ case "ucs2":
899
+ case "ucs-2":
900
+ case "utf16le":
901
+ case "utf-16le":
902
+ return ucs2Write(this, string, offset, length);
903
+ default:
904
+ if (loweredCase) throw new TypeError("Unknown encoding: " + encoding);
905
+ encoding = ("" + encoding).toLowerCase();
906
+ loweredCase = true;
907
+ }
908
+ }
909
+ };
910
+ Buffer4.prototype.toJSON = function toJSON() {
911
+ return {
912
+ type: "Buffer",
913
+ data: Array.prototype.slice.call(this._arr || this, 0)
914
+ };
915
+ };
916
+ function base64Slice(buf, start, end) {
917
+ if (start === 0 && end === buf.length) {
918
+ return base64.fromByteArray(buf);
919
+ } else {
920
+ return base64.fromByteArray(buf.slice(start, end));
921
+ }
922
+ }
923
+ function utf8Slice(buf, start, end) {
924
+ end = Math.min(buf.length, end);
925
+ const res = [];
926
+ let i = start;
927
+ while (i < end) {
928
+ const firstByte = buf[i];
929
+ let codePoint = null;
930
+ let bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
931
+ if (i + bytesPerSequence <= end) {
932
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
933
+ switch (bytesPerSequence) {
934
+ case 1:
935
+ if (firstByte < 128) {
936
+ codePoint = firstByte;
937
+ }
938
+ break;
939
+ case 2:
940
+ secondByte = buf[i + 1];
941
+ if ((secondByte & 192) === 128) {
942
+ tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
943
+ if (tempCodePoint > 127) {
944
+ codePoint = tempCodePoint;
945
+ }
946
+ }
947
+ break;
948
+ case 3:
949
+ secondByte = buf[i + 1];
950
+ thirdByte = buf[i + 2];
951
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
952
+ tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
953
+ if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
954
+ codePoint = tempCodePoint;
955
+ }
956
+ }
957
+ break;
958
+ case 4:
959
+ secondByte = buf[i + 1];
960
+ thirdByte = buf[i + 2];
961
+ fourthByte = buf[i + 3];
962
+ if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
963
+ tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
964
+ if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
965
+ codePoint = tempCodePoint;
966
+ }
967
+ }
968
+ }
969
+ }
970
+ if (codePoint === null) {
971
+ codePoint = 65533;
972
+ bytesPerSequence = 1;
973
+ } else if (codePoint > 65535) {
974
+ codePoint -= 65536;
975
+ res.push(codePoint >>> 10 & 1023 | 55296);
976
+ codePoint = 56320 | codePoint & 1023;
977
+ }
978
+ res.push(codePoint);
979
+ i += bytesPerSequence;
980
+ }
981
+ return decodeCodePointsArray(res);
982
+ }
983
+ var MAX_ARGUMENTS_LENGTH = 4096;
984
+ function decodeCodePointsArray(codePoints) {
985
+ const len = codePoints.length;
986
+ if (len <= MAX_ARGUMENTS_LENGTH) {
987
+ return String.fromCharCode.apply(String, codePoints);
988
+ }
989
+ let res = "";
990
+ let i = 0;
991
+ while (i < len) {
992
+ res += String.fromCharCode.apply(
993
+ String,
994
+ codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
995
+ );
996
+ }
997
+ return res;
998
+ }
999
+ function asciiSlice(buf, start, end) {
1000
+ let ret = "";
1001
+ end = Math.min(buf.length, end);
1002
+ for (let i = start; i < end; ++i) {
1003
+ ret += String.fromCharCode(buf[i] & 127);
1004
+ }
1005
+ return ret;
1006
+ }
1007
+ function latin1Slice(buf, start, end) {
1008
+ let ret = "";
1009
+ end = Math.min(buf.length, end);
1010
+ for (let i = start; i < end; ++i) {
1011
+ ret += String.fromCharCode(buf[i]);
1012
+ }
1013
+ return ret;
1014
+ }
1015
+ function hexSlice(buf, start, end) {
1016
+ const len = buf.length;
1017
+ if (!start || start < 0) start = 0;
1018
+ if (!end || end < 0 || end > len) end = len;
1019
+ let out = "";
1020
+ for (let i = start; i < end; ++i) {
1021
+ out += hexSliceLookupTable[buf[i]];
1022
+ }
1023
+ return out;
1024
+ }
1025
+ function utf16leSlice(buf, start, end) {
1026
+ const bytes = buf.slice(start, end);
1027
+ let res = "";
1028
+ for (let i = 0; i < bytes.length - 1; i += 2) {
1029
+ res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
1030
+ }
1031
+ return res;
1032
+ }
1033
+ Buffer4.prototype.slice = function slice(start, end) {
1034
+ const len = this.length;
1035
+ start = ~~start;
1036
+ end = end === void 0 ? len : ~~end;
1037
+ if (start < 0) {
1038
+ start += len;
1039
+ if (start < 0) start = 0;
1040
+ } else if (start > len) {
1041
+ start = len;
1042
+ }
1043
+ if (end < 0) {
1044
+ end += len;
1045
+ if (end < 0) end = 0;
1046
+ } else if (end > len) {
1047
+ end = len;
1048
+ }
1049
+ if (end < start) end = start;
1050
+ const newBuf = this.subarray(start, end);
1051
+ Object.setPrototypeOf(newBuf, Buffer4.prototype);
1052
+ return newBuf;
1053
+ };
1054
+ function checkOffset(offset, ext, length) {
1055
+ if (offset % 1 !== 0 || offset < 0) throw new RangeError("offset is not uint");
1056
+ if (offset + ext > length) throw new RangeError("Trying to access beyond buffer length");
1057
+ }
1058
+ Buffer4.prototype.readUintLE = Buffer4.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
1059
+ offset = offset >>> 0;
1060
+ byteLength2 = byteLength2 >>> 0;
1061
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1062
+ let val = this[offset];
1063
+ let mul = 1;
1064
+ let i = 0;
1065
+ while (++i < byteLength2 && (mul *= 256)) {
1066
+ val += this[offset + i] * mul;
1067
+ }
1068
+ return val;
1069
+ };
1070
+ Buffer4.prototype.readUintBE = Buffer4.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
1071
+ offset = offset >>> 0;
1072
+ byteLength2 = byteLength2 >>> 0;
1073
+ if (!noAssert) {
1074
+ checkOffset(offset, byteLength2, this.length);
1075
+ }
1076
+ let val = this[offset + --byteLength2];
1077
+ let mul = 1;
1078
+ while (byteLength2 > 0 && (mul *= 256)) {
1079
+ val += this[offset + --byteLength2] * mul;
1080
+ }
1081
+ return val;
1082
+ };
1083
+ Buffer4.prototype.readUint8 = Buffer4.prototype.readUInt8 = function readUInt8(offset, noAssert) {
1084
+ offset = offset >>> 0;
1085
+ if (!noAssert) checkOffset(offset, 1, this.length);
1086
+ return this[offset];
1087
+ };
1088
+ Buffer4.prototype.readUint16LE = Buffer4.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
1089
+ offset = offset >>> 0;
1090
+ if (!noAssert) checkOffset(offset, 2, this.length);
1091
+ return this[offset] | this[offset + 1] << 8;
1092
+ };
1093
+ Buffer4.prototype.readUint16BE = Buffer4.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
1094
+ offset = offset >>> 0;
1095
+ if (!noAssert) checkOffset(offset, 2, this.length);
1096
+ return this[offset] << 8 | this[offset + 1];
1097
+ };
1098
+ Buffer4.prototype.readUint32LE = Buffer4.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
1099
+ offset = offset >>> 0;
1100
+ if (!noAssert) checkOffset(offset, 4, this.length);
1101
+ return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
1102
+ };
1103
+ Buffer4.prototype.readUint32BE = Buffer4.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
1104
+ offset = offset >>> 0;
1105
+ if (!noAssert) checkOffset(offset, 4, this.length);
1106
+ return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
1107
+ };
1108
+ Buffer4.prototype.readBigUInt64LE = defineBigIntMethod(function readBigUInt64LE(offset) {
1109
+ offset = offset >>> 0;
1110
+ validateNumber(offset, "offset");
1111
+ const first = this[offset];
1112
+ const last = this[offset + 7];
1113
+ if (first === void 0 || last === void 0) {
1114
+ boundsError(offset, this.length - 8);
1115
+ }
1116
+ const lo = first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24;
1117
+ const hi = this[++offset] + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + last * 2 ** 24;
1118
+ return BigInt(lo) + (BigInt(hi) << BigInt(32));
1119
+ });
1120
+ Buffer4.prototype.readBigUInt64BE = defineBigIntMethod(function readBigUInt64BE(offset) {
1121
+ offset = offset >>> 0;
1122
+ validateNumber(offset, "offset");
1123
+ const first = this[offset];
1124
+ const last = this[offset + 7];
1125
+ if (first === void 0 || last === void 0) {
1126
+ boundsError(offset, this.length - 8);
1127
+ }
1128
+ const hi = first * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1129
+ const lo = this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last;
1130
+ return (BigInt(hi) << BigInt(32)) + BigInt(lo);
1131
+ });
1132
+ Buffer4.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
1133
+ offset = offset >>> 0;
1134
+ byteLength2 = byteLength2 >>> 0;
1135
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1136
+ let val = this[offset];
1137
+ let mul = 1;
1138
+ let i = 0;
1139
+ while (++i < byteLength2 && (mul *= 256)) {
1140
+ val += this[offset + i] * mul;
1141
+ }
1142
+ mul *= 128;
1143
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1144
+ return val;
1145
+ };
1146
+ Buffer4.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
1147
+ offset = offset >>> 0;
1148
+ byteLength2 = byteLength2 >>> 0;
1149
+ if (!noAssert) checkOffset(offset, byteLength2, this.length);
1150
+ let i = byteLength2;
1151
+ let mul = 1;
1152
+ let val = this[offset + --i];
1153
+ while (i > 0 && (mul *= 256)) {
1154
+ val += this[offset + --i] * mul;
1155
+ }
1156
+ mul *= 128;
1157
+ if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
1158
+ return val;
1159
+ };
1160
+ Buffer4.prototype.readInt8 = function readInt8(offset, noAssert) {
1161
+ offset = offset >>> 0;
1162
+ if (!noAssert) checkOffset(offset, 1, this.length);
1163
+ if (!(this[offset] & 128)) return this[offset];
1164
+ return (255 - this[offset] + 1) * -1;
1165
+ };
1166
+ Buffer4.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
1167
+ offset = offset >>> 0;
1168
+ if (!noAssert) checkOffset(offset, 2, this.length);
1169
+ const val = this[offset] | this[offset + 1] << 8;
1170
+ return val & 32768 ? val | 4294901760 : val;
1171
+ };
1172
+ Buffer4.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
1173
+ offset = offset >>> 0;
1174
+ if (!noAssert) checkOffset(offset, 2, this.length);
1175
+ const val = this[offset + 1] | this[offset] << 8;
1176
+ return val & 32768 ? val | 4294901760 : val;
1177
+ };
1178
+ Buffer4.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
1179
+ offset = offset >>> 0;
1180
+ if (!noAssert) checkOffset(offset, 4, this.length);
1181
+ return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
1182
+ };
1183
+ Buffer4.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
1184
+ offset = offset >>> 0;
1185
+ if (!noAssert) checkOffset(offset, 4, this.length);
1186
+ return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
1187
+ };
1188
+ Buffer4.prototype.readBigInt64LE = defineBigIntMethod(function readBigInt64LE(offset) {
1189
+ offset = offset >>> 0;
1190
+ validateNumber(offset, "offset");
1191
+ const first = this[offset];
1192
+ const last = this[offset + 7];
1193
+ if (first === void 0 || last === void 0) {
1194
+ boundsError(offset, this.length - 8);
1195
+ }
1196
+ const val = this[offset + 4] + this[offset + 5] * 2 ** 8 + this[offset + 6] * 2 ** 16 + (last << 24);
1197
+ return (BigInt(val) << BigInt(32)) + BigInt(first + this[++offset] * 2 ** 8 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 24);
1198
+ });
1199
+ Buffer4.prototype.readBigInt64BE = defineBigIntMethod(function readBigInt64BE(offset) {
1200
+ offset = offset >>> 0;
1201
+ validateNumber(offset, "offset");
1202
+ const first = this[offset];
1203
+ const last = this[offset + 7];
1204
+ if (first === void 0 || last === void 0) {
1205
+ boundsError(offset, this.length - 8);
1206
+ }
1207
+ const val = (first << 24) + // Overflow
1208
+ this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + this[++offset];
1209
+ return (BigInt(val) << BigInt(32)) + BigInt(this[++offset] * 2 ** 24 + this[++offset] * 2 ** 16 + this[++offset] * 2 ** 8 + last);
1210
+ });
1211
+ Buffer4.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
1212
+ offset = offset >>> 0;
1213
+ if (!noAssert) checkOffset(offset, 4, this.length);
1214
+ return ieee754.read(this, offset, true, 23, 4);
1215
+ };
1216
+ Buffer4.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
1217
+ offset = offset >>> 0;
1218
+ if (!noAssert) checkOffset(offset, 4, this.length);
1219
+ return ieee754.read(this, offset, false, 23, 4);
1220
+ };
1221
+ Buffer4.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
1222
+ offset = offset >>> 0;
1223
+ if (!noAssert) checkOffset(offset, 8, this.length);
1224
+ return ieee754.read(this, offset, true, 52, 8);
1225
+ };
1226
+ Buffer4.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
1227
+ offset = offset >>> 0;
1228
+ if (!noAssert) checkOffset(offset, 8, this.length);
1229
+ return ieee754.read(this, offset, false, 52, 8);
1230
+ };
1231
+ function checkInt(buf, value, offset, ext, max, min) {
1232
+ if (!Buffer4.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance');
1233
+ if (value > max || value < min) throw new RangeError('"value" argument is out of bounds');
1234
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1235
+ }
1236
+ Buffer4.prototype.writeUintLE = Buffer4.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
1237
+ value = +value;
1238
+ offset = offset >>> 0;
1239
+ byteLength2 = byteLength2 >>> 0;
1240
+ if (!noAssert) {
1241
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1242
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1243
+ }
1244
+ let mul = 1;
1245
+ let i = 0;
1246
+ this[offset] = value & 255;
1247
+ while (++i < byteLength2 && (mul *= 256)) {
1248
+ this[offset + i] = value / mul & 255;
1249
+ }
1250
+ return offset + byteLength2;
1251
+ };
1252
+ Buffer4.prototype.writeUintBE = Buffer4.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
1253
+ value = +value;
1254
+ offset = offset >>> 0;
1255
+ byteLength2 = byteLength2 >>> 0;
1256
+ if (!noAssert) {
1257
+ const maxBytes = Math.pow(2, 8 * byteLength2) - 1;
1258
+ checkInt(this, value, offset, byteLength2, maxBytes, 0);
1259
+ }
1260
+ let i = byteLength2 - 1;
1261
+ let mul = 1;
1262
+ this[offset + i] = value & 255;
1263
+ while (--i >= 0 && (mul *= 256)) {
1264
+ this[offset + i] = value / mul & 255;
1265
+ }
1266
+ return offset + byteLength2;
1267
+ };
1268
+ Buffer4.prototype.writeUint8 = Buffer4.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
1269
+ value = +value;
1270
+ offset = offset >>> 0;
1271
+ if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
1272
+ this[offset] = value & 255;
1273
+ return offset + 1;
1274
+ };
1275
+ Buffer4.prototype.writeUint16LE = Buffer4.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
1276
+ value = +value;
1277
+ offset = offset >>> 0;
1278
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1279
+ this[offset] = value & 255;
1280
+ this[offset + 1] = value >>> 8;
1281
+ return offset + 2;
1282
+ };
1283
+ Buffer4.prototype.writeUint16BE = Buffer4.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
1284
+ value = +value;
1285
+ offset = offset >>> 0;
1286
+ if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
1287
+ this[offset] = value >>> 8;
1288
+ this[offset + 1] = value & 255;
1289
+ return offset + 2;
1290
+ };
1291
+ Buffer4.prototype.writeUint32LE = Buffer4.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
1292
+ value = +value;
1293
+ offset = offset >>> 0;
1294
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1295
+ this[offset + 3] = value >>> 24;
1296
+ this[offset + 2] = value >>> 16;
1297
+ this[offset + 1] = value >>> 8;
1298
+ this[offset] = value & 255;
1299
+ return offset + 4;
1300
+ };
1301
+ Buffer4.prototype.writeUint32BE = Buffer4.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
1302
+ value = +value;
1303
+ offset = offset >>> 0;
1304
+ if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
1305
+ this[offset] = value >>> 24;
1306
+ this[offset + 1] = value >>> 16;
1307
+ this[offset + 2] = value >>> 8;
1308
+ this[offset + 3] = value & 255;
1309
+ return offset + 4;
1310
+ };
1311
+ function wrtBigUInt64LE(buf, value, offset, min, max) {
1312
+ checkIntBI(value, min, max, buf, offset, 7);
1313
+ let lo = Number(value & BigInt(4294967295));
1314
+ buf[offset++] = lo;
1315
+ lo = lo >> 8;
1316
+ buf[offset++] = lo;
1317
+ lo = lo >> 8;
1318
+ buf[offset++] = lo;
1319
+ lo = lo >> 8;
1320
+ buf[offset++] = lo;
1321
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1322
+ buf[offset++] = hi;
1323
+ hi = hi >> 8;
1324
+ buf[offset++] = hi;
1325
+ hi = hi >> 8;
1326
+ buf[offset++] = hi;
1327
+ hi = hi >> 8;
1328
+ buf[offset++] = hi;
1329
+ return offset;
1330
+ }
1331
+ function wrtBigUInt64BE(buf, value, offset, min, max) {
1332
+ checkIntBI(value, min, max, buf, offset, 7);
1333
+ let lo = Number(value & BigInt(4294967295));
1334
+ buf[offset + 7] = lo;
1335
+ lo = lo >> 8;
1336
+ buf[offset + 6] = lo;
1337
+ lo = lo >> 8;
1338
+ buf[offset + 5] = lo;
1339
+ lo = lo >> 8;
1340
+ buf[offset + 4] = lo;
1341
+ let hi = Number(value >> BigInt(32) & BigInt(4294967295));
1342
+ buf[offset + 3] = hi;
1343
+ hi = hi >> 8;
1344
+ buf[offset + 2] = hi;
1345
+ hi = hi >> 8;
1346
+ buf[offset + 1] = hi;
1347
+ hi = hi >> 8;
1348
+ buf[offset] = hi;
1349
+ return offset + 8;
1350
+ }
1351
+ Buffer4.prototype.writeBigUInt64LE = defineBigIntMethod(function writeBigUInt64LE(value, offset = 0) {
1352
+ return wrtBigUInt64LE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1353
+ });
1354
+ Buffer4.prototype.writeBigUInt64BE = defineBigIntMethod(function writeBigUInt64BE(value, offset = 0) {
1355
+ return wrtBigUInt64BE(this, value, offset, BigInt(0), BigInt("0xffffffffffffffff"));
1356
+ });
1357
+ Buffer4.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
1358
+ value = +value;
1359
+ offset = offset >>> 0;
1360
+ if (!noAssert) {
1361
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1362
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1363
+ }
1364
+ let i = 0;
1365
+ let mul = 1;
1366
+ let sub = 0;
1367
+ this[offset] = value & 255;
1368
+ while (++i < byteLength2 && (mul *= 256)) {
1369
+ if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
1370
+ sub = 1;
1371
+ }
1372
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1373
+ }
1374
+ return offset + byteLength2;
1375
+ };
1376
+ Buffer4.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
1377
+ value = +value;
1378
+ offset = offset >>> 0;
1379
+ if (!noAssert) {
1380
+ const limit = Math.pow(2, 8 * byteLength2 - 1);
1381
+ checkInt(this, value, offset, byteLength2, limit - 1, -limit);
1382
+ }
1383
+ let i = byteLength2 - 1;
1384
+ let mul = 1;
1385
+ let sub = 0;
1386
+ this[offset + i] = value & 255;
1387
+ while (--i >= 0 && (mul *= 256)) {
1388
+ if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
1389
+ sub = 1;
1390
+ }
1391
+ this[offset + i] = (value / mul >> 0) - sub & 255;
1392
+ }
1393
+ return offset + byteLength2;
1394
+ };
1395
+ Buffer4.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
1396
+ value = +value;
1397
+ offset = offset >>> 0;
1398
+ if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
1399
+ if (value < 0) value = 255 + value + 1;
1400
+ this[offset] = value & 255;
1401
+ return offset + 1;
1402
+ };
1403
+ Buffer4.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
1404
+ value = +value;
1405
+ offset = offset >>> 0;
1406
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1407
+ this[offset] = value & 255;
1408
+ this[offset + 1] = value >>> 8;
1409
+ return offset + 2;
1410
+ };
1411
+ Buffer4.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
1412
+ value = +value;
1413
+ offset = offset >>> 0;
1414
+ if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
1415
+ this[offset] = value >>> 8;
1416
+ this[offset + 1] = value & 255;
1417
+ return offset + 2;
1418
+ };
1419
+ Buffer4.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
1420
+ value = +value;
1421
+ offset = offset >>> 0;
1422
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1423
+ this[offset] = value & 255;
1424
+ this[offset + 1] = value >>> 8;
1425
+ this[offset + 2] = value >>> 16;
1426
+ this[offset + 3] = value >>> 24;
1427
+ return offset + 4;
1428
+ };
1429
+ Buffer4.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
1430
+ value = +value;
1431
+ offset = offset >>> 0;
1432
+ if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
1433
+ if (value < 0) value = 4294967295 + value + 1;
1434
+ this[offset] = value >>> 24;
1435
+ this[offset + 1] = value >>> 16;
1436
+ this[offset + 2] = value >>> 8;
1437
+ this[offset + 3] = value & 255;
1438
+ return offset + 4;
1439
+ };
1440
+ Buffer4.prototype.writeBigInt64LE = defineBigIntMethod(function writeBigInt64LE(value, offset = 0) {
1441
+ return wrtBigUInt64LE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1442
+ });
1443
+ Buffer4.prototype.writeBigInt64BE = defineBigIntMethod(function writeBigInt64BE(value, offset = 0) {
1444
+ return wrtBigUInt64BE(this, value, offset, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1445
+ });
1446
+ function checkIEEE754(buf, value, offset, ext, max, min) {
1447
+ if (offset + ext > buf.length) throw new RangeError("Index out of range");
1448
+ if (offset < 0) throw new RangeError("Index out of range");
1449
+ }
1450
+ function writeFloat(buf, value, offset, littleEndian, noAssert) {
1451
+ value = +value;
1452
+ offset = offset >>> 0;
1453
+ if (!noAssert) {
1454
+ checkIEEE754(buf, value, offset, 4, 34028234663852886e22, -34028234663852886e22);
1455
+ }
1456
+ ieee754.write(buf, value, offset, littleEndian, 23, 4);
1457
+ return offset + 4;
1458
+ }
1459
+ Buffer4.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
1460
+ return writeFloat(this, value, offset, true, noAssert);
1461
+ };
1462
+ Buffer4.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
1463
+ return writeFloat(this, value, offset, false, noAssert);
1464
+ };
1465
+ function writeDouble(buf, value, offset, littleEndian, noAssert) {
1466
+ value = +value;
1467
+ offset = offset >>> 0;
1468
+ if (!noAssert) {
1469
+ checkIEEE754(buf, value, offset, 8, 17976931348623157e292, -17976931348623157e292);
1470
+ }
1471
+ ieee754.write(buf, value, offset, littleEndian, 52, 8);
1472
+ return offset + 8;
1473
+ }
1474
+ Buffer4.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
1475
+ return writeDouble(this, value, offset, true, noAssert);
1476
+ };
1477
+ Buffer4.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
1478
+ return writeDouble(this, value, offset, false, noAssert);
1479
+ };
1480
+ Buffer4.prototype.copy = function copy(target, targetStart, start, end) {
1481
+ if (!Buffer4.isBuffer(target)) throw new TypeError("argument should be a Buffer");
1482
+ if (!start) start = 0;
1483
+ if (!end && end !== 0) end = this.length;
1484
+ if (targetStart >= target.length) targetStart = target.length;
1485
+ if (!targetStart) targetStart = 0;
1486
+ if (end > 0 && end < start) end = start;
1487
+ if (end === start) return 0;
1488
+ if (target.length === 0 || this.length === 0) return 0;
1489
+ if (targetStart < 0) {
1490
+ throw new RangeError("targetStart out of bounds");
1491
+ }
1492
+ if (start < 0 || start >= this.length) throw new RangeError("Index out of range");
1493
+ if (end < 0) throw new RangeError("sourceEnd out of bounds");
1494
+ if (end > this.length) end = this.length;
1495
+ if (target.length - targetStart < end - start) {
1496
+ end = target.length - targetStart + start;
1497
+ }
1498
+ const len = end - start;
1499
+ if (this === target && typeof Uint8Array.prototype.copyWithin === "function") {
1500
+ this.copyWithin(targetStart, start, end);
1501
+ } else {
1502
+ Uint8Array.prototype.set.call(
1503
+ target,
1504
+ this.subarray(start, end),
1505
+ targetStart
1506
+ );
1507
+ }
1508
+ return len;
1509
+ };
1510
+ Buffer4.prototype.fill = function fill(val, start, end, encoding) {
1511
+ if (typeof val === "string") {
1512
+ if (typeof start === "string") {
1513
+ encoding = start;
1514
+ start = 0;
1515
+ end = this.length;
1516
+ } else if (typeof end === "string") {
1517
+ encoding = end;
1518
+ end = this.length;
1519
+ }
1520
+ if (encoding !== void 0 && typeof encoding !== "string") {
1521
+ throw new TypeError("encoding must be a string");
1522
+ }
1523
+ if (typeof encoding === "string" && !Buffer4.isEncoding(encoding)) {
1524
+ throw new TypeError("Unknown encoding: " + encoding);
1525
+ }
1526
+ if (val.length === 1) {
1527
+ const code = val.charCodeAt(0);
1528
+ if (encoding === "utf8" && code < 128 || encoding === "latin1") {
1529
+ val = code;
1530
+ }
1531
+ }
1532
+ } else if (typeof val === "number") {
1533
+ val = val & 255;
1534
+ } else if (typeof val === "boolean") {
1535
+ val = Number(val);
1536
+ }
1537
+ if (start < 0 || this.length < start || this.length < end) {
1538
+ throw new RangeError("Out of range index");
1539
+ }
1540
+ if (end <= start) {
1541
+ return this;
1542
+ }
1543
+ start = start >>> 0;
1544
+ end = end === void 0 ? this.length : end >>> 0;
1545
+ if (!val) val = 0;
1546
+ let i;
1547
+ if (typeof val === "number") {
1548
+ for (i = start; i < end; ++i) {
1549
+ this[i] = val;
1550
+ }
1551
+ } else {
1552
+ const bytes = Buffer4.isBuffer(val) ? val : Buffer4.from(val, encoding);
1553
+ const len = bytes.length;
1554
+ if (len === 0) {
1555
+ throw new TypeError('The value "' + val + '" is invalid for argument "value"');
1556
+ }
1557
+ for (i = 0; i < end - start; ++i) {
1558
+ this[i + start] = bytes[i % len];
1559
+ }
1560
+ }
1561
+ return this;
1562
+ };
1563
+ var errors = {};
1564
+ function E(sym, getMessage, Base) {
1565
+ errors[sym] = class NodeError extends Base {
1566
+ constructor() {
1567
+ super();
1568
+ Object.defineProperty(this, "message", {
1569
+ value: getMessage.apply(this, arguments),
1570
+ writable: true,
1571
+ configurable: true
1572
+ });
1573
+ this.name = `${this.name} [${sym}]`;
1574
+ this.stack;
1575
+ delete this.name;
1576
+ }
1577
+ get code() {
1578
+ return sym;
1579
+ }
1580
+ set code(value) {
1581
+ Object.defineProperty(this, "code", {
1582
+ configurable: true,
1583
+ enumerable: true,
1584
+ value,
1585
+ writable: true
1586
+ });
1587
+ }
1588
+ toString() {
1589
+ return `${this.name} [${sym}]: ${this.message}`;
1590
+ }
1591
+ };
1592
+ }
1593
+ E(
1594
+ "ERR_BUFFER_OUT_OF_BOUNDS",
1595
+ function(name) {
1596
+ if (name) {
1597
+ return `${name} is outside of buffer bounds`;
1598
+ }
1599
+ return "Attempt to access memory outside buffer bounds";
1600
+ },
1601
+ RangeError
1602
+ );
1603
+ E(
1604
+ "ERR_INVALID_ARG_TYPE",
1605
+ function(name, actual) {
1606
+ return `The "${name}" argument must be of type number. Received type ${typeof actual}`;
1607
+ },
1608
+ TypeError
1609
+ );
1610
+ E(
1611
+ "ERR_OUT_OF_RANGE",
1612
+ function(str, range, input) {
1613
+ let msg = `The value of "${str}" is out of range.`;
1614
+ let received = input;
1615
+ if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) {
1616
+ received = addNumericalSeparator(String(input));
1617
+ } else if (typeof input === "bigint") {
1618
+ received = String(input);
1619
+ if (input > BigInt(2) ** BigInt(32) || input < -(BigInt(2) ** BigInt(32))) {
1620
+ received = addNumericalSeparator(received);
1621
+ }
1622
+ received += "n";
1623
+ }
1624
+ msg += ` It must be ${range}. Received ${received}`;
1625
+ return msg;
1626
+ },
1627
+ RangeError
1628
+ );
1629
+ function addNumericalSeparator(val) {
1630
+ let res = "";
1631
+ let i = val.length;
1632
+ const start = val[0] === "-" ? 1 : 0;
1633
+ for (; i >= start + 4; i -= 3) {
1634
+ res = `_${val.slice(i - 3, i)}${res}`;
1635
+ }
1636
+ return `${val.slice(0, i)}${res}`;
1637
+ }
1638
+ function checkBounds(buf, offset, byteLength2) {
1639
+ validateNumber(offset, "offset");
1640
+ if (buf[offset] === void 0 || buf[offset + byteLength2] === void 0) {
1641
+ boundsError(offset, buf.length - (byteLength2 + 1));
1642
+ }
1643
+ }
1644
+ function checkIntBI(value, min, max, buf, offset, byteLength2) {
1645
+ if (value > max || value < min) {
1646
+ const n = typeof min === "bigint" ? "n" : "";
1647
+ let range;
1648
+ if (byteLength2 > 3) {
1649
+ if (min === 0 || min === BigInt(0)) {
1650
+ range = `>= 0${n} and < 2${n} ** ${(byteLength2 + 1) * 8}${n}`;
1651
+ } else {
1652
+ range = `>= -(2${n} ** ${(byteLength2 + 1) * 8 - 1}${n}) and < 2 ** ${(byteLength2 + 1) * 8 - 1}${n}`;
1653
+ }
1654
+ } else {
1655
+ range = `>= ${min}${n} and <= ${max}${n}`;
1656
+ }
1657
+ throw new errors.ERR_OUT_OF_RANGE("value", range, value);
1658
+ }
1659
+ checkBounds(buf, offset, byteLength2);
1660
+ }
1661
+ function validateNumber(value, name) {
1662
+ if (typeof value !== "number") {
1663
+ throw new errors.ERR_INVALID_ARG_TYPE(name, "number", value);
1664
+ }
1665
+ }
1666
+ function boundsError(value, length, type) {
1667
+ if (Math.floor(value) !== value) {
1668
+ validateNumber(value, type);
1669
+ throw new errors.ERR_OUT_OF_RANGE(type || "offset", "an integer", value);
1670
+ }
1671
+ if (length < 0) {
1672
+ throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();
1673
+ }
1674
+ throw new errors.ERR_OUT_OF_RANGE(
1675
+ type || "offset",
1676
+ `>= ${type ? 1 : 0} and <= ${length}`,
1677
+ value
1678
+ );
1679
+ }
1680
+ var INVALID_BASE64_RE = /[^+/0-9A-Za-z-_]/g;
1681
+ function base64clean(str) {
1682
+ str = str.split("=")[0];
1683
+ str = str.trim().replace(INVALID_BASE64_RE, "");
1684
+ if (str.length < 2) return "";
1685
+ while (str.length % 4 !== 0) {
1686
+ str = str + "=";
1687
+ }
1688
+ return str;
1689
+ }
1690
+ function utf8ToBytes(string, units) {
1691
+ units = units || Infinity;
1692
+ let codePoint;
1693
+ const length = string.length;
1694
+ let leadSurrogate = null;
1695
+ const bytes = [];
1696
+ for (let i = 0; i < length; ++i) {
1697
+ codePoint = string.charCodeAt(i);
1698
+ if (codePoint > 55295 && codePoint < 57344) {
1699
+ if (!leadSurrogate) {
1700
+ if (codePoint > 56319) {
1701
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1702
+ continue;
1703
+ } else if (i + 1 === length) {
1704
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1705
+ continue;
1706
+ }
1707
+ leadSurrogate = codePoint;
1708
+ continue;
1709
+ }
1710
+ if (codePoint < 56320) {
1711
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1712
+ leadSurrogate = codePoint;
1713
+ continue;
1714
+ }
1715
+ codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
1716
+ } else if (leadSurrogate) {
1717
+ if ((units -= 3) > -1) bytes.push(239, 191, 189);
1718
+ }
1719
+ leadSurrogate = null;
1720
+ if (codePoint < 128) {
1721
+ if ((units -= 1) < 0) break;
1722
+ bytes.push(codePoint);
1723
+ } else if (codePoint < 2048) {
1724
+ if ((units -= 2) < 0) break;
1725
+ bytes.push(
1726
+ codePoint >> 6 | 192,
1727
+ codePoint & 63 | 128
1728
+ );
1729
+ } else if (codePoint < 65536) {
1730
+ if ((units -= 3) < 0) break;
1731
+ bytes.push(
1732
+ codePoint >> 12 | 224,
1733
+ codePoint >> 6 & 63 | 128,
1734
+ codePoint & 63 | 128
1735
+ );
1736
+ } else if (codePoint < 1114112) {
1737
+ if ((units -= 4) < 0) break;
1738
+ bytes.push(
1739
+ codePoint >> 18 | 240,
1740
+ codePoint >> 12 & 63 | 128,
1741
+ codePoint >> 6 & 63 | 128,
1742
+ codePoint & 63 | 128
1743
+ );
1744
+ } else {
1745
+ throw new Error("Invalid code point");
1746
+ }
1747
+ }
1748
+ return bytes;
1749
+ }
1750
+ function asciiToBytes(str) {
1751
+ const byteArray = [];
1752
+ for (let i = 0; i < str.length; ++i) {
1753
+ byteArray.push(str.charCodeAt(i) & 255);
1754
+ }
1755
+ return byteArray;
1756
+ }
1757
+ function utf16leToBytes(str, units) {
1758
+ let c, hi, lo;
1759
+ const byteArray = [];
1760
+ for (let i = 0; i < str.length; ++i) {
1761
+ if ((units -= 2) < 0) break;
1762
+ c = str.charCodeAt(i);
1763
+ hi = c >> 8;
1764
+ lo = c % 256;
1765
+ byteArray.push(lo);
1766
+ byteArray.push(hi);
1767
+ }
1768
+ return byteArray;
1769
+ }
1770
+ function base64ToBytes(str) {
1771
+ return base64.toByteArray(base64clean(str));
1772
+ }
1773
+ function blitBuffer(src, dst, offset, length) {
1774
+ let i;
1775
+ for (i = 0; i < length; ++i) {
1776
+ if (i + offset >= dst.length || i >= src.length) break;
1777
+ dst[i + offset] = src[i];
1778
+ }
1779
+ return i;
1780
+ }
1781
+ function isInstance(obj, type) {
1782
+ return obj instanceof type || obj != null && obj.constructor != null && obj.constructor.name != null && obj.constructor.name === type.name;
1783
+ }
1784
+ function numberIsNaN(obj) {
1785
+ return obj !== obj;
1786
+ }
1787
+ var hexSliceLookupTable = (function() {
1788
+ const alphabet = "0123456789abcdef";
1789
+ const table = new Array(256);
1790
+ for (let i = 0; i < 16; ++i) {
1791
+ const i16 = i * 16;
1792
+ for (let j = 0; j < 16; ++j) {
1793
+ table[i16 + j] = alphabet[i] + alphabet[j];
1794
+ }
1795
+ }
1796
+ return table;
1797
+ })();
1798
+ function defineBigIntMethod(fn) {
1799
+ return typeof BigInt === "undefined" ? BufferBigIntNotDefined : fn;
1800
+ }
1801
+ function BufferBigIntNotDefined() {
1802
+ throw new Error("BigInt not supported");
1803
+ }
1804
+ }
1805
+ });
1806
+
1
1807
  // src/vendors/Sub-Store/backend/src/utils/index.js
2
1808
  var IPV4_REGEX = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
3
1809
  var IPV6_REGEX = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
@@ -410,7 +2216,7 @@ var grammars = String.raw`
410
2216
  }
411
2217
  }
412
2218
 
413
- start = (anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
2219
+ start = (masque/anytls/shadowsocks/vmess/trojan/h2_connect/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/trust_tunnel/direct) {
414
2220
  return proxy;
415
2221
  }
416
2222
 
@@ -500,10 +2306,14 @@ anytls = tag equals "anytls" address (passwordk/reuse/ip_version/underlying_prox
500
2306
  proxy.type = "anytls";
501
2307
  proxy.tls = true;
502
2308
  }
503
- trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/block_quic/others)* {
2309
+ trust_tunnel = tag equals "trust-tunnel" address (usernamek/passwordk/headers/max_streams/reuse/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/h3/fast_open/tfo/block_quic/others)* {
504
2310
  proxy.type = "trusttunnel";
505
2311
  proxy.tls = true;
506
2312
  }
2313
+ masque = tag equals "masque" address (usernamek/passwordk/port_hopping_interval/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/client_cert/sni/cert_verify_name/alpn/fast_open/tfo/udp_relay/ecn/block_quic/others)* {
2314
+ proxy.type = "masque-surge";
2315
+ proxy.tls = true;
2316
+ }
507
2317
 
508
2318
  direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* {
509
2319
  proxy.type = "direct";
@@ -660,6 +2470,7 @@ alpn = comma "alpn" equals match:quoted_value {
660
2470
  const values = parseAlpn(match);
661
2471
  if (values.length > 0) proxy.alpn = values;
662
2472
  }
2473
+ h3 = comma "h3" equals flag:bool { if (flag) proxy.network = "h3"; }
663
2474
  quoted_value = '"' match:$[^"]* '"' { return match; } / "'" match:$[^']* "'" { return match; } / match:$[^,]+ { return match; }
664
2475
  uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); }
665
2476
  salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); proxy.obfs = 'salamander'; }
@@ -961,7 +2772,22 @@ function getParser2() {
961
2772
  }
962
2773
 
963
2774
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/parsers/peggy/qx.js
2775
+ var import_buffer = __toESM(require_buffer());
964
2776
  import peggy3 from "peggy";
2777
+ function decodeQxAlpn(raw) {
2778
+ if (typeof raw !== "string") return void 0;
2779
+ const hex = raw.trim().replace(/:/g, "");
2780
+ if (!hex || hex.length % 2 || /[^0-9a-f]/i.test(hex)) return void 0;
2781
+ const bytes = import_buffer.Buffer.from(hex, "hex");
2782
+ const alpn = [];
2783
+ for (let offset = 0; offset < bytes.length; ) {
2784
+ const length = bytes[offset++];
2785
+ if (!length || offset + length > bytes.length) return void 0;
2786
+ alpn.push(bytes.subarray(offset, offset + length).toString("utf8"));
2787
+ offset += length;
2788
+ }
2789
+ return alpn;
2790
+ }
965
2791
  var grammars3 = String.raw`
966
2792
  // global initializer
967
2793
  {{
@@ -1133,7 +2959,8 @@ port = digits:[0-9]+ {
1133
2959
  }
1134
2960
 
1135
2961
  username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); }
1136
- password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); }
2962
+ password = comma "password" equals password:$((!next_parameter .)+) { proxy.password = password.trim(); }
2963
+ next_parameter = "," _ [^=,]+ equals
1137
2964
  uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); }
1138
2965
 
1139
2966
  method = comma "method" equals cipher:cipher {
@@ -1223,7 +3050,15 @@ bool = b:("true"/"false") { return b === "true" }
1223
3050
  var parser3;
1224
3051
  function getParser3() {
1225
3052
  if (!parser3) {
1226
- parser3 = peggy3.generate(grammars3);
3053
+ const generated = peggy3.generate(grammars3);
3054
+ parser3 = {
3055
+ parse(input, options) {
3056
+ const proxy = generated.parse(input, options);
3057
+ const alpn = decodeQxAlpn(proxy["tls-alpn"]);
3058
+ if (alpn) proxy.alpn = alpn;
3059
+ return proxy;
3060
+ }
3061
+ };
1227
3062
  }
1228
3063
  return parser3;
1229
3064
  }
@@ -1250,8 +3085,7 @@ function splitQueryPart(part) {
1250
3085
  };
1251
3086
  }
1252
3087
  function parseSafeIntegerValue(value) {
1253
- if (!/^\d+$/.test(`${value}`))
1254
- return null;
3088
+ if (!/^\d+$/.test(`${value}`)) return null;
1255
3089
  const parsed = parseInt(`${value}`, 10);
1256
3090
  return Number.isSafeInteger(parsed) ? parsed : null;
1257
3091
  }
@@ -1269,8 +3103,7 @@ function extractPathQueryParam(rawPath, paramName) {
1269
3103
  const keptParts = [];
1270
3104
  let value = "";
1271
3105
  for (const part of query.split("&")) {
1272
- if (part === "")
1273
- continue;
3106
+ if (part === "") continue;
1274
3107
  const parsed = splitQueryPart(part);
1275
3108
  if (parsed.key === paramName) {
1276
3109
  if (value === "" && parsed.value !== "") {
@@ -1288,12 +3121,10 @@ function extractPathQueryParam(rawPath, paramName) {
1288
3121
  function getPathQueryParam(rawPath, paramName) {
1289
3122
  const path = rawPath == null ? "" : `${rawPath}`;
1290
3123
  const queryIndex = path.indexOf("?");
1291
- if (queryIndex === -1)
1292
- return "";
3124
+ if (queryIndex === -1) return "";
1293
3125
  const query = path.slice(queryIndex + 1);
1294
3126
  for (const part of query.split("&")) {
1295
- if (part === "")
1296
- continue;
3127
+ if (part === "") continue;
1297
3128
  const parsed = splitQueryPart(part);
1298
3129
  if (parsed.key === paramName && parsed.value !== "") {
1299
3130
  return parsed.value;
@@ -1328,8 +3159,7 @@ function setPathQueryParam(rawPath, paramName, value) {
1328
3159
  }
1329
3160
  function normalizeWebSocketEarlyDataPath(wsOpts) {
1330
3161
  const networkPath = wsOpts?.path;
1331
- if (!wsOpts)
1332
- return;
3162
+ if (!wsOpts) return;
1333
3163
  const { value: ed, parsed: maxEarlyData } = getSafeIntegerPathQueryParam(
1334
3164
  networkPath,
1335
3165
  "ed"
@@ -1346,8 +3176,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
1346
3176
  delete wsOpts["max-early-data"];
1347
3177
  return;
1348
3178
  }
1349
- if (ed === "")
1350
- return;
3179
+ if (ed === "") return;
1351
3180
  wsOpts.path = extractPathQueryParam(networkPath, "ed").path;
1352
3181
  if (wsOpts["early-data-header-name"] == null) {
1353
3182
  wsOpts["early-data-header-name"] = "Sec-WebSocket-Protocol";
@@ -1357,8 +3186,7 @@ function normalizeWebSocketEarlyDataPath(wsOpts) {
1357
3186
  }
1358
3187
  }
1359
3188
  function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
1360
- if (!wsOpts)
1361
- return;
3189
+ if (!wsOpts) return;
1362
3190
  delete wsOpts["_v2ray-http-upgrade-ed"];
1363
3191
  }
1364
3192
 
@@ -1366,10 +3194,8 @@ function deleteHttpUpgradeEarlyDataMetadata(wsOpts) {
1366
3194
  var unsafePathSegments = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
1367
3195
  var parser4;
1368
3196
  function $set(obj, path, value) {
1369
- if (Object(obj) !== obj)
1370
- return obj;
1371
- if (!Array.isArray(path))
1372
- path = path.toString().match(/[^.[\]]+/g) || [];
3197
+ if (Object(obj) !== obj) return obj;
3198
+ if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || [];
1373
3199
  if (path.some((segment) => unsafePathSegments.has(segment))) {
1374
3200
  throw new Error("Unsafe property path");
1375
3201
  }
@@ -1377,8 +3203,7 @@ function $set(obj, path, value) {
1377
3203
  return obj;
1378
3204
  }
1379
3205
  function toBool(str) {
1380
- if (str == null)
1381
- return void 0;
3206
+ if (str == null) return void 0;
1382
3207
  return /(TRUE)|1/i.test(str);
1383
3208
  }
1384
3209
  function isNumericEarlyData(value) {
@@ -1887,8 +3712,7 @@ var VMESS_SECURITY_ALIASES = {
1887
3712
  "chacha20-ietf-poly1305": "chacha20-poly1305"
1888
3713
  };
1889
3714
  function normalizeSecurityValue(security) {
1890
- if (security == null)
1891
- return "";
3715
+ if (security == null) return "";
1892
3716
  return `${security}`.trim().toLowerCase();
1893
3717
  }
1894
3718
  function canonicalizeVmessSecurity(security) {
@@ -1896,8 +3720,7 @@ function canonicalizeVmessSecurity(security) {
1896
3720
  }
1897
3721
  function normalizeVmessSecurity(security, supportedValues = VMESS_SECURITY_COMMON_VALUES, { acceptAliases = true, fallback = VMESS_SECURITY_AUTO } = {}) {
1898
3722
  const normalized = normalizeSecurityValue(security);
1899
- if (!normalized)
1900
- return fallback;
3723
+ if (!normalized) return fallback;
1901
3724
  const normalizedSupported = supportedValues.map(normalizeSecurityValue);
1902
3725
  if (normalizedSupported.includes(normalized)) {
1903
3726
  return canonicalizeVmessSecurity(normalized);
@@ -1928,8 +3751,7 @@ function formatSurgeVmessEncryptMethod(security) {
1928
3751
  "aes-128-gcm",
1929
3752
  "chacha20-poly1305"
1930
3753
  ]);
1931
- if (normalized === VMESS_SECURITY_AUTO)
1932
- return void 0;
3754
+ if (normalized === VMESS_SECURITY_AUTO) return void 0;
1933
3755
  return normalized === "chacha20-poly1305" ? "chacha20-ietf-poly1305" : normalized;
1934
3756
  }
1935
3757
 
@@ -1965,8 +3787,7 @@ function decodeShadowsocksUserInfo(rawUserInfoStr) {
1965
3787
  return Base64.decode(decodedUserInfoStr);
1966
3788
  }
1967
3789
  function isNumericEarlyData2(value) {
1968
- if (value == null || !/^\d+$/.test(`${value}`))
1969
- return false;
3790
+ if (value == null || !/^\d+$/.test(`${value}`)) return false;
1970
3791
  return Number.isSafeInteger(parseInt(`${value}`, 10));
1971
3792
  }
1972
3793
  function extractEarlyDataFromPath(path) {
@@ -2004,21 +3825,16 @@ function splitURIHostList(host) {
2004
3825
  return hosts.length > 0 ? hosts : void 0;
2005
3826
  }
2006
3827
  function parseWireGuardURIAddressValue(value) {
2007
- if (value == null)
2008
- return null;
3828
+ if (value == null) return null;
2009
3829
  const raw = `${value}`.trim();
2010
- if (!raw)
2011
- return null;
3830
+ if (!raw) return null;
2012
3831
  const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
2013
3832
  const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
2014
3833
  const normalizeCIDR = (cidr, max) => {
2015
- if (cidr == null)
2016
- return void 0;
2017
- if (!/^\d+$/.test(cidr))
2018
- return void 0;
3834
+ if (cidr == null) return void 0;
3835
+ if (!/^\d+$/.test(cidr)) return void 0;
2019
3836
  const parsed = parseInt(cidr, 10);
2020
- if (parsed < 0 || parsed > max)
2021
- return void 0;
3837
+ if (parsed < 0 || parsed > max) return void 0;
2022
3838
  return parsed;
2023
3839
  };
2024
3840
  if (isIPv4(host)) {
@@ -2273,14 +4089,12 @@ function URI_SS() {
2273
4089
  for (const item of pluginInfo) {
2274
4090
  const separatorIndex = item.indexOf("=");
2275
4091
  if (separatorIndex === -1) {
2276
- if (item)
2277
- params2[item] = true;
4092
+ if (item) params2[item] = true;
2278
4093
  continue;
2279
4094
  }
2280
4095
  const key = item.slice(0, separatorIndex);
2281
4096
  const val = item.slice(separatorIndex + 1).replace(/\\=/g, "=");
2282
- if (key)
2283
- params2[key] = val || true;
4097
+ if (key) params2[key] = val || true;
2284
4098
  }
2285
4099
  switch (params2.plugin) {
2286
4100
  case "obfs-local":
@@ -2421,7 +4235,9 @@ function URI_SSR() {
2421
4235
  ...proxy,
2422
4236
  name: other_params.remarks ? Base64.decode(other_params.remarks) : proxy.server,
2423
4237
  "protocol-param": getIfNotBlank(
2424
- Base64.decode(other_params.protoparam || "").replace(/\s/g, "")
4238
+ Base64.decode(
4239
+ other_params.protoparam || other_params.protocolparam || ""
4240
+ ).replace(/\s/g, "")
2425
4241
  ),
2426
4242
  "obfs-param": getIfNotBlank(
2427
4243
  Base64.decode(other_params.obfsparam || "").replace(/\s/g, "")
@@ -2437,6 +4253,9 @@ function URI_VMess() {
2437
4253
  return /^vmess:\/\//.test(line);
2438
4254
  };
2439
4255
  const parse2 = (line) => {
4256
+ if (/^vmess:\/\/[^/?#]+@/.test(line)) {
4257
+ return URI_VLESS().parse(line, "vmess");
4258
+ }
2440
4259
  let { content: lineWithoutFragment, fragment: fragmentName } = splitURIFragment(line.split("vmess://")[1]);
2441
4260
  let content = Base64.decode(lineWithoutFragment.replace(/\?.*?$/, ""));
2442
4261
  if (/=\s*vmess/.test(content)) {
@@ -2659,7 +4478,7 @@ function URI_VLESS() {
2659
4478
  const test = (line) => {
2660
4479
  return /^vless:\/\//.test(line);
2661
4480
  };
2662
- const parse2 = (line) => {
4481
+ const parse2 = (line, protocol = "vless") => {
2663
4482
  const mapXmuxToReuseSettings = (xmux) => {
2664
4483
  if (!isPlainObject(xmux)) {
2665
4484
  return void 0;
@@ -3369,7 +5188,7 @@ function URI_VLESS() {
3369
5188
  }
3370
5189
  return Object.keys(parsedDownloadSettings).length > 0 ? parsedDownloadSettings : void 0;
3371
5190
  };
3372
- line = line.split("vless://")[1];
5191
+ line = line.split(`${protocol}://`)[1];
3373
5192
  let isShadowrocket;
3374
5193
  let parsed = /^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(line);
3375
5194
  if (!parsed) {
@@ -3388,7 +5207,7 @@ function URI_VLESS() {
3388
5207
  name2 = decodeURIComponent(name2);
3389
5208
  }
3390
5209
  const proxy = {
3391
- type: "vless",
5210
+ type: protocol,
3392
5211
  name: name2,
3393
5212
  server,
3394
5213
  port,
@@ -3398,13 +5217,11 @@ function URI_VLESS() {
3398
5217
  const params = {};
3399
5218
  for (const addon of addons.split("&")) {
3400
5219
  if (addon) {
3401
- const [key, valueRaw] = addon.split("=");
3402
- let value = valueRaw;
3403
- value = decodeURIComponent(valueRaw);
3404
- params[key] = value;
5220
+ const [key, ...value] = addon.split("=");
5221
+ params[key] = decodeURIComponent(value.join("="));
3405
5222
  }
3406
5223
  }
3407
- proxy.name = name2 ?? params.remarks ?? params.remark ?? `VLESS ${server}:${port}`;
5224
+ proxy.name = name2 ?? params.remarks ?? params.remark ?? `${protocol === "vmess" ? "VMess" : "VLESS"} ${server}:${port}`;
3408
5225
  proxy.tls = params.security && params.security !== "none";
3409
5226
  if (params.pbk) {
3410
5227
  params.security = "reality";
@@ -3450,6 +5267,10 @@ function URI_VLESS() {
3450
5267
  const opts = {};
3451
5268
  if (params.pbk) {
3452
5269
  opts["public-key"] = params.pbk;
5270
+ const mlkem = params["support-x25519mlkem768"];
5271
+ if (["1", "t", "T", "true", "TRUE", "True"].includes(mlkem)) {
5272
+ opts["support-x25519mlkem768"] = true;
5273
+ }
3453
5274
  }
3454
5275
  if (params.sid) {
3455
5276
  opts["short-id"] = params.sid;
@@ -3612,7 +5433,11 @@ function URI_VLESS() {
3612
5433
  proxy._mode = params.mode;
3613
5434
  }
3614
5435
  }
3615
- if (params.encryption) {
5436
+ if (protocol === "vmess") {
5437
+ proxy.cipher = normalizeVmessSecurity(params.encryption);
5438
+ proxy.alterId = 0;
5439
+ delete proxy.flow;
5440
+ } else if (params.encryption) {
3616
5441
  proxy.encryption = params.encryption;
3617
5442
  }
3618
5443
  if (params.pqv) {
@@ -3943,8 +5768,7 @@ function URI_WireGuard() {
3943
5768
  } else if (["address", "ip"].includes(key)) {
3944
5769
  value.split(",").map((i) => {
3945
5770
  const parsed = parseWireGuardURIAddressValue(i);
3946
- if (!parsed)
3947
- return;
5771
+ if (!parsed) return;
3948
5772
  if (parsed.family === "ipv4") {
3949
5773
  proxy.ip = parsed.address;
3950
5774
  if (typeof parsed.cidr !== "undefined") {
@@ -4026,12 +5850,14 @@ function Clash_All() {
4026
5850
  "gost-relay",
4027
5851
  "openvpn",
4028
5852
  "tailscale",
5853
+ "easytier",
4029
5854
  "trusttunnel",
4030
5855
  "h2-connect",
4031
5856
  "naive",
4032
5857
  "anytls",
4033
5858
  "mieru",
4034
5859
  "masque",
5860
+ "masque-surge",
4035
5861
  "sudoku",
4036
5862
  "juicity",
4037
5863
  "ss",
@@ -4342,6 +6168,19 @@ function Surge_TrustTunnel() {
4342
6168
  const parse2 = (line) => getParser().parse(line);
4343
6169
  return { name, test, parse: parse2 };
4344
6170
  }
6171
+ function Surge_Masque() {
6172
+ const name = "Surge MASQUE Parser";
6173
+ const test = (line) => {
6174
+ return /^.*=\s*masque/.test(line.split(",")[0]);
6175
+ };
6176
+ const parse2 = (raw) => {
6177
+ const { port_hopping, line } = surge_port_hopping(raw);
6178
+ const proxy = getParser().parse(line);
6179
+ proxy.ports = port_hopping;
6180
+ return proxy;
6181
+ };
6182
+ return { name, test, parse: parse2 };
6183
+ }
4345
6184
  function Surge_H2Connect() {
4346
6185
  const name = "Surge HTTP/2 CONNECT Parser";
4347
6186
  const test = (line) => {
@@ -4521,6 +6360,7 @@ var parsers_default = [
4521
6360
  Surge_Direct(),
4522
6361
  Surge_AnyTLS(),
4523
6362
  Surge_TrustTunnel(),
6363
+ Surge_Masque(),
4524
6364
  Surge_H2Connect(),
4525
6365
  Surge_SSH(),
4526
6366
  Surge_SS(),
@@ -4656,8 +6496,7 @@ function fallbackBase64Encoded() {
4656
6496
  function Clash() {
4657
6497
  const name = "Clash Pre-processor";
4658
6498
  const test = function(raw) {
4659
- if (!/proxies/.test(raw))
4660
- return false;
6499
+ if (!/proxies/.test(raw)) return false;
4661
6500
  const content = safeLoad(raw);
4662
6501
  return Array.isArray(content.proxies) || Array.isArray(content["proxy-groups"]);
4663
6502
  };
@@ -4754,16 +6593,12 @@ function isShadowsocksOverTls(proxy) {
4754
6593
  return proxy?.type === "ss" && proxy?.tls === true && !isPresent2(proxy, "plugin") && (!isPresent2(proxy, "network") || normalizedNetwork === "tcp");
4755
6594
  }
4756
6595
  function normalizePluginMuxValue(mux) {
4757
- if (typeof mux === "boolean")
4758
- return Number(mux);
6596
+ if (typeof mux === "boolean") return Number(mux);
4759
6597
  if (typeof mux === "string") {
4760
6598
  const normalized = mux.trim().toLowerCase();
4761
- if (normalized === "true")
4762
- return 1;
4763
- if (normalized === "false")
4764
- return 0;
4765
- if (/^\d+$/.test(normalized))
4766
- return parseInt(normalized, 10);
6599
+ if (normalized === "true") return 1;
6600
+ if (normalized === "false") return 0;
6601
+ if (/^\d+$/.test(normalized)) return parseInt(normalized, 10);
4767
6602
  }
4768
6603
  return mux;
4769
6604
  }
@@ -4771,8 +6606,7 @@ function normalizePluginMuxBooleanValue(mux) {
4771
6606
  return Boolean(normalizePluginMuxValue(mux));
4772
6607
  }
4773
6608
  function supportsShadowsocksV2rayPluginMode(proxy, supportedModes) {
4774
- if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin")
4775
- return true;
6609
+ if (proxy?.type !== "ss" || proxy?.plugin !== "v2ray-plugin") return true;
4776
6610
  const normalizedMode = typeof proxy?.["plugin-opts"]?.mode === "string" ? proxy["plugin-opts"].mode.trim().toLowerCase() : proxy?.["plugin-opts"]?.mode;
4777
6611
  return supportedModes.includes(normalizedMode);
4778
6612
  }
@@ -4786,10 +6620,8 @@ function restoreShadowTLSOpts(target, serverNameKey) {
4786
6620
  password: opts.password,
4787
6621
  version: opts.version
4788
6622
  };
4789
- if (opts.host != null)
4790
- target[serverNameKey] = opts.host;
4791
- if (opts.alpn != null)
4792
- target.alpn = opts.alpn;
6623
+ if (opts.host != null) target[serverNameKey] = opts.host;
6624
+ if (opts.alpn != null) target.alpn = opts.alpn;
4793
6625
  delete target.plugin;
4794
6626
  delete target["plugin-opts"];
4795
6627
  return enabled;
@@ -4809,28 +6641,22 @@ function restoreShadowTLSProxyOpts(proxy) {
4809
6641
  }
4810
6642
  }
4811
6643
  function parseWireGuardCIDR(cidr, max) {
4812
- if (cidr == null)
4813
- return void 0;
6644
+ if (cidr == null) return void 0;
4814
6645
  const normalized = `${cidr}`.trim();
4815
- if (!/^\d+$/.test(normalized))
4816
- return void 0;
6646
+ if (!/^\d+$/.test(normalized)) return void 0;
4817
6647
  const parsed = parseInt(normalized, 10);
4818
- if (parsed < 0 || parsed > max)
4819
- return void 0;
6648
+ if (parsed < 0 || parsed > max) return void 0;
4820
6649
  return parsed;
4821
6650
  }
4822
6651
  function parseWireGuardInterfaceAddress(value, family) {
4823
- if (value == null)
4824
- return null;
6652
+ if (value == null) return null;
4825
6653
  const raw = `${value}`.trim();
4826
- if (!raw)
4827
- return null;
6654
+ if (!raw) return null;
4828
6655
  const [, hostRaw = raw, cidrRaw] = /^(.*?)(?:\/(\d+))?$/.exec(raw) || [];
4829
6656
  const host = `${hostRaw}`.trim().replace(/^\[/, "").replace(/\]$/, "");
4830
6657
  const isIPv4Family = family === "ipv4";
4831
6658
  const isValid = isIPv4Family ? isIPv4(host) : isIPv6(host);
4832
- if (!isValid)
4833
- return null;
6659
+ if (!isValid) return null;
4834
6660
  const max = isIPv4Family ? 32 : 128;
4835
6661
  return {
4836
6662
  address: host,
@@ -4843,8 +6669,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
4843
6669
  proxy[config.addressKey],
4844
6670
  family
4845
6671
  );
4846
- if (!parsed)
4847
- return void 0;
6672
+ if (!parsed) return void 0;
4848
6673
  const normalizedCIDR = parseWireGuardCIDR(
4849
6674
  proxy[config.cidrKey],
4850
6675
  config.defaultCIDR
@@ -4852,8 +6677,7 @@ function getWireGuardAddressWithCIDR(proxy = {}, family = "ipv4") {
4852
6677
  return `${parsed.address}/${normalizedCIDR ?? parsed.cidr ?? config.defaultCIDR}`;
4853
6678
  }
4854
6679
  function produceProxyListOutput(list, type, opts = {}) {
4855
- if (type === "internal")
4856
- return list;
6680
+ if (type === "internal") return list;
4857
6681
  if (opts.prettyYaml || opts["pretty-yaml"]) {
4858
6682
  return normalizeClashYaml(
4859
6683
  yaml_default.safeDump(
@@ -4888,8 +6712,7 @@ var ipVersions = {
4888
6712
  "ipv6-prefer": "prefer-v6"
4889
6713
  };
4890
6714
  function stripSurgeQuotes(value) {
4891
- if (typeof value !== "string")
4892
- return value;
6715
+ if (typeof value !== "string") return value;
4893
6716
  const trimmed = value.trim();
4894
6717
  const quote = trimmed[0];
4895
6718
  if ((quote === '"' || quote === "'") && trimmed[trimmed.length - 1] === quote) {
@@ -4910,23 +6733,19 @@ function formatSurgeAlpn(alpn) {
4910
6733
  }
4911
6734
  function appendAlpn(result, proxy) {
4912
6735
  const alpn = formatSurgeAlpn(proxy.alpn);
4913
- if (alpn)
4914
- result.append(`,alpn="${alpn}"`);
6736
+ if (alpn) result.append(`,alpn="${alpn}"`);
4915
6737
  }
4916
6738
  function getShadowTLSAlpn(proxy) {
4917
6739
  return formatSurgeAlpn(proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn);
4918
6740
  }
4919
6741
  function appendShadowTLS(result, proxy, includeUdpPort = false) {
4920
- if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
4921
- return;
6742
+ if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
4922
6743
  const password = proxy["plugin-opts"].password;
4923
6744
  const host = proxy["plugin-opts"].host;
4924
6745
  const version = proxy["plugin-opts"].version;
4925
- if (!password)
4926
- return;
6746
+ if (!password) return;
4927
6747
  result.append(`,shadow-tls-password="${password}"`);
4928
- if (host)
4929
- result.append(`,shadow-tls-sni=${host}`);
6748
+ if (host) result.append(`,shadow-tls-sni=${host}`);
4930
6749
  if (version) {
4931
6750
  if (version < 2) {
4932
6751
  throw unsupported(`shadow-tls version ${version} is not supported`);
@@ -4934,8 +6753,7 @@ function appendShadowTLS(result, proxy, includeUdpPort = false) {
4934
6753
  result.append(`,shadow-tls-version=${version}`);
4935
6754
  }
4936
6755
  const alpn = getShadowTLSAlpn(proxy);
4937
- if (alpn)
4938
- result.append(`,alpn="${alpn}"`);
6756
+ if (alpn) result.append(`,alpn="${alpn}"`);
4939
6757
  if (includeUdpPort) {
4940
6758
  result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
4941
6759
  }
@@ -4974,11 +6792,9 @@ function appendSshPrivateKey(result, proxy) {
4974
6792
  }
4975
6793
  }
4976
6794
  function warnMaxStreamsIfNeeded(proxy) {
4977
- if (!isPresent2(proxy, "max-streams"))
4978
- return;
6795
+ if (!isPresent2(proxy, "max-streams")) return;
4979
6796
  const maxStreams = Number(stripSurgeQuotes(proxy["max-streams"]));
4980
- if (!Number.isInteger(maxStreams) || maxStreams <= 3)
4981
- return;
6797
+ if (!Number.isInteger(maxStreams) || maxStreams <= 3) return;
4982
6798
  app_default.warn(
4983
6799
  `Surge ${proxy.type} proxy ${proxy.name}: max-streams=${maxStreams} is greater than 3. Too many streams sharing one TCP connection may hurt performance.`
4984
6800
  );
@@ -5027,6 +6843,8 @@ function Surge_Producer() {
5027
6843
  return ssh(proxy);
5028
6844
  case "trusttunnel":
5029
6845
  return trusttunnel(proxy);
6846
+ case "masque-surge":
6847
+ return masque_surge(proxy);
5030
6848
  }
5031
6849
  if (opts["include-unsupported-proxy"] && proxy.type === "wireguard") {
5032
6850
  return wireguard(proxy);
@@ -5147,7 +6965,6 @@ function trojan(proxy) {
5147
6965
  result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
5148
6966
  appendTlsProxyParams(result, proxy);
5149
6967
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5150
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5151
6968
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5152
6969
  result.appendIfPresent(
5153
6970
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5185,7 +7002,6 @@ function anytls(proxy) {
5185
7002
  );
5186
7003
  appendTlsProxyParams(result, proxy);
5187
7004
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5188
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5189
7005
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5190
7006
  result.appendIfPresent(
5191
7007
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5222,6 +7038,7 @@ function trusttunnel(proxy) {
5222
7038
  `,max-streams=${proxy["max-streams"]}`,
5223
7039
  "max-streams"
5224
7040
  );
7041
+ if (proxy.network === "h3") result.append(",h3=true");
5225
7042
  const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
5226
7043
  result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
5227
7044
  result.appendIfPresent(
@@ -5230,7 +7047,6 @@ function trusttunnel(proxy) {
5230
7047
  );
5231
7048
  appendTlsProxyParams(result, proxy);
5232
7049
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5233
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5234
7050
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5235
7051
  result.appendIfPresent(
5236
7052
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5256,6 +7072,56 @@ function trusttunnel(proxy) {
5256
7072
  result.appendIfPresent(`,reuse=${proxy["reuse"]}`, "reuse");
5257
7073
  return result.toString();
5258
7074
  }
7075
+ function masque_surge(proxy) {
7076
+ const result = new Result(proxy);
7077
+ result.append(`${proxy.name}=masque,${proxy.server},${proxy.port}`);
7078
+ result.appendIfPresent(`,username="${proxy.username}"`, "username");
7079
+ result.appendIfPresent(`,password="${proxy.password}"`, "password");
7080
+ if (hasNonBlankValue(proxy.ports)) {
7081
+ result.append(
7082
+ `,port-hopping="${String(proxy.ports).replace(/,/g, ";")}"`
7083
+ );
7084
+ }
7085
+ if (hasNonBlankValue(proxy["hop-interval"])) {
7086
+ result.append(`,port-hopping-interval=${proxy["hop-interval"]}`);
7087
+ }
7088
+ const ip_version = ipVersions[proxy["ip-version"]] || proxy["ip-version"];
7089
+ result.appendIfPresent(`,ip-version=${ip_version}`, "ip-version");
7090
+ result.appendIfPresent(
7091
+ `,no-error-alert=${proxy["no-error-alert"]}`,
7092
+ "no-error-alert"
7093
+ );
7094
+ appendTlsProxyParams(result, proxy);
7095
+ if (isPresent2(proxy, "tfo")) {
7096
+ result.append(`,tfo=${proxy.tfo}`);
7097
+ } else if (isPresent2(proxy, "fast-open")) {
7098
+ result.append(`,tfo=${proxy["fast-open"]}`);
7099
+ }
7100
+ result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
7101
+ result.appendIfPresent(
7102
+ `,test-timeout=${proxy["test-timeout"]}`,
7103
+ "test-timeout"
7104
+ );
7105
+ result.appendIfPresent(`,test-udp=${proxy["test-udp"]}`, "test-udp");
7106
+ result.appendIfPresent(`,hybrid=${proxy.hybrid}`, "hybrid");
7107
+ result.appendIfPresent(`,tos=${proxy.tos}`, "tos");
7108
+ result.appendIfPresent(
7109
+ `,allow-other-interface=${proxy["allow-other-interface"]}`,
7110
+ "allow-other-interface"
7111
+ );
7112
+ result.appendIfPresent(
7113
+ `,interface=${proxy["interface-name"]}`,
7114
+ "interface-name"
7115
+ );
7116
+ result.appendIfPresent(`,interface=${proxy.interface}`, "interface");
7117
+ result.appendIfPresent(`,block-quic=${proxy["block-quic"]}`, "block-quic");
7118
+ result.appendIfPresent(
7119
+ `,underlying-proxy=${proxy["underlying-proxy"]}`,
7120
+ "underlying-proxy"
7121
+ );
7122
+ result.appendIfPresent(`,ecn=${proxy.ecn}`, "ecn");
7123
+ return result.toString();
7124
+ }
5259
7125
  function h2Connect(proxy) {
5260
7126
  const result = new Result(proxy);
5261
7127
  result.append(`${proxy.name}=h2-connect,${proxy.server},${proxy.port}`);
@@ -5326,7 +7192,6 @@ function vmess(proxy, includeUnsupportedProxy) {
5326
7192
  result.appendIfPresent(`,tls=${proxy.tls}`, "tls");
5327
7193
  appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
5328
7194
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5329
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5330
7195
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5331
7196
  result.appendIfPresent(
5332
7197
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5373,7 +7238,6 @@ function ssh(proxy) {
5373
7238
  "no-error-alert"
5374
7239
  );
5375
7240
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5376
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5377
7241
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5378
7242
  result.appendIfPresent(
5379
7243
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5413,7 +7277,6 @@ function http(proxy) {
5413
7277
  );
5414
7278
  appendTlsProxyParams(result, proxy, Boolean(proxy.tls));
5415
7279
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5416
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5417
7280
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5418
7281
  result.appendIfPresent(
5419
7282
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5450,7 +7313,6 @@ function direct(proxy) {
5450
7313
  "no-error-alert"
5451
7314
  );
5452
7315
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5453
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5454
7316
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5455
7317
  result.appendIfPresent(
5456
7318
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5565,7 +7427,6 @@ function snell(proxy) {
5565
7427
  "obfs-opts.path"
5566
7428
  );
5567
7429
  result.appendIfPresent(`,tfo=${proxy.tfo}`, "tfo");
5568
- result.appendIfPresent(`,udp-relay=${proxy.udp}`, "udp");
5569
7430
  result.appendIfPresent(`,test-url=${proxy["test-url"]}`, "test-url");
5570
7431
  result.appendIfPresent(
5571
7432
  `,test-timeout=${proxy["test-timeout"]}`,
@@ -5902,14 +7763,19 @@ function ClashMeta_Producer() {
5902
7763
  const type = "ALL";
5903
7764
  const produce2 = (proxies, type2, opts = {}) => {
5904
7765
  const list = proxies.filter((proxy) => {
5905
- if (opts["include-unsupported-proxy"])
5906
- return true;
7766
+ if (opts["include-unsupported-proxy"]) return true;
5907
7767
  if (proxy.type === "h2-connect") {
5908
7768
  app_default.error(
5909
7769
  `mihomo does not support HTTP/2 CONNECT proxy type. Proxy ${proxy.name} has been filtered.`
5910
7770
  );
5911
7771
  return false;
5912
7772
  }
7773
+ if (proxy.type === "masque-surge") {
7774
+ app_default.error(
7775
+ `mihomo does not support Surge MASQUE proxy type. Proxy ${proxy.name} has been filtered.`
7776
+ );
7777
+ return false;
7778
+ }
5913
7779
  if (hasRootHeaders(proxy) && proxy.type === "trusttunnel") {
5914
7780
  app_default.error(
5915
7781
  `mihomo does not support headers for TrustTunnel proxy ${proxy.name}. Proxy has been filtered.`
@@ -6210,6 +8076,8 @@ function SurgeMac_Producer() {
6210
8076
  switch (proxy.type) {
6211
8077
  case "external":
6212
8078
  return external(proxy);
8079
+ // case 'ssr':
8080
+ // return shadowsocksr(proxy);
6213
8081
  default: {
6214
8082
  if (opts.mihomoExternal || proxy._mihomoExternal) {
6215
8083
  return mihomo(proxy, type, opts) || "";
@@ -6336,10 +8204,13 @@ function mihomo(proxy, type, opts) {
6336
8204
  ...clashProxy,
6337
8205
  name: proxyName
6338
8206
  });
6339
- opts._merged.config = {
6340
- ...opts._merged.config,
6341
- ...opts?.config || proxy._config || {}
6342
- };
8207
+ const configOverride = opts?.config || proxy._config;
8208
+ if (configOverride) {
8209
+ opts._merged.configOverride = {
8210
+ ...opts._merged.configOverride || {},
8211
+ ...configOverride
8212
+ };
8213
+ }
6343
8214
  } else {
6344
8215
  const external_proxy = {
6345
8216
  name: proxy.name,
@@ -6396,8 +8267,7 @@ function Clash_Producer() {
6396
8267
  const type = "ALL";
6397
8268
  const produce2 = (proxies, type2, opts = {}) => {
6398
8269
  const list = proxies.filter((proxy) => {
6399
- if (opts["include-unsupported-proxy"])
6400
- return true;
8270
+ if (opts["include-unsupported-proxy"]) return true;
6401
8271
  if (![
6402
8272
  "ss",
6403
8273
  "ssr",
@@ -6552,8 +8422,7 @@ function Stash_Producer() {
6552
8422
  const type = "ALL";
6553
8423
  const produce2 = (proxies, type2, opts = {}) => {
6554
8424
  const list = proxies.filter((proxy) => {
6555
- if (opts["include-unsupported-proxy"])
6556
- return true;
8425
+ if (opts["include-unsupported-proxy"]) return true;
6557
8426
  if (![
6558
8427
  "ss",
6559
8428
  "ssr",
@@ -6571,7 +8440,9 @@ function Stash_Producer() {
6571
8440
  "juicity",
6572
8441
  "anytls",
6573
8442
  "tailscale",
6574
- "trusttunnel"
8443
+ "trusttunnel",
8444
+ "masque",
8445
+ "mieru"
6575
8446
  ].includes(proxy.type) || proxy.type === "ss" && ![
6576
8447
  "aes-128-gcm",
6577
8448
  "aes-192-gcm",
@@ -6589,7 +8460,7 @@ function Stash_Producer() {
6589
8460
  "xchacha20-ietf-poly1305",
6590
8461
  "2022-blake3-aes-128-gcm",
6591
8462
  "2022-blake3-aes-256-gcm"
6592
- ].includes(proxy.cipher) || proxy.type === "snell" && proxy.version >= 4) {
8463
+ ].includes(proxy.cipher) || proxy.type === "snell" && proxy.version > 6) {
6593
8464
  return false;
6594
8465
  } else if (!supportsShadowsocksV2rayPluginMode(proxy, ["websocket"])) {
6595
8466
  return false;
@@ -6597,9 +8468,7 @@ function Stash_Producer() {
6597
8468
  return false;
6598
8469
  } else if (["anytls"].includes(proxy.type) && proxy.network && (!["tcp"].includes(proxy.network) || ["tcp"].includes(proxy.network) && proxy["reality-opts"])) {
6599
8470
  return false;
6600
- } else if (["xhttp"].includes(proxy.network)) {
6601
- return false;
6602
- } else if (proxy.encryption && proxy.encryption !== "none" && ["vless"].includes(proxy.type)) {
8471
+ } else if (!["vless"].includes(proxy.type) && ["xhttp"].includes(proxy.network)) {
6603
8472
  return false;
6604
8473
  } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
6605
8474
  return false;
@@ -6843,13 +8712,11 @@ function Loon_Producer() {
6843
8712
  }
6844
8713
  function appendTlsProfile(result, proxy) {
6845
8714
  const tlsProfile = getLoonTlsProfile(proxy);
6846
- if (tlsProfile)
6847
- result.append(`,tls-profile=${tlsProfile}`);
8715
+ if (tlsProfile) result.append(`,tls-profile=${tlsProfile}`);
6848
8716
  }
6849
8717
  function appendAlpn2(result, proxy) {
6850
8718
  const alpn = getLoonAlpn(proxy);
6851
- if (alpn)
6852
- result.append(`,alpn="${alpn}"`);
8719
+ if (alpn) result.append(`,alpn="${alpn}"`);
6853
8720
  }
6854
8721
  function getLoonShadowTLSAlpn(proxy) {
6855
8722
  const values = proxy?.["plugin-opts"]?.alpn ?? proxy?.alpn;
@@ -6857,16 +8724,13 @@ function getLoonShadowTLSAlpn(proxy) {
6857
8724
  return normalized.map((item) => `${item}`.trim()).filter((item) => item !== "").join(",");
6858
8725
  }
6859
8726
  function appendShadowTLS2(result, proxy) {
6860
- if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"])
6861
- return;
8727
+ if (proxy.plugin !== "shadow-tls" || !proxy["plugin-opts"]) return;
6862
8728
  const password = proxy["plugin-opts"].password;
6863
8729
  const host = proxy["plugin-opts"].host;
6864
8730
  const version = proxy["plugin-opts"].version;
6865
- if (!password)
6866
- return;
8731
+ if (!password) return;
6867
8732
  result.append(`,shadow-tls-password=${password}`);
6868
- if (host)
6869
- result.append(`,shadow-tls-sni=${host}`);
8733
+ if (host) result.append(`,shadow-tls-sni=${host}`);
6870
8734
  if (version) {
6871
8735
  if (version < 2) {
6872
8736
  throw new Error(`shadow-tls version ${version} is not supported`);
@@ -6875,8 +8739,7 @@ function appendShadowTLS2(result, proxy) {
6875
8739
  }
6876
8740
  appendTlsProfile(result, proxy);
6877
8741
  const alpn = getLoonShadowTLSAlpn(proxy);
6878
- if (alpn)
6879
- result.append(`,alpn="${alpn}"`);
8742
+ if (alpn) result.append(`,alpn="${alpn}"`);
6880
8743
  result.appendIfPresent(`,udp-port=${proxy["udp-port"]}`, "udp-port");
6881
8744
  }
6882
8745
  function appendReality(result, proxy) {
@@ -7459,8 +9322,7 @@ function getHttpUpgradeEarlyData(transportOpts, path) {
7459
9322
  const httpUpgradeEd = getSafeEarlyDataValue(
7460
9323
  transportOpts?.["_v2ray-http-upgrade-ed"]
7461
9324
  );
7462
- if (httpUpgradeEd !== "")
7463
- return httpUpgradeEd;
9325
+ if (httpUpgradeEd !== "") return httpUpgradeEd;
7464
9326
  const pathEd = getSafeEarlyDataValue(
7465
9327
  extractPathQueryParam(path || "/", "ed").value
7466
9328
  );
@@ -7492,8 +9354,7 @@ function setWebSocketEarlyDataPath(path, transportOpts) {
7492
9354
  return setPathQueryParam(path || "/", "ed", earlyData);
7493
9355
  }
7494
9356
  function getSafeEarlyDataValue(value) {
7495
- if (value == null || `${value}` === "")
7496
- return "";
9357
+ if (value == null || `${value}` === "") return "";
7497
9358
  return parseSafeIntegerValue(value) == null ? "" : `${value}`;
7498
9359
  }
7499
9360
  function parseIntegerLikeValue(value) {
@@ -7852,6 +9713,10 @@ function vless2(proxy) {
7852
9713
  const publicKey = proxy["reality-opts"]?.["public-key"];
7853
9714
  if (publicKey) {
7854
9715
  pbk = `&pbk=${encodeURIComponent(publicKey)}`;
9716
+ const mlkem = proxy["reality-opts"]["support-x25519mlkem768"];
9717
+ if (mlkem) {
9718
+ pbk += `&support-x25519mlkem768=${encodeURIComponent(mlkem)}`;
9719
+ }
7855
9720
  }
7856
9721
  const shortId = proxy["reality-opts"]?.["short-id"];
7857
9722
  if (shortId) {
@@ -8219,10 +10084,25 @@ function URI_Producer() {
8219
10084
  break;
8220
10085
  case "ssr":
8221
10086
  result = `${proxy.server}:${proxy.port}:${proxy.protocol}:${proxy.cipher}:${proxy.obfs}:${Base644.encode(proxy.password)}/`;
8222
- result += `?remarks=${Base644.encode(proxy.name)}${proxy["obfs-param"] ? "&obfsparam=" + Base644.encode(proxy["obfs-param"]) : ""}${proxy["protocol-param"] ? "&protocolparam=" + Base644.encode(proxy["protocol-param"]) : ""}`;
10087
+ result += `?remarks=${Base644.encode(proxy.name)}${proxy["obfs-param"] ? "&obfsparam=" + Base644.encode(proxy["obfs-param"]) : ""}${proxy["protocol-param"] ? "&protoparam=" + Base644.encode(proxy["protocol-param"]) : ""}`;
8223
10088
  result = "ssr://" + Base644.encode(result);
8224
10089
  break;
8225
10090
  case "vmess":
10091
+ if (proxy["reality-opts"]) {
10092
+ if (proxy.aead === false || proxy.aead !== true && Number(proxy.alterId || 0) !== 0) {
10093
+ throw new Error(
10094
+ "VMess REALITY URI requires AEAD (alterId=0)"
10095
+ );
10096
+ }
10097
+ result = vless2({
10098
+ ...proxy,
10099
+ server: isIPv6(proxy.server) ? `[${proxy.server}]` : proxy.server,
10100
+ network: proxy.network || "tcp",
10101
+ encryption: normalizeVmessSecurity(proxy.cipher),
10102
+ flow: void 0
10103
+ }).replace(/^vless:\/\//, "vmess://");
10104
+ break;
10105
+ }
8226
10106
  let type2 = "";
8227
10107
  let net = proxy.network || "tcp";
8228
10108
  if (proxy.network === "http") {
@@ -8710,7 +10590,26 @@ Reason: ${err}`);
8710
10590
  }
8711
10591
 
8712
10592
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/qx.js
10593
+ var import_buffer2 = __toESM(require_buffer());
8713
10594
  var targetPlatform4 = "QX";
10595
+ function encodeQxAlpn(alpn) {
10596
+ const protocols = (Array.isArray(alpn) ? alpn : `${alpn}`.split(",")).map((protocol) => `${protocol}`.trim()).filter(Boolean);
10597
+ return protocols.map((protocol) => {
10598
+ const bytes = import_buffer2.Buffer.from(protocol, "utf8");
10599
+ if (bytes.length > 255) {
10600
+ throw new Error("QX ALPN protocol exceeds 255 bytes");
10601
+ }
10602
+ return `${bytes.length.toString(16).padStart(2, "0")}${bytes.toString("hex")}`;
10603
+ }).join("") || void 0;
10604
+ }
10605
+ function appendTlsAlpn(result, proxy) {
10606
+ if (isPresent2(proxy, "tls-alpn")) {
10607
+ result.append(`,tls-alpn=${proxy["tls-alpn"]}`);
10608
+ return;
10609
+ }
10610
+ const encoded = isPresent2(proxy, "alpn") && encodeQxAlpn(proxy.alpn);
10611
+ if (encoded) result.append(`,tls-alpn=${encoded}`);
10612
+ }
8714
10613
  function QX_Producer() {
8715
10614
  const produce2 = (proxy, type, opts = {}) => {
8716
10615
  if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
@@ -8830,10 +10729,8 @@ function shadowsocks3(proxy) {
8830
10729
  }
8831
10730
  } else if (proxy.plugin === "v2ray-plugin" && proxy["plugin-opts"].mode === "websocket") {
8832
10731
  const opts = proxy["plugin-opts"];
8833
- if (opts.tls)
8834
- append(`,obfs=wss`);
8835
- else
8836
- append(`,obfs=ws`);
10732
+ if (opts.tls) append(`,obfs=wss`);
10733
+ else append(`,obfs=ws`);
8837
10734
  } else {
8838
10735
  throw new Error(`plugin is not supported`);
8839
10736
  }
@@ -8851,7 +10748,7 @@ function shadowsocks3(proxy) {
8851
10748
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
8852
10749
  "tls-pubkey-sha256"
8853
10750
  );
8854
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
10751
+ appendTlsAlpn(result, proxy);
8855
10752
  appendIfPresent(
8856
10753
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
8857
10754
  "tls-no-session-ticket"
@@ -8918,10 +10815,8 @@ function trojan3(proxy) {
8918
10815
  append(`,password=${proxy.password}`);
8919
10816
  if (isPresent2(proxy, "network")) {
8920
10817
  if (proxy.network === "ws") {
8921
- if (needTls(proxy))
8922
- append(`,obfs=wss`);
8923
- else
8924
- append(`,obfs=ws`);
10818
+ if (needTls(proxy)) append(`,obfs=wss`);
10819
+ else append(`,obfs=ws`);
8925
10820
  appendIfPresent(
8926
10821
  `,obfs-uri=${proxy["ws-opts"]?.path}`,
8927
10822
  "ws-opts.path"
@@ -8942,7 +10837,7 @@ function trojan3(proxy) {
8942
10837
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
8943
10838
  "tls-pubkey-sha256"
8944
10839
  );
8945
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
10840
+ appendTlsAlpn(result, proxy);
8946
10841
  appendIfPresent(
8947
10842
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
8948
10843
  "tls-no-session-ticket"
@@ -8980,15 +10875,12 @@ function vmess3(proxy) {
8980
10875
  }
8981
10876
  if (isPresent2(proxy, "network")) {
8982
10877
  if (proxy.network === "ws") {
8983
- if (proxy.tls)
8984
- append(`,obfs=wss`);
8985
- else
8986
- append(`,obfs=ws`);
10878
+ if (proxy.tls) append(`,obfs=wss`);
10879
+ else append(`,obfs=ws`);
8987
10880
  } else if (proxy.network === "http") {
8988
10881
  append(`,obfs=${getQxHttpObfs(proxy)}`);
8989
10882
  } else if (["tcp"].includes(proxy.network)) {
8990
- if (proxy.tls)
8991
- append(`,obfs=over-tls`);
10883
+ if (proxy.tls) append(`,obfs=over-tls`);
8992
10884
  } else if (!["tcp"].includes(proxy.network)) {
8993
10885
  throw new Error(`network ${proxy.network} is unsupported`);
8994
10886
  }
@@ -9003,15 +10895,14 @@ function vmess3(proxy) {
9003
10895
  `${proxy.network}-opts.headers.Host`
9004
10896
  );
9005
10897
  } else {
9006
- if (proxy.tls)
9007
- append(`,obfs=over-tls`);
10898
+ if (proxy.tls) append(`,obfs=over-tls`);
9008
10899
  }
9009
10900
  if (needTls(proxy)) {
9010
10901
  appendIfPresent(
9011
10902
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
9012
10903
  "tls-pubkey-sha256"
9013
10904
  );
9014
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
10905
+ appendTlsAlpn(result, proxy);
9015
10906
  appendIfPresent(
9016
10907
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
9017
10908
  "tls-no-session-ticket"
@@ -9056,15 +10947,12 @@ function vless3(proxy) {
9056
10947
  }
9057
10948
  if (isPresent2(proxy, "network")) {
9058
10949
  if (proxy.network === "ws") {
9059
- if (proxy.tls)
9060
- append(`,obfs=wss`);
9061
- else
9062
- append(`,obfs=ws`);
10950
+ if (proxy.tls) append(`,obfs=wss`);
10951
+ else append(`,obfs=ws`);
9063
10952
  } else if (proxy.network === "http") {
9064
10953
  append(`,obfs=${getQxHttpObfs(proxy)}`);
9065
10954
  } else if (["tcp"].includes(proxy.network)) {
9066
- if (proxy.tls)
9067
- append(`,obfs=over-tls`);
10955
+ if (proxy.tls) append(`,obfs=over-tls`);
9068
10956
  } else if (!["tcp"].includes(proxy.network)) {
9069
10957
  throw new Error(`network ${proxy.network} is unsupported`);
9070
10958
  }
@@ -9079,15 +10967,14 @@ function vless3(proxy) {
9079
10967
  `${proxy.network}-opts.headers.Host`
9080
10968
  );
9081
10969
  } else {
9082
- if (proxy.tls)
9083
- append(`,obfs=over-tls`);
10970
+ if (proxy.tls) append(`,obfs=over-tls`);
9084
10971
  }
9085
10972
  if (needTls(proxy)) {
9086
10973
  appendIfPresent(
9087
10974
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
9088
10975
  "tls-pubkey-sha256"
9089
10976
  );
9090
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
10977
+ appendTlsAlpn(result, proxy);
9091
10978
  appendIfPresent(
9092
10979
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
9093
10980
  "tls-no-session-ticket"
@@ -9131,7 +11018,7 @@ function anytls3(proxy) {
9131
11018
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
9132
11019
  "tls-pubkey-sha256"
9133
11020
  );
9134
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
11021
+ appendTlsAlpn(result, proxy);
9135
11022
  appendIfPresent(
9136
11023
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
9137
11024
  "tls-no-session-ticket"
@@ -9171,7 +11058,7 @@ function http3(proxy) {
9171
11058
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
9172
11059
  "tls-pubkey-sha256"
9173
11060
  );
9174
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
11061
+ appendTlsAlpn(result, proxy);
9175
11062
  appendIfPresent(
9176
11063
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
9177
11064
  "tls-no-session-ticket"
@@ -9212,7 +11099,7 @@ function socks53(proxy) {
9212
11099
  `,tls-pubkey-sha256=${proxy["tls-pubkey-sha256"]}`,
9213
11100
  "tls-pubkey-sha256"
9214
11101
  );
9215
- appendIfPresent(`,tls-alpn=${proxy["tls-alpn"]}`, "tls-alpn");
11102
+ appendTlsAlpn(result, proxy);
9216
11103
  appendIfPresent(
9217
11104
  `,tls-no-session-ticket=${proxy["tls-no-session-ticket"]}`,
9218
11105
  "tls-no-session-ticket"
@@ -9246,8 +11133,7 @@ function Shadowrocket_Producer() {
9246
11133
  const type = "ALL";
9247
11134
  const produce2 = (proxies, type2, opts = {}) => {
9248
11135
  const list = proxies.filter((proxy) => {
9249
- if (opts["include-unsupported-proxy"])
9250
- return true;
11136
+ if (opts["include-unsupported-proxy"]) return true;
9251
11137
  if (!supportsShadowsocksV2rayPluginMode(proxy, [
9252
11138
  "websocket",
9253
11139
  "quic",
@@ -9270,7 +11156,9 @@ function Shadowrocket_Producer() {
9270
11156
  "openvpn",
9271
11157
  "gost-relay",
9272
11158
  "shadowquic",
9273
- "zerotier"
11159
+ "zerotier",
11160
+ "masque-surge",
11161
+ "easytier"
9274
11162
  ].includes(proxy.type)) {
9275
11163
  return false;
9276
11164
  } else if (["xhttp"].includes(proxy.network)) {
@@ -9788,10 +11676,8 @@ var domainResolverParser = (proxy, parsedProxy) => {
9788
11676
  };
9789
11677
  var hasControlHTTPClient = (proxy) => {
9790
11678
  const value = proxy["control-http-client"];
9791
- if (value === void 0 || value === null)
9792
- return false;
9793
- if (typeof value === "string")
9794
- return value.trim() !== "";
11679
+ if (value === void 0 || value === null) return false;
11680
+ if (typeof value === "string") return value.trim() !== "";
9795
11681
  if (isPlainObject(value)) {
9796
11682
  return Object.values(value).some(
9797
11683
  (item) => item !== void 0 && item !== null && item !== ""
@@ -9813,18 +11699,13 @@ var networkParser = (proxy, parsedProxy) => {
9813
11699
  };
9814
11700
  var tfoParser = (proxy, parsedProxy) => {
9815
11701
  parsedProxy.tcp_fast_open = false;
9816
- if (proxy.tfo)
9817
- parsedProxy.tcp_fast_open = true;
9818
- if (proxy.tcp_fast_open)
9819
- parsedProxy.tcp_fast_open = true;
9820
- if (proxy["tcp-fast-open"])
9821
- parsedProxy.tcp_fast_open = true;
9822
- if (!parsedProxy.tcp_fast_open)
9823
- delete parsedProxy.tcp_fast_open;
11702
+ if (proxy.tfo) parsedProxy.tcp_fast_open = true;
11703
+ if (proxy.tcp_fast_open) parsedProxy.tcp_fast_open = true;
11704
+ if (proxy["tcp-fast-open"]) parsedProxy.tcp_fast_open = true;
11705
+ if (!parsedProxy.tcp_fast_open) delete parsedProxy.tcp_fast_open;
9824
11706
  };
9825
11707
  var smuxParser = (smux, proxy) => {
9826
- if (!smux || !smux.enabled)
9827
- return;
11708
+ if (!smux || !smux.enabled) return;
9828
11709
  proxy.multiplex = { enabled: true };
9829
11710
  proxy.multiplex.protocol = smux.protocol;
9830
11711
  if (smux["max-connections"])
@@ -9836,8 +11717,7 @@ var smuxParser = (smux, proxy) => {
9836
11717
  proxy.multiplex.max_streams = parseInt(`${smux["max-streams"]}`, 10);
9837
11718
  if (smux["min-streams"])
9838
11719
  proxy.multiplex.min_streams = parseInt(`${smux["min-streams"]}`, 10);
9839
- if (smux.padding)
9840
- proxy.multiplex.padding = true;
11720
+ if (smux.padding) proxy.multiplex.padding = true;
9841
11721
  if (smux["brutal-opts"]?.up || smux["brutal-opts"]?.down) {
9842
11722
  proxy.multiplex.brutal = {
9843
11723
  enabled: true
@@ -9865,25 +11745,20 @@ var wsParser = (proxy, parsedProxy) => {
9865
11745
  } = proxy["ws-opts"];
9866
11746
  transport.early_data_header_name = early_data_header_name;
9867
11747
  transport.max_early_data = max_early_data ? parseInt(max_early_data, 10) : void 0;
9868
- if (wsPath !== "")
9869
- transport.path = `${wsPath}`;
11748
+ if (wsPath !== "") transport.path = `${wsPath}`;
9870
11749
  if (Object.keys(wsHeaders).length > 0) {
9871
11750
  const headers = {};
9872
11751
  for (const key of Object.keys(wsHeaders)) {
9873
11752
  let value = wsHeaders[key];
9874
- if (value === "")
9875
- continue;
9876
- if (!Array.isArray(value))
9877
- value = [`${value}`];
9878
- if (value.length > 0)
9879
- headers[key] = value;
11753
+ if (value === "") continue;
11754
+ if (!Array.isArray(value)) value = [`${value}`];
11755
+ if (value.length > 0) headers[key] = value;
9880
11756
  }
9881
11757
  const { Host: wsHost } = headers;
9882
11758
  if (wsHost.length === 1)
9883
11759
  for (const item of `Host:${wsHost[0]}`.split("\n")) {
9884
11760
  const [key, value] = item.split(":");
9885
- if (value.trim() === "")
9886
- continue;
11761
+ if (value.trim() === "") continue;
9887
11762
  headers[key.trim()] = value.trim().split(",");
9888
11763
  }
9889
11764
  transport.headers = headers;
@@ -9893,19 +11768,15 @@ var wsParser = (proxy, parsedProxy) => {
9893
11768
  const headers = {};
9894
11769
  for (const key of Object.keys(proxy["ws-headers"])) {
9895
11770
  let value = proxy["ws-headers"][key];
9896
- if (value === "")
9897
- continue;
9898
- if (!Array.isArray(value))
9899
- value = [`${value}`];
9900
- if (value.length > 0)
9901
- headers[key] = value;
11771
+ if (value === "") continue;
11772
+ if (!Array.isArray(value)) value = [`${value}`];
11773
+ if (value.length > 0) headers[key] = value;
9902
11774
  }
9903
11775
  const { Host: wsHost } = headers;
9904
11776
  if (wsHost.length === 1)
9905
11777
  for (const item of `Host:${wsHost[0]}`.split("\n")) {
9906
11778
  const [key, value] = item.split(":");
9907
- if (value.trim() === "")
9908
- continue;
11779
+ if (value.trim() === "") continue;
9909
11780
  headers[key.trim()] = value.trim().split(",");
9910
11781
  }
9911
11782
  for (const key of Object.keys(headers))
@@ -9929,15 +11800,13 @@ var wsParser = (proxy, parsedProxy) => {
9929
11800
  transport.host = transport.headers.Host[0];
9930
11801
  delete transport.headers.Host;
9931
11802
  }
9932
- if (transport.max_early_data)
9933
- delete transport.max_early_data;
11803
+ if (transport.max_early_data) delete transport.max_early_data;
9934
11804
  if (transport.early_data_header_name)
9935
11805
  delete transport.early_data_header_name;
9936
11806
  }
9937
11807
  for (const key of Object.keys(transport.headers)) {
9938
11808
  const value = transport.headers[key];
9939
- if (value.length === 1)
9940
- transport.headers[key] = value[0];
11809
+ if (value.length === 1) transport.headers[key] = value[0];
9941
11810
  }
9942
11811
  parsedProxy.transport = transport;
9943
11812
  };
@@ -9949,52 +11818,43 @@ var h1Parser = (proxy, parsedProxy) => {
9949
11818
  path: h1Path = "",
9950
11819
  headers: h1Headers = {}
9951
11820
  } = proxy["http-opts"];
9952
- if (method !== "")
9953
- transport.method = method;
11821
+ if (method !== "") transport.method = method;
9954
11822
  if (Array.isArray(h1Path)) {
9955
11823
  transport.path = `${h1Path[0]}`;
9956
- } else if (h1Path !== "")
9957
- transport.path = `${h1Path}`;
11824
+ } else if (h1Path !== "") transport.path = `${h1Path}`;
9958
11825
  for (const key of Object.keys(h1Headers)) {
9959
11826
  let value = h1Headers[key];
9960
- if (value === "")
9961
- continue;
11827
+ if (value === "") continue;
9962
11828
  if (key.toLowerCase() === "host") {
9963
11829
  let host = value;
9964
11830
  if (!Array.isArray(host))
9965
11831
  host = `${host}`.split(",").map((i) => i.trim());
9966
- if (host.length > 0)
9967
- transport.host = host;
11832
+ if (host.length > 0) transport.host = host;
9968
11833
  continue;
9969
11834
  }
9970
11835
  if (!Array.isArray(value))
9971
11836
  value = `${value}`.split(",").map((i) => i.trim());
9972
- if (value.length > 0)
9973
- transport.headers[key] = value;
11837
+ if (value.length > 0) transport.headers[key] = value;
9974
11838
  }
9975
11839
  }
9976
11840
  if (proxy["http-host"] && proxy["http-host"] !== "") {
9977
11841
  let host = proxy["http-host"];
9978
11842
  if (!Array.isArray(host))
9979
11843
  host = `${host}`.split(",").map((i) => i.trim());
9980
- if (host.length > 0)
9981
- transport.host = host;
11844
+ if (host.length > 0) transport.host = host;
9982
11845
  }
9983
11846
  if (proxy["http-path"] && proxy["http-path"] !== "") {
9984
11847
  const path = proxy["http-path"];
9985
11848
  if (Array.isArray(path)) {
9986
11849
  transport.path = `${path[0]}`;
9987
- } else if (path !== "")
9988
- transport.path = `${path}`;
11850
+ } else if (path !== "") transport.path = `${path}`;
9989
11851
  }
9990
11852
  if (parsedProxy.tls.insecure)
9991
11853
  parsedProxy.tls.server_name = transport.host[0];
9992
- if (transport.host?.length === 1)
9993
- transport.host = transport.host[0];
11854
+ if (transport.host?.length === 1) transport.host = transport.host[0];
9994
11855
  for (const key of Object.keys(transport.headers)) {
9995
11856
  const value = transport.headers[key];
9996
- if (value.length === 1)
9997
- transport.headers[key] = value[0];
11857
+ if (value.length === 1) transport.headers[key] = value[0];
9998
11858
  }
9999
11859
  parsedProxy.transport = transport;
10000
11860
  };
@@ -10002,29 +11862,25 @@ var h2Parser = (proxy, parsedProxy) => {
10002
11862
  const transport = { type: "http" };
10003
11863
  if (proxy["h2-opts"]) {
10004
11864
  let { host = "", path = "" } = proxy["h2-opts"];
10005
- if (path !== "")
10006
- transport.path = `${path}`;
11865
+ if (path !== "") transport.path = `${path}`;
10007
11866
  if (host !== "") {
10008
11867
  if (!Array.isArray(host))
10009
11868
  host = `${host}`.split(",").map((i) => i.trim());
10010
- if (host.length > 0)
10011
- transport.host = host;
11869
+ if (host.length > 0) transport.host = host;
10012
11870
  }
10013
11871
  }
10014
11872
  if (proxy["h2-host"] && proxy["h2-host"] !== "") {
10015
11873
  let host = proxy["h2-host"];
10016
11874
  if (!Array.isArray(host))
10017
11875
  host = `${host}`.split(",").map((i) => i.trim());
10018
- if (host.length > 0)
10019
- transport.host = host;
11876
+ if (host.length > 0) transport.host = host;
10020
11877
  }
10021
11878
  if (proxy["h2-path"] && proxy["h2-path"] !== "")
10022
11879
  transport.path = `${proxy["h2-path"]}`;
10023
11880
  parsedProxy.tls.enabled = true;
10024
11881
  if (parsedProxy.tls.insecure)
10025
11882
  parsedProxy.tls.server_name = transport.host[0];
10026
- if (transport.host.length === 1)
10027
- transport.host = transport.host[0];
11883
+ if (transport.host.length === 1) transport.host = transport.host[0];
10028
11884
  parsedProxy.transport = transport;
10029
11885
  };
10030
11886
  var grpcParser = (proxy, parsedProxy) => {
@@ -10041,16 +11897,13 @@ var normalizePemLines = (value, label) => {
10041
11897
  const lines = [];
10042
11898
  for (const item of items) {
10043
11899
  const normalized = `${item}`.trim().replace(/\\r\\n/g, "\n").replace(/\\n/g, "\n");
10044
- if (normalized === "")
10045
- continue;
11900
+ if (normalized === "") continue;
10046
11901
  for (const line of normalized.split(/\r?\n/)) {
10047
11902
  const trimmed = line.trim();
10048
- if (trimmed !== "")
10049
- lines.push(trimmed);
11903
+ if (trimmed !== "") lines.push(trimmed);
10050
11904
  }
10051
11905
  }
10052
- if (lines.length === 0)
10053
- return void 0;
11906
+ if (lines.length === 0) return void 0;
10054
11907
  if (lines.some((line) => /^-----BEGIN [A-Za-z0-9 -]+-----$/.test(line))) {
10055
11908
  return lines;
10056
11909
  }
@@ -10070,34 +11923,24 @@ var singBoxUtlsFingerprints = [
10070
11923
  ];
10071
11924
  var getSingBoxUtlsFingerprint = (value) => {
10072
11925
  const fingerprint = `${value || ""}`.trim().toLowerCase();
10073
- if (singBoxUtlsFingerprints.includes(fingerprint))
10074
- return fingerprint;
11926
+ if (singBoxUtlsFingerprints.includes(fingerprint)) return fingerprint;
10075
11927
  };
10076
11928
  var tlsParser = (proxy, parsedProxy) => {
10077
- if (proxy.tls)
10078
- parsedProxy.tls.enabled = true;
11929
+ if (proxy.tls) parsedProxy.tls.enabled = true;
10079
11930
  if (proxy.servername && proxy.servername !== "")
10080
11931
  parsedProxy.tls.server_name = proxy.servername;
10081
11932
  if (proxy.peer && proxy.peer !== "")
10082
11933
  parsedProxy.tls.server_name = proxy.peer;
10083
- if (proxy.sni && proxy.sni !== "")
10084
- parsedProxy.tls.server_name = proxy.sni;
10085
- if (proxy["skip-cert-verify"])
10086
- parsedProxy.tls.insecure = true;
10087
- if (proxy.insecure)
10088
- parsedProxy.tls.insecure = true;
10089
- if (proxy["disable-sni"])
10090
- parsedProxy.tls.disable_sni = true;
11934
+ if (proxy.sni && proxy.sni !== "") parsedProxy.tls.server_name = proxy.sni;
11935
+ if (proxy["skip-cert-verify"]) parsedProxy.tls.insecure = true;
11936
+ if (proxy.insecure) parsedProxy.tls.insecure = true;
11937
+ if (proxy["disable-sni"]) parsedProxy.tls.disable_sni = true;
10091
11938
  if (typeof proxy.alpn === "string") {
10092
11939
  parsedProxy.tls.alpn = [proxy.alpn];
10093
- } else if (Array.isArray(proxy.alpn))
10094
- parsedProxy.tls.alpn = proxy.alpn;
10095
- if (proxy.ca)
10096
- parsedProxy.tls.certificate_path = `${proxy.ca}`;
10097
- if (proxy.ca_str)
10098
- parsedProxy.tls.certificate = [proxy.ca_str];
10099
- if (proxy["ca-str"])
10100
- parsedProxy.tls.certificate = [proxy["ca-str"]];
11940
+ } else if (Array.isArray(proxy.alpn)) parsedProxy.tls.alpn = proxy.alpn;
11941
+ if (proxy.ca) parsedProxy.tls.certificate_path = `${proxy.ca}`;
11942
+ if (proxy.ca_str) parsedProxy.tls.certificate = [proxy.ca_str];
11943
+ if (proxy["ca-str"]) parsedProxy.tls.certificate = [proxy["ca-str"]];
10101
11944
  if (proxy["reality-opts"]) {
10102
11945
  parsedProxy.tls.reality = { enabled: true };
10103
11946
  if (proxy["reality-opts"]["public-key"])
@@ -10125,8 +11968,7 @@ var tlsParser = (proxy, parsedProxy) => {
10125
11968
  const echOptsConfig = proxy["ech-opts"].config;
10126
11969
  if (Array.isArray(echOptsConfig) || typeof echOptsConfig === "string") {
10127
11970
  const config = normalizePemLines(echOptsConfig, "ECH CONFIGS");
10128
- if (config)
10129
- parsedProxy.tls.ech.config = config;
11971
+ if (config) parsedProxy.tls.ech.config = config;
10130
11972
  }
10131
11973
  parsedProxy.tls.ech.query_server_name = proxy["ech-opts"]["query-server-name"];
10132
11974
  parsedProxy.tls.ech.config_path = proxy["ech-opts"]["config-path"];
@@ -10137,8 +11979,7 @@ var tlsParser = (proxy, parsedProxy) => {
10137
11979
  if (proxy._curve_preferences && Array.isArray(proxy._curve_preferences)) {
10138
11980
  parsedProxy.tls.curve_preferences = proxy._curve_preferences;
10139
11981
  }
10140
- if (proxy["_fragment"])
10141
- parsedProxy.tls.fragment = !!proxy["_fragment"];
11982
+ if (proxy["_fragment"]) parsedProxy.tls.fragment = !!proxy["_fragment"];
10142
11983
  if (proxy["_fragment_fallback_delay"])
10143
11984
  parsedProxy.tls.fragment_fallback_delay = proxy["_fragment_fallback_delay"];
10144
11985
  if (proxy["_record_fragment"])
@@ -10153,12 +11994,16 @@ var tlsParser = (proxy, parsedProxy) => {
10153
11994
  parsedProxy.tls.client_certificate = proxy["_client_certificate"];
10154
11995
  if (proxy["_client_certificate_path"])
10155
11996
  parsedProxy.tls.client_certificate_path = proxy["_client_certificate_path"];
10156
- if (proxy["_client_key"])
10157
- parsedProxy.tls.client_key = proxy["_client_key"];
11997
+ if (proxy["_client_key"]) parsedProxy.tls.client_key = proxy["_client_key"];
10158
11998
  if (proxy["_client_key_path"])
10159
11999
  parsedProxy.tls.client_key_path = proxy["_client_key_path"];
10160
- if (!parsedProxy.tls.enabled)
12000
+ if (!parsedProxy.tls.enabled) {
10161
12001
  delete parsedProxy.tls;
12002
+ } else if ((proxy.fingerprint || proxy["tls-fingerprint"]) && !parsedProxy.tls.reality && !parsedProxy.tls.certificate && !parsedProxy.tls.certificate_path && !parsedProxy.tls.certificate_public_key_sha256) {
12003
+ app_default.warn(
12004
+ `Platform sing-box does not support certificate fingerprint pinning, it is dropped for proxy ${proxy.name}. Set _certificate_public_key_sha256 to pin the certificate public key instead`
12005
+ );
12006
+ }
10162
12007
  };
10163
12008
  var sshParser = (proxy = {}) => {
10164
12009
  const parsedProxy = {
@@ -10169,12 +12014,9 @@ var sshParser = (proxy = {}) => {
10169
12014
  };
10170
12015
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10171
12016
  throw "invalid port";
10172
- if (proxy.username)
10173
- parsedProxy.user = proxy.username;
10174
- if (proxy.password)
10175
- parsedProxy.password = proxy.password;
10176
- if (proxy["privateKey"])
10177
- parsedProxy.private_key_path = proxy["privateKey"];
12017
+ if (proxy.username) parsedProxy.user = proxy.username;
12018
+ if (proxy.password) parsedProxy.password = proxy.password;
12019
+ if (proxy["privateKey"]) parsedProxy.private_key_path = proxy["privateKey"];
10178
12020
  if (proxy["private-key"])
10179
12021
  parsedProxy.private_key_path = proxy["private-key"];
10180
12022
  if (proxy["private-key-passphrase"])
@@ -10185,12 +12027,10 @@ var sshParser = (proxy = {}) => {
10185
12027
  proxy["server-fingerprint"].split(" ")[0]
10186
12028
  ];
10187
12029
  }
10188
- if (proxy["host-key"])
10189
- parsedProxy.host_key = proxy["host-key"];
12030
+ if (proxy["host-key"]) parsedProxy.host_key = proxy["host-key"];
10190
12031
  if (proxy["host-key-algorithms"])
10191
12032
  parsedProxy.host_key_algorithms = proxy["host-key-algorithms"];
10192
- if (proxy["fast-open"])
10193
- parsedProxy.udp_fragment = true;
12033
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10194
12034
  tfoParser(proxy, parsedProxy);
10195
12035
  detourParser(proxy, parsedProxy);
10196
12036
  ipVersionParser(proxy, parsedProxy);
@@ -10207,10 +12047,8 @@ var httpParser = (proxy = {}) => {
10207
12047
  };
10208
12048
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10209
12049
  throw "invalid port";
10210
- if (proxy.username)
10211
- parsedProxy.username = proxy.username;
10212
- if (proxy.password)
10213
- parsedProxy.password = proxy.password;
12050
+ if (proxy.username) parsedProxy.username = proxy.username;
12051
+ if (proxy.password) parsedProxy.password = proxy.password;
10214
12052
  if (proxy.headers) {
10215
12053
  parsedProxy.headers = {};
10216
12054
  for (const k of Object.keys(proxy.headers)) {
@@ -10219,8 +12057,7 @@ var httpParser = (proxy = {}) => {
10219
12057
  if (Object.keys(parsedProxy.headers).length === 0)
10220
12058
  delete parsedProxy.headers;
10221
12059
  }
10222
- if (proxy["fast-open"])
10223
- parsedProxy.udp_fragment = true;
12060
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10224
12061
  tfoParser(proxy, parsedProxy);
10225
12062
  detourParser(proxy, parsedProxy);
10226
12063
  tlsParser(proxy, parsedProxy);
@@ -10238,20 +12075,16 @@ var socks5Parser = (proxy = {}) => {
10238
12075
  };
10239
12076
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10240
12077
  throw "invalid port";
10241
- if (proxy.username)
10242
- parsedProxy.username = proxy.username;
10243
- if (proxy.password)
10244
- parsedProxy.password = proxy.password;
10245
- if (proxy.uot)
10246
- parsedProxy.udp_over_tcp = true;
12078
+ if (proxy.username) parsedProxy.username = proxy.username;
12079
+ if (proxy.password) parsedProxy.password = proxy.password;
12080
+ if (proxy.uot) parsedProxy.udp_over_tcp = true;
10247
12081
  if (proxy["udp-over-tcp"]) {
10248
12082
  parsedProxy.udp_over_tcp = {
10249
12083
  enabled: true,
10250
12084
  version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
10251
12085
  };
10252
12086
  }
10253
- if (proxy["fast-open"])
10254
- parsedProxy.udp_fragment = true;
12087
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10255
12088
  networkParser(proxy, parsedProxy);
10256
12089
  tfoParser(proxy, parsedProxy);
10257
12090
  detourParser(proxy, parsedProxy);
@@ -10268,8 +12101,7 @@ var shadowTLSParser = (proxy = {}) => {
10268
12101
  password: proxy.password,
10269
12102
  detour: getShadowTLSTag(proxy)
10270
12103
  };
10271
- if (proxy.uot)
10272
- ssPart.udp_over_tcp = true;
12104
+ if (proxy.uot) ssPart.udp_over_tcp = true;
10273
12105
  if (proxy["udp-over-tcp"]) {
10274
12106
  ssPart.udp_over_tcp = {
10275
12107
  enabled: true,
@@ -10303,13 +12135,11 @@ var normalizeALPN = (alpn) => {
10303
12135
  if (typeof alpn === "string") {
10304
12136
  return alpn.split(",").map((item) => item.trim()).filter((item) => item !== "");
10305
12137
  }
10306
- if (Array.isArray(alpn))
10307
- return alpn;
12138
+ if (Array.isArray(alpn)) return alpn;
10308
12139
  return void 0;
10309
12140
  };
10310
12141
  var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
10311
- if (!pluginOpts)
10312
- throw new Error("shadow-tls plugin options are missing");
12142
+ if (!pluginOpts) throw new Error("shadow-tls plugin options are missing");
10313
12143
  const fingerprint = getSingBoxUtlsFingerprint(proxy["client-fingerprint"]);
10314
12144
  const stPart = {
10315
12145
  tag: getShadowTLSTag(proxy),
@@ -10323,8 +12153,7 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
10323
12153
  server_name: pluginOpts.host
10324
12154
  }
10325
12155
  };
10326
- if (proxy["skip-cert-verify"])
10327
- stPart.tls.insecure = true;
12156
+ if (proxy["skip-cert-verify"]) stPart.tls.insecure = true;
10328
12157
  if (fingerprint) {
10329
12158
  stPart.tls.utls = {
10330
12159
  enabled: true,
@@ -10334,10 +12163,8 @@ var shadowTLSOutboundParser = (proxy = {}, pluginOpts) => {
10334
12163
  if (stPart.server_port < 0 || stPart.server_port > 65535)
10335
12164
  throw "\u7AEF\u53E3\u503C\u975E\u6CD5";
10336
12165
  const alpn = normalizeALPN(pluginOpts.alpn) ?? normalizeALPN(proxy.alpn);
10337
- if (alpn)
10338
- stPart.tls.alpn = alpn;
10339
- if (proxy["fast-open"] === true)
10340
- stPart.udp_fragment = true;
12166
+ if (alpn) stPart.tls.alpn = alpn;
12167
+ if (proxy["fast-open"] === true) stPart.udp_fragment = true;
10341
12168
  tfoParser(proxy, stPart);
10342
12169
  detourParser(proxy, stPart);
10343
12170
  ipVersionParser(proxy, stPart);
@@ -10355,16 +12182,14 @@ var ssParser = (proxy = {}) => {
10355
12182
  };
10356
12183
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10357
12184
  throw "invalid port";
10358
- if (proxy.uot)
10359
- parsedProxy.udp_over_tcp = true;
12185
+ if (proxy.uot) parsedProxy.udp_over_tcp = true;
10360
12186
  if (proxy["udp-over-tcp"]) {
10361
12187
  parsedProxy.udp_over_tcp = {
10362
12188
  enabled: true,
10363
12189
  version: !proxy["udp-over-tcp-version"] || proxy["udp-over-tcp-version"] === 1 ? 1 : 2
10364
12190
  };
10365
12191
  }
10366
- if (proxy["fast-open"])
10367
- parsedProxy.udp_fragment = true;
12192
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10368
12193
  networkParser(proxy, parsedProxy);
10369
12194
  tfoParser(proxy, parsedProxy);
10370
12195
  detourParser(proxy, parsedProxy);
@@ -10394,15 +12219,12 @@ var ssParser = (proxy = {}) => {
10394
12219
  }
10395
12220
  if (proxy.plugin === "v2ray-plugin") {
10396
12221
  parsedProxy.plugin = "v2ray-plugin";
10397
- if (proxy["ws-host"])
10398
- proxy["plugin-opts"].host = proxy["ws-host"];
10399
- if (proxy["ws-path"])
10400
- proxy["plugin-opts"].path = proxy["ws-path"];
12222
+ if (proxy["ws-host"]) proxy["plugin-opts"].host = proxy["ws-host"];
12223
+ if (proxy["ws-path"]) proxy["plugin-opts"].path = proxy["ws-path"];
10401
12224
  Object.keys(proxy["plugin-opts"]).forEach((k) => {
10402
12225
  switch (k) {
10403
12226
  case "tls":
10404
- if (proxy["plugin-opts"].tls)
10405
- optArr.push("tls");
12227
+ if (proxy["plugin-opts"].tls) optArr.push("tls");
10406
12228
  break;
10407
12229
  case "host":
10408
12230
  optArr.push(`host=${proxy["plugin-opts"].host}`);
@@ -10421,8 +12243,7 @@ var ssParser = (proxy = {}) => {
10421
12243
  const mux = normalizePluginMuxValue(
10422
12244
  proxy["plugin-opts"].mux
10423
12245
  );
10424
- if (mux)
10425
- parsedProxy.multiplex = { enabled: true };
12246
+ if (mux) parsedProxy.multiplex = { enabled: true };
10426
12247
  optArr.push(`mux=${mux}`);
10427
12248
  break;
10428
12249
  }
@@ -10448,12 +12269,10 @@ var ssrParser = (proxy = {}) => {
10448
12269
  };
10449
12270
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10450
12271
  throw "invalid port";
10451
- if (proxy["obfs-param"])
10452
- parsedProxy.obfs_param = proxy["obfs-param"];
12272
+ if (proxy["obfs-param"]) parsedProxy.obfs_param = proxy["obfs-param"];
10453
12273
  if (proxy["protocol-param"] && proxy["protocol-param"] !== "")
10454
12274
  parsedProxy.protocol_param = proxy["protocol-param"];
10455
- if (proxy["fast-open"])
10456
- parsedProxy.udp_fragment = true;
12275
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10457
12276
  networkParser(proxy, parsedProxy);
10458
12277
  tfoParser(proxy, parsedProxy);
10459
12278
  detourParser(proxy, parsedProxy);
@@ -10463,11 +12282,9 @@ var ssrParser = (proxy = {}) => {
10463
12282
  return parsedProxy;
10464
12283
  };
10465
12284
  var getSnellVersion = (version) => {
10466
- if (version == null)
10467
- return void 0;
12285
+ if (version == null) return void 0;
10468
12286
  const normalized = `${version}`.trim();
10469
- if (!/^\d+$/.test(normalized))
10470
- return NaN;
12287
+ if (!/^\d+$/.test(normalized)) return NaN;
10471
12288
  return parseInt(normalized, 10);
10472
12289
  };
10473
12290
  var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
@@ -10489,13 +12306,10 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
10489
12306
  };
10490
12307
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10491
12308
  throw "invalid port";
10492
- if (outputVersion != null)
10493
- parsedProxy.version = outputVersion;
10494
- if (proxy._userkey)
10495
- parsedProxy.userkey = proxy._userkey;
12309
+ if (outputVersion != null) parsedProxy.version = outputVersion;
12310
+ if (proxy._userkey) parsedProxy.userkey = proxy._userkey;
10496
12311
  if (outputVersion === 6) {
10497
- if (proxy.mode)
10498
- parsedProxy.mode = proxy.mode;
12312
+ if (proxy.mode) parsedProxy.mode = proxy.mode;
10499
12313
  if (includeUnsupportedProxy && proxy["quic-proxy-mode"])
10500
12314
  parsedProxy.quic_proxy_mode = !!proxy["quic-proxy-mode"];
10501
12315
  } else {
@@ -10512,8 +12326,7 @@ var snellParser = (proxy = {}, includeUnsupportedProxy = false) => {
10512
12326
  delete parsedProxy.server;
10513
12327
  delete parsedProxy.server_port;
10514
12328
  } else {
10515
- if (proxy["fast-open"])
10516
- parsedProxy.udp_fragment = true;
12329
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10517
12330
  tfoParser(proxy, parsedProxy);
10518
12331
  detourParser(proxy, parsedProxy);
10519
12332
  ipVersionParser(proxy, parsedProxy);
@@ -10565,16 +12378,11 @@ var vmessParser = (proxy = {}) => {
10565
12378
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10566
12379
  throw "invalid port";
10567
12380
  vmessProtocolOptionsParser(proxy, parsedProxy);
10568
- if (proxy["fast-open"])
10569
- parsedProxy.udp_fragment = true;
10570
- if (proxy.network === "ws")
10571
- wsParser(proxy, parsedProxy);
10572
- if (proxy.network === "h2")
10573
- h2Parser(proxy, parsedProxy);
10574
- if (proxy.network === "http")
10575
- h1Parser(proxy, parsedProxy);
10576
- if (proxy.network === "grpc")
10577
- grpcParser(proxy, parsedProxy);
12381
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
12382
+ if (proxy.network === "ws") wsParser(proxy, parsedProxy);
12383
+ if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
12384
+ if (proxy.network === "http") h1Parser(proxy, parsedProxy);
12385
+ if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
10578
12386
  networkParser(proxy, parsedProxy);
10579
12387
  tfoParser(proxy, parsedProxy);
10580
12388
  detourParser(proxy, parsedProxy);
@@ -10596,18 +12404,12 @@ var vlessParser = (proxy = {}) => {
10596
12404
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10597
12405
  throw "invalid port";
10598
12406
  vmessVlessPacketEncodingParser(proxy, parsedProxy);
10599
- if (proxy["fast-open"])
10600
- parsedProxy.udp_fragment = true;
10601
- if (proxy.flow != null)
10602
- parsedProxy.flow = proxy.flow;
10603
- if (proxy.network === "ws")
10604
- wsParser(proxy, parsedProxy);
10605
- if (proxy.network === "h2")
10606
- h2Parser(proxy, parsedProxy);
10607
- if (proxy.network === "http")
10608
- h1Parser(proxy, parsedProxy);
10609
- if (proxy.network === "grpc")
10610
- grpcParser(proxy, parsedProxy);
12407
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
12408
+ if (proxy.flow != null) parsedProxy.flow = proxy.flow;
12409
+ if (proxy.network === "ws") wsParser(proxy, parsedProxy);
12410
+ if (proxy.network === "h2") h2Parser(proxy, parsedProxy);
12411
+ if (proxy.network === "http") h1Parser(proxy, parsedProxy);
12412
+ if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
10611
12413
  networkParser(proxy, parsedProxy);
10612
12414
  tfoParser(proxy, parsedProxy);
10613
12415
  detourParser(proxy, parsedProxy);
@@ -10628,12 +12430,9 @@ var trojanParser = (proxy = {}) => {
10628
12430
  };
10629
12431
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10630
12432
  throw "invalid port";
10631
- if (proxy["fast-open"])
10632
- parsedProxy.udp_fragment = true;
10633
- if (proxy.network === "grpc")
10634
- grpcParser(proxy, parsedProxy);
10635
- if (proxy.network === "ws")
10636
- wsParser(proxy, parsedProxy);
12433
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
12434
+ if (proxy.network === "grpc") grpcParser(proxy, parsedProxy);
12435
+ if (proxy.network === "ws") wsParser(proxy, parsedProxy);
10637
12436
  networkParser(proxy, parsedProxy);
10638
12437
  tfoParser(proxy, parsedProxy);
10639
12438
  detourParser(proxy, parsedProxy);
@@ -10653,12 +12452,9 @@ var naiveParser = (proxy = {}) => {
10653
12452
  };
10654
12453
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10655
12454
  throw "invalid port";
10656
- if (proxy.username)
10657
- parsedProxy.username = proxy.username;
10658
- if (proxy.password)
10659
- parsedProxy.password = proxy.password;
10660
- if (proxy.uot)
10661
- parsedProxy.udp_over_tcp = true;
12455
+ if (proxy.username) parsedProxy.username = proxy.username;
12456
+ if (proxy.password) parsedProxy.password = proxy.password;
12457
+ if (proxy.uot) parsedProxy.udp_over_tcp = true;
10662
12458
  if (proxy["udp-over-tcp"]) {
10663
12459
  parsedProxy.udp_over_tcp = {
10664
12460
  enabled: true,
@@ -10673,12 +12469,10 @@ var naiveParser = (proxy = {}) => {
10673
12469
  parsedProxy.insecure_concurrency = insecure_concurrency;
10674
12470
  if (proxy["extra-headers"])
10675
12471
  parsedProxy.extra_headers = proxy["extra-headers"];
10676
- if (proxy.quic)
10677
- parsedProxy.quic = !!proxy.quic;
12472
+ if (proxy.quic) parsedProxy.quic = !!proxy.quic;
10678
12473
  if (proxy["quic-congestion-control"])
10679
12474
  parsedProxy.quic_congestion_control = proxy["quic-congestion-control"];
10680
- if (proxy["fast-open"])
10681
- parsedProxy.udp_fragment = true;
12475
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10682
12476
  tfoParser(proxy, parsedProxy);
10683
12477
  detourParser(proxy, parsedProxy);
10684
12478
  tlsParser(proxy, parsedProxy);
@@ -10711,12 +12505,9 @@ var hysteriaParser = (proxy = {}) => {
10711
12505
  const range = p.replace(/\s*-\s*/g, ":");
10712
12506
  return range.includes(":") ? range : `${range}:${range}`;
10713
12507
  });
10714
- if (proxy.auth_str)
10715
- parsedProxy.auth_str = `${proxy.auth_str}`;
10716
- if (proxy["auth-str"])
10717
- parsedProxy.auth_str = `${proxy["auth-str"]}`;
10718
- if (proxy["fast-open"])
10719
- parsedProxy.udp_fragment = true;
12508
+ if (proxy.auth_str) parsedProxy.auth_str = `${proxy.auth_str}`;
12509
+ if (proxy["auth-str"]) parsedProxy.auth_str = `${proxy["auth-str"]}`;
12510
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10720
12511
  const reg = new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");
10721
12512
  if (reg.test(`${proxy.up}`) && !`${proxy.up}`.endsWith("Mbps")) {
10722
12513
  parsedProxy.up = `${proxy.up}`;
@@ -10728,16 +12519,13 @@ var hysteriaParser = (proxy = {}) => {
10728
12519
  } else {
10729
12520
  parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
10730
12521
  }
10731
- if (proxy.obfs)
10732
- parsedProxy.obfs = proxy.obfs;
12522
+ if (proxy.obfs) parsedProxy.obfs = proxy.obfs;
10733
12523
  if (proxy.recv_window_conn)
10734
12524
  parsedProxy.recv_window_conn = proxy.recv_window_conn;
10735
12525
  if (proxy["recv-window-conn"])
10736
12526
  parsedProxy.recv_window_conn = proxy["recv-window-conn"];
10737
- if (proxy.recv_window)
10738
- parsedProxy.recv_window = proxy.recv_window;
10739
- if (proxy["recv-window"])
10740
- parsedProxy.recv_window = proxy["recv-window"];
12527
+ if (proxy.recv_window) parsedProxy.recv_window = proxy.recv_window;
12528
+ if (proxy["recv-window"]) parsedProxy.recv_window = proxy["recv-window"];
10741
12529
  if (proxy.disable_mtu_discovery) {
10742
12530
  if (typeof proxy.disable_mtu_discovery === "boolean") {
10743
12531
  parsedProxy.disable_mtu_discovery = proxy.disable_mtu_discovery;
@@ -10774,10 +12562,8 @@ var hysteria2Parser = (proxy = {}) => {
10774
12562
  const range = p.replace(/\s*-\s*/g, ":");
10775
12563
  return range.includes(":") ? range : `${range}:${range}`;
10776
12564
  });
10777
- if (proxy.up)
10778
- parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
10779
- if (proxy.down)
10780
- parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
12565
+ if (proxy.up) parsedProxy.up_mbps = parseInt(`${proxy.up}`, 10);
12566
+ if (proxy.down) parsedProxy.down_mbps = parseInt(`${proxy.down}`, 10);
10781
12567
  if (["salamander", "gecko"].includes(proxy.obfs))
10782
12568
  parsedProxy.obfs.type = proxy.obfs;
10783
12569
  if (proxy.obfs === "gecko") {
@@ -10801,17 +12587,17 @@ var hysteria2Parser = (proxy = {}) => {
10801
12587
  `Invalid obfs packet size for proxy ${proxy.name}: min=${minRaw} max=${maxRaw}`
10802
12588
  );
10803
12589
  } else {
10804
- if (hasMin)
10805
- parsedProxy.obfs.min_packet_size = minPacketSize;
10806
- if (hasMax)
10807
- parsedProxy.obfs.max_packet_size = maxPacketSize;
12590
+ if (hasMin) parsedProxy.obfs.min_packet_size = minPacketSize;
12591
+ if (hasMax) parsedProxy.obfs.max_packet_size = maxPacketSize;
10808
12592
  }
10809
12593
  }
10810
12594
  }
10811
12595
  if (proxy["obfs-password"])
10812
12596
  parsedProxy.obfs.password = proxy["obfs-password"];
10813
- if (!parsedProxy.obfs.type)
10814
- delete parsedProxy.obfs;
12597
+ if (!parsedProxy.obfs.type) delete parsedProxy.obfs;
12598
+ if (proxy["bbr-profile"]) parsedProxy.bbr_profile = proxy["bbr-profile"];
12599
+ if (proxy["disable-chrome-parrot"])
12600
+ parsedProxy.disable_chrome_parrot = !!proxy["disable-chrome-parrot"];
10815
12601
  networkParser(proxy, parsedProxy);
10816
12602
  tlsParser(proxy, parsedProxy);
10817
12603
  tfoParser(proxy, parsedProxy);
@@ -10833,16 +12619,13 @@ var tuic5Parser = (proxy = {}) => {
10833
12619
  };
10834
12620
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10835
12621
  throw "invalid port";
10836
- if (proxy["fast-open"])
10837
- parsedProxy.udp_fragment = true;
12622
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10838
12623
  if (proxy["congestion-controller"] && proxy["congestion-controller"] !== "cubic")
10839
12624
  parsedProxy.congestion_control = proxy["congestion-controller"];
10840
12625
  if (proxy["udp-relay-mode"] && proxy["udp-relay-mode"] !== "native")
10841
12626
  parsedProxy.udp_relay_mode = proxy["udp-relay-mode"];
10842
- if (proxy["reduce-rtt"])
10843
- parsedProxy.zero_rtt_handshake = true;
10844
- if (proxy["udp-over-stream"])
10845
- parsedProxy.udp_over_stream = true;
12627
+ if (proxy["reduce-rtt"]) parsedProxy.zero_rtt_handshake = true;
12628
+ if (proxy["udp-over-stream"]) parsedProxy.udp_over_stream = true;
10846
12629
  if (proxy["heartbeat-interval"])
10847
12630
  parsedProxy.heartbeat = `${proxy["heartbeat-interval"]}ms`;
10848
12631
  networkParser(proxy, parsedProxy);
@@ -10863,8 +12646,8 @@ var anytlsParser = (proxy = {}, includeUnsupportedProxy = false) => {
10863
12646
  password: proxy.password,
10864
12647
  tls: { enabled: true, server_name: proxy.server, insecure: false }
10865
12648
  };
10866
- if (includeUnsupportedProxy && proxy["client-name"])
10867
- parsedProxy.client_name = `${proxy["client-name"]}`;
12649
+ if (proxy["client-metadata"])
12650
+ parsedProxy.client_metadata = `${proxy["client-metadata"]}`;
10868
12651
  if (/^\d+$/.test(proxy["idle-session-check-interval"]))
10869
12652
  parsedProxy.idle_session_check_interval = `${proxy["idle-session-check-interval"]}s`;
10870
12653
  if (/^\d+$/.test(proxy["idle-session-timeout"]))
@@ -10953,13 +12736,11 @@ var wireguardParser = (proxy = {}) => {
10953
12736
  };
10954
12737
  if (parsedProxy.server_port < 0 || parsedProxy.server_port > 65535)
10955
12738
  throw "invalid port";
10956
- if (proxy["fast-open"])
10957
- parsedProxy.udp_fragment = true;
12739
+ if (proxy["fast-open"]) parsedProxy.udp_fragment = true;
10958
12740
  if (typeof proxy.reserved === "string") {
10959
12741
  parsedProxy.reserved = proxy.reserved;
10960
12742
  } else if (Array.isArray(proxy.reserved)) {
10961
- for (const r of proxy.reserved)
10962
- parsedProxy.reserved.push(r);
12743
+ for (const r of proxy.reserved) parsedProxy.reserved.push(r);
10963
12744
  } else {
10964
12745
  delete parsedProxy.reserved;
10965
12746
  }
@@ -10993,8 +12774,7 @@ var wireguardParser = (proxy = {}) => {
10993
12774
  if (typeof p.reserved === "string") {
10994
12775
  peer.reserved.push(p.reserved);
10995
12776
  } else if (Array.isArray(p.reserved)) {
10996
- for (const r of p.reserved)
10997
- peer.reserved.push(r);
12777
+ for (const r of p.reserved) peer.reserved.push(r);
10998
12778
  } else {
10999
12779
  delete peer.reserved;
11000
12780
  }
@@ -11234,8 +13014,7 @@ function singbox_Producer() {
11234
13014
  app_default.error(e.message ?? e);
11235
13015
  }
11236
13016
  });
11237
- if (type2 === "internal")
11238
- return list;
13017
+ if (type2 === "internal") return list;
11239
13018
  const categorized = list.reduce(
11240
13019
  (result, item) => {
11241
13020
  if (["wireguard", "tailscale"].includes(item.type)) {
@@ -11253,6 +13032,17 @@ function singbox_Producer() {
11253
13032
  }
11254
13033
 
11255
13034
  // src/vendors/Sub-Store/backend/src/core/proxy-utils/producers/egern.js
13035
+ var ipVersions5 = {
13036
+ dual: "dual_stack",
13037
+ ipv4: "v4_only",
13038
+ ipv6: "v6_only",
13039
+ "v4-only": "v4_only",
13040
+ "v6-only": "v6_only",
13041
+ "ipv4-prefer": "v4_prefer",
13042
+ "ipv6-prefer": "v6_prefer",
13043
+ "prefer-v4": "v4_prefer",
13044
+ "prefer-v6": "v6_prefer"
13045
+ };
11256
13046
  function Egern_Producer() {
11257
13047
  const type = "ALL";
11258
13048
  const produce2 = (proxies, type2, opts = {}) => {
@@ -11262,6 +13052,7 @@ function Egern_Producer() {
11262
13052
  "https",
11263
13053
  "socks5",
11264
13054
  "ss",
13055
+ "ssr",
11265
13056
  "trojan",
11266
13057
  "hysteria2",
11267
13058
  "vless",
@@ -11312,6 +13103,8 @@ function Egern_Producer() {
11312
13103
  return false;
11313
13104
  } else if (proxy.type === "snell" && normalizeSnellVersion(proxy.version) === null) {
11314
13105
  return false;
13106
+ } else if (proxy.type === "ssr" && !isEgernSsr(proxy)) {
13107
+ return false;
11315
13108
  } else if (["anytls"].includes(proxy.type) && proxy.network && !["tcp"].includes(proxy.network)) {
11316
13109
  return false;
11317
13110
  } else if (["ws"].includes(proxy.network) && proxy["ws-opts"]?.["v2ray-http-upgrade"]) {
@@ -11399,6 +13192,21 @@ function Egern_Producer() {
11399
13192
  );
11400
13193
  }
11401
13194
  }
13195
+ } else if (proxy.type === "ssr") {
13196
+ proxy = {
13197
+ type: "shadowsocksr",
13198
+ name: proxy.name,
13199
+ method: normalizeSsrMethod(proxy.cipher),
13200
+ server: proxy.server,
13201
+ port: proxy.port,
13202
+ password: proxy.password,
13203
+ protocol: normalizeSsrPlugin(proxy.protocol),
13204
+ protocol_param: proxy["protocol-param"],
13205
+ obfs: normalizeSsrPlugin(proxy.obfs),
13206
+ obfs_param: proxy["obfs-param"],
13207
+ tfo: getTfo(proxy),
13208
+ udp_relay: getUdpRelay(proxy)
13209
+ };
11402
13210
  } else if (proxy.type === "hysteria2") {
11403
13211
  proxy = {
11404
13212
  type: "hysteria2",
@@ -11554,7 +13362,7 @@ function Egern_Producer() {
11554
13362
  };
11555
13363
  } else if (proxy.network === "http") {
11556
13364
  proxy.transport = {
11557
- http: {
13365
+ http1: {
11558
13366
  method: proxy["http-opts"]?.method,
11559
13367
  path: Array.isArray(
11560
13368
  proxy["http-opts"]?.path
@@ -11588,8 +13396,7 @@ function Egern_Producer() {
11588
13396
  }
11589
13397
  };
11590
13398
  flow = proxy.flow;
11591
- if (flow === "")
11592
- flow = void 0;
13399
+ if (flow === "") flow = void 0;
11593
13400
  }
11594
13401
  proxy = {
11595
13402
  type: "vless",
@@ -11673,6 +13480,7 @@ function Egern_Producer() {
11673
13480
  "https",
11674
13481
  "socks5",
11675
13482
  "ss",
13483
+ "ssr",
11676
13484
  "trojan",
11677
13485
  "vless",
11678
13486
  "vmess",
@@ -11704,6 +13512,7 @@ function Egern_Producer() {
11704
13512
  if ([
11705
13513
  "socks5",
11706
13514
  "ss",
13515
+ "ssr",
11707
13516
  "trojan",
11708
13517
  "vless",
11709
13518
  "vmess",
@@ -11724,9 +13533,12 @@ function Egern_Producer() {
11724
13533
  proxy.block_quic = false;
11725
13534
  }
11726
13535
  }
11727
- if (["ss"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
13536
+ if (["ss", "ssr"].includes(original.type) && proxy.shadow_tls && original["udp-port"] > 0 && original["udp-port"] <= 65535) {
11728
13537
  proxy["udp_port"] = original["udp-port"];
11729
13538
  }
13539
+ if (original["ip-version"]) {
13540
+ proxy.ip_version = ipVersions5[original["ip-version"]] || original["ip-version"];
13541
+ }
11730
13542
  delete proxy.subName;
11731
13543
  delete proxy.collectionName;
11732
13544
  delete proxy.id;
@@ -11774,29 +13586,24 @@ function hasHeaders(proxy) {
11774
13586
  return proxy?.headers && typeof proxy.headers === "object" && Object.keys(proxy.headers).length > 0;
11775
13587
  }
11776
13588
  function getTfo(proxy) {
11777
- return proxy.tfo ?? proxy["fast-open"];
13589
+ return !!(proxy.tfo ?? proxy["fast-open"]);
11778
13590
  }
11779
13591
  function getUdpRelay(proxy) {
11780
13592
  return proxy.udp ?? proxy.udp_relay;
11781
13593
  }
11782
13594
  function getNonEmptyValue(value) {
11783
- if (value == null)
11784
- return void 0;
11785
- if (typeof value === "string" && value.length === 0)
11786
- return void 0;
13595
+ if (value == null) return void 0;
13596
+ if (typeof value === "string" && value.length === 0) return void 0;
11787
13597
  return value;
11788
13598
  }
11789
13599
  function getReality(proxy) {
11790
13600
  const realityOpts = proxy?.["reality-opts"];
11791
- if (!realityOpts)
11792
- return void 0;
13601
+ if (!realityOpts) return void 0;
11793
13602
  const reality = {};
11794
13603
  const publicKey = getNonEmptyValue(realityOpts["public-key"]);
11795
13604
  const shortId = getNonEmptyValue(realityOpts["short-id"]);
11796
- if (publicKey != null)
11797
- reality.public_key = publicKey;
11798
- if (shortId != null)
11799
- reality.short_id = shortId;
13605
+ if (publicKey != null) reality.public_key = publicKey;
13606
+ if (shortId != null) reality.short_id = shortId;
11800
13607
  return Object.keys(reality).length > 0 ? reality : void 0;
11801
13608
  }
11802
13609
  function getGrpcTransport(proxy) {
@@ -11810,26 +13617,71 @@ function getGrpcTransport(proxy) {
11810
13617
  };
11811
13618
  }
11812
13619
  function isEgernGrpcGun(proxy) {
11813
- if (proxy.network !== "grpc")
11814
- return true;
13620
+ if (proxy.network !== "grpc") return true;
11815
13621
  const grpcType = proxy["grpc-opts"]?.["_grpc-type"];
11816
- if (grpcType == null)
11817
- return true;
13622
+ if (grpcType == null) return true;
11818
13623
  return `${grpcType}`.trim().toLowerCase() === "gun";
11819
13624
  }
11820
13625
  function normalizeSnellVersion(version) {
11821
- if (version == null)
11822
- return void 0;
13626
+ if (version == null) return void 0;
11823
13627
  const normalized = `${version}`.trim();
11824
- if (!/^[1-5]$/.test(normalized))
11825
- return null;
13628
+ if (!/^[1-5]$/.test(normalized)) return null;
11826
13629
  return parseInt(normalized, 10);
11827
13630
  }
13631
+ var EGERN_SSR_METHODS = [
13632
+ "none",
13633
+ "dummy",
13634
+ "rc4-md5",
13635
+ "aes-128-cfb",
13636
+ "aes-192-cfb",
13637
+ "aes-256-cfb",
13638
+ "aes-128-ctr",
13639
+ "aes-192-ctr",
13640
+ "aes-256-ctr",
13641
+ "chacha20",
13642
+ "chacha20-ietf",
13643
+ "xchacha20"
13644
+ ];
13645
+ var EGERN_SSR_PROTOCOLS = [
13646
+ "origin",
13647
+ "auth_sha1_v4",
13648
+ "auth_aes128_md5",
13649
+ "auth_aes128_sha1",
13650
+ "auth_chain_a",
13651
+ "auth_chain_b"
13652
+ ];
13653
+ var EGERN_SSR_OBFS = [
13654
+ "plain",
13655
+ "http_simple",
13656
+ "http_post",
13657
+ "random_head",
13658
+ "tls1.2_ticket_auth",
13659
+ "tls1.2_ticket_fastauth"
13660
+ ];
13661
+ function normalizeSsrPlugin(value) {
13662
+ if (value == null) return void 0;
13663
+ const normalized = `${value}`.trim().toLowerCase();
13664
+ return normalized.length > 0 ? normalized : void 0;
13665
+ }
13666
+ function normalizeSsrMethod(cipher) {
13667
+ const method = normalizeSsrPlugin(cipher);
13668
+ return method === "plain" ? "none" : method;
13669
+ }
13670
+ function isEgernSsr(proxy) {
13671
+ if (!EGERN_SSR_METHODS.includes(normalizeSsrMethod(proxy.cipher))) {
13672
+ return false;
13673
+ }
13674
+ const protocol = normalizeSsrPlugin(proxy.protocol);
13675
+ if (protocol != null && !EGERN_SSR_PROTOCOLS.includes(protocol)) {
13676
+ return false;
13677
+ }
13678
+ const obfs = normalizeSsrPlugin(proxy.obfs);
13679
+ return obfs == null || EGERN_SSR_OBFS.includes(obfs);
13680
+ }
11828
13681
  function getFirstHeaderValue(headers, ...keys) {
11829
13682
  for (const key of keys) {
11830
13683
  const value = getFirstValue(headers?.[key]);
11831
- if (value)
11832
- return value;
13684
+ if (value) return value;
11833
13685
  }
11834
13686
  return void 0;
11835
13687
  }
@@ -11840,8 +13692,7 @@ function getH2Headers(h2Opts) {
11840
13692
  const headers = {};
11841
13693
  if (h2Opts?.headers && typeof h2Opts.headers === "object" && !Array.isArray(h2Opts.headers)) {
11842
13694
  for (const [key, value] of Object.entries(h2Opts.headers)) {
11843
- if (/^host$/i.test(key))
11844
- continue;
13695
+ if (/^host$/i.test(key)) continue;
11845
13696
  const headerValue = getFirstValue(value);
11846
13697
  if (headerValue != null) {
11847
13698
  headers[key] = headerValue;
@@ -11855,16 +13706,13 @@ function getH2Headers(h2Opts) {
11855
13706
  return Object.keys(headers).length > 0 ? headers : void 0;
11856
13707
  }
11857
13708
  function getFirstValue(value) {
11858
- if (Array.isArray(value))
11859
- return value[0];
11860
- if (value != null)
11861
- return value;
13709
+ if (Array.isArray(value)) return value[0];
13710
+ if (value != null) return value;
11862
13711
  return void 0;
11863
13712
  }
11864
13713
  function getFingerprintSha256(proxy) {
11865
13714
  const fingerprint = proxy?.["tls-fingerprint"];
11866
- if (typeof fingerprint !== "string")
11867
- return void 0;
13715
+ if (typeof fingerprint !== "string") return void 0;
11868
13716
  const trimmedFingerprint = fingerprint.trim();
11869
13717
  return trimmedFingerprint.length > 0 ? trimmedFingerprint : void 0;
11870
13718
  }
@@ -11874,8 +13722,7 @@ function supportsRootFingerprintSha256(original, proxy) {
11874
13722
  ) || original.type === "socks5" && proxy.type === "socks5_tls" || original.type === "http" && proxy.type === "https";
11875
13723
  }
11876
13724
  function addTransportFingerprintSha256(transport, fingerprintSha256) {
11877
- if (!transport)
11878
- return;
13725
+ if (!transport) return;
11879
13726
  for (const key of ["grpc", "http2", "tls", "wss"]) {
11880
13727
  if (transport[key]) {
11881
13728
  transport[key].fingerprint_sha256 = fingerprintSha256;
@@ -11977,8 +13824,7 @@ function parseProxyLines(lines, opts) {
11977
13824
  const proxyList = [];
11978
13825
  let lastParser = null;
11979
13826
  for (const line of lines) {
11980
- if (line.length === 0)
11981
- continue;
13827
+ if (line.length === 0) continue;
11982
13828
  let proxy = null;
11983
13829
  if (lastParser) {
11984
13830
  proxy = tryParseProxy(lastParser, line);
@@ -12034,3 +13880,16 @@ export {
12034
13880
  produceOutput,
12035
13881
  tryParseProxy
12036
13882
  };
13883
+ /*! Bundled license information:
13884
+
13885
+ ieee754/index.js:
13886
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
13887
+
13888
+ buffer/index.js:
13889
+ (*!
13890
+ * The buffer module from node.js, for the browser.
13891
+ *
13892
+ * @author Feross Aboukhadijeh <https://feross.org>
13893
+ * @license MIT
13894
+ *)
13895
+ */