@vritti/quantum-ui 0.1.19 → 0.1.21

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/axios.js ADDED
@@ -0,0 +1,4041 @@
1
+ function bind(fn, thisArg) {
2
+ return function wrap() {
3
+ return fn.apply(thisArg, arguments);
4
+ };
5
+ }
6
+
7
+ // utils is a library of generic helper functions non-specific to axios
8
+
9
+ const {toString} = Object.prototype;
10
+ const {getPrototypeOf} = Object;
11
+ const {iterator, toStringTag} = Symbol;
12
+
13
+ const kindOf = (cache => thing => {
14
+ const str = toString.call(thing);
15
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
16
+ })(Object.create(null));
17
+
18
+ const kindOfTest = (type) => {
19
+ type = type.toLowerCase();
20
+ return (thing) => kindOf(thing) === type
21
+ };
22
+
23
+ const typeOfTest = type => thing => typeof thing === type;
24
+
25
+ /**
26
+ * Determine if a value is an Array
27
+ *
28
+ * @param {Object} val The value to test
29
+ *
30
+ * @returns {boolean} True if value is an Array, otherwise false
31
+ */
32
+ const {isArray} = Array;
33
+
34
+ /**
35
+ * Determine if a value is undefined
36
+ *
37
+ * @param {*} val The value to test
38
+ *
39
+ * @returns {boolean} True if the value is undefined, otherwise false
40
+ */
41
+ const isUndefined = typeOfTest('undefined');
42
+
43
+ /**
44
+ * Determine if a value is a Buffer
45
+ *
46
+ * @param {*} val The value to test
47
+ *
48
+ * @returns {boolean} True if value is a Buffer, otherwise false
49
+ */
50
+ function isBuffer(val) {
51
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
52
+ && isFunction$1(val.constructor.isBuffer) && val.constructor.isBuffer(val);
53
+ }
54
+
55
+ /**
56
+ * Determine if a value is an ArrayBuffer
57
+ *
58
+ * @param {*} val The value to test
59
+ *
60
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
61
+ */
62
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
63
+
64
+
65
+ /**
66
+ * Determine if a value is a view on an ArrayBuffer
67
+ *
68
+ * @param {*} val The value to test
69
+ *
70
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
71
+ */
72
+ function isArrayBufferView(val) {
73
+ let result;
74
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
75
+ result = ArrayBuffer.isView(val);
76
+ } else {
77
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
78
+ }
79
+ return result;
80
+ }
81
+
82
+ /**
83
+ * Determine if a value is a String
84
+ *
85
+ * @param {*} val The value to test
86
+ *
87
+ * @returns {boolean} True if value is a String, otherwise false
88
+ */
89
+ const isString = typeOfTest('string');
90
+
91
+ /**
92
+ * Determine if a value is a Function
93
+ *
94
+ * @param {*} val The value to test
95
+ * @returns {boolean} True if value is a Function, otherwise false
96
+ */
97
+ const isFunction$1 = typeOfTest('function');
98
+
99
+ /**
100
+ * Determine if a value is a Number
101
+ *
102
+ * @param {*} val The value to test
103
+ *
104
+ * @returns {boolean} True if value is a Number, otherwise false
105
+ */
106
+ const isNumber = typeOfTest('number');
107
+
108
+ /**
109
+ * Determine if a value is an Object
110
+ *
111
+ * @param {*} thing The value to test
112
+ *
113
+ * @returns {boolean} True if value is an Object, otherwise false
114
+ */
115
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
116
+
117
+ /**
118
+ * Determine if a value is a Boolean
119
+ *
120
+ * @param {*} thing The value to test
121
+ * @returns {boolean} True if value is a Boolean, otherwise false
122
+ */
123
+ const isBoolean = thing => thing === true || thing === false;
124
+
125
+ /**
126
+ * Determine if a value is a plain Object
127
+ *
128
+ * @param {*} val The value to test
129
+ *
130
+ * @returns {boolean} True if value is a plain Object, otherwise false
131
+ */
132
+ const isPlainObject = (val) => {
133
+ if (kindOf(val) !== 'object') {
134
+ return false;
135
+ }
136
+
137
+ const prototype = getPrototypeOf(val);
138
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(toStringTag in val) && !(iterator in val);
139
+ };
140
+
141
+ /**
142
+ * Determine if a value is an empty object (safely handles Buffers)
143
+ *
144
+ * @param {*} val The value to test
145
+ *
146
+ * @returns {boolean} True if value is an empty object, otherwise false
147
+ */
148
+ const isEmptyObject = (val) => {
149
+ // Early return for non-objects or Buffers to prevent RangeError
150
+ if (!isObject(val) || isBuffer(val)) {
151
+ return false;
152
+ }
153
+
154
+ try {
155
+ return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
156
+ } catch (e) {
157
+ // Fallback for any other objects that might cause RangeError with Object.keys()
158
+ return false;
159
+ }
160
+ };
161
+
162
+ /**
163
+ * Determine if a value is a Date
164
+ *
165
+ * @param {*} val The value to test
166
+ *
167
+ * @returns {boolean} True if value is a Date, otherwise false
168
+ */
169
+ const isDate = kindOfTest('Date');
170
+
171
+ /**
172
+ * Determine if a value is a File
173
+ *
174
+ * @param {*} val The value to test
175
+ *
176
+ * @returns {boolean} True if value is a File, otherwise false
177
+ */
178
+ const isFile = kindOfTest('File');
179
+
180
+ /**
181
+ * Determine if a value is a Blob
182
+ *
183
+ * @param {*} val The value to test
184
+ *
185
+ * @returns {boolean} True if value is a Blob, otherwise false
186
+ */
187
+ const isBlob = kindOfTest('Blob');
188
+
189
+ /**
190
+ * Determine if a value is a FileList
191
+ *
192
+ * @param {*} val The value to test
193
+ *
194
+ * @returns {boolean} True if value is a File, otherwise false
195
+ */
196
+ const isFileList = kindOfTest('FileList');
197
+
198
+ /**
199
+ * Determine if a value is a Stream
200
+ *
201
+ * @param {*} val The value to test
202
+ *
203
+ * @returns {boolean} True if value is a Stream, otherwise false
204
+ */
205
+ const isStream = (val) => isObject(val) && isFunction$1(val.pipe);
206
+
207
+ /**
208
+ * Determine if a value is a FormData
209
+ *
210
+ * @param {*} thing The value to test
211
+ *
212
+ * @returns {boolean} True if value is an FormData, otherwise false
213
+ */
214
+ const isFormData = (thing) => {
215
+ let kind;
216
+ return thing && (
217
+ (typeof FormData === 'function' && thing instanceof FormData) || (
218
+ isFunction$1(thing.append) && (
219
+ (kind = kindOf(thing)) === 'formdata' ||
220
+ // detect form-data instance
221
+ (kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]')
222
+ )
223
+ )
224
+ )
225
+ };
226
+
227
+ /**
228
+ * Determine if a value is a URLSearchParams object
229
+ *
230
+ * @param {*} val The value to test
231
+ *
232
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
233
+ */
234
+ const isURLSearchParams = kindOfTest('URLSearchParams');
235
+
236
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
237
+
238
+ /**
239
+ * Trim excess whitespace off the beginning and end of a string
240
+ *
241
+ * @param {String} str The String to trim
242
+ *
243
+ * @returns {String} The String freed of excess whitespace
244
+ */
245
+ const trim = (str) => str.trim ?
246
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
247
+
248
+ /**
249
+ * Iterate over an Array or an Object invoking a function for each item.
250
+ *
251
+ * If `obj` is an Array callback will be called passing
252
+ * the value, index, and complete array for each item.
253
+ *
254
+ * If 'obj' is an Object callback will be called passing
255
+ * the value, key, and complete object for each property.
256
+ *
257
+ * @param {Object|Array} obj The object to iterate
258
+ * @param {Function} fn The callback to invoke for each item
259
+ *
260
+ * @param {Boolean} [allOwnKeys = false]
261
+ * @returns {any}
262
+ */
263
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
264
+ // Don't bother if no value provided
265
+ if (obj === null || typeof obj === 'undefined') {
266
+ return;
267
+ }
268
+
269
+ let i;
270
+ let l;
271
+
272
+ // Force an array if not already something iterable
273
+ if (typeof obj !== 'object') {
274
+ /*eslint no-param-reassign:0*/
275
+ obj = [obj];
276
+ }
277
+
278
+ if (isArray(obj)) {
279
+ // Iterate over array values
280
+ for (i = 0, l = obj.length; i < l; i++) {
281
+ fn.call(null, obj[i], i, obj);
282
+ }
283
+ } else {
284
+ // Buffer check
285
+ if (isBuffer(obj)) {
286
+ return;
287
+ }
288
+
289
+ // Iterate over object keys
290
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
291
+ const len = keys.length;
292
+ let key;
293
+
294
+ for (i = 0; i < len; i++) {
295
+ key = keys[i];
296
+ fn.call(null, obj[key], key, obj);
297
+ }
298
+ }
299
+ }
300
+
301
+ function findKey(obj, key) {
302
+ if (isBuffer(obj)){
303
+ return null;
304
+ }
305
+
306
+ key = key.toLowerCase();
307
+ const keys = Object.keys(obj);
308
+ let i = keys.length;
309
+ let _key;
310
+ while (i-- > 0) {
311
+ _key = keys[i];
312
+ if (key === _key.toLowerCase()) {
313
+ return _key;
314
+ }
315
+ }
316
+ return null;
317
+ }
318
+
319
+ const _global = (() => {
320
+ /*eslint no-undef:0*/
321
+ if (typeof globalThis !== "undefined") return globalThis;
322
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
323
+ })();
324
+
325
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
326
+
327
+ /**
328
+ * Accepts varargs expecting each argument to be an object, then
329
+ * immutably merges the properties of each object and returns result.
330
+ *
331
+ * When multiple objects contain the same key the later object in
332
+ * the arguments list will take precedence.
333
+ *
334
+ * Example:
335
+ *
336
+ * ```js
337
+ * var result = merge({foo: 123}, {foo: 456});
338
+ * console.log(result.foo); // outputs 456
339
+ * ```
340
+ *
341
+ * @param {Object} obj1 Object to merge
342
+ *
343
+ * @returns {Object} Result of all merge properties
344
+ */
345
+ function merge(/* obj1, obj2, obj3, ... */) {
346
+ const {caseless, skipUndefined} = isContextDefined(this) && this || {};
347
+ const result = {};
348
+ const assignValue = (val, key) => {
349
+ const targetKey = caseless && findKey(result, key) || key;
350
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
351
+ result[targetKey] = merge(result[targetKey], val);
352
+ } else if (isPlainObject(val)) {
353
+ result[targetKey] = merge({}, val);
354
+ } else if (isArray(val)) {
355
+ result[targetKey] = val.slice();
356
+ } else if (!skipUndefined || !isUndefined(val)) {
357
+ result[targetKey] = val;
358
+ }
359
+ };
360
+
361
+ for (let i = 0, l = arguments.length; i < l; i++) {
362
+ arguments[i] && forEach(arguments[i], assignValue);
363
+ }
364
+ return result;
365
+ }
366
+
367
+ /**
368
+ * Extends object a by mutably adding to it the properties of object b.
369
+ *
370
+ * @param {Object} a The object to be extended
371
+ * @param {Object} b The object to copy properties from
372
+ * @param {Object} thisArg The object to bind function to
373
+ *
374
+ * @param {Boolean} [allOwnKeys]
375
+ * @returns {Object} The resulting value of object a
376
+ */
377
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
378
+ forEach(b, (val, key) => {
379
+ if (thisArg && isFunction$1(val)) {
380
+ a[key] = bind(val, thisArg);
381
+ } else {
382
+ a[key] = val;
383
+ }
384
+ }, {allOwnKeys});
385
+ return a;
386
+ };
387
+
388
+ /**
389
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
390
+ *
391
+ * @param {string} content with BOM
392
+ *
393
+ * @returns {string} content value without BOM
394
+ */
395
+ const stripBOM = (content) => {
396
+ if (content.charCodeAt(0) === 0xFEFF) {
397
+ content = content.slice(1);
398
+ }
399
+ return content;
400
+ };
401
+
402
+ /**
403
+ * Inherit the prototype methods from one constructor into another
404
+ * @param {function} constructor
405
+ * @param {function} superConstructor
406
+ * @param {object} [props]
407
+ * @param {object} [descriptors]
408
+ *
409
+ * @returns {void}
410
+ */
411
+ const inherits = (constructor, superConstructor, props, descriptors) => {
412
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
413
+ constructor.prototype.constructor = constructor;
414
+ Object.defineProperty(constructor, 'super', {
415
+ value: superConstructor.prototype
416
+ });
417
+ props && Object.assign(constructor.prototype, props);
418
+ };
419
+
420
+ /**
421
+ * Resolve object with deep prototype chain to a flat object
422
+ * @param {Object} sourceObj source object
423
+ * @param {Object} [destObj]
424
+ * @param {Function|Boolean} [filter]
425
+ * @param {Function} [propFilter]
426
+ *
427
+ * @returns {Object}
428
+ */
429
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
430
+ let props;
431
+ let i;
432
+ let prop;
433
+ const merged = {};
434
+
435
+ destObj = destObj || {};
436
+ // eslint-disable-next-line no-eq-null,eqeqeq
437
+ if (sourceObj == null) return destObj;
438
+
439
+ do {
440
+ props = Object.getOwnPropertyNames(sourceObj);
441
+ i = props.length;
442
+ while (i-- > 0) {
443
+ prop = props[i];
444
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
445
+ destObj[prop] = sourceObj[prop];
446
+ merged[prop] = true;
447
+ }
448
+ }
449
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
450
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
451
+
452
+ return destObj;
453
+ };
454
+
455
+ /**
456
+ * Determines whether a string ends with the characters of a specified string
457
+ *
458
+ * @param {String} str
459
+ * @param {String} searchString
460
+ * @param {Number} [position= 0]
461
+ *
462
+ * @returns {boolean}
463
+ */
464
+ const endsWith = (str, searchString, position) => {
465
+ str = String(str);
466
+ if (position === undefined || position > str.length) {
467
+ position = str.length;
468
+ }
469
+ position -= searchString.length;
470
+ const lastIndex = str.indexOf(searchString, position);
471
+ return lastIndex !== -1 && lastIndex === position;
472
+ };
473
+
474
+
475
+ /**
476
+ * Returns new array from array like object or null if failed
477
+ *
478
+ * @param {*} [thing]
479
+ *
480
+ * @returns {?Array}
481
+ */
482
+ const toArray = (thing) => {
483
+ if (!thing) return null;
484
+ if (isArray(thing)) return thing;
485
+ let i = thing.length;
486
+ if (!isNumber(i)) return null;
487
+ const arr = new Array(i);
488
+ while (i-- > 0) {
489
+ arr[i] = thing[i];
490
+ }
491
+ return arr;
492
+ };
493
+
494
+ /**
495
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
496
+ * thing passed in is an instance of Uint8Array
497
+ *
498
+ * @param {TypedArray}
499
+ *
500
+ * @returns {Array}
501
+ */
502
+ // eslint-disable-next-line func-names
503
+ const isTypedArray = (TypedArray => {
504
+ // eslint-disable-next-line func-names
505
+ return thing => {
506
+ return TypedArray && thing instanceof TypedArray;
507
+ };
508
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
509
+
510
+ /**
511
+ * For each entry in the object, call the function with the key and value.
512
+ *
513
+ * @param {Object<any, any>} obj - The object to iterate over.
514
+ * @param {Function} fn - The function to call for each entry.
515
+ *
516
+ * @returns {void}
517
+ */
518
+ const forEachEntry = (obj, fn) => {
519
+ const generator = obj && obj[iterator];
520
+
521
+ const _iterator = generator.call(obj);
522
+
523
+ let result;
524
+
525
+ while ((result = _iterator.next()) && !result.done) {
526
+ const pair = result.value;
527
+ fn.call(obj, pair[0], pair[1]);
528
+ }
529
+ };
530
+
531
+ /**
532
+ * It takes a regular expression and a string, and returns an array of all the matches
533
+ *
534
+ * @param {string} regExp - The regular expression to match against.
535
+ * @param {string} str - The string to search.
536
+ *
537
+ * @returns {Array<boolean>}
538
+ */
539
+ const matchAll = (regExp, str) => {
540
+ let matches;
541
+ const arr = [];
542
+
543
+ while ((matches = regExp.exec(str)) !== null) {
544
+ arr.push(matches);
545
+ }
546
+
547
+ return arr;
548
+ };
549
+
550
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
551
+ const isHTMLForm = kindOfTest('HTMLFormElement');
552
+
553
+ const toCamelCase = str => {
554
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
555
+ function replacer(m, p1, p2) {
556
+ return p1.toUpperCase() + p2;
557
+ }
558
+ );
559
+ };
560
+
561
+ /* Creating a function that will check if an object has a property. */
562
+ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
563
+
564
+ /**
565
+ * Determine if a value is a RegExp object
566
+ *
567
+ * @param {*} val The value to test
568
+ *
569
+ * @returns {boolean} True if value is a RegExp object, otherwise false
570
+ */
571
+ const isRegExp = kindOfTest('RegExp');
572
+
573
+ const reduceDescriptors = (obj, reducer) => {
574
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
575
+ const reducedDescriptors = {};
576
+
577
+ forEach(descriptors, (descriptor, name) => {
578
+ let ret;
579
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
580
+ reducedDescriptors[name] = ret || descriptor;
581
+ }
582
+ });
583
+
584
+ Object.defineProperties(obj, reducedDescriptors);
585
+ };
586
+
587
+ /**
588
+ * Makes all methods read-only
589
+ * @param {Object} obj
590
+ */
591
+
592
+ const freezeMethods = (obj) => {
593
+ reduceDescriptors(obj, (descriptor, name) => {
594
+ // skip restricted props in strict mode
595
+ if (isFunction$1(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
596
+ return false;
597
+ }
598
+
599
+ const value = obj[name];
600
+
601
+ if (!isFunction$1(value)) return;
602
+
603
+ descriptor.enumerable = false;
604
+
605
+ if ('writable' in descriptor) {
606
+ descriptor.writable = false;
607
+ return;
608
+ }
609
+
610
+ if (!descriptor.set) {
611
+ descriptor.set = () => {
612
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
613
+ };
614
+ }
615
+ });
616
+ };
617
+
618
+ const toObjectSet = (arrayOrString, delimiter) => {
619
+ const obj = {};
620
+
621
+ const define = (arr) => {
622
+ arr.forEach(value => {
623
+ obj[value] = true;
624
+ });
625
+ };
626
+
627
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
628
+
629
+ return obj;
630
+ };
631
+
632
+ const noop = () => {};
633
+
634
+ const toFiniteNumber = (value, defaultValue) => {
635
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
636
+ };
637
+
638
+
639
+
640
+ /**
641
+ * If the thing is a FormData object, return true, otherwise return false.
642
+ *
643
+ * @param {unknown} thing - The thing to check.
644
+ *
645
+ * @returns {boolean}
646
+ */
647
+ function isSpecCompliantForm(thing) {
648
+ return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
649
+ }
650
+
651
+ const toJSONObject = (obj) => {
652
+ const stack = new Array(10);
653
+
654
+ const visit = (source, i) => {
655
+
656
+ if (isObject(source)) {
657
+ if (stack.indexOf(source) >= 0) {
658
+ return;
659
+ }
660
+
661
+ //Buffer check
662
+ if (isBuffer(source)) {
663
+ return source;
664
+ }
665
+
666
+ if(!('toJSON' in source)) {
667
+ stack[i] = source;
668
+ const target = isArray(source) ? [] : {};
669
+
670
+ forEach(source, (value, key) => {
671
+ const reducedValue = visit(value, i + 1);
672
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
673
+ });
674
+
675
+ stack[i] = undefined;
676
+
677
+ return target;
678
+ }
679
+ }
680
+
681
+ return source;
682
+ };
683
+
684
+ return visit(obj, 0);
685
+ };
686
+
687
+ const isAsyncFn = kindOfTest('AsyncFunction');
688
+
689
+ const isThenable = (thing) =>
690
+ thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
691
+
692
+ // original code
693
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
694
+
695
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
696
+ if (setImmediateSupported) {
697
+ return setImmediate;
698
+ }
699
+
700
+ return postMessageSupported ? ((token, callbacks) => {
701
+ _global.addEventListener("message", ({source, data}) => {
702
+ if (source === _global && data === token) {
703
+ callbacks.length && callbacks.shift()();
704
+ }
705
+ }, false);
706
+
707
+ return (cb) => {
708
+ callbacks.push(cb);
709
+ _global.postMessage(token, "*");
710
+ }
711
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
712
+ })(
713
+ typeof setImmediate === 'function',
714
+ isFunction$1(_global.postMessage)
715
+ );
716
+
717
+ const asap = typeof queueMicrotask !== 'undefined' ?
718
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
719
+
720
+ // *********************
721
+
722
+
723
+ const isIterable = (thing) => thing != null && isFunction$1(thing[iterator]);
724
+
725
+
726
+ const utils$1 = {
727
+ isArray,
728
+ isArrayBuffer,
729
+ isBuffer,
730
+ isFormData,
731
+ isArrayBufferView,
732
+ isString,
733
+ isNumber,
734
+ isBoolean,
735
+ isObject,
736
+ isPlainObject,
737
+ isEmptyObject,
738
+ isReadableStream,
739
+ isRequest,
740
+ isResponse,
741
+ isHeaders,
742
+ isUndefined,
743
+ isDate,
744
+ isFile,
745
+ isBlob,
746
+ isRegExp,
747
+ isFunction: isFunction$1,
748
+ isStream,
749
+ isURLSearchParams,
750
+ isTypedArray,
751
+ isFileList,
752
+ forEach,
753
+ merge,
754
+ extend,
755
+ trim,
756
+ stripBOM,
757
+ inherits,
758
+ toFlatObject,
759
+ kindOf,
760
+ kindOfTest,
761
+ endsWith,
762
+ toArray,
763
+ forEachEntry,
764
+ matchAll,
765
+ isHTMLForm,
766
+ hasOwnProperty,
767
+ hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
768
+ reduceDescriptors,
769
+ freezeMethods,
770
+ toObjectSet,
771
+ toCamelCase,
772
+ noop,
773
+ toFiniteNumber,
774
+ findKey,
775
+ global: _global,
776
+ isContextDefined,
777
+ isSpecCompliantForm,
778
+ toJSONObject,
779
+ isAsyncFn,
780
+ isThenable,
781
+ setImmediate: _setImmediate,
782
+ asap,
783
+ isIterable
784
+ };
785
+
786
+ /**
787
+ * Create an Error with the specified message, config, error code, request and response.
788
+ *
789
+ * @param {string} message The error message.
790
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
791
+ * @param {Object} [config] The config.
792
+ * @param {Object} [request] The request.
793
+ * @param {Object} [response] The response.
794
+ *
795
+ * @returns {Error} The created error.
796
+ */
797
+ function AxiosError$1(message, code, config, request, response) {
798
+ Error.call(this);
799
+
800
+ if (Error.captureStackTrace) {
801
+ Error.captureStackTrace(this, this.constructor);
802
+ } else {
803
+ this.stack = (new Error()).stack;
804
+ }
805
+
806
+ this.message = message;
807
+ this.name = 'AxiosError';
808
+ code && (this.code = code);
809
+ config && (this.config = config);
810
+ request && (this.request = request);
811
+ if (response) {
812
+ this.response = response;
813
+ this.status = response.status ? response.status : null;
814
+ }
815
+ }
816
+
817
+ utils$1.inherits(AxiosError$1, Error, {
818
+ toJSON: function toJSON() {
819
+ return {
820
+ // Standard
821
+ message: this.message,
822
+ name: this.name,
823
+ // Microsoft
824
+ description: this.description,
825
+ number: this.number,
826
+ // Mozilla
827
+ fileName: this.fileName,
828
+ lineNumber: this.lineNumber,
829
+ columnNumber: this.columnNumber,
830
+ stack: this.stack,
831
+ // Axios
832
+ config: utils$1.toJSONObject(this.config),
833
+ code: this.code,
834
+ status: this.status
835
+ };
836
+ }
837
+ });
838
+
839
+ const prototype$1 = AxiosError$1.prototype;
840
+ const descriptors = {};
841
+
842
+ [
843
+ 'ERR_BAD_OPTION_VALUE',
844
+ 'ERR_BAD_OPTION',
845
+ 'ECONNABORTED',
846
+ 'ETIMEDOUT',
847
+ 'ERR_NETWORK',
848
+ 'ERR_FR_TOO_MANY_REDIRECTS',
849
+ 'ERR_DEPRECATED',
850
+ 'ERR_BAD_RESPONSE',
851
+ 'ERR_BAD_REQUEST',
852
+ 'ERR_CANCELED',
853
+ 'ERR_NOT_SUPPORT',
854
+ 'ERR_INVALID_URL'
855
+ // eslint-disable-next-line func-names
856
+ ].forEach(code => {
857
+ descriptors[code] = {value: code};
858
+ });
859
+
860
+ Object.defineProperties(AxiosError$1, descriptors);
861
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
862
+
863
+ // eslint-disable-next-line func-names
864
+ AxiosError$1.from = (error, code, config, request, response, customProps) => {
865
+ const axiosError = Object.create(prototype$1);
866
+
867
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
868
+ return obj !== Error.prototype;
869
+ }, prop => {
870
+ return prop !== 'isAxiosError';
871
+ });
872
+
873
+ const msg = error && error.message ? error.message : 'Error';
874
+
875
+ // Prefer explicit code; otherwise copy the low-level error's code (e.g. ECONNREFUSED)
876
+ const errCode = code == null && error ? error.code : code;
877
+ AxiosError$1.call(axiosError, msg, errCode, config, request, response);
878
+
879
+ // Chain the original error on the standard field; non-enumerable to avoid JSON noise
880
+ if (error && axiosError.cause == null) {
881
+ Object.defineProperty(axiosError, 'cause', { value: error, configurable: true });
882
+ }
883
+
884
+ axiosError.name = (error && error.name) || 'Error';
885
+
886
+ customProps && Object.assign(axiosError, customProps);
887
+
888
+ return axiosError;
889
+ };
890
+
891
+ // eslint-disable-next-line strict
892
+ const httpAdapter = null;
893
+
894
+ /**
895
+ * Determines if the given thing is a array or js object.
896
+ *
897
+ * @param {string} thing - The object or array to be visited.
898
+ *
899
+ * @returns {boolean}
900
+ */
901
+ function isVisitable(thing) {
902
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
903
+ }
904
+
905
+ /**
906
+ * It removes the brackets from the end of a string
907
+ *
908
+ * @param {string} key - The key of the parameter.
909
+ *
910
+ * @returns {string} the key without the brackets.
911
+ */
912
+ function removeBrackets(key) {
913
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
914
+ }
915
+
916
+ /**
917
+ * It takes a path, a key, and a boolean, and returns a string
918
+ *
919
+ * @param {string} path - The path to the current key.
920
+ * @param {string} key - The key of the current object being iterated over.
921
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
922
+ *
923
+ * @returns {string} The path to the current key.
924
+ */
925
+ function renderKey(path, key, dots) {
926
+ if (!path) return key;
927
+ return path.concat(key).map(function each(token, i) {
928
+ // eslint-disable-next-line no-param-reassign
929
+ token = removeBrackets(token);
930
+ return !dots && i ? '[' + token + ']' : token;
931
+ }).join(dots ? '.' : '');
932
+ }
933
+
934
+ /**
935
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
936
+ *
937
+ * @param {Array<any>} arr - The array to check
938
+ *
939
+ * @returns {boolean}
940
+ */
941
+ function isFlatArray(arr) {
942
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
943
+ }
944
+
945
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
946
+ return /^is[A-Z]/.test(prop);
947
+ });
948
+
949
+ /**
950
+ * Convert a data object to FormData
951
+ *
952
+ * @param {Object} obj
953
+ * @param {?Object} [formData]
954
+ * @param {?Object} [options]
955
+ * @param {Function} [options.visitor]
956
+ * @param {Boolean} [options.metaTokens = true]
957
+ * @param {Boolean} [options.dots = false]
958
+ * @param {?Boolean} [options.indexes = false]
959
+ *
960
+ * @returns {Object}
961
+ **/
962
+
963
+ /**
964
+ * It converts an object into a FormData object
965
+ *
966
+ * @param {Object<any, any>} obj - The object to convert to form data.
967
+ * @param {string} formData - The FormData object to append to.
968
+ * @param {Object<string, any>} options
969
+ *
970
+ * @returns
971
+ */
972
+ function toFormData$1(obj, formData, options) {
973
+ if (!utils$1.isObject(obj)) {
974
+ throw new TypeError('target must be an object');
975
+ }
976
+
977
+ // eslint-disable-next-line no-param-reassign
978
+ formData = formData || new (FormData)();
979
+
980
+ // eslint-disable-next-line no-param-reassign
981
+ options = utils$1.toFlatObject(options, {
982
+ metaTokens: true,
983
+ dots: false,
984
+ indexes: false
985
+ }, false, function defined(option, source) {
986
+ // eslint-disable-next-line no-eq-null,eqeqeq
987
+ return !utils$1.isUndefined(source[option]);
988
+ });
989
+
990
+ const metaTokens = options.metaTokens;
991
+ // eslint-disable-next-line no-use-before-define
992
+ const visitor = options.visitor || defaultVisitor;
993
+ const dots = options.dots;
994
+ const indexes = options.indexes;
995
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
996
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
997
+
998
+ if (!utils$1.isFunction(visitor)) {
999
+ throw new TypeError('visitor must be a function');
1000
+ }
1001
+
1002
+ function convertValue(value) {
1003
+ if (value === null) return '';
1004
+
1005
+ if (utils$1.isDate(value)) {
1006
+ return value.toISOString();
1007
+ }
1008
+
1009
+ if (utils$1.isBoolean(value)) {
1010
+ return value.toString();
1011
+ }
1012
+
1013
+ if (!useBlob && utils$1.isBlob(value)) {
1014
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
1015
+ }
1016
+
1017
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1018
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1019
+ }
1020
+
1021
+ return value;
1022
+ }
1023
+
1024
+ /**
1025
+ * Default visitor.
1026
+ *
1027
+ * @param {*} value
1028
+ * @param {String|Number} key
1029
+ * @param {Array<String|Number>} path
1030
+ * @this {FormData}
1031
+ *
1032
+ * @returns {boolean} return true to visit the each prop of the value recursively
1033
+ */
1034
+ function defaultVisitor(value, key, path) {
1035
+ let arr = value;
1036
+
1037
+ if (value && !path && typeof value === 'object') {
1038
+ if (utils$1.endsWith(key, '{}')) {
1039
+ // eslint-disable-next-line no-param-reassign
1040
+ key = metaTokens ? key : key.slice(0, -2);
1041
+ // eslint-disable-next-line no-param-reassign
1042
+ value = JSON.stringify(value);
1043
+ } else if (
1044
+ (utils$1.isArray(value) && isFlatArray(value)) ||
1045
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1046
+ )) {
1047
+ // eslint-disable-next-line no-param-reassign
1048
+ key = removeBrackets(key);
1049
+
1050
+ arr.forEach(function each(el, index) {
1051
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1052
+ // eslint-disable-next-line no-nested-ternary
1053
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1054
+ convertValue(el)
1055
+ );
1056
+ });
1057
+ return false;
1058
+ }
1059
+ }
1060
+
1061
+ if (isVisitable(value)) {
1062
+ return true;
1063
+ }
1064
+
1065
+ formData.append(renderKey(path, key, dots), convertValue(value));
1066
+
1067
+ return false;
1068
+ }
1069
+
1070
+ const stack = [];
1071
+
1072
+ const exposedHelpers = Object.assign(predicates, {
1073
+ defaultVisitor,
1074
+ convertValue,
1075
+ isVisitable
1076
+ });
1077
+
1078
+ function build(value, path) {
1079
+ if (utils$1.isUndefined(value)) return;
1080
+
1081
+ if (stack.indexOf(value) !== -1) {
1082
+ throw Error('Circular reference detected in ' + path.join('.'));
1083
+ }
1084
+
1085
+ stack.push(value);
1086
+
1087
+ utils$1.forEach(value, function each(el, key) {
1088
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1089
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1090
+ );
1091
+
1092
+ if (result === true) {
1093
+ build(el, path ? path.concat(key) : [key]);
1094
+ }
1095
+ });
1096
+
1097
+ stack.pop();
1098
+ }
1099
+
1100
+ if (!utils$1.isObject(obj)) {
1101
+ throw new TypeError('data must be an object');
1102
+ }
1103
+
1104
+ build(obj);
1105
+
1106
+ return formData;
1107
+ }
1108
+
1109
+ /**
1110
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1111
+ * their percent-encoded equivalents
1112
+ *
1113
+ * @param {string} str - The string to encode.
1114
+ *
1115
+ * @returns {string} The encoded string.
1116
+ */
1117
+ function encode$1(str) {
1118
+ const charMap = {
1119
+ '!': '%21',
1120
+ "'": '%27',
1121
+ '(': '%28',
1122
+ ')': '%29',
1123
+ '~': '%7E',
1124
+ '%20': '+',
1125
+ '%00': '\x00'
1126
+ };
1127
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1128
+ return charMap[match];
1129
+ });
1130
+ }
1131
+
1132
+ /**
1133
+ * It takes a params object and converts it to a FormData object
1134
+ *
1135
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1136
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1137
+ *
1138
+ * @returns {void}
1139
+ */
1140
+ function AxiosURLSearchParams(params, options) {
1141
+ this._pairs = [];
1142
+
1143
+ params && toFormData$1(params, this, options);
1144
+ }
1145
+
1146
+ const prototype = AxiosURLSearchParams.prototype;
1147
+
1148
+ prototype.append = function append(name, value) {
1149
+ this._pairs.push([name, value]);
1150
+ };
1151
+
1152
+ prototype.toString = function toString(encoder) {
1153
+ const _encode = encoder ? function(value) {
1154
+ return encoder.call(this, value, encode$1);
1155
+ } : encode$1;
1156
+
1157
+ return this._pairs.map(function each(pair) {
1158
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1159
+ }, '').join('&');
1160
+ };
1161
+
1162
+ /**
1163
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1164
+ * URI encoded counterparts
1165
+ *
1166
+ * @param {string} val The value to be encoded.
1167
+ *
1168
+ * @returns {string} The encoded value.
1169
+ */
1170
+ function encode(val) {
1171
+ return encodeURIComponent(val).
1172
+ replace(/%3A/gi, ':').
1173
+ replace(/%24/g, '$').
1174
+ replace(/%2C/gi, ',').
1175
+ replace(/%20/g, '+');
1176
+ }
1177
+
1178
+ /**
1179
+ * Build a URL by appending params to the end
1180
+ *
1181
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1182
+ * @param {object} [params] The params to be appended
1183
+ * @param {?(object|Function)} options
1184
+ *
1185
+ * @returns {string} The formatted url
1186
+ */
1187
+ function buildURL(url, params, options) {
1188
+ /*eslint no-param-reassign:0*/
1189
+ if (!params) {
1190
+ return url;
1191
+ }
1192
+
1193
+ const _encode = options && options.encode || encode;
1194
+
1195
+ if (utils$1.isFunction(options)) {
1196
+ options = {
1197
+ serialize: options
1198
+ };
1199
+ }
1200
+
1201
+ const serializeFn = options && options.serialize;
1202
+
1203
+ let serializedParams;
1204
+
1205
+ if (serializeFn) {
1206
+ serializedParams = serializeFn(params, options);
1207
+ } else {
1208
+ serializedParams = utils$1.isURLSearchParams(params) ?
1209
+ params.toString() :
1210
+ new AxiosURLSearchParams(params, options).toString(_encode);
1211
+ }
1212
+
1213
+ if (serializedParams) {
1214
+ const hashmarkIndex = url.indexOf("#");
1215
+
1216
+ if (hashmarkIndex !== -1) {
1217
+ url = url.slice(0, hashmarkIndex);
1218
+ }
1219
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1220
+ }
1221
+
1222
+ return url;
1223
+ }
1224
+
1225
+ class InterceptorManager {
1226
+ constructor() {
1227
+ this.handlers = [];
1228
+ }
1229
+
1230
+ /**
1231
+ * Add a new interceptor to the stack
1232
+ *
1233
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1234
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1235
+ *
1236
+ * @return {Number} An ID used to remove interceptor later
1237
+ */
1238
+ use(fulfilled, rejected, options) {
1239
+ this.handlers.push({
1240
+ fulfilled,
1241
+ rejected,
1242
+ synchronous: options ? options.synchronous : false,
1243
+ runWhen: options ? options.runWhen : null
1244
+ });
1245
+ return this.handlers.length - 1;
1246
+ }
1247
+
1248
+ /**
1249
+ * Remove an interceptor from the stack
1250
+ *
1251
+ * @param {Number} id The ID that was returned by `use`
1252
+ *
1253
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1254
+ */
1255
+ eject(id) {
1256
+ if (this.handlers[id]) {
1257
+ this.handlers[id] = null;
1258
+ }
1259
+ }
1260
+
1261
+ /**
1262
+ * Clear all interceptors from the stack
1263
+ *
1264
+ * @returns {void}
1265
+ */
1266
+ clear() {
1267
+ if (this.handlers) {
1268
+ this.handlers = [];
1269
+ }
1270
+ }
1271
+
1272
+ /**
1273
+ * Iterate over all the registered interceptors
1274
+ *
1275
+ * This method is particularly useful for skipping over any
1276
+ * interceptors that may have become `null` calling `eject`.
1277
+ *
1278
+ * @param {Function} fn The function to call for each interceptor
1279
+ *
1280
+ * @returns {void}
1281
+ */
1282
+ forEach(fn) {
1283
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1284
+ if (h !== null) {
1285
+ fn(h);
1286
+ }
1287
+ });
1288
+ }
1289
+ }
1290
+
1291
+ const transitionalDefaults = {
1292
+ silentJSONParsing: true,
1293
+ forcedJSONParsing: true,
1294
+ clarifyTimeoutError: false
1295
+ };
1296
+
1297
+ const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1298
+
1299
+ const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1300
+
1301
+ const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1302
+
1303
+ const platform$1 = {
1304
+ isBrowser: true,
1305
+ classes: {
1306
+ URLSearchParams: URLSearchParams$1,
1307
+ FormData: FormData$1,
1308
+ Blob: Blob$1
1309
+ },
1310
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1311
+ };
1312
+
1313
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1314
+
1315
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1316
+
1317
+ /**
1318
+ * Determine if we're running in a standard browser environment
1319
+ *
1320
+ * This allows axios to run in a web worker, and react-native.
1321
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1322
+ *
1323
+ * web workers:
1324
+ * typeof window -> undefined
1325
+ * typeof document -> undefined
1326
+ *
1327
+ * react-native:
1328
+ * navigator.product -> 'ReactNative'
1329
+ * nativescript
1330
+ * navigator.product -> 'NativeScript' or 'NS'
1331
+ *
1332
+ * @returns {boolean}
1333
+ */
1334
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1335
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1336
+
1337
+ /**
1338
+ * Determine if we're running in a standard browser webWorker environment
1339
+ *
1340
+ * Although the `isStandardBrowserEnv` method indicates that
1341
+ * `allows axios to run in a web worker`, the WebWorker will still be
1342
+ * filtered out due to its judgment standard
1343
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1344
+ * This leads to a problem when axios post `FormData` in webWorker
1345
+ */
1346
+ const hasStandardBrowserWebWorkerEnv = (() => {
1347
+ return (
1348
+ typeof WorkerGlobalScope !== 'undefined' &&
1349
+ // eslint-disable-next-line no-undef
1350
+ self instanceof WorkerGlobalScope &&
1351
+ typeof self.importScripts === 'function'
1352
+ );
1353
+ })();
1354
+
1355
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1356
+
1357
+ const utils = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
1358
+ __proto__: null,
1359
+ hasBrowserEnv,
1360
+ hasStandardBrowserEnv,
1361
+ hasStandardBrowserWebWorkerEnv,
1362
+ navigator: _navigator,
1363
+ origin
1364
+ }, Symbol.toStringTag, { value: 'Module' }));
1365
+
1366
+ const platform = {
1367
+ ...utils,
1368
+ ...platform$1
1369
+ };
1370
+
1371
+ function toURLEncodedForm(data, options) {
1372
+ return toFormData$1(data, new platform.classes.URLSearchParams(), {
1373
+ visitor: function(value, key, path, helpers) {
1374
+ if (platform.isNode && utils$1.isBuffer(value)) {
1375
+ this.append(key, value.toString('base64'));
1376
+ return false;
1377
+ }
1378
+
1379
+ return helpers.defaultVisitor.apply(this, arguments);
1380
+ },
1381
+ ...options
1382
+ });
1383
+ }
1384
+
1385
+ /**
1386
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1387
+ *
1388
+ * @param {string} name - The name of the property to get.
1389
+ *
1390
+ * @returns An array of strings.
1391
+ */
1392
+ function parsePropPath(name) {
1393
+ // foo[x][y][z]
1394
+ // foo.x.y.z
1395
+ // foo-x-y-z
1396
+ // foo x y z
1397
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1398
+ return match[0] === '[]' ? '' : match[1] || match[0];
1399
+ });
1400
+ }
1401
+
1402
+ /**
1403
+ * Convert an array to an object.
1404
+ *
1405
+ * @param {Array<any>} arr - The array to convert to an object.
1406
+ *
1407
+ * @returns An object with the same keys and values as the array.
1408
+ */
1409
+ function arrayToObject(arr) {
1410
+ const obj = {};
1411
+ const keys = Object.keys(arr);
1412
+ let i;
1413
+ const len = keys.length;
1414
+ let key;
1415
+ for (i = 0; i < len; i++) {
1416
+ key = keys[i];
1417
+ obj[key] = arr[key];
1418
+ }
1419
+ return obj;
1420
+ }
1421
+
1422
+ /**
1423
+ * It takes a FormData object and returns a JavaScript object
1424
+ *
1425
+ * @param {string} formData The FormData object to convert to JSON.
1426
+ *
1427
+ * @returns {Object<string, any> | null} The converted object.
1428
+ */
1429
+ function formDataToJSON(formData) {
1430
+ function buildPath(path, value, target, index) {
1431
+ let name = path[index++];
1432
+
1433
+ if (name === '__proto__') return true;
1434
+
1435
+ const isNumericKey = Number.isFinite(+name);
1436
+ const isLast = index >= path.length;
1437
+ name = !name && utils$1.isArray(target) ? target.length : name;
1438
+
1439
+ if (isLast) {
1440
+ if (utils$1.hasOwnProp(target, name)) {
1441
+ target[name] = [target[name], value];
1442
+ } else {
1443
+ target[name] = value;
1444
+ }
1445
+
1446
+ return !isNumericKey;
1447
+ }
1448
+
1449
+ if (!target[name] || !utils$1.isObject(target[name])) {
1450
+ target[name] = [];
1451
+ }
1452
+
1453
+ const result = buildPath(path, value, target[name], index);
1454
+
1455
+ if (result && utils$1.isArray(target[name])) {
1456
+ target[name] = arrayToObject(target[name]);
1457
+ }
1458
+
1459
+ return !isNumericKey;
1460
+ }
1461
+
1462
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1463
+ const obj = {};
1464
+
1465
+ utils$1.forEachEntry(formData, (name, value) => {
1466
+ buildPath(parsePropPath(name), value, obj, 0);
1467
+ });
1468
+
1469
+ return obj;
1470
+ }
1471
+
1472
+ return null;
1473
+ }
1474
+
1475
+ /**
1476
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1477
+ * of the input
1478
+ *
1479
+ * @param {any} rawValue - The value to be stringified.
1480
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1481
+ * @param {Function} encoder - A function that takes a value and returns a string.
1482
+ *
1483
+ * @returns {string} A stringified version of the rawValue.
1484
+ */
1485
+ function stringifySafely(rawValue, parser, encoder) {
1486
+ if (utils$1.isString(rawValue)) {
1487
+ try {
1488
+ (parser || JSON.parse)(rawValue);
1489
+ return utils$1.trim(rawValue);
1490
+ } catch (e) {
1491
+ if (e.name !== 'SyntaxError') {
1492
+ throw e;
1493
+ }
1494
+ }
1495
+ }
1496
+
1497
+ return (encoder || JSON.stringify)(rawValue);
1498
+ }
1499
+
1500
+ const defaults = {
1501
+
1502
+ transitional: transitionalDefaults,
1503
+
1504
+ adapter: ['xhr', 'http', 'fetch'],
1505
+
1506
+ transformRequest: [function transformRequest(data, headers) {
1507
+ const contentType = headers.getContentType() || '';
1508
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1509
+ const isObjectPayload = utils$1.isObject(data);
1510
+
1511
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1512
+ data = new FormData(data);
1513
+ }
1514
+
1515
+ const isFormData = utils$1.isFormData(data);
1516
+
1517
+ if (isFormData) {
1518
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1519
+ }
1520
+
1521
+ if (utils$1.isArrayBuffer(data) ||
1522
+ utils$1.isBuffer(data) ||
1523
+ utils$1.isStream(data) ||
1524
+ utils$1.isFile(data) ||
1525
+ utils$1.isBlob(data) ||
1526
+ utils$1.isReadableStream(data)
1527
+ ) {
1528
+ return data;
1529
+ }
1530
+ if (utils$1.isArrayBufferView(data)) {
1531
+ return data.buffer;
1532
+ }
1533
+ if (utils$1.isURLSearchParams(data)) {
1534
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1535
+ return data.toString();
1536
+ }
1537
+
1538
+ let isFileList;
1539
+
1540
+ if (isObjectPayload) {
1541
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1542
+ return toURLEncodedForm(data, this.formSerializer).toString();
1543
+ }
1544
+
1545
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1546
+ const _FormData = this.env && this.env.FormData;
1547
+
1548
+ return toFormData$1(
1549
+ isFileList ? {'files[]': data} : data,
1550
+ _FormData && new _FormData(),
1551
+ this.formSerializer
1552
+ );
1553
+ }
1554
+ }
1555
+
1556
+ if (isObjectPayload || hasJSONContentType ) {
1557
+ headers.setContentType('application/json', false);
1558
+ return stringifySafely(data);
1559
+ }
1560
+
1561
+ return data;
1562
+ }],
1563
+
1564
+ transformResponse: [function transformResponse(data) {
1565
+ const transitional = this.transitional || defaults.transitional;
1566
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1567
+ const JSONRequested = this.responseType === 'json';
1568
+
1569
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1570
+ return data;
1571
+ }
1572
+
1573
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1574
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1575
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1576
+
1577
+ try {
1578
+ return JSON.parse(data, this.parseReviver);
1579
+ } catch (e) {
1580
+ if (strictJSONParsing) {
1581
+ if (e.name === 'SyntaxError') {
1582
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1583
+ }
1584
+ throw e;
1585
+ }
1586
+ }
1587
+ }
1588
+
1589
+ return data;
1590
+ }],
1591
+
1592
+ /**
1593
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1594
+ * timeout is not created.
1595
+ */
1596
+ timeout: 0,
1597
+
1598
+ xsrfCookieName: 'XSRF-TOKEN',
1599
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1600
+
1601
+ maxContentLength: -1,
1602
+ maxBodyLength: -1,
1603
+
1604
+ env: {
1605
+ FormData: platform.classes.FormData,
1606
+ Blob: platform.classes.Blob
1607
+ },
1608
+
1609
+ validateStatus: function validateStatus(status) {
1610
+ return status >= 200 && status < 300;
1611
+ },
1612
+
1613
+ headers: {
1614
+ common: {
1615
+ 'Accept': 'application/json, text/plain, */*',
1616
+ 'Content-Type': undefined
1617
+ }
1618
+ }
1619
+ };
1620
+
1621
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1622
+ defaults.headers[method] = {};
1623
+ });
1624
+
1625
+ // RawAxiosHeaders whose duplicates are ignored by node
1626
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1627
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1628
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1629
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1630
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1631
+ 'referer', 'retry-after', 'user-agent'
1632
+ ]);
1633
+
1634
+ /**
1635
+ * Parse headers into an object
1636
+ *
1637
+ * ```
1638
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1639
+ * Content-Type: application/json
1640
+ * Connection: keep-alive
1641
+ * Transfer-Encoding: chunked
1642
+ * ```
1643
+ *
1644
+ * @param {String} rawHeaders Headers needing to be parsed
1645
+ *
1646
+ * @returns {Object} Headers parsed into an object
1647
+ */
1648
+ const parseHeaders = rawHeaders => {
1649
+ const parsed = {};
1650
+ let key;
1651
+ let val;
1652
+ let i;
1653
+
1654
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1655
+ i = line.indexOf(':');
1656
+ key = line.substring(0, i).trim().toLowerCase();
1657
+ val = line.substring(i + 1).trim();
1658
+
1659
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1660
+ return;
1661
+ }
1662
+
1663
+ if (key === 'set-cookie') {
1664
+ if (parsed[key]) {
1665
+ parsed[key].push(val);
1666
+ } else {
1667
+ parsed[key] = [val];
1668
+ }
1669
+ } else {
1670
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1671
+ }
1672
+ });
1673
+
1674
+ return parsed;
1675
+ };
1676
+
1677
+ const $internals = Symbol('internals');
1678
+
1679
+ function normalizeHeader(header) {
1680
+ return header && String(header).trim().toLowerCase();
1681
+ }
1682
+
1683
+ function normalizeValue(value) {
1684
+ if (value === false || value == null) {
1685
+ return value;
1686
+ }
1687
+
1688
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1689
+ }
1690
+
1691
+ function parseTokens(str) {
1692
+ const tokens = Object.create(null);
1693
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1694
+ let match;
1695
+
1696
+ while ((match = tokensRE.exec(str))) {
1697
+ tokens[match[1]] = match[2];
1698
+ }
1699
+
1700
+ return tokens;
1701
+ }
1702
+
1703
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1704
+
1705
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1706
+ if (utils$1.isFunction(filter)) {
1707
+ return filter.call(this, value, header);
1708
+ }
1709
+
1710
+ if (isHeaderNameFilter) {
1711
+ value = header;
1712
+ }
1713
+
1714
+ if (!utils$1.isString(value)) return;
1715
+
1716
+ if (utils$1.isString(filter)) {
1717
+ return value.indexOf(filter) !== -1;
1718
+ }
1719
+
1720
+ if (utils$1.isRegExp(filter)) {
1721
+ return filter.test(value);
1722
+ }
1723
+ }
1724
+
1725
+ function formatHeader(header) {
1726
+ return header.trim()
1727
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1728
+ return char.toUpperCase() + str;
1729
+ });
1730
+ }
1731
+
1732
+ function buildAccessors(obj, header) {
1733
+ const accessorName = utils$1.toCamelCase(' ' + header);
1734
+
1735
+ ['get', 'set', 'has'].forEach(methodName => {
1736
+ Object.defineProperty(obj, methodName + accessorName, {
1737
+ value: function(arg1, arg2, arg3) {
1738
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1739
+ },
1740
+ configurable: true
1741
+ });
1742
+ });
1743
+ }
1744
+
1745
+ let AxiosHeaders$1 = class AxiosHeaders {
1746
+ constructor(headers) {
1747
+ headers && this.set(headers);
1748
+ }
1749
+
1750
+ set(header, valueOrRewrite, rewrite) {
1751
+ const self = this;
1752
+
1753
+ function setHeader(_value, _header, _rewrite) {
1754
+ const lHeader = normalizeHeader(_header);
1755
+
1756
+ if (!lHeader) {
1757
+ throw new Error('header name must be a non-empty string');
1758
+ }
1759
+
1760
+ const key = utils$1.findKey(self, lHeader);
1761
+
1762
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1763
+ self[key || _header] = normalizeValue(_value);
1764
+ }
1765
+ }
1766
+
1767
+ const setHeaders = (headers, _rewrite) =>
1768
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1769
+
1770
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1771
+ setHeaders(header, valueOrRewrite);
1772
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1773
+ setHeaders(parseHeaders(header), valueOrRewrite);
1774
+ } else if (utils$1.isObject(header) && utils$1.isIterable(header)) {
1775
+ let obj = {}, dest, key;
1776
+ for (const entry of header) {
1777
+ if (!utils$1.isArray(entry)) {
1778
+ throw TypeError('Object iterator must return a key-value pair');
1779
+ }
1780
+
1781
+ obj[key = entry[0]] = (dest = obj[key]) ?
1782
+ (utils$1.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]]) : entry[1];
1783
+ }
1784
+
1785
+ setHeaders(obj, valueOrRewrite);
1786
+ } else {
1787
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1788
+ }
1789
+
1790
+ return this;
1791
+ }
1792
+
1793
+ get(header, parser) {
1794
+ header = normalizeHeader(header);
1795
+
1796
+ if (header) {
1797
+ const key = utils$1.findKey(this, header);
1798
+
1799
+ if (key) {
1800
+ const value = this[key];
1801
+
1802
+ if (!parser) {
1803
+ return value;
1804
+ }
1805
+
1806
+ if (parser === true) {
1807
+ return parseTokens(value);
1808
+ }
1809
+
1810
+ if (utils$1.isFunction(parser)) {
1811
+ return parser.call(this, value, key);
1812
+ }
1813
+
1814
+ if (utils$1.isRegExp(parser)) {
1815
+ return parser.exec(value);
1816
+ }
1817
+
1818
+ throw new TypeError('parser must be boolean|regexp|function');
1819
+ }
1820
+ }
1821
+ }
1822
+
1823
+ has(header, matcher) {
1824
+ header = normalizeHeader(header);
1825
+
1826
+ if (header) {
1827
+ const key = utils$1.findKey(this, header);
1828
+
1829
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1830
+ }
1831
+
1832
+ return false;
1833
+ }
1834
+
1835
+ delete(header, matcher) {
1836
+ const self = this;
1837
+ let deleted = false;
1838
+
1839
+ function deleteHeader(_header) {
1840
+ _header = normalizeHeader(_header);
1841
+
1842
+ if (_header) {
1843
+ const key = utils$1.findKey(self, _header);
1844
+
1845
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1846
+ delete self[key];
1847
+
1848
+ deleted = true;
1849
+ }
1850
+ }
1851
+ }
1852
+
1853
+ if (utils$1.isArray(header)) {
1854
+ header.forEach(deleteHeader);
1855
+ } else {
1856
+ deleteHeader(header);
1857
+ }
1858
+
1859
+ return deleted;
1860
+ }
1861
+
1862
+ clear(matcher) {
1863
+ const keys = Object.keys(this);
1864
+ let i = keys.length;
1865
+ let deleted = false;
1866
+
1867
+ while (i--) {
1868
+ const key = keys[i];
1869
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1870
+ delete this[key];
1871
+ deleted = true;
1872
+ }
1873
+ }
1874
+
1875
+ return deleted;
1876
+ }
1877
+
1878
+ normalize(format) {
1879
+ const self = this;
1880
+ const headers = {};
1881
+
1882
+ utils$1.forEach(this, (value, header) => {
1883
+ const key = utils$1.findKey(headers, header);
1884
+
1885
+ if (key) {
1886
+ self[key] = normalizeValue(value);
1887
+ delete self[header];
1888
+ return;
1889
+ }
1890
+
1891
+ const normalized = format ? formatHeader(header) : String(header).trim();
1892
+
1893
+ if (normalized !== header) {
1894
+ delete self[header];
1895
+ }
1896
+
1897
+ self[normalized] = normalizeValue(value);
1898
+
1899
+ headers[normalized] = true;
1900
+ });
1901
+
1902
+ return this;
1903
+ }
1904
+
1905
+ concat(...targets) {
1906
+ return this.constructor.concat(this, ...targets);
1907
+ }
1908
+
1909
+ toJSON(asStrings) {
1910
+ const obj = Object.create(null);
1911
+
1912
+ utils$1.forEach(this, (value, header) => {
1913
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1914
+ });
1915
+
1916
+ return obj;
1917
+ }
1918
+
1919
+ [Symbol.iterator]() {
1920
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1921
+ }
1922
+
1923
+ toString() {
1924
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1925
+ }
1926
+
1927
+ getSetCookie() {
1928
+ return this.get("set-cookie") || [];
1929
+ }
1930
+
1931
+ get [Symbol.toStringTag]() {
1932
+ return 'AxiosHeaders';
1933
+ }
1934
+
1935
+ static from(thing) {
1936
+ return thing instanceof this ? thing : new this(thing);
1937
+ }
1938
+
1939
+ static concat(first, ...targets) {
1940
+ const computed = new this(first);
1941
+
1942
+ targets.forEach((target) => computed.set(target));
1943
+
1944
+ return computed;
1945
+ }
1946
+
1947
+ static accessor(header) {
1948
+ const internals = this[$internals] = (this[$internals] = {
1949
+ accessors: {}
1950
+ });
1951
+
1952
+ const accessors = internals.accessors;
1953
+ const prototype = this.prototype;
1954
+
1955
+ function defineAccessor(_header) {
1956
+ const lHeader = normalizeHeader(_header);
1957
+
1958
+ if (!accessors[lHeader]) {
1959
+ buildAccessors(prototype, _header);
1960
+ accessors[lHeader] = true;
1961
+ }
1962
+ }
1963
+
1964
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1965
+
1966
+ return this;
1967
+ }
1968
+ };
1969
+
1970
+ AxiosHeaders$1.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1971
+
1972
+ // reserved names hotfix
1973
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({value}, key) => {
1974
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1975
+ return {
1976
+ get: () => value,
1977
+ set(headerValue) {
1978
+ this[mapped] = headerValue;
1979
+ }
1980
+ }
1981
+ });
1982
+
1983
+ utils$1.freezeMethods(AxiosHeaders$1);
1984
+
1985
+ /**
1986
+ * Transform the data for a request or a response
1987
+ *
1988
+ * @param {Array|Function} fns A single function or Array of functions
1989
+ * @param {?Object} response The response object
1990
+ *
1991
+ * @returns {*} The resulting transformed data
1992
+ */
1993
+ function transformData(fns, response) {
1994
+ const config = this || defaults;
1995
+ const context = response || config;
1996
+ const headers = AxiosHeaders$1.from(context.headers);
1997
+ let data = context.data;
1998
+
1999
+ utils$1.forEach(fns, function transform(fn) {
2000
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2001
+ });
2002
+
2003
+ headers.normalize();
2004
+
2005
+ return data;
2006
+ }
2007
+
2008
+ function isCancel$1(value) {
2009
+ return !!(value && value.__CANCEL__);
2010
+ }
2011
+
2012
+ /**
2013
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2014
+ *
2015
+ * @param {string=} message The message.
2016
+ * @param {Object=} config The config.
2017
+ * @param {Object=} request The request.
2018
+ *
2019
+ * @returns {CanceledError} The created error.
2020
+ */
2021
+ function CanceledError$1(message, config, request) {
2022
+ // eslint-disable-next-line no-eq-null,eqeqeq
2023
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
2024
+ this.name = 'CanceledError';
2025
+ }
2026
+
2027
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
2028
+ __CANCEL__: true
2029
+ });
2030
+
2031
+ /**
2032
+ * Resolve or reject a Promise based on response status.
2033
+ *
2034
+ * @param {Function} resolve A function that resolves the promise.
2035
+ * @param {Function} reject A function that rejects the promise.
2036
+ * @param {object} response The response.
2037
+ *
2038
+ * @returns {object} The response.
2039
+ */
2040
+ function settle(resolve, reject, response) {
2041
+ const validateStatus = response.config.validateStatus;
2042
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2043
+ resolve(response);
2044
+ } else {
2045
+ reject(new AxiosError$1(
2046
+ 'Request failed with status code ' + response.status,
2047
+ [AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2048
+ response.config,
2049
+ response.request,
2050
+ response
2051
+ ));
2052
+ }
2053
+ }
2054
+
2055
+ function parseProtocol(url) {
2056
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2057
+ return match && match[1] || '';
2058
+ }
2059
+
2060
+ /**
2061
+ * Calculate data maxRate
2062
+ * @param {Number} [samplesCount= 10]
2063
+ * @param {Number} [min= 1000]
2064
+ * @returns {Function}
2065
+ */
2066
+ function speedometer(samplesCount, min) {
2067
+ samplesCount = samplesCount || 10;
2068
+ const bytes = new Array(samplesCount);
2069
+ const timestamps = new Array(samplesCount);
2070
+ let head = 0;
2071
+ let tail = 0;
2072
+ let firstSampleTS;
2073
+
2074
+ min = min !== undefined ? min : 1000;
2075
+
2076
+ return function push(chunkLength) {
2077
+ const now = Date.now();
2078
+
2079
+ const startedAt = timestamps[tail];
2080
+
2081
+ if (!firstSampleTS) {
2082
+ firstSampleTS = now;
2083
+ }
2084
+
2085
+ bytes[head] = chunkLength;
2086
+ timestamps[head] = now;
2087
+
2088
+ let i = tail;
2089
+ let bytesCount = 0;
2090
+
2091
+ while (i !== head) {
2092
+ bytesCount += bytes[i++];
2093
+ i = i % samplesCount;
2094
+ }
2095
+
2096
+ head = (head + 1) % samplesCount;
2097
+
2098
+ if (head === tail) {
2099
+ tail = (tail + 1) % samplesCount;
2100
+ }
2101
+
2102
+ if (now - firstSampleTS < min) {
2103
+ return;
2104
+ }
2105
+
2106
+ const passed = startedAt && now - startedAt;
2107
+
2108
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2109
+ };
2110
+ }
2111
+
2112
+ /**
2113
+ * Throttle decorator
2114
+ * @param {Function} fn
2115
+ * @param {Number} freq
2116
+ * @return {Function}
2117
+ */
2118
+ function throttle(fn, freq) {
2119
+ let timestamp = 0;
2120
+ let threshold = 1000 / freq;
2121
+ let lastArgs;
2122
+ let timer;
2123
+
2124
+ const invoke = (args, now = Date.now()) => {
2125
+ timestamp = now;
2126
+ lastArgs = null;
2127
+ if (timer) {
2128
+ clearTimeout(timer);
2129
+ timer = null;
2130
+ }
2131
+ fn(...args);
2132
+ };
2133
+
2134
+ const throttled = (...args) => {
2135
+ const now = Date.now();
2136
+ const passed = now - timestamp;
2137
+ if ( passed >= threshold) {
2138
+ invoke(args, now);
2139
+ } else {
2140
+ lastArgs = args;
2141
+ if (!timer) {
2142
+ timer = setTimeout(() => {
2143
+ timer = null;
2144
+ invoke(lastArgs);
2145
+ }, threshold - passed);
2146
+ }
2147
+ }
2148
+ };
2149
+
2150
+ const flush = () => lastArgs && invoke(lastArgs);
2151
+
2152
+ return [throttled, flush];
2153
+ }
2154
+
2155
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2156
+ let bytesNotified = 0;
2157
+ const _speedometer = speedometer(50, 250);
2158
+
2159
+ return throttle(e => {
2160
+ const loaded = e.loaded;
2161
+ const total = e.lengthComputable ? e.total : undefined;
2162
+ const progressBytes = loaded - bytesNotified;
2163
+ const rate = _speedometer(progressBytes);
2164
+ const inRange = loaded <= total;
2165
+
2166
+ bytesNotified = loaded;
2167
+
2168
+ const data = {
2169
+ loaded,
2170
+ total,
2171
+ progress: total ? (loaded / total) : undefined,
2172
+ bytes: progressBytes,
2173
+ rate: rate ? rate : undefined,
2174
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2175
+ event: e,
2176
+ lengthComputable: total != null,
2177
+ [isDownloadStream ? 'download' : 'upload']: true
2178
+ };
2179
+
2180
+ listener(data);
2181
+ }, freq);
2182
+ };
2183
+
2184
+ const progressEventDecorator = (total, throttled) => {
2185
+ const lengthComputable = total != null;
2186
+
2187
+ return [(loaded) => throttled[0]({
2188
+ lengthComputable,
2189
+ total,
2190
+ loaded
2191
+ }), throttled[1]];
2192
+ };
2193
+
2194
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2195
+
2196
+ const isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2197
+ url = new URL(url, platform.origin);
2198
+
2199
+ return (
2200
+ origin.protocol === url.protocol &&
2201
+ origin.host === url.host &&
2202
+ (isMSIE || origin.port === url.port)
2203
+ );
2204
+ })(
2205
+ new URL(platform.origin),
2206
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2207
+ ) : () => true;
2208
+
2209
+ const cookies = platform.hasStandardBrowserEnv ?
2210
+
2211
+ // Standard browser envs support document.cookie
2212
+ {
2213
+ write(name, value, expires, path, domain, secure) {
2214
+ const cookie = [name + '=' + encodeURIComponent(value)];
2215
+
2216
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2217
+
2218
+ utils$1.isString(path) && cookie.push('path=' + path);
2219
+
2220
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2221
+
2222
+ secure === true && cookie.push('secure');
2223
+
2224
+ document.cookie = cookie.join('; ');
2225
+ },
2226
+
2227
+ read(name) {
2228
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2229
+ return (match ? decodeURIComponent(match[3]) : null);
2230
+ },
2231
+
2232
+ remove(name) {
2233
+ this.write(name, '', Date.now() - 86400000);
2234
+ }
2235
+ }
2236
+
2237
+ :
2238
+
2239
+ // Non-standard browser env (web workers, react-native) lack needed support.
2240
+ {
2241
+ write() {},
2242
+ read() {
2243
+ return null;
2244
+ },
2245
+ remove() {}
2246
+ };
2247
+
2248
+ /**
2249
+ * Determines whether the specified URL is absolute
2250
+ *
2251
+ * @param {string} url The URL to test
2252
+ *
2253
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2254
+ */
2255
+ function isAbsoluteURL(url) {
2256
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2257
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2258
+ // by any combination of letters, digits, plus, period, or hyphen.
2259
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2260
+ }
2261
+
2262
+ /**
2263
+ * Creates a new URL by combining the specified URLs
2264
+ *
2265
+ * @param {string} baseURL The base URL
2266
+ * @param {string} relativeURL The relative URL
2267
+ *
2268
+ * @returns {string} The combined URL
2269
+ */
2270
+ function combineURLs(baseURL, relativeURL) {
2271
+ return relativeURL
2272
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2273
+ : baseURL;
2274
+ }
2275
+
2276
+ /**
2277
+ * Creates a new URL by combining the baseURL with the requestedURL,
2278
+ * only when the requestedURL is not already an absolute URL.
2279
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2280
+ *
2281
+ * @param {string} baseURL The base URL
2282
+ * @param {string} requestedURL Absolute or relative URL to combine
2283
+ *
2284
+ * @returns {string} The combined full path
2285
+ */
2286
+ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
2287
+ let isRelativeUrl = !isAbsoluteURL(requestedURL);
2288
+ if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
2289
+ return combineURLs(baseURL, requestedURL);
2290
+ }
2291
+ return requestedURL;
2292
+ }
2293
+
2294
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
2295
+
2296
+ /**
2297
+ * Config-specific merge-function which creates a new config-object
2298
+ * by merging two configuration objects together.
2299
+ *
2300
+ * @param {Object} config1
2301
+ * @param {Object} config2
2302
+ *
2303
+ * @returns {Object} New object resulting from merging config2 to config1
2304
+ */
2305
+ function mergeConfig$1(config1, config2) {
2306
+ // eslint-disable-next-line no-param-reassign
2307
+ config2 = config2 || {};
2308
+ const config = {};
2309
+
2310
+ function getMergedValue(target, source, prop, caseless) {
2311
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2312
+ return utils$1.merge.call({caseless}, target, source);
2313
+ } else if (utils$1.isPlainObject(source)) {
2314
+ return utils$1.merge({}, source);
2315
+ } else if (utils$1.isArray(source)) {
2316
+ return source.slice();
2317
+ }
2318
+ return source;
2319
+ }
2320
+
2321
+ // eslint-disable-next-line consistent-return
2322
+ function mergeDeepProperties(a, b, prop , caseless) {
2323
+ if (!utils$1.isUndefined(b)) {
2324
+ return getMergedValue(a, b, prop , caseless);
2325
+ } else if (!utils$1.isUndefined(a)) {
2326
+ return getMergedValue(undefined, a, prop , caseless);
2327
+ }
2328
+ }
2329
+
2330
+ // eslint-disable-next-line consistent-return
2331
+ function valueFromConfig2(a, b) {
2332
+ if (!utils$1.isUndefined(b)) {
2333
+ return getMergedValue(undefined, b);
2334
+ }
2335
+ }
2336
+
2337
+ // eslint-disable-next-line consistent-return
2338
+ function defaultToConfig2(a, b) {
2339
+ if (!utils$1.isUndefined(b)) {
2340
+ return getMergedValue(undefined, b);
2341
+ } else if (!utils$1.isUndefined(a)) {
2342
+ return getMergedValue(undefined, a);
2343
+ }
2344
+ }
2345
+
2346
+ // eslint-disable-next-line consistent-return
2347
+ function mergeDirectKeys(a, b, prop) {
2348
+ if (prop in config2) {
2349
+ return getMergedValue(a, b);
2350
+ } else if (prop in config1) {
2351
+ return getMergedValue(undefined, a);
2352
+ }
2353
+ }
2354
+
2355
+ const mergeMap = {
2356
+ url: valueFromConfig2,
2357
+ method: valueFromConfig2,
2358
+ data: valueFromConfig2,
2359
+ baseURL: defaultToConfig2,
2360
+ transformRequest: defaultToConfig2,
2361
+ transformResponse: defaultToConfig2,
2362
+ paramsSerializer: defaultToConfig2,
2363
+ timeout: defaultToConfig2,
2364
+ timeoutMessage: defaultToConfig2,
2365
+ withCredentials: defaultToConfig2,
2366
+ withXSRFToken: defaultToConfig2,
2367
+ adapter: defaultToConfig2,
2368
+ responseType: defaultToConfig2,
2369
+ xsrfCookieName: defaultToConfig2,
2370
+ xsrfHeaderName: defaultToConfig2,
2371
+ onUploadProgress: defaultToConfig2,
2372
+ onDownloadProgress: defaultToConfig2,
2373
+ decompress: defaultToConfig2,
2374
+ maxContentLength: defaultToConfig2,
2375
+ maxBodyLength: defaultToConfig2,
2376
+ beforeRedirect: defaultToConfig2,
2377
+ transport: defaultToConfig2,
2378
+ httpAgent: defaultToConfig2,
2379
+ httpsAgent: defaultToConfig2,
2380
+ cancelToken: defaultToConfig2,
2381
+ socketPath: defaultToConfig2,
2382
+ responseEncoding: defaultToConfig2,
2383
+ validateStatus: mergeDirectKeys,
2384
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2385
+ };
2386
+
2387
+ utils$1.forEach(Object.keys({...config1, ...config2}), function computeConfigValue(prop) {
2388
+ const merge = mergeMap[prop] || mergeDeepProperties;
2389
+ const configValue = merge(config1[prop], config2[prop], prop);
2390
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2391
+ });
2392
+
2393
+ return config;
2394
+ }
2395
+
2396
+ const resolveConfig = (config) => {
2397
+ const newConfig = mergeConfig$1({}, config);
2398
+
2399
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
2400
+
2401
+ newConfig.headers = headers = AxiosHeaders$1.from(headers);
2402
+
2403
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
2404
+
2405
+ // HTTP basic authentication
2406
+ if (auth) {
2407
+ headers.set('Authorization', 'Basic ' +
2408
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2409
+ );
2410
+ }
2411
+
2412
+ if (utils$1.isFormData(data)) {
2413
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2414
+ headers.setContentType(undefined); // browser handles it
2415
+ } else if (utils$1.isFunction(data.getHeaders)) {
2416
+ // Node.js FormData (like form-data package)
2417
+ const formHeaders = data.getHeaders();
2418
+ // Only set safe headers to avoid overwriting security headers
2419
+ const allowedHeaders = ['content-type', 'content-length'];
2420
+ Object.entries(formHeaders).forEach(([key, val]) => {
2421
+ if (allowedHeaders.includes(key.toLowerCase())) {
2422
+ headers.set(key, val);
2423
+ }
2424
+ });
2425
+ }
2426
+ }
2427
+
2428
+ // Add xsrf header
2429
+ // This is only done if running in a standard browser environment.
2430
+ // Specifically not if we're in a web worker, or react-native.
2431
+
2432
+ if (platform.hasStandardBrowserEnv) {
2433
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2434
+
2435
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2436
+ // Add xsrf header
2437
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2438
+
2439
+ if (xsrfValue) {
2440
+ headers.set(xsrfHeaderName, xsrfValue);
2441
+ }
2442
+ }
2443
+ }
2444
+
2445
+ return newConfig;
2446
+ };
2447
+
2448
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2449
+
2450
+ const xhrAdapter = isXHRAdapterSupported && function (config) {
2451
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2452
+ const _config = resolveConfig(config);
2453
+ let requestData = _config.data;
2454
+ const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
2455
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2456
+ let onCanceled;
2457
+ let uploadThrottled, downloadThrottled;
2458
+ let flushUpload, flushDownload;
2459
+
2460
+ function done() {
2461
+ flushUpload && flushUpload(); // flush events
2462
+ flushDownload && flushDownload(); // flush events
2463
+
2464
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2465
+
2466
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2467
+ }
2468
+
2469
+ let request = new XMLHttpRequest();
2470
+
2471
+ request.open(_config.method.toUpperCase(), _config.url, true);
2472
+
2473
+ // Set the request timeout in MS
2474
+ request.timeout = _config.timeout;
2475
+
2476
+ function onloadend() {
2477
+ if (!request) {
2478
+ return;
2479
+ }
2480
+ // Prepare the response
2481
+ const responseHeaders = AxiosHeaders$1.from(
2482
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2483
+ );
2484
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2485
+ request.responseText : request.response;
2486
+ const response = {
2487
+ data: responseData,
2488
+ status: request.status,
2489
+ statusText: request.statusText,
2490
+ headers: responseHeaders,
2491
+ config,
2492
+ request
2493
+ };
2494
+
2495
+ settle(function _resolve(value) {
2496
+ resolve(value);
2497
+ done();
2498
+ }, function _reject(err) {
2499
+ reject(err);
2500
+ done();
2501
+ }, response);
2502
+
2503
+ // Clean up request
2504
+ request = null;
2505
+ }
2506
+
2507
+ if ('onloadend' in request) {
2508
+ // Use onloadend if available
2509
+ request.onloadend = onloadend;
2510
+ } else {
2511
+ // Listen for ready state to emulate onloadend
2512
+ request.onreadystatechange = function handleLoad() {
2513
+ if (!request || request.readyState !== 4) {
2514
+ return;
2515
+ }
2516
+
2517
+ // The request errored out and we didn't get a response, this will be
2518
+ // handled by onerror instead
2519
+ // With one exception: request that using file: protocol, most browsers
2520
+ // will return status as 0 even though it's a successful request
2521
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2522
+ return;
2523
+ }
2524
+ // readystate handler is calling before onerror or ontimeout handlers,
2525
+ // so we should call onloadend on the next 'tick'
2526
+ setTimeout(onloadend);
2527
+ };
2528
+ }
2529
+
2530
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2531
+ request.onabort = function handleAbort() {
2532
+ if (!request) {
2533
+ return;
2534
+ }
2535
+
2536
+ reject(new AxiosError$1('Request aborted', AxiosError$1.ECONNABORTED, config, request));
2537
+
2538
+ // Clean up request
2539
+ request = null;
2540
+ };
2541
+
2542
+ // Handle low level network errors
2543
+ request.onerror = function handleError(event) {
2544
+ // Browsers deliver a ProgressEvent in XHR onerror
2545
+ // (message may be empty; when present, surface it)
2546
+ // See https://developer.mozilla.org/docs/Web/API/XMLHttpRequest/error_event
2547
+ const msg = event && event.message ? event.message : 'Network Error';
2548
+ const err = new AxiosError$1(msg, AxiosError$1.ERR_NETWORK, config, request);
2549
+ // attach the underlying event for consumers who want details
2550
+ err.event = event || null;
2551
+ reject(err);
2552
+ request = null;
2553
+ };
2554
+
2555
+ // Handle timeout
2556
+ request.ontimeout = function handleTimeout() {
2557
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2558
+ const transitional = _config.transitional || transitionalDefaults;
2559
+ if (_config.timeoutErrorMessage) {
2560
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2561
+ }
2562
+ reject(new AxiosError$1(
2563
+ timeoutErrorMessage,
2564
+ transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
2565
+ config,
2566
+ request));
2567
+
2568
+ // Clean up request
2569
+ request = null;
2570
+ };
2571
+
2572
+ // Remove Content-Type if data is undefined
2573
+ requestData === undefined && requestHeaders.setContentType(null);
2574
+
2575
+ // Add headers to the request
2576
+ if ('setRequestHeader' in request) {
2577
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2578
+ request.setRequestHeader(key, val);
2579
+ });
2580
+ }
2581
+
2582
+ // Add withCredentials to request if needed
2583
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2584
+ request.withCredentials = !!_config.withCredentials;
2585
+ }
2586
+
2587
+ // Add responseType to request if needed
2588
+ if (responseType && responseType !== 'json') {
2589
+ request.responseType = _config.responseType;
2590
+ }
2591
+
2592
+ // Handle progress if needed
2593
+ if (onDownloadProgress) {
2594
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2595
+ request.addEventListener('progress', downloadThrottled);
2596
+ }
2597
+
2598
+ // Not all browsers support upload events
2599
+ if (onUploadProgress && request.upload) {
2600
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2601
+
2602
+ request.upload.addEventListener('progress', uploadThrottled);
2603
+
2604
+ request.upload.addEventListener('loadend', flushUpload);
2605
+ }
2606
+
2607
+ if (_config.cancelToken || _config.signal) {
2608
+ // Handle cancellation
2609
+ // eslint-disable-next-line func-names
2610
+ onCanceled = cancel => {
2611
+ if (!request) {
2612
+ return;
2613
+ }
2614
+ reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
2615
+ request.abort();
2616
+ request = null;
2617
+ };
2618
+
2619
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2620
+ if (_config.signal) {
2621
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2622
+ }
2623
+ }
2624
+
2625
+ const protocol = parseProtocol(_config.url);
2626
+
2627
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2628
+ reject(new AxiosError$1('Unsupported protocol ' + protocol + ':', AxiosError$1.ERR_BAD_REQUEST, config));
2629
+ return;
2630
+ }
2631
+
2632
+
2633
+ // Send the request
2634
+ request.send(requestData || null);
2635
+ });
2636
+ };
2637
+
2638
+ const composeSignals = (signals, timeout) => {
2639
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
2640
+
2641
+ if (timeout || length) {
2642
+ let controller = new AbortController();
2643
+
2644
+ let aborted;
2645
+
2646
+ const onabort = function (reason) {
2647
+ if (!aborted) {
2648
+ aborted = true;
2649
+ unsubscribe();
2650
+ const err = reason instanceof Error ? reason : this.reason;
2651
+ controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
2652
+ }
2653
+ };
2654
+
2655
+ let timer = timeout && setTimeout(() => {
2656
+ timer = null;
2657
+ onabort(new AxiosError$1(`timeout ${timeout} of ms exceeded`, AxiosError$1.ETIMEDOUT));
2658
+ }, timeout);
2659
+
2660
+ const unsubscribe = () => {
2661
+ if (signals) {
2662
+ timer && clearTimeout(timer);
2663
+ timer = null;
2664
+ signals.forEach(signal => {
2665
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2666
+ });
2667
+ signals = null;
2668
+ }
2669
+ };
2670
+
2671
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
2672
+
2673
+ const {signal} = controller;
2674
+
2675
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2676
+
2677
+ return signal;
2678
+ }
2679
+ };
2680
+
2681
+ const streamChunk = function* (chunk, chunkSize) {
2682
+ let len = chunk.byteLength;
2683
+
2684
+ if (len < chunkSize) {
2685
+ yield chunk;
2686
+ return;
2687
+ }
2688
+
2689
+ let pos = 0;
2690
+ let end;
2691
+
2692
+ while (pos < len) {
2693
+ end = pos + chunkSize;
2694
+ yield chunk.slice(pos, end);
2695
+ pos = end;
2696
+ }
2697
+ };
2698
+
2699
+ const readBytes = async function* (iterable, chunkSize) {
2700
+ for await (const chunk of readStream(iterable)) {
2701
+ yield* streamChunk(chunk, chunkSize);
2702
+ }
2703
+ };
2704
+
2705
+ const readStream = async function* (stream) {
2706
+ if (stream[Symbol.asyncIterator]) {
2707
+ yield* stream;
2708
+ return;
2709
+ }
2710
+
2711
+ const reader = stream.getReader();
2712
+ try {
2713
+ for (;;) {
2714
+ const {done, value} = await reader.read();
2715
+ if (done) {
2716
+ break;
2717
+ }
2718
+ yield value;
2719
+ }
2720
+ } finally {
2721
+ await reader.cancel();
2722
+ }
2723
+ };
2724
+
2725
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2726
+ const iterator = readBytes(stream, chunkSize);
2727
+
2728
+ let bytes = 0;
2729
+ let done;
2730
+ let _onFinish = (e) => {
2731
+ if (!done) {
2732
+ done = true;
2733
+ onFinish && onFinish(e);
2734
+ }
2735
+ };
2736
+
2737
+ return new ReadableStream({
2738
+ async pull(controller) {
2739
+ try {
2740
+ const {done, value} = await iterator.next();
2741
+
2742
+ if (done) {
2743
+ _onFinish();
2744
+ controller.close();
2745
+ return;
2746
+ }
2747
+
2748
+ let len = value.byteLength;
2749
+ if (onProgress) {
2750
+ let loadedBytes = bytes += len;
2751
+ onProgress(loadedBytes);
2752
+ }
2753
+ controller.enqueue(new Uint8Array(value));
2754
+ } catch (err) {
2755
+ _onFinish(err);
2756
+ throw err;
2757
+ }
2758
+ },
2759
+ cancel(reason) {
2760
+ _onFinish(reason);
2761
+ return iterator.return();
2762
+ }
2763
+ }, {
2764
+ highWaterMark: 2
2765
+ })
2766
+ };
2767
+
2768
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2769
+
2770
+ const {isFunction} = utils$1;
2771
+
2772
+ const globalFetchAPI = (({Request, Response}) => ({
2773
+ Request, Response
2774
+ }))(utils$1.global);
2775
+
2776
+ const {
2777
+ ReadableStream: ReadableStream$1, TextEncoder
2778
+ } = utils$1.global;
2779
+
2780
+
2781
+ const test = (fn, ...args) => {
2782
+ try {
2783
+ return !!fn(...args);
2784
+ } catch (e) {
2785
+ return false
2786
+ }
2787
+ };
2788
+
2789
+ const factory = (env) => {
2790
+ env = utils$1.merge.call({
2791
+ skipUndefined: true
2792
+ }, globalFetchAPI, env);
2793
+
2794
+ const {fetch: envFetch, Request, Response} = env;
2795
+ const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === 'function';
2796
+ const isRequestSupported = isFunction(Request);
2797
+ const isResponseSupported = isFunction(Response);
2798
+
2799
+ if (!isFetchSupported) {
2800
+ return false;
2801
+ }
2802
+
2803
+ const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
2804
+
2805
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2806
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2807
+ async (str) => new Uint8Array(await new Request(str).arrayBuffer())
2808
+ );
2809
+
2810
+ const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
2811
+ let duplexAccessed = false;
2812
+
2813
+ const hasContentType = new Request(platform.origin, {
2814
+ body: new ReadableStream$1(),
2815
+ method: 'POST',
2816
+ get duplex() {
2817
+ duplexAccessed = true;
2818
+ return 'half';
2819
+ },
2820
+ }).headers.has('Content-Type');
2821
+
2822
+ return duplexAccessed && !hasContentType;
2823
+ });
2824
+
2825
+ const supportsResponseStream = isResponseSupported && isReadableStreamSupported &&
2826
+ test(() => utils$1.isReadableStream(new Response('').body));
2827
+
2828
+ const resolvers = {
2829
+ stream: supportsResponseStream && ((res) => res.body)
2830
+ };
2831
+
2832
+ isFetchSupported && ((() => {
2833
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2834
+ !resolvers[type] && (resolvers[type] = (res, config) => {
2835
+ let method = res && res[type];
2836
+
2837
+ if (method) {
2838
+ return method.call(res);
2839
+ }
2840
+
2841
+ throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
2842
+ });
2843
+ });
2844
+ })());
2845
+
2846
+ const getBodyLength = async (body) => {
2847
+ if (body == null) {
2848
+ return 0;
2849
+ }
2850
+
2851
+ if (utils$1.isBlob(body)) {
2852
+ return body.size;
2853
+ }
2854
+
2855
+ if (utils$1.isSpecCompliantForm(body)) {
2856
+ const _request = new Request(platform.origin, {
2857
+ method: 'POST',
2858
+ body,
2859
+ });
2860
+ return (await _request.arrayBuffer()).byteLength;
2861
+ }
2862
+
2863
+ if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
2864
+ return body.byteLength;
2865
+ }
2866
+
2867
+ if (utils$1.isURLSearchParams(body)) {
2868
+ body = body + '';
2869
+ }
2870
+
2871
+ if (utils$1.isString(body)) {
2872
+ return (await encodeText(body)).byteLength;
2873
+ }
2874
+ };
2875
+
2876
+ const resolveBodyLength = async (headers, body) => {
2877
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
2878
+
2879
+ return length == null ? getBodyLength(body) : length;
2880
+ };
2881
+
2882
+ return async (config) => {
2883
+ let {
2884
+ url,
2885
+ method,
2886
+ data,
2887
+ signal,
2888
+ cancelToken,
2889
+ timeout,
2890
+ onDownloadProgress,
2891
+ onUploadProgress,
2892
+ responseType,
2893
+ headers,
2894
+ withCredentials = 'same-origin',
2895
+ fetchOptions
2896
+ } = resolveConfig(config);
2897
+
2898
+ let _fetch = envFetch || fetch;
2899
+
2900
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
2901
+
2902
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2903
+
2904
+ let request = null;
2905
+
2906
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2907
+ composedSignal.unsubscribe();
2908
+ });
2909
+
2910
+ let requestContentLength;
2911
+
2912
+ try {
2913
+ if (
2914
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
2915
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
2916
+ ) {
2917
+ let _request = new Request(url, {
2918
+ method: 'POST',
2919
+ body: data,
2920
+ duplex: "half"
2921
+ });
2922
+
2923
+ let contentTypeHeader;
2924
+
2925
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
2926
+ headers.setContentType(contentTypeHeader);
2927
+ }
2928
+
2929
+ if (_request.body) {
2930
+ const [onProgress, flush] = progressEventDecorator(
2931
+ requestContentLength,
2932
+ progressEventReducer(asyncDecorator(onUploadProgress))
2933
+ );
2934
+
2935
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2936
+ }
2937
+ }
2938
+
2939
+ if (!utils$1.isString(withCredentials)) {
2940
+ withCredentials = withCredentials ? 'include' : 'omit';
2941
+ }
2942
+
2943
+ // Cloudflare Workers throws when credentials are defined
2944
+ // see https://github.com/cloudflare/workerd/issues/902
2945
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2946
+
2947
+ const resolvedOptions = {
2948
+ ...fetchOptions,
2949
+ signal: composedSignal,
2950
+ method: method.toUpperCase(),
2951
+ headers: headers.normalize().toJSON(),
2952
+ body: data,
2953
+ duplex: "half",
2954
+ credentials: isCredentialsSupported ? withCredentials : undefined
2955
+ };
2956
+
2957
+ request = isRequestSupported && new Request(url, resolvedOptions);
2958
+
2959
+ let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
2960
+
2961
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
2962
+
2963
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
2964
+ const options = {};
2965
+
2966
+ ['status', 'statusText', 'headers'].forEach(prop => {
2967
+ options[prop] = response[prop];
2968
+ });
2969
+
2970
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
2971
+
2972
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2973
+ responseContentLength,
2974
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
2975
+ ) || [];
2976
+
2977
+ response = new Response(
2978
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2979
+ flush && flush();
2980
+ unsubscribe && unsubscribe();
2981
+ }),
2982
+ options
2983
+ );
2984
+ }
2985
+
2986
+ responseType = responseType || 'text';
2987
+
2988
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
2989
+
2990
+ !isStreamResponse && unsubscribe && unsubscribe();
2991
+
2992
+ return await new Promise((resolve, reject) => {
2993
+ settle(resolve, reject, {
2994
+ data: responseData,
2995
+ headers: AxiosHeaders$1.from(response.headers),
2996
+ status: response.status,
2997
+ statusText: response.statusText,
2998
+ config,
2999
+ request
3000
+ });
3001
+ })
3002
+ } catch (err) {
3003
+ unsubscribe && unsubscribe();
3004
+
3005
+ if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
3006
+ throw Object.assign(
3007
+ new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request),
3008
+ {
3009
+ cause: err.cause || err
3010
+ }
3011
+ )
3012
+ }
3013
+
3014
+ throw AxiosError$1.from(err, err && err.code, config, request);
3015
+ }
3016
+ }
3017
+ };
3018
+
3019
+ const seedCache = new Map();
3020
+
3021
+ const getFetch = (config) => {
3022
+ let env = config ? config.env : {};
3023
+ const {fetch, Request, Response} = env;
3024
+ const seeds = [
3025
+ Request, Response, fetch
3026
+ ];
3027
+
3028
+ let len = seeds.length, i = len,
3029
+ seed, target, map = seedCache;
3030
+
3031
+ while (i--) {
3032
+ seed = seeds[i];
3033
+ target = map.get(seed);
3034
+
3035
+ target === undefined && map.set(seed, target = (i ? new Map() : factory(env)));
3036
+
3037
+ map = target;
3038
+ }
3039
+
3040
+ return target;
3041
+ };
3042
+
3043
+ getFetch();
3044
+
3045
+ const knownAdapters = {
3046
+ http: httpAdapter,
3047
+ xhr: xhrAdapter,
3048
+ fetch: {
3049
+ get: getFetch,
3050
+ }
3051
+ };
3052
+
3053
+ utils$1.forEach(knownAdapters, (fn, value) => {
3054
+ if (fn) {
3055
+ try {
3056
+ Object.defineProperty(fn, 'name', {value});
3057
+ } catch (e) {
3058
+ // eslint-disable-next-line no-empty
3059
+ }
3060
+ Object.defineProperty(fn, 'adapterName', {value});
3061
+ }
3062
+ });
3063
+
3064
+ const renderReason = (reason) => `- ${reason}`;
3065
+
3066
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3067
+
3068
+ const adapters = {
3069
+ getAdapter: (adapters, config) => {
3070
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3071
+
3072
+ const {length} = adapters;
3073
+ let nameOrAdapter;
3074
+ let adapter;
3075
+
3076
+ const rejectedReasons = {};
3077
+
3078
+ for (let i = 0; i < length; i++) {
3079
+ nameOrAdapter = adapters[i];
3080
+ let id;
3081
+
3082
+ adapter = nameOrAdapter;
3083
+
3084
+ if (!isResolvedHandle(nameOrAdapter)) {
3085
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3086
+
3087
+ if (adapter === undefined) {
3088
+ throw new AxiosError$1(`Unknown adapter '${id}'`);
3089
+ }
3090
+ }
3091
+
3092
+ if (adapter && (utils$1.isFunction(adapter) || (adapter = adapter.get(config)))) {
3093
+ break;
3094
+ }
3095
+
3096
+ rejectedReasons[id || '#' + i] = adapter;
3097
+ }
3098
+
3099
+ if (!adapter) {
3100
+
3101
+ const reasons = Object.entries(rejectedReasons)
3102
+ .map(([id, state]) => `adapter ${id} ` +
3103
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3104
+ );
3105
+
3106
+ let s = length ?
3107
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3108
+ 'as no adapter specified';
3109
+
3110
+ throw new AxiosError$1(
3111
+ `There is no suitable adapter to dispatch the request ` + s,
3112
+ 'ERR_NOT_SUPPORT'
3113
+ );
3114
+ }
3115
+
3116
+ return adapter;
3117
+ },
3118
+ adapters: knownAdapters
3119
+ };
3120
+
3121
+ /**
3122
+ * Throws a `CanceledError` if cancellation has been requested.
3123
+ *
3124
+ * @param {Object} config The config that is to be used for the request
3125
+ *
3126
+ * @returns {void}
3127
+ */
3128
+ function throwIfCancellationRequested(config) {
3129
+ if (config.cancelToken) {
3130
+ config.cancelToken.throwIfRequested();
3131
+ }
3132
+
3133
+ if (config.signal && config.signal.aborted) {
3134
+ throw new CanceledError$1(null, config);
3135
+ }
3136
+ }
3137
+
3138
+ /**
3139
+ * Dispatch a request to the server using the configured adapter.
3140
+ *
3141
+ * @param {object} config The config that is to be used for the request
3142
+ *
3143
+ * @returns {Promise} The Promise to be fulfilled
3144
+ */
3145
+ function dispatchRequest(config) {
3146
+ throwIfCancellationRequested(config);
3147
+
3148
+ config.headers = AxiosHeaders$1.from(config.headers);
3149
+
3150
+ // Transform request data
3151
+ config.data = transformData.call(
3152
+ config,
3153
+ config.transformRequest
3154
+ );
3155
+
3156
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3157
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3158
+ }
3159
+
3160
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter, config);
3161
+
3162
+ return adapter(config).then(function onAdapterResolution(response) {
3163
+ throwIfCancellationRequested(config);
3164
+
3165
+ // Transform response data
3166
+ response.data = transformData.call(
3167
+ config,
3168
+ config.transformResponse,
3169
+ response
3170
+ );
3171
+
3172
+ response.headers = AxiosHeaders$1.from(response.headers);
3173
+
3174
+ return response;
3175
+ }, function onAdapterRejection(reason) {
3176
+ if (!isCancel$1(reason)) {
3177
+ throwIfCancellationRequested(config);
3178
+
3179
+ // Transform response data
3180
+ if (reason && reason.response) {
3181
+ reason.response.data = transformData.call(
3182
+ config,
3183
+ config.transformResponse,
3184
+ reason.response
3185
+ );
3186
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
3187
+ }
3188
+ }
3189
+
3190
+ return Promise.reject(reason);
3191
+ });
3192
+ }
3193
+
3194
+ const VERSION$1 = "1.12.2";
3195
+
3196
+ const validators$1 = {};
3197
+
3198
+ // eslint-disable-next-line func-names
3199
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
3200
+ validators$1[type] = function validator(thing) {
3201
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3202
+ };
3203
+ });
3204
+
3205
+ const deprecatedWarnings = {};
3206
+
3207
+ /**
3208
+ * Transitional option validator
3209
+ *
3210
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3211
+ * @param {string?} version - deprecated version / removed since version
3212
+ * @param {string?} message - some message with additional info
3213
+ *
3214
+ * @returns {function}
3215
+ */
3216
+ validators$1.transitional = function transitional(validator, version, message) {
3217
+ function formatMessage(opt, desc) {
3218
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3219
+ }
3220
+
3221
+ // eslint-disable-next-line func-names
3222
+ return (value, opt, opts) => {
3223
+ if (validator === false) {
3224
+ throw new AxiosError$1(
3225
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3226
+ AxiosError$1.ERR_DEPRECATED
3227
+ );
3228
+ }
3229
+
3230
+ if (version && !deprecatedWarnings[opt]) {
3231
+ deprecatedWarnings[opt] = true;
3232
+ // eslint-disable-next-line no-console
3233
+ console.warn(
3234
+ formatMessage(
3235
+ opt,
3236
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3237
+ )
3238
+ );
3239
+ }
3240
+
3241
+ return validator ? validator(value, opt, opts) : true;
3242
+ };
3243
+ };
3244
+
3245
+ validators$1.spelling = function spelling(correctSpelling) {
3246
+ return (value, opt) => {
3247
+ // eslint-disable-next-line no-console
3248
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3249
+ return true;
3250
+ }
3251
+ };
3252
+
3253
+ /**
3254
+ * Assert object's properties type
3255
+ *
3256
+ * @param {object} options
3257
+ * @param {object} schema
3258
+ * @param {boolean?} allowUnknown
3259
+ *
3260
+ * @returns {object}
3261
+ */
3262
+
3263
+ function assertOptions(options, schema, allowUnknown) {
3264
+ if (typeof options !== 'object') {
3265
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
3266
+ }
3267
+ const keys = Object.keys(options);
3268
+ let i = keys.length;
3269
+ while (i-- > 0) {
3270
+ const opt = keys[i];
3271
+ const validator = schema[opt];
3272
+ if (validator) {
3273
+ const value = options[opt];
3274
+ const result = value === undefined || validator(value, opt, options);
3275
+ if (result !== true) {
3276
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
3277
+ }
3278
+ continue;
3279
+ }
3280
+ if (allowUnknown !== true) {
3281
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
3282
+ }
3283
+ }
3284
+ }
3285
+
3286
+ const validator = {
3287
+ assertOptions,
3288
+ validators: validators$1
3289
+ };
3290
+
3291
+ const validators = validator.validators;
3292
+
3293
+ /**
3294
+ * Create a new instance of Axios
3295
+ *
3296
+ * @param {Object} instanceConfig The default config for the instance
3297
+ *
3298
+ * @return {Axios} A new instance of Axios
3299
+ */
3300
+ let Axios$1 = class Axios {
3301
+ constructor(instanceConfig) {
3302
+ this.defaults = instanceConfig || {};
3303
+ this.interceptors = {
3304
+ request: new InterceptorManager(),
3305
+ response: new InterceptorManager()
3306
+ };
3307
+ }
3308
+
3309
+ /**
3310
+ * Dispatch a request
3311
+ *
3312
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3313
+ * @param {?Object} config
3314
+ *
3315
+ * @returns {Promise} The Promise to be fulfilled
3316
+ */
3317
+ async request(configOrUrl, config) {
3318
+ try {
3319
+ return await this._request(configOrUrl, config);
3320
+ } catch (err) {
3321
+ if (err instanceof Error) {
3322
+ let dummy = {};
3323
+
3324
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3325
+
3326
+ // slice off the Error: ... line
3327
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3328
+ try {
3329
+ if (!err.stack) {
3330
+ err.stack = stack;
3331
+ // match without the 2 top stack lines
3332
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3333
+ err.stack += '\n' + stack;
3334
+ }
3335
+ } catch (e) {
3336
+ // ignore the case where "stack" is an un-writable property
3337
+ }
3338
+ }
3339
+
3340
+ throw err;
3341
+ }
3342
+ }
3343
+
3344
+ _request(configOrUrl, config) {
3345
+ /*eslint no-param-reassign:0*/
3346
+ // Allow for axios('example/url'[, config]) a la fetch API
3347
+ if (typeof configOrUrl === 'string') {
3348
+ config = config || {};
3349
+ config.url = configOrUrl;
3350
+ } else {
3351
+ config = configOrUrl || {};
3352
+ }
3353
+
3354
+ config = mergeConfig$1(this.defaults, config);
3355
+
3356
+ const {transitional, paramsSerializer, headers} = config;
3357
+
3358
+ if (transitional !== undefined) {
3359
+ validator.assertOptions(transitional, {
3360
+ silentJSONParsing: validators.transitional(validators.boolean),
3361
+ forcedJSONParsing: validators.transitional(validators.boolean),
3362
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3363
+ }, false);
3364
+ }
3365
+
3366
+ if (paramsSerializer != null) {
3367
+ if (utils$1.isFunction(paramsSerializer)) {
3368
+ config.paramsSerializer = {
3369
+ serialize: paramsSerializer
3370
+ };
3371
+ } else {
3372
+ validator.assertOptions(paramsSerializer, {
3373
+ encode: validators.function,
3374
+ serialize: validators.function
3375
+ }, true);
3376
+ }
3377
+ }
3378
+
3379
+ // Set config.allowAbsoluteUrls
3380
+ if (config.allowAbsoluteUrls !== undefined) ; else if (this.defaults.allowAbsoluteUrls !== undefined) {
3381
+ config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
3382
+ } else {
3383
+ config.allowAbsoluteUrls = true;
3384
+ }
3385
+
3386
+ validator.assertOptions(config, {
3387
+ baseUrl: validators.spelling('baseURL'),
3388
+ withXsrfToken: validators.spelling('withXSRFToken')
3389
+ }, true);
3390
+
3391
+ // Set config.method
3392
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3393
+
3394
+ // Flatten headers
3395
+ let contextHeaders = headers && utils$1.merge(
3396
+ headers.common,
3397
+ headers[config.method]
3398
+ );
3399
+
3400
+ headers && utils$1.forEach(
3401
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3402
+ (method) => {
3403
+ delete headers[method];
3404
+ }
3405
+ );
3406
+
3407
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
3408
+
3409
+ // filter out skipped interceptors
3410
+ const requestInterceptorChain = [];
3411
+ let synchronousRequestInterceptors = true;
3412
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3413
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3414
+ return;
3415
+ }
3416
+
3417
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3418
+
3419
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3420
+ });
3421
+
3422
+ const responseInterceptorChain = [];
3423
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3424
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3425
+ });
3426
+
3427
+ let promise;
3428
+ let i = 0;
3429
+ let len;
3430
+
3431
+ if (!synchronousRequestInterceptors) {
3432
+ const chain = [dispatchRequest.bind(this), undefined];
3433
+ chain.unshift(...requestInterceptorChain);
3434
+ chain.push(...responseInterceptorChain);
3435
+ len = chain.length;
3436
+
3437
+ promise = Promise.resolve(config);
3438
+
3439
+ while (i < len) {
3440
+ promise = promise.then(chain[i++], chain[i++]);
3441
+ }
3442
+
3443
+ return promise;
3444
+ }
3445
+
3446
+ len = requestInterceptorChain.length;
3447
+
3448
+ let newConfig = config;
3449
+
3450
+ while (i < len) {
3451
+ const onFulfilled = requestInterceptorChain[i++];
3452
+ const onRejected = requestInterceptorChain[i++];
3453
+ try {
3454
+ newConfig = onFulfilled(newConfig);
3455
+ } catch (error) {
3456
+ onRejected.call(this, error);
3457
+ break;
3458
+ }
3459
+ }
3460
+
3461
+ try {
3462
+ promise = dispatchRequest.call(this, newConfig);
3463
+ } catch (error) {
3464
+ return Promise.reject(error);
3465
+ }
3466
+
3467
+ i = 0;
3468
+ len = responseInterceptorChain.length;
3469
+
3470
+ while (i < len) {
3471
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3472
+ }
3473
+
3474
+ return promise;
3475
+ }
3476
+
3477
+ getUri(config) {
3478
+ config = mergeConfig$1(this.defaults, config);
3479
+ const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
3480
+ return buildURL(fullPath, config.params, config.paramsSerializer);
3481
+ }
3482
+ };
3483
+
3484
+ // Provide aliases for supported request methods
3485
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3486
+ /*eslint func-names:0*/
3487
+ Axios$1.prototype[method] = function(url, config) {
3488
+ return this.request(mergeConfig$1(config || {}, {
3489
+ method,
3490
+ url,
3491
+ data: (config || {}).data
3492
+ }));
3493
+ };
3494
+ });
3495
+
3496
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3497
+ /*eslint func-names:0*/
3498
+
3499
+ function generateHTTPMethod(isForm) {
3500
+ return function httpMethod(url, data, config) {
3501
+ return this.request(mergeConfig$1(config || {}, {
3502
+ method,
3503
+ headers: isForm ? {
3504
+ 'Content-Type': 'multipart/form-data'
3505
+ } : {},
3506
+ url,
3507
+ data
3508
+ }));
3509
+ };
3510
+ }
3511
+
3512
+ Axios$1.prototype[method] = generateHTTPMethod();
3513
+
3514
+ Axios$1.prototype[method + 'Form'] = generateHTTPMethod(true);
3515
+ });
3516
+
3517
+ /**
3518
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3519
+ *
3520
+ * @param {Function} executor The executor function.
3521
+ *
3522
+ * @returns {CancelToken}
3523
+ */
3524
+ let CancelToken$1 = class CancelToken {
3525
+ constructor(executor) {
3526
+ if (typeof executor !== 'function') {
3527
+ throw new TypeError('executor must be a function.');
3528
+ }
3529
+
3530
+ let resolvePromise;
3531
+
3532
+ this.promise = new Promise(function promiseExecutor(resolve) {
3533
+ resolvePromise = resolve;
3534
+ });
3535
+
3536
+ const token = this;
3537
+
3538
+ // eslint-disable-next-line func-names
3539
+ this.promise.then(cancel => {
3540
+ if (!token._listeners) return;
3541
+
3542
+ let i = token._listeners.length;
3543
+
3544
+ while (i-- > 0) {
3545
+ token._listeners[i](cancel);
3546
+ }
3547
+ token._listeners = null;
3548
+ });
3549
+
3550
+ // eslint-disable-next-line func-names
3551
+ this.promise.then = onfulfilled => {
3552
+ let _resolve;
3553
+ // eslint-disable-next-line func-names
3554
+ const promise = new Promise(resolve => {
3555
+ token.subscribe(resolve);
3556
+ _resolve = resolve;
3557
+ }).then(onfulfilled);
3558
+
3559
+ promise.cancel = function reject() {
3560
+ token.unsubscribe(_resolve);
3561
+ };
3562
+
3563
+ return promise;
3564
+ };
3565
+
3566
+ executor(function cancel(message, config, request) {
3567
+ if (token.reason) {
3568
+ // Cancellation has already been requested
3569
+ return;
3570
+ }
3571
+
3572
+ token.reason = new CanceledError$1(message, config, request);
3573
+ resolvePromise(token.reason);
3574
+ });
3575
+ }
3576
+
3577
+ /**
3578
+ * Throws a `CanceledError` if cancellation has been requested.
3579
+ */
3580
+ throwIfRequested() {
3581
+ if (this.reason) {
3582
+ throw this.reason;
3583
+ }
3584
+ }
3585
+
3586
+ /**
3587
+ * Subscribe to the cancel signal
3588
+ */
3589
+
3590
+ subscribe(listener) {
3591
+ if (this.reason) {
3592
+ listener(this.reason);
3593
+ return;
3594
+ }
3595
+
3596
+ if (this._listeners) {
3597
+ this._listeners.push(listener);
3598
+ } else {
3599
+ this._listeners = [listener];
3600
+ }
3601
+ }
3602
+
3603
+ /**
3604
+ * Unsubscribe from the cancel signal
3605
+ */
3606
+
3607
+ unsubscribe(listener) {
3608
+ if (!this._listeners) {
3609
+ return;
3610
+ }
3611
+ const index = this._listeners.indexOf(listener);
3612
+ if (index !== -1) {
3613
+ this._listeners.splice(index, 1);
3614
+ }
3615
+ }
3616
+
3617
+ toAbortSignal() {
3618
+ const controller = new AbortController();
3619
+
3620
+ const abort = (err) => {
3621
+ controller.abort(err);
3622
+ };
3623
+
3624
+ this.subscribe(abort);
3625
+
3626
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3627
+
3628
+ return controller.signal;
3629
+ }
3630
+
3631
+ /**
3632
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3633
+ * cancels the `CancelToken`.
3634
+ */
3635
+ static source() {
3636
+ let cancel;
3637
+ const token = new CancelToken(function executor(c) {
3638
+ cancel = c;
3639
+ });
3640
+ return {
3641
+ token,
3642
+ cancel
3643
+ };
3644
+ }
3645
+ };
3646
+
3647
+ /**
3648
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3649
+ *
3650
+ * Common use case would be to use `Function.prototype.apply`.
3651
+ *
3652
+ * ```js
3653
+ * function f(x, y, z) {}
3654
+ * var args = [1, 2, 3];
3655
+ * f.apply(null, args);
3656
+ * ```
3657
+ *
3658
+ * With `spread` this example can be re-written.
3659
+ *
3660
+ * ```js
3661
+ * spread(function(x, y, z) {})([1, 2, 3]);
3662
+ * ```
3663
+ *
3664
+ * @param {Function} callback
3665
+ *
3666
+ * @returns {Function}
3667
+ */
3668
+ function spread$1(callback) {
3669
+ return function wrap(arr) {
3670
+ return callback.apply(null, arr);
3671
+ };
3672
+ }
3673
+
3674
+ /**
3675
+ * Determines whether the payload is an error thrown by Axios
3676
+ *
3677
+ * @param {*} payload The value to test
3678
+ *
3679
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3680
+ */
3681
+ function isAxiosError$1(payload) {
3682
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
3683
+ }
3684
+
3685
+ const HttpStatusCode$1 = {
3686
+ Continue: 100,
3687
+ SwitchingProtocols: 101,
3688
+ Processing: 102,
3689
+ EarlyHints: 103,
3690
+ Ok: 200,
3691
+ Created: 201,
3692
+ Accepted: 202,
3693
+ NonAuthoritativeInformation: 203,
3694
+ NoContent: 204,
3695
+ ResetContent: 205,
3696
+ PartialContent: 206,
3697
+ MultiStatus: 207,
3698
+ AlreadyReported: 208,
3699
+ ImUsed: 226,
3700
+ MultipleChoices: 300,
3701
+ MovedPermanently: 301,
3702
+ Found: 302,
3703
+ SeeOther: 303,
3704
+ NotModified: 304,
3705
+ UseProxy: 305,
3706
+ Unused: 306,
3707
+ TemporaryRedirect: 307,
3708
+ PermanentRedirect: 308,
3709
+ BadRequest: 400,
3710
+ Unauthorized: 401,
3711
+ PaymentRequired: 402,
3712
+ Forbidden: 403,
3713
+ NotFound: 404,
3714
+ MethodNotAllowed: 405,
3715
+ NotAcceptable: 406,
3716
+ ProxyAuthenticationRequired: 407,
3717
+ RequestTimeout: 408,
3718
+ Conflict: 409,
3719
+ Gone: 410,
3720
+ LengthRequired: 411,
3721
+ PreconditionFailed: 412,
3722
+ PayloadTooLarge: 413,
3723
+ UriTooLong: 414,
3724
+ UnsupportedMediaType: 415,
3725
+ RangeNotSatisfiable: 416,
3726
+ ExpectationFailed: 417,
3727
+ ImATeapot: 418,
3728
+ MisdirectedRequest: 421,
3729
+ UnprocessableEntity: 422,
3730
+ Locked: 423,
3731
+ FailedDependency: 424,
3732
+ TooEarly: 425,
3733
+ UpgradeRequired: 426,
3734
+ PreconditionRequired: 428,
3735
+ TooManyRequests: 429,
3736
+ RequestHeaderFieldsTooLarge: 431,
3737
+ UnavailableForLegalReasons: 451,
3738
+ InternalServerError: 500,
3739
+ NotImplemented: 501,
3740
+ BadGateway: 502,
3741
+ ServiceUnavailable: 503,
3742
+ GatewayTimeout: 504,
3743
+ HttpVersionNotSupported: 505,
3744
+ VariantAlsoNegotiates: 506,
3745
+ InsufficientStorage: 507,
3746
+ LoopDetected: 508,
3747
+ NotExtended: 510,
3748
+ NetworkAuthenticationRequired: 511,
3749
+ };
3750
+
3751
+ Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
3752
+ HttpStatusCode$1[value] = key;
3753
+ });
3754
+
3755
+ /**
3756
+ * Create an instance of Axios
3757
+ *
3758
+ * @param {Object} defaultConfig The default config for the instance
3759
+ *
3760
+ * @returns {Axios} A new instance of Axios
3761
+ */
3762
+ function createInstance(defaultConfig) {
3763
+ const context = new Axios$1(defaultConfig);
3764
+ const instance = bind(Axios$1.prototype.request, context);
3765
+
3766
+ // Copy axios.prototype to instance
3767
+ utils$1.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
3768
+
3769
+ // Copy context to instance
3770
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
3771
+
3772
+ // Factory for creating new instances
3773
+ instance.create = function create(instanceConfig) {
3774
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3775
+ };
3776
+
3777
+ return instance;
3778
+ }
3779
+
3780
+ // Create the default instance to be exported
3781
+ const axios$1 = createInstance(defaults);
3782
+
3783
+ // Expose Axios class to allow class inheritance
3784
+ axios$1.Axios = Axios$1;
3785
+
3786
+ // Expose Cancel & CancelToken
3787
+ axios$1.CanceledError = CanceledError$1;
3788
+ axios$1.CancelToken = CancelToken$1;
3789
+ axios$1.isCancel = isCancel$1;
3790
+ axios$1.VERSION = VERSION$1;
3791
+ axios$1.toFormData = toFormData$1;
3792
+
3793
+ // Expose AxiosError class
3794
+ axios$1.AxiosError = AxiosError$1;
3795
+
3796
+ // alias for CanceledError for backward compatibility
3797
+ axios$1.Cancel = axios$1.CanceledError;
3798
+
3799
+ // Expose all/spread
3800
+ axios$1.all = function all(promises) {
3801
+ return Promise.all(promises);
3802
+ };
3803
+
3804
+ axios$1.spread = spread$1;
3805
+
3806
+ // Expose isAxiosError
3807
+ axios$1.isAxiosError = isAxiosError$1;
3808
+
3809
+ // Expose mergeConfig
3810
+ axios$1.mergeConfig = mergeConfig$1;
3811
+
3812
+ axios$1.AxiosHeaders = AxiosHeaders$1;
3813
+
3814
+ axios$1.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3815
+
3816
+ axios$1.getAdapter = adapters.getAdapter;
3817
+
3818
+ axios$1.HttpStatusCode = HttpStatusCode$1;
3819
+
3820
+ axios$1.default = axios$1;
3821
+
3822
+ // This module is intended to unwrap Axios default export as named.
3823
+ // Keep top-level export same with static properties
3824
+ // so that it can keep same with es module or cjs
3825
+ const {
3826
+ Axios,
3827
+ AxiosError,
3828
+ CanceledError,
3829
+ isCancel,
3830
+ CancelToken,
3831
+ VERSION,
3832
+ all,
3833
+ Cancel,
3834
+ isAxiosError,
3835
+ spread,
3836
+ toFormData,
3837
+ AxiosHeaders,
3838
+ HttpStatusCode,
3839
+ formToJSON,
3840
+ getAdapter,
3841
+ mergeConfig
3842
+ } = axios$1;
3843
+
3844
+ const defaultConfig = {
3845
+ csrf: {
3846
+ endpoint: "/csrf/token",
3847
+ enabled: true,
3848
+ headerName: "x-csrf-token"
3849
+ },
3850
+ axios: {
3851
+ baseURL: "/api",
3852
+ timeout: 3e4,
3853
+ withCredentials: true,
3854
+ headers: {
3855
+ "Content-Type": "application/json",
3856
+ Accept: "application/json"
3857
+ }
3858
+ },
3859
+ auth: {
3860
+ tokenHeaderName: "Authorization",
3861
+ tokenPrefix: "Bearer"
3862
+ }
3863
+ };
3864
+ let currentConfig = { ...defaultConfig };
3865
+ function defineConfig(config) {
3866
+ return config;
3867
+ }
3868
+ function configureQuantumUI(userConfig) {
3869
+ currentConfig = {
3870
+ csrf: {
3871
+ ...defaultConfig.csrf,
3872
+ ...userConfig.csrf || {}
3873
+ },
3874
+ axios: {
3875
+ ...defaultConfig.axios,
3876
+ ...userConfig.axios || {},
3877
+ headers: {
3878
+ ...defaultConfig.axios.headers,
3879
+ ...userConfig.axios?.headers || {}
3880
+ }
3881
+ },
3882
+ auth: {
3883
+ ...defaultConfig.auth,
3884
+ ...userConfig.auth || {}
3885
+ }
3886
+ };
3887
+ }
3888
+ function getConfig() {
3889
+ return currentConfig;
3890
+ }
3891
+ function resetConfig() {
3892
+ currentConfig = { ...defaultConfig };
3893
+ }
3894
+
3895
+ const tokenStore = {};
3896
+ let csrfToken = null;
3897
+ let csrfFetchPromise = null;
3898
+ const setCsrfToken = (token) => {
3899
+ if (!token || typeof token !== "string") {
3900
+ console.warn("[axios] Invalid CSRF token provided");
3901
+ return;
3902
+ }
3903
+ csrfToken = token;
3904
+ };
3905
+ const getCsrfToken = () => {
3906
+ return csrfToken;
3907
+ };
3908
+ const clearCsrfToken = () => {
3909
+ csrfToken = null;
3910
+ };
3911
+ const TOKEN_PRIORITY = ["access", "refresh", "onboarding"];
3912
+ const setToken = (type, token) => {
3913
+ if (!token || typeof token !== "string") {
3914
+ console.warn(`[axios] Invalid token provided for type: ${type}`);
3915
+ return;
3916
+ }
3917
+ tokenStore[type] = token;
3918
+ };
3919
+ const getToken = (type) => {
3920
+ return tokenStore[type] || null;
3921
+ };
3922
+ const clearToken = (type) => {
3923
+ delete tokenStore[type];
3924
+ };
3925
+ const clearAllTokens = () => {
3926
+ Object.keys(tokenStore).forEach((key) => {
3927
+ delete tokenStore[key];
3928
+ });
3929
+ };
3930
+ const getActiveToken = () => {
3931
+ for (const tokenType of TOKEN_PRIORITY) {
3932
+ const token = tokenStore[tokenType];
3933
+ if (token) {
3934
+ return token;
3935
+ }
3936
+ }
3937
+ return null;
3938
+ };
3939
+ async function fetchCsrfToken() {
3940
+ if (csrfFetchPromise) {
3941
+ return csrfFetchPromise;
3942
+ }
3943
+ csrfFetchPromise = (async () => {
3944
+ try {
3945
+ const config = getConfig();
3946
+ if (!config.csrf.enabled) {
3947
+ return null;
3948
+ }
3949
+ const response = await axios$1.get(config.csrf.endpoint, {
3950
+ baseURL: config.axios.baseURL,
3951
+ withCredentials: config.axios.withCredentials,
3952
+ timeout: config.axios.timeout
3953
+ });
3954
+ const token = response.data?.csrfToken;
3955
+ if (token && typeof token === "string") {
3956
+ setCsrfToken(token);
3957
+ return token;
3958
+ }
3959
+ console.warn("[axios] CSRF endpoint did not return a csrfToken field");
3960
+ return null;
3961
+ } catch (error) {
3962
+ console.error("[axios] Failed to fetch CSRF token:", error);
3963
+ return null;
3964
+ } finally {
3965
+ csrfFetchPromise = null;
3966
+ }
3967
+ })();
3968
+ return csrfFetchPromise;
3969
+ }
3970
+ function createAxiosInstance() {
3971
+ const config = getConfig();
3972
+ return axios$1.create({
3973
+ baseURL: config.axios.baseURL,
3974
+ withCredentials: config.axios.withCredentials,
3975
+ headers: config.axios.headers,
3976
+ timeout: config.axios.timeout
3977
+ });
3978
+ }
3979
+ const axios = createAxiosInstance();
3980
+ const getSubdomain = () => {
3981
+ if (typeof window === "undefined") {
3982
+ return null;
3983
+ }
3984
+ const hostname = window.location.hostname;
3985
+ const parts = hostname.split(".");
3986
+ if (parts.length >= 2 && parts[parts.length - 1] === "localhost") {
3987
+ return parts[0];
3988
+ }
3989
+ if (parts.length >= 3) {
3990
+ return parts[0];
3991
+ }
3992
+ return null;
3993
+ };
3994
+ axios.interceptors.request.use(
3995
+ async (config) => {
3996
+ const quantumConfig = getConfig();
3997
+ const token = getActiveToken();
3998
+ if (token) {
3999
+ const authHeaderName = quantumConfig.auth.tokenHeaderName;
4000
+ const tokenPrefix = quantumConfig.auth.tokenPrefix;
4001
+ config.headers[authHeaderName] = `${tokenPrefix} ${token}`;
4002
+ }
4003
+ const subdomain = getSubdomain();
4004
+ if (subdomain) {
4005
+ config.headers["x-subdomain"] = subdomain;
4006
+ }
4007
+ const isStateChangingRequest = ["post", "put", "patch", "delete"].includes(
4008
+ config.method?.toLowerCase() || ""
4009
+ );
4010
+ if (isStateChangingRequest && quantumConfig.csrf.enabled) {
4011
+ let csrfTokenValue = getCsrfToken();
4012
+ if (!csrfTokenValue) {
4013
+ csrfTokenValue = await fetchCsrfToken();
4014
+ }
4015
+ if (csrfTokenValue) {
4016
+ config.headers[quantumConfig.csrf.headerName] = csrfTokenValue;
4017
+ } else {
4018
+ console.warn("[axios] CSRF token not available for state-changing request");
4019
+ }
4020
+ }
4021
+ return config;
4022
+ },
4023
+ (error) => {
4024
+ return Promise.reject(error);
4025
+ }
4026
+ );
4027
+ axios.interceptors.response.use(
4028
+ (response) => {
4029
+ return response;
4030
+ },
4031
+ async (error) => {
4032
+ const originalRequest = error.config;
4033
+ if (error.response?.status === 401 && !originalRequest._retry) {
4034
+ originalRequest._retry = true;
4035
+ }
4036
+ return Promise.reject(error);
4037
+ }
4038
+ );
4039
+
4040
+ export { axios as a, getToken as b, configureQuantumUI as c, defineConfig as d, clearToken as e, clearAllTokens as f, getConfig as g, setCsrfToken as h, getCsrfToken as i, clearCsrfToken as j, resetConfig as r, setToken as s };
4041
+ //# sourceMappingURL=axios.js.map