mphttpx 1.0.5 → 1.0.7

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.
package/dist/index.esm.js CHANGED
@@ -1,13 +1,24 @@
1
+ /** @internal */
1
2
  const polyfill = Symbol("isPolyfill");
2
3
  /* eslint-disable no-prototype-builtins */
3
- const g = (typeof globalThis !== "undefined" && globalThis) ||
4
+ /** @internal */ const g = (typeof globalThis !== "undefined" && globalThis) ||
4
5
  (typeof self !== "undefined" && self) ||
5
6
  // @ts-ignore eslint-disable-next-line no-undef
6
7
  (typeof global !== "undefined" && global) ||
7
8
  {};
9
+ /** @internal */
10
+ class MPException extends Error {
11
+ constructor(message, name) {
12
+ super();
13
+ this.message = message !== null && message !== void 0 ? message : this.message;
14
+ this.name = name !== null && name !== void 0 ? name : this.name;
15
+ }
16
+ }
17
+ /** @internal */
8
18
  function isObjectType(name, value) {
9
19
  return Object.prototype.toString.call(value) === `[object ${name}]`;
10
20
  }
21
+ /** @internal */
11
22
  function isPolyfillType(name, value) {
12
23
  return !!value
13
24
  && typeof value === "object"
@@ -20,22 +31,18 @@ function isPolyfillType(name, value) {
20
31
  && Array.isArray(value.isPolyfill.hierarchy)
21
32
  && value.isPolyfill.hierarchy.indexOf(name) > -1;
22
33
  }
23
- class MPException extends Error {
24
- constructor(message, name) {
25
- super();
26
- this.message = message !== null && message !== void 0 ? message : this.message;
27
- this.name = name !== null && name !== void 0 ? name : this.name;
28
- }
29
- }
30
- function defineStringTag(targetFunc, stringTag) {
34
+ /** @internal */
35
+ function dfStringTag(targetFunc, stringTag) {
31
36
  Object.defineProperty(targetFunc.prototype, Symbol.toStringTag, {
32
37
  configurable: true,
33
38
  value: stringTag,
34
39
  });
35
40
  }
41
+ /** @internal */
36
42
  function objectValues(obj) {
37
43
  return Object.keys(obj).map(key => obj[key]);
38
44
  }
45
+ /** @internal */
39
46
  function objectEntries(obj) {
40
47
  return Object.keys(obj).map(key => [key, obj[key]]);
41
48
  }
@@ -52,7 +59,7 @@ class TextEncoderP {
52
59
  toString() { return "[object TextEncoder]"; }
53
60
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextEncoder"] }; }
54
61
  }
55
- defineStringTag(TextEncoderP, "TextEncoder");
62
+ dfStringTag(TextEncoderP, "TextEncoder");
56
63
  function encodeText(input, destination) {
57
64
  const HAS_DESTINATION = typeof destination !== "undefined";
58
65
  let pos = 0;
@@ -283,7 +290,7 @@ class TextDecoderP {
283
290
  toString() { return "[object TextDecoder]"; }
284
291
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["TextDecoder"] }; }
285
292
  }
286
- defineStringTag(TextDecoderP, "TextDecoder");
293
+ dfStringTag(TextDecoderP, "TextDecoder");
287
294
  /** @internal */ const _bomSeen = Symbol();
288
295
  /** @internal */ const _partial = Symbol();
289
296
  /** @internal */
@@ -302,38 +309,174 @@ function getBytesPerSequence(byte) {
302
309
  }
303
310
  const TextDecoderE = g["TextDecoder"] || TextDecoderP;
304
311
 
305
- var _a$9, _b$2, _c$1, _d$1, _e$1, _f$1;
306
312
  /** @internal */
307
- const state$g = Symbol( /* "EventState" */);
313
+ const state$g = Symbol( /* "BlobState" */);
314
+ class BlobP {
315
+ constructor(blobParts = [], options) {
316
+ if (!Array.isArray(blobParts)) {
317
+ throw new TypeError("First argument to Blob constructor must be an Array.");
318
+ }
319
+ let encoder = null;
320
+ let chunks = blobParts.reduce((chunks, part) => {
321
+ if (isPolyfillType("Blob", part)) {
322
+ chunks.push(part[state$g][_buffer]);
323
+ }
324
+ else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
325
+ chunks.push(BufferSource_toUint8Array(part));
326
+ }
327
+ else {
328
+ if (!encoder) {
329
+ encoder = new TextEncoderP();
330
+ }
331
+ chunks.push(encoder.encode(String(part)));
332
+ }
333
+ return chunks;
334
+ }, []);
335
+ this[state$g] = new BlobState(concat(chunks));
336
+ const that = this[state$g];
337
+ that.size = that[_buffer].length;
338
+ let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
339
+ that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
340
+ }
341
+ get size() { return this[state$g].size; }
342
+ get type() { return this[state$g].type; }
343
+ arrayBuffer() {
344
+ return Promise.resolve(clone(this[state$g][_buffer].buffer).buffer);
345
+ }
346
+ bytes() {
347
+ return Promise.resolve(clone(this[state$g][_buffer].buffer));
348
+ }
349
+ slice(start, end, contentType) {
350
+ let sliced = this[state$g][_buffer].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$g][_buffer].length);
351
+ return new BlobP([sliced], { type: contentType !== null && contentType !== void 0 ? contentType : "" });
352
+ }
353
+ stream() {
354
+ throw new ReferenceError("ReadableStream is not defined");
355
+ }
356
+ text() {
357
+ let decoder = new TextDecoderP();
358
+ return Promise.resolve(decoder.decode(this[state$g][_buffer]));
359
+ }
360
+ toString() { return "[object Blob]"; }
361
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
362
+ }
363
+ dfStringTag(BlobP, "Blob");
364
+ /** @internal */
365
+ const _buffer = Symbol();
366
+ /** @internal */
367
+ class BlobState {
368
+ constructor(buffer) {
369
+ this.size = 0;
370
+ this.type = "";
371
+ this[_buffer] = buffer;
372
+ }
373
+ }
374
+ /** @internal */
375
+ function Blob_toUint8Array(blob) {
376
+ return blob[state$g][_buffer];
377
+ }
378
+ function BufferSource_toUint8Array(buf) {
379
+ return buf instanceof ArrayBuffer
380
+ ? new Uint8Array(buf)
381
+ : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
382
+ }
383
+ function clone(buf) {
384
+ let sourceArray = BufferSource_toUint8Array(buf);
385
+ let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
386
+ cloneArray.set(sourceArray);
387
+ return cloneArray;
388
+ }
389
+ function concat(chunks) {
390
+ let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
391
+ let result = new Uint8Array(totalByteLength);
392
+ chunks.reduce((offset, chunk) => {
393
+ result.set(chunk, offset);
394
+ return offset + chunk.byteLength;
395
+ }, 0);
396
+ return result;
397
+ }
398
+ /** @internal */
399
+ function Uint8Array_toBase64(input) {
400
+ let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
401
+ let output = [];
402
+ for (var i = 0; i < input.length; i += 3) {
403
+ let byte1 = input[i];
404
+ let haveByte2 = i + 1 < input.length;
405
+ let byte2 = haveByte2 ? input[i + 1] : 0;
406
+ let haveByte3 = i + 2 < input.length;
407
+ let byte3 = haveByte3 ? input[i + 2] : 0;
408
+ let outByte1 = byte1 >> 2;
409
+ let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
410
+ let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
411
+ let outByte4 = byte3 & 0x3F;
412
+ if (!haveByte3) {
413
+ outByte4 = 64;
414
+ if (!haveByte2) {
415
+ outByte3 = 64;
416
+ }
417
+ }
418
+ output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
419
+ }
420
+ return output.join("");
421
+ }
422
+ const BlobE = g["Blob"] || BlobP;
423
+
424
+ /** @internal */
425
+ const state$f = Symbol( /* "FileState" */);
426
+ class FileP extends BlobP {
427
+ constructor(fileBits, fileName, options) {
428
+ super(fileBits, options);
429
+ this[state$f] = new FileState();
430
+ this[state$f].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date());
431
+ this[state$f].name = fileName.replace(/\//g, ":");
432
+ }
433
+ get lastModified() { return this[state$f].lastModified; }
434
+ get name() { return this[state$f].name; }
435
+ get webkitRelativePath() { return ""; }
436
+ toString() { return "[object File]"; }
437
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
438
+ }
439
+ dfStringTag(FileP, "File");
440
+ /** @internal */
441
+ class FileState {
442
+ constructor() {
443
+ this.lastModified = 0;
444
+ this.name = "";
445
+ }
446
+ }
447
+ const FileE = g["Blob"] ? g["File"] : FileP;
448
+
449
+ var _a$9, _b$2, _c$1, _d$1, _e$1;
450
+ /** @internal */ const state$e = Symbol( /* "EventState" */);
308
451
  class EventP {
309
452
  constructor(type, eventInitDict) {
310
- this[state$g] = new EventState();
311
- const that = this[state$g];
453
+ this[state$e] = new EventState();
454
+ const that = this[state$e];
312
455
  that.type = String(type);
313
456
  that.bubbles = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.bubbles);
314
457
  that.cancelable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.cancelable);
315
458
  that.composed = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.composed);
316
459
  Object.defineProperty(this, "isTrusted", {
317
460
  enumerable: true,
318
- get: (function isTrusted() { return this[state$g][_isTrusted]; }).bind(this),
461
+ get: (function isTrusted() { return this[state$e][_isTrusted]; }).bind(this),
319
462
  });
320
463
  }
321
- get type() { return this[state$g].type; }
322
- get bubbles() { return this[state$g].bubbles; }
323
- get cancelable() { return this[state$g].cancelable; }
324
- get composed() { return this[state$g].composed; }
325
- get target() { return this[state$g].target; }
326
- get currentTarget() { return this[state$g].currentTarget; }
327
- get eventPhase() { return this[state$g].eventPhase; }
328
- get srcElement() { return this[state$g].target; }
329
- get cancelBubble() { return this[state$g].cancelBubble; }
330
- set cancelBubble(value) { this[state$g].cancelBubble = value; }
331
- get defaultPrevented() { return this[state$g].defaultPrevented; }
332
- get returnValue() { return this[state$g].returnValue; }
464
+ get type() { return this[state$e].type; }
465
+ get bubbles() { return this[state$e].bubbles; }
466
+ get cancelable() { return this[state$e].cancelable; }
467
+ get composed() { return this[state$e].composed; }
468
+ get target() { return this[state$e].target; }
469
+ get currentTarget() { return this[state$e].currentTarget; }
470
+ get eventPhase() { return this[state$e].eventPhase; }
471
+ get srcElement() { return this[state$e].target; }
472
+ get cancelBubble() { return this[state$e].cancelBubble; }
473
+ set cancelBubble(value) { this[state$e].cancelBubble = value; }
474
+ get defaultPrevented() { return this[state$e].defaultPrevented; }
475
+ get returnValue() { return this[state$e].returnValue; }
333
476
  set returnValue(value) { if (!value) {
334
477
  this.preventDefault();
335
478
  } }
