@ztimson/momentum 0.45.0 → 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,206 +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
- const 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
- let colon = false;
762
- const [paths, methods] = combined.filter((p2) => p2 != null).flatMap((p2) => {
763
- var _a;
764
- return (_a = p2 == null ? void 0 : p2.toString()) == null ? void 0 : _a.split(":");
765
- }).reduce((acc, p2) => {
766
- if (p2.endsWith(":")) {
767
- colon = true;
768
- if (p2.length > 1) acc[0].push(p2.slice(0, -1));
769
- } else {
770
- acc[colon ? 1 : 0].push(p2);
771
- }
772
- return acc;
773
- }, [[], []]);
774
- return PathEvent.toString(paths, methods);
775
- }
776
- class PathEvent {
777
- constructor(pathedEvent) {
778
- /** First directory in path */
779
- __publicField(this, "module");
780
- /** Entire path, including the module & name */
781
- __publicField(this, "fullPath");
782
- /** Path including the name, excluding the module */
783
- __publicField(this, "path");
784
- /** Last sagment of path */
785
- __publicField(this, "name");
786
- /** List of methods */
787
- __publicField(this, "methods");
788
- /** All/Wildcard specified */
789
- __publicField(this, "all");
790
- /** None specified */
791
- __publicField(this, "none");
792
- /** Create method specified */
793
- __publicField(this, "create");
794
- /** Read method specified */
795
- __publicField(this, "read");
796
- /** Update method specified */
797
- __publicField(this, "update");
798
- /** Delete method specified */
799
- __publicField(this, "delete");
800
- var _a;
801
- if (typeof pathedEvent == "object") return Object.assign(this, pathedEvent);
802
- let [p2, scope, method] = pathedEvent.split(":");
803
- if (!method) method = scope || "*";
804
- if (p2 == "*" || !p2 && method == "*") {
805
- p2 = "";
806
- method = "*";
807
- }
808
- let temp = p2.split("/").filter((p22) => !!p22);
809
- this.module = ((_a = temp.splice(0, 1)[0]) == null ? void 0 : _a.toLowerCase()) || "";
810
- this.fullPath = p2;
811
- this.path = temp.join("/");
812
- this.name = temp.pop() || "";
813
- this.methods = method.split("");
814
- this.all = method == null ? void 0 : method.includes("*");
815
- this.none = method == null ? void 0 : method.includes("n");
816
- 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")));
817
- this.read = !(method == null ? void 0 : method.includes("n")) && ((method == null ? void 0 : method.includes("*")) || (method == null ? void 0 : method.includes("r")));
818
- 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")));
819
- 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")));
820
- }
821
- /**
822
- * Combine multiple pathed events into one parsed object. Longest path takes precedent, but all subsequent methods are
823
- * combined until a "none" is reached
824
- *
825
- * @param {string | PathEvent} paths PathedEvents as strings or pre-parsed
826
- * @return {PathEvent} Final combined permission
827
- */
828
- static combine(paths) {
829
- let hitNone = false;
830
- const combined = paths.map((p2) => new PathEvent(p2)).toSorted((p1, p2) => {
831
- const l1 = p1.fullPath.length, l2 = p2.fullPath.length;
832
- return l1 < l2 ? 1 : l1 > l2 ? -1 : 0;
833
- }).reduce((acc, p2) => {
834
- if (p2.none) hitNone = true;
835
- if (!acc) return p2;
836
- if (hitNone) return acc;
837
- if (p2.all) acc.all = true;
838
- if (p2.all || p2.create) acc.create = true;
839
- if (p2.all || p2.read) acc.read = true;
840
- if (p2.all || p2.update) acc.update = true;
841
- if (p2.all || p2.delete) acc.delete = true;
842
- acc.methods = [...acc.methods, ...p2.methods];
843
- return acc;
844
- }, null);
845
- if (combined.all) combined.methods = ["*"];
846
- if (combined.none) combined.methods = ["n"];
847
- combined.methods = new B(combined.methods);
848
- combined.raw = PES`${combined.fullPath}:${combined.methods}`;
849
- return combined;
850
- }
851
- /**
852
- * Squash 2 sets of paths & return true if any overlap is found
853
- *
854
- * @param {string | PathEvent | (string | PathEvent)[]} target Array of PathedEvents as strings or pre-parsed
855
- * @param has
856
- * @return {boolean} Whether there is any overlap
857
- */
858
- static has(target, ...has) {
859
- const parsedRequired = ft(has).map((pe) => new PathEvent(pe));
860
- const parsedTarget = ft(target).map((pe) => new PathEvent(pe));
861
- return !!parsedRequired.find((r) => {
862
- if (!r.fullPath && r.all) return true;
863
- const filtered = parsedTarget.filter((p2) => r.fullPath.startsWith(p2.fullPath));
864
- if (!filtered.length) return false;
865
- const combined = PathEvent.combine(filtered);
866
- return !combined.none && (combined.all || new B(combined.methods).intersection(new B(r.methods)).length);
867
- });
868
- }
869
- /**
870
- * Same as `has` but raises an error if there is no overlap
871
- *
872
- * @param {string | string[]} target Array of PathedEvents as strings or pre-parsed
873
- * @param has
874
- */
875
- static hasFatal(target, ...has) {
876
- if (!PathEvent.has(target, ...has)) throw new Error(`Missing permission: ${ft(has).join(", ")}`);
877
- }
878
- /**
879
- * Create pathed event string from its components
880
- *
881
- * @param {string | string[]} path Event path
882
- * @param {Method} methods Event method
883
- * @return {string} String representation of PathedEvent
884
- */
885
- static toString(path, methods) {
886
- let p2 = ft(path).filter((p22) => p22 != null).join("/");
887
- if (methods.length) p2 += `:${ft(methods).map((m) => m.toLowerCase()).join("")}`;
888
- return p2 == null ? void 0 : p2.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
889
- }
890
- /**
891
- * Create pathed event string from its components
892
- *
893
- * @return {string} String representation of PathedEvent
894
- */
895
- toString() {
896
- return PathEvent.toString(this.fullPath, this.methods);
897
- }
898
- }
899
- class PathedEventEmitter {
900
- constructor() {
901
- __publicField(this, "listeners", []);
902
- }
903
- emit(event, ...args) {
904
- const parsed = new PathEvent(event);
905
- this.listeners.filter((l) => PathEvent.has(l[0], event)).forEach((l) => l[1](parsed, ...args));
906
- }
907
- off(listener) {
908
- this.listeners = this.listeners.filter((l) => l[1] != listener);
909
- }
910
- on(event, listener) {
911
- ft(event).forEach((e) => this.listeners.push([new PathEvent(e), listener]));
912
- return () => this.off(listener);
913
- }
914
- once(event, listener) {
915
- return new Promise((res) => {
916
- const unsubscribe = this.on(event, (event2, ...args) => {
917
- res(args.length < 2 ? args[0] : args);
918
- if (listener) listener(event2, ...args);
919
- unsubscribe();
920
- });
921
- });
922
- }
923
- relayEvents(emitter) {
924
- emitter.on("*", (event, ...args) => this.emit(event, ...args));
925
- }
926
- }
927
- class Api extends F {
883
+ Object.defineProperty(n, "__esModule", { value: true }), e(B, n), e(I, n);
884
+ })(At);
885
+ class Api extends H {
928
886
  constructor(url = location.origin, opts = {}) {
929
887
  opts.url = url;
930
888
  super(opts);
931
- __publicField(this, "emitter", new PathedEventEmitter());
889
+ __publicField(this, "emitter", new ae());
932
890
  __publicField(this, "pending", {});
933
891
  __publicField(this, "_token", null);
934
892
  __publicField(this, "emit", this.emitter.emit.bind(this.emitter));
@@ -946,27 +904,27 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
946
904
  if (token == this._token) return;
947
905
  this._token = token;
948
906
  this.headers["Authorization"] = token ? `Bearer ${token}` : null;
949
- this.emit(PES`api/token:${token ? "u" : "d"}`, token);
907
+ this.emit(xt`api/token:${token ? "u" : "d"}`, token);
950
908
  }
951
909
  healthcheck() {
952
910
  return this.request({ url: "/api/healthcheck" }).then((resp) => {
953
- this.emit(PES`api/healthcheck:r`, resp);
911
+ this.emit(xt`api/healthcheck:r`, resp);
954
912
  return resp;
955
913
  });
956
914
  }
957
915
  request(options) {
958
- const key = Lt(options);
916
+ const key = It(options);
959
917
  const method = options.method == "GET" ? "r" : options.method == "POST" ? "c" : options.method == "DELETE" ? "d" : "u";
960
918
  if (this.pending[key] != null) return this.pending[key];
961
919
  this.pending[key] = super.request(options).then((response) => {
962
- this.emit(PES`api/response:${method}`, { request: options, response });
920
+ this.emit(xt`api/response:${method}`, { request: options, response });
963
921
  return response.data;
964
922
  }).catch((err) => {
965
923
  const e = (err == null ? void 0 : err.data) || err;
966
- this.emit(PES`api/error:${method}`, { request: options, error: e });
924
+ this.emit(xt`api/error:${method}`, { request: options, error: e });
967
925
  throw e;
968
926
  }).finally(() => delete this.pending[key]);
969
- 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] });
970
928
  return this.pending[key];
