tevrocsdk 0.1.32 → 0.1.34

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.
package/tevroc-sdk.umd.js CHANGED
@@ -11,9 +11,9 @@ var Tevroc = (() => {
11
11
  throw err = [e], e;
12
12
  }
13
13
  };
14
- var __export = (target, all3) => {
15
- for (var name in all3)
16
- __defProp(target, name, { get: all3[name], enumerable: true });
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
17
  };
18
18
  var __copyProps = (to, from, except, desc) => {
19
19
  if (from && typeof from === "object" || typeof from === "function") {
@@ -59,7 +59,7 @@ var Tevroc = (() => {
59
59
  });
60
60
 
61
61
  // node_modules/@capacitor/core/dist/index.js
62
- var ExceptionCode, CapacitorException, getPlatformId, createCapacitor, initCapacitorGlobal, Capacitor, registerPlugin, WebPlugin, encode3, decode, CapacitorCookiesPluginWeb, CapacitorCookies, readBlobAsBase64, normalizeHttpHeaders, buildUrlParams, buildRequestInit, CapacitorHttpPluginWeb, CapacitorHttp, SystemBarsStyle, SystemBarType, SystemBarsPluginWeb, SystemBars;
62
+ var ExceptionCode, CapacitorException, getPlatformId, createCapacitor, initCapacitorGlobal, Capacitor, registerPlugin, WebPlugin, encode, decode, CapacitorCookiesPluginWeb, CapacitorCookies, readBlobAsBase64, normalizeHttpHeaders, buildUrlParams, buildRequestInit, CapacitorHttpPluginWeb, CapacitorHttp, SystemBarsStyle, SystemBarType, SystemBarsPluginWeb, SystemBars;
63
63
  var init_dist = __esm({
64
64
  "node_modules/@capacitor/core/dist/index.js"() {
65
65
  (function(ExceptionCode2) {
@@ -329,7 +329,7 @@ var Tevroc = (() => {
329
329
  });
330
330
  }
331
331
  };
332
- encode3 = (str) => encodeURIComponent(str).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
332
+ encode = (str) => encodeURIComponent(str).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
333
333
  decode = (str) => str.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
334
334
  CapacitorCookiesPluginWeb = class extends WebPlugin {
335
335
  async getCookies() {
@@ -347,8 +347,8 @@ var Tevroc = (() => {
347
347
  }
348
348
  async setCookie(options) {
349
349
  try {
350
- const encodedKey = encode3(options.key);
351
- const encodedValue = encode3(options.value);
350
+ const encodedKey = encode(options.key);
351
+ const encodedValue = encode(options.value);
352
352
  const expires = options.expires ? `; expires=${options.expires.replace("expires=", "")}` : "";
353
353
  const path = (options.path || "/").replace("path=", "");
354
354
  const domain = options.url != null && options.url.length > 0 ? `domain=${options.url}` : "";
@@ -5041,9 +5041,9 @@ var Tevroc = (() => {
5041
5041
  // src/services/useGoogleAuth.js
5042
5042
  var useGoogleAuth_exports = {};
5043
5043
  __export(useGoogleAuth_exports, {
5044
- createGoogleLogin: () => createGoogleLogin2,
5044
+ createGoogleLogin: () => createGoogleLogin,
5045
5045
  initializeGoogleLogin: () => initializeGoogleLogin,
5046
- subscribeGoogleLogin: () => subscribeGoogleLogin2
5046
+ subscribeGoogleLogin: () => subscribeGoogleLogin
5047
5047
  });
5048
5048
  function emitGoogleLogin(user, err = null) {
5049
5049
  googleListeners.forEach((cb) => {
@@ -5054,14 +5054,14 @@ var Tevroc = (() => {
5054
5054
  }
5055
5055
  });
5056
5056
  }
5057
- function subscribeGoogleLogin2(cb) {
5057
+ function subscribeGoogleLogin(cb) {
5058
5058
  googleListeners.push(cb);
5059
5059
  return () => {
5060
5060
  const i = googleListeners.indexOf(cb);
5061
5061
  if (i !== -1) googleListeners.splice(i, 1);
5062
5062
  };
5063
5063
  }
5064
- var googleInitialized, googleListeners, authWindowRef, handleCallback, initializeGoogleLogin, createGoogleLogin2;
5064
+ var googleInitialized, googleListeners, authWindowRef, authCleanupTimer, authMessageListener, cleanupAuthWindow, handleCallback, initializeGoogleLogin, createGoogleLogin;
5065
5065
  var init_useGoogleAuth = __esm({
5066
5066
  "src/services/useGoogleAuth.js"() {
5067
5067
  init_esm2();
@@ -5071,8 +5071,58 @@ var Tevroc = (() => {
5071
5071
  googleInitialized = false;
5072
5072
  googleListeners = [];
5073
5073
  authWindowRef = null;
5074
+ authCleanupTimer = null;
5075
+ authMessageListener = null;
5076
+ cleanupAuthWindow = async () => {
5077
+ if (authCleanupTimer) {
5078
+ clearInterval(authCleanupTimer);
5079
+ authCleanupTimer = null;
5080
+ }
5081
+ if (authMessageListener && typeof window !== "undefined") {
5082
+ window.removeEventListener("message", authMessageListener);
5083
+ authMessageListener = null;
5084
+ }
5085
+ if (authWindowRef) {
5086
+ const currentAuthWindow = authWindowRef;
5087
+ authWindowRef = null;
5088
+ try {
5089
+ if (typeof currentAuthWindow?.close === "function") {
5090
+ await currentAuthWindow.close();
5091
+ }
5092
+ } catch (e) {
5093
+ console.warn("Error closing auth window:", e);
5094
+ }
5095
+ }
5096
+ if (isTauri) {
5097
+ try {
5098
+ const tauriAuthWindow = await WebviewWindow.getByLabel("auth");
5099
+ if (tauriAuthWindow && tauriAuthWindow !== authWindowRef) {
5100
+ await tauriAuthWindow.close();
5101
+ }
5102
+ } catch (e) {
5103
+ console.warn("Error closing Tauri auth window by label:", e);
5104
+ }
5105
+ }
5106
+ if (isCapacitor) {
5107
+ try {
5108
+ await Browser2.close();
5109
+ } catch (e) {
5110
+ console.warn("Error closing Capacitor browser:", e);
5111
+ }
5112
+ }
5113
+ if (typeof window !== "undefined" && window !== window.parent) {
5114
+ try {
5115
+ if (authWindowRef && typeof authWindowRef.close === "function") {
5116
+ await authWindowRef.close();
5117
+ }
5118
+ } catch (e) {
5119
+ console.warn("Error closing popup fallback:", e);
5120
+ }
5121
+ }
5122
+ };
5074
5123
  handleCallback = async (url) => {
5075
5124
  try {
5125
+ await cleanupAuthWindow();
5076
5126
  if (!url?.includes("token=")) return;
5077
5127
  const params = new URLSearchParams(url.split("?")[1]);
5078
5128
  const token = params.get("token");
@@ -5118,18 +5168,11 @@ var Tevroc = (() => {
5118
5168
  url = url?.url || url?.payload || null;
5119
5169
  }
5120
5170
  if (!url) return;
5121
- if (authWindowRef) {
5122
- try {
5123
- await authWindowRef.close();
5124
- authWindowRef = null;
5125
- } catch (e) {
5126
- }
5127
- }
5128
- handleCallback(url);
5171
+ await handleCallback(url);
5129
5172
  });
5130
5173
  }
5131
5174
  };
5132
- createGoogleLogin2 = async ({
5175
+ createGoogleLogin = async ({
5133
5176
  appId = "tevrocsoft",
5134
5177
  appName = "Tevroc",
5135
5178
  serviceUrl = "https://tevrocsoftapi.netlify.app"
@@ -5177,21 +5220,21 @@ var Tevroc = (() => {
5177
5220
  console.error("Popup blocked");
5178
5221
  return;
5179
5222
  }
5180
- const listener = (event) => {
5181
- if (event.origin !== serviceUrl) return;
5223
+ authWindowRef = popup;
5224
+ authMessageListener = async (event) => {
5225
+ const serviceOrigin = new URL(serviceUrl).origin;
5226
+ if (event.origin !== serviceOrigin) return;
5182
5227
  if (event.data?.type === "google-auth") {
5183
5228
  const token = event.data?.token || null;
5184
5229
  const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
5185
- popup.close();
5186
- window.removeEventListener("message", listener);
5187
- handleCallback(url);
5230
+ await handleCallback(url);
5188
5231
  }
5189
5232
  };
5190
- window.addEventListener("message", listener);
5191
- const timer = setInterval(() => {
5233
+ window.addEventListener("message", authMessageListener);
5234
+ authCleanupTimer = setInterval(() => {
5192
5235
  if (popup.closed) {
5193
- clearInterval(timer);
5194
- window.removeEventListener("message", listener);
5236
+ cleanupAuthWindow().catch(() => {
5237
+ });
5195
5238
  }
5196
5239
  }, 500);
5197
5240
  return;
@@ -5201,13 +5244,6 @@ var Tevroc = (() => {
5201
5244
  });
5202
5245
 
5203
5246
  // src/services/useYocoPayment.js
5204
- var useYocoPayment_exports = {};
5205
- __export(useYocoPayment_exports, {
5206
- createPayment: () => createPayment,
5207
- default: () => PaymentHandler,
5208
- initializePayment: () => initializePayment,
5209
- subscribePaymentStatus: () => subscribePaymentStatus2
5210
- });
5211
5247
  function emitPaymentStatus(status, err = null) {
5212
5248
  paymentStatusListeners.forEach((cb) => {
5213
5249
  try {
@@ -5217,22 +5253,13 @@ var Tevroc = (() => {
5217
5253
  }
5218
5254
  });
5219
5255
  }
5220
- function subscribePaymentStatus2(cb) {
5256
+ function subscribePaymentStatus(cb) {
5221
5257
  paymentStatusListeners.push(cb);
5222
5258
  return () => {
5223
5259
  const i = paymentStatusListeners.indexOf(cb);
5224
5260
  if (i !== -1) paymentStatusListeners.splice(i, 1);
5225
5261
  };
5226
5262
  }
5227
- function PaymentHandler({
5228
- externalCallback = () => {
5229
- }
5230
- } = {}) {
5231
- initializePayment(externalCallback);
5232
- return {
5233
- createPayment
5234
- };
5235
- }
5236
5263
  var paymentInitialized, paymentStatusListeners, paymentWindowRef, logs, addLog, handlePaymentCallback, initializePayment, createPayment;
5237
5264
  var init_useYocoPayment = __esm({
5238
5265
  "src/services/useYocoPayment.js"() {
@@ -5258,3420 +5285,156 @@ var Tevroc = (() => {
5258
5285
  }) => {
5259
5286
  try {
5260
5287
  addLog("PAYMENT CALLBACK:", url);
5261
- if (!url?.includes("state=")) return;
5288
+ if (!url?.includes("status=")) return;
5262
5289
  const params = new URLSearchParams(url.split("?")[1]);
5263
- const state = params.get("state");
5264
- addLog("PAYMENT RESULT:", state);
5265
- if (state == "success") {
5290
+ const status = params.get("status");
5291
+ addLog("PAYMENT RESULT:", status);
5292
+ if (status == "success") {
5266
5293
  addLog("PAYMENT SUCCESS");
5267
5294
  } else {
5268
5295
  addLog("PAYMENT FAILED");
5269
5296
  }
5270
- externalCallback(state, null);
5271
- emitPaymentStatus(state, null);
5297
+ externalCallback(status, null);
5298
+ emitPaymentStatus(status, null);
5272
5299
  } catch (err) {
5273
5300
  addLog("PAYMENT CALLBACK ERROR:", err.message);
5274
- externalCallback(null, err);
5275
- emitPaymentStatus(null, err);
5276
- }
5277
- };
5278
- initializePayment = async (externalCallback = () => {
5279
- }) => {
5280
- if (paymentInitialized) return;
5281
- paymentInitialized = true;
5282
- if (isCapacitor) {
5283
- App.addListener("appUrlOpen", (event) => {
5284
- handlePaymentCallback(
5285
- event.url,
5286
- externalCallback
5287
- );
5288
- });
5289
- }
5290
- if (isTauri) {
5291
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
5292
- await listen2("deep-link://open-url", async (event) => {
5293
- let url = event.payload;
5294
- if (typeof url === "object") {
5295
- url = url?.url || url?.payload || null;
5296
- }
5297
- if (!url) return;
5298
- if (paymentWindowRef) {
5299
- try {
5300
- await paymentWindowRef.close();
5301
- paymentWindowRef = null;
5302
- } catch (e) {
5303
- }
5304
- }
5305
- handlePaymentCallback(
5306
- url,
5307
- externalCallback
5308
- );
5309
- });
5310
- }
5311
- };
5312
- createPayment = async (amountZAR, {
5313
- appId = "tevrocsoft",
5314
- serviceUrl = "https://tevrocsoftapi.netlify.app",
5315
- externalCallback = () => {
5316
- }
5317
- } = {}) => {
5318
- await initializePayment(externalCallback);
5319
- const cents = Math.round(Number(amountZAR) * 100);
5320
- const basePaymentUrl = `${serviceUrl}/pay`;
5321
- const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}`;
5322
- if (isCapacitor) {
5323
- await Browser2.open({
5324
- url: paymentUrl
5325
- });
5326
- return;
5327
- }
5328
- if (isTauri) {
5329
- const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}`;
5330
- const win = new WebviewWindow("payment", {
5331
- url,
5332
- title: "Complete Payment",
5333
- width: 550,
5334
- height: 600,
5335
- resizable: true,
5336
- center: true
5337
- });
5338
- paymentWindowRef = win;
5339
- win.once("tauri://created", () => {
5340
- console.log("Payment window opened");
5341
- });
5342
- win.once("tauri://error", (e) => {
5343
- console.error("Payment window error:", e);
5344
- });
5345
- return;
5346
- }
5347
- const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
5348
- const mode = isLocalhost ? "localhost" : "netlify";
5349
- window.location.href = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
5350
- };
5351
- }
5352
- });
5353
-
5354
- // src/index.js
5355
- var index_exports = {};
5356
- __export(index_exports, {
5357
- TevrocClient: () => TevrocClient,
5358
- TevrocError: () => TevrocError,
5359
- createClient: () => createClient
5360
- });
5361
-
5362
- // node_modules/axios/lib/helpers/bind.js
5363
- function bind(fn, thisArg) {
5364
- return function wrap() {
5365
- return fn.apply(thisArg, arguments);
5366
- };
5367
- }
5368
-
5369
- // node_modules/axios/lib/utils.js
5370
- var { toString } = Object.prototype;
5371
- var { getPrototypeOf } = Object;
5372
- var { iterator, toStringTag } = Symbol;
5373
- var hasOwnProperty = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
5374
- var hasOwnInPrototypeChain = (thing, prop) => {
5375
- let obj = thing;
5376
- const seen = [];
5377
- while (obj != null && obj !== Object.prototype) {
5378
- if (seen.indexOf(obj) !== -1) {
5379
- return false;
5380
- }
5381
- seen.push(obj);
5382
- if (hasOwnProperty(obj, prop)) {
5383
- return true;
5384
- }
5385
- obj = getPrototypeOf(obj);
5386
- }
5387
- return false;
5388
- };
5389
- var getSafeProp = (obj, prop) => obj != null && hasOwnInPrototypeChain(obj, prop) ? obj[prop] : void 0;
5390
- var kindOf = /* @__PURE__ */ ((cache) => (thing) => {
5391
- const str = toString.call(thing);
5392
- return cache[str] || (cache[str] = str.slice(8, -1).toLowerCase());
5393
- })(/* @__PURE__ */ Object.create(null));
5394
- var kindOfTest = (type) => {
5395
- type = type.toLowerCase();
5396
- return (thing) => kindOf(thing) === type;
5397
- };
5398
- var typeOfTest = (type) => (thing) => typeof thing === type;
5399
- var { isArray } = Array;
5400
- var isUndefined = typeOfTest("undefined");
5401
- function isBuffer(val) {
5402
- return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
5403
- }
5404
- var isArrayBuffer = kindOfTest("ArrayBuffer");
5405
- function isArrayBufferView(val) {
5406
- let result;
5407
- if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
5408
- result = ArrayBuffer.isView(val);
5409
- } else {
5410
- result = val && val.buffer && isArrayBuffer(val.buffer);
5411
- }
5412
- return result;
5413
- }
5414
- var isString = typeOfTest("string");
5415
- var isFunction = typeOfTest("function");
5416
- var isNumber = typeOfTest("number");
5417
- var isObject = (thing) => thing !== null && typeof thing === "object";
5418
- var isBoolean = (thing) => thing === true || thing === false;
5419
- var isPlainObject = (val) => {
5420
- if (!isObject(val)) {
5421
- return false;
5422
- }
5423
- const prototype2 = getPrototypeOf(val);
5424
- return (prototype2 === null || prototype2 === Object.prototype || getPrototypeOf(prototype2) === null) && // Treat any genuine (non-Object.prototype-polluted) Symbol.toStringTag or
5425
- // Symbol.iterator as evidence the value is a tagged/iterable type rather
5426
- // than a plain object, while ignoring keys injected onto Object.prototype.
5427
- !hasOwnInPrototypeChain(val, toStringTag) && !hasOwnInPrototypeChain(val, iterator);
5428
- };
5429
- var isEmptyObject = (val) => {
5430
- if (!isObject(val) || isBuffer(val)) {
5431
- return false;
5432
- }
5433
- try {
5434
- return Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
5435
- } catch (e) {
5436
- return false;
5437
- }
5438
- };
5439
- var isDate = kindOfTest("Date");
5440
- var isFile = kindOfTest("File");
5441
- var isReactNativeBlob = (value) => {
5442
- return !!(value && typeof value.uri !== "undefined");
5443
- };
5444
- var isReactNative = (formData) => formData && typeof formData.getParts !== "undefined";
5445
- var isBlob = kindOfTest("Blob");
5446
- var isFileList = kindOfTest("FileList");
5447
- var isStream = (val) => isObject(val) && isFunction(val.pipe);
5448
- function getGlobal() {
5449
- if (typeof globalThis !== "undefined") return globalThis;
5450
- if (typeof self !== "undefined") return self;
5451
- if (typeof window !== "undefined") return window;
5452
- if (typeof global !== "undefined") return global;
5453
- return {};
5454
- }
5455
- var G = getGlobal();
5456
- var FormDataCtor = typeof G.FormData !== "undefined" ? G.FormData : void 0;
5457
- var isFormData = (thing) => {
5458
- if (!thing) return false;
5459
- if (FormDataCtor && thing instanceof FormDataCtor) return true;
5460
- const proto = getPrototypeOf(thing);
5461
- if (!proto || proto === Object.prototype) return false;
5462
- if (!isFunction(thing.append)) return false;
5463
- const kind = kindOf(thing);
5464
- return kind === "formdata" || // detect form-data instance
5465
- kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]";
5466
- };
5467
- var isURLSearchParams = kindOfTest("URLSearchParams");
5468
- var [isReadableStream, isRequest, isResponse, isHeaders] = [
5469
- "ReadableStream",
5470
- "Request",
5471
- "Response",
5472
- "Headers"
5473
- ].map(kindOfTest);
5474
- var trim = (str) => {
5475
- return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
5476
- };
5477
- function forEach(obj, fn, { allOwnKeys = false } = {}) {
5478
- if (obj === null || typeof obj === "undefined") {
5479
- return;
5480
- }
5481
- let i;
5482
- let l;
5483
- if (typeof obj !== "object") {
5484
- obj = [obj];
5485
- }
5486
- if (isArray(obj)) {
5487
- for (i = 0, l = obj.length; i < l; i++) {
5488
- fn.call(null, obj[i], i, obj);
5489
- }
5490
- } else {
5491
- if (isBuffer(obj)) {
5492
- return;
5493
- }
5494
- const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
5495
- const len = keys.length;
5496
- let key;
5497
- for (i = 0; i < len; i++) {
5498
- key = keys[i];
5499
- fn.call(null, obj[key], key, obj);
5500
- }
5501
- }
5502
- }
5503
- function findKey(obj, key) {
5504
- if (isBuffer(obj)) {
5505
- return null;
5506
- }
5507
- key = key.toLowerCase();
5508
- const keys = Object.keys(obj);
5509
- let i = keys.length;
5510
- let _key;
5511
- while (i-- > 0) {
5512
- _key = keys[i];
5513
- if (key === _key.toLowerCase()) {
5514
- return _key;
5515
- }
5516
- }
5517
- return null;
5518
- }
5519
- var _global = (() => {
5520
- if (typeof globalThis !== "undefined") return globalThis;
5521
- return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
5522
- })();
5523
- var isContextDefined = (context) => !isUndefined(context) && context !== _global;
5524
- function merge(...objs) {
5525
- const { caseless, skipUndefined } = isContextDefined(this) && this || {};
5526
- const result = {};
5527
- const assignValue = (val, key) => {
5528
- if (key === "__proto__" || key === "constructor" || key === "prototype") {
5529
- return;
5530
- }
5531
- const targetKey = caseless && typeof key === "string" && findKey(result, key) || key;
5532
- const existing = hasOwnProperty(result, targetKey) ? result[targetKey] : void 0;
5533
- if (isPlainObject(existing) && isPlainObject(val)) {
5534
- result[targetKey] = merge(existing, val);
5535
- } else if (isPlainObject(val)) {
5536
- result[targetKey] = merge({}, val);
5537
- } else if (isArray(val)) {
5538
- result[targetKey] = val.slice();
5539
- } else if (!skipUndefined || !isUndefined(val)) {
5540
- result[targetKey] = val;
5541
- }
5542
- };
5543
- for (let i = 0, l = objs.length; i < l; i++) {
5544
- const source = objs[i];
5545
- if (!source || isBuffer(source)) {
5546
- continue;
5547
- }
5548
- forEach(source, assignValue);
5549
- if (typeof source !== "object" || isArray(source)) {
5550
- continue;
5551
- }
5552
- const symbols = Object.getOwnPropertySymbols(source);
5553
- for (let j = 0; j < symbols.length; j++) {
5554
- const symbol = symbols[j];
5555
- if (propertyIsEnumerable.call(source, symbol)) {
5556
- assignValue(source[symbol], symbol);
5557
- }
5558
- }
5559
- }
5560
- return result;
5561
- }
5562
- var extend = (a, b, thisArg, { allOwnKeys } = {}) => {
5563
- forEach(
5564
- b,
5565
- (val, key) => {
5566
- if (thisArg && isFunction(val)) {
5567
- Object.defineProperty(a, key, {
5568
- // Null-proto descriptor so a polluted Object.prototype.get cannot
5569
- // hijack defineProperty's accessor-vs-data resolution.
5570
- __proto__: null,
5571
- value: bind(val, thisArg),
5572
- writable: true,
5573
- enumerable: true,
5574
- configurable: true
5575
- });
5576
- } else {
5577
- Object.defineProperty(a, key, {
5578
- __proto__: null,
5579
- value: val,
5580
- writable: true,
5581
- enumerable: true,
5582
- configurable: true
5583
- });
5584
- }
5585
- },
5586
- { allOwnKeys }
5587
- );
5588
- return a;
5589
- };
5590
- var stripBOM = (content) => {
5591
- if (content.charCodeAt(0) === 65279) {
5592
- content = content.slice(1);
5593
- }
5594
- return content;
5595
- };
5596
- var inherits = (constructor, superConstructor, props, descriptors) => {
5597
- constructor.prototype = Object.create(superConstructor.prototype, descriptors);
5598
- Object.defineProperty(constructor.prototype, "constructor", {
5599
- __proto__: null,
5600
- value: constructor,
5601
- writable: true,
5602
- enumerable: false,
5603
- configurable: true
5604
- });
5605
- Object.defineProperty(constructor, "super", {
5606
- __proto__: null,
5607
- value: superConstructor.prototype
5608
- });
5609
- props && Object.assign(constructor.prototype, props);
5610
- };
5611
- var toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
5612
- let props;
5613
- let i;
5614
- let prop;
5615
- const merged = {};
5616
- destObj = destObj || {};
5617
- if (sourceObj == null) return destObj;
5618
- do {
5619
- props = Object.getOwnPropertyNames(sourceObj);
5620
- i = props.length;
5621
- while (i-- > 0) {
5622
- prop = props[i];
5623
- if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
5624
- destObj[prop] = sourceObj[prop];
5625
- merged[prop] = true;
5626
- }
5627
- }
5628
- sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
5629
- } while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
5630
- return destObj;
5631
- };
5632
- var endsWith = (str, searchString, position) => {
5633
- str = String(str);
5634
- if (position === void 0 || position > str.length) {
5635
- position = str.length;
5636
- }
5637
- position -= searchString.length;
5638
- const lastIndex = str.indexOf(searchString, position);
5639
- return lastIndex !== -1 && lastIndex === position;
5640
- };
5641
- var toArray = (thing) => {
5642
- if (!thing) return null;
5643
- if (isArray(thing)) return thing;
5644
- let i = thing.length;
5645
- if (!isNumber(i)) return null;
5646
- const arr = new Array(i);
5647
- while (i-- > 0) {
5648
- arr[i] = thing[i];
5649
- }
5650
- return arr;
5651
- };
5652
- var isTypedArray = /* @__PURE__ */ ((TypedArray) => {
5653
- return (thing) => {
5654
- return TypedArray && thing instanceof TypedArray;
5655
- };
5656
- })(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
5657
- var forEachEntry = (obj, fn) => {
5658
- const generator = obj && obj[iterator];
5659
- const _iterator = generator.call(obj);
5660
- let result;
5661
- while ((result = _iterator.next()) && !result.done) {
5662
- const pair = result.value;
5663
- fn.call(obj, pair[0], pair[1]);
5664
- }
5665
- };
5666
- var matchAll = (regExp, str) => {
5667
- let matches;
5668
- const arr = [];
5669
- while ((matches = regExp.exec(str)) !== null) {
5670
- arr.push(matches);
5671
- }
5672
- return arr;
5673
- };
5674
- var isHTMLForm = kindOfTest("HTMLFormElement");
5675
- var toCamelCase = (str) => {
5676
- return str.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, function replacer(m, p1, p2) {
5677
- return p1.toUpperCase() + p2;
5678
- });
5679
- };
5680
- var { propertyIsEnumerable } = Object.prototype;
5681
- var isRegExp = kindOfTest("RegExp");
5682
- var reduceDescriptors = (obj, reducer) => {
5683
- const descriptors = Object.getOwnPropertyDescriptors(obj);
5684
- const reducedDescriptors = {};
5685
- forEach(descriptors, (descriptor, name) => {
5686
- let ret;
5687
- if ((ret = reducer(descriptor, name, obj)) !== false) {
5688
- reducedDescriptors[name] = ret || descriptor;
5689
- }
5690
- });
5691
- Object.defineProperties(obj, reducedDescriptors);
5692
- };
5693
- var freezeMethods = (obj) => {
5694
- reduceDescriptors(obj, (descriptor, name) => {
5695
- if (isFunction(obj) && ["arguments", "caller", "callee"].includes(name)) {
5696
- return false;
5697
- }
5698
- const value = obj[name];
5699
- if (!isFunction(value)) return;
5700
- descriptor.enumerable = false;
5701
- if ("writable" in descriptor) {
5702
- descriptor.writable = false;
5703
- return;
5704
- }
5705
- if (!descriptor.set) {
5706
- descriptor.set = () => {
5707
- throw Error("Can not rewrite read-only method '" + name + "'");
5708
- };
5709
- }
5710
- });
5711
- };
5712
- var toObjectSet = (arrayOrString, delimiter) => {
5713
- const obj = {};
5714
- const define = (arr) => {
5715
- arr.forEach((value) => {
5716
- obj[value] = true;
5717
- });
5718
- };
5719
- isArray(arrayOrString) ? define(arrayOrString) : define(String(arrayOrString).split(delimiter));
5720
- return obj;
5721
- };
5722
- var noop = () => {
5723
- };
5724
- var toFiniteNumber = (value, defaultValue) => {
5725
- return value != null && Number.isFinite(value = +value) ? value : defaultValue;
5726
- };
5727
- function isSpecCompliantForm(thing) {
5728
- return !!(thing && isFunction(thing.append) && thing[toStringTag] === "FormData" && thing[iterator]);
5729
- }
5730
- var toJSONObject = (obj) => {
5731
- const visited = /* @__PURE__ */ new WeakSet();
5732
- const visit = (source) => {
5733
- if (isObject(source)) {
5734
- if (visited.has(source)) {
5735
- return;
5736
- }
5737
- if (isBuffer(source)) {
5738
- return source;
5739
- }
5740
- if (!("toJSON" in source)) {
5741
- visited.add(source);
5742
- const target = isArray(source) ? [] : {};
5743
- forEach(source, (value, key) => {
5744
- const reducedValue = visit(value);
5745
- !isUndefined(reducedValue) && (target[key] = reducedValue);
5746
- });
5747
- visited.delete(source);
5748
- return target;
5749
- }
5750
- }
5751
- return source;
5752
- };
5753
- return visit(obj);
5754
- };
5755
- var isAsyncFn = kindOfTest("AsyncFunction");
5756
- var isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
5757
- var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
5758
- if (setImmediateSupported) {
5759
- return setImmediate;
5760
- }
5761
- return postMessageSupported ? ((token, callbacks) => {
5762
- _global.addEventListener(
5763
- "message",
5764
- ({ source, data }) => {
5765
- if (source === _global && data === token) {
5766
- callbacks.length && callbacks.shift()();
5767
- }
5768
- },
5769
- false
5770
- );
5771
- return (cb) => {
5772
- callbacks.push(cb);
5773
- _global.postMessage(token, "*");
5774
- };
5775
- })(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
5776
- })(typeof setImmediate === "function", isFunction(_global.postMessage));
5777
- var asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
5778
- var isIterable = (thing) => thing != null && isFunction(thing[iterator]);
5779
- var isSafeIterable = (thing) => thing != null && hasOwnInPrototypeChain(thing, iterator) && isIterable(thing);
5780
- var utils_default = {
5781
- isArray,
5782
- isArrayBuffer,
5783
- isBuffer,
5784
- isFormData,
5785
- isArrayBufferView,
5786
- isString,
5787
- isNumber,
5788
- isBoolean,
5789
- isObject,
5790
- isPlainObject,
5791
- isEmptyObject,
5792
- isReadableStream,
5793
- isRequest,
5794
- isResponse,
5795
- isHeaders,
5796
- isUndefined,
5797
- isDate,
5798
- isFile,
5799
- isReactNativeBlob,
5800
- isReactNative,
5801
- isBlob,
5802
- isRegExp,
5803
- isFunction,
5804
- isStream,
5805
- isURLSearchParams,
5806
- isTypedArray,
5807
- isFileList,
5808
- forEach,
5809
- merge,
5810
- extend,
5811
- trim,
5812
- stripBOM,
5813
- inherits,
5814
- toFlatObject,
5815
- kindOf,
5816
- kindOfTest,
5817
- endsWith,
5818
- toArray,
5819
- forEachEntry,
5820
- matchAll,
5821
- isHTMLForm,
5822
- hasOwnProperty,
5823
- hasOwnProp: hasOwnProperty,
5824
- // an alias to avoid ESLint no-prototype-builtins detection
5825
- hasOwnInPrototypeChain,
5826
- getSafeProp,
5827
- reduceDescriptors,
5828
- freezeMethods,
5829
- toObjectSet,
5830
- toCamelCase,
5831
- noop,
5832
- toFiniteNumber,
5833
- findKey,
5834
- global: _global,
5835
- isContextDefined,
5836
- isSpecCompliantForm,
5837
- toJSONObject,
5838
- isAsyncFn,
5839
- isThenable,
5840
- setImmediate: _setImmediate,
5841
- asap,
5842
- isIterable,
5843
- isSafeIterable
5844
- };
5845
-
5846
- // node_modules/axios/lib/helpers/parseHeaders.js
5847
- var ignoreDuplicateOf = utils_default.toObjectSet([
5848
- "age",
5849
- "authorization",
5850
- "content-length",
5851
- "content-type",
5852
- "etag",
5853
- "expires",
5854
- "from",
5855
- "host",
5856
- "if-modified-since",
5857
- "if-unmodified-since",
5858
- "last-modified",
5859
- "location",
5860
- "max-forwards",
5861
- "proxy-authorization",
5862
- "referer",
5863
- "retry-after",
5864
- "user-agent"
5865
- ]);
5866
- var parseHeaders_default = (rawHeaders) => {
5867
- const parsed = {};
5868
- let key;
5869
- let val;
5870
- let i;
5871
- rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
5872
- i = line.indexOf(":");
5873
- key = line.substring(0, i).trim().toLowerCase();
5874
- val = line.substring(i + 1).trim();
5875
- if (!key || parsed[key] && ignoreDuplicateOf[key]) {
5876
- return;
5877
- }
5878
- if (key === "set-cookie") {
5879
- if (parsed[key]) {
5880
- parsed[key].push(val);
5881
- } else {
5882
- parsed[key] = [val];
5883
- }
5884
- } else {
5885
- parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
5886
- }
5887
- });
5888
- return parsed;
5889
- };
5890
-
5891
- // node_modules/axios/lib/helpers/sanitizeHeaderValue.js
5892
- function trimSPorHTAB(str) {
5893
- let start = 0;
5894
- let end = str.length;
5895
- while (start < end) {
5896
- const code = str.charCodeAt(start);
5897
- if (code !== 9 && code !== 32) {
5898
- break;
5899
- }
5900
- start += 1;
5901
- }
5902
- while (end > start) {
5903
- const code = str.charCodeAt(end - 1);
5904
- if (code !== 9 && code !== 32) {
5905
- break;
5906
- }
5907
- end -= 1;
5908
- }
5909
- return start === 0 && end === str.length ? str : str.slice(start, end);
5910
- }
5911
- var INVALID_UNICODE_HEADER_VALUE_CHARS = new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+", "g");
5912
- var INVALID_BYTE_STRING_HEADER_VALUE_CHARS = new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+", "g");
5913
- function sanitizeValue(value, invalidChars) {
5914
- if (utils_default.isArray(value)) {
5915
- return value.map((item) => sanitizeValue(item, invalidChars));
5916
- }
5917
- return trimSPorHTAB(String(value).replace(invalidChars, ""));
5918
- }
5919
- var sanitizeHeaderValue = (value) => sanitizeValue(value, INVALID_UNICODE_HEADER_VALUE_CHARS);
5920
- var sanitizeByteStringHeaderValue = (value) => sanitizeValue(value, INVALID_BYTE_STRING_HEADER_VALUE_CHARS);
5921
- function toByteStringHeaderObject(headers) {
5922
- const byteStringHeaders = /* @__PURE__ */ Object.create(null);
5923
- utils_default.forEach(headers.toJSON(), (value, header) => {
5924
- byteStringHeaders[header] = sanitizeByteStringHeaderValue(value);
5925
- });
5926
- return byteStringHeaders;
5927
- }
5928
-
5929
- // node_modules/axios/lib/core/AxiosHeaders.js
5930
- var $internals = /* @__PURE__ */ Symbol("internals");
5931
- function normalizeHeader(header) {
5932
- return header && String(header).trim().toLowerCase();
5933
- }
5934
- function normalizeValue(value) {
5935
- if (value === false || value == null) {
5936
- return value;
5937
- }
5938
- return utils_default.isArray(value) ? value.map(normalizeValue) : sanitizeHeaderValue(String(value));
5939
- }
5940
- function parseTokens(str) {
5941
- const tokens = /* @__PURE__ */ Object.create(null);
5942
- const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
5943
- let match;
5944
- while (match = tokensRE.exec(str)) {
5945
- tokens[match[1]] = match[2];
5946
- }
5947
- return tokens;
5948
- }
5949
- var isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
5950
- function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
5951
- if (utils_default.isFunction(filter2)) {
5952
- return filter2.call(this, value, header);
5953
- }
5954
- if (isHeaderNameFilter) {
5955
- value = header;
5956
- }
5957
- if (!utils_default.isString(value)) return;
5958
- if (utils_default.isString(filter2)) {
5959
- return value.indexOf(filter2) !== -1;
5960
- }
5961
- if (utils_default.isRegExp(filter2)) {
5962
- return filter2.test(value);
5963
- }
5964
- }
5965
- function formatHeader(header) {
5966
- return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
5967
- return char.toUpperCase() + str;
5968
- });
5969
- }
5970
- function buildAccessors(obj, header) {
5971
- const accessorName = utils_default.toCamelCase(" " + header);
5972
- ["get", "set", "has"].forEach((methodName) => {
5973
- Object.defineProperty(obj, methodName + accessorName, {
5974
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
5975
- // this data descriptor into an accessor descriptor on the way in.
5976
- __proto__: null,
5977
- value: function(arg1, arg2, arg3) {
5978
- return this[methodName].call(this, header, arg1, arg2, arg3);
5979
- },
5980
- configurable: true
5981
- });
5982
- });
5983
- }
5984
- var AxiosHeaders = class {
5985
- constructor(headers) {
5986
- headers && this.set(headers);
5987
- }
5988
- set(header, valueOrRewrite, rewrite) {
5989
- const self2 = this;
5990
- function setHeader(_value, _header, _rewrite) {
5991
- const lHeader = normalizeHeader(_header);
5992
- if (!lHeader) {
5993
- return;
5994
- }
5995
- const key = utils_default.findKey(self2, lHeader);
5996
- if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
5997
- self2[key || _header] = normalizeValue(_value);
5998
- }
5999
- }
6000
- const setHeaders = (headers, _rewrite) => utils_default.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
6001
- if (utils_default.isPlainObject(header) || header instanceof this.constructor) {
6002
- setHeaders(header, valueOrRewrite);
6003
- } else if (utils_default.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
6004
- setHeaders(parseHeaders_default(header), valueOrRewrite);
6005
- } else if (utils_default.isObject(header) && utils_default.isSafeIterable(header)) {
6006
- let obj = /* @__PURE__ */ Object.create(null), dest, key;
6007
- for (const entry of header) {
6008
- if (!utils_default.isArray(entry)) {
6009
- throw new TypeError("Object iterator must return a key-value pair");
6010
- }
6011
- key = entry[0];
6012
- if (utils_default.hasOwnProp(obj, key)) {
6013
- dest = obj[key];
6014
- obj[key] = utils_default.isArray(dest) ? [...dest, entry[1]] : [dest, entry[1]];
6015
- } else {
6016
- obj[key] = entry[1];
6017
- }
6018
- }
6019
- setHeaders(obj, valueOrRewrite);
6020
- } else {
6021
- header != null && setHeader(valueOrRewrite, header, rewrite);
6022
- }
6023
- return this;
6024
- }
6025
- get(header, parser) {
6026
- header = normalizeHeader(header);
6027
- if (header) {
6028
- const key = utils_default.findKey(this, header);
6029
- if (key) {
6030
- const value = this[key];
6031
- if (!parser) {
6032
- return value;
6033
- }
6034
- if (parser === true) {
6035
- return parseTokens(value);
6036
- }
6037
- if (utils_default.isFunction(parser)) {
6038
- return parser.call(this, value, key);
6039
- }
6040
- if (utils_default.isRegExp(parser)) {
6041
- return parser.exec(value);
6042
- }
6043
- throw new TypeError("parser must be boolean|regexp|function");
6044
- }
6045
- }
6046
- }
6047
- has(header, matcher) {
6048
- header = normalizeHeader(header);
6049
- if (header) {
6050
- const key = utils_default.findKey(this, header);
6051
- return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
6052
- }
6053
- return false;
6054
- }
6055
- delete(header, matcher) {
6056
- const self2 = this;
6057
- let deleted = false;
6058
- function deleteHeader(_header) {
6059
- _header = normalizeHeader(_header);
6060
- if (_header) {
6061
- const key = utils_default.findKey(self2, _header);
6062
- if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
6063
- delete self2[key];
6064
- deleted = true;
6065
- }
6066
- }
6067
- }
6068
- if (utils_default.isArray(header)) {
6069
- header.forEach(deleteHeader);
6070
- } else {
6071
- deleteHeader(header);
6072
- }
6073
- return deleted;
6074
- }
6075
- clear(matcher) {
6076
- const keys = Object.keys(this);
6077
- let i = keys.length;
6078
- let deleted = false;
6079
- while (i--) {
6080
- const key = keys[i];
6081
- if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
6082
- delete this[key];
6083
- deleted = true;
6084
- }
6085
- }
6086
- return deleted;
6087
- }
6088
- normalize(format) {
6089
- const self2 = this;
6090
- const headers = {};
6091
- utils_default.forEach(this, (value, header) => {
6092
- const key = utils_default.findKey(headers, header);
6093
- if (key) {
6094
- self2[key] = normalizeValue(value);
6095
- delete self2[header];
6096
- return;
6097
- }
6098
- const normalized = format ? formatHeader(header) : String(header).trim();
6099
- if (normalized !== header) {
6100
- delete self2[header];
6101
- }
6102
- self2[normalized] = normalizeValue(value);
6103
- headers[normalized] = true;
6104
- });
6105
- return this;
6106
- }
6107
- concat(...targets) {
6108
- return this.constructor.concat(this, ...targets);
6109
- }
6110
- toJSON(asStrings) {
6111
- const obj = /* @__PURE__ */ Object.create(null);
6112
- utils_default.forEach(this, (value, header) => {
6113
- value != null && value !== false && (obj[header] = asStrings && utils_default.isArray(value) ? value.join(", ") : value);
6114
- });
6115
- return obj;
6116
- }
6117
- [Symbol.iterator]() {
6118
- return Object.entries(this.toJSON())[Symbol.iterator]();
6119
- }
6120
- toString() {
6121
- return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
6122
- }
6123
- getSetCookie() {
6124
- return this.get("set-cookie") || [];
6125
- }
6126
- get [Symbol.toStringTag]() {
6127
- return "AxiosHeaders";
6128
- }
6129
- static from(thing) {
6130
- return thing instanceof this ? thing : new this(thing);
6131
- }
6132
- static concat(first, ...targets) {
6133
- const computed = new this(first);
6134
- targets.forEach((target) => computed.set(target));
6135
- return computed;
6136
- }
6137
- static accessor(header) {
6138
- const internals = this[$internals] = this[$internals] = {
6139
- accessors: {}
6140
- };
6141
- const accessors = internals.accessors;
6142
- const prototype2 = this.prototype;
6143
- function defineAccessor(_header) {
6144
- const lHeader = normalizeHeader(_header);
6145
- if (!accessors[lHeader]) {
6146
- buildAccessors(prototype2, _header);
6147
- accessors[lHeader] = true;
6148
- }
6149
- }
6150
- utils_default.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
6151
- return this;
6152
- }
6153
- };
6154
- AxiosHeaders.accessor([
6155
- "Content-Type",
6156
- "Content-Length",
6157
- "Accept",
6158
- "Accept-Encoding",
6159
- "User-Agent",
6160
- "Authorization"
6161
- ]);
6162
- utils_default.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
6163
- let mapped = key[0].toUpperCase() + key.slice(1);
6164
- return {
6165
- get: () => value,
6166
- set(headerValue) {
6167
- this[mapped] = headerValue;
6168
- }
6169
- };
6170
- });
6171
- utils_default.freezeMethods(AxiosHeaders);
6172
- var AxiosHeaders_default = AxiosHeaders;
6173
-
6174
- // node_modules/axios/lib/core/AxiosError.js
6175
- var REDACTED = "[REDACTED ****]";
6176
- function hasOwnOrPrototypeToJSON(source) {
6177
- if (utils_default.hasOwnProp(source, "toJSON")) {
6178
- return true;
6179
- }
6180
- let prototype2 = Object.getPrototypeOf(source);
6181
- while (prototype2 && prototype2 !== Object.prototype) {
6182
- if (utils_default.hasOwnProp(prototype2, "toJSON")) {
6183
- return true;
6184
- }
6185
- prototype2 = Object.getPrototypeOf(prototype2);
6186
- }
6187
- return false;
6188
- }
6189
- function redactConfig(config, redactKeys) {
6190
- const lowerKeys = new Set(redactKeys.map((k) => String(k).toLowerCase()));
6191
- const seen = [];
6192
- const visit = (source) => {
6193
- if (source === null || typeof source !== "object") return source;
6194
- if (utils_default.isBuffer(source)) return source;
6195
- if (seen.indexOf(source) !== -1) return void 0;
6196
- if (source instanceof AxiosHeaders_default) {
6197
- source = source.toJSON();
6198
- }
6199
- seen.push(source);
6200
- let result;
6201
- if (utils_default.isArray(source)) {
6202
- result = [];
6203
- source.forEach((v, i) => {
6204
- const reducedValue = visit(v);
6205
- if (!utils_default.isUndefined(reducedValue)) {
6206
- result[i] = reducedValue;
6207
- }
6208
- });
6209
- } else {
6210
- if (!utils_default.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
6211
- seen.pop();
6212
- return source;
6213
- }
6214
- result = /* @__PURE__ */ Object.create(null);
6215
- for (const [key, value] of Object.entries(source)) {
6216
- const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
6217
- if (!utils_default.isUndefined(reducedValue)) {
6218
- result[key] = reducedValue;
6219
- }
6220
- }
6221
- }
6222
- seen.pop();
6223
- return result;
6224
- };
6225
- return visit(config);
6226
- }
6227
- var AxiosError = class _AxiosError extends Error {
6228
- static from(error, code, config, request, response, customProps) {
6229
- const axiosError = new _AxiosError(error.message, code || error.code, config, request, response);
6230
- axiosError.cause = error;
6231
- axiosError.name = error.name;
6232
- if (error.status != null && axiosError.status == null) {
6233
- axiosError.status = error.status;
6234
- }
6235
- customProps && Object.assign(axiosError, customProps);
6236
- return axiosError;
6237
- }
6238
- /**
6239
- * Create an Error with the specified message, config, error code, request and response.
6240
- *
6241
- * @param {string} message The error message.
6242
- * @param {string} [code] The error code (for example, 'ECONNABORTED').
6243
- * @param {Object} [config] The config.
6244
- * @param {Object} [request] The request.
6245
- * @param {Object} [response] The response.
6246
- *
6247
- * @returns {Error} The created error.
6248
- */
6249
- constructor(message, code, config, request, response) {
6250
- super(message);
6251
- Object.defineProperty(this, "message", {
6252
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
6253
- // this data descriptor into an accessor descriptor on the way in.
6254
- __proto__: null,
6255
- value: message,
6256
- enumerable: true,
6257
- writable: true,
6258
- configurable: true
6259
- });
6260
- this.name = "AxiosError";
6261
- this.isAxiosError = true;
6262
- code && (this.code = code);
6263
- config && (this.config = config);
6264
- request && (this.request = request);
6265
- if (response) {
6266
- this.response = response;
6267
- this.status = response.status;
6268
- }
6269
- }
6270
- toJSON() {
6271
- const config = this.config;
6272
- const redactKeys = config && utils_default.hasOwnProp(config, "redact") ? config.redact : void 0;
6273
- const serializedConfig = utils_default.isArray(redactKeys) && redactKeys.length > 0 ? redactConfig(config, redactKeys) : utils_default.toJSONObject(config);
6274
- return {
6275
- // Standard
6276
- message: this.message,
6277
- name: this.name,
6278
- // Microsoft
6279
- description: this.description,
6280
- number: this.number,
6281
- // Mozilla
6282
- fileName: this.fileName,
6283
- lineNumber: this.lineNumber,
6284
- columnNumber: this.columnNumber,
6285
- stack: this.stack,
6286
- // Axios
6287
- config: serializedConfig,
6288
- code: this.code,
6289
- status: this.status
6290
- };
6291
- }
6292
- };
6293
- AxiosError.ERR_BAD_OPTION_VALUE = "ERR_BAD_OPTION_VALUE";
6294
- AxiosError.ERR_BAD_OPTION = "ERR_BAD_OPTION";
6295
- AxiosError.ECONNABORTED = "ECONNABORTED";
6296
- AxiosError.ETIMEDOUT = "ETIMEDOUT";
6297
- AxiosError.ECONNREFUSED = "ECONNREFUSED";
6298
- AxiosError.ERR_NETWORK = "ERR_NETWORK";
6299
- AxiosError.ERR_FR_TOO_MANY_REDIRECTS = "ERR_FR_TOO_MANY_REDIRECTS";
6300
- AxiosError.ERR_DEPRECATED = "ERR_DEPRECATED";
6301
- AxiosError.ERR_BAD_RESPONSE = "ERR_BAD_RESPONSE";
6302
- AxiosError.ERR_BAD_REQUEST = "ERR_BAD_REQUEST";
6303
- AxiosError.ERR_CANCELED = "ERR_CANCELED";
6304
- AxiosError.ERR_NOT_SUPPORT = "ERR_NOT_SUPPORT";
6305
- AxiosError.ERR_INVALID_URL = "ERR_INVALID_URL";
6306
- AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED = "ERR_FORM_DATA_DEPTH_EXCEEDED";
6307
- var AxiosError_default = AxiosError;
6308
-
6309
- // node_modules/axios/lib/helpers/null.js
6310
- var null_default = null;
6311
-
6312
- // node_modules/axios/lib/helpers/toFormData.js
6313
- var DEFAULT_FORM_DATA_MAX_DEPTH = 100;
6314
- function isVisitable(thing) {
6315
- return utils_default.isPlainObject(thing) || utils_default.isArray(thing);
6316
- }
6317
- function removeBrackets(key) {
6318
- return utils_default.endsWith(key, "[]") ? key.slice(0, -2) : key;
6319
- }
6320
- function renderKey(path, key, dots) {
6321
- if (!path) return key;
6322
- return path.concat(key).map(function each(token, i) {
6323
- token = removeBrackets(token);
6324
- return !dots && i ? "[" + token + "]" : token;
6325
- }).join(dots ? "." : "");
6326
- }
6327
- function isFlatArray(arr) {
6328
- return utils_default.isArray(arr) && !arr.some(isVisitable);
6329
- }
6330
- var predicates = utils_default.toFlatObject(utils_default, {}, null, function filter(prop) {
6331
- return /^is[A-Z]/.test(prop);
6332
- });
6333
- function toFormData(obj, formData, options) {
6334
- if (!utils_default.isObject(obj)) {
6335
- throw new TypeError("target must be an object");
6336
- }
6337
- formData = formData || new (null_default || FormData)();
6338
- options = utils_default.toFlatObject(
6339
- options,
6340
- {
6341
- metaTokens: true,
6342
- dots: false,
6343
- indexes: false
6344
- },
6345
- false,
6346
- function defined(option, source) {
6347
- return !utils_default.isUndefined(source[option]);
6348
- }
6349
- );
6350
- const metaTokens = options.metaTokens;
6351
- const visitor = options.visitor || defaultVisitor;
6352
- const dots = options.dots;
6353
- const indexes = options.indexes;
6354
- const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
6355
- const maxDepth = options.maxDepth === void 0 ? DEFAULT_FORM_DATA_MAX_DEPTH : options.maxDepth;
6356
- const useBlob = _Blob && utils_default.isSpecCompliantForm(formData);
6357
- const stack = [];
6358
- if (!utils_default.isFunction(visitor)) {
6359
- throw new TypeError("visitor must be a function");
6360
- }
6361
- function convertValue(value) {
6362
- if (value === null) return "";
6363
- if (utils_default.isDate(value)) {
6364
- return value.toISOString();
6365
- }
6366
- if (utils_default.isBoolean(value)) {
6367
- return value.toString();
6368
- }
6369
- if (!useBlob && utils_default.isBlob(value)) {
6370
- throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
6371
- }
6372
- if (utils_default.isArrayBuffer(value) || utils_default.isTypedArray(value)) {
6373
- return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
6374
- }
6375
- return value;
6376
- }
6377
- function throwIfMaxDepthExceeded(depth) {
6378
- if (depth > maxDepth) {
6379
- throw new AxiosError_default(
6380
- "Object is too deeply nested (" + depth + " levels). Max depth: " + maxDepth,
6381
- AxiosError_default.ERR_FORM_DATA_DEPTH_EXCEEDED
6382
- );
6383
- }
6384
- }
6385
- function stringifyWithDepthLimit(value, depth) {
6386
- if (maxDepth === Infinity) {
6387
- return JSON.stringify(value);
6388
- }
6389
- const ancestors = [];
6390
- return JSON.stringify(value, function limitDepth(_key, currentValue) {
6391
- if (!utils_default.isObject(currentValue)) {
6392
- return currentValue;
6393
- }
6394
- while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
6395
- ancestors.pop();
6396
- }
6397
- ancestors.push(currentValue);
6398
- throwIfMaxDepthExceeded(depth + ancestors.length - 1);
6399
- return currentValue;
6400
- });
6401
- }
6402
- function defaultVisitor(value, key, path) {
6403
- let arr = value;
6404
- if (utils_default.isReactNative(formData) && utils_default.isReactNativeBlob(value)) {
6405
- formData.append(renderKey(path, key, dots), convertValue(value));
6406
- return false;
6407
- }
6408
- if (value && !path && typeof value === "object") {
6409
- if (utils_default.endsWith(key, "{}")) {
6410
- key = metaTokens ? key : key.slice(0, -2);
6411
- value = stringifyWithDepthLimit(value, 1);
6412
- } else if (utils_default.isArray(value) && isFlatArray(value) || (utils_default.isFileList(value) || utils_default.endsWith(key, "[]")) && (arr = utils_default.toArray(value))) {
6413
- key = removeBrackets(key);
6414
- arr.forEach(function each(el, index) {
6415
- !(utils_default.isUndefined(el) || el === null) && formData.append(
6416
- // eslint-disable-next-line no-nested-ternary
6417
- indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
6418
- convertValue(el)
6419
- );
6420
- });
6421
- return false;
6422
- }
6423
- }
6424
- if (isVisitable(value)) {
6425
- return true;
6426
- }
6427
- formData.append(renderKey(path, key, dots), convertValue(value));
6428
- return false;
6429
- }
6430
- const exposedHelpers = Object.assign(predicates, {
6431
- defaultVisitor,
6432
- convertValue,
6433
- isVisitable
6434
- });
6435
- function build(value, path, depth = 0) {
6436
- if (utils_default.isUndefined(value)) return;
6437
- throwIfMaxDepthExceeded(depth);
6438
- if (stack.indexOf(value) !== -1) {
6439
- throw new Error("Circular reference detected in " + path.join("."));
6440
- }
6441
- stack.push(value);
6442
- utils_default.forEach(value, function each(el, key) {
6443
- const result = !(utils_default.isUndefined(el) || el === null) && visitor.call(formData, el, utils_default.isString(key) ? key.trim() : key, path, exposedHelpers);
6444
- if (result === true) {
6445
- build(el, path ? path.concat(key) : [key], depth + 1);
6446
- }
6447
- });
6448
- stack.pop();
6449
- }
6450
- if (!utils_default.isObject(obj)) {
6451
- throw new TypeError("data must be an object");
6452
- }
6453
- build(obj);
6454
- return formData;
6455
- }
6456
- var toFormData_default = toFormData;
6457
-
6458
- // node_modules/axios/lib/helpers/AxiosURLSearchParams.js
6459
- function encode(str) {
6460
- const charMap = {
6461
- "!": "%21",
6462
- "'": "%27",
6463
- "(": "%28",
6464
- ")": "%29",
6465
- "~": "%7E",
6466
- "%20": "+"
6467
- };
6468
- return encodeURIComponent(str).replace(/[!'()~]|%20/g, function replacer(match) {
6469
- return charMap[match];
6470
- });
6471
- }
6472
- function AxiosURLSearchParams(params, options) {
6473
- this._pairs = [];
6474
- params && toFormData_default(params, this, options);
6475
- }
6476
- var prototype = AxiosURLSearchParams.prototype;
6477
- prototype.append = function append(name, value) {
6478
- this._pairs.push([name, value]);
6479
- };
6480
- prototype.toString = function toString2(encoder) {
6481
- const _encode = encoder ? function(value) {
6482
- return encoder.call(this, value, encode);
6483
- } : encode;
6484
- return this._pairs.map(function each(pair) {
6485
- return _encode(pair[0]) + "=" + _encode(pair[1]);
6486
- }, "").join("&");
6487
- };
6488
- var AxiosURLSearchParams_default = AxiosURLSearchParams;
6489
-
6490
- // node_modules/axios/lib/helpers/buildURL.js
6491
- function encode2(val) {
6492
- return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+");
6493
- }
6494
- function buildURL(url, params, options) {
6495
- if (!params) {
6496
- return url;
6497
- }
6498
- const _options = utils_default.isFunction(options) ? {
6499
- serialize: options
6500
- } : options;
6501
- const _encode = utils_default.getSafeProp(_options, "encode") || encode2;
6502
- const serializeFn = utils_default.getSafeProp(_options, "serialize");
6503
- let serializedParams;
6504
- if (serializeFn) {
6505
- serializedParams = serializeFn(params, _options);
6506
- } else {
6507
- serializedParams = utils_default.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams_default(params, _options).toString(_encode);
6508
- }
6509
- if (serializedParams) {
6510
- const hashmarkIndex = url.indexOf("#");
6511
- if (hashmarkIndex !== -1) {
6512
- url = url.slice(0, hashmarkIndex);
6513
- }
6514
- url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
6515
- }
6516
- return url;
6517
- }
6518
-
6519
- // node_modules/axios/lib/core/InterceptorManager.js
6520
- var InterceptorManager = class {
6521
- constructor() {
6522
- this.handlers = [];
6523
- }
6524
- /**
6525
- * Add a new interceptor to the stack
6526
- *
6527
- * @param {Function} fulfilled The function to handle `then` for a `Promise`
6528
- * @param {Function} rejected The function to handle `reject` for a `Promise`
6529
- * @param {Object} options The options for the interceptor, synchronous and runWhen
6530
- *
6531
- * @return {Number} An ID used to remove interceptor later
6532
- */
6533
- use(fulfilled, rejected, options) {
6534
- this.handlers.push({
6535
- fulfilled,
6536
- rejected,
6537
- synchronous: options ? options.synchronous : false,
6538
- runWhen: options ? options.runWhen : null
6539
- });
6540
- return this.handlers.length - 1;
6541
- }
6542
- /**
6543
- * Remove an interceptor from the stack
6544
- *
6545
- * @param {Number} id The ID that was returned by `use`
6546
- *
6547
- * @returns {void}
6548
- */
6549
- eject(id) {
6550
- if (this.handlers[id]) {
6551
- this.handlers[id] = null;
6552
- }
6553
- }
6554
- /**
6555
- * Clear all interceptors from the stack
6556
- *
6557
- * @returns {void}
6558
- */
6559
- clear() {
6560
- if (this.handlers) {
6561
- this.handlers = [];
6562
- }
6563
- }
6564
- /**
6565
- * Iterate over all the registered interceptors
6566
- *
6567
- * This method is particularly useful for skipping over any
6568
- * interceptors that may have become `null` calling `eject`.
6569
- *
6570
- * @param {Function} fn The function to call for each interceptor
6571
- *
6572
- * @returns {void}
6573
- */
6574
- forEach(fn) {
6575
- utils_default.forEach(this.handlers, function forEachHandler(h) {
6576
- if (h !== null) {
6577
- fn(h);
6578
- }
6579
- });
6580
- }
6581
- };
6582
- var InterceptorManager_default = InterceptorManager;
6583
-
6584
- // node_modules/axios/lib/defaults/transitional.js
6585
- var transitional_default = {
6586
- silentJSONParsing: true,
6587
- forcedJSONParsing: true,
6588
- clarifyTimeoutError: false,
6589
- legacyInterceptorReqResOrdering: true,
6590
- advertiseZstdAcceptEncoding: false,
6591
- validateStatusUndefinedResolves: true
6592
- };
6593
-
6594
- // node_modules/axios/lib/platform/browser/classes/URLSearchParams.js
6595
- var URLSearchParams_default = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams_default;
6596
-
6597
- // node_modules/axios/lib/platform/browser/classes/FormData.js
6598
- var FormData_default = typeof FormData !== "undefined" ? FormData : null;
6599
-
6600
- // node_modules/axios/lib/platform/browser/classes/Blob.js
6601
- var Blob_default = typeof Blob !== "undefined" ? Blob : null;
6602
-
6603
- // node_modules/axios/lib/platform/browser/index.js
6604
- var browser_default = {
6605
- isBrowser: true,
6606
- classes: {
6607
- URLSearchParams: URLSearchParams_default,
6608
- FormData: FormData_default,
6609
- Blob: Blob_default
6610
- },
6611
- protocols: ["http", "https", "file", "blob", "url", "data"]
6612
- };
6613
-
6614
- // node_modules/axios/lib/platform/common/utils.js
6615
- var utils_exports = {};
6616
- __export(utils_exports, {
6617
- hasBrowserEnv: () => hasBrowserEnv,
6618
- hasStandardBrowserEnv: () => hasStandardBrowserEnv,
6619
- hasStandardBrowserWebWorkerEnv: () => hasStandardBrowserWebWorkerEnv,
6620
- navigator: () => _navigator,
6621
- origin: () => origin
6622
- });
6623
- var hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
6624
- var _navigator = typeof navigator === "object" && navigator || void 0;
6625
- var hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
6626
- var hasStandardBrowserWebWorkerEnv = (() => {
6627
- return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
6628
- self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
6629
- })();
6630
- var origin = hasBrowserEnv && window.location.href || "http://localhost";
6631
-
6632
- // node_modules/axios/lib/platform/index.js
6633
- var platform_default = {
6634
- ...utils_exports,
6635
- ...browser_default
6636
- };
6637
-
6638
- // node_modules/axios/lib/helpers/toURLEncodedForm.js
6639
- function toURLEncodedForm(data, options) {
6640
- return toFormData_default(data, new platform_default.classes.URLSearchParams(), {
6641
- visitor: function(value, key, path, helpers) {
6642
- if (platform_default.isNode && utils_default.isBuffer(value)) {
6643
- this.append(key, value.toString("base64"));
6644
- return false;
6645
- }
6646
- return helpers.defaultVisitor.apply(this, arguments);
6647
- },
6648
- ...options
6649
- });
6650
- }
6651
-
6652
- // node_modules/axios/lib/helpers/formDataToJSON.js
6653
- var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
6654
- function throwIfDepthExceeded(index) {
6655
- if (index > MAX_DEPTH) {
6656
- throw new AxiosError_default(
6657
- "FormData field is too deeply nested (" + index + " levels). Max depth: " + MAX_DEPTH,
6658
- AxiosError_default.ERR_FORM_DATA_DEPTH_EXCEEDED
6659
- );
6660
- }
6661
- }
6662
- function parsePropPath(name) {
6663
- const path = [];
6664
- const pattern = /\w+|\[(\w*)]/g;
6665
- let match;
6666
- while ((match = pattern.exec(name)) !== null) {
6667
- throwIfDepthExceeded(path.length);
6668
- path.push(match[0] === "[]" ? "" : match[1] || match[0]);
6669
- }
6670
- return path;
6671
- }
6672
- function arrayToObject(arr) {
6673
- const obj = {};
6674
- const keys = Object.keys(arr);
6675
- let i;
6676
- const len = keys.length;
6677
- let key;
6678
- for (i = 0; i < len; i++) {
6679
- key = keys[i];
6680
- obj[key] = arr[key];
6681
- }
6682
- return obj;
6683
- }
6684
- function formDataToJSON(formData) {
6685
- function buildPath(path, value, target, index) {
6686
- throwIfDepthExceeded(index);
6687
- let name = path[index++];
6688
- if (name === "__proto__") return true;
6689
- const isNumericKey = Number.isFinite(+name);
6690
- const isLast = index >= path.length;
6691
- name = !name && utils_default.isArray(target) ? target.length : name;
6692
- if (isLast) {
6693
- if (utils_default.hasOwnProp(target, name)) {
6694
- target[name] = utils_default.isArray(target[name]) ? target[name].concat(value) : [target[name], value];
6695
- } else {
6696
- target[name] = value;
6697
- }
6698
- return !isNumericKey;
6699
- }
6700
- if (!utils_default.hasOwnProp(target, name) || !utils_default.isObject(target[name])) {
6701
- target[name] = [];
6702
- }
6703
- const result = buildPath(path, value, target[name], index);
6704
- if (result && utils_default.isArray(target[name])) {
6705
- target[name] = arrayToObject(target[name]);
6706
- }
6707
- return !isNumericKey;
6708
- }
6709
- if (utils_default.isFormData(formData) && utils_default.isFunction(formData.entries)) {
6710
- const obj = {};
6711
- utils_default.forEachEntry(formData, (name, value) => {
6712
- buildPath(parsePropPath(name), value, obj, 0);
6713
- });
6714
- return obj;
6715
- }
6716
- return null;
6717
- }
6718
- var formDataToJSON_default = formDataToJSON;
6719
-
6720
- // node_modules/axios/lib/defaults/index.js
6721
- var own = (obj, key) => obj != null && utils_default.hasOwnProp(obj, key) ? obj[key] : void 0;
6722
- function stringifySafely(rawValue, parser, encoder) {
6723
- if (utils_default.isString(rawValue)) {
6724
- try {
6725
- (parser || JSON.parse)(rawValue);
6726
- return utils_default.trim(rawValue);
6727
- } catch (e) {
6728
- if (e.name !== "SyntaxError") {
6729
- throw e;
6730
- }
6731
- }
6732
- }
6733
- return (encoder || JSON.stringify)(rawValue);
6734
- }
6735
- var defaults = {
6736
- transitional: transitional_default,
6737
- adapter: ["xhr", "http", "fetch"],
6738
- transformRequest: [
6739
- function transformRequest(data, headers) {
6740
- const contentType = headers.getContentType() || "";
6741
- const hasJSONContentType = contentType.indexOf("application/json") > -1;
6742
- const isObjectPayload = utils_default.isObject(data);
6743
- if (isObjectPayload && utils_default.isHTMLForm(data)) {
6744
- data = new FormData(data);
6745
- }
6746
- const isFormData2 = utils_default.isFormData(data);
6747
- if (isFormData2) {
6748
- return hasJSONContentType ? JSON.stringify(formDataToJSON_default(data)) : data;
6749
- }
6750
- 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)) {
6751
- return data;
6752
- }
6753
- if (utils_default.isArrayBufferView(data)) {
6754
- return data.buffer;
6755
- }
6756
- if (utils_default.isURLSearchParams(data)) {
6757
- headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
6758
- return data.toString();
6759
- }
6760
- let isFileList2;
6761
- if (isObjectPayload) {
6762
- const formSerializer = own(this, "formSerializer");
6763
- if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
6764
- return toURLEncodedForm(data, formSerializer).toString();
6765
- }
6766
- if ((isFileList2 = utils_default.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
6767
- const env = own(this, "env");
6768
- const _FormData = env && env.FormData;
6769
- return toFormData_default(
6770
- isFileList2 ? { "files[]": data } : data,
6771
- _FormData && new _FormData(),
6772
- formSerializer
6773
- );
6774
- }
6775
- }
6776
- if (isObjectPayload || hasJSONContentType) {
6777
- headers.setContentType("application/json", false);
6778
- return stringifySafely(data);
6779
- }
6780
- return data;
6781
- }
6782
- ],
6783
- transformResponse: [
6784
- function transformResponse(data) {
6785
- const transitional2 = own(this, "transitional") || defaults.transitional;
6786
- const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
6787
- const responseType = own(this, "responseType");
6788
- const JSONRequested = responseType === "json";
6789
- if (utils_default.isResponse(data) || utils_default.isReadableStream(data)) {
6790
- return data;
6791
- }
6792
- if (data && utils_default.isString(data) && (forcedJSONParsing && !responseType || JSONRequested)) {
6793
- const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
6794
- const strictJSONParsing = !silentJSONParsing && JSONRequested;
6795
- try {
6796
- return JSON.parse(data, own(this, "parseReviver"));
6797
- } catch (e) {
6798
- if (strictJSONParsing) {
6799
- if (e.name === "SyntaxError") {
6800
- throw AxiosError_default.from(e, AxiosError_default.ERR_BAD_RESPONSE, this, null, own(this, "response"));
6801
- }
6802
- throw e;
6803
- }
6804
- }
6805
- }
6806
- return data;
6807
- }
6808
- ],
6809
- /**
6810
- * A timeout in milliseconds to abort a request. If set to 0 (default) a
6811
- * timeout is not created.
6812
- */
6813
- timeout: 0,
6814
- xsrfCookieName: "XSRF-TOKEN",
6815
- xsrfHeaderName: "X-XSRF-TOKEN",
6816
- maxContentLength: -1,
6817
- maxBodyLength: -1,
6818
- env: {
6819
- FormData: platform_default.classes.FormData,
6820
- Blob: platform_default.classes.Blob
6821
- },
6822
- validateStatus: function validateStatus(status) {
6823
- return status >= 200 && status < 300;
6824
- },
6825
- headers: {
6826
- common: {
6827
- Accept: "application/json, text/plain, */*",
6828
- "Content-Type": void 0
6829
- }
6830
- }
6831
- };
6832
- utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query"], (method) => {
6833
- defaults.headers[method] = {};
6834
- });
6835
- var defaults_default = defaults;
6836
-
6837
- // node_modules/axios/lib/core/transformData.js
6838
- function transformData(fns, response) {
6839
- const config = this || defaults_default;
6840
- const context = response || config;
6841
- const headers = AxiosHeaders_default.from(context.headers);
6842
- let data = context.data;
6843
- utils_default.forEach(fns, function transform(fn) {
6844
- data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
6845
- });
6846
- headers.normalize();
6847
- return data;
6848
- }
6849
-
6850
- // node_modules/axios/lib/cancel/isCancel.js
6851
- function isCancel(value) {
6852
- return !!(value && value.__CANCEL__);
6853
- }
6854
-
6855
- // node_modules/axios/lib/cancel/CanceledError.js
6856
- var CanceledError = class extends AxiosError_default {
6857
- /**
6858
- * A `CanceledError` is an object that is thrown when an operation is canceled.
6859
- *
6860
- * @param {string=} message The message.
6861
- * @param {Object=} config The config.
6862
- * @param {Object=} request The request.
6863
- *
6864
- * @returns {CanceledError} The created error.
6865
- */
6866
- constructor(message, config, request) {
6867
- super(message == null ? "canceled" : message, AxiosError_default.ERR_CANCELED, config, request);
6868
- this.name = "CanceledError";
6869
- this.__CANCEL__ = true;
6870
- }
6871
- };
6872
- var CanceledError_default = CanceledError;
6873
-
6874
- // node_modules/axios/lib/core/settle.js
6875
- function settle(resolve, reject, response) {
6876
- const validateStatus2 = response.config.validateStatus;
6877
- if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
6878
- resolve(response);
6879
- } else {
6880
- reject(new AxiosError_default(
6881
- "Request failed with status code " + response.status,
6882
- response.status >= 400 && response.status < 500 ? AxiosError_default.ERR_BAD_REQUEST : AxiosError_default.ERR_BAD_RESPONSE,
6883
- response.config,
6884
- response.request,
6885
- response
6886
- ));
6887
- }
6888
- }
6889
-
6890
- // node_modules/axios/lib/helpers/parseProtocol.js
6891
- function parseProtocol(url) {
6892
- const match = /^([-+\w]{1,25}):(?:\/\/)?/.exec(url);
6893
- return match && match[1] || "";
6894
- }
6895
-
6896
- // node_modules/axios/lib/helpers/speedometer.js
6897
- function speedometer(samplesCount, min) {
6898
- samplesCount = samplesCount || 10;
6899
- const bytes = new Array(samplesCount);
6900
- const timestamps = new Array(samplesCount);
6901
- let head = 0;
6902
- let tail = 0;
6903
- let firstSampleTS;
6904
- min = min !== void 0 ? min : 1e3;
6905
- return function push(chunkLength) {
6906
- const now = Date.now();
6907
- const startedAt = timestamps[tail];
6908
- if (!firstSampleTS) {
6909
- firstSampleTS = now;
6910
- }
6911
- bytes[head] = chunkLength;
6912
- timestamps[head] = now;
6913
- let i = tail;
6914
- let bytesCount = 0;
6915
- while (i !== head) {
6916
- bytesCount += bytes[i++];
6917
- i = i % samplesCount;
6918
- }
6919
- head = (head + 1) % samplesCount;
6920
- if (head === tail) {
6921
- tail = (tail + 1) % samplesCount;
6922
- }
6923
- if (now - firstSampleTS < min) {
6924
- return;
6925
- }
6926
- const passed = startedAt && now - startedAt;
6927
- return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
6928
- };
6929
- }
6930
- var speedometer_default = speedometer;
6931
-
6932
- // node_modules/axios/lib/helpers/throttle.js
6933
- function throttle(fn, freq) {
6934
- let timestamp = 0;
6935
- let threshold = 1e3 / freq;
6936
- let lastArgs;
6937
- let timer;
6938
- const invoke2 = (args, now = Date.now()) => {
6939
- timestamp = now;
6940
- lastArgs = null;
6941
- if (timer) {
6942
- clearTimeout(timer);
6943
- timer = null;
6944
- }
6945
- fn(...args);
6946
- };
6947
- const throttled = (...args) => {
6948
- const now = Date.now();
6949
- const passed = now - timestamp;
6950
- if (passed >= threshold) {
6951
- invoke2(args, now);
6952
- } else {
6953
- lastArgs = args;
6954
- if (!timer) {
6955
- timer = setTimeout(() => {
6956
- timer = null;
6957
- invoke2(lastArgs);
6958
- }, threshold - passed);
6959
- }
6960
- }
6961
- };
6962
- const flush = () => lastArgs && invoke2(lastArgs);
6963
- return [throttled, flush];
6964
- }
6965
- var throttle_default = throttle;
6966
-
6967
- // node_modules/axios/lib/helpers/progressEventReducer.js
6968
- var progressEventReducer = (listener, isDownloadStream, freq = 3) => {
6969
- let bytesNotified = 0;
6970
- const _speedometer = speedometer_default(50, 250);
6971
- return throttle_default((e) => {
6972
- if (!e || typeof e.loaded !== "number") {
6973
- return;
6974
- }
6975
- const rawLoaded = e.loaded;
6976
- const total = e.lengthComputable ? e.total : void 0;
6977
- const loaded = total != null ? Math.min(rawLoaded, total) : rawLoaded;
6978
- const progressBytes = Math.max(0, loaded - bytesNotified);
6979
- const rate = _speedometer(progressBytes);
6980
- bytesNotified = Math.max(bytesNotified, loaded);
6981
- const data = {
6982
- loaded,
6983
- total,
6984
- progress: total ? loaded / total : void 0,
6985
- bytes: progressBytes,
6986
- rate: rate ? rate : void 0,
6987
- estimated: rate && total ? (total - loaded) / rate : void 0,
6988
- event: e,
6989
- lengthComputable: total != null,
6990
- [isDownloadStream ? "download" : "upload"]: true
6991
- };
6992
- listener(data);
6993
- }, freq);
6994
- };
6995
- var progressEventDecorator = (total, throttled) => {
6996
- const lengthComputable = total != null;
6997
- return [
6998
- (loaded) => throttled[0]({
6999
- lengthComputable,
7000
- total,
7001
- loaded
7002
- }),
7003
- throttled[1]
7004
- ];
7005
- };
7006
- var asyncDecorator = (fn) => (...args) => utils_default.asap(() => fn(...args));
7007
-
7008
- // node_modules/axios/lib/helpers/isURLSameOrigin.js
7009
- var isURLSameOrigin_default = platform_default.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
7010
- url = new URL(url, platform_default.origin);
7011
- return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
7012
- })(
7013
- new URL(platform_default.origin),
7014
- platform_default.navigator && /(msie|trident)/i.test(platform_default.navigator.userAgent)
7015
- ) : () => true;
7016
-
7017
- // node_modules/axios/lib/helpers/cookies.js
7018
- var cookies_default = platform_default.hasStandardBrowserEnv ? (
7019
- // Standard browser envs support document.cookie
7020
- {
7021
- write(name, value, expires, path, domain, secure, sameSite) {
7022
- if (typeof document === "undefined") return;
7023
- const cookie = [`${name}=${encodeURIComponent(value)}`];
7024
- if (utils_default.isNumber(expires)) {
7025
- cookie.push(`expires=${new Date(expires).toUTCString()}`);
7026
- }
7027
- if (utils_default.isString(path)) {
7028
- cookie.push(`path=${path}`);
7029
- }
7030
- if (utils_default.isString(domain)) {
7031
- cookie.push(`domain=${domain}`);
7032
- }
7033
- if (secure === true) {
7034
- cookie.push("secure");
7035
- }
7036
- if (utils_default.isString(sameSite)) {
7037
- cookie.push(`SameSite=${sameSite}`);
7038
- }
7039
- document.cookie = cookie.join("; ");
7040
- },
7041
- read(name) {
7042
- if (typeof document === "undefined") return null;
7043
- const cookies = document.cookie.split(";");
7044
- for (let i = 0; i < cookies.length; i++) {
7045
- const cookie = cookies[i].replace(/^\s+/, "");
7046
- const eq = cookie.indexOf("=");
7047
- if (eq !== -1 && cookie.slice(0, eq) === name) {
7048
- return decodeURIComponent(cookie.slice(eq + 1));
7049
- }
7050
- }
7051
- return null;
7052
- },
7053
- remove(name) {
7054
- this.write(name, "", Date.now() - 864e5, "/");
7055
- }
7056
- }
7057
- ) : (
7058
- // Non-standard browser env (web workers, react-native) lack needed support.
7059
- {
7060
- write() {
7061
- },
7062
- read() {
7063
- return null;
7064
- },
7065
- remove() {
7066
- }
7067
- }
7068
- );
7069
-
7070
- // node_modules/axios/lib/helpers/isAbsoluteURL.js
7071
- function isAbsoluteURL(url) {
7072
- if (typeof url !== "string") {
7073
- return false;
7074
- }
7075
- return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
7076
- }
7077
-
7078
- // node_modules/axios/lib/helpers/combineURLs.js
7079
- function combineURLs(baseURL, relativeURL) {
7080
- return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
7081
- }
7082
-
7083
- // node_modules/axios/lib/core/buildFullPath.js
7084
- var malformedHttpProtocol = /^https?:(?!\/\/)/i;
7085
- var httpProtocolControlCharacters = /[\t\n\r]/g;
7086
- function stripLeadingC0ControlOrSpace(url) {
7087
- let i = 0;
7088
- while (i < url.length && url.charCodeAt(i) <= 32) {
7089
- i++;
7090
- }
7091
- return url.slice(i);
7092
- }
7093
- function normalizeURLForProtocolCheck(url) {
7094
- return stripLeadingC0ControlOrSpace(url).replace(httpProtocolControlCharacters, "");
7095
- }
7096
- function assertValidHttpProtocolURL(url, config) {
7097
- if (typeof url === "string" && malformedHttpProtocol.test(normalizeURLForProtocolCheck(url))) {
7098
- throw new AxiosError_default(
7099
- 'Invalid URL: missing "//" after protocol',
7100
- AxiosError_default.ERR_INVALID_URL,
7101
- config
7102
- );
7103
- }
7104
- }
7105
- function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls, config) {
7106
- assertValidHttpProtocolURL(requestedURL, config);
7107
- let isRelativeUrl = !isAbsoluteURL(requestedURL);
7108
- if (baseURL && (isRelativeUrl || allowAbsoluteUrls === false)) {
7109
- assertValidHttpProtocolURL(baseURL, config);
7110
- return combineURLs(baseURL, requestedURL);
7111
- }
7112
- return requestedURL;
7113
- }
7114
-
7115
- // node_modules/axios/lib/core/mergeConfig.js
7116
- var headersToObject = (thing) => thing instanceof AxiosHeaders_default ? { ...thing } : thing;
7117
- function mergeConfig(config1, config2) {
7118
- config2 = config2 || {};
7119
- const config = /* @__PURE__ */ Object.create(null);
7120
- Object.defineProperty(config, "hasOwnProperty", {
7121
- // Null-proto descriptor so a polluted Object.prototype.get cannot turn
7122
- // this data descriptor into an accessor descriptor on the way in.
7123
- __proto__: null,
7124
- value: Object.prototype.hasOwnProperty,
7125
- enumerable: false,
7126
- writable: true,
7127
- configurable: true
7128
- });
7129
- function getMergedValue(target, source, prop, caseless) {
7130
- if (utils_default.isPlainObject(target) && utils_default.isPlainObject(source)) {
7131
- return utils_default.merge.call({ caseless }, target, source);
7132
- } else if (utils_default.isPlainObject(source)) {
7133
- return utils_default.merge({}, source);
7134
- } else if (utils_default.isArray(source)) {
7135
- return source.slice();
7136
- }
7137
- return source;
7138
- }
7139
- function mergeDeepProperties(a, b, prop, caseless) {
7140
- if (!utils_default.isUndefined(b)) {
7141
- return getMergedValue(a, b, prop, caseless);
7142
- } else if (!utils_default.isUndefined(a)) {
7143
- return getMergedValue(void 0, a, prop, caseless);
7144
- }
7145
- }
7146
- function valueFromConfig2(a, b) {
7147
- if (!utils_default.isUndefined(b)) {
7148
- return getMergedValue(void 0, b);
7149
- }
7150
- }
7151
- function defaultToConfig2(a, b) {
7152
- if (!utils_default.isUndefined(b)) {
7153
- return getMergedValue(void 0, b);
7154
- } else if (!utils_default.isUndefined(a)) {
7155
- return getMergedValue(void 0, a);
7156
- }
7157
- }
7158
- function getMergedTransitionalOption(prop) {
7159
- const transitional2 = utils_default.hasOwnProp(config2, "transitional") ? config2.transitional : void 0;
7160
- if (!utils_default.isUndefined(transitional2)) {
7161
- if (utils_default.isPlainObject(transitional2)) {
7162
- if (utils_default.hasOwnProp(transitional2, prop)) {
7163
- return transitional2[prop];
7164
- }
7165
- } else {
7166
- return void 0;
7167
- }
7168
- }
7169
- const transitional1 = utils_default.hasOwnProp(config1, "transitional") ? config1.transitional : void 0;
7170
- if (utils_default.isPlainObject(transitional1) && utils_default.hasOwnProp(transitional1, prop)) {
7171
- return transitional1[prop];
7172
- }
7173
- return void 0;
7174
- }
7175
- function mergeDirectKeys(a, b, prop) {
7176
- if (utils_default.hasOwnProp(config2, prop)) {
7177
- return getMergedValue(a, b);
7178
- } else if (utils_default.hasOwnProp(config1, prop)) {
7179
- return getMergedValue(void 0, a);
7180
- }
7181
- }
7182
- const mergeMap = {
7183
- url: valueFromConfig2,
7184
- method: valueFromConfig2,
7185
- data: valueFromConfig2,
7186
- baseURL: defaultToConfig2,
7187
- transformRequest: defaultToConfig2,
7188
- transformResponse: defaultToConfig2,
7189
- paramsSerializer: defaultToConfig2,
7190
- timeout: defaultToConfig2,
7191
- timeoutMessage: defaultToConfig2,
7192
- withCredentials: defaultToConfig2,
7193
- withXSRFToken: defaultToConfig2,
7194
- adapter: defaultToConfig2,
7195
- responseType: defaultToConfig2,
7196
- xsrfCookieName: defaultToConfig2,
7197
- xsrfHeaderName: defaultToConfig2,
7198
- onUploadProgress: defaultToConfig2,
7199
- onDownloadProgress: defaultToConfig2,
7200
- decompress: defaultToConfig2,
7201
- maxContentLength: defaultToConfig2,
7202
- maxBodyLength: defaultToConfig2,
7203
- beforeRedirect: defaultToConfig2,
7204
- transport: defaultToConfig2,
7205
- httpAgent: defaultToConfig2,
7206
- httpsAgent: defaultToConfig2,
7207
- cancelToken: defaultToConfig2,
7208
- socketPath: defaultToConfig2,
7209
- allowedSocketPaths: defaultToConfig2,
7210
- responseEncoding: defaultToConfig2,
7211
- validateStatus: mergeDirectKeys,
7212
- headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
7213
- };
7214
- utils_default.forEach(Object.keys({ ...config1, ...config2 }), function computeConfigValue(prop) {
7215
- if (prop === "__proto__" || prop === "constructor" || prop === "prototype") return;
7216
- const merge2 = utils_default.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
7217
- const a = utils_default.hasOwnProp(config1, prop) ? config1[prop] : void 0;
7218
- const b = utils_default.hasOwnProp(config2, prop) ? config2[prop] : void 0;
7219
- const configValue = merge2(a, b, prop);
7220
- utils_default.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
7221
- });
7222
- if (utils_default.hasOwnProp(config2, "validateStatus") && utils_default.isUndefined(config2.validateStatus) && getMergedTransitionalOption("validateStatusUndefinedResolves") === false) {
7223
- if (utils_default.hasOwnProp(config1, "validateStatus")) {
7224
- config.validateStatus = getMergedValue(void 0, config1.validateStatus);
7225
- } else {
7226
- delete config.validateStatus;
7227
- }
7228
- }
7229
- return config;
7230
- }
7231
-
7232
- // node_modules/axios/lib/helpers/resolveConfig.js
7233
- var FORM_DATA_CONTENT_HEADERS = ["content-type", "content-length"];
7234
- function setFormDataHeaders(headers, formHeaders, policy) {
7235
- if (policy !== "content-only") {
7236
- headers.set(formHeaders);
7237
- return;
7238
- }
7239
- Object.entries(formHeaders).forEach(([key, val]) => {
7240
- if (FORM_DATA_CONTENT_HEADERS.includes(key.toLowerCase())) {
7241
- headers.set(key, val);
7242
- }
7243
- });
7244
- }
7245
- var encodeUTF8 = (str) => encodeURIComponent(str).replace(
7246
- /%([0-9A-F]{2})/gi,
7247
- (_, hex) => String.fromCharCode(parseInt(hex, 16))
7248
- );
7249
- function resolveConfig(config) {
7250
- const newConfig = mergeConfig({}, config);
7251
- const own2 = (key) => utils_default.hasOwnProp(newConfig, key) ? newConfig[key] : void 0;
7252
- const data = own2("data");
7253
- let withXSRFToken = own2("withXSRFToken");
7254
- const xsrfHeaderName = own2("xsrfHeaderName");
7255
- const xsrfCookieName = own2("xsrfCookieName");
7256
- let headers = own2("headers");
7257
- const auth = own2("auth");
7258
- const baseURL = own2("baseURL");
7259
- const allowAbsoluteUrls = own2("allowAbsoluteUrls");
7260
- const url = own2("url");
7261
- newConfig.headers = headers = AxiosHeaders_default.from(headers);
7262
- newConfig.url = buildURL(
7263
- buildFullPath(baseURL, url, allowAbsoluteUrls, newConfig),
7264
- own2("params"),
7265
- own2("paramsSerializer")
7266
- );
7267
- if (auth) {
7268
- const username = utils_default.getSafeProp(auth, "username") || "";
7269
- const password = utils_default.getSafeProp(auth, "password") || "";
7270
- headers.set(
7271
- "Authorization",
7272
- "Basic " + btoa(username + ":" + (password ? encodeUTF8(password) : ""))
7273
- );
7274
- }
7275
- if (utils_default.isFormData(data)) {
7276
- if (platform_default.hasStandardBrowserEnv || platform_default.hasStandardBrowserWebWorkerEnv || utils_default.isReactNative(data)) {
7277
- headers.setContentType(void 0);
7278
- } else if (utils_default.isFunction(data.getHeaders)) {
7279
- setFormDataHeaders(headers, data.getHeaders(), own2("formDataHeaderPolicy"));
7280
- }
7281
- }
7282
- if (platform_default.hasStandardBrowserEnv) {
7283
- if (utils_default.isFunction(withXSRFToken)) {
7284
- withXSRFToken = withXSRFToken(newConfig);
7285
- }
7286
- const shouldSendXSRF = withXSRFToken === true || withXSRFToken == null && isURLSameOrigin_default(newConfig.url);
7287
- if (shouldSendXSRF) {
7288
- const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies_default.read(xsrfCookieName);
7289
- if (xsrfValue) {
7290
- headers.set(xsrfHeaderName, xsrfValue);
7291
- }
7292
- }
7293
- }
7294
- return newConfig;
7295
- }
7296
- var resolveConfig_default = resolveConfig;
7297
-
7298
- // node_modules/axios/lib/adapters/xhr.js
7299
- var isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
7300
- var xhr_default = isXHRAdapterSupported && function(config) {
7301
- return new Promise(function dispatchXhrRequest(resolve, reject) {
7302
- const _config = resolveConfig_default(config);
7303
- let requestData = _config.data;
7304
- const requestHeaders = AxiosHeaders_default.from(_config.headers).normalize();
7305
- let { responseType, onUploadProgress, onDownloadProgress } = _config;
7306
- let onCanceled;
7307
- let uploadThrottled, downloadThrottled;
7308
- let flushUpload, flushDownload;
7309
- function done() {
7310
- flushUpload && flushUpload();
7311
- flushDownload && flushDownload();
7312
- _config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
7313
- _config.signal && _config.signal.removeEventListener("abort", onCanceled);
7314
- }
7315
- let request = new XMLHttpRequest();
7316
- request.open(_config.method.toUpperCase(), _config.url, true);
7317
- request.timeout = _config.timeout;
7318
- function onloadend() {
7319
- if (!request) {
7320
- return;
7321
- }
7322
- const responseHeaders = AxiosHeaders_default.from(
7323
- "getAllResponseHeaders" in request && request.getAllResponseHeaders()
7324
- );
7325
- const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
7326
- const response = {
7327
- data: responseData,
7328
- status: request.status,
7329
- statusText: request.statusText,
7330
- headers: responseHeaders,
7331
- config,
7332
- request
7333
- };
7334
- settle(
7335
- function _resolve(value) {
7336
- resolve(value);
7337
- done();
7338
- },
7339
- function _reject(err) {
7340
- reject(err);
7341
- done();
7342
- },
7343
- response
7344
- );
7345
- request = null;
7346
- }
7347
- if ("onloadend" in request) {
7348
- request.onloadend = onloadend;
7349
- } else {
7350
- request.onreadystatechange = function handleLoad() {
7351
- if (!request || request.readyState !== 4) {
7352
- return;
7353
- }
7354
- if (request.status === 0 && !(request.responseURL && request.responseURL.startsWith("file:"))) {
7355
- return;
7356
- }
7357
- setTimeout(onloadend);
7358
- };
7359
- }
7360
- request.onabort = function handleAbort() {
7361
- if (!request) {
7362
- return;
7363
- }
7364
- reject(new AxiosError_default("Request aborted", AxiosError_default.ECONNABORTED, config, request));
7365
- done();
7366
- request = null;
7367
- };
7368
- request.onerror = function handleError(event) {
7369
- const msg = event && event.message ? event.message : "Network Error";
7370
- const err = new AxiosError_default(msg, AxiosError_default.ERR_NETWORK, config, request);
7371
- err.event = event || null;
7372
- reject(err);
7373
- done();
7374
- request = null;
7375
- };
7376
- request.ontimeout = function handleTimeout() {
7377
- let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
7378
- const transitional2 = _config.transitional || transitional_default;
7379
- if (_config.timeoutErrorMessage) {
7380
- timeoutErrorMessage = _config.timeoutErrorMessage;
7381
- }
7382
- reject(
7383
- new AxiosError_default(
7384
- timeoutErrorMessage,
7385
- transitional2.clarifyTimeoutError ? AxiosError_default.ETIMEDOUT : AxiosError_default.ECONNABORTED,
7386
- config,
7387
- request
7388
- )
7389
- );
7390
- done();
7391
- request = null;
7392
- };
7393
- requestData === void 0 && requestHeaders.setContentType(null);
7394
- if ("setRequestHeader" in request) {
7395
- utils_default.forEach(toByteStringHeaderObject(requestHeaders), function setRequestHeader(val, key) {
7396
- request.setRequestHeader(key, val);
7397
- });
7398
- }
7399
- if (!utils_default.isUndefined(_config.withCredentials)) {
7400
- request.withCredentials = !!_config.withCredentials;
7401
- }
7402
- if (responseType && responseType !== "json") {
7403
- request.responseType = _config.responseType;
7404
- }
7405
- if (onDownloadProgress) {
7406
- [downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
7407
- request.addEventListener("progress", downloadThrottled);
7408
- }
7409
- if (onUploadProgress && request.upload) {
7410
- [uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
7411
- request.upload.addEventListener("progress", uploadThrottled);
7412
- request.upload.addEventListener("loadend", flushUpload);
7413
- }
7414
- if (_config.cancelToken || _config.signal) {
7415
- onCanceled = (cancel) => {
7416
- if (!request) {
7417
- return;
7418
- }
7419
- reject(!cancel || cancel.type ? new CanceledError_default(null, config, request) : cancel);
7420
- request.abort();
7421
- done();
7422
- request = null;
7423
- };
7424
- _config.cancelToken && _config.cancelToken.subscribe(onCanceled);
7425
- if (_config.signal) {
7426
- _config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
7427
- }
7428
- }
7429
- const protocol = parseProtocol(_config.url);
7430
- if (protocol && !platform_default.protocols.includes(protocol)) {
7431
- reject(
7432
- new AxiosError_default(
7433
- "Unsupported protocol " + protocol + ":",
7434
- AxiosError_default.ERR_BAD_REQUEST,
7435
- config
7436
- )
7437
- );
7438
- return;
7439
- }
7440
- request.send(requestData || null);
7441
- });
7442
- };
7443
-
7444
- // node_modules/axios/lib/helpers/composeSignals.js
7445
- var composeSignals = (signals, timeout) => {
7446
- signals = signals ? signals.filter(Boolean) : [];
7447
- if (!timeout && !signals.length) {
7448
- return;
7449
- }
7450
- const controller = new AbortController();
7451
- let aborted = false;
7452
- const onabort = function(reason) {
7453
- if (!aborted) {
7454
- aborted = true;
7455
- unsubscribe();
7456
- const err = reason instanceof Error ? reason : this.reason;
7457
- controller.abort(
7458
- err instanceof AxiosError_default ? err : new CanceledError_default(err instanceof Error ? err.message : err)
7459
- );
7460
- }
7461
- };
7462
- let timer = timeout && setTimeout(() => {
7463
- timer = null;
7464
- onabort(new AxiosError_default(`timeout of ${timeout}ms exceeded`, AxiosError_default.ETIMEDOUT));
7465
- }, timeout);
7466
- const unsubscribe = () => {
7467
- if (!signals) {
7468
- return;
7469
- }
7470
- timer && clearTimeout(timer);
7471
- timer = null;
7472
- signals.forEach((signal2) => {
7473
- signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
7474
- });
7475
- signals = null;
7476
- };
7477
- signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
7478
- const { signal } = controller;
7479
- signal.unsubscribe = () => utils_default.asap(unsubscribe);
7480
- return signal;
7481
- };
7482
- var composeSignals_default = composeSignals;
7483
-
7484
- // node_modules/axios/lib/helpers/trackStream.js
7485
- var streamChunk = function* (chunk, chunkSize) {
7486
- let len = chunk.byteLength;
7487
- if (!chunkSize || len < chunkSize) {
7488
- yield chunk;
7489
- return;
7490
- }
7491
- let pos = 0;
7492
- let end;
7493
- while (pos < len) {
7494
- end = pos + chunkSize;
7495
- yield chunk.slice(pos, end);
7496
- pos = end;
7497
- }
7498
- };
7499
- var readBytes = async function* (iterable, chunkSize) {
7500
- for await (const chunk of readStream(iterable)) {
7501
- yield* streamChunk(chunk, chunkSize);
7502
- }
7503
- };
7504
- var readStream = async function* (stream) {
7505
- if (stream[Symbol.asyncIterator]) {
7506
- yield* stream;
7507
- return;
7508
- }
7509
- const reader = stream.getReader();
7510
- try {
7511
- for (; ; ) {
7512
- const { done, value } = await reader.read();
7513
- if (done) {
7514
- break;
7515
- }
7516
- yield value;
7517
- }
7518
- } finally {
7519
- await reader.cancel();
7520
- }
7521
- };
7522
- var trackStream = (stream, chunkSize, onProgress, onFinish) => {
7523
- const iterator2 = readBytes(stream, chunkSize);
7524
- let bytes = 0;
7525
- let done;
7526
- let _onFinish = (e) => {
7527
- if (!done) {
7528
- done = true;
7529
- onFinish && onFinish(e);
7530
- }
7531
- };
7532
- return new ReadableStream(
7533
- {
7534
- async pull(controller) {
7535
- try {
7536
- const { done: done2, value } = await iterator2.next();
7537
- if (done2) {
7538
- _onFinish();
7539
- controller.close();
7540
- return;
7541
- }
7542
- let len = value.byteLength;
7543
- if (onProgress) {
7544
- let loadedBytes = bytes += len;
7545
- onProgress(loadedBytes);
7546
- }
7547
- controller.enqueue(new Uint8Array(value));
7548
- } catch (err) {
7549
- _onFinish(err);
7550
- throw err;
7551
- }
7552
- },
7553
- cancel(reason) {
7554
- _onFinish(reason);
7555
- return iterator2.return();
7556
- }
7557
- },
7558
- {
7559
- highWaterMark: 2
7560
- }
7561
- );
7562
- };
7563
-
7564
- // node_modules/axios/lib/helpers/estimateDataURLDecodedBytes.js
7565
- var isHexDigit = (charCode) => charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;
7566
- var isPercentEncodedByte = (str, i, len) => i + 2 < len && isHexDigit(str.charCodeAt(i + 1)) && isHexDigit(str.charCodeAt(i + 2));
7567
- function estimateDataURLDecodedBytes(url) {
7568
- if (!url || typeof url !== "string") return 0;
7569
- if (!url.startsWith("data:")) return 0;
7570
- const comma = url.indexOf(",");
7571
- if (comma < 0) return 0;
7572
- const meta = url.slice(5, comma);
7573
- const body = url.slice(comma + 1);
7574
- const isBase64 = /;base64/i.test(meta);
7575
- if (isBase64) {
7576
- let effectiveLen = body.length;
7577
- const len = body.length;
7578
- for (let i = 0; i < len; i++) {
7579
- if (body.charCodeAt(i) === 37 && i + 2 < len) {
7580
- const a = body.charCodeAt(i + 1);
7581
- const b = body.charCodeAt(i + 2);
7582
- const isHex = isHexDigit(a) && isHexDigit(b);
7583
- if (isHex) {
7584
- effectiveLen -= 2;
7585
- i += 2;
7586
- }
7587
- }
7588
- }
7589
- let pad = 0;
7590
- let idx = len - 1;
7591
- const tailIsPct3D = (j) => j >= 2 && body.charCodeAt(j - 2) === 37 && // '%'
7592
- body.charCodeAt(j - 1) === 51 && // '3'
7593
- (body.charCodeAt(j) === 68 || body.charCodeAt(j) === 100);
7594
- if (idx >= 0) {
7595
- if (body.charCodeAt(idx) === 61) {
7596
- pad++;
7597
- idx--;
7598
- } else if (tailIsPct3D(idx)) {
7599
- pad++;
7600
- idx -= 3;
7601
- }
7602
- }
7603
- if (pad === 1 && idx >= 0) {
7604
- if (body.charCodeAt(idx) === 61) {
7605
- pad++;
7606
- } else if (tailIsPct3D(idx)) {
7607
- pad++;
7608
- }
7609
- }
7610
- const groups = Math.floor(effectiveLen / 4);
7611
- const bytes2 = groups * 3 - (pad || 0);
7612
- return bytes2 > 0 ? bytes2 : 0;
7613
- }
7614
- let bytes = 0;
7615
- for (let i = 0, len = body.length; i < len; i++) {
7616
- const c = body.charCodeAt(i);
7617
- if (c === 37 && isPercentEncodedByte(body, i, len)) {
7618
- bytes += 1;
7619
- i += 2;
7620
- } else if (c < 128) {
7621
- bytes += 1;
7622
- } else if (c < 2048) {
7623
- bytes += 2;
7624
- } else if (c >= 55296 && c <= 56319 && i + 1 < len) {
7625
- const next = body.charCodeAt(i + 1);
7626
- if (next >= 56320 && next <= 57343) {
7627
- bytes += 4;
7628
- i++;
7629
- } else {
7630
- bytes += 3;
7631
- }
7632
- } else {
7633
- bytes += 3;
7634
- }
7635
- }
7636
- return bytes;
7637
- }
7638
-
7639
- // node_modules/axios/lib/env/data.js
7640
- var VERSION = "1.18.0";
7641
-
7642
- // node_modules/axios/lib/adapters/fetch.js
7643
- var DEFAULT_CHUNK_SIZE = 64 * 1024;
7644
- var { isFunction: isFunction2 } = utils_default;
7645
- var encodeUTF82 = (str) => encodeURIComponent(str).replace(
7646
- /%([0-9A-F]{2})/gi,
7647
- (_, hex) => String.fromCharCode(parseInt(hex, 16))
7648
- );
7649
- var decodeURIComponentSafe = (value) => {
7650
- if (!utils_default.isString(value)) {
7651
- return value;
7652
- }
7653
- try {
7654
- return decodeURIComponent(value);
7655
- } catch (error) {
7656
- return value;
7657
- }
7658
- };
7659
- var test = (fn, ...args) => {
7660
- try {
7661
- return !!fn(...args);
7662
- } catch (e) {
7663
- return false;
7664
- }
7665
- };
7666
- var maybeWithAuthCredentials = (url) => {
7667
- const protocolIndex = url.indexOf("://");
7668
- let urlToCheck = url;
7669
- if (protocolIndex !== -1) {
7670
- urlToCheck = urlToCheck.slice(protocolIndex + 3);
7671
- }
7672
- return urlToCheck.includes("@") || urlToCheck.includes(":");
7673
- };
7674
- var factory = (env) => {
7675
- const globalObject = utils_default.global !== void 0 && utils_default.global !== null ? utils_default.global : globalThis;
7676
- const { ReadableStream: ReadableStream2, TextEncoder } = globalObject;
7677
- env = utils_default.merge.call(
7678
- {
7679
- skipUndefined: true
7680
- },
7681
- {
7682
- Request: globalObject.Request,
7683
- Response: globalObject.Response
7684
- },
7685
- env
7686
- );
7687
- const { fetch: envFetch, Request, Response } = env;
7688
- const isFetchSupported = envFetch ? isFunction2(envFetch) : typeof fetch === "function";
7689
- const isRequestSupported = isFunction2(Request);
7690
- const isResponseSupported = isFunction2(Response);
7691
- if (!isFetchSupported) {
7692
- return false;
7693
- }
7694
- const isReadableStreamSupported = isFetchSupported && isFunction2(ReadableStream2);
7695
- const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
7696
- const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
7697
- let duplexAccessed = false;
7698
- const request = new Request(platform_default.origin, {
7699
- body: new ReadableStream2(),
7700
- method: "POST",
7701
- get duplex() {
7702
- duplexAccessed = true;
7703
- return "half";
7704
- }
7705
- });
7706
- const hasContentType = request.headers.has("Content-Type");
7707
- if (request.body != null) {
7708
- request.body.cancel();
7709
- }
7710
- return duplexAccessed && !hasContentType;
7711
- });
7712
- const supportsResponseStream = isResponseSupported && isReadableStreamSupported && test(() => utils_default.isReadableStream(new Response("").body));
7713
- const resolvers = {
7714
- stream: supportsResponseStream && ((res) => res.body)
7715
- };
7716
- isFetchSupported && (() => {
7717
- ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
7718
- !resolvers[type] && (resolvers[type] = (res, config) => {
7719
- let method = res && res[type];
7720
- if (method) {
7721
- return method.call(res);
7722
- }
7723
- throw new AxiosError_default(
7724
- `Response type '${type}' is not supported`,
7725
- AxiosError_default.ERR_NOT_SUPPORT,
7726
- config
7727
- );
7728
- });
7729
- });
7730
- })();
7731
- const getBodyLength = async (body) => {
7732
- if (body == null) {
7733
- return 0;
7734
- }
7735
- if (utils_default.isBlob(body)) {
7736
- return body.size;
7737
- }
7738
- if (utils_default.isSpecCompliantForm(body)) {
7739
- const _request = new Request(platform_default.origin, {
7740
- method: "POST",
7741
- body
7742
- });
7743
- return (await _request.arrayBuffer()).byteLength;
7744
- }
7745
- if (utils_default.isArrayBufferView(body) || utils_default.isArrayBuffer(body)) {
7746
- return body.byteLength;
7747
- }
7748
- if (utils_default.isURLSearchParams(body)) {
7749
- body = body + "";
7750
- }
7751
- if (utils_default.isString(body)) {
7752
- return (await encodeText(body)).byteLength;
7753
- }
7754
- };
7755
- const resolveBodyLength = async (headers, body) => {
7756
- const length = utils_default.toFiniteNumber(headers.getContentLength());
7757
- return length == null ? getBodyLength(body) : length;
7758
- };
7759
- return async (config) => {
7760
- let {
7761
- url,
7762
- method,
7763
- data,
7764
- signal,
7765
- cancelToken,
7766
- timeout,
7767
- onDownloadProgress,
7768
- onUploadProgress,
7769
- responseType,
7770
- headers,
7771
- withCredentials = "same-origin",
7772
- fetchOptions,
7773
- maxContentLength,
7774
- maxBodyLength
7775
- } = resolveConfig_default(config);
7776
- const hasMaxContentLength = utils_default.isNumber(maxContentLength) && maxContentLength > -1;
7777
- const hasMaxBodyLength = utils_default.isNumber(maxBodyLength) && maxBodyLength > -1;
7778
- const own2 = (key) => utils_default.hasOwnProp(config, key) ? config[key] : void 0;
7779
- let _fetch = envFetch || fetch;
7780
- responseType = responseType ? (responseType + "").toLowerCase() : "text";
7781
- let composedSignal = composeSignals_default(
7782
- [signal, cancelToken && cancelToken.toAbortSignal()],
7783
- timeout
7784
- );
7785
- let request = null;
7786
- const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
7787
- composedSignal.unsubscribe();
7788
- });
7789
- let requestContentLength;
7790
- let pendingBodyError = null;
7791
- const maxBodyLengthError = () => new AxiosError_default(
7792
- "Request body larger than maxBodyLength limit",
7793
- AxiosError_default.ERR_BAD_REQUEST,
7794
- config,
7795
- request
7796
- );
7797
- try {
7798
- let auth = void 0;
7799
- const configAuth = own2("auth");
7800
- if (configAuth) {
7801
- const username = utils_default.getSafeProp(configAuth, "username") || "";
7802
- const password = utils_default.getSafeProp(configAuth, "password") || "";
7803
- auth = {
7804
- username,
7805
- password
7806
- };
7807
- }
7808
- if (maybeWithAuthCredentials(url)) {
7809
- const parsedURL = new URL(url, platform_default.origin);
7810
- if (!auth && (parsedURL.username || parsedURL.password)) {
7811
- const urlUsername = decodeURIComponentSafe(parsedURL.username);
7812
- const urlPassword = decodeURIComponentSafe(parsedURL.password);
7813
- auth = {
7814
- username: urlUsername,
7815
- password: urlPassword
7816
- };
7817
- }
7818
- if (parsedURL.username || parsedURL.password) {
7819
- parsedURL.username = "";
7820
- parsedURL.password = "";
7821
- url = parsedURL.href;
7822
- }
7823
- }
7824
- if (auth) {
7825
- headers.delete("authorization");
7826
- headers.set(
7827
- "Authorization",
7828
- "Basic " + btoa(encodeUTF82((auth.username || "") + ":" + (auth.password || "")))
7829
- );
5301
+ externalCallback(null, err);
5302
+ emitPaymentStatus(null, err);
7830
5303
  }
7831
- if (hasMaxContentLength && typeof url === "string" && url.startsWith("data:")) {
7832
- const estimated = estimateDataURLDecodedBytes(url);
7833
- if (estimated > maxContentLength) {
7834
- throw new AxiosError_default(
7835
- "maxContentLength size of " + maxContentLength + " exceeded",
7836
- AxiosError_default.ERR_BAD_RESPONSE,
7837
- config,
7838
- request
5304
+ };
5305
+ initializePayment = async (externalCallback = () => {
5306
+ }) => {
5307
+ if (paymentInitialized) return;
5308
+ paymentInitialized = true;
5309
+ if (isCapacitor) {
5310
+ App.addListener("appUrlOpen", (event) => {
5311
+ handlePaymentCallback(
5312
+ event.url,
5313
+ externalCallback
7839
5314
  );
7840
- }
7841
- }
7842
- if (hasMaxBodyLength && method !== "get" && method !== "head") {
7843
- const outboundLength = await getBodyLength(data);
7844
- if (typeof outboundLength === "number" && isFinite(outboundLength)) {
7845
- requestContentLength = outboundLength;
7846
- if (outboundLength > maxBodyLength) {
7847
- throw maxBodyLengthError();
7848
- }
7849
- }
5315
+ });
7850
5316
  }
7851
- const mustEnforceStreamBody = hasMaxBodyLength && (utils_default.isReadableStream(data) || utils_default.isStream(data));
7852
- const trackRequestStream = (stream, onProgress, flush) => trackStream(
7853
- stream,
7854
- DEFAULT_CHUNK_SIZE,
7855
- (loadedBytes) => {
7856
- if (hasMaxBodyLength && loadedBytes > maxBodyLength) {
7857
- throw pendingBodyError = maxBodyLengthError();
7858
- }
7859
- onProgress && onProgress(loadedBytes);
7860
- },
7861
- flush
7862
- );
7863
- if (supportsRequestStream && method !== "get" && method !== "head" && (onUploadProgress || mustEnforceStreamBody)) {
7864
- requestContentLength = requestContentLength == null ? await resolveBodyLength(headers, data) : requestContentLength;
7865
- if (requestContentLength !== 0 || mustEnforceStreamBody) {
7866
- let _request = new Request(url, {
7867
- method: "POST",
7868
- body: data,
7869
- duplex: "half"
7870
- });
7871
- let contentTypeHeader;
7872
- if (utils_default.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
7873
- headers.setContentType(contentTypeHeader);
5317
+ if (isTauri) {
5318
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
5319
+ await listen2("deep-link://open-url", async (event) => {
5320
+ let url = event.payload;
5321
+ if (typeof url === "object") {
5322
+ url = url?.url || url?.payload || null;
7874
5323
  }
7875
- if (_request.body) {
7876
- const [onProgress, flush] = onUploadProgress && progressEventDecorator(
7877
- requestContentLength,
7878
- progressEventReducer(asyncDecorator(onUploadProgress))
7879
- ) || [];
7880
- data = trackRequestStream(_request.body, onProgress, flush);
5324
+ if (!url) return;
5325
+ if (paymentWindowRef) {
5326
+ try {
5327
+ await paymentWindowRef.close();
5328
+ paymentWindowRef = null;
5329
+ } catch (e) {
5330
+ }
7881
5331
  }
7882
- }
7883
- } else if (mustEnforceStreamBody && !isRequestSupported && isReadableStreamSupported && method !== "get" && method !== "head") {
7884
- data = trackRequestStream(data);
7885
- } else if (mustEnforceStreamBody && isRequestSupported && !supportsRequestStream && method !== "get" && method !== "head") {
7886
- throw new AxiosError_default(
7887
- "Stream request bodies are not supported by the current fetch implementation",
7888
- AxiosError_default.ERR_NOT_SUPPORT,
7889
- config,
7890
- request
7891
- );
7892
- }
7893
- if (!utils_default.isString(withCredentials)) {
7894
- withCredentials = withCredentials ? "include" : "omit";
7895
- }
7896
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
7897
- if (utils_default.isFormData(data)) {
7898
- const contentType = headers.getContentType();
7899
- if (contentType && /^multipart\/form-data/i.test(contentType) && !/boundary=/i.test(contentType)) {
7900
- headers.delete("content-type");
7901
- }
7902
- }
7903
- headers.set("User-Agent", "axios/" + VERSION, false);
7904
- const resolvedOptions = {
7905
- ...fetchOptions,
7906
- signal: composedSignal,
7907
- method: method.toUpperCase(),
7908
- headers: toByteStringHeaderObject(headers.normalize()),
7909
- body: data,
7910
- duplex: "half",
7911
- credentials: isCredentialsSupported ? withCredentials : void 0
7912
- };
7913
- request = isRequestSupported && new Request(url, resolvedOptions);
7914
- let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url, resolvedOptions));
7915
- const responseHeaders = AxiosHeaders_default.from(response.headers);
7916
- if (hasMaxContentLength) {
7917
- const declaredLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
7918
- if (declaredLength != null && declaredLength > maxContentLength) {
7919
- throw new AxiosError_default(
7920
- "maxContentLength size of " + maxContentLength + " exceeded",
7921
- AxiosError_default.ERR_BAD_RESPONSE,
7922
- config,
7923
- request
5332
+ handlePaymentCallback(
5333
+ url,
5334
+ externalCallback
7924
5335
  );
7925
- }
7926
- }
7927
- const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
7928
- if (supportsResponseStream && response.body && (onDownloadProgress || hasMaxContentLength || isStreamResponse && unsubscribe)) {
7929
- const options = {};
7930
- ["status", "statusText", "headers"].forEach((prop) => {
7931
- options[prop] = response[prop];
7932
5336
  });
7933
- const responseContentLength = utils_default.toFiniteNumber(responseHeaders.getContentLength());
7934
- const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
7935
- responseContentLength,
7936
- progressEventReducer(asyncDecorator(onDownloadProgress), true)
7937
- ) || [];
7938
- let bytesRead = 0;
7939
- const onChunkProgress = (loadedBytes) => {
7940
- if (hasMaxContentLength) {
7941
- bytesRead = loadedBytes;
7942
- if (bytesRead > maxContentLength) {
7943
- throw new AxiosError_default(
7944
- "maxContentLength size of " + maxContentLength + " exceeded",
7945
- AxiosError_default.ERR_BAD_RESPONSE,
7946
- config,
7947
- request
7948
- );
7949
- }
7950
- }
7951
- onProgress && onProgress(loadedBytes);
7952
- };
7953
- response = new Response(
7954
- trackStream(response.body, DEFAULT_CHUNK_SIZE, onChunkProgress, () => {
7955
- flush && flush();
7956
- unsubscribe && unsubscribe();
7957
- }),
7958
- options
7959
- );
7960
5337
  }
7961
- responseType = responseType || "text";
7962
- let responseData = await resolvers[utils_default.findKey(resolvers, responseType) || "text"](
7963
- response,
7964
- config
7965
- );
7966
- if (hasMaxContentLength && !supportsResponseStream && !isStreamResponse) {
7967
- let materializedSize;
7968
- if (responseData != null) {
7969
- if (typeof responseData.byteLength === "number") {
7970
- materializedSize = responseData.byteLength;
7971
- } else if (typeof responseData.size === "number") {
7972
- materializedSize = responseData.size;
7973
- } else if (typeof responseData === "string") {
7974
- materializedSize = typeof TextEncoder === "function" ? new TextEncoder().encode(responseData).byteLength : responseData.length;
7975
- }
7976
- }
7977
- if (typeof materializedSize === "number" && materializedSize > maxContentLength) {
7978
- throw new AxiosError_default(
7979
- "maxContentLength size of " + maxContentLength + " exceeded",
7980
- AxiosError_default.ERR_BAD_RESPONSE,
7981
- config,
7982
- request
7983
- );
7984
- }
5338
+ };
5339
+ createPayment = async (amountZAR, {
5340
+ appId = "tevrocsoft",
5341
+ serviceUrl = "https://tevrocsoftapi.netlify.app",
5342
+ payAccount = "default",
5343
+ externalCallback = () => {
7985
5344
  }
7986
- !isStreamResponse && unsubscribe && unsubscribe();
7987
- return await new Promise((resolve, reject) => {
7988
- settle(resolve, reject, {
7989
- data: responseData,
7990
- headers: AxiosHeaders_default.from(response.headers),
7991
- status: response.status,
7992
- statusText: response.statusText,
7993
- config,
7994
- request
5345
+ } = {}) => {
5346
+ await initializePayment(externalCallback);
5347
+ const cents = Math.round(Number(amountZAR) * 100);
5348
+ const basePaymentUrl = `${serviceUrl.replace(/\/$/, "")}/yoco-pay`;
5349
+ const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}&account=${payAccount}`;
5350
+ console.log(basePaymentUrl, paymentUrl);
5351
+ if (isCapacitor) {
5352
+ await Browser2.open({
5353
+ url: paymentUrl
7995
5354
  });
7996
- });
7997
- } catch (err) {
7998
- unsubscribe && unsubscribe();
7999
- if (composedSignal && composedSignal.aborted && composedSignal.reason instanceof AxiosError_default) {
8000
- const canceledError = composedSignal.reason;
8001
- canceledError.config = config;
8002
- request && (canceledError.request = request);
8003
- err !== canceledError && (canceledError.cause = err);
8004
- throw canceledError;
8005
- }
8006
- if (pendingBodyError) {
8007
- request && !pendingBodyError.request && (pendingBodyError.request = request);
8008
- throw pendingBodyError;
8009
- }
8010
- if (err instanceof AxiosError_default) {
8011
- request && !err.request && (err.request = request);
8012
- throw err;
8013
- }
8014
- if (err && err.name === "TypeError" && /Load failed|fetch/i.test(err.message)) {
8015
- throw Object.assign(
8016
- new AxiosError_default(
8017
- "Network Error",
8018
- AxiosError_default.ERR_NETWORK,
8019
- config,
8020
- request,
8021
- err && err.response
8022
- ),
8023
- {
8024
- cause: err.cause || err
8025
- }
8026
- );
5355
+ return;
8027
5356
  }
8028
- throw AxiosError_default.from(err, err && err.code, config, request, err && err.response);
8029
- }
8030
- };
8031
- };
8032
- var seedCache = /* @__PURE__ */ new Map();
8033
- var getFetch = (config) => {
8034
- let env = config && config.env || {};
8035
- const { fetch: fetch2, Request, Response } = env;
8036
- const seeds = [Request, Response, fetch2];
8037
- let len = seeds.length, i = len, seed, target, map = seedCache;
8038
- while (i--) {
8039
- seed = seeds[i];
8040
- target = map.get(seed);
8041
- target === void 0 && map.set(seed, target = i ? /* @__PURE__ */ new Map() : factory(env));
8042
- map = target;
8043
- }
8044
- return target;
8045
- };
8046
- var adapter = getFetch();
8047
-
8048
- // node_modules/axios/lib/adapters/adapters.js
8049
- var knownAdapters = {
8050
- http: null_default,
8051
- xhr: xhr_default,
8052
- fetch: {
8053
- get: getFetch
8054
- }
8055
- };
8056
- utils_default.forEach(knownAdapters, (fn, value) => {
8057
- if (fn) {
8058
- try {
8059
- Object.defineProperty(fn, "name", { __proto__: null, value });
8060
- } catch (e) {
8061
- }
8062
- Object.defineProperty(fn, "adapterName", { __proto__: null, value });
8063
- }
8064
- });
8065
- var renderReason = (reason) => `- ${reason}`;
8066
- var isResolvedHandle = (adapter2) => utils_default.isFunction(adapter2) || adapter2 === null || adapter2 === false;
8067
- function getAdapter(adapters, config) {
8068
- adapters = utils_default.isArray(adapters) ? adapters : [adapters];
8069
- const { length } = adapters;
8070
- let nameOrAdapter;
8071
- let adapter2;
8072
- const rejectedReasons = {};
8073
- for (let i = 0; i < length; i++) {
8074
- nameOrAdapter = adapters[i];
8075
- let id;
8076
- adapter2 = nameOrAdapter;
8077
- if (!isResolvedHandle(nameOrAdapter)) {
8078
- adapter2 = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
8079
- if (adapter2 === void 0) {
8080
- throw new AxiosError_default(`Unknown adapter '${id}'`);
5357
+ if (isTauri) {
5358
+ const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}&account=${payAccount}`;
5359
+ const win = new WebviewWindow("payment", {
5360
+ url,
5361
+ title: "Complete Payment",
5362
+ width: 550,
5363
+ height: 600,
5364
+ resizable: true,
5365
+ center: true
5366
+ });
5367
+ paymentWindowRef = win;
5368
+ win.once("tauri://created", () => {
5369
+ console.log("Payment window opened");
5370
+ });
5371
+ win.once("tauri://error", (e) => {
5372
+ console.error("Payment window error:", e);
5373
+ });
5374
+ return;
8081
5375
  }
8082
- }
8083
- if (adapter2 && (utils_default.isFunction(adapter2) || (adapter2 = adapter2.get(config)))) {
8084
- break;
8085
- }
8086
- rejectedReasons[id || "#" + i] = adapter2;
8087
- }
8088
- if (!adapter2) {
8089
- const reasons = Object.entries(rejectedReasons).map(
8090
- ([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
8091
- );
8092
- let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
8093
- throw new AxiosError_default(
8094
- `There is no suitable adapter to dispatch the request ` + s,
8095
- "ERR_NOT_SUPPORT"
8096
- );
8097
- }
8098
- return adapter2;
8099
- }
8100
- var adapters_default = {
8101
- /**
8102
- * Resolve an adapter from a list of adapter names or functions.
8103
- * @type {Function}
8104
- */
8105
- getAdapter,
8106
- /**
8107
- * Exposes all known adapters
8108
- * @type {Object<string, Function|Object>}
8109
- */
8110
- adapters: knownAdapters
8111
- };
8112
-
8113
- // node_modules/axios/lib/core/dispatchRequest.js
8114
- function throwIfCancellationRequested(config) {
8115
- if (config.cancelToken) {
8116
- config.cancelToken.throwIfRequested();
8117
- }
8118
- if (config.signal && config.signal.aborted) {
8119
- throw new CanceledError_default(null, config);
8120
- }
8121
- }
8122
- function dispatchRequest(config) {
8123
- throwIfCancellationRequested(config);
8124
- config.headers = AxiosHeaders_default.from(config.headers);
8125
- config.data = transformData.call(config, config.transformRequest);
8126
- if (["post", "put", "patch"].indexOf(config.method) !== -1) {
8127
- config.headers.setContentType("application/x-www-form-urlencoded", false);
8128
- }
8129
- const adapter2 = adapters_default.getAdapter(config.adapter || defaults_default.adapter, config);
8130
- return adapter2(config).then(
8131
- function onAdapterResolution(response) {
8132
- throwIfCancellationRequested(config);
8133
- config.response = response;
5376
+ const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
5377
+ const mode = isLocalhost ? "localhost" : "netlify";
5378
+ const finalUrl = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
8134
5379
  try {
8135
- response.data = transformData.call(config, config.transformResponse, response);
8136
- } finally {
8137
- delete config.response;
8138
- }
8139
- response.headers = AxiosHeaders_default.from(response.headers);
8140
- return response;
8141
- },
8142
- function onAdapterRejection(reason) {
8143
- if (!isCancel(reason)) {
8144
- throwIfCancellationRequested(config);
8145
- if (reason && reason.response) {
8146
- config.response = reason.response;
5380
+ const popup = window.open(finalUrl, "yocoPayment", "width=500,height=650");
5381
+ if (!popup) {
5382
+ window.location.href = finalUrl;
5383
+ return;
5384
+ }
5385
+ let listenerAttached = true;
5386
+ let timerRunning = true;
5387
+ const listener = (event) => {
8147
5388
  try {
8148
- reason.response.data = transformData.call(
8149
- config,
8150
- config.transformResponse,
8151
- reason.response
8152
- );
8153
- } finally {
8154
- delete config.response;
5389
+ const serviceOrigin = new URL(serviceUrl).origin;
5390
+ if (event.origin !== serviceOrigin) return;
5391
+ if (event.data?.type === "payment-result") {
5392
+ const status = event.data?.status || null;
5393
+ listenerAttached = false;
5394
+ timerRunning = false;
5395
+ window.removeEventListener("message", listener);
5396
+ try {
5397
+ popup.close();
5398
+ } catch (e) {
5399
+ }
5400
+ const url = status ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}status=${status}` : window.location.href;
5401
+ handlePaymentCallback(url, externalCallback);
5402
+ }
5403
+ } catch (err) {
5404
+ console.error("Payment listener error", err);
8155
5405
  }
8156
- reason.response.headers = AxiosHeaders_default.from(reason.response.headers);
8157
- }
8158
- }
8159
- return Promise.reject(reason);
8160
- }
8161
- );
8162
- }
8163
-
8164
- // node_modules/axios/lib/helpers/validator.js
8165
- var validators = {};
8166
- ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
8167
- validators[type] = function validator(thing) {
8168
- return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
8169
- };
8170
- });
8171
- var deprecatedWarnings = {};
8172
- validators.transitional = function transitional(validator, version, message) {
8173
- function formatMessage(opt, desc) {
8174
- return "[Axios v" + VERSION + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
8175
- }
8176
- return (value, opt, opts) => {
8177
- if (validator === false) {
8178
- throw new AxiosError_default(
8179
- formatMessage(opt, " has been removed" + (version ? " in " + version : "")),
8180
- AxiosError_default.ERR_DEPRECATED
8181
- );
8182
- }
8183
- if (version && !deprecatedWarnings[opt]) {
8184
- deprecatedWarnings[opt] = true;
8185
- console.warn(
8186
- formatMessage(
8187
- opt,
8188
- " has been deprecated since v" + version + " and will be removed in the near future"
8189
- )
8190
- );
8191
- }
8192
- return validator ? validator(value, opt, opts) : true;
8193
- };
8194
- };
8195
- validators.spelling = function spelling(correctSpelling) {
8196
- return (value, opt) => {
8197
- console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
8198
- return true;
8199
- };
8200
- };
8201
- function assertOptions(options, schema, allowUnknown) {
8202
- if (typeof options !== "object") {
8203
- throw new AxiosError_default("options must be an object", AxiosError_default.ERR_BAD_OPTION_VALUE);
8204
- }
8205
- const keys = Object.keys(options);
8206
- let i = keys.length;
8207
- while (i-- > 0) {
8208
- const opt = keys[i];
8209
- const validator = Object.prototype.hasOwnProperty.call(schema, opt) ? schema[opt] : void 0;
8210
- if (validator) {
8211
- const value = options[opt];
8212
- const result = value === void 0 || validator(value, opt, options);
8213
- if (result !== true) {
8214
- throw new AxiosError_default(
8215
- "option " + opt + " must be " + result,
8216
- AxiosError_default.ERR_BAD_OPTION_VALUE
8217
- );
8218
- }
8219
- continue;
8220
- }
8221
- if (allowUnknown !== true) {
8222
- throw new AxiosError_default("Unknown option " + opt, AxiosError_default.ERR_BAD_OPTION);
8223
- }
8224
- }
8225
- }
8226
- var validator_default = {
8227
- assertOptions,
8228
- validators
8229
- };
8230
-
8231
- // node_modules/axios/lib/core/Axios.js
8232
- var validators2 = validator_default.validators;
8233
- var Axios = class {
8234
- constructor(instanceConfig) {
8235
- this.defaults = instanceConfig || {};
8236
- this.interceptors = {
8237
- request: new InterceptorManager_default(),
8238
- response: new InterceptorManager_default()
8239
- };
8240
- }
8241
- /**
8242
- * Dispatch a request
8243
- *
8244
- * @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
8245
- * @param {?Object} config
8246
- *
8247
- * @returns {Promise} The Promise to be fulfilled
8248
- */
8249
- async request(configOrUrl, config) {
8250
- try {
8251
- return await this._request(configOrUrl, config);
8252
- } catch (err) {
8253
- if (err instanceof Error) {
8254
- let dummy = {};
8255
- Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
8256
- const stack = (() => {
8257
- if (!dummy.stack) {
8258
- return "";
5406
+ };
5407
+ window.addEventListener("message", listener);
5408
+ const timer = setInterval(() => {
5409
+ if (!timerRunning) {
5410
+ clearInterval(timer);
5411
+ return;
8259
5412
  }
8260
- const firstNewlineIndex = dummy.stack.indexOf("\n");
8261
- return firstNewlineIndex === -1 ? "" : dummy.stack.slice(firstNewlineIndex + 1);
8262
- })();
8263
- try {
8264
- if (!err.stack) {
8265
- err.stack = stack;
8266
- } else if (stack) {
8267
- const firstNewlineIndex = stack.indexOf("\n");
8268
- const secondNewlineIndex = firstNewlineIndex === -1 ? -1 : stack.indexOf("\n", firstNewlineIndex + 1);
8269
- const stackWithoutTwoTopLines = secondNewlineIndex === -1 ? "" : stack.slice(secondNewlineIndex + 1);
8270
- if (!String(err.stack).endsWith(stackWithoutTwoTopLines)) {
8271
- err.stack += "\n" + stack;
5413
+ if (popup.closed) {
5414
+ clearInterval(timer);
5415
+ timerRunning = false;
5416
+ if (listenerAttached) {
5417
+ listenerAttached = false;
5418
+ window.removeEventListener("message", listener);
8272
5419
  }
8273
5420
  }
8274
- } catch (e) {
8275
- }
8276
- }
8277
- throw err;
8278
- }
8279
- }
8280
- _request(configOrUrl, config) {
8281
- if (typeof configOrUrl === "string") {
8282
- config = config || {};
8283
- config.url = configOrUrl;
8284
- } else {
8285
- config = configOrUrl || {};
8286
- }
8287
- config = mergeConfig(this.defaults, config);
8288
- const { transitional: transitional2, paramsSerializer, headers } = config;
8289
- if (transitional2 !== void 0) {
8290
- validator_default.assertOptions(
8291
- transitional2,
8292
- {
8293
- silentJSONParsing: validators2.transitional(validators2.boolean),
8294
- forcedJSONParsing: validators2.transitional(validators2.boolean),
8295
- clarifyTimeoutError: validators2.transitional(validators2.boolean),
8296
- legacyInterceptorReqResOrdering: validators2.transitional(validators2.boolean),
8297
- advertiseZstdAcceptEncoding: validators2.transitional(validators2.boolean),
8298
- validateStatusUndefinedResolves: validators2.transitional(validators2.boolean)
8299
- },
8300
- false
8301
- );
8302
- }
8303
- if (paramsSerializer != null) {
8304
- if (utils_default.isFunction(paramsSerializer)) {
8305
- config.paramsSerializer = {
8306
- serialize: paramsSerializer
8307
- };
8308
- } else {
8309
- validator_default.assertOptions(
8310
- paramsSerializer,
8311
- {
8312
- encode: validators2.function,
8313
- serialize: validators2.function
8314
- },
8315
- true
8316
- );
8317
- }
8318
- }
8319
- if (config.allowAbsoluteUrls !== void 0) {
8320
- } else if (this.defaults.allowAbsoluteUrls !== void 0) {
8321
- config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
8322
- } else {
8323
- config.allowAbsoluteUrls = true;
8324
- }
8325
- validator_default.assertOptions(
8326
- config,
8327
- {
8328
- baseUrl: validators2.spelling("baseURL"),
8329
- withXsrfToken: validators2.spelling("withXSRFToken")
8330
- },
8331
- true
8332
- );
8333
- config.method = (config.method || this.defaults.method || "get").toLowerCase();
8334
- let contextHeaders = headers && utils_default.merge(headers.common, headers[config.method]);
8335
- headers && utils_default.forEach(["delete", "get", "head", "post", "put", "patch", "query", "common"], (method) => {
8336
- delete headers[method];
8337
- });
8338
- config.headers = AxiosHeaders_default.concat(contextHeaders, headers);
8339
- const requestInterceptorChain = [];
8340
- let synchronousRequestInterceptors = true;
8341
- this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
8342
- if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
5421
+ }, 500);
8343
5422
  return;
8344
- }
8345
- synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
8346
- const transitional3 = config.transitional || transitional_default;
8347
- const legacyInterceptorReqResOrdering = transitional3 && transitional3.legacyInterceptorReqResOrdering;
8348
- if (legacyInterceptorReqResOrdering) {
8349
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
8350
- } else {
8351
- requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
8352
- }
8353
- });
8354
- const responseInterceptorChain = [];
8355
- this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
8356
- responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
8357
- });
8358
- let promise;
8359
- let i = 0;
8360
- let len;
8361
- if (!synchronousRequestInterceptors) {
8362
- const chain = [dispatchRequest.bind(this), void 0];
8363
- chain.unshift(...requestInterceptorChain);
8364
- chain.push(...responseInterceptorChain);
8365
- len = chain.length;
8366
- promise = Promise.resolve(config);
8367
- while (i < len) {
8368
- promise = promise.then(chain[i++], chain[i++]);
8369
- }
8370
- return promise;
8371
- }
8372
- len = requestInterceptorChain.length;
8373
- let newConfig = config;
8374
- while (i < len) {
8375
- const onFulfilled = requestInterceptorChain[i++];
8376
- const onRejected = requestInterceptorChain[i++];
8377
- try {
8378
- newConfig = onFulfilled(newConfig);
8379
- } catch (error) {
8380
- onRejected.call(this, error);
8381
- break;
8382
- }
8383
- }
8384
- try {
8385
- promise = dispatchRequest.call(this, newConfig);
8386
- } catch (error) {
8387
- return Promise.reject(error);
8388
- }
8389
- i = 0;
8390
- len = responseInterceptorChain.length;
8391
- while (i < len) {
8392
- promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
8393
- }
8394
- return promise;
8395
- }
8396
- getUri(config) {
8397
- config = mergeConfig(this.defaults, config);
8398
- const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls, config);
8399
- return buildURL(fullPath, config.params, config.paramsSerializer);
8400
- }
8401
- };
8402
- utils_default.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
8403
- Axios.prototype[method] = function(url, config) {
8404
- return this.request(
8405
- mergeConfig(config || {}, {
8406
- method,
8407
- url,
8408
- data: config && utils_default.hasOwnProp(config, "data") ? config.data : void 0
8409
- })
8410
- );
8411
- };
8412
- });
8413
- utils_default.forEach(["post", "put", "patch", "query"], function forEachMethodWithData(method) {
8414
- function generateHTTPMethod(isForm) {
8415
- return function httpMethod(url, data, config) {
8416
- return this.request(
8417
- mergeConfig(config || {}, {
8418
- method,
8419
- headers: isForm ? {
8420
- "Content-Type": "multipart/form-data"
8421
- } : {},
8422
- url,
8423
- data
8424
- })
8425
- );
8426
- };
8427
- }
8428
- Axios.prototype[method] = generateHTTPMethod();
8429
- if (method !== "query") {
8430
- Axios.prototype[method + "Form"] = generateHTTPMethod(true);
8431
- }
8432
- });
8433
- var Axios_default = Axios;
8434
-
8435
- // node_modules/axios/lib/cancel/CancelToken.js
8436
- var CancelToken = class _CancelToken {
8437
- constructor(executor) {
8438
- if (typeof executor !== "function") {
8439
- throw new TypeError("executor must be a function.");
8440
- }
8441
- let resolvePromise;
8442
- this.promise = new Promise(function promiseExecutor(resolve) {
8443
- resolvePromise = resolve;
8444
- });
8445
- const token = this;
8446
- this.promise.then((cancel) => {
8447
- if (!token._listeners) return;
8448
- let i = token._listeners.length;
8449
- while (i-- > 0) {
8450
- token._listeners[i](cancel);
8451
- }
8452
- token._listeners = null;
8453
- });
8454
- this.promise.then = (onfulfilled) => {
8455
- let _resolve;
8456
- const promise = new Promise((resolve) => {
8457
- token.subscribe(resolve);
8458
- _resolve = resolve;
8459
- }).then(onfulfilled);
8460
- promise.cancel = function reject() {
8461
- token.unsubscribe(_resolve);
8462
- };
8463
- return promise;
8464
- };
8465
- executor(function cancel(message, config, request) {
8466
- if (token.reason) {
5423
+ } catch (e) {
5424
+ window.location.href = finalUrl;
8467
5425
  return;
8468
5426
  }
8469
- token.reason = new CanceledError_default(message, config, request);
8470
- resolvePromise(token.reason);
8471
- });
8472
- }
8473
- /**
8474
- * Throws a `CanceledError` if cancellation has been requested.
8475
- */
8476
- throwIfRequested() {
8477
- if (this.reason) {
8478
- throw this.reason;
8479
- }
8480
- }
8481
- /**
8482
- * Subscribe to the cancel signal
8483
- */
8484
- subscribe(listener) {
8485
- if (this.reason) {
8486
- listener(this.reason);
8487
- return;
8488
- }
8489
- if (this._listeners) {
8490
- this._listeners.push(listener);
8491
- } else {
8492
- this._listeners = [listener];
8493
- }
8494
- }
8495
- /**
8496
- * Unsubscribe from the cancel signal
8497
- */
8498
- unsubscribe(listener) {
8499
- if (!this._listeners) {
8500
- return;
8501
- }
8502
- const index = this._listeners.indexOf(listener);
8503
- if (index !== -1) {
8504
- this._listeners.splice(index, 1);
8505
- }
8506
- }
8507
- toAbortSignal() {
8508
- const controller = new AbortController();
8509
- const abort = (err) => {
8510
- controller.abort(err);
8511
- };
8512
- this.subscribe(abort);
8513
- controller.signal.unsubscribe = () => this.unsubscribe(abort);
8514
- return controller.signal;
8515
- }
8516
- /**
8517
- * Returns an object that contains a new `CancelToken` and a function that, when called,
8518
- * cancels the `CancelToken`.
8519
- */
8520
- static source() {
8521
- let cancel;
8522
- const token = new _CancelToken(function executor(c) {
8523
- cancel = c;
8524
- });
8525
- return {
8526
- token,
8527
- cancel
8528
5427
  };
8529
5428
  }
8530
- };
8531
- var CancelToken_default = CancelToken;
8532
-
8533
- // node_modules/axios/lib/helpers/spread.js
8534
- function spread(callback) {
8535
- return function wrap(arr) {
8536
- return callback.apply(null, arr);
8537
- };
8538
- }
8539
-
8540
- // node_modules/axios/lib/helpers/isAxiosError.js
8541
- function isAxiosError(payload) {
8542
- return utils_default.isObject(payload) && payload.isAxiosError === true;
8543
- }
8544
-
8545
- // node_modules/axios/lib/helpers/HttpStatusCode.js
8546
- var HttpStatusCode = {
8547
- Continue: 100,
8548
- SwitchingProtocols: 101,
8549
- Processing: 102,
8550
- EarlyHints: 103,
8551
- Ok: 200,
8552
- Created: 201,
8553
- Accepted: 202,
8554
- NonAuthoritativeInformation: 203,
8555
- NoContent: 204,
8556
- ResetContent: 205,
8557
- PartialContent: 206,
8558
- MultiStatus: 207,
8559
- AlreadyReported: 208,
8560
- ImUsed: 226,
8561
- MultipleChoices: 300,
8562
- MovedPermanently: 301,
8563
- Found: 302,
8564
- SeeOther: 303,
8565
- NotModified: 304,
8566
- UseProxy: 305,
8567
- Unused: 306,
8568
- TemporaryRedirect: 307,
8569
- PermanentRedirect: 308,
8570
- BadRequest: 400,
8571
- Unauthorized: 401,
8572
- PaymentRequired: 402,
8573
- Forbidden: 403,
8574
- NotFound: 404,
8575
- MethodNotAllowed: 405,
8576
- NotAcceptable: 406,
8577
- ProxyAuthenticationRequired: 407,
8578
- RequestTimeout: 408,
8579
- Conflict: 409,
8580
- Gone: 410,
8581
- LengthRequired: 411,
8582
- PreconditionFailed: 412,
8583
- PayloadTooLarge: 413,
8584
- UriTooLong: 414,
8585
- UnsupportedMediaType: 415,
8586
- RangeNotSatisfiable: 416,
8587
- ExpectationFailed: 417,
8588
- ImATeapot: 418,
8589
- MisdirectedRequest: 421,
8590
- UnprocessableEntity: 422,
8591
- Locked: 423,
8592
- FailedDependency: 424,
8593
- TooEarly: 425,
8594
- UpgradeRequired: 426,
8595
- PreconditionRequired: 428,
8596
- TooManyRequests: 429,
8597
- RequestHeaderFieldsTooLarge: 431,
8598
- UnavailableForLegalReasons: 451,
8599
- InternalServerError: 500,
8600
- NotImplemented: 501,
8601
- BadGateway: 502,
8602
- ServiceUnavailable: 503,
8603
- GatewayTimeout: 504,
8604
- HttpVersionNotSupported: 505,
8605
- VariantAlsoNegotiates: 506,
8606
- InsufficientStorage: 507,
8607
- LoopDetected: 508,
8608
- NotExtended: 510,
8609
- NetworkAuthenticationRequired: 511,
8610
- WebServerIsDown: 521,
8611
- ConnectionTimedOut: 522,
8612
- OriginIsUnreachable: 523,
8613
- TimeoutOccurred: 524,
8614
- SslHandshakeFailed: 525,
8615
- InvalidSslCertificate: 526
8616
- };
8617
- Object.entries(HttpStatusCode).forEach(([key, value]) => {
8618
- HttpStatusCode[value] = key;
8619
5429
  });
8620
- var HttpStatusCode_default = HttpStatusCode;
8621
-
8622
- // node_modules/axios/lib/axios.js
8623
- function createInstance(defaultConfig) {
8624
- const context = new Axios_default(defaultConfig);
8625
- const instance = bind(Axios_default.prototype.request, context);
8626
- utils_default.extend(instance, Axios_default.prototype, context, { allOwnKeys: true });
8627
- utils_default.extend(instance, context, null, { allOwnKeys: true });
8628
- instance.create = function create2(instanceConfig) {
8629
- return createInstance(mergeConfig(defaultConfig, instanceConfig));
8630
- };
8631
- return instance;
8632
- }
8633
- var axios = createInstance(defaults_default);
8634
- axios.Axios = Axios_default;
8635
- axios.CanceledError = CanceledError_default;
8636
- axios.CancelToken = CancelToken_default;
8637
- axios.isCancel = isCancel;
8638
- axios.VERSION = VERSION;
8639
- axios.toFormData = toFormData_default;
8640
- axios.AxiosError = AxiosError_default;
8641
- axios.Cancel = axios.CanceledError;
8642
- axios.all = function all(promises) {
8643
- return Promise.all(promises);
8644
- };
8645
- axios.spread = spread;
8646
- axios.isAxiosError = isAxiosError;
8647
- axios.mergeConfig = mergeConfig;
8648
- axios.AxiosHeaders = AxiosHeaders_default;
8649
- axios.formToJSON = (thing) => formDataToJSON_default(utils_default.isHTMLForm(thing) ? new FormData(thing) : thing);
8650
- axios.getAdapter = adapters_default.getAdapter;
8651
- axios.HttpStatusCode = HttpStatusCode_default;
8652
- axios.default = axios;
8653
- var axios_default = axios;
8654
5430
 
8655
- // node_modules/axios/index.js
8656
- var {
8657
- Axios: Axios2,
8658
- AxiosError: AxiosError2,
8659
- CanceledError: CanceledError2,
8660
- isCancel: isCancel2,
8661
- CancelToken: CancelToken2,
8662
- VERSION: VERSION2,
8663
- all: all2,
8664
- Cancel,
8665
- isAxiosError: isAxiosError2,
8666
- spread: spread2,
8667
- toFormData: toFormData2,
8668
- AxiosHeaders: AxiosHeaders2,
8669
- HttpStatusCode: HttpStatusCode2,
8670
- formToJSON,
8671
- getAdapter: getAdapter2,
8672
- mergeConfig: mergeConfig2,
8673
- create
8674
- } = axios_default;
5431
+ // src/index.js
5432
+ var index_exports = {};
5433
+ __export(index_exports, {
5434
+ TevrocClient: () => TevrocClient,
5435
+ TevrocError: () => TevrocError,
5436
+ createClient: () => createClient
5437
+ });
8675
5438
 
8676
5439
  // src/services/useEntities.js
8677
5440
  init_usePlatform();
@@ -8763,13 +5526,13 @@ var Tevroc = (() => {
8763
5526
  }
8764
5527
  return {};
8765
5528
  }
8766
- function resolvePath(obj, path, create2 = false) {
5529
+ function resolvePath(obj, path, create = false) {
8767
5530
  const parts = String(path || "").split("/").filter(Boolean);
8768
5531
  let ref = obj;
8769
5532
  for (let i = 0; i < parts.length - 1; i += 1) {
8770
5533
  const part = parts[i];
8771
5534
  if (!(part in ref)) {
8772
- if (!create2) return null;
5535
+ if (!create) return null;
8773
5536
  ref[part] = {};
8774
5537
  }
8775
5538
  ref = ref[part];
@@ -8930,8 +5693,8 @@ var Tevroc = (() => {
8930
5693
  function getFilters(input = {}) {
8931
5694
  return input.filter || input.filters || input.where || {};
8932
5695
  }
8933
- function matchesFilter(record, filter2 = {}) {
8934
- return Object.entries(filter2).every(([key, expected]) => {
5696
+ function matchesFilter(record, filter = {}) {
5697
+ return Object.entries(filter).every(([key, expected]) => {
8935
5698
  const actual = record?.[key];
8936
5699
  if (expected && typeof expected === "object" && !Array.isArray(expected)) {
8937
5700
  if ("$eq" in expected && actual !== expected.$eq) return false;
@@ -8979,9 +5742,9 @@ var Tevroc = (() => {
8979
5742
  const sorted = sortRecords(rows, input.sort || options.sort);
8980
5743
  return { data: sorted.slice(0, input.limit || 200), limit: input.limit };
8981
5744
  },
8982
- filter: async (filter2 = {}, sortOrOptions, limit) => {
5745
+ filter: async (filter = {}, sortOrOptions, limit) => {
8983
5746
  const options = normalizeListArgs(sortOrOptions, limit);
8984
- return createEntityApi(store, entity).query({ ...options, filter: filter2 });
5747
+ return createEntityApi(store, entity).query({ ...options, filter });
8985
5748
  },
8986
5749
  bulkCreate: async (records = []) => ({ inserted: (await Promise.all(records.map((record) => createEntityApi(store, entity).create(record)))).length }),
8987
5750
  bulkUpdate: async (records = []) => {
@@ -9048,8 +5811,8 @@ var Tevroc = (() => {
9048
5811
  return { fileId, fileName: filename, webViewLink: `filebase://${path}`, downloadLink: `filebase://${path}` };
9049
5812
  },
9050
5813
  readJsonFromDrive: async (fileId, userId = "local") => {
9051
- const own2 = (await store.get(`drive/${userId}/${fileId}`)).val();
9052
- if (own2?.data) return own2.data;
5814
+ const own = (await store.get(`drive/${userId}/${fileId}`)).val();
5815
+ if (own?.data) return own.data;
9053
5816
  const contexts = await resolveFileContext(store, userId);
9054
5817
  const context = contexts.find((item) => item.fileId === fileId);
9055
5818
  if (!context) return {};
@@ -9205,6 +5968,8 @@ var Tevroc = (() => {
9205
5968
  }
9206
5969
 
9207
5970
  // src/index.js
5971
+ init_useGoogleAuth();
5972
+ init_useYocoPayment();
9208
5973
  var DEFAULT_TIMEOUT_MS = 3e4;
9209
5974
  var platformModule = null;
9210
5975
  async function getPlatformModule() {
@@ -9220,13 +5985,6 @@ var Tevroc = (() => {
9220
5985
  }
9221
5986
  return googleModule;
9222
5987
  }
9223
- var paymentModule = null;
9224
- async function getPaymentModule() {
9225
- if (!paymentModule) {
9226
- paymentModule = await Promise.resolve().then(() => (init_useYocoPayment(), useYocoPayment_exports));
9227
- }
9228
- return paymentModule;
9229
- }
9230
5988
  var TevrocError = class extends Error {
9231
5989
  constructor(message, options = {}) {
9232
5990
  super(message);
@@ -9249,10 +6007,11 @@ var Tevroc = (() => {
9249
6007
  this.serviceUrl = normalizeBaseUrl(serviceUrl);
9250
6008
  this.appId = options.appId;
9251
6009
  this.appName = options.appName;
6010
+ this.payAccount = options.payAccount ?? "default";
9252
6011
  this.isNative = options.isNative ?? false;
9253
- this.transport = options.axios ?? axios_default;
9254
- if (!this.transport || typeof this.transport.request !== "function") {
9255
- throw new TypeError("An axios instance is required");
6012
+ this.fetch = (options.fetch ?? globalThis.fetch).bind(globalThis);
6013
+ if (typeof this.fetch !== "function") {
6014
+ throw new TypeError("No fetch implementation available");
9256
6015
  }
9257
6016
  this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
9258
6017
  this.defaultHeaders = normalizeHeaders(options.headers);
@@ -9298,6 +6057,7 @@ var Tevroc = (() => {
9298
6057
  const controller = new AbortController();
9299
6058
  const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.timeoutMs);
9300
6059
  const token = this.token || getStoredToken();
6060
+ console.log(token, options);
9301
6061
  if (token && options.auth !== false) {
9302
6062
  headers.set("authorization", `Bearer ${token}`);
9303
6063
  }
@@ -9314,17 +6074,17 @@ var Tevroc = (() => {
9314
6074
  if (value !== void 0 && value !== null) headers.set(key, String(value));
9315
6075
  }
9316
6076
  }
6077
+ console.error(headers, url);
9317
6078
  try {
9318
- const response = await this.transport.request({
9319
- url,
6079
+ const response = await this.fetch(url, {
9320
6080
  method,
9321
- headers: Object.fromEntries(headers.entries()),
9322
- data: body,
9323
- signal: options.signal ?? controller.signal,
9324
- timeout: options.timeoutMs ?? this.timeoutMs,
9325
- validateStatus: () => true
6081
+ headers,
6082
+ body,
6083
+ signal: options.signal ?? controller.signal
9326
6084
  });
9327
- return await parseAxiosResponse(response, options.parseAs);
6085
+ let ret = await parseResponse(response, options.parseAs);
6086
+ console.log("Response from request:", ret);
6087
+ return ret;
9328
6088
  } catch (error) {
9329
6089
  if (error?.name === "AbortError") throw new TevrocError("Request timed out", { code: "timeout" });
9330
6090
  if (error instanceof TevrocError) throw error;
@@ -9347,14 +6107,18 @@ var Tevroc = (() => {
9347
6107
  }
9348
6108
  function createPaymentApi(client) {
9349
6109
  return {
9350
- create: async ({ amountZAR, appId = "tevrocsoft", mode = "web" }) => {
9351
- const { createPayment: createPayment2 } = await getPaymentModule();
9352
- return await createPayment2(amountZAR, {
6110
+ create: async ({ amountZAR, appId = "tevrocsoft", mode = "web", account = "default", externalCallback = void 0 } = {}) => {
6111
+ return await createPayment(amountZAR, {
9353
6112
  appId,
9354
6113
  serviceUrl: client.serviceUrl,
9355
- mode
6114
+ mode,
6115
+ payAccount: account,
6116
+ externalCallback
9356
6117
  });
9357
6118
  },
6119
+ createCheckout: async (payload = {}) => {
6120
+ return await client.request("/create-checkout", { method: "POST", body: payload, auth: false });
6121
+ },
9358
6122
  onstatus: (callback) => {
9359
6123
  if (typeof callback !== "function") {
9360
6124
  throw new Error("onstatus requires a function");
@@ -9366,37 +6130,38 @@ var Tevroc = (() => {
9366
6130
  function createAuthApi(client) {
9367
6131
  return {
9368
6132
  async register(input) {
9369
- const result = await client.request("/auth/register", { method: "POST", body: input, auth: false });
6133
+ const body = buildAuthPayload(input, client);
6134
+ const result = await client.request("/auth/register", { method: "POST", body, auth: false });
9370
6135
  if (result.token) client.setToken(result.token);
9371
6136
  return result;
9372
6137
  },
9373
6138
  // base44
9374
- loginWithProvider: async (provider, redirectTo, setToken = () => {
6139
+ loginWithProvider: async (provider, redirectTo, setToken = async () => {
9375
6140
  }) => {
9376
6141
  if (provider === "google") {
9377
- const { createGoogleLogin: createGoogleLogin3, subscribeGoogleLogin: subscribeGoogleLogin3 } = await getGoogleModule();
6142
+ const { createGoogleLogin: createGoogleLogin2, subscribeGoogleLogin: subscribeGoogleLogin2 } = await getGoogleModule();
9378
6143
  console.log({
9379
6144
  serviceUrl: client.serviceUrl,
9380
6145
  appId: client.appId,
9381
6146
  appName: client.appName
9382
6147
  });
9383
- createGoogleLogin3({
6148
+ createGoogleLogin2({
9384
6149
  serviceUrl: client.serviceUrl,
9385
6150
  appId: client.appId,
9386
6151
  appName: client.appName
9387
6152
  });
9388
6153
  if (redirectTo) {
9389
- const unsub = subscribeGoogleLogin3(async (user, err) => {
6154
+ const unsub = subscribeGoogleLogin2(async (user, err) => {
9390
6155
  console.log("Google callback:", user, err);
9391
6156
  unsub();
9392
6157
  if (!user) return;
9393
- let result = await client.request("/auth/google", {
6158
+ const result = await client.request("/auth/google", {
9394
6159
  method: "POST",
9395
- body: { accessToken: user.accessToken },
6160
+ body: buildAuthPayload({ accessToken: user.accessToken }, client),
9396
6161
  auth: false
9397
6162
  });
9398
6163
  console.log(result);
9399
- setToken(result.token);
6164
+ await setToken(result.token, result.user);
9400
6165
  console.log("Redirecting to:", redirectTo);
9401
6166
  window.location.href = redirectTo;
9402
6167
  });
@@ -9410,27 +6175,38 @@ var Tevroc = (() => {
9410
6175
  },
9411
6176
  //
9412
6177
  async login(input) {
9413
- const result = await client.request("/auth/login", { method: "POST", body: input, auth: false });
6178
+ const body = buildAuthPayload(input, client);
6179
+ const result = await client.request("/auth/login", { method: "POST", body, auth: false });
9414
6180
  if (result.token) client.setToken(result.token);
9415
6181
  return result;
9416
6182
  },
9417
- loginViaEmailPassword: (email, password) => client.auth.login({ email, password }),
9418
- loginWithGoogle: (input) => client.request("/auth/google", { method: "POST", body: input, auth: false }).then((result) => {
9419
- if (result.token) client.setToken(result.token);
9420
- return result;
9421
- }),
9422
6183
  async logout() {
9423
- const result = await client.request("/auth/logout", { method: "POST" });
6184
+ const result = await client.request("/auth/logout", { method: "POST", body: buildAuthPayload({}, client) });
9424
6185
  client.clearToken();
9425
6186
  return result;
9426
6187
  },
9427
- me: () => client.request("/auth/me"),
9428
- verifyOtp: (input) => client.request("/auth/verify-otp", { method: "POST", body: input, auth: false }),
9429
- changePassword: (input) => client.request("/auth/change-password", { method: "POST", body: input }),
9430
- resetPassword: (input) => client.request("/auth/reset-password", { method: "POST", body: input, auth: false }),
9431
- loginUrl: (redirectTo) => client.request("/auth/login-url", { query: redirectTo ? { redirectTo } : void 0, auth: false })
6188
+ inviteUser: (input) => client.request("/users/invite", { method: "POST", body: buildAuthPayload(input, client) }),
6189
+ acceptInvite: (input) => client.request("/auth/accept-invite", { method: "POST", body: buildAuthPayload(input, client), auth: false }),
6190
+ me: () => client.request("/auth/me", { headers: buildAuthHeaders(client) }),
6191
+ verifyOtp: (input) => client.request("/auth/verify-otp", { method: "POST", body: buildAuthPayload(input, client), auth: false }),
6192
+ changePassword: (input) => client.request("/auth/change-password", { method: "POST", body: buildAuthPayload(input, client) }),
6193
+ resetPassword: (input) => client.request("/auth/reset-password", { method: "POST", body: buildAuthPayload(input, client), auth: false }),
6194
+ loginUrl: (redirectTo) => client.request("/auth/login-url", {
6195
+ query: redirectTo ? { redirectTo, appId: client.appId || void 0 } : { appId: client.appId || void 0 },
6196
+ auth: false
6197
+ })
9432
6198
  };
9433
6199
  }
6200
+ function buildAuthPayload(input = {}, client) {
6201
+ const payload = { ...input || {} };
6202
+ if (client?.appId && payload.appId == null) {
6203
+ payload.appId = client.appId;
6204
+ }
6205
+ return payload;
6206
+ }
6207
+ function buildAuthHeaders(client) {
6208
+ return client?.appId ? { "x-app-id": client.appId } : {};
6209
+ }
9434
6210
  function createEntityRegistry(client) {
9435
6211
  return new Proxy(
9436
6212
  {},
@@ -9451,7 +6227,7 @@ var Tevroc = (() => {
9451
6227
  update: (id, patch) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "PATCH", body: patch }),
9452
6228
  delete: (id) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "DELETE" }),
9453
6229
  query: (input = {}) => client.request(`${base}/query`, { method: "POST", body: input }),
9454
- filter: (filter2 = {}, sortOrOptions, limit) => client.request(`${base}/query`, { method: "POST", body: normalizeFilterInput(filter2, sortOrOptions, limit) }),
6230
+ filter: (filter = {}, sortOrOptions, limit) => client.request(`${base}/query`, { method: "POST", body: normalizeFilterInput(filter, sortOrOptions, limit) }),
9455
6231
  bulkCreate: (records) => client.request(`${base}/bulk`, { method: "POST", body: { records } }),
9456
6232
  bulkUpdate: (records) => client.request(`${base}/bulk`, { method: "PATCH", body: { records } }),
9457
6233
  bulkDelete: (ids) => client.request(`${base}/bulk`, { method: "DELETE", body: { ids } }),
@@ -9574,15 +6350,14 @@ var Tevroc = (() => {
9574
6350
  if (options.contentType) headers["content-type"] = options.contentType;
9575
6351
  return client.request(path, { method: "POST", body: file, headers });
9576
6352
  }
9577
- async function parseAxiosResponse(response, parseAs) {
6353
+ async function parseResponse(response, parseAs) {
9578
6354
  if (parseAs === "response") return response;
9579
- const headers = response.headers ?? {};
9580
- const contentType = typeof headers.get === "function" ? headers.get("content-type") ?? "" : String(headers["content-type"] ?? headers["Content-Type"] ?? "");
6355
+ const contentType = response.headers.get("content-type") ?? "";
9581
6356
  const isJson = contentType.includes("application/json");
9582
- const data = response.data;
9583
- if (response.status < 200 || response.status >= 300) {
6357
+ const data = isJson ? await response.json() : await response.text();
6358
+ if (!response.ok) {
9584
6359
  const error = isJson && data?.error ? data.error : {};
9585
- throw new TevrocError(error.message ?? response.statusText ?? "Request failed", {
6360
+ throw new TevrocError(error.message ?? response.statusText, {
9586
6361
  status: response.status,
9587
6362
  code: error.code ?? "api_error",
9588
6363
  details: error.details ?? data,
@@ -9616,18 +6391,18 @@ var Tevroc = (() => {
9616
6391
  function getStoredToken() {
9617
6392
  return safeLocalStorage()?.getItem("tevroc_access_token") ?? null;
9618
6393
  }
9619
- function normalizeFilterInput(filter2 = {}, sortOrOptions, limit) {
9620
- const input = { filter: filter2 };
6394
+ function normalizeFilterInput(filter = {}, sortOrOptions, limit) {
6395
+ const input = { filter };
9621
6396
  if (typeof sortOrOptions === "string") input.sort = sortOrOptions;
9622
6397
  else if (sortOrOptions && typeof sortOrOptions === "object") Object.assign(input, sortOrOptions);
9623
6398
  if (limit !== void 0) input.limit = limit;
9624
6399
  return input;
9625
6400
  }
9626
6401
  function isJsonBody(body) {
9627
- const isArrayBuffer2 = typeof ArrayBuffer !== "undefined" && body instanceof ArrayBuffer;
9628
- const isBlob2 = typeof Blob !== "undefined" && body instanceof Blob;
9629
- const isFormData2 = typeof FormData !== "undefined" && body instanceof FormData;
9630
- return typeof body === "object" && !isArrayBuffer2 && !isBlob2 && !isFormData2;
6402
+ const isArrayBuffer = typeof ArrayBuffer !== "undefined" && body instanceof ArrayBuffer;
6403
+ const isBlob = typeof Blob !== "undefined" && body instanceof Blob;
6404
+ const isFormData = typeof FormData !== "undefined" && body instanceof FormData;
6405
+ return typeof body === "object" && !isArrayBuffer && !isBlob && !isFormData;
9631
6406
  }
9632
6407
  return __toCommonJS(index_exports);
9633
6408
  })();