@instantdb/core 0.22.69 → 0.22.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/__tests__/src/fieldsTypeTest.ts +111 -0
  2. package/__tests__/src/typeUtils.ts +39 -0
  3. package/__tests__/src/useDatesTypeTest.ts +67 -0
  4. package/__tests__/src/utils/PersistedObject.test.ts +8 -0
  5. package/dist/commonjs/Connection.d.ts.map +1 -1
  6. package/dist/commonjs/Connection.js +5 -4
  7. package/dist/commonjs/Connection.js.map +1 -1
  8. package/dist/commonjs/Reactor.d.ts +21 -10
  9. package/dist/commonjs/Reactor.d.ts.map +1 -1
  10. package/dist/commonjs/SyncTable.d.ts +10 -10
  11. package/dist/commonjs/SyncTable.d.ts.map +1 -1
  12. package/dist/commonjs/SyncTable.js.map +1 -1
  13. package/dist/commonjs/devtool.js.map +1 -1
  14. package/dist/commonjs/helperTypes.d.ts +1 -1
  15. package/dist/commonjs/helperTypes.d.ts.map +1 -1
  16. package/dist/commonjs/helperTypes.js.map +1 -1
  17. package/dist/commonjs/index.d.ts +7 -7
  18. package/dist/commonjs/index.d.ts.map +1 -1
  19. package/dist/commonjs/index.js +3 -2
  20. package/dist/commonjs/index.js.map +1 -1
  21. package/dist/commonjs/queryTypes.d.ts +20 -11
  22. package/dist/commonjs/queryTypes.d.ts.map +1 -1
  23. package/dist/commonjs/queryTypes.js.map +1 -1
  24. package/dist/commonjs/queryValidation.js.map +1 -1
  25. package/dist/commonjs/schemaTypes.d.ts +2 -2
  26. package/dist/commonjs/schemaTypes.d.ts.map +1 -1
  27. package/dist/commonjs/schemaTypes.js.map +1 -1
  28. package/dist/commonjs/utils/PersistedObject.d.ts +2 -2
  29. package/dist/esm/Connection.d.ts.map +1 -1
  30. package/dist/esm/Connection.js +5 -4
  31. package/dist/esm/Connection.js.map +1 -1
  32. package/dist/esm/Reactor.d.ts +21 -10
  33. package/dist/esm/Reactor.d.ts.map +1 -1
  34. package/dist/esm/SyncTable.d.ts +10 -10
  35. package/dist/esm/SyncTable.d.ts.map +1 -1
  36. package/dist/esm/SyncTable.js.map +1 -1
  37. package/dist/esm/devtool.js.map +1 -1
  38. package/dist/esm/helperTypes.d.ts +1 -1
  39. package/dist/esm/helperTypes.d.ts.map +1 -1
  40. package/dist/esm/helperTypes.js.map +1 -1
  41. package/dist/esm/index.d.ts +7 -7
  42. package/dist/esm/index.d.ts.map +1 -1
  43. package/dist/esm/index.js +3 -2
  44. package/dist/esm/index.js.map +1 -1
  45. package/dist/esm/queryTypes.d.ts +20 -11
  46. package/dist/esm/queryTypes.d.ts.map +1 -1
  47. package/dist/esm/queryTypes.js.map +1 -1
  48. package/dist/esm/queryValidation.js.map +1 -1
  49. package/dist/esm/schemaTypes.d.ts +2 -2
  50. package/dist/esm/schemaTypes.d.ts.map +1 -1
  51. package/dist/esm/schemaTypes.js.map +1 -1
  52. package/dist/esm/utils/PersistedObject.d.ts +2 -2
  53. package/dist/standalone/index.js +216 -214
  54. package/dist/standalone/index.umd.cjs +3 -3
  55. package/package.json +2 -2
  56. package/src/Connection.ts +4 -4
  57. package/src/SyncTable.ts +10 -10
  58. package/src/devtool.ts +2 -2
  59. package/src/helperTypes.ts +3 -1
  60. package/src/index.ts +19 -11
  61. package/src/queryTypes.ts +52 -24
  62. package/src/queryValidation.ts +2 -2
  63. package/src/schemaTypes.ts +5 -2
  64. package/tsconfig.json +2 -1
@@ -43,11 +43,11 @@ const A = {
43
43
  }, nn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Jn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Te = Symbol.iterator, L = {
44
44
  mutable: "mutable",
45
45
  immutable: "immutable"
46
- }, ot = {};
46
+ }, it = {};
47
47
  function ue(t, e) {
48
48
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
49
49
  }
50
- function Ot(t, e) {
50
+ function St(t, e) {
51
51
  if (e in t) {
52
52
  let n = Reflect.getPrototypeOf(t);
53
53
  for (; n; ) {
@@ -58,10 +58,10 @@ function Ot(t, e) {
58
58
  }
59
59
  }
60
60
  }
61
- function at(t) {
61
+ function ot(t) {
62
62
  return Object.getPrototypeOf(t) === Set.prototype;
63
63
  }
64
- function ct(t) {
64
+ function at(t) {
65
65
  return Object.getPrototypeOf(t) === Map.prototype;
66
66
  }
67
67
  function U(t) {
@@ -74,7 +74,7 @@ function Y(t) {
74
74
  function S(t) {
75
75
  return typeof t != "object" ? null : t == null ? void 0 : t[nn];
76
76
  }
77
- function ut(t) {
77
+ function ct(t) {
78
78
  var e;
79
79
  const n = S(t);
80
80
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -121,7 +121,7 @@ function Re(t, e) {
121
121
  function W(t, e) {
122
122
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
123
123
  }
124
- function qe(t) {
124
+ function Ke(t) {
125
125
  if (t)
126
126
  for (; t.finalities.revoke.length > 0; )
127
127
  t.finalities.revoke.pop()();
@@ -162,13 +162,13 @@ function sn(t, e) {
162
162
  if (Array.isArray(t))
163
163
  return Array.prototype.concat.call(t);
164
164
  if (t instanceof Set) {
165
- if (!at(t)) {
165
+ if (!ot(t)) {
166
166
  const r = Object.getPrototypeOf(t).constructor;
167
167
  return new r(t.values());
168
168
  }
169
169
  return Set.prototype.difference ? Set.prototype.difference.call(t, /* @__PURE__ */ new Set()) : new Set(t.values());
170
170
  } else if (t instanceof Map) {
171
- if (!ct(t)) {
171
+ if (!at(t)) {
172
172
  const r = Object.getPrototypeOf(t).constructor;
173
173
  return new r(t);
174
174
  }
@@ -197,7 +197,7 @@ function j(t) {
197
197
  }
198
198
  function oe(t) {
199
199
  if (!K(t))
200
- return ut(t);
200
+ return ct(t);
201
201
  if (Array.isArray(t))
202
202
  return t.map(oe);
203
203
  if (t instanceof Map) {
@@ -205,7 +205,7 @@ function oe(t) {
205
205
  r,
206
206
  oe(s)
207
207
  ]);
208
- if (!ct(t)) {
208
+ if (!at(t)) {
209
209
  const r = Object.getPrototypeOf(t).constructor;
210
210
  return new r(n);
211
211
  }
@@ -213,7 +213,7 @@ function oe(t) {
213
213
  }
214
214
  if (t instanceof Set) {
215
215
  const n = Array.from(t).map(oe);
216
- if (!at(t)) {
216
+ if (!ot(t)) {
217
217
  const r = Object.getPrototypeOf(t).constructor;
218
218
  return new r(n);
219
219
  }
@@ -231,7 +231,7 @@ function z(t) {
231
231
  var e;
232
232
  t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && z(t.parent));
233
233
  }
234
- function vt() {
234
+ function Ot() {
235
235
  throw new Error("Cannot modify frozen object");
236
236
  }
237
237
  function X(t, e, n, r, s) {
@@ -259,12 +259,12 @@ function X(t, e, n, r, s) {
259
259
  case 2:
260
260
  for (const [a, c] of t)
261
261
  X(a, a, n, r, s), X(c, a, n, r, s);
262
- t.set = t.clear = t.delete = vt;
262
+ t.set = t.clear = t.delete = Ot;
263
263
  break;
264
264
  case 3:
265
265
  for (const a of t)
266
266
  X(a, a, n, r, s);
267
- t.add = t.clear = t.delete = vt;
267
+ t.add = t.clear = t.delete = Ot;
268
268
  break;
269
269
  case 1:
270
270
  Object.freeze(t);
@@ -280,7 +280,7 @@ function X(t, e, n, r, s) {
280
280
  }
281
281
  r.pop(), s.pop();
282
282
  }
283
- function lt(t, e) {
283
+ function ut(t, e) {
284
284
  const n = Z(t);
285
285
  if (n === 0)
286
286
  Reflect.ownKeys(t).forEach((r) => {
@@ -297,7 +297,7 @@ function on(t, e, n) {
297
297
  if (Y(t) || !K(t, n) || e.has(t) || Object.isFrozen(t))
298
298
  return;
299
299
  const r = t instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
300
- if (e.add(t), lt(t, (i, o) => {
300
+ if (e.add(t), ut(t, (i, o) => {
301
301
  var a;
302
302
  if (Y(o)) {
303
303
  const c = S(o);
@@ -317,12 +317,12 @@ function er(t, e) {
317
317
  const n = t.type === 3 ? t.setMap : t.copy;
318
318
  t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && on(Q(n, e), t.finalities.handledSet, t.options);
319
319
  }
320
- function ze(t) {
320
+ function qe(t) {
321
321
  t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
322
- t.copy.add(ut(e));
322
+ t.copy.add(ct(e));
323
323
  }));
324
324
  }
325
- function Ve(t, e, n, r) {
325
+ function ze(t, e, n, r) {
326
326
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
327
327
  if (n && r) {
328
328
  const i = rn(t);
@@ -331,14 +331,14 @@ function Ve(t, e, n, r) {
331
331
  t.finalized = !0;
332
332
  }
333
333
  }
334
- function ft(t, e, n, r) {
334
+ function lt(t, e, n, r) {
335
335
  const s = S(n);
336
336
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
337
337
  var a;
338
338
  const c = t.type === 3 ? t.setMap : t.copy;
339
339
  if (W(Q(c, e), n)) {
340
340
  let u = s.original;
341
- s.copy && (u = s.copy), ze(t), Ve(t, r, i, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(u, s.original)), pe(c, e, u);
341
+ s.copy && (u = s.copy), qe(t), ze(t, r, i, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(u, s.original)), pe(c, e, u);
342
342
  }
343
343
  }), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), K(n, t.options) && t.finalities.draft.push(() => {
344
344
  const i = t.type === 3 ? t.setMap : t.copy;
@@ -447,7 +447,7 @@ function de(t, e, n, r) {
447
447
  const ve = (t, e, n = !1) => {
448
448
  if (typeof t == "object" && t !== null && (!K(t, e) || n))
449
449
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
450
- }, We = {
450
+ }, Ve = {
451
451
  get size() {
452
452
  return U(S(this)).size;
453
453
  },
@@ -456,7 +456,7 @@ const ve = (t, e, n = !1) => {
456
456
  },
457
457
  set(t, e) {
458
458
  const n = S(this), r = U(n);
459
- return (!r.has(t) || !W(r.get(t), e)) && (j(n), z(n), n.assignedMap.set(t, !0), n.copy.set(t, e), ft(n, t, e, de)), this;
459
+ return (!r.has(t) || !W(r.get(t), e)) && (j(n), z(n), n.assignedMap.set(t, !0), n.copy.set(t, e), lt(n, t, e, de)), this;
460
460
  },
461
461
  delete(t) {
462
462
  if (!this.has(t))
@@ -484,7 +484,7 @@ const ve = (t, e, n = !1) => {
484
484
  const r = S(this), s = U(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, L)) === L.mutable;
485
485
  if (r.options.strict && ve(s, r.options, i), i || r.finalized || !K(s, r.options) || s !== r.original.get(t))
486
486
  return s;
487
- const o = ot.createDraft({
487
+ const o = it.createDraft({
488
488
  original: s,
489
489
  parentDraft: r,
490
490
  key: t,
@@ -528,7 +528,7 @@ const ve = (t, e, n = !1) => {
528
528
  [Te]() {
529
529
  return this.entries();
530
530
  }
531
- }, sr = Reflect.ownKeys(We), At = (t, e, { isValuesIterator: n }) => () => {
531
+ }, sr = Reflect.ownKeys(Ve), vt = (t, e, { isValuesIterator: n }) => () => {
532
532
  var r, s;
533
533
  const i = e.next();
534
534
  if (i.done)
@@ -537,7 +537,7 @@ const ve = (t, e, n = !1) => {
537
537
  let a = t.setMap.get(o);
538
538
  const c = S(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, L)) === L.mutable;
539
539
  if (t.options.strict && ve(o, t.options, u), !u && !c && K(o, t.options) && !t.finalized && t.original.has(o)) {
540
- const l = ot.createDraft({
540
+ const l = it.createDraft({
541
541
  original: o,
542
542
  parentDraft: t,
543
543
  key: o,
@@ -564,7 +564,7 @@ const ve = (t, e, n = !1) => {
564
564
  },
565
565
  add(t) {
566
566
  const e = S(this);
567
- return this.has(t) || (j(e), z(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), ft(e, t, t, de)), this;
567
+ return this.has(t) || (j(e), z(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), lt(e, t, t, de)), this;
568
568
  },
569
569
  delete(t) {
570
570
  if (!this.has(t))
@@ -589,7 +589,7 @@ const ve = (t, e, n = !1) => {
589
589
  const e = t.setMap.keys();
590
590
  return {
591
591
  [Symbol.iterator]: () => this.values(),
592
- next: At(t, e, { isValuesIterator: !0 })
592
+ next: vt(t, e, { isValuesIterator: !0 })
593
593
  };
594
594
  },
595
595
  entries() {
@@ -598,7 +598,7 @@ const ve = (t, e, n = !1) => {
598
598
  const e = t.setMap.keys();
599
599
  return {
600
600
  [Symbol.iterator]: () => this.entries(),
601
- next: At(t, e, {
601
+ next: vt(t, e, {
602
602
  isValuesIterator: !1
603
603
  })
604
604
  };
@@ -656,8 +656,8 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
656
656
  const a = U(t);
657
657
  if (a instanceof Map && sr.includes(e)) {
658
658
  if (e === "size")
659
- return Object.getOwnPropertyDescriptor(We, "size").get.call(t.proxy);
660
- const u = We[e];
659
+ return Object.getOwnPropertyDescriptor(Ve, "size").get.call(t.proxy);
660
+ const u = Ve[e];
661
661
  if (u)
662
662
  return u.bind(t.proxy);
663
663
  }
@@ -669,7 +669,7 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
669
669
  return u.bind(t.proxy);
670
670
  }
671
671
  if (!ue(a, e)) {
672
- const u = Ot(a, e);
672
+ const u = St(a, e);
673
673
  return u ? "value" in u ? u.value : (
674
674
  // !case: support for getter
675
675
  (s = u.get) === null || s === void 0 ? void 0 : s.call(t.proxy)
@@ -679,7 +679,7 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
679
679
  if (t.options.strict && ve(c, t.options), t.finalized || !K(c, t.options))
680
680
  return c;
681
681
  if (c === Re(t.original, e)) {
682
- if (j(t), t.copy[e] = dt({
682
+ if (j(t), t.copy[e] = ft({
683
683
  original: t.original[e],
684
684
  parentDraft: t,
685
685
  key: t.type === 1 ? Number(e) : e,
@@ -700,11 +700,11 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
700
700
  let s;
701
701
  if (t.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
702
702
  throw new Error("Only supports setting array indices and the 'length' property.");
703
- const i = Ot(U(t), e);
703
+ const i = St(U(t), e);
704
704
  if (i != null && i.set)
705
705
  return i.set.call(t.proxy, n), !0;
706
706
  const o = Re(U(t), e), a = S(o);
707
- return a && W(a.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (W(n, o) && (n !== void 0 || ue(t.original, e)) || (j(t), z(t), ue(t.original, e) && W(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, ft(t, e, n, de)), !0);
707
+ return a && W(a.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (W(n, o) && (n !== void 0 || ue(t.original, e)) || (j(t), z(t), ue(t.original, e) && W(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, lt(t, e, n, de)), !0);
708
708
  },
709
709
  has(t, e) {
710
710
  return e in U(t);
@@ -735,7 +735,7 @@ const ir = Reflect.ownKeys(Ae), an = /* @__PURE__ */ new WeakSet(), cn = {
735
735
  return t.type === 1 ? cn.set.call(this, t, e, void 0, t.proxy) : (Re(t.original, e) !== void 0 || e in t.original ? (j(t), z(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
736
736
  }
737
737
  };
738
- function dt(t) {
738
+ function ft(t) {
739
739
  const { original: e, parentDraft: n, key: r, finalities: s, options: i } = t, o = Z(e), a = {
740
740
  type: o,
741
741
  finalized: !1,
@@ -759,7 +759,7 @@ function dt(t) {
759
759
  const b = Q(y, r), g = S(b);
760
760
  if (g) {
761
761
  let T = g.original;
762
- g.operated && (T = ut(b)), ze(g), Ve(g, de, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (h = l.options.updatedValues) !== null && h !== void 0 ? h : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, g.original)), pe(y, r, T);
762
+ g.operated && (T = ct(b)), qe(g), ze(g, de, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (h = l.options.updatedValues) !== null && h !== void 0 ? h : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, g.original)), pe(y, r, T);
763
763
  }
764
764
  (p = _.callbacks) === null || p === void 0 || p.forEach((T) => {
765
765
  T(f, d);
@@ -768,12 +768,12 @@ function dt(t) {
768
768
  } else {
769
769
  const l = S(c);
770
770
  l.finalities.draft.push((f, d) => {
771
- ze(l), Ve(l, de, f, d);
771
+ qe(l), ze(l, de, f, d);
772
772
  });
773
773
  }
774
774
  return c;
775
775
  }
776
- ot.createDraft = dt;
776
+ it.createDraft = ft;
777
777
  function or(t, e, n, r, s) {
778
778
  var i;
779
779
  const o = S(t), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : t, c = !!e.length;
@@ -781,7 +781,7 @@ function or(t, e, n, r, s) {
781
781
  for (; o.finalities.draft.length > 0; )
782
782
  o.finalities.draft.pop()(n, r);
783
783
  const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
784
- return o && qe(o), s && X(u, u, o == null ? void 0 : o.options.updatedValues), [
784
+ return o && Ke(o), s && X(u, u, o == null ? void 0 : o.options.updatedValues), [
785
785
  u,
786
786
  n && c ? [{ op: A.Replace, path: [], value: e[0] }] : n,
787
787
  r && c ? [{ op: A.Replace, path: [], value: a }] : r
@@ -796,7 +796,7 @@ function ar(t, e) {
796
796
  };
797
797
  let s, i;
798
798
  e.enablePatches && (s = [], i = []);
799
- const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, L)) === L.mutable || !K(t, e) ? t : dt({
799
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, L)) === L.mutable || !K(t, e) ? t : ft({
800
800
  original: t,
801
801
  parentDraft: null,
802
802
  finalities: r,
@@ -810,9 +810,9 @@ function ar(t, e) {
810
810
  }
811
811
  ];
812
812
  }
813
- function Qe(t) {
813
+ function We(t) {
814
814
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: s = !0 } = t;
815
- lt(n, (i, o, a) => {
815
+ ut(n, (i, o, a) => {
816
816
  const c = S(o);
817
817
  if (c && e && c.finalities === e.finalities) {
818
818
  t.isContainDraft = !0;
@@ -822,7 +822,7 @@ function Qe(t) {
822
822
  a.clear(), l.forEach((f) => a.add(i === f ? u : f));
823
823
  } else
824
824
  pe(a, i, u);
825
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Qe(t));
825
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, We(t));
826
826
  }), s && (t.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
827
827
  }
828
828
  function un(t) {
@@ -835,7 +835,7 @@ function un(t) {
835
835
  return n.original;
836
836
  let s;
837
837
  function i() {
838
- s = r === 2 ? ct(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : sn(t, n == null ? void 0 : n.options);
838
+ s = r === 2 ? at(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : sn(t, n == null ? void 0 : n.options);
839
839
  }
840
840
  if (n) {
841
841
  n.finalized = !0;
@@ -846,18 +846,18 @@ function un(t) {
846
846
  }
847
847
  } else
848
848
  s = t;
849
- if (lt(s, (o, a) => {
849
+ if (ut(s, (o, a) => {
850
850
  if (n && W(Q(n.original, o), a))
851
851
  return;
852
852
  const c = un(a);
853
853
  c !== a && (s === t && i(), pe(s, o, c));
854
854
  }), r === 3) {
855
855
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : s;
856
- return at(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
856
+ return ot(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
857
857
  }
858
858
  return s;
859
859
  }
860
- function kt(t) {
860
+ function At(t) {
861
861
  if (!Y(t))
862
862
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
863
863
  return un(t);
@@ -873,7 +873,7 @@ const cr = (t) => function e(n, r, s) {
873
873
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
874
874
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
875
875
  l = Object.assign(Object.assign({}, t), l);
876
- const f = Y(c) ? kt(c) : c, d = Array.isArray(l.mark) ? (m, M) => {
876
+ const f = Y(c) ? At(c) : c, d = Array.isArray(l.mark) ? (m, M) => {
877
877
  for (const I of l.mark) {
878
878
  if (typeof I != "function")
879
879
  throw new Error(`Invalid mark: ${I}, 'mark' should be a function.`);
@@ -899,7 +899,7 @@ const cr = (t) => function e(n, r, s) {
899
899
  try {
900
900
  T = u(b);
901
901
  } catch (m) {
902
- throw qe(S(b)), m;
902
+ throw Ke(S(b)), m;
903
903
  }
904
904
  const v = (m) => {
905
905
  const M = S(b);
@@ -909,14 +909,14 @@ const cr = (t) => function e(n, r, s) {
909
909
  const B = m == null ? void 0 : m[Jn];
910
910
  if (B) {
911
911
  const De = B[0];
912
- return y.strict && typeof m == "object" && m !== null && Qe({
912
+ return y.strict && typeof m == "object" && m !== null && We({
913
913
  rootDraft: M,
914
914
  value: m,
915
915
  useRawReturn: !0
916
916
  }), g([De]);
917
917
  }
918
918
  if (m !== void 0)
919
- return typeof m == "object" && m !== null && Qe({ rootDraft: M, value: m }), g([m]);
919
+ return typeof m == "object" && m !== null && We({ rootDraft: M, value: m }), g([m]);
920
920
  }
921
921
  if (m === b || m === void 0)
922
922
  return g([]);
@@ -924,12 +924,12 @@ const cr = (t) => function e(n, r, s) {
924
924
  if (y === I.options) {
925
925
  if (I.operated)
926
926
  throw new Error("Cannot return a modified child draft.");
927
- return g([kt(m)]);
927
+ return g([At(m)]);
928
928
  }
929
929
  return g([m]);
930
930
  };
931
931
  return T instanceof Promise ? T.then(v, (m) => {
932
- throw qe(S(b)), m;
932
+ throw Ke(S(b)), m;
933
933
  }) : v(T);
934
934
  }, ke = cr();
935
935
  Object.prototype.constructor.toString();
@@ -937,7 +937,7 @@ function ln(t, e) {
937
937
  const n = Object.keys(t), r = Object.keys(e);
938
938
  return n.length === r.length && Object.keys(t).every((s) => e.hasOwnProperty(s));
939
939
  }
940
- function Et(t, e) {
940
+ function kt(t, e) {
941
941
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every(
942
942
  (n) => e.hasOwnProperty(n) && t[n] === e[n]
943
943
  );
@@ -947,7 +947,7 @@ function Se(t, e) {
947
947
  (n) => Se(t[n], e[n])
948
948
  ) : !1;
949
949
  }
950
- function ht(t) {
950
+ function dt(t) {
951
951
  if (!ae(t))
952
952
  return t;
953
953
  const e = {};
@@ -984,7 +984,7 @@ function ur(t, e, n) {
984
984
  const s = e[e.length - 1];
985
985
  Array.isArray(r) && typeof s == "number" ? r.splice(s, 0, n) : r[s] = n;
986
986
  }
987
- function Ct(t, e, n) {
987
+ function Et(t, e, n) {
988
988
  if (!t || e.length === 0)
989
989
  return;
990
990
  let r = t || {};
@@ -1009,7 +1009,7 @@ function dn(t, e) {
1009
1009
  function lr(t) {
1010
1010
  return t && Object.keys(t).length === 0;
1011
1011
  }
1012
- const Mt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, fr = {
1012
+ const Ct = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, fr = {
1013
1013
  ZULU: 0,
1014
1014
  YEKT: 18e3,
1015
1015
  YEKST: 21600,
@@ -1275,10 +1275,10 @@ function Sr(t) {
1275
1275
  }
1276
1276
  }
1277
1277
  function Or(t) {
1278
- const e = t.match(Mt);
1278
+ const e = t.match(Ct);
1279
1279
  if (!e)
1280
1280
  return null;
1281
- const [n] = e, r = fr[n], s = new Date(t.replace(Mt, "Z"));
1281
+ const [n] = e, r = fr[n], s = new Date(t.replace(Ct, "Z"));
1282
1282
  return new Date(s.getTime() - r * 1e3);
1283
1283
  }
1284
1284
  const vr = [
@@ -1302,7 +1302,7 @@ function Ar(t, e) {
1302
1302
  return null;
1303
1303
  }
1304
1304
  }
1305
- function Ge(t) {
1305
+ function Qe(t) {
1306
1306
  for (const e of vr) {
1307
1307
  const n = Ar(e, t);
1308
1308
  if (n)
@@ -1313,7 +1313,7 @@ function Ge(t) {
1313
1313
  function kr(t) {
1314
1314
  try {
1315
1315
  const e = JSON.parse(t);
1316
- return typeof e == "string" ? Ge(e) : null;
1316
+ return typeof e == "string" ? Qe(e) : null;
1317
1317
  } catch {
1318
1318
  return null;
1319
1319
  }
@@ -1325,7 +1325,7 @@ function Me(t) {
1325
1325
  if (t instanceof Date)
1326
1326
  return t;
1327
1327
  if (typeof t == "string") {
1328
- const e = Ge(t) || kr(t) || Ge(t.trim());
1328
+ const e = Qe(t) || kr(t) || Qe(t.trim());
1329
1329
  if (!e)
1330
1330
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1331
1331
  return e;
@@ -1339,10 +1339,10 @@ function Me(t) {
1339
1339
  function Er(t) {
1340
1340
  return t.cardinality === "one";
1341
1341
  }
1342
- function pt(t) {
1342
+ function ht(t) {
1343
1343
  return t["value-type"] === "ref";
1344
1344
  }
1345
- function yt(t) {
1345
+ function pt(t) {
1346
1346
  return t["value-type"] === "blob";
1347
1347
  }
1348
1348
  function re(t, e) {
@@ -1379,7 +1379,7 @@ function hn(t, e, n) {
1379
1379
  console.warn("no such attr", a, t);
1380
1380
  continue;
1381
1381
  }
1382
- f["checked-data-type"] === "date" && n && (u = Me(u), o[2] = u), pt(f) && D(i, [u, c, a], o), D(r, [a, c, u], o), D(s, [c, a, u], o);
1382
+ f["checked-data-type"] === "date" && n && (u = Me(u), o[2] = u), ht(f) && D(i, [u, c, a], o), D(r, [a, c, u], o), D(s, [c, a, u], o);
1383
1383
  }
1384
1384
  return { eav: r, aev: s, vae: i };
1385
1385
  }
@@ -1387,7 +1387,7 @@ function pn(t) {
1387
1387
  const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1388
1388
  for (const i of Object.values(t)) {
1389
1389
  const o = i["forward-identity"], [a, c, u] = o, l = i["reverse-identity"];
1390
- if (D(r, [c, u], i), yt(i) && D(e, [c, u], i), i["primary?"] && D(n, [c], i), l) {
1390
+ if (D(r, [c, u], i), pt(i) && D(e, [c, u], i), i["primary?"] && D(n, [c], i), l) {
1391
1391
  const [f, d, h] = l;
1392
1392
  D(s, [d, h], i);
1393
1393
  }
@@ -1416,7 +1416,7 @@ function bn(t) {
1416
1416
  function Cr(t, e) {
1417
1417
  return se(t.eav, [e]) !== void 0;
1418
1418
  }
1419
- function bt(t) {
1419
+ function yt(t) {
1420
1420
  t.attrIndexes = pn(t.attrs);
1421
1421
  }
1422
1422
  function Oe(t, e, n, r, s) {
@@ -1455,7 +1455,7 @@ function _n(t, e) {
1455
1455
  if (!n)
1456
1456
  return;
1457
1457
  const [r, s, i] = n, o = re(t.attrs, s);
1458
- o && (N(t.eav, [r, s, i]), N(t.aev, [s, r, i]), pt(o) && N(t.vae, [i, s, r]));
1458
+ o && (N(t.eav, [r, s, i]), N(t.aev, [s, r, i]), ht(o) && N(t.vae, [i, s, r]));
1459
1459
  }
1460
1460
  let Mr = 0;
1461
1461
  function gn(t, e, n) {
@@ -1474,7 +1474,7 @@ function wn(t, e) {
1474
1474
  return;
1475
1475
  o["checked-data-type"] === "date" && t.useDateObjects && (i = Me(i));
1476
1476
  const a = se(t.eav, [r, s, i]), c = (a == null ? void 0 : a[3]) ?? gn(t, o, n), u = [r, s, i, c];
1477
- Er(o) ? (D(t.eav, [r, s], /* @__PURE__ */ new Map([[i, u]])), D(t.aev, [s, r], /* @__PURE__ */ new Map([[i, u]]))) : (D(t.eav, [r, s, i], u), D(t.aev, [s, r, i], u)), pt(o) && D(t.vae, [i, s, r], u);
1477
+ Er(o) ? (D(t.eav, [r, s], /* @__PURE__ */ new Map([[i, u]])), D(t.aev, [s, r], /* @__PURE__ */ new Map([[i, u]]))) : (D(t.eav, [r, s, i], u), D(t.aev, [s, r, i], u)), ht(o) && D(t.vae, [i, s, r], u);
1478
1478
  }
1479
1479
  function Ir(t, e) {
1480
1480
  var d;
@@ -1483,7 +1483,7 @@ function Ir(t, e) {
1483
1483
  return;
1484
1484
  const [r, s, i] = n, o = re(t.attrs, s);
1485
1485
  if (!o) return;
1486
- if (!yt(o))
1486
+ if (!pt(o))
1487
1487
  throw new Error("merge operation is not supported for links");
1488
1488
  const a = se(t.eav, [r, s]);
1489
1489
  if (!a) return;
@@ -1497,7 +1497,7 @@ function Ir(t, e) {
1497
1497
  ];
1498
1498
  D(t.eav, [r, s], /* @__PURE__ */ new Map([[l, f]]));
1499
1499
  }
1500
- function Be(t, e) {
1500
+ function Ge(t, e) {
1501
1501
  var c, u;
1502
1502
  const [n, r] = e, s = ye(t, [n]);
1503
1503
  if (!s)
@@ -1509,7 +1509,7 @@ function Be(t, e) {
1509
1509
  f && f["on-delete-reverse"] === "cascade" && R(o.get(l), 1).forEach(
1510
1510
  ([d, h, p]) => {
1511
1511
  var _;
1512
- return Be(t, [p, (_ = f["reverse-identity"]) == null ? void 0 : _[1]]);
1512
+ return Ge(t, [p, (_ = f["reverse-identity"]) == null ? void 0 : _[1]]);
1513
1513
  }
1514
1514
  ), // Fall back to deleting everything if we've rehydrated tx-steps from
1515
1515
  // the store that didn't set `etype` in deleteEntity
@@ -1523,7 +1523,7 @@ function Be(t, e) {
1523
1523
  a && a.forEach((l) => {
1524
1524
  var _, y, b;
1525
1525
  const [f, d, h] = l, p = t.attrs[d];
1526
- (!r || !p || ((_ = p["reverse-identity"]) == null ? void 0 : _[1]) === r) && (N(t.eav, [f, d, h]), N(t.aev, [d, f, h]), N(t.vae, [h, d, f])), p && p["on-delete"] === "cascade" && ((y = p["reverse-identity"]) == null ? void 0 : y[1]) === r && Be(t, [f, (b = p["forward-identity"]) == null ? void 0 : b[1]]);
1526
+ (!r || !p || ((_ = p["reverse-identity"]) == null ? void 0 : _[1]) === r) && (N(t.eav, [f, d, h]), N(t.aev, [d, f, h]), N(t.vae, [h, d, f])), p && p["on-delete"] === "cascade" && ((y = p["reverse-identity"]) == null ? void 0 : y[1]) === r && Ge(t, [f, (b = p["forward-identity"]) == null ? void 0 : b[1]]);
1527
1527
  }), ((u = t.vae.get(i)) == null ? void 0 : u.size) === 0 && N(t.vae, [i]);
1528
1528
  }
1529
1529
  function Tn(t, e) {
@@ -1537,7 +1537,7 @@ function Tn(t, e) {
1537
1537
  });
1538
1538
  }
1539
1539
  function Pr(t, [e]) {
1540
- t.attrs[e.id] = e, bt(t);
1540
+ t.attrs[e.id] = e, yt(t);
1541
1541
  }
1542
1542
  function mn(t) {
1543
1543
  return R(t.eav, 3);
@@ -1545,11 +1545,11 @@ function mn(t) {
1545
1545
  function jr(t, [e]) {
1546
1546
  if (!t.attrs[e]) return;
1547
1547
  const n = mn(t).filter(([r, s]) => s !== e);
1548
- delete t.attrs[e], bt(t), Tn(t, n);
1548
+ delete t.attrs[e], yt(t), Tn(t, n);
1549
1549
  }
1550
1550
  function $r(t, [e]) {
1551
1551
  const n = t.attrs[e.id];
1552
- n && (t.attrs[e.id] = { ...n, ...e }, bt(t), Tn(t, mn(t)));
1552
+ n && (t.attrs[e.id] = { ...n, ...e }, yt(t), Tn(t, mn(t)));
1553
1553
  }
1554
1554
  function Dr(t, e) {
1555
1555
  const [n, ...r] = e;
@@ -1564,7 +1564,7 @@ function Dr(t, e) {
1564
1564
  _n(t, r);
1565
1565
  break;
1566
1566
  case "delete-entity":
1567
- Be(t, r);
1567
+ Ge(t, r);
1568
1568
  break;
1569
1569
  case "add-attr":
1570
1570
  Pr(t, r);
@@ -1747,15 +1747,15 @@ function qr(t, e, n) {
1747
1747
  }
1748
1748
  return { ...n, [t]: e };
1749
1749
  }
1750
- function It(t, e, n) {
1750
+ function Mt(t, e, n) {
1751
1751
  return t === e ? n : null;
1752
1752
  }
1753
1753
  function zr(t) {
1754
1754
  switch (typeof t) {
1755
1755
  case "string":
1756
- return t.startsWith("?") ? qr : It;
1756
+ return t.startsWith("?") ? qr : Mt;
1757
1757
  default:
1758
- return It;
1758
+ return Mt;
1759
1759
  }
1760
1760
  }
1761
1761
  const Vr = [
@@ -1785,19 +1785,19 @@ function Gr(t, e, n) {
1785
1785
  return Jr(t, e, n).map((r) => Qr(e, r, n)).filter((r) => r);
1786
1786
  }
1787
1787
  function Br(t, e, n) {
1788
- return e.or ? e.or.patterns.flatMap((r) => He(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => He(t, s, r), n) : n.flatMap((r) => Gr(t, e, r));
1788
+ return e.or ? e.or.patterns.flatMap((r) => Be(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Be(t, s, r), n) : n.flatMap((r) => Gr(t, e, r));
1789
1789
  }
1790
- function He(t, e, n = [{}]) {
1790
+ function Be(t, e, n = [{}]) {
1791
1791
  return e.reduce((r, s) => Br(t, s, r), n);
1792
1792
  }
1793
- function _t(t, e) {
1794
- return Array.isArray(e) ? e.map((n) => _t(t, n)) : Kr(e) ? t[e] : e;
1793
+ function bt(t, e) {
1794
+ return Array.isArray(e) ? e.map((n) => bt(t, n)) : Kr(e) ? t[e] : e;
1795
1795
  }
1796
1796
  function Hr(t, { find: e, where: n }) {
1797
- return He(t, n).map((s) => _t(s, e));
1797
+ return Be(t, n).map((s) => bt(s, e));
1798
1798
  }
1799
1799
  function Jr(t, e, n) {
1800
- return xr(t, _t(n, e));
1800
+ return xr(t, bt(n, e));
1801
1801
  }
1802
1802
  const Yr = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1803
1803
  function te(t) {
@@ -1819,18 +1819,18 @@ function es() {
1819
1819
  }
1820
1820
  return xe(Xr);
1821
1821
  }
1822
- const ts = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Pt = { randomUUID: ts };
1822
+ const ts = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), It = { randomUUID: ts };
1823
1823
  function ns(t, e, n) {
1824
1824
  var s;
1825
- if (Pt.randomUUID && !t)
1826
- return Pt.randomUUID();
1825
+ if (It.randomUUID && !t)
1826
+ return It.randomUUID();
1827
1827
  t = t || {};
1828
1828
  const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? es();
1829
1829
  if (r.length < 16)
1830
1830
  throw new Error("Random bytes length must be >= 16");
1831
1831
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Zr(r);
1832
1832
  }
1833
- function jt(t) {
1833
+ function Pt(t) {
1834
1834
  const e = t.replace(/-/g, ""), n = [];
1835
1835
  for (let r = 0; r < e.length; r += 2)
1836
1836
  n.push(parseInt(e.substring(r, r + 2), 16));
@@ -1844,7 +1844,7 @@ function rs(t, e) {
1844
1844
  return 0;
1845
1845
  }
1846
1846
  function ss(t, e) {
1847
- return rs(jt(t), jt(e));
1847
+ return rs(Pt(t), Pt(e));
1848
1848
  }
1849
1849
  function k() {
1850
1850
  return ns();
@@ -1880,7 +1880,7 @@ function us(t, e) {
1880
1880
  throw new ne(`Could not find id attr for ${e}`);
1881
1881
  return n;
1882
1882
  }
1883
- function $t(t, e, n, r) {
1883
+ function jt(t, e, n, r) {
1884
1884
  return [ls(t, e, n, r)];
1885
1885
  }
1886
1886
  function ls(t, e, n, r) {
@@ -1913,7 +1913,7 @@ function An(t, e, n, r, s) {
1913
1913
  ];
1914
1914
  return [i ? f : u, d, h, a, !!i];
1915
1915
  }
1916
- function Dt(t, e) {
1916
+ function $t(t, e) {
1917
1917
  if (typeof e != "string")
1918
1918
  return function(o) {
1919
1919
  return !1;
@@ -1967,7 +1967,7 @@ function ds(t, e) {
1967
1967
  }
1968
1968
  };
1969
1969
  if (e.hasOwnProperty("$like")) {
1970
- const r = Dt(!0, e.$like);
1970
+ const r = $t(!0, e.$like);
1971
1971
  return {
1972
1972
  $comparator: !0,
1973
1973
  $op: function(i) {
@@ -1976,7 +1976,7 @@ function ds(t, e) {
1976
1976
  };
1977
1977
  }
1978
1978
  if (e.hasOwnProperty("$ilike")) {
1979
- const r = Dt(!1, e.$ilike);
1979
+ const r = $t(!1, e.$ilike);
1980
1980
  return {
1981
1981
  $comparator: !0,
1982
1982
  $op: function(i) {
@@ -2028,7 +2028,7 @@ function ps(t, e, n, r, s) {
2028
2028
  );
2029
2029
  return [i, o, a];
2030
2030
  }
2031
- function Je(t, e, n, r, s, i) {
2031
+ function He(t, e, n, r, s, i) {
2032
2032
  const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ps(
2033
2033
  t,
2034
2034
  e,
@@ -2060,7 +2060,7 @@ function gs(t, e, n) {
2060
2060
  return e == i ? i : `${i}-${n}`;
2061
2061
  };
2062
2062
  }
2063
- function Rt(t, e, n, r, s, i) {
2063
+ function Dt(t, e, n, r, s, i) {
2064
2064
  const o = t(r, s), a = i.map((c, u) => {
2065
2065
  const l = gs(t, o, u);
2066
2066
  return kn(l, n, r, s, c);
@@ -2073,22 +2073,22 @@ function ws(t) {
2073
2073
  e.push(t.slice(0, n));
2074
2074
  return e;
2075
2075
  }
2076
- function xt(t, e, n, r, s) {
2076
+ function Rt(t, e, n, r, s) {
2077
2077
  return ws(s).map(
2078
- (i) => Je(t, e, n, r, i, { $isNull: !0 })
2078
+ (i) => He(t, e, n, r, i, { $isNull: !0 })
2079
2079
  );
2080
2080
  }
2081
2081
  function kn(t, e, n, r, s) {
2082
2082
  return Object.entries(s).flatMap(([i, o]) => {
2083
2083
  if (bs([i, o]))
2084
- return Rt(t, "or", e, n, r, o);
2084
+ return Dt(t, "or", e, n, r, o);
2085
2085
  if (_s([i, o]))
2086
- return Rt(t, "and", e, n, r, o);
2086
+ return Dt(t, "and", e, n, r, o);
2087
2087
  if (i === "$entityIdStartsWith")
2088
2088
  return [];
2089
2089
  const a = i.split(".");
2090
2090
  if (o != null && o.hasOwnProperty("$ne") && (o = { ...o, $not: o.$ne }, delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2091
- const c = Je(t, e, n, r, a, o), u = xt(
2091
+ const c = He(t, e, n, r, a, o), u = Rt(
2092
2092
  t,
2093
2093
  e,
2094
2094
  n,
@@ -2107,7 +2107,7 @@ function kn(t, e, n, r, s) {
2107
2107
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2108
2108
  {
2109
2109
  or: {
2110
- patterns: xt(
2110
+ patterns: Rt(
2111
2111
  t,
2112
2112
  e,
2113
2113
  n,
@@ -2117,12 +2117,12 @@ function kn(t, e, n, r, s) {
2117
2117
  joinSym: t(n, r)
2118
2118
  }
2119
2119
  }
2120
- ] : Je(t, e, n, r, a, o);
2120
+ ] : He(t, e, n, r, a, o);
2121
2121
  });
2122
2122
  }
2123
2123
  function Ts(t, e, n, r) {
2124
2124
  const s = Ie;
2125
- return r ? kn(s, t, e, n, r).concat($t(s, t, e, n)) : $t(s, t, e, n);
2125
+ return r ? kn(s, t, e, n, r).concat(jt(s, t, e, n)) : jt(s, t, e, n);
2126
2126
  }
2127
2127
  function ms(t, e, n) {
2128
2128
  return [t(e, n), t("time", n)];
@@ -2177,7 +2177,7 @@ function ce(t, e, n, r, s) {
2177
2177
  function Ee([t, e], [n, r], s) {
2178
2178
  return ce(t, e, n, r, s);
2179
2179
  }
2180
- function Ye(t) {
2180
+ function Je(t) {
2181
2181
  return t == null ? t : new Date(t).getTime();
2182
2182
  }
2183
2183
  function As(t, e, n, r) {
@@ -2185,7 +2185,7 @@ function As(t, e, n, r) {
2185
2185
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2186
2186
  if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
2187
2187
  return Ee(r, [s, a], null) === c;
2188
- const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? Ye(l) : l, h = f === "date" ? Ye(o) : o;
2188
+ const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? Je(l) : l, h = f === "date" ? Je(o) : o;
2189
2189
  return Ee([u, d], [s, h], f) === c;
2190
2190
  }
2191
2191
  function ks(t, e) {
@@ -2209,7 +2209,7 @@ function Ms(t, e, n) {
2209
2209
  const r = /* @__PURE__ */ new Map();
2210
2210
  for (const o of n.fields) {
2211
2211
  const a = G(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
2212
- c && yt(a) && r.set(c, a);
2212
+ c && pt(a) && r.set(c, a);
2213
2213
  }
2214
2214
  if (!r.has("id")) {
2215
2215
  const o = G(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
@@ -2227,7 +2227,7 @@ function Is(t, { etype: e, pageInfo: n, dq: r, form: s }) {
2227
2227
  c = c.map(([b]) => {
2228
2228
  var T, v, m, M, I;
2229
2229
  let g = (I = (M = (m = (v = (T = t.eav.get(b)) == null ? void 0 : T.get(y)) == null ? void 0 : v.values()) == null ? void 0 : m.next()) == null ? void 0 : M.value) == null ? void 0 : I[2];
2230
- return _ && (g = Ye(g)), [b, g];
2230
+ return _ && (g = Je(g)), [b, g];
2231
2231
  });
2232
2232
  }
2233
2233
  c.sort(
@@ -2327,7 +2327,7 @@ function Rs() {
2327
2327
  return new Set(Object.keys(e));
2328
2328
  }
2329
2329
  const xs = Rs();
2330
- function Ze(t, e, n) {
2330
+ function Ye(t, e, n) {
2331
2331
  const r = {
2332
2332
  __etype: t,
2333
2333
  __ops: n
@@ -2337,7 +2337,7 @@ function Ze(t, e, n) {
2337
2337
  if (i === "__ops") return n;
2338
2338
  if (i === "__etype") return t;
2339
2339
  if (xs.has(i))
2340
- return (o, a) => Ze(t, e, [
2340
+ return (o, a) => Ye(t, e, [
2341
2341
  ...n,
2342
2342
  a ? [i, t, e, o, a] : [i, t, e, o]
2343
2343
  ]);
@@ -2363,7 +2363,7 @@ function Us(t) {
2363
2363
  get(e, n) {
2364
2364
  if (n === "__etype") return t;
2365
2365
  const r = n;
2366
- return Ce(r) ? Ze(t, In(r), []) : Ze(t, r, []);
2366
+ return Ce(r) ? Ye(t, In(r), []) : Ye(t, r, []);
2367
2367
  }
2368
2368
  }
2369
2369
  );
@@ -2425,30 +2425,30 @@ function Ns(t) {
2425
2425
  );
2426
2426
  return e[0];
2427
2427
  }
2428
- function Xe(t, e, n) {
2428
+ function Ze(t, e, n) {
2429
2429
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2430
2430
  // before assuming it's a ref lookup.
2431
2431
  !C(t, e, n);
2432
2432
  }
2433
- function et(t) {
2433
+ function Xe(t) {
2434
2434
  const [e, n, ...r] = t.split(".");
2435
2435
  if (r.length > 0 || n !== "id")
2436
2436
  throw new Error(`${t} is not a valid lookup attribute.`);
2437
2437
  return e;
2438
2438
  }
2439
2439
  function Ks(t, e, n) {
2440
- if (!Xe(t, e, n))
2440
+ if (!Ze(t, e, n))
2441
2441
  return C(t, e, n);
2442
- const r = et(n), s = C(t, e, r) || J(t, e, r);
2442
+ const r = Xe(n), s = C(t, e, r) || J(t, e, r);
2443
2443
  if (s && s["value-type"] !== "ref")
2444
2444
  throw new Error(`${n} does not reference a valid link attribute.`);
2445
2445
  return s;
2446
2446
  }
2447
- function tt(t) {
2447
+ function et(t) {
2448
2448
  return typeof t == "string" && !Ce(t) ? null : typeof t == "string" && Ce(t) ? In(t) : Ns(t);
2449
2449
  }
2450
2450
  function x(t, e, n) {
2451
- const r = tt(n);
2451
+ const r = et(n);
2452
2452
  if (r === null)
2453
2453
  return n;
2454
2454
  const [s, i] = r, o = Ks(t, e, s);
@@ -2525,14 +2525,14 @@ function $n({ stores: t, attrs: e }, [n, r, s, i]) {
2525
2525
  return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Vs(t, n, r) ? { mode: "update" } : null;
2526
2526
  }
2527
2527
  function Ws(t, e) {
2528
- const { attrs: n } = t, [r, s, i, o] = e, a = ht(i), c = x(n, r, s);
2528
+ const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s);
2529
2529
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
2530
2530
  const d = C(n, r, l);
2531
2531
  return d["checked-data-type"] === "date" && t.useDateObjects && (f = Me(f)), ["add-triple", c, d.id, f, { mode: "create" }];
2532
2532
  });
2533
2533
  }
2534
2534
  function Qs(t, e) {
2535
- const { attrs: n } = t, [r, s, i, o] = e, a = ht(i), c = x(n, r, s), u = $n(t, [r, c, i, o]);
2535
+ const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s), u = $n(t, [r, c, i, o]);
2536
2536
  return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
2537
2537
  const h = C(n, r, f);
2538
2538
  return h["checked-data-type"] === "date" && t.useDateObjects && (d = Me(d)), [
@@ -2548,7 +2548,7 @@ function Gs({ attrs: t }, [e, n]) {
2548
2548
  return [["delete-entity", x(t, e, n), e]];
2549
2549
  }
2550
2550
  function Bs(t, e) {
2551
- const { attrs: n } = t, [r, s, i, o] = e, a = ht(i), c = x(n, r, s), u = $n(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
2551
+ const { attrs: n } = t, [r, s, i, o] = e, a = dt(i), c = x(n, r, s), u = $n(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
2552
2552
  const p = C(n, r, d);
2553
2553
  return [
2554
2554
  "deep-merge-triple",
@@ -2652,7 +2652,7 @@ function ti(t, e, n) {
2652
2652
  "on-delete-reverse": i.onDelete
2653
2653
  };
2654
2654
  }
2655
- function Ut(t, e, n, r) {
2655
+ function xt(t, e, n, r) {
2656
2656
  const s = t ? ti(t, e, n) : null, i = k(), o = [k(), e, n], a = [k(), n, e];
2657
2657
  return {
2658
2658
  id: i,
@@ -2675,17 +2675,17 @@ const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2675
2675
  "merge",
2676
2676
  "delete",
2677
2677
  "ruleParams"
2678
- ]), nt = { "unique?": !0, "index?": !0 }, oi = { ...nt, cardinality: "one" };
2678
+ ]), tt = { "unique?": !0, "index?": !0 }, oi = { ...tt, cardinality: "one" };
2679
2679
  function ai(t) {
2680
2680
  const e = [], [n, r, s, i] = t;
2681
2681
  if (!ii.has(n))
2682
2682
  return e;
2683
- const o = tt(s);
2683
+ const o = et(s);
2684
2684
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2685
2685
  for (const [a, c] of Object.entries(i)) {
2686
2686
  const u = Array.isArray(c) ? c : [c];
2687
2687
  for (const l of u) {
2688
- const f = tt(l);
2688
+ const f = et(l);
2689
2689
  f && e.push({
2690
2690
  etype: r,
2691
2691
  lookupPair: f,
@@ -2706,7 +2706,7 @@ function ci({ attrs: t, schema: e }, n) {
2706
2706
  }
2707
2707
  function c(f, d) {
2708
2708
  const h = C(s, f, d), p = J(s, f, d);
2709
- a(h), a(p), !h && !p && o(Ut(e, f, d, oi));
2709
+ a(h), a(p), !h && !p && o(xt(e, f, d, oi));
2710
2710
  }
2711
2711
  for (const f of n)
2712
2712
  for (const { etype: d, lookupPair: h, linkLabel: p } of ai(f)) {
@@ -2716,19 +2716,19 @@ function ci({ attrs: t, schema: e }, n) {
2716
2716
  const y = C(s, d, p), b = J(s, d, p);
2717
2717
  a(y), a(b);
2718
2718
  const g = ((u = y == null ? void 0 : y["reverse-identity"]) == null ? void 0 : u[1]) || ((l = b == null ? void 0 : b["forward-identity"]) == null ? void 0 : l[1]) || p;
2719
- if (Xe(s, g, _))
2720
- c(g, et(_));
2719
+ if (Ze(s, g, _))
2720
+ c(g, Xe(_));
2721
2721
  else {
2722
2722
  const T = C(s, g, _);
2723
2723
  T || o(
2724
- _e(e, g, _, nt)
2724
+ _e(e, g, _, tt)
2725
2725
  ), a(T);
2726
2726
  }
2727
- } else if (Xe(s, d, _))
2728
- c(d, et(_));
2727
+ } else if (Ze(s, d, _))
2728
+ c(d, Xe(_));
2729
2729
  else {
2730
2730
  const y = C(s, d, _);
2731
- y || o(_e(e, d, _, nt)), a(y);
2731
+ y || o(_e(e, d, _, tt)), a(y);
2732
2732
  }
2733
2733
  }
2734
2734
  for (const f of n) {
@@ -2747,7 +2747,7 @@ function ci({ attrs: t, schema: e }, n) {
2747
2747
  )
2748
2748
  )), ri.has(d)) {
2749
2749
  const T = J(s, h, b);
2750
- !g && !T && o(Ut(e, h, b)), a(T);
2750
+ !g && !T && o(xt(e, h, b)), a(T);
2751
2751
  }
2752
2752
  }
2753
2753
  }
@@ -2758,7 +2758,7 @@ function ui(t, e) {
2758
2758
  const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ls(c)), [s, i] = ci(t, r), o = { ...t, attrs: s }, a = r.flatMap((c) => Ys(o, c));
2759
2759
  return [...i, ...a];
2760
2760
  }
2761
- function Lt(t, e) {
2761
+ function Ut(t, e) {
2762
2762
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2763
2763
  }
2764
2764
  const fe = "__meta";
@@ -2766,7 +2766,7 @@ class li {
2766
2766
  constructor(e, n) {
2767
2767
  }
2768
2768
  }
2769
- class rt {
2769
+ class nt {
2770
2770
  constructor(e) {
2771
2771
  this._subs = [], this._nextSave = null, this._nextGc = null, this._pendingSaveKeys = /* @__PURE__ */ new Set(), this._loadedKeys = /* @__PURE__ */ new Set(), this._version = 0, this._meta = {
2772
2772
  isLoading: !0,
@@ -2948,7 +2948,7 @@ class rt {
2948
2948
  gc() {
2949
2949
  this._nextGc || (this._nextGc = setTimeout(
2950
2950
  () => {
2951
- Lt(() => {
2951
+ Ut(() => {
2952
2952
  this._nextGc = null, this._gc();
2953
2953
  }, 30 * 1e3);
2954
2954
  },
@@ -2963,7 +2963,7 @@ class rt {
2963
2963
  return;
2964
2964
  }
2965
2965
  this._nextSave = setTimeout(() => {
2966
- Lt(() => {
2966
+ Ut(() => {
2967
2967
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
2968
2968
  }, this._idleCallbackMaxWaitMs);
2969
2969
  }, this._saveThrottleMs);
@@ -3052,7 +3052,7 @@ async function yi(t, e, n) {
3052
3052
  };
3053
3053
  });
3054
3054
  }
3055
- async function Ft(t, e, n) {
3055
+ async function Lt(t, e, n) {
3056
3056
  const r = n.put(e, t);
3057
3057
  return new Promise((s, i) => {
3058
3058
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
@@ -3087,7 +3087,7 @@ async function bi(t, e) {
3087
3087
  break;
3088
3088
  }
3089
3089
  default: {
3090
- const d = Ft(l, f, i);
3090
+ const d = Lt(l, f, i);
3091
3091
  a.push(d);
3092
3092
  const h = {
3093
3093
  createdAt: Date.now(),
@@ -3098,12 +3098,12 @@ async function bi(t, e) {
3098
3098
  break;
3099
3099
  }
3100
3100
  }
3101
- const u = Ft(fe, c, i);
3101
+ const u = Lt(fe, c, i);
3102
3102
  a.push(u), await Promise.all(a), await new Promise((l, f) => {
3103
3103
  s.oncomplete = (d) => l(d), s.onerror = (d) => f(d), s.onabort = (d) => f(d);
3104
3104
  });
3105
3105
  }
3106
- const Nt = /* @__PURE__ */ new Map();
3106
+ const Ft = /* @__PURE__ */ new Map();
3107
3107
  class Dn extends li {
3108
3108
  constructor(e, n) {
3109
3109
  super(e, n), this.dbName = `instant_${e}_${fi}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
@@ -3120,9 +3120,9 @@ class Dn extends li {
3120
3120
  const c = bi(this._appId, a).catch((u) => {
3121
3121
  hi("Error upgrading store from version 5 to 6.")(u);
3122
3122
  });
3123
- Nt.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
3123
+ Ft.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
3124
3124
  } else {
3125
- const c = Nt.get(this.dbName);
3125
+ const c = Ft.get(this.dbName);
3126
3126
  c ? c.then(() => e(a)).catch(() => e(a)) : e(a);
3127
3127
  }
3128
3128
  }, s.onupgradeneeded = (i) => {
@@ -3293,7 +3293,7 @@ async function Ti({
3293
3293
  })
3294
3294
  });
3295
3295
  }
3296
- async function Kt({
3296
+ async function Nt({
3297
3297
  apiURI: t,
3298
3298
  appId: e,
3299
3299
  code: n,
@@ -3435,9 +3435,9 @@ async function Ei({
3435
3435
  );
3436
3436
  return s;
3437
3437
  }
3438
- let gt = !1, xn = !1, Un = !1;
3439
- typeof window < "u" && typeof window.localStorage < "u" && (gt = !!window.localStorage.getItem("devBackend"), xn = !!window.localStorage.getItem("__instantLogging"), Un = !!window.localStorage.getItem("__devtoolLocalDash"));
3440
- function qt(t, e) {
3438
+ let _t = !1, xn = !1, Un = !1;
3439
+ typeof window < "u" && typeof window.localStorage < "u" && (_t = !!window.localStorage.getItem("devBackend"), xn = !!window.localStorage.getItem("__instantLogging"), Un = !!window.localStorage.getItem("__devtoolLocalDash"));
3440
+ function Kt(t, e) {
3441
3441
  if (!e) return t;
3442
3442
  const n = {};
3443
3443
  return e.forEach((r) => {
@@ -3449,25 +3449,25 @@ function Ci(t, e, n) {
3449
3449
  peers: {}
3450
3450
  };
3451
3451
  if (e && "user" in e ? e.user : !0) {
3452
- const i = qt(t.user ?? {}, e == null ? void 0 : e.keys);
3452
+ const i = Kt(t.user ?? {}, e == null ? void 0 : e.keys);
3453
3453
  r.user = { ...i, peerId: n };
3454
3454
  }
3455
3455
  for (const i of Object.keys(t.peers ?? {})) {
3456
3456
  const o = (e == null ? void 0 : e.peers) === void 0, a = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(i));
3457
3457
  if (o || a) {
3458
- const c = qt(t.peers[i], e == null ? void 0 : e.keys);
3458
+ const c = Kt(t.peers[i], e == null ? void 0 : e.keys);
3459
3459
  r.peers[i] = { ...c, peerId: i };
3460
3460
  }
3461
3461
  }
3462
3462
  return r;
3463
3463
  }
3464
3464
  function Mi(t, e) {
3465
- if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Et(t.user, e.user)) || !ln(t.peers, e.peers)) return !0;
3465
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !kt(t.user, e.user)) || !ln(t.peers, e.peers)) return !0;
3466
3466
  for (const r of Object.keys(t.peers))
3467
- if (!Et(t.peers[r], e.peers[r])) return !0;
3467
+ if (!kt(t.peers[r], e.peers[r])) return !0;
3468
3468
  return !1;
3469
3469
  }
3470
- class zt {
3470
+ class qt {
3471
3471
  constructor() {
3472
3472
  w(this, "promise");
3473
3473
  w(this, "_resolve");
@@ -3492,11 +3492,11 @@ function Ln(t, e = []) {
3492
3492
  Ln(n["child-nodes"], e);
3493
3493
  });
3494
3494
  }
3495
- function Vt(t) {
3495
+ function zt(t) {
3496
3496
  const e = [];
3497
3497
  return Ln(t, e), e;
3498
3498
  }
3499
- function Wt(t) {
3499
+ function Vt(t) {
3500
3500
  return Object.values(t.links).reduce((e, n) => {
3501
3501
  var r, s;
3502
3502
  return e[r = n.forward.on] ?? (e[r] = {}), e[n.forward.on][n.forward.label] = {
@@ -3510,7 +3510,7 @@ function Wt(t) {
3510
3510
  }, e;
3511
3511
  }, {});
3512
3512
  }
3513
- const Fn = "v0.22.69";
3513
+ const Fn = "v0.22.70";
3514
3514
  function Ii(t, e) {
3515
3515
  return {
3516
3516
  info: t ? (...n) => console.info(...n, e()) : () => {
@@ -3620,7 +3620,7 @@ class O extends Error {
3620
3620
  super(r), this.name = "QueryValidationError";
3621
3621
  }
3622
3622
  }
3623
- const Qt = [
3623
+ const Wt = [
3624
3624
  "where",
3625
3625
  "order",
3626
3626
  "limit",
@@ -3849,9 +3849,9 @@ const Qt = [
3849
3849
  }
3850
3850
  }, Di = (t, e, n, r, s = 0) => {
3851
3851
  for (const o of Object.keys(t))
3852
- if (!Qt.includes(o))
3852
+ if (!Wt.includes(o))
3853
3853
  throw new O(
3854
- `Invalid query parameter '${o}' in $ object. Valid parameters are: ${Qt.join(", ")}. Found: ${o}`,
3854
+ `Invalid query parameter '${o}' in $ object. Valid parameters are: ${Wt.join(", ")}. Found: ${o}`,
3855
3855
  r
3856
3856
  );
3857
3857
  const i = [
@@ -3923,7 +3923,7 @@ const Qt = [
3923
3923
  s
3924
3924
  );
3925
3925
  }
3926
- }, Gt = (t, e) => {
3926
+ }, Qt = (t, e) => {
3927
3927
  if (typeof t != "object" || t === null)
3928
3928
  throw new O(
3929
3929
  `Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`
@@ -3962,7 +3962,7 @@ const Qt = [
3962
3962
  );
3963
3963
  }
3964
3964
  }
3965
- }, Bt = (t) => typeof t != "string" ? !1 : Ce(t) ? !0 : te(t);
3965
+ }, Gt = (t) => typeof t != "string" ? !1 : Ce(t) ? !0 : te(t);
3966
3966
  class F extends Error {
3967
3967
  constructor(e) {
3968
3968
  super(e), this.name = "TransactionValidationError";
@@ -3998,7 +3998,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
3998
3998
  `Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
3999
3999
  );
4000
4000
  }
4001
- }, Ht = (t, e, n) => {
4001
+ }, Bt = (t, e, n) => {
4002
4002
  const r = Vn(t, n);
4003
4003
  if (typeof e != "object" || e === null)
4004
4004
  throw new F(
@@ -4014,11 +4014,11 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
4014
4014
  if (i != null) {
4015
4015
  if (Array.isArray(i)) {
4016
4016
  for (const a of i)
4017
- if (!Bt(a))
4017
+ if (!Gt(a))
4018
4018
  throw new F(
4019
4019
  `Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`
4020
4020
  );
4021
- } else if (!Bt(i))
4021
+ } else if (!Gt(i))
4022
4022
  throw new F(
4023
4023
  `Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`
4024
4024
  );
@@ -4028,8 +4028,8 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
4028
4028
  create: Le,
4029
4029
  update: Le,
4030
4030
  merge: Le,
4031
- link: Ht,
4032
- unlink: Ht,
4031
+ link: Bt,
4032
+ unlink: Bt,
4033
4033
  delete: () => {
4034
4034
  }
4035
4035
  }, Li = (t, e) => {
@@ -4066,7 +4066,7 @@ const zn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new F(
4066
4066
  }
4067
4067
  };
4068
4068
  let Wn = 0;
4069
- class Jt {
4069
+ class Ht {
4070
4070
  constructor(e) {
4071
4071
  this.type = "ws", this.id = `${this.type}_${Wn++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
4072
4072
  this.onopen && this.onopen({ target: this });
@@ -4096,7 +4096,7 @@ class Jt {
4096
4096
  }
4097
4097
  class Ni {
4098
4098
  constructor(e, n) {
4099
- this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${Wn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4099
+ this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Wn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4100
4100
  this.initParams || this.handleError();
4101
4101
  }, 1e4), this.conn.onmessage = (r) => {
4102
4102
  const s = JSON.parse(r.data);
@@ -4128,14 +4128,15 @@ class Ni {
4128
4128
  this.conn.close(), this.onclose && !this.closeFired && (this.closeFired = !0, this.onclose({ target: this }));
4129
4129
  }
4130
4130
  async postMessages(e) {
4131
+ var n, r, s;
4131
4132
  try {
4132
4133
  (await fetch(this.url, {
4133
4134
  method: "POST",
4134
4135
  headers: { "Content-Type": "application/json" },
4135
4136
  body: JSON.stringify({
4136
- machine_id: this.initParams.machineId,
4137
- session_id: this.initParams.sessionId,
4138
- sse_token: this.initParams.sseToken,
4137
+ machine_id: (n = this.initParams) == null ? void 0 : n.machineId,
4138
+ session_id: (r = this.initParams) == null ? void 0 : r.sessionId,
4139
+ sse_token: (s = this.initParams) == null ? void 0 : s.sseToken,
4139
4140
  messages: e
4140
4141
  })
4141
4142
  })).ok || this.handleError();
@@ -4196,7 +4197,7 @@ function zi(t, e, n) {
4196
4197
  function Fe(t, e) {
4197
4198
  return Mn({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4198
4199
  }
4199
- function Yt(t, e, n) {
4200
+ function Jt(t, e, n) {
4200
4201
  var i;
4201
4202
  const r = (i = G(e, t.table, "id")) == null ? void 0 : i.id;
4202
4203
  if (!r)
@@ -4204,7 +4205,7 @@ function Yt(t, e, n) {
4204
4205
  const s = se(e.eav, [n, r, n]);
4205
4206
  return s ? s[3] : -1;
4206
4207
  }
4207
- function Zt(t, e) {
4208
+ function Yt(t, e) {
4208
4209
  for (const { action: n, triple: r } of e)
4209
4210
  switch (n) {
4210
4211
  case "added":
@@ -4297,7 +4298,7 @@ function Qi(t, e, n) {
4297
4298
  var Gi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Gi || {});
4298
4299
  class Bi {
4299
4300
  constructor(e, n, r, s, i) {
4300
- this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.subs = new rt({
4301
+ this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.subs = new nt({
4301
4302
  persister: n,
4302
4303
  merge: zi,
4303
4304
  serialize: qi,
@@ -4438,7 +4439,7 @@ class Bi {
4438
4439
  c.push({
4439
4440
  store: l,
4440
4441
  entity: f,
4441
- serverCreatedAt: Yt(o, l, f.id)
4442
+ serverCreatedAt: Jt(o, l, f.id)
4442
4443
  }), i.push(f);
4443
4444
  }
4444
4445
  this.subs.updateInPlace((u) => {
@@ -4509,7 +4510,7 @@ class Bi {
4509
4510
  for (let g = 0; g < f.length; g++) {
4510
4511
  const T = f[g];
4511
4512
  if (Cr(T.store, y)) {
4512
- Zt(T.store, b);
4513
+ Yt(T.store, b);
4513
4514
  const v = Fe(s, T.store), m = Vi(T.store, b)[y];
4514
4515
  v ? (d.push({
4515
4516
  oldEntity: T.entity,
@@ -4522,7 +4523,7 @@ class Bi {
4522
4523
  const h = [];
4523
4524
  for (const [y, b] of Object.entries(u)) {
4524
4525
  const g = this.createStore([]);
4525
- l.attrs = g.attrs, Zt(g, b);
4526
+ l.attrs = g.attrs, Yt(g, b);
4526
4527
  const T = Fe(s, g);
4527
4528
  if (!T) {
4528
4529
  this.log.error("No entity found after applying change", {
@@ -4535,7 +4536,7 @@ class Bi {
4535
4536
  f.push({
4536
4537
  store: g,
4537
4538
  entity: T,
4538
- serverCreatedAt: Yt(s, g, T.id)
4539
+ serverCreatedAt: Jt(s, g, T.id)
4539
4540
  }), h.push(T);
4540
4541
  }
4541
4542
  const p = [];
@@ -4601,10 +4602,10 @@ function Xi({
4601
4602
  EventSourceImpl: s
4602
4603
  }) {
4603
4604
  if (!s)
4604
- return new Jt(`${r}?app_id=${e}`);
4605
+ return new Ht(`${r}?app_id=${e}`);
4605
4606
  switch (t) {
4606
4607
  case "ws":
4607
- return new Jt(`${r}?app_id=${e}`);
4608
+ return new Ht(`${r}?app_id=${e}`);
4608
4609
  case "sse":
4609
4610
  return new Ni(
4610
4611
  s,
@@ -4617,7 +4618,7 @@ function Xi({
4617
4618
  function eo() {
4618
4619
  return typeof window < "u" || typeof chrome < "u";
4619
4620
  }
4620
- const Xt = {
4621
+ const Zt = {
4621
4622
  "set-presence": !0,
4622
4623
  "set-presence-ok": !0,
4623
4624
  "refresh-presence": !0,
@@ -4663,7 +4664,7 @@ function io(t, e, n) {
4663
4664
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4664
4665
  return r && !s && n && (n.result = r), n || e;
4665
4666
  }
4666
- function en(t) {
4667
+ function Xt(t) {
4667
4668
  return [...t].sort((e, n) => {
4668
4669
  const [r, s] = e, [i, o] = n, a = s.order || 0, c = o.order || 0;
4669
4670
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
@@ -4798,7 +4799,7 @@ class oo {
4798
4799
  this._updatePendingMutations((c) => {
4799
4800
  c.set(r, o);
4800
4801
  });
4801
- const a = new zt();
4802
+ const a = new qt();
4802
4803
  return this.mutationDeferredStore.set(r, a), this._sendMutation(r, o), this.notifyAll(), a.promise;
4803
4804
  });
4804
4805
  w(this, "_transportOnOpen", (e) => {
@@ -4899,9 +4900,9 @@ class oo {
4899
4900
  ), this._scheduleReconnect();
4900
4901
  });
4901
4902
  if (this._EventSource = i, this.config = { ...Zi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ji, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Yi, this._log = Ii(
4902
- e.verbose || gt || xn,
4903
+ e.verbose || _t || xn,
4903
4904
  () => this._reactorStats()
4904
- ), this.versions = { ...s || {}, "@instantdb/core": Fn }, this.config.schema && (this._linkIndex = Wt(this.config.schema)), !!eo()) {
4905
+ ), this.versions = { ...s || {}, "@instantdb/core": Fn }, this.config.schema && (this._linkIndex = Vt(this.config.schema)), !!eo()) {
4905
4906
  if (!e.appId)
4906
4907
  throw new Error("Instant must be initialized with an appId.");
4907
4908
  if (!te(e.appId))
@@ -4949,7 +4950,7 @@ class oo {
4949
4950
  ...this.config,
4950
4951
  schema: e,
4951
4952
  cardinalityInference: !!e
4952
- }, this._linkIndex = e ? Wt(this.config.schema) : null;
4953
+ }, this._linkIndex = e ? Vt(this.config.schema) : null;
4953
4954
  }
4954
4955
  _reactorStats() {
4955
4956
  return {
@@ -4962,7 +4963,7 @@ class oo {
4962
4963
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
4963
4964
  }
4964
4965
  _initStorage(e) {
4965
- this.querySubs = new rt({
4966
+ this.querySubs = new nt({
4966
4967
  persister: new e(this.config.appId, "querySubs"),
4967
4968
  merge: io,
4968
4969
  serialize: no,
@@ -4982,7 +4983,7 @@ class oo {
4982
4983
  maxSize: 1e6
4983
4984
  // 1 million triples
4984
4985
  }
4985
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new rt({
4986
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new nt({
4986
4987
  persister: new e(this.config.appId, "kv"),
4987
4988
  merge: this._onMergeKv,
4988
4989
  serialize: so,
@@ -5048,7 +5049,7 @@ class oo {
5048
5049
  _handleReceive(e, n) {
5049
5050
  var s, i, o, a, c, u;
5050
5051
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5051
- switch (Xt[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5052
+ switch (Zt[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5052
5053
  case "init-ok": {
5053
5054
  this._setStatus(V.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
5054
5055
  for (const d of Object.keys(this._rooms)) {
@@ -5065,7 +5066,7 @@ class oo {
5065
5066
  const { q: d, result: h } = n, p = P(d);
5066
5067
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[p])
5067
5068
  break;
5068
- const _ = (a = (o = h == null ? void 0 : h[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], y = (u = (c = h == null ? void 0 : h[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, b = Vt(h), g = Oe(
5069
+ const _ = (a = (o = h == null ? void 0 : h[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], y = (u = (c = h == null ? void 0 : h[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, b = zt(h), g = Oe(
5069
5070
  this.attrs,
5070
5071
  b,
5071
5072
  r,
@@ -5113,9 +5114,9 @@ class oo {
5113
5114
  _ !== this._pendingMutations() && this.kv.updateInPlace((g) => {
5114
5115
  g.pendingMutations = _;
5115
5116
  });
5116
- const y = en(_.entries()), b = d.map((g) => {
5117
- var wt, Tt, mt, St;
5118
- const T = g["instaql-query"], v = g["instaql-result"], m = P(T), M = Vt(v), I = Oe(
5117
+ const y = Xt(_.entries()), b = d.map((g) => {
5118
+ var gt, wt, Tt, mt;
5119
+ const T = g["instaql-query"], v = g["instaql-result"], m = P(T), M = zt(v), I = Oe(
5119
5120
  this.attrs,
5120
5121
  M,
5121
5122
  r,
@@ -5125,7 +5126,7 @@ class oo {
5125
5126
  I,
5126
5127
  y,
5127
5128
  p
5128
- ), De = (Tt = (wt = v == null ? void 0 : v[0]) == null ? void 0 : wt.data) == null ? void 0 : Tt["page-info"], Gn = (St = (mt = v == null ? void 0 : v[0]) == null ? void 0 : mt.data) == null ? void 0 : St.aggregate;
5129
+ ), De = (wt = (gt = v == null ? void 0 : v[0]) == null ? void 0 : gt.data) == null ? void 0 : wt["page-info"], Gn = (mt = (Tt = v == null ? void 0 : v[0]) == null ? void 0 : Tt.data) == null ? void 0 : mt.aggregate;
5129
5130
  return { q: T, hash: m, store: B, pageInfo: De, aggregate: Gn };
5130
5131
  });
5131
5132
  b.forEach(({ hash: g, q: T, store: v, pageInfo: m, aggregate: M }) => {
@@ -5295,15 +5296,15 @@ class oo {
5295
5296
  * Returns an unsubscribe function
5296
5297
  */
5297
5298
  subscribeQuery(e, n, r) {
5298
- this.config.disableValidation || Gt(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5299
+ this.config.disableValidation || Qt(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5299
5300
  const s = P(e), i = this.getPreviousResult(e);
5300
5301
  return i && n(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5301
5302
  this._unsubQuery(e, s, n);
5302
5303
  };
5303
5304
  }
5304
5305
  queryOnce(e, n) {
5305
- this.config.disableValidation || Gt(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5306
- const r = new zt();
5306
+ this.config.disableValidation || Qt(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5307
+ const r = new qt();
5307
5308
  if (!this._isOnline)
5308
5309
  return r.reject(
5309
5310
  new Error("We can't run `queryOnce`, because the device is offline.")
@@ -5392,7 +5393,7 @@ class oo {
5392
5393
  return a ? u : n;
5393
5394
  }
5394
5395
  _rewriteMutationsSorted(e, n) {
5395
- return en(this._rewriteMutations(e, n).entries());
5396
+ return Xt(this._rewriteMutations(e, n).entries());
5396
5397
  }
5397
5398
  // ---------------------------
5398
5399
  // Transact
@@ -5537,7 +5538,7 @@ class oo {
5537
5538
  }
5538
5539
  _trySend(e, n, r) {
5539
5540
  if (this._transport.isOpen()) {
5540
- switch (Xt[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5541
+ switch (Zt[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5541
5542
  case "transact": {
5542
5543
  this._inFlightMutationEventIds.add(e);
5543
5544
  break;
@@ -5641,7 +5642,7 @@ class oo {
5641
5642
  return null;
5642
5643
  this._replaceUrlAfterOAuth();
5643
5644
  try {
5644
- const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Kt({
5645
+ const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Nt({
5645
5646
  apiURI: this.config.apiURI,
5646
5647
  appId: this.config.appId,
5647
5648
  code: r,
@@ -5833,7 +5834,7 @@ class oo {
5833
5834
  */
5834
5835
  async exchangeCodeForToken({ code: e, codeVerifier: n }) {
5835
5836
  var o;
5836
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Kt({
5837
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Nt({
5837
5838
  apiURI: this.config.apiURI,
5838
5839
  appId: this.config.appId,
5839
5840
  code: e,
@@ -5967,7 +5968,7 @@ class oo {
5967
5968
  ur(u, l, d);
5968
5969
  break;
5969
5970
  case "r":
5970
- Ct(u, l, d);
5971
+ Et(u, l, d);
5971
5972
  break;
5972
5973
  case "-":
5973
5974
  dn(u, l);
@@ -5984,7 +5985,7 @@ class oo {
5984
5985
  Object.entries(r).map(([i, o]) => [i, o.data])
5985
5986
  );
5986
5987
  this._presence = ke(this._presence, (i) => {
5987
- Ct(i, [e, "result", "peers"], s);
5988
+ Et(i, [e, "result", "peers"], s);
5988
5989
  });
5989
5990
  }
5990
5991
  // --------
@@ -6179,7 +6180,7 @@ function _o(t, e) {
6179
6180
  return u();
6180
6181
  }
6181
6182
  function go(t) {
6182
- return `${gt || Un ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6183
+ return `${_t || Un ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6183
6184
  }
6184
6185
  function wo(t) {
6185
6186
  const e = document.createElement("iframe");
@@ -6266,11 +6267,11 @@ function Ao() {
6266
6267
  function ko() {
6267
6268
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6268
6269
  }
6269
- function st(t) {
6270
+ function rt(t) {
6270
6271
  const e = t.__adminToken;
6271
6272
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6272
6273
  }
6273
- const it = ko(), Ke = Ao();
6274
+ const st = ko(), en = Ao();
6274
6275
  class Eo {
6275
6276
  constructor(e) {
6276
6277
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
@@ -6427,7 +6428,7 @@ class Mo {
6427
6428
  };
6428
6429
  }
6429
6430
  shutdown() {
6430
- delete it[st(this._reactor.config)], this._reactor.shutdown();
6431
+ delete st[rt(this._reactor.config)], this._reactor.shutdown();
6431
6432
  }
6432
6433
  /**
6433
6434
  * Use this for one-off queries.
@@ -6463,16 +6464,17 @@ class Mo {
6463
6464
  function tn(t) {
6464
6465
  if (!t)
6465
6466
  return "0";
6466
- if (Ke.get(t))
6467
- return Ke.get(t);
6468
- const e = P(t);
6469
- return Ke.set(t, e), e;
6467
+ const e = en.get(t);
6468
+ if (e)
6469
+ return e;
6470
+ const n = P(t);
6471
+ return en.set(t, n), n;
6470
6472
  }
6471
6473
  function Io(t, e) {
6472
6474
  return tn(t._reactor.config.schema) !== tn(e);
6473
6475
  }
6474
6476
  function Po(t, e, n, r, s) {
6475
- const i = it[st(t)];
6477
+ const i = st[rt(t)];
6476
6478
  if (i)
6477
6479
  return Io(i, t.schema) && i._reactor.updateSchema(t.schema), i;
6478
6480
  const o = new oo(
@@ -6488,7 +6490,7 @@ function Po(t, e, n, r, s) {
6488
6490
  ), a = new Mo(
6489
6491
  o
6490
6492
  );
6491
- return it[st(t)] = a, jo(t.appId, t.devtool), a;
6493
+ return st[rt(t)] = a, jo(t.appId, t.devtool), a;
6492
6494
  }
6493
6495
  function jo(t, e) {
6494
6496
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
@@ -6523,7 +6525,7 @@ export {
6523
6525
  Do as lookup,
6524
6526
  Ro as tx,
6525
6527
  Pn as txInit,
6526
- Gt as validateQuery,
6528
+ Qt as validateQuery,
6527
6529
  Fi as validateTransactions,
6528
6530
  Fn as version,
6529
6531
  P as weakHash