971
929
  }
972
930
  }
@@ -980,59 +938,59 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
980
938
  ActionType2[ActionType2["PUT"] = 6] = "PUT";
981
939
  return ActionType2;
982
940
  })(ActionType || {});
983
- class Actions extends PathedEventEmitter {
941
+ class Actions extends ae {
984
942
  constructor(api) {
985
943
  super();
986
944
  __publicField(this, "api");
987
- __publicField(this, "cache", new Dt("_id"));
945
+ __publicField(this, "cache", new Gt("_id"));
988
946
  this.api = typeof api == "string" ? new Api(api) : api;
989
947
  }
990
- delete(id) {
991
- if (!id) throw new Error("Cannot delete action, missing ID");
992
- return this.api.request({ url: `/api/` + PES`actions/${id}`, method: "DELETE" }).then(() => {
993
- this.cache.delete(id);
994
- this.emit(PES`actions/${id}:d`, id);
995
- });
996
- }
997
948
  all() {
998
- return this.api.request({ url: `/api/` + PES`actions` }).then((resp) => {
949
+ return this.api.request({ url: `/api/` + xt`actions` }).then((resp) => {
999
950
  this.cache.addAll(resp);
1000
- this.emit(PES`actions:r`, resp || []);
951
+ this.emit(xt`actions:r`, resp || []);
1001
952
  return resp;
1002
953
  });
1003
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
+ }
1004
962
  read(id, reload = false) {
1005
963
  if (!id) throw new Error("Cannot read action, missing ID");
1006
964
  const cached = this.cache.get(id);
1007
965
  if (!reload && cached) return Promise.resolve(cached);
1008
- return this.api.request({ url: `/api/` + PES`actions/${id}` }).then((action) => {
966
+ return this.api.request({ url: `/api/` + xt`actions/${id}` }).then((action) => {
1009
967
  if (action) this.cache.add(action);
1010
- this.emit(PES`actions/${id}:r`, action);
968
+ this.emit(xt`actions/${id}:r`, action);
1011
969
  return action;
1012
970
  });
1013
971
  }
1014
972
  run(path, opts = {}) {
1015
973
  if (!path) throw new Error("Cannot run action, missing path");
1016
- return this.api.request({ url: `/api/` + PES`actions/run/${path}`, ...opts });
974
+ return this.api.request({ url: `/api/` + xt`actions/run/${path}`, ...opts });
1017
975
  }
1018
976
  runById(action, opts = {}) {
1019
977
  const id = typeof action == "string" ? action : action == null ? void 0 : action._id;
1020
978
  if (!id) throw new Error("Cannot run action, missing ID");
1021
- 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 });
1022
980
  }
1023
981
  update(action) {
1024
982
  return this.api.request({
1025
- url: `/api/` + PES`actions/${action._id}`,
983
+ url: `/api/` + xt`actions/${action._id}`,
1026
984
  method: "POST",
1027
985
  body: action
1028
986
  }).then((action2) => {
1029
987
  if (action2) this.cache.add(action2);
1030
- this.emit(PES`actions/${action2._id}:u`, action2);
988
+ this.emit(xt`actions/${action2._id}:u`, action2);
1031
989
  return action2;
1032
990
  });
1033
991
  }
1034
992
  }
1035
- class Ai extends PathedEventEmitter {
993
+ class Ai extends ae {
1036
994
  constructor(api) {
1037
995
  super();
1038
996
  __publicField(this, "api");
@@ -1040,19 +998,19 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1040
998
  }
1041
999
  ask(question, context) {
1042
1000
  if (!question) throw new Error("Cannot ask AI, missing question");
1043
- return this.api.request({ url: `/api/` + PES`ai`, method: "POST", body: {
1001
+ return this.api.request({ url: `/api/` + xt`ai`, method: "POST", body: {
1044
1002
  question,
1045
1003
  context
1046
1004
  } }).then((response) => {
1047
- this.emit(PES`ai:c`, { question, context, response });
1005
+ this.emit(xt`ai:c`, { question, context, response });
1048
1006
  return response;
1049
1007
  });
1050
1008
  }
1051
1009
  clear() {
1052
- 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));
1053
1011
  }
1054
1012
  }
1055
- class Analytics extends PathedEventEmitter {
1013
+ class Analytics extends ae {
1056
1014
  constructor(api) {
1057
1015
  super();
1058
1016
  __publicField(this, "api");
@@ -1060,42 +1018,23 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1060
1018
  }
1061
1019
  ipTrace(ip) {
1062
1020
  if (!ip) throw new Error("Cannot trace, missing IP");
1063
- return this.api.request({ url: `/api/` + PES`analytics/trace/${ip}` }).then((resp) => {
1064
- 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);
1065
1023
  return resp;
1066
1024
  });
1067
1025
  }
1068
1026
  }
1069
- class Totp {
1070
- constructor(api) {
1071
- __publicField(this, "enable", this.reset);
1072
- this.api = api;
1073
- }
1074
- disable(username) {
1075
- return this.api.request({ url: `/api/auth/totp/${username}`, method: "DELETE" });
1076
- }
1077
- reset(username) {
1078
- return this.api.request({ url: `/api/auth/totp/${username}`, method: "POST" });
1079
- }
1080
- setup(username, method = "app", totp) {
1081
- return this.api.request({ url: `/api/auth/totp/${username}`, body: ut({
1082
- method,
1083
- totp
1084
- }) });
1085
- }
1086
- }
1087
- class Auth extends PathedEventEmitter {
1027
+ class Auth extends ae {
1088
1028
  constructor(api, opts = {}) {
1089
1029
  super();
1090
1030
  __publicField(this, "api");
1091
1031
  __publicField(this, "storageKey");
1092
- __publicField(this, "totp");
1093
1032
  __publicField(this, "_user");
1033
+ __publicField(this, "enableTotp", this.resetTotp);
1094
1034
  this.opts = opts;
1095
1035
  this.api = typeof api == "string" ? new Api(api) : api;
1096
- this.totp = new Totp(this.api);
1097
1036
  this.opts = {
1098
- loginUi: this.api.url + "/ui/#/login",
1037
+ loginUrl: this.api.url + "/ui/#/login",
1099
1038
  persist: true,
1100
1039
  ...this.opts
1101
1040
  };
@@ -1107,12 +1046,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1107
1046
  "/api/auth/totp"
1108
1047
  ];
1109
1048
  if (resp.status == 401 && !blacklist.find((url) => resp.url.includes(url)))
1110
- this.emit(PES`auth/session-expired:d`, this.api.token);
1049
+ this.emit(xt`auth/session-expired:d`, this.api.token);
1111
1050
  next();
1112
1051
  });
1113
1052
  this.api.on("api/token", (event, token) => {
1114
1053
  var _a;
1115
- console.log("loading user...");
1116
1054
  if ((_a = this.opts) == null ? void 0 : _a.persist) {
1117
1055
  if (token) localStorage.setItem(this.storageKey, token);
1118
1056
  else localStorage.removeItem(this.storageKey);
@@ -1133,17 +1071,14 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1133
1071
  return this._user;
1134
1072
  }
1135
1073
  set user(user) {
1136
- if (!A(this.user, user)) {
1074
+ if (!$(this.user, user)) {
1137
1075
  this._user = user ? user : null;
1138
- this.emit(PES`auth/user:u`, this._user);
1076
+ this.emit(xt`auth/user:u`, this._user);
1139
1077
  }
1140
1078
  }
1141
1079
  knownHost(host = location.origin) {
1142
1080
  if (host.startsWith("/")) return Promise.resolve();
1143
- return this.api.request({ url: `/api/auth/known-host?host=${encodeURI(new URL(host).origin)}` }).then(() => this.emit(PES`auth/known-host/${host}:r`, true)).catch((err) => {
1144
- this.emit(PES`auth/known-host/${host}:r`, false);
1145
- throw err;
1146
- });
1081
+ return this.api.request({ url: `/api/auth/known-host?host=${encodeURI(new URL(host).origin)}` });
1147
1082
  }
1148
1083
  login(username, password, totp) {
1149
1084
  if (!username || !password) throw new Error("Cannot login, missing username or password");
@@ -1159,16 +1094,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1159
1094
  }).then(async (resp) => {
1160
1095
  this.api.token = (resp == null ? void 0 : resp.token) || null;
1161
1096
  const user = await this.once("auth/user");
1162
- this.emit(PES`auth/login/${username}:u`, user);
1097
+ this.emit(xt`auth/login/${username}:u`, user);
1163
1098
  return user;
1164
1099
  });
1165
1100
  }
1166
1101
  loginRedirect(host = location.origin) {
1167
1102
  return new Promise((res, rej) => {
1168
1103
  var _a;
1169
- 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");
1170
1105
  if (!win) return rej("Unable to open login");
1171
- const origin = new URL(this.opts.loginUi).origin;
1106
+ const origin = new URL(this.opts.loginUrl).origin;
1172
1107
  win.addEventListener("message", (event) => {
1173
1108
  const data = (event == null ? void 0 : event.data) || {};
1174
1109
  if (event.origin != data.sender || data.sender != origin) return;
@@ -1180,7 +1115,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1180
1115
  });
1181
1116
  }
1182
1117
  logout() {
1183
- this.emit(PES`auth/logout:d`, this.user);
1118
+ this.emit(xt`auth/logout:d`, this.user);
1184
1119
  this.api.token = null;
1185
1120
  this.user = null;
1186
1121
  }
@@ -1189,7 +1124,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1189
1124
  if (!u.username || !u.password) throw new Error("Cannot register user, missing username or password");
1190
1125
  const user = await this.api.request({ url: "/api/auth/register", body: { ...u } });
1191
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}`;
1192
- this.emit(PES`auth/register:c`, user);
1127
+ this.emit(xt`auth/register:c`, user);
1193
1128
  return user;
1194
1129
  }
1195
1130
  reset(emailOrPass, token) {
@@ -1202,7 +1137,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1202
1137
  password: token ? emailOrPass : void 0
1203
1138
  }
1204
1139
  }).then(() => {
1205
- this.emit(PES`auth/reset:${token ? "u" : "c"}`, token || emailOrPass);
1140
+ this.emit(xt`auth/reset:${token ? "u" : "c"}`, token || emailOrPass);
1206
1141
  });
1207
1142
  }
1208
1143
  async session(token, set = false) {
@@ -1211,12 +1146,12 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1211
1146
  url: "/api/auth/session",
1212
1147
  headers: token ? { "Authorization": `Bearer ${token}` } : void 0
1213
1148
  });
1214
- this.emit(PES`auth/session:r`, session);
1149
+ this.emit(xt`auth/session:r`, session);
1215
1150
  if (set) {
1216
1151
  this.api.token = token;
1217
1152
  if (session == null ? void 0 : session.user) session.user.image = `${this.api.url}${session.user.image}?token=${this.api.token}`;
1218
1153
  this.user = (session == null ? void 0 : session.user) || null;
1219
- if (session) this.emit(PES`auth/login:c`, session.user);
1154
+ if (session) this.emit(xt`auth/login:c`, session.user);
1220
1155
  }
1221
1156
  return session;
1222
1157
  }
@@ -1226,12 +1161,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1226
1161
  url: "/api/auth/password",
1227
1162
  body: { username, password, oldPassword }
1228
1163
  }).then((resp) => {
1229
- 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);
1230
1165
  if (resp == null ? void 0 : resp.token) this.api.token = resp.token;
1231
1166
  });
1232
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
+ }
1233
1181
  }
1234
- class Client extends PathedEventEmitter {
1182
+ class Client extends ae {
1235
1183
  constructor(settings) {
1236
1184
  super();
1237
1185
  __publicField(this, "_platform");
@@ -1332,7 +1280,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1332
1280
  if (!dismissed && !this.pwa && this.mobile) this.pwaPrompt();
1333
1281
  }, 500);
1334
1282
  }
1335
- this.emit(PES`client/inject:c`, this.platform);
1283
+ this.emit(xt`client/inject:c`, this.platform);
1336
1284
  }
1337
1285
  pwaPrompt(platform) {
1338
1286
  const url = this.settings.api.url;
@@ -1449,16 +1397,16 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1449
1397
  setTimeout(() => {
1450
1398
  prompt.remove();
1451
1399
  backdrop.remove();
1452
- this.emit(PES`client/pwa:d`, platform);
1400
+ this.emit(xt`client/pwa:d`, platform);
1453
1401
  }, 500);
1454
1402
  };
1455
1403
  prompt.append(close);
1456
1404
  backdrop.append(prompt);
1457
1405
  document.body.append(backdrop);
1458
- this.emit(PES`client/pwa:c`, platform);
1406
+ this.emit(xt`client/pwa:c`, platform);
1459
1407
  }
1460
1408
  }
1461
- class Data extends PathedEventEmitter {
1409
+ class Data extends ae {
1462
1410
  constructor(api) {
1463
1411
  super();
1464
1412
  __publicField(this, "api");
@@ -1467,18 +1415,25 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1467
1415
  create(collection, document2) {
1468
1416
  if (!collection || !document2) throw new Error("Cannot create document, missing collection or document");
1469
1417
  return this.api.request({
1470
- url: `/api/` + PES`data/${collection}`,
1418
+ url: `/api/` + xt`data/${collection}`,
1471
1419
  method: "POST",
1472
1420
  body: document2
1473
1421
  }).then((resp) => {
1474
- this.emit(PES`data/${collection}:c`, resp);
1422
+ this.emit(xt`data/${collection}:c`, resp);
1475
1423
  return resp;
1476
1424
  });
1477
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
+ }
1478
1433
  read(collection, id) {
1479
1434
  if (!collection) throw new Error("Cannot read documents, missing collection");
1480
- return this.api.request({ url: `/api/` + PES`data/${collection}/${id}` }).then((resp) => {
1481
- 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);
1482
1437
  return resp;
1483
1438
  });
1484
1439
  }
@@ -1486,48 +1441,42 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1486
1441
  if (!collection || !document2) throw new Error("Cannot update document, missing collection or document");
1487
1442
  if (!document2._id) return this.create(collection, document2);
1488
1443
  return this.api.request({
1489
- url: `/api/` + PES`data/${collection}/${document2._id}`,
1444
+ url: `/api/` + xt`data/${collection}/${document2._id}`,
1490
1445
  method: append ? "PATCH" : "PUT",
1491
1446
  body: document2
1492
1447
  }).then((resp) => {
1493
- this.emit(PES`data/${collection}/${document2._id}:u`, resp);
1448
+ this.emit(xt`data/${collection}/${document2._id}:u`, resp);
1494
1449
  return resp;
1495
1450
  });
1496
1451
  }
1497
- delete(collection, id) {
1498
- if (!collection || !id) throw new Error("Cannot delete document, missing collection or ID");
1499
- return this.api.request({
1500
- url: `/api/` + PES`data/${collection}/${id}`,
1501
- method: "DELETE"
1502
- }).then(() => this.emit(PES`data/${collection}/${id}:d`, id));
1503
- }
1504
1452
  raw(collection, query) {
1505
1453
  if (!collection || !query) throw new Error("Cannot execute raw query, missing collection or query");
1506
1454
  const mode = query.operand.startsWith("find") ? "r" : query.operand == "insert" ? "c" : query.operand.startsWith("delete") ? "d" : "u";
1507
- return this.api.request({ url: `/api/` + PES`data/${collection}` + "?raw", body: query }).then((resp) => {
1508
- 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);
1509
1457
  return resp;
1510
1458
  });
1511
1459
  }
1460
+ // Schema ==========================================================================================================
1512
1461
  deleteSchema(path) {
1513
1462
  if (!path) throw new Error("Cannot delete schema, missing collection path");
1514
- 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));
1515
1464
  }
1516
- getSchema(pathOrTree) {
1517
- return this.api.request({ url: "/api/" + PES`schema/${typeof pathOrTree == "string" ? pathOrTree : ""}` + (pathOrTree === true ? `?tree=${pathOrTree}` : "") }).then((resp) => {
1518
- 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);
1519
1468
  return resp;
1520
1469
  });
1521
1470
  }
1522
- setSchema(schema) {
1471
+ updateSchema(schema) {
1523
1472
  if (!schema.path) throw new Error("Cannot update schema, missing collection path");
1524
- return this.api.request({ url: "/api/" + PES`schema/${schema.path}`, body: schema }).then((resp) => {
1525
- 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);
1526
1475
  return resp;
1527
1476
  });
1528
1477
  }
1529
1478
  }
1530
- class Email extends PathedEventEmitter {
1479
+ class Email extends ae {
1531
1480
  constructor(api) {
1532
1481
  super();
1533
1482
  __publicField(this, "api");
@@ -1536,92 +1485,126 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
1536
1485
  send(email) {
1537
1486
  var _a;
1538
1487
  if (!email.to && !email.bcc || !email.body) throw new Error("Cannot send email, missing address or body");
1539
- 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) => {
1540
1489
  var _a2;
1541
- 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 });
1542
1491
  return response;
1543
1492
  });
1544
1493
  }
1545
1494
  }
1546
- class Groups extends PathedEventEmitter {
1495
+ class Groups extends ae {
1547
1496
  constructor(api) {
1548
1497
  super();
1549
1498
  __publicField(this, "api");
1550
- __publicField(this, "cache", new Dt("name"));
1499
+ __publicField(this, "cache", new Gt("name"));
1551
1500
  this.api = typeof api == "string" ? new Api(api) : api;
1552
1501
  }
1553
1502
  async all(reload) {
1554
1503
  if (!reload && this.cache.complete) return this.cache.all();
1555
- return this.api.request({ url: `/api/` + PES`groups` }).then((resp) => {
1504
+ return this.api.request({ url: `/api/` + xt`groups` }).then((resp) => {
1556
1505
  this.cache.addAll(resp);
1557
- this.emit(PES`groups:r`, resp || []);
1506
+ this.emit(xt`groups:r`, resp || []);
1558
1507
  return resp;
1559
1508
  });
1560
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
+ }
1561
1520
  create(group) {
1562
1521
  if (!group.name) throw new Error("Cannot create group, missing name");
1563
1522
  return this.api.request({
1564
- url: `/api/` + PES`groups/${group.name}`,
1523
+ url: `/api/` + xt`groups/${group.name}`,
1565
1524
  method: "POST",
1566
1525
  body: group
1567
1526
  }).then((resp) => {
1568
1527
  this.cache.add(resp);
1569
- this.emit(PES`groups/${group.name}:c`, resp);
1528
+ this.emit(xt`groups/${group.name}:c`, resp);
1570
1529
  return resp;
1571
1530
  });
1572
1531
  }
1573
1532
  async read(name, reload) {
1574
1533
  if (!name) throw new Error("Cannot read group, missing name");
1575
1534
  if (!reload && this.cache.get(name)) return this.cache.get(name);
1576
- return this.api.request({ url: `/api/` + PES`groups/${name}` }).then((resp) => {
1535
+ return this.api.request({ url: `/api/` + xt`groups/${name}` }).then((resp) => {
1577
1536
  this.cache.add(resp);
1578
- this.emit(PES`groups/${name}:r`, resp);
1537
+ this.emit(xt`groups/${name}:r`, resp);
1579
1538
  return resp;
1580
1539
  });
1581
1540
  }
1582
1541
  update(group) {
1583
1542
  if (!group.name) throw new Error("Cannot update group, missing name");
1584
1543
  return this.api.request({
1585
- url: `/api/` + PES`groups/${group.name}`,
1544
+ url: `/api/` + xt`groups/${group.name}`,
1586
1545
  method: "PATCH",
1587
1546
  body: group
1588
1547
  }).then((resp) => {
1589
1548
  this.cache.add(resp);
1590
- this.emit(PES`groups/${group.name}:u`, resp);
1549
+ this.emit(xt`groups/${group.name}:u`, resp);
1591
1550
  return resp;
1592
1551
  });
1593
1552
  }
1594
- delete(name) {
1595
- if (!name) throw new Error("Cannot delete group, missing name");
1596
- return this.api.request({
1597
- url: `/api/` + PES`groups/${name}`,
1598
- method: "DELETE"
1599
- }).then(() => {
1600
- this.cache.delete(name);
1601
- this.emit(PES`groups/${name}:d`);
1602
- });
1603
- }
1604
1553
  }
1605
- class Logger extends PathedEventEmitter {
1606
- constructor(api, namespace, logLevel) {
1554
+ class Logger extends ae {
1555
+ constructor(api, channel, logLevel) {
1607
1556
  super();
1608
1557
  __publicField(this, "api");
1609
- 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');
1610
1567
  this.api = typeof api == "string" ? new Api(api) : api;
1611
- if (logLevel != null && logLevel != "NONE") {
1612
- window.addEventListener("error", (event) => {
1613
- var _a, _b;
1614
- return this.error(((_a = event.error) == null ? void 0 : _a.stack) || ((_b = event.error) == null ? void 0 : _b.message) || event.error);
1615
- });
1616
- window.addEventListener("unhandledrejection", async (event) => {
1617
- var _a, _b, _c, _d;
1618
- let log = ((_a = event.reason) == null ? void 0 : _a.stack) || event.reason;
1619
- if ((_b = event.reason) == null ? void 0 : _b.url)
1620
- 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}
1621
1579
 
1622
1580
  ${log}`;
1623
- ((_c = event.reason) == null ? void 0 : _c.code) == null || ((_d = event.reason) == null ? void 0 : _d.code) >= 500 ? this.error(log) : this.warn(log);
1624
- });
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
+ }
1625
1608
  }
1626
1609
  }
1627
1610
  buildLog(level, log) {
@@ -1637,44 +1620,38 @@ ${log}`;
1637
1620
  }
1638
1621
  };
1639
1622
  }
1640
- createLog(log, namespace = this.namespace) {
1641
- 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(() => {
1642
1626
  });
1643
1627
  }
1644
- clearLogs(namespace = this.namespace) {
1645
- 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`));
1646
1630
  }
