@luminix/core 0.0.1-beta.0 → 0.0.1-beta.10

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