iota-fetch 0.0.1

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