1647
- clearServerLogs() {
1648
- return this.clearLogs("server");
1649
- }
1650
- getLogs(length, page, namespace = this.namespace) {
1651
- if (!namespace) throw new Error("Cannot get logs, missing namespace");
1652
- const query = [length ? `length=${length}` : void 0, page ? `page=${page}` : void 0].filter((v) => !!v).join("&");
1653
- return this.api.request({ url: `/api/` + PES`logs/${namespace}` + (query ? `?${query}` : "") }).then((logs) => {
1654
- 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);
1655
1634
  return logs;
1656
1635
  });
1657
1636
  }
1658
- getServerLogs(length, page) {
1659
- return this.getLogs(length, page, "server");
1660
- }
1661
- debug(log, namespace = this.namespace) {
1662
- 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);
1663
1640
  }
1664
- log(log, namespace = this.namespace) {
1665
- 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);
1666
1643
  }
1667
- info(log, namespace = this.namespace) {
1668
- 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);
1669
1646
  }
1670
- warn(log, namespace = this.namespace) {
1671
- 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);
1672
1649
  }
1673
- error(log, namespace = this.namespace) {
1674
- 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);
1675
1652
  }
1676
1653
  }
1677
- class Payments extends PathedEventEmitter {
1654
+ class Payments extends ae {
1678
1655
  constructor(api, secret) {
1679
1656
  super();
1680
1657
  __publicField(this, "api");
@@ -1697,7 +1674,7 @@ ${log}`;
1697
1674
  amount,
1698
1675
  custom
1699
1676
  } });
1700
- this.emit(PES`payments:c`, request.data.clientSecret);
1677
+ this.emit(xt`payments:c`, request.data.clientSecret);
1701
1678
  return request.data.clientSecret;
1702
1679
  }
1703
1680
  async createForm(element, amount, custom) {
@@ -1711,28 +1688,28 @@ ${log}`;
1711
1688
  });
1712
1689
  }
