@instantdb/react 0.22.105 → 0.22.106-experimental.drewh-typesafe-lookup-syntax.21190204208.1

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.
@@ -1,7 +1,7 @@
1
1
  var gi = Object.defineProperty;
2
2
  var _i = (t, e, n) => e in t ? gi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
3
  var p = (t, e, n) => _i(t, typeof e != "symbol" ? e + "" : e, n);
4
- import Xr, { useRef as it, useCallback as _e, useSyncExternalStore as Xt, useEffect as Oe, useMemo as en, useState as es, createElement as wi } from "react";
4
+ import es, { useRef as it, useCallback as _e, useSyncExternalStore as en, useEffect as Oe, useMemo as tn, useState as ts, createElement as wi } from "react";
5
5
  function q(t) {
6
6
  if (typeof t == "number")
7
7
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -44,14 +44,14 @@ const U = {
44
44
  Remove: "remove",
45
45
  Replace: "replace",
46
46
  Add: "add"
47
- }, ts = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Ti = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), _t = Symbol.iterator, ne = {
47
+ }, ns = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Ti = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), _t = Symbol.iterator, ne = {
48
48
  mutable: "mutable",
49
49
  immutable: "immutable"
50
- }, Cn = {};
50
+ }, Pn = {};
51
51
  function et(t, e) {
52
52
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
53
53
  }
