react-nomba-checkout-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/babel.config.js +13 -0
  2. package/dist/apis/handleApiCall.d.ts +3 -0
  3. package/dist/apis/useCardCheckout.d.ts +8 -0
  4. package/dist/apis/useCardCheckoutOtp.d.ts +8 -0
  5. package/dist/apis/useFetchUssdBanks.d.ts +1 -0
  6. package/dist/apis/useGenerateQrCode.d.ts +1 -0
  7. package/dist/apis/useGetOrder.d.ts +1 -0
  8. package/dist/apis/useGetUssdCode.d.ts +15 -0
  9. package/dist/apis/useResendOtp.d.ts +1 -0
  10. package/dist/apis/useVerifyOrderStatus.d.ts +1 -0
  11. package/dist/assets/CloseIcon.d.ts +2 -0
  12. package/dist/assets/Loader.d.ts +3 -0
  13. package/dist/components/NombaCheckoutButton.d.ts +17 -0
  14. package/dist/components/NombaCheckoutModal.d.ts +16 -0
  15. package/dist/index.css +2 -0
  16. package/dist/index.css.map +1 -0
  17. package/dist/index.d.ts +11 -0
  18. package/dist/index.esm.css +2 -0
  19. package/dist/index.esm.css.map +1 -0
  20. package/dist/index.esm.js +4105 -0
  21. package/dist/index.esm.js.map +1 -0
  22. package/dist/index.js +4116 -0
  23. package/dist/index.js.map +1 -0
  24. package/package.json +76 -0
  25. package/rollup.config.js +43 -0
  26. package/src/apis/handleApiCall.ts +20 -0
  27. package/src/apis/useCardCheckout.ts +35 -0
  28. package/src/apis/useCardCheckoutOtp.ts +21 -0
  29. package/src/apis/useFetchUssdBanks.ts +10 -0
  30. package/src/apis/useGenerateQrCode.ts +13 -0
  31. package/src/apis/useGetOrder.ts +13 -0
  32. package/src/apis/useGetUssdCode.ts +28 -0
  33. package/src/apis/useResendOtp.ts +12 -0
  34. package/src/apis/useVerifyOrderStatus.ts +14 -0
  35. package/src/assets/CloseIcon.tsx +19 -0
  36. package/src/assets/Loader.tsx +18 -0
  37. package/src/components/NombaCheckoutButton.tsx +67 -0
  38. package/src/components/NombaCheckoutModal.tsx +132 -0
  39. package/src/index.tsx +24 -0
  40. package/src/styles.css +14 -0
  41. package/tsconfig.json +80 -0