336
- get timeStamp() { return this[state$g].timeStamp; }
479
+ get timeStamp() { return this[state$e].timeStamp; }
337
480
  composedPath() {
338
481
  let path = !!this.target ? [this.target] : [];
339
482
  if (!!this.currentTarget && this.currentTarget !== this.target)
@@ -341,7 +484,7 @@ class EventP {
341
484
  return path;
342
485
  }
343
486
  initEvent(type, bubbles, cancelable) {
344
- const that = this[state$g];
487
+ const that = this[state$e];
345
488
  if (that[_dispatched])
346
489
  return;
347
490
  that.type = String(type);
@@ -349,7 +492,7 @@ class EventP {
349
492
  that.cancelable = !!cancelable;
350
493
  }
351
494
  preventDefault() {
352
- const that = this[state$g];
495
+ const that = this[state$e];
353
496
  if (that[_passive]) {
354
497
  console.warn(`Ignoring 'preventDefault()' call on event of type '${this.type}' from a listener registered as 'passive'.`);
355
498
  return;
@@ -361,7 +504,7 @@ class EventP {
361
504
  }
362
505
  }
363
506
  stopImmediatePropagation() {
364
- this[state$g][_stopImmediatePropagationCalled] = true;
507
+ this[state$e][_stopImmediatePropagationCalled] = true;
365
508
  this.cancelBubble = true;
366
509
  }
367
510
  stopPropagation() {
@@ -378,13 +521,13 @@ const properties$2 = {
378
521
  };
379
522
  Object.defineProperties(EventP, properties$2);
380
523
  Object.defineProperties(EventP.prototype, properties$2);
381
- defineStringTag(EventP, "Event");
382
- /** @internal */ const _TimeStamp = Symbol();
383
- const _isTrusted = Symbol();
384
- const _passive = Symbol();
385
- const _dispatched = Symbol();
386
- const _preventDefaultCalled = Symbol();
387
- const _stopImmediatePropagationCalled = Symbol();
524
+ dfStringTag(EventP, "Event");
525
+ /** @internal */ const _timeStamp = (new Date()).getTime();
526
+ /** @internal */ const _isTrusted = Symbol();
527
+ /** @internal */ const _passive = Symbol();
528
+ /** @internal */ const _dispatched = Symbol();
529
+ /** @internal */ const _preventDefaultCalled = Symbol();
530
+ /** @internal */ const _stopImmediatePropagationCalled = Symbol();
388
531
  /** @internal */
389
532
  class EventState {
390
533
  constructor() {
@@ -398,33 +541,81 @@ class EventState {
398
541
  this.cancelBubble = false;
399
542
  this.defaultPrevented = false;
400
543
  this.returnValue = true;
401
- this.timeStamp = (new Date()).getTime() - EventState[_TimeStamp];
544
+ this.timeStamp = (new Date()).getTime() - _timeStamp;
545
+ this[_a$9] = false;
402
546
  this[_b$2] = false;
403
547
  this[_c$1] = false;
404
548
  this[_d$1] = false;
405
549
  this[_e$1] = false;
406
- this[_f$1] = false;
407
550
  }
408
551
  }
409
- _a$9 = _TimeStamp, _b$2 = _isTrusted, _c$1 = _passive, _d$1 = _dispatched, _e$1 = _preventDefaultCalled, _f$1 = _stopImmediatePropagationCalled;
410
- EventState[_a$9] = (new Date()).getTime();
552
+ _a$9 = _isTrusted, _b$2 = _passive, _c$1 = _dispatched, _d$1 = _preventDefaultCalled, _e$1 = _stopImmediatePropagationCalled;
553
+ /** @internal */
554
+ function Event_setTrusted(event, isTrusted) {
555
+ Object.defineProperty(event[state$e], _isTrusted, {
556
+ value: isTrusted,
557
+ writable: true,
558
+ enumerable: true,
559
+ configurable: true,
560
+ });
561
+ }
562
+ const passive$1 = 0;
563
+ const dispatched$2 = 1;
564
+ const preventDefaultCalled$1 = 2;
565
+ const stopImmediatePropagationCalled$1 = 3;
566
+ /** @internal */
567
+ function Event_getEtField(event, field) {
568
+ const s = event[state$e];
569
+ switch (field) {
570
+ case passive$1:
571
+ return s[_passive];
572
+ case dispatched$2:
573
+ return s[_dispatched];
574
+ case preventDefaultCalled$1:
575
+ return s[_preventDefaultCalled];
576
+ case stopImmediatePropagationCalled$1:
577
+ return s[_stopImmediatePropagationCalled];
578
+ }
579
+ }
580
+ /** @internal */
581
+ function Event_setEtField(event, field, value) {
582
+ const s = event[state$e];
583
+ switch (field) {
584
+ case passive$1:
585
+ s[_passive] = value;
586
+ break;
587
+ case dispatched$2:
588
+ s[_dispatched] = value;
589
+ break;
590
+ case preventDefaultCalled$1:
591
+ s[_preventDefaultCalled] = value;
592
+ break;
593
+ case stopImmediatePropagationCalled$1:
594
+ s[_stopImmediatePropagationCalled] = value;
595
+ break;
596
+ }
597
+ }
598
+ /** @internal */
411
599
  function createInnerEvent(target, type, eventInitDict, isTrusted = true) {
412
600
  let event = new EventP(type, eventInitDict);
413
- event[state$g].target = target;
414
- event[state$g][_isTrusted] = isTrusted;
601
+ event[state$e].target = target;
602
+ event[state$e][_isTrusted] = isTrusted;
415
603
  return event;
416
604
  }
417
605
  const EventE = g["EventTarget"] ? g["Event"] : EventP;
418
606
 
419
607
  var _a$8;
420
- /** @internal */
421
- const state$f = Symbol( /* "EventTargetState" */);
608
+ const passive = 0;
609
+ const dispatched$1 = 1;
610
+ const preventDefaultCalled = 2;
611
+ const stopImmediatePropagationCalled = 3;
612
+ /** @internal */ const state$d = Symbol( /* "EventTargetState" */);
422
613
  class EventTargetP {
423
614
  constructor() {
424
- this[state$f] = new EventTargetState(this);
615
+ this[state$d] = new EventTargetState(this);
425
616
  }
426
617
  addEventListener(type, callback, options) {
427
- const that = this[state$f];
618
+ const that = this[state$d];
428
619
  const executor = new Executor(type, callback);
429
620
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
430
621
  if (!that[_executors].some(x => x.equals(executor))) {
@@ -434,7 +625,7 @@ class EventTargetP {
434
625
  executor.options.passive = !!passive;
435
626
  if (signal) {
436
627
  executor.options.signal = signal;
437
- reply.call(that, signal, executor);
628
+ reply(this, signal, executor);
438
629
  }
439
630
  }
440
631
  that[_executors].push(executor);
@@ -449,12 +640,12 @@ class EventTargetP {
449
640
  if (!(event instanceof EventP)) {
450
641
  throw new TypeError("EventTarget.dispatchEvent: Argument 1 does not implement interface Event.");
451
642
  }
452
- event[state$g].target = this;
453
- Object.defineProperty(event[state$g], _isTrusted, { value: false, configurable: true, enumerable: true, writable: true });
454
- return fire.call(this[state$f], event);
643
+ Event_setTrusted(event, false);
644
+ event[state$e].target = this;
645
+ return EventTarget_fire(this, event);
455
646
  }
456
647
  removeEventListener(type, callback, options) {
457
- const that = this[state$f];
648
+ const that = this[state$d];
458
649
  const executor = new Executor(type, callback);
459
650
  executor.options.capture = typeof options === "boolean" ? options : !!(options === null || options === void 0 ? void 0 : options.capture);
460
651
  if (that[_executors].some(x => x.equals(executor))) {
@@ -464,7 +655,7 @@ class EventTargetP {
464
655
  toString() { return "[object EventTarget]"; }
465
656
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["EventTarget"] }; }
466
657
  }
467
- defineStringTag(EventTargetP, "EventTarget");
658
+ dfStringTag(EventTargetP, "EventTarget");
468
659
  /** @internal */
469
660
  const _executors = Symbol();
470
661
  /** @internal */
@@ -475,35 +666,37 @@ class EventTargetState {
475
666
  }
476
667
  }
477
668
  _a$8 = _executors;
478
- function fire(event) {
479
- const s = event[state$g];
669
+ /** @internal */
670
+ function EventTarget_fire(target, event) {
671
+ const that = target[state$d];
672
+ const s = event[state$e];
480
673
  if (!event.target)
481
- s.target = this.target;
482
- s.currentTarget = this.target;
674
+ s.target = target;
675
+ s.currentTarget = target;
483
676
  s.eventPhase = EventP.AT_TARGET;
484
- s[_dispatched] = true;
677
+ Event_setEtField(event, dispatched$1, true);
485
678
  let onceIndexes = [];
486
- for (let i = 0; i < this[_executors].length; ++i) {
487
- let executor = this[_executors][i];
679
+ for (let i = 0; i < that[_executors].length; ++i) {
680
+ let executor = that[_executors][i];
488
681
  if (executor.type !== event.type)
489
682
  continue;
490
- s[_passive] = !!executor.options.passive;
683
+ Event_setEtField(event, passive, !!executor.options.passive);
491
684
  if (executor.options.once)
492
685
  onceIndexes.push(i);
493
686
  let { callback: cb } = executor;
494
687
  try {
495
688
  if (typeof cb === "function")
496
- cb.call(this.target, event);
689
+ cb.call(target, event);
497
690
  }
498
691
  catch (e) {
499
692
  console.error(e);
500
693
  }
501
- s[_passive] = false;
502
- if (s[_stopImmediatePropagationCalled])
694
+ Event_setEtField(event, passive, false);
695
+ if (Event_getEtField(event, stopImmediatePropagationCalled))
503
696
  break;
504
697
  }
505
698
  if (onceIndexes.length > 0) {
506
- this[_executors] = this[_executors].reduce((acc, cur, index) => {
699
+ that[_executors] = that[_executors].reduce((acc, cur, index) => {
507
700
  if (onceIndexes.indexOf(index) === -1)
508
701
  acc.push(cur);
509
702
  return acc;
@@ -511,19 +704,24 @@ function fire(event) {
511
704
  }
512
705
  s.currentTarget = null;
513
706
  s.eventPhase = EventP.NONE;
514
- s[_dispatched] = false;
515
- return !(event.cancelable && s[_preventDefaultCalled]);
707
+ Event_setEtField(event, dispatched$1, false);
708
+ return !(event.cancelable && Event_getEtField(event, preventDefaultCalled));
709
+ }
710
+ /** @internal */
711
+ function EventTarget_count(target) {
712
+ return target[state$d][_executors].length;
516
713
  }
517
- function reply(signal, executor) {
714
+ function reply(target, signal, executor) {
715
+ const s = target[state$d];
518
716
  const onAbort = () => {
519
- this[_executors] = this[_executors].filter(x => !x.equals(executor));
717
+ s[_executors] = s[_executors].filter(x => !x.equals(executor));
520
718
  signal.removeEventListener("abort", onAbort);
521
719
  };
522
720
  try {
523
721
  signal.addEventListener("abort", onAbort);
524
722
  }
525
723
  catch (e) {
526
- console.error(e);
724
+ console.warn(e);
527
725
  }
528
726
  }
529
727
  /** @internal */
@@ -552,64 +750,41 @@ function extract(cb) {
552
750
  function isEventListenerObject(cb) {
553
751
  return !!cb && "handleEvent" in cb && typeof cb.handleEvent === "function";
554
752
  }
555
- function attachFn(type, cb, listener) {
753
+ /** @internal */
754
+ function attachFn(target, type, cb, listener) {
556
755
  if (typeof cb === "function") {
557
- this.addEventListener(type, listener);
756
+ target.addEventListener(type, listener);
558
757
  }
559
758
  else {
560
- this.removeEventListener(type, listener);
759
+ target.removeEventListener(type, listener);
561
760
  }
562
761
  }
563
- function executeFn(cb, ev) {
762
+ /** @internal */
763
+ function executeFn(target, cb, ev) {
564
764
  if (typeof cb === "function")
565
- cb.call(this, ev);
765
+ cb.call(target, ev);
566
766
  }
567
767
  const EventTargetE = g["EventTarget"] || EventTargetP;
568
768
 
569
769
  /** @internal */
570
- const state$e = Symbol( /* "CustomEventState" */);
571
- class CustomEventP extends EventP {
572
- constructor(type, eventInitDict) {
573
- var _a;
574
- super(type, eventInitDict);
575
- this[state$e] = new CustomEventState();
576
- this[state$e].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
577
- }
578
- get detail() { return this[state$e].detail; }
579
- initCustomEvent(type, bubbles, cancelable, detail) {
580
- if (this[state$g][_dispatched])
581
- return;
582
- this.initEvent(type, bubbles, cancelable);
583
- this[state$e].detail = detail !== null && detail !== void 0 ? detail : null;
584
- }
585
- toString() { return "[object CustomEvent]"; }
586
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
587
- }
588
- defineStringTag(CustomEventP, "CustomEvent");
589
- /** @internal */
590
- class CustomEventState {
591
- }
592
- const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
593
-
594
- /** @internal */
595
- const state$d = Symbol( /* "ProgressEventState" */);
770
+ const state$c = Symbol( /* "ProgressEventState" */);
596
771
  class ProgressEventP extends EventP {
597
772
  constructor(type, eventInitDict) {
598
773
  var _a, _b;
599
774
  super(type, eventInitDict);
600
- this[state$d] = new ProgressEventState();
601
- const that = this[state$d];
775
+ this[state$c] = new ProgressEventState();
776
+ const that = this[state$c];
602
777
  that.lengthComputable = !!(eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.lengthComputable);
603
778
  that.loaded = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.loaded) !== null && _a !== void 0 ? _a : 0;
604
779
  that.total = (_b = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.total) !== null && _b !== void 0 ? _b : 0;
605
780
  }
606
- get lengthComputable() { return getValue(this[state$d].lengthComputable); }
607
- get loaded() { return getValue(this[state$d].loaded); }
608
- get total() { return getValue(this[state$d].total); }
781
+ get lengthComputable() { return getValue(this[state$c].lengthComputable); }
782
+ get loaded() { return getValue(this[state$c].loaded); }
783
+ get total() { return getValue(this[state$c].total); }
609
784
  toString() { return "[object ProgressEvent]"; }
610
785
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["ProgressEvent", "Event"] }; }
611
786
  }
612
- defineStringTag(ProgressEventP, "ProgressEvent");
787
+ dfStringTag(ProgressEventP, "ProgressEvent");
613
788
  /** @internal */
614
789
  class ProgressEventState {
615
790
  constructor() {
@@ -623,234 +798,97 @@ function getValue(val) {
623
798
  }
624
799
  function createInnerProgressEvent(target, type, { lengthComputable = false, loaded = 0, total = 0, } = {}) {
625
800
  let event = new ProgressEventP(type);
626
- event[state$d].lengthComputable = lengthComputable;
627
- event[state$d].loaded = loaded;
628
- event[state$d].total = total;
629
- event[state$g].target = target;
630
- event[state$g][_isTrusted] = true;
801
+ event[state$c].lengthComputable = lengthComputable;
802
+ event[state$c].loaded = loaded;
803
+ event[state$c].total = total;
804
+ event[state$e].target = target;
805
+ Event_setTrusted(event, true);
631
806
  return event;
632
807
  }
808
+ /** @internal */
633
809
  function emitProcessEvent(target, type, loaded = 0, total = 0) {
634
810
  let event = createInnerProgressEvent(target, type, {
635
811
  lengthComputable: () => { return getValue(total) > 0; },
636
812
  loaded,
637
813
  total,
638
814
  });
639
- fire.call(target[state$f], event);
815
+ EventTarget_fire(target, event);
640
816
  }
641
817
  const ProgressEventE = g["EventTarget"] ? g["ProgressEvent"] : ProgressEventP;
642
818
 
819
+ var _a$7;
643
820
  /** @internal */
644
- const state$c = Symbol( /* "BlobState" */);
645
- class BlobP {
646
- constructor(blobParts = [], options) {
647
- if (!Array.isArray(blobParts)) {
648
- throw new TypeError("First argument to Blob constructor must be an Array.");
649
- }
650
- let encoder = null;
651
- let chunks = blobParts.reduce((chunks, part) => {
652
- if (isPolyfillType("Blob", part)) {
653
- chunks.push(part[state$c][_u8array]);
654
- }
655
- else if (part instanceof ArrayBuffer || ArrayBuffer.isView(part)) {
656
- chunks.push(convert$1(part));
657
- }
658
- else {
659
- if (!encoder) {
660
- encoder = new TextEncoderP();
661
- }
662
- chunks.push(encoder.encode(String(part)));
663
- }
664
- return chunks;
665
- }, []);
666
- this[state$c] = new BlobState(concat(chunks));
667
- const that = this[state$c];
668
- that.size = that[_u8array].length;
669
- let rawType = (options === null || options === void 0 ? void 0 : options.type) || "";
670
- that.type = /[^\u0020-\u007E]/.test(rawType) ? "" : rawType.toLowerCase();
821
+ const state$b = Symbol( /* "FileReaderState" */);
822
+ class FileReaderP extends EventTargetP {
823
+ constructor() {
824
+ super();
825
+ this[state$b] = new FileReaderState(this);
671
826
  }
672
- get size() { return this[state$c].size; }
673
- get type() { return this[state$c].type; }
674
- arrayBuffer() {
675
- return Promise.resolve(clone(this[state$c][_u8array].buffer).buffer);
827
+ get readyState() { return this[state$b].readyState; }
828
+ get result() { return this[state$b].result; }
829
+ get error() { return this[state$b].error; }
830
+ abort() {
831
+ if (this.readyState === FileReaderP.LOADING) {
832
+ this[state$b].readyState = FileReaderP.DONE;
833
+ this[state$b].result = null;
834
+ emitProcessEvent(this, "abort");
835
+ }
676
836
  }
677
- bytes() {
678
- return Promise.resolve(clone(this[state$c][_u8array].buffer));
837
+ readAsArrayBuffer(blob) {
838
+ read$1(this, "readAsArrayBuffer", blob, () => {
839
+ this[state$b].result = Blob_toUint8Array(blob).buffer.slice(0);
840
+ });
679
841
  }
680
- slice(start, end, contentType) {
681
- let sliced = this[state$c][_u8array].slice(start !== null && start !== void 0 ? start : 0, end !== null && end !== void 0 ? end : this[state$c][_u8array].length);
682
- return new BlobP([sliced], { type: contentType !== null && contentType !== void 0 ? contentType : "" });
842
+ readAsBinaryString(blob) {
843
+ read$1(this, "readAsBinaryString", blob, () => {
844
+ this[state$b].result = Blob_toUint8Array(blob).reduce((acc, cur) => {
845
+ acc += String.fromCharCode(cur);
846
+ return acc;
847
+ }, "");
848
+ });
683
849
  }
684
- stream() {
685
- throw new ReferenceError("ReadableStream is not defined");
850
+ readAsDataURL(blob) {
851
+ read$1(this, "readAsDataURL", blob, () => {
852
+ this[state$b].result = "data:" + (blob.type || "application/octet-stream") + ";base64," + Uint8Array_toBase64(Blob_toUint8Array(blob));
853
+ });
686
854
  }
687
- text() {
688
- let decoder = new TextDecoderP();
689
- return Promise.resolve(decoder.decode(this[state$c][_u8array]));
855
+ readAsText(blob, encoding) {
856
+ read$1(this, "readAsText", blob, () => {
857
+ this[state$b].result = (new TextDecoderP(encoding)).decode(Blob_toUint8Array(blob));
858
+ });
690
859
  }
691
- toString() { return "[object Blob]"; }
692
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Blob"] }; }
860
+ get onabort() { return this[state$b].onabort; }
861
+ set onabort(value) { this[state$b].onabort = value; attach$1(this, "abort"); }
862
+ get onerror() { return this[state$b].onerror; }
863
+ set onerror(value) { this[state$b].onerror = value; attach$1(this, "error"); }
864
+ get onload() { return this[state$b].onload; }
865
+ set onload(value) { this[state$b].onload = value; attach$1(this, "load"); }
866
+ get onloadend() { return this[state$b].onloadend; }
867
+ set onloadend(value) { this[state$b].onloadend = value; attach$1(this, "loadend"); }
868
+ get onloadstart() { return this[state$b].onloadstart; }
869
+ set onloadstart(value) { this[state$b].onloadstart = value; attach$1(this, "loadstart"); }
870
+ get onprogress() { return this[state$b].onprogress; }
871
+ set onprogress(value) { this[state$b].onprogress = value; attach$1(this, "progress"); }
872
+ toString() { return "[object FileReader]"; }
873
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
693
874
  }
694
- defineStringTag(BlobP, "Blob");
875
+ const properties$1 = {
876
+ EMPTY: { value: 0, enumerable: true },
877
+ LOADING: { value: 1, enumerable: true },
878
+ DONE: { value: 2, enumerable: true },
879
+ };
880
+ Object.defineProperties(FileReaderP, properties$1);
881
+ Object.defineProperties(FileReaderP.prototype, properties$1);
882
+ dfStringTag(FileReaderP, "FileReader");
695
883
  /** @internal */
696
- const _u8array = Symbol();
697
- /** @internal */
698
- class BlobState {
699
- constructor(buffer) {
700
- this.size = 0;
701
- this.type = "";
702
- this[_u8array] = buffer;
703
- }
704
- toUint8Array() {
705
- return this[_u8array];
706
- }
707
- toArrayBuffer() {
708
- return this[_u8array].buffer;
709
- }
710
- }
711
- function u8array2base64(input) {
712
- let byteToCharMap = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
713
- let output = [];
714
- for (var i = 0; i < input.length; i += 3) {
715
- let byte1 = input[i];
716
- let haveByte2 = i + 1 < input.length;
717
- let byte2 = haveByte2 ? input[i + 1] : 0;
718
- let haveByte3 = i + 2 < input.length;
719
- let byte3 = haveByte3 ? input[i + 2] : 0;
720
- let outByte1 = byte1 >> 2;
721
- let outByte2 = ((byte1 & 0x03) << 4) | (byte2 >> 4);
722
- let outByte3 = ((byte2 & 0x0F) << 2) | (byte3 >> 6);
723
- let outByte4 = byte3 & 0x3F;
724
- if (!haveByte3) {
725
- outByte4 = 64;
726
- if (!haveByte2) {
727
- outByte3 = 64;
728
- }
729
- }
730
- output.push(byteToCharMap[outByte1], byteToCharMap[outByte2], byteToCharMap[outByte3], byteToCharMap[outByte4]);
731
- }
732
- return output.join("");
733
- }
734
- function convert$1(buf) {
735
- return buf instanceof ArrayBuffer
736
- ? new Uint8Array(buf)
737
- : new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
738
- }
739
- function clone(buf) {
740
- let sourceArray = convert$1(buf);
741
- let cloneArray = new Uint8Array(new ArrayBuffer(sourceArray.byteLength));
742
- cloneArray.set(sourceArray);
743
- return cloneArray;
744
- }
745
- function concat(chunks) {
746
- let totalByteLength = chunks.reduce((acc, cur) => acc + cur.byteLength, 0);
747
- let result = new Uint8Array(totalByteLength);
748
- chunks.reduce((offset, chunk) => {
749
- result.set(chunk, offset);
750
- return offset + chunk.byteLength;
751
- }, 0);
752
- return result;
753
- }
754
- const BlobE = g["Blob"] || BlobP;
755
-
756
- /** @internal */
757
- const state$b = Symbol( /* "FileState" */);
758
- class FileP extends BlobP {
759
- constructor(fileBits, fileName, options) {
760
- super(fileBits, options);
761
- this[state$b] = new FileState();
762
- this[state$b].lastModified = +((options === null || options === void 0 ? void 0 : options.lastModified) ? new Date(options.lastModified) : new Date());
763
- this[state$b].name = fileName.replace(/\//g, ":");
764
- }
765
- get lastModified() { return this[state$b].lastModified; }
766
- get name() { return this[state$b].name; }
767
- get webkitRelativePath() { return ""; }
768
- toString() { return "[object File]"; }
769
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["File", "Blob"] }; }
770
- }
771
- defineStringTag(FileP, "File");
772
- /** @internal */
773
- class FileState {
774
- constructor() {
775
- this.lastModified = 0;
776
- this.name = "";
777
- }
778
- }
779
- const FileE = g["Blob"] ? g["File"] : FileP;
780
-
781
- var _a$7;
782
- /** @internal */
783
- const state$a = Symbol( /* "FileReaderState" */);
784
- class FileReaderP extends EventTargetP {
785
- constructor() {
786
- super();
787
- this[state$a] = new FileReaderState(this);
788
- }
789
- get readyState() { return this[state$a].readyState; }
790
- get result() { return this[state$a].result; }
791
- get error() { return this[state$a].error; }
792
- abort() {
793
- if (this.readyState === FileReaderP.LOADING) {
794
- this[state$a].readyState = FileReaderP.DONE;
795
- this[state$a].result = null;
796
- emitProcessEvent(this, "abort");
797
- }
798
- }
799
- readAsArrayBuffer(blob) {
800
- read$1.call(this[state$a], "readAsArrayBuffer", blob, () => {
801
- this[state$a].result = blob[state$c].toArrayBuffer().slice(0);
802
- });
803
- }
804
- readAsBinaryString(blob) {
805
- read$1.call(this[state$a], "readAsBinaryString", blob, () => {
806
- this[state$a].result = blob[state$c].toUint8Array().reduce((acc, cur) => {
807
- acc += String.fromCharCode(cur);
808
- return acc;
809
- }, "");
810
- });
811
- }
812
- readAsDataURL(blob) {
813
- read$1.call(this[state$a], "readAsDataURL", blob, () => {
814
- this[state$a].result = "data:" + blob.type + ";base64," + u8array2base64(blob[state$c].toUint8Array());
815
- });
816
- }
817
- readAsText(blob, encoding) {
818
- read$1.call(this[state$a], "readAsText", blob, () => {
819
- this[state$a].result = (new TextDecoderP(encoding)).decode(blob[state$c].toUint8Array());
820
- });
821
- }
822
- get onabort() { return this[state$a].onabort; }
823
- set onabort(value) { this[state$a].onabort = value; attach$1.call(this[state$a], "abort"); }
824
- get onerror() { return this[state$a].onerror; }
825
- set onerror(value) { this[state$a].onerror = value; attach$1.call(this[state$a], "error"); }
826
- get onload() { return this[state$a].onload; }
827
- set onload(value) { this[state$a].onload = value; attach$1.call(this[state$a], "load"); }
828
- get onloadend() { return this[state$a].onloadend; }
829
- set onloadend(value) { this[state$a].onloadend = value; attach$1.call(this[state$a], "loadend"); }
830
- get onloadstart() { return this[state$a].onloadstart; }
831
- set onloadstart(value) { this[state$a].onloadstart = value; attach$1.call(this[state$a], "loadstart"); }
832
- get onprogress() { return this[state$a].onprogress; }
833
- set onprogress(value) { this[state$a].onprogress = value; attach$1.call(this[state$a], "progress"); }
834
- toString() { return "[object FileReader]"; }
835
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["FileReader", "EventTarget"] }; }
836
- }
837
- const properties$1 = {
838
- EMPTY: { value: 0, enumerable: true },
839
- LOADING: { value: 1, enumerable: true },
840
- DONE: { value: 2, enumerable: true },
841
- };
842
- Object.defineProperties(FileReaderP, properties$1);
843
- Object.defineProperties(FileReaderP.prototype, properties$1);
844
- defineStringTag(FileReaderP, "FileReader");
845
- /** @internal */
846
- const _handlers$3 = Symbol();
884
+ const _handlers$3 = Symbol();
847
885
  /** @internal */
848
886
  class FileReaderState {
849
887
  constructor(target) {
850
888
  this.readyState = FileReaderP.EMPTY;
851
889
  this.result = null;
852
890
  this.error = null;
853
- this[_a$7] = getHandlers$3.call(this);
891
+ this[_a$7] = getHandlers$3(this);
854
892
  this.onabort = null;
855
893
  this.onerror = null;
856
894
  this.onload = null;
@@ -861,50 +899,51 @@ class FileReaderState {
861
899
  }
862
900
  }
863
901
  _a$7 = _handlers$3;
864
- function read$1(kind, blob, setResult) {
902
+ function read$1(reader, kind, blob, setResult) {
865
903
  if (!isPolyfillType("Blob", blob)) {
866
904
  throw new TypeError("Failed to execute '" + kind + "' on 'FileReader': parameter 1 is not of type 'Blob'.");
867
905
  }
868
- this.error = null;
869
- this.readyState = FileReaderP.LOADING;
870
- emitProcessEvent(this.target, "loadstart", 0, blob.size);
906
+ const s = reader[state$b];
907
+ s.error = null;
908
+ s.readyState = FileReaderP.LOADING;
909
+ emitProcessEvent(s.target, "loadstart", 0, blob.size);
871
910
  setTimeout(() => {
872
- if (this.readyState === FileReaderP.LOADING) {
873
- this.readyState = FileReaderP.DONE;
911
+ if (s.readyState === FileReaderP.LOADING) {
912
+ s.readyState = FileReaderP.DONE;
874
913
  try {
875
914
  setResult();
876
- emitProcessEvent(this.target, "load", blob.size, blob.size);
915
+ emitProcessEvent(s.target, "load", blob.size, blob.size);
877
916
  }
878
917
  catch (e) {
879
- this.result = null;
880
- this.error = e;
881
- emitProcessEvent(this.target, "error", 0, blob.size);
918
+ s.result = null;
919
+ s.error = e;
920
+ emitProcessEvent(s.target, "error", 0, blob.size);
882
921
  }
883
922
  }
884
- emitProcessEvent(this.target, "loadend", !!this.result ? blob.size : 0, blob.size);
923
+ emitProcessEvent(s.target, "loadend", !!s.result ? blob.size : 0, blob.size);
885
924
  });
886
925
  }
887
- function attach$1(type) {
926
+ function attach$1(reader, type) {
927
+ const s = reader[state$b];
888
928
  const fnName = ("on" + type);
889
- const cb = this[fnName];
890
- const listener = this[_handlers$3][fnName];
891
- attachFn.call(this.target, type, cb, listener);
929
+ const cb = s[fnName];
930
+ const listener = s[_handlers$3][fnName];
931
+ attachFn(reader, type, cb, listener);
892
932
  }
893
- function getHandlers$3() {
933
+ function getHandlers$3(s) {
894
934
  return {
895
- onabort: (ev) => { executeFn.call(this.target, this.onabort, ev); },
896
- onerror: (ev) => { executeFn.call(this.target, this.onerror, ev); },
897
- onload: (ev) => { executeFn.call(this.target, this.onload, ev); },
898
- onloadend: (ev) => { executeFn.call(this.target, this.onloadend, ev); },
899
- onloadstart: (ev) => { executeFn.call(this.target, this.onloadstart, ev); },
900
- onprogress: (ev) => { executeFn.call(this.target, this.onprogress, ev); },
935
+ onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
936
+ onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
937
+ onload: (ev) => { executeFn(s.target, s.onload, ev); },
938
+ onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
939
+ onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
940
+ onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
901
941
  };
902
942
  }
903
943
  const FileReaderE = g["Blob"] ? g["FileReader"] : FileReaderP;
904
944
 
905
945
  var _a$6;
906
- /** @internal */
907
- const state$9 = Symbol( /* "FormDataState" */);
946
+ /** @internal */ const state$a = Symbol( /* "FormDataState" */);
908
947
  class FormDataP {
909
948
  constructor(form, submitter) {
910
949
  if (form !== void 0) {
@@ -913,21 +952,21 @@ class FormDataP {
913
952
  if (!!submitter) {
914
953
  throw new TypeError("Failed to construct 'FormData': parameter 2 is not of type 'HTMLElement'.");
915
954
  }
916
- this[state$9] = new FormDataState();
955
+ this[state$a] = new FormDataState();
917
956
  }
918
957
  append(name, value, filename) {
919
- this[state$9][_formData].push(normalizeArgs(name, value, filename));
958
+ this[state$a][_formData].push(normalizeArgs(name, value, filename));
920
959
  }
921
960
  delete(name) {
922
961
  let result = [];
923
962
  name = String(name);
924
- each(this[state$9][_formData], entry => {
963
+ each(this[state$a][_formData], entry => {
925
964
  entry[0] !== name && result.push(entry);
926
965
  });
927
- this[state$9][_formData] = result;
966
+ this[state$a][_formData] = result;
928
967
  }
929
968
  get(name) {
930
- let entries = this[state$9][_formData];
969
+ let entries = this[state$a][_formData];
931
970
  name = String(name);
932
971
  for (let i = 0; i < entries.length; ++i) {
933
972
  if (entries[i][0] === name) {
@@ -939,15 +978,15 @@ class FormDataP {
939
978
  getAll(name) {
940
979
  let result = [];
941
980
  name = String(name);
942
- each(this[state$9][_formData], data => {
981
+ each(this[state$a][_formData], data => {
943
982
  data[0] === name && result.push(data[1]);
944
983
  });
945
984
  return result;
946
985
  }
947
986
  has(name) {
948
987
  name = String(name);
949
- for (let i = 0; i < this[state$9][_formData].length; ++i) {
950
- if (this[state$9][_formData][i][0] === name) {
988
+ for (let i = 0; i < this[state$a][_formData].length; ++i) {
989
+ if (this[state$a][_formData][i][0] === name) {
951
990
  return true;
952
991
  }
953
992
  }
@@ -958,27 +997,28 @@ class FormDataP {
958
997
  let result = [];
959
998
  let args = normalizeArgs(name, value, filename);
960
999
  let replace = true;
961
- each(this[state$9][_formData], data => {
1000
+ each(this[state$a][_formData], data => {
962
1001
  data[0] === name
963
1002
  ? replace && (replace = !result.push(args))
964
1003
  : result.push(data);
965
1004
  });
966
1005
  replace && result.push(args);
967
- this[state$9][_formData] = result;
1006
+ this[state$a][_formData] = result;
968
1007
  }
969
1008
  forEach(callbackfn, thisArg) {
970
- for (let [name, value] of this) {
971
- callbackfn.call(thisArg, value, name, thisArg);
1009
+ for (let i = 0; i < this[state$a][_formData].length; ++i) {
1010
+ let pair = this[state$a][_formData][i];
1011
+ callbackfn.call(thisArg, pair[1], pair[0], thisArg);
972
1012
  }
973
1013
  }
974
1014
  entries() {
975
- return this[state$9][_formData].values();
1015
+ return this[state$a][_formData].values();
976
1016
  }
977
1017
  keys() {
978
- return this[state$9][_formData].map(x => x[0]).values();
1018
+ return this[state$a][_formData].map(x => x[0]).values();
979
1019
  }
980
1020
  values() {
981
- return this[state$9][_formData].map(x => x[1]).values();
1021
+ return this[state$a][_formData].map(x => x[1]).values();
982
1022
  }
983
1023
  [Symbol.iterator]() {
984
1024
  return this.entries();
@@ -986,7 +1026,7 @@ class FormDataP {
986
1026
  toString() { return "[object FormData]"; }
987
1027
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["FormData"] }; }
988
1028
  }
989
- defineStringTag(FormDataP, "FormData");
1029
+ dfStringTag(FormDataP, "FormData");
990
1030
  /** @internal */
991
1031
  const _formData = Symbol();
992
1032
  /** @internal */
@@ -994,25 +1034,27 @@ class FormDataState {
994
1034
  constructor() {
995
1035
  this[_a$6] = [];
996
1036
  }
997
- toBlob() {
998
- const boundary = "----formdata-polyfill-" + Math.random();
999
- const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
1000
- let chunks = [];
1001
- for (const [name, value] of this[_formData].values()) {
1002
- if (typeof value === "string") {
1003
- chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
1004
- }
1005
- else {
1006
- 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`);
1007
- }
1037
+ }
1038
+ _a$6 = _formData;
1039
+ /** @internal */
1040
+ function FormData_toBlob(formData) {
1041
+ const boundary = "----formdata-polyfill-" + Math.random();
1042
+ const p = `--${boundary}\r\nContent-Disposition: form-data; name="`;
1043
+ let chunks = [];
1044
+ for (let i = 0; i < formData[state$a][_formData].length; ++i) {
1045
+ let pair = formData[state$a][_formData][i];
1046
+ let name = pair[0];
1047
+ let value = pair[1];
1048
+ if (typeof value === "string") {
1049
+ chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`);
1050
+ }
1051
+ else {
1052
+ 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`);
1008
1053
  }
1009
- chunks.push(`--${boundary}--`);
1010
- return new BlobP(chunks, {
1011
- type: "multipart/form-data; boundary=" + boundary,
1012
- });
1013
1054
  }
1055
+ chunks.push(`--${boundary}--`);
1056
+ return new BlobP(chunks, { type: "multipart/form-data; boundary=" + boundary });
1014
1057
  }
1015
- _a$6 = _formData;
1016
1058
  function normalizeArgs(name, value, filename) {
1017
1059
  if (isPolyfillType("Blob", value)) {
1018
1060
  filename = filename !== undefined
@@ -1042,6 +1084,7 @@ function escape(str) {
1042
1084
  * Parses multipart/form-data binary data, supporting restoration of text fields and files
1043
1085
  * @param body - Text in multipart/form-data format (including boundaries and data)
1044
1086
  * @returns Parsed FormData object (text fields as strings, files as File objects)
1087
+ * @internal
1045
1088
  */
1046
1089
  function createFormDataFromBody(body, errMsg = "Failed to fetch") {
1047
1090
  const formData = new FormDataP();
@@ -1121,25 +1164,29 @@ const FormDataE = g["FormData"] || FormDataP;
1121
1164
 
1122
1165
  var _a$5;
1123
1166
  /** @internal */
1124
- const state$8 = Symbol( /* "URLSearchParamsState" */);
1167
+ const state$9 = Symbol( /* "URLSearchParamsState" */);
1125
1168
  class URLSearchParamsP {
1126
1169
  constructor(init) {
1127
1170
  let search = init || "";
1128
1171
  if (isObjectType("URLSearchParams", search)) {
1129
1172
  search = search.toString();
1130
1173
  }
1131
- this[state$8] = new URLSearchParamsState();
1132
- this[state$8][_urlspDict] = parseToDict(search);
1174
+ this[state$9] = new URLSearchParamsState();
1175
+ this[state$9][_urlspDict] = parseToDict(search);
1133
1176
  }
1134
1177
  get size() {
1135
- return objectValues(this[state$8][_urlspDict]).reduce((acc, cur) => acc + cur.length, 0);
1178
+ return objectValues(this[state$9][_urlspDict]).reduce((acc, cur) => acc + cur.length, 0);
1136
1179
  }
1137
1180
  append(name, value) {
1138
- appendTo(this[state$8][_urlspDict], name, value);
1181
+ appendTo(this[state$9][_urlspDict], name, value);
1139
1182
  }
1140
1183
  delete(name, value) {
1141
1184
  let dict = {};
1142
- for (let [key, values] of objectEntries(this[state$8][_urlspDict])) {
1185
+ let pairs = objectEntries(this[state$9][_urlspDict]);
1186
+ for (let i = 0; i < pairs.length; ++i) {
1187
+ let pair = pairs[i];
1188
+ let key = pair[0];
1189
+ let values = pair[1];
1143
1190
  if (key === name) {
1144
1191
  if (value !== undefined) {
1145
1192
  let vals = values.filter(x => x !== ("" + value));
@@ -1150,46 +1197,47 @@ class URLSearchParamsP {
1150
1197
  }
1151
1198
  Object.assign(dict, { [key]: values });
1152
1199
  }
1153
- this[state$8][_urlspDict] = dict;
1200
+ this[state$9][_urlspDict] = dict;
1154
1201
  }
1155
1202
  get(name) {
1156
1203
  var _b;
1157
- return this.has(name) ? (_b = this[state$8][_urlspDict][name][0]) !== null && _b !== void 0 ? _b : null : null;
1204
+ return this.has(name) ? (_b = this[state$9][_urlspDict][name][0]) !== null && _b !== void 0 ? _b : null : null;
1158
1205
  }
1159
1206
  getAll(name) {
1160
- return this.has(name) ? this[state$8][_urlspDict][name].slice(0) : [];
1207
+ return this.has(name) ? this[state$9][_urlspDict][name].slice(0) : [];
1161
1208
  }
1162
1209
  has(name, value) {
1163
- if (hasOwnProperty(this[state$8][_urlspDict], name)) {
1210
+ if (hasOwnProperty(this[state$9][_urlspDict], name)) {
1164
1211
  if (value !== undefined) {
1165
- return this[state$8][_urlspDict][name].indexOf(("" + value)) > -1;
1212
+ return this[state$9][_urlspDict][name].indexOf(("" + value)) > -1;
1166
1213
  }
1167
1214
  return true;
1168
1215
  }
1169
1216
  return false;
1170
1217
  }
1171
1218
  set(name, value) {
1172
- this[state$8][_urlspDict][name] = ["" + value];
1219
+ this[state$9][_urlspDict][name] = ["" + value];
1173
1220
  }
1174
1221
  sort() {
1175
- const that = this[state$8];
1222
+ const that = this[state$9];
1176
1223
  let keys = Object.keys(that[_urlspDict]);
1177
1224
  keys.sort();
1178
1225
  let dict = {};
1179
- for (let key of keys) {
1226
+ for (let i = 0; i < keys.length; ++i) {
1227
+ let key = keys[i];
1180
1228
  Object.assign(dict, { [key]: that[_urlspDict][key] });
1181
1229
  }
1182
1230
  that[_urlspDict] = dict;
1183
1231
  }
1184
1232
  forEach(callbackfn, thisArg) {
1185
- objectEntries(this[state$8][_urlspDict]).forEach(([key, values]) => {
1233
+ objectEntries(this[state$9][_urlspDict]).forEach(([key, values]) => {
1186
1234
  values.forEach(value => {
1187
1235
  callbackfn.call(thisArg, value, key, this);
1188
1236
  });
1189
1237
  });
1190
1238
  }
1191
1239
  entries() {
1192
- return objectEntries(this[state$8][_urlspDict])
1240
+ return objectEntries(this[state$9][_urlspDict])
1193
1241
  .map(([key, values]) => {
1194
1242
  return values.map(value => {
1195
1243
  return [key, value];
@@ -1199,19 +1247,24 @@ class URLSearchParamsP {
1199
1247
  .values();
1200
1248
  }
1201
1249
  keys() {
1202
- return Object.keys(this[state$8][_urlspDict]).values();
1250
+ return Object.keys(this[state$9][_urlspDict]).values();
1203
1251
  }
1204
1252
  values() {
1205
- return objectValues(this[state$8][_urlspDict]).reduce(flatCb, []).values();
1253
+ return objectValues(this[state$9][_urlspDict]).reduce(flatCb, []).values();
1206
1254
  }
1207
1255
  [Symbol.iterator]() {
1208
1256
  return this.entries();
1209
1257
  }
1210
1258
  toString() {
1211
1259
  let query = [];
1212
- for (let [key, values] of objectEntries(this[state$8][_urlspDict])) {
1260
+ let pairs = objectEntries(this[state$9][_urlspDict]);
1261
+ for (let i = 0; i < pairs.length; ++i) {
1262
+ let pair = pairs[i];
1263
+ let key = pair[0];
1264
+ let values = pair[1];
1213
1265
  let name = encode$1(key);
1214
- for (let val of values) {
1266
+ for (let j = 0; j < values.length; ++j) {
1267
+ let val = values[j];
1215
1268
  query.push(name + "=" + encode$1(val));
1216
1269
  }
1217
1270
  }
@@ -1219,7 +1272,7 @@ class URLSearchParamsP {
1219
1272
  }
1220
1273
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["URLSearchParams"] }; }
1221
1274
  }
1222
- defineStringTag(URLSearchParamsP, "URLSearchParams");
1275
+ dfStringTag(URLSearchParamsP, "URLSearchParams");
1223
1276
  /** @internal */
1224
1277
  const _urlspDict = Symbol();
1225
1278
  /** @internal */
@@ -1245,7 +1298,9 @@ function parseToDict(search) {
1245
1298
  }
1246
1299
  }
1247
1300
  else {
1248
- for (let key in search) {
1301
+ let keys = Object.keys(search);
1302
+ for (let i = 0; i < keys.length; ++i) {
1303
+ let key = keys[i];
1249
1304
  if (search.hasOwnProperty(key)) {
1250
1305
  appendTo(dict, key, search[key]);
1251
1306
  }
@@ -1303,7 +1358,8 @@ function hasOwnProperty(obj, prop) {
1303
1358
  return Object.prototype.hasOwnProperty.call(obj, prop);
1304
1359
  }
1305
1360
  function flatCb(acc, cur) {
1306
- for (let item of cur) {
1361
+ for (let i = 0; i < cur.length; ++i) {
1362
+ let item = cur[i];
1307
1363
  acc.push(item);
1308
1364
  }
1309
1365
  return acc;
@@ -1312,36 +1368,39 @@ const URLSearchParamsE = g["URLSearchParams"] || URLSearchParamsP;
1312
1368
 
1313
1369
  var _a$4;
1314
1370
  /** @internal */
1315
- const state$7 = Symbol( /* "AbortSignalState" */);
1371
+ const state$8 = Symbol( /* "AbortSignalState" */);
1316
1372
  class AbortSignalP extends EventTargetP {
1317
1373
  static abort(reason) {
1318
- let signal = createAbortSignalP();
1319
- abort.call(signal[state$7], reason, false);
1374
+ let signal = createAbortSignal();
1375
+ AbortSignal_abort(signal, reason, false);
1320
1376
  return signal;
1321
1377
  }
1322
1378
  static any(signals) {
1323
- let signal = createAbortSignalP();
1379
+ let signal = createAbortSignal();
1324
1380
  let abortedSignal = signals.find(x => x.aborted);
1325
1381
  if (abortedSignal) {
1326
- abort.call(signal[state$7], abortedSignal.reason, false);
1382
+ AbortSignal_abort(signal, abortedSignal.reason, false);
1327
1383
  }
1328
1384
  else {
1385
+ let _signals = Array.from(signals);
1329
1386
  function abortFn(ev) {
1330
- for (let sig of signals) {
1387
+ for (let i = 0; i < _signals.length; ++i) {
1388
+ let sig = _signals[i];
1331
1389
  sig.removeEventListener("abort", abortFn);
1332
1390
  }
1333
- abort.call(signal[state$7], this.reason, true, ev.isTrusted);
1391
+ AbortSignal_abort(signal, this.reason, true, ev.isTrusted);
1334
1392
  }
1335
- for (let sig of signals) {
1393
+ for (let i = 0; i < _signals.length; ++i) {
1394
+ let sig = _signals[1];
1336
1395
  sig.addEventListener("abort", abortFn);
1337
1396
  }
1338
1397
  }
1339
1398
  return signal;
1340
1399
  }
1341
1400
  static timeout(milliseconds) {
1342
- let signal = createAbortSignalP();
1401
+ let signal = createAbortSignal();
1343
1402
  setTimeout(() => {
1344
- abort.call(signal[state$7], new MPException("signal timed out", "TimeoutError"));
1403
+ AbortSignal_abort(signal, new MPException("signal timed out", "TimeoutError"));
1345
1404
  }, milliseconds);
1346
1405
  return signal;
1347
1406
  }
@@ -1350,24 +1409,24 @@ class AbortSignalP extends EventTargetP {
1350
1409
  throw new TypeError("Failed to construct 'AbortSignal': Illegal constructor");
1351
1410
  }
1352
1411
  super();
1353
- this[state$7] = new AbortSignalState(this);
1412
+ this[state$8] = new AbortSignalState(this);
1354
1413
  }
1355
- get aborted() { return this[state$7].aborted; }
1356
- get reason() { return this[state$7].reason; }
1414
+ get aborted() { return this[state$8].aborted; }
1415
+ get reason() { return this[state$8].reason; }
1357
1416
  throwIfAborted() {
1358
1417
  if (this.aborted) {
1359
1418
  throw this.reason;
1360
1419
  }
1361
1420
  }
1362
- get onabort() { return this[state$7].onabort; }
1421
+ get onabort() { return this[state$8].onabort; }
1363
1422
  set onabort(value) {
1364
- this[state$7].onabort = value;
1365
- attachFn.call(this, "abort", value, this[state$7][_handlers$2].onabort);
1423
+ this[state$8].onabort = value;
1424
+ attachFn(this, "abort", value, this[state$8][_handlers$2].onabort);
1366
1425
  }
1367
1426
  toString() { return "[object AbortSignal]"; }
1368
1427
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortSignal", "EventTarget"] }; }
1369
1428
  }
1370
- defineStringTag(AbortSignalP, "AbortSignal");
1429
+ dfStringTag(AbortSignalP, "AbortSignal");
1371
1430
  /** @internal */
1372
1431
  const _handlers$2 = Symbol();
1373
1432
  /** @internal */
@@ -1375,526 +1434,159 @@ class AbortSignalState {
1375
1434
  constructor(target) {
1376
1435
  this.aborted = false;
1377
1436
  this.reason = undefined;
1378
- this[_a$4] = getHandlers$2.call(this);
1437
+ this[_a$4] = getHandlers$2(this);
1379
1438
  this.onabort = null;
1380
1439
  this.target = target;
1381
1440
  }
1382
1441
  }
1383
1442
  _a$4 = _handlers$2;
1384
- function abort(reason, notify = true, isTrusted = true) {
1385
- if (!this.aborted) {
1386
- this.aborted = true;
1387
- this.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
1443
+ /** @internal */
1444
+ function AbortSignal_abort(signal, reason, notify = true, isTrusted = true) {
1445
+ const s = signal[state$8];
1446
+ if (!s.aborted) {
1447
+ s.aborted = true;
1448
+ s.reason = reason !== null && reason !== void 0 ? reason : (new MPException("signal is aborted without reason", "AbortError"));
1388
1449
  if (notify) {
1389
- let evt = createInnerEvent(this.target, "abort", undefined, isTrusted);
1390
- fire.call(this.target[state$f], evt);
1450
+ let evt = createInnerEvent(signal, "abort", undefined, isTrusted);
1451
+ EventTarget_fire(signal, evt);
1391
1452
  }
1392
1453
  }
1393
1454
  }
1394
- function getHandlers$2() {
1455
+ function getHandlers$2(s) {
1395
1456
  return {
1396
- onabort: (ev) => { executeFn.call(this.target, this.onabort, ev); },
1457
+ onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
1397
1458
  };
1398
1459
  }
1399
- function createAbortSignalP() {
1400
- let instance = Object.create(AbortSignalP.prototype);
1401
- instance[state$f] = new EventTargetState(instance);
1402
- instance[state$7] = new AbortSignalState(instance);
1403
- return instance;
1460
+ /** @internal */
1461
+ function createAbortSignal() {
1462
+ let signal = Object.create(AbortSignalP.prototype);
1463
+ signal[state$d] = new EventTargetState(signal);
1464
+ signal[state$8] = new AbortSignalState(signal);
1465
+ return signal;
1404
1466
  }
1405
1467
  const AbortSignalE = g["AbortSignal"] || AbortSignalP;
1406
1468
 
1469
+ var _a$3, _b$1;
1407
1470
  /** @internal */
1408
- const state$6 = Symbol( /* "AbortControllerState" */);
1409
- class AbortControllerP {
1471
+ const state$7 = Symbol( /* "BodyState" */);
1472
+ class BodyImpl {
1410
1473
  constructor() {
1411
- this[state$6] = new AbortControllerState();
1474
+ if (new.target === BodyImpl) {
1475
+ throw new TypeError("Failed to construct 'Body': Illegal constructor");
1476
+ }
1477
+ this[state$7] = new BodyState();
1412
1478
  }
1413
- get signal() { return this[state$6].signal; }
1414
- abort(reason) {
1415
- abort.call(this[state$6].signal[state$7], reason);
1479
+ get body() {
1480
+ if (!this[state$7][_body]) {
1481
+ return null;
1482
+ }
1483
+ throw new ReferenceError("ReadableStream is not defined");
1416
1484
  }
1417
- toString() { return "[object AbortController]"; }
1418
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
1485
+ get bodyUsed() { return this[state$7].bodyUsed; }
1486
+ ;
1487
+ arrayBuffer() {
1488
+ const kind = "arrayBuffer";
1489
+ return consumed(this, kind) || read(this, kind);
1490
+ }
1491
+ blob() {
1492
+ const kind = "blob";
1493
+ return consumed(this, kind) || read(this, kind);
1494
+ }
1495
+ bytes() {
1496
+ const kind = "bytes";
1497
+ return consumed(this, kind) || read(this, kind);
1498
+ }
1499
+ formData() {
1500
+ const kind = "formData";
1501
+ return consumed(this, kind) || read(this, kind);
1502
+ }
1503
+ json() {
1504
+ const kind = "json";
1505
+ return consumed(this, kind) || read(this, kind);
1506
+ }
1507
+ text() {
1508
+ const kind = "text";
1509
+ return consumed(this, kind) || read(this, kind);
1510
+ }
1511
+ toString() { return "[object Body]"; }
1512
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
1419
1513
  }
1420
- defineStringTag(AbortControllerP, "AbortController");
1514
+ dfStringTag(BodyImpl, "Body");
1515
+ /** @internal */ const _name = Symbol();
1516
+ /** @internal */ const _body = Symbol();
1421
1517
  /** @internal */
1422
- class AbortControllerState {
1518
+ class BodyState {
1423
1519
  constructor() {
1424
- this.signal = createAbortSignalP();
1520
+ this.bodyUsed = false;
1521
+ this[_a$3] = "Body";
1522
+ this[_b$1] = "";
1425
1523
  }
1426
1524
  }
1427
- const AbortControllerE = g["AbortController"] || AbortControllerP;
1428
-
1429
- var _a$3;
1525
+ _a$3 = _name, _b$1 = _body;
1430
1526
  /** @internal */
1431
- const state$5 = Symbol( /* "XMLHttpRequestEventTargetState" */);
1432
- class XMLHttpRequestEventTargetP extends EventTargetP {
1433
- constructor() {
1434
- if (new.target === XMLHttpRequestEventTargetP) {
1435
- throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
1527
+ function Body_init(body, payload, headers) {
1528
+ if (isObjectType("ReadableStream", payload)) {
1529
+ throw new ReferenceError("ReadableStream is not defined");
1530
+ }
1531
+ body[state$7][_body] = convert(payload, type => {
1532
+ if (headers && !headers.get("Content-Type")) {
1533
+ headers.set("Content-Type", type);
1436
1534
  }
1437
- super();
1438
- this[state$5] = new XMLHttpRequestEventTargetState(this);
1439
- }
1440
- get onabort() { return this[state$5].onabort; }
1441
- set onabort(value) { this[state$5].onabort = value; attach.call(this[state$5], "abort"); }
1442
- get onerror() { return this[state$5].onerror; }
1443
- set onerror(value) { this[state$5].onerror = value; attach.call(this[state$5], "error"); }
1444
- get onload() { return this[state$5].onload; }
1445
- set onload(value) { this[state$5].onload = value; attach.call(this[state$5], "load"); }
1446
- get onloadend() { return this[state$5].onloadend; }
1447
- set onloadend(value) { this[state$5].onloadend = value; attach.call(this[state$5], "loadend"); }
1448
- get onloadstart() { return this[state$5].onloadstart; }
1449
- set onloadstart(value) { this[state$5].onloadstart = value; attach.call(this[state$5], "loadstart"); }
1450
- get onprogress() { return this[state$5].onprogress; }
1451
- set onprogress(value) { this[state$5].onprogress = value; attach.call(this[state$5], "progress"); }
1452
- get ontimeout() { return this[state$5].ontimeout; }
1453
- set ontimeout(value) { this[state$5].ontimeout = value; attach.call(this[state$5], "timeout"); }
1454
- toString() { return "[object XMLHttpRequestEventTarget]"; }
1455
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
1535
+ });
1456
1536
  }
1457
- defineStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
1458
1537
  /** @internal */
1459
- const _handlers$1 = Symbol();
1460
- /** @internal */
1461
- class XMLHttpRequestEventTargetState {
1462
- /**
1463
- * @param _target XMLHttpRequestEventTargetP
1464
- */
1465
- constructor(_target) {
1466
- this[_a$3] = getHandlers$1.call(this);
1467
- this.onabort = null;
1468
- this.onerror = null;
1469
- this.onload = null;
1470
- this.onloadend = null;
1471
- this.onloadstart = null;
1472
- this.onprogress = null;
1473
- this.ontimeout = null;
1474
- this.target = _target;
1475
- }
1538
+ function Body_setName(body, name) {
1539
+ body[state$7][_name] = name;
1476
1540
  }
1477
- _a$3 = _handlers$1;
1478
- function attach(type) {
1479
- const fnName = ("on" + type);
1480
- const cb = this[fnName];
1481
- const listener = this[_handlers$1][fnName];
1482
- attachFn.call(this.target, type, cb, listener);
1541
+ /** @internal */
1542
+ function Body_setBodyUsed(body, bodyUsed) {
1543
+ body[state$7].bodyUsed = bodyUsed;
1483
1544
  }
1484
- function getHandlers$1() {
1485
- return {
1486
- onabort: (ev) => { executeFn.call(this.target, this.onabort, ev); },
1487
- onerror: (ev) => { executeFn.call(this.target, this.onerror, ev); },
1488
- onload: (ev) => { executeFn.call(this.target, this.onload, ev); },
1489
- onloadend: (ev) => { executeFn.call(this.target, this.onloadend, ev); },
1490
- onloadstart: (ev) => { executeFn.call(this.target, this.onloadstart, ev); },
1491
- onprogress: (ev) => { executeFn.call(this.target, this.onprogress, ev); },
1492
- ontimeout: (ev) => { executeFn.call(this.target, this.ontimeout, ev); },
1493
- };
1545
+ /** @internal */
1546
+ function Body_toPayload(body) {
1547
+ return body[state$7][_body];
1494
1548
  }
1495
-
1496
- class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
1497
- constructor() {
1498
- if (new.target === XMLHttpRequestUploadP) {
1499
- throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
1549
+ function read(body, kind) {
1550
+ return new Promise((resolve, reject) => {
1551
+ try {
1552
+ resolve(readSync(body, kind));
1500
1553
  }
1501
- super();
1502
- }
1503
- toString() { return "[object XMLHttpRequestUpload]"; }
1504
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
1505
- }
1506
- defineStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
1507
- function createXMLHttpRequestUploadP() {
1508
- let instance = Object.create(XMLHttpRequestUploadP.prototype);
1509
- instance[state$f] = new EventTargetState(instance);
1510
- instance[state$5] = new XMLHttpRequestEventTargetState(instance);
1511
- return instance;
1512
- }
1513
-
1514
- // @ts-nocheck
1515
- const mp = (() => {
1516
- let u = "undefined", r = "request", f = "function";
1517
- let mp;
1518
- mp =
1519
- (typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
1520
- (typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
1521
- (typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
1522
- (typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
1523
- (typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
1524
- (typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
1525
- (typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
1526
- (typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
1527
- (typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
1528
- undefined;
1529
- if (typeof g["XMLHttpRequest"] === f) {
1530
- return;
1531
- }
1532
- if (mp === undefined)
1533
- mp =
1534
- (typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
1535
- (typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
1536
- undefined;
1537
- return mp;
1538
- })();
1539
-
1540
- const request = mp ? mp.request : function errorRequest(options) {
1541
- const errMsg = "NOT_SUPPORTED_ERR";
1542
- const errno = 9;
1543
- const err = {
1544
- errMsg,
1545
- errno,
1546
- exception: {
1547
- retryCount: 0,
1548
- reasons: [{ errMsg, errno }],
1549
- },
1550
- useHttpDNS: false,
1551
- };
1552
- Promise.resolve(err)
1553
- .then(err => { try {
1554
- if (options.fail) {
1555
- options.fail(err);
1554
+ catch (e) {
1555
+ reject(e);
1556
1556
  }
1557
+ });
1558
+ }
1559
+ function readSync(body, kind) {
1560
+ const payload = body[state$7][_body];
1561
+ if (kind === "arrayBuffer") {
1562
+ return convertBack("arraybuffer", payload);
1557
1563
  }
1558
- catch (e) {
1559
- console.warn(e);
1560
- } })
1561
- .then(() => { if (options.complete) {
1562
- options.complete(err);
1563
- } });
1564
- throw new ReferenceError("request is not defined");
1565
- };
1566
-
1567
- var _a$2, _b$1, _c, _d, _e, _f, _g, _h, _j, _k;
1568
- /** @internal */
1569
- const state$4 = Symbol( /* "XMLHttpRequestState" */);
1570
- class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
1571
- constructor() {
1572
- super();
1573
- this[state$4] = new XMLHttpRequestState(this);
1564
+ else if (kind === "blob") {
1565
+ return convertBack("blob", payload);
1574
1566
  }
1575
- get readyState() { return this[state$4].readyState; }
1576
- get response() { return this[state$4].response; }
1577
- get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
1578
- get responseType() { return this[state$4].responseType; }
1579
- set responseType(value) { this[state$4].responseType = value; }
1580
- get responseURL() { return this[state$4].responseURL; }
1581
- get responseXML() { return null; }
1582
- get status() { return this[state$4].status; }
1583
- get statusText() {
1584
- if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
1585
- return "";
1586
- return this[state$4].statusText || statusTextMap(this.status);
1567
+ else if (kind === "bytes") {
1568
+ let arrayBuffer = convertBack("arraybuffer", payload);
1569
+ return new Uint8Array(arrayBuffer);
1587
1570
  }
1588
- get timeout() { return this[state$4].timeout; }
1589
- set timeout(value) { this[state$4].timeout = value; }
1590
- get upload() {
1591
- const that = this[state$4];
1592
- if (!that.upload) {
1593
- that.upload = createXMLHttpRequestUploadP();
1594
- }
1595
- return that.upload;
1596
- }
1597
- get withCredentials() { return this[state$4].withCredentials; }
1598
- set withCredentials(value) { this[state$4].withCredentials = value; }
1599
- abort() {
1600
- clearRequest.call(this[state$4]);
1601
- }
1602
- getAllResponseHeaders() {
1603
- if (!this[state$4][_responseHeaders])
1604
- return "";
1605
- return objectEntries(this[state$4][_responseHeaders] || {}).map(([k, v]) => `${k}: ${v}\r\n`).join("");
1606
- }
1607
- getResponseHeader(name) {
1608
- var _l, _m;
1609
- if (!this[state$4][_responseHeaders])
1610
- return null;
1611
- let nameKey = name.toLowerCase();
1612
- return (_m = (_l = objectEntries(this[state$4][_responseHeaders] || {}).find(x => x[0].toLowerCase() === nameKey)) === null || _l === void 0 ? void 0 : _l[1]) !== null && _m !== void 0 ? _m : null;
1613
- }
1614
- open(...args) {
1615
- const [method, url, async = true, username = null, password = null] = args;
1616
- const that = this[state$4];
1617
- if (args.length < 2) {
1618
- throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
1619
- }
1620
- if (!async) {
1621
- console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
1622
- }
1623
- clearRequest.call(that, false);
1624
- that[_method] = normalizeMethod(method);
1625
- that[_requestURL] = String(url);
1626
- if (username !== null || password !== null) {
1627
- let _username = String(username !== null && username !== void 0 ? username : "");
1628
- let _password = String(password !== null && password !== void 0 ? password : "");
1629
- if (_username.length > 0 || _password.length > 0) {
1630
- let auth = `Basic ${u8array2base64((new TextEncoderP()).encode(_username + ":" + _password))}`;
1631
- this.setRequestHeader("Authorization", auth);
1632
- }
1633
- }
1634
- that[_inAfterOpenBeforeSend] = true;
1635
- setReadyStateAndNotify.call(that, XMLHttpRequestP.OPENED);
1636
- }
1637
- overrideMimeType(mime) {
1638
- if (this[state$4][_inAfterOpenBeforeSend]) {
1639
- console.warn(`XMLHttpRequest.overrideMimeType('${mime}') is not implemented: The method will have no effect on response parsing.`);
1640
- }
1641
- }
1642
- send(body) {
1643
- const that = this[state$4];
1644
- if (!that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED) {
1645
- throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
1646
- }
1647
- that[_inAfterOpenBeforeSend] = false;
1648
- const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
1649
- const processHeaders = allowsRequestBody && Object.keys(that[_requestHeaders]).map(x => x.toLowerCase()).indexOf("content-type") === -1;
1650
- const upload = that.upload;
1651
- const processContentLength = upload && upload[state$f][_executors].length > 0;
1652
- let headers = processHeaders ? Object.assign({}, that[_requestHeaders]) : that[_requestHeaders];
1653
- let contentLength = zero;
1654
- let data = convert(body, processHeaders ? v => { assignRequestHeader(headers, "Content-Type", v); } : void 0, processContentLength ? v => { contentLength = v; } : void 0);
1655
- let options = {
1656
- url: that[_requestURL],
1657
- method: that[_method],
1658
- header: headers,
1659
- data,
1660
- dataType: that.responseType === "json" ? "json" : normalizeDataType(that.responseType),
1661
- responseType: normalizeDataType(that.responseType),
1662
- success: requestSuccess.bind(that),
1663
- fail: requestFail.bind(that),
1664
- complete: requestComplete.bind(that),
1665
- };
1666
- if (that.withCredentials) {
1667
- options.withCredentials = true;
1668
- options.enableCookie = true;
1669
- }
1670
- that[_requestTask] = request(options);
1671
- emitProcessEvent(this, "loadstart");
1672
- if (processContentLength) {
1673
- const hasRequestBody = allowsRequestBody && (typeof data === "string" ? data.length > 0 : data.byteLength > 0);
1674
- if (hasRequestBody) {
1675
- emitProcessEvent(upload, "loadstart", 0, contentLength);
1676
- }
1677
- setTimeout(() => {
1678
- const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
1679
- const _contentLength = _aborted ? 0 : contentLength;
1680
- if (_aborted) {
1681
- emitProcessEvent(upload, "abort");
1682
- }
1683
- else {
1684
- if (hasRequestBody) {
1685
- emitProcessEvent(upload, "load", _contentLength, _contentLength);
1686
- }
1687
- }
1688
- if (_aborted || hasRequestBody) {
1689
- emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
1690
- }
1691
- });
1692
- }
1693
- checkRequestTimeout.call(that);
1694
- }
1695
- setRequestHeader(name, value) {
1696
- assignRequestHeader(this[state$4][_requestHeaders], name, value);
1697
- }
1698
- get onreadystatechange() { return this[state$4].onreadystatechange; }
1699
- set onreadystatechange(value) {
1700
- this[state$4].onreadystatechange = value;
1701
- attachFn.call(this, "readystatechange", value, this[state$4][_handlers].onreadystatechange);
1571
+ else if (kind === "formData") {
1572
+ let text = convertBack("text", payload);
1573
+ return createFormDataFromBody(text);
1702
1574
  }
1703
- toString() { return "[object XMLHttpRequest]"; }
1704
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
1705
- }
1706
- const properties = {
1707
- UNSENT: { value: 0, enumerable: true },
1708
- OPENED: { value: 1, enumerable: true },
1709
- HEADERS_RECEIVED: { value: 2, enumerable: true },
1710
- LOADING: { value: 3, enumerable: true },
1711
- DONE: { value: 4, enumerable: true },
1712
- };
1713
- Object.defineProperties(XMLHttpRequestP, properties);
1714
- Object.defineProperties(XMLHttpRequestP.prototype, properties);
1715
- defineStringTag(XMLHttpRequestP, "XMLHttpRequest");
1716
- /** @internal */ const _handlers = Symbol();
1717
- /** @internal */ const _inAfterOpenBeforeSend = Symbol();
1718
- /** @internal */ const _resetPending = Symbol();
1719
- /** @internal */ const _timeoutId = Symbol();
1720
- /** @internal */ const _requestURL = Symbol();
1721
- /** @internal */ const _method = Symbol();
1722
- /** @internal */ const _requestHeaders = Symbol();
1723
- const _responseHeaders = Symbol();
1724
- /** @internal */ const _responseContentLength = Symbol();
1725
- /** @internal */ const _requestTask = Symbol();
1726
- /** @internal */
1727
- class XMLHttpRequestState {
1728
- constructor(target) {
1729
- this.readyState = XMLHttpRequestP.UNSENT;
1730
- this.response = "";
1731
- this.responseType = "";
1732
- this.responseURL = "";
1733
- this.status = 0;
1734
- this.statusText = "";
1735
- this.timeout = 0;
1736
- this.withCredentials = false;
1737
- this[_a$2] = getHandlers.call(this);
1738
- this.onreadystatechange = null;
1739
- this[_b$1] = false;
1740
- this[_c] = false;
1741
- this[_d] = 0;
1742
- this[_e] = "";
1743
- this[_f] = "GET";
1744
- this[_g] = { Accept: "*/*" };
1745
- this[_h] = null;
1746
- this[_j] = zero;
1747
- this[_k] = null;
1748
- this.target = target;
1575
+ else if (kind === "json") {
1576
+ return convertBack("json", payload);
1749
1577
  }
1750
- }
1751
- _a$2 = _handlers, _b$1 = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
1752
- function requestSuccess({ statusCode, header, data }) {
1753
- this.responseURL = this[_requestURL];
1754
- this.status = statusCode;
1755
- this[_responseHeaders] = header;
1756
- let lengthStr = this.target.getResponseHeader("Content-Length");
1757
- this[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
1758
- if (this.readyState === XMLHttpRequestP.OPENED) {
1759
- setReadyStateAndNotify.call(this, XMLHttpRequestP.HEADERS_RECEIVED);
1760
- setReadyStateAndNotify.call(this, XMLHttpRequestP.LOADING);
1761
- setTimeout(() => {
1762
- if (!this[_inAfterOpenBeforeSend]) {
1763
- let l = this[_responseContentLength];
1764
- try {
1765
- this.response = convertBack(this.responseType, data);
1766
- emitProcessEvent(this.target, "load", l, l);
1767
- }
1768
- catch (e) {
1769
- console.error(e);
1770
- emitProcessEvent(this.target, "error");
1771
- }
1772
- }
1773
- });
1578
+ else {
1579
+ return convertBack("text", payload);
1774
1580
  }
1775
1581
  }
1776
- function requestFail(err) {
1777
- // Alipay Mini Programs
1778
- // error: 14 --- JSON parse data error
1779
- // error: 19 --- http status error
1780
- // At this point, the error data object will contain three pieces of information
1781
- // returned from the server: status, headers, and data.
1782
- // In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
1783
- // differ from those in Alipay Mini Programs and should instead return normally.
1784
- // Therefore, this scenario is also handled here as a successful request response.
1785
- if ("status" in err) {
1786
- requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
1582
+ function consumed(body, kind) {
1583
+ const s = body[state$7];
1584
+ if (!s[_body])
1787
1585
  return;
1586
+ if (s.bodyUsed) {
1587
+ return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${s[_name]}': body stream already read`));
1788
1588
  }
1789
- this.status = 0;
1790
- this.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
1791
- if (!this[_inAfterOpenBeforeSend] && this.readyState !== XMLHttpRequestP.UNSENT && this.readyState !== XMLHttpRequestP.DONE) {
1792
- emitProcessEvent(this.target, "error");
1793
- resetRequestTimeout.call(this);
1794
- }
1795
- }
1796
- function requestComplete() {
1797
- this[_requestTask] = null;
1798
- if (!this[_inAfterOpenBeforeSend] && (this.readyState === XMLHttpRequestP.OPENED || this.readyState === XMLHttpRequestP.LOADING)) {
1799
- setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
1800
- }
1801
- setTimeout(() => {
1802
- if (!this[_inAfterOpenBeforeSend]) {
1803
- let l = this[_responseContentLength];
1804
- emitProcessEvent(this.target, "loadend", l, l);
1805
- }
1806
- });
1807
- }
1808
- function clearRequest(delay = true) {
1809
- const timerFn = delay ? setTimeout : (f) => { f(); };
1810
- this[_resetPending] = true;
1811
- if (this[_requestTask] && this.readyState !== XMLHttpRequestP.DONE) {
1812
- if (delay) {
1813
- setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
1814
- }
1815
- timerFn(() => {
1816
- const requestTask = this[_requestTask];
1817
- if (requestTask) {
1818
- requestTask.abort();
1819
- }
1820
- if (delay) {
1821
- emitProcessEvent(this.target, "abort");
1822
- }
1823
- if (delay && !requestTask) {
1824
- emitProcessEvent(this.target, "loadend");
1825
- }
1826
- });
1827
- }
1828
- timerFn(() => {
1829
- if (this[_resetPending]) {
1830
- if (delay) {
1831
- this.readyState = XMLHttpRequestP.UNSENT;
1832
- }
1833
- resetXHR.call(this);
1834
- }
1835
- });
1836
- }
1837
- function checkRequestTimeout() {
1838
- if (this.timeout) {
1839
- this[_timeoutId] = setTimeout(() => {
1840
- if (!this.status && this.readyState !== XMLHttpRequestP.DONE) {
1841
- if (this[_requestTask])
1842
- this[_requestTask].abort();
1843
- setReadyStateAndNotify.call(this, XMLHttpRequestP.DONE);
1844
- emitProcessEvent(this.target, "timeout");
1845
- }
1846
- }, this.timeout);
1847
- }
1848
- }
1849
- function resetXHR() {
1850
- this[_resetPending] = false;
1851
- resetRequestTimeout.call(this);
1852
- this.response = "";
1853
- this.responseURL = "";
1854
- this.status = 0;
1855
- this.statusText = "";
1856
- this[_requestHeaders] = {};
1857
- this[_responseHeaders] = null;
1858
- this[_responseContentLength] = zero;
1859
- }
1860
- function resetRequestTimeout() {
1861
- if (this[_timeoutId]) {
1862
- clearTimeout(this[_timeoutId]);
1863
- this[_timeoutId] = 0;
1864
- }
1865
- }
1866
- function setReadyStateAndNotify(value) {
1867
- let hasChanged = value !== this.readyState;
1868
- this.readyState = value;
1869
- if (hasChanged) {
1870
- let evt = createInnerEvent(this.target, "readystatechange");
1871
- fire.call(this.target[state$f], evt);
1872
- }
1873
- }
1874
- function getHandlers() {
1875
- return {
1876
- onreadystatechange: (ev) => { executeFn.call(this.target, this.onreadystatechange, ev); },
1877
- };
1878
- }
1879
- // HTTP methods whose capitalization should be normalized
1880
- const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
1881
- function normalizeMethod(method) {
1882
- let upcased = method.toUpperCase();
1883
- return methods.indexOf(upcased) > -1 ? upcased : method;
1884
- }
1885
- function normalizeDataType(responseType) {
1886
- return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
1887
- }
1888
- function assignRequestHeader(headers, name, value) {
1889
- let nameKey = name.toLowerCase();
1890
- for (let key of Object.keys(headers)) {
1891
- if (key.toLowerCase() === nameKey) {
1892
- headers[key] = value;
1893
- return;
1894
- }
1895
- }
1896
- Object.assign(headers, { [name]: value });
1897
- return;
1589
+ s.bodyUsed = true;
1898
1590
  }
1899
1591
  const encode = (str) => {
1900
1592
  const encoder = new TextEncoderP();
@@ -1904,6 +1596,7 @@ const decode = (buf) => {
1904
1596
  let decoder = new TextDecoderP();
1905
1597
  return decoder.decode(buf);
1906
1598
  };
1599
+ /** @internal */
1907
1600
  function convert(body, setContentType, setContentLength) {
1908
1601
  let result;
1909
1602
  if (typeof body === "string") {
@@ -1925,14 +1618,14 @@ function convert(body, setContentType, setContentLength) {
1925
1618
  result = body.buffer.slice(body.byteOffset, body.byteOffset + body.byteLength);
1926
1619
  }
1927
1620
  else if (isPolyfillType("Blob", body)) {
1928
- result = body[state$c].toArrayBuffer().slice(0);
1621
+ result = Blob_toUint8Array(body).buffer.slice(0);
1929
1622
  if (setContentType && body.type) {
1930
1623
  setContentType(body.type);
1931
1624
  }
1932
1625
  }
1933
1626
  else if (isPolyfillType("FormData", body)) {
1934
- let blob = body[state$9].toBlob();
1935
- result = blob[state$c].toArrayBuffer();
1627
+ let blob = FormData_toBlob(body);
1628
+ result = Blob_toUint8Array(blob).buffer;
1936
1629
  if (setContentType) {
1937
1630
  setContentType(blob.type);
1938
1631
  }
@@ -1944,12 +1637,11 @@ function convert(body, setContentType, setContentLength) {
1944
1637
  result = String(body);
1945
1638
  }
1946
1639
  if (setContentLength) {
1947
- setContentLength(() => {
1948
- return (typeof result === "string" ? encode(result) : result).byteLength;
1949
- });
1640
+ setContentLength(() => (typeof result === "string" ? encode(result) : result).byteLength);
1950
1641
  }
1951
1642
  return result;
1952
1643
  }
1644
+ /** @internal */
1953
1645
  function convertBack(type, data) {
1954
1646
  let temp = !!data ? (typeof data !== "string" && !(data instanceof ArrayBuffer) ? JSON.stringify(data) : data) : "";
1955
1647
  if (!type || type === "text") {
@@ -1968,189 +1660,13 @@ function convertBack(type, data) {
1968
1660
  return temp;
1969
1661
  }
1970
1662
  }
1971
- const zero = () => 0;
1972
- const statusMessages = {
1973
- 100: "Continue",
1974
- 101: "Switching Protocols",
1975
- 102: "Processing",
1976
- 103: "Early Hints",
1977
- 200: "OK",
1978
- 201: "Created",
1979
- 202: "Accepted",
1980
- 203: "Non-Authoritative Information",
1981
- 204: "No Content",
1982
- 205: "Reset Content",
1983
- 206: "Partial Content",
1984
- 207: "Multi-Status",
1985
- 208: "Already Reported",
1986
- 226: "IM Used",
1987
- 300: "Multiple Choices",
1988
- 301: "Moved Permanently",
1989
- 302: "Found",
1990
- 303: "See Other",
1991
- 304: "Not Modified",
1992
- 307: "Temporary Redirect",
1993
- 308: "Permanent Redirect",
1994
- 400: "Bad Request",
1995
- 401: "Unauthorized",
1996
- 402: "Payment Required",
1997
- 403: "Forbidden",
1998
- 404: "Not Found",
1999
- 405: "Method Not Allowed",
2000
- 406: "Not Acceptable",
2001
- 407: "Proxy Authentication Required",
2002
- 408: "Request Timeout",
2003
- 409: "Conflict",
2004
- 410: "Gone",
2005
- 411: "Length Required",
2006
- 412: "Precondition Failed",
2007
- 413: "Content Too Large",
2008
- 414: "URI Too Long",
2009
- 415: "Unsupported Media Type",
2010
- 416: "Range Not Satisfiable",
2011
- 417: "Expectation Failed",
2012
- 418: "I'm a teapot",
2013
- 421: "Misdirected Request",
2014
- 422: "Unprocessable Entity",
2015
- 423: "Locked",
2016
- 424: "Failed Dependency",
2017
- 425: "Too Early",
2018
- 426: "Upgrade Required",
2019
- 428: "Precondition Required",
2020
- 429: "Too Many Requests",
2021
- 431: "Request Header Fields Too Large",
2022
- 451: "Unavailable For Legal Reasons",
2023
- 500: "Internal Server Error",
2024
- 501: "Not Implemented",
2025
- 502: "Bad Gateway",
2026
- 503: "Service Unavailable",
2027
- 504: "Gateway Timeout",
2028
- 505: "HTTP Version Not Supported",
2029
- 506: "Variant Also Negotiates",
2030
- 507: "Insufficient Storage",
2031
- 508: "Loop Detected",
2032
- 510: "Not Extended",
2033
- 511: "Network Authentication Required"
2034
- };
2035
- function statusTextMap(val) {
2036
- return statusMessages[val] || "unknown";
2037
- }
2038
- const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
2039
-
2040
- var _a$1, _b;
2041
- /** @internal */
2042
- const state$3 = Symbol( /* "BodyState" */);
2043
- class BodyP {
2044
- constructor() {
2045
- if (new.target === BodyP) {
2046
- throw new TypeError("Failed to construct 'Body': Illegal constructor");
2047
- }
2048
- this[state$3] = new BodyState();
2049
- }
2050
- get body() {
2051
- if (!this[state$3][_body]) {
2052
- return null;
2053
- }
2054
- throw new ReferenceError("ReadableStream is not defined");
2055
- }
2056
- get bodyUsed() { return this[state$3].bodyUsed; }
2057
- ;
2058
- arrayBuffer() {
2059
- const kind = "arrayBuffer";
2060
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2061
- }
2062
- blob() {
2063
- const kind = "blob";
2064
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2065
- }
2066
- bytes() {
2067
- const kind = "bytes";
2068
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2069
- }
2070
- formData() {
2071
- const kind = "formData";
2072
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2073
- }
2074
- json() {
2075
- const kind = "json";
2076
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2077
- }
2078
- text() {
2079
- const kind = "text";
2080
- return consumed.call(this[state$3], kind) || read.call(this[state$3], kind);
2081
- }
2082
- toString() { return "[object Body]"; }
2083
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Body"] }; }
2084
- }
2085
- defineStringTag(BodyP, "Body");
2086
- const _name = Symbol();
2087
- const _body = Symbol();
2088
- /** @internal */
2089
- class BodyState {
2090
- constructor() {
2091
- this.bodyUsed = false;
2092
- this[_a$1] = "Body";
2093
- this[_b] = "";
2094
- }
2095
- }
2096
- _a$1 = _name, _b = _body;
2097
- function initFn(body, headers) {
2098
- if (isObjectType("ReadableStream", body)) {
2099
- throw new ReferenceError("ReadableStream is not defined");
2100
- }
2101
- this[_body] = convert(body, type => {
2102
- if (headers && !headers.get("Content-Type")) {
2103
- headers.set("Content-Type", type);
2104
- }
2105
- });
2106
- }
2107
- function read(kind) {
2108
- return new Promise((resolve, reject) => {
2109
- try {
2110
- resolve(readSync.call(this, kind));
2111
- }
2112
- catch (e) {
2113
- reject(e);
2114
- }
2115
- });
2116
- }
2117
- function readSync(kind) {
2118
- if (kind === "arrayBuffer") {
2119
- return convertBack("arraybuffer", this[_body]);
2120
- }
2121
- else if (kind === "blob") {
2122
- return convertBack("blob", this[_body]);
2123
- }
2124
- else if (kind === "bytes") {
2125
- let arrayBuffer = convertBack("arraybuffer", this[_body]);
2126
- return new Uint8Array(arrayBuffer);
2127
- }
2128
- else if (kind === "formData") {
2129
- let text = convertBack("text", this[_body]);
2130
- return createFormDataFromBody(text);
2131
- }
2132
- else if (kind === "json") {
2133
- return convertBack("json", this[_body]);
2134
- }
2135
- else {
2136
- return convertBack("text", this[_body]);
2137
- }
2138
- }
2139
- function consumed(kind) {
2140
- if (!this[_body])
2141
- return;
2142
- if (this.bodyUsed) {
2143
- return Promise.reject(new TypeError(`TypeError: Failed to execute '${kind}' on '${this[_name]}': body stream already read`));
2144
- }
2145
- this.bodyUsed = true;
2146
- }
2147
1663
 
2148
- var _a;
1664
+ var _a$2;
2149
1665
  /** @internal */
2150
- const state$2 = Symbol( /* "HeadersState" */);
1666
+ const state$6 = Symbol( /* "HeadersState" */);
2151
1667
  class HeadersP {
2152
1668
  constructor(init) {
2153
- this[state$2] = new HeadersState();
1669
+ this[state$6] = new HeadersState();
2154
1670
  if (isObjectType("Headers", init)) {
2155
1671
  init.forEach((value, name) => {
2156
1672
  this.append(name, value);
@@ -2176,18 +1692,18 @@ class HeadersP {
2176
1692
  append(name, value) {
2177
1693
  var _b;
2178
1694
  let key = normalizeName(name, "append");
2179
- value = normalizeValue(value);
2180
- let oldValue = (_b = this[state$2][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1];
2181
- this[state$2][_headersMap].set(key, ["" + name, oldValue ? `${oldValue}, ${value}` : value]);
1695
+ let newValue = normalizeValue(value);
1696
+ let oldValue = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1];
1697
+ this[state$6][_headersMap].set(key, ["" + name, oldValue ? `${oldValue}, ${newValue}` : newValue]);
2182
1698
  }
2183
1699
  delete(name) {
2184
1700
  let key = normalizeName(name, "delete");
2185
- this[state$2][_headersMap].delete(key);
1701
+ this[state$6][_headersMap].delete(key);
2186
1702
  }
2187
1703
  get(name) {
2188
1704
  var _b, _c;
2189
1705
  let key = normalizeName(name, "get");
2190
- return (_c = (_b = this[state$2][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : null;
1706
+ return (_c = (_b = this[state$6][_headersMap].get(key)) === null || _b === void 0 ? void 0 : _b[1]) !== null && _c !== void 0 ? _c : null;
2191
1707
  }
2192
1708
  getSetCookie() {
2193
1709
  let value = this.get("Set-Cookie");
@@ -2195,11 +1711,11 @@ class HeadersP {
2195
1711
  }
2196
1712
  has(name) {
2197
1713
  let key = normalizeName(name, "has");
2198
- return this[state$2][_headersMap].has(key);
1714
+ return this[state$6][_headersMap].has(key);
2199
1715
  }
2200
1716
  set(name, value) {
2201
1717
  let key = normalizeName(name, "set");
2202
- this[state$2][_headersMap].set(key, ["" + name, normalizeValue(value)]);
1718
+ this[state$6][_headersMap].set(key, ["" + name, normalizeValue(value)]);
2203
1719
  }
2204
1720
  forEach(callbackfn, thisArg) {
2205
1721
  Array.from(this.entries()).forEach(([name, value]) => {
@@ -2207,7 +1723,7 @@ class HeadersP {
2207
1723
  });
2208
1724
  }
2209
1725
  entries() {
2210
- return this[state$2][_headersMap].values();
1726
+ return this[state$6][_headersMap].values();
2211
1727
  }
2212
1728
  keys() {
2213
1729
  return Array.from(this.entries()).map(pair => pair[0]).values();
@@ -2221,16 +1737,74 @@ class HeadersP {
2221
1737
  toString() { return "[object Headers]"; }
2222
1738
  get isPolyfill() { return { symbol: polyfill, hierarchy: ["Headers"] }; }
2223
1739
  }
2224
- defineStringTag(HeadersP, "Headers");
1740
+ dfStringTag(HeadersP, "Headers");
2225
1741
  /** @internal */
2226
1742
  const _headersMap = Symbol();
2227
1743
  /** @internal */
2228
1744
  class HeadersState {
2229
1745
  constructor() {
2230
- this[_a] = new Map();
1746
+ this[_a$2] = new SimpleMap();
2231
1747
  }
2232
1748
  }
2233
- _a = _headersMap;
1749
+ _a$2 = _headersMap;
1750
+ /** @internal */
1751
+ class SimpleMap {
1752
+ constructor() {
1753
+ this.array = [];
1754
+ }
1755
+ get(key) {
1756
+ for (let i = 0; i < this.array.length; ++i) {
1757
+ let pair = this.array[i];
1758
+ if (pair[0] === key) {
1759
+ return pair[1];
1760
+ }
1761
+ }
1762
+ }
1763
+ set(key, value) {
1764
+ let index = -1;
1765
+ for (let i = 0; i < this.array.length; ++i) {
1766
+ let pair = this.array[i];
1767
+ if (pair[0] === key) {
1768
+ pair[1] = value;
1769
+ index = i;
1770
+ break;
1771
+ }
1772
+ }
1773
+ if (index === -1) {
1774
+ this.array.push([key, value]);
1775
+ }
1776
+ return this.array;
1777
+ }
1778
+ has(key) {
1779
+ for (let i = 0; i < this.array.length; ++i) {
1780
+ let pair = this.array[i];
1781
+ if (pair[0] === key) {
1782
+ return true;
1783
+ }
1784
+ }
1785
+ return false;
1786
+ }
1787
+ delete(key) {
1788
+ let index = -1;
1789
+ let array = [];
1790
+ for (let i = 0; i < this.array.length; ++i) {
1791
+ let pair = this.array[i];
1792
+ if (pair[0] === key) {
1793
+ index = i;
1794
+ continue;
1795
+ }
1796
+ array.push(pair);
1797
+ }
1798
+ if (index > -1) {
1799
+ this.array = array;
1800
+ }
1801
+ return index > -1;
1802
+ }
1803
+ values() {
1804
+ return this.array.map(x => x[1]).values();
1805
+ }
1806
+ }
1807
+ /** @internal */
2234
1808
  function normalizeName(name, kind = "") {
2235
1809
  if (typeof name !== "string") {
2236
1810
  name = String(name);
@@ -2242,12 +1816,14 @@ function normalizeName(name, kind = "") {
2242
1816
  }
2243
1817
  return name.toLowerCase();
2244
1818
  }
1819
+ /** @internal */
2245
1820
  function normalizeValue(value) {
2246
1821
  if (typeof value !== "string") {
2247
1822
  value = String(value);
2248
1823
  }
2249
1824
  return value;
2250
1825
  }
1826
+ /** @internal */
2251
1827
  function parseHeaders(rawHeaders) {
2252
1828
  let headers = new HeadersP();
2253
1829
  let preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
@@ -2274,13 +1850,34 @@ function parseHeaders(rawHeaders) {
2274
1850
  const HeadersE = g["Headers"] || HeadersP;
2275
1851
 
2276
1852
  /** @internal */
2277
- const state$1 = Symbol( /* "RequestState" */);
2278
- class RequestP extends BodyP {
1853
+ const state$5 = Symbol( /* "AbortControllerState" */);
1854
+ class AbortControllerP {
1855
+ constructor() {
1856
+ this[state$5] = new AbortControllerState();
1857
+ }
1858
+ get signal() { return this[state$5].signal; }
1859
+ abort(reason) {
1860
+ AbortSignal_abort(this[state$5].signal, reason);
1861
+ }
1862
+ toString() { return "[object AbortController]"; }
1863
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["AbortController"] }; }
1864
+ }
1865
+ dfStringTag(AbortControllerP, "AbortController");
1866
+ /** @internal */
1867
+ class AbortControllerState {
1868
+ constructor() {
1869
+ this.signal = createAbortSignal();
1870
+ }
1871
+ }
1872
+ const AbortControllerE = g["AbortController"] || AbortControllerP;
1873
+
1874
+ /** @internal */ const state$4 = Symbol( /* "RequestState" */);
1875
+ class RequestP extends BodyImpl {
2279
1876
  constructor(input, init) {
2280
1877
  super();
2281
- this[state$1] = new RequestState();
2282
- const that = this[state$1];
2283
- this[state$3][_name] = "Request";
1878
+ Body_setName(this, "Request");
1879
+ this[state$4] = new RequestState();
1880
+ const that = this[state$4];
2284
1881
  let options = init !== null && init !== void 0 ? init : {};
2285
1882
  let body = options.body;
2286
1883
  if (isPolyfillType("Request", input)) {
@@ -2293,15 +1890,15 @@ class RequestP extends BodyP {
2293
1890
  }
2294
1891
  that.method = input.method;
2295
1892
  that.mode = input.mode;
2296
- let inputSignal = input[state$1].signal;
1893
+ let inputSignal = input[state$4].signal;
2297
1894
  if (inputSignal) {
2298
1895
  that.signal = inputSignal;
2299
1896
  }
2300
1897
  that.url = input.url;
2301
- let _input = input;
2302
- if (!body && _input[state$3][_body] !== null) {
2303
- body = _input[state$3][_body];
2304
- _input[state$3].bodyUsed = true;
1898
+ let payload = Body_toPayload(input);
1899
+ if (!body && payload !== null) {
1900
+ body = payload;
1901
+ Body_setBodyUsed(input, true);
2305
1902
  }
2306
1903
  }
2307
1904
  else {
@@ -2325,7 +1922,7 @@ class RequestP extends BodyP {
2325
1922
  if ((this.method === "GET" || this.method === "HEAD") && body) {
2326
1923
  throw new TypeError("Failed to construct 'Request': Request with GET/HEAD method cannot have body.");
2327
1924
  }
2328
- initFn.call(this[state$3], body, this.headers);
1925
+ Body_init(this, body, this.headers);
2329
1926
  if (this.method === "GET" || this.method === "HEAD") {
2330
1927
  if (options.cache === "no-store" || options.cache === "no-cache") {
2331
1928
  // Search for a '_' parameter in the query string
@@ -2342,153 +1939,707 @@ class RequestP extends BodyP {
2342
1939
  }
2343
1940
  }
2344
1941
  }
2345
- get cache() { return this[state$1].cache; }
2346
- get credentials() { return this[state$1].credentials; }
2347
- get destination() { return this[state$1].destination; }
1942
+ get cache() { return this[state$4].cache; }
1943
+ get credentials() { return this[state$4].credentials; }
1944
+ get destination() { return this[state$4].destination; }
2348
1945
  get headers() {
2349
- const that = this[state$1];
1946
+ const that = this[state$4];
2350
1947
  if (!that.headers) {
2351
1948
  that.headers = new HeadersP();
2352
1949
  }
2353
- return that.headers;
1950
+ return that.headers;
1951
+ }
1952
+ get integrity() { return this[state$4].integrity; }
1953
+ get keepalive() { return this[state$4].keepalive; }
1954
+ get method() { return this[state$4].method; }
1955
+ get mode() { return this[state$4].mode; }
1956
+ get redirect() { return this[state$4].redirect; }
1957
+ get referrer() { return this[state$4].referrer; }
1958
+ get referrerPolicy() { return this[state$4].referrerPolicy; }
1959
+ get signal() {
1960
+ const that = this[state$4];
1961
+ if (!that.signal) {
1962
+ that.signal = (new AbortControllerP()).signal;
1963
+ }
1964
+ return that.signal;
1965
+ }
1966
+ get url() { return this[state$4].url; }
1967
+ clone() {
1968
+ var _a;
1969
+ return new RequestP(this, { body: (_a = Body_toPayload(this)) !== null && _a !== void 0 ? _a : null });
1970
+ }
1971
+ toString() { return "[object Request]"; }
1972
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
1973
+ }
1974
+ dfStringTag(RequestP, "Request");
1975
+ /** @internal */
1976
+ class RequestState {
1977
+ constructor() {
1978
+ this.cache = "default";
1979
+ this.credentials = "same-origin";
1980
+ this.destination = "";
1981
+ this.integrity = "";
1982
+ this.keepalive = false;
1983
+ this.method = "GET";
1984
+ this.mode = "cors";
1985
+ this.redirect = "follow";
1986
+ this.referrer = "about:client";
1987
+ this.referrerPolicy = "";
1988
+ this.url = "";
1989
+ }
1990
+ }
1991
+ // HTTP methods whose capitalization should be normalized
1992
+ const methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
1993
+ /** @internal */
1994
+ function normalizeMethod(method) {
1995
+ let upcased = method.toUpperCase();
1996
+ return methods.indexOf(upcased) > -1 ? upcased : method;
1997
+ }
1998
+ const RequestE = g["Request"] || RequestP;
1999
+
2000
+ /** @internal */ const state$3 = Symbol( /* "ResponseState" */);
2001
+ class ResponseP extends BodyImpl {
2002
+ constructor(body, init) {
2003
+ super();
2004
+ Body_setName(this, "Response");
2005
+ this[state$3] = new ResponseState();
2006
+ const that = this[state$3];
2007
+ let options = init !== null && init !== void 0 ? init : {};
2008
+ let status = options.status === undefined ? 200 : options.status;
2009
+ if (status < 200 || status > 500) {
2010
+ throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
2011
+ }
2012
+ if (options.headers) {
2013
+ that.headers = new HeadersP(options.headers);
2014
+ }
2015
+ that.ok = this.status >= 200 && this.status < 300;
2016
+ that.status = status;
2017
+ that.statusText = options.statusText === undefined ? "" : "" + options.statusText;
2018
+ Body_init(this, body, this.headers);
2019
+ }
2020
+ get headers() {
2021
+ const that = this[state$3];
2022
+ if (!that.headers) {
2023
+ that.headers = new HeadersP();
2024
+ }
2025
+ return that.headers;
2026
+ }
2027
+ get ok() { return this[state$3].ok; }
2028
+ get redirected() { return this[state$3].redirected; }
2029
+ get status() { return this[state$3].status; }
2030
+ get statusText() { return this[state$3].statusText; }
2031
+ get type() { return this[state$3].type; }
2032
+ get url() { return this[state$3].url; }
2033
+ clone() {
2034
+ let response = new ResponseP(Body_toPayload(this), {
2035
+ headers: new HeadersP(this.headers),
2036
+ status: this.status,
2037
+ statusText: this.statusText,
2038
+ });
2039
+ response[state$3].url = this.url;
2040
+ return response;
2041
+ }
2042
+ static json(data, init) {
2043
+ return new ResponseP(JSON.stringify(data), init);
2044
+ }
2045
+ static error() {
2046
+ let response = new ResponseP(null, { status: 200, statusText: "" });
2047
+ response[state$3].ok = false;
2048
+ response[state$3].status = 0;
2049
+ response[state$3].type = "error";
2050
+ return response;
2051
+ }
2052
+ static redirect(url, status = 301) {
2053
+ if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
2054
+ throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
2055
+ }
2056
+ return new ResponseP(null, { status, headers: { location: String(url) } });
2057
+ }
2058
+ toString() { return "[object Response]"; }
2059
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
2060
+ }
2061
+ dfStringTag(ResponseP, "Response");
2062
+ /** @internal */
2063
+ class ResponseState {
2064
+ constructor() {
2065
+ this.ok = true;
2066
+ this.redirected = false;
2067
+ this.status = 200;
2068
+ this.statusText = "";
2069
+ this.type = "default";
2070
+ this.url = "";
2071
+ }
2072
+ }
2073
+ const ResponseE = g["Response"] || ResponseP;
2074
+
2075
+ var _a$1;
2076
+ /** @internal */ const state$2 = Symbol( /* "XMLHttpRequestEventTargetState" */);
2077
+ class XMLHttpRequestEventTargetP extends EventTargetP {
2078
+ constructor() {
2079
+ if (new.target === XMLHttpRequestEventTargetP) {
2080
+ throw new TypeError("Failed to construct 'XMLHttpRequestEventTarget': Illegal constructor");
2081
+ }
2082
+ super();
2083
+ this[state$2] = new XMLHttpRequestEventTargetState(this);
2084
+ }
2085
+ get onabort() { return this[state$2].onabort; }
2086
+ set onabort(value) { this[state$2].onabort = value; attach(this, "abort"); }
2087
+ get onerror() { return this[state$2].onerror; }
2088
+ set onerror(value) { this[state$2].onerror = value; attach(this, "error"); }
2089
+ get onload() { return this[state$2].onload; }
2090
+ set onload(value) { this[state$2].onload = value; attach(this, "load"); }
2091
+ get onloadend() { return this[state$2].onloadend; }
2092
+ set onloadend(value) { this[state$2].onloadend = value; attach(this, "loadend"); }
2093
+ get onloadstart() { return this[state$2].onloadstart; }
2094
+ set onloadstart(value) { this[state$2].onloadstart = value; attach(this, "loadstart"); }
2095
+ get onprogress() { return this[state$2].onprogress; }
2096
+ set onprogress(value) { this[state$2].onprogress = value; attach(this, "progress"); }
2097
+ get ontimeout() { return this[state$2].ontimeout; }
2098
+ set ontimeout(value) { this[state$2].ontimeout = value; attach(this, "timeout"); }
2099
+ toString() { return "[object XMLHttpRequestEventTarget]"; }
2100
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestEventTarget", "EventTarget"] }; }
2101
+ }
2102
+ dfStringTag(XMLHttpRequestEventTargetP, "XMLHttpRequestEventTarget");
2103
+ /** @internal */
2104
+ const _handlers$1 = Symbol();
2105
+ /** @internal */
2106
+ class XMLHttpRequestEventTargetState {
2107
+ /**
2108
+ * @param _target XMLHttpRequestEventTarget
2109
+ */
2110
+ constructor(_target) {
2111
+ this[_a$1] = getHandlers$1(this);
2112
+ this.onabort = null;
2113
+ this.onerror = null;
2114
+ this.onload = null;
2115
+ this.onloadend = null;
2116
+ this.onloadstart = null;
2117
+ this.onprogress = null;
2118
+ this.ontimeout = null;
2119
+ this.target = _target;
2120
+ }
2121
+ }
2122
+ _a$1 = _handlers$1;
2123
+ function attach(target, type) {
2124
+ const s = target[state$2];
2125
+ const fnName = ("on" + type);
2126
+ const cb = s[fnName];
2127
+ const listener = s[_handlers$1][fnName];
2128
+ attachFn(target, type, cb, listener);
2129
+ }
2130
+ function getHandlers$1(s) {
2131
+ return {
2132
+ onabort: (ev) => { executeFn(s.target, s.onabort, ev); },
2133
+ onerror: (ev) => { executeFn(s.target, s.onerror, ev); },
2134
+ onload: (ev) => { executeFn(s.target, s.onload, ev); },
2135
+ onloadend: (ev) => { executeFn(s.target, s.onloadend, ev); },
2136
+ onloadstart: (ev) => { executeFn(s.target, s.onloadstart, ev); },
2137
+ onprogress: (ev) => { executeFn(s.target, s.onprogress, ev); },
2138
+ ontimeout: (ev) => { executeFn(s.target, s.ontimeout, ev); },
2139
+ };
2140
+ }
2141
+
2142
+ class XMLHttpRequestUploadP extends XMLHttpRequestEventTargetP {
2143
+ constructor() {
2144
+ if (new.target === XMLHttpRequestUploadP) {
2145
+ throw new TypeError("Failed to construct 'XMLHttpRequestUpload': Illegal constructor");
2146
+ }
2147
+ super();
2148
+ }
2149
+ toString() { return "[object XMLHttpRequestUpload]"; }
2150
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequestUpload", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2151
+ }
2152
+ dfStringTag(XMLHttpRequestUploadP, "XMLHttpRequestUpload");
2153
+ /** @internal */
2154
+ function createXMLHttpRequestUpload() {
2155
+ let upload = Object.create(XMLHttpRequestUploadP.prototype);
2156
+ upload[state$d] = new EventTargetState(upload);
2157
+ upload[state$2] = new XMLHttpRequestEventTargetState(upload);
2158
+ return upload;
2159
+ }
2160
+
2161
+ // @ts-nocheck
2162
+ /** @internal */
2163
+ const mp$2 = (() => {
2164
+ let u = "undefined", r = "request", f = "function";
2165
+ let mp;
2166
+ mp =
2167
+ (typeof wx !== u && typeof (wx === null || wx === void 0 ? void 0 : wx[r]) === f && wx) || // 微信
2168
+ (typeof my !== u && typeof (my === null || my === void 0 ? void 0 : my[r]) === f && my) || // 支付宝
2169
+ (typeof qq !== u && typeof (qq === null || qq === void 0 ? void 0 : qq[r]) === f && qq) || // QQ
2170
+ (typeof jd !== u && typeof (jd === null || jd === void 0 ? void 0 : jd[r]) === f && jd) || // 京东
2171
+ (typeof swan !== u && typeof (swan === null || swan === void 0 ? void 0 : swan[r]) === f && swan) || // 百度
2172
+ (typeof tt !== u && typeof (tt === null || tt === void 0 ? void 0 : tt[r]) === f && tt) || // 抖音 | 飞书
2173
+ (typeof ks !== u && typeof (ks === null || ks === void 0 ? void 0 : ks[r]) === f && ks) || // 快手
2174
+ (typeof qh !== u && typeof (qh === null || qh === void 0 ? void 0 : qh[r]) === f && qh) || // 360
2175
+ (typeof xhs !== u && typeof (xhs === null || xhs === void 0 ? void 0 : xhs[r]) === f && xhs) || // 小红书
2176
+ undefined;
2177
+ if (typeof g["XMLHttpRequest"] === f) {
2178
+ return;
2179
+ }
2180
+ if (mp === undefined)
2181
+ mp =
2182
+ (typeof uni !== u && typeof (uni === null || uni === void 0 ? void 0 : uni[r]) === f && uni) || // UniApp
2183
+ (typeof Taro !== u && typeof (Taro === null || Taro === void 0 ? void 0 : Taro[r]) === f && Taro) || // Taro
2184
+ undefined;
2185
+ return mp;
2186
+ })();
2187
+
2188
+ const request = mp$2 ? mp$2.request : function errorRequest(options) {
2189
+ const errMsg = "NOT_SUPPORTED_ERR";
2190
+ const errno = 9;
2191
+ const err = {
2192
+ errMsg,
2193
+ errno,
2194
+ exception: {
2195
+ retryCount: 0,
2196
+ reasons: [{ errMsg, errno }],
2197
+ },
2198
+ useHttpDNS: false,
2199
+ };
2200
+ Promise.resolve(err)
2201
+ .then(err => { try {
2202
+ if (options.fail) {
2203
+ options.fail(err);
2204
+ }
2205
+ }
2206
+ catch (e) {
2207
+ console.error(e);
2208
+ } })
2209
+ .then(() => { if (options.complete) {
2210
+ options.complete(err);
2211
+ } });
2212
+ throw new ReferenceError("request is not defined");
2213
+ };
2214
+
2215
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2216
+ const mp$1 = { request: request };
2217
+ const setRequest = (request) => { mp$1.request = request; };
2218
+ /** @internal */ const state$1 = Symbol( /* "XMLHttpRequestState" */);
2219
+ class XMLHttpRequestP extends XMLHttpRequestEventTargetP {
2220
+ constructor() {
2221
+ super();
2222
+ this[state$1] = new XMLHttpRequestState(this);
2223
+ }
2224
+ get readyState() { return this[state$1].readyState; }
2225
+ get response() { return this[state$1].response; }
2226
+ get responseText() { return (!this.responseType || this.responseType === "text") ? this.response : ""; }
2227
+ get responseType() { return this[state$1].responseType; }
2228
+ set responseType(value) { this[state$1].responseType = normalizeResponseType(value); }
2229
+ get responseURL() { return this[state$1].responseURL; }
2230
+ get responseXML() { return null; }
2231
+ get status() { return this[state$1].status; }
2232
+ get statusText() {
2233
+ if (this.readyState === XMLHttpRequestP.UNSENT || this.readyState === XMLHttpRequestP.OPENED)
2234
+ return "";
2235
+ return this[state$1].statusText || statusTextMap(this.status);
2236
+ }
2237
+ get timeout() { return this[state$1].timeout; }
2238
+ set timeout(value) { this[state$1].timeout = value > 0 ? value : 0; }
2239
+ get upload() {
2240
+ const that = this[state$1];
2241
+ if (!that.upload) {
2242
+ that.upload = createXMLHttpRequestUpload();
2243
+ }
2244
+ return that.upload;
2245
+ }
2246
+ get withCredentials() { return this[state$1].withCredentials; }
2247
+ set withCredentials(value) { this[state$1].withCredentials = !!value; }
2248
+ abort() {
2249
+ clearRequest(this);
2250
+ }
2251
+ getAllResponseHeaders() {
2252
+ if (!this[state$1][_responseHeaders])
2253
+ return "";
2254
+ return Array.from(this[state$1][_responseHeaders].entries()).map(([k, v]) => `${k}: ${v}\r\n`).join("");
2255
+ }
2256
+ getResponseHeader(name) {
2257
+ if (!this[state$1][_responseHeaders])
2258
+ return null;
2259
+ return this[state$1][_responseHeaders].get(name);
2260
+ }
2261
+ open(...args) {
2262
+ const [method, url, async = true, username = null, password = null] = args;
2263
+ const that = this[state$1];
2264
+ if (args.length < 2) {
2265
+ throw new TypeError(`Failed to execute 'open' on 'XMLHttpRequest': 2 arguments required, but only ${args.length} present.`);
2266
+ }
2267
+ if (!async) {
2268
+ console.warn("Synchronous XMLHttpRequest is not supported because of its detrimental effects to the end user's experience.");
2269
+ }
2270
+ clearRequest(this, false);
2271
+ that[_method] = normalizeMethod(method);
2272
+ that[_requestURL] = String(url);
2273
+ if (username !== null || password !== null) {
2274
+ let _username = String(username !== null && username !== void 0 ? username : "");
2275
+ let _password = String(password !== null && password !== void 0 ? password : "");
2276
+ if (_username.length > 0 || _password.length > 0) {
2277
+ let auth = `Basic ${Uint8Array_toBase64((new TextEncoderP()).encode(_username + ":" + _password))}`;
2278
+ this.setRequestHeader("Authorization", auth);
2279
+ }
2280
+ }
2281
+ that[_inAfterOpenBeforeSend] = true;
2282
+ setReadyStateAndNotify(this, XMLHttpRequestP.OPENED);
2283
+ }
2284
+ overrideMimeType(mime) {
2285
+ if (this[state$1][_inAfterOpenBeforeSend]) {
2286
+ console.warn(`XMLHttpRequest.overrideMimeType('${mime}') is not implemented: The method will have no effect on response parsing.`);
2287
+ }
2288
+ }
2289
+ send(body) {
2290
+ const that = this[state$1];
2291
+ if (!that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED) {
2292
+ throw new MPException("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.", "InvalidStateError");
2293
+ }
2294
+ that[_inAfterOpenBeforeSend] = false;
2295
+ const allowsRequestBody = that[_method] !== "GET" && that[_method] !== "HEAD";
2296
+ const processHeaders = allowsRequestBody && !that[_requestHeaders].has("Content-Type");
2297
+ const upload = that.upload;
2298
+ const processContentLength = upload && EventTarget_count(upload) > 0;
2299
+ let headers = () => Array.from(that[_requestHeaders].entries())
2300
+ .reduce((acc, cur) => { acc[cur[0]] = cur[1]; return acc; }, {});
2301
+ let contentLength = zero;
2302
+ const processHeadersFn = processHeaders ? (v) => { that[_requestHeaders].set("Content-Type", v); } : void 0;
2303
+ const processContentLengthFn = processContentLength ? (v) => { contentLength = v; } : void 0;
2304
+ let data = body;
2305
+ try {
2306
+ data = convert(body, processHeadersFn, processContentLengthFn);
2307
+ }
2308
+ catch (e) {
2309
+ console.warn(e);
2310
+ }
2311
+ let options = {
2312
+ url: that[_requestURL],
2313
+ method: that[_method],
2314
+ header: headers(),
2315
+ data,
2316
+ dataType: that.responseType === "json" ? "json" : normalizeDataType(that.responseType),
2317
+ responseType: normalizeDataType(that.responseType),
2318
+ withCredentials: that.withCredentials,
2319
+ success: requestSuccess.bind(this),
2320
+ fail: requestFail.bind(this),
2321
+ complete: requestComplete.bind(this),
2322
+ };
2323
+ that[_requestTask] = mp$1.request(options);
2324
+ emitProcessEvent(this, "loadstart");
2325
+ if (processContentLength) {
2326
+ const hasRequestBody = allowsRequestBody && !!data;
2327
+ if (hasRequestBody) {
2328
+ emitProcessEvent(upload, "loadstart", 0, contentLength);
2329
+ }
2330
+ setTimeout(() => {
2331
+ const _aborted = that[_inAfterOpenBeforeSend] || that.readyState !== XMLHttpRequestP.OPENED;
2332
+ const _contentLength = _aborted ? 0 : contentLength;
2333
+ if (_aborted) {
2334
+ emitProcessEvent(upload, "abort");
2335
+ }
2336
+ else {
2337
+ if (hasRequestBody) {
2338
+ emitProcessEvent(upload, "load", _contentLength, _contentLength);
2339
+ }
2340
+ }
2341
+ if (_aborted || hasRequestBody) {
2342
+ emitProcessEvent(upload, "loadend", _contentLength, _contentLength);
2343
+ }
2344
+ });
2345
+ }
2346
+ checkRequestTimeout(this);
2354
2347
  }
2355
- get integrity() { return this[state$1].integrity; }
2356
- get keepalive() { return this[state$1].keepalive; }
2357
- get method() { return this[state$1].method; }
2358
- get mode() { return this[state$1].mode; }
2359
- get redirect() { return this[state$1].redirect; }
2360
- get referrer() { return this[state$1].referrer; }
2361
- get referrerPolicy() { return this[state$1].referrerPolicy; }
2362
- get signal() {
2363
- const that = this[state$1];
2364
- if (!that.signal) {
2365
- that.signal = (new AbortControllerP()).signal;
2366
- }
2367
- return that.signal;
2348
+ setRequestHeader(name, value) {
2349
+ this[state$1][_requestHeaders].append(name, value);
2368
2350
  }
2369
- get url() { return this[state$1].url; }
2370
- clone() {
2371
- var _a;
2372
- return new RequestP(this, { body: (_a = this[state$3][_body]) !== null && _a !== void 0 ? _a : null });
2351
+ get onreadystatechange() { return this[state$1].onreadystatechange; }
2352
+ set onreadystatechange(value) {
2353
+ this[state$1].onreadystatechange = value;
2354
+ attachFn(this, "readystatechange", value, this[state$1][_handlers].onreadystatechange);
2373
2355
  }
2374
- toString() { return "[object Request]"; }
2375
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Request", "Body"] }; }
2356
+ toString() { return "[object XMLHttpRequest]"; }
2357
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["XMLHttpRequest", "XMLHttpRequestEventTarget", "EventTarget"] }; }
2376
2358
  }
2377
- defineStringTag(RequestP, "Request");
2359
+ const properties = {
2360
+ UNSENT: { value: 0, enumerable: true },
2361
+ OPENED: { value: 1, enumerable: true },
2362
+ HEADERS_RECEIVED: { value: 2, enumerable: true },
2363
+ LOADING: { value: 3, enumerable: true },
2364
+ DONE: { value: 4, enumerable: true },
2365
+ };
2366
+ Object.defineProperties(XMLHttpRequestP, properties);
2367
+ Object.defineProperties(XMLHttpRequestP.prototype, properties);
2368
+ dfStringTag(XMLHttpRequestP, "XMLHttpRequest");
2369
+ /** @internal */ const _handlers = Symbol();
2370
+ /** @internal */ const _inAfterOpenBeforeSend = Symbol();
2371
+ /** @internal */ const _resetPending = Symbol();
2372
+ /** @internal */ const _timeoutId = Symbol();
2373
+ /** @internal */ const _requestURL = Symbol();
2374
+ /** @internal */ const _method = Symbol();
2375
+ /** @internal */ const _requestHeaders = Symbol();
2376
+ /** @internal */ const _responseHeaders = Symbol();
2377
+ /** @internal */ const _responseContentLength = Symbol();
2378
+ /** @internal */ const _requestTask = Symbol();
2378
2379
  /** @internal */
2379
- class RequestState {
2380
- constructor() {
2381
- this.cache = "default";
2382
- this.credentials = "same-origin";
2383
- this.destination = "";
2384
- this.integrity = "";
2385
- this.keepalive = false;
2386
- this.method = "GET";
2387
- this.mode = "cors";
2388
- this.redirect = "follow";
2389
- this.referrer = "about:client";
2390
- this.referrerPolicy = "";
2391
- this.url = "";
2380
+ class XMLHttpRequestState {
2381
+ constructor(target) {
2382
+ this.readyState = XMLHttpRequestP.UNSENT;
2383
+ this.response = "";
2384
+ this.responseType = "";
2385
+ this.responseURL = "";
2386
+ this.status = 0;
2387
+ this.statusText = "";
2388
+ this.timeout = 0;
2389
+ this.withCredentials = false;
2390
+ this[_a] = getHandlers(this);
2391
+ this.onreadystatechange = null;
2392
+ this[_b] = false;
2393
+ this[_c] = false;
2394
+ this[_d] = 0;
2395
+ this[_e] = "";
2396
+ this[_f] = "GET";
2397
+ this[_g] = new HeadersP();
2398
+ this[_h] = null;
2399
+ this[_j] = zero;
2400
+ this[_k] = null;
2401
+ this.target = target;
2392
2402
  }
2393
2403
  }
2394
- const RequestE = g["Request"] || RequestP;
2395
-
2396
- /** @internal */
2397
- const state = Symbol( /* "ResponseState" */);
2398
- class ResponseP extends BodyP {
2399
- constructor(body, init) {
2400
- super();
2401
- this[state] = new ResponseState();
2402
- const that = this[state];
2403
- this[state$3][_name] = "Response";
2404
- let options = init !== null && init !== void 0 ? init : {};
2405
- let status = options.status === undefined ? 200 : options.status;
2406
- if (status < 200 || status > 500) {
2407
- throw new RangeError(`Failed to construct 'Response': The status provided (${+status}) is outside the range [200, 599].`);
2408
- }
2409
- if (options.headers) {
2410
- that.headers = new HeadersP(options.headers);
2411
- }
2412
- that.ok = this.status >= 200 && this.status < 300;
2413
- that.status = status;
2414
- that.statusText = options.statusText === undefined ? "" : "" + options.statusText;
2415
- initFn.call(this[state$3], body, this.headers);
2416
- }
2417
- get headers() {
2418
- const that = this[state];
2419
- if (!that.headers) {
2420
- that.headers = new HeadersP();
2421
- }
2422
- return that.headers;
2423
- }
2424
- get ok() { return this[state].ok; }
2425
- get redirected() { return this[state].redirected; }
2426
- get status() { return this[state].status; }
2427
- get statusText() { return this[state].statusText; }
2428
- get type() { return this[state].type; }
2429
- get url() { return this[state].url; }
2430
- clone() {
2431
- let response = new ResponseP(this[state$3][_body], {
2432
- headers: new HeadersP(this.headers),
2433
- status: this.status,
2434
- statusText: this.statusText,
2404
+ _a = _handlers, _b = _inAfterOpenBeforeSend, _c = _resetPending, _d = _timeoutId, _e = _requestURL, _f = _method, _g = _requestHeaders, _h = _responseHeaders, _j = _responseContentLength, _k = _requestTask;
2405
+ function requestSuccess({ statusCode, header, data }) {
2406
+ const s = this[state$1];
2407
+ s.responseURL = s[_requestURL];
2408
+ s.status = statusCode;
2409
+ s[_responseHeaders] = new HeadersP(header);
2410
+ let lengthStr = s[_responseHeaders].get("Content-Length");
2411
+ s[_responseContentLength] = () => { return lengthStr ? parseInt(lengthStr) : 0; };
2412
+ if (s.readyState === XMLHttpRequestP.OPENED) {
2413
+ setReadyStateAndNotify(this, XMLHttpRequestP.HEADERS_RECEIVED);
2414
+ setReadyStateAndNotify(this, XMLHttpRequestP.LOADING);
2415
+ setTimeout(() => {
2416
+ if (!s[_inAfterOpenBeforeSend]) {
2417
+ let l = s[_responseContentLength];
2418
+ try {
2419
+ s.response = convertBack(s.responseType, data);
2420
+ emitProcessEvent(this, "load", l, l);
2421
+ }
2422
+ catch (e) {
2423
+ console.error(e);
2424
+ emitProcessEvent(this, "error");
2425
+ }
2426
+ }
2435
2427
  });
2436
- response[state].url = this.url;
2437
- return response;
2438
2428
  }
2439
- static json(data, init) {
2440
- return new Response(JSON.stringify(data), init);
2429
+ }
2430
+ function requestFail(err) {
2431
+ // Alipay Mini Programs
2432
+ // error: 14 --- JSON parse data error
2433
+ // error: 19 --- http status error
2434
+ // At this point, the error data object will contain three pieces of information
2435
+ // returned from the server: status, headers, and data.
2436
+ // In the browser's XMLHttpRequest, these two errors (Error 14 and Error 19)
2437
+ // differ from those in Alipay Mini Programs and should instead return normally.
2438
+ // Therefore, this scenario is also handled here as a successful request response.
2439
+ if ("status" in err) {
2440
+ requestSuccess.call(this, { statusCode: err.status, header: err.headers, data: err.data });
2441
+ return;
2441
2442
  }
2442
- static error() {
2443
- let response = new ResponseP(null, { status: 200, statusText: "" });
2444
- response[state].ok = false;
2445
- response[state].status = 0;
2446
- response[state].type = "error";
2447
- return response;
2443
+ const s = this[state$1];
2444
+ s.status = 0;
2445
+ s.statusText = "errMsg" in err ? err.errMsg : "errorMessage" in err ? err.errorMessage : "";
2446
+ if (!s[_inAfterOpenBeforeSend] && s.readyState !== XMLHttpRequestP.UNSENT && s.readyState !== XMLHttpRequestP.DONE) {
2447
+ emitProcessEvent(this, "error");
2448
+ resetRequestTimeout(this);
2448
2449
  }
2449
- static redirect(url, status = 301) {
2450
- if ([301, 302, 303, 307, 308].indexOf(status) === -1) {
2451
- throw new RangeError("Failed to execute 'redirect' on 'Response': Invalid status code");
2450
+ }
2451
+ function requestComplete() {
2452
+ const s = this[state$1];
2453
+ s[_requestTask] = null;
2454
+ if (!s[_inAfterOpenBeforeSend] && (s.readyState === XMLHttpRequestP.OPENED || s.readyState === XMLHttpRequestP.LOADING)) {
2455
+ setReadyStateAndNotify(this, XMLHttpRequestP.DONE);
2456
+ }
2457
+ setTimeout(() => {
2458
+ if (!s[_inAfterOpenBeforeSend]) {
2459
+ let l = s[_responseContentLength];
2460
+ emitProcessEvent(this, "loadend", l, l);
2461
+ }
2462
+ });
2463
+ }
2464
+ function clearRequest(xhr, delay = true) {
2465
+ const s = xhr[state$1];
2466
+ const timerFn = delay ? setTimeout : (f) => { f(); };
2467
+ s[_resetPending] = true;
2468
+ if (s[_requestTask] && s.readyState !== XMLHttpRequestP.DONE) {
2469
+ if (delay) {
2470
+ setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
2452
2471
  }
2453
- return new Response(null, { status, headers: { location: String(url) } });
2472
+ timerFn(() => {
2473
+ const requestTask = s[_requestTask];
2474
+ if (requestTask) {
2475
+ requestTask.abort();
2476
+ }
2477
+ if (delay) {
2478
+ emitProcessEvent(xhr, "abort");
2479
+ }
2480
+ if (delay && !requestTask) {
2481
+ emitProcessEvent(xhr, "loadend");
2482
+ }
2483
+ });
2454
2484
  }
2455
- toString() { return "[object Response]"; }
2456
- get isPolyfill() { return { symbol: polyfill, hierarchy: ["Response", "Body"] }; }
2485
+ timerFn(() => {
2486
+ if (s[_resetPending]) {
2487
+ if (delay) {
2488
+ s.readyState = XMLHttpRequestP.UNSENT;
2489
+ }
2490
+ resetXHR(xhr);
2491
+ }
2492
+ });
2457
2493
  }
2458
- defineStringTag(ResponseP, "Response");
2459
- /** @internal */
2460
- class ResponseState {
2461
- constructor() {
2462
- this.ok = true;
2463
- this.redirected = false;
2464
- this.status = 200;
2465
- this.statusText = "";
2466
- this.type = "default";
2467
- this.url = "";
2494
+ function checkRequestTimeout(xhr) {
2495
+ const s = xhr[state$1];
2496
+ if (s.timeout) {
2497
+ s[_timeoutId] = setTimeout(() => {
2498
+ if (!s.status && s.readyState !== XMLHttpRequestP.DONE) {
2499
+ if (s[_requestTask])
2500
+ s[_requestTask].abort();
2501
+ setReadyStateAndNotify(xhr, XMLHttpRequestP.DONE);
2502
+ emitProcessEvent(xhr, "timeout");
2503
+ }
2504
+ }, s.timeout);
2505
+ }
2506
+ }
2507
+ function resetXHR(xhr) {
2508
+ const s = xhr[state$1];
2509
+ s[_resetPending] = false;
2510
+ resetRequestTimeout(xhr);
2511
+ s.response = "";
2512
+ s.responseURL = "";
2513
+ s.status = 0;
2514
+ s.statusText = "";
2515
+ s[_requestHeaders] = new HeadersP();
2516
+ s[_responseHeaders] = null;
2517
+ s[_responseContentLength] = zero;
2518
+ }
2519
+ function resetRequestTimeout(xhr) {
2520
+ const s = xhr[state$1];
2521
+ if (s[_timeoutId]) {
2522
+ clearTimeout(s[_timeoutId]);
2523
+ s[_timeoutId] = 0;
2524
+ }
2525
+ }
2526
+ function setReadyStateAndNotify(xhr, value) {
2527
+ const s = xhr[state$1];
2528
+ let hasChanged = value !== s.readyState;
2529
+ s.readyState = value;
2530
+ if (hasChanged) {
2531
+ let evt = createInnerEvent(xhr, "readystatechange");
2532
+ EventTarget_fire(xhr, evt);
2468
2533
  }
2469
2534
  }
2470
- const ResponseE = g["Response"] || ResponseP;
2535
+ function getHandlers(s) {
2536
+ return {
2537
+ onreadystatechange: (ev) => { executeFn(s.target, s.onreadystatechange, ev); },
2538
+ };
2539
+ }
2540
+ const responseTypes = ["", "text", "json", "arraybuffer", "blob", "document"];
2541
+ function normalizeResponseType(responseType) {
2542
+ return responseTypes.indexOf(responseType) > -1 ? responseType : "";
2543
+ }
2544
+ function normalizeDataType(responseType) {
2545
+ return (responseType === "blob" || responseType === "arraybuffer") ? "arraybuffer" : "text";
2546
+ }
2547
+ function getAllResponseHeaders(xhr) {
2548
+ return xhr instanceof XMLHttpRequestP
2549
+ ? xhr[state$1][_responseHeaders]
2550
+ : parseHeaders(xhr.getAllResponseHeaders() || "");
2551
+ }
2552
+ const zero = () => 0;
2553
+ const statusMessages = {
2554
+ 100: "Continue",
2555
+ 101: "Switching Protocols",
2556
+ 102: "Processing",
2557
+ 103: "Early Hints",
2558
+ 200: "OK",
2559
+ 201: "Created",
2560
+ 202: "Accepted",
2561
+ 203: "Non-Authoritative Information",
2562
+ 204: "No Content",
2563
+ 205: "Reset Content",
2564
+ 206: "Partial Content",
2565
+ 207: "Multi-Status",
2566
+ 208: "Already Reported",
2567
+ 226: "IM Used",
2568
+ 300: "Multiple Choices",
2569
+ 301: "Moved Permanently",
2570
+ 302: "Found",
2571
+ 303: "See Other",
2572
+ 304: "Not Modified",
2573
+ 307: "Temporary Redirect",
2574
+ 308: "Permanent Redirect",
2575
+ 400: "Bad Request",
2576
+ 401: "Unauthorized",
2577
+ 402: "Payment Required",
2578
+ 403: "Forbidden",
2579
+ 404: "Not Found",
2580
+ 405: "Method Not Allowed",
2581
+ 406: "Not Acceptable",
2582
+ 407: "Proxy Authentication Required",
2583
+ 408: "Request Timeout",
2584
+ 409: "Conflict",
2585
+ 410: "Gone",
2586
+ 411: "Length Required",
2587
+ 412: "Precondition Failed",
2588
+ 413: "Content Too Large",
2589
+ 414: "URI Too Long",
2590
+ 415: "Unsupported Media Type",
2591
+ 416: "Range Not Satisfiable",
2592
+ 417: "Expectation Failed",
2593
+ 418: "I'm a teapot",
2594
+ 421: "Misdirected Request",
2595
+ 422: "Unprocessable Entity",
2596
+ 423: "Locked",
2597
+ 424: "Failed Dependency",
2598
+ 425: "Too Early",
2599
+ 426: "Upgrade Required",
2600
+ 428: "Precondition Required",
2601
+ 429: "Too Many Requests",
2602
+ 431: "Request Header Fields Too Large",
2603
+ 451: "Unavailable For Legal Reasons",
2604
+ 500: "Internal Server Error",
2605
+ 501: "Not Implemented",
2606
+ 502: "Bad Gateway",
2607
+ 503: "Service Unavailable",
2608
+ 504: "Gateway Timeout",
2609
+ 505: "HTTP Version Not Supported",
2610
+ 506: "Variant Also Negotiates",
2611
+ 507: "Insufficient Storage",
2612
+ 508: "Loop Detected",
2613
+ 510: "Not Extended",
2614
+ 511: "Network Authentication Required"
2615
+ };
2616
+ function statusTextMap(val) {
2617
+ return statusMessages[val] || "unknown";
2618
+ }
2619
+ const XMLHttpRequestE = (typeof XMLHttpRequest !== "undefined" && XMLHttpRequest) || XMLHttpRequestP;
2471
2620
 
2621
+ const mp = { XMLHttpRequest: XMLHttpRequestE };
2622
+ const setXMLHttpRequest = (XHR) => { mp.XMLHttpRequest = XHR; };
2472
2623
  function fetchP(input, init) {
2473
2624
  if (new.target === fetchP) {
2474
2625
  throw new TypeError("fetch is not a constructor");
2475
2626
  }
2476
2627
  return new Promise(function (resolve, reject) {
2477
2628
  const request = new RequestP(input, init);
2478
- const signal = request[state$1].signal;
2629
+ const signal = request[state$4].signal;
2479
2630
  if (signal && signal.aborted) {
2480
2631
  return reject(signal.reason);
2481
2632
  }
2482
- let xhr = new XMLHttpRequestE();
2633
+ let xhr = new mp.XMLHttpRequest();
2483
2634
  xhr.onload = function () {
2484
2635
  let options = {
2485
- headers: xhr instanceof XMLHttpRequestP ? (new HeadersP(xhr[state$4][_responseHeaders] || undefined)) : parseHeaders(xhr.getAllResponseHeaders() || ""),
2636
+ headers: getAllResponseHeaders(xhr),
2486
2637
  status: xhr.status,
2487
2638
  statusText: xhr.statusText,
2488
2639
  };
2489
2640
  setTimeout(() => {
2490
2641
  let response = new ResponseP(xhr.response, options);
2491
- response[state].url = xhr.responseURL;
2642
+ response[state$3].url = xhr.responseURL;
2492
2643
  resolve(response);
2493
2644
  });
2494
2645
  };
@@ -2542,7 +2693,7 @@ function fetchP(input, init) {
2542
2693
  }
2543
2694
  };
2544
2695
  }
2545
- xhr.send(request[state$3][_body]);
2696
+ xhr.send(Body_toPayload(request));
2546
2697
  });
2547
2698
  }
2548
2699
  function isObjectHeaders(val) {
@@ -2550,4 +2701,30 @@ function isObjectHeaders(val) {
2550
2701
  }
2551
2702
  const fetchE = g["fetch"] || fetchP;
2552
2703
 
2553
- 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 };
2704
+ const dispatched = 1;
2705
+ /** @internal */
2706
+ const state = Symbol( /* "CustomEventState" */);
2707
+ class CustomEventP extends EventP {
2708
+ constructor(type, eventInitDict) {
2709
+ var _a;
2710
+ super(type, eventInitDict);
2711
+ this[state] = new CustomEventState();
2712
+ this[state].detail = (_a = eventInitDict === null || eventInitDict === void 0 ? void 0 : eventInitDict.detail) !== null && _a !== void 0 ? _a : null;
2713
+ }
2714
+ get detail() { return this[state].detail; }
2715
+ initCustomEvent(type, bubbles, cancelable, detail) {
2716
+ if (Event_getEtField(this, dispatched))
2717
+ return;
2718
+ this.initEvent(type, bubbles, cancelable);
2719
+ this[state].detail = detail !== null && detail !== void 0 ? detail : null;
2720
+ }
2721
+ toString() { return "[object CustomEvent]"; }
2722
+ get isPolyfill() { return { symbol: polyfill, hierarchy: ["CustomEvent", "Event"] }; }
2723
+ }
2724
+ dfStringTag(CustomEventP, "CustomEvent");
2725
+ /** @internal */
2726
+ class CustomEventState {
2727
+ }
2728
+ const CustomEventE = g["EventTarget"] ? g["CustomEvent"] : CustomEventP;
2729
+
2730
+ 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, setRequest, setXMLHttpRequest };