nana800-analytics 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.
@@ -0,0 +1,3079 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all3) => {
7
+ for (var name in all3)
8
+ __defProp(target, name, { get: all3[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ PlatformType: () => PlatformType,
24
+ createNana800Analytics: () => createNana800Analytics
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+
28
+ // src/platform/PlatformDetector.ts
29
+ var PlatformType = /* @__PURE__ */ ((PlatformType2) => {
30
+ PlatformType2["BROWSER"] = "BROWSER";
31
+ PlatformType2["REACT_NATIVE"] = "REACT_NATIVE";
32
+ PlatformType2["NODE"] = "NODE";
33
+ PlatformType2["ELECTRON"] = "ELECTRON";
34
+ PlatformType2["UNKNOWN"] = "UNKNOWN";
35
+ return PlatformType2;
36
+ })(PlatformType || {});
37
+ var detectPlatform = () => {
38
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
39
+ if (typeof window.require === "function" && typeof window.process === "object") {
40
+ return "ELECTRON" /* ELECTRON */;
41
+ }
42
+ return "BROWSER" /* BROWSER */;
43
+ }
44
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
45
+ return "REACT_NATIVE" /* REACT_NATIVE */;
46
+ }
47
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
48
+ return "NODE" /* NODE */;
49
+ }
50
+ return "UNKNOWN" /* UNKNOWN */;
51
+ };
52
+
53
+ // src/constants.ts
54
+ var STORAGE_KEY = "nana800_analytics_events";
55
+ var STORAGE_USER_PROPS_KEY = "nana800_analytics_user_props";
56
+ var DEFAULT_FLUSH_INTERVAL_MS = 2e4;
57
+ var INITIAL_FLUSH_DELAY_MS = 3e3;
58
+ var MAX_EVENTS_BATCH_SIZE = 100;
59
+ var DEFAULT_BASE_URL = "https://api.analytics.nana800.io";
60
+
61
+ // src/storage/StorageManager.ts
62
+ var StorageManager = class {
63
+ storageAdapter = null;
64
+ constructor(platformType, customAdapter, disableStorage) {
65
+ if (disableStorage) {
66
+ this.storageAdapter = null;
67
+ return;
68
+ }
69
+ if (customAdapter) {
70
+ this.storageAdapter = customAdapter;
71
+ return;
72
+ }
73
+ this.storageAdapter = this.initializeDefaultStorage(platformType);
74
+ }
75
+ initializeDefaultStorage(platformType) {
76
+ if (platformType === "BROWSER" /* BROWSER */ || platformType === "ELECTRON" /* ELECTRON */) {
77
+ if (typeof localStorage !== "undefined") {
78
+ return {
79
+ setItem: (key, value) => {
80
+ localStorage.setItem(key, value);
81
+ },
82
+ getItem: (key) => {
83
+ return localStorage.getItem(key);
84
+ },
85
+ removeItem: (key) => {
86
+ localStorage.removeItem(key);
87
+ }
88
+ };
89
+ }
90
+ }
91
+ return null;
92
+ }
93
+ isAvailable() {
94
+ return this.storageAdapter !== null;
95
+ }
96
+ saveEvents(events) {
97
+ if (!this.storageAdapter) {
98
+ return;
99
+ }
100
+ try {
101
+ const eventsData = JSON.stringify(events);
102
+ const setPromise = this.storageAdapter.setItem(STORAGE_KEY, eventsData);
103
+ if (setPromise instanceof Promise) {
104
+ setPromise.catch((error) => {
105
+ console.error("Nana800Analytics: Failed to save events to storage:", error);
106
+ });
107
+ }
108
+ } catch (error) {
109
+ console.error("Nana800Analytics: Failed to save events to storage:", error);
110
+ }
111
+ }
112
+ saveUserProps(userProps) {
113
+ if (!this.storageAdapter) {
114
+ return;
115
+ }
116
+ try {
117
+ const userPropsData = JSON.stringify(userProps);
118
+ const setPromise = this.storageAdapter.setItem(STORAGE_USER_PROPS_KEY, userPropsData);
119
+ if (setPromise instanceof Promise) {
120
+ setPromise.catch((error) => {
121
+ console.error("Nana800Analytics: Failed to save user props to storage:", error);
122
+ });
123
+ }
124
+ } catch (error) {
125
+ console.error("Nana800Analytics: Failed to save user props to storage:", error);
126
+ }
127
+ }
128
+ async loadEvents() {
129
+ if (!this.storageAdapter) {
130
+ return [];
131
+ }
132
+ try {
133
+ const eventsData = await Promise.resolve(this.storageAdapter.getItem(STORAGE_KEY));
134
+ if (eventsData) {
135
+ const parsed = JSON.parse(eventsData);
136
+ if (Array.isArray(parsed)) {
137
+ return parsed.map((event) => ({
138
+ ...event,
139
+ event_time: new Date(event.event_time)
140
+ }));
141
+ }
142
+ }
143
+ } catch (error) {
144
+ console.error("Nana800Analytics: Failed to load events from storage:", error);
145
+ }
146
+ return [];
147
+ }
148
+ async loadUserProps() {
149
+ if (!this.storageAdapter) {
150
+ return [];
151
+ }
152
+ try {
153
+ const userPropsData = await Promise.resolve(this.storageAdapter.getItem(STORAGE_USER_PROPS_KEY));
154
+ if (userPropsData) {
155
+ const parsed = JSON.parse(userPropsData);
156
+ if (Array.isArray(parsed)) {
157
+ return parsed;
158
+ }
159
+ }
160
+ } catch (error) {
161
+ console.error("Nana800Analytics: Failed to load user props from storage:", error);
162
+ }
163
+ return [];
164
+ }
165
+ };
166
+
167
+ // node_modules/axios/lib/helpers/bind.js
168
+ function bind(fn, thisArg) {
169
+ return function wrap() {
170
+ return fn.apply(thisArg, arguments);
171
+ };
172
+ }
173
+
174
+ // node_modules/axios/lib/utils.js
175
+ var { toString } = Object.prototype;
176
+ var { getPrototypeOf } = Object;
177
+ var kindOf = ((cache) => (thing) => {
178
+ const str = toString.call(thing);
179
+ return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
180
+ })(/* @__PURE__ */ Object.create(null));
181
+ var kindOfTest = (type) => {
182
+ type = type.toLowerCase();
183
+ return (thing) => kindOf(thing) === type;
184
+ };
185
+ var typeOfTest = (type) => (thing) => typeof thing === type;
186
+ var { isArray } = Array;
187
+ var isUndefined = typeOfTest("undefined");
188
+ function isBuffer(val) {
189
+ return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
190
+ }
191
+ var isArrayBuffer = kindOfTest("ArrayBuffer");
192
+ function isArrayBufferView(val) {
193
+ let result;
194
+ if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
195
+ result = ArrayBuffer.isView(val);
196
+ } else {
197
+ result = val && val.buffer && isArrayBuffer(val.buffer);
198
+ }
199
+ return result;
200
+ }
201
+ var isString = typeOfTest("string");
202
+ var isFunction = typeOfTest("function");
203
+ var isNumber = typeOfTest("number");
204
+ var isObject = (thing) => thing !== null && typeof thing === "object";
205
+ var isBoolean = (thing) => thing === true || thing === false;
206
+ var isPlainObject = (val) => {
207
+ if (kindOf(val) !== "object") {
208
+ return false;
209
+ }
210
+ const prototype3 = getPrototypeOf(val);
211
+ return (prototype3 === null || prototype3 === Object.prototype || Object.getPrototypeOf(prototype3) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
212
+ };
213
+ var isDate = kindOfTest("Date");
214
+ var isFile = kindOfTest("File");
215
+ var isBlob = kindOfTest("Blob");
216
+ var isFileList = kindOfTest("FileList");
217
+ var isStream = (val) => isObject(val) && isFunction(val.pipe);
218
+ var isFormData = (thing) => {
219
+ let kind;
220
+ return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
221
+ kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
222
+ };
223
+ var isURLSearchParams = kindOfTest("URLSearchParams");
224
+ var [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
225
+ var trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
226
+ function forEach(obj, fn, { allOwnKeys = false } = {}) {
227
+ if (obj === null || typeof obj === "undefined") {
228
+ return;
229
+ }
230
+ let i;
231
+ let l;
232
+ if (typeof obj !== "object") {
233
+ obj = [obj];
234
+ }
235
+ if (isArray(obj)) {
236
+ for (i = 0, l = obj.length; i < l; i++) {
237
+ fn.call(null, obj[i], i, obj);
238
+ }
239
+ } else {
240
+ const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
241
+ const len = keys.length;
242
+ let key;
243
+ for (i = 0; i < len; i++) {
244
+ key = keys[i];
245
+ fn.call(null, obj[key], key, obj);
246
+ }
247
+ }
248
+ }
249
+ function findKey(obj, key) {
250
+ key = key.toLowerCase();
251
+ const keys = Object.keys(obj);
252
+ let i = keys.length;
253
+ let _key;
254
+ while (i-- > 0) {
255
+ _key = keys[i];
256
+ if (key === _key.toLowerCase()) {
257
+ return _key;
258
+ }
259
+ }
260
+ return null;
261
+ }
262
+ var _global = (() => {
263
+ if (typeof globalThis !== "undefined")
264
+ return globalThis;
265
+ return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
266
+ })();
267
+ var isContextDefined = (context) => !isUndefined(context) && context !== _global;
268
+ function merge() {
269
+ const { caseless } = isContextDefined(this) && this || {};
270
+ const result = {};
271
+ const assignValue = (val, key) => {
272
+ const targetKey = caseless && findKey(result, key) || key;
273
+ if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
274
+ result[targetKey] = merge(result[targetKey], val);
275
+ } else if (isPlainObject(val)) {
276
+ result[targetKey] = merge({}, val);
277
+ } else if (isArray(val)) {
278
+ result[targetKey] = val.slice();
279
+ } else {
280
+ result[targetKey] = val;
281
+ }
282
+ };
283
+ for (let i = 0, l = arguments.length; i < l; i++) {
284
+ arguments[i] && forEach(arguments[i], assignValue);
285
+ }
286
+ return result;
287
+ }
288
+ var extend = (a, b, thisArg, { allOwnKeys } = {}) => {
289
+ forEach(b, (val, key) => {
290
+ if (thisArg && isFunction(val)) {
291
+ a[key] = bind(val, thisArg);
292
+ } else {
293
+ a[key] = val;
294
+ }
295
+ }, { allOwnKeys });
296
+ return a;
297
+ };
298
+ var stripBOM = (content) => {
299
+ if (content.charCodeAt(0) === 65279) {
300
+ content = content.slice(1);
301
+ }
302
+ return content;
303
+ };
304
+ var inherits = (constructor, superConstructor, props, descriptors2) => {
305
+ constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
306
+ constructor.prototype.constructor = constructor;
307
+ Object.defineProperty(constructor, "super", {
308
+ value: superConstructor.prototype
309
+ });
310
+ props && Object.assign(constructor.prototype, props);
311
+ };
312
+ var toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
313
+ let props;
314
+ let i;
315
+ let prop;
316
+ const merged = {};
317
+ destObj = destObj || {};
318
+ if (sourceObj == null)
319
+ return destObj;
320
+ do {
321
+ props = Object.getOwnPropertyNames(sourceObj);
322
+ i = props.length;
323
+ while (i-- > 0) {
324
+ prop = props[i];
325
+ if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
326
+ destObj[prop] = sourceObj[prop];
327
+ merged[prop] = true;
328
+ }
329
+ }
330
+ sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
331
+ } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
332
+ return destObj;
333
+ };
334
+ var endsWith = (str, searchString, position) => {
335
+ str = String(str);
336
+ if (position === void 0 || position > str.length) {
337
+ position = str.length;
338
+ }
339
+ position -= searchString.length;
340
+ const lastIndex = str.indexOf(searchString, position);
341
+ return lastIndex !== -1 && lastIndex === position;
342
+ };
343
+ var toArray = (thing) => {
344
+ if (!thing)
345
+ return null;
346
+ if (isArray(thing))
347
+ return thing;
348
+ let i = thing.length;
349
+ if (!isNumber(i))
350
+ return null;
351
+ const arr = new Array(i);
352
+ while (i-- > 0) {
353
+ arr[i] = thing[i];
354
+ }
355
+ return arr;
356
+ };
357
+ var isTypedArray = ((TypedArray) => {
358
+ return (thing) => {
359
+ return TypedArray && thing instanceof TypedArray;
360
+ };
361
+ })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
362
+ var forEachEntry = (obj, fn) => {
363
+ const generator = obj && obj[Symbol.iterator];
364
+ const iterator = generator.call(obj);
365
+ let result;
366
+ while ((result = iterator.next()) && !result.done) {
367
+ const pair = result.value;
368
+ fn.call(obj, pair[0], pair[1]);
369
+ }
370
+ };
371
+ var matchAll = (regExp, str) => {
372
+ let matches;
373
+ const arr = [];
374
+ while ((matches = regExp.exec(str)) !== null) {
375
+ arr.push(matches);
376
+ }
377
+ return arr;
378
+ };
379
+ var isHTMLForm = kindOfTest("HTMLFormElement");
380
+ var toCamelCase = (str) => {
381
+ return str.toLowerCase().replace(
382
+ /[-_\s]([a-z\d])(\w*)/g,
383
+ function replacer(m, p1, p2) {
384
+ return p1.toUpperCase() + p2;
385
+ }
386
+ );
387
+ };
388
+ var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
389
+ var isRegExp = kindOfTest("RegExp");
390
+ var reduceDescriptors = (obj, reducer) => {
391
+ const descriptors2 = Object.getOwnPropertyDescriptors(obj);
392
+ const reducedDescriptors = {};
393
+ forEach(descriptors2, (descriptor, name) => {
394
+ let ret;
395
+ if ((ret = reducer(descriptor, name, obj)) !== false) {
396
+ reducedDescriptors[name] = ret || descriptor;
397
+ }
398
+ });
399
+ Object.defineProperties(obj, reducedDescriptors);
400
+ };
401
+ var freezeMethods = (obj) => {
402
+ reduceDescriptors(obj, (descriptor, name) => {
403
+ if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
404
+ return false;
405
+ }
406
+ const value = obj[name];
407
+ if (!isFunction(value))
408
+ return;
409
+ descriptor.enumerable = false;
410
+ if ("writable" in descriptor) {
411
+ descriptor.writable = false;
412
+ return;
413
+ }
414
+ if (!descriptor.set) {
415
+ descriptor.set = () => {
416
+ throw Error("Can not rewrite read-only method '" + name + "'");
417
+ };
418
+ }
419
+ });
420
+ };
421
+ var toObjectSet = (arrayOrString, delimiter) => {
422
+ const obj = {};
423
+ const define = (arr) => {
424
+ arr.forEach((value) => {
425
+ obj[value] = true;
426
+ });
427
+ };
428
+ isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
429
+ return obj;
430
+ };
431
+ var noop = () => {
432
+ };
433
+ var toFiniteNumber = (value, defaultValue) => {
434
+ return value != null && Number.isFinite(value = +value) ? value : defaultValue;
435
+ };
436
+ var ALPHA = "abcdefghijklmnopqrstuvwxyz";
437
+ var DIGIT = "0123456789";
438
+ var ALPHABET = {
439
+ DIGIT,
440
+ ALPHA,
441
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
442
+ };
443
+ var generateString = (size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
444
+ let str = "";
445
+ const { length } = alphabet;
446
+ while (size--) {
447
+ str += alphabet[Math.random() * length | 0];
448
+ }
449
+ return str;
450
+ };
451
+ function isSpecCompliantForm(thing) {
452
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
453
+ }
454
+ var toJSONObject = (obj) => {
455
+ const stack = new Array(10);
456
+ const visit = (source, i) => {
457
+ if (isObject(source)) {
458
+ if (stack.indexOf(source) >= 0) {
459
+ return;
460
+ }
461
+ if (!("toJSON" in source)) {
462
+ stack[i] = source;
463
+ const target = isArray(source) ? [] : {};
464
+ forEach(source, (value, key) => {
465
+ const reducedValue = visit(value, i + 1);
466
+ !isUndefined(reducedValue) && (target[key] = reducedValue);
467
+ });
468
+ stack[i] = void 0;
469
+ return target;
470
+ }
471
+ }
472
+ return source;
473
+ };
474
+ return visit(obj, 0);
475
+ };
476
+ var isAsyncFn = kindOfTest("AsyncFunction");
477
+ var isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
478
+ var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
479
+ if (setImmediateSupported) {
480
+ return setImmediate;
481
+ }
482
+ return postMessageSupported ? ((token, callbacks) => {
483
+ _global.addEventListener("message", ({ source, data }) => {
484
+ if (source === _global && data === token) {
485
+ callbacks.length && callbacks.shift()();
486
+ }
487
+ }, false);
488
+ return (cb) => {
489
+ callbacks.push(cb);
490
+ _global.postMessage(token, "*");
491
+ };
492
+ })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
493
+ })(
494
+ typeof setImmediate === "function",
495
+ isFunction(_global.postMessage)
496
+ );
497
+ var asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
498
+ var utils_default = {
499
+ isArray,
500
+ isArrayBuffer,
501
+ isBuffer,
502
+ isFormData,
503
+ isArrayBufferView,
504
+ isString,
505
+ isNumber,
506
+ isBoolean,
507
+ isObject,
508
+ isPlainObject,
509
+ isReadableStream,
510
+ isRequest,
511
+ isResponse,
512
+ isHeaders,
513
+ isUndefined,
514
+ isDate,
515
+ isFile,
516
+ isBlob,
517
+ isRegExp,
518
+ isFunction,
519
+ isStream,
520
+ isURLSearchParams,
521
+ isTypedArray,
522
+ isFileList,
523
+ forEach,
524
+ merge,
525
+ extend,
526
+ trim,
527
+ stripBOM,
528
+ inherits,
529
+ toFlatObject,
530
+ kindOf,
531
+ kindOfTest,
532
+ endsWith,
533
+ toArray,
534
+ forEachEntry,
535
+ matchAll,
536
+ isHTMLForm,
537
+ hasOwnProperty,
538
+ hasOwnProp: hasOwnProperty,
539
+ // an alias to avoid ESLint no-prototype-builtins detection
540
+ reduceDescriptors,
541
+ freezeMethods,
542
+ toObjectSet,
543
+ toCamelCase,
544
+ noop,
545
+ toFiniteNumber,
546
+ findKey,
547
+ global: _global,
548
+ isContextDefined,
549
+ ALPHABET,
550
+ generateString,
551
+ isSpecCompliantForm,
552
+ toJSONObject,
553
+ isAsyncFn,
554
+ isThenable,
555
+ setImmediate: _setImmediate,
556
+ asap
557
+ };
558
+
559
+ // node_modules/axios/lib/core/AxiosError.js
560
+ function AxiosError(message, code, config, request, response) {
561
+ Error.call(this);
562
+ if (Error.captureStackTrace) {
563
+ Error.captureStackTrace(this, this.constructor);
564
+ } else {
565
+ this.stack = new Error().stack;
566
+ }
567
+ this.message = message;
568
+ this.name = "AxiosError";
569
+ code && (this.code = code);
570
+ config && (this.config = config);
571
+ request && (this.request = request);
572
+ if (response) {
573
+ this.response = response;
574
+ this.status = response.status ? response.status : null;
575
+ }
576
+ }
577
+ utils_default.inherits(AxiosError, Error, {
578
+ toJSON: function toJSON() {
579
+ return {
580
+ // Standard
581
+ message: this.message,
582
+ name: this.name,
583
+ // Microsoft
584
+ description: this.description,
585
+ number: this.number,
586
+ // Mozilla
587
+ fileName: this.fileName,
588
+ lineNumber: this.lineNumber,
589
+ columnNumber: this.columnNumber,
590
+ stack: this.stack,
591
+ // Axios
592
+ config: utils_default.toJSONObject(this.config),
593
+ code: this.code,
594
+ status: this.status
595
+ };
596
+ }
597
+ });
598
+ var prototype = AxiosError.prototype;
599
+ var descriptors = {};
600
+ [
601
+ "ERR_BAD_OPTION_VALUE",
602
+ "ERR_BAD_OPTION",
603
+ "ECONNABORTED",
604
+ "ETIMEDOUT",
605
+ "ERR_NETWORK",
606
+ "ERR_FR_TOO_MANY_REDIRECTS",
607
+ "ERR_DEPRECATED",
608
+ "ERR_BAD_RESPONSE",
609
+ "ERR_BAD_REQUEST",
610
+ "ERR_CANCELED",
611
+ "ERR_NOT_SUPPORT",
612
+ "ERR_INVALID_URL"
613
+ // eslint-disable-next-line func-names
614
+ ].forEach((code) => {
615
+ descriptors[code] = { value: code };
616
+ });
617
+ Object.defineProperties(AxiosError, descriptors);
618
+ Object.defineProperty(prototype, "isAxiosError", { value: true });
619
+ AxiosError.from = (error, code, config, request, response, customProps) => {
620
+ const axiosError = Object.create(prototype);
621
+ utils_default.toFlatObject(error, axiosError, function filter2(obj) {
622
+ return obj !== Error.prototype;
623
+ }, (prop) => {
624
+ return prop !== "isAxiosError";
625
+ });
626
+ AxiosError.call(axiosError, error.message, code, config, request, response);
627
+ axiosError.cause = error;
628
+ axiosError.name = error.name;
629
+ customProps && Object.assign(axiosError, customProps);
630
+ return axiosError;
631
+ };
632
+ var AxiosError_default = AxiosError;
633
+
634
+ // node_modules/axios/lib/helpers/null.js
635
+ var null_default = null;
636
+
637
+ // node_modules/axios/lib/helpers/toFormData.js
638
+ function isVisitable(thing) {
639
+ return utils_default.isPlainObject(thing) || utils_default.isArray(thing);
640
+ }
641
+ function removeBrackets(key) {
642
+ return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
643
+ }
644
+ function renderKey(path, key, dots) {
645
+ if (!path)
646
+ return key;
647
+ return path.concat(key).map(function each(token, i) {
648
+ token = removeBrackets(token);
649
+ return !dots && i ? "[" + token + "]" : token;
650
+ }).join(dots ? "." : "");
651
+ }
652
+ function isFlatArray(arr) {
653
+ return utils_default.isArray(arr) && !arr.some(isVisitable);
654
+ }
655
+ var predicates = utils_default.toFlatObject(utils_default, {}, null, function filter(prop) {
656
+ return /^is[A-Z]/.test(prop);
657
+ });
658
+ function toFormData(obj, formData, options) {
659
+ if (!utils_default.isObject(obj)) {
660
+ throw new TypeError("target must be an object");
661
+ }
662
+ formData = formData || new (null_default || FormData)();
663
+ options = utils_default.toFlatObject(options, {
664
+ metaTokens: true,
665
+ dots: false,
666
+ indexes: false
667
+ }, false, function defined(option, source) {
668
+ return !utils_default.isUndefined(source[option]);
669
+ });
670
+ const metaTokens = options.metaTokens;
671
+ const visitor = options.visitor || defaultVisitor;
672
+ const dots = options.dots;
673
+ const indexes = options.indexes;
674
+ const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
675
+ const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
676
+ if (!utils_default.isFunction(visitor)) {
677
+ throw new TypeError("visitor must be a function");
678
+ }
679
+ function convertValue(value) {
680
+ if (value === null)
681
+ return "";
682
+ if (utils_default.isDate(value)) {
683
+ return value.toISOString();
684
+ }
685
+ if (!useBlob && utils_default.isBlob(value)) {
686
+ throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
687
+ }
688
+ if (utils_default.isArrayBuffer(value) || utils_default.isTypedArray(value)) {
689
+ return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
690
+ }
691
+ return value;
692
+ }
693
+ function defaultVisitor(value, key, path) {
694
+ let arr = value;
695
+ if (value && !path && typeof value === "object") {
696
+ if (utils_default.endsWith(key, "{}")) {
697
+ key = metaTokens ? key : key.slice(0, -2);
698
+ value = JSON.stringify(value);
699
+ } else if (utils_default.isArray(value) && isFlatArray(value) || (utils_default.isFileList(value) || utils_default.endsWith(key, "[]")) && (arr = utils_default.toArray(value))) {
700
+ key = removeBrackets(key);
701
+ arr.forEach(function each(el, index) {
702
+ !(utils_default.isUndefined(el) || el === null) && formData.append(
703
+ // eslint-disable-next-line no-nested-ternary
704
+ indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
705
+ convertValue(el)
706
+ );
707
+ });
708
+ return false;
709
+ }
710
+ }
711
+ if (isVisitable(value)) {
712
+ return true;
713
+ }
714
+ formData.append(renderKey(path, key, dots), convertValue(value));
715
+ return false;
716
+ }
717
+ const stack = [];
718
+ const exposedHelpers = Object.assign(predicates, {
719
+ defaultVisitor,
720
+ convertValue,
721
+ isVisitable
722
+ });
723
+ function build(value, path) {
724
+ if (utils_default.isUndefined(value))
725
+ return;
726
+ if (stack.indexOf(value) !== -1) {
727
+ throw Error("Circular reference detected in " + path.join("."));
728
+ }
729
+ stack.push(value);
730
+ utils_default.forEach(value, function each(el, key) {
731
+ const result = !(utils_default.isUndefined(el) || el === null) && visitor.call(
732
+ formData,
733
+ el,
734
+ utils_default.isString(key) ? key.trim() : key,
735
+ path,
736
+ exposedHelpers
737
+ );
738
+ if (result === true) {
739
+ build(el, path ? path.concat(key) : [key]);
740
+ }
741
+ });
742
+ stack.pop();
743
+ }
744
+ if (!utils_default.isObject(obj)) {
745
+ throw new TypeError("data must be an object");
746
+ }
747
+ build(obj);
748
+ return formData;
749
+ }
750
+ var toFormData_default = toFormData;
751
+
752
+ // node_modules/axios/lib/helpers/AxiosURLSearchParams.js
753
+ function encode(str) {
754
+ const charMap = {
755
+ "!": "%21",
756
+ "'": "%27",
757
+ "(": "%28",
758
+ ")": "%29",
759
+ "~": "%7E",
760
+ "%20": "+",
761
+ "%00": "\0"
762
+ };
763
+ return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer(match) {
764
+ return charMap[match];
765
+ });
766
+ }
767
+ function AxiosURLSearchParams(params, options) {
768
+ this._pairs = [];
769
+ params && toFormData_default(params, this, options);
770
+ }
771
+ var prototype2 = AxiosURLSearchParams.prototype;
772
+ prototype2.append = function append(name, value) {
773
+ this._pairs.push([name, value]);
774
+ };
775
+ prototype2.toString = function toString2(encoder) {
776
+ const _encode = encoder ? function(value) {
777
+ return encoder.call(this, value, encode);
778
+ } : encode;
779
+ return this._pairs.map(function each(pair) {
780
+ return _encode(pair[0]) + "=" + _encode(pair[1]);
781
+ }, "").join("&");
782
+ };
783
+ var AxiosURLSearchParams_default = AxiosURLSearchParams;
784
+
785
+ // node_modules/axios/lib/helpers/buildURL.js
786
+ function encode2(val) {
787
+ return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
788
+ }
789
+ function buildURL(url, params, options) {
790
+ if (!params) {
791
+ return url;
792
+ }
793
+ const _encode = options && options.encode || encode2;
794
+ const serializeFn = options && options.serialize;
795
+ let serializedParams;
796
+ if (serializeFn) {
797
+ serializedParams = serializeFn(params, options);
798
+ } else {
799
+ serializedParams = utils_default.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams_default(params, options).toString(_encode);
800
+ }
801
+ if (serializedParams) {
802
+ const hashmarkIndex = url.indexOf("#");
803
+ if (hashmarkIndex !== -1) {
804
+ url = url.slice(0, hashmarkIndex);
805
+ }
806
+ url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
807
+ }
808
+ return url;
809
+ }
810
+
811
+ // node_modules/axios/lib/core/InterceptorManager.js
812
+ var InterceptorManager = class {
813
+ constructor() {
814
+ this.handlers = [];
815
+ }
816
+ /**
817
+ * Add a new interceptor to the stack
818
+ *
819
+ * @param {Function} fulfilled The function to handle `then` for a `Promise`
820
+ * @param {Function} rejected The function to handle `reject` for a `Promise`
821
+ *
822
+ * @return {Number} An ID used to remove interceptor later
823
+ */
824
+ use(fulfilled, rejected, options) {
825
+ this.handlers.push({
826
+ fulfilled,
827
+ rejected,
828
+ synchronous: options ? options.synchronous : false,
829
+ runWhen: options ? options.runWhen : null
830
+ });
831
+ return this.handlers.length - 1;
832
+ }
833
+ /**
834
+ * Remove an interceptor from the stack
835
+ *
836
+ * @param {Number} id The ID that was returned by `use`
837
+ *
838
+ * @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
839
+ */
840
+ eject(id) {
841
+ if (this.handlers[id]) {
842
+ this.handlers[id] = null;
843
+ }
844
+ }
845
+ /**
846
+ * Clear all interceptors from the stack
847
+ *
848
+ * @returns {void}
849
+ */
850
+ clear() {
851
+ if (this.handlers) {
852
+ this.handlers = [];
853
+ }
854
+ }
855
+ /**
856
+ * Iterate over all the registered interceptors
857
+ *
858
+ * This method is particularly useful for skipping over any
859
+ * interceptors that may have become `null` calling `eject`.
860
+ *
861
+ * @param {Function} fn The function to call for each interceptor
862
+ *
863
+ * @returns {void}
864
+ */
865
+ forEach(fn) {
866
+ utils_default.forEach(this.handlers, function forEachHandler(h) {
867
+ if (h !== null) {
868
+ fn(h);
869
+ }
870
+ });
871
+ }
872
+ };
873
+ var InterceptorManager_default = InterceptorManager;
874
+
875
+ // node_modules/axios/lib/defaults/transitional.js
876
+ var transitional_default = {
877
+ silentJSONParsing: true,
878
+ forcedJSONParsing: true,
879
+ clarifyTimeoutError: false
880
+ };
881
+
882
+ // node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
883
+ var URLSearchParams_default = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams_default;
884
+
885
+ // node_modules/axios/lib/platform/browser/classes/FormData.js
886
+ var FormData_default = typeof FormData !== "undefined" ? FormData : null;
887
+
888
+ // node_modules/axios/lib/platform/browser/classes/Blob.js
889
+ var Blob_default = typeof Blob !== "undefined" ? Blob : null;
890
+
891
+ // node_modules/axios/lib/platform/browser/index.js
892
+ var browser_default = {
893
+ isBrowser: true,
894
+ classes: {
895
+ URLSearchParams: URLSearchParams_default,
896
+ FormData: FormData_default,
897
+ Blob: Blob_default
898
+ },
899
+ protocols: ["http", "https", "file", "blob", "url", "data"]
900
+ };
901
+
902
+ // node_modules/axios/lib/platform/common/utils.js
903
+ var utils_exports = {};
904
+ __export(utils_exports, {
905
+ hasBrowserEnv: () => hasBrowserEnv,
906
+ hasStandardBrowserEnv: () => hasStandardBrowserEnv,
907
+ hasStandardBrowserWebWorkerEnv: () => hasStandardBrowserWebWorkerEnv,
908
+ navigator: () => _navigator,
909
+ origin: () => origin
910
+ });
911
+ var hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
912
+ var _navigator = typeof navigator === "object" && navigator || void 0;
913
+ var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
914
+ var hasStandardBrowserWebWorkerEnv = (() => {
915
+ return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
916
+ self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
917
+ })();
918
+ var origin = hasBrowserEnv && window.location.href || "http://localhost";
919
+
920
+ // node_modules/axios/lib/platform/index.js
921
+ var platform_default = {
922
+ ...utils_exports,
923
+ ...browser_default
924
+ };
925
+
926
+ // node_modules/axios/lib/helpers/toURLEncodedForm.js
927
+ function toURLEncodedForm(data, options) {
928
+ return toFormData_default(data, new platform_default.classes.URLSearchParams(), Object.assign({
929
+ visitor: function(value, key, path, helpers) {
930
+ if (platform_default.isNode && utils_default.isBuffer(value)) {
931
+ this.append(key, value.toString("base64"));
932
+ return false;
933
+ }
934
+ return helpers.defaultVisitor.apply(this, arguments);
935
+ }
936
+ }, options));
937
+ }
938
+
939
+ // node_modules/axios/lib/helpers/formDataToJSON.js
940
+ function parsePropPath(name) {
941
+ return utils_default.matchAll(/\w+|\[(\w*)]/g, name).map((match) => {
942
+ return match[0] === "[]" ? "" : match[1] || match[0];
943
+ });
944
+ }
945
+ function arrayToObject(arr) {
946
+ const obj = {};
947
+ const keys = Object.keys(arr);
948
+ let i;
949
+ const len = keys.length;
950
+ let key;
951
+ for (i = 0; i < len; i++) {
952
+ key = keys[i];
953
+ obj[key] = arr[key];
954
+ }
955
+ return obj;
956
+ }
957
+ function formDataToJSON(formData) {
958
+ function buildPath(path, value, target, index) {
959
+ let name = path[index++];
960
+ if (name === "__proto__")
961
+ return true;
962
+ const isNumericKey = Number.isFinite(+name);
963
+ const isLast = index >= path.length;
964
+ name = !name && utils_default.isArray(target) ? target.length : name;
965
+ if (isLast) {
966
+ if (utils_default.hasOwnProp(target, name)) {
967
+ target[name] = [target[name], value];
968
+ } else {
969
+ target[name] = value;
970
+ }
971
+ return !isNumericKey;
972
+ }
973
+ if (!target[name] || !utils_default.isObject(target[name])) {
974
+ target[name] = [];
975
+ }
976
+ const result = buildPath(path, value, target[name], index);
977
+ if (result && utils_default.isArray(target[name])) {
978
+ target[name] = arrayToObject(target[name]);
979
+ }
980
+ return !isNumericKey;
981
+ }
982
+ if (utils_default.isFormData(formData) && utils_default.isFunction(formData.entries)) {
983
+ const obj = {};
984
+ utils_default.forEachEntry(formData, (name, value) => {
985
+ buildPath(parsePropPath(name), value, obj, 0);
986
+ });
987
+ return obj;
988
+ }
989
+ return null;
990
+ }
991
+ var formDataToJSON_default = formDataToJSON;
992
+
993
+ // node_modules/axios/lib/defaults/index.js
994
+ function stringifySafely(rawValue, parser, encoder) {
995
+ if (utils_default.isString(rawValue)) {
996
+ try {
997
+ (parser || JSON.parse)(rawValue);
998
+ return utils_default.trim(rawValue);
999
+ } catch (e) {
1000
+ if (e.name !== "SyntaxError") {
1001
+ throw e;
1002
+ }
1003
+ }
1004
+ }
1005
+ return (encoder || JSON.stringify)(rawValue);
1006
+ }
1007
+ var defaults = {
1008
+ transitional: transitional_default,
1009
+ adapter: ["xhr", "http", "fetch"],
1010
+ transformRequest: [function transformRequest(data, headers) {
1011
+ const contentType = headers.getContentType() || "";
1012
+ const hasJSONContentType = contentType.indexOf("application/json") > -1;
1013
+ const isObjectPayload = utils_default.isObject(data);
1014
+ if (isObjectPayload && utils_default.isHTMLForm(data)) {
1015
+ data = new FormData(data);
1016
+ }
1017
+ const isFormData2 = utils_default.isFormData(data);
1018
+ if (isFormData2) {
1019
+ return hasJSONContentType ? JSON.stringify(formDataToJSON_default(data)) : data;
1020
+ }
1021
+ if (utils_default.isArrayBuffer(data) || utils_default.isBuffer(data) || utils_default.isStream(data) || utils_default.isFile(data) || utils_default.isBlob(data) || utils_default.isReadableStream(data)) {
1022
+ return data;
1023
+ }
1024
+ if (utils_default.isArrayBufferView(data)) {
1025
+ return data.buffer;
1026
+ }
1027
+ if (utils_default.isURLSearchParams(data)) {
1028
+ headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
1029
+ return data.toString();
1030
+ }
1031
+ let isFileList2;
1032
+ if (isObjectPayload) {
1033
+ if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
1034
+ return toURLEncodedForm(data, this.formSerializer).toString();
1035
+ }
1036
+ if ((isFileList2 = utils_default.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
1037
+ const _FormData = this.env && this.env.FormData;
1038
+ return toFormData_default(
1039
+ isFileList2 ? { "files[]": data } : data,
1040
+ _FormData && new _FormData(),
1041
+ this.formSerializer
1042
+ );
1043
+ }
1044
+ }
1045
+ if (isObjectPayload || hasJSONContentType) {
1046
+ headers.setContentType("application/json", false);
1047
+ return stringifySafely(data);
1048
+ }
1049
+ return data;
1050
+ }],
1051
+ transformResponse: [function transformResponse(data) {
1052
+ const transitional2 = this.transitional || defaults.transitional;
1053
+ const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
1054
+ const JSONRequested = this.responseType === "json";
1055
+ if (utils_default.isResponse(data) || utils_default.isReadableStream(data)) {
1056
+ return data;
1057
+ }
1058
+ if (data && utils_default.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
1059
+ const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
1060
+ const strictJSONParsing = !silentJSONParsing && JSONRequested;
1061
+ try {
1062
+ return JSON.parse(data);
1063
+ } catch (e) {
1064
+ if (strictJSONParsing) {
1065
+ if (e.name === "SyntaxError") {
1066
+ throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, this.response);
1067
+ }
1068
+ throw e;
1069
+ }
1070
+ }
1071
+ }
1072
+ return data;
1073
+ }],
1074
+ /**
1075
+ * A timeout in milliseconds to abort a request. If set to 0 (default) a
1076
+ * timeout is not created.
1077
+ */
1078
+ timeout: 0,
1079
+ xsrfCookieName: "XSRF-TOKEN",
1080
+ xsrfHeaderName: "X-XSRF-TOKEN",
1081
+ maxContentLength: -1,
1082
+ maxBodyLength: -1,
1083
+ env: {
1084
+ FormData: platform_default.classes.FormData,
1085
+ Blob: platform_default.classes.Blob
1086
+ },
1087
+ validateStatus: function validateStatus(status) {
1088
+ return status >= 200 && status < 300;
1089
+ },
1090
+ headers: {
1091
+ common: {
1092
+ "Accept": "application/json, text/plain, */*",
1093
+ "Content-Type": void 0
1094
+ }
1095
+ }
1096
+ };
1097
+ utils_default.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
1098
+ defaults.headers[method] = {};
1099
+ });
1100
+ var defaults_default = defaults;
1101
+
1102
+ // node_modules/axios/lib/helpers/parseHeaders.js
1103
+ var ignoreDuplicateOf = utils_default.toObjectSet([
1104
+ "age",
1105
+ "authorization",
1106
+ "content-length",
1107
+ "content-type",
1108
+ "etag",
1109
+ "expires",
1110
+ "from",
1111
+ "host",
1112
+ "if-modified-since",
1113
+ "if-unmodified-since",
1114
+ "last-modified",
1115
+ "location",
1116
+ "max-forwards",
1117
+ "proxy-authorization",
1118
+ "referer",
1119
+ "retry-after",
1120
+ "user-agent"
1121
+ ]);
1122
+ var parseHeaders_default = (rawHeaders) => {
1123
+ const parsed = {};
1124
+ let key;
1125
+ let val;
1126
+ let i;
1127
+ rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
1128
+ i = line.indexOf(":");
1129
+ key = line.substring(0, i).trim().toLowerCase();
1130
+ val = line.substring(i + 1).trim();
1131
+ if (!key || parsed[key] && ignoreDuplicateOf[key]) {
1132
+ return;
1133
+ }
1134
+ if (key === "set-cookie") {
1135
+ if (parsed[key]) {
1136
+ parsed[key].push(val);
1137
+ } else {
1138
+ parsed[key] = [val];
1139
+ }
1140
+ } else {
1141
+ parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
1142
+ }
1143
+ });
1144
+ return parsed;
1145
+ };
1146
+
1147
+ // node_modules/axios/lib/core/AxiosHeaders.js
1148
+ var $internals = Symbol("internals");
1149
+ function normalizeHeader(header) {
1150
+ return header && String(header).trim().toLowerCase();
1151
+ }
1152
+ function normalizeValue(value) {
1153
+ if (value === false || value == null) {
1154
+ return value;
1155
+ }
1156
+ return utils_default.isArray(value) ? value.map(normalizeValue) : String(value);
1157
+ }
1158
+ function parseTokens(str) {
1159
+ const tokens = /* @__PURE__ */ Object.create(null);
1160
+ const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
1161
+ let match;
1162
+ while (match = tokensRE.exec(str)) {
1163
+ tokens[match[1]] = match[2];
1164
+ }
1165
+ return tokens;
1166
+ }
1167
+ var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
1168
+ function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
1169
+ if (utils_default.isFunction(filter2)) {
1170
+ return filter2.call(this, value, header);
1171
+ }
1172
+ if (isHeaderNameFilter) {
1173
+ value = header;
1174
+ }
1175
+ if (!utils_default.isString(value))
1176
+ return;
1177
+ if (utils_default.isString(filter2)) {
1178
+ return value.indexOf(filter2) !== -1;
1179
+ }
1180
+ if (utils_default.isRegExp(filter2)) {
1181
+ return filter2.test(value);
1182
+ }
1183
+ }
1184
+ function formatHeader(header) {
1185
+ return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
1186
+ return char.toUpperCase() + str;
1187
+ });
1188
+ }
1189
+ function buildAccessors(obj, header) {
1190
+ const accessorName = utils_default.toCamelCase(" " + header);
1191
+ ["get", "set", "has"].forEach((methodName) => {
1192
+ Object.defineProperty(obj, methodName + accessorName, {
1193
+ value: function(arg1, arg2, arg3) {
1194
+ return this[methodName].call(this, header, arg1, arg2, arg3);
1195
+ },
1196
+ configurable: true
1197
+ });
1198
+ });
1199
+ }
1200
+ var AxiosHeaders = class {
1201
+ constructor(headers) {
1202
+ headers && this.set(headers);
1203
+ }
1204
+ set(header, valueOrRewrite, rewrite) {
1205
+ const self2 = this;
1206
+ function setHeader(_value, _header, _rewrite) {
1207
+ const lHeader = normalizeHeader(_header);
1208
+ if (!lHeader) {
1209
+ throw new Error("header name must be a non-empty string");
1210
+ }
1211
+ const key = utils_default.findKey(self2, lHeader);
1212
+ if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
1213
+ self2[key || _header] = normalizeValue(_value);
1214
+ }
1215
+ }
1216
+ const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
1217
+ if (utils_default.isPlainObject(header) || header instanceof this.constructor) {
1218
+ setHeaders(header, valueOrRewrite);
1219
+ } else if (utils_default.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
1220
+ setHeaders(parseHeaders_default(header), valueOrRewrite);
1221
+ } else if (utils_default.isHeaders(header)) {
1222
+ for (const [key, value] of header.entries()) {
1223
+ setHeader(value, key, rewrite);
1224
+ }
1225
+ } else {
1226
+ header != null && setHeader(valueOrRewrite, header, rewrite);
1227
+ }
1228
+ return this;
1229
+ }
1230
+ get(header, parser) {
1231
+ header = normalizeHeader(header);
1232
+ if (header) {
1233
+ const key = utils_default.findKey(this, header);
1234
+ if (key) {
1235
+ const value = this[key];
1236
+ if (!parser) {
1237
+ return value;
1238
+ }
1239
+ if (parser === true) {
1240
+ return parseTokens(value);
1241
+ }
1242
+ if (utils_default.isFunction(parser)) {
1243
+ return parser.call(this, value, key);
1244
+ }
1245
+ if (utils_default.isRegExp(parser)) {
1246
+ return parser.exec(value);
1247
+ }
1248
+ throw new TypeError("parser must be boolean|regexp|function");
1249
+ }
1250
+ }
1251
+ }
1252
+ has(header, matcher) {
1253
+ header = normalizeHeader(header);
1254
+ if (header) {
1255
+ const key = utils_default.findKey(this, header);
1256
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1257
+ }
1258
+ return false;
1259
+ }
1260
+ delete(header, matcher) {
1261
+ const self2 = this;
1262
+ let deleted = false;
1263
+ function deleteHeader(_header) {
1264
+ _header = normalizeHeader(_header);
1265
+ if (_header) {
1266
+ const key = utils_default.findKey(self2, _header);
1267
+ if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
1268
+ delete self2[key];
1269
+ deleted = true;
1270
+ }
1271
+ }
1272
+ }
1273
+ if (utils_default.isArray(header)) {
1274
+ header.forEach(deleteHeader);
1275
+ } else {
1276
+ deleteHeader(header);
1277
+ }
1278
+ return deleted;
1279
+ }
1280
+ clear(matcher) {
1281
+ const keys = Object.keys(this);
1282
+ let i = keys.length;
1283
+ let deleted = false;
1284
+ while (i--) {
1285
+ const key = keys[i];
1286
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1287
+ delete this[key];
1288
+ deleted = true;
1289
+ }
1290
+ }
1291
+ return deleted;
1292
+ }
1293
+ normalize(format) {
1294
+ const self2 = this;
1295
+ const headers = {};
1296
+ utils_default.forEach(this, (value, header) => {
1297
+ const key = utils_default.findKey(headers, header);
1298
+ if (key) {
1299
+ self2[key] = normalizeValue(value);
1300
+ delete self2[header];
1301
+ return;
1302
+ }
1303
+ const normalized = format ? formatHeader(header) : String(header).trim();
1304
+ if (normalized !== header) {
1305
+ delete self2[header];
1306
+ }
1307
+ self2[normalized] = normalizeValue(value);
1308
+ headers[normalized] = true;
1309
+ });
1310
+ return this;
1311
+ }
1312
+ concat(...targets) {
1313
+ return this.constructor.concat(this, ...targets);
1314
+ }
1315
+ toJSON(asStrings) {
1316
+ const obj = /* @__PURE__ */ Object.create(null);
1317
+ utils_default.forEach(this, (value, header) => {
1318
+ value != null && value !== false && (obj[header] = asStrings && utils_default.isArray(value) ? value.join(", ") : value);
1319
+ });
1320
+ return obj;
1321
+ }
1322
+ [Symbol.iterator]() {
1323
+ return Object.entries(this.toJSON())[Symbol.iterator]();
1324
+ }
1325
+ toString() {
1326
+ return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
1327
+ }
1328
+ get [Symbol.toStringTag]() {
1329
+ return "AxiosHeaders";
1330
+ }
1331
+ static from(thing) {
1332
+ return thing instanceof this ? thing : new this(thing);
1333
+ }
1334
+ static concat(first, ...targets) {
1335
+ const computed = new this(first);
1336
+ targets.forEach((target) => computed.set(target));
1337
+ return computed;
1338
+ }
1339
+ static accessor(header) {
1340
+ const internals = this[$internals] = this[$internals] = {
1341
+ accessors: {}
1342
+ };
1343
+ const accessors = internals.accessors;
1344
+ const prototype3 = this.prototype;
1345
+ function defineAccessor(_header) {
1346
+ const lHeader = normalizeHeader(_header);
1347
+ if (!accessors[lHeader]) {
1348
+ buildAccessors(prototype3, _header);
1349
+ accessors[lHeader] = true;
1350
+ }
1351
+ }
1352
+ utils_default.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
1353
+ return this;
1354
+ }
1355
+ };
1356
+ AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1357
+ utils_default.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
1358
+ let mapped = key[0].toUpperCase() + key.slice(1);
1359
+ return {
1360
+ get: () => value,
1361
+ set(headerValue) {
1362
+ this[mapped] = headerValue;
1363
+ }
1364
+ };
1365
+ });
1366
+ utils_default.freezeMethods(AxiosHeaders);
1367
+ var AxiosHeaders_default = AxiosHeaders;
1368
+
1369
+ // node_modules/axios/lib/core/transformData.js
1370
+ function transformData(fns, response) {
1371
+ const config = this || defaults_default;
1372
+ const context = response || config;
1373
+ const headers = AxiosHeaders_default.from(context.headers);
1374
+ let data = context.data;
1375
+ utils_default.forEach(fns, function transform(fn) {
1376
+ data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
1377
+ });
1378
+ headers.normalize();
1379
+ return data;
1380
+ }
1381
+
1382
+ // node_modules/axios/lib/cancel/isCancel.js
1383
+ function isCancel(value) {
1384
+ return !!(value && value.__CANCEL__);
1385
+ }
1386
+
1387
+ // node_modules/axios/lib/cancel/CanceledError.js
1388
+ function CanceledError(message, config, request) {
1389
+ AxiosError_default.call(this, message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request);
1390
+ this.name = "CanceledError";
1391
+ }
1392
+ utils_default.inherits(CanceledError, AxiosError_default, {
1393
+ __CANCEL__: true
1394
+ });
1395
+ var CanceledError_default = CanceledError;
1396
+
1397
+ // node_modules/axios/lib/core/settle.js
1398
+ function settle(resolve, reject, response) {
1399
+ const validateStatus2 = response.config.validateStatus;
1400
+ if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
1401
+ resolve(response);
1402
+ } else {
1403
+ reject(new AxiosError_default(
1404
+ "Request failed with status code " + response.status,
1405
+ [AxiosError_default.ERR_BAD_REQUEST, AxiosError_default.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
1406
+ response.config,
1407
+ response.request,
1408
+ response
1409
+ ));
1410
+ }
1411
+ }
1412
+
1413
+ // node_modules/axios/lib/helpers/parseProtocol.js
1414
+ function parseProtocol(url) {
1415
+ const match = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
1416
+ return match && match[1] || "";
1417
+ }
1418
+
1419
+ // node_modules/axios/lib/helpers/speedometer.js
1420
+ function speedometer(samplesCount, min) {
1421
+ samplesCount = samplesCount || 10;
1422
+ const bytes = new Array(samplesCount);
1423
+ const timestamps = new Array(samplesCount);
1424
+ let head = 0;
1425
+ let tail = 0;
1426
+ let firstSampleTS;
1427
+ min = min !== void 0 ? min : 1e3;
1428
+ return function push(chunkLength) {
1429
+ const now = Date.now();
1430
+ const startedAt = timestamps[tail];
1431
+ if (!firstSampleTS) {
1432
+ firstSampleTS = now;
1433
+ }
1434
+ bytes[head] = chunkLength;
1435
+ timestamps[head] = now;
1436
+ let i = tail;
1437
+ let bytesCount = 0;
1438
+ while (i !== head) {
1439
+ bytesCount += bytes[i++];
1440
+ i = i % samplesCount;
1441
+ }
1442
+ head = (head + 1) % samplesCount;
1443
+ if (head === tail) {
1444
+ tail = (tail + 1) % samplesCount;
1445
+ }
1446
+ if (now - firstSampleTS < min) {
1447
+ return;
1448
+ }
1449
+ const passed = startedAt && now - startedAt;
1450
+ return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
1451
+ };
1452
+ }
1453
+ var speedometer_default = speedometer;
1454
+
1455
+ // node_modules/axios/lib/helpers/throttle.js
1456
+ function throttle(fn, freq) {
1457
+ let timestamp = 0;
1458
+ let threshold = 1e3 / freq;
1459
+ let lastArgs;
1460
+ let timer;
1461
+ const invoke = (args, now = Date.now()) => {
1462
+ timestamp = now;
1463
+ lastArgs = null;
1464
+ if (timer) {
1465
+ clearTimeout(timer);
1466
+ timer = null;
1467
+ }
1468
+ fn.apply(null, args);
1469
+ };
1470
+ const throttled = (...args) => {
1471
+ const now = Date.now();
1472
+ const passed = now - timestamp;
1473
+ if (passed >= threshold) {
1474
+ invoke(args, now);
1475
+ } else {
1476
+ lastArgs = args;
1477
+ if (!timer) {
1478
+ timer = setTimeout(() => {
1479
+ timer = null;
1480
+ invoke(lastArgs);
1481
+ }, threshold - passed);
1482
+ }
1483
+ }
1484
+ };
1485
+ const flush = () => lastArgs && invoke(lastArgs);
1486
+ return [throttled, flush];
1487
+ }
1488
+ var throttle_default = throttle;
1489
+
1490
+ // node_modules/axios/lib/helpers/progressEventReducer.js
1491
+ var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
1492
+ let bytesNotified = 0;
1493
+ const _speedometer = speedometer_default(50, 250);
1494
+ return throttle_default((e) => {
1495
+ const loaded = e.loaded;
1496
+ const total = e.lengthComputable ? e.total : void 0;
1497
+ const progressBytes = loaded - bytesNotified;
1498
+ const rate = _speedometer(progressBytes);
1499
+ const inRange = loaded <= total;
1500
+ bytesNotified = loaded;
1501
+ const data = {
1502
+ loaded,
1503
+ total,
1504
+ progress: total ? loaded / total : void 0,
1505
+ bytes: progressBytes,
1506
+ rate: rate ? rate : void 0,
1507
+ estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
1508
+ event: e,
1509
+ lengthComputable: total != null,
1510
+ [isDownloadStream ? "download" : "upload"]: true
1511
+ };
1512
+ listener(data);
1513
+ }, freq);
1514
+ };
1515
+ var progressEventDecorator = (total, throttled) => {
1516
+ const lengthComputable = total != null;
1517
+ return [(loaded) => throttled[0]({
1518
+ lengthComputable,
1519
+ total,
1520
+ loaded
1521
+ }), throttled[1]];
1522
+ };
1523
+ var asyncDecorator = (fn) => (...args) => utils_default.asap(() => fn(...args));
1524
+
1525
+ // node_modules/axios/lib/helpers/isURLSameOrigin.js
1526
+ var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? (
1527
+ // Standard browser envs have full support of the APIs needed to test
1528
+ // whether the request URL is of the same origin as current location.
1529
+ function standardBrowserEnv() {
1530
+ const msie = platform_default.navigator && /(msie|trident)/i.test(platform_default.navigator.userAgent);
1531
+ const urlParsingNode = document.createElement("a");
1532
+ let originURL;
1533
+ function resolveURL(url) {
1534
+ let href = url;
1535
+ if (msie) {
1536
+ urlParsingNode.setAttribute("href", href);
1537
+ href = urlParsingNode.href;
1538
+ }
1539
+ urlParsingNode.setAttribute("href", href);
1540
+ return {
1541
+ href: urlParsingNode.href,
1542
+ protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, "") : "",
1543
+ host: urlParsingNode.host,
1544
+ search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, "") : "",
1545
+ hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, "") : "",
1546
+ hostname: urlParsingNode.hostname,
1547
+ port: urlParsingNode.port,
1548
+ pathname: urlParsingNode.pathname.charAt(0) === "/" ? urlParsingNode.pathname : "/" + urlParsingNode.pathname
1549
+ };
1550
+ }
1551
+ originURL = resolveURL(window.location.href);
1552
+ return function isURLSameOrigin(requestURL) {
1553
+ const parsed = utils_default.isString(requestURL) ? resolveURL(requestURL) : requestURL;
1554
+ return parsed.protocol === originURL.protocol && parsed.host === originURL.host;
1555
+ };
1556
+ }()
1557
+ ) : (
1558
+ // Non standard browser envs (web workers, react-native) lack needed support.
1559
+ function nonStandardBrowserEnv() {
1560
+ return function isURLSameOrigin() {
1561
+ return true;
1562
+ };
1563
+ }()
1564
+ );
1565
+
1566
+ // node_modules/axios/lib/helpers/cookies.js
1567
+ var cookies_default = platform_default.hasStandardBrowserEnv ? (
1568
+ // Standard browser envs support document.cookie
1569
+ {
1570
+ write(name, value, expires, path, domain, secure) {
1571
+ const cookie = [name + "=" + encodeURIComponent(value)];
1572
+ utils_default.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
1573
+ utils_default.isString(path) && cookie.push("path=" + path);
1574
+ utils_default.isString(domain) && cookie.push("domain=" + domain);
1575
+ secure === true && cookie.push("secure");
1576
+ document.cookie = cookie.join("; ");
1577
+ },
1578
+ read(name) {
1579
+ const match = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
1580
+ return match ? decodeURIComponent(match[3]) : null;
1581
+ },
1582
+ remove(name) {
1583
+ this.write(name, "", Date.now() - 864e5);
1584
+ }
1585
+ }
1586
+ ) : (
1587
+ // Non-standard browser env (web workers, react-native) lack needed support.
1588
+ {
1589
+ write() {
1590
+ },
1591
+ read() {
1592
+ return null;
1593
+ },
1594
+ remove() {
1595
+ }
1596
+ }
1597
+ );
1598
+
1599
+ // node_modules/axios/lib/helpers/isAbsoluteURL.js
1600
+ function isAbsoluteURL(url) {
1601
+ return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
1602
+ }
1603
+
1604
+ // node_modules/axios/lib/helpers/combineURLs.js
1605
+ function combineURLs(baseURL, relativeURL) {
1606
+ return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
1607
+ }
1608
+
1609
+ // node_modules/axios/lib/core/buildFullPath.js
1610
+ function buildFullPath(baseURL, requestedURL) {
1611
+ if (baseURL && !isAbsoluteURL(requestedURL)) {
1612
+ return combineURLs(baseURL, requestedURL);
1613
+ }
1614
+ return requestedURL;
1615
+ }
1616
+
1617
+ // node_modules/axios/lib/core/mergeConfig.js
1618
+ var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
1619
+ function mergeConfig(config1, config2) {
1620
+ config2 = config2 || {};
1621
+ const config = {};
1622
+ function getMergedValue(target, source, caseless) {
1623
+ if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
1624
+ return utils_default.merge.call({ caseless }, target, source);
1625
+ } else if (utils_default.isPlainObject(source)) {
1626
+ return utils_default.merge({}, source);
1627
+ } else if (utils_default.isArray(source)) {
1628
+ return source.slice();
1629
+ }
1630
+ return source;
1631
+ }
1632
+ function mergeDeepProperties(a, b, caseless) {
1633
+ if (!utils_default.isUndefined(b)) {
1634
+ return getMergedValue(a, b, caseless);
1635
+ } else if (!utils_default.isUndefined(a)) {
1636
+ return getMergedValue(void 0, a, caseless);
1637
+ }
1638
+ }
1639
+ function valueFromConfig2(a, b) {
1640
+ if (!utils_default.isUndefined(b)) {
1641
+ return getMergedValue(void 0, b);
1642
+ }
1643
+ }
1644
+ function defaultToConfig2(a, b) {
1645
+ if (!utils_default.isUndefined(b)) {
1646
+ return getMergedValue(void 0, b);
1647
+ } else if (!utils_default.isUndefined(a)) {
1648
+ return getMergedValue(void 0, a);
1649
+ }
1650
+ }
1651
+ function mergeDirectKeys(a, b, prop) {
1652
+ if (prop in config2) {
1653
+ return getMergedValue(a, b);
1654
+ } else if (prop in config1) {
1655
+ return getMergedValue(void 0, a);
1656
+ }
1657
+ }
1658
+ const mergeMap = {
1659
+ url: valueFromConfig2,
1660
+ method: valueFromConfig2,
1661
+ data: valueFromConfig2,
1662
+ baseURL: defaultToConfig2,
1663
+ transformRequest: defaultToConfig2,
1664
+ transformResponse: defaultToConfig2,
1665
+ paramsSerializer: defaultToConfig2,
1666
+ timeout: defaultToConfig2,
1667
+ timeoutMessage: defaultToConfig2,
1668
+ withCredentials: defaultToConfig2,
1669
+ withXSRFToken: defaultToConfig2,
1670
+ adapter: defaultToConfig2,
1671
+ responseType: defaultToConfig2,
1672
+ xsrfCookieName: defaultToConfig2,
1673
+ xsrfHeaderName: defaultToConfig2,
1674
+ onUploadProgress: defaultToConfig2,
1675
+ onDownloadProgress: defaultToConfig2,
1676
+ decompress: defaultToConfig2,
1677
+ maxContentLength: defaultToConfig2,
1678
+ maxBodyLength: defaultToConfig2,
1679
+ beforeRedirect: defaultToConfig2,
1680
+ transport: defaultToConfig2,
1681
+ httpAgent: defaultToConfig2,
1682
+ httpsAgent: defaultToConfig2,
1683
+ cancelToken: defaultToConfig2,
1684
+ socketPath: defaultToConfig2,
1685
+ responseEncoding: defaultToConfig2,
1686
+ validateStatus: mergeDirectKeys,
1687
+ headers: (a, b) => mergeDeepProperties(headersToObject(a), headersToObject(b), true)
1688
+ };
1689
+ utils_default.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
1690
+ const merge2 = mergeMap[prop] || mergeDeepProperties;
1691
+ const configValue = merge2(config1[prop], config2[prop], prop);
1692
+ utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
1693
+ });
1694
+ return config;
1695
+ }
1696
+
1697
+ // node_modules/axios/lib/helpers/resolveConfig.js
1698
+ var resolveConfig_default = (config) => {
1699
+ const newConfig = mergeConfig({}, config);
1700
+ let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
1701
+ newConfig.headers = headers = AxiosHeaders_default.from(headers);
1702
+ newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
1703
+ if (auth) {
1704
+ headers.set(
1705
+ "Authorization",
1706
+ "Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
1707
+ );
1708
+ }
1709
+ let contentType;
1710
+ if (utils_default.isFormData(data)) {
1711
+ if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv) {
1712
+ headers.setContentType(void 0);
1713
+ } else if ((contentType = headers.getContentType()) !== false) {
1714
+ const [type, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
1715
+ headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
1716
+ }
1717
+ }
1718
+ if (platform_default.hasStandardBrowserEnv) {
1719
+ withXSRFToken && utils_default.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
1720
+ if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin_default(newConfig.url)) {
1721
+ const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
1722
+ if (xsrfValue) {
1723
+ headers.set(xsrfHeaderName, xsrfValue);
1724
+ }
1725
+ }
1726
+ }
1727
+ return newConfig;
1728
+ };
1729
+
1730
+ // node_modules/axios/lib/adapters/xhr.js
1731
+ var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
1732
+ var xhr_default = isXHRAdapterSupported && function(config) {
1733
+ return new Promise(function dispatchXhrRequest(resolve, reject) {
1734
+ const _config = resolveConfig_default(config);
1735
+ let requestData = _config.data;
1736
+ const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
1737
+ let { responseType, onUploadProgress, onDownloadProgress } = _config;
1738
+ let onCanceled;
1739
+ let uploadThrottled, downloadThrottled;
1740
+ let flushUpload, flushDownload;
1741
+ function done() {
1742
+ flushUpload && flushUpload();
1743
+ flushDownload && flushDownload();
1744
+ _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
1745
+ _config.signal && _config.signal.removeEventListener("abort", onCanceled);
1746
+ }
1747
+ let request = new XMLHttpRequest();
1748
+ request.open(_config.method.toUpperCase(), _config.url, true);
1749
+ request.timeout = _config.timeout;
1750
+ function onloadend() {
1751
+ if (!request) {
1752
+ return;
1753
+ }
1754
+ const responseHeaders = AxiosHeaders_default.from(
1755
+ "getAllResponseHeaders" in request && request.getAllResponseHeaders()
1756
+ );
1757
+ const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
1758
+ const response = {
1759
+ data: responseData,
1760
+ status: request.status,
1761
+ statusText: request.statusText,
1762
+ headers: responseHeaders,
1763
+ config,
1764
+ request
1765
+ };
1766
+ settle(function _resolve(value) {
1767
+ resolve(value);
1768
+ done();
1769
+ }, function _reject(err) {
1770
+ reject(err);
1771
+ done();
1772
+ }, response);
1773
+ request = null;
1774
+ }
1775
+ if ("onloadend" in request) {
1776
+ request.onloadend = onloadend;
1777
+ } else {
1778
+ request.onreadystatechange = function handleLoad() {
1779
+ if (!request || request.readyState !== 4) {
1780
+ return;
1781
+ }
1782
+ if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
1783
+ return;
1784
+ }
1785
+ setTimeout(onloadend);
1786
+ };
1787
+ }
1788
+ request.onabort = function handleAbort() {
1789
+ if (!request) {
1790
+ return;
1791
+ }
1792
+ reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
1793
+ request = null;
1794
+ };
1795
+ request.onerror = function handleError() {
1796
+ reject(new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request));
1797
+ request = null;
1798
+ };
1799
+ request.ontimeout = function handleTimeout() {
1800
+ let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
1801
+ const transitional2 = _config.transitional || transitional_default;
1802
+ if (_config.timeoutErrorMessage) {
1803
+ timeoutErrorMessage = _config.timeoutErrorMessage;
1804
+ }
1805
+ reject(new AxiosError_default(
1806
+ timeoutErrorMessage,
1807
+ transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
1808
+ config,
1809
+ request
1810
+ ));
1811
+ request = null;
1812
+ };
1813
+ requestData === void 0 && requestHeaders.setContentType(null);
1814
+ if ("setRequestHeader" in request) {
1815
+ utils_default.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
1816
+ request.setRequestHeader(key, val);
1817
+ });
1818
+ }
1819
+ if (!utils_default.isUndefined(_config.withCredentials)) {
1820
+ request.withCredentials = !!_config.withCredentials;
1821
+ }
1822
+ if (responseType && responseType !== "json") {
1823
+ request.responseType = _config.responseType;
1824
+ }
1825
+ if (onDownloadProgress) {
1826
+ [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
1827
+ request.addEventListener("progress", downloadThrottled);
1828
+ }
1829
+ if (onUploadProgress && request.upload) {
1830
+ [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
1831
+ request.upload.addEventListener("progress", uploadThrottled);
1832
+ request.upload.addEventListener("loadend", flushUpload);
1833
+ }
1834
+ if (_config.cancelToken || _config.signal) {
1835
+ onCanceled = (cancel) => {
1836
+ if (!request) {
1837
+ return;
1838
+ }
1839
+ reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
1840
+ request.abort();
1841
+ request = null;
1842
+ };
1843
+ _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
1844
+ if (_config.signal) {
1845
+ _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
1846
+ }
1847
+ }
1848
+ const protocol = parseProtocol(_config.url);
1849
+ if (protocol && platform_default.protocols.indexOf(protocol) === -1) {
1850
+ reject(new AxiosError_default("Unsupported protocol " + protocol + ":", AxiosError_default.ERR_BAD_REQUEST, config));
1851
+ return;
1852
+ }
1853
+ request.send(requestData || null);
1854
+ });
1855
+ };
1856
+
1857
+ // node_modules/axios/lib/helpers/composeSignals.js
1858
+ var composeSignals = (signals, timeout) => {
1859
+ const { length } = signals = signals ? signals.filter(Boolean) : [];
1860
+ if (timeout || length) {
1861
+ let controller = new AbortController();
1862
+ let aborted;
1863
+ const onabort = function(reason) {
1864
+ if (!aborted) {
1865
+ aborted = true;
1866
+ unsubscribe();
1867
+ const err = reason instanceof Error ? reason : this.reason;
1868
+ controller.abort(err instanceof AxiosError_default ? err : new CanceledError_default(err instanceof Error ? err.message : err));
1869
+ }
1870
+ };
1871
+ let timer = timeout && setTimeout(() => {
1872
+ timer = null;
1873
+ onabort(new AxiosError_default(`timeout ${timeout} of ms exceeded`, AxiosError_default.ETIMEDOUT));
1874
+ }, timeout);
1875
+ const unsubscribe = () => {
1876
+ if (signals) {
1877
+ timer && clearTimeout(timer);
1878
+ timer = null;
1879
+ signals.forEach((signal2) => {
1880
+ signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
1881
+ });
1882
+ signals = null;
1883
+ }
1884
+ };
1885
+ signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
1886
+ const { signal } = controller;
1887
+ signal.unsubscribe = () => utils_default.asap(unsubscribe);
1888
+ return signal;
1889
+ }
1890
+ };
1891
+ var composeSignals_default = composeSignals;
1892
+
1893
+ // node_modules/axios/lib/helpers/trackStream.js
1894
+ var streamChunk = function* (chunk, chunkSize) {
1895
+ let len = chunk.byteLength;
1896
+ if (!chunkSize || len < chunkSize) {
1897
+ yield chunk;
1898
+ return;
1899
+ }
1900
+ let pos = 0;
1901
+ let end;
1902
+ while (pos < len) {
1903
+ end = pos + chunkSize;
1904
+ yield chunk.slice(pos, end);
1905
+ pos = end;
1906
+ }
1907
+ };
1908
+ var readBytes = async function* (iterable, chunkSize) {
1909
+ for await (const chunk of readStream(iterable)) {
1910
+ yield* streamChunk(chunk, chunkSize);
1911
+ }
1912
+ };
1913
+ var readStream = async function* (stream) {
1914
+ if (stream[Symbol.asyncIterator]) {
1915
+ yield* stream;
1916
+ return;
1917
+ }
1918
+ const reader = stream.getReader();
1919
+ try {
1920
+ for (; ; ) {
1921
+ const { done, value } = await reader.read();
1922
+ if (done) {
1923
+ break;
1924
+ }
1925
+ yield value;
1926
+ }
1927
+ } finally {
1928
+ await reader.cancel();
1929
+ }
1930
+ };
1931
+ var trackStream = (stream, chunkSize, onProgress, onFinish) => {
1932
+ const iterator = readBytes(stream, chunkSize);
1933
+ let bytes = 0;
1934
+ let done;
1935
+ let _onFinish = (e) => {
1936
+ if (!done) {
1937
+ done = true;
1938
+ onFinish && onFinish(e);
1939
+ }
1940
+ };
1941
+ return new ReadableStream({
1942
+ async pull(controller) {
1943
+ try {
1944
+ const { done: done2, value } = await iterator.next();
1945
+ if (done2) {
1946
+ _onFinish();
1947
+ controller.close();
1948
+ return;
1949
+ }
1950
+ let len = value.byteLength;
1951
+ if (onProgress) {
1952
+ let loadedBytes = bytes += len;
1953
+ onProgress(loadedBytes);
1954
+ }
1955
+ controller.enqueue(new Uint8Array(value));
1956
+ } catch (err) {
1957
+ _onFinish(err);
1958
+ throw err;
1959
+ }
1960
+ },
1961
+ cancel(reason) {
1962
+ _onFinish(reason);
1963
+ return iterator.return();
1964
+ }
1965
+ }, {
1966
+ highWaterMark: 2
1967
+ });
1968
+ };
1969
+
1970
+ // node_modules/axios/lib/adapters/fetch.js
1971
+ var isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
1972
+ var isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
1973
+ var encodeText = isFetchSupported && (typeof TextEncoder === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
1974
+ var test = (fn, ...args) => {
1975
+ try {
1976
+ return !!fn(...args);
1977
+ } catch (e) {
1978
+ return false;
1979
+ }
1980
+ };
1981
+ var supportsRequestStream = isReadableStreamSupported && test(() => {
1982
+ let duplexAccessed = false;
1983
+ const hasContentType = new Request(platform_default.origin, {
1984
+ body: new ReadableStream(),
1985
+ method: "POST",
1986
+ get duplex() {
1987
+ duplexAccessed = true;
1988
+ return "half";
1989
+ }
1990
+ }).headers.has("Content-Type");
1991
+ return duplexAccessed && !hasContentType;
1992
+ });
1993
+ var DEFAULT_CHUNK_SIZE = 64 * 1024;
1994
+ var supportsResponseStream = isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
1995
+ var resolvers = {
1996
+ stream: supportsResponseStream && ((res) => res.body)
1997
+ };
1998
+ isFetchSupported && ((res) => {
1999
+ ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
2000
+ !resolvers[type] && (resolvers[type] = utils_default.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
2001
+ throw new AxiosError_default(`Response type '${type}' is not supported`, AxiosError_default.ERR_NOT_SUPPORT, config);
2002
+ });
2003
+ });
2004
+ })(new Response());
2005
+ var getBodyLength = async (body) => {
2006
+ if (body == null) {
2007
+ return 0;
2008
+ }
2009
+ if (utils_default.isBlob(body)) {
2010
+ return body.size;
2011
+ }
2012
+ if (utils_default.isSpecCompliantForm(body)) {
2013
+ const _request = new Request(platform_default.origin, {
2014
+ method: "POST",
2015
+ body
2016
+ });
2017
+ return (await _request.arrayBuffer()).byteLength;
2018
+ }
2019
+ if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
2020
+ return body.byteLength;
2021
+ }
2022
+ if (utils_default.isURLSearchParams(body)) {
2023
+ body = body + "";
2024
+ }
2025
+ if (utils_default.isString(body)) {
2026
+ return (await encodeText(body)).byteLength;
2027
+ }
2028
+ };
2029
+ var resolveBodyLength = async (headers, body) => {
2030
+ const length = utils_default.toFiniteNumber(headers.getContentLength());
2031
+ return length == null ? getBodyLength(body) : length;
2032
+ };
2033
+ var fetch_default = isFetchSupported && (async (config) => {
2034
+ let {
2035
+ url,
2036
+ method,
2037
+ data,
2038
+ signal,
2039
+ cancelToken,
2040
+ timeout,
2041
+ onDownloadProgress,
2042
+ onUploadProgress,
2043
+ responseType,
2044
+ headers,
2045
+ withCredentials = "same-origin",
2046
+ fetchOptions
2047
+ } = resolveConfig_default(config);
2048
+ responseType = responseType ? (responseType + "").toLowerCase() : "text";
2049
+ let composedSignal = composeSignals_default([signal, cancelToken && cancelToken.toAbortSignal()], timeout);
2050
+ let request;
2051
+ const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
2052
+ composedSignal.unsubscribe();
2053
+ });
2054
+ let requestContentLength;
2055
+ try {
2056
+ if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
2057
+ let _request = new Request(url, {
2058
+ method: "POST",
2059
+ body: data,
2060
+ duplex: "half"
2061
+ });
2062
+ let contentTypeHeader;
2063
+ if (utils_default.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
2064
+ headers.setContentType(contentTypeHeader);
2065
+ }
2066
+ if (_request.body) {
2067
+ const [onProgress, flush] = progressEventDecorator(
2068
+ requestContentLength,
2069
+ progressEventReducer(asyncDecorator(onUploadProgress))
2070
+ );
2071
+ data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
2072
+ }
2073
+ }
2074
+ if (!utils_default.isString(withCredentials)) {
2075
+ withCredentials = withCredentials ? "include" : "omit";
2076
+ }
2077
+ const isCredentialsSupported = "credentials" in Request.prototype;
2078
+ request = new Request(url, {
2079
+ ...fetchOptions,
2080
+ signal: composedSignal,
2081
+ method: method.toUpperCase(),
2082
+ headers: headers.normalize().toJSON(),
2083
+ body: data,
2084
+ duplex: "half",
2085
+ credentials: isCredentialsSupported ? withCredentials : void 0
2086
+ });
2087
+ let response = await fetch(request);
2088
+ const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
2089
+ if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
2090
+ const options = {};
2091
+ ["status", "statusText", "headers"].forEach((prop) => {
2092
+ options[prop] = response[prop];
2093
+ });
2094
+ const responseContentLength = utils_default.toFiniteNumber(response.headers.get("content-length"));
2095
+ const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
2096
+ responseContentLength,
2097
+ progressEventReducer(asyncDecorator(onDownloadProgress), true)
2098
+ ) || [];
2099
+ response = new Response(
2100
+ trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
2101
+ flush && flush();
2102
+ unsubscribe && unsubscribe();
2103
+ }),
2104
+ options
2105
+ );
2106
+ }
2107
+ responseType = responseType || "text";
2108
+ let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](response, config);
2109
+ !isStreamResponse && unsubscribe && unsubscribe();
2110
+ return await new Promise((resolve, reject) => {
2111
+ settle(resolve, reject, {
2112
+ data: responseData,
2113
+ headers: AxiosHeaders_default.from(response.headers),
2114
+ status: response.status,
2115
+ statusText: response.statusText,
2116
+ config,
2117
+ request
2118
+ });
2119
+ });
2120
+ } catch (err) {
2121
+ unsubscribe && unsubscribe();
2122
+ if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
2123
+ throw Object.assign(
2124
+ new AxiosError_default("Network Error", AxiosError_default.ERR_NETWORK, config, request),
2125
+ {
2126
+ cause: err.cause || err
2127
+ }
2128
+ );
2129
+ }
2130
+ throw AxiosError_default.from(err, err && err.code, config, request);
2131
+ }
2132
+ });
2133
+
2134
+ // node_modules/axios/lib/adapters/adapters.js
2135
+ var knownAdapters = {
2136
+ http: null_default,
2137
+ xhr: xhr_default,
2138
+ fetch: fetch_default
2139
+ };
2140
+ utils_default.forEach(knownAdapters, (fn, value) => {
2141
+ if (fn) {
2142
+ try {
2143
+ Object.defineProperty(fn, "name", { value });
2144
+ } catch (e) {
2145
+ }
2146
+ Object.defineProperty(fn, "adapterName", { value });
2147
+ }
2148
+ });
2149
+ var renderReason = (reason) => `- ${reason}`;
2150
+ var isResolvedHandle = (adapter) => utils_default.isFunction(adapter) || adapter === null || adapter === false;
2151
+ var adapters_default = {
2152
+ getAdapter: (adapters) => {
2153
+ adapters = utils_default.isArray(adapters) ? adapters : [adapters];
2154
+ const { length } = adapters;
2155
+ let nameOrAdapter;
2156
+ let adapter;
2157
+ const rejectedReasons = {};
2158
+ for (let i = 0; i < length; i++) {
2159
+ nameOrAdapter = adapters[i];
2160
+ let id;
2161
+ adapter = nameOrAdapter;
2162
+ if (!isResolvedHandle(nameOrAdapter)) {
2163
+ adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
2164
+ if (adapter === void 0) {
2165
+ throw new AxiosError_default(`Unknown adapter '${id}'`);
2166
+ }
2167
+ }
2168
+ if (adapter) {
2169
+ break;
2170
+ }
2171
+ rejectedReasons[id || "#" + i] = adapter;
2172
+ }
2173
+ if (!adapter) {
2174
+ const reasons = Object.entries(rejectedReasons).map(
2175
+ ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
2176
+ );
2177
+ let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
2178
+ throw new AxiosError_default(
2179
+ `There is no suitable adapter to dispatch the request ` + s,
2180
+ "ERR_NOT_SUPPORT"
2181
+ );
2182
+ }
2183
+ return adapter;
2184
+ },
2185
+ adapters: knownAdapters
2186
+ };
2187
+
2188
+ // node_modules/axios/lib/core/dispatchRequest.js
2189
+ function throwIfCancellationRequested(config) {
2190
+ if (config.cancelToken) {
2191
+ config.cancelToken.throwIfRequested();
2192
+ }
2193
+ if (config.signal && config.signal.aborted) {
2194
+ throw new CanceledError_default(null, config);
2195
+ }
2196
+ }
2197
+ function dispatchRequest(config) {
2198
+ throwIfCancellationRequested(config);
2199
+ config.headers = AxiosHeaders_default.from(config.headers);
2200
+ config.data = transformData.call(
2201
+ config,
2202
+ config.transformRequest
2203
+ );
2204
+ if (["post", "put", "patch"].indexOf(config.method) !== -1) {
2205
+ config.headers.setContentType("application/x-www-form-urlencoded", false);
2206
+ }
2207
+ const adapter = adapters_default.getAdapter(config.adapter || defaults_default.adapter);
2208
+ return adapter(config).then(function onAdapterResolution(response) {
2209
+ throwIfCancellationRequested(config);
2210
+ response.data = transformData.call(
2211
+ config,
2212
+ config.transformResponse,
2213
+ response
2214
+ );
2215
+ response.headers = AxiosHeaders_default.from(response.headers);
2216
+ return response;
2217
+ }, function onAdapterRejection(reason) {
2218
+ if (!isCancel(reason)) {
2219
+ throwIfCancellationRequested(config);
2220
+ if (reason && reason.response) {
2221
+ reason.response.data = transformData.call(
2222
+ config,
2223
+ config.transformResponse,
2224
+ reason.response
2225
+ );
2226
+ reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
2227
+ }
2228
+ }
2229
+ return Promise.reject(reason);
2230
+ });
2231
+ }
2232
+
2233
+ // node_modules/axios/lib/env/data.js
2234
+ var VERSION = "1.7.7";
2235
+
2236
+ // node_modules/axios/lib/helpers/validator.js
2237
+ var validators = {};
2238
+ ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2239
+ validators[type] = function validator(thing) {
2240
+ return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
2241
+ };
2242
+ });
2243
+ var deprecatedWarnings = {};
2244
+ validators.transitional = function transitional(validator, version, message) {
2245
+ function formatMessage(opt, desc) {
2246
+ return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
2247
+ }
2248
+ return (value, opt, opts) => {
2249
+ if (validator === false) {
2250
+ throw new AxiosError_default(
2251
+ formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
2252
+ AxiosError_default.ERR_DEPRECATED
2253
+ );
2254
+ }
2255
+ if (version && !deprecatedWarnings[opt]) {
2256
+ deprecatedWarnings[opt] = true;
2257
+ console.warn(
2258
+ formatMessage(
2259
+ opt,
2260
+ " has been deprecated since v" + version + " and will be removed in the near future"
2261
+ )
2262
+ );
2263
+ }
2264
+ return validator ? validator(value, opt, opts) : true;
2265
+ };
2266
+ };
2267
+ function assertOptions(options, schema, allowUnknown) {
2268
+ if (typeof options !== "object") {
2269
+ throw new AxiosError_default("options must be an object", AxiosError_default.ERR_BAD_OPTION_VALUE);
2270
+ }
2271
+ const keys = Object.keys(options);
2272
+ let i = keys.length;
2273
+ while (i-- > 0) {
2274
+ const opt = keys[i];
2275
+ const validator = schema[opt];
2276
+ if (validator) {
2277
+ const value = options[opt];
2278
+ const result = value === void 0 || validator(value, opt, options);
2279
+ if (result !== true) {
2280
+ throw new AxiosError_default("option " + opt + " must be " + result, AxiosError_default.ERR_BAD_OPTION_VALUE);
2281
+ }
2282
+ continue;
2283
+ }
2284
+ if (allowUnknown !== true) {
2285
+ throw new AxiosError_default("Unknown option " + opt, AxiosError_default.ERR_BAD_OPTION);
2286
+ }
2287
+ }
2288
+ }
2289
+ var validator_default = {
2290
+ assertOptions,
2291
+ validators
2292
+ };
2293
+
2294
+ // node_modules/axios/lib/core/Axios.js
2295
+ var validators2 = validator_default.validators;
2296
+ var Axios = class {
2297
+ constructor(instanceConfig) {
2298
+ this.defaults = instanceConfig;
2299
+ this.interceptors = {
2300
+ request: new InterceptorManager_default(),
2301
+ response: new InterceptorManager_default()
2302
+ };
2303
+ }
2304
+ /**
2305
+ * Dispatch a request
2306
+ *
2307
+ * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
2308
+ * @param {?Object} config
2309
+ *
2310
+ * @returns {Promise} The Promise to be fulfilled
2311
+ */
2312
+ async request(configOrUrl, config) {
2313
+ try {
2314
+ return await this._request(configOrUrl, config);
2315
+ } catch (err) {
2316
+ if (err instanceof Error) {
2317
+ let dummy;
2318
+ Error.captureStackTrace ? Error.captureStackTrace(dummy = {}) : dummy = new Error();
2319
+ const stack = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
2320
+ try {
2321
+ if (!err.stack) {
2322
+ err.stack = stack;
2323
+ } else if (stack && !String(err.stack).endsWith(stack.replace(/^.+\n.+\n/, ""))) {
2324
+ err.stack += "\n" + stack;
2325
+ }
2326
+ } catch (e) {
2327
+ }
2328
+ }
2329
+ throw err;
2330
+ }
2331
+ }
2332
+ _request(configOrUrl, config) {
2333
+ if (typeof configOrUrl === "string") {
2334
+ config = config || {};
2335
+ config.url = configOrUrl;
2336
+ } else {
2337
+ config = configOrUrl || {};
2338
+ }
2339
+ config = mergeConfig(this.defaults, config);
2340
+ const { transitional: transitional2, paramsSerializer, headers } = config;
2341
+ if (transitional2 !== void 0) {
2342
+ validator_default.assertOptions(transitional2, {
2343
+ silentJSONParsing: validators2.transitional(validators2.boolean),
2344
+ forcedJSONParsing: validators2.transitional(validators2.boolean),
2345
+ clarifyTimeoutError: validators2.transitional(validators2.boolean)
2346
+ }, false);
2347
+ }
2348
+ if (paramsSerializer != null) {
2349
+ if (utils_default.isFunction(paramsSerializer)) {
2350
+ config.paramsSerializer = {
2351
+ serialize: paramsSerializer
2352
+ };
2353
+ } else {
2354
+ validator_default.assertOptions(paramsSerializer, {
2355
+ encode: validators2.function,
2356
+ serialize: validators2.function
2357
+ }, true);
2358
+ }
2359
+ }
2360
+ config.method = (config.method || this.defaults.method || "get").toLowerCase();
2361
+ let contextHeaders = headers && utils_default.merge(
2362
+ headers.common,
2363
+ headers[config.method]
2364
+ );
2365
+ headers && utils_default.forEach(
2366
+ ["delete", "get", "head", "post", "put", "patch", "common"],
2367
+ (method) => {
2368
+ delete headers[method];
2369
+ }
2370
+ );
2371
+ config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
2372
+ const requestInterceptorChain = [];
2373
+ let synchronousRequestInterceptors = true;
2374
+ this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
2375
+ if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
2376
+ return;
2377
+ }
2378
+ synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
2379
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
2380
+ });
2381
+ const responseInterceptorChain = [];
2382
+ this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
2383
+ responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
2384
+ });
2385
+ let promise;
2386
+ let i = 0;
2387
+ let len;
2388
+ if (!synchronousRequestInterceptors) {
2389
+ const chain = [dispatchRequest.bind(this), void 0];
2390
+ chain.unshift.apply(chain, requestInterceptorChain);
2391
+ chain.push.apply(chain, responseInterceptorChain);
2392
+ len = chain.length;
2393
+ promise = Promise.resolve(config);
2394
+ while (i < len) {
2395
+ promise = promise.then(chain[i++], chain[i++]);
2396
+ }
2397
+ return promise;
2398
+ }
2399
+ len = requestInterceptorChain.length;
2400
+ let newConfig = config;
2401
+ i = 0;
2402
+ while (i < len) {
2403
+ const onFulfilled = requestInterceptorChain[i++];
2404
+ const onRejected = requestInterceptorChain[i++];
2405
+ try {
2406
+ newConfig = onFulfilled(newConfig);
2407
+ } catch (error) {
2408
+ onRejected.call(this, error);
2409
+ break;
2410
+ }
2411
+ }
2412
+ try {
2413
+ promise = dispatchRequest.call(this, newConfig);
2414
+ } catch (error) {
2415
+ return Promise.reject(error);
2416
+ }
2417
+ i = 0;
2418
+ len = responseInterceptorChain.length;
2419
+ while (i < len) {
2420
+ promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
2421
+ }
2422
+ return promise;
2423
+ }
2424
+ getUri(config) {
2425
+ config = mergeConfig(this.defaults, config);
2426
+ const fullPath = buildFullPath(config.baseURL, config.url);
2427
+ return buildURL(fullPath, config.params, config.paramsSerializer);
2428
+ }
2429
+ };
2430
+ utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
2431
+ Axios.prototype[method] = function(url, config) {
2432
+ return this.request(mergeConfig(config || {}, {
2433
+ method,
2434
+ url,
2435
+ data: (config || {}).data
2436
+ }));
2437
+ };
2438
+ });
2439
+ utils_default.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
2440
+ function generateHTTPMethod(isForm) {
2441
+ return function httpMethod(url, data, config) {
2442
+ return this.request(mergeConfig(config || {}, {
2443
+ method,
2444
+ headers: isForm ? {
2445
+ "Content-Type": "multipart/form-data"
2446
+ } : {},
2447
+ url,
2448
+ data
2449
+ }));
2450
+ };
2451
+ }
2452
+ Axios.prototype[method] = generateHTTPMethod();
2453
+ Axios.prototype[method + "Form"] = generateHTTPMethod(true);
2454
+ });
2455
+ var Axios_default = Axios;
2456
+
2457
+ // node_modules/axios/lib/cancel/CancelToken.js
2458
+ var CancelToken = class _CancelToken {
2459
+ constructor(executor) {
2460
+ if (typeof executor !== "function") {
2461
+ throw new TypeError("executor must be a function.");
2462
+ }
2463
+ let resolvePromise;
2464
+ this.promise = new Promise(function promiseExecutor(resolve) {
2465
+ resolvePromise = resolve;
2466
+ });
2467
+ const token = this;
2468
+ this.promise.then((cancel) => {
2469
+ if (!token._listeners)
2470
+ return;
2471
+ let i = token._listeners.length;
2472
+ while (i-- > 0) {
2473
+ token._listeners[i](cancel);
2474
+ }
2475
+ token._listeners = null;
2476
+ });
2477
+ this.promise.then = (onfulfilled) => {
2478
+ let _resolve;
2479
+ const promise = new Promise((resolve) => {
2480
+ token.subscribe(resolve);
2481
+ _resolve = resolve;
2482
+ }).then(onfulfilled);
2483
+ promise.cancel = function reject() {
2484
+ token.unsubscribe(_resolve);
2485
+ };
2486
+ return promise;
2487
+ };
2488
+ executor(function cancel(message, config, request) {
2489
+ if (token.reason) {
2490
+ return;
2491
+ }
2492
+ token.reason = new CanceledError_default(message, config, request);
2493
+ resolvePromise(token.reason);
2494
+ });
2495
+ }
2496
+ /**
2497
+ * Throws a `CanceledError` if cancellation has been requested.
2498
+ */
2499
+ throwIfRequested() {
2500
+ if (this.reason) {
2501
+ throw this.reason;
2502
+ }
2503
+ }
2504
+ /**
2505
+ * Subscribe to the cancel signal
2506
+ */
2507
+ subscribe(listener) {
2508
+ if (this.reason) {
2509
+ listener(this.reason);
2510
+ return;
2511
+ }
2512
+ if (this._listeners) {
2513
+ this._listeners.push(listener);
2514
+ } else {
2515
+ this._listeners = [listener];
2516
+ }
2517
+ }
2518
+ /**
2519
+ * Unsubscribe from the cancel signal
2520
+ */
2521
+ unsubscribe(listener) {
2522
+ if (!this._listeners) {
2523
+ return;
2524
+ }
2525
+ const index = this._listeners.indexOf(listener);
2526
+ if (index !== -1) {
2527
+ this._listeners.splice(index, 1);
2528
+ }
2529
+ }
2530
+ toAbortSignal() {
2531
+ const controller = new AbortController();
2532
+ const abort = (err) => {
2533
+ controller.abort(err);
2534
+ };
2535
+ this.subscribe(abort);
2536
+ controller.signal.unsubscribe = () => this.unsubscribe(abort);
2537
+ return controller.signal;
2538
+ }
2539
+ /**
2540
+ * Returns an object that contains a new `CancelToken` and a function that, when called,
2541
+ * cancels the `CancelToken`.
2542
+ */
2543
+ static source() {
2544
+ let cancel;
2545
+ const token = new _CancelToken(function executor(c) {
2546
+ cancel = c;
2547
+ });
2548
+ return {
2549
+ token,
2550
+ cancel
2551
+ };
2552
+ }
2553
+ };
2554
+ var CancelToken_default = CancelToken;
2555
+
2556
+ // node_modules/axios/lib/helpers/spread.js
2557
+ function spread(callback) {
2558
+ return function wrap(arr) {
2559
+ return callback.apply(null, arr);
2560
+ };
2561
+ }
2562
+
2563
+ // node_modules/axios/lib/helpers/isAxiosError.js
2564
+ function isAxiosError(payload) {
2565
+ return utils_default.isObject(payload) && payload.isAxiosError === true;
2566
+ }
2567
+
2568
+ // node_modules/axios/lib/helpers/HttpStatusCode.js
2569
+ var HttpStatusCode = {
2570
+ Continue: 100,
2571
+ SwitchingProtocols: 101,
2572
+ Processing: 102,
2573
+ EarlyHints: 103,
2574
+ Ok: 200,
2575
+ Created: 201,
2576
+ Accepted: 202,
2577
+ NonAuthoritativeInformation: 203,
2578
+ NoContent: 204,
2579
+ ResetContent: 205,
2580
+ PartialContent: 206,
2581
+ MultiStatus: 207,
2582
+ AlreadyReported: 208,
2583
+ ImUsed: 226,
2584
+ MultipleChoices: 300,
2585
+ MovedPermanently: 301,
2586
+ Found: 302,
2587
+ SeeOther: 303,
2588
+ NotModified: 304,
2589
+ UseProxy: 305,
2590
+ Unused: 306,
2591
+ TemporaryRedirect: 307,
2592
+ PermanentRedirect: 308,
2593
+ BadRequest: 400,
2594
+ Unauthorized: 401,
2595
+ PaymentRequired: 402,
2596
+ Forbidden: 403,
2597
+ NotFound: 404,
2598
+ MethodNotAllowed: 405,
2599
+ NotAcceptable: 406,
2600
+ ProxyAuthenticationRequired: 407,
2601
+ RequestTimeout: 408,
2602
+ Conflict: 409,
2603
+ Gone: 410,
2604
+ LengthRequired: 411,
2605
+ PreconditionFailed: 412,
2606
+ PayloadTooLarge: 413,
2607
+ UriTooLong: 414,
2608
+ UnsupportedMediaType: 415,
2609
+ RangeNotSatisfiable: 416,
2610
+ ExpectationFailed: 417,
2611
+ ImATeapot: 418,
2612
+ MisdirectedRequest: 421,
2613
+ UnprocessableEntity: 422,
2614
+ Locked: 423,
2615
+ FailedDependency: 424,
2616
+ TooEarly: 425,
2617
+ UpgradeRequired: 426,
2618
+ PreconditionRequired: 428,
2619
+ TooManyRequests: 429,
2620
+ RequestHeaderFieldsTooLarge: 431,
2621
+ UnavailableForLegalReasons: 451,
2622
+ InternalServerError: 500,
2623
+ NotImplemented: 501,
2624
+ BadGateway: 502,
2625
+ ServiceUnavailable: 503,
2626
+ GatewayTimeout: 504,
2627
+ HttpVersionNotSupported: 505,
2628
+ VariantAlsoNegotiates: 506,
2629
+ InsufficientStorage: 507,
2630
+ LoopDetected: 508,
2631
+ NotExtended: 510,
2632
+ NetworkAuthenticationRequired: 511
2633
+ };
2634
+ Object.entries(HttpStatusCode).forEach(([key, value]) => {
2635
+ HttpStatusCode[value] = key;
2636
+ });
2637
+ var HttpStatusCode_default = HttpStatusCode;
2638
+
2639
+ // node_modules/axios/lib/axios.js
2640
+ function createInstance(defaultConfig) {
2641
+ const context = new Axios_default(defaultConfig);
2642
+ const instance = bind(Axios_default.prototype.request, context);
2643
+ utils_default.extend(instance, Axios_default.prototype, context, { allOwnKeys: true });
2644
+ utils_default.extend(instance, context, null, { allOwnKeys: true });
2645
+ instance.create = function create(instanceConfig) {
2646
+ return createInstance(mergeConfig(defaultConfig, instanceConfig));
2647
+ };
2648
+ return instance;
2649
+ }
2650
+ var axios = createInstance(defaults_default);
2651
+ axios.Axios = Axios_default;
2652
+ axios.CanceledError = CanceledError_default;
2653
+ axios.CancelToken = CancelToken_default;
2654
+ axios.isCancel = isCancel;
2655
+ axios.VERSION = VERSION;
2656
+ axios.toFormData = toFormData_default;
2657
+ axios.AxiosError = AxiosError_default;
2658
+ axios.Cancel = axios.CanceledError;
2659
+ axios.all = function all(promises) {
2660
+ return Promise.all(promises);
2661
+ };
2662
+ axios.spread = spread;
2663
+ axios.isAxiosError = isAxiosError;
2664
+ axios.mergeConfig = mergeConfig;
2665
+ axios.AxiosHeaders = AxiosHeaders_default;
2666
+ axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
2667
+ axios.getAdapter = adapters_default.getAdapter;
2668
+ axios.HttpStatusCode = HttpStatusCode_default;
2669
+ axios.default = axios;
2670
+ var axios_default = axios;
2671
+
2672
+ // node_modules/axios/index.js
2673
+ var {
2674
+ Axios: Axios2,
2675
+ AxiosError: AxiosError2,
2676
+ CanceledError: CanceledError2,
2677
+ isCancel: isCancel2,
2678
+ CancelToken: CancelToken2,
2679
+ VERSION: VERSION2,
2680
+ all: all2,
2681
+ Cancel,
2682
+ isAxiosError: isAxiosError2,
2683
+ spread: spread2,
2684
+ toFormData: toFormData2,
2685
+ AxiosHeaders: AxiosHeaders2,
2686
+ HttpStatusCode: HttpStatusCode2,
2687
+ formToJSON,
2688
+ getAdapter,
2689
+ mergeConfig: mergeConfig2
2690
+ } = axios_default;
2691
+
2692
+ // src/api/ApiClient.ts
2693
+ var ApiClient = class {
2694
+ axiosClient;
2695
+ apiKey;
2696
+ appProjectId;
2697
+ constructor(baseUrl, apiKey, appProjectId) {
2698
+ this.apiKey = apiKey;
2699
+ this.appProjectId = appProjectId;
2700
+ this.axiosClient = axios_default.create({
2701
+ baseURL: baseUrl,
2702
+ headers: {
2703
+ "Content-Type": "application/json",
2704
+ "x-nana800-api-key": apiKey
2705
+ }
2706
+ });
2707
+ }
2708
+ async sendEvents(events) {
2709
+ const requestBody = {
2710
+ events: events.map((event) => ({
2711
+ analytics_event_name: event.analytics_event_name,
2712
+ user_id: event.user_id,
2713
+ properties: event.properties,
2714
+ event_time: event.event_time
2715
+ })),
2716
+ app_project_id: this.appProjectId,
2717
+ api_key: this.apiKey
2718
+ };
2719
+ const response = await this.axiosClient.post("/analytics_upload_data/tracked_events_list", requestBody).then(this.extractData);
2720
+ return response;
2721
+ }
2722
+ async sendUserProperties(userProps) {
2723
+ const requestBody = {
2724
+ list: userProps.map((prop) => ({
2725
+ user_id: prop.user_id,
2726
+ properties: prop.properties
2727
+ })),
2728
+ app_project_id: this.appProjectId,
2729
+ api_key: this.apiKey
2730
+ };
2731
+ const response = await this.axiosClient.post("/analytics_upload_data/identify_users_list", requestBody).then(this.extractData);
2732
+ return response;
2733
+ }
2734
+ extractData(resp) {
2735
+ return resp?.data;
2736
+ }
2737
+ };
2738
+
2739
+ // src/Nana800Analytics.ts
2740
+ var Nana800Analytics = class {
2741
+ config;
2742
+ eventsQueue = [];
2743
+ userPropsQueue = [];
2744
+ flushIntervalId = null;
2745
+ initialFlushTimeoutId = null;
2746
+ isInitialized = false;
2747
+ currentUserId = null;
2748
+ storageManager;
2749
+ apiClient;
2750
+ /**
2751
+ * Creates a new Nana800Analytics instance
2752
+ *
2753
+ * @param config - Configuration options for the analytics SDK
2754
+ */
2755
+ constructor(config) {
2756
+ this.config = {
2757
+ apiKey: config.apiKey,
2758
+ appProjectId: config.appProjectId,
2759
+ baseUrl: config.baseUrl,
2760
+ flushIntervalMs: config.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS,
2761
+ maxBatchSize: config.maxBatchSize ?? MAX_EVENTS_BATCH_SIZE,
2762
+ enableAutoFlush: config.enableAutoFlush ?? true,
2763
+ storageAdapter: config.storageAdapter,
2764
+ disableStorage: config.disableStorage,
2765
+ debug: config.debug
2766
+ };
2767
+ this.log("Constructor: Initializing Nana800Analytics SDK", {
2768
+ flushIntervalMs: this.config.flushIntervalMs,
2769
+ maxBatchSize: this.config.maxBatchSize,
2770
+ enableAutoFlush: this.config.enableAutoFlush,
2771
+ baseUrl: this.config.baseUrl || DEFAULT_BASE_URL
2772
+ });
2773
+ const platformType = detectPlatform();
2774
+ this.log("Constructor: Detected platform", { platformType });
2775
+ this.storageManager = new StorageManager(
2776
+ platformType,
2777
+ this.config.storageAdapter,
2778
+ this.config.disableStorage
2779
+ );
2780
+ this.apiClient = new ApiClient(
2781
+ this.config.baseUrl || DEFAULT_BASE_URL,
2782
+ this.config.apiKey,
2783
+ this.config.appProjectId
2784
+ );
2785
+ this.loadFromStorage();
2786
+ }
2787
+ /**
2788
+ * Initializes the analytics SDK and starts automatic event flushing
2789
+ *
2790
+ * @returns true if initialization was successful
2791
+ */
2792
+ init() {
2793
+ if (this.isInitialized) {
2794
+ console.warn("Nana800Analytics: Already initialized");
2795
+ return false;
2796
+ }
2797
+ this.log("Init: Starting SDK initialization");
2798
+ this.isInitialized = true;
2799
+ if (this.config.enableAutoFlush) {
2800
+ this.log("Init: Auto-flush is enabled, starting auto-flush mechanism");
2801
+ this.startAutoFlush();
2802
+ this.log(`Init: Scheduling initial flush in ${INITIAL_FLUSH_DELAY_MS}ms`);
2803
+ this.initialFlushTimeoutId = setTimeout(() => {
2804
+ this.log("Init: Executing initial flush");
2805
+ this.flush().catch((error) => {
2806
+ console.error("Nana800Analytics: Initial flush error:", error);
2807
+ });
2808
+ }, INITIAL_FLUSH_DELAY_MS);
2809
+ } else {
2810
+ this.log("Init: Auto-flush is disabled");
2811
+ }
2812
+ this.log("Init: SDK initialized successfully");
2813
+ return true;
2814
+ }
2815
+ /**
2816
+ * Tracks an analytics event
2817
+ *
2818
+ * @param eventName - Name of the event to track
2819
+ * @param properties - Optional event properties as key-value pairs
2820
+ * @param userId - Optional user identifier (uses current user if not provided)
2821
+ *
2822
+ * @example
2823
+ * ```typescript
2824
+ * analytics.track('button_clicked', { button_id: 'signup_btn' });
2825
+ * analytics.track('page_view', { page: '/dashboard' }, 'user123');
2826
+ * ```
2827
+ */
2828
+ track(eventName, properties = {}, userId) {
2829
+ const event = {
2830
+ analytics_event_name: eventName,
2831
+ user_id: userId ?? this.currentUserId,
2832
+ properties,
2833
+ event_time: /* @__PURE__ */ new Date()
2834
+ };
2835
+ this.eventsQueue.push(event);
2836
+ this.log("Track: Event added to queue", {
2837
+ eventName,
2838
+ queueLength: this.eventsQueue.length,
2839
+ maxBatchSize: this.config.maxBatchSize
2840
+ });
2841
+ this.saveToStorage();
2842
+ if (this.eventsQueue.length >= this.config.maxBatchSize) {
2843
+ this.log("Track: Queue reached max batch size, triggering flush");
2844
+ this.flush();
2845
+ }
2846
+ }
2847
+ /**
2848
+ * Sets the current user identifier and optionally updates user properties
2849
+ *
2850
+ * @param userId - User identifier
2851
+ * @param properties - Optional user properties to update
2852
+ *
2853
+ * @example
2854
+ * ```typescript
2855
+ * analytics.identify('user123', { name: 'John Doe', email: 'john@example.com' });
2856
+ * ```
2857
+ */
2858
+ identify(userId, properties = {}) {
2859
+ this.currentUserId = userId;
2860
+ const eventsWithoutUserId = this.eventsQueue.filter((event) => event.user_id === null);
2861
+ if (eventsWithoutUserId.length > 0) {
2862
+ this.log("Identify: Updating queued events with user_id", {
2863
+ count: eventsWithoutUserId.length,
2864
+ userId
2865
+ });
2866
+ eventsWithoutUserId.forEach((event) => {
2867
+ event.user_id = userId;
2868
+ });
2869
+ }
2870
+ if (Object.keys(properties).length > 0) {
2871
+ const userIdentity = {
2872
+ user_id: userId,
2873
+ properties
2874
+ };
2875
+ this.userPropsQueue.push(userIdentity);
2876
+ }
2877
+ this.saveToStorage();
2878
+ }
2879
+ /**
2880
+ * Updates user properties without changing the current user
2881
+ *
2882
+ * @param userId - User identifier
2883
+ * @param properties - User properties to update
2884
+ *
2885
+ * @example
2886
+ * ```typescript
2887
+ * analytics.setUserProperties('user123', { subscription: 'premium' });
2888
+ * ```
2889
+ */
2890
+ setUserProperties(userId, properties) {
2891
+ const userIdentity = {
2892
+ user_id: userId,
2893
+ properties
2894
+ };
2895
+ this.userPropsQueue.push(userIdentity);
2896
+ this.saveToStorage();
2897
+ }
2898
+ /**
2899
+ * Manually flushes all pending events and user properties to the server
2900
+ *
2901
+ * @returns Promise that resolves when flush is complete
2902
+ *
2903
+ * @example
2904
+ * ```typescript
2905
+ * await analytics.flush();
2906
+ * ```
2907
+ */
2908
+ async flush() {
2909
+ if (this.eventsQueue.length === 0 && this.userPropsQueue.length === 0) {
2910
+ this.log("Flush: No data to flush, skipping");
2911
+ return;
2912
+ }
2913
+ this.log("Flush: Starting flush", {
2914
+ eventsCount: this.eventsQueue.length,
2915
+ userPropsCount: this.userPropsQueue.length
2916
+ });
2917
+ const eventsWithUserId = this.eventsQueue.filter((event) => event.user_id !== null);
2918
+ const eventsWithoutUserId = this.eventsQueue.filter((event) => event.user_id === null);
2919
+ this.log("Flush: Filtering events by user_id", {
2920
+ eventsWithUserId: eventsWithUserId.length,
2921
+ eventsWithoutUserId: eventsWithoutUserId.length
2922
+ });
2923
+ const userPropsToSend = [...this.userPropsQueue];
2924
+ this.eventsQueue = eventsWithoutUserId;
2925
+ this.userPropsQueue = [];
2926
+ this.saveToStorage();
2927
+ const promises = [];
2928
+ if (eventsWithUserId.length > 0) {
2929
+ this.log("Flush: Sending events with user_id", { count: eventsWithUserId.length });
2930
+ promises.push(this.sendEvents(eventsWithUserId));
2931
+ } else {
2932
+ this.log("Flush: No events with user_id to send, skipping event flush");
2933
+ }
2934
+ if (userPropsToSend.length > 0) {
2935
+ this.log("Flush: Sending user properties", { count: userPropsToSend.length });
2936
+ promises.push(this.sendUserProperties(userPropsToSend));
2937
+ }
2938
+ await Promise.all(promises);
2939
+ this.log("Flush: Completed successfully");
2940
+ }
2941
+ /**
2942
+ * Clears the current user identifier
2943
+ */
2944
+ reset() {
2945
+ this.currentUserId = null;
2946
+ }
2947
+ /**
2948
+ * Stops automatic event flushing and clears the interval
2949
+ */
2950
+ destroy() {
2951
+ this.log("Destroy: Cleaning up SDK resources");
2952
+ if (this.flushIntervalId) {
2953
+ clearInterval(this.flushIntervalId);
2954
+ this.flushIntervalId = null;
2955
+ this.log("Destroy: Cleared flush interval");
2956
+ }
2957
+ if (this.initialFlushTimeoutId) {
2958
+ clearTimeout(this.initialFlushTimeoutId);
2959
+ this.initialFlushTimeoutId = null;
2960
+ this.log("Destroy: Cleared initial flush timeout");
2961
+ }
2962
+ this.isInitialized = false;
2963
+ this.log("Destroy: SDK destroyed successfully");
2964
+ }
2965
+ /**
2966
+ * Gets the current user identifier
2967
+ *
2968
+ * @returns Current user ID or null if not set
2969
+ */
2970
+ getUserId() {
2971
+ return this.currentUserId;
2972
+ }
2973
+ /**
2974
+ * Gets the number of pending events in the queue
2975
+ *
2976
+ * @returns Number of pending events
2977
+ */
2978
+ getPendingEventsCount() {
2979
+ return this.eventsQueue.length;
2980
+ }
2981
+ /**
2982
+ * Gets the number of pending user property updates in the queue
2983
+ *
2984
+ * @returns Number of pending user property updates
2985
+ */
2986
+ getPendingUserPropsCount() {
2987
+ return this.userPropsQueue.length;
2988
+ }
2989
+ startAutoFlush() {
2990
+ if (this.flushIntervalId) {
2991
+ this.log("StartAutoFlush: Interval already exists, skipping");
2992
+ return;
2993
+ }
2994
+ this.log("StartAutoFlush: Creating flush interval", {
2995
+ intervalMs: this.config.flushIntervalMs
2996
+ });
2997
+ this.flushIntervalId = setInterval(() => {
2998
+ this.log("StartAutoFlush: Auto-flush triggered by interval");
2999
+ this.flush().catch((error) => {
3000
+ console.error("Nana800Analytics: Auto-flush error:", error);
3001
+ });
3002
+ }, this.config.flushIntervalMs);
3003
+ this.log("StartAutoFlush: Interval created successfully", {
3004
+ intervalId: this.flushIntervalId
3005
+ });
3006
+ }
3007
+ async sendEvents(events) {
3008
+ try {
3009
+ this.log("SendEvents: Sending events to API", { count: events.length });
3010
+ await this.apiClient.sendEvents(events);
3011
+ this.log("SendEvents: Events sent successfully");
3012
+ } catch (error) {
3013
+ console.error("Nana800Analytics: Failed to send events:", error);
3014
+ this.log("SendEvents: Failed, re-queueing events", { count: events.length });
3015
+ this.eventsQueue.unshift(...events);
3016
+ this.saveToStorage();
3017
+ }
3018
+ }
3019
+ async sendUserProperties(userProps) {
3020
+ try {
3021
+ this.log("SendUserProperties: Sending user properties to API", { count: userProps.length });
3022
+ await this.apiClient.sendUserProperties(userProps);
3023
+ this.log("SendUserProperties: User properties sent successfully");
3024
+ } catch (error) {
3025
+ console.error("Nana800Analytics: Failed to send user properties:", error);
3026
+ this.log("SendUserProperties: Failed, re-queueing user properties", { count: userProps.length });
3027
+ this.userPropsQueue.unshift(...userProps);
3028
+ this.saveToStorage();
3029
+ }
3030
+ }
3031
+ saveToStorage() {
3032
+ if (!this.storageManager.isAvailable()) {
3033
+ return;
3034
+ }
3035
+ this.storageManager.saveEvents(this.eventsQueue);
3036
+ this.storageManager.saveUserProps(this.userPropsQueue);
3037
+ }
3038
+ loadFromStorage() {
3039
+ if (!this.storageManager.isAvailable()) {
3040
+ this.log("LoadFromStorage: Storage not available, skipping");
3041
+ return;
3042
+ }
3043
+ this.log("LoadFromStorage: Loading data from storage");
3044
+ const loadData = async () => {
3045
+ const [events, userProps] = await Promise.all([
3046
+ this.storageManager.loadEvents(),
3047
+ this.storageManager.loadUserProps()
3048
+ ]);
3049
+ this.eventsQueue = events;
3050
+ this.userPropsQueue = userProps;
3051
+ this.log("LoadFromStorage: Data loaded from storage", {
3052
+ eventsCount: events.length,
3053
+ userPropsCount: userProps.length
3054
+ });
3055
+ };
3056
+ loadData().catch((error) => {
3057
+ console.error("Nana800Analytics: Failed to load from storage:", error);
3058
+ });
3059
+ }
3060
+ log(message, data) {
3061
+ if (!this.config.debug) {
3062
+ return;
3063
+ }
3064
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3065
+ const prefix = `[Nana800Analytics ${timestamp}]`;
3066
+ if (data) {
3067
+ console.log(`${prefix} ${message}`, data);
3068
+ } else {
3069
+ console.log(`${prefix} ${message}`);
3070
+ }
3071
+ }
3072
+ };
3073
+
3074
+ // src/index.ts
3075
+ var createNana800Analytics = (config) => {
3076
+ const instance = new Nana800Analytics(config);
3077
+ instance.init();
3078
+ return instance;
3079
+ };