@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,3551 @@
1
+ /*!
2
+ * @wia/req v1.7.7
3
+ * (c) 2024 Sibyl Yu, Matt Zabriskie and contributors
4
+ * Released under the MIT License.
5
+ */
6
+ import FormData$1 from 'form-data';
7
+ import url from 'url';
8
+ import request from '@wiajs/request';
9
+ import Agent from '@wiajs/agent';
10
+ import { log as log$1, name } from '@wiajs/log';
11
+ import util from 'node:util';
12
+ import zlib from 'node:zlib';
13
+ import stream$1 from 'node:stream';
14
+ import stream, { Readable } from 'stream';
15
+ import { EventEmitter } from 'node:events';
16
+ import { TextEncoder } from 'util';
17
+
18
+ function bind(fn, thisArg) {
19
+ return function wrap() {
20
+ return fn.apply(thisArg, arguments);
21
+ };
22
+ }
23
+
24
+ // utils is a library of generic helper functions non-specific to axios
25
+ const { toString } = Object.prototype;
26
+ const { getPrototypeOf } = Object;
27
+ const kindOf = ((cache)=>(thing)=>{
28
+ const str = toString.call(thing);
29
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
30
+ })(Object.create(null));
31
+ const kindOfTest = (type)=>{
32
+ type = type.toLowerCase();
33
+ return (thing)=>kindOf(thing) === type;
34
+ };
35
+ const typeOfTest = (type)=>(thing)=>typeof thing === type;
36
+ /**
37
+ * Determine if a value is an Array
38
+ *
39
+ * @param {Object} val The value to test
40
+ *
41
+ * @returns {boolean} True if value is an Array, otherwise false
42
+ */ const { isArray } = Array;
43
+ /**
44
+ * Determine if a value is undefined
45
+ *
46
+ * @param {*} val The value to test
47
+ *
48
+ * @returns {boolean} True if the value is undefined, otherwise false
49
+ */ const isUndefined = typeOfTest('undefined');
50
+ /**
51
+ * Determine if a value is a Buffer
52
+ *
53
+ * @param {*} val The value to test
54
+ *
55
+ * @returns {boolean} True if value is a Buffer, otherwise false
56
+ */ function isBuffer(val) {
57
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
58
+ }
59
+ /**
60
+ * Determine if a value is an ArrayBuffer
61
+ *
62
+ * @param {*} val The value to test
63
+ *
64
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
65
+ */ const isArrayBuffer = kindOfTest('ArrayBuffer');
66
+ /**
67
+ * Determine if a value is a view on an ArrayBuffer
68
+ *
69
+ * @param {*} val The value to test
70
+ *
71
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
72
+ */ function isArrayBufferView(val) {
73
+ let result;
74
+ if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) {
75
+ result = ArrayBuffer.isView(val);
76
+ } else {
77
+ result = val && val.buffer && isArrayBuffer(val.buffer);
78
+ }
79
+ return result;
80
+ }
81
+ /**
82
+ * Determine if a value is a String
83
+ *
84
+ * @param {*} val The value to test
85
+ *
86
+ * @returns {boolean} True if value is a String, otherwise false
87
+ */ const isString = typeOfTest('string');
88
+ /**
89
+ * Determine if a value is a Function
90
+ *
91
+ * @param {*} val The value to test
92
+ * @returns {boolean} True if value is a Function, otherwise false
93
+ */ const isFunction = typeOfTest('function');
94
+ /**
95
+ * Determine if a value is a Number
96
+ *
97
+ * @param {*} val The value to test
98
+ *
99
+ * @returns {boolean} True if value is a Number, otherwise false
100
+ */ const isNumber = typeOfTest('number');
101
+ /**
102
+ * Determine if a value is an Object
103
+ *
104
+ * @param {*} thing The value to test
105
+ *
106
+ * @returns {boolean} True if value is an Object, otherwise false
107
+ */ const isObject = (thing)=>thing !== null && typeof thing === 'object';
108
+ /**
109
+ * Determine if a value is a Boolean
110
+ *
111
+ * @param {*} thing The value to test
112
+ * @returns {boolean} True if value is a Boolean, otherwise false
113
+ */ const isBoolean = (thing)=>thing === true || thing === false;
114
+ /**
115
+ * Determine if a value is a plain Object
116
+ *
117
+ * @param {*} val The value to test
118
+ *
119
+ * @returns {boolean} True if value is a plain Object, otherwise false
120
+ */ const isPlainObject = (val)=>{
121
+ if (kindOf(val) !== 'object') {
122
+ return false;
123
+ }
124
+ const prototype = getPrototypeOf(val);
125
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
126
+ };
127
+ /**
128
+ * Determine if a value is a Date
129
+ *
130
+ * @param {*} val The value to test
131
+ *
132
+ * @returns {boolean} True if value is a Date, otherwise false
133
+ */ const isDate = kindOfTest('Date');
134
+ /**
135
+ * Determine if a value is a File
136
+ *
137
+ * @param {*} val The value to test
138
+ *
139
+ * @returns {boolean} True if value is a File, otherwise false
140
+ */ const isFile = kindOfTest('File');
141
+ /**
142
+ * Determine if a value is a Blob
143
+ *
144
+ * @param {*} val The value to test
145
+ *
146
+ * @returns {boolean} True if value is a Blob, otherwise false
147
+ */ const isBlob = kindOfTest('Blob');
148
+ /**
149
+ * Determine if a value is a FileList
150
+ *
151
+ * @param {*} val The value to test
152
+ *
153
+ * @returns {boolean} True if value is a File, otherwise false
154
+ */ const isFileList = kindOfTest('FileList');
155
+ /**
156
+ * Determine if a value is a Stream
157
+ *
158
+ * @param {*} val The value to test
159
+ *
160
+ * @returns {boolean} True if value is a Stream, otherwise false
161
+ */ const isStream = (val)=>isObject(val) && isFunction(val.pipe);
162
+ /**
163
+ * Determine if a value is a FormData
164
+ *
165
+ * @param {*} thing The value to test
166
+ *
167
+ * @returns {boolean} True if value is an FormData, otherwise false
168
+ */ const isFormData = (thing)=>{
169
+ let kind;
170
+ return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === 'formdata' || // detect form-data instance
171
+ kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]'));
172
+ };
173
+ /**
174
+ * Determine if a value is a URLSearchParams object
175
+ *
176
+ * @param {*} val The value to test
177
+ *
178
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
179
+ */ const isURLSearchParams = kindOfTest('URLSearchParams');
180
+ const [isReadableStream, isRequest, isResponse, isHeaders] = [
181
+ 'ReadableStream',
182
+ 'Request',
183
+ 'Response',
184
+ 'Headers'
185
+ ].map(kindOfTest);
186
+ /**
187
+ * Trim excess whitespace off the beginning and end of a string
188
+ *
189
+ * @param {String} str The String to trim
190
+ *
191
+ * @returns {String} The String freed of excess whitespace
192
+ */ const trim = (str)=>str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
193
+ /**
194
+ * Iterate over an Array or an Object invoking a function for each item.
195
+ *
196
+ * If `obj` is an Array callback will be called passing
197
+ * the value, index, and complete array for each item.
198
+ *
199
+ * If 'obj' is an Object callback will be called passing
200
+ * the value, key, and complete object for each property.
201
+ *
202
+ * @param {Object|Array} obj The object to iterate
203
+ * @param {Function} fn The callback to invoke for each item
204
+ *
205
+ * @param {Boolean} [allOwnKeys = false]
206
+ * @returns {any}
207
+ */ function forEach(obj, fn, { allOwnKeys = false } = {}) {
208
+ // Don't bother if no value provided
209
+ if (obj === null || typeof obj === 'undefined') {
210
+ return;
211
+ }
212
+ let i;
213
+ let l;
214
+ // Force an array if not already something iterable
215
+ if (typeof obj !== 'object') {
216
+ /*eslint no-param-reassign:0*/ obj = [
217
+ obj
218
+ ];
219
+ }
220
+ if (isArray(obj)) {
221
+ // Iterate over array values
222
+ for(i = 0, l = obj.length; i < l; i++){
223
+ fn.call(null, obj[i], i, obj);
224
+ }
225
+ } else {
226
+ // Iterate over object keys
227
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
228
+ const len = keys.length;
229
+ let key;
230
+ for(i = 0; i < len; i++){
231
+ key = keys[i];
232
+ fn.call(null, obj[key], key, obj);
233
+ }
234
+ }
235
+ }
236
+ function findKey(obj, key) {
237
+ key = key.toLowerCase();
238
+ const keys = Object.keys(obj);
239
+ let i = keys.length;
240
+ let _key;
241
+ while(i-- > 0){
242
+ _key = keys[i];
243
+ if (key === _key.toLowerCase()) {
244
+ return _key;
245
+ }
246
+ }
247
+ return null;
248
+ }
249
+ const _global = (()=>{
250
+ /*eslint no-undef:0*/ if (typeof globalThis !== "undefined") return globalThis;
251
+ return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
252
+ })();
253
+ const isContextDefined = (context)=>!isUndefined(context) && context !== _global;
254
+ /**
255
+ * Accepts varargs expecting each argument to be an object, then
256
+ * immutably merges the properties of each object and returns result.
257
+ *
258
+ * When multiple objects contain the same key the later object in
259
+ * the arguments list will take precedence.
260
+ *
261
+ * Example:
262
+ *
263
+ * ```js
264
+ * var result = merge({foo: 123}, {foo: 456});
265
+ * console.log(result.foo); // outputs 456
266
+ * ```
267
+ *
268
+ * @param {Object} obj1 Object to merge
269
+ *
270
+ * @returns {Object} Result of all merge properties
271
+ */ function merge() {
272
+ const { caseless } = isContextDefined(this) && this || {};
273
+ const result = {};
274
+ const assignValue = (val, key)=>{
275
+ const targetKey = caseless && findKey(result, key) || key;
276
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
277
+ result[targetKey] = merge(result[targetKey], val);
278
+ } else if (isPlainObject(val)) {
279
+ result[targetKey] = merge({}, val);
280
+ } else if (isArray(val)) {
281
+ result[targetKey] = val.slice();
282
+ } else {
283
+ result[targetKey] = val;
284
+ }
285
+ };
286
+ for(let i = 0, l = arguments.length; i < l; i++){
287
+ arguments[i] && forEach(arguments[i], assignValue);
288
+ }
289
+ return result;
290
+ }
291
+ /**
292
+ * Extends object a by mutably adding to it the properties of object b.
293
+ *
294
+ * @param {Object} a The object to be extended
295
+ * @param {Object} b The object to copy properties from
296
+ * @param {Object} thisArg The object to bind function to
297
+ *
298
+ * @param {Boolean} [allOwnKeys]
299
+ * @returns {Object} The resulting value of object a
300
+ */ const extend = (a, b, thisArg, { allOwnKeys } = {})=>{
301
+ forEach(b, (val, key)=>{
302
+ if (thisArg && isFunction(val)) {
303
+ a[key] = bind(val, thisArg);
304
+ } else {
305
+ a[key] = val;
306
+ }
307
+ }, {
308
+ allOwnKeys
309
+ });
310
+ return a;
311
+ };
312
+ /**
313
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
314
+ *
315
+ * @param {string} content with BOM
316
+ *
317
+ * @returns {string} content value without BOM
318
+ */ const stripBOM = (content)=>{
319
+ if (content.charCodeAt(0) === 0xFEFF) {
320
+ content = content.slice(1);
321
+ }
322
+ return content;
323
+ };
324
+ /**
325
+ * Inherit the prototype methods from one constructor into another
326
+ * @param {function} constructor
327
+ * @param {function} superConstructor
328
+ * @param {object} [props]
329
+ * @param {object} [descriptors]
330
+ *
331
+ * @returns {void}
332
+ */ const inherits = (constructor, superConstructor, props, descriptors)=>{
333
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
334
+ constructor.prototype.constructor = constructor;
335
+ Object.defineProperty(constructor, 'super', {
336
+ value: superConstructor.prototype
337
+ });
338
+ props && Object.assign(constructor.prototype, props);
339
+ };
340
+ /**
341
+ * Resolve object with deep prototype chain to a flat object
342
+ * @param {Object} sourceObj source object
343
+ * @param {Object} [destObj]
344
+ * @param {Function|Boolean} [filter]
345
+ * @param {Function} [propFilter]
346
+ *
347
+ * @returns {Object}
348
+ */ const toFlatObject = (sourceObj, destObj, filter, propFilter)=>{
349
+ let props;
350
+ let i;
351
+ let prop;
352
+ const merged = {};
353
+ destObj = destObj || {};
354
+ // eslint-disable-next-line no-eq-null,eqeqeq
355
+ if (sourceObj == null) return destObj;
356
+ do {
357
+ props = Object.getOwnPropertyNames(sourceObj);
358
+ i = props.length;
359
+ while(i-- > 0){
360
+ prop = props[i];
361
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
362
+ destObj[prop] = sourceObj[prop];
363
+ merged[prop] = true;
364
+ }
365
+ }
366
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
367
+ }while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype)
368
+ return destObj;
369
+ };
370
+ /**
371
+ * Determines whether a string ends with the characters of a specified string
372
+ *
373
+ * @param {String} str
374
+ * @param {String} searchString
375
+ * @param {Number} [position= 0]
376
+ *
377
+ * @returns {boolean}
378
+ */ const endsWith = (str, searchString, position)=>{
379
+ str = String(str);
380
+ if (position === undefined || position > str.length) {
381
+ position = str.length;
382
+ }
383
+ position -= searchString.length;
384
+ const lastIndex = str.indexOf(searchString, position);
385
+ return lastIndex !== -1 && lastIndex === position;
386
+ };
387
+ /**
388
+ * Returns new array from array like object or null if failed
389
+ *
390
+ * @param {*} [thing]
391
+ *
392
+ * @returns {?Array}
393
+ */ const toArray = (thing)=>{
394
+ if (!thing) return null;
395
+ if (isArray(thing)) return thing;
396
+ let i = thing.length;
397
+ if (!isNumber(i)) return null;
398
+ const arr = new Array(i);
399
+ while(i-- > 0){
400
+ arr[i] = thing[i];
401
+ }
402
+ return arr;
403
+ };
404
+ /**
405
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
406
+ * thing passed in is an instance of Uint8Array
407
+ *
408
+ * @param {TypedArray}
409
+ *
410
+ * @returns {Array}
411
+ */ // eslint-disable-next-line func-names
412
+ const isTypedArray = ((TypedArray)=>{
413
+ // eslint-disable-next-line func-names
414
+ return (thing)=>{
415
+ return TypedArray && thing instanceof TypedArray;
416
+ };
417
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
418
+ /**
419
+ * For each entry in the object, call the function with the key and value.
420
+ *
421
+ * @param {Object<any, any>} obj - The object to iterate over.
422
+ * @param {Function} fn - The function to call for each entry.
423
+ *
424
+ * @returns {void}
425
+ */ const forEachEntry = (obj, fn)=>{
426
+ const generator = obj && obj[Symbol.iterator];
427
+ const iterator = generator.call(obj);
428
+ let result;
429
+ while((result = iterator.next()) && !result.done){
430
+ const pair = result.value;
431
+ fn.call(obj, pair[0], pair[1]);
432
+ }
433
+ };
434
+ /**
435
+ * It takes a regular expression and a string, and returns an array of all the matches
436
+ *
437
+ * @param {string} regExp - The regular expression to match against.
438
+ * @param {string} str - The string to search.
439
+ *
440
+ * @returns {Array<boolean>}
441
+ */ const matchAll = (regExp, str)=>{
442
+ let matches;
443
+ const arr = [];
444
+ while((matches = regExp.exec(str)) !== null){
445
+ arr.push(matches);
446
+ }
447
+ return arr;
448
+ };
449
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */ const isHTMLForm = kindOfTest('HTMLFormElement');
450
+ const toCamelCase = (str)=>{
451
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
452
+ return p1.toUpperCase() + p2;
453
+ });
454
+ };
455
+ /* Creating a function that will check if an object has a property. */ const hasOwnProperty = (({ hasOwnProperty })=>(obj, prop)=>hasOwnProperty.call(obj, prop))(Object.prototype);
456
+ /**
457
+ * Determine if a value is a RegExp object
458
+ *
459
+ * @param {*} val The value to test
460
+ *
461
+ * @returns {boolean} True if value is a RegExp object, otherwise false
462
+ */ const isRegExp = kindOfTest('RegExp');
463
+ const reduceDescriptors = (obj, reducer)=>{
464
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
465
+ const reducedDescriptors = {};
466
+ forEach(descriptors, (descriptor, name)=>{
467
+ let ret;
468
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
469
+ reducedDescriptors[name] = ret || descriptor;
470
+ }
471
+ });
472
+ Object.defineProperties(obj, reducedDescriptors);
473
+ };
474
+ /**
475
+ * Makes all methods read-only
476
+ * @param {Object} obj
477
+ */ const freezeMethods = (obj)=>{
478
+ reduceDescriptors(obj, (descriptor, name)=>{
479
+ // skip restricted props in strict mode
480
+ if (isFunction(obj) && [
481
+ 'arguments',
482
+ 'caller',
483
+ 'callee'
484
+ ].indexOf(name) !== -1) {
485
+ return false;
486
+ }
487
+ const value = obj[name];
488
+ if (!isFunction(value)) return;
489
+ descriptor.enumerable = false;
490
+ if ('writable' in descriptor) {
491
+ descriptor.writable = false;
492
+ return;
493
+ }
494
+ if (!descriptor.set) {
495
+ descriptor.set = ()=>{
496
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
497
+ };
498
+ }
499
+ });
500
+ };
501
+ const toObjectSet = (arrayOrString, delimiter)=>{
502
+ const obj = {};
503
+ const define = (arr)=>{
504
+ arr.forEach((value)=>{
505
+ obj[value] = true;
506
+ });
507
+ };
508
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
509
+ return obj;
510
+ };
511
+ const noop = ()=>{};
512
+ const toFiniteNumber = (value, defaultValue)=>{
513
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
514
+ };
515
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
516
+ const DIGIT = '0123456789';
517
+ const ALPHABET = {
518
+ DIGIT,
519
+ ALPHA,
520
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
521
+ };
522
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT)=>{
523
+ let str = '';
524
+ const { length } = alphabet;
525
+ while(size--){
526
+ str += alphabet[Math.random() * length | 0];
527
+ }
528
+ return str;
529
+ };
530
+ /**
531
+ * If the thing is a FormData object, return true, otherwise return false.
532
+ *
533
+ * @param {unknown} thing - The thing to check.
534
+ *
535
+ * @returns {boolean}
536
+ */ function isSpecCompliantForm(thing) {
537
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
538
+ }
539
+ const toJSONObject = (obj)=>{
540
+ const stack = new Array(10);
541
+ const visit = (source, i)=>{
542
+ if (isObject(source)) {
543
+ if (stack.indexOf(source) >= 0) {
544
+ return;
545
+ }
546
+ if (!('toJSON' in source)) {
547
+ stack[i] = source;
548
+ const target = isArray(source) ? [] : {};
549
+ forEach(source, (value, key)=>{
550
+ const reducedValue = visit(value, i + 1);
551
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
552
+ });
553
+ stack[i] = undefined;
554
+ return target;
555
+ }
556
+ }
557
+ return source;
558
+ };
559
+ return visit(obj, 0);
560
+ };
561
+ const isAsyncFn = kindOfTest('AsyncFunction');
562
+ const isThenable = (thing)=>thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
563
+ // original code
564
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
565
+ const _setImmediate = ((setImmediateSupported, postMessageSupported)=>{
566
+ if (setImmediateSupported) {
567
+ return setImmediate;
568
+ }
569
+ return postMessageSupported ? ((token, callbacks)=>{
570
+ _global.addEventListener("message", ({ source, data })=>{
571
+ if (source === _global && data === token) {
572
+ callbacks.length && callbacks.shift()();
573
+ }
574
+ }, false);
575
+ return (cb)=>{
576
+ callbacks.push(cb);
577
+ _global.postMessage(token, "*");
578
+ };
579
+ })(`axios@${Math.random()}`, []) : (cb)=>setTimeout(cb);
580
+ })(typeof setImmediate === 'function', isFunction(_global.postMessage));
581
+ const asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
582
+ function createErrorType(code, message, baseClass) {
583
+ // Create constructor
584
+ function CustomError(properties) {
585
+ Error.captureStackTrace(this, this.constructor);
586
+ Object.assign(this, properties || {});
587
+ this.code = code;
588
+ this.message = this.cause ? `${message}: ${this.cause.message}` : message;
589
+ }
590
+ // Attach constructor and set default properties
591
+ CustomError.prototype = new (baseClass || Error)();
592
+ CustomError.prototype.constructor = CustomError;
593
+ CustomError.prototype.name = `Error [${code}]`;
594
+ return CustomError;
595
+ }
596
+ // *********************
597
+ const utils$1 = {
598
+ isArray,
599
+ isArrayBuffer,
600
+ isBuffer,
601
+ isFormData,
602
+ isArrayBufferView,
603
+ isString,
604
+ isNumber,
605
+ isBoolean,
606
+ isObject,
607
+ isPlainObject,
608
+ isReadableStream,
609
+ isRequest,
610
+ isResponse,
611
+ isHeaders,
612
+ isUndefined,
613
+ isDate,
614
+ isFile,
615
+ isBlob,
616
+ isRegExp,
617
+ isFunction,
618
+ isStream,
619
+ isURLSearchParams,
620
+ isTypedArray,
621
+ isFileList,
622
+ forEach,
623
+ merge,
624
+ extend,
625
+ trim,
626
+ stripBOM,
627
+ inherits,
628
+ toFlatObject,
629
+ kindOf,
630
+ kindOfTest,
631
+ endsWith,
632
+ toArray,
633
+ forEachEntry,
634
+ matchAll,
635
+ isHTMLForm,
636
+ hasOwnProperty,
637
+ hasOwnProp: hasOwnProperty,
638
+ reduceDescriptors,
639
+ freezeMethods,
640
+ toObjectSet,
641
+ toCamelCase,
642
+ noop,
643
+ toFiniteNumber,
644
+ findKey,
645
+ global: _global,
646
+ isContextDefined,
647
+ ALPHABET,
648
+ generateString,
649
+ isSpecCompliantForm,
650
+ toJSONObject,
651
+ isAsyncFn,
652
+ isThenable,
653
+ setImmediate: _setImmediate,
654
+ asap,
655
+ createErrorType
656
+ };
657
+
658
+ /**
659
+ * Create an Error with the specified message, config, error code, request and response.
660
+ *
661
+ * @param {string} message The error message.
662
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
663
+ * @param {Object} [config] The config.
664
+ * @param {Object} [request] The request.
665
+ * @param {Object} [response] The response.
666
+ *
667
+ * @returns {Error} The created error.
668
+ */ function AxiosError$1(message, code, config, request, response) {
669
+ Error.call(this);
670
+ if (Error.captureStackTrace) {
671
+ Error.captureStackTrace(this, this.constructor);
672
+ } else {
673
+ this.stack = new Error().stack;
674
+ }
675
+ this.message = message;
676
+ this.name = 'AxiosError';
677
+ code && (this.code = code);
678
+ config && (this.config = config);
679
+ request && (this.request = request);
680
+ if (response) {
681
+ this.response = response;
682
+ this.status = response.status ? response.status : null;
683
+ }
684
+ }
685
+ utils$1.inherits(AxiosError$1, Error, {
686
+ toJSON: function toJSON() {
687
+ return {
688
+ // Standard
689
+ message: this.message,
690
+ name: this.name,
691
+ // Microsoft
692
+ description: this.description,
693
+ number: this.number,
694
+ // Mozilla
695
+ fileName: this.fileName,
696
+ lineNumber: this.lineNumber,
697
+ columnNumber: this.columnNumber,
698
+ stack: this.stack,
699
+ // Axios
700
+ config: utils$1.toJSONObject(this.config),
701
+ code: this.code,
702
+ status: this.status
703
+ };
704
+ }
705
+ });
706
+ const prototype$1 = AxiosError$1.prototype;
707
+ const descriptors = {};
708
+ [
709
+ 'ERR_BAD_OPTION_VALUE',
710
+ 'ERR_BAD_OPTION',
711
+ 'ECONNABORTED',
712
+ 'ETIMEDOUT',
713
+ 'ERR_NETWORK',
714
+ 'ERR_FR_TOO_MANY_REDIRECTS',
715
+ 'ERR_DEPRECATED',
716
+ 'ERR_BAD_RESPONSE',
717
+ 'ERR_BAD_REQUEST',
718
+ 'ERR_CANCELED',
719
+ 'ERR_NOT_SUPPORT',
720
+ 'ERR_INVALID_URL'
721
+ ].forEach((code)=>{
722
+ descriptors[code] = {
723
+ value: code
724
+ };
725
+ });
726
+ Object.defineProperties(AxiosError$1, descriptors);
727
+ Object.defineProperty(prototype$1, 'isAxiosError', {
728
+ value: true
729
+ });
730
+ // eslint-disable-next-line func-names
731
+ AxiosError$1.from = (error, code, config, request, response, customProps)=>{
732
+ const axiosError = Object.create(prototype$1);
733
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
734
+ return obj !== Error.prototype;
735
+ }, (prop)=>{
736
+ return prop !== 'isAxiosError';
737
+ });
738
+ AxiosError$1.call(axiosError, error.message, code, config, request, response);
739
+ axiosError.cause = error;
740
+ axiosError.name = error.name;
741
+ customProps && Object.assign(axiosError, customProps);
742
+ return axiosError;
743
+ };
744
+
745
+ /**
746
+ * Determines if the given thing is a array or js object.
747
+ *
748
+ * @param {string} thing - The object or array to be visited.
749
+ *
750
+ * @returns {boolean}
751
+ */ function isVisitable(thing) {
752
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
753
+ }
754
+ /**
755
+ * It removes the brackets from the end of a string
756
+ *
757
+ * @param {string} key - The key of the parameter.
758
+ *
759
+ * @returns {string} the key without the brackets.
760
+ */ function removeBrackets(key) {
761
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
762
+ }
763
+ /**
764
+ * It takes a path, a key, and a boolean, and returns a string
765
+ *
766
+ * @param {string} path - The path to the current key.
767
+ * @param {string} key - The key of the current object being iterated over.
768
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
769
+ *
770
+ * @returns {string} The path to the current key.
771
+ */ function renderKey(path, key, dots) {
772
+ if (!path) return key;
773
+ return path.concat(key).map(function each(token, i) {
774
+ // eslint-disable-next-line no-param-reassign
775
+ token = removeBrackets(token);
776
+ return !dots && i ? '[' + token + ']' : token;
777
+ }).join(dots ? '.' : '');
778
+ }
779
+ /**
780
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
781
+ *
782
+ * @param {Array<any>} arr - The array to check
783
+ *
784
+ * @returns {boolean}
785
+ */ function isFlatArray(arr) {
786
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
787
+ }
788
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
789
+ return /^is[A-Z]/.test(prop);
790
+ });
791
+ /**
792
+ * Convert a data object to FormData
793
+ *
794
+ * @param {Object} obj
795
+ * @param {?Object} [formData]
796
+ * @param {?Object} [options]
797
+ * @param {Function} [options.visitor]
798
+ * @param {Boolean} [options.metaTokens = true]
799
+ * @param {Boolean} [options.dots = false]
800
+ * @param {?Boolean} [options.indexes = false]
801
+ *
802
+ * @returns {Object}
803
+ **/ /**
804
+ * It converts an object into a FormData object
805
+ *
806
+ * @param {Object<any, any>} obj - The object to convert to form data.
807
+ * @param {string} formData - The FormData object to append to.
808
+ * @param {Object<string, any>} options
809
+ *
810
+ * @returns
811
+ */ function toFormData$1(obj, formData, options) {
812
+ if (!utils$1.isObject(obj)) {
813
+ throw new TypeError('target must be an object');
814
+ }
815
+ // eslint-disable-next-line no-param-reassign
816
+ formData = formData || new (FormData$1 || FormData)();
817
+ // eslint-disable-next-line no-param-reassign
818
+ options = utils$1.toFlatObject(options, {
819
+ metaTokens: true,
820
+ dots: false,
821
+ indexes: false
822
+ }, false, function defined(option, source) {
823
+ // eslint-disable-next-line no-eq-null,eqeqeq
824
+ return !utils$1.isUndefined(source[option]);
825
+ });
826
+ const metaTokens = options.metaTokens;
827
+ // eslint-disable-next-line no-use-before-define
828
+ const visitor = options.visitor || defaultVisitor;
829
+ const dots = options.dots;
830
+ const indexes = options.indexes;
831
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
832
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
833
+ if (!utils$1.isFunction(visitor)) {
834
+ throw new TypeError('visitor must be a function');
835
+ }
836
+ function convertValue(value) {
837
+ if (value === null) return '';
838
+ if (utils$1.isDate(value)) {
839
+ return value.toISOString();
840
+ }
841
+ if (!useBlob && utils$1.isBlob(value)) {
842
+ throw new AxiosError$1('Blob is not supported. Use a Buffer instead.');
843
+ }
844
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
845
+ return useBlob && typeof Blob === 'function' ? new Blob([
846
+ value
847
+ ]) : Buffer.from(value);
848
+ }
849
+ return value;
850
+ }
851
+ /**
852
+ * Default visitor.
853
+ *
854
+ * @param {*} value
855
+ * @param {String|Number} key
856
+ * @param {Array<String|Number>} path
857
+ * @this {FormData}
858
+ *
859
+ * @returns {boolean} return true to visit the each prop of the value recursively
860
+ */ function defaultVisitor(value, key, path) {
861
+ let arr = value;
862
+ if (value && !path && typeof value === 'object') {
863
+ if (utils$1.endsWith(key, '{}')) {
864
+ // eslint-disable-next-line no-param-reassign
865
+ key = metaTokens ? key : key.slice(0, -2);
866
+ // eslint-disable-next-line no-param-reassign
867
+ value = JSON.stringify(value);
868
+ } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))) {
869
+ // eslint-disable-next-line no-param-reassign
870
+ key = removeBrackets(key);
871
+ arr.forEach(function each(el, index) {
872
+ !(utils$1.isUndefined(el) || el === null) && formData.append(// eslint-disable-next-line no-nested-ternary
873
+ indexes === true ? renderKey([
874
+ key
875
+ ], index, dots) : indexes === null ? key : key + '[]', convertValue(el));
876
+ });
877
+ return false;
878
+ }
879
+ }
880
+ if (isVisitable(value)) {
881
+ return true;
882
+ }
883
+ formData.append(renderKey(path, key, dots), convertValue(value));
884
+ return false;
885
+ }
886
+ const stack = [];
887
+ const exposedHelpers = Object.assign(predicates, {
888
+ defaultVisitor,
889
+ convertValue,
890
+ isVisitable
891
+ });
892
+ function build(value, path) {
893
+ if (utils$1.isUndefined(value)) return;
894
+ if (stack.indexOf(value) !== -1) {
895
+ throw Error('Circular reference detected in ' + path.join('.'));
896
+ }
897
+ stack.push(value);
898
+ utils$1.forEach(value, function each(el, key) {
899
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers);
900
+ if (result === true) {
901
+ build(el, path ? path.concat(key) : [
902
+ key
903
+ ]);
904
+ }
905
+ });
906
+ stack.pop();
907
+ }
908
+ if (!utils$1.isObject(obj)) {
909
+ throw new TypeError('data must be an object');
910
+ }
911
+ build(obj);
912
+ return formData;
913
+ }
914
+
915
+ /**
916
+ * It encodes a string by replacing all characters that are not in the unreserved set with
917
+ * their percent-encoded equivalents
918
+ *
919
+ * @param {string} str - The string to encode.
920
+ *
921
+ * @returns {string} The encoded string.
922
+ */ function encode$1(str) {
923
+ const charMap = {
924
+ '!': '%21',
925
+ "'": '%27',
926
+ '(': '%28',
927
+ ')': '%29',
928
+ '~': '%7E',
929
+ '%20': '+',
930
+ '%00': '\x00'
931
+ };
932
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
933
+ return charMap[match];
934
+ });
935
+ }
936
+ /**
937
+ * It takes a params object and converts it to a FormData object
938
+ *
939
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
940
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
941
+ *
942
+ * @returns {void}
943
+ */ function AxiosURLSearchParams(params, options) {
944
+ this._pairs = [];
945
+ params && toFormData$1(params, this, options);
946
+ }
947
+ const prototype = AxiosURLSearchParams.prototype;
948
+ prototype.append = function append(name, value) {
949
+ this._pairs.push([
950
+ name,
951
+ value
952
+ ]);
953
+ };
954
+ prototype.toString = function toString(encoder) {
955
+ const _encode = encoder ? function(value) {
956
+ return encoder.call(this, value, encode$1);
957
+ } : encode$1;
958
+ return this._pairs.map(function each(pair) {
959
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
960
+ }, '').join('&');
961
+ };
962
+
963
+ /**
964
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
965
+ * URI encoded counterparts
966
+ *
967
+ * @param {string} val The value to be encoded.
968
+ *
969
+ * @returns {string} The encoded value.
970
+ */ function encode(val) {
971
+ return encodeURIComponent(val).replace(/%3A/gi, ':').replace(/%24/g, '$').replace(/%2C/gi, ',').replace(/%20/g, '+').replace(/%5B/gi, '[').replace(/%5D/gi, ']');
972
+ }
973
+ /**
974
+ * Build a URL by appending params to the end
975
+ *
976
+ * @param {string} url The base of the url (e.g., http://www.google.com)
977
+ * @param {object} [params] The params to be appended
978
+ * @param {?object} options
979
+ *
980
+ * @returns {string} The formatted url
981
+ */ function buildURL(url, params, options) {
982
+ /*eslint no-param-reassign:0*/ if (!params) {
983
+ return url;
984
+ }
985
+ const _encode = options && options.encode || encode;
986
+ const serializeFn = options && options.serialize;
987
+ let serializedParams;
988
+ if (serializeFn) {
989
+ serializedParams = serializeFn(params, options);
990
+ } else {
991
+ serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
992
+ }
993
+ if (serializedParams) {
994
+ const hashmarkIndex = url.indexOf("#");
995
+ if (hashmarkIndex !== -1) {
996
+ url = url.slice(0, hashmarkIndex);
997
+ }
998
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
999
+ }
1000
+ return url;
1001
+ }
1002
+
1003
+ let InterceptorManager = class InterceptorManager {
1004
+ constructor(){
1005
+ this.handlers = [];
1006
+ }
1007
+ /**
1008
+ * Add a new interceptor to the stack
1009
+ *
1010
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1011
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1012
+ *
1013
+ * @return {Number} An ID used to remove interceptor later
1014
+ */ use(fulfilled, rejected, options) {
1015
+ this.handlers.push({
1016
+ fulfilled,
1017
+ rejected,
1018
+ synchronous: options ? options.synchronous : false,
1019
+ runWhen: options ? options.runWhen : null
1020
+ });
1021
+ return this.handlers.length - 1;
1022
+ }
1023
+ /**
1024
+ * Remove an interceptor from the stack
1025
+ *
1026
+ * @param {Number} id The ID that was returned by `use`
1027
+ *
1028
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1029
+ */ eject(id) {
1030
+ if (this.handlers[id]) {
1031
+ this.handlers[id] = null;
1032
+ }
1033
+ }
1034
+ /**
1035
+ * Clear all interceptors from the stack
1036
+ *
1037
+ * @returns {void}
1038
+ */ clear() {
1039
+ if (this.handlers) {
1040
+ this.handlers = [];
1041
+ }
1042
+ }
1043
+ /**
1044
+ * Iterate over all the registered interceptors
1045
+ *
1046
+ * This method is particularly useful for skipping over any
1047
+ * interceptors that may have become `null` calling `eject`.
1048
+ *
1049
+ * @param {Function} fn The function to call for each interceptor
1050
+ *
1051
+ * @returns {void}
1052
+ */ forEach(fn) {
1053
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1054
+ if (h !== null) {
1055
+ fn(h);
1056
+ }
1057
+ });
1058
+ }
1059
+ };
1060
+ const InterceptorManager$1 = InterceptorManager;
1061
+
1062
+ const transitionalDefaults = {
1063
+ silentJSONParsing: true,
1064
+ forcedJSONParsing: true,
1065
+ clarifyTimeoutError: false
1066
+ };
1067
+
1068
+ const URLSearchParams = url.URLSearchParams;
1069
+
1070
+ const platform$1 = {
1071
+ isNode: true,
1072
+ classes: {
1073
+ URLSearchParams,
1074
+ FormData: FormData$1,
1075
+ Blob: typeof Blob !== 'undefined' && Blob || null
1076
+ },
1077
+ protocols: [
1078
+ 'http',
1079
+ 'https',
1080
+ 'file',
1081
+ 'data'
1082
+ ]
1083
+ };
1084
+
1085
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1086
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1087
+ /**
1088
+ * Determine if we're running in a standard browser environment
1089
+ *
1090
+ * This allows axios to run in a web worker, and react-native.
1091
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1092
+ *
1093
+ * web workers:
1094
+ * typeof window -> undefined
1095
+ * typeof document -> undefined
1096
+ *
1097
+ * react-native:
1098
+ * navigator.product -> 'ReactNative'
1099
+ * nativescript
1100
+ * navigator.product -> 'NativeScript' or 'NS'
1101
+ *
1102
+ * @returns {boolean}
1103
+ */ const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || [
1104
+ 'ReactNative',
1105
+ 'NativeScript',
1106
+ 'NS'
1107
+ ].indexOf(_navigator.product) < 0);
1108
+ /**
1109
+ * Determine if we're running in a standard browser webWorker environment
1110
+ *
1111
+ * Although the `isStandardBrowserEnv` method indicates that
1112
+ * `allows axios to run in a web worker`, the WebWorker will still be
1113
+ * filtered out due to its judgment standard
1114
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1115
+ * This leads to a problem when axios post `FormData` in webWorker
1116
+ */ const hasStandardBrowserWebWorkerEnv = (()=>{
1117
+ return typeof WorkerGlobalScope !== 'undefined' && // eslint-disable-next-line no-undef
1118
+ self instanceof WorkerGlobalScope && typeof self.importScripts === 'function';
1119
+ })();
1120
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1121
+
1122
+ const utils = /*#__PURE__*/Object.freeze({
1123
+ __proto__: null,
1124
+ hasBrowserEnv: hasBrowserEnv,
1125
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1126
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1127
+ navigator: _navigator,
1128
+ origin: origin
1129
+ });
1130
+
1131
+ const platform = {
1132
+ ...utils,
1133
+ ...platform$1
1134
+ };
1135
+
1136
+ function toURLEncodedForm(data, options) {
1137
+ return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
1138
+ visitor: function(value, key, path, helpers) {
1139
+ if (platform.isNode && utils$1.isBuffer(value)) {
1140
+ this.append(key, value.toString('base64'));
1141
+ return false;
1142
+ }
1143
+ return helpers.defaultVisitor.apply(this, arguments);
1144
+ }
1145
+ }, options));
1146
+ }
1147
+
1148
+ /**
1149
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1150
+ *
1151
+ * @param {string} name - The name of the property to get.
1152
+ *
1153
+ * @returns An array of strings.
1154
+ */ function parsePropPath(name) {
1155
+ // foo[x][y][z]
1156
+ // foo.x.y.z
1157
+ // foo-x-y-z
1158
+ // foo x y z
1159
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match)=>{
1160
+ return match[0] === '[]' ? '' : match[1] || match[0];
1161
+ });
1162
+ }
1163
+ /**
1164
+ * Convert an array to an object.
1165
+ *
1166
+ * @param {Array<any>} arr - The array to convert to an object.
1167
+ *
1168
+ * @returns An object with the same keys and values as the array.
1169
+ */ function arrayToObject(arr) {
1170
+ const obj = {};
1171
+ const keys = Object.keys(arr);
1172
+ let i;
1173
+ const len = keys.length;
1174
+ let key;
1175
+ for(i = 0; i < len; i++){
1176
+ key = keys[i];
1177
+ obj[key] = arr[key];
1178
+ }
1179
+ return obj;
1180
+ }
1181
+ /**
1182
+ * It takes a FormData object and returns a JavaScript object
1183
+ *
1184
+ * @param {string} formData The FormData object to convert to JSON.
1185
+ *
1186
+ * @returns {Object<string, any> | null} The converted object.
1187
+ */ function formDataToJSON(formData) {
1188
+ function buildPath(path, value, target, index) {
1189
+ let name = path[index++];
1190
+ if (name === '__proto__') return true;
1191
+ const isNumericKey = Number.isFinite(+name);
1192
+ const isLast = index >= path.length;
1193
+ name = !name && utils$1.isArray(target) ? target.length : name;
1194
+ if (isLast) {
1195
+ if (utils$1.hasOwnProp(target, name)) {
1196
+ target[name] = [
1197
+ target[name],
1198
+ value
1199
+ ];
1200
+ } else {
1201
+ target[name] = value;
1202
+ }
1203
+ return !isNumericKey;
1204
+ }
1205
+ if (!target[name] || !utils$1.isObject(target[name])) {
1206
+ target[name] = [];
1207
+ }
1208
+ const result = buildPath(path, value, target[name], index);
1209
+ if (result && utils$1.isArray(target[name])) {
1210
+ target[name] = arrayToObject(target[name]);
1211
+ }
1212
+ return !isNumericKey;
1213
+ }
1214
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1215
+ const obj = {};
1216
+ utils$1.forEachEntry(formData, (name, value)=>{
1217
+ buildPath(parsePropPath(name), value, obj, 0);
1218
+ });
1219
+ return obj;
1220
+ }
1221
+ return null;
1222
+ }
1223
+
1224
+ /**
1225
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1226
+ * of the input
1227
+ *
1228
+ * @param {any} rawValue - The value to be stringified.
1229
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1230
+ * @param {Function} encoder - A function that takes a value and returns a string.
1231
+ *
1232
+ * @returns {string} A stringified version of the rawValue.
1233
+ */ function stringifySafely(rawValue, parser, encoder) {
1234
+ if (utils$1.isString(rawValue)) {
1235
+ try {
1236
+ (parser || JSON.parse)(rawValue);
1237
+ return utils$1.trim(rawValue);
1238
+ } catch (e) {
1239
+ if (e.name !== 'SyntaxError') {
1240
+ throw e;
1241
+ }
1242
+ }
1243
+ }
1244
+ return (encoder || JSON.stringify)(rawValue);
1245
+ }
1246
+ const defaults = {
1247
+ transitional: transitionalDefaults,
1248
+ adapter: [
1249
+ 'xhr',
1250
+ 'http',
1251
+ 'fetch'
1252
+ ],
1253
+ transformRequest: [
1254
+ function transformRequest(data, headers) {
1255
+ const contentType = headers.getContentType() || '';
1256
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1257
+ const isObjectPayload = utils$1.isObject(data);
1258
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1259
+ data = new FormData(data);
1260
+ }
1261
+ const isFormData = utils$1.isFormData(data);
1262
+ if (isFormData) {
1263
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1264
+ }
1265
+ 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)) {
1266
+ return data;
1267
+ }
1268
+ if (utils$1.isArrayBufferView(data)) {
1269
+ return data.buffer;
1270
+ }
1271
+ if (utils$1.isURLSearchParams(data)) {
1272
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1273
+ return data.toString();
1274
+ }
1275
+ let isFileList;
1276
+ if (isObjectPayload) {
1277
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1278
+ return toURLEncodedForm(data, this.formSerializer).toString();
1279
+ }
1280
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1281
+ const _FormData = this.env && this.env.FormData;
1282
+ return toFormData$1(isFileList ? {
1283
+ 'files[]': data
1284
+ } : data, _FormData && new _FormData(), this.formSerializer);
1285
+ }
1286
+ }
1287
+ if (isObjectPayload || hasJSONContentType) {
1288
+ headers.setContentType('application/json', false);
1289
+ return stringifySafely(data);
1290
+ }
1291
+ return data;
1292
+ }
1293
+ ],
1294
+ transformResponse: [
1295
+ function transformResponse(data) {
1296
+ const transitional = this.transitional || defaults.transitional;
1297
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1298
+ const JSONRequested = this.responseType === 'json';
1299
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1300
+ return data;
1301
+ }
1302
+ if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1303
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1304
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1305
+ try {
1306
+ return JSON.parse(data);
1307
+ } catch (e) {
1308
+ if (strictJSONParsing) {
1309
+ if (e.name === 'SyntaxError') {
1310
+ throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
1311
+ }
1312
+ throw e;
1313
+ }
1314
+ }
1315
+ }
1316
+ return data;
1317
+ }
1318
+ ],
1319
+ /**
1320
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1321
+ * timeout is not created.
1322
+ */ timeout: 0,
1323
+ xsrfCookieName: 'XSRF-TOKEN',
1324
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1325
+ maxContentLength: -1,
1326
+ maxBodyLength: -1,
1327
+ env: {
1328
+ FormData: platform.classes.FormData,
1329
+ Blob: platform.classes.Blob
1330
+ },
1331
+ validateStatus: function validateStatus(status) {
1332
+ return status >= 200 && status < 300;
1333
+ },
1334
+ headers: {
1335
+ common: {
1336
+ 'Accept': 'application/json, text/plain, */*',
1337
+ 'Content-Type': undefined
1338
+ }
1339
+ }
1340
+ };
1341
+ utils$1.forEach([
1342
+ 'delete',
1343
+ 'get',
1344
+ 'head',
1345
+ 'post',
1346
+ 'put',
1347
+ 'patch'
1348
+ ], (method)=>{
1349
+ defaults.headers[method] = {};
1350
+ });
1351
+ const defaults$1 = defaults;
1352
+
1353
+ // RawAxiosHeaders whose duplicates are ignored by node
1354
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1355
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1356
+ 'age',
1357
+ 'authorization',
1358
+ 'content-length',
1359
+ 'content-type',
1360
+ 'etag',
1361
+ 'expires',
1362
+ 'from',
1363
+ 'host',
1364
+ 'if-modified-since',
1365
+ 'if-unmodified-since',
1366
+ 'last-modified',
1367
+ 'location',
1368
+ 'max-forwards',
1369
+ 'proxy-authorization',
1370
+ 'referer',
1371
+ 'retry-after',
1372
+ 'user-agent'
1373
+ ]);
1374
+ /**
1375
+ * Parse headers into an object
1376
+ *
1377
+ * ```
1378
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1379
+ * Content-Type: application/json
1380
+ * Connection: keep-alive
1381
+ * Transfer-Encoding: chunked
1382
+ * ```
1383
+ *
1384
+ * @param {String} rawHeaders Headers needing to be parsed
1385
+ *
1386
+ * @returns {Object} Headers parsed into an object
1387
+ */ const parseHeaders = ((rawHeaders)=>{
1388
+ const parsed = {};
1389
+ let key;
1390
+ let val;
1391
+ let i;
1392
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1393
+ i = line.indexOf(':');
1394
+ key = line.substring(0, i).trim().toLowerCase();
1395
+ val = line.substring(i + 1).trim();
1396
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1397
+ return;
1398
+ }
1399
+ if (key === 'set-cookie') {
1400
+ if (parsed[key]) {
1401
+ parsed[key].push(val);
1402
+ } else {
1403
+ parsed[key] = [
1404
+ val
1405
+ ];
1406
+ }
1407
+ } else {
1408
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1409
+ }
1410
+ });
1411
+ return parsed;
1412
+ });
1413
+
1414
+ var _computedKey, _computedKey1;
1415
+ const $internals = Symbol('internals');
1416
+ function normalizeHeader(header) {
1417
+ return header && String(header).trim().toLowerCase();
1418
+ }
1419
+ function normalizeValue(value) {
1420
+ if (value === false || value == null) {
1421
+ return value;
1422
+ }
1423
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1424
+ }
1425
+ function parseTokens(str) {
1426
+ const tokens = Object.create(null);
1427
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1428
+ let match;
1429
+ while(match = tokensRE.exec(str)){
1430
+ tokens[match[1]] = match[2];
1431
+ }
1432
+ return tokens;
1433
+ }
1434
+ const isValidHeaderName = (str)=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1435
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1436
+ if (utils$1.isFunction(filter)) {
1437
+ return filter.call(this, value, header);
1438
+ }
1439
+ if (isHeaderNameFilter) {
1440
+ value = header;
1441
+ }
1442
+ if (!utils$1.isString(value)) return;
1443
+ if (utils$1.isString(filter)) {
1444
+ return value.indexOf(filter) !== -1;
1445
+ }
1446
+ if (utils$1.isRegExp(filter)) {
1447
+ return filter.test(value);
1448
+ }
1449
+ }
1450
+ function formatHeader(header) {
1451
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str)=>{
1452
+ return char.toUpperCase() + str;
1453
+ });
1454
+ }
1455
+ function buildAccessors(obj, header) {
1456
+ const accessorName = utils$1.toCamelCase(' ' + header);
1457
+ [
1458
+ 'get',
1459
+ 'set',
1460
+ 'has'
1461
+ ].forEach((methodName)=>{
1462
+ Object.defineProperty(obj, methodName + accessorName, {
1463
+ value: function(arg1, arg2, arg3) {
1464
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1465
+ },
1466
+ configurable: true
1467
+ });
1468
+ });
1469
+ }
1470
+ _computedKey = Symbol.iterator, _computedKey1 = Symbol.toStringTag;
1471
+ let AxiosHeaders$1 = class AxiosHeaders {
1472
+ constructor(headers){
1473
+ headers && this.set(headers);
1474
+ }
1475
+ /**
1476
+ *
1477
+ * @param {*} header
1478
+ * @param {*} valueOrRewrite
1479
+ * @param {*} rewrite true:无论源值是否存在均赋值,false:源值如存在不覆盖,
1480
+ * undefined:源值不为 false 直接赋值,false 不赋值
1481
+ * @returns
1482
+ */ set(header, valueOrRewrite, rewrite) {
1483
+ const self = this;
1484
+ function setHeader(_value, _header, _rewrite) {
1485
+ const lHeader = normalizeHeader(_header);
1486
+ if (!lHeader) {
1487
+ throw new Error('header name must be a non-empty string');
1488
+ }
1489
+ const key = utils$1.findKey(self, lHeader);
1490
+ if (!key || self[key] === undefined || _rewrite === true || _rewrite === undefined && self[key] !== false) {
1491
+ self[key || _header] = normalizeValue(_value);
1492
+ }
1493
+ }
1494
+ const setHeaders = (headers, _rewrite)=>utils$1.forEach(headers, (_value, _header)=>setHeader(_value, _header, _rewrite));
1495
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1496
+ setHeaders(header, valueOrRewrite);
1497
+ } else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1498
+ setHeaders(parseHeaders(header), valueOrRewrite);
1499
+ } else if (utils$1.isHeaders(header)) {
1500
+ for (const [key, value] of header.entries()){
1501
+ setHeader(value, key, rewrite);
1502
+ }
1503
+ } else {
1504
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1505
+ }
1506
+ return this;
1507
+ }
1508
+ get(header, parser) {
1509
+ header = normalizeHeader(header);
1510
+ if (header) {
1511
+ const key = utils$1.findKey(this, header);
1512
+ if (key) {
1513
+ const value = this[key];
1514
+ if (!parser) {
1515
+ return value;
1516
+ }
1517
+ if (parser === true) {
1518
+ return parseTokens(value);
1519
+ }
1520
+ if (utils$1.isFunction(parser)) {
1521
+ return parser.call(this, value, key);
1522
+ }
1523
+ if (utils$1.isRegExp(parser)) {
1524
+ return parser.exec(value);
1525
+ }
1526
+ throw new TypeError('parser must be boolean|regexp|function');
1527
+ }
1528
+ }
1529
+ }
1530
+ has(header, matcher) {
1531
+ header = normalizeHeader(header);
1532
+ if (header) {
1533
+ const key = utils$1.findKey(this, header);
1534
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1535
+ }
1536
+ return false;
1537
+ }
1538
+ delete(header, matcher) {
1539
+ const self = this;
1540
+ let deleted = false;
1541
+ function deleteHeader(_header) {
1542
+ _header = normalizeHeader(_header);
1543
+ if (_header) {
1544
+ const key = utils$1.findKey(self, _header);
1545
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
1546
+ delete self[key];
1547
+ deleted = true;
1548
+ }
1549
+ }
1550
+ }
1551
+ if (utils$1.isArray(header)) {
1552
+ header.forEach(deleteHeader);
1553
+ } else {
1554
+ deleteHeader(header);
1555
+ }
1556
+ return deleted;
1557
+ }
1558
+ clear(matcher) {
1559
+ const keys = Object.keys(this);
1560
+ let i = keys.length;
1561
+ let deleted = false;
1562
+ while(i--){
1563
+ const key = keys[i];
1564
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1565
+ delete this[key];
1566
+ deleted = true;
1567
+ }
1568
+ }
1569
+ return deleted;
1570
+ }
1571
+ normalize(format) {
1572
+ const self = this;
1573
+ const headers = {};
1574
+ utils$1.forEach(this, (value, header)=>{
1575
+ const key = utils$1.findKey(headers, header);
1576
+ if (key) {
1577
+ self[key] = normalizeValue(value);
1578
+ delete self[header];
1579
+ return;
1580
+ }
1581
+ const normalized = format ? formatHeader(header) : String(header).trim();
1582
+ if (normalized !== header) {
1583
+ delete self[header];
1584
+ }
1585
+ self[normalized] = normalizeValue(value);
1586
+ headers[normalized] = true;
1587
+ });
1588
+ return this;
1589
+ }
1590
+ concat(...targets) {
1591
+ return this.constructor.concat(this, ...targets);
1592
+ }
1593
+ toJSON(asStrings) {
1594
+ const obj = Object.create(null);
1595
+ utils$1.forEach(this, (value, header)=>{
1596
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
1597
+ });
1598
+ return obj;
1599
+ }
1600
+ [_computedKey]() {
1601
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1602
+ }
1603
+ toString() {
1604
+ return Object.entries(this.toJSON()).map(([header, value])=>header + ': ' + value).join('\n');
1605
+ }
1606
+ get [_computedKey1]() {
1607
+ return 'AxiosHeaders';
1608
+ }
1609
+ static from(thing) {
1610
+ return thing instanceof this ? thing : new this(thing);
1611
+ }
1612
+ static concat(first, ...targets) {
1613
+ const computed = new this(first);
1614
+ targets.forEach((target)=>computed.set(target));
1615
+ return computed;
1616
+ }
1617
+ static accessor(header) {
1618
+ const internals = this[$internals] = this[$internals] = {
1619
+ accessors: {}
1620
+ };
1621
+ const accessors = internals.accessors;
1622
+ const prototype = this.prototype;
1623
+ function defineAccessor(_header) {
1624
+ const lHeader = normalizeHeader(_header);
1625
+ if (!accessors[lHeader]) {
1626
+ buildAccessors(prototype, _header);
1627
+ accessors[lHeader] = true;
1628
+ }
1629
+ }
1630
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1631
+ return this;
1632
+ }
1633
+ };
1634
+ AxiosHeaders$1.accessor([
1635
+ 'Content-Type',
1636
+ 'Content-Length',
1637
+ 'Accept',
1638
+ 'Accept-Encoding',
1639
+ 'User-Agent',
1640
+ 'Authorization'
1641
+ ]);
1642
+ // reserved names hotfix
1643
+ utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key)=>{
1644
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
1645
+ return {
1646
+ get: ()=>value,
1647
+ set (headerValue) {
1648
+ this[mapped] = headerValue;
1649
+ }
1650
+ };
1651
+ });
1652
+ utils$1.freezeMethods(AxiosHeaders$1);
1653
+ const AxiosHeaders$2 = AxiosHeaders$1;
1654
+
1655
+ /**
1656
+ * Transform the data for a request or a response
1657
+ *
1658
+ * @param {Array|Function} fns A single function or Array of functions
1659
+ * @param {?Object} response The response object
1660
+ *
1661
+ * @returns {*} The resulting transformed data
1662
+ */ function transformData(fns, response) {
1663
+ const config = this || defaults$1;
1664
+ const context = response || config;
1665
+ const headers = AxiosHeaders$2.from(context.headers);
1666
+ let data = context.data;
1667
+ utils$1.forEach(fns, function transform(fn) {
1668
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
1669
+ });
1670
+ headers.normalize();
1671
+ return data;
1672
+ }
1673
+
1674
+ function isCancel$1(value) {
1675
+ return !!(value && value.__CANCEL__);
1676
+ }
1677
+
1678
+ /**
1679
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
1680
+ *
1681
+ * @param {string=} message The message.
1682
+ * @param {Object=} config The config.
1683
+ * @param {Object=} request The request.
1684
+ *
1685
+ * @returns {CanceledError} The created error.
1686
+ */ function CanceledError$1(message, config, request) {
1687
+ // eslint-disable-next-line no-eq-null,eqeqeq
1688
+ AxiosError$1.call(this, message == null ? 'canceled' : message, AxiosError$1.ERR_CANCELED, config, request);
1689
+ this.name = 'CanceledError';
1690
+ }
1691
+ utils$1.inherits(CanceledError$1, AxiosError$1, {
1692
+ __CANCEL__: true
1693
+ });
1694
+
1695
+ /**
1696
+ * Resolve or reject a Promise based on response status.
1697
+ *
1698
+ * @param {Function} resolve A function that resolves the promise.
1699
+ * @param {Function} reject A function that rejects the promise.
1700
+ * @param {object} response The response.
1701
+ *
1702
+ * @returns {object} The response.
1703
+ */ function settle(resolve, reject, response) {
1704
+ const validateStatus = response.config.validateStatus;
1705
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
1706
+ resolve(response);
1707
+ } else {
1708
+ reject(new AxiosError$1('Request failed with status code ' + response.status, [
1709
+ AxiosError$1.ERR_BAD_REQUEST,
1710
+ AxiosError$1.ERR_BAD_RESPONSE
1711
+ ][Math.floor(response.status / 100) - 4], response.config, response.request, response));
1712
+ }
1713
+ }
1714
+
1715
+ /**
1716
+ * Determines whether the specified URL is absolute
1717
+ *
1718
+ * @param {string} url The URL to test
1719
+ *
1720
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
1721
+ */ function isAbsoluteURL(url) {
1722
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
1723
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
1724
+ // by any combination of letters, digits, plus, period, or hyphen.
1725
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1726
+ }
1727
+
1728
+ /**
1729
+ * Creates a new URL by combining the specified URLs
1730
+ *
1731
+ * @param {string} baseURL The base URL
1732
+ * @param {string} relativeURL The relative URL
1733
+ *
1734
+ * @returns {string} The combined URL
1735
+ */ function combineURLs(baseURL, relativeURL) {
1736
+ return relativeURL ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') : baseURL;
1737
+ }
1738
+
1739
+ /**
1740
+ * Creates a new URL by combining the baseURL with the requestedURL,
1741
+ * only when the requestedURL is not already an absolute URL.
1742
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
1743
+ *
1744
+ * @param {string} baseURL The base URL
1745
+ * @param {string} requestedURL Absolute or relative URL to combine
1746
+ *
1747
+ * @returns {string} The combined full path
1748
+ */ function buildFullPath(baseURL, requestedURL) {
1749
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1750
+ return combineURLs(baseURL, requestedURL);
1751
+ }
1752
+ return requestedURL;
1753
+ }
1754
+
1755
+ const VERSION$1 = "1.7.7";
1756
+
1757
+ function parseProtocol(url) {
1758
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1759
+ return match && match[1] || '';
1760
+ }
1761
+
1762
+ const DATA_URL_PATTERN = /^(?:([^;]+);)?(?:[^;]+;)?(base64|),([\s\S]*)$/;
1763
+ /**
1764
+ * Parse data uri to a Buffer or Blob
1765
+ *
1766
+ * @param {String} uri
1767
+ * @param {?Boolean} asBlob
1768
+ * @param {?Object} options
1769
+ * @param {?Function} options.Blob
1770
+ *
1771
+ * @returns {Buffer|Blob}
1772
+ */ function fromDataURI(uri, asBlob, options) {
1773
+ const _Blob = options && options.Blob || platform.classes.Blob;
1774
+ const protocol = parseProtocol(uri);
1775
+ if (asBlob === undefined && _Blob) {
1776
+ asBlob = true;
1777
+ }
1778
+ if (protocol === 'data') {
1779
+ uri = protocol.length ? uri.slice(protocol.length + 1) : uri;
1780
+ const match = DATA_URL_PATTERN.exec(uri);
1781
+ if (!match) {
1782
+ throw new AxiosError$1('Invalid URL', AxiosError$1.ERR_INVALID_URL);
1783
+ }
1784
+ const mime = match[1];
1785
+ const isBase64 = match[2];
1786
+ const body = match[3];
1787
+ const buffer = Buffer.from(decodeURIComponent(body), isBase64 ? 'base64' : 'utf8');
1788
+ if (asBlob) {
1789
+ if (!_Blob) {
1790
+ throw new AxiosError$1('Blob is not supported', AxiosError$1.ERR_NOT_SUPPORT);
1791
+ }
1792
+ return new _Blob([
1793
+ buffer
1794
+ ], {
1795
+ type: mime
1796
+ });
1797
+ }
1798
+ return buffer;
1799
+ }
1800
+ throw new AxiosError$1('Unsupported protocol ' + protocol, AxiosError$1.ERR_NOT_SUPPORT);
1801
+ }
1802
+
1803
+ const kInternals = Symbol('internals');
1804
+ let AxiosTransformStream = class AxiosTransformStream extends stream.Transform {
1805
+ constructor(options){
1806
+ options = utils$1.toFlatObject(options, {
1807
+ maxRate: 0,
1808
+ chunkSize: 64 * 1024,
1809
+ minChunkSize: 100,
1810
+ timeWindow: 500,
1811
+ ticksRate: 2,
1812
+ samplesCount: 15
1813
+ }, null, (prop, source)=>{
1814
+ return !utils$1.isUndefined(source[prop]);
1815
+ });
1816
+ super({
1817
+ readableHighWaterMark: options.chunkSize
1818
+ });
1819
+ const internals = this[kInternals] = {
1820
+ timeWindow: options.timeWindow,
1821
+ chunkSize: options.chunkSize,
1822
+ maxRate: options.maxRate,
1823
+ minChunkSize: options.minChunkSize,
1824
+ bytesSeen: 0,
1825
+ isCaptured: false,
1826
+ notifiedBytesLoaded: 0,
1827
+ ts: Date.now(),
1828
+ bytes: 0,
1829
+ onReadCallback: null
1830
+ };
1831
+ this.on('newListener', (event)=>{
1832
+ if (event === 'progress') {
1833
+ if (!internals.isCaptured) {
1834
+ internals.isCaptured = true;
1835
+ }
1836
+ }
1837
+ });
1838
+ }
1839
+ _read(size) {
1840
+ const internals = this[kInternals];
1841
+ if (internals.onReadCallback) {
1842
+ internals.onReadCallback();
1843
+ }
1844
+ return super._read(size);
1845
+ }
1846
+ _transform(chunk, encoding, callback) {
1847
+ const internals = this[kInternals];
1848
+ const maxRate = internals.maxRate;
1849
+ const readableHighWaterMark = this.readableHighWaterMark;
1850
+ const timeWindow = internals.timeWindow;
1851
+ const divider = 1000 / timeWindow;
1852
+ const bytesThreshold = maxRate / divider;
1853
+ const minChunkSize = internals.minChunkSize !== false ? Math.max(internals.minChunkSize, bytesThreshold * 0.01) : 0;
1854
+ const pushChunk = (_chunk, _callback)=>{
1855
+ const bytes = Buffer.byteLength(_chunk);
1856
+ internals.bytesSeen += bytes;
1857
+ internals.bytes += bytes;
1858
+ internals.isCaptured && this.emit('progress', internals.bytesSeen);
1859
+ if (this.push(_chunk)) {
1860
+ process.nextTick(_callback);
1861
+ } else {
1862
+ internals.onReadCallback = ()=>{
1863
+ internals.onReadCallback = null;
1864
+ process.nextTick(_callback);
1865
+ };
1866
+ }
1867
+ };
1868
+ const transformChunk = (_chunk, _callback)=>{
1869
+ const chunkSize = Buffer.byteLength(_chunk);
1870
+ let chunkRemainder = null;
1871
+ let maxChunkSize = readableHighWaterMark;
1872
+ let bytesLeft;
1873
+ let passed = 0;
1874
+ if (maxRate) {
1875
+ const now = Date.now();
1876
+ if (!internals.ts || (passed = now - internals.ts) >= timeWindow) {
1877
+ internals.ts = now;
1878
+ bytesLeft = bytesThreshold - internals.bytes;
1879
+ internals.bytes = bytesLeft < 0 ? -bytesLeft : 0;
1880
+ passed = 0;
1881
+ }
1882
+ bytesLeft = bytesThreshold - internals.bytes;
1883
+ }
1884
+ if (maxRate) {
1885
+ if (bytesLeft <= 0) {
1886
+ // next time window
1887
+ return setTimeout(()=>{
1888
+ _callback(null, _chunk);
1889
+ }, timeWindow - passed);
1890
+ }
1891
+ if (bytesLeft < maxChunkSize) {
1892
+ maxChunkSize = bytesLeft;
1893
+ }
1894
+ }
1895
+ if (maxChunkSize && chunkSize > maxChunkSize && chunkSize - maxChunkSize > minChunkSize) {
1896
+ chunkRemainder = _chunk.subarray(maxChunkSize);
1897
+ _chunk = _chunk.subarray(0, maxChunkSize);
1898
+ }
1899
+ pushChunk(_chunk, chunkRemainder ? ()=>{
1900
+ process.nextTick(_callback, null, chunkRemainder);
1901
+ } : _callback);
1902
+ };
1903
+ transformChunk(chunk, function transformNextChunk(err, _chunk) {
1904
+ if (err) {
1905
+ return callback(err);
1906
+ }
1907
+ if (_chunk) {
1908
+ transformChunk(_chunk, transformNextChunk);
1909
+ } else {
1910
+ callback(null);
1911
+ }
1912
+ });
1913
+ }
1914
+ };
1915
+ const AxiosTransformStream$1 = AxiosTransformStream;
1916
+
1917
+ const { asyncIterator } = Symbol;
1918
+ const readBlob = async function*(blob) {
1919
+ if (blob.stream) {
1920
+ yield* blob.stream();
1921
+ } else if (blob.arrayBuffer) {
1922
+ yield await blob.arrayBuffer();
1923
+ } else if (blob[asyncIterator]) {
1924
+ yield* blob[asyncIterator]();
1925
+ } else {
1926
+ yield blob;
1927
+ }
1928
+ };
1929
+ const readBlob$1 = readBlob;
1930
+
1931
+ const BOUNDARY_ALPHABET = utils$1.ALPHABET.ALPHA_DIGIT + '-_';
1932
+ const textEncoder = new TextEncoder();
1933
+ const CRLF = '\r\n';
1934
+ const CRLF_BYTES = textEncoder.encode(CRLF);
1935
+ const CRLF_BYTES_COUNT = 2;
1936
+ let FormDataPart = class FormDataPart {
1937
+ constructor(name, value){
1938
+ const { escapeName } = this.constructor;
1939
+ const isStringValue = utils$1.isString(value);
1940
+ let headers = `Content-Disposition: form-data; name="${escapeName(name)}"${!isStringValue && value.name ? `; filename="${escapeName(value.name)}"` : ''}${CRLF}`;
1941
+ if (isStringValue) {
1942
+ value = textEncoder.encode(String(value).replace(/\r?\n|\r\n?/g, CRLF));
1943
+ } else {
1944
+ headers += `Content-Type: ${value.type || "application/octet-stream"}${CRLF}`;
1945
+ }
1946
+ this.headers = textEncoder.encode(headers + CRLF);
1947
+ this.contentLength = isStringValue ? value.byteLength : value.size;
1948
+ this.size = this.headers.byteLength + this.contentLength + CRLF_BYTES_COUNT;
1949
+ this.name = name;
1950
+ this.value = value;
1951
+ }
1952
+ async *encode() {
1953
+ yield this.headers;
1954
+ const { value } = this;
1955
+ if (utils$1.isTypedArray(value)) {
1956
+ yield value;
1957
+ } else {
1958
+ yield* readBlob$1(value);
1959
+ }
1960
+ yield CRLF_BYTES;
1961
+ }
1962
+ static escapeName(name) {
1963
+ return String(name).replace(/[\r\n"]/g, (match)=>({
1964
+ '\r': '%0D',
1965
+ '\n': '%0A',
1966
+ '"': '%22'
1967
+ })[match]);
1968
+ }
1969
+ };
1970
+ const formDataToStream = (form, headersHandler, options)=>{
1971
+ const { tag = 'form-data-boundary', size = 25, boundary = tag + '-' + utils$1.generateString(size, BOUNDARY_ALPHABET) } = options || {};
1972
+ if (!utils$1.isFormData(form)) {
1973
+ throw TypeError('FormData instance required');
1974
+ }
1975
+ if (boundary.length < 1 || boundary.length > 70) {
1976
+ throw Error('boundary must be 10-70 characters long');
1977
+ }
1978
+ const boundaryBytes = textEncoder.encode('--' + boundary + CRLF);
1979
+ const footerBytes = textEncoder.encode('--' + boundary + '--' + CRLF + CRLF);
1980
+ let contentLength = footerBytes.byteLength;
1981
+ const parts = Array.from(form.entries()).map(([name, value])=>{
1982
+ const part = new FormDataPart(name, value);
1983
+ contentLength += part.size;
1984
+ return part;
1985
+ });
1986
+ contentLength += boundaryBytes.byteLength * parts.length;
1987
+ contentLength = utils$1.toFiniteNumber(contentLength);
1988
+ const computedHeaders = {
1989
+ 'Content-Type': `multipart/form-data; boundary=${boundary}`
1990
+ };
1991
+ if (Number.isFinite(contentLength)) {
1992
+ computedHeaders['Content-Length'] = contentLength;
1993
+ }
1994
+ headersHandler && headersHandler(computedHeaders);
1995
+ return Readable.from(async function*() {
1996
+ for (const part of parts){
1997
+ yield boundaryBytes;
1998
+ yield* part.encode();
1999
+ }
2000
+ yield footerBytes;
2001
+ }());
2002
+ };
2003
+ const formDataToStream$1 = formDataToStream;
2004
+
2005
+ const callbackify = (fn, reducer)=>{
2006
+ return utils$1.isAsyncFn(fn) ? function(...args) {
2007
+ const cb = args.pop();
2008
+ fn.apply(this, args).then((value)=>{
2009
+ try {
2010
+ reducer ? cb(null, ...reducer(value)) : cb(null, value);
2011
+ } catch (err) {
2012
+ cb(err);
2013
+ }
2014
+ }, cb);
2015
+ } : fn;
2016
+ };
2017
+ const callbackify$1 = callbackify;
2018
+
2019
+ /**
2020
+ * Calculate data maxRate
2021
+ * @param {Number} [samplesCount= 10]
2022
+ * @param {Number} [min= 1000]
2023
+ * @returns {Function}
2024
+ */ function speedometer(samplesCount, min) {
2025
+ samplesCount = samplesCount || 10;
2026
+ const bytes = new Array(samplesCount);
2027
+ const timestamps = new Array(samplesCount);
2028
+ let head = 0;
2029
+ let tail = 0;
2030
+ let firstSampleTS;
2031
+ min = min !== undefined ? min : 1000;
2032
+ return function push(chunkLength) {
2033
+ const now = Date.now();
2034
+ const startedAt = timestamps[tail];
2035
+ if (!firstSampleTS) {
2036
+ firstSampleTS = now;
2037
+ }
2038
+ bytes[head] = chunkLength;
2039
+ timestamps[head] = now;
2040
+ let i = tail;
2041
+ let bytesCount = 0;
2042
+ while(i !== head){
2043
+ bytesCount += bytes[i++];
2044
+ i = i % samplesCount;
2045
+ }
2046
+ head = (head + 1) % samplesCount;
2047
+ if (head === tail) {
2048
+ tail = (tail + 1) % samplesCount;
2049
+ }
2050
+ if (now - firstSampleTS < min) {
2051
+ return;
2052
+ }
2053
+ const passed = startedAt && now - startedAt;
2054
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2055
+ };
2056
+ }
2057
+
2058
+ /**
2059
+ * Throttle decorator
2060
+ * @param {Function} fn
2061
+ * @param {Number} freq
2062
+ * @return {Function}
2063
+ */ function throttle(fn, freq) {
2064
+ let timestamp = 0;
2065
+ let threshold = 1000 / freq;
2066
+ let lastArgs;
2067
+ let timer;
2068
+ const invoke = (args, now = Date.now())=>{
2069
+ timestamp = now;
2070
+ lastArgs = null;
2071
+ if (timer) {
2072
+ clearTimeout(timer);
2073
+ timer = null;
2074
+ }
2075
+ fn.apply(null, args);
2076
+ };
2077
+ const throttled = (...args)=>{
2078
+ const now = Date.now();
2079
+ const passed = now - timestamp;
2080
+ if (passed >= threshold) {
2081
+ invoke(args, now);
2082
+ } else {
2083
+ lastArgs = args;
2084
+ if (!timer) {
2085
+ timer = setTimeout(()=>{
2086
+ timer = null;
2087
+ invoke(lastArgs);
2088
+ }, threshold - passed);
2089
+ }
2090
+ }
2091
+ };
2092
+ const flush = ()=>lastArgs && invoke(lastArgs);
2093
+ return [
2094
+ throttled,
2095
+ flush
2096
+ ];
2097
+ }
2098
+
2099
+ /**
2100
+ *
2101
+ * @param {*} listener
2102
+ * @param {*} isDownloadStream
2103
+ * @param {*} freq
2104
+ * @returns
2105
+ */ const progressEventReducer = (listener, isDownloadStream, freq = 3)=>{
2106
+ let bytesNotified = 0;
2107
+ const _speedometer = speedometer(50, 250);
2108
+ return throttle((e)=>{
2109
+ const loaded = e.loaded;
2110
+ const total = e.lengthComputable ? e.total : undefined;
2111
+ const progressBytes = loaded - bytesNotified;
2112
+ const rate = _speedometer(progressBytes);
2113
+ const inRange = loaded <= total;
2114
+ bytesNotified = loaded;
2115
+ const data = {
2116
+ loaded,
2117
+ total,
2118
+ progress: total ? loaded / total : undefined,
2119
+ bytes: progressBytes,
2120
+ rate: rate ? rate : undefined,
2121
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2122
+ event: e,
2123
+ lengthComputable: total != null,
2124
+ [isDownloadStream ? 'download' : 'upload']: true
2125
+ };
2126
+ listener(data);
2127
+ }, freq);
2128
+ };
2129
+ /**
2130
+ *
2131
+ * @param {*} total
2132
+ * @param {*} throttled
2133
+ * @returns
2134
+ */ const progressEventDecorator = (total, throttled)=>{
2135
+ const lengthComputable = total != null;
2136
+ return [
2137
+ (loaded)=>throttled[0]({
2138
+ lengthComputable,
2139
+ total,
2140
+ loaded
2141
+ }),
2142
+ throttled[1]
2143
+ ];
2144
+ };
2145
+ /**
2146
+ *
2147
+ * @param {*} fn
2148
+ * @returns
2149
+ */ const asyncDecorator = (fn)=>(...args)=>utils$1.asap(()=>fn(...args));
2150
+
2151
+ // import Agent from '../fea/agent.js'
2152
+ const log = log$1({
2153
+ env: `wia:req:${name(import.meta.url)}`
2154
+ });
2155
+ const isBrotliSupported = utils$1.isFunction(zlib.createBrotliDecompress);
2156
+ const isHttps = /https:?/;
2157
+ const supportedProtocols = platform.protocols.map((protocol)=>`${protocol}:`);
2158
+ const isHttpAdapterSupported = typeof process !== "undefined" && utils$1.kindOf(process) === "process";
2159
+ /**
2160
+ * !+++
2161
+ * 将request 函数改为类,请求拆分为 init 初始化和 请求执行,
2162
+ * 如需重新发起请求时,无需重新初始化
2163
+ */ let HttpAdapter = class HttpAdapter {
2164
+ /**
2165
+ *
2166
+ * @param {*} config
2167
+ */ constructor(config){
2168
+ this.isDone = false;
2169
+ this.rejected = false;
2170
+ /** @type {*} */ this.req = null;
2171
+ /** @type {*} */ this.config = null;
2172
+ /** @type {*} */ this.data = null;
2173
+ /** @type {*} */ this.transport = null;
2174
+ this.config = config;
2175
+ // temporary internal emitter until the AxiosRequest class will be implemented
2176
+ this.emitter = new EventEmitter();
2177
+ }
2178
+ /**
2179
+ *
2180
+ * @param {number} code
2181
+ * @returns
2182
+ */ noBody(code) {
2183
+ return this.method === "HEAD" || // Informational
2184
+ code >= 100 && code < 200 || // No Content
2185
+ code === 204 || // Not Modified
2186
+ code === 304;
2187
+ }
2188
+ /**
2189
+ * 发起终止事件
2190
+ * @param {*} reason
2191
+ */ abort(reason) {
2192
+ this.emitter.emit("abort", !reason || reason.type ? new CanceledError$1(null, this.config, this.req) : reason);
2193
+ }
2194
+ onFinished() {
2195
+ const { config, emitter, abort } = this;
2196
+ config?.cancelToken?.unsubscribe(abort);
2197
+ config?.signal?.removeEventListener("abort", abort);
2198
+ emitter?.removeAllListeners();
2199
+ }
2200
+ /**
2201
+ *
2202
+ * @param {*} value
2203
+ * @param {*} isRejected
2204
+ */ onDone(value, isRejected) {
2205
+ this.isDone = true;
2206
+ if (isRejected) {
2207
+ this.rejected = true;
2208
+ this.onFinished();
2209
+ }
2210
+ }
2211
+ /**
2212
+ *
2213
+ * @param {*} value
2214
+ * @param {*} isRejected
2215
+ * @returns
2216
+ */ done(value, isRejected) {
2217
+ if (this.isDone) return;
2218
+ this.isDone = true;
2219
+ this?.onDone(value, isRejected);
2220
+ }
2221
+ /**
2222
+ * 初始化,生成 options 供请求调用
2223
+ * @returns {*} options
2224
+ */ async init() {
2225
+ // biome-ignore lint/complexity/noUselessThisAlias: <explanation>
2226
+ const _ = this;
2227
+ const { config } = _;
2228
+ let { data, lookup, family } = config;
2229
+ const method = config.method.toUpperCase();
2230
+ _.method = method;
2231
+ if (lookup) {
2232
+ const _lookup = callbackify$1(lookup, /** @param {*} value */ (value)=>utils$1.isArray(value) ? value : [
2233
+ value
2234
+ ]);
2235
+ // hotfix to support opt.all option which is required for node 20.x
2236
+ /**
2237
+ * @param {string} hostname
2238
+ * @param {*} opt
2239
+ * @param {*} cb
2240
+ */ lookup = (hostname, opt, cb)=>{
2241
+ _lookup(hostname, opt, (err, arg0, arg1)=>{
2242
+ if (err) return cb(err);
2243
+ const addresses = utils$1.isArray(arg0) ? arg0.map((addr)=>buildAddressEntry(addr)) : [
2244
+ buildAddressEntry(arg0, arg1)
2245
+ ];
2246
+ opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
2247
+ });
2248
+ };
2249
+ }
2250
+ if (config.cancelToken || config.signal) {
2251
+ config.cancelToken?.subscribe(_.abort);
2252
+ if (config.signal) {
2253
+ if (config.signal.aborted) _.abort();
2254
+ else config.signal.addEventListener("abort", _.abort);
2255
+ }
2256
+ }
2257
+ // Parse url
2258
+ const fullPath = buildFullPath(config.baseURL, config.url);
2259
+ // 'https://user:pass@sub.host.com:8080/p/a/t/h?query=string#hash'
2260
+ const parsed = new URL(fullPath, platform.hasBrowserEnv ? platform.origin : undefined);
2261
+ // http: or https:
2262
+ const protocol = parsed.protocol || supportedProtocols[0];
2263
+ _.protocol = protocol;
2264
+ if (protocol === "data:" && method !== "GET") {
2265
+ // throw error
2266
+ const response = {
2267
+ status: 405,
2268
+ statusText: "method not allowed",
2269
+ headers: {},
2270
+ config
2271
+ };
2272
+ throw new AxiosError$1(`Request failed with status code ${response.status}`, [
2273
+ AxiosError$1.ERR_BAD_REQUEST,
2274
+ AxiosError$1.ERR_BAD_RESPONSE
2275
+ ][Math.floor(response.status / 100) - 4], response.config, response.request, response);
2276
+ }
2277
+ if (supportedProtocols.indexOf(protocol) === -1) {
2278
+ throw new AxiosError$1(`Unsupported protocol ${protocol}`, AxiosError$1.ERR_BAD_REQUEST, config);
2279
+ }
2280
+ const headers = AxiosHeaders$2.from(config.headers).normalize();
2281
+ // Set User-Agent (required by some servers)
2282
+ // See https://github.com/axios/axios/issues/69
2283
+ // User-Agent is specified; handle case where no UA header is desired
2284
+ // Only set header if it hasn't been set in config
2285
+ // ! headers.set('User-Agent', 'axios/' + VERSION, false);
2286
+ headers.set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.35", false);
2287
+ const { onDownloadProgress, onUploadProgress, maxRate } = config;
2288
+ // support for spec compliant FormData objects
2289
+ if (utils$1.isSpecCompliantForm(data)) {
2290
+ const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
2291
+ data = formDataToStream$1(data, /** @param {*} formHeaders */ (formHeaders)=>headers.set(formHeaders), {
2292
+ tag: `axios-${VERSION$1}-boundary`,
2293
+ boundary: userBoundary?.[1] || undefined
2294
+ });
2295
+ // support for https://www.npmjs.com/package/form-data api
2296
+ } else if (utils$1.isFormData(data) && utils$1.isFunction(data.getHeaders)) {
2297
+ headers.set(data.getHeaders());
2298
+ if (!headers.hasContentLength()) {
2299
+ try {
2300
+ const knownLength = await util.promisify(data.getLength).call(data);
2301
+ Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
2302
+ /*eslint no-empty:0*/ } catch (e) {}
2303
+ }
2304
+ } else if (utils$1.isBlob(data)) {
2305
+ data.size && headers.setContentType(data.type || "application/octet-stream");
2306
+ headers.setContentLength(data.size || 0);
2307
+ data = stream$1.Readable.from(readBlob$1(data));
2308
+ } else if (data && !utils$1.isStream(data)) {
2309
+ if (Buffer.isBuffer(data)) ; else if (utils$1.isArrayBuffer(data)) {
2310
+ data = Buffer.from(new Uint8Array(data));
2311
+ } else if (utils$1.isString(data)) {
2312
+ data = Buffer.from(data, "utf-8");
2313
+ } else {
2314
+ throw new AxiosError$1("Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream", AxiosError$1.ERR_BAD_REQUEST, config);
2315
+ }
2316
+ // Add Content-Length header if data exists
2317
+ headers.setContentLength(data.length, false);
2318
+ if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
2319
+ throw new AxiosError$1("Request body larger than maxBodyLength limit", AxiosError$1.ERR_BAD_REQUEST, config);
2320
+ }
2321
+ }
2322
+ const contentLength = utils$1.toFiniteNumber(headers.getContentLength());
2323
+ let maxUploadRate;
2324
+ let maxDownloadRate;
2325
+ if (utils$1.isArray(maxRate)) [maxUploadRate, maxDownloadRate] = maxRate;
2326
+ else {
2327
+ maxUploadRate = maxRate;
2328
+ maxDownloadRate = maxRate;
2329
+ }
2330
+ _.maxUploadRate = maxUploadRate;
2331
+ _.maxDownloadRate = maxDownloadRate;
2332
+ if (data && (onUploadProgress || maxUploadRate)) {
2333
+ if (!utils$1.isStream(data)) {
2334
+ data = stream$1.Readable.from(data, {
2335
+ objectMode: false
2336
+ });
2337
+ }
2338
+ data = stream$1.pipeline([
2339
+ data,
2340
+ new AxiosTransformStream$1({
2341
+ maxRate: utils$1.toFiniteNumber(maxUploadRate)
2342
+ })
2343
+ ], utils$1.noop);
2344
+ onUploadProgress && data.on("progress", flushOnFinish(data, progressEventDecorator(contentLength, progressEventReducer(asyncDecorator(onUploadProgress), false, 3))));
2345
+ }
2346
+ // HTTP basic authentication
2347
+ let auth;
2348
+ if (config.auth) {
2349
+ const username = config.auth.username || "";
2350
+ const password = config.auth.password || "";
2351
+ auth = `${username}:${password}`;
2352
+ }
2353
+ if (!auth && parsed.username) {
2354
+ const urlUsername = parsed.username;
2355
+ const urlPassword = parsed.password;
2356
+ auth = `${urlUsername}:${urlPassword}`;
2357
+ }
2358
+ auth && headers.delete("authorization");
2359
+ let path;
2360
+ try {
2361
+ path = buildURL(parsed.pathname + parsed.search, config.params, config.paramsSerializer).replace(/^\?/, "");
2362
+ } catch (err) {
2363
+ /** @type {*} */ const customErr = new Error(err.message);
2364
+ customErr.config = config;
2365
+ customErr.url = config.url;
2366
+ customErr.exists = true;
2367
+ throw customErr;
2368
+ }
2369
+ headers.set("Accept-Encoding", `gzip, compress, deflate${isBrotliSupported ? ", br" : ""}`, false);
2370
+ /** @type {*} */ const options = {
2371
+ path,
2372
+ method,
2373
+ headers: headers.toJSON(),
2374
+ agents: {
2375
+ http: config.httpAgent,
2376
+ https: config.httpsAgent
2377
+ },
2378
+ auth,
2379
+ protocol,
2380
+ family,
2381
+ beforeRedirect: dispatchBeforeRedirect,
2382
+ beforeRedirects: {}
2383
+ };
2384
+ // cacheable-lookup integration hotfix
2385
+ if (!utils$1.isUndefined(lookup)) options.lookup = lookup;
2386
+ if (config.socketPath) options.socketPath = config.socketPath;
2387
+ else {
2388
+ options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
2389
+ options.port = parsed.port;
2390
+ // ! proxy
2391
+ if (config.agent) options.agents = new Agent(config.agent);
2392
+ }
2393
+ // 执行请求的具体对象
2394
+ _.transport = config.transport;
2395
+ const isHttpsRequest = isHttps.test(options.protocol);
2396
+ options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
2397
+ if (config.maxBodyLength > -1) options.maxBodyLength = config.maxBodyLength;
2398
+ else options.maxBodyLength = Number.POSITIVE_INFINITY;
2399
+ // maxRedirects 缺省 21,不跳转,直接使用系统http or https,不支持 stream
2400
+ // if (config.maxRedirects === 0 && !config.stream) transport = isHttpsRequest ? https : http;
2401
+ // 自动跳转
2402
+ // else {
2403
+ // 支持跳转或stream,需使用 http、https 封装类
2404
+ if (config.maxRedirects) options.maxRedirects = config.maxRedirects;
2405
+ if (config.beforeRedirect) options.beforeRedirects.config = config.beforeRedirect;
2406
+ if (config.insecureHTTPParser) options.insecureHTTPParser = config.insecureHTTPParser;
2407
+ _.options = options;
2408
+ _.data = data;
2409
+ log({
2410
+ config
2411
+ }, "init");
2412
+ return options;
2413
+ }
2414
+ /**
2415
+ * 执行请求
2416
+ * 需抛出内部异常
2417
+ * @param {Axios} axios 实例
2418
+ * @returns {Promise<*>}
2419
+ */ async request(axios) {
2420
+ /** @type {*} */ // biome-ignore lint/style/useConst: <explanation>
2421
+ let R;
2422
+ // biome-ignore lint/complexity/noUselessThisAlias: <explanation>
2423
+ const _ = this;
2424
+ try {
2425
+ await _.init();
2426
+ const { transport, protocol, config, options, data, abort, emitter, maxDownloadRate } = _;
2427
+ const { responseType, responseEncoding, onDownloadProgress } = config;
2428
+ if (protocol === "data:") {
2429
+ /** @type {*} */ let convertedData;
2430
+ try {
2431
+ convertedData = fromDataURI(config.url, responseType === "blob", {
2432
+ Blob: config.env?.Blob
2433
+ });
2434
+ } catch (err) {
2435
+ throw AxiosError$1.from(err, AxiosError$1.ERR_BAD_REQUEST, config);
2436
+ }
2437
+ if (responseType === "text") {
2438
+ convertedData = convertedData.toString(responseEncoding);
2439
+ if (!responseEncoding || responseEncoding === "utf8") {
2440
+ convertedData = utils$1.stripBOM(convertedData);
2441
+ }
2442
+ } else if (responseType === "stream") {
2443
+ convertedData = stream$1.Readable.from(convertedData);
2444
+ }
2445
+ // 返回响应
2446
+ R = {
2447
+ data: convertedData,
2448
+ status: 200,
2449
+ statusText: "OK",
2450
+ headers: new AxiosHeaders$2(),
2451
+ config
2452
+ };
2453
+ } else {
2454
+ let transformStream;
2455
+ if (onDownloadProgress || maxDownloadRate) {
2456
+ transformStream = new AxiosTransformStream$1({
2457
+ maxRate: utils$1.toFiniteNumber(maxDownloadRate)
2458
+ });
2459
+ onDownloadProgress && transformStream.on("progress", flushOnFinish(transformStream, progressEventDecorator(transformStream.responseLength, progressEventReducer(asyncDecorator(onDownloadProgress), true, 3))));
2460
+ }
2461
+ options.transformStream = transformStream;
2462
+ // 发起异步请求
2463
+ R = await new Promise((resolve, reject)=>{
2464
+ _.emitter.once("abort", reject);
2465
+ options.stream = config.stream;
2466
+ options.decompress = config.decompress;
2467
+ // Create the request,promise false: return stream
2468
+ // log.debug('request', {options});
2469
+ const req = transport ? transport.request(options) : request(options);
2470
+ if (!req) return reject(new AxiosError$1("Request failed.", AxiosError$1.ERR_BAD_REQUEST, config));
2471
+ _.req = req;
2472
+ emitter.once("abort", (err)=>{
2473
+ log("onabort");
2474
+ reject(err);
2475
+ req.destroy(err);
2476
+ });
2477
+ // Handle errors
2478
+ req.on("error", /** @param {*} err */ (err)=>{
2479
+ log("onerror");
2480
+ // @todo remove
2481
+ // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
2482
+ reject(AxiosError$1.from(err, null, config, req));
2483
+ });
2484
+ // set tcp keep alive to prevent drop connection by peer
2485
+ req.on("socket", /** @param {*} socket */ (socket)=>{
2486
+ log("onsocket");
2487
+ // default interval of sending ack packet is 1 minute
2488
+ socket.setKeepAlive(true, 1000 * 60);
2489
+ });
2490
+ // Handle request timeout
2491
+ if (config.timeout) {
2492
+ // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
2493
+ const timeout = Number.parseInt(config.timeout);
2494
+ if (Number.isNaN(timeout)) {
2495
+ reject(new AxiosError$1("error trying to parse `config.timeout` to int", AxiosError$1.ERR_BAD_OPTION_VALUE, config, req));
2496
+ } else {
2497
+ // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
2498
+ // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
2499
+ // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
2500
+ // And then these socket which be hang up will devouring CPU little by little.
2501
+ // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
2502
+ req.setTimeout(timeout, ()=>{
2503
+ if (_.isDone) return;
2504
+ let timeoutErrorMessage = config.timeout ? `timeout of ${config.timeout}ms exceeded` : "timeout exceeded";
2505
+ const transitional = config.transitional || transitionalDefaults;
2506
+ if (config.timeoutErrorMessage) {
2507
+ timeoutErrorMessage = config.timeoutErrorMessage;
2508
+ }
2509
+ reject(new AxiosError$1(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED, config, req));
2510
+ abort();
2511
+ });
2512
+ }
2513
+ }
2514
+ // stream finished
2515
+ req.on("finished", _.onFinished.bind(_));
2516
+ // ! stream 模式不等待响应数据,直接返回 req,建立pipe管道流
2517
+ if (config.stream) resolve(req);
2518
+ else {
2519
+ // 非stream模式,等待响应数据,返回数据
2520
+ req.on("response", /**
2521
+ * @param {*} res
2522
+ * @param {*} stream
2523
+ */ (res, stream)=>{
2524
+ if (req.destroyed) return;
2525
+ // 'transfer-encoding': 'chunked'时,无content-length,axios v1.2 不能自动解压
2526
+ const responseLength = +res.headers["content-length"];
2527
+ log("onresponse", {
2528
+ statusCode: res.statusCode,
2529
+ responseLength,
2530
+ headers: res.headers
2531
+ });
2532
+ // return the last request(ClientRequest) in case of redirects
2533
+ const lastRequest = res.req || req;
2534
+ /** @type {*} */ const response = {
2535
+ status: res.statusCode,
2536
+ statusText: res.statusMessage,
2537
+ headers: new AxiosHeaders$2(res.headers),
2538
+ config,
2539
+ request: lastRequest
2540
+ };
2541
+ // 直接返回 responseStream
2542
+ if (responseType === "stream") {
2543
+ response.data = stream;
2544
+ settle(resolve, reject, response);
2545
+ } else {
2546
+ // 处理 responseStream
2547
+ /** @type {*} */ const responseBuffer = [];
2548
+ let totalResponseBytes = 0;
2549
+ // 处理数据
2550
+ stream.on("data", /** @param {*} chunk */ (chunk)=>{
2551
+ responseBuffer.push(chunk);
2552
+ totalResponseBytes += chunk.length;
2553
+ // make sure the content length is not over the maxContentLength if specified
2554
+ if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
2555
+ // stream.destroy() emit aborted event before calling reject() on Node.js v16
2556
+ _.rejected = true;
2557
+ stream.destroy();
2558
+ reject(new AxiosError$1(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError$1.ERR_BAD_RESPONSE, config, lastRequest));
2559
+ }
2560
+ });
2561
+ stream.on("aborted", function handlerStreamAborted() {
2562
+ if (_.rejected) return;
2563
+ const err = new AxiosError$1(`maxContentLength size of ${config.maxContentLength} exceeded`, AxiosError$1.ERR_BAD_RESPONSE, config, lastRequest);
2564
+ stream.destroy(err);
2565
+ reject(err);
2566
+ });
2567
+ stream.on("error", function handleStreamError(err) {
2568
+ if (req.destroyed) return;
2569
+ reject(AxiosError$1.from(err, null, config, lastRequest));
2570
+ });
2571
+ // 数据传输结束
2572
+ stream.on("end", function handleStreamEnd() {
2573
+ try {
2574
+ let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
2575
+ if (responseType !== "arraybuffer") {
2576
+ responseData = responseData.toString(responseEncoding);
2577
+ if (!responseEncoding || responseEncoding === "utf8") {
2578
+ responseData = utils$1.stripBOM(responseData);
2579
+ }
2580
+ }
2581
+ response.data = responseData;
2582
+ settle(resolve, reject, response);
2583
+ } catch (err) {
2584
+ reject(AxiosError$1.from(err, null, config, response.request, response));
2585
+ }
2586
+ });
2587
+ }
2588
+ emitter.once("abort", (err)=>{
2589
+ if (!stream.destroyed) {
2590
+ stream.emit("error", err);
2591
+ stream.destroy();
2592
+ }
2593
+ });
2594
+ });
2595
+ // 发送数据
2596
+ if (utils$1.isStream(data)) {
2597
+ // Send the request
2598
+ let ended = false;
2599
+ let errored = false;
2600
+ data.on("end", ()=>{
2601
+ ended = true;
2602
+ });
2603
+ data.once("error", /** @param {*} err */ (err)=>{
2604
+ errored = true;
2605
+ req.destroy(err);
2606
+ });
2607
+ data.on("close", ()=>{
2608
+ if (!ended && !errored) {
2609
+ abort(new CanceledError$1("Request stream has been aborted", config, req));
2610
+ }
2611
+ });
2612
+ data.pipe(req); // stream 写入数据
2613
+ } else req.end(data);
2614
+ }
2615
+ });
2616
+ }
2617
+ _.done(R);
2618
+ } catch (e) {
2619
+ log.error(e, "request");
2620
+ _.done(e, true);
2621
+ throw e;
2622
+ }
2623
+ return R;
2624
+ }
2625
+ };
2626
+ /**
2627
+ *
2628
+ * @param {*} stream
2629
+ * @param {*} param1
2630
+ * @returns
2631
+ */ const flushOnFinish = (stream, [throttled, flush])=>{
2632
+ stream.on("end", flush).on("error", flush);
2633
+ return throttled;
2634
+ };
2635
+ /** @typedef {import('../core/Axios').default} Axios */ /**
2636
+ * If the proxy or config beforeRedirects functions are defined, call them with the options
2637
+ * object.
2638
+ *
2639
+ * @param {Object<string, any>} options - The options object that was passed to the request.
2640
+ * @param {*} responseDetails - The options object that was passed to the request.
2641
+ *
2642
+ */ function dispatchBeforeRedirect(options, responseDetails) {
2643
+ log.debug("dispatchBeforeRedirect", {
2644
+ opts: options.beforeRedirects
2645
+ });
2646
+ if (options.beforeRedirects.proxy) options.beforeRedirects.proxy(options);
2647
+ if (options.beforeRedirects.config) options.beforeRedirects.config(options, responseDetails);
2648
+ }
2649
+ /**
2650
+ *
2651
+ * @param {{address: string, family: *}} param0
2652
+ * @returns
2653
+ */ function resolveFamily({ address, family }) {
2654
+ if (!utils$1.isString(address)) {
2655
+ throw TypeError("address must be a string");
2656
+ }
2657
+ return {
2658
+ address,
2659
+ family: family || (address.indexOf(".") < 0 ? 6 : 4)
2660
+ };
2661
+ }
2662
+ /**
2663
+ *
2664
+ * @param {*} address
2665
+ * @param {*} family
2666
+ */ function buildAddressEntry(address, family) {
2667
+ resolveFamily(utils$1.isObject(address) ? address : {
2668
+ address,
2669
+ family
2670
+ });
2671
+ }
2672
+ /**
2673
+ * null or funciton
2674
+ */ const HttpAdapter$1 = isHttpAdapterSupported && HttpAdapter;
2675
+
2676
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2677
+ let XhrAdapter = class XhrAdapter {
2678
+ constructor(config){
2679
+ this.init(config);
2680
+ }
2681
+ init(config) {}
2682
+ request() {}
2683
+ stream() {}
2684
+ };
2685
+ const XhrAdapter$1 = isXHRAdapterSupported && XhrAdapter;
2686
+
2687
+ const knownAdapters = {
2688
+ http: HttpAdapter$1,
2689
+ xhr: XhrAdapter$1
2690
+ };
2691
+ /**
2692
+ * define adapter's name and adapterName to http or xhr
2693
+ * browser: httpAdapter is null!
2694
+ */ utils$1.forEach(knownAdapters, (val, key)=>{
2695
+ if (val) {
2696
+ try {
2697
+ Object.defineProperty(val, 'name', {
2698
+ value: key
2699
+ });
2700
+ } catch (e) {
2701
+ // eslint-disable-next-line no-empty
2702
+ }
2703
+ Object.defineProperty(val, 'adapterName', {
2704
+ value: key
2705
+ });
2706
+ }
2707
+ });
2708
+ const adapters = {
2709
+ /**
2710
+ * get http or xhr adapter
2711
+ * @param {*} adapters user pass or ['xhr', 'http']
2712
+ * @returns
2713
+ */ getAdapter: (adapters)=>{
2714
+ adapters = utils$1.isArray(adapters) ? adapters : [
2715
+ adapters
2716
+ ];
2717
+ const { length } = adapters;
2718
+ let nameOrAdapter;
2719
+ let adapter;
2720
+ // find not null adapter
2721
+ for(let i = 0; i < length; i++){
2722
+ nameOrAdapter = adapters[i];
2723
+ if (adapter = utils$1.isString(nameOrAdapter) ? knownAdapters[nameOrAdapter.toLowerCase()] : nameOrAdapter) {
2724
+ break;
2725
+ }
2726
+ }
2727
+ if (!adapter) {
2728
+ if (adapter === false) {
2729
+ throw new AxiosError$1(`Adapter ${nameOrAdapter} is not supported by the environment`, 'ERR_NOT_SUPPORT');
2730
+ }
2731
+ throw new Error(utils$1.hasOwnProp(knownAdapters, nameOrAdapter) ? `Adapter '${nameOrAdapter}' is not available in the build` : `Unknown adapter '${nameOrAdapter}'`);
2732
+ }
2733
+ if (!utils$1.isFunction(adapter)) {
2734
+ throw new TypeError('adapter is not a function');
2735
+ }
2736
+ return adapter;
2737
+ },
2738
+ adapters: knownAdapters
2739
+ };
2740
+
2741
+ /**
2742
+ * Throws a `CanceledError` if cancellation has been requested.
2743
+ *
2744
+ * @param {Object} config The config that is to be used for the request
2745
+ *
2746
+ * @returns {void}
2747
+ */ function throwIfCancellationRequested(config) {
2748
+ if (config.cancelToken) {
2749
+ config.cancelToken.throwIfRequested();
2750
+ }
2751
+ if (config.signal && config.signal.aborted) {
2752
+ throw new CanceledError$1(null, config);
2753
+ }
2754
+ }
2755
+ /**
2756
+ * Dispatch a request to the server using the configured adapter.
2757
+ * 请求如有异常,需向外抛出异常,不拦截
2758
+ * @param {object} config The config that is to be used for the request
2759
+ *
2760
+ * @returns {Promise<*>} The Promise to be fulfilled
2761
+ */ function dispatchRequest(config) {
2762
+ let R;
2763
+ throwIfCancellationRequested(config);
2764
+ config.headers = AxiosHeaders$2.from(config.headers);
2765
+ // Transform request data
2766
+ config.data = transformData.call(config, config.transformRequest);
2767
+ if ([
2768
+ 'post',
2769
+ 'put',
2770
+ 'patch'
2771
+ ].indexOf(config.method) !== -1) {
2772
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
2773
+ }
2774
+ const Adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
2775
+ const adapter = new Adapter(config);
2776
+ if (config.stream) R = adapter.request(this);
2777
+ else {
2778
+ R = adapter.request(this).then((response)=>{
2779
+ throwIfCancellationRequested(config);
2780
+ // Transform response data
2781
+ response.data = transformData.call(config, config.transformResponse, response);
2782
+ // ! body === data
2783
+ Object.defineProperty(response, 'body', {
2784
+ get () {
2785
+ return response.data;
2786
+ }
2787
+ });
2788
+ // if (response.data && !response.body) response.body = response.data
2789
+ response.headers = AxiosHeaders$2.from(response.headers);
2790
+ return response;
2791
+ }, (reason)=>{
2792
+ if (!isCancel$1(reason)) {
2793
+ throwIfCancellationRequested(config);
2794
+ // Transform response data
2795
+ if (reason && reason.response) {
2796
+ reason.response.data = transformData.call(config, config.transformResponse, reason.response);
2797
+ // body === data
2798
+ if (reason.response.data && !reason.response.body) reason.response.body = reason.response.data;
2799
+ reason.response.headers = AxiosHeaders$2.from(reason.response.headers);
2800
+ }
2801
+ }
2802
+ return Promise.reject(reason);
2803
+ });
2804
+ }
2805
+ return R;
2806
+ }
2807
+
2808
+ const headersToObject = (thing)=>thing instanceof AxiosHeaders$2 ? {
2809
+ ...thing
2810
+ } : thing;
2811
+ /**
2812
+ * Config-specific merge-function which creates a new config-object
2813
+ * by merging two configuration objects together.
2814
+ *
2815
+ * @param {Object} config1
2816
+ * @param {Object} config2
2817
+ *
2818
+ * @returns {Object} New object resulting from merging config2 to config1
2819
+ */ function mergeConfig$1(config1, config2) {
2820
+ // eslint-disable-next-line no-param-reassign
2821
+ config2 = config2 || {};
2822
+ const config = {};
2823
+ function getMergedValue(target, source, caseless) {
2824
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2825
+ return utils$1.merge.call({
2826
+ caseless
2827
+ }, target, source);
2828
+ } else if (utils$1.isPlainObject(source)) {
2829
+ return utils$1.merge({}, source);
2830
+ } else if (utils$1.isArray(source)) {
2831
+ return source.slice();
2832
+ }
2833
+ return source;
2834
+ }
2835
+ // eslint-disable-next-line consistent-return
2836
+ function mergeDeepProperties(a, b, caseless) {
2837
+ if (!utils$1.isUndefined(b)) {
2838
+ return getMergedValue(a, b, caseless);
2839
+ } else if (!utils$1.isUndefined(a)) {
2840
+ return getMergedValue(undefined, a, caseless);
2841
+ }
2842
+ }
2843
+ // eslint-disable-next-line consistent-return
2844
+ function valueFromConfig2(a, b) {
2845
+ if (!utils$1.isUndefined(b)) {
2846
+ return getMergedValue(undefined, b);
2847
+ }
2848
+ }
2849
+ // eslint-disable-next-line consistent-return
2850
+ function defaultToConfig2(a, b) {
2851
+ if (!utils$1.isUndefined(b)) {
2852
+ return getMergedValue(undefined, b);
2853
+ } else if (!utils$1.isUndefined(a)) {
2854
+ return getMergedValue(undefined, a);
2855
+ }
2856
+ }
2857
+ // eslint-disable-next-line consistent-return
2858
+ function mergeDirectKeys(a, b, prop) {
2859
+ if (prop in config2) {
2860
+ return getMergedValue(a, b);
2861
+ } else if (prop in config1) {
2862
+ return getMergedValue(undefined, a);
2863
+ }
2864
+ }
2865
+ const mergeMap = {
2866
+ url: valueFromConfig2,
2867
+ method: valueFromConfig2,
2868
+ data: valueFromConfig2,
2869
+ baseURL: defaultToConfig2,
2870
+ transformRequest: defaultToConfig2,
2871
+ transformResponse: defaultToConfig2,
2872
+ paramsSerializer: defaultToConfig2,
2873
+ timeout: defaultToConfig2,
2874
+ timeoutMessage: defaultToConfig2,
2875
+ withCredentials: defaultToConfig2,
2876
+ withXSRFToken: defaultToConfig2,
2877
+ adapter: defaultToConfig2,
2878
+ responseType: defaultToConfig2,
2879
+ xsrfCookieName: defaultToConfig2,
2880
+ xsrfHeaderName: defaultToConfig2,
2881
+ onUploadProgress: defaultToConfig2,
2882
+ onDownloadProgress: defaultToConfig2,
2883
+ decompress: defaultToConfig2,
2884
+ maxContentLength: defaultToConfig2,
2885
+ maxBodyLength: defaultToConfig2,
2886
+ beforeRedirect: defaultToConfig2,
2887
+ transport: defaultToConfig2,
2888
+ httpAgent: defaultToConfig2,
2889
+ httpsAgent: defaultToConfig2,
2890
+ cancelToken: defaultToConfig2,
2891
+ socketPath: defaultToConfig2,
2892
+ responseEncoding: defaultToConfig2,
2893
+ validateStatus: mergeDirectKeys,
2894
+ headers: (a, b)=>mergeDeepProperties(headersToObject(a), headersToObject(b), true)
2895
+ };
2896
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2897
+ const merge = mergeMap[prop] || mergeDeepProperties;
2898
+ const configValue = merge(config1[prop], config2[prop], prop);
2899
+ utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
2900
+ });
2901
+ return config;
2902
+ }
2903
+
2904
+ const validators$1 = {};
2905
+ // eslint-disable-next-line func-names
2906
+ [
2907
+ 'object',
2908
+ 'boolean',
2909
+ 'number',
2910
+ 'function',
2911
+ 'string',
2912
+ 'symbol'
2913
+ ].forEach((type, i)=>{
2914
+ validators$1[type] = function validator(thing) {
2915
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
2916
+ };
2917
+ });
2918
+ const deprecatedWarnings = {};
2919
+ /**
2920
+ * Transitional option validator
2921
+ *
2922
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
2923
+ * @param {string?} version - deprecated version / removed since version
2924
+ * @param {string?} message - some message with additional info
2925
+ *
2926
+ * @returns {function}
2927
+ */ validators$1.transitional = function transitional(validator, version, message) {
2928
+ function formatMessage(opt, desc) {
2929
+ return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
2930
+ }
2931
+ // eslint-disable-next-line func-names
2932
+ return (value, opt, opts)=>{
2933
+ if (validator === false) {
2934
+ throw new AxiosError$1(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')), AxiosError$1.ERR_DEPRECATED);
2935
+ }
2936
+ if (version && !deprecatedWarnings[opt]) {
2937
+ deprecatedWarnings[opt] = true;
2938
+ // eslint-disable-next-line no-console
2939
+ console.warn(formatMessage(opt, ' has been deprecated since v' + version + ' and will be removed in the near future'));
2940
+ }
2941
+ return validator ? validator(value, opt, opts) : true;
2942
+ };
2943
+ };
2944
+ validators$1.spelling = function spelling(correctSpelling) {
2945
+ return (value, opt)=>{
2946
+ // eslint-disable-next-line no-console
2947
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
2948
+ return true;
2949
+ };
2950
+ };
2951
+ /**
2952
+ * Assert object's properties type
2953
+ *
2954
+ * @param {object} options
2955
+ * @param {object} schema
2956
+ * @param {boolean?} allowUnknown
2957
+ *
2958
+ * @returns {object}
2959
+ */ function assertOptions(options, schema, allowUnknown) {
2960
+ if (typeof options !== 'object') {
2961
+ throw new AxiosError$1('options must be an object', AxiosError$1.ERR_BAD_OPTION_VALUE);
2962
+ }
2963
+ const keys = Object.keys(options);
2964
+ let i = keys.length;
2965
+ while(i-- > 0){
2966
+ const opt = keys[i];
2967
+ const validator = schema[opt];
2968
+ if (validator) {
2969
+ const value = options[opt];
2970
+ const result = value === undefined || validator(value, opt, options);
2971
+ if (result !== true) {
2972
+ throw new AxiosError$1('option ' + opt + ' must be ' + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
2973
+ }
2974
+ continue;
2975
+ }
2976
+ if (allowUnknown !== true) {
2977
+ throw new AxiosError$1('Unknown option ' + opt, AxiosError$1.ERR_BAD_OPTION);
2978
+ }
2979
+ }
2980
+ }
2981
+ const validator = {
2982
+ assertOptions,
2983
+ validators: validators$1
2984
+ };
2985
+
2986
+ const { validators } = validator;
2987
+ /**
2988
+ * Create a new instance of Axios
2989
+ *
2990
+ * @param {Object} instanceConfig The default config for the instance
2991
+ *
2992
+ * @return {Axios} A new instance of Axios
2993
+ */ let Axios$1 = class Axios {
2994
+ constructor(instanceConfig){
2995
+ this.defaults = instanceConfig;
2996
+ this.config = this.defaults // !+++
2997
+ ;
2998
+ this.interceptors = {
2999
+ request: new InterceptorManager$1(),
3000
+ response: new InterceptorManager$1()
3001
+ };
3002
+ this.init() // !+++
3003
+ ;
3004
+ }
3005
+ /**
3006
+ * !+++
3007
+ * config 属性直接挂在到实例上,方便读取、设置、修改
3008
+ * 需注意,不要与其属性、方法冲突!!!
3009
+ request(config)
3010
+ get(url[, config])
3011
+ delete(url[, config])
3012
+ head(url[, config])
3013
+ options(url[, config])
3014
+ post(url[, data[, config]])
3015
+ put(url[, data[, config]])
3016
+ patch(url[, data[, config]])
3017
+ getUri([config])
3018
+ */ init() {
3019
+ const m = this;
3020
+ [
3021
+ 'url',
3022
+ 'method',
3023
+ 'baseURL',
3024
+ 'transformRequest',
3025
+ 'transformResponse',
3026
+ 'headers',
3027
+ 'params',
3028
+ 'paramsSerializer',
3029
+ 'body',
3030
+ 'data',
3031
+ 'timeout',
3032
+ 'withCredentials',
3033
+ 'adapter',
3034
+ 'auth',
3035
+ 'responseType',
3036
+ 'responseEncoding',
3037
+ 'xsrfCookieName',
3038
+ 'xsrfHeaderName',
3039
+ 'onUploadProgress',
3040
+ 'onDownloadProgress',
3041
+ 'maxContentLength',
3042
+ 'maxBodyLength',
3043
+ 'validateStatus',
3044
+ 'maxRedirects',
3045
+ 'beforeRedirect',
3046
+ 'socketPath',
3047
+ 'httpAgent',
3048
+ 'httpsAgent',
3049
+ 'agent',
3050
+ 'cancelToken',
3051
+ 'signal',
3052
+ 'decompress',
3053
+ 'insecureHTTPParser',
3054
+ 'transitional',
3055
+ 'env',
3056
+ 'formSerializer',
3057
+ 'maxRate'
3058
+ ].forEach((p)=>Object.defineProperty(m, p, {
3059
+ enumerable: true,
3060
+ get () {
3061
+ return m.config[p];
3062
+ },
3063
+ set (value) {
3064
+ m.config[p] = value;
3065
+ }
3066
+ }));
3067
+ }
3068
+ /**
3069
+ * Dispatch a request
3070
+ * 启动执行请求,返回 Promise 实例
3071
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3072
+ * @param {?Object} config
3073
+ * @returns {Promise} The Promise to be fulfilled
3074
+ */ async request(configOrUrl, config) {
3075
+ try {
3076
+ return await this._request(configOrUrl, config);
3077
+ } catch (err) {
3078
+ if (err instanceof Error) {
3079
+ let dummy = {};
3080
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
3081
+ // slice off the Error: ... line
3082
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3083
+ try {
3084
+ if (!err.stack) {
3085
+ err.stack = stack;
3086
+ // match without the 2 top stack lines
3087
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3088
+ err.stack += '\n' + stack;
3089
+ }
3090
+ } catch (e) {
3091
+ // ignore the case where "stack" is an un-writable property
3092
+ }
3093
+ }
3094
+ throw err // 抛出异常
3095
+ ;
3096
+ }
3097
+ }
3098
+ /**
3099
+ * 执行请求
3100
+ * @param {*} configOrUrl
3101
+ * @param {*} config
3102
+ * @param {boolean} [stream = false] - 是否返回 stream
3103
+ * @returns
3104
+ */ _request(configOrUrl, config, stream = false) {
3105
+ let R = null;
3106
+ /* eslint no-param-reassign:0 */ // Allow for axios('example/url'[, config]) a la fetch API
3107
+ if (typeof configOrUrl === 'string') {
3108
+ config = config || {};
3109
+ config.url = configOrUrl;
3110
+ } else {
3111
+ config = configOrUrl || {};
3112
+ }
3113
+ // ! body as data alias, body ==> data,内部保持data不变
3114
+ if (!config.data && config.body) {
3115
+ config.data = config.body;
3116
+ // config.body = undefined;
3117
+ }
3118
+ config = mergeConfig$1(this.defaults, config);
3119
+ const { transitional, paramsSerializer, headers } = config;
3120
+ if (transitional !== undefined) {
3121
+ validator.assertOptions(transitional, {
3122
+ silentJSONParsing: validators.transitional(validators.boolean),
3123
+ forcedJSONParsing: validators.transitional(validators.boolean),
3124
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3125
+ }, false);
3126
+ }
3127
+ if (paramsSerializer) {
3128
+ if (utils$1.isFunction(paramsSerializer)) {
3129
+ config.paramsSerializer = {
3130
+ serialize: paramsSerializer
3131
+ };
3132
+ } else {
3133
+ validator.assertOptions(paramsSerializer, {
3134
+ encode: validators.function,
3135
+ serialize: validators.function
3136
+ }, true);
3137
+ }
3138
+ }
3139
+ validator.assertOptions(config, {
3140
+ baseUrl: validators.spelling('baseURL'),
3141
+ withXsrfToken: validators.spelling('withXSRFToken')
3142
+ }, true);
3143
+ // Set config.method
3144
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3145
+ // Flatten headers,方法头覆盖通用头
3146
+ const contextHeaders = headers && utils$1.merge(headers.common, headers[config.method]);
3147
+ headers && utils$1.forEach([
3148
+ 'delete',
3149
+ 'get',
3150
+ 'head',
3151
+ 'post',
3152
+ 'put',
3153
+ 'patch',
3154
+ 'common'
3155
+ ], (method)=>{
3156
+ delete headers[method];
3157
+ });
3158
+ // 源值存在,则不覆盖,contextHeaders 优先于 headers
3159
+ config.headers = AxiosHeaders$2.concat(contextHeaders, headers);
3160
+ // filter out skipped interceptors
3161
+ const requestInterceptorChain = [] // 请求拦截器,hook
3162
+ ;
3163
+ let synchronousRequestInterceptors = true;
3164
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3165
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3166
+ return;
3167
+ }
3168
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3169
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3170
+ });
3171
+ const responseInterceptorChain = [] // 响应拦截器,hook
3172
+ ;
3173
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3174
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3175
+ });
3176
+ let promise;
3177
+ let i = 0;
3178
+ let len;
3179
+ debugger;
3180
+ // 执行dispatchRequest
3181
+ // !+++ stream
3182
+ if (stream) {
3183
+ config.stream = true;
3184
+ R = dispatchRequest.call(this, config) // not promise
3185
+ ;
3186
+ } else if (!synchronousRequestInterceptors) {
3187
+ // 异步拦截器
3188
+ const chain = [
3189
+ dispatchRequest.bind(this),
3190
+ undefined
3191
+ ] // dispatchRequest 放入运行链
3192
+ ;
3193
+ chain.unshift(...requestInterceptorChain) // !*** 插入头
3194
+ ;
3195
+ chain.push(...responseInterceptorChain) // !*** 加入尾
3196
+ ;
3197
+ len = chain.length;
3198
+ promise = Promise.resolve(config) // promise 对象
3199
+ ;
3200
+ // 传入config配置,按顺序执行
3201
+ while(i < len)promise = promise.then(chain[i++], chain[i++]);
3202
+ R = promise;
3203
+ } else {
3204
+ // 同步拦截器
3205
+ len = requestInterceptorChain.length;
3206
+ let newConfig = config;
3207
+ i = 0;
3208
+ // 按加入顺序运行 request 拦截器
3209
+ while(i < len){
3210
+ const onFulfilled = requestInterceptorChain[i++];
3211
+ const onRejected = requestInterceptorChain[i++];
3212
+ try {
3213
+ newConfig = onFulfilled(newConfig) // 执行
3214
+ ;
3215
+ } catch (error) {
3216
+ onRejected.call(this, error);
3217
+ break;
3218
+ }
3219
+ }
3220
+ try {
3221
+ promise = dispatchRequest.call(this, newConfig);
3222
+ i = 0;
3223
+ len = responseInterceptorChain.length;
3224
+ // 按顺序执行响应 hook
3225
+ while(i < len)promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3226
+ R = promise;
3227
+ } catch (error) {
3228
+ R = Promise.reject(error);
3229
+ }
3230
+ }
3231
+ return R;
3232
+ }
3233
+ /**
3234
+ * !+++
3235
+ * 类似 request 库,返回 stream
3236
+ * stream 模式下,拦截器无效
3237
+ * 如需拦截器,请使用 responseType: 'stream',data 为 stream 传出
3238
+ * 或者 将 stream 作为 data 传入
3239
+ * @param {*} configOrUrl
3240
+ * @param {*} config
3241
+ * @returns
3242
+ */ stream(configOrUrl, config) {
3243
+ return this._request(configOrUrl, config, true);
3244
+ }
3245
+ /**
3246
+ *
3247
+ * @param {*} config
3248
+ * @returns
3249
+ */ getUri(config) {
3250
+ config = mergeConfig$1(this.defaults, config);
3251
+ const fullPath = buildFullPath(config.baseURL, config.url);
3252
+ return buildURL(fullPath, config.params, config.paramsSerializer);
3253
+ }
3254
+ };
3255
+ // Provide aliases for supported request methods
3256
+ utils$1.forEach([
3257
+ 'head',
3258
+ 'options'
3259
+ ], function forEachMethodNoData(method) {
3260
+ /* eslint func-names:0 */ Axios$1.prototype[method] = function(url, config) {
3261
+ return this.request(mergeConfig$1(config || {}, {
3262
+ method,
3263
+ url,
3264
+ data: (config || {}).data
3265
+ }));
3266
+ };
3267
+ });
3268
+ // delete、get, 与 axios不同,第二个参数为 params,而不是 data
3269
+ utils$1.forEach([
3270
+ 'delete',
3271
+ 'get'
3272
+ ], function forEachMethodNoData(method) {
3273
+ Axios$1.prototype[method] = function(url, params, config) {
3274
+ return this.request(mergeConfig$1(config || {}, {
3275
+ method,
3276
+ url,
3277
+ params
3278
+ }));
3279
+ };
3280
+ });
3281
+ utils$1.forEach([
3282
+ 'post',
3283
+ 'put',
3284
+ 'patch'
3285
+ ], function forEachMethodWithData(method) {
3286
+ function generateHTTPMethod(isForm) {
3287
+ return function httpMethod(url, data, config) {
3288
+ return this.request(mergeConfig$1(config || {}, {
3289
+ method,
3290
+ headers: isForm ? {
3291
+ 'Content-Type': 'multipart/form-data'
3292
+ } : {},
3293
+ url,
3294
+ data
3295
+ }));
3296
+ };
3297
+ }
3298
+ Axios$1.prototype[method] = generateHTTPMethod();
3299
+ Axios$1.prototype[`${method}Form`] = generateHTTPMethod(true);
3300
+ });
3301
+ // stream get, 与 axios不同,第二个参数为 params,而不是 data
3302
+ utils$1.forEach([
3303
+ 'gets'
3304
+ ], function forEachMethodNoData(method) {
3305
+ Axios$1.prototype[method] = function(url, params, config) {
3306
+ return this.stream(mergeConfig$1(config || {}, {
3307
+ method,
3308
+ url,
3309
+ params,
3310
+ data: (config || {}).data
3311
+ }));
3312
+ };
3313
+ });
3314
+ // stream post put patch
3315
+ utils$1.forEach([
3316
+ 'posts',
3317
+ 'puts',
3318
+ 'patchs'
3319
+ ], function forEachMethodWithData(method) {
3320
+ function generateStreamMethod(isForm) {
3321
+ return function httpMethod(url, data, config) {
3322
+ return this.stream(mergeConfig$1(config || {}, {
3323
+ method,
3324
+ headers: isForm ? {
3325
+ 'Content-Type': 'multipart/form-data'
3326
+ } : {},
3327
+ url,
3328
+ data
3329
+ }));
3330
+ };
3331
+ }
3332
+ Axios$1.prototype[method] = generateStreamMethod();
3333
+ Axios$1.prototype[`${method}Forms`] = generateStreamMethod(true);
3334
+ });
3335
+ const Axios$2 = Axios$1;
3336
+
3337
+ /**
3338
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3339
+ *
3340
+ * @param {Function} executor The executor function.
3341
+ *
3342
+ * @returns {CancelToken}
3343
+ */ let CancelToken$1 = class CancelToken {
3344
+ constructor(executor){
3345
+ if (typeof executor !== 'function') {
3346
+ throw new TypeError('executor must be a function.');
3347
+ }
3348
+ let resolvePromise;
3349
+ this.promise = new Promise(function promiseExecutor(resolve) {
3350
+ resolvePromise = resolve;
3351
+ });
3352
+ const token = this;
3353
+ // eslint-disable-next-line func-names
3354
+ this.promise.then((cancel)=>{
3355
+ if (!token._listeners) return;
3356
+ let i = token._listeners.length;
3357
+ while(i-- > 0){
3358
+ token._listeners[i](cancel);
3359
+ }
3360
+ token._listeners = null;
3361
+ });
3362
+ // eslint-disable-next-line func-names
3363
+ this.promise.then = (onfulfilled)=>{
3364
+ let _resolve;
3365
+ // eslint-disable-next-line func-names
3366
+ const promise = new Promise((resolve)=>{
3367
+ token.subscribe(resolve);
3368
+ _resolve = resolve;
3369
+ }).then(onfulfilled);
3370
+ promise.cancel = function reject() {
3371
+ token.unsubscribe(_resolve);
3372
+ };
3373
+ return promise;
3374
+ };
3375
+ executor(function cancel(message, config, request) {
3376
+ if (token.reason) {
3377
+ // Cancellation has already been requested
3378
+ return;
3379
+ }
3380
+ token.reason = new CanceledError$1(message, config, request);
3381
+ resolvePromise(token.reason);
3382
+ });
3383
+ }
3384
+ /**
3385
+ * Throws a `CanceledError` if cancellation has been requested.
3386
+ */ throwIfRequested() {
3387
+ if (this.reason) {
3388
+ throw this.reason;
3389
+ }
3390
+ }
3391
+ /**
3392
+ * Subscribe to the cancel signal
3393
+ */ subscribe(listener) {
3394
+ if (this.reason) {
3395
+ listener(this.reason);
3396
+ return;
3397
+ }
3398
+ if (this._listeners) {
3399
+ this._listeners.push(listener);
3400
+ } else {
3401
+ this._listeners = [
3402
+ listener
3403
+ ];
3404
+ }
3405
+ }
3406
+ /**
3407
+ * Unsubscribe from the cancel signal
3408
+ */ unsubscribe(listener) {
3409
+ if (!this._listeners) {
3410
+ return;
3411
+ }
3412
+ const index = this._listeners.indexOf(listener);
3413
+ if (index !== -1) {
3414
+ this._listeners.splice(index, 1);
3415
+ }
3416
+ }
3417
+ toAbortSignal() {
3418
+ const controller = new AbortController();
3419
+ const abort = (err)=>{
3420
+ controller.abort(err);
3421
+ };
3422
+ this.subscribe(abort);
3423
+ controller.signal.unsubscribe = ()=>this.unsubscribe(abort);
3424
+ return controller.signal;
3425
+ }
3426
+ /**
3427
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3428
+ * cancels the `CancelToken`.
3429
+ */ static source() {
3430
+ let cancel;
3431
+ const token = new CancelToken(function executor(c) {
3432
+ cancel = c;
3433
+ });
3434
+ return {
3435
+ token,
3436
+ cancel
3437
+ };
3438
+ }
3439
+ };
3440
+ const CancelToken$2 = CancelToken$1;
3441
+
3442
+ /**
3443
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3444
+ *
3445
+ * Common use case would be to use `Function.prototype.apply`.
3446
+ *
3447
+ * ```js
3448
+ * function f(x, y, z) {}
3449
+ * var args = [1, 2, 3];
3450
+ * f.apply(null, args);
3451
+ * ```
3452
+ *
3453
+ * With `spread` this example can be re-written.
3454
+ *
3455
+ * ```js
3456
+ * spread(function(x, y, z) {})([1, 2, 3]);
3457
+ * ```
3458
+ *
3459
+ * @param {Function} callback
3460
+ *
3461
+ * @returns {Function}
3462
+ */ function spread$1(callback) {
3463
+ return function wrap(arr) {
3464
+ return callback.apply(null, arr);
3465
+ };
3466
+ }
3467
+
3468
+ /**
3469
+ * Determines whether the payload is an error thrown by Axios
3470
+ *
3471
+ * @param {*} payload The value to test
3472
+ *
3473
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3474
+ */ function isAxiosError$1(payload) {
3475
+ return utils$1.isObject(payload) && payload.isAxiosError === true;
3476
+ }
3477
+
3478
+ /**
3479
+ * Create an instance of Axios
3480
+ *
3481
+ * @param {Object} defaultConfig The default config for the instance
3482
+ *
3483
+ * @returns {Axios} A new instance of Axios
3484
+ */ function createInstance(defaultConfig) {
3485
+ const context = new Axios$2(defaultConfig);
3486
+ const instance = bind(Axios$2.prototype.request, context);
3487
+ // Copy axios.prototype to instance
3488
+ utils$1.extend(instance, Axios$2.prototype, context, {
3489
+ allOwnKeys: true
3490
+ });
3491
+ // Copy context to instance
3492
+ utils$1.extend(instance, context, null, {
3493
+ allOwnKeys: true
3494
+ });
3495
+ // Factory for creating new instances
3496
+ instance.create = function create(instanceConfig) {
3497
+ return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
3498
+ };
3499
+ return instance;
3500
+ }
3501
+ // Create the default instance to be exported
3502
+ const req = createInstance(defaults$1);
3503
+ // Expose Axios class to allow class inheritance
3504
+ req.Axios = Axios$2;
3505
+ // Expose Cancel & CancelToken
3506
+ req.CanceledError = CanceledError$1;
3507
+ req.CancelToken = CancelToken$2;
3508
+ req.isCancel = isCancel$1;
3509
+ req.VERSION = VERSION$1;
3510
+ req.toFormData = toFormData$1;
3511
+ // Expose AxiosError class
3512
+ req.AxiosError = AxiosError$1;
3513
+ // alias for CanceledError for backward compatibility
3514
+ req.Cancel = req.CanceledError;
3515
+ // Expose all/spread
3516
+ req.all = (promises)=>Promise.all(promises);
3517
+ req.spread = spread$1;
3518
+ // Expose isAxiosError
3519
+ req.isAxiosError = isAxiosError$1;
3520
+ // Expose mergeConfig
3521
+ req.mergeConfig = mergeConfig$1;
3522
+ req.AxiosHeaders = AxiosHeaders$2;
3523
+ req.formToJSON = (thing)=>formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3524
+ req.getAdapter = adapters.getAdapter;
3525
+ req.default = req;
3526
+ // this module should only have a default export
3527
+ const req$1 = req;
3528
+
3529
+ // This module is intended to unwrap Axios default export as named.
3530
+ // Keep top-level export same with static properties
3531
+ // so that it can keep same with es module or cjs
3532
+ const {
3533
+ Axios,
3534
+ AxiosError,
3535
+ CanceledError,
3536
+ isCancel,
3537
+ CancelToken,
3538
+ VERSION,
3539
+ all,
3540
+ Cancel,
3541
+ isAxiosError,
3542
+ spread,
3543
+ toFormData,
3544
+ AxiosHeaders,
3545
+ HttpStatusCode,
3546
+ formToJSON,
3547
+ getAdapter,
3548
+ mergeConfig,
3549
+ } = req$1;
3550
+
3551
+ export { Axios, AxiosError, AxiosHeaders, Cancel, CancelToken, CanceledError, HttpStatusCode, VERSION, all, req$1 as default, formToJSON, getAdapter, isAxiosError, isCancel, mergeConfig, spread, toFormData };