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