@luminix/core 0.0.1-beta.3 → 0.0.1-beta.5

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.
Files changed (71) hide show
  1. package/dist/contracts/Builder.d.ts +53 -0
  2. package/dist/contracts/Collection.d.ts +190 -0
  3. package/dist/contracts/ModelCollection.d.ts +9 -0
  4. package/dist/contracts/Plugin.d.ts +8 -0
  5. package/dist/contracts/PropertyBag.d.ts +21 -0
  6. package/dist/contracts/Relation/BelongsTo.d.ts +20 -0
  7. package/dist/contracts/Relation/BelongsToMany.d.ts +31 -0
  8. package/dist/contracts/Relation/HasMany.d.ts +21 -0
  9. package/dist/contracts/Relation/HasOne.d.ts +15 -0
  10. package/dist/contracts/Relation/HasOneOrMany.d.ts +10 -0
  11. package/dist/contracts/Relation/MorphMany.d.ts +21 -0
  12. package/dist/contracts/Relation/MorphOne.d.ts +15 -0
  13. package/dist/contracts/Relation/MorphOneOrMany.d.ts +10 -0
  14. package/dist/contracts/Relation/MorphTo.d.ts +8 -0
  15. package/dist/contracts/Relation/MorphToMany.d.ts +16 -0
  16. package/dist/contracts/Relation.d.ts +44 -0
  17. package/dist/core.js +712 -663
  18. package/dist/exceptions/AttributeNotFillableException.d.ts +4 -0
  19. package/dist/exceptions/FacadeNotFoundException.d.ts +4 -0
  20. package/dist/exceptions/MethodNotImplementedException.d.ts +4 -0
  21. package/dist/exceptions/ModelInvalidRelatedTypeException.d.ts +4 -0
  22. package/dist/exceptions/ModelNotFoundException.d.ts +4 -0
  23. package/dist/exceptions/ModelNotPersistedException.d.ts +4 -0
  24. package/dist/exceptions/ModelWithoutPrimaryKeyException.d.ts +4 -0
  25. package/dist/exceptions/NoEmbedException.d.ts +4 -0
  26. package/dist/exceptions/NoInverseRelationException.d.ts +4 -0
  27. package/dist/exceptions/NotModelException.d.ts +4 -0
  28. package/dist/exceptions/NotReducibleException.d.ts +4 -0
  29. package/dist/exceptions/ReducerOverrideException.d.ts +4 -0
  30. package/dist/exceptions/RouteNotFoundException.d.ts +4 -0
  31. package/dist/exceptions/UnsupportedRelationException.d.ts +4 -0
  32. package/dist/facades/App.d.ts +30 -0
  33. package/dist/facades/Auth.d.ts +14 -0
  34. package/dist/facades/Error.d.ts +15 -0
  35. package/dist/facades/Log.d.ts +14 -0
  36. package/dist/facades/Model.d.ts +41 -0
  37. package/dist/facades/Route.d.ts +32 -0
  38. package/dist/helpers/app.d.ts +5 -0
  39. package/dist/helpers/auth.d.ts +3 -0
  40. package/dist/helpers/collect.d.ts +1 -0
  41. package/dist/helpers/config.d.ts +5 -0
  42. package/dist/helpers/error.d.ts +4 -0
  43. package/dist/helpers/log.d.ts +5 -0
  44. package/dist/helpers/model.d.ts +6 -0
  45. package/dist/helpers/route.d.ts +5 -0
  46. package/dist/index.d.ts +24 -0
  47. package/dist/mixins/BaseModel.d.ts +5 -0
  48. package/dist/mixins/HasEvents.d.ts +15 -0
  49. package/dist/mixins/Reducible.d.ts +17 -0
  50. package/dist/support/collection.d.ts +4 -0
  51. package/dist/support/model.d.ts +3 -0
  52. package/dist/support/reader.d.ts +2 -0
  53. package/dist/support/searchParams.d.ts +1 -0
  54. package/dist/types/App.d.ts +72 -0
  55. package/dist/types/Auth.d.ts +13 -0
  56. package/dist/types/Builder.d.ts +51 -0
  57. package/dist/types/Collection.d.ts +1804 -0
  58. package/dist/types/Config.d.ts +29 -0
  59. package/dist/types/Error.d.ts +31 -0
  60. package/dist/types/Event.d.ts +14 -0
  61. package/dist/types/Log.d.ts +37 -0
  62. package/dist/types/Model.d.ts +165 -0
  63. package/dist/types/Plugin.d.ts +4 -0
  64. package/dist/types/PropertyBag.d.ts +25 -0
  65. package/dist/types/Reducer.d.ts +17 -0
  66. package/dist/types/Relation.d.ts +30 -0
  67. package/dist/types/Route.d.ts +22 -0
  68. package/dist/types/Support.d.ts +7 -0
  69. package/package.json +1 -1
  70. package/vite.config.js +2 -2
  71. package/graph.png +0 -0
