mphttpx 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2312 @@
1
+ const polyfill = Symbol("isPolyfill");
2
+ const state$9 = Symbol("INTERNAL_STATE");
3
+ /* eslint-disable no-prototype-builtins */
4
+ const g = (typeof globalThis !== "undefined" && globalThis) ||
5
+ (typeof self !== "undefined" && self) ||
6
+ // @ts-ignore eslint-disable-next-line no-undef
7
+ (typeof global !== "undefined" && global) ||
8
+ {};
9
+ function isObjectType(name, value) {
10
+ return Object.prototype.toString.call(value) === `[object ${name}]`;
11
+ }
12
+ function isPolyfillType(name, value) {
13
+ return !!value
14
+ && typeof value === "object"
15
+ && "isPolyfill" in value
16
+ && !!value.isPolyfill
17
+ && typeof value.isPolyfill === "object"
18
+ && "symbol" in value.isPolyfill
19
+ && value.isPolyfill.symbol === polyfill
20
+ && "hierarchy" in value.isPolyfill
21
+ && Array.isArray(value.isPolyfill.hierarchy)
22
+ && value.isPolyfill.hierarchy.includes(name);
23
+ }
24
+ class MPException extends Error {
25
+ constructor(message, name) {
26
+ super();
27
+ this.message = message ?? this.message;
28
+ this.name = name ?? this.name;
29
+ }
30
+ }
31
+ function defineStringTag(targetFunc, stringTag) {
32
+ Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
33
+ configurable: true,
34
+ value: stringTag,
35
+ });
36
+ }
37
+
38
+ class TextEncoderP {
39
+ get encoding() { return "utf-8"; }
40
+ encode(input = "") {
41
+ return encodeText(input).encoded;
42
+ }
43
+ encodeInto(source, destination) {
44
+ const result = encodeText(source, destination);
45
+ return { read: result.read, written: result.written };
46
+ }
47
+ toString() { return "[object TextEncoder]"; }
48
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
49
+ }
50
+ defineStringTag(TextEncoderP, "TextEncoder");
51
+ function encodeText(input, destination) {
52
+ const HAS_DESTINATION = typeof destination !== "undefined";
53
+ let pos = 0;
54
+ let read = 0;
55
+ let len = input.length;
56
+ let at = 0; // output position
57
+ let tlen = Math.max(32, len + (len >> 1) + 7); // 1.5x size
58
+ let target = HAS_DESTINATION ? destination : new Uint8Array((tlen >> 3) << 3); // ... but at 8 byte offset
59
+ while (pos < len) {
60
+ let value = input.charCodeAt(pos++);
61
+ if (value >= 0xd800 && value <= 0xdbff) {
62
+ // high surrogate
63
+ if (pos < len) {
64
+ let extra = input.charCodeAt(pos);
65
+ if ((extra & 0xfc00) === 0xdc00) {
66
+ ++pos;
67
+ value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
68
+ }
69
+ else {
70
+ value = 0xfffd;
71
+ }
72
+ }
73
+ else {
74
+ value = 0xfffd;
75
+ }
76
+ }
77
+ else if (value >= 0xdc00 && value <= 0xdfff) {
78
+ value = 0xfffd;
79
+ }
80
+ // expand the buffer if we couldn't write 4 bytes
81
+ if (!HAS_DESTINATION && at + 4 > target.length) {
82
+ tlen += 8; // minimum extra
83
+ tlen *= (1.0 + (pos / input.length) * 2); // take 2x the remaining
84
+ tlen = (tlen >> 3) << 3; // 8 byte offset
85
+ let update = new Uint8Array(tlen);
86
+ update.set(target);
87
+ target = update;
88
+ }
89
+ let byteCount;
90
+ if ((value & 0xffffff80) === 0) { // 1-byte
91
+ byteCount = 1;
92
+ }
93
+ else if ((value & 0xfffff800) === 0) { // 2-byte
94
+ byteCount = 2;
95
+ }
96
+ else if ((value & 0xffff0000) === 0) { // 3-byte
97
+ byteCount = 3;
98
+ }
99
+ else if ((value & 0xffe00000) === 0) { // 4-byte
100
+ byteCount = 4;
101
+ }
102
+ else {
103
+ value = 0xfffd;
104
+ byteCount = 3;
105
+ }
106
+ if (HAS_DESTINATION && at + byteCount > target.length) {
107
+ break;
108
+ }
109
+ if (byteCount === 1) { // 1-byte
110
+ target[at++] = value; // ASCII
111
+ }
112
+ else if (byteCount === 2) { // 2-byte
113
+ target[at++] = ((value >> 6) & 0x1f) | 0xc0;
114
+ target[at++] = (value & 0x3f) | 0x80;
115
+ }
116
+ else if (byteCount === 3) { // 3-byte
117
+ target[at++] = ((value >> 12) & 0x0f) | 0xe0;
118
+ target[at++] = ((value >> 6) & 0x3f) | 0x80;
119
+ target[at++] = (value & 0x3f) | 0x80;
120
+ }
121
+ else if (byteCount === 4) { // 4-byte
122
+ target[at++] = ((value >> 18) & 0x07) | 0xf0;
123
+ target[at++] = ((value >> 12) & 0x3f) | 0x80;
124
+ target[at++] = ((value >> 6) & 0x3f) | 0x80;
125
+ target[at++] = (value & 0x3f) | 0x80;
126
+ }
127
+ read++;
128
+ }
129
+ return {
130
+ encoded: !HAS_DESTINATION ? target.slice(0, at) : destination.slice(),
131
+ read: read,
132
+ written: at,
133
+ };
134
+ }
135
+ const TextEncoderE = g["TextEncoder"] || TextEncoderP;
136
+
137
+ const state$8 = Symbol("TextDecoderState");
138
+ class TextDecoderP {
139
+ constructor(utfLabel = "utf-8", { fatal = false, ignoreBOM = false } = {}) {
140
+ if (!UTF8Labels.includes(utfLabel.toLowerCase())) {
141
+ throw new RangeError("TextDecoder: The encoding label provided ('" + utfLabel + "') is invalid.");
142
+ }
143
+ this[state$8] = new TextDecoderState();
144
+ this[state$8].fatal = fatal;
145
+ this[state$8].ignoreBOM = ignoreBOM;
146
+ }
147
+ [state$8];
148
+ get encoding() { return "utf-8"; }
149
+ get fatal() { return this[state$8].fatal; }
150
+ get ignoreBOM() { return this[state$8].ignoreBOM; }
151
+ decode(buffer, { stream = false } = {}) {
152
+ let buf;
153
+ if (typeof buffer !== "undefined") {
154
+ if (buffer instanceof Uint8Array) {
155
+ buf = buffer;
156
+ }
157
+ else if (ArrayBuffer.isView(buffer)) {
158
+ buf = new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
159
+ }
160
+ else {
161
+ buf = new Uint8Array(buffer);
162
+ }
163
+ }
164
+ else {
165
+ if (this[state$8]._partial.length > 0) {
166
+ if (this.fatal) {
167
+ throw new TypeError("TextDecoder: Incomplete UTF-8 sequence.");
168
+ }
169
+ else {
170
+ this[state$8]._partial = [];
171
+ }
172
+ }
173
+ return "";
174
+ }
175
+ if (!this[state$8]._bomSeen && this.ignoreBOM && buf.length >= 3) {
176
+ if (buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf) {
177
+ buf = buf.subarray(3);
178
+ this[state$8]._bomSeen = true;
179
+ }
180
+ }
181
+ if (this[state$8]._partial.length > 0) {
182
+ let merged = new Uint8Array(this[state$8]._partial.length + buf.length);
183
+ merged.set(this[state$8]._partial, 0);
184
+ merged.set(buf, this[state$8]._partial.length);
185
+ buf = merged;
186
+ this[state$8]._partial = [];
187
+ }
188
+ let end = buf.length;
189
+ let res = [];
190
+ if (stream && buf.length > 0) {
191
+ let i = buf.length;
192
+ while (i > 0 && i > buf.length - 4) {
193
+ let byte = buf[i - 1];
194
+ if ((byte & 0b11000000) !== 0b10000000) {
195
+ let len = getBytesPerSequence(byte);
196
+ if (len > buf.length - (i - 1)) {
197
+ end = i - 1;
198
+ }
199
+ break;
200
+ }
201
+ i--;
202
+ }
203
+ this[state$8]._partial = Array.from(buf.slice(end)); // save tail
204
+ buf = buf.slice(0, end);
205
+ }
206
+ let i = 0;
207
+ while (i < end) {
208
+ let firstByte = buf[i];
209
+ let codePoint = null;
210
+ let bytesPerSequence = getBytesPerSequence(firstByte);
211
+ if (i + bytesPerSequence <= end) {
212
+ let secondByte, thirdByte, fourthByte, tempCodePoint;
213
+ switch (bytesPerSequence) {
214
+ case 1:
215
+ if (firstByte < 0x80) {
216
+ codePoint = firstByte;
217
+ }
218
+ break;
219
+ case 2:
220
+ secondByte = buf[i + 1];
221
+ if ((secondByte & 0xC0) === 0x80) {
222
+ tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F);
223
+ if (tempCodePoint > 0x7F) {
224
+ codePoint = tempCodePoint;
225
+ }
226
+ }
227
+ break;
228
+ case 3:
229
+ secondByte = buf[i + 1];
230
+ thirdByte = buf[i + 2];
231
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
232
+ tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F);
233
+ if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
234
+ codePoint = tempCodePoint;
235
+ }
236
+ }
237
+ break;
238
+ case 4:
239
+ secondByte = buf[i + 1];
240
+ thirdByte = buf[i + 2];
241
+ fourthByte = buf[i + 3];
242
+ if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
243
+ tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F);
244
+ if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
245
+ codePoint = tempCodePoint;
246
+ }
247
+ }
248
+ }
249
+ }
250
+ if (codePoint === null) {
251
+ if (this.fatal) {
252
+ throw new TypeError("TextDecoder.decode: Decoding failed.");
253
+ }
254
+ else {
255
+ // we did not generate a valid codePoint so insert a
256
+ // replacement char (U+FFFD) and advance only 1 byte
257
+ codePoint = 0xFFFD;
258
+ bytesPerSequence = 1;
259
+ }
260
+ }
261
+ else if (codePoint > 0xFFFF) {
262
+ // encode to utf16 (surrogate pair dance)
263
+ codePoint -= 0x10000;
264
+ res.push(codePoint >>> 10 & 0x3FF | 0xD800);
265
+ codePoint = 0xDC00 | codePoint & 0x3FF;
266
+ }
267
+ res.push(codePoint);
268
+ i += bytesPerSequence;
269
+ }
270
+ let str = "";
271
+ for (let j = 0, len = res.length; j < len; j += 0x1000) {
272
+ str += String.fromCharCode.apply(String, res.slice(j, j + 0x1000));
273
+ }
274
+ return str;
275
+ }
276
+ toString() { return "[object TextDecoder]"; }
277
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
278
+ }
279
+ defineStringTag(TextDecoderP, "TextDecoder");
280
+ class TextDecoderState {
281
+ fatal = false;
282
+ ignoreBOM = false;
283
+ _bomSeen = false;
284
+ _partial = [];
285
+ }
286
+ const UTF8Labels = ["utf-8", "utf8", "unicode-1-1-utf-8"];
287
+ function getBytesPerSequence(byte) {
288
+ return (byte > 0xEF) ? 4 : (byte > 0xDF) ? 3 : (byte > 0xBF) ? 2 : 1;
289
+ }
290
+ const TextDecoderE = g["TextDecoder"] || TextDecoderP;
291
+
292
+ class EventP {
293
+ static NONE = 0;
294
+ static CAPTURING_PHASE = 1;
295
+ static AT_TARGET = 2;
296
+ static BUBBLING_PHASE = 3;
297
+ constructor(type, eventInitDict) {
298
+ this[state$9] = new EventState();
299
+ this[state$9].type = String(type);
300
+ this[state$9].bubbles = !!eventInitDict?.bubbles;
301
+ this[state$9].cancelable = !!eventInitDict?.cancelable;
302
+ this[state$9].composed = !!eventInitDict?.composed;
303
+ }
304
+ [state$9];
305
+ get type() { return this[state$9].type; }
306
+ get bubbles() { return this[state$9].bubbles; }
307
+ get cancelable() { return this[state$9].cancelable; }
308
+ get composed() { return this[state$9].composed; }
309
+ get target() { return this[state$9].target; }
310
+ get currentTarget() { return this[state$9].currentTarget; }
311
+ get eventPhase() { return this[state$9].eventPhase; }
312
+ NONE = EventP.NONE;
313
+ CAPTURING_PHASE = EventP.CAPTURING_PHASE;
314
+ AT_TARGET = EventP.AT_TARGET;
315
+ BUBBLING_PHASE = EventP.BUBBLING_PHASE;
316
+ get srcElement() { return this[state$9].target; }
317
+ cancelBubble = false;
318
+ get defaultPrevented() { return this[state$9].defaultPrevented; }
319
+ get returnValue() { return this[state$9].returnValue; }
320
+ set returnValue(value) { if (!value) {
321
+ this.preventDefault();
322
+ } }
323
+ get isTrusted() { return this[state$9].isTrusted; }
324
+ get timeStamp() { return this[state$9].timeStamp; }
325
+ composedPath() {
326
+ const path = !!this.target ? [this.target] : [];
327
+ if (!!this.currentTarget && this.currentTarget !== this.target)
328
+ path.push(this.currentTarget);
329
+ return path;
330
+ }
331
+ initEvent = (type, bubbles, cancelable) => {
332
+ if (this[state$9]._dispatched)
333
+ return;
334
+ this[state$9].type = String(type);
335
+ this[state$9].bubbles = !!bubbles;
336
+ this[state$9].cancelable = !!cancelable;
337
+ };
338
+ preventDefault = () => {
339
+ if (this[state$9]._passive) {
340
+ console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
341
+ return;
342
+ }
343
+ if (this.cancelable) {
344
+ this[state$9]._preventDefaultCalled = true;
345
+ this[state$9].defaultPrevented = true;
346
+ this[state$9].returnValue = false;
347
+ }
348
+ };
349
+ stopImmediatePropagation = () => {
350
+ this[state$9]._stopImmediatePropagationCalled = true;
351
+ this.cancelBubble = true;
352
+ };
353
+ stopPropagation() {
354
+ this.cancelBubble = true;
355
+ }
356
+ toString() { return "[object Event]"; }
357
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Event"] }; }
358
+ }
359
+ defineStringTag(EventP, "Event");
360
+ class EventState {
361
+ static TimeStamp = (new Date()).getTime();
362
+ type = "";
363
+ bubbles = false;
364
+ cancelable = false;
365
+ composed = false;
366
+ target = null;
367
+ currentTarget = null;
368
+ eventPhase = EventP.NONE;
369
+ defaultPrevented = false;
370
+ returnValue = true;
371
+ isTrusted = false;
372
+ timeStamp = (new Date()).getTime() - EventState.TimeStamp;
373
+ _passive = false;
374
+ _dispatched = false;
375
+ _preventDefaultCalled = false;
376
+ _stopImmediatePropagationCalled = false;
377
+ }
378
+ const EventE = g["EventTarget"] ? g["Event"] : EventP;
379
+
380
+ const state$7 = Symbol("EventTargetState");
381
+ class EventTargetP {
382
+ constructor() {
383
+ this[state$7] = new EventTargetState(this);
384
+ }
385
+ [state$7];
386
+ addEventListener(type, callback, options) {
387
+ const executor = new Executor(type, callback);
388
+ executor.options.capture = typeof options === "boolean" ? options : !!options?.capture;
389
+ if (!this[state$7].executors.some(x => x.equals(executor))) {
390
+ if (typeof options === "object") {
391
+ const { once, passive, signal } = options;
392
+ executor.options.once = !!once;
393
+ executor.options.passive = !!passive;
394
+ if (signal) {
395
+ executor.options.signal = signal;
396
+ this[state$7].reply(signal, executor);
397
+ }
398
+ }
399
+ this[state$7].executors.push(executor);
400
+ const f = (v) => !!v.options.capture ? 0 : 1;
401
+ this[state$7].executors = this[state$7].executors.sort((a, b) => f(a) - f(b));
402
+ }
403
+ }
404
+ dispatchEvent(event) {
405
+ if (typeof event !== "object") {
406
+ throw new TypeError("EventTarget.dispatchEvent: Argument 1 is not an object.");
407
+ }
408
+ if (!(event instanceof EventP)) {
409
+ throw new TypeError("EventTarget.dispatchEvent: Argument 1 does not implement interface Event.");
410
+ }
411
+ const s = event[state$9];
412
+ s.target = this;
413
+ s.isTrusted = false;
414
+ return this[state$7].fire(event);
415
+ }
416
+ removeEventListener(type, callback, options) {
417
+ const executor = new Executor(type, callback);
418
+ executor.options.capture = typeof options === "boolean" ? options : !!options?.capture;
419
+ if (this[state$7].executors.some(x => x.equals(executor))) {
420
+ this[state$7].executors = this[state$7].executors.filter(x => !x.equals(executor));
421
+ }
422
+ }
423
+ toString() { return "[object EventTarget]"; }
424
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
425
+ }
426
+ defineStringTag(EventTargetP, "EventTarget");
427
+ class EventTargetState {
428
+ constructor(target) {
429
+ this.target = target;
430
+ }
431
+ target;
432
+ executors = [];
433
+ fire(event) {
434
+ const s = event[state$9];
435
+ if (!event.target)
436
+ s.target = this.target;
437
+ s.currentTarget = this.target;
438
+ s.eventPhase = EventP.AT_TARGET;
439
+ s._dispatched = true;
440
+ const onceIndexes = [];
441
+ for (let i = 0; i < this.executors.length; ++i) {
442
+ const executor = this.executors[i];
443
+ if (executor.type !== event.type)
444
+ continue;
445
+ s._passive = !!executor.options.passive;
446
+ if (executor.options.once)
447
+ onceIndexes.push(i);
448
+ try {
449
+ const { callback: cb } = executor;
450
+ if (typeof cb === "function")
451
+ cb.call(this.target, event);
452
+ }
453
+ catch (e) {
454
+ console.error(e);
455
+ }
456
+ s._passive = false;
457
+ if (s._stopImmediatePropagationCalled)
458
+ break;
459
+ }
460
+ if (onceIndexes.length > 0) {
461
+ this.executors = this.executors.reduce((acc, cur, index) => {
462
+ if (!onceIndexes.includes(index))
463
+ acc.push(cur);
464
+ return acc;
465
+ }, []);
466
+ }
467
+ s.currentTarget = null;
468
+ s.eventPhase = EventP.NONE;
469
+ s._dispatched = false;
470
+ return !(event.cancelable && s._preventDefaultCalled);
471
+ }
472
+ reply(signal, executor) {
473
+ try {
474
+ const onAbort = () => {
475
+ this.executors = this.executors.filter(x => !x.equals(executor));
476
+ signal.removeEventListener("abort", onAbort);
477
+ };
478
+ signal.addEventListener("abort", onAbort);
479
+ }
480
+ catch (e) {
481
+ console.error(e);
482
+ }
483
+ }
484
+ }
485
+ class Executor {
486
+ static extract(cb) {
487
+ if (typeof cb === "function") {
488
+ return cb;
489
+ }
490
+ else if (isEventListenerObject(cb)) {
491
+ return cb.handleEvent;
492
+ }
493
+ else {
494
+ return cb;
495
+ }
496
+ }
497
+ constructor(type, callback) {
498
+ this.type = String(type);
499
+ this.callback = Executor.extract(callback);
500
+ }
501
+ type;
502
+ callback;
503
+ options = {};
504
+ equals(executor) {
505
+ return Object.is(this.type, executor.type) && Object.is(this.callback, executor.callback)
506
+ && Object.is(this.options.capture, executor.options.capture);
507
+ }
508
+ }
509
+ function isEventListenerObject(cb) {
510
+ return !!cb && "handleEvent" in cb && typeof cb.handleEvent === "function";
511
+ }
512
+ function attachFn(type, cb, listener) {
513
+ if (typeof cb === "function") {
514
+ this.addEventListener(type, listener);
515
+ }
516
+ else {
517
+ this.removeEventListener(type, listener);
518
+ }
519
+ }
520
+ function executeFn(cb, ev) {
521
+ if (typeof cb === "function")
522
+ cb.call(this, ev);
523
+ }
524
+ const EventTargetE = g["EventTarget"] || EventTargetP;
525
+
526
+ const state$6 = Symbol("CustomEventState");
527
+ class CustomEventP extends EventP {
528
+ constructor(type, eventInitDict) {
529
+ super(type, eventInitDict);
530
+ this[state$6] = new CustomEventState();
531
+ this[state$6].detail = eventInitDict?.detail ?? null;
532
+ }
533
+ [state$6];
534
+ get detail() { return this[state$6].detail; }
535
+ initCustomEvent(type, bubbles, cancelable, detail) {
536
+ if (this[state$9]._dispatched)
537
+ return;
538
+ this.initEvent(type, bubbles, cancelable);
539
+ this[state$6].detail = detail ?? null;
540
+ }
541
+ toString() { return "[object CustomEvent]"; }
542
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
543
+ }
544
+ defineStringTag(CustomEventP, "CustomEvent");
545
+ class CustomEventState {
546
+ detail;
547
+ }
548
+ const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
549
+
550
+ const state$5 = Symbol("ProgressEventState");
551
+ class ProgressEventP extends EventP {
552
+ constructor(type, eventInitDict) {
553
+ super(type, eventInitDict);
554
+ this[state$5] = new ProgressEventState();
555
+ this[state$5].lengthComputable = !!eventInitDict?.lengthComputable;
556
+ this[state$5].loaded = eventInitDict?.loaded ?? 0;
557
+ this[state$5].total = eventInitDict?.total ?? 0;
558
+ }
559
+ [state$5];
560
+ get lengthComputable() { return this[state$5].lengthComputable; }
561
+ get loaded() { return this[state$5].loaded; }
562
+ get total() { return this[state$5].total; }
563
+ toString() { return "[object ProgressEvent]"; }
564
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
565
+ }
566
+ defineStringTag(ProgressEventP, "ProgressEvent");
567
+ class ProgressEventState {
568
+ lengthComputable = false;
569
+ loaded = 0;
570
+ total = 0;
571
+ }
572
+ const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
573
+
574
+ class BlobP {
575
+ constructor(blobParts = [], options) {
576
+ if (!Array.isArray(blobParts)) {
577
+ throw new TypeError("First argument to Blob constructor must be an Array.");
578
+ }
579
+ let encoder = null;
580
+ let chunks = blobParts.reduce((chunks, part) => {
581
+ if (isPolyfillType("Blob", part)) {
582
+ chunks.push(part[state$9]._u8array);
583
+ }
584
+ else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
585
+ chunks.push(convert$1(part));
586
+ }
587
+ else {
588
+ if (!encoder) {
589
+ encoder = new TextEncoderP();
590
+ }
591
+ chunks.push(encoder.encode(String(part)));
592
+ }
593
+ return chunks;
594
+ }, []);
595
+ this[state$9] = new BlobState(concat(chunks));
596
+ this[state$9].size = this[state$9]._u8array.length;
597
+ const rawType = options?.type || "";
598
+ this[state$9].type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
599
+ }
600
+ [state$9];
601
+ get size() { return this[state$9].size; }
602
+ get type() { return this[state$9].type; }
603
+ arrayBuffer() {
604
+ return Promise.resolve(clone(this[state$9]._u8array.buffer).buffer);
605
+ }
606
+ bytes() {
607
+ return Promise.resolve(clone(this[state$9]._u8array.buffer));
608
+ }
609
+ slice(start, end, contentType) {
610
+ const sliced = this[state$9]._u8array.slice(start ?? 0, end ?? this[state$9]._u8array.length);
611
+ return new BlobP([sliced], { type: contentType ?? "" });
612
+ }
613
+ stream() {
614
+ throw new ReferenceError("ReadableStream is not defined");
615
+ }
616
+ text() {
617
+ const decoder = new TextDecoderP();
618
+ return Promise.resolve(decoder.decode(this[state$9]._u8array));
619
+ }
620
+ toString() { return "[object Blob]"; }
621
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
622
+ }
623
+ defineStringTag(BlobP, "Blob");
624
+ class BlobState {
625
+ constructor(buffer) {
626
+ this._u8array = buffer;
627
+ }
628
+ size = 0;
629
+ type = "";
630
+ _u8array;
631
+ }
632
+ function u8array2base64(input) {
633
+ let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
634
+ let output = [];
635
+ for (var i = 0; i < input.length; i += 3) {
636
+ let byte1 = input[i];
637
+ let haveByte2 = i + 1 < input.length;
638
+ let byte2 = haveByte2 ? input[i + 1] : 0;
639
+ let haveByte3 = i + 2 < input.length;
640
+ let byte3 = haveByte3 ? input[i + 2] : 0;
641
+ let outByte1 = byte1 >> 2;
642
+ let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
643
+ let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
644
+ let outByte4 = byte3 & 0x3F;
645
+ if (!haveByte3) {
646
+ outByte4 = 64;
647
+ if (!haveByte2) {
648
+ outByte3 = 64;
649
+ }
650
+ }
651
+ output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
652
+ }
653
+ return output.join("");
654
+ }
655
+ function convert$1(buf) {
656
+ return buf instanceof ArrayBuffer
657
+ ? new Uint8Array(buf)
658
+ : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
659
+ }
660
+ function clone(buf) {
661
+ const sourceArray = convert$1(buf);
662
+ const cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
663
+ cloneArray.set(sourceArray);
664
+ return cloneArray;
665
+ }
666
+ function concat(chunks) {
667
+ const totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
668
+ const result = new Uint8Array(totalByteLength);
669
+ chunks.reduce((offset, chunk) => {
670
+ result.set(chunk, offset);
671
+ return offset + chunk.byteLength;
672
+ }, 0);
673
+ return result;
674
+ }
675
+ const BlobE = g["Blob"] || BlobP;
676
+
677
+ const state$4 = Symbol("FileState");
678
+ class FileP extends BlobP {
679
+ constructor(fileBits, fileName, options) {
680
+ super(fileBits, options);
681
+ this[state$4] = new FileState();
682
+ this[state$4].lastModified = +(options?.lastModified ? new Date(options.lastModified) : new Date());
683
+ this[state$4].name = fileName.replace(/\//g, ":");
684
+ }
685
+ [state$4];
686
+ get lastModified() { return this[state$4].lastModified; }
687
+ get name() { return this[state$4].name; }
688
+ get webkitRelativePath() { return ""; }
689
+ toString() { return "[object File]"; }
690
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
691
+ }
692
+ defineStringTag(FileP, "File");
693
+ class FileState {
694
+ lastModified = 0;
695
+ name = "";
696
+ }
697
+ const FileE = g["Blob"] ? g["File"] : FileP;
698
+
699
+ const state$3 = Symbol("FileReaderState");
700
+ class FileReaderP extends EventTargetP {
701
+ static EMPTY = 0;
702
+ static LOADING = 1;
703
+ static DONE = 2;
704
+ constructor() {
705
+ super();
706
+ this[state$3] = new FileReaderState(this);
707
+ }
708
+ [state$3];
709
+ get readyState() { return this[state$3].readyState; }
710
+ get result() { return this[state$3].result; }
711
+ EMPTY = 0;
712
+ LOADING = 1;
713
+ DONE = 2;
714
+ get error() { return this[state$3].error; }
715
+ abort() {
716
+ if (this.readyState === FileReaderP.LOADING) {
717
+ this[state$3].readyState = FileReaderP.DONE;
718
+ this[state$3].result = null;
719
+ this[state$3].emitProcessEvent("abort");
720
+ }
721
+ }
722
+ readAsArrayBuffer = (blob) => {
723
+ this[state$3].read("readAsArrayBuffer", blob, () => {
724
+ this[state$3].result = blob[state$9]._u8array.buffer.slice(0);
725
+ });
726
+ };
727
+ readAsBinaryString = (blob) => {
728
+ this[state$3].read("readAsBinaryString", blob, () => {
729
+ this[state$3].result = blob[state$9]._u8array.reduce((acc, cur) => {
730
+ acc += String.fromCharCode(cur);
731
+ return acc;
732
+ }, "");
733
+ });
734
+ };
735
+ readAsDataURL = (blob) => {
736
+ this[state$3].read("readAsDataURL", blob, () => {
737
+ this[state$3].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$9]._u8array);
738
+ });
739
+ };
740
+ readAsText = (blob, encoding) => {
741
+ this[state$3].read("readAsText", blob, () => {
742
+ this[state$3].result = (new TextDecoderP(encoding)).decode(blob[state$9]._u8array);
743
+ });
744
+ };
745
+ get onabort() { return this[state$3].onabort; }
746
+ set onabort(value) { this[state$3].onabort = value; this[state$3].attach("abort"); }
747
+ get onerror() { return this[state$3].onerror; }
748
+ set onerror(value) { this[state$3].onerror = value; this[state$3].attach("error"); }
749
+ get onload() { return this[state$3].onload; }
750
+ set onload(value) { this[state$3].onload = value; this[state$3].attach("load"); }
751
+ get onloadend() { return this[state$3].onloadend; }
752
+ set onloadend(value) { this[state$3].onloadend = value; this[state$3].attach("loadend"); }
753
+ get onloadstart() { return this[state$3].onloadstart; }
754
+ set onloadstart(value) { this[state$3].onloadstart = value; this[state$3].attach("loadstart"); }
755
+ get onprogress() { return this[state$3].onprogress; }
756
+ set onprogress(value) { this[state$3].onprogress = value; this[state$3].attach("progress"); }
757
+ toString() { return "[object FileReader]"; }
758
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
759
+ }
760
+ defineStringTag(FileReaderP, "FileReader");
761
+ class FileReaderState {
762
+ constructor(target) {
763
+ this.target = target;
764
+ }
765
+ target;
766
+ readyState = FileReaderP.EMPTY;
767
+ result = null;
768
+ error = null;
769
+ read(kind, blob, setResult) {
770
+ if (!isPolyfillType("Blob", blob)) {
771
+ throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
772
+ }
773
+ this.error = null;
774
+ this.readyState = FileReaderP.LOADING;
775
+ this.emitProcessEvent("loadstart", 0, blob.size);
776
+ setTimeout(() => {
777
+ if (this.readyState === FileReaderP.LOADING) {
778
+ this.readyState = FileReaderP.DONE;
779
+ try {
780
+ setResult();
781
+ this.emitProcessEvent("load", blob.size, blob.size);
782
+ }
783
+ catch (e) {
784
+ this.result = null;
785
+ this.error = e;
786
+ this.emitProcessEvent("error", 0, blob.size);
787
+ }
788
+ }
789
+ this.emitProcessEvent("loadend", !!this.result ? blob.size : 0, blob.size);
790
+ });
791
+ }
792
+ emitProcessEvent(type, loaded = 0, total = 0) {
793
+ const event = new ProgressEventP(type, {
794
+ lengthComputable: total > 0,
795
+ loaded,
796
+ total,
797
+ });
798
+ event[state$9].target = this.target;
799
+ event[state$9].isTrusted = true;
800
+ this.target[state$7].fire(event);
801
+ }
802
+ attach(type) {
803
+ const cb = this[("on" + type)];
804
+ const listener = this[("_on" + type)];
805
+ attachFn.call(this.target, type, cb, listener);
806
+ }
807
+ onabort = null;
808
+ _onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
809
+ onerror = null;
810
+ _onerror = (ev) => { executeFn.call(this.target, this.onerror, ev); };
811
+ onload = null;
812
+ _onload = (ev) => { executeFn.call(this.target, this.onload, ev); };
813
+ onloadend = null;
814
+ _onloadend = (ev) => { executeFn.call(this.target, this.onloadend, ev); };
815
+ onloadstart = null;
816
+ _onloadstart = (ev) => { executeFn.call(this.target, this.onloadstart, ev); };
817
+ onprogress = null;
818
+ _onprogress = (ev) => { executeFn.call(this.target, this.onprogress, ev); };
819
+ }
820
+ const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
821
+
822
+ class FormDataP {
823
+ constructor(form, submitter) {
824
+ if (form !== void 0) {
825
+ throw new TypeError("Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.");
826
+ }
827
+ if (!!submitter) {
828
+ throw new TypeError("Failed to construct 'FormData': parameter 2 is not of type 'HTMLElement'.");
829
+ }
830
+ this[state$9] = new FormDataState();
831
+ }
832
+ [state$9];
833
+ append(name, value, filename) {
834
+ this[state$9]._data.push(normalizeArgs(name, value, filename));
835
+ }
836
+ delete(name) {
837
+ const result = [];
838
+ name = String(name);
839
+ each(this[state$9]._data, entry => {
840
+ entry[0] !== name && result.push(entry);
841
+ });
842
+ this[state$9]._data = result;
843
+ }
844
+ get(name) {
845
+ const entries = this[state$9]._data;
846
+ name = String(name);
847
+ for (let i = 0; i < entries.length; ++i) {
848
+ if (entries[i][0] === name) {
849
+ return entries[i][1];
850
+ }
851
+ }
852
+ return null;
853
+ }
854
+ getAll(name) {
855
+ const result = [];
856
+ name = String(name);
857
+ each(this[state$9]._data, data => {
858
+ data[0] === name && result.push(data[1]);
859
+ });
860
+ return result;
861
+ }
862
+ has(name) {
863
+ name = String(name);
864
+ for (let i = 0; i < this[state$9]._data.length; ++i) {
865
+ if (this[state$9]._data[i][0] === name) {
866
+ return true;
867
+ }
868
+ }
869
+ return false;
870
+ }
871
+ set(name, value, filename) {
872
+ name = String(name);
873
+ const result = [];
874
+ const args = normalizeArgs(name, value, filename);
875
+ let replace = true;
876
+ each(this[state$9]._data, data => {
877
+ data[0] === name
878
+ ? replace && (replace = !result.push(args))
879
+ : result.push(data);
880
+ });
881
+ replace && result.push(args);
882
+ this[state$9]._data = result;
883
+ }
884
+ forEach(callbackfn, thisArg) {
885
+ for (const [name, value] of this) {
886
+ callbackfn.call(thisArg, value, name, thisArg);
887
+ }
888
+ }
889
+ entries() {
890
+ return this[state$9]._data.values();
891
+ }
892
+ keys() {
893
+ return this[state$9]._data.map(x => x[0]).values();
894
+ }
895
+ values() {
896
+ return this[state$9]._data.map(x => x[1]).values();
897
+ }
898
+ [Symbol.iterator]() {
899
+ return this.entries();
900
+ }
901
+ toString() { return "[object FormData]"; }
902
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
903
+ }
904
+ defineStringTag(FormDataP, "FormData");
905
+ class FormDataState {
906
+ _data = [];
907
+ toBlob() {
908
+ const boundary = "----formdata-polyfill-" + Math.random();
909
+ const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
910
+ let chunks = [];
911
+ for (const [name, value] of this._data.values()) {
912
+ if (typeof value === "string") {
913
+ chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
914
+ }
915
+ else {
916
+ chunks.push(p + escape(normalizeLinefeeds(name)) + `"; filename="${escape(value.name)}"\r\nContent-Type: ${value.type || "application/octet-stream"}\r\n\r\n`, value, `\r\n`);
917
+ }
918
+ }
919
+ chunks.push(`--${boundary}--`);
920
+ return new BlobP(chunks, {
921
+ type: "multipart/form-data; boundary=" + boundary,
922
+ });
923
+ }
924
+ }
925
+ function normalizeArgs(name, value, filename) {
926
+ if (isPolyfillType("Blob", value)) {
927
+ filename = filename !== undefined
928
+ ? String(filename + "")
929
+ : typeof value.name === "string"
930
+ ? value.name
931
+ : "blob";
932
+ if (value.name !== filename || Object.prototype.toString.call(value) === "[object Blob]") {
933
+ value = new FileP([value], filename);
934
+ }
935
+ return [String(name), value];
936
+ }
937
+ return [String(name), String(value)];
938
+ }
939
+ function normalizeLinefeeds(value) {
940
+ return value.replace(/\r?\n|\r/g, "\r\n");
941
+ }
942
+ function each(arr, cb) {
943
+ for (let i = 0; i < arr.length; ++i) {
944
+ cb(arr[i]);
945
+ }
946
+ }
947
+ function escape(str) {
948
+ return str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22');
949
+ }
950
+ /**
951
+ * Parses multipart/form-data binary data, supporting restoration of text fields and files
952
+ * @param body - Text in multipart/form-data format (including boundaries and data)
953
+ * @returns Parsed FormData object (text fields as strings, files as File objects)
954
+ */
955
+ function createFormData(body) {
956
+ const formData = new FormDataP();
957
+ if (typeof body !== "string" || body.trim() === "") {
958
+ return formData;
959
+ }
960
+ // 1. Extract boundary string (from the first line, removing leading "--")
961
+ const firstLineEnd = body.indexOf("\r\n");
962
+ if (firstLineEnd === -1) {
963
+ // Invalid multipart format: Missing line break in header
964
+ throw new TypeError("Failed to fetch");
965
+ }
966
+ const boundary = body.substring(2, firstLineEnd).trim();
967
+ if (!boundary) {
968
+ // Invalid multipart format: Empty boundary
969
+ throw new TypeError("Invalid MIME type");
970
+ }
971
+ // 2. Split data into individual parts (excluding empty content and trailing "--")
972
+ const parts = body.split(`--${boundary}`).filter(part => {
973
+ const trimmed = part.trim();
974
+ return trimmed !== "" && trimmed !== "--";
975
+ });
976
+ if (parts.length === 0) {
977
+ // Invalid multipart format: No parts found
978
+ throw new TypeError("Failed to fetch");
979
+ }
980
+ // 3. Parse each part
981
+ parts.forEach(part => {
982
+ // Split header and content (separator between header and content is "\r\n\r\n")
983
+ const separatorIndex = part.indexOf("\r\n\r\n");
984
+ if (separatorIndex === -1) {
985
+ // Invalid part format: Missing header-content separator
986
+ throw new TypeError("Failed to fetch");
987
+ }
988
+ // Extract header (Content-Disposition and Content-Type)
989
+ const headerRaw = part.substring(0, separatorIndex).trim();
990
+ const contentRaw = part.substring(separatorIndex + 4); // Skip "\r\n\r\n"
991
+ // Parse header information
992
+ const nameMatch = headerRaw.match(/name="([^"]+)"/); // Field name
993
+ const filenameMatch = headerRaw.match(/filename="([^"]*)"/); // Filename (optional, only for file fields)
994
+ const contentTypeMatch = headerRaw.match(/Content-Type: ([^\r\n]+)/); // MIME type (optional)
995
+ if (!nameMatch || !nameMatch[1]) {
996
+ // Invalid part format: Missing field name
997
+ throw new TypeError("Failed to fetch");
998
+ }
999
+ const fieldName = nameMatch[1];
1000
+ const isFile = !!filenameMatch; // Whether it's a file field
1001
+ const mimeType = contentTypeMatch ? (contentTypeMatch[1] || "").trim() : "application/octet-stream";
1002
+ // 4. Process content (text or binary)
1003
+ if (isFile) {
1004
+ // File field: Use TextEncoder to handle raw binary data
1005
+ try {
1006
+ // Remove line breaks from content (simulating browser behavior)
1007
+ const content = contentRaw.replace(/\r\n/g, "");
1008
+ // Convert string to Uint8Array using TextEncoder
1009
+ const encoder = new TextEncoderP();
1010
+ const uint8Array = encoder.encode(content);
1011
+ // Create File object (default filename is unknown-file)
1012
+ const filename = filenameMatch[1] || "unknown-file";
1013
+ const file = new FileP([uint8Array], filename, { type: mimeType });
1014
+ formData.append(fieldName, file, filename);
1015
+ }
1016
+ catch (e) {
1017
+ // `Failed to process file field "${fieldName}": ${(e as Error).message}`
1018
+ throw new TypeError("Failed to fetch");
1019
+ }
1020
+ }
1021
+ else {
1022
+ // Text field: Directly take content (remove leading/trailing line breaks to match browser behavior)
1023
+ const value = contentRaw.replace(/^[\r\n]+|[\r\n]+$/g, "");
1024
+ formData.append(fieldName, value);
1025
+ }
1026
+ });
1027
+ return formData;
1028
+ }
1029
+ const FormDataE = g["FormData"] || FormDataP;
1030
+
1031
+ class URLSearchParamsP {
1032
+ constructor(init) {
1033
+ let search = init || "";
1034
+ if (isObjectType("URLSearchParams", search)) {
1035
+ search = search.toString();
1036
+ }
1037
+ this[state$9] = new URLSearchParamsState();
1038
+ this[state$9]._dict = parseToDict(search);
1039
+ }
1040
+ [state$9];
1041
+ get size() {
1042
+ return Object.values(this[state$9]._dict).reduce((acc, cur) => acc + cur.length, 0);
1043
+ }
1044
+ append(name, value) {
1045
+ appendTo(this[state$9]._dict, name, value);
1046
+ }
1047
+ delete(name, value) {
1048
+ let dict = {};
1049
+ for (let [key, values] of Object.entries(this[state$9]._dict)) {
1050
+ if (key === name) {
1051
+ if (value !== undefined) {
1052
+ let vals = values.filter(x => x !== ("" + value));
1053
+ if (vals.length > 0)
1054
+ Object.assign(dict, { [key]: vals });
1055
+ }
1056
+ continue;
1057
+ }
1058
+ Object.assign(dict, { [key]: values });
1059
+ }
1060
+ this[state$9]._dict = dict;
1061
+ }
1062
+ get(name) {
1063
+ return this.has(name) ? this[state$9]._dict[name][0] ?? null : null;
1064
+ }
1065
+ getAll(name) {
1066
+ return this.has(name) ? this[state$9]._dict[name].slice(0) : [];
1067
+ }
1068
+ has(name, value) {
1069
+ if (hasOwnProperty(this[state$9]._dict, name)) {
1070
+ if (value !== undefined) {
1071
+ return this[state$9]._dict[name].includes(("" + value));
1072
+ }
1073
+ return true;
1074
+ }
1075
+ return false;
1076
+ }
1077
+ set(name, value) {
1078
+ this[state$9]._dict[name] = ["" + value];
1079
+ }
1080
+ sort() {
1081
+ let keys = Object.keys(this[state$9]._dict);
1082
+ keys.sort();
1083
+ let dict = {};
1084
+ for (let key of keys) {
1085
+ Object.assign(dict, { [key]: this[state$9]._dict[key] });
1086
+ }
1087
+ this[state$9]._dict = dict;
1088
+ }
1089
+ forEach(callbackfn, thisArg) {
1090
+ Object.entries(this[state$9]._dict).forEach(([key, values]) => {
1091
+ values.forEach(value => {
1092
+ callbackfn.call(thisArg, value, key, this);
1093
+ });
1094
+ });
1095
+ }
1096
+ entries() {
1097
+ return Object.entries(this[state$9]._dict)
1098
+ .map(([key, values]) => {
1099
+ return values.map(value => {
1100
+ return [key, value];
1101
+ });
1102
+ })
1103
+ .flat()
1104
+ .values();
1105
+ }
1106
+ keys() {
1107
+ return Object.keys(this[state$9]._dict).values();
1108
+ }
1109
+ values() {
1110
+ return Object.values(this[state$9]._dict).flat().values();
1111
+ }
1112
+ [Symbol.iterator]() {
1113
+ return this.entries();
1114
+ }
1115
+ toString() {
1116
+ let query = [];
1117
+ for (let [key, values] of Object.entries(this[state$9]._dict)) {
1118
+ let name = encode$1(key);
1119
+ for (let val of values) {
1120
+ query.push(name + "=" + encode$1(val));
1121
+ }
1122
+ }
1123
+ return query.join("&");
1124
+ }
1125
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1126
+ }
1127
+ defineStringTag(URLSearchParamsP, "URLSearchParams");
1128
+ class URLSearchParamsState {
1129
+ _dict = {};
1130
+ }
1131
+ function parseToDict(search) {
1132
+ let dict = {};
1133
+ if (typeof search === "object") {
1134
+ // if `search` is an array, treat it as a sequence
1135
+ if (Array.isArray(search)) {
1136
+ for (let i = 0; i < search.length; ++i) {
1137
+ let item = search[i];
1138
+ if (Array.isArray(item) && item.length === 2) {
1139
+ appendTo(dict, item[0], item[1]);
1140
+ }
1141
+ else {
1142
+ throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
1143
+ }
1144
+ }
1145
+ }
1146
+ else {
1147
+ for (const key in search) {
1148
+ if (search.hasOwnProperty(key)) {
1149
+ appendTo(dict, key, search[key]);
1150
+ }
1151
+ }
1152
+ }
1153
+ }
1154
+ else {
1155
+ // remove first '?'
1156
+ if (search.indexOf("?") === 0) {
1157
+ search = search.slice(1);
1158
+ }
1159
+ let pairs = search.split("&");
1160
+ for (let j = 0; j < pairs.length; ++j) {
1161
+ let value = pairs[j], index = value.indexOf("=");
1162
+ if (-1 < index) {
1163
+ appendTo(dict, decode$1(value.slice(0, index)), decode$1(value.slice(index + 1)));
1164
+ }
1165
+ else {
1166
+ if (value) {
1167
+ appendTo(dict, decode$1(value), "");
1168
+ }
1169
+ }
1170
+ }
1171
+ }
1172
+ return dict;
1173
+ }
1174
+ function appendTo(dict, name, value) {
1175
+ let val = typeof value === "string" ? value : (value !== null && value !== undefined && typeof value.toString === "function" ? value.toString() : JSON.stringify(value));
1176
+ // Prevent using `hasOwnProperty` as a property name
1177
+ if (hasOwnProperty(dict, name)) {
1178
+ dict[name].push(val);
1179
+ }
1180
+ else {
1181
+ dict[name] = [val];
1182
+ }
1183
+ }
1184
+ function encode$1(str) {
1185
+ const replace = {
1186
+ "!": "%21",
1187
+ "'": "%27",
1188
+ "(": "%28",
1189
+ ")": "%29",
1190
+ "~": "%7E",
1191
+ "%20": "+",
1192
+ "%00": "\x00",
1193
+ };
1194
+ return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, match => replace[match]);
1195
+ }
1196
+ function decode$1(str) {
1197
+ return str
1198
+ .replace(/[ +]/g, "%20")
1199
+ .replace(/(%[a-f0-9]{2})+/ig, match => decodeURIComponent(match));
1200
+ }
1201
+ function hasOwnProperty(obj, prop) {
1202
+ return Object.prototype.hasOwnProperty.call(obj, prop);
1203
+ }
1204
+ const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1205
+
1206
+ class AbortSignalP extends EventTargetP {
1207
+ static abort(reason) {
1208
+ const signal = createAbortSignalP();
1209
+ signal[state$9].abort(reason, false);
1210
+ return signal;
1211
+ }
1212
+ static any(signals) {
1213
+ const signal = createAbortSignalP();
1214
+ const abortedSignal = signals.find(x => x.aborted);
1215
+ if (abortedSignal) {
1216
+ signal[state$9].abort(abortedSignal.reason, false);
1217
+ }
1218
+ else {
1219
+ function abortFn(ev) {
1220
+ for (const sig of signals) {
1221
+ sig.removeEventListener("abort", abortFn);
1222
+ }
1223
+ signal[state$9].abort(this.reason, true, ev.isTrusted);
1224
+ }
1225
+ for (const sig of signals) {
1226
+ sig.addEventListener("abort", abortFn);
1227
+ }
1228
+ }
1229
+ return signal;
1230
+ }
1231
+ static timeout(milliseconds) {
1232
+ const signal = createAbortSignalP();
1233
+ setTimeout(() => {
1234
+ signal[state$9].abort(new MPException("signal timed out", "TimeoutError"));
1235
+ }, milliseconds);
1236
+ return signal;
1237
+ }
1238
+ constructor() {
1239
+ if (new.target === AbortSignalP) {
1240
+ throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
1241
+ }
1242
+ super();
1243
+ this[state$9] = new AbortSignalState(this);
1244
+ }
1245
+ [state$9];
1246
+ get aborted() { return this[state$9].aborted; }
1247
+ get reason() { return this[state$9].reason; }
1248
+ throwIfAborted() {
1249
+ if (this.aborted) {
1250
+ throw this.reason;
1251
+ }
1252
+ }
1253
+ get onabort() { return this[state$9].onabort; }
1254
+ set onabort(value) {
1255
+ this[state$9].onabort = value;
1256
+ attachFn.call(this, "abort", value, this[state$9]._onabort);
1257
+ }
1258
+ toString() { return "[object AbortSignal]"; }
1259
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1260
+ }
1261
+ defineStringTag(AbortSignalP, "AbortSignal");
1262
+ class AbortSignalState {
1263
+ constructor(target) {
1264
+ this.target = target;
1265
+ }
1266
+ target;
1267
+ aborted = false;
1268
+ reason = undefined;
1269
+ abort(reason, notify = true, isTrusted = true) {
1270
+ if (!this.aborted) {
1271
+ this.aborted = true;
1272
+ this.reason = reason ?? (new MPException("signal is aborted without reason", "AbortError"));
1273
+ if (notify) {
1274
+ const evt = new EventP("abort");
1275
+ evt[state$9].target = this.target;
1276
+ evt[state$9].isTrusted = isTrusted;
1277
+ this.target[state$7].fire(evt);
1278
+ }
1279
+ }
1280
+ }
1281
+ onabort = null;
1282
+ _onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
1283
+ }
1284
+ function createAbortSignalP() {
1285
+ const instance = Object.create(AbortSignalP.prototype);
1286
+ instance[state$7] = new EventTargetState(instance);
1287
+ instance[state$9] = new AbortSignalState(instance);
1288
+ return instance;
1289
+ }
1290
+ const AbortSignalE = g["AbortSignal"] || AbortSignalP;
1291
+
1292
+ const state$2 = Symbol("AbortControllerState");
1293
+ class AbortControllerP {
1294
+ constructor() {
1295
+ this[state$2] = new AbortControllerState();
1296
+ }
1297
+ [state$2];
1298
+ get signal() { return this[state$2].signal; }
1299
+ abort(reason) {
1300
+ this[state$2].signal[state$9].abort(reason);
1301
+ }
1302
+ toString() { return "[object AbortController]"; }
1303
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
1304
+ }
1305
+ defineStringTag(AbortControllerP, "AbortController");
1306
+ class AbortControllerState {
1307
+ signal = createAbortSignalP();
1308
+ }
1309
+ const AbortControllerE = g["AbortController"] || AbortControllerP;
1310
+
1311
+ // @ts-nocheck
1312
+ const mp = (() => {
1313
+ let u = "undefined", r = "request", f = "function";
1314
+ let mp;
1315
+ mp =
1316
+ (typeof wx !== u && typeof wx?.[r] === f && wx) || // 微信
1317
+ (typeof my !== u && typeof my?.[r] === f && my) || // 支付宝
1318
+ (typeof qq !== u && typeof qq?.[r] === f && qq) || // QQ
1319
+ (typeof jd !== u && typeof jd?.[r] === f && jd) || // 京东
1320
+ (typeof swan !== u && typeof swan?.[r] === f && swan) || // 百度
1321
+ (typeof tt !== u && typeof tt?.[r] === f && tt) || // 抖音 | 飞书
1322
+ (typeof ks !== u && typeof ks?.[r] === f && ks) || // 快手
1323
+ (typeof qh !== u && typeof qh?.[r] === f && qh) || // 360
1324
+ undefined;
1325
+ if (typeof g["XMLHttpRequest"] === f && typeof g["fetch"] === f) {
1326
+ return;
1327
+ }
1328
+ if (mp === undefined)
1329
+ mp =
1330
+ (typeof uni !== u && typeof uni?.[r] === f && uni) || // UniApp
1331
+ (typeof Taro !== u && typeof Taro?.[r] === f && Taro) || // Taro
1332
+ undefined;
1333
+ return mp;
1334
+ })();
1335
+
1336
+ class XMLHttpRequestEventTargetP extends EventTargetP {
1337
+ constructor() {
1338
+ if (new.target === XMLHttpRequestEventTargetP) {
1339
+ throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
1340
+ }
1341
+ super();
1342
+ this[state$9] = new XMLHttpRequestEventTargetState(this);
1343
+ }
1344
+ [state$9];
1345
+ get onabort() { return this[state$9].onabort; }
1346
+ set onabort(value) { this[state$9].onabort = value; this[state$9].attach("abort"); }
1347
+ get onerror() { return this[state$9].onerror; }
1348
+ set onerror(value) { this[state$9].onerror = value; this[state$9].attach("error"); }
1349
+ get onload() { return this[state$9].onload; }
1350
+ set onload(value) { this[state$9].onload = value; this[state$9].attach("load"); }
1351
+ get onloadend() { return this[state$9].onloadend; }
1352
+ set onloadend(value) { this[state$9].onloadend = value; this[state$9].attach("loadend"); }
1353
+ get onloadstart() { return this[state$9].onloadstart; }
1354
+ set onloadstart(value) { this[state$9].onloadstart = value; this[state$9].attach("loadstart"); }
1355
+ get onprogress() { return this[state$9].onprogress; }
1356
+ set onprogress(value) { this[state$9].onprogress = value; this[state$9].attach("progress"); }
1357
+ get ontimeout() { return this[state$9].ontimeout; }
1358
+ set ontimeout(value) { this[state$9].ontimeout = value; this[state$9].attach("timeout"); }
1359
+ toString() { return "[object XMLHttpRequestEventTarget]"; }
1360
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
1361
+ }
1362
+ defineStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
1363
+ class XMLHttpRequestEventTargetState {
1364
+ /**
1365
+ * @param _target XMLHttpRequestEventTargetP
1366
+ */
1367
+ constructor(_target) {
1368
+ this.target = _target;
1369
+ }
1370
+ target;
1371
+ attach(type) {
1372
+ const cb = this[("on" + type)];
1373
+ const listener = this[("_on" + type)];
1374
+ attachFn.call(this.target, type, cb, listener);
1375
+ }
1376
+ onabort = null;
1377
+ _onabort = (ev) => { executeFn.call(this.target, this.onabort, ev); };
1378
+ onerror = null;
1379
+ _onerror = (ev) => { executeFn.call(this.target, this.onerror, ev); };
1380
+ onload = null;
1381
+ _onload = (ev) => { executeFn.call(this.target, this.onload, ev); };
1382
+ onloadend = null;
1383
+ _onloadend = (ev) => { executeFn.call(this.target, this.onloadend, ev); };
1384
+ onloadstart = null;
1385
+ _onloadstart = (ev) => { executeFn.call(this.target, this.onloadstart, ev); };
1386
+ onprogress = null;
1387
+ _onprogress = (ev) => { executeFn.call(this.target, this.onprogress, ev); };
1388
+ ontimeout = null;
1389
+ _ontimeout = (ev) => { executeFn.call(this.target, this.ontimeout, ev); };
1390
+ }
1391
+
1392
+ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
1393
+ constructor() {
1394
+ if (new.target === XMLHttpRequestUploadP) {
1395
+ throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
1396
+ }
1397
+ super();
1398
+ }
1399
+ toString() { return "[object XMLHttpRequestUpload]"; }
1400
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
1401
+ }
1402
+ defineStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
1403
+ function createXMLHttpRequestUploadP() {
1404
+ const instance = Object.create(XMLHttpRequestUploadP.prototype);
1405
+ instance[state$7] = new EventTargetState(instance);
1406
+ instance[state$9] = new XMLHttpRequestEventTargetState(instance);
1407
+ return instance;
1408
+ }
1409
+
1410
+ const request = mp ? mp.request : function errorRequest(options) {
1411
+ const errMsg = "NOT_SUPPORTED_ERR";
1412
+ const errno = 9;
1413
+ const err = {
1414
+ errMsg,
1415
+ errno,
1416
+ exception: {
1417
+ retryCount: 0,
1418
+ reasons: [{ errMsg, errno }],
1419
+ },
1420
+ useHttpDNS: false,
1421
+ };
1422
+ Promise.resolve(err)
1423
+ .then(err => { if (options.fail) {
1424
+ options.fail(err);
1425
+ } })
1426
+ .finally(() => { if (options.complete) {
1427
+ options.complete(err);
1428
+ } });
1429
+ throw new ReferenceError("request is not defined");
1430
+ };
1431
+
1432
+ const state$1 = Symbol("XMLHttpRequestState");
1433
+ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1434
+ static UNSENT = 0;
1435
+ static OPENED = 1;
1436
+ static HEADERS_RECEIVED = 2;
1437
+ static LOADING = 3;
1438
+ static DONE = 4;
1439
+ constructor() {
1440
+ super();
1441
+ this[state$1] = new XMLHttpRequestState(this);
1442
+ }
1443
+ [state$1];
1444
+ UNSENT = 0;
1445
+ OPENED = 1;
1446
+ HEADERS_RECEIVED = 2;
1447
+ LOADING = 3;
1448
+ DONE = 4;
1449
+ get readyState() { return this[state$1].readyState; }
1450
+ get response() { return this[state$1].response; }
1451
+ get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
1452
+ get responseType() { return this[state$1].responseType; }
1453
+ set responseType(value) { this[state$1].responseType = value; }
1454
+ get responseURL() { return this[state$1].responseURL; }
1455
+ get responseXML() { return null; }
1456
+ get status() { return this[state$1].status; }
1457
+ get statusText() {
1458
+ if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
1459
+ return "";
1460
+ return this[state$1].statusText || statusTextMap(this.status);
1461
+ }
1462
+ get timeout() { return this[state$1].timeout; }
1463
+ set timeout(value) { this[state$1].timeout = value; }
1464
+ get upload() { return this[state$1].upload; }
1465
+ get withCredentials() { return this[state$1].withCredentials; }
1466
+ set withCredentials(value) { this[state$1].withCredentials = value; }
1467
+ abort() {
1468
+ this[state$1].clearRequest();
1469
+ }
1470
+ getAllResponseHeaders() {
1471
+ if (!this[state$1]._resHeaders)
1472
+ return "";
1473
+ return Object.entries(this[state$1]._resHeaders || {}).map(([k, v]) => `${k}: ${v}\r\n`).join("");
1474
+ }
1475
+ getResponseHeader(name) {
1476
+ if (!this[state$1]._resHeaders)
1477
+ return null;
1478
+ return Object.entries(this[state$1]._resHeaders || {}).find(x => x[0].toLowerCase() === name.toLowerCase())?.[1] ?? null;
1479
+ }
1480
+ open(...args) {
1481
+ const [method, url, async = true, username = null, password = null] = args;
1482
+ if (args.length < 2) {
1483
+ throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
1484
+ }
1485
+ if (!async) {
1486
+ console.warn("Synchronous XMLHttpRequest is deprecated because of its detrimental effects to the end user's experience.");
1487
+ }
1488
+ this[state$1].clearRequest(false);
1489
+ this[state$1]._method = normalizeMethod(method);
1490
+ this[state$1]._reqURL = String(url);
1491
+ this[state$1]._reqCanSend = true;
1492
+ this[state$1].setReadyStateAndNotify(XMLHttpRequestP.OPENED);
1493
+ }
1494
+ overrideMimeType(mime) { }
1495
+ send(body) {
1496
+ if (!this[state$1]._reqCanSend || this.readyState !== XMLHttpRequestP.OPENED) {
1497
+ throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
1498
+ }
1499
+ this[state$1]._reqCanSend = false;
1500
+ this[state$1].execRequest(body);
1501
+ this[state$1].checkRequestTimeout();
1502
+ }
1503
+ setRequestHeader(name, value) {
1504
+ assignRequestHeader(this[state$1]._reqHeaders, name, value);
1505
+ }
1506
+ get onreadystatechange() { return this[state$1].onreadystatechange; }
1507
+ set onreadystatechange(value) {
1508
+ this[state$1].onreadystatechange = value;
1509
+ attachFn.call(this, "readystatechange", value, this[state$1]._onreadystatechange);
1510
+ }
1511
+ toString() { return "[object XMLHttpRequest"; }
1512
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
1513
+ }
1514
+ defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
1515
+ class XMLHttpRequestState {
1516
+ constructor(target) {
1517
+ this.target = target;
1518
+ this.upload = createXMLHttpRequestUploadP();
1519
+ }
1520
+ target;
1521
+ readyState = XMLHttpRequestP.UNSENT;
1522
+ response = "";
1523
+ responseType = "";
1524
+ responseURL = "";
1525
+ status = 0;
1526
+ statusText = "";
1527
+ timeout = 0;
1528
+ upload;
1529
+ withCredentials = false;
1530
+ _reqCanSend = false;
1531
+ _resetPending = false;
1532
+ _timeoutId = 0;
1533
+ _reqURL = "";
1534
+ _method = "GET";
1535
+ _reqHeaders = { Accept: "*/*" };
1536
+ _resHeaders = null;
1537
+ _resContLen = 0;
1538
+ _requestTask = null;
1539
+ execRequest(body) {
1540
+ const allowsRequestBody = !["GET", "HEAD"].includes(this._method);
1541
+ const contentTypeExists = Object.keys(this._reqHeaders).map(x => x.toLowerCase()).includes("Content-Type".toLowerCase());
1542
+ const processHeaders = allowsRequestBody && !contentTypeExists;
1543
+ const processContentLength = this.upload[state$7].executors.length > 0;
1544
+ let headers = { ...this._reqHeaders };
1545
+ let contentLength = 0;
1546
+ let data = convert(body, processHeaders ? v => { headers["Content-Type"] = v; } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
1547
+ this._requestTask = request({
1548
+ url: this._reqURL,
1549
+ method: this._method,
1550
+ header: headers,
1551
+ data,
1552
+ dataType: this.responseType === "json" ? "json" : "text",
1553
+ responseType: this.responseType === "arraybuffer" ? "arraybuffer" : "text",
1554
+ success: this.requestSuccess.bind(this),
1555
+ fail: this.requestFail.bind(this),
1556
+ complete: this.requestComplete.bind(this),
1557
+ });
1558
+ this.emitProcessEvent("loadstart");
1559
+ if (processContentLength) {
1560
+ const hasRequestBody = allowsRequestBody && contentLength > 0;
1561
+ if (hasRequestBody) {
1562
+ this.emitProcessEvent("loadstart", 0, contentLength, this.upload);
1563
+ }
1564
+ setTimeout(() => {
1565
+ const _aborted = this._reqCanSend || this.readyState !== XMLHttpRequestP.OPENED;
1566
+ const _contentLength = _aborted ? 0 : contentLength;
1567
+ if (_aborted) {
1568
+ this.emitProcessEvent("abort", 0, 0, this.upload);
1569
+ }
1570
+ else {
1571
+ if (hasRequestBody) {
1572
+ this.emitProcessEvent("load", _contentLength, _contentLength, this.upload);
1573
+ }
1574
+ }
1575
+ if (_aborted || hasRequestBody) {
1576
+ this.emitProcessEvent("loadend", _contentLength, _contentLength, this.upload);
1577
+ }
1578
+ });
1579
+ }
1580
+ }
1581
+ requestSuccess({ statusCode, header, data }) {
1582
+ this.responseURL = this._reqURL;
1583
+ this.status = statusCode;
1584
+ this._resHeaders = header;
1585
+ this._resContLen = parseInt(this.target.getResponseHeader("Content-Length") || "0");
1586
+ if (this.readyState === XMLHttpRequestP.OPENED) {
1587
+ this.setReadyStateAndNotify(XMLHttpRequestP.HEADERS_RECEIVED);
1588
+ this.setReadyStateAndNotify(XMLHttpRequestP.LOADING);
1589
+ setTimeout(() => {
1590
+ if (!this._reqCanSend) {
1591
+ let l = this._resContLen;
1592
+ try {
1593
+ this.response = convertBack(this.responseType, data);
1594
+ this.emitProcessEvent("load", l, l);
1595
+ }
1596
+ catch (e) {
1597
+ console.error(e);
1598
+ this.emitProcessEvent("error");
1599
+ }
1600
+ }
1601
+ });
1602
+ }
1603
+ }
1604
+ requestFail(err) {
1605
+ // Alipay Mini Programs
1606
+ // error: 14 --- JSON parse data error
1607
+ // error: 19 --- http status error
1608
+ // At this point, the error data object will contain three pieces of information
1609
+ // returned from the server: status, headers, and data.
1610
+ // In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
1611
+ // differ from those in Alipay Mini Programs and should instead return normally.
1612
+ // Therefore, this scenario is also handled here as a successful request response.
1613
+ if ("status" in err) {
1614
+ this.requestSuccess({ statusCode: err.status, header: err.headers, data: err.data });
1615
+ return;
1616
+ }
1617
+ this.status = 0;
1618
+ this.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
1619
+ if (!this._reqCanSend && this.readyState !== XMLHttpRequestP.UNSENT && this.readyState !== XMLHttpRequestP.DONE) {
1620
+ this.emitProcessEvent("error");
1621
+ this.resetRequestTimeout();
1622
+ }
1623
+ }
1624
+ requestComplete() {
1625
+ this._requestTask = null;
1626
+ if (!this._reqCanSend && (this.readyState === XMLHttpRequestP.OPENED || this.readyState === XMLHttpRequestP.LOADING)) {
1627
+ this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
1628
+ }
1629
+ setTimeout(() => {
1630
+ if (!this._reqCanSend) {
1631
+ let l = this._resContLen;
1632
+ this.emitProcessEvent("loadend", l, l);
1633
+ }
1634
+ });
1635
+ }
1636
+ clearRequest(delay = true) {
1637
+ const timerFn = delay ? setTimeout : (f) => { f(); };
1638
+ this._resetPending = true;
1639
+ if (this._requestTask && this.readyState !== XMLHttpRequestP.DONE) {
1640
+ if (delay) {
1641
+ this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
1642
+ }
1643
+ timerFn(() => {
1644
+ const requestTask = this._requestTask;
1645
+ if (requestTask) {
1646
+ requestTask.abort();
1647
+ }
1648
+ if (delay) {
1649
+ this.emitProcessEvent("abort");
1650
+ }
1651
+ if (delay && !requestTask) {
1652
+ this.emitProcessEvent("loadend");
1653
+ }
1654
+ });
1655
+ }
1656
+ timerFn(() => {
1657
+ if (this._resetPending) {
1658
+ if (delay) {
1659
+ this.readyState = XMLHttpRequestP.UNSENT;
1660
+ }
1661
+ this.resetXHR();
1662
+ }
1663
+ });
1664
+ }
1665
+ checkRequestTimeout() {
1666
+ if (this.timeout) {
1667
+ this._timeoutId = setTimeout(() => {
1668
+ if (!this.status && this.readyState !== XMLHttpRequestP.DONE) {
1669
+ if (this._requestTask)
1670
+ this._requestTask.abort();
1671
+ this.setReadyStateAndNotify(XMLHttpRequestP.DONE);
1672
+ this.emitProcessEvent("timeout");
1673
+ }
1674
+ }, this.timeout);
1675
+ }
1676
+ }
1677
+ resetXHR() {
1678
+ this._resetPending = false;
1679
+ this.resetRequestTimeout();
1680
+ this.response = "";
1681
+ this.responseURL = "";
1682
+ this.status = 0;
1683
+ this.statusText = "";
1684
+ this._reqHeaders = {};
1685
+ this._resHeaders = null;
1686
+ this._resContLen = 0;
1687
+ }
1688
+ resetRequestTimeout() {
1689
+ if (this._timeoutId) {
1690
+ clearTimeout(this._timeoutId);
1691
+ this._timeoutId = 0;
1692
+ }
1693
+ }
1694
+ emitProcessEvent(type, loaded = 0, total = 0, target) {
1695
+ const _target = target ?? this.target;
1696
+ const _event = new ProgressEventP(type, {
1697
+ lengthComputable: total > 0,
1698
+ loaded,
1699
+ total,
1700
+ });
1701
+ _event[state$9].target = _target;
1702
+ _event[state$9].isTrusted = true;
1703
+ _target[state$7].fire(_event);
1704
+ }
1705
+ setReadyStateAndNotify(value) {
1706
+ const hasChanged = value !== this.readyState;
1707
+ this.readyState = value;
1708
+ if (hasChanged) {
1709
+ const evt = new EventP("readystatechange");
1710
+ evt[state$9].target = this.target;
1711
+ evt[state$9].isTrusted = true;
1712
+ this.target[state$7].fire(evt);
1713
+ }
1714
+ }
1715
+ onreadystatechange = null;
1716
+ _onreadystatechange = (ev) => { executeFn.call(this.target, this.onreadystatechange, ev); };
1717
+ }
1718
+ // HTTP methods whose capitalization should be normalized
1719
+ const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
1720
+ function normalizeMethod(method) {
1721
+ let upcased = method.toUpperCase();
1722
+ return methods.indexOf(upcased) > -1 ? upcased : method;
1723
+ }
1724
+ function assignRequestHeader(headers, name, value) {
1725
+ for (const key of Object.keys(headers)) {
1726
+ if (key.toLowerCase() === name.toLowerCase()) {
1727
+ headers[key] = value;
1728
+ return;
1729
+ }
1730
+ }
1731
+ Object.assign(headers, { [name]: value });
1732
+ return;
1733
+ }
1734
+ const encode = (str) => {
1735
+ const encoder = new TextEncoderP();
1736
+ return encoder.encode(str).buffer;
1737
+ };
1738
+ const decode = (buf) => {
1739
+ let decoder = new TextDecoderP();
1740
+ return decoder.decode(buf);
1741
+ };
1742
+ function convert(body, setContentType, setContentLength) {
1743
+ let result;
1744
+ if (typeof body === "string") {
1745
+ result = body;
1746
+ if (setContentType) {
1747
+ setContentType("text/plain;charset=UTF-8");
1748
+ }
1749
+ }
1750
+ else if (isObjectType("URLSearchParams", body)) {
1751
+ result = body.toString();
1752
+ if (setContentType) {
1753
+ setContentType("application/x-www-form-urlencoded;charset=UTF-8");
1754
+ }
1755
+ }
1756
+ else if (body instanceof ArrayBuffer) {
1757
+ result = body.slice(0);
1758
+ }
1759
+ else if (ArrayBuffer.isView(body)) {
1760
+ result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
1761
+ }
1762
+ else if (isPolyfillType("Blob", body)) {
1763
+ result = body[state$9]._u8array.buffer.slice(0);
1764
+ if (setContentType && body.type) {
1765
+ setContentType(body.type);
1766
+ }
1767
+ }
1768
+ else if (isPolyfillType("FormData", body)) {
1769
+ const blob = body[state$9].toBlob();
1770
+ result = blob[state$9]._u8array.buffer;
1771
+ if (setContentType) {
1772
+ setContentType(blob.type);
1773
+ }
1774
+ }
1775
+ else if (!body) {
1776
+ result = "";
1777
+ }
1778
+ else {
1779
+ result = String(body);
1780
+ }
1781
+ if (setContentLength) {
1782
+ setContentLength((typeof result === "string" ? encode(result) : result).byteLength);
1783
+ }
1784
+ return result;
1785
+ }
1786
+ function convertBack(type, data) {
1787
+ let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
1788
+ if (!type || type === "text") {
1789
+ return typeof temp === "string" ? temp : decode(temp);
1790
+ }
1791
+ else if (type === "json") {
1792
+ return JSON.parse(typeof temp === "string" ? temp : decode(temp));
1793
+ }
1794
+ else if (type === "arraybuffer") {
1795
+ return temp instanceof ArrayBuffer ? temp.slice(0) : encode(temp);
1796
+ }
1797
+ else if (type === "blob") {
1798
+ return new BlobP([temp]);
1799
+ }
1800
+ else {
1801
+ return temp;
1802
+ }
1803
+ }
1804
+ const statusMessages = {
1805
+ 100: "Continue",
1806
+ 101: "Switching Protocols",
1807
+ 102: "Processing",
1808
+ 103: "Early Hints",
1809
+ 200: "OK",
1810
+ 201: "Created",
1811
+ 202: "Accepted",
1812
+ 203: "Non-Authoritative Information",
1813
+ 204: "No Content",
1814
+ 205: "Reset Content",
1815
+ 206: "Partial Content",
1816
+ 207: "Multi-Status",
1817
+ 208: "Already Reported",
1818
+ 226: "IM Used",
1819
+ 300: "Multiple Choices",
1820
+ 301: "Moved Permanently",
1821
+ 302: "Found",
1822
+ 303: "See Other",
1823
+ 304: "Not Modified",
1824
+ 307: "Temporary Redirect",
1825
+ 308: "Permanent Redirect",
1826
+ 400: "Bad Request",
1827
+ 401: "Unauthorized",
1828
+ 402: "Payment Required",
1829
+ 403: "Forbidden",
1830
+ 404: "Not Found",
1831
+ 405: "Method Not Allowed",
1832
+ 406: "Not Acceptable",
1833
+ 407: "Proxy Authentication Required",
1834
+ 408: "Request Timeout",
1835
+ 409: "Conflict",
1836
+ 410: "Gone",
1837
+ 411: "Length Required",
1838
+ 412: "Precondition Failed",
1839
+ 413: "Content Too Large",
1840
+ 414: "URI Too Long",
1841
+ 415: "Unsupported Media Type",
1842
+ 416: "Range Not Satisfiable",
1843
+ 417: "Expectation Failed",
1844
+ 418: "I'm a teapot",
1845
+ 421: "Misdirected Request",
1846
+ 422: "Unprocessable Entity",
1847
+ 423: "Locked",
1848
+ 424: "Failed Dependency",
1849
+ 425: "Too Early",
1850
+ 426: "Upgrade Required",
1851
+ 428: "Precondition Required",
1852
+ 429: "Too Many Requests",
1853
+ 431: "Request Header Fields Too Large",
1854
+ 451: "Unavailable For Legal Reasons",
1855
+ 500: "Internal Server Error",
1856
+ 501: "Not Implemented",
1857
+ 502: "Bad Gateway",
1858
+ 503: "Service Unavailable",
1859
+ 504: "Gateway Timeout",
1860
+ 505: "HTTP Version Not Supported",
1861
+ 506: "Variant Also Negotiates",
1862
+ 507: "Insufficient Storage",
1863
+ 508: "Loop Detected",
1864
+ 510: "Not Extended",
1865
+ 511: "Network Authentication Required"
1866
+ };
1867
+ function statusTextMap(val) {
1868
+ return statusMessages[val] || "unknown";
1869
+ }
1870
+ const XMLHttpRequestE = !mp ? g["XMLHttpRequest"] : XMLHttpRequestP;
1871
+
1872
+ const state = Symbol("BodyState");
1873
+ class BodyP {
1874
+ constructor() {
1875
+ if (new.target === BodyP) {
1876
+ throw new TypeError("Failed to construct 'Body': Illegal constructor");
1877
+ }
1878
+ this[state] = new BodyState();
1879
+ }
1880
+ [state];
1881
+ get body() {
1882
+ if (!this[state]._body) {
1883
+ return null;
1884
+ }
1885
+ throw new ReferenceError("ReadableStream is not defined");
1886
+ }
1887
+ get bodyUsed() { return this[state].bodyUsed; }
1888
+ ;
1889
+ arrayBuffer() {
1890
+ const kind = "arrayBuffer";
1891
+ return this[state].consumed(kind) || this[state].read(kind);
1892
+ }
1893
+ blob() {
1894
+ const kind = "blob";
1895
+ return this[state].consumed(kind) || this[state].read(kind);
1896
+ }
1897
+ bytes() {
1898
+ const kind = "bytes";
1899
+ return this[state].consumed(kind) || this[state].read(kind);
1900
+ }
1901
+ formData() {
1902
+ const kind = "formData";
1903
+ return this[state].consumed(kind) || this[state].read(kind);
1904
+ }
1905
+ json() {
1906
+ const kind = "json";
1907
+ return this[state].consumed(kind) || this[state].read(kind);
1908
+ }
1909
+ text() {
1910
+ const kind = "text";
1911
+ return this[state].consumed(kind) || this[state].read(kind);
1912
+ }
1913
+ toString() { return "[object Body]"; }
1914
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
1915
+ }
1916
+ defineStringTag(BodyP, "Body");
1917
+ class BodyState {
1918
+ bodyUsed = false;
1919
+ _name = "Body";
1920
+ _body = "";
1921
+ init(body, headers) {
1922
+ if (isObjectType("ReadableStream", body)) {
1923
+ throw new ReferenceError("ReadableStream is not defined");
1924
+ }
1925
+ this._body = convert(body, type => {
1926
+ if (headers && !headers.get("Content-Type")) {
1927
+ headers.set("Content-Type", type);
1928
+ }
1929
+ });
1930
+ }
1931
+ read(kind) {
1932
+ return new Promise((resolve, reject) => {
1933
+ try {
1934
+ if (kind === "arrayBuffer") {
1935
+ resolve(convertBack("arraybuffer", this._body));
1936
+ }
1937
+ else if (kind === "blob") {
1938
+ resolve(convertBack("blob", this._body));
1939
+ }
1940
+ else if (kind === "bytes") {
1941
+ let arrayBuffer = convertBack("arraybuffer", this._body);
1942
+ resolve(new Uint8Array(arrayBuffer));
1943
+ }
1944
+ else if (kind === "formData") {
1945
+ let text = convertBack("text", this._body);
1946
+ resolve(createFormData(text));
1947
+ }
1948
+ else if (kind === "json") {
1949
+ resolve(convertBack("json", this._body));
1950
+ }
1951
+ else {
1952
+ resolve(convertBack("text", this._body));
1953
+ }
1954
+ }
1955
+ catch (e) {
1956
+ reject(e);
1957
+ }
1958
+ });
1959
+ }
1960
+ consumed(kind) {
1961
+ if (!this._body)
1962
+ return;
1963
+ if (this.bodyUsed) {
1964
+ return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${this._name}': body stream already read`));
1965
+ }
1966
+ this.bodyUsed = true;
1967
+ }
1968
+ }
1969
+
1970
+ class HeadersP {
1971
+ constructor(init) {
1972
+ this[state$9] = new HeadersState();
1973
+ if (isObjectType("Headers", init)) {
1974
+ init.forEach((value, name) => {
1975
+ this.append(name, value);
1976
+ });
1977
+ }
1978
+ else if (Array.isArray(init)) {
1979
+ init.forEach(header => {
1980
+ if (!Array.isArray(header)) {
1981
+ throw new TypeError("Failed to construct 'Headers': The provided value cannot be converted to a sequence.");
1982
+ }
1983
+ if (header.length !== 2) {
1984
+ throw new TypeError("Failed to construct 'Headers': Invalid value");
1985
+ }
1986
+ this.append(header[0], header[1]);
1987
+ });
1988
+ }
1989
+ else if (init) {
1990
+ Object.entries(init).forEach(([name, value]) => {
1991
+ this.append(name, value);
1992
+ });
1993
+ }
1994
+ }
1995
+ [state$9];
1996
+ append(name, value) {
1997
+ let key = normalizeName(name, "append");
1998
+ value = normalizeValue(value);
1999
+ let oldValue = this[state$9]._map.get(key)?.[1];
2000
+ this[state$9]._map.set(key, ["" + name, oldValue ? `${oldValue}, ${value}` : value]);
2001
+ }
2002
+ delete(name) {
2003
+ let key = normalizeName(name, "delete");
2004
+ this[state$9]._map.delete(key);
2005
+ }
2006
+ get(name) {
2007
+ let key = normalizeName(name, "get");
2008
+ return this[state$9]._map.get(key)?.[1] ?? null;
2009
+ }
2010
+ getSetCookie() {
2011
+ let value = this.get("Set-Cookie");
2012
+ return value ? value.split(", ") : [];
2013
+ }
2014
+ has(name) {
2015
+ let key = normalizeName(name, "has");
2016
+ return this[state$9]._map.has(key);
2017
+ }
2018
+ set(name, value) {
2019
+ let key = normalizeName(name, "set");
2020
+ this[state$9]._map.set(key, ["" + name, normalizeValue(value)]);
2021
+ }
2022
+ forEach(callbackfn, thisArg) {
2023
+ Array.from(this.entries()).forEach(([name, value]) => {
2024
+ callbackfn.call(thisArg, value, name, this);
2025
+ });
2026
+ }
2027
+ entries() {
2028
+ return this[state$9]._map.values();
2029
+ }
2030
+ keys() {
2031
+ return Array.from(this.entries()).map(pair => pair[0]).values();
2032
+ }
2033
+ values() {
2034
+ return Array.from(this.entries()).map(pair => pair[1]).values();
2035
+ }
2036
+ [Symbol.iterator]() {
2037
+ return this.entries();
2038
+ }
2039
+ toString() { return "[object Headers]"; }
2040
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
2041
+ }
2042
+ defineStringTag(HeadersP, "Headers");
2043
+ class HeadersState {
2044
+ _map = new Map();
2045
+ }
2046
+ function normalizeName(name, kind = "") {
2047
+ if (typeof name !== "string") {
2048
+ name = String(name);
2049
+ }
2050
+ if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
2051
+ if (kind) {
2052
+ throw new TypeError(`Failed to execute '${kind}' on 'Headers': Invalid name`);
2053
+ }
2054
+ }
2055
+ return name.toLowerCase();
2056
+ }
2057
+ function normalizeValue(value) {
2058
+ if (typeof value !== "string") {
2059
+ value = String(value);
2060
+ }
2061
+ return value;
2062
+ }
2063
+ const HeadersE = g["Headers"] || HeadersP;
2064
+
2065
+ class RequestP extends BodyP {
2066
+ constructor(input, init) {
2067
+ super();
2068
+ this[state$9] = new RequestState();
2069
+ this[state]._name = "Request";
2070
+ let options = init ?? {};
2071
+ let body = options.body;
2072
+ if (isPolyfillType("Request", input)) {
2073
+ if (input.bodyUsed) {
2074
+ throw new TypeError("Failed to construct 'Request': Cannot construct a Request with a Request object that has already been used.");
2075
+ }
2076
+ this[state$9].credentials = input.credentials;
2077
+ if (!options.headers) {
2078
+ this[state$9].headers = new HeadersP(input.headers);
2079
+ }
2080
+ this[state$9].method = input.method;
2081
+ this[state$9].mode = input.mode;
2082
+ this[state$9].signal = input.signal;
2083
+ this[state$9].url = input.url;
2084
+ let _input = input;
2085
+ if (!body && _input[state]._body !== null) {
2086
+ body = _input[state]._body;
2087
+ _input[state].bodyUsed = true;
2088
+ }
2089
+ }
2090
+ else {
2091
+ this[state$9].url = String(input);
2092
+ }
2093
+ if (options.credentials) {
2094
+ this[state$9].credentials = options.credentials;
2095
+ }
2096
+ if (options.headers) {
2097
+ this[state$9].headers = new HeadersP(options.headers);
2098
+ }
2099
+ if (options.method) {
2100
+ this[state$9].method = normalizeMethod(options.method);
2101
+ }
2102
+ if (options.mode) {
2103
+ this[state$9].mode = options.mode;
2104
+ }
2105
+ if (options.signal) {
2106
+ this[state$9].signal = options.signal;
2107
+ }
2108
+ if ((this.method === "GET" || this.method === "HEAD") && body) {
2109
+ throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
2110
+ }
2111
+ this[state].init(body, this.headers);
2112
+ if (this.method === "GET" || this.method === "HEAD") {
2113
+ if (options.cache === "no-store" || options.cache === "no-cache") {
2114
+ // Search for a '_' parameter in the query string
2115
+ let reParamSearch = /([?&])_=[^&]*/;
2116
+ if (reParamSearch.test(this.url)) {
2117
+ // If it already exists then set the value with the current time
2118
+ this[state$9].url = this.url.replace(reParamSearch, "$1_=" + (new Date()).getTime());
2119
+ }
2120
+ else {
2121
+ // Otherwise add a new '_' parameter to the end with the current time
2122
+ let reQueryString = /\?/;
2123
+ this[state$9].url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (new Date()).getTime();
2124
+ }
2125
+ }
2126
+ }
2127
+ }
2128
+ [state$9];
2129
+ get cache() { return this[state$9].cache; }
2130
+ get credentials() { return this[state$9].credentials; }
2131
+ get destination() { return this[state$9].destination; }
2132
+ get headers() { return this[state$9].headers; }
2133
+ get integrity() { return this[state$9].integrity; }
2134
+ get keepalive() { return this[state$9].keepalive; }
2135
+ get method() { return this[state$9].method; }
2136
+ get mode() { return this[state$9].mode; }
2137
+ get redirect() { return this[state$9].redirect; }
2138
+ get referrer() { return this[state$9].referrer; }
2139
+ get referrerPolicy() { return this[state$9].referrerPolicy; }
2140
+ get signal() { return this[state$9].signal; }
2141
+ get url() { return this[state$9].url; }
2142
+ clone() {
2143
+ return new RequestP(this, { body: this[state]._body ?? null });
2144
+ }
2145
+ toString() { return "[object Request]"; }
2146
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request"] }; }
2147
+ }
2148
+ defineStringTag(RequestP, "Request");
2149
+ class RequestState {
2150
+ cache = "default";
2151
+ credentials = "same-origin";
2152
+ destination = "";
2153
+ headers = new HeadersP();
2154
+ integrity = "";
2155
+ keepalive = false;
2156
+ method = "GET";
2157
+ mode = "cors";
2158
+ redirect = "follow";
2159
+ referrer = "about:client";
2160
+ referrerPolicy = "";
2161
+ signal = (new AbortControllerP()).signal;
2162
+ url = "";
2163
+ }
2164
+ const RequestE = g["Request"] || RequestP;
2165
+
2166
+ class ResponseP extends BodyP {
2167
+ constructor(body, init) {
2168
+ super();
2169
+ this[state$9] = new ResponseState();
2170
+ this[state]._name = "Response";
2171
+ let options = init ?? {};
2172
+ let status = options.status === undefined ? 200 : options.status;
2173
+ if (status < 200 || status > 500) {
2174
+ throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
2175
+ }
2176
+ if (options.headers) {
2177
+ this[state$9].headers = new HeadersP(options.headers);
2178
+ }
2179
+ this[state$9].ok = this.status >= 200 && this.status < 300;
2180
+ this[state$9].status = status;
2181
+ this[state$9].statusText = options.statusText === undefined ? "" : "" + options.statusText;
2182
+ this[state].init(body, this.headers);
2183
+ }
2184
+ [state$9];
2185
+ get headers() { return this[state$9].headers; }
2186
+ get ok() { return this[state$9].ok; }
2187
+ get redirected() { return this[state$9].redirected; }
2188
+ get status() { return this[state$9].status; }
2189
+ get statusText() { return this[state$9].statusText; }
2190
+ get type() { return this[state$9].type; }
2191
+ get url() { return this[state$9].url; }
2192
+ clone() {
2193
+ const response = new ResponseP(this[state]._body, {
2194
+ headers: new HeadersP(this.headers),
2195
+ status: this.status,
2196
+ statusText: this.statusText,
2197
+ });
2198
+ response[state$9].url = this.url;
2199
+ return response;
2200
+ }
2201
+ static json(data, init) {
2202
+ return new Response(JSON.stringify(data), init);
2203
+ }
2204
+ static error() {
2205
+ const response = new ResponseP(null, { status: 200, statusText: "" });
2206
+ response[state$9].ok = false;
2207
+ response[state$9].status = 0;
2208
+ response[state$9].type = "error";
2209
+ return response;
2210
+ }
2211
+ static redirect(url, status = 301) {
2212
+ if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
2213
+ throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
2214
+ }
2215
+ return new Response(null, { status, headers: { location: String(url) } });
2216
+ }
2217
+ toString() { return "[object Response]"; }
2218
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response"] }; }
2219
+ }
2220
+ defineStringTag(ResponseP, "Response");
2221
+ class ResponseState {
2222
+ headers = new HeadersP();
2223
+ ok = true;
2224
+ redirected = false;
2225
+ status = 200;
2226
+ statusText = "";
2227
+ type = "default";
2228
+ url = "";
2229
+ }
2230
+ const ResponseE = g["Response"] || ResponseP;
2231
+
2232
+ function fetchP(input, init) {
2233
+ if (new.target === fetchP) {
2234
+ throw new TypeError("fetch is not a constructor");
2235
+ }
2236
+ return new Promise(function (resolve, reject) {
2237
+ let request = new RequestP(input, init);
2238
+ if (request.signal && request.signal.aborted) {
2239
+ return reject(request.signal.reason);
2240
+ }
2241
+ let xhr = new XMLHttpRequestP();
2242
+ xhr.onload = function () {
2243
+ let options = {
2244
+ headers: new HeadersP(xhr[state$1]._resHeaders || undefined),
2245
+ status: xhr.status,
2246
+ statusText: xhr.statusText,
2247
+ };
2248
+ setTimeout(() => {
2249
+ const response = new ResponseP(xhr.response, options);
2250
+ response[state$9].url = xhr.responseURL;
2251
+ resolve(response);
2252
+ });
2253
+ };
2254
+ xhr.onerror = function () {
2255
+ setTimeout(function () {
2256
+ reject(new TypeError("Failed to fetch"));
2257
+ });
2258
+ };
2259
+ xhr.ontimeout = function () {
2260
+ setTimeout(function () {
2261
+ reject(new MPException("request:fail timeout", "TimeoutError"));
2262
+ });
2263
+ };
2264
+ xhr.onabort = function () {
2265
+ setTimeout(function () {
2266
+ reject(new MPException("request:fail abort", "AbortError"));
2267
+ });
2268
+ };
2269
+ xhr.open(request.method, request.url);
2270
+ if (request.credentials === "include") {
2271
+ xhr.withCredentials = true;
2272
+ }
2273
+ else if (request.credentials === "omit") {
2274
+ xhr.withCredentials = false;
2275
+ }
2276
+ if (init && isObjectHeaders(init.headers)) {
2277
+ let headers = init.headers;
2278
+ let names = [];
2279
+ Object.entries(headers).forEach(([name, value]) => {
2280
+ names.push(normalizeName(name));
2281
+ xhr.setRequestHeader(name, normalizeValue(value));
2282
+ });
2283
+ request.headers.forEach(function (value, name) {
2284
+ if (names.indexOf(normalizeName(name)) === -1) {
2285
+ xhr.setRequestHeader(name, value);
2286
+ }
2287
+ });
2288
+ }
2289
+ else {
2290
+ request.headers.forEach(function (value, name) {
2291
+ xhr.setRequestHeader(name, value);
2292
+ });
2293
+ }
2294
+ if (request.signal) {
2295
+ const abortXHR = () => { xhr.abort(); };
2296
+ request.signal.addEventListener("abort", abortXHR);
2297
+ xhr.onreadystatechange = function () {
2298
+ // DONE (success or failure)
2299
+ if (xhr.readyState === 4) {
2300
+ request.signal.removeEventListener("abort", abortXHR);
2301
+ }
2302
+ };
2303
+ }
2304
+ xhr.send(request[state]._body);
2305
+ });
2306
+ }
2307
+ function isObjectHeaders(val) {
2308
+ return typeof val === "object" && !isObjectType("Headers", val);
2309
+ }
2310
+ const fetchE = !mp ? g["fetch"] : fetchP;
2311
+
2312
+ export { AbortControllerE as AbortController, AbortControllerP, AbortSignalE as AbortSignal, AbortSignalP, BlobE as Blob, BlobP, CustomEventE as CustomEvent, CustomEventP, EventE as Event, EventP, EventTargetE as EventTarget, EventTargetP, FileE as File, FileP, FileReaderE as FileReader, FileReaderP, FormDataE as FormData, FormDataP, HeadersE as Headers, HeadersP, ProgressEventE as ProgressEvent, ProgressEventP, RequestE as Request, RequestP, ResponseE as Response, ResponseP, TextDecoderE as TextDecoder, TextDecoderP, TextEncoderE as TextEncoder, TextEncoderP, URLSearchParamsE as URLSearchParams, URLSearchParamsP, XMLHttpRequestE as XMLHttpRequest, XMLHttpRequestP, fetchE as fetch, fetchP };