@tryghost/content-api 1.11.12 → 1.11.13

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