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