axios 0.27.2 → 0.28.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.
Files changed (50) hide show
  1. package/CHANGELOG.md +129 -58
  2. package/README.md +271 -80
  3. package/SECURITY.md +3 -3
  4. package/UPGRADE_GUIDE.md +16 -15
  5. package/bin/check-build-version.js +19 -0
  6. package/bin/ssl_hotfix.js +22 -0
  7. package/dist/axios.js +2007 -2225
  8. package/dist/axios.js.map +1 -0
  9. package/dist/axios.min.js +2 -3
  10. package/dist/axios.min.js.map +1 -0
  11. package/dist/esm/axios.js +2369 -0
  12. package/dist/esm/axios.js.map +1 -0
  13. package/dist/esm/axios.min.js +2 -0
  14. package/dist/esm/axios.min.js.map +1 -0
  15. package/index.d.ts +105 -19
  16. package/lib/adapters/http.js +153 -114
  17. package/lib/adapters/xhr.js +14 -10
  18. package/lib/axios.js +5 -1
  19. package/lib/cancel/CancelToken.js +4 -5
  20. package/lib/cancel/CanceledError.js +4 -2
  21. package/lib/core/Axios.js +13 -1
  22. package/lib/core/AxiosError.js +12 -1
  23. package/lib/core/InterceptorManager.js +9 -0
  24. package/lib/core/dispatchRequest.js +7 -0
  25. package/lib/core/mergeConfig.js +3 -0
  26. package/lib/core/transformData.js +3 -2
  27. package/lib/defaults/index.js +42 -13
  28. package/lib/env/data.js +1 -1
  29. package/lib/helpers/AxiosURLSearchParams.js +42 -0
  30. package/lib/helpers/bind.js +1 -5
  31. package/lib/helpers/buildURL.js +18 -33
  32. package/lib/helpers/formDataToJSON.js +71 -0
  33. package/lib/helpers/fromDataURI.js +51 -0
  34. package/lib/helpers/isURLSameOrigin.js +12 -12
  35. package/lib/helpers/parseHeaders.js +2 -2
  36. package/lib/helpers/toFormData.js +141 -34
  37. package/lib/helpers/toURLEncodedForm.js +18 -0
  38. package/lib/platform/browser/classes/FormData.js +3 -0
  39. package/lib/platform/browser/classes/URLSearchParams.js +5 -0
  40. package/lib/platform/browser/index.js +11 -0
  41. package/lib/platform/index.js +3 -0
  42. package/lib/platform/node/classes/FormData.js +3 -0
  43. package/lib/platform/node/classes/URLSearchParams.js +5 -0
  44. package/lib/platform/node/index.js +11 -0
  45. package/lib/utils.js +68 -16
  46. package/package.json +19 -6
  47. package/rollup.config.js +60 -0
  48. package/dist/axios.map +0 -1
  49. package/dist/axios.min.map +0 -1
  50. /package/lib/{defaults/env → env/classes}/FormData.js +0 -0
