@lx-frontend/multi-ajax 0.2.4-beta → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3193 @@
1
+ // Axios v1.3.4 Copyright (c) 2023 Matt Zabriskie and contributors
2
+ 'use strict';
3
+
4
+ function bind(fn, thisArg) {
5
+ return function wrap() {
6
+ return fn.apply(thisArg, arguments);
7
+ };
8
+ }
9
+
10
+ // utils is a library of generic helper functions non-specific to axios
11
+
12
+ const {toString} = Object.prototype;
13
+ const {getPrototypeOf} = Object;
14
+
15
+ const kindOf = (cache => thing => {
16
+ const str = toString.call(thing);
17
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
18
+ })(Object.create(null));
19
+
20
+ const kindOfTest = (type) => {
21
+ type = type.toLowerCase();
22
+ return (thing) => kindOf(thing) === type
23
+ };
24
+
25
+ const typeOfTest = type => thing => typeof thing === type;
26
+
27
+ /**
28
+ * Determine if a value is an Array
29
+ *
30
+ * @param {Object} val The value to test
31
+ *
32
+ * @returns {boolean} True if value is an Array, otherwise false
33
+ */
34
+ const {isArray} = Array;
35
+
36
+ /**
37
+ * Determine if a value is undefined
38
+ *
39
+ * @param {*} val The value to test
40
+ *
41
+ * @returns {boolean} True if the value is undefined, otherwise false
42
+ */
43
+ const isUndefined = typeOfTest('undefined');
44
+
45
+ /**
46
+ * Determine if a value is a Buffer
47
+ *
48
+ * @param {*} val The value to test
49
+ *
50
+ * @returns {boolean} True if value is a Buffer, otherwise false
51
+ */
52
+ function isBuffer(val) {
53
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
54
+ && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
55
+ }
56
+
57
+ /**
58
+ * Determine if a value is an ArrayBuffer
59
+ *
60
+ * @param {*} val The value to test
61
+ *
62
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
63
+ */
64
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
65
+
66
+
67
+ /**
68
+ * Determine if a value is a view on an ArrayBuffer
69
+ *
70
+ * @param {*} val The value to test
71
+ *
72
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
73
+ */
74
+ function isArrayBufferView(val) {
75
+ let result;
76
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
77
+ result = ArrayBuffer.isView(val);
78
+ } else {
79
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
80
+ }
81
+ return result;
82
+ }
83
+
84
+ /**
85
+ * Determine if a value is a String
86
+ *
87
+ * @param {*} val The value to test
88
+ *
89
+ * @returns {boolean} True if value is a String, otherwise false
90
+ */
91
+ const isString = typeOfTest('string');
92
+
93
+ /**
94
+ * Determine if a value is a Function
95
+ *
96
+ * @param {*} val The value to test
97
+ * @returns {boolean} True if value is a Function, otherwise false
98
+ */
99
+ const isFunction = typeOfTest('function');
100
+
101
+ /**
102
+ * Determine if a value is a Number
103
+ *
104
+ * @param {*} val The value to test
105
+ *
106
+ * @returns {boolean} True if value is a Number, otherwise false
107
+ */
108
+ const isNumber = typeOfTest('number');
109
+
110
+ /**
111
+ * Determine if a value is an Object
112
+ *
113
+ * @param {*} thing The value to test
114
+ *
115
+ * @returns {boolean} True if value is an Object, otherwise false
116
+ */
117
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
118
+
119
+ /**
120
+ * Determine if a value is a Boolean
121
+ *
122
+ * @param {*} thing The value to test
123
+ * @returns {boolean} True if value is a Boolean, otherwise false
124
+ */
125
+ const isBoolean = thing => thing === true || thing === false;
126
+
127
+ /**
128
+ * Determine if a value is a plain Object
129
+ *
130
+ * @param {*} val The value to test
131
+ *
132
+ * @returns {boolean} True if value is a plain Object, otherwise false
133
+ */
134
+ const isPlainObject = (val) => {
135
+ if (kindOf(val) !== 'object') {
136
+ return false;
137
+ }
138
+
139
+ const prototype = getPrototypeOf(val);
140
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
141
+ };
142
+
143
+ /**
144
+ * Determine if a value is a Date
145
+ *
146
+ * @param {*} val The value to test
147
+ *
148
+ * @returns {boolean} True if value is a Date, otherwise false
149
+ */
150
+ const isDate = kindOfTest('Date');
151
+
152
+ /**
153
+ * Determine if a value is a File
154
+ *
155
+ * @param {*} val The value to test
156
+ *
157
+ * @returns {boolean} True if value is a File, otherwise false
158
+ */
159
+ const isFile = kindOfTest('File');
160
+
161
+ /**
162
+ * Determine if a value is a Blob
163
+ *
164
+ * @param {*} val The value to test
165
+ *
166
+ * @returns {boolean} True if value is a Blob, otherwise false
167
+ */
168
+ const isBlob = kindOfTest('Blob');
169
+
170
+ /**
171
+ * Determine if a value is a FileList
172
+ *
173
+ * @param {*} val The value to test
174
+ *
175
+ * @returns {boolean} True if value is a File, otherwise false
176
+ */
177
+ const isFileList = kindOfTest('FileList');
178
+
179
+ /**
180
+ * Determine if a value is a Stream
181
+ *
182
+ * @param {*} val The value to test
183
+ *
184
+ * @returns {boolean} True if value is a Stream, otherwise false
185
+ */
186
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
187
+
188
+ /**
189
+ * Determine if a value is a FormData
190
+ *
191
+ * @param {*} thing The value to test
192
+ *
193
+ * @returns {boolean} True if value is an FormData, otherwise false
194
+ */
195
+ const isFormData = (thing) => {
196
+ const pattern = '[object FormData]';
197
+ return thing && (
198
+ (typeof FormData === 'function' && thing instanceof FormData) ||
199
+ toString.call(thing) === pattern ||
200
+ (isFunction(thing.toString) && thing.toString() === pattern)
201
+ );
202
+ };
203
+
204
+ /**
205
+ * Determine if a value is a URLSearchParams object
206
+ *
207
+ * @param {*} val The value to test
208
+ *
209
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
210
+ */
211
+ const isURLSearchParams = kindOfTest('URLSearchParams');
212
+
213
+ /**
214
+ * Trim excess whitespace off the beginning and end of a string
215
+ *
216
+ * @param {String} str The String to trim
217
+ *
218
+ * @returns {String} The String freed of excess whitespace
219
+ */
220
+ const trim = (str) => str.trim ?
221
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
222
+
223
+ /**
224
+ * Iterate over an Array or an Object invoking a function for each item.
225
+ *
226
+ * If `obj` is an Array callback will be called passing
227
+ * the value, index, and complete array for each item.
228
+ *
229
+ * If 'obj' is an Object callback will be called passing
230
+ * the value, key, and complete object for each property.
231
+ *
232
+ * @param {Object|Array} obj The object to iterate
233
+ * @param {Function} fn The callback to invoke for each item
234
+ *
235
+ * @param {Boolean} [allOwnKeys = false]
236
+ * @returns {any}
237
+ */
238
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
239
+ // Don't bother if no value provided
240
+ if (obj === null || typeof obj === 'undefined') {
241
+ return;
242
+ }
243
+
244
+ let i;
245
+ let l;
246
+
247
+ // Force an array if not already something iterable
248
+ if (typeof obj !== 'object') {
249
+ /*eslint no-param-reassign:0*/
250
+ obj = [obj];
251
+ }
252
+
253
+ if (isArray(obj)) {
254
+ // Iterate over array values
255
+ for (i = 0, l = obj.length; i < l; i++) {
256
+ fn.call(null, obj[i], i, obj);
257
+ }
258
+ } else {
259
+ // Iterate over object keys
260
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
261
+ const len = keys.length;
262
+ let key;
263
+
264
+ for (i = 0; i < len; i++) {
265
+ key = keys[i];
266
+ fn.call(null, obj[key], key, obj);
267
+ }
268
+ }
269
+ }
270
+
271
+ function findKey(obj, key) {
272
+ key = key.toLowerCase();
273
+ const keys = Object.keys(obj);
274
+ let i = keys.length;
275
+ let _key;
276
+ while (i-- > 0) {
277
+ _key = keys[i];
278
+ if (key === _key.toLowerCase()) {
279
+ return _key;
280
+ }
281
+ }
282
+ return null;
283
+ }
284
+
285
+ const _global = (() => {
286
+ /*eslint no-undef:0*/
287
+ if (typeof globalThis !== "undefined") return globalThis;
288
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
289
+ })();
290
+
291
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
292
+
293
+ /**
294
+ * Accepts varargs expecting each argument to be an object, then
295
+ * immutably merges the properties of each object and returns result.
296
+ *
297
+ * When multiple objects contain the same key the later object in
298
+ * the arguments list will take precedence.
299
+ *
300
+ * Example:
301
+ *
302
+ * ```js
303
+ * var result = merge({foo: 123}, {foo: 456});
304
+ * console.log(result.foo); // outputs 456
305
+ * ```
306
+ *
307
+ * @param {Object} obj1 Object to merge
308
+ *
309
+ * @returns {Object} Result of all merge properties
310
+ */
311
+ function merge(/* obj1, obj2, obj3, ... */) {
312
+ const {caseless} = isContextDefined(this) && this || {};
313
+ const result = {};
314
+ const assignValue = (val, key) => {
315
+ const targetKey = caseless && findKey(result, key) || key;
316
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
317
+ result[targetKey] = merge(result[targetKey], val);
318
+ } else if (isPlainObject(val)) {
319
+ result[targetKey] = merge({}, val);
320
+ } else if (isArray(val)) {
321
+ result[targetKey] = val.slice();
322
+ } else {
323
+ result[targetKey] = val;
324
+ }
325
+ };
326
+
327
+ for (let i = 0, l = arguments.length; i < l; i++) {
328
+ arguments[i] && forEach(arguments[i], assignValue);
329
+ }
330
+ return result;
331
+ }
332
+
333
+ /**
334
+ * Extends object a by mutably adding to it the properties of object b.
335
+ *
336
+ * @param {Object} a The object to be extended
337
+ * @param {Object} b The object to copy properties from
338
+ * @param {Object} thisArg The object to bind function to
339
+ *
340
+ * @param {Boolean} [allOwnKeys]
341
+ * @returns {Object} The resulting value of object a
342
+ */
343
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
344
+ forEach(b, (val, key) => {
345
+ if (thisArg && isFunction(val)) {
346
+ a[key] = bind(val, thisArg);
347
+ } else {
348
+ a[key] = val;
349
+ }
350
+ }, {allOwnKeys});
351
+ return a;
352
+ };
353
+
354
+ /**
355
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
356
+ *
357
+ * @param {string} content with BOM
358
+ *
359
+ * @returns {string} content value without BOM
360
+ */
361
+ const stripBOM = (content) => {
362
+ if (content.charCodeAt(0) === 0xFEFF) {
363
+ content = content.slice(1);
364
+ }
365
+ return content;
366
+ };
367
+
368
+ /**
369
+ * Inherit the prototype methods from one constructor into another
370
+ * @param {function} constructor
371
+ * @param {function} superConstructor
372
+ * @param {object} [props]
373
+ * @param {object} [descriptors]
374
+ *
375
+ * @returns {void}
376
+ */
377
+ const inherits = (constructor, superConstructor, props, descriptors) => {
378
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
379
+ constructor.prototype.constructor = constructor;
380
+ Object.defineProperty(constructor, 'super', {
381
+ value: superConstructor.prototype
382
+ });
383
+ props && Object.assign(constructor.prototype, props);
384
+ };
385
+
386
+ /**
387
+ * Resolve object with deep prototype chain to a flat object
388
+ * @param {Object} sourceObj source object
389
+ * @param {Object} [destObj]
390
+ * @param {Function|Boolean} [filter]
391
+ * @param {Function} [propFilter]
392
+ *
393
+ * @returns {Object}
394
+ */
395
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
396
+ let props;
397
+ let i;
398
+ let prop;
399
+ const merged = {};
400
+
401
+ destObj = destObj || {};
402
+ // eslint-disable-next-line no-eq-null,eqeqeq
403
+ if (sourceObj == null) return destObj;
404
+
405
+ do {
406
+ props = Object.getOwnPropertyNames(sourceObj);
407
+ i = props.length;
408
+ while (i-- > 0) {
409
+ prop = props[i];
410
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
411
+ destObj[prop] = sourceObj[prop];
412
+ merged[prop] = true;
413
+ }
414
+ }
415
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
416
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
417
+
418
+ return destObj;
419
+ };
420
+
421
+ /**
422
+ * Determines whether a string ends with the characters of a specified string
423
+ *
424
+ * @param {String} str
425
+ * @param {String} searchString
426
+ * @param {Number} [position= 0]
427
+ *
428
+ * @returns {boolean}
429
+ */
430
+ const endsWith = (str, searchString, position) => {
431
+ str = String(str);
432
+ if (position === undefined || position > str.length) {
433
+ position = str.length;
434
+ }
435
+ position -= searchString.length;
436
+ const lastIndex = str.indexOf(searchString, position);
437
+ return lastIndex !== -1 && lastIndex === position;
438
+ };
439
+
440
+
441
+ /**
442
+ * Returns new array from array like object or null if failed
443
+ *
444
+ * @param {*} [thing]
445
+ *
446
+ * @returns {?Array}
447
+ */
448
+ const toArray = (thing) => {
449
+ if (!thing) return null;
450
+ if (isArray(thing)) return thing;
451
+ let i = thing.length;
452
+ if (!isNumber(i)) return null;
453
+ const arr = new Array(i);
454
+ while (i-- > 0) {
455
+ arr[i] = thing[i];
456
+ }
457
+ return arr;
458
+ };
459
+
460
+ /**
461
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
462
+ * thing passed in is an instance of Uint8Array
463
+ *
464
+ * @param {TypedArray}
465
+ *
466
+ * @returns {Array}
467
+ */
468
+ // eslint-disable-next-line func-names
469
+ const isTypedArray = (TypedArray => {
470
+ // eslint-disable-next-line func-names
471
+ return thing => {
472
+ return TypedArray && thing instanceof TypedArray;
473
+ };
474
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
475
+
476
+ /**
477
+ * For each entry in the object, call the function with the key and value.
478
+ *
479
+ * @param {Object<any, any>} obj - The object to iterate over.
480
+ * @param {Function} fn - The function to call for each entry.
481
+ *
482
+ * @returns {void}
483
+ */
484
+ const forEachEntry = (obj, fn) => {
485
+ const generator = obj && obj[Symbol.iterator];
486
+
487
+ const iterator = generator.call(obj);
488
+
489
+ let result;
490
+
491
+ while ((result = iterator.next()) && !result.done) {
492
+ const pair = result.value;
493
+ fn.call(obj, pair[0], pair[1]);
494
+ }
495
+ };
496
+
497
+ /**
498
+ * It takes a regular expression and a string, and returns an array of all the matches
499
+ *
500
+ * @param {string} regExp - The regular expression to match against.
501
+ * @param {string} str - The string to search.
502
+ *
503
+ * @returns {Array<boolean>}
504
+ */
505
+ const matchAll = (regExp, str) => {
506
+ let matches;
507
+ const arr = [];
508
+
509
+ while ((matches = regExp.exec(str)) !== null) {
510
+ arr.push(matches);
511
+ }
512
+
513
+ return arr;
514
+ };
515
+
516
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
517
+ const isHTMLForm = kindOfTest('HTMLFormElement');
518
+
519
+ const toCamelCase = str => {
520
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
521
+ function replacer(m, p1, p2) {
522
+ return p1.toUpperCase() + p2;
523
+ }
524
+ );
525
+ };
526
+
527
+ /* Creating a function that will check if an object has a property. */
528
+ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
529
+
530
+ /**
531
+ * Determine if a value is a RegExp object
532
+ *
533
+ * @param {*} val The value to test
534
+ *
535
+ * @returns {boolean} True if value is a RegExp object, otherwise false
536
+ */
537
+ const isRegExp = kindOfTest('RegExp');
538
+
539
+ const reduceDescriptors = (obj, reducer) => {
540
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
541
+ const reducedDescriptors = {};
542
+
543
+ forEach(descriptors, (descriptor, name) => {
544
+ if (reducer(descriptor, name, obj) !== false) {
545
+ reducedDescriptors[name] = descriptor;
546
+ }
547
+ });
548
+
549
+ Object.defineProperties(obj, reducedDescriptors);
550
+ };
551
+
552
+ /**
553
+ * Makes all methods read-only
554
+ * @param {Object} obj
555
+ */
556
+
557
+ const freezeMethods = (obj) => {
558
+ reduceDescriptors(obj, (descriptor, name) => {
559
+ // skip restricted props in strict mode
560
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
561
+ return false;
562
+ }
563
+
564
+ const value = obj[name];
565
+
566
+ if (!isFunction(value)) return;
567
+
568
+ descriptor.enumerable = false;
569
+
570
+ if ('writable' in descriptor) {
571
+ descriptor.writable = false;
572
+ return;
573
+ }
574
+
575
+ if (!descriptor.set) {
576
+ descriptor.set = () => {
577
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
578
+ };
579
+ }
580
+ });
581
+ };
582
+
583
+ const toObjectSet = (arrayOrString, delimiter) => {
584
+ const obj = {};
585
+
586
+ const define = (arr) => {
587
+ arr.forEach(value => {
588
+ obj[value] = true;
589
+ });
590
+ };
591
+
592
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
593
+
594
+ return obj;
595
+ };
596
+
597
+ const noop = () => {};
598
+
599
+ const toFiniteNumber = (value, defaultValue) => {
600
+ value = +value;
601
+ return Number.isFinite(value) ? value : defaultValue;
602
+ };
603
+
604
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
605
+
606
+ const DIGIT = '0123456789';
607
+
608
+ const ALPHABET = {
609
+ DIGIT,
610
+ ALPHA,
611
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
612
+ };
613
+
614
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
615
+ let str = '';
616
+ const {length} = alphabet;
617
+ while (size--) {
618
+ str += alphabet[Math.random() * length|0];
619
+ }
620
+
621
+ return str;
622
+ };
623
+
624
+ /**
625
+ * If the thing is a FormData object, return true, otherwise return false.
626
+ *
627
+ * @param {unknown} thing - The thing to check.
628
+ *
629
+ * @returns {boolean}
630
+ */
631
+ function isSpecCompliantForm(thing) {
632
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
633
+ }
634
+
635
+ const toJSONObject = (obj) => {
636
+ const stack = new Array(10);
637
+
638
+ const visit = (source, i) => {
639
+
640
+ if (isObject(source)) {
641
+ if (stack.indexOf(source) >= 0) {
642
+ return;
643
+ }
644
+
645
+ if(!('toJSON' in source)) {
646
+ stack[i] = source;
647
+ const target = isArray(source) ? [] : {};
648
+
649
+ forEach(source, (value, key) => {
650
+ const reducedValue = visit(value, i + 1);
651
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
652
+ });
653
+
654
+ stack[i] = undefined;
655
+
656
+ return target;
657
+ }
658
+ }
659
+
660
+ return source;
661
+ };
662
+
663
+ return visit(obj, 0);
664
+ };
665
+
666
+ var utils = {
667
+ isArray,
668
+ isArrayBuffer,
669
+ isBuffer,
670
+ isFormData,
671
+ isArrayBufferView,
672
+ isString,
673
+ isNumber,
674
+ isBoolean,
675
+ isObject,
676
+ isPlainObject,
677
+ isUndefined,
678
+ isDate,
679
+ isFile,
680
+ isBlob,
681
+ isRegExp,
682
+ isFunction,
683
+ isStream,
684
+ isURLSearchParams,
685
+ isTypedArray,
686
+ isFileList,
687
+ forEach,
688
+ merge,
689
+ extend,
690
+ trim,
691
+ stripBOM,
692
+ inherits,
693
+ toFlatObject,
694
+ kindOf,
695
+ kindOfTest,
696
+ endsWith,
697
+ toArray,
698
+ forEachEntry,
699
+ matchAll,
700
+ isHTMLForm,
701
+ hasOwnProperty,
702
+ hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
703
+ reduceDescriptors,
704
+ freezeMethods,
705
+ toObjectSet,
706
+ toCamelCase,
707
+ noop,
708
+ toFiniteNumber,
709
+ findKey,
710
+ global: _global,
711
+ isContextDefined,
712
+ ALPHABET,
713
+ generateString,
714
+ isSpecCompliantForm,
715
+ toJSONObject
716
+ };
717
+
718
+ /**
719
+ * Create an Error with the specified message, config, error code, request and response.
720
+ *
721
+ * @param {string} message The error message.
722
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
723
+ * @param {Object} [config] The config.
724
+ * @param {Object} [request] The request.
725
+ * @param {Object} [response] The response.
726
+ *
727
+ * @returns {Error} The created error.
728
+ */
729
+ function AxiosError(message, code, config, request, response) {
730
+ Error.call(this);
731
+
732
+ if (Error.captureStackTrace) {
733
+ Error.captureStackTrace(this, this.constructor);
734
+ } else {
735
+ this.stack = (new Error()).stack;
736
+ }
737
+
738
+ this.message = message;
739
+ this.name = 'AxiosError';
740
+ code && (this.code = code);
741
+ config && (this.config = config);
742
+ request && (this.request = request);
743
+ response && (this.response = response);
744
+ }
745
+
746
+ utils.inherits(AxiosError, Error, {
747
+ toJSON: function toJSON() {
748
+ return {
749
+ // Standard
750
+ message: this.message,
751
+ name: this.name,
752
+ // Microsoft
753
+ description: this.description,
754
+ number: this.number,
755
+ // Mozilla
756
+ fileName: this.fileName,
757
+ lineNumber: this.lineNumber,
758
+ columnNumber: this.columnNumber,
759
+ stack: this.stack,
760
+ // Axios
761
+ config: utils.toJSONObject(this.config),
762
+ code: this.code,
763
+ status: this.response && this.response.status ? this.response.status : null
764
+ };
765
+ }
766
+ });
767
+
768
+ const prototype$1 = AxiosError.prototype;
769
+ const descriptors = {};
770
+
771
+ [
772
+ 'ERR_BAD_OPTION_VALUE',
773
+ 'ERR_BAD_OPTION',
774
+ 'ECONNABORTED',
775
+ 'ETIMEDOUT',
776
+ 'ERR_NETWORK',
777
+ 'ERR_FR_TOO_MANY_REDIRECTS',
778
+ 'ERR_DEPRECATED',
779
+ 'ERR_BAD_RESPONSE',
780
+ 'ERR_BAD_REQUEST',
781
+ 'ERR_CANCELED',
782
+ 'ERR_NOT_SUPPORT',
783
+ 'ERR_INVALID_URL'
784
+ // eslint-disable-next-line func-names
785
+ ].forEach(code => {
786
+ descriptors[code] = {value: code};
787
+ });
788
+
789
+ Object.defineProperties(AxiosError, descriptors);
790
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
791
+
792
+ // eslint-disable-next-line func-names
793
+ AxiosError.from = (error, code, config, request, response, customProps) => {
794
+ const axiosError = Object.create(prototype$1);
795
+
796
+ utils.toFlatObject(error, axiosError, function filter(obj) {
797
+ return obj !== Error.prototype;
798
+ }, prop => {
799
+ return prop !== 'isAxiosError';
800
+ });
801
+
802
+ AxiosError.call(axiosError, error.message, code, config, request, response);
803
+
804
+ axiosError.cause = error;
805
+
806
+ axiosError.name = error.name;
807
+
808
+ customProps && Object.assign(axiosError, customProps);
809
+
810
+ return axiosError;
811
+ };
812
+
813
+ // eslint-disable-next-line strict
814
+ var httpAdapter = null;
815
+
816
+ /**
817
+ * Determines if the given thing is a array or js object.
818
+ *
819
+ * @param {string} thing - The object or array to be visited.
820
+ *
821
+ * @returns {boolean}
822
+ */
823
+ function isVisitable(thing) {
824
+ return utils.isPlainObject(thing) || utils.isArray(thing);
825
+ }
826
+
827
+ /**
828
+ * It removes the brackets from the end of a string
829
+ *
830
+ * @param {string} key - The key of the parameter.
831
+ *
832
+ * @returns {string} the key without the brackets.
833
+ */
834
+ function removeBrackets(key) {
835
+ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
836
+ }
837
+
838
+ /**
839
+ * It takes a path, a key, and a boolean, and returns a string
840
+ *
841
+ * @param {string} path - The path to the current key.
842
+ * @param {string} key - The key of the current object being iterated over.
843
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
844
+ *
845
+ * @returns {string} The path to the current key.
846
+ */
847
+ function renderKey(path, key, dots) {
848
+ if (!path) return key;
849
+ return path.concat(key).map(function each(token, i) {
850
+ // eslint-disable-next-line no-param-reassign
851
+ token = removeBrackets(token);
852
+ return !dots && i ? '[' + token + ']' : token;
853
+ }).join(dots ? '.' : '');
854
+ }
855
+
856
+ /**
857
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
858
+ *
859
+ * @param {Array<any>} arr - The array to check
860
+ *
861
+ * @returns {boolean}
862
+ */
863
+ function isFlatArray(arr) {
864
+ return utils.isArray(arr) && !arr.some(isVisitable);
865
+ }
866
+
867
+ const predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
868
+ return /^is[A-Z]/.test(prop);
869
+ });
870
+
871
+ /**
872
+ * Convert a data object to FormData
873
+ *
874
+ * @param {Object} obj
875
+ * @param {?Object} [formData]
876
+ * @param {?Object} [options]
877
+ * @param {Function} [options.visitor]
878
+ * @param {Boolean} [options.metaTokens = true]
879
+ * @param {Boolean} [options.dots = false]
880
+ * @param {?Boolean} [options.indexes = false]
881
+ *
882
+ * @returns {Object}
883
+ **/
884
+
885
+ /**
886
+ * It converts an object into a FormData object
887
+ *
888
+ * @param {Object<any, any>} obj - The object to convert to form data.
889
+ * @param {string} formData - The FormData object to append to.
890
+ * @param {Object<string, any>} options
891
+ *
892
+ * @returns
893
+ */
894
+ function toFormData(obj, formData, options) {
895
+ if (!utils.isObject(obj)) {
896
+ throw new TypeError('target must be an object');
897
+ }
898
+
899
+ // eslint-disable-next-line no-param-reassign
900
+ formData = formData || new (FormData)();
901
+
902
+ // eslint-disable-next-line no-param-reassign
903
+ options = utils.toFlatObject(options, {
904
+ metaTokens: true,
905
+ dots: false,
906
+ indexes: false
907
+ }, false, function defined(option, source) {
908
+ // eslint-disable-next-line no-eq-null,eqeqeq
909
+ return !utils.isUndefined(source[option]);
910
+ });
911
+
912
+ const metaTokens = options.metaTokens;
913
+ // eslint-disable-next-line no-use-before-define
914
+ const visitor = options.visitor || defaultVisitor;
915
+ const dots = options.dots;
916
+ const indexes = options.indexes;
917
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
918
+ const useBlob = _Blob && utils.isSpecCompliantForm(formData);
919
+
920
+ if (!utils.isFunction(visitor)) {
921
+ throw new TypeError('visitor must be a function');
922
+ }
923
+
924
+ function convertValue(value) {
925
+ if (value === null) return '';
926
+
927
+ if (utils.isDate(value)) {
928
+ return value.toISOString();
929
+ }
930
+
931
+ if (!useBlob && utils.isBlob(value)) {
932
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
933
+ }
934
+
935
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
936
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
937
+ }
938
+
939
+ return value;
940
+ }
941
+
942
+ /**
943
+ * Default visitor.
944
+ *
945
+ * @param {*} value
946
+ * @param {String|Number} key
947
+ * @param {Array<String|Number>} path
948
+ * @this {FormData}
949
+ *
950
+ * @returns {boolean} return true to visit the each prop of the value recursively
951
+ */
952
+ function defaultVisitor(value, key, path) {
953
+ let arr = value;
954
+
955
+ if (value && !path && typeof value === 'object') {
956
+ if (utils.endsWith(key, '{}')) {
957
+ // eslint-disable-next-line no-param-reassign
958
+ key = metaTokens ? key : key.slice(0, -2);
959
+ // eslint-disable-next-line no-param-reassign
960
+ value = JSON.stringify(value);
961
+ } else if (
962
+ (utils.isArray(value) && isFlatArray(value)) ||
963
+ ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))
964
+ )) {
965
+ // eslint-disable-next-line no-param-reassign
966
+ key = removeBrackets(key);
967
+
968
+ arr.forEach(function each(el, index) {
969
+ !(utils.isUndefined(el) || el === null) && formData.append(
970
+ // eslint-disable-next-line no-nested-ternary
971
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
972
+ convertValue(el)
973
+ );
974
+ });
975
+ return false;
976
+ }
977
+ }
978
+
979
+ if (isVisitable(value)) {
980
+ return true;
981
+ }
982
+
983
+ formData.append(renderKey(path, key, dots), convertValue(value));
984
+
985
+ return false;
986
+ }
987
+
988
+ const stack = [];
989
+
990
+ const exposedHelpers = Object.assign(predicates, {
991
+ defaultVisitor,
992
+ convertValue,
993
+ isVisitable
994
+ });
995
+
996
+ function build(value, path) {
997
+ if (utils.isUndefined(value)) return;
998
+
999
+ if (stack.indexOf(value) !== -1) {
1000
+ throw Error('Circular reference detected in ' + path.join('.'));
1001
+ }
1002
+
1003
+ stack.push(value);
1004
+
1005
+ utils.forEach(value, function each(el, key) {
1006
+ const result = !(utils.isUndefined(el) || el === null) && visitor.call(
1007
+ formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
1008
+ );
1009
+
1010
+ if (result === true) {
1011
+ build(el, path ? path.concat(key) : [key]);
1012
+ }
1013
+ });
1014
+
1015
+ stack.pop();
1016
+ }
1017
+
1018
+ if (!utils.isObject(obj)) {
1019
+ throw new TypeError('data must be an object');
1020
+ }
1021
+
1022
+ build(obj);
1023
+
1024
+ return formData;
1025
+ }
1026
+
1027
+ /**
1028
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1029
+ * their percent-encoded equivalents
1030
+ *
1031
+ * @param {string} str - The string to encode.
1032
+ *
1033
+ * @returns {string} The encoded string.
1034
+ */
1035
+ function encode$1(str) {
1036
+ const charMap = {
1037
+ '!': '%21',
1038
+ "'": '%27',
1039
+ '(': '%28',
1040
+ ')': '%29',
1041
+ '~': '%7E',
1042
+ '%20': '+',
1043
+ '%00': '\x00'
1044
+ };
1045
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1046
+ return charMap[match];
1047
+ });
1048
+ }
1049
+
1050
+ /**
1051
+ * It takes a params object and converts it to a FormData object
1052
+ *
1053
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1054
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1055
+ *
1056
+ * @returns {void}
1057
+ */
1058
+ function AxiosURLSearchParams(params, options) {
1059
+ this._pairs = [];
1060
+
1061
+ params && toFormData(params, this, options);
1062
+ }
1063
+
1064
+ const prototype = AxiosURLSearchParams.prototype;
1065
+
1066
+ prototype.append = function append(name, value) {
1067
+ this._pairs.push([name, value]);
1068
+ };
1069
+
1070
+ prototype.toString = function toString(encoder) {
1071
+ const _encode = encoder ? function(value) {
1072
+ return encoder.call(this, value, encode$1);
1073
+ } : encode$1;
1074
+
1075
+ return this._pairs.map(function each(pair) {
1076
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1077
+ }, '').join('&');
1078
+ };
1079
+
1080
+ /**
1081
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1082
+ * URI encoded counterparts
1083
+ *
1084
+ * @param {string} val The value to be encoded.
1085
+ *
1086
+ * @returns {string} The encoded value.
1087
+ */
1088
+ function encode(val) {
1089
+ return encodeURIComponent(val).
1090
+ replace(/%3A/gi, ':').
1091
+ replace(/%24/g, '$').
1092
+ replace(/%2C/gi, ',').
1093
+ replace(/%20/g, '+').
1094
+ replace(/%5B/gi, '[').
1095
+ replace(/%5D/gi, ']');
1096
+ }
1097
+
1098
+ /**
1099
+ * Build a URL by appending params to the end
1100
+ *
1101
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1102
+ * @param {object} [params] The params to be appended
1103
+ * @param {?object} options
1104
+ *
1105
+ * @returns {string} The formatted url
1106
+ */
1107
+ function buildURL(url, params, options) {
1108
+ /*eslint no-param-reassign:0*/
1109
+ if (!params) {
1110
+ return url;
1111
+ }
1112
+
1113
+ const _encode = options && options.encode || encode;
1114
+
1115
+ const serializeFn = options && options.serialize;
1116
+
1117
+ let serializedParams;
1118
+
1119
+ if (serializeFn) {
1120
+ serializedParams = serializeFn(params, options);
1121
+ } else {
1122
+ serializedParams = utils.isURLSearchParams(params) ?
1123
+ params.toString() :
1124
+ new AxiosURLSearchParams(params, options).toString(_encode);
1125
+ }
1126
+
1127
+ if (serializedParams) {
1128
+ const hashmarkIndex = url.indexOf("#");
1129
+
1130
+ if (hashmarkIndex !== -1) {
1131
+ url = url.slice(0, hashmarkIndex);
1132
+ }
1133
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1134
+ }
1135
+
1136
+ return url;
1137
+ }
1138
+
1139
+ class InterceptorManager {
1140
+ constructor() {
1141
+ this.handlers = [];
1142
+ }
1143
+
1144
+ /**
1145
+ * Add a new interceptor to the stack
1146
+ *
1147
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1148
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1149
+ *
1150
+ * @return {Number} An ID used to remove interceptor later
1151
+ */
1152
+ use(fulfilled, rejected, options) {
1153
+ this.handlers.push({
1154
+ fulfilled,
1155
+ rejected,
1156
+ synchronous: options ? options.synchronous : false,
1157
+ runWhen: options ? options.runWhen : null
1158
+ });
1159
+ return this.handlers.length - 1;
1160
+ }
1161
+
1162
+ /**
1163
+ * Remove an interceptor from the stack
1164
+ *
1165
+ * @param {Number} id The ID that was returned by `use`
1166
+ *
1167
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1168
+ */
1169
+ eject(id) {
1170
+ if (this.handlers[id]) {
1171
+ this.handlers[id] = null;
1172
+ }
1173
+ }
1174
+
1175
+ /**
1176
+ * Clear all interceptors from the stack
1177
+ *
1178
+ * @returns {void}
1179
+ */
1180
+ clear() {
1181
+ if (this.handlers) {
1182
+ this.handlers = [];
1183
+ }
1184
+ }
1185
+
1186
+ /**
1187
+ * Iterate over all the registered interceptors
1188
+ *
1189
+ * This method is particularly useful for skipping over any
1190
+ * interceptors that may have become `null` calling `eject`.
1191
+ *
1192
+ * @param {Function} fn The function to call for each interceptor
1193
+ *
1194
+ * @returns {void}
1195
+ */
1196
+ forEach(fn) {
1197
+ utils.forEach(this.handlers, function forEachHandler(h) {
1198
+ if (h !== null) {
1199
+ fn(h);
1200
+ }
1201
+ });
1202
+ }
1203
+ }
1204
+
1205
+ var InterceptorManager$1 = InterceptorManager;
1206
+
1207
+ var transitionalDefaults = {
1208
+ silentJSONParsing: true,
1209
+ forcedJSONParsing: true,
1210
+ clarifyTimeoutError: false
1211
+ };
1212
+
1213
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1214
+
1215
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1216
+
1217
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1218
+
1219
+ /**
1220
+ * Determine if we're running in a standard browser environment
1221
+ *
1222
+ * This allows axios to run in a web worker, and react-native.
1223
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1224
+ *
1225
+ * web workers:
1226
+ * typeof window -> undefined
1227
+ * typeof document -> undefined
1228
+ *
1229
+ * react-native:
1230
+ * navigator.product -> 'ReactNative'
1231
+ * nativescript
1232
+ * navigator.product -> 'NativeScript' or 'NS'
1233
+ *
1234
+ * @returns {boolean}
1235
+ */
1236
+ const isStandardBrowserEnv = (() => {
1237
+ // 针对微信小程序环境打补丁
1238
+ if (typeof wx !== 'undefined' && typeof wx.request === 'function') return false
1239
+ let product;
1240
+ if (typeof navigator !== 'undefined' && (
1241
+ (product = navigator.product) === 'ReactNative' ||
1242
+ product === 'NativeScript' ||
1243
+ product === 'NS')
1244
+ ) {
1245
+ return false;
1246
+ }
1247
+
1248
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
1249
+ })();
1250
+
1251
+ /**
1252
+ * Determine if we're running in a standard browser webWorker environment
1253
+ *
1254
+ * Although the `isStandardBrowserEnv` method indicates that
1255
+ * `allows axios to run in a web worker`, the WebWorker will still be
1256
+ * filtered out due to its judgment standard
1257
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1258
+ * This leads to a problem when axios post `FormData` in webWorker
1259
+ */
1260
+ const isStandardBrowserWebWorkerEnv = (() => {
1261
+ return (
1262
+ typeof WorkerGlobalScope !== 'undefined' &&
1263
+ // eslint-disable-next-line no-undef
1264
+ self instanceof WorkerGlobalScope &&
1265
+ typeof self.importScripts === 'function'
1266
+ );
1267
+ })();
1268
+
1269
+
1270
+ var platform = {
1271
+ isBrowser: true,
1272
+ classes: {
1273
+ URLSearchParams: URLSearchParams$1,
1274
+ FormData: FormData$1,
1275
+ Blob: Blob$1
1276
+ },
1277
+ isStandardBrowserEnv,
1278
+ isStandardBrowserWebWorkerEnv,
1279
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1280
+ };
1281
+
1282
+ function toURLEncodedForm(data, options) {
1283
+ return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1284
+ visitor: function(value, key, path, helpers) {
1285
+ if (platform.isNode && utils.isBuffer(value)) {
1286
+ this.append(key, value.toString('base64'));
1287
+ return false;
1288
+ }
1289
+
1290
+ return helpers.defaultVisitor.apply(this, arguments);
1291
+ }
1292
+ }, options));
1293
+ }
1294
+
1295
+ /**
1296
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1297
+ *
1298
+ * @param {string} name - The name of the property to get.
1299
+ *
1300
+ * @returns An array of strings.
1301
+ */
1302
+ function parsePropPath(name) {
1303
+ // foo[x][y][z]
1304
+ // foo.x.y.z
1305
+ // foo-x-y-z
1306
+ // foo x y z
1307
+ return utils.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1308
+ return match[0] === '[]' ? '' : match[1] || match[0];
1309
+ });
1310
+ }
1311
+
1312
+ /**
1313
+ * Convert an array to an object.
1314
+ *
1315
+ * @param {Array<any>} arr - The array to convert to an object.
1316
+ *
1317
+ * @returns An object with the same keys and values as the array.
1318
+ */
1319
+ function arrayToObject(arr) {
1320
+ const obj = {};
1321
+ const keys = Object.keys(arr);
1322
+ let i;
1323
+ const len = keys.length;
1324
+ let key;
1325
+ for (i = 0; i < len; i++) {
1326
+ key = keys[i];
1327
+ obj[key] = arr[key];
1328
+ }
1329
+ return obj;
1330
+ }
1331
+
1332
+ /**
1333
+ * It takes a FormData object and returns a JavaScript object
1334
+ *
1335
+ * @param {string} formData The FormData object to convert to JSON.
1336
+ *
1337
+ * @returns {Object<string, any> | null} The converted object.
1338
+ */
1339
+ function formDataToJSON(formData) {
1340
+ function buildPath(path, value, target, index) {
1341
+ let name = path[index++];
1342
+ const isNumericKey = Number.isFinite(+name);
1343
+ const isLast = index >= path.length;
1344
+ name = !name && utils.isArray(target) ? target.length : name;
1345
+
1346
+ if (isLast) {
1347
+ if (utils.hasOwnProp(target, name)) {
1348
+ target[name] = [target[name], value];
1349
+ } else {
1350
+ target[name] = value;
1351
+ }
1352
+
1353
+ return !isNumericKey;
1354
+ }
1355
+
1356
+ if (!target[name] || !utils.isObject(target[name])) {
1357
+ target[name] = [];
1358
+ }
1359
+
1360
+ const result = buildPath(path, value, target[name], index);
1361
+
1362
+ if (result && utils.isArray(target[name])) {
1363
+ target[name] = arrayToObject(target[name]);
1364
+ }
1365
+
1366
+ return !isNumericKey;
1367
+ }
1368
+
1369
+ if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
1370
+ const obj = {};
1371
+
1372
+ utils.forEachEntry(formData, (name, value) => {
1373
+ buildPath(parsePropPath(name), value, obj, 0);
1374
+ });
1375
+
1376
+ return obj;
1377
+ }
1378
+
1379
+ return null;
1380
+ }
1381
+
1382
+ const DEFAULT_CONTENT_TYPE = {
1383
+ 'Content-Type': undefined
1384
+ };
1385
+
1386
+ /**
1387
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1388
+ * of the input
1389
+ *
1390
+ * @param {any} rawValue - The value to be stringified.
1391
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1392
+ * @param {Function} encoder - A function that takes a value and returns a string.
1393
+ *
1394
+ * @returns {string} A stringified version of the rawValue.
1395
+ */
1396
+ function stringifySafely(rawValue, parser, encoder) {
1397
+ if (utils.isString(rawValue)) {
1398
+ try {
1399
+ (parser || JSON.parse)(rawValue);
1400
+ return utils.trim(rawValue);
1401
+ } catch (e) {
1402
+ if (e.name !== 'SyntaxError') {
1403
+ throw e;
1404
+ }
1405
+ }
1406
+ }
1407
+
1408
+ return (encoder || JSON.stringify)(rawValue);
1409
+ }
1410
+
1411
+ const defaults = {
1412
+
1413
+ transitional: transitionalDefaults,
1414
+
1415
+ adapter: ['xhr', 'http'],
1416
+
1417
+ transformRequest: [function transformRequest(data, headers) {
1418
+ const contentType = headers.getContentType() || '';
1419
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1420
+ const isObjectPayload = utils.isObject(data);
1421
+
1422
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1423
+ data = new FormData(data);
1424
+ }
1425
+
1426
+ const isFormData = utils.isFormData(data);
1427
+
1428
+ if (isFormData) {
1429
+ if (!hasJSONContentType) {
1430
+ return data;
1431
+ }
1432
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1433
+ }
1434
+
1435
+ if (utils.isArrayBuffer(data) ||
1436
+ utils.isBuffer(data) ||
1437
+ utils.isStream(data) ||
1438
+ utils.isFile(data) ||
1439
+ utils.isBlob(data)
1440
+ ) {
1441
+ return data;
1442
+ }
1443
+ if (utils.isArrayBufferView(data)) {
1444
+ return data.buffer;
1445
+ }
1446
+ if (utils.isURLSearchParams(data)) {
1447
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1448
+ return data.toString();
1449
+ }
1450
+
1451
+ let isFileList;
1452
+
1453
+ if (isObjectPayload) {
1454
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1455
+ return toURLEncodedForm(data, this.formSerializer).toString();
1456
+ }
1457
+
1458
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1459
+ const _FormData = this.env && this.env.FormData;
1460
+
1461
+ return toFormData(
1462
+ isFileList ? {'files[]': data} : data,
1463
+ _FormData && new _FormData(),
1464
+ this.formSerializer
1465
+ );
1466
+ }
1467
+ }
1468
+
1469
+ if (isObjectPayload || hasJSONContentType ) {
1470
+ headers.setContentType('application/json', false);
1471
+ return stringifySafely(data);
1472
+ }
1473
+
1474
+ return data;
1475
+ }],
1476
+
1477
+ transformResponse: [function transformResponse(data) {
1478
+ const transitional = this.transitional || defaults.transitional;
1479
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1480
+ const JSONRequested = this.responseType === 'json';
1481
+
1482
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1483
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1484
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1485
+
1486
+ try {
1487
+ return JSON.parse(data);
1488
+ } catch (e) {
1489
+ if (strictJSONParsing) {
1490
+ if (e.name === 'SyntaxError') {
1491
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1492
+ }
1493
+ throw e;
1494
+ }
1495
+ }
1496
+ }
1497
+
1498
+ return data;
1499
+ }],
1500
+
1501
+ /**
1502
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1503
+ * timeout is not created.
1504
+ */
1505
+ timeout: 0,
1506
+
1507
+ xsrfCookieName: 'XSRF-TOKEN',
1508
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1509
+
1510
+ maxContentLength: -1,
1511
+ maxBodyLength: -1,
1512
+
1513
+ env: {
1514
+ FormData: platform.classes.FormData,
1515
+ Blob: platform.classes.Blob
1516
+ },
1517
+
1518
+ validateStatus: function validateStatus(status) {
1519
+ return status >= 200 && status < 300;
1520
+ },
1521
+
1522
+ headers: {
1523
+ common: {
1524
+ 'Accept': 'application/json, text/plain, */*'
1525
+ }
1526
+ }
1527
+ };
1528
+
1529
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1530
+ defaults.headers[method] = {};
1531
+ });
1532
+
1533
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1534
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1535
+ });
1536
+
1537
+ var defaults$1 = defaults;
1538
+
1539
+ // RawAxiosHeaders whose duplicates are ignored by node
1540
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1541
+ const ignoreDuplicateOf = utils.toObjectSet([
1542
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1543
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1544
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1545
+ 'referer', 'retry-after', 'user-agent'
1546
+ ]);
1547
+
1548
+ /**
1549
+ * Parse headers into an object
1550
+ *
1551
+ * ```
1552
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1553
+ * Content-Type: application/json
1554
+ * Connection: keep-alive
1555
+ * Transfer-Encoding: chunked
1556
+ * ```
1557
+ *
1558
+ * @param {String} rawHeaders Headers needing to be parsed
1559
+ *
1560
+ * @returns {Object} Headers parsed into an object
1561
+ */
1562
+ var parseHeaders = rawHeaders => {
1563
+ const parsed = {};
1564
+ let key;
1565
+ let val;
1566
+ let i;
1567
+
1568
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1569
+ i = line.indexOf(':');
1570
+ key = line.substring(0, i).trim().toLowerCase();
1571
+ val = line.substring(i + 1).trim();
1572
+
1573
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1574
+ return;
1575
+ }
1576
+
1577
+ if (key === 'set-cookie') {
1578
+ if (parsed[key]) {
1579
+ parsed[key].push(val);
1580
+ } else {
1581
+ parsed[key] = [val];
1582
+ }
1583
+ } else {
1584
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1585
+ }
1586
+ });
1587
+
1588
+ return parsed;
1589
+ };
1590
+
1591
+ const $internals = Symbol('internals');
1592
+
1593
+ function normalizeHeader(header) {
1594
+ return header && String(header).trim().toLowerCase();
1595
+ }
1596
+
1597
+ function normalizeValue(value) {
1598
+ if (value === false || value == null) {
1599
+ return value;
1600
+ }
1601
+
1602
+ return utils.isArray(value) ? value.map(normalizeValue) : String(value);
1603
+ }
1604
+
1605
+ function parseTokens(str) {
1606
+ const tokens = Object.create(null);
1607
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1608
+ let match;
1609
+
1610
+ while ((match = tokensRE.exec(str))) {
1611
+ tokens[match[1]] = match[2];
1612
+ }
1613
+
1614
+ return tokens;
1615
+ }
1616
+
1617
+ function isValidHeaderName(str) {
1618
+ return /^[-_a-zA-Z]+$/.test(str.trim());
1619
+ }
1620
+
1621
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1622
+ if (utils.isFunction(filter)) {
1623
+ return filter.call(this, value, header);
1624
+ }
1625
+
1626
+ if (isHeaderNameFilter) {
1627
+ value = header;
1628
+ }
1629
+
1630
+ if (!utils.isString(value)) return;
1631
+
1632
+ if (utils.isString(filter)) {
1633
+ return value.indexOf(filter) !== -1;
1634
+ }
1635
+
1636
+ if (utils.isRegExp(filter)) {
1637
+ return filter.test(value);
1638
+ }
1639
+ }
1640
+
1641
+ function formatHeader(header) {
1642
+ return header.trim()
1643
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1644
+ return char.toUpperCase() + str;
1645
+ });
1646
+ }
1647
+
1648
+ function buildAccessors(obj, header) {
1649
+ const accessorName = utils.toCamelCase(' ' + header);
1650
+
1651
+ ['get', 'set', 'has'].forEach(methodName => {
1652
+ Object.defineProperty(obj, methodName + accessorName, {
1653
+ value: function(arg1, arg2, arg3) {
1654
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1655
+ },
1656
+ configurable: true
1657
+ });
1658
+ });
1659
+ }
1660
+
1661
+ class AxiosHeaders {
1662
+ constructor(headers) {
1663
+ headers && this.set(headers);
1664
+ }
1665
+
1666
+ set(header, valueOrRewrite, rewrite) {
1667
+ const self = this;
1668
+
1669
+ function setHeader(_value, _header, _rewrite) {
1670
+ const lHeader = normalizeHeader(_header);
1671
+
1672
+ if (!lHeader) {
1673
+ throw new Error('header name must be a non-empty string');
1674
+ }
1675
+
1676
+ const key = utils.findKey(self, lHeader);
1677
+
1678
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1679
+ self[key || _header] = normalizeValue(_value);
1680
+ }
1681
+ }
1682
+
1683
+ const setHeaders = (headers, _rewrite) =>
1684
+ utils.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1685
+
1686
+ if (utils.isPlainObject(header) || header instanceof this.constructor) {
1687
+ setHeaders(header, valueOrRewrite);
1688
+ } else if(utils.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1689
+ setHeaders(parseHeaders(header), valueOrRewrite);
1690
+ } else {
1691
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1692
+ }
1693
+
1694
+ return this;
1695
+ }
1696
+
1697
+ get(header, parser) {
1698
+ header = normalizeHeader(header);
1699
+
1700
+ if (header) {
1701
+ const key = utils.findKey(this, header);
1702
+
1703
+ if (key) {
1704
+ const value = this[key];
1705
+
1706
+ if (!parser) {
1707
+ return value;
1708
+ }
1709
+
1710
+ if (parser === true) {
1711
+ return parseTokens(value);
1712
+ }
1713
+
1714
+ if (utils.isFunction(parser)) {
1715
+ return parser.call(this, value, key);
1716
+ }
1717
+
1718
+ if (utils.isRegExp(parser)) {
1719
+ return parser.exec(value);
1720
+ }
1721
+
1722
+ throw new TypeError('parser must be boolean|regexp|function');
1723
+ }
1724
+ }
1725
+ }
1726
+
1727
+ has(header, matcher) {
1728
+ header = normalizeHeader(header);
1729
+
1730
+ if (header) {
1731
+ const key = utils.findKey(this, header);
1732
+
1733
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1734
+ }
1735
+
1736
+ return false;
1737
+ }
1738
+
1739
+ delete(header, matcher) {
1740
+ const self = this;
1741
+ let deleted = false;
1742
+
1743
+ function deleteHeader(_header) {
1744
+ _header = normalizeHeader(_header);
1745
+
1746
+ if (_header) {
1747
+ const key = utils.findKey(self, _header);
1748
+
1749
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1750
+ delete self[key];
1751
+
1752
+ deleted = true;
1753
+ }
1754
+ }
1755
+ }
1756
+
1757
+ if (utils.isArray(header)) {
1758
+ header.forEach(deleteHeader);
1759
+ } else {
1760
+ deleteHeader(header);
1761
+ }
1762
+
1763
+ return deleted;
1764
+ }
1765
+
1766
+ clear(matcher) {
1767
+ const keys = Object.keys(this);
1768
+ let i = keys.length;
1769
+ let deleted = false;
1770
+
1771
+ while (i--) {
1772
+ const key = keys[i];
1773
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1774
+ delete this[key];
1775
+ deleted = true;
1776
+ }
1777
+ }
1778
+
1779
+ return deleted;
1780
+ }
1781
+
1782
+ normalize(format) {
1783
+ const self = this;
1784
+ const headers = {};
1785
+
1786
+ utils.forEach(this, (value, header) => {
1787
+ const key = utils.findKey(headers, header);
1788
+
1789
+ if (key) {
1790
+ self[key] = normalizeValue(value);
1791
+ delete self[header];
1792
+ return;
1793
+ }
1794
+
1795
+ const normalized = format ? formatHeader(header) : String(header).trim();
1796
+
1797
+ if (normalized !== header) {
1798
+ delete self[header];
1799
+ }
1800
+
1801
+ self[normalized] = normalizeValue(value);
1802
+
1803
+ headers[normalized] = true;
1804
+ });
1805
+
1806
+ return this;
1807
+ }
1808
+
1809
+ concat(...targets) {
1810
+ return this.constructor.concat(this, ...targets);
1811
+ }
1812
+
1813
+ toJSON(asStrings) {
1814
+ const obj = Object.create(null);
1815
+
1816
+ utils.forEach(this, (value, header) => {
1817
+ value != null && value !== false && (obj[header] = asStrings && utils.isArray(value) ? value.join(', ') : value);
1818
+ });
1819
+
1820
+ return obj;
1821
+ }
1822
+
1823
+ [Symbol.iterator]() {
1824
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1825
+ }
1826
+
1827
+ toString() {
1828
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
1829
+ }
1830
+
1831
+ get [Symbol.toStringTag]() {
1832
+ return 'AxiosHeaders';
1833
+ }
1834
+
1835
+ static from(thing) {
1836
+ return thing instanceof this ? thing : new this(thing);
1837
+ }
1838
+
1839
+ static concat(first, ...targets) {
1840
+ const computed = new this(first);
1841
+
1842
+ targets.forEach((target) => computed.set(target));
1843
+
1844
+ return computed;
1845
+ }
1846
+
1847
+ static accessor(header) {
1848
+ const internals = this[$internals] = (this[$internals] = {
1849
+ accessors: {}
1850
+ });
1851
+
1852
+ const accessors = internals.accessors;
1853
+ const prototype = this.prototype;
1854
+
1855
+ function defineAccessor(_header) {
1856
+ const lHeader = normalizeHeader(_header);
1857
+
1858
+ if (!accessors[lHeader]) {
1859
+ buildAccessors(prototype, _header);
1860
+ accessors[lHeader] = true;
1861
+ }
1862
+ }
1863
+
1864
+ utils.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1865
+
1866
+ return this;
1867
+ }
1868
+ }
1869
+
1870
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
1871
+
1872
+ utils.freezeMethods(AxiosHeaders.prototype);
1873
+ utils.freezeMethods(AxiosHeaders);
1874
+
1875
+ var AxiosHeaders$1 = AxiosHeaders;
1876
+
1877
+ /**
1878
+ * Transform the data for a request or a response
1879
+ *
1880
+ * @param {Array|Function} fns A single function or Array of functions
1881
+ * @param {?Object} response The response object
1882
+ *
1883
+ * @returns {*} The resulting transformed data
1884
+ */
1885
+ function transformData(fns, response) {
1886
+ const config = this || defaults$1;
1887
+ const context = response || config;
1888
+ const headers = AxiosHeaders$1.from(context.headers);
1889
+ let data = context.data;
1890
+
1891
+ utils.forEach(fns, function transform(fn) {
1892
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1893
+ });
1894
+
1895
+ headers.normalize();
1896
+
1897
+ return data;
1898
+ }
1899
+
1900
+ function isCancel(value) {
1901
+ return !!(value && value.__CANCEL__);
1902
+ }
1903
+
1904
+ /**
1905
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1906
+ *
1907
+ * @param {string=} message The message.
1908
+ * @param {Object=} config The config.
1909
+ * @param {Object=} request The request.
1910
+ *
1911
+ * @returns {CanceledError} The created error.
1912
+ */
1913
+ function CanceledError(message, config, request) {
1914
+ // eslint-disable-next-line no-eq-null,eqeqeq
1915
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
1916
+ this.name = 'CanceledError';
1917
+ }
1918
+
1919
+ utils.inherits(CanceledError, AxiosError, {
1920
+ __CANCEL__: true
1921
+ });
1922
+
1923
+ /**
1924
+ * Resolve or reject a Promise based on response status.
1925
+ *
1926
+ * @param {Function} resolve A function that resolves the promise.
1927
+ * @param {Function} reject A function that rejects the promise.
1928
+ * @param {object} response The response.
1929
+ *
1930
+ * @returns {object} The response.
1931
+ */
1932
+ function settle(resolve, reject, response) {
1933
+ const validateStatus = response.config.validateStatus;
1934
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1935
+ resolve(response);
1936
+ } else {
1937
+ reject(new AxiosError(
1938
+ 'Request failed with status code ' + response.status,
1939
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1940
+ response.config,
1941
+ response.request,
1942
+ response
1943
+ ));
1944
+ }
1945
+ }
1946
+
1947
+ var cookies = platform.isStandardBrowserEnv ?
1948
+
1949
+ // Standard browser envs support document.cookie
1950
+ (function standardBrowserEnv() {
1951
+ return {
1952
+ write: function write(name, value, expires, path, domain, secure) {
1953
+ const cookie = [];
1954
+ cookie.push(name + '=' + encodeURIComponent(value));
1955
+
1956
+ if (utils.isNumber(expires)) {
1957
+ cookie.push('expires=' + new Date(expires).toGMTString());
1958
+ }
1959
+
1960
+ if (utils.isString(path)) {
1961
+ cookie.push('path=' + path);
1962
+ }
1963
+
1964
+ if (utils.isString(domain)) {
1965
+ cookie.push('domain=' + domain);
1966
+ }
1967
+
1968
+ if (secure === true) {
1969
+ cookie.push('secure');
1970
+ }
1971
+
1972
+ document.cookie = cookie.join('; ');
1973
+ },
1974
+
1975
+ read: function read(name) {
1976
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1977
+ return (match ? decodeURIComponent(match[3]) : null);
1978
+ },
1979
+
1980
+ remove: function remove(name) {
1981
+ this.write(name, '', Date.now() - 86400000);
1982
+ }
1983
+ };
1984
+ })() :
1985
+
1986
+ // Non standard browser env (web workers, react-native) lack needed support.
1987
+ (function nonStandardBrowserEnv() {
1988
+ return {
1989
+ write: function write() {},
1990
+ read: function read() { return null; },
1991
+ remove: function remove() {}
1992
+ };
1993
+ })();
1994
+
1995
+ /**
1996
+ * Determines whether the specified URL is absolute
1997
+ *
1998
+ * @param {string} url The URL to test
1999
+ *
2000
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2001
+ */
2002
+ function isAbsoluteURL(url) {
2003
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2004
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2005
+ // by any combination of letters, digits, plus, period, or hyphen.
2006
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2007
+ }
2008
+
2009
+ /**
2010
+ * Creates a new URL by combining the specified URLs
2011
+ *
2012
+ * @param {string} baseURL The base URL
2013
+ * @param {string} relativeURL The relative URL
2014
+ *
2015
+ * @returns {string} The combined URL
2016
+ */
2017
+ function combineURLs(baseURL, relativeURL) {
2018
+ return relativeURL
2019
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2020
+ : baseURL;
2021
+ }
2022
+
2023
+ /**
2024
+ * Creates a new URL by combining the baseURL with the requestedURL,
2025
+ * only when the requestedURL is not already an absolute URL.
2026
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2027
+ *
2028
+ * @param {string} baseURL The base URL
2029
+ * @param {string} requestedURL Absolute or relative URL to combine
2030
+ *
2031
+ * @returns {string} The combined full path
2032
+ */
2033
+ function buildFullPath(baseURL, requestedURL) {
2034
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
2035
+ return combineURLs(baseURL, requestedURL);
2036
+ }
2037
+ return requestedURL;
2038
+ }
2039
+
2040
+ var isURLSameOrigin = platform.isStandardBrowserEnv ?
2041
+
2042
+ // Standard browser envs have full support of the APIs needed to test
2043
+ // whether the request URL is of the same origin as current location.
2044
+ (function standardBrowserEnv() {
2045
+ const msie = /(msie|trident)/i.test(navigator.userAgent);
2046
+ const urlParsingNode = document.createElement('a');
2047
+ let originURL;
2048
+
2049
+ /**
2050
+ * Parse a URL to discover it's components
2051
+ *
2052
+ * @param {String} url The URL to be parsed
2053
+ * @returns {Object}
2054
+ */
2055
+ function resolveURL(url) {
2056
+ let href = url;
2057
+
2058
+ if (msie) {
2059
+ // IE needs attribute set twice to normalize properties
2060
+ urlParsingNode.setAttribute('href', href);
2061
+ href = urlParsingNode.href;
2062
+ }
2063
+
2064
+ urlParsingNode.setAttribute('href', href);
2065
+
2066
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
2067
+ return {
2068
+ href: urlParsingNode.href,
2069
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
2070
+ host: urlParsingNode.host,
2071
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
2072
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
2073
+ hostname: urlParsingNode.hostname,
2074
+ port: urlParsingNode.port,
2075
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
2076
+ urlParsingNode.pathname :
2077
+ '/' + urlParsingNode.pathname
2078
+ };
2079
+ }
2080
+
2081
+ originURL = resolveURL(window.location.href);
2082
+
2083
+ /**
2084
+ * Determine if a URL shares the same origin as the current location
2085
+ *
2086
+ * @param {String} requestURL The URL to test
2087
+ * @returns {boolean} True if URL shares the same origin, otherwise false
2088
+ */
2089
+ return function isURLSameOrigin(requestURL) {
2090
+ const parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
2091
+ return (parsed.protocol === originURL.protocol &&
2092
+ parsed.host === originURL.host);
2093
+ };
2094
+ })() :
2095
+
2096
+ // Non standard browser envs (web workers, react-native) lack needed support.
2097
+ (function nonStandardBrowserEnv() {
2098
+ return function isURLSameOrigin() {
2099
+ return true;
2100
+ };
2101
+ })();
2102
+
2103
+ function parseProtocol(url) {
2104
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2105
+ return match && match[1] || '';
2106
+ }
2107
+
2108
+ /**
2109
+ * Calculate data maxRate
2110
+ * @param {Number} [samplesCount= 10]
2111
+ * @param {Number} [min= 1000]
2112
+ * @returns {Function}
2113
+ */
2114
+ function speedometer(samplesCount, min) {
2115
+ samplesCount = samplesCount || 10;
2116
+ const bytes = new Array(samplesCount);
2117
+ const timestamps = new Array(samplesCount);
2118
+ let head = 0;
2119
+ let tail = 0;
2120
+ let firstSampleTS;
2121
+
2122
+ min = min !== undefined ? min : 1000;
2123
+
2124
+ return function push(chunkLength) {
2125
+ const now = Date.now();
2126
+
2127
+ const startedAt = timestamps[tail];
2128
+
2129
+ if (!firstSampleTS) {
2130
+ firstSampleTS = now;
2131
+ }
2132
+
2133
+ bytes[head] = chunkLength;
2134
+ timestamps[head] = now;
2135
+
2136
+ let i = tail;
2137
+ let bytesCount = 0;
2138
+
2139
+ while (i !== head) {
2140
+ bytesCount += bytes[i++];
2141
+ i = i % samplesCount;
2142
+ }
2143
+
2144
+ head = (head + 1) % samplesCount;
2145
+
2146
+ if (head === tail) {
2147
+ tail = (tail + 1) % samplesCount;
2148
+ }
2149
+
2150
+ if (now - firstSampleTS < min) {
2151
+ return;
2152
+ }
2153
+
2154
+ const passed = startedAt && now - startedAt;
2155
+
2156
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2157
+ };
2158
+ }
2159
+
2160
+ function progressEventReducer(listener, isDownloadStream) {
2161
+ let bytesNotified = 0;
2162
+ const _speedometer = speedometer(50, 250);
2163
+
2164
+ return e => {
2165
+ const loaded = e.loaded;
2166
+ const total = e.lengthComputable ? e.total : undefined;
2167
+ const progressBytes = loaded - bytesNotified;
2168
+ const rate = _speedometer(progressBytes);
2169
+ const inRange = loaded <= total;
2170
+
2171
+ bytesNotified = loaded;
2172
+
2173
+ const data = {
2174
+ loaded,
2175
+ total,
2176
+ progress: total ? (loaded / total) : undefined,
2177
+ bytes: progressBytes,
2178
+ rate: rate ? rate : undefined,
2179
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2180
+ event: e
2181
+ };
2182
+
2183
+ data[isDownloadStream ? 'download' : 'upload'] = true;
2184
+
2185
+ listener(data);
2186
+ };
2187
+ }
2188
+
2189
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2190
+
2191
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2192
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2193
+ let requestData = config.data;
2194
+ const requestHeaders = AxiosHeaders$1.from(config.headers).normalize();
2195
+ const responseType = config.responseType;
2196
+ let onCanceled;
2197
+ function done() {
2198
+ if (config.cancelToken) {
2199
+ config.cancelToken.unsubscribe(onCanceled);
2200
+ }
2201
+
2202
+ if (config.signal) {
2203
+ config.signal.removeEventListener('abort', onCanceled);
2204
+ }
2205
+ }
2206
+
2207
+ if (utils.isFormData(requestData) && (platform.isStandardBrowserEnv || platform.isStandardBrowserWebWorkerEnv)) {
2208
+ requestHeaders.setContentType(false); // Let the browser set it
2209
+ }
2210
+
2211
+ let request = new XMLHttpRequest();
2212
+
2213
+ // HTTP basic authentication
2214
+ if (config.auth) {
2215
+ const username = config.auth.username || '';
2216
+ const password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
2217
+ requestHeaders.set('Authorization', 'Basic ' + btoa(username + ':' + password));
2218
+ }
2219
+
2220
+ const fullPath = buildFullPath(config.baseURL, config.url);
2221
+
2222
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
2223
+
2224
+ // Set the request timeout in MS
2225
+ request.timeout = config.timeout;
2226
+
2227
+ function onloadend() {
2228
+ if (!request) {
2229
+ return;
2230
+ }
2231
+ // Prepare the response
2232
+ const responseHeaders = AxiosHeaders$1.from(
2233
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2234
+ );
2235
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2236
+ request.responseText : request.response;
2237
+ const response = {
2238
+ data: responseData,
2239
+ status: request.status,
2240
+ statusText: request.statusText,
2241
+ headers: responseHeaders,
2242
+ config,
2243
+ request
2244
+ };
2245
+
2246
+ settle(function _resolve(value) {
2247
+ resolve(value);
2248
+ done();
2249
+ }, function _reject(err) {
2250
+ reject(err);
2251
+ done();
2252
+ }, response);
2253
+
2254
+ // Clean up request
2255
+ request = null;
2256
+ }
2257
+
2258
+ if ('onloadend' in request) {
2259
+ // Use onloadend if available
2260
+ request.onloadend = onloadend;
2261
+ } else {
2262
+ // Listen for ready state to emulate onloadend
2263
+ request.onreadystatechange = function handleLoad() {
2264
+ if (!request || request.readyState !== 4) {
2265
+ return;
2266
+ }
2267
+
2268
+ // The request errored out and we didn't get a response, this will be
2269
+ // handled by onerror instead
2270
+ // With one exception: request that using file: protocol, most browsers
2271
+ // will return status as 0 even though it's a successful request
2272
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2273
+ return;
2274
+ }
2275
+ // readystate handler is calling before onerror or ontimeout handlers,
2276
+ // so we should call onloadend on the next 'tick'
2277
+ setTimeout(onloadend);
2278
+ };
2279
+ }
2280
+
2281
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2282
+ request.onabort = function handleAbort() {
2283
+ if (!request) {
2284
+ return;
2285
+ }
2286
+
2287
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2288
+
2289
+ // Clean up request
2290
+ request = null;
2291
+ };
2292
+
2293
+ // Handle low level network errors
2294
+ request.onerror = function handleError() {
2295
+ // Real errors are hidden from us by the browser
2296
+ // onerror should only fire if it's a network error
2297
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2298
+
2299
+ // Clean up request
2300
+ request = null;
2301
+ };
2302
+
2303
+ // Handle timeout
2304
+ request.ontimeout = function handleTimeout() {
2305
+ let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
2306
+ const transitional = config.transitional || transitionalDefaults;
2307
+ if (config.timeoutErrorMessage) {
2308
+ timeoutErrorMessage = config.timeoutErrorMessage;
2309
+ }
2310
+ reject(new AxiosError(
2311
+ timeoutErrorMessage,
2312
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2313
+ config,
2314
+ request));
2315
+
2316
+ // Clean up request
2317
+ request = null;
2318
+ };
2319
+
2320
+ // Add xsrf header
2321
+ // This is only done if running in a standard browser environment.
2322
+ // Specifically not if we're in a web worker, or react-native.
2323
+ if (platform.isStandardBrowserEnv) {
2324
+ // Add xsrf header
2325
+ const xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath))
2326
+ && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
2327
+
2328
+ if (xsrfValue) {
2329
+ requestHeaders.set(config.xsrfHeaderName, xsrfValue);
2330
+ }
2331
+ }
2332
+
2333
+ // Remove Content-Type if data is undefined
2334
+ requestData === undefined && requestHeaders.setContentType(null);
2335
+
2336
+ // Add headers to the request
2337
+ if ('setRequestHeader' in request) {
2338
+ utils.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2339
+ request.setRequestHeader(key, val);
2340
+ });
2341
+ }
2342
+
2343
+ // Add withCredentials to request if needed
2344
+ if (!utils.isUndefined(config.withCredentials)) {
2345
+ request.withCredentials = !!config.withCredentials;
2346
+ }
2347
+
2348
+ // Add responseType to request if needed
2349
+ if (responseType && responseType !== 'json') {
2350
+ request.responseType = config.responseType;
2351
+ }
2352
+
2353
+ // Handle progress if needed
2354
+ if (typeof config.onDownloadProgress === 'function') {
2355
+ request.addEventListener('progress', progressEventReducer(config.onDownloadProgress, true));
2356
+ }
2357
+
2358
+ // Not all browsers support upload events
2359
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
2360
+ request.upload.addEventListener('progress', progressEventReducer(config.onUploadProgress));
2361
+ }
2362
+
2363
+ if (config.cancelToken || config.signal) {
2364
+ // Handle cancellation
2365
+ // eslint-disable-next-line func-names
2366
+ onCanceled = cancel => {
2367
+ if (!request) {
2368
+ return;
2369
+ }
2370
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2371
+ request.abort();
2372
+ request = null;
2373
+ };
2374
+
2375
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
2376
+ if (config.signal) {
2377
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
2378
+ }
2379
+ }
2380
+
2381
+ const protocol = parseProtocol(fullPath);
2382
+
2383
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2384
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2385
+ return;
2386
+ }
2387
+
2388
+
2389
+ // Send the request
2390
+ request.send(requestData || null);
2391
+ });
2392
+ };
2393
+
2394
+ const knownAdapters = {
2395
+ http: httpAdapter,
2396
+ xhr: xhrAdapter
2397
+ };
2398
+
2399
+ utils.forEach(knownAdapters, (fn, value) => {
2400
+ if(fn) {
2401
+ try {
2402
+ Object.defineProperty(fn, 'name', {value});
2403
+ } catch (e) {
2404
+ // eslint-disable-next-line no-empty
2405
+ }
2406
+ Object.defineProperty(fn, 'adapterName', {value});
2407
+ }
2408
+ });
2409
+
2410
+ var adapters = {
2411
+ getAdapter: (adapters) => {
2412
+ adapters = utils.isArray(adapters) ? adapters : [adapters];
2413
+
2414
+ const {length} = adapters;
2415
+ let nameOrAdapter;
2416
+ let adapter;
2417
+
2418
+ for (let i = 0; i < length; i++) {
2419
+ nameOrAdapter = adapters[i];
2420
+ if((adapter = utils.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter)) {
2421
+ break;
2422
+ }
2423
+ }
2424
+
2425
+ if (!adapter) {
2426
+ if (adapter === false) {
2427
+ throw new AxiosError(
2428
+ `Adapter ${nameOrAdapter} is not supported by the environment`,
2429
+ 'ERR_NOT_SUPPORT'
2430
+ );
2431
+ }
2432
+
2433
+ throw new Error(
2434
+ utils.hasOwnProp(knownAdapters, nameOrAdapter) ?
2435
+ `Adapter '${nameOrAdapter}' is not available in the build` :
2436
+ `Unknown adapter '${nameOrAdapter}'`
2437
+ );
2438
+ }
2439
+
2440
+ if (!utils.isFunction(adapter)) {
2441
+ throw new TypeError('adapter is not a function');
2442
+ }
2443
+
2444
+ return adapter;
2445
+ },
2446
+ adapters: knownAdapters
2447
+ };
2448
+
2449
+ /**
2450
+ * Throws a `CanceledError` if cancellation has been requested.
2451
+ *
2452
+ * @param {Object} config The config that is to be used for the request
2453
+ *
2454
+ * @returns {void}
2455
+ */
2456
+ function throwIfCancellationRequested(config) {
2457
+ if (config.cancelToken) {
2458
+ config.cancelToken.throwIfRequested();
2459
+ }
2460
+
2461
+ if (config.signal && config.signal.aborted) {
2462
+ throw new CanceledError(null, config);
2463
+ }
2464
+ }
2465
+
2466
+ /**
2467
+ * Dispatch a request to the server using the configured adapter.
2468
+ *
2469
+ * @param {object} config The config that is to be used for the request
2470
+ *
2471
+ * @returns {Promise} The Promise to be fulfilled
2472
+ */
2473
+ function dispatchRequest(config) {
2474
+ throwIfCancellationRequested(config);
2475
+
2476
+ config.headers = AxiosHeaders$1.from(config.headers);
2477
+
2478
+ // Transform request data
2479
+ config.data = transformData.call(
2480
+ config,
2481
+ config.transformRequest
2482
+ );
2483
+
2484
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
2485
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2486
+ }
2487
+
2488
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2489
+
2490
+ return adapter(config).then(function onAdapterResolution(response) {
2491
+ throwIfCancellationRequested(config);
2492
+
2493
+ // Transform response data
2494
+ response.data = transformData.call(
2495
+ config,
2496
+ config.transformResponse,
2497
+ response
2498
+ );
2499
+
2500
+ response.headers = AxiosHeaders$1.from(response.headers);
2501
+
2502
+ return response;
2503
+ }, function onAdapterRejection(reason) {
2504
+ if (!isCancel(reason)) {
2505
+ throwIfCancellationRequested(config);
2506
+
2507
+ // Transform response data
2508
+ if (reason && reason.response) {
2509
+ reason.response.data = transformData.call(
2510
+ config,
2511
+ config.transformResponse,
2512
+ reason.response
2513
+ );
2514
+ reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
2515
+ }
2516
+ }
2517
+
2518
+ return Promise.reject(reason);
2519
+ });
2520
+ }
2521
+
2522
+ const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? thing.toJSON() : thing;
2523
+
2524
+ /**
2525
+ * Config-specific merge-function which creates a new config-object
2526
+ * by merging two configuration objects together.
2527
+ *
2528
+ * @param {Object} config1
2529
+ * @param {Object} config2
2530
+ *
2531
+ * @returns {Object} New object resulting from merging config2 to config1
2532
+ */
2533
+ function mergeConfig(config1, config2) {
2534
+ // eslint-disable-next-line no-param-reassign
2535
+ config2 = config2 || {};
2536
+ const config = {};
2537
+
2538
+ function getMergedValue(target, source, caseless) {
2539
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
2540
+ return utils.merge.call({caseless}, target, source);
2541
+ } else if (utils.isPlainObject(source)) {
2542
+ return utils.merge({}, source);
2543
+ } else if (utils.isArray(source)) {
2544
+ return source.slice();
2545
+ }
2546
+ return source;
2547
+ }
2548
+
2549
+ // eslint-disable-next-line consistent-return
2550
+ function mergeDeepProperties(a, b, caseless) {
2551
+ if (!utils.isUndefined(b)) {
2552
+ return getMergedValue(a, b, caseless);
2553
+ } else if (!utils.isUndefined(a)) {
2554
+ return getMergedValue(undefined, a, caseless);
2555
+ }
2556
+ }
2557
+
2558
+ // eslint-disable-next-line consistent-return
2559
+ function valueFromConfig2(a, b) {
2560
+ if (!utils.isUndefined(b)) {
2561
+ return getMergedValue(undefined, b);
2562
+ }
2563
+ }
2564
+
2565
+ // eslint-disable-next-line consistent-return
2566
+ function defaultToConfig2(a, b) {
2567
+ if (!utils.isUndefined(b)) {
2568
+ return getMergedValue(undefined, b);
2569
+ } else if (!utils.isUndefined(a)) {
2570
+ return getMergedValue(undefined, a);
2571
+ }
2572
+ }
2573
+
2574
+ // eslint-disable-next-line consistent-return
2575
+ function mergeDirectKeys(a, b, prop) {
2576
+ if (prop in config2) {
2577
+ return getMergedValue(a, b);
2578
+ } else if (prop in config1) {
2579
+ return getMergedValue(undefined, a);
2580
+ }
2581
+ }
2582
+
2583
+ const mergeMap = {
2584
+ url: valueFromConfig2,
2585
+ method: valueFromConfig2,
2586
+ data: valueFromConfig2,
2587
+ baseURL: defaultToConfig2,
2588
+ transformRequest: defaultToConfig2,
2589
+ transformResponse: defaultToConfig2,
2590
+ paramsSerializer: defaultToConfig2,
2591
+ timeout: defaultToConfig2,
2592
+ timeoutMessage: defaultToConfig2,
2593
+ withCredentials: defaultToConfig2,
2594
+ adapter: defaultToConfig2,
2595
+ responseType: defaultToConfig2,
2596
+ xsrfCookieName: defaultToConfig2,
2597
+ xsrfHeaderName: defaultToConfig2,
2598
+ onUploadProgress: defaultToConfig2,
2599
+ onDownloadProgress: defaultToConfig2,
2600
+ decompress: defaultToConfig2,
2601
+ maxContentLength: defaultToConfig2,
2602
+ maxBodyLength: defaultToConfig2,
2603
+ beforeRedirect: defaultToConfig2,
2604
+ transport: defaultToConfig2,
2605
+ httpAgent: defaultToConfig2,
2606
+ httpsAgent: defaultToConfig2,
2607
+ cancelToken: defaultToConfig2,
2608
+ socketPath: defaultToConfig2,
2609
+ responseEncoding: defaultToConfig2,
2610
+ validateStatus: mergeDirectKeys,
2611
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2612
+ };
2613
+
2614
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
2615
+ const merge = mergeMap[prop] || mergeDeepProperties;
2616
+ const configValue = merge(config1[prop], config2[prop], prop);
2617
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2618
+ });
2619
+
2620
+ return config;
2621
+ }
2622
+
2623
+ const VERSION = "1.3.4";
2624
+
2625
+ const validators$1 = {};
2626
+
2627
+ // eslint-disable-next-line func-names
2628
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
2629
+ validators$1[type] = function validator(thing) {
2630
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2631
+ };
2632
+ });
2633
+
2634
+ const deprecatedWarnings = {};
2635
+
2636
+ /**
2637
+ * Transitional option validator
2638
+ *
2639
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
2640
+ * @param {string?} version - deprecated version / removed since version
2641
+ * @param {string?} message - some message with additional info
2642
+ *
2643
+ * @returns {function}
2644
+ */
2645
+ validators$1.transitional = function transitional(validator, version, message) {
2646
+ function formatMessage(opt, desc) {
2647
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2648
+ }
2649
+
2650
+ // eslint-disable-next-line func-names
2651
+ return (value, opt, opts) => {
2652
+ if (validator === false) {
2653
+ throw new AxiosError(
2654
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
2655
+ AxiosError.ERR_DEPRECATED
2656
+ );
2657
+ }
2658
+
2659
+ if (version && !deprecatedWarnings[opt]) {
2660
+ deprecatedWarnings[opt] = true;
2661
+ // eslint-disable-next-line no-console
2662
+ console.warn(
2663
+ formatMessage(
2664
+ opt,
2665
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
2666
+ )
2667
+ );
2668
+ }
2669
+
2670
+ return validator ? validator(value, opt, opts) : true;
2671
+ };
2672
+ };
2673
+
2674
+ /**
2675
+ * Assert object's properties type
2676
+ *
2677
+ * @param {object} options
2678
+ * @param {object} schema
2679
+ * @param {boolean?} allowUnknown
2680
+ *
2681
+ * @returns {object}
2682
+ */
2683
+
2684
+ function assertOptions(options, schema, allowUnknown) {
2685
+ if (typeof options !== 'object') {
2686
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
2687
+ }
2688
+ const keys = Object.keys(options);
2689
+ let i = keys.length;
2690
+ while (i-- > 0) {
2691
+ const opt = keys[i];
2692
+ const validator = schema[opt];
2693
+ if (validator) {
2694
+ const value = options[opt];
2695
+ const result = value === undefined || validator(value, opt, options);
2696
+ if (result !== true) {
2697
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
2698
+ }
2699
+ continue;
2700
+ }
2701
+ if (allowUnknown !== true) {
2702
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
2703
+ }
2704
+ }
2705
+ }
2706
+
2707
+ var validator = {
2708
+ assertOptions,
2709
+ validators: validators$1
2710
+ };
2711
+
2712
+ const validators = validator.validators;
2713
+
2714
+ /**
2715
+ * Create a new instance of Axios
2716
+ *
2717
+ * @param {Object} instanceConfig The default config for the instance
2718
+ *
2719
+ * @return {Axios} A new instance of Axios
2720
+ */
2721
+ class Axios {
2722
+ constructor(instanceConfig) {
2723
+ this.defaults = instanceConfig;
2724
+ this.interceptors = {
2725
+ request: new InterceptorManager$1(),
2726
+ response: new InterceptorManager$1()
2727
+ };
2728
+ }
2729
+
2730
+ /**
2731
+ * Dispatch a request
2732
+ *
2733
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2734
+ * @param {?Object} config
2735
+ *
2736
+ * @returns {Promise} The Promise to be fulfilled
2737
+ */
2738
+ request(configOrUrl, config) {
2739
+ /*eslint no-param-reassign:0*/
2740
+ // Allow for axios('example/url'[, config]) a la fetch API
2741
+ if (typeof configOrUrl === 'string') {
2742
+ config = config || {};
2743
+ config.url = configOrUrl;
2744
+ } else {
2745
+ config = configOrUrl || {};
2746
+ }
2747
+
2748
+ config = mergeConfig(this.defaults, config);
2749
+
2750
+ const {transitional, paramsSerializer, headers} = config;
2751
+
2752
+ if (transitional !== undefined) {
2753
+ validator.assertOptions(transitional, {
2754
+ silentJSONParsing: validators.transitional(validators.boolean),
2755
+ forcedJSONParsing: validators.transitional(validators.boolean),
2756
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2757
+ }, false);
2758
+ }
2759
+
2760
+ if (paramsSerializer !== undefined) {
2761
+ validator.assertOptions(paramsSerializer, {
2762
+ encode: validators.function,
2763
+ serialize: validators.function
2764
+ }, true);
2765
+ }
2766
+
2767
+ // Set config.method
2768
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2769
+
2770
+ let contextHeaders;
2771
+
2772
+ // Flatten headers
2773
+ contextHeaders = headers && utils.merge(
2774
+ headers.common,
2775
+ headers[config.method]
2776
+ );
2777
+
2778
+ contextHeaders && utils.forEach(
2779
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
2780
+ (method) => {
2781
+ delete headers[method];
2782
+ }
2783
+ );
2784
+
2785
+ config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
2786
+
2787
+ // filter out skipped interceptors
2788
+ const requestInterceptorChain = [];
2789
+ let synchronousRequestInterceptors = true;
2790
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2791
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2792
+ return;
2793
+ }
2794
+
2795
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2796
+
2797
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2798
+ });
2799
+
2800
+ const responseInterceptorChain = [];
2801
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2802
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2803
+ });
2804
+
2805
+ let promise;
2806
+ let i = 0;
2807
+ let len;
2808
+
2809
+ if (!synchronousRequestInterceptors) {
2810
+ const chain = [dispatchRequest.bind(this), undefined];
2811
+ chain.unshift.apply(chain, requestInterceptorChain);
2812
+ chain.push.apply(chain, responseInterceptorChain);
2813
+ len = chain.length;
2814
+
2815
+ promise = Promise.resolve(config);
2816
+
2817
+ while (i < len) {
2818
+ promise = promise.then(chain[i++], chain[i++]);
2819
+ }
2820
+
2821
+ return promise;
2822
+ }
2823
+
2824
+ len = requestInterceptorChain.length;
2825
+
2826
+ let newConfig = config;
2827
+
2828
+ i = 0;
2829
+
2830
+ while (i < len) {
2831
+ const onFulfilled = requestInterceptorChain[i++];
2832
+ const onRejected = requestInterceptorChain[i++];
2833
+ try {
2834
+ newConfig = onFulfilled(newConfig);
2835
+ } catch (error) {
2836
+ onRejected.call(this, error);
2837
+ break;
2838
+ }
2839
+ }
2840
+
2841
+ try {
2842
+ promise = dispatchRequest.call(this, newConfig);
2843
+ } catch (error) {
2844
+ return Promise.reject(error);
2845
+ }
2846
+
2847
+ i = 0;
2848
+ len = responseInterceptorChain.length;
2849
+
2850
+ while (i < len) {
2851
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2852
+ }
2853
+
2854
+ return promise;
2855
+ }
2856
+
2857
+ getUri(config) {
2858
+ config = mergeConfig(this.defaults, config);
2859
+ const fullPath = buildFullPath(config.baseURL, config.url);
2860
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2861
+ }
2862
+ }
2863
+
2864
+ // Provide aliases for supported request methods
2865
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2866
+ /*eslint func-names:0*/
2867
+ Axios.prototype[method] = function(url, config) {
2868
+ return this.request(mergeConfig(config || {}, {
2869
+ method,
2870
+ url,
2871
+ data: (config || {}).data
2872
+ }));
2873
+ };
2874
+ });
2875
+
2876
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2877
+ /*eslint func-names:0*/
2878
+
2879
+ function generateHTTPMethod(isForm) {
2880
+ return function httpMethod(url, data, config) {
2881
+ return this.request(mergeConfig(config || {}, {
2882
+ method,
2883
+ headers: isForm ? {
2884
+ 'Content-Type': 'multipart/form-data'
2885
+ } : {},
2886
+ url,
2887
+ data
2888
+ }));
2889
+ };
2890
+ }
2891
+
2892
+ Axios.prototype[method] = generateHTTPMethod();
2893
+
2894
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2895
+ });
2896
+
2897
+ var Axios$1 = Axios;
2898
+
2899
+ /**
2900
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
2901
+ *
2902
+ * @param {Function} executor The executor function.
2903
+ *
2904
+ * @returns {CancelToken}
2905
+ */
2906
+ class CancelToken {
2907
+ constructor(executor) {
2908
+ if (typeof executor !== 'function') {
2909
+ throw new TypeError('executor must be a function.');
2910
+ }
2911
+
2912
+ let resolvePromise;
2913
+
2914
+ this.promise = new Promise(function promiseExecutor(resolve) {
2915
+ resolvePromise = resolve;
2916
+ });
2917
+
2918
+ const token = this;
2919
+
2920
+ // eslint-disable-next-line func-names
2921
+ this.promise.then(cancel => {
2922
+ if (!token._listeners) return;
2923
+
2924
+ let i = token._listeners.length;
2925
+
2926
+ while (i-- > 0) {
2927
+ token._listeners[i](cancel);
2928
+ }
2929
+ token._listeners = null;
2930
+ });
2931
+
2932
+ // eslint-disable-next-line func-names
2933
+ this.promise.then = onfulfilled => {
2934
+ let _resolve;
2935
+ // eslint-disable-next-line func-names
2936
+ const promise = new Promise(resolve => {
2937
+ token.subscribe(resolve);
2938
+ _resolve = resolve;
2939
+ }).then(onfulfilled);
2940
+
2941
+ promise.cancel = function reject() {
2942
+ token.unsubscribe(_resolve);
2943
+ };
2944
+
2945
+ return promise;
2946
+ };
2947
+
2948
+ executor(function cancel(message, config, request) {
2949
+ if (token.reason) {
2950
+ // Cancellation has already been requested
2951
+ return;
2952
+ }
2953
+
2954
+ token.reason = new CanceledError(message, config, request);
2955
+ resolvePromise(token.reason);
2956
+ });
2957
+ }
2958
+
2959
+ /**
2960
+ * Throws a `CanceledError` if cancellation has been requested.
2961
+ */
2962
+ throwIfRequested() {
2963
+ if (this.reason) {
2964
+ throw this.reason;
2965
+ }
2966
+ }
2967
+
2968
+ /**
2969
+ * Subscribe to the cancel signal
2970
+ */
2971
+
2972
+ subscribe(listener) {
2973
+ if (this.reason) {
2974
+ listener(this.reason);
2975
+ return;
2976
+ }
2977
+
2978
+ if (this._listeners) {
2979
+ this._listeners.push(listener);
2980
+ } else {
2981
+ this._listeners = [listener];
2982
+ }
2983
+ }
2984
+
2985
+ /**
2986
+ * Unsubscribe from the cancel signal
2987
+ */
2988
+
2989
+ unsubscribe(listener) {
2990
+ if (!this._listeners) {
2991
+ return;
2992
+ }
2993
+ const index = this._listeners.indexOf(listener);
2994
+ if (index !== -1) {
2995
+ this._listeners.splice(index, 1);
2996
+ }
2997
+ }
2998
+
2999
+ /**
3000
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3001
+ * cancels the `CancelToken`.
3002
+ */
3003
+ static source() {
3004
+ let cancel;
3005
+ const token = new CancelToken(function executor(c) {
3006
+ cancel = c;
3007
+ });
3008
+ return {
3009
+ token,
3010
+ cancel
3011
+ };
3012
+ }
3013
+ }
3014
+
3015
+ var CancelToken$1 = CancelToken;
3016
+
3017
+ /**
3018
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3019
+ *
3020
+ * Common use case would be to use `Function.prototype.apply`.
3021
+ *
3022
+ * ```js
3023
+ * function f(x, y, z) {}
3024
+ * var args = [1, 2, 3];
3025
+ * f.apply(null, args);
3026
+ * ```
3027
+ *
3028
+ * With `spread` this example can be re-written.
3029
+ *
3030
+ * ```js
3031
+ * spread(function(x, y, z) {})([1, 2, 3]);
3032
+ * ```
3033
+ *
3034
+ * @param {Function} callback
3035
+ *
3036
+ * @returns {Function}
3037
+ */
3038
+ function spread(callback) {
3039
+ return function wrap(arr) {
3040
+ return callback.apply(null, arr);
3041
+ };
3042
+ }
3043
+
3044
+ /**
3045
+ * Determines whether the payload is an error thrown by Axios
3046
+ *
3047
+ * @param {*} payload The value to test
3048
+ *
3049
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3050
+ */
3051
+ function isAxiosError(payload) {
3052
+ return utils.isObject(payload) && (payload.isAxiosError === true);
3053
+ }
3054
+
3055
+ const HttpStatusCode = {
3056
+ Continue: 100,
3057
+ SwitchingProtocols: 101,
3058
+ Processing: 102,
3059
+ EarlyHints: 103,
3060
+ Ok: 200,
3061
+ Created: 201,
3062
+ Accepted: 202,
3063
+ NonAuthoritativeInformation: 203,
3064
+ NoContent: 204,
3065
+ ResetContent: 205,
3066
+ PartialContent: 206,
3067
+ MultiStatus: 207,
3068
+ AlreadyReported: 208,
3069
+ ImUsed: 226,
3070
+ MultipleChoices: 300,
3071
+ MovedPermanently: 301,
3072
+ Found: 302,
3073
+ SeeOther: 303,
3074
+ NotModified: 304,
3075
+ UseProxy: 305,
3076
+ Unused: 306,
3077
+ TemporaryRedirect: 307,
3078
+ PermanentRedirect: 308,
3079
+ BadRequest: 400,
3080
+ Unauthorized: 401,
3081
+ PaymentRequired: 402,
3082
+ Forbidden: 403,
3083
+ NotFound: 404,
3084
+ MethodNotAllowed: 405,
3085
+ NotAcceptable: 406,
3086
+ ProxyAuthenticationRequired: 407,
3087
+ RequestTimeout: 408,
3088
+ Conflict: 409,
3089
+ Gone: 410,
3090
+ LengthRequired: 411,
3091
+ PreconditionFailed: 412,
3092
+ PayloadTooLarge: 413,
3093
+ UriTooLong: 414,
3094
+ UnsupportedMediaType: 415,
3095
+ RangeNotSatisfiable: 416,
3096
+ ExpectationFailed: 417,
3097
+ ImATeapot: 418,
3098
+ MisdirectedRequest: 421,
3099
+ UnprocessableEntity: 422,
3100
+ Locked: 423,
3101
+ FailedDependency: 424,
3102
+ TooEarly: 425,
3103
+ UpgradeRequired: 426,
3104
+ PreconditionRequired: 428,
3105
+ TooManyRequests: 429,
3106
+ RequestHeaderFieldsTooLarge: 431,
3107
+ UnavailableForLegalReasons: 451,
3108
+ InternalServerError: 500,
3109
+ NotImplemented: 501,
3110
+ BadGateway: 502,
3111
+ ServiceUnavailable: 503,
3112
+ GatewayTimeout: 504,
3113
+ HttpVersionNotSupported: 505,
3114
+ VariantAlsoNegotiates: 506,
3115
+ InsufficientStorage: 507,
3116
+ LoopDetected: 508,
3117
+ NotExtended: 510,
3118
+ NetworkAuthenticationRequired: 511,
3119
+ };
3120
+
3121
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
3122
+ HttpStatusCode[value] = key;
3123
+ });
3124
+
3125
+ var HttpStatusCode$1 = HttpStatusCode;
3126
+
3127
+ /**
3128
+ * Create an instance of Axios
3129
+ *
3130
+ * @param {Object} defaultConfig The default config for the instance
3131
+ *
3132
+ * @returns {Axios} A new instance of Axios
3133
+ */
3134
+ function createInstance(defaultConfig) {
3135
+ const context = new Axios$1(defaultConfig);
3136
+ const instance = bind(Axios$1.prototype.request, context);
3137
+
3138
+ // Copy axios.prototype to instance
3139
+ utils.extend(instance, Axios$1.prototype, context, {allOwnKeys: true});
3140
+
3141
+ // Copy context to instance
3142
+ utils.extend(instance, context, null, {allOwnKeys: true});
3143
+
3144
+ // Factory for creating new instances
3145
+ instance.create = function create(instanceConfig) {
3146
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
3147
+ };
3148
+
3149
+ return instance;
3150
+ }
3151
+
3152
+ // Create the default instance to be exported
3153
+ const axios = createInstance(defaults$1);
3154
+
3155
+ // Expose Axios class to allow class inheritance
3156
+ axios.Axios = Axios$1;
3157
+
3158
+ // Expose Cancel & CancelToken
3159
+ axios.CanceledError = CanceledError;
3160
+ axios.CancelToken = CancelToken$1;
3161
+ axios.isCancel = isCancel;
3162
+ axios.VERSION = VERSION;
3163
+ axios.toFormData = toFormData;
3164
+
3165
+ // Expose AxiosError class
3166
+ axios.AxiosError = AxiosError;
3167
+
3168
+ // alias for CanceledError for backward compatibility
3169
+ axios.Cancel = axios.CanceledError;
3170
+
3171
+ // Expose all/spread
3172
+ axios.all = function all(promises) {
3173
+ return Promise.all(promises);
3174
+ };
3175
+
3176
+ axios.spread = spread;
3177
+
3178
+ // Expose isAxiosError
3179
+ axios.isAxiosError = isAxiosError;
3180
+
3181
+ // Expose mergeConfig
3182
+ axios.mergeConfig = mergeConfig;
3183
+
3184
+ axios.AxiosHeaders = AxiosHeaders$1;
3185
+
3186
+ axios.formToJSON = thing => formDataToJSON(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
3187
+
3188
+ axios.HttpStatusCode = HttpStatusCode$1;
3189
+
3190
+ axios.default = axios;
3191
+
3192
+ module.exports = axios;
3193
+ //# sourceMappingURL=axios.cjs.map