1713
1690
  async history(username) {
1714
- const history = await this.api.request({ url: `/api/` + PES`payments/${username}` });
1715
- 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);
1716
1693
  return history;
1717
1694
  }
1718
1695
  }
1719
- class Pdf extends PathedEventEmitter {
1696
+ class Pdf extends ae {
1720
1697
  constructor(api) {
1721
1698
  super();
1722
1699
  __publicField(this, "api");
1723
1700
  this.api = typeof api == "string" ? new Api(api) : api;
1724
1701
  }
1725
1702
  createPdf(body, options) {
1726
- 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) => {
1727
1704
  const blob = await resp.blob();
1728
1705
  if (options == null ? void 0 : options.download) {
1729
- let filename = (options == null ? void 0 : options.filename) || qt();
1706
+ let filename = (options == null ? void 0 : options.filename) || Yt();
1730
1707
  if (!filename.endsWith(".pdf")) filename += ".pdf";
1731
1708
  const url = URL.createObjectURL(blob);
1732
- dt(url, filename);
1709
+ pt(url, filename);
1733
1710
  URL.revokeObjectURL(url);
1734
1711
  }
1735
- this.emit(PES`pdf:c`, blob);
1712
+ this.emit(xt`pdf:c`, blob);
1736
1713
  return blob;
1737
1714
  });
1738
1715
  }