package/dist/core.js CHANGED
@@ -1,40 +1,41 @@
1
- var me = Object.defineProperty;
2
- var G = (n) => {
1
+ var Qe = Object.defineProperty;
2
+ var U = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var ge = (n, e, t) => e in n ? me(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
- var p = (n, e, t) => ge(n, typeof e != "symbol" ? e + "" : e, t), F = (n, e, t) => e.has(n) || G("Cannot " + t);
7
- var o = (n, e, t) => (F(n, e, "read from private field"), t ? t.call(n) : e.get(n)), q = (n, e, t) => e.has(n) ? G("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), P = (n, e, t, r) => (F(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t), V = (n, e, t) => (F(n, e, "access private method"), t);
5
+ var Ce = (n, e, t) => e in n ? Qe(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var m = (n, e, t) => Ce(n, typeof e != "symbol" ? e + "" : e, t), F = (n, e, t) => e.has(n) || U("Cannot " + t);
7
+ var o = (n, e, t) => (F(n, e, "read from private field"), t ? t.call(n) : e.get(n)), q = (n, e, t) => e.has(n) ? U("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), P = (n, e, t, r) => (F(n, e, "write to private field"), r ? r.call(n, t) : e.set(n, t), t), D = (n, e, t) => (F(n, e, "access private method"), t);
8
8
  import f from "lodash";
9
- import { produce as B, isDraftable as ye } from "immer";
10
- import K, { isAxiosError as we } from "axios";
11
- class O extends Error {
12
- constructor(e) {
13
- super(`[Luminix] Facade "${e}" not found`);
9
+ import { produce as R, isDraftable as Le } from "immer";
10
+ import K, { isAxiosError as Je } from "axios";
11
+ var X, Y;
12
+ class Ue extends (Y = Error, X = Symbol.toStringTag, Y) {
13
+ constructor(t) {
14
+ super(`[Luminix] Facade "${t}" not found`);
15
+ m(this, X, "FacadeNotFoundException");
14
16
  }
15
17
  }
16
- p(O, "name", "FacadeNotFoundException");
17
- class be {
18
+ class De {
18
19
  constructor(e) {
19
- p(this, "_user");
20
+ m(this, "_user");
20
21
  this.app = e;
21
22
  }
22
23
  attempt(e, t = !1, r) {
23
- const s = document.createElement("form");
24
- s.method = "post", s.action = this.app.make("route").url("login"), s.style.display = "none";
25
- const i = this.app.make("config").get("auth.csrf");
26
- if (typeof i == "string") {
27
- const c = document.createElement("input");
28
- c.type = "hidden", c.name = "_token", c.value = i, s.appendChild(c);
24
+ const i = document.createElement("form");
25
+ i.method = "post", i.action = this.app.make("route").url("login"), i.style.display = "none";
26
+ const s = this.app.make("config").get("auth.csrf");
27
+ if (typeof s == "string") {
28
+ const l = document.createElement("input");
29
+ l.type = "hidden", l.name = "_token", l.value = s, i.appendChild(l);
29
30
  }
30
31
  const u = document.createElement("input");
31
- u.type = "email", u.name = "email", u.value = e.email, s.appendChild(u);
32
+ u.type = "email", u.name = "email", u.value = e.email, i.appendChild(u);
32
33
  const a = document.createElement("input");
33
- if (a.type = "password", a.name = "password", a.value = e.password, s.appendChild(a), t) {
34
- const c = document.createElement("input");
35
- c.type = "checkbox", c.name = "remember", c.value = "1", c.checked = !0, s.appendChild(c);
34
+ if (a.type = "password", a.name = "password", a.value = e.password, i.appendChild(a), t) {
35
+ const l = document.createElement("input");
36
+ l.type = "checkbox", l.name = "remember", l.value = "1", l.checked = !0, i.appendChild(l);
36
37
  }
37
- r && s.addEventListener("submit", r), document.body.appendChild(s), s.submit();
38
+ r && i.addEventListener("submit", r), document.body.appendChild(i), i.submit();
38
39
  }
39
40
  check() {
40
41
  return !!this.app.make("config").get("auth.user");
@@ -44,17 +45,17 @@ class be {
44
45
  t.method = "post", t.action = this.app.make("route").url("logout"), t.style.display = "none";
45
46
  const r = this.app.make("config").get("auth.csrf");
46
47
  if (typeof r == "string") {
47
- const s = document.createElement("input");
48
- s.type = "hidden", s.name = "_token", s.value = r, t.appendChild(s);
48
+ const i = document.createElement("input");
49
+ i.type = "hidden", i.name = "_token", i.value = r, t.appendChild(i);
49
50
  }
50
51
  document.body.appendChild(t), e && t.addEventListener("submit", e), t.submit();
51
52
  }
52
53
  user() {
53
54
  if (!this._user) {
54
- const { model: e, config: t } = this.app.make(), r = e.make("user"), s = t.get("auth.user");
55
- if (!s)
55
+ const { model: e, config: t } = this.app.make(), r = e.make("user"), i = t.get("auth.user");
56
+ if (!i)
56
57
  return null;
57
- this._user = new r(s);
58
+ this._user = new r(i);
58
59
  }
59
60
  return this._user;
60
61
  }
@@ -63,7 +64,7 @@ class be {
63
64
  return ((e = this.user()) == null ? void 0 : e.getKey()) || null;
64
65
  }
65
66
  }
66
- class Ee {
67
+ class He {
67
68
  constructor(e) {
68
69
  this._debug = e;
69
70
  }
@@ -92,9 +93,9 @@ class Ee {
92
93
  this._debug && console.debug(...e);
93
94
  }
94
95
  }
95
- class v {
96
+ class S {
96
97
  constructor(e) {
97
- p(this, "locked", []);
98
+ m(this, "locked", []);
98
99
  this.bag = e, Object.freeze(this.bag);
99
100
  }
100
101
  get(e, t) {
@@ -110,14 +111,14 @@ class v {
110
111
  throw new Error("Cannot set the root path when there are locked paths");
111
112
  if (typeof t != "object" || t === null)
112
113
  throw new TypeError("Value must be an object");
113
- this.bag = B(this.bag, () => t), this.emit("change", {
114
+ this.bag = R(this.bag, () => t), this.emit("change", {
114
115
  path: e,
115
116
  value: t,
116
117
  type: "set"
117
118
  });
118
119
  return;
119
120
  }
120
- this.bag = B(this.bag, (r) => {
121
+ this.bag = R(this.bag, (r) => {
121
122
  f.set(r, e, t);
122
123
  }), this.emit("change", {
123
124
  path: e,
@@ -129,10 +130,10 @@ class v {
129
130
  if (typeof t != "object" || t === null)
130
131
  throw new TypeError("Value must be an object");
131
132
  if (e === ".") {
132
- if (this.locked.some((s) => f.has(t, s)))
133
+ if (this.locked.some((i) => f.has(t, i)))
133
134
  throw new Error(`Cannot merge a path "${e}" that would override a locked path`);
134
- this.bag = B(this.bag, (s) => ({
135
- ...s,
135
+ this.bag = R(this.bag, (i) => ({
136
+ ...i,
136
137
  ...t
137
138
  })), this.emit("change", {
138
139
  path: e,
@@ -157,7 +158,7 @@ class v {
157
158
  delete(e) {
158
159
  if (this.locked.some((t) => e.startsWith(t)))
159
160
  throw new Error(`Cannot delete a locked path "${e}"`);
160
- this.bag = B(this.bag, (t) => {
161
+ this.bag = R(this.bag, (t) => {
161
162
  f.unset(t, e);
162
163
  }), this.emit("change", {
163
164
  path: e,
@@ -171,7 +172,7 @@ class v {
171
172
  this.locked.push(e);
172
173
  }
173
174
  clone() {
174
- return new v(this.bag);
175
+ return new S(this.bag);
175
176
  }
176
177
  all() {
177
178
  return this.bag;
@@ -191,92 +192,93 @@ class v {
191
192
  }
192
193
  }
193
194
  function A(n) {
194
- var e, t, r, s, i, k;
195
- return s = class extends (t = n, e = Symbol.toStringTag, t) {
195
+ var e, t, r, i, Se, u;
196
+ return u = class extends (t = n, e = Symbol.toStringTag, t) {
196
197
  constructor(...d) {
197
198
  super(...d);
198
199
  q(this, i);
199
200
  q(this, r);
200
- p(this, e, n.name);
201
- P(this, r, V(this, i, k).call(this));
201
+ m(this, e, n.name);
202
+ P(this, r, D(this, i, Se).call(this));
202
203
  }
203
- on(d, g) {
204
+ on(d, p) {
204
205
  if (typeof d != "string")
205
206
  throw new TypeError("event must be a string");
206
- if (typeof g != "function")
207
+ if (typeof p != "function")
207
208
  throw new TypeError("callback must be a function");
208
- return o(this, r).on(d, g);
209
+ return o(this, r).on(d, p);
209
210
  }
210
- once(d, g) {
211
+ once(d, p) {
211
212
  if (typeof d != "string")
212
213
  throw new TypeError("event must be a string");
213
- if (typeof g != "function")
214
+ if (typeof p != "function")
214
215
  throw new TypeError("callback must be a function");
215
- const b = o(this, r).on(d, (m) => {
216
- b(), g(m);
216
+ const y = o(this, r).on(d, (w) => {
217
+ y(), p(w);
217
218
  });
218
219
  }
219
- emit(d, g = {}) {
220
+ emit(d, p = {}) {
220
221
  if (typeof d != "string")
221
222
  throw new TypeError("event must be a string");
222
- if (typeof g != "object")
223
+ if (typeof p != "object")
223
224
  throw new TypeError("data must be an object");
224
225
  o(this, r).emit(d, {
225
- ...g,
226
+ ...p,
226
227
  source: this
227
228
  });
228
229
  }
229
- }, r = new WeakMap(), i = new WeakSet(), k = function() {
230
+ }, r = new WeakMap(), i = new WeakSet(), Se = function() {
230
231
  return {
231
- emit(d, g) {
232
- for (let b = 0, m = this.events[d] || [], x = m.length; b < x; b++)
233
- m[b](g);
232
+ emit(d, p) {
233
+ for (let y = 0, w = this.events[d] || [], g = w.length; y < g; y++)
234
+ w[y](p);
234
235
  },
235
236
  events: {},
236
- on(d, g) {
237
- var b;
238
- return ((b = this.events)[d] || (b[d] = [])).push(g), () => {
239
- var m;
240
- this.events[d] = (m = this.events[d]) == null ? void 0 : m.filter((x) => g !== x);
237
+ on(d, p) {
238
+ var y;
239
+ return ((y = this.events)[d] || (y[d] = [])).push(p), () => {
240
+ var w;
241
+ this.events[d] = (w = this.events[d]) == null ? void 0 : w.filter((g) => p !== g);
241
242
  };
242
243
  }
243
244
  };
244
- }, p(s, "name", n.name), s;
245
+ }, u;
245
246
  }
246
- function X(...n) {
247
- return n.reduce((e, t) => e.flatMap((r) => t.map((s) => [r, s].flat())));
247
+ function H(...n) {
248
+ return n.reduce((e, t) => e.flatMap((r) => t.map((i) => [r, i].flat())));
248
249
  }
249
- function T(n) {
250
+ function $(n) {
250
251
  return !(typeof n != "object" || n === null || !Reflect.has(n, "constructor") || Reflect.get(n.constructor, "name") !== "Collection");
251
252
  }
252
- class y extends Error {
253
+ var Z, z;
254
+ class b extends (z = Error, Z = Symbol.toStringTag, z) {
253
255
  constructor() {
254
256
  super("[Luminix] Method not implemented.");
257
+ m(this, Z, "MethodNotImplementedException");
255
258
  }
256
259
  }
257
- p(y, "name", "MethodNotImplementedException");
258
- function l(n = [], e = L) {
260
+ function c(n = [], e = Q) {
259
261
  if (!Array.isArray(n))
260
262
  throw new TypeError("collect() expects an array");
261
263
  return new (A(e))([...n]);
262
264
  }
263
- const $ = (n) => {
265
+ const T = (n) => {
264
266
  n.emit("change", {
265
267
  items: n.all()
266
268
  });
267
269
  }, I = (n, e) => Array.isArray(n) ? n[e] ?? null : n.get(e);
268
- var Z, z, h;
269
- class L {
270
+ var O, k, h;
271
+ class Q {
270
272
  constructor(e = []) {
271
- // static name = 'Collection';
273
+ // [Symbol.toStringTag] = 'Collection';
272
274
  q(this, h);
273
- p(this, Z, "Collection");
275
+ m(this, O, "Collection");
274
276
  P(this, h, e);
275
277
  }
276
278
  get items() {
277
279
  return [...o(this, h)];
278
280
  }
279
- [(z = Symbol.iterator, Z = Symbol.toStringTag, z)]() {
281
+ [(k = Symbol.iterator, O = Symbol.toStringTag, k)]() {
280
282
  return o(this, h)[Symbol.iterator]();
281
283
  }
282
284
  all() {
@@ -292,34 +294,34 @@ class L {
292
294
  const t = [];
293
295
  for (let r = 0; r < o(this, h).length; r += e)
294
296
  t.push(o(this, h).slice(r, r + e));
295
- return l(t.map((r) => l(r)));
297
+ return c(t.map((r) => c(r)));
296
298
  }
297
299
  chunkWhile(e) {
298
300
  const t = [];
299
- let r = l();
300
- for (let s = 0; s < o(this, h).length; s++)
301
- e(o(this, h)[s], s, r) ? r.push(o(this, h)[s]) : (t.push(r), r = l());
302
- return r.count() > 0 && t.push(r), l(t);
301
+ let r = c();
302
+ for (let i = 0; i < o(this, h).length; i++)
303
+ e(o(this, h)[i], i, r) ? r.push(o(this, h)[i]) : (t.push(r), r = c());
304
+ return r.count() > 0 && t.push(r), c(t);
303
305
  }
304
306
  collapse() {
305
- return l(o(this, h).flat());
307
+ return c(o(this, h).flat());
306
308
  }
307
309
  collect() {
308
- return l(o(this, h));
310
+ return c(o(this, h));
309
311
  }
310
312
  combine(e) {
311
313
  const t = {};
312
- return o(this, h).forEach((r, s) => {
314
+ return o(this, h).forEach((r, i) => {
313
315
  if (typeof r != "string")
314
316
  throw new TypeError("The `combine` method expects the keys to be strings");
315
- t[r] = I(e, s);
317
+ t[r] = I(e, i);
316
318
  }), t;
317
319
  }
318
320
  concat(e) {
319
- return Array.isArray(e) ? l([...o(this, h), ...e]) : l([...o(this, h), ...e.all()]);
321
+ return Array.isArray(e) ? c([...o(this, h), ...e]) : c([...o(this, h), ...e.all()]);
320
322
  }
321
323
  contains(e, t) {
322
- return typeof e == "function" ? o(this, h).some((r, s) => e(r, s, this)) : o(this, h).some((r) => {
324
+ return typeof e == "function" ? o(this, h).some((r, i) => e(r, i, this)) : o(this, h).some((r) => {
323
325
  if (typeof t > "u")
324
326
  return r == e;
325
327
  if (typeof e != "string")
@@ -331,7 +333,7 @@ class L {
331
333
  return o(this, h).length === 1;
332
334
  }
333
335
  containsStrict(e, t) {
334
- return typeof e == "function" ? o(this, h).some((r, s) => e(r, s, this)) : o(this, h).some((r) => {
336
+ return typeof e == "function" ? o(this, h).some((r, i) => e(r, i, this)) : o(this, h).some((r) => {
335
337
  if (typeof t > "u")
336
338
  return r === e;
337
339
  if (typeof e != "string")
@@ -343,9 +345,9 @@ class L {
343
345
  return o(this, h).length;
344
346
  }
345
347
  countBy(e) {
346
- return typeof e == "function" ? o(this, h).reduce((t, r, s) => {
347
- const i = e(r, s, this);
348
- return t[i] = t[i] ? t[i] + 1 : 1, t;
348
+ return typeof e == "function" ? o(this, h).reduce((t, r, i) => {
349
+ const s = e(r, i, this);
350
+ return t[s] = t[s] ? t[s] + 1 : 1, t;
349
351
  }, {}) : o(this, h).reduce((t, r) => {
350
352
  if (!["string", "number"].includes(typeof r))
351
353
  throw new TypeError("The countBy method expects the items to be strings or numbers");
@@ -353,16 +355,16 @@ class L {
353
355
  }, {});
354
356
  }
355
357
  crossJoin(...e) {
356
- return l(X(
358
+ return c(H(
357
359
  o(this, h),
358
360
  ...e.map((t) => Array.isArray(t) ? t : t.all())
359
361
  ));
360
362
  }
361
363
  diff(e) {
362
- return Array.isArray(e) ? l(o(this, h).filter((t) => !e.includes(t))) : l(o(this, h).filter((t) => !e.contains(t)));
364
+ return Array.isArray(e) ? c(o(this, h).filter((t) => !e.includes(t))) : c(o(this, h).filter((t) => !e.contains(t)));
363
365
  }
364
366
  doesntContain(e, t) {
365
- return typeof e == "function" ? o(this, h).every((r, s) => !e(r, s, this)) : o(this, h).every((r) => {
367
+ return typeof e == "function" ? o(this, h).every((r, i) => !e(r, i, this)) : o(this, h).every((r) => {
366
368
  if (typeof t > "u")
367
369
  return r != e;
368
370
  if (typeof e != "string")
@@ -374,10 +376,10 @@ class L {
374
376
  console.log(this.toArray());
375
377
  }
376
378
  duplicates(e) {
377
- return l(typeof e == "string" ? o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i[e] == r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i == r) && t.push(r), t), []));
379
+ return c(typeof e == "string" ? o(this, h).reduce((t, r, i) => (o(this, h).slice(i + 1).some((s) => s[e] == r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, i) => (o(this, h).slice(i + 1).some((s) => s == r) && t.push(r), t), []));
378
380
  }
379
381
  duplicatesStrict(e) {
380
- return l(typeof e == "string" ? o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i[e] === r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, s) => (o(this, h).slice(s + 1).some((i) => i === r) && t.push(r), t), []));
382
+ return c(typeof e == "string" ? o(this, h).reduce((t, r, i) => (o(this, h).slice(i + 1).some((s) => s[e] === r[e]) && t.push(r[e]), t), []) : o(this, h).reduce((t, r, i) => (o(this, h).slice(i + 1).some((s) => s === r) && t.push(r), t), []));
381
383
  }
382
384
  each(e) {
383
385
  let t = 0;
@@ -390,7 +392,7 @@ class L {
390
392
  }
391
393
  eachSpread(e) {
392
394
  for (const t of this) {
393
- if (!Array.isArray(t) && !T(t))
395
+ if (!Array.isArray(t) && !$(t))
394
396
  throw new TypeError("The items in the collection must be arrays or collections");
395
397
  const r = Array.isArray(t) ? t : t.all();
396
398
  if (e(...r) === !1)
@@ -400,19 +402,19 @@ class L {
400
402
  }
401
403
  ensure(e) {
402
404
  const t = Array.isArray(e) ? e : [e];
403
- return o(this, h).forEach((r, s) => {
404
- if (!t.some((i) => typeof i == "string" ? typeof r === i : r instanceof i))
405
- throw new TypeError(`The item at index ${s} is not of the expected type`);
405
+ return o(this, h).forEach((r, i) => {
406
+ if (!t.some((s) => typeof s == "string" ? typeof r === s : r instanceof s))
407
+ throw new TypeError(`The item at index ${i} is not of the expected type`);
406
408
  }), this;
407
409
  }
408
410
  every(e) {
409
411
  return o(this, h).every((t, r) => e(t, r, this));
410
412
  }
411
413
  except(e) {
412
- return l(o(this, h).filter((t, r) => !e.includes(r)));
414
+ return c(o(this, h).filter((t, r) => !e.includes(r)));
413
415
  }
414
416
  filter(e) {
415
- return l(o(this, h).filter((t, r) => typeof e != "function" ? !!t : e(t, r, this)));
417
+ return c(o(this, h).filter((t, r) => typeof e != "function" ? !!t : e(t, r, this)));
416
418
  }
417
419
  first(e) {
418
420
  return typeof e == "function" ? o(this, h).find((t, r) => e(t, r, this)) ?? null : o(this, h)[0] ?? null;
@@ -427,38 +429,38 @@ class L {
427
429
  if (typeof e != "string")
428
430
  throw new TypeError("The key must be a string");
429
431
  if (typeof t > "u")
430
- return this.first((s) => !!s[e]);
432
+ return this.first((i) => !!i[e]);
431
433
  if (typeof r > "u")
432
- return o(this, h).find((s) => s[e] == t) ?? null;
434
+ return o(this, h).find((i) => i[e] == t) ?? null;
433
435
  if (typeof t != "string")
434
436
  throw new TypeError("The operator must be a string");
435
- return r === null ? o(this, h).find((s) => s[e] === null) ?? null : o(this, h).find((s) => {
437
+ return r === null ? o(this, h).find((i) => i[e] === null) ?? null : o(this, h).find((i) => {
436
438
  switch (t) {
437
439
  case "=":
438
- return s[e] == r;
440
+ return i[e] == r;
439
441
  case "!=":
440
- return s[e] != r;
442
+ return i[e] != r;
441
443
  case ">":
442
- return s[e] > r;
444
+ return i[e] > r;
443
445
  case "<":
444
- return s[e] < r;
446
+ return i[e] < r;
445
447
  case ">=":
446
- return s[e] >= r;
448
+ return i[e] >= r;
447
449
  case "<=":
448
- return s[e] <= r;
450
+ return i[e] <= r;
449
451
  default:
450
452
  throw new Error("Unsupported operator");
451
453
  }
452
454
  }) ?? null;
453
455
  }
454
456
  flatMap(e) {
455
- return l(o(this, h).flatMap((t, r) => e(t, r, this)));
457
+ return c(o(this, h).flatMap((t, r) => e(t, r, this)));
456
458
  }
457
459
  forget(e) {
458
- return o(this, h).splice(e, 1), $(this), this;
460
+ return o(this, h).splice(e, 1), T(this), this;
459
461
  }
460
462
  forPage(e, t) {
461
- return l(o(this, h).slice((e - 1) * t, e * t));
463
+ return c(o(this, h).slice((e - 1) * t, e * t));
462
464
  }
463
465
  get(e, t) {
464
466
  if (typeof e != "number")
@@ -467,19 +469,19 @@ class L {
467
469
  }
468
470
  groupBy(e) {
469
471
  const t = Array.isArray(e) ? e : [e];
470
- return o(this, h).reduce((r, s, i) => {
471
- const u = t.map((c) => {
472
- if (typeof c == "function") {
473
- const d = c(s, i, this);
472
+ return o(this, h).reduce((r, i, s) => {
473
+ const u = t.map((l) => {
474
+ if (typeof l == "function") {
475
+ const d = l(i, s, this);
474
476
  return Array.isArray(d) ? d : [d];
475
477
  }
476
- return [String(s[c])];
478
+ return [String(i[l])];
477
479
  });
478
- return X(...u).forEach((c) => {
479
- const d = Array.isArray(c) ? c.join(".") : c;
480
+ return H(...u).forEach((l) => {
481
+ const d = Array.isArray(l) ? l.join(".") : l;
480
482
  f.set(r, d, [
481
483
  ...f.get(r, d, []),
482
- s
484
+ i
483
485
  ]);
484
486
  }), r;
485
487
  }, {});
@@ -499,7 +501,7 @@ class L {
499
501
  return o(this, h).join(e);
500
502
  }
501
503
  if (typeof e == "function")
502
- return o(this, h).map((r, s) => e(r, s, this)).join(t);
504
+ return o(this, h).map((r, i) => e(r, i, this)).join(t);
503
505
  if (typeof e != "string")
504
506
  throw new TypeError("The key must be a string");
505
507
  if (!o(this, h).every((r) => typeof r == "object"))
@@ -507,7 +509,7 @@ class L {
507
509
  return o(this, h).map((r) => r[e]).join(t);
508
510
  }
509
511
  intersect(e) {
510
- return Array.isArray(e) ? l(o(this, h).filter((t) => e.includes(t))) : l(o(this, h).filter((t) => e.contains(t)));
512
+ return Array.isArray(e) ? c(o(this, h).filter((t) => e.includes(t))) : c(o(this, h).filter((t) => e.contains(t)));
511
513
  }
512
514
  isEmpty() {
513
515
  return o(this, h).length === 0;
@@ -520,7 +522,7 @@ class L {
520
522
  }
521
523
  keyBy(e) {
522
524
  if (typeof e == "function")
523
- return o(this, h).reduce((t, r, s) => (t[e(r, s, this)] = r, t), {});
525
+ return o(this, h).reduce((t, r, i) => (t[e(r, i, this)] = r, t), {});
524
526
  if (typeof e != "string")
525
527
  throw new TypeError("The key must be a string");
526
528
  return o(this, h).reduce((t, r) => (t[String(r[e])] = r, t), {});
@@ -529,31 +531,31 @@ class L {
529
531
  return typeof e == "function" ? o(this, h).toReversed().find((t, r) => e(t, r, this)) ?? null : o(this, h)[o(this, h).length - 1] ?? null;
530
532
  }
531
533
  map(e) {
532
- return l(o(this, h).map((t, r) => e(t, r, this)));
534
+ return c(o(this, h).map((t, r) => e(t, r, this)));
533
535
  }
534
536
  mapInto(e) {
535
- return l(o(this, h).map((t) => new e(t)));
537
+ return c(o(this, h).map((t) => new e(t)));
536
538
  }
537
539
  mapSpread(e) {
538
- return l(o(this, h).map((t) => {
539
- if (!Array.isArray(t) && !T(t))
540
+ return c(o(this, h).map((t) => {
541
+ if (!Array.isArray(t) && !$(t))
540
542
  throw new TypeError("The items in the collection must be arrays or collections");
541
543
  const r = Array.isArray(t) ? t : t.all();
542
544
  return e(...r);
543
545
  }));
544
546
  }
545
547
  mapToGroups(e) {
546
- return o(this, h).reduce((t, r, s) => {
547
- const i = e(r, s, this);
548
- return Object.entries(i).forEach(([u, a]) => {
548
+ return o(this, h).reduce((t, r, i) => {
549
+ const s = e(r, i, this);
550
+ return Object.entries(s).forEach(([u, a]) => {
549
551
  t[u] = t[u] ?? [], t[u].push(a);
550
552
  }), t;
551
553
  }, {});
552
554
  }
553
555
  mapWithKeys(e) {
554
- return o(this, h).reduce((t, r, s) => {
555
- const i = e(r, s, this);
556
- return Object.entries(i).forEach(([u, a]) => {
556
+ return o(this, h).reduce((t, r, i) => {
557
+ const s = e(r, i, this);
558
+ return Object.entries(s).forEach(([u, a]) => {
557
559
  t[u] = a;
558
560
  }), t;
559
561
  }, {});
@@ -563,33 +565,33 @@ class L {
563
565
  }
564
566
  median(e) {
565
567
  if (typeof e == "string") {
566
- const s = this.pluck(e).sort(), i = Math.floor(s.count() / 2);
567
- return s.count() % 2 === 0 ? l([I(s, i - 1), I(s, i)]).avg() : I(s, i);
568
+ const i = this.pluck(e).sort(), s = Math.floor(i.count() / 2);
569
+ return i.count() % 2 === 0 ? c([I(i, s - 1), I(i, s)]).avg() : I(i, s);
568
570
  }
569
571
  const t = o(this, h).toSorted(), r = Math.floor(t.length / 2);
570
- return t.length % 2 === 0 ? l([t[r - 1], t[r]]).avg() : t[r] ?? null;
572
+ return t.length % 2 === 0 ? c([t[r - 1], t[r]]).avg() : t[r] ?? null;
571
573
  }
572
574
  merge(e) {
573
- return Array.isArray(e) ? l([...o(this, h), ...e]) : l([...o(this, h), ...e.all()]);
575
+ return Array.isArray(e) ? c([...o(this, h), ...e]) : c([...o(this, h), ...e.all()]);
574
576
  }
575
577
  min(e) {
576
578
  return typeof e == "string" ? o(this, h).reduce((t, r) => r[e] < t ? r[e] : t, o(this, h)[0][e]) : o(this, h).reduce((t, r) => r < t ? r : t, o(this, h)[0]);
577
579
  }
578
580
  mode(e) {
579
- const t = typeof e == "string" ? this.filter((s) => ["number", "string"].includes(typeof s[e])).countBy((s) => s[e]) : this.countBy(), r = Math.max(...Object.values(t));
580
- return Object.entries(t).filter(([, s]) => s === r).map(([s]) => s);
581
+ const t = typeof e == "string" ? this.filter((i) => ["number", "string"].includes(typeof i[e])).countBy((i) => i[e]) : this.countBy(), r = Math.max(...Object.values(t));
582
+ return Object.entries(t).filter(([, i]) => i === r).map(([i]) => i);
581
583
  }
582
584
  nth(e, t = 0) {
583
585
  return this.chunk(e).filter((r) => r.count() > t).map((r) => r.get(t));
584
586
  }
585
587
  only(e) {
586
- return l(o(this, h).filter((t, r) => e.includes(r)));
588
+ return c(o(this, h).filter((t, r) => e.includes(r)));
587
589
  }
588
590
  pad(e, t = null) {
589
591
  const r = o(this, h).slice();
590
592
  for (; r.length < Math.abs(e); )
591
593
  e > 0 ? r.push(t) : r.unshift(t);
592
- return l(r);
594
+ return c(r);
593
595
  }
594
596
  partition(e) {
595
597
  return [
@@ -610,10 +612,10 @@ class L {
610
612
  }
611
613
  pipeThrough(e) {
612
614
  return e.reduce((t, r) => {
613
- if (!T(t) && !Array.isArray(t))
615
+ if (!$(t) && !Array.isArray(t))
614
616
  throw new TypeError("The pipeline expects the carry to be a collection or an array");
615
617
  return r(
616
- T(t) ? t : l(t)
618
+ $(t) ? t : c(t)
617
619
  );
618
620
  }, this);
619
621
  }
@@ -622,64 +624,64 @@ class L {
622
624
  }
623
625
  pop(e = 1) {
624
626
  const t = o(this, h).splice(o(this, h).length - e, e);
625
- return $(this), e === 1 ? t[0] ?? null : l(t);
627
+ return T(this), e === 1 ? t[0] ?? null : c(t);
626
628
  }
627
629
  prepend(e) {
628
630
  const t = o(this, h).unshift(e);
629
- return $(this), t;
631
+ return T(this), t;
630
632
  }
631
633
  pull(e) {
632
634
  const t = o(this, h).splice(e, 1)[0] ?? null;
633
- return $(this), t;
635
+ return T(this), t;
634
636
  }
635
637
  push(...e) {
636
638
  const t = o(this, h).push(...e);
637
- return $(this), t;
639
+ return T(this), t;
638
640
  }
639
641
  put(e, t) {
640
- return o(this, h).splice(e, 1, t), $(this), this;
642
+ return o(this, h).splice(e, 1, t), T(this), this;
641
643
  }
642
644
  random(e = 1) {
643
645
  if (o(this, h).length < e)
644
646
  throw new Error("The collection has fewer items than the requested amount");
645
- const t = l(f.sampleSize(o(this, h), e));
647
+ const t = c(f.sampleSize(o(this, h), e));
646
648
  return e === 1 ? t.first() : t;
647
649
  }
648
650
  reduce(e, t = null) {
649
- return o(this, h).reduce((r, s, i) => e(r, s, i, this), t);
651
+ return o(this, h).reduce((r, i, s) => e(r, i, s, this), t);
650
652
  }
651
653
  reject(e) {
652
654
  return this.filter((t, r) => !e(t, r, this));
653
655
  }
654
656
  replace(e) {
655
657
  const t = o(this, h).slice();
656
- return Object.entries(e).forEach(([r, s]) => {
657
- t[parseInt(r)] = s;
658
- }), l(t);
658
+ return Object.entries(e).forEach(([r, i]) => {
659
+ t[parseInt(r)] = i;
660
+ }), c(t);
659
661
  }
660
662
  reverse() {
661
- return l(o(this, h).toReversed());
663
+ return c(o(this, h).toReversed());
662
664
  }
663
665
  search(e, t = !1) {
664
- if (typeof e != "function" || o(this, h).every((s) => typeof s == "function")) {
665
- const s = o(this, h).findIndex((i) => t ? i === e : i == e);
666
- return s === -1 ? !1 : s;
666
+ if (typeof e != "function" || o(this, h).every((i) => typeof i == "function")) {
667
+ const i = o(this, h).findIndex((s) => t ? s === e : s == e);
668
+ return i === -1 ? !1 : i;
667
669
  }
668
- const r = o(this, h).findIndex((s, i) => e(s, i, this));
670
+ const r = o(this, h).findIndex((i, s) => e(i, s, this));
669
671
  return r === -1 ? !1 : r;
670
672
  }
671
673
  select(e) {
672
- return this.map((t) => e.reduce((r, s) => (r[s] = t[s], r), {}));
674
+ return this.map((t) => e.reduce((r, i) => (r[i] = t[i], r), {}));
673
675
  }
674
676
  shift(e = 1) {
675
677
  const t = o(this, h).splice(0, e);
676
- return $(this), e === 1 ? t[0] ?? null : l(t);
678
+ return T(this), e === 1 ? t[0] ?? null : c(t);
677
679
  }
678
680
  shuffle() {
679
- return l(f.shuffle(o(this, h)));
681
+ return c(f.shuffle(o(this, h)));
680
682
  }
681
683
  skip(e) {
682
- return l(o(this, h).slice(e));
684
+ return c(o(this, h).slice(e));
683
685
  }
684
686
  skipUntil(e) {
685
687
  return typeof e == "function" ? this.skip(o(this, h).findIndex((t, r) => e(t, r, this))) : this.skip(o(this, h).findIndex((t) => t == e));
@@ -688,13 +690,13 @@ class L {
688
690
  return typeof e == "function" ? this.skip(o(this, h).findIndex((t, r) => !e(t, r, this))) : this.skip(o(this, h).findIndex((t) => t != e));
689
691
  }
690
692
  slice(e, t) {
691
- return l(typeof t > "u" ? o(this, h).slice(e) : typeof e > "u" ? o(this, h).slice(0, t) : o(this, h).slice(e, e + t));
693
+ return c(typeof t > "u" ? o(this, h).slice(e) : typeof e > "u" ? o(this, h).slice(0, t) : o(this, h).slice(e, e + t));
692
694
  }
693
695
  sliding(e, t = 1) {
694
696
  const r = [];
695
- for (let s = 0; s < o(this, h).length && !(s + e > o(this, h).length); s += t)
696
- r.push(o(this, h).slice(s, s + e));
697
- return l(r.map((s) => l(s)));
697
+ for (let i = 0; i < o(this, h).length && !(i + e > o(this, h).length); i += t)
698
+ r.push(o(this, h).slice(i, i + e));
699
+ return c(r.map((i) => c(i)));
698
700
  }
699
701
  sole(e, t) {
700
702
  if (typeof e == "function") {
@@ -711,26 +713,26 @@ class L {
711
713
  return this.contains(...e);
712
714
  }
713
715
  sort(e) {
714
- return l(o(this, h).toSorted(e));
716
+ return c(o(this, h).toSorted(e));
715
717
  }
716
718
  sortBy(e, t = "asc") {
717
719
  if (typeof e == "function") {
718
720
  let r = -1;
719
- return l(o(this, h).toSorted((s, i) => (r++, e(s, r, this) - e(i, r, this))));
721
+ return c(o(this, h).toSorted((i, s) => (r++, e(i, r, this) - e(s, r, this))));
720
722
  }
721
723
  if (Array.isArray(e))
722
- return e.every((r) => Array.isArray(r)) ? l(o(this, h).toSorted((r, s) => {
723
- for (const [i, u] of e) {
724
- const a = r[i] ?? -1 / 0, c = s[i] ?? -1 / 0;
725
- if (a > c)
724
+ return e.every((r) => Array.isArray(r)) ? c(o(this, h).toSorted((r, i) => {
725
+ for (const [s, u] of e) {
726
+ const a = r[s] ?? -1 / 0, l = i[s] ?? -1 / 0;
727
+ if (a > l)
726
728
  return u === "asc" ? 1 : -1;
727
- if (a < c)
729
+ if (a < l)
728
730
  return u === "asc" ? -1 : 1;
729
731
  }
730
732
  return 0;
731
- })) : l(o(this, h).toSorted((r, s) => {
732
- for (const i of e) {
733
- const u = i(r, s);
733
+ })) : c(o(this, h).toSorted((r, i) => {
734
+ for (const s of e) {
735
+ const u = s(r, i);
734
736
  if (u !== 0)
735
737
  return u;
736
738
  }
@@ -738,31 +740,31 @@ class L {
738
740
  }));
739
741
  if (typeof e != "string")
740
742
  throw new TypeError("The key must be a string");
741
- return l(o(this, h).toSorted((r, s) => {
742
- const i = r[e] ?? -1 / 0, u = s[e] ?? -1 / 0;
743
- return i > u ? t === "asc" ? 1 : -1 : i < u ? t === "asc" ? -1 : 1 : 0;
743
+ return c(o(this, h).toSorted((r, i) => {
744
+ const s = r[e] ?? -1 / 0, u = i[e] ?? -1 / 0;
745
+ return s > u ? t === "asc" ? 1 : -1 : s < u ? t === "asc" ? -1 : 1 : 0;
744
746
  }));
745
747
  }
746
748
  sortDesc() {
747
749
  return this.sort((e, t) => e > t ? -1 : e < t ? 1 : 0);
748
750
  }
749
751
  splice(e, t, ...r) {
750
- const s = t === void 0 ? o(this, h).length : t, i = o(this, h).splice(e, s, ...r);
751
- return $(this), l(i);
752
+ const i = t === void 0 ? o(this, h).length : t, s = o(this, h).splice(e, i, ...r);
753
+ return T(this), c(s);
752
754
  }
753
755
  split(e) {
754
756
  const t = [];
755
757
  for (let r = 0; r < e; r++) {
756
- const s = o(this, h).slice(
758
+ const i = o(this, h).slice(
757
759
  t.flat().length,
758
760
  t.flat().length + Math.min(
759
761
  Math.ceil((o(this, h).length - t.flat().length) / (e - r)),
760
762
  o(this, h).length - t.flat().length
761
763
  )
762
764
  );
763
- t.push(l(s));
765
+ t.push(c(i));
764
766
  }
765
- return l(t);
767
+ return c(t);
766
768
  }
767
769
  splitIn(e) {
768
770
  const t = Math.ceil(o(this, h).length / e);
@@ -770,10 +772,10 @@ class L {
770
772
  }
771
773
  sum(e) {
772
774
  return typeof e == "string" ? o(this, h).reduce((t, r) => {
773
- const s = r[e];
774
- if (typeof s != "number")
775
+ const i = r[e];
776
+ if (typeof i != "number")
775
777
  throw new TypeError("The items must be numbers");
776
- return t + s;
778
+ return t + i;
777
779
  }, 0) : o(this, h).reduce((t, r) => {
778
780
  if (typeof r != "number")
779
781
  throw new TypeError("The items must be numbers");
@@ -781,7 +783,7 @@ class L {
781
783
  }, 0);
782
784
  }
783
785
  take(e) {
784
- return l(o(this, h).slice(0, e));
786
+ return c(o(this, h).slice(0, e));
785
787
  }
786
788
  takeUntil(e) {
787
789
  return typeof e == "function" ? this.take(o(this, h).findIndex((t, r) => e(t, r, this))) : this.take(o(this, h).findIndex((t) => t == e));
@@ -802,13 +804,13 @@ class L {
802
804
  transform(e) {
803
805
  for (const [t, r] of o(this, h).entries())
804
806
  o(this, h).splice(t, 1, e(r, t, this));
805
- return $(this), this;
807
+ return T(this), this;
806
808
  }
807
809
  unique(e) {
808
- return l(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((s, i) => s[e] == t[e] && i !== r)) : [...new Set(o(this, h))]);
810
+ return c(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((i, s) => i[e] == t[e] && s !== r)) : [...new Set(o(this, h))]);
809
811
  }
810
812
  uniqueStrict(e) {
811
- return l(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((s, i) => s[e] === t[e] && i !== r)) : [...new Set(o(this, h))]);
813
+ return c(typeof e == "string" ? o(this, h).filter((t, r) => !o(this, h).some((i, s) => i[e] === t[e] && s !== r)) : [...new Set(o(this, h))]);
812
814
  }
813
815
  unless(e, t, r) {
814
816
  return e ? typeof r == "function" && r(this) : t(this), this;
@@ -833,112 +835,117 @@ class L {
833
835
  }
834
836
  where(e, t, r) {
835
837
  if (typeof r > "u")
836
- return l(o(this, h).filter((i) => i[e] == t));
838
+ return c(o(this, h).filter((s) => s[e] == t));
837
839
  if (typeof t != "string")
838
840
  throw new TypeError("The operator must be a string");
839
841
  if (r === null)
840
- return l(o(this, h).filter((i) => i[e] === null));
841
- const s = {
842
- "=": (i) => i[e] == r,
843
- "!=": (i) => i[e] != r,
844
- ">": (i) => i[e] > r,
845
- "<": (i) => i[e] < r,
846
- ">=": (i) => i[e] >= r,
847
- "<=": (i) => i[e] <= r
842
+ return c(o(this, h).filter((s) => s[e] === null));
843
+ const i = {
844
+ "=": (s) => s[e] == r,
845
+ "!=": (s) => s[e] != r,
846
+ ">": (s) => s[e] > r,
847
+ "<": (s) => s[e] < r,
848
+ ">=": (s) => s[e] >= r,
849
+ "<=": (s) => s[e] <= r
848
850
  };
849
- if (!(t in s))
851
+ if (!(t in i))
850
852
  throw new Error("Unsupported operator");
851
- return l(o(this, h).filter((i, u) => s[t](i, u, this)));
853
+ return c(o(this, h).filter((s, u) => i[t](s, u, this)));
852
854
  }
853
855
  whereStrict(e, t, r) {
854
856
  if (typeof r > "u")
855
- return l(o(this, h).filter((i) => i[e] === t));
857
+ return c(o(this, h).filter((s) => s[e] === t));
856
858
  if (typeof t != "string")
857
859
  throw new TypeError("The operator must be a string");
858
860
  if (r === null)
859
- return l(o(this, h).filter((i) => i[e] === null));
860
- const s = {
861
- "=": (i) => i[e] === r,
862
- "!=": (i) => i[e] !== r,
863
- ">": (i) => i[e] > r,
864
- "<": (i) => i[e] < r,
865
- ">=": (i) => i[e] >= r,
866
- "<=": (i) => i[e] <= r
861
+ return c(o(this, h).filter((s) => s[e] === null));
862
+ const i = {
863
+ "=": (s) => s[e] === r,
864
+ "!=": (s) => s[e] !== r,
865
+ ">": (s) => s[e] > r,
866
+ "<": (s) => s[e] < r,
867
+ ">=": (s) => s[e] >= r,
868
+ "<=": (s) => s[e] <= r
867
869
  };
868
- if (!(t in s))
870
+ if (!(t in i))
869
871
  throw new Error("Unsupported operator");
870
- return l(o(this, h).filter((i, u) => s[t](i, u, this)));
872
+ return c(o(this, h).filter((s, u) => i[t](s, u, this)));
871
873
  }
872
874
  whereBetween(e, [t, r]) {
873
- return l(o(this, h).filter((s) => s[e] >= t && s[e] <= r));
875
+ return c(o(this, h).filter((i) => i[e] >= t && i[e] <= r));
874
876
  }
875
877
  whereIn(e, t) {
876
- return l(o(this, h).filter((r) => t.includes(r[e])));
878
+ return c(o(this, h).filter((r) => t.includes(r[e])));
877
879
  }
878
880
  whereInstanceOf(e) {
879
- return l(o(this, h).filter((t) => t instanceof e));
881
+ return c(o(this, h).filter((t) => t instanceof e));
880
882
  }
881
883
  whereNotBetween(e, [t, r]) {
882
- return l(o(this, h).filter((s) => s[e] < t || s[e] > r));
884
+ return c(o(this, h).filter((i) => i[e] < t || i[e] > r));
883
885
  }
884
886
  whereNotIn(e, t) {
885
- return l(o(this, h).filter((r) => !t.includes(r[e])));
887
+ return c(o(this, h).filter((r) => !t.includes(r[e])));
886
888
  }
887
889
  whereNotNull(e) {
888
- return l(o(this, h).filter((t) => t[e] !== null));
890
+ return c(o(this, h).filter((t) => t[e] !== null));
889
891
  }
890
892
  whereNull(e) {
891
- return l(o(this, h).filter((t) => t[e] === null));
893
+ return c(o(this, h).filter((t) => t[e] === null));
892
894
  }
893
895
  zip(e) {
894
- return Array.isArray(e) ? l(
896
+ return Array.isArray(e) ? c(
895
897
  o(this, h).map((t, r) => [t, e[r] ?? null])
896
- ) : l(
898
+ ) : c(
897
899
  o(this, h).map((t, r) => [t, e.get(r)])
898
900
  );
899
901
  }
900
902
  // HasEvents methods
901
903
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
902
904
  on(e, t) {
903
- throw new y();
905
+ throw new b();
904
906
  }
905
907
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
906
908
  once(e, t) {
907
- throw new y();
909
+ throw new b();
908
910
  }
909
911
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
910
912
  emit(e, t) {
911
- throw new y();
913
+ throw new b();
912
914
  }
913
915
  }
914
916
  h = new WeakMap();
915
- const J = A(L);
916
- class Q extends L {
917
- intersect(e) {
918
- return this.filter((t) => e.some((r) => r.getKey() === t.getKey()));
917
+ const C = A(Q);
918
+ var ee, te;
919
+ class W extends (te = Q, ee = Symbol.toStringTag, te) {
920
+ constructor() {
921
+ super(...arguments);
922
+ m(this, ee, "Collection");
923
+ }
924
+ intersect(t) {
925
+ return this.filter((r) => t.some((i) => i.getKey() === r.getKey()));
919
926
  }
920
927
  }
921
- p(Q, "name", "Collection");
922
- const S = (...n) => {
928
+ const v = (...n) => {
923
929
  const e = new URLSearchParams();
924
930
  return n.forEach((t) => {
925
931
  const [, ...r] = t.split("?");
926
- new URLSearchParams(r.join("")).forEach((i, u) => {
927
- e.set(u, i);
932
+ new URLSearchParams(r.join("")).forEach((s, u) => {
933
+ e.set(u, s);
928
934
  });
929
935
  }), e;
930
936
  };
931
- class ee extends Error {
932
- constructor(e) {
933
- super(`[Luminix] Model "${e}" does not have a primary key`);
937
+ var re, se;
938
+ class We extends (se = Error, re = Symbol.toStringTag, se) {
939
+ constructor(t) {
940
+ super(`[Luminix] Model "${t}" does not have a primary key`);
941
+ m(this, re, "ModelWithoutPrimaryKeyException");
934
942
  }
935
943
  }
936
- p(ee, "name", "ModelWithoutPrimaryKeyException");
937
- const xe = A(v);
938
- class _e {
944
+ const Ge = A(S);
945
+ class Ve {
939
946
  constructor(e, t, r = {}) {
940
- p(this, "bag");
941
- this.facades = e, this.abstract = t, this.query = r, this.bag = new xe(r), this.bag.on("change", () => {
947
+ m(this, "bag");
948
+ this.facades = e, this.abstract = t, this.query = r, this.bag = new Ge(r), this.bag.on("change", () => {
942
949
  this.emit("change", {
943
950
  data: this.bag
944
951
  });
@@ -946,15 +953,15 @@ class _e {
946
953
  }
947
954
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
948
955
  on(e, t) {
949
- throw new y();
956
+ throw new b();
950
957
  }
951
958
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
952
959
  once(e, t) {
953
- throw new y();
960
+ throw new b();
954
961
  }
955
962
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
956
963
  emit(e, t) {
957
- throw new y();
964
+ throw new b();
958
965
  }
959
966
  lock(e) {
960
967
  this.bag.lock(e);
@@ -981,7 +988,7 @@ class _e {
981
988
  return this.bag.set(`where.${f.camelCase(e)}`, t), this;
982
989
  if (typeof t != "string")
983
990
  throw new Error(`Invalid operator ${t} provided for where clause.`);
984
- const i = {
991
+ const s = {
985
992
  "=": "",
986
993
  "!=": "NotEquals",
987
994
  ">": "GreaterThan",
@@ -989,7 +996,22 @@ class _e {
989
996
  "<": "LessThan",
990
997
  "<=": "LessThanOrEquals"
991
998
  }[t] || f.upperFirst(f.camelCase(t));
992
- return this.bag.set(`where.${f.camelCase(e)}${i}`, r), this;
999
+ return this.bag.set(`where.${f.camelCase(e)}${s}`, r), this;
1000
+ }
1001
+ with(e) {
1002
+ const t = this.bag.get("with", []);
1003
+ return (Array.isArray(e) ? e : [e]).forEach((i) => {
1004
+ t.includes(i) || t.push(i);
1005
+ }), this.bag.set("with", t), this;
1006
+ }
1007
+ withOnly(e) {
1008
+ return this.bag.set("with", Array.isArray(e) ? e : [e]), this;
1009
+ }
1010
+ without(e) {
1011
+ const t = this.bag.get("with", []);
1012
+ return (Array.isArray(e) ? e : [e]).forEach((i) => {
1013
+ t.includes(i) && t.splice(t.indexOf(i), 1);
1014
+ }), this.bag.set("with", t), this;
993
1015
  }
994
1016
  orderBy(e, t = "asc") {
995
1017
  return this.bag.set("order_by", `${e}:${t}`), this;
@@ -1003,6 +1025,11 @@ class _e {
1003
1025
  unset(e) {
1004
1026
  return this.bag.delete(e), this;
1005
1027
  }
1028
+ include(e) {
1029
+ for (const [t, r] of e.entries())
1030
+ this.bag.set(t, r);
1031
+ return this;
1032
+ }
1006
1033
  async exec(e = 1, t) {
1007
1034
  try {
1008
1035
  this.bag.set("page", e), this.emit("submit", {
@@ -1011,36 +1038,36 @@ class _e {
1011
1038
  const { data: r } = await this.facades.route.call(`luminix.${this.abstract}.index`, {
1012
1039
  params: this.bag.all(),
1013
1040
  errorBag: `${this.abstract}.fetch`
1014
- }), s = this.facades.model.make(this.abstract), i = l(r.data.map((u) => {
1015
- const a = new s(u);
1041
+ }), i = this.facades.model.make(this.abstract), s = c(r.data.map((u) => {
1042
+ const a = new i(u);
1016
1043
  return a.exists = !0, this.facades.model.emit("fetch", {
1017
1044
  class: this.abstract,
1018
1045
  model: a
1019
1046
  }), a;
1020
- }), Q);
1047
+ }), W);
1021
1048
  if (t) {
1022
1049
  const [u] = t.split("?");
1023
1050
  return {
1024
1051
  ...r,
1025
- data: i,
1052
+ data: s,
1026
1053
  links: {
1027
- first: `${u}?${S(t, r.links.first).toString()}`,
1028
- last: `${u}?${S(t, r.links.last).toString()}`,
1029
- next: r.links.next && `${u}?${S(t, r.links.next).toString()}`,
1030
- prev: r.links.prev && `${u}?${S(t, r.links.prev).toString()}`
1054
+ first: `${u}?${v(t, r.links.first).toString()}`,
1055
+ last: `${u}?${v(t, r.links.last).toString()}`,
1056
+ next: r.links.next && `${u}?${v(t, r.links.next).toString()}`,
1057
+ prev: r.links.prev && `${u}?${v(t, r.links.prev).toString()}`
1031
1058
  },
1032
1059
  meta: {
1033
1060
  ...r.meta,
1034
1061
  links: r.meta.links.map((a) => ({
1035
1062
  ...a,
1036
- url: a.url && `${u}?${S(t, a.url).toString()}`
1063
+ url: a.url && `${u}?${v(t, a.url).toString()}`
1037
1064
  }))
1038
1065
  }
1039
1066
  };
1040
1067
  }
1041
1068
  return {
1042
1069
  ...r,
1043
- data: i
1070
+ data: s
1044
1071
  };
1045
1072
  } catch (r) {
1046
1073
  throw this.emit("error", {
@@ -1065,7 +1092,7 @@ class _e {
1065
1092
  async find(e) {
1066
1093
  const t = this.facades.model.schema(this.abstract).primaryKey;
1067
1094
  if (!t)
1068
- throw new ee(this.abstract);
1095
+ throw new We(this.abstract);
1069
1096
  const r = await this.where(t, e).limit(1).exec(1);
1070
1097
  return this.emit("success", {
1071
1098
  response: r,
@@ -1076,11 +1103,11 @@ class _e {
1076
1103
  const e = this.facades.config.get("luminix.backend.api.max_per_page", 150), t = await this.limit(e).exec(1), r = t.meta.last_page;
1077
1104
  if (r === 1)
1078
1105
  return t.data;
1079
- const s = Array.from({ length: r - 1 }, (a, c) => c + 2), i = await Promise.all(
1080
- s.map((a) => this.limit(e).exec(a))
1081
- ), u = l(
1082
- i.reduce((a, c) => (a.push(...c.data), a), t.data).all(),
1083
- Q
1106
+ const i = Array.from({ length: r - 1 }, (a, l) => l + 2), s = await Promise.all(
1107
+ i.map((a) => this.limit(e).exec(a))
1108
+ ), u = c(
1109
+ s.reduce((a, l) => (a.push(...l.data), a), t.data).all(),
1110
+ W
1084
1111
  );
1085
1112
  return this.emit("success", {
1086
1113
  response: {
@@ -1091,39 +1118,43 @@ class _e {
1091
1118
  }), u;
1092
1119
  }
1093
1120
  }
1094
- const Me = A(_e);
1095
- class M extends Error {
1096
- constructor(e) {
1097
- super(`[Luminix] Expected ${e} to be reducible.`);
1121
+ const Xe = A(Ve);
1122
+ var ie, ne;
1123
+ class _ extends (ne = Error, ie = Symbol.toStringTag, ne) {
1124
+ constructor(t) {
1125
+ super(`[Luminix] Expected ${t} to be reducible.`);
1126
+ m(this, ie, "NotReducibleException");
1098
1127
  }
1099
1128
  }
1100
- p(M, "name", "NotReducibleException");
1101
- class E extends TypeError {
1102
- constructor(e, t = "Model") {
1103
- super(`[Luminix] "${e}" expects ${t}`);
1129
+ var oe, he;
1130
+ class x extends (he = TypeError, oe = Symbol.toStringTag, he) {
1131
+ constructor(t, r = "Model") {
1132
+ super(`[Luminix] "${t}" expects ${r}`);
1133
+ m(this, oe, "NotModelException");
1104
1134
  }
1105
1135
  }
1106
- p(E, "name", "NotModelException");
1107
- class te extends Error {
1108
- constructor(e, t, r, s) {
1109
- super(`[Luminix] Could not determine inverse relation for "${t}" in model "${e}". Please specify a relation in model "${r}" of type ${s} that points back to "${e}".`);
1136
+ var ue, ae;
1137
+ class Ye extends (ae = Error, ue = Symbol.toStringTag, ae) {
1138
+ constructor(t, r, i, s) {
1139
+ super(`[Luminix] Could not determine inverse relation for "${r}" in model "${t}". Please specify a relation in model "${i}" of type ${s} that points back to "${t}".`);
1140
+ m(this, ue, "NoInverseRelationException");
1110
1141
  }
1111
1142
  }
1112
- p(te, "name", "NoInverseRelationException");
1113
- class re extends Error {
1114
- constructor(e) {
1115
- super(`[Luminix] Relation "${e}" is not supported`);
1143
+ var le, ce;
1144
+ class Ze extends (ce = Error, le = Symbol.toStringTag, ce) {
1145
+ constructor(t) {
1146
+ super(`[Luminix] Relation "${t}" is not supported`);
1147
+ m(this, le, "UnsupportedRelationException");
1116
1148
  }
1117
1149
  }
1118
- p(re, "name", "UnsupportedRelationException");
1119
- function w(n) {
1150
+ function E(n) {
1120
1151
  return typeof n == "object" && n !== null && n.__isModel === !0;
1121
1152
  }
1122
1153
  class j {
1123
- constructor(e, t, r, s = null) {
1124
- p(this, "unsubscribeQuery", null);
1125
- if (this.meta = e, this.facades = t, this.parent = r, this.items = s, s !== null && !w(s) && !(T(s) && s.every(w)))
1126
- throw new E("Relation.constructor()", "Model, Collection<Model> or null");
1154
+ constructor(e, t, r, i = null) {
1155
+ m(this, "unsubscribeQuery", null);
1156
+ if (this.meta = e, this.facades = t, this.parent = r, this.items = i, i !== null && !E(i) && !($(i) && i.every(E)))
1157
+ throw new x("Relation.constructor()", "Model, Collection<Model> or null");
1127
1158
  }
1128
1159
  make(e) {
1129
1160
  const t = this.getRelated();
@@ -1139,13 +1170,13 @@ class j {
1139
1170
  if (this.isMultiple()) {
1140
1171
  if (!Array.isArray(e))
1141
1172
  throw new TypeError("Relation.make() expects an array");
1142
- this.set(l(e.map((r) => new t(r))));
1173
+ this.set(c(e.map((r) => new t(r))));
1143
1174
  }
1144
1175
  }
1145
1176
  guessInverseRelation() {
1146
1177
  const { relations: e } = this.getRelated().getSchema();
1147
1178
  if (typeof this.facades.model.guessInverseRelation != "function")
1148
- throw new M("ModelFacade");
1179
+ throw new _("ModelFacade");
1149
1180
  const t = this.getType(), r = this.facades.model.guessInverseRelation({
1150
1181
  HasOne: ["BelongsTo"],
1151
1182
  HasMany: ["BelongsTo"],
@@ -1157,18 +1188,18 @@ class j {
1157
1188
  MorphToMany: ["MorphToMany"]
1158
1189
  }, this.parent, t, this.getRelated());
1159
1190
  if (!(t in r))
1160
- throw new re(t);
1161
- for (const s in e) {
1162
- const i = e[s];
1163
- if ((i.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(t)) && r[t].includes(i.type))
1164
- return s;
1191
+ throw new Ze(t);
1192
+ for (const i in e) {
1193
+ const s = e[i];
1194
+ if ((s.model === this.parent.getType() || ["MorphOne", "MorphMany"].includes(t)) && r[t].includes(s.type))
1195
+ return i;
1165
1196
  }
1166
- throw new te(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
1197
+ throw new Ye(this.parent.getType(), t, this.getRelated().getSchemaName(), r[t].join(" or "));
1167
1198
  }
1168
1199
  set(e) {
1169
- if (e !== null && !w(e) && !(T(e) && e.every(w)))
1170
- throw new E("Relation.set()", "Model, Collection<Model> or null");
1171
- !this.items || w(this.items) ? this.items = e : T(e) && this.items.splice(0, this.items.count(), ...e);
1200
+ if (e !== null && !E(e) && !($(e) && e.every(E)))
1201
+ throw new x("Relation.set()", "Model, Collection<Model> or null");
1202
+ !this.items || E(this.items) ? this.items = e : $(e) && this.items.splice(0, this.items.count(), ...e);
1172
1203
  }
1173
1204
  getForeignKey() {
1174
1205
  return this.meta.foreignKey;
@@ -1198,10 +1229,10 @@ class j {
1198
1229
  return this.items;
1199
1230
  }
1200
1231
  isSingle() {
1201
- return w(this.items);
1232
+ return E(this.items);
1202
1233
  }
1203
1234
  isMultiple() {
1204
- return T(this.items);
1235
+ return $(this.items);
1205
1236
  }
1206
1237
  getParent() {
1207
1238
  return this.parent;
@@ -1246,45 +1277,50 @@ class j {
1246
1277
  // return this.query().find(id);
1247
1278
  // }
1248
1279
  }
1249
- class U extends Error {
1250
- constructor(e, t) {
1251
- super(`[Luminix] Attribute "${t}" in model "${e}" is not fillable`);
1280
+ var de, fe;
1281
+ class Ne extends (fe = Error, de = Symbol.toStringTag, fe) {
1282
+ constructor(t, r) {
1283
+ super(`[Luminix] Attribute "${r}" in model "${t}" is not fillable`);
1284
+ m(this, de, "AttributeNotFillableException");
1252
1285
  }
1253
1286
  }
1254
- p(U, "name", "AttributeNotFillableException");
1255
- class D extends Error {
1256
- constructor(e, t) {
1257
- super(`[Luminix] Model "${e}" must be persisted before calling "${t}"`);
1287
+ var pe, me;
1288
+ class ve extends (me = Error, pe = Symbol.toStringTag, me) {
1289
+ constructor(t, r) {
1290
+ super(`[Luminix] Model "${t}" must be persisted before calling "${r}"`);
1291
+ m(this, pe, "ModelNotPersistedException");
1258
1292
  }
1259
1293
  }
1260
- p(D, "name", "ModelNotPersistedException");
1261
- function $e(n, e) {
1294
+ function ze(n, e) {
1295
+ var r;
1296
+ r = Symbol.toStringTag;
1262
1297
  class t {
1263
1298
  constructor(s = {}) {
1264
- p(this, "_attributes", new v({}));
1265
- p(this, "_original", {});
1266
- p(this, "_relations", {});
1267
- p(this, "_changedKeys", []);
1268
- p(this, "exists", !1);
1299
+ m(this, "_attributes", new S({}));
1300
+ m(this, "_original", {});
1301
+ m(this, "_relations", {});
1302
+ m(this, "_changedKeys", []);
1303
+ m(this, "exists", !1);
1304
+ m(this, r, f.upperFirst(f.camelCase(e)));
1269
1305
  this.makeRelations(), this.makeAttributes(s);
1270
1306
  }
1271
- cast(s, i) {
1272
- return s == null || !i ? s : ["boolean", "bool"].includes(i) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && typeof s == "string" ? new Date(s) : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(s) : s;
1307
+ cast(s, u) {
1308
+ return s == null || !u ? s : ["boolean", "bool"].includes(u) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(u) && typeof s == "string" ? new Date(s) : ["float", "double", "integer", "int"].includes(u) || u.startsWith("decimal:") ? Number(s) : s;
1273
1309
  }
1274
- mutate(s, i) {
1275
- return s == null || !i ? s : ["boolean", "bool"].includes(i) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(i) && s instanceof Date ? s.toISOString() : ["float", "double", "integer", "int"].includes(i) || i.startsWith("decimal:") ? Number(s) : s;
1310
+ mutate(s, u) {
1311
+ return s == null || !u ? s : ["boolean", "bool"].includes(u) ? !!s : ["date", "datetime", "immutable_date", "immutable_datetime"].includes(u) && s instanceof Date ? s.toISOString() : ["float", "double", "integer", "int"].includes(u) || u.startsWith("decimal:") ? Number(s) : s;
1276
1312
  }
1277
1313
  makeRelations() {
1278
1314
  const { relations: s } = n.model.schema(e);
1279
1315
  if (this._relations = {}, !s)
1280
1316
  return;
1281
1317
  if (typeof n.model.relationMap != "function")
1282
- throw new M("ModelFacade");
1283
- const i = n.model.relationMap({}, e);
1284
- Object.entries(s).forEach(([u, a]) => {
1285
- const { type: c } = a, d = c in i ? i[c] : j;
1286
- this._relations[u] = new d(
1287
- { name: u, ...a },
1318
+ throw new _("ModelFacade");
1319
+ const u = n.model.relationMap({}, e);
1320
+ Object.entries(s).forEach(([a, l]) => {
1321
+ const { type: d } = l, p = d in u ? u[d] : j;
1322
+ this._relations[a] = new p(
1323
+ { name: a, ...l },
1288
1324
  n,
1289
1325
  this,
1290
1326
  null
@@ -1292,12 +1328,12 @@ function $e(n, e) {
1292
1328
  });
1293
1329
  }
1294
1330
  makeAttributes(s) {
1295
- const { relations: i } = n.model.schema(e), u = Object.keys(i || {}), a = f.omit(s, u);
1296
- if (this.fillable.filter((c) => !(c in a)).forEach((c) => {
1297
- a[c] = null;
1298
- }), i && Object.keys(i).forEach((c) => {
1299
- this.relation(f.camelCase(c)).make(s[c]);
1300
- }), !this.validateJsonObject(a)) {
1331
+ const { relations: u } = n.model.schema(e), a = Object.keys(u || {}), l = f.omit(s, a);
1332
+ if (this.fillable.filter((d) => !(d in l)).forEach((d) => {
1333
+ l[d] = null;
1334
+ }), u && Object.keys(u).forEach((d) => {
1335
+ this.relation(f.camelCase(d)).make(s[d]);
1336
+ }), !this.validateJsonObject(l)) {
1301
1337
  if (n.config.get("app.env", "production") === "production")
1302
1338
  throw new TypeError(`[Luminix] Invalid attributes for model "${e}"`);
1303
1339
  n.log.warning(`Invalid attributes for model "${e}".
@@ -1306,7 +1342,7 @@ function $e(n, e) {
1306
1342
  abstract: e
1307
1343
  });
1308
1344
  }
1309
- this._attributes = new v(a), this._original = a, this._changedKeys = [];
1345
+ this._attributes = new S(l), this._original = l, this._changedKeys = [];
1310
1346
  }
1311
1347
  makePrimaryKeyReplacer() {
1312
1348
  return {
@@ -1360,23 +1396,23 @@ function $e(n, e) {
1360
1396
  model: this
1361
1397
  });
1362
1398
  }
1363
- dispatchErrorEvent(s, i) {
1399
+ dispatchErrorEvent(s, u) {
1364
1400
  this.emit("error", {
1365
1401
  error: s,
1366
- operation: i
1402
+ operation: u
1367
1403
  }), n.model.emit("error", {
1368
1404
  class: e,
1369
1405
  model: this,
1370
1406
  error: s,
1371
- operation: i
1407
+ operation: u
1372
1408
  });
1373
1409
  }
1374
1410
  updateChangedKeys(s) {
1375
- const i = (u, a) => typeof u == "object" && u !== null ? f.isEqual(u, a) : u == a;
1376
- !this._changedKeys.includes(s) && !i(this._original[s], this._attributes.get("key")) ? this._changedKeys.push(s) : this._changedKeys.includes(s) && i(this._original[s], this._attributes.get("key")) && this._changedKeys.splice(this._changedKeys.indexOf(s), 1);
1411
+ const u = (a, l) => typeof a == "object" && a !== null ? f.isEqual(a, l) : a == l;
1412
+ !this._changedKeys.includes(s) && !u(this._original[s], this._attributes.get("key")) ? this._changedKeys.push(s) : this._changedKeys.includes(s) && u(this._original[s], this._attributes.get("key")) && this._changedKeys.splice(this._changedKeys.indexOf(s), 1);
1377
1413
  }
1378
1414
  validateJsonObject(s) {
1379
- return typeof s != "object" || s === null ? !1 : Object.entries(s).every(([, i]) => ["boolean", "number", "string"].includes(typeof i) || i === null || this.validateJsonObject(i) || Array.isArray(i) && i.every((u) => this.validateJsonObject(u)));
1415
+ return typeof s != "object" || s === null ? !1 : Object.entries(s).every(([, u]) => ["boolean", "number", "string"].includes(typeof u) || u === null || this.validateJsonObject(u) || Array.isArray(u) && u.every((a) => this.validateJsonObject(a)));
1380
1416
  }
1381
1417
  get attributes() {
1382
1418
  return this._attributes.all();
@@ -1410,42 +1446,42 @@ function $e(n, e) {
1410
1446
  return this._changedKeys.length > 0;
1411
1447
  }
1412
1448
  getAttribute(s) {
1413
- let i = this._attributes.get(s, null);
1414
- s in this.casts && (i = this.cast(i, this.casts[s]));
1415
- const u = n.model[`model${f.upperFirst(f.camelCase(e))}Get${f.upperFirst(f.camelCase(s))}Attribute`];
1416
- if (typeof u != "function")
1417
- throw new M("ModelFacade");
1418
- return u.bind(n.model)(i, this);
1419
- }
1420
- setAttribute(s, i) {
1449
+ let u = this._attributes.get(s, null);
1450
+ s in this.casts && (u = this.cast(u, this.casts[s]));
1451
+ const a = n.model[`model${f.upperFirst(f.camelCase(e))}Get${f.upperFirst(f.camelCase(s))}Attribute`];
1452
+ if (typeof a != "function")
1453
+ throw new _("ModelFacade");
1454
+ return a.bind(n.model)(u, this);
1455
+ }
1456
+ setAttribute(s, u) {
1421
1457
  if (!this.fillable.includes(s)) {
1422
1458
  if (n.config.get("app.env", "production") === "production")
1423
- throw new U(e, s);
1459
+ throw new Ne(e, s);
1424
1460
  n.log.warning(`[Luminix] Trying to set a non-fillable attribute "${s}" in model "${e}".
1425
1461
  This will throw an error in production.`);
1426
1462
  return;
1427
1463
  }
1428
- const u = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(s))}Attribute`];
1429
- if (typeof u != "function")
1430
- throw new M("ModelFacade");
1431
- const a = u.bind(n.model)(
1432
- this.mutate(i, this.casts[s]),
1464
+ const a = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(s))}Attribute`];
1465
+ if (typeof a != "function")
1466
+ throw new _("ModelFacade");
1467
+ const l = a.bind(n.model)(
1468
+ this.mutate(u, this.casts[s]),
1433
1469
  this
1434
1470
  );
1435
- if (!this.validateJsonObject({ [s]: a })) {
1471
+ if (!this.validateJsonObject({ [s]: l })) {
1436
1472
  if (n.config.get("app.env", "production") === "production")
1437
1473
  throw new TypeError(`[Luminix] Attribute "${s}" in model "${e}" must be a boolean, number, string or null`);
1438
1474
  n.log.warning(`Invalid type for attribute "${s}" in model "${e}" after mutation.
1439
1475
  This will throw an error in production.`, {
1440
1476
  key: s,
1441
- value: i,
1442
- mutated: a,
1477
+ value: u,
1478
+ mutated: l,
1443
1479
  cast: this.casts[s],
1444
1480
  item: this.toJson()
1445
1481
  });
1446
1482
  return;
1447
1483
  }
1448
- this._attributes.set(s, a), this.updateChangedKeys(s), this.dispatchChangeEvent({ [s]: a });
1484
+ this._attributes.set(s, l), this.updateChangedKeys(s), this.dispatchChangeEvent({ [s]: l });
1449
1485
  }
1450
1486
  getKey() {
1451
1487
  return this.getAttribute(this.primaryKey);
@@ -1454,28 +1490,28 @@ function $e(n, e) {
1454
1490
  return this.primaryKey;
1455
1491
  }
1456
1492
  fill(s) {
1457
- const i = f.pick(s, this.fillable), u = Object.entries(i).reduce((a, [c, d]) => {
1458
- const g = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(c))}Attribute`];
1459
- if (typeof g != "function")
1460
- throw new M("ModelFacade");
1461
- return a[c] = g.bind(n.model)(
1462
- this.mutate(d, this.casts[c]),
1493
+ const u = f.pick(s, this.fillable), a = Object.entries(u).reduce((l, [d, p]) => {
1494
+ const y = n.model[`model${f.upperFirst(f.camelCase(e))}Set${f.upperFirst(f.camelCase(d))}Attribute`];
1495
+ if (typeof y != "function")
1496
+ throw new _("ModelFacade");
1497
+ return l[d] = y.bind(n.model)(
1498
+ this.mutate(p, this.casts[d]),
1463
1499
  this
1464
- ), a;
1500
+ ), l;
1465
1501
  }, {});
1466
- if (!this.validateJsonObject(u)) {
1502
+ if (!this.validateJsonObject(a)) {
1467
1503
  if (n.config.get("app.env", "production") === "production")
1468
1504
  throw new TypeError(`[Luminix] Invalid attributes for model "${e}"`);
1469
1505
  n.log.warning(`Invalid attributes for model "${e}" after mutation.
1470
1506
  This will throw an error in production.`, {
1471
1507
  attributes: s,
1472
- mutatedAttributes: u,
1508
+ mutatedAttributes: a,
1473
1509
  item: this.toJson(),
1474
1510
  casts: this.casts
1475
1511
  });
1476
1512
  return;
1477
1513
  }
1478
- this._attributes.merge(".", u), Object.keys(u).forEach((a) => this.updateChangedKeys(a)), this.dispatchChangeEvent(u);
1514
+ this._attributes.merge(".", a), Object.keys(a).forEach((l) => this.updateChangedKeys(l)), this.dispatchChangeEvent(a);
1479
1515
  }
1480
1516
  dump() {
1481
1517
  n.log.info({
@@ -1484,16 +1520,16 @@ function $e(n, e) {
1484
1520
  });
1485
1521
  }
1486
1522
  toJson() {
1487
- const s = Object.entries(this.relations).reduce((u, [a, c]) => (c.isLoaded() && (c.isSingle() ? u[f.snakeCase(a)] = c.getLoadedItems().toJson() : c.isMultiple() && (u[f.snakeCase(a)] = c.getLoadedItems().map((d) => d.toJson()).all())), u), {}), i = n.model[`model${f.upperFirst(f.camelCase(e))}Json`];
1488
- if (typeof i != "function")
1489
- throw new M("ModelFacade");
1490
- return i.bind(n.model)({
1523
+ const s = Object.entries(this.relations).reduce((a, [l, d]) => (d.isLoaded() && (d.isSingle() ? a[f.snakeCase(l)] = d.getLoadedItems().toJson() : d.isMultiple() && (a[f.snakeCase(l)] = d.getLoadedItems().map((p) => p.toJson()).all())), a), {}), u = n.model[`model${f.upperFirst(f.camelCase(e))}Json`];
1524
+ if (typeof u != "function")
1525
+ throw new _("ModelFacade");
1526
+ return u.bind(n.model)({
1491
1527
  ...this.attributes,
1492
1528
  ...s
1493
1529
  }, this);
1494
1530
  }
1495
1531
  diff() {
1496
- return this._changedKeys.reduce((s, i) => (s[i] = this._attributes.get(i), s), {});
1532
+ return this._changedKeys.reduce((s, u) => (s[u] = this._attributes.get(u), s), {});
1497
1533
  }
1498
1534
  getType() {
1499
1535
  return e;
@@ -1504,7 +1540,7 @@ function $e(n, e) {
1504
1540
  }
1505
1541
  async refresh() {
1506
1542
  if (!this.exists)
1507
- throw new D(e, "refresh");
1543
+ throw new ve(e, "refresh");
1508
1544
  const { data: s } = await n.route.call([
1509
1545
  `luminix.${e}.show`,
1510
1546
  this.makePrimaryKeyReplacer()
@@ -1516,33 +1552,33 @@ function $e(n, e) {
1516
1552
  async save(s = {}) {
1517
1553
  try {
1518
1554
  const {
1519
- additionalPayload: i = {},
1520
- sendsOnlyModifiedFields: u = !0
1521
- } = s, a = this.exists, c = a ? [
1555
+ additionalPayload: u = {},
1556
+ sendsOnlyModifiedFields: a = !0
1557
+ } = s, l = this.exists, d = l ? [
1522
1558
  `luminix.${e}.update`,
1523
1559
  this.makePrimaryKeyReplacer()
1524
- ] : `luminix.${e}.store`, d = await n.route.call(
1525
- c,
1560
+ ] : `luminix.${e}.store`, p = await n.route.call(
1561
+ d,
1526
1562
  {
1527
1563
  data: {
1528
1564
  ...f.pick(
1529
- u && a ? this.diff() : this.attributes,
1565
+ a && l ? this.diff() : this.attributes,
1530
1566
  this.fillable
1531
1567
  ),
1532
- ...i
1568
+ ...u
1533
1569
  },
1534
- errorBag: a ? `${e}[${this.getKey()}].update` : `${e}.store`
1570
+ errorBag: l ? `${e}[${this.getKey()}].update` : `${e}.store`
1535
1571
  }
1536
1572
  );
1537
- if ([200, 201].includes(d.status))
1538
- return this.makeAttributes(d.data), this.exists = !0, this.dispatchSaveEvent(), a ? this.dispatchUpdateEvent(d.data) : this.dispatchCreateEvent(d.data), d;
1539
- throw d;
1540
- } catch (i) {
1541
- throw n.log.error(i), this.dispatchErrorEvent(i, "save"), i;
1573
+ if ([200, 201].includes(p.status))
1574
+ return this.makeAttributes(p.data), this.exists = !0, this.dispatchSaveEvent(), l ? this.dispatchUpdateEvent(p.data) : this.dispatchCreateEvent(p.data), p;
1575
+ throw p;
1576
+ } catch (u) {
1577
+ throw n.log.error(u), this.dispatchErrorEvent(u, "save"), u;
1542
1578
  }
1543
1579
  }
1544
1580
  async push() {
1545
- throw new y();
1581
+ throw new b();
1546
1582
  }
1547
1583
  async delete() {
1548
1584
  try {
@@ -1561,20 +1597,20 @@ function $e(n, e) {
1561
1597
  }
1562
1598
  async update(s) {
1563
1599
  try {
1564
- const i = await n.route.call([
1600
+ const u = await n.route.call([
1565
1601
  `luminix.${e}.update`,
1566
1602
  this.makePrimaryKeyReplacer()
1567
1603
  ], {
1568
1604
  data: s,
1569
1605
  errorBag: `${e}[${this.getKey()}].update`
1570
1606
  });
1571
- if (i.status === 200) {
1572
- this.makeAttributes(i.data), this.dispatchUpdateEvent(i.data);
1607
+ if (u.status === 200) {
1608
+ this.makeAttributes(u.data), this.dispatchUpdateEvent(u.data);
1573
1609
  return;
1574
1610
  }
1575
- throw i;
1576
- } catch (i) {
1577
- throw n.log.error(i), this.dispatchErrorEvent(i, "save"), i;
1611
+ throw u;
1612
+ } catch (u) {
1613
+ throw n.log.error(u), this.dispatchErrorEvent(u, "save"), u;
1578
1614
  }
1579
1615
  }
1580
1616
  async forceDelete() {
@@ -1622,7 +1658,7 @@ function $e(n, e) {
1622
1658
  return n.model.schema(e);
1623
1659
  }
1624
1660
  static query() {
1625
- return new Me(n, e);
1661
+ return new Xe(n, e);
1626
1662
  }
1627
1663
  static where(...s) {
1628
1664
  return this.query().where(...s);
@@ -1633,14 +1669,14 @@ function $e(n, e) {
1633
1669
  static whereNotNull(s) {
1634
1670
  return this.query().whereNotNull(s);
1635
1671
  }
1636
- static whereBetween(s, i) {
1637
- return this.query().whereBetween(s, i);
1672
+ static whereBetween(s, u) {
1673
+ return this.query().whereBetween(s, u);
1638
1674
  }
1639
- static whereNotBetween(s, i) {
1640
- return this.query().whereNotBetween(s, i);
1675
+ static whereNotBetween(s, u) {
1676
+ return this.query().whereNotBetween(s, u);
1641
1677
  }
1642
- static orderBy(s, i = "asc") {
1643
- return this.query().orderBy(s, i);
1678
+ static orderBy(s, u = "asc") {
1679
+ return this.query().orderBy(s, u);
1644
1680
  }
1645
1681
  static searchBy(s) {
1646
1682
  return this.query().searchBy(s);
@@ -1651,8 +1687,8 @@ function $e(n, e) {
1651
1687
  static limit(s) {
1652
1688
  return this.query().limit(s);
1653
1689
  }
1654
- static get(s = 1, i) {
1655
- return this.query().get(s, i);
1690
+ static get(s = 1, u) {
1691
+ return this.query().get(s, u);
1656
1692
  }
1657
1693
  static find(s) {
1658
1694
  return this.query().find(s);
@@ -1661,12 +1697,12 @@ function $e(n, e) {
1661
1697
  return this.query().first();
1662
1698
  }
1663
1699
  static async create(s) {
1664
- const i = n.model.make(e), u = new i();
1665
- return u.fill(s), await u.save(), u;
1700
+ const u = n.model.make(e), a = new u();
1701
+ return a.fill(s), await a.save(), a;
1666
1702
  }
1667
- static async update(s, i) {
1668
- const u = n.model.make(e), a = new u({ id: s });
1669
- return a.fill(i), a.exists = !0, await a.save(), a;
1703
+ static async update(s, u) {
1704
+ const a = n.model.make(e), l = new a({ id: s });
1705
+ return l.fill(u), l.exists = !0, await l.save(), l;
1670
1706
  }
1671
1707
  static delete(s) {
1672
1708
  if (Array.isArray(s))
@@ -1674,8 +1710,8 @@ function $e(n, e) {
1674
1710
  params: { ids: s },
1675
1711
  errorBag: `${e}.deleteMany`
1676
1712
  });
1677
- const i = n.model.make(e);
1678
- return new i({ id: s }).delete();
1713
+ const u = n.model.make(e);
1714
+ return new u({ id: s }).delete();
1679
1715
  }
1680
1716
  static async restore(s) {
1681
1717
  if (Array.isArray(s))
@@ -1683,8 +1719,8 @@ function $e(n, e) {
1683
1719
  data: { ids: s },
1684
1720
  errorBag: `${e}.restoreMany`
1685
1721
  });
1686
- const i = n.model.make(e);
1687
- return new i({ id: s }).restore();
1722
+ const u = n.model.make(e);
1723
+ return new u({ id: s }).restore();
1688
1724
  }
1689
1725
  static forceDelete(s) {
1690
1726
  if (Array.isArray(s))
@@ -1692,8 +1728,8 @@ function $e(n, e) {
1692
1728
  params: { ids: s, force: !0 },
1693
1729
  errorBag: `${e}.forceDeleteMany`
1694
1730
  });
1695
- const i = n.model.make(e);
1696
- return new i({ id: s }).forceDelete();
1731
+ const u = n.model.make(e);
1732
+ return new u({ id: s }).forceDelete();
1697
1733
  }
1698
1734
  static singular() {
1699
1735
  return n.model.schema(e).displayName.singular;
@@ -1702,94 +1738,97 @@ function $e(n, e) {
1702
1738
  return n.model.schema(e).displayName.plural;
1703
1739
  }
1704
1740
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1705
- on(s, i) {
1706
- throw new y();
1741
+ on(s, u) {
1742
+ throw new b();
1707
1743
  }
1708
1744
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1709
- once(s, i) {
1710
- throw new y();
1745
+ once(s, u) {
1746
+ throw new b();
1711
1747
  }
1712
1748
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1713
- emit(s, i) {
1714
- throw new y();
1749
+ emit(s, u) {
1750
+ throw new b();
1715
1751
  }
1716
1752
  }
1717
- return p(t, "name", f.upperFirst(f.camelCase(e))), A(t);
1753
+ return A(t);
1718
1754
  }
1719
- function Te(n, e, t) {
1720
- var r;
1721
- return r = class extends t {
1722
- constructor(s = {}) {
1723
- return super(s), new Proxy(this, {
1724
- get: (i, u) => {
1725
- if (u === "__isModel")
1755
+ function Oe(n, e, t) {
1756
+ var r, i;
1757
+ return class extends (i = t, r = Symbol.toStringTag, i) {
1758
+ constructor(u = {}) {
1759
+ super(u);
1760
+ m(this, r, f.upperFirst(f.camelCase(e)));
1761
+ return new Proxy(this, {
1762
+ get: (a, l) => {
1763
+ if (l === "__isModel")
1726
1764
  return !0;
1727
- if (u in i) {
1728
- const c = i[u];
1729
- return typeof c == "function" ? c.bind(i) : c;
1765
+ if (l in a) {
1766
+ const p = a[l];
1767
+ return typeof p == "function" ? p.bind(a) : p;
1730
1768
  }
1731
- if (u !== f.camelCase(u))
1769
+ if (l !== f.camelCase(l))
1732
1770
  return;
1733
- const a = f.snakeCase(u);
1734
- if (Object.keys(i.relations).includes(a))
1735
- return i.relations[a].getLoadedItems();
1736
- if (u.endsWith("Relation") && Object.keys(i.relations).includes(f.snakeCase(u.slice(0, -8))))
1737
- return () => i.relation(u.slice(0, -8));
1738
- if (Object.keys(i.attributes).includes(a))
1739
- return i.getAttribute(a);
1740
- if (n.model.hasReducer(`model${i.constructor.name}Get${f.upperFirst(u)}Attribute`)) {
1741
- const c = n.model[`model${i.constructor.name}Get${f.upperFirst(u)}Attribute`];
1742
- if (typeof c != "function")
1743
- throw new M("ModelFacade");
1744
- return c.bind(n.model)(void 0, i);
1771
+ const d = f.snakeCase(l);
1772
+ if (Object.keys(a.relations).includes(d))
1773
+ return a.relations[d].getLoadedItems();
1774
+ if (l.endsWith("Relation") && Object.keys(a.relations).includes(f.snakeCase(l.slice(0, -8))))
1775
+ return () => a.relation(l.slice(0, -8));
1776
+ if (Object.keys(a.attributes).includes(d))
1777
+ return a.getAttribute(d);
1778
+ if (n.model.hasReducer(`model${a.constructor.name}Get${f.upperFirst(l)}Attribute`)) {
1779
+ const p = n.model[`model${a.constructor.name}Get${f.upperFirst(l)}Attribute`];
1780
+ if (typeof p != "function")
1781
+ throw new _("ModelFacade");
1782
+ return p.bind(n.model)(void 0, a);
1745
1783
  }
1746
- return Reflect.get(i, u);
1784
+ return Reflect.get(a, l);
1747
1785
  },
1748
- set: (i, u, a) => {
1749
- if (u in i && typeof i[u] != "function")
1750
- return Reflect.set(i, u, a);
1751
- if (i.fillable.includes(f.snakeCase(u)))
1752
- return i.setAttribute(
1753
- f.snakeCase(u),
1754
- a
1786
+ set: (a, l, d) => {
1787
+ if (l in a && typeof a[l] != "function")
1788
+ return Reflect.set(a, l, d);
1789
+ if (a.fillable.includes(f.snakeCase(l)))
1790
+ return a.setAttribute(
1791
+ f.snakeCase(l),
1792
+ d
1755
1793
  ), !0;
1756
- throw new U(e, f.snakeCase(u));
1794
+ throw new Ne(e, f.snakeCase(l));
1757
1795
  }
1758
1796
  });
1759
1797
  }
1760
- }, p(r, "name", f.upperFirst(f.camelCase(e))), r;
1798
+ };
1761
1799
  }
1762
- class se extends Error {
1763
- constructor(e, t) {
1764
- super(`[Luminix] Cannot create reducer '${e}' on '${t}' as it is a reserved property`);
1800
+ var ge, ye;
1801
+ class ke extends (ye = Error, ge = Symbol.toStringTag, ye) {
1802
+ constructor(t, r) {
1803
+ super(`[Luminix] Cannot create reducer '${t}' on '${r}' as it is a reserved property`);
1804
+ m(this, ge, "ReducerOverrideException");
1765
1805
  }
1766
1806
  }
1767
- p(se, "name", "ReducerOverrideException");
1768
- function ie(n) {
1807
+ function Re(n) {
1769
1808
  return class extends n {
1770
1809
  constructor(...t) {
1771
1810
  super(...t);
1772
- p(this, "reducers", {});
1811
+ m(this, "reducers", {});
1773
1812
  return new Proxy(this, {
1774
- get(r, s, i) {
1775
- return typeof s == "symbol" || s in r ? Reflect.get(r, s, i) : (u, ...a) => {
1776
- const { [s]: c = l() } = r.reducers;
1777
- return ye(u) ? B(u, (d) => c.sortBy("priority").reduce((g, b) => b.callback(g, ...a), d)) : c.sortBy("priority").reduce((d, g) => g.callback(d, ...a), u);
1813
+ get(r, i, s) {
1814
+ return typeof i == "symbol" || i in r ? Reflect.get(r, i, s) : (u, ...a) => {
1815
+ const { [i]: l = c() } = r.reducers;
1816
+ return Le(u) ? R(u, (d) => l.sortBy("priority").reduce((p, y) => y.callback(p, ...a), d)) : l.sortBy("priority").reduce((d, p) => p.callback(d, ...a), u);
1778
1817
  };
1779
1818
  }
1780
1819
  });
1781
1820
  }
1782
- reducer(t, r, s = 10) {
1821
+ reducer(t, r, i = 10) {
1783
1822
  if (t in this)
1784
- throw new se(t, this);
1785
- return this.reducers[t] || (this.reducers[t] = l()), this.reducers[t].push({ callback: r, priority: s }), () => this.removeReducer(t, r);
1823
+ throw new ke(t, this);
1824
+ return this.reducers[t] || (this.reducers[t] = c()), this.reducers[t].push({ callback: r, priority: i }), () => this.removeReducer(t, r);
1786
1825
  }
1787
1826
  removeReducer(t, r) {
1788
- const s = this.reducers[t].search((i) => i.callback === r);
1789
- s !== !1 && this.reducers[t].pull(s);
1827
+ const i = this.reducers[t].search((s) => s.callback === r);
1828
+ i !== !1 && this.reducers[t].pull(i);
1790
1829
  }
1791
1830
  getReducer(t) {
1792
- return this.reducers[t] || (this.reducers[t] = l()), this.reducers[t];
1831
+ return this.reducers[t] || (this.reducers[t] = c()), this.reducers[t];
1793
1832
  }
1794
1833
  hasReducer(t) {
1795
1834
  return !!this.reducers[t] && this.reducers[t].count() > 0;
@@ -1802,23 +1841,25 @@ function ie(n) {
1802
1841
  }
1803
1842
  };
1804
1843
  }
1805
- class C extends Error {
1806
- constructor(e) {
1807
- super(`[Luminix] Model "${e}" not found`);
1844
+ var we, be;
1845
+ class G extends (be = Error, we = Symbol.toStringTag, be) {
1846
+ constructor(t) {
1847
+ super(`[Luminix] Model "${t}" not found`);
1848
+ m(this, we, "ModelNotFoundException");
1808
1849
  }
1809
1850
  }
1810
- p(C, "name", "ModelNotFoundException");
1811
- class N extends TypeError {
1812
- constructor(e, t, r) {
1813
- super(`[Luminix] "${e}" expects a related model of type "${t}". Received "${r}" instead.`);
1851
+ var Ee, xe;
1852
+ class B extends (xe = TypeError, Ee = Symbol.toStringTag, xe) {
1853
+ constructor(t, r, i) {
1854
+ super(`[Luminix] "${t}" expects a related model of type "${r}". Received "${i}" instead.`);
1855
+ m(this, Ee, "ModelInvalidRelatedTypeException");
1814
1856
  }
1815
1857
  }
1816
- p(N, "name", "ModelInvalidRelatedTypeException");
1817
- class ne extends j {
1818
- constructor(e, t, r, s = null) {
1819
- if (!w(s) && s !== null)
1820
- throw new E("BelongsTo.constructor()", "Model or null");
1821
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1858
+ class Be extends j {
1859
+ constructor(e, t, r, i = null) {
1860
+ if (!E(i) && i !== null)
1861
+ throw new x("BelongsTo.constructor()", "Model or null");
1862
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
1822
1863
  }
1823
1864
  isSingle() {
1824
1865
  return !0;
@@ -1834,12 +1875,12 @@ class ne extends j {
1834
1875
  return this.query().first();
1835
1876
  }
1836
1877
  async associate(e) {
1837
- if (!w(e))
1838
- throw new E("BelongsTo.associate()");
1878
+ if (!E(e))
1879
+ throw new x("BelongsTo.associate()");
1839
1880
  if (e.getType() !== this.getRelated().getSchemaName())
1840
- throw new N("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
1881
+ throw new B("BelongsTo.associate()", this.getRelated().getSchemaName(), e.getType());
1841
1882
  if (!e.exists)
1842
- throw new D(this.getRelated().getSchemaName(), "save");
1883
+ throw new ve(this.getRelated().getSchemaName(), "save");
1843
1884
  return this.parent.update({
1844
1885
  [this.getForeignKey()]: e.getKey()
1845
1886
  });
@@ -1850,11 +1891,11 @@ class ne extends j {
1850
1891
  });
1851
1892
  }
1852
1893
  }
1853
- class oe extends j {
1854
- constructor(e, t, r, s = null) {
1855
- if (s !== null && !(s instanceof J && s.every(w)))
1856
- throw new E("BelongsToMany.constructor()", "Collection<Model> or null");
1857
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
1894
+ class qe extends j {
1895
+ constructor(e, t, r, i = null) {
1896
+ if (i !== null && !(i instanceof C && i.every(E)))
1897
+ throw new x("BelongsToMany.constructor()", "Collection<Model> or null");
1898
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
1858
1899
  }
1859
1900
  isSingle() {
1860
1901
  return !1;
@@ -1892,10 +1933,10 @@ class oe extends j {
1892
1933
  }
1893
1934
  async attach(e, t = {}) {
1894
1935
  if (await this.attachQuietly(e, t), this.items) {
1895
- const r = this.items.search((i) => i.getKey() === e), s = await this.getRelated().find(e);
1896
- if (!s)
1936
+ const r = this.items.search((s) => s.getKey() === e), i = await this.getRelated().find(e);
1937
+ if (!i)
1897
1938
  return;
1898
- r !== !1 ? this.items.put(r, s) : this.items.push(s);
1939
+ r !== !1 ? this.items.put(r, i) : this.items.push(i);
1899
1940
  } else
1900
1941
  this.items = await this.all();
1901
1942
  }
@@ -1955,24 +1996,24 @@ class oe extends j {
1955
1996
  this.items ? this.items.splice(0, this.items.count(), ...r) : this.items = r;
1956
1997
  }
1957
1998
  }
1958
- class H extends j {
1999
+ class L extends j {
1959
2000
  query() {
1960
2001
  const e = super.query(), t = this.guessInverseRelation();
1961
2002
  return e.where(t, this.parent.getKey()), e.lock(`where.${t}`), e;
1962
2003
  }
1963
2004
  async saveQuietly(e) {
1964
- if (!w(e))
1965
- throw new E("HasOneOrMany.saveQuietly()");
2005
+ if (!E(e))
2006
+ throw new x("HasOneOrMany.saveQuietly()");
1966
2007
  if (e.getType() !== this.getRelated().getSchemaName())
1967
- throw new N("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
2008
+ throw new B("HasOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
1968
2009
  e.setAttribute(this.getForeignKey(), this.parent.getKey()), await e.save();
1969
2010
  }
1970
2011
  }
1971
- class Ae extends H {
1972
- constructor(e, t, r, s = null) {
1973
- if (!w(s) && s !== null)
1974
- throw new E("HasOne.constructor()", "Model or null");
1975
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2012
+ class et extends L {
2013
+ constructor(e, t, r, i = null) {
2014
+ if (!E(i) && i !== null)
2015
+ throw new x("HasOne.constructor()", "Model or null");
2016
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
1976
2017
  }
1977
2018
  isSingle() {
1978
2019
  return !0;
@@ -1987,11 +2028,11 @@ class Ae extends H {
1987
2028
  await this.saveQuietly(e), this.items = e;
1988
2029
  }
1989
2030
  }
1990
- class ve extends H {
1991
- constructor(e, t, r, s = null) {
1992
- if (s !== null && !(s instanceof J && s.every(w)))
1993
- throw new E("HasMany.constructor()", "Collection<Model> or null");
1994
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2031
+ class tt extends L {
2032
+ constructor(e, t, r, i = null) {
2033
+ if (i !== null && !(i instanceof C && i.every(E)))
2034
+ throw new x("HasMany.constructor()", "Collection<Model> or null");
2035
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
1995
2036
  }
1996
2037
  isSingle() {
1997
2038
  return !1;
@@ -2012,10 +2053,10 @@ class ve extends H {
2012
2053
  return this.query().find(e);
2013
2054
  }
2014
2055
  async saveManyQuietly(e) {
2015
- if (!Array.isArray(e) || !e.every(w))
2016
- throw new E("HasMany.saveManyQuietly()", "Model[]");
2056
+ if (!Array.isArray(e) || !e.every(E))
2057
+ throw new x("HasMany.saveManyQuietly()", "Model[]");
2017
2058
  if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
2018
- throw new N("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2059
+ throw new B("HasMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2019
2060
  await Promise.all(e.map((t) => (t.setAttribute(this.getForeignKey(), this.parent.getKey()), t.save())));
2020
2061
  }
2021
2062
  async saveMany(e) {
@@ -2027,7 +2068,7 @@ class ve extends H {
2027
2068
  await this.saveQuietly(e), this.items === null ? this.items = await this.all() : this.items.push(e);
2028
2069
  }
2029
2070
  }
2030
- class he extends H {
2071
+ class Ie extends L {
2031
2072
  query() {
2032
2073
  const e = this.getRelated().query();
2033
2074
  e.once("success", (r) => {
@@ -2037,19 +2078,19 @@ class he extends H {
2037
2078
  return e.where(t + "_id", this.parent.getKey()), e.where(t + "_type", this.getRelated().getSchemaName()), e.lock(`where.${t}_id`), e.lock(`where.${t}_type`), e;
2038
2079
  }
2039
2080
  async saveQuietly(e) {
2040
- if (!w(e))
2041
- throw new E("MorphOneOrMany.saveQuietly()");
2081
+ if (!E(e))
2082
+ throw new x("MorphOneOrMany.saveQuietly()");
2042
2083
  if (e.getType() !== this.getRelated().getSchemaName())
2043
- throw new N("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
2084
+ throw new B("MorphOneOrMany.saveQuietly()", this.getRelated().getSchemaName(), e.getType());
2044
2085
  const t = this.guessInverseRelation();
2045
2086
  e.setAttribute(t + "_id", this.parent.getKey()), e.setAttribute(t + "_type", this.parent.getType()), await e.save();
2046
2087
  }
2047
2088
  }
2048
- class Re extends he {
2049
- constructor(e, t, r, s = null) {
2050
- if (s !== null && !(s instanceof J && s.every(w)))
2051
- throw new E("MorphMany.constructor()", "Collection<Model> or null");
2052
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2089
+ class rt extends Ie {
2090
+ constructor(e, t, r, i = null) {
2091
+ if (i !== null && !(i instanceof C && i.every(E)))
2092
+ throw new x("MorphMany.constructor()", "Collection<Model> or null");
2093
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
2053
2094
  }
2054
2095
  isSingle() {
2055
2096
  return !1;
@@ -2070,10 +2111,10 @@ class Re extends he {
2070
2111
  return this.query().find(e);
2071
2112
  }
2072
2113
  async saveManyQuietly(e) {
2073
- if (!Array.isArray(e) || !e.every(w))
2074
- throw new E("MorphMany.saveManyQuietly()");
2114
+ if (!Array.isArray(e) || !e.every(E))
2115
+ throw new x("MorphMany.saveManyQuietly()");
2075
2116
  if (!e.every((t) => t.getType() === this.getRelated().getSchemaName()))
2076
- throw new N("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2117
+ throw new B("MorphMany.saveManyQuietly()", this.getRelated().getSchemaName(), e.map((t) => t.getType()).join(", "));
2077
2118
  await Promise.all(e.map((t) => (t.setAttribute(this.getName() + "_id", this.parent.getKey()), t.setAttribute(this.getName() + "_type", this.parent.getType()), t.save())));
2078
2119
  }
2079
2120
  async save(e) {
@@ -2085,10 +2126,10 @@ class Re extends he {
2085
2126
  this.items ? this.items.splice(0, this.items.count(), ...t) : this.items = t;
2086
2127
  }
2087
2128
  }
2088
- class Ne extends he {
2089
- constructor(e, t, r, s = null) {
2090
- if (super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s, s !== null && !w(s))
2091
- throw new E("MorphOne.constructor()", "Model or null");
2129
+ class st extends Ie {
2130
+ constructor(e, t, r, i = null) {
2131
+ if (super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i, i !== null && !E(i))
2132
+ throw new x("MorphOne.constructor()", "Model or null");
2092
2133
  }
2093
2134
  isSingle() {
2094
2135
  return !0;
@@ -2103,7 +2144,7 @@ class Ne extends he {
2103
2144
  await this.saveQuietly(e), this.items = e;
2104
2145
  }
2105
2146
  }
2106
- class Se extends ne {
2147
+ class it extends Be {
2107
2148
  getRelated() {
2108
2149
  return this.facades.model.make(
2109
2150
  this.parent.getAttribute(this.getName() + "_type")
@@ -2118,8 +2159,8 @@ class Se extends ne {
2118
2159
  // return super.query();
2119
2160
  // }
2120
2161
  async associate(e) {
2121
- if (!w(e))
2122
- throw new E("MorphTo.associate()");
2162
+ if (!E(e))
2163
+ throw new x("MorphTo.associate()");
2123
2164
  return e.exists || await e.save(), this.parent.update({
2124
2165
  [this.getName() + "_id"]: e.getKey(),
2125
2166
  [this.getName() + "_type"]: e.getType()
@@ -2132,49 +2173,52 @@ class Se extends ne {
2132
2173
  });
2133
2174
  }
2134
2175
  }
2135
- class Be extends oe {
2136
- constructor(e, t, r, s = null) {
2137
- super(e, t, r, s), this.meta = e, this.facades = t, this.parent = r, this.items = s;
2176
+ class nt extends qe {
2177
+ constructor(e, t, r, i = null) {
2178
+ super(e, t, r, i), this.meta = e, this.facades = t, this.parent = r, this.items = i;
2138
2179
  }
2139
2180
  query() {
2140
2181
  const e = super.query(), t = this.guessInverseRelation();
2141
2182
  return e.where(t + "_id", this.parent.getKey()), e.where(t + "_type", this.parent.getType()), e.lock(`where.${t}_id`), e.lock(`where.${t}_type`), e;
2142
2183
  }
2143
2184
  }
2144
- class ue {
2185
+ var Me;
2186
+ Me = Symbol.toStringTag;
2187
+ class ot {
2145
2188
  constructor(e) {
2146
- p(this, "_models", {});
2189
+ m(this, "_models", {});
2190
+ m(this, Me, "ModelFacade");
2147
2191
  this._schema = e;
2148
2192
  }
2149
2193
  boot(e) {
2150
2194
  this._schema && (Object.keys(this._schema).forEach((t) => {
2151
2195
  const r = this[`model${f.upperFirst(f.camelCase(t))}`];
2152
2196
  if (typeof this.model != "function" || typeof r != "function")
2153
- throw new M("ModelFacade");
2154
- const s = this.model(
2155
- $e(e.make(), t),
2197
+ throw new _("ModelFacade");
2198
+ const i = this.model(
2199
+ ze(e.make(), t),
2156
2200
  t
2157
- ), i = r(s);
2158
- this._models[t] = Te(e.make(), t, i);
2201
+ ), s = r(i);
2202
+ this._models[t] = Oe(e.make(), t, s);
2159
2203
  }), this.reducer("relationMap", () => ({
2160
- BelongsTo: ne,
2161
- BelongsToMany: oe,
2162
- HasOne: Ae,
2163
- HasMany: ve,
2164
- MorphMany: Re,
2165
- MorphOne: Ne,
2166
- MorphTo: Se,
2167
- MorphToMany: Be
2204
+ BelongsTo: Be,
2205
+ BelongsToMany: qe,
2206
+ HasOne: et,
2207
+ HasMany: tt,
2208
+ MorphMany: rt,
2209
+ MorphOne: st,
2210
+ MorphTo: it,
2211
+ MorphToMany: nt
2168
2212
  }), 0));
2169
2213
  }
2170
2214
  schema(e) {
2171
2215
  if (!this._schema || e && !this._schema[e])
2172
- throw new C(e || "undefined");
2216
+ throw new G(e || "undefined");
2173
2217
  return e ? this._schema[e] : this._schema;
2174
2218
  }
2175
2219
  make(e) {
2176
2220
  if (e && !this._models[e])
2177
- throw new C(e);
2221
+ throw new G(e);
2178
2222
  return e ? this._models[e] : this._models;
2179
2223
  }
2180
2224
  toString() {
@@ -2182,68 +2226,68 @@ class ue {
2182
2226
  }
2183
2227
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2184
2228
  on(e, t) {
2185
- throw new y();
2229
+ throw new b();
2186
2230
  }
2187
2231
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2188
2232
  once(e, t) {
2189
- throw new y();
2233
+ throw new b();
2190
2234
  }
2191
2235
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2192
2236
  emit(e, t) {
2193
- throw new y();
2237
+ throw new b();
2194
2238
  }
2195
2239
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2196
2240
  reducer(e, t, r) {
2197
- throw new y();
2241
+ throw new b();
2198
2242
  }
2199
2243
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2200
2244
  removeReducer(e) {
2201
- throw new y();
2245
+ throw new b();
2202
2246
  }
2203
2247
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2204
2248
  getReducer(e) {
2205
- throw new y();
2249
+ throw new b();
2206
2250
  }
2207
2251
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2208
2252
  hasReducer(e) {
2209
- throw new y();
2253
+ throw new b();
2210
2254
  }
2211
2255
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2212
2256
  clearReducer(e) {
2213
- throw new y();
2257
+ throw new b();
2214
2258
  }
2215
2259
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
2216
2260
  flushReducers() {
2217
- throw new y();
2261
+ throw new b();
2218
2262
  }
2219
2263
  }
2220
- p(ue, "name", "ModelFacade");
2221
- const qe = A(ie(ue));
2222
- class ae extends Error {
2264
+ const ht = A(Re(ot));
2265
+ var _e, Te;
2266
+ class ut extends (Te = Error, _e = Symbol.toStringTag, Te) {
2223
2267
  constructor() {
2224
2268
  super("[Luminix] Embed element not found. Make sure to include the `@luminixEmbed()` directive in your Blade template.");
2269
+ m(this, _e, "NoEmbedException");
2225
2270
  }
2226
2271
  }
2227
- p(ae, "name", "NoEmbedException");
2228
- const le = (n, e = "data") => {
2272
+ const Ke = (n, e = "data") => {
2229
2273
  if (!document.querySelector("#luminix-embed"))
2230
- throw new ae();
2274
+ throw new ut();
2231
2275
  const t = document.getElementById(`luminix-${e}::` + n);
2232
2276
  return t ? t.dataset.json && t.dataset.value ? JSON.parse(t.dataset.value) : t.dataset.value : null;
2233
- }, Y = A(v), Ie = (n) => we(n) && n.response !== void 0 && n.response.data !== null && "message" in n.response.data && typeof n.response.data.message == "string" && "errors" in n.response.data && typeof n.response.data.errors == "object" && n.response.data.errors !== null && Object.values(n.response.data.errors).every((e) => Array.isArray(e) && e.every((t) => typeof t == "string")) && n.response.status === 422;
2234
- let Ke = class {
2277
+ }, V = A(S), at = (n) => Je(n) && n.response !== void 0 && n.response.data !== null && "message" in n.response.data && typeof n.response.data.message == "string" && "errors" in n.response.data && typeof n.response.data.errors == "object" && n.response.data.errors !== null && Object.values(n.response.data.errors).every((e) => Array.isArray(e) && e.every((t) => typeof t == "string")) && n.response.status === 422;
2278
+ let lt = class {
2235
2279
  constructor() {
2236
- p(this, "bags");
2280
+ m(this, "bags");
2237
2281
  const e = {};
2238
2282
  document.querySelectorAll('#luminix-embed [id^="luminix-error"]').forEach((r) => {
2239
- const i = r.id.replace("luminix-error::", "");
2240
- e[i] = le(i, "error");
2283
+ const s = r.id.replace("luminix-error::", "");
2284
+ e[s] = Ke(s, "error");
2241
2285
  }), this.bags = {
2242
- default: new Y(e)
2286
+ default: new V(e)
2243
2287
  };
2244
2288
  }
2245
2289
  bag(e = "default") {
2246
- return this.bags[e] || (this.bags[e] = new Y({})), this.bags[e];
2290
+ return this.bags[e] || (this.bags[e] = new V({})), this.bags[e];
2247
2291
  }
2248
2292
  add(e, t, r = "default") {
2249
2293
  this.bag(r).set(e, t);
@@ -2261,13 +2305,14 @@ let Ke = class {
2261
2305
  this.bag(e).set(".", {});
2262
2306
  }
2263
2307
  };
2264
- class ce extends Error {
2265
- constructor(e) {
2266
- super(`[Luminix] Route "${e}" not found`);
2308
+ var $e, Ae;
2309
+ class ct extends (Ae = Error, $e = Symbol.toStringTag, Ae) {
2310
+ constructor(t) {
2311
+ super(`[Luminix] Route "${t}" not found`);
2312
+ m(this, $e, "RouteNotFoundException");
2267
2313
  }
2268
2314
  }
2269
- p(ce, "name", "RouteNotFoundException");
2270
- class je {
2315
+ class dt {
2271
2316
  constructor(e, t, r = "") {
2272
2317
  this.routes = e, this.error = t, this.appUrl = r;
2273
2318
  }
@@ -2277,8 +2322,8 @@ class je {
2277
2322
  const [t, ...r] = e;
2278
2323
  if (typeof t != "string")
2279
2324
  return !1;
2280
- const s = ["get", "post", "put", "patch", "delete"];
2281
- return !!r.every((i) => s.includes(i));
2325
+ const i = ["get", "post", "put", "patch", "delete"];
2326
+ return !!r.every((s) => i.includes(s));
2282
2327
  }
2283
2328
  extractGenerator(e) {
2284
2329
  let t, r = !1;
@@ -2286,23 +2331,23 @@ class je {
2286
2331
  }
2287
2332
  get(e) {
2288
2333
  if (!this.exists(e))
2289
- throw new ce(e);
2334
+ throw new ct(e);
2290
2335
  return f.get(this.routes, e);
2291
2336
  }
2292
2337
  url(e) {
2293
- const [t, r] = this.extractGenerator(e), s = this.get(t)[0].replace(/^\/|\/$/g, ""), i = /{([^}]+)}/g;
2338
+ const [t, r] = this.extractGenerator(e), i = this.get(t)[0].replace(/^\/|\/$/g, ""), s = /{([^}]+)}/g;
2294
2339
  if (r === !1) {
2295
2340
  if (typeof this.replaceRouteParams != "function")
2296
- throw new M("RouteFacade");
2297
- return this.appUrl + this.replaceRouteParams(`/${s}`);
2341
+ throw new _("RouteFacade");
2342
+ return this.appUrl + this.replaceRouteParams(`/${i}`);
2298
2343
  }
2299
- const u = s.match(i), a = u ? u.map((m) => m.slice(1, -1)) : [], c = Object.keys(r), d = a.filter((m) => !c.includes(m)), g = c.filter((m) => !a.includes(m));
2344
+ const u = i.match(s), a = u ? u.map((w) => w.slice(1, -1)) : [], l = Object.keys(r), d = a.filter((w) => !l.includes(w)), p = l.filter((w) => !a.includes(w));
2300
2345
  if (d.length > 0)
2301
2346
  throw new TypeError(`Missing values for parameter(s): ${d.join(", ")}`);
2302
- if (g.length > 0)
2303
- throw new TypeError(`Unexpected parameters: ${g.join(", ")}`);
2304
- const b = a.reduce((m, x) => m.replace(`{${x}}`, `${r[x]}`), s);
2305
- return this.appUrl + `/${b}`;
2347
+ if (p.length > 0)
2348
+ throw new TypeError(`Unexpected parameters: ${p.join(", ")}`);
2349
+ const y = a.reduce((w, g) => w.replace(`{${g}}`, `${r[g]}`), i);
2350
+ return this.appUrl + `/${y}`;
2306
2351
  }
2307
2352
  methods(e) {
2308
2353
  const [t] = this.extractGenerator(e);
@@ -2313,37 +2358,37 @@ class je {
2313
2358
  }
2314
2359
  async call(e, t = {}) {
2315
2360
  if (typeof this.axiosOptions != "function" || typeof this.axiosError != "function")
2316
- throw new M("RouteFacade");
2317
- const [r, s] = this.extractGenerator(e), [, ...i] = this.get(r), u = this.url(s ? [r, s] : r), a = this.axiosOptions(t, r), { method: c = i[0], errorBag: d = "route.call", ...g } = a, { data: b, ...m } = g;
2361
+ throw new _("RouteFacade");
2362
+ const [r, i] = this.extractGenerator(e), [, ...s] = this.get(r), u = this.url(i ? [r, i] : r), a = this.axiosOptions(t, r), { method: l = s[0], errorBag: d = "route.call", ...p } = a, { data: y, ...w } = p;
2318
2363
  this.error.clear(d);
2319
2364
  try {
2320
- return ["get", "delete"].includes(c) ? await K[c](u, g) : await K[c](u, b, m);
2321
- } catch (x) {
2322
- if (Ie(x)) {
2323
- const { errors: fe } = x.response.data;
2324
- this.error.set(Object.entries(fe).reduce((W, [de, pe]) => (W[de] = pe.join(" "), W), {}));
2325
- } else K.isAxiosError(x) && this.error.set(
2326
- this.axiosError({ axios: x.message }, {
2327
- error: x,
2365
+ return ["get", "delete"].includes(l) ? await K[l](u, p) : await K[l](u, y, w);
2366
+ } catch (g) {
2367
+ if (at(g)) {
2368
+ const { errors: je } = g.response.data;
2369
+ this.error.set(Object.entries(je).reduce((J, [Fe, Pe]) => (J[Fe] = Pe.join(" "), J), {}));
2370
+ } else K.isAxiosError(g) && this.error.set(
2371
+ this.axiosError({ axios: g.message }, {
2372
+ error: g,
2328
2373
  name: r,
2329
- replace: s,
2374
+ replace: i,
2330
2375
  config: t
2331
2376
  }),
2332
2377
  d
2333
2378
  );
2334
- throw x;
2379
+ throw g;
2335
2380
  }
2336
2381
  }
2337
2382
  toString() {
2338
2383
  return "route";
2339
2384
  }
2340
2385
  }
2341
- const Fe = ie(je);
2342
- class Pe {
2386
+ const ft = Re(dt);
2387
+ class pt {
2343
2388
  constructor() {
2344
- p(this, "facades", {});
2345
- p(this, "booted", !1);
2346
- p(this, "_plugins", []);
2389
+ m(this, "facades", {});
2390
+ m(this, "booted", !1);
2391
+ m(this, "_plugins", []);
2347
2392
  }
2348
2393
  make(e = void 0) {
2349
2394
  if (!e)
@@ -2361,38 +2406,42 @@ class Pe {
2361
2406
  return this._plugins;
2362
2407
  }
2363
2408
  async boot(e = {}) {
2364
- var a, c, d, g, b;
2409
+ var a, l, d, p, y, w;
2365
2410
  if (this.booted)
2366
2411
  throw new window.Error("[Luminix] App already booted");
2367
2412
  this.booted = !0, (a = e.app) != null && a.debug && console.log("[Luminix] Booting started..."), this.emit("init", {
2368
- register: (m) => {
2369
- this._plugins.push(m), typeof m.register == "function" && m.register(this);
2413
+ register: (g) => {
2414
+ this._plugins.push(g), typeof g.register == "function" && g.register(this);
2370
2415
  }
2371
2416
  });
2372
- const t = (((c = e.app) == null ? void 0 : c.url) ?? "") + (((d = e.app) == null ? void 0 : d.bootUrl) ?? "/luminix-api/init");
2373
- if (typeof t == "string" && !document.getElementById("luminix-data::config")) {
2374
- const { data: m } = await K.get(t);
2375
- m && typeof m == "object" && f.merge(e, m);
2376
- } else if (document.getElementById("luminix-data::config")) {
2377
- const m = le("config");
2378
- m && typeof m == "object" && f.merge(e, m);
2379
- }
2380
- this.bind("log", new Ee(!!((g = e.app) != null && g.debug)));
2417
+ const t = (((l = e.app) == null ? void 0 : l.url) ?? "") + (((d = e.app) == null ? void 0 : d.bootUrl) ?? "/luminix-api/init");
2418
+ if (document.getElementById("luminix-data::config")) {
2419
+ if (document.getElementById("luminix-data::config")) {
2420
+ const g = Ke("config");
2421
+ g && typeof g == "object" && f.merge(e, g);
2422
+ }
2423
+ } else try {
2424
+ const { data: g } = await K.get(t);
2425
+ g && typeof g == "object" && f.merge(e, g);
2426
+ } catch (g) {
2427
+ (p = e.app) != null && p.debug && console.error(g);
2428
+ }
2429
+ this.bind("log", new He(!!((y = e.app) != null && y.debug)));
2381
2430
  const { log: r } = this.facades, {
2382
- manifest: { routes: s = {}, models: i = {} } = {},
2431
+ manifest: { routes: i = {}, models: s = {} } = {},
2383
2432
  ...u
2384
2433
  } = e;
2385
- this.bind("config", new v(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new Ke()), this.bind("route", new Fe(s, this.facades.error, ((b = e.app) == null ? void 0 : b.url) ?? "")), this.bind("model", new qe(i)), this.bind("auth", new be(this)), this.emit("booting");
2386
- for (const m of Object.values(this.facades))
2387
- typeof m == "object" && m !== null && "boot" in m && typeof m.boot == "function" && m.boot(this);
2388
- for (const m of this._plugins)
2389
- typeof m.boot == "function" && m.boot(this.facades);
2434
+ this.bind("config", new S(u)), this.facades.config.has("auth.user") || this.facades.config.set("auth.user", null), this.facades.config.lock("auth.user"), this.bind("error", new lt()), this.bind("route", new ft(i, this.facades.error, ((w = e.app) == null ? void 0 : w.url) ?? "")), this.bind("model", new ht(s)), this.bind("auth", new De(this)), this.emit("booting");
2435
+ for (const g of Object.values(this.facades))
2436
+ typeof g == "object" && g !== null && "boot" in g && typeof g.boot == "function" && g.boot(this);
2437
+ for (const g of this._plugins)
2438
+ typeof g.boot == "function" && g.boot(this.facades);
2390
2439
  return r.info("[Luminix] App boot completed", {
2391
2440
  config: this.facades.config.all(),
2392
2441
  plugins: this._plugins,
2393
2442
  manifest: {
2394
- routes: s,
2395
- models: i
2443
+ routes: i,
2444
+ models: s
2396
2445
  }
2397
2446
  }), this.emit("booted"), this.facades;
2398
2447
  }
@@ -2409,49 +2458,49 @@ class Pe {
2409
2458
  throw new window.Error("Method not implemented.");
2410
2459
  }
2411
2460
  }
2412
- const Qe = A(Pe);
2413
- let _;
2414
- function R(n = void 0) {
2415
- if (_ || (_ = new Qe()), typeof n != "string")
2461
+ const mt = A(pt);
2462
+ let M;
2463
+ function N(n = void 0) {
2464
+ if (M || (M = new mt()), typeof n != "string")
2416
2465
  return {
2417
- boot: _.boot.bind(_),
2418
- make: _.make.bind(_),
2419
- plugins: _.plugins.bind(_),
2420
- on: _.once.bind(_)
2466
+ boot: M.boot.bind(M),
2467
+ make: M.make.bind(M),
2468
+ plugins: M.plugins.bind(M),
2469
+ on: M.once.bind(M)
2421
2470
  };
2422
- if (!_.has(n))
2423
- throw new O(n);
2424
- return _.make(n);
2471
+ if (!M.has(n))
2472
+ throw new Ue(n);
2473
+ return M.make(n);
2425
2474
  }
2426
- function We() {
2427
- return R("auth");
2475
+ function Mt() {
2476
+ return N("auth");
2428
2477
  }
2429
- function Ge(n) {
2430
- return l(n);
2478
+ function _t(n) {
2479
+ return c(n);
2431
2480
  }
2432
- function Ve(n, e) {
2433
- const t = R("config");
2481
+ function Tt(n, e) {
2482
+ const t = N("config");
2434
2483
  return typeof n > "u" ? t : t.get(n, e);
2435
2484
  }
2436
- function Xe(n, e = "default") {
2437
- return n ? R().make("error").get(n, e) : R().make("error");
2485
+ function $t(n, e = "default") {
2486
+ return n ? N().make("error").get(n, e) : N().make("error");
2438
2487
  }
2439
- function Ye(...n) {
2440
- const e = R("log");
2488
+ function At(...n) {
2489
+ const e = N("log");
2441
2490
  return n.length ? e.debug(...n) : e;
2442
2491
  }
2443
- function Ze(n) {
2444
- const e = R("model");
2492
+ function St(n) {
2493
+ const e = N("model");
2445
2494
  return n ? e.make(n) : e;
2446
2495
  }
2447
- function ze(n, e = !1) {
2448
- const t = R("route");
2496
+ function Nt(n, e = !1) {
2497
+ const t = N("route");
2449
2498
  return n ? e ? t.url([n, e]) : t.url(n) : t;
2450
2499
  }
2451
- class Oe {
2500
+ class vt {
2452
2501
  constructor() {
2453
- p(this, "name");
2454
- p(this, "version");
2502
+ m(this, "name");
2503
+ m(this, "version");
2455
2504
  }
2456
2505
  register(e) {
2457
2506
  }
@@ -2460,18 +2509,18 @@ class Oe {
2460
2509
  }
2461
2510
  export {
2462
2511
  A as HasEvents,
2463
- Oe as Plugin,
2464
- v as PropertyBag,
2465
- ie as Reducible,
2466
- R as app,
2467
- We as auth,
2468
- Ge as collect,
2469
- Ve as config,
2470
- Xe as error,
2471
- T as isCollection,
2472
- w as isModel,
2473
- Ie as isValidationError,
2474
- Ye as log,
2475
- Ze as model,
2476
- ze as route
2512
+ vt as Plugin,
2513
+ S as PropertyBag,
2514
+ Re as Reducible,
2515
+ N as app,
2516
+ Mt as auth,
2517
+ _t as collect,
2518
+ Tt as config,
2519
+ $t as error,
2520
+ $ as isCollection,
2521
+ E as isModel,
2522
+ at as isValidationError,
2523
+ At as log,
2524
+ St as model,
2525
+ Nt as route
2477
2526
  };