@instantdb/react 1.0.50 → 1.0.51-branch-optional-async-storage.29876965683.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  var $i = Object.defineProperty;
2
2
  var Di = (n, e, t) => e in n ? $i(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var p = (n, e, t) => Di(n, typeof e != "symbol" ? e + "" : e, t);
4
- import ys, { useRef as $e, useCallback as Me, useSyncExternalStore as Vt, useEffect as We, useMemo as Sn, useState as bs, createElement as Ui } from "react";
5
- function ce(n) {
6
- const e = Ut(n);
4
+ import ys, { useRef as Me, useCallback as Ie, useSyncExternalStore as wt, useEffect as We, useMemo as Sn, useState as bs, createElement as Ui } from "react";
5
+ function ue(n) {
6
+ const e = Lt(n);
7
7
  let t = 3735928559 ^ e.length, r = 1103547991 ^ e.length;
8
8
  for (let s = 0; s < e.length; s++) {
9
9
  const i = e.charCodeAt(s);
@@ -11,13 +11,13 @@ function ce(n) {
11
11
  }
12
12
  return t = Math.imul(t ^ t >>> 16, 2246822507) ^ Math.imul(r ^ r >>> 13, 3266489909), r = Math.imul(r ^ r >>> 16, 2246822507) ^ Math.imul(t ^ t >>> 13, 3266489909), `${(r >>> 0).toString(16).padStart(8, "0")}${(t >>> 0).toString(16).padStart(8, "0")}`;
13
13
  }
14
- function Ut(n) {
14
+ function Lt(n) {
15
15
  if (n && typeof n.toJSON == "function")
16
- return Ut(n.toJSON());
16
+ return Lt(n.toJSON());
17
17
  if (Array.isArray(n)) {
18
18
  let e = "[";
19
19
  for (let t = 0; t < n.length; t++)
20
- t > 0 && (e += ","), e += Ut(n[t]);
20
+ t > 0 && (e += ","), e += Lt(n[t]);
21
21
  return e + "]";
22
22
  }
23
23
  if (n && typeof n == "object") {
@@ -26,7 +26,7 @@ function Ut(n) {
26
26
  let t = "{", r = !0;
27
27
  for (let s = 0; s < e.length; s++) {
28
28
  const i = e[s], o = n[i];
29
- o !== void 0 && (r || (t += ","), t += JSON.stringify(i) + ":" + Ut(o), r = !1);
29
+ o !== void 0 && (r || (t += ","), t += JSON.stringify(i) + ":" + Lt(o), r = !1);
30
30
  }
31
31
  return t + "}";
32
32
  }
@@ -77,11 +77,11 @@ const te = {
77
77
  Remove: "remove",
78
78
  Replace: "replace",
79
79
  Add: "add"
80
- }, gs = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Li = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Lt = Symbol.iterator, we = {
80
+ }, gs = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Li = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ft = Symbol.iterator, we = {
81
81
  mutable: "mutable",
82
82
  immutable: "immutable"
83
83
  }, Gn = {};
84
- function wt(n, e) {
84
+ function St(n, e) {
85
85
  return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
86
86
  }
87
87
  function Er(n, e) {
@@ -106,17 +106,17 @@ function me(n) {
106
106
  return (e = n.copy) !== null && e !== void 0 ? e : n.original;
107
107
  }
108
108
  function qe(n) {
109
- return !!D(n);
109
+ return !!L(n);
110
110
  }
111
- function D(n) {
111
+ function L(n) {
112
112
  return typeof n != "object" ? null : n == null ? void 0 : n[gs];
113
113
  }
114
114
  function Yn(n) {
115
115
  var e;
116
- const t = D(n);
116
+ const t = L(n);
117
117
  return t ? (e = t.copy) !== null && e !== void 0 ? e : t.original : n;
118
118
  }
119
- function ke(n, e) {
119
+ function Ae(n, e) {
120
120
  if (!n || typeof n != "object")
121
121
  return !1;
122
122
  let t;
@@ -124,11 +124,11 @@ function ke(n, e) {
124
124
  }
125
125
  function _s(n, e = []) {
126
126
  if (Object.hasOwnProperty.call(n, "key")) {
127
- const t = n.parent.copy, r = D(je(t, n.key));
127
+ const t = n.parent.copy, r = L(xe(t, n.key));
128
128
  if (r !== null && (r == null ? void 0 : r.original) !== n.original)
129
129
  return null;
130
130
  const s = n.parent.type === 3, i = s ? Array.from(n.parent.setMap.keys()).indexOf(n.key) : n.key;
131
- if (!(s && t.size > i || wt(t, i)))
131
+ if (!(s && t.size > i || St(t, i)))
132
132
  return null;
133
133
  e.push(i);
134
134
  }
@@ -145,17 +145,17 @@ function _s(n, e = []) {
145
145
  function ze(n) {
146
146
  return Array.isArray(n) ? 1 : n instanceof Map ? 2 : n instanceof Set ? 3 : 0;
147
147
  }
148
- function je(n, e) {
148
+ function xe(n, e) {
149
149
  return ze(n) === 2 ? n.get(e) : n[e];
150
150
  }
151
- function Ot(n, e, t) {
151
+ function At(n, e, t) {
152
152
  ze(n) === 2 ? n.set(e, t) : n[e] = t;
153
153
  }
154
154
  function fn(n, e) {
155
- const t = D(n);
155
+ const t = L(n);
156
156
  return (t ? me(t) : n)[e];
157
157
  }
158
- function Re(n, e) {
158
+ function je(n, e) {
159
159
  return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
160
160
  }
161
161
  function Tn(n) {
@@ -172,7 +172,7 @@ function Ne(n, e) {
172
172
  function Fi(n, e) {
173
173
  for (let t = 0; t < e.length - 1; t += 1) {
174
174
  const r = e[t];
175
- if (n = je(ze(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
175
+ if (n = xe(ze(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
176
176
  throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
177
177
  }
178
178
  return n;
@@ -233,7 +233,7 @@ function de(n) {
233
233
  n.copy || (n.copy = ms(n.original, n.options));
234
234
  }
235
235
  function ht(n) {
236
- if (!ke(n))
236
+ if (!Ae(n))
237
237
  return Yn(n);
238
238
  if (Array.isArray(n))
239
239
  return n.map(ht);
@@ -261,12 +261,12 @@ function ht(n) {
261
261
  e[t] = ht(n[t]);
262
262
  return e;
263
263
  }
264
- function Ft(n) {
264
+ function Nt(n) {
265
265
  return qe(n) ? ht(n) : n;
266
266
  }
267
- function Ie(n) {
267
+ function Pe(n) {
268
268
  var e;
269
- n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && Ie(n.parent));
269
+ n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && Pe(n.parent));
270
270
  }
271
271
  function Or() {
272
272
  throw new Error("Cannot modify frozen object");
@@ -331,16 +331,16 @@ function Zn(n, e) {
331
331
  n.forEach((r, s) => e(s, r, n));
332
332
  }
333
333
  function ws(n, e, t) {
334
- if (qe(n) || !ke(n, t) || e.has(n) || Object.isFrozen(n))
334
+ if (qe(n) || !Ae(n, t) || e.has(n) || Object.isFrozen(n))
335
335
  return;
336
336
  const r = n instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
337
337
  if (e.add(n), Zn(n, (i, o) => {
338
338
  var a;
339
339
  if (qe(o)) {
340
- const c = D(o);
340
+ const c = L(o);
341
341
  de(c);
342
342
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
343
- Ot(r ? s : n, i, u);
343
+ At(r ? s : n, i, u);
344
344
  } else
345
345
  ws(o, e, t);
346
346
  }), s) {
@@ -352,7 +352,7 @@ function ws(n, e, t) {
352
352
  }
353
353
  function Wi(n, e) {
354
354
  const t = n.type === 3 ? n.setMap : n.copy;
355
- n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && ws(je(t, e), n.finalities.handledSet, n.options);
355
+ n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && ws(xe(t, e), n.finalities.handledSet, n.options);
356
356
  }
357
357
  function vn(n) {
358
358
  n.type === 3 && n.copy && (n.copy.clear(), n.setMap.forEach((e) => {
@@ -369,17 +369,17 @@ function En(n, e, t, r) {
369
369
  }
370
370
  }
371
371
  function Xn(n, e, t, r) {
372
- const s = D(t);
372
+ const s = L(t);
373
373
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
374
374
  var a;
375
375
  const c = n.type === 3 ? n.setMap : n.copy;
376
- if (Re(je(c, e), t)) {
376
+ if (je(xe(c, e), t)) {
377
377
  let u = s.original;
378
- s.copy && (u = s.copy), vn(n), En(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), Ot(c, e, u);
378
+ s.copy && (u = s.copy), vn(n), En(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), At(c, e, u);
379
379
  }
380
- }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), ke(t, n.options) && n.finalities.draft.push(() => {
380
+ }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), Ae(t, n.options) && n.finalities.draft.push(() => {
381
381
  const i = n.type === 3 ? n.setMap : n.copy;
382
- Re(je(i, e), t) && Wi(n, e);
382
+ je(xe(i, e), t) && Wi(n, e);
383
383
  });
384
384
  }
385
385
  function qi(n, e, t, r, s) {
@@ -392,12 +392,12 @@ function qi(n, e, t, r, s) {
392
392
  op: te.Replace,
393
393
  path: f,
394
394
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
395
- value: Ft(c[u])
395
+ value: Nt(c[u])
396
396
  }), r.push({
397
397
  op: te.Replace,
398
398
  path: f,
399
399
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
400
- value: Ft(i[u])
400
+ value: Nt(i[u])
401
401
  });
402
402
  }
403
403
  for (let u = i.length; u < c.length; u += 1) {
@@ -406,7 +406,7 @@ function qi(n, e, t, r, s) {
406
406
  op: te.Add,
407
407
  path: f,
408
408
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
409
- value: Ft(c[u])
409
+ value: Nt(c[u])
410
410
  });
411
411
  }
412
412
  if (i.length < c.length) {
@@ -430,11 +430,11 @@ function qi(n, e, t, r, s) {
430
430
  }
431
431
  function zi({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
432
432
  t.forEach((a, c) => {
433
- const u = je(n, c), l = Ft(je(e, c)), f = a ? wt(n, c) ? te.Replace : te.Add : te.Remove;
434
- if (Re(u, l) && f === te.Replace)
433
+ const u = xe(n, c), l = Nt(xe(e, c)), f = a ? St(n, c) ? te.Replace : te.Add : te.Remove;
434
+ if (je(u, l) && f === te.Replace)
435
435
  return;
436
- const d = r.concat(c), y = Ne(d, o);
437
- s.push(f === te.Remove ? { op: f, path: y } : { op: f, path: y, value: l }), i.push(f === te.Add ? { op: te.Remove, path: y } : f === te.Remove ? { op: te.Add, path: y, value: u } : { op: te.Replace, path: y, value: u });
436
+ const d = r.concat(c), b = Ne(d, o);
437
+ s.push(f === te.Remove ? { op: f, path: b } : { op: f, path: b, value: l }), i.push(f === te.Add ? { op: te.Remove, path: b } : f === te.Remove ? { op: te.Add, path: b, value: u } : { op: te.Replace, path: b, value: u });
438
438
  });
439
439
  }
440
440
  function Vi({ original: n, copy: e }, t, r, s, i) {
@@ -469,7 +469,7 @@ function Vi({ original: n, copy: e }, t, r, s, i) {
469
469
  o += 1;
470
470
  });
471
471
  }
472
- function Et(n, e, t, r) {
472
+ function Ot(n, e, t, r) {
473
473
  const { pathAsArray: s = !0 } = n.options.enablePatches;
474
474
  switch (n.type) {
475
475
  case 0:
@@ -482,44 +482,44 @@ function Et(n, e, t, r) {
482
482
  }
483
483
  }
484
484
  const Qt = (n, e, t = !1) => {
485
- if (typeof n == "object" && n !== null && (!ke(n, e) || t))
485
+ if (typeof n == "object" && n !== null && (!Ae(n, e) || t))
486
486
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
487
487
  }, On = {
488
488
  get size() {
489
- return me(D(this)).size;
489
+ return me(L(this)).size;
490
490
  },
491
491
  has(n) {
492
- return me(D(this)).has(n);
492
+ return me(L(this)).has(n);
493
493
  },
494
494
  set(n, e) {
495
- const t = D(this), r = me(t);
496
- return (!r.has(n) || !Re(r.get(n), e)) && (de(t), Ie(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Xn(t, n, e, Et)), this;
495
+ const t = L(this), r = me(t);
496
+ return (!r.has(n) || !je(r.get(n), e)) && (de(t), Pe(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Xn(t, n, e, Ot)), this;
497
497
  },
498
498
  delete(n) {
499
499
  if (!this.has(n))
500
500
  return !1;
501
- const e = D(this);
502
- return de(e), Ie(e), e.original.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.copy.delete(n), !0;
501
+ const e = L(this);
502
+ return de(e), Pe(e), e.original.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.copy.delete(n), !0;
503
503
  },
504
504
  clear() {
505
- const n = D(this);
505
+ const n = L(this);
506
506
  if (this.size) {
507
- de(n), Ie(n), n.assignedMap = /* @__PURE__ */ new Map();
507
+ de(n), Pe(n), n.assignedMap = /* @__PURE__ */ new Map();
508
508
  for (const [e] of n.original)
509
509
  n.assignedMap.set(e, !1);
510
510
  n.copy.clear();
511
511
  }
512
512
  },
513
513
  forEach(n, e) {
514
- const t = D(this);
514
+ const t = L(this);
515
515
  me(t).forEach((r, s) => {
516
516
  n.call(e, this.get(s), s, this);
517
517
  });
518
518
  },
519
519
  get(n) {
520
520
  var e, t;
521
- const r = D(this), s = me(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, we)) === we.mutable;
522
- if (r.options.strict && Qt(s, r.options, i), i || r.finalized || !ke(s, r.options) || s !== r.original.get(n))
521
+ const r = L(this), s = me(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, we)) === we.mutable;
522
+ if (r.options.strict && Qt(s, r.options, i), i || r.finalized || !Ae(s, r.options) || s !== r.original.get(n))
523
523
  return s;
524
524
  const o = Gn.createDraft({
525
525
  original: s,
@@ -531,12 +531,12 @@ const Qt = (n, e, t = !1) => {
531
531
  return de(r), r.copy.set(n, o), o;
532
532
  },
533
533
  keys() {
534
- return me(D(this)).keys();
534
+ return me(L(this)).keys();
535
535
  },
536
536
  values() {
537
537
  const n = this.keys();
538
538
  return {
539
- [Lt]: () => this.values(),
539
+ [Ft]: () => this.values(),
540
540
  next: () => {
541
541
  const e = n.next();
542
542
  return e.done ? e : {
@@ -549,7 +549,7 @@ const Qt = (n, e, t = !1) => {
549
549
  entries() {
550
550
  const n = this.keys();
551
551
  return {
552
- [Lt]: () => this.entries(),
552
+ [Ft]: () => this.entries(),
553
553
  next: () => {
554
554
  const e = n.next();
555
555
  if (e.done)
@@ -562,18 +562,18 @@ const Qt = (n, e, t = !1) => {
562
562
  }
563
563
  };
564
564
  },
565
- [Lt]() {
565
+ [Ft]() {
566
566
  return this.entries();
567
567
  }
568
- }, Qi = Reflect.ownKeys(On), kr = (n, e, { isValuesIterator: t }) => () => {
568
+ }, Qi = Reflect.ownKeys(On), Ar = (n, e, { isValuesIterator: t }) => () => {
569
569
  var r, s;
570
570
  const i = e.next();
571
571
  if (i.done)
572
572
  return i;
573
573
  const o = i.value;
574
574
  let a = n.setMap.get(o);
575
- const c = D(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, we)) === we.mutable;
576
- if (n.options.strict && Qt(o, n.options, u), !u && !c && ke(o, n.options) && !n.finalized && n.original.has(o)) {
575
+ const c = L(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, we)) === we.mutable;
576
+ if (n.options.strict && Qt(o, n.options, u), !u && !c && Ae(o, n.options) && !n.finalized && n.original.has(o)) {
577
577
  const l = Gn.createDraft({
578
578
  original: o,
579
579
  parentDraft: n,
@@ -589,53 +589,53 @@ const Qt = (n, e, t = !1) => {
589
589
  };
590
590
  }, Bt = {
591
591
  get size() {
592
- return D(this).setMap.size;
592
+ return L(this).setMap.size;
593
593
  },
594
594
  has(n) {
595
- const e = D(this);
595
+ const e = L(this);
596
596
  if (e.setMap.has(n))
597
597
  return !0;
598
598
  de(e);
599
- const t = D(n);
599
+ const t = L(n);
600
600
  return !!(t && e.setMap.has(t.original));
601
601
  },
602
602
  add(n) {
603
- const e = D(this);
604
- return this.has(n) || (de(e), Ie(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Xn(e, n, n, Et)), this;
603
+ const e = L(this);
604
+ return this.has(n) || (de(e), Pe(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Xn(e, n, n, Ot)), this;
605
605
  },
606
606
  delete(n) {
607
607
  if (!this.has(n))
608
608
  return !1;
609
- const e = D(this);
610
- de(e), Ie(e);
611
- const t = D(n);
609
+ const e = L(this);
610
+ de(e), Pe(e);
611
+ const t = L(n);
612
612
  return t && e.setMap.has(t.original) ? (e.assignedMap.set(t.original, !1), e.setMap.delete(t.original)) : (!t && e.setMap.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.setMap.delete(n));
613
613
  },
614
614
  clear() {
615
615
  if (!this.size)
616
616
  return;
617
- const n = D(this);
618
- de(n), Ie(n);
617
+ const n = L(this);
618
+ de(n), Pe(n);
619
619
  for (const e of n.original)
620
620
  n.assignedMap.set(e, !1);
621
621
  n.setMap.clear();
622
622
  },
623
623
  values() {
624
- const n = D(this);
624
+ const n = L(this);
625
625
  de(n);
626
626
  const e = n.setMap.keys();
627
627
  return {
628
628
  [Symbol.iterator]: () => this.values(),
629
- next: kr(n, e, { isValuesIterator: !0 })
629
+ next: Ar(n, e, { isValuesIterator: !0 })
630
630
  };
631
631
  },
632
632
  entries() {
633
- const n = D(this);
633
+ const n = L(this);
634
634
  de(n);
635
635
  const e = n.setMap.keys();
636
636
  return {
637
637
  [Symbol.iterator]: () => this.entries(),
638
- next: kr(n, e, {
638
+ next: Ar(n, e, {
639
639
  isValuesIterator: !1
640
640
  })
641
641
  };
@@ -643,7 +643,7 @@ const Qt = (n, e, t = !1) => {
643
643
  keys() {
644
644
  return this.values();
645
645
  },
646
- [Lt]() {
646
+ [Ft]() {
647
647
  return this.values();
648
648
  },
649
649
  forEach(n, e) {
@@ -705,7 +705,7 @@ const Bi = Reflect.ownKeys(Bt), Ss = /* @__PURE__ */ new WeakSet(), Ts = {
705
705
  if (u)
706
706
  return u.bind(n.proxy);
707
707
  }
708
- if (!wt(a, e)) {
708
+ if (!St(a, e)) {
709
709
  const u = Er(a, e);
710
710
  return u ? "value" in u ? u.value : (
711
711
  // !case: support for getter
@@ -713,7 +713,7 @@ const Bi = Reflect.ownKeys(Bt), Ss = /* @__PURE__ */ new WeakSet(), Ts = {
713
713
  ) : void 0;
714
714
  }
715
715
  const c = a[e];
716
- if (n.options.strict && Qt(c, n.options), n.finalized || !ke(c, n.options))
716
+ if (n.options.strict && Qt(c, n.options), n.finalized || !Ae(c, n.options))
717
717
  return c;
718
718
  if (c === fn(n.original, e)) {
719
719
  if (de(n), n.copy[e] = er({
@@ -723,8 +723,8 @@ const Bi = Reflect.ownKeys(Bt), Ss = /* @__PURE__ */ new WeakSet(), Ts = {
723
723
  finalities: n.finalities,
724
724
  options: n.options
725
725
  }), typeof o == "function") {
726
- const u = D(n.copy[e]);
727
- return de(u), Ie(u), u.copy;
726
+ const u = L(n.copy[e]);
727
+ return de(u), Pe(u), u.copy;
728
728
  }
729
729
  return n.copy[e];
730
730
  }
@@ -740,8 +740,8 @@ const Bi = Reflect.ownKeys(Bt), Ss = /* @__PURE__ */ new WeakSet(), Ts = {
740
740
  const i = Er(me(n), e);
741
741
  if (i != null && i.set)
742
742
  return i.set.call(n.proxy, t), !0;
743
- const o = fn(me(n), e), a = D(o);
744
- return a && Re(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Re(t, o) && (t !== void 0 || wt(n.original, e)) || (de(n), Ie(n), wt(n.original, e) && Re(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Xn(n, e, t, Et)), !0);
743
+ const o = fn(me(n), e), a = L(o);
744
+ return a && je(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (je(t, o) && (t !== void 0 || St(n.original, e)) || (de(n), Pe(n), St(n.original, e) && je(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Xn(n, e, t, Ot)), !0);
745
745
  },
746
746
  has(n, e) {
747
747
  return e in me(n);
@@ -769,7 +769,7 @@ const Bi = Reflect.ownKeys(Bt), Ss = /* @__PURE__ */ new WeakSet(), Ts = {
769
769
  },
770
770
  deleteProperty(n, e) {
771
771
  var t;
772
- return n.type === 1 ? Ts.set.call(this, n, e, void 0, n.proxy) : (fn(n.original, e) !== void 0 || e in n.original ? (de(n), Ie(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
772
+ return n.type === 1 ? Ts.set.call(this, n, e, void 0, n.proxy) : (fn(n.original, e) !== void 0 || e in n.original ? (de(n), Pe(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
773
773
  }
774
774
  };
775
775
  function er(n) {
@@ -790,22 +790,22 @@ function er(n) {
790
790
  if (s.revoke.push(u), Ss.add(c), a.proxy = c, t) {
791
791
  const l = t;
792
792
  l.finalities.draft.push((f, d) => {
793
- var y, b;
794
- const g = D(c);
795
- let m = l.type === 3 ? l.setMap : l.copy;
796
- const T = je(m, r), _ = D(T);
797
- if (_) {
798
- let w = _.original;
799
- _.operated && (w = Yn(T)), vn(_), En(_, Et, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(w, _.original)), Ot(m, r, w);
793
+ var b, y;
794
+ const g = L(c);
795
+ let _ = l.type === 3 ? l.setMap : l.copy;
796
+ const S = xe(_, r), m = L(S);
797
+ if (m) {
798
+ let w = m.original;
799
+ m.operated && (w = Yn(S)), vn(m), En(m, Ot, f, d), l.options.enableAutoFreeze && (l.options.updatedValues = (b = l.options.updatedValues) !== null && b !== void 0 ? b : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(w, m.original)), At(_, r, w);
800
800
  }
801
- (b = g.callbacks) === null || b === void 0 || b.forEach((w) => {
801
+ (y = g.callbacks) === null || y === void 0 || y.forEach((w) => {
802
802
  w(f, d);
803
803
  });
804
804
  });
805
805
  } else {
806
- const l = D(c);
806
+ const l = L(c);
807
807
  l.finalities.draft.push((f, d) => {
808
- vn(l), En(l, Et, f, d);
808
+ vn(l), En(l, Ot, f, d);
809
809
  });
810
810
  }
811
811
  return c;
@@ -813,7 +813,7 @@ function er(n) {
813
813
  Gn.createDraft = er;
814
814
  function Gi(n, e, t, r, s) {
815
815
  var i;
816
- const o = D(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
816
+ const o = L(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
817
817
  if (o != null && o.operated)
818
818
  for (; o.finalities.draft.length > 0; )
819
819
  o.finalities.draft.pop()(t, r);
@@ -833,7 +833,7 @@ function Hi(n, e) {
833
833
  };
834
834
  let s, i;
835
835
  e.enablePatches && (s = [], i = []);
836
- const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, we)) === we.mutable || !ke(n, e) ? n : er({
836
+ const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, we)) === we.mutable || !Ae(n, e) ? n : er({
837
837
  original: n,
838
838
  parentDraft: null,
839
839
  finalities: r,
@@ -847,10 +847,10 @@ function Hi(n, e) {
847
847
  }
848
848
  ];
849
849
  }
850
- function kn(n) {
850
+ function An(n) {
851
851
  const { rootDraft: e, value: t, useRawReturn: r = !1, isRoot: s = !0 } = n;
852
852
  Zn(t, (i, o, a) => {
853
- const c = D(o);
853
+ const c = L(o);
854
854
  if (c && e && c.finalities === e.finalities) {
855
855
  n.isContainDraft = !0;
856
856
  const u = c.original;
@@ -858,14 +858,14 @@ function kn(n) {
858
858
  const l = Array.from(a);
859
859
  a.clear(), l.forEach((f) => a.add(i === f ? u : f));
860
860
  } else
861
- Ot(a, i, u);
862
- } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, kn(n));
861
+ At(a, i, u);
862
+ } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, An(n));
863
863
  }), s && (n.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."));
864
864
  }
865
865
  function vs(n) {
866
866
  var e;
867
- const t = D(n);
868
- if (!ke(n, t == null ? void 0 : t.options))
867
+ const t = L(n);
868
+ if (!Ae(n, t == null ? void 0 : t.options))
869
869
  return n;
870
870
  const r = ze(n);
871
871
  if (t && !t.operated)
@@ -884,17 +884,17 @@ function vs(n) {
884
884
  } else
885
885
  s = n;
886
886
  if (Zn(s, (o, a) => {
887
- if (t && Re(je(t.original, o), a))
887
+ if (t && je(xe(t.original, o), a))
888
888
  return;
889
889
  const c = vs(a);
890
- c !== a && (s === n && i(), Ot(s, o, c));
890
+ c !== a && (s === n && i(), At(s, o, c));
891
891
  }), r === 3) {
892
892
  const o = (e = t == null ? void 0 : t.original) !== null && e !== void 0 ? e : s;
893
893
  return Hn(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
894
894
  }
895
895
  return s;
896
896
  }
897
- function Ar(n) {
897
+ function kr(n) {
898
898
  if (!qe(n))
899
899
  throw new Error(`current() is only used for Draft, parameter: ${n}`);
900
900
  return vs(n);
@@ -902,72 +902,72 @@ function Ar(n) {
902
902
  const Ji = (n) => function e(t, r, s) {
903
903
  var i, o, a;
904
904
  if (typeof t == "function" && typeof r != "function")
905
- return function(v, ...U) {
906
- return e(v, (I) => t.call(this, I, ...U), r);
905
+ return function(O, ...M) {
906
+ return e(O, (I) => t.call(this, I, ...M), r);
907
907
  };
908
908
  const c = t, u = r;
909
909
  let l = s;
910
910
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
911
911
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
912
912
  l = Object.assign(Object.assign({}, n), l);
913
- const f = qe(c) ? Ar(c) : c, d = Array.isArray(l.mark) ? (v, U) => {
913
+ const f = qe(c) ? kr(c) : c, d = Array.isArray(l.mark) ? (O, M) => {
914
914
  for (const I of l.mark) {
915
915
  if (typeof I != "function")
916
916
  throw new Error(`Invalid mark: ${I}, 'mark' should be a function.`);
917
- const P = I(v, U);
918
- if (P)
919
- return P;
917
+ const R = I(O, M);
918
+ if (R)
919
+ return R;
920
920
  }
921
- } : l.mark, y = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, b = (o = l.strict) !== null && o !== void 0 ? o : !1, m = {
921
+ } : l.mark, b = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, y = (o = l.strict) !== null && o !== void 0 ? o : !1, _ = {
922
922
  enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
923
923
  mark: d,
924
- strict: b,
925
- enablePatches: y
924
+ strict: y,
925
+ enablePatches: b
926
926
  };
927
- if (!ke(f, m) && typeof f == "object" && f !== null)
927
+ if (!Ae(f, _) && typeof f == "object" && f !== null)
928
928
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
929
- const [T, _] = Hi(f, m);
929
+ const [S, m] = Hi(f, _);
930
930
  if (typeof r != "function") {
931
- if (!ke(f, m))
931
+ if (!Ae(f, _))
932
932
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
933
- return [T, _];
933
+ return [S, m];
934
934
  }
935
935
  let w;
936
936
  try {
937
- w = u(T);
938
- } catch (v) {
939
- throw Tn(D(T)), v;
940
- }
941
- const C = (v) => {
942
- const U = D(T);
943
- if (!qe(v)) {
944
- if (v !== void 0 && !Re(v, T) && (U != null && U.operated))
937
+ w = u(S);
938
+ } catch (O) {
939
+ throw Tn(L(S)), O;
940
+ }
941
+ const A = (O) => {
942
+ const M = L(S);
943
+ if (!qe(O)) {
944
+ if (O !== void 0 && !je(O, S) && (M != null && M.operated))
945
945
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
946
- const P = v == null ? void 0 : v[Li];
947
- if (P) {
948
- const H = P[0];
949
- return m.strict && typeof v == "object" && v !== null && kn({
950
- rootDraft: U,
951
- value: v,
946
+ const R = O == null ? void 0 : O[Li];
947
+ if (R) {
948
+ const H = R[0];
949
+ return _.strict && typeof O == "object" && O !== null && An({
950
+ rootDraft: M,
951
+ value: O,
952
952
  useRawReturn: !0
953
- }), _([H]);
953
+ }), m([H]);
954
954
  }
955
- if (v !== void 0)
956
- return typeof v == "object" && v !== null && kn({ rootDraft: U, value: v }), _([v]);
955
+ if (O !== void 0)
956
+ return typeof O == "object" && O !== null && An({ rootDraft: M, value: O }), m([O]);
957
957
  }
958
- if (v === T || v === void 0)
959
- return _([]);
960
- const I = D(v);
961
- if (m === I.options) {
958
+ if (O === S || O === void 0)
959
+ return m([]);
960
+ const I = L(O);
961
+ if (_ === I.options) {
962
962
  if (I.operated)
963
963
  throw new Error("Cannot return a modified child draft.");
964
- return _([Ar(v)]);
964
+ return m([kr(O)]);
965
965
  }
966
- return _([v]);
966
+ return m([O]);
967
967
  };
968
- return w instanceof Promise ? w.then(C, (v) => {
969
- throw Tn(D(T)), v;
970
- }) : C(w);
968
+ return w instanceof Promise ? w.then(A, (O) => {
969
+ throw Tn(L(S)), O;
970
+ }) : A(w);
971
971
  }, Gt = Ji();
972
972
  Object.prototype.constructor.toString();
973
973
  function Es(n, e) {
@@ -977,8 +977,8 @@ function Es(n, e) {
977
977
  function Cr(n, e) {
978
978
  return Object.keys(n).length === Object.keys(e).length && Object.keys(n).every((t) => e.hasOwnProperty(t) && n[t] === e[t]);
979
979
  }
980
- function Nt(n, e) {
981
- return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Es(n, e) ? Object.keys(n).every((t) => Nt(n[t], e[t])) : !1;
980
+ function Kt(n, e) {
981
+ return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Es(n, e) ? Object.keys(n).every((t) => Kt(n[t], e[t])) : !1;
982
982
  }
983
983
  function tr(n) {
984
984
  if (!pt(n))
@@ -1028,7 +1028,7 @@ function Ir(n, e, t) {
1028
1028
  }
1029
1029
  r[e[e.length - 1]] = t;
1030
1030
  }
1031
- function ks(n, e) {
1031
+ function As(n, e) {
1032
1032
  if (!n || e.length === 0)
1033
1033
  return;
1034
1034
  const [t, ...r] = e;
@@ -1037,7 +1037,7 @@ function ks(n, e) {
1037
1037
  Array.isArray(n) ? n.splice(t, 1) : delete n[t];
1038
1038
  return;
1039
1039
  }
1040
- ks(n[t], r), Zi(n[t]) && delete n[t];
1040
+ As(n[t], r), Zi(n[t]) && delete n[t];
1041
1041
  }
1042
1042
  }
1043
1043
  function Zi(n) {
@@ -1283,10 +1283,10 @@ function uo(n) {
1283
1283
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?(.*)$/, t = n.match(e);
1284
1284
  if (t) {
1285
1285
  const [, r, s, i, o, a, c, u, l] = t, f = s.padStart(2, "0"), d = i.padStart(2, "0");
1286
- let y = a.padStart(2, "0");
1287
- c !== void 0 && (y += `:${c.padStart(2, "0")}`), u !== void 0 && (y += `:${u.padStart(2, "0")}`);
1288
- const b = `${r}-${f}-${d}T${y}${l}`;
1289
- return new Date(b);
1286
+ let b = a.padStart(2, "0");
1287
+ c !== void 0 && (b += `:${c.padStart(2, "0")}`), u !== void 0 && (b += `:${u.padStart(2, "0")}`);
1288
+ const y = `${r}-${f}-${d}T${b}${l}`;
1289
+ return new Date(y);
1290
1290
  }
1291
1291
  return null;
1292
1292
  }
@@ -1338,7 +1338,7 @@ function yo(n, e) {
1338
1338
  return null;
1339
1339
  }
1340
1340
  }
1341
- function An(n) {
1341
+ function kn(n) {
1342
1342
  for (const e of po) {
1343
1343
  const t = yo(e, n);
1344
1344
  if (t)
@@ -1349,7 +1349,7 @@ function An(n) {
1349
1349
  function bo(n) {
1350
1350
  try {
1351
1351
  const e = JSON.parse(n);
1352
- return typeof e == "string" ? An(e) : null;
1352
+ return typeof e == "string" ? kn(e) : null;
1353
1353
  } catch {
1354
1354
  return null;
1355
1355
  }
@@ -1361,7 +1361,7 @@ function Zt(n) {
1361
1361
  if (n instanceof Date)
1362
1362
  return n;
1363
1363
  if (typeof n == "string") {
1364
- const e = An(n) || bo(n) || An(n.trim());
1364
+ const e = kn(n) || bo(n) || kn(n.trim());
1365
1365
  if (!e)
1366
1366
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1367
1367
  return e;
@@ -1477,7 +1477,7 @@ function be(n, e, t) {
1477
1477
  }
1478
1478
  s > -1 && r.set(e[s], t);
1479
1479
  }
1480
- function As(n, e, t) {
1480
+ function ks(n, e, t) {
1481
1481
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1482
1482
  for (const o of e) {
1483
1483
  let [a, c, u] = o;
@@ -1511,7 +1511,7 @@ function _o(n, e) {
1511
1511
  return at(n.eav, [e]) !== void 0;
1512
1512
  }
1513
1513
  function yt(n, e, t, r) {
1514
- const s = As(n, e, r);
1514
+ const s = ks(n, e, r);
1515
1515
  return s.cardinalityInference = t, s.useDateObjects = r, s;
1516
1516
  }
1517
1517
  function kt(n, e) {
@@ -1534,14 +1534,14 @@ function kt(n, e) {
1534
1534
  const l = (i = ge(c, 2).find((g) => g[2] === a)) == null ? void 0 : i[0];
1535
1535
  if (!l)
1536
1536
  return null;
1537
- const [f, d, y, ...b] = e;
1538
- return [t, d, l, ...b];
1537
+ const [f, d, b, ...y] = e;
1538
+ return [t, d, l, ...y];
1539
1539
  } else {
1540
1540
  const [o, ...a] = e;
1541
1541
  return [t, ...a];
1542
1542
  }
1543
1543
  }
1544
- function Ms(n, e, t) {
1544
+ function Rs(n, e, t) {
1545
1545
  const r = kt(n, t);
1546
1546
  if (!r)
1547
1547
  return;
@@ -1549,7 +1549,7 @@ function Ms(n, e, t) {
1549
1549
  a && (Oe(n.eav, [s, i, o]), Oe(n.aev, [i, s, o]), nr(a) && Oe(n.vae, [o, i, s]));
1550
1550
  }
1551
1551
  let mo = 0;
1552
- function Rs(n, e, t) {
1552
+ function Ms(n, e, t) {
1553
1553
  const [r, s, i] = t;
1554
1554
  let o;
1555
1555
  const a = at(n.eav, [r, s, i]);
@@ -1564,11 +1564,11 @@ function js(n, e, t) {
1564
1564
  if (!a)
1565
1565
  return;
1566
1566
  a["checked-data-type"] === "date" && n.useDateObjects && (o = Zt(o));
1567
- const c = at(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Rs(n, a, r), l = [s, i, o, u];
1567
+ const c = at(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Ms(n, a, r), l = [s, i, o, u];
1568
1568
  go(a) ? (be(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), be(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (be(n.eav, [s, i, o], l), be(n.aev, [i, s, o], l)), nr(a) && be(n.vae, [o, i, s], l);
1569
1569
  }
1570
1570
  function wo(n, e, t) {
1571
- var y;
1571
+ var b;
1572
1572
  const r = kt(n, t);
1573
1573
  if (!r)
1574
1574
  return;
@@ -1580,14 +1580,14 @@ function wo(n, e, t) {
1580
1580
  const c = at(n.eav, [s, i]);
1581
1581
  if (!c)
1582
1582
  return;
1583
- const u = (y = c.values().next()) == null ? void 0 : y.value;
1583
+ const u = (b = c.values().next()) == null ? void 0 : b.value;
1584
1584
  if (!u)
1585
1585
  return;
1586
1586
  const l = u[2], f = Os(l, o), d = [
1587
1587
  s,
1588
1588
  i,
1589
1589
  f,
1590
- Rs(n, a, u)
1590
+ Ms(n, a, u)
1591
1591
  ];
1592
1592
  be(n.eav, [s, i], /* @__PURE__ */ new Map([[f, d]])), be(n.aev, [i, s], /* @__PURE__ */ new Map([[f, d]]));
1593
1593
  }
@@ -1600,9 +1600,9 @@ function Cn(n, e, t) {
1600
1600
  if (a) {
1601
1601
  for (const f of a.keys()) {
1602
1602
  const d = e.getAttr(f);
1603
- d && d["on-delete-reverse"] === "cascade" && ge(a.get(f), 1).forEach(([y, b, g]) => {
1604
- var m;
1605
- return Cn(n, e, [g, (m = d["reverse-identity"]) == null ? void 0 : m[1]]);
1603
+ d && d["on-delete-reverse"] === "cascade" && ge(a.get(f), 1).forEach(([b, y, g]) => {
1604
+ var _;
1605
+ return Cn(n, e, [g, (_ = d["reverse-identity"]) == null ? void 0 : _[1]]);
1606
1606
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
1607
1607
  // the store that didn't set `etype` in deleteEntity
1608
1608
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -1613,13 +1613,13 @@ function Cn(n, e, t) {
1613
1613
  }
1614
1614
  const c = n.vae.get(o) && ge(n.vae.get(o), 2);
1615
1615
  c && c.forEach((f) => {
1616
- var m, T, _;
1617
- const [d, y, b] = f, g = e.getAttr(y);
1618
- (!s || !g || ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s) && (Oe(n.eav, [d, y, b]), Oe(n.aev, [y, d, b]), Oe(n.vae, [b, y, d])), g && g["on-delete"] === "cascade" && ((T = g["reverse-identity"]) == null ? void 0 : T[1]) === s && Cn(n, e, [d, (_ = g["forward-identity"]) == null ? void 0 : _[1]]);
1616
+ var _, S, m;
1617
+ const [d, b, y] = f, g = e.getAttr(b);
1618
+ (!s || !g || ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s) && (Oe(n.eav, [d, b, y]), Oe(n.aev, [b, d, y]), Oe(n.vae, [y, b, d])), g && g["on-delete"] === "cascade" && ((S = g["reverse-identity"]) == null ? void 0 : S[1]) === s && Cn(n, e, [d, (m = g["forward-identity"]) == null ? void 0 : m[1]]);
1619
1619
  }), ((l = n.vae.get(o)) == null ? void 0 : l.size) === 0 && Oe(n.vae, [o]);
1620
1620
  }
1621
1621
  function xs(n, e, t) {
1622
- const r = As(e, t, n.useDateObjects);
1622
+ const r = ks(e, t, n.useDateObjects);
1623
1623
  Object.keys(r).forEach((s) => {
1624
1624
  n[s] = r[s];
1625
1625
  });
@@ -1649,7 +1649,7 @@ function Eo(n, e, t) {
1649
1649
  wo(n, e, s);
1650
1650
  break;
1651
1651
  case "retract-triple":
1652
- Ms(n, e, s);
1652
+ Rs(n, e, s);
1653
1653
  break;
1654
1654
  case "delete-entity":
1655
1655
  Cn(n, e, s);
@@ -1720,7 +1720,7 @@ function Oo(n, e, t) {
1720
1720
  let r = "";
1721
1721
  return n !== void 0 && (r += "e"), e !== void 0 && (r += "a"), t !== void 0 && (r += "v"), r;
1722
1722
  }
1723
- function ko(n, [e, t, r]) {
1723
+ function Ao(n, [e, t, r]) {
1724
1724
  var i, o;
1725
1725
  switch (Oo(e, t, r)) {
1726
1726
  case "e": {
@@ -1768,7 +1768,7 @@ function ko(n, [e, t, r]) {
1768
1768
  return ge(n.eav, 3);
1769
1769
  }
1770
1770
  }
1771
- function Ao(n, e, t) {
1771
+ function ko(n, e, t) {
1772
1772
  var s;
1773
1773
  const r = {};
1774
1774
  if (!e)
@@ -1834,25 +1834,25 @@ function Po(n, e, t) {
1834
1834
  }
1835
1835
  });
1836
1836
  }
1837
- function Mo(n) {
1837
+ function Ro(n) {
1838
1838
  return typeof n == "string" && n.startsWith("?");
1839
1839
  }
1840
- function Ro(n, e, t) {
1840
+ function Mo(n, e, t) {
1841
1841
  if (t.hasOwnProperty(n)) {
1842
1842
  const r = t[n];
1843
1843
  return Us(r, e, t);
1844
1844
  }
1845
1845
  return { ...t, [n]: e };
1846
1846
  }
1847
- function Mr(n, e, t) {
1847
+ function Rr(n, e, t) {
1848
1848
  return n === e ? t : null;
1849
1849
  }
1850
1850
  function jo(n) {
1851
1851
  switch (typeof n) {
1852
1852
  case "string":
1853
- return n.startsWith("?") ? Ro : Mr;
1853
+ return n.startsWith("?") ? Mo : Rr;
1854
1854
  default:
1855
- return Mr;
1855
+ return Rr;
1856
1856
  }
1857
1857
  }
1858
1858
  const xo = [
@@ -1888,23 +1888,23 @@ function In(n, e, t = [{}]) {
1888
1888
  return e.reduce((r, s) => Lo(n, s, r), t);
1889
1889
  }
1890
1890
  function sr(n, e) {
1891
- return Array.isArray(e) ? e.map((t) => sr(n, t)) : Mo(e) ? n[e] : e;
1891
+ return Array.isArray(e) ? e.map((t) => sr(n, t)) : Ro(e) ? n[e] : e;
1892
1892
  }
1893
1893
  function Fo(n, { find: e, where: t }) {
1894
1894
  return In(n, t).map((s) => sr(s, e));
1895
1895
  }
1896
1896
  function No(n, e, t) {
1897
- return ko(n, sr(t, e));
1897
+ return Ao(n, sr(t, e));
1898
1898
  }
1899
1899
  const Ko = /^(?:[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;
1900
1900
  function it(n) {
1901
1901
  return typeof n == "string" && Ko.test(n);
1902
1902
  }
1903
- const oe = [];
1903
+ const ae = [];
1904
1904
  for (let n = 0; n < 256; ++n)
1905
- oe.push((n + 256).toString(16).slice(1));
1905
+ ae.push((n + 256).toString(16).slice(1));
1906
1906
  function Wo(n, e = 0) {
1907
- return (oe[n[e + 0]] + oe[n[e + 1]] + oe[n[e + 2]] + oe[n[e + 3]] + "-" + oe[n[e + 4]] + oe[n[e + 5]] + "-" + oe[n[e + 6]] + oe[n[e + 7]] + "-" + oe[n[e + 8]] + oe[n[e + 9]] + "-" + oe[n[e + 10]] + oe[n[e + 11]] + oe[n[e + 12]] + oe[n[e + 13]] + oe[n[e + 14]] + oe[n[e + 15]]).toLowerCase();
1907
+ return (ae[n[e + 0]] + ae[n[e + 1]] + ae[n[e + 2]] + ae[n[e + 3]] + "-" + ae[n[e + 4]] + ae[n[e + 5]] + "-" + ae[n[e + 6]] + ae[n[e + 7]] + "-" + ae[n[e + 8]] + ae[n[e + 9]] + "-" + ae[n[e + 10]] + ae[n[e + 11]] + ae[n[e + 12]] + ae[n[e + 13]] + ae[n[e + 14]] + ae[n[e + 15]]).toLowerCase();
1908
1908
  }
1909
1909
  let dn;
1910
1910
  const qo = new Uint8Array(16);
@@ -1916,11 +1916,11 @@ function zo() {
1916
1916
  }
1917
1917
  return dn(qo);
1918
1918
  }
1919
- const Vo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rr = { randomUUID: Vo };
1919
+ const Vo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Mr = { randomUUID: Vo };
1920
1920
  function Qo(n, e, t) {
1921
1921
  var s;
1922
- if (Rr.randomUUID && !n)
1923
- return Rr.randomUUID();
1922
+ if (Mr.randomUUID && !n)
1923
+ return Mr.randomUUID();
1924
1924
  n = n || {};
1925
1925
  const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? zo();
1926
1926
  if (r.length < 16)
@@ -1962,11 +1962,11 @@ function Jo() {
1962
1962
  }
1963
1963
  const Yo = Jo();
1964
1964
  let Ls = !0;
1965
- const ul = (n) => {
1965
+ const ll = (n) => {
1966
1966
  Ls = n;
1967
1967
  };
1968
1968
  let Zo = 0;
1969
- function St(n) {
1969
+ function Tt(n) {
1970
1970
  return Xt(`_${n}`, Zo++);
1971
1971
  }
1972
1972
  function Xt(n, e) {
@@ -2003,18 +2003,18 @@ function Fs(n, e, t, r, s) {
2003
2003
  throw new ot(`Could not find attr for ${[t, s]}`);
2004
2004
  if (a["value-type"] !== "ref")
2005
2005
  throw new Error(`Attr ${a.id} is not a ref`);
2006
- const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], d = r + 1, y = i ? [
2006
+ const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], d = r + 1, b = i ? [
2007
2007
  n(u, r),
2008
2008
  a.id,
2009
2009
  n(f, d),
2010
- St("time")
2010
+ Tt("time")
2011
2011
  ] : [
2012
2012
  n(u, d),
2013
2013
  a.id,
2014
2014
  n(f, r),
2015
- St("time")
2015
+ Tt("time")
2016
2016
  ];
2017
- return [i ? f : u, d, y, a, !!i];
2017
+ return [i ? f : u, d, b, a, !!i];
2018
2018
  }
2019
2019
  function $r(n, e) {
2020
2020
  if (typeof e != "string")
@@ -2098,20 +2098,20 @@ function ra(n, e, t, r, s, i) {
2098
2098
  n(t, r),
2099
2099
  u.id,
2100
2100
  { $isNull: { attrId: c.id, isNull: i.$isNull, reverse: !o } },
2101
- St("time")
2101
+ Tt("time")
2102
2102
  ];
2103
2103
  }
2104
2104
  return o ? [
2105
2105
  n(t, r),
2106
2106
  c.id,
2107
2107
  na(c, i),
2108
- St("time")
2109
- ] : [i, c.id, n(t, r), St("time")];
2108
+ Tt("time")
2109
+ ] : [i, c.id, n(t, r), Tt("time")];
2110
2110
  }
2111
2111
  function sa(n, e, t, r, s) {
2112
2112
  const [i, o, a] = s.reduce((c, u) => {
2113
- const [l, f, d] = c, [y, b, g] = Fs(n, e, l, f, u);
2114
- return [y, b, [...d, g]];
2113
+ const [l, f, d] = c, [b, y, g] = Fs(n, e, l, f, u);
2114
+ return [b, y, [...d, g]];
2115
2115
  }, [t, r, []]);
2116
2116
  return [i, o, a];
2117
2117
  }
@@ -2196,24 +2196,24 @@ function da(n, e, t, r, s, i) {
2196
2196
  function ha(n, e, t, { etype: r, level: s, form: i }, o) {
2197
2197
  const a = Object.keys(i).filter((c) => c !== "$");
2198
2198
  return a.length ? Object.entries(o).map(function([u, l]) {
2199
- return a.map(function(y) {
2200
- var g, m, T;
2201
- const b = !!(e.cardinalityInference && ((T = (m = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : m[y]) != null && T.isSingular));
2199
+ return a.map(function(b) {
2200
+ var g, _, S;
2201
+ const y = !!(e.cardinalityInference && ((S = (_ = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : _[b]) != null && S.isSingular));
2202
2202
  try {
2203
- const [_, w, C] = da(n, t, r, s, y, u), v = qs(e, t, {
2204
- etype: _,
2203
+ const [m, w, A] = da(n, t, r, s, b, u), O = qs(e, t, {
2204
+ etype: m,
2205
2205
  level: w,
2206
- form: i[y],
2207
- join: C
2208
- }), U = b ? v[0] : v;
2209
- return { [y]: U };
2210
- } catch (_) {
2211
- if (_ instanceof ot)
2212
- return { [y]: b ? void 0 : [] };
2213
- throw _;
2214
- }
2215
- }).reduce(function(y, b) {
2216
- return { ...y, ...b };
2206
+ form: i[b],
2207
+ join: A
2208
+ }), M = y ? O[0] : O;
2209
+ return { [b]: M };
2210
+ } catch (m) {
2211
+ if (m instanceof ot)
2212
+ return { [b]: y ? void 0 : [] };
2213
+ throw m;
2214
+ }
2215
+ }).reduce(function(b, y) {
2216
+ return { ...b, ...y };
2217
2217
  }, l);
2218
2218
  }) : Object.values(o);
2219
2219
  }
@@ -2226,7 +2226,7 @@ function bt(n, e, t, r, s) {
2226
2226
  function Ht([n, e], [t, r], s) {
2227
2227
  return bt(n, e, t, r, s);
2228
2228
  }
2229
- function Mn(n) {
2229
+ function Rn(n) {
2230
2230
  return n == null ? n : new Date(n).getTime();
2231
2231
  }
2232
2232
  function Ks(n, e, t) {
@@ -2234,7 +2234,7 @@ function Ks(n, e, t) {
2234
2234
  const [r, s, i, o] = n;
2235
2235
  if (((d = e["forward-identity"]) == null ? void 0 : d[2]) === "id")
2236
2236
  return Ht(t, [r, o], null);
2237
- const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? Mn(c) : c, f = u === "date" ? Mn(i) : i;
2237
+ const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? Rn(c) : c, f = u === "date" ? Rn(i) : i;
2238
2238
  return Ht([a, l], [r, f], u);
2239
2239
  }
2240
2240
  function ya(n, e, t, r) {
@@ -2275,33 +2275,33 @@ function wa(n, e, t) {
2275
2275
  return r;
2276
2276
  }
2277
2277
  function Sa(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2278
- var g, m;
2278
+ var g, _;
2279
2279
  const o = (g = i == null ? void 0 : i.$) == null ? void 0 : g.order, a = Ws(i), c = Ta(i);
2280
2280
  let u = Fo(n, s);
2281
2281
  const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], d = ma(e, t, l, o);
2282
- if (d && ((m = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : m[2]) !== "id") {
2283
- const T = d["checked-data-type"] === "date", _ = d.id;
2282
+ if (d && ((_ = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : _[2]) !== "id") {
2283
+ const S = d["checked-data-type"] === "date", m = d.id;
2284
2284
  u = u.map(([w]) => {
2285
- var v, U, I, P, H;
2286
- let C = (H = (P = (I = (U = (v = n.eav.get(w)) == null ? void 0 : v.get(_)) == null ? void 0 : U.values()) == null ? void 0 : I.next()) == null ? void 0 : P.value) == null ? void 0 : H[2];
2287
- return T && (C = Mn(C)), [w, C];
2285
+ var O, M, I, R, H;
2286
+ let A = (H = (R = (I = (M = (O = n.eav.get(w)) == null ? void 0 : O.get(m)) == null ? void 0 : M.values()) == null ? void 0 : I.next()) == null ? void 0 : R.value) == null ? void 0 : H[2];
2287
+ return S && (A = Rn(A)), [w, A];
2288
2288
  });
2289
2289
  }
2290
- u.sort(c === "asc" ? function(_, w) {
2291
- return Ht(_, w, d == null ? void 0 : d["checked-data-type"]);
2292
- } : function(_, w) {
2293
- return Ht(w, _, d == null ? void 0 : d["checked-data-type"]);
2290
+ u.sort(c === "asc" ? function(m, w) {
2291
+ return Ht(m, w, d == null ? void 0 : d["checked-data-type"]);
2292
+ } : function(m, w) {
2293
+ return Ht(w, m, d == null ? void 0 : d["checked-data-type"]);
2294
2294
  });
2295
- let y = {};
2296
- const b = wa(e, t, s);
2297
- for (const T of u) {
2298
- const [_] = T;
2299
- if (y[_] || !a && l && d && ya(l, d, c, T) || !a && f && d && ba(f, d, c, T))
2295
+ let b = {};
2296
+ const y = wa(e, t, s);
2297
+ for (const S of u) {
2298
+ const [m] = S;
2299
+ if (b[m] || !a && l && d && ya(l, d, c, S) || !a && f && d && ba(f, d, c, S))
2300
2300
  continue;
2301
- const w = Ao(n, b, _);
2302
- w && (y[_] = w);
2301
+ const w = ko(n, y, m);
2302
+ w && (b[m] = w);
2303
2303
  }
2304
- return y;
2304
+ return b;
2305
2305
  }
2306
2306
  function Ta(n) {
2307
2307
  var t;
@@ -2314,19 +2314,19 @@ function Ws(n) {
2314
2314
  return !e && !t && !r;
2315
2315
  }
2316
2316
  function va(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2317
- var d, y, b, g, m;
2317
+ var d, b, y, g, _;
2318
2318
  if (!Ws(s) && (!o || !o["start-cursor"]))
2319
2319
  return [];
2320
- const a = ia(la(e, t, r, (d = s.$) == null ? void 0 : d.where), i), c = fa(Xt, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Sa(n, e, {
2320
+ const a = ia(la(e, t, r, (d = s.$) == null ? void 0 : d.where), i), c = fa(Xt, t, r), u = (b = s.$) == null ? void 0 : b.fields, l = Sa(n, e, {
2321
2321
  etype: t,
2322
2322
  pageInfo: o,
2323
2323
  form: s,
2324
2324
  dq: { where: a, find: c, fields: u }
2325
- }), f = ((b = s.$) == null ? void 0 : b.limit) || ((g = s.$) == null ? void 0 : g.first) || ((m = s.$) == null ? void 0 : m.last);
2325
+ }), f = ((y = s.$) == null ? void 0 : y.limit) || ((g = s.$) == null ? void 0 : g.first) || ((_ = s.$) == null ? void 0 : _.last);
2326
2326
  if (f != null) {
2327
2327
  r > 0 && Ls && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2328
- const T = Object.entries(l);
2329
- return T.length <= f ? l : Object.fromEntries(T.slice(0, f));
2328
+ const S = Object.entries(l);
2329
+ return S.length <= f ? l : Object.fromEntries(S.slice(0, f));
2330
2330
  }
2331
2331
  return l;
2332
2332
  }
@@ -2365,7 +2365,7 @@ function zs({ store: n, attrsStore: e, pageInfo: t, aggregate: r }, s) {
2365
2365
  }, {}) };
2366
2366
  return t && (o.pageInfo = Oa(t)), r && (o.aggregate = r), o;
2367
2367
  }
2368
- function ka() {
2368
+ function Aa() {
2369
2369
  const e = {
2370
2370
  __etype: 1,
2371
2371
  __ops: 1,
@@ -2379,8 +2379,8 @@ function ka() {
2379
2379
  };
2380
2380
  return new Set(Object.keys(e));
2381
2381
  }
2382
- const Aa = ka();
2383
- function Kt(n, e, t) {
2382
+ const ka = Aa();
2383
+ function Wt(n, e, t) {
2384
2384
  const r = {
2385
2385
  __etype: n,
2386
2386
  __ops: t
@@ -2391,8 +2391,8 @@ function Kt(n, e, t) {
2391
2391
  return t;
2392
2392
  if (i === "__etype")
2393
2393
  return n;
2394
- if (Aa.has(i))
2395
- return (o, a) => Kt(n, e, [
2394
+ if (ka.has(i))
2395
+ return (o, a) => Wt(n, e, [
2396
2396
  ...t,
2397
2397
  a ? [i, n, e, o, a] : [i, n, e, o]
2398
2398
  ]);
@@ -2405,7 +2405,7 @@ function Ca(n, e) {
2405
2405
  function Jt(n) {
2406
2406
  return n.startsWith("lookup__");
2407
2407
  }
2408
- function Rn(n) {
2408
+ function Mn(n) {
2409
2409
  const [e, t, ...r] = n.split("__");
2410
2410
  return [t, JSON.parse(r.join("__"))];
2411
2411
  }
@@ -2415,11 +2415,11 @@ function Ia(n) {
2415
2415
  }, {
2416
2416
  get(e, t) {
2417
2417
  if (t === "lookup")
2418
- return (s, i) => Kt(n, Rn(Ca(s, i)), []);
2418
+ return (s, i) => Wt(n, Mn(Ca(s, i)), []);
2419
2419
  if (t === "__etype")
2420
2420
  return n;
2421
2421
  const r = t;
2422
- return Jt(r) ? Kt(n, Rn(r), []) : Kt(n, r, []);
2422
+ return Jt(r) ? Wt(n, Mn(r), []) : Wt(n, r, []);
2423
2423
  }
2424
2424
  });
2425
2425
  }
@@ -2430,11 +2430,11 @@ function ir() {
2430
2430
  }
2431
2431
  });
2432
2432
  }
2433
- const ll = ir();
2433
+ const fl = ir();
2434
2434
  function Pa(n) {
2435
2435
  return n.__ops;
2436
2436
  }
2437
- function Ma(n, e) {
2437
+ function Ra(n, e) {
2438
2438
  const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
2439
2439
  for (const o of e) {
2440
2440
  const a = t[o];
@@ -2453,7 +2453,7 @@ function Ma(n, e) {
2453
2453
  }
2454
2454
  return s;
2455
2455
  }
2456
- function Ra(n) {
2456
+ function Ma(n) {
2457
2457
  if (Array.isArray(n))
2458
2458
  return n;
2459
2459
  const e = Object.entries(n);
@@ -2481,7 +2481,7 @@ function xa(n, e, t) {
2481
2481
  return s;
2482
2482
  }
2483
2483
  function xn(n) {
2484
- return typeof n == "string" && !Jt(n) ? null : typeof n == "string" && Jt(n) ? Rn(n) : Ra(n);
2484
+ return typeof n == "string" && !Jt(n) ? null : typeof n == "string" && Jt(n) ? Mn(n) : Ma(n);
2485
2485
  }
2486
2486
  function _e(n, e, t) {
2487
2487
  const r = xn(t);
@@ -2580,11 +2580,11 @@ function La(n, e) {
2580
2580
  function Fa(n, e) {
2581
2581
  const { attrsStore: t } = n, [r, s, i, o] = e, a = tr(i), c = _e(t, r, s), u = Qs(n, [r, c, i, o]);
2582
2582
  return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
2583
- const y = se(t, r, f);
2584
- return y["checked-data-type"] === "date" && n.useDateObjects && (d = Zt(d)), [
2583
+ const b = se(t, r, f);
2584
+ return b["checked-data-type"] === "date" && n.useDateObjects && (d = Zt(d)), [
2585
2585
  "add-triple",
2586
2586
  c,
2587
- y.id,
2587
+ b.id,
2588
2588
  d,
2589
2589
  ...u ? [u] : []
2590
2590
  ];
@@ -2594,13 +2594,13 @@ function Na({ attrsStore: n }, [e, t]) {
2594
2594
  return [["delete-entity", _e(n, e, t), e]];
2595
2595
  }
2596
2596
  function Ka(n, e) {
2597
- const { attrsStore: t } = n, [r, s, i, o] = e, a = tr(i), c = _e(t, r, s), u = Qs(n, [r, c, i, o]), l = Object.entries(a).map(([d, y]) => {
2598
- const b = se(t, r, d);
2597
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = tr(i), c = _e(t, r, s), u = Qs(n, [r, c, i, o]), l = Object.entries(a).map(([d, b]) => {
2598
+ const y = se(t, r, d);
2599
2599
  return [
2600
2600
  "deep-merge-triple",
2601
2601
  c,
2602
- b.id,
2603
- y,
2602
+ y.id,
2603
+ b,
2604
2604
  ...u ? [u] : []
2605
2605
  ];
2606
2606
  });
@@ -2668,7 +2668,7 @@ function Qa(n, e, t) {
2668
2668
  "checked-data-type": o
2669
2669
  };
2670
2670
  }
2671
- function Rt(n, e, t, r) {
2671
+ function jt(n, e, t, r) {
2672
2672
  const s = n ? Qa(n, e, t) : null, i = Z(), a = [Z(), e, t];
2673
2673
  return {
2674
2674
  id: i,
@@ -2749,72 +2749,72 @@ function ec(n) {
2749
2749
  return e;
2750
2750
  }
2751
2751
  function tc({ attrsStore: n, schema: e }, t) {
2752
- var d, y;
2752
+ var d, b;
2753
2753
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2754
- function o(b, g) {
2755
- return se(n, b, g) || s.find((m) => m["forward-identity"][1] === b && m["forward-identity"][2] === g);
2754
+ function o(y, g) {
2755
+ return se(n, y, g) || s.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === g);
2756
2756
  }
2757
- function a(b, g) {
2758
- return Ve(n, b, g) || s.find((m) => {
2759
- var T, _;
2760
- return ((T = m["reverse-identity"]) == null ? void 0 : T[1]) === b && ((_ = m["reverse-identity"]) == null ? void 0 : _[2]) === g;
2757
+ function a(y, g) {
2758
+ return Ve(n, y, g) || s.find((_) => {
2759
+ var S, m;
2760
+ return ((S = _["reverse-identity"]) == null ? void 0 : S[1]) === y && ((m = _["reverse-identity"]) == null ? void 0 : m[2]) === g;
2761
2761
  });
2762
2762
  }
2763
- function c(b) {
2764
- s.push(b), i.push(["add-attr", b]), r.add(b.id);
2763
+ function c(y) {
2764
+ s.push(y), i.push(["add-attr", y]), r.add(y.id);
2765
2765
  }
2766
- function u(b) {
2767
- b && "isUnsynced" in b && b.isUnsynced && !r.has(b.id) && (s.push(b), i.push(["add-attr", b]), r.add(b.id));
2766
+ function u(y) {
2767
+ y && "isUnsynced" in y && y.isUnsynced && !r.has(y.id) && (s.push(y), i.push(["add-attr", y]), r.add(y.id));
2768
2768
  }
2769
- function l(b, g) {
2769
+ function l(y, g) {
2770
2770
  return g.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2771
2771
  // before assuming it's a ref lookup.
2772
- !o(b, g);
2773
- }
2774
- function f(b, g) {
2775
- const m = o(b, g), T = a(b, g);
2776
- u(m), u(T), !m && !T && c(Lr(e, b, g, Xa));
2777
- }
2778
- for (const b of t)
2779
- for (const { etype: g, lookupPair: m, linkLabel: T } of ec(b)) {
2780
- const _ = m[0];
2781
- if (T) {
2782
- f(g, T);
2783
- const w = o(g, T), C = a(g, T);
2784
- u(w), u(C);
2785
- const v = ((d = w == null ? void 0 : w["reverse-identity"]) == null ? void 0 : d[1]) || ((y = C == null ? void 0 : C["forward-identity"]) == null ? void 0 : y[1]) || T;
2786
- if (l(v, _))
2787
- f(v, jn(_));
2772
+ !o(y, g);
2773
+ }
2774
+ function f(y, g) {
2775
+ const _ = o(y, g), S = a(y, g);
2776
+ u(_), u(S), !_ && !S && c(Lr(e, y, g, Xa));
2777
+ }
2778
+ for (const y of t)
2779
+ for (const { etype: g, lookupPair: _, linkLabel: S } of ec(y)) {
2780
+ const m = _[0];
2781
+ if (S) {
2782
+ f(g, S);
2783
+ const w = o(g, S), A = a(g, S);
2784
+ u(w), u(A);
2785
+ const O = ((d = w == null ? void 0 : w["reverse-identity"]) == null ? void 0 : d[1]) || ((b = A == null ? void 0 : A["forward-identity"]) == null ? void 0 : b[1]) || S;
2786
+ if (l(O, m))
2787
+ f(O, jn(m));
2788
2788
  else {
2789
- const U = o(v, _);
2790
- U || c(Rt(e, v, _, $n)), u(U);
2789
+ const M = o(O, m);
2790
+ M || c(jt(e, O, m, $n)), u(M);
2791
2791
  }
2792
- } else if (l(g, _))
2793
- f(g, jn(_));
2792
+ } else if (l(g, m))
2793
+ f(g, jn(m));
2794
2794
  else {
2795
- const w = o(g, _);
2796
- w || c(Rt(e, g, _, $n)), u(w);
2795
+ const w = o(g, m);
2796
+ w || c(jt(e, g, m, $n)), u(w);
2797
2797
  }
2798
2798
  }
2799
- for (const b of t) {
2800
- const [g, m, T, _] = b;
2799
+ for (const y of t) {
2800
+ const [g, _, S, m] = y;
2801
2801
  if (Ha.has(g)) {
2802
- const w = o(m, "id");
2803
- u(w), w || c(Rt(e, m, "id", { "unique?": !0 }));
2804
- for (const C of Object.keys(_)) {
2805
- const v = o(m, C);
2806
- if (u(v), Ya.has(g) && (v || c(Rt(e, m, C, C === "id" ? { "unique?": !0 } : null))), Ja.has(g)) {
2807
- const U = a(m, C);
2808
- !v && !U && c(Lr(e, m, C)), u(U);
2802
+ const w = o(_, "id");
2803
+ u(w), w || c(jt(e, _, "id", { "unique?": !0 }));
2804
+ for (const A of Object.keys(m)) {
2805
+ const O = o(_, A);
2806
+ if (u(O), Ya.has(g) && (O || c(jt(e, _, A, A === "id" ? { "unique?": !0 } : null))), Ja.has(g)) {
2807
+ const M = a(_, A);
2808
+ !O && !M && c(Lr(e, _, A)), u(M);
2809
2809
  }
2810
2810
  }
2811
2811
  }
2812
2812
  }
2813
2813
  if (s.length) {
2814
- const b = { ...n.attrs };
2814
+ const y = { ...n.attrs };
2815
2815
  for (const g of s)
2816
- b[g.id] = g;
2817
- return [new Ke(b, n.linkIndex), i];
2816
+ y[g.id] = g;
2817
+ return [new Ke(y, n.linkIndex), i];
2818
2818
  }
2819
2819
  return [n, i];
2820
2820
  }
@@ -2930,10 +2930,10 @@ class Dn {
2930
2930
  _writeToStorage(e) {
2931
2931
  const t = [], r = e == null ? void 0 : e.skipGc;
2932
2932
  if (this._meta.isLoading) {
2933
- const f = new Promise((d, y) => {
2934
- setTimeout(() => this._enqueuePersist(e ? { ...e, attempts: (e.attempts || 0) + 1 } : { attempts: 1 }).then(d).catch(y), 10 + ((e == null ? void 0 : e.attempts) ?? 0) * 1e3);
2933
+ const f = new Promise((d, b) => {
2934
+ setTimeout(() => this._enqueuePersist(e ? { ...e, attempts: (e.attempts || 0) + 1 } : { attempts: 1 }).then(d).catch(b), 10 + ((e == null ? void 0 : e.attempts) ?? 0) * 1e3);
2935
2935
  });
2936
- return t.push(f), Promise.all(t).then((d) => d.reduce((y, b) => y + b, 0));
2936
+ return t.push(f), Promise.all(t).then((d) => d.reduce((b, y) => b + y, 0));
2937
2937
  }
2938
2938
  const s = this._meta.value;
2939
2939
  if (!s)
@@ -2951,12 +2951,12 @@ class Dn {
2951
2951
  if (this._loadedKeys.has(f)) {
2952
2952
  const d = this.serialize(f, this.currentValue[f]);
2953
2953
  c.push([f, d]);
2954
- const y = this._objectSize(d), b = u[f] ?? {
2954
+ const b = this._objectSize(d), y = u[f] ?? {
2955
2955
  createdAt: Date.now(),
2956
2956
  updatedAt: Date.now(),
2957
- size: y
2957
+ size: b
2958
2958
  };
2959
- b.updatedAt = Date.now(), b.size = y, u[f] = b, this._pendingSaveKeys.delete(f);
2959
+ y.updatedAt = Date.now(), y.size = b, u[f] = y, this._pendingSaveKeys.delete(f);
2960
2960
  } else
2961
2961
  a.push(f);
2962
2962
  const l = this._persister.multiSet(c);
@@ -2965,7 +2965,7 @@ class Dn {
2965
2965
  const d = this._loadKey(f).then(() => this._enqueuePersist(e));
2966
2966
  t.push(d);
2967
2967
  }
2968
- return r || this.gc(), Promise.all(t).then((f) => f.reduce((d, y) => d + y, 0));
2968
+ return r || this.gc(), Promise.all(t).then((f) => f.reduce((d, b) => d + b, 0));
2969
2969
  }
2970
2970
  async flush() {
2971
2971
  return this._nextSave ? (clearTimeout(this._nextSave), this._nextSave = null, this._writeToStorage()) : void 0;
@@ -2999,21 +2999,21 @@ class Dn {
2999
2999
  for (const d of e)
3000
3000
  t.has(d) || d in r.objects || (this._log.info("Lost track of key in meta", d), s.push(this._persister.removeItem(d)), i.removed.push(d), i.removedMissingCount++);
3001
3001
  const o = Date.now();
3002
- for (const [d, y] of Object.entries(r.objects))
3003
- !t.has(d) && y.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedOldCount++);
3002
+ for (const [d, b] of Object.entries(r.objects))
3003
+ !t.has(d) && b.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedOldCount++);
3004
3004
  const a = Object.entries(r.objects);
3005
- a.sort(([d, y], [b, g]) => y.updatedAt - g.updatedAt);
3005
+ a.sort(([d, b], [y, g]) => b.updatedAt - g.updatedAt);
3006
3006
  const c = a.filter(([d]) => !t.has(d));
3007
3007
  if (a.length > this._gcOpts.maxEntries)
3008
3008
  for (const [d] of c.slice(0, a.length - this._gcOpts.maxEntries))
3009
3009
  s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedThresholdCount++;
3010
3010
  const u = Object.entries(r.objects);
3011
- u.sort(([d, y], [b, g]) => y.updatedAt - g.updatedAt);
3011
+ u.sort(([d, b], [y, g]) => b.updatedAt - g.updatedAt);
3012
3012
  const l = u.filter(([d]) => !t.has(d));
3013
- let f = u.reduce((d, [y, b]) => d + b.size, 0);
3013
+ let f = u.reduce((d, [b, y]) => d + y.size, 0);
3014
3014
  for (; f > 0 && f > this._gcOpts.maxSize && l.length; ) {
3015
- const [[d, y]] = l.splice(0, 1);
3016
- f -= y.size, s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedSizeCount++;
3015
+ const [[d, b]] = l.splice(0, 1);
3016
+ f -= b.size, s.push(this._persister.removeItem(d)), delete r.objects[d], i.removed.push(d), i.removedSizeCount++;
3017
3017
  }
3018
3018
  for (const d of Object.keys(r.objects))
3019
3019
  !e.has(d) && !t.has(d) && delete r.objects[d];
@@ -3109,26 +3109,26 @@ async function cc(n, e, t) {
3109
3109
  return new Promise((i, o) => {
3110
3110
  var l, f, d;
3111
3111
  const a = {};
3112
- for (const [y, b] of Object.entries(r)) {
3113
- const g = typeof b == "string" ? JSON.parse(b) : b;
3112
+ for (const [b, y] of Object.entries(r)) {
3113
+ const g = typeof y == "string" ? JSON.parse(y) : y;
3114
3114
  if (g.lastAccessed) {
3115
- const T = {
3115
+ const S = {
3116
3116
  createdAt: g.lastAccessed,
3117
3117
  updatedAt: g.lastAccessed,
3118
3118
  size: ((d = (f = (l = g.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : d.length) ?? 0
3119
3119
  };
3120
- a[y] = T;
3120
+ a[b] = S;
3121
3121
  }
3122
- const m = t.put(g, y);
3123
- s.add(m);
3122
+ const _ = t.put(g, b);
3123
+ s.add(_);
3124
3124
  }
3125
3125
  const c = { objects: a }, u = t.put(c, tt);
3126
3126
  s.add(u);
3127
- for (const y of s)
3128
- y.onsuccess = () => {
3129
- s.delete(y), s.size === 0 && i();
3130
- }, y.onerror = (b) => {
3131
- o(b);
3127
+ for (const b of s)
3128
+ b.onsuccess = () => {
3129
+ s.delete(b), s.size === 0 && i();
3130
+ }, b.onerror = (y) => {
3131
+ o(y);
3132
3132
  };
3133
3133
  });
3134
3134
  }
@@ -3143,20 +3143,20 @@ async function uc(n, e) {
3143
3143
  if (!t)
3144
3144
  return;
3145
3145
  const r = await new Promise((l, f) => {
3146
- const b = t.transaction(["kv"], "readonly").objectStore("kv").openCursor();
3147
- b.onerror = (m) => {
3148
- f(m);
3146
+ const y = t.transaction(["kv"], "readonly").objectStore("kv").openCursor();
3147
+ y.onerror = (_) => {
3148
+ f(_);
3149
3149
  };
3150
3150
  const g = [];
3151
- b.onsuccess = () => {
3152
- const m = b.result;
3153
- if (m) {
3154
- const T = m.key, _ = m.value;
3155
- g.push([T, _]), m.continue();
3151
+ y.onsuccess = () => {
3152
+ const _ = y.result;
3153
+ if (_) {
3154
+ const S = _.key, m = _.value;
3155
+ g.push([S, m]), _.continue();
3156
3156
  } else
3157
3157
  l(g);
3158
- }, b.onerror = (m) => {
3159
- f(m);
3158
+ }, y.onerror = (_) => {
3159
+ f(_);
3160
3160
  };
3161
3161
  }), s = e.transaction(["kv", "querySubs"], "readwrite"), i = s.objectStore("kv"), o = s.objectStore("querySubs"), a = [], c = { objects: {} };
3162
3162
  for (const [l, f] of r)
@@ -3169,12 +3169,12 @@ async function uc(n, e) {
3169
3169
  default: {
3170
3170
  const d = Nr(l, f, i);
3171
3171
  a.push(d);
3172
- const y = {
3172
+ const b = {
3173
3173
  createdAt: Date.now(),
3174
3174
  updatedAt: Date.now(),
3175
3175
  size: 0
3176
3176
  };
3177
- c.objects[l] = y;
3177
+ c.objects[l] = b;
3178
3178
  break;
3179
3179
  }
3180
3180
  }
@@ -3298,20 +3298,20 @@ class Gs {
3298
3298
  };
3299
3299
  }
3300
3300
  }
3301
- class ue extends Error {
3301
+ class oe extends Error {
3302
3302
  constructor(t, r, s) {
3303
3303
  super(t);
3304
3304
  p(this, "hint");
3305
3305
  p(this, "traceId");
3306
3306
  this.hint = r, s && (this.traceId = s);
3307
3307
  const i = new.target.prototype;
3308
- Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, ue), this.name = "InstantError";
3308
+ Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, oe), this.name = "InstantError";
3309
3309
  }
3310
3310
  get [Symbol.toStringTag]() {
3311
3311
  return "InstantError";
3312
3312
  }
3313
3313
  }
3314
- class en extends ue {
3314
+ class en extends oe {
3315
3315
  constructor(t) {
3316
3316
  var i, o;
3317
3317
  const r = ((i = t.body) == null ? void 0 : i.message) || `API Error (${t.status})`;
@@ -3325,19 +3325,19 @@ class en extends ue {
3325
3325
  return "InstantAPIError";
3326
3326
  }
3327
3327
  }
3328
- async function Ae(n, e) {
3328
+ async function ke(n, e) {
3329
3329
  const t = await fetch(n, e), r = await t.json();
3330
3330
  return t.status === 200 ? Promise.resolve(r) : Promise.reject(new en({ status: t.status, body: r }));
3331
3331
  }
3332
3332
  function lc({ apiURI: n, appId: e, email: t }) {
3333
- return Ae(`${n}/runtime/auth/send_magic_code`, {
3333
+ return ke(`${n}/runtime/auth/send_magic_code`, {
3334
3334
  method: "POST",
3335
3335
  headers: { "content-type": "application/json" },
3336
3336
  body: JSON.stringify({ "app-id": e, email: t })
3337
3337
  });
3338
3338
  }
3339
3339
  async function fc({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, extraFields: i }) {
3340
- return await Ae(`${n}/runtime/auth/verify_magic_code`, {
3340
+ return await ke(`${n}/runtime/auth/verify_magic_code`, {
3341
3341
  method: "POST",
3342
3342
  headers: { "content-type": "application/json" },
3343
3343
  body: JSON.stringify({
@@ -3350,7 +3350,7 @@ async function fc({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, ext
3350
3350
  });
3351
3351
  }
3352
3352
  async function dc({ apiURI: n, appId: e, refreshToken: t }) {
3353
- return await Ae(`${n}/runtime/auth/verify_refresh_token`, {
3353
+ return await ke(`${n}/runtime/auth/verify_refresh_token`, {
3354
3354
  method: "POST",
3355
3355
  headers: { "content-type": "application/json" },
3356
3356
  body: JSON.stringify({
@@ -3360,7 +3360,7 @@ async function dc({ apiURI: n, appId: e, refreshToken: t }) {
3360
3360
  });
3361
3361
  }
3362
3362
  async function hc({ apiURI: n, appId: e }) {
3363
- return await Ae(`${n}/runtime/auth/sign_in_guest`, {
3363
+ return await ke(`${n}/runtime/auth/sign_in_guest`, {
3364
3364
  method: "POST",
3365
3365
  headers: { "content-type": "application/json" },
3366
3366
  body: JSON.stringify({
@@ -3369,7 +3369,7 @@ async function hc({ apiURI: n, appId: e }) {
3369
3369
  });
3370
3370
  }
3371
3371
  async function Wr({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken: s, extraFields: i }) {
3372
- return await Ae(`${n}/runtime/oauth/token`, {
3372
+ return await ke(`${n}/runtime/oauth/token`, {
3373
3373
  method: "POST",
3374
3374
  headers: { "content-type": "application/json" },
3375
3375
  body: JSON.stringify({
@@ -3382,7 +3382,7 @@ async function Wr({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken:
3382
3382
  });
3383
3383
  }
3384
3384
  async function pc({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, refreshToken: i, extraFields: o }) {
3385
- return await Ae(`${n}/runtime/oauth/id_token`, {
3385
+ return await ke(`${n}/runtime/oauth/id_token`, {
3386
3386
  method: "POST",
3387
3387
  headers: { "content-type": "application/json" },
3388
3388
  body: JSON.stringify({
@@ -3396,7 +3396,7 @@ async function pc({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, re
3396
3396
  });
3397
3397
  }
3398
3398
  async function yc({ apiURI: n, appId: e, refreshToken: t }) {
3399
- return await Ae(`${n}/runtime/signout`, {
3399
+ return await ke(`${n}/runtime/signout`, {
3400
3400
  method: "POST",
3401
3401
  headers: {
3402
3402
  "content-type": "application/json"
@@ -3414,14 +3414,14 @@ async function bc({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, cont
3414
3414
  authorization: `Bearer ${s}`,
3415
3415
  "content-type": i || r.type
3416
3416
  };
3417
- return o && (a["content-disposition"] = o), await Ae(`${n}/storage/upload`, {
3417
+ return o && (a["content-disposition"] = o), await ke(`${n}/storage/upload`, {
3418
3418
  method: "PUT",
3419
3419
  headers: a,
3420
3420
  body: r
3421
3421
  });
3422
3422
  }
3423
3423
  async function gc({ apiURI: n, appId: e, path: t, refreshToken: r }) {
3424
- const { data: s } = await Ae(`${n}/storage/files?app_id=${e}&filename=${encodeURIComponent(t)}`, {
3424
+ const { data: s } = await ke(`${n}/storage/files?app_id=${e}&filename=${encodeURIComponent(t)}`, {
3425
3425
  method: "DELETE",
3426
3426
  headers: {
3427
3427
  "content-type": "application/json",
@@ -3431,7 +3431,7 @@ async function gc({ apiURI: n, appId: e, path: t, refreshToken: r }) {
3431
3431
  return s;
3432
3432
  }
3433
3433
  async function _c({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata: s = {} }) {
3434
- const { data: i } = await Ae(`${n}/storage/signed-upload-url`, {
3434
+ const { data: i } = await ke(`${n}/storage/signed-upload-url`, {
3435
3435
  method: "POST",
3436
3436
  headers: {
3437
3437
  "content-type": "application/json",
@@ -3454,7 +3454,7 @@ async function mc(n, e) {
3454
3454
  })).ok;
3455
3455
  }
3456
3456
  async function wc({ apiURI: n, appId: e, path: t, refreshToken: r }) {
3457
- const { data: s } = await Ae(`${n}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(t)}`, {
3457
+ const { data: s } = await ke(`${n}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(t)}`, {
3458
3458
  method: "GET",
3459
3459
  headers: {
3460
3460
  "content-type": "application/json",
@@ -3541,7 +3541,7 @@ function Qr(n) {
3541
3541
  }, e;
3542
3542
  }, {});
3543
3543
  }
3544
- const ar = "v1.0.50";
3544
+ const ar = "v1.0.51-branch-optional-async-storage.29876965683.1";
3545
3545
  function vc(n, e, t = console) {
3546
3546
  return {
3547
3547
  info: n ? (...r) => t.info(...r, e()) : () => {
@@ -3701,7 +3701,7 @@ const Br = [
3701
3701
  Oc(u, l, i, e, r, t, `${s}.${u}`);
3702
3702
  } else if (!Zs(n, i, o))
3703
3703
  throw new B(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof n}`, s);
3704
- }, kc = (n, e, t, r, s) => {
3704
+ }, Ac = (n, e, t, r, s) => {
3705
3705
  const i = n.split(".");
3706
3706
  if (i.length < 2)
3707
3707
  throw new B(`Invalid dot notation path '${n}'. Must contain at least one dot.`, s);
@@ -3710,12 +3710,12 @@ const Br = [
3710
3710
  const f = i[l], d = r.entities[o];
3711
3711
  if (!d)
3712
3712
  throw new B(`Entity '${o}' does not exist in schema while traversing dot notation path '${n}'.`, s);
3713
- const y = d.links[f];
3714
- if (!y) {
3715
- const b = Object.keys(d.links);
3716
- throw new B(`Link '${f}' does not exist on entity '${o}' in dot notation path '${n}'. Available links: ${b.length > 0 ? b.join(", ") : "none"}`, s);
3713
+ const b = d.links[f];
3714
+ if (!b) {
3715
+ const y = Object.keys(d.links);
3716
+ throw new B(`Link '${f}' does not exist on entity '${o}' in dot notation path '${n}'. Available links: ${y.length > 0 ? y.join(", ") : "none"}`, s);
3717
3717
  }
3718
- o = y.entityName;
3718
+ o = b.entityName;
3719
3719
  }
3720
3720
  const a = i[i.length - 1], c = r.entities[o];
3721
3721
  if (!c)
@@ -3751,7 +3751,7 @@ const Br = [
3751
3751
  continue;
3752
3752
  }
3753
3753
  if (s.includes(".")) {
3754
- kc(s, i, e, t, `${r}.${s}`);
3754
+ Ac(s, i, e, t, `${r}.${s}`);
3755
3755
  continue;
3756
3756
  }
3757
3757
  const o = t.entities[e];
@@ -3771,7 +3771,7 @@ const Br = [
3771
3771
  rt(i, s, u, e, `${r}.${s}`);
3772
3772
  }
3773
3773
  }
3774
- }, Ac = (n, e, t, r, s = 0) => {
3774
+ }, kc = (n, e, t, r, s = 0) => {
3775
3775
  for (const o of Object.keys(n))
3776
3776
  if (!Br.includes(o))
3777
3777
  throw new B(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Br.join(", ")}. Found: ${o}`, r);
@@ -3812,7 +3812,7 @@ const Br = [
3812
3812
  const a = n[o];
3813
3813
  if (typeof a != "object" || a === null)
3814
3814
  throw new B(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
3815
- Ac(a, e, t, `${r}.$`, s);
3815
+ kc(a, e, t, `${r}.$`, s);
3816
3816
  }
3817
3817
  }, Gr = (n, e) => {
3818
3818
  if (typeof n != "object" || n === null)
@@ -3890,7 +3890,7 @@ const ti = (n) => n.length > 0 ? n.join(", ") : "none", Cc = (n, e) => new Te(`E
3890
3890
  unlink: Jr,
3891
3891
  delete: () => {
3892
3892
  }
3893
- }, Mc = (n, e) => {
3893
+ }, Rc = (n, e) => {
3894
3894
  if (!e)
3895
3895
  return;
3896
3896
  const [t, r, s, i] = n;
@@ -3900,7 +3900,7 @@ const ti = (n) => n.length > 0 ? n.join(", ") : "none", Cc = (n, e) => new Te(`E
3900
3900
  throw new Te(`Entity name must be a string, but received: ${typeof r}`);
3901
3901
  const o = Pc[t];
3902
3902
  o && i !== void 0 && o(r, i, e);
3903
- }, Rc = (n, e) => {
3903
+ }, Mc = (n, e) => {
3904
3904
  const t = Array.isArray(n) ? n : [n];
3905
3905
  for (const r of t) {
3906
3906
  if (!r || typeof r != "object")
@@ -3910,7 +3910,7 @@ const ti = (n) => n.length > 0 ? n.join(", ") : "none", Cc = (n, e) => new Te(`E
3910
3910
  for (const s of r.__ops) {
3911
3911
  if (!Array.isArray(s))
3912
3912
  throw new Te(`Transaction operation must be an array, but received: ${typeof s}`);
3913
- Mc(s, e);
3913
+ Rc(s, e);
3914
3914
  }
3915
3915
  }
3916
3916
  };
@@ -4097,7 +4097,7 @@ function Xr(n, e, t) {
4097
4097
  js(n, e, s);
4098
4098
  break;
4099
4099
  case "removed":
4100
- Ms(n, e, s);
4100
+ Rs(n, e, s);
4101
4101
  break;
4102
4102
  }
4103
4103
  }
@@ -4110,23 +4110,23 @@ function Uc(n, e, t) {
4110
4110
  continue;
4111
4111
  const d = r[c] ?? {};
4112
4112
  r[c] = d;
4113
- const y = d[f] ?? {};
4113
+ const b = d[f] ?? {};
4114
4114
  switch (o) {
4115
4115
  case "added":
4116
- y.newValue = l;
4116
+ b.newValue = l;
4117
4117
  break;
4118
4118
  case "removed":
4119
- y.oldValue === void 0 && (y.oldValue = l);
4119
+ b.oldValue === void 0 && (b.oldValue = l);
4120
4120
  break;
4121
4121
  }
4122
- d[f] = y;
4122
+ d[f] = b;
4123
4123
  }
4124
4124
  for (const [o, a] of Object.entries(r))
4125
4125
  for (const [c, { oldValue: u, newValue: l }] of Object.entries(a))
4126
4126
  u === l && delete a[c];
4127
4127
  return r;
4128
4128
  }
4129
- function jt(n, e) {
4129
+ function xt(n, e) {
4130
4130
  return { [n.table]: e.map((t) => t.entity) };
4131
4131
  }
4132
4132
  function Lc(n, e) {
@@ -4192,7 +4192,7 @@ class Nc {
4192
4192
  this.subs.flush();
4193
4193
  }
4194
4194
  subscribe(e, t) {
4195
- const r = ce(e);
4195
+ const r = ue(e);
4196
4196
  return this.callbacks[r] = this.callbacks[r] || [], this.callbacks[r].push(t), this.initSubscription(e, r, t), (s) => {
4197
4197
  this.unsubscribe(r, t, s == null ? void 0 : s.keepSubscription);
4198
4198
  };
@@ -4235,13 +4235,13 @@ class Nc {
4235
4235
  if (s && s.state && s.state.txId) {
4236
4236
  this.sendResync(s, s.state, s.state.txId), (u = s.values) != null && u.entities && r && r({
4237
4237
  type: Ue.LoadFromStorage,
4238
- data: jt(s, (l = s.values) == null ? void 0 : l.entities)
4238
+ data: xt(s, (l = s.values) == null ? void 0 : l.entities)
4239
4239
  });
4240
4240
  return;
4241
4241
  }
4242
4242
  const i = Object.keys(e)[0], o = ((d = (f = e[i]) == null ? void 0 : f.$) == null ? void 0 : d.order) || { serverCreatedAt: "asc" }, [a, c] = Object.entries(o)[0];
4243
- this.subs.updateInPlace((y) => {
4244
- y[t] = {
4243
+ this.subs.updateInPlace((b) => {
4244
+ b[t] = {
4245
4245
  query: e,
4246
4246
  hash: t,
4247
4247
  table: i,
@@ -4260,7 +4260,7 @@ class Nc {
4260
4260
  }
4261
4261
  }
4262
4262
  onStartSyncOk(e) {
4263
- const t = e["subscription-id"], r = e.q, s = ce(r);
4263
+ const t = e["subscription-id"], r = e.q, s = ue(r);
4264
4264
  this.idToHash[t] = s, this.subs.updateInPlace((i) => {
4265
4265
  const o = i[s];
4266
4266
  if (!o)
@@ -4304,7 +4304,7 @@ class Nc {
4304
4304
  u[s] = o, u[s].updatedAt = Date.now();
4305
4305
  }), o.values && this.notifyCbs(s, {
4306
4306
  type: Ue.InitialSyncBatch,
4307
- data: jt(o, o.values.entities),
4307
+ data: xt(o, o.values.entities),
4308
4308
  batch: i
4309
4309
  });
4310
4310
  }
@@ -4329,7 +4329,7 @@ class Nc {
4329
4329
  const s = this.subs.currentValue[r];
4330
4330
  s && this.notifyCbs(r, {
4331
4331
  type: Ue.InitialSyncComplete,
4332
- data: jt(s, ((i = s.values) == null ? void 0 : i.entities) || [])
4332
+ data: xt(s, ((i = s.values) == null ? void 0 : i.entities) || [])
4333
4333
  });
4334
4334
  }
4335
4335
  onSyncUpdateTriples(e) {
@@ -4354,9 +4354,9 @@ class Nc {
4354
4354
  continue;
4355
4355
  i.txId = a["tx-id"];
4356
4356
  const c = [], u = {};
4357
- for (const m of a.changes) {
4358
- const T = u[m.triple[0]] ?? [];
4359
- u[m.triple[0]] = T, T.push(m);
4357
+ for (const _ of a.changes) {
4358
+ const S = u[_.triple[0]] ?? [];
4359
+ u[_.triple[0]] = S, S.push(_);
4360
4360
  }
4361
4361
  const l = s.values ?? {
4362
4362
  entities: [],
@@ -4364,48 +4364,48 @@ class Nc {
4364
4364
  }, f = l.entities;
4365
4365
  s.values = l;
4366
4366
  const d = [];
4367
- e: for (const [m, T] of Object.entries(u))
4368
- for (let _ = 0; _ < f.length; _++) {
4369
- const w = f[_];
4370
- if (_o(w.store, m)) {
4371
- Xr(w.store, l.attrsStore, T);
4372
- const C = yn(s, w.store, l.attrsStore), v = Uc(w.store, l.attrsStore, T)[m];
4373
- C ? (d.push({
4367
+ e: for (const [_, S] of Object.entries(u))
4368
+ for (let m = 0; m < f.length; m++) {
4369
+ const w = f[m];
4370
+ if (_o(w.store, _)) {
4371
+ Xr(w.store, l.attrsStore, S);
4372
+ const A = yn(s, w.store, l.attrsStore), O = Uc(w.store, l.attrsStore, S)[_];
4373
+ A ? (d.push({
4374
4374
  oldEntity: w.entity,
4375
- newEntity: C,
4376
- changedFields: v || {}
4377
- }), w.entity = C) : c.push(_), delete u[m];
4375
+ newEntity: A,
4376
+ changedFields: O || {}
4377
+ }), w.entity = A) : c.push(m), delete u[_];
4378
4378
  continue e;
4379
4379
  }
4380
4380
  }
4381
- const y = [];
4382
- for (const [m, T] of Object.entries(u)) {
4383
- const _ = this.createStore([]);
4384
- Xr(_, l.attrsStore, T);
4385
- const w = yn(s, _, l.attrsStore);
4381
+ const b = [];
4382
+ for (const [_, S] of Object.entries(u)) {
4383
+ const m = this.createStore([]);
4384
+ Xr(m, l.attrsStore, S);
4385
+ const w = yn(s, m, l.attrsStore);
4386
4386
  if (!w) {
4387
4387
  this.log.error("No entity found after applying change", {
4388
4388
  sub: s,
4389
- changes: T,
4390
- store: _
4389
+ changes: S,
4390
+ store: m
4391
4391
  });
4392
4392
  continue;
4393
4393
  }
4394
4394
  f.push({
4395
- store: _,
4395
+ store: m,
4396
4396
  entity: w,
4397
- serverCreatedAt: Zr(s, _, l.attrsStore, w.id)
4398
- }), y.push(w);
4397
+ serverCreatedAt: Zr(s, m, l.attrsStore, w.id)
4398
+ }), b.push(w);
4399
4399
  }
4400
- const b = [];
4401
- for (const m of c.sort().reverse())
4402
- b.push(f[m].entity), f.splice(m, 1);
4400
+ const y = [];
4401
+ for (const _ of c.sort().reverse())
4402
+ y.push(f[_].entity), f.splice(_, 1);
4403
4403
  const g = Lc(s, this.getAttrs);
4404
4404
  Fc(s, g, f), this.notifyCbs(r, {
4405
4405
  type: Ue.SyncTransaction,
4406
- data: jt(s, (o = s.values) == null ? void 0 : o.entities),
4407
- added: y,
4408
- removed: b,
4406
+ data: xt(s, (o = s.values) == null ? void 0 : o.entities),
4407
+ added: b,
4408
+ removed: y,
4409
4409
  updated: d
4410
4410
  });
4411
4411
  }
@@ -4425,7 +4425,7 @@ class Nc {
4425
4425
  }
4426
4426
  }
4427
4427
  onStartSyncError(e) {
4428
- const t = ce(e["original-event"].q), r = {
4428
+ const t = ue(e["original-event"].q), r = {
4429
4429
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa.",
4430
4430
  status: e.status,
4431
4431
  type: e.type,
@@ -4447,104 +4447,104 @@ function Kc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
4447
4447
  let o = null, a = null, c = null;
4448
4448
  const u = Z();
4449
4449
  let l = !1, f = !1;
4450
- const d = [], y = [], b = [];
4451
- let g = !1, m = 0, T = 0;
4452
- const _ = [], w = new TextEncoder();
4453
- function C() {
4450
+ const d = [], b = [], y = [];
4451
+ let g = !1, _ = 0, S = 0;
4452
+ const m = [], w = new TextEncoder();
4453
+ function A() {
4454
4454
  f = !0;
4455
- for (const O of d)
4456
- O(a ?? void 0);
4455
+ for (const E of d)
4456
+ E(a ?? void 0);
4457
4457
  }
4458
- function v(O) {
4459
- return d.push(O), f && O(a ?? void 0), () => {
4460
- const A = d.indexOf(O);
4461
- A !== -1 && d.splice(A, 1);
4458
+ function O(E) {
4459
+ return d.push(E), f && E(a ?? void 0), () => {
4460
+ const C = d.indexOf(E);
4461
+ C !== -1 && d.splice(C, 1);
4462
4462
  };
4463
4463
  }
4464
- function U(O) {
4465
- return b.push(O), () => {
4466
- const A = b.indexOf(O);
4467
- A !== -1 && b.splice(A, 1);
4464
+ function M(E) {
4465
+ return y.push(E), () => {
4466
+ const C = y.indexOf(E);
4467
+ C !== -1 && y.splice(C, 1);
4468
4468
  };
4469
4469
  }
4470
- e.waitUntil && e.waitUntil(new Promise((O) => {
4471
- b.push(O);
4470
+ e.waitUntil && e.waitUntil(new Promise((E) => {
4471
+ y.push(E);
4472
4472
  }));
4473
4473
  function I() {
4474
- for (const O of b)
4474
+ for (const E of y)
4475
4475
  try {
4476
- O();
4476
+ E();
4477
4477
  } catch {
4478
4478
  }
4479
4479
  }
4480
- function P(O) {
4481
- return y.push(O), o && O(o), () => {
4482
- const A = y.indexOf(O);
4483
- A !== -1 && y.splice(A, 1);
4480
+ function R(E) {
4481
+ return b.push(E), o && E(o), () => {
4482
+ const C = b.indexOf(E);
4483
+ C !== -1 && b.splice(C, 1);
4484
4484
  };
4485
4485
  }
4486
- function H(O) {
4487
- o = O;
4488
- for (const A of y)
4489
- A(o);
4486
+ function H(E) {
4487
+ o = E;
4488
+ for (const C of b)
4489
+ C(o);
4490
4490
  }
4491
- function K() {
4491
+ function F() {
4492
4492
  g = !0;
4493
4493
  }
4494
- function G(O) {
4495
- let A = m, W = 0, J = 0;
4496
- for (const { byteLen: X } of _) {
4497
- const le = A + X;
4498
- if (le > O)
4494
+ function G(E) {
4495
+ let C = _, W = 0, J = 0;
4496
+ for (const { byteLen: X } of m) {
4497
+ const le = C + X;
4498
+ if (le > E)
4499
4499
  break;
4500
- A = le, W++, J += X;
4500
+ C = le, W++, J += X;
4501
4501
  }
4502
- W > 0 && (m += J, T -= J, _.splice(0, W));
4502
+ W > 0 && (_ += J, S -= J, m.splice(0, W));
4503
4503
  }
4504
- function V(O, A) {
4505
- a = A, C(), O.error(A), I();
4504
+ function V(E, C) {
4505
+ a = C, A(), E.error(C), I();
4506
4506
  }
4507
4507
  async function ne() {
4508
- const O = await t({
4508
+ const E = await t({
4509
4509
  clientId: i,
4510
4510
  reconnectToken: u,
4511
4511
  ruleParams: e.ruleParams
4512
4512
  });
4513
- switch (O.type) {
4513
+ switch (E.type) {
4514
4514
  case "ok": {
4515
- const { streamId: A, offset: W } = O;
4516
- o = A, G(W), _.length && r({
4517
- streamId: A,
4518
- chunks: _.map((J) => J.chunk),
4519
- offset: m
4515
+ const { streamId: C, offset: W } = E;
4516
+ o = C, G(W), m.length && r({
4517
+ streamId: C,
4518
+ chunks: m.map((J) => J.chunk),
4519
+ offset: _
4520
4520
  }), g = !1;
4521
4521
  break;
4522
4522
  }
4523
4523
  case "disconnect": {
4524
- K();
4524
+ F();
4525
4525
  break;
4526
4526
  }
4527
4527
  case "error": {
4528
- c && V(c, O.error);
4528
+ c && V(c, E.error);
4529
4529
  break;
4530
4530
  }
4531
4531
  }
4532
4532
  }
4533
4533
  function q() {
4534
- K(), ne();
4534
+ F(), ne();
4535
4535
  }
4536
- function k({ offset: O, done: A }) {
4537
- G(O), A && (l = !0, I());
4536
+ function k({ offset: E, done: C }) {
4537
+ G(E), C && (l = !0, I());
4538
4538
  }
4539
- function j(O) {
4540
- return l ? (V(O, new ue("Stream has been closed.")), null) : o || (V(O, new ue("Stream has not been initialized.")), null);
4539
+ function x(E) {
4540
+ return l ? (V(E, new oe("Stream has been closed.")), null) : o || (V(E, new oe("Stream has not been initialized.")), null);
4541
4541
  }
4542
- async function R(O) {
4543
- c = O;
4544
- let A = !0, W = 0;
4545
- for (; A; ) {
4542
+ async function j(E) {
4543
+ c = E;
4544
+ let C = !0, W = 0;
4545
+ for (; C; ) {
4546
4546
  let J = Date.now() + Math.min(15e3, 500 * (W - 1));
4547
- A = !1;
4547
+ C = !1;
4548
4548
  const X = await t({
4549
4549
  clientId: e.clientId,
4550
4550
  reconnectToken: u,
@@ -4554,12 +4554,12 @@ function Kc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
4554
4554
  case "ok": {
4555
4555
  const { streamId: le, offset: ct } = X;
4556
4556
  if (ct !== 0) {
4557
- const ve = new ue("Write stream is corrupted");
4558
- V(O, ve);
4557
+ const ve = new oe("Write stream is corrupted");
4558
+ V(E, ve);
4559
4559
  return;
4560
4560
  }
4561
4561
  H(le), s(le, {
4562
- onDisconnect: K,
4562
+ onDisconnect: F,
4563
4563
  onFlush: k,
4564
4564
  onConnectionReconnect: ne,
4565
4565
  onAppendFailed: q
@@ -4567,75 +4567,75 @@ function Kc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
4567
4567
  return;
4568
4568
  }
4569
4569
  case "disconnect": {
4570
- A = !0, K(), W++, await new Promise((le) => {
4570
+ C = !0, F(), W++, await new Promise((le) => {
4571
4571
  setTimeout(le, Math.max(0, J - Date.now()));
4572
4572
  });
4573
4573
  break;
4574
4574
  }
4575
4575
  case "error": {
4576
- V(O, X.error);
4576
+ V(E, X.error);
4577
4577
  return;
4578
4578
  }
4579
4579
  }
4580
4580
  }
4581
4581
  }
4582
- class F extends n {
4583
- constructor(A, W) {
4584
- super(A, W);
4582
+ class D extends n {
4583
+ constructor(C, W) {
4584
+ super(C, W);
4585
4585
  }
4586
4586
  async streamId() {
4587
- return o || new Promise((A, W) => {
4587
+ return o || new Promise((C, W) => {
4588
4588
  const J = [], X = () => {
4589
4589
  for (const ve of J)
4590
4590
  ve();
4591
4591
  }, le = (ve) => {
4592
- A(ve), X();
4592
+ C(ve), X();
4593
4593
  }, ct = (ve) => {
4594
- W(ve || new ue("Stream is closed.")), X();
4594
+ W(ve || new oe("Stream is closed.")), X();
4595
4595
  };
4596
- J.push(P(le)), J.push(v(ct));
4596
+ J.push(R(le)), J.push(O(ct));
4597
4597
  });
4598
4598
  }
4599
4599
  }
4600
4600
  return {
4601
- stream: new F({
4601
+ stream: new D({
4602
4602
  // TODO(dww): accept a storage so that write streams can survive across
4603
4603
  // browser restarts
4604
- async start(O) {
4604
+ async start(E) {
4605
4605
  try {
4606
- await R(O);
4607
- } catch (A) {
4608
- V(O, A);
4606
+ await j(E);
4607
+ } catch (C) {
4608
+ V(E, C);
4609
4609
  }
4610
4610
  },
4611
- write(O, A) {
4612
- const W = j(A);
4611
+ write(E, C) {
4612
+ const W = x(C);
4613
4613
  if (W) {
4614
- const J = w.encode(O).length;
4615
- _.push({ chunk: O, byteLen: J });
4616
- const X = m + T;
4617
- T += J, g || r({ streamId: W, chunks: [O], offset: X });
4614
+ const J = w.encode(E).length;
4615
+ m.push({ chunk: E, byteLen: J });
4616
+ const X = _ + S;
4617
+ S += J, g || r({ streamId: W, chunks: [E], offset: X });
4618
4618
  }
4619
4619
  },
4620
4620
  close() {
4621
4621
  o ? r({
4622
4622
  streamId: o,
4623
4623
  chunks: [],
4624
- offset: m + T,
4624
+ offset: _ + S,
4625
4625
  isDone: !0
4626
- }) : I(), C();
4626
+ }) : I(), A();
4627
4627
  },
4628
- abort(O) {
4628
+ abort(E) {
4629
4629
  o ? r({
4630
4630
  streamId: o,
4631
4631
  chunks: [],
4632
- offset: m + T,
4632
+ offset: _ + S,
4633
4633
  isDone: !0,
4634
- abortReason: O
4635
- }) : I(), C();
4634
+ abortReason: E
4635
+ }) : I(), A();
4636
4636
  }
4637
4637
  }),
4638
- addCompleteCb: U,
4638
+ addCompleteCb: M,
4639
4639
  closed() {
4640
4640
  return f;
4641
4641
  }
@@ -4680,151 +4680,151 @@ function qc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
4680
4680
  const o = new TextDecoder("utf-8"), a = new TextEncoder();
4681
4681
  let c, u = !1;
4682
4682
  const l = [], f = [];
4683
- let d = null, y = null;
4684
- function b(I) {
4683
+ let d = null, b = null;
4684
+ function y(I) {
4685
4685
  u = !0;
4686
- for (const P of l)
4687
- P(I);
4686
+ for (const R of l)
4687
+ R(I);
4688
4688
  }
4689
4689
  function g(I) {
4690
4690
  return l.push(I), () => {
4691
- const P = l.indexOf(I);
4692
- P !== -1 && l.splice(P, 1);
4691
+ const R = l.indexOf(I);
4692
+ R !== -1 && l.splice(R, 1);
4693
4693
  };
4694
4694
  }
4695
- function m(I) {
4695
+ function _(I) {
4696
4696
  return f.push(I), d && I(d), () => {
4697
- const P = f.indexOf(I);
4698
- P !== -1 && f.splice(P, 1);
4697
+ const R = f.indexOf(I);
4698
+ R !== -1 && f.splice(R, 1);
4699
4699
  };
4700
4700
  }
4701
- function T(I, P) {
4702
- y = P, I.error(P), b(P);
4701
+ function S(I, R) {
4702
+ b = R, I.error(R), y(R);
4703
4703
  }
4704
- let _ = 0;
4705
- async function w(I, P) {
4704
+ let m = 0;
4705
+ async function w(I, R) {
4706
4706
  c = Z();
4707
4707
  const H = { ...I || {}, eventId: c };
4708
- for await (const K of t(H)) {
4708
+ for await (const F of t(H)) {
4709
4709
  if (i)
4710
4710
  return;
4711
- if (K.type === "reconnect")
4711
+ if (F.type === "reconnect")
4712
4712
  return { retry: !0 };
4713
- if (K.type === "error") {
4714
- T(P, K.error);
4713
+ if (F.type === "error") {
4714
+ S(R, F.error);
4715
4715
  return;
4716
4716
  }
4717
- if (K.offset > s) {
4718
- T(P, new ue("Stream is corrupted.")), i = !0;
4717
+ if (F.offset > s) {
4718
+ S(R, new oe("Stream is corrupted.")), i = !0;
4719
4719
  return;
4720
4720
  }
4721
- d = K.streamId;
4721
+ d = F.streamId;
4722
4722
  for (const V of f)
4723
4723
  V(d);
4724
- let G = s - K.offset;
4725
- if (K.files && K.files.length) {
4724
+ let G = s - F.offset;
4725
+ if (F.files && F.files.length) {
4726
4726
  const V = new AbortController();
4727
- let ne = fetch(K.files[0].url, {
4727
+ let ne = fetch(F.files[0].url, {
4728
4728
  signal: V.signal
4729
4729
  });
4730
- for (let q = 0; q < K.files.length; q++) {
4731
- const k = K.files[q + 1], R = await ne;
4732
- if (k && (ne = fetch(k.url, { signal: V.signal })), !R.ok) {
4733
- if (_++, _ > 10) {
4734
- T(P, new ue("Unable to process stream."));
4730
+ for (let q = 0; q < F.files.length; q++) {
4731
+ const k = F.files[q + 1], j = await ne;
4732
+ if (k && (ne = fetch(k.url, { signal: V.signal })), !j.ok) {
4733
+ if (m++, m > 10) {
4734
+ S(R, new oe("Unable to process stream."));
4735
4735
  return;
4736
4736
  }
4737
4737
  return { retry: !0 };
4738
4738
  }
4739
- if (R.body) {
4740
- const F = R.body.getReader();
4739
+ if (j.body) {
4740
+ const D = j.body.getReader();
4741
4741
  try {
4742
4742
  for (; ; ) {
4743
- const { done: N, value: O } = await F.read();
4744
- if (N)
4743
+ const { done: K, value: E } = await D.read();
4744
+ if (K)
4745
4745
  break;
4746
4746
  if (i) {
4747
4747
  V.abort();
4748
4748
  return;
4749
4749
  }
4750
- let A = O;
4751
- if (G > 0 && (A = O.subarray(G), G -= O.length - A.length), !A.length)
4750
+ let C = E;
4751
+ if (G > 0 && (C = E.subarray(G), G -= E.length - C.length), !C.length)
4752
4752
  continue;
4753
- s += A.length;
4754
- const W = o.decode(A);
4755
- P.enqueue(W);
4753
+ s += C.length;
4754
+ const W = o.decode(C);
4755
+ R.enqueue(W);
4756
4756
  }
4757
4757
  } finally {
4758
- F.releaseLock();
4758
+ D.releaseLock();
4759
4759
  }
4760
4760
  } else {
4761
- const F = await R.arrayBuffer();
4762
- let N = F;
4761
+ const D = await j.arrayBuffer();
4762
+ let K = D;
4763
4763
  if (i) {
4764
4764
  V.abort();
4765
4765
  return;
4766
4766
  }
4767
- if (G > 0 && (N = new Uint8Array(F).subarray(G), G -= F.byteLength - N.length), !N.byteLength)
4767
+ if (G > 0 && (K = new Uint8Array(D).subarray(G), G -= D.byteLength - K.length), !K.byteLength)
4768
4768
  continue;
4769
- s += N.byteLength;
4770
- const O = o.decode(N);
4771
- P.enqueue(O);
4769
+ s += K.byteLength;
4770
+ const E = o.decode(K);
4771
+ R.enqueue(E);
4772
4772
  }
4773
4773
  }
4774
4774
  }
4775
- if (_ = 0, K.content) {
4776
- let V = K.content, ne = a.encode(K.content);
4775
+ if (m = 0, F.content) {
4776
+ let V = F.content, ne = a.encode(F.content);
4777
4777
  if (G > 0) {
4778
4778
  const q = ne.subarray(G);
4779
4779
  if (G -= ne.length - q.length, !q.length)
4780
4780
  continue;
4781
4781
  ne = q, V = o.decode(q);
4782
4782
  }
4783
- s += ne.length, P.enqueue(V);
4783
+ s += ne.length, R.enqueue(V);
4784
4784
  }
4785
4785
  }
4786
4786
  }
4787
- async function C(I) {
4788
- let P = !0, H = 0;
4789
- for (; P; ) {
4790
- P = !1;
4791
- let K = Date.now() + Math.min(15e3, 500 * (H - 1));
4787
+ async function A(I) {
4788
+ let R = !0, H = 0;
4789
+ for (; R; ) {
4790
+ R = !1;
4791
+ let F = Date.now() + Math.min(15e3, 500 * (H - 1));
4792
4792
  const G = await w({ ...e, offset: s }, I);
4793
- G != null && G.retry && (P = !0, H++, K < Date.now() - 3e5 && (H = 0), await new Promise((V) => {
4794
- setTimeout(V, Math.max(0, K - Date.now()));
4793
+ G != null && G.retry && (R = !0, H++, F < Date.now() - 3e5 && (H = 0), await new Promise((V) => {
4794
+ setTimeout(V, Math.max(0, F - Date.now()));
4795
4795
  }));
4796
4796
  }
4797
- !i && !u && (I.close(), b());
4797
+ !i && !u && (I.close(), y());
4798
4798
  }
4799
- class v extends n {
4800
- constructor(P, H) {
4801
- super(P, H);
4799
+ class O extends n {
4800
+ constructor(R, H) {
4801
+ super(R, H);
4802
4802
  }
4803
4803
  async streamId() {
4804
4804
  if (d)
4805
4805
  return d;
4806
- if (y)
4807
- throw y;
4808
- return new Promise((P, H) => {
4809
- const K = [], G = () => {
4810
- for (const q of K)
4806
+ if (b)
4807
+ throw b;
4808
+ return new Promise((R, H) => {
4809
+ const F = [], G = () => {
4810
+ for (const q of F)
4811
4811
  q();
4812
4812
  }, V = (q) => {
4813
- P(q), G();
4813
+ R(q), G();
4814
4814
  }, ne = (q) => {
4815
- H(q || new ue("Stream is closed.")), G();
4815
+ H(q || new oe("Stream is closed.")), G();
4816
4816
  };
4817
- K.push(m(V)), K.push(g(ne));
4817
+ F.push(_(V)), F.push(g(ne));
4818
4818
  });
4819
4819
  }
4820
4820
  }
4821
4821
  return {
4822
- stream: new v({
4822
+ stream: new O({
4823
4823
  start(I) {
4824
- C(I);
4824
+ A(I);
4825
4825
  },
4826
4826
  cancel(I) {
4827
- i = !0, c && r({ eventId: c }), b();
4827
+ i = !0, c && r({ eventId: c }), y();
4828
4828
  }
4829
4829
  }),
4830
4830
  addCloseCb: g,
@@ -4939,7 +4939,7 @@ class zc {
4939
4939
  if (e.error) {
4940
4940
  e.retry ? r.push({ type: "reconnect" }) : r.push({
4941
4941
  type: "error",
4942
- error: new ue(e.error)
4942
+ error: new oe(e.error)
4943
4943
  }), r.close(), delete this.readStreamIterators[t];
4944
4944
  return;
4945
4945
  }
@@ -4977,7 +4977,7 @@ class zc {
4977
4977
  const r = e["client-event-id"], s = this.startWriteStreamCbs[r];
4978
4978
  s && (s({
4979
4979
  type: "error",
4980
- error: new ue(e.message || "Unknown error", e.hint)
4980
+ error: new oe(e.message || "Unknown error", e.hint)
4981
4981
  }), delete this.startWriteStreamCbs[r]);
4982
4982
  break;
4983
4983
  }
@@ -4985,7 +4985,7 @@ class zc {
4985
4985
  const r = e["client-event-id"], s = this.readStreamIterators[r];
4986
4986
  s && (s.push({
4987
4987
  type: "error",
4988
- error: new ue(e.message || "Unknown error", e.hint)
4988
+ error: new oe(e.message || "Unknown error", e.hint)
4989
4989
  }), s.close(), delete this.readStreamIterators[r]);
4990
4990
  break;
4991
4991
  }
@@ -5004,7 +5004,7 @@ const Ce = {
5004
5004
  }, Vc = 3e4, Qc = 3e4, Bc = 200, Gc = 1e3 * 60, Hc = Gc * 60 * 24, es = "lastSyncedUserCookie", Jc = {
5005
5005
  apiURI: "https://api.instantdb.com",
5006
5006
  websocketURI: "wss://api.instantdb.com/runtime/session"
5007
- }, bn = "_instant_oauth_redirect", gn = "_instant_extra_fields_id", xt = "oauthExtraFields", Ge = "currentUser";
5007
+ }, bn = "_instant_oauth_redirect", gn = "_instant_extra_fields_id", $t = "oauthExtraFields", Ge = "currentUser";
5008
5008
  function Yc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5009
5009
  if (!s)
5010
5010
  return new Yr(`${r}?app_id=${e}`);
@@ -5105,6 +5105,13 @@ class su {
5105
5105
  p(this, "attrsCbs", []);
5106
5106
  p(this, "mutationErrorCbs", []);
5107
5107
  p(this, "connectionStatusCbs", []);
5108
+ p(this, "appStatusCbs", []);
5109
+ /**
5110
+ * Carries the raw server status off the public type: `disabled` is an
5111
+ * operator-level state we don't surface to apps.
5112
+ * @type {import('./clientTypes.ts').AppStatusState & { status?: 'active' | 'read-only' | 'disabled' }}
5113
+ */
5114
+ p(this, "_appStatusState", { isLoading: !0, isReadOnly: void 0 });
5108
5115
  p(this, "config");
5109
5116
  p(this, "mutationDeferredStore", /* @__PURE__ */ new Map());
5110
5117
  p(this, "_reconnectTimeoutId", null);
@@ -5160,14 +5167,14 @@ class su {
5160
5167
  // Queries
5161
5168
  p(this, "getPreviousResult", (e) => {
5162
5169
  var r;
5163
- const t = ce(e);
5170
+ const t = ue(e);
5164
5171
  return (r = this.dataForQuery(t)) == null ? void 0 : r.data;
5165
5172
  });
5166
5173
  /** Re-run instaql and call all callbacks with new data */
5167
5174
  p(this, "notifyOne", (e) => {
5168
5175
  var i;
5169
5176
  const t = this.queryCbs[e] ?? [], r = (i = this._dataForQueryCache[e]) == null ? void 0 : i.data, s = this.dataForQuery(e);
5170
- s != null && s.data && (this._dataForQueryCache[e] = s, !Nt(s.data, r) && t.forEach((o) => o.cb(s.data)));
5177
+ s != null && s.data && (this._dataForQueryCache[e] = s, !Kt(s.data, r) && t.forEach((o) => o.cb(s.data)));
5171
5178
  });
5172
5179
  p(this, "notifyOneQueryOnce", (e) => {
5173
5180
  var s;
@@ -5177,11 +5184,17 @@ class su {
5177
5184
  });
5178
5185
  });
5179
5186
  p(this, "notifyQueryError", (e, t) => {
5180
- (this.queryCbs[e] || []).forEach((s) => s.cb({ error: t }));
5187
+ delete this._dataForQueryCache[e], (this.queryCbs[e] || []).forEach((s) => s.cb({ error: t }));
5181
5188
  });
5182
5189
  /** Applies transactions locally and sends transact message to server */
5183
5190
  p(this, "pushTx", (e) => {
5184
- this.config.disableValidation || Rc(e, this.config.schema);
5191
+ if (this._appStatusState.isReadOnly)
5192
+ return Promise.reject(this._appStatusState.status === "disabled" ? new oe("This app is currently disabled.", {
5193
+ status: "disabled"
5194
+ }) : new oe("This app is in read-only mode.", {
5195
+ status: "read-only"
5196
+ }));
5197
+ this.config.disableValidation || Mc(e, this.config.schema);
5185
5198
  try {
5186
5199
  const t = nc({
5187
5200
  attrsStore: this.optimisticAttrs(),
@@ -5409,7 +5422,7 @@ class su {
5409
5422
  status: o ?? 0
5410
5423
  }));
5411
5424
  } else
5412
- s.reject(new ue((r == null ? void 0 : r.message) || "Unknown error", r == null ? void 0 : r.hint, r == null ? void 0 : r.traceId));
5425
+ s.reject(new oe((r == null ? void 0 : r.message) || "Unknown error", r == null ? void 0 : r.hint, r == null ? void 0 : r.traceId));
5413
5426
  }
5414
5427
  _setStatus(e, t) {
5415
5428
  this.status = e, this._errorMessage = t, this.notifyConnectionStatusSubs(e), this._instantStream.onConnectionStatusChange(e);
@@ -5433,7 +5446,7 @@ class su {
5433
5446
  _addQueryData(e, t, r) {
5434
5447
  if (!this.attrs)
5435
5448
  throw new Error("Attrs in reactor have not been set");
5436
- const s = ce(e), i = this.ensureAttrs(), o = yt(this.attrs, t.triples, r, this.config.useDateObjects);
5449
+ const s = ue(e), i = this.ensureAttrs(), o = yt(this.attrs, t.triples, r, this.config.useDateObjects);
5437
5450
  this.querySubs.updateInPlace((a) => {
5438
5451
  a[s] = {
5439
5452
  result: {
@@ -5448,39 +5461,39 @@ class su {
5448
5461
  }), this._cleanupPendingMutationsQueries(), this.notifyOne(s), this.notifyOneQueryOnce(s), this._cleanupPendingMutationsTimeout();
5449
5462
  }
5450
5463
  _handleReceive(e, t) {
5451
- var s, i, o, a, c, u, l;
5464
+ var s, i, o, a, c, u, l, f;
5452
5465
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5453
5466
  switch (ts[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
5454
5467
  case "init-ok": {
5455
- this._setStatus(Ce.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
5468
+ this._setStatus(Ce.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAppStatus(((s = t["app-status"]) == null ? void 0 : s.status) ?? "active"), this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
5456
5469
  for (const y of Object.keys(this._rooms)) {
5457
- const b = (i = (s = this._presence[y]) == null ? void 0 : s.result) == null ? void 0 : i.user, g = (o = this._rooms[y]) == null ? void 0 : o.roomType;
5458
- this._tryJoinRoom(g, y, b);
5470
+ const g = (o = (i = this._presence[y]) == null ? void 0 : i.result) == null ? void 0 : o.user, _ = (a = this._rooms[y]) == null ? void 0 : a.roomType;
5471
+ this._tryJoinRoom(_, y, g);
5459
5472
  }
5460
5473
  break;
5461
5474
  }
5462
5475
  case "add-query-exists": {
5463
- this.notifyOneQueryOnce(ce(t.q));
5476
+ this.notifyOneQueryOnce(ue(t.q));
5464
5477
  break;
5465
5478
  }
5466
5479
  case "add-query-ok": {
5467
- const { q: y, result: b } = t, g = ce(y);
5468
- if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
5480
+ const { q: y, result: g } = t, _ = ue(y);
5481
+ if (!this._hasQueryListeners() && !this.querySubs.currentValue[_])
5469
5482
  break;
5470
- const m = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], T = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = Vr(b), w = this.ensureAttrs(), C = yt(w, _, r, this.config.useDateObjects);
5471
- this.querySubs.updateInPlace((v) => {
5472
- if (!v[g]) {
5473
- this._log.info("Missing value in querySubs", { hash: g, q: y });
5483
+ const S = (u = (c = g == null ? void 0 : g[0]) == null ? void 0 : c.data) == null ? void 0 : u["page-info"], m = (f = (l = g == null ? void 0 : g[0]) == null ? void 0 : l.data) == null ? void 0 : f.aggregate, w = Vr(g), A = this.ensureAttrs(), O = yt(A, w, r, this.config.useDateObjects);
5484
+ this.querySubs.updateInPlace((M) => {
5485
+ if (!M[_]) {
5486
+ this._log.info("Missing value in querySubs", { hash: _, q: y });
5474
5487
  return;
5475
5488
  }
5476
- v[g].result = {
5477
- store: C,
5478
- attrsStore: w,
5479
- pageInfo: m,
5480
- aggregate: T,
5489
+ M[_].result = {
5490
+ store: O,
5491
+ attrsStore: A,
5492
+ pageInfo: S,
5493
+ aggregate: m,
5481
5494
  processedTxId: t["processed-tx-id"]
5482
5495
  };
5483
- }), this._cleanupPendingMutationsQueries(), this.notifyOne(g), this.notifyOneQueryOnce(g), this._cleanupPendingMutationsTimeout();
5496
+ }), this._cleanupPendingMutationsQueries(), this.notifyOne(_), this.notifyOneQueryOnce(_), this._cleanupPendingMutationsTimeout();
5484
5497
  break;
5485
5498
  }
5486
5499
  case "start-sync-ok": {
@@ -5516,65 +5529,65 @@ class su {
5516
5529
  break;
5517
5530
  }
5518
5531
  case "refresh-ok": {
5519
- const { computations: y, attrs: b } = t, g = t["processed-tx-id"];
5520
- b && this._setAttrs(b), this._cleanupPendingMutationsTimeout();
5521
- const m = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), g);
5522
- m !== this._pendingMutations() && this.kv.updateInPlace((w) => {
5523
- w.pendingMutations = m;
5532
+ const { computations: y, attrs: g } = t, _ = t["processed-tx-id"];
5533
+ g && this._setAttrs(g), this._cleanupPendingMutationsTimeout();
5534
+ const S = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), _);
5535
+ S !== this._pendingMutations() && this.kv.updateInPlace((A) => {
5536
+ A.pendingMutations = S;
5524
5537
  });
5525
- const T = _n(m.entries()), _ = y.map((w) => {
5526
- var q, k, j, R;
5527
- const C = w["instaql-query"], v = w["instaql-result"], U = ce(C), I = Vr(v), P = this.ensureAttrs(), H = yt(P, I, r, this.config.useDateObjects), { store: K, attrsStore: G } = this._applyOptimisticUpdates(H, P, T, g), V = (k = (q = v == null ? void 0 : v[0]) == null ? void 0 : q.data) == null ? void 0 : k["page-info"], ne = (R = (j = v == null ? void 0 : v[0]) == null ? void 0 : j.data) == null ? void 0 : R.aggregate;
5538
+ const m = _n(S.entries()), w = y.map((A) => {
5539
+ var k, x, j, D;
5540
+ const O = A["instaql-query"], M = A["instaql-result"], I = ue(O), R = Vr(M), H = this.ensureAttrs(), F = yt(H, R, r, this.config.useDateObjects), { store: G, attrsStore: V } = this._applyOptimisticUpdates(F, H, m, _), ne = (x = (k = M == null ? void 0 : M[0]) == null ? void 0 : k.data) == null ? void 0 : x["page-info"], q = (D = (j = M == null ? void 0 : M[0]) == null ? void 0 : j.data) == null ? void 0 : D.aggregate;
5528
5541
  return {
5529
- q: C,
5530
- hash: U,
5531
- store: K,
5532
- attrsStore: G,
5533
- pageInfo: V,
5534
- aggregate: ne
5542
+ q: O,
5543
+ hash: I,
5544
+ store: G,
5545
+ attrsStore: V,
5546
+ pageInfo: ne,
5547
+ aggregate: q
5535
5548
  };
5536
5549
  });
5537
- _.forEach(({ hash: w, q: C, store: v, attrsStore: U, pageInfo: I, aggregate: P }) => {
5538
- this.querySubs.updateInPlace((H) => {
5539
- if (!H[w]) {
5540
- this._log.error("Missing value in querySubs", { hash: w, q: C });
5550
+ w.forEach(({ hash: A, q: O, store: M, attrsStore: I, pageInfo: R, aggregate: H }) => {
5551
+ this.querySubs.updateInPlace((F) => {
5552
+ if (!F[A]) {
5553
+ this._log.error("Missing value in querySubs", { hash: A, q: O });
5541
5554
  return;
5542
5555
  }
5543
- H[w].result = {
5544
- store: v,
5545
- attrsStore: U,
5546
- pageInfo: I,
5547
- aggregate: P,
5548
- processedTxId: g
5556
+ F[A].result = {
5557
+ store: M,
5558
+ attrsStore: I,
5559
+ pageInfo: R,
5560
+ aggregate: H,
5561
+ processedTxId: _
5549
5562
  };
5550
5563
  });
5551
- }), this._cleanupPendingMutationsQueries(), _.forEach(({ hash: w }) => {
5552
- this.notifyOne(w);
5564
+ }), this._cleanupPendingMutationsQueries(), w.forEach(({ hash: A }) => {
5565
+ this.notifyOne(A);
5553
5566
  });
5554
5567
  break;
5555
5568
  }
5556
5569
  case "transact-ok": {
5557
- const { "client-event-id": y, "tx-id": b } = t;
5570
+ const { "client-event-id": y, "tx-id": g } = t;
5558
5571
  this._inFlightMutationEventIds.delete(y);
5559
- const m = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(y);
5560
- if (!m)
5572
+ const S = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(y);
5573
+ if (!S)
5561
5574
  break;
5562
- this._updatePendingMutations((_) => {
5563
- _.set(y, {
5564
- ..._.get(y),
5565
- "tx-id": b,
5575
+ this._updatePendingMutations((w) => {
5576
+ w.set(y, {
5577
+ ...w.get(y),
5578
+ "tx-id": g,
5566
5579
  confirmed: Date.now()
5567
5580
  });
5568
5581
  });
5569
- const T = [];
5570
- for (const _ of m["tx-steps"])
5571
- if (_[0] === "add-attr") {
5572
- const w = _[1];
5573
- T.push(w);
5582
+ const m = [];
5583
+ for (const w of S["tx-steps"])
5584
+ if (w[0] === "add-attr") {
5585
+ const A = w[1];
5586
+ m.push(A);
5574
5587
  }
5575
- if (T.length) {
5576
- const _ = Object.values(this.ensureAttrs().attrs);
5577
- this._setAttrs([..._, ...T]);
5588
+ if (m.length) {
5589
+ const w = Object.values(this.ensureAttrs().attrs);
5590
+ this._setAttrs([...w, ...m]);
5578
5591
  }
5579
5592
  this._finishTransaction("synced", y), this._cleanupPendingMutationsTimeout();
5580
5593
  break;
@@ -5590,8 +5603,8 @@ class su {
5590
5603
  break;
5591
5604
  }
5592
5605
  case "server-broadcast": {
5593
- const y = t["room-id"], b = t.topic;
5594
- this._trySetRoomConnected(y, !0), this._notifyBroadcastSubs(y, b, t);
5606
+ const y = t["room-id"], g = t.topic;
5607
+ this._trySetRoomConnected(y, !0), this._notifyBroadcastSubs(y, g, t);
5595
5608
  break;
5596
5609
  }
5597
5610
  case "join-room-ok": {
@@ -5608,9 +5621,21 @@ class su {
5608
5621
  this._trySetRoomConnected(y, !1);
5609
5622
  break;
5610
5623
  }
5624
+ case "app-status-changed": {
5625
+ const y = this._appStatusState.status;
5626
+ if (this._setAppStatus(t.status), t.status === "disabled" && y !== "disabled") {
5627
+ const g = {
5628
+ message: "This app is currently disabled.",
5629
+ hint: { status: "disabled" }
5630
+ };
5631
+ Object.keys(this.queryCbs).forEach((_) => this.notifyQueryError(_, g));
5632
+ }
5633
+ y === "disabled" && t.status !== "disabled" && this._startSocket();
5634
+ break;
5635
+ }
5611
5636
  case "join-room-error":
5612
- const f = t["room-id"], d = this._rooms[f];
5613
- d && (d.error = t.error), this._notifyPresenceSubs(f);
5637
+ const d = t["room-id"], b = this._rooms[d];
5638
+ b && (b.error = t.error), this._notifyPresenceSubs(d);
5614
5639
  break;
5615
5640
  case "error":
5616
5641
  this._handleReceiveError(t);
@@ -5653,7 +5678,7 @@ class su {
5653
5678
  }
5654
5679
  }
5655
5680
  _handleReceiveError(e) {
5656
- var a, c, u, l, f, d, y, b;
5681
+ var a, c, u, l, f, d, b, y;
5657
5682
  this._log.info("error", e);
5658
5683
  const t = e["client-event-id"];
5659
5684
  this._inFlightMutationEventIds.delete(t);
@@ -5661,27 +5686,27 @@ class su {
5661
5686
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa."
5662
5687
  };
5663
5688
  if (e.hint && (s.hint = e.hint), e["trace-id"] || (a = e["original-event"]) != null && a["trace-id"]) {
5664
- const m = [e["trace-id"], (c = e["original-event"]) == null ? void 0 : c["trace-id"]].filter(Boolean).join(",");
5665
- s.traceId = m;
5689
+ const _ = [e["trace-id"], (c = e["original-event"]) == null ? void 0 : c["trace-id"]].filter(Boolean).join(",");
5690
+ s.traceId = _;
5666
5691
  }
5667
5692
  if (r) {
5668
5693
  this._handleMutationError("error", t, s);
5669
5694
  return;
5670
5695
  }
5671
5696
  if ((u = e["original-event"]) != null && u.hasOwnProperty("q") && ((l = e["original-event"]) == null ? void 0 : l.op) === "add-query") {
5672
- const g = (f = e["original-event"]) == null ? void 0 : f.q, m = ce(g);
5673
- this.notifyQueryError(ce(g), s), this.notifyQueryOnceError(g, m, t, s);
5697
+ const g = (f = e["original-event"]) == null ? void 0 : f.q, _ = ue(g);
5698
+ this.notifyQueryError(ue(g), s), this.notifyQueryOnceError(g, _, t, s);
5674
5699
  return;
5675
5700
  }
5676
5701
  if (((d = e["original-event"]) == null ? void 0 : d.op) === "init") {
5677
- if (e.type === "record-not-found" && ((y = e.hint) == null ? void 0 : y["record-type"]) === "app-user") {
5702
+ if (e.type === "record-not-found" && ((b = e.hint) == null ? void 0 : b["record-type"]) === "app-user") {
5678
5703
  this.changeCurrentUser(null);
5679
5704
  return;
5680
5705
  }
5681
5706
  this._setStatus(Ce.ERRORED, s), this.notifyAll();
5682
5707
  return;
5683
5708
  }
5684
- switch ((b = e["original-event"]) == null ? void 0 : b.op) {
5709
+ switch ((y = e["original-event"]) == null ? void 0 : y.op) {
5685
5710
  case "resync-table": {
5686
5711
  this._syncTable.onResyncError(e);
5687
5712
  return;
@@ -5753,7 +5778,7 @@ class su {
5753
5778
  */
5754
5779
  subscribeQuery(e, t, r) {
5755
5780
  this.config.disableValidation || Gr(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
5756
- const s = ce(e), i = this.getPreviousResult(e);
5781
+ const s = ue(e), i = this.getPreviousResult(e);
5757
5782
  return i && t(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: t }), this._startQuerySub(e, s), () => {
5758
5783
  this._unsubQuery(e, s, t);
5759
5784
  };
@@ -5765,7 +5790,7 @@ class su {
5765
5790
  return r.reject(new Error("We can't run `queryOnce`, because the device is offline.")), r.promise;
5766
5791
  if (!this.querySubs)
5767
5792
  return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
5768
- const s = ce(e), i = this._startQuerySub(e, s);
5793
+ const s = ue(e), i = this._startQuerySub(e, s);
5769
5794
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), Vc), r.promise;
5770
5795
  }
5771
5796
  _completeQueryOnce(e, t, r) {
@@ -5804,36 +5829,36 @@ class su {
5804
5829
  if (!t)
5805
5830
  return /* @__PURE__ */ new Map();
5806
5831
  const s = (l) => {
5807
- const [f, d, y] = l["forward-identity"];
5808
- return se(e, d, y);
5832
+ const [f, d, b] = l["forward-identity"];
5833
+ return se(e, d, b);
5809
5834
  }, i = (l) => {
5810
- const [f, d, y] = l["forward-identity"];
5811
- return Ve(e, d, y);
5835
+ const [f, d, b] = l["forward-identity"];
5836
+ return Ve(e, d, b);
5812
5837
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
5813
5838
  let a = !1;
5814
5839
  const c = (l, f) => {
5815
5840
  const d = [];
5816
- for (const y of l) {
5817
- const [b] = y;
5818
- if (b === "add-attr") {
5819
- const [m, T] = y, _ = s(T);
5820
- if (_ && T.id !== _.id) {
5821
- o.attrIdMap[T.id] = _.id, a = !0;
5841
+ for (const b of l) {
5842
+ const [y] = b;
5843
+ if (y === "add-attr") {
5844
+ const [_, S] = b, m = s(S);
5845
+ if (m && S.id !== m.id) {
5846
+ o.attrIdMap[S.id] = m.id, a = !0;
5822
5847
  continue;
5823
5848
  }
5824
- if (T["value-type"] === "ref") {
5825
- const w = i(T);
5849
+ if (S["value-type"] === "ref") {
5850
+ const w = i(S);
5826
5851
  if (w) {
5827
- o.attrIdMap[T.id] = w.id, o.refSwapAttrIds.add(T.id), a = !0;
5852
+ o.attrIdMap[S.id] = w.id, o.refSwapAttrIds.add(S.id), a = !0;
5828
5853
  continue;
5829
5854
  }
5830
5855
  }
5831
5856
  }
5832
- if (r && f && r >= f && b === "add-attr" || b === "update-attr" || b === "delete-attr") {
5857
+ if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
5833
5858
  a = !0;
5834
5859
  continue;
5835
5860
  }
5836
- const g = a ? Ma(o, y) : y;
5861
+ const g = a ? Ra(o, b) : b;
5837
5862
  d.push(g);
5838
5863
  }
5839
5864
  return a ? d : l;
@@ -5886,12 +5911,12 @@ class su {
5886
5911
  if (l && s === l.querySubVersion && o === l.pendingMutationsVersion)
5887
5912
  return l;
5888
5913
  let f = u.store, d = u.attrsStore;
5889
- const { pageInfo: y, aggregate: b, processedTxId: g } = u, m = this._rewriteMutationsSorted(d, a);
5914
+ const { pageInfo: b, aggregate: y, processedTxId: g } = u, _ = this._rewriteMutationsSorted(d, a);
5890
5915
  if (t) {
5891
- const _ = this._applyOptimisticUpdates(f, d, m, g);
5892
- f = _.store, d = _.attrsStore;
5916
+ const m = this._applyOptimisticUpdates(f, d, _, g);
5917
+ f = m.store, d = m.attrsStore;
5893
5918
  }
5894
- return { data: zs({ store: f, attrsStore: d, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
5919
+ return { data: zs({ store: f, attrsStore: d, pageInfo: b, aggregate: y }, c), querySubVersion: s, pendingMutationsVersion: o };
5895
5920
  }
5896
5921
  _applyOptimisticUpdates(e, t, r, s) {
5897
5922
  for (const [i, o] of r)
@@ -6086,18 +6111,18 @@ class su {
6086
6111
  this._replaceUrlAfterOAuth();
6087
6112
  try {
6088
6113
  let u;
6089
- const l = await this.kv.waitForKeyToLoad(xt);
6090
- s && l && (u = l[s]), l && this.kv.updateInPlace((b) => {
6091
- delete b[xt];
6114
+ const l = await this.kv.waitForKeyToLoad($t);
6115
+ s && l && (u = l[s]), l && this.kv.updateInPlace((y) => {
6116
+ delete y[$t];
6092
6117
  });
6093
- const f = await this._getCurrentUser(), d = (f == null ? void 0 : f.type) === "guest", { user: y } = await Wr({
6118
+ const f = await this._getCurrentUser(), d = (f == null ? void 0 : f.type) === "guest", { user: b } = await Wr({
6094
6119
  apiURI: this.config.apiURI,
6095
6120
  appId: this.config.appId,
6096
6121
  code: r,
6097
6122
  refreshToken: d ? f.refresh_token : void 0,
6098
6123
  extraFields: u
6099
6124
  });
6100
- return this.setCurrentUser(y), null;
6125
+ return this.setCurrentUser(b), null;
6101
6126
  } catch (u) {
6102
6127
  return ((i = u == null ? void 0 : u.body) == null ? void 0 : i.type) === "record-not-found" && ((a = (o = u == null ? void 0 : u.body) == null ? void 0 : o.hint) == null ? void 0 : a["record-type"]) === "app-oauth-code" && await this._hasCurrentUser() ? null : { error: { message: ((c = u == null ? void 0 : u.body) == null ? void 0 : c.message) || "Error logging in." } };
6103
6128
  }
@@ -6116,7 +6141,7 @@ class su {
6116
6141
  t.isLoading || e(this._currentUserCached);
6117
6142
  let r = !1;
6118
6143
  return this.getCurrentUser().then((s) => {
6119
- r || Nt(s, t) || e(s);
6144
+ r || Kt(s, t) || e(s);
6120
6145
  }), () => {
6121
6146
  r = !0, this.authCbs = this.authCbs.filter((s) => s !== e);
6122
6147
  };
@@ -6124,7 +6149,7 @@ class su {
6124
6149
  async getAuth() {
6125
6150
  const { user: e, error: t } = await this.getCurrentUser();
6126
6151
  if (t)
6127
- throw new ue("Could not get current user: " + t.message);
6152
+ throw new oe("Could not get current user: " + t.message);
6128
6153
  return e ?? null;
6129
6154
  }
6130
6155
  subscribeConnectionStatus(e) {
@@ -6132,6 +6157,21 @@ class su {
6132
6157
  this.connectionStatusCbs = this.connectionStatusCbs.filter((t) => t !== e);
6133
6158
  };
6134
6159
  }
6160
+ /**
6161
+ * @param {'active' | 'read-only' | 'disabled' | undefined} status
6162
+ */
6163
+ _setAppStatus(e) {
6164
+ !e || e === this._appStatusState.status || (this._appStatusState = {
6165
+ isLoading: !1,
6166
+ isReadOnly: e !== "active",
6167
+ status: e
6168
+ }, this.notifyAppStatusSubs(this._appStatusState));
6169
+ }
6170
+ subscribeAppStatus(e) {
6171
+ return this.appStatusCbs.push(e), e(this._appStatusState), () => {
6172
+ this.appStatusCbs = this.appStatusCbs.filter((t) => t !== e);
6173
+ };
6174
+ }
6135
6175
  subscribeAttrs(e) {
6136
6176
  return this.attrsCbs.push(e), this.attrs && e(this.attrs.attrs), () => {
6137
6177
  this.attrsCbs = this.attrsCbs.filter((t) => t !== e);
@@ -6152,6 +6192,9 @@ class su {
6152
6192
  notifyConnectionStatusSubs(e) {
6153
6193
  this.connectionStatusCbs.forEach((t) => t(e));
6154
6194
  }
6195
+ notifyAppStatusSubs(e) {
6196
+ this.appStatusCbs.forEach((t) => t(e));
6197
+ }
6155
6198
  async setCurrentUser(e) {
6156
6199
  this.kv.updateInPlace((t) => {
6157
6200
  t[Ge] = e;
@@ -6200,7 +6243,7 @@ class su {
6200
6243
  async changeCurrentUser(e) {
6201
6244
  var r;
6202
6245
  const { user: t } = await this.getCurrentUser();
6203
- if (!Nt(t, e)) {
6246
+ if (!Kt(t, e)) {
6204
6247
  this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
6205
6248
  try {
6206
6249
  await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
@@ -6336,8 +6379,8 @@ class su {
6336
6379
  if (r) {
6337
6380
  const a = `${Math.random().toString(36).slice(2)}`;
6338
6381
  this.kv.updateInPlace((c) => {
6339
- const u = c[xt] || {};
6340
- u[a] = r, c[xt] = u;
6382
+ const u = c[$t] || {};
6383
+ u[a] = r, c[$t] = u;
6341
6384
  }), o = `${t}${t.includes("?") ? "&" : "?"}${gn}=${a}`;
6342
6385
  }
6343
6386
  return `${s}/runtime/oauth/start?app_id=${i}&client_name=${e}&redirect_uri=${encodeURIComponent(o)}`;
@@ -6496,7 +6539,7 @@ class su {
6496
6539
  Ir(u, l, d);
6497
6540
  break;
6498
6541
  case "-":
6499
- ks(u, l);
6542
+ As(u, l);
6500
6543
  break;
6501
6544
  }
6502
6545
  delete u[this._sessionId];
@@ -6541,8 +6584,8 @@ class su {
6541
6584
  _notifyBroadcastSubs(e, t, r) {
6542
6585
  var s, i, o;
6543
6586
  (o = (i = (s = this._broadcastSubs) == null ? void 0 : s[e]) == null ? void 0 : i[t]) == null || o.forEach((a) => {
6544
- var l, f, d, y, b, g;
6545
- const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (g = (b = (y = this._presence[e]) == null ? void 0 : y.result) == null ? void 0 : b.peers) == null ? void 0 : g[r.data["peer-id"]];
6587
+ var l, f, d, b, y, g;
6588
+ const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (d = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : d.user : (g = (y = (b = this._presence[e]) == null ? void 0 : b.result) == null ? void 0 : y.peers) == null ? void 0 : g[r.data["peer-id"]];
6546
6589
  return a(c, u);
6547
6590
  });
6548
6591
  }
@@ -6658,7 +6701,7 @@ function hu({ entities: n, links: e, rooms: t }) {
6658
6701
  s
6659
6702
  );
6660
6703
  }
6661
- const fl = {
6704
+ const dl = {
6662
6705
  // constructs
6663
6706
  graph: iu,
6664
6707
  schema: hu,
@@ -6671,9 +6714,9 @@ const fl = {
6671
6714
  json: fu,
6672
6715
  any: du
6673
6716
  };
6674
- let $t;
6717
+ let Dt;
6675
6718
  function pu(n, e) {
6676
- $t == null || $t.dispose();
6719
+ Dt == null || Dt.dispose();
6677
6720
  const t = wu(e), r = gu(e, a), s = bu(yu(n));
6678
6721
  function i(l) {
6679
6722
  var f;
@@ -6690,7 +6733,7 @@ function pu(n, e) {
6690
6733
  t.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", i);
6691
6734
  }
6692
6735
  function u() {
6693
- document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), $t = {
6736
+ document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), Dt = {
6694
6737
  dispose: c
6695
6738
  };
6696
6739
  }
@@ -6789,29 +6832,29 @@ function Su(n, e) {
6789
6832
  }
6790
6833
  });
6791
6834
  }
6792
- function Dt(n, e) {
6835
+ function Ut(n, e) {
6793
6836
  return new Response(JSON.stringify({ ok: !1, error: e }), {
6794
6837
  status: n,
6795
6838
  headers: { "Content-Type": "application/json" }
6796
6839
  });
6797
6840
  }
6798
- const dl = (n) => ({
6841
+ const hl = (n) => ({
6799
6842
  POST: async (e) => {
6800
6843
  let t;
6801
6844
  try {
6802
6845
  t = await e.json();
6803
6846
  } catch {
6804
- return Dt(400, "Invalid JSON body");
6847
+ return Ut(400, "Invalid JSON body");
6805
6848
  }
6806
6849
  if (!t.type)
6807
- return Dt(400, 'Missing "type" field');
6850
+ return Ut(400, 'Missing "type" field');
6808
6851
  if (t.appId !== n.appId)
6809
- return Dt(403, "App ID mismatch");
6852
+ return Ut(403, "App ID mismatch");
6810
6853
  switch (t.type) {
6811
6854
  case "sync-user":
6812
6855
  return Su(n, t.user ?? null);
6813
6856
  default:
6814
- return Dt(400, `Unknown type: ${t.type}`);
6857
+ return Ut(400, `Unknown type: ${t.type}`);
6815
6858
  }
6816
6859
  }
6817
6860
  });
@@ -6848,157 +6891,157 @@ const Tu = (n) => JSON.stringify(n), gt = (n, e = !1) => JSON.stringify([n, e]),
6848
6891
  ...Array.from(n.values()).flatMap((s) => s.data)
6849
6892
  ];
6850
6893
  return { chunks: t, data: r };
6851
- }, mn = ["bootstrap", "bootstrap", "bootstrap", 1], ku = (n, e, t, r) => {
6894
+ }, mn = ["bootstrap", "bootstrap", "bootstrap", 1], Au = (n, e, t, r) => {
6852
6895
  var G, V, ne, q;
6853
6896
  const { entityName: s, entityQuery: i } = oi(e), o = ((G = i.$) == null ? void 0 : G.limit) || 10, a = s, c = ii((V = i.$) == null ? void 0 : V.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
6854
- let d = !1, y = !0, b = null, g = null;
6855
- const m = (k) => {
6897
+ let d = !1, b = !0, y = null, g = null;
6898
+ const _ = (k) => {
6856
6899
  t({ error: k, data: void 0, canLoadNextPage: !1 });
6857
- }, T = () => {
6858
- if (!y)
6900
+ }, S = () => {
6901
+ if (!b)
6859
6902
  return;
6860
- const { chunks: k, data: j } = Ou(u, l);
6903
+ const { chunks: k, data: x } = Ou(u, l);
6861
6904
  t({
6862
- data: { [a]: j },
6905
+ data: { [a]: x },
6863
6906
  // @ts-expect-error hidden debug variable
6864
6907
  chunks: k,
6865
6908
  canLoadNextPage: Eu(u)
6866
6909
  });
6867
- }, _ = (k, j) => {
6868
- u.set(gt(k, j.afterInclusive), j), T();
6869
- }, w = (k, j) => {
6870
- l.set(gt(k), j), P(), T();
6871
- }, C = (k, j) => {
6872
- var O, A;
6873
- const { cursor: R } = ns(k), F = f.get(He("reverse", R));
6874
- F == null || F();
6875
- const N = n.subscribeQuery({
6910
+ }, m = (k, x) => {
6911
+ u.set(gt(k, x.afterInclusive), x), S();
6912
+ }, w = (k, x) => {
6913
+ l.set(gt(k), x), R(), S();
6914
+ }, A = (k, x) => {
6915
+ var E, C;
6916
+ const { cursor: j } = ns(k), D = f.get(He("reverse", j));
6917
+ D == null || D();
6918
+ const K = n.subscribeQuery({
6876
6919
  [a]: {
6877
6920
  ...i,
6878
6921
  $: {
6879
- after: R,
6880
- before: j.endCursor,
6922
+ after: j,
6923
+ before: x.endCursor,
6881
6924
  beforeInclusive: !0,
6882
- where: (O = i.$) == null ? void 0 : O.where,
6883
- fields: (A = i.$) == null ? void 0 : A.fields,
6925
+ where: (E = i.$) == null ? void 0 : E.where,
6926
+ fields: (C = i.$) == null ? void 0 : C.fields,
6884
6927
  order: rs(c)
6885
6928
  }
6886
6929
  }
6887
6930
  }, (W) => {
6888
6931
  if (W.error)
6889
- return m(W.error);
6932
+ return _(W.error);
6890
6933
  const J = W.data[a], X = W.pageInfo[a];
6891
- lt(J && X, "Expected query subscription to contain rows and pageInfo"), w(R, {
6934
+ lt(J && X, "Expected query subscription to contain rows and pageInfo"), w(j, {
6892
6935
  data: J,
6893
6936
  status: "frozen",
6894
6937
  hasMore: X.hasNextPage,
6895
6938
  endCursor: X.endCursor
6896
6939
  });
6897
6940
  }, r);
6898
- f.set(He("reverse", R), N);
6899
- }, v = (k) => {
6900
- var R, F;
6901
- const j = n.subscribeQuery({
6941
+ f.set(He("reverse", j), K);
6942
+ }, O = (k) => {
6943
+ var j, D;
6944
+ const x = n.subscribeQuery({
6902
6945
  [a]: {
6903
6946
  ...i,
6904
6947
  $: {
6905
6948
  limit: o,
6906
6949
  after: k,
6907
- where: (R = i.$) == null ? void 0 : R.where,
6908
- fields: (F = i.$) == null ? void 0 : F.fields,
6950
+ where: (j = i.$) == null ? void 0 : j.where,
6951
+ fields: (D = i.$) == null ? void 0 : D.fields,
6909
6952
  order: rs(c)
6910
6953
  }
6911
6954
  }
6912
- }, (N) => {
6913
- if (N.error)
6914
- return m(N.error);
6915
- const O = N.data[a], A = N.pageInfo[a];
6916
- lt(O && A, "Expected rows and pageInfo"), w(k, {
6917
- data: O,
6955
+ }, (K) => {
6956
+ if (K.error)
6957
+ return _(K.error);
6958
+ const E = K.data[a], C = K.pageInfo[a];
6959
+ lt(E && C, "Expected rows and pageInfo"), w(k, {
6960
+ data: E,
6918
6961
  status: "bootstrapping",
6919
- hasMore: A.hasNextPage,
6920
- endCursor: A.endCursor
6962
+ hasMore: C.hasNextPage,
6963
+ endCursor: C.endCursor
6921
6964
  });
6922
6965
  }, r);
6923
- f.set(He("reverse", k), j);
6924
- }, U = (k, j = !1) => {
6925
- var F, N;
6926
- const R = n.subscribeQuery({
6966
+ f.set(He("reverse", k), x);
6967
+ }, M = (k, x = !1) => {
6968
+ var D, K;
6969
+ const j = n.subscribeQuery({
6927
6970
  [a]: {
6928
6971
  ...i,
6929
6972
  $: {
6930
6973
  limit: o,
6931
6974
  after: k,
6932
- afterInclusive: j,
6933
- where: (F = i.$) == null ? void 0 : F.where,
6934
- fields: (N = i.$) == null ? void 0 : N.fields,
6975
+ afterInclusive: x,
6976
+ where: (D = i.$) == null ? void 0 : D.where,
6977
+ fields: (K = i.$) == null ? void 0 : K.fields,
6935
6978
  order: c
6936
6979
  }
6937
6980
  }
6938
- }, (O) => {
6939
- if (O.error)
6940
- return m(O.error);
6941
- const A = O.data[a], W = O.pageInfo[a];
6942
- lt(A && W, "Page info and rows"), _(k, {
6943
- data: A,
6981
+ }, (E) => {
6982
+ if (E.error)
6983
+ return _(E.error);
6984
+ const C = E.data[a], W = E.pageInfo[a];
6985
+ lt(C && W, "Page info and rows"), m(k, {
6986
+ data: C,
6944
6987
  status: "bootstrapping",
6945
6988
  hasMore: W.hasNextPage,
6946
6989
  endCursor: W.endCursor,
6947
- afterInclusive: j
6990
+ afterInclusive: x
6948
6991
  });
6949
6992
  }, r);
6950
- f.set(He("forward", k, j), R);
6951
- }, I = (k, j = !1) => {
6952
- var A, W;
6953
- const R = gt(k, j), F = f.get(He("forward", k, j));
6954
- F == null || F();
6955
- const N = u.get(R);
6956
- if (!(N != null && N.endCursor))
6993
+ f.set(He("forward", k, x), j);
6994
+ }, I = (k, x = !1) => {
6995
+ var C, W;
6996
+ const j = gt(k, x), D = f.get(He("forward", k, x));
6997
+ D == null || D();
6998
+ const K = u.get(j);
6999
+ if (!(K != null && K.endCursor))
6957
7000
  return;
6958
- const O = n.subscribeQuery({
7001
+ const E = n.subscribeQuery({
6959
7002
  [a]: {
6960
7003
  ...i,
6961
7004
  $: {
6962
7005
  after: k,
6963
- afterInclusive: N.afterInclusive,
6964
- before: N.endCursor,
7006
+ afterInclusive: K.afterInclusive,
7007
+ before: K.endCursor,
6965
7008
  beforeInclusive: !0,
6966
- where: (A = i.$) == null ? void 0 : A.where,
7009
+ where: (C = i.$) == null ? void 0 : C.where,
6967
7010
  fields: (W = i.$) == null ? void 0 : W.fields,
6968
7011
  order: c
6969
7012
  }
6970
7013
  }
6971
7014
  }, (J) => {
6972
7015
  if (J.error)
6973
- return m(J.error);
7016
+ return _(J.error);
6974
7017
  const X = J.data[a], le = J.pageInfo[a];
6975
- lt(X && le, "Expected rows and pageInfo"), _(k, {
7018
+ lt(X && le, "Expected rows and pageInfo"), m(k, {
6976
7019
  data: X,
6977
7020
  status: "frozen",
6978
7021
  hasMore: le.hasNextPage,
6979
7022
  endCursor: le.endCursor,
6980
- afterInclusive: N.afterInclusive
7023
+ afterInclusive: K.afterInclusive
6981
7024
  });
6982
7025
  }, r);
6983
- f.set(He("forward", k, j), O);
6984
- }, P = () => {
7026
+ f.set(He("forward", k, x), E);
7027
+ }, R = () => {
6985
7028
  const k = Array.from(l.entries()).at(-1);
6986
7029
  if (!k)
6987
7030
  return;
6988
- const [j, R] = k;
6989
- if (!(R != null && R.hasMore) || !vu(R))
7031
+ const [x, j] = k;
7032
+ if (!(j != null && j.hasMore) || !vu(j))
6990
7033
  return;
6991
- const F = `${j}:${Tu(R.endCursor)}`;
6992
- F != b && (b = F, C(j, R), v(R.endCursor));
7034
+ const D = `${x}:${Tu(j.endCursor)}`;
7035
+ D != y && (y = D, A(x, j), O(j.endCursor));
6993
7036
  }, H = () => {
6994
7037
  const k = Array.from(u.entries()).at(-1);
6995
7038
  if (!k)
6996
7039
  return;
6997
- const [j, R] = k;
6998
- if (!R.endCursor)
7040
+ const [x, j] = k;
7041
+ if (!j.endCursor)
6999
7042
  return;
7000
- const { cursor: F, afterInclusive: N } = ns(j);
7001
- I(F, N), U(R.endCursor);
7043
+ const { cursor: D, afterInclusive: K } = ns(x);
7044
+ I(D, K), M(j.endCursor);
7002
7045
  };
7003
7046
  return g = n.subscribeQuery({
7004
7047
  [a]: {
@@ -7011,32 +7054,32 @@ const Tu = (n) => JSON.stringify(n), gt = (n, e = !1) => JSON.stringify([n, e]),
7011
7054
  }
7012
7055
  }
7013
7056
  }, async (k) => {
7014
- var N;
7057
+ var K;
7015
7058
  if (d)
7016
7059
  return;
7017
7060
  if (k.error)
7018
- return m(k.error);
7019
- const j = k.pageInfo[a], R = (N = k == null ? void 0 : k.data) == null ? void 0 : N[a];
7020
- if (lt(R && j, "Expected rows and pageInfo"), R.length < o) {
7021
- _(mn, {
7022
- data: R,
7061
+ return _(k.error);
7062
+ const x = k.pageInfo[a], j = (K = k == null ? void 0 : k.data) == null ? void 0 : K[a];
7063
+ if (lt(j && x, "Expected rows and pageInfo"), j.length < o) {
7064
+ m(mn, {
7065
+ data: j,
7023
7066
  status: "pre-bootstrap"
7024
7067
  });
7025
7068
  return;
7026
7069
  }
7027
- const F = j.startCursor;
7028
- if (!F) {
7029
- _(mn, {
7030
- data: R,
7070
+ const D = x.startCursor;
7071
+ if (!D) {
7072
+ m(mn, {
7073
+ data: j,
7031
7074
  status: "pre-bootstrap"
7032
7075
  });
7033
7076
  return;
7034
7077
  }
7035
- u.delete(gt(mn)), U(F, !0), v(j.startCursor), d = !0;
7078
+ u.delete(gt(mn)), M(D, !0), O(x.startCursor), d = !0;
7036
7079
  }, r), {
7037
7080
  unsubscribe: () => {
7038
- if (y) {
7039
- y = !1, g == null || g(), g = null;
7081
+ if (b) {
7082
+ b = !1, g == null || g(), g = null;
7040
7083
  for (const k of f.values())
7041
7084
  k == null || k();
7042
7085
  f.clear();
@@ -7081,7 +7124,7 @@ const Tu = (n) => JSON.stringify(n), gt = (n, e = !1) => JSON.stringify([n, e]),
7081
7124
  if (!t || !r)
7082
7125
  throw new B("No query provided for infinite query");
7083
7126
  return { entityName: t, entityQuery: r };
7084
- }, Au = {
7127
+ }, ku = {
7085
7128
  apiURI: "https://api.instantdb.com",
7086
7129
  websocketURI: "wss://api.instantdb.com/runtime/session"
7087
7130
  };
@@ -7213,7 +7256,7 @@ class Pu {
7213
7256
  this.db = e;
7214
7257
  }
7215
7258
  }
7216
- class Mu {
7259
+ class Ru {
7217
7260
  constructor(e) {
7218
7261
  p(this, "db");
7219
7262
  /**
@@ -7271,7 +7314,7 @@ class Mu {
7271
7314
  this.db = e;
7272
7315
  }
7273
7316
  }
7274
- class Ru {
7317
+ class Mu {
7275
7318
  constructor(e) {
7276
7319
  p(this, "db");
7277
7320
  /**
@@ -7307,7 +7350,7 @@ class ju {
7307
7350
  p(this, "storage");
7308
7351
  p(this, "streams");
7309
7352
  p(this, "tx", ir());
7310
- this._reactor = e, this.auth = new Pu(this._reactor), this.storage = new Mu(this._reactor), this.streams = new Ru(this._reactor);
7353
+ this._reactor = e, this.auth = new Pu(this._reactor), this.storage = new Ru(this._reactor), this.streams = new Mu(this._reactor);
7311
7354
  }
7312
7355
  /**
7313
7356
  * Use this to write data! You can create, update, delete, and link objects
@@ -7385,7 +7428,7 @@ class ju {
7385
7428
  * });
7386
7429
  */
7387
7430
  subscribeInfiniteQuery(e, t, r) {
7388
- return ku(this, e, t, r);
7431
+ return Au(this, e, t, r);
7389
7432
  }
7390
7433
  /**
7391
7434
  * Listen for the logged in state. This is useful
@@ -7441,6 +7484,20 @@ class ju {
7441
7484
  subscribeConnectionStatus(e) {
7442
7485
  return this._reactor.subscribeConnectionStatus(e);
7443
7486
  }
7487
+ /**
7488
+ * Observe the app's maintenance-mode state. While read-only, reads and
7489
+ * live queries keep working but writes are rejected. The callback fires
7490
+ * immediately with the current state and again on every change.
7491
+ *
7492
+ * @example
7493
+ * const unsub = db.subscribeAppStatus(({ isLoading, isReadOnly }) => {
7494
+ * if (isLoading) return;
7495
+ * if (isReadOnly) showMaintenanceBanner();
7496
+ * });
7497
+ */
7498
+ subscribeAppStatus(e) {
7499
+ return this._reactor.subscribeAppStatus(e);
7500
+ }
7444
7501
  /**
7445
7502
  * Join a room to publish and subscribe to topics and presence.
7446
7503
  *
@@ -7509,7 +7566,7 @@ function os(n) {
7509
7566
  const e = is.get(n);
7510
7567
  if (e)
7511
7568
  return e;
7512
- const t = ce(n);
7569
+ const t = ue(n);
7513
7570
  return is.set(n, t), t;
7514
7571
  }
7515
7572
  function xu(n, e) {
@@ -7525,7 +7582,7 @@ function $u(n, e, t, r, s) {
7525
7582
  if (o)
7526
7583
  return xu(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7527
7584
  const a = new su({
7528
- ...Au,
7585
+ ...ku,
7529
7586
  ...i,
7530
7587
  cardinalityInference: !!i.schema
7531
7588
  }, e || Bs, t || Gs, { ...r || {}, "@instantdb/core": ar }, s), c = new ju(a);
@@ -7557,11 +7614,11 @@ function Uu() {
7557
7614
  as = 1;
7558
7615
  var n = ys, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
7559
7616
  function o(a, c, u) {
7560
- var l, f = {}, d = null, y = null;
7561
- u !== void 0 && (d = "" + u), c.key !== void 0 && (d = "" + c.key), c.ref !== void 0 && (y = c.ref);
7617
+ var l, f = {}, d = null, b = null;
7618
+ u !== void 0 && (d = "" + u), c.key !== void 0 && (d = "" + c.key), c.ref !== void 0 && (b = c.ref);
7562
7619
  for (l in c) r.call(c, l) && !i.hasOwnProperty(l) && (f[l] = c[l]);
7563
7620
  if (a && a.defaultProps) for (l in c = a.defaultProps, c) f[l] === void 0 && (f[l] = c[l]);
7564
- return { $$typeof: e, type: a, key: d, ref: y, props: f, _owner: s.current };
7621
+ return { $$typeof: e, type: a, key: d, ref: b, props: f, _owner: s.current };
7565
7622
  }
7566
7623
  return ft.Fragment = t, ft.jsx = o, ft.jsxs = o, ft;
7567
7624
  }
@@ -7580,46 +7637,46 @@ function Lu() {
7580
7637
  * LICENSE file in the root directory of this source tree.
7581
7638
  */
7582
7639
  return n.NODE_ENV !== "production" && function() {
7583
- var e = ys, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, m = "@@iterator";
7584
- function T(h) {
7640
+ var e = ys, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), d = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), g = Symbol.iterator, _ = "@@iterator";
7641
+ function S(h) {
7585
7642
  if (h === null || typeof h != "object")
7586
7643
  return null;
7587
- var S = g && h[g] || h[m];
7588
- return typeof S == "function" ? S : null;
7644
+ var T = g && h[g] || h[_];
7645
+ return typeof T == "function" ? T : null;
7589
7646
  }
7590
- var _ = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
7647
+ var m = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
7591
7648
  function w(h) {
7592
7649
  {
7593
- for (var S = arguments.length, E = new Array(S > 1 ? S - 1 : 0), M = 1; M < S; M++)
7594
- E[M - 1] = arguments[M];
7595
- C("error", h, E);
7650
+ for (var T = arguments.length, v = new Array(T > 1 ? T - 1 : 0), P = 1; P < T; P++)
7651
+ v[P - 1] = arguments[P];
7652
+ A("error", h, v);
7596
7653
  }
7597
7654
  }
7598
- function C(h, S, E) {
7655
+ function A(h, T, v) {
7599
7656
  {
7600
- var M = _.ReactDebugCurrentFrame, z = M.getStackAddendum();
7601
- z !== "" && (S += "%s", E = E.concat([z]));
7602
- var Q = E.map(function(L) {
7603
- return String(L);
7657
+ var P = m.ReactDebugCurrentFrame, z = P.getStackAddendum();
7658
+ z !== "" && (T += "%s", v = v.concat([z]));
7659
+ var Q = v.map(function(N) {
7660
+ return String(N);
7604
7661
  });
7605
- Q.unshift("Warning: " + S), Function.prototype.apply.call(console[h], console, Q);
7662
+ Q.unshift("Warning: " + T), Function.prototype.apply.call(console[h], console, Q);
7606
7663
  }
7607
7664
  }
7608
- var v = !1, U = !1, I = !1, P = !1, H = !1, K;
7609
- K = Symbol.for("react.module.reference");
7665
+ var O = !1, M = !1, I = !1, R = !1, H = !1, F;
7666
+ F = Symbol.for("react.module.reference");
7610
7667
  function G(h) {
7611
- return !!(typeof h == "string" || typeof h == "function" || h === s || h === o || H || h === i || h === l || h === f || P || h === b || v || U || I || typeof h == "object" && h !== null && (h.$$typeof === y || h.$$typeof === d || h.$$typeof === a || h.$$typeof === c || h.$$typeof === u || // This needs to include all possible module reference object
7668
+ return !!(typeof h == "string" || typeof h == "function" || h === s || h === o || H || h === i || h === l || h === f || R || h === y || O || M || I || typeof h == "object" && h !== null && (h.$$typeof === b || h.$$typeof === d || h.$$typeof === a || h.$$typeof === c || h.$$typeof === u || // This needs to include all possible module reference object
7612
7669
  // types supported by any Flight configuration anywhere since
7613
7670
  // we don't know which Flight build this will end up being used
7614
7671
  // with.
7615
- h.$$typeof === K || h.getModuleId !== void 0));
7672
+ h.$$typeof === F || h.getModuleId !== void 0));
7616
7673
  }
7617
- function V(h, S, E) {
7618
- var M = h.displayName;
7619
- if (M)
7620
- return M;
7621
- var z = S.displayName || S.name || "";
7622
- return z !== "" ? E + "(" + z + ")" : E;
7674
+ function V(h, T, v) {
7675
+ var P = h.displayName;
7676
+ if (P)
7677
+ return P;
7678
+ var z = T.displayName || T.name || "";
7679
+ return z !== "" ? v + "(" + z + ")" : v;
7623
7680
  }
7624
7681
  function ne(h) {
7625
7682
  return h.displayName || "Context";
@@ -7648,20 +7705,20 @@ function Lu() {
7648
7705
  if (typeof h == "object")
7649
7706
  switch (h.$$typeof) {
7650
7707
  case c:
7651
- var S = h;
7652
- return ne(S) + ".Consumer";
7708
+ var T = h;
7709
+ return ne(T) + ".Consumer";
7653
7710
  case a:
7654
- var E = h;
7655
- return ne(E._context) + ".Provider";
7711
+ var v = h;
7712
+ return ne(v._context) + ".Provider";
7656
7713
  case u:
7657
7714
  return V(h, h.render, "ForwardRef");
7658
7715
  case d:
7659
- var M = h.displayName || null;
7660
- return M !== null ? M : q(h.type) || "Memo";
7661
- case y: {
7662
- var z = h, Q = z._payload, L = z._init;
7716
+ var P = h.displayName || null;
7717
+ return P !== null ? P : q(h.type) || "Memo";
7718
+ case b: {
7719
+ var z = h, Q = z._payload, N = z._init;
7663
7720
  try {
7664
- return q(L(Q));
7721
+ return q(N(Q));
7665
7722
  } catch {
7666
7723
  return null;
7667
7724
  }
@@ -7669,14 +7726,14 @@ function Lu() {
7669
7726
  }
7670
7727
  return null;
7671
7728
  }
7672
- var k = Object.assign, j = 0, R, F, N, O, A, W, J;
7729
+ var k = Object.assign, x = 0, j, D, K, E, C, W, J;
7673
7730
  function X() {
7674
7731
  }
7675
7732
  X.__reactDisabledLog = !0;
7676
7733
  function le() {
7677
7734
  {
7678
- if (j === 0) {
7679
- R = console.log, F = console.info, N = console.warn, O = console.error, A = console.group, W = console.groupCollapsed, J = console.groupEnd;
7735
+ if (x === 0) {
7736
+ j = console.log, D = console.info, K = console.warn, E = console.error, C = console.group, W = console.groupCollapsed, J = console.groupEnd;
7680
7737
  var h = {
7681
7738
  configurable: !0,
7682
7739
  enumerable: !0,
@@ -7693,12 +7750,12 @@ function Lu() {
7693
7750
  groupEnd: h
7694
7751
  });
7695
7752
  }
7696
- j++;
7753
+ x++;
7697
7754
  }
7698
7755
  }
7699
7756
  function ct() {
7700
7757
  {
7701
- if (j--, j === 0) {
7758
+ if (x--, x === 0) {
7702
7759
  var h = {
7703
7760
  configurable: !0,
7704
7761
  enumerable: !0,
@@ -7706,19 +7763,19 @@ function Lu() {
7706
7763
  };
7707
7764
  Object.defineProperties(console, {
7708
7765
  log: k({}, h, {
7709
- value: R
7766
+ value: j
7710
7767
  }),
7711
7768
  info: k({}, h, {
7712
- value: F
7769
+ value: D
7713
7770
  }),
7714
7771
  warn: k({}, h, {
7715
- value: N
7772
+ value: K
7716
7773
  }),
7717
7774
  error: k({}, h, {
7718
- value: O
7775
+ value: E
7719
7776
  }),
7720
7777
  group: k({}, h, {
7721
- value: A
7778
+ value: C
7722
7779
  }),
7723
7780
  groupCollapsed: k({}, h, {
7724
7781
  value: W
@@ -7728,88 +7785,88 @@ function Lu() {
7728
7785
  })
7729
7786
  });
7730
7787
  }
7731
- j < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
7788
+ x < 0 && w("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
7732
7789
  }
7733
7790
  }
7734
- var ve = _.ReactCurrentDispatcher, rn;
7735
- function At(h, S, E) {
7791
+ var ve = m.ReactCurrentDispatcher, rn;
7792
+ function Ct(h, T, v) {
7736
7793
  {
7737
7794
  if (rn === void 0)
7738
7795
  try {
7739
7796
  throw Error();
7740
7797
  } catch (z) {
7741
- var M = z.stack.trim().match(/\n( *(at )?)/);
7742
- rn = M && M[1] || "";
7798
+ var P = z.stack.trim().match(/\n( *(at )?)/);
7799
+ rn = P && P[1] || "";
7743
7800
  }
7744
7801
  return `
7745
7802
  ` + rn + h;
7746
7803
  }
7747
7804
  }
7748
- var sn = !1, Ct;
7805
+ var sn = !1, It;
7749
7806
  {
7750
7807
  var li = typeof WeakMap == "function" ? WeakMap : Map;
7751
- Ct = new li();
7808
+ It = new li();
7752
7809
  }
7753
- function ur(h, S) {
7810
+ function ur(h, T) {
7754
7811
  if (!h || sn)
7755
7812
  return "";
7756
7813
  {
7757
- var E = Ct.get(h);
7758
- if (E !== void 0)
7759
- return E;
7814
+ var v = It.get(h);
7815
+ if (v !== void 0)
7816
+ return v;
7760
7817
  }
7761
- var M;
7818
+ var P;
7762
7819
  sn = !0;
7763
7820
  var z = Error.prepareStackTrace;
7764
7821
  Error.prepareStackTrace = void 0;
7765
7822
  var Q;
7766
7823
  Q = ve.current, ve.current = null, le();
7767
7824
  try {
7768
- if (S) {
7769
- var L = function() {
7825
+ if (T) {
7826
+ var N = function() {
7770
7827
  throw Error();
7771
7828
  };
7772
- if (Object.defineProperty(L.prototype, "props", {
7829
+ if (Object.defineProperty(N.prototype, "props", {
7773
7830
  set: function() {
7774
7831
  throw Error();
7775
7832
  }
7776
7833
  }), typeof Reflect == "object" && Reflect.construct) {
7777
7834
  try {
7778
- Reflect.construct(L, []);
7835
+ Reflect.construct(N, []);
7779
7836
  } catch (pe) {
7780
- M = pe;
7837
+ P = pe;
7781
7838
  }
7782
- Reflect.construct(h, [], L);
7839
+ Reflect.construct(h, [], N);
7783
7840
  } else {
7784
7841
  try {
7785
- L.call();
7842
+ N.call();
7786
7843
  } catch (pe) {
7787
- M = pe;
7844
+ P = pe;
7788
7845
  }
7789
- h.call(L.prototype);
7846
+ h.call(N.prototype);
7790
7847
  }
7791
7848
  } else {
7792
7849
  try {
7793
7850
  throw Error();
7794
7851
  } catch (pe) {
7795
- M = pe;
7852
+ P = pe;
7796
7853
  }
7797
7854
  h();
7798
7855
  }
7799
7856
  } catch (pe) {
7800
- if (pe && M && typeof pe.stack == "string") {
7801
- for (var $ = pe.stack.split(`
7802
- `), fe = M.stack.split(`
7803
- `), ee = $.length - 1, re = fe.length - 1; ee >= 1 && re >= 0 && $[ee] !== fe[re]; )
7857
+ if (pe && P && typeof pe.stack == "string") {
7858
+ for (var U = pe.stack.split(`
7859
+ `), fe = P.stack.split(`
7860
+ `), ee = U.length - 1, re = fe.length - 1; ee >= 1 && re >= 0 && U[ee] !== fe[re]; )
7804
7861
  re--;
7805
7862
  for (; ee >= 1 && re >= 0; ee--, re--)
7806
- if ($[ee] !== fe[re]) {
7863
+ if (U[ee] !== fe[re]) {
7807
7864
  if (ee !== 1 || re !== 1)
7808
7865
  do
7809
- if (ee--, re--, re < 0 || $[ee] !== fe[re]) {
7866
+ if (ee--, re--, re < 0 || U[ee] !== fe[re]) {
7810
7867
  var Se = `
7811
- ` + $[ee].replace(" at new ", " at ");
7812
- return h.displayName && Se.includes("<anonymous>") && (Se = Se.replace("<anonymous>", h.displayName)), typeof h == "function" && Ct.set(h, Se), Se;
7868
+ ` + U[ee].replace(" at new ", " at ");
7869
+ return h.displayName && Se.includes("<anonymous>") && (Se = Se.replace("<anonymous>", h.displayName)), typeof h == "function" && It.set(h, Se), Se;
7813
7870
  }
7814
7871
  while (ee >= 1 && re >= 0);
7815
7872
  break;
@@ -7818,69 +7875,69 @@ function Lu() {
7818
7875
  } finally {
7819
7876
  sn = !1, ve.current = Q, ct(), Error.prepareStackTrace = z;
7820
7877
  }
7821
- var Be = h ? h.displayName || h.name : "", De = Be ? At(Be) : "";
7822
- return typeof h == "function" && Ct.set(h, De), De;
7878
+ var Be = h ? h.displayName || h.name : "", De = Be ? Ct(Be) : "";
7879
+ return typeof h == "function" && It.set(h, De), De;
7823
7880
  }
7824
- function fi(h, S, E) {
7881
+ function fi(h, T, v) {
7825
7882
  return ur(h, !1);
7826
7883
  }
7827
7884
  function di(h) {
7828
- var S = h.prototype;
7829
- return !!(S && S.isReactComponent);
7885
+ var T = h.prototype;
7886
+ return !!(T && T.isReactComponent);
7830
7887
  }
7831
- function It(h, S, E) {
7888
+ function Pt(h, T, v) {
7832
7889
  if (h == null)
7833
7890
  return "";
7834
7891
  if (typeof h == "function")
7835
7892
  return ur(h, di(h));
7836
7893
  if (typeof h == "string")
7837
- return At(h);
7894
+ return Ct(h);
7838
7895
  switch (h) {
7839
7896
  case l:
7840
- return At("Suspense");
7897
+ return Ct("Suspense");
7841
7898
  case f:
7842
- return At("SuspenseList");
7899
+ return Ct("SuspenseList");
7843
7900
  }
7844
7901
  if (typeof h == "object")
7845
7902
  switch (h.$$typeof) {
7846
7903
  case u:
7847
7904
  return fi(h.render);
7848
7905
  case d:
7849
- return It(h.type, S, E);
7850
- case y: {
7851
- var M = h, z = M._payload, Q = M._init;
7906
+ return Pt(h.type, T, v);
7907
+ case b: {
7908
+ var P = h, z = P._payload, Q = P._init;
7852
7909
  try {
7853
- return It(Q(z), S, E);
7910
+ return Pt(Q(z), T, v);
7854
7911
  } catch {
7855
7912
  }
7856
7913
  }
7857
7914
  }
7858
7915
  return "";
7859
7916
  }
7860
- var ut = Object.prototype.hasOwnProperty, lr = {}, fr = _.ReactDebugCurrentFrame;
7861
- function Pt(h) {
7917
+ var ut = Object.prototype.hasOwnProperty, lr = {}, fr = m.ReactDebugCurrentFrame;
7918
+ function Rt(h) {
7862
7919
  if (h) {
7863
- var S = h._owner, E = It(h.type, h._source, S ? S.type : null);
7864
- fr.setExtraStackFrame(E);
7920
+ var T = h._owner, v = Pt(h.type, h._source, T ? T.type : null);
7921
+ fr.setExtraStackFrame(v);
7865
7922
  } else
7866
7923
  fr.setExtraStackFrame(null);
7867
7924
  }
7868
- function hi(h, S, E, M, z) {
7925
+ function hi(h, T, v, P, z) {
7869
7926
  {
7870
7927
  var Q = Function.call.bind(ut);
7871
- for (var L in h)
7872
- if (Q(h, L)) {
7873
- var $ = void 0;
7928
+ for (var N in h)
7929
+ if (Q(h, N)) {
7930
+ var U = void 0;
7874
7931
  try {
7875
- if (typeof h[L] != "function") {
7876
- var fe = Error((M || "React class") + ": " + E + " type `" + L + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof h[L] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
7932
+ if (typeof h[N] != "function") {
7933
+ var fe = Error((P || "React class") + ": " + v + " type `" + N + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof h[N] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
7877
7934
  throw fe.name = "Invariant Violation", fe;
7878
7935
  }
7879
- $ = h[L](S, L, M, E, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
7936
+ U = h[N](T, N, P, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
7880
7937
  } catch (ee) {
7881
- $ = ee;
7938
+ U = ee;
7882
7939
  }
7883
- $ && !($ instanceof Error) && (Pt(z), w("%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).", M || "React class", E, L, typeof $), Pt(null)), $ instanceof Error && !($.message in lr) && (lr[$.message] = !0, Pt(z), w("Failed %s type: %s", E, $.message), Pt(null));
7940
+ U && !(U instanceof Error) && (Rt(z), w("%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).", P || "React class", v, N, typeof U), Rt(null)), U instanceof Error && !(U.message in lr) && (lr[U.message] = !0, Rt(z), w("Failed %s type: %s", v, U.message), Rt(null));
7884
7941
  }
7885
7942
  }
7886
7943
  }
@@ -7890,8 +7947,8 @@ function Lu() {
7890
7947
  }
7891
7948
  function yi(h) {
7892
7949
  {
7893
- var S = typeof Symbol == "function" && Symbol.toStringTag, E = S && h[Symbol.toStringTag] || h.constructor.name || "Object";
7894
- return E;
7950
+ var T = typeof Symbol == "function" && Symbol.toStringTag, v = T && h[Symbol.toStringTag] || h.constructor.name || "Object";
7951
+ return v;
7895
7952
  }
7896
7953
  }
7897
7954
  function bi(h) {
@@ -7908,7 +7965,7 @@ function Lu() {
7908
7965
  if (bi(h))
7909
7966
  return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", yi(h)), dr(h);
7910
7967
  }
7911
- var pr = _.ReactCurrentOwner, gi = {
7968
+ var pr = m.ReactCurrentOwner, gi = {
7912
7969
  key: !0,
7913
7970
  ref: !0,
7914
7971
  __self: !0,
@@ -7916,97 +7973,97 @@ function Lu() {
7916
7973
  }, yr, br;
7917
7974
  function _i(h) {
7918
7975
  if (ut.call(h, "ref")) {
7919
- var S = Object.getOwnPropertyDescriptor(h, "ref").get;
7920
- if (S && S.isReactWarning)
7976
+ var T = Object.getOwnPropertyDescriptor(h, "ref").get;
7977
+ if (T && T.isReactWarning)
7921
7978
  return !1;
7922
7979
  }
7923
7980
  return h.ref !== void 0;
7924
7981
  }
7925
7982
  function mi(h) {
7926
7983
  if (ut.call(h, "key")) {
7927
- var S = Object.getOwnPropertyDescriptor(h, "key").get;
7928
- if (S && S.isReactWarning)
7984
+ var T = Object.getOwnPropertyDescriptor(h, "key").get;
7985
+ if (T && T.isReactWarning)
7929
7986
  return !1;
7930
7987
  }
7931
7988
  return h.key !== void 0;
7932
7989
  }
7933
- function wi(h, S) {
7990
+ function wi(h, T) {
7934
7991
  typeof h.ref == "string" && pr.current;
7935
7992
  }
7936
- function Si(h, S) {
7993
+ function Si(h, T) {
7937
7994
  {
7938
- var E = function() {
7939
- yr || (yr = !0, w("%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)", S));
7995
+ var v = function() {
7996
+ yr || (yr = !0, w("%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));
7940
7997
  };
7941
- E.isReactWarning = !0, Object.defineProperty(h, "key", {
7942
- get: E,
7998
+ v.isReactWarning = !0, Object.defineProperty(h, "key", {
7999
+ get: v,
7943
8000
  configurable: !0
7944
8001
  });
7945
8002
  }
7946
8003
  }
7947
- function Ti(h, S) {
8004
+ function Ti(h, T) {
7948
8005
  {
7949
- var E = function() {
7950
- br || (br = !0, w("%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)", S));
8006
+ var v = function() {
8007
+ br || (br = !0, w("%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));
7951
8008
  };
7952
- E.isReactWarning = !0, Object.defineProperty(h, "ref", {
7953
- get: E,
8009
+ v.isReactWarning = !0, Object.defineProperty(h, "ref", {
8010
+ get: v,
7954
8011
  configurable: !0
7955
8012
  });
7956
8013
  }
7957
8014
  }
7958
- var vi = function(h, S, E, M, z, Q, L) {
7959
- var $ = {
8015
+ var vi = function(h, T, v, P, z, Q, N) {
8016
+ var U = {
7960
8017
  // This tag allows us to uniquely identify this as a React Element
7961
8018
  $$typeof: t,
7962
8019
  // Built-in properties that belong on the element
7963
8020
  type: h,
7964
- key: S,
7965
- ref: E,
7966
- props: L,
8021
+ key: T,
8022
+ ref: v,
8023
+ props: N,
7967
8024
  // Record the component responsible for creating this element.
7968
8025
  _owner: Q
7969
8026
  };
7970
- return $._store = {}, Object.defineProperty($._store, "validated", {
8027
+ return U._store = {}, Object.defineProperty(U._store, "validated", {
7971
8028
  configurable: !1,
7972
8029
  enumerable: !1,
7973
8030
  writable: !0,
7974
8031
  value: !1
7975
- }), Object.defineProperty($, "_self", {
8032
+ }), Object.defineProperty(U, "_self", {
7976
8033
  configurable: !1,
7977
8034
  enumerable: !1,
7978
8035
  writable: !1,
7979
- value: M
7980
- }), Object.defineProperty($, "_source", {
8036
+ value: P
8037
+ }), Object.defineProperty(U, "_source", {
7981
8038
  configurable: !1,
7982
8039
  enumerable: !1,
7983
8040
  writable: !1,
7984
8041
  value: z
7985
- }), Object.freeze && (Object.freeze($.props), Object.freeze($)), $;
8042
+ }), Object.freeze && (Object.freeze(U.props), Object.freeze(U)), U;
7986
8043
  };
7987
- function Ei(h, S, E, M, z) {
8044
+ function Ei(h, T, v, P, z) {
7988
8045
  {
7989
- var Q, L = {}, $ = null, fe = null;
7990
- E !== void 0 && (hr(E), $ = "" + E), mi(S) && (hr(S.key), $ = "" + S.key), _i(S) && (fe = S.ref, wi(S, z));
7991
- for (Q in S)
7992
- ut.call(S, Q) && !gi.hasOwnProperty(Q) && (L[Q] = S[Q]);
8046
+ var Q, N = {}, U = null, fe = null;
8047
+ v !== void 0 && (hr(v), U = "" + v), mi(T) && (hr(T.key), U = "" + T.key), _i(T) && (fe = T.ref, wi(T, z));
8048
+ for (Q in T)
8049
+ ut.call(T, Q) && !gi.hasOwnProperty(Q) && (N[Q] = T[Q]);
7993
8050
  if (h && h.defaultProps) {
7994
8051
  var ee = h.defaultProps;
7995
8052
  for (Q in ee)
7996
- L[Q] === void 0 && (L[Q] = ee[Q]);
8053
+ N[Q] === void 0 && (N[Q] = ee[Q]);
7997
8054
  }
7998
- if ($ || fe) {
8055
+ if (U || fe) {
7999
8056
  var re = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
8000
- $ && Si(L, re), fe && Ti(L, re);
8057
+ U && Si(N, re), fe && Ti(N, re);
8001
8058
  }
8002
- return vi(h, $, fe, z, M, pr.current, L);
8059
+ return vi(h, U, fe, z, P, pr.current, N);
8003
8060
  }
8004
8061
  }
8005
- var an = _.ReactCurrentOwner, gr = _.ReactDebugCurrentFrame;
8062
+ var an = m.ReactCurrentOwner, gr = m.ReactDebugCurrentFrame;
8006
8063
  function Qe(h) {
8007
8064
  if (h) {
8008
- var S = h._owner, E = It(h.type, h._source, S ? S.type : null);
8009
- gr.setExtraStackFrame(E);
8065
+ var T = h._owner, v = Pt(h.type, h._source, T ? T.type : null);
8066
+ gr.setExtraStackFrame(v);
8010
8067
  } else
8011
8068
  gr.setExtraStackFrame(null);
8012
8069
  }
@@ -8031,81 +8088,81 @@ Check the render method of \`` + h + "`.";
8031
8088
  return "";
8032
8089
  }
8033
8090
  var mr = {};
8034
- function ki(h) {
8091
+ function Ai(h) {
8035
8092
  {
8036
- var S = _r();
8037
- if (!S) {
8038
- var E = typeof h == "string" ? h : h.displayName || h.name;
8039
- E && (S = `
8093
+ var T = _r();
8094
+ if (!T) {
8095
+ var v = typeof h == "string" ? h : h.displayName || h.name;
8096
+ v && (T = `
8040
8097
 
8041
- Check the top-level render call using <` + E + ">.");
8098
+ Check the top-level render call using <` + v + ">.");
8042
8099
  }
8043
- return S;
8100
+ return T;
8044
8101
  }
8045
8102
  }
8046
- function wr(h, S) {
8103
+ function wr(h, T) {
8047
8104
  {
8048
8105
  if (!h._store || h._store.validated || h.key != null)
8049
8106
  return;
8050
8107
  h._store.validated = !0;
8051
- var E = ki(S);
8052
- if (mr[E])
8108
+ var v = Ai(T);
8109
+ if (mr[v])
8053
8110
  return;
8054
- mr[E] = !0;
8055
- var M = "";
8056
- h && h._owner && h._owner !== an.current && (M = " It was passed a child from " + q(h._owner.type) + "."), Qe(h), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', E, M), Qe(null);
8111
+ mr[v] = !0;
8112
+ var P = "";
8113
+ h && h._owner && h._owner !== an.current && (P = " It was passed a child from " + q(h._owner.type) + "."), Qe(h), w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', v, P), Qe(null);
8057
8114
  }
8058
8115
  }
8059
- function Sr(h, S) {
8116
+ function Sr(h, T) {
8060
8117
  {
8061
8118
  if (typeof h != "object")
8062
8119
  return;
8063
8120
  if (on(h))
8064
- for (var E = 0; E < h.length; E++) {
8065
- var M = h[E];
8066
- un(M) && wr(M, S);
8121
+ for (var v = 0; v < h.length; v++) {
8122
+ var P = h[v];
8123
+ un(P) && wr(P, T);
8067
8124
  }
8068
8125
  else if (un(h))
8069
8126
  h._store && (h._store.validated = !0);
8070
8127
  else if (h) {
8071
- var z = T(h);
8128
+ var z = S(h);
8072
8129
  if (typeof z == "function" && z !== h.entries)
8073
- for (var Q = z.call(h), L; !(L = Q.next()).done; )
8074
- un(L.value) && wr(L.value, S);
8130
+ for (var Q = z.call(h), N; !(N = Q.next()).done; )
8131
+ un(N.value) && wr(N.value, T);
8075
8132
  }
8076
8133
  }
8077
8134
  }
8078
- function Ai(h) {
8135
+ function ki(h) {
8079
8136
  {
8080
- var S = h.type;
8081
- if (S == null || typeof S == "string")
8137
+ var T = h.type;
8138
+ if (T == null || typeof T == "string")
8082
8139
  return;
8083
- var E;
8084
- if (typeof S == "function")
8085
- E = S.propTypes;
8086
- else if (typeof S == "object" && (S.$$typeof === u || // Note: Memo only checks outer props here.
8140
+ var v;
8141
+ if (typeof T == "function")
8142
+ v = T.propTypes;
8143
+ else if (typeof T == "object" && (T.$$typeof === u || // Note: Memo only checks outer props here.
8087
8144
  // Inner props are checked in the reconciler.
8088
- S.$$typeof === d))
8089
- E = S.propTypes;
8145
+ T.$$typeof === d))
8146
+ v = T.propTypes;
8090
8147
  else
8091
8148
  return;
8092
- if (E) {
8093
- var M = q(S);
8094
- hi(E, h.props, "prop", M, h);
8095
- } else if (S.PropTypes !== void 0 && !cn) {
8149
+ if (v) {
8150
+ var P = q(T);
8151
+ hi(v, h.props, "prop", P, h);
8152
+ } else if (T.PropTypes !== void 0 && !cn) {
8096
8153
  cn = !0;
8097
- var z = q(S);
8154
+ var z = q(T);
8098
8155
  w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", z || "Unknown");
8099
8156
  }
8100
- typeof S.getDefaultProps == "function" && !S.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
8157
+ typeof T.getDefaultProps == "function" && !T.getDefaultProps.isReactClassApproved && w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
8101
8158
  }
8102
8159
  }
8103
8160
  function Ci(h) {
8104
8161
  {
8105
- for (var S = Object.keys(h.props), E = 0; E < S.length; E++) {
8106
- var M = S[E];
8107
- if (M !== "children" && M !== "key") {
8108
- Qe(h), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", M), Qe(null);
8162
+ for (var T = Object.keys(h.props), v = 0; v < T.length; v++) {
8163
+ var P = T[v];
8164
+ if (P !== "children" && P !== "key") {
8165
+ Qe(h), w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", P), Qe(null);
8109
8166
  break;
8110
8167
  }
8111
8168
  }
@@ -8113,24 +8170,24 @@ Check the top-level render call using <` + E + ">.");
8113
8170
  }
8114
8171
  }
8115
8172
  var Tr = {};
8116
- function vr(h, S, E, M, z, Q) {
8173
+ function vr(h, T, v, P, z, Q) {
8117
8174
  {
8118
- var L = G(h);
8119
- if (!L) {
8120
- var $ = "";
8121
- (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && ($ += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
8175
+ var N = G(h);
8176
+ if (!N) {
8177
+ var U = "";
8178
+ (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && (U += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
8122
8179
  var fe = Oi();
8123
- fe ? $ += fe : $ += _r();
8180
+ fe ? U += fe : U += _r();
8124
8181
  var ee;
8125
- h === null ? ee = "null" : on(h) ? ee = "array" : h !== void 0 && h.$$typeof === t ? (ee = "<" + (q(h.type) || "Unknown") + " />", $ = " Did you accidentally export a JSX literal instead of a component?") : ee = typeof h, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", ee, $);
8182
+ h === null ? ee = "null" : on(h) ? ee = "array" : h !== void 0 && h.$$typeof === t ? (ee = "<" + (q(h.type) || "Unknown") + " />", U = " Did you accidentally export a JSX literal instead of a component?") : ee = typeof h, w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", ee, U);
8126
8183
  }
8127
- var re = Ei(h, S, E, z, Q);
8184
+ var re = Ei(h, T, v, z, Q);
8128
8185
  if (re == null)
8129
8186
  return re;
8130
- if (L) {
8131
- var Se = S.children;
8187
+ if (N) {
8188
+ var Se = T.children;
8132
8189
  if (Se !== void 0)
8133
- if (M)
8190
+ if (P)
8134
8191
  if (on(Se)) {
8135
8192
  for (var Be = 0; Be < Se.length; Be++)
8136
8193
  Sr(Se[Be], h);
@@ -8140,8 +8197,8 @@ Check the top-level render call using <` + E + ">.");
8140
8197
  else
8141
8198
  Sr(Se, h);
8142
8199
  }
8143
- if (ut.call(S, "key")) {
8144
- var De = q(h), pe = Object.keys(S).filter(function(xi) {
8200
+ if (ut.call(T, "key")) {
8201
+ var De = q(h), pe = Object.keys(T).filter(function(xi) {
8145
8202
  return xi !== "key";
8146
8203
  }), ln = pe.length > 0 ? "{key: someKey, " + pe.join(": ..., ") + ": ...}" : "{key: someKey}";
8147
8204
  if (!Tr[De + ln]) {
@@ -8154,22 +8211,22 @@ React keys must be passed directly to JSX without using spread:
8154
8211
  <%s key={someKey} {...props} />`, ln, De, ji, De), Tr[De + ln] = !0;
8155
8212
  }
8156
8213
  }
8157
- return h === s ? Ci(re) : Ai(re), re;
8214
+ return h === s ? Ci(re) : ki(re), re;
8158
8215
  }
8159
8216
  }
8160
- function Ii(h, S, E) {
8161
- return vr(h, S, E, !0);
8217
+ function Ii(h, T, v) {
8218
+ return vr(h, T, v, !0);
8162
8219
  }
8163
- function Pi(h, S, E) {
8164
- return vr(h, S, E, !1);
8220
+ function Pi(h, T, v) {
8221
+ return vr(h, T, v, !1);
8165
8222
  }
8166
- var Mi = Pi, Ri = Ii;
8167
- dt.Fragment = s, dt.jsx = Mi, dt.jsxs = Ri;
8223
+ var Ri = Pi, Mi = Ii;
8224
+ dt.Fragment = s, dt.jsx = Ri, dt.jsxs = Mi;
8168
8225
  }(), dt;
8169
8226
  }
8170
8227
  var Fu = {};
8171
8228
  Fu.NODE_ENV === "production" ? Fn.exports = Uu() : Fn.exports = Lu();
8172
- var ae = Fn.exports;
8229
+ var ce = Fn.exports;
8173
8230
  const Nu = {
8174
8231
  isLoading: !0,
8175
8232
  data: void 0,
@@ -8187,7 +8244,7 @@ function us(n) {
8187
8244
  }
8188
8245
  function Ku(n, e, t, r) {
8189
8246
  e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
8190
- const s = e ? ai(e) : null, i = ce(s), o = $e(us(n._reactor.getPreviousResult(s))), a = $e(Nu), c = Me(
8247
+ const s = e ? ai(e) : null, i = ue(s), o = Me(us(n._reactor.getPreviousResult(s))), a = Me(Nu), c = Ie(
8191
8248
  (l) => (o.current = us(n._reactor.getPreviousResult(s)), l(), s ? n.subscribeQuery(s, (d) => {
8192
8249
  o.current = {
8193
8250
  isLoading: !d,
@@ -8204,7 +8261,7 @@ function Ku(n, e, t, r) {
8204
8261
  // Build a new subscribe function if the query changes
8205
8262
  [i]
8206
8263
  );
8207
- return { state: Vt(c, () => o.current, () => a.current), query: s, queryHash: i };
8264
+ return { state: wt(c, () => o.current, () => a.current), query: s, queryHash: i };
8208
8265
  }
8209
8266
  const Wu = {
8210
8267
  error: void 0,
@@ -8213,10 +8270,10 @@ const Wu = {
8213
8270
  canLoadNextPage: !1
8214
8271
  };
8215
8272
  function qu({ core: n, query: e, opts: t }) {
8216
- const r = $e(null), s = ce(e), i = ce(t), o = ss(n, e, t), a = $e({
8273
+ const r = Me(null), s = ue(e), i = ue(t), o = ss(n, e, t), a = Me({
8217
8274
  ...o,
8218
8275
  isLoading: !o.data && !o.error
8219
- }), c = Me((f) => {
8276
+ }), c = Ie((f) => {
8220
8277
  r.current = null;
8221
8278
  const d = ss(n, e, t);
8222
8279
  if (a.current = {
@@ -8225,18 +8282,18 @@ function qu({ core: n, query: e, opts: t }) {
8225
8282
  }, f(), !e)
8226
8283
  return () => {
8227
8284
  };
8228
- const y = n.subscribeInfiniteQuery(e, (b) => {
8285
+ const b = n.subscribeInfiniteQuery(e, (y) => {
8229
8286
  a.current = {
8230
- ...b,
8287
+ ...y,
8231
8288
  isLoading: !1
8232
8289
  }, f();
8233
8290
  }, t);
8234
- return r.current = y, () => {
8235
- y.unsubscribe(), r.current === y && (r.current = null);
8291
+ return r.current = b, () => {
8292
+ b.unsubscribe(), r.current === b && (r.current = null);
8236
8293
  };
8237
8294
  }, [s, i]);
8238
8295
  return {
8239
- ...Vt(c, () => a.current, () => Wu),
8296
+ ...wt(c, () => a.current, () => Wu),
8240
8297
  loadNextPage: () => {
8241
8298
  var f;
8242
8299
  (f = r.current) == null || f.loadNextPage();
@@ -8244,7 +8301,7 @@ function qu({ core: n, query: e, opts: t }) {
8244
8301
  };
8245
8302
  }
8246
8303
  function zu() {
8247
- const n = $e(null);
8304
+ const n = Me(null);
8248
8305
  We(() => {
8249
8306
  t();
8250
8307
  }, []);
@@ -8258,13 +8315,13 @@ function zu() {
8258
8315
  }
8259
8316
  const Vu = 1e3;
8260
8317
  function Qu(n, e, t) {
8261
- const r = $e(t);
8318
+ const r = Me(t);
8262
8319
  r.current = t, We(() => n.core._reactor.subscribeTopic(n.type, n.id, e, (i, o) => {
8263
8320
  r.current(i, o);
8264
8321
  }), [n.id, e]);
8265
8322
  }
8266
8323
  function Bu(n, e) {
8267
- return We(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Me((r) => {
8324
+ return We(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Ie((r) => {
8268
8325
  n.core._reactor.publishTopic({
8269
8326
  roomType: n.type,
8270
8327
  roomId: n.id,
@@ -8282,7 +8339,7 @@ function Gu(n, e = {}) {
8282
8339
  We(() => n.core._reactor.subscribePresence(n.type, n.id, e, (u) => {
8283
8340
  r(u);
8284
8341
  }), [n.id, e.user, (o = e.peers) == null ? void 0 : o.join(), (a = e.keys) == null ? void 0 : a.join()]);
8285
- const s = Me((c) => {
8342
+ const s = Ie((c) => {
8286
8343
  n.core._reactor.publishPresence(n.type, n.id, c);
8287
8344
  }, [n.type, n.id]);
8288
8345
  return Sn(() => ({
@@ -8299,7 +8356,7 @@ function Ju(n, e, t = {}) {
8299
8356
  }), i = Sn(() => {
8300
8357
  const l = n._core._reactor.getPresence(n.type, n.id);
8301
8358
  return t != null && t.writeOnly ? [] : Object.values((l == null ? void 0 : l.peers) ?? {}).filter((f) => f[e] === !0);
8302
- }, [t == null ? void 0 : t.writeOnly, s]), o = Me((l) => {
8359
+ }, [t == null ? void 0 : t.writeOnly, s]), o = Ie((l) => {
8303
8360
  n.core._reactor.publishPresence(n.type, n.id, {
8304
8361
  [e]: l
8305
8362
  }), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Vu, () => {
@@ -8307,10 +8364,10 @@ function Ju(n, e, t = {}) {
8307
8364
  [e]: null
8308
8365
  });
8309
8366
  }));
8310
- }, [n.type, n.id, e, t == null ? void 0 : t.timeout, r]), a = Me((l) => {
8367
+ }, [n.type, n.id, e, t == null ? void 0 : t.timeout, r]), a = Ie((l) => {
8311
8368
  const d = !((t == null ? void 0 : t.stopOnEnter) && l.key === "Enter");
8312
8369
  o(d);
8313
- }, [t.stopOnEnter, o]), c = Me(() => {
8370
+ }, [t.stopOnEnter, o]), c = Ie(() => {
8314
8371
  o(!1);
8315
8372
  }, [o]), u = Sn(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
8316
8373
  return {
@@ -8417,8 +8474,11 @@ const Zu = {
8417
8474
  isLoading: !0,
8418
8475
  user: void 0,
8419
8476
  error: void 0
8477
+ }, Xu = {
8478
+ isLoading: !0,
8479
+ isReadOnly: void 0
8420
8480
  };
8421
- class Wt {
8481
+ class qt {
8422
8482
  constructor(e, t) {
8423
8483
  p(this, "tx", ir());
8424
8484
  p(this, "auth");
@@ -8564,7 +8624,7 @@ class Wt {
8564
8624
  p(this, "useUser", () => {
8565
8625
  const { user: e } = this.useAuth();
8566
8626
  if (!e)
8567
- throw new ue("useUser must be used within an auth-protected route");
8627
+ throw new oe("useUser must be used within an auth-protected route");
8568
8628
  return e;
8569
8629
  });
8570
8630
  /**
@@ -8590,16 +8650,34 @@ class Wt {
8590
8650
  * }
8591
8651
  */
8592
8652
  p(this, "useConnectionStatus", () => {
8593
- const e = $e(this.core._reactor.status), t = Me((s) => this.core.subscribeConnectionStatus((o) => {
8653
+ const e = Me(this.core._reactor.status), t = Ie((s) => this.core.subscribeConnectionStatus((o) => {
8594
8654
  o !== e.current && (e.current = o, s());
8595
8655
  }), []);
8596
- return Vt(
8656
+ return wt(
8597
8657
  t,
8598
8658
  () => e.current,
8599
8659
  // For SSR, always return 'connecting' as the initial state
8600
8660
  () => "connecting"
8601
8661
  );
8602
8662
  });
8663
+ /**
8664
+ * Observe the app's maintenance-mode state. While read-only, reads and
8665
+ * live queries keep working but writes are rejected.
8666
+ *
8667
+ * @example
8668
+ * function App() {
8669
+ * const { isLoading, isReadOnly } = db.useAppStatus()
8670
+ * if (isLoading) return null
8671
+ * if (isReadOnly) return <MaintenanceBanner />
8672
+ * // ...
8673
+ * }
8674
+ */
8675
+ p(this, "useAppStatus", () => {
8676
+ const e = Me(this.core._reactor._appStatusState), t = Ie((s) => this.core.subscribeAppStatus((i) => {
8677
+ (i.isLoading !== e.current.isLoading || i.isReadOnly !== e.current.isReadOnly) && (e.current = i, s());
8678
+ }), []);
8679
+ return wt(t, () => e.current, () => Xu);
8680
+ });
8603
8681
  /**
8604
8682
  * Use this for one-off queries.
8605
8683
  * Returns local data if available, otherwise fetches from the server.
@@ -8654,7 +8732,7 @@ class Wt {
8654
8732
  */
8655
8733
  p(this, "SignedIn", ({ children: e }) => {
8656
8734
  const t = this.useAuth();
8657
- return t.isLoading || t.error || !t.user ? null : ae.jsx(ae.Fragment, { children: e });
8735
+ return t.isLoading || t.error || !t.user ? null : ce.jsx(ce.Fragment, { children: e });
8658
8736
  });
8659
8737
  /**
8660
8738
  * Only render children if the user is signed out.
@@ -8668,7 +8746,7 @@ class Wt {
8668
8746
  */
8669
8747
  p(this, "SignedOut", ({ children: e }) => {
8670
8748
  const t = this.useAuth();
8671
- return t.isLoading || t.error || t.user ? null : ae.jsx(ae.Fragment, { children: e });
8749
+ return t.isLoading || t.error || t.user ? null : ce.jsx(ce.Fragment, { children: e });
8672
8750
  });
8673
8751
  this.core = $u(
8674
8752
  e,
@@ -8697,10 +8775,10 @@ class Wt {
8697
8775
  return new Yu(this.core, e, t);
8698
8776
  }
8699
8777
  _useAuth() {
8700
- const e = $e(this.core._reactor._currentUserCached), t = Me((s) => this.core.subscribeAuth((o) => {
8778
+ const e = Me(this.core._reactor._currentUserCached), t = Ie((s) => this.core.subscribeAuth((o) => {
8701
8779
  e.current = { isLoading: !1, ...o }, s();
8702
8780
  }), []);
8703
- return Vt(t, () => e.current, () => Zu);
8781
+ return wt(t, () => e.current, () => Zu);
8704
8782
  }
8705
8783
  /**
8706
8784
  * One time query for the logged in state. This is useful
@@ -8716,7 +8794,7 @@ class Wt {
8716
8794
  return this.core.getAuth();
8717
8795
  }
8718
8796
  }
8719
- p(Wt, "Store"), p(Wt, "NetworkListener"), p(Wt, "EventSourceImpl");
8797
+ p(qt, "Store"), p(qt, "NetworkListener"), p(qt, "EventSourceImpl");
8720
8798
  class ls extends Error {
8721
8799
  constructor(e, t) {
8722
8800
  super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
@@ -8724,7 +8802,7 @@ class ls extends Error {
8724
8802
  }
8725
8803
  function wn(n) {
8726
8804
  }
8727
- function Xu(n) {
8805
+ function el(n) {
8728
8806
  if (typeof n == "function")
8729
8807
  throw new TypeError(
8730
8808
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
@@ -8732,46 +8810,46 @@ function Xu(n) {
8732
8810
  const { onEvent: e = wn, onError: t = wn, onRetry: r = wn, onComment: s } = n;
8733
8811
  let i = "", o = !0, a, c = "", u = "";
8734
8812
  function l(g) {
8735
- const m = o ? g.replace(/^\xEF\xBB\xBF/, "") : g, [T, _] = el(`${i}${m}`);
8736
- for (const w of T)
8813
+ const _ = o ? g.replace(/^\xEF\xBB\xBF/, "") : g, [S, m] = tl(`${i}${_}`);
8814
+ for (const w of S)
8737
8815
  f(w);
8738
- i = _, o = !1;
8816
+ i = m, o = !1;
8739
8817
  }
8740
8818
  function f(g) {
8741
8819
  if (g === "") {
8742
- y();
8820
+ b();
8743
8821
  return;
8744
8822
  }
8745
8823
  if (g.startsWith(":")) {
8746
8824
  s && s(g.slice(g.startsWith(": ") ? 2 : 1));
8747
8825
  return;
8748
8826
  }
8749
- const m = g.indexOf(":");
8750
- if (m !== -1) {
8751
- const T = g.slice(0, m), _ = g[m + 1] === " " ? 2 : 1, w = g.slice(m + _);
8752
- d(T, w, g);
8827
+ const _ = g.indexOf(":");
8828
+ if (_ !== -1) {
8829
+ const S = g.slice(0, _), m = g[_ + 1] === " " ? 2 : 1, w = g.slice(_ + m);
8830
+ d(S, w, g);
8753
8831
  return;
8754
8832
  }
8755
8833
  d(g, "", g);
8756
8834
  }
8757
- function d(g, m, T) {
8835
+ function d(g, _, S) {
8758
8836
  switch (g) {
8759
8837
  case "event":
8760
- u = m;
8838
+ u = _;
8761
8839
  break;
8762
8840
  case "data":
8763
- c = `${c}${m}
8841
+ c = `${c}${_}
8764
8842
  `;
8765
8843
  break;
8766
8844
  case "id":
8767
- a = m.includes("\0") ? void 0 : m;
8845
+ a = _.includes("\0") ? void 0 : _;
8768
8846
  break;
8769
8847
  case "retry":
8770
- /^\d+$/.test(m) ? r(parseInt(m, 10)) : t(
8771
- new ls(`Invalid \`retry\` value: "${m}"`, {
8848
+ /^\d+$/.test(_) ? r(parseInt(_, 10)) : t(
8849
+ new ls(`Invalid \`retry\` value: "${_}"`, {
8772
8850
  type: "invalid-retry",
8773
- value: m,
8774
- line: T
8851
+ value: _,
8852
+ line: S
8775
8853
  })
8776
8854
  );
8777
8855
  break;
@@ -8779,13 +8857,13 @@ function Xu(n) {
8779
8857
  t(
8780
8858
  new ls(
8781
8859
  `Unknown field "${g.length > 20 ? `${g.slice(0, 20)}…` : g}"`,
8782
- { type: "unknown-field", field: g, value: m, line: T }
8860
+ { type: "unknown-field", field: g, value: _, line: S }
8783
8861
  )
8784
8862
  );
8785
8863
  break;
8786
8864
  }
8787
8865
  }
8788
- function y() {
8866
+ function b() {
8789
8867
  c.length > 0 && e({
8790
8868
  id: a,
8791
8869
  event: u || void 0,
@@ -8795,12 +8873,12 @@ function Xu(n) {
8795
8873
  `) ? c.slice(0, -1) : c
8796
8874
  }), a = void 0, c = "", u = "";
8797
8875
  }
8798
- function b(g = {}) {
8876
+ function y(g = {}) {
8799
8877
  i && g.consume && f(i), o = !0, a = void 0, c = "", u = "", i = "";
8800
8878
  }
8801
- return { feed: l, reset: b };
8879
+ return { feed: l, reset: y };
8802
8880
  }
8803
- function el(n) {
8881
+ function tl(n) {
8804
8882
  const e = [];
8805
8883
  let t = "", r = 0;
8806
8884
  for (; r < n.length; ) {
@@ -8860,7 +8938,7 @@ class fs extends Event {
8860
8938
  return e(ds(this), t);
8861
8939
  }
8862
8940
  }
8863
- function tl(n) {
8941
+ function nl(n) {
8864
8942
  const e = globalThis.DOMException;
8865
8943
  return typeof e == "function" ? new e(n, "SyntaxError") : new SyntaxError(n);
8866
8944
  }
@@ -8879,69 +8957,69 @@ function ds(n) {
8879
8957
  }
8880
8958
  var ci = (n) => {
8881
8959
  throw TypeError(n);
8882
- }, cr = (n, e, t) => e.has(n) || ci("Cannot " + t), x = (n, e, t) => (cr(n, e, "read from private field"), t ? t.call(n) : e.get(n)), ie = (n, e, t) => e.has(n) ? ci("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), Y = (n, e, t, r) => (cr(n, e, "write to private field"), e.set(n, t), t), Pe = (n, e, t) => (cr(n, e, "access private method"), t), ye, Fe, Ye, qt, Yt, Tt, nt, vt, xe, Ze, st, Xe, _t, Ee, Kn, Wn, qn, hs, zn, Vn, mt, Qn, Bn;
8883
- class zt extends EventTarget {
8960
+ }, cr = (n, e, t) => e.has(n) || ci("Cannot " + t), $ = (n, e, t) => (cr(n, e, "read from private field"), t ? t.call(n) : e.get(n)), ie = (n, e, t) => e.has(n) ? ci("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), Y = (n, e, t, r) => (cr(n, e, "write to private field"), e.set(n, t), t), Re = (n, e, t) => (cr(n, e, "access private method"), t), ye, Fe, Ye, zt, Yt, vt, nt, Et, $e, Ze, st, Xe, _t, Ee, Kn, Wn, qn, hs, zn, Vn, mt, Qn, Bn;
8961
+ class Vt extends EventTarget {
8884
8962
  constructor(e, t) {
8885
8963
  var r, s;
8886
- super(), ie(this, Ee), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, ie(this, ye), ie(this, Fe), ie(this, Ye), ie(this, qt), ie(this, Yt), ie(this, Tt), ie(this, nt), ie(this, vt, null), ie(this, xe), ie(this, Ze), ie(this, st, null), ie(this, Xe, null), ie(this, _t, null), ie(this, Wn, async (i) => {
8964
+ super(), ie(this, Ee), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, ie(this, ye), ie(this, Fe), ie(this, Ye), ie(this, zt), ie(this, Yt), ie(this, vt), ie(this, nt), ie(this, Et, null), ie(this, $e), ie(this, Ze), ie(this, st, null), ie(this, Xe, null), ie(this, _t, null), ie(this, Wn, async (i) => {
8887
8965
  var o;
8888
- x(this, Ze).reset();
8966
+ $(this, Ze).reset();
8889
8967
  const { body: a, redirected: c, status: u, headers: l } = i;
8890
8968
  if (u === 204) {
8891
- Pe(this, Ee, mt).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
8969
+ Re(this, Ee, mt).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
8892
8970
  return;
8893
8971
  }
8894
8972
  if (c ? Y(this, Ye, new URL(i.url)) : Y(this, Ye, void 0), u !== 200) {
8895
- Pe(this, Ee, mt).call(this, `Non-200 status code (${u})`, u);
8973
+ Re(this, Ee, mt).call(this, `Non-200 status code (${u})`, u);
8896
8974
  return;
8897
8975
  }
8898
8976
  if (!(l.get("content-type") || "").startsWith("text/event-stream")) {
8899
- Pe(this, Ee, mt).call(this, 'Invalid content type, expected "text/event-stream"', u);
8977
+ Re(this, Ee, mt).call(this, 'Invalid content type, expected "text/event-stream"', u);
8900
8978
  return;
8901
8979
  }
8902
- if (x(this, ye) === this.CLOSED)
8980
+ if ($(this, ye) === this.CLOSED)
8903
8981
  return;
8904
8982
  Y(this, ye, this.OPEN);
8905
8983
  const f = new Event("open");
8906
- if ((o = x(this, _t)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
8907
- Pe(this, Ee, mt).call(this, "Invalid response body, expected a web ReadableStream", u), this.close();
8984
+ if ((o = $(this, _t)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
8985
+ Re(this, Ee, mt).call(this, "Invalid response body, expected a web ReadableStream", u), this.close();
8908
8986
  return;
8909
8987
  }
8910
- const d = new TextDecoder(), y = a.getReader();
8911
- let b = !0;
8988
+ const d = new TextDecoder(), b = a.getReader();
8989
+ let y = !0;
8912
8990
  do {
8913
- const { done: g, value: m } = await y.read();
8914
- m && x(this, Ze).feed(d.decode(m, { stream: !g })), g && (b = !1, x(this, Ze).reset(), Pe(this, Ee, Qn).call(this));
8915
- } while (b);
8991
+ const { done: g, value: _ } = await b.read();
8992
+ _ && $(this, Ze).feed(d.decode(_, { stream: !g })), g && (y = !1, $(this, Ze).reset(), Re(this, Ee, Qn).call(this));
8993
+ } while (y);
8916
8994
  }), ie(this, qn, (i) => {
8917
- Y(this, xe, void 0), !(i.name === "AbortError" || i.type === "aborted") && Pe(this, Ee, Qn).call(this, Nn(i));
8995
+ Y(this, $e, void 0), !(i.name === "AbortError" || i.type === "aborted") && Re(this, Ee, Qn).call(this, Nn(i));
8918
8996
  }), ie(this, zn, (i) => {
8919
- typeof i.id == "string" && Y(this, vt, i.id);
8997
+ typeof i.id == "string" && Y(this, Et, i.id);
8920
8998
  const o = new MessageEvent(i.event || "message", {
8921
8999
  data: i.data,
8922
- origin: x(this, Ye) ? x(this, Ye).origin : x(this, Fe).origin,
9000
+ origin: $(this, Ye) ? $(this, Ye).origin : $(this, Fe).origin,
8923
9001
  lastEventId: i.id || ""
8924
9002
  });
8925
- x(this, Xe) && (!i.event || i.event === "message") && x(this, Xe).call(this, o), this.dispatchEvent(o);
9003
+ $(this, Xe) && (!i.event || i.event === "message") && $(this, Xe).call(this, o), this.dispatchEvent(o);
8926
9004
  }), ie(this, Vn, (i) => {
8927
- Y(this, Tt, i);
9005
+ Y(this, vt, i);
8928
9006
  }), ie(this, Bn, () => {
8929
- Y(this, nt, void 0), x(this, ye) === this.CONNECTING && Pe(this, Ee, Kn).call(this);
9007
+ Y(this, nt, void 0), $(this, ye) === this.CONNECTING && Re(this, Ee, Kn).call(this);
8930
9008
  });
8931
9009
  try {
8932
9010
  if (e instanceof URL)
8933
9011
  Y(this, Fe, e);
8934
9012
  else if (typeof e == "string")
8935
- Y(this, Fe, new URL(e, nl()));
9013
+ Y(this, Fe, new URL(e, rl()));
8936
9014
  else
8937
9015
  throw new Error("Invalid URL");
8938
9016
  } catch {
8939
- throw tl("An invalid or illegal string was specified");
9017
+ throw nl("An invalid or illegal string was specified");
8940
9018
  }
8941
- Y(this, Ze, Xu({
8942
- onEvent: x(this, zn),
8943
- onRetry: x(this, Vn)
8944
- })), Y(this, ye, this.CONNECTING), Y(this, Tt, 3e3), Y(this, Yt, (r = t == null ? void 0 : t.fetch) != null ? r : globalThis.fetch), Y(this, qt, (s = t == null ? void 0 : t.withCredentials) != null ? s : !1), Pe(this, Ee, Kn).call(this);
9019
+ Y(this, Ze, el({
9020
+ onEvent: $(this, zn),
9021
+ onRetry: $(this, Vn)
9022
+ })), Y(this, ye, this.CONNECTING), Y(this, vt, 3e3), Y(this, Yt, (r = t == null ? void 0 : t.fetch) != null ? r : globalThis.fetch), Y(this, zt, (s = t == null ? void 0 : t.withCredentials) != null ? s : !1), Re(this, Ee, Kn).call(this);
8945
9023
  }
8946
9024
  /**
8947
9025
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -8954,7 +9032,7 @@ class zt extends EventTarget {
8954
9032
  * @public
8955
9033
  */
8956
9034
  get readyState() {
8957
- return x(this, ye);
9035
+ return $(this, ye);
8958
9036
  }
8959
9037
  /**
8960
9038
  * Returns the URL providing the event stream.
@@ -8964,7 +9042,7 @@ class zt extends EventTarget {
8964
9042
  * @public
8965
9043
  */
8966
9044
  get url() {
8967
- return x(this, Fe).href;
9045
+ return $(this, Fe).href;
8968
9046
  }
8969
9047
  /**
8970
9048
  * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
@@ -8972,25 +9050,25 @@ class zt extends EventTarget {
8972
9050
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
8973
9051
  */
8974
9052
  get withCredentials() {
8975
- return x(this, qt);
9053
+ return $(this, zt);
8976
9054
  }
8977
9055
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
8978
9056
  get onerror() {
8979
- return x(this, st);
9057
+ return $(this, st);
8980
9058
  }
8981
9059
  set onerror(e) {
8982
9060
  Y(this, st, e);
8983
9061
  }
8984
9062
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
8985
9063
  get onmessage() {
8986
- return x(this, Xe);
9064
+ return $(this, Xe);
8987
9065
  }
8988
9066
  set onmessage(e) {
8989
9067
  Y(this, Xe, e);
8990
9068
  }
8991
9069
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
8992
9070
  get onopen() {
8993
- return x(this, _t);
9071
+ return $(this, _t);
8994
9072
  }
8995
9073
  set onopen(e) {
8996
9074
  Y(this, _t, e);
@@ -9011,16 +9089,16 @@ class zt extends EventTarget {
9011
9089
  * @public
9012
9090
  */
9013
9091
  close() {
9014
- x(this, nt) && clearTimeout(x(this, nt)), x(this, ye) !== this.CLOSED && (x(this, xe) && x(this, xe).abort(), Y(this, ye, this.CLOSED), Y(this, xe, void 0));
9092
+ $(this, nt) && clearTimeout($(this, nt)), $(this, ye) !== this.CLOSED && ($(this, $e) && $(this, $e).abort(), Y(this, ye, this.CLOSED), Y(this, $e, void 0));
9015
9093
  }
9016
9094
  }
9017
- ye = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), qt = /* @__PURE__ */ new WeakMap(), Yt = /* @__PURE__ */ new WeakMap(), Tt = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), _t = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakSet(), /**
9095
+ ye = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), zt = /* @__PURE__ */ new WeakMap(), Yt = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), Et = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), Ze = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), _t = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakSet(), /**
9018
9096
  * Connect to the given URL and start receiving events
9019
9097
  *
9020
9098
  * @internal
9021
9099
  */
9022
9100
  Kn = function() {
9023
- Y(this, ye, this.CONNECTING), Y(this, xe, new AbortController()), x(this, Yt)(x(this, Fe), Pe(this, Ee, hs).call(this)).then(x(this, Wn)).catch(x(this, qn));
9101
+ Y(this, ye, this.CONNECTING), Y(this, $e, new AbortController()), $(this, Yt)($(this, Fe), Re(this, Ee, hs).call(this)).then($(this, Wn)).catch($(this, qn));
9024
9102
  }, Wn = /* @__PURE__ */ new WeakMap(), qn = /* @__PURE__ */ new WeakMap(), /**
9025
9103
  * Get request options for the `fetch()` request
9026
9104
  *
@@ -9034,9 +9112,9 @@ hs = function() {
9034
9112
  // [spec] …will have their mode set to "cors"…
9035
9113
  mode: "cors",
9036
9114
  redirect: "follow",
9037
- headers: { Accept: "text/event-stream", ...x(this, vt) ? { "Last-Event-ID": x(this, vt) } : void 0 },
9115
+ headers: { Accept: "text/event-stream", ...$(this, Et) ? { "Last-Event-ID": $(this, Et) } : void 0 },
9038
9116
  cache: "no-store",
9039
- signal: (n = x(this, xe)) == null ? void 0 : n.signal
9117
+ signal: (n = $(this, $e)) == null ? void 0 : n.signal
9040
9118
  };
9041
9119
  return "window" in globalThis && (e.credentials = this.withCredentials ? "include" : "same-origin"), e;
9042
9120
  }, zn = /* @__PURE__ */ new WeakMap(), Vn = /* @__PURE__ */ new WeakMap(), /**
@@ -9048,9 +9126,9 @@ hs = function() {
9048
9126
  */
9049
9127
  mt = function(n, e) {
9050
9128
  var t;
9051
- x(this, ye) !== this.CLOSED && Y(this, ye, this.CLOSED);
9129
+ $(this, ye) !== this.CLOSED && Y(this, ye, this.CLOSED);
9052
9130
  const r = new fs("error", { code: e, message: n });
9053
- (t = x(this, st)) == null || t.call(this, r), this.dispatchEvent(r);
9131
+ (t = $(this, st)) == null || t.call(this, r), this.dispatchEvent(r);
9054
9132
  }, /**
9055
9133
  * Schedules a reconnection attempt against the EventSource endpoint.
9056
9134
  *
@@ -9060,35 +9138,35 @@ mt = function(n, e) {
9060
9138
  */
9061
9139
  Qn = function(n, e) {
9062
9140
  var t;
9063
- if (x(this, ye) === this.CLOSED)
9141
+ if ($(this, ye) === this.CLOSED)
9064
9142
  return;
9065
9143
  Y(this, ye, this.CONNECTING);
9066
9144
  const r = new fs("error", { code: e, message: n });
9067
- (t = x(this, st)) == null || t.call(this, r), this.dispatchEvent(r), Y(this, nt, setTimeout(x(this, Bn), x(this, Tt)));
9145
+ (t = $(this, st)) == null || t.call(this, r), this.dispatchEvent(r), Y(this, nt, setTimeout($(this, Bn), $(this, vt)));
9068
9146
  }, Bn = /* @__PURE__ */ new WeakMap(), /**
9069
9147
  * ReadyState representing an EventSource currently trying to connect
9070
9148
  *
9071
9149
  * @public
9072
9150
  */
9073
- zt.CONNECTING = 0, /**
9151
+ Vt.CONNECTING = 0, /**
9074
9152
  * ReadyState representing an EventSource connection that is open (eg connected)
9075
9153
  *
9076
9154
  * @public
9077
9155
  */
9078
- zt.OPEN = 1, /**
9156
+ Vt.OPEN = 1, /**
9079
9157
  * ReadyState representing an EventSource connection that is closed (eg disconnected)
9080
9158
  *
9081
9159
  * @public
9082
9160
  */
9083
- zt.CLOSED = 2;
9084
- function nl() {
9161
+ Vt.CLOSED = 2;
9162
+ function rl() {
9085
9163
  const n = "document" in globalThis ? globalThis.document : void 0;
9086
9164
  return n && typeof n == "object" && "baseURI" in n && typeof n.baseURI == "string" ? n.baseURI : void 0;
9087
9165
  }
9088
- class ui extends Wt {
9166
+ class ui extends qt {
9089
9167
  }
9090
- p(ui, "EventSourceImpl", zt);
9091
- function rl(n) {
9168
+ p(ui, "EventSourceImpl", Vt);
9169
+ function sl(n) {
9092
9170
  const e = {
9093
9171
  ...n,
9094
9172
  useDateObjects: n.useDateObjects ?? !1
@@ -9097,8 +9175,8 @@ function rl(n) {
9097
9175
  "@instantdb/react": ar
9098
9176
  });
9099
9177
  }
9100
- const hl = rl;
9101
- function pl({
9178
+ const pl = sl;
9179
+ function yl({
9102
9180
  as: n = "div",
9103
9181
  spaceId: e,
9104
9182
  room: t,
@@ -9113,39 +9191,39 @@ function pl({
9113
9191
  const l = e || `cursors-space-default--${String(t.type)}-${t.id}`, f = t.usePresence({
9114
9192
  keys: [l]
9115
9193
  }), d = t._core._reactor.getPresence(t.type, t.id);
9116
- function y(_, w) {
9117
- const C = w.clientX, v = w.clientY, U = (C - _.left) / _.width * 100, I = (v - _.top) / _.height * 100;
9194
+ function b(m, w) {
9195
+ const A = w.clientX, O = w.clientY, M = (A - m.left) / m.width * 100, I = (O - m.top) / m.height * 100;
9118
9196
  f.publishPresence({
9119
9197
  [l]: {
9120
- x: C,
9121
- y: v,
9122
- xPercent: U,
9198
+ x: A,
9199
+ y: O,
9200
+ xPercent: M,
9123
9201
  yPercent: I,
9124
9202
  color: i
9125
9203
  }
9126
9204
  });
9127
9205
  }
9128
- function b(_) {
9129
- c || _.stopPropagation();
9130
- const w = _.currentTarget.getBoundingClientRect();
9131
- y(w, _);
9206
+ function y(m) {
9207
+ c || m.stopPropagation();
9208
+ const w = m.currentTarget.getBoundingClientRect();
9209
+ b(w, m);
9132
9210
  }
9133
- function g(_) {
9211
+ function g(m) {
9134
9212
  f.publishPresence({
9135
9213
  [l]: void 0
9136
9214
  });
9137
9215
  }
9138
- function m(_) {
9139
- if (_.touches.length !== 1)
9216
+ function _(m) {
9217
+ if (m.touches.length !== 1)
9140
9218
  return;
9141
- const w = _.touches[0];
9219
+ const w = m.touches[0];
9142
9220
  if (w.target instanceof Element) {
9143
- c || _.stopPropagation();
9144
- const C = w.target.getBoundingClientRect();
9145
- y(C, w);
9221
+ c || m.stopPropagation();
9222
+ const A = w.target.getBoundingClientRect();
9223
+ b(A, w);
9146
9224
  }
9147
9225
  }
9148
- function T(_) {
9226
+ function S(m) {
9149
9227
  f.publishPresence({
9150
9228
  [l]: void 0
9151
9229
  });
@@ -9153,10 +9231,10 @@ function pl({
9153
9231
  return Ui(
9154
9232
  n,
9155
9233
  {
9156
- onMouseMove: b,
9234
+ onMouseMove: y,
9157
9235
  onMouseOut: g,
9158
- onTouchMove: m,
9159
- onTouchEnd: T,
9236
+ onTouchMove: _,
9237
+ onTouchEnd: S,
9160
9238
  className: r,
9161
9239
  style: {
9162
9240
  position: "relative",
@@ -9165,31 +9243,31 @@ function pl({
9165
9243
  },
9166
9244
  [
9167
9245
  o,
9168
- /* @__PURE__ */ ae.jsx(
9246
+ /* @__PURE__ */ ce.jsx(
9169
9247
  "div",
9170
9248
  {
9171
9249
  style: {
9172
9250
  ...ps,
9173
- ...il,
9174
- zIndex: u !== void 0 ? u : ol
9251
+ ...ol,
9252
+ zIndex: u !== void 0 ? u : al
9175
9253
  },
9176
- children: Object.entries(f.peers).map(([_, w]) => {
9177
- const C = w[l];
9178
- return C ? /* @__PURE__ */ ae.jsx(
9254
+ children: Object.entries(f.peers).map(([m, w]) => {
9255
+ const A = w[l];
9256
+ return A ? /* @__PURE__ */ ce.jsx(
9179
9257
  "div",
9180
9258
  {
9181
9259
  style: {
9182
9260
  ...ps,
9183
- transform: `translate(${C.xPercent}%, ${C.yPercent}%)`,
9261
+ transform: `translate(${A.xPercent}%, ${A.yPercent}%)`,
9184
9262
  transformOrigin: "0 0",
9185
9263
  transition: "transform 100ms"
9186
9264
  },
9187
9265
  children: a ? a({
9188
- color: C.color,
9189
- presence: d == null ? void 0 : d.peers[_]
9190
- }) : /* @__PURE__ */ ae.jsx(sl, { ...C })
9266
+ color: A.color,
9267
+ presence: d == null ? void 0 : d.peers[m]
9268
+ }) : /* @__PURE__ */ ce.jsx(il, { ...A })
9191
9269
  },
9192
- _
9270
+ m
9193
9271
  ) : null;
9194
9272
  })
9195
9273
  },
@@ -9198,9 +9276,9 @@ function pl({
9198
9276
  ]
9199
9277
  );
9200
9278
  }
9201
- function sl({ color: n }) {
9279
+ function il({ color: n }) {
9202
9280
  const t = n || "black";
9203
- return /* @__PURE__ */ ae.jsxs(
9281
+ return /* @__PURE__ */ ce.jsxs(
9204
9282
  "svg",
9205
9283
  {
9206
9284
  style: { height: 35, width: 35 },
@@ -9208,36 +9286,36 @@ function sl({ color: n }) {
9208
9286
  fill: "none",
9209
9287
  xmlns: "http://www.w3.org/2000/svg",
9210
9288
  children: [
9211
- /* @__PURE__ */ ae.jsxs(
9289
+ /* @__PURE__ */ ce.jsxs(
9212
9290
  "g",
9213
9291
  {
9214
9292
  fill: "rgba(0,0,0,.2)",
9215
9293
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
9216
9294
  children: [
9217
- /* @__PURE__ */ ae.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
9218
- /* @__PURE__ */ ae.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
9295
+ /* @__PURE__ */ ce.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
9296
+ /* @__PURE__ */ ce.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
9219
9297
  ]
9220
9298
  }
9221
9299
  ),
9222
- /* @__PURE__ */ ae.jsxs(
9300
+ /* @__PURE__ */ ce.jsxs(
9223
9301
  "g",
9224
9302
  {
9225
9303
  fill: "white",
9226
9304
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
9227
9305
  children: [
9228
- /* @__PURE__ */ ae.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
9229
- /* @__PURE__ */ ae.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
9306
+ /* @__PURE__ */ ce.jsx("path", { d: "m12 24.4219v-16.015l11.591 11.619h-6.781l-.411.124z" }),
9307
+ /* @__PURE__ */ ce.jsx("path", { d: "m21.0845 25.0962-3.605 1.535-4.682-11.089 3.686-1.553z" })
9230
9308
  ]
9231
9309
  }
9232
9310
  ),
9233
- /* @__PURE__ */ ae.jsxs(
9311
+ /* @__PURE__ */ ce.jsxs(
9234
9312
  "g",
9235
9313
  {
9236
9314
  fill: t,
9237
9315
  transform: "matrix(1, 0, 0, 1, -11.999999046325684, -8.406899452209473)",
9238
9316
  children: [
9239
- /* @__PURE__ */ ae.jsx("path", { d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" }),
9240
- /* @__PURE__ */ ae.jsx("path", { d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z" })
9317
+ /* @__PURE__ */ ce.jsx("path", { d: "m19.751 24.4155-1.844.774-3.1-7.374 1.841-.775z" }),
9318
+ /* @__PURE__ */ ce.jsx("path", { d: "m13 10.814v11.188l2.969-2.866.428-.139h4.768z" })
9241
9319
  ]
9242
9320
  }
9243
9321
  )
@@ -9251,24 +9329,24 @@ const ps = {
9251
9329
  left: 0,
9252
9330
  bottom: 0,
9253
9331
  right: 0
9254
- }, il = {
9332
+ }, ol = {
9255
9333
  overflow: "hidden",
9256
9334
  pointerEvents: "none",
9257
9335
  userSelect: "none"
9258
- }, ol = 99999;
9336
+ }, al = 99999;
9259
9337
  export {
9260
- pl as Cursors,
9338
+ yl as Cursors,
9261
9339
  en as InstantAPIError,
9262
- Wt as InstantReactAbstractDatabase,
9340
+ qt as InstantReactAbstractDatabase,
9263
9341
  ui as InstantReactWebDatabase,
9264
9342
  rc as StoreInterface,
9265
9343
  Ue as SyncTableCallbackEventType,
9266
- dl as createInstantRouteHandler,
9267
- fl as i,
9344
+ hl as createInstantRouteHandler,
9345
+ dl as i,
9268
9346
  Z as id,
9269
- rl as init,
9270
- hl as init_experimental,
9347
+ sl as init,
9348
+ pl as init_experimental,
9271
9349
  Ca as lookup,
9272
- ul as setInstantWarningsEnabled,
9273
- ll as tx
9350
+ ll as setInstantWarningsEnabled,
9351
+ fl as tx
9274
9352
  };