@@ -1796,7 +1773,7 @@ ${log}`;
1796
1773
  };
1797
1774
  __publicField(_Socket, "timeout", 1e4);
1798
1775
  let Socket = _Socket;
1799
- class Storage extends PathedEventEmitter {
1776
+ class Storage extends ae {
1800
1777
  constructor(api) {
1801
1778
  super();
1802
1779
  __publicField(this, "api");
@@ -1804,119 +1781,119 @@ ${log}`;
1804
1781
  }
1805
1782
  copy(source, destination) {
1806
1783
  if (!source || !destination) throw new Error("Cannot copy file or folder, missing source or destination");
1807
- return this.api.request({ url: "/api/" + PES`storage/${destination}`, body: { from: source } }).then((response) => {
1808
- 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);
1809
1786
  return response;
1810
1787
  });
1811
1788
  }
1812
1789
  delete(path) {
1813
1790
  if (!path) throw new Error("Cannot delete file or folder, missing path");
1814
- return this.api.request({ url: "/api/" + PES`storage/${path}`, method: "DELETE" }).then(() => {
1815
- 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);
1816
1793
  });
1817
1794
  }
1818
1795
  download(path, opts = {}) {
1819
1796
  if (!path) throw new Error("Cannot download file, missing path");
1820
- 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) => {
1821
1798
  const blob = await response.blob();
1822
1799
  const name = opts.downloadAs || path.split("/").pop();
1823
- this.emit(PES`storage/${path}:r`, blob);
1824
- Gt(blob, name);
1800
+ this.emit(xt`storage/${path}:r`, blob);
1801
+ qt(blob, name);
1825
1802
  return response;
1826
1803
  });