54
- function dr(t, e) {
54
+ function hr(t, e) {
55
55
  if (e in t) {
56
56
  let n = Reflect.getPrototypeOf(t);
57
57
  for (; n; ) {
@@ -62,10 +62,10 @@ function dr(t, e) {
62
62
  }
63
63
  }
64
64
  }
65
- function Pn(t) {
65
+ function In(t) {
66
66
  return Object.getPrototypeOf(t) === Set.prototype;
67
67
  }
68
- function In(t) {
68
+ function Mn(t) {
69
69
  return Object.getPrototypeOf(t) === Map.prototype;
70
70
  }
71
71
  function te(t) {
@@ -76,9 +76,9 @@ function Ae(t) {
76
76
  return !!P(t);
77
77
  }
78
78
  function P(t) {
79
- return typeof t != "object" ? null : t == null ? void 0 : t[ts];
79
+ return typeof t != "object" ? null : t == null ? void 0 : t[ns];
80
80
  }
81
- function Mn(t) {
81
+ function jn(t) {
82
82
  var e;
83
83
  const n = P(t);
84
84
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -89,7 +89,7 @@ function ce(t, e) {
89
89
  let n;
90
90
  return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, ne)) === ne.immutable || typeof n == "function");
91
91
  }
92
- function ns(t, e = []) {
92
+ function rs(t, e = []) {
93
93
  if (Object.hasOwnProperty.call(t, "key")) {
94
94
  const n = t.parent.copy, r = P(ye(n, t.key));
95
95
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
@@ -100,7 +100,7 @@ function ns(t, e = []) {
100
100
  e.push(i);
101
101
  }
102
102
  if (t.parent)
103
- return ns(t.parent, e);
103
+ return rs(t.parent, e);
104
104
  e.reverse();
105
105
  try {
106
106
  mi(t.copy, e);
@@ -118,14 +118,14 @@ function ye(t, e) {
118
118
  function at(t, e, n) {
119
119
  ke(t) === 2 ? t.set(e, n) : t[e] = n;
120
120
  }
121
- function Vt(t, e) {
121
+ function Bt(t, e) {
122
122
  const n = P(t);
123
123
  return (n ? te(n) : t)[e];
124
124
  }
125
125
  function pe(t, e) {
126
126
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
127
127
  }
128
- function tn(t) {
128
+ function nn(t) {
129
129
  if (t)
130
130
  for (; t.finalities.revoke.length > 0; )
131
131
  t.finalities.revoke.pop()();
@@ -161,18 +161,18 @@ function Si(t) {
161
161
  }), e;
162
162
  }
163
163
  const vi = Object.prototype.propertyIsEnumerable;
164
- function rs(t, e) {
164
+ function ss(t, e) {
165
165
  let n;
166
166
  if (Array.isArray(t))
167
167
  return Array.prototype.concat.call(t);
168
168
  if (t instanceof Set) {
169
- if (!Pn(t)) {
169
+ if (!In(t)) {
170
170
  const r = Object.getPrototypeOf(t).constructor;
171
171
  return new r(t.values());
172
172
  }
173
173
  return Set.prototype.difference ? Set.prototype.difference.call(t, /* @__PURE__ */ new Set()) : new Set(t.values());
174
174
  } else if (t instanceof Map) {
175
- if (!In(t)) {
175
+ if (!Mn(t)) {
176
176
  const r = Object.getPrototypeOf(t).constructor;
177
177
  return new r(t);
178
178
  }
@@ -197,11 +197,11 @@ function rs(t, e) {
197
197
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
198
198
  }
199
199
  function Q(t) {
200
- t.copy || (t.copy = rs(t.original, t.options));
200
+ t.copy || (t.copy = ss(t.original, t.options));
201
201
  }
202
202
  function Qe(t) {
203
203
  if (!ce(t))
204
- return Mn(t);
204
+ return jn(t);
205
205
  if (Array.isArray(t))
206
206
  return t.map(Qe);
207
207
  if (t instanceof Map) {
@@ -209,7 +209,7 @@ function Qe(t) {
209
209
  r,
210
210
  Qe(s)
211
211
  ]);
212
- if (!In(t)) {
212
+ if (!Mn(t)) {
213
213
  const r = Object.getPrototypeOf(t).constructor;
214
214
  return new r(n);
215
215
  }
@@ -217,7 +217,7 @@ function Qe(t) {
217
217
  }
218
218
  if (t instanceof Set) {
219
219
  const n = Array.from(t).map(Qe);
220
- if (!Pn(t)) {
220
+ if (!In(t)) {
221
221
  const r = Object.getPrototypeOf(t).constructor;
222
222
  return new r(n);
223
223
  }
@@ -235,7 +235,7 @@ function fe(t) {
235
235
  var e;
236
236
  t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && fe(t.parent));
237
237
  }
238
- function hr() {
238
+ function pr() {
239
239
  throw new Error("Cannot modify frozen object");
240
240
  }
241
241
  function Me(t, e, n, r, s) {
@@ -263,12 +263,12 @@ function Me(t, e, n, r, s) {
263
263
  case 2:
264
264
  for (const [a, c] of t)
265
265
  Me(a, a, n, r, s), Me(c, a, n, r, s);
266
- t.set = t.clear = t.delete = hr;
266
+ t.set = t.clear = t.delete = pr;
267
267
  break;
268
268
  case 3:
269
269
  for (const a of t)
270
270
  Me(a, a, n, r, s);
271
- t.add = t.clear = t.delete = hr;
271
+ t.add = t.clear = t.delete = pr;
272
272
  break;
273
273
  case 1:
274
274
  Object.freeze(t);
@@ -284,7 +284,7 @@ function Me(t, e, n, r, s) {
284
284
  }
285
285
  r.pop(), s.pop();
286
286
  }
287
- function jn(t, e) {
287
+ function Rn(t, e) {
288
288
  const n = ke(t);
289
289
  if (n === 0)
290
290
  Reflect.ownKeys(t).forEach((r) => {
@@ -297,11 +297,11 @@ function jn(t, e) {
297
297
  } else
298
298
  t.forEach((r, s) => e(s, r, t));
299
299
  }
300
- function ss(t, e, n) {
300
+ function is(t, e, n) {
301
301
  if (Ae(t) || !ce(t, n) || e.has(t) || Object.isFrozen(t))
302
302
  return;
303
303
  const r = t instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
304
- if (e.add(t), jn(t, (i, o) => {
304
+ if (e.add(t), Rn(t, (i, o) => {
305
305
  var a;
306
306
  if (Ae(o)) {
307
307
  const c = P(o);
@@ -309,7 +309,7 @@ function ss(t, e, n) {
309
309
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
310
310
  at(r ? s : t, i, u);
311
311
  } else
312
- ss(o, e, n);
312
+ is(o, e, n);
313
313
  }), s) {
314
314
  const i = t, o = Array.from(i);
315
315
  i.clear(), o.forEach((a) => {
@@ -319,30 +319,30 @@ function ss(t, e, n) {
319
319
  }
320
320
  function Ei(t, e) {
321
321
  const n = t.type === 3 ? t.setMap : t.copy;
322
- t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && ss(ye(n, e), t.finalities.handledSet, t.options);
322
+ t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && is(ye(n, e), t.finalities.handledSet, t.options);
323
323
  }
324
- function nn(t) {
324
+ function rn(t) {
325
325
  t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
326
- t.copy.add(Mn(e));
326
+ t.copy.add(jn(e));
327
327
  }));
328
328
  }
329
- function rn(t, e, n, r) {
329
+ function sn(t, e, n, r) {
330
330
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
331
331
  if (n && r) {
332
- const i = ns(t);
332
+ const i = rs(t);
333
333
  i && e(t, i, n, r);
334
334
  }
335
335
  t.finalized = !0;
336
336
  }
337
337
  }
338
- function Rn(t, e, n, r) {
338
+ function xn(t, e, n, r) {
339
339
  const s = P(n);
340
340
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
341
341
  var a;
342
342
  const c = t.type === 3 ? t.setMap : t.copy;
343
343
  if (pe(ye(c, e), n)) {
344
344
  let u = s.original;
345
- s.copy && (u = s.copy), nn(t), rn(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)), at(c, e, u);
345
+ s.copy && (u = s.copy), rn(t), sn(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)), at(c, e, u);
346
346
  }
347
347
  }), t.options.enableAutoFreeze && s.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ce(n, t.options) && t.finalities.draft.push(() => {
348
348
  const i = t.type === 3 ? t.setMap : t.copy;
@@ -448,10 +448,10 @@ function ot(t, e, n, r) {
448
448
  return ki(t, e, n, r, s);
449
449
  }
450
450
  }
451
- const Et = (t, e, n = !1) => {
451
+ const Ot = (t, e, n = !1) => {
452
452
  if (typeof t == "object" && t !== null && (!ce(t, e) || n))
453
453
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
454
- }, sn = {
454
+ }, on = {
455
455
  get size() {
456
456
  return te(P(this)).size;
457
457
  },
@@ -460,7 +460,7 @@ const Et = (t, e, n = !1) => {
460
460
  },
461
461
  set(t, e) {
462
462
  const n = P(this), r = te(n);
463
- return (!r.has(t) || !pe(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), Rn(n, t, e, ot)), this;
463
+ return (!r.has(t) || !pe(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), xn(n, t, e, ot)), this;
464
464
  },
465
465
  delete(t) {
466
466
  if (!this.has(t))
@@ -486,9 +486,9 @@ const Et = (t, e, n = !1) => {
486
486
  get(t) {
487
487
  var e, n;
488
488
  const r = P(this), s = te(r).get(t), i = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, s, ne)) === ne.mutable;
489
- if (r.options.strict && Et(s, r.options, i), i || r.finalized || !ce(s, r.options) || s !== r.original.get(t))
489
+ if (r.options.strict && Ot(s, r.options, i), i || r.finalized || !ce(s, r.options) || s !== r.original.get(t))
490
490
  return s;
491
- const o = Cn.createDraft({
491
+ const o = Pn.createDraft({
492
492
  original: s,
493
493
  parentDraft: r,
494
494
  key: t,
@@ -532,7 +532,7 @@ const Et = (t, e, n = !1) => {
532
532
  [_t]() {
533
533
  return this.entries();
534
534
  }
535
- }, Ci = Reflect.ownKeys(sn), pr = (t, e, { isValuesIterator: n }) => () => {
535
+ }, Ci = Reflect.ownKeys(on), yr = (t, e, { isValuesIterator: n }) => () => {
536
536
  var r, s;
537
537
  const i = e.next();
538
538
  if (i.done)
@@ -540,8 +540,8 @@ const Et = (t, e, n = !1) => {
540
540
  const o = i.value;
541
541
  let a = t.setMap.get(o);
542
542
  const c = P(a), u = ((s = (r = t.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, ne)) === ne.mutable;
543
- if (t.options.strict && Et(o, t.options, u), !u && !c && ce(o, t.options) && !t.finalized && t.original.has(o)) {
544
- const l = Cn.createDraft({
543
+ if (t.options.strict && Ot(o, t.options, u), !u && !c && ce(o, t.options) && !t.finalized && t.original.has(o)) {
544
+ const l = Pn.createDraft({
545
545
  original: o,
546
546
  parentDraft: t,
547
547
  key: o,
@@ -554,7 +554,7 @@ const Et = (t, e, n = !1) => {
554
554
  done: !1,
555
555
  value: n ? a : [a, a]
556
556
  };
557
- }, Ot = {
557
+ }, At = {
558
558
  get size() {
559
559
  return P(this).setMap.size;
560
560
  },
@@ -568,7 +568,7 @@ const Et = (t, e, n = !1) => {
568
568
  },
569
569
  add(t) {
570
570
  const e = P(this);
571
- return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), Rn(e, t, t, ot)), this;
571
+ return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), xn(e, t, t, ot)), this;
572
572
  },
573
573
  delete(t) {
574
574
  if (!this.has(t))
@@ -593,7 +593,7 @@ const Et = (t, e, n = !1) => {
593
593
  const e = t.setMap.keys();
594
594
  return {
595
595
  [Symbol.iterator]: () => this.values(),
596
- next: pr(t, e, { isValuesIterator: !0 })
596
+ next: yr(t, e, { isValuesIterator: !0 })
597
597
  };
598
598
  },
599
599
  entries() {
@@ -602,7 +602,7 @@ const Et = (t, e, n = !1) => {
602
602
  const e = t.setMap.keys();
603
603
  return {
604
604
  [Symbol.iterator]: () => this.entries(),
605
- next: pr(t, e, {
605
+ next: yr(t, e, {
606
606
  isValuesIterator: !1
607
607
  })
608
608
  };
@@ -620,7 +620,7 @@ const Et = (t, e, n = !1) => {
620
620
  t.call(e, r.value, r.value, this), r = n.next();
621
621
  }
622
622
  };
623
- Set.prototype.difference && Object.assign(Ot, {
623
+ Set.prototype.difference && Object.assign(At, {
624
624
  intersection(t) {
625
625
  return Set.prototype.intersection.call(new Set(this.values()), t);
626
626
  },
@@ -643,47 +643,47 @@ Set.prototype.difference && Object.assign(Ot, {
643
643
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
644
644
  }
645
645
  });
646
- const Pi = Reflect.ownKeys(Ot), is = /* @__PURE__ */ new WeakSet(), os = {
646
+ const Pi = Reflect.ownKeys(At), os = /* @__PURE__ */ new WeakSet(), as = {
647
647
  get(t, e, n) {
648
648
  var r, s;
649
649
  const i = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
650
- if (i && is.has(i))
650
+ if (i && os.has(i))
651
651
  return i;
652
- if (e === ts)
652
+ if (e === ns)
653
653
  return t;
654
654
  let o;
655
655
  if (t.options.mark) {
656
656
  const u = e === "size" && (t.original instanceof Map || t.original instanceof Set) ? Reflect.get(t.original, e) : Reflect.get(t.original, e, n);
657
657
  if (o = t.options.mark(u, ne), o === ne.mutable)
658
- return t.options.strict && Et(u, t.options, !0), u;
658
+ return t.options.strict && Ot(u, t.options, !0), u;
659
659
  }
660
660
  const a = te(t);
661
661
  if (a instanceof Map && Ci.includes(e)) {
662
662
  if (e === "size")
663
- return Object.getOwnPropertyDescriptor(sn, "size").get.call(t.proxy);
664
- const u = sn[e];
663
+ return Object.getOwnPropertyDescriptor(on, "size").get.call(t.proxy);
664
+ const u = on[e];
665
665
  if (u)
666
666
  return u.bind(t.proxy);
667
667
  }
668
668
  if (a instanceof Set && Pi.includes(e)) {
669
669
  if (e === "size")
670
- return Object.getOwnPropertyDescriptor(Ot, "size").get.call(t.proxy);
671
- const u = Ot[e];
670
+ return Object.getOwnPropertyDescriptor(At, "size").get.call(t.proxy);
671
+ const u = At[e];
672
672
  if (u)
673
673
  return u.bind(t.proxy);
674
674
  }
675
675
  if (!et(a, e)) {
676
- const u = dr(a, e);
676
+ const u = hr(a, e);
677
677
  return u ? "value" in u ? u.value : (
678
678
  // !case: support for getter
679
679
  (s = u.get) === null || s === void 0 ? void 0 : s.call(t.proxy)
680
680
  ) : void 0;
681
681
  }
682
682
  const c = a[e];
683
- if (t.options.strict && Et(c, t.options), t.finalized || !ce(c, t.options))
683
+ if (t.options.strict && Ot(c, t.options), t.finalized || !ce(c, t.options))
684
684
  return c;
685
- if (c === Vt(t.original, e)) {
686
- if (Q(t), t.copy[e] = xn({
685
+ if (c === Bt(t.original, e)) {
686
+ if (Q(t), t.copy[e] = $n({
687
687
  original: t.original[e],
688
688
  parentDraft: t,
689
689
  key: t.type === 1 ? Number(e) : e,
@@ -704,11 +704,11 @@ const Pi = Reflect.ownKeys(Ot), is = /* @__PURE__ */ new WeakSet(), os = {
704
704
  let s;
705
705
  if (t.type === 1 && e !== "length" && !(Number.isInteger(s = Number(e)) && s >= 0 && (e === 0 || s === 0 || String(s) === String(e))))
706
706
  throw new Error("Only supports setting array indices and the 'length' property.");
707
- const i = dr(te(t), e);
707
+ const i = hr(te(t), e);
708
708
  if (i != null && i.set)
709
709
  return i.set.call(t.proxy, n), !0;
710
- const o = Vt(te(t), e), a = P(o);
711
- return a && pe(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) : (pe(n, o) && (n !== void 0 || et(t.original, e)) || (Q(t), fe(t), et(t.original, e) && pe(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Rn(t, e, n, ot)), !0);
710
+ const o = Bt(te(t), e), a = P(o);
711
+ return a && pe(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) : (pe(n, o) && (n !== void 0 || et(t.original, e)) || (Q(t), fe(t), et(t.original, e) && pe(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, xn(t, e, n, ot)), !0);
712
712
  },
713
713
  has(t, e) {
714
714
  return e in te(t);
@@ -736,10 +736,10 @@ const Pi = Reflect.ownKeys(Ot), is = /* @__PURE__ */ new WeakSet(), os = {
736
736
  },
737
737
  deleteProperty(t, e) {
738
738
  var n;
739
- return t.type === 1 ? os.set.call(this, t, e, void 0, t.proxy) : (Vt(t.original, e) !== void 0 || e in t.original ? (Q(t), fe(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);
739
+ return t.type === 1 ? as.set.call(this, t, e, void 0, t.proxy) : (Bt(t.original, e) !== void 0 || e in t.original ? (Q(t), fe(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);
740
740
  }
741
741
  };
742
- function xn(t) {
742
+ function $n(t) {
743
743
  const { original: e, parentDraft: n, key: r, finalities: s, options: i } = t, o = ke(e), a = {
744
744
  type: o,
745
745
  finalized: !1,
@@ -753,8 +753,8 @@ function xn(t) {
753
753
  setMap: o === 3 ? new Map(e.entries()) : void 0
754
754
  };
755
755
  (r || "key" in t) && (a.key = r);
756
- const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, os);
757
- if (s.revoke.push(u), is.add(c), a.proxy = c, n) {
756
+ const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, as);
757
+ if (s.revoke.push(u), os.add(c), a.proxy = c, n) {
758
758
  const l = n;
759
759
  l.finalities.draft.push((f, h) => {
760
760
  var y, b;
@@ -763,7 +763,7 @@ function xn(t) {
763
763
  const m = ye(w, r), _ = P(m);
764
764
  if (_) {
765
765
  let S = _.original;
766
- _.operated && (S = Mn(m)), nn(_), rn(_, ot, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(S, _.original)), at(w, r, S);
766
+ _.operated && (S = jn(m)), rn(_), sn(_, ot, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(S, _.original)), at(w, r, S);
767
767
  }
768
768
  (b = g.callbacks) === null || b === void 0 || b.forEach((S) => {
769
769
  S(f, h);
@@ -772,12 +772,12 @@ function xn(t) {
772
772
  } else {
773
773
  const l = P(c);
774
774
  l.finalities.draft.push((f, h) => {
775
- nn(l), rn(l, ot, f, h);
775
+ rn(l), sn(l, ot, f, h);
776
776
  });
777
777
  }
778
778
  return c;
779
779
  }
780
- Cn.createDraft = xn;
780
+ Pn.createDraft = $n;
781
781
  function Ii(t, e, n, r, s) {
782
782
  var i;
783
783
  const o = P(t), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : t, c = !!e.length;
@@ -785,7 +785,7 @@ function Ii(t, e, n, r, s) {
785
785
  for (; o.finalities.draft.length > 0; )
786
786
  o.finalities.draft.pop()(n, r);
787
787
  const u = c ? e[0] : o ? o.operated ? o.copy : o.original : t;
788
- return o && tn(o), s && Me(u, u, o == null ? void 0 : o.options.updatedValues), [
788
+ return o && nn(o), s && Me(u, u, o == null ? void 0 : o.options.updatedValues), [
789
789
  u,
790
790
  n && c ? [{ op: U.Replace, path: [], value: e[0] }] : n,
791
791
  r && c ? [{ op: U.Replace, path: [], value: a }] : r
@@ -800,7 +800,7 @@ function Mi(t, e) {
800
800
  };
801
801
  let s, i;
802
802
  e.enablePatches && (s = [], i = []);
803
- const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ce(t, e) ? t : xn({
803
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ce(t, e) ? t : $n({
804
804
  original: t,
805
805
  parentDraft: null,
806
806
  finalities: r,
@@ -814,9 +814,9 @@ function Mi(t, e) {
814
814
  }
815
815
  ];
816
816
  }
817
- function on(t) {
817
+ function an(t) {
818
818
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: s = !0 } = t;
819
- jn(n, (i, o, a) => {
819
+ Rn(n, (i, o, a) => {
820
820
  const c = P(o);
821
821
  if (c && e && c.finalities === e.finalities) {
822
822
  t.isContainDraft = !0;
@@ -826,10 +826,10 @@ function on(t) {
826
826
  a.clear(), l.forEach((f) => a.add(i === f ? u : f));
827
827
  } else
828
828
  at(a, i, u);
829
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, on(t));
829
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, an(t));
830
830
  }), 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."));
831
831
  }
832
- function as(t) {
832
+ function cs(t) {
833
833
  var e;
834
834
  const n = P(t);
835
835
  if (!ce(t, n == null ? void 0 : n.options))
@@ -839,7 +839,7 @@ function as(t) {
839
839
  return n.original;
840
840
  let s;
841
841
  function i() {
842
- s = r === 2 ? In(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : rs(t, n == null ? void 0 : n.options);
842
+ s = r === 2 ? Mn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : ss(t, n == null ? void 0 : n.options);
843
843
  }
844
844
  if (n) {
845
845
  n.finalized = !0;
@@ -850,21 +850,21 @@ function as(t) {
850
850
  }
851
851
  } else
852
852
  s = t;
853
- if (jn(s, (o, a) => {
853
+ if (Rn(s, (o, a) => {
854
854
  if (n && pe(ye(n.original, o), a))
855
855
  return;
856
- const c = as(a);
856
+ const c = cs(a);
857
857
  c !== a && (s === t && i(), at(s, o, c));
858
858
  }), r === 3) {
859
859
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : s;
860
- return Pn(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
860
+ return In(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
861
861
  }
862
862
  return s;
863
863
  }
864
- function yr(t) {
864
+ function br(t) {
865
865
  if (!Ae(t))
866
866
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
867
- return as(t);
867
+ return cs(t);
868
868
  }
869
869
  const ji = (t) => function e(n, r, s) {
870
870
  var i, o, a;
@@ -877,7 +877,7 @@ const ji = (t) => function e(n, r, s) {
877
877
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
878
878
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
879
879
  l = Object.assign(Object.assign({}, t), l);
880
- const f = Ae(c) ? yr(c) : c, h = Array.isArray(l.mark) ? (E, j) => {
880
+ const f = Ae(c) ? br(c) : c, h = Array.isArray(l.mark) ? (E, j) => {
881
881
  for (const L of l.mark) {
882
882
  if (typeof L != "function")
883
883
  throw new Error(`Invalid mark: ${L}, 'mark' should be a function.`);
@@ -903,7 +903,7 @@ const ji = (t) => function e(n, r, s) {
903
903
  try {
904
904
  S = u(m);
905
905
  } catch (E) {
906
- throw tn(P(m)), E;
906
+ throw nn(P(m)), E;
907
907
  }
908
908
  const O = (E) => {
909
909
  const j = P(m);
@@ -913,14 +913,14 @@ const ji = (t) => function e(n, r, s) {
913
913
  const B = E == null ? void 0 : E[Ti];
914
914
  if (B) {
915
915
  const qe = B[0];
916
- return w.strict && typeof E == "object" && E !== null && on({
916
+ return w.strict && typeof E == "object" && E !== null && an({
917
917
  rootDraft: j,
918
918
  value: E,
919
919
  useRawReturn: !0
920
920
  }), _([qe]);
921
921
  }
922
922
  if (E !== void 0)
923
- return typeof E == "object" && E !== null && on({ rootDraft: j, value: E }), _([E]);
923
+ return typeof E == "object" && E !== null && an({ rootDraft: j, value: E }), _([E]);
924
924
  }
925
925
  if (E === m || E === void 0)
926
926
  return _([]);
@@ -928,26 +928,26 @@ const ji = (t) => function e(n, r, s) {
928
928
  if (w === L.options) {
929
929
  if (L.operated)
930
930
  throw new Error("Cannot return a modified child draft.");
931
- return _([yr(E)]);
931
+ return _([br(E)]);
932
932
  }
933
933
  return _([E]);
934
934
  };
935
935
  return S instanceof Promise ? S.then(O, (E) => {
936
- throw tn(P(m)), E;
936
+ throw nn(P(m)), E;
937
937
  }) : O(S);
938
- }, At = ji();
938
+ }, kt = ji();
939
939
  Object.prototype.constructor.toString();
940
- function cs(t, e) {
940
+ function us(t, e) {
941
941
  const n = Object.keys(t), r = Object.keys(e);
942
942
  return n.length === r.length && Object.keys(t).every((s) => e.hasOwnProperty(s));
943
943
  }
944
- function br(t, e) {
944
+ function gr(t, e) {
945
945
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
946
946
  }
947
947
  function Tt(t, e) {
948
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : cs(t, e) ? Object.keys(t).every((n) => Tt(t[n], e[n])) : !1;
948
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : us(t, e) ? Object.keys(t).every((n) => Tt(t[n], e[n])) : !1;
949
949
  }
950
- function $n(t) {
950
+ function Dn(t) {
951
951
  if (!He(t))
952
952
  return t;
953
953
  const e = {};
@@ -955,7 +955,7 @@ function $n(t) {
955
955
  r !== void 0 && (e[n] = r);
956
956
  return e;
957
957
  }
958
- function us(t, e) {
958
+ function ls(t, e) {
959
959
  if (!He(t) || !He(e))
960
960
  return e;
961
961
  const n = { ...t };
@@ -967,7 +967,7 @@ function us(t, e) {
967
967
  continue;
968
968
  }
969
969
  const s = He(t[r]) && He(e[r]);
970
- n[r] = s ? us(t[r], e[r]) : e[r];
970
+ n[r] = s ? ls(t[r], e[r]) : e[r];
971
971
  }
972
972
  return n;
973
973
  }
@@ -985,7 +985,7 @@ function Ri(t, e, n) {
985
985
  const s = e[e.length - 1];
986
986
  Array.isArray(r) && typeof s == "number" ? r.splice(s, 0, n) : r[s] = n;
987
987
  }
988
- function gr(t, e, n) {
988
+ function _r(t, e, n) {
989
989
  if (!t || e.length === 0)
990
990
  return;
991
991
  let r = t || {};
@@ -995,7 +995,7 @@ function gr(t, e, n) {
995
995
  }
996
996
  r[e[e.length - 1]] = n;
997
997
  }
998
- function ls(t, e) {
998
+ function fs(t, e) {
999
999
  if (!t || e.length === 0)
1000
1000
  return;
1001
1001
  const [n, ...r] = e;
@@ -1004,13 +1004,13 @@ function ls(t, e) {
1004
1004
  Array.isArray(t) ? t.splice(n, 1) : delete t[n];
1005
1005
  return;
1006
1006
  }
1007
- ls(t[n], r), xi(t[n]) && delete t[n];
1007
+ fs(t[n], r), xi(t[n]) && delete t[n];
1008
1008
  }
1009
1009
  }
1010
1010
  function xi(t) {
1011
1011
  return t && Object.keys(t).length === 0;
1012
1012
  }
1013
- const _r = /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$/, $i = {
1013
+ const wr = /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$/, $i = {
1014
1014
  ZULU: 0,
1015
1015
  YEKT: 18e3,
1016
1016
  YEKST: 21600,
@@ -1274,10 +1274,10 @@ function Gi(t) {
1274
1274
  }
1275
1275
  }
1276
1276
  function Qi(t) {
1277
- const e = t.match(_r);
1277
+ const e = t.match(wr);
1278
1278
  if (!e)
1279
1279
  return null;
1280
- const [n] = e, r = $i[n], s = new Date(t.replace(_r, "Z"));
1280
+ const [n] = e, r = $i[n], s = new Date(t.replace(wr, "Z"));
1281
1281
  return new Date(s.getTime() - r * 1e3);
1282
1282
  }
1283
1283
  const Hi = [
@@ -1302,7 +1302,7 @@ function Ji(t, e) {
1302
1302
  return null;
1303
1303
  }
1304
1304
  }
1305
- function an(t) {
1305
+ function cn(t) {
1306
1306
  for (const e of Hi) {
1307
1307
  const n = Ji(e, t);
1308
1308
  if (n)
@@ -1313,19 +1313,19 @@ function an(t) {
1313
1313
  function Yi(t) {
1314
1314
  try {
1315
1315
  const e = JSON.parse(t);
1316
- return typeof e == "string" ? an(e) : null;
1316
+ return typeof e == "string" ? cn(e) : null;
1317
1317
  } catch {
1318
1318
  return null;
1319
1319
  }
1320
1320
  }
1321
- function It(t) {
1321
+ function Mt(t) {
1322
1322
  if (t !== void 0) {
1323
1323
  if (t === null)
1324
1324
  return null;
1325
1325
  if (t instanceof Date)
1326
1326
  return t;
1327
1327
  if (typeof t == "string") {
1328
- const e = an(t) || Yi(t) || an(t.trim());
1328
+ const e = cn(t) || Yi(t) || cn(t.trim());
1329
1329
  if (!e)
1330
1330
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1331
1331
  return e;
@@ -1365,7 +1365,7 @@ class Ee {
1365
1365
  return this._blobAttrs;
1366
1366
  this._blobAttrs = /* @__PURE__ */ new Map();
1367
1367
  for (const e of Object.values(this.attrs))
1368
- if (Un(e)) {
1368
+ if (Ln(e)) {
1369
1369
  const [n, r, s] = e["forward-identity"];
1370
1370
  Z(this.blobAttrs, [r, s], e);
1371
1371
  }
@@ -1412,10 +1412,10 @@ class Ee {
1412
1412
  function Zi(t) {
1413
1413
  return t.cardinality === "one";
1414
1414
  }
1415
- function Dn(t) {
1415
+ function Un(t) {
1416
1416
  return t["value-type"] === "ref";
1417
1417
  }
1418
- function Un(t) {
1418
+ function Ln(t) {
1419
1419
  return t["value-type"] === "blob";
1420
1420
  }
1421
1421
  function Ke(t, e) {
@@ -1441,7 +1441,7 @@ function Z(t, e, n) {
1441
1441
  }
1442
1442
  s > -1 && r.set(e[s], n);
1443
1443
  }
1444
- function fs(t, e, n) {
1444
+ function ds(t, e, n) {
1445
1445
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1446
1446
  for (const o of e) {
1447
1447
  let [a, c, u] = o;
@@ -1450,11 +1450,11 @@ function fs(t, e, n) {
1450
1450
  console.warn("no such attr", c, a);
1451
1451
  continue;
1452
1452
  }
1453
- l["checked-data-type"] === "date" && n && (u = It(u), o[2] = u), Dn(l) && Z(i, [u, c, a], o), Z(r, [a, c, u], o), Z(s, [c, a, u], o);
1453
+ l["checked-data-type"] === "date" && n && (u = Mt(u), o[2] = u), Un(l) && Z(i, [u, c, a], o), Z(r, [a, c, u], o), Z(s, [c, a, u], o);
1454
1454
  }
1455
1455
  return { eav: r, aev: s, vae: i };
1456
1456
  }
1457
- function ds(t) {
1457
+ function hs(t) {
1458
1458
  return {
1459
1459
  triples: X(t.eav, 3),
1460
1460
  cardinalityInference: t.cardinalityInference,
@@ -1462,10 +1462,10 @@ function ds(t) {
1462
1462
  version: 1
1463
1463
  };
1464
1464
  }
1465
- function hs(t, e) {
1465
+ function ps(t, e) {
1466
1466
  return Je(t, e.triples, e.cardinalityInference, e.useDateObjects);
1467
1467
  }
1468
- function ps(t, e) {
1468
+ function ys(t, e) {
1469
1469
  if (t)
1470
1470
  return new Ee(t.attrs, t.linkIndex);
1471
1471
  if (e && "__type" in e)
@@ -1475,7 +1475,7 @@ function Xi(t, e) {
1475
1475
  return Ke(t.eav, [e]) !== void 0;
1476
1476
  }
1477
1477
  function Je(t, e, n, r) {
1478
- const s = fs(t, e, r);
1478
+ const s = ds(t, e, r);
1479
1479
  return s.cardinalityInference = n, s.useDateObjects = r, s;
1480
1480
  }
1481
1481
  function ct(t, e) {
@@ -1505,21 +1505,21 @@ function ct(t, e) {
1505
1505
  return [n, ...a];
1506
1506
  }
1507
1507
  }
1508
- function ys(t, e, n) {
1508
+ function bs(t, e, n) {
1509
1509
  const r = ct(t, n);
1510
1510
  if (!r)
1511
1511
  return;
1512
1512
  const [s, i, o] = r, a = e.getAttr(i);
1513
- a && (ae(t.eav, [s, i, o]), ae(t.aev, [i, s, o]), Dn(a) && ae(t.vae, [o, i, s]));
1513
+ a && (ae(t.eav, [s, i, o]), ae(t.aev, [i, s, o]), Un(a) && ae(t.vae, [o, i, s]));
1514
1514
  }
1515
1515
  let eo = 0;
1516
- function bs(t, e, n) {
1516
+ function gs(t, e, n) {
1517
1517
  const [r, s, i] = n;
1518
1518
  let o;
1519
1519
  const a = Ke(t.eav, [r, s, i]);
1520
1520
  return a && (o = a[3]), o || Date.now() * 10 + eo++;
1521
1521
  }
1522
- function gs(t, e, n) {
1522
+ function _s(t, e, n) {
1523
1523
  const r = ct(t, n);
1524
1524
  if (!r)
1525
1525
  return;
@@ -1527,9 +1527,9 @@ function gs(t, e, n) {
1527
1527
  const a = e.getAttr(i);
1528
1528
  if (!a)
1529
1529
  return;
1530
- a["checked-data-type"] === "date" && t.useDateObjects && (o = It(o));
1531
- const c = Ke(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? bs(t, a, r), l = [s, i, o, u];
1532
- Zi(a) ? (Z(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), Z(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (Z(t.eav, [s, i, o], l), Z(t.aev, [i, s, o], l)), Dn(a) && Z(t.vae, [o, i, s], l);
1530
+ a["checked-data-type"] === "date" && t.useDateObjects && (o = Mt(o));
1531
+ const c = Ke(t.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? gs(t, a, r), l = [s, i, o, u];
1532
+ Zi(a) ? (Z(t.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), Z(t.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (Z(t.eav, [s, i, o], l), Z(t.aev, [i, s, o], l)), Un(a) && Z(t.vae, [o, i, s], l);
1533
1533
  }
1534
1534
  function to(t, e, n) {
1535
1535
  var y;
@@ -1539,7 +1539,7 @@ function to(t, e, n) {
1539
1539
  const [s, i, o] = r, a = e.getAttr(i);
1540
1540
  if (!a)
1541
1541
  return;
1542
- if (!Un(a))
1542
+ if (!Ln(a))
1543
1543
  throw new Error("merge operation is not supported for links");
1544
1544
  const c = Ke(t.eav, [s, i]);
1545
1545
  if (!c)
@@ -1547,15 +1547,15 @@ function to(t, e, n) {
1547
1547
  const u = (y = c.values().next()) == null ? void 0 : y.value;
1548
1548
  if (!u)
1549
1549
  return;
1550
- const l = u[2], f = us(l, o), h = [
1550
+ const l = u[2], f = ls(l, o), h = [
1551
1551
  s,
1552
1552
  i,
1553
1553
  f,
1554
- bs(t, a, u)
1554
+ gs(t, a, u)
1555
1555
  ];
1556
1556
  Z(t.eav, [s, i], /* @__PURE__ */ new Map([[f, h]])), Z(t.aev, [i, s], /* @__PURE__ */ new Map([[f, h]]));
1557
1557
  }
1558
- function cn(t, e, n) {
1558
+ function un(t, e, n) {
1559
1559
  var u, l;
1560
1560
  const [r, s] = n, i = ct(t, [r]);
1561
1561
  if (!i)
@@ -1566,7 +1566,7 @@ function cn(t, e, n) {
1566
1566
  const h = e.getAttr(f);
1567
1567
  h && h["on-delete-reverse"] === "cascade" && X(a.get(f), 1).forEach(([y, b, g]) => {
1568
1568
  var w;
1569
- return cn(t, e, [g, (w = h["reverse-identity"]) == null ? void 0 : w[1]]);
1569
+ return un(t, e, [g, (w = h["reverse-identity"]) == null ? void 0 : w[1]]);
1570
1570
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1571
1571
  // the store that didn't set `etype` in deleteEntity
1572
1572
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -1579,11 +1579,11 @@ function cn(t, e, n) {
1579
1579
  c && c.forEach((f) => {
1580
1580
  var w, m, _;
1581
1581
  const [h, y, b] = f, g = e.getAttr(y);
1582
- (!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ae(t.eav, [h, y, b]), ae(t.aev, [y, h, b]), ae(t.vae, [b, y, h])), g && g["on-delete"] === "cascade" && ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s && cn(t, e, [h, (_ = g["forward-identity"]) == null ? void 0 : _[1]]);
1582
+ (!s || !g || ((w = g["reverse-identity"]) == null ? void 0 : w[1]) === s) && (ae(t.eav, [h, y, b]), ae(t.aev, [y, h, b]), ae(t.vae, [b, y, h])), g && g["on-delete"] === "cascade" && ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s && un(t, e, [h, (_ = g["forward-identity"]) == null ? void 0 : _[1]]);
1583
1583
  }), ((l = t.vae.get(o)) == null ? void 0 : l.size) === 0 && ae(t.vae, [o]);
1584
1584
  }
1585
- function _s(t, e, n) {
1586
- const r = fs(e, n, t.useDateObjects);
1585
+ function ws(t, e, n) {
1586
+ const r = ds(e, n, t.useDateObjects);
1587
1587
  Object.keys(r).forEach((s) => {
1588
1588
  t[s] = r[s];
1589
1589
  });
@@ -1591,32 +1591,32 @@ function _s(t, e, n) {
1591
1591
  function no(t, [e]) {
1592
1592
  t.addAttr(e);
1593
1593
  }
1594
- function ws(t) {
1594
+ function Ts(t) {
1595
1595
  return X(t.eav, 3);
1596
1596
  }
1597
1597
  function ro(t, e, [n]) {
1598
1598
  if (!e.getAttr(n))
1599
1599
  return;
1600
- const r = ws(t).filter(([s, i]) => i !== n);
1601
- e.deleteAttr(n), _s(t, e, r);
1600
+ const r = Ts(t).filter(([s, i]) => i !== n);
1601
+ e.deleteAttr(n), ws(t, e, r);
1602
1602
  }
1603
1603
  function so(t, e, [n]) {
1604
- e.getAttr(n.id) && (e.updateAttr(n), _s(t, e, ws(t)));
1604
+ e.getAttr(n.id) && (e.updateAttr(n), ws(t, e, Ts(t)));
1605
1605
  }
1606
1606
  function io(t, e, n) {
1607
1607
  const [r, ...s] = n;
1608
1608
  switch (r) {
1609
1609
  case "add-triple":
1610
- gs(t, e, s);
1610
+ _s(t, e, s);
1611
1611
  break;
1612
1612
  case "deep-merge-triple":
1613
1613
  to(t, e, s);
1614
1614
  break;
1615
1615
  case "retract-triple":
1616
- ys(t, e, s);
1616
+ bs(t, e, s);
1617
1617
  break;
1618
1618
  case "delete-entity":
1619
- cn(t, e, s);
1619
+ un(t, e, s);
1620
1620
  break;
1621
1621
  case "add-attr":
1622
1622
  no(e, s);
@@ -1755,7 +1755,7 @@ function Ce(t, e, n) {
1755
1755
  function uo(t, e) {
1756
1756
  return t.blobAttrs.get(e);
1757
1757
  }
1758
- function Ts(t, e) {
1758
+ function ms(t, e) {
1759
1759
  var r;
1760
1760
  const n = t.primaryKeys.get(e);
1761
1761
  return n || ((r = t.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
@@ -1778,7 +1778,7 @@ function fo(t, e, n) {
1778
1778
  let l = !1;
1779
1779
  const f = e.getAttr(o);
1780
1780
  if (f) {
1781
- const h = Ts(e, f["forward-identity"][1]);
1781
+ const h = ms(e, f["forward-identity"][1]);
1782
1782
  l = !!lo(t, e, [
1783
1783
  i,
1784
1784
  h == null ? void 0 : h.id,
@@ -1787,7 +1787,7 @@ function fo(t, e, n) {
1787
1787
  }
1788
1788
  return !(u === "create" && l || u === "update" && !l);
1789
1789
  });
1790
- return At({ store: t, attrsStore: e }, (s) => {
1790
+ return kt({ store: t, attrsStore: e }, (s) => {
1791
1791
  r.forEach((i) => {
1792
1792
  io(s.store, s.attrsStore, i);
1793
1793
  });
@@ -1804,19 +1804,19 @@ function ho(t) {
1804
1804
  function po(t, e, n) {
1805
1805
  if (n.hasOwnProperty(t)) {
1806
1806
  const r = n[t];
1807
- return ms(r, e, n);
1807
+ return Ss(r, e, n);
1808
1808
  }
1809
1809
  return { ...n, [t]: e };
1810
1810
  }
1811
- function wr(t, e, n) {
1811
+ function Tr(t, e, n) {
1812
1812
  return t === e ? n : null;
1813
1813
  }
1814
1814
  function yo(t) {
1815
1815
  switch (typeof t) {
1816
1816
  case "string":
1817
- return t.startsWith("?") ? po : wr;
1817
+ return t.startsWith("?") ? po : Tr;
1818
1818
  default:
1819
- return wr;
1819
+ return Tr;
1820
1820
  }
1821
1821
  }
1822
1822
  const bo = [
@@ -1833,32 +1833,32 @@ function go(t) {
1833
1833
  return !0;
1834
1834
  return !1;
1835
1835
  }
1836
- function ms(t, e, n) {
1836
+ function Ss(t, e, n) {
1837
1837
  return n ? typeof t == "object" ? go(t) ? n : null : yo(t)(t, e, n) : null;
1838
1838
  }
1839
1839
  function _o(t, e, n) {
1840
1840
  return t.reduce((r, s, i) => {
1841
1841
  const o = e[i];
1842
- return ms(s, o, r);
1842
+ return Ss(s, o, r);
1843
1843
  }, n);
1844
1844
  }
1845
1845
  function wo(t, e, n) {
1846
1846
  return So(t, e, n).map((r) => _o(e, r, n)).filter((r) => r);
1847
1847
  }
1848
1848
  function To(t, e, n) {
1849
- return e.or ? e.or.patterns.flatMap((r) => un(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => un(t, s, r), n) : n.flatMap((r) => wo(t, e, r));
1849
+ return e.or ? e.or.patterns.flatMap((r) => ln(t, r, n)) : e.and ? e.and.patterns.reduce((r, s) => ln(t, s, r), n) : n.flatMap((r) => wo(t, e, r));
1850
1850
  }
1851
- function un(t, e, n = [{}]) {
1851
+ function ln(t, e, n = [{}]) {
1852
1852
  return e.reduce((r, s) => To(t, s, r), n);
1853
1853
  }
1854
- function Ln(t, e) {
1855
- return Array.isArray(e) ? e.map((n) => Ln(t, n)) : ho(e) ? t[e] : e;
1854
+ function Fn(t, e) {
1855
+ return Array.isArray(e) ? e.map((n) => Fn(t, n)) : ho(e) ? t[e] : e;
1856
1856
  }
1857
1857
  function mo(t, { find: e, where: n }) {
1858
- return un(t, n).map((s) => Ln(s, e));
1858
+ return ln(t, n).map((s) => Fn(s, e));
1859
1859
  }
1860
1860
  function So(t, e, n) {
1861
- return ao(t, Ln(n, e));
1861
+ return ao(t, Fn(n, e));
1862
1862
  }
1863
1863
  const vo = /^(?:[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;
1864
1864
  function Le(t) {
@@ -1870,28 +1870,28 @@ for (let t = 0; t < 256; ++t)
1870
1870
  function Eo(t, e = 0) {
1871
1871
  return (z[t[e + 0]] + z[t[e + 1]] + z[t[e + 2]] + z[t[e + 3]] + "-" + z[t[e + 4]] + z[t[e + 5]] + "-" + z[t[e + 6]] + z[t[e + 7]] + "-" + z[t[e + 8]] + z[t[e + 9]] + "-" + z[t[e + 10]] + z[t[e + 11]] + z[t[e + 12]] + z[t[e + 13]] + z[t[e + 14]] + z[t[e + 15]]).toLowerCase();
1872
1872
  }
1873
- let Bt;
1873
+ let Gt;
1874
1874
  const Oo = new Uint8Array(16);
1875
1875
  function Ao() {
1876
- if (!Bt) {
1876
+ if (!Gt) {
1877
1877
  if (typeof crypto > "u" || !crypto.getRandomValues)
1878
1878
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1879
- Bt = crypto.getRandomValues.bind(crypto);
1879
+ Gt = crypto.getRandomValues.bind(crypto);
1880
1880
  }
1881
- return Bt(Oo);
1881
+ return Gt(Oo);
1882
1882
  }
1883
- const ko = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Tr = { randomUUID: ko };
1883
+ const ko = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), mr = { randomUUID: ko };
1884
1884
  function Co(t, e, n) {
1885
1885
  var s;
1886
- if (Tr.randomUUID && !t)
1887
- return Tr.randomUUID();
1886
+ if (mr.randomUUID && !t)
1887
+ return mr.randomUUID();
1888
1888
  t = t || {};
1889
1889
  const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Ao();
1890
1890
  if (r.length < 16)
1891
1891
  throw new Error("Random bytes length must be >= 16");
1892
1892
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Eo(r);
1893
1893
  }
1894
- function mr(t) {
1894
+ function Sr(t) {
1895
1895
  const e = t.replace(/-/g, ""), n = [];
1896
1896
  for (let r = 0; r < e.length; r += 2)
1897
1897
  n.push(parseInt(e.substring(r, r + 2), 16));
@@ -1907,7 +1907,7 @@ function Po(t, e) {
1907
1907
  return 0;
1908
1908
  }
1909
1909
  function Io(t, e) {
1910
- return Po(mr(t), mr(e));
1910
+ return Po(Sr(t), Sr(e));
1911
1911
  }
1912
1912
  function W() {
1913
1913
  return Co();
@@ -1927,9 +1927,9 @@ function jo() {
1927
1927
  const Ro = jo();
1928
1928
  let xo = 0;
1929
1929
  function tt(t) {
1930
- return Mt(`_${t}`, xo++);
1930
+ return jt(`_${t}`, xo++);
1931
1931
  }
1932
- function Mt(t, e) {
1932
+ function jt(t, e) {
1933
1933
  return `?${t}-${e}`;
1934
1934
  }
1935
1935
  class Fe extends Error {
@@ -1938,12 +1938,12 @@ class Fe extends Error {
1938
1938
  }
1939
1939
  }
1940
1940
  function $o(t, e) {
1941
- const n = Ts(t, e);
1941
+ const n = ms(t, e);
1942
1942
  if (!n)
1943
1943
  throw new Fe(`Could not find id attr for ${e}`);
1944
1944
  return n;
1945
1945
  }
1946
- function Sr(t, e, n, r) {
1946
+ function vr(t, e, n, r) {
1947
1947
  return [Do(t, e, n, r)];
1948
1948
  }
1949
1949
  function Do(t, e, n, r) {
@@ -1957,7 +1957,7 @@ function Do(t, e, n, r) {
1957
1957
  function Uo(t, e, n) {
1958
1958
  return t.map((r) => r === e ? n : r);
1959
1959
  }
1960
- function Ss(t, e, n, r, s) {
1960
+ function vs(t, e, n, r, s) {
1961
1961
  const i = N(e, n, s), o = Ce(e, n, s), a = i || o;
1962
1962
  if (!a)
1963
1963
  throw new Fe(`Could not find attr for ${[n, s]}`);
@@ -1976,7 +1976,7 @@ function Ss(t, e, n, r, s) {
1976
1976
  ];
1977
1977
  return [i ? f : u, h, y, a, !!i];
1978
1978
  }
1979
- function vr(t, e) {
1979
+ function Er(t, e) {
1980
1980
  if (typeof e != "string")
1981
1981
  return function(o) {
1982
1982
  return !1;
@@ -2027,7 +2027,7 @@ function Lo(t, e) {
2027
2027
  }
2028
2028
  };
2029
2029
  if (e.hasOwnProperty("$like")) {
2030
- const r = vr(!0, e.$like);
2030
+ const r = Er(!0, e.$like);
2031
2031
  return {
2032
2032
  $comparator: !0,
2033
2033
  $op: function(i) {
@@ -2036,7 +2036,7 @@ function Lo(t, e) {
2036
2036
  };
2037
2037
  }
2038
2038
  if (e.hasOwnProperty("$ilike")) {
2039
- const r = vr(!1, e.$ilike);
2039
+ const r = Er(!1, e.$ilike);
2040
2040
  return {
2041
2041
  $comparator: !0,
2042
2042
  $op: function(i) {
@@ -2070,12 +2070,12 @@ function Fo(t, e, n, r, s, i) {
2070
2070
  }
2071
2071
  function No(t, e, n, r, s) {
2072
2072
  const [i, o, a] = s.reduce((c, u) => {
2073
- const [l, f, h] = c, [y, b, g] = Ss(t, e, l, f, u);
2073
+ const [l, f, h] = c, [y, b, g] = vs(t, e, l, f, u);
2074
2074
  return [y, b, [...h, g]];
2075
2075
  }, [n, r, []]);
2076
2076
  return [i, o, a];
2077
2077
  }
2078
- function ln(t, e, n, r, s, i) {
2078
+ function fn(t, e, n, r, s, i) {
2079
2079
  const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = No(t, e, n, r, o), f = Fo(t, e, c, u, a, i);
2080
2080
  return l.concat([f]);
2081
2081
  }
@@ -2094,10 +2094,10 @@ function zo(t, e, n) {
2094
2094
  return e == i ? i : `${i}-${n}`;
2095
2095
  };
2096
2096
  }
2097
- function Er(t, e, n, r, s, i) {
2097
+ function Or(t, e, n, r, s, i) {
2098
2098
  const o = t(r, s), a = i.map((c, u) => {
2099
2099
  const l = zo(t, o, u);
2100
- return vs(l, n, r, s, c);
2100
+ return Es(l, n, r, s, c);
2101
2101
  });
2102
2102
  return { [e]: { patterns: a, joinSym: o } };
2103
2103
  }
@@ -2107,22 +2107,22 @@ function Vo(t) {
2107
2107
  e.push(t.slice(0, n));
2108
2108
  return e;
2109
2109
  }
2110
- function Or(t, e, n, r, s) {
2111
- return Vo(s).map((i) => ln(t, e, n, r, i, {
2110
+ function Ar(t, e, n, r, s) {
2111
+ return Vo(s).map((i) => fn(t, e, n, r, i, {
2112
2112
  $isNull: !0
2113
2113
  }));
2114
2114
  }
2115
- function vs(t, e, n, r, s) {
2115
+ function Es(t, e, n, r, s) {
2116
2116
  return Object.entries(s).flatMap(([i, o]) => {
2117
2117
  if (qo([i, o]))
2118
- return Er(t, "or", e, n, r, o);
2118
+ return Or(t, "or", e, n, r, o);
2119
2119
  if (Wo([i, o]))
2120
- return Er(t, "and", e, n, r, o);
2120
+ return Or(t, "and", e, n, r, o);
2121
2121
  if (i === "$entityIdStartsWith")
2122
2122
  return [];
2123
2123
  const a = i.split(".");
2124
2124
  if (o != null && o.hasOwnProperty("$ne") && (o = { ...o, $not: o.$ne }, delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2125
- const c = ln(t, e, n, r, a, o), u = Or(t, e, n, r, a);
2125
+ const c = fn(t, e, n, r, a, o), u = Ar(t, e, n, r, a);
2126
2126
  return [
2127
2127
  {
2128
2128
  or: {
@@ -2135,22 +2135,22 @@ function vs(t, e, n, r, s) {
2135
2135
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2136
2136
  {
2137
2137
  or: {
2138
- patterns: Or(t, e, n, r, a),
2138
+ patterns: Ar(t, e, n, r, a),
2139
2139
  joinSym: t(n, r)
2140
2140
  }
2141
2141
  }
2142
- ] : ln(t, e, n, r, a, o);
2142
+ ] : fn(t, e, n, r, a, o);
2143
2143
  });
2144
2144
  }
2145
2145
  function Bo(t, e, n, r) {
2146
- const s = Mt;
2147
- return r ? vs(s, t, e, n, r).concat(Sr(s, t, e, n)) : Sr(s, t, e, n);
2146
+ const s = jt;
2147
+ return r ? Es(s, t, e, n, r).concat(vr(s, t, e, n)) : vr(s, t, e, n);
2148
2148
  }
2149
2149
  function Go(t, e, n) {
2150
2150
  return [t(e, n), t("time", n)];
2151
2151
  }
2152
2152
  function Qo(t, e, n, r, s, i) {
2153
- const [o, a, c, u, l] = Ss(t, e, n, r, s), f = Uo(c, t(n, r), i);
2153
+ const [o, a, c, u, l] = vs(t, e, n, r, s), f = Uo(c, t(n, r), i);
2154
2154
  return [o, a, f, u, l];
2155
2155
  }
2156
2156
  function Ho(t, e, n, { etype: r, level: s, form: i }, o) {
@@ -2160,7 +2160,7 @@ function Ho(t, e, n, { etype: r, level: s, form: i }, o) {
2160
2160
  var g, w, m;
2161
2161
  const b = !!(e.cardinalityInference && ((m = (w = (g = n.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : w[y]) != null && m.isSingular));
2162
2162
  try {
2163
- const [_, S, O] = Qo(t, n, r, s, y, u), E = Os(e, n, {
2163
+ const [_, S, O] = Qo(t, n, r, s, y, u), E = As(e, n, {
2164
2164
  etype: _,
2165
2165
  level: S,
2166
2166
  form: i[y],
@@ -2183,19 +2183,19 @@ function Jo(t, e, n) {
2183
2183
  function Ye(t, e, n, r, s) {
2184
2184
  return e === r || e == null && r == null ? Io(t, n) : r == null ? 1 : e == null ? -1 : Jo(e, r, s);
2185
2185
  }
2186
- function kt([t, e], [n, r], s) {
2186
+ function Ct([t, e], [n, r], s) {
2187
2187
  return Ye(t, e, n, r, s);
2188
2188
  }
2189
- function fn(t) {
2189
+ function dn(t) {
2190
2190
  return t == null ? t : new Date(t).getTime();
2191
2191
  }
2192
2192
  function Yo(t, e, n, r) {
2193
2193
  var b;
2194
2194
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2195
2195
  if (((b = e["forward-identity"]) == null ? void 0 : b[2]) === "id")
2196
- return kt(r, [s, a], null) === c;
2197
- const [u, l] = r, f = e["checked-data-type"], h = f === "date" ? fn(l) : l, y = f === "date" ? fn(o) : o;
2198
- return kt([u, h], [s, y], f) === c;
2196
+ return Ct(r, [s, a], null) === c;
2197
+ const [u, l] = r, f = e["checked-data-type"], h = f === "date" ? dn(l) : l, y = f === "date" ? dn(o) : o;
2198
+ return Ct([u, h], [s, y], f) === c;
2199
2199
  }
2200
2200
  function Zo(t, e) {
2201
2201
  const n = e[1];
@@ -2218,7 +2218,7 @@ function ta(t, e, n) {
2218
2218
  const r = /* @__PURE__ */ new Map();
2219
2219
  for (const o of n.fields) {
2220
2220
  const a = N(t, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
2221
- c && Un(a) && r.set(c, a);
2221
+ c && Ln(a) && r.set(c, a);
2222
2222
  }
2223
2223
  if (!r.has("id")) {
2224
2224
  const o = N(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) == null ? void 0 : i[2];
@@ -2228,7 +2228,7 @@ function ta(t, e, n) {
2228
2228
  }
2229
2229
  function na(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2230
2230
  var b, g;
2231
- const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = Es(i), c = ra(i);
2231
+ const o = (b = i == null ? void 0 : i.$) == null ? void 0 : b.order, a = Os(i), c = ra(i);
2232
2232
  let u = mo(t, s);
2233
2233
  const l = r == null ? void 0 : r["start-cursor"], f = ea(e, n, l, o);
2234
2234
  if (f && ((g = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : g[2]) !== "id") {
@@ -2236,13 +2236,13 @@ function na(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2236
2236
  u = u.map(([_]) => {
2237
2237
  var O, E, j, L, B;
2238
2238
  let S = (B = (L = (j = (E = (O = t.eav.get(_)) == null ? void 0 : O.get(m)) == null ? void 0 : E.values()) == null ? void 0 : j.next()) == null ? void 0 : L.value) == null ? void 0 : B[2];
2239
- return w && (S = fn(S)), [_, S];
2239
+ return w && (S = dn(S)), [_, S];
2240
2240
  });
2241
2241
  }
2242
2242
  u.sort(c === "asc" ? function(m, _) {
2243
- return kt(m, _, f == null ? void 0 : f["checked-data-type"]);
2243
+ return Ct(m, _, f == null ? void 0 : f["checked-data-type"]);
2244
2244
  } : function(m, _) {
2245
- return kt(_, m, f == null ? void 0 : f["checked-data-type"]);
2245
+ return Ct(_, m, f == null ? void 0 : f["checked-data-type"]);
2246
2246
  });
2247
2247
  let h = {};
2248
2248
  const y = ta(e, n, s);
@@ -2260,16 +2260,16 @@ function ra(t) {
2260
2260
  const e = (n = t.$) == null ? void 0 : n.order;
2261
2261
  return e && e[Object.keys(e)[0]] || "asc";
2262
2262
  }
2263
- function Es(t) {
2263
+ function Os(t) {
2264
2264
  var s, i, o;
2265
2265
  const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
2266
2266
  return !e && !n && !r;
2267
2267
  }
2268
2268
  function sa(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2269
2269
  var h, y, b, g, w;
2270
- if (!Es(s) && (!o || !o["start-cursor"]))
2270
+ if (!Os(s) && (!o || !o["start-cursor"]))
2271
2271
  return [];
2272
- const a = Ko(Bo(e, n, r, (h = s.$) == null ? void 0 : h.where), i), c = Go(Mt, n, r), u = (y = s.$) == null ? void 0 : y.fields, l = na(t, e, {
2272
+ const a = Ko(Bo(e, n, r, (h = s.$) == null ? void 0 : h.where), i), c = Go(jt, n, r), u = (y = s.$) == null ? void 0 : y.fields, l = na(t, e, {
2273
2273
  etype: n,
2274
2274
  pageInfo: o,
2275
2275
  form: s,
@@ -2291,9 +2291,9 @@ function ia(t, e, n) {
2291
2291
  throw r;
2292
2292
  }
2293
2293
  }
2294
- function Os(t, e, n) {
2294
+ function As(t, e, n) {
2295
2295
  const r = ia(t, e, n);
2296
- return Ho(Mt, t, e, n, r);
2296
+ return Ho(jt, t, e, n, r);
2297
2297
  }
2298
2298
  function oa(t) {
2299
2299
  const e = {};
@@ -2306,9 +2306,9 @@ function oa(t) {
2306
2306
  };
2307
2307
  return e;
2308
2308
  }
2309
- function As({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, s) {
2309
+ function ks({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, s) {
2310
2310
  const o = { data: Object.keys(s).reduce(function(c, u) {
2311
- return r != null && r[u] || u === "$$ruleParams" || (c[u] = Os(t, e, {
2311
+ return r != null && r[u] || u === "$$ruleParams" || (c[u] = As(t, e, {
2312
2312
  etype: u,
2313
2313
  form: s[u],
2314
2314
  level: 0,
@@ -2332,7 +2332,7 @@ function aa() {
2332
2332
  return new Set(Object.keys(e));
2333
2333
  }
2334
2334
  const ca = aa();
2335
- function dn(t, e, n) {
2335
+ function mt(t, e, n) {
2336
2336
  const r = {
2337
2337
  __etype: t,
2338
2338
  __ops: n
@@ -2344,47 +2344,49 @@ function dn(t, e, n) {
2344
2344
  if (i === "__etype")
2345
2345
  return t;
2346
2346
  if (ca.has(i))
2347
- return (o, a) => dn(t, e, [
2347
+ return (o, a) => mt(t, e, [
2348
2348
  ...n,
2349
2349
  a ? [i, t, e, o, a] : [i, t, e, o]
2350
2350
  ]);
2351
2351
  }
2352
2352
  });
2353
2353
  }
2354
- function Iu(t, e) {
2354
+ function ua(t, e) {
2355
2355
  return `lookup__${t}__${JSON.stringify(e)}`;
2356
2356
  }
2357
- function Ct(t) {
2357
+ function Pt(t) {
2358
2358
  return t.startsWith("lookup__");
2359
2359
  }
2360
- function ks(t) {
2360
+ function hn(t) {
2361
2361
  const [e, n, ...r] = t.split("__");
2362
2362
  return [n, JSON.parse(r.join("__"))];
2363
2363
  }
2364
- function ua(t) {
2364
+ function la(t) {
2365
2365
  return new Proxy({
2366
2366
  __etype: t
2367
2367
  }, {
2368
2368
  get(e, n) {
2369
+ if (n === "lookup")
2370
+ return (s, i) => mt(t, hn(ua(s, i)), []);
2369
2371
  if (n === "__etype")
2370
2372
  return t;
2371
2373
  const r = n;
2372
- return Ct(r) ? dn(t, ks(r), []) : dn(t, r, []);
2374
+ return Pt(r) ? mt(t, hn(r), []) : mt(t, r, []);
2373
2375
  }
2374
2376
  });
2375
2377
  }
2376
- function Fn() {
2378
+ function Nn() {
2377
2379
  return new Proxy({}, {
2378
2380
  get(t, e) {
2379
- return ua(e);
2381
+ return la(e);
2380
2382
  }
2381
2383
  });
2382
2384
  }
2383
- const Mu = Fn();
2384
- function la(t) {
2385
+ const Mu = Nn();
2386
+ function fa(t) {
2385
2387
  return t.__ops;
2386
2388
  }
2387
- function fa(t, e) {
2389
+ function da(t, e) {
2388
2390
  const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
2389
2391
  for (const o of e) {
2390
2392
  const a = n[o];
@@ -2403,7 +2405,7 @@ function fa(t, e) {
2403
2405
  }
2404
2406
  return s;
2405
2407
  }
2406
- function da(t) {
2408
+ function ha(t) {
2407
2409
  if (Array.isArray(t))
2408
2410
  return t;
2409
2411
  const e = Object.entries(t);
@@ -2411,33 +2413,33 @@ function da(t) {
2411
2413
  throw new Error("lookup must be an object with a single unique attr and value.");
2412
2414
  return e[0];
2413
2415
  }
2414
- function ha(t, e, n) {
2416
+ function pa(t, e, n) {
2415
2417
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2416
2418
  // before assuming it's a ref lookup.
2417
2419
  !N(t, e, n);
2418
2420
  }
2419
- function hn(t) {
2421
+ function pn(t) {
2420
2422
  const [e, n, ...r] = t.split(".");
2421
2423
  if (r.length > 0 || n !== "id")
2422
2424
  throw new Error(`${t} is not a valid lookup attribute.`);
2423
2425
  return e;
2424
2426
  }
2425
- function pa(t, e, n) {
2426
- if (!ha(t, e, n))
2427
+ function ya(t, e, n) {
2428
+ if (!pa(t, e, n))
2427
2429
  return N(t, e, n);
2428
- const r = hn(n), s = N(t, e, r) || Ce(t, e, r);
2430
+ const r = pn(n), s = N(t, e, r) || Ce(t, e, r);
2429
2431
  if (s && s["value-type"] !== "ref")
2430
2432
  throw new Error(`${n} does not reference a valid link attribute.`);
2431
2433
  return s;
2432
2434
  }
2433
- function pn(t) {
2434
- return typeof t == "string" && !Ct(t) ? null : typeof t == "string" && Ct(t) ? ks(t) : da(t);
2435
+ function yn(t) {
2436
+ return typeof t == "string" && !Pt(t) ? null : typeof t == "string" && Pt(t) ? hn(t) : ha(t);
2435
2437
  }
2436
2438
  function ee(t, e, n) {
2437
- const r = pn(n);
2439
+ const r = yn(n);
2438
2440
  if (r === null)
2439
2441
  return n;
2440
- const [s, i] = r, o = pa(t, e, s);
2442
+ const [s, i] = r, o = ya(t, e, s);
2441
2443
  if (!o || !o["unique?"])
2442
2444
  throw new Error(`${s} is not a unique attribute.`);
2443
2445
  return [o.id, i];
@@ -2452,7 +2454,7 @@ function Cs(t, e, n, r) {
2452
2454
  s
2453
2455
  ]].concat(r) : r;
2454
2456
  }
2455
- function ya({ attrsStore: t }, [e, n, r]) {
2457
+ function ba({ attrsStore: t }, [e, n, r]) {
2456
2458
  const s = Object.entries(r).flatMap(([i, o]) => {
2457
2459
  const a = Array.isArray(o) ? o : [o], c = N(t, e, i), u = Ce(t, e, i);
2458
2460
  return a.map((l) => c ? [
@@ -2473,7 +2475,7 @@ function ya({ attrsStore: t }, [e, n, r]) {
2473
2475
  });
2474
2476
  return Cs(t, e, n, s);
2475
2477
  }
2476
- function ba({ attrsStore: t }, [e, n, r]) {
2478
+ function ga({ attrsStore: t }, [e, n, r]) {
2477
2479
  const s = Object.entries(r).flatMap(([i, o]) => {
2478
2480
  const a = Array.isArray(o) ? o : [o], c = N(t, e, i), u = Ce(t, e, i);
2479
2481
  return a.map((l) => c ? [
@@ -2494,7 +2496,7 @@ function ba({ attrsStore: t }, [e, n, r]) {
2494
2496
  });
2495
2497
  return Cs(t, e, n, s);
2496
2498
  }
2497
- function ga(t, e, n, r) {
2499
+ function _a(t, e, n, r) {
2498
2500
  var s;
2499
2501
  if (Array.isArray(r)) {
2500
2502
  const [i, o] = r;
@@ -2518,20 +2520,20 @@ function ga(t, e, n, r) {
2518
2520
  return !1;
2519
2521
  }
2520
2522
  function Ps({ stores: t, attrsStore: e }, [n, r, s, i]) {
2521
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : ga(t, e, n, r) ? { mode: "update" } : null;
2523
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : _a(t, e, n, r) ? { mode: "update" } : null;
2522
2524
  }
2523
- function _a(t, e) {
2524
- const { attrsStore: n } = t, [r, s, i, o] = e, a = $n(i), c = ee(n, r, s);
2525
+ function wa(t, e) {
2526
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = Dn(i), c = ee(n, r, s);
2525
2527
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
2526
2528
  const h = N(n, r, l);
2527
- return h["checked-data-type"] === "date" && t.useDateObjects && (f = It(f)), ["add-triple", c, h.id, f, { mode: "create" }];
2529
+ return h["checked-data-type"] === "date" && t.useDateObjects && (f = Mt(f)), ["add-triple", c, h.id, f, { mode: "create" }];
2528
2530
  });
2529
2531
  }
2530
- function wa(t, e) {
2531
- const { attrsStore: n } = t, [r, s, i, o] = e, a = $n(i), c = ee(n, r, s), u = Ps(t, [r, c, i, o]);
2532
+ function Ta(t, e) {
2533
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = Dn(i), c = ee(n, r, s), u = Ps(t, [r, c, i, o]);
2532
2534
  return [["id", c]].concat(Object.entries(a)).map(([f, h]) => {
2533
2535
  const y = N(n, r, f);
2534
- return y["checked-data-type"] === "date" && t.useDateObjects && (h = It(h)), [
2536
+ return y["checked-data-type"] === "date" && t.useDateObjects && (h = Mt(h)), [
2535
2537
  "add-triple",
2536
2538
  c,
2537
2539
  y.id,
@@ -2540,11 +2542,11 @@ function wa(t, e) {
2540
2542
  ];
2541
2543
  });
2542
2544
  }
2543
- function Ta({ attrsStore: t }, [e, n]) {
2545
+ function ma({ attrsStore: t }, [e, n]) {
2544
2546
  return [["delete-entity", ee(t, e, n), e]];
2545
2547
  }
2546
- function ma(t, e) {
2547
- const { attrsStore: n } = t, [r, s, i, o] = e, a = $n(i), c = ee(n, r, s), u = Ps(t, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
2548
+ function Sa(t, e) {
2549
+ const { attrsStore: n } = t, [r, s, i, o] = e, a = Dn(i), c = ee(n, r, s), u = Ps(t, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
2548
2550
  const b = N(n, r, h);
2549
2551
  return [
2550
2552
  "deep-merge-triple",
@@ -2562,38 +2564,38 @@ function ma(t, e) {
2562
2564
  ...u ? [u] : []
2563
2565
  ]].concat(l);
2564
2566
  }
2565
- function Sa({ attrsStore: t }, [e, n, r]) {
2567
+ function va({ attrsStore: t }, [e, n, r]) {
2566
2568
  return [["rule-params", ee(t, e, n), e, r]];
2567
2569
  }
2568
- function va(t) {
2570
+ function Ea(t) {
2569
2571
  const [e, n, r, s, i] = t;
2570
2572
  if (!s)
2571
2573
  return t;
2572
2574
  const o = { ...s };
2573
2575
  return delete o.id, [e, n, r, o, ...i ? [i] : []];
2574
2576
  }
2575
- function Ea(t, e) {
2576
- const [n, ...r] = va(e);
2577
+ function Oa(t, e) {
2578
+ const [n, ...r] = Ea(e);
2577
2579
  switch (n) {
2578
2580
  case "merge":
2579
- return ma(t, r);
2581
+ return Sa(t, r);
2580
2582
  case "create":
2581
- return _a(t, r);
2582
- case "update":
2583
2583
  return wa(t, r);
2584
+ case "update":
2585
+ return Ta(t, r);
2584
2586
  case "link":
2585
- return ya(t, r);
2586
- case "unlink":
2587
2587
  return ba(t, r);
2588
+ case "unlink":
2589
+ return ga(t, r);
2588
2590
  case "delete":
2589
- return Ta(t, r);
2591
+ return ma(t, r);
2590
2592
  case "ruleParams":
2591
- return Sa(t, r);
2593
+ return va(t, r);
2592
2594
  default:
2593
2595
  throw new Error(`unsupported action ${n}`);
2594
2596
  }
2595
2597
  }
2596
- function Oa(t) {
2598
+ function Aa(t) {
2597
2599
  switch (t) {
2598
2600
  case "string":
2599
2601
  case "date":
@@ -2604,14 +2606,14 @@ function Oa(t) {
2604
2606
  return;
2605
2607
  }
2606
2608
  }
2607
- function Aa(t, e, n) {
2609
+ function ka(t, e, n) {
2608
2610
  var a, c;
2609
2611
  const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
2610
2612
  if (n === "id")
2611
2613
  return null;
2612
2614
  if (!r)
2613
2615
  throw new Error(`${e}.${n} does not exist in your schema`);
2614
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Oa(r == null ? void 0 : r.valueType);
2616
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Aa(r == null ? void 0 : r.valueType);
2615
2617
  return {
2616
2618
  "index?": i,
2617
2619
  "unique?": s,
@@ -2619,7 +2621,7 @@ function Aa(t, e, n) {
2619
2621
  };
2620
2622
  }
2621
2623
  function yt(t, e, n, r) {
2622
- const s = t ? Aa(t, e, n) : null, i = W(), a = [W(), e, n];
2624
+ const s = t ? ka(t, e, n) : null, i = W(), a = [W(), e, n];
2623
2625
  return {
2624
2626
  id: i,
2625
2627
  "forward-identity": a,
@@ -2632,11 +2634,11 @@ function yt(t, e, n, r) {
2632
2634
  ...r || {}
2633
2635
  };
2634
2636
  }
2635
- function ka(t, e, n) {
2637
+ function Ca(t, e, n) {
2636
2638
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2637
2639
  }
2638
- function Ca(t, e, n) {
2639
- const r = ka(t, e, n);
2640
+ function Pa(t, e, n) {
2641
+ const r = Ca(t, e, n);
2640
2642
  if (!r)
2641
2643
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2642
2644
  const { forward: s, reverse: i } = r;
@@ -2649,8 +2651,8 @@ function Ca(t, e, n) {
2649
2651
  "on-delete-reverse": i.onDelete
2650
2652
  };
2651
2653
  }
2652
- function Ar(t, e, n, r) {
2653
- const s = t ? Ca(t, e, n) : null, i = W(), o = [W(), e, n], a = [W(), n, e];
2654
+ function kr(t, e, n, r) {
2655
+ const s = t ? Pa(t, e, n) : null, i = W(), o = [W(), e, n], a = [W(), n, e];
2654
2656
  return {
2655
2657
  id: i,
2656
2658
  // @ts-ignore: ts thinks it's any[]
@@ -2667,7 +2669,7 @@ function Ar(t, e, n, r) {
2667
2669
  ...r || {}
2668
2670
  };
2669
2671
  }
2670
- const Pa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Ia = /* @__PURE__ */ new Set(["link", "unlink"]), Ma = /* @__PURE__ */ new Set(["create", "update", "merge"]), ja = /* @__PURE__ */ new Set([
2672
+ const Ia = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Ma = /* @__PURE__ */ new Set(["link", "unlink"]), ja = /* @__PURE__ */ new Set(["create", "update", "merge"]), Ra = /* @__PURE__ */ new Set([
2671
2673
  "link",
2672
2674
  "unlink",
2673
2675
  "create",
@@ -2675,20 +2677,20 @@ const Pa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2675
2677
  "merge",
2676
2678
  "delete",
2677
2679
  "ruleParams"
2678
- ]), yn = { "unique?": !0, "index?": !0 }, Ra = {
2679
- ...yn,
2680
+ ]), bn = { "unique?": !0, "index?": !0 }, xa = {
2681
+ ...bn,
2680
2682
  cardinality: "one"
2681
2683
  };
2682
- function xa(t) {
2684
+ function $a(t) {
2683
2685
  const e = [], [n, r, s, i] = t;
2684
- if (!ja.has(n))
2686
+ if (!Ra.has(n))
2685
2687
  return e;
2686
- const o = pn(s);
2688
+ const o = yn(s);
2687
2689
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2688
2690
  for (const [a, c] of Object.entries(i)) {
2689
2691
  const u = Array.isArray(c) ? c : [c];
2690
2692
  for (const l of u) {
2691
- const f = pn(l);
2693
+ const f = yn(l);
2692
2694
  f && e.push({
2693
2695
  etype: r,
2694
2696
  lookupPair: f,
@@ -2698,7 +2700,7 @@ function xa(t) {
2698
2700
  }
2699
2701
  return e;
2700
2702
  }
2701
- function $a({ attrsStore: t, schema: e }, n) {
2703
+ function Da({ attrsStore: t, schema: e }, n) {
2702
2704
  var h, y;
2703
2705
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2704
2706
  function o(b, g) {
@@ -2723,10 +2725,10 @@ function $a({ attrsStore: t, schema: e }, n) {
2723
2725
  }
2724
2726
  function f(b, g) {
2725
2727
  const w = o(b, g), m = a(b, g);
2726
- u(w), u(m), !w && !m && c(Ar(e, b, g, Ra));
2728
+ u(w), u(m), !w && !m && c(kr(e, b, g, xa));
2727
2729
  }
2728
2730
  for (const b of n)
2729
- for (const { etype: g, lookupPair: w, linkLabel: m } of xa(b)) {
2731
+ for (const { etype: g, lookupPair: w, linkLabel: m } of $a(b)) {
2730
2732
  const _ = w[0];
2731
2733
  if (m) {
2732
2734
  f(g, m);
@@ -2734,28 +2736,28 @@ function $a({ attrsStore: t, schema: e }, n) {
2734
2736
  u(S), u(O);
2735
2737
  const E = ((h = S == null ? void 0 : S["reverse-identity"]) == null ? void 0 : h[1]) || ((y = O == null ? void 0 : O["forward-identity"]) == null ? void 0 : y[1]) || m;
2736
2738
  if (l(E, _))
2737
- f(E, hn(_));
2739
+ f(E, pn(_));
2738
2740
  else {
2739
2741
  const j = o(E, _);
2740
- j || c(yt(e, E, _, yn)), u(j);
2742
+ j || c(yt(e, E, _, bn)), u(j);
2741
2743
  }
2742
2744
  } else if (l(g, _))
2743
- f(g, hn(_));
2745
+ f(g, pn(_));
2744
2746
  else {
2745
2747
  const S = o(g, _);
2746
- S || c(yt(e, g, _, yn)), u(S);
2748
+ S || c(yt(e, g, _, bn)), u(S);
2747
2749
  }
2748
2750
  }
2749
2751
  for (const b of n) {
2750
2752
  const [g, w, m, _] = b;
2751
- if (Pa.has(g)) {
2753
+ if (Ia.has(g)) {
2752
2754
  const S = o(w, "id");
2753
2755
  u(S), S || c(yt(e, w, "id", { "unique?": !0 }));
2754
2756
  for (const O of Object.keys(_)) {
2755
2757
  const E = o(w, O);
2756
- if (u(E), Ma.has(g) && (E || c(yt(e, w, O, O === "id" ? { "unique?": !0 } : null))), Ia.has(g)) {
2758
+ if (u(E), ja.has(g) && (E || c(yt(e, w, O, O === "id" ? { "unique?": !0 } : null))), Ma.has(g)) {
2757
2759
  const j = a(w, O);
2758
- !E && !j && c(Ar(e, w, O)), u(j);
2760
+ !E && !j && c(kr(e, w, O)), u(j);
2759
2761
  }
2760
2762
  }
2761
2763
  }
@@ -2768,19 +2770,19 @@ function $a({ attrsStore: t, schema: e }, n) {
2768
2770
  }
2769
2771
  return [t, i];
2770
2772
  }
2771
- function Da(t, e) {
2772
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => la(c)), [s, i] = $a(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Ea(o, c));
2773
+ function Ua(t, e) {
2774
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => fa(c)), [s, i] = Da(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Oa(o, c));
2773
2775
  return [...i, ...a];
2774
2776
  }
2775
- function kr(t, e) {
2777
+ function Cr(t, e) {
2776
2778
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2777
2779
  }
2778
2780
  const nt = "__meta";
2779
- class Ua {
2781
+ class La {
2780
2782
  constructor(e, n) {
2781
2783
  }
2782
2784
  }
2783
- class bn {
2785
+ class gn {
2784
2786
  constructor(e) {
2785
2787
  p(this, "currentValue");
2786
2788
  p(this, "_subs", []);
@@ -2973,7 +2975,7 @@ class bn {
2973
2975
  gc() {
2974
2976
  this._nextGc || (this._nextGc = setTimeout(
2975
2977
  () => {
2976
- kr(() => {
2978
+ Cr(() => {
2977
2979
  this._nextGc = null, this._gc();
2978
2980
  }, 30 * 1e3);
2979
2981
  },
@@ -2988,7 +2990,7 @@ class bn {
2988
2990
  return;
2989
2991
  }
2990
2992
  this._nextSave = setTimeout(() => {
2991
- kr(() => {
2993
+ Cr(() => {
2992
2994
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
2993
2995
  }, this._idleCallbackMaxWaitMs);
2994
2996
  }, this._saveThrottleMs);
@@ -3002,7 +3004,7 @@ class bn {
3002
3004
  // so that we know which entries we need to persist to the store.
3003
3005
  updateInPlace(e) {
3004
3006
  this._version++;
3005
- const [n, r] = At(this.currentValue, e, {
3007
+ const [n, r] = kt(this.currentValue, e, {
3006
3008
  enablePatches: !0
3007
3009
  });
3008
3010
  for (const s of r) {
@@ -3020,13 +3022,13 @@ class bn {
3020
3022
  };
3021
3023
  }
3022
3024
  }
3023
- const La = 6, Fa = ["kv", "querySubs", "syncSubs"];
3024
- function Na(t) {
3025
+ const Fa = 6, Na = ["kv", "querySubs", "syncSubs"];
3026
+ function Ka(t) {
3025
3027
  return function(n) {
3026
3028
  console.error("Error in IndexedDB event", { source: t, event: n });
3027
3029
  };
3028
3030
  }
3029
- async function Ka(t) {
3031
+ async function qa(t) {
3030
3032
  return new Promise((e) => {
3031
3033
  const n = indexedDB.open(t);
3032
3034
  n.onerror = (r) => {
@@ -3040,7 +3042,7 @@ async function Ka(t) {
3040
3042
  };
3041
3043
  });
3042
3044
  }
3043
- async function qa(t, e, n) {
3045
+ async function Wa(t, e, n) {
3044
3046
  const r = (
3045
3047
  // Backwards compatibility for older versions where we JSON.stringified before storing
3046
3048
  typeof e == "string" ? JSON.parse(e) : e
@@ -3074,14 +3076,14 @@ async function qa(t, e, n) {
3074
3076
  };
3075
3077
  });
3076
3078
  }
3077
- async function Cr(t, e, n) {
3079
+ async function Pr(t, e, n) {
3078
3080
  const r = n.put(e, t);
3079
3081
  return new Promise((s, i) => {
3080
3082
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3081
3083
  });
3082
3084
  }
3083
- async function Wa(t, e) {
3084
- const n = await Ka(`instant_${t}_5`);
3085
+ async function za(t, e) {
3086
+ const n = await qa(`instant_${t}_5`);
3085
3087
  if (!n)
3086
3088
  return;
3087
3089
  const r = await new Promise((l, f) => {
@@ -3104,12 +3106,12 @@ async function Wa(t, e) {
3104
3106
  for (const [l, f] of r)
3105
3107
  switch (l) {
3106
3108
  case "querySubs": {
3107
- const h = qa(l, f, o);
3109
+ const h = Wa(l, f, o);
3108
3110
  a.push(h);
3109
3111
  break;
3110
3112
  }
3111
3113
  default: {
3112
- const h = Cr(l, f, i);
3114
+ const h = Pr(l, f, i);
3113
3115
  a.push(h);
3114
3116
  const y = {
3115
3117
  createdAt: Date.now(),
@@ -3120,13 +3122,13 @@ async function Wa(t, e) {
3120
3122
  break;
3121
3123
  }
3122
3124
  }
3123
- const u = Cr(nt, c, i);
3125
+ const u = Pr(nt, c, i);
3124
3126
  a.push(u), await Promise.all(a), await new Promise((l, f) => {
3125
3127
  s.oncomplete = (h) => l(h), s.onerror = (h) => f(h), s.onabort = (h) => f(h);
3126
3128
  });
3127
3129
  }
3128
- const Pr = /* @__PURE__ */ new Map();
3129
- class Is extends Ua {
3130
+ const Ir = /* @__PURE__ */ new Map();
3131
+ class Is extends La {
3130
3132
  constructor(n, r) {
3131
3133
  super(n, r);
3132
3134
  p(this, "dbName");
@@ -3134,7 +3136,7 @@ class Is extends Ua {
3134
3136
  p(this, "_appId");
3135
3137
  p(this, "_prefix");
3136
3138
  p(this, "_dbPromise");
3137
- this.dbName = `instant_${n}_${La}`, this._storeName = r, this._appId = n, this._dbPromise = this._init();
3139
+ this.dbName = `instant_${n}_${Fa}`, this._storeName = r, this._appId = n, this._dbPromise = this._init();
3138
3140
  }
3139
3141
  _init() {
3140
3142
  return new Promise((n, r) => {
@@ -3145,12 +3147,12 @@ class Is extends Ua {
3145
3147
  }, i.onsuccess = (o) => {
3146
3148
  const c = o.target.result;
3147
3149
  if (s) {
3148
- const u = Wa(this._appId, c).catch((l) => {
3149
- Na("Error upgrading store from version 5 to 6.")(l);
3150
+ const u = za(this._appId, c).catch((l) => {
3151
+ Ka("Error upgrading store from version 5 to 6.")(l);
3150
3152
  });
3151
- Pr.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
3153
+ Ir.set(this.dbName, u), u.then(() => n(c)).catch(() => n(c));
3152
3154
  } else {
3153
- const u = Pr.get(this.dbName);
3155
+ const u = Ir.get(this.dbName);
3154
3156
  u ? u.then(() => n(c)).catch(() => n(c)) : n(c);
3155
3157
  }
3156
3158
  }, i.onupgradeneeded = (o) => {
@@ -3160,7 +3162,7 @@ class Is extends Ua {
3160
3162
  }
3161
3163
  _upgradeStore(n) {
3162
3164
  const s = n.target.result;
3163
- for (const i of Fa)
3165
+ for (const i of Na)
3164
3166
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3165
3167
  }
3166
3168
  async getItem(n) {
@@ -3252,7 +3254,7 @@ class Ne extends Error {
3252
3254
  return "InstantError";
3253
3255
  }
3254
3256
  }
3255
- class jt extends Ne {
3257
+ class Rt extends Ne {
3256
3258
  constructor(n) {
3257
3259
  var i;
3258
3260
  const r = ((i = n.body) == null ? void 0 : i.message) || `API Error (${n.status})`;
@@ -3260,7 +3262,7 @@ class jt extends Ne {
3260
3262
  p(this, "body");
3261
3263
  p(this, "status");
3262
3264
  const s = new.target.prototype;
3263
- Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, jt), this.name = "InstantAPIError", this.status = n.status, this.body = n.body;
3265
+ Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Rt), this.name = "InstantAPIError", this.status = n.status, this.body = n.body;
3264
3266
  }
3265
3267
  get [Symbol.toStringTag]() {
3266
3268
  return "InstantAPIError";
@@ -3268,16 +3270,16 @@ class jt extends Ne {
3268
3270
  }
3269
3271
  async function ue(t, e) {
3270
3272
  const n = await fetch(t, e), r = await n.json();
3271
- return n.status === 200 ? Promise.resolve(r) : Promise.reject(new jt({ status: n.status, body: r }));
3273
+ return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Rt({ status: n.status, body: r }));
3272
3274
  }
3273
- function za({ apiURI: t, appId: e, email: n }) {
3275
+ function Va({ apiURI: t, appId: e, email: n }) {
3274
3276
  return ue(`${t}/runtime/auth/send_magic_code`, {
3275
3277
  method: "POST",
3276
3278
  headers: { "content-type": "application/json" },
3277
3279
  body: JSON.stringify({ "app-id": e, email: n })
3278
3280
  });
3279
3281
  }
3280
- async function Va({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3282
+ async function Ba({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3281
3283
  return await ue(`${t}/runtime/auth/verify_magic_code`, {
3282
3284
  method: "POST",
3283
3285
  headers: { "content-type": "application/json" },
@@ -3289,7 +3291,7 @@ async function Va({ apiURI: t, appId: e, email: n, code: r, refreshToken: s }) {
3289
3291
  })
3290
3292
  });
3291
3293
  }
3292
- async function Ba({ apiURI: t, appId: e, refreshToken: n }) {
3294
+ async function Ga({ apiURI: t, appId: e, refreshToken: n }) {
3293
3295
  return await ue(`${t}/runtime/auth/verify_refresh_token`, {
3294
3296
  method: "POST",
3295
3297
  headers: { "content-type": "application/json" },
@@ -3299,7 +3301,7 @@ async function Ba({ apiURI: t, appId: e, refreshToken: n }) {
3299
3301
  })
3300
3302
  });
3301
3303
  }
3302
- async function Ga({ apiURI: t, appId: e }) {
3304
+ async function Qa({ apiURI: t, appId: e }) {
3303
3305
  return await ue(`${t}/runtime/auth/sign_in_guest`, {
3304
3306
  method: "POST",
3305
3307
  headers: { "content-type": "application/json" },
@@ -3308,7 +3310,7 @@ async function Ga({ apiURI: t, appId: e }) {
3308
3310
  })
3309
3311
  });
3310
3312
  }
3311
- async function Ir({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken: s }) {
3313
+ async function Mr({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken: s }) {
3312
3314
  return await ue(`${t}/runtime/oauth/token`, {
3313
3315
  method: "POST",
3314
3316
  headers: { "content-type": "application/json" },
@@ -3320,7 +3322,7 @@ async function Ir({ apiURI: t, appId: e, code: n, codeVerifier: r, refreshToken:
3320
3322
  })
3321
3323
  });
3322
3324
  }
3323
- async function Qa({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i }) {
3325
+ async function Ha({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, refreshToken: i }) {
3324
3326
  return await ue(`${t}/runtime/oauth/id_token`, {
3325
3327
  method: "POST",
3326
3328
  headers: { "content-type": "application/json" },
@@ -3333,7 +3335,7 @@ async function Qa({ apiURI: t, appId: e, nonce: n, idToken: r, clientName: s, re
3333
3335
  })
3334
3336
  });
3335
3337
  }
3336
- async function Ha({ apiURI: t, appId: e, refreshToken: n }) {
3338
+ async function Ja({ apiURI: t, appId: e, refreshToken: n }) {
3337
3339
  return await ue(`${t}/runtime/signout`, {
3338
3340
  method: "POST",
3339
3341
  headers: {
@@ -3345,7 +3347,7 @@ async function Ha({ apiURI: t, appId: e, refreshToken: n }) {
3345
3347
  })
3346
3348
  });
3347
3349
  }
3348
- async function Ja({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
3350
+ async function Ya({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
3349
3351
  const a = {
3350
3352
  app_id: e,
3351
3353
  path: n,
@@ -3358,7 +3360,7 @@ async function Ja({ apiURI: t, appId: e, path: n, file: r, refreshToken: s, cont
3358
3360
  body: r
3359
3361
  });
3360
3362
  }
3361
- async function Ya({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3363
+ async function Za({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3362
3364
  const { data: s } = await ue(`${t}/storage/files?app_id=${e}&filename=${encodeURIComponent(n)}`, {
3363
3365
  method: "DELETE",
3364
3366
  headers: {
@@ -3368,7 +3370,7 @@ async function Ya({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3368
3370
  });
3369
3371
  return s;
3370
3372
  }
3371
- async function Za({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
3373
+ async function Xa({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata: s = {} }) {
3372
3374
  const { data: i } = await ue(`${t}/storage/signed-upload-url`, {
3373
3375
  method: "POST",
3374
3376
  headers: {
@@ -3382,7 +3384,7 @@ async function Za({ apiURI: t, appId: e, fileName: n, refreshToken: r, metadata:
3382
3384
  });
3383
3385
  return i;
3384
3386
  }
3385
- async function Xa(t, e) {
3387
+ async function ec(t, e) {
3386
3388
  return (await fetch(t, {
3387
3389
  method: "PUT",
3388
3390
  body: e,
@@ -3391,7 +3393,7 @@ async function Xa(t, e) {
3391
3393
  }
3392
3394
  })).ok;
3393
3395
  }
3394
- async function ec({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3396
+ async function tc({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3395
3397
  const { data: s } = await ue(`${t}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(n)}`, {
3396
3398
  method: "GET",
3397
3399
  headers: {
@@ -3401,9 +3403,9 @@ async function ec({ apiURI: t, appId: e, path: n, refreshToken: r }) {
3401
3403
  });
3402
3404
  return s;
3403
3405
  }
3404
- let Nn = !1, js = !1, Rs = !1;
3405
- typeof window < "u" && typeof window.localStorage < "u" && (Nn = !!window.localStorage.getItem("devBackend"), js = !!window.localStorage.getItem("__instantLogging"), Rs = !!window.localStorage.getItem("__devtoolLocalDash"));
3406
- function Mr(t, e) {
3406
+ let Kn = !1, js = !1, Rs = !1;
3407
+ typeof window < "u" && typeof window.localStorage < "u" && (Kn = !!window.localStorage.getItem("devBackend"), js = !!window.localStorage.getItem("__instantLogging"), Rs = !!window.localStorage.getItem("__devtoolLocalDash"));
3408
+ function jr(t, e) {
3407
3409
  if (!e)
3408
3410
  return t;
3409
3411
  const n = {};
@@ -3411,32 +3413,32 @@ function Mr(t, e) {
3411
3413
  n[r] = t[r];
3412
3414
  }), n;
3413
3415
  }
3414
- function tc(t, e, n) {
3416
+ function nc(t, e, n) {
3415
3417
  const r = {
3416
3418
  peers: {}
3417
3419
  };
3418
3420
  if (e && "user" in e ? e.user : !0) {
3419
- const i = Mr(t.user ?? {}, e == null ? void 0 : e.keys);
3421
+ const i = jr(t.user ?? {}, e == null ? void 0 : e.keys);
3420
3422
  r.user = { ...i, peerId: n };
3421
3423
  }
3422
3424
  for (const i of Object.keys(t.peers ?? {})) {
3423
3425
  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));
3424
3426
  if (o || a) {
3425
- const c = Mr(t.peers[i], e == null ? void 0 : e.keys);
3427
+ const c = jr(t.peers[i], e == null ? void 0 : e.keys);
3426
3428
  r.peers[i] = { ...c, peerId: i };
3427
3429
  }
3428
3430
  }
3429
3431
  return r;
3430
3432
  }
3431
- function nc(t, e) {
3432
- if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !br(t.user, e.user)) || !cs(t.peers, e.peers))
3433
+ function rc(t, e) {
3434
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !gr(t.user, e.user)) || !us(t.peers, e.peers))
3433
3435
  return !0;
3434
3436
  for (const r of Object.keys(t.peers))
3435
- if (!br(t.peers[r], e.peers[r]))
3437
+ if (!gr(t.peers[r], e.peers[r]))
3436
3438
  return !0;
3437
3439
  return !1;
3438
3440
  }
3439
- class jr {
3441
+ class Rr {
3440
3442
  constructor() {
3441
3443
  p(this, "promise");
3442
3444
  p(this, "_resolve");
@@ -3461,11 +3463,11 @@ function xs(t, e = []) {
3461
3463
  xs(n["child-nodes"], e);
3462
3464
  });
3463
3465
  }
3464
- function Rr(t) {
3466
+ function xr(t) {
3465
3467
  const e = [];
3466
3468
  return xs(t, e), e;
3467
3469
  }
3468
- function xr(t) {
3470
+ function $r(t) {
3469
3471
  return Object.values(t.links).reduce((e, n) => {
3470
3472
  var r, s;
3471
3473
  return e[r = n.forward.on] ?? (e[r] = {}), e[n.forward.on][n.forward.label] = {
@@ -3479,8 +3481,8 @@ function xr(t) {
3479
3481
  }, e;
3480
3482
  }, {});
3481
3483
  }
3482
- const Kn = "v0.22.105";
3483
- function rc(t, e) {
3484
+ const qn = "v0.22.106-experimental.drewh-typesafe-lookup-syntax.21190204208.1";
3485
+ function sc(t, e) {
3484
3486
  return {
3485
3487
  info: t ? (...n) => console.info(...n, e()) : () => {
3486
3488
  },
@@ -3523,17 +3525,17 @@ class H {
3523
3525
  });
3524
3526
  }
3525
3527
  }
3526
- class Rt {
3528
+ class xt {
3527
3529
  constructor(e, n) {
3528
3530
  p(this, "attrs");
3529
3531
  p(this, "links");
3530
3532
  this.attrs = e, this.links = n;
3531
3533
  }
3532
3534
  asType() {
3533
- return new Rt(this.attrs, this.links);
3535
+ return new xt(this.attrs, this.links);
3534
3536
  }
3535
3537
  }
3536
- class xt {
3538
+ class $t {
3537
3539
  constructor(e, n, r) {
3538
3540
  p(this, "entities");
3539
3541
  p(this, "links");
@@ -3560,7 +3562,7 @@ class xt {
3560
3562
  * @see https://instantdb.com/docs/presence-and-topics#typesafety
3561
3563
  */
3562
3564
  withRoomSchema() {
3563
- return new xt(this.entities, this.links, {});
3565
+ return new $t(this.entities, this.links, {});
3564
3566
  }
3565
3567
  }
3566
3568
  class x extends Error {
@@ -3569,7 +3571,7 @@ class x extends Error {
3569
3571
  super(r), this.name = "QueryValidationError";
3570
3572
  }
3571
3573
  }
3572
- const $r = [
3574
+ const Dr = [
3573
3575
  "where",
3574
3576
  "order",
3575
3577
  "limit",
@@ -3580,7 +3582,7 @@ const $r = [
3580
3582
  "before",
3581
3583
  "fields",
3582
3584
  "aggregate"
3583
- ], sc = (t) => t.valueType || "unknown", $s = (t, e, n = !1) => {
3585
+ ], ic = (t) => t.valueType || "unknown", $s = (t, e, n = !1) => {
3584
3586
  if (n || t == null)
3585
3587
  return !0;
3586
3588
  switch (e) {
@@ -3595,7 +3597,7 @@ const $r = [
3595
3597
  default:
3596
3598
  return !0;
3597
3599
  }
3598
- }, ic = (t, e, n, r, s, i, o) => {
3600
+ }, oc = (t, e, n, r, s, i, o) => {
3599
3601
  const a = i.valueType === "json", c = (u, l, f) => {
3600
3602
  if (!$s(f, l, a))
3601
3603
  throw new x(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
@@ -3628,16 +3630,16 @@ const $r = [
3628
3630
  throw new x(`Unknown operator '${t}' for attribute '${r}' in entity '${s}'`, o);
3629
3631
  }
3630
3632
  }, De = (t, e, n, r, s) => {
3631
- const i = sc(n), o = n.valueType === "json";
3633
+ const i = ic(n), o = n.valueType === "json";
3632
3634
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3633
3635
  if (o)
3634
3636
  return;
3635
3637
  const c = t;
3636
3638
  for (const [u, l] of Object.entries(c))
3637
- ic(u, l, i, e, r, n, `${s}.${u}`);
3639
+ oc(u, l, i, e, r, n, `${s}.${u}`);
3638
3640
  } else if (!$s(t, i, o))
3639
3641
  throw new x(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`, s);
3640
- }, oc = (t, e, n, r, s) => {
3642
+ }, ac = (t, e, n, r, s) => {
3641
3643
  const i = t.split(".");
3642
3644
  if (i.length < 2)
3643
3645
  throw new x(`Invalid dot notation path '${t}'. Must contain at least one dot.`, s);
@@ -3687,7 +3689,7 @@ const $r = [
3687
3689
  continue;
3688
3690
  }
3689
3691
  if (s.includes(".")) {
3690
- oc(s, i, e, n, `${r}.${s}`);
3692
+ ac(s, i, e, n, `${r}.${s}`);
3691
3693
  continue;
3692
3694
  }
3693
3695
  const o = n.entities[e];
@@ -3707,10 +3709,10 @@ const $r = [
3707
3709
  De(i, s, u, e, `${r}.${s}`);
3708
3710
  }
3709
3711
  }
3710
- }, ac = (t, e, n, r, s = 0) => {
3712
+ }, cc = (t, e, n, r, s = 0) => {
3711
3713
  for (const o of Object.keys(t))
3712
- if (!$r.includes(o))
3713
- throw new x(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${$r.join(", ")}. Found: ${o}`, r);
3714
+ if (!Dr.includes(o))
3715
+ throw new x(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Dr.join(", ")}. Found: ${o}`, r);
3714
3716
  const i = [
3715
3717
  // 'limit', // only supported client side
3716
3718
  "offset",
@@ -3746,9 +3748,9 @@ const $r = [
3746
3748
  const a = t[o];
3747
3749
  if (typeof a != "object" || a === null)
3748
3750
  throw new x(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3749
- ac(a, e, n, `${r}.$`, s);
3751
+ cc(a, e, n, `${r}.$`, s);
3750
3752
  }
3751
- }, Dr = (t, e) => {
3753
+ }, Ur = (t, e) => {
3752
3754
  if (typeof t != "object" || t === null)
3753
3755
  throw new x(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
3754
3756
  if (Array.isArray(t))
@@ -3767,27 +3769,27 @@ const $r = [
3767
3769
  Us(n[r], r, e, r, 0);
3768
3770
  }
3769
3771
  }
3770
- }, Ur = (t) => typeof t != "string" ? !1 : Ct(t) ? !0 : Le(t);
3772
+ }, Lr = (t) => typeof t != "string" ? !1 : Pt(t) ? !0 : Le(t);
3771
3773
  class se extends Error {
3772
3774
  constructor(e) {
3773
3775
  super(e), this.name = "TransactionValidationError";
3774
3776
  }
3775
3777
  }
3776
- const Ls = (t) => t.length > 0 ? t.join(", ") : "none", cc = (t, e) => new se(`Entity '${t}' does not exist in schema. Available entities: ${Ls(e)}`), Gt = {
3778
+ const Ls = (t) => t.length > 0 ? t.join(", ") : "none", uc = (t, e) => new se(`Entity '${t}' does not exist in schema. Available entities: ${Ls(e)}`), Qt = {
3777
3779
  string: (t) => typeof t == "string",
3778
3780
  number: (t) => typeof t == "number" && !isNaN(t),
3779
3781
  boolean: (t) => typeof t == "boolean",
3780
3782
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3781
3783
  json: () => !0
3782
- }, uc = (t, e) => {
3784
+ }, lc = (t, e) => {
3783
3785
  var n;
3784
- return t == null ? !0 : ((n = Gt[e.valueType]) == null ? void 0 : n.call(Gt, t)) ?? !1;
3786
+ return t == null ? !0 : ((n = Qt[e.valueType]) == null ? void 0 : n.call(Qt, t)) ?? !1;
3785
3787
  }, Fs = (t, e) => {
3786
3788
  const n = e.entities[t];
3787
3789
  if (!n)
3788
- throw cc(t, Object.keys(e.entities));
3790
+ throw uc(t, Object.keys(e.entities));
3789
3791
  return n;
3790
- }, Qt = (t, e, n) => {
3792
+ }, Ht = (t, e, n) => {
3791
3793
  const r = Fs(t, n);
3792
3794
  if (typeof e != "object" || e === null)
3793
3795
  throw new se(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
@@ -3795,10 +3797,10 @@ const Ls = (t) => t.length > 0 ? t.join(", ") : "none", cc = (t, e) => new se(`E
3795
3797
  if (s === "id")
3796
3798
  continue;
3797
3799
  const o = r.attrs[s];
3798
- if (o && !uc(i, o))
3800
+ if (o && !lc(i, o))
3799
3801
  throw new se(`Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`);
3800
3802
  }
3801
- }, Lr = (t, e, n) => {
3803
+ }, Fr = (t, e, n) => {
3802
3804
  const r = Fs(t, n);
3803
3805
  if (typeof e != "object" || e === null)
3804
3806
  throw new se(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
@@ -3810,21 +3812,21 @@ const Ls = (t) => t.length > 0 ? t.join(", ") : "none", cc = (t, e) => new se(`E
3810
3812
  if (i != null) {
3811
3813
  if (Array.isArray(i)) {
3812
3814
  for (const a of i)
3813
- if (!Ur(a))
3815
+ if (!Lr(a))
3814
3816
  throw new se(`Invalid entity ID in link '${s}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
3815
- } else if (!Ur(i))
3817
+ } else if (!Lr(i))
3816
3818
  throw new se(`Invalid UUID in link '${s}' for entity '${t}'. Expected a UUID, but received: ${i}`);
3817
3819
  }
3818
3820
  }
3819
- }, lc = {
3820
- create: Qt,
3821
- update: Qt,
3822
- merge: Qt,
3823
- link: Lr,
3824
- unlink: Lr,
3821
+ }, fc = {
3822
+ create: Ht,
3823
+ update: Ht,
3824
+ merge: Ht,
3825
+ link: Fr,
3826
+ unlink: Fr,
3825
3827
  delete: () => {
3826
3828
  }
3827
- }, fc = (t, e) => {
3829
+ }, dc = (t, e) => {
3828
3830
  if (!e)
3829
3831
  return;
3830
3832
  const [n, r, s, i] = t;
@@ -3832,9 +3834,9 @@ const Ls = (t) => t.length > 0 ? t.join(", ") : "none", cc = (t, e) => new se(`E
3832
3834
  throw new se(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
3833
3835
  if (typeof r != "string")
3834
3836
  throw new se(`Entity name must be a string, but received: ${typeof r}`);
3835
- const o = lc[n];
3837
+ const o = fc[n];
3836
3838
  o && i !== void 0 && o(r, i, e);
3837
- }, dc = (t, e) => {
3839
+ }, hc = (t, e) => {
3838
3840
  const n = Array.isArray(t) ? t : [t];
3839
3841
  for (const r of n) {
3840
3842
  if (!r || typeof r != "object")
@@ -3844,12 +3846,12 @@ const Ls = (t) => t.length > 0 ? t.join(", ") : "none", cc = (t, e) => new se(`E
3844
3846
  for (const s of r.__ops) {
3845
3847
  if (!Array.isArray(s))
3846
3848
  throw new se(`Transaction operation must be an array, but received: ${typeof s}`);
3847
- fc(s, e);
3849
+ dc(s, e);
3848
3850
  }
3849
3851
  }
3850
3852
  };
3851
3853
  let Ns = 0;
3852
- class Fr {
3854
+ class Nr {
3853
3855
  constructor(e) {
3854
3856
  p(this, "type", "ws");
3855
3857
  p(this, "conn");
@@ -3884,7 +3886,7 @@ class Fr {
3884
3886
  return this.conn.send(JSON.stringify(e));
3885
3887
  }
3886
3888
  }
3887
- class hc {
3889
+ class pc {
3888
3890
  constructor(e, n) {
3889
3891
  p(this, "type", "sse");
3890
3892
  p(this, "initParams", null);
@@ -3980,24 +3982,24 @@ class hc {
3980
3982
  this.handleClose();
3981
3983
  }
3982
3984
  }
3983
- function pc(t, e) {
3985
+ function yc(t, e) {
3984
3986
  const n = t.values;
3985
3987
  if (n) {
3986
- const r = ps(n.attrsStore, null);
3988
+ const r = ys(n.attrsStore, null);
3987
3989
  if (r) {
3988
3990
  for (const s of n.entities || [])
3989
- s.store.useDateObjects = e, s.store = hs(r, s.store);
3991
+ s.store.useDateObjects = e, s.store = ps(r, s.store);
3990
3992
  n.attrsStore = r;
3991
3993
  }
3992
3994
  }
3993
3995
  return t;
3994
3996
  }
3995
- function yc(t, e) {
3997
+ function bc(t, e) {
3996
3998
  var n;
3997
3999
  if (e.values) {
3998
4000
  const r = [];
3999
4001
  for (const s of (n = e.values) == null ? void 0 : n.entities) {
4000
- const i = ds(s.store);
4002
+ const i = hs(s.store);
4001
4003
  r.push({ ...s, store: i });
4002
4004
  }
4003
4005
  return {
@@ -4007,15 +4009,15 @@ function yc(t, e) {
4007
4009
  } else
4008
4010
  return e;
4009
4011
  }
4010
- function bc(t, e, n) {
4012
+ function gc(t, e, n) {
4011
4013
  var i, o;
4012
4014
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
4013
4015
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
4014
4016
  }
4015
- function Ht(t, e, n) {
4016
- return As({ store: e, attrsStore: n, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4017
+ function Jt(t, e, n) {
4018
+ return ks({ store: e, attrsStore: n, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4017
4019
  }
4018
- function Nr(t, e, n, r) {
4020
+ function Kr(t, e, n, r) {
4019
4021
  var o;
4020
4022
  const s = (o = N(n, t.table, "id")) == null ? void 0 : o.id;
4021
4023
  if (!s)
@@ -4023,18 +4025,18 @@ function Nr(t, e, n, r) {
4023
4025
  const i = Ke(e.eav, [r, s, r]);
4024
4026
  return i ? i[3] : -1;
4025
4027
  }
4026
- function Kr(t, e, n) {
4028
+ function qr(t, e, n) {
4027
4029
  for (const { action: r, triple: s } of n)
4028
4030
  switch (r) {
4029
4031
  case "added":
4030
- gs(t, e, s);
4032
+ _s(t, e, s);
4031
4033
  break;
4032
4034
  case "removed":
4033
- ys(t, e, s);
4035
+ bs(t, e, s);
4034
4036
  break;
4035
4037
  }
4036
4038
  }
4037
- function gc(t, e, n) {
4039
+ function _c(t, e, n) {
4038
4040
  var s, i;
4039
4041
  const r = {};
4040
4042
  for (const { action: o, triple: a } of n) {
@@ -4062,14 +4064,14 @@ function gc(t, e, n) {
4062
4064
  function bt(t, e) {
4063
4065
  return { [t.table]: e.map((n) => n.entity) };
4064
4066
  }
4065
- function _c(t, e) {
4067
+ function wc(t, e) {
4066
4068
  var r;
4067
4069
  if (t.orderFieldType)
4068
4070
  return t.orderFieldType;
4069
4071
  const n = t.orderField === "serverCreatedAt" ? "number" : (r = N(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
4070
4072
  return t.orderFieldType = n, n;
4071
4073
  }
4072
- function wc(t, e, n) {
4074
+ function Tc(t, e, n) {
4073
4075
  const r = e;
4074
4076
  if (t.orderField === "serverCreatedAt") {
4075
4077
  n.sort(t.orderDirection === "asc" ? function(o, a) {
@@ -4090,7 +4092,7 @@ var Te;
4090
4092
  (function(t) {
4091
4093
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4092
4094
  })(Te || (Te = {}));
4093
- class Tc {
4095
+ class mc {
4094
4096
  constructor(e, n, r, s, i, o) {
4095
4097
  p(this, "trySend");
4096
4098
  p(this, "subs");
@@ -4101,11 +4103,11 @@ class Tc {
4101
4103
  p(this, "log");
4102
4104
  p(this, "createStore");
4103
4105
  p(this, "getAttrs");
4104
- this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new bn({
4106
+ this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new gn({
4105
4107
  persister: n,
4106
- merge: bc,
4107
- serialize: yc,
4108
- parse: (a, c) => pc(c, this.config.useDateObjects),
4108
+ merge: gc,
4109
+ serialize: bc,
4110
+ parse: (a, c) => yc(c, this.config.useDateObjects),
4109
4111
  objectSize: (a) => {
4110
4112
  var c;
4111
4113
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4226,11 +4228,11 @@ class Tc {
4226
4228
  o.values = a;
4227
4229
  const c = a.entities;
4228
4230
  for (const u of r) {
4229
- const l = this.createStore(u), f = Ht(o, l, a.attrsStore);
4231
+ const l = this.createStore(u), f = Jt(o, l, a.attrsStore);
4230
4232
  c.push({
4231
4233
  store: l,
4232
4234
  entity: f,
4233
- serverCreatedAt: Nr(o, l, a.attrsStore, f.id)
4235
+ serverCreatedAt: Kr(o, l, a.attrsStore, f.id)
4234
4236
  }), i.push(f);
4235
4237
  }
4236
4238
  this.subs.updateInPlace((u) => {
@@ -4301,8 +4303,8 @@ class Tc {
4301
4303
  for (let _ = 0; _ < f.length; _++) {
4302
4304
  const S = f[_];
4303
4305
  if (Xi(S.store, w)) {
4304
- Kr(S.store, l.attrsStore, m);
4305
- const O = Ht(s, S.store, l.attrsStore), E = gc(S.store, l.attrsStore, m)[w];
4306
+ qr(S.store, l.attrsStore, m);
4307
+ const O = Jt(s, S.store, l.attrsStore), E = _c(S.store, l.attrsStore, m)[w];
4306
4308
  O ? (h.push({
4307
4309
  oldEntity: S.entity,
4308
4310
  newEntity: O,
@@ -4314,8 +4316,8 @@ class Tc {
4314
4316
  const y = [];
4315
4317
  for (const [w, m] of Object.entries(u)) {
4316
4318
  const _ = this.createStore([]);
4317
- Kr(_, l.attrsStore, m);
4318
- const S = Ht(s, _, l.attrsStore);
4319
+ qr(_, l.attrsStore, m);
4320
+ const S = Jt(s, _, l.attrsStore);
4319
4321
  if (!S) {
4320
4322
  this.log.error("No entity found after applying change", {
4321
4323
  sub: s,
@@ -4327,14 +4329,14 @@ class Tc {
4327
4329
  f.push({
4328
4330
  store: _,
4329
4331
  entity: S,
4330
- serverCreatedAt: Nr(s, _, l.attrsStore, S.id)
4332
+ serverCreatedAt: Kr(s, _, l.attrsStore, S.id)
4331
4333
  }), y.push(S);
4332
4334
  }
4333
4335
  const b = [];
4334
4336
  for (const w of c.sort().reverse())
4335
4337
  b.push(f[w].entity), f.splice(w, 1);
4336
- const g = _c(s, this.getAttrs);
4337
- wc(s, g, f), this.notifyCbs(r, {
4338
+ const g = wc(s, this.getAttrs);
4339
+ Tc(s, g, f), this.notifyCbs(r, {
4338
4340
  type: Te.SyncTransaction,
4339
4341
  data: bt(s, (o = s.values) == null ? void 0 : o.entities),
4340
4342
  added: y,
@@ -4381,39 +4383,39 @@ const de = {
4381
4383
  AUTHENTICATED: "authenticated",
4382
4384
  CLOSED: "closed",
4383
4385
  ERRORED: "errored"
4384
- }, mc = 3e4, Sc = 3e4, vc = 200, Ec = 1e3 * 60, Oc = {
4386
+ }, Sc = 3e4, vc = 3e4, Ec = 200, Oc = 1e3 * 60, Ac = {
4385
4387
  apiURI: "https://api.instantdb.com",
4386
4388
  websocketURI: "wss://api.instantdb.com/runtime/session"
4387
- }, Jt = "_instant_oauth_redirect", Ve = "currentUser";
4388
- function Ac({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
4389
+ }, Yt = "_instant_oauth_redirect", Ve = "currentUser";
4390
+ function kc({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: s }) {
4389
4391
  if (!s)
4390
- return new Fr(`${r}?app_id=${e}`);
4392
+ return new Nr(`${r}?app_id=${e}`);
4391
4393
  switch (t) {
4392
4394
  case "ws":
4393
- return new Fr(`${r}?app_id=${e}`);
4395
+ return new Nr(`${r}?app_id=${e}`);
4394
4396
  case "sse":
4395
- return new hc(s, `${n}/runtime/sse?app_id=${e}`);
4397
+ return new pc(s, `${n}/runtime/sse?app_id=${e}`);
4396
4398
  default:
4397
4399
  throw new Error("Unknown transport type " + t);
4398
4400
  }
4399
4401
  }
4400
- function kc() {
4402
+ function Cc() {
4401
4403
  return typeof window < "u" || typeof chrome < "u";
4402
4404
  }
4403
- const qr = {
4405
+ const Wr = {
4404
4406
  "set-presence": !0,
4405
4407
  "set-presence-ok": !0,
4406
4408
  "refresh-presence": !0,
4407
4409
  "patch-presence": !0
4408
4410
  };
4409
- function Cc(t, e) {
4411
+ function Pc(t, e) {
4410
4412
  var r;
4411
4413
  const n = typeof t == "string" ? JSON.parse(t) : t;
4412
4414
  if ((r = n == null ? void 0 : n.result) != null && r.store) {
4413
- const s = ps(n.result.attrsStore, n.result.store);
4415
+ const s = ys(n.result.attrsStore, n.result.store);
4414
4416
  if (s) {
4415
4417
  const i = n.result.store;
4416
- n.result.store = hs(s, {
4418
+ n.result.store = ps(s, {
4417
4419
  ...i,
4418
4420
  useDateObjects: e
4419
4421
  }), n.result.attrsStore = s;
@@ -4421,7 +4423,7 @@ function Cc(t, e) {
4421
4423
  }
4422
4424
  return n;
4423
4425
  }
4424
- function Pc(t, e) {
4426
+ function Ic(t, e) {
4425
4427
  const { result: n, ...r } = e, s = (
4426
4428
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
4427
4429
  r
@@ -4429,14 +4431,14 @@ function Pc(t, e) {
4429
4431
  if (n) {
4430
4432
  const i = {
4431
4433
  ...n,
4432
- store: ds(n.store),
4434
+ store: hs(n.store),
4433
4435
  attrsStore: n.attrsStore.toJSON()
4434
4436
  };
4435
4437
  s.result = i;
4436
4438
  }
4437
4439
  return s;
4438
4440
  }
4439
- function Ic(t, e) {
4441
+ function Mc(t, e) {
4440
4442
  switch (t) {
4441
4443
  case "pendingMutations":
4442
4444
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4444,7 +4446,7 @@ function Ic(t, e) {
4444
4446
  return e;
4445
4447
  }
4446
4448
  }
4447
- function Mc(t, e) {
4449
+ function jc(t, e) {
4448
4450
  switch (t) {
4449
4451
  case "pendingMutations":
4450
4452
  return [...e.entries()];
@@ -4452,17 +4454,17 @@ function Mc(t, e) {
4452
4454
  return e;
4453
4455
  }
4454
4456
  }
4455
- function jc(t, e, n) {
4457
+ function Rc(t, e, n) {
4456
4458
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4457
4459
  return r && !s && n && (n.result = r), n || e;
4458
4460
  }
4459
- function Yt(t) {
4461
+ function Zt(t) {
4460
4462
  return [...t].sort((e, n) => {
4461
4463
  const [r, s] = e, [i, o] = n, a = s.order || 0, c = o.order || 0;
4462
4464
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
4463
4465
  });
4464
4466
  }
4465
- class Rc {
4467
+ class xc {
4466
4468
  constructor(e, n = Is, r = Ms, s, i) {
4467
4469
  /** @type {s.AttrsStore | undefined} */
4468
4470
  p(this, "attrs");
@@ -4557,9 +4559,9 @@ class Rc {
4557
4559
  });
4558
4560
  /** Applies transactions locally and sends transact message to server */
4559
4561
  p(this, "pushTx", (e) => {
4560
- this.config.disableValidation || dc(e, this.config.schema);
4562
+ this.config.disableValidation || hc(e, this.config.schema);
4561
4563
  try {
4562
- const n = Da({
4564
+ const n = Ua({
4563
4565
  attrsStore: this.optimisticAttrs(),
4564
4566
  schema: this.config.schema,
4565
4567
  stores: Object.values(this.querySubs.currentValue).map((r) => {
@@ -4589,7 +4591,7 @@ class Rc {
4589
4591
  this._updatePendingMutations((c) => {
4590
4592
  c.set(r, o);
4591
4593
  });
4592
- const a = new jr();
4594
+ const a = new Rr();
4593
4595
  return this.mutationDeferredStore.set(r, a), this._sendMutation(r, o), this.notifyAll(), a.promise;
4594
4596
  });
4595
4597
  p(this, "_transportOnOpen", (e) => {
@@ -4660,7 +4662,7 @@ class Rc {
4660
4662
  }
4661
4663
  this._log.info("[socket][close]", n.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4662
4664
  });
4663
- if (this._EventSource = i, this.config = { ...Oc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Sc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? vc, this._log = rc(e.verbose || Nn || js, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": Kn }, this.config.schema && (this._linkIndex = xr(this.config.schema)), !!kc()) {
4665
+ if (this._EventSource = i, this.config = { ...Ac, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? vc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Ec, this._log = sc(e.verbose || Kn || js, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": qn }, this.config.schema && (this._linkIndex = $r(this.config.schema)), !!Cc()) {
4664
4666
  if (!e.appId)
4665
4667
  throw new Error("Instant must be initialized with an appId.");
4666
4668
  if (!Le(e.appId))
@@ -4675,14 +4677,14 @@ class Rc {
4675
4677
  } catch (c) {
4676
4678
  this._log.error("[error] handle broadcast channel", c);
4677
4679
  }
4678
- })), this._initStorage(n), this._syncTable = new Tc(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4680
+ })), this._initStorage(n), this._syncTable = new mc(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4679
4681
  useDateObjects: this.config.useDateObjects
4680
4682
  }, this._log, (o) => Je(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser().then((o) => {
4681
4683
  this.syncUserToEndpoint(o.user);
4682
4684
  }), setInterval(async () => {
4683
4685
  const o = await this.getCurrentUser();
4684
4686
  this.syncUserToEndpoint(o.user);
4685
- }, Ec), r.getIsOnline().then((o) => {
4687
+ }, Oc), r.getIsOnline().then((o) => {
4686
4688
  this._isOnline = o, this._startSocket(), r.listen((a) => {
4687
4689
  a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", de.CLOSED), this._setStatus(de.CLOSED)));
4688
4690
  });
@@ -4699,7 +4701,7 @@ class Rc {
4699
4701
  ...this.config,
4700
4702
  schema: e,
4701
4703
  cardinalityInference: !!e
4702
- }, this._linkIndex = e ? xr(this.config.schema) : null;
4704
+ }, this._linkIndex = e ? $r(this.config.schema) : null;
4703
4705
  }
4704
4706
  _reactorStats() {
4705
4707
  return {
@@ -4712,11 +4714,11 @@ class Rc {
4712
4714
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
4713
4715
  }
4714
4716
  _initStorage(e) {
4715
- this.querySubs = new bn({
4717
+ this.querySubs = new gn({
4716
4718
  persister: new e(this.config.appId, "querySubs"),
4717
- merge: jc,
4718
- serialize: Pc,
4719
- parse: (n, r) => Cc(r, this.config.useDateObjects),
4719
+ merge: Rc,
4720
+ serialize: Ic,
4721
+ parse: (n, r) => Pc(r, this.config.useDateObjects),
4720
4722
  // objectSize
4721
4723
  objectSize: (n) => {
4722
4724
  var r, s, i;
@@ -4732,11 +4734,11 @@ class Rc {
4732
4734
  maxSize: 1e6
4733
4735
  // 1 million triples
4734
4736
  }
4735
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new bn({
4737
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new gn({
4736
4738
  persister: new e(this.config.appId, "kv"),
4737
4739
  merge: this._onMergeKv,
4738
- serialize: Mc,
4739
- parse: Ic,
4740
+ serialize: jc,
4741
+ parse: Mc,
4740
4742
  objectSize: () => 0,
4741
4743
  logger: this._log,
4742
4744
  saveThrottleMs: 100,
@@ -4768,7 +4770,7 @@ class Rc {
4768
4770
  s.resolve({ status: e, eventId: n });
4769
4771
  else if (r != null && r.type) {
4770
4772
  const { status: o, ...a } = r;
4771
- s.reject(new jt({
4773
+ s.reject(new Rt({
4772
4774
  // @ts-expect-error body.type is not constant typed
4773
4775
  body: a,
4774
4776
  status: o ?? 0
@@ -4815,7 +4817,7 @@ class Rc {
4815
4817
  _handleReceive(e, n) {
4816
4818
  var s, i, o, a, c, u;
4817
4819
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4818
- switch (qr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4820
+ switch (Wr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4819
4821
  case "init-ok": {
4820
4822
  this._setStatus(de.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
4821
4823
  for (const h of Object.keys(this._rooms)) {
@@ -4832,7 +4834,7 @@ class Rc {
4832
4834
  const { q: h, result: y } = n, b = q(h);
4833
4835
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[b])
4834
4836
  break;
4835
- const g = (a = (o = y == null ? void 0 : y[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], w = (u = (c = y == null ? void 0 : y[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, m = Rr(y), _ = this.ensureAttrs(), S = Je(_, m, r, this.config.useDateObjects);
4837
+ const g = (a = (o = y == null ? void 0 : y[0]) == null ? void 0 : o.data) == null ? void 0 : a["page-info"], w = (u = (c = y == null ? void 0 : y[0]) == null ? void 0 : c.data) == null ? void 0 : u.aggregate, m = xr(y), _ = this.ensureAttrs(), S = Je(_, m, r, this.config.useDateObjects);
4836
4838
  this.querySubs.updateInPlace((O) => {
4837
4839
  if (!O[b]) {
4838
4840
  this._log.info("Missing value in querySubs", { hash: b, q: h });
@@ -4871,16 +4873,16 @@ class Rc {
4871
4873
  g !== this._pendingMutations() && this.kv.updateInPlace((_) => {
4872
4874
  _.pendingMutations = g;
4873
4875
  });
4874
- const w = Yt(g.entries()), m = h.map((_) => {
4876
+ const w = Zt(g.entries()), m = h.map((_) => {
4875
4877
  var We, ie, le, be;
4876
- const S = _["instaql-query"], O = _["instaql-result"], E = q(S), j = Rr(O), L = this.ensureAttrs(), B = Je(L, j, r, this.config.useDateObjects), { store: qe, attrsStore: ut } = this._applyOptimisticUpdates(B, L, w, b), $t = (ie = (We = O == null ? void 0 : O[0]) == null ? void 0 : We.data) == null ? void 0 : ie["page-info"], Dt = (be = (le = O == null ? void 0 : O[0]) == null ? void 0 : le.data) == null ? void 0 : be.aggregate;
4878
+ const S = _["instaql-query"], O = _["instaql-result"], E = q(S), j = xr(O), L = this.ensureAttrs(), B = Je(L, j, r, this.config.useDateObjects), { store: qe, attrsStore: ut } = this._applyOptimisticUpdates(B, L, w, b), Dt = (ie = (We = O == null ? void 0 : O[0]) == null ? void 0 : We.data) == null ? void 0 : ie["page-info"], Ut = (be = (le = O == null ? void 0 : O[0]) == null ? void 0 : le.data) == null ? void 0 : be.aggregate;
4877
4879
  return {
4878
4880
  q: S,
4879
4881
  hash: E,
4880
4882
  store: qe,
4881
4883
  attrsStore: ut,
4882
- pageInfo: $t,
4883
- aggregate: Dt
4884
+ pageInfo: Dt,
4885
+ aggregate: Ut
4884
4886
  };
4885
4887
  });
4886
4888
  m.forEach(({ hash: _, q: S, store: O, attrsStore: E, pageInfo: j, aggregate: L }) => {
@@ -5059,21 +5061,21 @@ class Rc {
5059
5061
  * Returns an unsubscribe function
5060
5062
  */
5061
5063
  subscribeQuery(e, n, r) {
5062
- this.config.disableValidation || Dr(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5064
+ this.config.disableValidation || Ur(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5063
5065
  const s = q(e), i = this.getPreviousResult(e);
5064
5066
  return i && n(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5065
5067
  this._unsubQuery(e, s, n);
5066
5068
  };
5067
5069
  }
5068
5070
  queryOnce(e, n) {
5069
- this.config.disableValidation || Dr(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5070
- const r = new jr();
5071
+ this.config.disableValidation || Ur(e, this.config.schema), n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
5072
+ const r = new Rr();
5071
5073
  if (!this._isOnline)
5072
5074
  return r.reject(new Error("We can't run `queryOnce`, because the device is offline.")), r.promise;
5073
5075
  if (!this.querySubs)
5074
5076
  return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
5075
5077
  const s = q(e), i = this._startQuerySub(e, s);
5076
- return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), mc), r.promise;
5078
+ return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), Sc), r.promise;
5077
5079
  }
5078
5080
  _completeQueryOnce(e, n, r) {
5079
5081
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((s) => s.dfd !== r), this._cleanupQuery(e, n));
@@ -5140,7 +5142,7 @@ class Rc {
5140
5142
  a = !0;
5141
5143
  continue;
5142
5144
  }
5143
- const g = a ? fa(o, y) : y;
5145
+ const g = a ? da(o, y) : y;
5144
5146
  h.push(g);
5145
5147
  }
5146
5148
  return a ? h : l;
@@ -5153,7 +5155,7 @@ class Rc {
5153
5155
  return a ? u : n;
5154
5156
  }
5155
5157
  _rewriteMutationsSorted(e, n) {
5156
- return Yt(this._rewriteMutations(e, n).entries());
5158
+ return Zt(this._rewriteMutations(e, n).entries());
5157
5159
  }
5158
5160
  // ---------------------------
5159
5161
  // Transact
@@ -5198,7 +5200,7 @@ class Rc {
5198
5200
  const _ = this._applyOptimisticUpdates(f, h, w, g);
5199
5201
  f = _.store, h = _.attrsStore;
5200
5202
  }
5201
- return { data: As({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
5203
+ return { data: ks({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
5202
5204
  }
5203
5205
  _applyOptimisticUpdates(e, n, r, s) {
5204
5206
  for (const [i, o] of r)
@@ -5262,7 +5264,7 @@ class Rc {
5262
5264
  const r = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations());
5263
5265
  r !== this._pendingMutations() && this.kv.updateInPlace((i) => {
5264
5266
  i.pendingMutations = r;
5265
- }), Yt(r.entries()).forEach(([i, o]) => {
5267
+ }), Zt(r.entries()).forEach(([i, o]) => {
5266
5268
  o["tx-id"] || this._sendMutation(i, o);
5267
5269
  }), this._syncTable.flushPending();
5268
5270
  }
@@ -5297,7 +5299,7 @@ class Rc {
5297
5299
  }
5298
5300
  _trySend(e, n, r) {
5299
5301
  if (this._transport.isOpen()) {
5300
- switch (qr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5302
+ switch (Wr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5301
5303
  case "transact": {
5302
5304
  this._inFlightMutationEventIds.add(e);
5303
5305
  break;
@@ -5318,7 +5320,7 @@ class Rc {
5318
5320
  return;
5319
5321
  }
5320
5322
  const e = this._transport;
5321
- this._transport = Ac({
5323
+ this._transport = kc({
5322
5324
  transportType: this._transportType,
5323
5325
  appId: this.config.appId,
5324
5326
  apiURI: this.config.apiURI,
@@ -5352,9 +5354,9 @@ class Rc {
5352
5354
  if (typeof URL > "u")
5353
5355
  return;
5354
5356
  const e = new URL(window.location.href);
5355
- if (e.searchParams.get(Jt)) {
5357
+ if (e.searchParams.get(Yt)) {
5356
5358
  const n = e.toString();
5357
- e.searchParams.delete(Jt), e.searchParams.delete("code"), e.searchParams.delete("error");
5359
+ e.searchParams.delete(Yt), e.searchParams.delete("code"), e.searchParams.delete("error");
5358
5360
  const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
5359
5361
  if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
5360
5362
  typeof navigation == "object" && // @ts-ignore (waiting for ts support)
@@ -5378,7 +5380,7 @@ class Rc {
5378
5380
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
5379
5381
  return null;
5380
5382
  const e = new URLSearchParams(window.location.search);
5381
- if (!e.get(Jt))
5383
+ if (!e.get(Yt))
5382
5384
  return null;
5383
5385
  const n = e.get("error");
5384
5386
  if (n)
@@ -5388,7 +5390,7 @@ class Rc {
5388
5390
  return null;
5389
5391
  this._replaceUrlAfterOAuth();
5390
5392
  try {
5391
- const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Ir({
5393
+ const c = await this._getCurrentUser(), u = (c == null ? void 0 : c.type) === "guest", { user: l } = await Mr({
5392
5394
  apiURI: this.config.apiURI,
5393
5395
  appId: this.config.appId,
5394
5396
  code: r,
@@ -5525,7 +5527,7 @@ class Rc {
5525
5527
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5526
5528
  }
5527
5529
  sendMagicCode({ email: e }) {
5528
- return za({
5530
+ return Va({
5529
5531
  apiURI: this.config.apiURI,
5530
5532
  appId: this.config.appId,
5531
5533
  email: e
@@ -5533,7 +5535,7 @@ class Rc {
5533
5535
  }
5534
5536
  async signInWithMagicCode({ email: e, code: n }) {
5535
5537
  var o;
5536
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Va({
5538
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Ba({
5537
5539
  apiURI: this.config.apiURI,
5538
5540
  appId: this.config.appId,
5539
5541
  email: e,
@@ -5543,7 +5545,7 @@ class Rc {
5543
5545
  return await this.changeCurrentUser(i.user), i;
5544
5546
  }
5545
5547
  async signInWithCustomToken(e) {
5546
- const n = await Ba({
5548
+ const n = await Ga({
5547
5549
  apiURI: this.config.apiURI,
5548
5550
  appId: this.config.appId,
5549
5551
  refreshToken: e
@@ -5551,7 +5553,7 @@ class Rc {
5551
5553
  return await this.changeCurrentUser(n.user), n;
5552
5554
  }
5553
5555
  async signInAsGuest() {
5554
- const e = await Ga({
5556
+ const e = await Qa({
5555
5557
  apiURI: this.config.apiURI,
5556
5558
  appId: this.config.appId
5557
5559
  });
@@ -5566,7 +5568,7 @@ class Rc {
5566
5568
  this._log.info("[auth-invalidate] skipped invalidateToken");
5567
5569
  return;
5568
5570
  }
5569
- Ha({
5571
+ Ja({
5570
5572
  apiURI: this.config.apiURI,
5571
5573
  appId: this.config.appId,
5572
5574
  refreshToken: r
@@ -5598,7 +5600,7 @@ class Rc {
5598
5600
  */
5599
5601
  async exchangeCodeForToken({ code: e, codeVerifier: n }) {
5600
5602
  var o;
5601
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Ir({
5603
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Mr({
5602
5604
  apiURI: this.config.apiURI,
5603
5605
  appId: this.config.appId,
5604
5606
  code: e,
@@ -5619,7 +5621,7 @@ class Rc {
5619
5621
  */
5620
5622
  async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
5621
5623
  var a;
5622
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await Qa({
5624
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await Ha({
5623
5625
  apiURI: this.config.apiURI,
5624
5626
  appId: this.config.appId,
5625
5627
  idToken: e,
@@ -5660,7 +5662,7 @@ class Rc {
5660
5662
  getPresence(e, n, r = {}) {
5661
5663
  const s = this._rooms[n], i = this._presence[n];
5662
5664
  return !s || !i || !i.result ? null : {
5663
- ...tc(i.result, r, this._sessionId),
5665
+ ...nc(i.result, r, this._sessionId),
5664
5666
  isLoading: !s.isConnected,
5665
5667
  error: s.error
5666
5668
  };
@@ -5716,24 +5718,24 @@ class Rc {
5716
5718
  }
5717
5719
  _notifyPresenceSub(e, n) {
5718
5720
  const r = this.getPresence("", e, n);
5719
- r && (n.prev && !nc(r, n.prev) || (n.prev = r, n.cb(r)));
5721
+ r && (n.prev && !rc(r, n.prev) || (n.prev = r, n.cb(r)));
5720
5722
  }
5721
5723
  _patchPresencePeers(e, n) {
5722
5724
  var o, a, c;
5723
5725
  const r = ((a = (o = this._presence[e]) == null ? void 0 : o.result) == null ? void 0 : a.peers) || {};
5724
5726
  let s = Object.fromEntries(Object.entries(r).map(([u, l]) => [u, { data: l }]));
5725
5727
  (c = this._presence[e]) == null || c.result;
5726
- const i = At(s, (u) => {
5728
+ const i = kt(s, (u) => {
5727
5729
  for (let [l, f, h] of n)
5728
5730
  switch (f) {
5729
5731
  case "+":
5730
5732
  Ri(u, l, h);
5731
5733
  break;
5732
5734
  case "r":
5733
- gr(u, l, h);
5735
+ _r(u, l, h);
5734
5736
  break;
5735
5737
  case "-":
5736
- ls(u, l);
5738
+ fs(u, l);
5737
5739
  break;
5738
5740
  }
5739
5741
  delete u[this._sessionId];
@@ -5744,8 +5746,8 @@ class Rc {
5744
5746
  const r = { ...n };
5745
5747
  delete r[this._sessionId];
5746
5748
  const s = Object.fromEntries(Object.entries(r).map(([i, o]) => [i, o.data]));
5747
- this._presence = At(this._presence, (i) => {
5748
- gr(i, [e, "result", "peers"], s);
5749
+ this._presence = kt(this._presence, (i) => {
5750
+ _r(i, [e, "result", "peers"], s);
5749
5751
  });
5750
5752
  }
5751
5753
  // --------
@@ -5788,7 +5790,7 @@ class Rc {
5788
5790
  async uploadFile(e, n, r) {
5789
5791
  var o;
5790
5792
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
5791
- return Ja({
5793
+ return Ya({
5792
5794
  ...r,
5793
5795
  apiURI: this.config.apiURI,
5794
5796
  appId: this.config.appId,
@@ -5800,7 +5802,7 @@ class Rc {
5800
5802
  async deleteFile(e) {
5801
5803
  var i;
5802
5804
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
5803
- return await Ya({
5805
+ return await Za({
5804
5806
  apiURI: this.config.apiURI,
5805
5807
  appId: this.config.appId,
5806
5808
  path: e,
@@ -5811,18 +5813,18 @@ class Rc {
5811
5813
  // ---------------------------------
5812
5814
  async upload(e, n) {
5813
5815
  var c;
5814
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await Za({
5816
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await Xa({
5815
5817
  apiURI: this.config.apiURI,
5816
5818
  appId: this.config.appId,
5817
5819
  fileName: i,
5818
5820
  refreshToken: s
5819
5821
  });
5820
- return await Xa(o, n);
5822
+ return await ec(o, n);
5821
5823
  }
5822
5824
  async getDownloadUrl(e) {
5823
5825
  var i;
5824
5826
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
5825
- return await ec({
5827
+ return await tc({
5826
5828
  apiURI: this.config.apiURI,
5827
5829
  appId: this.config.appId,
5828
5830
  path: e,
@@ -5830,8 +5832,8 @@ class Rc {
5830
5832
  });
5831
5833
  }
5832
5834
  }
5833
- function xc(t, e) {
5834
- return new xt(
5835
+ function $c(t, e) {
5836
+ return new $t(
5835
5837
  Ks(t, e),
5836
5838
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
5837
5839
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
@@ -5842,25 +5844,25 @@ function xc(t, e) {
5842
5844
  void 0
5843
5845
  );
5844
5846
  }
5845
- function $c(t) {
5846
- return new Rt(t, {});
5847
+ function Dc(t) {
5848
+ return new xt(t, {});
5847
5849
  }
5848
- function Dc() {
5850
+ function Uc() {
5849
5851
  return new H("string", !0, !1);
5850
5852
  }
5851
- function Uc() {
5853
+ function Lc() {
5852
5854
  return new H("number", !0, !1);
5853
5855
  }
5854
- function Lc() {
5856
+ function Fc() {
5855
5857
  return new H("boolean", !0, !1);
5856
5858
  }
5857
- function Fc() {
5859
+ function Nc() {
5858
5860
  return new H("date", !0, !1);
5859
5861
  }
5860
- function Nc() {
5862
+ function Kc() {
5861
5863
  return new H("json", !0, !1);
5862
5864
  }
5863
- function Kc() {
5865
+ function qc() {
5864
5866
  return new H("json", !0, !1);
5865
5867
  }
5866
5868
  function Ks(t, e) {
@@ -5876,15 +5878,15 @@ function Ks(t, e) {
5876
5878
  };
5877
5879
  return Object.fromEntries(Object.entries(t).map(([c, u]) => [
5878
5880
  c,
5879
- new Rt(u.attrs, {
5881
+ new xt(u.attrs, {
5880
5882
  ...n.fwd[c],
5881
5883
  ...n.rev[c]
5882
5884
  })
5883
5885
  ]));
5884
5886
  }
5885
- function qc({ entities: t, links: e, rooms: n }) {
5887
+ function Wc({ entities: t, links: e, rooms: n }) {
5886
5888
  const r = e ?? {}, s = n ?? {};
5887
- return new xt(
5889
+ return new $t(
5888
5890
  Ks(t, r),
5889
5891
  // (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
5890
5892
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
@@ -5897,21 +5899,21 @@ function qc({ entities: t, links: e, rooms: n }) {
5897
5899
  }
5898
5900
  const ju = {
5899
5901
  // constructs
5900
- graph: xc,
5901
- schema: qc,
5902
- entity: $c,
5902
+ graph: $c,
5903
+ schema: Wc,
5904
+ entity: Dc,
5903
5905
  // value types
5904
- string: Dc,
5905
- number: Uc,
5906
- boolean: Lc,
5907
- date: Fc,
5908
- json: Nc,
5909
- any: Kc
5906
+ string: Uc,
5907
+ number: Lc,
5908
+ boolean: Fc,
5909
+ date: Nc,
5910
+ json: Kc,
5911
+ any: qc
5910
5912
  };
5911
5913
  let gt;
5912
- function Wc(t, e) {
5914
+ function zc(t, e) {
5913
5915
  gt == null || gt.dispose();
5914
- const n = Hc(e), r = Bc(e, a), s = Vc(zc(t));
5916
+ const n = Jc(e), r = Gc(e, a), s = Bc(Vc(t));
5915
5917
  function i(l) {
5916
5918
  var f;
5917
5919
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -5933,10 +5935,10 @@ function Wc(t, e) {
5933
5935
  }
5934
5936
  return u();
5935
5937
  }
5936
- function zc(t) {
5937
- return `${Nn || Rs ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5938
- }
5939
5938
  function Vc(t) {
5939
+ return `${Kn || Rs ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5940
+ }
5941
+ function Bc(t) {
5940
5942
  const e = document.createElement("iframe");
5941
5943
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
5942
5944
  width: "100%",
@@ -5945,7 +5947,7 @@ function Vc(t) {
5945
5947
  border: "none"
5946
5948
  }), { element: e };
5947
5949
  }
5948
- function Bc(t, e) {
5950
+ function Gc(t, e) {
5949
5951
  const n = `
5950
5952
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
5951
5953
  <rect width="512" height="512" fill="black"/>
@@ -5955,7 +5957,7 @@ function Bc(t, e) {
5955
5957
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
5956
5958
  // pos
5957
5959
  position: "fixed",
5958
- ...Gc(t.position),
5960
+ ...Qc(t.position),
5959
5961
  height: "32px",
5960
5962
  width: "32px",
5961
5963
  // layout
@@ -5970,7 +5972,7 @@ function Bc(t, e) {
5970
5972
  cursor: "pointer"
5971
5973
  }), r.addEventListener("click", e), { element: r };
5972
5974
  }
5973
- function Gc(t) {
5975
+ function Qc(t) {
5974
5976
  switch (t) {
5975
5977
  case "bottom-left":
5976
5978
  return { bottom: "24px", left: "24px" };
@@ -5982,7 +5984,7 @@ function Gc(t) {
5982
5984
  return { top: "24px", left: "24px" };
5983
5985
  }
5984
5986
  }
5985
- function Qc(t) {
5987
+ function Hc(t) {
5986
5988
  switch (t) {
5987
5989
  case "bottom-left":
5988
5990
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -5994,11 +5996,11 @@ function Qc(t) {
5994
5996
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
5995
5997
  }
5996
5998
  }
5997
- function Hc(t) {
5999
+ function Jc(t) {
5998
6000
  const e = document.createElement("div");
5999
6001
  Object.assign(e.style, {
6000
6002
  position: "fixed",
6001
- ...Qc(t.position),
6003
+ ...Hc(t.position),
6002
6004
  display: "block",
6003
6005
  borderRadius: "4px",
6004
6006
  border: "1px #ccc solid",
@@ -6011,22 +6013,22 @@ function Hc(t) {
6011
6013
  }
6012
6014
  return { element: e, isVisible: n };
6013
6015
  }
6014
- const Jc = {
6016
+ const Yc = {
6015
6017
  apiURI: "https://api.instantdb.com",
6016
6018
  websocketURI: "wss://api.instantdb.com/runtime/session"
6017
6019
  };
6018
- function Yc() {
6020
+ function Zc() {
6019
6021
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6020
6022
  }
6021
- function Zc() {
6023
+ function Xc() {
6022
6024
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6023
6025
  }
6024
- function gn(t) {
6026
+ function _n(t) {
6025
6027
  const e = t.__adminToken;
6026
6028
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6027
6029
  }
6028
- const _n = Zc(), Wr = Yc();
6029
- class Xc {
6030
+ const wn = Xc(), zr = Zc();
6031
+ class eu {
6030
6032
  constructor(e) {
6031
6033
  p(this, "db");
6032
6034
  /**
@@ -6143,7 +6145,7 @@ class Xc {
6143
6145
  this.db = e;
6144
6146
  }
6145
6147
  }
6146
- class eu {
6148
+ class tu {
6147
6149
  constructor(e) {
6148
6150
  p(this, "db");
6149
6151
  /**
@@ -6192,16 +6194,16 @@ class eu {
6192
6194
  this.db = e;
6193
6195
  }
6194
6196
  }
6195
- function tu(t) {
6197
+ function nu(t) {
6196
6198
  return JSON.parse(JSON.stringify(t));
6197
6199
  }
6198
- class nu {
6200
+ class ru {
6199
6201
  constructor(e) {
6200
6202
  p(this, "_reactor");
6201
6203
  p(this, "auth");
6202
6204
  p(this, "storage");
6203
- p(this, "tx", Fn());
6204
- this._reactor = e, this.auth = new Xc(this._reactor), this.storage = new eu(this._reactor);
6205
+ p(this, "tx", Nn());
6206
+ this._reactor = e, this.auth = new eu(this._reactor), this.storage = new tu(this._reactor);
6205
6207
  }
6206
6208
  /**
6207
6209
  * Use this to write data! You can create, update, delete, and link objects
@@ -6342,7 +6344,7 @@ class nu {
6342
6344
  };
6343
6345
  }
6344
6346
  shutdown() {
6345
- delete _n[gn(this._reactor.config)], this._reactor.shutdown();
6347
+ delete wn[_n(this._reactor.config)], this._reactor.shutdown();
6346
6348
  }
6347
6349
  /**
6348
6350
  * Use this for one-off queries.
@@ -6375,35 +6377,35 @@ class nu {
6375
6377
  return this._reactor.subscribeTable(e, n);
6376
6378
  }
6377
6379
  }
6378
- function zr(t) {
6380
+ function Vr(t) {
6379
6381
  if (!t)
6380
6382
  return "0";
6381
- const e = Wr.get(t);
6383
+ const e = zr.get(t);
6382
6384
  if (e)
6383
6385
  return e;
6384
6386
  const n = q(t);
6385
- return Wr.set(t, n), n;
6387
+ return zr.set(t, n), n;
6386
6388
  }
6387
- function ru(t, e) {
6388
- return zr(t._reactor.config.schema) !== zr(e);
6389
+ function su(t, e) {
6390
+ return Vr(t._reactor.config.schema) !== Vr(e);
6389
6391
  }
6390
- function su(t, e, n, r, s) {
6392
+ function iu(t, e, n, r, s) {
6391
6393
  var u;
6392
6394
  const i = {
6393
6395
  ...t,
6394
6396
  appId: (u = t.appId) == null ? void 0 : u.trim(),
6395
6397
  useDateObjects: t.useDateObjects ?? !1
6396
- }, o = _n[gn(i)];
6398
+ }, o = wn[_n(i)];
6397
6399
  if (o)
6398
- return ru(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6399
- const a = new Rc({
6400
- ...Jc,
6400
+ return su(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6401
+ const a = new xc({
6402
+ ...Yc,
6401
6403
  ...i,
6402
6404
  cardinalityInference: !!i.schema
6403
- }, e || Is, n || Ms, { ...r || {}, "@instantdb/core": Kn }, s), c = new nu(a);
6404
- return _n[gn(i)] = c, iu(i.appId, i.devtool), c;
6405
+ }, e || Is, n || Ms, { ...r || {}, "@instantdb/core": qn }, s), c = new ru(a);
6406
+ return wn[_n(i)] = c, ou(i.appId, i.devtool), c;
6405
6407
  }
6406
- function iu(t, e) {
6408
+ function ou(t, e) {
6407
6409
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6408
6410
  return;
6409
6411
  const n = {
@@ -6411,9 +6413,9 @@ function iu(t, e) {
6411
6413
  allowedHosts: ["localhost"],
6412
6414
  ...typeof e == "object" ? e : {}
6413
6415
  };
6414
- n.allowedHosts.includes(window.location.hostname) && Wc(t, n);
6416
+ n.allowedHosts.includes(window.location.hostname) && zc(t, n);
6415
6417
  }
6416
- var wn = { exports: {} }, Be = {};
6418
+ var Tn = { exports: {} }, Be = {};
6417
6419
  /**
6418
6420
  * @license React
6419
6421
  * react-jsx-runtime.production.min.js
@@ -6423,11 +6425,11 @@ var wn = { exports: {} }, Be = {};
6423
6425
  * This source code is licensed under the MIT license found in the
6424
6426
  * LICENSE file in the root directory of this source tree.
6425
6427
  */
6426
- var Vr;
6427
- function ou() {
6428
- if (Vr) return Be;
6429
- Vr = 1;
6430
- var t = Xr, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
6428
+ var Br;
6429
+ function au() {
6430
+ if (Br) return Be;
6431
+ Br = 1;
6432
+ var t = es, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
6431
6433
  function o(a, c, u) {
6432
6434
  var l, f = {}, h = null, y = null;
6433
6435
  u !== void 0 && (h = "" + u), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (y = c.ref);
@@ -6437,10 +6439,10 @@ function ou() {
6437
6439
  }
6438
6440
  return Be.Fragment = n, Be.jsx = o, Be.jsxs = o, Be;
6439
6441
  }
6440
- var Ge = {}, Br;
6441
- function au() {
6442
- if (Br) return Ge;
6443
- Br = 1;
6442
+ var Ge = {}, Gr;
6443
+ function cu() {
6444
+ if (Gr) return Ge;
6445
+ Gr = 1;
6444
6446
  var t = {};
6445
6447
  /**
6446
6448
  * @license React
@@ -6452,7 +6454,7 @@ function au() {
6452
6454
  * LICENSE file in the root directory of this source tree.
6453
6455
  */
6454
6456
  return t.NODE_ENV !== "production" && function() {
6455
- var e = Xr, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, w = "@@iterator";
6457
+ var e = es, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, w = "@@iterator";
6456
6458
  function m(d) {
6457
6459
  if (d === null || typeof d != "object")
6458
6460
  return null;
@@ -6479,14 +6481,14 @@ function au() {
6479
6481
  }
6480
6482
  var E = !1, j = !1, L = !1, B = !1, qe = !1, ut;
6481
6483
  ut = Symbol.for("react.module.reference");
6482
- function $t(d) {
6484
+ function Dt(d) {
6483
6485
  return !!(typeof d == "string" || typeof d == "function" || d === s || d === o || qe || d === i || d === l || d === f || B || d === b || E || j || L || typeof d == "object" && d !== null && (d.$$typeof === y || d.$$typeof === h || d.$$typeof === a || d.$$typeof === c || d.$$typeof === u || // This needs to include all possible module reference object
6484
6486
  // types supported by any Flight configuration anywhere since
6485
6487
  // we don't know which Flight build this will end up being used
6486
6488
  // with.
6487
6489
  d.$$typeof === ut || d.getModuleId !== void 0));
6488
6490
  }
6489
- function Dt(d, T, v) {
6491
+ function Ut(d, T, v) {
6490
6492
  var A = d.displayName;
6491
6493
  if (A)
6492
6494
  return A;
@@ -6526,7 +6528,7 @@ function au() {
6526
6528
  var v = d;
6527
6529
  return We(v._context) + ".Provider";
6528
6530
  case u:
6529
- return Dt(d, d.render, "ForwardRef");
6531
+ return Ut(d, d.render, "ForwardRef");
6530
6532
  case h:
6531
6533
  var A = d.displayName || null;
6532
6534
  return A !== null ? A : ie(d.type) || "Memo";
@@ -6541,18 +6543,18 @@ function au() {
6541
6543
  }
6542
6544
  return null;
6543
6545
  }
6544
- var le = Object.assign, be = 0, Wn, zn, Vn, Bn, Gn, Qn, Hn;
6545
- function Jn() {
6546
+ var le = Object.assign, be = 0, zn, Vn, Bn, Gn, Qn, Hn, Jn;
6547
+ function Yn() {
6546
6548
  }
6547
- Jn.__reactDisabledLog = !0;
6549
+ Yn.__reactDisabledLog = !0;
6548
6550
  function zs() {
6549
6551
  {
6550
6552
  if (be === 0) {
6551
- Wn = console.log, zn = console.info, Vn = console.warn, Bn = console.error, Gn = console.group, Qn = console.groupCollapsed, Hn = console.groupEnd;
6553
+ zn = console.log, Vn = console.info, Bn = console.warn, Gn = console.error, Qn = console.group, Hn = console.groupCollapsed, Jn = console.groupEnd;
6552
6554
  var d = {
6553
6555
  configurable: !0,
6554
6556
  enumerable: !0,
6555
- value: Jn,
6557
+ value: Yn,
6556
6558
  writable: !0
6557
6559
  };
6558
6560
  Object.defineProperties(console, {
@@ -6578,52 +6580,52 @@ function au() {
6578
6580
  };
6579
6581
  Object.defineProperties(console, {
6580
6582
  log: le({}, d, {
6581
- value: Wn
6583
+ value: zn
6582
6584
  }),
6583
6585
  info: le({}, d, {
6584
- value: zn
6586
+ value: Vn
6585
6587
  }),
6586
6588
  warn: le({}, d, {
6587
- value: Vn
6589
+ value: Bn
6588
6590
  }),
6589
6591
  error: le({}, d, {
6590
- value: Bn
6592
+ value: Gn
6591
6593
  }),
6592
6594
  group: le({}, d, {
6593
- value: Gn
6595
+ value: Qn
6594
6596
  }),
6595
6597
  groupCollapsed: le({}, d, {
6596
- value: Qn
6598
+ value: Hn
6597
6599
  }),
6598
6600
  groupEnd: le({}, d, {
6599
- value: Hn
6601
+ value: Jn
6600
6602
  })
6601
6603
  });
6602
6604
  }
6603
6605
  be < 0 && S("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
6604
6606
  }
6605
6607
  }
6606
- var Ut = _.ReactCurrentDispatcher, Lt;
6608
+ var Lt = _.ReactCurrentDispatcher, Ft;
6607
6609
  function lt(d, T, v) {
6608
6610
  {
6609
- if (Lt === void 0)
6611
+ if (Ft === void 0)
6610
6612
  try {
6611
6613
  throw Error();
6612
6614
  } catch (M) {
6613
6615
  var A = M.stack.trim().match(/\n( *(at )?)/);
6614
- Lt = A && A[1] || "";
6616
+ Ft = A && A[1] || "";
6615
6617
  }
6616
6618
  return `
6617
- ` + Lt + d;
6619
+ ` + Ft + d;
6618
6620
  }
6619
6621
  }
6620
- var Ft = !1, ft;
6622
+ var Nt = !1, ft;
6621
6623
  {
6622
6624
  var Bs = typeof WeakMap == "function" ? WeakMap : Map;
6623
6625
  ft = new Bs();
6624
6626
  }
6625
- function Yn(d, T) {
6626
- if (!d || Ft)
6627
+ function Zn(d, T) {
6628
+ if (!d || Nt)
6627
6629
  return "";
6628
6630
  {
6629
6631
  var v = ft.get(d);
@@ -6631,11 +6633,11 @@ function au() {
6631
6633
  return v;
6632
6634
  }
6633
6635
  var A;
6634
- Ft = !0;
6636
+ Nt = !0;
6635
6637
  var M = Error.prepareStackTrace;
6636
6638
  Error.prepareStackTrace = void 0;
6637
6639
  var R;
6638
- R = Ut.current, Ut.current = null, zs();
6640
+ R = Lt.current, Lt.current = null, zs();
6639
6641
  try {
6640
6642
  if (T) {
6641
6643
  var I = function() {
@@ -6688,13 +6690,13 @@ function au() {
6688
6690
  }
6689
6691
  }
6690
6692
  } finally {
6691
- Ft = !1, Ut.current = R, Vs(), Error.prepareStackTrace = M;
6693
+ Nt = !1, Lt.current = R, Vs(), Error.prepareStackTrace = M;
6692
6694
  }
6693
6695
  var Ie = d ? d.displayName || d.name : "", we = Ie ? lt(Ie) : "";
6694
6696
  return typeof d == "function" && ft.set(d, we), we;
6695
6697
  }
6696
6698
  function Gs(d, T, v) {
6697
- return Yn(d, !1);
6699
+ return Zn(d, !1);
6698
6700
  }
6699
6701
  function Qs(d) {
6700
6702
  var T = d.prototype;
@@ -6704,7 +6706,7 @@ function au() {
6704
6706
  if (d == null)
6705
6707
  return "";
6706
6708
  if (typeof d == "function")
6707
- return Yn(d, Qs(d));
6709
+ return Zn(d, Qs(d));
6708
6710
  if (typeof d == "string")
6709
6711
  return lt(d);
6710
6712
  switch (d) {
@@ -6729,13 +6731,13 @@ function au() {
6729
6731
  }
6730
6732
  return "";
6731
6733
  }
6732
- var ze = Object.prototype.hasOwnProperty, Zn = {}, Xn = _.ReactDebugCurrentFrame;
6734
+ var ze = Object.prototype.hasOwnProperty, Xn = {}, er = _.ReactDebugCurrentFrame;
6733
6735
  function ht(d) {
6734
6736
  if (d) {
6735
6737
  var T = d._owner, v = dt(d.type, d._source, T ? T.type : null);
6736
- Xn.setExtraStackFrame(v);
6738
+ er.setExtraStackFrame(v);
6737
6739
  } else
6738
- Xn.setExtraStackFrame(null);
6740
+ er.setExtraStackFrame(null);
6739
6741
  }
6740
6742
  function Hs(d, T, v, A, M) {
6741
6743
  {
@@ -6752,12 +6754,12 @@ function au() {
6752
6754
  } catch (D) {
6753
6755
  C = D;
6754
6756
  }
6755
- C && !(C instanceof Error) && (ht(M), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", A || "React class", v, I, typeof C), ht(null)), C instanceof Error && !(C.message in Zn) && (Zn[C.message] = !0, ht(M), S("Failed %s type: %s", v, C.message), ht(null));
6757
+ C && !(C instanceof Error) && (ht(M), S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", A || "React class", v, I, typeof C), ht(null)), C instanceof Error && !(C.message in Xn) && (Xn[C.message] = !0, ht(M), S("Failed %s type: %s", v, C.message), ht(null));
6756
6758
  }
6757
6759
  }
6758
6760
  }
6759
6761
  var Js = Array.isArray;
6760
- function Nt(d) {
6762
+ function Kt(d) {
6761
6763
  return Js(d);
6762
6764
  }
6763
6765
  function Ys(d) {
@@ -6768,24 +6770,24 @@ function au() {
6768
6770
  }
6769
6771
  function Zs(d) {
6770
6772
  try {
6771
- return er(d), !1;
6773
+ return tr(d), !1;
6772
6774
  } catch {
6773
6775
  return !0;
6774
6776
  }
6775
6777
  }
6776
- function er(d) {
6778
+ function tr(d) {
6777
6779
  return "" + d;
6778
6780
  }
6779
- function tr(d) {
6781
+ function nr(d) {
6780
6782
  if (Zs(d))
6781
- return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ys(d)), er(d);
6783
+ return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ys(d)), tr(d);
6782
6784
  }
6783
- var nr = _.ReactCurrentOwner, Xs = {
6785
+ var rr = _.ReactCurrentOwner, Xs = {
6784
6786
  key: !0,
6785
6787
  ref: !0,
6786
6788
  __self: !0,
6787
6789
  __source: !0
6788
- }, rr, sr;
6790
+ }, sr, ir;
6789
6791
  function ei(d) {
6790
6792
  if (ze.call(d, "ref")) {
6791
6793
  var T = Object.getOwnPropertyDescriptor(d, "ref").get;
@@ -6803,12 +6805,12 @@ function au() {
6803
6805
  return d.key !== void 0;
6804
6806
  }
6805
6807
  function ni(d, T) {
6806
- typeof d.ref == "string" && nr.current;
6808
+ typeof d.ref == "string" && rr.current;
6807
6809
  }
6808
6810
  function ri(d, T) {
6809
6811
  {
6810
6812
  var v = function() {
6811
- rr || (rr = !0, S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", T));
6813
+ sr || (sr = !0, S("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", T));
6812
6814
  };
6813
6815
  v.isReactWarning = !0, Object.defineProperty(d, "key", {
6814
6816
  get: v,
@@ -6819,7 +6821,7 @@ function au() {
6819
6821
  function si(d, T) {
6820
6822
  {
6821
6823
  var v = function() {
6822
- sr || (sr = !0, S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", T));
6824
+ ir || (ir = !0, S("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", T));
6823
6825
  };
6824
6826
  v.isReactWarning = !0, Object.defineProperty(d, "ref", {
6825
6827
  get: v,
@@ -6859,7 +6861,7 @@ function au() {
6859
6861
  function oi(d, T, v, A, M) {
6860
6862
  {
6861
6863
  var R, I = {}, C = null, G = null;
6862
- v !== void 0 && (tr(v), C = "" + v), ti(T) && (tr(T.key), C = "" + T.key), ei(T) && (G = T.ref, ni(T, M));
6864
+ v !== void 0 && (nr(v), C = "" + v), ti(T) && (nr(T.key), C = "" + T.key), ei(T) && (G = T.ref, ni(T, M));
6863
6865
  for (R in T)
6864
6866
  ze.call(T, R) && !Xs.hasOwnProperty(R) && (I[R] = T[R]);
6865
6867
  if (d && d.defaultProps) {
@@ -6871,26 +6873,26 @@ function au() {
6871
6873
  var F = typeof d == "function" ? d.displayName || d.name || "Unknown" : d;
6872
6874
  C && ri(I, F), G && si(I, F);
6873
6875
  }
6874
- return ii(d, C, G, M, A, nr.current, I);
6876
+ return ii(d, C, G, M, A, rr.current, I);
6875
6877
  }
6876
6878
  }
6877
- var Kt = _.ReactCurrentOwner, ir = _.ReactDebugCurrentFrame;
6879
+ var qt = _.ReactCurrentOwner, or = _.ReactDebugCurrentFrame;
6878
6880
  function Pe(d) {
6879
6881
  if (d) {
6880
6882
  var T = d._owner, v = dt(d.type, d._source, T ? T.type : null);
6881
- ir.setExtraStackFrame(v);
6883
+ or.setExtraStackFrame(v);
6882
6884
  } else
6883
- ir.setExtraStackFrame(null);
6885
+ or.setExtraStackFrame(null);
6884
6886
  }
6885
- var qt;
6886
- qt = !1;
6887
- function Wt(d) {
6887
+ var Wt;
6888
+ Wt = !1;
6889
+ function zt(d) {
6888
6890
  return typeof d == "object" && d !== null && d.$$typeof === n;
6889
6891
  }
6890
- function or() {
6892
+ function ar() {
6891
6893
  {
6892
- if (Kt.current) {
6893
- var d = ie(Kt.current.type);
6894
+ if (qt.current) {
6895
+ var d = ie(qt.current.type);
6894
6896
  if (d)
6895
6897
  return `
6896
6898
 
@@ -6902,10 +6904,10 @@ Check the render method of \`` + d + "`.";
6902
6904
  function ai(d) {
6903
6905
  return "";
6904
6906
  }
6905
- var ar = {};
6907
+ var cr = {};
6906
6908
  function ci(d) {
6907
6909
  {
6908
- var T = or();
6910
+ var T = ar();
6909
6911
  if (!T) {
6910
6912
  var v = typeof d == "string" ? d : d.displayName || d.name;
6911
6913
  v && (T = `
@@ -6915,35 +6917,35 @@ Check the top-level render call using <` + v + ">.");
6915
6917
  return T;
6916
6918
  }
6917
6919
  }
6918
- function cr(d, T) {
6920
+ function ur(d, T) {
6919
6921
  {
6920
6922
  if (!d._store || d._store.validated || d.key != null)
6921
6923
  return;
6922
6924
  d._store.validated = !0;
6923
6925
  var v = ci(T);
6924
- if (ar[v])
6926
+ if (cr[v])
6925
6927
  return;
6926
- ar[v] = !0;
6928
+ cr[v] = !0;
6927
6929
  var A = "";
6928
- d && d._owner && d._owner !== Kt.current && (A = " It was passed a child from " + ie(d._owner.type) + "."), Pe(d), S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, A), Pe(null);
6930
+ d && d._owner && d._owner !== qt.current && (A = " It was passed a child from " + ie(d._owner.type) + "."), Pe(d), S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, A), Pe(null);
6929
6931
  }
6930
6932
  }
6931
- function ur(d, T) {
6933
+ function lr(d, T) {
6932
6934
  {
6933
6935
  if (typeof d != "object")
6934
6936
  return;
6935
- if (Nt(d))
6937
+ if (Kt(d))
6936
6938
  for (var v = 0; v < d.length; v++) {
6937
6939
  var A = d[v];
6938
- Wt(A) && cr(A, T);
6940
+ zt(A) && ur(A, T);
6939
6941
  }
6940
- else if (Wt(d))
6942
+ else if (zt(d))
6941
6943
  d._store && (d._store.validated = !0);
6942
6944
  else if (d) {
6943
6945
  var M = m(d);
6944
6946
  if (typeof M == "function" && M !== d.entries)
6945
6947
  for (var R = M.call(d), I; !(I = R.next()).done; )
6946
- Wt(I.value) && cr(I.value, T);
6948
+ zt(I.value) && ur(I.value, T);
6947
6949
  }
6948
6950
  }
6949
6951
  }
@@ -6964,8 +6966,8 @@ Check the top-level render call using <` + v + ">.");
6964
6966
  if (v) {
6965
6967
  var A = ie(T);
6966
6968
  Hs(v, d.props, "prop", A, d);
6967
- } else if (T.PropTypes !== void 0 && !qt) {
6968
- qt = !0;
6969
+ } else if (T.PropTypes !== void 0 && !Wt) {
6970
+ Wt = !0;
6969
6971
  var M = ie(T);
6970
6972
  S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", M || "Unknown");
6971
6973
  }
@@ -6984,17 +6986,17 @@ Check the top-level render call using <` + v + ">.");
6984
6986
  d.ref !== null && (Pe(d), S("Invalid attribute `ref` supplied to `React.Fragment`."), Pe(null));
6985
6987
  }
6986
6988
  }
6987
- var lr = {};
6988
- function fr(d, T, v, A, M, R) {
6989
+ var fr = {};
6990
+ function dr(d, T, v, A, M, R) {
6989
6991
  {
6990
- var I = $t(d);
6992
+ var I = Dt(d);
6991
6993
  if (!I) {
6992
6994
  var C = "";
6993
6995
  (d === void 0 || typeof d == "object" && d !== null && Object.keys(d).length === 0) && (C += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
6994
6996
  var G = ai();
6995
- G ? C += G : C += or();
6997
+ G ? C += G : C += ar();
6996
6998
  var D;
6997
- d === null ? D = "null" : Nt(d) ? D = "array" : d !== void 0 && d.$$typeof === n ? (D = "<" + (ie(d.type) || "Unknown") + " />", C = " Did you accidentally export a JSX literal instead of a component?") : D = typeof d, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", D, C);
6999
+ d === null ? D = "null" : Kt(d) ? D = "array" : d !== void 0 && d.$$typeof === n ? (D = "<" + (ie(d.type) || "Unknown") + " />", C = " Did you accidentally export a JSX literal instead of a component?") : D = typeof d, S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", D, C);
6998
7000
  }
6999
7001
  var F = oi(d, T, v, M, R);
7000
7002
  if (F == null)
@@ -7003,52 +7005,52 @@ Check the top-level render call using <` + v + ">.");
7003
7005
  var re = T.children;
7004
7006
  if (re !== void 0)
7005
7007
  if (A)
7006
- if (Nt(re)) {
7008
+ if (Kt(re)) {
7007
7009
  for (var Ie = 0; Ie < re.length; Ie++)
7008
- ur(re[Ie], d);
7010
+ lr(re[Ie], d);
7009
7011
  Object.freeze && Object.freeze(re);
7010
7012
  } else
7011
7013
  S("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
7012
7014
  else
7013
- ur(re, d);
7015
+ lr(re, d);
7014
7016
  }
7015
7017
  if (ze.call(T, "key")) {
7016
7018
  var we = ie(d), J = Object.keys(T).filter(function(bi) {
7017
7019
  return bi !== "key";
7018
- }), zt = J.length > 0 ? "{key: someKey, " + J.join(": ..., ") + ": ...}" : "{key: someKey}";
7019
- if (!lr[we + zt]) {
7020
+ }), Vt = J.length > 0 ? "{key: someKey, " + J.join(": ..., ") + ": ...}" : "{key: someKey}";
7021
+ if (!fr[we + Vt]) {
7020
7022
  var yi = J.length > 0 ? "{" + J.join(": ..., ") + ": ...}" : "{}";
7021
7023
  S(`A props object containing a "key" prop is being spread into JSX:
7022
7024
  let props = %s;
7023
7025
  <%s {...props} />
7024
7026
  React keys must be passed directly to JSX without using spread:
7025
7027
  let props = %s;
7026
- <%s key={someKey} {...props} />`, zt, we, yi, we), lr[we + zt] = !0;
7028
+ <%s key={someKey} {...props} />`, Vt, we, yi, we), fr[we + Vt] = !0;
7027
7029
  }
7028
7030
  }
7029
7031
  return d === s ? li(F) : ui(F), F;
7030
7032
  }
7031
7033
  }
7032
7034
  function fi(d, T, v) {
7033
- return fr(d, T, v, !0);
7035
+ return dr(d, T, v, !0);
7034
7036
  }
7035
7037
  function di(d, T, v) {
7036
- return fr(d, T, v, !1);
7038
+ return dr(d, T, v, !1);
7037
7039
  }
7038
7040
  var hi = di, pi = fi;
7039
7041
  Ge.Fragment = s, Ge.jsx = hi, Ge.jsxs = pi;
7040
7042
  }(), Ge;
7041
7043
  }
7042
- var cu = {};
7043
- cu.NODE_ENV === "production" ? wn.exports = ou() : wn.exports = au();
7044
- var V = wn.exports;
7045
- const uu = {
7044
+ var uu = {};
7045
+ uu.NODE_ENV === "production" ? Tn.exports = au() : Tn.exports = cu();
7046
+ var V = Tn.exports;
7047
+ const lu = {
7046
7048
  isLoading: !0,
7047
7049
  data: void 0,
7048
7050
  pageInfo: void 0,
7049
7051
  error: void 0
7050
7052
  };
7051
- function Gr(t) {
7053
+ function Qr(t) {
7052
7054
  return {
7053
7055
  isLoading: !t,
7054
7056
  data: void 0,
@@ -7057,10 +7059,10 @@ function Gr(t) {
7057
7059
  ...t || {}
7058
7060
  };
7059
7061
  }
7060
- function lu(t, e, n) {
7062
+ function fu(t, e, n) {
7061
7063
  e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
7062
- const r = e ? tu(e) : null, s = q(r), i = it(Gr(t._reactor.getPreviousResult(r))), o = _e(
7063
- (c) => (i.current = Gr(t._reactor.getPreviousResult(r)), c(), r ? t.subscribeQuery(r, (l) => {
7064
+ const r = e ? nu(e) : null, s = q(r), i = it(Qr(t._reactor.getPreviousResult(r))), o = _e(
7065
+ (c) => (i.current = Qr(t._reactor.getPreviousResult(r)), c(), r ? t.subscribeQuery(r, (l) => {
7064
7066
  i.current = {
7065
7067
  isLoading: !l,
7066
7068
  // @ts-expect-error: ts thinks this will always be overwritten
@@ -7076,9 +7078,9 @@ function lu(t, e, n) {
7076
7078
  // Build a new subscribe function if the query changes
7077
7079
  [s]
7078
7080
  );
7079
- return { state: Xt(o, () => i.current, () => uu), query: r };
7081
+ return { state: en(o, () => i.current, () => lu), query: r };
7080
7082
  }
7081
- function fu() {
7083
+ function du() {
7082
7084
  const t = it(null);
7083
7085
  Oe(() => {
7084
7086
  n();
@@ -7091,14 +7093,14 @@ function fu() {
7091
7093
  }
7092
7094
  return { set: e, clear: n };
7093
7095
  }
7094
- const du = 1e3;
7095
- function hu(t, e, n) {
7096
+ const hu = 1e3;
7097
+ function pu(t, e, n) {
7096
7098
  const r = it(n);
7097
7099
  r.current = n, Oe(() => t.core._reactor.subscribeTopic(t.id, e, (i, o) => {
7098
7100
  r.current(i, o);
7099
7101
  }), [t.id, e]);
7100
7102
  }
7101
- function pu(t, e) {
7103
+ function yu(t, e) {
7102
7104
  return Oe(() => t.core._reactor.joinRoom(t.id), [t.id]), _e((r) => {
7103
7105
  t.core._reactor.publishTopic({
7104
7106
  roomType: t.type,
@@ -7108,9 +7110,9 @@ function pu(t, e) {
7108
7110
  });
7109
7111
  }, [t.id, e]);
7110
7112
  }
7111
- function yu(t, e = {}) {
7113
+ function bu(t, e = {}) {
7112
7114
  var o, a;
7113
- const [n, r] = es(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
7115
+ const [n, r] = ts(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
7114
7116
  peers: {},
7115
7117
  isLoading: !0
7116
7118
  });
@@ -7120,24 +7122,24 @@ function yu(t, e = {}) {
7120
7122
  const s = _e((c) => {
7121
7123
  t.core._reactor.publishPresence(t.type, t.id, c);
7122
7124
  }, [t.type, t.id]);
7123
- return en(() => ({
7125
+ return tn(() => ({
7124
7126
  ...n,
7125
7127
  publishPresence: s
7126
7128
  }), [n, s]);
7127
7129
  }
7128
- function bu(t, e, n) {
7130
+ function gu(t, e, n) {
7129
7131
  Oe(() => t.core._reactor.joinRoom(t.id, e), [t.id]), Oe(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
7130
7132
  }
7131
- function gu(t, e, n = {}) {
7132
- const r = fu(), s = me.usePresence(t, {
7133
+ function _u(t, e, n = {}) {
7134
+ const r = du(), s = me.usePresence(t, {
7133
7135
  keys: [e]
7134
- }), i = en(() => {
7136
+ }), i = tn(() => {
7135
7137
  const l = t._core._reactor.getPresence(t.type, t.id);
7136
7138
  return n != null && n.writeOnly ? [] : Object.values((l == null ? void 0 : l.peers) ?? {}).filter((f) => f[e] === !0);
7137
7139
  }, [n == null ? void 0 : n.writeOnly, s]), o = _e((l) => {
7138
7140
  t.core._reactor.publishPresence(t.type, t.id, {
7139
7141
  [e]: l
7140
- }), l && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? du, () => {
7142
+ }), l && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? hu, () => {
7141
7143
  t.core._reactor.publishPresence(t.type, t.id, {
7142
7144
  [e]: null
7143
7145
  });
@@ -7147,7 +7149,7 @@ function gu(t, e, n = {}) {
7147
7149
  o(h);
7148
7150
  }, [n.stopOnEnter, o]), c = _e(() => {
7149
7151
  o(!1);
7150
- }, [o]), u = en(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
7152
+ }, [o]), u = tn(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
7151
7153
  return {
7152
7154
  active: i,
7153
7155
  setActive: o,
@@ -7155,13 +7157,13 @@ function gu(t, e, n = {}) {
7155
7157
  };
7156
7158
  }
7157
7159
  const me = {
7158
- useTopicEffect: hu,
7159
- usePublishTopic: pu,
7160
- usePresence: yu,
7161
- useSyncPresence: bu,
7162
- useTypingIndicator: gu
7160
+ useTopicEffect: pu,
7161
+ usePublishTopic: yu,
7162
+ usePresence: bu,
7163
+ useSyncPresence: gu,
7164
+ useTypingIndicator: _u
7163
7165
  };
7164
- class _u {
7166
+ class wu {
7165
7167
  constructor(e, n, r) {
7166
7168
  p(this, "core");
7167
7169
  /** @deprecated use `core` instead */
@@ -7248,14 +7250,14 @@ class _u {
7248
7250
  this.core = e, this._core = this.core, this.type = n, this.id = r;
7249
7251
  }
7250
7252
  }
7251
- const wu = {
7253
+ const Tu = {
7252
7254
  isLoading: !0,
7253
7255
  user: void 0,
7254
7256
  error: void 0
7255
7257
  };
7256
- class mt {
7258
+ class St {
7257
7259
  constructor(e, n) {
7258
- p(this, "tx", Fn());
7260
+ p(this, "tx", Nn());
7259
7261
  p(this, "auth");
7260
7262
  p(this, "storage");
7261
7263
  p(this, "core");
@@ -7283,7 +7285,7 @@ class mt {
7283
7285
  * console.log('Device ID:', deviceId)
7284
7286
  */
7285
7287
  p(this, "useLocalId", (e) => {
7286
- const [n, r] = es(null);
7288
+ const [n, r] = ts(null);
7287
7289
  return Oe(() => {
7288
7290
  (async () => {
7289
7291
  const i = await this.getLocalId(e);
@@ -7351,7 +7353,7 @@ class mt {
7351
7353
  * auth.user ? { goals: {} } : null,
7352
7354
  * );
7353
7355
  */
7354
- p(this, "useQuery", (e, n) => lu(this.core, e, n).state);
7356
+ p(this, "useQuery", (e, n) => fu(this.core, e, n).state);
7355
7357
  /**
7356
7358
  * Listen for the logged in state. This is useful
7357
7359
  * for deciding when to show a login screen.
@@ -7427,7 +7429,7 @@ class mt {
7427
7429
  const e = it(this.core._reactor.status), n = _e((s) => this.core.subscribeConnectionStatus((o) => {
7428
7430
  o !== e.current && (e.current = o, s());
7429
7431
  }), []);
7430
- return Xt(
7432
+ return en(
7431
7433
  n,
7432
7434
  () => e.current,
7433
7435
  // For SSR, always return 'connecting' as the initial state
@@ -7476,7 +7478,7 @@ class mt {
7476
7478
  const n = this.useAuth();
7477
7479
  return n.isLoading || n.error || n.user ? null : V.jsx(V.Fragment, { children: e });
7478
7480
  });
7479
- this.core = su(
7481
+ this.core = iu(
7480
7482
  e,
7481
7483
  // @ts-expect-error because TS can't resolve subclass statics
7482
7484
  this.constructor.Storage,
@@ -7500,13 +7502,13 @@ class mt {
7500
7502
  * const { peers } = db.rooms.usePresence(room);
7501
7503
  */
7502
7504
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7503
- return new _u(this.core, e, n);
7505
+ return new wu(this.core, e, n);
7504
7506
  }
7505
7507
  _useAuth() {
7506
7508
  const e = it(this.core._reactor._currentUserCached), n = _e((s) => this.core.subscribeAuth((o) => {
7507
7509
  e.current = { isLoading: !1, ...o }, s();
7508
7510
  }), []);
7509
- return Xt(n, () => e.current, () => wu);
7511
+ return en(n, () => e.current, () => Tu);
7510
7512
  }
7511
7513
  /**
7512
7514
  * One time query for the logged in state. This is useful
@@ -7522,23 +7524,23 @@ class mt {
7522
7524
  return this.core.getAuth();
7523
7525
  }
7524
7526
  }
7525
- p(mt, "Storage"), p(mt, "NetworkListener"), p(mt, "EventSourceImpl");
7526
- class Qr extends Error {
7527
+ p(St, "Storage"), p(St, "NetworkListener"), p(St, "EventSourceImpl");
7528
+ class Hr extends Error {
7527
7529
  constructor(e, n) {
7528
7530
  super(e), this.name = "ParseError", this.type = n.type, this.field = n.field, this.value = n.value, this.line = n.line;
7529
7531
  }
7530
7532
  }
7531
- function Zt(t) {
7533
+ function Xt(t) {
7532
7534
  }
7533
- function Tu(t) {
7535
+ function mu(t) {
7534
7536
  if (typeof t == "function")
7535
7537
  throw new TypeError(
7536
7538
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
7537
7539
  );
7538
- const { onEvent: e = Zt, onError: n = Zt, onRetry: r = Zt, onComment: s } = t;
7540
+ const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: s } = t;
7539
7541
  let i = "", o = !0, a, c = "", u = "";
7540
7542
  function l(g) {
7541
- const w = o ? g.replace(/^\xEF\xBB\xBF/, "") : g, [m, _] = mu(`${i}${w}`);
7543
+ const w = o ? g.replace(/^\xEF\xBB\xBF/, "") : g, [m, _] = Su(`${i}${w}`);
7542
7544
  for (const S of m)
7543
7545
  f(S);
7544
7546
  i = _, o = !1;
@@ -7574,7 +7576,7 @@ function Tu(t) {
7574
7576
  break;
7575
7577
  case "retry":
7576
7578
  /^\d+$/.test(w) ? r(parseInt(w, 10)) : n(
7577
- new Qr(`Invalid \`retry\` value: "${w}"`, {
7579
+ new Hr(`Invalid \`retry\` value: "${w}"`, {
7578
7580
  type: "invalid-retry",
7579
7581
  value: w,
7580
7582
  line: m
@@ -7583,7 +7585,7 @@ function Tu(t) {
7583
7585
  break;
7584
7586
  default:
7585
7587
  n(
7586
- new Qr(
7588
+ new Hr(
7587
7589
  `Unknown field "${g.length > 20 ? `${g.slice(0, 20)}…` : g}"`,
7588
7590
  { type: "unknown-field", field: g, value: w, line: m }
7589
7591
  )
@@ -7606,7 +7608,7 @@ function Tu(t) {
7606
7608
  }
7607
7609
  return { feed: l, reset: b };
7608
7610
  }
7609
- function mu(t) {
7611
+ function Su(t) {
7610
7612
  const e = [];
7611
7613
  let n = "", r = 0;
7612
7614
  for (; r < t.length; ) {
@@ -7624,7 +7626,7 @@ function mu(t) {
7624
7626
  }
7625
7627
  return [e, n];
7626
7628
  }
7627
- class Hr extends Event {
7629
+ class Jr extends Event {
7628
7630
  /**
7629
7631
  * Constructs a new `ErrorEvent` instance. This is typically not called directly,
7630
7632
  * but rather emitted by the `EventSource` object when an error occurs.
@@ -7649,7 +7651,7 @@ class Hr extends Event {
7649
7651
  * @returns A string representation of the error
7650
7652
  */
7651
7653
  [Symbol.for("nodejs.util.inspect.custom")](e, n, r) {
7652
- return r(Jr(this), n);
7654
+ return r(Yr(this), n);
7653
7655
  }
7654
7656
  /**
7655
7657
  * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -7663,17 +7665,17 @@ class Hr extends Event {
7663
7665
  * @returns A string representation of the error
7664
7666
  */
7665
7667
  [Symbol.for("Deno.customInspect")](e, n) {
7666
- return e(Jr(this), n);
7668
+ return e(Yr(this), n);
7667
7669
  }
7668
7670
  }
7669
- function Su(t) {
7671
+ function vu(t) {
7670
7672
  const e = globalThis.DOMException;
7671
7673
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7672
7674
  }
7673
- function Tn(t) {
7674
- return t instanceof Error ? "errors" in t && Array.isArray(t.errors) ? t.errors.map(Tn).join(", ") : "cause" in t && t.cause instanceof Error ? `${t}: ${Tn(t.cause)}` : t.message : `${t}`;
7675
+ function mn(t) {
7676
+ return t instanceof Error ? "errors" in t && Array.isArray(t.errors) ? t.errors.map(mn).join(", ") : "cause" in t && t.cause instanceof Error ? `${t}: ${mn(t.cause)}` : t.message : `${t}`;
7675
7677
  }
7676
- function Jr(t) {
7678
+ function Yr(t) {
7677
7679
  return {
7678
7680
  type: t.type,
7679
7681
  message: t.message,
@@ -7685,11 +7687,11 @@ function Jr(t) {
7685
7687
  }
7686
7688
  var qs = (t) => {
7687
7689
  throw TypeError(t);
7688
- }, qn = (t, e, n) => e.has(t) || qs("Cannot " + n), k = (t, e, n) => (qn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), K = (t, e, n) => e.has(t) ? qs("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), $ = (t, e, n, r) => (qn(t, e, "write to private field"), e.set(t, n), n), he = (t, e, n) => (qn(t, e, "access private method"), n), Y, Se, je, St, Pt, rt, $e, st, ge, Re, Ue, xe, Ze, oe, mn, Sn, vn, Yr, En, On, Xe, An, kn;
7689
- class vt extends EventTarget {
7690
+ }, Wn = (t, e, n) => e.has(t) || qs("Cannot " + n), k = (t, e, n) => (Wn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), K = (t, e, n) => e.has(t) ? qs("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), $ = (t, e, n, r) => (Wn(t, e, "write to private field"), e.set(t, n), n), he = (t, e, n) => (Wn(t, e, "access private method"), n), Y, Se, je, vt, It, rt, $e, st, ge, Re, Ue, xe, Ze, oe, Sn, vn, En, Zr, On, An, Xe, kn, Cn;
7691
+ class Et extends EventTarget {
7690
7692
  constructor(e, n) {
7691
7693
  var r, s;
7692
- super(), K(this, oe), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, K(this, Y), K(this, Se), K(this, je), K(this, St), K(this, Pt), K(this, rt), K(this, $e), K(this, st, null), K(this, ge), K(this, Re), K(this, Ue, null), K(this, xe, null), K(this, Ze, null), K(this, Sn, async (i) => {
7694
+ super(), K(this, oe), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, K(this, Y), K(this, Se), K(this, je), K(this, vt), K(this, It), K(this, rt), K(this, $e), K(this, st, null), K(this, ge), K(this, Re), K(this, Ue, null), K(this, xe, null), K(this, Ze, null), K(this, vn, async (i) => {
7693
7695
  var o;
7694
7696
  k(this, Re).reset();
7695
7697
  const { body: a, redirected: c, status: u, headers: l } = i;
@@ -7717,11 +7719,11 @@ class vt extends EventTarget {
7717
7719
  let b = !0;
7718
7720
  do {
7719
7721
  const { done: g, value: w } = await y.read();
7720
- w && k(this, Re).feed(h.decode(w, { stream: !g })), g && (b = !1, k(this, Re).reset(), he(this, oe, An).call(this));
7722
+ w && k(this, Re).feed(h.decode(w, { stream: !g })), g && (b = !1, k(this, Re).reset(), he(this, oe, kn).call(this));
7721
7723
  } while (b);
7722
- }), K(this, vn, (i) => {
7723
- $(this, ge, void 0), !(i.name === "AbortError" || i.type === "aborted") && he(this, oe, An).call(this, Tn(i));
7724
7724
  }), K(this, En, (i) => {
7725
+ $(this, ge, void 0), !(i.name === "AbortError" || i.type === "aborted") && he(this, oe, kn).call(this, mn(i));
7726
+ }), K(this, On, (i) => {
7725
7727
  typeof i.id == "string" && $(this, st, i.id);
7726
7728
  const o = new MessageEvent(i.event || "message", {
7727
7729
  data: i.data,
@@ -7729,25 +7731,25 @@ class vt extends EventTarget {
7729
7731
  lastEventId: i.id || ""
7730
7732
  });
7731
7733
  k(this, xe) && (!i.event || i.event === "message") && k(this, xe).call(this, o), this.dispatchEvent(o);
7732
- }), K(this, On, (i) => {
7734
+ }), K(this, An, (i) => {
7733
7735
  $(this, rt, i);
7734
- }), K(this, kn, () => {
7735
- $(this, $e, void 0), k(this, Y) === this.CONNECTING && he(this, oe, mn).call(this);
7736
+ }), K(this, Cn, () => {
7737
+ $(this, $e, void 0), k(this, Y) === this.CONNECTING && he(this, oe, Sn).call(this);
7736
7738
  });
7737
7739
  try {
7738
7740
  if (e instanceof URL)
7739
7741
  $(this, Se, e);
7740
7742
  else if (typeof e == "string")
7741
- $(this, Se, new URL(e, vu()));
7743
+ $(this, Se, new URL(e, Eu()));
7742
7744
  else
7743
7745
  throw new Error("Invalid URL");
7744
7746
  } catch {
7745
- throw Su("An invalid or illegal string was specified");
7747
+ throw vu("An invalid or illegal string was specified");
7746
7748
  }
7747
- $(this, Re, Tu({
7748
- onEvent: k(this, En),
7749
- onRetry: k(this, On)
7750
- })), $(this, Y, this.CONNECTING), $(this, rt, 3e3), $(this, Pt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, St, (s = n == null ? void 0 : n.withCredentials) != null ? s : !1), he(this, oe, mn).call(this);
7749
+ $(this, Re, mu({
7750
+ onEvent: k(this, On),
7751
+ onRetry: k(this, An)
7752
+ })), $(this, Y, this.CONNECTING), $(this, rt, 3e3), $(this, It, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, vt, (s = n == null ? void 0 : n.withCredentials) != null ? s : !1), he(this, oe, Sn).call(this);
7751
7753
  }
7752
7754
  /**
7753
7755
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -7778,7 +7780,7 @@ class vt extends EventTarget {
7778
7780
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
7779
7781
  */
7780
7782
  get withCredentials() {
7781
- return k(this, St);
7783
+ return k(this, vt);
7782
7784
  }
7783
7785
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
7784
7786
  get onerror() {
@@ -7820,20 +7822,20 @@ class vt extends EventTarget {
7820
7822
  k(this, $e) && clearTimeout(k(this, $e)), k(this, Y) !== this.CLOSED && (k(this, ge) && k(this, ge).abort(), $(this, Y, this.CLOSED), $(this, ge, void 0));
7821
7823
  }
7822
7824
  }
7823
- Y = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakMap(), Pt = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), Re = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new WeakSet(), /**
7825
+ Y = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), je = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), It = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), Re = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new WeakSet(), /**
7824
7826
  * Connect to the given URL and start receiving events
7825
7827
  *
7826
7828
  * @internal
7827
7829
  */
7828
- mn = function() {
7829
- $(this, Y, this.CONNECTING), $(this, ge, new AbortController()), k(this, Pt)(k(this, Se), he(this, oe, Yr).call(this)).then(k(this, Sn)).catch(k(this, vn));
7830
- }, Sn = /* @__PURE__ */ new WeakMap(), vn = /* @__PURE__ */ new WeakMap(), /**
7830
+ Sn = function() {
7831
+ $(this, Y, this.CONNECTING), $(this, ge, new AbortController()), k(this, It)(k(this, Se), he(this, oe, Zr).call(this)).then(k(this, vn)).catch(k(this, En));
7832
+ }, vn = /* @__PURE__ */ new WeakMap(), En = /* @__PURE__ */ new WeakMap(), /**
7831
7833
  * Get request options for the `fetch()` request
7832
7834
  *
7833
7835
  * @returns The request options
7834
7836
  * @internal
7835
7837
  */
7836
- Yr = function() {
7838
+ Zr = function() {
7837
7839
  var t;
7838
7840
  const e = {
7839
7841
  // [spec] Let `corsAttributeState` be `Anonymous`…
@@ -7845,7 +7847,7 @@ Yr = function() {
7845
7847
  signal: (t = k(this, ge)) == null ? void 0 : t.signal
7846
7848
  };
7847
7849
  return "window" in globalThis && (e.credentials = this.withCredentials ? "include" : "same-origin"), e;
7848
- }, En = /* @__PURE__ */ new WeakMap(), On = /* @__PURE__ */ new WeakMap(), /**
7850
+ }, On = /* @__PURE__ */ new WeakMap(), An = /* @__PURE__ */ new WeakMap(), /**
7849
7851
  * Handles the process referred to in the EventSource specification as "failing a connection".
7850
7852
  *
7851
7853
  * @param error - The error causing the connection to fail
@@ -7855,7 +7857,7 @@ Yr = function() {
7855
7857
  Xe = function(t, e) {
7856
7858
  var n;
7857
7859
  k(this, Y) !== this.CLOSED && $(this, Y, this.CLOSED);
7858
- const r = new Hr("error", { code: e, message: t });
7860
+ const r = new Jr("error", { code: e, message: t });
7859
7861
  (n = k(this, Ue)) == null || n.call(this, r), this.dispatchEvent(r);
7860
7862
  }, /**
7861
7863
  * Schedules a reconnection attempt against the EventSource endpoint.
@@ -7864,46 +7866,46 @@ Xe = function(t, e) {
7864
7866
  * @param code - The HTTP status code, if available
7865
7867
  * @internal
7866
7868
  */
7867
- An = function(t, e) {
7869
+ kn = function(t, e) {
7868
7870
  var n;
7869
7871
  if (k(this, Y) === this.CLOSED)
7870
7872
  return;
7871
7873
  $(this, Y, this.CONNECTING);
7872
- const r = new Hr("error", { code: e, message: t });
7873
- (n = k(this, Ue)) == null || n.call(this, r), this.dispatchEvent(r), $(this, $e, setTimeout(k(this, kn), k(this, rt)));
7874
- }, kn = /* @__PURE__ */ new WeakMap(), /**
7874
+ const r = new Jr("error", { code: e, message: t });
7875
+ (n = k(this, Ue)) == null || n.call(this, r), this.dispatchEvent(r), $(this, $e, setTimeout(k(this, Cn), k(this, rt)));
7876
+ }, Cn = /* @__PURE__ */ new WeakMap(), /**
7875
7877
  * ReadyState representing an EventSource currently trying to connect
7876
7878
  *
7877
7879
  * @public
7878
7880
  */
7879
- vt.CONNECTING = 0, /**
7881
+ Et.CONNECTING = 0, /**
7880
7882
  * ReadyState representing an EventSource connection that is open (eg connected)
7881
7883
  *
7882
7884
  * @public
7883
7885
  */
7884
- vt.OPEN = 1, /**
7886
+ Et.OPEN = 1, /**
7885
7887
  * ReadyState representing an EventSource connection that is closed (eg disconnected)
7886
7888
  *
7887
7889
  * @public
7888
7890
  */
7889
- vt.CLOSED = 2;
7890
- function vu() {
7891
+ Et.CLOSED = 2;
7892
+ function Eu() {
7891
7893
  const t = "document" in globalThis ? globalThis.document : void 0;
7892
7894
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7893
7895
  }
7894
- class Ws extends mt {
7896
+ class Ws extends St {
7895
7897
  }
7896
- p(Ws, "EventSourceImpl", vt);
7897
- function Eu(t) {
7898
+ p(Ws, "EventSourceImpl", Et);
7899
+ function Ou(t) {
7898
7900
  const e = {
7899
7901
  ...t,
7900
7902
  useDateObjects: t.useDateObjects ?? !1
7901
7903
  };
7902
7904
  return new Ws(e, {
7903
- "@instantdb/react": Kn
7905
+ "@instantdb/react": qn
7904
7906
  });
7905
7907
  }
7906
- const Ru = Eu;
7908
+ const Ru = Ou;
7907
7909
  function xu({
7908
7910
  as: t = "div",
7909
7911
  spaceId: e,
@@ -7975,9 +7977,9 @@ function xu({
7975
7977
  "div",
7976
7978
  {
7977
7979
  style: {
7978
- ...Zr,
7979
- ...Au,
7980
- zIndex: u !== void 0 ? u : ku
7980
+ ...Xr,
7981
+ ...ku,
7982
+ zIndex: u !== void 0 ? u : Cu
7981
7983
  },
7982
7984
  children: Object.entries(f.peers).map(([_, S]) => {
7983
7985
  const O = S[l];
@@ -7985,7 +7987,7 @@ function xu({
7985
7987
  "div",
7986
7988
  {
7987
7989
  style: {
7988
- ...Zr,
7990
+ ...Xr,
7989
7991
  transform: `translate(${O.xPercent}%, ${O.yPercent}%)`,
7990
7992
  transformOrigin: "0 0",
7991
7993
  transition: "transform 100ms"
@@ -7993,7 +7995,7 @@ function xu({
7993
7995
  children: a ? a({
7994
7996
  color: O.color,
7995
7997
  presence: h == null ? void 0 : h.peers[_]
7996
- }) : /* @__PURE__ */ V.jsx(Ou, { ...O })
7998
+ }) : /* @__PURE__ */ V.jsx(Au, { ...O })
7997
7999
  },
7998
8000
  _
7999
8001
  ) : null;
@@ -8004,7 +8006,7 @@ function xu({
8004
8006
  ]
8005
8007
  );
8006
8008
  }
8007
- function Ou({ color: t }) {
8009
+ function Au({ color: t }) {
8008
8010
  const n = t || "black";
8009
8011
  return /* @__PURE__ */ V.jsxs(
8010
8012
  "svg",
@@ -8051,27 +8053,27 @@ function Ou({ color: t }) {
8051
8053
  }
8052
8054
  );
8053
8055
  }
8054
- const Zr = {
8056
+ const Xr = {
8055
8057
  position: "absolute",
8056
8058
  top: 0,
8057
8059
  left: 0,
8058
8060
  bottom: 0,
8059
8061
  right: 0
8060
- }, Au = {
8062
+ }, ku = {
8061
8063
  overflow: "hidden",
8062
8064
  pointerEvents: "none",
8063
8065
  userSelect: "none"
8064
- }, ku = 99999;
8066
+ }, Cu = 99999;
8065
8067
  export {
8066
8068
  xu as Cursors,
8067
- jt as InstantAPIError,
8068
- mt as InstantReactAbstractDatabase,
8069
+ Rt as InstantAPIError,
8070
+ St as InstantReactAbstractDatabase,
8069
8071
  Ws as InstantReactWebDatabase,
8070
8072
  Te as SyncTableCallbackEventType,
8071
8073
  ju as i,
8072
8074
  W as id,
8073
- Eu as init,
8075
+ Ou as init,
8074
8076
  Ru as init_experimental,
8075
- Iu as lookup,
8077
+ ua as lookup,
8076
8078
  Mu as tx
8077
8079
  };