@@ -0,0 +1,4105 @@
1
+ import React, { Component } from 'react';
2
+
3
+ /******************************************************************************
4
+ Copyright (c) Microsoft Corporation.
5
+
6
+ Permission to use, copy, modify, and/or distribute this software for any
7
+ purpose with or without fee is hereby granted.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
16
+ ***************************************************************************** */
17
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
18
+
19
+ var extendStatics = function(d, b) {
20
+ extendStatics = Object.setPrototypeOf ||
21
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
22
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
23
+ return extendStatics(d, b);
24
+ };
25
+
26
+ function __extends(d, b) {
27
+ if (typeof b !== "function" && b !== null)
28
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29
+ extendStatics(d, b);
30
+ function __() { this.constructor = d; }
31
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
32
+ }
33
+
34
+ var __assign = function() {
35
+ __assign = Object.assign || function __assign(t) {
36
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
37
+ s = arguments[i];
38
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
39
+ }
40
+ return t;
41
+ };
42
+ return __assign.apply(this, arguments);
43
+ };
44
+
45
+ function __awaiter(thisArg, _arguments, P, generator) {
46
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
47
+ return new (P || (P = Promise))(function (resolve, reject) {
48
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
49
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
50
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
51
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
52
+ });
53
+ }
54
+
55
+ function __generator(thisArg, body) {
56
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
+ function verb(n) { return function (v) { return step([n, v]); }; }
59
+ function step(op) {
60
+ if (f) throw new TypeError("Generator is already executing.");
61
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
62
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
+ if (y = 0, t) op = [op[0] & 2, t.value];
64
+ switch (op[0]) {
65
+ case 0: case 1: t = op; break;
66
+ case 4: _.label++; return { value: op[1], done: false };
67
+ case 5: _.label++; y = op[1]; op = [0]; continue;
68
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
+ default:
70
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
+ if (t[2]) _.ops.pop();
75
+ _.trys.pop(); continue;
76
+ }
77
+ op = body.call(thisArg, _);
78
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
80
+ }
81
+ }
82
+
83
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
84
+ var e = new Error(message);
85
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
86
+ };
87
+
88
+ var Loader = function () { return (React.createElement("svg", { width: "18", height: "21", viewBox: "0 0 18 21", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
89
+ React.createElement("path", { d: "M10.3203 8.49095L12.002 7.47669L13.6836 6.46243L15.3652 5.44817L17.0468 4.43393V0.545959L15.3652 1.56021L13.6836 2.57447L12.002 3.58872L10.3203 4.60297L8.63871 5.6172V7.56118L6.95709 6.54697L5.27546 5.53271L3.50974 4.51845L1.82811 3.5042L0.146484 2.48994V6.37789L1.82811 7.39215L3.50974 8.40641L5.19136 9.42067L6.87298 10.4349L8.5546 11.4492L6.87298 12.4634L5.19136 13.4777L3.50974 14.4919L1.82811 15.5062L0.146484 16.3514V20.2394L1.82811 19.2251L3.50974 18.2108L5.19136 17.1966L6.87298 16.1824L8.5546 15.1681V13.2241L10.2362 14.2383L11.9179 15.2526L13.5995 16.2669L15.2811 17.2811L16.9628 18.2954V14.4074L15.2811 13.3932L13.5995 12.3789L11.9179 11.3646L10.2362 10.3504L8.5546 9.33613L10.3203 8.49095Z", fill: "#121212" }))); };
90
+
91
+ var CloseIcon = function () { return (React.createElement("svg", { width: "32", height: "32", viewBox: "0 0 32 32", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
92
+ React.createElement("rect", { width: "32", height: "32", rx: "16", fill: "#F2F2F2", "fill-opacity": "0.64" }),
93
+ React.createElement("path", { "fill-rule": "evenodd", "clip-rule": "evenodd", d: "M11.7646 11.7646C11.8948 11.6344 12.1059 11.6344 12.236 11.7646L16.0003 15.5289L19.7646 11.7646C19.8948 11.6344 20.1059 11.6344 20.236 11.7646C20.3662 11.8948 20.3662 12.1059 20.236 12.236L16.4717 16.0003L20.236 19.7646C20.3662 19.8948 20.3662 20.1059 20.236 20.236C20.1059 20.3662 19.8948 20.3662 19.7646 20.236L16.0003 16.4717L12.236 20.236C12.1059 20.3662 11.8948 20.3662 11.7646 20.236C11.6344 20.1059 11.6344 19.8948 11.7646 19.7646L15.5289 16.0003L11.7646 12.236C11.6344 12.1059 11.6344 11.8948 11.7646 11.7646Z", fill: "#0D0D0D" }))); };
94
+
95
+ var NombaCheckoutModal = /** @class */ (function (_super) {
96
+ __extends(NombaCheckoutModal, _super);
97
+ function NombaCheckoutModal(props) {
98
+ var _this = _super.call(this, props) || this;
99
+ _this.handleClose = function () {
100
+ var _a, _b;
101
+ (_b = (_a = _this.props).onClose) === null || _b === undefined ? undefined : _b.call(_a);
102
+ };
103
+ _this.handleIframeLoad = function () {
104
+ _this.setState({ isLoading: false });
105
+ };
106
+ _this.state = {
107
+ isLoading: true,
108
+ };
109
+ return _this;
110
+ }
111
+ NombaCheckoutModal.prototype.render = function () {
112
+ var orderId = this.props.orderId;
113
+ var isLoading = this.state.isLoading;
114
+ return (React.createElement("div", { style: modalStyles.overlay, onClick: this.handleClose },
115
+ React.createElement("div", { style: modalStyles.modal, onClick: function (e) { return e.stopPropagation(); } },
116
+ React.createElement("div", { style: modalStyles.content },
117
+ isLoading && (React.createElement("div", { style: modalStyles.loader },
118
+ React.createElement("div", { className: "spinner" }),
119
+ React.createElement(Loader, null))),
120
+ React.createElement("button", { style: modalStyles.closeButton, onClick: this.handleClose },
121
+ React.createElement(CloseIcon, null)),
122
+ React.createElement("iframe", { src: "https://checkout.nomba.com/pay/".concat(orderId), allow: "clipboard-write clipboard-read", width: "100%", height: "80vh", style: modalStyles.iframe, title: "Nomba checkout", onLoad: this.handleIframeLoad })))));
123
+ };
124
+ return NombaCheckoutModal;
125
+ }(Component));
126
+ var modalStyles = {
127
+ overlay: {
128
+ position: "fixed",
129
+ top: 0,
130
+ left: 0,
131
+ right: 0,
132
+ bottom: 0,
133
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
134
+ display: "flex",
135
+ justifyContent: "center",
136
+ alignItems: "center",
137
+ zIndex: 9999,
138
+ },
139
+ modal: {
140
+ backgroundColor: "white",
141
+ width: "100%",
142
+ maxWidth: "60vw",
143
+ borderRadius: "8px",
144
+ boxShadow: "0 4px 8px rgba(0, 0, 0, 0.1)",
145
+ position: "relative",
146
+ height: "600px",
147
+ maxHeight: "95vh",
148
+ },
149
+ header: {
150
+ position: "relative",
151
+ display: "flex",
152
+ justifyContent: "space-between",
153
+ alignItems: "center",
154
+ },
155
+ closeButton: {
156
+ position: "absolute",
157
+ top: "16px",
158
+ right: "16px",
159
+ border: "none",
160
+ background: "transparent",
161
+ },
162
+ content: {
163
+ position: "relative",
164
+ },
165
+ iframe: {
166
+ border: "none",
167
+ borderRadius: "8px",
168
+ width: "100%",
169
+ maxHeight: "95vh",
170
+ height: "600px",
171
+ display: "block",
172
+ },
173
+ loader: {
174
+ position: "absolute",
175
+ top: 0,
176
+ left: 0,
177
+ width: "100%",
178
+ height: "100%",
179
+ backgroundColor: "rgba(255, 255, 255, 0.8)",
180
+ display: "flex",
181
+ flexDirection: "column",
182
+ alignItems: "center",
183
+ justifyContent: "center",
184
+ fontSize: "18px",
185
+ fontWeight: "bold",
186
+ },
187
+ };
188
+
189
+ var NombaCheckoutButton = /** @class */ (function (_super) {
190
+ __extends(NombaCheckoutButton, _super);
191
+ function NombaCheckoutButton(props) {
192
+ var _this = _super.call(this, props) || this;
193
+ _this.handleClose = function () {
194
+ var _a, _b;
195
+ _this.setState({ showModal: false });
196
+ (_b = (_a = _this.props).onClose) === null || _b === undefined ? undefined : _b.call(_a);
197
+ };
198
+ _this.state = {
199
+ showModal: false,
200
+ };
201
+ return _this;
202
+ }
203
+ NombaCheckoutButton.prototype.render = function () {
204
+ var _this = this;
205
+ var _a = this.props, orderId = _a.orderId, children = _a.children, buttonStyle = _a.buttonStyle, buttonText = _a.buttonText;
206
+ var showModal = this.state.showModal;
207
+ return (React.createElement("div", null,
208
+ React.createElement("button", { style: buttonStyle || styles.button, onClick: showModal
209
+ ? function () { return _this.handleClose(); }
210
+ : function () { return _this.setState({ showModal: true }); } }, children || buttonText || "Pay with Nomba"),
211
+ showModal && (React.createElement(NombaCheckoutModal, { orderId: orderId, onClose: this.handleClose }))));
212
+ };
213
+ return NombaCheckoutButton;
214
+ }(Component));
215
+ var styles = {
216
+ button: {
217
+ height: "48px",
218
+ width: "100%",
219
+ background: "#ffcc00",
220
+ fontSize: "16px",
221
+ fontWeight: 500,
222
+ borderRadius: "8px",
223
+ },
224
+ };
225
+
226
+ function bind(fn, thisArg) {
227
+ return function wrap() {
228
+ return fn.apply(thisArg, arguments);
229
+ };
230
+ }
231
+
232
+ // utils is a library of generic helper functions non-specific to axios
233
+
234
+ const {toString} = Object.prototype;
235
+ const {getPrototypeOf} = Object;
236
+
237
+ const kindOf = (cache => thing => {
238
+ const str = toString.call(thing);
239
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
240
+ })(Object.create(null));
241
+
242
+ const kindOfTest = (type) => {
243
+ type = type.toLowerCase();
244
+ return (thing) => kindOf(thing) === type
245
+ };
246
+
247
+ const typeOfTest = type => thing => typeof thing === type;
248
+
249
+ /**
250
+ * Determine if a value is an Array
251
+ *
252
+ * @param {Object} val The value to test
253
+ *
254
+ * @returns {boolean} True if value is an Array, otherwise false
255
+ */
256
+ const {isArray} = Array;
257
+
258
+ /**
259
+ * Determine if a value is undefined
260
+ *
261
+ * @param {*} val The value to test
262
+ *
263
+ * @returns {boolean} True if the value is undefined, otherwise false
264
+ */
265
+ const isUndefined = typeOfTest('undefined');
266
+
267
+ /**
268
+ * Determine if a value is a Buffer
269
+ *
270
+ * @param {*} val The value to test
271
+ *
272
+ * @returns {boolean} True if value is a Buffer, otherwise false
273
+ */
274
+ function isBuffer(val) {
275
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
276
+ && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
277
+ }
278
+
279
+ /**
280
+ * Determine if a value is an ArrayBuffer
281
+ *
282
+ * @param {*} val The value to test
283
+ *
284
+ * @returns {boolean} True if value is an ArrayBuffer, otherwise false
285
+ */
286
+ const isArrayBuffer = kindOfTest('ArrayBuffer');
287
+
288
+
289
+ /**
290
+ * Determine if a value is a view on an ArrayBuffer
291
+ *
292
+ * @param {*} val The value to test
293
+ *
294
+ * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
295
+ */
296
+ function isArrayBufferView(val) {
297
+ let result;
298
+ if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
299
+ result = ArrayBuffer.isView(val);
300
+ } else {
301
+ result = (val) && (val.buffer) && (isArrayBuffer(val.buffer));
302
+ }
303
+ return result;
304
+ }
305
+
306
+ /**
307
+ * Determine if a value is a String
308
+ *
309
+ * @param {*} val The value to test
310
+ *
311
+ * @returns {boolean} True if value is a String, otherwise false
312
+ */
313
+ const isString = typeOfTest('string');
314
+
315
+ /**
316
+ * Determine if a value is a Function
317
+ *
318
+ * @param {*} val The value to test
319
+ * @returns {boolean} True if value is a Function, otherwise false
320
+ */
321
+ const isFunction = typeOfTest('function');
322
+
323
+ /**
324
+ * Determine if a value is a Number
325
+ *
326
+ * @param {*} val The value to test
327
+ *
328
+ * @returns {boolean} True if value is a Number, otherwise false
329
+ */
330
+ const isNumber = typeOfTest('number');
331
+
332
+ /**
333
+ * Determine if a value is an Object
334
+ *
335
+ * @param {*} thing The value to test
336
+ *
337
+ * @returns {boolean} True if value is an Object, otherwise false
338
+ */
339
+ const isObject = (thing) => thing !== null && typeof thing === 'object';
340
+
341
+ /**
342
+ * Determine if a value is a Boolean
343
+ *
344
+ * @param {*} thing The value to test
345
+ * @returns {boolean} True if value is a Boolean, otherwise false
346
+ */
347
+ const isBoolean = thing => thing === true || thing === false;
348
+
349
+ /**
350
+ * Determine if a value is a plain Object
351
+ *
352
+ * @param {*} val The value to test
353
+ *
354
+ * @returns {boolean} True if value is a plain Object, otherwise false
355
+ */
356
+ const isPlainObject = (val) => {
357
+ if (kindOf(val) !== 'object') {
358
+ return false;
359
+ }
360
+
361
+ const prototype = getPrototypeOf(val);
362
+ return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
363
+ };
364
+
365
+ /**
366
+ * Determine if a value is a Date
367
+ *
368
+ * @param {*} val The value to test
369
+ *
370
+ * @returns {boolean} True if value is a Date, otherwise false
371
+ */
372
+ const isDate = kindOfTest('Date');
373
+
374
+ /**
375
+ * Determine if a value is a File
376
+ *
377
+ * @param {*} val The value to test
378
+ *
379
+ * @returns {boolean} True if value is a File, otherwise false
380
+ */
381
+ const isFile = kindOfTest('File');
382
+
383
+ /**
384
+ * Determine if a value is a Blob
385
+ *
386
+ * @param {*} val The value to test
387
+ *
388
+ * @returns {boolean} True if value is a Blob, otherwise false
389
+ */
390
+ const isBlob = kindOfTest('Blob');
391
+
392
+ /**
393
+ * Determine if a value is a FileList
394
+ *
395
+ * @param {*} val The value to test
396
+ *
397
+ * @returns {boolean} True if value is a File, otherwise false
398
+ */
399
+ const isFileList = kindOfTest('FileList');
400
+
401
+ /**
402
+ * Determine if a value is a Stream
403
+ *
404
+ * @param {*} val The value to test
405
+ *
406
+ * @returns {boolean} True if value is a Stream, otherwise false
407
+ */
408
+ const isStream = (val) => isObject(val) && isFunction(val.pipe);
409
+
410
+ /**
411
+ * Determine if a value is a FormData
412
+ *
413
+ * @param {*} thing The value to test
414
+ *
415
+ * @returns {boolean} True if value is an FormData, otherwise false
416
+ */
417
+ const isFormData = (thing) => {
418
+ let kind;
419
+ return thing && (
420
+ (typeof FormData === 'function' && thing instanceof FormData) || (
421
+ isFunction(thing.append) && (
422
+ (kind = kindOf(thing)) === 'formdata' ||
423
+ // detect form-data instance
424
+ (kind === 'object' && isFunction(thing.toString) && thing.toString() === '[object FormData]')
425
+ )
426
+ )
427
+ )
428
+ };
429
+
430
+ /**
431
+ * Determine if a value is a URLSearchParams object
432
+ *
433
+ * @param {*} val The value to test
434
+ *
435
+ * @returns {boolean} True if value is a URLSearchParams object, otherwise false
436
+ */
437
+ const isURLSearchParams = kindOfTest('URLSearchParams');
438
+
439
+ const [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'Request', 'Response', 'Headers'].map(kindOfTest);
440
+
441
+ /**
442
+ * Trim excess whitespace off the beginning and end of a string
443
+ *
444
+ * @param {String} str The String to trim
445
+ *
446
+ * @returns {String} The String freed of excess whitespace
447
+ */
448
+ const trim = (str) => str.trim ?
449
+ str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
450
+
451
+ /**
452
+ * Iterate over an Array or an Object invoking a function for each item.
453
+ *
454
+ * If `obj` is an Array callback will be called passing
455
+ * the value, index, and complete array for each item.
456
+ *
457
+ * If 'obj' is an Object callback will be called passing
458
+ * the value, key, and complete object for each property.
459
+ *
460
+ * @param {Object|Array} obj The object to iterate
461
+ * @param {Function} fn The callback to invoke for each item
462
+ *
463
+ * @param {Boolean} [allOwnKeys = false]
464
+ * @returns {any}
465
+ */
466
+ function forEach(obj, fn, {allOwnKeys = false} = {}) {
467
+ // Don't bother if no value provided
468
+ if (obj === null || typeof obj === 'undefined') {
469
+ return;
470
+ }
471
+
472
+ let i;
473
+ let l;
474
+
475
+ // Force an array if not already something iterable
476
+ if (typeof obj !== 'object') {
477
+ /*eslint no-param-reassign:0*/
478
+ obj = [obj];
479
+ }
480
+
481
+ if (isArray(obj)) {
482
+ // Iterate over array values
483
+ for (i = 0, l = obj.length; i < l; i++) {
484
+ fn.call(null, obj[i], i, obj);
485
+ }
486
+ } else {
487
+ // Iterate over object keys
488
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
489
+ const len = keys.length;
490
+ let key;
491
+
492
+ for (i = 0; i < len; i++) {
493
+ key = keys[i];
494
+ fn.call(null, obj[key], key, obj);
495
+ }
496
+ }
497
+ }
498
+
499
+ function findKey(obj, key) {
500
+ key = key.toLowerCase();
501
+ const keys = Object.keys(obj);
502
+ let i = keys.length;
503
+ let _key;
504
+ while (i-- > 0) {
505
+ _key = keys[i];
506
+ if (key === _key.toLowerCase()) {
507
+ return _key;
508
+ }
509
+ }
510
+ return null;
511
+ }
512
+
513
+ const _global = (() => {
514
+ /*eslint no-undef:0*/
515
+ if (typeof globalThis !== "undefined") return globalThis;
516
+ return typeof self !== "undefined" ? self : (typeof window !== 'undefined' ? window : global)
517
+ })();
518
+
519
+ const isContextDefined = (context) => !isUndefined(context) && context !== _global;
520
+
521
+ /**
522
+ * Accepts varargs expecting each argument to be an object, then
523
+ * immutably merges the properties of each object and returns result.
524
+ *
525
+ * When multiple objects contain the same key the later object in
526
+ * the arguments list will take precedence.
527
+ *
528
+ * Example:
529
+ *
530
+ * ```js
531
+ * var result = merge({foo: 123}, {foo: 456});
532
+ * console.log(result.foo); // outputs 456
533
+ * ```
534
+ *
535
+ * @param {Object} obj1 Object to merge
536
+ *
537
+ * @returns {Object} Result of all merge properties
538
+ */
539
+ function merge(/* obj1, obj2, obj3, ... */) {
540
+ const {caseless} = isContextDefined(this) && this || {};
541
+ const result = {};
542
+ const assignValue = (val, key) => {
543
+ const targetKey = caseless && findKey(result, key) || key;
544
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
545
+ result[targetKey] = merge(result[targetKey], val);
546
+ } else if (isPlainObject(val)) {
547
+ result[targetKey] = merge({}, val);
548
+ } else if (isArray(val)) {
549
+ result[targetKey] = val.slice();
550
+ } else {
551
+ result[targetKey] = val;
552
+ }
553
+ };
554
+
555
+ for (let i = 0, l = arguments.length; i < l; i++) {
556
+ arguments[i] && forEach(arguments[i], assignValue);
557
+ }
558
+ return result;
559
+ }
560
+
561
+ /**
562
+ * Extends object a by mutably adding to it the properties of object b.
563
+ *
564
+ * @param {Object} a The object to be extended
565
+ * @param {Object} b The object to copy properties from
566
+ * @param {Object} thisArg The object to bind function to
567
+ *
568
+ * @param {Boolean} [allOwnKeys]
569
+ * @returns {Object} The resulting value of object a
570
+ */
571
+ const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
572
+ forEach(b, (val, key) => {
573
+ if (thisArg && isFunction(val)) {
574
+ a[key] = bind(val, thisArg);
575
+ } else {
576
+ a[key] = val;
577
+ }
578
+ }, {allOwnKeys});
579
+ return a;
580
+ };
581
+
582
+ /**
583
+ * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
584
+ *
585
+ * @param {string} content with BOM
586
+ *
587
+ * @returns {string} content value without BOM
588
+ */
589
+ const stripBOM = (content) => {
590
+ if (content.charCodeAt(0) === 0xFEFF) {
591
+ content = content.slice(1);
592
+ }
593
+ return content;
594
+ };
595
+
596
+ /**
597
+ * Inherit the prototype methods from one constructor into another
598
+ * @param {function} constructor
599
+ * @param {function} superConstructor
600
+ * @param {object} [props]
601
+ * @param {object} [descriptors]
602
+ *
603
+ * @returns {void}
604
+ */
605
+ const inherits = (constructor, superConstructor, props, descriptors) => {
606
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors);
607
+ constructor.prototype.constructor = constructor;
608
+ Object.defineProperty(constructor, 'super', {
609
+ value: superConstructor.prototype
610
+ });
611
+ props && Object.assign(constructor.prototype, props);
612
+ };
613
+
614
+ /**
615
+ * Resolve object with deep prototype chain to a flat object
616
+ * @param {Object} sourceObj source object
617
+ * @param {Object} [destObj]
618
+ * @param {Function|Boolean} [filter]
619
+ * @param {Function} [propFilter]
620
+ *
621
+ * @returns {Object}
622
+ */
623
+ const toFlatObject = (sourceObj, destObj, filter, propFilter) => {
624
+ let props;
625
+ let i;
626
+ let prop;
627
+ const merged = {};
628
+
629
+ destObj = destObj || {};
630
+ // eslint-disable-next-line no-eq-null,eqeqeq
631
+ if (sourceObj == null) return destObj;
632
+
633
+ do {
634
+ props = Object.getOwnPropertyNames(sourceObj);
635
+ i = props.length;
636
+ while (i-- > 0) {
637
+ prop = props[i];
638
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
639
+ destObj[prop] = sourceObj[prop];
640
+ merged[prop] = true;
641
+ }
642
+ }
643
+ sourceObj = filter !== false && getPrototypeOf(sourceObj);
644
+ } while (sourceObj && (!filter || filter(sourceObj, destObj)) && sourceObj !== Object.prototype);
645
+
646
+ return destObj;
647
+ };
648
+
649
+ /**
650
+ * Determines whether a string ends with the characters of a specified string
651
+ *
652
+ * @param {String} str
653
+ * @param {String} searchString
654
+ * @param {Number} [position= 0]
655
+ *
656
+ * @returns {boolean}
657
+ */
658
+ const endsWith = (str, searchString, position) => {
659
+ str = String(str);
660
+ if (position === undefined || position > str.length) {
661
+ position = str.length;
662
+ }
663
+ position -= searchString.length;
664
+ const lastIndex = str.indexOf(searchString, position);
665
+ return lastIndex !== -1 && lastIndex === position;
666
+ };
667
+
668
+
669
+ /**
670
+ * Returns new array from array like object or null if failed
671
+ *
672
+ * @param {*} [thing]
673
+ *
674
+ * @returns {?Array}
675
+ */
676
+ const toArray = (thing) => {
677
+ if (!thing) return null;
678
+ if (isArray(thing)) return thing;
679
+ let i = thing.length;
680
+ if (!isNumber(i)) return null;
681
+ const arr = new Array(i);
682
+ while (i-- > 0) {
683
+ arr[i] = thing[i];
684
+ }
685
+ return arr;
686
+ };
687
+
688
+ /**
689
+ * Checking if the Uint8Array exists and if it does, it returns a function that checks if the
690
+ * thing passed in is an instance of Uint8Array
691
+ *
692
+ * @param {TypedArray}
693
+ *
694
+ * @returns {Array}
695
+ */
696
+ // eslint-disable-next-line func-names
697
+ const isTypedArray = (TypedArray => {
698
+ // eslint-disable-next-line func-names
699
+ return thing => {
700
+ return TypedArray && thing instanceof TypedArray;
701
+ };
702
+ })(typeof Uint8Array !== 'undefined' && getPrototypeOf(Uint8Array));
703
+
704
+ /**
705
+ * For each entry in the object, call the function with the key and value.
706
+ *
707
+ * @param {Object<any, any>} obj - The object to iterate over.
708
+ * @param {Function} fn - The function to call for each entry.
709
+ *
710
+ * @returns {void}
711
+ */
712
+ const forEachEntry = (obj, fn) => {
713
+ const generator = obj && obj[Symbol.iterator];
714
+
715
+ const iterator = generator.call(obj);
716
+
717
+ let result;
718
+
719
+ while ((result = iterator.next()) && !result.done) {
720
+ const pair = result.value;
721
+ fn.call(obj, pair[0], pair[1]);
722
+ }
723
+ };
724
+
725
+ /**
726
+ * It takes a regular expression and a string, and returns an array of all the matches
727
+ *
728
+ * @param {string} regExp - The regular expression to match against.
729
+ * @param {string} str - The string to search.
730
+ *
731
+ * @returns {Array<boolean>}
732
+ */
733
+ const matchAll = (regExp, str) => {
734
+ let matches;
735
+ const arr = [];
736
+
737
+ while ((matches = regExp.exec(str)) !== null) {
738
+ arr.push(matches);
739
+ }
740
+
741
+ return arr;
742
+ };
743
+
744
+ /* Checking if the kindOfTest function returns true when passed an HTMLFormElement. */
745
+ const isHTMLForm = kindOfTest('HTMLFormElement');
746
+
747
+ const toCamelCase = str => {
748
+ return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,
749
+ function replacer(m, p1, p2) {
750
+ return p1.toUpperCase() + p2;
751
+ }
752
+ );
753
+ };
754
+
755
+ /* Creating a function that will check if an object has a property. */
756
+ const hasOwnProperty = (({hasOwnProperty}) => (obj, prop) => hasOwnProperty.call(obj, prop))(Object.prototype);
757
+
758
+ /**
759
+ * Determine if a value is a RegExp object
760
+ *
761
+ * @param {*} val The value to test
762
+ *
763
+ * @returns {boolean} True if value is a RegExp object, otherwise false
764
+ */
765
+ const isRegExp = kindOfTest('RegExp');
766
+
767
+ const reduceDescriptors = (obj, reducer) => {
768
+ const descriptors = Object.getOwnPropertyDescriptors(obj);
769
+ const reducedDescriptors = {};
770
+
771
+ forEach(descriptors, (descriptor, name) => {
772
+ let ret;
773
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
774
+ reducedDescriptors[name] = ret || descriptor;
775
+ }
776
+ });
777
+
778
+ Object.defineProperties(obj, reducedDescriptors);
779
+ };
780
+
781
+ /**
782
+ * Makes all methods read-only
783
+ * @param {Object} obj
784
+ */
785
+
786
+ const freezeMethods = (obj) => {
787
+ reduceDescriptors(obj, (descriptor, name) => {
788
+ // skip restricted props in strict mode
789
+ if (isFunction(obj) && ['arguments', 'caller', 'callee'].indexOf(name) !== -1) {
790
+ return false;
791
+ }
792
+
793
+ const value = obj[name];
794
+
795
+ if (!isFunction(value)) return;
796
+
797
+ descriptor.enumerable = false;
798
+
799
+ if ('writable' in descriptor) {
800
+ descriptor.writable = false;
801
+ return;
802
+ }
803
+
804
+ if (!descriptor.set) {
805
+ descriptor.set = () => {
806
+ throw Error('Can not rewrite read-only method \'' + name + '\'');
807
+ };
808
+ }
809
+ });
810
+ };
811
+
812
+ const toObjectSet = (arrayOrString, delimiter) => {
813
+ const obj = {};
814
+
815
+ const define = (arr) => {
816
+ arr.forEach(value => {
817
+ obj[value] = true;
818
+ });
819
+ };
820
+
821
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
822
+
823
+ return obj;
824
+ };
825
+
826
+ const noop = () => {};
827
+
828
+ const toFiniteNumber = (value, defaultValue) => {
829
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
830
+ };
831
+
832
+ const ALPHA = 'abcdefghijklmnopqrstuvwxyz';
833
+
834
+ const DIGIT = '0123456789';
835
+
836
+ const ALPHABET = {
837
+ DIGIT,
838
+ ALPHA,
839
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
840
+ };
841
+
842
+ const generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
843
+ let str = '';
844
+ const {length} = alphabet;
845
+ while (size--) {
846
+ str += alphabet[Math.random() * length|0];
847
+ }
848
+
849
+ return str;
850
+ };
851
+
852
+ /**
853
+ * If the thing is a FormData object, return true, otherwise return false.
854
+ *
855
+ * @param {unknown} thing - The thing to check.
856
+ *
857
+ * @returns {boolean}
858
+ */
859
+ function isSpecCompliantForm(thing) {
860
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === 'FormData' && thing[Symbol.iterator]);
861
+ }
862
+
863
+ const toJSONObject = (obj) => {
864
+ const stack = new Array(10);
865
+
866
+ const visit = (source, i) => {
867
+
868
+ if (isObject(source)) {
869
+ if (stack.indexOf(source) >= 0) {
870
+ return;
871
+ }
872
+
873
+ if(!('toJSON' in source)) {
874
+ stack[i] = source;
875
+ const target = isArray(source) ? [] : {};
876
+
877
+ forEach(source, (value, key) => {
878
+ const reducedValue = visit(value, i + 1);
879
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
880
+ });
881
+
882
+ stack[i] = undefined;
883
+
884
+ return target;
885
+ }
886
+ }
887
+
888
+ return source;
889
+ };
890
+
891
+ return visit(obj, 0);
892
+ };
893
+
894
+ const isAsyncFn = kindOfTest('AsyncFunction');
895
+
896
+ const isThenable = (thing) =>
897
+ thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
898
+
899
+ // original code
900
+ // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
901
+
902
+ const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
903
+ if (setImmediateSupported) {
904
+ return setImmediate;
905
+ }
906
+
907
+ return postMessageSupported ? ((token, callbacks) => {
908
+ _global.addEventListener("message", ({source, data}) => {
909
+ if (source === _global && data === token) {
910
+ callbacks.length && callbacks.shift()();
911
+ }
912
+ }, false);
913
+
914
+ return (cb) => {
915
+ callbacks.push(cb);
916
+ _global.postMessage(token, "*");
917
+ }
918
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
919
+ })(
920
+ typeof setImmediate === 'function',
921
+ isFunction(_global.postMessage)
922
+ );
923
+
924
+ const asap = typeof queueMicrotask !== 'undefined' ?
925
+ queueMicrotask.bind(_global) : ( typeof process !== 'undefined' && process.nextTick || _setImmediate);
926
+
927
+ // *********************
928
+
929
+ var utils$1 = {
930
+ isArray,
931
+ isArrayBuffer,
932
+ isBuffer,
933
+ isFormData,
934
+ isArrayBufferView,
935
+ isString,
936
+ isNumber,
937
+ isBoolean,
938
+ isObject,
939
+ isPlainObject,
940
+ isReadableStream,
941
+ isRequest,
942
+ isResponse,
943
+ isHeaders,
944
+ isUndefined,
945
+ isDate,
946
+ isFile,
947
+ isBlob,
948
+ isRegExp,
949
+ isFunction,
950
+ isStream,
951
+ isURLSearchParams,
952
+ isTypedArray,
953
+ isFileList,
954
+ forEach,
955
+ merge,
956
+ extend,
957
+ trim,
958
+ stripBOM,
959
+ inherits,
960
+ toFlatObject,
961
+ kindOf,
962
+ kindOfTest,
963
+ endsWith,
964
+ toArray,
965
+ forEachEntry,
966
+ matchAll,
967
+ isHTMLForm,
968
+ hasOwnProperty,
969
+ hasOwnProp: hasOwnProperty, // an alias to avoid ESLint no-prototype-builtins detection
970
+ reduceDescriptors,
971
+ freezeMethods,
972
+ toObjectSet,
973
+ toCamelCase,
974
+ noop,
975
+ toFiniteNumber,
976
+ findKey,
977
+ global: _global,
978
+ isContextDefined,
979
+ ALPHABET,
980
+ generateString,
981
+ isSpecCompliantForm,
982
+ toJSONObject,
983
+ isAsyncFn,
984
+ isThenable,
985
+ setImmediate: _setImmediate,
986
+ asap
987
+ };
988
+
989
+ /**
990
+ * Create an Error with the specified message, config, error code, request and response.
991
+ *
992
+ * @param {string} message The error message.
993
+ * @param {string} [code] The error code (for example, 'ECONNABORTED').
994
+ * @param {Object} [config] The config.
995
+ * @param {Object} [request] The request.
996
+ * @param {Object} [response] The response.
997
+ *
998
+ * @returns {Error} The created error.
999
+ */
1000
+ function AxiosError(message, code, config, request, response) {
1001
+ Error.call(this);
1002
+
1003
+ if (Error.captureStackTrace) {
1004
+ Error.captureStackTrace(this, this.constructor);
1005
+ } else {
1006
+ this.stack = (new Error()).stack;
1007
+ }
1008
+
1009
+ this.message = message;
1010
+ this.name = 'AxiosError';
1011
+ code && (this.code = code);
1012
+ config && (this.config = config);
1013
+ request && (this.request = request);
1014
+ if (response) {
1015
+ this.response = response;
1016
+ this.status = response.status ? response.status : null;
1017
+ }
1018
+ }
1019
+
1020
+ utils$1.inherits(AxiosError, Error, {
1021
+ toJSON: function toJSON() {
1022
+ return {
1023
+ // Standard
1024
+ message: this.message,
1025
+ name: this.name,
1026
+ // Microsoft
1027
+ description: this.description,
1028
+ number: this.number,
1029
+ // Mozilla
1030
+ fileName: this.fileName,
1031
+ lineNumber: this.lineNumber,
1032
+ columnNumber: this.columnNumber,
1033
+ stack: this.stack,
1034
+ // Axios
1035
+ config: utils$1.toJSONObject(this.config),
1036
+ code: this.code,
1037
+ status: this.status
1038
+ };
1039
+ }
1040
+ });
1041
+
1042
+ const prototype$1 = AxiosError.prototype;
1043
+ const descriptors = {};
1044
+
1045
+ [
1046
+ 'ERR_BAD_OPTION_VALUE',
1047
+ 'ERR_BAD_OPTION',
1048
+ 'ECONNABORTED',
1049
+ 'ETIMEDOUT',
1050
+ 'ERR_NETWORK',
1051
+ 'ERR_FR_TOO_MANY_REDIRECTS',
1052
+ 'ERR_DEPRECATED',
1053
+ 'ERR_BAD_RESPONSE',
1054
+ 'ERR_BAD_REQUEST',
1055
+ 'ERR_CANCELED',
1056
+ 'ERR_NOT_SUPPORT',
1057
+ 'ERR_INVALID_URL'
1058
+ // eslint-disable-next-line func-names
1059
+ ].forEach(code => {
1060
+ descriptors[code] = {value: code};
1061
+ });
1062
+
1063
+ Object.defineProperties(AxiosError, descriptors);
1064
+ Object.defineProperty(prototype$1, 'isAxiosError', {value: true});
1065
+
1066
+ // eslint-disable-next-line func-names
1067
+ AxiosError.from = (error, code, config, request, response, customProps) => {
1068
+ const axiosError = Object.create(prototype$1);
1069
+
1070
+ utils$1.toFlatObject(error, axiosError, function filter(obj) {
1071
+ return obj !== Error.prototype;
1072
+ }, prop => {
1073
+ return prop !== 'isAxiosError';
1074
+ });
1075
+
1076
+ AxiosError.call(axiosError, error.message, code, config, request, response);
1077
+
1078
+ axiosError.cause = error;
1079
+
1080
+ axiosError.name = error.name;
1081
+
1082
+ customProps && Object.assign(axiosError, customProps);
1083
+
1084
+ return axiosError;
1085
+ };
1086
+
1087
+ // eslint-disable-next-line strict
1088
+ var httpAdapter = null;
1089
+
1090
+ /**
1091
+ * Determines if the given thing is a array or js object.
1092
+ *
1093
+ * @param {string} thing - The object or array to be visited.
1094
+ *
1095
+ * @returns {boolean}
1096
+ */
1097
+ function isVisitable(thing) {
1098
+ return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
1099
+ }
1100
+
1101
+ /**
1102
+ * It removes the brackets from the end of a string
1103
+ *
1104
+ * @param {string} key - The key of the parameter.
1105
+ *
1106
+ * @returns {string} the key without the brackets.
1107
+ */
1108
+ function removeBrackets(key) {
1109
+ return utils$1.endsWith(key, '[]') ? key.slice(0, -2) : key;
1110
+ }
1111
+
1112
+ /**
1113
+ * It takes a path, a key, and a boolean, and returns a string
1114
+ *
1115
+ * @param {string} path - The path to the current key.
1116
+ * @param {string} key - The key of the current object being iterated over.
1117
+ * @param {string} dots - If true, the key will be rendered with dots instead of brackets.
1118
+ *
1119
+ * @returns {string} The path to the current key.
1120
+ */
1121
+ function renderKey(path, key, dots) {
1122
+ if (!path) return key;
1123
+ return path.concat(key).map(function each(token, i) {
1124
+ // eslint-disable-next-line no-param-reassign
1125
+ token = removeBrackets(token);
1126
+ return !dots && i ? '[' + token + ']' : token;
1127
+ }).join(dots ? '.' : '');
1128
+ }
1129
+
1130
+ /**
1131
+ * If the array is an array and none of its elements are visitable, then it's a flat array.
1132
+ *
1133
+ * @param {Array<any>} arr - The array to check
1134
+ *
1135
+ * @returns {boolean}
1136
+ */
1137
+ function isFlatArray(arr) {
1138
+ return utils$1.isArray(arr) && !arr.some(isVisitable);
1139
+ }
1140
+
1141
+ const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
1142
+ return /^is[A-Z]/.test(prop);
1143
+ });
1144
+
1145
+ /**
1146
+ * Convert a data object to FormData
1147
+ *
1148
+ * @param {Object} obj
1149
+ * @param {?Object} [formData]
1150
+ * @param {?Object} [options]
1151
+ * @param {Function} [options.visitor]
1152
+ * @param {Boolean} [options.metaTokens = true]
1153
+ * @param {Boolean} [options.dots = false]
1154
+ * @param {?Boolean} [options.indexes = false]
1155
+ *
1156
+ * @returns {Object}
1157
+ **/
1158
+
1159
+ /**
1160
+ * It converts an object into a FormData object
1161
+ *
1162
+ * @param {Object<any, any>} obj - The object to convert to form data.
1163
+ * @param {string} formData - The FormData object to append to.
1164
+ * @param {Object<string, any>} options
1165
+ *
1166
+ * @returns
1167
+ */
1168
+ function toFormData(obj, formData, options) {
1169
+ if (!utils$1.isObject(obj)) {
1170
+ throw new TypeError('target must be an object');
1171
+ }
1172
+
1173
+ // eslint-disable-next-line no-param-reassign
1174
+ formData = formData || new (FormData)();
1175
+
1176
+ // eslint-disable-next-line no-param-reassign
1177
+ options = utils$1.toFlatObject(options, {
1178
+ metaTokens: true,
1179
+ dots: false,
1180
+ indexes: false
1181
+ }, false, function defined(option, source) {
1182
+ // eslint-disable-next-line no-eq-null,eqeqeq
1183
+ return !utils$1.isUndefined(source[option]);
1184
+ });
1185
+
1186
+ const metaTokens = options.metaTokens;
1187
+ // eslint-disable-next-line no-use-before-define
1188
+ const visitor = options.visitor || defaultVisitor;
1189
+ const dots = options.dots;
1190
+ const indexes = options.indexes;
1191
+ const _Blob = options.Blob || typeof Blob !== 'undefined' && Blob;
1192
+ const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
1193
+
1194
+ if (!utils$1.isFunction(visitor)) {
1195
+ throw new TypeError('visitor must be a function');
1196
+ }
1197
+
1198
+ function convertValue(value) {
1199
+ if (value === null) return '';
1200
+
1201
+ if (utils$1.isDate(value)) {
1202
+ return value.toISOString();
1203
+ }
1204
+
1205
+ if (!useBlob && utils$1.isBlob(value)) {
1206
+ throw new AxiosError('Blob is not supported. Use a Buffer instead.');
1207
+ }
1208
+
1209
+ if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
1210
+ return useBlob && typeof Blob === 'function' ? new Blob([value]) : Buffer.from(value);
1211
+ }
1212
+
1213
+ return value;
1214
+ }
1215
+
1216
+ /**
1217
+ * Default visitor.
1218
+ *
1219
+ * @param {*} value
1220
+ * @param {String|Number} key
1221
+ * @param {Array<String|Number>} path
1222
+ * @this {FormData}
1223
+ *
1224
+ * @returns {boolean} return true to visit the each prop of the value recursively
1225
+ */
1226
+ function defaultVisitor(value, key, path) {
1227
+ let arr = value;
1228
+
1229
+ if (value && !path && typeof value === 'object') {
1230
+ if (utils$1.endsWith(key, '{}')) {
1231
+ // eslint-disable-next-line no-param-reassign
1232
+ key = metaTokens ? key : key.slice(0, -2);
1233
+ // eslint-disable-next-line no-param-reassign
1234
+ value = JSON.stringify(value);
1235
+ } else if (
1236
+ (utils$1.isArray(value) && isFlatArray(value)) ||
1237
+ ((utils$1.isFileList(value) || utils$1.endsWith(key, '[]')) && (arr = utils$1.toArray(value))
1238
+ )) {
1239
+ // eslint-disable-next-line no-param-reassign
1240
+ key = removeBrackets(key);
1241
+
1242
+ arr.forEach(function each(el, index) {
1243
+ !(utils$1.isUndefined(el) || el === null) && formData.append(
1244
+ // eslint-disable-next-line no-nested-ternary
1245
+ indexes === true ? renderKey([key], index, dots) : (indexes === null ? key : key + '[]'),
1246
+ convertValue(el)
1247
+ );
1248
+ });
1249
+ return false;
1250
+ }
1251
+ }
1252
+
1253
+ if (isVisitable(value)) {
1254
+ return true;
1255
+ }
1256
+
1257
+ formData.append(renderKey(path, key, dots), convertValue(value));
1258
+
1259
+ return false;
1260
+ }
1261
+
1262
+ const stack = [];
1263
+
1264
+ const exposedHelpers = Object.assign(predicates, {
1265
+ defaultVisitor,
1266
+ convertValue,
1267
+ isVisitable
1268
+ });
1269
+
1270
+ function build(value, path) {
1271
+ if (utils$1.isUndefined(value)) return;
1272
+
1273
+ if (stack.indexOf(value) !== -1) {
1274
+ throw Error('Circular reference detected in ' + path.join('.'));
1275
+ }
1276
+
1277
+ stack.push(value);
1278
+
1279
+ utils$1.forEach(value, function each(el, key) {
1280
+ const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
1281
+ formData, el, utils$1.isString(key) ? key.trim() : key, path, exposedHelpers
1282
+ );
1283
+
1284
+ if (result === true) {
1285
+ build(el, path ? path.concat(key) : [key]);
1286
+ }
1287
+ });
1288
+
1289
+ stack.pop();
1290
+ }
1291
+
1292
+ if (!utils$1.isObject(obj)) {
1293
+ throw new TypeError('data must be an object');
1294
+ }
1295
+
1296
+ build(obj);
1297
+
1298
+ return formData;
1299
+ }
1300
+
1301
+ /**
1302
+ * It encodes a string by replacing all characters that are not in the unreserved set with
1303
+ * their percent-encoded equivalents
1304
+ *
1305
+ * @param {string} str - The string to encode.
1306
+ *
1307
+ * @returns {string} The encoded string.
1308
+ */
1309
+ function encode$1(str) {
1310
+ const charMap = {
1311
+ '!': '%21',
1312
+ "'": '%27',
1313
+ '(': '%28',
1314
+ ')': '%29',
1315
+ '~': '%7E',
1316
+ '%20': '+',
1317
+ '%00': '\x00'
1318
+ };
1319
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
1320
+ return charMap[match];
1321
+ });
1322
+ }
1323
+
1324
+ /**
1325
+ * It takes a params object and converts it to a FormData object
1326
+ *
1327
+ * @param {Object<string, any>} params - The parameters to be converted to a FormData object.
1328
+ * @param {Object<string, any>} options - The options object passed to the Axios constructor.
1329
+ *
1330
+ * @returns {void}
1331
+ */
1332
+ function AxiosURLSearchParams(params, options) {
1333
+ this._pairs = [];
1334
+
1335
+ params && toFormData(params, this, options);
1336
+ }
1337
+
1338
+ const prototype = AxiosURLSearchParams.prototype;
1339
+
1340
+ prototype.append = function append(name, value) {
1341
+ this._pairs.push([name, value]);
1342
+ };
1343
+
1344
+ prototype.toString = function toString(encoder) {
1345
+ const _encode = encoder ? function(value) {
1346
+ return encoder.call(this, value, encode$1);
1347
+ } : encode$1;
1348
+
1349
+ return this._pairs.map(function each(pair) {
1350
+ return _encode(pair[0]) + '=' + _encode(pair[1]);
1351
+ }, '').join('&');
1352
+ };
1353
+
1354
+ /**
1355
+ * It replaces all instances of the characters `:`, `$`, `,`, `+`, `[`, and `]` with their
1356
+ * URI encoded counterparts
1357
+ *
1358
+ * @param {string} val The value to be encoded.
1359
+ *
1360
+ * @returns {string} The encoded value.
1361
+ */
1362
+ function encode(val) {
1363
+ return encodeURIComponent(val).
1364
+ replace(/%3A/gi, ':').
1365
+ replace(/%24/g, '$').
1366
+ replace(/%2C/gi, ',').
1367
+ replace(/%20/g, '+').
1368
+ replace(/%5B/gi, '[').
1369
+ replace(/%5D/gi, ']');
1370
+ }
1371
+
1372
+ /**
1373
+ * Build a URL by appending params to the end
1374
+ *
1375
+ * @param {string} url The base of the url (e.g., http://www.google.com)
1376
+ * @param {object} [params] The params to be appended
1377
+ * @param {?(object|Function)} options
1378
+ *
1379
+ * @returns {string} The formatted url
1380
+ */
1381
+ function buildURL(url, params, options) {
1382
+ /*eslint no-param-reassign:0*/
1383
+ if (!params) {
1384
+ return url;
1385
+ }
1386
+
1387
+ const _encode = options && options.encode || encode;
1388
+
1389
+ if (utils$1.isFunction(options)) {
1390
+ options = {
1391
+ serialize: options
1392
+ };
1393
+ }
1394
+
1395
+ const serializeFn = options && options.serialize;
1396
+
1397
+ let serializedParams;
1398
+
1399
+ if (serializeFn) {
1400
+ serializedParams = serializeFn(params, options);
1401
+ } else {
1402
+ serializedParams = utils$1.isURLSearchParams(params) ?
1403
+ params.toString() :
1404
+ new AxiosURLSearchParams(params, options).toString(_encode);
1405
+ }
1406
+
1407
+ if (serializedParams) {
1408
+ const hashmarkIndex = url.indexOf("#");
1409
+
1410
+ if (hashmarkIndex !== -1) {
1411
+ url = url.slice(0, hashmarkIndex);
1412
+ }
1413
+ url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
1414
+ }
1415
+
1416
+ return url;
1417
+ }
1418
+
1419
+ class InterceptorManager {
1420
+ constructor() {
1421
+ this.handlers = [];
1422
+ }
1423
+
1424
+ /**
1425
+ * Add a new interceptor to the stack
1426
+ *
1427
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
1428
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
1429
+ *
1430
+ * @return {Number} An ID used to remove interceptor later
1431
+ */
1432
+ use(fulfilled, rejected, options) {
1433
+ this.handlers.push({
1434
+ fulfilled,
1435
+ rejected,
1436
+ synchronous: options ? options.synchronous : false,
1437
+ runWhen: options ? options.runWhen : null
1438
+ });
1439
+ return this.handlers.length - 1;
1440
+ }
1441
+
1442
+ /**
1443
+ * Remove an interceptor from the stack
1444
+ *
1445
+ * @param {Number} id The ID that was returned by `use`
1446
+ *
1447
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
1448
+ */
1449
+ eject(id) {
1450
+ if (this.handlers[id]) {
1451
+ this.handlers[id] = null;
1452
+ }
1453
+ }
1454
+
1455
+ /**
1456
+ * Clear all interceptors from the stack
1457
+ *
1458
+ * @returns {void}
1459
+ */
1460
+ clear() {
1461
+ if (this.handlers) {
1462
+ this.handlers = [];
1463
+ }
1464
+ }
1465
+
1466
+ /**
1467
+ * Iterate over all the registered interceptors
1468
+ *
1469
+ * This method is particularly useful for skipping over any
1470
+ * interceptors that may have become `null` calling `eject`.
1471
+ *
1472
+ * @param {Function} fn The function to call for each interceptor
1473
+ *
1474
+ * @returns {void}
1475
+ */
1476
+ forEach(fn) {
1477
+ utils$1.forEach(this.handlers, function forEachHandler(h) {
1478
+ if (h !== null) {
1479
+ fn(h);
1480
+ }
1481
+ });
1482
+ }
1483
+ }
1484
+
1485
+ var transitionalDefaults = {
1486
+ silentJSONParsing: true,
1487
+ forcedJSONParsing: true,
1488
+ clarifyTimeoutError: false
1489
+ };
1490
+
1491
+ var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
1492
+
1493
+ var FormData$1 = typeof FormData !== 'undefined' ? FormData : null;
1494
+
1495
+ var Blob$1 = typeof Blob !== 'undefined' ? Blob : null;
1496
+
1497
+ var platform$1 = {
1498
+ isBrowser: true,
1499
+ classes: {
1500
+ URLSearchParams: URLSearchParams$1,
1501
+ FormData: FormData$1,
1502
+ Blob: Blob$1
1503
+ },
1504
+ protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
1505
+ };
1506
+
1507
+ const hasBrowserEnv = typeof window !== 'undefined' && typeof document !== 'undefined';
1508
+
1509
+ const _navigator = typeof navigator === 'object' && navigator || undefined;
1510
+
1511
+ /**
1512
+ * Determine if we're running in a standard browser environment
1513
+ *
1514
+ * This allows axios to run in a web worker, and react-native.
1515
+ * Both environments support XMLHttpRequest, but not fully standard globals.
1516
+ *
1517
+ * web workers:
1518
+ * typeof window -> undefined
1519
+ * typeof document -> undefined
1520
+ *
1521
+ * react-native:
1522
+ * navigator.product -> 'ReactNative'
1523
+ * nativescript
1524
+ * navigator.product -> 'NativeScript' or 'NS'
1525
+ *
1526
+ * @returns {boolean}
1527
+ */
1528
+ const hasStandardBrowserEnv = hasBrowserEnv &&
1529
+ (!_navigator || ['ReactNative', 'NativeScript', 'NS'].indexOf(_navigator.product) < 0);
1530
+
1531
+ /**
1532
+ * Determine if we're running in a standard browser webWorker environment
1533
+ *
1534
+ * Although the `isStandardBrowserEnv` method indicates that
1535
+ * `allows axios to run in a web worker`, the WebWorker will still be
1536
+ * filtered out due to its judgment standard
1537
+ * `typeof window !== 'undefined' && typeof document !== 'undefined'`.
1538
+ * This leads to a problem when axios post `FormData` in webWorker
1539
+ */
1540
+ const hasStandardBrowserWebWorkerEnv = (() => {
1541
+ return (
1542
+ typeof WorkerGlobalScope !== 'undefined' &&
1543
+ // eslint-disable-next-line no-undef
1544
+ self instanceof WorkerGlobalScope &&
1545
+ typeof self.importScripts === 'function'
1546
+ );
1547
+ })();
1548
+
1549
+ const origin = hasBrowserEnv && window.location.href || 'http://localhost';
1550
+
1551
+ var utils = /*#__PURE__*/Object.freeze({
1552
+ __proto__: null,
1553
+ hasBrowserEnv: hasBrowserEnv,
1554
+ hasStandardBrowserEnv: hasStandardBrowserEnv,
1555
+ hasStandardBrowserWebWorkerEnv: hasStandardBrowserWebWorkerEnv,
1556
+ navigator: _navigator,
1557
+ origin: origin
1558
+ });
1559
+
1560
+ var platform = {
1561
+ ...utils,
1562
+ ...platform$1
1563
+ };
1564
+
1565
+ function toURLEncodedForm(data, options) {
1566
+ return toFormData(data, new platform.classes.URLSearchParams(), Object.assign({
1567
+ visitor: function(value, key, path, helpers) {
1568
+ if (platform.isNode && utils$1.isBuffer(value)) {
1569
+ this.append(key, value.toString('base64'));
1570
+ return false;
1571
+ }
1572
+
1573
+ return helpers.defaultVisitor.apply(this, arguments);
1574
+ }
1575
+ }, options));
1576
+ }
1577
+
1578
+ /**
1579
+ * It takes a string like `foo[x][y][z]` and returns an array like `['foo', 'x', 'y', 'z']
1580
+ *
1581
+ * @param {string} name - The name of the property to get.
1582
+ *
1583
+ * @returns An array of strings.
1584
+ */
1585
+ function parsePropPath(name) {
1586
+ // foo[x][y][z]
1587
+ // foo.x.y.z
1588
+ // foo-x-y-z
1589
+ // foo x y z
1590
+ return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map(match => {
1591
+ return match[0] === '[]' ? '' : match[1] || match[0];
1592
+ });
1593
+ }
1594
+
1595
+ /**
1596
+ * Convert an array to an object.
1597
+ *
1598
+ * @param {Array<any>} arr - The array to convert to an object.
1599
+ *
1600
+ * @returns An object with the same keys and values as the array.
1601
+ */
1602
+ function arrayToObject(arr) {
1603
+ const obj = {};
1604
+ const keys = Object.keys(arr);
1605
+ let i;
1606
+ const len = keys.length;
1607
+ let key;
1608
+ for (i = 0; i < len; i++) {
1609
+ key = keys[i];
1610
+ obj[key] = arr[key];
1611
+ }
1612
+ return obj;
1613
+ }
1614
+
1615
+ /**
1616
+ * It takes a FormData object and returns a JavaScript object
1617
+ *
1618
+ * @param {string} formData The FormData object to convert to JSON.
1619
+ *
1620
+ * @returns {Object<string, any> | null} The converted object.
1621
+ */
1622
+ function formDataToJSON(formData) {
1623
+ function buildPath(path, value, target, index) {
1624
+ let name = path[index++];
1625
+
1626
+ if (name === '__proto__') return true;
1627
+
1628
+ const isNumericKey = Number.isFinite(+name);
1629
+ const isLast = index >= path.length;
1630
+ name = !name && utils$1.isArray(target) ? target.length : name;
1631
+
1632
+ if (isLast) {
1633
+ if (utils$1.hasOwnProp(target, name)) {
1634
+ target[name] = [target[name], value];
1635
+ } else {
1636
+ target[name] = value;
1637
+ }
1638
+
1639
+ return !isNumericKey;
1640
+ }
1641
+
1642
+ if (!target[name] || !utils$1.isObject(target[name])) {
1643
+ target[name] = [];
1644
+ }
1645
+
1646
+ const result = buildPath(path, value, target[name], index);
1647
+
1648
+ if (result && utils$1.isArray(target[name])) {
1649
+ target[name] = arrayToObject(target[name]);
1650
+ }
1651
+
1652
+ return !isNumericKey;
1653
+ }
1654
+
1655
+ if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
1656
+ const obj = {};
1657
+
1658
+ utils$1.forEachEntry(formData, (name, value) => {
1659
+ buildPath(parsePropPath(name), value, obj, 0);
1660
+ });
1661
+
1662
+ return obj;
1663
+ }
1664
+
1665
+ return null;
1666
+ }
1667
+
1668
+ /**
1669
+ * It takes a string, tries to parse it, and if it fails, it returns the stringified version
1670
+ * of the input
1671
+ *
1672
+ * @param {any} rawValue - The value to be stringified.
1673
+ * @param {Function} parser - A function that parses a string into a JavaScript object.
1674
+ * @param {Function} encoder - A function that takes a value and returns a string.
1675
+ *
1676
+ * @returns {string} A stringified version of the rawValue.
1677
+ */
1678
+ function stringifySafely(rawValue, parser, encoder) {
1679
+ if (utils$1.isString(rawValue)) {
1680
+ try {
1681
+ (parser || JSON.parse)(rawValue);
1682
+ return utils$1.trim(rawValue);
1683
+ } catch (e) {
1684
+ if (e.name !== 'SyntaxError') {
1685
+ throw e;
1686
+ }
1687
+ }
1688
+ }
1689
+
1690
+ return (0, JSON.stringify)(rawValue);
1691
+ }
1692
+
1693
+ const defaults = {
1694
+
1695
+ transitional: transitionalDefaults,
1696
+
1697
+ adapter: ['xhr', 'http', 'fetch'],
1698
+
1699
+ transformRequest: [function transformRequest(data, headers) {
1700
+ const contentType = headers.getContentType() || '';
1701
+ const hasJSONContentType = contentType.indexOf('application/json') > -1;
1702
+ const isObjectPayload = utils$1.isObject(data);
1703
+
1704
+ if (isObjectPayload && utils$1.isHTMLForm(data)) {
1705
+ data = new FormData(data);
1706
+ }
1707
+
1708
+ const isFormData = utils$1.isFormData(data);
1709
+
1710
+ if (isFormData) {
1711
+ return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
1712
+ }
1713
+
1714
+ if (utils$1.isArrayBuffer(data) ||
1715
+ utils$1.isBuffer(data) ||
1716
+ utils$1.isStream(data) ||
1717
+ utils$1.isFile(data) ||
1718
+ utils$1.isBlob(data) ||
1719
+ utils$1.isReadableStream(data)
1720
+ ) {
1721
+ return data;
1722
+ }
1723
+ if (utils$1.isArrayBufferView(data)) {
1724
+ return data.buffer;
1725
+ }
1726
+ if (utils$1.isURLSearchParams(data)) {
1727
+ headers.setContentType('application/x-www-form-urlencoded;charset=utf-8', false);
1728
+ return data.toString();
1729
+ }
1730
+
1731
+ let isFileList;
1732
+
1733
+ if (isObjectPayload) {
1734
+ if (contentType.indexOf('application/x-www-form-urlencoded') > -1) {
1735
+ return toURLEncodedForm(data, this.formSerializer).toString();
1736
+ }
1737
+
1738
+ if ((isFileList = utils$1.isFileList(data)) || contentType.indexOf('multipart/form-data') > -1) {
1739
+ const _FormData = this.env && this.env.FormData;
1740
+
1741
+ return toFormData(
1742
+ isFileList ? {'files[]': data} : data,
1743
+ _FormData && new _FormData(),
1744
+ this.formSerializer
1745
+ );
1746
+ }
1747
+ }
1748
+
1749
+ if (isObjectPayload || hasJSONContentType ) {
1750
+ headers.setContentType('application/json', false);
1751
+ return stringifySafely(data);
1752
+ }
1753
+
1754
+ return data;
1755
+ }],
1756
+
1757
+ transformResponse: [function transformResponse(data) {
1758
+ const transitional = this.transitional || defaults.transitional;
1759
+ const forcedJSONParsing = transitional && transitional.forcedJSONParsing;
1760
+ const JSONRequested = this.responseType === 'json';
1761
+
1762
+ if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
1763
+ return data;
1764
+ }
1765
+
1766
+ if (data && utils$1.isString(data) && ((forcedJSONParsing && !this.responseType) || JSONRequested)) {
1767
+ const silentJSONParsing = transitional && transitional.silentJSONParsing;
1768
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1769
+
1770
+ try {
1771
+ return JSON.parse(data);
1772
+ } catch (e) {
1773
+ if (strictJSONParsing) {
1774
+ if (e.name === 'SyntaxError') {
1775
+ throw AxiosError.from(e, AxiosError.ERR_BAD_RESPONSE, this, null, this.response);
1776
+ }
1777
+ throw e;
1778
+ }
1779
+ }
1780
+ }
1781
+
1782
+ return data;
1783
+ }],
1784
+
1785
+ /**
1786
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1787
+ * timeout is not created.
1788
+ */
1789
+ timeout: 0,
1790
+
1791
+ xsrfCookieName: 'XSRF-TOKEN',
1792
+ xsrfHeaderName: 'X-XSRF-TOKEN',
1793
+
1794
+ maxContentLength: -1,
1795
+ maxBodyLength: -1,
1796
+
1797
+ env: {
1798
+ FormData: platform.classes.FormData,
1799
+ Blob: platform.classes.Blob
1800
+ },
1801
+
1802
+ validateStatus: function validateStatus(status) {
1803
+ return status >= 200 && status < 300;
1804
+ },
1805
+
1806
+ headers: {
1807
+ common: {
1808
+ 'Accept': 'application/json, text/plain, */*',
1809
+ 'Content-Type': undefined
1810
+ }
1811
+ }
1812
+ };
1813
+
1814
+ utils$1.forEach(['delete', 'get', 'head', 'post', 'put', 'patch'], (method) => {
1815
+ defaults.headers[method] = {};
1816
+ });
1817
+
1818
+ // RawAxiosHeaders whose duplicates are ignored by node
1819
+ // c.f. https://nodejs.org/api/http.html#http_message_headers
1820
+ const ignoreDuplicateOf = utils$1.toObjectSet([
1821
+ 'age', 'authorization', 'content-length', 'content-type', 'etag',
1822
+ 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
1823
+ 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
1824
+ 'referer', 'retry-after', 'user-agent'
1825
+ ]);
1826
+
1827
+ /**
1828
+ * Parse headers into an object
1829
+ *
1830
+ * ```
1831
+ * Date: Wed, 27 Aug 2014 08:58:49 GMT
1832
+ * Content-Type: application/json
1833
+ * Connection: keep-alive
1834
+ * Transfer-Encoding: chunked
1835
+ * ```
1836
+ *
1837
+ * @param {String} rawHeaders Headers needing to be parsed
1838
+ *
1839
+ * @returns {Object} Headers parsed into an object
1840
+ */
1841
+ var parseHeaders = rawHeaders => {
1842
+ const parsed = {};
1843
+ let key;
1844
+ let val;
1845
+ let i;
1846
+
1847
+ rawHeaders && rawHeaders.split('\n').forEach(function parser(line) {
1848
+ i = line.indexOf(':');
1849
+ key = line.substring(0, i).trim().toLowerCase();
1850
+ val = line.substring(i + 1).trim();
1851
+
1852
+ if (!key || (parsed[key] && ignoreDuplicateOf[key])) {
1853
+ return;
1854
+ }
1855
+
1856
+ if (key === 'set-cookie') {
1857
+ if (parsed[key]) {
1858
+ parsed[key].push(val);
1859
+ } else {
1860
+ parsed[key] = [val];
1861
+ }
1862
+ } else {
1863
+ parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
1864
+ }
1865
+ });
1866
+
1867
+ return parsed;
1868
+ };
1869
+
1870
+ const $internals = Symbol('internals');
1871
+
1872
+ function normalizeHeader(header) {
1873
+ return header && String(header).trim().toLowerCase();
1874
+ }
1875
+
1876
+ function normalizeValue(value) {
1877
+ if (value === false || value == null) {
1878
+ return value;
1879
+ }
1880
+
1881
+ return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
1882
+ }
1883
+
1884
+ function parseTokens(str) {
1885
+ const tokens = Object.create(null);
1886
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1887
+ let match;
1888
+
1889
+ while ((match = tokensRE.exec(str))) {
1890
+ tokens[match[1]] = match[2];
1891
+ }
1892
+
1893
+ return tokens;
1894
+ }
1895
+
1896
+ const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1897
+
1898
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1899
+ if (utils$1.isFunction(filter)) {
1900
+ return filter.call(this, value, header);
1901
+ }
1902
+
1903
+ if (isHeaderNameFilter) {
1904
+ value = header;
1905
+ }
1906
+
1907
+ if (!utils$1.isString(value)) return;
1908
+
1909
+ if (utils$1.isString(filter)) {
1910
+ return value.indexOf(filter) !== -1;
1911
+ }
1912
+
1913
+ if (utils$1.isRegExp(filter)) {
1914
+ return filter.test(value);
1915
+ }
1916
+ }
1917
+
1918
+ function formatHeader(header) {
1919
+ return header.trim()
1920
+ .toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1921
+ return char.toUpperCase() + str;
1922
+ });
1923
+ }
1924
+
1925
+ function buildAccessors(obj, header) {
1926
+ const accessorName = utils$1.toCamelCase(' ' + header);
1927
+
1928
+ ['get', 'set', 'has'].forEach(methodName => {
1929
+ Object.defineProperty(obj, methodName + accessorName, {
1930
+ value: function(arg1, arg2, arg3) {
1931
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1932
+ },
1933
+ configurable: true
1934
+ });
1935
+ });
1936
+ }
1937
+
1938
+ class AxiosHeaders {
1939
+ constructor(headers) {
1940
+ headers && this.set(headers);
1941
+ }
1942
+
1943
+ set(header, valueOrRewrite, rewrite) {
1944
+ const self = this;
1945
+
1946
+ function setHeader(_value, _header, _rewrite) {
1947
+ const lHeader = normalizeHeader(_header);
1948
+
1949
+ if (!lHeader) {
1950
+ throw new Error('header name must be a non-empty string');
1951
+ }
1952
+
1953
+ const key = utils$1.findKey(self, lHeader);
1954
+
1955
+ if(!key || self[key] === undefined || _rewrite === true || (_rewrite === undefined && self[key] !== false)) {
1956
+ self[key || _header] = normalizeValue(_value);
1957
+ }
1958
+ }
1959
+
1960
+ const setHeaders = (headers, _rewrite) =>
1961
+ utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1962
+
1963
+ if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
1964
+ setHeaders(header, valueOrRewrite);
1965
+ } else if(utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1966
+ setHeaders(parseHeaders(header), valueOrRewrite);
1967
+ } else if (utils$1.isHeaders(header)) {
1968
+ for (const [key, value] of header.entries()) {
1969
+ setHeader(value, key, rewrite);
1970
+ }
1971
+ } else {
1972
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1973
+ }
1974
+
1975
+ return this;
1976
+ }
1977
+
1978
+ get(header, parser) {
1979
+ header = normalizeHeader(header);
1980
+
1981
+ if (header) {
1982
+ const key = utils$1.findKey(this, header);
1983
+
1984
+ if (key) {
1985
+ const value = this[key];
1986
+
1987
+ if (!parser) {
1988
+ return value;
1989
+ }
1990
+
1991
+ if (parser === true) {
1992
+ return parseTokens(value);
1993
+ }
1994
+
1995
+ if (utils$1.isFunction(parser)) {
1996
+ return parser.call(this, value, key);
1997
+ }
1998
+
1999
+ if (utils$1.isRegExp(parser)) {
2000
+ return parser.exec(value);
2001
+ }
2002
+
2003
+ throw new TypeError('parser must be boolean|regexp|function');
2004
+ }
2005
+ }
2006
+ }
2007
+
2008
+ has(header, matcher) {
2009
+ header = normalizeHeader(header);
2010
+
2011
+ if (header) {
2012
+ const key = utils$1.findKey(this, header);
2013
+
2014
+ return !!(key && this[key] !== undefined && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
2015
+ }
2016
+
2017
+ return false;
2018
+ }
2019
+
2020
+ delete(header, matcher) {
2021
+ const self = this;
2022
+ let deleted = false;
2023
+
2024
+ function deleteHeader(_header) {
2025
+ _header = normalizeHeader(_header);
2026
+
2027
+ if (_header) {
2028
+ const key = utils$1.findKey(self, _header);
2029
+
2030
+ if (key && (!matcher || matchHeaderValue(self, self[key], key, matcher))) {
2031
+ delete self[key];
2032
+
2033
+ deleted = true;
2034
+ }
2035
+ }
2036
+ }
2037
+
2038
+ if (utils$1.isArray(header)) {
2039
+ header.forEach(deleteHeader);
2040
+ } else {
2041
+ deleteHeader(header);
2042
+ }
2043
+
2044
+ return deleted;
2045
+ }
2046
+
2047
+ clear(matcher) {
2048
+ const keys = Object.keys(this);
2049
+ let i = keys.length;
2050
+ let deleted = false;
2051
+
2052
+ while (i--) {
2053
+ const key = keys[i];
2054
+ if(!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
2055
+ delete this[key];
2056
+ deleted = true;
2057
+ }
2058
+ }
2059
+
2060
+ return deleted;
2061
+ }
2062
+
2063
+ normalize(format) {
2064
+ const self = this;
2065
+ const headers = {};
2066
+
2067
+ utils$1.forEach(this, (value, header) => {
2068
+ const key = utils$1.findKey(headers, header);
2069
+
2070
+ if (key) {
2071
+ self[key] = normalizeValue(value);
2072
+ delete self[header];
2073
+ return;
2074
+ }
2075
+
2076
+ const normalized = format ? formatHeader(header) : String(header).trim();
2077
+
2078
+ if (normalized !== header) {
2079
+ delete self[header];
2080
+ }
2081
+
2082
+ self[normalized] = normalizeValue(value);
2083
+
2084
+ headers[normalized] = true;
2085
+ });
2086
+
2087
+ return this;
2088
+ }
2089
+
2090
+ concat(...targets) {
2091
+ return this.constructor.concat(this, ...targets);
2092
+ }
2093
+
2094
+ toJSON(asStrings) {
2095
+ const obj = Object.create(null);
2096
+
2097
+ utils$1.forEach(this, (value, header) => {
2098
+ value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(', ') : value);
2099
+ });
2100
+
2101
+ return obj;
2102
+ }
2103
+
2104
+ [Symbol.iterator]() {
2105
+ return Object.entries(this.toJSON())[Symbol.iterator]();
2106
+ }
2107
+
2108
+ toString() {
2109
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ': ' + value).join('\n');
2110
+ }
2111
+
2112
+ get [Symbol.toStringTag]() {
2113
+ return 'AxiosHeaders';
2114
+ }
2115
+
2116
+ static from(thing) {
2117
+ return thing instanceof this ? thing : new this(thing);
2118
+ }
2119
+
2120
+ static concat(first, ...targets) {
2121
+ const computed = new this(first);
2122
+
2123
+ targets.forEach((target) => computed.set(target));
2124
+
2125
+ return computed;
2126
+ }
2127
+
2128
+ static accessor(header) {
2129
+ const internals = this[$internals] = (this[$internals] = {
2130
+ accessors: {}
2131
+ });
2132
+
2133
+ const accessors = internals.accessors;
2134
+ const prototype = this.prototype;
2135
+
2136
+ function defineAccessor(_header) {
2137
+ const lHeader = normalizeHeader(_header);
2138
+
2139
+ if (!accessors[lHeader]) {
2140
+ buildAccessors(prototype, _header);
2141
+ accessors[lHeader] = true;
2142
+ }
2143
+ }
2144
+
2145
+ utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
2146
+
2147
+ return this;
2148
+ }
2149
+ }
2150
+
2151
+ AxiosHeaders.accessor(['Content-Type', 'Content-Length', 'Accept', 'Accept-Encoding', 'User-Agent', 'Authorization']);
2152
+
2153
+ // reserved names hotfix
2154
+ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({value}, key) => {
2155
+ let mapped = key[0].toUpperCase() + key.slice(1); // map `set` => `Set`
2156
+ return {
2157
+ get: () => value,
2158
+ set(headerValue) {
2159
+ this[mapped] = headerValue;
2160
+ }
2161
+ }
2162
+ });
2163
+
2164
+ utils$1.freezeMethods(AxiosHeaders);
2165
+
2166
+ /**
2167
+ * Transform the data for a request or a response
2168
+ *
2169
+ * @param {Array|Function} fns A single function or Array of functions
2170
+ * @param {?Object} response The response object
2171
+ *
2172
+ * @returns {*} The resulting transformed data
2173
+ */
2174
+ function transformData(fns, response) {
2175
+ const config = this || defaults;
2176
+ const context = response || config;
2177
+ const headers = AxiosHeaders.from(context.headers);
2178
+ let data = context.data;
2179
+
2180
+ utils$1.forEach(fns, function transform(fn) {
2181
+ data = fn.call(config, data, headers.normalize(), response ? response.status : undefined);
2182
+ });
2183
+
2184
+ headers.normalize();
2185
+
2186
+ return data;
2187
+ }
2188
+
2189
+ function isCancel(value) {
2190
+ return !!(value && value.__CANCEL__);
2191
+ }
2192
+
2193
+ /**
2194
+ * A `CanceledError` is an object that is thrown when an operation is canceled.
2195
+ *
2196
+ * @param {string=} message The message.
2197
+ * @param {Object=} config The config.
2198
+ * @param {Object=} request The request.
2199
+ *
2200
+ * @returns {CanceledError} The created error.
2201
+ */
2202
+ function CanceledError(message, config, request) {
2203
+ // eslint-disable-next-line no-eq-null,eqeqeq
2204
+ AxiosError.call(this, message == null ? 'canceled' : message, AxiosError.ERR_CANCELED, config, request);
2205
+ this.name = 'CanceledError';
2206
+ }
2207
+
2208
+ utils$1.inherits(CanceledError, AxiosError, {
2209
+ __CANCEL__: true
2210
+ });
2211
+
2212
+ /**
2213
+ * Resolve or reject a Promise based on response status.
2214
+ *
2215
+ * @param {Function} resolve A function that resolves the promise.
2216
+ * @param {Function} reject A function that rejects the promise.
2217
+ * @param {object} response The response.
2218
+ *
2219
+ * @returns {object} The response.
2220
+ */
2221
+ function settle(resolve, reject, response) {
2222
+ const validateStatus = response.config.validateStatus;
2223
+ if (!response.status || !validateStatus || validateStatus(response.status)) {
2224
+ resolve(response);
2225
+ } else {
2226
+ reject(new AxiosError(
2227
+ 'Request failed with status code ' + response.status,
2228
+ [AxiosError.ERR_BAD_REQUEST, AxiosError.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
2229
+ response.config,
2230
+ response.request,
2231
+ response
2232
+ ));
2233
+ }
2234
+ }
2235
+
2236
+ function parseProtocol(url) {
2237
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
2238
+ return match && match[1] || '';
2239
+ }
2240
+
2241
+ /**
2242
+ * Calculate data maxRate
2243
+ * @param {Number} [samplesCount= 10]
2244
+ * @param {Number} [min= 1000]
2245
+ * @returns {Function}
2246
+ */
2247
+ function speedometer(samplesCount, min) {
2248
+ samplesCount = samplesCount || 10;
2249
+ const bytes = new Array(samplesCount);
2250
+ const timestamps = new Array(samplesCount);
2251
+ let head = 0;
2252
+ let tail = 0;
2253
+ let firstSampleTS;
2254
+
2255
+ min = min !== undefined ? min : 1000;
2256
+
2257
+ return function push(chunkLength) {
2258
+ const now = Date.now();
2259
+
2260
+ const startedAt = timestamps[tail];
2261
+
2262
+ if (!firstSampleTS) {
2263
+ firstSampleTS = now;
2264
+ }
2265
+
2266
+ bytes[head] = chunkLength;
2267
+ timestamps[head] = now;
2268
+
2269
+ let i = tail;
2270
+ let bytesCount = 0;
2271
+
2272
+ while (i !== head) {
2273
+ bytesCount += bytes[i++];
2274
+ i = i % samplesCount;
2275
+ }
2276
+
2277
+ head = (head + 1) % samplesCount;
2278
+
2279
+ if (head === tail) {
2280
+ tail = (tail + 1) % samplesCount;
2281
+ }
2282
+
2283
+ if (now - firstSampleTS < min) {
2284
+ return;
2285
+ }
2286
+
2287
+ const passed = startedAt && now - startedAt;
2288
+
2289
+ return passed ? Math.round(bytesCount * 1000 / passed) : undefined;
2290
+ };
2291
+ }
2292
+
2293
+ /**
2294
+ * Throttle decorator
2295
+ * @param {Function} fn
2296
+ * @param {Number} freq
2297
+ * @return {Function}
2298
+ */
2299
+ function throttle(fn, freq) {
2300
+ let timestamp = 0;
2301
+ let threshold = 1000 / freq;
2302
+ let lastArgs;
2303
+ let timer;
2304
+
2305
+ const invoke = (args, now = Date.now()) => {
2306
+ timestamp = now;
2307
+ lastArgs = null;
2308
+ if (timer) {
2309
+ clearTimeout(timer);
2310
+ timer = null;
2311
+ }
2312
+ fn.apply(null, args);
2313
+ };
2314
+
2315
+ const throttled = (...args) => {
2316
+ const now = Date.now();
2317
+ const passed = now - timestamp;
2318
+ if ( passed >= threshold) {
2319
+ invoke(args, now);
2320
+ } else {
2321
+ lastArgs = args;
2322
+ if (!timer) {
2323
+ timer = setTimeout(() => {
2324
+ timer = null;
2325
+ invoke(lastArgs);
2326
+ }, threshold - passed);
2327
+ }
2328
+ }
2329
+ };
2330
+
2331
+ const flush = () => lastArgs && invoke(lastArgs);
2332
+
2333
+ return [throttled, flush];
2334
+ }
2335
+
2336
+ const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
2337
+ let bytesNotified = 0;
2338
+ const _speedometer = speedometer(50, 250);
2339
+
2340
+ return throttle(e => {
2341
+ const loaded = e.loaded;
2342
+ const total = e.lengthComputable ? e.total : undefined;
2343
+ const progressBytes = loaded - bytesNotified;
2344
+ const rate = _speedometer(progressBytes);
2345
+ const inRange = loaded <= total;
2346
+
2347
+ bytesNotified = loaded;
2348
+
2349
+ const data = {
2350
+ loaded,
2351
+ total,
2352
+ progress: total ? (loaded / total) : undefined,
2353
+ bytes: progressBytes,
2354
+ rate: rate ? rate : undefined,
2355
+ estimated: rate && total && inRange ? (total - loaded) / rate : undefined,
2356
+ event: e,
2357
+ lengthComputable: total != null,
2358
+ [isDownloadStream ? 'download' : 'upload']: true
2359
+ };
2360
+
2361
+ listener(data);
2362
+ }, freq);
2363
+ };
2364
+
2365
+ const progressEventDecorator = (total, throttled) => {
2366
+ const lengthComputable = total != null;
2367
+
2368
+ return [(loaded) => throttled[0]({
2369
+ lengthComputable,
2370
+ total,
2371
+ loaded
2372
+ }), throttled[1]];
2373
+ };
2374
+
2375
+ const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
2376
+
2377
+ var isURLSameOrigin = platform.hasStandardBrowserEnv ? ((origin, isMSIE) => (url) => {
2378
+ url = new URL(url, platform.origin);
2379
+
2380
+ return (
2381
+ origin.protocol === url.protocol &&
2382
+ origin.host === url.host &&
2383
+ (isMSIE || origin.port === url.port)
2384
+ );
2385
+ })(
2386
+ new URL(platform.origin),
2387
+ platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
2388
+ ) : () => true;
2389
+
2390
+ var cookies = platform.hasStandardBrowserEnv ?
2391
+
2392
+ // Standard browser envs support document.cookie
2393
+ {
2394
+ write(name, value, expires, path, domain, secure) {
2395
+ const cookie = [name + '=' + encodeURIComponent(value)];
2396
+
2397
+ utils$1.isNumber(expires) && cookie.push('expires=' + new Date(expires).toGMTString());
2398
+
2399
+ utils$1.isString(path) && cookie.push('path=' + path);
2400
+
2401
+ utils$1.isString(domain) && cookie.push('domain=' + domain);
2402
+
2403
+ secure === true && cookie.push('secure');
2404
+
2405
+ document.cookie = cookie.join('; ');
2406
+ },
2407
+
2408
+ read(name) {
2409
+ const match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
2410
+ return (match ? decodeURIComponent(match[3]) : null);
2411
+ },
2412
+
2413
+ remove(name) {
2414
+ this.write(name, '', Date.now() - 86400000);
2415
+ }
2416
+ }
2417
+
2418
+ :
2419
+
2420
+ // Non-standard browser env (web workers, react-native) lack needed support.
2421
+ {
2422
+ write() {},
2423
+ read() {
2424
+ return null;
2425
+ },
2426
+ remove() {}
2427
+ };
2428
+
2429
+ /**
2430
+ * Determines whether the specified URL is absolute
2431
+ *
2432
+ * @param {string} url The URL to test
2433
+ *
2434
+ * @returns {boolean} True if the specified URL is absolute, otherwise false
2435
+ */
2436
+ function isAbsoluteURL(url) {
2437
+ // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2438
+ // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2439
+ // by any combination of letters, digits, plus, period, or hyphen.
2440
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2441
+ }
2442
+
2443
+ /**
2444
+ * Creates a new URL by combining the specified URLs
2445
+ *
2446
+ * @param {string} baseURL The base URL
2447
+ * @param {string} relativeURL The relative URL
2448
+ *
2449
+ * @returns {string} The combined URL
2450
+ */
2451
+ function combineURLs(baseURL, relativeURL) {
2452
+ return relativeURL
2453
+ ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
2454
+ : baseURL;
2455
+ }
2456
+
2457
+ /**
2458
+ * Creates a new URL by combining the baseURL with the requestedURL,
2459
+ * only when the requestedURL is not already an absolute URL.
2460
+ * If the requestURL is absolute, this function returns the requestedURL untouched.
2461
+ *
2462
+ * @param {string} baseURL The base URL
2463
+ * @param {string} requestedURL Absolute or relative URL to combine
2464
+ *
2465
+ * @returns {string} The combined full path
2466
+ */
2467
+ function buildFullPath(baseURL, requestedURL) {
2468
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
2469
+ return combineURLs(baseURL, requestedURL);
2470
+ }
2471
+ return requestedURL;
2472
+ }
2473
+
2474
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
2475
+
2476
+ /**
2477
+ * Config-specific merge-function which creates a new config-object
2478
+ * by merging two configuration objects together.
2479
+ *
2480
+ * @param {Object} config1
2481
+ * @param {Object} config2
2482
+ *
2483
+ * @returns {Object} New object resulting from merging config2 to config1
2484
+ */
2485
+ function mergeConfig(config1, config2) {
2486
+ // eslint-disable-next-line no-param-reassign
2487
+ config2 = config2 || {};
2488
+ const config = {};
2489
+
2490
+ function getMergedValue(target, source, prop, caseless) {
2491
+ if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
2492
+ return utils$1.merge.call({caseless}, target, source);
2493
+ } else if (utils$1.isPlainObject(source)) {
2494
+ return utils$1.merge({}, source);
2495
+ } else if (utils$1.isArray(source)) {
2496
+ return source.slice();
2497
+ }
2498
+ return source;
2499
+ }
2500
+
2501
+ // eslint-disable-next-line consistent-return
2502
+ function mergeDeepProperties(a, b, prop , caseless) {
2503
+ if (!utils$1.isUndefined(b)) {
2504
+ return getMergedValue(a, b, prop , caseless);
2505
+ } else if (!utils$1.isUndefined(a)) {
2506
+ return getMergedValue(undefined, a, prop , caseless);
2507
+ }
2508
+ }
2509
+
2510
+ // eslint-disable-next-line consistent-return
2511
+ function valueFromConfig2(a, b) {
2512
+ if (!utils$1.isUndefined(b)) {
2513
+ return getMergedValue(undefined, b);
2514
+ }
2515
+ }
2516
+
2517
+ // eslint-disable-next-line consistent-return
2518
+ function defaultToConfig2(a, b) {
2519
+ if (!utils$1.isUndefined(b)) {
2520
+ return getMergedValue(undefined, b);
2521
+ } else if (!utils$1.isUndefined(a)) {
2522
+ return getMergedValue(undefined, a);
2523
+ }
2524
+ }
2525
+
2526
+ // eslint-disable-next-line consistent-return
2527
+ function mergeDirectKeys(a, b, prop) {
2528
+ if (prop in config2) {
2529
+ return getMergedValue(a, b);
2530
+ } else if (prop in config1) {
2531
+ return getMergedValue(undefined, a);
2532
+ }
2533
+ }
2534
+
2535
+ const mergeMap = {
2536
+ url: valueFromConfig2,
2537
+ method: valueFromConfig2,
2538
+ data: valueFromConfig2,
2539
+ baseURL: defaultToConfig2,
2540
+ transformRequest: defaultToConfig2,
2541
+ transformResponse: defaultToConfig2,
2542
+ paramsSerializer: defaultToConfig2,
2543
+ timeout: defaultToConfig2,
2544
+ timeoutMessage: defaultToConfig2,
2545
+ withCredentials: defaultToConfig2,
2546
+ withXSRFToken: defaultToConfig2,
2547
+ adapter: defaultToConfig2,
2548
+ responseType: defaultToConfig2,
2549
+ xsrfCookieName: defaultToConfig2,
2550
+ xsrfHeaderName: defaultToConfig2,
2551
+ onUploadProgress: defaultToConfig2,
2552
+ onDownloadProgress: defaultToConfig2,
2553
+ decompress: defaultToConfig2,
2554
+ maxContentLength: defaultToConfig2,
2555
+ maxBodyLength: defaultToConfig2,
2556
+ beforeRedirect: defaultToConfig2,
2557
+ transport: defaultToConfig2,
2558
+ httpAgent: defaultToConfig2,
2559
+ httpsAgent: defaultToConfig2,
2560
+ cancelToken: defaultToConfig2,
2561
+ socketPath: defaultToConfig2,
2562
+ responseEncoding: defaultToConfig2,
2563
+ validateStatus: mergeDirectKeys,
2564
+ headers: (a, b , prop) => mergeDeepProperties(headersToObject(a), headersToObject(b),prop, true)
2565
+ };
2566
+
2567
+ utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
2568
+ const merge = mergeMap[prop] || mergeDeepProperties;
2569
+ const configValue = merge(config1[prop], config2[prop], prop);
2570
+ (utils$1.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
2571
+ });
2572
+
2573
+ return config;
2574
+ }
2575
+
2576
+ var resolveConfig = (config) => {
2577
+ const newConfig = mergeConfig({}, config);
2578
+
2579
+ let {data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth} = newConfig;
2580
+
2581
+ newConfig.headers = headers = AxiosHeaders.from(headers);
2582
+
2583
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
2584
+
2585
+ // HTTP basic authentication
2586
+ if (auth) {
2587
+ headers.set('Authorization', 'Basic ' +
2588
+ btoa((auth.username || '') + ':' + (auth.password ? unescape(encodeURIComponent(auth.password)) : ''))
2589
+ );
2590
+ }
2591
+
2592
+ let contentType;
2593
+
2594
+ if (utils$1.isFormData(data)) {
2595
+ if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
2596
+ headers.setContentType(undefined); // Let the browser set it
2597
+ } else if ((contentType = headers.getContentType()) !== false) {
2598
+ // fix semicolon duplication issue for ReactNative FormData implementation
2599
+ const [type, ...tokens] = contentType ? contentType.split(';').map(token => token.trim()).filter(Boolean) : [];
2600
+ headers.setContentType([type || 'multipart/form-data', ...tokens].join('; '));
2601
+ }
2602
+ }
2603
+
2604
+ // Add xsrf header
2605
+ // This is only done if running in a standard browser environment.
2606
+ // Specifically not if we're in a web worker, or react-native.
2607
+
2608
+ if (platform.hasStandardBrowserEnv) {
2609
+ withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
2610
+
2611
+ if (withXSRFToken || (withXSRFToken !== false && isURLSameOrigin(newConfig.url))) {
2612
+ // Add xsrf header
2613
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
2614
+
2615
+ if (xsrfValue) {
2616
+ headers.set(xsrfHeaderName, xsrfValue);
2617
+ }
2618
+ }
2619
+ }
2620
+
2621
+ return newConfig;
2622
+ };
2623
+
2624
+ const isXHRAdapterSupported = typeof XMLHttpRequest !== 'undefined';
2625
+
2626
+ var xhrAdapter = isXHRAdapterSupported && function (config) {
2627
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
2628
+ const _config = resolveConfig(config);
2629
+ let requestData = _config.data;
2630
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
2631
+ let {responseType, onUploadProgress, onDownloadProgress} = _config;
2632
+ let onCanceled;
2633
+ let uploadThrottled, downloadThrottled;
2634
+ let flushUpload, flushDownload;
2635
+
2636
+ function done() {
2637
+ flushUpload && flushUpload(); // flush events
2638
+ flushDownload && flushDownload(); // flush events
2639
+
2640
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
2641
+
2642
+ _config.signal && _config.signal.removeEventListener('abort', onCanceled);
2643
+ }
2644
+
2645
+ let request = new XMLHttpRequest();
2646
+
2647
+ request.open(_config.method.toUpperCase(), _config.url, true);
2648
+
2649
+ // Set the request timeout in MS
2650
+ request.timeout = _config.timeout;
2651
+
2652
+ function onloadend() {
2653
+ if (!request) {
2654
+ return;
2655
+ }
2656
+ // Prepare the response
2657
+ const responseHeaders = AxiosHeaders.from(
2658
+ 'getAllResponseHeaders' in request && request.getAllResponseHeaders()
2659
+ );
2660
+ const responseData = !responseType || responseType === 'text' || responseType === 'json' ?
2661
+ request.responseText : request.response;
2662
+ const response = {
2663
+ data: responseData,
2664
+ status: request.status,
2665
+ statusText: request.statusText,
2666
+ headers: responseHeaders,
2667
+ config,
2668
+ request
2669
+ };
2670
+
2671
+ settle(function _resolve(value) {
2672
+ resolve(value);
2673
+ done();
2674
+ }, function _reject(err) {
2675
+ reject(err);
2676
+ done();
2677
+ }, response);
2678
+
2679
+ // Clean up request
2680
+ request = null;
2681
+ }
2682
+
2683
+ if ('onloadend' in request) {
2684
+ // Use onloadend if available
2685
+ request.onloadend = onloadend;
2686
+ } else {
2687
+ // Listen for ready state to emulate onloadend
2688
+ request.onreadystatechange = function handleLoad() {
2689
+ if (!request || request.readyState !== 4) {
2690
+ return;
2691
+ }
2692
+
2693
+ // The request errored out and we didn't get a response, this will be
2694
+ // handled by onerror instead
2695
+ // With one exception: request that using file: protocol, most browsers
2696
+ // will return status as 0 even though it's a successful request
2697
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
2698
+ return;
2699
+ }
2700
+ // readystate handler is calling before onerror or ontimeout handlers,
2701
+ // so we should call onloadend on the next 'tick'
2702
+ setTimeout(onloadend);
2703
+ };
2704
+ }
2705
+
2706
+ // Handle browser request cancellation (as opposed to a manual cancellation)
2707
+ request.onabort = function handleAbort() {
2708
+ if (!request) {
2709
+ return;
2710
+ }
2711
+
2712
+ reject(new AxiosError('Request aborted', AxiosError.ECONNABORTED, config, request));
2713
+
2714
+ // Clean up request
2715
+ request = null;
2716
+ };
2717
+
2718
+ // Handle low level network errors
2719
+ request.onerror = function handleError() {
2720
+ // Real errors are hidden from us by the browser
2721
+ // onerror should only fire if it's a network error
2722
+ reject(new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request));
2723
+
2724
+ // Clean up request
2725
+ request = null;
2726
+ };
2727
+
2728
+ // Handle timeout
2729
+ request.ontimeout = function handleTimeout() {
2730
+ let timeoutErrorMessage = _config.timeout ? 'timeout of ' + _config.timeout + 'ms exceeded' : 'timeout exceeded';
2731
+ const transitional = _config.transitional || transitionalDefaults;
2732
+ if (_config.timeoutErrorMessage) {
2733
+ timeoutErrorMessage = _config.timeoutErrorMessage;
2734
+ }
2735
+ reject(new AxiosError(
2736
+ timeoutErrorMessage,
2737
+ transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
2738
+ config,
2739
+ request));
2740
+
2741
+ // Clean up request
2742
+ request = null;
2743
+ };
2744
+
2745
+ // Remove Content-Type if data is undefined
2746
+ requestData === undefined && requestHeaders.setContentType(null);
2747
+
2748
+ // Add headers to the request
2749
+ if ('setRequestHeader' in request) {
2750
+ utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
2751
+ request.setRequestHeader(key, val);
2752
+ });
2753
+ }
2754
+
2755
+ // Add withCredentials to request if needed
2756
+ if (!utils$1.isUndefined(_config.withCredentials)) {
2757
+ request.withCredentials = !!_config.withCredentials;
2758
+ }
2759
+
2760
+ // Add responseType to request if needed
2761
+ if (responseType && responseType !== 'json') {
2762
+ request.responseType = _config.responseType;
2763
+ }
2764
+
2765
+ // Handle progress if needed
2766
+ if (onDownloadProgress) {
2767
+ ([downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true));
2768
+ request.addEventListener('progress', downloadThrottled);
2769
+ }
2770
+
2771
+ // Not all browsers support upload events
2772
+ if (onUploadProgress && request.upload) {
2773
+ ([uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress));
2774
+
2775
+ request.upload.addEventListener('progress', uploadThrottled);
2776
+
2777
+ request.upload.addEventListener('loadend', flushUpload);
2778
+ }
2779
+
2780
+ if (_config.cancelToken || _config.signal) {
2781
+ // Handle cancellation
2782
+ // eslint-disable-next-line func-names
2783
+ onCanceled = cancel => {
2784
+ if (!request) {
2785
+ return;
2786
+ }
2787
+ reject(!cancel || cancel.type ? new CanceledError(null, config, request) : cancel);
2788
+ request.abort();
2789
+ request = null;
2790
+ };
2791
+
2792
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
2793
+ if (_config.signal) {
2794
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener('abort', onCanceled);
2795
+ }
2796
+ }
2797
+
2798
+ const protocol = parseProtocol(_config.url);
2799
+
2800
+ if (protocol && platform.protocols.indexOf(protocol) === -1) {
2801
+ reject(new AxiosError('Unsupported protocol ' + protocol + ':', AxiosError.ERR_BAD_REQUEST, config));
2802
+ return;
2803
+ }
2804
+
2805
+
2806
+ // Send the request
2807
+ request.send(requestData || null);
2808
+ });
2809
+ };
2810
+
2811
+ const composeSignals = (signals, timeout) => {
2812
+ const {length} = (signals = signals ? signals.filter(Boolean) : []);
2813
+
2814
+ if (timeout || length) {
2815
+ let controller = new AbortController();
2816
+
2817
+ let aborted;
2818
+
2819
+ const onabort = function (reason) {
2820
+ if (!aborted) {
2821
+ aborted = true;
2822
+ unsubscribe();
2823
+ const err = reason instanceof Error ? reason : this.reason;
2824
+ controller.abort(err instanceof AxiosError ? err : new CanceledError(err instanceof Error ? err.message : err));
2825
+ }
2826
+ };
2827
+
2828
+ let timer = timeout && setTimeout(() => {
2829
+ timer = null;
2830
+ onabort(new AxiosError(`timeout ${timeout} of ms exceeded`, AxiosError.ETIMEDOUT));
2831
+ }, timeout);
2832
+
2833
+ const unsubscribe = () => {
2834
+ if (signals) {
2835
+ timer && clearTimeout(timer);
2836
+ timer = null;
2837
+ signals.forEach(signal => {
2838
+ signal.unsubscribe ? signal.unsubscribe(onabort) : signal.removeEventListener('abort', onabort);
2839
+ });
2840
+ signals = null;
2841
+ }
2842
+ };
2843
+
2844
+ signals.forEach((signal) => signal.addEventListener('abort', onabort));
2845
+
2846
+ const {signal} = controller;
2847
+
2848
+ signal.unsubscribe = () => utils$1.asap(unsubscribe);
2849
+
2850
+ return signal;
2851
+ }
2852
+ };
2853
+
2854
+ const streamChunk = function* (chunk, chunkSize) {
2855
+ let len = chunk.byteLength;
2856
+
2857
+ if (len < chunkSize) {
2858
+ yield chunk;
2859
+ return;
2860
+ }
2861
+
2862
+ let pos = 0;
2863
+ let end;
2864
+
2865
+ while (pos < len) {
2866
+ end = pos + chunkSize;
2867
+ yield chunk.slice(pos, end);
2868
+ pos = end;
2869
+ }
2870
+ };
2871
+
2872
+ const readBytes = async function* (iterable, chunkSize) {
2873
+ for await (const chunk of readStream(iterable)) {
2874
+ yield* streamChunk(chunk, chunkSize);
2875
+ }
2876
+ };
2877
+
2878
+ const readStream = async function* (stream) {
2879
+ if (stream[Symbol.asyncIterator]) {
2880
+ yield* stream;
2881
+ return;
2882
+ }
2883
+
2884
+ const reader = stream.getReader();
2885
+ try {
2886
+ for (;;) {
2887
+ const {done, value} = await reader.read();
2888
+ if (done) {
2889
+ break;
2890
+ }
2891
+ yield value;
2892
+ }
2893
+ } finally {
2894
+ await reader.cancel();
2895
+ }
2896
+ };
2897
+
2898
+ const trackStream = (stream, chunkSize, onProgress, onFinish) => {
2899
+ const iterator = readBytes(stream, chunkSize);
2900
+
2901
+ let bytes = 0;
2902
+ let done;
2903
+ let _onFinish = (e) => {
2904
+ if (!done) {
2905
+ done = true;
2906
+ onFinish && onFinish(e);
2907
+ }
2908
+ };
2909
+
2910
+ return new ReadableStream({
2911
+ async pull(controller) {
2912
+ try {
2913
+ const {done, value} = await iterator.next();
2914
+
2915
+ if (done) {
2916
+ _onFinish();
2917
+ controller.close();
2918
+ return;
2919
+ }
2920
+
2921
+ let len = value.byteLength;
2922
+ if (onProgress) {
2923
+ let loadedBytes = bytes += len;
2924
+ onProgress(loadedBytes);
2925
+ }
2926
+ controller.enqueue(new Uint8Array(value));
2927
+ } catch (err) {
2928
+ _onFinish(err);
2929
+ throw err;
2930
+ }
2931
+ },
2932
+ cancel(reason) {
2933
+ _onFinish(reason);
2934
+ return iterator.return();
2935
+ }
2936
+ }, {
2937
+ highWaterMark: 2
2938
+ })
2939
+ };
2940
+
2941
+ const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
2942
+ const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';
2943
+
2944
+ // used only inside the fetch adapter
2945
+ const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
2946
+ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
2947
+ async (str) => new Uint8Array(await new Response(str).arrayBuffer())
2948
+ );
2949
+
2950
+ const test = (fn, ...args) => {
2951
+ try {
2952
+ return !!fn(...args);
2953
+ } catch (e) {
2954
+ return false
2955
+ }
2956
+ };
2957
+
2958
+ const supportsRequestStream = isReadableStreamSupported && test(() => {
2959
+ let duplexAccessed = false;
2960
+
2961
+ const hasContentType = new Request(platform.origin, {
2962
+ body: new ReadableStream(),
2963
+ method: 'POST',
2964
+ get duplex() {
2965
+ duplexAccessed = true;
2966
+ return 'half';
2967
+ },
2968
+ }).headers.has('Content-Type');
2969
+
2970
+ return duplexAccessed && !hasContentType;
2971
+ });
2972
+
2973
+ const DEFAULT_CHUNK_SIZE = 64 * 1024;
2974
+
2975
+ const supportsResponseStream = isReadableStreamSupported &&
2976
+ test(() => utils$1.isReadableStream(new Response('').body));
2977
+
2978
+
2979
+ const resolvers = {
2980
+ stream: supportsResponseStream && ((res) => res.body)
2981
+ };
2982
+
2983
+ isFetchSupported && (((res) => {
2984
+ ['text', 'arrayBuffer', 'blob', 'formData', 'stream'].forEach(type => {
2985
+ !resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res) => res[type]() :
2986
+ (_, config) => {
2987
+ throw new AxiosError(`Response type '${type}' is not supported`, AxiosError.ERR_NOT_SUPPORT, config);
2988
+ });
2989
+ });
2990
+ })(new Response));
2991
+
2992
+ const getBodyLength = async (body) => {
2993
+ if (body == null) {
2994
+ return 0;
2995
+ }
2996
+
2997
+ if(utils$1.isBlob(body)) {
2998
+ return body.size;
2999
+ }
3000
+
3001
+ if(utils$1.isSpecCompliantForm(body)) {
3002
+ const _request = new Request(platform.origin, {
3003
+ method: 'POST',
3004
+ body,
3005
+ });
3006
+ return (await _request.arrayBuffer()).byteLength;
3007
+ }
3008
+
3009
+ if(utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
3010
+ return body.byteLength;
3011
+ }
3012
+
3013
+ if(utils$1.isURLSearchParams(body)) {
3014
+ body = body + '';
3015
+ }
3016
+
3017
+ if(utils$1.isString(body)) {
3018
+ return (await encodeText(body)).byteLength;
3019
+ }
3020
+ };
3021
+
3022
+ const resolveBodyLength = async (headers, body) => {
3023
+ const length = utils$1.toFiniteNumber(headers.getContentLength());
3024
+
3025
+ return length == null ? getBodyLength(body) : length;
3026
+ };
3027
+
3028
+ var fetchAdapter = isFetchSupported && (async (config) => {
3029
+ let {
3030
+ url,
3031
+ method,
3032
+ data,
3033
+ signal,
3034
+ cancelToken,
3035
+ timeout,
3036
+ onDownloadProgress,
3037
+ onUploadProgress,
3038
+ responseType,
3039
+ headers,
3040
+ withCredentials = 'same-origin',
3041
+ fetchOptions
3042
+ } = resolveConfig(config);
3043
+
3044
+ responseType = responseType ? (responseType + '').toLowerCase() : 'text';
3045
+
3046
+ let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
3047
+
3048
+ let request;
3049
+
3050
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
3051
+ composedSignal.unsubscribe();
3052
+ });
3053
+
3054
+ let requestContentLength;
3055
+
3056
+ try {
3057
+ if (
3058
+ onUploadProgress && supportsRequestStream && method !== 'get' && method !== 'head' &&
3059
+ (requestContentLength = await resolveBodyLength(headers, data)) !== 0
3060
+ ) {
3061
+ let _request = new Request(url, {
3062
+ method: 'POST',
3063
+ body: data,
3064
+ duplex: "half"
3065
+ });
3066
+
3067
+ let contentTypeHeader;
3068
+
3069
+ if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
3070
+ headers.setContentType(contentTypeHeader);
3071
+ }
3072
+
3073
+ if (_request.body) {
3074
+ const [onProgress, flush] = progressEventDecorator(
3075
+ requestContentLength,
3076
+ progressEventReducer(asyncDecorator(onUploadProgress))
3077
+ );
3078
+
3079
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
3080
+ }
3081
+ }
3082
+
3083
+ if (!utils$1.isString(withCredentials)) {
3084
+ withCredentials = withCredentials ? 'include' : 'omit';
3085
+ }
3086
+
3087
+ // Cloudflare Workers throws when credentials are defined
3088
+ // see https://github.com/cloudflare/workerd/issues/902
3089
+ const isCredentialsSupported = "credentials" in Request.prototype;
3090
+ request = new Request(url, {
3091
+ ...fetchOptions,
3092
+ signal: composedSignal,
3093
+ method: method.toUpperCase(),
3094
+ headers: headers.normalize().toJSON(),
3095
+ body: data,
3096
+ duplex: "half",
3097
+ credentials: isCredentialsSupported ? withCredentials : undefined
3098
+ });
3099
+
3100
+ let response = await fetch(request);
3101
+
3102
+ const isStreamResponse = supportsResponseStream && (responseType === 'stream' || responseType === 'response');
3103
+
3104
+ if (supportsResponseStream && (onDownloadProgress || (isStreamResponse && unsubscribe))) {
3105
+ const options = {};
3106
+
3107
+ ['status', 'statusText', 'headers'].forEach(prop => {
3108
+ options[prop] = response[prop];
3109
+ });
3110
+
3111
+ const responseContentLength = utils$1.toFiniteNumber(response.headers.get('content-length'));
3112
+
3113
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
3114
+ responseContentLength,
3115
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
3116
+ ) || [];
3117
+
3118
+ response = new Response(
3119
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
3120
+ flush && flush();
3121
+ unsubscribe && unsubscribe();
3122
+ }),
3123
+ options
3124
+ );
3125
+ }
3126
+
3127
+ responseType = responseType || 'text';
3128
+
3129
+ let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || 'text'](response, config);
3130
+
3131
+ !isStreamResponse && unsubscribe && unsubscribe();
3132
+
3133
+ return await new Promise((resolve, reject) => {
3134
+ settle(resolve, reject, {
3135
+ data: responseData,
3136
+ headers: AxiosHeaders.from(response.headers),
3137
+ status: response.status,
3138
+ statusText: response.statusText,
3139
+ config,
3140
+ request
3141
+ });
3142
+ })
3143
+ } catch (err) {
3144
+ unsubscribe && unsubscribe();
3145
+
3146
+ if (err && err.name === 'TypeError' && /fetch/i.test(err.message)) {
3147
+ throw Object.assign(
3148
+ new AxiosError('Network Error', AxiosError.ERR_NETWORK, config, request),
3149
+ {
3150
+ cause: err.cause || err
3151
+ }
3152
+ )
3153
+ }
3154
+
3155
+ throw AxiosError.from(err, err && err.code, config, request);
3156
+ }
3157
+ });
3158
+
3159
+ const knownAdapters = {
3160
+ http: httpAdapter,
3161
+ xhr: xhrAdapter,
3162
+ fetch: fetchAdapter
3163
+ };
3164
+
3165
+ utils$1.forEach(knownAdapters, (fn, value) => {
3166
+ if (fn) {
3167
+ try {
3168
+ Object.defineProperty(fn, 'name', {value});
3169
+ } catch (e) {
3170
+ // eslint-disable-next-line no-empty
3171
+ }
3172
+ Object.defineProperty(fn, 'adapterName', {value});
3173
+ }
3174
+ });
3175
+
3176
+ const renderReason = (reason) => `- ${reason}`;
3177
+
3178
+ const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
3179
+
3180
+ var adapters = {
3181
+ getAdapter: (adapters) => {
3182
+ adapters = utils$1.isArray(adapters) ? adapters : [adapters];
3183
+
3184
+ const {length} = adapters;
3185
+ let nameOrAdapter;
3186
+ let adapter;
3187
+
3188
+ const rejectedReasons = {};
3189
+
3190
+ for (let i = 0; i < length; i++) {
3191
+ nameOrAdapter = adapters[i];
3192
+ let id;
3193
+
3194
+ adapter = nameOrAdapter;
3195
+
3196
+ if (!isResolvedHandle(nameOrAdapter)) {
3197
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
3198
+
3199
+ if (adapter === undefined) {
3200
+ throw new AxiosError(`Unknown adapter '${id}'`);
3201
+ }
3202
+ }
3203
+
3204
+ if (adapter) {
3205
+ break;
3206
+ }
3207
+
3208
+ rejectedReasons[id || '#' + i] = adapter;
3209
+ }
3210
+
3211
+ if (!adapter) {
3212
+
3213
+ const reasons = Object.entries(rejectedReasons)
3214
+ .map(([id, state]) => `adapter ${id} ` +
3215
+ (state === false ? 'is not supported by the environment' : 'is not available in the build')
3216
+ );
3217
+
3218
+ let s = length ?
3219
+ (reasons.length > 1 ? 'since :\n' + reasons.map(renderReason).join('\n') : ' ' + renderReason(reasons[0])) :
3220
+ 'as no adapter specified';
3221
+
3222
+ throw new AxiosError(
3223
+ `There is no suitable adapter to dispatch the request ` + s,
3224
+ 'ERR_NOT_SUPPORT'
3225
+ );
3226
+ }
3227
+
3228
+ return adapter;
3229
+ },
3230
+ adapters: knownAdapters
3231
+ };
3232
+
3233
+ /**
3234
+ * Throws a `CanceledError` if cancellation has been requested.
3235
+ *
3236
+ * @param {Object} config The config that is to be used for the request
3237
+ *
3238
+ * @returns {void}
3239
+ */
3240
+ function throwIfCancellationRequested(config) {
3241
+ if (config.cancelToken) {
3242
+ config.cancelToken.throwIfRequested();
3243
+ }
3244
+
3245
+ if (config.signal && config.signal.aborted) {
3246
+ throw new CanceledError(null, config);
3247
+ }
3248
+ }
3249
+
3250
+ /**
3251
+ * Dispatch a request to the server using the configured adapter.
3252
+ *
3253
+ * @param {object} config The config that is to be used for the request
3254
+ *
3255
+ * @returns {Promise} The Promise to be fulfilled
3256
+ */
3257
+ function dispatchRequest(config) {
3258
+ throwIfCancellationRequested(config);
3259
+
3260
+ config.headers = AxiosHeaders.from(config.headers);
3261
+
3262
+ // Transform request data
3263
+ config.data = transformData.call(
3264
+ config,
3265
+ config.transformRequest
3266
+ );
3267
+
3268
+ if (['post', 'put', 'patch'].indexOf(config.method) !== -1) {
3269
+ config.headers.setContentType('application/x-www-form-urlencoded', false);
3270
+ }
3271
+
3272
+ const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
3273
+
3274
+ return adapter(config).then(function onAdapterResolution(response) {
3275
+ throwIfCancellationRequested(config);
3276
+
3277
+ // Transform response data
3278
+ response.data = transformData.call(
3279
+ config,
3280
+ config.transformResponse,
3281
+ response
3282
+ );
3283
+
3284
+ response.headers = AxiosHeaders.from(response.headers);
3285
+
3286
+ return response;
3287
+ }, function onAdapterRejection(reason) {
3288
+ if (!isCancel(reason)) {
3289
+ throwIfCancellationRequested(config);
3290
+
3291
+ // Transform response data
3292
+ if (reason && reason.response) {
3293
+ reason.response.data = transformData.call(
3294
+ config,
3295
+ config.transformResponse,
3296
+ reason.response
3297
+ );
3298
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
3299
+ }
3300
+ }
3301
+
3302
+ return Promise.reject(reason);
3303
+ });
3304
+ }
3305
+
3306
+ const VERSION = "1.7.9";
3307
+
3308
+ const validators$1 = {};
3309
+
3310
+ // eslint-disable-next-line func-names
3311
+ ['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach((type, i) => {
3312
+ validators$1[type] = function validator(thing) {
3313
+ return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
3314
+ };
3315
+ });
3316
+
3317
+ const deprecatedWarnings = {};
3318
+
3319
+ /**
3320
+ * Transitional option validator
3321
+ *
3322
+ * @param {function|boolean?} validator - set to false if the transitional option has been removed
3323
+ * @param {string?} version - deprecated version / removed since version
3324
+ * @param {string?} message - some message with additional info
3325
+ *
3326
+ * @returns {function}
3327
+ */
3328
+ validators$1.transitional = function transitional(validator, version, message) {
3329
+ function formatMessage(opt, desc) {
3330
+ return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3331
+ }
3332
+
3333
+ // eslint-disable-next-line func-names
3334
+ return (value, opt, opts) => {
3335
+ if (validator === false) {
3336
+ throw new AxiosError(
3337
+ formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')),
3338
+ AxiosError.ERR_DEPRECATED
3339
+ );
3340
+ }
3341
+
3342
+ if (version && !deprecatedWarnings[opt]) {
3343
+ deprecatedWarnings[opt] = true;
3344
+ // eslint-disable-next-line no-console
3345
+ console.warn(
3346
+ formatMessage(
3347
+ opt,
3348
+ ' has been deprecated since v' + version + ' and will be removed in the near future'
3349
+ )
3350
+ );
3351
+ }
3352
+
3353
+ return validator ? validator(value, opt, opts) : true;
3354
+ };
3355
+ };
3356
+
3357
+ validators$1.spelling = function spelling(correctSpelling) {
3358
+ return (value, opt) => {
3359
+ // eslint-disable-next-line no-console
3360
+ console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
3361
+ return true;
3362
+ }
3363
+ };
3364
+
3365
+ /**
3366
+ * Assert object's properties type
3367
+ *
3368
+ * @param {object} options
3369
+ * @param {object} schema
3370
+ * @param {boolean?} allowUnknown
3371
+ *
3372
+ * @returns {object}
3373
+ */
3374
+
3375
+ function assertOptions(options, schema, allowUnknown) {
3376
+ if (typeof options !== 'object') {
3377
+ throw new AxiosError('options must be an object', AxiosError.ERR_BAD_OPTION_VALUE);
3378
+ }
3379
+ const keys = Object.keys(options);
3380
+ let i = keys.length;
3381
+ while (i-- > 0) {
3382
+ const opt = keys[i];
3383
+ const validator = schema[opt];
3384
+ if (validator) {
3385
+ const value = options[opt];
3386
+ const result = value === undefined || validator(value, opt, options);
3387
+ if (result !== true) {
3388
+ throw new AxiosError('option ' + opt + ' must be ' + result, AxiosError.ERR_BAD_OPTION_VALUE);
3389
+ }
3390
+ continue;
3391
+ }
3392
+ if (allowUnknown !== true) {
3393
+ throw new AxiosError('Unknown option ' + opt, AxiosError.ERR_BAD_OPTION);
3394
+ }
3395
+ }
3396
+ }
3397
+
3398
+ var validator = {
3399
+ assertOptions,
3400
+ validators: validators$1
3401
+ };
3402
+
3403
+ const validators = validator.validators;
3404
+
3405
+ /**
3406
+ * Create a new instance of Axios
3407
+ *
3408
+ * @param {Object} instanceConfig The default config for the instance
3409
+ *
3410
+ * @return {Axios} A new instance of Axios
3411
+ */
3412
+ class Axios {
3413
+ constructor(instanceConfig) {
3414
+ this.defaults = instanceConfig;
3415
+ this.interceptors = {
3416
+ request: new InterceptorManager(),
3417
+ response: new InterceptorManager()
3418
+ };
3419
+ }
3420
+
3421
+ /**
3422
+ * Dispatch a request
3423
+ *
3424
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
3425
+ * @param {?Object} config
3426
+ *
3427
+ * @returns {Promise} The Promise to be fulfilled
3428
+ */
3429
+ async request(configOrUrl, config) {
3430
+ try {
3431
+ return await this._request(configOrUrl, config);
3432
+ } catch (err) {
3433
+ if (err instanceof Error) {
3434
+ let dummy = {};
3435
+
3436
+ Error.captureStackTrace ? Error.captureStackTrace(dummy) : (dummy = new Error());
3437
+
3438
+ // slice off the Error: ... line
3439
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, '') : '';
3440
+ try {
3441
+ if (!err.stack) {
3442
+ err.stack = stack;
3443
+ // match without the 2 top stack lines
3444
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ''))) {
3445
+ err.stack += '\n' + stack;
3446
+ }
3447
+ } catch (e) {
3448
+ // ignore the case where "stack" is an un-writable property
3449
+ }
3450
+ }
3451
+
3452
+ throw err;
3453
+ }
3454
+ }
3455
+
3456
+ _request(configOrUrl, config) {
3457
+ /*eslint no-param-reassign:0*/
3458
+ // Allow for axios('example/url'[, config]) a la fetch API
3459
+ if (typeof configOrUrl === 'string') {
3460
+ config = config || {};
3461
+ config.url = configOrUrl;
3462
+ } else {
3463
+ config = configOrUrl || {};
3464
+ }
3465
+
3466
+ config = mergeConfig(this.defaults, config);
3467
+
3468
+ const {transitional, paramsSerializer, headers} = config;
3469
+
3470
+ if (transitional !== undefined) {
3471
+ validator.assertOptions(transitional, {
3472
+ silentJSONParsing: validators.transitional(validators.boolean),
3473
+ forcedJSONParsing: validators.transitional(validators.boolean),
3474
+ clarifyTimeoutError: validators.transitional(validators.boolean)
3475
+ }, false);
3476
+ }
3477
+
3478
+ if (paramsSerializer != null) {
3479
+ if (utils$1.isFunction(paramsSerializer)) {
3480
+ config.paramsSerializer = {
3481
+ serialize: paramsSerializer
3482
+ };
3483
+ } else {
3484
+ validator.assertOptions(paramsSerializer, {
3485
+ encode: validators.function,
3486
+ serialize: validators.function
3487
+ }, true);
3488
+ }
3489
+ }
3490
+
3491
+ validator.assertOptions(config, {
3492
+ baseUrl: validators.spelling('baseURL'),
3493
+ withXsrfToken: validators.spelling('withXSRFToken')
3494
+ }, true);
3495
+
3496
+ // Set config.method
3497
+ config.method = (config.method || this.defaults.method || 'get').toLowerCase();
3498
+
3499
+ // Flatten headers
3500
+ let contextHeaders = headers && utils$1.merge(
3501
+ headers.common,
3502
+ headers[config.method]
3503
+ );
3504
+
3505
+ headers && utils$1.forEach(
3506
+ ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
3507
+ (method) => {
3508
+ delete headers[method];
3509
+ }
3510
+ );
3511
+
3512
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
3513
+
3514
+ // filter out skipped interceptors
3515
+ const requestInterceptorChain = [];
3516
+ let synchronousRequestInterceptors = true;
3517
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
3518
+ if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
3519
+ return;
3520
+ }
3521
+
3522
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3523
+
3524
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3525
+ });
3526
+
3527
+ const responseInterceptorChain = [];
3528
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
3529
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3530
+ });
3531
+
3532
+ let promise;
3533
+ let i = 0;
3534
+ let len;
3535
+
3536
+ if (!synchronousRequestInterceptors) {
3537
+ const chain = [dispatchRequest.bind(this), undefined];
3538
+ chain.unshift.apply(chain, requestInterceptorChain);
3539
+ chain.push.apply(chain, responseInterceptorChain);
3540
+ len = chain.length;
3541
+
3542
+ promise = Promise.resolve(config);
3543
+
3544
+ while (i < len) {
3545
+ promise = promise.then(chain[i++], chain[i++]);
3546
+ }
3547
+
3548
+ return promise;
3549
+ }
3550
+
3551
+ len = requestInterceptorChain.length;
3552
+
3553
+ let newConfig = config;
3554
+
3555
+ i = 0;
3556
+
3557
+ while (i < len) {
3558
+ const onFulfilled = requestInterceptorChain[i++];
3559
+ const onRejected = requestInterceptorChain[i++];
3560
+ try {
3561
+ newConfig = onFulfilled(newConfig);
3562
+ } catch (error) {
3563
+ onRejected.call(this, error);
3564
+ break;
3565
+ }
3566
+ }
3567
+
3568
+ try {
3569
+ promise = dispatchRequest.call(this, newConfig);
3570
+ } catch (error) {
3571
+ return Promise.reject(error);
3572
+ }
3573
+
3574
+ i = 0;
3575
+ len = responseInterceptorChain.length;
3576
+
3577
+ while (i < len) {
3578
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
3579
+ }
3580
+
3581
+ return promise;
3582
+ }
3583
+
3584
+ getUri(config) {
3585
+ config = mergeConfig(this.defaults, config);
3586
+ const fullPath = buildFullPath(config.baseURL, config.url);
3587
+ return buildURL(fullPath, config.params, config.paramsSerializer);
3588
+ }
3589
+ }
3590
+
3591
+ // Provide aliases for supported request methods
3592
+ utils$1.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
3593
+ /*eslint func-names:0*/
3594
+ Axios.prototype[method] = function(url, config) {
3595
+ return this.request(mergeConfig(config || {}, {
3596
+ method,
3597
+ url,
3598
+ data: (config || {}).data
3599
+ }));
3600
+ };
3601
+ });
3602
+
3603
+ utils$1.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
3604
+ /*eslint func-names:0*/
3605
+
3606
+ function generateHTTPMethod(isForm) {
3607
+ return function httpMethod(url, data, config) {
3608
+ return this.request(mergeConfig(config || {}, {
3609
+ method,
3610
+ headers: isForm ? {
3611
+ 'Content-Type': 'multipart/form-data'
3612
+ } : {},
3613
+ url,
3614
+ data
3615
+ }));
3616
+ };
3617
+ }
3618
+
3619
+ Axios.prototype[method] = generateHTTPMethod();
3620
+
3621
+ Axios.prototype[method + 'Form'] = generateHTTPMethod(true);
3622
+ });
3623
+
3624
+ /**
3625
+ * A `CancelToken` is an object that can be used to request cancellation of an operation.
3626
+ *
3627
+ * @param {Function} executor The executor function.
3628
+ *
3629
+ * @returns {CancelToken}
3630
+ */
3631
+ class CancelToken {
3632
+ constructor(executor) {
3633
+ if (typeof executor !== 'function') {
3634
+ throw new TypeError('executor must be a function.');
3635
+ }
3636
+
3637
+ let resolvePromise;
3638
+
3639
+ this.promise = new Promise(function promiseExecutor(resolve) {
3640
+ resolvePromise = resolve;
3641
+ });
3642
+
3643
+ const token = this;
3644
+
3645
+ // eslint-disable-next-line func-names
3646
+ this.promise.then(cancel => {
3647
+ if (!token._listeners) return;
3648
+
3649
+ let i = token._listeners.length;
3650
+
3651
+ while (i-- > 0) {
3652
+ token._listeners[i](cancel);
3653
+ }
3654
+ token._listeners = null;
3655
+ });
3656
+
3657
+ // eslint-disable-next-line func-names
3658
+ this.promise.then = onfulfilled => {
3659
+ let _resolve;
3660
+ // eslint-disable-next-line func-names
3661
+ const promise = new Promise(resolve => {
3662
+ token.subscribe(resolve);
3663
+ _resolve = resolve;
3664
+ }).then(onfulfilled);
3665
+
3666
+ promise.cancel = function reject() {
3667
+ token.unsubscribe(_resolve);
3668
+ };
3669
+
3670
+ return promise;
3671
+ };
3672
+
3673
+ executor(function cancel(message, config, request) {
3674
+ if (token.reason) {
3675
+ // Cancellation has already been requested
3676
+ return;
3677
+ }
3678
+
3679
+ token.reason = new CanceledError(message, config, request);
3680
+ resolvePromise(token.reason);
3681
+ });
3682
+ }
3683
+
3684
+ /**
3685
+ * Throws a `CanceledError` if cancellation has been requested.
3686
+ */
3687
+ throwIfRequested() {
3688
+ if (this.reason) {
3689
+ throw this.reason;
3690
+ }
3691
+ }
3692
+
3693
+ /**
3694
+ * Subscribe to the cancel signal
3695
+ */
3696
+
3697
+ subscribe(listener) {
3698
+ if (this.reason) {
3699
+ listener(this.reason);
3700
+ return;
3701
+ }
3702
+
3703
+ if (this._listeners) {
3704
+ this._listeners.push(listener);
3705
+ } else {
3706
+ this._listeners = [listener];
3707
+ }
3708
+ }
3709
+
3710
+ /**
3711
+ * Unsubscribe from the cancel signal
3712
+ */
3713
+
3714
+ unsubscribe(listener) {
3715
+ if (!this._listeners) {
3716
+ return;
3717
+ }
3718
+ const index = this._listeners.indexOf(listener);
3719
+ if (index !== -1) {
3720
+ this._listeners.splice(index, 1);
3721
+ }
3722
+ }
3723
+
3724
+ toAbortSignal() {
3725
+ const controller = new AbortController();
3726
+
3727
+ const abort = (err) => {
3728
+ controller.abort(err);
3729
+ };
3730
+
3731
+ this.subscribe(abort);
3732
+
3733
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
3734
+
3735
+ return controller.signal;
3736
+ }
3737
+
3738
+ /**
3739
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
3740
+ * cancels the `CancelToken`.
3741
+ */
3742
+ static source() {
3743
+ let cancel;
3744
+ const token = new CancelToken(function executor(c) {
3745
+ cancel = c;
3746
+ });
3747
+ return {
3748
+ token,
3749
+ cancel
3750
+ };
3751
+ }
3752
+ }
3753
+
3754
+ /**
3755
+ * Syntactic sugar for invoking a function and expanding an array for arguments.
3756
+ *
3757
+ * Common use case would be to use `Function.prototype.apply`.
3758
+ *
3759
+ * ```js
3760
+ * function f(x, y, z) {}
3761
+ * var args = [1, 2, 3];
3762
+ * f.apply(null, args);
3763
+ * ```
3764
+ *
3765
+ * With `spread` this example can be re-written.
3766
+ *
3767
+ * ```js
3768
+ * spread(function(x, y, z) {})([1, 2, 3]);
3769
+ * ```
3770
+ *
3771
+ * @param {Function} callback
3772
+ *
3773
+ * @returns {Function}
3774
+ */
3775
+ function spread(callback) {
3776
+ return function wrap(arr) {
3777
+ return callback.apply(null, arr);
3778
+ };
3779
+ }
3780
+
3781
+ /**
3782
+ * Determines whether the payload is an error thrown by Axios
3783
+ *
3784
+ * @param {*} payload The value to test
3785
+ *
3786
+ * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
3787
+ */
3788
+ function isAxiosError(payload) {
3789
+ return utils$1.isObject(payload) && (payload.isAxiosError === true);
3790
+ }
3791
+
3792
+ const HttpStatusCode = {
3793
+ Continue: 100,
3794
+ SwitchingProtocols: 101,
3795
+ Processing: 102,
3796
+ EarlyHints: 103,
3797
+ Ok: 200,
3798
+ Created: 201,
3799
+ Accepted: 202,
3800
+ NonAuthoritativeInformation: 203,
3801
+ NoContent: 204,
3802
+ ResetContent: 205,
3803
+ PartialContent: 206,
3804
+ MultiStatus: 207,
3805
+ AlreadyReported: 208,
3806
+ ImUsed: 226,
3807
+ MultipleChoices: 300,
3808
+ MovedPermanently: 301,
3809
+ Found: 302,
3810
+ SeeOther: 303,
3811
+ NotModified: 304,
3812
+ UseProxy: 305,
3813
+ Unused: 306,
3814
+ TemporaryRedirect: 307,
3815
+ PermanentRedirect: 308,
3816
+ BadRequest: 400,
3817
+ Unauthorized: 401,
3818
+ PaymentRequired: 402,
3819
+ Forbidden: 403,
3820
+ NotFound: 404,
3821
+ MethodNotAllowed: 405,
3822
+ NotAcceptable: 406,
3823
+ ProxyAuthenticationRequired: 407,
3824
+ RequestTimeout: 408,
3825
+ Conflict: 409,
3826
+ Gone: 410,
3827
+ LengthRequired: 411,
3828
+ PreconditionFailed: 412,
3829
+ PayloadTooLarge: 413,
3830
+ UriTooLong: 414,
3831
+ UnsupportedMediaType: 415,
3832
+ RangeNotSatisfiable: 416,
3833
+ ExpectationFailed: 417,
3834
+ ImATeapot: 418,
3835
+ MisdirectedRequest: 421,
3836
+ UnprocessableEntity: 422,
3837
+ Locked: 423,
3838
+ FailedDependency: 424,
3839
+ TooEarly: 425,
3840
+ UpgradeRequired: 426,
3841
+ PreconditionRequired: 428,
3842
+ TooManyRequests: 429,
3843
+ RequestHeaderFieldsTooLarge: 431,
3844
+ UnavailableForLegalReasons: 451,
3845
+ InternalServerError: 500,
3846
+ NotImplemented: 501,
3847
+ BadGateway: 502,
3848
+ ServiceUnavailable: 503,
3849
+ GatewayTimeout: 504,
3850
+ HttpVersionNotSupported: 505,
3851
+ VariantAlsoNegotiates: 506,
3852
+ InsufficientStorage: 507,
3853
+ LoopDetected: 508,
3854
+ NotExtended: 510,
3855
+ NetworkAuthenticationRequired: 511,
3856
+ };
3857
+
3858
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
3859
+ HttpStatusCode[value] = key;
3860
+ });
3861
+
3862
+ /**
3863
+ * Create an instance of Axios
3864
+ *
3865
+ * @param {Object} defaultConfig The default config for the instance
3866
+ *
3867
+ * @returns {Axios} A new instance of Axios
3868
+ */
3869
+ function createInstance(defaultConfig) {
3870
+ const context = new Axios(defaultConfig);
3871
+ const instance = bind(Axios.prototype.request, context);
3872
+
3873
+ // Copy axios.prototype to instance
3874
+ utils$1.extend(instance, Axios.prototype, context, {allOwnKeys: true});
3875
+
3876
+ // Copy context to instance
3877
+ utils$1.extend(instance, context, null, {allOwnKeys: true});
3878
+
3879
+ // Factory for creating new instances
3880
+ instance.create = function create(instanceConfig) {
3881
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
3882
+ };
3883
+
3884
+ return instance;
3885
+ }
3886
+
3887
+ // Create the default instance to be exported
3888
+ const axios = createInstance(defaults);
3889
+
3890
+ // Expose Axios class to allow class inheritance
3891
+ axios.Axios = Axios;
3892
+
3893
+ // Expose Cancel & CancelToken
3894
+ axios.CanceledError = CanceledError;
3895
+ axios.CancelToken = CancelToken;
3896
+ axios.isCancel = isCancel;
3897
+ axios.VERSION = VERSION;
3898
+ axios.toFormData = toFormData;
3899
+
3900
+ // Expose AxiosError class
3901
+ axios.AxiosError = AxiosError;
3902
+
3903
+ // alias for CanceledError for backward compatibility
3904
+ axios.Cancel = axios.CanceledError;
3905
+
3906
+ // Expose all/spread
3907
+ axios.all = function all(promises) {
3908
+ return Promise.all(promises);
3909
+ };
3910
+
3911
+ axios.spread = spread;
3912
+
3913
+ // Expose isAxiosError
3914
+ axios.isAxiosError = isAxiosError;
3915
+
3916
+ // Expose mergeConfig
3917
+ axios.mergeConfig = mergeConfig;
3918
+
3919
+ axios.AxiosHeaders = AxiosHeaders;
3920
+
3921
+ axios.formToJSON = thing => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
3922
+
3923
+ axios.getAdapter = adapters.getAdapter;
3924
+
3925
+ axios.HttpStatusCode = HttpStatusCode;
3926
+
3927
+ axios.default = axios;
3928
+
3929
+ var handleApiCall = function (url, method, body, customHeaders) { return __awaiter(undefined, undefined, undefined, function () {
3930
+ var options, response;
3931
+ return __generator(this, function (_a) {
3932
+ switch (_a.label) {
3933
+ case 0:
3934
+ options = {
3935
+ method: method,
3936
+ headers: __assign({ "content-type": "application/json" }, customHeaders),
3937
+ data: body && body,
3938
+ url: "https://vendor-api.kudi.ai/v1".concat(url),
3939
+ };
3940
+ return [4 /*yield*/, axios(options)];
3941
+ case 1:
3942
+ response = _a.sent();
3943
+ return [2 /*return*/, response];
3944
+ }
3945
+ });
3946
+ }); };
3947
+
3948
+ var useGetOrder = function (orderReference) { return __awaiter(undefined, undefined, undefined, function () {
3949
+ var response, error_1;
3950
+ return __generator(this, function (_a) {
3951
+ switch (_a.label) {
3952
+ case 0:
3953
+ _a.trys.push([0, 2, , 3]);
3954
+ return [4 /*yield*/, handleApiCall("/checkout/order/".concat(orderReference), "GET")];
3955
+ case 1:
3956
+ response = _a.sent();
3957
+ return [2 /*return*/, response.data];
3958
+ case 2:
3959
+ error_1 = _a.sent();
3960
+ return [2 /*return*/, error_1];
3961
+ case 3: return [2 /*return*/];
3962
+ }
3963
+ });
3964
+ }); };
3965
+
3966
+ var useCardCheckout = function (payload) { return __awaiter(undefined, undefined, undefined, function () {
3967
+ var response, error_1;
3968
+ return __generator(this, function (_a) {
3969
+ switch (_a.label) {
3970
+ case 0:
3971
+ _a.trys.push([0, 2, , 3]);
3972
+ return [4 /*yield*/, handleApiCall("/checkout/checkout-card-detail", "POST", __assign(__assign({}, payload), { key: "", deviceInformation: {
3973
+ httpBrowserLanguage: navigator.language,
3974
+ httpBrowserJavaEnabled: "true",
3975
+ httpBrowserJavaScriptEnabled: "true",
3976
+ httpBrowserColorDepth: window.screen.colorDepth.toString(),
3977
+ httpBrowserScreenHeight: window.screen.height.toString(),
3978
+ httpBrowserScreenWidth: window.screen.width.toString(),
3979
+ httpBrowserTimeDifference: new Date().getTimezoneOffset().toString(),
3980
+ userAgentBrowserValue: navigator.userAgent,
3981
+ deviceChannel: "Browser",
3982
+ } }))];
3983
+ case 1:
3984
+ response = _a.sent();
3985
+ return [2 /*return*/, response.data];
3986
+ case 2:
3987
+ error_1 = _a.sent();
3988
+ return [2 /*return*/, error_1];
3989
+ case 3: return [2 /*return*/];
3990
+ }
3991
+ });
3992
+ }); };
3993
+
3994
+ var useCardCheckoutOtp = function (payload) { return __awaiter(undefined, undefined, undefined, function () {
3995
+ var response, error_1;
3996
+ return __generator(this, function (_a) {
3997
+ switch (_a.label) {
3998
+ case 0:
3999
+ _a.trys.push([0, 2, , 3]);
4000
+ return [4 /*yield*/, handleApiCall("/checkout/checkout-card-otp", "POST", payload)];
4001
+ case 1:
4002
+ response = _a.sent();
4003
+ return [2 /*return*/, response.data];
4004
+ case 2:
4005
+ error_1 = _a.sent();
4006
+ return [2 /*return*/, error_1];
4007
+ case 3: return [2 /*return*/];
4008
+ }
4009
+ });
4010
+ }); };
4011
+
4012
+ var useGenerateQrCode = function (orderReference) { return __awaiter(undefined, undefined, undefined, function () {
4013
+ var response, error_1;
4014
+ return __generator(this, function (_a) {
4015
+ switch (_a.label) {
4016
+ case 0:
4017
+ _a.trys.push([0, 2, , 3]);
4018
+ return [4 /*yield*/, handleApiCall("/checkout/qr/".concat(orderReference), "GET")];
4019
+ case 1:
4020
+ response = _a.sent();
4021
+ return [2 /*return*/, response.data];
4022
+ case 2:
4023
+ error_1 = _a.sent();
4024
+ return [2 /*return*/, error_1];
4025
+ case 3: return [2 /*return*/];
4026
+ }
4027
+ });
4028
+ }); };
4029
+
4030
+ var useVerifyOrderStatus = function (orderReference) { return __awaiter(undefined, undefined, undefined, function () {
4031
+ var response, error_1;
4032
+ return __generator(this, function (_a) {
4033
+ switch (_a.label) {
4034
+ case 0:
4035
+ _a.trys.push([0, 2, , 3]);
4036
+ return [4 /*yield*/, handleApiCall("/checkout/confirm-transaction-receipt", "POST", { orderReference: orderReference })];
4037
+ case 1:
4038
+ response = _a.sent();
4039
+ return [2 /*return*/, response.data];
4040
+ case 2:
4041
+ error_1 = _a.sent();
4042
+ return [2 /*return*/, error_1];
4043
+ case 3: return [2 /*return*/];
4044
+ }
4045
+ });
4046
+ }); };
4047
+
4048
+ var useResendOtp = function (orderReference) { return __awaiter(undefined, undefined, undefined, function () {
4049
+ var response, error_1;
4050
+ return __generator(this, function (_a) {
4051
+ switch (_a.label) {
4052
+ case 0:
4053
+ _a.trys.push([0, 2, , 3]);
4054
+ return [4 /*yield*/, handleApiCall("/checkout/resend-otp", "POST", {
4055
+ orderReference: orderReference,
4056
+ })];
4057
+ case 1:
4058
+ response = _a.sent();
4059
+ return [2 /*return*/, response.data];
4060
+ case 2:
4061
+ error_1 = _a.sent();
4062
+ return [2 /*return*/, error_1];
4063
+ case 3: return [2 /*return*/];
4064
+ }
4065
+ });
4066
+ }); };
4067
+
4068
+ var useFetchUssdBanks = function () { return __awaiter(undefined, undefined, undefined, function () {
4069
+ var response, error_1;
4070
+ return __generator(this, function (_a) {
4071
+ switch (_a.label) {
4072
+ case 0:
4073
+ _a.trys.push([0, 2, , 3]);
4074
+ return [4 /*yield*/, handleApiCall("/checkout/ussd/banks", "GET")];
4075
+ case 1:
4076
+ response = _a.sent();
4077
+ return [2 /*return*/, response.data];
4078
+ case 2:
4079
+ error_1 = _a.sent();
4080
+ return [2 /*return*/, error_1];
4081
+ case 3: return [2 /*return*/];
4082
+ }
4083
+ });
4084
+ }); };
4085
+
4086
+ var useGetUssdCode = function (payload) { return __awaiter(undefined, undefined, undefined, function () {
4087
+ var response, error_1;
4088
+ return __generator(this, function (_a) {
4089
+ switch (_a.label) {
4090
+ case 0:
4091
+ _a.trys.push([0, 2, , 3]);
4092
+ return [4 /*yield*/, handleApiCall("/checkout/ussd/code", "POST", payload)];
4093
+ case 1:
4094
+ response = _a.sent();
4095
+ return [2 /*return*/, response.data];
4096
+ case 2:
4097
+ error_1 = _a.sent();
4098
+ return [2 /*return*/, error_1];
4099
+ case 3: return [2 /*return*/];
4100
+ }
4101
+ });
4102
+ }); };
4103
+
4104
+ export { NombaCheckoutButton, NombaCheckoutModal, useCardCheckout, useCardCheckoutOtp, useFetchUssdBanks, useGenerateQrCode, useGetOrder, useGetUssdCode, useResendOtp, useVerifyOrderStatus };
4105
+ //# sourceMappingURL=index.esm.js.map