axios 1.1.3 → 1.2.0-alpha.1

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.

Potentially problematic release.


This version of axios might be problematic. Click here for more details.

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