@wiajs/req 1.7.12 → 1.7.13

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