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