@instantdb/react 0.22.62-experimental.drewh-entity-caching.19581443445.1 → 0.22.62

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,4 +1,4 @@
1
- import di, { useRef as at, useCallback as ge, useSyncExternalStore as rn, useEffect as ke, useMemo as sn, useState as fi, createElement as js } from "react";
1
+ import ci, { useRef as at, useCallback as ge, useSyncExternalStore as nn, useEffect as ke, useMemo as rn, useState as di, createElement as ks } from "react";
2
2
  function z(t) {
3
3
  if (typeof t == "number")
4
4
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -41,14 +41,14 @@ const U = {
41
41
  Remove: "remove",
42
42
  Replace: "replace",
43
43
  Add: "add"
44
- }, li = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Cs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), vt = Symbol.iterator, ne = {
44
+ }, fi = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), js = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), vt = Symbol.iterator, ne = {
45
45
  mutable: "mutable",
46
46
  immutable: "immutable"
47
- }, xn = {};
47
+ }, Rn = {};
48
48
  function nt(t, e) {
49
49
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
50
50
  }
51
- function wr(t, e) {
51
+ function Tr(t, e) {
52
52
  if (e in t) {
53
53
  let n = Reflect.getPrototypeOf(t);
54
54
  for (; n; ) {
@@ -59,10 +59,10 @@ function wr(t, e) {
59
59
  }
60
60
  }
61
61
  }
62
- function $n(t) {
62
+ function xn(t) {
63
63
  return Object.getPrototypeOf(t) === Set.prototype;
64
64
  }
65
- function Dn(t) {
65
+ function $n(t) {
66
66
  return Object.getPrototypeOf(t) === Map.prototype;
67
67
  }
68
68
  function te(t) {
@@ -73,9 +73,9 @@ function je(t) {
73
73
  return !!j(t);
74
74
  }
75
75
  function j(t) {
76
- return typeof t != "object" ? null : t == null ? void 0 : t[li];
76
+ return typeof t != "object" ? null : t == null ? void 0 : t[fi];
77
77
  }
78
- function Un(t) {
78
+ function Dn(t) {
79
79
  var e;
80
80
  const n = j(t);
81
81
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -86,7 +86,7 @@ function ae(t, e) {
86
86
  let n;
87
87
  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");
88
88
  }
89
- function hi(t, e = []) {
89
+ function li(t, e = []) {
90
90
  if (Object.hasOwnProperty.call(t, "key")) {
91
91
  const n = t.parent.copy, r = j(be(n, t.key));
92
92
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
@@ -97,10 +97,10 @@ function hi(t, e = []) {
97
97
  e.push(s);
98
98
  }
99
99
  if (t.parent)
100
- return hi(t.parent, e);
100
+ return li(t.parent, e);
101
101
  e.reverse();
102
102
  try {
103
- Ps(t.copy, e);
103
+ Cs(t.copy, e);
104
104
  } catch {
105
105
  return null;
106
106
  }
@@ -122,7 +122,7 @@ function Ht(t, e) {
122
122
  function ye(t, e) {
123
123
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
124
124
  }
125
- function on(t) {
125
+ function sn(t) {
126
126
  if (t)
127
127
  for (; t.finalities.revoke.length > 0; )
128
128
  t.finalities.revoke.pop()();
@@ -133,7 +133,7 @@ function Ee(t, e) {
133
133
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
134
134
  }).join("/");
135
135
  }
136
- function Ps(t, e) {
136
+ function Cs(t, e) {
137
137
  for (let n = 0; n < e.length - 1; n += 1) {
138
138
  const r = e[n];
139
139
  if (t = be(Ce(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
@@ -141,7 +141,7 @@ function Ps(t, e) {
141
141
  }
142
142
  return t;
143
143
  }
144
- function Is(t) {
144
+ function Ps(t) {
145
145
  const e = Object.create(Object.getPrototypeOf(t));
146
146
  return Reflect.ownKeys(t).forEach((n) => {
147
147
  let r = Reflect.getOwnPropertyDescriptor(t, n);
@@ -157,26 +157,26 @@ function Is(t) {
157
157
  }), Reflect.defineProperty(e, n, r);
158
158
  }), e;
159
159
  }
160
- const Ms = Object.prototype.propertyIsEnumerable;
161
- function pi(t, e) {
160
+ const Is = Object.prototype.propertyIsEnumerable;
161
+ function hi(t, e) {
162
162
  let n;
163
163
  if (Array.isArray(t))
164
164
  return Array.prototype.concat.call(t);
165
165
  if (t instanceof Set) {
166
- if (!$n(t)) {
166
+ if (!xn(t)) {
167
167
  const r = Object.getPrototypeOf(t).constructor;
168
168
  return new r(t.values());
169
169
  }
170
170
  return Set.prototype.difference ? Set.prototype.difference.call(t, /* @__PURE__ */ new Set()) : new Set(t.values());
171
171
  } else if (t instanceof Map) {
172
- if (!Dn(t)) {
172
+ if (!$n(t)) {
173
173
  const r = Object.getPrototypeOf(t).constructor;
174
174
  return new r(t);
175
175
  }
176
176
  return new Map(t);
177
177
  } else if (e != null && e.mark && (n = e.mark(t, ne), n !== void 0) && n !== ne.mutable) {
178
178
  if (n === ne.immutable)
179
- return Is(t);
179
+ return Ps(t);
180
180
  if (typeof n == "function") {
181
181
  if (e.enablePatches || e.enableAutoFreeze)
182
182
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -188,17 +188,17 @@ function pi(t, e) {
188
188
  return Object.keys(t).forEach((i) => {
189
189
  r[i] = t[i];
190
190
  }), Object.getOwnPropertySymbols(t).forEach((i) => {
191
- Ms.call(t, i) && (r[i] = t[i]);
191
+ Is.call(t, i) && (r[i] = t[i]);
192
192
  }), r;
193
193
  } else
194
194
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
195
195
  }
196
196
  function Q(t) {
197
- t.copy || (t.copy = pi(t.original, t.options));
197
+ t.copy || (t.copy = hi(t.original, t.options));
198
198
  }
199
199
  function Je(t) {
200
200
  if (!ae(t))
201
- return Un(t);
201
+ return Dn(t);
202
202
  if (Array.isArray(t))
203
203
  return t.map(Je);
204
204
  if (t instanceof Map) {
@@ -206,7 +206,7 @@ function Je(t) {
206
206
  r,
207
207
  Je(i)
208
208
  ]);
209
- if (!Dn(t)) {
209
+ if (!$n(t)) {
210
210
  const r = Object.getPrototypeOf(t).constructor;
211
211
  return new r(n);
212
212
  }
@@ -214,7 +214,7 @@ function Je(t) {
214
214
  }
215
215
  if (t instanceof Set) {
216
216
  const n = Array.from(t).map(Je);
217
- if (!$n(t)) {
217
+ if (!xn(t)) {
218
218
  const r = Object.getPrototypeOf(t).constructor;
219
219
  return new r(n);
220
220
  }
@@ -232,7 +232,7 @@ function fe(t) {
232
232
  var e;
233
233
  t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && fe(t.parent));
234
234
  }
235
- function mr() {
235
+ function wr() {
236
236
  throw new Error("Cannot modify frozen object");
237
237
  }
238
238
  function Me(t, e, n, r, i) {
@@ -260,12 +260,12 @@ function Me(t, e, n, r, i) {
260
260
  case 2:
261
261
  for (const [a, u] of t)
262
262
  Me(a, a, n, r, i), Me(u, a, n, r, i);
263
- t.set = t.clear = t.delete = mr;
263
+ t.set = t.clear = t.delete = wr;
264
264
  break;
265
265
  case 3:
266
266
  for (const a of t)
267
267
  Me(a, a, n, r, i);
268
- t.add = t.clear = t.delete = mr;
268
+ t.add = t.clear = t.delete = wr;
269
269
  break;
270
270
  case 1:
271
271
  Object.freeze(t);
@@ -281,7 +281,7 @@ function Me(t, e, n, r, i) {
281
281
  }
282
282
  r.pop(), i.pop();
283
283
  }
284
- function Ln(t, e) {
284
+ function Un(t, e) {
285
285
  const n = Ce(t);
286
286
  if (n === 0)
287
287
  Reflect.ownKeys(t).forEach((r) => {
@@ -294,11 +294,11 @@ function Ln(t, e) {
294
294
  } else
295
295
  t.forEach((r, i) => e(i, r, t));
296
296
  }
297
- function yi(t, e, n) {
297
+ function pi(t, e, n) {
298
298
  if (je(t) || !ae(t, n) || e.has(t) || Object.isFrozen(t))
299
299
  return;
300
300
  const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
301
- if (e.add(t), Ln(t, (s, o) => {
301
+ if (e.add(t), Un(t, (s, o) => {
302
302
  var a;
303
303
  if (je(o)) {
304
304
  const u = j(o);
@@ -306,7 +306,7 @@ function yi(t, e, n) {
306
306
  const d = !((a = u.assignedMap) === null || a === void 0) && a.size || u.operated ? u.copy : u.original;
307
307
  ct(r ? i : t, s, d);
308
308
  } else
309
- yi(o, e, n);
309
+ pi(o, e, n);
310
310
  }), i) {
311
311
  const s = t, o = Array.from(s);
312
312
  s.clear(), o.forEach((a) => {
@@ -314,39 +314,39 @@ function yi(t, e, n) {
314
314
  });
315
315
  }
316
316
  }
317
- function Rs(t, e) {
317
+ function Ms(t, e) {
318
318
  const n = t.type === 3 ? t.setMap : t.copy;
319
- t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && yi(be(n, e), t.finalities.handledSet, t.options);
319
+ t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && pi(be(n, e), t.finalities.handledSet, t.options);
320
320
  }
321
- function an(t) {
321
+ function on(t) {
322
322
  t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
323
- t.copy.add(Un(e));
323
+ t.copy.add(Dn(e));
324
324
  }));
325
325
  }
326
- function un(t, e, n, r) {
326
+ function an(t, e, n, r) {
327
327
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
328
328
  if (n && r) {
329
- const s = hi(t);
329
+ const s = li(t);
330
330
  s && e(t, s, n, r);
331
331
  }
332
332
  t.finalized = !0;
333
333
  }
334
334
  }
335
- function Fn(t, e, n, r) {
335
+ function Ln(t, e, n, r) {
336
336
  const i = j(n);
337
337
  i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
338
338
  var a;
339
339
  const u = t.type === 3 ? t.setMap : t.copy;
340
340
  if (ye(be(u, e), n)) {
341
341
  let d = i.original;
342
- i.copy && (d = i.copy), an(t), un(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), ct(u, e, d);
342
+ i.copy && (d = i.copy), on(t), an(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), ct(u, e, d);
343
343
  }
344
344
  }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ae(n, t.options) && t.finalities.draft.push(() => {
345
345
  const s = t.type === 3 ? t.setMap : t.copy;
346
- ye(be(s, e), n) && Rs(t, e);
346
+ ye(be(s, e), n) && Ms(t, e);
347
347
  });
348
348
  }
349
- function xs(t, e, n, r, i) {
349
+ function Rs(t, e, n, r, i) {
350
350
  let { original: s, assignedMap: o, options: a } = t, u = t.copy;
351
351
  u.length < s.length && ([s, u] = [u, s], [n, r] = [r, n]);
352
352
  for (let d = 0; d < s.length; d += 1)
@@ -392,7 +392,7 @@ function xs(t, e, n, r, i) {
392
392
  }
393
393
  }
394
394
  }
395
- function $s({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
395
+ function xs({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
396
396
  n.forEach((a, u) => {
397
397
  const d = be(t, u), c = St(be(e, u)), f = a ? nt(t, u) ? U.Replace : U.Add : U.Remove;
398
398
  if (ye(d, c) && f === U.Replace)
@@ -401,7 +401,7 @@ function $s({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
401
401
  i.push(f === U.Remove ? { op: f, path: p } : { op: f, path: p, value: c }), s.push(f === U.Add ? { op: U.Remove, path: p } : f === U.Remove ? { op: U.Add, path: p, value: d } : { op: U.Replace, path: p, value: d });
402
402
  });
403
403
  }
404
- function Ds({ original: t, copy: e }, n, r, i, s) {
404
+ function $s({ original: t, copy: e }, n, r, i, s) {
405
405
  let o = 0;
406
406
  t.forEach((a) => {
407
407
  if (!e.has(a)) {
@@ -438,17 +438,17 @@ function ut(t, e, n, r) {
438
438
  switch (t.type) {
439
439
  case 0:
440
440
  case 2:
441
- return $s(t, e, n, r, i);
442
- case 1:
443
441
  return xs(t, e, n, r, i);
442
+ case 1:
443
+ return Rs(t, e, n, r, i);
444
444
  case 3:
445
- return Ds(t, e, n, r, i);
445
+ return $s(t, e, n, r, i);
446
446
  }
447
447
  }
448
448
  const jt = (t, e, n = !1) => {
449
449
  if (typeof t == "object" && t !== null && (!ae(t, e) || n))
450
450
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
451
- }, cn = {
451
+ }, un = {
452
452
  get size() {
453
453
  return te(j(this)).size;
454
454
  },
@@ -457,7 +457,7 @@ const jt = (t, e, n = !1) => {
457
457
  },
458
458
  set(t, e) {
459
459
  const n = j(this), r = te(n);
460
- return (!r.has(t) || !ye(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), Fn(n, t, e, ut)), this;
460
+ return (!r.has(t) || !ye(r.get(t), e)) && (Q(n), fe(n), n.assignedMap.set(t, !0), n.copy.set(t, e), Ln(n, t, e, ut)), this;
461
461
  },
462
462
  delete(t) {
463
463
  if (!this.has(t))
@@ -485,7 +485,7 @@ const jt = (t, e, n = !1) => {
485
485
  const r = j(this), i = te(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, ne)) === ne.mutable;
486
486
  if (r.options.strict && jt(i, r.options, s), s || r.finalized || !ae(i, r.options) || i !== r.original.get(t))
487
487
  return i;
488
- const o = xn.createDraft({
488
+ const o = Rn.createDraft({
489
489
  original: i,
490
490
  parentDraft: r,
491
491
  key: t,
@@ -529,7 +529,7 @@ const jt = (t, e, n = !1) => {
529
529
  [vt]() {
530
530
  return this.entries();
531
531
  }
532
- }, Us = Reflect.ownKeys(cn), vr = (t, e, { isValuesIterator: n }) => () => {
532
+ }, Ds = Reflect.ownKeys(un), mr = (t, e, { isValuesIterator: n }) => () => {
533
533
  var r, i;
534
534
  const s = e.next();
535
535
  if (s.done)
@@ -538,7 +538,7 @@ const jt = (t, e, n = !1) => {
538
538
  let a = t.setMap.get(o);
539
539
  const u = j(a), d = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, a, ne)) === ne.mutable;
540
540
  if (t.options.strict && jt(o, t.options, d), !d && !u && ae(o, t.options) && !t.finalized && t.original.has(o)) {
541
- const c = xn.createDraft({
541
+ const c = Rn.createDraft({
542
542
  original: o,
543
543
  parentDraft: t,
544
544
  key: o,
@@ -565,7 +565,7 @@ const jt = (t, e, n = !1) => {
565
565
  },
566
566
  add(t) {
567
567
  const e = j(this);
568
- return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), Fn(e, t, t, ut)), this;
568
+ return this.has(t) || (Q(e), fe(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), Ln(e, t, t, ut)), this;
569
569
  },
570
570
  delete(t) {
571
571
  if (!this.has(t))
@@ -590,7 +590,7 @@ const jt = (t, e, n = !1) => {
590
590
  const e = t.setMap.keys();
591
591
  return {
592
592
  [Symbol.iterator]: () => this.values(),
593
- next: vr(t, e, { isValuesIterator: !0 })
593
+ next: mr(t, e, { isValuesIterator: !0 })
594
594
  };
595
595
  },
596
596
  entries() {
@@ -599,7 +599,7 @@ const jt = (t, e, n = !1) => {
599
599
  const e = t.setMap.keys();
600
600
  return {
601
601
  [Symbol.iterator]: () => this.entries(),
602
- next: vr(t, e, {
602
+ next: mr(t, e, {
603
603
  isValuesIterator: !1
604
604
  })
605
605
  };
@@ -640,13 +640,13 @@ Set.prototype.difference && Object.assign(Ct, {
640
640
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
641
641
  }
642
642
  });
643
- const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
643
+ const Us = Reflect.ownKeys(Ct), yi = /* @__PURE__ */ new WeakSet(), bi = {
644
644
  get(t, e, n) {
645
645
  var r, i;
646
646
  const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
647
- if (s && bi.has(s))
647
+ if (s && yi.has(s))
648
648
  return s;
649
- if (e === li)
649
+ if (e === fi)
650
650
  return t;
651
651
  let o;
652
652
  if (t.options.mark) {
@@ -655,14 +655,14 @@ const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
655
655
  return t.options.strict && jt(d, t.options, !0), d;
656
656
  }
657
657
  const a = te(t);
658
- if (a instanceof Map && Us.includes(e)) {
658
+ if (a instanceof Map && Ds.includes(e)) {
659
659
  if (e === "size")
660
- return Object.getOwnPropertyDescriptor(cn, "size").get.call(t.proxy);
661
- const d = cn[e];
660
+ return Object.getOwnPropertyDescriptor(un, "size").get.call(t.proxy);
661
+ const d = un[e];
662
662
  if (d)
663
663
  return d.bind(t.proxy);
664
664
  }
665
- if (a instanceof Set && Ls.includes(e)) {
665
+ if (a instanceof Set && Us.includes(e)) {
666
666
  if (e === "size")
667
667
  return Object.getOwnPropertyDescriptor(Ct, "size").get.call(t.proxy);
668
668
  const d = Ct[e];
@@ -670,7 +670,7 @@ const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
670
670
  return d.bind(t.proxy);
671
671
  }
672
672
  if (!nt(a, e)) {
673
- const d = wr(a, e);
673
+ const d = Tr(a, e);
674
674
  return d ? "value" in d ? d.value : (
675
675
  // !case: support for getter
676
676
  (i = d.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
@@ -680,7 +680,7 @@ const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
680
680
  if (t.options.strict && jt(u, t.options), t.finalized || !ae(u, t.options))
681
681
  return u;
682
682
  if (u === Ht(t.original, e)) {
683
- if (Q(t), t.copy[e] = Nn({
683
+ if (Q(t), t.copy[e] = Fn({
684
684
  original: t.original[e],
685
685
  parentDraft: t,
686
686
  key: t.type === 1 ? Number(e) : e,
@@ -701,11 +701,11 @@ const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
701
701
  let i;
702
702
  if (t.type === 1 && e !== "length" && !(Number.isInteger(i = Number(e)) && i >= 0 && (e === 0 || i === 0 || String(i) === String(e))))
703
703
  throw new Error("Only supports setting array indices and the 'length' property.");
704
- const s = wr(te(t), e);
704
+ const s = Tr(te(t), e);
705
705
  if (s != null && s.set)
706
706
  return s.set.call(t.proxy, n), !0;
707
707
  const o = Ht(te(t), e), a = j(o);
708
- return a && ye(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) : (ye(n, o) && (n !== void 0 || nt(t.original, e)) || (Q(t), fe(t), nt(t.original, e) && ye(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Fn(t, e, n, ut)), !0);
708
+ return a && ye(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) : (ye(n, o) && (n !== void 0 || nt(t.original, e)) || (Q(t), fe(t), nt(t.original, e) && ye(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, Ln(t, e, n, ut)), !0);
709
709
  },
710
710
  has(t, e) {
711
711
  return e in te(t);
@@ -733,10 +733,10 @@ const Ls = Reflect.ownKeys(Ct), bi = /* @__PURE__ */ new WeakSet(), _i = {
733
733
  },
734
734
  deleteProperty(t, e) {
735
735
  var n;
736
- return t.type === 1 ? _i.set.call(this, t, e, void 0, t.proxy) : (Ht(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);
736
+ return t.type === 1 ? bi.set.call(this, t, e, void 0, t.proxy) : (Ht(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);
737
737
  }
738
738
  };
739
- function Nn(t) {
739
+ function Fn(t) {
740
740
  const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = Ce(e), a = {
741
741
  type: o,
742
742
  finalized: !1,
@@ -750,8 +750,8 @@ function Nn(t) {
750
750
  setMap: o === 3 ? new Map(e.entries()) : void 0
751
751
  };
752
752
  (r || "key" in t) && (a.key = r);
753
- const { proxy: u, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, _i);
754
- if (i.revoke.push(d), bi.add(u), a.proxy = u, n) {
753
+ const { proxy: u, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, bi);
754
+ if (i.revoke.push(d), yi.add(u), a.proxy = u, n) {
755
755
  const c = n;
756
756
  c.finalities.draft.push((f, l) => {
757
757
  var p, y;
@@ -760,7 +760,7 @@ function Nn(t) {
760
760
  const w = be(_, r), g = j(w);
761
761
  if (g) {
762
762
  let m = g.original;
763
- g.operated && (m = Un(w)), an(g), un(g, ut, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(m, g.original)), ct(_, r, m);
763
+ g.operated && (m = Dn(w)), on(g), an(g, ut, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(m, g.original)), ct(_, r, m);
764
764
  }
765
765
  (y = b.callbacks) === null || y === void 0 || y.forEach((m) => {
766
766
  m(f, l);
@@ -769,26 +769,26 @@ function Nn(t) {
769
769
  } else {
770
770
  const c = j(u);
771
771
  c.finalities.draft.push((f, l) => {
772
- an(c), un(c, ut, f, l);
772
+ on(c), an(c, ut, f, l);
773
773
  });
774
774
  }
775
775
  return u;
776
776
  }
777
- xn.createDraft = Nn;
778
- function Fs(t, e, n, r, i) {
777
+ Rn.createDraft = Fn;
778
+ function Ls(t, e, n, r, i) {
779
779
  var s;
780
780
  const o = j(t), a = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, u = !!e.length;
781
781
  if (o != null && o.operated)
782
782
  for (; o.finalities.draft.length > 0; )
783
783
  o.finalities.draft.pop()(n, r);
784
784
  const d = u ? e[0] : o ? o.operated ? o.copy : o.original : t;
785
- return o && on(o), i && Me(d, d, o == null ? void 0 : o.options.updatedValues), [
785
+ return o && sn(o), i && Me(d, d, o == null ? void 0 : o.options.updatedValues), [
786
786
  d,
787
787
  n && u ? [{ op: U.Replace, path: [], value: e[0] }] : n,
788
788
  r && u ? [{ op: U.Replace, path: [], value: a }] : r
789
789
  ];
790
790
  }
791
- function Ns(t, e) {
791
+ function Fs(t, e) {
792
792
  var n;
793
793
  const r = {
794
794
  draft: [],
@@ -797,7 +797,7 @@ function Ns(t, e) {
797
797
  };
798
798
  let i, s;
799
799
  e.enablePatches && (i = [], s = []);
800
- const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ae(t, e) ? t : Nn({
800
+ const a = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, ne)) === ne.mutable || !ae(t, e) ? t : Fn({
801
801
  original: t,
802
802
  parentDraft: null,
803
803
  finalities: r,
@@ -806,14 +806,14 @@ function Ns(t, e) {
806
806
  return [
807
807
  a,
808
808
  (u = []) => {
809
- const [d, c, f] = Fs(a, u, i, s, e.enableAutoFreeze);
809
+ const [d, c, f] = Ls(a, u, i, s, e.enableAutoFreeze);
810
810
  return e.enablePatches ? [d, c, f] : d;
811
811
  }
812
812
  ];
813
813
  }
814
- function dn(t) {
814
+ function cn(t) {
815
815
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
816
- Ln(n, (s, o, a) => {
816
+ Un(n, (s, o, a) => {
817
817
  const u = j(o);
818
818
  if (u && e && u.finalities === e.finalities) {
819
819
  t.isContainDraft = !0;
@@ -823,10 +823,10 @@ function dn(t) {
823
823
  a.clear(), c.forEach((f) => a.add(s === f ? d : f));
824
824
  } else
825
825
  ct(a, s, d);
826
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, dn(t));
826
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, cn(t));
827
827
  }), i && (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."));
828
828
  }
829
- function gi(t) {
829
+ function _i(t) {
830
830
  var e;
831
831
  const n = j(t);
832
832
  if (!ae(t, n == null ? void 0 : n.options))
@@ -836,7 +836,7 @@ function gi(t) {
836
836
  return n.original;
837
837
  let i;
838
838
  function s() {
839
- i = r === 2 ? Dn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : pi(t, n == null ? void 0 : n.options);
839
+ i = r === 2 ? $n(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : hi(t, n == null ? void 0 : n.options);
840
840
  }
841
841
  if (n) {
842
842
  n.finalized = !0;
@@ -847,23 +847,23 @@ function gi(t) {
847
847
  }
848
848
  } else
849
849
  i = t;
850
- if (Ln(i, (o, a) => {
850
+ if (Un(i, (o, a) => {
851
851
  if (n && ye(be(n.original, o), a))
852
852
  return;
853
- const u = gi(a);
853
+ const u = _i(a);
854
854
  u !== a && (i === t && s(), ct(i, o, u));
855
855
  }), r === 3) {
856
856
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
857
- return $n(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
857
+ return xn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
858
858
  }
859
859
  return i;
860
860
  }
861
- function Sr(t) {
861
+ function vr(t) {
862
862
  if (!je(t))
863
863
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
864
- return gi(t);
864
+ return _i(t);
865
865
  }
866
- const Ks = (t) => function e(n, r, i) {
866
+ const Ns = (t) => function e(n, r, i) {
867
867
  var s, o, a;
868
868
  if (typeof n == "function" && typeof r != "function")
869
869
  return function(S, ...I) {
@@ -874,7 +874,7 @@ const Ks = (t) => function e(n, r, i) {
874
874
  if (typeof r != "function" && (c = r), c !== void 0 && Object.prototype.toString.call(c) !== "[object Object]")
875
875
  throw new Error(`Invalid options: ${c}, 'options' should be an object.`);
876
876
  c = Object.assign(Object.assign({}, t), c);
877
- const f = je(u) ? Sr(u) : u, l = Array.isArray(c.mark) ? (S, I) => {
877
+ const f = je(u) ? vr(u) : u, l = Array.isArray(c.mark) ? (S, I) => {
878
878
  for (const x of c.mark) {
879
879
  if (typeof x != "function")
880
880
  throw new Error(`Invalid mark: ${x}, 'mark' should be a function.`);
@@ -890,7 +890,7 @@ const Ks = (t) => function e(n, r, i) {
890
890
  };
891
891
  if (!ae(f, _) && typeof f == "object" && f !== null)
892
892
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
893
- const [w, g] = Ns(f, _);
893
+ const [w, g] = Fs(f, _);
894
894
  if (typeof r != "function") {
895
895
  if (!ae(f, _))
896
896
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -900,24 +900,24 @@ const Ks = (t) => function e(n, r, i) {
900
900
  try {
901
901
  m = d(w);
902
902
  } catch (S) {
903
- throw on(j(w)), S;
903
+ throw sn(j(w)), S;
904
904
  }
905
905
  const E = (S) => {
906
906
  const I = j(w);
907
907
  if (!je(S)) {
908
908
  if (S !== void 0 && !ye(S, w) && (I != null && I.operated))
909
909
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
910
- const B = S == null ? void 0 : S[Cs];
910
+ const B = S == null ? void 0 : S[js];
911
911
  if (B) {
912
912
  const Ve = B[0];
913
- return _.strict && typeof S == "object" && S !== null && dn({
913
+ return _.strict && typeof S == "object" && S !== null && cn({
914
914
  rootDraft: I,
915
915
  value: S,
916
916
  useRawReturn: !0
917
917
  }), g([Ve]);
918
918
  }
919
919
  if (S !== void 0)
920
- return typeof S == "object" && S !== null && dn({ rootDraft: I, value: S }), g([S]);
920
+ return typeof S == "object" && S !== null && cn({ rootDraft: I, value: S }), g([S]);
921
921
  }
922
922
  if (S === w || S === void 0)
923
923
  return g([]);
@@ -925,26 +925,26 @@ const Ks = (t) => function e(n, r, i) {
925
925
  if (_ === x.options) {
926
926
  if (x.operated)
927
927
  throw new Error("Cannot return a modified child draft.");
928
- return g([Sr(S)]);
928
+ return g([vr(S)]);
929
929
  }
930
930
  return g([S]);
931
931
  };
932
932
  return m instanceof Promise ? m.then(E, (S) => {
933
- throw on(j(w)), S;
933
+ throw sn(j(w)), S;
934
934
  }) : E(m);
935
- }, Pt = Ks();
935
+ }, Pt = Ns();
936
936
  Object.prototype.constructor.toString();
937
- function Ti(t, e) {
937
+ function gi(t, e) {
938
938
  const n = Object.keys(t), r = Object.keys(e);
939
939
  return n.length === r.length && Object.keys(t).every((i) => e.hasOwnProperty(i));
940
940
  }
941
- function Or(t, e) {
941
+ function Sr(t, e) {
942
942
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
943
943
  }
944
944
  function Ot(t, e) {
945
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : Ti(t, e) ? Object.keys(t).every((n) => Ot(t[n], e[n])) : !1;
945
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : gi(t, e) ? Object.keys(t).every((n) => Ot(t[n], e[n])) : !1;
946
946
  }
947
- function Kn(t) {
947
+ function Nn(t) {
948
948
  if (!Ze(t))
949
949
  return t;
950
950
  const e = {};
@@ -952,7 +952,7 @@ function Kn(t) {
952
952
  r !== void 0 && (e[n] = r);
953
953
  return e;
954
954
  }
955
- function wi(t, e) {
955
+ function Ti(t, e) {
956
956
  if (!Ze(t) || !Ze(e))
957
957
  return e;
958
958
  const n = Object.assign({}, t);
@@ -964,14 +964,14 @@ function wi(t, e) {
964
964
  continue;
965
965
  }
966
966
  const i = Ze(t[r]) && Ze(e[r]);
967
- n[r] = i ? wi(t[r], e[r]) : e[r];
967
+ n[r] = i ? Ti(t[r], e[r]) : e[r];
968
968
  }
969
969
  return n;
970
970
  }
971
971
  function Ze(t) {
972
972
  return typeof t == "object" && t !== null && !Array.isArray(t);
973
973
  }
974
- function qs(t, e, n) {
974
+ function Ks(t, e, n) {
975
975
  if (!t || e.length === 0)
976
976
  return;
977
977
  let r = t || {};
@@ -982,7 +982,7 @@ function qs(t, e, n) {
982
982
  const i = e[e.length - 1];
983
983
  Array.isArray(r) && typeof i == "number" ? r.splice(i, 0, n) : r[i] = n;
984
984
  }
985
- function Er(t, e, n) {
985
+ function Or(t, e, n) {
986
986
  if (!t || e.length === 0)
987
987
  return;
988
988
  let r = t || {};
@@ -992,7 +992,7 @@ function Er(t, e, n) {
992
992
  }
993
993
  r[e[e.length - 1]] = n;
994
994
  }
995
- function mi(t, e) {
995
+ function wi(t, e) {
996
996
  if (!t || e.length === 0)
997
997
  return;
998
998
  const [n, ...r] = e;
@@ -1001,13 +1001,13 @@ function mi(t, e) {
1001
1001
  Array.isArray(t) ? t.splice(n, 1) : delete t[n];
1002
1002
  return;
1003
1003
  }
1004
- mi(t[n], r), Ws(t[n]) && delete t[n];
1004
+ wi(t[n], r), qs(t[n]) && delete t[n];
1005
1005
  }
1006
1006
  }
1007
- function Ws(t) {
1007
+ function qs(t) {
1008
1008
  return t && Object.keys(t).length === 0;
1009
1009
  }
1010
- const Ar = /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$/, zs = {
1010
+ const Er = /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$/, Ws = {
1011
1011
  ZULU: 0,
1012
1012
  YEKT: 18e3,
1013
1013
  YEKST: 21600,
@@ -1203,39 +1203,39 @@ const Ar = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1203
1203
  ACSST: 37800,
1204
1204
  ACDT: 37800
1205
1205
  };
1206
- function Vs(t) {
1206
+ function zs(t) {
1207
1207
  return new Date(t);
1208
1208
  }
1209
- function Bs(t) {
1209
+ function Vs(t) {
1210
1210
  return /* @__PURE__ */ new Date(t + "Z");
1211
1211
  }
1212
- const Gs = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1213
- function Qs(t) {
1214
- const e = t.match(Gs);
1212
+ const Bs = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1213
+ function Gs(t) {
1214
+ const e = t.match(Bs);
1215
1215
  if (!e)
1216
1216
  return null;
1217
1217
  const [n, r, i, s] = e;
1218
1218
  return r <= 0 || i <= 0 || s <= 0 ? null : r > 999 ? new Date(Date.UTC(r, i - 1, s, 0, 0, 0, 0)) : new Date(Date.UTC(s, r - 1, i, 0, 0, 0, 0));
1219
1219
  }
1220
- function Hs(t) {
1220
+ function Qs(t) {
1221
1221
  const [e, n] = t.split(" ");
1222
1222
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1223
1223
  }
1224
- function Ys(t) {
1224
+ function Hs(t) {
1225
1225
  const [e, n] = t.split(" ");
1226
1226
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1227
1227
  }
1228
- function Js(t) {
1228
+ function Ys(t) {
1229
1229
  return new Date(t);
1230
1230
  }
1231
- function Zs(t) {
1231
+ function Js(t) {
1232
1232
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1233
1233
  if (!t.match(e))
1234
1234
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1235
1235
  const r = /* @__PURE__ */ new Date(t + " UTC");
1236
1236
  return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
1237
1237
  }
1238
- function Xs(t) {
1238
+ function Zs(t) {
1239
1239
  const e = /^(.+T.+)([+-])(\d{2})$/, n = t.match(e);
1240
1240
  if (n) {
1241
1241
  const [, r, i, s] = n, o = `${r}${i}${s}:00`;
@@ -1243,14 +1243,14 @@ function Xs(t) {
1243
1243
  }
1244
1244
  return null;
1245
1245
  }
1246
- function eo(t) {
1246
+ function Xs(t) {
1247
1247
  const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1248
1248
  if (!o)
1249
1249
  throw new Error(`Unable to parse time from: ${t}`);
1250
1250
  let [, a, u, d, c] = o;
1251
1251
  return a = Number(a), u = Number(u), d = Number(d), c === "PM" && a !== 12 ? a += 12 : c === "AM" && a === 12 && (a = 0), new Date(Date.UTC(s, r - 1, i, a, u, d));
1252
1252
  }
1253
- function to(t) {
1253
+ function eo(t) {
1254
1254
  switch (t) {
1255
1255
  case "epoch":
1256
1256
  return /* @__PURE__ */ new Date(0);
@@ -1262,27 +1262,27 @@ function to(t) {
1262
1262
  return null;
1263
1263
  }
1264
1264
  }
1265
- function no(t) {
1266
- const e = t.match(Ar);
1265
+ function to(t) {
1266
+ const e = t.match(Er);
1267
1267
  if (!e)
1268
1268
  return null;
1269
- const [n] = e, r = zs[n], i = new Date(t.replace(Ar, "Z"));
1269
+ const [n] = e, r = Ws[n], i = new Date(t.replace(Er, "Z"));
1270
1270
  return new Date(i.getTime() - r * 1e3);
1271
1271
  }
1272
- const ro = [
1273
- Qs,
1274
- Ys,
1275
- Zs,
1276
- eo,
1272
+ const no = [
1273
+ Gs,
1274
+ Hs,
1277
1275
  Js,
1278
- Bs,
1279
1276
  Xs,
1280
- Hs,
1277
+ Ys,
1281
1278
  Vs,
1282
- to,
1283
- no
1279
+ Zs,
1280
+ Qs,
1281
+ zs,
1282
+ eo,
1283
+ to
1284
1284
  ];
1285
- function io(t, e) {
1285
+ function ro(t, e) {
1286
1286
  try {
1287
1287
  const n = t(e);
1288
1288
  return n instanceof Date && !isNaN(n.getTime()) ? n : null;
@@ -1290,18 +1290,18 @@ function io(t, e) {
1290
1290
  return null;
1291
1291
  }
1292
1292
  }
1293
- function fn(t) {
1294
- for (const e of ro) {
1295
- const n = io(e, t);
1293
+ function dn(t) {
1294
+ for (const e of no) {
1295
+ const n = ro(e, t);
1296
1296
  if (n)
1297
1297
  return n;
1298
1298
  }
1299
1299
  return null;
1300
1300
  }
1301
- function so(t) {
1301
+ function io(t) {
1302
1302
  try {
1303
1303
  const e = JSON.parse(t);
1304
- return typeof e == "string" ? fn(e) : null;
1304
+ return typeof e == "string" ? dn(e) : null;
1305
1305
  } catch {
1306
1306
  return null;
1307
1307
  }
@@ -1313,7 +1313,7 @@ function xt(t) {
1313
1313
  if (t instanceof Date)
1314
1314
  return t;
1315
1315
  if (typeof t == "string") {
1316
- const e = fn(t) || so(t) || fn(t.trim());
1316
+ const e = dn(t) || io(t) || dn(t.trim());
1317
1317
  if (!e)
1318
1318
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1319
1319
  return e;
@@ -1322,13 +1322,13 @@ function xt(t) {
1322
1322
  throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
1323
1323
  }
1324
1324
  }
1325
- function oo(t) {
1325
+ function so(t) {
1326
1326
  return t.cardinality === "one";
1327
1327
  }
1328
- function qn(t) {
1328
+ function Kn(t) {
1329
1329
  return t["value-type"] === "ref";
1330
1330
  }
1331
- function Wn(t) {
1331
+ function qn(t) {
1332
1332
  return t["value-type"] === "blob";
1333
1333
  }
1334
1334
  function qe(t, e) {
@@ -1358,7 +1358,7 @@ function Z(t, e, n) {
1358
1358
  let s = t.get(r);
1359
1359
  s || (s = /* @__PURE__ */ new Map(), t.set(r, s)), Z(s, i, n);
1360
1360
  }
1361
- function vi(t, e, n) {
1361
+ function mi(t, e, n) {
1362
1362
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1363
1363
  for (const o of e) {
1364
1364
  let [a, u, d, c] = o;
@@ -1367,22 +1367,22 @@ function vi(t, e, n) {
1367
1367
  console.warn("no such attr", a, t);
1368
1368
  continue;
1369
1369
  }
1370
- f["checked-data-type"] === "date" && n && (d = xt(d), o[2] = d), qn(f) && Z(s, [d, u, a], o), Z(r, [a, u, d], o), Z(i, [u, a, d], o);
1370
+ f["checked-data-type"] === "date" && n && (d = xt(d), o[2] = d), Kn(f) && Z(s, [d, u, a], o), Z(r, [a, u, d], o), Z(i, [u, a, d], o);
1371
1371
  }
1372
1372
  return { eav: r, aev: i, vae: s };
1373
1373
  }
1374
- function Si(t) {
1374
+ function vi(t) {
1375
1375
  const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1376
1376
  for (const s of Object.values(t)) {
1377
1377
  const o = s["forward-identity"], [a, u, d] = o, c = s["reverse-identity"];
1378
- if (Z(r, [u, d], s), Wn(s) && Z(e, [u, d], s), s["primary?"] && Z(n, [u], s), c) {
1378
+ if (Z(r, [u, d], s), qn(s) && Z(e, [u, d], s), s["primary?"] && Z(n, [u], s), c) {
1379
1379
  const [f, l, p] = c;
1380
1380
  Z(i, [l, p], s);
1381
1381
  }
1382
1382
  }
1383
1383
  return { blobAttrs: e, primaryKeys: n, forwardIdents: r, revIdents: i };
1384
1384
  }
1385
- function Oi(t) {
1385
+ function Si(t) {
1386
1386
  return {
1387
1387
  __type: t.__type,
1388
1388
  attrs: t.attrs,
@@ -1392,18 +1392,18 @@ function Oi(t) {
1392
1392
  useDateObjects: t.useDateObjects
1393
1393
  };
1394
1394
  }
1395
- function Ei(t) {
1395
+ function Oi(t) {
1396
1396
  return Et(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
1397
1397
  }
1398
- function ao(t, e) {
1398
+ function oo(t, e) {
1399
1399
  return We(t.eav, [e]) !== void 0;
1400
1400
  }
1401
- function zn(t) {
1402
- t.attrIndexes = Si(t.attrs);
1401
+ function Wn(t) {
1402
+ t.attrIndexes = vi(t.attrs);
1403
1403
  }
1404
1404
  function Et(t, e, n, r, i) {
1405
- const s = vi(t, e, i);
1406
- return s.useDateObjects = i, s.attrs = t, s.attrIndexes = Si(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
1405
+ const s = mi(t, e, i);
1406
+ return s.useDateObjects = i, s.attrs = t, s.attrIndexes = vi(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
1407
1407
  }
1408
1408
  function dt(t, e) {
1409
1409
  var n, r;
@@ -1432,21 +1432,21 @@ function dt(t, e) {
1432
1432
  return [i, ...a];
1433
1433
  }
1434
1434
  }
1435
- function Ai(t, e) {
1435
+ function Ei(t, e) {
1436
1436
  const n = dt(t, e);
1437
1437
  if (!n)
1438
1438
  return;
1439
1439
  const [r, i, s] = n, o = qe(t.attrs, i);
1440
- o && (oe(t.eav, [r, i, s]), oe(t.aev, [i, r, s]), qn(o) && oe(t.vae, [s, i, r]));
1440
+ o && (oe(t.eav, [r, i, s]), oe(t.aev, [i, r, s]), Kn(o) && oe(t.vae, [s, i, r]));
1441
1441
  }
1442
- let uo = 0;
1443
- function ki(t, e, n) {
1442
+ let ao = 0;
1443
+ function Ai(t, e, n) {
1444
1444
  const [r, i, s] = n;
1445
1445
  let o;
1446
1446
  const a = We(t.ea, [r, i, s]);
1447
- return a && (o = a[3]), o || Date.now() * 10 + uo++;
1447
+ return a && (o = a[3]), o || Date.now() * 10 + ao++;
1448
1448
  }
1449
- function ji(t, e) {
1449
+ function ki(t, e) {
1450
1450
  var n;
1451
1451
  const r = dt(t, e);
1452
1452
  if (!r)
@@ -1456,10 +1456,10 @@ function ji(t, e) {
1456
1456
  if (!a)
1457
1457
  return;
1458
1458
  a["checked-data-type"] === "date" && t.useDateObjects && (o = xt(o));
1459
- const u = We(t.eav, [i, s, o]), d = (n = u == null ? void 0 : u[3]) !== null && n !== void 0 ? n : ki(t, a, r), c = [i, s, o, d];
1460
- oo(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), Z(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (Z(t.eav, [i, s, o], c), Z(t.aev, [s, i, o], c)), qn(a) && Z(t.vae, [o, s, i], c);
1459
+ const u = We(t.eav, [i, s, o]), d = (n = u == null ? void 0 : u[3]) !== null && n !== void 0 ? n : Ai(t, a, r), c = [i, s, o, d];
1460
+ so(a) ? (Z(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), Z(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (Z(t.eav, [i, s, o], c), Z(t.aev, [s, i, o], c)), Kn(a) && Z(t.vae, [o, s, i], c);
1461
1461
  }
1462
- function co(t, e) {
1462
+ function uo(t, e) {
1463
1463
  var n;
1464
1464
  const r = dt(t, e);
1465
1465
  if (!r)
@@ -1467,7 +1467,7 @@ function co(t, e) {
1467
1467
  const [i, s, o] = r, a = qe(t.attrs, s);
1468
1468
  if (!a)
1469
1469
  return;
1470
- if (!Wn(a))
1470
+ if (!qn(a))
1471
1471
  throw new Error("merge operation is not supported for links");
1472
1472
  const u = We(t.eav, [i, s]);
1473
1473
  if (!u)
@@ -1475,15 +1475,15 @@ function co(t, e) {
1475
1475
  const d = (n = u.values().next()) === null || n === void 0 ? void 0 : n.value;
1476
1476
  if (!d)
1477
1477
  return;
1478
- const c = d[2], f = wi(c, o), l = [
1478
+ const c = d[2], f = Ti(c, o), l = [
1479
1479
  i,
1480
1480
  s,
1481
1481
  f,
1482
- ki(t, a, d)
1482
+ Ai(t, a, d)
1483
1483
  ];
1484
1484
  Z(t.eav, [i, s], /* @__PURE__ */ new Map([[f, l]]));
1485
1485
  }
1486
- function ln(t, e) {
1486
+ function fn(t, e) {
1487
1487
  var n, r;
1488
1488
  const [i, s] = e, o = dt(t, [i]);
1489
1489
  if (!o)
@@ -1494,7 +1494,7 @@ function ln(t, e) {
1494
1494
  const f = t.attrs[c];
1495
1495
  f && f["on-delete-reverse"] === "cascade" && X(u.get(c), 1).forEach(([l, p, y]) => {
1496
1496
  var b;
1497
- return ln(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
1497
+ return fn(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
1498
1498
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1499
1499
  // the store that didn't set `etype` in deleteEntity
1500
1500
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -1507,54 +1507,54 @@ function ln(t, e) {
1507
1507
  d && d.forEach((c) => {
1508
1508
  var f, l, p;
1509
1509
  const [y, b, _] = c, w = t.attrs[b];
1510
- (!s || !w || ((f = w["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (oe(t.eav, [y, b, _]), oe(t.aev, [b, y, _]), oe(t.vae, [_, b, y])), w && w["on-delete"] === "cascade" && ((l = w["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && ln(t, [y, (p = w["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
1510
+ (!s || !w || ((f = w["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (oe(t.eav, [y, b, _]), oe(t.aev, [b, y, _]), oe(t.vae, [_, b, y])), w && w["on-delete"] === "cascade" && ((l = w["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && fn(t, [y, (p = w["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
1511
1511
  }), ((r = t.vae.get(a)) === null || r === void 0 ? void 0 : r.size) === 0 && oe(t.vae, [a]);
1512
1512
  }
1513
- function Ci(t, e) {
1514
- const n = vi(t.attrs, e, t.useDateObjects);
1513
+ function ji(t, e) {
1514
+ const n = mi(t.attrs, e, t.useDateObjects);
1515
1515
  Object.keys(n).forEach((r) => {
1516
1516
  t[r] = n[r];
1517
1517
  });
1518
1518
  }
1519
- function fo(t, [e]) {
1520
- t.attrs[e.id] = e, zn(t);
1519
+ function co(t, [e]) {
1520
+ t.attrs[e.id] = e, Wn(t);
1521
1521
  }
1522
- function Pi(t) {
1522
+ function Ci(t) {
1523
1523
  return X(t.eav, 3);
1524
1524
  }
1525
- function lo(t, [e]) {
1525
+ function fo(t, [e]) {
1526
1526
  if (!t.attrs[e])
1527
1527
  return;
1528
- const n = Pi(t).filter(([r, i]) => i !== e);
1529
- delete t.attrs[e], zn(t), Ci(t, n);
1528
+ const n = Ci(t).filter(([r, i]) => i !== e);
1529
+ delete t.attrs[e], Wn(t), ji(t, n);
1530
1530
  }
1531
- function ho(t, [e]) {
1531
+ function lo(t, [e]) {
1532
1532
  const n = t.attrs[e.id];
1533
- n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), zn(t), Ci(t, Pi(t)));
1533
+ n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), Wn(t), ji(t, Ci(t)));
1534
1534
  }
1535
- function po(t, e) {
1535
+ function ho(t, e) {
1536
1536
  const [n, ...r] = e;
1537
1537
  switch (n) {
1538
1538
  case "add-triple":
1539
- ji(t, r);
1539
+ ki(t, r);
1540
1540
  break;
1541
1541
  case "deep-merge-triple":
1542
- co(t, r);
1542
+ uo(t, r);
1543
1543
  break;
1544
1544
  case "retract-triple":
1545
- Ai(t, r);
1545
+ Ei(t, r);
1546
1546
  break;
1547
1547
  case "delete-entity":
1548
- ln(t, r);
1548
+ fn(t, r);
1549
1549
  break;
1550
1550
  case "add-attr":
1551
- fo(t, r);
1551
+ co(t, r);
1552
1552
  break;
1553
1553
  case "delete-attr":
1554
- lo(t, r);
1554
+ fo(t, r);
1555
1555
  break;
1556
1556
  case "update-attr":
1557
- ho(t, r);
1557
+ lo(t, r);
1558
1558
  break;
1559
1559
  case "restore-attr":
1560
1560
  break;
@@ -1609,13 +1609,13 @@ function gt(t, e, n) {
1609
1609
  }
1610
1610
  return s;
1611
1611
  }
1612
- function yo(t, e, n) {
1612
+ function po(t, e, n) {
1613
1613
  let r = "";
1614
1614
  return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
1615
1615
  }
1616
- function bo(t, [e, n, r]) {
1616
+ function yo(t, [e, n, r]) {
1617
1617
  var i, s;
1618
- switch (yo(e, n, r)) {
1618
+ switch (po(e, n, r)) {
1619
1619
  case "e": {
1620
1620
  const a = t.eav.get(e);
1621
1621
  return X(a, 2);
@@ -1661,36 +1661,33 @@ function bo(t, [e, n, r]) {
1661
1661
  return X(t.eav, 3);
1662
1662
  }
1663
1663
  }
1664
- const Yt = {};
1665
- function _o(t, e, n) {
1664
+ function bo(t, e, n) {
1666
1665
  var r;
1667
- if (Yt[n])
1668
- return Yt[n];
1669
1666
  const i = {};
1670
1667
  for (const [s, o] of e.entries()) {
1671
1668
  const a = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), u = X(a, 1);
1672
1669
  for (const d of u)
1673
1670
  i[s] = d[2];
1674
1671
  }
1675
- return Yt[n] = i, i;
1672
+ return i;
1676
1673
  }
1677
1674
  function Te(t, e, n) {
1678
1675
  var r;
1679
1676
  return (r = t.attrIndexes.forwardIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
1680
1677
  }
1681
- function Ii(t, e, n) {
1678
+ function Pi(t, e, n) {
1682
1679
  var r;
1683
1680
  return (r = t.attrIndexes.revIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
1684
1681
  }
1685
- function go(t, e) {
1682
+ function _o(t, e) {
1686
1683
  return t.attrIndexes.blobAttrs.get(e);
1687
1684
  }
1688
- function Mi(t, e) {
1685
+ function Ii(t, e) {
1689
1686
  var n;
1690
1687
  const r = t.attrIndexes.primaryKeys.get(e);
1691
1688
  return r || ((n = t.attrIndexes.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
1692
1689
  }
1693
- function To(t, e) {
1690
+ function go(t, e) {
1694
1691
  const n = dt(t, e);
1695
1692
  if (!n)
1696
1693
  return;
@@ -1698,7 +1695,7 @@ function To(t, e) {
1698
1695
  if (qe(t.attrs, i))
1699
1696
  return We(t.eav, [r, i]);
1700
1697
  }
1701
- function wo(t, e) {
1698
+ function To(t, e) {
1702
1699
  const n = e.filter(([r, i, s, o, a]) => {
1703
1700
  if (r !== "add-triple" && r !== "deep-merge-triple")
1704
1701
  return !0;
@@ -1708,39 +1705,39 @@ function wo(t, e) {
1708
1705
  let d = !1;
1709
1706
  const c = qe(t.attrs, s);
1710
1707
  if (c) {
1711
- const f = Mi(t, c["forward-identity"][1]);
1712
- d = !!To(t, [i, f.id, i]);
1708
+ const f = Ii(t, c["forward-identity"][1]);
1709
+ d = !!go(t, [i, f.id, i]);
1713
1710
  }
1714
1711
  return !(u === "create" && d || u === "update" && !d);
1715
1712
  });
1716
1713
  return Pt(t, (r) => {
1717
1714
  n.forEach((i) => {
1718
- po(r, i);
1715
+ ho(r, i);
1719
1716
  });
1720
1717
  });
1721
1718
  }
1722
- function mo(t) {
1719
+ function wo(t) {
1723
1720
  return typeof t == "string" && t.startsWith("?");
1724
1721
  }
1725
- function vo(t, e, n) {
1722
+ function mo(t, e, n) {
1726
1723
  if (n.hasOwnProperty(t)) {
1727
1724
  const r = n[t];
1728
- return Ri(r, e, n);
1725
+ return Mi(r, e, n);
1729
1726
  }
1730
1727
  return Object.assign(Object.assign({}, n), { [t]: e });
1731
1728
  }
1732
- function kr(t, e, n) {
1729
+ function Ar(t, e, n) {
1733
1730
  return t === e ? n : null;
1734
1731
  }
1735
- function So(t) {
1732
+ function vo(t) {
1736
1733
  switch (typeof t) {
1737
1734
  case "string":
1738
- return t.startsWith("?") ? vo : kr;
1735
+ return t.startsWith("?") ? mo : Ar;
1739
1736
  default:
1740
- return kr;
1737
+ return Ar;
1741
1738
  }
1742
1739
  }
1743
- const Oo = [
1740
+ const So = [
1744
1741
  "in",
1745
1742
  "$in",
1746
1743
  "$not",
@@ -1748,77 +1745,77 @@ const Oo = [
1748
1745
  "$comparator"
1749
1746
  // covers all of $gt, $lt, etc.
1750
1747
  ];
1751
- function Eo(t) {
1752
- for (const e of Oo)
1748
+ function Oo(t) {
1749
+ for (const e of So)
1753
1750
  if (t.hasOwnProperty(e))
1754
1751
  return !0;
1755
1752
  return !1;
1756
1753
  }
1757
- function Ri(t, e, n) {
1758
- return n ? typeof t == "object" ? Eo(t) ? n : null : So(t)(t, e, n) : null;
1754
+ function Mi(t, e, n) {
1755
+ return n ? typeof t == "object" ? Oo(t) ? n : null : vo(t)(t, e, n) : null;
1759
1756
  }
1760
- function Ao(t, e, n) {
1757
+ function Eo(t, e, n) {
1761
1758
  return t.reduce((r, i, s) => {
1762
1759
  const o = e[s];
1763
- return Ri(i, o, r);
1760
+ return Mi(i, o, r);
1764
1761
  }, n);
1765
1762
  }
1766
- function ko(t, e, n) {
1767
- return Po(t, e, n).map((r) => Ao(e, r, n)).filter((r) => r);
1763
+ function Ao(t, e, n) {
1764
+ return Co(t, e, n).map((r) => Eo(e, r, n)).filter((r) => r);
1768
1765
  }
1769
- function jo(t, e, n) {
1770
- return e.or ? e.or.patterns.flatMap((r) => hn(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => hn(t, i, r), n) : n.flatMap((r) => ko(t, e, r));
1766
+ function ko(t, e, n) {
1767
+ return e.or ? e.or.patterns.flatMap((r) => ln(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => ln(t, i, r), n) : n.flatMap((r) => Ao(t, e, r));
1771
1768
  }
1772
- function hn(t, e, n = [{}]) {
1773
- return e.reduce((r, i) => jo(t, i, r), n);
1769
+ function ln(t, e, n = [{}]) {
1770
+ return e.reduce((r, i) => ko(t, i, r), n);
1774
1771
  }
1775
- function Vn(t, e) {
1776
- return Array.isArray(e) ? e.map((n) => Vn(t, n)) : mo(e) ? t[e] : e;
1772
+ function zn(t, e) {
1773
+ return Array.isArray(e) ? e.map((n) => zn(t, n)) : wo(e) ? t[e] : e;
1777
1774
  }
1778
- function Co(t, { find: e, where: n }) {
1779
- return hn(t, n).map((i) => Vn(i, e));
1775
+ function jo(t, { find: e, where: n }) {
1776
+ return ln(t, n).map((i) => zn(i, e));
1780
1777
  }
1781
- function Po(t, e, n) {
1782
- return bo(t, Vn(n, e));
1778
+ function Co(t, e, n) {
1779
+ return yo(t, zn(n, e));
1783
1780
  }
1784
- const Io = /^(?:[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;
1781
+ const Po = /^(?:[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;
1785
1782
  function Fe(t) {
1786
- return typeof t == "string" && Io.test(t);
1783
+ return typeof t == "string" && Po.test(t);
1787
1784
  }
1788
1785
  const q = [];
1789
1786
  for (let t = 0; t < 256; ++t)
1790
1787
  q.push((t + 256).toString(16).slice(1));
1791
- function Mo(t, e = 0) {
1788
+ function Io(t, e = 0) {
1792
1789
  return (q[t[e + 0]] + q[t[e + 1]] + q[t[e + 2]] + q[t[e + 3]] + "-" + q[t[e + 4]] + q[t[e + 5]] + "-" + q[t[e + 6]] + q[t[e + 7]] + "-" + q[t[e + 8]] + q[t[e + 9]] + "-" + q[t[e + 10]] + q[t[e + 11]] + q[t[e + 12]] + q[t[e + 13]] + q[t[e + 14]] + q[t[e + 15]]).toLowerCase();
1793
1790
  }
1794
- let Jt;
1795
- const Ro = new Uint8Array(16);
1796
- function xo() {
1797
- if (!Jt) {
1791
+ let Yt;
1792
+ const Mo = new Uint8Array(16);
1793
+ function Ro() {
1794
+ if (!Yt) {
1798
1795
  if (typeof crypto > "u" || !crypto.getRandomValues)
1799
1796
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1800
- Jt = crypto.getRandomValues.bind(crypto);
1797
+ Yt = crypto.getRandomValues.bind(crypto);
1801
1798
  }
1802
- return Jt(Ro);
1799
+ return Yt(Mo);
1803
1800
  }
1804
- const $o = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), jr = { randomUUID: $o };
1805
- function Do(t, e, n) {
1801
+ const xo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), kr = { randomUUID: xo };
1802
+ function $o(t, e, n) {
1806
1803
  var i;
1807
- if (jr.randomUUID && !t)
1808
- return jr.randomUUID();
1804
+ if (kr.randomUUID && !t)
1805
+ return kr.randomUUID();
1809
1806
  t = t || {};
1810
- const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? xo();
1807
+ const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Ro();
1811
1808
  if (r.length < 16)
1812
1809
  throw new Error("Random bytes length must be >= 16");
1813
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Mo(r);
1810
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Io(r);
1814
1811
  }
1815
- function Cr(t) {
1812
+ function jr(t) {
1816
1813
  const e = t.replace(/-/g, ""), n = [];
1817
1814
  for (let r = 0; r < e.length; r += 2)
1818
1815
  n.push(parseInt(e.substring(r, r + 2), 16));
1819
1816
  return n;
1820
1817
  }
1821
- function Uo(t, e) {
1818
+ function Do(t, e) {
1822
1819
  for (let n = 0; n < t.length; n++) {
1823
1820
  if (t[n] < e[n])
1824
1821
  return -1;
@@ -1827,17 +1824,17 @@ function Uo(t, e) {
1827
1824
  }
1828
1825
  return 0;
1829
1826
  }
1830
- function Lo(t, e) {
1831
- return Uo(Cr(t), Cr(e));
1827
+ function Uo(t, e) {
1828
+ return Do(jr(t), jr(e));
1832
1829
  }
1833
1830
  function K() {
1834
- return Do();
1831
+ return $o();
1835
1832
  }
1836
- function Fo(t, e) {
1833
+ function Lo(t, e) {
1837
1834
  return t.localeCompare(e);
1838
1835
  }
1839
- function No() {
1840
- let t = Fo;
1836
+ function Fo() {
1837
+ let t = Lo;
1841
1838
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1842
1839
  try {
1843
1840
  t = Intl.Collator("en-US").compare;
@@ -1845,10 +1842,10 @@ function No() {
1845
1842
  }
1846
1843
  return t;
1847
1844
  }
1848
- const Ko = No();
1849
- let qo = 0;
1845
+ const No = Fo();
1846
+ let Ko = 0;
1850
1847
  function rt(t) {
1851
- return $t(`_${t}`, qo++);
1848
+ return $t(`_${t}`, Ko++);
1852
1849
  }
1853
1850
  function $t(t, e) {
1854
1851
  return `?${t}-${e}`;
@@ -1858,28 +1855,28 @@ class Ne extends Error {
1858
1855
  super(e), this.name = "AttrNotFoundError";
1859
1856
  }
1860
1857
  }
1861
- function Wo(t, e) {
1862
- const n = Mi(t, e);
1858
+ function qo(t, e) {
1859
+ const n = Ii(t, e);
1863
1860
  if (!n)
1864
1861
  throw new Ne(`Could not find id attr for ${e}`);
1865
1862
  return n;
1866
1863
  }
1867
- function Pr(t, e, n, r) {
1868
- return [zo(t, e, n, r)];
1864
+ function Cr(t, e, n, r) {
1865
+ return [Wo(t, e, n, r)];
1869
1866
  }
1870
- function zo(t, e, n, r) {
1867
+ function Wo(t, e, n, r) {
1871
1868
  return [
1872
1869
  t(n, r),
1873
- Wo(e, n).id,
1870
+ qo(e, n).id,
1874
1871
  t(n, r),
1875
1872
  t("time", r)
1876
1873
  ];
1877
1874
  }
1878
- function Vo(t, e, n) {
1875
+ function zo(t, e, n) {
1879
1876
  return t.map((r) => r === e ? n : r);
1880
1877
  }
1881
- function xi(t, e, n, r, i) {
1882
- const s = Te(e, n, i), o = Ii(e, n, i), a = s || o;
1878
+ function Ri(t, e, n, r, i) {
1879
+ const s = Te(e, n, i), o = Pi(e, n, i), a = s || o;
1883
1880
  if (!a)
1884
1881
  throw new Ne(`Could not find attr for ${[n, i]}`);
1885
1882
  if (a["value-type"] !== "ref")
@@ -1897,7 +1894,7 @@ function xi(t, e, n, r, i) {
1897
1894
  ];
1898
1895
  return [s ? f : d, l, p, a, !!s];
1899
1896
  }
1900
- function Ir(t, e) {
1897
+ function Pr(t, e) {
1901
1898
  if (typeof e != "string")
1902
1899
  return function(o) {
1903
1900
  return !1;
@@ -1907,7 +1904,7 @@ function Ir(t, e) {
1907
1904
  return typeof o != "string" ? !1 : i.test(o);
1908
1905
  };
1909
1906
  }
1910
- function Bo(t, e) {
1907
+ function Vo(t, e) {
1911
1908
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
1912
1909
  return e;
1913
1910
  const n = t["checked-data-type"] === "date";
@@ -1948,7 +1945,7 @@ function Bo(t, e) {
1948
1945
  }
1949
1946
  };
1950
1947
  if (e.hasOwnProperty("$like")) {
1951
- const r = Ir(!0, e.$like);
1948
+ const r = Pr(!0, e.$like);
1952
1949
  return {
1953
1950
  $comparator: !0,
1954
1951
  $op: function(s) {
@@ -1957,7 +1954,7 @@ function Bo(t, e) {
1957
1954
  };
1958
1955
  }
1959
1956
  if (e.hasOwnProperty("$ilike")) {
1960
- const r = Ir(!1, e.$ilike);
1957
+ const r = Pr(!1, e.$ilike);
1961
1958
  return {
1962
1959
  $comparator: !0,
1963
1960
  $op: function(s) {
@@ -1967,8 +1964,8 @@ function Bo(t, e) {
1967
1964
  }
1968
1965
  return e;
1969
1966
  }
1970
- function Go(t, e, n, r, i, s) {
1971
- const o = Te(e, n, i), a = Ii(e, n, i), u = o || a;
1967
+ function Bo(t, e, n, r, i, s) {
1968
+ const o = Te(e, n, i), a = Pi(e, n, i), u = o || a;
1972
1969
  if (!u)
1973
1970
  throw new Ne(`No attr for etype = ${n} label = ${i}`);
1974
1971
  if (s != null && s.hasOwnProperty("$isNull")) {
@@ -1985,63 +1982,63 @@ function Go(t, e, n, r, i, s) {
1985
1982
  return o ? [
1986
1983
  t(n, r),
1987
1984
  u.id,
1988
- Bo(u, s),
1985
+ Vo(u, s),
1989
1986
  rt("time")
1990
1987
  ] : [s, u.id, t(n, r), rt("time")];
1991
1988
  }
1992
- function Qo(t, e, n, r, i) {
1989
+ function Go(t, e, n, r, i) {
1993
1990
  const [s, o, a] = i.reduce((u, d) => {
1994
- const [c, f, l] = u, [p, y, b] = xi(t, e, c, f, d);
1991
+ const [c, f, l] = u, [p, y, b] = Ri(t, e, c, f, d);
1995
1992
  return [p, y, [...l, b]];
1996
1993
  }, [n, r, []]);
1997
1994
  return [s, o, a];
1998
1995
  }
1999
- function pn(t, e, n, r, i, s) {
2000
- const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, d, c] = Qo(t, e, n, r, o), f = Go(t, e, u, d, a, s);
1996
+ function hn(t, e, n, r, i, s) {
1997
+ const o = i.slice(0, i.length - 1), a = i[i.length - 1], [u, d, c] = Go(t, e, n, r, o), f = Bo(t, e, u, d, a, s);
2001
1998
  return c.concat([f]);
2002
1999
  }
2003
- function Ho(t, e) {
2000
+ function Qo(t, e) {
2004
2001
  return e ? [e].concat(t) : t;
2005
2002
  }
2006
- function Yo([t, e]) {
2003
+ function Ho([t, e]) {
2007
2004
  return t === "or" && Array.isArray(e);
2008
2005
  }
2009
- function Jo([t, e]) {
2006
+ function Yo([t, e]) {
2010
2007
  return t === "and" && Array.isArray(e);
2011
2008
  }
2012
- function Zo(t, e, n) {
2009
+ function Jo(t, e, n) {
2013
2010
  return (r, i) => {
2014
2011
  const s = t(r, i);
2015
2012
  return e == s ? s : `${s}-${n}`;
2016
2013
  };
2017
2014
  }
2018
- function Mr(t, e, n, r, i, s) {
2015
+ function Ir(t, e, n, r, i, s) {
2019
2016
  const o = t(r, i), a = s.map((u, d) => {
2020
- const c = Zo(t, o, d);
2021
- return $i(c, n, r, i, u);
2017
+ const c = Jo(t, o, d);
2018
+ return xi(c, n, r, i, u);
2022
2019
  });
2023
2020
  return { [e]: { patterns: a, joinSym: o } };
2024
2021
  }
2025
- function Xo(t) {
2022
+ function Zo(t) {
2026
2023
  const e = [];
2027
2024
  for (let n = 1; n <= t.length; n++)
2028
2025
  e.push(t.slice(0, n));
2029
2026
  return e;
2030
2027
  }
2031
- function Rr(t, e, n, r, i) {
2032
- return Xo(i).map((s) => pn(t, e, n, r, s, { $isNull: !0 }));
2028
+ function Mr(t, e, n, r, i) {
2029
+ return Zo(i).map((s) => hn(t, e, n, r, s, { $isNull: !0 }));
2033
2030
  }
2034
- function $i(t, e, n, r, i) {
2031
+ function xi(t, e, n, r, i) {
2035
2032
  return Object.entries(i).flatMap(([s, o]) => {
2033
+ if (Ho([s, o]))
2034
+ return Ir(t, "or", e, n, r, o);
2036
2035
  if (Yo([s, o]))
2037
- return Mr(t, "or", e, n, r, o);
2038
- if (Jo([s, o]))
2039
- return Mr(t, "and", e, n, r, o);
2036
+ return Ir(t, "and", e, n, r, o);
2040
2037
  if (s === "$entityIdStartsWith")
2041
2038
  return [];
2042
2039
  const a = s.split(".");
2043
2040
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2044
- const u = pn(t, e, n, r, a, o), d = Rr(t, e, n, r, a);
2041
+ const u = hn(t, e, n, r, a, o), d = Mr(t, e, n, r, a);
2045
2042
  return [
2046
2043
  {
2047
2044
  or: {
@@ -2054,32 +2051,32 @@ function $i(t, e, n, r, i) {
2054
2051
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && a.length > 1 ? [
2055
2052
  {
2056
2053
  or: {
2057
- patterns: Rr(t, e, n, r, a),
2054
+ patterns: Mr(t, e, n, r, a),
2058
2055
  joinSym: t(n, r)
2059
2056
  }
2060
2057
  }
2061
- ] : pn(t, e, n, r, a, o);
2058
+ ] : hn(t, e, n, r, a, o);
2062
2059
  });
2063
2060
  }
2064
- function ea(t, e, n, r) {
2061
+ function Xo(t, e, n, r) {
2065
2062
  const i = $t;
2066
- return r ? $i(i, t, e, n, r).concat(Pr(i, t, e, n)) : Pr(i, t, e, n);
2063
+ return r ? xi(i, t, e, n, r).concat(Cr(i, t, e, n)) : Cr(i, t, e, n);
2067
2064
  }
2068
- function ta(t, e, n) {
2065
+ function ea(t, e, n) {
2069
2066
  return [t(e, n), t("time", n)];
2070
2067
  }
2071
- function na(t, e, n, r, i, s) {
2072
- const [o, a, u, d, c] = xi(t, e, n, r, i), f = Vo(u, t(n, r), s);
2068
+ function ta(t, e, n, r, i, s) {
2069
+ const [o, a, u, d, c] = Ri(t, e, n, r, i), f = zo(u, t(n, r), s);
2073
2070
  return [o, a, f, d, c];
2074
2071
  }
2075
- function ra(t, e, { etype: n, level: r, form: i }, s) {
2072
+ function na(t, e, { etype: n, level: r, form: i }, s) {
2076
2073
  const o = Object.keys(i).filter((a) => a !== "$");
2077
2074
  return o.length ? Object.entries(s).map(function([u, d]) {
2078
2075
  return o.map(function(l) {
2079
2076
  var p, y, b;
2080
2077
  const _ = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
2081
2078
  try {
2082
- const [w, g, m] = na(t, e, n, r, l, u), E = Ui(e, {
2079
+ const [w, g, m] = ta(t, e, n, r, l, u), E = Di(e, {
2083
2080
  etype: w,
2084
2081
  level: g,
2085
2082
  form: i[l],
@@ -2096,48 +2093,48 @@ function ra(t, e, { etype: n, level: r, form: i }, s) {
2096
2093
  }, d);
2097
2094
  }) : Object.values(s);
2098
2095
  }
2099
- function ia(t, e, n) {
2100
- return n === "string" ? Ko(t, e) : t > e ? 1 : -1;
2096
+ function ra(t, e, n) {
2097
+ return n === "string" ? No(t, e) : t > e ? 1 : -1;
2101
2098
  }
2102
2099
  function Xe(t, e, n, r, i) {
2103
- return e === r || e == null && r == null ? Lo(t, n) : r == null ? 1 : e == null ? -1 : ia(e, r, i);
2100
+ return e === r || e == null && r == null ? Uo(t, n) : r == null ? 1 : e == null ? -1 : ra(e, r, i);
2104
2101
  }
2105
2102
  function It([t, e], [n, r], i) {
2106
2103
  return Xe(t, e, n, r, i);
2107
2104
  }
2108
- function yn(t) {
2105
+ function pn(t) {
2109
2106
  return t == null ? t : new Date(t).getTime();
2110
2107
  }
2111
- function sa(t, e, n, r) {
2108
+ function ia(t, e, n, r) {
2112
2109
  var i;
2113
2110
  const [s, o, a, u] = t, d = n === "desc" ? 1 : -1;
2114
2111
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2115
2112
  return It(r, [s, u], null) === d;
2116
- const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? yn(f) : f, y = l === "date" ? yn(a) : a;
2113
+ const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? pn(f) : f, y = l === "date" ? pn(a) : a;
2117
2114
  return It([c, p], [s, y], l) === d;
2118
2115
  }
2119
- function oa(t, e) {
2116
+ function sa(t, e) {
2120
2117
  const n = e[1];
2121
2118
  return t.attrs[n];
2122
2119
  }
2123
- function aa(t, e, n) {
2120
+ function oa(t, e, n) {
2124
2121
  const r = Object.keys(n)[0];
2125
2122
  return Te(t, e, r);
2126
2123
  }
2127
- function ua(t, e, n, r) {
2124
+ function aa(t, e, n, r) {
2128
2125
  if (n)
2129
- return oa(t, n);
2126
+ return sa(t, n);
2130
2127
  if (r)
2131
- return aa(t, e, r);
2128
+ return oa(t, e, r);
2132
2129
  }
2133
- function ca(t, e, n) {
2130
+ function ua(t, e, n) {
2134
2131
  var r, i;
2135
2132
  if (!Array.isArray(n.fields))
2136
- return go(t, e);
2133
+ return _o(t, e);
2137
2134
  const s = /* @__PURE__ */ new Map();
2138
2135
  for (const o of n.fields) {
2139
2136
  const a = Te(t, e, o), u = (r = a == null ? void 0 : a["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2140
- u && Wn(a) && s.set(u, a);
2137
+ u && qn(a) && s.set(u, a);
2141
2138
  }
2142
2139
  if (!s.has("id")) {
2143
2140
  const o = Te(t, e, "id"), a = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
@@ -2145,17 +2142,17 @@ function ca(t, e, n) {
2145
2142
  }
2146
2143
  return s;
2147
2144
  }
2148
- function da(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2145
+ function ca(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2149
2146
  var s, o;
2150
- const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = Di(i), d = fa(i);
2151
- let c = Co(t, r);
2152
- const f = n == null ? void 0 : n["start-cursor"], l = ua(t, e, f, a);
2147
+ const a = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, u = $i(i), d = da(i);
2148
+ let c = jo(t, r);
2149
+ const f = n == null ? void 0 : n["start-cursor"], l = aa(t, e, f, a);
2153
2150
  if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
2154
2151
  const b = l["checked-data-type"] === "date", _ = l.id;
2155
2152
  c = c.map(([w]) => {
2156
2153
  var g, m, E, S, I;
2157
2154
  let x = (I = (S = (E = (m = (g = t.eav.get(w)) === null || g === void 0 ? void 0 : g.get(_)) === null || m === void 0 ? void 0 : m.values()) === null || E === void 0 ? void 0 : E.next()) === null || S === void 0 ? void 0 : S.value) === null || I === void 0 ? void 0 : I[2];
2158
- return b && (x = yn(x)), [w, x];
2155
+ return b && (x = pn(x)), [w, x];
2159
2156
  });
2160
2157
  }
2161
2158
  c.sort(d === "asc" ? function(_, w) {
@@ -2164,31 +2161,31 @@ function da(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2164
2161
  return It(w, _, l == null ? void 0 : l["checked-data-type"]);
2165
2162
  });
2166
2163
  let p = {};
2167
- const y = ca(t, e, r);
2164
+ const y = ua(t, e, r);
2168
2165
  for (const b of c) {
2169
2166
  const [_] = b;
2170
- if (p[_] || !u && f && l && sa(f, l, d, b))
2167
+ if (p[_] || !u && f && l && ia(f, l, d, b))
2171
2168
  continue;
2172
- const w = _o(t, y, _);
2169
+ const w = bo(t, y, _);
2173
2170
  w && (p[_] = w);
2174
2171
  }
2175
2172
  return p;
2176
2173
  }
2177
- function fa(t) {
2174
+ function da(t) {
2178
2175
  var e;
2179
2176
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2180
2177
  return n && n[Object.keys(n)[0]] || "asc";
2181
2178
  }
2182
- function Di(t) {
2179
+ function $i(t) {
2183
2180
  var e, n, r;
2184
2181
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2185
2182
  return !i && !s && !o;
2186
2183
  }
2187
- function la(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2184
+ function fa(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2188
2185
  var o, a, u, d, c;
2189
- if (!Di(r) && (!s || !s["start-cursor"]))
2186
+ if (!$i(r) && (!s || !s["start-cursor"]))
2190
2187
  return [];
2191
- const f = Ho(ea(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = ta($t, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = da(t, {
2188
+ const f = Qo(Xo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = ea($t, e, n), p = (a = r.$) === null || a === void 0 ? void 0 : a.fields, y = ca(t, {
2192
2189
  etype: e,
2193
2190
  pageInfo: s,
2194
2191
  form: r,
@@ -2201,20 +2198,20 @@ function la(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2201
2198
  }
2202
2199
  return y;
2203
2200
  }
2204
- function ha(t, e) {
2201
+ function la(t, e) {
2205
2202
  try {
2206
- return la(t, e);
2203
+ return fa(t, e);
2207
2204
  } catch (n) {
2208
2205
  if (n instanceof Ne)
2209
2206
  return {};
2210
2207
  throw n;
2211
2208
  }
2212
2209
  }
2213
- function Ui(t, e) {
2214
- const n = ha(t, e);
2215
- return ra($t, t, e, n);
2210
+ function Di(t, e) {
2211
+ const n = la(t, e);
2212
+ return na($t, t, e, n);
2216
2213
  }
2217
- function pa(t) {
2214
+ function ha(t) {
2218
2215
  const e = {};
2219
2216
  for (const [n, r] of Object.entries(t))
2220
2217
  e[n] = {
@@ -2225,18 +2222,18 @@ function pa(t) {
2225
2222
  };
2226
2223
  return e;
2227
2224
  }
2228
- function Li({ store: t, pageInfo: e, aggregate: n }, r) {
2225
+ function Ui({ store: t, pageInfo: e, aggregate: n }, r) {
2229
2226
  const s = { data: Object.keys(r).reduce(function(a, u) {
2230
- return n != null && n[u] || u === "$$ruleParams" || (a[u] = Ui(t, {
2227
+ return n != null && n[u] || u === "$$ruleParams" || (a[u] = Di(t, {
2231
2228
  etype: u,
2232
2229
  form: r[u],
2233
2230
  level: 0,
2234
2231
  pageInfo: e == null ? void 0 : e[u]
2235
2232
  })), a;
2236
2233
  }, {}) };
2237
- return e && (s.pageInfo = pa(e)), n && (s.aggregate = n), s;
2234
+ return e && (s.pageInfo = ha(e)), n && (s.aggregate = n), s;
2238
2235
  }
2239
- function ya() {
2236
+ function pa() {
2240
2237
  const e = {
2241
2238
  __etype: 1,
2242
2239
  __ops: 1,
@@ -2250,8 +2247,8 @@ function ya() {
2250
2247
  };
2251
2248
  return new Set(Object.keys(e));
2252
2249
  }
2253
- const ba = ya();
2254
- function bn(t, e, n) {
2250
+ const ya = pa();
2251
+ function yn(t, e, n) {
2255
2252
  const r = {
2256
2253
  __etype: t,
2257
2254
  __ops: n
@@ -2262,25 +2259,25 @@ function bn(t, e, n) {
2262
2259
  return n;
2263
2260
  if (s === "__etype")
2264
2261
  return t;
2265
- if (ba.has(s))
2266
- return (o, a) => bn(t, e, [
2262
+ if (ya.has(s))
2263
+ return (o, a) => yn(t, e, [
2267
2264
  ...n,
2268
2265
  a ? [s, t, e, o, a] : [s, t, e, o]
2269
2266
  ]);
2270
2267
  }
2271
2268
  });
2272
2269
  }
2273
- function Nc(t, e) {
2270
+ function Fc(t, e) {
2274
2271
  return `lookup__${t}__${JSON.stringify(e)}`;
2275
2272
  }
2276
2273
  function Mt(t) {
2277
2274
  return t.startsWith("lookup__");
2278
2275
  }
2279
- function Fi(t) {
2276
+ function Li(t) {
2280
2277
  const [e, n, ...r] = t.split("__");
2281
2278
  return [n, JSON.parse(r.join("__"))];
2282
2279
  }
2283
- function _a(t) {
2280
+ function ba(t) {
2284
2281
  return new Proxy({
2285
2282
  __etype: t
2286
2283
  }, {
@@ -2288,22 +2285,22 @@ function _a(t) {
2288
2285
  if (n === "__etype")
2289
2286
  return t;
2290
2287
  const r = n;
2291
- return Mt(r) ? bn(t, Fi(r), []) : bn(t, r, []);
2288
+ return Mt(r) ? yn(t, Li(r), []) : yn(t, r, []);
2292
2289
  }
2293
2290
  });
2294
2291
  }
2295
- function Bn() {
2292
+ function Vn() {
2296
2293
  return new Proxy({}, {
2297
2294
  get(t, e) {
2298
- return _a(e);
2295
+ return ba(e);
2299
2296
  }
2300
2297
  });
2301
2298
  }
2302
- const Kc = Bn();
2303
- function ga(t) {
2299
+ const Nc = Vn();
2300
+ function _a(t) {
2304
2301
  return t.__ops;
2305
2302
  }
2306
- function Ta(t, e) {
2303
+ function ga(t, e) {
2307
2304
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2308
2305
  for (const o of e) {
2309
2306
  const a = n[o];
@@ -2337,7 +2334,7 @@ function Ae(t, e, n) {
2337
2334
  return o === e && a === n;
2338
2335
  });
2339
2336
  }
2340
- function wa(t) {
2337
+ function Ta(t) {
2341
2338
  if (Array.isArray(t))
2342
2339
  return t;
2343
2340
  const e = Object.entries(t);
@@ -2345,38 +2342,38 @@ function wa(t) {
2345
2342
  throw new Error("lookup must be an object with a single unique attr and value.");
2346
2343
  return e[0];
2347
2344
  }
2348
- function _n(t, e, n) {
2345
+ function bn(t, e, n) {
2349
2346
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2350
2347
  // before assuming it's a ref lookup.
2351
2348
  !V(t, e, n);
2352
2349
  }
2353
- function gn(t) {
2350
+ function _n(t) {
2354
2351
  const [e, n, ...r] = t.split(".");
2355
2352
  if (r.length > 0 || n !== "id")
2356
2353
  throw new Error(`${t} is not a valid lookup attribute.`);
2357
2354
  return e;
2358
2355
  }
2359
- function ma(t, e, n) {
2360
- if (!_n(t, e, n))
2356
+ function wa(t, e, n) {
2357
+ if (!bn(t, e, n))
2361
2358
  return V(t, e, n);
2362
- const r = gn(n), i = V(t, e, r) || Ae(t, e, r);
2359
+ const r = _n(n), i = V(t, e, r) || Ae(t, e, r);
2363
2360
  if (i && i["value-type"] !== "ref")
2364
2361
  throw new Error(`${n} does not reference a valid link attribute.`);
2365
2362
  return i;
2366
2363
  }
2367
- function Tn(t) {
2368
- return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? Fi(t) : wa(t);
2364
+ function gn(t) {
2365
+ return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? Li(t) : Ta(t);
2369
2366
  }
2370
2367
  function ee(t, e, n) {
2371
- const r = Tn(n);
2368
+ const r = gn(n);
2372
2369
  if (r === null)
2373
2370
  return n;
2374
- const [i, s] = r, o = ma(t, e, i);
2371
+ const [i, s] = r, o = wa(t, e, i);
2375
2372
  if (!o || !o["unique?"])
2376
2373
  throw new Error(`${i} is not a unique attribute.`);
2377
2374
  return [o.id, s];
2378
2375
  }
2379
- function Ni(t, e, n, r) {
2376
+ function Fi(t, e, n, r) {
2380
2377
  const i = ee(t, e, n);
2381
2378
  return Array.isArray(i) ? [[
2382
2379
  "add-triple",
@@ -2385,7 +2382,7 @@ function Ni(t, e, n, r) {
2385
2382
  i
2386
2383
  ]].concat(r) : r;
2387
2384
  }
2388
- function va({ attrs: t }, [e, n, r]) {
2385
+ function ma({ attrs: t }, [e, n, r]) {
2389
2386
  const i = Object.entries(r).flatMap(([s, o]) => {
2390
2387
  const a = Array.isArray(o) ? o : [o], u = V(t, e, s), d = Ae(t, e, s);
2391
2388
  return a.map((c) => u ? [
@@ -2400,9 +2397,9 @@ function va({ attrs: t }, [e, n, r]) {
2400
2397
  ee(t, e, n)
2401
2398
  ]);
2402
2399
  });
2403
- return Ni(t, e, n, i);
2400
+ return Fi(t, e, n, i);
2404
2401
  }
2405
- function Sa({ attrs: t }, [e, n, r]) {
2402
+ function va({ attrs: t }, [e, n, r]) {
2406
2403
  const i = Object.entries(r).flatMap(([s, o]) => {
2407
2404
  const a = Array.isArray(o) ? o : [o], u = V(t, e, s), d = Ae(t, e, s);
2408
2405
  return a.map((c) => u ? [
@@ -2417,9 +2414,9 @@ function Sa({ attrs: t }, [e, n, r]) {
2417
2414
  ee(t, e, n)
2418
2415
  ]);
2419
2416
  });
2420
- return Ni(t, e, n, i);
2417
+ return Fi(t, e, n, i);
2421
2418
  }
2422
- function Oa(t, e, n) {
2419
+ function Sa(t, e, n) {
2423
2420
  if (Array.isArray(n)) {
2424
2421
  const [r, i] = n;
2425
2422
  for (const s of t || []) {
@@ -2441,18 +2438,18 @@ function Oa(t, e, n) {
2441
2438
  }
2442
2439
  return !1;
2443
2440
  }
2444
- function Ki({ stores: t, attrs: e }, [n, r, i, s]) {
2445
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Oa(t, n, r) ? { mode: "update" } : null;
2441
+ function Ni({ stores: t, attrs: e }, [n, r, i, s]) {
2442
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Sa(t, n, r) ? { mode: "update" } : null;
2446
2443
  }
2447
- function Ea(t, e) {
2448
- const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Kn(o), d = ee(r, i, s);
2444
+ function Oa(t, e) {
2445
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Nn(o), d = ee(r, i, s);
2449
2446
  return [["id", d]].concat(Object.entries(u)).map(([f, l]) => {
2450
2447
  const p = V(r, i, f);
2451
2448
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = xt(l)), ["add-triple", d, p.id, l, { mode: "create" }];
2452
2449
  });
2453
2450
  }
2454
- function Aa(t, e) {
2455
- const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Kn(o), d = ee(r, i, s), c = Ki(t, [i, d, o, a]);
2451
+ function Ea(t, e) {
2452
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Nn(o), d = ee(r, i, s), c = Ni(t, [i, d, o, a]);
2456
2453
  return [["id", d]].concat(Object.entries(u)).map(([l, p]) => {
2457
2454
  const y = V(r, i, l);
2458
2455
  return y["checked-data-type"] === "date" && t.useDateObjects && (p = xt(p)), [
@@ -2464,11 +2461,11 @@ function Aa(t, e) {
2464
2461
  ];
2465
2462
  });
2466
2463
  }
2467
- function ka({ attrs: t }, [e, n]) {
2464
+ function Aa({ attrs: t }, [e, n]) {
2468
2465
  return [["delete-entity", ee(t, e, n), e]];
2469
2466
  }
2470
- function ja(t, e) {
2471
- const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Kn(o), d = ee(r, i, s), c = Ki(t, [i, d, o, a]), f = Object.entries(u).map(([p, y]) => {
2467
+ function ka(t, e) {
2468
+ const { stores: n, attrs: r } = t, [i, s, o, a] = e, u = Nn(o), d = ee(r, i, s), c = Ni(t, [i, d, o, a]), f = Object.entries(u).map(([p, y]) => {
2472
2469
  const b = V(r, i, p);
2473
2470
  return [
2474
2471
  "deep-merge-triple",
@@ -2486,38 +2483,38 @@ function ja(t, e) {
2486
2483
  ...c ? [c] : []
2487
2484
  ]].concat(f);
2488
2485
  }
2489
- function Ca({ attrs: t }, [e, n, r]) {
2486
+ function ja({ attrs: t }, [e, n, r]) {
2490
2487
  return [["rule-params", ee(t, e, n), e, r]];
2491
2488
  }
2492
- function Pa(t) {
2489
+ function Ca(t) {
2493
2490
  const [e, n, r, i, s] = t;
2494
2491
  if (!i)
2495
2492
  return t;
2496
2493
  const o = Object.assign({}, i);
2497
2494
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2498
2495
  }
2499
- function Ia(t, e) {
2500
- const [n, ...r] = Pa(e);
2496
+ function Pa(t, e) {
2497
+ const [n, ...r] = Ca(e);
2501
2498
  switch (n) {
2502
2499
  case "merge":
2503
- return ja(t, r);
2500
+ return ka(t, r);
2504
2501
  case "create":
2505
- return Ea(t, r);
2502
+ return Oa(t, r);
2506
2503
  case "update":
2507
- return Aa(t, r);
2504
+ return Ea(t, r);
2508
2505
  case "link":
2509
- return va(t, r);
2506
+ return ma(t, r);
2510
2507
  case "unlink":
2511
- return Sa(t, r);
2508
+ return va(t, r);
2512
2509
  case "delete":
2513
- return ka(t, r);
2510
+ return Aa(t, r);
2514
2511
  case "ruleParams":
2515
- return Ca(t, r);
2512
+ return ja(t, r);
2516
2513
  default:
2517
2514
  throw new Error(`unsupported action ${n}`);
2518
2515
  }
2519
2516
  }
2520
- function Ma(t) {
2517
+ function Ia(t) {
2521
2518
  switch (t) {
2522
2519
  case "string":
2523
2520
  case "date":
@@ -2528,14 +2525,14 @@ function Ma(t) {
2528
2525
  return;
2529
2526
  }
2530
2527
  }
2531
- function Ra(t, e, n) {
2528
+ function Ma(t, e, n) {
2532
2529
  var r, i;
2533
2530
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2534
2531
  if (n === "id")
2535
2532
  return null;
2536
2533
  if (!s)
2537
2534
  throw new Error(`${e}.${n} does not exist in your schema`);
2538
- const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ma(s == null ? void 0 : s.valueType);
2535
+ const { unique: o, indexed: a } = s == null ? void 0 : s.config, u = Ia(s == null ? void 0 : s.valueType);
2539
2536
  return {
2540
2537
  "index?": a,
2541
2538
  "unique?": o,
@@ -2543,14 +2540,14 @@ function Ra(t, e, n) {
2543
2540
  };
2544
2541
  }
2545
2542
  function Tt(t, e, n, r) {
2546
- const i = t ? Ra(t, e, n) : null, s = K(), a = [K(), e, n];
2543
+ const i = t ? Ma(t, e, n) : null, s = K(), a = [K(), e, n];
2547
2544
  return Object.assign(Object.assign({ id: s, "forward-identity": a, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2548
2545
  }
2549
- function xa(t, e, n) {
2546
+ function Ra(t, e, n) {
2550
2547
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2551
2548
  }
2552
- function $a(t, e, n) {
2553
- const r = xa(t, e, n);
2549
+ function xa(t, e, n) {
2550
+ const r = Ra(t, e, n);
2554
2551
  if (!r)
2555
2552
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2556
2553
  const { forward: i, reverse: s } = r;
@@ -2563,11 +2560,11 @@ function $a(t, e, n) {
2563
2560
  "on-delete-reverse": s.onDelete
2564
2561
  };
2565
2562
  }
2566
- function xr(t, e, n, r) {
2567
- const i = t ? $a(t, e, n) : null, s = K(), o = [K(), e, n], a = [K(), n, e];
2563
+ function Rr(t, e, n, r) {
2564
+ const i = t ? xa(t, e, n) : null, s = K(), o = [K(), e, n], a = [K(), n, e];
2568
2565
  return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": a, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2569
2566
  }
2570
- const Da = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Ua = /* @__PURE__ */ new Set(["link", "unlink"]), La = /* @__PURE__ */ new Set(["create", "update", "merge"]), Fa = /* @__PURE__ */ new Set([
2567
+ const $a = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Da = /* @__PURE__ */ new Set(["link", "unlink"]), Ua = /* @__PURE__ */ new Set(["create", "update", "merge"]), La = /* @__PURE__ */ new Set([
2571
2568
  "link",
2572
2569
  "unlink",
2573
2570
  "create",
@@ -2575,17 +2572,17 @@ const Da = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2575
2572
  "merge",
2576
2573
  "delete",
2577
2574
  "ruleParams"
2578
- ]), wn = { "unique?": !0, "index?": !0 }, Na = Object.assign(Object.assign({}, wn), { cardinality: "one" });
2579
- function Ka(t) {
2575
+ ]), Tn = { "unique?": !0, "index?": !0 }, Fa = Object.assign(Object.assign({}, Tn), { cardinality: "one" });
2576
+ function Na(t) {
2580
2577
  const e = [], [n, r, i, s] = t;
2581
- if (!Fa.has(n))
2578
+ if (!La.has(n))
2582
2579
  return e;
2583
- const o = Tn(i);
2580
+ const o = gn(i);
2584
2581
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
2585
2582
  for (const [a, u] of Object.entries(s)) {
2586
2583
  const d = Array.isArray(u) ? u : [u];
2587
2584
  for (const c of d) {
2588
- const f = Tn(c);
2585
+ const f = gn(c);
2589
2586
  f && e.push({
2590
2587
  etype: r,
2591
2588
  lookupPair: f,
@@ -2595,7 +2592,7 @@ function Ka(t) {
2595
2592
  }
2596
2593
  return e;
2597
2594
  }
2598
- function qa({ attrs: t, schema: e }, n) {
2595
+ function Ka({ attrs: t, schema: e }, n) {
2599
2596
  var r, i;
2600
2597
  const [s, o, a] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
2601
2598
  function u(f) {
@@ -2606,47 +2603,47 @@ function qa({ attrs: t, schema: e }, n) {
2606
2603
  }
2607
2604
  function c(f, l) {
2608
2605
  const p = V(o, f, l), y = Ae(o, f, l);
2609
- d(p), d(y), !p && !y && u(xr(e, f, l, Na));
2606
+ d(p), d(y), !p && !y && u(Rr(e, f, l, Fa));
2610
2607
  }
2611
2608
  for (const f of n)
2612
- for (const { etype: l, lookupPair: p, linkLabel: y } of Ka(f)) {
2609
+ for (const { etype: l, lookupPair: p, linkLabel: y } of Na(f)) {
2613
2610
  const b = p[0];
2614
2611
  if (y) {
2615
2612
  c(l, y);
2616
2613
  const _ = V(o, l, y), w = Ae(o, l, y);
2617
2614
  d(_), d(w);
2618
2615
  const g = ((r = _ == null ? void 0 : _["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = w == null ? void 0 : w["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || y;
2619
- if (_n(o, g, b))
2620
- c(g, gn(b));
2616
+ if (bn(o, g, b))
2617
+ c(g, _n(b));
2621
2618
  else {
2622
2619
  const m = V(o, g, b);
2623
- m || u(Tt(e, g, b, wn)), d(m);
2620
+ m || u(Tt(e, g, b, Tn)), d(m);
2624
2621
  }
2625
- } else if (_n(o, l, b))
2626
- c(l, gn(b));
2622
+ } else if (bn(o, l, b))
2623
+ c(l, _n(b));
2627
2624
  else {
2628
2625
  const _ = V(o, l, b);
2629
- _ || u(Tt(e, l, b, wn)), d(_);
2626
+ _ || u(Tt(e, l, b, Tn)), d(_);
2630
2627
  }
2631
2628
  }
2632
2629
  for (const f of n) {
2633
2630
  const [l, p, y, b] = f;
2634
- if (Da.has(l)) {
2631
+ if ($a.has(l)) {
2635
2632
  const _ = V(o, p, "id");
2636
2633
  d(_), _ || u(Tt(e, p, "id", { "unique?": !0 }));
2637
2634
  for (const w of Object.keys(b)) {
2638
2635
  const g = V(o, p, w);
2639
- if (d(g), La.has(l) && (g || u(Tt(e, p, w, w === "id" ? { "unique?": !0 } : null))), Ua.has(l)) {
2636
+ if (d(g), Ua.has(l) && (g || u(Tt(e, p, w, w === "id" ? { "unique?": !0 } : null))), Da.has(l)) {
2640
2637
  const m = Ae(o, p, w);
2641
- !g && !m && u(xr(e, p, w)), d(m);
2638
+ !g && !m && u(Rr(e, p, w)), d(m);
2642
2639
  }
2643
2640
  }
2644
2641
  }
2645
2642
  }
2646
2643
  return [o, a];
2647
2644
  }
2648
- function Wa(t, e) {
2649
- const r = (Array.isArray(e) ? e : [e]).flatMap((u) => ga(u)), [i, s] = qa(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), a = r.flatMap((u) => Ia(o, u));
2645
+ function qa(t, e) {
2646
+ const r = (Array.isArray(e) ? e : [e]).flatMap((u) => _a(u)), [i, s] = Ka(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), a = r.flatMap((u) => Pa(o, u));
2650
2647
  return [...s, ...a];
2651
2648
  }
2652
2649
  var de = function(t, e, n, r) {
@@ -2676,15 +2673,15 @@ var de = function(t, e, n, r) {
2676
2673
  d((r = r.apply(t, e || [])).next());
2677
2674
  });
2678
2675
  };
2679
- function $r(t, e) {
2676
+ function xr(t, e) {
2680
2677
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2681
2678
  }
2682
2679
  const it = "__meta";
2683
- class za {
2680
+ class Wa {
2684
2681
  constructor(e, n) {
2685
2682
  }
2686
2683
  }
2687
- class mn {
2684
+ class wn {
2688
2685
  constructor(e) {
2689
2686
  var n, r;
2690
2687
  this._subs = [], this._nextSave = null, this._nextGc = null, this._pendingSaveKeys = /* @__PURE__ */ new Set(), this._loadedKeys = /* @__PURE__ */ new Set(), this._version = 0, this._meta = {
@@ -2878,7 +2875,7 @@ class mn {
2878
2875
  gc() {
2879
2876
  this._nextGc || (this._nextGc = setTimeout(
2880
2877
  () => {
2881
- $r(() => {
2878
+ xr(() => {
2882
2879
  this._nextGc = null, this._gc();
2883
2880
  }, 30 * 1e3);
2884
2881
  },
@@ -2893,7 +2890,7 @@ class mn {
2893
2890
  return;
2894
2891
  }
2895
2892
  this._nextSave = setTimeout(() => {
2896
- $r(() => {
2893
+ xr(() => {
2897
2894
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
2898
2895
  }, this._idleCallbackMaxWaitMs);
2899
2896
  }, this._saveThrottleMs);
@@ -2955,13 +2952,13 @@ var pe = function(t, e, n, r) {
2955
2952
  d((r = r.apply(t, e || [])).next());
2956
2953
  });
2957
2954
  };
2958
- const Va = 6, Ba = ["kv", "querySubs", "syncSubs"];
2959
- function Ga(t) {
2955
+ const za = 6, Va = ["kv", "querySubs", "syncSubs"];
2956
+ function Ba(t) {
2960
2957
  return function(n) {
2961
2958
  console.error("Error in IndexedDB event", { source: t, event: n });
2962
2959
  };
2963
2960
  }
2964
- function Qa(t) {
2961
+ function Ga(t) {
2965
2962
  return pe(this, void 0, void 0, function* () {
2966
2963
  return new Promise((e) => {
2967
2964
  const n = indexedDB.open(t);
@@ -2977,7 +2974,7 @@ function Qa(t) {
2977
2974
  });
2978
2975
  });
2979
2976
  }
2980
- function Ha(t, e, n) {
2977
+ function Qa(t, e, n) {
2981
2978
  return pe(this, void 0, void 0, function* () {
2982
2979
  const r = (
2983
2980
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3013,7 +3010,7 @@ function Ha(t, e, n) {
3013
3010
  });
3014
3011
  });
3015
3012
  }
3016
- function Dr(t, e, n) {
3013
+ function $r(t, e, n) {
3017
3014
  return pe(this, void 0, void 0, function* () {
3018
3015
  const r = n.put(e, t);
3019
3016
  return new Promise((i, s) => {
@@ -3021,9 +3018,9 @@ function Dr(t, e, n) {
3021
3018
  });
3022
3019
  });
3023
3020
  }
3024
- function Ya(t, e) {
3021
+ function Ha(t, e) {
3025
3022
  return pe(this, void 0, void 0, function* () {
3026
- const n = yield Qa(`instant_${t}_5`);
3023
+ const n = yield Ga(`instant_${t}_5`);
3027
3024
  if (!n)
3028
3025
  return;
3029
3026
  const r = yield new Promise((c, f) => {
@@ -3046,12 +3043,12 @@ function Ya(t, e) {
3046
3043
  for (const [c, f] of r)
3047
3044
  switch (c) {
3048
3045
  case "querySubs": {
3049
- const l = Ha(c, f, o);
3046
+ const l = Qa(c, f, o);
3050
3047
  a.push(l);
3051
3048
  break;
3052
3049
  }
3053
3050
  default: {
3054
- const l = Dr(c, f, s);
3051
+ const l = $r(c, f, s);
3055
3052
  a.push(l);
3056
3053
  const p = {
3057
3054
  createdAt: Date.now(),
@@ -3062,16 +3059,16 @@ function Ya(t, e) {
3062
3059
  break;
3063
3060
  }
3064
3061
  }
3065
- const d = Dr(it, u, s);
3062
+ const d = $r(it, u, s);
3066
3063
  a.push(d), yield Promise.all(a), yield new Promise((c, f) => {
3067
3064
  i.oncomplete = (l) => c(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3068
3065
  });
3069
3066
  });
3070
3067
  }
3071
- const Ur = /* @__PURE__ */ new Map();
3072
- class qi extends za {
3068
+ const Dr = /* @__PURE__ */ new Map();
3069
+ class Ki extends Wa {
3073
3070
  constructor(e, n) {
3074
- super(e, n), this.dbName = `instant_${e}_${Va}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3071
+ super(e, n), this.dbName = `instant_${e}_${za}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3075
3072
  }
3076
3073
  _init() {
3077
3074
  return new Promise((e, n) => {
@@ -3082,12 +3079,12 @@ class qi extends za {
3082
3079
  }, i.onsuccess = (s) => {
3083
3080
  const a = s.target.result;
3084
3081
  if (r) {
3085
- const u = Ya(this._appId, a).catch((d) => {
3086
- Ga("Error upgrading store from version 5 to 6.")(d);
3082
+ const u = Ha(this._appId, a).catch((d) => {
3083
+ Ba("Error upgrading store from version 5 to 6.")(d);
3087
3084
  });
3088
- Ur.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
3085
+ Dr.set(this.dbName, u), u.then(() => e(a)).catch(() => e(a));
3089
3086
  } else {
3090
- const u = Ur.get(this.dbName);
3087
+ const u = Dr.get(this.dbName);
3091
3088
  u ? u.then(() => e(a)).catch(() => e(a)) : e(a);
3092
3089
  }
3093
3090
  }, i.onupgradeneeded = (s) => {
@@ -3097,7 +3094,7 @@ class qi extends za {
3097
3094
  }
3098
3095
  _upgradeStore(e) {
3099
3096
  const r = e.target.result;
3100
- for (const i of Ba)
3097
+ for (const i of Va)
3101
3098
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3102
3099
  }
3103
3100
  getItem(e) {
@@ -3172,7 +3169,7 @@ class qi extends za {
3172
3169
  });
3173
3170
  }
3174
3171
  }
3175
- var Ja = function(t, e, n, r) {
3172
+ var Ya = function(t, e, n, r) {
3176
3173
  function i(s) {
3177
3174
  return s instanceof n ? s : new n(function(o) {
3178
3175
  o(s);
@@ -3199,9 +3196,9 @@ var Ja = function(t, e, n, r) {
3199
3196
  d((r = r.apply(t, e || [])).next());
3200
3197
  });
3201
3198
  };
3202
- class Wi {
3199
+ class qi {
3203
3200
  static getIsOnline() {
3204
- return Ja(this, void 0, void 0, function* () {
3201
+ return Ya(this, void 0, void 0, function* () {
3205
3202
  return navigator.onLine;
3206
3203
  });
3207
3204
  }
@@ -3226,7 +3223,7 @@ class Ke extends Error {
3226
3223
  return "InstantError";
3227
3224
  }
3228
3225
  }
3229
- var Za = function(t, e, n, r) {
3226
+ var Ja = function(t, e, n, r) {
3230
3227
  function i(s) {
3231
3228
  return s instanceof n ? s : new n(function(o) {
3232
3229
  o(s);
@@ -3266,7 +3263,7 @@ class Dt extends Ke {
3266
3263
  }
3267
3264
  }
3268
3265
  function ue(t, e) {
3269
- return Za(this, void 0, void 0, function* () {
3266
+ return Ja(this, void 0, void 0, function* () {
3270
3267
  const n = yield fetch(t, e), r = yield n.json();
3271
3268
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
3272
3269
  });
@@ -3298,14 +3295,14 @@ var ze = function(t, e, n, r) {
3298
3295
  d((r = r.apply(t, e || [])).next());
3299
3296
  });
3300
3297
  };
3301
- function Xa({ apiURI: t, appId: e, email: n }) {
3298
+ function Za({ apiURI: t, appId: e, email: n }) {
3302
3299
  return ue(`${t}/runtime/auth/send_magic_code`, {
3303
3300
  method: "POST",
3304
3301
  headers: { "content-type": "application/json" },
3305
3302
  body: JSON.stringify({ "app-id": e, email: n })
3306
3303
  });
3307
3304
  }
3308
- function eu(t) {
3305
+ function Xa(t) {
3309
3306
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3310
3307
  return yield ue(`${e}/runtime/auth/verify_magic_code`, {
3311
3308
  method: "POST",
@@ -3318,7 +3315,7 @@ function eu(t) {
3318
3315
  });
3319
3316
  });
3320
3317
  }
3321
- function tu(t) {
3318
+ function eu(t) {
3322
3319
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3323
3320
  return yield ue(`${e}/runtime/auth/verify_refresh_token`, {
3324
3321
  method: "POST",
@@ -3330,7 +3327,7 @@ function tu(t) {
3330
3327
  });
3331
3328
  });
3332
3329
  }
3333
- function nu(t) {
3330
+ function tu(t) {
3334
3331
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3335
3332
  return yield ue(`${e}/runtime/auth/sign_in_guest`, {
3336
3333
  method: "POST",
@@ -3341,7 +3338,7 @@ function nu(t) {
3341
3338
  });
3342
3339
  });
3343
3340
  }
3344
- function Lr(t) {
3341
+ function Ur(t) {
3345
3342
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
3346
3343
  return yield ue(`${e}/runtime/oauth/token`, {
3347
3344
  method: "POST",
@@ -3355,7 +3352,7 @@ function Lr(t) {
3355
3352
  });
3356
3353
  });
3357
3354
  }
3358
- function ru(t) {
3355
+ function nu(t) {
3359
3356
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3360
3357
  return yield ue(`${e}/runtime/oauth/id_token`, {
3361
3358
  method: "POST",
@@ -3370,7 +3367,7 @@ function ru(t) {
3370
3367
  });
3371
3368
  });
3372
3369
  }
3373
- function iu(t) {
3370
+ function ru(t) {
3374
3371
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3375
3372
  return yield ue(`${e}/runtime/signout`, {
3376
3373
  method: "POST",
@@ -3411,7 +3408,7 @@ var ft = function(t, e, n, r) {
3411
3408
  d((r = r.apply(t, e || [])).next());
3412
3409
  });
3413
3410
  };
3414
- function su(t) {
3411
+ function iu(t) {
3415
3412
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: a }) {
3416
3413
  const u = {
3417
3414
  app_id: n,
@@ -3426,7 +3423,7 @@ function su(t) {
3426
3423
  });
3427
3424
  });
3428
3425
  }
3429
- function ou(t) {
3426
+ function su(t) {
3430
3427
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3431
3428
  const { data: s } = yield ue(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3432
3429
  method: "DELETE",
@@ -3438,7 +3435,7 @@ function ou(t) {
3438
3435
  return s;
3439
3436
  });
3440
3437
  }
3441
- function au(t) {
3438
+ function ou(t) {
3442
3439
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3443
3440
  const { data: o } = yield ue(`${e}/storage/signed-upload-url`, {
3444
3441
  method: "POST",
@@ -3454,7 +3451,7 @@ function au(t) {
3454
3451
  return o;
3455
3452
  });
3456
3453
  }
3457
- function uu(t, e) {
3454
+ function au(t, e) {
3458
3455
  return ft(this, void 0, void 0, function* () {
3459
3456
  return (yield fetch(t, {
3460
3457
  method: "PUT",
@@ -3465,7 +3462,7 @@ function uu(t, e) {
3465
3462
  })).ok;
3466
3463
  });
3467
3464
  }
3468
- function cu(t) {
3465
+ function uu(t) {
3469
3466
  return ft(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3470
3467
  const { data: s } = yield ue(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3471
3468
  method: "GET",
@@ -3477,9 +3474,9 @@ function cu(t) {
3477
3474
  return s;
3478
3475
  });
3479
3476
  }
3480
- let Gn = !1, zi = !1, Vi = !1;
3481
- typeof window < "u" && typeof window.localStorage < "u" && (Gn = !!window.localStorage.getItem("devBackend"), zi = !!window.localStorage.getItem("__instantLogging"), Vi = !!window.localStorage.getItem("__devtoolLocalDash"));
3482
- function Fr(t, e) {
3477
+ let Bn = !1, Wi = !1, zi = !1;
3478
+ typeof window < "u" && typeof window.localStorage < "u" && (Bn = !!window.localStorage.getItem("devBackend"), Wi = !!window.localStorage.getItem("__instantLogging"), zi = !!window.localStorage.getItem("__devtoolLocalDash"));
3479
+ function Lr(t, e) {
3483
3480
  if (!e)
3484
3481
  return t;
3485
3482
  const n = {};
@@ -3487,33 +3484,33 @@ function Fr(t, e) {
3487
3484
  n[r] = t[r];
3488
3485
  }), n;
3489
3486
  }
3490
- function du(t, e, n) {
3487
+ function cu(t, e, n) {
3491
3488
  var r, i;
3492
3489
  const s = {
3493
3490
  peers: {}
3494
3491
  };
3495
3492
  if (e && "user" in e ? e.user : !0) {
3496
- const a = Fr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3493
+ const a = Lr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
3497
3494
  s.user = Object.assign(Object.assign({}, a), { peerId: n });
3498
3495
  }
3499
3496
  for (const a of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
3500
3497
  const u = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(a));
3501
3498
  if (u || d) {
3502
- const c = Fr(t.peers[a], e == null ? void 0 : e.keys);
3499
+ const c = Lr(t.peers[a], e == null ? void 0 : e.keys);
3503
3500
  s.peers[a] = Object.assign(Object.assign({}, c), { peerId: a });
3504
3501
  }
3505
3502
  }
3506
3503
  return s;
3507
3504
  }
3508
- function fu(t, e) {
3509
- if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Or(t.user, e.user)) || !Ti(t.peers, e.peers))
3505
+ function du(t, e) {
3506
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Sr(t.user, e.user)) || !gi(t.peers, e.peers))
3510
3507
  return !0;
3511
3508
  for (const r of Object.keys(t.peers))
3512
- if (!Or(t.peers[r], e.peers[r]))
3509
+ if (!Sr(t.peers[r], e.peers[r]))
3513
3510
  return !0;
3514
3511
  return !1;
3515
3512
  }
3516
- class Nr {
3513
+ class Fr {
3517
3514
  constructor() {
3518
3515
  this.promise = new Promise((e, n) => {
3519
3516
  this._resolve = e, this._reject = n;
@@ -3526,20 +3523,20 @@ class Nr {
3526
3523
  this._reject(e);
3527
3524
  }
3528
3525
  }
3529
- function Bi(t, e = []) {
3526
+ function Vi(t, e = []) {
3530
3527
  t.forEach((n) => {
3531
3528
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
3532
3529
  for (const o of s)
3533
3530
  for (const a of o)
3534
3531
  e.push(a);
3535
- Bi(n["child-nodes"], e);
3532
+ Vi(n["child-nodes"], e);
3536
3533
  });
3537
3534
  }
3538
- function Kr(t) {
3535
+ function Nr(t) {
3539
3536
  const e = [];
3540
- return Bi(t, e), e;
3537
+ return Vi(t, e), e;
3541
3538
  }
3542
- function qr(t) {
3539
+ function Kr(t) {
3543
3540
  return Object.values(t.links).reduce((e, n) => {
3544
3541
  var r, i, s, o;
3545
3542
  return (r = e[s = n.forward.on]) !== null && r !== void 0 || (e[s] = {}), e[n.forward.on][n.forward.label] = {
@@ -3553,8 +3550,8 @@ function qr(t) {
3553
3550
  }, e;
3554
3551
  }, {});
3555
3552
  }
3556
- const Qn = "v0.22.62-experimental.drewh-entity-caching.19581443445.1";
3557
- function lu(t, e) {
3553
+ const Gn = "v0.22.62";
3554
+ function fu(t, e) {
3558
3555
  return {
3559
3556
  info: t ? (...n) => console.info(...n, e()) : () => {
3560
3557
  },
@@ -3627,7 +3624,7 @@ class R extends Error {
3627
3624
  super(r), this.name = "QueryValidationError";
3628
3625
  }
3629
3626
  }
3630
- const Wr = [
3627
+ const qr = [
3631
3628
  "where",
3632
3629
  "order",
3633
3630
  "limit",
@@ -3638,7 +3635,7 @@ const Wr = [
3638
3635
  "before",
3639
3636
  "fields",
3640
3637
  "aggregate"
3641
- ], hu = (t) => t.valueType || "unknown", Gi = (t, e, n = !1) => {
3638
+ ], lu = (t) => t.valueType || "unknown", Bi = (t, e, n = !1) => {
3642
3639
  if (n || t == null)
3643
3640
  return !0;
3644
3641
  switch (e) {
@@ -3653,9 +3650,9 @@ const Wr = [
3653
3650
  default:
3654
3651
  return !0;
3655
3652
  }
3656
- }, pu = (t, e, n, r, i, s, o) => {
3653
+ }, hu = (t, e, n, r, i, s, o) => {
3657
3654
  const a = s.valueType === "json", u = (d, c, f) => {
3658
- if (!Gi(f, c, a))
3655
+ if (!Bi(f, c, a))
3659
3656
  throw new R(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
3660
3657
  };
3661
3658
  switch (t) {
@@ -3686,16 +3683,16 @@ const Wr = [
3686
3683
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3687
3684
  }
3688
3685
  }, Ue = (t, e, n, r, i) => {
3689
- const s = hu(n), o = n.valueType === "json";
3686
+ const s = lu(n), o = n.valueType === "json";
3690
3687
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3691
3688
  if (o)
3692
3689
  return;
3693
3690
  const u = t;
3694
3691
  for (const [d, c] of Object.entries(u))
3695
- pu(d, c, s, e, r, n, `${i}.${d}`);
3696
- } else if (!Gi(t, s, o))
3692
+ hu(d, c, s, e, r, n, `${i}.${d}`);
3693
+ } else if (!Bi(t, s, o))
3697
3694
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3698
- }, yu = (t, e, n, r, i) => {
3695
+ }, pu = (t, e, n, r, i) => {
3699
3696
  const s = t.split(".");
3700
3697
  if (s.length < 2)
3701
3698
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3732,12 +3729,12 @@ const Wr = [
3732
3729
  throw new R(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
3733
3730
  }
3734
3731
  Ue(e, t, d, n, i);
3735
- }, Qi = (t, e, n, r) => {
3732
+ }, Gi = (t, e, n, r) => {
3736
3733
  for (const [i, s] of Object.entries(t)) {
3737
3734
  if (i === "or" || i === "and") {
3738
3735
  if (Array.isArray(s))
3739
3736
  for (const d of s)
3740
- typeof d == "object" && d !== null && Qi(d, e, n, `${r}.${i}[${d}]`);
3737
+ typeof d == "object" && d !== null && Gi(d, e, n, `${r}.${i}[${d}]`);
3741
3738
  continue;
3742
3739
  }
3743
3740
  if (i === "id") {
@@ -3745,7 +3742,7 @@ const Wr = [
3745
3742
  continue;
3746
3743
  }
3747
3744
  if (i.includes(".")) {
3748
- yu(i, s, e, n, `${r}.${i}`);
3745
+ pu(i, s, e, n, `${r}.${i}`);
3749
3746
  continue;
3750
3747
  }
3751
3748
  const o = n.entities[e];
@@ -3765,10 +3762,10 @@ const Wr = [
3765
3762
  Ue(s, i, d, e, `${r}.${i}`);
3766
3763
  }
3767
3764
  }
3768
- }, bu = (t, e, n, r, i = 0) => {
3765
+ }, yu = (t, e, n, r, i = 0) => {
3769
3766
  for (const o of Object.keys(t))
3770
- if (!Wr.includes(o))
3771
- throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Wr.join(", ")}. Found: ${o}`, r);
3767
+ if (!qr.includes(o))
3768
+ throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${qr.join(", ")}. Found: ${o}`, r);
3772
3769
  const s = [
3773
3770
  // 'limit', // only supported client side
3774
3771
  "offset",
@@ -3783,9 +3780,9 @@ const Wr = [
3783
3780
  if (t.where && n) {
3784
3781
  if (typeof t.where != "object" || t.where === null)
3785
3782
  throw new R(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`, r ? `${r}.where` : void 0);
3786
- Qi(t.where, e, n, r ? `${r}.where` : "where");
3783
+ Gi(t.where, e, n, r ? `${r}.where` : "where");
3787
3784
  }
3788
- }, Hi = (t, e, n, r, i = 0) => {
3785
+ }, Qi = (t, e, n, r, i = 0) => {
3789
3786
  var s;
3790
3787
  if (!t || typeof t != "object")
3791
3788
  throw new R(`Query part for entity '${e}' must be an object, but received: ${typeof t}`, r);
@@ -3798,15 +3795,15 @@ const Wr = [
3798
3795
  const a = t[o];
3799
3796
  if (typeof a == "object" && a !== null) {
3800
3797
  const u = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
3801
- u && Hi(a, u, n, `${r}.${o}`, i + 1);
3798
+ u && Qi(a, u, n, `${r}.${o}`, i + 1);
3802
3799
  }
3803
3800
  } else {
3804
3801
  const a = t[o];
3805
3802
  if (typeof a != "object" || a === null)
3806
3803
  throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3807
- bu(a, e, n, `${r}.$`, i);
3804
+ yu(a, e, n, `${r}.$`, i);
3808
3805
  }
3809
- }, zr = (t, e) => {
3806
+ }, Wr = (t, e) => {
3810
3807
  if (typeof t != "object" || t === null)
3811
3808
  throw new R(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
3812
3809
  if (Array.isArray(t))
@@ -3822,67 +3819,67 @@ const Wr = [
3822
3819
  const i = Object.keys(e.entities);
3823
3820
  throw new R(`Entity '${r}' does not exist in schema. Available entities: ${i.length > 0 ? i.join(", ") : "none"}`, r);
3824
3821
  }
3825
- Hi(n[r], r, e, r, 0);
3822
+ Qi(n[r], r, e, r, 0);
3826
3823
  }
3827
3824
  }
3828
- }, Vr = (t) => typeof t != "string" ? !1 : Mt(t) ? !0 : Fe(t);
3825
+ }, zr = (t) => typeof t != "string" ? !1 : Mt(t) ? !0 : Fe(t);
3829
3826
  class ie extends Error {
3830
3827
  constructor(e) {
3831
3828
  super(e), this.name = "TransactionValidationError";
3832
3829
  }
3833
3830
  }
3834
- const Yi = (t) => t.length > 0 ? t.join(", ") : "none", _u = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Yi(e)}`), Br = {
3831
+ const Hi = (t) => t.length > 0 ? t.join(", ") : "none", bu = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Hi(e)}`), Vr = {
3835
3832
  string: (t) => typeof t == "string",
3836
3833
  number: (t) => typeof t == "number" && !isNaN(t),
3837
3834
  boolean: (t) => typeof t == "boolean",
3838
3835
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3839
3836
  json: () => !0
3840
- }, gu = (t, e) => {
3837
+ }, _u = (t, e) => {
3841
3838
  var n, r;
3842
- return t == null ? !0 : (r = (n = Br[e.valueType]) === null || n === void 0 ? void 0 : n.call(Br, t)) !== null && r !== void 0 ? r : !1;
3843
- }, Ji = (t, e) => {
3839
+ return t == null ? !0 : (r = (n = Vr[e.valueType]) === null || n === void 0 ? void 0 : n.call(Vr, t)) !== null && r !== void 0 ? r : !1;
3840
+ }, Yi = (t, e) => {
3844
3841
  const n = e.entities[t];
3845
3842
  if (!n)
3846
- throw _u(t, Object.keys(e.entities));
3843
+ throw bu(t, Object.keys(e.entities));
3847
3844
  return n;
3848
- }, Zt = (t, e, n) => {
3849
- const r = Ji(t, n);
3845
+ }, Jt = (t, e, n) => {
3846
+ const r = Yi(t, n);
3850
3847
  if (typeof e != "object" || e === null)
3851
3848
  throw new ie(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
3852
3849
  for (const [i, s] of Object.entries(e)) {
3853
3850
  if (i === "id")
3854
3851
  continue;
3855
3852
  const o = r.attrs[i];
3856
- if (o && !gu(s, o))
3853
+ if (o && !_u(s, o))
3857
3854
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3858
3855
  }
3859
- }, Gr = (t, e, n) => {
3860
- const r = Ji(t, n);
3856
+ }, Br = (t, e, n) => {
3857
+ const r = Yi(t, n);
3861
3858
  if (typeof e != "object" || e === null)
3862
3859
  throw new ie(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
3863
3860
  for (const [i, s] of Object.entries(e)) {
3864
3861
  if (!r.links[i]) {
3865
3862
  const a = Object.keys(r.links);
3866
- throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Yi(a)}`);
3863
+ throw new ie(`Link '${i}' does not exist on entity '${t}'. Available links: ${Hi(a)}`);
3867
3864
  }
3868
3865
  if (s != null) {
3869
3866
  if (Array.isArray(s)) {
3870
3867
  for (const a of s)
3871
- if (!Vr(a))
3868
+ if (!zr(a))
3872
3869
  throw new ie(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${a}`);
3873
- } else if (!Vr(s))
3870
+ } else if (!zr(s))
3874
3871
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3875
3872
  }
3876
3873
  }
3877
- }, Tu = {
3878
- create: Zt,
3879
- update: Zt,
3880
- merge: Zt,
3881
- link: Gr,
3882
- unlink: Gr,
3874
+ }, gu = {
3875
+ create: Jt,
3876
+ update: Jt,
3877
+ merge: Jt,
3878
+ link: Br,
3879
+ unlink: Br,
3883
3880
  delete: () => {
3884
3881
  }
3885
- }, wu = (t, e) => {
3882
+ }, Tu = (t, e) => {
3886
3883
  if (!e)
3887
3884
  return;
3888
3885
  const [n, r, i, s] = t;
@@ -3890,9 +3887,9 @@ const Yi = (t) => t.length > 0 ? t.join(", ") : "none", _u = (t, e) => new ie(`E
3890
3887
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3891
3888
  if (typeof r != "string")
3892
3889
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3893
- const o = Tu[n];
3890
+ const o = gu[n];
3894
3891
  o && s !== void 0 && o(r, s, e);
3895
- }, mu = (t, e) => {
3892
+ }, wu = (t, e) => {
3896
3893
  const n = Array.isArray(t) ? t : [t];
3897
3894
  for (const r of n) {
3898
3895
  if (!r || typeof r != "object")
@@ -3902,11 +3899,11 @@ const Yi = (t) => t.length > 0 ? t.join(", ") : "none", _u = (t, e) => new ie(`E
3902
3899
  for (const i of r.__ops) {
3903
3900
  if (!Array.isArray(i))
3904
3901
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
3905
- wu(i, e);
3902
+ Tu(i, e);
3906
3903
  }
3907
3904
  }
3908
3905
  };
3909
- var Qr = function(t, e, n, r) {
3906
+ var Gr = function(t, e, n, r) {
3910
3907
  function i(s) {
3911
3908
  return s instanceof n ? s : new n(function(o) {
3912
3909
  o(s);
@@ -3933,10 +3930,10 @@ var Qr = function(t, e, n, r) {
3933
3930
  d((r = r.apply(t, e || [])).next());
3934
3931
  });
3935
3932
  };
3936
- let Zi = 0;
3937
- class Hr {
3933
+ let Ji = 0;
3934
+ class Qr {
3938
3935
  constructor(e) {
3939
- this.type = "ws", this.id = `${this.type}_${Zi++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
3936
+ this.type = "ws", this.id = `${this.type}_${Ji++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
3940
3937
  this.onopen && this.onopen({ target: this });
3941
3938
  }, this.conn.onmessage = (n) => {
3942
3939
  this.onmessage && this.onmessage({
@@ -3964,9 +3961,9 @@ class Hr {
3964
3961
  return this.conn.send(JSON.stringify(e));
3965
3962
  }
3966
3963
  }
3967
- class vu {
3964
+ class mu {
3968
3965
  constructor(e, n) {
3969
- this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${Zi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
3966
+ this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${Ji++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
3970
3967
  this.initParams || this.handleError();
3971
3968
  }, 1e4), this.conn.onmessage = (r) => {
3972
3969
  const i = JSON.parse(r.data);
@@ -3998,7 +3995,7 @@ class vu {
3998
3995
  this.conn.close(), this.onclose && !this.closeFired && (this.closeFired = !0, this.onclose({ target: this }));
3999
3996
  }
4000
3997
  postMessages(e) {
4001
- return Qr(this, void 0, void 0, function* () {
3998
+ return Gr(this, void 0, void 0, function* () {
4002
3999
  try {
4003
4000
  (yield fetch(this.url, {
4004
4001
  method: "POST",
@@ -4016,7 +4013,7 @@ class vu {
4016
4013
  });
4017
4014
  }
4018
4015
  flushQueue() {
4019
- return Qr(this, void 0, void 0, function* () {
4016
+ return Gr(this, void 0, void 0, function* () {
4020
4017
  if (this.sendPromise || !this.sendQueue.length)
4021
4018
  return;
4022
4019
  const e = this.sendQueue;
@@ -4042,7 +4039,7 @@ class vu {
4042
4039
  this.handleClose();
4043
4040
  }
4044
4041
  }
4045
- var Yr = function(t, e, n, r) {
4042
+ var Hr = function(t, e, n, r) {
4046
4043
  function i(s) {
4047
4044
  return s instanceof n ? s : new n(function(o) {
4048
4045
  o(s);
@@ -4069,34 +4066,34 @@ var Yr = function(t, e, n, r) {
4069
4066
  d((r = r.apply(t, e || [])).next());
4070
4067
  });
4071
4068
  };
4072
- function Su(t, e) {
4069
+ function vu(t, e) {
4073
4070
  const n = t.values;
4074
4071
  if (n)
4075
4072
  for (const r of n.entities || [])
4076
- r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Ei(r.store);
4073
+ r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Oi(r.store);
4077
4074
  return t;
4078
4075
  }
4079
- function Ou(t, e) {
4076
+ function Su(t, e) {
4080
4077
  var n, r;
4081
4078
  if (!((n = e.values) === null || n === void 0) && n.entities) {
4082
4079
  const i = [];
4083
4080
  for (const s of (r = e.values) === null || r === void 0 ? void 0 : r.entities) {
4084
- const o = Oi(s.store);
4081
+ const o = Si(s.store);
4085
4082
  delete o.attrs, i.push(Object.assign(Object.assign({}, s), { store: o }));
4086
4083
  }
4087
4084
  return Object.assign(Object.assign({}, e), { values: Object.assign(Object.assign({}, e.values), { entities: i }) });
4088
4085
  } else
4089
4086
  return e;
4090
4087
  }
4091
- function Eu(t, e, n) {
4088
+ function Ou(t, e, n) {
4092
4089
  var r, i;
4093
4090
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4094
4091
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
4095
4092
  }
4096
- function Xt(t, e) {
4097
- return Li({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4093
+ function Zt(t, e) {
4094
+ return Ui({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4098
4095
  }
4099
- function Jr(t, e, n) {
4096
+ function Yr(t, e, n) {
4100
4097
  var r;
4101
4098
  const i = (r = Te(e, t.table, "id")) === null || r === void 0 ? void 0 : r.id;
4102
4099
  if (!i)
@@ -4104,18 +4101,18 @@ function Jr(t, e, n) {
4104
4101
  const s = We(e.eav, [n, i, n]);
4105
4102
  return s ? s[3] : -1;
4106
4103
  }
4107
- function Zr(t, e) {
4104
+ function Jr(t, e) {
4108
4105
  for (const { action: n, triple: r } of e)
4109
4106
  switch (n) {
4110
4107
  case "added":
4111
- ji(t, r);
4108
+ ki(t, r);
4112
4109
  break;
4113
4110
  case "removed":
4114
- Ai(t, r);
4111
+ Ei(t, r);
4115
4112
  break;
4116
4113
  }
4117
4114
  }
4118
- function Au(t, e) {
4115
+ function Eu(t, e) {
4119
4116
  var n, r, i, s;
4120
4117
  const o = {};
4121
4118
  for (const { action: a, triple: u } of e) {
@@ -4143,14 +4140,14 @@ function Au(t, e) {
4143
4140
  function wt(t, e) {
4144
4141
  return { [t.table]: e.map((n) => n.entity) };
4145
4142
  }
4146
- function ku(t, e) {
4143
+ function Au(t, e) {
4147
4144
  var n;
4148
4145
  if (t.orderFieldType)
4149
4146
  return t.orderFieldType;
4150
4147
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = Te(e([]), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4151
4148
  return t.orderFieldType = r, r;
4152
4149
  }
4153
- function ju(t, e, n) {
4150
+ function ku(t, e, n) {
4154
4151
  const r = e;
4155
4152
  if (t.orderField === "serverCreatedAt") {
4156
4153
  n.sort(t.orderDirection === "asc" ? function(o, a) {
@@ -4171,13 +4168,13 @@ var ve;
4171
4168
  (function(t) {
4172
4169
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4173
4170
  })(ve || (ve = {}));
4174
- class Cu {
4171
+ class ju {
4175
4172
  constructor(e, n, r, i, s) {
4176
- this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new mn({
4173
+ this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new wn({
4177
4174
  persister: n,
4178
- merge: Eu,
4179
- serialize: Ou,
4180
- parse: (o, a) => Su(a, this.config.useDateObjects),
4175
+ merge: Ou,
4176
+ serialize: Su,
4177
+ parse: (o, a) => vu(a, this.config.useDateObjects),
4181
4178
  objectSize: (o) => {
4182
4179
  var a;
4183
4180
  return ((a = o.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
@@ -4234,7 +4231,7 @@ class Cu {
4234
4231
  });
4235
4232
  }
4236
4233
  initSubscription(e, n, r) {
4237
- return Yr(this, void 0, void 0, function* () {
4234
+ return Hr(this, void 0, void 0, function* () {
4238
4235
  var i, s, o, a;
4239
4236
  yield this.subs.waitForKeyToLoad(n);
4240
4237
  const u = this.subs.currentValue[n];
@@ -4260,7 +4257,7 @@ class Cu {
4260
4257
  });
4261
4258
  }
4262
4259
  flushPending() {
4263
- return Yr(this, void 0, void 0, function* () {
4260
+ return Hr(this, void 0, void 0, function* () {
4264
4261
  for (const e of Object.keys(this.callbacks)) {
4265
4262
  yield this.subs.waitForKeyToLoad(e);
4266
4263
  const n = this.subs.currentValue[e];
@@ -4305,11 +4302,11 @@ class Cu {
4305
4302
  for (const c of i) {
4306
4303
  const f = this.createStore(c);
4307
4304
  u.attrs = f.attrs;
4308
- const l = Xt(a, f);
4305
+ const l = Zt(a, f);
4309
4306
  d.push({
4310
4307
  store: f,
4311
4308
  entity: l,
4312
- serverCreatedAt: Jr(a, f, l.id)
4309
+ serverCreatedAt: Yr(a, f, l.id)
4313
4310
  }), o.push(l);
4314
4311
  }
4315
4312
  this.subs.updateInPlace((c) => {
@@ -4379,9 +4376,9 @@ class Cu {
4379
4376
  e: for (const [g, m] of Object.entries(f))
4380
4377
  for (let E = 0; E < p.length; E++) {
4381
4378
  const S = p[E];
4382
- if (ao(S.store, g)) {
4383
- Zr(S.store, m);
4384
- const I = Xt(a, S.store), x = Au(S.store, m)[g];
4379
+ if (oo(S.store, g)) {
4380
+ Jr(S.store, m);
4381
+ const I = Zt(a, S.store), x = Eu(S.store, m)[g];
4385
4382
  I ? (y.push({
4386
4383
  oldEntity: S.entity,
4387
4384
  newEntity: I,
@@ -4393,8 +4390,8 @@ class Cu {
4393
4390
  const b = [];
4394
4391
  for (const [g, m] of Object.entries(f)) {
4395
4392
  const E = this.createStore([]);
4396
- l.attrs = E.attrs, Zr(E, m);
4397
- const S = Xt(a, E);
4393
+ l.attrs = E.attrs, Jr(E, m);
4394
+ const S = Zt(a, E);
4398
4395
  if (!S) {
4399
4396
  this.log.error("No entity found after applying change", {
4400
4397
  sub: a,
@@ -4406,14 +4403,14 @@ class Cu {
4406
4403
  p.push({
4407
4404
  store: E,
4408
4405
  entity: S,
4409
- serverCreatedAt: Jr(a, E, S.id)
4406
+ serverCreatedAt: Yr(a, E, S.id)
4410
4407
  }), b.push(S);
4411
4408
  }
4412
4409
  const _ = [];
4413
4410
  for (const g of c.sort().reverse())
4414
4411
  _.push(p[g].entity), p.splice(g, 1);
4415
- const w = ku(a, this.createStore);
4416
- ju(a, w, p), this.notifyCbs(o, {
4412
+ const w = Au(a, this.createStore);
4413
+ ku(a, w, p), this.notifyCbs(o, {
4417
4414
  type: ve.SyncTransaction,
4418
4415
  data: wt(a, (i = a.values) === null || i === void 0 ? void 0 : i.entities),
4419
4416
  added: b,
@@ -4480,7 +4477,7 @@ var F = function(t, e, n, r) {
4480
4477
  }
4481
4478
  d((r = r.apply(t, e || [])).next());
4482
4479
  });
4483
- }, Pu = function(t, e) {
4480
+ }, Cu = function(t, e) {
4484
4481
  var n = {};
4485
4482
  for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
4486
4483
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -4494,46 +4491,46 @@ const le = {
4494
4491
  AUTHENTICATED: "authenticated",
4495
4492
  CLOSED: "closed",
4496
4493
  ERRORED: "errored"
4497
- }, Iu = 3e4, Mu = 3e4, Ru = 200, xu = {
4494
+ }, Pu = 3e4, Iu = 3e4, Mu = 200, Ru = {
4498
4495
  apiURI: "https://api.instantdb.com",
4499
4496
  websocketURI: "wss://api.instantdb.com/runtime/session"
4500
- }, en = "_instant_oauth_redirect", Qe = "currentUser";
4501
- function $u({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4497
+ }, Xt = "_instant_oauth_redirect", Qe = "currentUser";
4498
+ function xu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4502
4499
  if (!i)
4503
- return new Hr(`${r}?app_id=${e}`);
4500
+ return new Qr(`${r}?app_id=${e}`);
4504
4501
  switch (t) {
4505
4502
  case "ws":
4506
- return new Hr(`${r}?app_id=${e}`);
4503
+ return new Qr(`${r}?app_id=${e}`);
4507
4504
  case "sse":
4508
- return new vu(i, `${n}/runtime/sse?app_id=${e}`);
4505
+ return new mu(i, `${n}/runtime/sse?app_id=${e}`);
4509
4506
  default:
4510
4507
  throw new Error("Unknown transport type " + t);
4511
4508
  }
4512
4509
  }
4513
- function Du() {
4510
+ function $u() {
4514
4511
  return typeof window < "u" || typeof chrome < "u";
4515
4512
  }
4516
- const Xr = {
4513
+ const Zr = {
4517
4514
  "set-presence": !0,
4518
4515
  "set-presence-ok": !0,
4519
4516
  "refresh-presence": !0,
4520
4517
  "patch-presence": !0
4521
4518
  };
4522
- function Uu(t, e) {
4519
+ function Du(t, e) {
4523
4520
  var n;
4524
4521
  const r = typeof t == "string" ? JSON.parse(t) : t;
4525
4522
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
4526
4523
  const i = r.result.store;
4527
- r.result.store = Ei(Object.assign(Object.assign({}, i), { useDateObjects: e }));
4524
+ r.result.store = Oi(Object.assign(Object.assign({}, i), { useDateObjects: e }));
4528
4525
  }
4529
4526
  return r;
4530
4527
  }
4531
- function Lu(t, e) {
4528
+ function Uu(t, e) {
4532
4529
  var n;
4533
4530
  const r = Object.assign({}, e);
4534
- return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Oi(e.result.store) })), r;
4531
+ return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Si(e.result.store) })), r;
4535
4532
  }
4536
- function Fu(t, e) {
4533
+ function Lu(t, e) {
4537
4534
  switch (t) {
4538
4535
  case "pendingMutations":
4539
4536
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4541,7 +4538,7 @@ function Fu(t, e) {
4541
4538
  return e;
4542
4539
  }
4543
4540
  }
4544
- function Nu(t, e) {
4541
+ function Fu(t, e) {
4545
4542
  switch (t) {
4546
4543
  case "pendingMutations":
4547
4544
  return [...e.entries()];
@@ -4549,18 +4546,18 @@ function Nu(t, e) {
4549
4546
  return e;
4550
4547
  }
4551
4548
  }
4552
- function Ku(t, e, n) {
4549
+ function Nu(t, e, n) {
4553
4550
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4554
4551
  return r && !i && n && (n.result = r), n || e;
4555
4552
  }
4556
- function ei(t) {
4553
+ function Xr(t) {
4557
4554
  return [...t].sort((e, n) => {
4558
4555
  const [r, i] = e, [s, o] = n, a = i.order || 0, u = o.order || 0;
4559
4556
  return a == u ? r < s ? -1 : r > s ? 1 : 0 : a - u;
4560
4557
  });
4561
4558
  }
4562
- class qu {
4563
- constructor(e, n = qi, r = Wi, i, s) {
4559
+ class Ku {
4560
+ constructor(e, n = Ki, r = qi, i, s) {
4564
4561
  var o, a, u;
4565
4562
  if (this._isOnline = !0, this._isShutdown = !1, this.status = le.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (d, c, f) => {
4566
4563
  var l, p;
@@ -4591,9 +4588,9 @@ class qu {
4591
4588
  }, this.notifyQueryError = (d, c) => {
4592
4589
  (this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
4593
4590
  }, this.pushTx = (d) => {
4594
- this.config.disableValidation || mu(d, this.config.schema);
4591
+ this.config.disableValidation || wu(d, this.config.schema);
4595
4592
  try {
4596
- const c = Wa({
4593
+ const c = qa({
4597
4594
  attrs: this.optimisticAttrs(),
4598
4595
  schema: this.config.schema,
4599
4596
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4617,7 +4614,7 @@ class qu {
4617
4614
  this._updatePendingMutations((_) => {
4618
4615
  _.set(f, y);
4619
4616
  });
4620
- const b = new Nr();
4617
+ const b = new Fr();
4621
4618
  return this.mutationDeferredStore.set(f, b), this._sendMutation(f, y), this.notifyAll(), b.promise;
4622
4619
  }, this._transportOnOpen = (d) => {
4623
4620
  const c = d.target;
@@ -4678,7 +4675,7 @@ class qu {
4678
4675
  return;
4679
4676
  }
4680
4677
  this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4681
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, xu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Mu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Ru, this._log = lu(e.verbose || Gn || zi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Qn }), this.config.schema && (this._linkIndex = qr(this.config.schema)), !!Du()) {
4678
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Ru), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (a = this.config.pendingTxCleanupTimeout) !== null && a !== void 0 ? a : Iu, this._pendingMutationCleanupThreshold = (u = this.config.pendingMutationCleanupThreshold) !== null && u !== void 0 ? u : Mu, this._log = fu(e.verbose || Bn || Wi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Gn }), this.config.schema && (this._linkIndex = Kr(this.config.schema)), !!$u()) {
4682
4679
  if (!e.appId)
4683
4680
  throw new Error("Instant must be initialized with an appId.");
4684
4681
  if (!Fe(e.appId))
@@ -4693,7 +4690,7 @@ class qu {
4693
4690
  } catch (f) {
4694
4691
  this._log.error("[error] handle broadcast channel", f);
4695
4692
  }
4696
- }))), this._initStorage(n), this._syncTable = new Cu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4693
+ }))), this._initStorage(n), this._syncTable = new ju(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4697
4694
  useDateObjects: this.config.useDateObjects
4698
4695
  }, this._log, (d) => Et(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
4699
4696
  this._isOnline = d, this._startSocket(), r.listen((c) => {
@@ -4703,7 +4700,7 @@ class qu {
4703
4700
  }
4704
4701
  }
4705
4702
  updateSchema(e) {
4706
- this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? qr(this.config.schema) : null;
4703
+ this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? Kr(this.config.schema) : null;
4707
4704
  }
4708
4705
  _reactorStats() {
4709
4706
  return {
@@ -4716,11 +4713,11 @@ class qu {
4716
4713
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
4717
4714
  }
4718
4715
  _initStorage(e) {
4719
- this.querySubs = new mn({
4716
+ this.querySubs = new wn({
4720
4717
  persister: new e(this.config.appId, "querySubs"),
4721
- merge: Ku,
4722
- serialize: Lu,
4723
- parse: (n, r) => Uu(r, this.config.useDateObjects),
4718
+ merge: Nu,
4719
+ serialize: Uu,
4720
+ parse: (n, r) => Du(r, this.config.useDateObjects),
4724
4721
  // objectSize
4725
4722
  objectSize: (n) => {
4726
4723
  var r, i, s, o;
@@ -4736,11 +4733,11 @@ class qu {
4736
4733
  maxSize: 1e6
4737
4734
  // 1 million triples
4738
4735
  }
4739
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new mn({
4736
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new wn({
4740
4737
  persister: new e(this.config.appId, "kv"),
4741
4738
  merge: this._onMergeKv,
4742
- serialize: Nu,
4743
- parse: Fu,
4739
+ serialize: Fu,
4740
+ parse: Lu,
4744
4741
  objectSize: () => 0,
4745
4742
  logger: this._log,
4746
4743
  saveThrottleMs: 100,
@@ -4771,7 +4768,7 @@ class qu {
4771
4768
  if (s)
4772
4769
  i.resolve({ status: e, eventId: n });
4773
4770
  else if (r != null && r.type) {
4774
- const { status: o } = r, a = Pu(r, ["status"]);
4771
+ const { status: o } = r, a = Cu(r, ["status"]);
4775
4772
  i.reject(new Dt({
4776
4773
  // @ts-expect-error body.type is not constant typed
4777
4774
  body: a,
@@ -4795,7 +4792,7 @@ class qu {
4795
4792
  _handleReceive(e, n) {
4796
4793
  var r, i, s, o, a, u;
4797
4794
  const d = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
4798
- switch (Xr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4795
+ switch (Zr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
4799
4796
  case "init-ok": {
4800
4797
  this._setStatus(le.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
4801
4798
  for (const l of Object.keys(this._rooms)) {
@@ -4812,7 +4809,7 @@ class qu {
4812
4809
  const { q: l, result: p } = n, y = z(l);
4813
4810
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
4814
4811
  break;
4815
- const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, w = Kr(p), g = Et(this.attrs, w, d, this._linkIndex, this.config.useDateObjects);
4812
+ const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], _ = (u = (a = p == null ? void 0 : p[0]) === null || a === void 0 ? void 0 : a.data) === null || u === void 0 ? void 0 : u.aggregate, w = Nr(p), g = Et(this.attrs, w, d, this._linkIndex, this.config.useDateObjects);
4816
4813
  this.querySubs.updateInPlace((m) => {
4817
4814
  if (!m[y]) {
4818
4815
  this._log.info("Missing value in querySubs", { hash: y, q: l });
@@ -4850,9 +4847,9 @@ class qu {
4850
4847
  b !== this._pendingMutations() && this.kv.updateInPlace((g) => {
4851
4848
  g.pendingMutations = b;
4852
4849
  });
4853
- const _ = ei(b.entries()), w = l.map((g) => {
4850
+ const _ = Xr(b.entries()), w = l.map((g) => {
4854
4851
  var m, E, S, I;
4855
- const x = g["instaql-query"], B = g["instaql-result"], Ve = z(x), lt = Kr(B), Ft = Et(this.attrs, lt, d, this._linkIndex, this.config.useDateObjects), Nt = this._applyOptimisticUpdates(Ft, _, y), ht = (E = (m = B == null ? void 0 : B[0]) === null || m === void 0 ? void 0 : m.data) === null || E === void 0 ? void 0 : E["page-info"], ce = (I = (S = B == null ? void 0 : B[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
4852
+ const x = g["instaql-query"], B = g["instaql-result"], Ve = z(x), lt = Nr(B), Ft = Et(this.attrs, lt, d, this._linkIndex, this.config.useDateObjects), Nt = this._applyOptimisticUpdates(Ft, _, y), ht = (E = (m = B == null ? void 0 : B[0]) === null || m === void 0 ? void 0 : m.data) === null || E === void 0 ? void 0 : E["page-info"], ce = (I = (S = B == null ? void 0 : B[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
4856
4853
  return { q: x, hash: Ve, store: Nt, pageInfo: ht, aggregate: ce };
4857
4854
  });
4858
4855
  w.forEach(({ hash: g, q: m, store: E, pageInfo: S, aggregate: I }) => {
@@ -5015,7 +5012,7 @@ class qu {
5015
5012
  */
5016
5013
  subscribeQuery(e, n, r) {
5017
5014
  var i;
5018
- this.config.disableValidation || zr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5015
+ this.config.disableValidation || Wr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5019
5016
  const s = z(e), o = this.getPreviousResult(e);
5020
5017
  return o && n(o), this.queryCbs[s] = (i = this.queryCbs[s]) !== null && i !== void 0 ? i : [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5021
5018
  this._unsubQuery(e, s, n);
@@ -5023,14 +5020,14 @@ class qu {
5023
5020
  }
5024
5021
  queryOnce(e, n) {
5025
5022
  var r;
5026
- this.config.disableValidation || zr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5027
- const i = new Nr();
5023
+ this.config.disableValidation || Wr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5024
+ const i = new Fr();
5028
5025
  if (!this._isOnline)
5029
5026
  return i.reject(new Error("We can't run `queryOnce`, because the device is offline.")), i.promise;
5030
5027
  if (!this.querySubs)
5031
5028
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5032
5029
  const s = z(e), o = this._startQuerySub(e, s);
5033
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Iu), i.promise;
5030
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Pu), i.promise;
5034
5031
  }
5035
5032
  _completeQueryOnce(e, n, r) {
5036
5033
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5091,7 +5088,7 @@ class qu {
5091
5088
  a = !0;
5092
5089
  continue;
5093
5090
  }
5094
- const b = a ? Ta(o, p) : p;
5091
+ const b = a ? ga(o, p) : p;
5095
5092
  l.push(b);
5096
5093
  }
5097
5094
  return a ? l : c;
@@ -5101,7 +5098,7 @@ class qu {
5101
5098
  return a ? d : n;
5102
5099
  }
5103
5100
  _rewriteMutationsSorted(e, n) {
5104
- return ei(this._rewriteMutations(e, n).entries());
5101
+ return Xr(this._rewriteMutations(e, n).entries());
5105
5102
  }
5106
5103
  // ---------------------------
5107
5104
  // Transact
@@ -5134,7 +5131,7 @@ class qu {
5134
5131
  const d = this._dataForQueryCache[e];
5135
5132
  if (d && r === d.querySubVersion && s === d.pendingMutationsVersion)
5136
5133
  return d.data;
5137
- const { store: c, pageInfo: f, aggregate: l, processedTxId: p } = u, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), _ = Li({ store: b, pageInfo: f, aggregate: l }, a);
5134
+ const { store: c, pageInfo: f, aggregate: l, processedTxId: p } = u, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), _ = Ui({ store: b, pageInfo: f, aggregate: l }, a);
5138
5135
  return this._dataForQueryCache[e] = {
5139
5136
  querySubVersion: r,
5140
5137
  pendingMutationsVersion: s,
@@ -5143,7 +5140,7 @@ class qu {
5143
5140
  }
5144
5141
  _applyOptimisticUpdates(e, n, r) {
5145
5142
  for (const [i, s] of n)
5146
- (!s["tx-id"] || r && s["tx-id"] > r) && (e = wo(e, s["tx-steps"]));
5143
+ (!s["tx-id"] || r && s["tx-id"] > r) && (e = To(e, s["tx-steps"]));
5147
5144
  return e;
5148
5145
  }
5149
5146
  /** Re-compute all subscriptions */
@@ -5231,7 +5228,7 @@ class qu {
5231
5228
  }
5232
5229
  _trySend(e, n, r) {
5233
5230
  if (this._transport.isOpen()) {
5234
- switch (Xr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5231
+ switch (Zr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5235
5232
  case "transact": {
5236
5233
  this._inFlightMutationEventIds.add(e);
5237
5234
  break;
@@ -5252,7 +5249,7 @@ class qu {
5252
5249
  return;
5253
5250
  }
5254
5251
  const e = this._transport;
5255
- this._transport = $u({
5252
+ this._transport = xu({
5256
5253
  transportType: this._transportType,
5257
5254
  appId: this.config.appId,
5258
5255
  apiURI: this.config.apiURI,
@@ -5288,9 +5285,9 @@ class qu {
5288
5285
  if (typeof URL > "u")
5289
5286
  return;
5290
5287
  const e = new URL(window.location.href);
5291
- if (e.searchParams.get(en)) {
5288
+ if (e.searchParams.get(Xt)) {
5292
5289
  const n = e.toString();
5293
- e.searchParams.delete(en), e.searchParams.delete("code"), e.searchParams.delete("error");
5290
+ e.searchParams.delete(Xt), e.searchParams.delete("code"), e.searchParams.delete("error");
5294
5291
  const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
5295
5292
  if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
5296
5293
  typeof navigation == "object" && // @ts-ignore (waiting for ts support)
@@ -5315,7 +5312,7 @@ class qu {
5315
5312
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
5316
5313
  return null;
5317
5314
  const s = new URLSearchParams(window.location.search);
5318
- if (!s.get(en))
5315
+ if (!s.get(Xt))
5319
5316
  return null;
5320
5317
  const o = s.get("error");
5321
5318
  if (o)
@@ -5325,7 +5322,7 @@ class qu {
5325
5322
  return null;
5326
5323
  this._replaceUrlAfterOAuth();
5327
5324
  try {
5328
- const u = yield this._getCurrentUser(), d = (u == null ? void 0 : u.type) === "guest", { user: c } = yield Lr({
5325
+ const u = yield this._getCurrentUser(), d = (u == null ? void 0 : u.type) === "guest", { user: c } = yield Ur({
5329
5326
  apiURI: this.config.apiURI,
5330
5327
  appId: this.config.appId,
5331
5328
  code: a,
@@ -5455,7 +5452,7 @@ class qu {
5455
5452
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5456
5453
  }
5457
5454
  sendMagicCode({ email: e }) {
5458
- return Xa({
5455
+ return Za({
5459
5456
  apiURI: this.config.apiURI,
5460
5457
  appId: this.config.appId,
5461
5458
  email: e
@@ -5464,7 +5461,7 @@ class qu {
5464
5461
  signInWithMagicCode(e) {
5465
5462
  return F(this, arguments, void 0, function* ({ email: n, code: r }) {
5466
5463
  var i;
5467
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield eu({
5464
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Xa({
5468
5465
  apiURI: this.config.apiURI,
5469
5466
  appId: this.config.appId,
5470
5467
  email: n,
@@ -5476,7 +5473,7 @@ class qu {
5476
5473
  }
5477
5474
  signInWithCustomToken(e) {
5478
5475
  return F(this, void 0, void 0, function* () {
5479
- const n = yield tu({
5476
+ const n = yield eu({
5480
5477
  apiURI: this.config.apiURI,
5481
5478
  appId: this.config.appId,
5482
5479
  refreshToken: e
@@ -5486,7 +5483,7 @@ class qu {
5486
5483
  }
5487
5484
  signInAsGuest() {
5488
5485
  return F(this, void 0, void 0, function* () {
5489
- const e = yield nu({
5486
+ const e = yield tu({
5490
5487
  apiURI: this.config.apiURI,
5491
5488
  appId: this.config.appId
5492
5489
  });
@@ -5502,7 +5499,7 @@ class qu {
5502
5499
  this._log.info("[auth-invalidate] skipped invalidateToken");
5503
5500
  return;
5504
5501
  }
5505
- iu({
5502
+ ru({
5506
5503
  apiURI: this.config.apiURI,
5507
5504
  appId: this.config.appId,
5508
5505
  refreshToken: i
@@ -5537,7 +5534,7 @@ class qu {
5537
5534
  exchangeCodeForToken(e) {
5538
5535
  return F(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
5539
5536
  var i;
5540
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Lr({
5537
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", a = yield Ur({
5541
5538
  apiURI: this.config.apiURI,
5542
5539
  appId: this.config.appId,
5543
5540
  code: n,
@@ -5560,7 +5557,7 @@ class qu {
5560
5557
  signInWithIdToken(e) {
5561
5558
  return F(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5562
5559
  var s;
5563
- const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield ru({
5560
+ const o = yield this.getCurrentUser(), a = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, u = yield nu({
5564
5561
  apiURI: this.config.apiURI,
5565
5562
  appId: this.config.appId,
5566
5563
  idToken: n,
@@ -5601,7 +5598,7 @@ class qu {
5601
5598
  // TODO: look into typing again
5602
5599
  getPresence(e, n, r = {}) {
5603
5600
  const i = this._rooms[n], s = this._presence[n];
5604
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, du(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5601
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, cu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5605
5602
  }
5606
5603
  // TODO: look into typing again
5607
5604
  publishPresence(e, n, r) {
@@ -5651,7 +5648,7 @@ class qu {
5651
5648
  }
5652
5649
  _notifyPresenceSub(e, n) {
5653
5650
  const r = this.getPresence("", e, n);
5654
- r && (n.prev && !fu(r, n.prev) || (n.prev = r, n.cb(r)));
5651
+ r && (n.prev && !du(r, n.prev) || (n.prev = r, n.cb(r)));
5655
5652
  }
5656
5653
  _patchPresencePeers(e, n) {
5657
5654
  var r, i, s;
@@ -5662,13 +5659,13 @@ class qu {
5662
5659
  for (let [c, f, l] of n)
5663
5660
  switch (f) {
5664
5661
  case "+":
5665
- qs(d, c, l);
5662
+ Ks(d, c, l);
5666
5663
  break;
5667
5664
  case "r":
5668
- Er(d, c, l);
5665
+ Or(d, c, l);
5669
5666
  break;
5670
5667
  case "-":
5671
- mi(d, c);
5668
+ wi(d, c);
5672
5669
  break;
5673
5670
  }
5674
5671
  delete d[this._sessionId];
@@ -5680,7 +5677,7 @@ class qu {
5680
5677
  delete r[this._sessionId];
5681
5678
  const i = Object.fromEntries(Object.entries(r).map(([s, o]) => [s, o.data]));
5682
5679
  this._presence = Pt(this._presence, (s) => {
5683
- Er(s, [e, "result", "peers"], i);
5680
+ Or(s, [e, "result", "peers"], i);
5684
5681
  });
5685
5682
  }
5686
5683
  // --------
@@ -5725,14 +5722,14 @@ class qu {
5725
5722
  return F(this, void 0, void 0, function* () {
5726
5723
  var i;
5727
5724
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5728
- return su(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5725
+ return iu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5729
5726
  });
5730
5727
  }
5731
5728
  deleteFile(e) {
5732
5729
  return F(this, void 0, void 0, function* () {
5733
5730
  var n;
5734
5731
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5735
- return yield ou({
5732
+ return yield su({
5736
5733
  apiURI: this.config.apiURI,
5737
5734
  appId: this.config.appId,
5738
5735
  path: e,
@@ -5745,20 +5742,20 @@ class qu {
5745
5742
  upload(e, n) {
5746
5743
  return F(this, void 0, void 0, function* () {
5747
5744
  var r;
5748
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, a = yield au({
5745
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, a = yield ou({
5749
5746
  apiURI: this.config.apiURI,
5750
5747
  appId: this.config.appId,
5751
5748
  fileName: o,
5752
5749
  refreshToken: s
5753
5750
  });
5754
- return yield uu(a, n);
5751
+ return yield au(a, n);
5755
5752
  });
5756
5753
  }
5757
5754
  getDownloadUrl(e) {
5758
5755
  return F(this, void 0, void 0, function* () {
5759
5756
  var n;
5760
5757
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5761
- return yield cu({
5758
+ return yield uu({
5762
5759
  apiURI: this.config.apiURI,
5763
5760
  appId: this.config.appId,
5764
5761
  path: e,
@@ -5767,9 +5764,9 @@ class qu {
5767
5764
  });
5768
5765
  }
5769
5766
  }
5770
- function Wu(t, e) {
5767
+ function qu(t, e) {
5771
5768
  return new Lt(
5772
- Xi(t, e),
5769
+ Zi(t, e),
5773
5770
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
5774
5771
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
5775
5772
  // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
@@ -5779,28 +5776,28 @@ function Wu(t, e) {
5779
5776
  void 0
5780
5777
  );
5781
5778
  }
5782
- function zu(t) {
5779
+ function Wu(t) {
5783
5780
  return new Ut(t, {});
5784
5781
  }
5785
- function Vu() {
5782
+ function zu() {
5786
5783
  return new H("string", !0, !1);
5787
5784
  }
5788
- function Bu() {
5785
+ function Vu() {
5789
5786
  return new H("number", !0, !1);
5790
5787
  }
5791
- function Gu() {
5788
+ function Bu() {
5792
5789
  return new H("boolean", !0, !1);
5793
5790
  }
5794
- function Qu() {
5791
+ function Gu() {
5795
5792
  return new H("date", !0, !1);
5796
5793
  }
5797
- function Hu() {
5794
+ function Qu() {
5798
5795
  return new H("json", !0, !1);
5799
5796
  }
5800
- function Yu() {
5797
+ function Hu() {
5801
5798
  return new H("json", !0, !1);
5802
5799
  }
5803
- function Xi(t, e) {
5800
+ function Zi(t, e) {
5804
5801
  var n, r, i, s;
5805
5802
  const o = { fwd: {}, rev: {} };
5806
5803
  for (const u of Object.values(e))
@@ -5816,10 +5813,10 @@ function Xi(t, e) {
5816
5813
  new Ut(d.attrs, Object.assign(Object.assign({}, o.fwd[u]), o.rev[u]))
5817
5814
  ]));
5818
5815
  }
5819
- function Ju({ entities: t, links: e, rooms: n }) {
5816
+ function Yu({ entities: t, links: e, rooms: n }) {
5820
5817
  const r = e ?? {}, i = n ?? {};
5821
5818
  return new Lt(
5822
- Xi(t, r),
5819
+ Zi(t, r),
5823
5820
  // (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
5824
5821
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
5825
5822
  // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
@@ -5829,23 +5826,23 @@ function Ju({ entities: t, links: e, rooms: n }) {
5829
5826
  i
5830
5827
  );
5831
5828
  }
5832
- const qc = {
5829
+ const Kc = {
5833
5830
  // constructs
5834
- graph: Wu,
5835
- schema: Ju,
5836
- entity: zu,
5831
+ graph: qu,
5832
+ schema: Yu,
5833
+ entity: Wu,
5837
5834
  // value types
5838
- string: Vu,
5839
- number: Bu,
5840
- boolean: Gu,
5841
- date: Qu,
5842
- json: Hu,
5843
- any: Yu
5835
+ string: zu,
5836
+ number: Vu,
5837
+ boolean: Bu,
5838
+ date: Gu,
5839
+ json: Qu,
5840
+ any: Hu
5844
5841
  };
5845
5842
  let mt;
5846
- function Zu(t, e) {
5843
+ function Ju(t, e) {
5847
5844
  mt == null || mt.dispose();
5848
- const n = ic(e), r = tc(e, a), i = ec(Xu(t));
5845
+ const n = rc(e), r = ec(e, a), i = Xu(Zu(t));
5849
5846
  function s(c) {
5850
5847
  var f;
5851
5848
  c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -5867,10 +5864,10 @@ function Zu(t, e) {
5867
5864
  }
5868
5865
  return d();
5869
5866
  }
5870
- function Xu(t) {
5871
- return `${Gn || Vi ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5867
+ function Zu(t) {
5868
+ return `${Bn || zi ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
5872
5869
  }
5873
- function ec(t) {
5870
+ function Xu(t) {
5874
5871
  const e = document.createElement("iframe");
5875
5872
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
5876
5873
  width: "100%",
@@ -5879,7 +5876,7 @@ function ec(t) {
5879
5876
  border: "none"
5880
5877
  }), { element: e };
5881
5878
  }
5882
- function tc(t, e) {
5879
+ function ec(t, e) {
5883
5880
  const n = `
5884
5881
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
5885
5882
  <rect width="512" height="512" fill="black"/>
@@ -5889,7 +5886,7 @@ function tc(t, e) {
5889
5886
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
5890
5887
  // pos
5891
5888
  position: "fixed"
5892
- }, nc(t.position)), {
5889
+ }, tc(t.position)), {
5893
5890
  height: "32px",
5894
5891
  width: "32px",
5895
5892
  // layout
@@ -5904,7 +5901,7 @@ function tc(t, e) {
5904
5901
  cursor: "pointer"
5905
5902
  })), r.addEventListener("click", e), { element: r };
5906
5903
  }
5907
- function nc(t) {
5904
+ function tc(t) {
5908
5905
  switch (t) {
5909
5906
  case "bottom-left":
5910
5907
  return { bottom: "24px", left: "24px" };
@@ -5916,7 +5913,7 @@ function nc(t) {
5916
5913
  return { top: "24px", left: "24px" };
5917
5914
  }
5918
5915
  }
5919
- function rc(t) {
5916
+ function nc(t) {
5920
5917
  switch (t) {
5921
5918
  case "bottom-left":
5922
5919
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -5928,47 +5925,47 @@ function rc(t) {
5928
5925
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
5929
5926
  }
5930
5927
  }
5931
- function ic(t) {
5928
+ function rc(t) {
5932
5929
  const e = document.createElement("div");
5933
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, rc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
5930
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, nc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
5934
5931
  function n() {
5935
5932
  return e.style.display !== "none";
5936
5933
  }
5937
5934
  return { element: e, isVisible: n };
5938
5935
  }
5939
- const sc = {
5936
+ const ic = {
5940
5937
  apiURI: "https://api.instantdb.com",
5941
5938
  websocketURI: "wss://api.instantdb.com/runtime/session"
5942
5939
  };
5943
- function oc() {
5940
+ function sc() {
5944
5941
  var t;
5945
5942
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
5946
5943
  }
5947
- function ac() {
5944
+ function oc() {
5948
5945
  var t;
5949
5946
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
5950
5947
  }
5951
- function vn(t) {
5948
+ function mn(t) {
5952
5949
  const e = t.__adminToken;
5953
5950
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
5954
5951
  }
5955
- const Sn = ac(), tn = oc();
5956
- class uc {
5952
+ const vn = oc(), en = sc();
5953
+ class ac {
5957
5954
  constructor(e) {
5958
5955
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
5959
5956
  }
5960
5957
  }
5961
- class cc {
5958
+ class uc {
5962
5959
  constructor(e) {
5963
5960
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
5964
5961
  }
5965
5962
  }
5966
- function dc(t) {
5963
+ function cc(t) {
5967
5964
  return JSON.parse(JSON.stringify(t));
5968
5965
  }
5969
- class fc {
5966
+ class dc {
5970
5967
  constructor(e) {
5971
- this.tx = Bn(), this._reactor = e, this.auth = new uc(this._reactor), this.storage = new cc(this._reactor);
5968
+ this.tx = Vn(), this._reactor = e, this.auth = new ac(this._reactor), this.storage = new uc(this._reactor);
5972
5969
  }
5973
5970
  /**
5974
5971
  * Use this to write data! You can create, update, delete, and link objects
@@ -6109,7 +6106,7 @@ class fc {
6109
6106
  };
6110
6107
  }
6111
6108
  shutdown() {
6112
- delete Sn[vn(this._reactor.config)], this._reactor.shutdown();
6109
+ delete vn[mn(this._reactor.config)], this._reactor.shutdown();
6113
6110
  }
6114
6111
  /**
6115
6112
  * Use this for one-off queries.
@@ -6142,31 +6139,31 @@ class fc {
6142
6139
  return this._reactor.subscribeTable(e, n);
6143
6140
  }
6144
6141
  }
6145
- function ti(t) {
6142
+ function ei(t) {
6146
6143
  if (!t)
6147
6144
  return "0";
6148
- if (tn.get(t))
6149
- return tn.get(t);
6145
+ if (en.get(t))
6146
+ return en.get(t);
6150
6147
  const e = z(t);
6151
- return tn.set(t, e), e;
6148
+ return en.set(t, e), e;
6152
6149
  }
6153
- function lc(t, e) {
6154
- return ti(t._reactor.config.schema) !== ti(e);
6150
+ function fc(t, e) {
6151
+ return ei(t._reactor.config.schema) !== ei(e);
6155
6152
  }
6156
- function hc(t, e, n, r, i) {
6157
- const s = Sn[vn(t)];
6153
+ function lc(t, e, n, r, i) {
6154
+ const s = vn[mn(t)];
6158
6155
  if (s)
6159
- return lc(s, t.schema) && s._reactor.updateSchema(t.schema), s;
6160
- const o = new qu(Object.assign(Object.assign(Object.assign({}, sc), t), { cardinalityInference: !!t.schema }), e || qi, n || Wi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Qn }), i), a = new fc(o);
6161
- return Sn[vn(t)] = a, pc(t.appId, t.devtool), a;
6156
+ return fc(s, t.schema) && s._reactor.updateSchema(t.schema), s;
6157
+ const o = new Ku(Object.assign(Object.assign(Object.assign({}, ic), t), { cardinalityInference: !!t.schema }), e || Ki, n || qi, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Gn }), i), a = new dc(o);
6158
+ return vn[mn(t)] = a, hc(t.appId, t.devtool), a;
6162
6159
  }
6163
- function pc(t, e) {
6160
+ function hc(t, e) {
6164
6161
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6165
6162
  return;
6166
6163
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6167
- n.allowedHosts.includes(window.location.hostname) && Zu(t, n);
6164
+ n.allowedHosts.includes(window.location.hostname) && Ju(t, n);
6168
6165
  }
6169
- var On = { exports: {} }, He = {};
6166
+ var Sn = { exports: {} }, He = {};
6170
6167
  /**
6171
6168
  * @license React
6172
6169
  * react-jsx-runtime.production.min.js
@@ -6176,11 +6173,11 @@ var On = { exports: {} }, He = {};
6176
6173
  * This source code is licensed under the MIT license found in the
6177
6174
  * LICENSE file in the root directory of this source tree.
6178
6175
  */
6179
- var ni;
6180
- function yc() {
6181
- if (ni) return He;
6182
- ni = 1;
6183
- var t = di, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
6176
+ var ti;
6177
+ function pc() {
6178
+ if (ti) return He;
6179
+ ti = 1;
6180
+ var t = ci, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
6184
6181
  function o(a, u, d) {
6185
6182
  var c, f = {}, l = null, p = null;
6186
6183
  d !== void 0 && (l = "" + d), u.key !== void 0 && (l = "" + u.key), u.ref !== void 0 && (p = u.ref);
@@ -6190,10 +6187,10 @@ function yc() {
6190
6187
  }
6191
6188
  return He.Fragment = n, He.jsx = o, He.jsxs = o, He;
6192
6189
  }
6193
- var Ye = {}, ri;
6194
- function bc() {
6195
- if (ri) return Ye;
6196
- ri = 1;
6190
+ var Ye = {}, ni;
6191
+ function yc() {
6192
+ if (ni) return Ye;
6193
+ ni = 1;
6197
6194
  var t = {};
6198
6195
  /**
6199
6196
  * @license React
@@ -6205,7 +6202,7 @@ function bc() {
6205
6202
  * LICENSE file in the root directory of this source tree.
6206
6203
  */
6207
6204
  return t.NODE_ENV !== "production" && function() {
6208
- var e = di, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
6205
+ var e = ci, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), u = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, _ = "@@iterator";
6209
6206
  function w(h) {
6210
6207
  if (h === null || typeof h != "object")
6211
6208
  return null;
@@ -6294,18 +6291,18 @@ function bc() {
6294
6291
  }
6295
6292
  return null;
6296
6293
  }
6297
- var we = Object.assign, Be = 0, Jn, Zn, Xn, er, tr, nr, rr;
6298
- function ir() {
6294
+ var we = Object.assign, Be = 0, Yn, Jn, Zn, Xn, er, tr, nr;
6295
+ function rr() {
6299
6296
  }
6300
- ir.__reactDisabledLog = !0;
6301
- function ts() {
6297
+ rr.__reactDisabledLog = !0;
6298
+ function es() {
6302
6299
  {
6303
6300
  if (Be === 0) {
6304
- Jn = console.log, Zn = console.info, Xn = console.warn, er = console.error, tr = console.group, nr = console.groupCollapsed, rr = console.groupEnd;
6301
+ Yn = console.log, Jn = console.info, Zn = console.warn, Xn = console.error, er = console.group, tr = console.groupCollapsed, nr = console.groupEnd;
6305
6302
  var h = {
6306
6303
  configurable: !0,
6307
6304
  enumerable: !0,
6308
- value: ir,
6305
+ value: rr,
6309
6306
  writable: !0
6310
6307
  };
6311
6308
  Object.defineProperties(console, {
@@ -6321,7 +6318,7 @@ function bc() {
6321
6318
  Be++;
6322
6319
  }
6323
6320
  }
6324
- function ns() {
6321
+ function ts() {
6325
6322
  {
6326
6323
  if (Be--, Be === 0) {
6327
6324
  var h = {
@@ -6331,25 +6328,25 @@ function bc() {
6331
6328
  };
6332
6329
  Object.defineProperties(console, {
6333
6330
  log: we({}, h, {
6334
- value: Jn
6331
+ value: Yn
6335
6332
  }),
6336
6333
  info: we({}, h, {
6337
- value: Zn
6334
+ value: Jn
6338
6335
  }),
6339
6336
  warn: we({}, h, {
6340
- value: Xn
6337
+ value: Zn
6341
6338
  }),
6342
6339
  error: we({}, h, {
6343
- value: er
6340
+ value: Xn
6344
6341
  }),
6345
6342
  group: we({}, h, {
6346
- value: tr
6343
+ value: er
6347
6344
  }),
6348
6345
  groupCollapsed: we({}, h, {
6349
- value: nr
6346
+ value: tr
6350
6347
  }),
6351
6348
  groupEnd: we({}, h, {
6352
- value: rr
6349
+ value: nr
6353
6350
  })
6354
6351
  });
6355
6352
  }
@@ -6372,10 +6369,10 @@ function bc() {
6372
6369
  }
6373
6370
  var Wt = !1, yt;
6374
6371
  {
6375
- var rs = typeof WeakMap == "function" ? WeakMap : Map;
6376
- yt = new rs();
6372
+ var ns = typeof WeakMap == "function" ? WeakMap : Map;
6373
+ yt = new ns();
6377
6374
  }
6378
- function sr(h, T) {
6375
+ function ir(h, T) {
6379
6376
  if (!h || Wt)
6380
6377
  return "";
6381
6378
  {
@@ -6388,7 +6385,7 @@ function bc() {
6388
6385
  var P = Error.prepareStackTrace;
6389
6386
  Error.prepareStackTrace = void 0;
6390
6387
  var M;
6391
- M = Kt.current, Kt.current = null, ts();
6388
+ M = Kt.current, Kt.current = null, es();
6392
6389
  try {
6393
6390
  if (T) {
6394
6391
  var C = function() {
@@ -6441,15 +6438,15 @@ function bc() {
6441
6438
  }
6442
6439
  }
6443
6440
  } finally {
6444
- Wt = !1, Kt.current = M, ns(), Error.prepareStackTrace = P;
6441
+ Wt = !1, Kt.current = M, ts(), Error.prepareStackTrace = P;
6445
6442
  }
6446
6443
  var Ie = h ? h.displayName || h.name : "", me = Ie ? pt(Ie) : "";
6447
6444
  return typeof h == "function" && yt.set(h, me), me;
6448
6445
  }
6449
- function is(h, T, v) {
6450
- return sr(h, !1);
6446
+ function rs(h, T, v) {
6447
+ return ir(h, !1);
6451
6448
  }
6452
- function ss(h) {
6449
+ function is(h) {
6453
6450
  var T = h.prototype;
6454
6451
  return !!(T && T.isReactComponent);
6455
6452
  }
@@ -6457,7 +6454,7 @@ function bc() {
6457
6454
  if (h == null)
6458
6455
  return "";
6459
6456
  if (typeof h == "function")
6460
- return sr(h, ss(h));
6457
+ return ir(h, is(h));
6461
6458
  if (typeof h == "string")
6462
6459
  return pt(h);
6463
6460
  switch (h) {
@@ -6469,7 +6466,7 @@ function bc() {
6469
6466
  if (typeof h == "object")
6470
6467
  switch (h.$$typeof) {
6471
6468
  case d:
6472
- return is(h.render);
6469
+ return rs(h.render);
6473
6470
  case l:
6474
6471
  return bt(h.type, T, v);
6475
6472
  case p: {
@@ -6482,15 +6479,15 @@ function bc() {
6482
6479
  }
6483
6480
  return "";
6484
6481
  }
6485
- var Ge = Object.prototype.hasOwnProperty, or = {}, ar = g.ReactDebugCurrentFrame;
6482
+ var Ge = Object.prototype.hasOwnProperty, sr = {}, or = g.ReactDebugCurrentFrame;
6486
6483
  function _t(h) {
6487
6484
  if (h) {
6488
6485
  var T = h._owner, v = bt(h.type, h._source, T ? T.type : null);
6489
- ar.setExtraStackFrame(v);
6486
+ or.setExtraStackFrame(v);
6490
6487
  } else
6491
- ar.setExtraStackFrame(null);
6488
+ or.setExtraStackFrame(null);
6492
6489
  }
6493
- function os(h, T, v, O, P) {
6490
+ function ss(h, T, v, O, P) {
6494
6491
  {
6495
6492
  var M = Function.call.bind(Ge);
6496
6493
  for (var C in h)
@@ -6505,41 +6502,41 @@ function bc() {
6505
6502
  } catch (D) {
6506
6503
  k = D;
6507
6504
  }
6508
- k && !(k instanceof Error) && (_t(P), m("%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).", O || "React class", v, C, typeof k), _t(null)), k instanceof Error && !(k.message in or) && (or[k.message] = !0, _t(P), m("Failed %s type: %s", v, k.message), _t(null));
6505
+ k && !(k instanceof Error) && (_t(P), m("%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).", O || "React class", v, C, typeof k), _t(null)), k instanceof Error && !(k.message in sr) && (sr[k.message] = !0, _t(P), m("Failed %s type: %s", v, k.message), _t(null));
6509
6506
  }
6510
6507
  }
6511
6508
  }
6512
- var as = Array.isArray;
6509
+ var os = Array.isArray;
6513
6510
  function zt(h) {
6514
- return as(h);
6511
+ return os(h);
6515
6512
  }
6516
- function us(h) {
6513
+ function as(h) {
6517
6514
  {
6518
6515
  var T = typeof Symbol == "function" && Symbol.toStringTag, v = T && h[Symbol.toStringTag] || h.constructor.name || "Object";
6519
6516
  return v;
6520
6517
  }
6521
6518
  }
6522
- function cs(h) {
6519
+ function us(h) {
6523
6520
  try {
6524
- return ur(h), !1;
6521
+ return ar(h), !1;
6525
6522
  } catch {
6526
6523
  return !0;
6527
6524
  }
6528
6525
  }
6529
- function ur(h) {
6526
+ function ar(h) {
6530
6527
  return "" + h;
6531
6528
  }
6532
- function cr(h) {
6533
- if (cs(h))
6534
- return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", us(h)), ur(h);
6529
+ function ur(h) {
6530
+ if (us(h))
6531
+ return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", as(h)), ar(h);
6535
6532
  }
6536
- var dr = g.ReactCurrentOwner, ds = {
6533
+ var cr = g.ReactCurrentOwner, cs = {
6537
6534
  key: !0,
6538
6535
  ref: !0,
6539
6536
  __self: !0,
6540
6537
  __source: !0
6541
- }, fr, lr;
6542
- function fs(h) {
6538
+ }, dr, fr;
6539
+ function ds(h) {
6543
6540
  if (Ge.call(h, "ref")) {
6544
6541
  var T = Object.getOwnPropertyDescriptor(h, "ref").get;
6545
6542
  if (T && T.isReactWarning)
@@ -6547,7 +6544,7 @@ function bc() {
6547
6544
  }
6548
6545
  return h.ref !== void 0;
6549
6546
  }
6550
- function ls(h) {
6547
+ function fs(h) {
6551
6548
  if (Ge.call(h, "key")) {
6552
6549
  var T = Object.getOwnPropertyDescriptor(h, "key").get;
6553
6550
  if (T && T.isReactWarning)
@@ -6555,13 +6552,13 @@ function bc() {
6555
6552
  }
6556
6553
  return h.key !== void 0;
6557
6554
  }
6558
- function hs(h, T) {
6559
- typeof h.ref == "string" && dr.current;
6555
+ function ls(h, T) {
6556
+ typeof h.ref == "string" && cr.current;
6560
6557
  }
6561
- function ps(h, T) {
6558
+ function hs(h, T) {
6562
6559
  {
6563
6560
  var v = function() {
6564
- fr || (fr = !0, m("%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));
6561
+ dr || (dr = !0, m("%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));
6565
6562
  };
6566
6563
  v.isReactWarning = !0, Object.defineProperty(h, "key", {
6567
6564
  get: v,
@@ -6569,10 +6566,10 @@ function bc() {
6569
6566
  });
6570
6567
  }
6571
6568
  }
6572
- function ys(h, T) {
6569
+ function ps(h, T) {
6573
6570
  {
6574
6571
  var v = function() {
6575
- lr || (lr = !0, m("%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));
6572
+ fr || (fr = !0, m("%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));
6576
6573
  };
6577
6574
  v.isReactWarning = !0, Object.defineProperty(h, "ref", {
6578
6575
  get: v,
@@ -6580,7 +6577,7 @@ function bc() {
6580
6577
  });
6581
6578
  }
6582
6579
  }
6583
- var bs = function(h, T, v, O, P, M, C) {
6580
+ var ys = function(h, T, v, O, P, M, C) {
6584
6581
  var k = {
6585
6582
  // This tag allows us to uniquely identify this as a React Element
6586
6583
  $$typeof: n,
@@ -6609,12 +6606,12 @@ function bc() {
6609
6606
  value: P
6610
6607
  }), Object.freeze && (Object.freeze(k.props), Object.freeze(k)), k;
6611
6608
  };
6612
- function _s(h, T, v, O, P) {
6609
+ function bs(h, T, v, O, P) {
6613
6610
  {
6614
6611
  var M, C = {}, k = null, G = null;
6615
- v !== void 0 && (cr(v), k = "" + v), ls(T) && (cr(T.key), k = "" + T.key), fs(T) && (G = T.ref, hs(T, P));
6612
+ v !== void 0 && (ur(v), k = "" + v), fs(T) && (ur(T.key), k = "" + T.key), ds(T) && (G = T.ref, ls(T, P));
6616
6613
  for (M in T)
6617
- Ge.call(T, M) && !ds.hasOwnProperty(M) && (C[M] = T[M]);
6614
+ Ge.call(T, M) && !cs.hasOwnProperty(M) && (C[M] = T[M]);
6618
6615
  if (h && h.defaultProps) {
6619
6616
  var D = h.defaultProps;
6620
6617
  for (M in D)
@@ -6622,25 +6619,25 @@ function bc() {
6622
6619
  }
6623
6620
  if (k || G) {
6624
6621
  var L = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
6625
- k && ps(C, L), G && ys(C, L);
6622
+ k && hs(C, L), G && ps(C, L);
6626
6623
  }
6627
- return bs(h, k, G, P, O, dr.current, C);
6624
+ return ys(h, k, G, P, O, cr.current, C);
6628
6625
  }
6629
6626
  }
6630
- var Vt = g.ReactCurrentOwner, hr = g.ReactDebugCurrentFrame;
6627
+ var Vt = g.ReactCurrentOwner, lr = g.ReactDebugCurrentFrame;
6631
6628
  function Pe(h) {
6632
6629
  if (h) {
6633
6630
  var T = h._owner, v = bt(h.type, h._source, T ? T.type : null);
6634
- hr.setExtraStackFrame(v);
6631
+ lr.setExtraStackFrame(v);
6635
6632
  } else
6636
- hr.setExtraStackFrame(null);
6633
+ lr.setExtraStackFrame(null);
6637
6634
  }
6638
6635
  var Bt;
6639
6636
  Bt = !1;
6640
6637
  function Gt(h) {
6641
6638
  return typeof h == "object" && h !== null && h.$$typeof === n;
6642
6639
  }
6643
- function pr() {
6640
+ function hr() {
6644
6641
  {
6645
6642
  if (Vt.current) {
6646
6643
  var h = ce(Vt.current.type);
@@ -6652,13 +6649,13 @@ Check the render method of \`` + h + "`.";
6652
6649
  return "";
6653
6650
  }
6654
6651
  }
6655
- function gs(h) {
6652
+ function _s(h) {
6656
6653
  return "";
6657
6654
  }
6658
- var yr = {};
6659
- function Ts(h) {
6655
+ var pr = {};
6656
+ function gs(h) {
6660
6657
  {
6661
- var T = pr();
6658
+ var T = hr();
6662
6659
  if (!T) {
6663
6660
  var v = typeof h == "string" ? h : h.displayName || h.name;
6664
6661
  v && (T = `
@@ -6668,27 +6665,27 @@ Check the top-level render call using <` + v + ">.");
6668
6665
  return T;
6669
6666
  }
6670
6667
  }
6671
- function br(h, T) {
6668
+ function yr(h, T) {
6672
6669
  {
6673
6670
  if (!h._store || h._store.validated || h.key != null)
6674
6671
  return;
6675
6672
  h._store.validated = !0;
6676
- var v = Ts(T);
6677
- if (yr[v])
6673
+ var v = gs(T);
6674
+ if (pr[v])
6678
6675
  return;
6679
- yr[v] = !0;
6676
+ pr[v] = !0;
6680
6677
  var O = "";
6681
6678
  h && h._owner && h._owner !== Vt.current && (O = " It was passed a child from " + ce(h._owner.type) + "."), Pe(h), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, O), Pe(null);
6682
6679
  }
6683
6680
  }
6684
- function _r(h, T) {
6681
+ function br(h, T) {
6685
6682
  {
6686
6683
  if (typeof h != "object")
6687
6684
  return;
6688
6685
  if (zt(h))
6689
6686
  for (var v = 0; v < h.length; v++) {
6690
6687
  var O = h[v];
6691
- Gt(O) && br(O, T);
6688
+ Gt(O) && yr(O, T);
6692
6689
  }
6693
6690
  else if (Gt(h))
6694
6691
  h._store && (h._store.validated = !0);
@@ -6696,11 +6693,11 @@ Check the top-level render call using <` + v + ">.");
6696
6693
  var P = w(h);
6697
6694
  if (typeof P == "function" && P !== h.entries)
6698
6695
  for (var M = P.call(h), C; !(C = M.next()).done; )
6699
- Gt(C.value) && br(C.value, T);
6696
+ Gt(C.value) && yr(C.value, T);
6700
6697
  }
6701
6698
  }
6702
6699
  }
6703
- function ws(h) {
6700
+ function Ts(h) {
6704
6701
  {
6705
6702
  var T = h.type;
6706
6703
  if (T == null || typeof T == "string")
@@ -6716,7 +6713,7 @@ Check the top-level render call using <` + v + ">.");
6716
6713
  return;
6717
6714
  if (v) {
6718
6715
  var O = ce(T);
6719
- os(v, h.props, "prop", O, h);
6716
+ ss(v, h.props, "prop", O, h);
6720
6717
  } else if (T.PropTypes !== void 0 && !Bt) {
6721
6718
  Bt = !0;
6722
6719
  var P = ce(T);
@@ -6725,7 +6722,7 @@ Check the top-level render call using <` + v + ">.");
6725
6722
  typeof T.getDefaultProps == "function" && !T.getDefaultProps.isReactClassApproved && m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
6726
6723
  }
6727
6724
  }
6728
- function ms(h) {
6725
+ function ws(h) {
6729
6726
  {
6730
6727
  for (var T = Object.keys(h.props), v = 0; v < T.length; v++) {
6731
6728
  var O = T[v];
@@ -6737,19 +6734,19 @@ Check the top-level render call using <` + v + ">.");
6737
6734
  h.ref !== null && (Pe(h), m("Invalid attribute `ref` supplied to `React.Fragment`."), Pe(null));
6738
6735
  }
6739
6736
  }
6740
- var gr = {};
6741
- function Tr(h, T, v, O, P, M) {
6737
+ var _r = {};
6738
+ function gr(h, T, v, O, P, M) {
6742
6739
  {
6743
6740
  var C = Ft(h);
6744
6741
  if (!C) {
6745
6742
  var k = "";
6746
6743
  (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && (k += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
6747
- var G = gs();
6748
- G ? k += G : k += pr();
6744
+ var G = _s();
6745
+ G ? k += G : k += hr();
6749
6746
  var D;
6750
6747
  h === null ? D = "null" : zt(h) ? D = "array" : h !== void 0 && h.$$typeof === n ? (D = "<" + (ce(h.type) || "Unknown") + " />", k = " Did you accidentally export a JSX literal instead of a component?") : D = typeof h, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", D, k);
6751
6748
  }
6752
- var L = _s(h, T, v, P, M);
6749
+ var L = bs(h, T, v, P, M);
6753
6750
  if (L == null)
6754
6751
  return L;
6755
6752
  if (C) {
@@ -6758,65 +6755,65 @@ Check the top-level render call using <` + v + ">.");
6758
6755
  if (O)
6759
6756
  if (zt(re)) {
6760
6757
  for (var Ie = 0; Ie < re.length; Ie++)
6761
- _r(re[Ie], h);
6758
+ br(re[Ie], h);
6762
6759
  Object.freeze && Object.freeze(re);
6763
6760
  } else
6764
6761
  m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
6765
6762
  else
6766
- _r(re, h);
6763
+ br(re, h);
6767
6764
  }
6768
6765
  if (Ge.call(T, "key")) {
6769
- var me = ce(h), Y = Object.keys(T).filter(function(ks) {
6770
- return ks !== "key";
6766
+ var me = ce(h), Y = Object.keys(T).filter(function(As) {
6767
+ return As !== "key";
6771
6768
  }), Qt = Y.length > 0 ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}";
6772
- if (!gr[me + Qt]) {
6773
- var As = Y.length > 0 ? "{" + Y.join(": ..., ") + ": ...}" : "{}";
6769
+ if (!_r[me + Qt]) {
6770
+ var Es = Y.length > 0 ? "{" + Y.join(": ..., ") + ": ...}" : "{}";
6774
6771
  m(`A props object containing a "key" prop is being spread into JSX:
6775
6772
  let props = %s;
6776
6773
  <%s {...props} />
6777
6774
  React keys must be passed directly to JSX without using spread:
6778
6775
  let props = %s;
6779
- <%s key={someKey} {...props} />`, Qt, me, As, me), gr[me + Qt] = !0;
6776
+ <%s key={someKey} {...props} />`, Qt, me, Es, me), _r[me + Qt] = !0;
6780
6777
  }
6781
6778
  }
6782
- return h === i ? ms(L) : ws(L), L;
6779
+ return h === i ? ws(L) : Ts(L), L;
6783
6780
  }
6784
6781
  }
6785
- function vs(h, T, v) {
6786
- return Tr(h, T, v, !0);
6782
+ function ms(h, T, v) {
6783
+ return gr(h, T, v, !0);
6787
6784
  }
6788
- function Ss(h, T, v) {
6789
- return Tr(h, T, v, !1);
6785
+ function vs(h, T, v) {
6786
+ return gr(h, T, v, !1);
6790
6787
  }
6791
- var Os = Ss, Es = vs;
6792
- Ye.Fragment = i, Ye.jsx = Os, Ye.jsxs = Es;
6788
+ var Ss = vs, Os = ms;
6789
+ Ye.Fragment = i, Ye.jsx = Ss, Ye.jsxs = Os;
6793
6790
  }(), Ye;
6794
6791
  }
6795
- var _c = {};
6796
- _c.NODE_ENV === "production" ? On.exports = yc() : On.exports = bc();
6797
- var W = On.exports;
6798
- const gc = {
6792
+ var bc = {};
6793
+ bc.NODE_ENV === "production" ? Sn.exports = pc() : Sn.exports = yc();
6794
+ var W = Sn.exports;
6795
+ const _c = {
6799
6796
  isLoading: !0,
6800
6797
  data: void 0,
6801
6798
  pageInfo: void 0,
6802
6799
  error: void 0
6803
6800
  };
6804
- function ii(t) {
6801
+ function ri(t) {
6805
6802
  return Object.assign({ isLoading: !t, data: void 0, pageInfo: void 0, error: void 0 }, t || {});
6806
6803
  }
6807
- function Tc(t, e, n) {
6804
+ function gc(t, e, n) {
6808
6805
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6809
- const r = e ? dc(e) : null, i = z(r), s = at(ii(t._reactor.getPreviousResult(r))), o = ge(
6810
- (u) => (s.current = ii(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
6806
+ const r = e ? cc(e) : null, i = z(r), s = at(ri(t._reactor.getPreviousResult(r))), o = ge(
6807
+ (u) => (s.current = ri(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (c) => {
6811
6808
  s.current = Object.assign({ isLoading: !c, data: void 0, pageInfo: void 0, error: void 0 }, c), u();
6812
6809
  }) : () => {
6813
6810
  }),
6814
6811
  // Build a new subscribe function if the query changes
6815
6812
  [i]
6816
6813
  );
6817
- return { state: rn(o, () => s.current, () => gc), query: r };
6814
+ return { state: nn(o, () => s.current, () => _c), query: r };
6818
6815
  }
6819
- function wc() {
6816
+ function Tc() {
6820
6817
  const t = at(null);
6821
6818
  ke(() => {
6822
6819
  n();
@@ -6829,14 +6826,14 @@ function wc() {
6829
6826
  }
6830
6827
  return { set: e, clear: n };
6831
6828
  }
6832
- const mc = 1e3;
6833
- function vc(t, e, n) {
6829
+ const wc = 1e3;
6830
+ function mc(t, e, n) {
6834
6831
  const r = at(n);
6835
6832
  r.current = n, ke(() => t.core._reactor.subscribeTopic(t.id, e, (s, o) => {
6836
6833
  r.current(s, o);
6837
6834
  }), [t.id, e]);
6838
6835
  }
6839
- function Sc(t, e) {
6836
+ function vc(t, e) {
6840
6837
  return ke(() => t.core._reactor.joinRoom(t.id), [t.id]), ge((r) => {
6841
6838
  t.core._reactor.publishTopic({
6842
6839
  roomType: t.type,
@@ -6846,9 +6843,9 @@ function Sc(t, e) {
6846
6843
  });
6847
6844
  }, [t.id, e]);
6848
6845
  }
6849
- function Oc(t, e = {}) {
6846
+ function Sc(t, e = {}) {
6850
6847
  var n, r;
6851
- const [i, s] = fi(() => {
6848
+ const [i, s] = di(() => {
6852
6849
  var u;
6853
6850
  return (u = t.core._reactor.getPresence(t.type, t.id, e)) !== null && u !== void 0 ? u : {
6854
6851
  peers: {},
@@ -6861,15 +6858,15 @@ function Oc(t, e = {}) {
6861
6858
  const o = ge((u) => {
6862
6859
  t.core._reactor.publishPresence(t.type, t.id, u);
6863
6860
  }, [t.type, t.id]);
6864
- return sn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
6861
+ return rn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
6865
6862
  }
6866
- function Ec(t, e, n) {
6863
+ function Oc(t, e, n) {
6867
6864
  ke(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ke(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6868
6865
  }
6869
- function Ac(t, e, n = {}) {
6870
- const r = wc(), i = Se.usePresence(t, {
6866
+ function Ec(t, e, n = {}) {
6867
+ const r = Tc(), i = Se.usePresence(t, {
6871
6868
  keys: [e]
6872
- }), s = sn(() => {
6869
+ }), s = rn(() => {
6873
6870
  var c;
6874
6871
  const f = t._core._reactor.getPresence(t.type, t.id);
6875
6872
  return n != null && n.writeOnly ? [] : Object.values((c = f == null ? void 0 : f.peers) !== null && c !== void 0 ? c : {}).filter((l) => l[e] === !0);
@@ -6877,7 +6874,7 @@ function Ac(t, e, n = {}) {
6877
6874
  var f;
6878
6875
  t.core._reactor.publishPresence(t.type, t.id, {
6879
6876
  [e]: c
6880
- }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : mc, () => {
6877
+ }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : wc, () => {
6881
6878
  t.core._reactor.publishPresence(t.type, t.id, {
6882
6879
  [e]: null
6883
6880
  });
@@ -6887,7 +6884,7 @@ function Ac(t, e, n = {}) {
6887
6884
  o(l);
6888
6885
  }, [n.stopOnEnter, o]), u = ge(() => {
6889
6886
  o(!1);
6890
- }, [o]), d = sn(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
6887
+ }, [o]), d = rn(() => ({ onKeyDown: a, onBlur: u }), [a, u]);
6891
6888
  return {
6892
6889
  active: s,
6893
6890
  setActive: o,
@@ -6895,20 +6892,20 @@ function Ac(t, e, n = {}) {
6895
6892
  };
6896
6893
  }
6897
6894
  const Se = {
6898
- useTopicEffect: vc,
6899
- usePublishTopic: Sc,
6900
- usePresence: Oc,
6901
- useSyncPresence: Ec,
6902
- useTypingIndicator: Ac
6895
+ useTopicEffect: mc,
6896
+ usePublishTopic: vc,
6897
+ usePresence: Sc,
6898
+ useSyncPresence: Oc,
6899
+ useTypingIndicator: Ec
6903
6900
  };
6904
- class kc {
6901
+ class Ac {
6905
6902
  constructor(e, n, r) {
6906
6903
  this.useTopicEffect = (i, s) => {
6907
6904
  Se.useTopicEffect(this, i, s);
6908
6905
  }, this.usePublishTopic = (i) => Se.usePublishTopic(this, i), this.usePresence = (i = {}) => Se.usePresence(this, i), this.useSyncPresence = (i, s) => Se.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => Se.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6909
6906
  }
6910
6907
  }
6911
- var jc = function(t, e, n, r) {
6908
+ var kc = function(t, e, n, r) {
6912
6909
  function i(s) {
6913
6910
  return s instanceof n ? s : new n(function(o) {
6914
6911
  o(s);
@@ -6935,26 +6932,26 @@ var jc = function(t, e, n, r) {
6935
6932
  d((r = r.apply(t, e || [])).next());
6936
6933
  });
6937
6934
  };
6938
- const Cc = {
6935
+ const jc = {
6939
6936
  isLoading: !0,
6940
6937
  user: void 0,
6941
6938
  error: void 0
6942
6939
  };
6943
- class Pc {
6940
+ class Cc {
6944
6941
  constructor(e, n) {
6945
- this.tx = Bn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6946
- const [i, s] = fi(null);
6942
+ this.tx = Vn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6943
+ const [i, s] = di(null);
6947
6944
  return ke(() => {
6948
- jc(this, void 0, void 0, function* () {
6945
+ kc(this, void 0, void 0, function* () {
6949
6946
  const a = yield this.getLocalId(r);
6950
6947
  s(a);
6951
6948
  });
6952
6949
  }, [r]), i;
6953
- }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => Tc(this.core, r, i).state, this.useAuth = () => {
6950
+ }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => gc(this.core, r, i).state, this.useAuth = () => {
6954
6951
  const r = at(this.core._reactor._currentUserCached), i = ge((o) => this.core.subscribeAuth((u) => {
6955
6952
  r.current = Object.assign({ isLoading: !1 }, u), o();
6956
6953
  }), []);
6957
- return rn(i, () => r.current, () => Cc);
6954
+ return nn(i, () => r.current, () => jc);
6958
6955
  }, this.useUser = () => {
6959
6956
  const { user: r } = this.useAuth();
6960
6957
  if (!r)
@@ -6964,7 +6961,7 @@ class Pc {
6964
6961
  const r = at(this.core._reactor.status), i = ge((o) => this.core.subscribeConnectionStatus((u) => {
6965
6962
  u !== r.current && (r.current = u, o());
6966
6963
  }), []);
6967
- return rn(
6964
+ return nn(
6968
6965
  i,
6969
6966
  () => r.current,
6970
6967
  // For SSR, always return 'connecting' as the initial state
@@ -6976,7 +6973,7 @@ class Pc {
6976
6973
  }, this.SignedOut = ({ children: r }) => {
6977
6974
  const i = this.useAuth();
6978
6975
  return i.isLoading || i.error || i.user ? null : W.jsx(W.Fragment, { children: r });
6979
- }, this.core = hc(
6976
+ }, this.core = lc(
6980
6977
  e,
6981
6978
  // @ts-expect-error because TS can't resolve subclass statics
6982
6979
  this.constructor.Storage,
@@ -7000,7 +6997,7 @@ class Pc {
7000
6997
  * const { peers } = db.rooms.usePresence(room);
7001
6998
  */
7002
6999
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7003
- return new kc(this.core, e, n);
7000
+ return new Ac(this.core, e, n);
7004
7001
  }
7005
7002
  /**
7006
7003
  * One time query for the logged in state. This is useful
@@ -7016,22 +7013,22 @@ class Pc {
7016
7013
  return this.core.getAuth();
7017
7014
  }
7018
7015
  }
7019
- class si extends Error {
7016
+ class ii extends Error {
7020
7017
  constructor(e, n) {
7021
7018
  super(e), this.name = "ParseError", this.type = n.type, this.field = n.field, this.value = n.value, this.line = n.line;
7022
7019
  }
7023
7020
  }
7024
- function nn(t) {
7021
+ function tn(t) {
7025
7022
  }
7026
- function Ic(t) {
7023
+ function Pc(t) {
7027
7024
  if (typeof t == "function")
7028
7025
  throw new TypeError(
7029
7026
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
7030
7027
  );
7031
- const { onEvent: e = nn, onError: n = nn, onRetry: r = nn, onComment: i } = t;
7028
+ const { onEvent: e = tn, onError: n = tn, onRetry: r = tn, onComment: i } = t;
7032
7029
  let s = "", o = !0, a, u = "", d = "";
7033
7030
  function c(b) {
7034
- const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [w, g] = Mc(`${s}${_}`);
7031
+ const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [w, g] = Ic(`${s}${_}`);
7035
7032
  for (const m of w)
7036
7033
  f(m);
7037
7034
  s = g, o = !1;
@@ -7067,7 +7064,7 @@ function Ic(t) {
7067
7064
  break;
7068
7065
  case "retry":
7069
7066
  /^\d+$/.test(_) ? r(parseInt(_, 10)) : n(
7070
- new si(`Invalid \`retry\` value: "${_}"`, {
7067
+ new ii(`Invalid \`retry\` value: "${_}"`, {
7071
7068
  type: "invalid-retry",
7072
7069
  value: _,
7073
7070
  line: w
@@ -7076,7 +7073,7 @@ function Ic(t) {
7076
7073
  break;
7077
7074
  default:
7078
7075
  n(
7079
- new si(
7076
+ new ii(
7080
7077
  `Unknown field "${b.length > 20 ? `${b.slice(0, 20)}…` : b}"`,
7081
7078
  { type: "unknown-field", field: b, value: _, line: w }
7082
7079
  )
@@ -7099,7 +7096,7 @@ function Ic(t) {
7099
7096
  }
7100
7097
  return { feed: c, reset: y };
7101
7098
  }
7102
- function Mc(t) {
7099
+ function Ic(t) {
7103
7100
  const e = [];
7104
7101
  let n = "", r = 0;
7105
7102
  for (; r < t.length; ) {
@@ -7117,7 +7114,7 @@ function Mc(t) {
7117
7114
  }
7118
7115
  return [e, n];
7119
7116
  }
7120
- class oi extends Event {
7117
+ class si extends Event {
7121
7118
  /**
7122
7119
  * Constructs a new `ErrorEvent` instance. This is typically not called directly,
7123
7120
  * but rather emitted by the `EventSource` object when an error occurs.
@@ -7142,7 +7139,7 @@ class oi extends Event {
7142
7139
  * @returns A string representation of the error
7143
7140
  */
7144
7141
  [Symbol.for("nodejs.util.inspect.custom")](e, n, r) {
7145
- return r(ai(this), n);
7142
+ return r(oi(this), n);
7146
7143
  }
7147
7144
  /**
7148
7145
  * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
@@ -7156,17 +7153,17 @@ class oi extends Event {
7156
7153
  * @returns A string representation of the error
7157
7154
  */
7158
7155
  [Symbol.for("Deno.customInspect")](e, n) {
7159
- return e(ai(this), n);
7156
+ return e(oi(this), n);
7160
7157
  }
7161
7158
  }
7162
- function Rc(t) {
7159
+ function Mc(t) {
7163
7160
  const e = globalThis.DOMException;
7164
7161
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7165
7162
  }
7166
- function En(t) {
7167
- return t instanceof Error ? "errors" in t && Array.isArray(t.errors) ? t.errors.map(En).join(", ") : "cause" in t && t.cause instanceof Error ? `${t}: ${En(t.cause)}` : t.message : `${t}`;
7163
+ function On(t) {
7164
+ return t instanceof Error ? "errors" in t && Array.isArray(t.errors) ? t.errors.map(On).join(", ") : "cause" in t && t.cause instanceof Error ? `${t}: ${On(t.cause)}` : t.message : `${t}`;
7168
7165
  }
7169
- function ai(t) {
7166
+ function oi(t) {
7170
7167
  return {
7171
7168
  type: t.type,
7172
7169
  message: t.message,
@@ -7176,13 +7173,13 @@ function ai(t) {
7176
7173
  timeStamp: t.timeStamp
7177
7174
  };
7178
7175
  }
7179
- var es = (t) => {
7176
+ var Xi = (t) => {
7180
7177
  throw TypeError(t);
7181
- }, Hn = (t, e, n) => e.has(t) || es("Cannot " + n), A = (t, e, n) => (Hn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), N = (t, e, n) => e.has(t) ? es("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, n), $ = (t, e, n, r) => (Hn(t, e, "write to private field"), e.set(t, n), n), he = (t, e, n) => (Hn(t, e, "access private method"), n), J, Oe, Re, At, Rt, st, De, ot, _e, xe, Le, $e, et, se, An, kn, jn, ui, Cn, Pn, tt, In, Mn;
7178
+ }, Qn = (t, e, n) => e.has(t) || Xi("Cannot " + n), A = (t, e, n) => (Qn(t, e, "read from private field"), n ? n.call(t) : e.get(t)), N = (t, e, n) => e.has(t) ? Xi("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), J, Oe, Re, At, Rt, st, De, ot, _e, xe, Le, $e, et, se, En, An, kn, ai, jn, Cn, tt, Pn, In;
7182
7179
  class kt extends EventTarget {
7183
7180
  constructor(e, n) {
7184
7181
  var r, i;
7185
- super(), N(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, N(this, J), N(this, Oe), N(this, Re), N(this, At), N(this, Rt), N(this, st), N(this, De), N(this, ot, null), N(this, _e), N(this, xe), N(this, Le, null), N(this, $e, null), N(this, et, null), N(this, kn, async (s) => {
7182
+ super(), N(this, se), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, N(this, J), N(this, Oe), N(this, Re), N(this, At), N(this, Rt), N(this, st), N(this, De), N(this, ot, null), N(this, _e), N(this, xe), N(this, Le, null), N(this, $e, null), N(this, et, null), N(this, An, async (s) => {
7186
7183
  var o;
7187
7184
  A(this, xe).reset();
7188
7185
  const { body: a, redirected: u, status: d, headers: c } = s;
@@ -7210,11 +7207,11 @@ class kt extends EventTarget {
7210
7207
  let y = !0;
7211
7208
  do {
7212
7209
  const { done: b, value: _ } = await p.read();
7213
- _ && A(this, xe).feed(l.decode(_, { stream: !b })), b && (y = !1, A(this, xe).reset(), he(this, se, In).call(this));
7210
+ _ && A(this, xe).feed(l.decode(_, { stream: !b })), b && (y = !1, A(this, xe).reset(), he(this, se, Pn).call(this));
7214
7211
  } while (y);
7212
+ }), N(this, kn, (s) => {
7213
+ $(this, _e, void 0), !(s.name === "AbortError" || s.type === "aborted") && he(this, se, Pn).call(this, On(s));
7215
7214
  }), N(this, jn, (s) => {
7216
- $(this, _e, void 0), !(s.name === "AbortError" || s.type === "aborted") && he(this, se, In).call(this, En(s));
7217
- }), N(this, Cn, (s) => {
7218
7215
  typeof s.id == "string" && $(this, ot, s.id);
7219
7216
  const o = new MessageEvent(s.event || "message", {
7220
7217
  data: s.data,
@@ -7222,25 +7219,25 @@ class kt extends EventTarget {
7222
7219
  lastEventId: s.id || ""
7223
7220
  });
7224
7221
  A(this, $e) && (!s.event || s.event === "message") && A(this, $e).call(this, o), this.dispatchEvent(o);
7225
- }), N(this, Pn, (s) => {
7222
+ }), N(this, Cn, (s) => {
7226
7223
  $(this, st, s);
7227
- }), N(this, Mn, () => {
7228
- $(this, De, void 0), A(this, J) === this.CONNECTING && he(this, se, An).call(this);
7224
+ }), N(this, In, () => {
7225
+ $(this, De, void 0), A(this, J) === this.CONNECTING && he(this, se, En).call(this);
7229
7226
  });
7230
7227
  try {
7231
7228
  if (e instanceof URL)
7232
7229
  $(this, Oe, e);
7233
7230
  else if (typeof e == "string")
7234
- $(this, Oe, new URL(e, xc()));
7231
+ $(this, Oe, new URL(e, Rc()));
7235
7232
  else
7236
7233
  throw new Error("Invalid URL");
7237
7234
  } catch {
7238
- throw Rc("An invalid or illegal string was specified");
7235
+ throw Mc("An invalid or illegal string was specified");
7239
7236
  }
7240
- $(this, xe, Ic({
7241
- onEvent: A(this, Cn),
7242
- onRetry: A(this, Pn)
7243
- })), $(this, J, this.CONNECTING), $(this, st, 3e3), $(this, Rt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, At, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), he(this, se, An).call(this);
7237
+ $(this, xe, Pc({
7238
+ onEvent: A(this, jn),
7239
+ onRetry: A(this, Cn)
7240
+ })), $(this, J, this.CONNECTING), $(this, st, 3e3), $(this, Rt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), $(this, At, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), he(this, se, En).call(this);
7244
7241
  }
7245
7242
  /**
7246
7243
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -7318,15 +7315,15 @@ J = /* @__PURE__ */ new WeakMap(), Oe = /* @__PURE__ */ new WeakMap(), Re = /* @
7318
7315
  *
7319
7316
  * @internal
7320
7317
  */
7321
- An = function() {
7322
- $(this, J, this.CONNECTING), $(this, _e, new AbortController()), A(this, Rt)(A(this, Oe), he(this, se, ui).call(this)).then(A(this, kn)).catch(A(this, jn));
7323
- }, kn = /* @__PURE__ */ new WeakMap(), jn = /* @__PURE__ */ new WeakMap(), /**
7318
+ En = function() {
7319
+ $(this, J, this.CONNECTING), $(this, _e, new AbortController()), A(this, Rt)(A(this, Oe), he(this, se, ai).call(this)).then(A(this, An)).catch(A(this, kn));
7320
+ }, An = /* @__PURE__ */ new WeakMap(), kn = /* @__PURE__ */ new WeakMap(), /**
7324
7321
  * Get request options for the `fetch()` request
7325
7322
  *
7326
7323
  * @returns The request options
7327
7324
  * @internal
7328
7325
  */
7329
- ui = function() {
7326
+ ai = function() {
7330
7327
  var t;
7331
7328
  const e = {
7332
7329
  // [spec] Let `corsAttributeState` be `Anonymous`…
@@ -7338,7 +7335,7 @@ ui = function() {
7338
7335
  signal: (t = A(this, _e)) == null ? void 0 : t.signal
7339
7336
  };
7340
7337
  return "window" in globalThis && (e.credentials = this.withCredentials ? "include" : "same-origin"), e;
7341
- }, Cn = /* @__PURE__ */ new WeakMap(), Pn = /* @__PURE__ */ new WeakMap(), /**
7338
+ }, jn = /* @__PURE__ */ new WeakMap(), Cn = /* @__PURE__ */ new WeakMap(), /**
7342
7339
  * Handles the process referred to in the EventSource specification as "failing a connection".
7343
7340
  *
7344
7341
  * @param error - The error causing the connection to fail
@@ -7348,7 +7345,7 @@ ui = function() {
7348
7345
  tt = function(t, e) {
7349
7346
  var n;
7350
7347
  A(this, J) !== this.CLOSED && $(this, J, this.CLOSED);
7351
- const r = new oi("error", { code: e, message: t });
7348
+ const r = new si("error", { code: e, message: t });
7352
7349
  (n = A(this, Le)) == null || n.call(this, r), this.dispatchEvent(r);
7353
7350
  }, /**
7354
7351
  * Schedules a reconnection attempt against the EventSource endpoint.
@@ -7357,14 +7354,14 @@ tt = function(t, e) {
7357
7354
  * @param code - The HTTP status code, if available
7358
7355
  * @internal
7359
7356
  */
7360
- In = function(t, e) {
7357
+ Pn = function(t, e) {
7361
7358
  var n;
7362
7359
  if (A(this, J) === this.CLOSED)
7363
7360
  return;
7364
7361
  $(this, J, this.CONNECTING);
7365
- const r = new oi("error", { code: e, message: t });
7366
- (n = A(this, Le)) == null || n.call(this, r), this.dispatchEvent(r), $(this, De, setTimeout(A(this, Mn), A(this, st)));
7367
- }, Mn = /* @__PURE__ */ new WeakMap(), /**
7362
+ const r = new si("error", { code: e, message: t });
7363
+ (n = A(this, Le)) == null || n.call(this, r), this.dispatchEvent(r), $(this, De, setTimeout(A(this, In), A(this, st)));
7364
+ }, In = /* @__PURE__ */ new WeakMap(), /**
7368
7365
  * ReadyState representing an EventSource currently trying to connect
7369
7366
  *
7370
7367
  * @public
@@ -7380,24 +7377,24 @@ kt.OPEN = 1, /**
7380
7377
  * @public
7381
7378
  */
7382
7379
  kt.CLOSED = 2;
7383
- function xc() {
7380
+ function Rc() {
7384
7381
  const t = "document" in globalThis ? globalThis.document : void 0;
7385
7382
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7386
7383
  }
7387
- const Yn = class Yn extends Pc {
7384
+ const Hn = class Hn extends Cc {
7388
7385
  };
7389
- Yn.EventSourceImpl = kt;
7390
- let Rn = Yn;
7391
- function $c(t) {
7392
- return new Rn(
7386
+ Hn.EventSourceImpl = kt;
7387
+ let Mn = Hn;
7388
+ function xc(t) {
7389
+ return new Mn(
7393
7390
  t,
7394
7391
  {
7395
- "@instantdb/react": Qn
7392
+ "@instantdb/react": Gn
7396
7393
  }
7397
7394
  );
7398
7395
  }
7399
- const Wc = $c;
7400
- function zc({
7396
+ const qc = xc;
7397
+ function Wc({
7401
7398
  as: t = "div",
7402
7399
  spaceId: e,
7403
7400
  room: n,
@@ -7449,7 +7446,7 @@ function zc({
7449
7446
  [c]: void 0
7450
7447
  });
7451
7448
  }
7452
- return js(
7449
+ return ks(
7453
7450
  t,
7454
7451
  {
7455
7452
  onMouseMove: y,
@@ -7468,9 +7465,9 @@ function zc({
7468
7465
  "div",
7469
7466
  {
7470
7467
  style: {
7471
- ...ci,
7472
- ...Uc,
7473
- zIndex: d !== void 0 ? d : Lc
7468
+ ...ui,
7469
+ ...Dc,
7470
+ zIndex: d !== void 0 ? d : Uc
7474
7471
  },
7475
7472
  children: Object.entries(f.peers).map(([g, m]) => {
7476
7473
  const E = m[c];
@@ -7478,7 +7475,7 @@ function zc({
7478
7475
  "div",
7479
7476
  {
7480
7477
  style: {
7481
- ...ci,
7478
+ ...ui,
7482
7479
  transform: `translate(${E.xPercent}%, ${E.yPercent}%)`,
7483
7480
  transformOrigin: "0 0",
7484
7481
  transition: "transform 100ms"
@@ -7486,7 +7483,7 @@ function zc({
7486
7483
  children: a ? a({
7487
7484
  color: E.color,
7488
7485
  presence: l.peers[g]
7489
- }) : /* @__PURE__ */ W.jsx(Dc, { ...E })
7486
+ }) : /* @__PURE__ */ W.jsx($c, { ...E })
7490
7487
  },
7491
7488
  g
7492
7489
  ) : null;
@@ -7497,7 +7494,7 @@ function zc({
7497
7494
  ]
7498
7495
  );
7499
7496
  }
7500
- function Dc({ color: t }) {
7497
+ function $c({ color: t }) {
7501
7498
  const n = t || "black";
7502
7499
  return /* @__PURE__ */ W.jsxs(
7503
7500
  "svg",
@@ -7544,27 +7541,27 @@ function Dc({ color: t }) {
7544
7541
  }
7545
7542
  );
7546
7543
  }
7547
- const ci = {
7544
+ const ui = {
7548
7545
  position: "absolute",
7549
7546
  top: 0,
7550
7547
  left: 0,
7551
7548
  bottom: 0,
7552
7549
  right: 0
7553
- }, Uc = {
7550
+ }, Dc = {
7554
7551
  overflow: "hidden",
7555
7552
  pointerEvents: "none",
7556
7553
  userSelect: "none"
7557
- }, Lc = 99999;
7554
+ }, Uc = 99999;
7558
7555
  export {
7559
- zc as Cursors,
7556
+ Wc as Cursors,
7560
7557
  Dt as InstantAPIError,
7561
- Pc as InstantReactAbstractDatabase,
7562
- Rn as InstantReactWebDatabase,
7558
+ Cc as InstantReactAbstractDatabase,
7559
+ Mn as InstantReactWebDatabase,
7563
7560
  ve as SyncTableCallbackEventType,
7564
- qc as i,
7561
+ Kc as i,
7565
7562
  K as id,
7566
- $c as init,
7567
- Wc as init_experimental,
7568
- Nc as lookup,
7569
- Kc as tx
7563
+ xc as init,
7564
+ qc as init_experimental,
7565
+ Fc as lookup,
7566
+ Nc as tx
7570
7567
  };