@stoker-platform/node-client 0.5.15 → 0.5.17

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/bundle.js CHANGED
@@ -15,7 +15,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
15
15
  const { labels: s } = n;
16
16
  return t.collections && // eslint-disable-next-line security/detect-object-injection
17
17
  Re("Update", t.collections[s.collection]) && (!e.access || Zn(e, t)) && ri(e, t) && !(n.auth && !t.collections?.[s.collection].auth && ["Enabled", "Role", "Name", "Email", "Photo_URL"].includes(e.name));
18
- }, U = (n, e) => n.filter((t) => t.name === e)[0], K = (n) => ["OneToOne", "OneToMany", "ManyToOne", "ManyToMany"].includes(n.type), ii = (n, e) => {
18
+ }, W = (n, e) => n.filter((t) => t.name === e)[0], K = (n) => ["OneToOne", "OneToMany", "ManyToOne", "ManyToMany"].includes(n.type), ii = (n, e) => {
19
19
  const t = {
20
20
  Record_Owner: "recordOwner",
21
21
  Record_User: "recordUser",
@@ -39,7 +39,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
39
39
  return i?.parentFilters?.forEach((a) => {
40
40
  if (!a.roles.some((f) => f.role === t.Role))
41
41
  return;
42
- const o = a.collectionField, l = U(n.fields, o);
42
+ const o = a.collectionField, l = W(n.fields, o);
43
43
  if (!K(l))
44
44
  throw new Error("PERMISSION_DENIED");
45
45
  const c = t.collections?.[l.collection], m = e.collections[l.collection].access.entityRestrictions;
@@ -62,92 +62,92 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
62
62
  !i.find((m) => m.field === c.field) && c.roles.includes(t.Role) && i.push(c);
63
63
  }
64
64
  return i;
65
- }, Zo = (n, e, t, s, r, i) => {
66
- const { fields: a } = e, o = r.collections?.[e.labels.collection];
67
- let l = !0;
68
- if (!o) {
69
- l = !1;
65
+ }, Zo = (n, e, t, s, r, i, a) => {
66
+ const { fields: o } = e, l = r.collections?.[e.labels.collection];
67
+ let c = !0;
68
+ if (!l) {
69
+ c = !1;
70
70
  return;
71
71
  }
72
- const c = ii(e, r), u = Fs(e, r), m = oi(e, t, r);
73
- c?.filter((w) => w.type === "Record_Owner").forEach((w) => {
74
- "operations" in w && w.operations && !w.operations.includes(n) || i.Created_By !== s && (l = !1);
75
- }), c?.filter((w) => w.type === "Record_User").forEach((w) => {
76
- if ("operations" in w && w.operations && !w.operations.includes(n))
72
+ const u = ii(e, r), m = Fs(e, r), d = oi(e, t, r);
73
+ u?.filter((_) => _.type === "Record_Owner").forEach((_) => {
74
+ "operations" in _ && _.operations && !_.operations.includes(n) || i.Created_By !== s && (c = !1);
75
+ }), u?.filter((_) => _.type === "Record_User").forEach((_) => {
76
+ if ("operations" in _ && _.operations && !_.operations.includes(n))
77
77
  return;
78
- const T = U(a, w.collectionField);
79
- i[`${T.name}_Array`]?.includes(r.Doc_ID) || (l = !1);
80
- }), c?.filter((w) => w.type === "Record_Property").forEach((w) => {
81
- if ("operations" in w && w.operations && !w.operations.includes(n))
78
+ const N = W(o, _.collectionField);
79
+ i[`${N.name}_Array`]?.includes(r.Doc_ID) || (c = !1);
80
+ }), u?.filter((_) => _.type === "Record_Property").forEach((_) => {
81
+ if ("operations" in _ && _.operations && !_.operations.includes(n))
82
82
  return;
83
- const T = U(a, w.propertyField), D = w.roles.find((C) => C.role === r.Role);
84
- T.type === "Array" ? D.values?.some((C) => i[T.name].includes(C)) || (l = !1) : D.values?.includes(i[T.name]) || (l = !1);
83
+ const N = W(o, _.propertyField), C = _.roles.find((L) => L.role === r.Role);
84
+ N.type === "Array" ? C.values?.some((L) => i[N.name].includes(L)) || (c = !1) : C.values?.includes(i[N.name]) || (c = !1);
85
85
  });
86
- let d = !0, f = !1;
87
- u?.filter((w) => w.type === "Individual").forEach(() => {
88
- f = !0, o.individualEntities?.includes(i.id) || (d = !1);
86
+ let f = !0, h = !1;
87
+ m?.filter((_) => _.type === "Individual").forEach(() => {
88
+ h = !0, l?.individualEntities?.includes(i.id) || (f = !1);
89
89
  });
90
- let h = !0, v = !1;
91
- if (u?.filter((w) => w.type === "Parent").forEach((w) => {
92
- v = !0;
93
- const T = U(a, w.collectionField);
94
- o.parentEntities?.some((D) => i[`${T.name}_Array`].includes(D)) || (h = !1);
95
- }), u?.filter((w) => w.type === "Parent_Property").forEach((w) => {
96
- v = !0;
97
- const T = U(a, w.collectionField), D = U(a, w.propertyField);
98
- Object.entries(o.parentPropertyEntities || {}).some((C) => {
99
- const [W, x] = C;
100
- return W === i[D.name] && i[`${T.name}_Array`].some((y) => x.includes(y));
101
- }) || (h = !1);
102
- }), f && v) {
103
- if (!(d || h)) {
104
- l = !1;
90
+ let v = !0, p = !1;
91
+ if (m?.filter((_) => _.type === "Parent").forEach((_) => {
92
+ p = !0;
93
+ const N = W(o, _.collectionField);
94
+ l?.parentEntities?.some((C) => i[`${N.name}_Array`].includes(C)) || (v = !1);
95
+ }), m?.filter((_) => _.type === "Parent_Property").forEach((_) => {
96
+ p = !0;
97
+ const N = W(o, _.collectionField), C = W(o, _.propertyField);
98
+ Object.entries(l?.parentPropertyEntities || {}).some((L) => {
99
+ const [I, y] = L;
100
+ return I === i[C.name] && i[`${N.name}_Array`].some((k) => y.includes(k));
101
+ }) || (v = !1);
102
+ }), h && p) {
103
+ if (!(f || v)) {
104
+ c = !1;
105
105
  return;
106
106
  }
107
- } else if (!d || !h) {
108
- l = !1;
107
+ } else if (!f || !v) {
108
+ c = !1;
109
109
  return;
110
110
  }
111
- let p = !0, E = !1;
112
- m?.filter((w) => w.parentFilter.type === "Individual").forEach((w) => {
113
- E = !0;
114
- const { parentFilter: T } = w, D = U(a, T.collectionField), C = r.collections?.[D.collection];
115
- if (!C) {
116
- l = !1;
111
+ let E = !0, O = !1;
112
+ d?.filter((_) => _.parentFilter.type === "Individual").forEach((_) => {
113
+ O = !0;
114
+ const { parentFilter: N } = _, C = W(o, N.collectionField), L = r.collections?.[C.collection];
115
+ if (!L) {
116
+ c = !1;
117
117
  return;
118
118
  }
119
- C.individualEntities?.some((W) => i[`${D.name}_Array`].includes(W)) || (p = !1);
119
+ L.individualEntities?.some((I) => i[`${C.name}_Array`].includes(I)) || (E = !1);
120
120
  });
121
- let O = !0, N = !1;
122
- if (m?.filter((w) => w.parentFilter.type === "Parent").forEach((w) => {
123
- N = !0;
124
- const { parentFilter: T } = w, D = U(a, T.collectionField), C = U(a, T.parentCollectionField), W = r.collections?.[D.collection];
125
- if (!W) {
126
- l = !1;
121
+ let R = !0, x = !1;
122
+ if (d?.filter((_) => _.parentFilter.type === "Parent").forEach((_) => {
123
+ x = !0;
124
+ const { parentFilter: N } = _, C = W(o, N.collectionField), L = W(o, N.parentCollectionField), I = r.collections?.[C.collection];
125
+ if (!I) {
126
+ c = !1;
127
127
  return;
128
128
  }
129
- W.parentEntities?.some((x) => i[`${C.name}_Array`].includes(x)) || (O = !1);
130
- }), m?.filter((w) => w.parentFilter.type === "Parent_Property").forEach((w) => {
131
- N = !0;
132
- const { parentFilter: T } = w, D = U(a, T.collectionField), C = U(a, T.parentPropertyField), W = U(a, T.parentCollectionField), x = r.collections?.[D.collection];
133
- if (!x) {
134
- l = !1;
129
+ I.parentEntities?.some((y) => i[`${L.name}_Array`].includes(y)) || (R = !1);
130
+ }), d?.filter((_) => _.parentFilter.type === "Parent_Property").forEach((_) => {
131
+ x = !0;
132
+ const { parentFilter: N } = _, C = W(o, N.collectionField), L = W(o, N.parentPropertyField), I = W(o, N.parentCollectionField), y = r.collections?.[C.collection];
133
+ if (!y) {
134
+ c = !1;
135
135
  return;
136
136
  }
137
- Object.entries(x.parentPropertyEntities || {}).some((y) => {
138
- const [k, _] = y;
139
- return k === i[C.name] && i[`${W.name}_Array`].some((B) => _.includes(B));
140
- }) || (O = !1);
141
- }), E && N) {
142
- if (!(p || O)) {
143
- l = !1;
137
+ Object.entries(y.parentPropertyEntities || {}).some((k) => {
138
+ const [w, B] = k;
139
+ return w === i[L.name] && i[`${I.name}_Array`].some((g) => B.includes(g));
140
+ }) || (R = !1);
141
+ }), O && x) {
142
+ if (!(E || R)) {
143
+ c = !1;
144
144
  return;
145
145
  }
146
- } else if (!p || !O) {
147
- l = !1;
146
+ } else if (!E || !R) {
147
+ c = !1;
148
148
  return;
149
149
  }
150
- return l;
150
+ return c;
151
151
  }, it = (n, e, t, s, r, i) => {
152
152
  const { labels: a } = e, o = r.collections?.[a.collection];
153
153
  let l = !0;
@@ -261,12 +261,12 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
261
261
  if (d !== !0 && !(typeof d == "object" && d.includes(t)) ? h.forEach((p) => {
262
262
  const E = p.charAt(0).toUpperCase() + p.slice(1);
263
263
  if (p !== "assignable") {
264
- const O = !!o.operations[p]?.includes(t), N = !!f?.operations.includes(E);
265
- if (!O && N) {
264
+ const O = !!o.operations[p]?.includes(t), R = !!f?.operations.includes(E);
265
+ if (!O && R) {
266
266
  r = `Collection ${a.collection} has excess ${p} operation for role ${t}`, s = !1;
267
267
  return;
268
268
  }
269
- if (O && !N) {
269
+ if (O && !R) {
270
270
  r = `Collection ${a.collection} has missing ${p} operation for role ${t}`, s = !1;
271
271
  return;
272
272
  }
@@ -274,8 +274,8 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
274
274
  }) : h.forEach((p) => {
275
275
  const E = p.charAt(0).toUpperCase() + p.slice(1);
276
276
  if (p !== "assignable") {
277
- const O = !!o.operations[p]?.includes(t), N = !!f?.operations.includes(E);
278
- if (!O && N) {
277
+ const O = !!o.operations[p]?.includes(t), R = !!f?.operations.includes(E);
278
+ if (!O && R) {
279
279
  r = `Collection ${a.collection} has excess ${p} operation for role ${t}`, s = !1;
280
280
  return;
281
281
  }
@@ -307,7 +307,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
307
307
  return;
308
308
  }
309
309
  if (p.type === "Parent") {
310
- const O = U(l, p.collectionField);
310
+ const O = W(l, p.collectionField);
311
311
  if (!K(O)) {
312
312
  s = !1;
313
313
  return;
@@ -318,7 +318,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
318
318
  }
319
319
  }
320
320
  if (p.type === "Parent_Property") {
321
- const O = U(l, p.collectionField);
321
+ const O = W(l, p.collectionField);
322
322
  if (!K(O)) {
323
323
  s = !1;
324
324
  return;
@@ -344,30 +344,30 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
344
344
  s === h.userRole && h.recordRole === r && n !== "delete" && i && Object.keys(t.collections).forEach((v) => {
345
345
  const p = i.collections?.[v], E = l?.collections?.[v];
346
346
  if (!(n === "update" && qe(p, E)) && p) {
347
- const O = h.collections.some((N) => N.collection === v);
347
+ const O = h.collections.some((R) => R.collection === v);
348
348
  if (O) {
349
349
  if (O) {
350
- const N = h.collections.find((T) => T.collection === v);
351
- if (!(p.operations.every((T) => N.operations.includes(T)) || n === "update" && qe(p.operations, E?.operations))) {
350
+ const R = h.collections.find((_) => _.collection === v);
351
+ if (!(p.operations.every((_) => R.operations.includes(_)) || n === "update" && qe(p.operations, E?.operations))) {
352
352
  d = `User ${s} does not have write access to all included operations for collection ${v}`, m = !1;
353
353
  return;
354
354
  }
355
- if (!N.auth && p.auth && !(n === "update" && qe(p.auth, E?.auth))) {
355
+ if (!R.auth && p.auth && !(n === "update" && qe(p.auth, E?.auth))) {
356
356
  d = `User ${s} does not have write access to auth for collection ${v}`, m = !1;
357
357
  return;
358
358
  }
359
- const w = {
359
+ const x = {
360
360
  recordOwner: "Record_Owner",
361
361
  recordUser: "Record_User",
362
362
  recordProperty: "Record_Property"
363
363
  };
364
- if (Object.keys(w).forEach((T) => {
365
- const D = w[T];
366
- if (N.attributeRestrictions?.includes(D) && !(p[T]?.active || n === "update" && qe(p[T], E?.[T]))) {
367
- d = `User ${s} does not have write access to attribute restriction ${T} for collection ${v}`, m = !1;
364
+ if (Object.keys(x).forEach((_) => {
365
+ const N = x[_];
366
+ if (R.attributeRestrictions?.includes(N) && !(p[_]?.active || n === "update" && qe(p[_], E?.[_]))) {
367
+ d = `User ${s} does not have write access to attribute restriction ${_} for collection ${v}`, m = !1;
368
368
  return;
369
369
  }
370
- }), N.restrictEntities && !p.restrictEntities && !(n === "update" && qe(p.restrictEntities, E?.restrictEntities))) {
370
+ }), R.restrictEntities && !p.restrictEntities && !(n === "update" && qe(p.restrictEntities, E?.restrictEntities))) {
371
371
  d = `User ${s} does not have write access to restrictEntities for collection ${v}`, m = !1;
372
372
  return;
373
373
  }
@@ -504,7 +504,7 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
504
504
  for (const i of r.parentFilters) {
505
505
  if (!i.roles.some((c) => c.role === n))
506
506
  continue;
507
- const a = U(e.fields, i.collectionField);
507
+ const a = W(e.fields, i.collectionField);
508
508
  if (!K(a))
509
509
  throw new Error("PERMISSION_DENIED");
510
510
  const l = t.collections[a.collection].access.entityRestrictions?.restrictions?.find((c) => c.type === i.type && c.roles.some((u) => u.role === n));
@@ -656,39 +656,39 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
656
656
  if (l.roles.some((c) => c.role === e))
657
657
  switch (l.type) {
658
658
  case "Record_Owner":
659
- t.push(U(o, "Created_By"));
659
+ t.push(W(o, "Created_By"));
660
660
  break;
661
661
  case "Record_User":
662
- t.push(U(r, l.collectionField));
662
+ t.push(W(r, l.collectionField));
663
663
  break;
664
664
  case "Record_Property":
665
- t.push(U(r, l.propertyField));
665
+ t.push(W(r, l.propertyField));
666
666
  break;
667
667
  }
668
668
  }), a && (a.restrictions?.forEach((l) => {
669
669
  if (l.roles.some((c) => c.role === e))
670
670
  switch (l.type) {
671
671
  case "Individual":
672
- t.push(U(o, "id"));
672
+ t.push(W(o, "id"));
673
673
  break;
674
674
  case "Parent":
675
- t.push(U(r, l.collectionField));
675
+ t.push(W(r, l.collectionField));
676
676
  break;
677
677
  case "Parent_Property":
678
- t.push(U(r, l.collectionField)), t.push(U(r, l.propertyField));
678
+ t.push(W(r, l.collectionField)), t.push(W(r, l.propertyField));
679
679
  break;
680
680
  }
681
681
  }), a.parentFilters && a.parentFilters.forEach((l) => {
682
682
  if (l.roles.some((c) => c.role === e))
683
683
  switch (l.type) {
684
684
  case "Individual":
685
- t.push(U(r, l.collectionField));
685
+ t.push(W(r, l.collectionField));
686
686
  break;
687
687
  case "Parent":
688
- t.push(U(r, l.parentCollectionField));
688
+ t.push(W(r, l.parentCollectionField));
689
689
  break;
690
690
  case "Parent_Property":
691
- t.push(U(r, l.parentCollectionField)), t.push(U(r, l.parentPropertyField));
691
+ t.push(W(r, l.parentCollectionField)), t.push(W(r, l.parentPropertyField));
692
692
  break;
693
693
  }
694
694
  })), [...new Set(t)];
@@ -701,19 +701,19 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
701
701
  }), s.forEach((c) => {
702
702
  (!c.access || c.access.includes(e)) && t.push(c);
703
703
  }), r?.filter((c) => (!c.roles || c.roles.includes(e)) && c.field !== "Collection_Path").forEach((c) => {
704
- t.push(U(o, c.field));
704
+ t.push(W(o, c.field));
705
705
  }), i?.range && i.range.fields.forEach((c) => {
706
- pt.includes(c) && t.push(U(o, c));
706
+ pt.includes(c) && t.push(W(o, c));
707
707
  }), a?.forEach((c) => {
708
- const u = U(s.concat(o), c.field);
709
- (!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(U(o, c.field));
708
+ const u = W(s.concat(o), c.field);
709
+ (!c.roles || c.roles.includes(e)) && u && (!u.access || u.access?.includes(e)) && pt.includes(c.field) && t.push(W(o, c.field));
710
710
  }), ui(n, e).forEach((c) => {
711
- pt.includes(c.name) && t.push(U(o, c.name));
711
+ pt.includes(c.name) && t.push(W(o, c.name));
712
712
  }), [...new Set(t)];
713
713
  }, ta = (n, e, t) => {
714
714
  const s = [], { fields: r, preloadCache: i } = e, a = zn();
715
715
  i?.range && i.range.fields.forEach((c) => {
716
- pt.includes(c) ? s.push(U(a, c)) : s.push(U(r, c));
716
+ pt.includes(c) ? s.push(W(a, c)) : s.push(W(r, c));
717
717
  });
718
718
  const o = /* @__PURE__ */ new Set(), l = ci(e, t);
719
719
  return Object.entries(l).map(([c, u]) => {
@@ -746,9 +746,9 @@ const jn = (n) => !!n.auth, Re = (n, e) => {
746
746
  });
747
747
  });
748
748
  }), a.forEach((l) => {
749
- s.push(U(r, l));
749
+ s.push(W(r, l));
750
750
  }), i) {
751
- const l = U(r, i.archivedField);
751
+ const l = W(r, i.archivedField);
752
752
  l && s.push(l);
753
753
  }
754
754
  return s.push(...ta(n, e, t)), [...new Set(s)];
@@ -810,7 +810,7 @@ const Vs = (n, e, t, s, r, i, a, o, l, c) => (n == "create" && (t.Collection_Pat
810
810
  const { access: t, queries: s } = n, { serverReadOnly: r } = t, i = /* @__PURE__ */ new Set();
811
811
  if (s)
812
812
  for (const a of s) {
813
- const o = U(e, a.field);
813
+ const o = W(e, a.field);
814
814
  e.find((l) => l.name === a.field) && K(o) && ["OneToOne", "OneToMany"].includes(o.type) && i.add(o);
815
815
  }
816
816
  return e.forEach((a) => {
@@ -830,7 +830,7 @@ const Vs = (n, e, t, s, r, i, a, o, l, c) => (n == "create" && (t.Collection_Pat
830
830
  e[`${i.name}_Array`] = e[i.name];
831
831
  else if (e[`${i.name}_Array`] = Object.keys(e[i.name]), i.includeFields)
832
832
  for (const a of i.includeFields) {
833
- const o = t.collections[i.collection], l = U(o.fields, a);
833
+ const o = t.collections[i.collection], l = W(o.fields, a);
834
834
  wt(o, [l]).size === 1 && Object.keys(e[i.name]).forEach((u) => {
835
835
  e[i.name][u][a] ? e[i.name][u][`${a}_Lowercase`] = e[i.name][u][a].toLowerCase() : delete e[i.name][u][`${a}_Lowercase`];
836
836
  });
@@ -856,7 +856,7 @@ const Vs = (n, e, t, s, r, i, a, o, l, c) => (n == "create" && (t.Collection_Pat
856
856
  }, sa = async (n, e, t, s) => {
857
857
  const { fields: r } = e;
858
858
  for (const i of t.fields) {
859
- const a = U(r, i.name);
859
+ const a = W(r, i.name);
860
860
  i.custom?.initialValue && !(s && a.access && !a.access.includes(s)) && (n[i.name] = await re(i.custom.initialValue, [n]), wt(e, [a]).size === 1 && (n[`${i.name}_Lowercase`] = n[i.name].toLowerCase()));
861
861
  }
862
862
  for (const i of r)
@@ -907,7 +907,7 @@ var rr;
907
907
  // second overwrites first
908
908
  });
909
909
  })(rr || (rr = {}));
910
- const V = te.arrayToEnum([
910
+ const U = te.arrayToEnum([
911
911
  "string",
912
912
  "nan",
913
913
  "number",
@@ -931,23 +931,23 @@ const V = te.arrayToEnum([
931
931
  ]), Xe = (n) => {
932
932
  switch (typeof n) {
933
933
  case "undefined":
934
- return V.undefined;
934
+ return U.undefined;
935
935
  case "string":
936
- return V.string;
936
+ return U.string;
937
937
  case "number":
938
- return Number.isNaN(n) ? V.nan : V.number;
938
+ return Number.isNaN(n) ? U.nan : U.number;
939
939
  case "boolean":
940
- return V.boolean;
940
+ return U.boolean;
941
941
  case "function":
942
- return V.function;
942
+ return U.function;
943
943
  case "bigint":
944
- return V.bigint;
944
+ return U.bigint;
945
945
  case "symbol":
946
- return V.symbol;
946
+ return U.symbol;
947
947
  case "object":
948
- return Array.isArray(n) ? V.array : n === null ? V.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? V.promise : typeof Map < "u" && n instanceof Map ? V.map : typeof Set < "u" && n instanceof Set ? V.set : typeof Date < "u" && n instanceof Date ? V.date : V.object;
948
+ return Array.isArray(n) ? U.array : n === null ? U.null : n.then && typeof n.then == "function" && n.catch && typeof n.catch == "function" ? U.promise : typeof Map < "u" && n instanceof Map ? U.map : typeof Set < "u" && n instanceof Set ? U.set : typeof Date < "u" && n instanceof Date ? U.date : U.object;
949
949
  default:
950
- return V.unknown;
950
+ return U.unknown;
951
951
  }
952
952
  }, A = te.arrayToEnum([
953
953
  "invalid_type",
@@ -1035,7 +1035,7 @@ const ys = (n, e) => {
1035
1035
  let t;
1036
1036
  switch (n.code) {
1037
1037
  case A.invalid_type:
1038
- n.received === V.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
1038
+ n.received === U.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
1039
1039
  break;
1040
1040
  case A.invalid_literal:
1041
1041
  t = `Invalid literal value, expected ${JSON.stringify(n.expected, te.jsonStringifyReplacer)}`;
@@ -1468,11 +1468,11 @@ function Ra(n, e) {
1468
1468
  }
1469
1469
  class Be extends X {
1470
1470
  _parse(e) {
1471
- if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== V.string) {
1471
+ if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== U.string) {
1472
1472
  const i = this._getOrReturnCtx(e);
1473
1473
  return P(i, {
1474
1474
  code: A.invalid_type,
1475
- expected: V.string,
1475
+ expected: U.string,
1476
1476
  received: i.parsedType
1477
1477
  }), Y;
1478
1478
  }
@@ -1858,11 +1858,11 @@ class Dt extends X {
1858
1858
  super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
1859
1859
  }
1860
1860
  _parse(e) {
1861
- if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== V.number) {
1861
+ if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== U.number) {
1862
1862
  const i = this._getOrReturnCtx(e);
1863
1863
  return P(i, {
1864
1864
  code: A.invalid_type,
1865
- expected: V.number,
1865
+ expected: U.number,
1866
1866
  received: i.parsedType
1867
1867
  }), Y;
1868
1868
  }
@@ -2036,7 +2036,7 @@ class Xt extends X {
2036
2036
  } catch {
2037
2037
  return this._getInvalidInput(e);
2038
2038
  }
2039
- if (this._getType(e) !== V.bigint)
2039
+ if (this._getType(e) !== U.bigint)
2040
2040
  return this._getInvalidInput(e);
2041
2041
  let s;
2042
2042
  const r = new Oe();
@@ -2064,7 +2064,7 @@ class Xt extends X {
2064
2064
  const t = this._getOrReturnCtx(e);
2065
2065
  return P(t, {
2066
2066
  code: A.invalid_type,
2067
- expected: V.bigint,
2067
+ expected: U.bigint,
2068
2068
  received: t.parsedType
2069
2069
  }), Y;
2070
2070
  }
@@ -2160,11 +2160,11 @@ Xt.create = (n) => new Xt({
2160
2160
  });
2161
2161
  class gs extends X {
2162
2162
  _parse(e) {
2163
- if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== V.boolean) {
2163
+ if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== U.boolean) {
2164
2164
  const s = this._getOrReturnCtx(e);
2165
2165
  return P(s, {
2166
2166
  code: A.invalid_type,
2167
- expected: V.boolean,
2167
+ expected: U.boolean,
2168
2168
  received: s.parsedType
2169
2169
  }), Y;
2170
2170
  }
@@ -2178,11 +2178,11 @@ gs.create = (n) => new gs({
2178
2178
  });
2179
2179
  class xn extends X {
2180
2180
  _parse(e) {
2181
- if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== V.date) {
2181
+ if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== U.date) {
2182
2182
  const i = this._getOrReturnCtx(e);
2183
2183
  return P(i, {
2184
2184
  code: A.invalid_type,
2185
- expected: V.date,
2185
+ expected: U.date,
2186
2186
  received: i.parsedType
2187
2187
  }), Y;
2188
2188
  }
@@ -2256,11 +2256,11 @@ xn.create = (n) => new xn({
2256
2256
  });
2257
2257
  class lr extends X {
2258
2258
  _parse(e) {
2259
- if (this._getType(e) !== V.symbol) {
2259
+ if (this._getType(e) !== U.symbol) {
2260
2260
  const s = this._getOrReturnCtx(e);
2261
2261
  return P(s, {
2262
2262
  code: A.invalid_type,
2263
- expected: V.symbol,
2263
+ expected: U.symbol,
2264
2264
  received: s.parsedType
2265
2265
  }), Y;
2266
2266
  }
@@ -2273,11 +2273,11 @@ lr.create = (n) => new lr({
2273
2273
  });
2274
2274
  class ws extends X {
2275
2275
  _parse(e) {
2276
- if (this._getType(e) !== V.undefined) {
2276
+ if (this._getType(e) !== U.undefined) {
2277
2277
  const s = this._getOrReturnCtx(e);
2278
2278
  return P(s, {
2279
2279
  code: A.invalid_type,
2280
- expected: V.undefined,
2280
+ expected: U.undefined,
2281
2281
  received: s.parsedType
2282
2282
  }), Y;
2283
2283
  }
@@ -2290,11 +2290,11 @@ ws.create = (n) => new ws({
2290
2290
  });
2291
2291
  class cr extends X {
2292
2292
  _parse(e) {
2293
- if (this._getType(e) !== V.null) {
2293
+ if (this._getType(e) !== U.null) {
2294
2294
  const s = this._getOrReturnCtx(e);
2295
2295
  return P(s, {
2296
2296
  code: A.invalid_type,
2297
- expected: V.null,
2297
+ expected: U.null,
2298
2298
  received: s.parsedType
2299
2299
  }), Y;
2300
2300
  }
@@ -2334,7 +2334,7 @@ class ot extends X {
2334
2334
  const t = this._getOrReturnCtx(e);
2335
2335
  return P(t, {
2336
2336
  code: A.invalid_type,
2337
- expected: V.never,
2337
+ expected: U.never,
2338
2338
  received: t.parsedType
2339
2339
  }), Y;
2340
2340
  }
@@ -2345,11 +2345,11 @@ ot.create = (n) => new ot({
2345
2345
  });
2346
2346
  class dr extends X {
2347
2347
  _parse(e) {
2348
- if (this._getType(e) !== V.undefined) {
2348
+ if (this._getType(e) !== U.undefined) {
2349
2349
  const s = this._getOrReturnCtx(e);
2350
2350
  return P(s, {
2351
2351
  code: A.invalid_type,
2352
- expected: V.void,
2352
+ expected: U.void,
2353
2353
  received: s.parsedType
2354
2354
  }), Y;
2355
2355
  }
@@ -2363,10 +2363,10 @@ dr.create = (n) => new dr({
2363
2363
  class We extends X {
2364
2364
  _parse(e) {
2365
2365
  const { ctx: t, status: s } = this._processInputParams(e), r = this._def;
2366
- if (t.parsedType !== V.array)
2366
+ if (t.parsedType !== U.array)
2367
2367
  return P(t, {
2368
2368
  code: A.invalid_type,
2369
- expected: V.array,
2369
+ expected: U.array,
2370
2370
  received: t.parsedType
2371
2371
  }), Y;
2372
2372
  if (r.exactLength !== null) {
@@ -2460,11 +2460,11 @@ class de extends X {
2460
2460
  return this._cached = { shape: e, keys: t }, this._cached;
2461
2461
  }
2462
2462
  _parse(e) {
2463
- if (this._getType(e) !== V.object) {
2463
+ if (this._getType(e) !== U.object) {
2464
2464
  const c = this._getOrReturnCtx(e);
2465
2465
  return P(c, {
2466
2466
  code: A.invalid_type,
2467
- expected: V.object,
2467
+ expected: U.object,
2468
2468
  received: c.parsedType
2469
2469
  }), Y;
2470
2470
  }
@@ -2813,7 +2813,7 @@ function Es(n, e) {
2813
2813
  const t = Xe(n), s = Xe(e);
2814
2814
  if (n === e)
2815
2815
  return { valid: !0, data: n };
2816
- if (t === V.object && s === V.object) {
2816
+ if (t === U.object && s === U.object) {
2817
2817
  const r = te.objectKeys(e), i = te.objectKeys(n).filter((o) => r.indexOf(o) !== -1), a = { ...n, ...e };
2818
2818
  for (const o of i) {
2819
2819
  const l = Es(n[o], e[o]);
@@ -2822,7 +2822,7 @@ function Es(n, e) {
2822
2822
  a[o] = l.data;
2823
2823
  }
2824
2824
  return { valid: !0, data: a };
2825
- } else if (t === V.array && s === V.array) {
2825
+ } else if (t === U.array && s === U.array) {
2826
2826
  if (n.length !== e.length)
2827
2827
  return { valid: !1 };
2828
2828
  const r = [];
@@ -2833,7 +2833,7 @@ function Es(n, e) {
2833
2833
  r.push(l.data);
2834
2834
  }
2835
2835
  return { valid: !0, data: r };
2836
- } else return t === V.date && s === V.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2836
+ } else return t === U.date && s === U.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
2837
2837
  }
2838
2838
  class Dn extends X {
2839
2839
  _parse(e) {
@@ -2876,10 +2876,10 @@ Dn.create = (n, e, t) => new Dn({
2876
2876
  class yt extends X {
2877
2877
  _parse(e) {
2878
2878
  const { status: t, ctx: s } = this._processInputParams(e);
2879
- if (s.parsedType !== V.array)
2879
+ if (s.parsedType !== U.array)
2880
2880
  return P(s, {
2881
2881
  code: A.invalid_type,
2882
- expected: V.array,
2882
+ expected: U.array,
2883
2883
  received: s.parsedType
2884
2884
  }), Y;
2885
2885
  if (s.data.length < this._def.items.length)
@@ -2932,10 +2932,10 @@ class An extends X {
2932
2932
  }
2933
2933
  _parse(e) {
2934
2934
  const { status: t, ctx: s } = this._processInputParams(e);
2935
- if (s.parsedType !== V.object)
2935
+ if (s.parsedType !== U.object)
2936
2936
  return P(s, {
2937
2937
  code: A.invalid_type,
2938
- expected: V.object,
2938
+ expected: U.object,
2939
2939
  received: s.parsedType
2940
2940
  }), Y;
2941
2941
  const r = [], i = this._def.keyType, a = this._def.valueType;
@@ -2973,10 +2973,10 @@ class fr extends X {
2973
2973
  }
2974
2974
  _parse(e) {
2975
2975
  const { status: t, ctx: s } = this._processInputParams(e);
2976
- if (s.parsedType !== V.map)
2976
+ if (s.parsedType !== U.map)
2977
2977
  return P(s, {
2978
2978
  code: A.invalid_type,
2979
- expected: V.map,
2979
+ expected: U.map,
2980
2980
  received: s.parsedType
2981
2981
  }), Y;
2982
2982
  const r = this._def.keyType, i = this._def.valueType, a = [...s.data.entries()].map(([o, l], c) => ({
@@ -3015,10 +3015,10 @@ fr.create = (n, e, t) => new fr({
3015
3015
  class en extends X {
3016
3016
  _parse(e) {
3017
3017
  const { status: t, ctx: s } = this._processInputParams(e);
3018
- if (s.parsedType !== V.set)
3018
+ if (s.parsedType !== U.set)
3019
3019
  return P(s, {
3020
3020
  code: A.invalid_type,
3021
- expected: V.set,
3021
+ expected: U.set,
3022
3022
  received: s.parsedType
3023
3023
  }), Y;
3024
3024
  const r = this._def;
@@ -3176,7 +3176,7 @@ At.create = pi;
3176
3176
  class mr extends X {
3177
3177
  _parse(e) {
3178
3178
  const t = te.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
3179
- if (s.parsedType !== V.string && s.parsedType !== V.number) {
3179
+ if (s.parsedType !== U.string && s.parsedType !== U.number) {
3180
3180
  const r = te.objectValues(t);
3181
3181
  return P(s, {
3182
3182
  expected: te.joinValues(r),
@@ -3209,13 +3209,13 @@ class Cn extends X {
3209
3209
  }
3210
3210
  _parse(e) {
3211
3211
  const { ctx: t } = this._processInputParams(e);
3212
- if (t.parsedType !== V.promise && t.common.async === !1)
3212
+ if (t.parsedType !== U.promise && t.common.async === !1)
3213
3213
  return P(t, {
3214
3214
  code: A.invalid_type,
3215
- expected: V.promise,
3215
+ expected: U.promise,
3216
3216
  received: t.parsedType
3217
3217
  }), Y;
3218
- const s = t.parsedType === V.promise ? t.data : Promise.resolve(t.data);
3218
+ const s = t.parsedType === U.promise ? t.data : Promise.resolve(t.data);
3219
3219
  return Ce(s.then((r) => this._def.type.parseAsync(r, {
3220
3220
  path: t.path,
3221
3221
  errorMap: t.common.contextualErrorMap
@@ -3321,7 +3321,7 @@ Ct.createWithPreprocess = (n, e, t) => new Ct({
3321
3321
  });
3322
3322
  class st extends X {
3323
3323
  _parse(e) {
3324
- return this._getType(e) === V.undefined ? Ce(void 0) : this._def.innerType._parse(e);
3324
+ return this._getType(e) === U.undefined ? Ce(void 0) : this._def.innerType._parse(e);
3325
3325
  }
3326
3326
  unwrap() {
3327
3327
  return this._def.innerType;
@@ -3334,7 +3334,7 @@ st.create = (n, e) => new st({
3334
3334
  });
3335
3335
  class $t extends X {
3336
3336
  _parse(e) {
3337
- return this._getType(e) === V.null ? Ce(null) : this._def.innerType._parse(e);
3337
+ return this._getType(e) === U.null ? Ce(null) : this._def.innerType._parse(e);
3338
3338
  }
3339
3339
  unwrap() {
3340
3340
  return this._def.innerType;
@@ -3349,7 +3349,7 @@ class Os extends X {
3349
3349
  _parse(e) {
3350
3350
  const { ctx: t } = this._processInputParams(e);
3351
3351
  let s = t.data;
3352
- return t.parsedType === V.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
3352
+ return t.parsedType === U.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
3353
3353
  data: s,
3354
3354
  path: t.path,
3355
3355
  parent: t
@@ -3410,11 +3410,11 @@ ks.create = (n, e) => new ks({
3410
3410
  });
3411
3411
  class pr extends X {
3412
3412
  _parse(e) {
3413
- if (this._getType(e) !== V.nan) {
3413
+ if (this._getType(e) !== U.nan) {
3414
3414
  const s = this._getOrReturnCtx(e);
3415
3415
  return P(s, {
3416
3416
  code: A.invalid_type,
3417
- expected: V.nan,
3417
+ expected: U.nan,
3418
3418
  received: s.parsedType
3419
3419
  }), Y;
3420
3420
  }
@@ -4135,7 +4135,7 @@ function Ga(n, e, t) {
4135
4135
  function Ya(n) {
4136
4136
  const e = [];
4137
4137
  for (let t = 1; t <= 12; t++) {
4138
- const s = L.utc(2009, t, 1);
4138
+ const s = V.utc(2009, t, 1);
4139
4139
  e.push(n(s));
4140
4140
  }
4141
4141
  return e;
@@ -4143,7 +4143,7 @@ function Ya(n) {
4143
4143
  function Ja(n) {
4144
4144
  const e = [];
4145
4145
  for (let t = 1; t <= 7; t++) {
4146
- const s = L.utc(2016, 11, 13 + t);
4146
+ const s = V.utc(2016, 11, 13 + t);
4147
4147
  e.push(n(s));
4148
4148
  }
4149
4149
  return e;
@@ -4300,7 +4300,7 @@ class se {
4300
4300
  () => {
4301
4301
  if (!this.meridiemCache) {
4302
4302
  const e = { hour: "numeric", hourCycle: "h12" };
4303
- this.meridiemCache = [L.utc(2016, 11, 13, 9), L.utc(2016, 11, 13, 19)].map(
4303
+ this.meridiemCache = [V.utc(2016, 11, 13, 9), V.utc(2016, 11, 13, 19)].map(
4304
4304
  (t) => this.extract(t, e, "dayperiod")
4305
4305
  );
4306
4306
  }
@@ -4311,7 +4311,7 @@ class se {
4311
4311
  eras(e) {
4312
4312
  return fn(this, e, to, () => {
4313
4313
  const t = { era: e };
4314
- return this.eraCache[e] || (this.eraCache[e] = [L.utc(-40, 1, 1), L.utc(2017, 1, 1)].map(
4314
+ return this.eraCache[e] || (this.eraCache[e] = [V.utc(-40, 1, 1), V.utc(2017, 1, 1)].map(
4315
4315
  (s) => this.extract(s, t, "era")
4316
4316
  )), this.eraCache[e];
4317
4317
  });
@@ -4730,7 +4730,7 @@ class le {
4730
4730
  * @return {void}
4731
4731
  */
4732
4732
  static resetCaches() {
4733
- se.resetCache(), Ge.resetCache(), L.resetCache(), rl();
4733
+ se.resetCache(), Ge.resetCache(), V.resetCache(), rl();
4734
4734
  }
4735
4735
  }
4736
4736
  class Pe {
@@ -5983,7 +5983,7 @@ class ee {
5983
5983
  format: "extended",
5984
5984
  ...e,
5985
5985
  includeOffset: !1
5986
- }, L.fromMillis(t, { zone: "UTC" }).toISOTime(e));
5986
+ }, V.fromMillis(t, { zone: "UTC" }).toISOTime(e));
5987
5987
  }
5988
5988
  /**
5989
5989
  * Returns an ISO 8601 representation of this Duration appropriate for use in JSON.
@@ -6371,13 +6371,13 @@ class ae {
6371
6371
  if (s && r) {
6372
6372
  let i, a;
6373
6373
  try {
6374
- i = L.fromISO(s, t), a = i.isValid;
6374
+ i = V.fromISO(s, t), a = i.isValid;
6375
6375
  } catch {
6376
6376
  a = !1;
6377
6377
  }
6378
6378
  let o, l;
6379
6379
  try {
6380
- o = L.fromISO(r, t), l = o.isValid;
6380
+ o = V.fromISO(r, t), l = o.isValid;
6381
6381
  } catch {
6382
6382
  l = !1;
6383
6383
  }
@@ -6771,7 +6771,7 @@ class hn {
6771
6771
  * @return {boolean}
6772
6772
  */
6773
6773
  static hasDST(e = le.defaultZone) {
6774
- const t = L.now().setZone(e).set({ month: 12 });
6774
+ const t = V.now().setZone(e).set({ month: 12 });
6775
6775
  return !e.isUniversal && t.offset !== t.set({ month: 6 }).offset;
6776
6776
  }
6777
6777
  /**
@@ -7239,7 +7239,7 @@ function Oc(n) {
7239
7239
  }
7240
7240
  let os = null;
7241
7241
  function kc() {
7242
- return os || (os = L.fromMillis(1555555555555)), os;
7242
+ return os || (os = V.fromMillis(1555555555555)), os;
7243
7243
  }
7244
7244
  function bc(n, e) {
7245
7245
  if (n.literal)
@@ -7320,7 +7320,7 @@ function dt(n, e) {
7320
7320
  loc: n.loc,
7321
7321
  invalid: n.invalid
7322
7322
  };
7323
- return new L({ ...t, ...e, old: t });
7323
+ return new V({ ...t, ...e, old: t });
7324
7324
  }
7325
7325
  function go(n, e, t) {
7326
7326
  let s = n - e * 60 * 1e3;
@@ -7370,14 +7370,14 @@ function Wr(n, e) {
7370
7370
  function bt(n, e, t, s, r, i) {
7371
7371
  const { setZone: a, zone: o } = t;
7372
7372
  if (n && Object.keys(n).length !== 0 || e) {
7373
- const l = e || o, c = L.fromObject(n, {
7373
+ const l = e || o, c = V.fromObject(n, {
7374
7374
  ...t,
7375
7375
  zone: l,
7376
7376
  specificOffset: i
7377
7377
  });
7378
7378
  return a ? c : c.setZone(o);
7379
7379
  } else
7380
- return L.invalid(
7380
+ return V.invalid(
7381
7381
  new Pe("unparsable", `the input "${r}" can't be parsed as ${s}`)
7382
7382
  );
7383
7383
  }
@@ -7502,7 +7502,7 @@ function Ic(n) {
7502
7502
  function zr(n, e) {
7503
7503
  const t = tt(e.zone, le.defaultZone);
7504
7504
  if (!t.isValid)
7505
- return L.invalid(Ht(t));
7505
+ return V.invalid(Ht(t));
7506
7506
  const s = se.fromObject(e);
7507
7507
  let r, i;
7508
7508
  if (H(n.year))
@@ -7512,11 +7512,11 @@ function zr(n, e) {
7512
7512
  H(n[l]) && (n[l] = wo[l]);
7513
7513
  const a = Zi(n) || zi(n);
7514
7514
  if (a)
7515
- return L.invalid(a);
7515
+ return V.invalid(a);
7516
7516
  const o = Ic(t);
7517
7517
  [r, i] = _n(n, o, t);
7518
7518
  }
7519
- return new L({ ts: r, zone: t, loc: s, o: i });
7519
+ return new V({ ts: r, zone: t, loc: s, o: i });
7520
7520
  }
7521
7521
  function qr(n, e, t) {
7522
7522
  const s = H(t.round) ? !0 : t.round, r = H(t.rounding) ? "trunc" : t.rounding, i = (o, l) => (o = qs(o, s || t.calendary ? 0 : 2, t.calendary ? "round" : r), e.loc.clone(t).relFormatter(t).format(o, l)), a = (o) => t.calendary ? e.hasSame(n, o) ? 0 : e.startOf(o).diff(n.startOf(o), o).get(o) : e.diff(n, o).get(o);
@@ -7535,7 +7535,7 @@ function Br(n) {
7535
7535
  }
7536
7536
  let Gt;
7537
7537
  const Ms = /* @__PURE__ */ new Map();
7538
- class L {
7538
+ class V {
7539
7539
  /**
7540
7540
  * @access private
7541
7541
  */
@@ -7562,7 +7562,7 @@ class L {
7562
7562
  * @return {DateTime}
7563
7563
  */
7564
7564
  static now() {
7565
- return new L({});
7565
+ return new V({});
7566
7566
  }
7567
7567
  /**
7568
7568
  * Create a local DateTime
@@ -7628,13 +7628,13 @@ class L {
7628
7628
  static fromJSDate(e, t = {}) {
7629
7629
  const s = ll(e) ? e.valueOf() : NaN;
7630
7630
  if (Number.isNaN(s))
7631
- return L.invalid("invalid input");
7631
+ return V.invalid("invalid input");
7632
7632
  const r = tt(t.zone, le.defaultZone);
7633
- return r.isValid ? new L({
7633
+ return r.isValid ? new V({
7634
7634
  ts: s,
7635
7635
  zone: r,
7636
7636
  loc: se.fromObject(t)
7637
- }) : L.invalid(Ht(r));
7637
+ }) : V.invalid(Ht(r));
7638
7638
  }
7639
7639
  /**
7640
7640
  * Create a DateTime from a number of milliseconds since the epoch (meaning since 1 January 1970 00:00:00 UTC). Uses the default zone.
@@ -7649,7 +7649,7 @@ class L {
7649
7649
  */
7650
7650
  static fromMillis(e, t = {}) {
7651
7651
  if (rt(e))
7652
- return e < -Ur || e > Ur ? L.invalid("Timestamp out of range") : new L({
7652
+ return e < -Ur || e > Ur ? V.invalid("Timestamp out of range") : new V({
7653
7653
  ts: e,
7654
7654
  zone: tt(t.zone, le.defaultZone),
7655
7655
  loc: se.fromObject(t)
@@ -7671,7 +7671,7 @@ class L {
7671
7671
  */
7672
7672
  static fromSeconds(e, t = {}) {
7673
7673
  if (rt(e))
7674
- return new L({
7674
+ return new V({
7675
7675
  ts: e * 1e3,
7676
7676
  zone: tt(t.zone, le.defaultZone),
7677
7677
  loc: se.fromObject(t)
@@ -7715,7 +7715,7 @@ class L {
7715
7715
  e = e || {};
7716
7716
  const s = tt(t.zone, le.defaultZone);
7717
7717
  if (!s.isValid)
7718
- return L.invalid(Ht(s));
7718
+ return V.invalid(Ht(s));
7719
7719
  const r = se.fromObject(t), i = Vn(e, Zr), { minDaysInFirstWeek: a, startOfWeek: o } = xr(i, r), l = le.now(), c = H(t.specificOffset) ? s.offset(l) : t.specificOffset, u = !H(i.ordinal), m = !H(i.year), d = !H(i.month) || !H(i.day), f = m || d, h = i.weekYear || i.weekNumber;
7720
7720
  if ((f || u) && h)
7721
7721
  throw new Tt(
@@ -7726,24 +7726,24 @@ class L {
7726
7726
  const v = h || i.weekday && !f;
7727
7727
  let p, E, O = pn(l, c);
7728
7728
  v ? (p = Nc, E = Tc, O = Pn(O, a, o)) : u ? (p = xc, E = Rc, O = is(O)) : (p = En, E = wo);
7729
- let N = !1;
7729
+ let R = !1;
7730
7730
  for (const y of p) {
7731
7731
  const k = i[y];
7732
- H(k) ? N ? i[y] = E[y] : i[y] = O[y] : N = !0;
7732
+ H(k) ? R ? i[y] = E[y] : i[y] = O[y] : R = !0;
7733
7733
  }
7734
- const w = v ? il(i, a, o) : u ? ol(i) : Zi(i), T = w || zi(i);
7735
- if (T)
7736
- return L.invalid(T);
7737
- const D = v ? Rr(i, a, o) : u ? Nr(i) : i, [C, W] = _n(D, c, s), x = new L({
7734
+ const x = v ? il(i, a, o) : u ? ol(i) : Zi(i), _ = x || zi(i);
7735
+ if (_)
7736
+ return V.invalid(_);
7737
+ const N = v ? Rr(i, a, o) : u ? Nr(i) : i, [C, L] = _n(N, c, s), I = new V({
7738
7738
  ts: C,
7739
7739
  zone: s,
7740
- o: W,
7740
+ o: L,
7741
7741
  loc: r
7742
7742
  });
7743
- return i.weekday && f && e.weekday !== x.weekday ? L.invalid(
7743
+ return i.weekday && f && e.weekday !== I.weekday ? V.invalid(
7744
7744
  "mismatched weekday",
7745
- `you can't specify both a weekday of ${i.weekday} and a date of ${x.toISO()}`
7746
- ) : x.isValid ? x : L.invalid(x.invalid);
7745
+ `you can't specify both a weekday of ${i.weekday} and a date of ${I.toISO()}`
7746
+ ) : I.isValid ? I : V.invalid(I.invalid);
7747
7747
  }
7748
7748
  /**
7749
7749
  * Create a DateTime from an ISO 8601 string
@@ -7827,13 +7827,13 @@ class L {
7827
7827
  numberingSystem: i,
7828
7828
  defaultToEN: !0
7829
7829
  }), [o, l, c, u] = Sc(a, e, t);
7830
- return u ? L.invalid(u) : bt(o, l, s, `format ${t}`, e, c);
7830
+ return u ? V.invalid(u) : bt(o, l, s, `format ${t}`, e, c);
7831
7831
  }
7832
7832
  /**
7833
7833
  * @deprecated use fromFormat instead
7834
7834
  */
7835
7835
  static fromString(e, t, s = {}) {
7836
- return L.fromFormat(e, t, s);
7836
+ return V.fromFormat(e, t, s);
7837
7837
  }
7838
7838
  /**
7839
7839
  * Create a DateTime from a SQL date, time, or datetime
@@ -7872,7 +7872,7 @@ class L {
7872
7872
  const s = e instanceof Pe ? e : new Pe(e, t);
7873
7873
  if (le.throwOnInvalid)
7874
7874
  throw new Ca(s);
7875
- return new L({ invalid: s });
7875
+ return new V({ invalid: s });
7876
7876
  }
7877
7877
  /**
7878
7878
  * Check if an object is an instance of DateTime. Works across context boundaries
@@ -8311,7 +8311,7 @@ class L {
8311
8311
  }
8312
8312
  return dt(this, { ts: r, zone: e });
8313
8313
  } else
8314
- return L.invalid(Ht(e));
8314
+ return V.invalid(Ht(e));
8315
8315
  }
8316
8316
  /**
8317
8317
  * "Set" the locale, numberingSystem, or outputCalendar. Returns a newly-constructed DateTime.
@@ -8772,7 +8772,7 @@ class L {
8772
8772
  * @return {Duration}
8773
8773
  */
8774
8774
  diffNow(e = "milliseconds", t = {}) {
8775
- return this.diff(L.now(), e, t);
8775
+ return this.diff(V.now(), e, t);
8776
8776
  }
8777
8777
  /**
8778
8778
  * Return an Interval spanning between this DateTime and another DateTime
@@ -8829,7 +8829,7 @@ class L {
8829
8829
  */
8830
8830
  toRelative(e = {}) {
8831
8831
  if (!this.isValid) return null;
8832
- const t = e.base || L.fromObject({}, { zone: this.zone }), s = e.padding ? this < t ? -e.padding : e.padding : 0;
8832
+ const t = e.base || V.fromObject({}, { zone: this.zone }), s = e.padding ? this < t ? -e.padding : e.padding : 0;
8833
8833
  let r = ["years", "months", "days", "hours", "minutes", "seconds"], i = e.unit;
8834
8834
  return Array.isArray(e.unit) && (r = e.unit, i = void 0), qr(t, this.plus(s), {
8835
8835
  ...e,
@@ -8852,7 +8852,7 @@ class L {
8852
8852
  * @example DateTime.now().minus({ days: 2 }).toRelativeCalendar() //=> "2 days ago"
8853
8853
  */
8854
8854
  toRelativeCalendar(e = {}) {
8855
- return this.isValid ? qr(e.base || L.fromObject({}, { zone: this.zone }), this, {
8855
+ return this.isValid ? qr(e.base || V.fromObject({}, { zone: this.zone }), this, {
8856
8856
  ...e,
8857
8857
  numeric: "auto",
8858
8858
  units: ["years", "months", "days"],
@@ -8865,7 +8865,7 @@ class L {
8865
8865
  * @return {DateTime} the min DateTime, or undefined if called with no argument
8866
8866
  */
8867
8867
  static min(...e) {
8868
- if (!e.every(L.isDateTime))
8868
+ if (!e.every(V.isDateTime))
8869
8869
  throw new we("min requires all arguments be DateTimes");
8870
8870
  return Ir(e, (t) => t.valueOf(), Math.min);
8871
8871
  }
@@ -8875,7 +8875,7 @@ class L {
8875
8875
  * @return {DateTime} the max DateTime, or undefined if called with no argument
8876
8876
  */
8877
8877
  static max(...e) {
8878
- if (!e.every(L.isDateTime))
8878
+ if (!e.every(V.isDateTime))
8879
8879
  throw new we("max requires all arguments be DateTimes");
8880
8880
  return Ir(e, (t) => t.valueOf(), Math.max);
8881
8881
  }
@@ -8899,7 +8899,7 @@ class L {
8899
8899
  * @deprecated use fromFormatExplain instead
8900
8900
  */
8901
8901
  static fromStringExplain(e, t, s = {}) {
8902
- return L.fromFormatExplain(e, t, s);
8902
+ return V.fromFormatExplain(e, t, s);
8903
8903
  }
8904
8904
  /**
8905
8905
  * Build a parser for `fmt` using the given locale. This parser can be passed
@@ -8946,7 +8946,7 @@ class L {
8946
8946
  `fromFormatParser called with a locale of ${a}, but the format parser was created for ${t.locale}`
8947
8947
  );
8948
8948
  const { result: o, zone: l, specificOffset: c, invalidReason: u } = t.explainFromTokens(e);
8949
- return u ? L.invalid(u) : bt(
8949
+ return u ? V.invalid(u) : bt(
8950
8950
  o,
8951
8951
  l,
8952
8952
  s,
@@ -9112,12 +9112,12 @@ class L {
9112
9112
  }
9113
9113
  }
9114
9114
  function Zt(n) {
9115
- if (L.isDateTime(n))
9115
+ if (V.isDateTime(n))
9116
9116
  return n;
9117
9117
  if (n && n.valueOf && rt(n.valueOf()))
9118
- return L.fromJSDate(n);
9118
+ return V.fromJSDate(n);
9119
9119
  if (n && typeof n == "object")
9120
- return L.fromObject(n);
9120
+ return V.fromObject(n);
9121
9121
  throw new we(
9122
9122
  `Unknown datetime argument: ${n}, of type ${typeof n}`
9123
9123
  );
@@ -9173,7 +9173,9 @@ const Dc = (n, e) => {
9173
9173
  case "Number":
9174
9174
  n.autoIncrement ? s = ke([ts(), ht().int()], {
9175
9175
  message: "Must be a valid number"
9176
- }) : (s = ht(), n.min && (s = s.min(n.min, `Must be greater than or equal to ${n.min}`)), n.max && (s = s.max(n.max, `Must be less than or equal to ${n.max}`)), n.decimal ? t ? s = s.describe(`${r}Must have ${n.decimal} decimal places`) : s = s.refine((l) => n.decimal ? (l.toString().split(".")[1]?.length || 0) <= n.decimal : !1, {
9176
+ }) : (s = ht({
9177
+ message: "Must be a valid number"
9178
+ }), n.min && (s = s.min(n.min, `Must be greater than or equal to ${n.min}`)), n.max && (s = s.max(n.max, `Must be less than or equal to ${n.max}`)), n.decimal ? t ? s = s.describe(`${r}Must have ${n.decimal} decimal places`) : s = s.refine((l) => n.decimal ? (l.toString().split(".")[1]?.length || 0) <= n.decimal : !1, {
9177
9179
  message: `Must have ${n.decimal} or fewer decimal places`
9178
9180
  }) : s = s.int("Must not have decimal places"), n.values ? (t || (s = ke([
9179
9181
  s.refine((l) => n.values?.includes(l), {
@@ -9186,10 +9188,10 @@ const Dc = (n, e) => {
9186
9188
  t ? (s = je({
9187
9189
  seconds: ht(),
9188
9190
  nanoseconds: ht()
9189
- }), n.min && n.max ? s = s.describe(`${r}Must be between ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)} and ${L.fromMillis(n.max).toLocaleString(L.DATE_MED)}`) : n.min ? s = s.describe(`${r}Must be greater than or equal to ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)}`) : n.max ? s = s.describe(`${r}Must be less than or equal to ${L.fromMillis(n.max).toLocaleString(L.DATE_MED)}`) : r && (s = s.describe(r.trim()))) : (s = Cc(), n.min && (s = s.refine((l) => l.toMillis() >= n.min, {
9190
- message: `Must be greater than or equal to ${L.fromMillis(n.min).toLocaleString(L.DATE_MED)}`
9191
+ }), n.min && n.max ? s = s.describe(`${r}Must be between ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)} and ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`) : n.min ? s = s.describe(`${r}Must be greater than or equal to ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)}`) : n.max ? s = s.describe(`${r}Must be less than or equal to ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`) : r && (s = s.describe(r.trim()))) : (s = Cc(), n.min && (s = s.refine((l) => l.toMillis() >= n.min, {
9192
+ message: `Must be greater than or equal to ${V.fromMillis(n.min).toLocaleString(V.DATE_MED)}`
9191
9193
  })), n.max && (s = s.refine((l) => l.toMillis() <= n.max, {
9192
- message: `Must be less than or equal to ${L.fromMillis(n.max).toLocaleString(L.DATE_MED)}`
9194
+ message: `Must be less than or equal to ${V.fromMillis(n.max).toLocaleString(V.DATE_MED)}`
9193
9195
  })));
9194
9196
  break;
9195
9197
  case "Array":
@@ -9224,7 +9226,7 @@ const Dc = (n, e) => {
9224
9226
  o[`attribute-${c.labels.collection}-${u.type}`] = Qt().optional();
9225
9227
  }), c.access.entityRestrictions?.restrictions?.forEach((u) => {
9226
9228
  if (u.type === "Individual" && (o[`accessible-${c.labels.collection}-${c.labels.collection}`] = je({}).catchall(ge()).optional()), u.type === "Parent" || u.type === "Parent_Property") {
9227
- const m = U(c.fields, u.collectionField);
9229
+ const m = W(c.fields, u.collectionField);
9228
9230
  o[`accessible-${c.labels.collection}-${m.collection}`] = je({}).catchall(ge()).optional();
9229
9231
  }
9230
9232
  });
@@ -9242,143 +9244,143 @@ const Dc = (n, e) => {
9242
9244
  for (const o of s.fields)
9243
9245
  await Hr(o.custom?.preValidate, r);
9244
9246
  return Aa(n, t, i).parse(e), e;
9245
- }, Ys = (n, e, t, s, r, i, a, o, l, c, u, m, d, f, h, v, p, E, O, N, w) => {
9246
- const { fields: T } = a;
9247
- T.filter((y) => "unique" in y && y.unique).forEach((y) => {
9247
+ }, Ys = (n, e, t, s, r, i, a, o, l, c, u, m, d, f, h, v, p, E, O, R, x) => {
9248
+ const { fields: _ } = a;
9249
+ _.filter((y) => "unique" in y && y.unique).forEach((y) => {
9248
9250
  n !== "delete" && (typeof r[y.name] == "string" || typeof r[y.name] == "number") && (e.set(f(y, r[y.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||")), {
9249
9251
  id: s,
9250
9252
  Collection_Path: t
9251
- }), w && w.size++);
9252
- }), T.forEach((y) => {
9253
+ }), x && x.size++);
9254
+ }), _.forEach((y) => {
9253
9255
  if (ct(y, a, i)) {
9254
- const k = dn(y, a, i), _ = {};
9255
- r[y.name] !== void 0 && (_[y.name] = r[y.name], K(y) && (_[`${y.name}_Array`] = r[`${y.name}_Array`])), k.forEach((B) => {
9256
- r[B.name] !== void 0 && (K(B) ? _[`${B.name}_Array`] = r[`${B.name}_Array`] : _[B.name] = r[B.name]);
9257
- }), Object.keys(_).length > 0 && (n === "create" && (_.Collection_Path = t, _.Collection_Path_String = t.join("/"), e.set(d(y), _)), n === "update" && e.update(d(y), _), n === "delete" && e.delete(d(y)), w && w.size++);
9256
+ const k = dn(y, a, i), w = {};
9257
+ r[y.name] !== void 0 && (w[y.name] = r[y.name], K(y) && (w[`${y.name}_Array`] = r[`${y.name}_Array`])), k.forEach((B) => {
9258
+ r[B.name] !== void 0 && (K(B) ? w[`${B.name}_Array`] = r[`${B.name}_Array`] : w[B.name] = r[B.name]);
9259
+ }), Object.keys(w).length > 0 && (n === "create" && (w.Collection_Path = t, w.Collection_Path_String = t.join("/"), e.set(d(y), w)), n === "update" && e.update(d(y), w), n === "delete" && e.delete(d(y)), x && x.size++);
9258
9260
  }
9259
9261
  });
9260
- const D = l[a.labels.collection];
9261
- for (const y of D) {
9262
- const k = na(y, a), _ = { ...r };
9262
+ const N = l[a.labels.collection];
9263
+ for (const y of N) {
9264
+ const k = na(y, a), w = { ...r };
9263
9265
  k.forEach((B) => {
9264
- delete _[B.name], delete _[`${B.name}_Array`], delete _[`${B.name}_Single`], delete _[`${B.name}_Lowercase`];
9265
- }), Object.keys(_).length > 0 && (n === "create" && (_.Collection_Path ||= t, _.Collection_Path_String = t.join("/"), e.set(h(y.key), _)), n === "update" && e.update(h(y.key), _), n === "delete" && e.delete(h(y.key)), w && w.size++);
9266
+ delete w[B.name], delete w[`${B.name}_Array`], delete w[`${B.name}_Single`], delete w[`${B.name}_Lowercase`];
9267
+ }), Object.keys(w).length > 0 && (n === "create" && (w.Collection_Path ||= t, w.Collection_Path_String = t.join("/"), e.set(h(y.key), w)), n === "update" && e.update(h(y.key), w), n === "delete" && e.delete(h(y.key)), x && x.size++);
9266
9268
  }
9267
9269
  const C = (y, k) => {
9268
- let _ = 1;
9269
- ct(k, y, i) && _++, y.fields.forEach((g) => {
9270
- ct(g, y, i) && JSON.parse(Kn(dn(g, y, i))).includes(k.name) && _++;
9270
+ let w = 1;
9271
+ ct(k, y, i) && w++, y.fields.forEach((g) => {
9272
+ ct(g, y, i) && JSON.parse(Kn(dn(g, y, i))).includes(k.name) && w++;
9271
9273
  });
9272
9274
  const B = l[y.labels.collection];
9273
9275
  for (const g of B)
9274
- g.fields.some((R) => R.name === k.name) && K(k) && _++;
9275
- return _;
9276
- }, W = (y, k, _, B, g) => {
9277
- const R = {};
9278
- R[`${_.name}.${s}`] = m(), R[`${_.name}_Array`] = u(s), R[`${_.name}_Single`] = m(), e.update(v(g, B), R), ct(_, k, i) && e.update(p(y, _.name, B), {
9279
- [`${_.name}.${s}`]: m(),
9280
- [`${_.name}_Array`]: u(s)
9276
+ g.fields.some((T) => T.name === k.name) && K(k) && w++;
9277
+ return w;
9278
+ }, L = (y, k, w, B, g) => {
9279
+ const T = {};
9280
+ T[`${w.name}.${s}`] = m(), T[`${w.name}_Array`] = u(s), T[`${w.name}_Single`] = m(), e.update(v(g, B), T), ct(w, k, i) && e.update(p(y, w.name, B), {
9281
+ [`${w.name}.${s}`]: m(),
9282
+ [`${w.name}_Array`]: u(s)
9281
9283
  }), k.fields.forEach(($) => {
9282
- ct($, k, i) && JSON.parse(Kn(dn($, k, i))).includes(_.name) && e.update(p(y, $.name, B), {
9283
- [`${_.name}_Array`]: u(s)
9284
+ ct($, k, i) && JSON.parse(Kn(dn($, k, i))).includes(w.name) && e.update(p(y, $.name, B), {
9285
+ [`${w.name}_Array`]: u(s)
9284
9286
  });
9285
9287
  });
9286
9288
  const S = l[k.labels.collection];
9287
9289
  for (const $ of S)
9288
- $.fields.some((I) => I.name === _.name) && K(_) && e.update(E(y, $.key, B), R);
9290
+ $.fields.some((D) => D.name === w.name) && K(w) && e.update(E(y, $.key, B), T);
9289
9291
  };
9290
9292
  if (n === "delete")
9291
9293
  return;
9292
- const x = T.filter((y) => K(y) && y.twoWay);
9294
+ const I = _.filter((y) => K(y) && y.twoWay);
9293
9295
  if (!o?.noTwoWay) {
9294
- for (const y of x) {
9295
- if (!w)
9296
+ for (const y of I) {
9297
+ if (!x)
9296
9298
  throw new Error("VALIDATION_ERROR: batchSize is required");
9297
- const k = i.collections[y.collection], _ = U(k.fields, y.twoWay), B = ft(k, k.fields), g = Array.from(B).map((R) => R.name);
9298
- if (!_)
9299
+ const k = i.collections[y.collection], w = W(k.fields, y.twoWay), B = ft(k, k.fields), g = Array.from(B).map((T) => T.name);
9300
+ if (!w)
9299
9301
  throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
9300
- if (K(_)) {
9302
+ if (K(w)) {
9301
9303
  if (r[`${y.name}_Array`])
9302
- for (const [R, S] of Object.entries(r[y.name])) {
9303
- if (n === "update" && O && O[`${y.name}_Array`]?.includes(R))
9304
+ for (const [T, S] of Object.entries(r[y.name])) {
9305
+ if (n === "update" && O && O[`${y.name}_Array`]?.includes(T))
9304
9306
  continue;
9305
9307
  const $ = { ...O, ...r };
9306
9308
  nt($);
9307
- const I = {};
9308
- _.includeFields && _.includeFields.forEach((F) => {
9309
+ const D = {};
9310
+ w.includeFields && w.includeFields.forEach((F) => {
9309
9311
  if ($[F] !== void 0) {
9310
- I[F] = $[F];
9311
- const z = U(a.fields, F);
9312
- wt(a, [z]).size === 1 && (I[`${F}_Lowercase`] = $[`${F}_Lowercase`]);
9312
+ D[F] = $[F];
9313
+ const z = W(a.fields, F);
9314
+ wt(a, [z]).size === 1 && (D[`${F}_Lowercase`] = $[`${F}_Lowercase`]);
9313
9315
  }
9314
9316
  });
9315
9317
  const j = {
9316
9318
  [`${y.twoWay}.${s}`]: {
9317
9319
  Collection_Path: t,
9318
- ...I
9320
+ ...D
9319
9321
  },
9320
9322
  [`${y.twoWay}_Array`]: c(s)
9321
9323
  };
9322
- g.includes(_.name) && (j[`${y.twoWay}_Single`] = {
9324
+ g.includes(w.name) && (j[`${y.twoWay}_Single`] = {
9323
9325
  Collection_Path: t,
9324
- ...I
9326
+ ...D
9325
9327
  });
9326
9328
  const q = Sn(r);
9327
- e.update(v(S.Collection_Path, R), {
9329
+ e.update(v(S.Collection_Path, T), {
9328
9330
  ...j,
9329
9331
  ...q
9330
- }), w.size++, ct(_, k, i) && (e.update(p(y, _.name, R), {
9331
- [`${_.name}.${s}`]: {
9332
+ }), x.size++, ct(w, k, i) && (e.update(p(y, w.name, T), {
9333
+ [`${w.name}.${s}`]: {
9332
9334
  Collection_Path: t,
9333
- ...I
9335
+ ...D
9334
9336
  },
9335
- [`${_.name}_Array`]: c(s)
9336
- }), w.size++), k.fields.forEach((F) => {
9337
+ [`${w.name}_Array`]: c(s)
9338
+ }), x.size++), k.fields.forEach((F) => {
9337
9339
  if (ct(F, k, i)) {
9338
9340
  const z = JSON.parse(Kn(dn(F, k, i))), Q = {};
9339
- z.includes(_.name) && (Q[`${y.twoWay}_Array`] = c(s)), Object.keys(q).forEach((oe) => {
9341
+ z.includes(w.name) && (Q[`${y.twoWay}_Array`] = c(s)), Object.keys(q).forEach((oe) => {
9340
9342
  z.includes(oe) && (Q[oe] = q[oe]);
9341
- }), Object.keys(Q).length > 0 && (e.update(p(y, F.name, R), Q), w.size++);
9343
+ }), Object.keys(Q).length > 0 && (e.update(p(y, F.name, T), Q), x.size++);
9342
9344
  }
9343
9345
  });
9344
9346
  const b = l[k.labels.collection];
9345
9347
  for (const F of b)
9346
- if (F.fields.some((z) => z.name === _.name)) {
9348
+ if (F.fields.some((z) => z.name === w.name)) {
9347
9349
  const z = { ...j };
9348
9350
  Object.keys(q).forEach((Q) => {
9349
9351
  F.fields.some((oe) => oe.name === Q) && (z[Q] = q[Q]);
9350
- }), Object.keys(z).length > 0 && (e.update(E(y, F.key, R), z), w.size++);
9352
+ }), Object.keys(z).length > 0 && (e.update(E(y, F.key, T), z), x.size++);
9351
9353
  }
9352
9354
  }
9353
9355
  } else
9354
- throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9356
+ throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
9355
9357
  }
9356
- w && w.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${w.size} operations in the Firestore transaction has exceeded the recommended limit of 500. This is likely due to a large number of two way updates, roles, dependencies on the collection, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
9357
- for (const y of x) {
9358
- if (!w)
9358
+ x && x.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${x.size} operations in the Firestore transaction has exceeded the recommended limit of 500. This is likely due to a large number of two way updates, roles, dependencies on the collection, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
9359
+ for (const y of I) {
9360
+ if (!x)
9359
9361
  throw new Error("VALIDATION_ERROR: batchSize is required");
9360
- const k = i.collections[y.collection], _ = U(k.fields, y.twoWay);
9361
- if (!_)
9362
+ const k = i.collections[y.collection], w = W(k.fields, y.twoWay);
9363
+ if (!w)
9362
9364
  throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
9363
- if (K(_)) {
9365
+ if (K(w)) {
9364
9366
  if (n === "update" && O && !(r[y.name] && Fe(r[y.name])) && r[`${y.name}_Array`] && O[`${y.name}_Array`]?.length > 0)
9365
9367
  for (const [B, g] of Object.entries(O[y.name]))
9366
- !r[`${y.name}_Array`].includes(B) && !N?.get(y.name)?.includes(B) && (w.size += C(k, _), w.size <= 500 && W(y, k, _, B, g.Collection_Path));
9368
+ !r[`${y.name}_Array`].includes(B) && !R?.get(y.name)?.includes(B) && (x.size += C(k, w), x.size <= 500 && L(y, k, w, B, g.Collection_Path));
9367
9369
  } else
9368
- throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9370
+ throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
9369
9371
  }
9370
- for (const y of x) {
9371
- if (!w)
9372
+ for (const y of I) {
9373
+ if (!x)
9372
9374
  throw new Error("VALIDATION_ERROR: batchSize is required");
9373
- const k = i.collections[y.collection], _ = U(k.fields, y.twoWay);
9374
- if (!_)
9375
+ const k = i.collections[y.collection], w = W(k.fields, y.twoWay);
9376
+ if (!w)
9375
9377
  throw new Error(`SCHEMA_ERROR: Field ${y.twoWay} not found in collection ${y.collection}`);
9376
- if (K(_)) {
9378
+ if (K(w)) {
9377
9379
  if (n === "update" && O && r[y.name] && Fe(r[y.name]) && O[`${y.name}_Array`]?.length > 0)
9378
9380
  for (const [B, g] of Object.entries(O[y.name]))
9379
- N?.get(y.name)?.includes(B) || (w.size += C(k, _), w.size <= 500 && W(y, k, _, B, g.Collection_Path));
9381
+ R?.get(y.name)?.includes(B) || (x.size += C(k, w), x.size <= 500 && L(y, k, w, B, g.Collection_Path));
9380
9382
  } else
9381
- throw new Error(`SCHEMA_ERROR: Invalid field type: ${_.type}`);
9383
+ throw new Error(`SCHEMA_ERROR: Invalid field type: ${w.type}`);
9382
9384
  }
9383
9385
  }
9384
9386
  }, Ue = (n) => {
@@ -9568,99 +9570,99 @@ const Rt = {
9568
9570
  const f = r.collections?.[l.collection];
9569
9571
  if (!r.Role)
9570
9572
  throw new Error("PERMISSION_DENIED");
9571
- const h = f && Re("Read", f), v = ai(o, t, r), p = ii(o, r), E = Fs(o, r), O = oi(o, t, r), N = (g = []) => {
9572
- const R = [], S = fi(r.Role, o, t);
9573
+ const h = f && Re("Read", f), v = ai(o, t, r), p = ii(o, r), E = Fs(o, r), O = oi(o, t, r), R = (g = []) => {
9574
+ const T = [], S = fi(r.Role, o, t);
9573
9575
  if (!S)
9574
9576
  throw new Error("PERMISSION_DENIED");
9575
9577
  if (h) {
9576
9578
  let $ = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${S.key}`).where("Collection_Path_String", "==", e.join("/"));
9577
- g.forEach((I) => {
9578
- $ = $.where(...I);
9579
- }), R.push($);
9579
+ g.forEach((D) => {
9580
+ $ = $.where(...D);
9581
+ }), T.push($);
9580
9582
  } else if (v)
9581
9583
  for (const $ of v) {
9582
- let I = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${$.field}`).where("Collection_Path_String", "==", e.join("/"));
9584
+ let D = i.collection("tenants").doc(n).collection("system_fields").doc(l.collection).collection(`${l.collection}-${$.field}`).where("Collection_Path_String", "==", e.join("/"));
9583
9585
  g.forEach((j) => {
9584
- I = I.where(...j);
9585
- }), R.push(I);
9586
+ D = D.where(...j);
9587
+ }), T.push(D);
9586
9588
  }
9587
- return R;
9588
- }, w = p.filter((g) => "operations" in g && g.operations ? g.operations.includes("Read") : !0);
9589
- if (w.length === 0 && E.length === 0 && O.length === 0)
9590
- return N();
9591
- let T = 0;
9592
- const D = (g) => {
9593
- g && (T === 0 ? T = g : T *= g);
9589
+ return T;
9590
+ }, x = p.filter((g) => "operations" in g && g.operations ? g.operations.includes("Read") : !0);
9591
+ if (x.length === 0 && E.length === 0 && O.length === 0)
9592
+ return R();
9593
+ let _ = 0;
9594
+ const N = (g) => {
9595
+ g && (_ === 0 ? _ = g : _ *= g);
9594
9596
  };
9595
- if (w.length > 0) {
9596
- for (const g of w)
9597
+ if (x.length > 0) {
9598
+ for (const g of x)
9597
9599
  if (g.operations && g.type === "Record_Property") {
9598
- const R = g.roles.find((S) => S.role === r.Role);
9599
- if (!R)
9600
+ const T = g.roles.find((S) => S.role === r.Role);
9601
+ if (!T)
9600
9602
  throw new Error("PERMISSION_DENIED");
9601
- D(R.values?.length);
9603
+ N(T.values?.length);
9602
9604
  }
9603
9605
  }
9604
- u?.roles.includes(r.Role) && u.range && D(u.range.fields.length);
9606
+ u?.roles.includes(r.Role) && u.range && N(u.range.fields.length);
9605
9607
  const C = m.admin?.statusField;
9606
- C && !u?.roles.includes(r.Role) && D(Math.max(C.active?.length || 0, C.archived?.length || 0));
9607
- const W = T === 0 ? 30 : Math.max(1, Math.floor(30 / T)), x = [];
9608
- w.filter((g) => g.type === "Record_Owner").forEach(() => x.push(["Created_By", "==", s])), w.filter((g) => g.type === "Record_User").forEach((g) => {
9608
+ C && !u?.roles.includes(r.Role) && N(Math.max(C.active?.length || 0, C.archived?.length || 0));
9609
+ const L = _ === 0 ? 30 : Math.max(1, Math.floor(30 / _)), I = [];
9610
+ x.filter((g) => g.type === "Record_Owner").forEach(() => I.push(["Created_By", "==", s])), x.filter((g) => g.type === "Record_User").forEach((g) => {
9609
9611
  if ("collectionField" in g) {
9610
- const R = U(c, g.collectionField);
9611
- x.push([`${R.name}_Array`, "array-contains", r.Doc_ID]);
9612
+ const T = W(c, g.collectionField);
9613
+ I.push([`${T.name}_Array`, "array-contains", r.Doc_ID]);
9612
9614
  }
9613
- }), w.filter((g) => g.type === "Record_Property").forEach((g) => {
9615
+ }), x.filter((g) => g.type === "Record_Property").forEach((g) => {
9614
9616
  if ("propertyField" in g) {
9615
- const R = g.roles.find(($) => $.role === r.Role);
9616
- if (!R)
9617
+ const T = g.roles.find(($) => $.role === r.Role);
9618
+ if (!T)
9617
9619
  throw new Error("PERMISSION_DENIED");
9618
- const S = U(c, g.propertyField);
9619
- S.type === "Array" ? x.push([`${S.name}_Array`, "array-contains-any", R.values]) : x.push([S.name, "in", R.values]);
9620
+ const S = W(c, g.propertyField);
9621
+ S.type === "Array" ? I.push([`${S.name}_Array`, "array-contains-any", T.values]) : I.push([S.name, "in", T.values]);
9620
9622
  }
9621
9623
  });
9622
9624
  const y = [];
9623
9625
  E.filter((g) => g.type === "Individual").forEach((g) => {
9624
- const R = f?.individualEntities, S = [];
9625
- if (R) {
9626
- const $ = g.singleQuery ? g.singleQuery : W;
9627
- for (let I = 0; I < R.length; I += $) {
9628
- const j = R.slice(I, I + $);
9626
+ const T = f?.individualEntities, S = [];
9627
+ if (T) {
9628
+ const $ = g.singleQuery ? g.singleQuery : L;
9629
+ for (let D = 0; D < T.length; D += $) {
9630
+ const j = T.slice(D, D + $);
9629
9631
  S.push(j);
9630
9632
  }
9631
9633
  if (!g.singleQuery)
9632
- S.forEach((I) => {
9633
- y.push(...N(x.concat([["id", "in", I]])));
9634
+ S.forEach((D) => {
9635
+ y.push(...R(I.concat([["id", "in", D]])));
9634
9636
  });
9635
9637
  else {
9636
- if (R.length > $)
9638
+ if (T.length > $)
9637
9639
  throw new Error(`INPUT_ERROR: Individual entity restriction with singleQuery set to true must not have more than ${g.singleQuery} entities`);
9638
- x.push(["id", "in", R]);
9640
+ I.push(["id", "in", T]);
9639
9641
  }
9640
9642
  }
9641
9643
  }), O.filter((g) => g.parentFilter.type === "Individual").forEach((g) => {
9642
- const { parentFilter: R, parentRestriction: S } = g;
9643
- if ("collectionField" in R) {
9644
- const $ = U(c, R.collectionField);
9644
+ const { parentFilter: T, parentRestriction: S } = g;
9645
+ if ("collectionField" in T) {
9646
+ const $ = W(c, T.collectionField);
9645
9647
  if ("collection" in $) {
9646
- const I = r.collections?.[$.collection];
9647
- if (!I)
9648
+ const D = r.collections?.[$.collection];
9649
+ if (!D)
9648
9650
  throw new Error("PERMISSION_DENIED");
9649
- const j = I.individualEntities, q = [];
9651
+ const j = D.individualEntities, q = [];
9650
9652
  if (j) {
9651
- const b = S.singleQuery ? S.singleQuery : W;
9653
+ const b = S.singleQuery ? S.singleQuery : L;
9652
9654
  for (let F = 0; F < j.length; F += b) {
9653
9655
  const z = j.slice(F, F + b);
9654
9656
  q.push(z);
9655
9657
  }
9656
9658
  if (!S.singleQuery)
9657
9659
  q.forEach((F) => {
9658
- y.push(...N(x.concat([[`${$.name}_Array`, "array-contains-any", F]])));
9660
+ y.push(...R(I.concat([[`${$.name}_Array`, "array-contains-any", F]])));
9659
9661
  });
9660
9662
  else {
9661
9663
  if (j.length > b)
9662
9664
  throw new Error(`INPUT_ERROR: Individual entity parentFilter with singleQuery set to true must not have more than ${S.singleQuery} entities`);
9663
- x.push([`${$.name}_Array`, "array-contains-any", j]);
9665
+ I.push([`${$.name}_Array`, "array-contains-any", j]);
9664
9666
  }
9665
9667
  }
9666
9668
  }
@@ -9669,53 +9671,53 @@ const Rt = {
9669
9671
  const k = [];
9670
9672
  E.filter((g) => g.type === "Parent").forEach((g) => {
9671
9673
  if ("collectionField" in g) {
9672
- const R = U(c, g.collectionField);
9673
- if ("collection" in R) {
9674
+ const T = W(c, g.collectionField);
9675
+ if ("collection" in T) {
9674
9676
  const S = f?.parentEntities, $ = [];
9675
9677
  if (S) {
9676
- const I = g.singleQuery ? g.singleQuery : W;
9677
- for (let j = 0; j < S.length; j += I) {
9678
- const q = S.slice(j, j + I);
9678
+ const D = g.singleQuery ? g.singleQuery : L;
9679
+ for (let j = 0; j < S.length; j += D) {
9680
+ const q = S.slice(j, j + D);
9679
9681
  $.push(q);
9680
9682
  }
9681
9683
  if (!g.singleQuery)
9682
9684
  $.forEach((j) => {
9683
- k.push(...N(x.concat([[`${R.name}_Array`, "array-contains-any", j]])));
9685
+ k.push(...R(I.concat([[`${T.name}_Array`, "array-contains-any", j]])));
9684
9686
  });
9685
9687
  else {
9686
- if (S && S.length > I)
9688
+ if (S && S.length > D)
9687
9689
  throw new Error(`INPUT_ERROR: Parent entity restriction with singleQuery set to true must not have more than ${g.singleQuery} entities`);
9688
- x.push([`${R.name}_Array`, "array-contains-any", S]);
9690
+ I.push([`${T.name}_Array`, "array-contains-any", S]);
9689
9691
  }
9690
9692
  }
9691
9693
  }
9692
9694
  }
9693
9695
  }), O.filter((g) => g.parentFilter.type === "Parent").forEach((g) => {
9694
- const { parentFilter: R, parentRestriction: S } = g;
9695
- if ("collectionField" in R && "parentCollectionField" in R) {
9696
- const $ = U(c, R.collectionField), I = U(c, R.parentCollectionField);
9697
- if ("collection" in $ && "collection" in I) {
9696
+ const { parentFilter: T, parentRestriction: S } = g;
9697
+ if ("collectionField" in T && "parentCollectionField" in T) {
9698
+ const $ = W(c, T.collectionField), D = W(c, T.parentCollectionField);
9699
+ if ("collection" in $ && "collection" in D) {
9698
9700
  const j = r.collections?.[$.collection];
9699
9701
  if (!j)
9700
9702
  throw new Error("PERMISSION_DENIED");
9701
9703
  const q = j.parentEntities, b = [];
9702
9704
  if (q) {
9703
- const F = S.singleQuery ? S.singleQuery : W;
9705
+ const F = S.singleQuery ? S.singleQuery : L;
9704
9706
  for (let z = 0; z < q.length; z += F) {
9705
9707
  const Q = q.slice(z, z + F);
9706
9708
  b.push(Q);
9707
9709
  }
9708
9710
  if (!S.singleQuery)
9709
9711
  b.forEach((z) => {
9710
- k.push(...N(x.concat([
9711
- [`${I.name}_Array`, "array-contains-any", z]
9712
+ k.push(...R(I.concat([
9713
+ [`${D.name}_Array`, "array-contains-any", z]
9712
9714
  ])));
9713
9715
  });
9714
9716
  else {
9715
9717
  if (q && q.length > F)
9716
9718
  throw new Error(`INPUT_ERROR: Profile_Parent entity parentFilter with singleQuery set to true must not have more than ${S.singleQuery} entities`);
9717
- x.push([
9718
- `${I.name}_Array`,
9719
+ I.push([
9720
+ `${D.name}_Array`,
9719
9721
  "array-contains-any",
9720
9722
  q
9721
9723
  ]);
@@ -9724,23 +9726,23 @@ const Rt = {
9724
9726
  }
9725
9727
  }
9726
9728
  });
9727
- const _ = [];
9729
+ const w = [];
9728
9730
  k.length === 0 && (E.filter((g) => g.type === "Parent_Property").forEach((g) => {
9729
9731
  if ("collectionField" in g && "propertyField" in g) {
9730
- const R = U(c, g.collectionField), S = U(c, g.propertyField);
9731
- if ("collection" in R) {
9732
+ const T = W(c, g.collectionField), S = W(c, g.propertyField);
9733
+ if ("collection" in T) {
9732
9734
  const $ = f?.parentPropertyEntities || {};
9733
- Object.entries($).forEach(([I, j]) => {
9735
+ Object.entries($).forEach(([D, j]) => {
9734
9736
  if (j.length > 0) {
9735
9737
  const q = [];
9736
- for (let b = 0; b < j.length; b += W) {
9737
- const F = j.slice(b, b + W);
9738
+ for (let b = 0; b < j.length; b += L) {
9739
+ const F = j.slice(b, b + L);
9738
9740
  q.push(F);
9739
9741
  }
9740
9742
  q.forEach((b) => {
9741
- _.push(...N(x.concat([
9742
- [`${R.name}_Array`, "array-contains-any", b],
9743
- [S.name, "==", I]
9743
+ w.push(...R(I.concat([
9744
+ [`${T.name}_Array`, "array-contains-any", b],
9745
+ [S.name, "==", D]
9744
9746
  ])));
9745
9747
  });
9746
9748
  }
@@ -9748,9 +9750,9 @@ const Rt = {
9748
9750
  }
9749
9751
  }
9750
9752
  }), O.filter((g) => g.parentFilter.type === "Parent_Property").forEach((g) => {
9751
- const { parentFilter: R } = g;
9752
- if ("collectionField" in R && "parentCollectionField" in R && "parentPropertyField" in R) {
9753
- const S = U(c, R.collectionField), $ = U(c, R.parentCollectionField), I = U(c, R.parentPropertyField);
9753
+ const { parentFilter: T } = g;
9754
+ if ("collectionField" in T && "parentCollectionField" in T && "parentPropertyField" in T) {
9755
+ const S = W(c, T.collectionField), $ = W(c, T.parentCollectionField), D = W(c, T.parentPropertyField);
9754
9756
  if ("collection" in S && "collection" in $) {
9755
9757
  const j = r.collections?.[S.collection];
9756
9758
  if (!j)
@@ -9759,18 +9761,18 @@ const Rt = {
9759
9761
  Object.entries(q).forEach(([b, F]) => {
9760
9762
  if (F.length > 0) {
9761
9763
  const z = [];
9762
- for (let Q = 0; Q < F.length; Q += W) {
9763
- const oe = F.slice(Q, Q + W);
9764
+ for (let Q = 0; Q < F.length; Q += L) {
9765
+ const oe = F.slice(Q, Q + L);
9764
9766
  z.push(oe);
9765
9767
  }
9766
9768
  z.forEach((Q) => {
9767
- _.push(...N(x.concat([
9769
+ w.push(...R(I.concat([
9768
9770
  [
9769
9771
  `${$.name}_Array`,
9770
9772
  "array-contains-any",
9771
9773
  Q
9772
9774
  ],
9773
- [I.name, "==", b]
9775
+ [D.name, "==", b]
9774
9776
  ])));
9775
9777
  });
9776
9778
  }
@@ -9778,8 +9780,8 @@ const Rt = {
9778
9780
  }
9779
9781
  }
9780
9782
  }));
9781
- const B = [...y, ...k, ..._];
9782
- return !E.length && !O.length ? N(x) : B;
9783
+ const B = [...y, ...k, ...w];
9784
+ return !E.length && !O.length ? R(I) : B;
9783
9785
  } else
9784
9786
  throw new Error("PERMISSION_DENIED");
9785
9787
  else return [d];
@@ -9893,10 +9895,10 @@ const Rt = {
9893
9895
  const p = Wt(), E = n.at(-1);
9894
9896
  if (!E)
9895
9897
  throw new Error("EMPTY_PATH");
9896
- const O = Object.keys(h.collections).includes(E), N = p.disabledCollections?.includes(E);
9897
- if (!O || N)
9898
+ const O = Object.keys(h.collections).includes(E), R = p.disabledCollections?.includes(E);
9899
+ if (!O || R)
9898
9900
  throw new Error("COLLECTION_NOT_FOUND");
9899
- const w = h.collections[E], { labels: T } = w, D = Qe(T.collection, h);
9901
+ const x = h.collections[E], { labels: _ } = x, N = Qe(_.collection, h);
9900
9902
  if (t?.user) {
9901
9903
  if (!u?.exists)
9902
9904
  throw new Error("PERMISSION_DENIED");
@@ -9908,8 +9910,8 @@ const Rt = {
9908
9910
  let C = Fc(s, n, h, t?.user, v);
9909
9911
  if (C.length === 0)
9910
9912
  return { cursor: {}, pages: 0, docs: [] };
9911
- if (e && (C = C.map((g) => (e.forEach(([R, S, $]) => {
9912
- g = g.where(R, S, $);
9913
+ if (e && (C = C.map((g) => (e.forEach(([T, S, $]) => {
9914
+ g = g.where(T, S, $);
9913
9915
  }), g))), a = t?.pagination?.startAfter || t?.pagination?.endBefore || {
9914
9916
  first: /* @__PURE__ */ new Map(),
9915
9917
  last: /* @__PURE__ */ new Map()
@@ -9918,36 +9920,36 @@ const Rt = {
9918
9920
  throw new Error("INPUT_ERROR: startAfter and endBefore cannot be provided together");
9919
9921
  const g = t.pagination.startAfter || t.pagination.endBefore;
9920
9922
  if (t?.user) {
9921
- const R = Ko(v.Role, w, h);
9922
- if (g && R !== !0)
9923
- throw new Error("INPUT_ERROR: Pagination is not allowed when using " + R);
9923
+ const T = Ko(v.Role, x, h);
9924
+ if (g && T !== !0)
9925
+ throw new Error("INPUT_ERROR: Pagination is not allowed when using " + T);
9924
9926
  }
9925
- t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((R) => R.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((R, S) => R.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((R, S) => R.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).endBefore(a.first.get(S)).limitToLast(t.pagination.number)) : !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((R) => R.limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((R, S) => R.startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((R, S) => R.endBefore(a.first.get(S)).limitToLast(t.pagination.number));
9927
+ t.pagination.orderByField && t.pagination.orderByDirection ? !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((T) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((T, S) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((T, S) => T.orderBy(t.pagination.orderByField, t.pagination.orderByDirection).endBefore(a.first.get(S)).limitToLast(t.pagination.number)) : !t.pagination.startAfter && !t.pagination.endBefore ? C = C.map((T) => T.limit(t.pagination.number)) : t.pagination.startAfter ? C = C.map((T, S) => T.startAfter(a.last.get(S)).limit(t.pagination.number)) : C = C.map((T, S) => T.endBefore(a.first.get(S)).limitToLast(t.pagination.number));
9926
9928
  }
9927
- const W = {};
9928
- await ie("preOperation", p, D, ["read", void 0, void 0, W]), await ie("preRead", p, D, [W, C, !0, !1]), o = /* @__PURE__ */ new Map();
9929
- const k = C.map(async (g) => await c.get(g)), _ = await Promise.all(k);
9930
- for (const g of _) {
9931
- for (const R of g.docs) {
9932
- o.has(R.id) || o.set(R.id, {});
9933
- const S = R.data(), $ = o.get(R.id);
9934
- $.id ||= R.id;
9935
- const I = { ...$, ...S };
9936
- delete I.Collection_Path_String, o.set(R.id, I);
9929
+ const L = {};
9930
+ await ie("preOperation", p, N, ["read", void 0, void 0, L]), await ie("preRead", p, N, [L, C, !0, !1]), o = /* @__PURE__ */ new Map();
9931
+ const k = C.map(async (g) => await c.get(g)), w = await Promise.all(k);
9932
+ for (const g of w) {
9933
+ for (const T of g.docs) {
9934
+ o.has(T.id) || o.set(T.id, {});
9935
+ const S = T.data(), $ = o.get(T.id);
9936
+ $.id ||= T.id;
9937
+ const D = { ...$, ...S };
9938
+ delete D.Collection_Path_String, o.set(T.id, D);
9937
9939
  }
9938
- a.first.set(_.indexOf(g), g.docs[0]), a.last.set(_.indexOf(g), g.docs.at(-1) || g.docs[0]);
9940
+ a.first.set(w.indexOf(g), g.docs[0]), a.last.set(w.indexOf(g), g.docs.at(-1) || g.docs[0]);
9939
9941
  }
9940
9942
  if (t?.pagination) {
9941
9943
  let g = C[0];
9942
- e && (g = e.reduce((I, [j, q, b]) => I.where(j, q, b), g)), t.pagination.orderByField && t.pagination.orderByDirection && (g = g.orderBy(t.pagination.orderByField, t.pagination.orderByDirection));
9944
+ e && (g = e.reduce((D, [j, q, b]) => D.where(j, q, b), g)), t.pagination.orderByField && t.pagination.orderByDirection && (g = g.orderBy(t.pagination.orderByField, t.pagination.orderByDirection));
9943
9945
  const S = (await g.count().get()).data().count, $ = t.pagination.number;
9944
9946
  i = $ > 0 ? Math.ceil(S / $) : 0;
9945
9947
  }
9946
9948
  let B;
9947
- t?.noComputedFields || (B = await re(D.admin?.retriever));
9949
+ t?.noComputedFields || (B = await re(N.admin?.retriever));
9948
9950
  for (const g of o.values()) {
9949
- const R = [], S = [...g.Collection_Path, g.id];
9950
- t?.subcollections && R.push(To(
9951
+ const T = [], S = [...g.Collection_Path, g.id];
9952
+ t?.subcollections && T.push(To(
9951
9953
  s,
9952
9954
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9953
9955
  o.get(g.id),
@@ -9961,13 +9963,13 @@ const Rt = {
9961
9963
  t?.noEmbeddingFields
9962
9964
  )), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((q) => {
9963
9965
  if (typeof q == "string") {
9964
- const b = w.fields.find((F) => F.name === q);
9966
+ const b = x.fields.find((F) => F.name === q);
9965
9967
  if (b)
9966
9968
  return b;
9967
9969
  throw new Error(`SCHEMA_ERROR: Field ${q} not found in collection ${E}`);
9968
9970
  }
9969
9971
  return q;
9970
- })), R.push(Qs(
9972
+ })), T.push(Qs(
9971
9973
  s,
9972
9974
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
9973
9975
  o.get(g.id),
@@ -9978,11 +9980,11 @@ const Rt = {
9978
9980
  t.user,
9979
9981
  t.transactional ? c : void 0,
9980
9982
  t?.noEmbeddingFields
9981
- ))), await Promise.all(R);
9983
+ ))), await Promise.all(T);
9982
9984
  const $ = [];
9983
- for (const q of w.fields) {
9985
+ for (const q of x.fields) {
9984
9986
  if (q.type === "Computed" && !t?.noComputedFields) {
9985
- const b = De(q, D);
9987
+ const b = De(q, N);
9986
9988
  if (!b.formula)
9987
9989
  continue;
9988
9990
  $.push(re(b.formula, [g, B]).then((F) => {
@@ -9993,19 +9995,19 @@ const Rt = {
9993
9995
  }
9994
9996
  if (await Promise.all($), t?.user && v?.Role) {
9995
9997
  const q = v.Role;
9996
- if (!(D.custom?.serverAccess?.read !== void 0 ? await re(D.custom.serverAccess.read, [q, g]) : !0)) {
9998
+ if (!(N.custom?.serverAccess?.read !== void 0 ? await re(N.custom.serverAccess.read, [q, g]) : !0)) {
9997
9999
  o.delete(g.id);
9998
10000
  continue;
9999
10001
  }
10000
- for (const F of w.fields) {
10001
- const z = !F.access || F.access.includes(q), Q = De(F, D), oe = Q?.custom?.serverAccess?.read !== void 0 ? await re(Q.custom.serverAccess.read, [q, g]) : !0;
10002
+ for (const F of x.fields) {
10003
+ const z = !F.access || F.access.includes(q), Q = De(F, N), oe = Q?.custom?.serverAccess?.read !== void 0 ? await re(Q.custom.serverAccess.read, [q, g]) : !0;
10002
10004
  (!z || !oe) && (K(F) ? (delete o.get(g.id)[F.name], delete o.get(g.id)[`${F.name}_Array`], delete o.get(g.id)[`${F.name}_Single`]) : delete o.get(g.id)[F.name]);
10003
10005
  }
10004
10006
  }
10005
- const I = ["read", g, g.id, W];
10006
- await ie("postOperation", p, D, I), await ie("postRead", p, D, [W, C, g, !1]);
10007
+ const D = ["read", g, g.id, L];
10008
+ await ie("postOperation", p, N, D), await ie("postRead", p, N, [L, C, g, !1]);
10007
10009
  }
10008
- t?.user && await Jo(Array.from(o.values()), w, h, t.user, v);
10010
+ t?.user && await Jo(Array.from(o.values()), x, h, t.user, v);
10009
10011
  };
10010
10012
  return t?.providedTransaction ? await l(t.providedTransaction) : await r.runTransaction(async (c) => {
10011
10013
  await l(c);
@@ -10097,8 +10099,8 @@ const Rt = {
10097
10099
  const p = Object.keys(d.collections).includes(v), E = h.disabledCollections?.includes(v);
10098
10100
  if (!p || E)
10099
10101
  throw new Error("COLLECTION_NOT_FOUND");
10100
- const O = d.collections[v], { labels: N } = O, w = Qe(N.collection, d);
10101
- let T;
10102
+ const O = d.collections[v], { labels: R } = O, x = Qe(R.collection, d);
10103
+ let _;
10102
10104
  if (t?.user) {
10103
10105
  if (!l?.exists)
10104
10106
  throw new Error("PERMISSION_DENIED");
@@ -10106,36 +10108,36 @@ const Rt = {
10106
10108
  throw new Error("USER_ERROR");
10107
10109
  if (!f.Enabled)
10108
10110
  throw new Error("PERMISSION_DENIED");
10109
- if (T = f.collections?.[N.collection], !T)
10111
+ if (_ = f.collections?.[R.collection], !_)
10110
10112
  throw new Error("PERMISSION_DENIED");
10111
10113
  }
10112
- if (t?.user && (!T || !Re("Read", T)))
10114
+ if (t?.user && (!_ || !Re("Read", _)))
10113
10115
  throw new Error("PERMISSION_DENIED");
10114
- const D = So(s, n, e, d, f);
10115
- if (D.length === 0)
10116
+ const N = So(s, n, e, d, f);
10117
+ if (N.length === 0)
10116
10118
  throw new Error("PERMISSION_DENIED");
10117
10119
  const C = {};
10118
- await ie("preOperation", h, w, ["read", void 0, e, C]), await ie("preRead", h, w, [C, D, !1, !1]), i = {};
10119
- const y = D.map((S) => o.get(S)), k = await Promise.all(y);
10120
+ await ie("preOperation", h, x, ["read", void 0, e, C]), await ie("preRead", h, x, [C, N, !1, !1]), i = {};
10121
+ const y = N.map((S) => o.get(S)), k = await Promise.all(y);
10120
10122
  for (const S of k)
10121
10123
  if (S.exists) {
10122
10124
  const $ = S.data();
10123
10125
  i.id ||= S.id, i = { ...i, ...$ }, delete i.Collection_Path_String;
10124
10126
  } else
10125
- throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") || N.collection}`);
10126
- const _ = [], B = n ? [...n, e] : [N.collection, e];
10127
- if (t?.subcollections && _.push(No(s, o, i, B, t.subcollections, d, void 0, t.user)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((S) => {
10127
+ throw new Error(`NOT_FOUND: Document with ID ${e} does not exist at location ${n?.join("/") || R.collection}`);
10128
+ const w = [], B = n ? [...n, e] : [R.collection, e];
10129
+ if (t?.subcollections && w.push(No(s, o, i, B, t.subcollections, d, void 0, t.user)), t?.relations && (t.relations.fields && (t.relations.fields = t.relations.fields.map((S) => {
10128
10130
  if (typeof S == "string") {
10129
- const $ = O.fields.find((I) => I.name === S);
10131
+ const $ = O.fields.find((D) => D.name === S);
10130
10132
  if ($)
10131
10133
  return $;
10132
10134
  throw new Error(`SCHEMA_ERROR: Field ${S} not found in collection ${v}`);
10133
10135
  }
10134
10136
  return S;
10135
- })), _.push(xo(s, o, i, B, d, t.relations, t.user, t.noComputedFields, t.noEmbeddingFields))), await Promise.all(_), !t?.noComputedFields) {
10137
+ })), w.push(xo(s, o, i, B, d, t.relations, t.user, t.noComputedFields, t.noEmbeddingFields))), await Promise.all(w), !t?.noComputedFields) {
10136
10138
  for (const S of O.fields)
10137
10139
  if (S.type === "Computed") {
10138
- const $ = De(S, w);
10140
+ const $ = De(S, x);
10139
10141
  if (!$.formula)
10140
10142
  continue;
10141
10143
  i[S.name] = await $.formula(i);
@@ -10146,14 +10148,14 @@ const Rt = {
10146
10148
  S.type === "Embedding" && delete i[S.name];
10147
10149
  if (t?.user && f?.Role) {
10148
10150
  const S = f.Role;
10149
- if (!(w.custom?.serverAccess?.read !== void 0 ? await re(w.custom?.serverAccess?.read, [S, i]) : !0))
10151
+ if (!(x.custom?.serverAccess?.read !== void 0 ? await re(x.custom?.serverAccess?.read, [S, i]) : !0))
10150
10152
  throw new Error("PERMISSION_DENIED");
10151
- for (const I of O.fields) {
10152
- const j = !I.access || I.access.includes(S), q = De(I, w), b = q?.custom?.serverAccess?.read !== void 0 ? await re(q.custom.serverAccess.read, [S, i]) : !0;
10153
- (!j || !b) && (K(I) ? (delete i[I.name], delete i[`${I.name}_Array`], delete i[`${I.name}_Single`]) : delete i[I.name]);
10153
+ for (const D of O.fields) {
10154
+ const j = !D.access || D.access.includes(S), q = De(D, x), b = q?.custom?.serverAccess?.read !== void 0 ? await re(q.custom.serverAccess.read, [S, i]) : !0;
10155
+ (!j || !b) && (K(D) ? (delete i[D.name], delete i[`${D.name}_Array`], delete i[`${D.name}_Single`]) : delete i[D.name]);
10154
10156
  }
10155
10157
  }
10156
- await ie("postOperation", h, w, ["read", i, e, C]), await ie("postRead", h, w, [C, D, i, !1]), t?.user && await Yo(i, O, d, t.user, f);
10158
+ await ie("postOperation", h, x, ["read", i, e, C]), await ie("postRead", h, x, [C, N, i, !1]), t?.user && await Yo(i, O, d, t.user, f);
10157
10159
  };
10158
10160
  return t?.providedTransaction ? await a(t.providedTransaction) : await r.runTransaction(async (o) => {
10159
10161
  await a(o);
@@ -10228,19 +10230,19 @@ ${i}`);
10228
10230
  n = m;
10229
10231
  else
10230
10232
  throw new Error("Admin email not set");
10231
- const d = ds(n), f = $c(e), h = t ? Yr(t) : void 0, v = s ? Yr(s) : void 0, p = r ? ds(r) : void 0, E = i ? ds(i) : void 0, O = a ? Un(a) : void 0, N = l ? Un(l) : void 0, w = Array.isArray(d) ? d : [d];
10232
- if (w.length === 0 || w.length === 1 && !w[0])
10233
+ const d = ds(n), f = $c(e), h = t ? Yr(t) : void 0, v = s ? Yr(s) : void 0, p = r ? ds(r) : void 0, E = i ? ds(i) : void 0, O = a ? Un(a) : void 0, R = l ? Un(l) : void 0, x = Array.isArray(d) ? d : [d];
10234
+ if (x.length === 0 || x.length === 1 && !x[0])
10233
10235
  throw new Error("No valid email addresses provided");
10234
- const T = { to: d, message: { subject: f } };
10235
- if (h && (T.message.text = h), v && (T.message.html = v), p) {
10236
- const D = Array.isArray(p) ? p : [p];
10237
- D.length > 0 && D[0] && (T.cc = p);
10236
+ const _ = { to: d, message: { subject: f } };
10237
+ if (h && (_.message.text = h), v && (_.message.html = v), p) {
10238
+ const N = Array.isArray(p) ? p : [p];
10239
+ N.length > 0 && N[0] && (_.cc = p);
10238
10240
  }
10239
10241
  if (E) {
10240
- const D = Array.isArray(E) ? E : [E];
10241
- D.length > 0 && D[0] && (T.bcc = E);
10242
+ const N = Array.isArray(E) ? E : [E];
10243
+ N.length > 0 && N[0] && (_.bcc = E);
10242
10244
  }
10243
- O && (T.replyTo = O), o && (T.message.attachments = o), N && (T.from = N), await c.collection("system_mail").add(T);
10245
+ O && (_.replyTo = O), o && (_.message.attachments = o), R && (_.from = R), await c.collection("system_mail").add(_);
10244
10246
  }, Ao = async (n, e, t, s, r, i, a) => {
10245
10247
  const o = gt(), l = ce(), c = "USER_ERROR", u = async (f, h) => {
10246
10248
  try {
@@ -10345,7 +10347,7 @@ ${i}`);
10345
10347
  return t.includeFields.forEach((r) => {
10346
10348
  if (e[r] !== void 0) {
10347
10349
  s[r] = e[r];
10348
- const i = U(n.fields, r);
10350
+ const i = W(n.fields, r);
10349
10351
  wt(n, [i]).size === 1 && (s[`${r}_Lowercase`] = e[`${r}_Lowercase`]);
10350
10352
  }
10351
10353
  }), s;
@@ -10366,7 +10368,7 @@ ${i}`);
10366
10368
  const f = await r.get(d.doc(u));
10367
10369
  if (!f.exists)
10368
10370
  throw new Error(`VALIDATION_ERROR: Record ${u} not found in collection ${t.collection}`);
10369
- const h = f.data(), v = U(o, t.enforceHierarchy.field), p = t.enforceHierarchy;
10371
+ const h = f.data(), v = W(o, t.enforceHierarchy.field), p = t.enforceHierarchy;
10370
10372
  if (!h[p.recordLinkField] || !s[v.name] || !Object.keys(s[v.name]).every((E) => Object.keys(h[p.recordLinkField]).includes(E)))
10371
10373
  throw new Error("VALIDATION_ERROR: Invalid relation hierarchy");
10372
10374
  }, gn = async (n, e, t) => {
@@ -10384,19 +10386,19 @@ ${i}`);
10384
10386
  K(E) && ["OneToOne", "OneToMany"].includes(E.type) && E.enforceHierarchy && s[E.name] && (n === "Create" || n === "Update" && !qe(m?.[E.name], s[E.name])) && await Qr(e, i, E, s, o, l);
10385
10387
  for (const E of d)
10386
10388
  if (K(E) && E.twoWay) {
10387
- const O = a.collections[E.collection], N = U(O.fields, E.twoWay), w = ft(O, [N]);
10389
+ const O = a.collections[E.collection], R = W(O.fields, E.twoWay), x = ft(O, [R]);
10388
10390
  if (s[E.name]) {
10389
- const T = Object.entries(s[E.name]);
10390
- for (const D of T) {
10391
- const [C, W] = D;
10391
+ const _ = Object.entries(s[E.name]);
10392
+ for (const N of _) {
10393
+ const [C, L] = N;
10392
10394
  if (n === "Create" || !m?.[E.name]?.[C]) {
10393
- let x;
10395
+ let I;
10394
10396
  const y = p.get(E.collection)?.[C];
10395
10397
  if (y)
10396
- x = y;
10398
+ I = y;
10397
10399
  else {
10398
10400
  l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
10399
- const _ = Ae(f, W.Collection_Path, e), B = await o.get(_.doc(C));
10401
+ const w = Ae(f, L.Collection_Path, e), B = await o.get(w.doc(C));
10400
10402
  if (!B.exists) {
10401
10403
  gn(E, r, C);
10402
10404
  continue;
@@ -10405,73 +10407,73 @@ ${i}`);
10405
10407
  v.set(E.collection, {
10406
10408
  ...v.get(E.collection) || {},
10407
10409
  [C]: g
10408
- }), x = ye({ ...g, ...Sn(s) });
10410
+ }), I = ye({ ...g, ...Sn(s) });
10409
10411
  }
10410
10412
  const k = {
10411
- ...x[N.name],
10413
+ ...I[R.name],
10412
10414
  [t]: {
10413
10415
  Collection_Path: s.Collection_Path,
10414
- ...Pc(i, s, N)
10416
+ ...Pc(i, s, R)
10415
10417
  }
10416
10418
  };
10417
- x[N.name] = k, x[`${N.name}_Array`] ||= [], x[`${N.name}_Array`].push(t), w.size === 1 && (x[`${N.name}_Single`] = k), p.set(E.collection, {
10419
+ I[R.name] = k, I[`${R.name}_Array`] ||= [], I[`${R.name}_Array`].push(t), x.size === 1 && (I[`${R.name}_Single`] = k), p.set(E.collection, {
10418
10420
  ...p.get(E.collection) || {},
10419
- [C]: x
10421
+ [C]: I
10420
10422
  });
10421
10423
  }
10422
10424
  }
10423
10425
  }
10424
10426
  if (n === "Update") {
10425
- const T = Object.entries(m?.[E.name] || {});
10426
- for (const D of T) {
10427
- const [C, W] = D;
10427
+ const _ = Object.entries(m?.[E.name] || {});
10428
+ for (const N of _) {
10429
+ const [C, L] = N;
10428
10430
  if (!s[E.name]?.[C]) {
10429
- let x;
10431
+ let I;
10430
10432
  const y = p.get(E.collection)?.[C];
10431
10433
  if (y)
10432
- x = y;
10434
+ I = y;
10433
10435
  else {
10434
10436
  l.size++, l && l.size > 500 && console.error(new Error(`VALIDATION_ERROR: ${l.size} operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of two way updates, unique field checks, entity restrictions (in permissions when dealing with user collections) or relation hierarchy checks.`));
10435
- const k = Ae(f, W.Collection_Path, e), _ = await o.get(k.doc(C));
10436
- if (!_.exists) {
10437
+ const k = Ae(f, L.Collection_Path, e), w = await o.get(k.doc(C));
10438
+ if (!w.exists) {
10437
10439
  h.set(E.name, [...h.get(E.name) || [], C]);
10438
10440
  continue;
10439
10441
  }
10440
- const B = _.data();
10442
+ const B = w.data();
10441
10443
  v.set(E.collection, {
10442
10444
  ...v.get(E.collection) || {},
10443
10445
  [C]: B
10444
- }), x = ye({ ...B, ...Sn(s) });
10446
+ }), I = ye({ ...B, ...Sn(s) });
10445
10447
  }
10446
- x[N.name][t] && delete x[N.name][t], Array.isArray(x[`${N.name}_Array`]) && (x[`${N.name}_Array`] = x[`${N.name}_Array`].filter((k) => k !== t)), w.size === 1 && delete x[`${N.name}_Single`], p.set(E.collection, {
10448
+ I[R.name][t] && delete I[R.name][t], Array.isArray(I[`${R.name}_Array`]) && (I[`${R.name}_Array`] = I[`${R.name}_Array`].filter((k) => k !== t)), x.size === 1 && delete I[`${R.name}_Single`], p.set(E.collection, {
10447
10449
  ...p.get(E.collection) || {},
10448
- [C]: x
10450
+ [C]: I
10449
10451
  });
10450
10452
  }
10451
10453
  }
10452
10454
  }
10453
10455
  }
10454
10456
  for (const [E, O] of p.entries()) {
10455
- const N = a.collections[E], w = Qe(E, a);
10456
- for (const [T, D] of Object.entries(O)) {
10457
- const { addedFields: C, removedFields: W } = Lc(n, T, E, i, s, m);
10457
+ const R = a.collections[E], x = Qe(E, a);
10458
+ for (const [_, N] of Object.entries(O)) {
10459
+ const { addedFields: C, removedFields: L } = Lc(n, _, E, i, s, m);
10458
10460
  if (c && u) {
10459
- for (const x of C) {
10460
- const y = U(N.fields, x.twoWay);
10461
- if (!tr(N, y, u)) {
10462
- gn(x, r, T);
10461
+ for (const I of C) {
10462
+ const y = W(R.fields, I.twoWay);
10463
+ if (!tr(R, y, u)) {
10464
+ gn(I, r, _);
10463
10465
  continue;
10464
10466
  }
10465
10467
  }
10466
- for (const x of W) {
10467
- const y = U(N.fields, x.twoWay), k = ft(N, [y]);
10468
- if (!tr(N, y, u)) {
10468
+ for (const I of L) {
10469
+ const y = W(R.fields, I.twoWay), k = ft(R, [y]);
10470
+ if (!tr(R, y, u)) {
10469
10471
  ms(
10470
- x,
10472
+ I,
10471
10473
  r,
10472
10474
  // eslint-disable-next-line security/detect-object-injection
10473
- m?.[x.name]?.[T],
10474
- T,
10475
+ m?.[I.name]?.[_],
10476
+ _,
10475
10477
  k.size === 1
10476
10478
  );
10477
10479
  continue;
@@ -10479,51 +10481,51 @@ ${i}`);
10479
10481
  }
10480
10482
  if (!it(
10481
10483
  "Update",
10482
- N,
10484
+ R,
10483
10485
  a,
10484
10486
  c,
10485
10487
  u,
10486
10488
  // eslint-disable-next-line security/detect-object-injection
10487
- v.get(E)?.[T]
10489
+ v.get(E)?.[_]
10488
10490
  )) {
10489
- for (const x of C)
10490
- gn(x, r, T);
10491
- for (const x of W) {
10492
- const y = U(N.fields, x.twoWay), k = ft(N, [y]);
10491
+ for (const I of C)
10492
+ gn(I, r, _);
10493
+ for (const I of L) {
10494
+ const y = W(R.fields, I.twoWay), k = ft(R, [y]);
10493
10495
  ms(
10494
- x,
10496
+ I,
10495
10497
  r,
10496
10498
  // eslint-disable-next-line security/detect-object-injection
10497
- m?.[x.name]?.[T],
10498
- T,
10499
+ m?.[I.name]?.[_],
10500
+ _,
10499
10501
  k.size === 1
10500
10502
  );
10501
10503
  }
10502
10504
  }
10503
- if (!it("Update", N, a, c, u, D)) {
10504
- for (const x of C)
10505
- gn(x, r, T);
10506
- for (const x of W) {
10507
- const y = U(N.fields, x.twoWay), k = ft(N, [y]);
10505
+ if (!it("Update", R, a, c, u, N)) {
10506
+ for (const I of C)
10507
+ gn(I, r, _);
10508
+ for (const I of L) {
10509
+ const y = W(R.fields, I.twoWay), k = ft(R, [y]);
10508
10510
  ms(
10509
- x,
10511
+ I,
10510
10512
  r,
10511
10513
  // eslint-disable-next-line security/detect-object-injection
10512
- m?.[x.name]?.[T],
10513
- T,
10514
+ m?.[I.name]?.[_],
10515
+ _,
10514
10516
  k.size === 1
10515
10517
  );
10516
10518
  }
10517
10519
  }
10518
10520
  }
10519
10521
  try {
10520
- await nn("update", D, N, w, ["update", D, {}, void 0, D], a);
10521
- } catch (x) {
10522
- throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${T} in ${E}: ${x.message}`);
10522
+ await nn("update", N, R, x, ["update", N, {}, void 0, N], a);
10523
+ } catch (I) {
10524
+ throw new Error(`VALIDATION_ERROR: Two way relation update would invalidate record ${_} in ${E}: ${I.message}`);
10523
10525
  }
10524
- for (const x of C) {
10525
- const y = U(N.fields, x.twoWay);
10526
- ["OneToOne", "OneToMany"].includes(y.type) && K(y) && y.enforceHierarchy && await Qr(e, N, y, D, o, l, !0);
10526
+ for (const I of C) {
10527
+ const y = W(R.fields, I.twoWay);
10528
+ ["OneToOne", "OneToMany"].includes(y.type) && K(y) && y.enforceHierarchy && await Qr(e, R, y, N, o, l, !0);
10527
10529
  }
10528
10530
  }
10529
10531
  }
@@ -10595,27 +10597,27 @@ ${i}`);
10595
10597
  }
10596
10598
  }
10597
10599
  if (l.parentEntities) {
10598
- const h = c.entityRestrictions?.restrictions?.find((w) => w.type === "Parent" && w.roles.some((T) => T.role === e.Role));
10600
+ const h = c.entityRestrictions?.restrictions?.find((x) => x.type === "Parent" && x.roles.some((_) => _.role === e.Role));
10599
10601
  if (!h)
10600
10602
  throw new Error("PERMISSION_DENIED");
10601
- const v = U(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentEntities, O = d?.parentEntities || [], N = i ? E.filter((w) => !O.includes(w)) : E;
10602
- for (const w of N) {
10603
+ const v = W(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentEntities, O = d?.parentEntities || [], R = i ? E.filter((x) => !O.includes(x)) : E;
10604
+ for (const x of R) {
10603
10605
  if (a && a.size++, a && a.size > 500)
10604
10606
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks or entity restrictions (in permissions when dealing with user collections).");
10605
10607
  f.push(async () => {
10606
- if (!await ps(n, p, w, t, s))
10608
+ if (!await ps(n, p, x, t, s))
10607
10609
  throw new Error("PERMISSION_DENIED");
10608
10610
  });
10609
10611
  }
10610
10612
  }
10611
10613
  if (l.parentPropertyEntities) {
10612
- const h = c.entityRestrictions?.restrictions?.find((N) => N.type === "Parent_Property" && N.roles.some((w) => w.role === e.Role));
10614
+ const h = c.entityRestrictions?.restrictions?.find((R) => R.type === "Parent_Property" && R.roles.some((x) => x.role === e.Role));
10613
10615
  if (!h)
10614
10616
  throw new Error("PERMISSION_DENIED");
10615
- const v = U(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentPropertyEntities, O = d?.parentPropertyEntities || {};
10616
- for (const [N, w] of Object.entries(E)) {
10617
- const T = O[N] || [], D = i ? w.filter((C) => !T.includes(C)) : w;
10618
- for (const C of D) {
10617
+ const v = W(u.fields, h.collectionField), p = r.collections[v.collection], E = l.parentPropertyEntities, O = d?.parentPropertyEntities || {};
10618
+ for (const [R, x] of Object.entries(E)) {
10619
+ const _ = O[R] || [], N = i ? x.filter((C) => !_.includes(C)) : x;
10620
+ for (const C of N) {
10619
10621
  if (a && a.size++, a && a.size > 500)
10620
10622
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks or entity restrictions (in permissions when dealing with user collections).");
10621
10623
  f.push(async () => {
@@ -10640,48 +10642,48 @@ ${i}`);
10640
10642
  const u = n.at(-1), m = Object.keys(c.collections).includes(u), d = l.disabledCollections?.includes(u);
10641
10643
  if (!m || d)
10642
10644
  throw new Error("COLLECTION_NOT_FOUND");
10643
- const f = c.collections[u], { labels: h, fields: v, enableWriteLog: p, softDelete: E } = f, O = Qe(h.collection, c), N = await re(l.appName), w = ce(), T = gt(), C = (s ? await T.getUser(s) : void 0)?.customClaims?.role;
10644
- let W;
10645
+ const f = c.collections[u], { labels: h, fields: v, enableWriteLog: p, softDelete: E } = f, O = Qe(h.collection, c), R = await re(l.appName), x = ce(), _ = gt(), C = (s ? await _.getUser(s) : void 0)?.customClaims?.role;
10646
+ let L;
10645
10647
  s && await Ks(n, f);
10646
- const x = Ae(w, n, o), y = a || x.doc().id;
10648
+ const I = Ae(x, n, o), y = a || I.doc().id;
10647
10649
  i = i || {}, i.collection = h.collection, e.id = y, Co(e), Xs(e);
10648
- const k = Vs("create", n, e, c, N, "Online", s || "System", lt.now(), me.serverTimestamp());
10650
+ const k = Vs("create", n, e, c, R, "Online", s || "System", lt.now(), me.serverTimestamp());
10649
10651
  r?.createdAt && (k.Created_At = r.createdAt), r?.createdBy && (k.Created_By = r.createdBy);
10650
- const _ = ye(k);
10652
+ const w = ye(k);
10651
10653
  E && (k[E.archivedField] = !1), Ue(e), p && !r?.providedTransaction && await Ft("create", "started", k, o, n, y, f), await ie("preOperation", l, O, ["create", k, y, i]), await ie("preWrite", l, O, ["create", k, y, i]), Tn(f, k, c), Rn(f, k), await sa(k, f, O, C), Ue(k);
10652
10654
  try {
10653
10655
  if (f.auth && t && !t.password)
10654
10656
  throw new Error("Password is required");
10655
10657
  r?.providedTransaction || (await Io("create", o, y, k, f, c), await nn("create", k, f, O, ["create", k, i], c));
10656
- } catch (I) {
10657
- throw new Error(`VALIDATION_ERROR: ${I.message}`);
10658
+ } catch (D) {
10659
+ throw new Error(`VALIDATION_ERROR: ${D.message}`);
10658
10660
  }
10659
10661
  Ue(k), e.id = y, E && (k[E.archivedField] = !1), Tn(f, k, c), Rn(f, k);
10660
10662
  try {
10661
- Mo("create", k, _), Fo("create", f, k), await nn("create", k, f, O, ["create", k, i], c);
10662
- } catch (I) {
10663
- throw new Error(`VALIDATION_ERROR: ${I.message}`);
10663
+ Mo("create", k, w), Fo("create", f, k), await nn("create", k, f, O, ["create", k, i], c);
10664
+ } catch (D) {
10665
+ throw new Error(`VALIDATION_ERROR: ${D.message}`);
10664
10666
  }
10665
10667
  if (s) {
10666
- const I = C;
10667
- if (!I)
10668
+ const D = C;
10669
+ if (!D)
10668
10670
  throw new Error("USER_ERROR");
10669
- if (!(O.custom?.serverAccess?.create !== void 0 ? await re(O.custom.serverAccess.create, [I, k]) : !0))
10671
+ if (!(O.custom?.serverAccess?.create !== void 0 ? await re(O.custom.serverAccess.create, [D, k]) : !0))
10670
10672
  throw new Error("PERMISSION_DENIED");
10671
10673
  for (const q of f.fields) {
10672
10674
  if (!(q.name in k))
10673
10675
  continue;
10674
10676
  const b = De(q, O);
10675
- if (b?.custom?.serverAccess?.create !== void 0 && !await re(b.custom.serverAccess.create, [I, k]))
10677
+ if (b?.custom?.serverAccess?.create !== void 0 && !await re(b.custom.serverAccess.create, [D, k]))
10676
10678
  throw new Error("PERMISSION_DENIED");
10677
10679
  }
10678
10680
  }
10679
10681
  t && (t.permissions ||= {}, t.permissions.Role ||= k.Role, t.permissions.Enabled ||= k.Enabled);
10680
- const R = async (I, j) => {
10682
+ const T = async (D, j) => {
10681
10683
  const [q, b, F, z] = await Promise.all([
10682
- r?.providedTransaction ? Promise.resolve({}) : I.get(w.collection("system_deployment").doc("latest_deploy")),
10683
- r?.providedTransaction ? Promise.resolve({}) : I.get(w.collection("system_deployment").doc("maintenance_mode")),
10684
- s ? I.get(w.collection("tenants").doc(o).collection("system_user_permissions").doc(s)) : Promise.resolve({}),
10684
+ r?.providedTransaction ? Promise.resolve({}) : D.get(x.collection("system_deployment").doc("latest_deploy")),
10685
+ r?.providedTransaction ? Promise.resolve({}) : D.get(x.collection("system_deployment").doc("maintenance_mode")),
10686
+ s ? D.get(x.collection("tenants").doc(o).collection("system_user_permissions").doc(s)) : Promise.resolve({}),
10685
10687
  r?.providedSchema ? Promise.resolve(r.providedSchema) : Ye()
10686
10688
  ]);
10687
10689
  if (j && (j.size += 3), !r?.providedTransaction) {
@@ -10698,19 +10700,19 @@ ${i}`);
10698
10700
  if (c = z, s) {
10699
10701
  if (!F?.exists)
10700
10702
  throw new Error("PERMISSION_DENIED");
10701
- if (W = F.data(), !W.Role)
10703
+ if (L = F.data(), !L.Role)
10702
10704
  throw new Error("USER_ERROR");
10703
- if (!W.Enabled)
10705
+ if (!L.Enabled)
10704
10706
  throw new Error("PERMISSION_DENIED");
10705
10707
  }
10706
10708
  if (!r?.providedTransaction) {
10707
10709
  const oe = v.filter((ue) => "unique" in ue && ue.unique).map(async (ue) => {
10708
- if (!s || !ue.access || ue.access.includes(W.Role)) {
10710
+ if (!s || !ue.access || ue.access.includes(L.Role)) {
10709
10711
  if (!e[ue.name])
10710
10712
  return;
10711
10713
  const he = De(ue, O);
10712
10714
  if (!(s && he?.custom?.serverAccess?.read !== void 0 ? await re(he.custom.serverAccess.read, [
10713
- W?.Role,
10715
+ L?.Role,
10714
10716
  k
10715
10717
  ]) : !0))
10716
10718
  throw new Error("PERMISSION_DENIED");
@@ -10718,7 +10720,7 @@ ${i}`);
10718
10720
  if (Js(pe)) {
10719
10721
  if (j && j.size++, j && j.size > 500)
10720
10722
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks.");
10721
- if ((await I.get(w.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${ue.name}`).doc(pe)))?.exists)
10723
+ if ((await D.get(x.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${ue.name}`).doc(pe)))?.exists)
10722
10724
  throw new Error(`VALIDATION_ERROR: ${ue.name} "${k[ue.name]}" already exists`);
10723
10725
  } else
10724
10726
  throw new Error(`VALIDATION_ERROR: ${ue.name} "${k[ue.name]}" is invalid`);
@@ -10726,13 +10728,13 @@ ${i}`);
10726
10728
  });
10727
10729
  await Promise.all(oe);
10728
10730
  }
10729
- nr(k, y, f, c, s, W, t?.permissions), t?.permissions && s && W && await Po(I, t.permissions, s, W, c), nr(k, y, f, c, s, W, t?.permissions);
10731
+ nr(k, y, f, c, s, L, t?.permissions), t?.permissions && s && L && await Po(D, t.permissions, s, L, c), nr(k, y, f, c, s, L, t?.permissions);
10730
10732
  };
10731
10733
  if (f.auth && t) {
10732
- await w.runTransaction(async (j) => {
10733
- await R(j);
10734
+ await x.runTransaction(async (j) => {
10735
+ await T(j);
10734
10736
  }, { maxAttempts: 10 });
10735
- const I = await Ao(
10737
+ const D = await Ao(
10736
10738
  o,
10737
10739
  y,
10738
10740
  l,
@@ -10742,14 +10744,14 @@ ${i}`);
10742
10744
  t.permissions,
10743
10745
  t.password
10744
10746
  );
10745
- k.User_ID = I;
10747
+ k.User_ID = D;
10746
10748
  }
10747
- const S = async (I) => {
10749
+ const S = async (D) => {
10748
10750
  try {
10749
10751
  const j = { size: 1 };
10750
- await R(I, j), r?.noTwoWay || await $o("Create", o, y, k, k, f, c, I, j, s, W);
10752
+ await T(D, j), r?.noTwoWay || await $o("Create", o, y, k, k, f, c, D, j, s, L);
10751
10753
  const q = Ls(c);
10752
- Ys("create", I, n, y, k, c, f, r, q, me.arrayUnion, me.arrayRemove, me.delete, (b) => w.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b.name}`).doc(y), (b, F) => w.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${b.name}`).doc(F), (b) => w.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b}`).doc(y), (b, F) => Ae(w, b, o).doc(F), (b, F, z) => w.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F}`).doc(z), (b, F, z) => w.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F.replaceAll(" ", "-")}`).doc(z), void 0, void 0, j), I.set(x.doc(y), k);
10754
+ Ys("create", D, n, y, k, c, f, r, q, me.arrayUnion, me.arrayRemove, me.delete, (b) => x.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b.name}`).doc(y), (b, F) => x.collection("tenants").doc(o).collection("system_unique").doc(h.collection).collection(`Unique-${h.collection}-${b.name}`).doc(F), (b) => x.collection("tenants").doc(o).collection("system_fields").doc(h.collection).collection(`${h.collection}-${b}`).doc(y), (b, F) => Ae(x, b, o).doc(F), (b, F, z) => x.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F}`).doc(z), (b, F, z) => x.collection("tenants").doc(o).collection("system_fields").doc(b.collection).collection(`${b.collection}-${F.replaceAll(" ", "-")}`).doc(z), void 0, void 0, j), D.set(I.doc(y), k);
10753
10755
  } catch (j) {
10754
10756
  if (r?.providedTransaction)
10755
10757
  throw j;
@@ -10762,11 +10764,11 @@ ${i}`);
10762
10764
  }
10763
10765
  }
10764
10766
  };
10765
- if (r?.providedTransaction ? await S(r.providedTransaction) : await w.runTransaction(async (I) => {
10766
- await S(I);
10767
+ if (r?.providedTransaction ? await S(r.providedTransaction) : await x.runTransaction(async (D) => {
10768
+ await S(D);
10767
10769
  }, { maxAttempts: 10 }), !r?.providedTransaction) {
10768
- const I = ["create", k, y, i], j = [...I];
10769
- await ie("postWrite", l, O, I), await ie("postOperation", l, O, j);
10770
+ const D = ["create", k, y, i], j = [...D];
10771
+ await ie("postWrite", l, O, D), await ie("postOperation", l, O, j);
10770
10772
  }
10771
10773
  return { id: y, ...k };
10772
10774
  }, Jt = async (n, e, t, s) => {
@@ -10853,16 +10855,16 @@ ${i}`);
10853
10855
  throw new Error("Error generating email verification link");
10854
10856
  });
10855
10857
  if (O.includes("apiKey=&")) {
10856
- const N = JSON.parse(process.env.STOKER_FB_WEB_APP_CONFIG);
10857
- O = O.replace("apiKey=&", `apiKey=${N.apiKey}&`);
10858
+ const R = JSON.parse(process.env.STOKER_FB_WEB_APP_CONFIG);
10859
+ O = O.replace("apiKey=&", `apiKey=${R.apiKey}&`);
10858
10860
  }
10859
10861
  if (O) {
10860
- const N = `https://${m.app.options.projectId}.firebaseapp.com/__/auth/action${O}`, w = await re(s.appName), T = s?.mail?.emailVerification && s.mail.emailVerification(N, w);
10862
+ const R = `https://${m.app.options.projectId}.firebaseapp.com/__/auth/action${O}`, x = await re(s.appName), _ = s?.mail?.emailVerification && s.mail.emailVerification(R, x);
10861
10863
  try {
10862
- await Do(i.Email, T?.subject || "Please verify your email address", void 0, T?.html || `Please verify your email address by clicking the link:
10864
+ await Do(i.Email, _?.subject || "Please verify your email address", void 0, _?.html || `Please verify your email address by clicking the link:
10863
10865
  </br>
10864
10866
  </br>
10865
- <a href="${N}">${N}</a>`);
10867
+ <a href="${R}">${R}</a>`);
10866
10868
  } catch {
10867
10869
  throw await Jt(a.User_ID, o, c, h), new Error(h);
10868
10870
  }
@@ -10912,10 +10914,10 @@ ${i}`);
10912
10914
  const m = n.at(-1), d = Object.keys(u.collections).includes(m), f = c.disabledCollections?.includes(m);
10913
10915
  if (!d || f)
10914
10916
  throw new Error("COLLECTION_NOT_FOUND");
10915
- const h = u.collections[m], { labels: v, fields: p, enableWriteLog: E } = h, O = Qe(v.collection, u), N = await re(c.appName), w = gt(), T = ce();
10916
- let D;
10917
+ const h = u.collections[m], { labels: v, fields: p, enableWriteLog: E } = h, O = Qe(v.collection, u), R = await re(c.appName), x = gt(), _ = ce();
10918
+ let N;
10917
10919
  r && await Ks(n, h);
10918
- const C = Ae(T, n, l);
10920
+ const C = Ae(_, n, l);
10919
10921
  a = a || {}, a.collection = v.collection, o = o || await at(n, e, {
10920
10922
  user: r,
10921
10923
  noComputedFields: !0,
@@ -10938,39 +10940,39 @@ ${i}`);
10938
10940
  throw new Error("VALIDATION_ERROR: User operations are only permitted for auth collections");
10939
10941
  if (s?.operation === "delete" && s.permissions)
10940
10942
  throw new Error("VALIDATION_ERROR: Permissions are not allowed for delete operations");
10941
- const W = h.auth && s?.operation === "create", x = h.auth && s?.operation === "delete", y = h.auth && !W && !x && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), k = (b) => b.User_ID && (h.auth && !W && !x && s?.operation === "update" || t.Role && t.Role !== b.Role || t.Enabled !== void 0 && t.Enabled !== b.Enabled || t.Name && t.Name !== b.Name || t.Email && t.Email !== b.Email || t.Photo_URL && t.Photo_URL !== b.Photo_URL);
10943
+ const L = h.auth && s?.operation === "create", I = h.auth && s?.operation === "delete", y = h.auth && !L && !I && (s?.operation === "update" || t.Role || t.Enabled !== void 0 || t.Name || t.Email || t.Photo_URL), k = (b) => b.User_ID && (h.auth && !L && !I && s?.operation === "update" || t.Role && t.Role !== b.Role || t.Enabled !== void 0 && t.Enabled !== b.Enabled || t.Name && t.Name !== b.Name || t.Email && t.Email !== b.Email || t.Photo_URL && t.Photo_URL !== b.Photo_URL);
10942
10944
  delete t.id, Co(t), Xs(t);
10943
- const _ = Vs("update", n, t, u, N, "Online", r || "System", lt.now(), me.serverTimestamp()), B = ye(_);
10945
+ const w = Vs("update", n, t, u, R, "Online", r || "System", lt.now(), me.serverTimestamp()), B = ye(w);
10944
10946
  for (const b of p)
10945
- !K(b) && Fe(_[b.name]) && b.nullable && (_[b.name] = null);
10946
- Ue(_), Ue(o), E && !i?.providedTransaction && await Ft("update", "started", _, l, n, e, h, void 0, o);
10947
+ !K(b) && Fe(w[b.name]) && b.nullable && (w[b.name] = null);
10948
+ Ue(w), Ue(o), E && !i?.providedTransaction && await Ft("update", "started", w, l, n, e, h, void 0, o);
10947
10949
  const g = [
10948
10950
  "update",
10949
- _,
10951
+ w,
10950
10952
  e,
10951
10953
  a,
10952
10954
  void 0,
10953
10955
  ye(o)
10954
10956
  ];
10955
10957
  await ie("preOperation", c, O, g);
10956
- const R = ["update", _, e, a, void 0, ye(o)];
10957
- await ie("preWrite", c, O, R), Tn(h, _, u), Rn(h, _), Ue(_);
10958
+ const T = ["update", w, e, a, void 0, ye(o)];
10959
+ await ie("preWrite", c, O, T), Tn(h, w, u), Rn(h, w), Ue(w);
10958
10960
  try {
10959
- if (W && !s.password)
10961
+ if (L && !s.password)
10960
10962
  throw new Error("Password is required");
10961
10963
  if (!i?.providedTransaction) {
10962
- const b = { ...o, ..._ };
10963
- await Io("update", l, e, b, h, u), nt(b), await nn("update", b, h, O, ["update", _, a, void 0, ye(o)], u);
10964
+ const b = { ...o, ...w };
10965
+ await Io("update", l, e, b, h, u), nt(b), await nn("update", b, h, O, ["update", w, a, void 0, ye(o)], u);
10964
10966
  }
10965
10967
  } catch (b) {
10966
10968
  throw new Error(`VALIDATION_ERROR: ${b.message}`);
10967
10969
  }
10968
- Ue(_), delete t.id, Tn(h, _, u), Rn(h, _);
10970
+ Ue(w), delete t.id, Tn(h, w, u), Rn(h, w);
10969
10971
  for (const b of p)
10970
- !K(b) && Fe(_[b.name]) && b.nullable && (_[b.name] = null);
10972
+ !K(b) && Fe(w[b.name]) && b.nullable && (w[b.name] = null);
10971
10973
  try {
10972
- const b = { ...o, ..._ };
10973
- nt(b), Fo("update", h, _, o), Mo("update", _, B), await nn("update", b, h, O, ["update", _, a, void 0, o], u);
10974
+ const b = { ...o, ...w };
10975
+ nt(b), Fo("update", h, w, o), Mo("update", w, B), await nn("update", b, h, O, ["update", w, a, void 0, o], u);
10974
10976
  } catch (b) {
10975
10977
  throw new Error(`VALIDATION_ERROR: ${b.message}`);
10976
10978
  }
@@ -10978,21 +10980,21 @@ ${i}`);
10978
10980
  s && (s.permissions ||= {});
10979
10981
  const $ = async (b, F, z) => {
10980
10982
  const [Q, oe, ue, he, Ve] = await Promise.all([
10981
- i?.providedTransaction ? Promise.resolve({}) : b.get(T.collection("system_deployment").doc("latest_deploy")),
10982
- i?.providedTransaction ? Promise.resolve({}) : b.get(T.collection("system_deployment").doc("maintenance_mode")),
10983
+ i?.providedTransaction ? Promise.resolve({}) : b.get(_.collection("system_deployment").doc("latest_deploy")),
10984
+ i?.providedTransaction ? Promise.resolve({}) : b.get(_.collection("system_deployment").doc("maintenance_mode")),
10983
10985
  i?.providedTransaction ? Promise.resolve(o) : at(n, e, {
10984
10986
  user: r,
10985
10987
  providedTransaction: b,
10986
10988
  noComputedFields: !0
10987
10989
  }),
10988
- r ? b.get(T.collection("tenants").doc(l).collection("system_user_permissions").doc(r)) : Promise.resolve({}),
10990
+ r ? b.get(_.collection("tenants").doc(l).collection("system_user_permissions").doc(r)) : Promise.resolve({}),
10989
10991
  i?.providedSchema ? Promise.resolve(i.providedSchema) : Ye()
10990
10992
  ]);
10991
10993
  if (z && (z.size += 3), !i?.providedTransaction) {
10992
10994
  if (!Q.exists)
10993
10995
  throw new Error("VERSION_ERROR");
10994
10996
  const pe = Q.data();
10995
- if (pe.force && _.Last_Write_At.valueOf() < pe.time.valueOf())
10997
+ if (pe.force && w.Last_Write_At.valueOf() < pe.time.valueOf())
10996
10998
  throw new Error("VERSION_ERROR");
10997
10999
  if (!oe.exists)
10998
11000
  throw new Error("MAINTENANCE_MODE");
@@ -11004,19 +11006,19 @@ ${i}`);
11004
11006
  if (o = ue, u = Ve, r) {
11005
11007
  if (!he?.exists)
11006
11008
  throw new Error("PERMISSION_DENIED");
11007
- if (D = he.data(), !D.Role)
11009
+ if (N = he.data(), !N.Role)
11008
11010
  throw new Error("USER_ERROR");
11009
- if (!D.Enabled)
11011
+ if (!N.Enabled)
11010
11012
  throw new Error("PERMISSION_DENIED");
11011
11013
  }
11012
- if (z && (z.size += So(l, n, e, u, D).length), W && o.User_ID || x && !o.User_ID)
11014
+ if (z && (z.size += So(l, n, e, u, N).length), L && o.User_ID || I && !o.User_ID)
11013
11015
  throw new Error("USER_ERROR");
11014
11016
  if (k(o)) {
11015
- const pe = await b.get(T.collection("tenants").doc(l).collection("system_user_permissions").doc(o.User_ID));
11017
+ const pe = await b.get(_.collection("tenants").doc(l).collection("system_user_permissions").doc(o.User_ID));
11016
11018
  if (z && z.size++, !pe?.exists)
11017
11019
  throw new Error("PERMISSION_DENIED");
11018
11020
  if (S = pe.data(), s?.permissions) {
11019
- if (s.permissions.Role ||= _.Role || o.Role, s.permissions.Enabled ??= _.Enabled ?? o.Enabled, Fe(s.permissions.Role))
11021
+ if (s.permissions.Role ||= w.Role || o.Role, s.permissions.Enabled ??= w.Enabled ?? o.Enabled, Fe(s.permissions.Role))
11020
11022
  throw new Error("VALIDATION_ERROR: Role field is required");
11021
11023
  if (Fe(s.permissions.Enabled))
11022
11024
  throw new Error("VALIDATION_ERROR: Enabled field is required");
@@ -11024,35 +11026,35 @@ ${i}`);
11024
11026
  }
11025
11027
  if (!i?.providedTransaction) {
11026
11028
  const vt = p.filter((Ee) => "unique" in Ee && Ee.unique).map(async (Ee) => {
11027
- if (!r || !Ee.access || Ee.access.includes(D.Role)) {
11028
- if (_[Ee.name] === void 0 || Fe(_[Ee.name]))
11029
+ if (!r || !Ee.access || Ee.access.includes(N.Role)) {
11030
+ if (w[Ee.name] === void 0 || Fe(w[Ee.name]))
11029
11031
  return;
11030
- const jt = De(Ee, O), un = { ...o, ..._ };
11032
+ const jt = De(Ee, O), un = { ...o, ...w };
11031
11033
  if (!(r && jt?.custom?.serverAccess?.read !== void 0 ? await re(jt.custom.serverAccess.read, [
11032
- D?.Role,
11034
+ N?.Role,
11033
11035
  un
11034
11036
  ]) : !0))
11035
11037
  throw new Error("PERMISSION_DENIED");
11036
- const Jn = _[Ee.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
11038
+ const Jn = w[Ee.name].toString().toLowerCase().replace(/\s/g, "---").replaceAll("/", "|||");
11037
11039
  if (Js(Jn)) {
11038
11040
  if (z && z.size++, z && z.size > 500)
11039
11041
  throw new Error("VALIDATION_ERROR: The number of operations in the Firestore transaction has exceeded the limit of 500. This is likely due to a large number of unique field checks.");
11040
- const er = await b.get(T.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${Ee.name}`).doc(Jn));
11042
+ const er = await b.get(_.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${Ee.name}`).doc(Jn));
11041
11043
  if (er.exists && er.data().id !== e)
11042
- throw new Error(`VALIDATION_ERROR: ${Ee.name} "${_[Ee.name]}" already exists`);
11044
+ throw new Error(`VALIDATION_ERROR: ${Ee.name} "${w[Ee.name]}" already exists`);
11043
11045
  } else
11044
- throw new Error(`VALIDATION_ERROR: ${Ee.name} "${_[Ee.name]}" is invalid`);
11046
+ throw new Error(`VALIDATION_ERROR: ${Ee.name} "${w[Ee.name]}" is invalid`);
11045
11047
  }
11046
11048
  });
11047
11049
  await Promise.all(vt);
11048
11050
  }
11049
- if (r && D?.Role) {
11050
- const pe = D.Role, vt = { ...o, ..._ };
11051
+ if (r && N?.Role) {
11052
+ const pe = N.Role, vt = { ...o, ...w };
11051
11053
  if (!(O.custom?.serverAccess?.update !== void 0 ? await re(O.custom.serverAccess.update, [pe, vt, o]) : !0))
11052
11054
  throw new Error("PERMISSION_DENIED");
11053
11055
  for (const jt of h.fields) {
11054
11056
  const un = De(jt, O);
11055
- if (Object.prototype.hasOwnProperty.call(_, jt.name) && un?.custom?.serverAccess?.update !== void 0 && !await re(un.custom.serverAccess.update, [
11057
+ if (Object.prototype.hasOwnProperty.call(w, jt.name) && un?.custom?.serverAccess?.update !== void 0 && !await re(un.custom.serverAccess.update, [
11056
11058
  pe,
11057
11059
  vt,
11058
11060
  o
@@ -11060,28 +11062,28 @@ ${i}`);
11060
11062
  throw new Error("PERMISSION_DENIED");
11061
11063
  }
11062
11064
  }
11063
- sr(_, o, e, h, u, r, D, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), s?.permissions && r && D && await Po(b, s.permissions, r, D, u, S, z), sr(_, o, e, h, u, r, D, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), F && (W || k(o) || x) && await jc(b, e, o.User_ID);
11065
+ sr(w, o, e, h, u, r, N, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), s?.permissions && r && N && await Po(b, s.permissions, r, N, u, S, z), sr(w, o, e, h, u, r, N, s?.operation ? s.operation : y ? "update" : void 0, s?.permissions, S), F && (L || k(o) || I) && await jc(b, e, o.User_ID);
11064
11066
  };
11065
- (W || y || x) && await T.runTransaction(async (b) => {
11067
+ (L || y || I) && await _.runTransaction(async (b) => {
11066
11068
  await $(b, !0);
11067
11069
  }, { maxAttempts: 10 });
11068
- const I = async (b, F) => {
11070
+ const D = async (b, F) => {
11069
11071
  if (!o)
11070
11072
  throw new Error("NOT_FOUND");
11071
11073
  try {
11072
- const z = { size: 1 }, Q = { ...o, ..._ };
11074
+ const z = { size: 1 }, Q = { ...o, ...w };
11073
11075
  await $(b, !1, z);
11074
11076
  let oe;
11075
- !i?.noTwoWay && !i?.providedTransaction && (oe = await $o("Update", l, e, Q, _, h, u, b, z, r, D, o));
11077
+ !i?.noTwoWay && !i?.providedTransaction && (oe = await $o("Update", l, e, Q, w, h, u, b, z, r, N, o));
11076
11078
  const ue = Ls(u);
11077
- Ys("update", b, n, e, _, u, h, i, ue, me.arrayUnion, me.arrayRemove, me.delete, (he) => T.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he.name}`).doc(e), (he, Ve) => T.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${he.name}`).doc(Ve), (he) => T.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he}`).doc(e), (he, Ve) => Ae(T, he, l).doc(Ve), (he, Ve, pe) => T.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve}`).doc(pe), (he, Ve, pe) => T.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve.replaceAll(" ", "-")}`).doc(pe), o, oe, z), b.update(C.doc(e), _);
11079
+ Ys("update", b, n, e, w, u, h, i, ue, me.arrayUnion, me.arrayRemove, me.delete, (he) => _.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he.name}`).doc(e), (he, Ve) => _.collection("tenants").doc(l).collection("system_unique").doc(v.collection).collection(`Unique-${v.collection}-${he.name}`).doc(Ve), (he) => _.collection("tenants").doc(l).collection("system_fields").doc(v.collection).collection(`${v.collection}-${he}`).doc(e), (he, Ve) => Ae(_, he, l).doc(Ve), (he, Ve, pe) => _.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve}`).doc(pe), (he, Ve, pe) => _.collection("tenants").doc(l).collection("system_fields").doc(he.collection).collection(`${he.collection}-${Ve.replaceAll(" ", "-")}`).doc(pe), o, oe, z), b.update(C.doc(e), w);
11078
11080
  } catch (z) {
11079
11081
  if (i?.providedTransaction)
11080
11082
  throw z;
11081
11083
  {
11082
11084
  const Q = [
11083
11085
  "update",
11084
- _,
11086
+ w,
11085
11087
  e,
11086
11088
  a,
11087
11089
  z,
@@ -11091,40 +11093,40 @@ ${i}`);
11091
11093
  ], oe = await ie("postWriteError", c, O, Q);
11092
11094
  if (E && (await new Promise((ue) => {
11093
11095
  setTimeout(ue, 250);
11094
- }), await Ft("update", oe?.resolved ? "success" : "failed", _, l, n, e, h, oe?.resolved ? void 0 : z, o)), !oe?.resolved)
11095
- throw W && await cn(o), k(o) && await Jt(o.User_ID, F, S, "USER_ERROR"), x && await T.collection("tenants").doc(l).collection(v.collection).doc(e).update({ User_ID: me.delete() }), z;
11096
+ }), await Ft("update", oe?.resolved ? "success" : "failed", w, l, n, e, h, oe?.resolved ? void 0 : z, o)), !oe?.resolved)
11097
+ throw L && await cn(o), k(o) && await Jt(o.User_ID, F, S, "USER_ERROR"), I && await _.collection("tenants").doc(l).collection(v.collection).doc(e).update({ User_ID: me.delete() }), z;
11096
11098
  }
11097
11099
  }
11098
- (W || k(o) || x) && await Gr(Kr, [e, o.User_ID]).catch(() => {
11100
+ (L || k(o) || I) && await Gr(Kr, [e, o.User_ID]).catch(() => {
11099
11101
  throw new Error("USER_ERROR");
11100
11102
  });
11101
11103
  };
11102
11104
  try {
11103
11105
  let b;
11104
- if (W || k(o) || x) {
11106
+ if (L || k(o) || I) {
11105
11107
  if (k(o)) {
11106
- b = await w.getUser(o.User_ID);
11108
+ b = await x.getUser(o.User_ID);
11107
11109
  const Q = b.customClaims;
11108
11110
  if (!(Q && Q.role && Q.collection && Q.doc))
11109
11111
  throw new Error("USER_ERROR");
11110
11112
  }
11111
- const F = { ...o, ..._ };
11113
+ const F = { ...o, ...w };
11112
11114
  nt(F);
11113
11115
  const z = await Wc(s?.operation || "update", l, e, c, v.collection, F, o, b, s?.permissions, S, s?.password);
11114
- W && (_.User_ID = z), x && (_.User_ID = me.delete());
11116
+ L && (w.User_ID = z), I && (w.User_ID = me.delete());
11115
11117
  }
11116
- i?.providedTransaction ? await I(i.providedTransaction, b) : await T.runTransaction(async (F) => {
11117
- await I(F, b);
11118
+ i?.providedTransaction ? await D(i.providedTransaction, b) : await _.runTransaction(async (F) => {
11119
+ await D(F, b);
11118
11120
  }, { maxAttempts: 10 });
11119
11121
  } catch (b) {
11120
- throw (W || k(o) || x) && await Gr(Kr, [e, o.User_ID]).catch(() => {
11122
+ throw (L || k(o) || I) && await Gr(Kr, [e, o.User_ID]).catch(() => {
11121
11123
  throw new Error("USER_ERROR");
11122
11124
  }), b;
11123
11125
  }
11124
11126
  if (!i?.providedTransaction) {
11125
11127
  const b = [
11126
11128
  "update",
11127
- _,
11129
+ w,
11128
11130
  e,
11129
11131
  a,
11130
11132
  void 0,
@@ -11132,7 +11134,7 @@ ${i}`);
11132
11134
  ], F = [...b];
11133
11135
  await ie("postWrite", c, O, b), await ie("postOperation", c, O, F);
11134
11136
  }
11135
- const j = { ...o, ..._ };
11137
+ const j = { ...o, ...w };
11136
11138
  return nt(j), { id: e, ...j };
11137
11139
  }, hu = async (n, e, t, s, r) => {
11138
11140
  const i = Je(), a = Wt();
@@ -11146,60 +11148,60 @@ ${i}`);
11146
11148
  if (v && !f && !s?.force)
11147
11149
  return await Zc(n, e, { [v.archivedField]: !0, [v.timestampField]: me.serverTimestamp() }, void 0, t);
11148
11150
  const O = ce();
11149
- let N;
11151
+ let R;
11150
11152
  t && await Ks(n, m);
11151
- const w = Ae(O, n, i);
11153
+ const x = Ae(O, n, i);
11152
11154
  r = r || {}, r.collection = d.collection;
11153
- const T = await at(n, e, { user: t });
11154
- let D = Vs("delete", n, T, o, E, "Online", t || "System", lt.now(), me.serverTimestamp());
11155
- const C = Sn(D);
11156
- Ue(D), h && await Ft("delete", "started", D, i, n, e, m), await ie("preOperation", a, p, ["delete", D, e, r]), await ie("preWrite", a, p, ["delete", D, e, r]), Ue(D);
11155
+ const _ = await at(n, e, { user: t });
11156
+ let N = Vs("delete", n, _, o, E, "Online", t || "System", lt.now(), me.serverTimestamp());
11157
+ const C = Sn(N);
11158
+ Ue(N), h && await Ft("delete", "started", N, i, n, e, m), await ie("preOperation", a, p, ["delete", N, e, r]), await ie("preWrite", a, p, ["delete", N, e, r]), Ue(N);
11157
11159
  const y = async (g) => {
11158
- const [R, S, $, I] = await Promise.all([
11160
+ const [T, S, $, D] = await Promise.all([
11159
11161
  g.get(O.collection("system_deployment").doc("maintenance_mode")),
11160
11162
  at([d.collection], e, { user: t, providedTransaction: g }),
11161
11163
  t ? g.get(O.collection("tenants").doc(i).collection("system_user_permissions").doc(t)) : Promise.resolve({}),
11162
11164
  Ye()
11163
11165
  ]);
11164
- if (!R.exists)
11166
+ if (!T.exists)
11165
11167
  throw new Error("MAINTENANCE_MODE");
11166
- if (R.data().active)
11168
+ if (T.data().active)
11167
11169
  throw new Error("MAINTENANCE_MODE");
11168
11170
  if (!S)
11169
11171
  throw new Error("NOT_FOUND");
11170
- if (D = { ...S, ...C }, o = I, t) {
11172
+ if (N = { ...S, ...C }, o = D, t) {
11171
11173
  if (!$?.exists)
11172
11174
  throw new Error("PERMISSION_DENIED");
11173
- if (N = $.data(), !N.Role)
11175
+ if (R = $.data(), !R.Role)
11174
11176
  throw new Error("USER_ERROR");
11175
- if (!N.Enabled)
11177
+ if (!R.Enabled)
11176
11178
  throw new Error("PERMISSION_DENIED");
11177
- Go(D, e, m, o, t, N);
11179
+ Go(N, e, m, o, t, R);
11178
11180
  }
11179
- if (t && N?.Role) {
11180
- const q = N.Role;
11181
- if (!(p.custom?.serverAccess?.delete !== void 0 ? await re(p.custom.serverAccess.delete, [q, D]) : !0))
11181
+ if (t && R?.Role) {
11182
+ const q = R.Role;
11183
+ if (!(p.custom?.serverAccess?.delete !== void 0 ? await re(p.custom.serverAccess.delete, [q, N]) : !0))
11182
11184
  throw new Error("PERMISSION_DENIED");
11183
11185
  }
11184
11186
  };
11185
11187
  m.auth && (await O.runTransaction(async (g) => {
11186
11188
  await y(g);
11187
- }, { maxAttempts: 10 }), D.User_ID && await cn(D));
11189
+ }, { maxAttempts: 10 }), N.User_ID && await cn(N));
11188
11190
  try {
11189
11191
  await O.runTransaction(async (g) => {
11190
11192
  await y(g);
11191
- const R = Ls(o);
11192
- Ys("delete", g, n, e, D, o, m, s, R, me.arrayUnion, me.arrayRemove, me.delete, (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S.name}`).doc(e), (S, $) => O.collection("tenants").doc(i).collection("system_unique").doc(d.collection).collection(`Unique-${d.collection}-${S.name}`).doc($), (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S}`).doc(e), (S, $) => Ae(O, S, i).doc($), (S, $, I) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$}`).doc(I), (S, $, I) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$.replaceAll(" ", "-")}`).doc(I)), g.delete(w.doc(e));
11193
+ const T = Ls(o);
11194
+ Ys("delete", g, n, e, N, o, m, s, T, me.arrayUnion, me.arrayRemove, me.delete, (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S.name}`).doc(e), (S, $) => O.collection("tenants").doc(i).collection("system_unique").doc(d.collection).collection(`Unique-${d.collection}-${S.name}`).doc($), (S) => O.collection("tenants").doc(i).collection("system_fields").doc(d.collection).collection(`${d.collection}-${S}`).doc(e), (S, $) => Ae(O, S, i).doc($), (S, $, D) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$}`).doc(D), (S, $, D) => O.collection("tenants").doc(i).collection("system_fields").doc(S.collection).collection(`${S.collection}-${$.replaceAll(" ", "-")}`).doc(D)), g.delete(x.doc(e));
11193
11195
  }, { maxAttempts: 10 });
11194
11196
  } catch (g) {
11195
- const S = await ie("postWriteError", a, p, ["delete", D, e, r, g]);
11197
+ const S = await ie("postWriteError", a, p, ["delete", N, e, r, g]);
11196
11198
  if (h && (await new Promise(($) => {
11197
11199
  setTimeout($, 250);
11198
- }), await Ft("delete", S?.resolved ? "success" : "failed", D, i, n, e, m, S?.resolved ? void 0 : g)), !S?.resolved)
11199
- throw m.auth && D.User_ID && await O.collection("tenants").doc(i).collection(d.collection).doc(e).update({ User_ID: me.delete() }), g;
11200
+ }), await Ft("delete", S?.resolved ? "success" : "failed", N, i, n, e, m, S?.resolved ? void 0 : g)), !S?.resolved)
11201
+ throw m.auth && N.User_ID && await O.collection("tenants").doc(i).collection(d.collection).doc(e).update({ User_ID: me.delete() }), g;
11200
11202
  }
11201
- const k = ["delete", D, e, r], _ = [...k];
11202
- return await ie("postWrite", a, p, k), await ie("postOperation", a, p, _), { id: e, ...D };
11203
+ const k = ["delete", N, e, r], w = [...k];
11204
+ return await ie("postWrite", a, p, k), await ie("postOperation", a, p, w), { id: e, ...N };
11203
11205
  }, mu = async (n, e) => {
11204
11206
  const t = ce(), s = ko(), r = process.env.ADMIN_SMS;
11205
11207
  if (s === "development")
@@ -11221,16 +11223,16 @@ ${i}`);
11221
11223
  e(n);
11222
11224
  }, yu = async (n) => await gt().getUser(n), gu = (n) => {
11223
11225
  const e = bo();
11224
- return L.fromJSDate(n).setZone(e);
11226
+ return V.fromJSDate(n).setZone(e);
11225
11227
  }, qc = (n) => {
11226
11228
  const e = bo();
11227
- return L.fromJSDate(n.toDate()).setZone(e);
11229
+ return V.fromJSDate(n.toDate()).setZone(e);
11228
11230
  }, wu = (n, e) => {
11229
- const s = L.fromJSDate(n, { zone: e }).offset, i = L.fromJSDate(n).offset, a = s - i;
11230
- return L.fromJSDate(n).plus({ minutes: a }).toJSDate();
11231
+ const s = V.fromJSDate(n, { zone: e }).offset, i = V.fromJSDate(n).offset, a = s - i;
11232
+ return V.fromJSDate(n).plus({ minutes: a }).toJSDate();
11231
11233
  }, _u = (n, e) => {
11232
- const s = L.fromJSDate(n, { zone: e }).offset, i = L.fromJSDate(n).offset, a = s - i;
11233
- return L.fromJSDate(n).minus({ minutes: a }).toJSDate();
11234
+ const s = V.fromJSDate(n, { zone: e }).offset, i = V.fromJSDate(n).offset, a = s - i;
11235
+ return V.fromJSDate(n).minus({ minutes: a }).toJSDate();
11234
11236
  }, Eu = (n) => "seconds" in n && "nanoseconds" in n ? qc(new lt(n.seconds, n.nanoseconds)).toFormat("MMMM d, yyyy '@' h:mm a") : "";
11235
11237
  export {
11236
11238
  fu as addRecord,