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