@wiajs/req 1.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +1023 -0
  2. package/LICENSE +7 -0
  3. package/MIGRATION_GUIDE.md +3 -0
  4. package/README.md +1645 -0
  5. package/SECURITY.md +6 -0
  6. package/dist/node/req.cjs +4397 -0
  7. package/dist/node/req.mjs +3551 -0
  8. package/dist/web/req.mjs +2609 -0
  9. package/index.d.cts +545 -0
  10. package/index.d.ts +565 -0
  11. package/index.js +43 -0
  12. package/lib/adapters/README.md +37 -0
  13. package/lib/adapters/adapters.js +57 -0
  14. package/lib/adapters/fetch.js +229 -0
  15. package/lib/adapters/http.js +552 -0
  16. package/lib/adapters/xhr.js +200 -0
  17. package/lib/axios.js +89 -0
  18. package/lib/cancel/CancelToken.js +106 -0
  19. package/lib/cancel/CanceledError.js +20 -0
  20. package/lib/cancel/isCancel.js +4 -0
  21. package/lib/core/Axios.js +359 -0
  22. package/lib/core/AxiosError.js +89 -0
  23. package/lib/core/AxiosHeaders.js +243 -0
  24. package/lib/core/InterceptorManager.js +59 -0
  25. package/lib/core/README.md +8 -0
  26. package/lib/core/buildFullPath.js +18 -0
  27. package/lib/core/dispatchRequest.js +72 -0
  28. package/lib/core/mergeConfig.js +98 -0
  29. package/lib/core/settle.js +21 -0
  30. package/lib/core/transformData.js +22 -0
  31. package/lib/defaults/index.js +136 -0
  32. package/lib/defaults/transitional.js +6 -0
  33. package/lib/env/README.md +3 -0
  34. package/lib/env/classes/FormData.js +2 -0
  35. package/lib/env/data.js +1 -0
  36. package/lib/helpers/AxiosTransformStream.js +116 -0
  37. package/lib/helpers/AxiosURLSearchParams.js +50 -0
  38. package/lib/helpers/HttpStatusCode.js +69 -0
  39. package/lib/helpers/README.md +7 -0
  40. package/lib/helpers/ZlibHeaderTransformStream.js +22 -0
  41. package/lib/helpers/bind.js +6 -0
  42. package/lib/helpers/buildURL.js +42 -0
  43. package/lib/helpers/callbackify.js +14 -0
  44. package/lib/helpers/combineURLs.js +11 -0
  45. package/lib/helpers/composeSignals.js +37 -0
  46. package/lib/helpers/cookies.js +29 -0
  47. package/lib/helpers/deprecatedMethod.js +18 -0
  48. package/lib/helpers/formDataToJSON.js +78 -0
  49. package/lib/helpers/formDataToStream.js +77 -0
  50. package/lib/helpers/fromDataURI.js +44 -0
  51. package/lib/helpers/isAbsoluteURL.js +13 -0
  52. package/lib/helpers/isAxiosError.js +11 -0
  53. package/lib/helpers/isURLSameOrigin.js +50 -0
  54. package/lib/helpers/null.js +2 -0
  55. package/lib/helpers/parseHeaders.js +61 -0
  56. package/lib/helpers/parseProtocol.js +5 -0
  57. package/lib/helpers/progressEventReducer.js +54 -0
  58. package/lib/helpers/readBlob.js +13 -0
  59. package/lib/helpers/resolveConfig.js +45 -0
  60. package/lib/helpers/speedometer.js +40 -0
  61. package/lib/helpers/spread.js +26 -0
  62. package/lib/helpers/throttle.js +41 -0
  63. package/lib/helpers/toFormData.js +175 -0
  64. package/lib/helpers/toURLEncodedForm.js +15 -0
  65. package/lib/helpers/trackStream.js +75 -0
  66. package/lib/helpers/validator.js +84 -0
  67. package/lib/platform/browser/classes/Blob.js +2 -0
  68. package/lib/platform/browser/classes/FormData.js +2 -0
  69. package/lib/platform/browser/classes/URLSearchParams.js +3 -0
  70. package/lib/platform/browser/index.js +19 -0
  71. package/lib/platform/common/utils.js +37 -0
  72. package/lib/platform/index.js +6 -0
  73. package/lib/platform/node/classes/FormData.js +2 -0
  74. package/lib/platform/node/classes/URLSearchParams.js +3 -0
  75. package/lib/platform/node/index.js +16 -0
  76. package/lib/req.js +67 -0
  77. package/lib/utils.js +635 -0
  78. package/package.json +214 -0