1827
1804
  }
1828
1805
  list(path) {
1829
1806
  if (!path) path = "/";
1830
- return this.api.request({ url: "/api/" + PES`storage/${path}` + "?list" }).then((resp) => {
1831
- 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);
1832
1809
  return resp;
1833
1810
  });
1834
1811
  }
1835
1812
  open(path, target = "_blank") {
1836
1813
  if (!path) throw new Error("Cannot download file, missing path");
1837
- 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}` : "");
1838
1815
  if (!target) return link;
1839
- this.emit(PES`storage/${path}:r`, path);
1816
+ this.emit(xt`storage/${path}:r`, path);
1840
1817
  return window.open(link, target);
1841
1818
  }
1842
1819
  mkdir(path) {
1843
1820
  if (!path) throw new Error("Cannot make directory, missing path");
1844
- return this.api.request({ url: "/api/" + PES`storage/${path}`, body: { directory: true } }).then((resp) => {
1845
- 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);
1846
1823
  return resp;
1847
1824
  });
1848
1825
  }
1849
1826
  move(source, destination) {
1850
1827
  if (!source || !destination) throw new Error("Cannot move file or folder, missing source or destination");
1851
1828
  if (source == destination) return this.list(destination);
1852
- return this.api.request({ url: "/api/" + PES`storage/${source}`, method: "PATCH", body: { move: destination } }).then((response) => {
1853
- 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);
1854
1831
  return response;
1855
1832
  });
1856
1833
  }
1857
1834
  upload(files, opts) {
1858
- return new E(async (res, rej, prog) => {
1859
- 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);
1860
1837
  if (!files || Array.isArray(files) && !files.length) return [];
1861
1838
  const path = (opts && typeof opts == "object" ? opts == null ? void 0 : opts.path : opts) || "/";
1862
- return Ft({
1863
- url: `${this.api.url}/api/` + PES`storage/${path}`,
1864
- files: ft(files),
1839
+ return Ht({
1840
+ url: `${this.api.url}/api/` + xt`storage/${path}`,
1841
+ files: b(files),
1865
1842
  headers: this.api.headers
1866
- }).onProgress((p2) => {
1867
- prog(p2);
1843
+ }).onProgress((p) => {
1844
+ prog(p);
1868
1845
  }).then((resp) => {
1869
- this.emit(PES`storage/${path}:c`, resp);
1846
+ this.emit(xt`storage/${path}:c`, resp);
1870
1847
  res(resp);
1871
1848
  }).catch((err) => rej(err));
1872
1849
  });
1873
1850
  }
1874
1851
  }
1875
- class Users extends PathedEventEmitter {
1852
+ class Users extends ae {
1876
1853
  constructor(api) {
1877
1854
  super();
1878
1855
  __publicField(this, "api");
1879
- __publicField(this, "cache", new Dt("username"));
1856
+ __publicField(this, "cache", new Gt("username"));
1880
1857
  this.api = typeof api == "string" ? new Api(api) : api;
1881
1858
  }
1882
1859
  async all(reload) {
1883
1860
  if (!reload && this.cache.complete) return this.cache.all();
1884
- return this.api.request({ url: "/api/" + PES`users` }).then((resp) => {
1861
+ return this.api.request({ url: "/api/" + xt`users` }).then((resp) => {
1885
1862
  resp == null ? void 0 : resp.forEach((r) => {
1886
1863
  r.image = this.api.url + r.image + `?token=${this.api.token}`;
1887
1864
  return r;
1888
1865
  });
1889
1866
  this.cache.addAll(resp);
1890
- this.emit(PES`users:r`, resp || []);
1867
+ this.emit(xt`users:r`, resp || []);
1891
1868
  return resp;
1892
1869
  });
1893
1870
  }
1894
1871
  delete(username) {
1895
1872
  if (!username) throw new Error("Cannot delete user, missing username");
1896
1873
  return this.api.request({
1897
- url: "/api/" + PES`users/${username}`,
1874
+ url: "/api/" + xt`users/${username}`,
1898
1875
  method: "DELETE"
1899
1876
  }).then(() => {
1900
1877
  this.cache.delete(username);
1901
- this.emit(PES`users/${username}:d`, username);
1878
+ this.emit(xt`users/${username}:d`, username);
1902
1879
  });
1903
1880
  }
1904
1881
  async read(username, reload) {
1905
1882
  if (!username) throw new Error("Cannot read user, missing username");
1906
1883
  if (!reload && this.cache.get(username)) return this.cache.get(username);
1907
- return this.api.request({ url: "/api/" + PES`users/${username}` }).then((resp) => {
1884
+ return this.api.request({ url: "/api/" + xt`users/${username}` }).then((resp) => {
1908
1885
  if (resp) {
1909
1886
  resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
1910
1887
  this.cache.add(resp);
1911
1888
  }
1912
- this.emit(PES`users/${username}:r`, resp);
1889
+ this.emit(xt`users/${username}:r`, resp);
1913
1890
  return resp;
1914
1891
  });
1915
1892
  }
1916
1893
  update(user) {
1917
1894
  if (!user.username) throw new Error("Cannot update user, missing username");
1918
1895
  return this.api.request({
1919
- url: `/api/` + PES`users/${user.username}`,
1896
+ url: `/api/` + xt`users/${user.username}`,
1920
1897
  method: "PATCH",
1921
1898
  body: user
1922
1899
  }).then((resp) => {
@@ -1924,60 +1901,60 @@ ${log}`;
1924
1901
  resp.image = this.api.url + resp.image + `?token=${this.api.token}`;
