@instantdb/react-common 0.22.68-experimental.drewh-entity-caching.19642167601.1 → 0.22.68

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,5 +1,5 @@
1
- import Or, { useRef as ze, useCallback as de, useSyncExternalStore as $t, useEffect as ge, useMemo as xt, useState as Er } from "react";
2
- var Dt = { exports: {} }, $e = {};
1
+ import Sr, { useRef as ze, useCallback as de, useSyncExternalStore as Rt, useEffect as ge, useMemo as $t, useState as Or } from "react";
2
+ var xt = { exports: {} }, $e = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -9,11 +9,11 @@ var Dt = { exports: {} }, $e = {};
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
- var Fn;
13
- function Ki() {
14
- if (Fn) return $e;
15
- Fn = 1;
16
- var t = Or, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
12
+ var Ln;
13
+ function Ni() {
14
+ if (Ln) return $e;
15
+ Ln = 1;
16
+ var t = Sr, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
17
17
  function o(u, a, d) {
18
18
  var c, f = {}, l = null, p = null;
19
19
  d !== void 0 && (l = "" + d), a.key !== void 0 && (l = "" + a.key), a.ref !== void 0 && (p = a.ref);
@@ -23,10 +23,10 @@ function Ki() {
23
23
  }
24
24
  return $e.Fragment = n, $e.jsx = o, $e.jsxs = o, $e;
25
25
  }
26
- var xe = {}, Nn;
27
- function qi() {
28
- if (Nn) return xe;
29
- Nn = 1;
26
+ var xe = {}, Fn;
27
+ function Ki() {
28
+ if (Fn) return xe;
29
+ Fn = 1;
30
30
  var t = {};
31
31
  /**
32
32
  * @license React
@@ -38,7 +38,7 @@ function qi() {
38
38
  * LICENSE file in the root directory of this source tree.
39
39
  */
40
40
  return t.NODE_ENV !== "production" && function() {
41
- var e = Or, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, g = "@@iterator";
41
+ var e = Sr, n = Symbol.for("react.element"), r = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), u = Symbol.for("react.provider"), a = Symbol.for("react.context"), d = Symbol.for("react.forward_ref"), c = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), l = Symbol.for("react.memo"), p = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), b = Symbol.iterator, g = "@@iterator";
42
42
  function m(h) {
43
43
  if (h === null || typeof h != "object")
44
44
  return null;
@@ -127,18 +127,18 @@ function qi() {
127
127
  }
128
128
  return null;
129
129
  }
130
- var le = Object.assign, Me = 0, bn, _n, gn, Tn, mn, wn, vn;
131
- function Sn() {
130
+ var le = Object.assign, Me = 0, yn, bn, _n, gn, Tn, mn, wn;
131
+ function vn() {
132
132
  }
133
- Sn.__reactDisabledLog = !0;
134
- function pi() {
133
+ vn.__reactDisabledLog = !0;
134
+ function hi() {
135
135
  {
136
136
  if (Me === 0) {
137
- bn = console.log, _n = console.info, gn = console.warn, Tn = console.error, mn = console.group, wn = console.groupCollapsed, vn = console.groupEnd;
137
+ yn = console.log, bn = console.info, _n = console.warn, gn = console.error, Tn = console.group, mn = console.groupCollapsed, wn = console.groupEnd;
138
138
  var h = {
139
139
  configurable: !0,
140
140
  enumerable: !0,
141
- value: Sn,
141
+ value: vn,
142
142
  writable: !0
143
143
  };
144
144
  Object.defineProperties(console, {
@@ -154,7 +154,7 @@ function qi() {
154
154
  Me++;
155
155
  }
156
156
  }
157
- function yi() {
157
+ function pi() {
158
158
  {
159
159
  if (Me--, Me === 0) {
160
160
  var h = {
@@ -164,25 +164,25 @@ function qi() {
164
164
  };
165
165
  Object.defineProperties(console, {
166
166
  log: le({}, h, {
167
- value: bn
167
+ value: yn
168
168
  }),
169
169
  info: le({}, h, {
170
- value: _n
170
+ value: bn
171
171
  }),
172
172
  warn: le({}, h, {
173
- value: gn
173
+ value: _n
174
174
  }),
175
175
  error: le({}, h, {
176
- value: Tn
176
+ value: gn
177
177
  }),
178
178
  group: le({}, h, {
179
- value: mn
179
+ value: Tn
180
180
  }),
181
181
  groupCollapsed: le({}, h, {
182
- value: wn
182
+ value: mn
183
183
  }),
184
184
  groupEnd: le({}, h, {
185
- value: vn
185
+ value: wn
186
186
  })
187
187
  });
188
188
  }
@@ -205,10 +205,10 @@ function qi() {
205
205
  }
206
206
  var wt = !1, Je;
207
207
  {
208
- var bi = typeof WeakMap == "function" ? WeakMap : Map;
209
- Je = new bi();
208
+ var yi = typeof WeakMap == "function" ? WeakMap : Map;
209
+ Je = new yi();
210
210
  }
211
- function On(h, _) {
211
+ function Sn(h, _) {
212
212
  if (!h || wt)
213
213
  return "";
214
214
  {
@@ -221,7 +221,7 @@ function qi() {
221
221
  var C = Error.prepareStackTrace;
222
222
  Error.prepareStackTrace = void 0;
223
223
  var P;
224
- P = Tt.current, Tt.current = null, pi();
224
+ P = Tt.current, Tt.current = null, hi();
225
225
  try {
226
226
  if (_) {
227
227
  var k = function() {
@@ -274,15 +274,15 @@ function qi() {
274
274
  }
275
275
  }
276
276
  } finally {
277
- wt = !1, Tt.current = P, yi(), Error.prepareStackTrace = C;
277
+ wt = !1, Tt.current = P, pi(), Error.prepareStackTrace = C;
278
278
  }
279
279
  var ve = h ? h.displayName || h.name : "", he = ve ? Ye(ve) : "";
280
280
  return typeof h == "function" && Je.set(h, he), he;
281
281
  }
282
- function _i(h, _, w) {
283
- return On(h, !1);
282
+ function bi(h, _, w) {
283
+ return Sn(h, !1);
284
284
  }
285
- function gi(h) {
285
+ function _i(h) {
286
286
  var _ = h.prototype;
287
287
  return !!(_ && _.isReactComponent);
288
288
  }
@@ -290,7 +290,7 @@ function qi() {
290
290
  if (h == null)
291
291
  return "";
292
292
  if (typeof h == "function")
293
- return On(h, gi(h));
293
+ return Sn(h, _i(h));
294
294
  if (typeof h == "string")
295
295
  return Ye(h);
296
296
  switch (h) {
@@ -302,7 +302,7 @@ function qi() {
302
302
  if (typeof h == "object")
303
303
  switch (h.$$typeof) {
304
304
  case d:
305
- return _i(h.render);
305
+ return bi(h.render);
306
306
  case l:
307
307
  return Ze(h.type, _, w);
308
308
  case p: {
@@ -315,15 +315,15 @@ function qi() {
315
315
  }
316
316
  return "";
317
317
  }
318
- var Re = Object.prototype.hasOwnProperty, En = {}, An = T.ReactDebugCurrentFrame;
318
+ var Re = Object.prototype.hasOwnProperty, On = {}, En = T.ReactDebugCurrentFrame;
319
319
  function Xe(h) {
320
320
  if (h) {
321
321
  var _ = h._owner, w = Ze(h.type, h._source, _ ? _.type : null);
322
- An.setExtraStackFrame(w);
322
+ En.setExtraStackFrame(w);
323
323
  } else
324
- An.setExtraStackFrame(null);
324
+ En.setExtraStackFrame(null);
325
325
  }
326
- function Ti(h, _, w, O, C) {
326
+ function gi(h, _, w, O, C) {
327
327
  {
328
328
  var P = Function.call.bind(Re);
329
329
  for (var k in h)
@@ -338,41 +338,41 @@ function qi() {
338
338
  } catch ($) {
339
339
  E = $;
340
340
  }
341
- E && !(E instanceof Error) && (Xe(C), v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", O || "React class", w, k, typeof E), Xe(null)), E instanceof Error && !(E.message in En) && (En[E.message] = !0, Xe(C), v("Failed %s type: %s", w, E.message), Xe(null));
341
+ E && !(E instanceof Error) && (Xe(C), v("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", O || "React class", w, k, typeof E), Xe(null)), E instanceof Error && !(E.message in On) && (On[E.message] = !0, Xe(C), v("Failed %s type: %s", w, E.message), Xe(null));
342
342
  }
343
343
  }
344
344
  }
345
- var mi = Array.isArray;
345
+ var Ti = Array.isArray;
346
346
  function vt(h) {
347
- return mi(h);
347
+ return Ti(h);
348
348
  }
349
- function wi(h) {
349
+ function mi(h) {
350
350
  {
351
351
  var _ = typeof Symbol == "function" && Symbol.toStringTag, w = _ && h[Symbol.toStringTag] || h.constructor.name || "Object";
352
352
  return w;
353
353
  }
354
354
  }
355
- function vi(h) {
355
+ function wi(h) {
356
356
  try {
357
- return kn(h), !1;
357
+ return An(h), !1;
358
358
  } catch {
359
359
  return !0;
360
360
  }
361
361
  }
362
- function kn(h) {
362
+ function An(h) {
363
363
  return "" + h;
364
364
  }
365
- function jn(h) {
366
- if (vi(h))
367
- return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", wi(h)), kn(h);
365
+ function kn(h) {
366
+ if (wi(h))
367
+ return v("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", mi(h)), An(h);
368
368
  }
369
- var Cn = T.ReactCurrentOwner, Si = {
369
+ var jn = T.ReactCurrentOwner, vi = {
370
370
  key: !0,
371
371
  ref: !0,
372
372
  __self: !0,
373
373
  __source: !0
374
- }, Pn, In;
375
- function Oi(h) {
374
+ }, Cn, Pn;
375
+ function Si(h) {
376
376
  if (Re.call(h, "ref")) {
377
377
  var _ = Object.getOwnPropertyDescriptor(h, "ref").get;
378
378
  if (_ && _.isReactWarning)
@@ -380,7 +380,7 @@ function qi() {
380
380
  }
381
381
  return h.ref !== void 0;
382
382
  }
383
- function Ei(h) {
383
+ function Oi(h) {
384
384
  if (Re.call(h, "key")) {
385
385
  var _ = Object.getOwnPropertyDescriptor(h, "key").get;
386
386
  if (_ && _.isReactWarning)
@@ -388,13 +388,13 @@ function qi() {
388
388
  }
389
389
  return h.key !== void 0;
390
390
  }
391
- function Ai(h, _) {
392
- typeof h.ref == "string" && Cn.current;
391
+ function Ei(h, _) {
392
+ typeof h.ref == "string" && jn.current;
393
393
  }
394
- function ki(h, _) {
394
+ function Ai(h, _) {
395
395
  {
396
396
  var w = function() {
397
- Pn || (Pn = !0, v("%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)", _));
397
+ Cn || (Cn = !0, v("%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)", _));
398
398
  };
399
399
  w.isReactWarning = !0, Object.defineProperty(h, "key", {
400
400
  get: w,
@@ -402,10 +402,10 @@ function qi() {
402
402
  });
403
403
  }
404
404
  }
405
- function ji(h, _) {
405
+ function ki(h, _) {
406
406
  {
407
407
  var w = function() {
408
- In || (In = !0, v("%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)", _));
408
+ Pn || (Pn = !0, v("%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)", _));
409
409
  };
410
410
  w.isReactWarning = !0, Object.defineProperty(h, "ref", {
411
411
  get: w,
@@ -413,7 +413,7 @@ function qi() {
413
413
  });
414
414
  }
415
415
  }
416
- var Ci = function(h, _, w, O, C, P, k) {
416
+ var ji = function(h, _, w, O, C, P, k) {
417
417
  var E = {
418
418
  // This tag allows us to uniquely identify this as a React Element
419
419
  $$typeof: n,
@@ -442,12 +442,12 @@ function qi() {
442
442
  value: C
443
443
  }), Object.freeze && (Object.freeze(E.props), Object.freeze(E)), E;
444
444
  };
445
- function Pi(h, _, w, O, C) {
445
+ function Ci(h, _, w, O, C) {
446
446
  {
447
447
  var P, k = {}, E = null, z = null;
448
- w !== void 0 && (jn(w), E = "" + w), Ei(_) && (jn(_.key), E = "" + _.key), Oi(_) && (z = _.ref, Ai(_, C));
448
+ w !== void 0 && (kn(w), E = "" + w), Oi(_) && (kn(_.key), E = "" + _.key), Si(_) && (z = _.ref, Ei(_, C));
449
449
  for (P in _)
450
- Re.call(_, P) && !Si.hasOwnProperty(P) && (k[P] = _[P]);
450
+ Re.call(_, P) && !vi.hasOwnProperty(P) && (k[P] = _[P]);
451
451
  if (h && h.defaultProps) {
452
452
  var $ = h.defaultProps;
453
453
  for (P in $)
@@ -455,25 +455,25 @@ function qi() {
455
455
  }
456
456
  if (E || z) {
457
457
  var D = typeof h == "function" ? h.displayName || h.name || "Unknown" : h;
458
- E && ki(k, D), z && ji(k, D);
458
+ E && Ai(k, D), z && ki(k, D);
459
459
  }
460
- return Ci(h, E, z, C, O, Cn.current, k);
460
+ return ji(h, E, z, C, O, jn.current, k);
461
461
  }
462
462
  }
463
- var St = T.ReactCurrentOwner, Mn = T.ReactDebugCurrentFrame;
463
+ var St = T.ReactCurrentOwner, In = T.ReactDebugCurrentFrame;
464
464
  function we(h) {
465
465
  if (h) {
466
466
  var _ = h._owner, w = Ze(h.type, h._source, _ ? _.type : null);
467
- Mn.setExtraStackFrame(w);
467
+ In.setExtraStackFrame(w);
468
468
  } else
469
- Mn.setExtraStackFrame(null);
469
+ In.setExtraStackFrame(null);
470
470
  }
471
471
  var Ot;
472
472
  Ot = !1;
473
473
  function Et(h) {
474
474
  return typeof h == "object" && h !== null && h.$$typeof === n;
475
475
  }
476
- function Rn() {
476
+ function Mn() {
477
477
  {
478
478
  if (St.current) {
479
479
  var h = ne(St.current.type);
@@ -485,13 +485,13 @@ Check the render method of \`` + h + "`.";
485
485
  return "";
486
486
  }
487
487
  }
488
- function Ii(h) {
488
+ function Pi(h) {
489
489
  return "";
490
490
  }
491
- var $n = {};
492
- function Mi(h) {
491
+ var Rn = {};
492
+ function Ii(h) {
493
493
  {
494
- var _ = Rn();
494
+ var _ = Mn();
495
495
  if (!_) {
496
496
  var w = typeof h == "string" ? h : h.displayName || h.name;
497
497
  w && (_ = `
@@ -501,27 +501,27 @@ Check the top-level render call using <` + w + ">.");
501
501
  return _;
502
502
  }
503
503
  }
504
- function xn(h, _) {
504
+ function $n(h, _) {
505
505
  {
506
506
  if (!h._store || h._store.validated || h.key != null)
507
507
  return;
508
508
  h._store.validated = !0;
509
- var w = Mi(_);
510
- if ($n[w])
509
+ var w = Ii(_);
510
+ if (Rn[w])
511
511
  return;
512
- $n[w] = !0;
512
+ Rn[w] = !0;
513
513
  var O = "";
514
514
  h && h._owner && h._owner !== St.current && (O = " It was passed a child from " + ne(h._owner.type) + "."), we(h), v('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', w, O), we(null);
515
515
  }
516
516
  }
517
- function Dn(h, _) {
517
+ function xn(h, _) {
518
518
  {
519
519
  if (typeof h != "object")
520
520
  return;
521
521
  if (vt(h))
522
522
  for (var w = 0; w < h.length; w++) {
523
523
  var O = h[w];
524
- Et(O) && xn(O, _);
524
+ Et(O) && $n(O, _);
525
525
  }
526
526
  else if (Et(h))
527
527
  h._store && (h._store.validated = !0);
@@ -529,11 +529,11 @@ Check the top-level render call using <` + w + ">.");
529
529
  var C = m(h);
530
530
  if (typeof C == "function" && C !== h.entries)
531
531
  for (var P = C.call(h), k; !(k = P.next()).done; )
532
- Et(k.value) && xn(k.value, _);
532
+ Et(k.value) && $n(k.value, _);
533
533
  }
534
534
  }
535
535
  }
536
- function Ri(h) {
536
+ function Mi(h) {
537
537
  {
538
538
  var _ = h.type;
539
539
  if (_ == null || typeof _ == "string")
@@ -549,7 +549,7 @@ Check the top-level render call using <` + w + ">.");
549
549
  return;
550
550
  if (w) {
551
551
  var O = ne(_);
552
- Ti(w, h.props, "prop", O, h);
552
+ gi(w, h.props, "prop", O, h);
553
553
  } else if (_.PropTypes !== void 0 && !Ot) {
554
554
  Ot = !0;
555
555
  var C = ne(_);
@@ -558,7 +558,7 @@ Check the top-level render call using <` + w + ">.");
558
558
  typeof _.getDefaultProps == "function" && !_.getDefaultProps.isReactClassApproved && v("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
559
559
  }
560
560
  }
561
- function $i(h) {
561
+ function Ri(h) {
562
562
  {
563
563
  for (var _ = Object.keys(h.props), w = 0; w < _.length; w++) {
564
564
  var O = _[w];
@@ -570,19 +570,19 @@ Check the top-level render call using <` + w + ">.");
570
570
  h.ref !== null && (we(h), v("Invalid attribute `ref` supplied to `React.Fragment`."), we(null));
571
571
  }
572
572
  }
573
- var Un = {};
574
- function Ln(h, _, w, O, C, P) {
573
+ var Dn = {};
574
+ function Un(h, _, w, O, C, P) {
575
575
  {
576
576
  var k = _t(h);
577
577
  if (!k) {
578
578
  var E = "";
579
579
  (h === void 0 || typeof h == "object" && h !== null && Object.keys(h).length === 0) && (E += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
580
- var z = Ii();
581
- z ? E += z : E += Rn();
580
+ var z = Pi();
581
+ z ? E += z : E += Mn();
582
582
  var $;
583
583
  h === null ? $ = "null" : vt(h) ? $ = "array" : h !== void 0 && h.$$typeof === n ? ($ = "<" + (ne(h.type) || "Unknown") + " />", E = " Did you accidentally export a JSX literal instead of a component?") : $ = typeof h, v("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", $, E);
584
584
  }
585
- var D = Pi(h, _, w, C, P);
585
+ var D = Ci(h, _, w, C, P);
586
586
  if (D == null)
587
587
  return D;
588
588
  if (k) {
@@ -591,43 +591,43 @@ Check the top-level render call using <` + w + ">.");
591
591
  if (O)
592
592
  if (vt(J)) {
593
593
  for (var ve = 0; ve < J.length; ve++)
594
- Dn(J[ve], h);
594
+ xn(J[ve], h);
595
595
  Object.freeze && Object.freeze(J);
596
596
  } else
597
597
  v("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
598
598
  else
599
- Dn(J, h);
599
+ xn(J, h);
600
600
  }
601
601
  if (Re.call(_, "key")) {
602
- var he = ne(h), W = Object.keys(_).filter(function(Ni) {
603
- return Ni !== "key";
602
+ var he = ne(h), W = Object.keys(_).filter(function(Fi) {
603
+ return Fi !== "key";
604
604
  }), At = W.length > 0 ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}";
605
- if (!Un[he + At]) {
606
- var Fi = W.length > 0 ? "{" + W.join(": ..., ") + ": ...}" : "{}";
605
+ if (!Dn[he + At]) {
606
+ var Li = W.length > 0 ? "{" + W.join(": ..., ") + ": ...}" : "{}";
607
607
  v(`A props object containing a "key" prop is being spread into JSX:
608
608
  let props = %s;
609
609
  <%s {...props} />
610
610
  React keys must be passed directly to JSX without using spread:
611
611
  let props = %s;
612
- <%s key={someKey} {...props} />`, At, he, Fi, he), Un[he + At] = !0;
612
+ <%s key={someKey} {...props} />`, At, he, Li, he), Dn[he + At] = !0;
613
613
  }
614
614
  }
615
- return h === i ? $i(D) : Ri(D), D;
615
+ return h === i ? Ri(D) : Mi(D), D;
616
616
  }
617
617
  }
618
- function xi(h, _, w) {
619
- return Ln(h, _, w, !0);
618
+ function $i(h, _, w) {
619
+ return Un(h, _, w, !0);
620
620
  }
621
- function Di(h, _, w) {
622
- return Ln(h, _, w, !1);
621
+ function xi(h, _, w) {
622
+ return Un(h, _, w, !1);
623
623
  }
624
- var Ui = Di, Li = xi;
625
- xe.Fragment = i, xe.jsx = Ui, xe.jsxs = Li;
624
+ var Di = xi, Ui = $i;
625
+ xe.Fragment = i, xe.jsx = Di, xe.jsxs = Ui;
626
626
  }(), xe;
627
627
  }
628
- var zi = {};
629
- zi.NODE_ENV === "production" ? Dt.exports = Ki() : Dt.exports = qi();
630
- var et = Dt.exports;
628
+ var qi = {};
629
+ qi.NODE_ENV === "production" ? xt.exports = Ni() : xt.exports = Ki();
630
+ var et = xt.exports;
631
631
  function N(t) {
632
632
  if (typeof t == "number")
633
633
  return (Math.abs(t * 2654435761) >>> 0).toString(16);
@@ -670,14 +670,14 @@ const x = {
670
670
  Remove: "remove",
671
671
  Replace: "replace",
672
672
  Add: "add"
673
- }, Ar = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Vi = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), st = Symbol.iterator, Y = {
673
+ }, Er = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), zi = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), st = Symbol.iterator, Y = {
674
674
  mutable: "mutable",
675
675
  immutable: "immutable"
676
- }, tn = {};
676
+ }, en = {};
677
677
  function Ne(t, e) {
678
678
  return t instanceof Map ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
679
679
  }
680
- function Kn(t, e) {
680
+ function Nn(t, e) {
681
681
  if (e in t) {
682
682
  let n = Reflect.getPrototypeOf(t);
683
683
  for (; n; ) {
@@ -688,10 +688,10 @@ function Kn(t, e) {
688
688
  }
689
689
  }
690
690
  }
691
- function nn(t) {
691
+ function tn(t) {
692
692
  return Object.getPrototypeOf(t) === Set.prototype;
693
693
  }
694
- function rn(t) {
694
+ function nn(t) {
695
695
  return Object.getPrototypeOf(t) === Map.prototype;
696
696
  }
697
697
  function H(t) {
@@ -702,9 +702,9 @@ function Te(t) {
702
702
  return !!A(t);
703
703
  }
704
704
  function A(t) {
705
- return typeof t != "object" ? null : t == null ? void 0 : t[Ar];
705
+ return typeof t != "object" ? null : t == null ? void 0 : t[Er];
706
706
  }
707
- function sn(t) {
707
+ function rn(t) {
708
708
  var e;
709
709
  const n = A(t);
710
710
  return n ? (e = n.copy) !== null && e !== void 0 ? e : n.original : t;
@@ -715,7 +715,7 @@ function ee(t, e) {
715
715
  let n;
716
716
  return Object.getPrototypeOf(t) === Object.prototype || Array.isArray(t) || t instanceof Map || t instanceof Set || !!(e != null && e.mark) && ((n = e.mark(t, Y)) === Y.immutable || typeof n == "function");
717
717
  }
718
- function kr(t, e = []) {
718
+ function Ar(t, e = []) {
719
719
  if (Object.hasOwnProperty.call(t, "key")) {
720
720
  const n = t.parent.copy, r = A(ce(n, t.key));
721
721
  if (r !== null && (r == null ? void 0 : r.original) !== t.original)
@@ -726,10 +726,10 @@ function kr(t, e = []) {
726
726
  e.push(s);
727
727
  }
728
728
  if (t.parent)
729
- return kr(t.parent, e);
729
+ return Ar(t.parent, e);
730
730
  e.reverse();
731
731
  try {
732
- Wi(t.copy, e);
732
+ Vi(t.copy, e);
733
733
  } catch {
734
734
  return null;
735
735
  }
@@ -751,7 +751,7 @@ function kt(t, e) {
751
751
  function ae(t, e) {
752
752
  return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
753
753
  }
754
- function Ut(t) {
754
+ function Dt(t) {
755
755
  if (t)
756
756
  for (; t.finalities.revoke.length > 0; )
757
757
  t.finalities.revoke.pop()();
@@ -762,7 +762,7 @@ function be(t, e) {
762
762
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
763
763
  }).join("/");
764
764
  }
765
- function Wi(t, e) {
765
+ function Vi(t, e) {
766
766
  for (let n = 0; n < e.length - 1; n += 1) {
767
767
  const r = e[n];
768
768
  if (t = ce(me(t) === 3 ? Array.from(t) : t, r), typeof t != "object")
@@ -770,7 +770,7 @@ function Wi(t, e) {
770
770
  }
771
771
  return t;
772
772
  }
773
- function Bi(t) {
773
+ function Wi(t) {
774
774
  const e = Object.create(Object.getPrototypeOf(t));
775
775
  return Reflect.ownKeys(t).forEach((n) => {
776
776
  let r = Reflect.getOwnPropertyDescriptor(t, n);
@@ -786,26 +786,26 @@ function Bi(t) {
786
786
  }), Reflect.defineProperty(e, n, r);
787
787
  }), e;
788
788
  }
789
- const Gi = Object.prototype.propertyIsEnumerable;
790
- function jr(t, e) {
789
+ const Bi = Object.prototype.propertyIsEnumerable;
790
+ function kr(t, e) {
791
791
  let n;
792
792
  if (Array.isArray(t))
793
793
  return Array.prototype.concat.call(t);
794
794
  if (t instanceof Set) {
795
- if (!nn(t)) {
795
+ if (!tn(t)) {
796
796
  const r = Object.getPrototypeOf(t).constructor;
797
797
  return new r(t.values());
798
798
  }
799
799
  return Set.prototype.difference ? Set.prototype.difference.call(t, /* @__PURE__ */ new Set()) : new Set(t.values());
800
800
  } else if (t instanceof Map) {
801
- if (!rn(t)) {
801
+ if (!nn(t)) {
802
802
  const r = Object.getPrototypeOf(t).constructor;
803
803
  return new r(t);
804
804
  }
805
805
  return new Map(t);
806
806
  } else if (e != null && e.mark && (n = e.mark(t, Y), n !== void 0) && n !== Y.mutable) {
807
807
  if (n === Y.immutable)
808
- return Bi(t);
808
+ return Wi(t);
809
809
  if (typeof n == "function") {
810
810
  if (e.enablePatches || e.enableAutoFreeze)
811
811
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -817,17 +817,17 @@ function jr(t, e) {
817
817
  return Object.keys(t).forEach((i) => {
818
818
  r[i] = t[i];
819
819
  }), Object.getOwnPropertySymbols(t).forEach((i) => {
820
- Gi.call(t, i) && (r[i] = t[i]);
820
+ Bi.call(t, i) && (r[i] = t[i]);
821
821
  }), r;
822
822
  } else
823
823
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
824
824
  }
825
825
  function V(t) {
826
- t.copy || (t.copy = jr(t.original, t.options));
826
+ t.copy || (t.copy = kr(t.original, t.options));
827
827
  }
828
828
  function Ue(t) {
829
829
  if (!ee(t))
830
- return sn(t);
830
+ return rn(t);
831
831
  if (Array.isArray(t))
832
832
  return t.map(Ue);
833
833
  if (t instanceof Map) {
@@ -835,7 +835,7 @@ function Ue(t) {
835
835
  r,
836
836
  Ue(i)
837
837
  ]);
838
- if (!rn(t)) {
838
+ if (!nn(t)) {
839
839
  const r = Object.getPrototypeOf(t).constructor;
840
840
  return new r(n);
841
841
  }
@@ -843,7 +843,7 @@ function Ue(t) {
843
843
  }
844
844
  if (t instanceof Set) {
845
845
  const n = Array.from(t).map(Ue);
846
- if (!nn(t)) {
846
+ if (!tn(t)) {
847
847
  const r = Object.getPrototypeOf(t).constructor;
848
848
  return new r(n);
849
849
  }
@@ -861,7 +861,7 @@ function ie(t) {
861
861
  var e;
862
862
  t.assignedMap = (e = t.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), t.operated || (t.operated = !0, t.parent && ie(t.parent));
863
863
  }
864
- function qn() {
864
+ function Kn() {
865
865
  throw new Error("Cannot modify frozen object");
866
866
  }
867
867
  function Se(t, e, n, r, i) {
@@ -889,12 +889,12 @@ function Se(t, e, n, r, i) {
889
889
  case 2:
890
890
  for (const [u, a] of t)
891
891
  Se(u, u, n, r, i), Se(a, u, n, r, i);
892
- t.set = t.clear = t.delete = qn;
892
+ t.set = t.clear = t.delete = Kn;
893
893
  break;
894
894
  case 3:
895
895
  for (const u of t)
896
896
  Se(u, u, n, r, i);
897
- t.add = t.clear = t.delete = qn;
897
+ t.add = t.clear = t.delete = Kn;
898
898
  break;
899
899
  case 1:
900
900
  Object.freeze(t);
@@ -910,7 +910,7 @@ function Se(t, e, n, r, i) {
910
910
  }
911
911
  r.pop(), i.pop();
912
912
  }
913
- function on(t, e) {
913
+ function sn(t, e) {
914
914
  const n = me(t);
915
915
  if (n === 0)
916
916
  Reflect.ownKeys(t).forEach((r) => {
@@ -923,11 +923,11 @@ function on(t, e) {
923
923
  } else
924
924
  t.forEach((r, i) => e(i, r, t));
925
925
  }
926
- function Cr(t, e, n) {
926
+ function jr(t, e, n) {
927
927
  if (Te(t) || !ee(t, n) || e.has(t) || Object.isFrozen(t))
928
928
  return;
929
929
  const r = t instanceof Set, i = r ? /* @__PURE__ */ new Map() : void 0;
930
- if (e.add(t), on(t, (s, o) => {
930
+ if (e.add(t), sn(t, (s, o) => {
931
931
  var u;
932
932
  if (Te(o)) {
933
933
  const a = A(o);
@@ -935,7 +935,7 @@ function Cr(t, e, n) {
935
935
  const d = !((u = a.assignedMap) === null || u === void 0) && u.size || a.operated ? a.copy : a.original;
936
936
  We(r ? i : t, s, d);
937
937
  } else
938
- Cr(o, e, n);
938
+ jr(o, e, n);
939
939
  }), i) {
940
940
  const s = t, o = Array.from(s);
941
941
  s.clear(), o.forEach((u) => {
@@ -943,39 +943,39 @@ function Cr(t, e, n) {
943
943
  });
944
944
  }
945
945
  }
946
- function Qi(t, e) {
946
+ function Gi(t, e) {
947
947
  const n = t.type === 3 ? t.setMap : t.copy;
948
- t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Cr(ce(n, e), t.finalities.handledSet, t.options);
948
+ t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && jr(ce(n, e), t.finalities.handledSet, t.options);
949
949
  }
950
- function Lt(t) {
950
+ function Ut(t) {
951
951
  t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
952
- t.copy.add(sn(e));
952
+ t.copy.add(rn(e));
953
953
  }));
954
954
  }
955
- function Ft(t, e, n, r) {
955
+ function Lt(t, e, n, r) {
956
956
  if (t.operated && t.assignedMap && t.assignedMap.size > 0 && !t.finalized) {
957
957
  if (n && r) {
958
- const s = kr(t);
958
+ const s = Ar(t);
959
959
  s && e(t, s, n, r);
960
960
  }
961
961
  t.finalized = !0;
962
962
  }
963
963
  }
964
- function un(t, e, n, r) {
964
+ function on(t, e, n, r) {
965
965
  const i = A(n);
966
966
  i && (i.callbacks || (i.callbacks = []), i.callbacks.push((s, o) => {
967
967
  var u;
968
968
  const a = t.type === 3 ? t.setMap : t.copy;
969
969
  if (ae(ce(a, e), n)) {
970
970
  let d = i.original;
971
- i.copy && (d = i.copy), Lt(t), Ft(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), We(a, e, d);
971
+ i.copy && (d = i.copy), Ut(t), Lt(t, r, s, o), t.options.enableAutoFreeze && (t.options.updatedValues = (u = t.options.updatedValues) !== null && u !== void 0 ? u : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(d, i.original)), We(a, e, d);
972
972
  }
973
973
  }), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), ee(n, t.options) && t.finalities.draft.push(() => {
974
974
  const s = t.type === 3 ? t.setMap : t.copy;
975
- ae(ce(s, e), n) && Qi(t, e);
975
+ ae(ce(s, e), n) && Gi(t, e);
976
976
  });
977
977
  }
978
- function Hi(t, e, n, r, i) {
978
+ function Qi(t, e, n, r, i) {
979
979
  let { original: s, assignedMap: o, options: u } = t, a = t.copy;
980
980
  a.length < s.length && ([s, a] = [a, s], [n, r] = [r, n]);
981
981
  for (let d = 0; d < s.length; d += 1)
@@ -1021,7 +1021,7 @@ function Hi(t, e, n, r, i) {
1021
1021
  }
1022
1022
  }
1023
1023
  }
1024
- function Yi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1024
+ function Hi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1025
1025
  n.forEach((u, a) => {
1026
1026
  const d = ce(t, a), c = ot(ce(e, a)), f = u ? Ne(t, a) ? x.Replace : x.Add : x.Remove;
1027
1027
  if (ae(d, c) && f === x.Replace)
@@ -1030,7 +1030,7 @@ function Yi({ original: t, copy: e, assignedMap: n }, r, i, s, o) {
1030
1030
  i.push(f === x.Remove ? { op: f, path: p } : { op: f, path: p, value: c }), s.push(f === x.Add ? { op: x.Remove, path: p } : f === x.Remove ? { op: x.Add, path: p, value: d } : { op: x.Replace, path: p, value: d });
1031
1031
  });
1032
1032
  }
1033
- function Ji({ original: t, copy: e }, n, r, i, s) {
1033
+ function Yi({ original: t, copy: e }, n, r, i, s) {
1034
1034
  let o = 0;
1035
1035
  t.forEach((u) => {
1036
1036
  if (!e.has(u)) {
@@ -1067,17 +1067,17 @@ function Ve(t, e, n, r) {
1067
1067
  switch (t.type) {
1068
1068
  case 0:
1069
1069
  case 2:
1070
- return Yi(t, e, n, r, i);
1071
- case 1:
1072
1070
  return Hi(t, e, n, r, i);
1071
+ case 1:
1072
+ return Qi(t, e, n, r, i);
1073
1073
  case 3:
1074
- return Ji(t, e, n, r, i);
1074
+ return Yi(t, e, n, r, i);
1075
1075
  }
1076
1076
  }
1077
1077
  const ct = (t, e, n = !1) => {
1078
1078
  if (typeof t == "object" && t !== null && (!ee(t, e) || n))
1079
1079
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
1080
- }, Nt = {
1080
+ }, Ft = {
1081
1081
  get size() {
1082
1082
  return H(A(this)).size;
1083
1083
  },
@@ -1086,7 +1086,7 @@ const ct = (t, e, n = !1) => {
1086
1086
  },
1087
1087
  set(t, e) {
1088
1088
  const n = A(this), r = H(n);
1089
- return (!r.has(t) || !ae(r.get(t), e)) && (V(n), ie(n), n.assignedMap.set(t, !0), n.copy.set(t, e), un(n, t, e, Ve)), this;
1089
+ return (!r.has(t) || !ae(r.get(t), e)) && (V(n), ie(n), n.assignedMap.set(t, !0), n.copy.set(t, e), on(n, t, e, Ve)), this;
1090
1090
  },
1091
1091
  delete(t) {
1092
1092
  if (!this.has(t))
@@ -1114,7 +1114,7 @@ const ct = (t, e, n = !1) => {
1114
1114
  const r = A(this), i = H(r).get(t), s = ((n = (e = r.options).mark) === null || n === void 0 ? void 0 : n.call(e, i, Y)) === Y.mutable;
1115
1115
  if (r.options.strict && ct(i, r.options, s), s || r.finalized || !ee(i, r.options) || i !== r.original.get(t))
1116
1116
  return i;
1117
- const o = tn.createDraft({
1117
+ const o = en.createDraft({
1118
1118
  original: i,
1119
1119
  parentDraft: r,
1120
1120
  key: t,
@@ -1158,7 +1158,7 @@ const ct = (t, e, n = !1) => {
1158
1158
  [st]() {
1159
1159
  return this.entries();
1160
1160
  }
1161
- }, Zi = Reflect.ownKeys(Nt), zn = (t, e, { isValuesIterator: n }) => () => {
1161
+ }, Ji = Reflect.ownKeys(Ft), qn = (t, e, { isValuesIterator: n }) => () => {
1162
1162
  var r, i;
1163
1163
  const s = e.next();
1164
1164
  if (s.done)
@@ -1167,7 +1167,7 @@ const ct = (t, e, n = !1) => {
1167
1167
  let u = t.setMap.get(o);
1168
1168
  const a = A(u), d = ((i = (r = t.options).mark) === null || i === void 0 ? void 0 : i.call(r, u, Y)) === Y.mutable;
1169
1169
  if (t.options.strict && ct(o, t.options, d), !d && !a && ee(o, t.options) && !t.finalized && t.original.has(o)) {
1170
- const c = tn.createDraft({
1170
+ const c = en.createDraft({
1171
1171
  original: o,
1172
1172
  parentDraft: t,
1173
1173
  key: o,
@@ -1194,7 +1194,7 @@ const ct = (t, e, n = !1) => {
1194
1194
  },
1195
1195
  add(t) {
1196
1196
  const e = A(this);
1197
- return this.has(t) || (V(e), ie(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), un(e, t, t, Ve)), this;
1197
+ return this.has(t) || (V(e), ie(e), e.assignedMap.set(t, !0), e.setMap.set(t, t), on(e, t, t, Ve)), this;
1198
1198
  },
1199
1199
  delete(t) {
1200
1200
  if (!this.has(t))
@@ -1219,7 +1219,7 @@ const ct = (t, e, n = !1) => {
1219
1219
  const e = t.setMap.keys();
1220
1220
  return {
1221
1221
  [Symbol.iterator]: () => this.values(),
1222
- next: zn(t, e, { isValuesIterator: !0 })
1222
+ next: qn(t, e, { isValuesIterator: !0 })
1223
1223
  };
1224
1224
  },
1225
1225
  entries() {
@@ -1228,7 +1228,7 @@ const ct = (t, e, n = !1) => {
1228
1228
  const e = t.setMap.keys();
1229
1229
  return {
1230
1230
  [Symbol.iterator]: () => this.entries(),
1231
- next: zn(t, e, {
1231
+ next: qn(t, e, {
1232
1232
  isValuesIterator: !1
1233
1233
  })
1234
1234
  };
@@ -1269,13 +1269,13 @@ Set.prototype.difference && Object.assign(dt, {
1269
1269
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), t);
1270
1270
  }
1271
1271
  });
1272
- const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1272
+ const Zi = Reflect.ownKeys(dt), Cr = /* @__PURE__ */ new WeakSet(), Pr = {
1273
1273
  get(t, e, n) {
1274
1274
  var r, i;
1275
1275
  const s = (r = t.copy) === null || r === void 0 ? void 0 : r[e];
1276
- if (s && Pr.has(s))
1276
+ if (s && Cr.has(s))
1277
1277
  return s;
1278
- if (e === Ar)
1278
+ if (e === Er)
1279
1279
  return t;
1280
1280
  let o;
1281
1281
  if (t.options.mark) {
@@ -1284,14 +1284,14 @@ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1284
1284
  return t.options.strict && ct(d, t.options, !0), d;
1285
1285
  }
1286
1286
  const u = H(t);
1287
- if (u instanceof Map && Zi.includes(e)) {
1287
+ if (u instanceof Map && Ji.includes(e)) {
1288
1288
  if (e === "size")
1289
- return Object.getOwnPropertyDescriptor(Nt, "size").get.call(t.proxy);
1290
- const d = Nt[e];
1289
+ return Object.getOwnPropertyDescriptor(Ft, "size").get.call(t.proxy);
1290
+ const d = Ft[e];
1291
1291
  if (d)
1292
1292
  return d.bind(t.proxy);
1293
1293
  }
1294
- if (u instanceof Set && Xi.includes(e)) {
1294
+ if (u instanceof Set && Zi.includes(e)) {
1295
1295
  if (e === "size")
1296
1296
  return Object.getOwnPropertyDescriptor(dt, "size").get.call(t.proxy);
1297
1297
  const d = dt[e];
@@ -1299,7 +1299,7 @@ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1299
1299
  return d.bind(t.proxy);
1300
1300
  }
1301
1301
  if (!Ne(u, e)) {
1302
- const d = Kn(u, e);
1302
+ const d = Nn(u, e);
1303
1303
  return d ? "value" in d ? d.value : (
1304
1304
  // !case: support for getter
1305
1305
  (i = d.get) === null || i === void 0 ? void 0 : i.call(t.proxy)
@@ -1309,7 +1309,7 @@ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1309
1309
  if (t.options.strict && ct(a, t.options), t.finalized || !ee(a, t.options))
1310
1310
  return a;
1311
1311
  if (a === kt(t.original, e)) {
1312
- if (V(t), t.copy[e] = an({
1312
+ if (V(t), t.copy[e] = un({
1313
1313
  original: t.original[e],
1314
1314
  parentDraft: t,
1315
1315
  key: t.type === 1 ? Number(e) : e,
@@ -1330,11 +1330,11 @@ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1330
1330
  let i;
1331
1331
  if (t.type === 1 && e !== "length" && !(Number.isInteger(i = Number(e)) && i >= 0 && (e === 0 || i === 0 || String(i) === String(e))))
1332
1332
  throw new Error("Only supports setting array indices and the 'length' property.");
1333
- const s = Kn(H(t), e);
1333
+ const s = Nn(H(t), e);
1334
1334
  if (s != null && s.set)
1335
1335
  return s.set.call(t.proxy, n), !0;
1336
1336
  const o = kt(H(t), e), u = A(o);
1337
- return u && ae(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (ae(n, o) && (n !== void 0 || Ne(t.original, e)) || (V(t), ie(t), Ne(t.original, e) && ae(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, un(t, e, n, Ve)), !0);
1337
+ return u && ae(u.original, n) ? (t.copy[e] = n, t.assignedMap = (r = t.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (ae(n, o) && (n !== void 0 || Ne(t.original, e)) || (V(t), ie(t), Ne(t.original, e) && ae(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, on(t, e, n, Ve)), !0);
1338
1338
  },
1339
1339
  has(t, e) {
1340
1340
  return e in H(t);
@@ -1362,10 +1362,10 @@ const Xi = Reflect.ownKeys(dt), Pr = /* @__PURE__ */ new WeakSet(), Ir = {
1362
1362
  },
1363
1363
  deleteProperty(t, e) {
1364
1364
  var n;
1365
- return t.type === 1 ? Ir.set.call(this, t, e, void 0, t.proxy) : (kt(t.original, e) !== void 0 || e in t.original ? (V(t), ie(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
1365
+ return t.type === 1 ? Pr.set.call(this, t, e, void 0, t.proxy) : (kt(t.original, e) !== void 0 || e in t.original ? (V(t), ie(t), t.assignedMap.set(e, !1)) : (t.assignedMap = (n = t.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), t.assignedMap.delete(e)), t.copy && delete t.copy[e], !0);
1366
1366
  }
1367
1367
  };
1368
- function an(t) {
1368
+ function un(t) {
1369
1369
  const { original: e, parentDraft: n, key: r, finalities: i, options: s } = t, o = me(e), u = {
1370
1370
  type: o,
1371
1371
  finalized: !1,
@@ -1379,8 +1379,8 @@ function an(t) {
1379
1379
  setMap: o === 3 ? new Map(e.entries()) : void 0
1380
1380
  };
1381
1381
  (r || "key" in t) && (u.key = r);
1382
- const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, Ir);
1383
- if (i.revoke.push(d), Pr.add(a), u.proxy = a, n) {
1382
+ const { proxy: a, revoke: d } = Proxy.revocable(o === 1 ? Object.assign([], u) : u, Pr);
1383
+ if (i.revoke.push(d), Cr.add(a), u.proxy = a, n) {
1384
1384
  const c = n;
1385
1385
  c.finalities.draft.push((f, l) => {
1386
1386
  var p, y;
@@ -1389,7 +1389,7 @@ function an(t) {
1389
1389
  const m = ce(g, r), T = A(m);
1390
1390
  if (T) {
1391
1391
  let v = T.original;
1392
- T.operated && (v = sn(m)), Lt(T), Ft(T, Ve, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(v, T.original)), We(g, r, v);
1392
+ T.operated && (v = rn(m)), Ut(T), Lt(T, Ve, f, l), c.options.enableAutoFreeze && (c.options.updatedValues = (p = c.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(v, T.original)), We(g, r, v);
1393
1393
  }
1394
1394
  (y = b.callbacks) === null || y === void 0 || y.forEach((v) => {
1395
1395
  v(f, l);
@@ -1398,26 +1398,26 @@ function an(t) {
1398
1398
  } else {
1399
1399
  const c = A(a);
1400
1400
  c.finalities.draft.push((f, l) => {
1401
- Lt(c), Ft(c, Ve, f, l);
1401
+ Ut(c), Lt(c, Ve, f, l);
1402
1402
  });
1403
1403
  }
1404
1404
  return a;
1405
1405
  }
1406
- tn.createDraft = an;
1407
- function es(t, e, n, r, i) {
1406
+ en.createDraft = un;
1407
+ function Xi(t, e, n, r, i) {
1408
1408
  var s;
1409
1409
  const o = A(t), u = (s = o == null ? void 0 : o.original) !== null && s !== void 0 ? s : t, a = !!e.length;
1410
1410
  if (o != null && o.operated)
1411
1411
  for (; o.finalities.draft.length > 0; )
1412
1412
  o.finalities.draft.pop()(n, r);
1413
1413
  const d = a ? e[0] : o ? o.operated ? o.copy : o.original : t;
1414
- return o && Ut(o), i && Se(d, d, o == null ? void 0 : o.options.updatedValues), [
1414
+ return o && Dt(o), i && Se(d, d, o == null ? void 0 : o.options.updatedValues), [
1415
1415
  d,
1416
1416
  n && a ? [{ op: x.Replace, path: [], value: e[0] }] : n,
1417
1417
  r && a ? [{ op: x.Replace, path: [], value: u }] : r
1418
1418
  ];
1419
1419
  }
1420
- function ts(t, e) {
1420
+ function es(t, e) {
1421
1421
  var n;
1422
1422
  const r = {
1423
1423
  draft: [],
@@ -1426,7 +1426,7 @@ function ts(t, e) {
1426
1426
  };
1427
1427
  let i, s;
1428
1428
  e.enablePatches && (i = [], s = []);
1429
- const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, Y)) === Y.mutable || !ee(t, e) ? t : an({
1429
+ const u = ((n = e.mark) === null || n === void 0 ? void 0 : n.call(e, t, Y)) === Y.mutable || !ee(t, e) ? t : un({
1430
1430
  original: t,
1431
1431
  parentDraft: null,
1432
1432
  finalities: r,
@@ -1435,14 +1435,14 @@ function ts(t, e) {
1435
1435
  return [
1436
1436
  u,
1437
1437
  (a = []) => {
1438
- const [d, c, f] = es(u, a, i, s, e.enableAutoFreeze);
1438
+ const [d, c, f] = Xi(u, a, i, s, e.enableAutoFreeze);
1439
1439
  return e.enablePatches ? [d, c, f] : d;
1440
1440
  }
1441
1441
  ];
1442
1442
  }
1443
- function Kt(t) {
1443
+ function Nt(t) {
1444
1444
  const { rootDraft: e, value: n, useRawReturn: r = !1, isRoot: i = !0 } = t;
1445
- on(n, (s, o, u) => {
1445
+ sn(n, (s, o, u) => {
1446
1446
  const a = A(o);
1447
1447
  if (a && e && a.finalities === e.finalities) {
1448
1448
  t.isContainDraft = !0;
@@ -1452,10 +1452,10 @@ function Kt(t) {
1452
1452
  u.clear(), c.forEach((f) => u.add(s === f ? d : f));
1453
1453
  } else
1454
1454
  We(u, s, d);
1455
- } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Kt(t));
1455
+ } else typeof o == "object" && o !== null && (t.value = o, t.isRoot = !1, Nt(t));
1456
1456
  }), i && (t.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
1457
1457
  }
1458
- function Mr(t) {
1458
+ function Ir(t) {
1459
1459
  var e;
1460
1460
  const n = A(t);
1461
1461
  if (!ee(t, n == null ? void 0 : n.options))
@@ -1465,7 +1465,7 @@ function Mr(t) {
1465
1465
  return n.original;
1466
1466
  let i;
1467
1467
  function s() {
1468
- i = r === 2 ? rn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : jr(t, n == null ? void 0 : n.options);
1468
+ i = r === 2 ? nn(t) ? new Map(t) : new (Object.getPrototypeOf(t)).constructor(t) : r === 3 ? Array.from(n.setMap.values()) : kr(t, n == null ? void 0 : n.options);
1469
1469
  }
1470
1470
  if (n) {
1471
1471
  n.finalized = !0;
@@ -1476,23 +1476,23 @@ function Mr(t) {
1476
1476
  }
1477
1477
  } else
1478
1478
  i = t;
1479
- if (on(i, (o, u) => {
1479
+ if (sn(i, (o, u) => {
1480
1480
  if (n && ae(ce(n.original, o), u))
1481
1481
  return;
1482
- const a = Mr(u);
1482
+ const a = Ir(u);
1483
1483
  a !== u && (i === t && s(), We(i, o, a));
1484
1484
  }), r === 3) {
1485
1485
  const o = (e = n == null ? void 0 : n.original) !== null && e !== void 0 ? e : i;
1486
- return nn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
1486
+ return tn(o) ? new Set(i) : new (Object.getPrototypeOf(o)).constructor(i);
1487
1487
  }
1488
1488
  return i;
1489
1489
  }
1490
- function Vn(t) {
1490
+ function zn(t) {
1491
1491
  if (!Te(t))
1492
1492
  throw new Error(`current() is only used for Draft, parameter: ${t}`);
1493
- return Mr(t);
1493
+ return Ir(t);
1494
1494
  }
1495
- const ns = (t) => function e(n, r, i) {
1495
+ const ts = (t) => function e(n, r, i) {
1496
1496
  var s, o, u;
1497
1497
  if (typeof n == "function" && typeof r != "function")
1498
1498
  return function(S, ...I) {
@@ -1503,7 +1503,7 @@ const ns = (t) => function e(n, r, i) {
1503
1503
  if (typeof r != "function" && (c = r), c !== void 0 && Object.prototype.toString.call(c) !== "[object Object]")
1504
1504
  throw new Error(`Invalid options: ${c}, 'options' should be an object.`);
1505
1505
  c = Object.assign(Object.assign({}, t), c);
1506
- const f = Te(a) ? Vn(a) : a, l = Array.isArray(c.mark) ? (S, I) => {
1506
+ const f = Te(a) ? zn(a) : a, l = Array.isArray(c.mark) ? (S, I) => {
1507
1507
  for (const R of c.mark) {
1508
1508
  if (typeof R != "function")
1509
1509
  throw new Error(`Invalid mark: ${R}, 'mark' should be a function.`);
@@ -1519,7 +1519,7 @@ const ns = (t) => function e(n, r, i) {
1519
1519
  };
1520
1520
  if (!ee(f, g) && typeof f == "object" && f !== null)
1521
1521
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1522
- const [m, T] = ts(f, g);
1522
+ const [m, T] = es(f, g);
1523
1523
  if (typeof r != "function") {
1524
1524
  if (!ee(f, g))
1525
1525
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -1529,24 +1529,24 @@ const ns = (t) => function e(n, r, i) {
1529
1529
  try {
1530
1530
  v = d(m);
1531
1531
  } catch (S) {
1532
- throw Ut(A(m)), S;
1532
+ throw Dt(A(m)), S;
1533
1533
  }
1534
1534
  const j = (S) => {
1535
1535
  const I = A(m);
1536
1536
  if (!Te(S)) {
1537
1537
  if (S !== void 0 && !ae(S, m) && (I != null && I.operated))
1538
1538
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
1539
- const q = S == null ? void 0 : S[Vi];
1539
+ const q = S == null ? void 0 : S[zi];
1540
1540
  if (q) {
1541
1541
  const Ie = q[0];
1542
- return g.strict && typeof S == "object" && S !== null && Kt({
1542
+ return g.strict && typeof S == "object" && S !== null && Nt({
1543
1543
  rootDraft: I,
1544
1544
  value: S,
1545
1545
  useRawReturn: !0
1546
1546
  }), T([Ie]);
1547
1547
  }
1548
1548
  if (S !== void 0)
1549
- return typeof S == "object" && S !== null && Kt({ rootDraft: I, value: S }), T([S]);
1549
+ return typeof S == "object" && S !== null && Nt({ rootDraft: I, value: S }), T([S]);
1550
1550
  }
1551
1551
  if (S === m || S === void 0)
1552
1552
  return T([]);
@@ -1554,26 +1554,26 @@ const ns = (t) => function e(n, r, i) {
1554
1554
  if (g === R.options) {
1555
1555
  if (R.operated)
1556
1556
  throw new Error("Cannot return a modified child draft.");
1557
- return T([Vn(S)]);
1557
+ return T([zn(S)]);
1558
1558
  }
1559
1559
  return T([S]);
1560
1560
  };
1561
1561
  return v instanceof Promise ? v.then(j, (S) => {
1562
- throw Ut(A(m)), S;
1562
+ throw Dt(A(m)), S;
1563
1563
  }) : j(v);
1564
- }, ft = ns();
1564
+ }, ft = ts();
1565
1565
  Object.prototype.constructor.toString();
1566
- function Rr(t, e) {
1566
+ function Mr(t, e) {
1567
1567
  const n = Object.keys(t), r = Object.keys(e);
1568
1568
  return n.length === r.length && Object.keys(t).every((i) => e.hasOwnProperty(i));
1569
1569
  }
1570
- function Wn(t, e) {
1570
+ function Vn(t, e) {
1571
1571
  return Object.keys(t).length === Object.keys(e).length && Object.keys(t).every((n) => e.hasOwnProperty(n) && t[n] === e[n]);
1572
1572
  }
1573
1573
  function ut(t, e) {
1574
- return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : Rr(t, e) ? Object.keys(t).every((n) => ut(t[n], e[n])) : !1;
1574
+ return typeof t != "object" || typeof e != "object" || t === null || e === null ? t === e : Mr(t, e) ? Object.keys(t).every((n) => ut(t[n], e[n])) : !1;
1575
1575
  }
1576
- function cn(t) {
1576
+ function an(t) {
1577
1577
  if (!Le(t))
1578
1578
  return t;
1579
1579
  const e = {};
@@ -1581,7 +1581,7 @@ function cn(t) {
1581
1581
  r !== void 0 && (e[n] = r);
1582
1582
  return e;
1583
1583
  }
1584
- function $r(t, e) {
1584
+ function Rr(t, e) {
1585
1585
  if (!Le(t) || !Le(e))
1586
1586
  return e;
1587
1587
  const n = Object.assign({}, t);
@@ -1593,14 +1593,14 @@ function $r(t, e) {
1593
1593
  continue;
1594
1594
  }
1595
1595
  const i = Le(t[r]) && Le(e[r]);
1596
- n[r] = i ? $r(t[r], e[r]) : e[r];
1596
+ n[r] = i ? Rr(t[r], e[r]) : e[r];
1597
1597
  }
1598
1598
  return n;
1599
1599
  }
1600
1600
  function Le(t) {
1601
1601
  return typeof t == "object" && t !== null && !Array.isArray(t);
1602
1602
  }
1603
- function rs(t, e, n) {
1603
+ function ns(t, e, n) {
1604
1604
  if (!t || e.length === 0)
1605
1605
  return;
1606
1606
  let r = t || {};
@@ -1611,7 +1611,7 @@ function rs(t, e, n) {
1611
1611
  const i = e[e.length - 1];
1612
1612
  Array.isArray(r) && typeof i == "number" ? r.splice(i, 0, n) : r[i] = n;
1613
1613
  }
1614
- function Bn(t, e, n) {
1614
+ function Wn(t, e, n) {
1615
1615
  if (!t || e.length === 0)
1616
1616
  return;
1617
1617
  let r = t || {};
@@ -1621,7 +1621,7 @@ function Bn(t, e, n) {
1621
1621
  }
1622
1622
  r[e[e.length - 1]] = n;
1623
1623
  }
1624
- function xr(t, e) {
1624
+ function $r(t, e) {
1625
1625
  if (!t || e.length === 0)
1626
1626
  return;
1627
1627
  const [n, ...r] = e;
@@ -1630,13 +1630,13 @@ function xr(t, e) {
1630
1630
  Array.isArray(t) ? t.splice(n, 1) : delete t[n];
1631
1631
  return;
1632
1632
  }
1633
- xr(t[n], r), is(t[n]) && delete t[n];
1633
+ $r(t[n], r), rs(t[n]) && delete t[n];
1634
1634
  }
1635
1635
  }
1636
- function is(t) {
1636
+ function rs(t) {
1637
1637
  return t && Object.keys(t).length === 0;
1638
1638
  }
1639
- const Gn = /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$/, ss = {
1639
+ const Bn = /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$/, is = {
1640
1640
  ZULU: 0,
1641
1641
  YEKT: 18e3,
1642
1642
  YEKST: 21600,
@@ -1832,39 +1832,39 @@ const Gn = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1832
1832
  ACSST: 37800,
1833
1833
  ACDT: 37800
1834
1834
  };
1835
- function os(t) {
1835
+ function ss(t) {
1836
1836
  return new Date(t);
1837
1837
  }
1838
- function us(t) {
1838
+ function os(t) {
1839
1839
  return /* @__PURE__ */ new Date(t + "Z");
1840
1840
  }
1841
- const as = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1842
- function cs(t) {
1843
- const e = t.match(as);
1841
+ const us = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1842
+ function as(t) {
1843
+ const e = t.match(us);
1844
1844
  if (!e)
1845
1845
  return null;
1846
1846
  const [n, r, i, s] = e;
1847
1847
  return r <= 0 || i <= 0 || s <= 0 ? null : r > 999 ? new Date(Date.UTC(r, i - 1, s, 0, 0, 0, 0)) : new Date(Date.UTC(s, r - 1, i, 0, 0, 0, 0));
1848
1848
  }
1849
- function ds(t) {
1849
+ function cs(t) {
1850
1850
  const [e, n] = t.split(" ");
1851
1851
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1852
1852
  }
1853
- function fs(t) {
1853
+ function ds(t) {
1854
1854
  const [e, n] = t.split(" ");
1855
1855
  return /* @__PURE__ */ new Date(e + "T" + n + "Z");
1856
1856
  }
1857
- function ls(t) {
1857
+ function fs(t) {
1858
1858
  return new Date(t);
1859
1859
  }
1860
- function hs(t) {
1860
+ function ls(t) {
1861
1861
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1862
1862
  if (!t.match(e))
1863
1863
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1864
1864
  const r = /* @__PURE__ */ new Date(t + " UTC");
1865
1865
  return new Date(Date.UTC(r.getUTCFullYear(), r.getUTCMonth(), r.getUTCDate(), 0, 0, 0, 0));
1866
1866
  }
1867
- function ps(t) {
1867
+ function hs(t) {
1868
1868
  const e = /^(.+T.+)([+-])(\d{2})$/, n = t.match(e);
1869
1869
  if (n) {
1870
1870
  const [, r, i, s] = n, o = `${r}${i}${s}:00`;
@@ -1872,14 +1872,14 @@ function ps(t) {
1872
1872
  }
1873
1873
  return null;
1874
1874
  }
1875
- function ys(t) {
1875
+ function ps(t) {
1876
1876
  const [e, n] = t.split(", "), [r, i, s] = e.split("/").map(Number), o = n.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1877
1877
  if (!o)
1878
1878
  throw new Error(`Unable to parse time from: ${t}`);
1879
1879
  let [, u, a, d, c] = o;
1880
1880
  return u = Number(u), a = Number(a), d = Number(d), c === "PM" && u !== 12 ? u += 12 : c === "AM" && u === 12 && (u = 0), new Date(Date.UTC(s, r - 1, i, u, a, d));
1881
1881
  }
1882
- function bs(t) {
1882
+ function ys(t) {
1883
1883
  switch (t) {
1884
1884
  case "epoch":
1885
1885
  return /* @__PURE__ */ new Date(0);
@@ -1891,27 +1891,27 @@ function bs(t) {
1891
1891
  return null;
1892
1892
  }
1893
1893
  }
1894
- function _s(t) {
1895
- const e = t.match(Gn);
1894
+ function bs(t) {
1895
+ const e = t.match(Bn);
1896
1896
  if (!e)
1897
1897
  return null;
1898
- const [n] = e, r = ss[n], i = new Date(t.replace(Gn, "Z"));
1898
+ const [n] = e, r = is[n], i = new Date(t.replace(Bn, "Z"));
1899
1899
  return new Date(i.getTime() - r * 1e3);
1900
1900
  }
1901
- const gs = [
1902
- cs,
1903
- fs,
1904
- hs,
1905
- ys,
1901
+ const _s = [
1902
+ as,
1903
+ ds,
1906
1904
  ls,
1907
- us,
1908
1905
  ps,
1909
- ds,
1906
+ fs,
1910
1907
  os,
1911
- bs,
1912
- _s
1908
+ hs,
1909
+ cs,
1910
+ ss,
1911
+ ys,
1912
+ bs
1913
1913
  ];
1914
- function Ts(t, e) {
1914
+ function gs(t, e) {
1915
1915
  try {
1916
1916
  const n = t(e);
1917
1917
  return n instanceof Date && !isNaN(n.getTime()) ? n : null;
@@ -1919,18 +1919,18 @@ function Ts(t, e) {
1919
1919
  return null;
1920
1920
  }
1921
1921
  }
1922
- function qt(t) {
1923
- for (const e of gs) {
1924
- const n = Ts(e, t);
1922
+ function Kt(t) {
1923
+ for (const e of _s) {
1924
+ const n = gs(e, t);
1925
1925
  if (n)
1926
1926
  return n;
1927
1927
  }
1928
1928
  return null;
1929
1929
  }
1930
- function ms(t) {
1930
+ function Ts(t) {
1931
1931
  try {
1932
1932
  const e = JSON.parse(t);
1933
- return typeof e == "string" ? qt(e) : null;
1933
+ return typeof e == "string" ? Kt(e) : null;
1934
1934
  } catch {
1935
1935
  return null;
1936
1936
  }
@@ -1942,7 +1942,7 @@ function pt(t) {
1942
1942
  if (t instanceof Date)
1943
1943
  return t;
1944
1944
  if (typeof t == "string") {
1945
- const e = qt(t) || ms(t) || qt(t.trim());
1945
+ const e = Kt(t) || Ts(t) || Kt(t.trim());
1946
1946
  if (!e)
1947
1947
  throw new Error(`Unable to parse \`${t}\` as a date.`);
1948
1948
  return e;
@@ -1951,13 +1951,13 @@ function pt(t) {
1951
1951
  throw new Error(`Invalid date value \`${t}\`. Expected a date, number, or string, got type ${typeof t}.`);
1952
1952
  }
1953
1953
  }
1954
- function ws(t) {
1954
+ function ms(t) {
1955
1955
  return t.cardinality === "one";
1956
1956
  }
1957
- function dn(t) {
1957
+ function cn(t) {
1958
1958
  return t["value-type"] === "ref";
1959
1959
  }
1960
- function fn(t) {
1960
+ function dn(t) {
1961
1961
  return t["value-type"] === "blob";
1962
1962
  }
1963
1963
  function je(t, e) {
@@ -1987,7 +1987,7 @@ function B(t, e, n) {
1987
1987
  let s = t.get(r);
1988
1988
  s || (s = /* @__PURE__ */ new Map(), t.set(r, s)), B(s, i, n);
1989
1989
  }
1990
- function Dr(t, e, n) {
1990
+ function xr(t, e, n) {
1991
1991
  const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1992
1992
  for (const o of e) {
1993
1993
  let [u, a, d, c] = o;
@@ -1996,22 +1996,22 @@ function Dr(t, e, n) {
1996
1996
  console.warn("no such attr", u, t);
1997
1997
  continue;
1998
1998
  }
1999
- f["checked-data-type"] === "date" && n && (d = pt(d), o[2] = d), dn(f) && B(s, [d, a, u], o), B(r, [u, a, d], o), B(i, [a, u, d], o);
1999
+ f["checked-data-type"] === "date" && n && (d = pt(d), o[2] = d), cn(f) && B(s, [d, a, u], o), B(r, [u, a, d], o), B(i, [a, u, d], o);
2000
2000
  }
2001
2001
  return { eav: r, aev: i, vae: s };
2002
2002
  }
2003
- function Ur(t) {
2003
+ function Dr(t) {
2004
2004
  const e = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
2005
2005
  for (const s of Object.values(t)) {
2006
2006
  const o = s["forward-identity"], [u, a, d] = o, c = s["reverse-identity"];
2007
- if (B(r, [a, d], s), fn(s) && B(e, [a, d], s), s["primary?"] && B(n, [a], s), c) {
2007
+ if (B(r, [a, d], s), dn(s) && B(e, [a, d], s), s["primary?"] && B(n, [a], s), c) {
2008
2008
  const [f, l, p] = c;
2009
2009
  B(i, [l, p], s);
2010
2010
  }
2011
2011
  }
2012
2012
  return { blobAttrs: e, primaryKeys: n, forwardIdents: r, revIdents: i };
2013
2013
  }
2014
- function Lr(t) {
2014
+ function Ur(t) {
2015
2015
  return {
2016
2016
  __type: t.__type,
2017
2017
  attrs: t.attrs,
@@ -2021,18 +2021,18 @@ function Lr(t) {
2021
2021
  useDateObjects: t.useDateObjects
2022
2022
  };
2023
2023
  }
2024
- function Fr(t) {
2024
+ function Lr(t) {
2025
2025
  return at(t.attrs, t.triples, t.cardinalityInference, t.linkIndex, t.useDateObjects);
2026
2026
  }
2027
- function vs(t, e) {
2027
+ function ws(t, e) {
2028
2028
  return Ce(t.eav, [e]) !== void 0;
2029
2029
  }
2030
- function ln(t) {
2031
- t.attrIndexes = Ur(t.attrs);
2030
+ function fn(t) {
2031
+ t.attrIndexes = Dr(t.attrs);
2032
2032
  }
2033
2033
  function at(t, e, n, r, i) {
2034
- const s = Dr(t, e, i);
2035
- return s.useDateObjects = i, s.attrs = t, s.attrIndexes = Ur(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
2034
+ const s = xr(t, e, i);
2035
+ return s.useDateObjects = i, s.attrs = t, s.attrIndexes = Dr(t), s.cardinalityInference = n, s.linkIndex = r, s.__type = "store", s;
2036
2036
  }
2037
2037
  function Be(t, e) {
2038
2038
  var n, r;
@@ -2061,21 +2061,21 @@ function Be(t, e) {
2061
2061
  return [i, ...u];
2062
2062
  }
2063
2063
  }
2064
- function Nr(t, e) {
2064
+ function Fr(t, e) {
2065
2065
  const n = Be(t, e);
2066
2066
  if (!n)
2067
2067
  return;
2068
2068
  const [r, i, s] = n, o = je(t.attrs, i);
2069
- o && (X(t.eav, [r, i, s]), X(t.aev, [i, r, s]), dn(o) && X(t.vae, [s, i, r]));
2069
+ o && (X(t.eav, [r, i, s]), X(t.aev, [i, r, s]), cn(o) && X(t.vae, [s, i, r]));
2070
2070
  }
2071
- let Ss = 0;
2072
- function Kr(t, e, n) {
2071
+ let vs = 0;
2072
+ function Nr(t, e, n) {
2073
2073
  const [r, i, s] = n;
2074
2074
  let o;
2075
2075
  const u = Ce(t.ea, [r, i, s]);
2076
- return u && (o = u[3]), o || Date.now() * 10 + Ss++;
2076
+ return u && (o = u[3]), o || Date.now() * 10 + vs++;
2077
2077
  }
2078
- function qr(t, e) {
2078
+ function Kr(t, e) {
2079
2079
  var n;
2080
2080
  const r = Be(t, e);
2081
2081
  if (!r)
@@ -2085,10 +2085,10 @@ function qr(t, e) {
2085
2085
  if (!u)
2086
2086
  return;
2087
2087
  u["checked-data-type"] === "date" && t.useDateObjects && (o = pt(o));
2088
- const a = Ce(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Kr(t, u, r), c = [i, s, o, d];
2089
- ws(u) ? (B(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), B(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (B(t.eav, [i, s, o], c), B(t.aev, [s, i, o], c)), dn(u) && B(t.vae, [o, s, i], c);
2088
+ const a = Ce(t.eav, [i, s, o]), d = (n = a == null ? void 0 : a[3]) !== null && n !== void 0 ? n : Nr(t, u, r), c = [i, s, o, d];
2089
+ ms(u) ? (B(t.eav, [i, s], /* @__PURE__ */ new Map([[o, c]])), B(t.aev, [s, i], /* @__PURE__ */ new Map([[o, c]]))) : (B(t.eav, [i, s, o], c), B(t.aev, [s, i, o], c)), cn(u) && B(t.vae, [o, s, i], c);
2090
2090
  }
2091
- function Os(t, e) {
2091
+ function Ss(t, e) {
2092
2092
  var n;
2093
2093
  const r = Be(t, e);
2094
2094
  if (!r)
@@ -2096,7 +2096,7 @@ function Os(t, e) {
2096
2096
  const [i, s, o] = r, u = je(t.attrs, s);
2097
2097
  if (!u)
2098
2098
  return;
2099
- if (!fn(u))
2099
+ if (!dn(u))
2100
2100
  throw new Error("merge operation is not supported for links");
2101
2101
  const a = Ce(t.eav, [i, s]);
2102
2102
  if (!a)
@@ -2104,15 +2104,15 @@ function Os(t, e) {
2104
2104
  const d = (n = a.values().next()) === null || n === void 0 ? void 0 : n.value;
2105
2105
  if (!d)
2106
2106
  return;
2107
- const c = d[2], f = $r(c, o), l = [
2107
+ const c = d[2], f = Rr(c, o), l = [
2108
2108
  i,
2109
2109
  s,
2110
2110
  f,
2111
- Kr(t, u, d)
2111
+ Nr(t, u, d)
2112
2112
  ];
2113
2113
  B(t.eav, [i, s], /* @__PURE__ */ new Map([[f, l]]));
2114
2114
  }
2115
- function zt(t, e) {
2115
+ function qt(t, e) {
2116
2116
  var n, r;
2117
2117
  const [i, s] = e, o = Be(t, [i]);
2118
2118
  if (!o)
@@ -2123,7 +2123,7 @@ function zt(t, e) {
2123
2123
  const f = t.attrs[c];
2124
2124
  f && f["on-delete-reverse"] === "cascade" && G(a.get(c), 1).forEach(([l, p, y]) => {
2125
2125
  var b;
2126
- return zt(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
2126
+ return qt(t, [y, (b = f["reverse-identity"]) === null || b === void 0 ? void 0 : b[1]]);
2127
2127
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
2128
2128
  // the store that didn't set `etype` in deleteEntity
2129
2129
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -2136,54 +2136,54 @@ function zt(t, e) {
2136
2136
  d && d.forEach((c) => {
2137
2137
  var f, l, p;
2138
2138
  const [y, b, g] = c, m = t.attrs[b];
2139
- (!s || !m || ((f = m["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (X(t.eav, [y, b, g]), X(t.aev, [b, y, g]), X(t.vae, [g, b, y])), m && m["on-delete"] === "cascade" && ((l = m["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && zt(t, [y, (p = m["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
2139
+ (!s || !m || ((f = m["reverse-identity"]) === null || f === void 0 ? void 0 : f[1]) === s) && (X(t.eav, [y, b, g]), X(t.aev, [b, y, g]), X(t.vae, [g, b, y])), m && m["on-delete"] === "cascade" && ((l = m["reverse-identity"]) === null || l === void 0 ? void 0 : l[1]) === s && qt(t, [y, (p = m["forward-identity"]) === null || p === void 0 ? void 0 : p[1]]);
2140
2140
  }), ((r = t.vae.get(u)) === null || r === void 0 ? void 0 : r.size) === 0 && X(t.vae, [u]);
2141
2141
  }
2142
- function zr(t, e) {
2143
- const n = Dr(t.attrs, e, t.useDateObjects);
2142
+ function qr(t, e) {
2143
+ const n = xr(t.attrs, e, t.useDateObjects);
2144
2144
  Object.keys(n).forEach((r) => {
2145
2145
  t[r] = n[r];
2146
2146
  });
2147
2147
  }
2148
- function Es(t, [e]) {
2149
- t.attrs[e.id] = e, ln(t);
2148
+ function Os(t, [e]) {
2149
+ t.attrs[e.id] = e, fn(t);
2150
2150
  }
2151
- function Vr(t) {
2151
+ function zr(t) {
2152
2152
  return G(t.eav, 3);
2153
2153
  }
2154
- function As(t, [e]) {
2154
+ function Es(t, [e]) {
2155
2155
  if (!t.attrs[e])
2156
2156
  return;
2157
- const n = Vr(t).filter(([r, i]) => i !== e);
2158
- delete t.attrs[e], ln(t), zr(t, n);
2157
+ const n = zr(t).filter(([r, i]) => i !== e);
2158
+ delete t.attrs[e], fn(t), qr(t, n);
2159
2159
  }
2160
- function ks(t, [e]) {
2160
+ function As(t, [e]) {
2161
2161
  const n = t.attrs[e.id];
2162
- n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), ln(t), zr(t, Vr(t)));
2162
+ n && (t.attrs[e.id] = Object.assign(Object.assign({}, n), e), fn(t), qr(t, zr(t)));
2163
2163
  }
2164
- function js(t, e) {
2164
+ function ks(t, e) {
2165
2165
  const [n, ...r] = e;
2166
2166
  switch (n) {
2167
2167
  case "add-triple":
2168
- qr(t, r);
2168
+ Kr(t, r);
2169
2169
  break;
2170
2170
  case "deep-merge-triple":
2171
- Os(t, r);
2171
+ Ss(t, r);
2172
2172
  break;
2173
2173
  case "retract-triple":
2174
- Nr(t, r);
2174
+ Fr(t, r);
2175
2175
  break;
2176
2176
  case "delete-entity":
2177
- zt(t, r);
2177
+ qt(t, r);
2178
2178
  break;
2179
2179
  case "add-attr":
2180
- Es(t, r);
2180
+ Os(t, r);
2181
2181
  break;
2182
2182
  case "delete-attr":
2183
- As(t, r);
2183
+ Es(t, r);
2184
2184
  break;
2185
2185
  case "update-attr":
2186
- ks(t, r);
2186
+ As(t, r);
2187
2187
  break;
2188
2188
  case "restore-attr":
2189
2189
  break;
@@ -2238,13 +2238,13 @@ function tt(t, e, n) {
2238
2238
  }
2239
2239
  return s;
2240
2240
  }
2241
- function Cs(t, e, n) {
2241
+ function js(t, e, n) {
2242
2242
  let r = "";
2243
2243
  return t !== void 0 && (r += "e"), e !== void 0 && (r += "a"), n !== void 0 && (r += "v"), r;
2244
2244
  }
2245
- function Ps(t, [e, n, r]) {
2245
+ function Cs(t, [e, n, r]) {
2246
2246
  var i, s;
2247
- switch (Cs(e, n, r)) {
2247
+ switch (js(e, n, r)) {
2248
2248
  case "e": {
2249
2249
  const u = t.eav.get(e);
2250
2250
  return G(u, 2);
@@ -2290,36 +2290,33 @@ function Ps(t, [e, n, r]) {
2290
2290
  return G(t.eav, 3);
2291
2291
  }
2292
2292
  }
2293
- const jt = {};
2294
- function Is(t, e, n) {
2293
+ function Ps(t, e, n) {
2295
2294
  var r;
2296
- if (jt[n])
2297
- return jt[n];
2298
2295
  const i = {};
2299
2296
  for (const [s, o] of e.entries()) {
2300
2297
  const u = (r = t.eav.get(n)) === null || r === void 0 ? void 0 : r.get(o.id), a = G(u, 1);
2301
2298
  for (const d of a)
2302
2299
  i[s] = d[2];
2303
2300
  }
2304
- return jt[n] = i, i;
2301
+ return i;
2305
2302
  }
2306
2303
  function fe(t, e, n) {
2307
2304
  var r;
2308
2305
  return (r = t.attrIndexes.forwardIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
2309
2306
  }
2310
- function Wr(t, e, n) {
2307
+ function Vr(t, e, n) {
2311
2308
  var r;
2312
2309
  return (r = t.attrIndexes.revIdents.get(e)) === null || r === void 0 ? void 0 : r.get(n);
2313
2310
  }
2314
- function Ms(t, e) {
2311
+ function Is(t, e) {
2315
2312
  return t.attrIndexes.blobAttrs.get(e);
2316
2313
  }
2317
- function Br(t, e) {
2314
+ function Wr(t, e) {
2318
2315
  var n;
2319
2316
  const r = t.attrIndexes.primaryKeys.get(e);
2320
2317
  return r || ((n = t.attrIndexes.forwardIdents.get(e)) === null || n === void 0 ? void 0 : n.get("id"));
2321
2318
  }
2322
- function Rs(t, e) {
2319
+ function Ms(t, e) {
2323
2320
  const n = Be(t, e);
2324
2321
  if (!n)
2325
2322
  return;
@@ -2327,7 +2324,7 @@ function Rs(t, e) {
2327
2324
  if (je(t.attrs, i))
2328
2325
  return Ce(t.eav, [r, i]);
2329
2326
  }
2330
- function $s(t, e) {
2327
+ function Rs(t, e) {
2331
2328
  const n = e.filter(([r, i, s, o, u]) => {
2332
2329
  if (r !== "add-triple" && r !== "deep-merge-triple")
2333
2330
  return !0;
@@ -2337,39 +2334,39 @@ function $s(t, e) {
2337
2334
  let d = !1;
2338
2335
  const c = je(t.attrs, s);
2339
2336
  if (c) {
2340
- const f = Br(t, c["forward-identity"][1]);
2341
- d = !!Rs(t, [i, f.id, i]);
2337
+ const f = Wr(t, c["forward-identity"][1]);
2338
+ d = !!Ms(t, [i, f.id, i]);
2342
2339
  }
2343
2340
  return !(a === "create" && d || a === "update" && !d);
2344
2341
  });
2345
2342
  return ft(t, (r) => {
2346
2343
  n.forEach((i) => {
2347
- js(r, i);
2344
+ ks(r, i);
2348
2345
  });
2349
2346
  });
2350
2347
  }
2351
- function xs(t) {
2348
+ function $s(t) {
2352
2349
  return typeof t == "string" && t.startsWith("?");
2353
2350
  }
2354
- function Ds(t, e, n) {
2351
+ function xs(t, e, n) {
2355
2352
  if (n.hasOwnProperty(t)) {
2356
2353
  const r = n[t];
2357
- return Gr(r, e, n);
2354
+ return Br(r, e, n);
2358
2355
  }
2359
2356
  return Object.assign(Object.assign({}, n), { [t]: e });
2360
2357
  }
2361
- function Qn(t, e, n) {
2358
+ function Gn(t, e, n) {
2362
2359
  return t === e ? n : null;
2363
2360
  }
2364
- function Us(t) {
2361
+ function Ds(t) {
2365
2362
  switch (typeof t) {
2366
2363
  case "string":
2367
- return t.startsWith("?") ? Ds : Qn;
2364
+ return t.startsWith("?") ? xs : Gn;
2368
2365
  default:
2369
- return Qn;
2366
+ return Gn;
2370
2367
  }
2371
2368
  }
2372
- const Ls = [
2369
+ const Us = [
2373
2370
  "in",
2374
2371
  "$in",
2375
2372
  "$not",
@@ -2377,77 +2374,77 @@ const Ls = [
2377
2374
  "$comparator"
2378
2375
  // covers all of $gt, $lt, etc.
2379
2376
  ];
2380
- function Fs(t) {
2381
- for (const e of Ls)
2377
+ function Ls(t) {
2378
+ for (const e of Us)
2382
2379
  if (t.hasOwnProperty(e))
2383
2380
  return !0;
2384
2381
  return !1;
2385
2382
  }
2386
- function Gr(t, e, n) {
2387
- return n ? typeof t == "object" ? Fs(t) ? n : null : Us(t)(t, e, n) : null;
2383
+ function Br(t, e, n) {
2384
+ return n ? typeof t == "object" ? Ls(t) ? n : null : Ds(t)(t, e, n) : null;
2388
2385
  }
2389
- function Ns(t, e, n) {
2386
+ function Fs(t, e, n) {
2390
2387
  return t.reduce((r, i, s) => {
2391
2388
  const o = e[s];
2392
- return Gr(i, o, r);
2389
+ return Br(i, o, r);
2393
2390
  }, n);
2394
2391
  }
2395
- function Ks(t, e, n) {
2396
- return Vs(t, e, n).map((r) => Ns(e, r, n)).filter((r) => r);
2392
+ function Ns(t, e, n) {
2393
+ return zs(t, e, n).map((r) => Fs(e, r, n)).filter((r) => r);
2397
2394
  }
2398
- function qs(t, e, n) {
2399
- return e.or ? e.or.patterns.flatMap((r) => Vt(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => Vt(t, i, r), n) : n.flatMap((r) => Ks(t, e, r));
2395
+ function Ks(t, e, n) {
2396
+ return e.or ? e.or.patterns.flatMap((r) => zt(t, r, n)) : e.and ? e.and.patterns.reduce((r, i) => zt(t, i, r), n) : n.flatMap((r) => Ns(t, e, r));
2400
2397
  }
2401
- function Vt(t, e, n = [{}]) {
2402
- return e.reduce((r, i) => qs(t, i, r), n);
2398
+ function zt(t, e, n = [{}]) {
2399
+ return e.reduce((r, i) => Ks(t, i, r), n);
2403
2400
  }
2404
- function hn(t, e) {
2405
- return Array.isArray(e) ? e.map((n) => hn(t, n)) : xs(e) ? t[e] : e;
2401
+ function ln(t, e) {
2402
+ return Array.isArray(e) ? e.map((n) => ln(t, n)) : $s(e) ? t[e] : e;
2406
2403
  }
2407
- function zs(t, { find: e, where: n }) {
2408
- return Vt(t, n).map((i) => hn(i, e));
2404
+ function qs(t, { find: e, where: n }) {
2405
+ return zt(t, n).map((i) => ln(i, e));
2409
2406
  }
2410
- function Vs(t, e, n) {
2411
- return Ps(t, hn(n, e));
2407
+ function zs(t, e, n) {
2408
+ return Cs(t, ln(n, e));
2412
2409
  }
2413
- const Ws = /^(?:[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;
2410
+ const Vs = /^(?:[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;
2414
2411
  function Ee(t) {
2415
- return typeof t == "string" && Ws.test(t);
2412
+ return typeof t == "string" && Vs.test(t);
2416
2413
  }
2417
2414
  const F = [];
2418
2415
  for (let t = 0; t < 256; ++t)
2419
2416
  F.push((t + 256).toString(16).slice(1));
2420
- function Bs(t, e = 0) {
2417
+ function Ws(t, e = 0) {
2421
2418
  return (F[t[e + 0]] + F[t[e + 1]] + F[t[e + 2]] + F[t[e + 3]] + "-" + F[t[e + 4]] + F[t[e + 5]] + "-" + F[t[e + 6]] + F[t[e + 7]] + "-" + F[t[e + 8]] + F[t[e + 9]] + "-" + F[t[e + 10]] + F[t[e + 11]] + F[t[e + 12]] + F[t[e + 13]] + F[t[e + 14]] + F[t[e + 15]]).toLowerCase();
2422
2419
  }
2423
- let Ct;
2424
- const Gs = new Uint8Array(16);
2425
- function Qs() {
2426
- if (!Ct) {
2420
+ let jt;
2421
+ const Bs = new Uint8Array(16);
2422
+ function Gs() {
2423
+ if (!jt) {
2427
2424
  if (typeof crypto > "u" || !crypto.getRandomValues)
2428
2425
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2429
- Ct = crypto.getRandomValues.bind(crypto);
2426
+ jt = crypto.getRandomValues.bind(crypto);
2430
2427
  }
2431
- return Ct(Gs);
2428
+ return jt(Bs);
2432
2429
  }
2433
- const Hs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Hn = { randomUUID: Hs };
2434
- function Ys(t, e, n) {
2430
+ const Qs = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qn = { randomUUID: Qs };
2431
+ function Hs(t, e, n) {
2435
2432
  var i;
2436
- if (Hn.randomUUID && !t)
2437
- return Hn.randomUUID();
2433
+ if (Qn.randomUUID && !t)
2434
+ return Qn.randomUUID();
2438
2435
  t = t || {};
2439
- const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Qs();
2436
+ const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Gs();
2440
2437
  if (r.length < 16)
2441
2438
  throw new Error("Random bytes length must be >= 16");
2442
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Bs(r);
2439
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Ws(r);
2443
2440
  }
2444
- function Yn(t) {
2441
+ function Hn(t) {
2445
2442
  const e = t.replace(/-/g, ""), n = [];
2446
2443
  for (let r = 0; r < e.length; r += 2)
2447
2444
  n.push(parseInt(e.substring(r, r + 2), 16));
2448
2445
  return n;
2449
2446
  }
2450
- function Js(t, e) {
2447
+ function Ys(t, e) {
2451
2448
  for (let n = 0; n < t.length; n++) {
2452
2449
  if (t[n] < e[n])
2453
2450
  return -1;
@@ -2456,17 +2453,17 @@ function Js(t, e) {
2456
2453
  }
2457
2454
  return 0;
2458
2455
  }
2459
- function Zs(t, e) {
2460
- return Js(Yn(t), Yn(e));
2456
+ function Js(t, e) {
2457
+ return Ys(Hn(t), Hn(e));
2461
2458
  }
2462
2459
  function L() {
2463
- return Ys();
2460
+ return Hs();
2464
2461
  }
2465
- function Xs(t, e) {
2462
+ function Zs(t, e) {
2466
2463
  return t.localeCompare(e);
2467
2464
  }
2468
- function eo() {
2469
- let t = Xs;
2465
+ function Xs() {
2466
+ let t = Zs;
2470
2467
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
2471
2468
  try {
2472
2469
  t = Intl.Collator("en-US").compare;
@@ -2474,10 +2471,10 @@ function eo() {
2474
2471
  }
2475
2472
  return t;
2476
2473
  }
2477
- const to = eo();
2478
- let no = 0;
2474
+ const eo = Xs();
2475
+ let to = 0;
2479
2476
  function Ke(t) {
2480
- return yt(`_${t}`, no++);
2477
+ return yt(`_${t}`, to++);
2481
2478
  }
2482
2479
  function yt(t, e) {
2483
2480
  return `?${t}-${e}`;
@@ -2487,28 +2484,28 @@ class Ae extends Error {
2487
2484
  super(e), this.name = "AttrNotFoundError";
2488
2485
  }
2489
2486
  }
2490
- function ro(t, e) {
2491
- const n = Br(t, e);
2487
+ function no(t, e) {
2488
+ const n = Wr(t, e);
2492
2489
  if (!n)
2493
2490
  throw new Ae(`Could not find id attr for ${e}`);
2494
2491
  return n;
2495
2492
  }
2496
- function Jn(t, e, n, r) {
2497
- return [io(t, e, n, r)];
2493
+ function Yn(t, e, n, r) {
2494
+ return [ro(t, e, n, r)];
2498
2495
  }
2499
- function io(t, e, n, r) {
2496
+ function ro(t, e, n, r) {
2500
2497
  return [
2501
2498
  t(n, r),
2502
- ro(e, n).id,
2499
+ no(e, n).id,
2503
2500
  t(n, r),
2504
2501
  t("time", r)
2505
2502
  ];
2506
2503
  }
2507
- function so(t, e, n) {
2504
+ function io(t, e, n) {
2508
2505
  return t.map((r) => r === e ? n : r);
2509
2506
  }
2510
- function Qr(t, e, n, r, i) {
2511
- const s = fe(e, n, i), o = Wr(e, n, i), u = s || o;
2507
+ function Gr(t, e, n, r, i) {
2508
+ const s = fe(e, n, i), o = Vr(e, n, i), u = s || o;
2512
2509
  if (!u)
2513
2510
  throw new Ae(`Could not find attr for ${[n, i]}`);
2514
2511
  if (u["value-type"] !== "ref")
@@ -2526,7 +2523,7 @@ function Qr(t, e, n, r, i) {
2526
2523
  ];
2527
2524
  return [s ? f : d, l, p, u, !!s];
2528
2525
  }
2529
- function Zn(t, e) {
2526
+ function Jn(t, e) {
2530
2527
  if (typeof e != "string")
2531
2528
  return function(o) {
2532
2529
  return !1;
@@ -2536,7 +2533,7 @@ function Zn(t, e) {
2536
2533
  return typeof o != "string" ? !1 : i.test(o);
2537
2534
  };
2538
2535
  }
2539
- function oo(t, e) {
2536
+ function so(t, e) {
2540
2537
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2541
2538
  return e;
2542
2539
  const n = t["checked-data-type"] === "date";
@@ -2577,7 +2574,7 @@ function oo(t, e) {
2577
2574
  }
2578
2575
  };
2579
2576
  if (e.hasOwnProperty("$like")) {
2580
- const r = Zn(!0, e.$like);
2577
+ const r = Jn(!0, e.$like);
2581
2578
  return {
2582
2579
  $comparator: !0,
2583
2580
  $op: function(s) {
@@ -2586,7 +2583,7 @@ function oo(t, e) {
2586
2583
  };
2587
2584
  }
2588
2585
  if (e.hasOwnProperty("$ilike")) {
2589
- const r = Zn(!1, e.$ilike);
2586
+ const r = Jn(!1, e.$ilike);
2590
2587
  return {
2591
2588
  $comparator: !0,
2592
2589
  $op: function(s) {
@@ -2596,8 +2593,8 @@ function oo(t, e) {
2596
2593
  }
2597
2594
  return e;
2598
2595
  }
2599
- function uo(t, e, n, r, i, s) {
2600
- const o = fe(e, n, i), u = Wr(e, n, i), a = o || u;
2596
+ function oo(t, e, n, r, i, s) {
2597
+ const o = fe(e, n, i), u = Vr(e, n, i), a = o || u;
2601
2598
  if (!a)
2602
2599
  throw new Ae(`No attr for etype = ${n} label = ${i}`);
2603
2600
  if (s != null && s.hasOwnProperty("$isNull")) {
@@ -2614,63 +2611,63 @@ function uo(t, e, n, r, i, s) {
2614
2611
  return o ? [
2615
2612
  t(n, r),
2616
2613
  a.id,
2617
- oo(a, s),
2614
+ so(a, s),
2618
2615
  Ke("time")
2619
2616
  ] : [s, a.id, t(n, r), Ke("time")];
2620
2617
  }
2621
- function ao(t, e, n, r, i) {
2618
+ function uo(t, e, n, r, i) {
2622
2619
  const [s, o, u] = i.reduce((a, d) => {
2623
- const [c, f, l] = a, [p, y, b] = Qr(t, e, c, f, d);
2620
+ const [c, f, l] = a, [p, y, b] = Gr(t, e, c, f, d);
2624
2621
  return [p, y, [...l, b]];
2625
2622
  }, [n, r, []]);
2626
2623
  return [s, o, u];
2627
2624
  }
2628
- function Wt(t, e, n, r, i, s) {
2629
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = ao(t, e, n, r, o), f = uo(t, e, a, d, u, s);
2625
+ function Vt(t, e, n, r, i, s) {
2626
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, d, c] = uo(t, e, n, r, o), f = oo(t, e, a, d, u, s);
2630
2627
  return c.concat([f]);
2631
2628
  }
2632
- function co(t, e) {
2629
+ function ao(t, e) {
2633
2630
  return e ? [e].concat(t) : t;
2634
2631
  }
2635
- function fo([t, e]) {
2632
+ function co([t, e]) {
2636
2633
  return t === "or" && Array.isArray(e);
2637
2634
  }
2638
- function lo([t, e]) {
2635
+ function fo([t, e]) {
2639
2636
  return t === "and" && Array.isArray(e);
2640
2637
  }
2641
- function ho(t, e, n) {
2638
+ function lo(t, e, n) {
2642
2639
  return (r, i) => {
2643
2640
  const s = t(r, i);
2644
2641
  return e == s ? s : `${s}-${n}`;
2645
2642
  };
2646
2643
  }
2647
- function Xn(t, e, n, r, i, s) {
2644
+ function Zn(t, e, n, r, i, s) {
2648
2645
  const o = t(r, i), u = s.map((a, d) => {
2649
- const c = ho(t, o, d);
2650
- return Hr(c, n, r, i, a);
2646
+ const c = lo(t, o, d);
2647
+ return Qr(c, n, r, i, a);
2651
2648
  });
2652
2649
  return { [e]: { patterns: u, joinSym: o } };
2653
2650
  }
2654
- function po(t) {
2651
+ function ho(t) {
2655
2652
  const e = [];
2656
2653
  for (let n = 1; n <= t.length; n++)
2657
2654
  e.push(t.slice(0, n));
2658
2655
  return e;
2659
2656
  }
2660
- function er(t, e, n, r, i) {
2661
- return po(i).map((s) => Wt(t, e, n, r, s, { $isNull: !0 }));
2657
+ function Xn(t, e, n, r, i) {
2658
+ return ho(i).map((s) => Vt(t, e, n, r, s, { $isNull: !0 }));
2662
2659
  }
2663
- function Hr(t, e, n, r, i) {
2660
+ function Qr(t, e, n, r, i) {
2664
2661
  return Object.entries(i).flatMap(([s, o]) => {
2662
+ if (co([s, o]))
2663
+ return Zn(t, "or", e, n, r, o);
2665
2664
  if (fo([s, o]))
2666
- return Xn(t, "or", e, n, r, o);
2667
- if (lo([s, o]))
2668
- return Xn(t, "and", e, n, r, o);
2665
+ return Zn(t, "and", e, n, r, o);
2669
2666
  if (s === "$entityIdStartsWith")
2670
2667
  return [];
2671
2668
  const u = s.split(".");
2672
2669
  if (o != null && o.hasOwnProperty("$ne") && (o = Object.assign(Object.assign({}, o), { $not: o.$ne }), delete o.$ne), o != null && o.hasOwnProperty("$not")) {
2673
- const a = Wt(t, e, n, r, u, o), d = er(t, e, n, r, u);
2670
+ const a = Vt(t, e, n, r, u, o), d = Xn(t, e, n, r, u);
2674
2671
  return [
2675
2672
  {
2676
2673
  or: {
@@ -2683,32 +2680,32 @@ function Hr(t, e, n, r, i) {
2683
2680
  return o != null && o.hasOwnProperty("$isNull") && o.$isNull === !0 && u.length > 1 ? [
2684
2681
  {
2685
2682
  or: {
2686
- patterns: er(t, e, n, r, u),
2683
+ patterns: Xn(t, e, n, r, u),
2687
2684
  joinSym: t(n, r)
2688
2685
  }
2689
2686
  }
2690
- ] : Wt(t, e, n, r, u, o);
2687
+ ] : Vt(t, e, n, r, u, o);
2691
2688
  });
2692
2689
  }
2693
- function yo(t, e, n, r) {
2690
+ function po(t, e, n, r) {
2694
2691
  const i = yt;
2695
- return r ? Hr(i, t, e, n, r).concat(Jn(i, t, e, n)) : Jn(i, t, e, n);
2692
+ return r ? Qr(i, t, e, n, r).concat(Yn(i, t, e, n)) : Yn(i, t, e, n);
2696
2693
  }
2697
- function bo(t, e, n) {
2694
+ function yo(t, e, n) {
2698
2695
  return [t(e, n), t("time", n)];
2699
2696
  }
2700
- function _o(t, e, n, r, i, s) {
2701
- const [o, u, a, d, c] = Qr(t, e, n, r, i), f = so(a, t(n, r), s);
2697
+ function bo(t, e, n, r, i, s) {
2698
+ const [o, u, a, d, c] = Gr(t, e, n, r, i), f = io(a, t(n, r), s);
2702
2699
  return [o, u, f, d, c];
2703
2700
  }
2704
- function go(t, e, { etype: n, level: r, form: i }, s) {
2701
+ function _o(t, e, { etype: n, level: r, form: i }, s) {
2705
2702
  const o = Object.keys(i).filter((u) => u !== "$");
2706
2703
  return o.length ? Object.entries(s).map(function([a, d]) {
2707
2704
  return o.map(function(l) {
2708
2705
  var p, y, b;
2709
2706
  const g = !!(e.cardinalityInference && (!((b = (y = (p = e.linkIndex) === null || p === void 0 ? void 0 : p[n]) === null || y === void 0 ? void 0 : y[l]) === null || b === void 0) && b.isSingular));
2710
2707
  try {
2711
- const [m, T, v] = _o(t, e, n, r, l, a), j = Jr(e, {
2708
+ const [m, T, v] = bo(t, e, n, r, l, a), j = Yr(e, {
2712
2709
  etype: m,
2713
2710
  level: T,
2714
2711
  form: i[l],
@@ -2725,48 +2722,48 @@ function go(t, e, { etype: n, level: r, form: i }, s) {
2725
2722
  }, d);
2726
2723
  }) : Object.values(s);
2727
2724
  }
2728
- function To(t, e, n) {
2729
- return n === "string" ? to(t, e) : t > e ? 1 : -1;
2725
+ function go(t, e, n) {
2726
+ return n === "string" ? eo(t, e) : t > e ? 1 : -1;
2730
2727
  }
2731
2728
  function Fe(t, e, n, r, i) {
2732
- return e === r || e == null && r == null ? Zs(t, n) : r == null ? 1 : e == null ? -1 : To(e, r, i);
2729
+ return e === r || e == null && r == null ? Js(t, n) : r == null ? 1 : e == null ? -1 : go(e, r, i);
2733
2730
  }
2734
2731
  function lt([t, e], [n, r], i) {
2735
2732
  return Fe(t, e, n, r, i);
2736
2733
  }
2737
- function Bt(t) {
2734
+ function Wt(t) {
2738
2735
  return t == null ? t : new Date(t).getTime();
2739
2736
  }
2740
- function mo(t, e, n, r) {
2737
+ function To(t, e, n, r) {
2741
2738
  var i;
2742
2739
  const [s, o, u, a] = t, d = n === "desc" ? 1 : -1;
2743
2740
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
2744
2741
  return lt(r, [s, a], null) === d;
2745
- const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? Bt(f) : f, y = l === "date" ? Bt(u) : u;
2742
+ const [c, f] = r, l = e["checked-data-type"], p = l === "date" ? Wt(f) : f, y = l === "date" ? Wt(u) : u;
2746
2743
  return lt([c, p], [s, y], l) === d;
2747
2744
  }
2748
- function wo(t, e) {
2745
+ function mo(t, e) {
2749
2746
  const n = e[1];
2750
2747
  return t.attrs[n];
2751
2748
  }
2752
- function vo(t, e, n) {
2749
+ function wo(t, e, n) {
2753
2750
  const r = Object.keys(n)[0];
2754
2751
  return fe(t, e, r);
2755
2752
  }
2756
- function So(t, e, n, r) {
2753
+ function vo(t, e, n, r) {
2757
2754
  if (n)
2758
- return wo(t, n);
2755
+ return mo(t, n);
2759
2756
  if (r)
2760
- return vo(t, e, r);
2757
+ return wo(t, e, r);
2761
2758
  }
2762
- function Oo(t, e, n) {
2759
+ function So(t, e, n) {
2763
2760
  var r, i;
2764
2761
  if (!Array.isArray(n.fields))
2765
- return Ms(t, e);
2762
+ return Is(t, e);
2766
2763
  const s = /* @__PURE__ */ new Map();
2767
2764
  for (const o of n.fields) {
2768
2765
  const u = fe(t, e, o), a = (r = u == null ? void 0 : u["forward-identity"]) === null || r === void 0 ? void 0 : r[2];
2769
- a && fn(u) && s.set(a, u);
2766
+ a && dn(u) && s.set(a, u);
2770
2767
  }
2771
2768
  if (!s.has("id")) {
2772
2769
  const o = fe(t, e, "id"), u = (i = o == null ? void 0 : o["forward-identity"]) === null || i === void 0 ? void 0 : i[2];
@@ -2774,17 +2771,17 @@ function Oo(t, e, n) {
2774
2771
  }
2775
2772
  return s;
2776
2773
  }
2777
- function Eo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2774
+ function Oo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2778
2775
  var s, o;
2779
- const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Yr(i), d = Ao(i);
2780
- let c = zs(t, r);
2781
- const f = n == null ? void 0 : n["start-cursor"], l = So(t, e, f, u);
2776
+ const u = (s = i == null ? void 0 : i.$) === null || s === void 0 ? void 0 : s.order, a = Hr(i), d = Eo(i);
2777
+ let c = qs(t, r);
2778
+ const f = n == null ? void 0 : n["start-cursor"], l = vo(t, e, f, u);
2782
2779
  if (l && ((o = l == null ? void 0 : l["forward-identity"]) === null || o === void 0 ? void 0 : o[2]) !== "id") {
2783
2780
  const b = l["checked-data-type"] === "date", g = l.id;
2784
2781
  c = c.map(([m]) => {
2785
2782
  var T, v, j, S, I;
2786
2783
  let R = (I = (S = (j = (v = (T = t.eav.get(m)) === null || T === void 0 ? void 0 : T.get(g)) === null || v === void 0 ? void 0 : v.values()) === null || j === void 0 ? void 0 : j.next()) === null || S === void 0 ? void 0 : S.value) === null || I === void 0 ? void 0 : I[2];
2787
- return b && (R = Bt(R)), [m, R];
2784
+ return b && (R = Wt(R)), [m, R];
2788
2785
  });
2789
2786
  }
2790
2787
  c.sort(d === "asc" ? function(g, m) {
@@ -2793,31 +2790,31 @@ function Eo(t, { etype: e, pageInfo: n, dq: r, form: i }) {
2793
2790
  return lt(m, g, l == null ? void 0 : l["checked-data-type"]);
2794
2791
  });
2795
2792
  let p = {};
2796
- const y = Oo(t, e, r);
2793
+ const y = So(t, e, r);
2797
2794
  for (const b of c) {
2798
2795
  const [g] = b;
2799
- if (p[g] || !a && f && l && mo(f, l, d, b))
2796
+ if (p[g] || !a && f && l && To(f, l, d, b))
2800
2797
  continue;
2801
- const m = Is(t, y, g);
2798
+ const m = Ps(t, y, g);
2802
2799
  m && (p[g] = m);
2803
2800
  }
2804
2801
  return p;
2805
2802
  }
2806
- function Ao(t) {
2803
+ function Eo(t) {
2807
2804
  var e;
2808
2805
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2809
2806
  return n && n[Object.keys(n)[0]] || "asc";
2810
2807
  }
2811
- function Yr(t) {
2808
+ function Hr(t) {
2812
2809
  var e, n, r;
2813
2810
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2814
2811
  return !i && !s && !o;
2815
2812
  }
2816
- function ko(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2813
+ function Ao(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2817
2814
  var o, u, a, d, c;
2818
- if (!Yr(r) && (!s || !s["start-cursor"]))
2815
+ if (!Hr(r) && (!s || !s["start-cursor"]))
2819
2816
  return [];
2820
- const f = co(yo(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = bo(yt, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = Eo(t, {
2817
+ const f = ao(po(t, e, n, (o = r.$) === null || o === void 0 ? void 0 : o.where), i), l = yo(yt, e, n), p = (u = r.$) === null || u === void 0 ? void 0 : u.fields, y = Oo(t, {
2821
2818
  etype: e,
2822
2819
  pageInfo: s,
2823
2820
  form: r,
@@ -2830,20 +2827,20 @@ function ko(t, { etype: e, level: n, form: r, join: i, pageInfo: s }) {
2830
2827
  }
2831
2828
  return y;
2832
2829
  }
2833
- function jo(t, e) {
2830
+ function ko(t, e) {
2834
2831
  try {
2835
- return ko(t, e);
2832
+ return Ao(t, e);
2836
2833
  } catch (n) {
2837
2834
  if (n instanceof Ae)
2838
2835
  return {};
2839
2836
  throw n;
2840
2837
  }
2841
2838
  }
2842
- function Jr(t, e) {
2843
- const n = jo(t, e);
2844
- return go(yt, t, e, n);
2839
+ function Yr(t, e) {
2840
+ const n = ko(t, e);
2841
+ return _o(yt, t, e, n);
2845
2842
  }
2846
- function Co(t) {
2843
+ function jo(t) {
2847
2844
  const e = {};
2848
2845
  for (const [n, r] of Object.entries(t))
2849
2846
  e[n] = {
@@ -2854,18 +2851,18 @@ function Co(t) {
2854
2851
  };
2855
2852
  return e;
2856
2853
  }
2857
- function Zr({ store: t, pageInfo: e, aggregate: n }, r) {
2854
+ function Jr({ store: t, pageInfo: e, aggregate: n }, r) {
2858
2855
  const s = { data: Object.keys(r).reduce(function(u, a) {
2859
- return n != null && n[a] || a === "$$ruleParams" || (u[a] = Jr(t, {
2856
+ return n != null && n[a] || a === "$$ruleParams" || (u[a] = Yr(t, {
2860
2857
  etype: a,
2861
2858
  form: r[a],
2862
2859
  level: 0,
2863
2860
  pageInfo: e == null ? void 0 : e[a]
2864
2861
  })), u;
2865
2862
  }, {}) };
2866
- return e && (s.pageInfo = Co(e)), n && (s.aggregate = n), s;
2863
+ return e && (s.pageInfo = jo(e)), n && (s.aggregate = n), s;
2867
2864
  }
2868
- function Po() {
2865
+ function Co() {
2869
2866
  const e = {
2870
2867
  __etype: 1,
2871
2868
  __ops: 1,
@@ -2879,8 +2876,8 @@ function Po() {
2879
2876
  };
2880
2877
  return new Set(Object.keys(e));
2881
2878
  }
2882
- const Io = Po();
2883
- function Gt(t, e, n) {
2879
+ const Po = Co();
2880
+ function Bt(t, e, n) {
2884
2881
  const r = {
2885
2882
  __etype: t,
2886
2883
  __ops: n
@@ -2891,8 +2888,8 @@ function Gt(t, e, n) {
2891
2888
  return n;
2892
2889
  if (s === "__etype")
2893
2890
  return t;
2894
- if (Io.has(s))
2895
- return (o, u) => Gt(t, e, [
2891
+ if (Po.has(s))
2892
+ return (o, u) => Bt(t, e, [
2896
2893
  ...n,
2897
2894
  u ? [s, t, e, o, u] : [s, t, e, o]
2898
2895
  ]);
@@ -2902,11 +2899,11 @@ function Gt(t, e, n) {
2902
2899
  function ht(t) {
2903
2900
  return t.startsWith("lookup__");
2904
2901
  }
2905
- function Xr(t) {
2902
+ function Zr(t) {
2906
2903
  const [e, n, ...r] = t.split("__");
2907
2904
  return [n, JSON.parse(r.join("__"))];
2908
2905
  }
2909
- function Mo(t) {
2906
+ function Io(t) {
2910
2907
  return new Proxy({
2911
2908
  __etype: t
2912
2909
  }, {
@@ -2914,22 +2911,22 @@ function Mo(t) {
2914
2911
  if (n === "__etype")
2915
2912
  return t;
2916
2913
  const r = n;
2917
- return ht(r) ? Gt(t, Xr(r), []) : Gt(t, r, []);
2914
+ return ht(r) ? Bt(t, Zr(r), []) : Bt(t, r, []);
2918
2915
  }
2919
2916
  });
2920
2917
  }
2921
- function pn() {
2918
+ function hn() {
2922
2919
  return new Proxy({}, {
2923
2920
  get(t, e) {
2924
- return Mo(e);
2921
+ return Io(e);
2925
2922
  }
2926
2923
  });
2927
2924
  }
2928
- pn();
2929
- function Ro(t) {
2925
+ hn();
2926
+ function Mo(t) {
2930
2927
  return t.__ops;
2931
2928
  }
2932
- function $o(t, e) {
2929
+ function Ro(t, e) {
2933
2930
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2934
2931
  for (const o of e) {
2935
2932
  const u = n[o];
@@ -2963,7 +2960,7 @@ function _e(t, e, n) {
2963
2960
  return o === e && u === n;
2964
2961
  });
2965
2962
  }
2966
- function xo(t) {
2963
+ function $o(t) {
2967
2964
  if (Array.isArray(t))
2968
2965
  return t;
2969
2966
  const e = Object.entries(t);
@@ -2971,38 +2968,38 @@ function xo(t) {
2971
2968
  throw new Error("lookup must be an object with a single unique attr and value.");
2972
2969
  return e[0];
2973
2970
  }
2974
- function Qt(t, e, n) {
2971
+ function Gt(t, e, n) {
2975
2972
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2976
2973
  // before assuming it's a ref lookup.
2977
2974
  !K(t, e, n);
2978
2975
  }
2979
- function Ht(t) {
2976
+ function Qt(t) {
2980
2977
  const [e, n, ...r] = t.split(".");
2981
2978
  if (r.length > 0 || n !== "id")
2982
2979
  throw new Error(`${t} is not a valid lookup attribute.`);
2983
2980
  return e;
2984
2981
  }
2985
- function Do(t, e, n) {
2986
- if (!Qt(t, e, n))
2982
+ function xo(t, e, n) {
2983
+ if (!Gt(t, e, n))
2987
2984
  return K(t, e, n);
2988
- const r = Ht(n), i = K(t, e, r) || _e(t, e, r);
2985
+ const r = Qt(n), i = K(t, e, r) || _e(t, e, r);
2989
2986
  if (i && i["value-type"] !== "ref")
2990
2987
  throw new Error(`${n} does not reference a valid link attribute.`);
2991
2988
  return i;
2992
2989
  }
2993
- function Yt(t) {
2994
- return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Xr(t) : xo(t);
2990
+ function Ht(t) {
2991
+ return typeof t == "string" && !ht(t) ? null : typeof t == "string" && ht(t) ? Zr(t) : $o(t);
2995
2992
  }
2996
2993
  function Q(t, e, n) {
2997
- const r = Yt(n);
2994
+ const r = Ht(n);
2998
2995
  if (r === null)
2999
2996
  return n;
3000
- const [i, s] = r, o = Do(t, e, i);
2997
+ const [i, s] = r, o = xo(t, e, i);
3001
2998
  if (!o || !o["unique?"])
3002
2999
  throw new Error(`${i} is not a unique attribute.`);
3003
3000
  return [o.id, s];
3004
3001
  }
3005
- function ei(t, e, n, r) {
3002
+ function Xr(t, e, n, r) {
3006
3003
  const i = Q(t, e, n);
3007
3004
  return Array.isArray(i) ? [[
3008
3005
  "add-triple",
@@ -3011,7 +3008,7 @@ function ei(t, e, n, r) {
3011
3008
  i
3012
3009
  ]].concat(r) : r;
3013
3010
  }
3014
- function Uo({ attrs: t }, [e, n, r]) {
3011
+ function Do({ attrs: t }, [e, n, r]) {
3015
3012
  const i = Object.entries(r).flatMap(([s, o]) => {
3016
3013
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
3017
3014
  return u.map((c) => a ? [
@@ -3026,9 +3023,9 @@ function Uo({ attrs: t }, [e, n, r]) {
3026
3023
  Q(t, e, n)
3027
3024
  ]);
3028
3025
  });
3029
- return ei(t, e, n, i);
3026
+ return Xr(t, e, n, i);
3030
3027
  }
3031
- function Lo({ attrs: t }, [e, n, r]) {
3028
+ function Uo({ attrs: t }, [e, n, r]) {
3032
3029
  const i = Object.entries(r).flatMap(([s, o]) => {
3033
3030
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), d = _e(t, e, s);
3034
3031
  return u.map((c) => a ? [
@@ -3043,9 +3040,9 @@ function Lo({ attrs: t }, [e, n, r]) {
3043
3040
  Q(t, e, n)
3044
3041
  ]);
3045
3042
  });
3046
- return ei(t, e, n, i);
3043
+ return Xr(t, e, n, i);
3047
3044
  }
3048
- function Fo(t, e, n) {
3045
+ function Lo(t, e, n) {
3049
3046
  if (Array.isArray(n)) {
3050
3047
  const [r, i] = n;
3051
3048
  for (const s of t || []) {
@@ -3067,18 +3064,18 @@ function Fo(t, e, n) {
3067
3064
  }
3068
3065
  return !1;
3069
3066
  }
3070
- function ti({ stores: t, attrs: e }, [n, r, i, s]) {
3071
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Fo(t, n, r) ? { mode: "update" } : null;
3067
+ function ei({ stores: t, attrs: e }, [n, r, i, s]) {
3068
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Lo(t, n, r) ? { mode: "update" } : null;
3072
3069
  }
3073
- function No(t, e) {
3074
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = cn(o), d = Q(r, i, s);
3070
+ function Fo(t, e) {
3071
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s);
3075
3072
  return [["id", d]].concat(Object.entries(a)).map(([f, l]) => {
3076
3073
  const p = K(r, i, f);
3077
3074
  return p["checked-data-type"] === "date" && t.useDateObjects && (l = pt(l)), ["add-triple", d, p.id, l, { mode: "create" }];
3078
3075
  });
3079
3076
  }
3080
- function Ko(t, e) {
3081
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = cn(o), d = Q(r, i, s), c = ti(t, [i, d, o, u]);
3077
+ function No(t, e) {
3078
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]);
3082
3079
  return [["id", d]].concat(Object.entries(a)).map(([l, p]) => {
3083
3080
  const y = K(r, i, l);
3084
3081
  return y["checked-data-type"] === "date" && t.useDateObjects && (p = pt(p)), [
@@ -3090,11 +3087,11 @@ function Ko(t, e) {
3090
3087
  ];
3091
3088
  });
3092
3089
  }
3093
- function qo({ attrs: t }, [e, n]) {
3090
+ function Ko({ attrs: t }, [e, n]) {
3094
3091
  return [["delete-entity", Q(t, e, n), e]];
3095
3092
  }
3096
- function zo(t, e) {
3097
- const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = cn(o), d = Q(r, i, s), c = ti(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
3093
+ function qo(t, e) {
3094
+ const { stores: n, attrs: r } = t, [i, s, o, u] = e, a = an(o), d = Q(r, i, s), c = ei(t, [i, d, o, u]), f = Object.entries(a).map(([p, y]) => {
3098
3095
  const b = K(r, i, p);
3099
3096
  return [
3100
3097
  "deep-merge-triple",
@@ -3112,38 +3109,38 @@ function zo(t, e) {
3112
3109
  ...c ? [c] : []
3113
3110
  ]].concat(f);
3114
3111
  }
3115
- function Vo({ attrs: t }, [e, n, r]) {
3112
+ function zo({ attrs: t }, [e, n, r]) {
3116
3113
  return [["rule-params", Q(t, e, n), e, r]];
3117
3114
  }
3118
- function Wo(t) {
3115
+ function Vo(t) {
3119
3116
  const [e, n, r, i, s] = t;
3120
3117
  if (!i)
3121
3118
  return t;
3122
3119
  const o = Object.assign({}, i);
3123
3120
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
3124
3121
  }
3125
- function Bo(t, e) {
3126
- const [n, ...r] = Wo(e);
3122
+ function Wo(t, e) {
3123
+ const [n, ...r] = Vo(e);
3127
3124
  switch (n) {
3128
3125
  case "merge":
3129
- return zo(t, r);
3126
+ return qo(t, r);
3130
3127
  case "create":
3131
- return No(t, r);
3128
+ return Fo(t, r);
3132
3129
  case "update":
3133
- return Ko(t, r);
3130
+ return No(t, r);
3134
3131
  case "link":
3135
- return Uo(t, r);
3132
+ return Do(t, r);
3136
3133
  case "unlink":
3137
- return Lo(t, r);
3134
+ return Uo(t, r);
3138
3135
  case "delete":
3139
- return qo(t, r);
3136
+ return Ko(t, r);
3140
3137
  case "ruleParams":
3141
- return Vo(t, r);
3138
+ return zo(t, r);
3142
3139
  default:
3143
3140
  throw new Error(`unsupported action ${n}`);
3144
3141
  }
3145
3142
  }
3146
- function Go(t) {
3143
+ function Bo(t) {
3147
3144
  switch (t) {
3148
3145
  case "string":
3149
3146
  case "date":
@@ -3154,14 +3151,14 @@ function Go(t) {
3154
3151
  return;
3155
3152
  }
3156
3153
  }
3157
- function Qo(t, e, n) {
3154
+ function Go(t, e, n) {
3158
3155
  var r, i;
3159
3156
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
3160
3157
  if (n === "id")
3161
3158
  return null;
3162
3159
  if (!s)
3163
3160
  throw new Error(`${e}.${n} does not exist in your schema`);
3164
- const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Go(s == null ? void 0 : s.valueType);
3161
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Bo(s == null ? void 0 : s.valueType);
3165
3162
  return {
3166
3163
  "index?": u,
3167
3164
  "unique?": o,
@@ -3169,14 +3166,14 @@ function Qo(t, e, n) {
3169
3166
  };
3170
3167
  }
3171
3168
  function nt(t, e, n, r) {
3172
- const i = t ? Qo(t, e, n) : null, s = L(), u = [L(), e, n];
3169
+ const i = t ? Go(t, e, n) : null, s = L(), u = [L(), e, n];
3173
3170
  return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
3174
3171
  }
3175
- function Ho(t, e, n) {
3172
+ function Qo(t, e, n) {
3176
3173
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
3177
3174
  }
3178
- function Yo(t, e, n) {
3179
- const r = Ho(t, e, n);
3175
+ function Ho(t, e, n) {
3176
+ const r = Qo(t, e, n);
3180
3177
  if (!r)
3181
3178
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
3182
3179
  const { forward: i, reverse: s } = r;
@@ -3189,11 +3186,11 @@ function Yo(t, e, n) {
3189
3186
  "on-delete-reverse": s.onDelete
3190
3187
  };
3191
3188
  }
3192
- function tr(t, e, n, r) {
3193
- const i = t ? Yo(t, e, n) : null, s = L(), o = [L(), e, n], u = [L(), n, e];
3189
+ function er(t, e, n, r) {
3190
+ const i = t ? Ho(t, e, n) : null, s = L(), o = [L(), e, n], u = [L(), n, e];
3194
3191
  return Object.assign(Object.assign({ id: s, "forward-identity": o, "reverse-identity": u, "value-type": "ref", cardinality: "many", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
3195
3192
  }
3196
- const Jo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Zo = /* @__PURE__ */ new Set(["link", "unlink"]), Xo = /* @__PURE__ */ new Set(["create", "update", "merge"]), eu = /* @__PURE__ */ new Set([
3193
+ const Yo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Jo = /* @__PURE__ */ new Set(["link", "unlink"]), Zo = /* @__PURE__ */ new Set(["create", "update", "merge"]), Xo = /* @__PURE__ */ new Set([
3197
3194
  "link",
3198
3195
  "unlink",
3199
3196
  "create",
@@ -3201,17 +3198,17 @@ const Jo = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
3201
3198
  "merge",
3202
3199
  "delete",
3203
3200
  "ruleParams"
3204
- ]), Jt = { "unique?": !0, "index?": !0 }, tu = Object.assign(Object.assign({}, Jt), { cardinality: "one" });
3205
- function nu(t) {
3201
+ ]), Yt = { "unique?": !0, "index?": !0 }, eu = Object.assign(Object.assign({}, Yt), { cardinality: "one" });
3202
+ function tu(t) {
3206
3203
  const e = [], [n, r, i, s] = t;
3207
- if (!eu.has(n))
3204
+ if (!Xo.has(n))
3208
3205
  return e;
3209
- const o = Yt(i);
3206
+ const o = Ht(i);
3210
3207
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
3211
3208
  for (const [u, a] of Object.entries(s)) {
3212
3209
  const d = Array.isArray(a) ? a : [a];
3213
3210
  for (const c of d) {
3214
- const f = Yt(c);
3211
+ const f = Ht(c);
3215
3212
  f && e.push({
3216
3213
  etype: r,
3217
3214
  lookupPair: f,
@@ -3221,7 +3218,7 @@ function nu(t) {
3221
3218
  }
3222
3219
  return e;
3223
3220
  }
3224
- function ru({ attrs: t, schema: e }, n) {
3221
+ function nu({ attrs: t, schema: e }, n) {
3225
3222
  var r, i;
3226
3223
  const [s, o, u] = [/* @__PURE__ */ new Set(), Object.assign({}, t), []];
3227
3224
  function a(f) {
@@ -3232,47 +3229,47 @@ function ru({ attrs: t, schema: e }, n) {
3232
3229
  }
3233
3230
  function c(f, l) {
3234
3231
  const p = K(o, f, l), y = _e(o, f, l);
3235
- d(p), d(y), !p && !y && a(tr(e, f, l, tu));
3232
+ d(p), d(y), !p && !y && a(er(e, f, l, eu));
3236
3233
  }
3237
3234
  for (const f of n)
3238
- for (const { etype: l, lookupPair: p, linkLabel: y } of nu(f)) {
3235
+ for (const { etype: l, lookupPair: p, linkLabel: y } of tu(f)) {
3239
3236
  const b = p[0];
3240
3237
  if (y) {
3241
3238
  c(l, y);
3242
3239
  const g = K(o, l, y), m = _e(o, l, y);
3243
3240
  d(g), d(m);
3244
3241
  const T = ((r = g == null ? void 0 : g["reverse-identity"]) === null || r === void 0 ? void 0 : r[1]) || ((i = m == null ? void 0 : m["forward-identity"]) === null || i === void 0 ? void 0 : i[1]) || y;
3245
- if (Qt(o, T, b))
3246
- c(T, Ht(b));
3242
+ if (Gt(o, T, b))
3243
+ c(T, Qt(b));
3247
3244
  else {
3248
3245
  const v = K(o, T, b);
3249
- v || a(nt(e, T, b, Jt)), d(v);
3246
+ v || a(nt(e, T, b, Yt)), d(v);
3250
3247
  }
3251
- } else if (Qt(o, l, b))
3252
- c(l, Ht(b));
3248
+ } else if (Gt(o, l, b))
3249
+ c(l, Qt(b));
3253
3250
  else {
3254
3251
  const g = K(o, l, b);
3255
- g || a(nt(e, l, b, Jt)), d(g);
3252
+ g || a(nt(e, l, b, Yt)), d(g);
3256
3253
  }
3257
3254
  }
3258
3255
  for (const f of n) {
3259
3256
  const [l, p, y, b] = f;
3260
- if (Jo.has(l)) {
3257
+ if (Yo.has(l)) {
3261
3258
  const g = K(o, p, "id");
3262
3259
  d(g), g || a(nt(e, p, "id", { "unique?": !0 }));
3263
3260
  for (const m of Object.keys(b)) {
3264
3261
  const T = K(o, p, m);
3265
- if (d(T), Xo.has(l) && (T || a(nt(e, p, m, m === "id" ? { "unique?": !0 } : null))), Zo.has(l)) {
3262
+ if (d(T), Zo.has(l) && (T || a(nt(e, p, m, m === "id" ? { "unique?": !0 } : null))), Jo.has(l)) {
3266
3263
  const v = _e(o, p, m);
3267
- !T && !v && a(tr(e, p, m)), d(v);
3264
+ !T && !v && a(er(e, p, m)), d(v);
3268
3265
  }
3269
3266
  }
3270
3267
  }
3271
3268
  }
3272
3269
  return [o, u];
3273
3270
  }
3274
- function iu(t, e) {
3275
- const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Ro(a)), [i, s] = ru(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Bo(o, a));
3271
+ function ru(t, e) {
3272
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => Mo(a)), [i, s] = nu(t, r), o = Object.assign(Object.assign({}, t), { attrs: i }), u = r.flatMap((a) => Wo(o, a));
3276
3273
  return [...s, ...u];
3277
3274
  }
3278
3275
  var re = function(t, e, n, r) {
@@ -3302,15 +3299,15 @@ var re = function(t, e, n, r) {
3302
3299
  d((r = r.apply(t, e || [])).next());
3303
3300
  });
3304
3301
  };
3305
- function nr(t, e) {
3302
+ function tr(t, e) {
3306
3303
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
3307
3304
  }
3308
3305
  const qe = "__meta";
3309
- class su {
3306
+ class iu {
3310
3307
  constructor(e, n) {
3311
3308
  }
3312
3309
  }
3313
- class Zt {
3310
+ class Jt {
3314
3311
  constructor(e) {
3315
3312
  var n, r;
3316
3313
  this._subs = [], this._nextSave = null, this._nextGc = null, this._pendingSaveKeys = /* @__PURE__ */ new Set(), this._loadedKeys = /* @__PURE__ */ new Set(), this._version = 0, this._meta = {
@@ -3504,7 +3501,7 @@ class Zt {
3504
3501
  gc() {
3505
3502
  this._nextGc || (this._nextGc = setTimeout(
3506
3503
  () => {
3507
- nr(() => {
3504
+ tr(() => {
3508
3505
  this._nextGc = null, this._gc();
3509
3506
  }, 30 * 1e3);
3510
3507
  },
@@ -3519,7 +3516,7 @@ class Zt {
3519
3516
  return;
3520
3517
  }
3521
3518
  this._nextSave = setTimeout(() => {
3522
- nr(() => {
3519
+ tr(() => {
3523
3520
  this._nextSave = null, this._writeToStorage(e).then(n).catch(r);
3524
3521
  }, this._idleCallbackMaxWaitMs);
3525
3522
  }, this._saveThrottleMs);
@@ -3581,13 +3578,13 @@ var oe = function(t, e, n, r) {
3581
3578
  d((r = r.apply(t, e || [])).next());
3582
3579
  });
3583
3580
  };
3584
- const ou = 6, uu = ["kv", "querySubs", "syncSubs"];
3585
- function au(t) {
3581
+ const su = 6, ou = ["kv", "querySubs", "syncSubs"];
3582
+ function uu(t) {
3586
3583
  return function(n) {
3587
3584
  console.error("Error in IndexedDB event", { source: t, event: n });
3588
3585
  };
3589
3586
  }
3590
- function cu(t) {
3587
+ function au(t) {
3591
3588
  return oe(this, void 0, void 0, function* () {
3592
3589
  return new Promise((e) => {
3593
3590
  const n = indexedDB.open(t);
@@ -3603,7 +3600,7 @@ function cu(t) {
3603
3600
  });
3604
3601
  });
3605
3602
  }
3606
- function du(t, e, n) {
3603
+ function cu(t, e, n) {
3607
3604
  return oe(this, void 0, void 0, function* () {
3608
3605
  const r = (
3609
3606
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3639,7 +3636,7 @@ function du(t, e, n) {
3639
3636
  });
3640
3637
  });
3641
3638
  }
3642
- function rr(t, e, n) {
3639
+ function nr(t, e, n) {
3643
3640
  return oe(this, void 0, void 0, function* () {
3644
3641
  const r = n.put(e, t);
3645
3642
  return new Promise((i, s) => {
@@ -3647,9 +3644,9 @@ function rr(t, e, n) {
3647
3644
  });
3648
3645
  });
3649
3646
  }
3650
- function fu(t, e) {
3647
+ function du(t, e) {
3651
3648
  return oe(this, void 0, void 0, function* () {
3652
- const n = yield cu(`instant_${t}_5`);
3649
+ const n = yield au(`instant_${t}_5`);
3653
3650
  if (!n)
3654
3651
  return;
3655
3652
  const r = yield new Promise((c, f) => {
@@ -3672,12 +3669,12 @@ function fu(t, e) {
3672
3669
  for (const [c, f] of r)
3673
3670
  switch (c) {
3674
3671
  case "querySubs": {
3675
- const l = du(c, f, o);
3672
+ const l = cu(c, f, o);
3676
3673
  u.push(l);
3677
3674
  break;
3678
3675
  }
3679
3676
  default: {
3680
- const l = rr(c, f, s);
3677
+ const l = nr(c, f, s);
3681
3678
  u.push(l);
3682
3679
  const p = {
3683
3680
  createdAt: Date.now(),
@@ -3688,16 +3685,16 @@ function fu(t, e) {
3688
3685
  break;
3689
3686
  }
3690
3687
  }
3691
- const d = rr(qe, a, s);
3688
+ const d = nr(qe, a, s);
3692
3689
  u.push(d), yield Promise.all(u), yield new Promise((c, f) => {
3693
3690
  i.oncomplete = (l) => c(l), i.onerror = (l) => f(l), i.onabort = (l) => f(l);
3694
3691
  });
3695
3692
  });
3696
3693
  }
3697
- const ir = /* @__PURE__ */ new Map();
3698
- class ni extends su {
3694
+ const rr = /* @__PURE__ */ new Map();
3695
+ class ti extends iu {
3699
3696
  constructor(e, n) {
3700
- super(e, n), this.dbName = `instant_${e}_${ou}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3697
+ super(e, n), this.dbName = `instant_${e}_${su}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3701
3698
  }
3702
3699
  _init() {
3703
3700
  return new Promise((e, n) => {
@@ -3708,12 +3705,12 @@ class ni extends su {
3708
3705
  }, i.onsuccess = (s) => {
3709
3706
  const u = s.target.result;
3710
3707
  if (r) {
3711
- const a = fu(this._appId, u).catch((d) => {
3712
- au("Error upgrading store from version 5 to 6.")(d);
3708
+ const a = du(this._appId, u).catch((d) => {
3709
+ uu("Error upgrading store from version 5 to 6.")(d);
3713
3710
  });
3714
- ir.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3711
+ rr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3715
3712
  } else {
3716
- const a = ir.get(this.dbName);
3713
+ const a = rr.get(this.dbName);
3717
3714
  a ? a.then(() => e(u)).catch(() => e(u)) : e(u);
3718
3715
  }
3719
3716
  }, i.onupgradeneeded = (s) => {
@@ -3723,7 +3720,7 @@ class ni extends su {
3723
3720
  }
3724
3721
  _upgradeStore(e) {
3725
3722
  const r = e.target.result;
3726
- for (const i of uu)
3723
+ for (const i of ou)
3727
3724
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3728
3725
  }
3729
3726
  getItem(e) {
@@ -3798,7 +3795,7 @@ class ni extends su {
3798
3795
  });
3799
3796
  }
3800
3797
  }
3801
- var lu = function(t, e, n, r) {
3798
+ var fu = function(t, e, n, r) {
3802
3799
  function i(s) {
3803
3800
  return s instanceof n ? s : new n(function(o) {
3804
3801
  o(s);
@@ -3825,9 +3822,9 @@ var lu = function(t, e, n, r) {
3825
3822
  d((r = r.apply(t, e || [])).next());
3826
3823
  });
3827
3824
  };
3828
- class ri {
3825
+ class ni {
3829
3826
  static getIsOnline() {
3830
- return lu(this, void 0, void 0, function* () {
3827
+ return fu(this, void 0, void 0, function* () {
3831
3828
  return navigator.onLine;
3832
3829
  });
3833
3830
  }
@@ -3852,7 +3849,7 @@ class ke extends Error {
3852
3849
  return "InstantError";
3853
3850
  }
3854
3851
  }
3855
- var hu = function(t, e, n, r) {
3852
+ var lu = function(t, e, n, r) {
3856
3853
  function i(s) {
3857
3854
  return s instanceof n ? s : new n(function(o) {
3858
3855
  o(s);
@@ -3892,7 +3889,7 @@ class bt extends ke {
3892
3889
  }
3893
3890
  }
3894
3891
  function te(t, e) {
3895
- return hu(this, void 0, void 0, function* () {
3892
+ return lu(this, void 0, void 0, function* () {
3896
3893
  const n = yield fetch(t, e), r = yield n.json();
3897
3894
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new bt({ status: n.status, body: r }));
3898
3895
  });
@@ -3924,14 +3921,14 @@ var Pe = function(t, e, n, r) {
3924
3921
  d((r = r.apply(t, e || [])).next());
3925
3922
  });
3926
3923
  };
3927
- function pu({ apiURI: t, appId: e, email: n }) {
3924
+ function hu({ apiURI: t, appId: e, email: n }) {
3928
3925
  return te(`${t}/runtime/auth/send_magic_code`, {
3929
3926
  method: "POST",
3930
3927
  headers: { "content-type": "application/json" },
3931
3928
  body: JSON.stringify({ "app-id": e, email: n })
3932
3929
  });
3933
3930
  }
3934
- function yu(t) {
3931
+ function pu(t) {
3935
3932
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3936
3933
  return yield te(`${e}/runtime/auth/verify_magic_code`, {
3937
3934
  method: "POST",
@@ -3944,7 +3941,7 @@ function yu(t) {
3944
3941
  });
3945
3942
  });
3946
3943
  }
3947
- function bu(t) {
3944
+ function yu(t) {
3948
3945
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3949
3946
  return yield te(`${e}/runtime/auth/verify_refresh_token`, {
3950
3947
  method: "POST",
@@ -3956,7 +3953,7 @@ function bu(t) {
3956
3953
  });
3957
3954
  });
3958
3955
  }
3959
- function _u(t) {
3956
+ function bu(t) {
3960
3957
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3961
3958
  return yield te(`${e}/runtime/auth/sign_in_guest`, {
3962
3959
  method: "POST",
@@ -3967,7 +3964,7 @@ function _u(t) {
3967
3964
  });
3968
3965
  });
3969
3966
  }
3970
- function sr(t) {
3967
+ function ir(t) {
3971
3968
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, code: r, codeVerifier: i, refreshToken: s }) {
3972
3969
  return yield te(`${e}/runtime/oauth/token`, {
3973
3970
  method: "POST",
@@ -3981,7 +3978,7 @@ function sr(t) {
3981
3978
  });
3982
3979
  });
3983
3980
  }
3984
- function gu(t) {
3981
+ function _u(t) {
3985
3982
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3986
3983
  return yield te(`${e}/runtime/oauth/id_token`, {
3987
3984
  method: "POST",
@@ -3996,7 +3993,7 @@ function gu(t) {
3996
3993
  });
3997
3994
  });
3998
3995
  }
3999
- function Tu(t) {
3996
+ function gu(t) {
4000
3997
  return Pe(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
4001
3998
  return yield te(`${e}/runtime/signout`, {
4002
3999
  method: "POST",
@@ -4037,7 +4034,7 @@ var Ge = function(t, e, n, r) {
4037
4034
  d((r = r.apply(t, e || [])).next());
4038
4035
  });
4039
4036
  };
4040
- function mu(t) {
4037
+ function Tu(t) {
4041
4038
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
4042
4039
  const a = {
4043
4040
  app_id: n,
@@ -4052,7 +4049,7 @@ function mu(t) {
4052
4049
  });
4053
4050
  });
4054
4051
  }
4055
- function wu(t) {
4052
+ function mu(t) {
4056
4053
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4057
4054
  const { data: s } = yield te(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4058
4055
  method: "DELETE",
@@ -4064,7 +4061,7 @@ function wu(t) {
4064
4061
  return s;
4065
4062
  });
4066
4063
  }
4067
- function vu(t) {
4064
+ function wu(t) {
4068
4065
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
4069
4066
  const { data: o } = yield te(`${e}/storage/signed-upload-url`, {
4070
4067
  method: "POST",
@@ -4080,7 +4077,7 @@ function vu(t) {
4080
4077
  return o;
4081
4078
  });
4082
4079
  }
4083
- function Su(t, e) {
4080
+ function vu(t, e) {
4084
4081
  return Ge(this, void 0, void 0, function* () {
4085
4082
  return (yield fetch(t, {
4086
4083
  method: "PUT",
@@ -4091,7 +4088,7 @@ function Su(t, e) {
4091
4088
  })).ok;
4092
4089
  });
4093
4090
  }
4094
- function Ou(t) {
4091
+ function Su(t) {
4095
4092
  return Ge(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
4096
4093
  const { data: s } = yield te(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
4097
4094
  method: "GET",
@@ -4103,9 +4100,9 @@ function Ou(t) {
4103
4100
  return s;
4104
4101
  });
4105
4102
  }
4106
- let yn = !1, ii = !1, si = !1;
4107
- typeof window < "u" && typeof window.localStorage < "u" && (yn = !!window.localStorage.getItem("devBackend"), ii = !!window.localStorage.getItem("__instantLogging"), si = !!window.localStorage.getItem("__devtoolLocalDash"));
4108
- function or(t, e) {
4103
+ let pn = !1, ri = !1, ii = !1;
4104
+ typeof window < "u" && typeof window.localStorage < "u" && (pn = !!window.localStorage.getItem("devBackend"), ri = !!window.localStorage.getItem("__instantLogging"), ii = !!window.localStorage.getItem("__devtoolLocalDash"));
4105
+ function sr(t, e) {
4109
4106
  if (!e)
4110
4107
  return t;
4111
4108
  const n = {};
@@ -4113,33 +4110,33 @@ function or(t, e) {
4113
4110
  n[r] = t[r];
4114
4111
  }), n;
4115
4112
  }
4116
- function Eu(t, e, n) {
4113
+ function Ou(t, e, n) {
4117
4114
  var r, i;
4118
4115
  const s = {
4119
4116
  peers: {}
4120
4117
  };
4121
4118
  if (e && "user" in e ? e.user : !0) {
4122
- const u = or((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
4119
+ const u = sr((r = t.user) !== null && r !== void 0 ? r : {}, e == null ? void 0 : e.keys);
4123
4120
  s.user = Object.assign(Object.assign({}, u), { peerId: n });
4124
4121
  }
4125
4122
  for (const u of Object.keys((i = t.peers) !== null && i !== void 0 ? i : {})) {
4126
4123
  const a = (e == null ? void 0 : e.peers) === void 0, d = Array.isArray(e == null ? void 0 : e.peers) && (e == null ? void 0 : e.peers.includes(u));
4127
4124
  if (a || d) {
4128
- const c = or(t.peers[u], e == null ? void 0 : e.keys);
4125
+ const c = sr(t.peers[u], e == null ? void 0 : e.keys);
4129
4126
  s.peers[u] = Object.assign(Object.assign({}, c), { peerId: u });
4130
4127
  }
4131
4128
  }
4132
4129
  return s;
4133
4130
  }
4134
- function Au(t, e) {
4135
- if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Wn(t.user, e.user)) || !Rr(t.peers, e.peers))
4131
+ function Eu(t, e) {
4132
+ if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !Vn(t.user, e.user)) || !Mr(t.peers, e.peers))
4136
4133
  return !0;
4137
4134
  for (const r of Object.keys(t.peers))
4138
- if (!Wn(t.peers[r], e.peers[r]))
4135
+ if (!Vn(t.peers[r], e.peers[r]))
4139
4136
  return !0;
4140
4137
  return !1;
4141
4138
  }
4142
- class ur {
4139
+ class or {
4143
4140
  constructor() {
4144
4141
  this.promise = new Promise((e, n) => {
4145
4142
  this._resolve = e, this._reject = n;
@@ -4152,20 +4149,20 @@ class ur {
4152
4149
  this._reject(e);
4153
4150
  }
4154
4151
  }
4155
- function oi(t, e = []) {
4152
+ function si(t, e = []) {
4156
4153
  t.forEach((n) => {
4157
4154
  const { data: r } = n, { "datalog-result": i } = r, { "join-rows": s } = i;
4158
4155
  for (const o of s)
4159
4156
  for (const u of o)
4160
4157
  e.push(u);
4161
- oi(n["child-nodes"], e);
4158
+ si(n["child-nodes"], e);
4162
4159
  });
4163
4160
  }
4164
- function ar(t) {
4161
+ function ur(t) {
4165
4162
  const e = [];
4166
- return oi(t, e), e;
4163
+ return si(t, e), e;
4167
4164
  }
4168
- function cr(t) {
4165
+ function ar(t) {
4169
4166
  return Object.values(t.links).reduce((e, n) => {
4170
4167
  var r, i, s, o;
4171
4168
  return (r = e[s = n.forward.on]) !== null && r !== void 0 || (e[s] = {}), e[n.forward.on][n.forward.label] = {
@@ -4179,8 +4176,8 @@ function cr(t) {
4179
4176
  }, e;
4180
4177
  }, {});
4181
4178
  }
4182
- const ui = "v0.22.68-experimental.drewh-entity-caching.19642167601.1";
4183
- function ku(t, e) {
4179
+ const oi = "v0.22.68";
4180
+ function Au(t, e) {
4184
4181
  return {
4185
4182
  info: t ? (...n) => console.info(...n, e()) : () => {
4186
4183
  },
@@ -4218,7 +4215,7 @@ class M extends Error {
4218
4215
  super(r), this.name = "QueryValidationError";
4219
4216
  }
4220
4217
  }
4221
- const dr = [
4218
+ const cr = [
4222
4219
  "where",
4223
4220
  "order",
4224
4221
  "limit",
@@ -4229,7 +4226,7 @@ const dr = [
4229
4226
  "before",
4230
4227
  "fields",
4231
4228
  "aggregate"
4232
- ], ju = (t) => t.valueType || "unknown", ai = (t, e, n = !1) => {
4229
+ ], ku = (t) => t.valueType || "unknown", ui = (t, e, n = !1) => {
4233
4230
  if (n || t == null)
4234
4231
  return !0;
4235
4232
  switch (e) {
@@ -4244,9 +4241,9 @@ const dr = [
4244
4241
  default:
4245
4242
  return !0;
4246
4243
  }
4247
- }, Cu = (t, e, n, r, i, s, o) => {
4244
+ }, ju = (t, e, n, r, i, s, o) => {
4248
4245
  const u = s.valueType === "json", a = (d, c, f) => {
4249
- if (!ai(f, c, u))
4246
+ if (!ui(f, c, u))
4250
4247
  throw new M(`Invalid value for operator '${d}' on attribute '${r}' in entity '${i}'. Expected ${c}, but received: ${typeof f}`, o);
4251
4248
  };
4252
4249
  switch (t) {
@@ -4277,16 +4274,16 @@ const dr = [
4277
4274
  throw new M(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
4278
4275
  }
4279
4276
  }, Oe = (t, e, n, r, i) => {
4280
- const s = ju(n), o = n.valueType === "json";
4277
+ const s = ku(n), o = n.valueType === "json";
4281
4278
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
4282
4279
  if (o)
4283
4280
  return;
4284
4281
  const a = t;
4285
4282
  for (const [d, c] of Object.entries(a))
4286
- Cu(d, c, s, e, r, n, `${i}.${d}`);
4287
- } else if (!ai(t, s, o))
4283
+ ju(d, c, s, e, r, n, `${i}.${d}`);
4284
+ } else if (!ui(t, s, o))
4288
4285
  throw new M(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
4289
- }, Pu = (t, e, n, r, i) => {
4286
+ }, Cu = (t, e, n, r, i) => {
4290
4287
  const s = t.split(".");
4291
4288
  if (s.length < 2)
4292
4289
  throw new M(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -4323,12 +4320,12 @@ const dr = [
4323
4320
  throw new M(`Attribute '${u}' does not exist on entity '${o}' in dot notation path '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") + ", id" : "id"}`, i);
4324
4321
  }
4325
4322
  Oe(e, t, d, n, i);
4326
- }, ci = (t, e, n, r) => {
4323
+ }, ai = (t, e, n, r) => {
4327
4324
  for (const [i, s] of Object.entries(t)) {
4328
4325
  if (i === "or" || i === "and") {
4329
4326
  if (Array.isArray(s))
4330
4327
  for (const d of s)
4331
- typeof d == "object" && d !== null && ci(d, e, n, `${r}.${i}[${d}]`);
4328
+ typeof d == "object" && d !== null && ai(d, e, n, `${r}.${i}[${d}]`);
4332
4329
  continue;
4333
4330
  }
4334
4331
  if (i === "id") {
@@ -4336,7 +4333,7 @@ const dr = [
4336
4333
  continue;
4337
4334
  }
4338
4335
  if (i.includes(".")) {
4339
- Pu(i, s, e, n, `${r}.${i}`);
4336
+ Cu(i, s, e, n, `${r}.${i}`);
4340
4337
  continue;
4341
4338
  }
4342
4339
  const o = n.entities[e];
@@ -4356,10 +4353,10 @@ const dr = [
4356
4353
  Oe(s, i, d, e, `${r}.${i}`);
4357
4354
  }
4358
4355
  }
4359
- }, Iu = (t, e, n, r, i = 0) => {
4356
+ }, Pu = (t, e, n, r, i = 0) => {
4360
4357
  for (const o of Object.keys(t))
4361
- if (!dr.includes(o))
4362
- throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${dr.join(", ")}. Found: ${o}`, r);
4358
+ if (!cr.includes(o))
4359
+ throw new M(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${cr.join(", ")}. Found: ${o}`, r);
4363
4360
  const s = [
4364
4361
  // 'limit', // only supported client side
4365
4362
  "offset",
@@ -4374,9 +4371,9 @@ const dr = [
4374
4371
  if (t.where && n) {
4375
4372
  if (typeof t.where != "object" || t.where === null)
4376
4373
  throw new M(`'where' clause must be an object in entity '${e}', but received: ${typeof t.where}`, r ? `${r}.where` : void 0);
4377
- ci(t.where, e, n, r ? `${r}.where` : "where");
4374
+ ai(t.where, e, n, r ? `${r}.where` : "where");
4378
4375
  }
4379
- }, di = (t, e, n, r, i = 0) => {
4376
+ }, ci = (t, e, n, r, i = 0) => {
4380
4377
  var s;
4381
4378
  if (!t || typeof t != "object")
4382
4379
  throw new M(`Query part for entity '${e}' must be an object, but received: ${typeof t}`, r);
@@ -4389,15 +4386,15 @@ const dr = [
4389
4386
  const u = t[o];
4390
4387
  if (typeof u == "object" && u !== null) {
4391
4388
  const a = (s = n == null ? void 0 : n.entities[e].links[o]) === null || s === void 0 ? void 0 : s.entityName;
4392
- a && di(u, a, n, `${r}.${o}`, i + 1);
4389
+ a && ci(u, a, n, `${r}.${o}`, i + 1);
4393
4390
  }
4394
4391
  } else {
4395
4392
  const u = t[o];
4396
4393
  if (typeof u != "object" || u === null)
4397
4394
  throw new M(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
4398
- Iu(u, e, n, `${r}.$`, i);
4395
+ Pu(u, e, n, `${r}.$`, i);
4399
4396
  }
4400
- }, fr = (t, e) => {
4397
+ }, dr = (t, e) => {
4401
4398
  if (typeof t != "object" || t === null)
4402
4399
  throw new M(`Query must be an object, but received: ${typeof t}${t === null ? " (null)" : ""}`);
4403
4400
  if (Array.isArray(t))
@@ -4413,67 +4410,67 @@ const dr = [
4413
4410
  const i = Object.keys(e.entities);
4414
4411
  throw new M(`Entity '${r}' does not exist in schema. Available entities: ${i.length > 0 ? i.join(", ") : "none"}`, r);
4415
4412
  }
4416
- di(n[r], r, e, r, 0);
4413
+ ci(n[r], r, e, r, 0);
4417
4414
  }
4418
4415
  }
4419
- }, lr = (t) => typeof t != "string" ? !1 : ht(t) ? !0 : Ee(t);
4416
+ }, fr = (t) => typeof t != "string" ? !1 : ht(t) ? !0 : Ee(t);
4420
4417
  class Z extends Error {
4421
4418
  constructor(e) {
4422
4419
  super(e), this.name = "TransactionValidationError";
4423
4420
  }
4424
4421
  }
4425
- const fi = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${fi(e)}`), hr = {
4422
+ const di = (t) => t.length > 0 ? t.join(", ") : "none", Iu = (t, e) => new Z(`Entity '${t}' does not exist in schema. Available entities: ${di(e)}`), lr = {
4426
4423
  string: (t) => typeof t == "string",
4427
4424
  number: (t) => typeof t == "number" && !isNaN(t),
4428
4425
  boolean: (t) => typeof t == "boolean",
4429
4426
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4430
4427
  json: () => !0
4431
- }, Ru = (t, e) => {
4428
+ }, Mu = (t, e) => {
4432
4429
  var n, r;
4433
- return t == null ? !0 : (r = (n = hr[e.valueType]) === null || n === void 0 ? void 0 : n.call(hr, t)) !== null && r !== void 0 ? r : !1;
4434
- }, li = (t, e) => {
4430
+ return t == null ? !0 : (r = (n = lr[e.valueType]) === null || n === void 0 ? void 0 : n.call(lr, t)) !== null && r !== void 0 ? r : !1;
4431
+ }, fi = (t, e) => {
4435
4432
  const n = e.entities[t];
4436
4433
  if (!n)
4437
- throw Mu(t, Object.keys(e.entities));
4434
+ throw Iu(t, Object.keys(e.entities));
4438
4435
  return n;
4439
- }, Pt = (t, e, n) => {
4440
- const r = li(t, n);
4436
+ }, Ct = (t, e, n) => {
4437
+ const r = fi(t, n);
4441
4438
  if (typeof e != "object" || e === null)
4442
4439
  throw new Z(`Arguments for data operation on entity '${t}' must be an object, but received: ${typeof e}`);
4443
4440
  for (const [i, s] of Object.entries(e)) {
4444
4441
  if (i === "id")
4445
4442
  continue;
4446
4443
  const o = r.attrs[i];
4447
- if (o && !Ru(s, o))
4444
+ if (o && !Mu(s, o))
4448
4445
  throw new Z(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
4449
4446
  }
4450
- }, pr = (t, e, n) => {
4451
- const r = li(t, n);
4447
+ }, hr = (t, e, n) => {
4448
+ const r = fi(t, n);
4452
4449
  if (typeof e != "object" || e === null)
4453
4450
  throw new Z(`Arguments for link operation on entity '${t}' must be an object, but received: ${typeof e}`);
4454
4451
  for (const [i, s] of Object.entries(e)) {
4455
4452
  if (!r.links[i]) {
4456
4453
  const u = Object.keys(r.links);
4457
- throw new Z(`Link '${i}' does not exist on entity '${t}'. Available links: ${fi(u)}`);
4454
+ throw new Z(`Link '${i}' does not exist on entity '${t}'. Available links: ${di(u)}`);
4458
4455
  }
4459
4456
  if (s != null) {
4460
4457
  if (Array.isArray(s)) {
4461
4458
  for (const u of s)
4462
- if (!lr(u))
4459
+ if (!fr(u))
4463
4460
  throw new Z(`Invalid entity ID in link '${i}' for entity '${t}'. Expected a UUID or a lookup, but received: ${u}`);
4464
- } else if (!lr(s))
4461
+ } else if (!fr(s))
4465
4462
  throw new Z(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
4466
4463
  }
4467
4464
  }
4468
- }, $u = {
4469
- create: Pt,
4470
- update: Pt,
4471
- merge: Pt,
4472
- link: pr,
4473
- unlink: pr,
4465
+ }, Ru = {
4466
+ create: Ct,
4467
+ update: Ct,
4468
+ merge: Ct,
4469
+ link: hr,
4470
+ unlink: hr,
4474
4471
  delete: () => {
4475
4472
  }
4476
- }, xu = (t, e) => {
4473
+ }, $u = (t, e) => {
4477
4474
  if (!e)
4478
4475
  return;
4479
4476
  const [n, r, i, s] = t;
@@ -4481,9 +4478,9 @@ const fi = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`En
4481
4478
  throw new Z(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
4482
4479
  if (typeof r != "string")
4483
4480
  throw new Z(`Entity name must be a string, but received: ${typeof r}`);
4484
- const o = $u[n];
4481
+ const o = Ru[n];
4485
4482
  o && s !== void 0 && o(r, s, e);
4486
- }, Du = (t, e) => {
4483
+ }, xu = (t, e) => {
4487
4484
  const n = Array.isArray(t) ? t : [t];
4488
4485
  for (const r of n) {
4489
4486
  if (!r || typeof r != "object")
@@ -4493,11 +4490,11 @@ const fi = (t) => t.length > 0 ? t.join(", ") : "none", Mu = (t, e) => new Z(`En
4493
4490
  for (const i of r.__ops) {
4494
4491
  if (!Array.isArray(i))
4495
4492
  throw new Z(`Transaction operation must be an array, but received: ${typeof i}`);
4496
- xu(i, e);
4493
+ $u(i, e);
4497
4494
  }
4498
4495
  }
4499
4496
  };
4500
- var yr = function(t, e, n, r) {
4497
+ var pr = function(t, e, n, r) {
4501
4498
  function i(s) {
4502
4499
  return s instanceof n ? s : new n(function(o) {
4503
4500
  o(s);
@@ -4524,10 +4521,10 @@ var yr = function(t, e, n, r) {
4524
4521
  d((r = r.apply(t, e || [])).next());
4525
4522
  });
4526
4523
  };
4527
- let hi = 0;
4528
- class br {
4524
+ let li = 0;
4525
+ class yr {
4529
4526
  constructor(e) {
4530
- this.type = "ws", this.id = `${this.type}_${hi++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
4527
+ this.type = "ws", this.id = `${this.type}_${li++}`, this.conn = new WebSocket(e), this.conn.onopen = (n) => {
4531
4528
  this.onopen && this.onopen({ target: this });
4532
4529
  }, this.conn.onmessage = (n) => {
4533
4530
  this.onmessage && this.onmessage({
@@ -4555,9 +4552,9 @@ class br {
4555
4552
  return this.conn.send(JSON.stringify(e));
4556
4553
  }
4557
4554
  }
4558
- class Uu {
4555
+ class Du {
4559
4556
  constructor(e, n) {
4560
- this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${hi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4557
+ this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = null, this.id = `${this.type}_${li++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4561
4558
  this.initParams || this.handleError();
4562
4559
  }, 1e4), this.conn.onmessage = (r) => {
4563
4560
  const i = JSON.parse(r.data);
@@ -4589,7 +4586,7 @@ class Uu {
4589
4586
  this.conn.close(), this.onclose && !this.closeFired && (this.closeFired = !0, this.onclose({ target: this }));
4590
4587
  }
4591
4588
  postMessages(e) {
4592
- return yr(this, void 0, void 0, function* () {
4589
+ return pr(this, void 0, void 0, function* () {
4593
4590
  try {
4594
4591
  (yield fetch(this.url, {
4595
4592
  method: "POST",
@@ -4607,7 +4604,7 @@ class Uu {
4607
4604
  });
4608
4605
  }
4609
4606
  flushQueue() {
4610
- return yr(this, void 0, void 0, function* () {
4607
+ return pr(this, void 0, void 0, function* () {
4611
4608
  if (this.sendPromise || !this.sendQueue.length)
4612
4609
  return;
4613
4610
  const e = this.sendQueue;
@@ -4633,7 +4630,7 @@ class Uu {
4633
4630
  this.handleClose();
4634
4631
  }
4635
4632
  }
4636
- var _r = function(t, e, n, r) {
4633
+ var br = function(t, e, n, r) {
4637
4634
  function i(s) {
4638
4635
  return s instanceof n ? s : new n(function(o) {
4639
4636
  o(s);
@@ -4660,34 +4657,34 @@ var _r = function(t, e, n, r) {
4660
4657
  d((r = r.apply(t, e || [])).next());
4661
4658
  });
4662
4659
  };
4663
- function Lu(t, e) {
4660
+ function Uu(t, e) {
4664
4661
  const n = t.values;
4665
4662
  if (n)
4666
4663
  for (const r of n.entities || [])
4667
- r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Fr(r.store);
4664
+ r.store.useDateObjects = e, r.store.attrs = n.attrs, r.store = Lr(r.store);
4668
4665
  return t;
4669
4666
  }
4670
- function Fu(t, e) {
4667
+ function Lu(t, e) {
4671
4668
  var n, r;
4672
4669
  if (!((n = e.values) === null || n === void 0) && n.entities) {
4673
4670
  const i = [];
4674
4671
  for (const s of (r = e.values) === null || r === void 0 ? void 0 : r.entities) {
4675
- const o = Lr(s.store);
4672
+ const o = Ur(s.store);
4676
4673
  delete o.attrs, i.push(Object.assign(Object.assign({}, s), { store: o }));
4677
4674
  }
4678
4675
  return Object.assign(Object.assign({}, e), { values: Object.assign(Object.assign({}, e.values), { entities: i }) });
4679
4676
  } else
4680
4677
  return e;
4681
4678
  }
4682
- function Nu(t, e, n) {
4679
+ function Fu(t, e, n) {
4683
4680
  var r, i;
4684
4681
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4685
4682
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
4686
4683
  }
4687
- function It(t, e) {
4688
- return Zr({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4684
+ function Pt(t, e) {
4685
+ return Jr({ store: e, pageInfo: null, aggregate: null }, t.query).data[t.table][0];
4689
4686
  }
4690
- function gr(t, e, n) {
4687
+ function _r(t, e, n) {
4691
4688
  var r;
4692
4689
  const i = (r = fe(e, t.table, "id")) === null || r === void 0 ? void 0 : r.id;
4693
4690
  if (!i)
@@ -4695,18 +4692,18 @@ function gr(t, e, n) {
4695
4692
  const s = Ce(e.eav, [n, i, n]);
4696
4693
  return s ? s[3] : -1;
4697
4694
  }
4698
- function Tr(t, e) {
4695
+ function gr(t, e) {
4699
4696
  for (const { action: n, triple: r } of e)
4700
4697
  switch (n) {
4701
4698
  case "added":
4702
- qr(t, r);
4699
+ Kr(t, r);
4703
4700
  break;
4704
4701
  case "removed":
4705
- Nr(t, r);
4702
+ Fr(t, r);
4706
4703
  break;
4707
4704
  }
4708
4705
  }
4709
- function Ku(t, e) {
4706
+ function Nu(t, e) {
4710
4707
  var n, r, i, s;
4711
4708
  const o = {};
4712
4709
  for (const { action: u, triple: a } of e) {
@@ -4734,14 +4731,14 @@ function Ku(t, e) {
4734
4731
  function rt(t, e) {
4735
4732
  return { [t.table]: e.map((n) => n.entity) };
4736
4733
  }
4737
- function qu(t, e) {
4734
+ function Ku(t, e) {
4738
4735
  var n;
4739
4736
  if (t.orderFieldType)
4740
4737
  return t.orderFieldType;
4741
4738
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = fe(e([]), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4742
4739
  return t.orderFieldType = r, r;
4743
4740
  }
4744
- function zu(t, e, n) {
4741
+ function qu(t, e, n) {
4745
4742
  const r = e;
4746
4743
  if (t.orderField === "serverCreatedAt") {
4747
4744
  n.sort(t.orderDirection === "asc" ? function(o, u) {
@@ -4762,13 +4759,13 @@ var pe;
4762
4759
  (function(t) {
4763
4760
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4764
4761
  })(pe || (pe = {}));
4765
- class Vu {
4762
+ class zu {
4766
4763
  constructor(e, n, r, i, s) {
4767
- this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Zt({
4764
+ this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.subs = new Jt({
4768
4765
  persister: n,
4769
- merge: Nu,
4770
- serialize: Fu,
4771
- parse: (o, u) => Lu(u, this.config.useDateObjects),
4766
+ merge: Fu,
4767
+ serialize: Lu,
4768
+ parse: (o, u) => Uu(u, this.config.useDateObjects),
4772
4769
  objectSize: (o) => {
4773
4770
  var u;
4774
4771
  return ((u = o.values) === null || u === void 0 ? void 0 : u.entities.length) || 0;
@@ -4825,7 +4822,7 @@ class Vu {
4825
4822
  });
4826
4823
  }
4827
4824
  initSubscription(e, n, r) {
4828
- return _r(this, void 0, void 0, function* () {
4825
+ return br(this, void 0, void 0, function* () {
4829
4826
  var i, s, o, u;
4830
4827
  yield this.subs.waitForKeyToLoad(n);
4831
4828
  const a = this.subs.currentValue[n];
@@ -4851,7 +4848,7 @@ class Vu {
4851
4848
  });
4852
4849
  }
4853
4850
  flushPending() {
4854
- return _r(this, void 0, void 0, function* () {
4851
+ return br(this, void 0, void 0, function* () {
4855
4852
  for (const e of Object.keys(this.callbacks)) {
4856
4853
  yield this.subs.waitForKeyToLoad(e);
4857
4854
  const n = this.subs.currentValue[e];
@@ -4896,11 +4893,11 @@ class Vu {
4896
4893
  for (const c of i) {
4897
4894
  const f = this.createStore(c);
4898
4895
  a.attrs = f.attrs;
4899
- const l = It(u, f);
4896
+ const l = Pt(u, f);
4900
4897
  d.push({
4901
4898
  store: f,
4902
4899
  entity: l,
4903
- serverCreatedAt: gr(u, f, l.id)
4900
+ serverCreatedAt: _r(u, f, l.id)
4904
4901
  }), o.push(l);
4905
4902
  }
4906
4903
  this.subs.updateInPlace((c) => {
@@ -4970,9 +4967,9 @@ class Vu {
4970
4967
  e: for (const [T, v] of Object.entries(f))
4971
4968
  for (let j = 0; j < p.length; j++) {
4972
4969
  const S = p[j];
4973
- if (vs(S.store, T)) {
4974
- Tr(S.store, v);
4975
- const I = It(u, S.store), R = Ku(S.store, v)[T];
4970
+ if (ws(S.store, T)) {
4971
+ gr(S.store, v);
4972
+ const I = Pt(u, S.store), R = Nu(S.store, v)[T];
4976
4973
  I ? (y.push({
4977
4974
  oldEntity: S.entity,
4978
4975
  newEntity: I,
@@ -4984,8 +4981,8 @@ class Vu {
4984
4981
  const b = [];
4985
4982
  for (const [T, v] of Object.entries(f)) {
4986
4983
  const j = this.createStore([]);
4987
- l.attrs = j.attrs, Tr(j, v);
4988
- const S = It(u, j);
4984
+ l.attrs = j.attrs, gr(j, v);
4985
+ const S = Pt(u, j);
4989
4986
  if (!S) {
4990
4987
  this.log.error("No entity found after applying change", {
4991
4988
  sub: u,
@@ -4997,14 +4994,14 @@ class Vu {
4997
4994
  p.push({
4998
4995
  store: j,
4999
4996
  entity: S,
5000
- serverCreatedAt: gr(u, j, S.id)
4997
+ serverCreatedAt: _r(u, j, S.id)
5001
4998
  }), b.push(S);
5002
4999
  }
5003
5000
  const g = [];
5004
5001
  for (const T of c.sort().reverse())
5005
5002
  g.push(p[T].entity), p.splice(T, 1);
5006
- const m = qu(u, this.createStore);
5007
- zu(u, m, p), this.notifyCbs(o, {
5003
+ const m = Ku(u, this.createStore);
5004
+ qu(u, m, p), this.notifyCbs(o, {
5008
5005
  type: pe.SyncTransaction,
5009
5006
  data: rt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
5010
5007
  added: b,
@@ -5071,7 +5068,7 @@ var U = function(t, e, n, r) {
5071
5068
  }
5072
5069
  d((r = r.apply(t, e || [])).next());
5073
5070
  });
5074
- }, Wu = function(t, e) {
5071
+ }, Vu = function(t, e) {
5075
5072
  var n = {};
5076
5073
  for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
5077
5074
  if (t != null && typeof Object.getOwnPropertySymbols == "function")
@@ -5085,46 +5082,46 @@ const se = {
5085
5082
  AUTHENTICATED: "authenticated",
5086
5083
  CLOSED: "closed",
5087
5084
  ERRORED: "errored"
5088
- }, Bu = 3e4, Gu = 3e4, Qu = 200, Hu = {
5085
+ }, Wu = 3e4, Bu = 3e4, Gu = 200, Qu = {
5089
5086
  apiURI: "https://api.instantdb.com",
5090
5087
  websocketURI: "wss://api.instantdb.com/runtime/session"
5091
- }, Mt = "_instant_oauth_redirect", De = "currentUser";
5092
- function Yu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5088
+ }, It = "_instant_oauth_redirect", De = "currentUser";
5089
+ function Hu({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
5093
5090
  if (!i)
5094
- return new br(`${r}?app_id=${e}`);
5091
+ return new yr(`${r}?app_id=${e}`);
5095
5092
  switch (t) {
5096
5093
  case "ws":
5097
- return new br(`${r}?app_id=${e}`);
5094
+ return new yr(`${r}?app_id=${e}`);
5098
5095
  case "sse":
5099
- return new Uu(i, `${n}/runtime/sse?app_id=${e}`);
5096
+ return new Du(i, `${n}/runtime/sse?app_id=${e}`);
5100
5097
  default:
5101
5098
  throw new Error("Unknown transport type " + t);
5102
5099
  }
5103
5100
  }
5104
- function Ju() {
5101
+ function Yu() {
5105
5102
  return typeof window < "u" || typeof chrome < "u";
5106
5103
  }
5107
- const mr = {
5104
+ const Tr = {
5108
5105
  "set-presence": !0,
5109
5106
  "set-presence-ok": !0,
5110
5107
  "refresh-presence": !0,
5111
5108
  "patch-presence": !0
5112
5109
  };
5113
- function Zu(t, e) {
5110
+ function Ju(t, e) {
5114
5111
  var n;
5115
5112
  const r = typeof t == "string" ? JSON.parse(t) : t;
5116
5113
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
5117
5114
  const i = r.result.store;
5118
- r.result.store = Fr(Object.assign(Object.assign({}, i), { useDateObjects: e }));
5115
+ r.result.store = Lr(Object.assign(Object.assign({}, i), { useDateObjects: e }));
5119
5116
  }
5120
5117
  return r;
5121
5118
  }
5122
- function Xu(t, e) {
5119
+ function Zu(t, e) {
5123
5120
  var n;
5124
5121
  const r = Object.assign({}, e);
5125
- return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Lr(e.result.store) })), r;
5122
+ return !((n = e.result) === null || n === void 0) && n.store && (r.result = Object.assign(Object.assign({}, e.result), { store: Ur(e.result.store) })), r;
5126
5123
  }
5127
- function ea(t, e) {
5124
+ function Xu(t, e) {
5128
5125
  switch (t) {
5129
5126
  case "pendingMutations":
5130
5127
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -5132,7 +5129,7 @@ function ea(t, e) {
5132
5129
  return e;
5133
5130
  }
5134
5131
  }
5135
- function ta(t, e) {
5132
+ function ea(t, e) {
5136
5133
  switch (t) {
5137
5134
  case "pendingMutations":
5138
5135
  return [...e.entries()];
@@ -5140,18 +5137,18 @@ function ta(t, e) {
5140
5137
  return e;
5141
5138
  }
5142
5139
  }
5143
- function na(t, e, n) {
5140
+ function ta(t, e, n) {
5144
5141
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
5145
5142
  return r && !i && n && (n.result = r), n || e;
5146
5143
  }
5147
- function wr(t) {
5144
+ function mr(t) {
5148
5145
  return [...t].sort((e, n) => {
5149
5146
  const [r, i] = e, [s, o] = n, u = i.order || 0, a = o.order || 0;
5150
5147
  return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
5151
5148
  });
5152
5149
  }
5153
- class ra {
5154
- constructor(e, n = ni, r = ri, i, s) {
5150
+ class na {
5151
+ constructor(e, n = ti, r = ni, i, s) {
5155
5152
  var o, u, a;
5156
5153
  if (this._isOnline = !0, this._isShutdown = !1, this.status = se.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (d, c, f) => {
5157
5154
  var l, p;
@@ -5182,9 +5179,9 @@ class ra {
5182
5179
  }, this.notifyQueryError = (d, c) => {
5183
5180
  (this.queryCbs[d] || []).forEach((l) => l.cb({ error: c }));
5184
5181
  }, this.pushTx = (d) => {
5185
- this.config.disableValidation || Du(d, this.config.schema);
5182
+ this.config.disableValidation || xu(d, this.config.schema);
5186
5183
  try {
5187
- const c = iu({
5184
+ const c = ru({
5188
5185
  attrs: this.optimisticAttrs(),
5189
5186
  schema: this.config.schema,
5190
5187
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -5208,7 +5205,7 @@ class ra {
5208
5205
  this._updatePendingMutations((g) => {
5209
5206
  g.set(f, y);
5210
5207
  });
5211
- const b = new ur();
5208
+ const b = new or();
5212
5209
  return this.mutationDeferredStore.set(f, b), this._sendMutation(f, y), this.notifyAll(), b.promise;
5213
5210
  }, this._transportOnOpen = (d) => {
5214
5211
  const c = d.target;
@@ -5269,7 +5266,7 @@ class ra {
5269
5266
  return;
5270
5267
  }
5271
5268
  this._log.info("[socket][close]", c.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
5272
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Hu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Gu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Qu, this._log = ku(e.verbose || yn || ii, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": ui }), this.config.schema && (this._linkIndex = cr(this.config.schema)), !!Ju()) {
5269
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Qu), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Bu, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Gu, this._log = Au(e.verbose || pn || ri, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": oi }), this.config.schema && (this._linkIndex = ar(this.config.schema)), !!Yu()) {
5273
5270
  if (!e.appId)
5274
5271
  throw new Error("Instant must be initialized with an appId.");
5275
5272
  if (!Ee(e.appId))
@@ -5284,7 +5281,7 @@ class ra {
5284
5281
  } catch (f) {
5285
5282
  this._log.error("[error] handle broadcast channel", f);
5286
5283
  }
5287
- }))), this._initStorage(n), this._syncTable = new Vu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5284
+ }))), this._initStorage(n), this._syncTable = new zu(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
5288
5285
  useDateObjects: this.config.useDateObjects
5289
5286
  }, this._log, (d) => at(this.attrs, d, this.config.enableCardinalityInference, this._linkIndex, this.config.useDateObjects)), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((d) => {
5290
5287
  this._isOnline = d, this._startSocket(), r.listen((c) => {
@@ -5294,7 +5291,7 @@ class ra {
5294
5291
  }
5295
5292
  }
5296
5293
  updateSchema(e) {
5297
- this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? cr(this.config.schema) : null;
5294
+ this.config = Object.assign(Object.assign({}, this.config), { schema: e, cardinalityInference: !!e }), this._linkIndex = e ? ar(this.config.schema) : null;
5298
5295
  }
5299
5296
  _reactorStats() {
5300
5297
  return {
@@ -5307,11 +5304,11 @@ class ra {
5307
5304
  this.kv.waitForKeyToLoad("pendingMutations").then(() => this.notifyOne(e));
5308
5305
  }
5309
5306
  _initStorage(e) {
5310
- this.querySubs = new Zt({
5307
+ this.querySubs = new Jt({
5311
5308
  persister: new e(this.config.appId, "querySubs"),
5312
- merge: na,
5313
- serialize: Xu,
5314
- parse: (n, r) => Zu(r, this.config.useDateObjects),
5309
+ merge: ta,
5310
+ serialize: Zu,
5311
+ parse: (n, r) => Ju(r, this.config.useDateObjects),
5315
5312
  // objectSize
5316
5313
  objectSize: (n) => {
5317
5314
  var r, i, s, o;
@@ -5327,11 +5324,11 @@ class ra {
5327
5324
  maxSize: 1e6
5328
5325
  // 1 million triples
5329
5326
  }
5330
- }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Zt({
5327
+ }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new Jt({
5331
5328
  persister: new e(this.config.appId, "kv"),
5332
5329
  merge: this._onMergeKv,
5333
- serialize: ta,
5334
- parse: ea,
5330
+ serialize: ea,
5331
+ parse: Xu,
5335
5332
  objectSize: () => 0,
5336
5333
  logger: this._log,
5337
5334
  saveThrottleMs: 100,
@@ -5362,7 +5359,7 @@ class ra {
5362
5359
  if (s)
5363
5360
  i.resolve({ status: e, eventId: n });
5364
5361
  else if (r != null && r.type) {
5365
- const { status: o } = r, u = Wu(r, ["status"]);
5362
+ const { status: o } = r, u = Vu(r, ["status"]);
5366
5363
  i.reject(new bt({
5367
5364
  // @ts-expect-error body.type is not constant typed
5368
5365
  body: u,
@@ -5386,7 +5383,7 @@ class ra {
5386
5383
  _handleReceive(e, n) {
5387
5384
  var r, i, s, o, u, a;
5388
5385
  const d = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
5389
- switch (mr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5386
+ switch (Tr[n.op] || this._log.info("[receive]", e, n.op, n), n.op) {
5390
5387
  case "init-ok": {
5391
5388
  this._setStatus(se.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(n.attrs), this._flushPendingMessages(), this._sessionId = n["session-id"];
5392
5389
  for (const l of Object.keys(this._rooms)) {
@@ -5403,7 +5400,7 @@ class ra {
5403
5400
  const { q: l, result: p } = n, y = N(l);
5404
5401
  if (!this._hasQueryListeners() && !this.querySubs.currentValue[y])
5405
5402
  break;
5406
- const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], g = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, m = ar(p), T = at(this.attrs, m, d, this._linkIndex, this.config.useDateObjects);
5403
+ const b = (o = (s = p == null ? void 0 : p[0]) === null || s === void 0 ? void 0 : s.data) === null || o === void 0 ? void 0 : o["page-info"], g = (a = (u = p == null ? void 0 : p[0]) === null || u === void 0 ? void 0 : u.data) === null || a === void 0 ? void 0 : a.aggregate, m = ur(p), T = at(this.attrs, m, d, this._linkIndex, this.config.useDateObjects);
5407
5404
  this.querySubs.updateInPlace((v) => {
5408
5405
  if (!v[y]) {
5409
5406
  this._log.info("Missing value in querySubs", { hash: y, q: l });
@@ -5441,9 +5438,9 @@ class ra {
5441
5438
  b !== this._pendingMutations() && this.kv.updateInPlace((T) => {
5442
5439
  T.pendingMutations = b;
5443
5440
  });
5444
- const g = wr(b.entries()), m = l.map((T) => {
5441
+ const g = mr(b.entries()), m = l.map((T) => {
5445
5442
  var v, j, S, I;
5446
- const R = T["instaql-query"], q = T["instaql-result"], Ie = N(R), Qe = ar(q), _t = at(this.attrs, Qe, d, this._linkIndex, this.config.useDateObjects), gt = this._applyOptimisticUpdates(_t, g, y), He = (j = (v = q == null ? void 0 : q[0]) === null || v === void 0 ? void 0 : v.data) === null || j === void 0 ? void 0 : j["page-info"], ne = (I = (S = q == null ? void 0 : q[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
5443
+ const R = T["instaql-query"], q = T["instaql-result"], Ie = N(R), Qe = ur(q), _t = at(this.attrs, Qe, d, this._linkIndex, this.config.useDateObjects), gt = this._applyOptimisticUpdates(_t, g, y), He = (j = (v = q == null ? void 0 : q[0]) === null || v === void 0 ? void 0 : v.data) === null || j === void 0 ? void 0 : j["page-info"], ne = (I = (S = q == null ? void 0 : q[0]) === null || S === void 0 ? void 0 : S.data) === null || I === void 0 ? void 0 : I.aggregate;
5447
5444
  return { q: R, hash: Ie, store: gt, pageInfo: He, aggregate: ne };
5448
5445
  });
5449
5446
  m.forEach(({ hash: T, q: v, store: j, pageInfo: S, aggregate: I }) => {
@@ -5606,7 +5603,7 @@ class ra {
5606
5603
  */
5607
5604
  subscribeQuery(e, n, r) {
5608
5605
  var i;
5609
- this.config.disableValidation || fr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5606
+ this.config.disableValidation || dr(e, this.config.schema), r && "ruleParams" in r && (e = Object.assign({ $$ruleParams: r.ruleParams }, e));
5610
5607
  const s = N(e), o = this.getPreviousResult(e);
5611
5608
  return o && n(o), this.queryCbs[s] = (i = this.queryCbs[s]) !== null && i !== void 0 ? i : [], this.queryCbs[s].push({ q: e, cb: n }), this._startQuerySub(e, s), () => {
5612
5609
  this._unsubQuery(e, s, n);
@@ -5614,14 +5611,14 @@ class ra {
5614
5611
  }
5615
5612
  queryOnce(e, n) {
5616
5613
  var r;
5617
- this.config.disableValidation || fr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5618
- const i = new ur();
5614
+ this.config.disableValidation || dr(e, this.config.schema), n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
5615
+ const i = new or();
5619
5616
  if (!this._isOnline)
5620
5617
  return i.reject(new Error("We can't run `queryOnce`, because the device is offline.")), i.promise;
5621
5618
  if (!this.querySubs)
5622
5619
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5623
5620
  const s = N(e), o = this._startQuerySub(e, s);
5624
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Bu), i.promise;
5621
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Wu), i.promise;
5625
5622
  }
5626
5623
  _completeQueryOnce(e, n, r) {
5627
5624
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5682,7 +5679,7 @@ class ra {
5682
5679
  u = !0;
5683
5680
  continue;
5684
5681
  }
5685
- const b = u ? $o(o, p) : p;
5682
+ const b = u ? Ro(o, p) : p;
5686
5683
  l.push(b);
5687
5684
  }
5688
5685
  return u ? l : c;
@@ -5692,7 +5689,7 @@ class ra {
5692
5689
  return u ? d : n;
5693
5690
  }
5694
5691
  _rewriteMutationsSorted(e, n) {
5695
- return wr(this._rewriteMutations(e, n).entries());
5692
+ return mr(this._rewriteMutations(e, n).entries());
5696
5693
  }
5697
5694
  // ---------------------------
5698
5695
  // Transact
@@ -5725,7 +5722,7 @@ class ra {
5725
5722
  const d = this._dataForQueryCache[e];
5726
5723
  if (d && r === d.querySubVersion && s === d.pendingMutationsVersion)
5727
5724
  return d.data;
5728
- const { store: c, pageInfo: f, aggregate: l, processedTxId: p } = a, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), g = Zr({ store: b, pageInfo: f, aggregate: l }, u);
5725
+ const { store: c, pageInfo: f, aggregate: l, processedTxId: p } = a, y = this._rewriteMutationsSorted(c.attrs, o), b = this._applyOptimisticUpdates(c, y, p), g = Jr({ store: b, pageInfo: f, aggregate: l }, u);
5729
5726
  return this._dataForQueryCache[e] = {
5730
5727
  querySubVersion: r,
5731
5728
  pendingMutationsVersion: s,
@@ -5734,7 +5731,7 @@ class ra {
5734
5731
  }
5735
5732
  _applyOptimisticUpdates(e, n, r) {
5736
5733
  for (const [i, s] of n)
5737
- (!s["tx-id"] || r && s["tx-id"] > r) && (e = $s(e, s["tx-steps"]));
5734
+ (!s["tx-id"] || r && s["tx-id"] > r) && (e = Rs(e, s["tx-steps"]));
5738
5735
  return e;
5739
5736
  }
5740
5737
  /** Re-compute all subscriptions */
@@ -5822,7 +5819,7 @@ class ra {
5822
5819
  }
5823
5820
  _trySend(e, n, r) {
5824
5821
  if (this._transport.isOpen()) {
5825
- switch (mr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5822
+ switch (Tr[n.op] || this._log.info("[send]", this._transport.id, n.op, n), n.op) {
5826
5823
  case "transact": {
5827
5824
  this._inFlightMutationEventIds.add(e);
5828
5825
  break;
@@ -5843,7 +5840,7 @@ class ra {
5843
5840
  return;
5844
5841
  }
5845
5842
  const e = this._transport;
5846
- this._transport = Yu({
5843
+ this._transport = Hu({
5847
5844
  transportType: this._transportType,
5848
5845
  appId: this.config.appId,
5849
5846
  apiURI: this.config.apiURI,
@@ -5879,9 +5876,9 @@ class ra {
5879
5876
  if (typeof URL > "u")
5880
5877
  return;
5881
5878
  const e = new URL(window.location.href);
5882
- if (e.searchParams.get(Mt)) {
5879
+ if (e.searchParams.get(It)) {
5883
5880
  const n = e.toString();
5884
- e.searchParams.delete(Mt), e.searchParams.delete("code"), e.searchParams.delete("error");
5881
+ e.searchParams.delete(It), e.searchParams.delete("code"), e.searchParams.delete("error");
5885
5882
  const r = e.pathname + (e.searchParams.size ? "?" + e.searchParams : "") + e.hash;
5886
5883
  if (history.replaceState(history.state, "", r), // @ts-ignore (waiting for ts support)
5887
5884
  typeof navigation == "object" && // @ts-ignore (waiting for ts support)
@@ -5906,7 +5903,7 @@ class ra {
5906
5903
  if (typeof window > "u" || typeof window.location > "u" || typeof URLSearchParams > "u")
5907
5904
  return null;
5908
5905
  const s = new URLSearchParams(window.location.search);
5909
- if (!s.get(Mt))
5906
+ if (!s.get(It))
5910
5907
  return null;
5911
5908
  const o = s.get("error");
5912
5909
  if (o)
@@ -5916,7 +5913,7 @@ class ra {
5916
5913
  return null;
5917
5914
  this._replaceUrlAfterOAuth();
5918
5915
  try {
5919
- const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield sr({
5916
+ const a = yield this._getCurrentUser(), d = (a == null ? void 0 : a.type) === "guest", { user: c } = yield ir({
5920
5917
  apiURI: this.config.apiURI,
5921
5918
  appId: this.config.appId,
5922
5919
  code: u,
@@ -6046,7 +6043,7 @@ class ra {
6046
6043
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
6047
6044
  }
6048
6045
  sendMagicCode({ email: e }) {
6049
- return pu({
6046
+ return hu({
6050
6047
  apiURI: this.config.apiURI,
6051
6048
  appId: this.config.appId,
6052
6049
  email: e
@@ -6055,7 +6052,7 @@ class ra {
6055
6052
  signInWithMagicCode(e) {
6056
6053
  return U(this, arguments, void 0, function* ({ email: n, code: r }) {
6057
6054
  var i;
6058
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield yu({
6055
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield pu({
6059
6056
  apiURI: this.config.apiURI,
6060
6057
  appId: this.config.appId,
6061
6058
  email: n,
@@ -6067,7 +6064,7 @@ class ra {
6067
6064
  }
6068
6065
  signInWithCustomToken(e) {
6069
6066
  return U(this, void 0, void 0, function* () {
6070
- const n = yield bu({
6067
+ const n = yield yu({
6071
6068
  apiURI: this.config.apiURI,
6072
6069
  appId: this.config.appId,
6073
6070
  refreshToken: e
@@ -6077,7 +6074,7 @@ class ra {
6077
6074
  }
6078
6075
  signInAsGuest() {
6079
6076
  return U(this, void 0, void 0, function* () {
6080
- const e = yield _u({
6077
+ const e = yield bu({
6081
6078
  apiURI: this.config.apiURI,
6082
6079
  appId: this.config.appId
6083
6080
  });
@@ -6093,7 +6090,7 @@ class ra {
6093
6090
  this._log.info("[auth-invalidate] skipped invalidateToken");
6094
6091
  return;
6095
6092
  }
6096
- Tu({
6093
+ gu({
6097
6094
  apiURI: this.config.apiURI,
6098
6095
  appId: this.config.appId,
6099
6096
  refreshToken: i
@@ -6128,7 +6125,7 @@ class ra {
6128
6125
  exchangeCodeForToken(e) {
6129
6126
  return U(this, arguments, void 0, function* ({ code: n, codeVerifier: r }) {
6130
6127
  var i;
6131
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield sr({
6128
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield ir({
6132
6129
  apiURI: this.config.apiURI,
6133
6130
  appId: this.config.appId,
6134
6131
  code: n,
@@ -6151,7 +6148,7 @@ class ra {
6151
6148
  signInWithIdToken(e) {
6152
6149
  return U(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
6153
6150
  var s;
6154
- const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield gu({
6151
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield _u({
6155
6152
  apiURI: this.config.apiURI,
6156
6153
  appId: this.config.appId,
6157
6154
  idToken: n,
@@ -6192,7 +6189,7 @@ class ra {
6192
6189
  // TODO: look into typing again
6193
6190
  getPresence(e, n, r = {}) {
6194
6191
  const i = this._rooms[n], s = this._presence[n];
6195
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Eu(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6192
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, Ou(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
6196
6193
  }
6197
6194
  // TODO: look into typing again
6198
6195
  publishPresence(e, n, r) {
@@ -6242,7 +6239,7 @@ class ra {
6242
6239
  }
6243
6240
  _notifyPresenceSub(e, n) {
6244
6241
  const r = this.getPresence("", e, n);
6245
- r && (n.prev && !Au(r, n.prev) || (n.prev = r, n.cb(r)));
6242
+ r && (n.prev && !Eu(r, n.prev) || (n.prev = r, n.cb(r)));
6246
6243
  }
6247
6244
  _patchPresencePeers(e, n) {
6248
6245
  var r, i, s;
@@ -6253,13 +6250,13 @@ class ra {
6253
6250
  for (let [c, f, l] of n)
6254
6251
  switch (f) {
6255
6252
  case "+":
6256
- rs(d, c, l);
6253
+ ns(d, c, l);
6257
6254
  break;
6258
6255
  case "r":
6259
- Bn(d, c, l);
6256
+ Wn(d, c, l);
6260
6257
  break;
6261
6258
  case "-":
6262
- xr(d, c);
6259
+ $r(d, c);
6263
6260
  break;
6264
6261
  }
6265
6262
  delete d[this._sessionId];
@@ -6271,7 +6268,7 @@ class ra {
6271
6268
  delete r[this._sessionId];
6272
6269
  const i = Object.fromEntries(Object.entries(r).map(([s, o]) => [s, o.data]));
6273
6270
  this._presence = ft(this._presence, (s) => {
6274
- Bn(s, [e, "result", "peers"], i);
6271
+ Wn(s, [e, "result", "peers"], i);
6275
6272
  });
6276
6273
  }
6277
6274
  // --------
@@ -6316,14 +6313,14 @@ class ra {
6316
6313
  return U(this, void 0, void 0, function* () {
6317
6314
  var i;
6318
6315
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
6319
- return mu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6316
+ return Tu(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
6320
6317
  });
6321
6318
  }
6322
6319
  deleteFile(e) {
6323
6320
  return U(this, void 0, void 0, function* () {
6324
6321
  var n;
6325
6322
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6326
- return yield wu({
6323
+ return yield mu({
6327
6324
  apiURI: this.config.apiURI,
6328
6325
  appId: this.config.appId,
6329
6326
  path: e,
@@ -6336,20 +6333,20 @@ class ra {
6336
6333
  upload(e, n) {
6337
6334
  return U(this, void 0, void 0, function* () {
6338
6335
  var r;
6339
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield vu({
6336
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield wu({
6340
6337
  apiURI: this.config.apiURI,
6341
6338
  appId: this.config.appId,
6342
6339
  fileName: o,
6343
6340
  refreshToken: s
6344
6341
  });
6345
- return yield Su(u, n);
6342
+ return yield vu(u, n);
6346
6343
  });
6347
6344
  }
6348
6345
  getDownloadUrl(e) {
6349
6346
  return U(this, void 0, void 0, function* () {
6350
6347
  var n;
6351
6348
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
6352
- return yield Ou({
6349
+ return yield Su({
6353
6350
  apiURI: this.config.apiURI,
6354
6351
  appId: this.config.appId,
6355
6352
  path: e,
@@ -6359,9 +6356,9 @@ class ra {
6359
6356
  }
6360
6357
  }
6361
6358
  let it;
6362
- function ia(t, e) {
6359
+ function ra(t, e) {
6363
6360
  it == null || it.dispose();
6364
- const n = da(e), r = ua(e, u), i = oa(sa(t));
6361
+ const n = ca(e), r = oa(e, u), i = sa(ia(t));
6365
6362
  function s(c) {
6366
6363
  var f;
6367
6364
  c.source === i.element.contentWindow && ((f = c.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
@@ -6383,10 +6380,10 @@ function ia(t, e) {
6383
6380
  }
6384
6381
  return d();
6385
6382
  }
6386
- function sa(t) {
6387
- return `${yn || si ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6383
+ function ia(t) {
6384
+ return `${pn || ii ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6388
6385
  }
6389
- function oa(t) {
6386
+ function sa(t) {
6390
6387
  const e = document.createElement("iframe");
6391
6388
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6392
6389
  width: "100%",
@@ -6395,7 +6392,7 @@ function oa(t) {
6395
6392
  border: "none"
6396
6393
  }), { element: e };
6397
6394
  }
6398
- function ua(t, e) {
6395
+ function oa(t, e) {
6399
6396
  const n = `
6400
6397
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6401
6398
  <rect width="512" height="512" fill="black"/>
@@ -6405,7 +6402,7 @@ function ua(t, e) {
6405
6402
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6406
6403
  // pos
6407
6404
  position: "fixed"
6408
- }, aa(t.position)), {
6405
+ }, ua(t.position)), {
6409
6406
  height: "32px",
6410
6407
  width: "32px",
6411
6408
  // layout
@@ -6420,7 +6417,7 @@ function ua(t, e) {
6420
6417
  cursor: "pointer"
6421
6418
  })), r.addEventListener("click", e), { element: r };
6422
6419
  }
6423
- function aa(t) {
6420
+ function ua(t) {
6424
6421
  switch (t) {
6425
6422
  case "bottom-left":
6426
6423
  return { bottom: "24px", left: "24px" };
@@ -6432,7 +6429,7 @@ function aa(t) {
6432
6429
  return { top: "24px", left: "24px" };
6433
6430
  }
6434
6431
  }
6435
- function ca(t) {
6432
+ function aa(t) {
6436
6433
  switch (t) {
6437
6434
  case "bottom-left":
6438
6435
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6444,47 +6441,47 @@ function ca(t) {
6444
6441
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6445
6442
  }
6446
6443
  }
6447
- function da(t) {
6444
+ function ca(t) {
6448
6445
  const e = document.createElement("div");
6449
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ca(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6446
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, aa(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6450
6447
  function n() {
6451
6448
  return e.style.display !== "none";
6452
6449
  }
6453
6450
  return { element: e, isVisible: n };
6454
6451
  }
6455
- const fa = {
6452
+ const da = {
6456
6453
  apiURI: "https://api.instantdb.com",
6457
6454
  websocketURI: "wss://api.instantdb.com/runtime/session"
6458
6455
  };
6459
- function la() {
6456
+ function fa() {
6460
6457
  var t;
6461
6458
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6462
6459
  }
6463
- function ha() {
6460
+ function la() {
6464
6461
  var t;
6465
6462
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6466
6463
  }
6467
- function Xt(t) {
6464
+ function Zt(t) {
6468
6465
  const e = t.__adminToken;
6469
6466
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6470
6467
  }
6471
- const en = ha(), Rt = la();
6472
- class pa {
6468
+ const Xt = la(), Mt = fa();
6469
+ class ha {
6473
6470
  constructor(e) {
6474
6471
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
6475
6472
  }
6476
6473
  }
6477
- class ya {
6474
+ class pa {
6478
6475
  constructor(e) {
6479
6476
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
6480
6477
  }
6481
6478
  }
6482
- function ba(t) {
6479
+ function ya(t) {
6483
6480
  return JSON.parse(JSON.stringify(t));
6484
6481
  }
6485
- class _a {
6482
+ class ba {
6486
6483
  constructor(e) {
6487
- this.tx = pn(), this._reactor = e, this.auth = new pa(this._reactor), this.storage = new ya(this._reactor);
6484
+ this.tx = hn(), this._reactor = e, this.auth = new ha(this._reactor), this.storage = new pa(this._reactor);
6488
6485
  }
6489
6486
  /**
6490
6487
  * Use this to write data! You can create, update, delete, and link objects
@@ -6625,7 +6622,7 @@ class _a {
6625
6622
  };
6626
6623
  }
6627
6624
  shutdown() {
6628
- delete en[Xt(this._reactor.config)], this._reactor.shutdown();
6625
+ delete Xt[Zt(this._reactor.config)], this._reactor.shutdown();
6629
6626
  }
6630
6627
  /**
6631
6628
  * Use this for one-off queries.
@@ -6658,37 +6655,37 @@ class _a {
6658
6655
  return this._reactor.subscribeTable(e, n);
6659
6656
  }
6660
6657
  }
6661
- function vr(t) {
6658
+ function wr(t) {
6662
6659
  if (!t)
6663
6660
  return "0";
6664
- if (Rt.get(t))
6665
- return Rt.get(t);
6661
+ if (Mt.get(t))
6662
+ return Mt.get(t);
6666
6663
  const e = N(t);
6667
- return Rt.set(t, e), e;
6664
+ return Mt.set(t, e), e;
6668
6665
  }
6669
- function ga(t, e) {
6670
- return vr(t._reactor.config.schema) !== vr(e);
6666
+ function _a(t, e) {
6667
+ return wr(t._reactor.config.schema) !== wr(e);
6671
6668
  }
6672
- function Ta(t, e, n, r, i) {
6673
- const s = en[Xt(t)];
6669
+ function ga(t, e, n, r, i) {
6670
+ const s = Xt[Zt(t)];
6674
6671
  if (s)
6675
- return ga(s, t.schema) && s._reactor.updateSchema(t.schema), s;
6676
- const o = new ra(Object.assign(Object.assign(Object.assign({}, fa), t), { cardinalityInference: !!t.schema }), e || ni, n || ri, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": ui }), i), u = new _a(o);
6677
- return en[Xt(t)] = u, ma(t.appId, t.devtool), u;
6672
+ return _a(s, t.schema) && s._reactor.updateSchema(t.schema), s;
6673
+ const o = new na(Object.assign(Object.assign(Object.assign({}, da), t), { cardinalityInference: !!t.schema }), e || ti, n || ni, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": oi }), i), u = new ba(o);
6674
+ return Xt[Zt(t)] = u, Ta(t.appId, t.devtool), u;
6678
6675
  }
6679
- function ma(t, e) {
6676
+ function Ta(t, e) {
6680
6677
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6681
6678
  return;
6682
6679
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6683
- n.allowedHosts.includes(window.location.hostname) && ia(t, n);
6680
+ n.allowedHosts.includes(window.location.hostname) && ra(t, n);
6684
6681
  }
6685
- const wa = {
6682
+ const ma = {
6686
6683
  isLoading: !0,
6687
6684
  data: void 0,
6688
6685
  pageInfo: void 0,
6689
6686
  error: void 0
6690
6687
  };
6691
- function Sr(t) {
6688
+ function vr(t) {
6692
6689
  return {
6693
6690
  isLoading: !t,
6694
6691
  data: void 0,
@@ -6697,12 +6694,12 @@ function Sr(t) {
6697
6694
  ...t || {}
6698
6695
  };
6699
6696
  }
6700
- function va(t, e, n) {
6697
+ function wa(t, e, n) {
6701
6698
  e && n && "ruleParams" in n && (e = { $$ruleParams: n.ruleParams, ...e });
6702
- const r = e ? ba(e) : null, i = N(r), s = ze(
6703
- Sr(t._reactor.getPreviousResult(r))
6699
+ const r = e ? ya(e) : null, i = N(r), s = ze(
6700
+ vr(t._reactor.getPreviousResult(r))
6704
6701
  ), o = de(
6705
- (a) => (s.current = Sr(
6702
+ (a) => (s.current = vr(
6706
6703
  t._reactor.getPreviousResult(r)
6707
6704
  ), r ? t.subscribeQuery(r, (c) => {
6708
6705
  s.current = {
@@ -6717,13 +6714,13 @@ function va(t, e, n) {
6717
6714
  // Build a new subscribe function if the query changes
6718
6715
  [i]
6719
6716
  );
6720
- return { state: $t(
6717
+ return { state: Rt(
6721
6718
  o,
6722
6719
  () => s.current,
6723
- () => wa
6720
+ () => ma
6724
6721
  ), query: r };
6725
6722
  }
6726
- function Sa() {
6723
+ function va() {
6727
6724
  const t = ze(null);
6728
6725
  ge(() => {
6729
6726
  n();
@@ -6736,8 +6733,8 @@ function Sa() {
6736
6733
  }
6737
6734
  return { set: e, clear: n };
6738
6735
  }
6739
- const Oa = 1e3;
6740
- function Ea(t, e, n) {
6736
+ const Sa = 1e3;
6737
+ function Oa(t, e, n) {
6741
6738
  const r = ze(n);
6742
6739
  r.current = n, ge(() => t.core._reactor.subscribeTopic(
6743
6740
  t.id,
@@ -6747,7 +6744,7 @@ function Ea(t, e, n) {
6747
6744
  }
6748
6745
  ), [t.id, e]);
6749
6746
  }
6750
- function Aa(t, e) {
6747
+ function Ea(t, e) {
6751
6748
  return ge(() => t.core._reactor.joinRoom(t.id), [t.id]), de(
6752
6749
  (r) => {
6753
6750
  t.core._reactor.publishTopic({
@@ -6760,9 +6757,9 @@ function Aa(t, e) {
6760
6757
  [t.id, e]
6761
6758
  );
6762
6759
  }
6763
- function ka(t, e = {}) {
6760
+ function Aa(t, e = {}) {
6764
6761
  var o, u;
6765
- const [n, r] = Er(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
6762
+ const [n, r] = Or(() => t.core._reactor.getPresence(t.type, t.id, e) ?? {
6766
6763
  peers: {},
6767
6764
  isLoading: !0
6768
6765
  });
@@ -6780,18 +6777,18 @@ function ka(t, e = {}) {
6780
6777
  },
6781
6778
  [t.type, t.id]
6782
6779
  );
6783
- return xt(() => ({
6780
+ return $t(() => ({
6784
6781
  ...n,
6785
6782
  publishPresence: i
6786
6783
  }), [n, i]);
6787
6784
  }
6788
- function ja(t, e, n) {
6785
+ function ka(t, e, n) {
6789
6786
  ge(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ge(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
6790
6787
  }
6791
- function Ca(t, e, n = {}) {
6792
- const r = Sa(), i = ye.usePresence(t, {
6788
+ function ja(t, e, n = {}) {
6789
+ const r = va(), i = ye.usePresence(t, {
6793
6790
  keys: [e]
6794
- }), s = xt(() => {
6791
+ }), s = $t(() => {
6795
6792
  const c = t._core._reactor.getPresence(
6796
6793
  t.type,
6797
6794
  t.id
@@ -6803,7 +6800,7 @@ function Ca(t, e, n = {}) {
6803
6800
  (c) => {
6804
6801
  t.core._reactor.publishPresence(t.type, t.id, {
6805
6802
  [e]: c
6806
- }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? Oa, () => {
6803
+ }), c && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((n == null ? void 0 : n.timeout) ?? Sa, () => {
6807
6804
  t.core._reactor.publishPresence(t.type, t.id, {
6808
6805
  [e]: null
6809
6806
  });
@@ -6818,7 +6815,7 @@ function Ca(t, e, n = {}) {
6818
6815
  [n.stopOnEnter, o]
6819
6816
  ), a = de(() => {
6820
6817
  o(!1);
6821
- }, [o]), d = xt(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
6818
+ }, [o]), d = $t(() => ({ onKeyDown: u, onBlur: a }), [u, a]);
6822
6819
  return {
6823
6820
  active: s,
6824
6821
  setActive: o,
@@ -6826,35 +6823,35 @@ function Ca(t, e, n = {}) {
6826
6823
  };
6827
6824
  }
6828
6825
  const ye = {
6829
- useTopicEffect: Ea,
6830
- usePublishTopic: Aa,
6831
- usePresence: ka,
6832
- useSyncPresence: ja,
6833
- useTypingIndicator: Ca
6826
+ useTopicEffect: Oa,
6827
+ usePublishTopic: Ea,
6828
+ usePresence: Aa,
6829
+ useSyncPresence: ka,
6830
+ useTypingIndicator: ja
6834
6831
  };
6835
- class Pa {
6832
+ class Ca {
6836
6833
  constructor(e, n, r) {
6837
6834
  this.useTopicEffect = (i, s) => {
6838
6835
  ye.useTopicEffect(this, i, s);
6839
6836
  }, this.usePublishTopic = (i) => ye.usePublishTopic(this, i), this.usePresence = (i = {}) => ye.usePresence(this, i), this.useSyncPresence = (i, s) => ye.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => ye.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
6840
6837
  }
6841
6838
  }
6842
- const Ia = {
6839
+ const Pa = {
6843
6840
  isLoading: !0,
6844
6841
  user: void 0,
6845
6842
  error: void 0
6846
6843
  };
6847
- class Ra {
6844
+ class Ma {
6848
6845
  constructor(e, n) {
6849
- this.tx = pn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6850
- const [i, s] = Er(null);
6846
+ this.tx = hn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
6847
+ const [i, s] = Or(null);
6851
6848
  return ge(() => {
6852
6849
  (async () => {
6853
6850
  const u = await this.getLocalId(r);
6854
6851
  s(u);
6855
6852
  })();
6856
6853
  }, [r]), i;
6857
- }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => va(
6854
+ }, this.rooms = ye, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => wa(
6858
6855
  this.core,
6859
6856
  r,
6860
6857
  i
@@ -6864,10 +6861,10 @@ class Ra {
6864
6861
  ), i = de((o) => this.core.subscribeAuth((a) => {
6865
6862
  r.current = { isLoading: !1, ...a }, o();
6866
6863
  }), []);
6867
- return $t(
6864
+ return Rt(
6868
6865
  i,
6869
6866
  () => r.current,
6870
- () => Ia
6867
+ () => Pa
6871
6868
  );
6872
6869
  }, this.useUser = () => {
6873
6870
  const { user: r } = this.useAuth();
@@ -6882,7 +6879,7 @@ class Ra {
6882
6879
  ), i = de((o) => this.core.subscribeConnectionStatus((a) => {
6883
6880
  a !== r.current && (r.current = a, o());
6884
6881
  }), []);
6885
- return $t(
6882
+ return Rt(
6886
6883
  i,
6887
6884
  () => r.current,
6888
6885
  // For SSR, always return 'connecting' as the initial state
@@ -6894,7 +6891,7 @@ class Ra {
6894
6891
  }, this.SignedOut = ({ children: r }) => {
6895
6892
  const i = this.useAuth();
6896
6893
  return i.isLoading || i.error || i.user ? null : /* @__PURE__ */ et.jsx(et.Fragment, { children: r });
6897
- }, this.core = Ta(
6894
+ }, this.core = ga(
6898
6895
  e,
6899
6896
  // @ts-expect-error because TS can't resolve subclass statics
6900
6897
  this.constructor.Storage,
@@ -6918,7 +6915,7 @@ class Ra {
6918
6915
  * const { peers } = db.rooms.usePresence(room);
6919
6916
  */
6920
6917
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
6921
- return new Pa(this.core, e, n);
6918
+ return new Ca(this.core, e, n);
6922
6919
  }
6923
6920
  /**
6924
6921
  * One time query for the logged in state. This is useful
@@ -6935,5 +6932,5 @@ class Ra {
6935
6932
  }
6936
6933
  }
6937
6934
  export {
6938
- Ra as InstantReactAbstractDatabase
6935
+ Ma as InstantReactAbstractDatabase
6939
6936
  };