@@ -0,0 +1,2609 @@
1
+ /*!
2
+ * @wia/req v1.7.7
3
+ * (c) 2024 Sibyl Yu, Matt Zabriskie and contributors
4
+ * Released under the MIT License.
5
+ */
6
+ function bind(fn, thisArg) {
7
+ return function wrap() {
8
+ return fn.apply(thisArg, arguments);
9
+ };
10
+ }
11
+
12
+ // utils is a library of generic helper functions non-specific to axios
13
+ const { toString } = Object.prototype;
14
+ const { getPrototypeOf } = Object;
15
+ const kindOf = ((cache)=>(thing)=>{
16
+ const str = toString.call(thing);
17
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
18
+ })(Object.create(null));
19
+ const kindOfTest = (type)=>{
20
+ type = type.toLowerCase();
21
+ return (thing)=>kindOf(thing) === type;
22
+ };
23
+ const typeOfTest = (type)=>(thing)=>typeof thing === type;
24
+ /**
25
+ * Determine if a value is an Array
26
+ *
27
+ * @param {Object} val The value to test
28
+ *
29
+ * @returns {boolean} True if value is an Array, otherwise false
30
+ */ const { isArray } = Array;
31
+ /**
32
+ * Determine if a value is undefined
33
+ *
34
+ * @param {*} val The value to test
35
+ *
36
+ * @returns {boolean} True if the value is undefined, otherwise false
37
+ */ const isUndefined = typeOfTest('undefined');
38
+ /**
39
+ * Determine if a value is a Buffer
40
+ *
41
+ * @param {*} val The value to test
42
+ *
43
+ * @returns {boolean} True if value is a Buffer, otherwise false
44
+ */ function isBuffer(val) {
45
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
46
+ }
47
+ /**
48
+ * Determine if a value is an ArrayBuffer
49
+ *
50
+ * @param {*} val The value to test
51
+ *
52
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
53
+ */ const isArrayBuffer = kindOfTest('ArrayBuffer');
54
+ /**
55
+ * Determine if a value is a view on an ArrayBuffer
56
+ *
57
+ * @param {*} val The value to test
58
+ *
59
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
60
+ */ function isArrayBufferView(val) {
61
+ let result;
62
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
63
+ result = ArrayBuffer.isView(val);
64
+ } else {
65
+ result = val && val.buffer && isArrayBuffer(val.buffer);
66
+ }
67
+ return result;
68
+ }
69
+ /**
70
+ * Determine if a value is a String
71
+ *
72
+ * @param {*} val The value to test
73
+ *
74
+ * @returns {boolean} True if value is a String, otherwise false
75
+ */ const isString = typeOfTest('string');
76
+ /**
77
+ * Determine if a value is a Function
78
+ *
79
+ * @param {*} val The value to test
80
+ * @returns {boolean} True if value is a Function, otherwise false
81
+ */ const isFunction = typeOfTest('function');
82
+ /**
83
+ * Determine if a value is a Number
84
+ *
85
+ * @param {*} val The value to test
86
+ *
87
+ * @returns {boolean} True if value is a Number, otherwise false
88
+ */ const isNumber = typeOfTest('number');
89
+ /**
90
+ * Determine if a value is an Object
91
+ *
92
+ * @param {*} thing The value to test
93
+ *
94
+ * @returns {boolean} True if value is an Object, otherwise false
95
+ */ const isObject = (thing)=>thing !== null && typeof thing === 'object';
96
+ /**
97
+ * Determine if a value is a Boolean
98
+ *
99
+ * @param {*} thing The value to test
100
+ * @returns {boolean} True if value is a Boolean, otherwise false
101
+ */ const isBoolean = (thing)=>thing === true || thing === false;
102
+ /**
103
+ * Determine if a value is a plain Object
104
+ *
105
+ * @param {*} val The value to test
106
+ *
107
+ * @returns {boolean} True if value is a plain Object, otherwise false
108
+ */ const isPlainObject = (val)=>{
109
+ if (kindOf(val) !== 'object') {
110
+ return false;
111
+ }
112
+ const prototype = getPrototypeOf(val);
113
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
114
+ };
115
+ /**
116
+ * Determine if a value is a Date
117
+ *
118
+ * @param {*} val The value to test
119
+ *
120
+ * @returns {boolean} True if value is a Date, otherwise false
121
+ */ const isDate = kindOfTest('Date');
122
+ /**
123
+ * Determine if a value is a File
124
+ *
125
+ * @param {*} val The value to test
126
+ *
127
+ * @returns {boolean} True if value is a File, otherwise false
128
+ */ const isFile = kindOfTest('File');
129
+ /**
130
+ * Determine if a value is a Blob
131
+ *
132
+ * @param {*} val The value to test
133
+ *
134
+ * @returns {boolean} True if value is a Blob, otherwise false
135
+ */ const isBlob = kindOfTest('Blob');
136
+ /**
137
+ * Determine if a value is a FileList
138
+ *
139
+ * @param {*} val The value to test
140
+ *
141
+ * @returns {boolean} True if value is a File, otherwise false
142
+ */ const isFileList = kindOfTest('FileList');
143
+ /**
144
+ * Determine if a value is a Stream
145
+ *
146
+ * @param {*} val The value to test
147
+ *
148
+ * @returns {boolean} True if value is a Stream, otherwise false
149
+ */ const isStream = (val)=>isObject(val) && isFunction(val.pipe);
150
+ /**
151
+ * Determine if a value is a FormData
152
+ *
153
+ * @param {*} thing The value to test
154
+ *
155
+ * @returns {boolean} True if value is an FormData, otherwise false
156
+ */ const isFormData = (thing)=>{
157
+ let kind;
158
+ return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === 'formdata' || // detect form-data instance
159
+ kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]'));
160
+ };
161
+ /**
162
+ * Determine if a value is a URLSearchParams object
163
+ *
164
+ * @param {*} val The value to test
165
+ *
166
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
167
+ */ const isURLSearchParams = kindOfTest('URLSearchParams');
168
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
169
+ 'ReadableStream',
170
+ 'Request',
171
+ 'Response',
172
+ 'Headers'
173
+ ].map(kindOfTest);
174
+ /**
175
+ * Trim excess whitespace off the beginning and end of a string
176
+ *
177
+ * @param {String} str The String to trim
178
+ *
179
+ * @returns {String} The String freed of excess whitespace
180
+ */ const trim = (str)=>str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
181
+ /**
182
+ * Iterate over an Array or an Object invoking a function for each item.
183
+ *
184
+ * If `obj` is an Array callback will be called passing
185
+ * the value, index, and complete array for each item.
186
+ *
187
+ * If 'obj' is an Object callback will be called passing
188
+ * the value, key, and complete object for each property.
189
+ *
190
+ * @param {Object|Array} obj The object to iterate
191
+ * @param {Function} fn The callback to invoke for each item
192
+ *
193
+ * @param {Boolean} [allOwnKeys = false]
194
+ * @returns {any}
195
+ */ function forEach(obj, fn, { allOwnKeys = false } = {}) {
196
+ // Don't bother if no value provided
197
+ if (obj === null || typeof obj === 'undefined') {
198
+ return;
199
+ }
200
+ let i;
201
+ let l;
202
+ // Force an array if not already something iterable
203
+ if (typeof obj !== 'object') {
204
+ /*eslint no-param-reassign:0*/ obj = [
205
+ obj
206
+ ];
207
+ }
208
+ if (isArray(obj)) {
209
+ // Iterate over array values
210
+ for(i = 0, l = obj.length; i < l; i++){
211
+ fn.call(null, obj[i], i, obj);
212
+ }
213
+ } else {
214
+ // Iterate over object keys
215
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
216
+ const len = keys.length;
217
+ let key;
218
+ for(i = 0; i < len; i++){
219
+ key = keys[i];
220
+ fn.call(null, obj[key], key, obj);
221
+ }
222
+ }
223
+ }
224
+ function findKey(obj, key) {
225
+ key = key.toLowerCase();
226
+ const keys = Object.keys(obj);
227
+ let i = keys.length;
228
+ let _key;
229
+ while(i-- > 0){
230
+ _key = keys[i];
231
+ if (key === _key.toLowerCase()) {
232
+ return _key;
233
+ }
234
+ }
235
+ return null;
236
+ }
237
+ const _global = (()=>{
238
+ /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
239
+ return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
240
+ })();
241
+ const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
242
+ /**
243
+ * Accepts varargs expecting each argument to be an object, then
244
+ * immutably merges the properties of each object and returns result.
245
+ *
246
+ * When multiple objects contain the same key the later object in
247
+ * the arguments list will take precedence.
248
+ *
249
+ * Example:
250
+ *
251
+ * ```js
252
+ * var result = merge({foo: 123}, {foo: 456});
253
+ * console.log(result.foo); // outputs 456
254
+ * ```
255
+ *
256
+ * @param {Object} obj1 Object to merge
257
+ *
258
+ * @returns {Object} Result of all merge properties
259
+ */ function merge() {
260
+ const { caseless } = isContextDefined(this) && this || {};
261
+ const result = {};
262
+ const assignValue = (val, key)=>{
263
+ const targetKey = caseless && findKey(result, key) || key;
264
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
265
+ result[targetKey] = merge(result[targetKey], val);
266
+ } else if (isPlainObject(val)) {
267
+ result[targetKey] = merge({}, val);
268
+ } else if (isArray(val)) {
269
+ result[targetKey] = val.slice();
270
+ } else {
271
+ result[targetKey] = val;
272
+ }
273
+ };
274
+ for(let i = 0, l = arguments.length; i < l; i++){
275
+ arguments[i] && forEach(arguments[i], assignValue);
276
+ }
277
+ return result;
278
+ }
279
+ /**
280
+ * Extends object a by mutably adding to it the properties of object b.
281
+ *
282
+ * @param {Object} a The object to be extended
283
+ * @param {Object} b The object to copy properties from
284
+ * @param {Object} thisArg The object to bind function to
285
+ *
286
+ * @param {Boolean} [allOwnKeys]
287
+ * @returns {Object} The resulting value of object a
288
+ */ const extend = (a, b, thisArg, { allOwnKeys } = {})=>{
289
+ forEach(b, (val, key)=>{
290
+ if (thisArg && isFunction(val)) {
291
+ a[key] = bind(val, thisArg);
292
+ } else {
293
+ a[key] = val;
294
+ }
295
+ }, {
296
+ allOwnKeys
297
+ });
298
+ return a;
299
+ };
300
+ /**
301
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
302
+ *
303
+ * @param {string} content with BOM
304
+ *
305
+ * @returns {string} content value without BOM
306
+ */ const stripBOM = (content)=>{
307
+ if (content.charCodeAt(0) === 0xFEFF) {
308
+ content = content.slice(1);
309
+ }
310
+ return content;
311
+ };
312
+ /**
313
+ * Inherit the prototype methods from one constructor into another
314
+ * @param {function} constructor
315
+ * @param {function} superConstructor
316
+ * @param {object} [props]
317
+ * @param {object} [descriptors]
318
+ *
319
+ * @returns {void}
320
+ */ const inherits = (constructor, superConstructor, props, descriptors)=>{
321
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
322
+ constructor.prototype.constructor = constructor;
323
+ Object.defineProperty(constructor, 'super', {
324
+ value: superConstructor.prototype
325
+ });
326
+ props && Object.assign(constructor.prototype, props);
327
+ };
328
+ /**
329
+ * Resolve object with deep prototype chain to a flat object
330
+ * @param {Object} sourceObj source object
331
+ * @param {Object} [destObj]
332
+ * @param {Function|Boolean} [filter]
333
+ * @param {Function} [propFilter]
334
+ *
335
+ * @returns {Object}
336
+ */ const toFlatObject = (sourceObj, destObj, filter, propFilter)=>{
337
+ let props;
338
+ let i;
339
+ let prop;
340
+ const merged = {};
341
+ destObj = destObj || {};
342
+ // eslint-disable-next-line no-eq-null,eqeqeq
343
+ if (sourceObj == null) return destObj;
344
+ do {
345
+ props = Object.getOwnPropertyNames(sourceObj);
346
+ i = props.length;
347
+ while(i-- > 0){
348
+ prop = props[i];
349
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
350
+ destObj[prop] = sourceObj[prop];
351
+ merged[prop] = true;
352
+ }
353
+ }
354
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
355
+ }while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype)
356
+ return destObj;
357
+ };
358
+ /**
359
+ * Determines whether a string ends with the characters of a specified string
360
+ *
361
+ * @param {String} str
362
+ * @param {String} searchString
363
+ * @param {Number} [position= 0]
364
+ *
365
+ * @returns {boolean}
366
+ */ const endsWith = (str, searchString, position)=>{
367
+ str = String(str);
368
+ if (position === undefined || position > str.length) {
369
+ position = str.length;
370
+ }
371
+ position -= searchString.length;
372
+ const lastIndex = str.indexOf(searchString, position);
373
+ return lastIndex !== -1 && lastIndex === position;
374
+ };
375
+ /**
376
+ * Returns new array from array like object or null if failed
377
+ *
378
+ * @param {*} [thing]
379
+ *
380
+ * @returns {?Array}
381
+ */ const toArray = (thing)=>{
382
+ if (!thing) return null;
383
+ if (isArray(thing)) return thing;
384
+ let i = thing.length;
385
+ if (!isNumber(i)) return null;
386
+ const arr = new Array(i);
387
+ while(i-- > 0){
388
+ arr[i] = thing[i];
389
+ }
390
+ return arr;
391
+ };
392
+ /**
393
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
394
+ * thing passed in is an instance of Uint8Array
395
+ *
396
+ * @param {TypedArray}
397
+ *
398
+ * @returns {Array}
399
+ */ // eslint-disable-next-line func-names
400
+ const isTypedArray = ((TypedArray)=>{
401
+ // eslint-disable-next-line func-names
402
+ return (thing)=>{
403
+ return TypedArray && thing instanceof TypedArray;
404
+ };
405
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
406
+ /**
407
+ * For each entry in the object, call the function with the key and value.
408
+ *
409
+ * @param {Object<any, any>} obj - The object to iterate over.
410
+ * @param {Function} fn - The function to call for each entry.
411
+ *
412
+ * @returns {void}
413
+ */ const forEachEntry = (obj, fn)=>{
414
+ const generator = obj && obj[Symbol.iterator];
415
+ const iterator = generator.call(obj);
416
+ let result;
417
+ while((result = iterator.next()) && !result.done){
418
+ const pair = result.value;
419
+ fn.call(obj, pair[0], pair[1]);
420
+ }
421
+ };
422
+ /**
423
+ * It takes a regular expression and a string, and returns an array of all the matches
424
+ *
425
+ * @param {string} regExp - The regular expression to match against.
426
+ * @param {string} str - The string to search.
427
+ *
428
+ * @returns {Array<boolean>}
429
+ */ const matchAll = (regExp, str)=>{
430
+ let matches;
431
+ const arr = [];
432
+ while((matches = regExp.exec(str)) !== null){
433
+ arr.push(matches);
434
+ }
435
+ return arr;
436
+ };
437
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ const isHTMLForm = kindOfTest('HTMLFormElement');
438
+ const toCamelCase = (str)=>{
439
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
440
+ return p1.toUpperCase() + p2;
441
+ });
442
+ };
443
+ /* Creating a function that will check if an object has a property. */ const hasOwnProperty = (({ hasOwnProperty })=>(obj, prop)=>hasOwnProperty.call(obj, prop))(Object.prototype);
444
+ /**
445
+ * Determine if a value is a RegExp object
446
+ *
447
+ * @param {*} val The value to test
448
+ *
449
+ * @returns {boolean} True if value is a RegExp object, otherwise false
450
+ */ const isRegExp = kindOfTest('RegExp');
451
+ const reduceDescriptors = (obj, reducer)=>{
452
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
453
+ const reducedDescriptors = {};
454
+ forEach(descriptors, (descriptor, name)=>{
455
+ let ret;
456
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
457
+ reducedDescriptors[name] = ret || descriptor;
458
+ }
459
+ });
460
+ Object.defineProperties(obj, reducedDescriptors);
461
+ };
462
+ /**
463
+ * Makes all methods read-only
464
+ * @param {Object} obj
465
+ */ const freezeMethods = (obj)=>{
466
+ reduceDescriptors(obj, (descriptor, name)=>{
467
+ // skip restricted props in strict mode
468
+ if (isFunction(obj) && [
469
+ 'arguments',
470
+ 'caller',
471
+ 'callee'
472
+ ].indexOf(name) !== -1) {
473
+ return false;
474
+ }
475
+ const value = obj[name];
476
+ if (!isFunction(value)) return;
477
+ descriptor.enumerable = false;
478
+ if ('writable' in descriptor) {
479
+ descriptor.writable = false;
480
+ return;
481
+ }
482
+ if (!descriptor.set) {
483
+ descriptor.set = ()=>{
484
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
485
+ };
486
+ }
487
+ });
488
+ };
489
+ const toObjectSet = (arrayOrString, delimiter)=>{
490
+ const obj = {};
491
+ const define = (arr)=>{
492
+ arr.forEach((value)=>{
493
+ obj[value] = true;
494
+ });
495
+ };
496
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
497
+ return obj;
498
+ };
499
+ const noop = ()=>{};
500
+ const toFiniteNumber = (value, defaultValue)=>{
501
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
502
+ };
503
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
504
+ const DIGIT = '0123456789';
505
+ const ALPHABET = {
506
+ DIGIT,
507
+ ALPHA,
508
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
509
+ };
510
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT)=>{
511
+ let str = '';
512
+ const { length } = alphabet;
513
+ while(size--){
514
+ str += alphabet[Math.random() * length | 0];
515
+ }
516
+ return str;
517
+ };
518
+ /**
519
+ * If the thing is a FormData object, return true, otherwise return false.
520
+ *
521
+ * @param {unknown} thing - The thing to check.
522
+ *
523
+ * @returns {boolean}
524
+ */ function isSpecCompliantForm(thing) {
525
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
526
+ }
527
+ const toJSONObject = (obj)=>{
528
+ const stack = new Array(10);
529
+ const visit = (source, i)=>{
530
+ if (isObject(source)) {
531
+ if (stack.indexOf(source) >= 0) {
532
+ return;
533
+ }
534
+ if (!('toJSON' in source)) {
535
+ stack[i] = source;
536
+ const target = isArray(source) ? [] : {};
537
+ forEach(source, (value, key)=>{
538
+ const reducedValue = visit(value, i + 1);
539
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
540
+ });
541
+ stack[i] = undefined;
542
+ return target;
543
+ }
544
+ }
545
+ return source;
546
+ };
547
+ return visit(obj, 0);
548
+ };
549
+ const isAsyncFn = kindOfTest('AsyncFunction');
550
+ const isThenable = (thing)=>thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
551
+ // original code
552
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
553
+ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
554
+ if (setImmediateSupported) {
555
+ return setImmediate;
556
+ }
557
+ return postMessageSupported ? ((token, callbacks)=>{
558
+ _global.addEventListener("message", ({ source, data })=>{
559
+ if (source === _global && data === token) {
560
+ callbacks.length && callbacks.shift()();
561
+ }
562
+ }, false);
563
+ return (cb)=>{
564
+ callbacks.push(cb);
565
+ _global.postMessage(token, "*");
566
+ };
567
+ })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
568
+ })(typeof setImmediate === 'function', isFunction(_global.postMessage));
569
+ const asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
570
+ function createErrorType(code, message, baseClass) {
571
+ // Create constructor
572
+ function CustomError(properties) {
573
+ Error.captureStackTrace(this, this.constructor);
574
+ Object.assign(this, properties || {});
575
+ this.code = code;
576
+ this.message = this.cause ? `${message}: ${this.cause.message}` : message;
577
+ }
578
+ // Attach constructor and set default properties
579
+ CustomError.prototype = new (baseClass || Error)();
580
+ CustomError.prototype.constructor = CustomError;
581
+ CustomError.prototype.name = `Error [${code}]`;
582
+ return CustomError;
583
+ }
584
+ // *********************
585
+ const utils$1 = {
586
+ isArray,
587
+ isArrayBuffer,
588
+ isBuffer,
589
+ isFormData,
590
+ isArrayBufferView,
591
+ isString,
592
+ isNumber,
593
+ isBoolean,
594
+ isObject,
595
+ isPlainObject,
596
+ isReadableStream,
597
+ isRequest,
598
+ isResponse,
599
+ isHeaders,
600
+ isUndefined,
601
+ isDate,
602
+ isFile,
603
+ isBlob,
604
+ isRegExp,
605
+ isFunction,
606
+ isStream,
607
+ isURLSearchParams,
608
+ isTypedArray,
609
+ isFileList,
610
+ forEach,
611
+ merge,
612
+ extend,
613
+ trim,
614
+ stripBOM,
615
+ inherits,
616
+ toFlatObject,
617
+ kindOf,
618
+ kindOfTest,
619
+ endsWith,
620
+ toArray,
621
+ forEachEntry,
622
+ matchAll,
623
+ isHTMLForm,
624
+ hasOwnProperty,
625
+ hasOwnProp: hasOwnProperty,
626
+ reduceDescriptors,
627
+ freezeMethods,
628
+ toObjectSet,
629
+ toCamelCase,
630
+ noop,
631
+ toFiniteNumber,
632
+ findKey,
633
+ global: _global,
634
+ isContextDefined,
635
+ ALPHABET,
636
+ generateString,
637
+ isSpecCompliantForm,
638
+ toJSONObject,
639
+ isAsyncFn,
640
+ isThenable,
641
+ setImmediate: _setImmediate,
642
+ asap,
643
+ createErrorType
644
+ };
645
+
646
+ /**
647
+ * Create an Error with the specified message, config, error code, request and response.
648
+ *
649
+ * @param {string} message The error message.
650
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
651
+ * @param {Object} [config] The config.
652
+ * @param {Object} [request] The request.
653
+ * @param {Object} [response] The response.
654
+ *
655
+ * @returns {Error} The created error.
656
+ */ function AxiosError$1(message, code, config, request, response) {
657
+ Error.call(this);
658
+ if (Error.captureStackTrace) {
659
+ Error.captureStackTrace(this, this.constructor);
660
+ } else {
661
+ this.stack = new Error().stack;
662
+ }
663
+ this.message = message;
664
+ this.name = 'AxiosError';
665
+ code && (this.code = code);
666
+ config && (this.config = config);
667
+ request && (this.request = request);
668
+ if (response) {
669
+ this.response = response;
670
+ this.status = response.status ? response.status : null;
671
+ }
672
+ }
673
+ utils$1.inherits(AxiosError$1, Error, {
674
+ toJSON: function toJSON() {
675
+ return {
676
+ // Standard
677
+ message: this.message,
678
+ name: this.name,
679
+ // Microsoft
680
+ description: this.description,
681
+ number: this.number,
682
+ // Mozilla
683
+ fileName: this.fileName,
684
+ lineNumber: this.lineNumber,
685
+ columnNumber: this.columnNumber,
686
+ stack: this.stack,
687
+ // Axios
688
+ config: utils$1.toJSONObject(this.config),
689
+ code: this.code,
690
+ status: this.status
691
+ };
692
+ }
693
+ });
694
+ const prototype$1 = AxiosError$1.prototype;
695
+ const descriptors = {};
696
+ [
697
+ 'ERR_BAD_OPTION_VALUE',
698
+ 'ERR_BAD_OPTION',
699
+ 'ECONNABORTED',
700
+ 'ETIMEDOUT',
701
+ 'ERR_NETWORK',
702
+ 'ERR_FR_TOO_MANY_REDIRECTS',
703
+ 'ERR_DEPRECATED',
704
+ 'ERR_BAD_RESPONSE',
705
+ 'ERR_BAD_REQUEST',
706
+ 'ERR_CANCELED',
707
+ 'ERR_NOT_SUPPORT',
708
+ 'ERR_INVALID_URL'
709
+ ].forEach((code)=>{
710
+ descriptors[code] = {
711
+ value: code
712
+ };
713
+ });
714
+ Object.defineProperties(AxiosError$1, descriptors);
715
+ Object.defineProperty(prototype$1, 'isAxiosError', {
716
+ value: true
717
+ });
718
+ // eslint-disable-next-line func-names
719
+ AxiosError$1.from = (error, code, config, request, response, customProps)=>{
720
+ const axiosError = Object.create(prototype$1);
721
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
722
+ return obj !== Error.prototype;
723
+ }, (prop)=>{
724
+ return prop !== 'isAxiosError';
725
+ });
726
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
727
+ axiosError.cause = error;
728
+ axiosError.name = error.name;
729
+ customProps && Object.assign(axiosError, customProps);
730
+ return axiosError;
731
+ };
732
+
733
+ // eslint-disable-next-line strict
734
+ const HttpAdapter = null;
735
+
736
+ /**
737
+ * Determines if the given thing is a array or js object.
738
+ *
739
+ * @param {string} thing - The object or array to be visited.
740
+ *
741
+ * @returns {boolean}
742
+ */ function isVisitable(thing) {
743
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
744
+ }
745
+ /**
746
+ * It removes the brackets from the end of a string
747
+ *
748
+ * @param {string} key - The key of the parameter.
749
+ *
750
+ * @returns {string} the key without the brackets.
751
+ */ function removeBrackets(key) {
752
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
753
+ }
754
+ /**
755
+ * It takes a path, a key, and a boolean, and returns a string
756
+ *
757
+ * @param {string} path - The path to the current key.
758
+ * @param {string} key - The key of the current object being iterated over.
759
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
760
+ *
761
+ * @returns {string} The path to the current key.
762
+ */ function renderKey(path, key, dots) {
763
+ if (!path) return key;
764
+ return path.concat(key).map(function each(token, i) {
765
+ // eslint-disable-next-line no-param-reassign
766
+ token = removeBrackets(token);
767
+ return !dots && i ? '[' + token + ']' : token;
768
+ }).join(dots ? '.' : '');
769
+ }
770
+ /**
771
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
772
+ *
773
+ * @param {Array<any>} arr - The array to check
774
+ *
775
+ * @returns {boolean}
776
+ */ function isFlatArray(arr) {
777
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
778
+ }
779
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
780
+ return /^is[A-Z]/.test(prop);
781
+ });
782
+ /**
783
+ * Convert a data object to FormData
784
+ *
785
+ * @param {Object} obj
786
+ * @param {?Object} [formData]
787
+ * @param {?Object} [options]
788
+ * @param {Function} [options.visitor]
789
+ * @param {Boolean} [options.metaTokens = true]
790
+ * @param {Boolean} [options.dots = false]
791
+ * @param {?Boolean} [options.indexes = false]
792
+ *
793
+ * @returns {Object}
794
+ **/ /**
795
+ * It converts an object into a FormData object
796
+ *
797
+ * @param {Object<any, any>} obj - The object to convert to form data.
798
+ * @param {string} formData - The FormData object to append to.
799
+ * @param {Object<string, any>} options
800
+ *
801
+ * @returns
802
+ */ function toFormData$1(obj, formData, options) {
803
+ if (!utils$1.isObject(obj)) {
804
+ throw new TypeError('target must be an object');
805
+ }
806
+ // eslint-disable-next-line no-param-reassign
807
+ formData = formData || new (FormData)();
808
+ // eslint-disable-next-line no-param-reassign
809
+ options = utils$1.toFlatObject(options, {
810
+ metaTokens: true,
811
+ dots: false,
812
+ indexes: false
813
+ }, false, function defined(option, source) {
814
+ // eslint-disable-next-line no-eq-null,eqeqeq
815
+ return !utils$1.isUndefined(source[option]);
816
+ });
817
+ const metaTokens = options.metaTokens;
818
+ // eslint-disable-next-line no-use-before-define
819
+ const visitor = options.visitor || defaultVisitor;
820
+ const dots = options.dots;
821
+ const indexes = options.indexes;
822
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
823
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
824
+ if (!utils$1.isFunction(visitor)) {
825
+ throw new TypeError('visitor must be a function');
826
+ }
827
+ function convertValue(value) {
828
+ if (value === null) return '';
829
+ if (utils$1.isDate(value)) {
830
+ return value.toISOString();
831
+ }
832
+ if (!useBlob && utils$1.isBlob(value)) {
833
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
834
+ }
835
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
836
+ return useBlob && typeof Blob === 'function' ? new Blob([
837
+ value
838
+ ]) : Buffer.from(value);
839
+ }
840
+ return value;
841
+ }
842
+ /**
843
+ * Default visitor.
844
+ *
845
+ * @param {*} value
846
+ * @param {String|Number} key
847
+ * @param {Array<String|Number>} path
848
+ * @this {FormData}
849
+ *
850
+ * @returns {boolean} return true to visit the each prop of the value recursively
851
+ */ function defaultVisitor(value, key, path) {
852
+ let arr = value;
853
+ if (value && !path && typeof value === 'object') {
854
+ if (utils$1.endsWith(key, '{}')) {
855
+ // eslint-disable-next-line no-param-reassign
856
+ key = metaTokens ? key : key.slice(0, -2);
857
+ // eslint-disable-next-line no-param-reassign
858
+ value = JSON.stringify(value);
859
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
860
+ // eslint-disable-next-line no-param-reassign
861
+ key = removeBrackets(key);
862
+ arr.forEach(function each(el, index) {
863
+ !(utils$1.isUndefined(el) || el === null) && formData.append(// eslint-disable-next-line no-nested-ternary
864
+ indexes === true ? renderKey([
865
+ key
866
+ ], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
867
+ });
868
+ return false;
869
+ }
870
+ }
871
+ if (isVisitable(value)) {
872
+ return true;
873
+ }
874
+ formData.append(renderKey(path, key, dots), convertValue(value));
875
+ return false;
876
+ }
877
+ const stack = [];
878
+ const exposedHelpers = Object.assign(predicates, {
879
+ defaultVisitor,
880
+ convertValue,
881
+ isVisitable
882
+ });
883
+ function build(value, path) {
884
+ if (utils$1.isUndefined(value)) return;
885
+ if (stack.indexOf(value) !== -1) {
886
+ throw Error('Circular reference detected in ' + path.join('.'));
887
+ }
888
+ stack.push(value);
889
+ utils$1.forEach(value, function each(el, key) {
890
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
891
+ if (result === true) {
892
+ build(el, path ? path.concat(key) : [
893
+ key
894
+ ]);
895
+ }
896
+ });
897
+ stack.pop();
898
+ }
899
+ if (!utils$1.isObject(obj)) {
900
+ throw new TypeError('data must be an object');
901
+ }
902
+ build(obj);
903
+ return formData;
904
+ }
905
+
906
+ /**
907
+ * It encodes a string by replacing all characters that are not in the unreserved set with
908
+ * their percent-encoded equivalents
909
+ *
910
+ * @param {string} str - The string to encode.
911
+ *
912
+ * @returns {string} The encoded string.
913
+ */ function encode$1(str) {
914
+ const charMap = {
915
+ '!': '%21',
916
+ "'": '%27',
917
+ '(': '%28',
918
+ ')': '%29',
919
+ '~': '%7E',
920
+ '%20': '+',
921
+ '%00': '\x00'
922
+ };
923
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
924
+ return charMap[match];
925
+ });
926
+ }
927
+ /**
928
+ * It takes a params object and converts it to a FormData object
929
+ *
930
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
931
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
932
+ *
933
+ * @returns {void}
934
+ */ function AxiosURLSearchParams(params, options) {
935
+ this._pairs = [];
936
+ params && toFormData$1(params, this, options);
937
+ }
938
+ const prototype = AxiosURLSearchParams.prototype;
939
+ prototype.append = function append(name, value) {
940
+ this._pairs.push([
941
+ name,
942
+ value
943
+ ]);
944
+ };
945
+ prototype.toString = function toString(encoder) {
946
+ const _encode = encoder ? function(value) {
947
+ return encoder.call(this, value, encode$1);
948
+ } : encode$1;
949
+ return this._pairs.map(function each(pair) {
950
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
951
+ }, '').join('&');
952
+ };
953
+
954
+ /**
955
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
956
+ * URI encoded counterparts
957
+ *
958
+ * @param {string} val The value to be encoded.
959
+ *
960
+ * @returns {string} The encoded value.
961
+ */ function encode(val) {
962
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
963
+ }
964
+ /**
965
+ * Build a URL by appending params to the end
966
+ *
967
+ * @param {string} url The base of the url (e.g., http://www.google.com)
968
+ * @param {object} [params] The params to be appended
969
+ * @param {?object} options
970
+ *
971
+ * @returns {string} The formatted url
972
+ */ function buildURL(url, params, options) {
973
+ /*eslint no-param-reassign:0*/ if (!params) {
974
+ return url;
975
+ }
976
+ const _encode = options && options.encode || encode;
977
+ const serializeFn = options && options.serialize;
978
+ let serializedParams;
979
+ if (serializeFn) {
980
+ serializedParams = serializeFn(params, options);
981
+ } else {
982
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
983
+ }
984
+ if (serializedParams) {
985
+ const hashmarkIndex = url.indexOf("#");
986
+ if (hashmarkIndex !== -1) {
987
+ url = url.slice(0, hashmarkIndex);
988
+ }
989
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
990
+ }
991
+ return url;
992
+ }
993
+
994
+ let InterceptorManager = class InterceptorManager {
995
+ constructor(){
996
+ this.handlers = [];
997
+ }
998
+ /**
999
+ * Add a new interceptor to the stack
1000
+ *
1001
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1002
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1003
+ *
1004
+ * @return {Number} An ID used to remove interceptor later
1005
+ */ use(fulfilled, rejected, options) {
1006
+ this.handlers.push({
1007
+ fulfilled,
1008
+ rejected,
1009
+ synchronous: options ? options.synchronous : false,
1010
+ runWhen: options ? options.runWhen : null
1011
+ });
1012
+ return this.handlers.length - 1;
1013
+ }
1014
+ /**
1015
+ * Remove an interceptor from the stack
1016
+ *
1017
+ * @param {Number} id The ID that was returned by `use`
1018
+ *
1019
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1020
+ */ eject(id) {
1021
+ if (this.handlers[id]) {
1022
+ this.handlers[id] = null;
1023
+ }
1024
+ }
1025
+ /**
1026
+ * Clear all interceptors from the stack
1027
+ *
1028
+ * @returns {void}
1029
+ */ clear() {
1030
+ if (this.handlers) {
1031
+ this.handlers = [];
1032
+ }
1033
+ }
1034
+ /**
1035
+ * Iterate over all the registered interceptors
1036
+ *
1037
+ * This method is particularly useful for skipping over any
1038
+ * interceptors that may have become `null` calling `eject`.
1039
+ *
1040
+ * @param {Function} fn The function to call for each interceptor
1041
+ *
1042
+ * @returns {void}
1043
+ */ forEach(fn) {
1044
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1045
+ if (h !== null) {
1046
+ fn(h);
1047
+ }
1048
+ });
1049
+ }
1050
+ };
1051
+ const InterceptorManager$1 = InterceptorManager;
1052
+
1053
+ const transitionalDefaults = {
1054
+ silentJSONParsing: true,
1055
+ forcedJSONParsing: true,
1056
+ clarifyTimeoutError: false
1057
+ };
1058
+
1059
+ const URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1060
+
1061
+ const FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1062
+
1063
+ const Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1064
+
1065
+ const platform$1 = {
1066
+ isBrowser: true,
1067
+ classes: {
1068
+ URLSearchParams: URLSearchParams$1,
1069
+ FormData: FormData$1,
1070
+ Blob: Blob$1
1071
+ },
1072
+ protocols: [
1073
+ 'http',
1074
+ 'https',
1075
+ 'file',
1076
+ 'blob',
1077
+ 'url',
1078
+ 'data'
1079
+ ]
1080
+ };
1081
+
1082
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1083
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1084
+ /**
1085
+ * Determine if we're running in a standard browser environment
1086
+ *
1087
+ * This allows axios to run in a web worker, and react-native.
1088
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1089
+ *
1090
+ * web workers:
1091
+ * typeof window -> undefined
1092
+ * typeof document -> undefined
1093
+ *
1094
+ * react-native:
1095
+ * navigator.product -> 'ReactNative'
1096
+ * nativescript
1097
+ * navigator.product -> 'NativeScript' or 'NS'
1098
+ *
1099
+ * @returns {boolean}
1100
+ */ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || [
1101
+ 'ReactNative',
1102
+ 'NativeScript',
1103
+ 'NS'
1104
+ ].indexOf(_navigator.product) < 0);
1105
+ /**
1106
+ * Determine if we're running in a standard browser webWorker environment
1107
+ *
1108
+ * Although the `isStandardBrowserEnv` method indicates that
1109
+ * `allows axios to run in a web worker`, the WebWorker will still be
1110
+ * filtered out due to its judgment standard
1111
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1112
+ * This leads to a problem when axios post `FormData` in webWorker
1113
+ */ const hasStandardBrowserWebWorkerEnv = (()=>{
1114
+ return typeof WorkerGlobalScope !== 'undefined' && // eslint-disable-next-line no-undef
1115
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
1116
+ })();
1117
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1118
+
1119
+ const utils = /*#__PURE__*/Object.freeze({
1120
+ __proto__: null,
1121
+ hasBrowserEnv: hasBrowserEnv,
1122
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1123
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1124
+ navigator: _navigator,
1125
+ origin: origin
1126
+ });
1127
+
1128
+ const platform = {
1129
+ ...utils,
1130
+ ...platform$1
1131
+ };
1132
+
1133
+ function toURLEncodedForm(data, options) {
1134
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1135
+ visitor: function(value, key, path, helpers) {
1136
+ if (platform.isNode && utils$1.isBuffer(value)) {
1137
+ this.append(key, value.toString('base64'));
1138
+ return false;
1139
+ }
1140
+ return helpers.defaultVisitor.apply(this, arguments);
1141
+ }
1142
+ }, options));
1143
+ }
1144
+
1145
+ /**
1146
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1147
+ *
1148
+ * @param {string} name - The name of the property to get.
1149
+ *
1150
+ * @returns An array of strings.
1151
+ */ function parsePropPath(name) {
1152
+ // foo[x][y][z]
1153
+ // foo.x.y.z
1154
+ // foo-x-y-z
1155
+ // foo x y z
1156
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match)=>{
1157
+ return match[0] === '[]' ? '' : match[1] || match[0];
1158
+ });
1159
+ }
1160
+ /**
1161
+ * Convert an array to an object.
1162
+ *
1163
+ * @param {Array<any>} arr - The array to convert to an object.
1164
+ *
1165
+ * @returns An object with the same keys and values as the array.
1166
+ */ function arrayToObject(arr) {
1167
+ const obj = {};
1168
+ const keys = Object.keys(arr);
1169
+ let i;
1170
+ const len = keys.length;
1171
+ let key;
1172
+ for(i = 0; i < len; i++){
1173
+ key = keys[i];
1174
+ obj[key] = arr[key];
1175
+ }
1176
+ return obj;
1177
+ }
1178
+ /**
1179
+ * It takes a FormData object and returns a JavaScript object
1180
+ *
1181
+ * @param {string} formData The FormData object to convert to JSON.
1182
+ *
1183
+ * @returns {Object<string, any> | null} The converted object.
1184
+ */ function formDataToJSON(formData) {
1185
+ function buildPath(path, value, target, index) {
1186
+ let name = path[index++];
1187
+ if (name === '__proto__') return true;
1188
+ const isNumericKey = Number.isFinite(+name);
1189
+ const isLast = index >= path.length;
1190
+ name = !name && utils$1.isArray(target) ? target.length : name;
1191
+ if (isLast) {
1192
+ if (utils$1.hasOwnProp(target, name)) {
1193
+ target[name] = [
1194
+ target[name],
1195
+ value
1196
+ ];
1197
+ } else {
1198
+ target[name] = value;
1199
+ }
1200
+ return !isNumericKey;
1201
+ }
1202
+ if (!target[name] || !utils$1.isObject(target[name])) {
1203
+ target[name] = [];
1204
+ }
1205
+ const result = buildPath(path, value, target[name], index);
1206
+ if (result && utils$1.isArray(target[name])) {
1207
+ target[name] = arrayToObject(target[name]);
1208
+ }
1209
+ return !isNumericKey;
1210
+ }
1211
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1212
+ const obj = {};
1213
+ utils$1.forEachEntry(formData, (name, value)=>{
1214
+ buildPath(parsePropPath(name), value, obj, 0);
1215
+ });
1216
+ return obj;
1217
+ }
1218
+ return null;
1219
+ }
1220
+
1221
+ /**
1222
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1223
+ * of the input
1224
+ *
1225
+ * @param {any} rawValue - The value to be stringified.
1226
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1227
+ * @param {Function} encoder - A function that takes a value and returns a string.
1228
+ *
1229
+ * @returns {string} A stringified version of the rawValue.
1230
+ */ function stringifySafely(rawValue, parser, encoder) {
1231
+ if (utils$1.isString(rawValue)) {
1232
+ try {
1233
+ (parser || JSON.parse)(rawValue);
1234
+ return utils$1.trim(rawValue);
1235
+ } catch (e) {
1236
+ if (e.name !== 'SyntaxError') {
1237
+ throw e;
1238
+ }
1239
+ }
1240
+ }
1241
+ return (encoder || JSON.stringify)(rawValue);
1242
+ }
1243
+ const defaults = {
1244
+ transitional: transitionalDefaults,
1245
+ adapter: [
1246
+ 'xhr',
1247
+ 'http',
1248
+ 'fetch'
1249
+ ],
1250
+ transformRequest: [
1251
+ function transformRequest(data, headers) {
1252
+ const contentType = headers.getContentType() || '';
1253
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1254
+ const isObjectPayload = utils$1.isObject(data);
1255
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1256
+ data = new FormData(data);
1257
+ }
1258
+ const isFormData = utils$1.isFormData(data);
1259
+ if (isFormData) {
1260
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1261
+ }
1262
+ if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
1263
+ return data;
1264
+ }
1265
+ if (utils$1.isArrayBufferView(data)) {
1266
+ return data.buffer;
1267
+ }
1268
+ if (utils$1.isURLSearchParams(data)) {
1269
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1270
+ return data.toString();
1271
+ }
1272
+ let isFileList;
1273
+ if (isObjectPayload) {
1274
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1275
+ return toURLEncodedForm(data, this.formSerializer).toString();
1276
+ }
1277
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1278
+ const _FormData = this.env && this.env.FormData;
1279
+ return toFormData$1(isFileList ? {
1280
+ 'files[]': data
1281
+ } : data, _FormData && new _FormData(), this.formSerializer);
1282
+ }
1283
+ }
1284
+ if (isObjectPayload || hasJSONContentType) {
1285
+ headers.setContentType('application/json', false);
1286
+ return stringifySafely(data);
1287
+ }
1288
+ return data;
1289
+ }
1290
+ ],
1291
+ transformResponse: [
1292
+ function transformResponse(data) {
1293
+ const transitional = this.transitional || defaults.transitional;
1294
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1295
+ const JSONRequested = this.responseType === 'json';
1296
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1297
+ return data;
1298
+ }
1299
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1300
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1301
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1302
+ try {
1303
+ return JSON.parse(data);
1304
+ } catch (e) {
1305
+ if (strictJSONParsing) {
1306
+ if (e.name === 'SyntaxError') {
1307
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1308
+ }
1309
+ throw e;
1310
+ }
1311
+ }
1312
+ }
1313
+ return data;
1314
+ }
1315
+ ],
1316
+ /**
1317
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1318
+ * timeout is not created.
1319
+ */ timeout: 0,
1320
+ xsrfCookieName: 'XSRF-TOKEN',
1321
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1322
+ maxContentLength: -1,
1323
+ maxBodyLength: -1,
1324
+ env: {
1325
+ FormData: platform.classes.FormData,
1326
+ Blob: platform.classes.Blob
1327
+ },
1328
+ validateStatus: function validateStatus(status) {
1329
+ return status >= 200 && status < 300;
1330
+ },
1331
+ headers: {
1332
+ common: {
1333
+ 'Accept': 'application/json, text/plain, */*',
1334
+ 'Content-Type': undefined
1335
+ }
1336
+ }
1337
+ };
1338
+ utils$1.forEach([
1339
+ 'delete',
1340
+ 'get',
1341
+ 'head',
1342
+ 'post',
1343
+ 'put',
1344
+ 'patch'
1345
+ ], (method)=>{
1346
+ defaults.headers[method] = {};
1347
+ });
1348
+ const defaults$1 = defaults;
1349
+
1350
+ // RawAxiosHeaders whose duplicates are ignored by node
1351
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1352
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1353
+ 'age',
1354
+ 'authorization',
1355
+ 'content-length',
1356
+ 'content-type',
1357
+ 'etag',
1358
+ 'expires',
1359
+ 'from',
1360
+ 'host',
1361
+ 'if-modified-since',
1362
+ 'if-unmodified-since',
1363
+ 'last-modified',
1364
+ 'location',
1365
+ 'max-forwards',
1366
+ 'proxy-authorization',
1367
+ 'referer',
1368
+ 'retry-after',
1369
+ 'user-agent'
1370
+ ]);
1371
+ /**
1372
+ * Parse headers into an object
1373
+ *
1374
+ * ```
1375
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1376
+ * Content-Type: application/json
1377
+ * Connection: keep-alive
1378
+ * Transfer-Encoding: chunked
1379
+ * ```
1380
+ *
1381
+ * @param {String} rawHeaders Headers needing to be parsed
1382
+ *
1383
+ * @returns {Object} Headers parsed into an object
1384
+ */ const parseHeaders = ((rawHeaders)=>{
1385
+ const parsed = {};
1386
+ let key;
1387
+ let val;
1388
+ let i;
1389
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1390
+ i = line.indexOf(':');
1391
+ key = line.substring(0, i).trim().toLowerCase();
1392
+ val = line.substring(i + 1).trim();
1393
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1394
+ return;
1395
+ }
1396
+ if (key === 'set-cookie') {
1397
+ if (parsed[key]) {
1398
+ parsed[key].push(val);
1399
+ } else {
1400
+ parsed[key] = [
1401
+ val
1402
+ ];
1403
+ }
1404
+ } else {
1405
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1406
+ }
1407
+ });
1408
+ return parsed;
1409
+ });
1410
+
1411
+ var _computedKey, _computedKey1;
1412
+ const $internals = Symbol('internals');
1413
+ function normalizeHeader(header) {
1414
+ return header && String(header).trim().toLowerCase();
1415
+ }
1416
+ function normalizeValue(value) {
1417
+ if (value === false || value == null) {
1418
+ return value;
1419
+ }
1420
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1421
+ }
1422
+ function parseTokens(str) {
1423
+ const tokens = Object.create(null);
1424
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1425
+ let match;
1426
+ while(match = tokensRE.exec(str)){
1427
+ tokens[match[1]] = match[2];
1428
+ }
1429
+ return tokens;
1430
+ }
1431
+ const isValidHeaderName = (str)=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1432
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1433
+ if (utils$1.isFunction(filter)) {
1434
+ return filter.call(this, value, header);
1435
+ }
1436
+ if (isHeaderNameFilter) {
1437
+ value = header;
1438
+ }
1439
+ if (!utils$1.isString(value)) return;
1440
+ if (utils$1.isString(filter)) {
1441
+ return value.indexOf(filter) !== -1;
1442
+ }
1443
+ if (utils$1.isRegExp(filter)) {
1444
+ return filter.test(value);
1445
+ }
1446
+ }
1447
+ function formatHeader(header) {
1448
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str)=>{
1449
+ return char.toUpperCase() + str;
1450
+ });
1451
+ }
1452
+ function buildAccessors(obj, header) {
1453
+ const accessorName = utils$1.toCamelCase(' ' + header);
1454
+ [
1455
+ 'get',
1456
+ 'set',
1457
+ 'has'
1458
+ ].forEach((methodName)=>{
1459
+ Object.defineProperty(obj, methodName + accessorName, {
1460
+ value: function(arg1, arg2, arg3) {
1461
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1462
+ },
1463
+ configurable: true
1464
+ });
1465
+ });
1466
+ }
1467
+ _computedKey = Symbol.iterator, _computedKey1 = Symbol.toStringTag;
1468
+ let AxiosHeaders$1 = class AxiosHeaders {
1469
+ constructor(headers){
1470
+ headers && this.set(headers);
1471
+ }
1472
+ /**
1473
+ *
1474
+ * @param {*} header
1475
+ * @param {*} valueOrRewrite
1476
+ * @param {*} rewrite true:无论源值是否存在均赋值,false:源值如存在不覆盖,
1477
+ * undefined:源值不为 false 直接赋值,false 不赋值
1478
+ * @returns
1479
+ */ set(header, valueOrRewrite, rewrite) {
1480
+ const self = this;
1481
+ function setHeader(_value, _header, _rewrite) {
1482
+ const lHeader = normalizeHeader(_header);
1483
+ if (!lHeader) {
1484
+ throw new Error('header name must be a non-empty string');
1485
+ }
1486
+ const key = utils$1.findKey(self, lHeader);
1487
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1488
+ self[key || _header] = normalizeValue(_value);
1489
+ }
1490
+ }
1491
+ const setHeaders = (headers, _rewrite)=>utils$1.forEach(headers, (_value, _header)=>setHeader(_value, _header, _rewrite));
1492
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1493
+ setHeaders(header, valueOrRewrite);
1494
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1495
+ setHeaders(parseHeaders(header), valueOrRewrite);
1496
+ } else if (utils$1.isHeaders(header)) {
1497
+ for (const [key, value] of header.entries()){
1498
+ setHeader(value, key, rewrite);
1499
+ }
1500
+ } else {
1501
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1502
+ }
1503
+ return this;
1504
+ }
1505
+ get(header, parser) {
1506
+ header = normalizeHeader(header);
1507
+ if (header) {
1508
+ const key = utils$1.findKey(this, header);
1509
+ if (key) {
1510
+ const value = this[key];
1511
+ if (!parser) {
1512
+ return value;
1513
+ }
1514
+ if (parser === true) {
1515
+ return parseTokens(value);
1516
+ }
1517
+ if (utils$1.isFunction(parser)) {
1518
+ return parser.call(this, value, key);
1519
+ }
1520
+ if (utils$1.isRegExp(parser)) {
1521
+ return parser.exec(value);
1522
+ }
1523
+ throw new TypeError('parser must be boolean|regexp|function');
1524
+ }
1525
+ }
1526
+ }
1527
+ has(header, matcher) {
1528
+ header = normalizeHeader(header);
1529
+ if (header) {
1530
+ const key = utils$1.findKey(this, header);
1531
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1532
+ }
1533
+ return false;
1534
+ }
1535
+ delete(header, matcher) {
1536
+ const self = this;
1537
+ let deleted = false;
1538
+ function deleteHeader(_header) {
1539
+ _header = normalizeHeader(_header);
1540
+ if (_header) {
1541
+ const key = utils$1.findKey(self, _header);
1542
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1543
+ delete self[key];
1544
+ deleted = true;
1545
+ }
1546
+ }
1547
+ }
1548
+ if (utils$1.isArray(header)) {
1549
+ header.forEach(deleteHeader);
1550
+ } else {
1551
+ deleteHeader(header);
1552
+ }
1553
+ return deleted;
1554
+ }
1555
+ clear(matcher) {
1556
+ const keys = Object.keys(this);
1557
+ let i = keys.length;
1558
+ let deleted = false;
1559
+ while(i--){
1560
+ const key = keys[i];
1561
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1562
+ delete this[key];
1563
+ deleted = true;
1564
+ }
1565
+ }
1566
+ return deleted;
1567
+ }
1568
+ normalize(format) {
1569
+ const self = this;
1570
+ const headers = {};
1571
+ utils$1.forEach(this, (value, header)=>{
1572
+ const key = utils$1.findKey(headers, header);
1573
+ if (key) {
1574
+ self[key] = normalizeValue(value);
1575
+ delete self[header];
1576
+ return;
1577
+ }
1578
+ const normalized = format ? formatHeader(header) : String(header).trim();
1579
+ if (normalized !== header) {
1580
+ delete self[header];
1581
+ }
1582
+ self[normalized] = normalizeValue(value);
1583
+ headers[normalized] = true;
1584
+ });
1585
+ return this;
1586
+ }
1587
+ concat(...targets) {
1588
+ return this.constructor.concat(this, ...targets);
1589
+ }
1590
+ toJSON(asStrings) {
1591
+ const obj = Object.create(null);
1592
+ utils$1.forEach(this, (value, header)=>{
1593
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1594
+ });
1595
+ return obj;
1596
+ }
1597
+ [_computedKey]() {
1598
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1599
+ }
1600
+ toString() {
1601
+ return Object.entries(this.toJSON()).map(([header, value])=>header + ': ' + value).join('\n');
1602
+ }
1603
+ get [_computedKey1]() {
1604
+ return 'AxiosHeaders';
1605
+ }
1606
+ static from(thing) {
1607
+ return thing instanceof this ? thing : new this(thing);
1608
+ }
1609
+ static concat(first, ...targets) {
1610
+ const computed = new this(first);
1611
+ targets.forEach((target)=>computed.set(target));
1612
+ return computed;
1613
+ }
1614
+ static accessor(header) {
1615
+ const internals = this[$internals] = this[$internals] = {
1616
+ accessors: {}
1617
+ };
1618
+ const accessors = internals.accessors;
1619
+ const prototype = this.prototype;
1620
+ function defineAccessor(_header) {
1621
+ const lHeader = normalizeHeader(_header);
1622
+ if (!accessors[lHeader]) {
1623
+ buildAccessors(prototype, _header);
1624
+ accessors[lHeader] = true;
1625
+ }
1626
+ }
1627
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1628
+ return this;
1629
+ }
1630
+ };
1631
+ AxiosHeaders$1.accessor([
1632
+ 'Content-Type',
1633
+ 'Content-Length',
1634
+ 'Accept',
1635
+ 'Accept-Encoding',
1636
+ 'User-Agent',
1637
+ 'Authorization'
1638
+ ]);
1639
+ // reserved names hotfix
1640
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key)=>{
1641
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1642
+ return {
1643
+ get: ()=>value,
1644
+ set (headerValue) {
1645
+ this[mapped] = headerValue;
1646
+ }
1647
+ };
1648
+ });
1649
+ utils$1.freezeMethods(AxiosHeaders$1);
1650
+ const AxiosHeaders$2 = AxiosHeaders$1;
1651
+
1652
+ /**
1653
+ * Transform the data for a request or a response
1654
+ *
1655
+ * @param {Array|Function} fns A single function or Array of functions
1656
+ * @param {?Object} response The response object
1657
+ *
1658
+ * @returns {*} The resulting transformed data
1659
+ */ function transformData(fns, response) {
1660
+ const config = this || defaults$1;
1661
+ const context = response || config;
1662
+ const headers = AxiosHeaders$2.from(context.headers);
1663
+ let data = context.data;
1664
+ utils$1.forEach(fns, function transform(fn) {
1665
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1666
+ });
1667
+ headers.normalize();
1668
+ return data;
1669
+ }
1670
+
1671
+ function isCancel$1(value) {
1672
+ return !!(value && value.__CANCEL__);
1673
+ }
1674
+
1675
+ /**
1676
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1677
+ *
1678
+ * @param {string=} message The message.
1679
+ * @param {Object=} config The config.
1680
+ * @param {Object=} request The request.
1681
+ *
1682
+ * @returns {CanceledError} The created error.
1683
+ */ function CanceledError$1(message, config, request) {
1684
+ // eslint-disable-next-line no-eq-null,eqeqeq
1685
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1686
+ this.name = 'CanceledError';
1687
+ }
1688
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1689
+ __CANCEL__: true
1690
+ });
1691
+
1692
+ /**
1693
+ * Determines whether the specified URL is absolute
1694
+ *
1695
+ * @param {string} url The URL to test
1696
+ *
1697
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1698
+ */ function isAbsoluteURL(url) {
1699
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1700
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1701
+ // by any combination of letters, digits, plus, period, or hyphen.
1702
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1703
+ }
1704
+
1705
+ /**
1706
+ * Creates a new URL by combining the specified URLs
1707
+ *
1708
+ * @param {string} baseURL The base URL
1709
+ * @param {string} relativeURL The relative URL
1710
+ *
1711
+ * @returns {string} The combined URL
1712
+ */ function combineURLs(baseURL, relativeURL) {
1713
+ return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
1714
+ }
1715
+
1716
+ /**
1717
+ * Creates a new URL by combining the baseURL with the requestedURL,
1718
+ * only when the requestedURL is not already an absolute URL.
1719
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1720
+ *
1721
+ * @param {string} baseURL The base URL
1722
+ * @param {string} requestedURL Absolute or relative URL to combine
1723
+ *
1724
+ * @returns {string} The combined full path
1725
+ */ function buildFullPath(baseURL, requestedURL) {
1726
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1727
+ return combineURLs(baseURL, requestedURL);
1728
+ }
1729
+ return requestedURL;
1730
+ }
1731
+
1732
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
1733
+ let XhrAdapter = class XhrAdapter {
1734
+ constructor(config){
1735
+ this.init(config);
1736
+ }
1737
+ init(config) {}
1738
+ request() {}
1739
+ stream() {}
1740
+ };
1741
+ const XhrAdapter$1 = isXHRAdapterSupported && XhrAdapter;
1742
+
1743
+ const knownAdapters = {
1744
+ http: HttpAdapter,
1745
+ xhr: XhrAdapter$1
1746
+ };
1747
+ /**
1748
+ * define adapter's name and adapterName to http or xhr
1749
+ * browser: httpAdapter is null!
1750
+ */ utils$1.forEach(knownAdapters, (val, key)=>{
1751
+ if (val) {
1752
+ try {
1753
+ Object.defineProperty(val, 'name', {
1754
+ value: key
1755
+ });
1756
+ } catch (e) {
1757
+ // eslint-disable-next-line no-empty
1758
+ }
1759
+ Object.defineProperty(val, 'adapterName', {
1760
+ value: key
1761
+ });
1762
+ }
1763
+ });
1764
+ const adapters = {
1765
+ /**
1766
+ * get http or xhr adapter
1767
+ * @param {*} adapters user pass or ['xhr', 'http']
1768
+ * @returns
1769
+ */ getAdapter: (adapters)=>{
1770
+ adapters = utils$1.isArray(adapters) ? adapters : [
1771
+ adapters
1772
+ ];
1773
+ const { length } = adapters;
1774
+ let nameOrAdapter;
1775
+ let adapter;
1776
+ // find not null adapter
1777
+ for(let i = 0; i < length; i++){
1778
+ nameOrAdapter = adapters[i];
1779
+ if (adapter = utils$1.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
1780
+ break;
1781
+ }
1782
+ }
1783
+ if (!adapter) {
1784
+ if (adapter === false) {
1785
+ throw new AxiosError$1(`Adapter ${nameOrAdapter} is not supported by the environment`, 'ERR_NOT_SUPPORT');
1786
+ }
1787
+ throw new Error(utils$1.hasOwnProp(knownAdapters, nameOrAdapter) ? `Adapter '${nameOrAdapter}' is not available in the build` : `Unknown adapter '${nameOrAdapter}'`);
1788
+ }
1789
+ if (!utils$1.isFunction(adapter)) {
1790
+ throw new TypeError('adapter is not a function');
1791
+ }
1792
+ return adapter;
1793
+ },
1794
+ adapters: knownAdapters
1795
+ };
1796
+
1797
+ /**
1798
+ * Throws a `CanceledError` if cancellation has been requested.
1799
+ *
1800
+ * @param {Object} config The config that is to be used for the request
1801
+ *
1802
+ * @returns {void}
1803
+ */ function throwIfCancellationRequested(config) {
1804
+ if (config.cancelToken) {
1805
+ config.cancelToken.throwIfRequested();
1806
+ }
1807
+ if (config.signal && config.signal.aborted) {
1808
+ throw new CanceledError$1(null, config);
1809
+ }
1810
+ }
1811
+ /**
1812
+ * Dispatch a request to the server using the configured adapter.
1813
+ * 请求如有异常,需向外抛出异常,不拦截
1814
+ * @param {object} config The config that is to be used for the request
1815
+ *
1816
+ * @returns {Promise<*>} The Promise to be fulfilled
1817
+ */ function dispatchRequest(config) {
1818
+ let R;
1819
+ throwIfCancellationRequested(config);
1820
+ config.headers = AxiosHeaders$2.from(config.headers);
1821
+ // Transform request data
1822
+ config.data = transformData.call(config, config.transformRequest);
1823
+ if ([
1824
+ 'post',
1825
+ 'put',
1826
+ 'patch'
1827
+ ].indexOf(config.method) !== -1) {
1828
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
1829
+ }
1830
+ const Adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
1831
+ const adapter = new Adapter(config);
1832
+ if (config.stream) R = adapter.request(this);
1833
+ else {
1834
+ R = adapter.request(this).then((response)=>{
1835
+ throwIfCancellationRequested(config);
1836
+ // Transform response data
1837
+ response.data = transformData.call(config, config.transformResponse, response);
1838
+ // ! body === data
1839
+ Object.defineProperty(response, 'body', {
1840
+ get () {
1841
+ return response.data;
1842
+ }
1843
+ });
1844
+ // if (response.data && !response.body) response.body = response.data
1845
+ response.headers = AxiosHeaders$2.from(response.headers);
1846
+ return response;
1847
+ }, (reason)=>{
1848
+ if (!isCancel$1(reason)) {
1849
+ throwIfCancellationRequested(config);
1850
+ // Transform response data
1851
+ if (reason && reason.response) {
1852
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
1853
+ // body === data
1854
+ if (reason.response.data && !reason.response.body) reason.response.body = reason.response.data;
1855
+ reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
1856
+ }
1857
+ }
1858
+ return Promise.reject(reason);
1859
+ });
1860
+ }
1861
+ return R;
1862
+ }
1863
+
1864
+ const headersToObject = (thing)=>thing instanceof AxiosHeaders$2 ? {
1865
+ ...thing
1866
+ } : thing;
1867
+ /**
1868
+ * Config-specific merge-function which creates a new config-object
1869
+ * by merging two configuration objects together.
1870
+ *
1871
+ * @param {Object} config1
1872
+ * @param {Object} config2
1873
+ *
1874
+ * @returns {Object} New object resulting from merging config2 to config1
1875
+ */ function mergeConfig$1(config1, config2) {
1876
+ // eslint-disable-next-line no-param-reassign
1877
+ config2 = config2 || {};
1878
+ const config = {};
1879
+ function getMergedValue(target, source, caseless) {
1880
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
1881
+ return utils$1.merge.call({
1882
+ caseless
1883
+ }, target, source);
1884
+ } else if (utils$1.isPlainObject(source)) {
1885
+ return utils$1.merge({}, source);
1886
+ } else if (utils$1.isArray(source)) {
1887
+ return source.slice();
1888
+ }
1889
+ return source;
1890
+ }
1891
+ // eslint-disable-next-line consistent-return
1892
+ function mergeDeepProperties(a, b, caseless) {
1893
+ if (!utils$1.isUndefined(b)) {
1894
+ return getMergedValue(a, b, caseless);
1895
+ } else if (!utils$1.isUndefined(a)) {
1896
+ return getMergedValue(undefined, a, caseless);
1897
+ }
1898
+ }
1899
+ // eslint-disable-next-line consistent-return
1900
+ function valueFromConfig2(a, b) {
1901
+ if (!utils$1.isUndefined(b)) {
1902
+ return getMergedValue(undefined, b);
1903
+ }
1904
+ }
1905
+ // eslint-disable-next-line consistent-return
1906
+ function defaultToConfig2(a, b) {
1907
+ if (!utils$1.isUndefined(b)) {
1908
+ return getMergedValue(undefined, b);
1909
+ } else if (!utils$1.isUndefined(a)) {
1910
+ return getMergedValue(undefined, a);
1911
+ }
1912
+ }
1913
+ // eslint-disable-next-line consistent-return
1914
+ function mergeDirectKeys(a, b, prop) {
1915
+ if (prop in config2) {
1916
+ return getMergedValue(a, b);
1917
+ } else if (prop in config1) {
1918
+ return getMergedValue(undefined, a);
1919
+ }
1920
+ }
1921
+ const mergeMap = {
1922
+ url: valueFromConfig2,
1923
+ method: valueFromConfig2,
1924
+ data: valueFromConfig2,
1925
+ baseURL: defaultToConfig2,
1926
+ transformRequest: defaultToConfig2,
1927
+ transformResponse: defaultToConfig2,
1928
+ paramsSerializer: defaultToConfig2,
1929
+ timeout: defaultToConfig2,
1930
+ timeoutMessage: defaultToConfig2,
1931
+ withCredentials: defaultToConfig2,
1932
+ withXSRFToken: defaultToConfig2,
1933
+ adapter: defaultToConfig2,
1934
+ responseType: defaultToConfig2,
1935
+ xsrfCookieName: defaultToConfig2,
1936
+ xsrfHeaderName: defaultToConfig2,
1937
+ onUploadProgress: defaultToConfig2,
1938
+ onDownloadProgress: defaultToConfig2,
1939
+ decompress: defaultToConfig2,
1940
+ maxContentLength: defaultToConfig2,
1941
+ maxBodyLength: defaultToConfig2,
1942
+ beforeRedirect: defaultToConfig2,
1943
+ transport: defaultToConfig2,
1944
+ httpAgent: defaultToConfig2,
1945
+ httpsAgent: defaultToConfig2,
1946
+ cancelToken: defaultToConfig2,
1947
+ socketPath: defaultToConfig2,
1948
+ responseEncoding: defaultToConfig2,
1949
+ validateStatus: mergeDirectKeys,
1950
+ headers: (a, b)=>mergeDeepProperties(headersToObject(a), headersToObject(b), true)
1951
+ };
1952
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
1953
+ const merge = mergeMap[prop] || mergeDeepProperties;
1954
+ const configValue = merge(config1[prop], config2[prop], prop);
1955
+ utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
1956
+ });
1957
+ return config;
1958
+ }
1959
+
1960
+ const VERSION$1 = "1.7.7";
1961
+
1962
+ const validators$1 = {};
1963
+ // eslint-disable-next-line func-names
1964
+ [
1965
+ 'object',
1966
+ 'boolean',
1967
+ 'number',
1968
+ 'function',
1969
+ 'string',
1970
+ 'symbol'
1971
+ ].forEach((type, i)=>{
1972
+ validators$1[type] = function validator(thing) {
1973
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
1974
+ };
1975
+ });
1976
+ const deprecatedWarnings = {};
1977
+ /**
1978
+ * Transitional option validator
1979
+ *
1980
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
1981
+ * @param {string?} version - deprecated version / removed since version
1982
+ * @param {string?} message - some message with additional info
1983
+ *
1984
+ * @returns {function}
1985
+ */ validators$1.transitional = function transitional(validator, version, message) {
1986
+ function formatMessage(opt, desc) {
1987
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
1988
+ }
1989
+ // eslint-disable-next-line func-names
1990
+ return (value, opt, opts)=>{
1991
+ if (validator === false) {
1992
+ throw new AxiosError$1(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError$1.ERR_DEPRECATED);
1993
+ }
1994
+ if (version && !deprecatedWarnings[opt]) {
1995
+ deprecatedWarnings[opt] = true;
1996
+ // eslint-disable-next-line no-console
1997
+ console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
1998
+ }
1999
+ return validator ? validator(value, opt, opts) : true;
2000
+ };
2001
+ };
2002
+ validators$1.spelling = function spelling(correctSpelling) {
2003
+ return (value, opt)=>{
2004
+ // eslint-disable-next-line no-console
2005
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2006
+ return true;
2007
+ };
2008
+ };
2009
+ /**
2010
+ * Assert object's properties type
2011
+ *
2012
+ * @param {object} options
2013
+ * @param {object} schema
2014
+ * @param {boolean?} allowUnknown
2015
+ *
2016
+ * @returns {object}
2017
+ */ function assertOptions(options, schema, allowUnknown) {
2018
+ if (typeof options !== 'object') {
2019
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2020
+ }
2021
+ const keys = Object.keys(options);
2022
+ let i = keys.length;
2023
+ while(i-- > 0){
2024
+ const opt = keys[i];
2025
+ const validator = schema[opt];
2026
+ if (validator) {
2027
+ const value = options[opt];
2028
+ const result = value === undefined || validator(value, opt, options);
2029
+ if (result !== true) {
2030
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2031
+ }
2032
+ continue;
2033
+ }
2034
+ if (allowUnknown !== true) {
2035
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2036
+ }
2037
+ }
2038
+ }
2039
+ const validator = {
2040
+ assertOptions,
2041
+ validators: validators$1
2042
+ };
2043
+
2044
+ const { validators } = validator;
2045
+ /**
2046
+ * Create a new instance of Axios
2047
+ *
2048
+ * @param {Object} instanceConfig The default config for the instance
2049
+ *
2050
+ * @return {Axios} A new instance of Axios
2051
+ */ let Axios$1 = class Axios {
2052
+ constructor(instanceConfig){
2053
+ this.defaults = instanceConfig;
2054
+ this.config = this.defaults // !+++
2055
+ ;
2056
+ this.interceptors = {
2057
+ request: new InterceptorManager$1(),
2058
+ response: new InterceptorManager$1()
2059
+ };
2060
+ this.init() // !+++
2061
+ ;
2062
+ }
2063
+ /**
2064
+ * !+++
2065
+ * config 属性直接挂在到实例上,方便读取、设置、修改
2066
+ * 需注意,不要与其属性、方法冲突!!!
2067
+ request(config)
2068
+ get(url[, config])
2069
+ delete(url[, config])
2070
+ head(url[, config])
2071
+ options(url[, config])
2072
+ post(url[, data[, config]])
2073
+ put(url[, data[, config]])
2074
+ patch(url[, data[, config]])
2075
+ getUri([config])
2076
+ */ init() {
2077
+ const m = this;
2078
+ [
2079
+ 'url',
2080
+ 'method',
2081
+ 'baseURL',
2082
+ 'transformRequest',
2083
+ 'transformResponse',
2084
+ 'headers',
2085
+ 'params',
2086
+ 'paramsSerializer',
2087
+ 'body',
2088
+ 'data',
2089
+ 'timeout',
2090
+ 'withCredentials',
2091
+ 'adapter',
2092
+ 'auth',
2093
+ 'responseType',
2094
+ 'responseEncoding',
2095
+ 'xsrfCookieName',
2096
+ 'xsrfHeaderName',
2097
+ 'onUploadProgress',
2098
+ 'onDownloadProgress',
2099
+ 'maxContentLength',
2100
+ 'maxBodyLength',
2101
+ 'validateStatus',
2102
+ 'maxRedirects',
2103
+ 'beforeRedirect',
2104
+ 'socketPath',
2105
+ 'httpAgent',
2106
+ 'httpsAgent',
2107
+ 'agent',
2108
+ 'cancelToken',
2109
+ 'signal',
2110
+ 'decompress',
2111
+ 'insecureHTTPParser',
2112
+ 'transitional',
2113
+ 'env',
2114
+ 'formSerializer',
2115
+ 'maxRate'
2116
+ ].forEach((p)=>Object.defineProperty(m, p, {
2117
+ enumerable: true,
2118
+ get () {
2119
+ return m.config[p];
2120
+ },
2121
+ set (value) {
2122
+ m.config[p] = value;
2123
+ }
2124
+ }));
2125
+ }
2126
+ /**
2127
+ * Dispatch a request
2128
+ * 启动执行请求,返回 Promise 实例
2129
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2130
+ * @param {?Object} config
2131
+ * @returns {Promise} The Promise to be fulfilled
2132
+ */ async request(configOrUrl, config) {
2133
+ try {
2134
+ return await this._request(configOrUrl, config);
2135
+ } catch (err) {
2136
+ if (err instanceof Error) {
2137
+ let dummy = {};
2138
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
2139
+ // slice off the Error: ... line
2140
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
2141
+ try {
2142
+ if (!err.stack) {
2143
+ err.stack = stack;
2144
+ // match without the 2 top stack lines
2145
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
2146
+ err.stack += '\n' + stack;
2147
+ }
2148
+ } catch (e) {
2149
+ // ignore the case where "stack" is an un-writable property
2150
+ }
2151
+ }
2152
+ throw err // 抛出异常
2153
+ ;
2154
+ }
2155
+ }
2156
+ /**
2157
+ * 执行请求
2158
+ * @param {*} configOrUrl
2159
+ * @param {*} config
2160
+ * @param {boolean} [stream = false] - 是否返回 stream
2161
+ * @returns
2162
+ */ _request(configOrUrl, config, stream = false) {
2163
+ let R = null;
2164
+ /* eslint no-param-reassign:0 */ // Allow for axios('example/url'[, config]) a la fetch API
2165
+ if (typeof configOrUrl === 'string') {
2166
+ config = config || {};
2167
+ config.url = configOrUrl;
2168
+ } else {
2169
+ config = configOrUrl || {};
2170
+ }
2171
+ // ! body as data alias, body ==> data,内部保持data不变
2172
+ if (!config.data && config.body) {
2173
+ config.data = config.body;
2174
+ // config.body = undefined;
2175
+ }
2176
+ config = mergeConfig$1(this.defaults, config);
2177
+ const { transitional, paramsSerializer, headers } = config;
2178
+ if (transitional !== undefined) {
2179
+ validator.assertOptions(transitional, {
2180
+ silentJSONParsing: validators.transitional(validators.boolean),
2181
+ forcedJSONParsing: validators.transitional(validators.boolean),
2182
+ clarifyTimeoutError: validators.transitional(validators.boolean)
2183
+ }, false);
2184
+ }
2185
+ if (paramsSerializer) {
2186
+ if (utils$1.isFunction(paramsSerializer)) {
2187
+ config.paramsSerializer = {
2188
+ serialize: paramsSerializer
2189
+ };
2190
+ } else {
2191
+ validator.assertOptions(paramsSerializer, {
2192
+ encode: validators.function,
2193
+ serialize: validators.function
2194
+ }, true);
2195
+ }
2196
+ }
2197
+ validator.assertOptions(config, {
2198
+ baseUrl: validators.spelling('baseURL'),
2199
+ withXsrfToken: validators.spelling('withXSRFToken')
2200
+ }, true);
2201
+ // Set config.method
2202
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
2203
+ // Flatten headers,方法头覆盖通用头
2204
+ const contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
2205
+ headers && utils$1.forEach([
2206
+ 'delete',
2207
+ 'get',
2208
+ 'head',
2209
+ 'post',
2210
+ 'put',
2211
+ 'patch',
2212
+ 'common'
2213
+ ], (method)=>{
2214
+ delete headers[method];
2215
+ });
2216
+ // 源值存在,则不覆盖,contextHeaders 优先于 headers
2217
+ config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
2218
+ // filter out skipped interceptors
2219
+ const requestInterceptorChain = [] // 请求拦截器,hook
2220
+ ;
2221
+ let synchronousRequestInterceptors = true;
2222
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2223
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
2224
+ return;
2225
+ }
2226
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2227
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2228
+ });
2229
+ const responseInterceptorChain = [] // 响应拦截器,hook
2230
+ ;
2231
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2232
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2233
+ });
2234
+ let promise;
2235
+ let i = 0;
2236
+ let len;
2237
+ debugger;
2238
+ // 执行dispatchRequest
2239
+ // !+++ stream
2240
+ if (stream) {
2241
+ config.stream = true;
2242
+ R = dispatchRequest.call(this, config) // not promise
2243
+ ;
2244
+ } else if (!synchronousRequestInterceptors) {
2245
+ // 异步拦截器
2246
+ const chain = [
2247
+ dispatchRequest.bind(this),
2248
+ undefined
2249
+ ] // dispatchRequest 放入运行链
2250
+ ;
2251
+ chain.unshift(...requestInterceptorChain) // !*** 插入头
2252
+ ;
2253
+ chain.push(...responseInterceptorChain) // !*** 加入尾
2254
+ ;
2255
+ len = chain.length;
2256
+ promise = Promise.resolve(config) // promise 对象
2257
+ ;
2258
+ // 传入config配置,按顺序执行
2259
+ while(i < len)promise = promise.then(chain[i++], chain[i++]);
2260
+ R = promise;
2261
+ } else {
2262
+ // 同步拦截器
2263
+ len = requestInterceptorChain.length;
2264
+ let newConfig = config;
2265
+ i = 0;
2266
+ // 按加入顺序运行 request 拦截器
2267
+ while(i < len){
2268
+ const onFulfilled = requestInterceptorChain[i++];
2269
+ const onRejected = requestInterceptorChain[i++];
2270
+ try {
2271
+ newConfig = onFulfilled(newConfig) // 执行
2272
+ ;
2273
+ } catch (error) {
2274
+ onRejected.call(this, error);
2275
+ break;
2276
+ }
2277
+ }
2278
+ try {
2279
+ promise = dispatchRequest.call(this, newConfig);
2280
+ i = 0;
2281
+ len = responseInterceptorChain.length;
2282
+ // 按顺序执行响应 hook
2283
+ while(i < len)promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2284
+ R = promise;
2285
+ } catch (error) {
2286
+ R = Promise.reject(error);
2287
+ }
2288
+ }
2289
+ return R;
2290
+ }
2291
+ /**
2292
+ * !+++
2293
+ * 类似 request 库,返回 stream
2294
+ * stream 模式下,拦截器无效
2295
+ * 如需拦截器,请使用 responseType: 'stream',data 为 stream 传出
2296
+ * 或者 将 stream 作为 data 传入
2297
+ * @param {*} configOrUrl
2298
+ * @param {*} config
2299
+ * @returns
2300
+ */ stream(configOrUrl, config) {
2301
+ return this._request(configOrUrl, config, true);
2302
+ }
2303
+ /**
2304
+ *
2305
+ * @param {*} config
2306
+ * @returns
2307
+ */ getUri(config) {
2308
+ config = mergeConfig$1(this.defaults, config);
2309
+ const fullPath = buildFullPath(config.baseURL, config.url);
2310
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2311
+ }
2312
+ };
2313
+ // Provide aliases for supported request methods
2314
+ utils$1.forEach([
2315
+ 'head',
2316
+ 'options'
2317
+ ], function forEachMethodNoData(method) {
2318
+ /* eslint func-names:0 */ Axios$1.prototype[method] = function(url, config) {
2319
+ return this.request(mergeConfig$1(config || {}, {
2320
+ method,
2321
+ url,
2322
+ data: (config || {}).data
2323
+ }));
2324
+ };
2325
+ });
2326
+ // delete、get, 与 axios不同,第二个参数为 params,而不是 data
2327
+ utils$1.forEach([
2328
+ 'delete',
2329
+ 'get'
2330
+ ], function forEachMethodNoData(method) {
2331
+ Axios$1.prototype[method] = function(url, params, config) {
2332
+ return this.request(mergeConfig$1(config || {}, {
2333
+ method,
2334
+ url,
2335
+ params
2336
+ }));
2337
+ };
2338
+ });
2339
+ utils$1.forEach([
2340
+ 'post',
2341
+ 'put',
2342
+ 'patch'
2343
+ ], function forEachMethodWithData(method) {
2344
+ function generateHTTPMethod(isForm) {
2345
+ return function httpMethod(url, data, config) {
2346
+ return this.request(mergeConfig$1(config || {}, {
2347
+ method,
2348
+ headers: isForm ? {
2349
+ 'Content-Type': 'multipart/form-data'
2350
+ } : {},
2351
+ url,
2352
+ data
2353
+ }));
2354
+ };
2355
+ }
2356
+ Axios$1.prototype[method] = generateHTTPMethod();
2357
+ Axios$1.prototype[`${method}Form`] = generateHTTPMethod(true);
2358
+ });
2359
+ // stream get, 与 axios不同,第二个参数为 params,而不是 data
2360
+ utils$1.forEach([
2361
+ 'gets'
2362
+ ], function forEachMethodNoData(method) {
2363
+ Axios$1.prototype[method] = function(url, params, config) {
2364
+ return this.stream(mergeConfig$1(config || {}, {
2365
+ method,
2366
+ url,
2367
+ params,
2368
+ data: (config || {}).data
2369
+ }));
2370
+ };
2371
+ });
2372
+ // stream post put patch
2373
+ utils$1.forEach([
2374
+ 'posts',
2375
+ 'puts',
2376
+ 'patchs'
2377
+ ], function forEachMethodWithData(method) {
2378
+ function generateStreamMethod(isForm) {
2379
+ return function httpMethod(url, data, config) {
2380
+ return this.stream(mergeConfig$1(config || {}, {
2381
+ method,
2382
+ headers: isForm ? {
2383
+ 'Content-Type': 'multipart/form-data'
2384
+ } : {},
2385
+ url,
2386
+ data
2387
+ }));
2388
+ };
2389
+ }
2390
+ Axios$1.prototype[method] = generateStreamMethod();
2391
+ Axios$1.prototype[`${method}Forms`] = generateStreamMethod(true);
2392
+ });
2393
+ const Axios$2 = Axios$1;
2394
+
2395
+ /**
2396
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
2397
+ *
2398
+ * @param {Function} executor The executor function.
2399
+ *
2400
+ * @returns {CancelToken}
2401
+ */ let CancelToken$1 = class CancelToken {
2402
+ constructor(executor){
2403
+ if (typeof executor !== 'function') {
2404
+ throw new TypeError('executor must be a function.');
2405
+ }
2406
+ let resolvePromise;
2407
+ this.promise = new Promise(function promiseExecutor(resolve) {
2408
+ resolvePromise = resolve;
2409
+ });
2410
+ const token = this;
2411
+ // eslint-disable-next-line func-names
2412
+ this.promise.then((cancel)=>{
2413
+ if (!token._listeners) return;
2414
+ let i = token._listeners.length;
2415
+ while(i-- > 0){
2416
+ token._listeners[i](cancel);
2417
+ }
2418
+ token._listeners = null;
2419
+ });
2420
+ // eslint-disable-next-line func-names
2421
+ this.promise.then = (onfulfilled)=>{
2422
+ let _resolve;
2423
+ // eslint-disable-next-line func-names
2424
+ const promise = new Promise((resolve)=>{
2425
+ token.subscribe(resolve);
2426
+ _resolve = resolve;
2427
+ }).then(onfulfilled);
2428
+ promise.cancel = function reject() {
2429
+ token.unsubscribe(_resolve);
2430
+ };
2431
+ return promise;
2432
+ };
2433
+ executor(function cancel(message, config, request) {
2434
+ if (token.reason) {
2435
+ // Cancellation has already been requested
2436
+ return;
2437
+ }
2438
+ token.reason = new CanceledError$1(message, config, request);
2439
+ resolvePromise(token.reason);
2440
+ });
2441
+ }
2442
+ /**
2443
+ * Throws a `CanceledError` if cancellation has been requested.
2444
+ */ throwIfRequested() {
2445
+ if (this.reason) {
2446
+ throw this.reason;
2447
+ }
2448
+ }
2449
+ /**
2450
+ * Subscribe to the cancel signal
2451
+ */ subscribe(listener) {
2452
+ if (this.reason) {
2453
+ listener(this.reason);
2454
+ return;
2455
+ }
2456
+ if (this._listeners) {
2457
+ this._listeners.push(listener);
2458
+ } else {
2459
+ this._listeners = [
2460
+ listener
2461
+ ];
2462
+ }
2463
+ }
2464
+ /**
2465
+ * Unsubscribe from the cancel signal
2466
+ */ unsubscribe(listener) {
2467
+ if (!this._listeners) {
2468
+ return;
2469
+ }
2470
+ const index = this._listeners.indexOf(listener);
2471
+ if (index !== -1) {
2472
+ this._listeners.splice(index, 1);
2473
+ }
2474
+ }
2475
+ toAbortSignal() {
2476
+ const controller = new AbortController();
2477
+ const abort = (err)=>{
2478
+ controller.abort(err);
2479
+ };
2480
+ this.subscribe(abort);
2481
+ controller.signal.unsubscribe = ()=>this.unsubscribe(abort);
2482
+ return controller.signal;
2483
+ }
2484
+ /**
2485
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2486
+ * cancels the `CancelToken`.
2487
+ */ static source() {
2488
+ let cancel;
2489
+ const token = new CancelToken(function executor(c) {
2490
+ cancel = c;
2491
+ });
2492
+ return {
2493
+ token,
2494
+ cancel
2495
+ };
2496
+ }
2497
+ };
2498
+ const CancelToken$2 = CancelToken$1;
2499
+
2500
+ /**
2501
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
2502
+ *
2503
+ * Common use case would be to use `Function.prototype.apply`.
2504
+ *
2505
+ * ```js
2506
+ * function f(x, y, z) {}
2507
+ * var args = [1, 2, 3];
2508
+ * f.apply(null, args);
2509
+ * ```
2510
+ *
2511
+ * With `spread` this example can be re-written.
2512
+ *
2513
+ * ```js
2514
+ * spread(function(x, y, z) {})([1, 2, 3]);
2515
+ * ```
2516
+ *
2517
+ * @param {Function} callback
2518
+ *
2519
+ * @returns {Function}
2520
+ */ function spread$1(callback) {
2521
+ return function wrap(arr) {
2522
+ return callback.apply(null, arr);
2523
+ };
2524
+ }
2525
+
2526
+ /**
2527
+ * Determines whether the payload is an error thrown by Axios
2528
+ *
2529
+ * @param {*} payload The value to test
2530
+ *
2531
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
2532
+ */ function isAxiosError$1(payload) {
2533
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
2534
+ }
2535
+
2536
+ /**
2537
+ * Create an instance of Axios
2538
+ *
2539
+ * @param {Object} defaultConfig The default config for the instance
2540
+ *
2541
+ * @returns {Axios} A new instance of Axios
2542
+ */ function createInstance(defaultConfig) {
2543
+ const context = new Axios$2(defaultConfig);
2544
+ const instance = bind(Axios$2.prototype.request, context);
2545
+ // Copy axios.prototype to instance
2546
+ utils$1.extend(instance, Axios$2.prototype, context, {
2547
+ allOwnKeys: true
2548
+ });
2549
+ // Copy context to instance
2550
+ utils$1.extend(instance, context, null, {
2551
+ allOwnKeys: true
2552
+ });
2553
+ // Factory for creating new instances
2554
+ instance.create = function create(instanceConfig) {
2555
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
2556
+ };
2557
+ return instance;
2558
+ }
2559
+ // Create the default instance to be exported
2560
+ const req = createInstance(defaults$1);
2561
+ // Expose Axios class to allow class inheritance
2562
+ req.Axios = Axios$2;
2563
+ // Expose Cancel & CancelToken
2564
+ req.CanceledError = CanceledError$1;
2565
+ req.CancelToken = CancelToken$2;
2566
+ req.isCancel = isCancel$1;
2567
+ req.VERSION = VERSION$1;
2568
+ req.toFormData = toFormData$1;
2569
+ // Expose AxiosError class
2570
+ req.AxiosError = AxiosError$1;
2571
+ // alias for CanceledError for backward compatibility
2572
+ req.Cancel = req.CanceledError;
2573
+ // Expose all/spread
2574
+ req.all = (promises)=>Promise.all(promises);
2575
+ req.spread = spread$1;
2576
+ // Expose isAxiosError
2577
+ req.isAxiosError = isAxiosError$1;
2578
+ // Expose mergeConfig
2579
+ req.mergeConfig = mergeConfig$1;
2580
+ req.AxiosHeaders = AxiosHeaders$2;
2581
+ req.formToJSON = (thing)=>formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
2582
+ req.getAdapter = adapters.getAdapter;
2583
+ req.default = req;
2584
+ // this module should only have a default export
2585
+ const req$1 = req;
2586
+
2587
+ // This module is intended to unwrap Axios default export as named.
2588
+ // Keep top-level export same with static properties
2589
+ // so that it can keep same with es module or cjs
2590
+ const {
2591
+ Axios,
2592
+ AxiosError,
2593
+ CanceledError,
2594
+ isCancel,
2595
+ CancelToken,
2596
+ VERSION,
2597
+ all,
2598
+ Cancel,
2599
+ isAxiosError,
2600
+ spread,
2601
+ toFormData,
2602
+ AxiosHeaders,
2603
+ HttpStatusCode,
2604
+ formToJSON,
2605
+ getAdapter,
2606
+ mergeConfig,
2607
+ } = req$1;
2608
+
2609
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, req$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };