@instantdb/core 0.22.104 → 0.22.105

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.
@@ -43,11 +43,11 @@ const I = {
43
43
  }, nn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Jn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Se = Symbol.iterator, F = {
44
44
  mutable: "mutable",
45
45
  immutable: "immutable"
46
- }, ot = {};
46
+ }, at = {};
47
47
  function le(t, e) {
48
48
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
49
49
  }
50
- function At(t, e) {
50
+ function Ot(t, e) {
51
51
  if (e in t) {
52
52
  let n = Reflect.getPrototypeOf(t);
53
53
  for (; n; ) {
@@ -58,10 +58,10 @@ function At(t, e) {
58
58
  }
59
59
  }
60
60
  }
61
- function at(t) {
61
+ function ct(t) {
62
62
  return Object.getPrototypeOf(t) === Set.prototype;
63
63
  }
64
- function ct(t) {
64
+ function ut(t) {
65
65
  return Object.getPrototypeOf(t) === Map.prototype;
66
66
  }
67
67
  function N(t) {
@@ -74,7 +74,7 @@ function Y(t) {
74
74
  function A(t) {
75
75
  return typeof t != "object" ? null : t == null ? void 0 : t[nn];
76
76
  }
77
- function ut(t) {
77
+ function lt(t) {
78
78
  var e;
79
79
  const n = A(t);
80
80
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -121,7 +121,7 @@ function xe(t, e) {
121
121
  function G(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 ze(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 (!ct(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 (!ut(t)) {
172
172
  const r = Object.getPrototypeOf(t).constructor;
173
173
  return new r(t);
174
174
  }
@@ -197,7 +197,7 @@ function $(t) {
197
197
  }
198
198
  function ae(t) {
199
199
  if (!z(t))
200
- return ut(t);
200
+ return lt(t);
201
201
  if (Array.isArray(t))
202
202
  return t.map(ae);
203
203
  if (t instanceof Map) {
@@ -205,7 +205,7 @@ function ae(t) {
205
205
  r,
206
206
  ae(s)
207
207
  ]);
208
- if (!ct(t)) {
208
+ if (!ut(t)) {
209
209
  const r = Object.getPrototypeOf(t).constructor;
210
210
  return new r(n);
211
211
  }
@@ -213,7 +213,7 @@ function ae(t) {
213
213
  }
214
214
  if (t instanceof Set) {
215
215
  const n = Array.from(t).map(ae);
216
- if (!at(t)) {
216
+ if (!ct(t)) {
217
217
  const r = Object.getPrototypeOf(t).constructor;
218
218
  return new r(n);
219
219
  }
@@ -231,7 +231,7 @@ function Q(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 && Q(t.parent));
233
233
  }
234
- function Ot() {
234
+ function vt() {
235
235
  throw new Error("Cannot modify frozen object");
236
236
  }
237
237
  function ee(t, e, n, r, s) {
@@ -259,12 +259,12 @@ function ee(t, e, n, r, s) {
259
259
  case 2:
260
260
  for (const [a, c] of t)
261
261
  ee(a, a, n, r, s), ee(c, a, n, r, s);
262
- t.set = t.clear = t.delete = Ot;
262
+ t.set = t.clear = t.delete = vt;
263
263
  break;
264
264
  case 3:
265
265
  for (const a of t)
266
266
  ee(a, a, n, r, s);
267
- t.add = t.clear = t.delete = Ot;
267
+ t.add = t.clear = t.delete = vt;
268
268
  break;
269
269
  case 1:
270
270
  Object.freeze(t);
@@ -280,7 +280,7 @@ function ee(t, e, n, r, s) {
280
280
  }
281
281
  r.pop(), s.pop();
282
282
  }
283
- function lt(t, e) {
283
+ function dt(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) || !z(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), dt(t, (i, o) => {
301
301
  var a;
302
302
  if (Y(o)) {
303
303
  const c = A(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(B(n, e), t.finalities.handledSet, t.options);
319
319
  }
320
- function ze(t) {
320
+ function Ve(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(lt(e));
323
323
  }));
324
324
  }
325
- function Ve(t, e, n, r) {
325
+ function Qe(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 dt(t, e, n, r) {
334
+ function ft(t, e, n, r) {
335
335
  const s = A(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 (G(B(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)), ye(c, e, u);
341
+ s.copy && (u = s.copy), Ve(t), Qe(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)), ye(c, e, u);
342
342
  }
343
343
  }), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), z(n, t.options) && t.finalities.draft.push(() => {
344
344
  const i = t.type === 3 ? t.setMap : t.copy;
@@ -447,7 +447,7 @@ function he(t, e, n, r) {
447
447
  const ve = (t, e, n = !1) => {
448
448
  if (typeof t == "object" && t !== null && (!z(t, e) || n))
449
449
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
450
- }, Qe = {
450
+ }, We = {
451
451
  get size() {
452
452
  return N(A(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 = A(this), r = N(n);
459
- return (!r.has(t) || !G(r.get(t), e)) && ($(n), Q(n), n.assignedMap.set(t, !0), n.copy.set(t, e), dt(n, t, e, he)), this;
459
+ return (!r.has(t) || !G(r.get(t), e)) && ($(n), Q(n), n.assignedMap.set(t, !0), n.copy.set(t, e), ft(n, t, e, he)), 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 = A(this), s = N(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, F)) === F.mutable;
485
485
  if (r.options.strict && ve(s, r.options, i), i || r.finalized || !z(s, r.options) || s !== r.original.get(t))
486
486
  return s;
487
- const o = ot.createDraft({
487
+ const o = at.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
  [Se]() {
529
529
  return this.entries();
530
530
  }
531
- }, sr = Reflect.ownKeys(Qe), vt = (t, e, { isValuesIterator: n }) => () => {
531
+ }, sr = Reflect.ownKeys(We), kt = (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 = A(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, F)) === F.mutable;
539
539
  if (t.options.strict && ve(o, t.options, u), !u && !c && z(o, t.options) && !t.finalized && t.original.has(o)) {
540
- const l = ot.createDraft({
540
+ const l = at.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 = A(this);
567
- return this.has(t) || ($(e), Q(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), dt(e, t, t, he)), this;
567
+ return this.has(t) || ($(e), Q(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), ft(e, t, t, he)), 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: vt(t, e, { isValuesIterator: !0 })
592
+ next: kt(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: vt(t, e, {
601
+ next: kt(t, e, {
602
602
  isValuesIterator: !1
603
603
  })
604
604
  };
@@ -656,8 +656,8 @@ const ir = Reflect.ownKeys(ke), an = /* @__PURE__ */ new WeakSet(), cn = {
656
656
  const a = N(t);
657
657
  if (a instanceof Map && sr.includes(e)) {
658
658
  if (e === "size")
659
- return Object.getOwnPropertyDescriptor(Qe, "size").get.call(t.proxy);
660
- const u = Qe[e];
659
+ return Object.getOwnPropertyDescriptor(We, "size").get.call(t.proxy);
660
+ const u = We[e];
661
661
  if (u)
662
662
  return u.bind(t.proxy);
663
663
  }
@@ -669,7 +669,7 @@ const ir = Reflect.ownKeys(ke), an = /* @__PURE__ */ new WeakSet(), cn = {
669
669
  return u.bind(t.proxy);
670
670
  }
671
671
  if (!le(a, e)) {
672
- const u = At(a, e);
672
+ const u = Ot(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(ke), an = /* @__PURE__ */ new WeakSet(), cn = {
679
679
  if (t.options.strict && ve(c, t.options), t.finalized || !z(c, t.options))
680
680
  return c;
681
681
  if (c === xe(t.original, e)) {
682
- if ($(t), t.copy[e] = ft({
682
+ if ($(t), t.copy[e] = ht({
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(ke), 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 = At(N(t), e);
703
+ const i = Ot(N(t), e);
704
704
  if (i != null && i.set)
705
705
  return i.set.call(t.proxy, n), !0;
706
706
  const o = xe(N(t), e), a = A(o);
707
- return a && G(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) : (G(n, o) && (n !== void 0 || le(t.original, e)) || ($(t), Q(t), le(t.original, e) && G(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, dt(t, e, n, he)), !0);
707
+ return a && G(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) : (G(n, o) && (n !== void 0 || le(t.original, e)) || ($(t), Q(t), le(t.original, e) && G(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, ft(t, e, n, he)), !0);
708
708
  },
709
709
  has(t, e) {
710
710
  return e in N(t);
@@ -735,7 +735,7 @@ const ir = Reflect.ownKeys(ke), an = /* @__PURE__ */ new WeakSet(), cn = {
735
735
  return t.type === 1 ? cn.set.call(this, t, e, void 0, t.proxy) : (xe(t.original, e) !== void 0 || e in t.original ? ($(t), Q(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 ft(t) {
738
+ function ht(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 ft(t) {
759
759
  const _ = B(w, r), b = A(_);
760
760
  if (b) {
761
761
  let T = b.original;
762
- b.operated && (T = ut(_)), ze(b), Ve(b, he, d, f), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, b.original)), ye(w, r, T);
762
+ b.operated && (T = lt(_)), Ve(b), Qe(b, he, d, f), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, b.original)), ye(w, r, T);
763
763
  }
764
764
  (y = g.callbacks) === null || y === void 0 || y.forEach((T) => {
765
765
  T(d, f);
@@ -768,12 +768,12 @@ function ft(t) {
768
768
  } else {
769
769
  const l = A(c);
770
770
  l.finalities.draft.push((d, f) => {
771
- ze(l), Ve(l, he, d, f);
771
+ Ve(l), Qe(l, he, d, f);
772
772
  });
773
773
  }
774
774
  return c;
775
775
  }
776
- ot.createDraft = ft;
776
+ at.createDraft = ht;
777
777
  function or(t, e, n, r, s) {
778
778
  var i;
779
779
  const o = A(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 && ee(u, u, o == null ? void 0 : o.options.updatedValues), [
784
+ return o && ze(o), s && ee(u, u, o == null ? void 0 : o.options.updatedValues), [
785
785
  u,
786
786
  n && c ? [{ op: I.Replace, path: [], value: e[0] }] : n,
787
787
  r && c ? [{ op: I.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, F)) === F.mutable || !z(t, e) ? t : ft({
799
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, F)) === F.mutable || !z(t, e) ? t : ht({
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 We(t) {
813
+ function Ge(t) {
814
814
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: s = !0 } = t;
815
- lt(n, (i, o, a) => {
815
+ dt(n, (i, o, a) => {
816
816
  const c = A(o);
817
817
  if (c && e && c.finalities === e.finalities) {
818
818
  t.isContainDraft = !0;
@@ -822,7 +822,7 @@ function We(t) {
822
822
  a.clear(), l.forEach((d) => a.add(i === d ? u : d));
823
823
  } else
824
824
  ye(a, i, u);
825
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, We(t));
825
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Ge(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 ? ut(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 (dt(s, (o, a) => {
850
850
  if (n && G(B(n.original, o), a))
851
851
  return;
852
852
  const c = un(a);
853
853
  c !== a && (s === t && i(), ye(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 ct(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
857
857
  }
858
858
  return s;
859
859
  }
860
- function kt(t) {
860
+ function Et(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 d = Y(c) ? kt(c) : c, f = Array.isArray(l.mark) ? (m, v) => {
876
+ const d = Y(c) ? Et(c) : c, f = Array.isArray(l.mark) ? (m, v) => {
877
877
  for (const O of l.mark) {
878
878
  if (typeof O != "function")
879
879
  throw new Error(`Invalid mark: ${O}, 'mark' should be a function.`);
@@ -899,7 +899,7 @@ const cr = (t) => function e(n, r, s) {
899
899
  try {
900
900
  T = u(_);
901
901
  } catch (m) {
902
- throw qe(A(_)), m;
902
+ throw ze(A(_)), m;
903
903
  }
904
904
  const S = (m) => {
905
905
  const v = A(_);
@@ -909,14 +909,14 @@ const cr = (t) => function e(n, r, s) {
909
909
  const L = m == null ? void 0 : m[Jn];
910
910
  if (L) {
911
911
  const Re = L[0];
912
- return w.strict && typeof m == "object" && m !== null && We({
912
+ return w.strict && typeof m == "object" && m !== null && Ge({
913
913
  rootDraft: v,
914
914
  value: m,
915
915
  useRawReturn: !0
916
916
  }), b([Re]);
917
917
  }
918
918
  if (m !== void 0)
919
- return typeof m == "object" && m !== null && We({ rootDraft: v, value: m }), b([m]);
919
+ return typeof m == "object" && m !== null && Ge({ rootDraft: v, value: m }), b([m]);
920
920
  }
921
921
  if (m === _ || m === void 0)
922
922
  return b([]);
@@ -924,12 +924,12 @@ const cr = (t) => function e(n, r, s) {
924
924
  if (w === O.options) {
925
925
  if (O.operated)
926
926
  throw new Error("Cannot return a modified child draft.");
927
- return b([kt(m)]);
927
+ return b([Et(m)]);
928
928
  }
929
929
  return b([m]);
930
930
  };
931
931
  return T instanceof Promise ? T.then(S, (m) => {
932
- throw qe(A(_)), m;
932
+ throw ze(A(_)), m;
933
933
  }) : S(T);
934
934
  }, Ee = 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 It(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 Oe(t, e) {
947
947
  (n) => Oe(t[n], e[n])
948
948
  ) : !1;
949
949
  }
950
- function ht(t) {
950
+ function pt(t) {
951
951
  if (!ce(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 It(t, e, n) {
987
+ function Mt(t, e, n) {
988
988
  if (!t || e.length === 0)
989
989
  return;
990
990
  let r = t || {};
@@ -1009,7 +1009,7 @@ function fn(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$/, dr = {
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$/, dr = {
1013
1013
  ZULU: 0,
1014
1014
  YEKT: 18e3,
1015
1015
  YEKST: 21600,
@@ -1283,10 +1283,10 @@ function Ar(t) {
1283
1283
  }
1284
1284
  }
1285
1285
  function Or(t) {
1286
- const e = t.match(Mt);
1286
+ const e = t.match(Ct);
1287
1287
  if (!e)
1288
1288
  return null;
1289
- const [n] = e, r = dr[n], s = new Date(t.replace(Mt, "Z"));
1289
+ const [n] = e, r = dr[n], s = new Date(t.replace(Ct, "Z"));
1290
1290
  return new Date(s.getTime() - r * 1e3);
1291
1291
  }
1292
1292
  const vr = [
@@ -1311,7 +1311,7 @@ function kr(t, e) {
1311
1311
  return null;
1312
1312
  }
1313
1313
  }
1314
- function Ge(t) {
1314
+ function Be(t) {
1315
1315
  for (const e of vr) {
1316
1316
  const n = kr(e, t);
1317
1317
  if (n)
@@ -1322,7 +1322,7 @@ function Ge(t) {
1322
1322
  function Er(t) {
1323
1323
  try {
1324
1324
  const e = JSON.parse(t);
1325
- return typeof e == "string" ? Ge(e) : null;
1325
+ return typeof e == "string" ? Be(e) : null;
1326
1326
  } catch {
1327
1327
  return null;
1328
1328
  }
@@ -1334,7 +1334,7 @@ function Ce(t) {
1334
1334
  if (t instanceof Date)
1335
1335
  return t;
1336
1336
  if (typeof t == "string") {
1337
- const e = Ge(t) || Er(t) || Ge(t.trim());
1337
+ const e = Be(t) || Er(t) || Be(t.trim());
1338
1338
  if (!e)
1339
1339
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1340
1340
  return e;
@@ -1376,7 +1376,7 @@ class H {
1376
1376
  return this._blobAttrs;
1377
1377
  this._blobAttrs = /* @__PURE__ */ new Map();
1378
1378
  for (const e of Object.values(this.attrs))
1379
- if (yt(e)) {
1379
+ if (bt(e)) {
1380
1380
  const [n, r, s] = e["forward-identity"];
1381
1381
  R(this.blobAttrs, [r, s], e);
1382
1382
  }
@@ -1423,10 +1423,10 @@ class H {
1423
1423
  function Ir(t) {
1424
1424
  return t.cardinality === "one";
1425
1425
  }
1426
- function pt(t) {
1426
+ function yt(t) {
1427
1427
  return t["value-type"] === "ref";
1428
1428
  }
1429
- function yt(t) {
1429
+ function bt(t) {
1430
1430
  return t["value-type"] === "blob";
1431
1431
  }
1432
1432
  function ie(t, e) {
@@ -1460,7 +1460,7 @@ function hn(t, e, n) {
1460
1460
  console.warn("no such attr", c, a);
1461
1461
  continue;
1462
1462
  }
1463
- l["checked-data-type"] === "date" && n && (u = Ce(u), o[2] = u), pt(l) && R(i, [u, c, a], o), R(r, [a, c, u], o), R(s, [c, a, u], o);
1463
+ l["checked-data-type"] === "date" && n && (u = Ce(u), o[2] = u), yt(l) && R(i, [u, c, a], o), R(r, [a, c, u], o), R(s, [c, a, u], o);
1464
1464
  }
1465
1465
  return { eav: r, aev: s, vae: i };
1466
1466
  }
@@ -1529,7 +1529,7 @@ function gn(t, e, n) {
1529
1529
  if (!r)
1530
1530
  return;
1531
1531
  const [s, i, o] = r, a = e.getAttr(i);
1532
- a && (q(t.eav, [s, i, o]), q(t.aev, [i, s, o]), pt(a) && q(t.vae, [o, i, s]));
1532
+ a && (q(t.eav, [s, i, o]), q(t.aev, [i, s, o]), yt(a) && q(t.vae, [o, i, s]));
1533
1533
  }
1534
1534
  let Cr = 0;
1535
1535
  function _n(t, e, n) {
@@ -1548,7 +1548,7 @@ function wn(t, e, n) {
1548
1548
  return;
1549
1549
  a["checked-data-type"] === "date" && t.useDateObjects && (o = Ce(o));
1550
1550
  const c = ie(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? _n(t, a, r), l = [s, i, o, u];
1551
- Ir(a) ? (R(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), R(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (R(t.eav, [s, i, o], l), R(t.aev, [i, s, o], l)), pt(a) && R(t.vae, [o, i, s], l);
1551
+ Ir(a) ? (R(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), R(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (R(t.eav, [s, i, o], l), R(t.aev, [i, s, o], l)), yt(a) && R(t.vae, [o, i, s], l);
1552
1552
  }
1553
1553
  function Pr(t, e, n) {
1554
1554
  var p;
@@ -1557,7 +1557,7 @@ function Pr(t, e, n) {
1557
1557
  return;
1558
1558
  const [s, i, o] = r, a = e.getAttr(i);
1559
1559
  if (!a) return;
1560
- if (!yt(a))
1560
+ if (!bt(a))
1561
1561
  throw new Error("merge operation is not supported for links");
1562
1562
  const c = ie(t.eav, [s, i]);
1563
1563
  if (!c) return;
@@ -1571,7 +1571,7 @@ function Pr(t, e, n) {
1571
1571
  ];
1572
1572
  R(t.eav, [s, i], /* @__PURE__ */ new Map([[d, f]])), R(t.aev, [i, s], /* @__PURE__ */ new Map([[d, f]]));
1573
1573
  }
1574
- function Be(t, e, n) {
1574
+ function He(t, e, n) {
1575
1575
  var u, l;
1576
1576
  const [r, s] = n, i = be(t, [r]);
1577
1577
  if (!i)
@@ -1583,7 +1583,7 @@ function Be(t, e, n) {
1583
1583
  f && f["on-delete-reverse"] === "cascade" && x(a.get(d), 1).forEach(
1584
1584
  ([p, y, g]) => {
1585
1585
  var w;
1586
- return Be(t, e, [g, (w = f["reverse-identity"]) == null ? void 0 : w[1]]);
1586
+ return He(t, e, [g, (w = f["reverse-identity"]) == null ? void 0 : w[1]]);
1587
1587
  }
1588
1588
  ), // Fall back to deleting everything if we've rehydrated tx-steps from
1589
1589
  // the store that didn't set `etype` in deleteEntity
@@ -1597,7 +1597,7 @@ function Be(t, e, n) {
1597
1597
  c && c.forEach((d) => {
1598
1598
  var w, _, b;
1599
1599
  const [f, p, y] = d, g = e.getAttr(p);
1600
- (!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (q(t.eav, [f, p, y]), q(t.aev, [p, f, y]), q(t.vae, [y, p, f])), g && g["on-delete"] === "cascade" && ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s && Be(t, e, [f, (b = g["forward-identity"]) == null ? void 0 : b[1]]);
1600
+ (!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (q(t.eav, [f, p, y]), q(t.aev, [p, f, y]), q(t.vae, [y, p, f])), g && g["on-delete"] === "cascade" && ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s && He(t, e, [f, (b = g["forward-identity"]) == null ? void 0 : b[1]]);
1601
1601
  }), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && q(t.vae, [o]);
1602
1602
  }
1603
1603
  function Tn(t, e, n) {
@@ -1637,7 +1637,7 @@ function Rr(t, e, n) {
1637
1637
  gn(t, e, s);
1638
1638
  break;
1639
1639
  case "delete-entity":
1640
- Be(t, e, s);
1640
+ He(t, e, s);
1641
1641
  break;
1642
1642
  case "add-attr":
1643
1643
  jr(e, s);
@@ -1838,15 +1838,15 @@ function zr(t, e, n) {
1838
1838
  }
1839
1839
  return { ...n, [t]: e };
1840
1840
  }
1841
- function Ct(t, e, n) {
1841
+ function Pt(t, e, n) {
1842
1842
  return t === e ? n : null;
1843
1843
  }
1844
1844
  function Vr(t) {
1845
1845
  switch (typeof t) {
1846
1846
  case "string":
1847
- return t.startsWith("?") ? zr : Ct;
1847
+ return t.startsWith("?") ? zr : Pt;
1848
1848
  default:
1849
- return Ct;
1849
+ return Pt;
1850
1850
  }
1851
1851
  }
1852
1852
  const Qr = [
@@ -1876,19 +1876,19 @@ function Br(t, e, n) {
1876
1876
  return Yr(t, e, n).map((r) => Gr(e, r, n)).filter((r) => r);
1877
1877
  }
1878
1878
  function Hr(t, e, n) {
1879
- 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) => Br(t, e, r));
1879
+ return e.or ? e.or.patterns.flatMap((r) => Je(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => Je(t, s, r), n) : n.flatMap((r) => Br(t, e, r));
1880
1880
  }
1881
- function He(t, e, n = [{}]) {
1881
+ function Je(t, e, n = [{}]) {
1882
1882
  return e.reduce((r, s) => Hr(t, s, r), n);
1883
1883
  }
1884
- function bt(t, e) {
1885
- return Array.isArray(e) ? e.map((n) => bt(t, n)) : qr(e) ? t[e] : e;
1884
+ function gt(t, e) {
1885
+ return Array.isArray(e) ? e.map((n) => gt(t, n)) : qr(e) ? t[e] : e;
1886
1886
  }
1887
1887
  function Jr(t, { find: e, where: n }) {
1888
- return He(t, n).map((s) => bt(s, e));
1888
+ return Je(t, n).map((s) => gt(s, e));
1889
1889
  }
1890
1890
  function Yr(t, e, n) {
1891
- return Ur(t, bt(n, e));
1891
+ return Ur(t, gt(n, e));
1892
1892
  }
1893
1893
  const Zr = /^(?:[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;
1894
1894
  function re(t) {
@@ -1910,18 +1910,18 @@ function ts() {
1910
1910
  }
1911
1911
  return Ue(es);
1912
1912
  }
1913
- const ns = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Pt = { randomUUID: ns };
1913
+ const ns = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), jt = { randomUUID: ns };
1914
1914
  function rs(t, e, n) {
1915
1915
  var s;
1916
- if (Pt.randomUUID && !t)
1917
- return Pt.randomUUID();
1916
+ if (jt.randomUUID && !t)
1917
+ return jt.randomUUID();
1918
1918
  t = t || {};
1919
1919
  const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? ts();
1920
1920
  if (r.length < 16)
1921
1921
  throw new Error("Random bytes length must be >= 16");
1922
1922
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Xr(r);
1923
1923
  }
1924
- function jt(t) {
1924
+ function $t(t) {
1925
1925
  const e = t.replace(/-/g, ""), n = [];
1926
1926
  for (let r = 0; r < e.length; r += 2)
1927
1927
  n.push(parseInt(e.substring(r, r + 2), 16));
@@ -1935,7 +1935,7 @@ function ss(t, e) {
1935
1935
  return 0;
1936
1936
  }
1937
1937
  function is(t, e) {
1938
- return ss(jt(t), jt(e));
1938
+ return ss($t(t), $t(e));
1939
1939
  }
1940
1940
  function P() {
1941
1941
  return rs();
@@ -1971,7 +1971,7 @@ function ls(t, e) {
1971
1971
  throw new se(`Could not find id attr for ${e}`);
1972
1972
  return n;
1973
1973
  }
1974
- function $t(t, e, n, r) {
1974
+ function Dt(t, e, n, r) {
1975
1975
  return [ds(t, e, n, r)];
1976
1976
  }
1977
1977
  function ds(t, e, n, r) {
@@ -2004,7 +2004,7 @@ function On(t, e, n, r, s) {
2004
2004
  ];
2005
2005
  return [i ? d : u, f, p, a, !!i];
2006
2006
  }
2007
- function Dt(t, e) {
2007
+ function Rt(t, e) {
2008
2008
  if (typeof e != "string")
2009
2009
  return function(o) {
2010
2010
  return !1;
@@ -2058,7 +2058,7 @@ function hs(t, e) {
2058
2058
  }
2059
2059
  };
2060
2060
  if (e.hasOwnProperty("$like")) {
2061
- const r = Dt(!0, e.$like);
2061
+ const r = Rt(!0, e.$like);
2062
2062
  return {
2063
2063
  $comparator: !0,
2064
2064
  $op: function(i) {
@@ -2067,7 +2067,7 @@ function hs(t, e) {
2067
2067
  };
2068
2068
  }
2069
2069
  if (e.hasOwnProperty("$ilike")) {
2070
- const r = Dt(!1, e.$ilike);
2070
+ const r = Rt(!1, e.$ilike);
2071
2071
  return {
2072
2072
  $comparator: !0,
2073
2073
  $op: function(i) {
@@ -2123,7 +2123,7 @@ function ys(t, e, n, r, s) {
2123
2123
  );
2124
2124
  return [i, o, a];
2125
2125
  }
2126
- function Je(t, e, n, r, s, i) {
2126
+ function Ye(t, e, n, r, s, i) {
2127
2127
  const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ys(
2128
2128
  t,
2129
2129
  e,
@@ -2155,7 +2155,7 @@ function ws(t, e, n) {
2155
2155
  return e == i ? i : `${i}-${n}`;
2156
2156
  };
2157
2157
  }
2158
- function Rt(t, e, n, r, s, i) {
2158
+ function xt(t, e, n, r, s, i) {
2159
2159
  const o = t(r, s), a = i.map((c, u) => {
2160
2160
  const l = ws(t, o, u);
2161
2161
  return vn(l, n, r, s, c);
@@ -2168,9 +2168,9 @@ function Ts(t) {
2168
2168
  e.push(t.slice(0, n));
2169
2169
  return e;
2170
2170
  }
2171
- function xt(t, e, n, r, s) {
2171
+ function Ut(t, e, n, r, s) {
2172
2172
  return Ts(s).map(
2173
- (i) => Je(t, e, n, r, i, {
2173
+ (i) => Ye(t, e, n, r, i, {
2174
2174
  $isNull: !0
2175
2175
  })
2176
2176
  );
@@ -2178,21 +2178,21 @@ function xt(t, e, n, r, s) {
2178
2178
  function vn(t, e, n, r, s) {
2179
2179
  return Object.entries(s).flatMap(([i, o]) => {
2180
2180
  if (gs([i, o]))
2181
- return Rt(t, "or", e, n, r, o);
2181
+ return xt(t, "or", e, n, r, o);
2182
2182
  if (_s([i, o]))
2183
- return Rt(t, "and", e, n, r, o);
2183
+ return xt(t, "and", e, n, r, o);
2184
2184
  if (i === "$entityIdStartsWith")
2185
2185
  return [];
2186
2186
  const a = i.split(".");
2187
2187
  if (o != null && o.hasOwnProperty("$ne") && (o = { ...o, $not: o.$ne }, delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2188
- const c = Je(
2188
+ const c = Ye(
2189
2189
  t,
2190
2190
  e,
2191
2191
  n,
2192
2192
  r,
2193
2193
  a,
2194
2194
  o
2195
- ), u = xt(
2195
+ ), u = Ut(
2196
2196
  t,
2197
2197
  e,
2198
2198
  n,
@@ -2211,7 +2211,7 @@ function vn(t, e, n, r, s) {
2211
2211
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2212
2212
  {
2213
2213
  or: {
2214
- patterns: xt(
2214
+ patterns: Ut(
2215
2215
  t,
2216
2216
  e,
2217
2217
  n,
@@ -2221,12 +2221,12 @@ function vn(t, e, n, r, s) {
2221
2221
  joinSym: t(n, r)
2222
2222
  }
2223
2223
  }
2224
- ] : Je(t, e, n, r, a, o);
2224
+ ] : Ye(t, e, n, r, a, o);
2225
2225
  });
2226
2226
  }
2227
2227
  function ms(t, e, n, r) {
2228
2228
  const s = Pe;
2229
- return r ? vn(s, t, e, n, r).concat($t(s, t, e, n)) : $t(s, t, e, n);
2229
+ return r ? vn(s, t, e, n, r).concat(Dt(s, t, e, n)) : Dt(s, t, e, n);
2230
2230
  }
2231
2231
  function Ss(t, e, n) {
2232
2232
  return [t(e, n), t("time", n)];
@@ -2281,7 +2281,7 @@ function ue(t, e, n, r, s) {
2281
2281
  function Ie([t, e], [n, r], s) {
2282
2282
  return ue(t, e, n, r, s);
2283
2283
  }
2284
- function Ye(t) {
2284
+ function Ze(t) {
2285
2285
  return t == null ? t : new Date(t).getTime();
2286
2286
  }
2287
2287
  function ks(t, e, n, r) {
@@ -2289,7 +2289,7 @@ function ks(t, e, n, r) {
2289
2289
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2290
2290
  if (((y = e["forward-identity"]) == null ? void 0 : y[2]) === "id")
2291
2291
  return Ie(r, [s, a], null) === c;
2292
- const [u, l] = r, d = e["checked-data-type"], f = d === "date" ? Ye(l) : l, p = d === "date" ? Ye(o) : o;
2292
+ const [u, l] = r, d = e["checked-data-type"], f = d === "date" ? Ze(l) : l, p = d === "date" ? Ze(o) : o;
2293
2293
  return Ie([u, f], [s, p], d) === c;
2294
2294
  }
2295
2295
  function Es(t, e) {
@@ -2313,7 +2313,7 @@ function Cs(t, e, n) {
2313
2313
  const r = /* @__PURE__ */ new Map();
2314
2314
  for (const o of n.fields) {
2315
2315
  const a = M(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
2316
- c && yt(a) && r.set(c, a);
2316
+ c && bt(a) && r.set(c, a);
2317
2317
  }
2318
2318
  if (!r.has("id")) {
2319
2319
  const o = M(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
@@ -2331,7 +2331,7 @@ function Ps(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2331
2331
  u = u.map(([b]) => {
2332
2332
  var S, m, v, O, L;
2333
2333
  let T = (L = (O = (v = (m = (S = t.eav.get(b)) == null ? void 0 : S.get(_)) == null ? void 0 : m.values()) == null ? void 0 : v.next()) == null ? void 0 : O.value) == null ? void 0 : L[2];
2334
- return w && (T = Ye(T)), [b, T];
2334
+ return w && (T = Ze(T)), [b, T];
2335
2335
  });
2336
2336
  }
2337
2337
  u.sort(
@@ -2408,7 +2408,7 @@ function Rs(t) {
2408
2408
  };
2409
2409
  return e;
2410
2410
  }
2411
- function gt({
2411
+ function _t({
2412
2412
  store: t,
2413
2413
  attrsStore: e,
2414
2414
  pageInfo: n,
@@ -2439,7 +2439,7 @@ function xs() {
2439
2439
  return new Set(Object.keys(e));
2440
2440
  }
2441
2441
  const Us = xs();
2442
- function Ze(t, e, n) {
2442
+ function Xe(t, e, n) {
2443
2443
  const r = {
2444
2444
  __etype: t,
2445
2445
  __ops: n
@@ -2449,7 +2449,7 @@ function Ze(t, e, n) {
2449
2449
  if (i === "__ops") return n;
2450
2450
  if (i === "__etype") return t;
2451
2451
  if (Us.has(i))
2452
- return (o, a) => Ze(t, e, [
2452
+ return (o, a) => Xe(t, e, [
2453
2453
  ...n,
2454
2454
  a ? [i, t, e, o, a] : [i, t, e, o]
2455
2455
  ]);
@@ -2475,7 +2475,7 @@ function Ls(t) {
2475
2475
  get(e, n) {
2476
2476
  if (n === "__etype") return t;
2477
2477
  const r = n;
2478
- return Me(r) ? Ze(t, In(r), []) : Ze(t, r, []);
2478
+ return Me(r) ? Xe(t, In(r), []) : Xe(t, r, []);
2479
2479
  }
2480
2480
  }
2481
2481
  );
@@ -2528,7 +2528,7 @@ function qs(t, e, n) {
2528
2528
  // before assuming it's a ref lookup.
2529
2529
  !M(t, e, n);
2530
2530
  }
2531
- function Xe(t) {
2531
+ function et(t) {
2532
2532
  const [e, n, ...r] = t.split(".");
2533
2533
  if (r.length > 0 || n !== "id")
2534
2534
  throw new Error(`${t} is not a valid lookup attribute.`);
@@ -2537,16 +2537,16 @@ function Xe(t) {
2537
2537
  function zs(t, e, n) {
2538
2538
  if (!qs(t, e, n))
2539
2539
  return M(t, e, n);
2540
- const r = Xe(n), s = M(t, e, r) || X(t, e, r);
2540
+ const r = et(n), s = M(t, e, r) || X(t, e, r);
2541
2541
  if (s && s["value-type"] !== "ref")
2542
2542
  throw new Error(`${n} does not reference a valid link attribute.`);
2543
2543
  return s;
2544
2544
  }
2545
- function et(t) {
2545
+ function tt(t) {
2546
2546
  return typeof t == "string" && !Me(t) ? null : typeof t == "string" && Me(t) ? In(t) : Ks(t);
2547
2547
  }
2548
2548
  function U(t, e, n) {
2549
- const r = et(n);
2549
+ const r = tt(n);
2550
2550
  if (r === null)
2551
2551
  return n;
2552
2552
  const [s, i] = r, o = zs(t, e, s);
@@ -2633,14 +2633,14 @@ function Pn({ stores: t, attrsStore: e }, [n, r, s, i]) {
2633
2633
  return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Ws(t, e, n, r) ? { mode: "update" } : null;
2634
2634
  }
2635
2635
  function Gs(t, e) {
2636
- const { attrsStore: n } = t, [r, s, i, o] = e, a = ht(i), c = U(n, r, s);
2636
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = pt(i), c = U(n, r, s);
2637
2637
  return [["id", c]].concat(Object.entries(a)).map(([l, d]) => {
2638
2638
  const f = M(n, r, l);
2639
2639
  return f["checked-data-type"] === "date" && t.useDateObjects && (d = Ce(d)), ["add-triple", c, f.id, d, { mode: "create" }];
2640
2640
  });
2641
2641
  }
2642
2642
  function Bs(t, e) {
2643
- const { attrsStore: n } = t, [r, s, i, o] = e, a = ht(i), c = U(n, r, s), u = Pn(t, [r, c, i, o]);
2643
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = pt(i), c = U(n, r, s), u = Pn(t, [r, c, i, o]);
2644
2644
  return [["id", c]].concat(Object.entries(a)).map(([d, f]) => {
2645
2645
  const p = M(n, r, d);
2646
2646
  return p["checked-data-type"] === "date" && t.useDateObjects && (f = Ce(f)), [
@@ -2656,7 +2656,7 @@ function Hs({ attrsStore: t }, [e, n]) {
2656
2656
  return [["delete-entity", U(t, e, n), e]];
2657
2657
  }
2658
2658
  function Js(t, e) {
2659
- const { attrsStore: n } = t, [r, s, i, o] = e, a = ht(i), c = U(n, r, s), u = Pn(t, [r, c, i, o]), l = Object.entries(a).map(([f, p]) => {
2659
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = pt(i), c = U(n, r, s), u = Pn(t, [r, c, i, o]), l = Object.entries(a).map(([f, p]) => {
2660
2660
  const y = M(n, r, f);
2661
2661
  return [
2662
2662
  "deep-merge-triple",
@@ -2760,7 +2760,7 @@ function ri(t, e, n) {
2760
2760
  "on-delete-reverse": i.onDelete
2761
2761
  };
2762
2762
  }
2763
- function Ut(t, e, n, r) {
2763
+ function Lt(t, e, n, r) {
2764
2764
  const s = t ? ri(t, e, n) : null, i = P(), o = [P(), e, n], a = [P(), n, e];
2765
2765
  return {
2766
2766
  id: i,
@@ -2786,20 +2786,20 @@ const si = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2786
2786
  "merge",
2787
2787
  "delete",
2788
2788
  "ruleParams"
2789
- ]), tt = { "unique?": !0, "index?": !0 }, ci = {
2790
- ...tt,
2789
+ ]), nt = { "unique?": !0, "index?": !0 }, ci = {
2790
+ ...nt,
2791
2791
  cardinality: "one"
2792
2792
  };
2793
2793
  function ui(t) {
2794
2794
  const e = [], [n, r, s, i] = t;
2795
2795
  if (!ai.has(n))
2796
2796
  return e;
2797
- const o = et(s);
2797
+ const o = tt(s);
2798
2798
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2799
2799
  for (const [a, c] of Object.entries(i)) {
2800
2800
  const u = Array.isArray(c) ? c : [c];
2801
2801
  for (const l of u) {
2802
- const d = et(l);
2802
+ const d = tt(l);
2803
2803
  d && e.push({
2804
2804
  etype: r,
2805
2805
  lookupPair: d,
@@ -2838,7 +2838,7 @@ function li({ attrsStore: t, schema: e }, n) {
2838
2838
  }
2839
2839
  function d(y, g) {
2840
2840
  const w = o(y, g), _ = a(y, g);
2841
- u(w), u(_), !w && !_ && c(Ut(e, y, g, ci));
2841
+ u(w), u(_), !w && !_ && c(Lt(e, y, g, ci));
2842
2842
  }
2843
2843
  for (const y of n)
2844
2844
  for (const { etype: g, lookupPair: w, linkLabel: _ } of ui(y)) {
@@ -2849,18 +2849,18 @@ function li({ attrsStore: t, schema: e }, n) {
2849
2849
  u(T), u(S);
2850
2850
  const m = ((f = T == null ? void 0 : T["reverse-identity"]) == null ? void 0 : f[1]) || ((p = S == null ? void 0 : S["forward-identity"]) == null ? void 0 : p[1]) || _;
2851
2851
  if (l(m, b))
2852
- d(m, Xe(b));
2852
+ d(m, et(b));
2853
2853
  else {
2854
2854
  const v = o(m, b);
2855
2855
  v || c(
2856
- _e(e, m, b, tt)
2856
+ _e(e, m, b, nt)
2857
2857
  ), u(v);
2858
2858
  }
2859
2859
  } else if (l(g, b))
2860
- d(g, Xe(b));
2860
+ d(g, et(b));
2861
2861
  else {
2862
2862
  const T = o(g, b);
2863
- T || c(_e(e, g, b, tt)), u(T);
2863
+ T || c(_e(e, g, b, nt)), u(T);
2864
2864
  }
2865
2865
  }
2866
2866
  for (const y of n) {
@@ -2879,7 +2879,7 @@ function li({ attrsStore: t, schema: e }, n) {
2879
2879
  )
2880
2880
  )), ii.has(g)) {
2881
2881
  const v = a(w, S);
2882
- !m && !v && c(Ut(e, w, S)), u(v);
2882
+ !m && !v && c(Lt(e, w, S)), u(v);
2883
2883
  }
2884
2884
  }
2885
2885
  }
@@ -2896,7 +2896,7 @@ function di(t, e) {
2896
2896
  const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ns(c)), [s, i] = li(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Xs(o, c));
2897
2897
  return [...i, ...a];
2898
2898
  }
2899
- function Lt(t, e) {
2899
+ function Nt(t, e) {
2900
2900
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2901
2901
  }
2902
2902
  const fe = "__meta";
@@ -2904,7 +2904,7 @@ class fi {
2904
2904
  constructor(e, n) {
2905
2905
  }
2906
2906
  }
2907
- class nt {
2907
+ class rt {
2908
2908
  constructor(e) {
2909
2909
  h(this, "currentValue");
2910
2910
  h(this, "_subs", []);
@@ -3105,7 +3105,7 @@ class nt {
3105
3105
  gc() {
3106
3106
  this._nextGc || (this._nextGc = setTimeout(
3107
3107
  () => {
3108
- Lt(() => {
3108
+ Nt(() => {
3109
3109
  this._nextGc = null, this._gc();
3110
3110
  }, 30 * 1e3);
3111
3111
  },
@@ -3120,7 +3120,7 @@ class nt {
3120
3120
  return;
3121
3121
  }
3122
3122
  this._nextSave = setTimeout(() => {
3123
- Lt(() => {
3123
+ Nt(() => {
3124
3124
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
3125
3125
  }, this._idleCallbackMaxWaitMs);
3126
3126
  }, this._saveThrottleMs);
@@ -3206,7 +3206,7 @@ async function gi(t, e, n) {
3206
3206
  };
3207
3207
  });
3208
3208
  }
3209
- async function Nt(t, e, n) {
3209
+ async function Ft(t, e, n) {
3210
3210
  const r = n.put(e, t);
3211
3211
  return new Promise((s, i) => {
3212
3212
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
@@ -3241,7 +3241,7 @@ async function _i(t, e) {
3241
3241
  break;
3242
3242
  }
3243
3243
  default: {
3244
- const f = Nt(l, d, i);
3244
+ const f = Ft(l, d, i);
3245
3245
  a.push(f);
3246
3246
  const p = {
3247
3247
  createdAt: Date.now(),
@@ -3252,12 +3252,12 @@ async function _i(t, e) {
3252
3252
  break;
3253
3253
  }
3254
3254
  }
3255
- const u = Nt(fe, c, i);
3255
+ const u = Ft(fe, c, i);
3256
3256
  a.push(u), await Promise.all(a), await new Promise((l, d) => {
3257
3257
  s.oncomplete = (f) => l(f), s.onerror = (f) => d(f), s.onabort = (f) => d(f);
3258
3258
  });
3259
3259
  }
3260
- const Ft = /* @__PURE__ */ new Map();
3260
+ const Kt = /* @__PURE__ */ new Map();
3261
3261
  class jn extends fi {
3262
3262
  constructor(n, r) {
3263
3263
  super(n, r);
@@ -3280,9 +3280,9 @@ class jn extends fi {
3280
3280
  const u = _i(this._appId, c).catch((l) => {
3281
3281
  yi("Error upgrading store from version 5 to 6.")(l);
3282
3282
  });
3283
- Ft.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
3283
+ Kt.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
3284
3284
  } else {
3285
- const u = Ft.get(this.dbName);
3285
+ const u = Kt.get(this.dbName);
3286
3286
  u ? u.then(() => n(c)).catch(() => n(c)) : n(c);
3287
3287
  }
3288
3288
  }, i.onupgradeneeded = (o) => {
@@ -3457,7 +3457,7 @@ async function Si({
3457
3457
  })
3458
3458
  });
3459
3459
  }
3460
- async function Kt({
3460
+ async function qt({
3461
3461
  apiURI: t,
3462
3462
  appId: e,
3463
3463
  code: n,
@@ -3599,9 +3599,9 @@ async function Mi({
3599
3599
  );
3600
3600
  return s;
3601
3601
  }
3602
- let _t = !1, Dn = !1, Rn = !1;
3603
- typeof window < "u" && typeof window.localStorage < "u" && (_t = !!window.localStorage.getItem("devBackend"), Dn = !!window.localStorage.getItem("__instantLogging"), Rn = !!window.localStorage.getItem("__devtoolLocalDash"));
3604
- function qt(t, e) {
3602
+ let wt = !1, Dn = !1, Rn = !1;
3603
+ typeof window < "u" && typeof window.localStorage < "u" && (wt = !!window.localStorage.getItem("devBackend"), Dn = !!window.localStorage.getItem("__instantLogging"), Rn = !!window.localStorage.getItem("__devtoolLocalDash"));
3604
+ function zt(t, e) {
3605
3605
  if (!e) return t;
3606
3606
  const n = {};
3607
3607
  return e.forEach((r) => {
@@ -3613,25 +3613,25 @@ function Ci(t, e, n) {
3613
3613
  peers: {}
3614
3614
  };
3615
3615
  if (e && "user" in e ? e.user : !0) {
3616
- const i = qt(t.user ?? {}, e == null ? void 0 : e.keys);
3616
+ const i = zt(t.user ?? {}, e == null ? void 0 : e.keys);
3617
3617
  r.user = { ...i, peerId: n };
3618
3618
  }
3619
3619
  for (const i of Object.keys(t.peers ?? {})) {
3620
3620
  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));
3621
3621
  if (o || a) {
3622
- const c = qt(t.peers[i], e == null ? void 0 : e.keys);
3622
+ const c = zt(t.peers[i], e == null ? void 0 : e.keys);
3623
3623
  r.peers[i] = { ...c, peerId: i };
3624
3624
  }
3625
3625
  }
3626
3626
  return r;
3627
3627
  }
3628
3628
  function Pi(t, e) {
3629
- 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;
3629
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !It(t.user, e.user)) || !ln(t.peers, e.peers)) return !0;
3630
3630
  for (const r of Object.keys(t.peers))
3631
- if (!Et(t.peers[r], e.peers[r])) return !0;
3631
+ if (!It(t.peers[r], e.peers[r])) return !0;
3632
3632
  return !1;
3633
3633
  }
3634
- class zt {
3634
+ class Vt {
3635
3635
  constructor() {
3636
3636
  h(this, "promise");
3637
3637
  h(this, "_resolve");
@@ -3656,11 +3656,11 @@ function xn(t, e = []) {
3656
3656
  xn(n["child-nodes"], e);
3657
3657
  });
3658
3658
  }
3659
- function Vt(t) {
3659
+ function Qt(t) {
3660
3660
  const e = [];
3661
3661
  return xn(t, e), e;
3662
3662
  }
3663
- function rt(t) {
3663
+ function st(t) {
3664
3664
  return Object.values(t.links).reduce((e, n) => {
3665
3665
  var r, s;
3666
3666
  return e[r = n.forward.on] ?? (e[r] = {}), e[n.forward.on][n.forward.label] = {
@@ -3674,7 +3674,7 @@ function rt(t) {
3674
3674
  }, e;
3675
3675
  }, {});
3676
3676
  }
3677
- const Un = "v0.22.104";
3677
+ const Un = "v0.22.105";
3678
3678
  function ji(t, e) {
3679
3679
  return {
3680
3680
  info: t ? (...n) => console.info(...n, e()) : () => {
@@ -3785,7 +3785,7 @@ class k extends Error {
3785
3785
  super(r), this.name = "QueryValidationError";
3786
3786
  }
3787
3787
  }
3788
- const Qt = [
3788
+ const Wt = [
3789
3789
  "where",
3790
3790
  "order",
3791
3791
  "limit",
@@ -4014,9 +4014,9 @@ const Qt = [
4014
4014
  }
4015
4015
  }, xi = (t, e, n, r, s = 0) => {
4016
4016
  for (const o of Object.keys(t))
4017
- if (!Qt.includes(o))
4017
+ if (!Wt.includes(o))
4018
4018
  throw new k(
4019
- `Invalid query parameter '${o}' in $ object. Valid parameters are: ${Qt.join(", ")}. Found: ${o}`,
4019
+ `Invalid query parameter '${o}' in $ object. Valid parameters are: ${Wt.join(", ")}. Found: ${o}`,
4020
4020
  r
4021
4021
  );
4022
4022
  const i = [
@@ -4088,7 +4088,7 @@ const Qt = [
4088
4088
  s
4089
4089
  );
4090
4090
  }
4091
- }, Wt = (t, e) => {
4091
+ }, Gt = (t, e) => {
4092
4092
  if (typeof t != "object" || t === null)
4093
4093
  throw new k(
4094
4094
  `Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`
@@ -4127,7 +4127,7 @@ const Qt = [
4127
4127
  );
4128
4128
  }
4129
4129
  }
4130
- }, Gt = (t) => typeof t != "string" ? !1 : Me(t) ? !0 : re(t);
4130
+ }, Bt = (t) => typeof t != "string" ? !1 : Me(t) ? !0 : re(t);
4131
4131
  class K extends Error {
4132
4132
  constructor(e) {
4133
4133
  super(e), this.name = "TransactionValidationError";
@@ -4163,7 +4163,7 @@ const Kn = (t) => t.length > 0 ? t.join(", ") : "none", Ui = (t, e) => new K(
4163
4163
  `Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
4164
4164
  );
4165
4165
  }
4166
- }, Bt = (t, e, n) => {
4166
+ }, Ht = (t, e, n) => {
4167
4167
  const r = qn(t, n);
4168
4168
  if (typeof e != "object" || e === null)
4169
4169
  throw new K(
@@ -4179,11 +4179,11 @@ const Kn = (t) => t.length > 0 ? t.join(", ") : "none", Ui = (t, e) => new K(
4179
4179
  if (i != null) {
4180
4180
  if (Array.isArray(i)) {
4181
4181
  for (const a of i)
4182
- if (!Gt(a))
4182
+ if (!Bt(a))
4183
4183
  throw new K(
4184
4184
  `Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`
4185
4185
  );
4186
- } else if (!Gt(i))
4186
+ } else if (!Bt(i))
4187
4187
  throw new K(
4188
4188
  `Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`
4189
4189
  );
@@ -4193,8 +4193,8 @@ const Kn = (t) => t.length > 0 ? t.join(", ") : "none", Ui = (t, e) => new K(
4193
4193
  create: Ne,
4194
4194
  update: Ne,
4195
4195
  merge: Ne,
4196
- link: Bt,
4197
- unlink: Bt,
4196
+ link: Ht,
4197
+ unlink: Ht,
4198
4198
  delete: () => {
4199
4199
  }
4200
4200
  }, Fi = (t, e) => {
@@ -4231,7 +4231,7 @@ const Kn = (t) => t.length > 0 ? t.join(", ") : "none", Ui = (t, e) => new K(
4231
4231
  }
4232
4232
  };
4233
4233
  let zn = 0;
4234
- class Ht {
4234
+ class Jt {
4235
4235
  constructor(e) {
4236
4236
  h(this, "type", "ws");
4237
4237
  h(this, "conn");
@@ -4396,12 +4396,12 @@ function Qi(t, e, n) {
4396
4396
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
4397
4397
  }
4398
4398
  function Fe(t, e, n) {
4399
- return gt(
4399
+ return _t(
4400
4400
  { store: e, attrsStore: n, pageInfo: null, aggregate: null },
4401
4401
  t.query
4402
4402
  ).data[t.table][0];
4403
4403
  }
4404
- function Jt(t, e, n, r) {
4404
+ function Yt(t, e, n, r) {
4405
4405
  var o;
4406
4406
  const s = (o = M(n, t.table, "id")) == null ? void 0 : o.id;
4407
4407
  if (!s)
@@ -4409,7 +4409,7 @@ function Jt(t, e, n, r) {
4409
4409
  const i = ie(e.eav, [r, s, r]);
4410
4410
  return i ? i[3] : -1;
4411
4411
  }
4412
- function Yt(t, e, n) {
4412
+ function Zt(t, e, n) {
4413
4413
  for (const { action: r, triple: s } of n)
4414
4414
  switch (r) {
4415
4415
  case "added":
@@ -4511,7 +4511,7 @@ class Ji {
4511
4511
  h(this, "log");
4512
4512
  h(this, "createStore");
4513
4513
  h(this, "getAttrs");
4514
- this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new nt({
4514
+ this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new rt({
4515
4515
  persister: n,
4516
4516
  merge: Qi,
4517
4517
  serialize: Vi,
@@ -4650,7 +4650,7 @@ class Ji {
4650
4650
  c.push({
4651
4651
  store: l,
4652
4652
  entity: d,
4653
- serverCreatedAt: Jt(
4653
+ serverCreatedAt: Yt(
4654
4654
  o,
4655
4655
  l,
4656
4656
  a.attrsStore,
@@ -4726,7 +4726,7 @@ class Ji {
4726
4726
  for (let b = 0; b < d.length; b++) {
4727
4727
  const T = d[b];
4728
4728
  if (Mr(T.store, w)) {
4729
- Yt(T.store, l.attrsStore, _);
4729
+ Zt(T.store, l.attrsStore, _);
4730
4730
  const S = Fe(s, T.store, l.attrsStore), m = Wi(
4731
4731
  T.store,
4732
4732
  l.attrsStore,
@@ -4743,7 +4743,7 @@ class Ji {
4743
4743
  const p = [];
4744
4744
  for (const [w, _] of Object.entries(u)) {
4745
4745
  const b = this.createStore([]);
4746
- Yt(b, l.attrsStore, _);
4746
+ Zt(b, l.attrsStore, _);
4747
4747
  const T = Fe(s, b, l.attrsStore);
4748
4748
  if (!T) {
4749
4749
  this.log.error("No entity found after applying change", {
@@ -4756,7 +4756,7 @@ class Ji {
4756
4756
  d.push({
4757
4757
  store: b,
4758
4758
  entity: T,
4759
- serverCreatedAt: Jt(
4759
+ serverCreatedAt: Yt(
4760
4760
  s,
4761
4761
  b,
4762
4762
  l.attrsStore,
@@ -4827,10 +4827,10 @@ function no({
4827
4827
  EventSourceImpl: s
4828
4828
  }) {
4829
4829
  if (!s)
4830
- return new Ht(`${r}?app_id=${e}`);
4830
+ return new Jt(`${r}?app_id=${e}`);
4831
4831
  switch (t) {
4832
4832
  case "ws":
4833
- return new Ht(`${r}?app_id=${e}`);
4833
+ return new Jt(`${r}?app_id=${e}`);
4834
4834
  case "sse":
4835
4835
  return new qi(
4836
4836
  s,
@@ -4843,7 +4843,7 @@ function no({
4843
4843
  function ro() {
4844
4844
  return typeof window < "u" || typeof chrome < "u";
4845
4845
  }
4846
- const Zt = {
4846
+ const Xt = {
4847
4847
  "set-presence": !0,
4848
4848
  "set-presence-ok": !0,
4849
4849
  "refresh-presence": !0,
@@ -4902,7 +4902,7 @@ function co(t, e, n) {
4902
4902
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4903
4903
  return r && !s && n && (n.result = r), n || e;
4904
4904
  }
4905
- function Xt(t) {
4905
+ function qe(t) {
4906
4906
  return [...t].sort((e, n) => {
4907
4907
  const [r, s] = e, [i, o] = n, a = s.order || 0, c = o.order || 0;
4908
4908
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
@@ -5040,7 +5040,7 @@ class uo {
5040
5040
  this._updatePendingMutations((c) => {
5041
5041
  c.set(r, o);
5042
5042
  });
5043
- const a = new zt();
5043
+ const a = new Vt();
5044
5044
  return this.mutationDeferredStore.set(r, a), this._sendMutation(r, o), this.notifyAll(), a.promise;
5045
5045
  });
5046
5046
  h(this, "_transportOnOpen", (e) => {
@@ -5145,9 +5145,9 @@ class uo {
5145
5145
  ), this._scheduleReconnect();
5146
5146
  });
5147
5147
  if (this._EventSource = i, this.config = { ...to, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Zi, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Xi, this._log = ji(
5148
- e.verbose || _t || Dn,
5148
+ e.verbose || wt || Dn,
5149
5149
  () => this._reactorStats()
5150
- ), this.versions = { ...s || {}, "@instantdb/core": Un }, this.config.schema && (this._linkIndex = rt(this.config.schema)), !!ro()) {
5150
+ ), this.versions = { ...s || {}, "@instantdb/core": Un }, this.config.schema && (this._linkIndex = st(this.config.schema)), !!ro()) {
5151
5151
  if (!e.appId)
5152
5152
  throw new Error("Instant must be initialized with an appId.");
5153
5153
  if (!re(e.appId))
@@ -5205,7 +5205,7 @@ class uo {
5205
5205
  ...this.config,
5206
5206
  schema: e,
5207
5207
  cardinalityInference: !!e
5208
- }, this._linkIndex = e ? rt(this.config.schema) : null;
5208
+ }, this._linkIndex = e ? st(this.config.schema) : null;
5209
5209
  }
5210
5210
  _reactorStats() {
5211
5211
  return {
@@ -5218,7 +5218,7 @@ class uo {
5218
5218
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
5219
5219
  }
5220
5220
  _initStorage(e) {
5221
- this.querySubs = new nt({
5221
+ this.querySubs = new rt({
5222
5222
  persister: new e(this.config.appId, "querySubs"),
5223
5223
  merge: co,
5224
5224
  serialize: io,
@@ -5238,7 +5238,7 @@ class uo {
5238
5238
  maxSize: 1e6
5239
5239
  // 1 million triples
5240
5240
  }
5241
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new nt({
5241
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new rt({
5242
5242
  persister: new e(this.config.appId, "kv"),
5243
5243
  merge: this._onMergeKv,
5244
5244
  serialize: ao,
@@ -5333,7 +5333,7 @@ class uo {
5333
5333
  _handleReceive(e, n) {
5334
5334
  var s, i, o, a, c, u;
5335
5335
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5336
- switch (Zt[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5336
+ switch (Xt[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5337
5337
  case "init-ok": {
5338
5338
  this._setStatus(W.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
5339
5339
  for (const f of Object.keys(this._rooms)) {
@@ -5350,7 +5350,7 @@ class uo {
5350
5350
  const { q: f, result: p } = n, y = C(f);
5351
5351
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
5352
5352
  break;
5353
- const g = (a = (o = p == null ? void 0 : p[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], w = (u = (c = p == null ? void 0 : p[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, _ = Vt(p), b = this.ensureAttrs(), T = te(
5353
+ const g = (a = (o = p == null ? void 0 : p[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], w = (u = (c = p == null ? void 0 : p[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, _ = Qt(p), b = this.ensureAttrs(), T = te(
5354
5354
  b,
5355
5355
  _,
5356
5356
  r,
@@ -5398,9 +5398,9 @@ class uo {
5398
5398
  g !== this._pendingMutations() && this.kv.updateInPlace((b) => {
5399
5399
  b.pendingMutations = g;
5400
5400
  });
5401
- const w = Xt(g.entries()), _ = f.map((b) => {
5402
- var wt, Tt, mt, St;
5403
- const T = b["instaql-query"], S = b["instaql-result"], m = C(T), v = Vt(S), O = this.ensureAttrs(), L = te(
5401
+ const w = qe(g.entries()), _ = f.map((b) => {
5402
+ var Tt, mt, St, At;
5403
+ const T = b["instaql-query"], S = b["instaql-result"], m = C(T), v = Qt(S), O = this.ensureAttrs(), L = te(
5404
5404
  O,
5405
5405
  v,
5406
5406
  r,
@@ -5410,7 +5410,7 @@ class uo {
5410
5410
  O,
5411
5411
  w,
5412
5412
  y
5413
- ), Wn = (Tt = (wt = S == null ? void 0 : S[0]) == null ? void 0 : wt.data) == null ? void 0 : Tt["page-info"], Gn = (St = (mt = S == null ? void 0 : S[0]) == null ? void 0 : mt.data) == null ? void 0 : St.aggregate;
5413
+ ), Wn = (mt = (Tt = S == null ? void 0 : S[0]) == null ? void 0 : Tt.data) == null ? void 0 : mt["page-info"], Gn = (At = (St = S == null ? void 0 : S[0]) == null ? void 0 : St.data) == null ? void 0 : At.aggregate;
5414
5414
  return {
5415
5415
  q: T,
5416
5416
  hash: m,
@@ -5607,15 +5607,15 @@ class uo {
5607
5607
  * Returns an unsubscribe function
5608
5608
  */
5609
5609
  subscribeQuery(e, n, r) {
5610
- this.config.disableValidation || Wt(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5610
+ this.config.disableValidation || Gt(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5611
5611
  const s = C(e), i = this.getPreviousResult(e);
5612
5612
  return i && n(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5613
5613
  this._unsubQuery(e, s, n);
5614
5614
  };
5615
5615
  }
5616
5616
  queryOnce(e, n) {
5617
- this.config.disableValidation || Wt(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5618
- const r = new zt();
5617
+ this.config.disableValidation || Gt(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5618
+ const r = new Vt();
5619
5619
  if (!this._isOnline)
5620
5620
  return r.reject(
5621
5621
  new Error("We can't run `queryOnce`, because the device is offline.")
@@ -5710,7 +5710,7 @@ class uo {
5710
5710
  return a ? u : n;
5711
5711
  }
5712
5712
  _rewriteMutationsSorted(e, n) {
5713
- return Xt(this._rewriteMutations(e, n).entries());
5713
+ return qe(this._rewriteMutations(e, n).entries());
5714
5714
  }
5715
5715
  // ---------------------------
5716
5716
  // Transact
@@ -5763,7 +5763,7 @@ class uo {
5763
5763
  );
5764
5764
  d = b.store, f = b.attrsStore;
5765
5765
  }
5766
- return { data: gt(
5766
+ return { data: _t(
5767
5767
  { store: d, attrsStore: f, pageInfo: p, aggregate: y },
5768
5768
  c
5769
5769
  ), querySubVersion: s, pendingMutationsVersion: o };
@@ -5825,15 +5825,19 @@ class uo {
5825
5825
  // Websocket
5826
5826
  /** Send messages we accumulated while we were connecting */
5827
5827
  _flushPendingMessages() {
5828
- Object.keys(this.queryCbs).map((s) => this.querySubs.currentValue[s]).filter((s) => s).forEach(({ eventId: s, q: i }) => {
5829
- this._trySendAuthed(s, { op: "add-query", q: i });
5830
- }), Object.values(this.queryOnceDfds).flat().forEach(({ eventId: s, q: i }) => {
5831
- this._trySendAuthed(s, { op: "add-query", q: i });
5832
- }), this._rewriteMutationsSorted(
5828
+ Object.keys(this.queryCbs).map((i) => this.querySubs.currentValue[i]).filter((i) => i).forEach(({ eventId: i, q: o }) => {
5829
+ this._trySendAuthed(i, { op: "add-query", q: o });
5830
+ }), Object.values(this.queryOnceDfds).flat().forEach(({ eventId: i, q: o }) => {
5831
+ this._trySendAuthed(i, { op: "add-query", q: o });
5832
+ });
5833
+ const r = this._rewriteMutations(
5833
5834
  this.ensureAttrs(),
5834
5835
  this._pendingMutations()
5835
- ).forEach(([s, i]) => {
5836
- i["tx-id"] || this._sendMutation(s, i);
5836
+ );
5837
+ r !== this._pendingMutations() && this.kv.updateInPlace((i) => {
5838
+ i.pendingMutations = r;
5839
+ }), qe(r.entries()).forEach(([i, o]) => {
5840
+ o["tx-id"] || this._sendMutation(i, o);
5837
5841
  }), this._syncTable.flushPending();
5838
5842
  }
5839
5843
  /**
@@ -5867,7 +5871,7 @@ class uo {
5867
5871
  }
5868
5872
  _trySend(e, n, r) {
5869
5873
  if (this._transport.isOpen()) {
5870
- switch (Zt[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5874
+ switch (Xt[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5871
5875
  case "transact": {
5872
5876
  this._inFlightMutationEventIds.add(e);
5873
5877
  break;
@@ -5971,7 +5975,7 @@ class uo {
5971
5975
  return null;
5972
5976
  this._replaceUrlAfterOAuth();
5973
5977
  try {
5974
- const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Kt({
5978
+ const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await qt({
5975
5979
  apiURI: this.config.apiURI,
5976
5980
  appId: this.config.appId,
5977
5981
  code: r,
@@ -6182,7 +6186,7 @@ class uo {
6182
6186
  */
6183
6187
  async exchangeCodeForToken({ code: e, codeVerifier: n }) {
6184
6188
  var o;
6185
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Kt({
6189
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await qt({
6186
6190
  apiURI: this.config.apiURI,
6187
6191
  appId: this.config.appId,
6188
6192
  code: e,
@@ -6316,7 +6320,7 @@ class uo {
6316
6320
  ur(u, l, f);
6317
6321
  break;
6318
6322
  case "r":
6319
- It(u, l, f);
6323
+ Mt(u, l, f);
6320
6324
  break;
6321
6325
  case "-":
6322
6326
  fn(u, l);
@@ -6333,7 +6337,7 @@ class uo {
6333
6337
  Object.entries(r).map(([i, o]) => [i, o.data])
6334
6338
  );
6335
6339
  this._presence = Ee(this._presence, (i) => {
6336
- It(i, [e, "result", "peers"], s);
6340
+ Mt(i, [e, "result", "peers"], s);
6337
6341
  });
6338
6342
  }
6339
6343
  // --------
@@ -6528,7 +6532,7 @@ function To(t, e) {
6528
6532
  return u();
6529
6533
  }
6530
6534
  function mo(t) {
6531
- return `${_t || Rn ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6535
+ return `${wt || Rn ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6532
6536
  }
6533
6537
  function So(t) {
6534
6538
  const e = document.createElement("iframe");
@@ -6829,14 +6833,14 @@ class Vo {
6829
6833
  });
6830
6834
  const o = !!((f = (d = (l = this.db) == null ? void 0 : l._reactor) == null ? void 0 : d.config) != null && f.schema) && ("cardinalityInference" in ((y = (p = this.db) == null ? void 0 : p._reactor) == null ? void 0 : y.config) ? !!((w = (g = this.db) == null ? void 0 : g._reactor.config) != null && w.cardinalityInference) : !0), a = new H(
6831
6835
  r.reduce((b, T) => (b[T.id] = T, b), {}),
6832
- rt((_ = this.db) == null ? void 0 : _._reactor.config.schema)
6836
+ st((_ = this.db) == null ? void 0 : _._reactor.config.schema)
6833
6837
  ), c = te(
6834
6838
  a,
6835
6839
  n,
6836
6840
  o,
6837
6841
  this.params.db._reactor.config.useDateObjects || !1
6838
6842
  );
6839
- return gt(
6843
+ return _t(
6840
6844
  {
6841
6845
  store: c,
6842
6846
  attrsStore: a,
@@ -6903,11 +6907,11 @@ function Co() {
6903
6907
  function Po() {
6904
6908
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6905
6909
  }
6906
- function st(t) {
6910
+ function it(t) {
6907
6911
  const e = t.__adminToken;
6908
6912
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6909
6913
  }
6910
- const it = Po(), en = Co();
6914
+ const ot = Po(), en = Co();
6911
6915
  class jo {
6912
6916
  constructor(e) {
6913
6917
  /**
@@ -7222,7 +7226,7 @@ class Ro {
7222
7226
  };
7223
7227
  }
7224
7228
  shutdown() {
7225
- delete it[st(this._reactor.config)], this._reactor.shutdown();
7229
+ delete ot[it(this._reactor.config)], this._reactor.shutdown();
7226
7230
  }
7227
7231
  /**
7228
7232
  * Use this for one-off queries.
@@ -7273,7 +7277,7 @@ function Uo(t, e, n, r, s) {
7273
7277
  ...t,
7274
7278
  appId: (u = t.appId) == null ? void 0 : u.trim(),
7275
7279
  useDateObjects: t.useDateObjects ?? !1
7276
- }, o = it[st(i)];
7280
+ }, o = ot[it(i)];
7277
7281
  if (o)
7278
7282
  return xo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7279
7283
  const a = new uo(
@@ -7287,7 +7291,7 @@ function Uo(t, e, n, r, s) {
7287
7291
  { ...r || {}, "@instantdb/core": Un },
7288
7292
  s
7289
7293
  ), c = new Ro(a);
7290
- return it[st(i)] = c, Lo(i.appId, i.devtool), c;
7294
+ return ot[it(i)] = c, Lo(i.appId, i.devtool), c;
7291
7295
  }
7292
7296
  function Lo(t, e) {
7293
7297
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
@@ -7325,7 +7329,7 @@ export {
7325
7329
  zo as parseSchemaFromJSON,
7326
7330
  Ko as tx,
7327
7331
  Mn as txInit,
7328
- Wt as validateQuery,
7332
+ Gt as validateQuery,
7329
7333
  Ki as validateTransactions,
7330
7334
  Un as version,
7331
7335
  C as weakHash