@instantdb/react-common 1.0.42 → 1.0.43-branch-drewh-user-sync-less-often.26902629460.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- var Bs = Object.defineProperty;
2
- var Gs = (n, e, t) => e in n ? Bs(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var p = (n, e, t) => Gs(n, typeof e != "symbol" ? e + "" : e, t);
4
- import Pr, { useRef as ke, useCallback as Ae, useSyncExternalStore as At, useEffect as je, useMemo as Jt, useState as Rr } from "react";
1
+ var Gs = Object.defineProperty;
2
+ var Hs = (n, e, t) => e in n ? Gs(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var p = (n, e, t) => Hs(n, typeof e != "symbol" ? e + "" : e, t);
4
+ import Mr, { useRef as ke, useCallback as Ae, useSyncExternalStore as At, useEffect as je, useMemo as Jt, useState as Rr } from "react";
5
5
  var Yt = { exports: {} }, Je = {};
6
6
  /**
7
7
  * @license React
@@ -13,10 +13,10 @@ var Yt = { exports: {} }, Je = {};
13
13
  * LICENSE file in the root directory of this source tree.
14
14
  */
15
15
  var zn;
16
- function Hs() {
16
+ function Js() {
17
17
  if (zn) return Je;
18
18
  zn = 1;
19
- var n = Pr, 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 };
19
+ var n = Mr, 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 };
20
20
  function o(a, c, u) {
21
21
  var l, f = {}, h = null, y = null;
22
22
  u !== void 0 && (h = "" + u), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (y = c.ref);
@@ -27,7 +27,7 @@ function Hs() {
27
27
  return Je.Fragment = t, Je.jsx = o, Je.jsxs = o, Je;
28
28
  }
29
29
  var Ye = {}, Vn;
30
- function Js() {
30
+ function Ys() {
31
31
  if (Vn) return Ye;
32
32
  Vn = 1;
33
33
  var n = {};
@@ -41,7 +41,7 @@ function Js() {
41
41
  * LICENSE file in the root directory of this source tree.
42
42
  */
43
43
  return n.NODE_ENV !== "production" && function() {
44
- var e = Pr, 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"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, m = "@@iterator";
44
+ var e = Mr, 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"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, m = "@@iterator";
45
45
  function S(d) {
46
46
  if (d === null || typeof d != "object")
47
47
  return null;
@@ -53,10 +53,10 @@ function Js() {
53
53
  {
54
54
  for (var w = arguments.length, v = new Array(w > 1 ? w - 1 : 0), I = 1; I < w; I++)
55
55
  v[I - 1] = arguments[I];
56
- R("error", d, v);
56
+ M("error", d, v);
57
57
  }
58
58
  }
59
- function R(d, w, v) {
59
+ function M(d, w, v) {
60
60
  {
61
61
  var I = _.ReactDebugCurrentFrame, W = I.getStackAddendum();
62
62
  W !== "" && (w += "%s", v = v.concat([W]));
@@ -130,14 +130,14 @@ function Js() {
130
130
  }
131
131
  return null;
132
132
  }
133
- var E = Object.assign, j = 0, M, U, L, A, k, K, H;
133
+ var E = Object.assign, j = 0, R, U, L, A, k, K, H;
134
134
  function Y() {
135
135
  }
136
136
  Y.__reactDisabledLog = !0;
137
137
  function oe() {
138
138
  {
139
139
  if (j === 0) {
140
- M = console.log, U = console.info, L = console.warn, A = console.error, k = console.group, K = console.groupCollapsed, H = console.groupEnd;
140
+ R = console.log, U = console.info, L = console.warn, A = console.error, k = console.group, K = console.groupCollapsed, H = console.groupEnd;
141
141
  var d = {
142
142
  configurable: !0,
143
143
  enumerable: !0,
@@ -167,7 +167,7 @@ function Js() {
167
167
  };
168
168
  Object.defineProperties(console, {
169
169
  log: E({}, d, {
170
- value: M
170
+ value: R
171
171
  }),
172
172
  info: E({}, d, {
173
173
  value: U
@@ -208,8 +208,8 @@ function Js() {
208
208
  }
209
209
  var $t = !1, lt;
210
210
  {
211
- var Ss = typeof WeakMap == "function" ? WeakMap : Map;
212
- lt = new Ss();
211
+ var vs = typeof WeakMap == "function" ? WeakMap : Map;
212
+ lt = new vs();
213
213
  }
214
214
  function In(d, w) {
215
215
  if (!d || $t)
@@ -282,10 +282,10 @@ function Js() {
282
282
  var Le = d ? d.displayName || d.name : "", Ce = Le ? ut(Le) : "";
283
283
  return typeof d == "function" && lt.set(d, Ce), Ce;
284
284
  }
285
- function vs(d, w, v) {
285
+ function As(d, w, v) {
286
286
  return In(d, !1);
287
287
  }
288
- function As(d) {
288
+ function Os(d) {
289
289
  var w = d.prototype;
290
290
  return !!(w && w.isReactComponent);
291
291
  }
@@ -293,7 +293,7 @@ function Js() {
293
293
  if (d == null)
294
294
  return "";
295
295
  if (typeof d == "function")
296
- return In(d, As(d));
296
+ return In(d, Os(d));
297
297
  if (typeof d == "string")
298
298
  return ut(d);
299
299
  switch (d) {
@@ -305,7 +305,7 @@ function Js() {
305
305
  if (typeof d == "object")
306
306
  switch (d.$$typeof) {
307
307
  case u:
308
- return vs(d.render);
308
+ return As(d.render);
309
309
  case h:
310
310
  return ft(d.type, w, v);
311
311
  case y: {
@@ -318,15 +318,15 @@ function Js() {
318
318
  }
319
319
  return "";
320
320
  }
321
- var He = Object.prototype.hasOwnProperty, Pn = {}, Rn = _.ReactDebugCurrentFrame;
321
+ var He = Object.prototype.hasOwnProperty, Pn = {}, Mn = _.ReactDebugCurrentFrame;
322
322
  function dt(d) {
323
323
  if (d) {
324
324
  var w = d._owner, v = ft(d.type, d._source, w ? w.type : null);
325
- Rn.setExtraStackFrame(v);
325
+ Mn.setExtraStackFrame(v);
326
326
  } else
327
- Rn.setExtraStackFrame(null);
327
+ Mn.setExtraStackFrame(null);
328
328
  }
329
- function Os(d, w, v, I, W) {
329
+ function Es(d, w, v, I, W) {
330
330
  {
331
331
  var V = Function.call.bind(He);
332
332
  for (var D in d)
@@ -345,37 +345,37 @@ function Js() {
345
345
  }
346
346
  }
347
347
  }
348
- var Es = Array.isArray;
348
+ var ks = Array.isArray;
349
349
  function xt(d) {
350
- return Es(d);
350
+ return ks(d);
351
351
  }
352
- function ks(d) {
352
+ function Cs(d) {
353
353
  {
354
354
  var w = typeof Symbol == "function" && Symbol.toStringTag, v = w && d[Symbol.toStringTag] || d.constructor.name || "Object";
355
355
  return v;
356
356
  }
357
357
  }
358
- function Cs(d) {
358
+ function Is(d) {
359
359
  try {
360
- return Mn(d), !1;
360
+ return Rn(d), !1;
361
361
  } catch {
362
362
  return !0;
363
363
  }
364
364
  }
365
- function Mn(d) {
365
+ function Rn(d) {
366
366
  return "" + d;
367
367
  }
368
368
  function jn(d) {
369
- if (Cs(d))
370
- return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ks(d)), Mn(d);
369
+ if (Is(d))
370
+ return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Cs(d)), Rn(d);
371
371
  }
372
- var $n = _.ReactCurrentOwner, Is = {
372
+ var $n = _.ReactCurrentOwner, Ps = {
373
373
  key: !0,
374
374
  ref: !0,
375
375
  __self: !0,
376
376
  __source: !0
377
377
  }, xn, Dn;
378
- function Ps(d) {
378
+ function Ms(d) {
379
379
  if (He.call(d, "ref")) {
380
380
  var w = Object.getOwnPropertyDescriptor(d, "ref").get;
381
381
  if (w && w.isReactWarning)
@@ -391,10 +391,10 @@ function Js() {
391
391
  }
392
392
  return d.key !== void 0;
393
393
  }
394
- function Ms(d, w) {
394
+ function js(d, w) {
395
395
  typeof d.ref == "string" && $n.current;
396
396
  }
397
- function js(d, w) {
397
+ function $s(d, w) {
398
398
  {
399
399
  var v = function() {
400
400
  xn || (xn = !0, T("%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)", w));
@@ -405,7 +405,7 @@ function Js() {
405
405
  });
406
406
  }
407
407
  }
408
- function $s(d, w) {
408
+ function xs(d, w) {
409
409
  {
410
410
  var v = function() {
411
411
  Dn || (Dn = !0, T("%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)", w));
@@ -416,7 +416,7 @@ function Js() {
416
416
  });
417
417
  }
418
418
  }
419
- var xs = function(d, w, v, I, W, V, D) {
419
+ var Ds = function(d, w, v, I, W, V, D) {
420
420
  var $ = {
421
421
  // This tag allows us to uniquely identify this as a React Element
422
422
  $$typeof: t,
@@ -445,12 +445,12 @@ function Js() {
445
445
  value: W
446
446
  }), Object.freeze && (Object.freeze($.props), Object.freeze($)), $;
447
447
  };
448
- function Ds(d, w, v, I, W) {
448
+ function Us(d, w, v, I, W) {
449
449
  {
450
450
  var V, D = {}, $ = null, ae = null;
451
- v !== void 0 && (jn(v), $ = "" + v), Rs(w) && (jn(w.key), $ = "" + w.key), Ps(w) && (ae = w.ref, Ms(w, W));
451
+ v !== void 0 && (jn(v), $ = "" + v), Rs(w) && (jn(w.key), $ = "" + w.key), Ms(w) && (ae = w.ref, js(w, W));
452
452
  for (V in w)
453
- He.call(w, V) && !Is.hasOwnProperty(V) && (D[V] = w[V]);
453
+ He.call(w, V) && !Ps.hasOwnProperty(V) && (D[V] = w[V]);
454
454
  if (d && d.defaultProps) {
455
455
  var Z = d.defaultProps;
456
456
  for (V in Z)
@@ -458,9 +458,9 @@ function Js() {
458
458
  }
459
459
  if ($ || ae) {
460
460
  var te = typeof d == "function" ? d.displayName || d.name || "Unknown" : d;
461
- $ && js(D, te), ae && $s(D, te);
461
+ $ && $s(D, te), ae && xs(D, te);
462
462
  }
463
- return xs(d, $, ae, W, I, $n.current, D);
463
+ return Ds(d, $, ae, W, I, $n.current, D);
464
464
  }
465
465
  }
466
466
  var Dt = _.ReactCurrentOwner, Un = _.ReactDebugCurrentFrame;
@@ -488,11 +488,11 @@ Check the render method of \`` + d + "`.";
488
488
  return "";
489
489
  }
490
490
  }
491
- function Us(d) {
491
+ function Ls(d) {
492
492
  return "";
493
493
  }
494
494
  var Fn = {};
495
- function Ls(d) {
495
+ function Fs(d) {
496
496
  {
497
497
  var w = Ln();
498
498
  if (!w) {
@@ -509,7 +509,7 @@ Check the top-level render call using <` + v + ">.");
509
509
  if (!d._store || d._store.validated || d.key != null)
510
510
  return;
511
511
  d._store.validated = !0;
512
- var v = Ls(w);
512
+ var v = Fs(w);
513
513
  if (Fn[v])
514
514
  return;
515
515
  Fn[v] = !0;
@@ -536,7 +536,7 @@ Check the top-level render call using <` + v + ">.");
536
536
  }
537
537
  }
538
538
  }
539
- function Fs(d) {
539
+ function Ns(d) {
540
540
  {
541
541
  var w = d.type;
542
542
  if (w == null || typeof w == "string")
@@ -552,7 +552,7 @@ Check the top-level render call using <` + v + ">.");
552
552
  return;
553
553
  if (v) {
554
554
  var I = q(w);
555
- Os(v, d.props, "prop", I, d);
555
+ Es(v, d.props, "prop", I, d);
556
556
  } else if (w.PropTypes !== void 0 && !Ut) {
557
557
  Ut = !0;
558
558
  var W = q(w);
@@ -561,7 +561,7 @@ Check the top-level render call using <` + v + ">.");
561
561
  typeof w.getDefaultProps == "function" && !w.getDefaultProps.isReactClassApproved && T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
562
562
  }
563
563
  }
564
- function Ns(d) {
564
+ function Ks(d) {
565
565
  {
566
566
  for (var w = Object.keys(d.props), v = 0; v < w.length; v++) {
567
567
  var I = w[v];
@@ -580,12 +580,12 @@ Check the top-level render call using <` + v + ">.");
580
580
  if (!D) {
581
581
  var $ = "";
582
582
  (d === void 0 || typeof d == "object" && d !== null && Object.keys(d).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.");
583
- var ae = Us();
583
+ var ae = Ls();
584
584
  ae ? $ += ae : $ += Ln();
585
585
  var Z;
586
586
  d === null ? Z = "null" : xt(d) ? Z = "array" : d !== void 0 && d.$$typeof === t ? (Z = "<" + (q(d.type) || "Unknown") + " />", $ = " Did you accidentally export a JSX literal instead of a component?") : Z = typeof d, T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", Z, $);
587
587
  }
588
- var te = Ds(d, w, v, W, V);
588
+ var te = Us(d, w, v, W, V);
589
589
  if (te == null)
590
590
  return te;
591
591
  if (D) {
@@ -602,34 +602,34 @@ Check the top-level render call using <` + v + ">.");
602
602
  Kn(ye, d);
603
603
  }
604
604
  if (He.call(w, "key")) {
605
- var Ce = q(d), ue = Object.keys(w).filter(function(Qs) {
606
- return Qs !== "key";
605
+ var Ce = q(d), ue = Object.keys(w).filter(function(Bs) {
606
+ return Bs !== "key";
607
607
  }), Ft = ue.length > 0 ? "{key: someKey, " + ue.join(": ..., ") + ": ...}" : "{key: someKey}";
608
608
  if (!qn[Ce + Ft]) {
609
- var Vs = ue.length > 0 ? "{" + ue.join(": ..., ") + ": ...}" : "{}";
609
+ var Qs = ue.length > 0 ? "{" + ue.join(": ..., ") + ": ...}" : "{}";
610
610
  T(`A props object containing a "key" prop is being spread into JSX:
611
611
  let props = %s;
612
612
  <%s {...props} />
613
613
  React keys must be passed directly to JSX without using spread:
614
614
  let props = %s;
615
- <%s key={someKey} {...props} />`, Ft, Ce, Vs, Ce), qn[Ce + Ft] = !0;
615
+ <%s key={someKey} {...props} />`, Ft, Ce, Qs, Ce), qn[Ce + Ft] = !0;
616
616
  }
617
617
  }
618
- return d === s ? Ns(te) : Fs(te), te;
618
+ return d === s ? Ks(te) : Ns(te), te;
619
619
  }
620
620
  }
621
- function Ks(d, w, v) {
621
+ function qs(d, w, v) {
622
622
  return Wn(d, w, v, !0);
623
623
  }
624
- function qs(d, w, v) {
624
+ function Ws(d, w, v) {
625
625
  return Wn(d, w, v, !1);
626
626
  }
627
- var Ws = qs, zs = Ks;
628
- Ye.Fragment = s, Ye.jsx = Ws, Ye.jsxs = zs;
627
+ var zs = Ws, Vs = qs;
628
+ Ye.Fragment = s, Ye.jsx = zs, Ye.jsxs = Vs;
629
629
  }(), Ye;
630
630
  }
631
- var Ys = {};
632
- Ys.NODE_ENV === "production" ? Yt.exports = Hs() : Yt.exports = Js();
631
+ var Zs = {};
632
+ Zs.NODE_ENV === "production" ? Yt.exports = Js() : Yt.exports = Ys();
633
633
  var ht = Yt.exports;
634
634
  function se(n) {
635
635
  const e = mt(n);
@@ -706,7 +706,7 @@ const X = {
706
706
  Remove: "remove",
707
707
  Replace: "replace",
708
708
  Add: "add"
709
- }, Mr = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Zs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), wt = Symbol.iterator, pe = {
709
+ }, jr = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Xs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), wt = Symbol.iterator, pe = {
710
710
  mutable: "mutable",
711
711
  immutable: "immutable"
712
712
  }, bn = {};
@@ -738,7 +738,7 @@ function $e(n) {
738
738
  return !!x(n);
739
739
  }
740
740
  function x(n) {
741
- return typeof n != "object" ? null : n == null ? void 0 : n[Mr];
741
+ return typeof n != "object" ? null : n == null ? void 0 : n[jr];
742
742
  }
743
743
  function mn(n) {
744
744
  var e;
@@ -751,7 +751,7 @@ function me(n, e) {
751
751
  let t;
752
752
  return Object.getPrototypeOf(n) === Object.prototype || Array.isArray(n) || n instanceof Map || n instanceof Set || !!(e != null && e.mark) && ((t = e.mark(n, pe)) === pe.immutable || typeof t == "function");
753
753
  }
754
- function jr(n, e = []) {
754
+ function $r(n, e = []) {
755
755
  if (Object.hasOwnProperty.call(n, "key")) {
756
756
  const t = n.parent.copy, r = x(Ee(t, n.key));
757
757
  if (r !== null && (r == null ? void 0 : r.original) !== n.original)
@@ -762,10 +762,10 @@ function jr(n, e = []) {
762
762
  e.push(i);
763
763
  }
764
764
  if (n.parent)
765
- return jr(n.parent, e);
765
+ return $r(n.parent, e);
766
766
  e.reverse();
767
767
  try {
768
- Xs(n.copy, e);
768
+ ei(n.copy, e);
769
769
  } catch {
770
770
  return null;
771
771
  }
@@ -792,13 +792,13 @@ function Zt(n) {
792
792
  for (; n.finalities.revoke.length > 0; )
793
793
  n.finalities.revoke.pop()();
794
794
  }
795
- function Re(n, e) {
795
+ function Me(n, e) {
796
796
  return e ? n : [""].concat(n).map((t) => {
797
797
  const r = `${t}`;
798
798
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
799
799
  }).join("/");
800
800
  }
801
- function Xs(n, e) {
801
+ function ei(n, e) {
802
802
  for (let t = 0; t < e.length - 1; t += 1) {
803
803
  const r = e[t];
804
804
  if (n = Ee(xe(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
@@ -806,7 +806,7 @@ function Xs(n, e) {
806
806
  }
807
807
  return n;
808
808
  }
809
- function ei(n) {
809
+ function ti(n) {
810
810
  const e = Object.create(Object.getPrototypeOf(n));
811
811
  return Reflect.ownKeys(n).forEach((t) => {
812
812
  let r = Reflect.getOwnPropertyDescriptor(n, t);
@@ -822,8 +822,8 @@ function ei(n) {
822
822
  }), Reflect.defineProperty(e, t, r);
823
823
  }), e;
824
824
  }
825
- const ti = Object.prototype.propertyIsEnumerable;
826
- function $r(n, e) {
825
+ const ni = Object.prototype.propertyIsEnumerable;
826
+ function xr(n, e) {
827
827
  let t;
828
828
  if (Array.isArray(n))
829
829
  return Array.prototype.concat.call(n);
@@ -841,7 +841,7 @@ function $r(n, e) {
841
841
  return new Map(n);
842
842
  } else if (e != null && e.mark && (t = e.mark(n, pe), t !== void 0) && t !== pe.mutable) {
843
843
  if (t === pe.immutable)
844
- return ei(n);
844
+ return ti(n);
845
845
  if (typeof t == "function") {
846
846
  if (e.enablePatches || e.enableAutoFreeze)
847
847
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -853,13 +853,13 @@ function $r(n, e) {
853
853
  return Object.keys(n).forEach((s) => {
854
854
  r[s] = n[s];
855
855
  }), Object.getOwnPropertySymbols(n).forEach((s) => {
856
- ti.call(n, s) && (r[s] = n[s]);
856
+ ni.call(n, s) && (r[s] = n[s]);
857
857
  }), r;
858
858
  } else
859
859
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
860
860
  }
861
861
  function ce(n) {
862
- n.copy || (n.copy = $r(n.original, n.options));
862
+ n.copy || (n.copy = xr(n.original, n.options));
863
863
  }
864
864
  function Xe(n) {
865
865
  if (!me(n))
@@ -959,7 +959,7 @@ function wn(n, e) {
959
959
  } else
960
960
  n.forEach((r, s) => e(s, r, n));
961
961
  }
962
- function xr(n, e, t) {
962
+ function Dr(n, e, t) {
963
963
  if ($e(n) || !me(n, t) || e.has(n) || Object.isFrozen(n))
964
964
  return;
965
965
  const r = n instanceof Set, s = r ? /* @__PURE__ */ new Map() : void 0;
@@ -971,7 +971,7 @@ function xr(n, e, t) {
971
971
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
972
972
  at(r ? s : n, i, u);
973
973
  } else
974
- xr(o, e, t);
974
+ Dr(o, e, t);
975
975
  }), s) {
976
976
  const i = n, o = Array.from(i);
977
977
  i.clear(), o.forEach((a) => {
@@ -979,9 +979,9 @@ function xr(n, e, t) {
979
979
  });
980
980
  }
981
981
  }
982
- function ni(n, e) {
982
+ function ri(n, e) {
983
983
  const t = n.type === 3 ? n.setMap : n.copy;
984
- n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && xr(Ee(t, e), n.finalities.handledSet, n.options);
984
+ n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && Dr(Ee(t, e), n.finalities.handledSet, n.options);
985
985
  }
986
986
  function Xt(n) {
987
987
  n.type === 3 && n.copy && (n.copy.clear(), n.setMap.forEach((e) => {
@@ -991,7 +991,7 @@ function Xt(n) {
991
991
  function en(n, e, t, r) {
992
992
  if (n.operated && n.assignedMap && n.assignedMap.size > 0 && !n.finalized) {
993
993
  if (t && r) {
994
- const i = jr(n);
994
+ const i = $r(n);
995
995
  i && e(n, i, t, r);
996
996
  }
997
997
  n.finalized = !0;
@@ -1008,15 +1008,15 @@ function Tn(n, e, t, r) {
1008
1008
  }
1009
1009
  }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), me(t, n.options) && n.finalities.draft.push(() => {
1010
1010
  const i = n.type === 3 ? n.setMap : n.copy;
1011
- Oe(Ee(i, e), t) && ni(n, e);
1011
+ Oe(Ee(i, e), t) && ri(n, e);
1012
1012
  });
1013
1013
  }
1014
- function ri(n, e, t, r, s) {
1014
+ function si(n, e, t, r, s) {
1015
1015
  let { original: i, assignedMap: o, options: a } = n, c = n.copy;
1016
1016
  c.length < i.length && ([i, c] = [c, i], [t, r] = [r, t]);
1017
1017
  for (let u = 0; u < i.length; u += 1)
1018
1018
  if (o.get(u.toString()) && c[u] !== i[u]) {
1019
- const l = e.concat([u]), f = Re(l, s);
1019
+ const l = e.concat([u]), f = Me(l, s);
1020
1020
  t.push({
1021
1021
  op: X.Replace,
1022
1022
  path: f,
@@ -1030,7 +1030,7 @@ function ri(n, e, t, r, s) {
1030
1030
  });
1031
1031
  }
1032
1032
  for (let u = i.length; u < c.length; u += 1) {
1033
- const l = e.concat([u]), f = Re(l, s);
1033
+ const l = e.concat([u]), f = Me(l, s);
1034
1034
  t.push({
1035
1035
  op: X.Add,
1036
1036
  path: f,
@@ -1041,7 +1041,7 @@ function ri(n, e, t, r, s) {
1041
1041
  if (i.length < c.length) {
1042
1042
  const { arrayLengthAssignment: u = !0 } = a.enablePatches;
1043
1043
  if (u) {
1044
- const l = e.concat(["length"]), f = Re(l, s);
1044
+ const l = e.concat(["length"]), f = Me(l, s);
1045
1045
  r.push({
1046
1046
  op: X.Replace,
1047
1047
  path: f,
@@ -1049,7 +1049,7 @@ function ri(n, e, t, r, s) {
1049
1049
  });
1050
1050
  } else
1051
1051
  for (let l = c.length; i.length < l; l -= 1) {
1052
- const f = e.concat([l - 1]), h = Re(f, s);
1052
+ const f = e.concat([l - 1]), h = Me(f, s);
1053
1053
  r.push({
1054
1054
  op: X.Remove,
1055
1055
  path: h
@@ -1057,20 +1057,20 @@ function ri(n, e, t, r, s) {
1057
1057
  }
1058
1058
  }
1059
1059
  }
1060
- function si({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
1060
+ function ii({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
1061
1061
  t.forEach((a, c) => {
1062
1062
  const u = Ee(n, c), l = Tt(Ee(e, c)), f = a ? st(n, c) ? X.Replace : X.Add : X.Remove;
1063
1063
  if (Oe(u, l) && f === X.Replace)
1064
1064
  return;
1065
- const h = r.concat(c), y = Re(h, o);
1065
+ const h = r.concat(c), y = Me(h, o);
1066
1066
  s.push(f === X.Remove ? { op: f, path: y } : { op: f, path: y, value: l }), i.push(f === X.Add ? { op: X.Remove, path: y } : f === X.Remove ? { op: X.Add, path: y, value: u } : { op: X.Replace, path: y, value: u });
1067
1067
  });
1068
1068
  }
1069
- function ii({ original: n, copy: e }, t, r, s, i) {
1069
+ function oi({ original: n, copy: e }, t, r, s, i) {
1070
1070
  let o = 0;
1071
1071
  n.forEach((a) => {
1072
1072
  if (!e.has(a)) {
1073
- const c = t.concat([o]), u = Re(c, i);
1073
+ const c = t.concat([o]), u = Me(c, i);
1074
1074
  r.push({
1075
1075
  op: X.Remove,
1076
1076
  path: u,
@@ -1084,7 +1084,7 @@ function ii({ original: n, copy: e }, t, r, s, i) {
1084
1084
  o += 1;
1085
1085
  }), o = 0, e.forEach((a) => {
1086
1086
  if (!n.has(a)) {
1087
- const c = t.concat([o]), u = Re(c, i);
1087
+ const c = t.concat([o]), u = Me(c, i);
1088
1088
  r.push({
1089
1089
  op: X.Add,
1090
1090
  path: u,
@@ -1103,11 +1103,11 @@ function ot(n, e, t, r) {
1103
1103
  switch (n.type) {
1104
1104
  case 0:
1105
1105
  case 2:
1106
- return si(n, e, t, r, s);
1106
+ return ii(n, e, t, r, s);
1107
1107
  case 1:
1108
- return ri(n, e, t, r, s);
1108
+ return si(n, e, t, r, s);
1109
1109
  case 3:
1110
- return ii(n, e, t, r, s);
1110
+ return oi(n, e, t, r, s);
1111
1111
  }
1112
1112
  }
1113
1113
  const Ot = (n, e, t = !1) => {
@@ -1194,7 +1194,7 @@ const Ot = (n, e, t = !1) => {
1194
1194
  [wt]() {
1195
1195
  return this.entries();
1196
1196
  }
1197
- }, oi = Reflect.ownKeys(tn), Gn = (n, e, { isValuesIterator: t }) => () => {
1197
+ }, ai = Reflect.ownKeys(tn), Gn = (n, e, { isValuesIterator: t }) => () => {
1198
1198
  var r, s;
1199
1199
  const i = e.next();
1200
1200
  if (i.done)
@@ -1305,13 +1305,13 @@ Set.prototype.difference && Object.assign(Et, {
1305
1305
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), n);
1306
1306
  }
1307
1307
  });
1308
- const ai = Reflect.ownKeys(Et), Dr = /* @__PURE__ */ new WeakSet(), Ur = {
1308
+ const ci = Reflect.ownKeys(Et), Ur = /* @__PURE__ */ new WeakSet(), Lr = {
1309
1309
  get(n, e, t) {
1310
1310
  var r, s;
1311
1311
  const i = (r = n.copy) === null || r === void 0 ? void 0 : r[e];
1312
- if (i && Dr.has(i))
1312
+ if (i && Ur.has(i))
1313
1313
  return i;
1314
- if (e === Mr)
1314
+ if (e === jr)
1315
1315
  return n;
1316
1316
  let o;
1317
1317
  if (n.options.mark) {
@@ -1320,14 +1320,14 @@ const ai = Reflect.ownKeys(Et), Dr = /* @__PURE__ */ new WeakSet(), Ur = {
1320
1320
  return n.options.strict && Ot(u, n.options, !0), u;
1321
1321
  }
1322
1322
  const a = he(n);
1323
- if (a instanceof Map && oi.includes(e)) {
1323
+ if (a instanceof Map && ai.includes(e)) {
1324
1324
  if (e === "size")
1325
1325
  return Object.getOwnPropertyDescriptor(tn, "size").get.call(n.proxy);
1326
1326
  const u = tn[e];
1327
1327
  if (u)
1328
1328
  return u.bind(n.proxy);
1329
1329
  }
1330
- if (a instanceof Set && ai.includes(e)) {
1330
+ if (a instanceof Set && ci.includes(e)) {
1331
1331
  if (e === "size")
1332
1332
  return Object.getOwnPropertyDescriptor(Et, "size").get.call(n.proxy);
1333
1333
  const u = Et[e];
@@ -1398,7 +1398,7 @@ const ai = Reflect.ownKeys(Et), Dr = /* @__PURE__ */ new WeakSet(), Ur = {
1398
1398
  },
1399
1399
  deleteProperty(n, e) {
1400
1400
  var t;
1401
- return n.type === 1 ? Ur.set.call(this, n, e, void 0, n.proxy) : (Nt(n.original, e) !== void 0 || e in n.original ? (ce(n), Se(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);
1401
+ return n.type === 1 ? Lr.set.call(this, n, e, void 0, n.proxy) : (Nt(n.original, e) !== void 0 || e in n.original ? (ce(n), Se(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);
1402
1402
  }
1403
1403
  };
1404
1404
  function Sn(n) {
@@ -1415,8 +1415,8 @@ function Sn(n) {
1415
1415
  setMap: o === 3 ? new Map(e.entries()) : void 0
1416
1416
  };
1417
1417
  (r || "key" in n) && (a.key = r);
1418
- const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, Ur);
1419
- if (s.revoke.push(u), Dr.add(c), a.proxy = c, t) {
1418
+ const { proxy: c, revoke: u } = Proxy.revocable(o === 1 ? Object.assign([], a) : a, Lr);
1419
+ if (s.revoke.push(u), Ur.add(c), a.proxy = c, t) {
1420
1420
  const l = t;
1421
1421
  l.finalities.draft.push((f, h) => {
1422
1422
  var y, b;
@@ -1440,7 +1440,7 @@ function Sn(n) {
1440
1440
  return c;
1441
1441
  }
1442
1442
  bn.createDraft = Sn;
1443
- function ci(n, e, t, r, s) {
1443
+ function ui(n, e, t, r, s) {
1444
1444
  var i;
1445
1445
  const o = x(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
1446
1446
  if (o != null && o.operated)
@@ -1453,7 +1453,7 @@ function ci(n, e, t, r, s) {
1453
1453
  r && c ? [{ op: X.Replace, path: [], value: a }] : r
1454
1454
  ];
1455
1455
  }
1456
- function ui(n, e) {
1456
+ function li(n, e) {
1457
1457
  var t;
1458
1458
  const r = {
1459
1459
  draft: [],
@@ -1471,7 +1471,7 @@ function ui(n, e) {
1471
1471
  return [
1472
1472
  a,
1473
1473
  (c = []) => {
1474
- const [u, l, f] = ci(a, c, s, i, e.enableAutoFreeze);
1474
+ const [u, l, f] = ui(a, c, s, i, e.enableAutoFreeze);
1475
1475
  return e.enablePatches ? [u, l, f] : u;
1476
1476
  }
1477
1477
  ];
@@ -1491,7 +1491,7 @@ function nn(n) {
1491
1491
  } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, nn(n));
1492
1492
  }), 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."));
1493
1493
  }
1494
- function Lr(n) {
1494
+ function Fr(n) {
1495
1495
  var e;
1496
1496
  const t = x(n);
1497
1497
  if (!me(n, t == null ? void 0 : t.options))
@@ -1501,7 +1501,7 @@ function Lr(n) {
1501
1501
  return t.original;
1502
1502
  let s;
1503
1503
  function i() {
1504
- s = r === 2 ? _n(n) ? new Map(n) : new (Object.getPrototypeOf(n)).constructor(n) : r === 3 ? Array.from(t.setMap.values()) : $r(n, t == null ? void 0 : t.options);
1504
+ s = r === 2 ? _n(n) ? new Map(n) : new (Object.getPrototypeOf(n)).constructor(n) : r === 3 ? Array.from(t.setMap.values()) : xr(n, t == null ? void 0 : t.options);
1505
1505
  }
1506
1506
  if (t) {
1507
1507
  t.finalized = !0;
@@ -1515,7 +1515,7 @@ function Lr(n) {
1515
1515
  if (wn(s, (o, a) => {
1516
1516
  if (t && Oe(Ee(t.original, o), a))
1517
1517
  return;
1518
- const c = Lr(a);
1518
+ const c = Fr(a);
1519
1519
  c !== a && (s === n && i(), at(s, o, c));
1520
1520
  }), r === 3) {
1521
1521
  const o = (e = t == null ? void 0 : t.original) !== null && e !== void 0 ? e : s;
@@ -1526,9 +1526,9 @@ function Lr(n) {
1526
1526
  function Hn(n) {
1527
1527
  if (!$e(n))
1528
1528
  throw new Error(`current() is only used for Draft, parameter: ${n}`);
1529
- return Lr(n);
1529
+ return Fr(n);
1530
1530
  }
1531
- const li = (n) => function e(t, r, s) {
1531
+ const fi = (n) => function e(t, r, s) {
1532
1532
  var i, o, a;
1533
1533
  if (typeof t == "function" && typeof r != "function")
1534
1534
  return function(O, ...F) {
@@ -1555,7 +1555,7 @@ const li = (n) => function e(t, r, s) {
1555
1555
  };
1556
1556
  if (!me(f, m) && typeof f == "object" && f !== null)
1557
1557
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1558
- const [S, _] = ui(f, m);
1558
+ const [S, _] = li(f, m);
1559
1559
  if (typeof r != "function") {
1560
1560
  if (!me(f, m))
1561
1561
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -1567,12 +1567,12 @@ const li = (n) => function e(t, r, s) {
1567
1567
  } catch (O) {
1568
1568
  throw Zt(x(S)), O;
1569
1569
  }
1570
- const R = (O) => {
1570
+ const M = (O) => {
1571
1571
  const F = x(S);
1572
1572
  if (!$e(O)) {
1573
1573
  if (O !== void 0 && !Oe(O, S) && (F != null && F.operated))
1574
1574
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
1575
- const C = O == null ? void 0 : O[Zs];
1575
+ const C = O == null ? void 0 : O[Xs];
1576
1576
  if (C) {
1577
1577
  const G = C[0];
1578
1578
  return m.strict && typeof O == "object" && O !== null && nn({
@@ -1594,12 +1594,12 @@ const li = (n) => function e(t, r, s) {
1594
1594
  }
1595
1595
  return _([O]);
1596
1596
  };
1597
- return T instanceof Promise ? T.then(R, (O) => {
1597
+ return T instanceof Promise ? T.then(M, (O) => {
1598
1598
  throw Zt(x(S)), O;
1599
- }) : R(T);
1600
- }, kt = li();
1599
+ }) : M(T);
1600
+ }, kt = fi();
1601
1601
  Object.prototype.constructor.toString();
1602
- function Fr(n, e) {
1602
+ function Nr(n, e) {
1603
1603
  const t = Object.keys(n), r = Object.keys(e);
1604
1604
  return t.length === r.length && Object.keys(n).every((s) => e.hasOwnProperty(s));
1605
1605
  }
@@ -1607,7 +1607,7 @@ function Jn(n, e) {
1607
1607
  return Object.keys(n).length === Object.keys(e).length && Object.keys(n).every((t) => e.hasOwnProperty(t) && n[t] === e[t]);
1608
1608
  }
1609
1609
  function St(n, e) {
1610
- return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Fr(n, e) ? Object.keys(n).every((t) => St(n[t], e[t])) : !1;
1610
+ return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Nr(n, e) ? Object.keys(n).every((t) => St(n[t], e[t])) : !1;
1611
1611
  }
1612
1612
  function vn(n) {
1613
1613
  if (!et(n))
@@ -1617,7 +1617,7 @@ function vn(n) {
1617
1617
  r !== void 0 && (e[t] = r);
1618
1618
  return e;
1619
1619
  }
1620
- function Nr(n, e) {
1620
+ function Kr(n, e) {
1621
1621
  if (!et(n) || !et(e))
1622
1622
  return e;
1623
1623
  const t = { ...n };
@@ -1629,14 +1629,14 @@ function Nr(n, e) {
1629
1629
  continue;
1630
1630
  }
1631
1631
  const s = et(n[r]) && et(e[r]);
1632
- t[r] = s ? Nr(n[r], e[r]) : e[r];
1632
+ t[r] = s ? Kr(n[r], e[r]) : e[r];
1633
1633
  }
1634
1634
  return t;
1635
1635
  }
1636
1636
  function et(n) {
1637
1637
  return typeof n == "object" && n !== null && !Array.isArray(n);
1638
1638
  }
1639
- function fi(n, e, t) {
1639
+ function di(n, e, t) {
1640
1640
  if (!n || e.length === 0)
1641
1641
  return;
1642
1642
  let r = n || {};
@@ -1657,7 +1657,7 @@ function Yn(n, e, t) {
1657
1657
  }
1658
1658
  r[e[e.length - 1]] = t;
1659
1659
  }
1660
- function Kr(n, e) {
1660
+ function qr(n, e) {
1661
1661
  if (!n || e.length === 0)
1662
1662
  return;
1663
1663
  const [t, ...r] = e;
@@ -1666,13 +1666,13 @@ function Kr(n, e) {
1666
1666
  Array.isArray(n) ? n.splice(t, 1) : delete n[t];
1667
1667
  return;
1668
1668
  }
1669
- Kr(n[t], r), di(n[t]) && delete n[t];
1669
+ qr(n[t], r), hi(n[t]) && delete n[t];
1670
1670
  }
1671
1671
  }
1672
- function di(n) {
1672
+ function hi(n) {
1673
1673
  return n && Object.keys(n).length === 0;
1674
1674
  }
1675
- const Zn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, hi = {
1675
+ const Zn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, pi = {
1676
1676
  ZULU: 0,
1677
1677
  YEKT: 18e3,
1678
1678
  YEKST: 21600,
@@ -1868,39 +1868,39 @@ const Zn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1868
1868
  ACSST: 37800,
1869
1869
  ACDT: 37800
1870
1870
  };
1871
- function pi(n) {
1871
+ function yi(n) {
1872
1872
  return new Date(n);
1873
1873
  }
1874
- function yi(n) {
1874
+ function bi(n) {
1875
1875
  return /* @__PURE__ */ new Date(n + "Z");
1876
1876
  }
1877
- const bi = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1878
- function gi(n) {
1879
- const e = n.match(bi);
1877
+ const gi = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1878
+ function _i(n) {
1879
+ const e = n.match(gi);
1880
1880
  if (!e)
1881
1881
  return null;
1882
1882
  const [t, r, s, i] = e;
1883
1883
  return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
1884
1884
  }
1885
- function _i(n) {
1885
+ function mi(n) {
1886
1886
  const [e, t] = n.split(" ");
1887
1887
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1888
1888
  }
1889
- function mi(n) {
1889
+ function wi(n) {
1890
1890
  const [e, t] = n.split(" ");
1891
1891
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1892
1892
  }
1893
- function wi(n) {
1893
+ function Ti(n) {
1894
1894
  return new Date(n);
1895
1895
  }
1896
- function Ti(n) {
1896
+ function Si(n) {
1897
1897
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1898
1898
  if (!n.match(e))
1899
1899
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1900
1900
  const r = /* @__PURE__ */ new Date(n + " UTC");
1901
1901
  return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
1902
1902
  }
1903
- function Si(n) {
1903
+ function vi(n) {
1904
1904
  const e = /^(.+T.+)([+-])(\d{2})$/, t = n.match(e);
1905
1905
  if (t) {
1906
1906
  const [, r, s, i] = t, o = `${r}${s}${i}:00`;
@@ -1908,7 +1908,7 @@ function Si(n) {
1908
1908
  }
1909
1909
  return null;
1910
1910
  }
1911
- function vi(n) {
1911
+ function Ai(n) {
1912
1912
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?(.*)$/, t = n.match(e);
1913
1913
  if (t) {
1914
1914
  const [, r, s, i, o, a, c, u, l] = t, f = s.padStart(2, "0"), h = i.padStart(2, "0");
@@ -1919,14 +1919,14 @@ function vi(n) {
1919
1919
  }
1920
1920
  return null;
1921
1921
  }
1922
- function Ai(n) {
1922
+ function Oi(n) {
1923
1923
  const [e, t] = n.split(", "), [r, s, i] = e.split("/").map(Number), o = t.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1924
1924
  if (!o)
1925
1925
  throw new Error(`Unable to parse time from: ${n}`);
1926
1926
  let [, a, c, u, l] = o;
1927
1927
  return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
1928
1928
  }
1929
- function Oi(n) {
1929
+ function Ei(n) {
1930
1930
  switch (n) {
1931
1931
  case "epoch":
1932
1932
  return /* @__PURE__ */ new Date(0);
@@ -1938,28 +1938,28 @@ function Oi(n) {
1938
1938
  return null;
1939
1939
  }
1940
1940
  }
1941
- function Ei(n) {
1941
+ function ki(n) {
1942
1942
  const e = n.match(Zn);
1943
1943
  if (!e)
1944
1944
  return null;
1945
- const [t] = e, r = hi[t], s = new Date(n.replace(Zn, "Z"));
1945
+ const [t] = e, r = pi[t], s = new Date(n.replace(Zn, "Z"));
1946
1946
  return new Date(s.getTime() - r * 1e3);
1947
1947
  }
1948
- const ki = [
1949
- gi,
1950
- mi,
1951
- Ti,
1952
- Ai,
1953
- yi,
1954
- Si,
1948
+ const Ci = [
1955
1949
  _i,
1956
- pi,
1950
+ wi,
1951
+ Si,
1957
1952
  Oi,
1958
- Ei,
1953
+ bi,
1959
1954
  vi,
1960
- wi
1955
+ mi,
1956
+ yi,
1957
+ Ei,
1958
+ ki,
1959
+ Ai,
1960
+ Ti
1961
1961
  ];
1962
- function Ci(n, e) {
1962
+ function Ii(n, e) {
1963
1963
  try {
1964
1964
  const t = n(e);
1965
1965
  return t instanceof Date && !isNaN(t.getTime()) ? t : null;
@@ -1968,14 +1968,14 @@ function Ci(n, e) {
1968
1968
  }
1969
1969
  }
1970
1970
  function rn(n) {
1971
- for (const e of ki) {
1972
- const t = Ci(e, n);
1971
+ for (const e of Ci) {
1972
+ const t = Ii(e, n);
1973
1973
  if (t)
1974
1974
  return t;
1975
1975
  }
1976
1976
  return null;
1977
1977
  }
1978
- function Ii(n) {
1978
+ function Pi(n) {
1979
1979
  try {
1980
1980
  const e = JSON.parse(n);
1981
1981
  return typeof e == "string" ? rn(e) : null;
@@ -1990,7 +1990,7 @@ function Pt(n) {
1990
1990
  if (n instanceof Date)
1991
1991
  return n;
1992
1992
  if (typeof n == "string") {
1993
- const e = rn(n) || Ii(n) || rn(n.trim());
1993
+ const e = rn(n) || Pi(n) || rn(n.trim());
1994
1994
  if (!e)
1995
1995
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1996
1996
  return e;
@@ -1999,7 +1999,7 @@ function Pt(n) {
1999
1999
  throw new Error(`Invalid date value \`${n}\`. Expected a date, number, or string, got type ${typeof n}.`);
2000
2000
  }
2001
2001
  }
2002
- class Me {
2002
+ class Re {
2003
2003
  constructor(e, t) {
2004
2004
  p(this, "attrs");
2005
2005
  p(this, "linkIndex");
@@ -2074,7 +2074,7 @@ class Me {
2074
2074
  return { attrs: this.attrs, linkIndex: this.linkIndex };
2075
2075
  }
2076
2076
  }
2077
- function Pi(n) {
2077
+ function Mi(n) {
2078
2078
  return n.cardinality === "one";
2079
2079
  }
2080
2080
  function An(n) {
@@ -2106,7 +2106,7 @@ function le(n, e, t) {
2106
2106
  }
2107
2107
  s > -1 && r.set(e[s], t);
2108
2108
  }
2109
- function qr(n, e, t) {
2109
+ function Wr(n, e, t) {
2110
2110
  const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2111
2111
  for (const o of e) {
2112
2112
  let [a, c, u] = o;
@@ -2119,7 +2119,7 @@ function qr(n, e, t) {
2119
2119
  }
2120
2120
  return { eav: r, aev: s, vae: i };
2121
2121
  }
2122
- function Wr(n) {
2122
+ function zr(n) {
2123
2123
  return {
2124
2124
  triples: fe(n.eav, 3),
2125
2125
  cardinalityInference: n.cardinalityInference,
@@ -2127,20 +2127,20 @@ function Wr(n) {
2127
2127
  version: 1
2128
2128
  };
2129
2129
  }
2130
- function zr(n, e) {
2130
+ function Vr(n, e) {
2131
2131
  return tt(n, e.triples, e.cardinalityInference, e.useDateObjects);
2132
2132
  }
2133
- function Vr(n, e) {
2133
+ function Qr(n, e) {
2134
2134
  if (n)
2135
- return new Me(n.attrs, n.linkIndex);
2135
+ return new Re(n.attrs, n.linkIndex);
2136
2136
  if (e && "__type" in e)
2137
- return new Me(e.attrs, e.linkIndex);
2137
+ return new Re(e.attrs, e.linkIndex);
2138
2138
  }
2139
2139
  function Ri(n, e) {
2140
2140
  return Be(n.eav, [e]) !== void 0;
2141
2141
  }
2142
2142
  function tt(n, e, t, r) {
2143
- const s = qr(n, e, r);
2143
+ const s = Wr(n, e, r);
2144
2144
  return s.cardinalityInference = t, s.useDateObjects = r, s;
2145
2145
  }
2146
2146
  function ct(n, e) {
@@ -2170,21 +2170,21 @@ function ct(n, e) {
2170
2170
  return [t, ...a];
2171
2171
  }
2172
2172
  }
2173
- function Qr(n, e, t) {
2173
+ function Br(n, e, t) {
2174
2174
  const r = ct(n, t);
2175
2175
  if (!r)
2176
2176
  return;
2177
2177
  const [s, i, o] = r, a = e.getAttr(i);
2178
2178
  a && (_e(n.eav, [s, i, o]), _e(n.aev, [i, s, o]), An(a) && _e(n.vae, [o, i, s]));
2179
2179
  }
2180
- let Mi = 0;
2181
- function Br(n, e, t) {
2180
+ let ji = 0;
2181
+ function Gr(n, e, t) {
2182
2182
  const [r, s, i] = t;
2183
2183
  let o;
2184
2184
  const a = Be(n.eav, [r, s, i]);
2185
- return a && (o = a[3]), o || Date.now() * 10 + Mi++;
2185
+ return a && (o = a[3]), o || Date.now() * 10 + ji++;
2186
2186
  }
2187
- function Gr(n, e, t) {
2187
+ function Hr(n, e, t) {
2188
2188
  const r = ct(n, t);
2189
2189
  if (!r)
2190
2190
  return;
@@ -2193,10 +2193,10 @@ function Gr(n, e, t) {
2193
2193
  if (!a)
2194
2194
  return;
2195
2195
  a["checked-data-type"] === "date" && n.useDateObjects && (o = Pt(o));
2196
- const c = Be(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Br(n, a, r), l = [s, i, o, u];
2197
- Pi(a) ? (le(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), le(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (le(n.eav, [s, i, o], l), le(n.aev, [i, s, o], l)), An(a) && le(n.vae, [o, i, s], l);
2196
+ const c = Be(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Gr(n, a, r), l = [s, i, o, u];
2197
+ Mi(a) ? (le(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), le(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (le(n.eav, [s, i, o], l), le(n.aev, [i, s, o], l)), An(a) && le(n.vae, [o, i, s], l);
2198
2198
  }
2199
- function ji(n, e, t) {
2199
+ function $i(n, e, t) {
2200
2200
  var y;
2201
2201
  const r = ct(n, t);
2202
2202
  if (!r)
@@ -2212,11 +2212,11 @@ function ji(n, e, t) {
2212
2212
  const u = (y = c.values().next()) == null ? void 0 : y.value;
2213
2213
  if (!u)
2214
2214
  return;
2215
- const l = u[2], f = Nr(l, o), h = [
2215
+ const l = u[2], f = Kr(l, o), h = [
2216
2216
  s,
2217
2217
  i,
2218
2218
  f,
2219
- Br(n, a, u)
2219
+ Gr(n, a, u)
2220
2220
  ];
2221
2221
  le(n.eav, [s, i], /* @__PURE__ */ new Map([[f, h]])), le(n.aev, [i, s], /* @__PURE__ */ new Map([[f, h]]));
2222
2222
  }
@@ -2247,50 +2247,50 @@ function sn(n, e, t) {
2247
2247
  (!s || !g || ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s) && (_e(n.eav, [h, y, b]), _e(n.aev, [y, h, b]), _e(n.vae, [b, y, h])), g && g["on-delete"] === "cascade" && ((S = g["reverse-identity"]) == null ? void 0 : S[1]) === s && sn(n, e, [h, (_ = g["forward-identity"]) == null ? void 0 : _[1]]);
2248
2248
  }), ((l = n.vae.get(o)) == null ? void 0 : l.size) === 0 && _e(n.vae, [o]);
2249
2249
  }
2250
- function Hr(n, e, t) {
2251
- const r = qr(e, t, n.useDateObjects);
2250
+ function Jr(n, e, t) {
2251
+ const r = Wr(e, t, n.useDateObjects);
2252
2252
  Object.keys(r).forEach((s) => {
2253
2253
  n[s] = r[s];
2254
2254
  });
2255
2255
  }
2256
- function $i(n, [e]) {
2256
+ function xi(n, [e]) {
2257
2257
  n.addAttr(e);
2258
2258
  }
2259
- function Jr(n) {
2259
+ function Yr(n) {
2260
2260
  return fe(n.eav, 3);
2261
2261
  }
2262
- function xi(n, e, [t]) {
2262
+ function Di(n, e, [t]) {
2263
2263
  if (!e.getAttr(t))
2264
2264
  return;
2265
- const r = Jr(n).filter(([s, i]) => i !== t);
2266
- e.deleteAttr(t), Hr(n, e, r);
2265
+ const r = Yr(n).filter(([s, i]) => i !== t);
2266
+ e.deleteAttr(t), Jr(n, e, r);
2267
2267
  }
2268
- function Di(n, e, [t]) {
2269
- e.getAttr(t.id) && (e.updateAttr(t), Hr(n, e, Jr(n)));
2268
+ function Ui(n, e, [t]) {
2269
+ e.getAttr(t.id) && (e.updateAttr(t), Jr(n, e, Yr(n)));
2270
2270
  }
2271
- function Ui(n, e, t) {
2271
+ function Li(n, e, t) {
2272
2272
  const [r, ...s] = t;
2273
2273
  switch (r) {
2274
2274
  case "add-triple":
2275
- Gr(n, e, s);
2275
+ Hr(n, e, s);
2276
2276
  break;
2277
2277
  case "deep-merge-triple":
2278
- ji(n, e, s);
2278
+ $i(n, e, s);
2279
2279
  break;
2280
2280
  case "retract-triple":
2281
- Qr(n, e, s);
2281
+ Br(n, e, s);
2282
2282
  break;
2283
2283
  case "delete-entity":
2284
2284
  sn(n, e, s);
2285
2285
  break;
2286
2286
  case "add-attr":
2287
- $i(e, s);
2287
+ xi(e, s);
2288
2288
  break;
2289
2289
  case "delete-attr":
2290
- xi(n, e, s);
2290
+ Di(n, e, s);
2291
2291
  break;
2292
2292
  case "update-attr":
2293
- Di(n, e, s);
2293
+ Ui(n, e, s);
2294
2294
  break;
2295
2295
  case "restore-attr":
2296
2296
  break;
@@ -2345,13 +2345,13 @@ function pt(n, e, t) {
2345
2345
  }
2346
2346
  return r;
2347
2347
  }
2348
- function Li(n, e, t) {
2348
+ function Fi(n, e, t) {
2349
2349
  let r = "";
2350
2350
  return n !== void 0 && (r += "e"), e !== void 0 && (r += "a"), t !== void 0 && (r += "v"), r;
2351
2351
  }
2352
- function Fi(n, [e, t, r]) {
2352
+ function Ni(n, [e, t, r]) {
2353
2353
  var i, o;
2354
- switch (Li(e, t, r)) {
2354
+ switch (Fi(e, t, r)) {
2355
2355
  case "e": {
2356
2356
  const a = n.eav.get(e);
2357
2357
  return fe(a, 2);
@@ -2397,7 +2397,7 @@ function Fi(n, [e, t, r]) {
2397
2397
  return fe(n.eav, 3);
2398
2398
  }
2399
2399
  }
2400
- function Ni(n, e, t) {
2400
+ function Ki(n, e, t) {
2401
2401
  var s;
2402
2402
  const r = {};
2403
2403
  if (!e)
@@ -2417,15 +2417,15 @@ function De(n, e, t) {
2417
2417
  var r;
2418
2418
  return (r = n.revIdents.get(e)) == null ? void 0 : r.get(t);
2419
2419
  }
2420
- function Ki(n, e) {
2420
+ function qi(n, e) {
2421
2421
  return n.blobAttrs.get(e);
2422
2422
  }
2423
- function Yr(n, e) {
2423
+ function Zr(n, e) {
2424
2424
  var r;
2425
2425
  const t = n.primaryKeys.get(e);
2426
2426
  return t || ((r = n.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
2427
2427
  }
2428
- function qi(n, e, t) {
2428
+ function Wi(n, e, t) {
2429
2429
  const r = ct(n, t);
2430
2430
  if (!r)
2431
2431
  return;
@@ -2433,7 +2433,7 @@ function qi(n, e, t) {
2433
2433
  if (e.getAttr(i))
2434
2434
  return Be(n.eav, [s, i]);
2435
2435
  }
2436
- function Wi(n, e, t) {
2436
+ function zi(n, e, t) {
2437
2437
  const r = t.filter(([s, i, o, a, c]) => {
2438
2438
  if (s !== "add-triple" && s !== "deep-merge-triple")
2439
2439
  return !0;
@@ -2443,8 +2443,8 @@ function Wi(n, e, t) {
2443
2443
  let l = !1;
2444
2444
  const f = e.getAttr(o);
2445
2445
  if (f) {
2446
- const h = Yr(e, f["forward-identity"][1]);
2447
- l = !!qi(n, e, [
2446
+ const h = Zr(e, f["forward-identity"][1]);
2447
+ l = !!Wi(n, e, [
2448
2448
  i,
2449
2449
  h == null ? void 0 : h.id,
2450
2450
  i
@@ -2454,37 +2454,37 @@ function Wi(n, e, t) {
2454
2454
  });
2455
2455
  return kt({ store: n, attrsStore: e }, (s) => {
2456
2456
  r.forEach((i) => {
2457
- Ui(s.store, s.attrsStore, i);
2457
+ Li(s.store, s.attrsStore, i);
2458
2458
  });
2459
2459
  }, {
2460
2460
  mark: (s) => {
2461
- if (s instanceof Me)
2461
+ if (s instanceof Re)
2462
2462
  return "immutable";
2463
2463
  }
2464
2464
  });
2465
2465
  }
2466
- function zi(n) {
2466
+ function Vi(n) {
2467
2467
  return typeof n == "string" && n.startsWith("?");
2468
2468
  }
2469
- function Vi(n, e, t) {
2469
+ function Qi(n, e, t) {
2470
2470
  if (t.hasOwnProperty(n)) {
2471
2471
  const r = t[n];
2472
- return Zr(r, e, t);
2472
+ return Xr(r, e, t);
2473
2473
  }
2474
2474
  return { ...t, [n]: e };
2475
2475
  }
2476
2476
  function Xn(n, e, t) {
2477
2477
  return n === e ? t : null;
2478
2478
  }
2479
- function Qi(n) {
2479
+ function Bi(n) {
2480
2480
  switch (typeof n) {
2481
2481
  case "string":
2482
- return n.startsWith("?") ? Vi : Xn;
2482
+ return n.startsWith("?") ? Qi : Xn;
2483
2483
  default:
2484
2484
  return Xn;
2485
2485
  }
2486
2486
  }
2487
- const Bi = [
2487
+ const Gi = [
2488
2488
  "in",
2489
2489
  "$in",
2490
2490
  "$not",
@@ -2492,69 +2492,69 @@ const Bi = [
2492
2492
  "$comparator"
2493
2493
  // covers all of $gt, $lt, etc.
2494
2494
  ];
2495
- function Gi(n) {
2496
- for (const e of Bi)
2495
+ function Hi(n) {
2496
+ for (const e of Gi)
2497
2497
  if (n.hasOwnProperty(e))
2498
2498
  return !0;
2499
2499
  return !1;
2500
2500
  }
2501
- function Zr(n, e, t) {
2502
- return t ? typeof n == "object" ? Gi(n) ? t : null : Qi(n)(n, e, t) : null;
2501
+ function Xr(n, e, t) {
2502
+ return t ? typeof n == "object" ? Hi(n) ? t : null : Bi(n)(n, e, t) : null;
2503
2503
  }
2504
- function Hi(n, e, t) {
2504
+ function Ji(n, e, t) {
2505
2505
  return n.reduce((r, s, i) => {
2506
2506
  const o = e[i];
2507
- return Zr(s, o, r);
2507
+ return Xr(s, o, r);
2508
2508
  }, t);
2509
2509
  }
2510
- function Ji(n, e, t) {
2511
- return Xi(n, e, t).map((r) => Hi(e, r, t)).filter((r) => r);
2512
- }
2513
2510
  function Yi(n, e, t) {
2514
- return e.or ? e.or.patterns.flatMap((r) => on(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => on(n, s, r), t) : t.flatMap((r) => Ji(n, e, r));
2511
+ return eo(n, e, t).map((r) => Ji(e, r, t)).filter((r) => r);
2512
+ }
2513
+ function Zi(n, e, t) {
2514
+ return e.or ? e.or.patterns.flatMap((r) => on(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => on(n, s, r), t) : t.flatMap((r) => Yi(n, e, r));
2515
2515
  }
2516
2516
  function on(n, e, t = [{}]) {
2517
- return e.reduce((r, s) => Yi(n, s, r), t);
2517
+ return e.reduce((r, s) => Zi(n, s, r), t);
2518
2518
  }
2519
2519
  function En(n, e) {
2520
- return Array.isArray(e) ? e.map((t) => En(n, t)) : zi(e) ? n[e] : e;
2520
+ return Array.isArray(e) ? e.map((t) => En(n, t)) : Vi(e) ? n[e] : e;
2521
2521
  }
2522
- function Zi(n, { find: e, where: t }) {
2522
+ function Xi(n, { find: e, where: t }) {
2523
2523
  return on(n, t).map((s) => En(s, e));
2524
2524
  }
2525
- function Xi(n, e, t) {
2526
- return Fi(n, En(t, e));
2525
+ function eo(n, e, t) {
2526
+ return Ni(n, En(t, e));
2527
2527
  }
2528
- const eo = /^(?:[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;
2528
+ const to = /^(?:[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;
2529
2529
  function Ve(n) {
2530
- return typeof n == "string" && eo.test(n);
2530
+ return typeof n == "string" && to.test(n);
2531
2531
  }
2532
2532
  const re = [];
2533
2533
  for (let n = 0; n < 256; ++n)
2534
2534
  re.push((n + 256).toString(16).slice(1));
2535
- function to(n, e = 0) {
2535
+ function no(n, e = 0) {
2536
2536
  return (re[n[e + 0]] + re[n[e + 1]] + re[n[e + 2]] + re[n[e + 3]] + "-" + re[n[e + 4]] + re[n[e + 5]] + "-" + re[n[e + 6]] + re[n[e + 7]] + "-" + re[n[e + 8]] + re[n[e + 9]] + "-" + re[n[e + 10]] + re[n[e + 11]] + re[n[e + 12]] + re[n[e + 13]] + re[n[e + 14]] + re[n[e + 15]]).toLowerCase();
2537
2537
  }
2538
2538
  let Kt;
2539
- const no = new Uint8Array(16);
2540
- function ro() {
2539
+ const ro = new Uint8Array(16);
2540
+ function so() {
2541
2541
  if (!Kt) {
2542
2542
  if (typeof crypto > "u" || !crypto.getRandomValues)
2543
2543
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2544
2544
  Kt = crypto.getRandomValues.bind(crypto);
2545
2545
  }
2546
- return Kt(no);
2546
+ return Kt(ro);
2547
2547
  }
2548
- const so = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), er = { randomUUID: so };
2549
- function io(n, e, t) {
2548
+ const io = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), er = { randomUUID: io };
2549
+ function oo(n, e, t) {
2550
2550
  var s;
2551
2551
  if (er.randomUUID && !n)
2552
2552
  return er.randomUUID();
2553
2553
  n = n || {};
2554
- const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? ro();
2554
+ const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? so();
2555
2555
  if (r.length < 16)
2556
2556
  throw new Error("Random bytes length must be >= 16");
2557
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, to(r);
2557
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, no(r);
2558
2558
  }
2559
2559
  function tr(n) {
2560
2560
  const e = n.replace(/-/g, ""), t = [];
@@ -2562,7 +2562,7 @@ function tr(n) {
2562
2562
  t.push(parseInt(e.substring(r, r + 2), 16));
2563
2563
  return t;
2564
2564
  }
2565
- function oo(n, e) {
2565
+ function ao(n, e) {
2566
2566
  for (let t = 0; t < n.length; t++) {
2567
2567
  if (n[t] < e[t])
2568
2568
  return -1;
@@ -2571,17 +2571,17 @@ function oo(n, e) {
2571
2571
  }
2572
2572
  return 0;
2573
2573
  }
2574
- function ao(n, e) {
2575
- return oo(tr(n), tr(e));
2574
+ function co(n, e) {
2575
+ return ao(tr(n), tr(e));
2576
2576
  }
2577
2577
  function J() {
2578
- return io();
2578
+ return oo();
2579
2579
  }
2580
- function co(n, e) {
2580
+ function uo(n, e) {
2581
2581
  return n.localeCompare(e);
2582
2582
  }
2583
- function uo() {
2584
- let n = co;
2583
+ function lo() {
2584
+ let n = uo;
2585
2585
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
2586
2586
  try {
2587
2587
  n = Intl.Collator("en-US").compare;
@@ -2589,12 +2589,12 @@ function uo() {
2589
2589
  }
2590
2590
  return n;
2591
2591
  }
2592
- const lo = uo();
2593
- let fo = !0, ho = 0;
2592
+ const fo = lo();
2593
+ let ho = !0, po = 0;
2594
2594
  function it(n) {
2595
- return Rt(`_${n}`, ho++);
2595
+ return Mt(`_${n}`, po++);
2596
2596
  }
2597
- function Rt(n, e) {
2597
+ function Mt(n, e) {
2598
2598
  return `?${n}-${e}`;
2599
2599
  }
2600
2600
  class Qe extends Error {
@@ -2602,27 +2602,27 @@ class Qe extends Error {
2602
2602
  super(e), this.name = "AttrNotFoundError";
2603
2603
  }
2604
2604
  }
2605
- function po(n, e) {
2606
- const t = Yr(n, e);
2605
+ function yo(n, e) {
2606
+ const t = Zr(n, e);
2607
2607
  if (!t)
2608
2608
  throw new Qe(`Could not find id attr for ${e}`);
2609
2609
  return t;
2610
2610
  }
2611
2611
  function nr(n, e, t, r) {
2612
- return [yo(n, e, t, r)];
2612
+ return [bo(n, e, t, r)];
2613
2613
  }
2614
- function yo(n, e, t, r) {
2614
+ function bo(n, e, t, r) {
2615
2615
  return [
2616
2616
  n(t, r),
2617
- po(e, t).id,
2617
+ yo(e, t).id,
2618
2618
  n(t, r),
2619
2619
  n("time", r)
2620
2620
  ];
2621
2621
  }
2622
- function bo(n, e, t) {
2622
+ function go(n, e, t) {
2623
2623
  return n.map((r) => r === e ? t : r);
2624
2624
  }
2625
- function Xr(n, e, t, r, s) {
2625
+ function es(n, e, t, r, s) {
2626
2626
  const i = ne(e, t, s), o = De(e, t, s), a = i || o;
2627
2627
  if (!a)
2628
2628
  throw new Qe(`Could not find attr for ${[t, s]}`);
@@ -2651,7 +2651,7 @@ function rr(n, e) {
2651
2651
  return typeof o != "string" ? !1 : s.test(o);
2652
2652
  };
2653
2653
  }
2654
- function go(n, e) {
2654
+ function _o(n, e) {
2655
2655
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2656
2656
  return e;
2657
2657
  const t = n["checked-data-type"] === "date";
@@ -2711,7 +2711,7 @@ function go(n, e) {
2711
2711
  }
2712
2712
  return e;
2713
2713
  }
2714
- function _o(n, e, t, r, s, i) {
2714
+ function mo(n, e, t, r, s, i) {
2715
2715
  const o = ne(e, t, s), a = De(e, t, s), c = o || a;
2716
2716
  if (!c)
2717
2717
  throw new Qe(`No attr for etype = ${t} label = ${s}`);
@@ -2729,31 +2729,31 @@ function _o(n, e, t, r, s, i) {
2729
2729
  return o ? [
2730
2730
  n(t, r),
2731
2731
  c.id,
2732
- go(c, i),
2732
+ _o(c, i),
2733
2733
  it("time")
2734
2734
  ] : [i, c.id, n(t, r), it("time")];
2735
2735
  }
2736
- function mo(n, e, t, r, s) {
2736
+ function wo(n, e, t, r, s) {
2737
2737
  const [i, o, a] = s.reduce((c, u) => {
2738
- const [l, f, h] = c, [y, b, g] = Xr(n, e, l, f, u);
2738
+ const [l, f, h] = c, [y, b, g] = es(n, e, l, f, u);
2739
2739
  return [y, b, [...h, g]];
2740
2740
  }, [t, r, []]);
2741
2741
  return [i, o, a];
2742
2742
  }
2743
2743
  function an(n, e, t, r, s, i) {
2744
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = mo(n, e, t, r, o), f = _o(n, e, c, u, a, i);
2744
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = wo(n, e, t, r, o), f = mo(n, e, c, u, a, i);
2745
2745
  return l.concat([f]);
2746
2746
  }
2747
- function wo(n, e) {
2747
+ function To(n, e) {
2748
2748
  return e ? [e].concat(n) : n;
2749
2749
  }
2750
- function To([n, e]) {
2750
+ function So([n, e]) {
2751
2751
  return n === "or" && Array.isArray(e);
2752
2752
  }
2753
- function So([n, e]) {
2753
+ function vo([n, e]) {
2754
2754
  return n === "and" && Array.isArray(e);
2755
2755
  }
2756
- function vo(n, e, t) {
2756
+ function Ao(n, e, t) {
2757
2757
  return (r, s) => {
2758
2758
  const i = n(r, s);
2759
2759
  return e == i ? i : `${i}-${t}`;
@@ -2761,27 +2761,27 @@ function vo(n, e, t) {
2761
2761
  }
2762
2762
  function sr(n, e, t, r, s, i) {
2763
2763
  const o = n(r, s), a = i.map((c, u) => {
2764
- const l = vo(n, o, u);
2765
- return es(l, t, r, s, c);
2764
+ const l = Ao(n, o, u);
2765
+ return ts(l, t, r, s, c);
2766
2766
  });
2767
2767
  return { [e]: { patterns: a, joinSym: o } };
2768
2768
  }
2769
- function Ao(n) {
2769
+ function Oo(n) {
2770
2770
  const e = [];
2771
2771
  for (let t = 1; t <= n.length; t++)
2772
2772
  e.push(n.slice(0, t));
2773
2773
  return e;
2774
2774
  }
2775
2775
  function ir(n, e, t, r, s) {
2776
- return Ao(s).map((i) => an(n, e, t, r, i, {
2776
+ return Oo(s).map((i) => an(n, e, t, r, i, {
2777
2777
  $isNull: !0
2778
2778
  }));
2779
2779
  }
2780
- function es(n, e, t, r, s) {
2780
+ function ts(n, e, t, r, s) {
2781
2781
  return Object.entries(s).flatMap(([i, o]) => {
2782
- if (To([i, o]))
2783
- return sr(n, "or", e, t, r, o);
2784
2782
  if (So([i, o]))
2783
+ return sr(n, "or", e, t, r, o);
2784
+ if (vo([i, o]))
2785
2785
  return sr(n, "and", e, t, r, o);
2786
2786
  if (i === "$entityIdStartsWith")
2787
2787
  return [];
@@ -2807,29 +2807,29 @@ function es(n, e, t, r, s) {
2807
2807
  ] : an(n, e, t, r, a, o);
2808
2808
  });
2809
2809
  }
2810
- function Oo(n, e, t, r) {
2811
- const s = Rt;
2812
- return r ? es(s, n, e, t, r).concat(nr(s, n, e, t)) : nr(s, n, e, t);
2810
+ function Eo(n, e, t, r) {
2811
+ const s = Mt;
2812
+ return r ? ts(s, n, e, t, r).concat(nr(s, n, e, t)) : nr(s, n, e, t);
2813
2813
  }
2814
- function Eo(n, e, t) {
2814
+ function ko(n, e, t) {
2815
2815
  return [n(e, t), n("time", t)];
2816
2816
  }
2817
- function ko(n, e, t, r, s, i) {
2818
- const [o, a, c, u, l] = Xr(n, e, t, r, s), f = bo(c, n(t, r), i);
2817
+ function Co(n, e, t, r, s, i) {
2818
+ const [o, a, c, u, l] = es(n, e, t, r, s), f = go(c, n(t, r), i);
2819
2819
  return [o, a, f, u, l];
2820
2820
  }
2821
- function Co(n, e, t, { etype: r, level: s, form: i }, o) {
2821
+ function Io(n, e, t, { etype: r, level: s, form: i }, o) {
2822
2822
  const a = Object.keys(i).filter((c) => c !== "$");
2823
2823
  return a.length ? Object.entries(o).map(function([u, l]) {
2824
2824
  return a.map(function(y) {
2825
2825
  var g, m, S;
2826
2826
  const b = !!(e.cardinalityInference && ((S = (m = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : m[y]) != null && S.isSingular));
2827
2827
  try {
2828
- const [_, T, R] = ko(n, t, r, s, y, u), O = rs(e, t, {
2828
+ const [_, T, M] = Co(n, t, r, s, y, u), O = ss(e, t, {
2829
2829
  etype: _,
2830
2830
  level: T,
2831
2831
  form: i[y],
2832
- join: R
2832
+ join: M
2833
2833
  }), F = b ? O[0] : O;
2834
2834
  return { [y]: F };
2835
2835
  } catch (_) {
@@ -2842,11 +2842,11 @@ function Co(n, e, t, { etype: r, level: s, form: i }, o) {
2842
2842
  }, l);
2843
2843
  }) : Object.values(o);
2844
2844
  }
2845
- function Io(n, e, t) {
2846
- return t === "string" ? lo(n, e) : n > e ? 1 : -1;
2845
+ function Po(n, e, t) {
2846
+ return t === "string" ? fo(n, e) : n > e ? 1 : -1;
2847
2847
  }
2848
2848
  function nt(n, e, t, r, s) {
2849
- return e === r || e == null && r == null ? ao(n, t) : r == null ? 1 : e == null ? -1 : Io(e, r, s);
2849
+ return e === r || e == null && r == null ? co(n, t) : r == null ? 1 : e == null ? -1 : Po(e, r, s);
2850
2850
  }
2851
2851
  function Ct([n, e], [t, r], s) {
2852
2852
  return nt(n, e, t, r, s);
@@ -2854,7 +2854,7 @@ function Ct([n, e], [t, r], s) {
2854
2854
  function cn(n) {
2855
2855
  return n == null ? n : new Date(n).getTime();
2856
2856
  }
2857
- function ts(n, e, t) {
2857
+ function ns(n, e, t) {
2858
2858
  var h;
2859
2859
  const [r, s, i, o] = n;
2860
2860
  if (((h = e["forward-identity"]) == null ? void 0 : h[2]) === "id")
@@ -2862,32 +2862,32 @@ function ts(n, e, t) {
2862
2862
  const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? cn(c) : c, f = u === "date" ? cn(i) : i;
2863
2863
  return Ct([a, l], [r, f], u);
2864
2864
  }
2865
- function Po(n, e, t, r) {
2866
- const s = ts(n, e, r);
2865
+ function Mo(n, e, t, r) {
2866
+ const s = ns(n, e, r);
2867
2867
  return t === "desc" ? s > 0 : s < 0;
2868
2868
  }
2869
2869
  function Ro(n, e, t, r) {
2870
- const s = ts(n, e, r);
2870
+ const s = ns(n, e, r);
2871
2871
  return t === "desc" ? s < 0 : s > 0;
2872
2872
  }
2873
- function Mo(n, e) {
2873
+ function jo(n, e) {
2874
2874
  const t = e[1];
2875
2875
  return n.getAttr(t);
2876
2876
  }
2877
- function jo(n, e, t) {
2877
+ function $o(n, e, t) {
2878
2878
  const r = Object.keys(t)[0];
2879
2879
  return ne(n, e, r);
2880
2880
  }
2881
- function $o(n, e, t, r) {
2881
+ function xo(n, e, t, r) {
2882
2882
  if (t)
2883
- return Mo(n, t);
2883
+ return jo(n, t);
2884
2884
  if (r)
2885
- return jo(n, e, r);
2885
+ return $o(n, e, r);
2886
2886
  }
2887
- function xo(n, e, t) {
2887
+ function Do(n, e, t) {
2888
2888
  var s, i;
2889
2889
  if (!Array.isArray(t.fields))
2890
- return Ki(n, e);
2890
+ return qi(n, e);
2891
2891
  const r = /* @__PURE__ */ new Map();
2892
2892
  for (const o of t.fields) {
2893
2893
  const a = ne(n, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
@@ -2899,17 +2899,17 @@ function xo(n, e, t) {
2899
2899
  }
2900
2900
  return r;
2901
2901
  }
2902
- function Do(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2902
+ function Uo(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2903
2903
  var g, m;
2904
- const o = (g = i == null ? void 0 : i.$) == null ? void 0 : g.order, a = ns(i), c = Uo(i);
2905
- let u = Zi(n, s);
2906
- const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], h = $o(e, t, l, o);
2904
+ const o = (g = i == null ? void 0 : i.$) == null ? void 0 : g.order, a = rs(i), c = Lo(i);
2905
+ let u = Xi(n, s);
2906
+ const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], h = xo(e, t, l, o);
2907
2907
  if (h && ((m = h == null ? void 0 : h["forward-identity"]) == null ? void 0 : m[2]) !== "id") {
2908
2908
  const S = h["checked-data-type"] === "date", _ = h.id;
2909
2909
  u = u.map(([T]) => {
2910
2910
  var O, F, P, C, G;
2911
- let R = (G = (C = (P = (F = (O = n.eav.get(T)) == null ? void 0 : O.get(_)) == null ? void 0 : F.values()) == null ? void 0 : P.next()) == null ? void 0 : C.value) == null ? void 0 : G[2];
2912
- return S && (R = cn(R)), [T, R];
2911
+ let M = (G = (C = (P = (F = (O = n.eav.get(T)) == null ? void 0 : O.get(_)) == null ? void 0 : F.values()) == null ? void 0 : P.next()) == null ? void 0 : C.value) == null ? void 0 : G[2];
2912
+ return S && (M = cn(M)), [T, M];
2913
2913
  });
2914
2914
  }
2915
2915
  u.sort(c === "asc" ? function(_, T) {
@@ -2918,57 +2918,57 @@ function Do(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2918
2918
  return Ct(T, _, h == null ? void 0 : h["checked-data-type"]);
2919
2919
  });
2920
2920
  let y = {};
2921
- const b = xo(e, t, s);
2921
+ const b = Do(e, t, s);
2922
2922
  for (const S of u) {
2923
2923
  const [_] = S;
2924
- if (y[_] || !a && l && h && Po(l, h, c, S) || !a && f && h && Ro(f, h, c, S))
2924
+ if (y[_] || !a && l && h && Mo(l, h, c, S) || !a && f && h && Ro(f, h, c, S))
2925
2925
  continue;
2926
- const T = Ni(n, b, _);
2926
+ const T = Ki(n, b, _);
2927
2927
  T && (y[_] = T);
2928
2928
  }
2929
2929
  return y;
2930
2930
  }
2931
- function Uo(n) {
2931
+ function Lo(n) {
2932
2932
  var t;
2933
2933
  const e = (t = n.$) == null ? void 0 : t.order;
2934
2934
  return e && e[Object.keys(e)[0]] || "asc";
2935
2935
  }
2936
- function ns(n) {
2936
+ function rs(n) {
2937
2937
  var s, i, o;
2938
2938
  const e = (s = n.$) == null ? void 0 : s.offset, t = (i = n.$) == null ? void 0 : i.before, r = (o = n.$) == null ? void 0 : o.after;
2939
2939
  return !e && !t && !r;
2940
2940
  }
2941
- function Lo(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2941
+ function Fo(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2942
2942
  var h, y, b, g, m;
2943
- if (!ns(s) && (!o || !o["start-cursor"]))
2943
+ if (!rs(s) && (!o || !o["start-cursor"]))
2944
2944
  return [];
2945
- const a = wo(Oo(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = Eo(Rt, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Do(n, e, {
2945
+ const a = To(Eo(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = ko(Mt, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Uo(n, e, {
2946
2946
  etype: t,
2947
2947
  pageInfo: o,
2948
2948
  form: s,
2949
2949
  dq: { where: a, find: c, fields: u }
2950
2950
  }), f = ((b = s.$) == null ? void 0 : b.limit) || ((g = s.$) == null ? void 0 : g.first) || ((m = s.$) == null ? void 0 : m.last);
2951
2951
  if (f != null) {
2952
- r > 0 && fo && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2952
+ r > 0 && ho && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2953
2953
  const S = Object.entries(l);
2954
2954
  return S.length <= f ? l : Object.fromEntries(S.slice(0, f));
2955
2955
  }
2956
2956
  return l;
2957
2957
  }
2958
- function Fo(n, e, t) {
2958
+ function No(n, e, t) {
2959
2959
  try {
2960
- return Lo(n, e, t);
2960
+ return Fo(n, e, t);
2961
2961
  } catch (r) {
2962
2962
  if (r instanceof Qe)
2963
2963
  return {};
2964
2964
  throw r;
2965
2965
  }
2966
2966
  }
2967
- function rs(n, e, t) {
2968
- const r = Fo(n, e, t);
2969
- return Co(Rt, n, e, t, r);
2967
+ function ss(n, e, t) {
2968
+ const r = No(n, e, t);
2969
+ return Io(Mt, n, e, t, r);
2970
2970
  }
2971
- function No(n) {
2971
+ function Ko(n) {
2972
2972
  const e = {};
2973
2973
  for (const [t, r] of Object.entries(n))
2974
2974
  e[t] = {
@@ -2979,18 +2979,18 @@ function No(n) {
2979
2979
  };
2980
2980
  return e;
2981
2981
  }
2982
- function ss({ store: n, attrsStore: e, pageInfo: t, aggregate: r }, s) {
2982
+ function is({ store: n, attrsStore: e, pageInfo: t, aggregate: r }, s) {
2983
2983
  const o = { data: Object.keys(s).reduce(function(c, u) {
2984
- return r != null && r[u] || u === "$$ruleParams" || (c[u] = rs(n, e, {
2984
+ return r != null && r[u] || u === "$$ruleParams" || (c[u] = ss(n, e, {
2985
2985
  etype: u,
2986
2986
  form: s[u],
2987
2987
  level: 0,
2988
2988
  pageInfo: t == null ? void 0 : t[u]
2989
2989
  })), c;
2990
2990
  }, {}) };
2991
- return t && (o.pageInfo = No(t)), r && (o.aggregate = r), o;
2991
+ return t && (o.pageInfo = Ko(t)), r && (o.aggregate = r), o;
2992
2992
  }
2993
- function Ko() {
2993
+ function qo() {
2994
2994
  const e = {
2995
2995
  __etype: 1,
2996
2996
  __ops: 1,
@@ -3004,7 +3004,7 @@ function Ko() {
3004
3004
  };
3005
3005
  return new Set(Object.keys(e));
3006
3006
  }
3007
- const qo = Ko();
3007
+ const Wo = qo();
3008
3008
  function vt(n, e, t) {
3009
3009
  const r = {
3010
3010
  __etype: n,
@@ -3016,7 +3016,7 @@ function vt(n, e, t) {
3016
3016
  return t;
3017
3017
  if (i === "__etype")
3018
3018
  return n;
3019
- if (qo.has(i))
3019
+ if (Wo.has(i))
3020
3020
  return (o, a) => vt(n, e, [
3021
3021
  ...t,
3022
3022
  a ? [i, n, e, o, a] : [i, n, e, o]
@@ -3024,7 +3024,7 @@ function vt(n, e, t) {
3024
3024
  }
3025
3025
  });
3026
3026
  }
3027
- function Wo(n, e) {
3027
+ function zo(n, e) {
3028
3028
  return `lookup__${n}__${JSON.stringify(e)}`;
3029
3029
  }
3030
3030
  function It(n) {
@@ -3034,13 +3034,13 @@ function un(n) {
3034
3034
  const [e, t, ...r] = n.split("__");
3035
3035
  return [t, JSON.parse(r.join("__"))];
3036
3036
  }
3037
- function zo(n) {
3037
+ function Vo(n) {
3038
3038
  return new Proxy({
3039
3039
  __etype: n
3040
3040
  }, {
3041
3041
  get(e, t) {
3042
3042
  if (t === "lookup")
3043
- return (s, i) => vt(n, un(Wo(s, i)), []);
3043
+ return (s, i) => vt(n, un(zo(s, i)), []);
3044
3044
  if (t === "__etype")
3045
3045
  return n;
3046
3046
  const r = t;
@@ -3051,15 +3051,15 @@ function zo(n) {
3051
3051
  function kn() {
3052
3052
  return new Proxy({}, {
3053
3053
  get(n, e) {
3054
- return zo(e);
3054
+ return Vo(e);
3055
3055
  }
3056
3056
  });
3057
3057
  }
3058
3058
  kn();
3059
- function Vo(n) {
3059
+ function Qo(n) {
3060
3060
  return n.__ops;
3061
3061
  }
3062
- function Qo(n, e) {
3062
+ function Bo(n, e) {
3063
3063
  const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
3064
3064
  for (const o of e) {
3065
3065
  const a = t[o];
@@ -3078,7 +3078,7 @@ function Qo(n, e) {
3078
3078
  }
3079
3079
  return s;
3080
3080
  }
3081
- function Bo(n) {
3081
+ function Go(n) {
3082
3082
  if (Array.isArray(n))
3083
3083
  return n;
3084
3084
  const e = Object.entries(n);
@@ -3086,7 +3086,7 @@ function Bo(n) {
3086
3086
  throw new Error("lookup must be an object with a single unique attr and value.");
3087
3087
  return e[0];
3088
3088
  }
3089
- function Go(n, e, t) {
3089
+ function Ho(n, e, t) {
3090
3090
  return t.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
3091
3091
  // before assuming it's a ref lookup.
3092
3092
  !ne(n, e, t);
@@ -3097,8 +3097,8 @@ function ln(n) {
3097
3097
  throw new Error(`${n} is not a valid lookup attribute.`);
3098
3098
  return e;
3099
3099
  }
3100
- function Ho(n, e, t) {
3101
- if (!Go(n, e, t))
3100
+ function Jo(n, e, t) {
3101
+ if (!Ho(n, e, t))
3102
3102
  return ne(n, e, t);
3103
3103
  const r = ln(t), s = ne(n, e, r) || De(n, e, r);
3104
3104
  if (s && s["value-type"] !== "ref")
@@ -3106,18 +3106,18 @@ function Ho(n, e, t) {
3106
3106
  return s;
3107
3107
  }
3108
3108
  function fn(n) {
3109
- return typeof n == "string" && !It(n) ? null : typeof n == "string" && It(n) ? un(n) : Bo(n);
3109
+ return typeof n == "string" && !It(n) ? null : typeof n == "string" && It(n) ? un(n) : Go(n);
3110
3110
  }
3111
3111
  function de(n, e, t) {
3112
3112
  const r = fn(t);
3113
3113
  if (r === null)
3114
3114
  return t;
3115
- const [s, i] = r, o = Ho(n, e, s);
3115
+ const [s, i] = r, o = Jo(n, e, s);
3116
3116
  if (!o || !o["unique?"])
3117
3117
  throw new Error(`${s} is not a unique attribute.`);
3118
3118
  return [o.id, i];
3119
3119
  }
3120
- function is(n, e, t, r) {
3120
+ function os(n, e, t, r) {
3121
3121
  var o;
3122
3122
  const s = de(n, e, t);
3123
3123
  return Array.isArray(s) ? [[
@@ -3127,7 +3127,7 @@ function is(n, e, t, r) {
3127
3127
  s
3128
3128
  ]].concat(r) : r;
3129
3129
  }
3130
- function Jo({ attrsStore: n }, [e, t, r]) {
3130
+ function Yo({ attrsStore: n }, [e, t, r]) {
3131
3131
  const s = Object.entries(r).flatMap(([i, o]) => {
3132
3132
  const a = Array.isArray(o) ? o : [o], c = ne(n, e, i), u = De(n, e, i);
3133
3133
  return a.map((l) => c ? [
@@ -3146,9 +3146,9 @@ function Jo({ attrsStore: n }, [e, t, r]) {
3146
3146
  de(n, e, t)
3147
3147
  ]);
3148
3148
  });
3149
- return is(n, e, t, s);
3149
+ return os(n, e, t, s);
3150
3150
  }
3151
- function Yo({ attrsStore: n }, [e, t, r]) {
3151
+ function Zo({ attrsStore: n }, [e, t, r]) {
3152
3152
  const s = Object.entries(r).flatMap(([i, o]) => {
3153
3153
  const a = Array.isArray(o) ? o : [o], c = ne(n, e, i), u = De(n, e, i);
3154
3154
  return a.map((l) => c ? [
@@ -3167,9 +3167,9 @@ function Yo({ attrsStore: n }, [e, t, r]) {
3167
3167
  de(n, e, t)
3168
3168
  ]);
3169
3169
  });
3170
- return is(n, e, t, s);
3170
+ return os(n, e, t, s);
3171
3171
  }
3172
- function Zo(n, e, t, r) {
3172
+ function Xo(n, e, t, r) {
3173
3173
  var s;
3174
3174
  if (Array.isArray(r)) {
3175
3175
  const [i, o] = r;
@@ -3192,18 +3192,18 @@ function Zo(n, e, t, r) {
3192
3192
  }
3193
3193
  return !1;
3194
3194
  }
3195
- function os({ stores: n, attrsStore: e }, [t, r, s, i]) {
3196
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Zo(n, e, t, r) ? { mode: "update" } : null;
3195
+ function as({ stores: n, attrsStore: e }, [t, r, s, i]) {
3196
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Xo(n, e, t, r) ? { mode: "update" } : null;
3197
3197
  }
3198
- function Xo(n, e) {
3198
+ function ea(n, e) {
3199
3199
  const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s);
3200
3200
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
3201
3201
  const h = ne(t, r, l);
3202
3202
  return h["checked-data-type"] === "date" && n.useDateObjects && (f = Pt(f)), ["add-triple", c, h.id, f, { mode: "create" }];
3203
3203
  });
3204
3204
  }
3205
- function ea(n, e) {
3206
- const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = os(n, [r, c, i, o]);
3205
+ function ta(n, e) {
3206
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = as(n, [r, c, i, o]);
3207
3207
  return [["id", c]].concat(Object.entries(a)).map(([f, h]) => {
3208
3208
  const y = ne(t, r, f);
3209
3209
  return y["checked-data-type"] === "date" && n.useDateObjects && (h = Pt(h)), [
@@ -3215,11 +3215,11 @@ function ea(n, e) {
3215
3215
  ];
3216
3216
  });
3217
3217
  }
3218
- function ta({ attrsStore: n }, [e, t]) {
3218
+ function na({ attrsStore: n }, [e, t]) {
3219
3219
  return [["delete-entity", de(n, e, t), e]];
3220
3220
  }
3221
- function na(n, e) {
3222
- const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = os(n, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3221
+ function ra(n, e) {
3222
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = as(n, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3223
3223
  const b = ne(t, r, h);
3224
3224
  return [
3225
3225
  "deep-merge-triple",
@@ -3237,38 +3237,38 @@ function na(n, e) {
3237
3237
  ...u ? [u] : []
3238
3238
  ]].concat(l);
3239
3239
  }
3240
- function ra({ attrsStore: n }, [e, t, r]) {
3240
+ function sa({ attrsStore: n }, [e, t, r]) {
3241
3241
  return [["rule-params", de(n, e, t), e, r]];
3242
3242
  }
3243
- function sa(n) {
3243
+ function ia(n) {
3244
3244
  const [e, t, r, s, i] = n;
3245
3245
  if (!s)
3246
3246
  return n;
3247
3247
  const o = { ...s };
3248
3248
  return delete o.id, [e, t, r, o, ...i ? [i] : []];
3249
3249
  }
3250
- function ia(n, e) {
3251
- const [t, ...r] = sa(e);
3250
+ function oa(n, e) {
3251
+ const [t, ...r] = ia(e);
3252
3252
  switch (t) {
3253
3253
  case "merge":
3254
- return na(n, r);
3254
+ return ra(n, r);
3255
3255
  case "create":
3256
- return Xo(n, r);
3257
- case "update":
3258
3256
  return ea(n, r);
3257
+ case "update":
3258
+ return ta(n, r);
3259
3259
  case "link":
3260
- return Jo(n, r);
3261
- case "unlink":
3262
3260
  return Yo(n, r);
3261
+ case "unlink":
3262
+ return Zo(n, r);
3263
3263
  case "delete":
3264
- return ta(n, r);
3264
+ return na(n, r);
3265
3265
  case "ruleParams":
3266
- return ra(n, r);
3266
+ return sa(n, r);
3267
3267
  default:
3268
3268
  throw new Error(`unsupported action ${t}`);
3269
3269
  }
3270
3270
  }
3271
- function oa(n) {
3271
+ function aa(n) {
3272
3272
  switch (n) {
3273
3273
  case "string":
3274
3274
  case "date":
@@ -3279,14 +3279,14 @@ function oa(n) {
3279
3279
  return;
3280
3280
  }
3281
3281
  }
3282
- function aa(n, e, t) {
3282
+ function ca(n, e, t) {
3283
3283
  var a, c;
3284
3284
  const r = (c = (a = n.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[t];
3285
3285
  if (t === "id")
3286
3286
  return null;
3287
3287
  if (!r)
3288
3288
  throw new Error(`${e}.${t} does not exist in your schema`);
3289
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = oa(r == null ? void 0 : r.valueType);
3289
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = aa(r == null ? void 0 : r.valueType);
3290
3290
  return {
3291
3291
  "index?": i,
3292
3292
  "unique?": s,
@@ -3294,7 +3294,7 @@ function aa(n, e, t) {
3294
3294
  };
3295
3295
  }
3296
3296
  function yt(n, e, t, r) {
3297
- const s = n ? aa(n, e, t) : null, i = J(), a = [J(), e, t];
3297
+ const s = n ? ca(n, e, t) : null, i = J(), a = [J(), e, t];
3298
3298
  return {
3299
3299
  id: i,
3300
3300
  "forward-identity": a,
@@ -3307,11 +3307,11 @@ function yt(n, e, t, r) {
3307
3307
  ...r || {}
3308
3308
  };
3309
3309
  }
3310
- function ca(n, e, t) {
3310
+ function ua(n, e, t) {
3311
3311
  return Object.values(n.links).find((i) => i.forward.on === e && i.forward.label === t || i.reverse.on === e && i.reverse.label === t);
3312
3312
  }
3313
- function ua(n, e, t) {
3314
- const r = ca(n, e, t);
3313
+ function la(n, e, t) {
3314
+ const r = ua(n, e, t);
3315
3315
  if (!r)
3316
3316
  throw new Error(`Couldn't find the link ${e}.${t} in your schema`);
3317
3317
  const { forward: s, reverse: i } = r;
@@ -3325,7 +3325,7 @@ function ua(n, e, t) {
3325
3325
  };
3326
3326
  }
3327
3327
  function or(n, e, t, r) {
3328
- const s = n ? ua(n, e, t) : null, i = J(), o = [J(), e, t], a = [J(), t, e];
3328
+ const s = n ? la(n, e, t) : null, i = J(), o = [J(), e, t], a = [J(), t, e];
3329
3329
  return {
3330
3330
  id: i,
3331
3331
  // @ts-ignore: ts thinks it's any[]
@@ -3342,7 +3342,7 @@ function or(n, e, t, r) {
3342
3342
  ...r || {}
3343
3343
  };
3344
3344
  }
3345
- const la = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), fa = /* @__PURE__ */ new Set(["link", "unlink"]), da = /* @__PURE__ */ new Set(["create", "update", "merge"]), ha = /* @__PURE__ */ new Set([
3345
+ const fa = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), da = /* @__PURE__ */ new Set(["link", "unlink"]), ha = /* @__PURE__ */ new Set(["create", "update", "merge"]), pa = /* @__PURE__ */ new Set([
3346
3346
  "link",
3347
3347
  "unlink",
3348
3348
  "create",
@@ -3350,13 +3350,13 @@ const la = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3350
3350
  "merge",
3351
3351
  "delete",
3352
3352
  "ruleParams"
3353
- ]), dn = { "unique?": !0, "index?": !0 }, pa = {
3353
+ ]), dn = { "unique?": !0, "index?": !0 }, ya = {
3354
3354
  ...dn,
3355
3355
  cardinality: "one"
3356
3356
  };
3357
- function ya(n) {
3357
+ function ba(n) {
3358
3358
  const e = [], [t, r, s, i] = n;
3359
- if (!ha.has(t))
3359
+ if (!pa.has(t))
3360
3360
  return e;
3361
3361
  const o = fn(s);
3362
3362
  if (o && e.push({ etype: r, lookupPair: o }), t === "link")
@@ -3373,7 +3373,7 @@ function ya(n) {
3373
3373
  }
3374
3374
  return e;
3375
3375
  }
3376
- function ba({ attrsStore: n, schema: e }, t) {
3376
+ function ga({ attrsStore: n, schema: e }, t) {
3377
3377
  var h, y;
3378
3378
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
3379
3379
  function o(b, g) {
@@ -3398,16 +3398,16 @@ function ba({ attrsStore: n, schema: e }, t) {
3398
3398
  }
3399
3399
  function f(b, g) {
3400
3400
  const m = o(b, g), S = a(b, g);
3401
- u(m), u(S), !m && !S && c(or(e, b, g, pa));
3401
+ u(m), u(S), !m && !S && c(or(e, b, g, ya));
3402
3402
  }
3403
3403
  for (const b of t)
3404
- for (const { etype: g, lookupPair: m, linkLabel: S } of ya(b)) {
3404
+ for (const { etype: g, lookupPair: m, linkLabel: S } of ba(b)) {
3405
3405
  const _ = m[0];
3406
3406
  if (S) {
3407
3407
  f(g, S);
3408
- const T = o(g, S), R = a(g, S);
3409
- u(T), u(R);
3410
- const O = ((h = T == null ? void 0 : T["reverse-identity"]) == null ? void 0 : h[1]) || ((y = R == null ? void 0 : R["forward-identity"]) == null ? void 0 : y[1]) || S;
3408
+ const T = o(g, S), M = a(g, S);
3409
+ u(T), u(M);
3410
+ const O = ((h = T == null ? void 0 : T["reverse-identity"]) == null ? void 0 : h[1]) || ((y = M == null ? void 0 : M["forward-identity"]) == null ? void 0 : y[1]) || S;
3411
3411
  if (l(O, _))
3412
3412
  f(O, ln(_));
3413
3413
  else {
@@ -3423,14 +3423,14 @@ function ba({ attrsStore: n, schema: e }, t) {
3423
3423
  }
3424
3424
  for (const b of t) {
3425
3425
  const [g, m, S, _] = b;
3426
- if (la.has(g)) {
3426
+ if (fa.has(g)) {
3427
3427
  const T = o(m, "id");
3428
3428
  u(T), T || c(yt(e, m, "id", { "unique?": !0 }));
3429
- for (const R of Object.keys(_)) {
3430
- const O = o(m, R);
3431
- if (u(O), da.has(g) && (O || c(yt(e, m, R, R === "id" ? { "unique?": !0 } : null))), fa.has(g)) {
3432
- const F = a(m, R);
3433
- !O && !F && c(or(e, m, R)), u(F);
3429
+ for (const M of Object.keys(_)) {
3430
+ const O = o(m, M);
3431
+ if (u(O), ha.has(g) && (O || c(yt(e, m, M, M === "id" ? { "unique?": !0 } : null))), da.has(g)) {
3432
+ const F = a(m, M);
3433
+ !O && !F && c(or(e, m, M)), u(F);
3434
3434
  }
3435
3435
  }
3436
3436
  }
@@ -3439,19 +3439,19 @@ function ba({ attrsStore: n, schema: e }, t) {
3439
3439
  const b = { ...n.attrs };
3440
3440
  for (const g of s)
3441
3441
  b[g.id] = g;
3442
- return [new Me(b, n.linkIndex), i];
3442
+ return [new Re(b, n.linkIndex), i];
3443
3443
  }
3444
3444
  return [n, i];
3445
3445
  }
3446
- function ga(n, e) {
3447
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Vo(c)), [s, i] = ba(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => ia(o, c));
3446
+ function _a(n, e) {
3447
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Qo(c)), [s, i] = ga(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => oa(o, c));
3448
3448
  return [...i, ...a];
3449
3449
  }
3450
3450
  function ar(n, e) {
3451
3451
  typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
3452
3452
  }
3453
3453
  const We = "__meta";
3454
- class _a {
3454
+ class ma {
3455
3455
  constructor(e, t) {
3456
3456
  }
3457
3457
  }
@@ -3703,13 +3703,13 @@ class hn {
3703
3703
  e && await this._enqueuePersist();
3704
3704
  }
3705
3705
  }
3706
- const ma = 6, wa = ["kv", "querySubs", "syncSubs"];
3707
- function Ta(n) {
3706
+ const wa = 6, Ta = ["kv", "querySubs", "syncSubs"];
3707
+ function Sa(n) {
3708
3708
  return function(t) {
3709
3709
  console.error("Error in IndexedDB event", { source: n, event: t });
3710
3710
  };
3711
3711
  }
3712
- async function Sa(n) {
3712
+ async function va(n) {
3713
3713
  return new Promise((e) => {
3714
3714
  const t = indexedDB.open(n);
3715
3715
  t.onerror = (r) => {
@@ -3723,7 +3723,7 @@ async function Sa(n) {
3723
3723
  };
3724
3724
  });
3725
3725
  }
3726
- async function va(n, e, t) {
3726
+ async function Aa(n, e, t) {
3727
3727
  const r = (
3728
3728
  // Backwards compatibility for older versions where we JSON.stringified before storing
3729
3729
  typeof e == "string" ? JSON.parse(e) : e
@@ -3763,8 +3763,8 @@ async function cr(n, e, t) {
3763
3763
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3764
3764
  });
3765
3765
  }
3766
- async function Aa(n, e) {
3767
- const t = await Sa(`instant_${n}_5`);
3766
+ async function Oa(n, e) {
3767
+ const t = await va(`instant_${n}_5`);
3768
3768
  if (!t)
3769
3769
  return;
3770
3770
  const r = await new Promise((l, f) => {
@@ -3787,7 +3787,7 @@ async function Aa(n, e) {
3787
3787
  for (const [l, f] of r)
3788
3788
  switch (l) {
3789
3789
  case "querySubs": {
3790
- const h = va(l, f, o);
3790
+ const h = Aa(l, f, o);
3791
3791
  a.push(h);
3792
3792
  break;
3793
3793
  }
@@ -3809,7 +3809,7 @@ async function Aa(n, e) {
3809
3809
  });
3810
3810
  }
3811
3811
  const ur = /* @__PURE__ */ new Map();
3812
- class as extends _a {
3812
+ class cs extends ma {
3813
3813
  constructor(t, r) {
3814
3814
  super(t, r);
3815
3815
  p(this, "dbName");
@@ -3817,7 +3817,7 @@ class as extends _a {
3817
3817
  p(this, "_appId");
3818
3818
  p(this, "_prefix");
3819
3819
  p(this, "_dbPromise");
3820
- this.dbName = `instant_${t}_${ma}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3820
+ this.dbName = `instant_${t}_${wa}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3821
3821
  }
3822
3822
  _init() {
3823
3823
  return new Promise((t, r) => {
@@ -3832,8 +3832,8 @@ class as extends _a {
3832
3832
  }, c.onversionchange = () => {
3833
3833
  c.close();
3834
3834
  }, s) {
3835
- const u = Aa(this._appId, c).catch((l) => {
3836
- Ta("Error upgrading store from version 5 to 6.")(l);
3835
+ const u = Oa(this._appId, c).catch((l) => {
3836
+ Sa("Error upgrading store from version 5 to 6.")(l);
3837
3837
  });
3838
3838
  ur.set(this.dbName, u), u.then(() => t(c)).catch(() => t(c));
3839
3839
  } else {
@@ -3847,7 +3847,7 @@ class as extends _a {
3847
3847
  }
3848
3848
  _upgradeStore(t) {
3849
3849
  const s = t.target.result;
3850
- for (const i of wa)
3850
+ for (const i of Ta)
3851
3851
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3852
3852
  }
3853
3853
  // Browsers can close IndexedDB connections unexpectedly (backgrounded tabs,
@@ -3908,7 +3908,7 @@ class as extends _a {
3908
3908
  }));
3909
3909
  }
3910
3910
  }
3911
- class cs {
3911
+ class us {
3912
3912
  static async getIsOnline() {
3913
3913
  return navigator.onLine;
3914
3914
  }
@@ -3936,7 +3936,7 @@ class ie extends Error {
3936
3936
  return "InstantError";
3937
3937
  }
3938
3938
  }
3939
- class Mt extends ie {
3939
+ class Rt extends ie {
3940
3940
  constructor(t) {
3941
3941
  var i, o;
3942
3942
  const r = ((i = t.body) == null ? void 0 : i.message) || `API Error (${t.status})`;
@@ -3944,7 +3944,7 @@ class Mt extends ie {
3944
3944
  p(this, "body");
3945
3945
  p(this, "status");
3946
3946
  const s = new.target.prototype;
3947
- Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Mt), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3947
+ Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Rt), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3948
3948
  }
3949
3949
  get [Symbol.toStringTag]() {
3950
3950
  return "InstantAPIError";
@@ -3952,16 +3952,16 @@ class Mt extends ie {
3952
3952
  }
3953
3953
  async function we(n, e) {
3954
3954
  const t = await fetch(n, e), r = await t.json();
3955
- return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Mt({ status: t.status, body: r }));
3955
+ return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Rt({ status: t.status, body: r }));
3956
3956
  }
3957
- function Oa({ apiURI: n, appId: e, email: t }) {
3957
+ function Ea({ apiURI: n, appId: e, email: t }) {
3958
3958
  return we(`${n}/runtime/auth/send_magic_code`, {
3959
3959
  method: "POST",
3960
3960
  headers: { "content-type": "application/json" },
3961
3961
  body: JSON.stringify({ "app-id": e, email: t })
3962
3962
  });
3963
3963
  }
3964
- async function Ea({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, extraFields: i }) {
3964
+ async function ka({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, extraFields: i }) {
3965
3965
  return await we(`${n}/runtime/auth/verify_magic_code`, {
3966
3966
  method: "POST",
3967
3967
  headers: { "content-type": "application/json" },
@@ -3974,7 +3974,7 @@ async function Ea({ apiURI: n, appId: e, email: t, code: r, refreshToken: s, ext
3974
3974
  })
3975
3975
  });
3976
3976
  }
3977
- async function ka({ apiURI: n, appId: e, refreshToken: t }) {
3977
+ async function Ca({ apiURI: n, appId: e, refreshToken: t }) {
3978
3978
  return await we(`${n}/runtime/auth/verify_refresh_token`, {
3979
3979
  method: "POST",
3980
3980
  headers: { "content-type": "application/json" },
@@ -3984,7 +3984,7 @@ async function ka({ apiURI: n, appId: e, refreshToken: t }) {
3984
3984
  })
3985
3985
  });
3986
3986
  }
3987
- async function Ca({ apiURI: n, appId: e }) {
3987
+ async function Ia({ apiURI: n, appId: e }) {
3988
3988
  return await we(`${n}/runtime/auth/sign_in_guest`, {
3989
3989
  method: "POST",
3990
3990
  headers: { "content-type": "application/json" },
@@ -4006,7 +4006,7 @@ async function lr({ apiURI: n, appId: e, code: t, codeVerifier: r, refreshToken:
4006
4006
  })
4007
4007
  });
4008
4008
  }
4009
- async function Ia({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, refreshToken: i, extraFields: o }) {
4009
+ async function Pa({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, refreshToken: i, extraFields: o }) {
4010
4010
  return await we(`${n}/runtime/oauth/id_token`, {
4011
4011
  method: "POST",
4012
4012
  headers: { "content-type": "application/json" },
@@ -4020,7 +4020,7 @@ async function Ia({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, re
4020
4020
  })
4021
4021
  });
4022
4022
  }
4023
- async function Pa({ apiURI: n, appId: e, refreshToken: t }) {
4023
+ async function Ma({ apiURI: n, appId: e, refreshToken: t }) {
4024
4024
  return await we(`${n}/runtime/signout`, {
4025
4025
  method: "POST",
4026
4026
  headers: {
@@ -4045,7 +4045,7 @@ async function Ra({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, cont
4045
4045
  body: r
4046
4046
  });
4047
4047
  }
4048
- async function Ma({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4048
+ async function ja({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4049
4049
  const { data: s } = await we(`${n}/storage/files?app_id=${e}&filename=${encodeURIComponent(t)}`, {
4050
4050
  method: "DELETE",
4051
4051
  headers: {
@@ -4055,7 +4055,7 @@ async function Ma({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4055
4055
  });
4056
4056
  return s;
4057
4057
  }
4058
- async function ja({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata: s = {} }) {
4058
+ async function $a({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata: s = {} }) {
4059
4059
  const { data: i } = await we(`${n}/storage/signed-upload-url`, {
4060
4060
  method: "POST",
4061
4061
  headers: {
@@ -4069,7 +4069,7 @@ async function ja({ apiURI: n, appId: e, fileName: t, refreshToken: r, metadata:
4069
4069
  });
4070
4070
  return i;
4071
4071
  }
4072
- async function $a(n, e) {
4072
+ async function xa(n, e) {
4073
4073
  return (await fetch(n, {
4074
4074
  method: "PUT",
4075
4075
  body: e,
@@ -4078,7 +4078,7 @@ async function $a(n, e) {
4078
4078
  }
4079
4079
  })).ok;
4080
4080
  }
4081
- async function xa({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4081
+ async function Da({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4082
4082
  const { data: s } = await we(`${n}/storage/signed-download-url?app_id=${e}&filename=${encodeURIComponent(t)}`, {
4083
4083
  method: "GET",
4084
4084
  headers: {
@@ -4088,8 +4088,8 @@ async function xa({ apiURI: n, appId: e, path: t, refreshToken: r }) {
4088
4088
  });
4089
4089
  return s;
4090
4090
  }
4091
- let Cn = !1, us = !1, ls = !1;
4092
- typeof window < "u" && typeof window.localStorage < "u" && (Cn = !!window.localStorage.getItem("devBackend"), us = !!window.localStorage.getItem("__instantLogging"), ls = !!window.localStorage.getItem("__devtoolLocalDash"));
4091
+ let Cn = !1, ls = !1, fs = !1;
4092
+ typeof window < "u" && typeof window.localStorage < "u" && (Cn = !!window.localStorage.getItem("devBackend"), ls = !!window.localStorage.getItem("__instantLogging"), fs = !!window.localStorage.getItem("__devtoolLocalDash"));
4093
4093
  function fr(n, e) {
4094
4094
  if (!e)
4095
4095
  return n;
@@ -4098,7 +4098,7 @@ function fr(n, e) {
4098
4098
  t[r] = n[r];
4099
4099
  }), t;
4100
4100
  }
4101
- function Da(n, e, t) {
4101
+ function Ua(n, e, t) {
4102
4102
  const r = {
4103
4103
  peers: {}
4104
4104
  };
@@ -4115,8 +4115,8 @@ function Da(n, e, t) {
4115
4115
  }
4116
4116
  return r;
4117
4117
  }
4118
- function Ua(n, e) {
4119
- if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !Jn(n.user, e.user)) || !Fr(n.peers, e.peers))
4118
+ function La(n, e) {
4119
+ if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !Jn(n.user, e.user)) || !Nr(n.peers, e.peers))
4120
4120
  return !0;
4121
4121
  for (const r of Object.keys(n.peers))
4122
4122
  if (!Jn(n.peers[r], e.peers[r]))
@@ -4139,18 +4139,18 @@ class dr {
4139
4139
  this._reject(e);
4140
4140
  }
4141
4141
  }
4142
- function fs(n, e = []) {
4142
+ function ds(n, e = []) {
4143
4143
  n.forEach((t) => {
4144
4144
  const { data: r } = t, { "datalog-result": s } = r, { "join-rows": i } = s;
4145
4145
  for (const o of i)
4146
4146
  for (const a of o)
4147
4147
  e.push(a);
4148
- fs(t["child-nodes"], e);
4148
+ ds(t["child-nodes"], e);
4149
4149
  });
4150
4150
  }
4151
4151
  function hr(n) {
4152
4152
  const e = [];
4153
- return fs(n, e), e;
4153
+ return ds(n, e), e;
4154
4154
  }
4155
4155
  function pr(n) {
4156
4156
  return Object.values(n.links).reduce((e, t) => {
@@ -4166,8 +4166,8 @@ function pr(n) {
4166
4166
  }, e;
4167
4167
  }, {});
4168
4168
  }
4169
- const ds = "v1.0.42";
4170
- function La(n, e) {
4169
+ const hs = "v1.0.43-branch-drewh-user-sync-less-often.26902629460.1";
4170
+ function Fa(n, e) {
4171
4171
  return {
4172
4172
  info: n ? (...t) => console.info(...t, e()) : () => {
4173
4173
  },
@@ -4229,7 +4229,7 @@ const yr = [
4229
4229
  "beforeInclusive",
4230
4230
  "fields",
4231
4231
  "aggregate"
4232
- ], Fa = (n) => n.valueType || "unknown", hs = (n, e, t = !1) => {
4232
+ ], Na = (n) => n.valueType || "unknown", ps = (n, e, t = !1) => {
4233
4233
  if (t || n == null)
4234
4234
  return !0;
4235
4235
  switch (e) {
@@ -4244,9 +4244,9 @@ const yr = [
4244
4244
  default:
4245
4245
  return !0;
4246
4246
  }
4247
- }, Na = (n, e, t, r, s, i, o) => {
4247
+ }, Ka = (n, e, t, r, s, i, o) => {
4248
4248
  const a = i.valueType === "json", c = (u, l, f) => {
4249
- if (!hs(f, l, a))
4249
+ if (!ps(f, l, a))
4250
4250
  throw new Q(`Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
4251
4251
  };
4252
4252
  switch (n) {
@@ -4277,16 +4277,16 @@ const yr = [
4277
4277
  throw new Q(`Unknown operator '${n}' for attribute '${r}' in entity '${s}'`, o);
4278
4278
  }
4279
4279
  }, ze = (n, e, t, r, s) => {
4280
- const i = Fa(t), o = t.valueType === "json";
4280
+ const i = Na(t), o = t.valueType === "json";
4281
4281
  if (typeof n == "object" && n !== null && !Array.isArray(n)) {
4282
4282
  if (o)
4283
4283
  return;
4284
4284
  const c = n;
4285
4285
  for (const [u, l] of Object.entries(c))
4286
- Na(u, l, i, e, r, t, `${s}.${u}`);
4287
- } else if (!hs(n, i, o))
4286
+ Ka(u, l, i, e, r, t, `${s}.${u}`);
4287
+ } else if (!ps(n, i, o))
4288
4288
  throw new Q(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof n}`, s);
4289
- }, Ka = (n, e, t, r, s) => {
4289
+ }, qa = (n, e, t, r, s) => {
4290
4290
  const i = n.split(".");
4291
4291
  if (i.length < 2)
4292
4292
  throw new Q(`Invalid dot notation path '${n}'. Must contain at least one dot.`, s);
@@ -4323,12 +4323,12 @@ const yr = [
4323
4323
  throw new Q(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${n}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
4324
4324
  }
4325
4325
  ze(e, n, u, t, s);
4326
- }, ps = (n, e, t, r) => {
4326
+ }, ys = (n, e, t, r) => {
4327
4327
  for (const [s, i] of Object.entries(n)) {
4328
4328
  if (s === "or" || s === "and") {
4329
4329
  if (Array.isArray(i))
4330
4330
  for (const u of i)
4331
- typeof u == "object" && u !== null && ps(u, e, t, `${r}.${s}[${u}]`);
4331
+ typeof u == "object" && u !== null && ys(u, e, t, `${r}.${s}[${u}]`);
4332
4332
  continue;
4333
4333
  }
4334
4334
  if (s === "id") {
@@ -4336,7 +4336,7 @@ const yr = [
4336
4336
  continue;
4337
4337
  }
4338
4338
  if (s.includes(".")) {
4339
- Ka(s, i, e, t, `${r}.${s}`);
4339
+ qa(s, i, e, t, `${r}.${s}`);
4340
4340
  continue;
4341
4341
  }
4342
4342
  const o = t.entities[e];
@@ -4356,7 +4356,7 @@ const yr = [
4356
4356
  ze(i, s, u, e, `${r}.${s}`);
4357
4357
  }
4358
4358
  }
4359
- }, qa = (n, e, t, r, s = 0) => {
4359
+ }, Wa = (n, e, t, r, s = 0) => {
4360
4360
  for (const o of Object.keys(n))
4361
4361
  if (!yr.includes(o))
4362
4362
  throw new Q(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${yr.join(", ")}. Found: ${o}`, r);
@@ -4376,9 +4376,9 @@ const yr = [
4376
4376
  if (n.where && t) {
4377
4377
  if (typeof n.where != "object" || n.where === null)
4378
4378
  throw new Q(`'where' clause must be an object in entity '${e}', but received: ${typeof n.where}`, r ? `${r}.where` : void 0);
4379
- ps(n.where, e, t, r ? `${r}.where` : "where");
4379
+ ys(n.where, e, t, r ? `${r}.where` : "where");
4380
4380
  }
4381
- }, ys = (n, e, t, r, s = 0) => {
4381
+ }, bs = (n, e, t, r, s = 0) => {
4382
4382
  var i;
4383
4383
  if (!n || typeof n != "object")
4384
4384
  throw new Q(`Query part for entity '${e}' must be an object, but received: ${typeof n}`, r);
@@ -4391,13 +4391,13 @@ const yr = [
4391
4391
  const a = n[o];
4392
4392
  if (typeof a == "object" && a !== null) {
4393
4393
  const c = (i = t == null ? void 0 : t.entities[e].links[o]) == null ? void 0 : i.entityName;
4394
- c && ys(a, c, t, `${r}.${o}`, s + 1);
4394
+ c && bs(a, c, t, `${r}.${o}`, s + 1);
4395
4395
  }
4396
4396
  } else {
4397
4397
  const a = n[o];
4398
4398
  if (typeof a != "object" || a === null)
4399
4399
  throw new Q(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`, `${r}.$`);
4400
- qa(a, e, t, `${r}.$`, s);
4400
+ Wa(a, e, t, `${r}.$`, s);
4401
4401
  }
4402
4402
  }, br = (n, e) => {
4403
4403
  if (typeof n != "object" || n === null)
@@ -4415,7 +4415,7 @@ const yr = [
4415
4415
  const s = Object.keys(e.entities);
4416
4416
  throw new Q(`Entity '${r}' does not exist in schema. Available entities: ${s.length > 0 ? s.join(", ") : "none"}`, r);
4417
4417
  }
4418
- ys(t[r], r, e, r, 0);
4418
+ bs(t[r], r, e, r, 0);
4419
4419
  }
4420
4420
  }
4421
4421
  }, gr = (n) => typeof n != "string" ? !1 : It(n) ? !0 : Ve(n);
@@ -4424,39 +4424,39 @@ class be extends Error {
4424
4424
  super(e), this.name = "TransactionValidationError";
4425
4425
  }
4426
4426
  }
4427
- const bs = (n) => n.length > 0 ? n.join(", ") : "none", Wa = (n, e) => new be(`Entity '${n}' does not exist in schema. Available entities: ${bs(e)}`), qt = {
4427
+ const gs = (n) => n.length > 0 ? n.join(", ") : "none", za = (n, e) => new be(`Entity '${n}' does not exist in schema. Available entities: ${gs(e)}`), qt = {
4428
4428
  string: (n) => typeof n == "string",
4429
4429
  number: (n) => typeof n == "number" && !isNaN(n),
4430
4430
  boolean: (n) => typeof n == "boolean",
4431
4431
  date: (n) => n instanceof Date || typeof n == "string" || typeof n == "number",
4432
4432
  json: () => !0
4433
- }, za = (n, e) => {
4433
+ }, Va = (n, e) => {
4434
4434
  var t;
4435
4435
  return n == null ? !0 : ((t = qt[e.valueType]) == null ? void 0 : t.call(qt, n)) ?? !1;
4436
- }, gs = (n, e) => {
4436
+ }, _s = (n, e) => {
4437
4437
  const t = e.entities[n];
4438
4438
  if (!t)
4439
- throw Wa(n, Object.keys(e.entities));
4439
+ throw za(n, Object.keys(e.entities));
4440
4440
  return t;
4441
4441
  }, Wt = (n, e, t) => {
4442
- const r = gs(n, t);
4442
+ const r = _s(n, t);
4443
4443
  if (typeof e != "object" || e === null)
4444
4444
  throw new be(`Arguments for data operation on entity '${n}' must be an object, but received: ${typeof e}`);
4445
4445
  for (const [s, i] of Object.entries(e)) {
4446
4446
  if (s === "id")
4447
4447
  continue;
4448
4448
  const o = r.attrs[s];
4449
- if (o && !za(i, o))
4449
+ if (o && !Va(i, o))
4450
4450
  throw new be(`Invalid value for attribute '${s}' in entity '${n}'. Expected ${o.valueType}, but received: ${typeof i}`);
4451
4451
  }
4452
4452
  }, _r = (n, e, t) => {
4453
- const r = gs(n, t);
4453
+ const r = _s(n, t);
4454
4454
  if (typeof e != "object" || e === null)
4455
4455
  throw new be(`Arguments for link operation on entity '${n}' must be an object, but received: ${typeof e}`);
4456
4456
  for (const [s, i] of Object.entries(e)) {
4457
4457
  if (!r.links[s]) {
4458
4458
  const a = Object.keys(r.links);
4459
- throw new be(`Link '${s}' does not exist on entity '${n}'. Available links: ${bs(a)}`);
4459
+ throw new be(`Link '${s}' does not exist on entity '${n}'. Available links: ${gs(a)}`);
4460
4460
  }
4461
4461
  if (i != null) {
4462
4462
  if (Array.isArray(i)) {
@@ -4467,7 +4467,7 @@ const bs = (n) => n.length > 0 ? n.join(", ") : "none", Wa = (n, e) => new be(`E
4467
4467
  throw new be(`Invalid UUID in link '${s}' for entity '${n}'. Expected a UUID, but received: ${i}`);
4468
4468
  }
4469
4469
  }
4470
- }, Va = {
4470
+ }, Qa = {
4471
4471
  create: Wt,
4472
4472
  update: Wt,
4473
4473
  merge: Wt,
@@ -4475,7 +4475,7 @@ const bs = (n) => n.length > 0 ? n.join(", ") : "none", Wa = (n, e) => new be(`E
4475
4475
  unlink: _r,
4476
4476
  delete: () => {
4477
4477
  }
4478
- }, Qa = (n, e) => {
4478
+ }, Ba = (n, e) => {
4479
4479
  if (!e)
4480
4480
  return;
4481
4481
  const [t, r, s, i] = n;
@@ -4483,9 +4483,9 @@ const bs = (n) => n.length > 0 ? n.join(", ") : "none", Wa = (n, e) => new be(`E
4483
4483
  throw new be(`Invalid id for entity '${r}'. Expected a UUID, but received: ${s}`);
4484
4484
  if (typeof r != "string")
4485
4485
  throw new be(`Entity name must be a string, but received: ${typeof r}`);
4486
- const o = Va[t];
4486
+ const o = Qa[t];
4487
4487
  o && i !== void 0 && o(r, i, e);
4488
- }, Ba = (n, e) => {
4488
+ }, Ga = (n, e) => {
4489
4489
  const t = Array.isArray(n) ? n : [n];
4490
4490
  for (const r of t) {
4491
4491
  if (!r || typeof r != "object")
@@ -4495,11 +4495,11 @@ const bs = (n) => n.length > 0 ? n.join(", ") : "none", Wa = (n, e) => new be(`E
4495
4495
  for (const s of r.__ops) {
4496
4496
  if (!Array.isArray(s))
4497
4497
  throw new be(`Transaction operation must be an array, but received: ${typeof s}`);
4498
- Qa(s, e);
4498
+ Ba(s, e);
4499
4499
  }
4500
4500
  }
4501
4501
  };
4502
- let _s = 0;
4502
+ let ms = 0;
4503
4503
  class mr {
4504
4504
  constructor(e) {
4505
4505
  p(this, "type", "ws");
@@ -4509,7 +4509,7 @@ class mr {
4509
4509
  p(this, "onmessage");
4510
4510
  p(this, "onclose");
4511
4511
  p(this, "onerror");
4512
- this.id = `${this.type}_${_s++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4512
+ this.id = `${this.type}_${ms++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4513
4513
  this.onopen && this.onopen({ target: this });
4514
4514
  }, this.conn.onmessage = (t) => {
4515
4515
  this.onmessage && this.onmessage({
@@ -4535,7 +4535,7 @@ class mr {
4535
4535
  return this.conn.send(JSON.stringify(e));
4536
4536
  }
4537
4537
  }
4538
- class Ga {
4538
+ class Ha {
4539
4539
  constructor(e, t, r) {
4540
4540
  p(this, "type", "sse");
4541
4541
  p(this, "initParams", null);
@@ -4552,7 +4552,7 @@ class Ga {
4552
4552
  p(this, "onmessage");
4553
4553
  p(this, "onclose");
4554
4554
  p(this, "onerror");
4555
- this.id = `${this.type}_${_s++}`, this.url = t, this.messageUrl = r || this.url, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4555
+ this.id = `${this.type}_${ms++}`, this.url = t, this.messageUrl = r || this.url, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4556
4556
  this.initParams || this.handleError();
4557
4557
  }, 1e4), this.conn.onmessage = (s) => {
4558
4558
  const i = JSON.parse(s.data);
@@ -4632,24 +4632,24 @@ class Ga {
4632
4632
  this.handleClose();
4633
4633
  }
4634
4634
  }
4635
- function Ha(n, e) {
4635
+ function Ja(n, e) {
4636
4636
  const t = n.values;
4637
4637
  if (t) {
4638
- const r = Vr(t.attrsStore, null);
4638
+ const r = Qr(t.attrsStore, null);
4639
4639
  if (r) {
4640
4640
  for (const s of t.entities || [])
4641
- s.store.useDateObjects = e, s.store = zr(r, s.store);
4641
+ s.store.useDateObjects = e, s.store = Vr(r, s.store);
4642
4642
  t.attrsStore = r;
4643
4643
  }
4644
4644
  }
4645
4645
  return n;
4646
4646
  }
4647
- function Ja(n, e) {
4647
+ function Ya(n, e) {
4648
4648
  var t;
4649
4649
  if (e.values) {
4650
4650
  const r = [];
4651
4651
  for (const s of (t = e.values) == null ? void 0 : t.entities) {
4652
- const i = Wr(s.store);
4652
+ const i = zr(s.store);
4653
4653
  r.push({ ...s, store: i });
4654
4654
  }
4655
4655
  return {
@@ -4659,13 +4659,13 @@ function Ja(n, e) {
4659
4659
  } else
4660
4660
  return e;
4661
4661
  }
4662
- function Ya(n, e, t) {
4662
+ function Za(n, e, t) {
4663
4663
  var i, o;
4664
4664
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = t == null ? void 0 : t.state) == null ? void 0 : o.txId;
4665
4665
  return r && (!s || r > s) ? e : s && (!r || s > r) ? t : e || t;
4666
4666
  }
4667
4667
  function zt(n, e, t) {
4668
- return ss({ store: e, attrsStore: t, pageInfo: null, aggregate: null }, n.query).data[n.table][0];
4668
+ return is({ store: e, attrsStore: t, pageInfo: null, aggregate: null }, n.query).data[n.table][0];
4669
4669
  }
4670
4670
  function wr(n, e, t, r) {
4671
4671
  var o;
@@ -4679,14 +4679,14 @@ function Tr(n, e, t) {
4679
4679
  for (const { action: r, triple: s } of t)
4680
4680
  switch (r) {
4681
4681
  case "added":
4682
- Gr(n, e, s);
4682
+ Hr(n, e, s);
4683
4683
  break;
4684
4684
  case "removed":
4685
- Qr(n, e, s);
4685
+ Br(n, e, s);
4686
4686
  break;
4687
4687
  }
4688
4688
  }
4689
- function Za(n, e, t) {
4689
+ function Xa(n, e, t) {
4690
4690
  var s, i;
4691
4691
  const r = {};
4692
4692
  for (const { action: o, triple: a } of t) {
@@ -4714,14 +4714,14 @@ function Za(n, e, t) {
4714
4714
  function bt(n, e) {
4715
4715
  return { [n.table]: e.map((t) => t.entity) };
4716
4716
  }
4717
- function Xa(n, e) {
4717
+ function ec(n, e) {
4718
4718
  var r;
4719
4719
  if (n.orderFieldType)
4720
4720
  return n.orderFieldType;
4721
4721
  const t = n.orderField === "serverCreatedAt" ? "number" : (r = ne(e(), n.table, n.orderField)) == null ? void 0 : r["checked-data-type"];
4722
4722
  return n.orderFieldType = t, t;
4723
4723
  }
4724
- function ec(n, e, t) {
4724
+ function tc(n, e, t) {
4725
4725
  const r = e;
4726
4726
  if (n.orderField === "serverCreatedAt") {
4727
4727
  t.sort(n.orderDirection === "asc" ? function(o, a) {
@@ -4742,7 +4742,7 @@ var Ie;
4742
4742
  (function(n) {
4743
4743
  n.InitialSyncBatch = "InitialSyncBatch", n.InitialSyncComplete = "InitialSyncComplete", n.LoadFromStorage = "LoadFromStorage", n.SyncTransaction = "SyncTransaction", n.Error = "Error";
4744
4744
  })(Ie || (Ie = {}));
4745
- class tc {
4745
+ class nc {
4746
4746
  constructor(e, t, r, s, i, o) {
4747
4747
  p(this, "trySend");
4748
4748
  p(this, "subs");
@@ -4755,9 +4755,9 @@ class tc {
4755
4755
  p(this, "getAttrs");
4756
4756
  this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new hn({
4757
4757
  persister: t,
4758
- merge: Ya,
4759
- serialize: Ja,
4760
- parse: (a, c) => Ha(c, this.config.useDateObjects),
4758
+ merge: Za,
4759
+ serialize: Ya,
4760
+ parse: (a, c) => Ja(c, this.config.useDateObjects),
4761
4761
  objectSize: (a) => {
4762
4762
  var c;
4763
4763
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4954,12 +4954,12 @@ class tc {
4954
4954
  const T = f[_];
4955
4955
  if (Ri(T.store, m)) {
4956
4956
  Tr(T.store, l.attrsStore, S);
4957
- const R = zt(s, T.store, l.attrsStore), O = Za(T.store, l.attrsStore, S)[m];
4958
- R ? (h.push({
4957
+ const M = zt(s, T.store, l.attrsStore), O = Xa(T.store, l.attrsStore, S)[m];
4958
+ M ? (h.push({
4959
4959
  oldEntity: T.entity,
4960
- newEntity: R,
4960
+ newEntity: M,
4961
4961
  changedFields: O || {}
4962
- }), T.entity = R) : c.push(_), delete u[m];
4962
+ }), T.entity = M) : c.push(_), delete u[m];
4963
4963
  continue e;
4964
4964
  }
4965
4965
  }
@@ -4985,8 +4985,8 @@ class tc {
4985
4985
  const b = [];
4986
4986
  for (const m of c.sort().reverse())
4987
4987
  b.push(f[m].entity), f.splice(m, 1);
4988
- const g = Xa(s, this.getAttrs);
4989
- ec(s, g, f), this.notifyCbs(r, {
4988
+ const g = ec(s, this.getAttrs);
4989
+ tc(s, g, f), this.notifyCbs(r, {
4990
4990
  type: Ie.SyncTransaction,
4991
4991
  data: bt(s, (o = s.values) == null ? void 0 : o.entities),
4992
4992
  added: y,
@@ -5027,7 +5027,7 @@ class tc {
5027
5027
  r && this.initSubscription(r.query, r.hash);
5028
5028
  }
5029
5029
  }
5030
- function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStream: s }) {
5030
+ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStream: s }) {
5031
5031
  const i = e.clientId;
5032
5032
  let o = null, a = null, c = null;
5033
5033
  const u = J();
@@ -5035,7 +5035,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5035
5035
  const h = [], y = [], b = [];
5036
5036
  let g = !1, m = 0, S = 0;
5037
5037
  const _ = [], T = new TextEncoder();
5038
- function R() {
5038
+ function M() {
5039
5039
  f = !0;
5040
5040
  for (const A of h)
5041
5041
  A(a ?? void 0);
@@ -5087,7 +5087,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5087
5087
  K > 0 && (m += H, S -= H, _.splice(0, K));
5088
5088
  }
5089
5089
  function z(A, k) {
5090
- a = k, R(), A.error(k), P();
5090
+ a = k, M(), A.error(k), P();
5091
5091
  }
5092
5092
  async function ee() {
5093
5093
  const A = await t({
@@ -5124,7 +5124,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5124
5124
  function j(A) {
5125
5125
  return l ? (z(A, new ie("Stream has been closed.")), null) : o || (z(A, new ie("Stream has not been initialized.")), null);
5126
5126
  }
5127
- async function M(A) {
5127
+ async function R(A) {
5128
5128
  c = A;
5129
5129
  let k = !0, K = 0;
5130
5130
  for (; k; ) {
@@ -5188,7 +5188,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5188
5188
  // browser restarts
5189
5189
  async start(A) {
5190
5190
  try {
5191
- await M(A);
5191
+ await R(A);
5192
5192
  } catch (k) {
5193
5193
  z(A, k);
5194
5194
  }
@@ -5208,7 +5208,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5208
5208
  chunks: [],
5209
5209
  offset: m + S,
5210
5210
  isDone: !0
5211
- }) : P(), R();
5211
+ }) : P(), M();
5212
5212
  },
5213
5213
  abort(A) {
5214
5214
  o ? r({
@@ -5217,7 +5217,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5217
5217
  offset: m + S,
5218
5218
  isDone: !0,
5219
5219
  abortReason: A
5220
- }) : P(), R();
5220
+ }) : P(), M();
5221
5221
  }
5222
5222
  }),
5223
5223
  addCompleteCb: F,
@@ -5226,7 +5226,7 @@ function nc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5226
5226
  }
5227
5227
  };
5228
5228
  }
5229
- class rc {
5229
+ class sc {
5230
5230
  constructor() {
5231
5231
  p(this, "items", []);
5232
5232
  p(this, "resolvers", []);
@@ -5260,7 +5260,7 @@ class rc {
5260
5260
  }
5261
5261
  }
5262
5262
  }
5263
- function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5263
+ function ic({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5264
5264
  let s = e.byteOffset || 0, i = !1;
5265
5265
  const o = new TextDecoder("utf-8"), a = new TextEncoder();
5266
5266
  let c, u = !1;
@@ -5313,16 +5313,16 @@ function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5313
5313
  signal: z.signal
5314
5314
  });
5315
5315
  for (let q = 0; q < N.files.length; q++) {
5316
- const E = N.files[q + 1], M = await ee;
5317
- if (E && (ee = fetch(E.url, { signal: z.signal })), !M.ok) {
5316
+ const E = N.files[q + 1], R = await ee;
5317
+ if (E && (ee = fetch(E.url, { signal: z.signal })), !R.ok) {
5318
5318
  if (_++, _ > 10) {
5319
5319
  S(C, new ie("Unable to process stream."));
5320
5320
  return;
5321
5321
  }
5322
5322
  return { retry: !0 };
5323
5323
  }
5324
- if (M.body) {
5325
- const U = M.body.getReader();
5324
+ if (R.body) {
5325
+ const U = R.body.getReader();
5326
5326
  try {
5327
5327
  for (; ; ) {
5328
5328
  const { done: L, value: A } = await U.read();
@@ -5343,7 +5343,7 @@ function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5343
5343
  U.releaseLock();
5344
5344
  }
5345
5345
  } else {
5346
- const U = await M.arrayBuffer();
5346
+ const U = await R.arrayBuffer();
5347
5347
  let L = U;
5348
5348
  if (i) {
5349
5349
  z.abort();
@@ -5369,7 +5369,7 @@ function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5369
5369
  }
5370
5370
  }
5371
5371
  }
5372
- async function R(P) {
5372
+ async function M(P) {
5373
5373
  let C = !0, G = 0;
5374
5374
  for (; C; ) {
5375
5375
  C = !1;
@@ -5406,7 +5406,7 @@ function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5406
5406
  return {
5407
5407
  stream: new O({
5408
5408
  start(P) {
5409
- R(P);
5409
+ M(P);
5410
5410
  },
5411
5411
  cancel(P) {
5412
5412
  i = !0, c && r({ eventId: c }), b();
@@ -5418,7 +5418,7 @@ function sc({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5418
5418
  }
5419
5419
  };
5420
5420
  }
5421
- class ic {
5421
+ class oc {
5422
5422
  constructor({ WStream: e, RStream: t, trySend: r, log: s }) {
5423
5423
  p(this, "trySend");
5424
5424
  p(this, "WStream");
@@ -5431,7 +5431,7 @@ class ic {
5431
5431
  this.WStream = e, this.RStream = t, this.trySend = r, this.log = s;
5432
5432
  }
5433
5433
  createWriteStream(e) {
5434
- const { stream: t, addCompleteCb: r } = nc({
5434
+ const { stream: t, addCompleteCb: r } = rc({
5435
5435
  WStream: this.WStream,
5436
5436
  startStream: this.startWriteStream.bind(this),
5437
5437
  appendStream: this.appendStream.bind(this),
@@ -5443,7 +5443,7 @@ class ic {
5443
5443
  }), t;
5444
5444
  }
5445
5445
  createReadStream(e) {
5446
- const { stream: t, addCloseCb: r } = sc({
5446
+ const { stream: t, addCloseCb: r } = ic({
5447
5447
  RStream: this.RStream,
5448
5448
  opts: e,
5449
5449
  startStream: this.startReadStream.bind(this),
@@ -5505,7 +5505,7 @@ class ic {
5505
5505
  if (!r && !t)
5506
5506
  throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");
5507
5507
  r && (o["stream-id"] = r), t && (o["client-id"] = t), s && (o.offset = s), i && (o["rule-params"] = i);
5508
- const a = new rc();
5508
+ const a = new sc();
5509
5509
  return this.readStreamIterators[e] = a, this.trySend(e, o), a;
5510
5510
  }
5511
5511
  cancelReadStream({ eventId: e }) {
@@ -5586,39 +5586,39 @@ const Te = {
5586
5586
  AUTHENTICATED: "authenticated",
5587
5587
  CLOSED: "closed",
5588
5588
  ERRORED: "errored"
5589
- }, oc = 3e4, ac = 3e4, cc = 200, uc = 1e3 * 60, lc = {
5589
+ }, ac = 3e4, cc = 3e4, uc = 200, lc = 1e3 * 60, fc = lc * 60 * 24, Sr = "lastSyncedUserCookie", dc = {
5590
5590
  apiURI: "https://api.instantdb.com",
5591
5591
  websocketURI: "wss://api.instantdb.com/runtime/session"
5592
5592
  }, Vt = "_instant_oauth_redirect", Qt = "_instant_extra_fields_id", gt = "oauthExtraFields", Fe = "currentUser";
5593
- function fc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5593
+ function hc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5594
5594
  if (!s)
5595
5595
  return new mr(`${r}?app_id=${e}`);
5596
5596
  switch (n) {
5597
5597
  case "ws":
5598
5598
  return new mr(`${r}?app_id=${e}`);
5599
5599
  case "sse":
5600
- return new Ga(s, `${t}/runtime/sse?app_id=${e}`);
5600
+ return new Ha(s, `${t}/runtime/sse?app_id=${e}`);
5601
5601
  default:
5602
5602
  throw new Error("Unknown transport type " + n);
5603
5603
  }
5604
5604
  }
5605
- function dc() {
5605
+ function pc() {
5606
5606
  return typeof window < "u" || typeof chrome < "u";
5607
5607
  }
5608
- const Sr = {
5608
+ const vr = {
5609
5609
  "set-presence": !0,
5610
5610
  "set-presence-ok": !0,
5611
5611
  "refresh-presence": !0,
5612
5612
  "patch-presence": !0
5613
5613
  };
5614
- function hc(n, e) {
5614
+ function yc(n, e) {
5615
5615
  var r;
5616
5616
  const t = typeof n == "string" ? JSON.parse(n) : n;
5617
5617
  if ((r = t == null ? void 0 : t.result) != null && r.store) {
5618
- const s = Vr(t.result.attrsStore, t.result.store);
5618
+ const s = Qr(t.result.attrsStore, t.result.store);
5619
5619
  if (s) {
5620
5620
  const i = t.result.store;
5621
- t.result.store = zr(s, {
5621
+ t.result.store = Vr(s, {
5622
5622
  ...i,
5623
5623
  useDateObjects: e
5624
5624
  }), t.result.attrsStore = s;
@@ -5626,7 +5626,7 @@ function hc(n, e) {
5626
5626
  }
5627
5627
  return t;
5628
5628
  }
5629
- function pc(n, e) {
5629
+ function bc(n, e) {
5630
5630
  const { result: t, ...r } = e, s = (
5631
5631
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
5632
5632
  r
@@ -5634,14 +5634,14 @@ function pc(n, e) {
5634
5634
  if (t) {
5635
5635
  const i = {
5636
5636
  ...t,
5637
- store: Wr(t.store),
5637
+ store: zr(t.store),
5638
5638
  attrsStore: t.attrsStore.toJSON()
5639
5639
  };
5640
5640
  s.result = i;
5641
5641
  }
5642
5642
  return s;
5643
5643
  }
5644
- function yc(n, e) {
5644
+ function gc(n, e) {
5645
5645
  switch (n) {
5646
5646
  case "pendingMutations":
5647
5647
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5649,7 +5649,7 @@ function yc(n, e) {
5649
5649
  return e;
5650
5650
  }
5651
5651
  }
5652
- function bc(n, e) {
5652
+ function _c(n, e) {
5653
5653
  switch (n) {
5654
5654
  case "pendingMutations":
5655
5655
  return [...e.entries()];
@@ -5657,7 +5657,7 @@ function bc(n, e) {
5657
5657
  return e;
5658
5658
  }
5659
5659
  }
5660
- function gc(n, e, t) {
5660
+ function mc(n, e, t) {
5661
5661
  const r = e == null ? void 0 : e.result, s = t == null ? void 0 : t.result;
5662
5662
  return r && !s && t && (t.result = r), t || e;
5663
5663
  }
@@ -5667,8 +5667,8 @@ function Bt(n) {
5667
5667
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
5668
5668
  });
5669
5669
  }
5670
- class _c {
5671
- constructor(e, t = as, r = cs, s, i) {
5670
+ class wc {
5671
+ constructor(e, t = cs, r = us, s, i) {
5672
5672
  /** @type {s.AttrsStore | undefined} */
5673
5673
  p(this, "attrs");
5674
5674
  p(this, "_isOnline", !0);
@@ -5766,9 +5766,9 @@ class _c {
5766
5766
  });
5767
5767
  /** Applies transactions locally and sends transact message to server */
5768
5768
  p(this, "pushTx", (e) => {
5769
- this.config.disableValidation || Ba(e, this.config.schema);
5769
+ this.config.disableValidation || Ga(e, this.config.schema);
5770
5770
  try {
5771
- const t = ga({
5771
+ const t = _a({
5772
5772
  attrsStore: this.optimisticAttrs(),
5773
5773
  schema: this.config.schema,
5774
5774
  stores: Object.values(this.querySubs.currentValue).map((r) => {
@@ -5869,7 +5869,7 @@ class _c {
5869
5869
  }
5870
5870
  this._log.info("[socket][close]", t.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5871
5871
  });
5872
- if (this._EventSource = i, this.config = { ...lc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? ac, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? cc, this._log = La(e.verbose || Cn || us, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": ds }, this.config.schema && (this._linkIndex = pr(this.config.schema)), !!dc()) {
5872
+ if (this._EventSource = i, this.config = { ...dc, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? cc, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? uc, this._log = Fa(e.verbose || Cn || ls, () => this._reactorStats()), this.versions = { ...s || {}, "@instantdb/core": hs }, this.config.schema && (this._linkIndex = pr(this.config.schema)), !!pc()) {
5873
5873
  if (!e.appId)
5874
5874
  throw new Error("Instant must be initialized with an appId.");
5875
5875
  if (!Ve(e.appId))
@@ -5888,19 +5888,14 @@ class _c {
5888
5888
  } catch (c) {
5889
5889
  this._log.error("[error] handle broadcast channel", c);
5890
5890
  }
5891
- })), this._initStorage(t), this._syncTable = new tc(this._trySendAuthed.bind(this), new t(this.config.appId, "syncSubs"), {
5891
+ })), this._initStorage(t), this._syncTable = new nc(this._trySendAuthed.bind(this), new t(this.config.appId, "syncSubs"), {
5892
5892
  useDateObjects: this.config.useDateObjects
5893
- }, this._log, (o) => tt(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new ic({
5893
+ }, this._log, (o) => tt(this.ensureAttrs(), o, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._instantStream = new oc({
5894
5894
  WStream: this.config.WritableStream || WritableStream,
5895
5895
  RStream: this.config.ReadableStream || ReadableStream,
5896
5896
  trySend: this._trySendAuthed.bind(this),
5897
5897
  log: this._log
5898
- }), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser().then((o) => {
5899
- this.syncUserToEndpoint(o.user);
5900
- }), setInterval(async () => {
5901
- const o = await this.getCurrentUser();
5902
- this.syncUserToEndpoint(o.user);
5903
- }, uc), r.getIsOnline().then((o) => {
5898
+ }), this._oauthCallbackResponse = this._oauthLoginInit(), this.setupUserSyncTimer(), r.getIsOnline().then((o) => {
5904
5899
  this._isOnline = o, this._startSocket(), r.listen((a) => {
5905
5900
  a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", Te.CLOSED), this._setStatus(Te.CLOSED)));
5906
5901
  });
@@ -5939,9 +5934,9 @@ class _c {
5939
5934
  _initStorage(e) {
5940
5935
  this.querySubs = new hn({
5941
5936
  persister: new e(this.config.appId, "querySubs"),
5942
- merge: gc,
5943
- serialize: pc,
5944
- parse: (t, r) => hc(r, this.config.useDateObjects),
5937
+ merge: mc,
5938
+ serialize: bc,
5939
+ parse: (t, r) => yc(r, this.config.useDateObjects),
5945
5940
  // objectSize
5946
5941
  objectSize: (t) => {
5947
5942
  var r, s, i;
@@ -5960,8 +5955,8 @@ class _c {
5960
5955
  }), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new hn({
5961
5956
  persister: new e(this.config.appId, "kv"),
5962
5957
  merge: this._onMergeKv,
5963
- serialize: bc,
5964
- parse: yc,
5958
+ serialize: _c,
5959
+ parse: gc,
5965
5960
  objectSize: () => 0,
5966
5961
  logger: this._log,
5967
5962
  saveThrottleMs: 100,
@@ -5993,7 +5988,7 @@ class _c {
5993
5988
  s.resolve({ status: e, eventId: t });
5994
5989
  else if (r != null && r.type) {
5995
5990
  const { status: o, ...a } = r;
5996
- s.reject(new Mt({
5991
+ s.reject(new Rt({
5997
5992
  // @ts-expect-error body.type is not constant typed
5998
5993
  body: a,
5999
5994
  status: o ?? 0
@@ -6040,7 +6035,7 @@ class _c {
6040
6035
  _handleReceive(e, t) {
6041
6036
  var s, i, o, a, c, u, l;
6042
6037
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
6043
- switch (Sr[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
6038
+ switch (vr[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
6044
6039
  case "init-ok": {
6045
6040
  this._setStatus(Te.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
6046
6041
  for (const y of Object.keys(this._rooms)) {
@@ -6057,14 +6052,14 @@ class _c {
6057
6052
  const { q: y, result: b } = t, g = se(y);
6058
6053
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
6059
6054
  break;
6060
- const m = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = hr(b), T = this.ensureAttrs(), R = tt(T, _, r, this.config.useDateObjects);
6055
+ const m = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = hr(b), T = this.ensureAttrs(), M = tt(T, _, r, this.config.useDateObjects);
6061
6056
  this.querySubs.updateInPlace((O) => {
6062
6057
  if (!O[g]) {
6063
6058
  this._log.info("Missing value in querySubs", { hash: g, q: y });
6064
6059
  return;
6065
6060
  }
6066
6061
  O[g].result = {
6067
- store: R,
6062
+ store: M,
6068
6063
  attrsStore: T,
6069
6064
  pageInfo: m,
6070
6065
  aggregate: S,
@@ -6113,10 +6108,10 @@ class _c {
6113
6108
  T.pendingMutations = m;
6114
6109
  });
6115
6110
  const S = Bt(m.entries()), _ = y.map((T) => {
6116
- var q, E, j, M;
6117
- const R = T["instaql-query"], O = T["instaql-result"], F = se(R), P = hr(O), C = this.ensureAttrs(), G = tt(C, P, r, this.config.useDateObjects), { store: N, attrsStore: B } = this._applyOptimisticUpdates(G, C, S, g), z = (E = (q = O == null ? void 0 : O[0]) == null ? void 0 : q.data) == null ? void 0 : E["page-info"], ee = (M = (j = O == null ? void 0 : O[0]) == null ? void 0 : j.data) == null ? void 0 : M.aggregate;
6111
+ var q, E, j, R;
6112
+ const M = T["instaql-query"], O = T["instaql-result"], F = se(M), P = hr(O), C = this.ensureAttrs(), G = tt(C, P, r, this.config.useDateObjects), { store: N, attrsStore: B } = this._applyOptimisticUpdates(G, C, S, g), z = (E = (q = O == null ? void 0 : O[0]) == null ? void 0 : q.data) == null ? void 0 : E["page-info"], ee = (R = (j = O == null ? void 0 : O[0]) == null ? void 0 : j.data) == null ? void 0 : R.aggregate;
6118
6113
  return {
6119
- q: R,
6114
+ q: M,
6120
6115
  hash: F,
6121
6116
  store: N,
6122
6117
  attrsStore: B,
@@ -6124,10 +6119,10 @@ class _c {
6124
6119
  aggregate: ee
6125
6120
  };
6126
6121
  });
6127
- _.forEach(({ hash: T, q: R, store: O, attrsStore: F, pageInfo: P, aggregate: C }) => {
6122
+ _.forEach(({ hash: T, q: M, store: O, attrsStore: F, pageInfo: P, aggregate: C }) => {
6128
6123
  this.querySubs.updateInPlace((G) => {
6129
6124
  if (!G[T]) {
6130
- this._log.error("Missing value in querySubs", { hash: T, q: R });
6125
+ this._log.error("Missing value in querySubs", { hash: T, q: M });
6131
6126
  return;
6132
6127
  }
6133
6128
  G[T].result = {
@@ -6298,7 +6293,7 @@ class _c {
6298
6293
  i && (i.dfd.reject(s), this._completeQueryOnce(e, t, i.dfd));
6299
6294
  }
6300
6295
  _setAttrs(e) {
6301
- this.attrs = new Me(e.reduce((t, r) => (t[r.id] = r, t), {}), this._linkIndex), this.notifyAttrsSubs();
6296
+ this.attrs = new Re(e.reduce((t, r) => (t[r.id] = r, t), {}), this._linkIndex), this.notifyAttrsSubs();
6302
6297
  }
6303
6298
  _startQuerySub(e, t) {
6304
6299
  const r = J();
@@ -6356,7 +6351,7 @@ class _c {
6356
6351
  if (!this.querySubs)
6357
6352
  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;
6358
6353
  const s = se(e), i = this._startQuerySub(e, s);
6359
- 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")), oc), r.promise;
6354
+ 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")), ac), r.promise;
6360
6355
  }
6361
6356
  _completeQueryOnce(e, t, r) {
6362
6357
  this.queryOnceDfds[t] && (this.queryOnceDfds[t] = this.queryOnceDfds[t].filter((s) => s.dfd !== r), this._cleanupQuery(e, t));
@@ -6423,7 +6418,7 @@ class _c {
6423
6418
  a = !0;
6424
6419
  continue;
6425
6420
  }
6426
- const g = a ? Qo(o, y) : y;
6421
+ const g = a ? Bo(o, y) : y;
6427
6422
  h.push(g);
6428
6423
  }
6429
6424
  return a ? h : l;
@@ -6454,13 +6449,13 @@ class _c {
6454
6449
  r.push(u);
6455
6450
  }
6456
6451
  if (!t.size && !r.length)
6457
- return this.attrs || new Me({}, this._linkIndex);
6452
+ return this.attrs || new Re({}, this._linkIndex);
6458
6453
  const s = { ...((o = this.attrs) == null ? void 0 : o.attrs) || {} };
6459
6454
  for (const a of r)
6460
6455
  s[a.id] = a;
6461
6456
  for (const a of t)
6462
6457
  delete s[a];
6463
- return new Me(s, this._linkIndex);
6458
+ return new Re(s, this._linkIndex);
6464
6459
  }
6465
6460
  /** Runs instaql on a query and a store */
6466
6461
  dataForQuery(e, t = !0) {
@@ -6481,12 +6476,12 @@ class _c {
6481
6476
  const _ = this._applyOptimisticUpdates(f, h, m, g);
6482
6477
  f = _.store, h = _.attrsStore;
6483
6478
  }
6484
- return { data: ss({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
6479
+ return { data: is({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
6485
6480
  }
6486
6481
  _applyOptimisticUpdates(e, t, r, s) {
6487
6482
  for (const [i, o] of r)
6488
6483
  if (!o["tx-id"] || s && o["tx-id"] > s) {
6489
- const a = Wi(e, t, o["tx-steps"]);
6484
+ const a = zi(e, t, o["tx-steps"]);
6490
6485
  e = a.store, t = a.attrsStore;
6491
6486
  }
6492
6487
  return { store: e, attrsStore: t };
@@ -6580,7 +6575,7 @@ class _c {
6580
6575
  }
6581
6576
  _trySend(e, t, r) {
6582
6577
  if (this._transport.isOpen()) {
6583
- switch (Sr[t.op] || this._log.info("[send]", this._transport.id, t.op, {
6578
+ switch (vr[t.op] || this._log.info("[send]", this._transport.id, t.op, {
6584
6579
  "client-event-id": e,
6585
6580
  ...t
6586
6581
  }), t.op) {
@@ -6604,7 +6599,7 @@ class _c {
6604
6599
  return;
6605
6600
  }
6606
6601
  const e = this._transport;
6607
- this._transport = fc({
6602
+ this._transport = hc({
6608
6603
  transportType: this._transportType,
6609
6604
  appId: this.config.appId,
6610
6605
  apiURI: this.config.apiURI,
@@ -6799,10 +6794,22 @@ class _c {
6799
6794
  }
6800
6795
  }
6801
6796
  }
6802
- async syncUserToEndpoint(e) {
6797
+ async setupUserSyncTimer() {
6803
6798
  if (this.config.firstPartyPath)
6804
6799
  try {
6805
- await fetch(this.config.firstPartyPath + "/", {
6800
+ const e = await this.kv.waitForKeyToLoad(Sr), t = e ? new Date(e).getTime() : 0;
6801
+ if (!(!Number.isFinite(t) || Date.now() - t >= fc))
6802
+ return;
6803
+ const { user: s } = await this.getCurrentUser();
6804
+ await this.syncUserToEndpoint(s ?? null);
6805
+ } catch (e) {
6806
+ this._log.error("Error syncing user cookie on startup", e);
6807
+ }
6808
+ }
6809
+ async syncUserToEndpoint(e) {
6810
+ if (this.config.firstPartyPath) {
6811
+ try {
6812
+ const t = await fetch(this.config.firstPartyPath + "/", {
6806
6813
  method: "POST",
6807
6814
  body: JSON.stringify({
6808
6815
  type: "sync-user",
@@ -6813,16 +6820,17 @@ class _c {
6813
6820
  "Content-Type": "application/json"
6814
6821
  }
6815
6822
  });
6823
+ if (!t.ok)
6824
+ throw new Error(`HTTP error! status: ${t.status}`);
6816
6825
  } catch (t) {
6817
6826
  this._log.error("Error syncing user with external endpoint", t);
6818
6827
  }
6828
+ this.kv.updateInPlace((t) => {
6829
+ t[Sr] = (/* @__PURE__ */ new Date()).toISOString();
6830
+ });
6831
+ }
6819
6832
  }
6820
6833
  async updateUser(e) {
6821
- try {
6822
- await this.syncUserToEndpoint(e);
6823
- } catch (r) {
6824
- this._log.error("Error syncing user with external endpoint", r);
6825
- }
6826
6834
  const t = { error: void 0, user: e };
6827
6835
  this._currentUserCached = { isLoading: !1, ...t }, this._dataForQueryCache = {}, this.querySubs.updateInPlace((r) => {
6828
6836
  Object.keys(r).forEach((s) => {
@@ -6836,9 +6844,14 @@ class _c {
6836
6844
  });
6837
6845
  r.clear();
6838
6846
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
6847
+ try {
6848
+ await this.syncUserToEndpoint(e);
6849
+ } catch (r) {
6850
+ this._log.error("Error syncing user with external endpoint", r);
6851
+ }
6839
6852
  }
6840
6853
  sendMagicCode({ email: e }) {
6841
- return Oa({
6854
+ return Ea({
6842
6855
  apiURI: this.config.apiURI,
6843
6856
  appId: this.config.appId,
6844
6857
  email: e
@@ -6846,7 +6859,7 @@ class _c {
6846
6859
  }
6847
6860
  async signInWithMagicCode(e) {
6848
6861
  var i, o;
6849
- const t = await this.getCurrentUser(), r = ((i = t == null ? void 0 : t.user) == null ? void 0 : i.type) === "guest", s = await Ea({
6862
+ const t = await this.getCurrentUser(), r = ((i = t == null ? void 0 : t.user) == null ? void 0 : i.type) === "guest", s = await ka({
6850
6863
  apiURI: this.config.apiURI,
6851
6864
  appId: this.config.appId,
6852
6865
  email: e.email,
@@ -6857,7 +6870,7 @@ class _c {
6857
6870
  return await this.changeCurrentUser(s.user), s;
6858
6871
  }
6859
6872
  async signInWithCustomToken(e) {
6860
- const t = await ka({
6873
+ const t = await Ca({
6861
6874
  apiURI: this.config.apiURI,
6862
6875
  appId: this.config.appId,
6863
6876
  refreshToken: e
@@ -6865,7 +6878,7 @@ class _c {
6865
6878
  return await this.changeCurrentUser(t.user), t;
6866
6879
  }
6867
6880
  async signInAsGuest() {
6868
- const e = await Ca({
6881
+ const e = await Ia({
6869
6882
  apiURI: this.config.apiURI,
6870
6883
  appId: this.config.appId
6871
6884
  });
@@ -6880,7 +6893,7 @@ class _c {
6880
6893
  this._log.info("[auth-invalidate] skipped invalidateToken");
6881
6894
  return;
6882
6895
  }
6883
- Pa({
6896
+ Ma({
6884
6897
  apiURI: this.config.apiURI,
6885
6898
  appId: this.config.appId,
6886
6899
  refreshToken: r
@@ -6945,7 +6958,7 @@ class _c {
6945
6958
  */
6946
6959
  async signInWithIdToken(e) {
6947
6960
  var i;
6948
- const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token, s = await Ia({
6961
+ const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token, s = await Pa({
6949
6962
  apiURI: this.config.apiURI,
6950
6963
  appId: this.config.appId,
6951
6964
  idToken: e.idToken,
@@ -6989,7 +7002,7 @@ class _c {
6989
7002
  getPresence(e, t, r = {}) {
6990
7003
  const s = this._rooms[t], i = this._presence[t];
6991
7004
  return !s || !i || !i.result ? null : {
6992
- ...Da(i.result, r, this._sessionId),
7005
+ ...Ua(i.result, r, this._sessionId),
6993
7006
  isLoading: !s.isConnected,
6994
7007
  error: s.error
6995
7008
  };
@@ -7051,7 +7064,7 @@ class _c {
7051
7064
  }
7052
7065
  _notifyPresenceSub(e, t) {
7053
7066
  const r = this.getPresence("", e, t);
7054
- r && (t.prev && !Ua(r, t.prev) || (t.prev = r, t.cb(r)));
7067
+ r && (t.prev && !La(r, t.prev) || (t.prev = r, t.cb(r)));
7055
7068
  }
7056
7069
  _patchPresencePeers(e, t) {
7057
7070
  var o, a, c;
@@ -7062,13 +7075,13 @@ class _c {
7062
7075
  for (let [l, f, h] of t)
7063
7076
  switch (f) {
7064
7077
  case "+":
7065
- fi(u, l, h);
7078
+ di(u, l, h);
7066
7079
  break;
7067
7080
  case "r":
7068
7081
  Yn(u, l, h);
7069
7082
  break;
7070
7083
  case "-":
7071
- Kr(u, l);
7084
+ qr(u, l);
7072
7085
  break;
7073
7086
  }
7074
7087
  delete u[this._sessionId];
@@ -7135,7 +7148,7 @@ class _c {
7135
7148
  async deleteFile(e) {
7136
7149
  var i;
7137
7150
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
7138
- return await Ma({
7151
+ return await ja({
7139
7152
  apiURI: this.config.apiURI,
7140
7153
  appId: this.config.appId,
7141
7154
  path: e,
@@ -7146,18 +7159,18 @@ class _c {
7146
7159
  // ---------------------------------
7147
7160
  async upload(e, t) {
7148
7161
  var c;
7149
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await ja({
7162
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await $a({
7150
7163
  apiURI: this.config.apiURI,
7151
7164
  appId: this.config.appId,
7152
7165
  fileName: i,
7153
7166
  refreshToken: s
7154
7167
  });
7155
- return await $a(o, t);
7168
+ return await xa(o, t);
7156
7169
  }
7157
7170
  async getDownloadUrl(e) {
7158
7171
  var i;
7159
7172
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
7160
- return await xa({
7173
+ return await Da({
7161
7174
  apiURI: this.config.apiURI,
7162
7175
  appId: this.config.appId,
7163
7176
  path: e,
@@ -7166,9 +7179,9 @@ class _c {
7166
7179
  }
7167
7180
  }
7168
7181
  let _t;
7169
- function mc(n, e) {
7182
+ function Tc(n, e) {
7170
7183
  _t == null || _t.dispose();
7171
- const t = Oc(e), r = Sc(e, a), s = Tc(wc(n));
7184
+ const t = kc(e), r = Ac(e, a), s = vc(Sc(n));
7172
7185
  function i(l) {
7173
7186
  var f;
7174
7187
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && t.isVisible() && a();
@@ -7190,10 +7203,10 @@ function mc(n, e) {
7190
7203
  }
7191
7204
  return u();
7192
7205
  }
7193
- function wc(n) {
7194
- return `${Cn || ls ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
7206
+ function Sc(n) {
7207
+ return `${Cn || fs ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
7195
7208
  }
7196
- function Tc(n) {
7209
+ function vc(n) {
7197
7210
  const e = document.createElement("iframe");
7198
7211
  return e.src = n, e.className = "instant-devtool-iframe", Object.assign(e.style, {
7199
7212
  width: "100%",
@@ -7202,7 +7215,7 @@ function Tc(n) {
7202
7215
  border: "none"
7203
7216
  }), { element: e };
7204
7217
  }
7205
- function Sc(n, e) {
7218
+ function Ac(n, e) {
7206
7219
  const t = `
7207
7220
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
7208
7221
  <rect width="512" height="512" fill="black"/>
@@ -7212,7 +7225,7 @@ function Sc(n, e) {
7212
7225
  return r.innerHTML = t, r.className = "instant-devtool-toggler", Object.assign(r.style, {
7213
7226
  // pos
7214
7227
  position: "fixed",
7215
- ...vc(n.position),
7228
+ ...Oc(n.position),
7216
7229
  height: "32px",
7217
7230
  width: "32px",
7218
7231
  // layout
@@ -7227,7 +7240,7 @@ function Sc(n, e) {
7227
7240
  cursor: "pointer"
7228
7241
  }), r.addEventListener("click", e), { element: r };
7229
7242
  }
7230
- function vc(n) {
7243
+ function Oc(n) {
7231
7244
  switch (n) {
7232
7245
  case "bottom-left":
7233
7246
  return { bottom: "24px", left: "24px" };
@@ -7239,7 +7252,7 @@ function vc(n) {
7239
7252
  return { top: "24px", left: "24px" };
7240
7253
  }
7241
7254
  }
7242
- function Ac(n) {
7255
+ function Ec(n) {
7243
7256
  switch (n) {
7244
7257
  case "bottom-left":
7245
7258
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -7251,11 +7264,11 @@ function Ac(n) {
7251
7264
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
7252
7265
  }
7253
7266
  }
7254
- function Oc(n) {
7267
+ function kc(n) {
7255
7268
  const e = document.createElement("div");
7256
7269
  Object.assign(e.style, {
7257
7270
  position: "fixed",
7258
- ...Ac(n.position),
7271
+ ...Ec(n.position),
7259
7272
  display: "block",
7260
7273
  borderRadius: "4px",
7261
7274
  border: "1px #ccc solid",
@@ -7272,14 +7285,14 @@ function Ze(n, e) {
7272
7285
  if (!n)
7273
7286
  throw new Error("[assertion error] " + e);
7274
7287
  }
7275
- const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]), vr = (n) => {
7288
+ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]), Ar = (n) => {
7276
7289
  const [e, t] = JSON.parse(n);
7277
7290
  return { cursor: e, afterInclusive: t };
7278
- }, Ne = (n, e, t = !1) => `${n}:${rt(e, t)}`, kc = (n) => !!n.endCursor, Cc = (n) => {
7291
+ }, Ne = (n, e, t = !1) => `${n}:${rt(e, t)}`, Ic = (n) => !!n.endCursor, Pc = (n) => {
7279
7292
  var t;
7280
7293
  const e = Array.from(n.values());
7281
7294
  return e.length === 0 ? !1 : ((t = e[e.length - 1]) == null ? void 0 : t.hasMore) || !1;
7282
- }, Ar = (n) => {
7295
+ }, Or = (n) => {
7283
7296
  if (!n)
7284
7297
  return {
7285
7298
  serverCreatedAt: "asc"
@@ -7290,9 +7303,9 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7290
7303
  } : {
7291
7304
  serverCreatedAt: "asc"
7292
7305
  };
7293
- }, ms = (n) => n && Object.keys(n).length > 0 ? n : {
7306
+ }, ws = (n) => n && Object.keys(n).length > 0 ? n : {
7294
7307
  serverCreatedAt: "asc"
7295
- }, Ic = (n, e) => {
7308
+ }, Mc = (n, e) => {
7296
7309
  const t = [
7297
7310
  ...Array.from(e.values()).slice().reverse(),
7298
7311
  ...Array.from(n.values())
@@ -7301,65 +7314,65 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7301
7314
  ...Array.from(n.values()).flatMap((s) => s.data)
7302
7315
  ];
7303
7316
  return { chunks: t, data: r };
7304
- }, Gt = ["bootstrap", "bootstrap", "bootstrap", 1], Pc = (n, e, t, r) => {
7317
+ }, Gt = ["bootstrap", "bootstrap", "bootstrap", 1], Rc = (n, e, t, r) => {
7305
7318
  var B, z, ee, q;
7306
- const { entityName: s, entityQuery: i } = ws(e), o = ((B = i.$) == null ? void 0 : B.limit) || 10, a = s, c = ms((z = i.$) == null ? void 0 : z.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
7319
+ const { entityName: s, entityQuery: i } = Ts(e), o = ((B = i.$) == null ? void 0 : B.limit) || 10, a = s, c = ws((z = i.$) == null ? void 0 : z.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
7307
7320
  let h = !1, y = !0, b = null, g = null;
7308
7321
  const m = (E) => {
7309
7322
  t({ error: E, data: void 0, canLoadNextPage: !1 });
7310
7323
  }, S = () => {
7311
7324
  if (!y)
7312
7325
  return;
7313
- const { chunks: E, data: j } = Ic(u, l);
7326
+ const { chunks: E, data: j } = Mc(u, l);
7314
7327
  t({
7315
7328
  data: { [a]: j },
7316
7329
  // @ts-expect-error hidden debug variable
7317
7330
  chunks: E,
7318
- canLoadNextPage: Cc(u)
7331
+ canLoadNextPage: Pc(u)
7319
7332
  });
7320
7333
  }, _ = (E, j) => {
7321
7334
  u.set(rt(E, j.afterInclusive), j), S();
7322
7335
  }, T = (E, j) => {
7323
7336
  l.set(rt(E), j), C(), S();
7324
- }, R = (E, j) => {
7337
+ }, M = (E, j) => {
7325
7338
  var A, k;
7326
- const { cursor: M } = vr(E), U = f.get(Ne("reverse", M));
7339
+ const { cursor: R } = Ar(E), U = f.get(Ne("reverse", R));
7327
7340
  U == null || U();
7328
7341
  const L = n.subscribeQuery({
7329
7342
  [a]: {
7330
7343
  ...i,
7331
7344
  $: {
7332
- after: M,
7345
+ after: R,
7333
7346
  before: j.endCursor,
7334
7347
  beforeInclusive: !0,
7335
7348
  where: (A = i.$) == null ? void 0 : A.where,
7336
7349
  fields: (k = i.$) == null ? void 0 : k.fields,
7337
- order: Ar(c)
7350
+ order: Or(c)
7338
7351
  }
7339
7352
  }
7340
7353
  }, (K) => {
7341
7354
  if (K.error)
7342
7355
  return m(K.error);
7343
7356
  const H = K.data[a], Y = K.pageInfo[a];
7344
- Ze(H && Y, "Expected query subscription to contain rows and pageInfo"), T(M, {
7357
+ Ze(H && Y, "Expected query subscription to contain rows and pageInfo"), T(R, {
7345
7358
  data: H,
7346
7359
  status: "frozen",
7347
7360
  hasMore: Y.hasNextPage,
7348
7361
  endCursor: Y.endCursor
7349
7362
  });
7350
7363
  }, r);
7351
- f.set(Ne("reverse", M), L);
7364
+ f.set(Ne("reverse", R), L);
7352
7365
  }, O = (E) => {
7353
- var M, U;
7366
+ var R, U;
7354
7367
  const j = n.subscribeQuery({
7355
7368
  [a]: {
7356
7369
  ...i,
7357
7370
  $: {
7358
7371
  limit: o,
7359
7372
  after: E,
7360
- where: (M = i.$) == null ? void 0 : M.where,
7373
+ where: (R = i.$) == null ? void 0 : R.where,
7361
7374
  fields: (U = i.$) == null ? void 0 : U.fields,
7362
- order: Ar(c)
7375
+ order: Or(c)
7363
7376
  }
7364
7377
  }
7365
7378
  }, (L) => {
@@ -7376,7 +7389,7 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7376
7389
  f.set(Ne("reverse", E), j);
7377
7390
  }, F = (E, j = !1) => {
7378
7391
  var U, L;
7379
- const M = n.subscribeQuery({
7392
+ const R = n.subscribeQuery({
7380
7393
  [a]: {
7381
7394
  ...i,
7382
7395
  $: {
@@ -7400,12 +7413,12 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7400
7413
  afterInclusive: j
7401
7414
  });
7402
7415
  }, r);
7403
- f.set(Ne("forward", E, j), M);
7416
+ f.set(Ne("forward", E, j), R);
7404
7417
  }, P = (E, j = !1) => {
7405
7418
  var k, K;
7406
- const M = rt(E, j), U = f.get(Ne("forward", E, j));
7419
+ const R = rt(E, j), U = f.get(Ne("forward", E, j));
7407
7420
  U == null || U();
7408
- const L = u.get(M);
7421
+ const L = u.get(R);
7409
7422
  if (!(L != null && L.endCursor))
7410
7423
  return;
7411
7424
  const A = n.subscribeQuery({
@@ -7438,20 +7451,20 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7438
7451
  const E = Array.from(l.entries()).at(-1);
7439
7452
  if (!E)
7440
7453
  return;
7441
- const [j, M] = E;
7442
- if (!(M != null && M.hasMore) || !kc(M))
7454
+ const [j, R] = E;
7455
+ if (!(R != null && R.hasMore) || !Ic(R))
7443
7456
  return;
7444
- const U = `${j}:${Ec(M.endCursor)}`;
7445
- U != b && (b = U, R(j, M), O(M.endCursor));
7457
+ const U = `${j}:${Cc(R.endCursor)}`;
7458
+ U != b && (b = U, M(j, R), O(R.endCursor));
7446
7459
  }, G = () => {
7447
7460
  const E = Array.from(u.entries()).at(-1);
7448
7461
  if (!E)
7449
7462
  return;
7450
- const [j, M] = E;
7451
- if (!M.endCursor)
7463
+ const [j, R] = E;
7464
+ if (!R.endCursor)
7452
7465
  return;
7453
- const { cursor: U, afterInclusive: L } = vr(j);
7454
- P(U, L), F(M.endCursor);
7466
+ const { cursor: U, afterInclusive: L } = Ar(j);
7467
+ P(U, L), F(R.endCursor);
7455
7468
  };
7456
7469
  return g = n.subscribeQuery({
7457
7470
  [a]: {
@@ -7469,10 +7482,10 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7469
7482
  return;
7470
7483
  if (E.error)
7471
7484
  return m(E.error);
7472
- const j = E.pageInfo[a], M = (L = E == null ? void 0 : E.data) == null ? void 0 : L[a];
7473
- if (Ze(M && j, "Expected rows and pageInfo"), M.length < o) {
7485
+ const j = E.pageInfo[a], R = (L = E == null ? void 0 : E.data) == null ? void 0 : L[a];
7486
+ if (Ze(R && j, "Expected rows and pageInfo"), R.length < o) {
7474
7487
  _(Gt, {
7475
- data: M,
7488
+ data: R,
7476
7489
  status: "pre-bootstrap"
7477
7490
  });
7478
7491
  return;
@@ -7480,7 +7493,7 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7480
7493
  const U = j.startCursor;
7481
7494
  if (!U) {
7482
7495
  _(Gt, {
7483
- data: M,
7496
+ data: R,
7484
7497
  status: "pre-bootstrap"
7485
7498
  });
7486
7499
  return;
@@ -7497,7 +7510,7 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7497
7510
  },
7498
7511
  loadNextPage: G
7499
7512
  };
7500
- }, Or = (n, e, t) => {
7513
+ }, Er = (n, e, t) => {
7501
7514
  var u, l, f, h;
7502
7515
  if (!e)
7503
7516
  return {
@@ -7505,8 +7518,8 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7505
7518
  data: void 0,
7506
7519
  error: void 0
7507
7520
  };
7508
- const { entityName: r, entityQuery: s } = ws(e), i = ((u = s.$) == null ? void 0 : u.limit) || 10, o = ms((l = s.$) == null ? void 0 : l.order);
7509
- let a = e ? Ts({
7521
+ const { entityName: r, entityQuery: s } = Ts(e), i = ((u = s.$) == null ? void 0 : u.limit) || 10, o = ws((l = s.$) == null ? void 0 : l.order);
7522
+ let a = e ? Ss({
7510
7523
  [r]: {
7511
7524
  ...s,
7512
7525
  $: {
@@ -7527,29 +7540,29 @@ const Ec = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7527
7540
  data: (c == null ? void 0 : c.data) || void 0,
7528
7541
  error: void 0
7529
7542
  };
7530
- }, ws = (n) => {
7543
+ }, Ts = (n) => {
7531
7544
  if (Object.keys(n).length !== 1)
7532
7545
  throw new Q("subscribeInfiniteQuery expects exactly one entity");
7533
7546
  const [t, r] = Object.entries(n)[0];
7534
7547
  if (!t || !r)
7535
7548
  throw new Q("No query provided for infinite query");
7536
7549
  return { entityName: t, entityQuery: r };
7537
- }, Rc = {
7550
+ }, jc = {
7538
7551
  apiURI: "https://api.instantdb.com",
7539
7552
  websocketURI: "wss://api.instantdb.com/runtime/session"
7540
7553
  };
7541
- function Mc() {
7554
+ function $c() {
7542
7555
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
7543
7556
  }
7544
- function jc() {
7557
+ function xc() {
7545
7558
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
7546
7559
  }
7547
7560
  function pn(n) {
7548
7561
  const e = n.__adminToken, t = n.__extraDedupeKey;
7549
7562
  return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects + "_" + (t || "");
7550
7563
  }
7551
- const yn = jc(), Er = Mc();
7552
- class $c {
7564
+ const yn = xc(), kr = $c();
7565
+ class Dc {
7553
7566
  constructor(e) {
7554
7567
  p(this, "db");
7555
7568
  /**
@@ -7666,7 +7679,7 @@ class $c {
7666
7679
  this.db = e;
7667
7680
  }
7668
7681
  }
7669
- class xc {
7682
+ class Uc {
7670
7683
  constructor(e) {
7671
7684
  p(this, "db");
7672
7685
  /**
@@ -7724,7 +7737,7 @@ class xc {
7724
7737
  this.db = e;
7725
7738
  }
7726
7739
  }
7727
- class Dc {
7740
+ class Lc {
7728
7741
  constructor(e) {
7729
7742
  p(this, "db");
7730
7743
  /**
@@ -7750,17 +7763,17 @@ class Dc {
7750
7763
  this.db = e;
7751
7764
  }
7752
7765
  }
7753
- function Ts(n) {
7766
+ function Ss(n) {
7754
7767
  return JSON.parse(JSON.stringify(n));
7755
7768
  }
7756
- class Uc {
7769
+ class Fc {
7757
7770
  constructor(e) {
7758
7771
  p(this, "_reactor");
7759
7772
  p(this, "auth");
7760
7773
  p(this, "storage");
7761
7774
  p(this, "streams");
7762
7775
  p(this, "tx", kn());
7763
- this._reactor = e, this.auth = new $c(this._reactor), this.storage = new xc(this._reactor), this.streams = new Dc(this._reactor);
7776
+ this._reactor = e, this.auth = new Dc(this._reactor), this.storage = new Uc(this._reactor), this.streams = new Lc(this._reactor);
7764
7777
  }
7765
7778
  /**
7766
7779
  * Use this to write data! You can create, update, delete, and link objects
@@ -7838,7 +7851,7 @@ class Uc {
7838
7851
  * });
7839
7852
  */
7840
7853
  subscribeInfiniteQuery(e, t, r) {
7841
- return Pc(this, e, t, r);
7854
+ return Rc(this, e, t, r);
7842
7855
  }
7843
7856
  /**
7844
7857
  * Listen for the logged in state. This is useful
@@ -7956,19 +7969,19 @@ class Uc {
7956
7969
  return this._reactor.subscribeTable(e, t);
7957
7970
  }
7958
7971
  }
7959
- function kr(n) {
7972
+ function Cr(n) {
7960
7973
  if (!n)
7961
7974
  return "0";
7962
- const e = Er.get(n);
7975
+ const e = kr.get(n);
7963
7976
  if (e)
7964
7977
  return e;
7965
7978
  const t = se(n);
7966
- return Er.set(n, t), t;
7979
+ return kr.set(n, t), t;
7967
7980
  }
7968
- function Lc(n, e) {
7969
- return kr(n._reactor.config.schema) !== kr(e);
7981
+ function Nc(n, e) {
7982
+ return Cr(n._reactor.config.schema) !== Cr(e);
7970
7983
  }
7971
- function Fc(n, e, t, r, s) {
7984
+ function Kc(n, e, t, r, s) {
7972
7985
  var u;
7973
7986
  const i = {
7974
7987
  ...n,
@@ -7976,15 +7989,15 @@ function Fc(n, e, t, r, s) {
7976
7989
  useDateObjects: n.useDateObjects ?? !1
7977
7990
  }, o = yn[pn(i)];
7978
7991
  if (o)
7979
- return Lc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7980
- const a = new _c({
7981
- ...Rc,
7992
+ return Nc(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7993
+ const a = new wc({
7994
+ ...jc,
7982
7995
  ...i,
7983
7996
  cardinalityInference: !!i.schema
7984
- }, e || as, t || cs, { ...r || {}, "@instantdb/core": ds }, s), c = new Uc(a);
7985
- return yn[pn(i)] = c, Nc(i.appId, i.devtool), c;
7997
+ }, e || cs, t || us, { ...r || {}, "@instantdb/core": hs }, s), c = new Fc(a);
7998
+ return yn[pn(i)] = c, qc(i.appId, i.devtool), c;
7986
7999
  }
7987
- function Nc(n, e) {
8000
+ function qc(n, e) {
7988
8001
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
7989
8002
  return;
7990
8003
  const t = {
@@ -7992,15 +8005,15 @@ function Nc(n, e) {
7992
8005
  allowedHosts: ["localhost"],
7993
8006
  ...typeof e == "object" ? e : {}
7994
8007
  };
7995
- t.allowedHosts.includes(window.location.hostname) && mc(n, t);
8008
+ t.allowedHosts.includes(window.location.hostname) && Tc(n, t);
7996
8009
  }
7997
- const Cr = {
8010
+ const Ir = {
7998
8011
  isLoading: !0,
7999
8012
  data: void 0,
8000
8013
  pageInfo: void 0,
8001
8014
  error: void 0
8002
8015
  };
8003
- function Ir(n) {
8016
+ function Pr(n) {
8004
8017
  return {
8005
8018
  isLoading: !n,
8006
8019
  data: void 0,
@@ -8009,12 +8022,12 @@ function Ir(n) {
8009
8022
  ...n || {}
8010
8023
  };
8011
8024
  }
8012
- function Kc(n, e, t, r) {
8025
+ function Wc(n, e, t, r) {
8013
8026
  e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
8014
- const s = e ? Ts(e) : null, i = se(s), o = ke(
8015
- Ir(n._reactor.getPreviousResult(s))
8016
- ), a = ke(Cr), c = Ae(
8017
- (l) => (o.current = Ir(
8027
+ const s = e ? Ss(e) : null, i = se(s), o = ke(
8028
+ Pr(n._reactor.getPreviousResult(s))
8029
+ ), a = ke(Ir), c = Ae(
8030
+ (l) => (o.current = Pr(
8018
8031
  n._reactor.getPreviousResult(s)
8019
8032
  ), l(), s ? n.subscribeQuery(s, (h) => {
8020
8033
  o.current = {
@@ -8036,7 +8049,7 @@ function Kc(n, e, t, r) {
8036
8049
  c,
8037
8050
  () => o.current,
8038
8051
  () => {
8039
- if (r && a.current === Cr) {
8052
+ if (r && a.current === Ir) {
8040
8053
  const l = r();
8041
8054
  l && (a.current = l);
8042
8055
  }
@@ -8044,24 +8057,24 @@ function Kc(n, e, t, r) {
8044
8057
  }
8045
8058
  ), query: s, queryHash: i };
8046
8059
  }
8047
- const qc = {
8060
+ const zc = {
8048
8061
  error: void 0,
8049
8062
  data: void 0,
8050
8063
  isLoading: !0,
8051
8064
  canLoadNextPage: !1
8052
8065
  };
8053
- function Wc({
8066
+ function Vc({
8054
8067
  core: n,
8055
8068
  query: e,
8056
8069
  opts: t
8057
8070
  }) {
8058
- const r = ke(null), s = se(e), i = se(t), o = Or(n, e, t), a = ke({
8071
+ const r = ke(null), s = se(e), i = se(t), o = Er(n, e, t), a = ke({
8059
8072
  ...o,
8060
8073
  isLoading: !o.data && !o.error
8061
8074
  }), c = Ae(
8062
8075
  (f) => {
8063
8076
  r.current = null;
8064
- const h = Or(n, e, t);
8077
+ const h = Er(n, e, t);
8065
8078
  if (a.current = {
8066
8079
  ...h,
8067
8080
  isLoading: !h.data && !h.error
@@ -8088,7 +8101,7 @@ function Wc({
8088
8101
  ...At(
8089
8102
  c,
8090
8103
  () => a.current,
8091
- () => qc
8104
+ () => zc
8092
8105
  ),
8093
8106
  loadNextPage: () => {
8094
8107
  var f;
@@ -8096,7 +8109,7 @@ function Wc({
8096
8109
  }
8097
8110
  };
8098
8111
  }
8099
- function zc() {
8112
+ function Qc() {
8100
8113
  const n = ke(null);
8101
8114
  je(() => {
8102
8115
  t();
@@ -8109,8 +8122,8 @@ function zc() {
8109
8122
  }
8110
8123
  return { set: e, clear: t };
8111
8124
  }
8112
- const Vc = 1e3;
8113
- function Qc(n, e, t) {
8125
+ const Bc = 1e3;
8126
+ function Gc(n, e, t) {
8114
8127
  const r = ke(t);
8115
8128
  r.current = t, je(() => n.core._reactor.subscribeTopic(
8116
8129
  n.type,
@@ -8121,7 +8134,7 @@ function Qc(n, e, t) {
8121
8134
  }
8122
8135
  ), [n.id, e]);
8123
8136
  }
8124
- function Bc(n, e) {
8137
+ function Hc(n, e) {
8125
8138
  return je(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Ae(
8126
8139
  (r) => {
8127
8140
  n.core._reactor.publishTopic({
@@ -8134,7 +8147,7 @@ function Bc(n, e) {
8134
8147
  [n.id, e]
8135
8148
  );
8136
8149
  }
8137
- function Gc(n, e = {}) {
8150
+ function Jc(n, e = {}) {
8138
8151
  var o, a;
8139
8152
  const [t, r] = Rr(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
8140
8153
  peers: {},
@@ -8159,14 +8172,14 @@ function Gc(n, e = {}) {
8159
8172
  publishPresence: s
8160
8173
  }), [t, s]);
8161
8174
  }
8162
- function Hc(n, e, t) {
8175
+ function Yc(n, e, t) {
8163
8176
  je(
8164
8177
  () => n.core._reactor.joinRoom(n.type, n.id, e),
8165
8178
  [n.id]
8166
8179
  ), je(() => n.core._reactor.publishPresence(n.type, n.id, e), [n.type, n.id, t ?? JSON.stringify(e)]);
8167
8180
  }
8168
- function Jc(n, e, t = {}) {
8169
- const r = zc(), s = Pe.usePresence(n, {
8181
+ function Zc(n, e, t = {}) {
8182
+ const r = Qc(), s = Pe.usePresence(n, {
8170
8183
  keys: [e]
8171
8184
  }), i = Jt(() => {
8172
8185
  const l = n._core._reactor.getPresence(
@@ -8180,7 +8193,7 @@ function Jc(n, e, t = {}) {
8180
8193
  (l) => {
8181
8194
  n.core._reactor.publishPresence(n.type, n.id, {
8182
8195
  [e]: l
8183
- }), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Vc, () => {
8196
+ }), l && ((t == null ? void 0 : t.timeout) === null || (t == null ? void 0 : t.timeout) === 0 || r.set((t == null ? void 0 : t.timeout) ?? Bc, () => {
8184
8197
  n.core._reactor.publishPresence(n.type, n.id, {
8185
8198
  [e]: null
8186
8199
  });
@@ -8203,13 +8216,13 @@ function Jc(n, e, t = {}) {
8203
8216
  };
8204
8217
  }
8205
8218
  const Pe = {
8206
- useTopicEffect: Qc,
8207
- usePublishTopic: Bc,
8208
- usePresence: Gc,
8209
- useSyncPresence: Hc,
8210
- useTypingIndicator: Jc
8219
+ useTopicEffect: Gc,
8220
+ usePublishTopic: Hc,
8221
+ usePresence: Jc,
8222
+ useSyncPresence: Yc,
8223
+ useTypingIndicator: Zc
8211
8224
  };
8212
- class Yc {
8225
+ class Xc {
8213
8226
  constructor(e, t, r) {
8214
8227
  p(this, "core");
8215
8228
  /** @deprecated use `core` instead */
@@ -8296,7 +8309,7 @@ class Yc {
8296
8309
  this.core = e, this._core = this.core, this.type = t, this.id = r;
8297
8310
  }
8298
8311
  }
8299
- const Zc = {
8312
+ const eu = {
8300
8313
  isLoading: !0,
8301
8314
  user: void 0,
8302
8315
  error: void 0
@@ -8400,7 +8413,7 @@ class Ht {
8400
8413
  * auth.user ? { goals: {} } : null,
8401
8414
  * );
8402
8415
  */
8403
- p(this, "useQuery", (e, t) => Kc(this.core, e, t).state);
8416
+ p(this, "useQuery", (e, t) => Wc(this.core, e, t).state);
8404
8417
  /**
8405
8418
  * Listen for the logged in state. This is useful
8406
8419
  * for deciding when to show a login screen.
@@ -8524,7 +8537,7 @@ class Ht {
8524
8537
  * },
8525
8538
  * });
8526
8539
  */
8527
- p(this, "useInfiniteQuery", (e, t) => Wc({
8540
+ p(this, "useInfiniteQuery", (e, t) => Vc({
8528
8541
  core: this.core,
8529
8542
  query: e,
8530
8543
  opts: t
@@ -8557,7 +8570,7 @@ class Ht {
8557
8570
  const t = this.useAuth();
8558
8571
  return t.isLoading || t.error || t.user ? null : /* @__PURE__ */ ht.jsx(ht.Fragment, { children: e });
8559
8572
  });
8560
- this.core = Fc(
8573
+ this.core = Kc(
8561
8574
  e,
8562
8575
  // @ts-expect-error because TS can't resolve subclass statics
8563
8576
  e.Store || this.constructor.Store,
@@ -8581,7 +8594,7 @@ class Ht {
8581
8594
  * const { peers } = db.rooms.usePresence(room);
8582
8595
  */
8583
8596
  room(e = "_defaultRoomType", t = "_defaultRoomId") {
8584
- return new Yc(this.core, e, t);
8597
+ return new Xc(this.core, e, t);
8585
8598
  }
8586
8599
  _useAuth() {
8587
8600
  const e = ke(
@@ -8592,7 +8605,7 @@ class Ht {
8592
8605
  return At(
8593
8606
  t,
8594
8607
  () => e.current,
8595
- () => Zc
8608
+ () => eu
8596
8609
  );
8597
8610
  }
8598
8611
  /**
@@ -8612,5 +8625,5 @@ class Ht {
8612
8625
  p(Ht, "Store"), p(Ht, "NetworkListener"), p(Ht, "EventSourceImpl");
8613
8626
  export {
8614
8627
  Ht as InstantReactAbstractDatabase,
8615
- Kc as useQueryInternal
8628
+ Wc as useQueryInternal
8616
8629
  };