@@ -0,0 +1,2369 @@
1
+ // axios v0.28.1 Copyright (c) 2024 Matt Zabriskie
2
+ var bind = function bind(fn, thisArg) {
3
+ return function wrap() {
4
+ return fn.apply(thisArg, arguments);
5
+ };
6
+ };
7
+
8
+ // utils is a library of generic helper functions non-specific to axios
9
+
10
+ var toString = Object.prototype.toString;
11
+
12
+ // eslint-disable-next-line func-names
13
+ var kindOf = (function(cache) {
14
+ // eslint-disable-next-line func-names
15
+ return function(thing) {
16
+ var str = toString.call(thing);
17
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
18
+ };
19
+ })(Object.create(null));
20
+
21
+ function kindOfTest(type) {
22
+ type = type.toLowerCase();
23
+ return function isKindOf(thing) {
24
+ return kindOf(thing) === type;
25
+ };
26
+ }
27
+
28
+ /**
29
+ * Determine if a value is an Array
30
+ *
31
+ * @param {Object} val The value to test
32
+ * @returns {boolean} True if value is an Array, otherwise false
33
+ */
34
+ function isArray(val) {
35
+ return Array.isArray(val);
36
+ }
37
+
38
+ /**
39
+ * Determine if a value is undefined
40
+ *
41
+ * @param {Object} val The value to test
42
+ * @returns {boolean} True if the value is undefined, otherwise false
43
+ */
44
+ function isUndefined(val) {
45
+ return typeof val === 'undefined';
46
+ }
47
+
48
+ /**
49
+ * Determine if a value is a Buffer
50
+ *
51
+ * @param {Object} val The value to test
52
+ * @returns {boolean} True if value is a Buffer, otherwise false
53
+ */
54
+ function isBuffer(val) {
55
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
56
+ && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
57
+ }
58
+
59
+ /**
60
+ * Determine if a value is an ArrayBuffer
61
+ *
62
+ * @function
63
+ * @param {Object} val The value to test
64
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
65
+ */
66
+ var isArrayBuffer = kindOfTest('ArrayBuffer');
67
+
68
+
69
+ /**
70
+ * Determine if a value is a view on an ArrayBuffer
71
+ *
72
+ * @param {Object} val The value to test
73
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
74
+ */
75
+ function isArrayBufferView(val) {
76
+ var result;
77
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
78
+ result = ArrayBuffer.isView(val);
79
+ } else {
80
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
81
+ }
82
+ return result;
83
+ }
84
+
85
+ /**
86
+ * Determine if a value is a String
87
+ *
88
+ * @param {Object} val The value to test
89
+ * @returns {boolean} True if value is a String, otherwise false
90
+ */
91
+ function isString(val) {
92
+ return typeof val === 'string';
93
+ }
94
+
95
+ /**
96
+ * Determine if a value is a Number
97
+ *
98
+ * @param {Object} val The value to test
99
+ * @returns {boolean} True if value is a Number, otherwise false
100
+ */
101
+ function isNumber(val) {
102
+ return typeof val === 'number';
103
+ }
104
+
105
+ /**
106
+ * Determine if a value is an Object
107
+ *
108
+ * @param {Object} val The value to test
109
+ * @returns {boolean} True if value is an Object, otherwise false
110
+ */
111
+ function isObject(val) {
112
+ return val !== null && typeof val === 'object';
113
+ }
114
+
115
+ /**
116
+ * Determine if a value is a plain Object
117
+ *
118
+ * @param {Object} val The value to test
119
+ * @return {boolean} True if value is a plain Object, otherwise false
120
+ */
121
+ function isPlainObject(val) {
122
+ if (kindOf(val) !== 'object') {
123
+ return false;
124
+ }
125
+
126
+ var prototype = Object.getPrototypeOf(val);
127
+ return prototype === null || prototype === Object.prototype;
128
+ }
129
+
130
+ /**
131
+ * Determine if a value is a empty Object
132
+ *
133
+ * @param {Object} val The value to test
134
+ * @return {boolean} True if value is a empty Object, otherwise false
135
+ */
136
+ function isEmptyObject(val) {
137
+ return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
138
+ }
139
+
140
+ /**
141
+ * Determine if a value is a Date
142
+ *
143
+ * @function
144
+ * @param {Object} val The value to test
145
+ * @returns {boolean} True if value is a Date, otherwise false
146
+ */
147
+ var isDate = kindOfTest('Date');
148
+
149
+ /**
150
+ * Determine if a value is a File
151
+ *
152
+ * @function
153
+ * @param {Object} val The value to test
154
+ * @returns {boolean} True if value is a File, otherwise false
155
+ */
156
+ var isFile = kindOfTest('File');
157
+
158
+ /**
159
+ * Determine if a value is a Blob
160
+ *
161
+ * @function
162
+ * @param {Object} val The value to test
163
+ * @returns {boolean} True if value is a Blob, otherwise false
164
+ */
165
+ var isBlob = kindOfTest('Blob');
166
+
167
+ /**
168
+ * Determine if a value is a FileList
169
+ *
170
+ * @function
171
+ * @param {Object} val The value to test
172
+ * @returns {boolean} True if value is a File, otherwise false
173
+ */
174
+ var isFileList = kindOfTest('FileList');
175
+
176
+ /**
177
+ * Determine if a value is a Function
178
+ *
179
+ * @param {Object} val The value to test
180
+ * @returns {boolean} True if value is a Function, otherwise false
181
+ */
182
+ function isFunction(val) {
183
+ return toString.call(val) === '[object Function]';
184
+ }
185
+
186
+ /**
187
+ * Determine if a value is a Stream
188
+ *
189
+ * @param {Object} val The value to test
190
+ * @returns {boolean} True if value is a Stream, otherwise false
191
+ */
192
+ function isStream(val) {
193
+ return isObject(val) && isFunction(val.pipe);
194
+ }
195
+
196
+ /**
197
+ * Determine if a value is a FormData
198
+ *
199
+ * @param {Object} thing The value to test
200
+ * @returns {boolean} True if value is an FormData, otherwise false
201
+ */
202
+ function isFormData(thing) {
203
+ var pattern = '[object FormData]';
204
+ return thing && (
205
+ (typeof FormData === 'function' && thing instanceof FormData) ||
206
+ toString.call(thing) === pattern ||
207
+ (isFunction(thing.toString) && thing.toString() === pattern)
208
+ );
209
+ }
210
+
211
+ /**
212
+ * Determine if a value is a URLSearchParams object
213
+ * @function
214
+ * @param {Object} val The value to test
215
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
216
+ */
217
+ var isURLSearchParams = kindOfTest('URLSearchParams');
218
+
219
+ /**
220
+ * Trim excess whitespace off the beginning and end of a string
221
+ *
222
+ * @param {String} str The String to trim
223
+ * @returns {String} The String freed of excess whitespace
224
+ */
225
+ function trim(str) {
226
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
227
+ }
228
+
229
+ /**
230
+ * Determine if we're running in a standard browser environment
231
+ *
232
+ * This allows axios to run in a web worker, and react-native.
233
+ * Both environments support XMLHttpRequest, but not fully standard globals.
234
+ *
235
+ * web workers:
236
+ * typeof window -> undefined
237
+ * typeof document -> undefined
238
+ *
239
+ * react-native:
240
+ * navigator.product -> 'ReactNative'
241
+ * nativescript
242
+ * navigator.product -> 'NativeScript' or 'NS'
243
+ */
244
+ function isStandardBrowserEnv() {
245
+ var product;
246
+ if (typeof navigator !== 'undefined' && (
247
+ (product = navigator.product) === 'ReactNative' ||
248
+ product === 'NativeScript' ||
249
+ product === 'NS')
250
+ ) {
251
+ return false;
252
+ }
253
+
254
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
255
+ }
256
+
257
+ /**
258
+ * Iterate over an Array or an Object invoking a function for each item.
259
+ *
260
+ * If `obj` is an Array callback will be called passing
261
+ * the value, index, and complete array for each item.
262
+ *
263
+ * If 'obj' is an Object callback will be called passing
264
+ * the value, key, and complete object for each property.
265
+ *
266
+ * @param {Object|Array} obj The object to iterate
267
+ * @param {Function} fn The callback to invoke for each item
268
+ */
269
+ function forEach(obj, fn) {
270
+ // Don't bother if no value provided
271
+ if (obj === null || typeof obj === 'undefined') {
272
+ return;
273
+ }
274
+
275
+ // Force an array if not already something iterable
276
+ if (typeof obj !== 'object') {
277
+ /*eslint no-param-reassign:0*/
278
+ obj = [obj];
279
+ }
280
+
281
+ if (isArray(obj)) {
282
+ // Iterate over array values
283
+ for (var i = 0, l = obj.length; i < l; i++) {
284
+ fn.call(null, obj[i], i, obj);
285
+ }
286
+ } else {
287
+ // Iterate over object keys
288
+ for (var key in obj) {
289
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
290
+ fn.call(null, obj[key], key, obj);
291
+ }
292
+ }
293
+ }
294
+ }
295
+
296
+ /**
297
+ * Accepts varargs expecting each argument to be an object, then
298
+ * immutably merges the properties of each object and returns result.
299
+ *
300
+ * When multiple objects contain the same key the later object in
301
+ * the arguments list will take precedence.
302
+ *
303
+ * Example:
304
+ *
305
+ * ```js
306
+ * var result = merge({foo: 123}, {foo: 456});
307
+ * console.log(result.foo); // outputs 456
308
+ * ```
309
+ *
310
+ * @param {Object} obj1 Object to merge
311
+ * @returns {Object} Result of all merge properties
312
+ */
313
+ function merge(/* obj1, obj2, obj3, ... */) {
314
+ var result = {};
315
+ function assignValue(val, key) {
316
+ if (isPlainObject(result[key]) && isPlainObject(val)) {
317
+ result[key] = merge(result[key], val);
318
+ } else if (isPlainObject(val)) {
319
+ result[key] = merge({}, val);
320
+ } else if (isArray(val)) {
321
+ result[key] = val.slice();
322
+ } else {
323
+ result[key] = val;
324
+ }
325
+ }
326
+
327
+ for (var i = 0, l = arguments.length; i < l; i++) {
328
+ 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
+ * @return {Object} The resulting value of object a
340
+ */
341
+ function extend(a, b, thisArg) {
342
+ forEach(b, function assignValue(val, key) {
343
+ if (thisArg && typeof val === 'function') {
344
+ a[key] = bind(val, thisArg);
345
+ } else {
346
+ a[key] = val;
347
+ }
348
+ });
349
+ return a;
350
+ }
351
+
352
+ /**
353
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
354
+ *
355
+ * @param {string} content with BOM
356
+ * @return {string} content value without BOM
357
+ */
358
+ function stripBOM(content) {
359
+ if (content.charCodeAt(0) === 0xFEFF) {
360
+ content = content.slice(1);
361
+ }
362
+ return content;
363
+ }
364
+
365
+ /**
366
+ * Inherit the prototype methods from one constructor into another
367
+ * @param {function} constructor
368
+ * @param {function} superConstructor
369
+ * @param {object} [props]
370
+ * @param {object} [descriptors]
371
+ */
372
+
373
+ function inherits(constructor, superConstructor, props, descriptors) {
374
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
375
+ constructor.prototype.constructor = constructor;
376
+ props && Object.assign(constructor.prototype, props);
377
+ }
378
+
379
+ /**
380
+ * Resolve object with deep prototype chain to a flat object
381
+ * @param {Object} sourceObj source object
382
+ * @param {Object} [destObj]
383
+ * @param {Function|Boolean} [filter]
384
+ * @param {Function} [propFilter]
385
+ * @returns {Object}
386
+ */
387
+
388
+ function toFlatObject(sourceObj, destObj, filter, propFilter) {
389
+ var props;
390
+ var i;
391
+ var prop;
392
+ var merged = {};
393
+
394
+ destObj = destObj || {};
395
+ // eslint-disable-next-line no-eq-null,eqeqeq
396
+ if (sourceObj == null) return destObj;
397
+
398
+ do {
399
+ props = Object.getOwnPropertyNames(sourceObj);
400
+ i = props.length;
401
+ while (i-- > 0) {
402
+ prop = props[i];
403
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
404
+ destObj[prop] = sourceObj[prop];
405
+ merged[prop] = true;
406
+ }
407
+ }
408
+ sourceObj = filter !== false && Object.getPrototypeOf(sourceObj);
409
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
410
+
411
+ return destObj;
412
+ }
413
+
414
+ /*
415
+ * determines whether a string ends with the characters of a specified string
416
+ * @param {String} str
417
+ * @param {String} searchString
418
+ * @param {Number} [position= 0]
419
+ * @returns {boolean}
420
+ */
421
+ function endsWith(str, searchString, position) {
422
+ str = String(str);
423
+ if (position === undefined || position > str.length) {
424
+ position = str.length;
425
+ }
426
+ position -= searchString.length;
427
+ var lastIndex = str.indexOf(searchString, position);
428
+ return lastIndex !== -1 && lastIndex === position;
429
+ }
430
+
431
+
432
+ /**
433
+ * Returns new array from array like object or null if failed
434
+ * @param {*} [thing]
435
+ * @returns {?Array}
436
+ */
437
+ function toArray(thing) {
438
+ if (!thing) return null;
439
+ if (isArray(thing)) return thing;
440
+ var i = thing.length;
441
+ if (!isNumber(i)) return null;
442
+ var arr = new Array(i);
443
+ while (i-- > 0) {
444
+ arr[i] = thing[i];
445
+ }
446
+ return arr;
447
+ }
448
+
449
+ // eslint-disable-next-line func-names
450
+ var isTypedArray = (function(TypedArray) {
451
+ // eslint-disable-next-line func-names
452
+ return function(thing) {
453
+ return TypedArray && thing instanceof TypedArray;
454
+ };
455
+ })(typeof Uint8Array !== 'undefined' && Object.getPrototypeOf(Uint8Array));
456
+
457
+ function forEachEntry(obj, fn) {
458
+ var generator = obj && obj[Symbol.iterator];
459
+
460
+ var iterator = generator.call(obj);
461
+
462
+ var result;
463
+
464
+ while ((result = iterator.next()) && !result.done) {
465
+ var pair = result.value;
466
+ fn.call(obj, pair[0], pair[1]);
467
+ }
468
+ }
469
+
470
+ function matchAll(regExp, str) {
471
+ var matches;
472
+ var arr = [];
473
+
474
+ while ((matches = regExp.exec(str)) !== null) {
475
+ arr.push(matches);
476
+ }
477
+
478
+ return arr;
479
+ }
480
+
481
+ var isHTMLForm = kindOfTest('HTMLFormElement');
482
+
483
+ var hasOwnProperty = (function resolver(_hasOwnProperty) {
484
+ return function(obj, prop) {
485
+ return _hasOwnProperty.call(obj, prop);
486
+ };
487
+ })(Object.prototype.hasOwnProperty);
488
+
489
+ var utils = {
490
+ isArray: isArray,
491
+ isArrayBuffer: isArrayBuffer,
492
+ isBuffer: isBuffer,
493
+ isFormData: isFormData,
494
+ isArrayBufferView: isArrayBufferView,
495
+ isString: isString,
496
+ isNumber: isNumber,
497
+ isObject: isObject,
498
+ isPlainObject: isPlainObject,
499
+ isEmptyObject: isEmptyObject,
500
+ isUndefined: isUndefined,
501
+ isDate: isDate,
502
+ isFile: isFile,
503
+ isBlob: isBlob,
504
+ isFunction: isFunction,
505
+ isStream: isStream,
506
+ isURLSearchParams: isURLSearchParams,
507
+ isStandardBrowserEnv: isStandardBrowserEnv,
508
+ forEach: forEach,
509
+ merge: merge,
510
+ extend: extend,
511
+ trim: trim,
512
+ stripBOM: stripBOM,
513
+ inherits: inherits,
514
+ toFlatObject: toFlatObject,
515
+ kindOf: kindOf,
516
+ kindOfTest: kindOfTest,
517
+ endsWith: endsWith,
518
+ toArray: toArray,
519
+ isTypedArray: isTypedArray,
520
+ isFileList: isFileList,
521
+ forEachEntry: forEachEntry,
522
+ matchAll: matchAll,
523
+ isHTMLForm: isHTMLForm,
524
+ hasOwnProperty: hasOwnProperty
525
+ };
526
+
527
+ /**
528
+ * Create an Error with the specified message, config, error code, request and response.
529
+ *
530
+ * @param {string} message The error message.
531
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
532
+ * @param {Object} [config] The config.
533
+ * @param {Object} [request] The request.
534
+ * @param {Object} [response] The response.
535
+ * @returns {Error} The created error.
536
+ */
537
+ function AxiosError(message, code, config, request, response) {
538
+ Error.call(this);
539
+
540
+ if (Error.captureStackTrace) {
541
+ Error.captureStackTrace(this, this.constructor);
542
+ } else {
543
+ this.stack = (new Error()).stack;
544
+ }
545
+
546
+ this.message = message;
547
+ this.name = 'AxiosError';
548
+ code && (this.code = code);
549
+ config && (this.config = config);
550
+ request && (this.request = request);
551
+ response && (this.response = response);
552
+ }
553
+
554
+ utils.inherits(AxiosError, Error, {
555
+ toJSON: function toJSON() {
556
+ return {
557
+ // Standard
558
+ message: this.message,
559
+ name: this.name,
560
+ // Microsoft
561
+ description: this.description,
562
+ number: this.number,
563
+ // Mozilla
564
+ fileName: this.fileName,
565
+ lineNumber: this.lineNumber,
566
+ columnNumber: this.columnNumber,
567
+ stack: this.stack,
568
+ // Axios
569
+ config: this.config,
570
+ code: this.code,
571
+ status: this.response && this.response.status ? this.response.status : null
572
+ };
573
+ }
574
+ });
575
+
576
+ var prototype$1 = AxiosError.prototype;
577
+ var descriptors = {};
578
+
579
+ [
580
+ 'ERR_BAD_OPTION_VALUE',
581
+ 'ERR_BAD_OPTION',
582
+ 'ECONNABORTED',
583
+ 'ETIMEDOUT',
584
+ 'ERR_NETWORK',
585
+ 'ERR_FR_TOO_MANY_REDIRECTS',
586
+ 'ERR_DEPRECATED',
587
+ 'ERR_BAD_RESPONSE',
588
+ 'ERR_BAD_REQUEST',
589
+ 'ERR_CANCELED',
590
+ 'ERR_NOT_SUPPORT',
591
+ 'ERR_INVALID_URL'
592
+ // eslint-disable-next-line func-names
593
+ ].forEach(function(code) {
594
+ descriptors[code] = {value: code};
595
+ });
596
+
597
+ Object.defineProperties(AxiosError, descriptors);
598
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
599
+
600
+ // eslint-disable-next-line func-names
601
+ AxiosError.from = function(error, code, config, request, response, customProps) {
602
+ var axiosError = Object.create(prototype$1);
603
+
604
+ utils.toFlatObject(error, axiosError, function filter(obj) {
605
+ return obj !== Error.prototype;
606
+ });
607
+
608
+ AxiosError.call(axiosError, error.message, code, config, request, response);
609
+
610
+ axiosError.cause = error;
611
+
612
+ axiosError.name = error.name;
613
+
614
+ customProps && Object.assign(axiosError, customProps);
615
+
616
+ return axiosError;
617
+ };
618
+
619
+ var AxiosError_1 = AxiosError;
620
+
621
+ /* eslint-env browser */
622
+ var browser$1 = typeof self == 'object' ? self.FormData : window.FormData;
623
+
624
+ // eslint-disable-next-line strict
625
+ var FormData$1 = browser$1;
626
+
627
+ function isVisitable(thing) {
628
+ return utils.isPlainObject(thing) || utils.isArray(thing);
629
+ }
630
+
631
+ function removeBrackets(key) {
632
+ return utils.endsWith(key, '[]') ? key.slice(0, -2) : key;
633
+ }
634
+
635
+ function renderKey(path, key, dots) {
636
+ if (!path) return key;
637
+ return path.concat(key).map(function each(token, i) {
638
+ // eslint-disable-next-line no-param-reassign
639
+ token = removeBrackets(token);
640
+ return !dots && i ? '[' + token + ']' : token;
641
+ }).join(dots ? '.' : '');
642
+ }
643
+
644
+ function isFlatArray(arr) {
645
+ return utils.isArray(arr) && !arr.some(isVisitable);
646
+ }
647
+
648
+ var predicates = utils.toFlatObject(utils, {}, null, function filter(prop) {
649
+ return /^is[A-Z]/.test(prop);
650
+ });
651
+
652
+ function isSpecCompliant(thing) {
653
+ return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator];
654
+ }
655
+
656
+ /**
657
+ * Convert a data object to FormData
658
+ * @param {Object} obj
659
+ * @param {?Object} [formData]
660
+ * @param {?Object} [options]
661
+ * @param {Function} [options.visitor]
662
+ * @param {Boolean} [options.metaTokens = true]
663
+ * @param {Boolean} [options.dots = false]
664
+ * @param {?Boolean} [options.indexes = false]
665
+ * @returns {Object}
666
+ **/
667
+
668
+ function toFormData(obj, formData, options) {
669
+ if (!utils.isObject(obj)) {
670
+ throw new TypeError('target must be an object');
671
+ }
672
+
673
+ // eslint-disable-next-line no-param-reassign
674
+ formData = formData || new (FormData$1 || FormData)();
675
+
676
+ // eslint-disable-next-line no-param-reassign
677
+ options = utils.toFlatObject(options, {
678
+ metaTokens: true,
679
+ dots: false,
680
+ indexes: false
681
+ }, false, function defined(option, source) {
682
+ // eslint-disable-next-line no-eq-null,eqeqeq
683
+ return !utils.isUndefined(source[option]);
684
+ });
685
+
686
+ var metaTokens = options.metaTokens;
687
+ // eslint-disable-next-line no-use-before-define
688
+ var visitor = options.visitor || defaultVisitor;
689
+ var dots = options.dots;
690
+ var indexes = options.indexes;
691
+ var _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
692
+ var useBlob = _Blob && isSpecCompliant(formData);
693
+
694
+ if (!utils.isFunction(visitor)) {
695
+ throw new TypeError('visitor must be a function');
696
+ }
697
+
698
+ function convertValue(value) {
699
+ if (value === null) return '';
700
+
701
+ if (utils.isDate(value)) {
702
+ return value.toISOString();
703
+ }
704
+
705
+ if (!useBlob && utils.isBlob(value)) {
706
+ throw new AxiosError_1('Blob is not supported. Use a Buffer instead.');
707
+ }
708
+
709
+ if (utils.isArrayBuffer(value) || utils.isTypedArray(value)) {
710
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
711
+ }
712
+
713
+ return value;
714
+ }
715
+
716
+ /**
717
+ *
718
+ * @param {*} value
719
+ * @param {String|Number} key
720
+ * @param {Array<String|Number>} path
721
+ * @this {FormData}
722
+ * @returns {boolean} return true to visit the each prop of the value recursively
723
+ */
724
+ function defaultVisitor(value, key, path) {
725
+ var arr = value;
726
+
727
+ if (value && !path && typeof value === 'object') {
728
+ if (utils.endsWith(key, '{}')) {
729
+ // eslint-disable-next-line no-param-reassign
730
+ key = metaTokens ? key : key.slice(0, -2);
731
+ // eslint-disable-next-line no-param-reassign
732
+ value = JSON.stringify(value);
733
+ } else if (
734
+ (utils.isArray(value) && isFlatArray(value)) ||
735
+ (utils.isFileList(value) || utils.endsWith(key, '[]') && (arr = utils.toArray(value))
736
+ )) {
737
+ // eslint-disable-next-line no-param-reassign
738
+ key = removeBrackets(key);
739
+
740
+ arr.forEach(function each(el, index) {
741
+ !utils.isUndefined(el) && formData.append(
742
+ // eslint-disable-next-line no-nested-ternary
743
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
744
+ convertValue(el)
745
+ );
746
+ });
747
+ return false;
748
+ }
749
+ }
750
+
751
+ if (isVisitable(value)) {
752
+ return true;
753
+ }
754
+
755
+ formData.append(renderKey(path, key, dots), convertValue(value));
756
+
757
+ return false;
758
+ }
759
+
760
+ var stack = [];
761
+
762
+ var exposedHelpers = Object.assign(predicates, {
763
+ defaultVisitor: defaultVisitor,
764
+ convertValue: convertValue,
765
+ isVisitable: isVisitable
766
+ });
767
+
768
+ function build(value, path) {
769
+ if (utils.isUndefined(value)) return;
770
+
771
+ if (stack.indexOf(value) !== -1) {
772
+ throw Error('Circular reference detected in ' + path.join('.'));
773
+ }
774
+
775
+ stack.push(value);
776
+
777
+ utils.forEach(value, function each(el, key) {
778
+ var result = !utils.isUndefined(el) && visitor.call(
779
+ formData, el, utils.isString(key) ? key.trim() : key, path, exposedHelpers
780
+ );
781
+
782
+ if (result === true) {
783
+ build(el, path ? path.concat(key) : [key]);
784
+ }
785
+ });
786
+
787
+ stack.pop();
788
+ }
789
+
790
+ if (!utils.isObject(obj)) {
791
+ throw new TypeError('data must be an object');
792
+ }
793
+
794
+ build(obj);
795
+
796
+ return formData;
797
+ }
798
+
799
+ var toFormData_1 = toFormData;
800
+
801
+ function encode$1(str) {
802
+ var charMap = {
803
+ '!': '%21',
804
+ "'": '%27',
805
+ '(': '%28',
806
+ ')': '%29',
807
+ '~': '%7E',
808
+ '%20': '+',
809
+ '%00': '\x00'
810
+ };
811
+ return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function replacer(match) {
812
+ return charMap[match];
813
+ });
814
+ }
815
+
816
+ function AxiosURLSearchParams(params, options) {
817
+ this._pairs = [];
818
+
819
+ params && toFormData_1(params, this, options);
820
+ }
821
+
822
+ var prototype = AxiosURLSearchParams.prototype;
823
+
824
+ prototype.append = function append(name, value) {
825
+ this._pairs.push([name, value]);
826
+ };
827
+
828
+ prototype.toString = function toString(encoder) {
829
+ var _encode = encoder ? function(value) {
830
+ return encoder.call(this, value, encode$1);
831
+ } : encode$1;
832
+
833
+ return this._pairs.map(function each(pair) {
834
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
835
+ }, '').join('&');
836
+ };
837
+
838
+ var AxiosURLSearchParams_1 = AxiosURLSearchParams;
839
+
840
+ function encode(val) {
841
+ return encodeURIComponent(val).
842
+ replace(/%3A/gi, ':').
843
+ replace(/%24/g, '$').
844
+ replace(/%2C/gi, ',').
845
+ replace(/%20/g, '+').
846
+ replace(/%5B/gi, '[').
847
+ replace(/%5D/gi, ']');
848
+ }
849
+
850
+ /**
851
+ * Build a URL by appending params to the end
852
+ *
853
+ * @param {string} url The base of the url (e.g., http://www.google.com)
854
+ * @param {object} [params] The params to be appended
855
+ * @param {?object} options
856
+ * @returns {string} The formatted url
857
+ */
858
+ var buildURL = function buildURL(url, params, options) {
859
+ /*eslint no-param-reassign:0*/
860
+ if (!params) {
861
+ return url;
862
+ }
863
+
864
+ var hashmarkIndex = url.indexOf('#');
865
+
866
+ if (hashmarkIndex !== -1) {
867
+ url = url.slice(0, hashmarkIndex);
868
+ }
869
+
870
+ var _encode = options && options.encode || encode;
871
+
872
+ var serializeFn = options && options.serialize;
873
+
874
+ var serializedParams;
875
+
876
+ if (serializeFn) {
877
+ serializedParams = serializeFn(params, options);
878
+ } else {
879
+ serializedParams = utils.isURLSearchParams(params) ?
880
+ params.toString() :
881
+ new AxiosURLSearchParams_1(params, options).toString(_encode);
882
+ }
883
+
884
+ if (serializedParams) {
885
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
886
+ }
887
+
888
+ return url;
889
+ };
890
+
891
+ function InterceptorManager() {
892
+ this.handlers = [];
893
+ }
894
+
895
+ /**
896
+ * Add a new interceptor to the stack
897
+ *
898
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
899
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
900
+ *
901
+ * @return {Number} An ID used to remove interceptor later
902
+ */
903
+ InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
904
+ this.handlers.push({
905
+ fulfilled: fulfilled,
906
+ rejected: rejected,
907
+ synchronous: options ? options.synchronous : false,
908
+ runWhen: options ? options.runWhen : null
909
+ });
910
+ return this.handlers.length - 1;
911
+ };
912
+
913
+ /**
914
+ * Remove an interceptor from the stack
915
+ *
916
+ * @param {Number} id The ID that was returned by `use`
917
+ */
918
+ InterceptorManager.prototype.eject = function eject(id) {
919
+ if (this.handlers[id]) {
920
+ this.handlers[id] = null;
921
+ }
922
+ };
923
+
924
+ /**
925
+ * Clear all interceptors from the stack
926
+ */
927
+ InterceptorManager.prototype.clear = function clear() {
928
+ if (this.handlers) {
929
+ this.handlers = [];
930
+ }
931
+ };
932
+
933
+ /**
934
+ * Iterate over all the registered interceptors
935
+ *
936
+ * This method is particularly useful for skipping over any
937
+ * interceptors that may have become `null` calling `eject`.
938
+ *
939
+ * @param {Function} fn The function to call for each interceptor
940
+ */
941
+ InterceptorManager.prototype.forEach = function forEach(fn) {
942
+ utils.forEach(this.handlers, function forEachHandler(h) {
943
+ if (h !== null) {
944
+ fn(h);
945
+ }
946
+ });
947
+ };
948
+
949
+ var InterceptorManager_1 = InterceptorManager;
950
+
951
+ var normalizeHeaderName = function normalizeHeaderName(headers, normalizedName) {
952
+ utils.forEach(headers, function processHeader(value, name) {
953
+ if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
954
+ headers[normalizedName] = value;
955
+ delete headers[name];
956
+ }
957
+ });
958
+ };
959
+
960
+ var transitional = {
961
+ silentJSONParsing: true,
962
+ forcedJSONParsing: true,
963
+ clarifyTimeoutError: false
964
+ };
965
+
966
+ var URLSearchParams_1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams_1;
967
+
968
+ var FormData_1 = FormData;
969
+
970
+ var browser = {
971
+ isBrowser: true,
972
+ classes: {
973
+ URLSearchParams: URLSearchParams_1,
974
+ FormData: FormData_1,
975
+ Blob: Blob
976
+ },
977
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
978
+ };
979
+
980
+ var platform = browser;
981
+
982
+ var toURLEncodedForm = function toURLEncodedForm(data, options) {
983
+ return toFormData_1(data, new platform.classes.URLSearchParams(), Object.assign({
984
+ visitor: function(value, key, path, helpers) {
985
+ if (platform.isNode && utils.isBuffer(value)) {
986
+ this.append(key, value.toString('base64'));
987
+ return false;
988
+ }
989
+
990
+ return helpers.defaultVisitor.apply(this, arguments);
991
+ }
992
+ }, options));
993
+ };
994
+
995
+ function parsePropPath(name) {
996
+ // foo[x][y][z]
997
+ // foo.x.y.z
998
+ // foo-x-y-z
999
+ // foo x y z
1000
+ return utils.matchAll(/\w+|\[(\w*)]/g, name).map(function(match) {
1001
+ return match[0] === '[]' ? '' : match[1] || match[0];
1002
+ });
1003
+ }
1004
+
1005
+ function arrayToObject(arr) {
1006
+ var obj = {};
1007
+ var keys = Object.keys(arr);
1008
+ var i;
1009
+ var len = keys.length;
1010
+ var key;
1011
+ for (i = 0; i < len; i++) {
1012
+ key = keys[i];
1013
+ obj[key] = arr[key];
1014
+ }
1015
+ return obj;
1016
+ }
1017
+
1018
+ function formDataToJSON(formData) {
1019
+ function buildPath(path, value, target, index) {
1020
+ var name = path[index++];
1021
+ var isNumericKey = Number.isFinite(+name);
1022
+ var isLast = index >= path.length;
1023
+ name = !name && utils.isArray(target) ? target.length : name;
1024
+
1025
+ if (isLast) {
1026
+ if (utils.hasOwnProperty(target, name)) {
1027
+ target[name] = [target[name], value];
1028
+ } else {
1029
+ target[name] = value;
1030
+ }
1031
+
1032
+ return !isNumericKey;
1033
+ }
1034
+
1035
+ if (!target[name] || !utils.isObject(target[name])) {
1036
+ target[name] = [];
1037
+ }
1038
+
1039
+ var result = buildPath(path, value, target[name], index);
1040
+
1041
+ if (result && utils.isArray(target[name])) {
1042
+ target[name] = arrayToObject(target[name]);
1043
+ }
1044
+
1045
+ return !isNumericKey;
1046
+ }
1047
+
1048
+ if (utils.isFormData(formData) && utils.isFunction(formData.entries)) {
1049
+ var obj = {};
1050
+
1051
+ utils.forEachEntry(formData, function(name, value) {
1052
+ buildPath(parsePropPath(name), value, obj, 0);
1053
+ });
1054
+
1055
+ return obj;
1056
+ }
1057
+
1058
+ return null;
1059
+ }
1060
+
1061
+ var formDataToJSON_1 = formDataToJSON;
1062
+
1063
+ /**
1064
+ * Resolve or reject a Promise based on response status.
1065
+ *
1066
+ * @param {Function} resolve A function that resolves the promise.
1067
+ * @param {Function} reject A function that rejects the promise.
1068
+ * @param {object} response The response.
1069
+ */
1070
+ var settle = function settle(resolve, reject, response) {
1071
+ var validateStatus = response.config.validateStatus;
1072
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1073
+ resolve(response);
1074
+ } else {
1075
+ reject(new AxiosError_1(
1076
+ 'Request failed with status code ' + response.status,
1077
+ [AxiosError_1.ERR_BAD_REQUEST, AxiosError_1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1078
+ response.config,
1079
+ response.request,
1080
+ response
1081
+ ));
1082
+ }
1083
+ };
1084
+
1085
+ var cookies = (
1086
+ utils.isStandardBrowserEnv() ?
1087
+
1088
+ // Standard browser envs support document.cookie
1089
+ (function standardBrowserEnv() {
1090
+ return {
1091
+ write: function write(name, value, expires, path, domain, secure) {
1092
+ var cookie = [];
1093
+ cookie.push(name + '=' + encodeURIComponent(value));
1094
+
1095
+ if (utils.isNumber(expires)) {
1096
+ cookie.push('expires=' + new Date(expires).toGMTString());
1097
+ }
1098
+
1099
+ if (utils.isString(path)) {
1100
+ cookie.push('path=' + path);
1101
+ }
1102
+
1103
+ if (utils.isString(domain)) {
1104
+ cookie.push('domain=' + domain);
1105
+ }
1106
+
1107
+ if (secure === true) {
1108
+ cookie.push('secure');
1109
+ }
1110
+
1111
+ document.cookie = cookie.join('; ');
1112
+ },
1113
+
1114
+ read: function read(name) {
1115
+ var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
1116
+ return (match ? decodeURIComponent(match[3]) : null);
1117
+ },
1118
+
1119
+ remove: function remove(name) {
1120
+ this.write(name, '', Date.now() - 86400000);
1121
+ }
1122
+ };
1123
+ })() :
1124
+
1125
+ // Non standard browser env (web workers, react-native) lack needed support.
1126
+ (function nonStandardBrowserEnv() {
1127
+ return {
1128
+ write: function write() {},
1129
+ read: function read() { return null; },
1130
+ remove: function remove() {}
1131
+ };
1132
+ })()
1133
+ );
1134
+
1135
+ /**
1136
+ * Determines whether the specified URL is absolute
1137
+ *
1138
+ * @param {string} url The URL to test
1139
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1140
+ */
1141
+ var isAbsoluteURL = function isAbsoluteURL(url) {
1142
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1143
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1144
+ // by any combination of letters, digits, plus, period, or hyphen.
1145
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1146
+ };
1147
+
1148
+ /**
1149
+ * Creates a new URL by combining the specified URLs
1150
+ *
1151
+ * @param {string} baseURL The base URL
1152
+ * @param {string} relativeURL The relative URL
1153
+ * @returns {string} The combined URL
1154
+ */
1155
+ var combineURLs = function combineURLs(baseURL, relativeURL) {
1156
+ return relativeURL
1157
+ ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
1158
+ : baseURL;
1159
+ };
1160
+
1161
+ /**
1162
+ * Creates a new URL by combining the baseURL with the requestedURL,
1163
+ * only when the requestedURL is not already an absolute URL.
1164
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1165
+ *
1166
+ * @param {string} baseURL The base URL
1167
+ * @param {string} requestedURL Absolute or relative URL to combine
1168
+ * @returns {string} The combined full path
1169
+ */
1170
+ var buildFullPath = function buildFullPath(baseURL, requestedURL) {
1171
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1172
+ return combineURLs(baseURL, requestedURL);
1173
+ }
1174
+ return requestedURL;
1175
+ };
1176
+
1177
+ // Headers whose duplicates are ignored by node
1178
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1179
+ var ignoreDuplicateOf = [
1180
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1181
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1182
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1183
+ 'referer', 'retry-after', 'user-agent'
1184
+ ];
1185
+
1186
+ /**
1187
+ * Parse headers into an object
1188
+ *
1189
+ * ```
1190
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1191
+ * Content-Type: application/json
1192
+ * Connection: keep-alive
1193
+ * Transfer-Encoding: chunked
1194
+ * ```
1195
+ *
1196
+ * @param {String} headers Headers needing to be parsed
1197
+ * @returns {Object} Headers parsed into an object
1198
+ */
1199
+ var parseHeaders = function parseHeaders(headers) {
1200
+ var parsed = {};
1201
+ var key;
1202
+ var val;
1203
+ var i;
1204
+
1205
+ if (!headers) { return parsed; }
1206
+
1207
+ utils.forEach(headers.split('\n'), function parser(line) {
1208
+ i = line.indexOf(':');
1209
+ key = utils.trim(line.slice(0, i)).toLowerCase();
1210
+ val = utils.trim(line.slice(i + 1));
1211
+
1212
+ if (key) {
1213
+ if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
1214
+ return;
1215
+ }
1216
+ if (key === 'set-cookie') {
1217
+ parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
1218
+ } else {
1219
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1220
+ }
1221
+ }
1222
+ });
1223
+
1224
+ return parsed;
1225
+ };
1226
+
1227
+ var isURLSameOrigin = (
1228
+ utils.isStandardBrowserEnv() ?
1229
+
1230
+ // Standard browser envs have full support of the APIs needed to test
1231
+ // whether the request URL is of the same origin as current location.
1232
+ (function standardBrowserEnv() {
1233
+ var msie = /(msie|trident)/i.test(navigator.userAgent);
1234
+ var urlParsingNode = document.createElement('a');
1235
+ var originURL;
1236
+
1237
+ /**
1238
+ * Parse a URL to discover it's components
1239
+ *
1240
+ * @param {String} url The URL to be parsed
1241
+ * @returns {Object}
1242
+ */
1243
+ function resolveURL(url) {
1244
+ var href = url;
1245
+
1246
+ if (msie) {
1247
+ // IE needs attribute set twice to normalize properties
1248
+ urlParsingNode.setAttribute('href', href);
1249
+ href = urlParsingNode.href;
1250
+ }
1251
+
1252
+ urlParsingNode.setAttribute('href', href);
1253
+
1254
+ // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
1255
+ return {
1256
+ href: urlParsingNode.href,
1257
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
1258
+ host: urlParsingNode.host,
1259
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
1260
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
1261
+ hostname: urlParsingNode.hostname,
1262
+ port: urlParsingNode.port,
1263
+ pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
1264
+ urlParsingNode.pathname :
1265
+ '/' + urlParsingNode.pathname
1266
+ };
1267
+ }
1268
+
1269
+ originURL = resolveURL(window.location.href);
1270
+
1271
+ /**
1272
+ * Determine if a URL shares the same origin as the current location
1273
+ *
1274
+ * @param {String} requestURL The URL to test
1275
+ * @returns {boolean} True if URL shares the same origin, otherwise false
1276
+ */
1277
+ return function isURLSameOrigin(requestURL) {
1278
+ var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
1279
+ return (parsed.protocol === originURL.protocol &&
1280
+ parsed.host === originURL.host);
1281
+ };
1282
+ })() :
1283
+
1284
+ // Non standard browser envs (web workers, react-native) lack needed support.
1285
+ (function nonStandardBrowserEnv() {
1286
+ return function isURLSameOrigin() {
1287
+ return true;
1288
+ };
1289
+ })()
1290
+ );
1291
+
1292
+ /**
1293
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1294
+ *
1295
+ * @class
1296
+ * @param {string=} message The message.
1297
+ * @param {Object=} config The config.
1298
+ * @param {Object=} request The request.
1299
+ */
1300
+ function CanceledError(message, config, request) {
1301
+ // eslint-disable-next-line no-eq-null,eqeqeq
1302
+ AxiosError_1.call(this, message == null ? 'canceled' : message, AxiosError_1.ERR_CANCELED, config, request);
1303
+ this.name = 'CanceledError';
1304
+ }
1305
+
1306
+ utils.inherits(CanceledError, AxiosError_1, {
1307
+ __CANCEL__: true
1308
+ });
1309
+
1310
+ var CanceledError_1 = CanceledError;
1311
+
1312
+ var parseProtocol = function parseProtocol(url) {
1313
+ var match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1314
+ return match && match[1] || '';
1315
+ };
1316
+
1317
+ var xhr = function xhrAdapter(config) {
1318
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
1319
+ var requestData = config.data;
1320
+ var requestHeaders = config.headers;
1321
+ var responseType = config.responseType;
1322
+ var withXSRFToken = config.withXSRFToken;
1323
+ var onCanceled;
1324
+ function done() {
1325
+ if (config.cancelToken) {
1326
+ config.cancelToken.unsubscribe(onCanceled);
1327
+ }
1328
+
1329
+ if (config.signal) {
1330
+ config.signal.removeEventListener('abort', onCanceled);
1331
+ }
1332
+ }
1333
+
1334
+ if (utils.isFormData(requestData) && utils.isStandardBrowserEnv()) {
1335
+ delete requestHeaders['Content-Type']; // Let the browser set it
1336
+ }
1337
+
1338
+ var request = new XMLHttpRequest();
1339
+
1340
+ // HTTP basic authentication
1341
+ if (config.auth) {
1342
+ var username = config.auth.username || '';
1343
+ var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
1344
+ requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
1345
+ }
1346
+
1347
+ var fullPath = buildFullPath(config.baseURL, config.url);
1348
+
1349
+ request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
1350
+
1351
+ // Set the request timeout in MS
1352
+ request.timeout = config.timeout;
1353
+
1354
+ function onloadend() {
1355
+ if (!request) {
1356
+ return;
1357
+ }
1358
+ // Prepare the response
1359
+ var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
1360
+ var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
1361
+ request.responseText : request.response;
1362
+ var response = {
1363
+ data: responseData,
1364
+ status: request.status,
1365
+ statusText: request.statusText,
1366
+ headers: responseHeaders,
1367
+ config: config,
1368
+ request: request
1369
+ };
1370
+
1371
+ settle(function _resolve(value) {
1372
+ resolve(value);
1373
+ done();
1374
+ }, function _reject(err) {
1375
+ reject(err);
1376
+ done();
1377
+ }, response);
1378
+
1379
+ // Clean up request
1380
+ request = null;
1381
+ }
1382
+
1383
+ if ('onloadend' in request) {
1384
+ // Use onloadend if available
1385
+ request.onloadend = onloadend;
1386
+ } else {
1387
+ // Listen for ready state to emulate onloadend
1388
+ request.onreadystatechange = function handleLoad() {
1389
+ if (!request || request.readyState !== 4) {
1390
+ return;
1391
+ }
1392
+
1393
+ // The request errored out and we didn't get a response, this will be
1394
+ // handled by onerror instead
1395
+ // With one exception: request that using file: protocol, most browsers
1396
+ // will return status as 0 even though it's a successful request
1397
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
1398
+ return;
1399
+ }
1400
+ // readystate handler is calling before onerror or ontimeout handlers,
1401
+ // so we should call onloadend on the next 'tick'
1402
+ setTimeout(onloadend);
1403
+ };
1404
+ }
1405
+
1406
+ // Handle browser request cancellation (as opposed to a manual cancellation)
1407
+ request.onabort = function handleAbort() {
1408
+ if (!request) {
1409
+ return;
1410
+ }
1411
+
1412
+ reject(new AxiosError_1('Request aborted', AxiosError_1.ECONNABORTED, config, request));
1413
+
1414
+ // Clean up request
1415
+ request = null;
1416
+ };
1417
+
1418
+ // Handle low level network errors
1419
+ request.onerror = function handleError() {
1420
+ // Real errors are hidden from us by the browser
1421
+ // onerror should only fire if it's a network error
1422
+ reject(new AxiosError_1('Network Error', AxiosError_1.ERR_NETWORK, config, request));
1423
+
1424
+ // Clean up request
1425
+ request = null;
1426
+ };
1427
+
1428
+ // Handle timeout
1429
+ request.ontimeout = function handleTimeout() {
1430
+ var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
1431
+ var transitional$1 = config.transitional || transitional;
1432
+ if (config.timeoutErrorMessage) {
1433
+ timeoutErrorMessage = config.timeoutErrorMessage;
1434
+ }
1435
+ reject(new AxiosError_1(
1436
+ timeoutErrorMessage,
1437
+ transitional$1.clarifyTimeoutError ? AxiosError_1.ETIMEDOUT : AxiosError_1.ECONNABORTED,
1438
+ config,
1439
+ request));
1440
+
1441
+ // Clean up request
1442
+ request = null;
1443
+ };
1444
+
1445
+ // Add xsrf header
1446
+ // This is only done if running in a standard browser environment.
1447
+ // Specifically not if we're in a web worker, or react-native.
1448
+ if (utils.isStandardBrowserEnv()) {
1449
+ // Add xsrf header
1450
+ withXSRFToken && utils.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(config));
1451
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(fullPath))) {
1452
+ // Add xsrf header
1453
+ var xsrfValue = config.xsrfHeaderName && config.xsrfCookieName && cookies.read(config.xsrfCookieName);
1454
+ if (xsrfValue) {
1455
+ requestHeaders[config.xsrfHeaderName] = xsrfValue;
1456
+ }
1457
+ }
1458
+ }
1459
+
1460
+ // Add headers to the request
1461
+ if ('setRequestHeader' in request) {
1462
+ utils.forEach(requestHeaders, function setRequestHeader(val, key) {
1463
+ if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
1464
+ // Remove Content-Type if data is undefined
1465
+ delete requestHeaders[key];
1466
+ } else {
1467
+ // Otherwise add header to the request
1468
+ request.setRequestHeader(key, val);
1469
+ }
1470
+ });
1471
+ }
1472
+
1473
+ // Add withCredentials to request if needed
1474
+ if (!utils.isUndefined(config.withCredentials)) {
1475
+ request.withCredentials = !!config.withCredentials;
1476
+ }
1477
+
1478
+ // Add responseType to request if needed
1479
+ if (responseType && responseType !== 'json') {
1480
+ request.responseType = config.responseType;
1481
+ }
1482
+
1483
+ // Handle progress if needed
1484
+ if (typeof config.onDownloadProgress === 'function') {
1485
+ request.addEventListener('progress', config.onDownloadProgress);
1486
+ }
1487
+
1488
+ // Not all browsers support upload events
1489
+ if (typeof config.onUploadProgress === 'function' && request.upload) {
1490
+ request.upload.addEventListener('progress', config.onUploadProgress);
1491
+ }
1492
+
1493
+ if (config.cancelToken || config.signal) {
1494
+ // Handle cancellation
1495
+ // eslint-disable-next-line func-names
1496
+ onCanceled = function(cancel) {
1497
+ if (!request) {
1498
+ return;
1499
+ }
1500
+ reject(!cancel || cancel.type ? new CanceledError_1(null, config, request) : cancel);
1501
+ request.abort();
1502
+ request = null;
1503
+ };
1504
+
1505
+ config.cancelToken && config.cancelToken.subscribe(onCanceled);
1506
+ if (config.signal) {
1507
+ config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
1508
+ }
1509
+ }
1510
+
1511
+ // false, 0 (zero number), and '' (empty string) are valid JSON values
1512
+ if (!requestData && requestData !== false && requestData !== 0 && requestData !== '') {
1513
+ requestData = null;
1514
+ }
1515
+
1516
+ var protocol = parseProtocol(fullPath);
1517
+
1518
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
1519
+ reject(new AxiosError_1('Unsupported protocol ' + protocol + ':', AxiosError_1.ERR_BAD_REQUEST, config));
1520
+ return;
1521
+ }
1522
+
1523
+
1524
+ // Send the request
1525
+ request.send(requestData);
1526
+ });
1527
+ };
1528
+
1529
+ var DEFAULT_CONTENT_TYPE = {
1530
+ 'Content-Type': 'application/x-www-form-urlencoded'
1531
+ };
1532
+
1533
+ function setContentTypeIfUnset(headers, value) {
1534
+ if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
1535
+ headers['Content-Type'] = value;
1536
+ }
1537
+ }
1538
+
1539
+ function getDefaultAdapter() {
1540
+ var adapter;
1541
+ if (typeof XMLHttpRequest !== 'undefined') {
1542
+ // For browsers use XHR adapter
1543
+ adapter = xhr;
1544
+ } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
1545
+ // For node use HTTP adapter
1546
+ adapter = xhr;
1547
+ }
1548
+ return adapter;
1549
+ }
1550
+
1551
+ function stringifySafely(rawValue, parser, encoder) {
1552
+ if (utils.isString(rawValue)) {
1553
+ try {
1554
+ (parser || JSON.parse)(rawValue);
1555
+ return utils.trim(rawValue);
1556
+ } catch (e) {
1557
+ if (e.name !== 'SyntaxError') {
1558
+ throw e;
1559
+ }
1560
+ }
1561
+ }
1562
+
1563
+ return (encoder || JSON.stringify)(rawValue);
1564
+ }
1565
+
1566
+ var defaults = {
1567
+
1568
+ transitional: transitional,
1569
+
1570
+ adapter: getDefaultAdapter(),
1571
+
1572
+ transformRequest: [function transformRequest(data, headers) {
1573
+ normalizeHeaderName(headers, 'Accept');
1574
+ normalizeHeaderName(headers, 'Content-Type');
1575
+
1576
+ var contentType = headers && headers['Content-Type'] || '';
1577
+ var hasJSONContentType = contentType.indexOf('application/json') > -1;
1578
+ var isObjectPayload = utils.isObject(data);
1579
+
1580
+ if (isObjectPayload && utils.isHTMLForm(data)) {
1581
+ data = new FormData(data);
1582
+ }
1583
+
1584
+ var isFormData = utils.isFormData(data);
1585
+
1586
+ if (isFormData) {
1587
+ return hasJSONContentType ? JSON.stringify(formDataToJSON_1(data)) : data;
1588
+ }
1589
+
1590
+ if (utils.isArrayBuffer(data) ||
1591
+ utils.isBuffer(data) ||
1592
+ utils.isStream(data) ||
1593
+ utils.isFile(data) ||
1594
+ utils.isBlob(data)
1595
+ ) {
1596
+ return data;
1597
+ }
1598
+ if (utils.isArrayBufferView(data)) {
1599
+ return data.buffer;
1600
+ }
1601
+ if (utils.isURLSearchParams(data)) {
1602
+ setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
1603
+ return data.toString();
1604
+ }
1605
+
1606
+ var isFileList;
1607
+
1608
+ if (isObjectPayload) {
1609
+ if (contentType.indexOf('application/x-www-form-urlencoded') !== -1) {
1610
+ return toURLEncodedForm(data, this.formSerializer).toString();
1611
+ }
1612
+
1613
+ if ((isFileList = utils.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1614
+ var _FormData = this.env && this.env.FormData;
1615
+
1616
+ return toFormData_1(
1617
+ isFileList ? {'files[]': data} : data,
1618
+ _FormData && new _FormData(),
1619
+ this.formSerializer
1620
+ );
1621
+ }
1622
+ }
1623
+
1624
+ if (isObjectPayload || hasJSONContentType ) {
1625
+ setContentTypeIfUnset(headers, 'application/json');
1626
+ return stringifySafely(data);
1627
+ }
1628
+
1629
+ return data;
1630
+ }],
1631
+
1632
+ transformResponse: [function transformResponse(data) {
1633
+ var transitional = this.transitional || defaults.transitional;
1634
+ var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1635
+ var JSONRequested = this.responseType === 'json';
1636
+
1637
+ if (data && utils.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1638
+ var silentJSONParsing = transitional && transitional.silentJSONParsing;
1639
+ var strictJSONParsing = !silentJSONParsing && JSONRequested;
1640
+
1641
+ try {
1642
+ return JSON.parse(data);
1643
+ } catch (e) {
1644
+ if (strictJSONParsing) {
1645
+ if (e.name === 'SyntaxError') {
1646
+ throw AxiosError_1.from(e, AxiosError_1.ERR_BAD_RESPONSE, this, null, this.response);
1647
+ }
1648
+ throw e;
1649
+ }
1650
+ }
1651
+ }
1652
+
1653
+ return data;
1654
+ }],
1655
+
1656
+ /**
1657
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1658
+ * timeout is not created.
1659
+ */
1660
+ timeout: 0,
1661
+
1662
+ xsrfCookieName: 'XSRF-TOKEN',
1663
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1664
+
1665
+ maxContentLength: -1,
1666
+ maxBodyLength: -1,
1667
+
1668
+ env: {
1669
+ FormData: platform.classes.FormData,
1670
+ Blob: platform.classes.Blob
1671
+ },
1672
+
1673
+ validateStatus: function validateStatus(status) {
1674
+ return status >= 200 && status < 300;
1675
+ },
1676
+
1677
+ headers: {
1678
+ common: {
1679
+ 'Accept': 'application/json, text/plain, */*'
1680
+ }
1681
+ }
1682
+ };
1683
+
1684
+ utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
1685
+ defaults.headers[method] = {};
1686
+ });
1687
+
1688
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
1689
+ defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
1690
+ });
1691
+
1692
+ var defaults_1 = defaults;
1693
+
1694
+ /**
1695
+ * Transform the data for a request or a response
1696
+ *
1697
+ * @param {Object|String} data The data to be transformed
1698
+ * @param {Array} headers The headers for the request or response
1699
+ * @param {Number} status HTTP status code
1700
+ * @param {Array|Function} fns A single function or Array of functions
1701
+ * @returns {*} The resulting transformed data
1702
+ */
1703
+ var transformData = function transformData(data, headers, status, fns) {
1704
+ var context = this || defaults_1;
1705
+ /*eslint no-param-reassign:0*/
1706
+ utils.forEach(fns, function transform(fn) {
1707
+ data = fn.call(context, data, headers, status);
1708
+ });
1709
+
1710
+ return data;
1711
+ };
1712
+
1713
+ var isCancel = function isCancel(value) {
1714
+ return !!(value && value.__CANCEL__);
1715
+ };
1716
+
1717
+ /**
1718
+ * Throws a `CanceledError` if cancellation has been requested.
1719
+ */
1720
+ function throwIfCancellationRequested(config) {
1721
+ if (config.cancelToken) {
1722
+ config.cancelToken.throwIfRequested();
1723
+ }
1724
+
1725
+ if (config.signal && config.signal.aborted) {
1726
+ throw new CanceledError_1();
1727
+ }
1728
+ }
1729
+
1730
+ /**
1731
+ * Dispatch a request to the server using the configured adapter.
1732
+ *
1733
+ * @param {object} config The config that is to be used for the request
1734
+ * @returns {Promise} The Promise to be fulfilled
1735
+ */
1736
+ var dispatchRequest = function dispatchRequest(config) {
1737
+ throwIfCancellationRequested(config);
1738
+
1739
+ // Ensure headers exist
1740
+ config.headers = config.headers || {};
1741
+
1742
+ // Transform request data
1743
+ config.data = transformData.call(
1744
+ config,
1745
+ config.data,
1746
+ config.headers,
1747
+ null,
1748
+ config.transformRequest
1749
+ );
1750
+
1751
+ normalizeHeaderName(config.headers, 'Accept');
1752
+ normalizeHeaderName(config.headers, 'Content-Type');
1753
+
1754
+ // Flatten headers
1755
+ config.headers = utils.merge(
1756
+ config.headers.common || {},
1757
+ config.headers[config.method] || {},
1758
+ config.headers
1759
+ );
1760
+
1761
+ utils.forEach(
1762
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
1763
+ function cleanHeaderConfig(method) {
1764
+ delete config.headers[method];
1765
+ }
1766
+ );
1767
+
1768
+ var adapter = config.adapter || defaults_1.adapter;
1769
+
1770
+ return adapter(config).then(function onAdapterResolution(response) {
1771
+ throwIfCancellationRequested(config);
1772
+
1773
+ // Transform response data
1774
+ response.data = transformData.call(
1775
+ config,
1776
+ response.data,
1777
+ response.headers,
1778
+ response.status,
1779
+ config.transformResponse
1780
+ );
1781
+
1782
+ return response;
1783
+ }, function onAdapterRejection(reason) {
1784
+ if (!isCancel(reason)) {
1785
+ throwIfCancellationRequested(config);
1786
+
1787
+ // Transform response data
1788
+ if (reason && reason.response) {
1789
+ reason.response.data = transformData.call(
1790
+ config,
1791
+ reason.response.data,
1792
+ reason.response.headers,
1793
+ reason.response.status,
1794
+ config.transformResponse
1795
+ );
1796
+ }
1797
+ }
1798
+
1799
+ return Promise.reject(reason);
1800
+ });
1801
+ };
1802
+
1803
+ /**
1804
+ * Config-specific merge-function which creates a new config-object
1805
+ * by merging two configuration objects together.
1806
+ *
1807
+ * @param {Object} config1
1808
+ * @param {Object} config2
1809
+ * @returns {Object} New object resulting from merging config2 to config1
1810
+ */
1811
+ var mergeConfig = function mergeConfig(config1, config2) {
1812
+ // eslint-disable-next-line no-param-reassign
1813
+ config2 = config2 || {};
1814
+ var config = {};
1815
+
1816
+ function getMergedValue(target, source) {
1817
+ if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
1818
+ return utils.merge(target, source);
1819
+ } else if (utils.isEmptyObject(source)) {
1820
+ return utils.merge({}, target);
1821
+ } else if (utils.isPlainObject(source)) {
1822
+ return utils.merge({}, source);
1823
+ } else if (utils.isArray(source)) {
1824
+ return source.slice();
1825
+ }
1826
+ return source;
1827
+ }
1828
+
1829
+ // eslint-disable-next-line consistent-return
1830
+ function mergeDeepProperties(prop) {
1831
+ if (!utils.isUndefined(config2[prop])) {
1832
+ return getMergedValue(config1[prop], config2[prop]);
1833
+ } else if (!utils.isUndefined(config1[prop])) {
1834
+ return getMergedValue(undefined, config1[prop]);
1835
+ }
1836
+ }
1837
+
1838
+ // eslint-disable-next-line consistent-return
1839
+ function valueFromConfig2(prop) {
1840
+ if (!utils.isUndefined(config2[prop])) {
1841
+ return getMergedValue(undefined, config2[prop]);
1842
+ }
1843
+ }
1844
+
1845
+ // eslint-disable-next-line consistent-return
1846
+ function defaultToConfig2(prop) {
1847
+ if (!utils.isUndefined(config2[prop])) {
1848
+ return getMergedValue(undefined, config2[prop]);
1849
+ } else if (!utils.isUndefined(config1[prop])) {
1850
+ return getMergedValue(undefined, config1[prop]);
1851
+ }
1852
+ }
1853
+
1854
+ // eslint-disable-next-line consistent-return
1855
+ function mergeDirectKeys(prop) {
1856
+ if (prop in config2) {
1857
+ return getMergedValue(config1[prop], config2[prop]);
1858
+ } else if (prop in config1) {
1859
+ return getMergedValue(undefined, config1[prop]);
1860
+ }
1861
+ }
1862
+
1863
+ var mergeMap = {
1864
+ 'url': valueFromConfig2,
1865
+ 'method': valueFromConfig2,
1866
+ 'data': valueFromConfig2,
1867
+ 'baseURL': defaultToConfig2,
1868
+ 'transformRequest': defaultToConfig2,
1869
+ 'transformResponse': defaultToConfig2,
1870
+ 'paramsSerializer': defaultToConfig2,
1871
+ 'timeout': defaultToConfig2,
1872
+ 'timeoutMessage': defaultToConfig2,
1873
+ 'withCredentials': defaultToConfig2,
1874
+ 'withXSRFToken': defaultToConfig2,
1875
+ 'adapter': defaultToConfig2,
1876
+ 'responseType': defaultToConfig2,
1877
+ 'xsrfCookieName': defaultToConfig2,
1878
+ 'xsrfHeaderName': defaultToConfig2,
1879
+ 'onUploadProgress': defaultToConfig2,
1880
+ 'onDownloadProgress': defaultToConfig2,
1881
+ 'decompress': defaultToConfig2,
1882
+ 'maxContentLength': defaultToConfig2,
1883
+ 'maxBodyLength': defaultToConfig2,
1884
+ 'beforeRedirect': defaultToConfig2,
1885
+ 'transport': defaultToConfig2,
1886
+ 'httpAgent': defaultToConfig2,
1887
+ 'httpsAgent': defaultToConfig2,
1888
+ 'cancelToken': defaultToConfig2,
1889
+ 'socketPath': defaultToConfig2,
1890
+ 'responseEncoding': defaultToConfig2,
1891
+ 'validateStatus': mergeDirectKeys
1892
+ };
1893
+
1894
+ utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
1895
+ var merge = mergeMap[prop] || mergeDeepProperties;
1896
+ var configValue = merge(prop);
1897
+ (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
1898
+ });
1899
+
1900
+ return config;
1901
+ };
1902
+
1903
+ var data = {
1904
+ "version": "0.28.1"
1905
+ };
1906
+
1907
+ var VERSION = data.version;
1908
+
1909
+
1910
+ var validators$1 = {};
1911
+
1912
+ // eslint-disable-next-line func-names
1913
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
1914
+ validators$1[type] = function validator(thing) {
1915
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1916
+ };
1917
+ });
1918
+
1919
+ var deprecatedWarnings = {};
1920
+
1921
+ /**
1922
+ * Transitional option validator
1923
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
1924
+ * @param {string?} version - deprecated version / removed since version
1925
+ * @param {string?} message - some message with additional info
1926
+ * @returns {function}
1927
+ */
1928
+ validators$1.transitional = function transitional(validator, version, message) {
1929
+ function formatMessage(opt, desc) {
1930
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1931
+ }
1932
+
1933
+ // eslint-disable-next-line func-names
1934
+ return function(value, opt, opts) {
1935
+ if (validator === false) {
1936
+ throw new AxiosError_1(
1937
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
1938
+ AxiosError_1.ERR_DEPRECATED
1939
+ );
1940
+ }
1941
+
1942
+ if (version && !deprecatedWarnings[opt]) {
1943
+ deprecatedWarnings[opt] = true;
1944
+ // eslint-disable-next-line no-console
1945
+ console.warn(
1946
+ formatMessage(
1947
+ opt,
1948
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
1949
+ )
1950
+ );
1951
+ }
1952
+
1953
+ return validator ? validator(value, opt, opts) : true;
1954
+ };
1955
+ };
1956
+
1957
+ /**
1958
+ * Assert object's properties type
1959
+ * @param {object} options
1960
+ * @param {object} schema
1961
+ * @param {boolean?} allowUnknown
1962
+ */
1963
+
1964
+ function assertOptions(options, schema, allowUnknown) {
1965
+ if (typeof options !== 'object') {
1966
+ throw new AxiosError_1('options must be an object', AxiosError_1.ERR_BAD_OPTION_VALUE);
1967
+ }
1968
+ var keys = Object.keys(options);
1969
+ var i = keys.length;
1970
+ while (i-- > 0) {
1971
+ var opt = keys[i];
1972
+ var validator = schema[opt];
1973
+ if (validator) {
1974
+ var value = options[opt];
1975
+ var result = value === undefined || validator(value, opt, options);
1976
+ if (result !== true) {
1977
+ throw new AxiosError_1('option ' + opt + ' must be ' + result, AxiosError_1.ERR_BAD_OPTION_VALUE);
1978
+ }
1979
+ continue;
1980
+ }
1981
+ if (allowUnknown !== true) {
1982
+ throw new AxiosError_1('Unknown option ' + opt, AxiosError_1.ERR_BAD_OPTION);
1983
+ }
1984
+ }
1985
+ }
1986
+
1987
+ var validator = {
1988
+ assertOptions: assertOptions,
1989
+ validators: validators$1
1990
+ };
1991
+
1992
+ var validators = validator.validators;
1993
+ /**
1994
+ * Create a new instance of Axios
1995
+ *
1996
+ * @param {Object} instanceConfig The default config for the instance
1997
+ */
1998
+ function Axios(instanceConfig) {
1999
+ this.defaults = instanceConfig;
2000
+ this.interceptors = {
2001
+ request: new InterceptorManager_1(),
2002
+ response: new InterceptorManager_1()
2003
+ };
2004
+ }
2005
+
2006
+ /**
2007
+ * Dispatch a request
2008
+ *
2009
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2010
+ * @param {?Object} config
2011
+ */
2012
+ Axios.prototype.request = function request(configOrUrl, config) {
2013
+ /*eslint no-param-reassign:0*/
2014
+ // Allow for axios('example/url'[, config]) a la fetch API
2015
+ if (typeof configOrUrl === 'string') {
2016
+ config = config || {};
2017
+ config.url = configOrUrl;
2018
+ } else {
2019
+ config = configOrUrl || {};
2020
+ }
2021
+
2022
+ config = mergeConfig(this.defaults, config);
2023
+
2024
+ // Set config.method
2025
+ if (config.method) {
2026
+ config.method = config.method.toLowerCase();
2027
+ } else if (this.defaults.method) {
2028
+ config.method = this.defaults.method.toLowerCase();
2029
+ } else {
2030
+ config.method = 'get';
2031
+ }
2032
+
2033
+ var transitional = config.transitional;
2034
+
2035
+ if (transitional !== undefined) {
2036
+ validator.assertOptions(transitional, {
2037
+ silentJSONParsing: validators.transitional(validators.boolean),
2038
+ forcedJSONParsing: validators.transitional(validators.boolean),
2039
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2040
+ }, false);
2041
+ }
2042
+
2043
+ var paramsSerializer = config.paramsSerializer;
2044
+
2045
+ if (paramsSerializer !== undefined) {
2046
+ validator.assertOptions(paramsSerializer, {
2047
+ encode: validators.function,
2048
+ serialize: validators.function
2049
+ }, true);
2050
+ }
2051
+
2052
+ utils.isFunction(paramsSerializer) && (config.paramsSerializer = {serialize: paramsSerializer});
2053
+
2054
+ // filter out skipped interceptors
2055
+ var requestInterceptorChain = [];
2056
+ var synchronousRequestInterceptors = true;
2057
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2058
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2059
+ return;
2060
+ }
2061
+
2062
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2063
+
2064
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2065
+ });
2066
+
2067
+ var responseInterceptorChain = [];
2068
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2069
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2070
+ });
2071
+
2072
+ var promise;
2073
+
2074
+ if (!synchronousRequestInterceptors) {
2075
+ var chain = [dispatchRequest, undefined];
2076
+
2077
+ Array.prototype.unshift.apply(chain, requestInterceptorChain);
2078
+ chain = chain.concat(responseInterceptorChain);
2079
+
2080
+ promise = Promise.resolve(config);
2081
+ while (chain.length) {
2082
+ promise = promise.then(chain.shift(), chain.shift());
2083
+ }
2084
+
2085
+ return promise;
2086
+ }
2087
+
2088
+
2089
+ var newConfig = config;
2090
+ while (requestInterceptorChain.length) {
2091
+ var onFulfilled = requestInterceptorChain.shift();
2092
+ var onRejected = requestInterceptorChain.shift();
2093
+ try {
2094
+ newConfig = onFulfilled(newConfig);
2095
+ } catch (error) {
2096
+ onRejected(error);
2097
+ break;
2098
+ }
2099
+ }
2100
+
2101
+ try {
2102
+ promise = dispatchRequest(newConfig);
2103
+ } catch (error) {
2104
+ return Promise.reject(error);
2105
+ }
2106
+
2107
+ while (responseInterceptorChain.length) {
2108
+ promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
2109
+ }
2110
+
2111
+ return promise;
2112
+ };
2113
+
2114
+ Axios.prototype.getUri = function getUri(config) {
2115
+ config = mergeConfig(this.defaults, config);
2116
+ var fullPath = buildFullPath(config.baseURL, config.url);
2117
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2118
+ };
2119
+
2120
+ // Provide aliases for supported request methods
2121
+ utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
2122
+ /*eslint func-names:0*/
2123
+ Axios.prototype[method] = function(url, config) {
2124
+ return this.request(mergeConfig(config || {}, {
2125
+ method: method,
2126
+ url: url,
2127
+ data: (config || {}).data
2128
+ }));
2129
+ };
2130
+ });
2131
+
2132
+ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2133
+ /*eslint func-names:0*/
2134
+
2135
+ function generateHTTPMethod(isForm) {
2136
+ return function httpMethod(url, data, config) {
2137
+ return this.request(mergeConfig(config || {}, {
2138
+ method: method,
2139
+ headers: isForm ? {
2140
+ 'Content-Type': 'multipart/form-data'
2141
+ } : {},
2142
+ url: url,
2143
+ data: data
2144
+ }));
2145
+ };
2146
+ }
2147
+
2148
+ Axios.prototype[method] = generateHTTPMethod();
2149
+
2150
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
2151
+ });
2152
+
2153
+ var Axios_1 = Axios;
2154
+
2155
+ /**
2156
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
2157
+ *
2158
+ * @class
2159
+ * @param {Function} executor The executor function.
2160
+ */
2161
+ function CancelToken(executor) {
2162
+ if (typeof executor !== 'function') {
2163
+ throw new TypeError('executor must be a function.');
2164
+ }
2165
+
2166
+ var resolvePromise;
2167
+
2168
+ this.promise = new Promise(function promiseExecutor(resolve) {
2169
+ resolvePromise = resolve;
2170
+ });
2171
+
2172
+ var token = this;
2173
+
2174
+ // eslint-disable-next-line func-names
2175
+ this.promise.then(function(cancel) {
2176
+ if (!token._listeners) return;
2177
+
2178
+ var i = token._listeners.length;
2179
+
2180
+ while (i-- > 0) {
2181
+ token._listeners[i](cancel);
2182
+ }
2183
+ token._listeners = null;
2184
+ });
2185
+
2186
+ // eslint-disable-next-line func-names
2187
+ this.promise.then = function(onfulfilled) {
2188
+ var _resolve;
2189
+ // eslint-disable-next-line func-names
2190
+ var promise = new Promise(function(resolve) {
2191
+ token.subscribe(resolve);
2192
+ _resolve = resolve;
2193
+ }).then(onfulfilled);
2194
+
2195
+ promise.cancel = function reject() {
2196
+ token.unsubscribe(_resolve);
2197
+ };
2198
+
2199
+ return promise;
2200
+ };
2201
+
2202
+ executor(function cancel(message, config, request) {
2203
+ if (token.reason) {
2204
+ // Cancellation has already been requested
2205
+ return;
2206
+ }
2207
+
2208
+ token.reason = new CanceledError_1(message, config, request);
2209
+ resolvePromise(token.reason);
2210
+ });
2211
+ }
2212
+
2213
+ /**
2214
+ * Throws a `CanceledError` if cancellation has been requested.
2215
+ */
2216
+ CancelToken.prototype.throwIfRequested = function throwIfRequested() {
2217
+ if (this.reason) {
2218
+ throw this.reason;
2219
+ }
2220
+ };
2221
+
2222
+ /**
2223
+ * Subscribe to the cancel signal
2224
+ */
2225
+
2226
+ CancelToken.prototype.subscribe = function subscribe(listener) {
2227
+ if (this.reason) {
2228
+ listener(this.reason);
2229
+ return;
2230
+ }
2231
+
2232
+ if (this._listeners) {
2233
+ this._listeners.push(listener);
2234
+ } else {
2235
+ this._listeners = [listener];
2236
+ }
2237
+ };
2238
+
2239
+ /**
2240
+ * Unsubscribe from the cancel signal
2241
+ */
2242
+
2243
+ CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
2244
+ if (!this._listeners) {
2245
+ return;
2246
+ }
2247
+ var index = this._listeners.indexOf(listener);
2248
+ if (index !== -1) {
2249
+ this._listeners.splice(index, 1);
2250
+ }
2251
+ };
2252
+
2253
+ /**
2254
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2255
+ * cancels the `CancelToken`.
2256
+ */
2257
+ CancelToken.source = function source() {
2258
+ var cancel;
2259
+ var token = new CancelToken(function executor(c) {
2260
+ cancel = c;
2261
+ });
2262
+ return {
2263
+ token: token,
2264
+ cancel: cancel
2265
+ };
2266
+ };
2267
+
2268
+ var CancelToken_1 = CancelToken;
2269
+
2270
+ /**
2271
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
2272
+ *
2273
+ * Common use case would be to use `Function.prototype.apply`.
2274
+ *
2275
+ * ```js
2276
+ * function f(x, y, z) {}
2277
+ * var args = [1, 2, 3];
2278
+ * f.apply(null, args);
2279
+ * ```
2280
+ *
2281
+ * With `spread` this example can be re-written.
2282
+ *
2283
+ * ```js
2284
+ * spread(function(x, y, z) {})([1, 2, 3]);
2285
+ * ```
2286
+ *
2287
+ * @param {Function} callback
2288
+ * @returns {Function}
2289
+ */
2290
+ var spread = function spread(callback) {
2291
+ return function wrap(arr) {
2292
+ return callback.apply(null, arr);
2293
+ };
2294
+ };
2295
+
2296
+ /**
2297
+ * Determines whether the payload is an error thrown by Axios
2298
+ *
2299
+ * @param {*} payload The value to test
2300
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2301
+ */
2302
+ var isAxiosError = function isAxiosError(payload) {
2303
+ return utils.isObject(payload) && (payload.isAxiosError === true);
2304
+ };
2305
+
2306
+ /**
2307
+ * Create an instance of Axios
2308
+ *
2309
+ * @param {Object} defaultConfig The default config for the instance
2310
+ * @return {Axios} A new instance of Axios
2311
+ */
2312
+ function createInstance(defaultConfig) {
2313
+ var context = new Axios_1(defaultConfig);
2314
+ var instance = bind(Axios_1.prototype.request, context);
2315
+
2316
+ // Copy axios.prototype to instance
2317
+ utils.extend(instance, Axios_1.prototype, context);
2318
+
2319
+ // Copy context to instance
2320
+ utils.extend(instance, context);
2321
+
2322
+ // Factory for creating new instances
2323
+ instance.create = function create(instanceConfig) {
2324
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
2325
+ };
2326
+
2327
+ return instance;
2328
+ }
2329
+
2330
+ // Create the default instance to be exported
2331
+ var axios = createInstance(defaults_1);
2332
+
2333
+ // Expose Axios class to allow class inheritance
2334
+ axios.Axios = Axios_1;
2335
+
2336
+ // Expose Cancel & CancelToken
2337
+ axios.CanceledError = CanceledError_1;
2338
+ axios.CancelToken = CancelToken_1;
2339
+ axios.isCancel = isCancel;
2340
+ axios.VERSION = data.version;
2341
+ axios.toFormData = toFormData_1;
2342
+
2343
+ // Expose AxiosError class
2344
+ axios.AxiosError = AxiosError_1;
2345
+
2346
+ // alias for CanceledError for backward compatibility
2347
+ axios.Cancel = axios.CanceledError;
2348
+
2349
+ // Expose all/spread
2350
+ axios.all = function all(promises) {
2351
+ return Promise.all(promises);
2352
+ };
2353
+ axios.spread = spread;
2354
+
2355
+ // Expose isAxiosError
2356
+ axios.isAxiosError = isAxiosError;
2357
+
2358
+ axios.formToJSON = function(thing) {
2359
+ return formDataToJSON_1(utils.isHTMLForm(thing) ? new FormData(thing) : thing);
2360
+ };
2361
+
2362
+ var axios_1 = axios;
2363
+
2364
+ // Allow use of default import syntax in TypeScript
2365
+ var _default = axios;
2366
+ axios_1.default = _default;
2367
+
2368
+ export { axios_1 as default };
2369
+ //# sourceMappingURL=axios.js.map