1925
1902
  this.cache.add(resp);
1926
1903
  }
1927
- this.emit(PES`users/${user.username}:${resp._id ? "u" : "c"}`, resp);
1904
+ this.emit(xt`users/${user.username}:${resp._id ? "u" : "c"}`, resp);
1928
1905
  return resp;
1929
1906
  });
1930
1907
  }
1931
1908
  uploadImage(username, file) {
1932
1909
  if (!username || !file) throw new Error("Cannot update user image, missing username or file");
1933
- return Ft({
1934
- url: this.api.url + `/api/` + PES`users/${username}/image`,
1910
+ return Ht({
1911
+ url: this.api.url + `/api/` + xt`users/${username}/image`,
1935
1912
  files: [file],
1936
1913
  headers: this.api.headers
1937
1914
  });
1938
1915
  }
1939
1916
  }
1940
- class Settings extends PathedEventEmitter {
1917
+ class Settings extends ae {
1941
1918
  constructor(api) {
1942
1919
  super();
1943
1920
  __publicField(this, "api");
1944
- __publicField(this, "cache", new Dt());
1921
+ __publicField(this, "cache", new Gt());
1945
1922
  this.api = typeof api == "string" ? new Api(api) : api;
1946
1923
  }
1947
1924
  async all(detailed = false, reload) {
1948
1925
  if (!reload && !detailed && this.cache.complete) return this.cache;
1949
- 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) => {
1950
1927
  if (resp) Object.keys(resp).forEach((key) => this.cache.set(key, detailed ? resp[key].value : resp[key]));
1951
- this.emit(PES`settings:r`, resp || []);
1928
+ this.emit(xt`settings:r`, resp || []);
1952
1929
  return resp;
1953
1930
  });
1954
1931
  }
1955
1932
  delete(key) {
1956
1933
  if (!key) throw new Error("Cannot delete setting, missing key");
1957
- 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(() => {
1958
1935
  this.cache.delete(key);
1959
- this.emit(PES`settings/${key}:d`, key);
1936
+ this.emit(xt`settings/${key}:d`, key);
1960
1937
  });
1961
1938
  }
1962
1939
  read(key, reload = false) {
1963
1940
  if (!key) throw new Error("Cannot read setting, missing key");
1964
1941
  if (!reload && this.cache.get(key)) return this.cache.get(key);
1965
- return this.api.request({ url: `/api/` + PES`settings/${key}` }).then((variable) => {
1942
+ return this.api.request({ url: `/api/` + xt`settings/${key}` }).then((variable) => {
1966
1943
  if (variable) this.cache.set(variable.key, variable.value);
1967
- this.emit(PES`settings/${key}:r`, variable);
1944
+ this.emit(xt`settings/${key}:r`, variable);
1968
1945
  return variable;
1969
1946
  });
1970
1947
  }
1971
1948
  update(variable) {
1972
1949
  if (!variable.key) throw new Error("Cannot update setting, missing key");
1973
- 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) => {
1974
1951
  if (variable2) this.cache.set(variable2.key, variable2.value);
1975
- 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);
1976
1953
  return variable2;
1977
1954
  });
1978
1955
  }
