bibot 1.0.15 → 1.0.19

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