@ztimson/momentum 0.45.1 → 0.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,29 +1,29 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- var it = Object.defineProperty;
5
- var ct = (r, t, e) => t in r ? it(r, t, { enumerable: true, configurable: true, writable: true, value: e }) : r[t] = e;
6
- var c = (r, t, e) => ct(r, typeof t != "symbol" ? t + "" : t, e);
7
- function ut(r, t = false) {
8
- if (r == null) throw new Error("Cannot clean a NULL value");
9
- return Array.isArray(r) ? r = r.filter((e) => e != null) : Object.entries(r).forEach(([e, n]) => {
10
- (t && n === void 0 || !t && n == null) && delete r[e];
11
- }), r;
4
+ var ut = Object.defineProperty;
5
+ var at = (n, t, e) => t in n ? ut(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
6
+ var c = (n, t, e) => at(n, typeof t != "symbol" ? t + "" : t, e);
7
+ function lt(n, t = false) {
8
+ if (n == null) throw new Error("Cannot clean a NULL value");
9
+ return Array.isArray(n) ? n = n.filter((e) => e != null) : Object.entries(n).forEach(([e, r]) => {
10
+ (t && r === void 0 || !t && r == null) && delete n[e];
11
+ }), n;
12
12
  }
13
- function A(r, t) {
14
- const e = typeof r, n = typeof t;
15
- return e != "object" || r == null || n != "object" || t == null ? e == "function" && n == "function" ? r.toString() == t.toString() : r === t : Object.keys(r).length != Object.keys(t).length ? false : Object.keys(r).every((o) => A(r[o], t[o]));
13
+ function $(n, t) {
14
+ const e = typeof n, r = typeof t;
15
+ return e != "object" || n == null || r != "object" || t == null ? e == "function" && r == "function" ? n.toString() == t.toString() : n === t : Object.keys(n).length != Object.keys(t).length ? false : Object.keys(n).every((i) => $(n[i], t[i]));
16
16
  }
17
- function M(r) {
17
+ function k(n) {
18
18
  try {
19
- return JSON.parse(r);
19
+ return JSON.parse(n);
20
20
  } catch {
21
- return r;
21
+ return n;
22
22
  }
23
23
  }
24
- function Lt(r, t) {
24
+ function It(n, t) {
25
25
  let e = [];
26
- return JSON.stringify(r, (n, s) => {
26
+ return JSON.stringify(n, (r, s) => {
27
27
  if (typeof s == "object" && s !== null) {
28
28
  if (e.includes(s)) return;
29
29
  e.push(s);
@@ -31,10 +31,10 @@ function Lt(r, t) {
31
31
  return s;
32
32
  }, t);
33
33
  }
34
- function ft(r) {
35
- return Array.isArray(r) ? r : [r];
34
+ function b(n) {
35
+ return Array.isArray(n) ? n : [n];
36
36
  }
37
- class B extends Array {
37
+ class E extends Array {
38
38
  /** Number of elements in set */
39
39
  get size() {
40
40
  return this.length;
@@ -59,8 +59,8 @@ class B extends Array {
59
59
  */
60
60
  delete(...t) {
61
61
  t.forEach((e) => {
62
- const n = this.indexOf(e);
63
- n != -1 && this.slice(n, 1);
62
+ const r = this.indexOf(e);
63
+ r != -1 && this.slice(r, 1);
64
64
  });
65
65
  }
66
66
  /**
@@ -69,7 +69,7 @@ class B extends Array {
69
69
  * @return {ASet<T>} Different elements
70
70
  */
71
71
  difference(t) {
72
- return new B(this.filter((e) => !t.has(e)));
72
+ return new E(this.filter((e) => !t.has(e)));
73
73
  }
74
74
  /**
75
75
  * Check if set includes element
@@ -85,7 +85,7 @@ class B extends Array {
85
85
  * @return {boolean} Set of common elements
86
86
  */
87
87
  intersection(t) {
88
- return new B(this.filter((e) => t.has(e)));
88
+ return new E(this.filter((e) => t.has(e)));
89
89
  }
90
90
  /**
91
91
  * Check if this set has no elements in common with the comparison set
@@ -117,7 +117,7 @@ class B extends Array {
117
117
  * @return {ASet<T>} New set of unique elements
118
118
  */
119
119
  symmetricDifference(t) {
120
- return new B([...this.difference(t), ...t.difference(this)]);
120
+ return new E([...this.difference(t), ...t.difference(this)]);
121
121
  }
122
122
  /**
123
123
  * Create joined list of elements included in this & the comparison set
@@ -125,10 +125,10 @@ class B extends Array {
125
125
  * @return {ASet<T>} New set of both previous sets combined
126
126
  */
127
127
  union(t) {
128
- return new B([...this, ...t]);
128
+ return new E([...this, ...t]);
129
129
  }
130
130
  }
131
- class Dt {
131
+ class Gt {
132
132
  /**
133
133
  * Create new cache
134
134
  *
@@ -140,8 +140,8 @@ class Dt {
140
140
  c(this, "complete", false);
141
141
  c(this, "values", this.all());
142
142
  return this.key = t, this.ttl = e, new Proxy(this, {
143
- get: (n, s) => s in n ? n[s] : n.store[s],
144
- set: (n, s, o) => (s in n ? n[s] = o : n.store[s] = o, true)
143
+ get: (r, s) => s in r ? r[s] : r.store[s],
144
+ set: (r, s, i) => (s in r ? r[s] = i : r.store[s] = i, true)
145
145
  });
146
146
  }
147
147
  getKey(t) {
@@ -164,8 +164,8 @@ class Dt {
164
164
  * @return {this}
165
165
  */
166
166
  add(t, e = this.ttl) {
167
- const n = this.getKey(t);
168
- return this.set(n, t, e), this;
167
+ const r = this.getKey(t);
168
+ return this.set(r, t, e), this;
169
169
  }
170
170
  /**
171
171
  * Add several rows to the cache
@@ -175,7 +175,7 @@ class Dt {
175
175
  * @return {this}
176
176
  */
177
177
  addAll(t, e = true) {
178
- return t.forEach((n) => this.add(n)), this.complete = e, this;
178
+ return t.forEach((r) => this.add(r)), this.complete = e, this;
179
179
  }
180
180
  /**
181
181
  * Delete an item from the cache
@@ -224,18 +224,18 @@ class Dt {
224
224
  * @param {number | undefined} ttl Override default expiry
225
225
  * @return {this}
226
226
  */
227
- set(t, e, n = this.ttl) {
228
- return this.store[t] = e, n && setTimeout(() => {
227
+ set(t, e, r = this.ttl) {
228
+ return this.store[t] = e, r && setTimeout(() => {
229
229
  this.complete = false, this.delete(t);
230
- }, n), this;
230
+ }, r), this;
231
231
  }
232
232
  }
233
- class E extends Promise {
233
+ class O extends Promise {
234
234
  constructor(e) {
235
- super((n, s) => e(
236
- (o) => n(o),
237
- (o) => s(o),
238
- (o) => this.progress = o
235
+ super((r, s) => e(
236
+ (i) => r(i),
237
+ (i) => s(i),
238
+ (i) => this.progress = i
239
239
  ));
240
240
  c(this, "listeners", []);
241
241
  c(this, "_progress", 0);
@@ -244,20 +244,20 @@ class E extends Promise {
244
244
  return this._progress;
245
245
  }
246
246
  set progress(e) {
247
- e != this._progress && (this._progress = e, this.listeners.forEach((n) => n(e)));
247
+ e != this._progress && (this._progress = e, this.listeners.forEach((r) => r(e)));
248
248
  }
249
249
  static from(e) {
250
- return e instanceof E ? e : new E((n, s) => e.then((...o) => n(...o)).catch((...o) => s(...o)));
250
+ return e instanceof O ? e : new O((r, s) => e.then((...i) => r(...i)).catch((...i) => s(...i)));
251
251
  }
252
252
  from(e) {
253
- const n = E.from(e);
254
- return this.onProgress((s) => n.progress = s), n;
253
+ const r = O.from(e);
254
+ return this.onProgress((s) => r.progress = s), r;
255
255
  }
256
256
  onProgress(e) {
257
257
  return this.listeners.push(e), this;
258
258
  }
259
- then(e, n) {
260
- const s = super.then(e, n);
259
+ then(e, r) {
260
+ const s = super.then(e, r);
261
261
  return this.from(s);
262
262
  }
263
263
  catch(e) {
@@ -267,81 +267,81 @@ class E extends Promise {
267
267
  return this.from(super.finally(e));
268
268
  }
269
269
  }
270
- function Gt(r, t) {
271
- r instanceof Blob || (r = new Blob(ft(r)));
272
- const e = URL.createObjectURL(r);
273
- dt(e, t), URL.revokeObjectURL(e);
270
+ function qt(n, t) {
271
+ n instanceof Blob || (n = new Blob(b(n)));
272
+ const e = URL.createObjectURL(n);
273
+ pt(e, t), URL.revokeObjectURL(e);
274
274
  }
275
- function dt(r, t) {
275
+ function pt(n, t) {
276
276
  const e = document.createElement("a");
277
- e.href = r, e.download = t || r.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
277
+ e.href = n, e.download = t || n.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
278
278
  }
279
- function Ut(r = {}) {
279
+ function Ft(n = {}) {
280
280
  return new Promise((t) => {
281
281
  const e = document.createElement("input");
282
- e.type = "file", e.accept = r.accept || "*", e.style.display = "none", e.multiple = !!r.multiple, e.onblur = e.onchange = async () => {
282
+ e.type = "file", e.accept = n.accept || "*", e.style.display = "none", e.multiple = !!n.multiple, e.onblur = e.onchange = async () => {
283
283
  t(Array.from(e.files)), e.remove();
284
284
  }, document.body.appendChild(e), e.click();
285
285
  });
286
286
  }
287
- function qt(r, t = /* @__PURE__ */ new Date()) {
287
+ function Yt(n, t = /* @__PURE__ */ new Date()) {
288
288
  (typeof t == "number" || typeof t == "string") && (t = new Date(t));
289
289
  const e = `${t.getFullYear()}-${(t.getMonth() + 1).toString().padStart(2, "0")}-${t.getDate().toString().padStart(2, "0")}_${t.getHours().toString().padStart(2, "0")}-${t.getMinutes().toString().padStart(2, "0")}-${t.getSeconds().toString().padStart(2, "0")}`;
290
290
  return e;
291
291
  }
292
- function Ft(r) {
293
- return new E((t, e, n) => {
294
- const s = new XMLHttpRequest(), o = new FormData();
295
- r.files.forEach((i) => o.append("file", i)), s.withCredentials = !!r.withCredentials, s.upload.addEventListener("progress", (i) => i.lengthComputable ? n(i.loaded / i.total) : null), s.addEventListener("loadend", () => t(M(s.responseText))), s.addEventListener("error", () => e(M(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", r.url), Object.entries(r.headers || {}).forEach(([i, a]) => s.setRequestHeader(i, a)), s.send(o);
292
+ function Ht(n) {
293
+ return new O((t, e, r) => {
294
+ const s = new XMLHttpRequest(), i = new FormData();
295
+ n.files.forEach((o) => i.append("file", o)), s.withCredentials = !!n.withCredentials, s.upload.addEventListener("progress", (o) => o.lengthComputable ? r(o.loaded / o.total) : null), s.addEventListener("loadend", () => t(k(s.responseText))), s.addEventListener("error", () => e(k(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", n.url), Object.entries(n.headers || {}).forEach(([o, u]) => s.setRequestHeader(o, u)), s.send(i);
296
296
  });
297
297
  }
298
- class _ {
298
+ class z {
299
299
  constructor() {
300
300
  c(this, "listeners", {});
301
301
  }
302
302
  static emit(t, ...e) {
303
- (this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t.toString()] || []).forEach((n) => n(...e));
303
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t.toString()] || []).forEach((r) => r(...e));
304
304
  }
305
305
  static off(t, e) {
306
- const n = t.toString();
307
- this.listeners[n] = (this.listeners[n] || []).filter((s) => s === e);
306
+ const r = t.toString();
307
+ this.listeners[r] = (this.listeners[r] || []).filter((s) => s === e);
308
308
  }
309
309
  static on(t, e) {
310
310
  var s;
311
- const n = t.toString();
312
- return this.listeners[n] || (this.listeners[n] = []), (s = this.listeners[n]) == null || s.push(e), () => this.off(t, e);
311
+ const r = t.toString();
312
+ return this.listeners[r] || (this.listeners[r] = []), (s = this.listeners[r]) == null || s.push(e), () => this.off(t, e);
313
313
  }
314
314
  static once(t, e) {
315
- return new Promise((n) => {
316
- const s = this.on(t, (...o) => {
317
- n(o.length == 1 ? o[0] : o), e && e(...o), s();
315
+ return new Promise((r) => {
316
+ const s = this.on(t, (...i) => {
317
+ r(i.length == 1 ? i[0] : i), e && e(...i), s();
318
318
  });
319
319
  });
320
320
  }
321
321
  emit(t, ...e) {
322
- (this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t] || []).forEach((n) => n(...e));
322
+ (this.listeners["*"] || []).forEach((r) => r(t, ...e)), (this.listeners[t] || []).forEach((r) => r(...e));
323
323
  }
324
324
  off(t, e) {
325
- this.listeners[t] = (this.listeners[t] || []).filter((n) => n === e);
325
+ this.listeners[t] = (this.listeners[t] || []).filter((r) => r === e);
326
326
  }
327
327
  on(t, e) {
328
- var n;
329
- return this.listeners[t] || (this.listeners[t] = []), (n = this.listeners[t]) == null || n.push(e), () => this.off(t, e);
328
+ var r;
329
+ return this.listeners[t] || (this.listeners[t] = []), (r = this.listeners[t]) == null || r.push(e), () => this.off(t, e);
330
330
  }
331
331
  once(t, e) {
332
- return new Promise((n) => {
333
- const s = this.on(t, (...o) => {
334
- n(o.length == 1 ? o[0] : o), e && e(...o), s();
332
+ return new Promise((r) => {
333
+ const s = this.on(t, (...i) => {
334
+ r(i.length == 1 ? i[0] : i), e && e(...i), s();
335
335
  });
336
336
  });
337
337
  }
338
338
  }
339
- c(_, "listeners", {});
340
- class p extends Error {
341
- constructor(e, n) {
339
+ c(z, "listeners", {});
340
+ class g extends Error {
341
+ constructor(e, r) {
342
342
  super(e);
343
343
  c(this, "_code");
344
- n != null && (this._code = n);
344
+ r != null && (this._code = r);
345
345
  }
346
346
  get code() {
347
347
  return this._code || this.constructor.code;
@@ -350,11 +350,11 @@ class p extends Error {
350
350
  this._code = e;
351
351
  }
352
352
  static from(e) {
353
- const n = Number(e.statusCode) ?? Number(e.code), s = new this(e.message || e.toString());
353
+ const r = Number(e.statusCode) ?? Number(e.code), s = new this(e.message || e.toString());
354
354
  return Object.assign(s, {
355
355
  stack: e.stack,
356
356
  ...e,
357
- code: n ?? void 0
357
+ code: r ?? void 0
358
358
  });
359
359
  }
360
360
  static instanceof(e) {
@@ -364,8 +364,8 @@ class p extends Error {
364
364
  return this.message || super.toString();
365
365
  }
366
366
  }
367
- c(p, "code", 500);
368
- class W extends p {
367
+ c(g, "code", 500);
368
+ class K extends g {
369
369
  constructor(t = "Bad Request") {
370
370
  super(t);
371
371
  }
@@ -373,8 +373,8 @@ class W extends p {
373
373
  return t.constructor.code == this.code;
374
374
  }
375
375
  }
376
- c(W, "code", 400);
377
- class J extends p {
376
+ c(K, "code", 400);
377
+ class Z extends g {
378
378
  constructor(t = "Unauthorized") {
379
379
  super(t);
380
380
  }
@@ -382,8 +382,8 @@ class J extends p {
382
382
  return t.constructor.code == this.code;
383
383
  }
384
384
  }
385
- c(J, "code", 401);
386
- class z extends p {
385
+ c(Z, "code", 401);
386
+ class _ extends g {
387
387
  constructor(t = "Payment Required") {
388
388
  super(t);
389
389
  }
@@ -391,8 +391,8 @@ class z extends p {
391
391
  return t.constructor.code == this.code;
392
392
  }
393
393
  }
394
- c(z, "code", 402);
395
- class K extends p {
394
+ c(_, "code", 402);
395
+ class V extends g {
396
396
  constructor(t = "Forbidden") {
397
397
  super(t);
398
398
  }
@@ -400,8 +400,8 @@ class K extends p {
400
400
  return t.constructor.code == this.code;
401
401
  }
402
402
  }
403
- c(K, "code", 403);
404
- class Z extends p {
403
+ c(V, "code", 403);
404
+ class X extends g {
405
405
  constructor(t = "Not Found") {
406
406
  super(t);
407
407
  }
@@ -409,8 +409,8 @@ class Z extends p {
409
409
  return t.constructor.code == this.code;
410
410
  }
411
411
  }
412
- c(Z, "code", 404);
413
- class V extends p {
412
+ c(X, "code", 404);
413
+ class Q extends g {
414
414
  constructor(t = "Method Not Allowed") {
415
415
  super(t);
416
416
  }
@@ -418,8 +418,8 @@ class V extends p {
418
418
  return t.constructor.code == this.code;
419
419
  }
420
420
  }
421
- c(V, "code", 405);
422
- class X extends p {
421
+ c(Q, "code", 405);
422
+ class tt extends g {
423
423
  constructor(t = "Not Acceptable") {
424
424
  super(t);
425
425
  }
@@ -427,8 +427,8 @@ class X extends p {
427
427
  return t.constructor.code == this.code;
428
428
  }
429
429
  }
430
- c(X, "code", 406);
431
- class Q extends p {
430
+ c(tt, "code", 406);
431
+ class et extends g {
432
432
  constructor(t = "Internal Server Error") {
433
433
  super(t);
434
434
  }
@@ -436,8 +436,8 @@ class Q extends p {
436
436
  return t.constructor.code == this.code;
437
437
  }
438
438
  }
439
- c(Q, "code", 500);
440
- class tt extends p {
439
+ c(et, "code", 500);
440
+ class nt extends g {
441
441
  constructor(t = "Not Implemented") {
442
442
  super(t);
443
443
  }
@@ -445,8 +445,8 @@ class tt extends p {
445
445
  return t.constructor.code == this.code;
446
446
  }
447
447
  }
448
- c(tt, "code", 501);
449
- class et extends p {
448
+ c(nt, "code", 501);
449
+ class rt extends g {
450
450
  constructor(t = "Bad Gateway") {
451
451
  super(t);
452
452
  }
@@ -454,8 +454,8 @@ class et extends p {
454
454
  return t.constructor.code == this.code;
455
455
  }
456
456
  }
457
- c(et, "code", 502);
458
- class rt extends p {
457
+ c(rt, "code", 502);
458
+ class st extends g {
459
459
  constructor(t = "Service Unavailable") {
460
460
  super(t);
461
461
  }
@@ -463,8 +463,8 @@ class rt extends p {
463
463
  return t.constructor.code == this.code;
464
464
  }
465
465
  }
466
- c(rt, "code", 503);
467
- class nt extends p {
466
+ c(st, "code", 503);
467
+ class it extends g {
468
468
  constructor(t = "Gateway Timeout") {
469
469
  super(t);
470
470
  }
@@ -472,18 +472,18 @@ class nt extends p {
472
472
  return t.constructor.code == this.code;
473
473
  }
474
474
  }
475
- c(nt, "code", 504);
476
- const w = class w2 {
475
+ c(it, "code", 504);
476
+ const m = class m2 {
477
477
  constructor(t = {}) {
478
478
  c(this, "interceptors", {});
479
479
  c(this, "headers", {});
480
480
  c(this, "url");
481
- this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w2.addInterceptor(e));
481
+ this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => m2.addInterceptor(e));
482
482
  }
483
483
  static addInterceptor(t) {
484
- const e = Object.keys(w2.interceptors).length.toString();
485
- return w2.interceptors[e] = t, () => {
486
- w2.interceptors[e] = null;
484
+ const e = Object.keys(m2.interceptors).length.toString();
485
+ return m2.interceptors[e] = t, () => {
486
+ m2.interceptors[e] = null;
487
487
  };
488
488
  }
489
489
  addInterceptor(t) {
@@ -496,50 +496,50 @@ const w = class w2 {
496
496
  var s;
497
497
  if (!this.url && !t.url) throw new Error("URL needs to be set");
498
498
  let e = ((s = t.url) != null && s.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
499
- if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (o, i) => `#${t.fragment}${i}`) : e += "#" + t.fragment), t.query) {
500
- const o = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((i) => ({ key: i, value: t.query[i] }));
501
- e += (e.includes("?") ? "&" : "?") + o.map((i) => `${i.key}=${i.value}`).join("&");
499
+ if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (i, o) => `#${t.fragment}${o}`) : e += "#" + t.fragment), t.query) {
500
+ const i = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((o) => ({ key: o, value: t.query[o] }));
501
+ e += (e.includes("?") ? "&" : "?") + i.map((o) => `${o.key}=${o.value}`).join("&");
502
502
  }
503
- const n = ut({
503
+ const r = lt({
504
504
  "Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
505
- ...w2.headers,
505
+ ...m2.headers,
506
506
  ...this.headers,
507
507
  ...t.headers
508
508
  });
509
- return typeof t.body == "object" && t.body != null && n["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new E((o, i, a) => {
509
+ return typeof t.body == "object" && t.body != null && r["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new O((i, o, u) => {
510
510
  fetch(e, {
511
- headers: n,
511
+ headers: r,
512
512
  method: t.method || (t.body ? "POST" : "GET"),
513
513
  body: t.body
514
- }).then(async (u) => {
515
- var G, U;
516
- for (let l of [...Object.values(w2.interceptors), ...Object.values(this.interceptors)])
517
- await new Promise((R) => l(u, () => R()));
518
- const v = u.headers.get("Content-Length"), N = v ? parseInt(v, 10) : 0;
519
- let P = 0;
520
- const I = (G = u.body) == null ? void 0 : G.getReader(), ot = new ReadableStream({
514
+ }).then(async (a) => {
515
+ var q, F;
516
+ for (let l of [...Object.values(m2.interceptors), ...Object.values(this.interceptors)])
517
+ await new Promise((C) => l(a, () => C()));
518
+ const R = a.headers.get("Content-Length"), T = R ? parseInt(R, 10) : 0;
519
+ let U = 0;
520
+ const M = (q = a.body) == null ? void 0 : q.getReader(), ct = new ReadableStream({
521
521
  start(l) {
522
- function R() {
523
- I == null || I.read().then((O) => {
524
- if (O.done) return l.close();
525
- P += O.value.byteLength, a(P / N), l.enqueue(O.value), R();
526
- }).catch((O) => l.error(O));
522
+ function C() {
523
+ M == null || M.read().then((A) => {
524
+ if (A.done) return l.close();
525
+ U += A.value.byteLength, u(U / T), l.enqueue(A.value), C();
526
+ }).catch((A) => l.error(A));
527
527
  }
528
- R();
528
+ C();
529
529
  }
530
530
  });
531
- if (u.data = new Response(ot), t.decode == null || t.decode) {
532
- const l = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
533
- l != null && l.includes("form") ? u.data = await u.data.formData() : l != null && l.includes("json") ? u.data = await u.data.json() : l != null && l.includes("text") ? u.data = await u.data.text() : l != null && l.includes("application") && (u.data = await u.data.blob());
531
+ if (a.data = new Response(ct), t.decode == null || t.decode) {
532
+ const l = (F = a.headers.get("Content-Type")) == null ? void 0 : F.toLowerCase();
533
+ l != null && l.includes("form") ? a.data = await a.data.formData() : l != null && l.includes("json") ? a.data = await a.data.json() : l != null && l.includes("text") ? a.data = await a.data.text() : l != null && l.includes("application") && (a.data = await a.data.blob());
534
534
  }
535
- u.ok ? o(u) : i(u);
535
+ a.ok ? i(a) : o(a);
536
536
  });
537
537
  });
538
538
  }
539
539
  };
540
- c(w, "interceptors", {}), c(w, "headers", {});
541
- let F = w;
542
- const x = {
540
+ c(m, "interceptors", {}), c(m, "headers", {});
541
+ let H = m;
542
+ const j = {
543
543
  CLEAR: "\x1B[0m",
544
544
  BRIGHT: "\x1B[1m",
545
545
  DIM: "\x1B[2m",
@@ -547,7 +547,7 @@ const x = {
547
547
  BLINK: "\x1B[5m",
548
548
  REVERSE: "\x1B[7m",
549
549
  HIDDEN: "\x1B[8m"
550
- }, $ = {
550
+ }, L = {
551
551
  BLACK: "\x1B[30m",
552
552
  RED: "\x1B[31m",
553
553
  GREEN: "\x1B[32m",
@@ -565,52 +565,190 @@ const x = {
565
565
  LIGHT_CYAN: "\x1B[96m",
566
566
  WHITE: "\x1B[97m"
567
567
  };
568
- var yt = /* @__PURE__ */ ((r) => (r[r.ERROR = 0] = "ERROR", r[r.WARN = 1] = "WARN", r[r.INFO = 2] = "INFO", r[r.LOG = 3] = "LOG", r[r.DEBUG = 4] = "DEBUG", r))(yt || {});
569
- const g = class g2 extends _ {
568
+ var yt = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(yt || {});
569
+ const w = class w2 extends z {
570
570
  constructor(t) {
571
571
  super(), this.namespace = t;
572
572
  }
573
- pad(t, e, n, s = false) {
574
- const o = t.toString(), i = e - o.length;
575
- if (i <= 0) return o;
576
- const a = Array(~~(i / n.length)).fill(n).join("");
577
- return s ? o + a : a + o;
573
+ pad(t, e, r, s = false) {
574
+ const i = t.toString(), o = e - i.length;
575
+ if (o <= 0) return i;
576
+ const u = Array(~~(o / r.length)).fill(r).join("");
577
+ return s ? i + u : u + i;
578
578
  }
579
579
  format(...t) {
580
580
  const e = /* @__PURE__ */ new Date();
581
581
  return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", true)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
582
582
  }
583
583
  debug(...t) {
584
- if (g2.LOG_LEVEL < 4) return;
584
+ if (w2.LOG_LEVEL < 4) return;
585
585
  const e = this.format(...t);
586
- g2.emit(4, e), console.debug($.LIGHT_GREY + e + x.CLEAR);
586
+ w2.emit(4, e), console.debug(L.LIGHT_GREY + e + j.CLEAR);
587
587
  }
588
588
  log(...t) {
589
- if (g2.LOG_LEVEL < 3) return;
589
+ if (w2.LOG_LEVEL < 3) return;
590
590
  const e = this.format(...t);
591
- g2.emit(3, e), console.log(x.CLEAR + e);
591
+ w2.emit(3, e), console.log(j.CLEAR + e);
592
592
  }
593
593
  info(...t) {
594
- if (g2.LOG_LEVEL < 2) return;
594
+ if (w2.LOG_LEVEL < 2) return;
595
595
  const e = this.format(...t);
596
- g2.emit(2, e), console.info($.BLUE + e + x.CLEAR);
596
+ w2.emit(2, e), console.info(L.BLUE + e + j.CLEAR);
597
597
  }
598
598
  warn(...t) {
599
- if (g2.LOG_LEVEL < 1) return;
599
+ if (w2.LOG_LEVEL < 1) return;
600
600
  const e = this.format(...t);
601
- g2.emit(1, e), console.warn($.YELLOW + e + x.CLEAR);
601
+ w2.emit(1, e), console.warn(L.YELLOW + e + j.CLEAR);
602
602
  }
603
603
  error(...t) {
604
- if (g2.LOG_LEVEL < 0) return;
604
+ if (w2.LOG_LEVEL < 0) return;
605
605
  const e = this.format(...t);
606
- g2.emit(0, e), console.error($.RED + e + x.CLEAR);
606
+ w2.emit(0, e), console.error(L.RED + e + j.CLEAR);
607
607
  }
608
608
  };
609
- c(g, "LOG_LEVEL", 4);
610
- var j = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, xt = {}, S = {};
611
- Object.defineProperty(S, "__esModule", { value: true });
612
- S.persist = S.Persist = void 0;
613
- class st {
609
+ c(w, "LOG_LEVEL", 4);
610
+ function ue(n, ...t) {
611
+ const e = [];
612
+ for (let r = 0; r < n.length || r < t.length; r++)
613
+ n[r] && e.push(n[r]), t[r] && e.push(t[r]);
614
+ return new y(e.join(""));
615
+ }
616
+ function xt(n, ...t) {
617
+ let e = [];
618
+ for (let i = 0; i < n.length || i < t.length; i++)
619
+ n[i] && e.push(n[i]), t[i] && e.push(t[i]);
620
+ const [r, s] = e.join("").split(":");
621
+ return y.toString(r, s == null ? void 0 : s.split(""));
622
+ }
623
+ class y {
624
+ constructor(t) {
625
+ c(this, "module");
626
+ c(this, "fullPath");
627
+ c(this, "path");
628
+ c(this, "name");
629
+ c(this, "methods");
630
+ c(this, "all");
631
+ c(this, "none");
632
+ c(this, "create");
633
+ c(this, "read");
634
+ c(this, "update");
635
+ c(this, "delete");
636
+ var o;
637
+ if (typeof t == "object") return Object.assign(this, t);
638
+ let [e, r, s] = t.split(":");
639
+ s || (s = r || "*"), (e == "*" || !e && s == "*") && (e = "", s = "*");
640
+ let i = e.split("/").filter((u) => !!u);
641
+ this.module = ((o = i.splice(0, 1)[0]) == null ? void 0 : o.toLowerCase()) || "", this.fullPath = e, this.path = i.join("/"), this.name = i.pop() || "", this.methods = s.split(""), this.all = s == null ? void 0 : s.includes("*"), this.none = s == null ? void 0 : s.includes("n"), this.create = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("c"))), this.read = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("r"))), this.update = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("u"))), this.delete = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("d")));
642
+ }
643
+ /**
644
+ * Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
645
+ * combined until a "none" is reached
646
+ *
647
+ * @param {string | PathEvent} paths Events as strings or pre-parsed
648
+ * @return {PathEvent} Final combined permission
649
+ */
650
+ static combine(t) {
651
+ let e = false;
652
+ const r = t.map((s) => new y(s)).toSorted((s, i) => {
653
+ const o = s.fullPath.length, u = i.fullPath.length;
654
+ return o < u ? 1 : o > u ? -1 : 0;
655
+ }).reduce((s, i) => (i.none && (e = true), s ? (e || (i.all && (s.all = true), (i.all || i.create) && (s.create = true), (i.all || i.read) && (s.read = true), (i.all || i.update) && (s.update = true), (i.all || i.delete) && (s.delete = true), s.methods = [...s.methods, ...i.methods]), s) : i), null);
656
+ return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new E(r.methods), r.raw = xt`${r.fullPath}:${r.methods}`, r;
657
+ }
658
+ /**
659
+ * Squash 2 sets of paths & return true if any overlap is found
660
+ *
661
+ * @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
662
+ * @param has Target must have at least one of these path
663
+ * @return {boolean} Whether there is any overlap
664
+ */
665
+ static has(t, ...e) {
666
+ const r = b(e).map((i) => new y(i)), s = b(t).map((i) => new y(i));
667
+ return !!r.find((i) => {
668
+ if (!i.fullPath && i.all) return true;
669
+ const o = s.filter((a) => i.fullPath.startsWith(a.fullPath));
670
+ if (!o.length) return false;
671
+ const u = y.combine(o);
672
+ return !u.none && (u.all || new E(u.methods).intersection(new E(i.methods)).length);
673
+ });
674
+ }
675
+ /**
676
+ * Squash 2 sets of paths & return true if the target has all paths
677
+ *
678
+ * @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
679
+ * @param has Target must have all these paths
680
+ * @return {boolean} Whether there is any overlap
681
+ */
682
+ static hasAll(t, ...e) {
683
+ return e.filter((r) => y.has(t, r)).length == e.length;
684
+ }
685
+ /**
686
+ * Same as `has` but raises an error if there is no overlap
687
+ *
688
+ * @param {string | string[]} target Array of Events as strings or pre-parsed
689
+ * @param has Target must have at least one of these path
690
+ */
691
+ static hasFatal(t, ...e) {
692
+ if (!y.has(t, ...e)) throw new Error(`Requires one of: ${b(e).join(", ")}`);
693
+ }
694
+ /**
695
+ * Same as `hasAll` but raises an error if the target is missing any paths
696
+ *
697
+ * @param {string | string[]} target Array of Events as strings or pre-parsed
698
+ * @param has Target must have all these paths
699
+ */
700
+ static hasAllFatal(t, ...e) {
701
+ if (!y.hasAll(t, ...e)) throw new Error(`Requires all: ${b(e).join(", ")}`);
702
+ }
703
+ /**
704
+ * Create event string from its components
705
+ *
706
+ * @param {string | string[]} path Event path
707
+ * @param {Method} methods Event method
708
+ * @return {string} String representation of Event
709
+ */
710
+ static toString(t, e) {
711
+ let r = b(t).filter((s) => s != null).join("/");
712
+ return e != null && e.length && (r += `:${b(e).map((s) => s.toLowerCase()).join("")}`), r == null ? void 0 : r.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
713
+ }
714
+ /**
715
+ * Create event string from its components
716
+ *
717
+ * @return {string} String representation of Event
718
+ */
719
+ toString() {
720
+ return y.toString(this.fullPath, this.methods);
721
+ }
722
+ }
723
+ class ae {
724
+ constructor() {
725
+ c(this, "listeners", []);
726
+ }
727
+ emit(t, ...e) {
728
+ const r = new y(t);
729
+ this.listeners.filter((s) => y.has(s[0], t)).forEach(async (s) => s[1](r, ...e));
730
+ }
731
+ off(t) {
732
+ this.listeners = this.listeners.filter((e) => e[1] != t);
733
+ }
734
+ on(t, e) {
735
+ return b(t).forEach((r) => this.listeners.push([new y(r), e])), () => this.off(e);
736
+ }
737
+ once(t, e) {
738
+ return new Promise((r) => {
739
+ const s = this.on(t, (i, ...o) => {
740
+ r(o.length < 2 ? o[0] : o), e && e(i, ...o), s();
741
+ });
742
+ });
743
+ }
744
+ relayEvents(t) {
745
+ t.on("*", (e, ...r) => this.emit(e, ...r));
746
+ }
747
+ }
748
+ var v = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, At = {}, B = {};
749
+ Object.defineProperty(B, "__esModule", { value: true });
750
+ B.persist = B.Persist = void 0;
751
+ class ot {
614
752
  /**
615
753
  * @param {string} key Primary key value will be stored under
616
754
  * @param {PersistOptions<T>} options Configure using {@link PersistOptions}
@@ -631,11 +769,11 @@ class st {
631
769
  /** Set value with proxy object wrapper to sync future changes */
632
770
  set value(t) {
633
771
  t == null || typeof t != "object" ? this._value = t : this._value = new Proxy(t, {
634
- get: (e, n) => typeof e[n] == "function" ? (...o) => {
635
- const i = e[n](...o);
636
- return this.save(), i;
637
- } : e[n],
638
- set: (e, n, s) => (e[n] = s, this.save(), true)
772
+ get: (e, r) => typeof e[r] == "function" ? (...i) => {
773
+ const o = e[r](...i);
774
+ return this.save(), o;
775
+ } : e[r],
776
+ set: (e, r, s) => (e[r] = s, this.save(), true)
639
777
  }), this.save();
640
778
  }
641
779
  /** Notify listeners of change */
@@ -687,25 +825,25 @@ class st {
687
825
  return this.value;
688
826
  }
689
827
  }
690
- S.Persist = st;
691
- function Bt(r) {
828
+ B.Persist = ot;
829
+ function jt(n) {
692
830
  return (t, e) => {
693
- const n = (r == null ? void 0 : r.key) || `${t.constructor.name}.${e.toString()}`, s = new st(n, r);
831
+ const r = (n == null ? void 0 : n.key) || `${t.constructor.name}.${e.toString()}`, s = new ot(r, n);
694
832
  Object.defineProperty(t, e, {
695
833
  get: function() {
696
834
  return s.value;
697
835
  },
698
- set: function(o) {
699
- s.value = o;
836
+ set: function(i) {
837
+ s.value = i;
700
838
  }
701
839
  });
702
840
  };
703
841
  }
704
- S.persist = Bt;
705
- var L = {};
706
- Object.defineProperty(L, "__esModule", { value: true });
707
- L.MemoryStorage = void 0;
708
- class At {
842
+ B.persist = jt;
843
+ var I = {};
844
+ Object.defineProperty(I, "__esModule", { value: true });
845
+ I.MemoryStorage = void 0;
846
+ class $t {
709
847
  get length() {
710
848
  return Object.keys(this).length;
711
849
  }
@@ -725,194 +863,26 @@ class At {
725
863
  this[t] = e;
726
864
  }
727
865
  }
728
- L.MemoryStorage = At;
729
- (function(r) {
730
- var t = j && j.__createBinding || (Object.create ? function(n, s, o, i) {
731
- i === void 0 && (i = o);
732
- var a = Object.getOwnPropertyDescriptor(s, o);
733
- (!a || ("get" in a ? !s.__esModule : a.writable || a.configurable)) && (a = { enumerable: true, get: function() {
734
- return s[o];
735
- } }), Object.defineProperty(n, i, a);
736
- } : function(n, s, o, i) {
737
- i === void 0 && (i = o), n[i] = s[o];
738
- }), e = j && j.__exportStar || function(n, s) {
739
- for (var o in n) o !== "default" && !Object.prototype.hasOwnProperty.call(s, o) && t(s, n, o);
866
+ I.MemoryStorage = $t;
867
+ (function(n) {
868
+ var t = v && v.__createBinding || (Object.create ? function(r, s, i, o) {
869
+ o === void 0 && (o = i);
870
+ var u = Object.getOwnPropertyDescriptor(s, i);
871
+ (!u || ("get" in u ? !s.__esModule : u.writable || u.configurable)) && (u = { enumerable: true, get: function() {
872
+ return s[i];
873
+ } }), Object.defineProperty(r, o, u);
874
+ } : function(r, s, i, o) {
875
+ o === void 0 && (o = i), r[o] = s[i];
876
+ }), e = v && v.__exportStar || function(r, s) {
877
+ for (var i in r) i !== "default" && !Object.prototype.hasOwnProperty.call(s, i) && t(s, r, i);
740
878
  };
741
- Object.defineProperty(r, "__esModule", { value: true }), e(S, r), e(L, r);
742
- })(xt);
743
- function PE(str, ...args) {
744
- const combined = [];
745
- for (let i = 0; i < str.length || i < args.length; i++) {
746
- if (str[i]) combined.push(str[i]);
747
- if (args[i]) combined.push(args[i]);
748
- }
749
- return new PathEvent(combined.join(""));
750
- }
751
- function PES(str, ...args) {
752
- let combined = [];
753
- for (let i = 0; i < str.length || i < args.length; i++) {
754
- if (str[i]) combined.push(str[i]);
755
- if (args[i]) combined.push(args[i]);
756
- }
757
- const [paths, methods] = combined.join("").split(":");
758
- return PathEvent.toString(paths, methods == null ? void 0 : methods.split(""));
759
- }
760
- class PathEvent {
761
- constructor(pathedEvent) {
762
- /** First directory in path */
763
- __publicField(this, "module");
764
- /** Entire path, including the module & name */
765
- __publicField(this, "fullPath");
766
- /** Path including the name, excluding the module */
767
- __publicField(this, "path");
768
- /** Last sagment of path */
769
- __publicField(this, "name");
770
- /** List of methods */
771
- __publicField(this, "methods");
772
- /** All/Wildcard specified */
773
- __publicField(this, "all");
774
- /** None specified */
775
- __publicField(this, "none");
776
- /** Create method specified */
777
- __publicField(this, "create");
778
- /** Read method specified */
779
- __publicField(this, "read");
780
- /** Update method specified */
781
- __publicField(this, "update");
782
- /** Delete method specified */
783
- __publicField(this, "delete");
784
- var _a;
785
- if (typeof pathedEvent == "object") return Object.assign(this, pathedEvent);
786
- let [p2, scope, method] = pathedEvent.split(":");
787
- if (!method) method = scope || "*";
788
- if (p2 == "*" || !p2 && method == "*") {
789
- p2 = "";
790
- method = "*";
791
- }
792
- let temp = p2.split("/").filter((p22) => !!p22);
793
- this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
794
- this.fullPath = p2;
795
- this.path = temp.join("/");
796
- this.name = temp.pop() || "";
797
- this.methods = method.split("");
798
- this.all = method == null ? void 0 : method.includes("*");
799
- this.none = method == null ? void 0 : method.includes("n");
800
- this.create = !(method == null ? void 0 : method.includes("n")) && ((method == null ? void 0 : method.includes("*")) || (method == null ? void 0 : method.includes("w")) || (method == null ? void 0 : method.includes("c")));
801
- this.read = !(method == null ? void 0 : method.includes("n")) && ((method == null ? void 0 : method.includes("*")) || (method == null ? void 0 : method.includes("r")));
802
- this.update = !(method == null ? void 0 : method.includes("n")) && ((method == null ? void 0 : method.includes("*")) || (method == null ? void 0 : method.includes("w")) || (method == null ? void 0 : method.includes("u")));
803
- this.delete = !(method == null ? void 0 : method.includes("n")) && ((method == null ? void 0 : method.includes("*")) || (method == null ? void 0 : method.includes("w")) || (method == null ? void 0 : method.includes("d")));
804
- }
805
- /**
806
- * Combine multiple pathed events into one parsed object. Longest path takes precedent, but all subsequent methods are
807
- * combined until a "none" is reached
808
- *
809
- * @param {string | PathEvent} paths PathedEvents as strings or pre-parsed
810
- * @return {PathEvent} Final combined permission
811
- */
812
- static combine(paths) {
813
- let hitNone = false;
814
- const combined = paths.map((p2) => new PathEvent(p2)).toSorted((p1, p2) => {
815
- const l1 = p1.fullPath.length, l2 = p2.fullPath.length;
816
- return l1 < l2 ? 1 : l1 > l2 ? -1 : 0;
817
- }).reduce((acc, p2) => {
818
- if (p2.none) hitNone = true;
819
- if (!acc) return p2;
820
- if (hitNone) return acc;
821
- if (p2.all) acc.all = true;
822
- if (p2.all || p2.create) acc.create = true;
823
- if (p2.all || p2.read) acc.read = true;
824
- if (p2.all || p2.update) acc.update = true;
825
- if (p2.all || p2.delete) acc.delete = true;
826
- acc.methods = [...acc.methods, ...p2.methods];
827
- return acc;
828
- }, null);
829
- if (combined.all) combined.methods = ["*"];
830
- if (combined.none) combined.methods = ["n"];
831
- combined.methods = new B(combined.methods);
832
- combined.raw = PES`${combined.fullPath}:${combined.methods}`;
833
- return combined;
834
- }
835
- /**
836
- * Squash 2 sets of paths & return true if any overlap is found
837
- *
838
- * @param {string | PathEvent | (string | PathEvent)[]} target Array of PathedEvents as strings or pre-parsed
839
- * @param has
840
- * @return {boolean} Whether there is any overlap
841
- */
842
- static has(target, ...has) {
843
- const parsedRequired = ft(has).map((pe) => new PathEvent(pe));
844
- const parsedTarget = ft(target).map((pe) => new PathEvent(pe));
845
- return !!parsedRequired.find((r) => {
846
- if (!r.fullPath && r.all) return true;
847
- const filtered = parsedTarget.filter((p2) => r.fullPath.startsWith(p2.fullPath));
848
- if (!filtered.length) return false;
849
- const combined = PathEvent.combine(filtered);
850
- return !combined.none && (combined.all || new B(combined.methods).intersection(new B(r.methods)).length);
851
- });
852
- }
853
- /**
854
- * Same as `has` but raises an error if there is no overlap
855
- *
856
- * @param {string | string[]} target Array of PathedEvents as strings or pre-parsed
857
- * @param has
858
- */
859
- static hasFatal(target, ...has) {
860
- if (!PathEvent.has(target, ...has)) throw new Error(`Missing permission: ${ft(has).join(", ")}`);
861
- }
862
- /**
863
- * Create pathed event string from its components
864
- *
865
- * @param {string | string[]} path Event path
866
- * @param {Method} methods Event method
867
- * @return {string} String representation of PathedEvent
868
- */
869
- static toString(path, methods) {
870
- let p2 = ft(path).filter((p22) => p22 != null).join("/");
871
- if (methods == null ? void 0 : methods.length) p2 += `:${ft(methods).map((m) => m.toLowerCase()).join("")}`;
872
- return p2 == null ? void 0 : p2.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
873
- }
874
- /**
875
- * Create pathed event string from its components
876
- *
877
- * @return {string} String representation of PathedEvent
878
- */
879
- toString() {
880
- return PathEvent.toString(this.fullPath, this.methods);
881
- }
882
- }
883
- class PathedEventEmitter {
884
- constructor() {
885
- __publicField(this, "listeners", []);
886
- }
887
- emit(event, ...args) {
888
- const parsed = new PathEvent(event);
889
- this.listeners.filter((l) => PathEvent.has(l[0], event)).forEach((l) => l[1](parsed, ...args));
890
- }
891
- off(listener) {
892
- this.listeners = this.listeners.filter((l) => l[1] != listener);
893
- }
894
- on(event, listener) {
895
- ft(event).forEach((e) => this.listeners.push([new PathEvent(e), listener]));
896
- return () => this.off(listener);
897
- }
898
- once(event, listener) {
899
- return new Promise((res) => {
900
- const unsubscribe = this.on(event, (event2, ...args) => {
901
- res(args.length < 2 ? args[0] : args);
902
- if (listener) listener(event2, ...args);
903
- unsubscribe();
904
- });
905
- });
906
- }
907
- relayEvents(emitter) {
908
- emitter.on("*", (event, ...args) => this.emit(event, ...args));
909
- }
910
- }
911
- class Api extends F {
879
+ Object.defineProperty(n, "__esModule", { value: true }), e(B, n), e(I, n);
880
+ })(At);
881
+ class Api extends H {
912
882
  constructor(url = location.origin, opts = {}) {
913
883
  opts.url = url;
914
884
  super(opts);
915
- __publicField(this, "emitter", new PathedEventEmitter());
885
+ __publicField(this, "emitter", new ae());
916
886
  __publicField(this, "pending", {});
917
887
  __publicField(this, "_token", null);
918
888
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
@@ -930,27 +900,27 @@ class Api extends F {
930
900
  if (token == this._token) return;
931
901
  this._token = token;
932
902
  this.headers["Authorization"] = token ? `Bearer ${token}` : null;
933
- this.emit(PES`api/token:${token ? "u" : "d"}`, token);
903
+ this.emit(xt`api/token:${token ? "u" : "d"}`, token);
934
904
  }
935
905
  healthcheck() {
936
906
  return this.request({ url: "/api/healthcheck" }).then((resp) => {
937
- this.emit(PES`api/healthcheck:r`, resp);
907
+ this.emit(xt`api/healthcheck:r`, resp);
938
908
  return resp;
939
909
  });
940
910
  }
941
911
  request(options) {
942
- const key = Lt(options);
912
+ const key = It(options);
943
913
  const method = options.method == "GET" ? "r" : options.method == "POST" ? "c" : options.method == "DELETE" ? "d" : "u";
944
914
  if (this.pending[key] != null) return this.pending[key];
945
915
  this.pending[key] = super.request(options).then((response) => {
946
- this.emit(PES`api/response:${method}`, { request: options, response });
916
+ this.emit(xt`api/response:${method}`, { request: options, response });
947
917
  return response.data;
948
918
  }).catch((err) => {
949
919
  const e = (err == null ? void 0 : err.data) || err;
950
- this.emit(PES`api/error:${method}`, { request: options, error: e });
920
+ this.emit(xt`api/error:${method}`, { request: options, error: e });
951
921
  throw e;
952
922
  }).finally(() => delete this.pending[key]);
953
- this.emit(PES`api/request:${method}`, { request: options, response: this.pending[key] });
923
+ this.emit(xt`api/request:${method}`, { request: options, response: this.pending[key] });
954
924
  return this.pending[key];
955
925
  }
956
926
  }
@@ -964,59 +934,59 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
964
934
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
965
935
  return ActionType2;
966
936
  })(ActionType || {});
967
- class Actions extends PathedEventEmitter {
937
+ class Actions extends ae {
968
938
  constructor(api) {
969
939
  super();
970
940
  __publicField(this, "api");
971
- __publicField(this, "cache", new Dt("_id"));
941
+ __publicField(this, "cache", new Gt("_id"));
972
942
  this.api = typeof api == "string" ? new Api(api) : api;
973
943
  }
974
- delete(id) {
975
- if (!id) throw new Error("Cannot delete action, missing ID");
976
- return this.api.request({ url: `/api/` + PES`actions/${id}`, method: "DELETE" }).then(() => {
977
- this.cache.delete(id);
978
- this.emit(PES`actions/${id}:d`, id);
979
- });
980
- }
981
944
  all() {
982
- return this.api.request({ url: `/api/` + PES`actions` }).then((resp) => {
945
+ return this.api.request({ url: `/api/` + xt`actions` }).then((resp) => {
983
946
  this.cache.addAll(resp);
984
- this.emit(PES`actions:r`, resp || []);
947
+ this.emit(xt`actions:r`, resp || []);
985
948
  return resp;
986
949
  });
987
950
  }
951
+ delete(id) {
952
+ if (!id) throw new Error("Cannot delete action, missing ID");
953
+ return this.api.request({ url: `/api/` + xt`actions/${id}`, method: "DELETE" }).then(() => {
954
+ this.cache.delete(id);
955
+ this.emit(xt`actions/${id}:d`, id);
956
+ });
957
+ }
988
958
  read(id, reload = false) {
989
959
  if (!id) throw new Error("Cannot read action, missing ID");
990
960
  const cached = this.cache.get(id);
991
961
  if (!reload && cached) return Promise.resolve(cached);
992
- return this.api.request({ url: `/api/` + PES`actions/${id}` }).then((action) => {
962
+ return this.api.request({ url: `/api/` + xt`actions/${id}` }).then((action) => {
993
963
  if (action) this.cache.add(action);
994
- this.emit(PES`actions/${id}:r`, action);
964
+ this.emit(xt`actions/${id}:r`, action);
995
965
  return action;
996
966
  });
997
967
  }
998
968
  run(path, opts = {}) {
999
969
  if (!path) throw new Error("Cannot run action, missing path");
1000
- return this.api.request({ url: `/api/` + PES`actions/run/${path}`, ...opts });
970
+ return this.api.request({ url: `/api/` + xt`actions/run/${path}`, ...opts });
1001
971
  }
1002
972
  runById(action, opts = {}) {
1003
973
  const id = typeof action == "string" ? action : action == null ? void 0 : action._id;
1004
974
  if (!id) throw new Error("Cannot run action, missing ID");
1005
- return this.api.request({ url: "/api/" + PES`actions/run-by-id/${id}`, method: "POST", ...opts });
975
+ return this.api.request({ url: "/api/" + xt`actions/run-by-id/${id}`, method: "POST", ...opts });
1006
976
  }
1007
977
  update(action) {
1008
978
  return this.api.request({
1009
- url: `/api/` + PES`actions/${action._id}`,
979
+ url: `/api/` + xt`actions/${action._id}`,
1010
980
  method: "POST",
1011
981
  body: action
1012
982
  }).then((action2) => {
1013
983
  if (action2) this.cache.add(action2);
1014
- this.emit(PES`actions/${action2._id}:u`, action2);
984
+ this.emit(xt`actions/${action2._id}:u`, action2);
1015
985
  return action2;
1016
986
  });
1017
987
  }
1018
988
  }
1019
- class Ai extends PathedEventEmitter {
989
+ class Ai extends ae {
1020
990
  constructor(api) {
1021
991
  super();
1022
992
  __publicField(this, "api");
@@ -1024,19 +994,19 @@ class Ai extends PathedEventEmitter {
1024
994
  }
1025
995
  ask(question, context) {
1026
996
  if (!question) throw new Error("Cannot ask AI, missing question");
1027
- return this.api.request({ url: `/api/` + PES`ai`, method: "POST", body: {
997
+ return this.api.request({ url: `/api/` + xt`ai`, method: "POST", body: {
1028
998
  question,
1029
999
  context
1030
1000
  } }).then((response) => {
1031
- this.emit(PES`ai:c`, { question, context, response });
1001
+ this.emit(xt`ai:c`, { question, context, response });
1032
1002
  return response;
1033
1003
  });
1034
1004
  }
1035
1005
  clear() {
1036
- return this.api.request({ url: "/api/" + PES`ai`, method: "DELETE" }).then(() => this.emit(PES`ai:d`, this.api.token));
1006
+ return this.api.request({ url: "/api/" + xt`ai`, method: "DELETE" }).then(() => this.emit(xt`ai:d`, this.api.token));
1037
1007
  }
1038
1008
  }
1039
- class Analytics extends PathedEventEmitter {
1009
+ class Analytics extends ae {
1040
1010
  constructor(api) {
1041
1011
  super();
1042
1012
  __publicField(this, "api");
@@ -1044,42 +1014,23 @@ class Analytics extends PathedEventEmitter {
1044
1014
  }
1045
1015
  ipTrace(ip) {
1046
1016
  if (!ip) throw new Error("Cannot trace, missing IP");
1047
- return this.api.request({ url: `/api/` + PES`analytics/trace/${ip}` }).then((resp) => {
1048
- this.emit(PES`analytics/trace/${ip}:r`, resp);
1017
+ return this.api.request({ url: `/api/` + xt`analytics/trace/${ip}` }).then((resp) => {
1018
+ this.emit(xt`analytics/trace/${ip}:r`, resp);
1049
1019
  return resp;
1050
1020
  });
1051
1021
  }
1052
1022
  }
1053
- class Totp {
1054
- constructor(api) {
1055
- __publicField(this, "enable", this.reset);
1056
- this.api = api;
1057
- }
1058
- disable(username) {
1059
- return this.api.request({ url: `/api/auth/totp/${username}`, method: "DELETE" });
1060
- }
1061
- reset(username) {
1062
- return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1063
- }
1064
- setup(username, method = "app", totp) {
1065
- return this.api.request({ url: `/api/auth/totp/${username}`, body: ut({
1066
- method,
1067
- totp
1068
- }) });
1069
- }
1070
- }
1071
- class Auth extends PathedEventEmitter {
1023
+ class Auth extends ae {
1072
1024
  constructor(api, opts = {}) {
1073
1025
  super();
1074
1026
  __publicField(this, "api");
1075
1027
  __publicField(this, "storageKey");
1076
- __publicField(this, "totp");
1077
1028
  __publicField(this, "_user");
1029
+ __publicField(this, "enableTotp", this.resetTotp);
1078
1030
  this.opts = opts;
1079
1031
  this.api = typeof api == "string" ? new Api(api) : api;
1080
- this.totp = new Totp(this.api);
1081
1032
  this.opts = {
1082
- loginUi: this.api.url + "/ui/#/login",
1033
+ loginUrl: this.api.url + "/ui/#/login",
1083
1034
  persist: true,
1084
1035
  ...this.opts
1085
1036
  };
@@ -1091,12 +1042,11 @@ class Auth extends PathedEventEmitter {
1091
1042
  "/api/auth/totp"
1092
1043
  ];
1093
1044
  if (resp.status == 401 && !blacklist.find((url) => resp.url.includes(url)))
1094
- this.emit(PES`auth/session-expired:d`, this.api.token);
1045
+ this.emit(xt`auth/session-expired:d`, this.api.token);
1095
1046
  next();
1096
1047
  });
1097
1048
  this.api.on("api/token", (event, token) => {
1098
1049
  var _a;
1099
- console.log("loading user...");
1100
1050
  if ((_a = this.opts) == null ? void 0 : _a.persist) {
1101
1051
  if (token) localStorage.setItem(this.storageKey, token);
1102
1052
  else localStorage.removeItem(this.storageKey);
@@ -1117,9 +1067,9 @@ class Auth extends PathedEventEmitter {
1117
1067
  return this._user;
1118
1068
  }
1119
1069
  set user(user) {
1120
- if (!A(this.user, user)) {
1070
+ if (!$(this.user, user)) {
1121
1071
  this._user = user ? user : null;
1122
- this.emit(PES`auth/user:u`, this._user);
1072
+ this.emit(xt`auth/user:u`, this._user);
1123
1073
  }
1124
1074
  }
1125
1075
  knownHost(host = location.origin) {
@@ -1140,16 +1090,16 @@ class Auth extends PathedEventEmitter {
1140
1090
  }).then(async (resp) => {
1141
1091
  this.api.token = (resp == null ? void 0 : resp.token) || null;
1142
1092
  const user = await this.once("auth/user");
1143
- this.emit(PES`auth/login/${username}:u`, user);
1093
+ this.emit(xt`auth/login/${username}:u`, user);
1144
1094
  return user;
1145
1095
  });
1146
1096
  }
1147
1097
  loginRedirect(host = location.origin) {
1148
1098
  return new Promise((res, rej) => {
1149
1099
  var _a;
1150
- const win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.loginUi}?redirect=postmessage&host=${host}`), "_blank");
1100
+ const win = window.open(encodeURI(`${(_a = this.opts) == null ? void 0 : _a.loginUrl}?redirect=postmessage&host=${host}`), "_blank");
1151
1101
  if (!win) return rej("Unable to open login");
1152
- const origin = new URL(this.opts.loginUi).origin;
1102
+ const origin = new URL(this.opts.loginUrl).origin;
1153
1103
  win.addEventListener("message", (event) => {
1154
1104
  const data = (event == null ? void 0 : event.data) || {};
1155
1105
  if (event.origin != data.sender || data.sender != origin) return;
@@ -1161,7 +1111,7 @@ class Auth extends PathedEventEmitter {
1161
1111
  });
1162
1112
  }
1163
1113
  logout() {
1164
- this.emit(PES`auth/logout:d`, this.user);
1114
+ this.emit(xt`auth/logout:d`, this.user);
1165
1115
  this.api.token = null;
1166
1116
  this.user = null;
1167
1117
  }
@@ -1170,7 +1120,7 @@ class Auth extends PathedEventEmitter {
1170
1120
  if (!u.username || !u.password) throw new Error("Cannot register user, missing username or password");
1171
1121
  const user = await this.api.request({ url: "/api/auth/register", body: { ...u } });
1172
1122
  if ((_a = user == null ? void 0 : user.image) == null ? void 0 : _a.startsWith("/")) user.image = `${this.api.url}${user.image}?token=${this.api.token}`;
1173
- this.emit(PES`auth/register:c`, user);
1123
+ this.emit(xt`auth/register:c`, user);
1174
1124
  return user;
1175
1125
  }
1176
1126
  reset(emailOrPass, token) {
@@ -1183,7 +1133,7 @@ class Auth extends PathedEventEmitter {
1183
1133
  password: token ? emailOrPass : void 0
1184
1134
  }
1185
1135
  }).then(() => {
1186
- this.emit(PES`auth/reset:${token ? "u" : "c"}`, token || emailOrPass);
1136
+ this.emit(xt`auth/reset:${token ? "u" : "c"}`, token || emailOrPass);
1187
1137
  });
1188
1138
  }
1189
1139
  async session(token, set = false) {
@@ -1192,12 +1142,12 @@ class Auth extends PathedEventEmitter {
1192
1142
  url: "/api/auth/session",
1193
1143
  headers: token ? { "Authorization": `Bearer ${token}` } : void 0
1194
1144
  });
1195
- this.emit(PES`auth/session:r`, session);
1145
+ this.emit(xt`auth/session:r`, session);
1196
1146
  if (set) {
1197
1147
  this.api.token = token;
1198
1148
  if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}?token=${this.api.token}`;
1199
1149
  this.user = (session == null ? void 0 : session.user) || null;
1200
- if (session) this.emit(PES`auth/login:c`, session.user);
1150
+ if (session) this.emit(xt`auth/login:c`, session.user);
1201
1151
  }
1202
1152
  return session;
1203
1153
  }
@@ -1207,12 +1157,25 @@ class Auth extends PathedEventEmitter {
1207
1157
  url: "/api/auth/password",
1208
1158
  body: { username, password, oldPassword }
1209
1159
  }).then((resp) => {
1210
- this.emit(PES`auth/reset:u`, resp == null ? void 0 : resp.token);
1160
+ this.emit(xt`auth/reset:u`, resp == null ? void 0 : resp.token);
1211
1161
  if (resp == null ? void 0 : resp.token) this.api.token = resp.token;
1212
1162
  });
1213
1163
  }
1164
+ // TOTP ============================================================================================================
1165
+ disableTotp(username) {
1166
+ return this.api.request({ url: `/api/auth/totp/${username}`, method: "DELETE" });
1167
+ }
1168
+ resetTotp(username) {
1169
+ return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1170
+ }
1171
+ setupTotp(username, method = "app", totp) {
1172
+ return this.api.request({ url: `/api/auth/totp/${username}`, body: lt({
1173
+ method,
1174
+ totp
1175
+ }) });
1176
+ }
1214
1177
  }
1215
- class Client extends PathedEventEmitter {
1178
+ class Client extends ae {
1216
1179
  constructor(settings) {
1217
1180
  super();
1218
1181
  __publicField(this, "_platform");
@@ -1313,7 +1276,7 @@ class Client extends PathedEventEmitter {
1313
1276
  if (!dismissed && !this.pwa && this.mobile) this.pwaPrompt();
1314
1277
  }, 500);
1315
1278
  }
1316
- this.emit(PES`client/inject:c`, this.platform);
1279
+ this.emit(xt`client/inject:c`, this.platform);
1317
1280
  }
1318
1281
  pwaPrompt(platform) {
1319
1282
  const url = this.settings.api.url;
@@ -1430,16 +1393,16 @@ class Client extends PathedEventEmitter {
1430
1393
  setTimeout(() => {
1431
1394
  prompt.remove();
1432
1395
  backdrop.remove();
1433
- this.emit(PES`client/pwa:d`, platform);
1396
+ this.emit(xt`client/pwa:d`, platform);
1434
1397
  }, 500);
1435
1398
  };
1436
1399
  prompt.append(close);
1437
1400
  backdrop.append(prompt);
1438
1401
  document.body.append(backdrop);
1439
- this.emit(PES`client/pwa:c`, platform);
1402
+ this.emit(xt`client/pwa:c`, platform);
1440
1403
  }
1441
1404
  }
1442
- class Data extends PathedEventEmitter {
1405
+ class Data extends ae {
1443
1406
  constructor(api) {
1444
1407
  super();
1445
1408
  __publicField(this, "api");
@@ -1448,18 +1411,25 @@ class Data extends PathedEventEmitter {
1448
1411
  create(collection, document2) {
1449
1412
  if (!collection || !document2) throw new Error("Cannot create document, missing collection or document");
1450
1413
  return this.api.request({
1451
- url: `/api/` + PES`data/${collection}`,
1414
+ url: `/api/` + xt`data/${collection}`,
1452
1415
  method: "POST",
1453
1416
  body: document2
1454
1417
  }).then((resp) => {
1455
- this.emit(PES`data/${collection}:c`, resp);
1418
+ this.emit(xt`data/${collection}:c`, resp);
1456
1419
  return resp;
1457
1420
  });
1458
1421
  }
1422
+ delete(collection, id) {
1423
+ if (!collection || !id) throw new Error("Cannot delete document, missing collection or ID");
1424
+ return this.api.request({
1425
+ url: `/api/` + xt`data/${collection}/${id}`,
1426
+ method: "DELETE"
1427
+ }).then(() => this.emit(xt`data/${collection}/${id}:d`, id));
1428
+ }
1459
1429
  read(collection, id) {
1460
1430
  if (!collection) throw new Error("Cannot read documents, missing collection");
1461
- return this.api.request({ url: `/api/` + PES`data/${collection}/${id}` }).then((resp) => {
1462
- this.emit(PES`data/${collection}/${id}:r`, collection, resp);
1431
+ return this.api.request({ url: `/api/` + xt`data/${collection}/${id}` }).then((resp) => {
1432
+ this.emit(xt`data/${collection}/${id}:r`, collection, resp);
1463
1433
  return resp;
1464
1434
  });
1465
1435
  }
@@ -1467,48 +1437,42 @@ class Data extends PathedEventEmitter {
1467
1437
  if (!collection || !document2) throw new Error("Cannot update document, missing collection or document");
1468
1438
  if (!document2._id) return this.create(collection, document2);
1469
1439
  return this.api.request({
1470
- url: `/api/` + PES`data/${collection}/${document2._id}`,
1440
+ url: `/api/` + xt`data/${collection}/${document2._id}`,
1471
1441
  method: append ? "PATCH" : "PUT",
1472
1442
  body: document2
1473
1443
  }).then((resp) => {
1474
- this.emit(PES`data/${collection}/${document2._id}:u`, resp);
1444
+ this.emit(xt`data/${collection}/${document2._id}:u`, resp);
1475
1445
  return resp;
1476
1446
  });
1477
1447
  }
1478
- delete(collection, id) {
1479
- if (!collection || !id) throw new Error("Cannot delete document, missing collection or ID");
1480
- return this.api.request({
1481
- url: `/api/` + PES`data/${collection}/${id}`,
1482
- method: "DELETE"
1483
- }).then(() => this.emit(PES`data/${collection}/${id}:d`, id));
1484
- }
1485
1448
  raw(collection, query) {
1486
1449
  if (!collection || !query) throw new Error("Cannot execute raw query, missing collection or query");
1487
1450
  const mode = query.operand.startsWith("find") ? "r" : query.operand == "insert" ? "c" : query.operand.startsWith("delete") ? "d" : "u";
1488
- return this.api.request({ url: `/api/` + PES`data/${collection}` + "?raw", body: query }).then((resp) => {
1489
- this.emit(PES`data/${collection}:${mode}`, resp);
1451
+ return this.api.request({ url: `/api/` + xt`data/${collection}` + "?raw", body: query }).then((resp) => {
1452
+ this.emit(xt`data/${collection}:${mode}`, resp);
1490
1453
  return resp;
1491
1454
  });
1492
1455
  }
1456
+ // Schema ==========================================================================================================
1493
1457
  deleteSchema(path) {
1494
1458
  if (!path) throw new Error("Cannot delete schema, missing collection path");
1495
- return this.api.request({ url: `/api/` + PES`schema/${path}`, method: "DELETE" }).then(() => this.emit(PES`schema/${path}:d`, path));
1459
+ return this.api.request({ url: `/api/` + xt`schema/${path}`, method: "DELETE" }).then(() => this.emit(xt`schema/${path}:d`, path));
1496
1460
  }
1497
- getSchema(pathOrTree) {
1498
- return this.api.request({ url: "/api/" + PES`schema/${typeof pathOrTree == "string" ? pathOrTree : ""}` + (pathOrTree === true ? `?tree=${pathOrTree}` : "") }).then((resp) => {
1499
- this.emit(PES`schema/${typeof pathOrTree == "string" ? pathOrTree : ""}:r`, resp);
1461
+ readSchema(pathOrTree) {
1462
+ return this.api.request({ url: "/api/" + xt`schema/${typeof pathOrTree == "string" ? pathOrTree : ""}` + (pathOrTree === true ? `?tree=${pathOrTree}` : "") }).then((resp) => {
1463
+ this.emit(xt`schema/${typeof pathOrTree == "string" ? pathOrTree : ""}:r`, resp);
1500
1464
  return resp;
1501
1465
  });
1502
1466
  }
1503
- setSchema(schema) {
1467
+ updateSchema(schema) {
1504
1468
  if (!schema.path) throw new Error("Cannot update schema, missing collection path");
1505
- return this.api.request({ url: "/api/" + PES`schema/${schema.path}`, body: schema }).then((resp) => {
1506
- this.emit(PES`schema/${schema.path}:${schema._id ? "u" : "c"}`, resp);
1469
+ return this.api.request({ url: "/api/" + xt`schema/${schema.path}`, body: schema }).then((resp) => {
1470
+ this.emit(xt`schema/${schema.path}:${schema._id ? "u" : "c"}`, resp);
1507
1471
  return resp;
1508
1472
  });
1509
1473
  }
1510
1474
  }
1511
- class Email extends PathedEventEmitter {
1475
+ class Email extends ae {
1512
1476
  constructor(api) {
1513
1477
  super();
1514
1478
  __publicField(this, "api");
@@ -1517,92 +1481,126 @@ class Email extends PathedEventEmitter {
1517
1481
  send(email) {
1518
1482
  var _a;
1519
1483
  if (!email.to && !email.bcc || !email.body) throw new Error("Cannot send email, missing address or body");
1520
- return this.api.request({ url: "/api/" + PES`email/${(_a = email.body) == null ? void 0 : _a.template}`, body: email }).then((response) => {
1484
+ return this.api.request({ url: "/api/" + xt`email/${(_a = email.body) == null ? void 0 : _a.template}`, body: email }).then((response) => {
1521
1485
  var _a2;
1522
- this.emit(PES`email/${(_a2 = email.body) == null ? void 0 : _a2.template}:c`, { email, response });
1486
+ this.emit(xt`email/${(_a2 = email.body) == null ? void 0 : _a2.template}:c`, { email, response });
1523
1487
  return response;
1524
1488
  });
1525
1489
  }
1526
1490
  }
1527
- class Groups extends PathedEventEmitter {
1491
+ class Groups extends ae {
1528
1492
  constructor(api) {
1529
1493
  super();
1530
1494
  __publicField(this, "api");
1531
- __publicField(this, "cache", new Dt("name"));
1495
+ __publicField(this, "cache", new Gt("name"));
1532
1496
  this.api = typeof api == "string" ? new Api(api) : api;
1533
1497
  }
1534
1498
  async all(reload) {
1535
1499
  if (!reload && this.cache.complete) return this.cache.all();
1536
- return this.api.request({ url: `/api/` + PES`groups` }).then((resp) => {
1500
+ return this.api.request({ url: `/api/` + xt`groups` }).then((resp) => {
1537
1501
  this.cache.addAll(resp);
1538
- this.emit(PES`groups:r`, resp || []);
1502
+ this.emit(xt`groups:r`, resp || []);
1539
1503
  return resp;
1540
1504
  });
1541
1505
  }
1506
+ delete(name) {
1507
+ if (!name) throw new Error("Cannot delete group, missing name");
1508
+ return this.api.request({
1509
+ url: `/api/` + xt`groups/${name}`,
1510
+ method: "DELETE"
1511
+ }).then(() => {
1512
+ this.cache.delete(name);
1513
+ this.emit(xt`groups/${name}:d`);
1514
+ });
1515
+ }
1542
1516
  create(group) {
1543
1517
  if (!group.name) throw new Error("Cannot create group, missing name");
1544
1518
  return this.api.request({
1545
- url: `/api/` + PES`groups/${group.name}`,
1519
+ url: `/api/` + xt`groups/${group.name}`,
1546
1520
  method: "POST",
1547
1521
  body: group
1548
1522
  }).then((resp) => {
1549
1523
  this.cache.add(resp);
1550
- this.emit(PES`groups/${group.name}:c`, resp);
1524
+ this.emit(xt`groups/${group.name}:c`, resp);
1551
1525
  return resp;
1552
1526
  });
1553
1527
  }
1554
1528
  async read(name, reload) {
1555
1529
  if (!name) throw new Error("Cannot read group, missing name");
1556
1530
  if (!reload && this.cache.get(name)) return this.cache.get(name);
1557
- return this.api.request({ url: `/api/` + PES`groups/${name}` }).then((resp) => {
1531
+ return this.api.request({ url: `/api/` + xt`groups/${name}` }).then((resp) => {
1558
1532
  this.cache.add(resp);
1559
- this.emit(PES`groups/${name}:r`, resp);
1533
+ this.emit(xt`groups/${name}:r`, resp);
1560
1534
  return resp;
1561
1535
  });
1562
1536
  }
1563
1537
  update(group) {
1564
1538
  if (!group.name) throw new Error("Cannot update group, missing name");
1565
1539
  return this.api.request({
1566
- url: `/api/` + PES`groups/${group.name}`,
1540
+ url: `/api/` + xt`groups/${group.name}`,
1567
1541
  method: "PATCH",
1568
1542
  body: group
1569
1543
  }).then((resp) => {
1570
1544
  this.cache.add(resp);
1571
- this.emit(PES`groups/${group.name}:u`, resp);
1545
+ this.emit(xt`groups/${group.name}:u`, resp);
1572
1546
  return resp;
1573
1547
  });
1574
1548
  }
1575
- delete(name) {
1576
- if (!name) throw new Error("Cannot delete group, missing name");
1577
- return this.api.request({
1578
- url: `/api/` + PES`groups/${name}`,
1579
- method: "DELETE"
1580
- }).then(() => {
1581
- this.cache.delete(name);
1582
- this.emit(PES`groups/${name}:d`);
1583
- });
1584
- }
1585
1549
  }
1586
- class Logger extends PathedEventEmitter {
1587
- constructor(api, namespace, logLevel) {
1550
+ class Logger extends ae {
1551
+ constructor(api, channel, logLevel) {
1588
1552
  super();
1589
1553
  __publicField(this, "api");
1590
- this.namespace = namespace;
1554
+ __publicField(this, "console", {
1555
+ debug: console.debug,
1556
+ log: console.log,
1557
+ info: console.info,
1558
+ warn: console.warn,
1559
+ error: console.error
1560
+ });
1561
+ this.channel = channel;
1562
+ if (channel.toLowerCase() == "server") throw new Error('"Server" namespace is reserved');
1591
1563
  this.api = typeof api == "string" ? new Api(api) : api;
1592
- if (logLevel != null && logLevel != "NONE") {
1593
- window.addEventListener("error", (event) => {
1594
- var _a, _b;
1595
- return this.error(((_a = event.error) == null ? void 0 : _a.stack) || ((_b = event.error) == null ? void 0 : _b.message) || event.error);
1596
- });
1597
- window.addEventListener("unhandledrejection", async (event) => {
1598
- var _a, _b, _c, _d;
1599
- let log = ((_a = event.reason) == null ? void 0 : _a.stack) || event.reason;
1600
- if ((_b = event.reason) == null ? void 0 : _b.url)
1601
- log = `${event.reason.method} ${event.reason.url} -> ${event.reason.code}
1564
+ if (logLevel != null && logLevel && logLevel != "NONE") {
1565
+ if (yt[logLevel] >= 0) {
1566
+ console.error = (...args) => {
1567
+ this.console.error(...args);
1568
+ this.error(...args);
1569
+ };
1570
+ window.addEventListener("unhandledrejection", async (event) => {
1571
+ var _a, _b, _c, _d;
1572
+ let log = ((_a = event.reason) == null ? void 0 : _a.stack) || event.reason;
1573
+ if ((_b = event.reason) == null ? void 0 : _b.url)
1574
+ log = `${event.reason.method} ${event.reason.url} -> ${event.reason.code}
1602
1575
 
1603
1576
  ${log}`;
1604
- ((_c = event.reason) == null ? void 0 : _c.code) == null || ((_d = event.reason) == null ? void 0 : _d.code) >= 500 ? this.error(log) : this.warn(log);
1605
- });
1577
+ ((_c = event.reason) == null ? void 0 : _c.code) == null || ((_d = event.reason) == null ? void 0 : _d.code) >= 500 ? this.error(log) : this.warn(log);
1578
+ });
1579
+ }
1580
+ if (yt[logLevel] >= 1) {
1581
+ console.warn = (...args) => {
1582
+ this.console.warn(...args);
1583
+ this.warn(...args);
1584
+ };
1585
+ }
1586
+ if (yt[logLevel] >= 2) {
1587
+ console.info = (...args) => {
1588
+ this.console.info(...args);
1589
+ this.info(...args);
1590
+ };
1591
+ }
1592
+ if (yt[logLevel] >= 3) {
1593
+ console.log = (...args) => {
1594
+ this.console.log(...args);
1595
+ this.log(...args);
1596
+ };
1597
+ }
1598
+ if (yt[logLevel] >= 4) {
1599
+ console.debug = (...args) => {
1600
+ this.console.debug(...args);
1601
+ this.debug(...args);
1602
+ };
1603
+ }
1606
1604
  }
1607
1605
  }
1608
1606
  buildLog(level, log) {
@@ -1618,44 +1616,38 @@ ${log}`;
1618
1616
  }
1619
1617
  };
1620
1618
  }
1621
- createLog(log, namespace = this.namespace) {
1622
- return this.api.request({ url: `/api/` + PES`logs/${namespace}`, body: log }).then(() => this.emit(PES`logs/${namespace}:c`, log)).catch(() => {
1619
+ create(log, channel = this.channel) {
1620
+ if (channel.toLowerCase() == "server") throw new Error('"Server" namespace is reserved');
1621
+ return this.api.request({ url: `/api/` + xt`logs/${channel}`, body: log }).then(() => this.emit(xt`logs/${channel}:c`, log)).catch(() => {
1623
1622
  });
1624
1623
  }
1625
- clearLogs(namespace = this.namespace) {
1626
- return this.api.request({ url: `/api/` + PES`logs/${namespace}`, method: "DELETE" }).then(() => this.emit(PES`logs/${namespace}:d`));
1624
+ delete(channel = this.channel) {
1625
+ return this.api.request({ url: `/api/` + xt`logs/${channel}`, method: "DELETE" }).then(() => this.emit(xt`logs/${channel}:d`));
1627
1626
  }
1628
- clearServerLogs() {
1629
- return this.clearLogs("server");
1630
- }
1631
- getLogs(length, page, namespace = this.namespace) {
1632
- if (!namespace) throw new Error("Cannot get logs, missing namespace");
1633
- const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((v) => !!v).join("&");
1634
- return this.api.request({ url: `/api/` + PES`logs/${namespace}` + (query ? `?${query}` : "") }).then((logs) => {
1635
- this.emit(PES`logs/${namespace}:r`, logs);
1627
+ read(channel = this.channel) {
1628
+ return this.api.request({ url: `/api/` + xt`logs/${channel}` }).then((logs) => {
1629
+ this.emit(xt`logs/${channel}:r`, logs);
1636
1630
  return logs;
1637
1631
  });
1638
1632
  }
1639
- getServerLogs(length, page) {
1640
- return this.getLogs(length, page, "server");
1641
- }
1642
- debug(log, namespace = this.namespace) {
1643
- return this.createLog(this.buildLog(yt.DEBUG, log), namespace);
1633
+ // Console =========================================================================================================
1634
+ debug(log, channel = this.channel) {
1635
+ return this.create(this.buildLog(yt.DEBUG, log), channel);
1644
1636
  }
1645
- log(log, namespace = this.namespace) {
1646
- return this.createLog(this.buildLog(yt.LOG, log), namespace);
1637
+ log(log, channel = this.channel) {
1638
+ return this.create(this.buildLog(yt.LOG, log), channel);
1647
1639
  }
1648
- info(log, namespace = this.namespace) {
1649
- return this.createLog(this.buildLog(yt.INFO, log), namespace);
1640
+ info(log, channel = this.channel) {
1641
+ return this.create(this.buildLog(yt.INFO, log), channel);
1650
1642
  }
1651
- warn(log, namespace = this.namespace) {
1652
- return this.createLog(this.buildLog(yt.WARN, log), namespace);
1643
+ warn(log, channel = this.channel) {
1644
+ return this.create(this.buildLog(yt.WARN, log), channel);
1653
1645
  }
1654
- error(log, namespace = this.namespace) {
1655
- return this.createLog(this.buildLog(yt.ERROR, log), namespace);
1646
+ error(log, channel = this.channel) {
1647
+ return this.create(this.buildLog(yt.ERROR, log), channel);
1656
1648
  }
1657
1649
  }
1658
- class Payments extends PathedEventEmitter {
1650
+ class Payments extends ae {
1659
1651
  constructor(api, secret) {
1660
1652
  super();
1661
1653
  __publicField(this, "api");
@@ -1678,7 +1670,7 @@ class Payments extends PathedEventEmitter {
1678
1670
  amount,
1679
1671
  custom
1680
1672
  } });
1681
- this.emit(PES`payments:c`, request.data.clientSecret);
1673
+ this.emit(xt`payments:c`, request.data.clientSecret);
1682
1674
  return request.data.clientSecret;
1683
1675
  }
1684
1676
  async createForm(element, amount, custom) {
@@ -1692,28 +1684,28 @@ class Payments extends PathedEventEmitter {
1692
1684
  });
1693
1685
  }
1694
1686
  async history(username) {
1695
- const history = await this.api.request({ url: `/api/` + PES`payments/${username}` });
1696
- this.emit(PES`payments/${username}:r`, history);
1687
+ const history = await this.api.request({ url: `/api/` + xt`payments/${username}` });
1688
+ this.emit(xt`payments/${username}:r`, history);
1697
1689
  return history;
1698
1690
  }
1699
1691
  }
1700
- class Pdf extends PathedEventEmitter {
1692
+ class Pdf extends ae {
1701
1693
  constructor(api) {
1702
1694
  super();
1703
1695
  __publicField(this, "api");
1704
1696
  this.api = typeof api == "string" ? new Api(api) : api;
1705
1697
  }
1706
1698
  createPdf(body, options) {
1707
- return this.api.request({ url: `/api/` + PES`pdf`, body: { ...body, options }, decode: false }).then(async (resp) => {
1699
+ return this.api.request({ url: `/api/` + xt`pdf`, body: { ...body, options }, decode: false }).then(async (resp) => {
1708
1700
  const blob = await resp.blob();
1709
1701
  if (options == null ? void 0 : options.download) {
1710
- let filename = (options == null ? void 0 : options.filename) || qt();
1702
+ let filename = (options == null ? void 0 : options.filename) || Yt();
1711
1703
  if (!filename.endsWith(".pdf")) filename += ".pdf";
1712
1704
  const url = URL.createObjectURL(blob);
1713
- dt(url, filename);
1705
+ pt(url, filename);
1714
1706
  URL.revokeObjectURL(url);
1715
1707
  }
1716
- this.emit(PES`pdf:c`, blob);
1708
+ this.emit(xt`pdf:c`, blob);
1717
1709
  return blob;
1718
1710
  });
1719
1711
  }
@@ -1777,7 +1769,7 @@ const _Socket = class _Socket {
1777
1769
  };
1778
1770
  __publicField(_Socket, "timeout", 1e4);
1779
1771
  let Socket = _Socket;
1780
- class Storage extends PathedEventEmitter {
1772
+ class Storage extends ae {
1781
1773
  constructor(api) {
1782
1774
  super();
1783
1775
  __publicField(this, "api");
@@ -1785,119 +1777,119 @@ class Storage extends PathedEventEmitter {
1785
1777
  }
1786
1778
  copy(source, destination) {
1787
1779
  if (!source || !destination) throw new Error("Cannot copy file or folder, missing source or destination");
1788
- return this.api.request({ url: "/api/" + PES`storage/${destination}`, body: { from: source } }).then((response) => {
1789
- this.emit(PES`storage/${destination}:c`, response);
1780
+ return this.api.request({ url: "/api/" + xt`storage/${destination}`, body: { from: source } }).then((response) => {
1781
+ this.emit(xt`storage/${destination}:c`, response);
1790
1782
  return response;
1791
1783
  });
1792
1784
  }
1793
1785
  delete(path) {
1794
1786
  if (!path) throw new Error("Cannot delete file or folder, missing path");
1795
- return this.api.request({ url: "/api/" + PES`storage/${path}`, method: "DELETE" }).then(() => {
1796
- this.emit(PES`storage/${path}:d`, path);
1787
+ return this.api.request({ url: "/api/" + xt`storage/${path}`, method: "DELETE" }).then(() => {
1788
+ this.emit(xt`storage/${path}:d`, path);
1797
1789
  });
1798
1790
  }
1799
1791
  download(path, opts = {}) {
1800
1792
  if (!path) throw new Error("Cannot download file, missing path");
1801
- return this.api.request({ ...opts, url: "/api/" + PES`storage/${path}`, decode: false }).then(async (response) => {
1793
+ return this.api.request({ ...opts, url: "/api/" + xt`storage/${path}`, decode: false }).then(async (response) => {
1802
1794
  const blob = await response.blob();
1803
1795
  const name = opts.downloadAs || path.split("/").pop();
1804
- this.emit(PES`storage/${path}:r`, blob);
1805
- Gt(blob, name);
1796
+ this.emit(xt`storage/${path}:r`, blob);
1797
+ qt(blob, name);
1806
1798
  return response;
1807
1799
  });
1808
1800
  }
1809
1801
  list(path) {
1810
1802
  if (!path) path = "/";
1811
- return this.api.request({ url: "/api/" + PES`storage/${path}` + "?list" }).then((resp) => {
1812
- this.emit(PES`storage/${path}:r`, resp);
1803
+ return this.api.request({ url: "/api/" + xt`storage/${path}` + "?list" }).then((resp) => {
1804
+ this.emit(xt`storage/${path}:r`, resp);
1813
1805
  return resp;
1814
1806
  });
1815
1807
  }
1816
1808
  open(path, target = "_blank") {
1817
1809
  if (!path) throw new Error("Cannot download file, missing path");
1818
- const link = `${this.api.url}/api/` + PES`storage/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
1810
+ const link = `${this.api.url}/api/` + xt`storage/${path}` + (this.api.token ? `?token=${this.api.token}` : "");
1819
1811
  if (!target) return link;
1820
- this.emit(PES`storage/${path}:r`, path);
1812
+ this.emit(xt`storage/${path}:r`, path);
1821
1813
  return window.open(link, target);
1822
1814
  }
1823
1815
  mkdir(path) {
1824
1816
  if (!path) throw new Error("Cannot make directory, missing path");
1825
- return this.api.request({ url: "/api/" + PES`storage/${path}`, body: { directory: true } }).then((resp) => {
1826
- this.emit(PES`storage/${path}:c`, resp);
1817
+ return this.api.request({ url: "/api/" + xt`storage/${path}`, body: { directory: true } }).then((resp) => {
1818
+ this.emit(xt`storage/${path}:c`, resp);
1827
1819
  return resp;
1828
1820
  });
1829
1821
  }
1830
1822
  move(source, destination) {
1831
1823
  if (!source || !destination) throw new Error("Cannot move file or folder, missing source or destination");
1832
1824
  if (source == destination) return this.list(destination);
1833
- return this.api.request({ url: "/api/" + PES`storage/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
1834
- this.emit(PES`storage/${source}:u`, response);
1825
+ return this.api.request({ url: "/api/" + xt`storage/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
1826
+ this.emit(xt`storage/${source}:u`, response);
1835
1827
  return response;
1836
1828
  });
1837
1829
  }
1838
1830
  upload(files, opts) {
1839
- return new E(async (res, rej, prog) => {
1840
- if (!files) files = await Ut(typeof opts == "object" ? opts : void 0);
1831
+ return new O(async (res, rej, prog) => {
1832
+ if (!files) files = await Ft(typeof opts == "object" ? opts : void 0);
1841
1833
  if (!files || Array.isArray(files) && !files.length) return [];
1842
1834
  const path = (opts && typeof opts == "object" ? opts == null ? void 0 : opts.path : opts) || "/";
1843
- return Ft({
1844
- url: `${this.api.url}/api/` + PES`storage/${path}`,
1845
- files: ft(files),
1835
+ return Ht({
1836
+ url: `${this.api.url}/api/` + xt`storage/${path}`,
1837
+ files: b(files),
1846
1838
  headers: this.api.headers
1847
- }).onProgress((p2) => {
1848
- prog(p2);
1839
+ }).onProgress((p) => {
1840
+ prog(p);
1849
1841
  }).then((resp) => {
1850
- this.emit(PES`storage/${path}:c`, resp);
1842
+ this.emit(xt`storage/${path}:c`, resp);
1851
1843
  res(resp);
1852
1844
  }).catch((err) => rej(err));
1853
1845
  });
1854
1846
  }
1855
1847
  }
1856
- class Users extends PathedEventEmitter {
1848
+ class Users extends ae {
1857
1849
  constructor(api) {
1858
1850
  super();
1859
1851
  __publicField(this, "api");
1860
- __publicField(this, "cache", new Dt("username"));
1852
+ __publicField(this, "cache", new Gt("username"));
1861
1853
  this.api = typeof api == "string" ? new Api(api) : api;
1862
1854
  }
1863
1855
  async all(reload) {
1864
1856
  if (!reload && this.cache.complete) return this.cache.all();
1865
- return this.api.request({ url: "/api/" + PES`users` }).then((resp) => {
1857
+ return this.api.request({ url: "/api/" + xt`users` }).then((resp) => {
1866
1858
  resp == null ? void 0 : resp.forEach((r) => {
1867
1859
  r.image = this.api.url + r.image + `?token=${this.api.token}`;
1868
1860
  return r;
1869
1861
  });
1870
1862
  this.cache.addAll(resp);
1871
- this.emit(PES`users:r`, resp || []);
1863
+ this.emit(xt`users:r`, resp || []);
1872
1864
  return resp;
1873
1865
  });
1874
1866
  }
1875
1867
  delete(username) {
1876
1868
  if (!username) throw new Error("Cannot delete user, missing username");
1877
1869
  return this.api.request({
1878
- url: "/api/" + PES`users/${username}`,
1870
+ url: "/api/" + xt`users/${username}`,
1879
1871
  method: "DELETE"
1880
1872
  }).then(() => {
1881
1873
  this.cache.delete(username);
1882
- this.emit(PES`users/${username}:d`, username);
1874
+ this.emit(xt`users/${username}:d`, username);
1883
1875
  });
1884
1876
  }
1885
1877
  async read(username, reload) {
1886
1878
  if (!username) throw new Error("Cannot read user, missing username");
1887
1879
  if (!reload && this.cache.get(username)) return this.cache.get(username);
1888
- return this.api.request({ url: "/api/" + PES`users/${username}` }).then((resp) => {
1880
+ return this.api.request({ url: "/api/" + xt`users/${username}` }).then((resp) => {
1889
1881
  if (resp) {
1890
1882
  resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
1891
1883
  this.cache.add(resp);
1892
1884
  }
1893
- this.emit(PES`users/${username}:r`, resp);
1885
+ this.emit(xt`users/${username}:r`, resp);
1894
1886
  return resp;
1895
1887
  });
1896
1888
  }
1897
1889
  update(user) {
1898
1890
  if (!user.username) throw new Error("Cannot update user, missing username");
1899
1891
  return this.api.request({
1900
- url: `/api/` + PES`users/${user.username}`,
1892
+ url: `/api/` + xt`users/${user.username}`,
1901
1893
  method: "PATCH",
1902
1894
  body: user
1903
1895
  }).then((resp) => {
@@ -1905,60 +1897,60 @@ class Users extends PathedEventEmitter {
1905
1897
  resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
1906
1898
  this.cache.add(resp);
1907
1899
  }
1908
- this.emit(PES`users/${user.username}:${resp._id ? "u" : "c"}`, resp);
1900
+ this.emit(xt`users/${user.username}:${resp._id ? "u" : "c"}`, resp);
1909
1901
  return resp;
1910
1902
  });
1911
1903
  }
1912
1904
  uploadImage(username, file) {
1913
1905
  if (!username || !file) throw new Error("Cannot update user image, missing username or file");
1914
- return Ft({
1915
- url: this.api.url + `/api/` + PES`users/${username}/image`,
1906
+ return Ht({
1907
+ url: this.api.url + `/api/` + xt`users/${username}/image`,
1916
1908
  files: [file],
1917
1909
  headers: this.api.headers
1918
1910
  });
1919
1911
  }
1920
1912
  }
1921
- class Settings extends PathedEventEmitter {
1913
+ class Settings extends ae {
1922
1914
  constructor(api) {
1923
1915
  super();
1924
1916
  __publicField(this, "api");
1925
- __publicField(this, "cache", new Dt());
1917
+ __publicField(this, "cache", new Gt());
1926
1918
  this.api = typeof api == "string" ? new Api(api) : api;
1927
1919
  }
1928
1920
  async all(detailed = false, reload) {
1929
1921
  if (!reload && !detailed && this.cache.complete) return this.cache;
1930
- return this.api.request({ url: `/api/` + PES`settings` + (detailed ? "?detailed" : "") }).then((resp) => {
1922
+ return this.api.request({ url: `/api/` + xt`settings` + (detailed ? "?detailed" : "") }).then((resp) => {
1931
1923
  if (resp) Object.keys(resp).forEach((key) => this.cache.set(key, detailed ? resp[key].value : resp[key]));
1932
- this.emit(PES`settings:r`, resp || []);
1924
+ this.emit(xt`settings:r`, resp || []);
1933
1925
  return resp;
1934
1926
  });
1935
1927
  }
1936
1928
  delete(key) {
1937
1929
  if (!key) throw new Error("Cannot delete setting, missing key");
1938
- return this.api.request({ url: `/api/` + PES`settings/${key}`, method: "DELETE" }).then(() => {
1930
+ return this.api.request({ url: `/api/` + xt`settings/${key}`, method: "DELETE" }).then(() => {
1939
1931
  this.cache.delete(key);
1940
- this.emit(PES`settings/${key}:d`, key);
1932
+ this.emit(xt`settings/${key}:d`, key);
1941
1933
  });
1942
1934
  }
1943
1935
  read(key, reload = false) {
1944
1936
  if (!key) throw new Error("Cannot read setting, missing key");
1945
1937
  if (!reload && this.cache.get(key)) return this.cache.get(key);
1946
- return this.api.request({ url: `/api/` + PES`settings/${key}` }).then((variable) => {
1938
+ return this.api.request({ url: `/api/` + xt`settings/${key}` }).then((variable) => {
1947
1939
  if (variable) this.cache.set(variable.key, variable.value);
1948
- this.emit(PES`settings/${key}:r`, variable);
1940
+ this.emit(xt`settings/${key}:r`, variable);
1949
1941
  return variable;
1950
1942
  });
1951
1943
  }
1952
1944
  update(variable) {
1953
1945
  if (!variable.key) throw new Error("Cannot update setting, missing key");
1954
- return this.api.request({ url: `/api/` + PES`settings/${variable.key}`, body: variable }).then((variable2) => {
1946
+ return this.api.request({ url: `/api/` + xt`settings/${variable.key}`, body: variable }).then((variable2) => {
1955
1947
  if (variable2) this.cache.set(variable2.key, variable2.value);
1956
- this.emit(`/api/` + PES`settings/${variable2.key}:${variable2._id ? "u" : "c"}`, variable2);
1948
+ this.emit(`/api/` + xt`settings/${variable2.key}:${variable2._id ? "u" : "c"}`, variable2);
1957
1949
  return variable2;
1958
1950
  });
1959
1951
  }
1960
1952
  }
1961
- class Static extends PathedEventEmitter {
1953
+ class Static extends ae {
1962
1954
  constructor(api) {
1963
1955
  super();
1964
1956
  __publicField(this, "api");
@@ -1966,27 +1958,27 @@ class Static extends PathedEventEmitter {
1966
1958
  }
1967
1959
  delete(path) {
1968
1960
  if (!path) throw new Error("Cannot delete static asset, missing path");
1969
- return this.api.request({ url: `/api/` + PES`static/${path}`, method: "DELETE" }).then(() => {
1970
- this.emit(PES`static/${path}:d`, path);
1961
+ return this.api.request({ url: `/api/` + xt`static/${path}`, method: "DELETE" }).then(() => {
1962
+ this.emit(xt`static/${path}:d`, path);
1971
1963
  });
1972
1964
  }
1973
1965
  upload(files, path = "/") {
1974
1966
  if (!files) throw new Error("Cannot upload static assets, missing file");
1975
- return new E(async (res, rej, prog) => {
1976
- return Ft({
1977
- url: this.api.url + "/api/" + PES`static/${path}`,
1978
- files: ft(files),
1967
+ return new O(async (res, rej, prog) => {
1968
+ return Ht({
1969
+ url: this.api.url + "/api/" + xt`static/${path}`,
1970
+ files: b(files),
1979
1971
  headers: this.api.headers
1980
- }).onProgress((p2) => {
1981
- prog(p2);
1972
+ }).onProgress((p) => {
1973
+ prog(p);
1982
1974
  }).then((resp) => {
1983
- this.emit(PES`static/${path}:c`, resp);
1975
+ this.emit(xt`static/${path}:c`, resp);
1984
1976
  res(resp);
1985
1977
  }).catch((err) => rej(err));
1986
1978
  });
1987
1979
  }
1988
1980
  }
1989
- class Momentum extends PathedEventEmitter {
1981
+ class Momentum extends ae {
1990
1982
  constructor(url, opts) {
1991
1983
  super();
1992
1984
  __publicField(this, "api");
@@ -2012,12 +2004,12 @@ class Momentum extends PathedEventEmitter {
2012
2004
  this.analytics = new Analytics(this.api);
2013
2005
  this.auth = new Auth(this.api, {
2014
2006
  persist: (opts == null ? void 0 : opts.persist) ?? true,
2015
- loginUi: opts == null ? void 0 : opts.loginUi
2007
+ loginUrl: opts == null ? void 0 : opts.loginUrl
2016
2008
  });
2017
2009
  this.data = new Data(this.api);
2018
2010
  this.email = new Email(this.api);
2019
2011
  this.groups = new Groups(this.api);
2020
- this.logger = new Logger(this.api, "client", opts == null ? void 0 : opts.logLevel);
2012
+ this.logger = new Logger(this.api, (opts == null ? void 0 : opts.app) || "client", opts == null ? void 0 : opts.logLevel);
2021
2013
  if (opts == null ? void 0 : opts.stripeSecret) this.payments = new Payments(this.api, opts.stripeSecret);
2022
2014
  this.pdf = new Pdf(this.api);
2023
2015
  this.settings = new Settings(this.api);
@@ -2062,16 +2054,15 @@ export {
2062
2054
  Groups,
2063
2055
  Logger,
2064
2056
  Momentum,
2065
- PE,
2066
- PES,
2067
- PathEvent,
2068
- PathedEventEmitter,
2057
+ ue as PE,
2058
+ xt as PES,
2059
+ y as PathEvent,
2060
+ ae as PathEventEmitter,
2069
2061
  Payments,
2070
2062
  Pdf,
2071
2063
  Settings,
2072
2064
  Socket,
2073
2065
  Static,
2074
2066
  Storage,
2075
- Totp,
2076
2067
  Users
2077
2068
  };