1979
1956
  }
1980
- class Static extends PathedEventEmitter {
1957
+ class Static extends ae {
1981
1958
  constructor(api) {
1982
1959
  super();
1983
1960
  __publicField(this, "api");
@@ -1985,27 +1962,27 @@ ${log}`;
1985
1962
  }
1986
1963
  delete(path) {
1987
1964
  if (!path) throw new Error("Cannot delete static asset, missing path");
1988
- return this.api.request({ url: `/api/` + PES`static/${path}`, method: "DELETE" }).then(() => {
1989
- 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);
1990
1967
  });
1991
1968
  }
1992
1969
  upload(files, path = "/") {
1993
1970
  if (!files) throw new Error("Cannot upload static assets, missing file");
1994
- return new E(async (res, rej, prog) => {
1995
- return Ft({
1996
- url: this.api.url + "/api/" + PES`static/${path}`,
1997
- 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),
1998
1975
  headers: this.api.headers
1999
- }).onProgress((p2) => {
2000
- prog(p2);
1976
+ }).onProgress((p) => {
1977
+ prog(p);
2001
1978
  }).then((resp) => {
2002
- this.emit(PES`static/${path}:c`, resp);
1979
+ this.emit(xt`static/${path}:c`, resp);
2003
1980
  res(resp);
2004
1981
  }).catch((err) => rej(err));
2005
1982
  });
2006
1983
  }
2007
1984
  }
2008
- class Momentum extends PathedEventEmitter {
1985
+ class Momentum extends ae {
2009
1986
  constructor(url, opts) {
2010
1987
  super();
2011
1988
  __publicField(this, "api");
@@ -2031,12 +2008,12 @@ ${log}`;
2031
2008
  this.analytics = new Analytics(this.api);
2032
2009
  this.auth = new Auth(this.api, {
2033
2010
  persist: (opts == null ? void 0 : opts.persist) ?? true,
2034
- loginUi: opts == null ? void 0 : opts.loginUi
2011
+ loginUrl: opts == null ? void 0 : opts.loginUrl
2035
2012
  });
2036
2013
  this.data = new Data(this.api);
2037
2014
  this.email = new Email(this.api);
2038
2015
  this.groups = new Groups(this.api);
2039
- 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);
2040
2017
  if (opts == null ? void 0 : opts.stripeSecret) this.payments = new Payments(this.api, opts.stripeSecret);
2041
2018
  this.pdf = new Pdf(this.api);
2042
2019
  this.settings = new Settings(this.api);
@@ -2080,17 +2057,16 @@ ${log}`;
2080
2057
  exports2.Groups = Groups;
2081
2058
  exports2.Logger = Logger;
2082
2059
  exports2.Momentum = Momentum;
2083
- exports2.PE = PE;
2084
- exports2.PES = PES;
2085
- exports2.PathEvent = PathEvent;
2086
- exports2.PathedEventEmitter = PathedEventEmitter;
2060
+ exports2.PE = ue;
2061
+ exports2.PES = xt;
2062
+ exports2.PathEvent = y;
2063
+ exports2.PathEventEmitter = ae;
2087
2064
  exports2.Payments = Payments;
2088
2065
  exports2.Pdf = Pdf;
2089
2066
  exports2.Settings = Settings;
2090
2067
  exports2.Socket = Socket;
2091
2068
  exports2.Static = Static;
2092
2069
  exports2.Storage = Storage;
2093
- exports2.Totp = Totp;
2094
2070
  exports2.Users = Users;
2095
2071
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
2096
2072
  });