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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var Gs = Object.defineProperty;
2
2
  var Hs = (n, e, t) => e in n ? Gs(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var p = (n, e, t) => Hs(n, typeof e != "symbol" ? e + "" : e, t);
4
- import Mr, { useRef as ke, useCallback as Ae, useSyncExternalStore as At, useEffect as je, useMemo as Jt, useState as Rr } from "react";
4
+ import Rr, { useRef as Oe, useCallback as Te, useSyncExternalStore as st, useEffect as je, useMemo as Jt, useState as Mr } from "react";
5
5
  var Yt = { exports: {} }, Je = {};
6
6
  /**
7
7
  * @license React
@@ -16,13 +16,13 @@ var zn;
16
16
  function Js() {
17
17
  if (zn) return Je;
18
18
  zn = 1;
19
- var n = Mr, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
19
+ var n = Rr, e = Symbol.for("react.element"), t = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, s = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
20
20
  function o(a, c, u) {
21
- var l, f = {}, h = null, y = null;
22
- u !== void 0 && (h = "" + u), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (y = c.ref);
21
+ var l, f = {}, h = null, b = null;
22
+ u !== void 0 && (h = "" + u), c.key !== void 0 && (h = "" + c.key), c.ref !== void 0 && (b = c.ref);
23
23
  for (l in c) r.call(c, l) && !i.hasOwnProperty(l) && (f[l] = c[l]);
24
24
  if (a && a.defaultProps) for (l in c = a.defaultProps, c) f[l] === void 0 && (f[l] = c[l]);
25
- return { $$typeof: e, type: a, key: h, ref: y, props: f, _owner: s.current };
25
+ return { $$typeof: e, type: a, key: h, ref: b, props: f, _owner: s.current };
26
26
  }
27
27
  return Je.Fragment = t, Je.jsx = o, Je.jsxs = o, Je;
28
28
  }
@@ -41,39 +41,39 @@ function Ys() {
41
41
  * LICENSE file in the root directory of this source tree.
42
42
  */
43
43
  return n.NODE_ENV !== "production" && function() {
44
- var e = Mr, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), b = Symbol.for("react.offscreen"), g = Symbol.iterator, m = "@@iterator";
44
+ var e = Rr, t = Symbol.for("react.element"), r = Symbol.for("react.portal"), s = Symbol.for("react.fragment"), i = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), a = Symbol.for("react.provider"), c = Symbol.for("react.context"), u = Symbol.for("react.forward_ref"), l = Symbol.for("react.suspense"), f = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), b = Symbol.for("react.lazy"), y = Symbol.for("react.offscreen"), g = Symbol.iterator, _ = "@@iterator";
45
45
  function S(d) {
46
46
  if (d === null || typeof d != "object")
47
47
  return null;
48
- var w = g && d[g] || d[m];
48
+ var w = g && d[g] || d[_];
49
49
  return typeof w == "function" ? w : null;
50
50
  }
51
- var _ = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
51
+ var m = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
52
52
  function T(d) {
53
53
  {
54
54
  for (var w = arguments.length, v = new Array(w > 1 ? w - 1 : 0), I = 1; I < w; I++)
55
55
  v[I - 1] = arguments[I];
56
- M("error", d, v);
56
+ C("error", d, v);
57
57
  }
58
58
  }
59
- function M(d, w, v) {
59
+ function C(d, w, v) {
60
60
  {
61
- var I = _.ReactDebugCurrentFrame, W = I.getStackAddendum();
61
+ var I = m.ReactDebugCurrentFrame, W = I.getStackAddendum();
62
62
  W !== "" && (w += "%s", v = v.concat([W]));
63
- var V = v.map(function(D) {
64
- return String(D);
63
+ var V = v.map(function(F) {
64
+ return String(F);
65
65
  });
66
66
  V.unshift("Warning: " + w), Function.prototype.apply.call(console[d], console, V);
67
67
  }
68
68
  }
69
- var O = !1, F = !1, P = !1, C = !1, G = !1, N;
70
- N = Symbol.for("react.module.reference");
69
+ var O = !1, M = !1, R = !1, P = !1, G = !1, L;
70
+ L = Symbol.for("react.module.reference");
71
71
  function B(d) {
72
- return !!(typeof d == "string" || typeof d == "function" || d === s || d === o || G || d === i || d === l || d === f || C || d === b || O || F || P || typeof d == "object" && d !== null && (d.$$typeof === y || d.$$typeof === h || d.$$typeof === a || d.$$typeof === c || d.$$typeof === u || // This needs to include all possible module reference object
72
+ return !!(typeof d == "string" || typeof d == "function" || d === s || d === o || G || d === i || d === l || d === f || P || d === y || O || M || R || typeof d == "object" && d !== null && (d.$$typeof === b || d.$$typeof === h || d.$$typeof === a || d.$$typeof === c || d.$$typeof === u || // This needs to include all possible module reference object
73
73
  // types supported by any Flight configuration anywhere since
74
74
  // we don't know which Flight build this will end up being used
75
75
  // with.
76
- d.$$typeof === N || d.getModuleId !== void 0));
76
+ d.$$typeof === L || d.getModuleId !== void 0));
77
77
  }
78
78
  function z(d, w, v) {
79
79
  var I = d.displayName;
@@ -119,10 +119,10 @@ function Ys() {
119
119
  case h:
120
120
  var I = d.displayName || null;
121
121
  return I !== null ? I : q(d.type) || "Memo";
122
- case y: {
123
- var W = d, V = W._payload, D = W._init;
122
+ case b: {
123
+ var W = d, V = W._payload, F = W._init;
124
124
  try {
125
- return q(D(V));
125
+ return q(F(V));
126
126
  } catch {
127
127
  return null;
128
128
  }
@@ -130,14 +130,14 @@ function Ys() {
130
130
  }
131
131
  return null;
132
132
  }
133
- var E = Object.assign, j = 0, R, U, L, A, k, K, H;
133
+ var E = Object.assign, $ = 0, j, x, N, A, k, K, H;
134
134
  function Y() {
135
135
  }
136
136
  Y.__reactDisabledLog = !0;
137
137
  function oe() {
138
138
  {
139
- if (j === 0) {
140
- R = console.log, U = console.info, L = console.warn, A = console.error, k = console.group, K = console.groupCollapsed, H = console.groupEnd;
139
+ if ($ === 0) {
140
+ j = console.log, x = console.info, N = console.warn, A = console.error, k = console.group, K = console.groupCollapsed, H = console.groupEnd;
141
141
  var d = {
142
142
  configurable: !0,
143
143
  enumerable: !0,
@@ -154,12 +154,12 @@ function Ys() {
154
154
  groupEnd: d
155
155
  });
156
156
  }
157
- j++;
157
+ $++;
158
158
  }
159
159
  }
160
160
  function Ge() {
161
161
  {
162
- if (j--, j === 0) {
162
+ if ($--, $ === 0) {
163
163
  var d = {
164
164
  configurable: !0,
165
165
  enumerable: !0,
@@ -167,13 +167,13 @@ function Ys() {
167
167
  };
168
168
  Object.defineProperties(console, {
169
169
  log: E({}, d, {
170
- value: R
170
+ value: j
171
171
  }),
172
172
  info: E({}, d, {
173
- value: U
173
+ value: x
174
174
  }),
175
175
  warn: E({}, d, {
176
- value: L
176
+ value: N
177
177
  }),
178
178
  error: E({}, d, {
179
179
  value: A
@@ -189,11 +189,11 @@ function Ys() {
189
189
  })
190
190
  });
191
191
  }
192
- j < 0 && T("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
192
+ $ < 0 && T("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
193
193
  }
194
194
  }
195
- var ge = _.ReactCurrentDispatcher, jt;
196
- function ut(d, w, v) {
195
+ var ge = m.ReactCurrentDispatcher, jt;
196
+ function lt(d, w, v) {
197
197
  {
198
198
  if (jt === void 0)
199
199
  try {
@@ -206,16 +206,16 @@ function Ys() {
206
206
  ` + jt + d;
207
207
  }
208
208
  }
209
- var $t = !1, lt;
209
+ var $t = !1, ft;
210
210
  {
211
211
  var vs = typeof WeakMap == "function" ? WeakMap : Map;
212
- lt = new vs();
212
+ ft = new vs();
213
213
  }
214
214
  function In(d, w) {
215
215
  if (!d || $t)
216
216
  return "";
217
217
  {
218
- var v = lt.get(d);
218
+ var v = ft.get(d);
219
219
  if (v !== void 0)
220
220
  return v;
221
221
  }
@@ -227,27 +227,27 @@ function Ys() {
227
227
  V = ge.current, ge.current = null, oe();
228
228
  try {
229
229
  if (w) {
230
- var D = function() {
230
+ var F = function() {
231
231
  throw Error();
232
232
  };
233
- if (Object.defineProperty(D.prototype, "props", {
233
+ if (Object.defineProperty(F.prototype, "props", {
234
234
  set: function() {
235
235
  throw Error();
236
236
  }
237
237
  }), typeof Reflect == "object" && Reflect.construct) {
238
238
  try {
239
- Reflect.construct(D, []);
239
+ Reflect.construct(F, []);
240
240
  } catch (ue) {
241
241
  I = ue;
242
242
  }
243
- Reflect.construct(d, [], D);
243
+ Reflect.construct(d, [], F);
244
244
  } else {
245
245
  try {
246
- D.call();
246
+ F.call();
247
247
  } catch (ue) {
248
248
  I = ue;
249
249
  }
250
- d.call(D.prototype);
250
+ d.call(F.prototype);
251
251
  }
252
252
  } else {
253
253
  try {
@@ -259,18 +259,18 @@ function Ys() {
259
259
  }
260
260
  } catch (ue) {
261
261
  if (ue && I && typeof ue.stack == "string") {
262
- for (var $ = ue.stack.split(`
262
+ for (var D = ue.stack.split(`
263
263
  `), ae = I.stack.split(`
264
- `), Z = $.length - 1, te = ae.length - 1; Z >= 1 && te >= 0 && $[Z] !== ae[te]; )
264
+ `), Z = D.length - 1, te = ae.length - 1; Z >= 1 && te >= 0 && D[Z] !== ae[te]; )
265
265
  te--;
266
266
  for (; Z >= 1 && te >= 0; Z--, te--)
267
- if ($[Z] !== ae[te]) {
267
+ if (D[Z] !== ae[te]) {
268
268
  if (Z !== 1 || te !== 1)
269
269
  do
270
- if (Z--, te--, te < 0 || $[Z] !== ae[te]) {
270
+ if (Z--, te--, te < 0 || D[Z] !== ae[te]) {
271
271
  var ye = `
272
- ` + $[Z].replace(" at new ", " at ");
273
- return d.displayName && ye.includes("<anonymous>") && (ye = ye.replace("<anonymous>", d.displayName)), typeof d == "function" && lt.set(d, ye), ye;
272
+ ` + D[Z].replace(" at new ", " at ");
273
+ return d.displayName && ye.includes("<anonymous>") && (ye = ye.replace("<anonymous>", d.displayName)), typeof d == "function" && ft.set(d, ye), ye;
274
274
  }
275
275
  while (Z >= 1 && te >= 0);
276
276
  break;
@@ -279,8 +279,8 @@ function Ys() {
279
279
  } finally {
280
280
  $t = !1, ge.current = V, Ge(), Error.prepareStackTrace = W;
281
281
  }
282
- var Le = d ? d.displayName || d.name : "", Ce = Le ? ut(Le) : "";
283
- return typeof d == "function" && lt.set(d, Ce), Ce;
282
+ var Le = d ? d.displayName || d.name : "", Ce = Le ? lt(Le) : "";
283
+ return typeof d == "function" && ft.set(d, Ce), Ce;
284
284
  }
285
285
  function As(d, w, v) {
286
286
  return In(d, !1);
@@ -289,59 +289,59 @@ function Ys() {
289
289
  var w = d.prototype;
290
290
  return !!(w && w.isReactComponent);
291
291
  }
292
- function ft(d, w, v) {
292
+ function dt(d, w, v) {
293
293
  if (d == null)
294
294
  return "";
295
295
  if (typeof d == "function")
296
296
  return In(d, Os(d));
297
297
  if (typeof d == "string")
298
- return ut(d);
298
+ return lt(d);
299
299
  switch (d) {
300
300
  case l:
301
- return ut("Suspense");
301
+ return lt("Suspense");
302
302
  case f:
303
- return ut("SuspenseList");
303
+ return lt("SuspenseList");
304
304
  }
305
305
  if (typeof d == "object")
306
306
  switch (d.$$typeof) {
307
307
  case u:
308
308
  return As(d.render);
309
309
  case h:
310
- return ft(d.type, w, v);
311
- case y: {
310
+ return dt(d.type, w, v);
311
+ case b: {
312
312
  var I = d, W = I._payload, V = I._init;
313
313
  try {
314
- return ft(V(W), w, v);
314
+ return dt(V(W), w, v);
315
315
  } catch {
316
316
  }
317
317
  }
318
318
  }
319
319
  return "";
320
320
  }
321
- var He = Object.prototype.hasOwnProperty, Pn = {}, Mn = _.ReactDebugCurrentFrame;
322
- function dt(d) {
321
+ var He = Object.prototype.hasOwnProperty, Pn = {}, Rn = m.ReactDebugCurrentFrame;
322
+ function ht(d) {
323
323
  if (d) {
324
- var w = d._owner, v = ft(d.type, d._source, w ? w.type : null);
325
- Mn.setExtraStackFrame(v);
324
+ var w = d._owner, v = dt(d.type, d._source, w ? w.type : null);
325
+ Rn.setExtraStackFrame(v);
326
326
  } else
327
- Mn.setExtraStackFrame(null);
327
+ Rn.setExtraStackFrame(null);
328
328
  }
329
329
  function Es(d, w, v, I, W) {
330
330
  {
331
331
  var V = Function.call.bind(He);
332
- for (var D in d)
333
- if (V(d, D)) {
334
- var $ = void 0;
332
+ for (var F in d)
333
+ if (V(d, F)) {
334
+ var D = void 0;
335
335
  try {
336
- if (typeof d[D] != "function") {
337
- var ae = Error((I || "React class") + ": " + v + " type `" + D + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof d[D] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
336
+ if (typeof d[F] != "function") {
337
+ var ae = Error((I || "React class") + ": " + v + " type `" + F + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof d[F] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
338
338
  throw ae.name = "Invariant Violation", ae;
339
339
  }
340
- $ = d[D](w, D, I, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
340
+ D = d[F](w, F, I, v, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
341
341
  } catch (Z) {
342
- $ = Z;
342
+ D = Z;
343
343
  }
344
- $ && !($ instanceof Error) && (dt(W), T("%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).", I || "React class", v, D, typeof $), dt(null)), $ instanceof Error && !($.message in Pn) && (Pn[$.message] = !0, dt(W), T("Failed %s type: %s", v, $.message), dt(null));
344
+ D && !(D instanceof Error) && (ht(W), T("%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).", I || "React class", v, F, typeof D), ht(null)), D instanceof Error && !(D.message in Pn) && (Pn[D.message] = !0, ht(W), T("Failed %s type: %s", v, D.message), ht(null));
345
345
  }
346
346
  }
347
347
  }
@@ -357,25 +357,25 @@ function Ys() {
357
357
  }
358
358
  function Is(d) {
359
359
  try {
360
- return Rn(d), !1;
360
+ return Mn(d), !1;
361
361
  } catch {
362
362
  return !0;
363
363
  }
364
364
  }
365
- function Rn(d) {
365
+ function Mn(d) {
366
366
  return "" + d;
367
367
  }
368
368
  function jn(d) {
369
369
  if (Is(d))
370
- return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Cs(d)), Rn(d);
370
+ return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Cs(d)), Mn(d);
371
371
  }
372
- var $n = _.ReactCurrentOwner, Ps = {
372
+ var $n = m.ReactCurrentOwner, Ps = {
373
373
  key: !0,
374
374
  ref: !0,
375
375
  __self: !0,
376
376
  __source: !0
377
377
  }, xn, Dn;
378
- function Ms(d) {
378
+ function Rs(d) {
379
379
  if (He.call(d, "ref")) {
380
380
  var w = Object.getOwnPropertyDescriptor(d, "ref").get;
381
381
  if (w && w.isReactWarning)
@@ -383,7 +383,7 @@ function Ys() {
383
383
  }
384
384
  return d.ref !== void 0;
385
385
  }
386
- function Rs(d) {
386
+ function Ms(d) {
387
387
  if (He.call(d, "key")) {
388
388
  var w = Object.getOwnPropertyDescriptor(d, "key").get;
389
389
  if (w && w.isReactWarning)
@@ -416,57 +416,57 @@ function Ys() {
416
416
  });
417
417
  }
418
418
  }
419
- var Ds = function(d, w, v, I, W, V, D) {
420
- var $ = {
419
+ var Ds = function(d, w, v, I, W, V, F) {
420
+ var D = {
421
421
  // This tag allows us to uniquely identify this as a React Element
422
422
  $$typeof: t,
423
423
  // Built-in properties that belong on the element
424
424
  type: d,
425
425
  key: w,
426
426
  ref: v,
427
- props: D,
427
+ props: F,
428
428
  // Record the component responsible for creating this element.
429
429
  _owner: V
430
430
  };
431
- return $._store = {}, Object.defineProperty($._store, "validated", {
431
+ return D._store = {}, Object.defineProperty(D._store, "validated", {
432
432
  configurable: !1,
433
433
  enumerable: !1,
434
434
  writable: !0,
435
435
  value: !1
436
- }), Object.defineProperty($, "_self", {
436
+ }), Object.defineProperty(D, "_self", {
437
437
  configurable: !1,
438
438
  enumerable: !1,
439
439
  writable: !1,
440
440
  value: I
441
- }), Object.defineProperty($, "_source", {
441
+ }), Object.defineProperty(D, "_source", {
442
442
  configurable: !1,
443
443
  enumerable: !1,
444
444
  writable: !1,
445
445
  value: W
446
- }), Object.freeze && (Object.freeze($.props), Object.freeze($)), $;
446
+ }), Object.freeze && (Object.freeze(D.props), Object.freeze(D)), D;
447
447
  };
448
448
  function Us(d, w, v, I, W) {
449
449
  {
450
- var V, D = {}, $ = null, ae = null;
451
- v !== void 0 && (jn(v), $ = "" + v), Rs(w) && (jn(w.key), $ = "" + w.key), Ms(w) && (ae = w.ref, js(w, W));
450
+ var V, F = {}, D = null, ae = null;
451
+ v !== void 0 && (jn(v), D = "" + v), Ms(w) && (jn(w.key), D = "" + w.key), Rs(w) && (ae = w.ref, js(w, W));
452
452
  for (V in w)
453
- He.call(w, V) && !Ps.hasOwnProperty(V) && (D[V] = w[V]);
453
+ He.call(w, V) && !Ps.hasOwnProperty(V) && (F[V] = w[V]);
454
454
  if (d && d.defaultProps) {
455
455
  var Z = d.defaultProps;
456
456
  for (V in Z)
457
- D[V] === void 0 && (D[V] = Z[V]);
457
+ F[V] === void 0 && (F[V] = Z[V]);
458
458
  }
459
- if ($ || ae) {
459
+ if (D || ae) {
460
460
  var te = typeof d == "function" ? d.displayName || d.name || "Unknown" : d;
461
- $ && $s(D, te), ae && xs(D, te);
461
+ D && $s(F, te), ae && xs(F, te);
462
462
  }
463
- return Ds(d, $, ae, W, I, $n.current, D);
463
+ return Ds(d, D, ae, W, I, $n.current, F);
464
464
  }
465
465
  }
466
- var Dt = _.ReactCurrentOwner, Un = _.ReactDebugCurrentFrame;
466
+ var Dt = m.ReactCurrentOwner, Un = m.ReactDebugCurrentFrame;
467
467
  function Ue(d) {
468
468
  if (d) {
469
- var w = d._owner, v = ft(d.type, d._source, w ? w.type : null);
469
+ var w = d._owner, v = dt(d.type, d._source, w ? w.type : null);
470
470
  Un.setExtraStackFrame(v);
471
471
  } else
472
472
  Un.setExtraStackFrame(null);
@@ -531,8 +531,8 @@ Check the top-level render call using <` + v + ">.");
531
531
  else if (d) {
532
532
  var W = S(d);
533
533
  if (typeof W == "function" && W !== d.entries)
534
- for (var V = W.call(d), D; !(D = V.next()).done; )
535
- Lt(D.value) && Nn(D.value, w);
534
+ for (var V = W.call(d), F; !(F = V.next()).done; )
535
+ Lt(F.value) && Nn(F.value, w);
536
536
  }
537
537
  }
538
538
  }
@@ -576,19 +576,19 @@ Check the top-level render call using <` + v + ">.");
576
576
  var qn = {};
577
577
  function Wn(d, w, v, I, W, V) {
578
578
  {
579
- var D = B(d);
580
- if (!D) {
581
- var $ = "";
582
- (d === void 0 || typeof d == "object" && d !== null && Object.keys(d).length === 0) && ($ += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
579
+ var F = B(d);
580
+ if (!F) {
581
+ var D = "";
582
+ (d === void 0 || typeof d == "object" && d !== null && Object.keys(d).length === 0) && (D += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
583
583
  var ae = Ls();
584
- ae ? $ += ae : $ += Ln();
584
+ ae ? D += ae : D += Ln();
585
585
  var Z;
586
- d === null ? Z = "null" : xt(d) ? Z = "array" : d !== void 0 && d.$$typeof === t ? (Z = "<" + (q(d.type) || "Unknown") + " />", $ = " Did you accidentally export a JSX literal instead of a component?") : Z = typeof d, T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", Z, $);
586
+ d === null ? Z = "null" : xt(d) ? Z = "array" : d !== void 0 && d.$$typeof === t ? (Z = "<" + (q(d.type) || "Unknown") + " />", D = " Did you accidentally export a JSX literal instead of a component?") : Z = typeof d, T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", Z, D);
587
587
  }
588
588
  var te = Us(d, w, v, W, V);
589
589
  if (te == null)
590
590
  return te;
591
- if (D) {
591
+ if (F) {
592
592
  var ye = w.children;
593
593
  if (ye !== void 0)
594
594
  if (I)
@@ -630,9 +630,9 @@ React keys must be passed directly to JSX without using spread:
630
630
  }
631
631
  var Zs = {};
632
632
  Zs.NODE_ENV === "production" ? Yt.exports = Js() : Yt.exports = Ys();
633
- var ht = Yt.exports;
634
- function se(n) {
635
- const e = mt(n);
633
+ var pt = Yt.exports;
634
+ function ie(n) {
635
+ const e = wt(n);
636
636
  let t = 3735928559 ^ e.length, r = 1103547991 ^ e.length;
637
637
  for (let s = 0; s < e.length; s++) {
638
638
  const i = e.charCodeAt(s);
@@ -640,13 +640,13 @@ function se(n) {
640
640
  }
641
641
  return t = Math.imul(t ^ t >>> 16, 2246822507) ^ Math.imul(r ^ r >>> 13, 3266489909), r = Math.imul(r ^ r >>> 16, 2246822507) ^ Math.imul(t ^ t >>> 13, 3266489909), `${(r >>> 0).toString(16).padStart(8, "0")}${(t >>> 0).toString(16).padStart(8, "0")}`;
642
642
  }
643
- function mt(n) {
643
+ function wt(n) {
644
644
  if (n && typeof n.toJSON == "function")
645
- return mt(n.toJSON());
645
+ return wt(n.toJSON());
646
646
  if (Array.isArray(n)) {
647
647
  let e = "[";
648
648
  for (let t = 0; t < n.length; t++)
649
- t > 0 && (e += ","), e += mt(n[t]);
649
+ t > 0 && (e += ","), e += wt(n[t]);
650
650
  return e + "]";
651
651
  }
652
652
  if (n && typeof n == "object") {
@@ -655,7 +655,7 @@ function mt(n) {
655
655
  let t = "{", r = !0;
656
656
  for (let s = 0; s < e.length; s++) {
657
657
  const i = e[s], o = n[i];
658
- o !== void 0 && (r || (t += ","), t += JSON.stringify(i) + ":" + mt(o), r = !1);
658
+ o !== void 0 && (r || (t += ","), t += JSON.stringify(i) + ":" + wt(o), r = !1);
659
659
  }
660
660
  return t + "}";
661
661
  }
@@ -706,11 +706,11 @@ const X = {
706
706
  Remove: "remove",
707
707
  Replace: "replace",
708
708
  Add: "add"
709
- }, jr = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Xs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), wt = Symbol.iterator, pe = {
709
+ }, jr = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Xs = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), St = Symbol.iterator, pe = {
710
710
  mutable: "mutable",
711
711
  immutable: "immutable"
712
712
  }, bn = {};
713
- function st(n, e) {
713
+ function it(n, e) {
714
714
  return n instanceof Map ? n.has(e) : Object.prototype.hasOwnProperty.call(n, e);
715
715
  }
716
716
  function Qn(n, e) {
@@ -735,14 +735,14 @@ function he(n) {
735
735
  return (e = n.copy) !== null && e !== void 0 ? e : n.original;
736
736
  }
737
737
  function $e(n) {
738
- return !!x(n);
738
+ return !!U(n);
739
739
  }
740
- function x(n) {
740
+ function U(n) {
741
741
  return typeof n != "object" ? null : n == null ? void 0 : n[jr];
742
742
  }
743
743
  function mn(n) {
744
744
  var e;
745
- const t = x(n);
745
+ const t = U(n);
746
746
  return t ? (e = t.copy) !== null && e !== void 0 ? e : t.original : n;
747
747
  }
748
748
  function me(n, e) {
@@ -753,11 +753,11 @@ function me(n, e) {
753
753
  }
754
754
  function $r(n, e = []) {
755
755
  if (Object.hasOwnProperty.call(n, "key")) {
756
- const t = n.parent.copy, r = x(Ee(t, n.key));
756
+ const t = n.parent.copy, r = U(ke(t, n.key));
757
757
  if (r !== null && (r == null ? void 0 : r.original) !== n.original)
758
758
  return null;
759
759
  const s = n.parent.type === 3, i = s ? Array.from(n.parent.setMap.keys()).indexOf(n.key) : n.key;
760
- if (!(s && t.size > i || st(t, i)))
760
+ if (!(s && t.size > i || it(t, i)))
761
761
  return null;
762
762
  e.push(i);
763
763
  }
@@ -774,17 +774,17 @@ function $r(n, e = []) {
774
774
  function xe(n) {
775
775
  return Array.isArray(n) ? 1 : n instanceof Map ? 2 : n instanceof Set ? 3 : 0;
776
776
  }
777
- function Ee(n, e) {
777
+ function ke(n, e) {
778
778
  return xe(n) === 2 ? n.get(e) : n[e];
779
779
  }
780
- function at(n, e, t) {
780
+ function ct(n, e, t) {
781
781
  xe(n) === 2 ? n.set(e, t) : n[e] = t;
782
782
  }
783
783
  function Nt(n, e) {
784
- const t = x(n);
784
+ const t = U(n);
785
785
  return (t ? he(t) : n)[e];
786
786
  }
787
- function Oe(n, e) {
787
+ function Ee(n, e) {
788
788
  return n === e ? n !== 0 || 1 / n === 1 / e : n !== n && e !== e;
789
789
  }
790
790
  function Zt(n) {
@@ -792,7 +792,7 @@ function Zt(n) {
792
792
  for (; n.finalities.revoke.length > 0; )
793
793
  n.finalities.revoke.pop()();
794
794
  }
795
- function Me(n, e) {
795
+ function Re(n, e) {
796
796
  return e ? n : [""].concat(n).map((t) => {
797
797
  const r = `${t}`;
798
798
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
@@ -801,7 +801,7 @@ function Me(n, e) {
801
801
  function ei(n, e) {
802
802
  for (let t = 0; t < e.length - 1; t += 1) {
803
803
  const r = e[t];
804
- if (n = Ee(xe(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
804
+ if (n = ke(xe(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
805
805
  throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
806
806
  }
807
807
  return n;
@@ -893,9 +893,9 @@ function Xe(n) {
893
893
  function Tt(n) {
894
894
  return $e(n) ? Xe(n) : n;
895
895
  }
896
- function Se(n) {
896
+ function ve(n) {
897
897
  var e;
898
- n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && Se(n.parent));
898
+ n.assignedMap = (e = n.assignedMap) !== null && e !== void 0 ? e : /* @__PURE__ */ new Map(), n.operated || (n.operated = !0, n.parent && ve(n.parent));
899
899
  }
900
900
  function Bn() {
901
901
  throw new Error("Cannot modify frozen object");
@@ -966,10 +966,10 @@ function Dr(n, e, t) {
966
966
  if (e.add(n), wn(n, (i, o) => {
967
967
  var a;
968
968
  if ($e(o)) {
969
- const c = x(o);
969
+ const c = U(o);
970
970
  ce(c);
971
971
  const u = !((a = c.assignedMap) === null || a === void 0) && a.size || c.operated ? c.copy : c.original;
972
- at(r ? s : n, i, u);
972
+ ct(r ? s : n, i, u);
973
973
  } else
974
974
  Dr(o, e, t);
975
975
  }), s) {
@@ -981,7 +981,7 @@ function Dr(n, e, t) {
981
981
  }
982
982
  function ri(n, e) {
983
983
  const t = n.type === 3 ? n.setMap : n.copy;
984
- n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && Dr(Ee(t, e), n.finalities.handledSet, n.options);
984
+ n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && Dr(ke(t, e), n.finalities.handledSet, n.options);
985
985
  }
986
986
  function Xt(n) {
987
987
  n.type === 3 && n.copy && (n.copy.clear(), n.setMap.forEach((e) => {
@@ -997,18 +997,18 @@ function en(n, e, t, r) {
997
997
  n.finalized = !0;
998
998
  }
999
999
  }
1000
- function Tn(n, e, t, r) {
1001
- const s = x(t);
1000
+ function Sn(n, e, t, r) {
1001
+ const s = U(t);
1002
1002
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((i, o) => {
1003
1003
  var a;
1004
1004
  const c = n.type === 3 ? n.setMap : n.copy;
1005
- if (Oe(Ee(c, e), t)) {
1005
+ if (Ee(ke(c, e), t)) {
1006
1006
  let u = s.original;
1007
- s.copy && (u = s.copy), Xt(n), en(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), at(c, e, u);
1007
+ s.copy && (u = s.copy), Xt(n), en(n, r, i, o), n.options.enableAutoFreeze && (n.options.updatedValues = (a = n.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), n.options.updatedValues.set(u, s.original)), ct(c, e, u);
1008
1008
  }
1009
1009
  }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), me(t, n.options) && n.finalities.draft.push(() => {
1010
1010
  const i = n.type === 3 ? n.setMap : n.copy;
1011
- Oe(Ee(i, e), t) && ri(n, e);
1011
+ Ee(ke(i, e), t) && ri(n, e);
1012
1012
  });
1013
1013
  }
1014
1014
  function si(n, e, t, r, s) {
@@ -1016,7 +1016,7 @@ function si(n, e, t, r, s) {
1016
1016
  c.length < i.length && ([i, c] = [c, i], [t, r] = [r, t]);
1017
1017
  for (let u = 0; u < i.length; u += 1)
1018
1018
  if (o.get(u.toString()) && c[u] !== i[u]) {
1019
- const l = e.concat([u]), f = Me(l, s);
1019
+ const l = e.concat([u]), f = Re(l, s);
1020
1020
  t.push({
1021
1021
  op: X.Replace,
1022
1022
  path: f,
@@ -1030,7 +1030,7 @@ function si(n, e, t, r, s) {
1030
1030
  });
1031
1031
  }
1032
1032
  for (let u = i.length; u < c.length; u += 1) {
1033
- const l = e.concat([u]), f = Me(l, s);
1033
+ const l = e.concat([u]), f = Re(l, s);
1034
1034
  t.push({
1035
1035
  op: X.Add,
1036
1036
  path: f,
@@ -1041,7 +1041,7 @@ function si(n, e, t, r, s) {
1041
1041
  if (i.length < c.length) {
1042
1042
  const { arrayLengthAssignment: u = !0 } = a.enablePatches;
1043
1043
  if (u) {
1044
- const l = e.concat(["length"]), f = Me(l, s);
1044
+ const l = e.concat(["length"]), f = Re(l, s);
1045
1045
  r.push({
1046
1046
  op: X.Replace,
1047
1047
  path: f,
@@ -1049,7 +1049,7 @@ function si(n, e, t, r, s) {
1049
1049
  });
1050
1050
  } else
1051
1051
  for (let l = c.length; i.length < l; l -= 1) {
1052
- const f = e.concat([l - 1]), h = Me(f, s);
1052
+ const f = e.concat([l - 1]), h = Re(f, s);
1053
1053
  r.push({
1054
1054
  op: X.Remove,
1055
1055
  path: h
@@ -1059,18 +1059,18 @@ function si(n, e, t, r, s) {
1059
1059
  }
1060
1060
  function ii({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
1061
1061
  t.forEach((a, c) => {
1062
- const u = Ee(n, c), l = Tt(Ee(e, c)), f = a ? st(n, c) ? X.Replace : X.Add : X.Remove;
1063
- if (Oe(u, l) && f === X.Replace)
1062
+ const u = ke(n, c), l = Tt(ke(e, c)), f = a ? it(n, c) ? X.Replace : X.Add : X.Remove;
1063
+ if (Ee(u, l) && f === X.Replace)
1064
1064
  return;
1065
- const h = r.concat(c), y = Me(h, o);
1066
- s.push(f === X.Remove ? { op: f, path: y } : { op: f, path: y, value: l }), i.push(f === X.Add ? { op: X.Remove, path: y } : f === X.Remove ? { op: X.Add, path: y, value: u } : { op: X.Replace, path: y, value: u });
1065
+ const h = r.concat(c), b = Re(h, o);
1066
+ s.push(f === X.Remove ? { op: f, path: b } : { op: f, path: b, value: l }), i.push(f === X.Add ? { op: X.Remove, path: b } : f === X.Remove ? { op: X.Add, path: b, value: u } : { op: X.Replace, path: b, value: u });
1067
1067
  });
1068
1068
  }
1069
1069
  function oi({ original: n, copy: e }, t, r, s, i) {
1070
1070
  let o = 0;
1071
1071
  n.forEach((a) => {
1072
1072
  if (!e.has(a)) {
1073
- const c = t.concat([o]), u = Me(c, i);
1073
+ const c = t.concat([o]), u = Re(c, i);
1074
1074
  r.push({
1075
1075
  op: X.Remove,
1076
1076
  path: u,
@@ -1084,7 +1084,7 @@ function oi({ original: n, copy: e }, t, r, s, i) {
1084
1084
  o += 1;
1085
1085
  }), o = 0, e.forEach((a) => {
1086
1086
  if (!n.has(a)) {
1087
- const c = t.concat([o]), u = Me(c, i);
1087
+ const c = t.concat([o]), u = Re(c, i);
1088
1088
  r.push({
1089
1089
  op: X.Add,
1090
1090
  path: u,
@@ -1098,7 +1098,7 @@ function oi({ original: n, copy: e }, t, r, s, i) {
1098
1098
  o += 1;
1099
1099
  });
1100
1100
  }
1101
- function ot(n, e, t, r) {
1101
+ function at(n, e, t, r) {
1102
1102
  const { pathAsArray: s = !0 } = n.options.enablePatches;
1103
1103
  switch (n.type) {
1104
1104
  case 0:
@@ -1115,39 +1115,39 @@ const Ot = (n, e, t = !1) => {
1115
1115
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
1116
1116
  }, tn = {
1117
1117
  get size() {
1118
- return he(x(this)).size;
1118
+ return he(U(this)).size;
1119
1119
  },
1120
1120
  has(n) {
1121
- return he(x(this)).has(n);
1121
+ return he(U(this)).has(n);
1122
1122
  },
1123
1123
  set(n, e) {
1124
- const t = x(this), r = he(t);
1125
- return (!r.has(n) || !Oe(r.get(n), e)) && (ce(t), Se(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Tn(t, n, e, ot)), this;
1124
+ const t = U(this), r = he(t);
1125
+ return (!r.has(n) || !Ee(r.get(n), e)) && (ce(t), ve(t), t.assignedMap.set(n, !0), t.copy.set(n, e), Sn(t, n, e, at)), this;
1126
1126
  },
1127
1127
  delete(n) {
1128
1128
  if (!this.has(n))
1129
1129
  return !1;
1130
- const e = x(this);
1131
- return ce(e), Se(e), e.original.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.copy.delete(n), !0;
1130
+ const e = U(this);
1131
+ return ce(e), ve(e), e.original.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.copy.delete(n), !0;
1132
1132
  },
1133
1133
  clear() {
1134
- const n = x(this);
1134
+ const n = U(this);
1135
1135
  if (this.size) {
1136
- ce(n), Se(n), n.assignedMap = /* @__PURE__ */ new Map();
1136
+ ce(n), ve(n), n.assignedMap = /* @__PURE__ */ new Map();
1137
1137
  for (const [e] of n.original)
1138
1138
  n.assignedMap.set(e, !1);
1139
1139
  n.copy.clear();
1140
1140
  }
1141
1141
  },
1142
1142
  forEach(n, e) {
1143
- const t = x(this);
1143
+ const t = U(this);
1144
1144
  he(t).forEach((r, s) => {
1145
1145
  n.call(e, this.get(s), s, this);
1146
1146
  });
1147
1147
  },
1148
1148
  get(n) {
1149
1149
  var e, t;
1150
- const r = x(this), s = he(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, pe)) === pe.mutable;
1150
+ const r = U(this), s = he(r).get(n), i = ((t = (e = r.options).mark) === null || t === void 0 ? void 0 : t.call(e, s, pe)) === pe.mutable;
1151
1151
  if (r.options.strict && Ot(s, r.options, i), i || r.finalized || !me(s, r.options) || s !== r.original.get(n))
1152
1152
  return s;
1153
1153
  const o = bn.createDraft({
@@ -1160,12 +1160,12 @@ const Ot = (n, e, t = !1) => {
1160
1160
  return ce(r), r.copy.set(n, o), o;
1161
1161
  },
1162
1162
  keys() {
1163
- return he(x(this)).keys();
1163
+ return he(U(this)).keys();
1164
1164
  },
1165
1165
  values() {
1166
1166
  const n = this.keys();
1167
1167
  return {
1168
- [wt]: () => this.values(),
1168
+ [St]: () => this.values(),
1169
1169
  next: () => {
1170
1170
  const e = n.next();
1171
1171
  return e.done ? e : {
@@ -1178,7 +1178,7 @@ const Ot = (n, e, t = !1) => {
1178
1178
  entries() {
1179
1179
  const n = this.keys();
1180
1180
  return {
1181
- [wt]: () => this.entries(),
1181
+ [St]: () => this.entries(),
1182
1182
  next: () => {
1183
1183
  const e = n.next();
1184
1184
  if (e.done)
@@ -1191,7 +1191,7 @@ const Ot = (n, e, t = !1) => {
1191
1191
  }
1192
1192
  };
1193
1193
  },
1194
- [wt]() {
1194
+ [St]() {
1195
1195
  return this.entries();
1196
1196
  }
1197
1197
  }, ai = Reflect.ownKeys(tn), Gn = (n, e, { isValuesIterator: t }) => () => {
@@ -1201,7 +1201,7 @@ const Ot = (n, e, t = !1) => {
1201
1201
  return i;
1202
1202
  const o = i.value;
1203
1203
  let a = n.setMap.get(o);
1204
- const c = x(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, pe)) === pe.mutable;
1204
+ const c = U(a), u = ((s = (r = n.options).mark) === null || s === void 0 ? void 0 : s.call(r, a, pe)) === pe.mutable;
1205
1205
  if (n.options.strict && Ot(o, n.options, u), !u && !c && me(o, n.options) && !n.finalized && n.original.has(o)) {
1206
1206
  const l = bn.createDraft({
1207
1207
  original: o,
@@ -1218,39 +1218,39 @@ const Ot = (n, e, t = !1) => {
1218
1218
  };
1219
1219
  }, Et = {
1220
1220
  get size() {
1221
- return x(this).setMap.size;
1221
+ return U(this).setMap.size;
1222
1222
  },
1223
1223
  has(n) {
1224
- const e = x(this);
1224
+ const e = U(this);
1225
1225
  if (e.setMap.has(n))
1226
1226
  return !0;
1227
1227
  ce(e);
1228
- const t = x(n);
1228
+ const t = U(n);
1229
1229
  return !!(t && e.setMap.has(t.original));
1230
1230
  },
1231
1231
  add(n) {
1232
- const e = x(this);
1233
- return this.has(n) || (ce(e), Se(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Tn(e, n, n, ot)), this;
1232
+ const e = U(this);
1233
+ return this.has(n) || (ce(e), ve(e), e.assignedMap.set(n, !0), e.setMap.set(n, n), Sn(e, n, n, at)), this;
1234
1234
  },
1235
1235
  delete(n) {
1236
1236
  if (!this.has(n))
1237
1237
  return !1;
1238
- const e = x(this);
1239
- ce(e), Se(e);
1240
- const t = x(n);
1238
+ const e = U(this);
1239
+ ce(e), ve(e);
1240
+ const t = U(n);
1241
1241
  return t && e.setMap.has(t.original) ? (e.assignedMap.set(t.original, !1), e.setMap.delete(t.original)) : (!t && e.setMap.has(n) ? e.assignedMap.set(n, !1) : e.assignedMap.delete(n), e.setMap.delete(n));
1242
1242
  },
1243
1243
  clear() {
1244
1244
  if (!this.size)
1245
1245
  return;
1246
- const n = x(this);
1247
- ce(n), Se(n);
1246
+ const n = U(this);
1247
+ ce(n), ve(n);
1248
1248
  for (const e of n.original)
1249
1249
  n.assignedMap.set(e, !1);
1250
1250
  n.setMap.clear();
1251
1251
  },
1252
1252
  values() {
1253
- const n = x(this);
1253
+ const n = U(this);
1254
1254
  ce(n);
1255
1255
  const e = n.setMap.keys();
1256
1256
  return {
@@ -1259,7 +1259,7 @@ const Ot = (n, e, t = !1) => {
1259
1259
  };
1260
1260
  },
1261
1261
  entries() {
1262
- const n = x(this);
1262
+ const n = U(this);
1263
1263
  ce(n);
1264
1264
  const e = n.setMap.keys();
1265
1265
  return {
@@ -1272,7 +1272,7 @@ const Ot = (n, e, t = !1) => {
1272
1272
  keys() {
1273
1273
  return this.values();
1274
1274
  },
1275
- [wt]() {
1275
+ [St]() {
1276
1276
  return this.values();
1277
1277
  },
1278
1278
  forEach(n, e) {
@@ -1334,7 +1334,7 @@ const ci = Reflect.ownKeys(Et), Ur = /* @__PURE__ */ new WeakSet(), Lr = {
1334
1334
  if (u)
1335
1335
  return u.bind(n.proxy);
1336
1336
  }
1337
- if (!st(a, e)) {
1337
+ if (!it(a, e)) {
1338
1338
  const u = Qn(a, e);
1339
1339
  return u ? "value" in u ? u.value : (
1340
1340
  // !case: support for getter
@@ -1345,15 +1345,15 @@ const ci = Reflect.ownKeys(Et), Ur = /* @__PURE__ */ new WeakSet(), Lr = {
1345
1345
  if (n.options.strict && Ot(c, n.options), n.finalized || !me(c, n.options))
1346
1346
  return c;
1347
1347
  if (c === Nt(n.original, e)) {
1348
- if (ce(n), n.copy[e] = Sn({
1348
+ if (ce(n), n.copy[e] = Tn({
1349
1349
  original: n.original[e],
1350
1350
  parentDraft: n,
1351
1351
  key: n.type === 1 ? Number(e) : e,
1352
1352
  finalities: n.finalities,
1353
1353
  options: n.options
1354
1354
  }), typeof o == "function") {
1355
- const u = x(n.copy[e]);
1356
- return ce(u), Se(u), u.copy;
1355
+ const u = U(n.copy[e]);
1356
+ return ce(u), ve(u), u.copy;
1357
1357
  }
1358
1358
  return n.copy[e];
1359
1359
  }
@@ -1369,8 +1369,8 @@ const ci = Reflect.ownKeys(Et), Ur = /* @__PURE__ */ new WeakSet(), Lr = {
1369
1369
  const i = Qn(he(n), e);
1370
1370
  if (i != null && i.set)
1371
1371
  return i.set.call(n.proxy, t), !0;
1372
- const o = Nt(he(n), e), a = x(o);
1373
- return a && Oe(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Oe(t, o) && (t !== void 0 || st(n.original, e)) || (ce(n), Se(n), st(n.original, e) && Oe(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Tn(n, e, t, ot)), !0);
1372
+ const o = Nt(he(n), e), a = U(o);
1373
+ return a && Ee(a.original, t) ? (n.copy[e] = t, n.assignedMap = (r = n.assignedMap) !== null && r !== void 0 ? r : /* @__PURE__ */ new Map(), n.assignedMap.set(e, !1), !0) : (Ee(t, o) && (t !== void 0 || it(n.original, e)) || (ce(n), ve(n), it(n.original, e) && Ee(t, n.original[e]) ? n.assignedMap.delete(e) : n.assignedMap.set(e, !0), n.copy[e] = t, Sn(n, e, t, at)), !0);
1374
1374
  },
1375
1375
  has(n, e) {
1376
1376
  return e in he(n);
@@ -1398,10 +1398,10 @@ const ci = Reflect.ownKeys(Et), Ur = /* @__PURE__ */ new WeakSet(), Lr = {
1398
1398
  },
1399
1399
  deleteProperty(n, e) {
1400
1400
  var t;
1401
- return n.type === 1 ? Lr.set.call(this, n, e, void 0, n.proxy) : (Nt(n.original, e) !== void 0 || e in n.original ? (ce(n), Se(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
1401
+ return n.type === 1 ? Lr.set.call(this, n, e, void 0, n.proxy) : (Nt(n.original, e) !== void 0 || e in n.original ? (ce(n), ve(n), n.assignedMap.set(e, !1)) : (n.assignedMap = (t = n.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), n.assignedMap.delete(e)), n.copy && delete n.copy[e], !0);
1402
1402
  }
1403
1403
  };
1404
- function Sn(n) {
1404
+ function Tn(n) {
1405
1405
  const { original: e, parentDraft: t, key: r, finalities: s, options: i } = n, o = xe(e), a = {
1406
1406
  type: o,
1407
1407
  finalized: !1,
@@ -1419,30 +1419,30 @@ function Sn(n) {
1419
1419
  if (s.revoke.push(u), Ur.add(c), a.proxy = c, t) {
1420
1420
  const l = t;
1421
1421
  l.finalities.draft.push((f, h) => {
1422
- var y, b;
1423
- const g = x(c);
1424
- let m = l.type === 3 ? l.setMap : l.copy;
1425
- const S = Ee(m, r), _ = x(S);
1426
- if (_) {
1427
- let T = _.original;
1428
- _.operated && (T = mn(S)), Xt(_), en(_, ot, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, _.original)), at(m, r, T);
1422
+ var b, y;
1423
+ const g = U(c);
1424
+ let _ = l.type === 3 ? l.setMap : l.copy;
1425
+ const S = ke(_, r), m = U(S);
1426
+ if (m) {
1427
+ let T = m.original;
1428
+ m.operated && (T = mn(S)), Xt(m), en(m, at, f, h), l.options.enableAutoFreeze && (l.options.updatedValues = (b = l.options.updatedValues) !== null && b !== void 0 ? b : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(T, m.original)), ct(_, r, T);
1429
1429
  }
1430
- (b = g.callbacks) === null || b === void 0 || b.forEach((T) => {
1430
+ (y = g.callbacks) === null || y === void 0 || y.forEach((T) => {
1431
1431
  T(f, h);
1432
1432
  });
1433
1433
  });
1434
1434
  } else {
1435
- const l = x(c);
1435
+ const l = U(c);
1436
1436
  l.finalities.draft.push((f, h) => {
1437
- Xt(l), en(l, ot, f, h);
1437
+ Xt(l), en(l, at, f, h);
1438
1438
  });
1439
1439
  }
1440
1440
  return c;
1441
1441
  }
1442
- bn.createDraft = Sn;
1442
+ bn.createDraft = Tn;
1443
1443
  function ui(n, e, t, r, s) {
1444
1444
  var i;
1445
- const o = x(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
1445
+ const o = U(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
1446
1446
  if (o != null && o.operated)
1447
1447
  for (; o.finalities.draft.length > 0; )
1448
1448
  o.finalities.draft.pop()(t, r);
@@ -1462,7 +1462,7 @@ function li(n, e) {
1462
1462
  };
1463
1463
  let s, i;
1464
1464
  e.enablePatches && (s = [], i = []);
1465
- const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, pe)) === pe.mutable || !me(n, e) ? n : Sn({
1465
+ const a = ((t = e.mark) === null || t === void 0 ? void 0 : t.call(e, n, pe)) === pe.mutable || !me(n, e) ? n : Tn({
1466
1466
  original: n,
1467
1467
  parentDraft: null,
1468
1468
  finalities: r,
@@ -1479,7 +1479,7 @@ function li(n, e) {
1479
1479
  function nn(n) {
1480
1480
  const { rootDraft: e, value: t, useRawReturn: r = !1, isRoot: s = !0 } = n;
1481
1481
  wn(t, (i, o, a) => {
1482
- const c = x(o);
1482
+ const c = U(o);
1483
1483
  if (c && e && c.finalities === e.finalities) {
1484
1484
  n.isContainDraft = !0;
1485
1485
  const u = c.original;
@@ -1487,13 +1487,13 @@ function nn(n) {
1487
1487
  const l = Array.from(a);
1488
1488
  a.clear(), l.forEach((f) => a.add(i === f ? u : f));
1489
1489
  } else
1490
- at(a, i, u);
1490
+ ct(a, i, u);
1491
1491
  } else typeof o == "object" && o !== null && (n.value = o, n.isRoot = !1, nn(n));
1492
1492
  }), s && (n.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), r && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
1493
1493
  }
1494
1494
  function Fr(n) {
1495
1495
  var e;
1496
- const t = x(n);
1496
+ const t = U(n);
1497
1497
  if (!me(n, t == null ? void 0 : t.options))
1498
1498
  return n;
1499
1499
  const r = xe(n);
@@ -1513,10 +1513,10 @@ function Fr(n) {
1513
1513
  } else
1514
1514
  s = n;
1515
1515
  if (wn(s, (o, a) => {
1516
- if (t && Oe(Ee(t.original, o), a))
1516
+ if (t && Ee(ke(t.original, o), a))
1517
1517
  return;
1518
1518
  const c = Fr(a);
1519
- c !== a && (s === n && i(), at(s, o, c));
1519
+ c !== a && (s === n && i(), ct(s, o, c));
1520
1520
  }), r === 3) {
1521
1521
  const o = (e = t == null ? void 0 : t.original) !== null && e !== void 0 ? e : s;
1522
1522
  return gn(o) ? new Set(s) : new (Object.getPrototypeOf(o)).constructor(s);
@@ -1531,72 +1531,72 @@ function Hn(n) {
1531
1531
  const fi = (n) => function e(t, r, s) {
1532
1532
  var i, o, a;
1533
1533
  if (typeof t == "function" && typeof r != "function")
1534
- return function(O, ...F) {
1535
- return e(O, (P) => t.call(this, P, ...F), r);
1534
+ return function(O, ...M) {
1535
+ return e(O, (R) => t.call(this, R, ...M), r);
1536
1536
  };
1537
1537
  const c = t, u = r;
1538
1538
  let l = s;
1539
1539
  if (typeof r != "function" && (l = r), l !== void 0 && Object.prototype.toString.call(l) !== "[object Object]")
1540
1540
  throw new Error(`Invalid options: ${l}, 'options' should be an object.`);
1541
1541
  l = Object.assign(Object.assign({}, n), l);
1542
- const f = $e(c) ? Hn(c) : c, h = Array.isArray(l.mark) ? (O, F) => {
1543
- for (const P of l.mark) {
1544
- if (typeof P != "function")
1545
- throw new Error(`Invalid mark: ${P}, 'mark' should be a function.`);
1546
- const C = P(O, F);
1547
- if (C)
1548
- return C;
1549
- }
1550
- } : l.mark, y = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, b = (o = l.strict) !== null && o !== void 0 ? o : !1, m = {
1542
+ const f = $e(c) ? Hn(c) : c, h = Array.isArray(l.mark) ? (O, M) => {
1543
+ for (const R of l.mark) {
1544
+ if (typeof R != "function")
1545
+ throw new Error(`Invalid mark: ${R}, 'mark' should be a function.`);
1546
+ const P = R(O, M);
1547
+ if (P)
1548
+ return P;
1549
+ }
1550
+ } : l.mark, b = (i = l.enablePatches) !== null && i !== void 0 ? i : !1, y = (o = l.strict) !== null && o !== void 0 ? o : !1, _ = {
1551
1551
  enableAutoFreeze: (a = l.enableAutoFreeze) !== null && a !== void 0 ? a : !1,
1552
1552
  mark: h,
1553
- strict: b,
1554
- enablePatches: y
1553
+ strict: y,
1554
+ enablePatches: b
1555
1555
  };
1556
- if (!me(f, m) && typeof f == "object" && f !== null)
1556
+ if (!me(f, _) && typeof f == "object" && f !== null)
1557
1557
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1558
- const [S, _] = li(f, m);
1558
+ const [S, m] = li(f, _);
1559
1559
  if (typeof r != "function") {
1560
- if (!me(f, m))
1560
+ if (!me(f, _))
1561
1561
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
1562
- return [S, _];
1562
+ return [S, m];
1563
1563
  }
1564
1564
  let T;
1565
1565
  try {
1566
1566
  T = u(S);
1567
1567
  } catch (O) {
1568
- throw Zt(x(S)), O;
1568
+ throw Zt(U(S)), O;
1569
1569
  }
1570
- const M = (O) => {
1571
- const F = x(S);
1570
+ const C = (O) => {
1571
+ const M = U(S);
1572
1572
  if (!$e(O)) {
1573
- if (O !== void 0 && !Oe(O, S) && (F != null && F.operated))
1573
+ if (O !== void 0 && !Ee(O, S) && (M != null && M.operated))
1574
1574
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
1575
- const C = O == null ? void 0 : O[Xs];
1576
- if (C) {
1577
- const G = C[0];
1578
- return m.strict && typeof O == "object" && O !== null && nn({
1579
- rootDraft: F,
1575
+ const P = O == null ? void 0 : O[Xs];
1576
+ if (P) {
1577
+ const G = P[0];
1578
+ return _.strict && typeof O == "object" && O !== null && nn({
1579
+ rootDraft: M,
1580
1580
  value: O,
1581
1581
  useRawReturn: !0
1582
- }), _([G]);
1582
+ }), m([G]);
1583
1583
  }
1584
1584
  if (O !== void 0)
1585
- return typeof O == "object" && O !== null && nn({ rootDraft: F, value: O }), _([O]);
1585
+ return typeof O == "object" && O !== null && nn({ rootDraft: M, value: O }), m([O]);
1586
1586
  }
1587
1587
  if (O === S || O === void 0)
1588
- return _([]);
1589
- const P = x(O);
1590
- if (m === P.options) {
1591
- if (P.operated)
1588
+ return m([]);
1589
+ const R = U(O);
1590
+ if (_ === R.options) {
1591
+ if (R.operated)
1592
1592
  throw new Error("Cannot return a modified child draft.");
1593
- return _([Hn(O)]);
1593
+ return m([Hn(O)]);
1594
1594
  }
1595
- return _([O]);
1595
+ return m([O]);
1596
1596
  };
1597
- return T instanceof Promise ? T.then(M, (O) => {
1598
- throw Zt(x(S)), O;
1599
- }) : M(T);
1597
+ return T instanceof Promise ? T.then(C, (O) => {
1598
+ throw Zt(U(S)), O;
1599
+ }) : C(T);
1600
1600
  }, kt = fi();
1601
1601
  Object.prototype.constructor.toString();
1602
1602
  function Nr(n, e) {
@@ -1606,8 +1606,8 @@ function Nr(n, e) {
1606
1606
  function Jn(n, e) {
1607
1607
  return Object.keys(n).length === Object.keys(e).length && Object.keys(n).every((t) => e.hasOwnProperty(t) && n[t] === e[t]);
1608
1608
  }
1609
- function St(n, e) {
1610
- return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Nr(n, e) ? Object.keys(n).every((t) => St(n[t], e[t])) : !1;
1609
+ function vt(n, e) {
1610
+ return typeof n != "object" || typeof e != "object" || n === null || e === null ? n === e : Nr(n, e) ? Object.keys(n).every((t) => vt(n[t], e[t])) : !1;
1611
1611
  }
1612
1612
  function vn(n) {
1613
1613
  if (!et(n))
@@ -1890,10 +1890,10 @@ function wi(n) {
1890
1890
  const [e, t] = n.split(" ");
1891
1891
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1892
1892
  }
1893
- function Ti(n) {
1893
+ function Si(n) {
1894
1894
  return new Date(n);
1895
1895
  }
1896
- function Si(n) {
1896
+ function Ti(n) {
1897
1897
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1898
1898
  if (!n.match(e))
1899
1899
  throw new Error(`Unable to parse \`${n}\` as a date.`);
@@ -1912,10 +1912,10 @@ function Ai(n) {
1912
1912
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(\d{1,2})(?::(\d{1,2}))?(?::(\d{1,2}))?(.*)$/, t = n.match(e);
1913
1913
  if (t) {
1914
1914
  const [, r, s, i, o, a, c, u, l] = t, f = s.padStart(2, "0"), h = i.padStart(2, "0");
1915
- let y = a.padStart(2, "0");
1916
- c !== void 0 && (y += `:${c.padStart(2, "0")}`), u !== void 0 && (y += `:${u.padStart(2, "0")}`);
1917
- const b = `${r}-${f}-${h}T${y}${l}`;
1918
- return new Date(b);
1915
+ let b = a.padStart(2, "0");
1916
+ c !== void 0 && (b += `:${c.padStart(2, "0")}`), u !== void 0 && (b += `:${u.padStart(2, "0")}`);
1917
+ const y = `${r}-${f}-${h}T${b}${l}`;
1918
+ return new Date(y);
1919
1919
  }
1920
1920
  return null;
1921
1921
  }
@@ -1948,7 +1948,7 @@ function ki(n) {
1948
1948
  const Ci = [
1949
1949
  _i,
1950
1950
  wi,
1951
- Si,
1951
+ Ti,
1952
1952
  Oi,
1953
1953
  bi,
1954
1954
  vi,
@@ -1957,7 +1957,7 @@ const Ci = [
1957
1957
  Ei,
1958
1958
  ki,
1959
1959
  Ai,
1960
- Ti
1960
+ Si
1961
1961
  ];
1962
1962
  function Ii(n, e) {
1963
1963
  try {
@@ -1999,7 +1999,7 @@ function Pt(n) {
1999
1999
  throw new Error(`Invalid date value \`${n}\`. Expected a date, number, or string, got type ${typeof n}.`);
2000
2000
  }
2001
2001
  }
2002
- class Re {
2002
+ class Me {
2003
2003
  constructor(e, t) {
2004
2004
  p(this, "attrs");
2005
2005
  p(this, "linkIndex");
@@ -2074,7 +2074,7 @@ class Re {
2074
2074
  return { attrs: this.attrs, linkIndex: this.linkIndex };
2075
2075
  }
2076
2076
  }
2077
- function Mi(n) {
2077
+ function Ri(n) {
2078
2078
  return n.cardinality === "one";
2079
2079
  }
2080
2080
  function An(n) {
@@ -2132,18 +2132,18 @@ function Vr(n, e) {
2132
2132
  }
2133
2133
  function Qr(n, e) {
2134
2134
  if (n)
2135
- return new Re(n.attrs, n.linkIndex);
2135
+ return new Me(n.attrs, n.linkIndex);
2136
2136
  if (e && "__type" in e)
2137
- return new Re(e.attrs, e.linkIndex);
2137
+ return new Me(e.attrs, e.linkIndex);
2138
2138
  }
2139
- function Ri(n, e) {
2139
+ function Mi(n, e) {
2140
2140
  return Be(n.eav, [e]) !== void 0;
2141
2141
  }
2142
2142
  function tt(n, e, t, r) {
2143
2143
  const s = Wr(n, e, r);
2144
2144
  return s.cardinalityInference = t, s.useDateObjects = r, s;
2145
2145
  }
2146
- function ct(n, e) {
2146
+ function ut(n, e) {
2147
2147
  var s, i;
2148
2148
  let t;
2149
2149
  if (Array.isArray(e[0])) {
@@ -2163,15 +2163,15 @@ function ct(n, e) {
2163
2163
  const l = (i = fe(c, 2).find((g) => g[2] === a)) == null ? void 0 : i[0];
2164
2164
  if (!l)
2165
2165
  return null;
2166
- const [f, h, y, ...b] = e;
2167
- return [t, h, l, ...b];
2166
+ const [f, h, b, ...y] = e;
2167
+ return [t, h, l, ...y];
2168
2168
  } else {
2169
2169
  const [o, ...a] = e;
2170
2170
  return [t, ...a];
2171
2171
  }
2172
2172
  }
2173
2173
  function Br(n, e, t) {
2174
- const r = ct(n, t);
2174
+ const r = ut(n, t);
2175
2175
  if (!r)
2176
2176
  return;
2177
2177
  const [s, i, o] = r, a = e.getAttr(i);
@@ -2185,7 +2185,7 @@ function Gr(n, e, t) {
2185
2185
  return a && (o = a[3]), o || Date.now() * 10 + ji++;
2186
2186
  }
2187
2187
  function Hr(n, e, t) {
2188
- const r = ct(n, t);
2188
+ const r = ut(n, t);
2189
2189
  if (!r)
2190
2190
  return;
2191
2191
  let [s, i, o] = r;
@@ -2194,11 +2194,11 @@ function Hr(n, e, t) {
2194
2194
  return;
2195
2195
  a["checked-data-type"] === "date" && n.useDateObjects && (o = Pt(o));
2196
2196
  const c = Be(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? Gr(n, a, r), l = [s, i, o, u];
2197
- Mi(a) ? (le(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), le(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (le(n.eav, [s, i, o], l), le(n.aev, [i, s, o], l)), An(a) && le(n.vae, [o, i, s], l);
2197
+ Ri(a) ? (le(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), le(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (le(n.eav, [s, i, o], l), le(n.aev, [i, s, o], l)), An(a) && le(n.vae, [o, i, s], l);
2198
2198
  }
2199
2199
  function $i(n, e, t) {
2200
- var y;
2201
- const r = ct(n, t);
2200
+ var b;
2201
+ const r = ut(n, t);
2202
2202
  if (!r)
2203
2203
  return;
2204
2204
  const [s, i, o] = r, a = e.getAttr(i);
@@ -2209,7 +2209,7 @@ function $i(n, e, t) {
2209
2209
  const c = Be(n.eav, [s, i]);
2210
2210
  if (!c)
2211
2211
  return;
2212
- const u = (y = c.values().next()) == null ? void 0 : y.value;
2212
+ const u = (b = c.values().next()) == null ? void 0 : b.value;
2213
2213
  if (!u)
2214
2214
  return;
2215
2215
  const l = u[2], f = Kr(l, o), h = [
@@ -2222,16 +2222,16 @@ function $i(n, e, t) {
2222
2222
  }
2223
2223
  function sn(n, e, t) {
2224
2224
  var u, l;
2225
- const [r, s] = t, i = ct(n, [r]);
2225
+ const [r, s] = t, i = ut(n, [r]);
2226
2226
  if (!i)
2227
2227
  return;
2228
2228
  const [o] = i, a = n.eav.get(o);
2229
2229
  if (a) {
2230
2230
  for (const f of a.keys()) {
2231
2231
  const h = e.getAttr(f);
2232
- h && h["on-delete-reverse"] === "cascade" && fe(a.get(f), 1).forEach(([y, b, g]) => {
2233
- var m;
2234
- return sn(n, e, [g, (m = h["reverse-identity"]) == null ? void 0 : m[1]]);
2232
+ h && h["on-delete-reverse"] === "cascade" && fe(a.get(f), 1).forEach(([b, y, g]) => {
2233
+ var _;
2234
+ return sn(n, e, [g, (_ = h["reverse-identity"]) == null ? void 0 : _[1]]);
2235
2235
  }), // Fall back to deleting everything if we've rehydrated tx-steps from
2236
2236
  // the store that didn't set `etype` in deleteEntity
2237
2237
  (!s || // If we don't know about the attr, let's just get rid of it
@@ -2242,9 +2242,9 @@ function sn(n, e, t) {
2242
2242
  }
2243
2243
  const c = n.vae.get(o) && fe(n.vae.get(o), 2);
2244
2244
  c && c.forEach((f) => {
2245
- var m, S, _;
2246
- const [h, y, b] = f, g = e.getAttr(y);
2247
- (!s || !g || ((m = g["reverse-identity"]) == null ? void 0 : m[1]) === s) && (_e(n.eav, [h, y, b]), _e(n.aev, [y, h, b]), _e(n.vae, [b, y, h])), g && g["on-delete"] === "cascade" && ((S = g["reverse-identity"]) == null ? void 0 : S[1]) === s && sn(n, e, [h, (_ = g["forward-identity"]) == null ? void 0 : _[1]]);
2245
+ var _, S, m;
2246
+ const [h, b, y] = f, g = e.getAttr(b);
2247
+ (!s || !g || ((_ = g["reverse-identity"]) == null ? void 0 : _[1]) === s) && (_e(n.eav, [h, b, y]), _e(n.aev, [b, h, y]), _e(n.vae, [y, b, h])), g && g["on-delete"] === "cascade" && ((S = g["reverse-identity"]) == null ? void 0 : S[1]) === s && sn(n, e, [h, (m = g["forward-identity"]) == null ? void 0 : m[1]]);
2248
2248
  }), ((l = n.vae.get(o)) == null ? void 0 : l.size) === 0 && _e(n.vae, [o]);
2249
2249
  }
2250
2250
  function Jr(n, e, t) {
@@ -2312,7 +2312,7 @@ function fe(n, e, t = []) {
2312
2312
  fe(r, e - 1, t);
2313
2313
  return t;
2314
2314
  }
2315
- function pt(n, e, t) {
2315
+ function yt(n, e, t) {
2316
2316
  var i;
2317
2317
  const r = [];
2318
2318
  if (t != null && t.hasOwnProperty("$not")) {
@@ -2362,7 +2362,7 @@ function Ni(n, [e, t, r]) {
2362
2362
  }
2363
2363
  case "eav": {
2364
2364
  const a = (o = n.eav.get(e)) == null ? void 0 : o.get(t);
2365
- return a ? pt(n, a, r) : [];
2365
+ return a ? yt(n, a, r) : [];
2366
2366
  }
2367
2367
  case "ev": {
2368
2368
  const a = n.eav.get(e);
@@ -2370,7 +2370,7 @@ function Ni(n, [e, t, r]) {
2370
2370
  return [];
2371
2371
  const c = [];
2372
2372
  for (const u of a.values())
2373
- c.push(...pt(n, u, r));
2373
+ c.push(...yt(n, u, r));
2374
2374
  return c;
2375
2375
  }
2376
2376
  case "a": {
@@ -2383,14 +2383,14 @@ function Ni(n, [e, t, r]) {
2383
2383
  return [];
2384
2384
  const c = [];
2385
2385
  for (const u of a.values())
2386
- c.push(...pt(n, u, r));
2386
+ c.push(...yt(n, u, r));
2387
2387
  return c;
2388
2388
  }
2389
2389
  case "v": {
2390
2390
  const a = [];
2391
2391
  for (const c of n.eav.values())
2392
2392
  for (const u of c.values())
2393
- a.push(...pt(n, u, r));
2393
+ a.push(...yt(n, u, r));
2394
2394
  return a;
2395
2395
  }
2396
2396
  default:
@@ -2426,7 +2426,7 @@ function Zr(n, e) {
2426
2426
  return t || ((r = n.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
2427
2427
  }
2428
2428
  function Wi(n, e, t) {
2429
- const r = ct(n, t);
2429
+ const r = ut(n, t);
2430
2430
  if (!r)
2431
2431
  return;
2432
2432
  const [s, i, o] = r;
@@ -2458,7 +2458,7 @@ function zi(n, e, t) {
2458
2458
  });
2459
2459
  }, {
2460
2460
  mark: (s) => {
2461
- if (s instanceof Re)
2461
+ if (s instanceof Me)
2462
2462
  return "immutable";
2463
2463
  }
2464
2464
  });
@@ -2529,11 +2529,11 @@ const to = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a
2529
2529
  function Ve(n) {
2530
2530
  return typeof n == "string" && to.test(n);
2531
2531
  }
2532
- const re = [];
2532
+ const se = [];
2533
2533
  for (let n = 0; n < 256; ++n)
2534
- re.push((n + 256).toString(16).slice(1));
2534
+ se.push((n + 256).toString(16).slice(1));
2535
2535
  function no(n, e = 0) {
2536
- return (re[n[e + 0]] + re[n[e + 1]] + re[n[e + 2]] + re[n[e + 3]] + "-" + re[n[e + 4]] + re[n[e + 5]] + "-" + re[n[e + 6]] + re[n[e + 7]] + "-" + re[n[e + 8]] + re[n[e + 9]] + "-" + re[n[e + 10]] + re[n[e + 11]] + re[n[e + 12]] + re[n[e + 13]] + re[n[e + 14]] + re[n[e + 15]]).toLowerCase();
2536
+ return (se[n[e + 0]] + se[n[e + 1]] + se[n[e + 2]] + se[n[e + 3]] + "-" + se[n[e + 4]] + se[n[e + 5]] + "-" + se[n[e + 6]] + se[n[e + 7]] + "-" + se[n[e + 8]] + se[n[e + 9]] + "-" + se[n[e + 10]] + se[n[e + 11]] + se[n[e + 12]] + se[n[e + 13]] + se[n[e + 14]] + se[n[e + 15]]).toLowerCase();
2537
2537
  }
2538
2538
  let Kt;
2539
2539
  const ro = new Uint8Array(16);
@@ -2591,10 +2591,10 @@ function lo() {
2591
2591
  }
2592
2592
  const fo = lo();
2593
2593
  let ho = !0, po = 0;
2594
- function it(n) {
2595
- return Mt(`_${n}`, po++);
2594
+ function ot(n) {
2595
+ return Rt(`_${n}`, po++);
2596
2596
  }
2597
- function Mt(n, e) {
2597
+ function Rt(n, e) {
2598
2598
  return `?${n}-${e}`;
2599
2599
  }
2600
2600
  class Qe extends Error {
@@ -2628,18 +2628,18 @@ function es(n, e, t, r, s) {
2628
2628
  throw new Qe(`Could not find attr for ${[t, s]}`);
2629
2629
  if (a["value-type"] !== "ref")
2630
2630
  throw new Error(`Attr ${a.id} is not a ref`);
2631
- const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], h = r + 1, y = i ? [
2631
+ const [c, u] = a["forward-identity"], [l, f] = a["reverse-identity"], h = r + 1, b = i ? [
2632
2632
  n(u, r),
2633
2633
  a.id,
2634
2634
  n(f, h),
2635
- it("time")
2635
+ ot("time")
2636
2636
  ] : [
2637
2637
  n(u, h),
2638
2638
  a.id,
2639
2639
  n(f, r),
2640
- it("time")
2640
+ ot("time")
2641
2641
  ];
2642
- return [i ? f : u, h, y, a, !!i];
2642
+ return [i ? f : u, h, b, a, !!i];
2643
2643
  }
2644
2644
  function rr(n, e) {
2645
2645
  if (typeof e != "string")
@@ -2723,20 +2723,20 @@ function mo(n, e, t, r, s, i) {
2723
2723
  n(t, r),
2724
2724
  u.id,
2725
2725
  { $isNull: { attrId: c.id, isNull: i.$isNull, reverse: !o } },
2726
- it("time")
2726
+ ot("time")
2727
2727
  ];
2728
2728
  }
2729
2729
  return o ? [
2730
2730
  n(t, r),
2731
2731
  c.id,
2732
2732
  _o(c, i),
2733
- it("time")
2734
- ] : [i, c.id, n(t, r), it("time")];
2733
+ ot("time")
2734
+ ] : [i, c.id, n(t, r), ot("time")];
2735
2735
  }
2736
2736
  function wo(n, e, t, r, s) {
2737
2737
  const [i, o, a] = s.reduce((c, u) => {
2738
- const [l, f, h] = c, [y, b, g] = es(n, e, l, f, u);
2739
- return [y, b, [...h, g]];
2738
+ const [l, f, h] = c, [b, y, g] = es(n, e, l, f, u);
2739
+ return [b, y, [...h, g]];
2740
2740
  }, [t, r, []]);
2741
2741
  return [i, o, a];
2742
2742
  }
@@ -2744,10 +2744,10 @@ function an(n, e, t, r, s, i) {
2744
2744
  const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = wo(n, e, t, r, o), f = mo(n, e, c, u, a, i);
2745
2745
  return l.concat([f]);
2746
2746
  }
2747
- function To(n, e) {
2747
+ function So(n, e) {
2748
2748
  return e ? [e].concat(n) : n;
2749
2749
  }
2750
- function So([n, e]) {
2750
+ function To([n, e]) {
2751
2751
  return n === "or" && Array.isArray(e);
2752
2752
  }
2753
2753
  function vo([n, e]) {
@@ -2779,7 +2779,7 @@ function ir(n, e, t, r, s) {
2779
2779
  }
2780
2780
  function ts(n, e, t, r, s) {
2781
2781
  return Object.entries(s).flatMap(([i, o]) => {
2782
- if (So([i, o]))
2782
+ if (To([i, o]))
2783
2783
  return sr(n, "or", e, t, r, o);
2784
2784
  if (vo([i, o]))
2785
2785
  return sr(n, "and", e, t, r, o);
@@ -2808,7 +2808,7 @@ function ts(n, e, t, r, s) {
2808
2808
  });
2809
2809
  }
2810
2810
  function Eo(n, e, t, r) {
2811
- const s = Mt;
2811
+ const s = Rt;
2812
2812
  return r ? ts(s, n, e, t, r).concat(nr(s, n, e, t)) : nr(s, n, e, t);
2813
2813
  }
2814
2814
  function ko(n, e, t) {
@@ -2821,24 +2821,24 @@ function Co(n, e, t, r, s, i) {
2821
2821
  function Io(n, e, t, { etype: r, level: s, form: i }, o) {
2822
2822
  const a = Object.keys(i).filter((c) => c !== "$");
2823
2823
  return a.length ? Object.entries(o).map(function([u, l]) {
2824
- return a.map(function(y) {
2825
- var g, m, S;
2826
- const b = !!(e.cardinalityInference && ((S = (m = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : m[y]) != null && S.isSingular));
2824
+ return a.map(function(b) {
2825
+ var g, _, S;
2826
+ const y = !!(e.cardinalityInference && ((S = (_ = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : _[b]) != null && S.isSingular));
2827
2827
  try {
2828
- const [_, T, M] = Co(n, t, r, s, y, u), O = ss(e, t, {
2829
- etype: _,
2828
+ const [m, T, C] = Co(n, t, r, s, b, u), O = ss(e, t, {
2829
+ etype: m,
2830
2830
  level: T,
2831
- form: i[y],
2832
- join: M
2833
- }), F = b ? O[0] : O;
2834
- return { [y]: F };
2835
- } catch (_) {
2836
- if (_ instanceof Qe)
2837
- return { [y]: b ? void 0 : [] };
2838
- throw _;
2831
+ form: i[b],
2832
+ join: C
2833
+ }), M = y ? O[0] : O;
2834
+ return { [b]: M };
2835
+ } catch (m) {
2836
+ if (m instanceof Qe)
2837
+ return { [b]: y ? void 0 : [] };
2838
+ throw m;
2839
2839
  }
2840
- }).reduce(function(y, b) {
2841
- return { ...y, ...b };
2840
+ }).reduce(function(b, y) {
2841
+ return { ...b, ...y };
2842
2842
  }, l);
2843
2843
  }) : Object.values(o);
2844
2844
  }
@@ -2862,11 +2862,11 @@ function ns(n, e, t) {
2862
2862
  const [a, c] = t, u = e["checked-data-type"], l = u === "date" ? cn(c) : c, f = u === "date" ? cn(i) : i;
2863
2863
  return Ct([a, l], [r, f], u);
2864
2864
  }
2865
- function Mo(n, e, t, r) {
2865
+ function Ro(n, e, t, r) {
2866
2866
  const s = ns(n, e, r);
2867
2867
  return t === "desc" ? s > 0 : s < 0;
2868
2868
  }
2869
- function Ro(n, e, t, r) {
2869
+ function Mo(n, e, t, r) {
2870
2870
  const s = ns(n, e, r);
2871
2871
  return t === "desc" ? s < 0 : s > 0;
2872
2872
  }
@@ -2900,33 +2900,33 @@ function Do(n, e, t) {
2900
2900
  return r;
2901
2901
  }
2902
2902
  function Uo(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2903
- var g, m;
2903
+ var g, _;
2904
2904
  const o = (g = i == null ? void 0 : i.$) == null ? void 0 : g.order, a = rs(i), c = Lo(i);
2905
2905
  let u = Xi(n, s);
2906
2906
  const l = r == null ? void 0 : r["start-cursor"], f = r == null ? void 0 : r["end-cursor"], h = xo(e, t, l, o);
2907
- if (h && ((m = h == null ? void 0 : h["forward-identity"]) == null ? void 0 : m[2]) !== "id") {
2908
- const S = h["checked-data-type"] === "date", _ = h.id;
2907
+ if (h && ((_ = h == null ? void 0 : h["forward-identity"]) == null ? void 0 : _[2]) !== "id") {
2908
+ const S = h["checked-data-type"] === "date", m = h.id;
2909
2909
  u = u.map(([T]) => {
2910
- var O, F, P, C, G;
2911
- let M = (G = (C = (P = (F = (O = n.eav.get(T)) == null ? void 0 : O.get(_)) == null ? void 0 : F.values()) == null ? void 0 : P.next()) == null ? void 0 : C.value) == null ? void 0 : G[2];
2912
- return S && (M = cn(M)), [T, M];
2910
+ var O, M, R, P, G;
2911
+ let C = (G = (P = (R = (M = (O = n.eav.get(T)) == null ? void 0 : O.get(m)) == null ? void 0 : M.values()) == null ? void 0 : R.next()) == null ? void 0 : P.value) == null ? void 0 : G[2];
2912
+ return S && (C = cn(C)), [T, C];
2913
2913
  });
2914
2914
  }
2915
- u.sort(c === "asc" ? function(_, T) {
2916
- return Ct(_, T, h == null ? void 0 : h["checked-data-type"]);
2917
- } : function(_, T) {
2918
- return Ct(T, _, h == null ? void 0 : h["checked-data-type"]);
2915
+ u.sort(c === "asc" ? function(m, T) {
2916
+ return Ct(m, T, h == null ? void 0 : h["checked-data-type"]);
2917
+ } : function(m, T) {
2918
+ return Ct(T, m, h == null ? void 0 : h["checked-data-type"]);
2919
2919
  });
2920
- let y = {};
2921
- const b = Do(e, t, s);
2920
+ let b = {};
2921
+ const y = Do(e, t, s);
2922
2922
  for (const S of u) {
2923
- const [_] = S;
2924
- if (y[_] || !a && l && h && Mo(l, h, c, S) || !a && f && h && Ro(f, h, c, S))
2923
+ const [m] = S;
2924
+ if (b[m] || !a && l && h && Ro(l, h, c, S) || !a && f && h && Mo(f, h, c, S))
2925
2925
  continue;
2926
- const T = Ki(n, b, _);
2927
- T && (y[_] = T);
2926
+ const T = Ki(n, y, m);
2927
+ T && (b[m] = T);
2928
2928
  }
2929
- return y;
2929
+ return b;
2930
2930
  }
2931
2931
  function Lo(n) {
2932
2932
  var t;
@@ -2939,15 +2939,15 @@ function rs(n) {
2939
2939
  return !e && !t && !r;
2940
2940
  }
2941
2941
  function Fo(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2942
- var h, y, b, g, m;
2942
+ var h, b, y, g, _;
2943
2943
  if (!rs(s) && (!o || !o["start-cursor"]))
2944
2944
  return [];
2945
- const a = To(Eo(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = ko(Mt, t, r), u = (y = s.$) == null ? void 0 : y.fields, l = Uo(n, e, {
2945
+ const a = So(Eo(e, t, r, (h = s.$) == null ? void 0 : h.where), i), c = ko(Rt, t, r), u = (b = s.$) == null ? void 0 : b.fields, l = Uo(n, e, {
2946
2946
  etype: t,
2947
2947
  pageInfo: o,
2948
2948
  form: s,
2949
2949
  dq: { where: a, find: c, fields: u }
2950
- }), f = ((b = s.$) == null ? void 0 : b.limit) || ((g = s.$) == null ? void 0 : g.first) || ((m = s.$) == null ? void 0 : m.last);
2950
+ }), f = ((y = s.$) == null ? void 0 : y.limit) || ((g = s.$) == null ? void 0 : g.first) || ((_ = s.$) == null ? void 0 : _.last);
2951
2951
  if (f != null) {
2952
2952
  r > 0 && ho && console.warn("WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit.");
2953
2953
  const S = Object.entries(l);
@@ -2966,7 +2966,7 @@ function No(n, e, t) {
2966
2966
  }
2967
2967
  function ss(n, e, t) {
2968
2968
  const r = No(n, e, t);
2969
- return Io(Mt, n, e, t, r);
2969
+ return Io(Rt, n, e, t, r);
2970
2970
  }
2971
2971
  function Ko(n) {
2972
2972
  const e = {};
@@ -3005,7 +3005,7 @@ function qo() {
3005
3005
  return new Set(Object.keys(e));
3006
3006
  }
3007
3007
  const Wo = qo();
3008
- function vt(n, e, t) {
3008
+ function At(n, e, t) {
3009
3009
  const r = {
3010
3010
  __etype: n,
3011
3011
  __ops: t
@@ -3017,7 +3017,7 @@ function vt(n, e, t) {
3017
3017
  if (i === "__etype")
3018
3018
  return n;
3019
3019
  if (Wo.has(i))
3020
- return (o, a) => vt(n, e, [
3020
+ return (o, a) => At(n, e, [
3021
3021
  ...t,
3022
3022
  a ? [i, n, e, o, a] : [i, n, e, o]
3023
3023
  ]);
@@ -3040,11 +3040,11 @@ function Vo(n) {
3040
3040
  }, {
3041
3041
  get(e, t) {
3042
3042
  if (t === "lookup")
3043
- return (s, i) => vt(n, un(zo(s, i)), []);
3043
+ return (s, i) => At(n, un(zo(s, i)), []);
3044
3044
  if (t === "__etype")
3045
3045
  return n;
3046
3046
  const r = t;
3047
- return It(r) ? vt(n, un(r), []) : vt(n, r, []);
3047
+ return It(r) ? At(n, un(r), []) : At(n, r, []);
3048
3048
  }
3049
3049
  });
3050
3050
  }
@@ -3205,11 +3205,11 @@ function ea(n, e) {
3205
3205
  function ta(n, e) {
3206
3206
  const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = as(n, [r, c, i, o]);
3207
3207
  return [["id", c]].concat(Object.entries(a)).map(([f, h]) => {
3208
- const y = ne(t, r, f);
3209
- return y["checked-data-type"] === "date" && n.useDateObjects && (h = Pt(h)), [
3208
+ const b = ne(t, r, f);
3209
+ return b["checked-data-type"] === "date" && n.useDateObjects && (h = Pt(h)), [
3210
3210
  "add-triple",
3211
3211
  c,
3212
- y.id,
3212
+ b.id,
3213
3213
  h,
3214
3214
  ...u ? [u] : []
3215
3215
  ];
@@ -3219,13 +3219,13 @@ function na({ attrsStore: n }, [e, t]) {
3219
3219
  return [["delete-entity", de(n, e, t), e]];
3220
3220
  }
3221
3221
  function ra(n, e) {
3222
- const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = as(n, [r, c, i, o]), l = Object.entries(a).map(([h, y]) => {
3223
- const b = ne(t, r, h);
3222
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = vn(i), c = de(t, r, s), u = as(n, [r, c, i, o]), l = Object.entries(a).map(([h, b]) => {
3223
+ const y = ne(t, r, h);
3224
3224
  return [
3225
3225
  "deep-merge-triple",
3226
3226
  c,
3227
- b.id,
3228
- y,
3227
+ y.id,
3228
+ b,
3229
3229
  ...u ? [u] : []
3230
3230
  ];
3231
3231
  });
@@ -3293,7 +3293,7 @@ function ca(n, e, t) {
3293
3293
  "checked-data-type": o
3294
3294
  };
3295
3295
  }
3296
- function yt(n, e, t, r) {
3296
+ function bt(n, e, t, r) {
3297
3297
  const s = n ? ca(n, e, t) : null, i = J(), a = [J(), e, t];
3298
3298
  return {
3299
3299
  id: i,
@@ -3374,72 +3374,72 @@ function ba(n) {
3374
3374
  return e;
3375
3375
  }
3376
3376
  function ga({ attrsStore: n, schema: e }, t) {
3377
- var h, y;
3377
+ var h, b;
3378
3378
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
3379
- function o(b, g) {
3380
- return ne(n, b, g) || s.find((m) => m["forward-identity"][1] === b && m["forward-identity"][2] === g);
3379
+ function o(y, g) {
3380
+ return ne(n, y, g) || s.find((_) => _["forward-identity"][1] === y && _["forward-identity"][2] === g);
3381
3381
  }
3382
- function a(b, g) {
3383
- return De(n, b, g) || s.find((m) => {
3384
- var S, _;
3385
- return ((S = m["reverse-identity"]) == null ? void 0 : S[1]) === b && ((_ = m["reverse-identity"]) == null ? void 0 : _[2]) === g;
3382
+ function a(y, g) {
3383
+ return De(n, y, g) || s.find((_) => {
3384
+ var S, m;
3385
+ return ((S = _["reverse-identity"]) == null ? void 0 : S[1]) === y && ((m = _["reverse-identity"]) == null ? void 0 : m[2]) === g;
3386
3386
  });
3387
3387
  }
3388
- function c(b) {
3389
- s.push(b), i.push(["add-attr", b]), r.add(b.id);
3388
+ function c(y) {
3389
+ s.push(y), i.push(["add-attr", y]), r.add(y.id);
3390
3390
  }
3391
- function u(b) {
3392
- b && "isUnsynced" in b && b.isUnsynced && !r.has(b.id) && (s.push(b), i.push(["add-attr", b]), r.add(b.id));
3391
+ function u(y) {
3392
+ y && "isUnsynced" in y && y.isUnsynced && !r.has(y.id) && (s.push(y), i.push(["add-attr", y]), r.add(y.id));
3393
3393
  }
3394
- function l(b, g) {
3394
+ function l(y, g) {
3395
3395
  return g.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
3396
3396
  // before assuming it's a ref lookup.
3397
- !o(b, g);
3397
+ !o(y, g);
3398
3398
  }
3399
- function f(b, g) {
3400
- const m = o(b, g), S = a(b, g);
3401
- u(m), u(S), !m && !S && c(or(e, b, g, ya));
3399
+ function f(y, g) {
3400
+ const _ = o(y, g), S = a(y, g);
3401
+ u(_), u(S), !_ && !S && c(or(e, y, g, ya));
3402
3402
  }
3403
- for (const b of t)
3404
- for (const { etype: g, lookupPair: m, linkLabel: S } of ba(b)) {
3405
- const _ = m[0];
3403
+ for (const y of t)
3404
+ for (const { etype: g, lookupPair: _, linkLabel: S } of ba(y)) {
3405
+ const m = _[0];
3406
3406
  if (S) {
3407
3407
  f(g, S);
3408
- const T = o(g, S), M = a(g, S);
3409
- u(T), u(M);
3410
- const O = ((h = T == null ? void 0 : T["reverse-identity"]) == null ? void 0 : h[1]) || ((y = M == null ? void 0 : M["forward-identity"]) == null ? void 0 : y[1]) || S;
3411
- if (l(O, _))
3412
- f(O, ln(_));
3408
+ const T = o(g, S), C = a(g, S);
3409
+ u(T), u(C);
3410
+ const O = ((h = T == null ? void 0 : T["reverse-identity"]) == null ? void 0 : h[1]) || ((b = C == null ? void 0 : C["forward-identity"]) == null ? void 0 : b[1]) || S;
3411
+ if (l(O, m))
3412
+ f(O, ln(m));
3413
3413
  else {
3414
- const F = o(O, _);
3415
- F || c(yt(e, O, _, dn)), u(F);
3414
+ const M = o(O, m);
3415
+ M || c(bt(e, O, m, dn)), u(M);
3416
3416
  }
3417
- } else if (l(g, _))
3418
- f(g, ln(_));
3417
+ } else if (l(g, m))
3418
+ f(g, ln(m));
3419
3419
  else {
3420
- const T = o(g, _);
3421
- T || c(yt(e, g, _, dn)), u(T);
3420
+ const T = o(g, m);
3421
+ T || c(bt(e, g, m, dn)), u(T);
3422
3422
  }
3423
3423
  }
3424
- for (const b of t) {
3425
- const [g, m, S, _] = b;
3424
+ for (const y of t) {
3425
+ const [g, _, S, m] = y;
3426
3426
  if (fa.has(g)) {
3427
- const T = o(m, "id");
3428
- u(T), T || c(yt(e, m, "id", { "unique?": !0 }));
3429
- for (const M of Object.keys(_)) {
3430
- const O = o(m, M);
3431
- if (u(O), ha.has(g) && (O || c(yt(e, m, M, M === "id" ? { "unique?": !0 } : null))), da.has(g)) {
3432
- const F = a(m, M);
3433
- !O && !F && c(or(e, m, M)), u(F);
3427
+ const T = o(_, "id");
3428
+ u(T), T || c(bt(e, _, "id", { "unique?": !0 }));
3429
+ for (const C of Object.keys(m)) {
3430
+ const O = o(_, C);
3431
+ if (u(O), ha.has(g) && (O || c(bt(e, _, C, C === "id" ? { "unique?": !0 } : null))), da.has(g)) {
3432
+ const M = a(_, C);
3433
+ !O && !M && c(or(e, _, C)), u(M);
3434
3434
  }
3435
3435
  }
3436
3436
  }
3437
3437
  }
3438
3438
  if (s.length) {
3439
- const b = { ...n.attrs };
3439
+ const y = { ...n.attrs };
3440
3440
  for (const g of s)
3441
- b[g.id] = g;
3442
- return [new Re(b, n.linkIndex), i];
3441
+ y[g.id] = g;
3442
+ return [new Me(y, n.linkIndex), i];
3443
3443
  }
3444
3444
  return [n, i];
3445
3445
  }
@@ -3555,10 +3555,10 @@ class hn {
3555
3555
  _writeToStorage(e) {
3556
3556
  const t = [], r = e == null ? void 0 : e.skipGc;
3557
3557
  if (this._meta.isLoading) {
3558
- const f = new Promise((h, y) => {
3559
- setTimeout(() => this._enqueuePersist(e ? { ...e, attempts: (e.attempts || 0) + 1 } : { attempts: 1 }).then(h).catch(y), 10 + ((e == null ? void 0 : e.attempts) ?? 0) * 1e3);
3558
+ const f = new Promise((h, b) => {
3559
+ setTimeout(() => this._enqueuePersist(e ? { ...e, attempts: (e.attempts || 0) + 1 } : { attempts: 1 }).then(h).catch(b), 10 + ((e == null ? void 0 : e.attempts) ?? 0) * 1e3);
3560
3560
  });
3561
- return t.push(f), Promise.all(t).then((h) => h.reduce((y, b) => y + b, 0));
3561
+ return t.push(f), Promise.all(t).then((h) => h.reduce((b, y) => b + y, 0));
3562
3562
  }
3563
3563
  const s = this._meta.value;
3564
3564
  if (!s)
@@ -3576,12 +3576,12 @@ class hn {
3576
3576
  if (this._loadedKeys.has(f)) {
3577
3577
  const h = this.serialize(f, this.currentValue[f]);
3578
3578
  c.push([f, h]);
3579
- const y = this._objectSize(h), b = u[f] ?? {
3579
+ const b = this._objectSize(h), y = u[f] ?? {
3580
3580
  createdAt: Date.now(),
3581
3581
  updatedAt: Date.now(),
3582
- size: y
3582
+ size: b
3583
3583
  };
3584
- b.updatedAt = Date.now(), b.size = y, u[f] = b, this._pendingSaveKeys.delete(f);
3584
+ y.updatedAt = Date.now(), y.size = b, u[f] = y, this._pendingSaveKeys.delete(f);
3585
3585
  } else
3586
3586
  a.push(f);
3587
3587
  const l = this._persister.multiSet(c);
@@ -3590,7 +3590,7 @@ class hn {
3590
3590
  const h = this._loadKey(f).then(() => this._enqueuePersist(e));
3591
3591
  t.push(h);
3592
3592
  }
3593
- return r || this.gc(), Promise.all(t).then((f) => f.reduce((h, y) => h + y, 0));
3593
+ return r || this.gc(), Promise.all(t).then((f) => f.reduce((h, b) => h + b, 0));
3594
3594
  }
3595
3595
  async flush() {
3596
3596
  return this._nextSave ? (clearTimeout(this._nextSave), this._nextSave = null, this._writeToStorage()) : void 0;
@@ -3624,21 +3624,21 @@ class hn {
3624
3624
  for (const h of e)
3625
3625
  t.has(h) || h in r.objects || (this._log.info("Lost track of key in meta", h), s.push(this._persister.removeItem(h)), i.removed.push(h), i.removedMissingCount++);
3626
3626
  const o = Date.now();
3627
- for (const [h, y] of Object.entries(r.objects))
3628
- !t.has(h) && y.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedOldCount++);
3627
+ for (const [h, b] of Object.entries(r.objects))
3628
+ !t.has(h) && b.updatedAt < o - this._gcOpts.maxAgeMs && (s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedOldCount++);
3629
3629
  const a = Object.entries(r.objects);
3630
- a.sort(([h, y], [b, g]) => y.updatedAt - g.updatedAt);
3630
+ a.sort(([h, b], [y, g]) => b.updatedAt - g.updatedAt);
3631
3631
  const c = a.filter(([h]) => !t.has(h));
3632
3632
  if (a.length > this._gcOpts.maxEntries)
3633
3633
  for (const [h] of c.slice(0, a.length - this._gcOpts.maxEntries))
3634
3634
  s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedThresholdCount++;
3635
3635
  const u = Object.entries(r.objects);
3636
- u.sort(([h, y], [b, g]) => y.updatedAt - g.updatedAt);
3636
+ u.sort(([h, b], [y, g]) => b.updatedAt - g.updatedAt);
3637
3637
  const l = u.filter(([h]) => !t.has(h));
3638
- let f = u.reduce((h, [y, b]) => h + b.size, 0);
3638
+ let f = u.reduce((h, [b, y]) => h + y.size, 0);
3639
3639
  for (; f > 0 && f > this._gcOpts.maxSize && l.length; ) {
3640
- const [[h, y]] = l.splice(0, 1);
3641
- f -= y.size, s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedSizeCount++;
3640
+ const [[h, b]] = l.splice(0, 1);
3641
+ f -= b.size, s.push(this._persister.removeItem(h)), delete r.objects[h], i.removed.push(h), i.removedSizeCount++;
3642
3642
  }
3643
3643
  for (const h of Object.keys(r.objects))
3644
3644
  !e.has(h) && !t.has(h) && delete r.objects[h];
@@ -3703,8 +3703,8 @@ class hn {
3703
3703
  e && await this._enqueuePersist();
3704
3704
  }
3705
3705
  }
3706
- const wa = 6, Ta = ["kv", "querySubs", "syncSubs"];
3707
- function Sa(n) {
3706
+ const wa = 6, Sa = ["kv", "querySubs", "syncSubs"];
3707
+ function Ta(n) {
3708
3708
  return function(t) {
3709
3709
  console.error("Error in IndexedDB event", { source: n, event: t });
3710
3710
  };
@@ -3734,26 +3734,26 @@ async function Aa(n, e, t) {
3734
3734
  return new Promise((i, o) => {
3735
3735
  var l, f, h;
3736
3736
  const a = {};
3737
- for (const [y, b] of Object.entries(r)) {
3738
- const g = typeof b == "string" ? JSON.parse(b) : b;
3737
+ for (const [b, y] of Object.entries(r)) {
3738
+ const g = typeof y == "string" ? JSON.parse(y) : y;
3739
3739
  if (g.lastAccessed) {
3740
3740
  const S = {
3741
3741
  createdAt: g.lastAccessed,
3742
3742
  updatedAt: g.lastAccessed,
3743
3743
  size: ((h = (f = (l = g.result) == null ? void 0 : l.store) == null ? void 0 : f.triples) == null ? void 0 : h.length) ?? 0
3744
3744
  };
3745
- a[y] = S;
3745
+ a[b] = S;
3746
3746
  }
3747
- const m = t.put(g, y);
3748
- s.add(m);
3747
+ const _ = t.put(g, b);
3748
+ s.add(_);
3749
3749
  }
3750
3750
  const c = { objects: a }, u = t.put(c, We);
3751
3751
  s.add(u);
3752
- for (const y of s)
3753
- y.onsuccess = () => {
3754
- s.delete(y), s.size === 0 && i();
3755
- }, y.onerror = (b) => {
3756
- o(b);
3752
+ for (const b of s)
3753
+ b.onsuccess = () => {
3754
+ s.delete(b), s.size === 0 && i();
3755
+ }, b.onerror = (y) => {
3756
+ o(y);
3757
3757
  };
3758
3758
  });
3759
3759
  }
@@ -3768,20 +3768,20 @@ async function Oa(n, e) {
3768
3768
  if (!t)
3769
3769
  return;
3770
3770
  const r = await new Promise((l, f) => {
3771
- const b = t.transaction(["kv"], "readonly").objectStore("kv").openCursor();
3772
- b.onerror = (m) => {
3773
- f(m);
3771
+ const y = t.transaction(["kv"], "readonly").objectStore("kv").openCursor();
3772
+ y.onerror = (_) => {
3773
+ f(_);
3774
3774
  };
3775
3775
  const g = [];
3776
- b.onsuccess = () => {
3777
- const m = b.result;
3778
- if (m) {
3779
- const S = m.key, _ = m.value;
3780
- g.push([S, _]), m.continue();
3776
+ y.onsuccess = () => {
3777
+ const _ = y.result;
3778
+ if (_) {
3779
+ const S = _.key, m = _.value;
3780
+ g.push([S, m]), _.continue();
3781
3781
  } else
3782
3782
  l(g);
3783
- }, b.onerror = (m) => {
3784
- f(m);
3783
+ }, y.onerror = (_) => {
3784
+ f(_);
3785
3785
  };
3786
3786
  }), s = e.transaction(["kv", "querySubs"], "readwrite"), i = s.objectStore("kv"), o = s.objectStore("querySubs"), a = [], c = { objects: {} };
3787
3787
  for (const [l, f] of r)
@@ -3794,12 +3794,12 @@ async function Oa(n, e) {
3794
3794
  default: {
3795
3795
  const h = cr(l, f, i);
3796
3796
  a.push(h);
3797
- const y = {
3797
+ const b = {
3798
3798
  createdAt: Date.now(),
3799
3799
  updatedAt: Date.now(),
3800
3800
  size: 0
3801
3801
  };
3802
- c.objects[l] = y;
3802
+ c.objects[l] = b;
3803
3803
  break;
3804
3804
  }
3805
3805
  }
@@ -3833,7 +3833,7 @@ class cs extends ma {
3833
3833
  c.close();
3834
3834
  }, s) {
3835
3835
  const u = Oa(this._appId, c).catch((l) => {
3836
- Sa("Error upgrading store from version 5 to 6.")(l);
3836
+ Ta("Error upgrading store from version 5 to 6.")(l);
3837
3837
  });
3838
3838
  ur.set(this.dbName, u), u.then(() => t(c)).catch(() => t(c));
3839
3839
  } else {
@@ -3847,7 +3847,7 @@ class cs extends ma {
3847
3847
  }
3848
3848
  _upgradeStore(t) {
3849
3849
  const s = t.target.result;
3850
- for (const i of Ta)
3850
+ for (const i of Sa)
3851
3851
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3852
3852
  }
3853
3853
  // Browsers can close IndexedDB connections unexpectedly (backgrounded tabs,
@@ -3923,20 +3923,20 @@ class us {
3923
3923
  };
3924
3924
  }
3925
3925
  }
3926
- class ie extends Error {
3926
+ class re extends Error {
3927
3927
  constructor(t, r, s) {
3928
3928
  super(t);
3929
3929
  p(this, "hint");
3930
3930
  p(this, "traceId");
3931
3931
  this.hint = r, s && (this.traceId = s);
3932
3932
  const i = new.target.prototype;
3933
- Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, ie), this.name = "InstantError";
3933
+ Object.setPrototypeOf && Object.setPrototypeOf(this, i), Error.captureStackTrace && Error.captureStackTrace(this, re), this.name = "InstantError";
3934
3934
  }
3935
3935
  get [Symbol.toStringTag]() {
3936
3936
  return "InstantError";
3937
3937
  }
3938
3938
  }
3939
- class Rt extends ie {
3939
+ class Mt extends re {
3940
3940
  constructor(t) {
3941
3941
  var i, o;
3942
3942
  const r = ((i = t.body) == null ? void 0 : i.message) || `API Error (${t.status})`;
@@ -3944,7 +3944,7 @@ class Rt extends ie {
3944
3944
  p(this, "body");
3945
3945
  p(this, "status");
3946
3946
  const s = new.target.prototype;
3947
- Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Rt), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3947
+ Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Mt), this.name = "InstantAPIError", this.status = t.status, this.body = t.body;
3948
3948
  }
3949
3949
  get [Symbol.toStringTag]() {
3950
3950
  return "InstantAPIError";
@@ -3952,7 +3952,7 @@ class Rt extends ie {
3952
3952
  }
3953
3953
  async function we(n, e) {
3954
3954
  const t = await fetch(n, e), r = await t.json();
3955
- return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Rt({ status: t.status, body: r }));
3955
+ return t.status === 200 ? Promise.resolve(r) : Promise.reject(new Mt({ status: t.status, body: r }));
3956
3956
  }
3957
3957
  function Ea({ apiURI: n, appId: e, email: t }) {
3958
3958
  return we(`${n}/runtime/auth/send_magic_code`, {
@@ -4020,7 +4020,7 @@ async function Pa({ apiURI: n, appId: e, nonce: t, idToken: r, clientName: s, re
4020
4020
  })
4021
4021
  });
4022
4022
  }
4023
- async function Ma({ apiURI: n, appId: e, refreshToken: t }) {
4023
+ async function Ra({ apiURI: n, appId: e, refreshToken: t }) {
4024
4024
  return await we(`${n}/runtime/signout`, {
4025
4025
  method: "POST",
4026
4026
  headers: {
@@ -4032,7 +4032,7 @@ async function Ma({ apiURI: n, appId: e, refreshToken: t }) {
4032
4032
  })
4033
4033
  });
4034
4034
  }
4035
- async function Ra({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
4035
+ async function Ma({ apiURI: n, appId: e, path: t, file: r, refreshToken: s, contentType: i, contentDisposition: o }) {
4036
4036
  const a = {
4037
4037
  app_id: e,
4038
4038
  path: t,
@@ -4166,7 +4166,7 @@ function pr(n) {
4166
4166
  }, e;
4167
4167
  }, {});
4168
4168
  }
4169
- const hs = "v1.0.50";
4169
+ const hs = "v1.0.51-branch-optional-async-storage.29876965683.1";
4170
4170
  function Fa(n, e, t = console) {
4171
4171
  return {
4172
4172
  info: n ? (...r) => t.info(...r, e()) : () => {
@@ -4177,7 +4177,7 @@ function Fa(n, e, t = console) {
4177
4177
  }
4178
4178
  };
4179
4179
  }
4180
- class ve {
4180
+ class Ae {
4181
4181
  constructor(e, t, r, s = { indexed: !1, unique: !1 }) {
4182
4182
  p(this, "valueType");
4183
4183
  p(this, "required");
@@ -4192,19 +4192,19 @@ class ve {
4192
4192
  * and enforced for backend
4193
4193
  */
4194
4194
  clientRequired() {
4195
- return new ve(this.valueType, !1, this.isIndexed, this.config);
4195
+ return new Ae(this.valueType, !1, this.isIndexed, this.config);
4196
4196
  }
4197
4197
  optional() {
4198
- return new ve(this.valueType, !1, this.isIndexed, this.config);
4198
+ return new Ae(this.valueType, !1, this.isIndexed, this.config);
4199
4199
  }
4200
4200
  unique() {
4201
- return new ve(this.valueType, this.required, this.isIndexed, {
4201
+ return new Ae(this.valueType, this.required, this.isIndexed, {
4202
4202
  ...this.config,
4203
4203
  unique: !0
4204
4204
  });
4205
4205
  }
4206
4206
  indexed() {
4207
- return new ve(this.valueType, this.required, !0, {
4207
+ return new Ae(this.valueType, this.required, !0, {
4208
4208
  ...this.config,
4209
4209
  indexed: !0
4210
4210
  });
@@ -4295,12 +4295,12 @@ const yr = [
4295
4295
  const f = i[l], h = r.entities[o];
4296
4296
  if (!h)
4297
4297
  throw new Q(`Entity '${o}' does not exist in schema while traversing dot notation path '${n}'.`, s);
4298
- const y = h.links[f];
4299
- if (!y) {
4300
- const b = Object.keys(h.links);
4301
- throw new Q(`Link '${f}' does not exist on entity '${o}' in dot notation path '${n}'. Available links: ${b.length > 0 ? b.join(", ") : "none"}`, s);
4298
+ const b = h.links[f];
4299
+ if (!b) {
4300
+ const y = Object.keys(h.links);
4301
+ throw new Q(`Link '${f}' does not exist on entity '${o}' in dot notation path '${n}'. Available links: ${y.length > 0 ? y.join(", ") : "none"}`, s);
4302
4302
  }
4303
- o = y.entityName;
4303
+ o = b.entityName;
4304
4304
  }
4305
4305
  const a = i[i.length - 1], c = r.entities[o];
4306
4306
  if (!c)
@@ -4308,14 +4308,14 @@ const yr = [
4308
4308
  if (a === "id") {
4309
4309
  if (typeof e == "string" && !Ve(e))
4310
4310
  throw new Q(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${e}`, s);
4311
- ze(e, n, new ve("string", !1, !0), t, s);
4311
+ ze(e, n, new Ae("string", !1, !0), t, s);
4312
4312
  return;
4313
4313
  }
4314
4314
  const u = c.attrs[a];
4315
4315
  if (Object.keys(c.links).includes(a)) {
4316
4316
  if (typeof e == "string" && !Ve(e))
4317
4317
  throw new Q(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${e}`, s);
4318
- ze(e, n, new ve("string", !1, !0), t, s);
4318
+ ze(e, n, new Ae("string", !1, !0), t, s);
4319
4319
  return;
4320
4320
  }
4321
4321
  if (!u) {
@@ -4332,7 +4332,7 @@ const yr = [
4332
4332
  continue;
4333
4333
  }
4334
4334
  if (s === "id") {
4335
- ze(i, "id", new ve("string", !1, !0), e, `${r}.id`);
4335
+ ze(i, "id", new Ae("string", !1, !0), e, `${r}.id`);
4336
4336
  continue;
4337
4337
  }
4338
4338
  if (s.includes(".")) {
@@ -4352,7 +4352,7 @@ const yr = [
4352
4352
  else if (c) {
4353
4353
  if (typeof i == "string" && !Ve(i))
4354
4354
  throw new Q(`Invalid value for link '${s}' in entity '${e}'. Expected a UUID, but received: ${i}`, `${r}.${s}`);
4355
- const u = new ve("string", !1, !0);
4355
+ const u = new Ae("string", !1, !0);
4356
4356
  ze(i, s, u, e, `${r}.${s}`);
4357
4357
  }
4358
4358
  }
@@ -4675,7 +4675,7 @@ function wr(n, e, t, r) {
4675
4675
  const i = Be(e.eav, [r, s, r]);
4676
4676
  return i ? i[3] : -1;
4677
4677
  }
4678
- function Tr(n, e, t) {
4678
+ function Sr(n, e, t) {
4679
4679
  for (const { action: r, triple: s } of t)
4680
4680
  switch (r) {
4681
4681
  case "added":
@@ -4695,23 +4695,23 @@ function Xa(n, e, t) {
4695
4695
  continue;
4696
4696
  const h = r[c] ?? {};
4697
4697
  r[c] = h;
4698
- const y = h[f] ?? {};
4698
+ const b = h[f] ?? {};
4699
4699
  switch (o) {
4700
4700
  case "added":
4701
- y.newValue = l;
4701
+ b.newValue = l;
4702
4702
  break;
4703
4703
  case "removed":
4704
- y.oldValue === void 0 && (y.oldValue = l);
4704
+ b.oldValue === void 0 && (b.oldValue = l);
4705
4705
  break;
4706
4706
  }
4707
- h[f] = y;
4707
+ h[f] = b;
4708
4708
  }
4709
4709
  for (const [o, a] of Object.entries(r))
4710
4710
  for (const [c, { oldValue: u, newValue: l }] of Object.entries(a))
4711
4711
  u === l && delete a[c];
4712
4712
  return r;
4713
4713
  }
4714
- function bt(n, e) {
4714
+ function gt(n, e) {
4715
4715
  return { [n.table]: e.map((t) => t.entity) };
4716
4716
  }
4717
4717
  function ec(n, e) {
@@ -4777,7 +4777,7 @@ class nc {
4777
4777
  this.subs.flush();
4778
4778
  }
4779
4779
  subscribe(e, t) {
4780
- const r = se(e);
4780
+ const r = ie(e);
4781
4781
  return this.callbacks[r] = this.callbacks[r] || [], this.callbacks[r].push(t), this.initSubscription(e, r, t), (s) => {
4782
4782
  this.unsubscribe(r, t, s == null ? void 0 : s.keepSubscription);
4783
4783
  };
@@ -4820,13 +4820,13 @@ class nc {
4820
4820
  if (s && s.state && s.state.txId) {
4821
4821
  this.sendResync(s, s.state, s.state.txId), (u = s.values) != null && u.entities && r && r({
4822
4822
  type: Ie.LoadFromStorage,
4823
- data: bt(s, (l = s.values) == null ? void 0 : l.entities)
4823
+ data: gt(s, (l = s.values) == null ? void 0 : l.entities)
4824
4824
  });
4825
4825
  return;
4826
4826
  }
4827
4827
  const i = Object.keys(e)[0], o = ((h = (f = e[i]) == null ? void 0 : f.$) == null ? void 0 : h.order) || { serverCreatedAt: "asc" }, [a, c] = Object.entries(o)[0];
4828
- this.subs.updateInPlace((y) => {
4829
- y[t] = {
4828
+ this.subs.updateInPlace((b) => {
4829
+ b[t] = {
4830
4830
  query: e,
4831
4831
  hash: t,
4832
4832
  table: i,
@@ -4845,7 +4845,7 @@ class nc {
4845
4845
  }
4846
4846
  }
4847
4847
  onStartSyncOk(e) {
4848
- const t = e["subscription-id"], r = e.q, s = se(r);
4848
+ const t = e["subscription-id"], r = e.q, s = ie(r);
4849
4849
  this.idToHash[t] = s, this.subs.updateInPlace((i) => {
4850
4850
  const o = i[s];
4851
4851
  if (!o)
@@ -4889,7 +4889,7 @@ class nc {
4889
4889
  u[s] = o, u[s].updatedAt = Date.now();
4890
4890
  }), o.values && this.notifyCbs(s, {
4891
4891
  type: Ie.InitialSyncBatch,
4892
- data: bt(o, o.values.entities),
4892
+ data: gt(o, o.values.entities),
4893
4893
  batch: i
4894
4894
  });
4895
4895
  }
@@ -4914,7 +4914,7 @@ class nc {
4914
4914
  const s = this.subs.currentValue[r];
4915
4915
  s && this.notifyCbs(r, {
4916
4916
  type: Ie.InitialSyncComplete,
4917
- data: bt(s, ((i = s.values) == null ? void 0 : i.entities) || [])
4917
+ data: gt(s, ((i = s.values) == null ? void 0 : i.entities) || [])
4918
4918
  });
4919
4919
  }
4920
4920
  onSyncUpdateTriples(e) {
@@ -4939,9 +4939,9 @@ class nc {
4939
4939
  continue;
4940
4940
  i.txId = a["tx-id"];
4941
4941
  const c = [], u = {};
4942
- for (const m of a.changes) {
4943
- const S = u[m.triple[0]] ?? [];
4944
- u[m.triple[0]] = S, S.push(m);
4942
+ for (const _ of a.changes) {
4943
+ const S = u[_.triple[0]] ?? [];
4944
+ u[_.triple[0]] = S, S.push(_);
4945
4945
  }
4946
4946
  const l = s.values ?? {
4947
4947
  entities: [],
@@ -4949,48 +4949,48 @@ class nc {
4949
4949
  }, f = l.entities;
4950
4950
  s.values = l;
4951
4951
  const h = [];
4952
- e: for (const [m, S] of Object.entries(u))
4953
- for (let _ = 0; _ < f.length; _++) {
4954
- const T = f[_];
4955
- if (Ri(T.store, m)) {
4956
- Tr(T.store, l.attrsStore, S);
4957
- const M = zt(s, T.store, l.attrsStore), O = Xa(T.store, l.attrsStore, S)[m];
4958
- M ? (h.push({
4952
+ e: for (const [_, S] of Object.entries(u))
4953
+ for (let m = 0; m < f.length; m++) {
4954
+ const T = f[m];
4955
+ if (Mi(T.store, _)) {
4956
+ Sr(T.store, l.attrsStore, S);
4957
+ const C = zt(s, T.store, l.attrsStore), O = Xa(T.store, l.attrsStore, S)[_];
4958
+ C ? (h.push({
4959
4959
  oldEntity: T.entity,
4960
- newEntity: M,
4960
+ newEntity: C,
4961
4961
  changedFields: O || {}
4962
- }), T.entity = M) : c.push(_), delete u[m];
4962
+ }), T.entity = C) : c.push(m), delete u[_];
4963
4963
  continue e;
4964
4964
  }
4965
4965
  }
4966
- const y = [];
4967
- for (const [m, S] of Object.entries(u)) {
4968
- const _ = this.createStore([]);
4969
- Tr(_, l.attrsStore, S);
4970
- const T = zt(s, _, l.attrsStore);
4966
+ const b = [];
4967
+ for (const [_, S] of Object.entries(u)) {
4968
+ const m = this.createStore([]);
4969
+ Sr(m, l.attrsStore, S);
4970
+ const T = zt(s, m, l.attrsStore);
4971
4971
  if (!T) {
4972
4972
  this.log.error("No entity found after applying change", {
4973
4973
  sub: s,
4974
4974
  changes: S,
4975
- store: _
4975
+ store: m
4976
4976
  });
4977
4977
  continue;
4978
4978
  }
4979
4979
  f.push({
4980
- store: _,
4980
+ store: m,
4981
4981
  entity: T,
4982
- serverCreatedAt: wr(s, _, l.attrsStore, T.id)
4983
- }), y.push(T);
4982
+ serverCreatedAt: wr(s, m, l.attrsStore, T.id)
4983
+ }), b.push(T);
4984
4984
  }
4985
- const b = [];
4986
- for (const m of c.sort().reverse())
4987
- b.push(f[m].entity), f.splice(m, 1);
4985
+ const y = [];
4986
+ for (const _ of c.sort().reverse())
4987
+ y.push(f[_].entity), f.splice(_, 1);
4988
4988
  const g = ec(s, this.getAttrs);
4989
4989
  tc(s, g, f), this.notifyCbs(r, {
4990
4990
  type: Ie.SyncTransaction,
4991
- data: bt(s, (o = s.values) == null ? void 0 : o.entities),
4992
- added: y,
4993
- removed: b,
4991
+ data: gt(s, (o = s.values) == null ? void 0 : o.entities),
4992
+ added: b,
4993
+ removed: y,
4994
4994
  updated: h
4995
4995
  });
4996
4996
  }
@@ -5010,7 +5010,7 @@ class nc {
5010
5010
  }
5011
5011
  }
5012
5012
  onStartSyncError(e) {
5013
- const t = se(e["original-event"].q), r = {
5013
+ const t = ie(e["original-event"].q), r = {
5014
5014
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa.",
5015
5015
  status: e.status,
5016
5016
  type: e.type,
@@ -5032,10 +5032,10 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5032
5032
  let o = null, a = null, c = null;
5033
5033
  const u = J();
5034
5034
  let l = !1, f = !1;
5035
- const h = [], y = [], b = [];
5036
- let g = !1, m = 0, S = 0;
5037
- const _ = [], T = new TextEncoder();
5038
- function M() {
5035
+ const h = [], b = [], y = [];
5036
+ let g = !1, _ = 0, S = 0;
5037
+ const m = [], T = new TextEncoder();
5038
+ function C() {
5039
5039
  f = !0;
5040
5040
  for (const A of h)
5041
5041
  A(a ?? void 0);
@@ -5046,48 +5046,48 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5046
5046
  k !== -1 && h.splice(k, 1);
5047
5047
  };
5048
5048
  }
5049
- function F(A) {
5050
- return b.push(A), () => {
5051
- const k = b.indexOf(A);
5052
- k !== -1 && b.splice(k, 1);
5049
+ function M(A) {
5050
+ return y.push(A), () => {
5051
+ const k = y.indexOf(A);
5052
+ k !== -1 && y.splice(k, 1);
5053
5053
  };
5054
5054
  }
5055
5055
  e.waitUntil && e.waitUntil(new Promise((A) => {
5056
- b.push(A);
5056
+ y.push(A);
5057
5057
  }));
5058
- function P() {
5059
- for (const A of b)
5058
+ function R() {
5059
+ for (const A of y)
5060
5060
  try {
5061
5061
  A();
5062
5062
  } catch {
5063
5063
  }
5064
5064
  }
5065
- function C(A) {
5066
- return y.push(A), o && A(o), () => {
5067
- const k = y.indexOf(A);
5068
- k !== -1 && y.splice(k, 1);
5065
+ function P(A) {
5066
+ return b.push(A), o && A(o), () => {
5067
+ const k = b.indexOf(A);
5068
+ k !== -1 && b.splice(k, 1);
5069
5069
  };
5070
5070
  }
5071
5071
  function G(A) {
5072
5072
  o = A;
5073
- for (const k of y)
5073
+ for (const k of b)
5074
5074
  k(o);
5075
5075
  }
5076
- function N() {
5076
+ function L() {
5077
5077
  g = !0;
5078
5078
  }
5079
5079
  function B(A) {
5080
- let k = m, K = 0, H = 0;
5081
- for (const { byteLen: Y } of _) {
5080
+ let k = _, K = 0, H = 0;
5081
+ for (const { byteLen: Y } of m) {
5082
5082
  const oe = k + Y;
5083
5083
  if (oe > A)
5084
5084
  break;
5085
5085
  k = oe, K++, H += Y;
5086
5086
  }
5087
- K > 0 && (m += H, S -= H, _.splice(0, K));
5087
+ K > 0 && (_ += H, S -= H, m.splice(0, K));
5088
5088
  }
5089
5089
  function z(A, k) {
5090
- a = k, M(), A.error(k), P();
5090
+ a = k, C(), A.error(k), R();
5091
5091
  }
5092
5092
  async function ee() {
5093
5093
  const A = await t({
@@ -5098,15 +5098,15 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5098
5098
  switch (A.type) {
5099
5099
  case "ok": {
5100
5100
  const { streamId: k, offset: K } = A;
5101
- o = k, B(K), _.length && r({
5101
+ o = k, B(K), m.length && r({
5102
5102
  streamId: k,
5103
- chunks: _.map((H) => H.chunk),
5104
- offset: m
5103
+ chunks: m.map((H) => H.chunk),
5104
+ offset: _
5105
5105
  }), g = !1;
5106
5106
  break;
5107
5107
  }
5108
5108
  case "disconnect": {
5109
- N();
5109
+ L();
5110
5110
  break;
5111
5111
  }
5112
5112
  case "error": {
@@ -5116,15 +5116,15 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5116
5116
  }
5117
5117
  }
5118
5118
  function q() {
5119
- N(), ee();
5119
+ L(), ee();
5120
5120
  }
5121
5121
  function E({ offset: A, done: k }) {
5122
- B(A), k && (l = !0, P());
5122
+ B(A), k && (l = !0, R());
5123
5123
  }
5124
- function j(A) {
5125
- return l ? (z(A, new ie("Stream has been closed.")), null) : o || (z(A, new ie("Stream has not been initialized.")), null);
5124
+ function $(A) {
5125
+ return l ? (z(A, new re("Stream has been closed.")), null) : o || (z(A, new re("Stream has not been initialized.")), null);
5126
5126
  }
5127
- async function R(A) {
5127
+ async function j(A) {
5128
5128
  c = A;
5129
5129
  let k = !0, K = 0;
5130
5130
  for (; k; ) {
@@ -5139,12 +5139,12 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5139
5139
  case "ok": {
5140
5140
  const { streamId: oe, offset: Ge } = Y;
5141
5141
  if (Ge !== 0) {
5142
- const ge = new ie("Write stream is corrupted");
5142
+ const ge = new re("Write stream is corrupted");
5143
5143
  z(A, ge);
5144
5144
  return;
5145
5145
  }
5146
5146
  G(oe), s(oe, {
5147
- onDisconnect: N,
5147
+ onDisconnect: L,
5148
5148
  onFlush: E,
5149
5149
  onConnectionReconnect: ee,
5150
5150
  onAppendFailed: q
@@ -5152,7 +5152,7 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5152
5152
  return;
5153
5153
  }
5154
5154
  case "disconnect": {
5155
- k = !0, N(), K++, await new Promise((oe) => {
5155
+ k = !0, L(), K++, await new Promise((oe) => {
5156
5156
  setTimeout(oe, Math.max(0, H - Date.now()));
5157
5157
  });
5158
5158
  break;
@@ -5164,7 +5164,7 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5164
5164
  }
5165
5165
  }
5166
5166
  }
5167
- class U extends n {
5167
+ class x extends n {
5168
5168
  constructor(k, K) {
5169
5169
  super(k, K);
5170
5170
  }
@@ -5176,29 +5176,29 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5176
5176
  }, oe = (ge) => {
5177
5177
  k(ge), Y();
5178
5178
  }, Ge = (ge) => {
5179
- K(ge || new ie("Stream is closed.")), Y();
5179
+ K(ge || new re("Stream is closed.")), Y();
5180
5180
  };
5181
- H.push(C(oe)), H.push(O(Ge));
5181
+ H.push(P(oe)), H.push(O(Ge));
5182
5182
  });
5183
5183
  }
5184
5184
  }
5185
5185
  return {
5186
- stream: new U({
5186
+ stream: new x({
5187
5187
  // TODO(dww): accept a storage so that write streams can survive across
5188
5188
  // browser restarts
5189
5189
  async start(A) {
5190
5190
  try {
5191
- await R(A);
5191
+ await j(A);
5192
5192
  } catch (k) {
5193
5193
  z(A, k);
5194
5194
  }
5195
5195
  },
5196
5196
  write(A, k) {
5197
- const K = j(k);
5197
+ const K = $(k);
5198
5198
  if (K) {
5199
5199
  const H = T.encode(A).length;
5200
- _.push({ chunk: A, byteLen: H });
5201
- const Y = m + S;
5200
+ m.push({ chunk: A, byteLen: H });
5201
+ const Y = _ + S;
5202
5202
  S += H, g || r({ streamId: K, chunks: [A], offset: Y });
5203
5203
  }
5204
5204
  },
@@ -5206,21 +5206,21 @@ function rc({ WStream: n, opts: e, startStream: t, appendStream: r, registerStre
5206
5206
  o ? r({
5207
5207
  streamId: o,
5208
5208
  chunks: [],
5209
- offset: m + S,
5209
+ offset: _ + S,
5210
5210
  isDone: !0
5211
- }) : P(), M();
5211
+ }) : R(), C();
5212
5212
  },
5213
5213
  abort(A) {
5214
5214
  o ? r({
5215
5215
  streamId: o,
5216
5216
  chunks: [],
5217
- offset: m + S,
5217
+ offset: _ + S,
5218
5218
  isDone: !0,
5219
5219
  abortReason: A
5220
- }) : P(), M();
5220
+ }) : R(), C();
5221
5221
  }
5222
5222
  }),
5223
- addCompleteCb: F,
5223
+ addCompleteCb: M,
5224
5224
  closed() {
5225
5225
  return f;
5226
5226
  }
@@ -5265,68 +5265,68 @@ function ic({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5265
5265
  const o = new TextDecoder("utf-8"), a = new TextEncoder();
5266
5266
  let c, u = !1;
5267
5267
  const l = [], f = [];
5268
- let h = null, y = null;
5269
- function b(P) {
5268
+ let h = null, b = null;
5269
+ function y(R) {
5270
5270
  u = !0;
5271
- for (const C of l)
5272
- C(P);
5271
+ for (const P of l)
5272
+ P(R);
5273
5273
  }
5274
- function g(P) {
5275
- return l.push(P), () => {
5276
- const C = l.indexOf(P);
5277
- C !== -1 && l.splice(C, 1);
5274
+ function g(R) {
5275
+ return l.push(R), () => {
5276
+ const P = l.indexOf(R);
5277
+ P !== -1 && l.splice(P, 1);
5278
5278
  };
5279
5279
  }
5280
- function m(P) {
5281
- return f.push(P), h && P(h), () => {
5282
- const C = f.indexOf(P);
5283
- C !== -1 && f.splice(C, 1);
5280
+ function _(R) {
5281
+ return f.push(R), h && R(h), () => {
5282
+ const P = f.indexOf(R);
5283
+ P !== -1 && f.splice(P, 1);
5284
5284
  };
5285
5285
  }
5286
- function S(P, C) {
5287
- y = C, P.error(C), b(C);
5286
+ function S(R, P) {
5287
+ b = P, R.error(P), y(P);
5288
5288
  }
5289
- let _ = 0;
5290
- async function T(P, C) {
5289
+ let m = 0;
5290
+ async function T(R, P) {
5291
5291
  c = J();
5292
- const G = { ...P || {}, eventId: c };
5293
- for await (const N of t(G)) {
5292
+ const G = { ...R || {}, eventId: c };
5293
+ for await (const L of t(G)) {
5294
5294
  if (i)
5295
5295
  return;
5296
- if (N.type === "reconnect")
5296
+ if (L.type === "reconnect")
5297
5297
  return { retry: !0 };
5298
- if (N.type === "error") {
5299
- S(C, N.error);
5298
+ if (L.type === "error") {
5299
+ S(P, L.error);
5300
5300
  return;
5301
5301
  }
5302
- if (N.offset > s) {
5303
- S(C, new ie("Stream is corrupted.")), i = !0;
5302
+ if (L.offset > s) {
5303
+ S(P, new re("Stream is corrupted.")), i = !0;
5304
5304
  return;
5305
5305
  }
5306
- h = N.streamId;
5306
+ h = L.streamId;
5307
5307
  for (const z of f)
5308
5308
  z(h);
5309
- let B = s - N.offset;
5310
- if (N.files && N.files.length) {
5309
+ let B = s - L.offset;
5310
+ if (L.files && L.files.length) {
5311
5311
  const z = new AbortController();
5312
- let ee = fetch(N.files[0].url, {
5312
+ let ee = fetch(L.files[0].url, {
5313
5313
  signal: z.signal
5314
5314
  });
5315
- for (let q = 0; q < N.files.length; q++) {
5316
- const E = N.files[q + 1], R = await ee;
5317
- if (E && (ee = fetch(E.url, { signal: z.signal })), !R.ok) {
5318
- if (_++, _ > 10) {
5319
- S(C, new ie("Unable to process stream."));
5315
+ for (let q = 0; q < L.files.length; q++) {
5316
+ const E = L.files[q + 1], j = await ee;
5317
+ if (E && (ee = fetch(E.url, { signal: z.signal })), !j.ok) {
5318
+ if (m++, m > 10) {
5319
+ S(P, new re("Unable to process stream."));
5320
5320
  return;
5321
5321
  }
5322
5322
  return { retry: !0 };
5323
5323
  }
5324
- if (R.body) {
5325
- const U = R.body.getReader();
5324
+ if (j.body) {
5325
+ const x = j.body.getReader();
5326
5326
  try {
5327
5327
  for (; ; ) {
5328
- const { done: L, value: A } = await U.read();
5329
- if (L)
5328
+ const { done: N, value: A } = await x.read();
5329
+ if (N)
5330
5330
  break;
5331
5331
  if (i) {
5332
5332
  z.abort();
@@ -5337,79 +5337,79 @@ function ic({ RStream: n, opts: e, startStream: t, cancelStream: r }) {
5337
5337
  continue;
5338
5338
  s += k.length;
5339
5339
  const K = o.decode(k);
5340
- C.enqueue(K);
5340
+ P.enqueue(K);
5341
5341
  }
5342
5342
  } finally {
5343
- U.releaseLock();
5343
+ x.releaseLock();
5344
5344
  }
5345
5345
  } else {
5346
- const U = await R.arrayBuffer();
5347
- let L = U;
5346
+ const x = await j.arrayBuffer();
5347
+ let N = x;
5348
5348
  if (i) {
5349
5349
  z.abort();
5350
5350
  return;
5351
5351
  }
5352
- if (B > 0 && (L = new Uint8Array(U).subarray(B), B -= U.byteLength - L.length), !L.byteLength)
5352
+ if (B > 0 && (N = new Uint8Array(x).subarray(B), B -= x.byteLength - N.length), !N.byteLength)
5353
5353
  continue;
5354
- s += L.byteLength;
5355
- const A = o.decode(L);
5356
- C.enqueue(A);
5354
+ s += N.byteLength;
5355
+ const A = o.decode(N);
5356
+ P.enqueue(A);
5357
5357
  }
5358
5358
  }
5359
5359
  }
5360
- if (_ = 0, N.content) {
5361
- let z = N.content, ee = a.encode(N.content);
5360
+ if (m = 0, L.content) {
5361
+ let z = L.content, ee = a.encode(L.content);
5362
5362
  if (B > 0) {
5363
5363
  const q = ee.subarray(B);
5364
5364
  if (B -= ee.length - q.length, !q.length)
5365
5365
  continue;
5366
5366
  ee = q, z = o.decode(q);
5367
5367
  }
5368
- s += ee.length, C.enqueue(z);
5368
+ s += ee.length, P.enqueue(z);
5369
5369
  }
5370
5370
  }
5371
5371
  }
5372
- async function M(P) {
5373
- let C = !0, G = 0;
5374
- for (; C; ) {
5375
- C = !1;
5376
- let N = Date.now() + Math.min(15e3, 500 * (G - 1));
5377
- const B = await T({ ...e, offset: s }, P);
5378
- B != null && B.retry && (C = !0, G++, N < Date.now() - 3e5 && (G = 0), await new Promise((z) => {
5379
- setTimeout(z, Math.max(0, N - Date.now()));
5372
+ async function C(R) {
5373
+ let P = !0, G = 0;
5374
+ for (; P; ) {
5375
+ P = !1;
5376
+ let L = Date.now() + Math.min(15e3, 500 * (G - 1));
5377
+ const B = await T({ ...e, offset: s }, R);
5378
+ B != null && B.retry && (P = !0, G++, L < Date.now() - 3e5 && (G = 0), await new Promise((z) => {
5379
+ setTimeout(z, Math.max(0, L - Date.now()));
5380
5380
  }));
5381
5381
  }
5382
- !i && !u && (P.close(), b());
5382
+ !i && !u && (R.close(), y());
5383
5383
  }
5384
5384
  class O extends n {
5385
- constructor(C, G) {
5386
- super(C, G);
5385
+ constructor(P, G) {
5386
+ super(P, G);
5387
5387
  }
5388
5388
  async streamId() {
5389
5389
  if (h)
5390
5390
  return h;
5391
- if (y)
5392
- throw y;
5393
- return new Promise((C, G) => {
5394
- const N = [], B = () => {
5395
- for (const q of N)
5391
+ if (b)
5392
+ throw b;
5393
+ return new Promise((P, G) => {
5394
+ const L = [], B = () => {
5395
+ for (const q of L)
5396
5396
  q();
5397
5397
  }, z = (q) => {
5398
- C(q), B();
5398
+ P(q), B();
5399
5399
  }, ee = (q) => {
5400
- G(q || new ie("Stream is closed.")), B();
5400
+ G(q || new re("Stream is closed.")), B();
5401
5401
  };
5402
- N.push(m(z)), N.push(g(ee));
5402
+ L.push(_(z)), L.push(g(ee));
5403
5403
  });
5404
5404
  }
5405
5405
  }
5406
5406
  return {
5407
5407
  stream: new O({
5408
- start(P) {
5409
- M(P);
5408
+ start(R) {
5409
+ C(R);
5410
5410
  },
5411
- cancel(P) {
5412
- i = !0, c && r({ eventId: c }), b();
5411
+ cancel(R) {
5412
+ i = !0, c && r({ eventId: c }), y();
5413
5413
  }
5414
5414
  }),
5415
5415
  addCloseCb: g,
@@ -5524,7 +5524,7 @@ class oc {
5524
5524
  if (e.error) {
5525
5525
  e.retry ? r.push({ type: "reconnect" }) : r.push({
5526
5526
  type: "error",
5527
- error: new ie(e.error)
5527
+ error: new re(e.error)
5528
5528
  }), r.close(), delete this.readStreamIterators[t];
5529
5529
  return;
5530
5530
  }
@@ -5539,7 +5539,7 @@ class oc {
5539
5539
  onConnectionStatusChange(e) {
5540
5540
  for (const t of Object.values(this.startWriteStreamCbs))
5541
5541
  t({ type: "disconnect" });
5542
- if (this.startWriteStreamCbs = {}, e !== Te.AUTHENTICATED)
5542
+ if (this.startWriteStreamCbs = {}, e !== Se.AUTHENTICATED)
5543
5543
  for (const { onDisconnect: t } of Object.values(this.writeStreams))
5544
5544
  t();
5545
5545
  else {
@@ -5562,7 +5562,7 @@ class oc {
5562
5562
  const r = e["client-event-id"], s = this.startWriteStreamCbs[r];
5563
5563
  s && (s({
5564
5564
  type: "error",
5565
- error: new ie(e.message || "Unknown error", e.hint)
5565
+ error: new re(e.message || "Unknown error", e.hint)
5566
5566
  }), delete this.startWriteStreamCbs[r]);
5567
5567
  break;
5568
5568
  }
@@ -5570,7 +5570,7 @@ class oc {
5570
5570
  const r = e["client-event-id"], s = this.readStreamIterators[r];
5571
5571
  s && (s.push({
5572
5572
  type: "error",
5573
- error: new ie(e.message || "Unknown error", e.hint)
5573
+ error: new re(e.message || "Unknown error", e.hint)
5574
5574
  }), s.close(), delete this.readStreamIterators[r]);
5575
5575
  break;
5576
5576
  }
@@ -5580,16 +5580,16 @@ class oc {
5580
5580
  return this.activeStreams.size > 0;
5581
5581
  }
5582
5582
  }
5583
- const Te = {
5583
+ const Se = {
5584
5584
  CONNECTING: "connecting",
5585
5585
  OPENED: "opened",
5586
5586
  AUTHENTICATED: "authenticated",
5587
5587
  CLOSED: "closed",
5588
5588
  ERRORED: "errored"
5589
- }, ac = 3e4, cc = 3e4, uc = 200, lc = 1e3 * 60, fc = lc * 60 * 24, Sr = "lastSyncedUserCookie", dc = {
5589
+ }, ac = 3e4, cc = 3e4, uc = 200, lc = 1e3 * 60, fc = lc * 60 * 24, Tr = "lastSyncedUserCookie", dc = {
5590
5590
  apiURI: "https://api.instantdb.com",
5591
5591
  websocketURI: "wss://api.instantdb.com/runtime/session"
5592
- }, Vt = "_instant_oauth_redirect", Qt = "_instant_extra_fields_id", gt = "oauthExtraFields", Fe = "currentUser";
5592
+ }, Vt = "_instant_oauth_redirect", Qt = "_instant_extra_fields_id", _t = "oauthExtraFields", Fe = "currentUser";
5593
5593
  function hc({ transportType: n, appId: e, apiURI: t, wsURI: r, EventSourceImpl: s }) {
5594
5594
  if (!s)
5595
5595
  return new mr(`${r}?app_id=${e}`);
@@ -5673,7 +5673,7 @@ class wc {
5673
5673
  p(this, "attrs");
5674
5674
  p(this, "_isOnline", !0);
5675
5675
  p(this, "_isShutdown", !1);
5676
- p(this, "status", Te.CONNECTING);
5676
+ p(this, "status", Se.CONNECTING);
5677
5677
  /** @type {PersistedObject<string, QuerySub, QuerySubInStorage>} */
5678
5678
  p(this, "querySubs");
5679
5679
  /** @type {PersistedObject} */
@@ -5690,6 +5690,13 @@ class wc {
5690
5690
  p(this, "attrsCbs", []);
5691
5691
  p(this, "mutationErrorCbs", []);
5692
5692
  p(this, "connectionStatusCbs", []);
5693
+ p(this, "appStatusCbs", []);
5694
+ /**
5695
+ * Carries the raw server status off the public type: `disabled` is an
5696
+ * operator-level state we don't surface to apps.
5697
+ * @type {import('./clientTypes.ts').AppStatusState & { status?: 'active' | 'read-only' | 'disabled' }}
5698
+ */
5699
+ p(this, "_appStatusState", { isLoading: !0, isReadOnly: void 0 });
5693
5700
  p(this, "config");
5694
5701
  p(this, "mutationDeferredStore", /* @__PURE__ */ new Map());
5695
5702
  p(this, "_reconnectTimeoutId", null);
@@ -5745,14 +5752,14 @@ class wc {
5745
5752
  // Queries
5746
5753
  p(this, "getPreviousResult", (e) => {
5747
5754
  var r;
5748
- const t = se(e);
5755
+ const t = ie(e);
5749
5756
  return (r = this.dataForQuery(t)) == null ? void 0 : r.data;
5750
5757
  });
5751
5758
  /** Re-run instaql and call all callbacks with new data */
5752
5759
  p(this, "notifyOne", (e) => {
5753
5760
  var i;
5754
5761
  const t = this.queryCbs[e] ?? [], r = (i = this._dataForQueryCache[e]) == null ? void 0 : i.data, s = this.dataForQuery(e);
5755
- s != null && s.data && (this._dataForQueryCache[e] = s, !St(s.data, r) && t.forEach((o) => o.cb(s.data)));
5762
+ s != null && s.data && (this._dataForQueryCache[e] = s, !vt(s.data, r) && t.forEach((o) => o.cb(s.data)));
5756
5763
  });
5757
5764
  p(this, "notifyOneQueryOnce", (e) => {
5758
5765
  var s;
@@ -5762,10 +5769,16 @@ class wc {
5762
5769
  });
5763
5770
  });
5764
5771
  p(this, "notifyQueryError", (e, t) => {
5765
- (this.queryCbs[e] || []).forEach((s) => s.cb({ error: t }));
5772
+ delete this._dataForQueryCache[e], (this.queryCbs[e] || []).forEach((s) => s.cb({ error: t }));
5766
5773
  });
5767
5774
  /** Applies transactions locally and sends transact message to server */
5768
5775
  p(this, "pushTx", (e) => {
5776
+ if (this._appStatusState.isReadOnly)
5777
+ return Promise.reject(this._appStatusState.status === "disabled" ? new re("This app is currently disabled.", {
5778
+ status: "disabled"
5779
+ }) : new re("This app is in read-only mode.", {
5780
+ status: "read-only"
5781
+ }));
5769
5782
  this.config.disableValidation || Ga(e, this.config.schema);
5770
5783
  try {
5771
5784
  const t = _a({
@@ -5807,7 +5820,7 @@ class wc {
5807
5820
  this._log.info("[socket][open]", t.id, "skip; this is no longer the current transport");
5808
5821
  return;
5809
5822
  }
5810
- this._log.info("[socket][open]", this._transport.id), this._setStatus(Te.OPENED), this.getCurrentUser().then((r) => {
5823
+ this._log.info("[socket][open]", this._transport.id), this._setStatus(Se.OPENED), this.getCurrentUser().then((r) => {
5811
5824
  var s;
5812
5825
  this._trySend(J(), {
5813
5826
  op: "init",
@@ -5860,7 +5873,7 @@ class wc {
5860
5873
  this._log.info("[socket][close]", t.id, "skip; this is no longer the current transport");
5861
5874
  return;
5862
5875
  }
5863
- this._setStatus(Te.CLOSED);
5876
+ this._setStatus(Se.CLOSED);
5864
5877
  for (const r of Object.values(this._rooms))
5865
5878
  r.isConnected = !1;
5866
5879
  if (this._isShutdown) {
@@ -5897,7 +5910,7 @@ class wc {
5897
5910
  log: this._log
5898
5911
  }), this._oauthCallbackResponse = this._oauthLoginInit(), this.setupUserSyncTimer(), r.getIsOnline().then((o) => {
5899
5912
  this._isOnline = o, this._startSocket(), r.listen((a) => {
5900
- a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", Te.CLOSED), this._setStatus(Te.CLOSED)));
5913
+ a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info("Changing status from", this.status, "to", Se.CLOSED), this._setStatus(Se.CLOSED)));
5901
5914
  });
5902
5915
  }), typeof addEventListener < "u" && (this._beforeUnload = this._beforeUnload.bind(this), addEventListener("beforeunload", this._beforeUnload));
5903
5916
  }
@@ -5988,13 +6001,13 @@ class wc {
5988
6001
  s.resolve({ status: e, eventId: t });
5989
6002
  else if (r != null && r.type) {
5990
6003
  const { status: o, ...a } = r;
5991
- s.reject(new Rt({
6004
+ s.reject(new Mt({
5992
6005
  // @ts-expect-error body.type is not constant typed
5993
6006
  body: a,
5994
6007
  status: o ?? 0
5995
6008
  }));
5996
6009
  } else
5997
- s.reject(new ie((r == null ? void 0 : r.message) || "Unknown error", r == null ? void 0 : r.hint, r == null ? void 0 : r.traceId));
6010
+ s.reject(new re((r == null ? void 0 : r.message) || "Unknown error", r == null ? void 0 : r.hint, r == null ? void 0 : r.traceId));
5998
6011
  }
5999
6012
  _setStatus(e, t) {
6000
6013
  this.status = e, this._errorMessage = t, this.notifyConnectionStatusSubs(e), this._instantStream.onConnectionStatusChange(e);
@@ -6018,7 +6031,7 @@ class wc {
6018
6031
  _addQueryData(e, t, r) {
6019
6032
  if (!this.attrs)
6020
6033
  throw new Error("Attrs in reactor have not been set");
6021
- const s = se(e), i = this.ensureAttrs(), o = tt(this.attrs, t.triples, r, this.config.useDateObjects);
6034
+ const s = ie(e), i = this.ensureAttrs(), o = tt(this.attrs, t.triples, r, this.config.useDateObjects);
6022
6035
  this.querySubs.updateInPlace((a) => {
6023
6036
  a[s] = {
6024
6037
  result: {
@@ -6033,39 +6046,39 @@ class wc {
6033
6046
  }), this._cleanupPendingMutationsQueries(), this.notifyOne(s), this.notifyOneQueryOnce(s), this._cleanupPendingMutationsTimeout();
6034
6047
  }
6035
6048
  _handleReceive(e, t) {
6036
- var s, i, o, a, c, u, l;
6049
+ var s, i, o, a, c, u, l, f;
6037
6050
  const r = !!this.config.schema && ("cardinalityInference" in this.config ? !!this.config.cardinalityInference : !0);
6038
6051
  switch (vr[t.op] || this._log.info("[receive]", e, t.op, t), t.op) {
6039
6052
  case "init-ok": {
6040
- this._setStatus(Te.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
6053
+ this._setStatus(Se.AUTHENTICATED), this._reconnectTimeoutMs = 0, this._setAppStatus(((s = t["app-status"]) == null ? void 0 : s.status) ?? "active"), this._setAttrs(t.attrs), this._flushPendingMessages(), this._sessionId = t["session-id"];
6041
6054
  for (const y of Object.keys(this._rooms)) {
6042
- const b = (i = (s = this._presence[y]) == null ? void 0 : s.result) == null ? void 0 : i.user, g = (o = this._rooms[y]) == null ? void 0 : o.roomType;
6043
- this._tryJoinRoom(g, y, b);
6055
+ const g = (o = (i = this._presence[y]) == null ? void 0 : i.result) == null ? void 0 : o.user, _ = (a = this._rooms[y]) == null ? void 0 : a.roomType;
6056
+ this._tryJoinRoom(_, y, g);
6044
6057
  }
6045
6058
  break;
6046
6059
  }
6047
6060
  case "add-query-exists": {
6048
- this.notifyOneQueryOnce(se(t.q));
6061
+ this.notifyOneQueryOnce(ie(t.q));
6049
6062
  break;
6050
6063
  }
6051
6064
  case "add-query-ok": {
6052
- const { q: y, result: b } = t, g = se(y);
6053
- if (!this._hasQueryListeners() && !this.querySubs.currentValue[g])
6065
+ const { q: y, result: g } = t, _ = ie(y);
6066
+ if (!this._hasQueryListeners() && !this.querySubs.currentValue[_])
6054
6067
  break;
6055
- const m = (c = (a = b == null ? void 0 : b[0]) == null ? void 0 : a.data) == null ? void 0 : c["page-info"], S = (l = (u = b == null ? void 0 : b[0]) == null ? void 0 : u.data) == null ? void 0 : l.aggregate, _ = hr(b), T = this.ensureAttrs(), M = tt(T, _, r, this.config.useDateObjects);
6056
- this.querySubs.updateInPlace((O) => {
6057
- if (!O[g]) {
6058
- this._log.info("Missing value in querySubs", { hash: g, q: y });
6068
+ const S = (u = (c = g == null ? void 0 : g[0]) == null ? void 0 : c.data) == null ? void 0 : u["page-info"], m = (f = (l = g == null ? void 0 : g[0]) == null ? void 0 : l.data) == null ? void 0 : f.aggregate, T = hr(g), C = this.ensureAttrs(), O = tt(C, T, r, this.config.useDateObjects);
6069
+ this.querySubs.updateInPlace((M) => {
6070
+ if (!M[_]) {
6071
+ this._log.info("Missing value in querySubs", { hash: _, q: y });
6059
6072
  return;
6060
6073
  }
6061
- O[g].result = {
6062
- store: M,
6063
- attrsStore: T,
6064
- pageInfo: m,
6065
- aggregate: S,
6074
+ M[_].result = {
6075
+ store: O,
6076
+ attrsStore: C,
6077
+ pageInfo: S,
6078
+ aggregate: m,
6066
6079
  processedTxId: t["processed-tx-id"]
6067
6080
  };
6068
- }), this._cleanupPendingMutationsQueries(), this.notifyOne(g), this.notifyOneQueryOnce(g), this._cleanupPendingMutationsTimeout();
6081
+ }), this._cleanupPendingMutationsQueries(), this.notifyOne(_), this.notifyOneQueryOnce(_), this._cleanupPendingMutationsTimeout();
6069
6082
  break;
6070
6083
  }
6071
6084
  case "start-sync-ok": {
@@ -6101,65 +6114,65 @@ class wc {
6101
6114
  break;
6102
6115
  }
6103
6116
  case "refresh-ok": {
6104
- const { computations: y, attrs: b } = t, g = t["processed-tx-id"];
6105
- b && this._setAttrs(b), this._cleanupPendingMutationsTimeout();
6106
- const m = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), g);
6107
- m !== this._pendingMutations() && this.kv.updateInPlace((T) => {
6108
- T.pendingMutations = m;
6117
+ const { computations: y, attrs: g } = t, _ = t["processed-tx-id"];
6118
+ g && this._setAttrs(g), this._cleanupPendingMutationsTimeout();
6119
+ const S = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations(), _);
6120
+ S !== this._pendingMutations() && this.kv.updateInPlace((C) => {
6121
+ C.pendingMutations = S;
6109
6122
  });
6110
- const S = Bt(m.entries()), _ = y.map((T) => {
6111
- var q, E, j, R;
6112
- const M = T["instaql-query"], O = T["instaql-result"], F = se(M), P = hr(O), C = this.ensureAttrs(), G = tt(C, P, r, this.config.useDateObjects), { store: N, attrsStore: B } = this._applyOptimisticUpdates(G, C, S, g), z = (E = (q = O == null ? void 0 : O[0]) == null ? void 0 : q.data) == null ? void 0 : E["page-info"], ee = (R = (j = O == null ? void 0 : O[0]) == null ? void 0 : j.data) == null ? void 0 : R.aggregate;
6123
+ const m = Bt(S.entries()), T = y.map((C) => {
6124
+ var E, $, j, x;
6125
+ const O = C["instaql-query"], M = C["instaql-result"], R = ie(O), P = hr(M), G = this.ensureAttrs(), L = tt(G, P, r, this.config.useDateObjects), { store: B, attrsStore: z } = this._applyOptimisticUpdates(L, G, m, _), ee = ($ = (E = M == null ? void 0 : M[0]) == null ? void 0 : E.data) == null ? void 0 : $["page-info"], q = (x = (j = M == null ? void 0 : M[0]) == null ? void 0 : j.data) == null ? void 0 : x.aggregate;
6113
6126
  return {
6114
- q: M,
6115
- hash: F,
6116
- store: N,
6117
- attrsStore: B,
6118
- pageInfo: z,
6119
- aggregate: ee
6127
+ q: O,
6128
+ hash: R,
6129
+ store: B,
6130
+ attrsStore: z,
6131
+ pageInfo: ee,
6132
+ aggregate: q
6120
6133
  };
6121
6134
  });
6122
- _.forEach(({ hash: T, q: M, store: O, attrsStore: F, pageInfo: P, aggregate: C }) => {
6123
- this.querySubs.updateInPlace((G) => {
6124
- if (!G[T]) {
6125
- this._log.error("Missing value in querySubs", { hash: T, q: M });
6135
+ T.forEach(({ hash: C, q: O, store: M, attrsStore: R, pageInfo: P, aggregate: G }) => {
6136
+ this.querySubs.updateInPlace((L) => {
6137
+ if (!L[C]) {
6138
+ this._log.error("Missing value in querySubs", { hash: C, q: O });
6126
6139
  return;
6127
6140
  }
6128
- G[T].result = {
6129
- store: O,
6130
- attrsStore: F,
6141
+ L[C].result = {
6142
+ store: M,
6143
+ attrsStore: R,
6131
6144
  pageInfo: P,
6132
- aggregate: C,
6133
- processedTxId: g
6145
+ aggregate: G,
6146
+ processedTxId: _
6134
6147
  };
6135
6148
  });
6136
- }), this._cleanupPendingMutationsQueries(), _.forEach(({ hash: T }) => {
6137
- this.notifyOne(T);
6149
+ }), this._cleanupPendingMutationsQueries(), T.forEach(({ hash: C }) => {
6150
+ this.notifyOne(C);
6138
6151
  });
6139
6152
  break;
6140
6153
  }
6141
6154
  case "transact-ok": {
6142
- const { "client-event-id": y, "tx-id": b } = t;
6155
+ const { "client-event-id": y, "tx-id": g } = t;
6143
6156
  this._inFlightMutationEventIds.delete(y);
6144
- const m = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(y);
6145
- if (!m)
6157
+ const S = this._rewriteMutations(this.ensureAttrs(), this._pendingMutations()).get(y);
6158
+ if (!S)
6146
6159
  break;
6147
- this._updatePendingMutations((_) => {
6148
- _.set(y, {
6149
- ..._.get(y),
6150
- "tx-id": b,
6160
+ this._updatePendingMutations((T) => {
6161
+ T.set(y, {
6162
+ ...T.get(y),
6163
+ "tx-id": g,
6151
6164
  confirmed: Date.now()
6152
6165
  });
6153
6166
  });
6154
- const S = [];
6155
- for (const _ of m["tx-steps"])
6156
- if (_[0] === "add-attr") {
6157
- const T = _[1];
6158
- S.push(T);
6167
+ const m = [];
6168
+ for (const T of S["tx-steps"])
6169
+ if (T[0] === "add-attr") {
6170
+ const C = T[1];
6171
+ m.push(C);
6159
6172
  }
6160
- if (S.length) {
6161
- const _ = Object.values(this.ensureAttrs().attrs);
6162
- this._setAttrs([..._, ...S]);
6173
+ if (m.length) {
6174
+ const T = Object.values(this.ensureAttrs().attrs);
6175
+ this._setAttrs([...T, ...m]);
6163
6176
  }
6164
6177
  this._finishTransaction("synced", y), this._cleanupPendingMutationsTimeout();
6165
6178
  break;
@@ -6175,8 +6188,8 @@ class wc {
6175
6188
  break;
6176
6189
  }
6177
6190
  case "server-broadcast": {
6178
- const y = t["room-id"], b = t.topic;
6179
- this._trySetRoomConnected(y, !0), this._notifyBroadcastSubs(y, b, t);
6191
+ const y = t["room-id"], g = t.topic;
6192
+ this._trySetRoomConnected(y, !0), this._notifyBroadcastSubs(y, g, t);
6180
6193
  break;
6181
6194
  }
6182
6195
  case "join-room-ok": {
@@ -6193,9 +6206,21 @@ class wc {
6193
6206
  this._trySetRoomConnected(y, !1);
6194
6207
  break;
6195
6208
  }
6209
+ case "app-status-changed": {
6210
+ const y = this._appStatusState.status;
6211
+ if (this._setAppStatus(t.status), t.status === "disabled" && y !== "disabled") {
6212
+ const g = {
6213
+ message: "This app is currently disabled.",
6214
+ hint: { status: "disabled" }
6215
+ };
6216
+ Object.keys(this.queryCbs).forEach((_) => this.notifyQueryError(_, g));
6217
+ }
6218
+ y === "disabled" && t.status !== "disabled" && this._startSocket();
6219
+ break;
6220
+ }
6196
6221
  case "join-room-error":
6197
- const f = t["room-id"], h = this._rooms[f];
6198
- h && (h.error = t.error), this._notifyPresenceSubs(f);
6222
+ const h = t["room-id"], b = this._rooms[h];
6223
+ b && (b.error = t.error), this._notifyPresenceSubs(h);
6199
6224
  break;
6200
6225
  case "error":
6201
6226
  this._handleReceiveError(t);
@@ -6238,7 +6263,7 @@ class wc {
6238
6263
  }
6239
6264
  }
6240
6265
  _handleReceiveError(e) {
6241
- var a, c, u, l, f, h, y, b;
6266
+ var a, c, u, l, f, h, b, y;
6242
6267
  this._log.info("error", e);
6243
6268
  const t = e["client-event-id"];
6244
6269
  this._inFlightMutationEventIds.delete(t);
@@ -6246,27 +6271,27 @@ class wc {
6246
6271
  message: e.message || "Uh-oh, something went wrong. Ping Joe & Stopa."
6247
6272
  };
6248
6273
  if (e.hint && (s.hint = e.hint), e["trace-id"] || (a = e["original-event"]) != null && a["trace-id"]) {
6249
- const m = [e["trace-id"], (c = e["original-event"]) == null ? void 0 : c["trace-id"]].filter(Boolean).join(",");
6250
- s.traceId = m;
6274
+ const _ = [e["trace-id"], (c = e["original-event"]) == null ? void 0 : c["trace-id"]].filter(Boolean).join(",");
6275
+ s.traceId = _;
6251
6276
  }
6252
6277
  if (r) {
6253
6278
  this._handleMutationError("error", t, s);
6254
6279
  return;
6255
6280
  }
6256
6281
  if ((u = e["original-event"]) != null && u.hasOwnProperty("q") && ((l = e["original-event"]) == null ? void 0 : l.op) === "add-query") {
6257
- const g = (f = e["original-event"]) == null ? void 0 : f.q, m = se(g);
6258
- this.notifyQueryError(se(g), s), this.notifyQueryOnceError(g, m, t, s);
6282
+ const g = (f = e["original-event"]) == null ? void 0 : f.q, _ = ie(g);
6283
+ this.notifyQueryError(ie(g), s), this.notifyQueryOnceError(g, _, t, s);
6259
6284
  return;
6260
6285
  }
6261
6286
  if (((h = e["original-event"]) == null ? void 0 : h.op) === "init") {
6262
- if (e.type === "record-not-found" && ((y = e.hint) == null ? void 0 : y["record-type"]) === "app-user") {
6287
+ if (e.type === "record-not-found" && ((b = e.hint) == null ? void 0 : b["record-type"]) === "app-user") {
6263
6288
  this.changeCurrentUser(null);
6264
6289
  return;
6265
6290
  }
6266
- this._setStatus(Te.ERRORED, s), this.notifyAll();
6291
+ this._setStatus(Se.ERRORED, s), this.notifyAll();
6267
6292
  return;
6268
6293
  }
6269
- switch ((b = e["original-event"]) == null ? void 0 : b.op) {
6294
+ switch ((y = e["original-event"]) == null ? void 0 : y.op) {
6270
6295
  case "resync-table": {
6271
6296
  this._syncTable.onResyncError(e);
6272
6297
  return;
@@ -6293,7 +6318,7 @@ class wc {
6293
6318
  i && (i.dfd.reject(s), this._completeQueryOnce(e, t, i.dfd));
6294
6319
  }
6295
6320
  _setAttrs(e) {
6296
- this.attrs = new Re(e.reduce((t, r) => (t[r.id] = r, t), {}), this._linkIndex), this.notifyAttrsSubs();
6321
+ this.attrs = new Me(e.reduce((t, r) => (t[r.id] = r, t), {}), this._linkIndex), this.notifyAttrsSubs();
6297
6322
  }
6298
6323
  _startQuerySub(e, t) {
6299
6324
  const r = J();
@@ -6338,7 +6363,7 @@ class wc {
6338
6363
  */
6339
6364
  subscribeQuery(e, t, r) {
6340
6365
  this.config.disableValidation || br(e, this.config.schema), r && "ruleParams" in r && (e = { $$ruleParams: r.ruleParams, ...e });
6341
- const s = se(e), i = this.getPreviousResult(e);
6366
+ const s = ie(e), i = this.getPreviousResult(e);
6342
6367
  return i && t(i), this.queryCbs[s] = this.queryCbs[s] ?? [], this.queryCbs[s].push({ q: e, cb: t }), this._startQuerySub(e, s), () => {
6343
6368
  this._unsubQuery(e, s, t);
6344
6369
  };
@@ -6350,7 +6375,7 @@ class wc {
6350
6375
  return r.reject(new Error("We can't run `queryOnce`, because the device is offline.")), r.promise;
6351
6376
  if (!this.querySubs)
6352
6377
  return r.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), r.promise;
6353
- const s = se(e), i = this._startQuerySub(e, s);
6378
+ const s = ie(e), i = this._startQuerySub(e, s);
6354
6379
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(() => r.reject(new Error("Query timed out")), ac), r.promise;
6355
6380
  }
6356
6381
  _completeQueryOnce(e, t, r) {
@@ -6389,21 +6414,21 @@ class wc {
6389
6414
  if (!t)
6390
6415
  return /* @__PURE__ */ new Map();
6391
6416
  const s = (l) => {
6392
- const [f, h, y] = l["forward-identity"];
6393
- return ne(e, h, y);
6417
+ const [f, h, b] = l["forward-identity"];
6418
+ return ne(e, h, b);
6394
6419
  }, i = (l) => {
6395
- const [f, h, y] = l["forward-identity"];
6396
- return De(e, h, y);
6420
+ const [f, h, b] = l["forward-identity"];
6421
+ return De(e, h, b);
6397
6422
  }, o = { attrIdMap: {}, refSwapAttrIds: /* @__PURE__ */ new Set() };
6398
6423
  let a = !1;
6399
6424
  const c = (l, f) => {
6400
6425
  const h = [];
6401
- for (const y of l) {
6402
- const [b] = y;
6403
- if (b === "add-attr") {
6404
- const [m, S] = y, _ = s(S);
6405
- if (_ && S.id !== _.id) {
6406
- o.attrIdMap[S.id] = _.id, a = !0;
6426
+ for (const b of l) {
6427
+ const [y] = b;
6428
+ if (y === "add-attr") {
6429
+ const [_, S] = b, m = s(S);
6430
+ if (m && S.id !== m.id) {
6431
+ o.attrIdMap[S.id] = m.id, a = !0;
6407
6432
  continue;
6408
6433
  }
6409
6434
  if (S["value-type"] === "ref") {
@@ -6414,11 +6439,11 @@ class wc {
6414
6439
  }
6415
6440
  }
6416
6441
  }
6417
- if (r && f && r >= f && b === "add-attr" || b === "update-attr" || b === "delete-attr") {
6442
+ if (r && f && r >= f && y === "add-attr" || y === "update-attr" || y === "delete-attr") {
6418
6443
  a = !0;
6419
6444
  continue;
6420
6445
  }
6421
- const g = a ? Bo(o, y) : y;
6446
+ const g = a ? Bo(o, b) : b;
6422
6447
  h.push(g);
6423
6448
  }
6424
6449
  return a ? h : l;
@@ -6449,13 +6474,13 @@ class wc {
6449
6474
  r.push(u);
6450
6475
  }
6451
6476
  if (!t.size && !r.length)
6452
- return this.attrs || new Re({}, this._linkIndex);
6477
+ return this.attrs || new Me({}, this._linkIndex);
6453
6478
  const s = { ...((o = this.attrs) == null ? void 0 : o.attrs) || {} };
6454
6479
  for (const a of r)
6455
6480
  s[a.id] = a;
6456
6481
  for (const a of t)
6457
6482
  delete s[a];
6458
- return new Re(s, this._linkIndex);
6483
+ return new Me(s, this._linkIndex);
6459
6484
  }
6460
6485
  /** Runs instaql on a query and a store */
6461
6486
  dataForQuery(e, t = !0) {
@@ -6471,12 +6496,12 @@ class wc {
6471
6496
  if (l && s === l.querySubVersion && o === l.pendingMutationsVersion)
6472
6497
  return l;
6473
6498
  let f = u.store, h = u.attrsStore;
6474
- const { pageInfo: y, aggregate: b, processedTxId: g } = u, m = this._rewriteMutationsSorted(h, a);
6499
+ const { pageInfo: b, aggregate: y, processedTxId: g } = u, _ = this._rewriteMutationsSorted(h, a);
6475
6500
  if (t) {
6476
- const _ = this._applyOptimisticUpdates(f, h, m, g);
6477
- f = _.store, h = _.attrsStore;
6501
+ const m = this._applyOptimisticUpdates(f, h, _, g);
6502
+ f = m.store, h = m.attrsStore;
6478
6503
  }
6479
- return { data: is({ store: f, attrsStore: h, pageInfo: y, aggregate: b }, c), querySubVersion: s, pendingMutationsVersion: o };
6504
+ return { data: is({ store: f, attrsStore: h, pageInfo: b, aggregate: y }, c), querySubVersion: s, pendingMutationsVersion: o };
6480
6505
  }
6481
6506
  _applyOptimisticUpdates(e, t, r, s) {
6482
6507
  for (const [i, o] of r)
@@ -6513,7 +6538,7 @@ class wc {
6513
6538
  });
6514
6539
  return;
6515
6540
  }
6516
- if (this.status !== Te.AUTHENTICATED) {
6541
+ if (this.status !== Se.AUTHENTICATED) {
6517
6542
  this._finishTransaction("enqueued", e);
6518
6543
  return;
6519
6544
  }
@@ -6571,7 +6596,7 @@ class wc {
6571
6596
  });
6572
6597
  }
6573
6598
  _trySendAuthed(...e) {
6574
- this.status === Te.AUTHENTICATED && this._trySend(...e);
6599
+ this.status === Se.AUTHENTICATED && this._trySend(...e);
6575
6600
  }
6576
6601
  _trySend(e, t, r) {
6577
6602
  if (this._transport.isOpen()) {
@@ -6671,18 +6696,18 @@ class wc {
6671
6696
  this._replaceUrlAfterOAuth();
6672
6697
  try {
6673
6698
  let u;
6674
- const l = await this.kv.waitForKeyToLoad(gt);
6675
- s && l && (u = l[s]), l && this.kv.updateInPlace((b) => {
6676
- delete b[gt];
6699
+ const l = await this.kv.waitForKeyToLoad(_t);
6700
+ s && l && (u = l[s]), l && this.kv.updateInPlace((y) => {
6701
+ delete y[_t];
6677
6702
  });
6678
- const f = await this._getCurrentUser(), h = (f == null ? void 0 : f.type) === "guest", { user: y } = await lr({
6703
+ const f = await this._getCurrentUser(), h = (f == null ? void 0 : f.type) === "guest", { user: b } = await lr({
6679
6704
  apiURI: this.config.apiURI,
6680
6705
  appId: this.config.appId,
6681
6706
  code: r,
6682
6707
  refreshToken: h ? f.refresh_token : void 0,
6683
6708
  extraFields: u
6684
6709
  });
6685
- return this.setCurrentUser(y), null;
6710
+ return this.setCurrentUser(b), null;
6686
6711
  } catch (u) {
6687
6712
  return ((i = u == null ? void 0 : u.body) == null ? void 0 : i.type) === "record-not-found" && ((a = (o = u == null ? void 0 : u.body) == null ? void 0 : o.hint) == null ? void 0 : a["record-type"]) === "app-oauth-code" && await this._hasCurrentUser() ? null : { error: { message: ((c = u == null ? void 0 : u.body) == null ? void 0 : c.message) || "Error logging in." } };
6688
6713
  }
@@ -6701,7 +6726,7 @@ class wc {
6701
6726
  t.isLoading || e(this._currentUserCached);
6702
6727
  let r = !1;
6703
6728
  return this.getCurrentUser().then((s) => {
6704
- r || St(s, t) || e(s);
6729
+ r || vt(s, t) || e(s);
6705
6730
  }), () => {
6706
6731
  r = !0, this.authCbs = this.authCbs.filter((s) => s !== e);
6707
6732
  };
@@ -6709,7 +6734,7 @@ class wc {
6709
6734
  async getAuth() {
6710
6735
  const { user: e, error: t } = await this.getCurrentUser();
6711
6736
  if (t)
6712
- throw new ie("Could not get current user: " + t.message);
6737
+ throw new re("Could not get current user: " + t.message);
6713
6738
  return e ?? null;
6714
6739
  }
6715
6740
  subscribeConnectionStatus(e) {
@@ -6717,6 +6742,21 @@ class wc {
6717
6742
  this.connectionStatusCbs = this.connectionStatusCbs.filter((t) => t !== e);
6718
6743
  };
6719
6744
  }
6745
+ /**
6746
+ * @param {'active' | 'read-only' | 'disabled' | undefined} status
6747
+ */
6748
+ _setAppStatus(e) {
6749
+ !e || e === this._appStatusState.status || (this._appStatusState = {
6750
+ isLoading: !1,
6751
+ isReadOnly: e !== "active",
6752
+ status: e
6753
+ }, this.notifyAppStatusSubs(this._appStatusState));
6754
+ }
6755
+ subscribeAppStatus(e) {
6756
+ return this.appStatusCbs.push(e), e(this._appStatusState), () => {
6757
+ this.appStatusCbs = this.appStatusCbs.filter((t) => t !== e);
6758
+ };
6759
+ }
6720
6760
  subscribeAttrs(e) {
6721
6761
  return this.attrsCbs.push(e), this.attrs && e(this.attrs.attrs), () => {
6722
6762
  this.attrsCbs = this.attrsCbs.filter((t) => t !== e);
@@ -6737,6 +6777,9 @@ class wc {
6737
6777
  notifyConnectionStatusSubs(e) {
6738
6778
  this.connectionStatusCbs.forEach((t) => t(e));
6739
6779
  }
6780
+ notifyAppStatusSubs(e) {
6781
+ this.appStatusCbs.forEach((t) => t(e));
6782
+ }
6740
6783
  async setCurrentUser(e) {
6741
6784
  this.kv.updateInPlace((t) => {
6742
6785
  t[Fe] = e;
@@ -6785,7 +6828,7 @@ class wc {
6785
6828
  async changeCurrentUser(e) {
6786
6829
  var r;
6787
6830
  const { user: t } = await this.getCurrentUser();
6788
- if (!St(t, e)) {
6831
+ if (!vt(t, e)) {
6789
6832
  this._frameworkClient = null, await this.setCurrentUser(e), await this.updateUser(e);
6790
6833
  try {
6791
6834
  await this.kv.flush(), (r = this._broadcastChannel) == null || r.postMessage({ type: "auth" });
@@ -6797,7 +6840,7 @@ class wc {
6797
6840
  async setupUserSyncTimer() {
6798
6841
  if (this.config.firstPartyPath)
6799
6842
  try {
6800
- const e = await this.kv.waitForKeyToLoad(Sr), t = e ? new Date(e).getTime() : 0;
6843
+ const e = await this.kv.waitForKeyToLoad(Tr), t = e ? new Date(e).getTime() : 0;
6801
6844
  if (!(!Number.isFinite(t) || Date.now() - t >= fc))
6802
6845
  return;
6803
6846
  const { user: s } = await this.getCurrentUser();
@@ -6826,7 +6869,7 @@ class wc {
6826
6869
  this._log.error("Error syncing user with external endpoint", t);
6827
6870
  }
6828
6871
  this.kv.updateInPlace((t) => {
6829
- t[Sr] = (/* @__PURE__ */ new Date()).toISOString();
6872
+ t[Tr] = (/* @__PURE__ */ new Date()).toISOString();
6830
6873
  });
6831
6874
  }
6832
6875
  }
@@ -6893,7 +6936,7 @@ class wc {
6893
6936
  this._log.info("[auth-invalidate] skipped invalidateToken");
6894
6937
  return;
6895
6938
  }
6896
- Ma({
6939
+ Ra({
6897
6940
  apiURI: this.config.apiURI,
6898
6941
  appId: this.config.appId,
6899
6942
  refreshToken: r
@@ -6921,8 +6964,8 @@ class wc {
6921
6964
  if (r) {
6922
6965
  const a = `${Math.random().toString(36).slice(2)}`;
6923
6966
  this.kv.updateInPlace((c) => {
6924
- const u = c[gt] || {};
6925
- u[a] = r, c[gt] = u;
6967
+ const u = c[_t] || {};
6968
+ u[a] = r, c[_t] = u;
6926
6969
  }), o = `${t}${t.includes("?") ? "&" : "?"}${Qt}=${a}`;
6927
6970
  }
6928
6971
  return `${s}/runtime/oauth/start?app_id=${i}&client_name=${e}&redirect_uri=${encodeURIComponent(o)}`;
@@ -7126,8 +7169,8 @@ class wc {
7126
7169
  _notifyBroadcastSubs(e, t, r) {
7127
7170
  var s, i, o;
7128
7171
  (o = (i = (s = this._broadcastSubs) == null ? void 0 : s[e]) == null ? void 0 : i[t]) == null || o.forEach((a) => {
7129
- var l, f, h, y, b, g;
7130
- const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (h = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : h.user : (g = (b = (y = this._presence[e]) == null ? void 0 : y.result) == null ? void 0 : b.peers) == null ? void 0 : g[r.data["peer-id"]];
7172
+ var l, f, h, b, y, g;
7173
+ const c = (l = r.data) == null ? void 0 : l.data, u = r.data["peer-id"] === this._sessionId ? (h = (f = this._presence[e]) == null ? void 0 : f.result) == null ? void 0 : h.user : (g = (y = (b = this._presence[e]) == null ? void 0 : b.result) == null ? void 0 : y.peers) == null ? void 0 : g[r.data["peer-id"]];
7131
7174
  return a(c, u);
7132
7175
  });
7133
7176
  }
@@ -7136,7 +7179,7 @@ class wc {
7136
7179
  async uploadFile(e, t, r) {
7137
7180
  var o;
7138
7181
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
7139
- return Ra({
7182
+ return Ma({
7140
7183
  ...r,
7141
7184
  apiURI: this.config.apiURI,
7142
7185
  appId: this.config.appId,
@@ -7178,10 +7221,10 @@ class wc {
7178
7221
  });
7179
7222
  }
7180
7223
  }
7181
- let _t;
7182
- function Tc(n, e) {
7183
- _t == null || _t.dispose();
7184
- const t = kc(e), r = Ac(e, a), s = vc(Sc(n));
7224
+ let mt;
7225
+ function Sc(n, e) {
7226
+ mt == null || mt.dispose();
7227
+ const t = kc(e), r = Ac(e, a), s = vc(Tc(n));
7185
7228
  function i(l) {
7186
7229
  var f;
7187
7230
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && t.isVisible() && a();
@@ -7197,13 +7240,13 @@ function Tc(n, e) {
7197
7240
  t.element.remove(), r.element.remove(), removeEventListener("keydown", o), removeEventListener("message", i);
7198
7241
  }
7199
7242
  function u() {
7200
- document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), _t = {
7243
+ document.body.appendChild(t.element), document.body.appendChild(r.element), addEventListener("keydown", o), addEventListener("message", i), mt = {
7201
7244
  dispose: c
7202
7245
  };
7203
7246
  }
7204
7247
  return u();
7205
7248
  }
7206
- function Sc(n) {
7249
+ function Tc(n) {
7207
7250
  return `${Cn || fs ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
7208
7251
  }
7209
7252
  function vc(n) {
@@ -7305,7 +7348,7 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7305
7348
  };
7306
7349
  }, ws = (n) => n && Object.keys(n).length > 0 ? n : {
7307
7350
  serverCreatedAt: "asc"
7308
- }, Mc = (n, e) => {
7351
+ }, Rc = (n, e) => {
7309
7352
  const t = [
7310
7353
  ...Array.from(e.values()).slice().reverse(),
7311
7354
  ...Array.from(n.values())
@@ -7314,36 +7357,36 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7314
7357
  ...Array.from(n.values()).flatMap((s) => s.data)
7315
7358
  ];
7316
7359
  return { chunks: t, data: r };
7317
- }, Gt = ["bootstrap", "bootstrap", "bootstrap", 1], Rc = (n, e, t, r) => {
7360
+ }, Gt = ["bootstrap", "bootstrap", "bootstrap", 1], Mc = (n, e, t, r) => {
7318
7361
  var B, z, ee, q;
7319
- const { entityName: s, entityQuery: i } = Ts(e), o = ((B = i.$) == null ? void 0 : B.limit) || 10, a = s, c = ws((z = i.$) == null ? void 0 : z.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
7320
- let h = !1, y = !0, b = null, g = null;
7321
- const m = (E) => {
7362
+ const { entityName: s, entityQuery: i } = Ss(e), o = ((B = i.$) == null ? void 0 : B.limit) || 10, a = s, c = ws((z = i.$) == null ? void 0 : z.order), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
7363
+ let h = !1, b = !0, y = null, g = null;
7364
+ const _ = (E) => {
7322
7365
  t({ error: E, data: void 0, canLoadNextPage: !1 });
7323
7366
  }, S = () => {
7324
- if (!y)
7367
+ if (!b)
7325
7368
  return;
7326
- const { chunks: E, data: j } = Mc(u, l);
7369
+ const { chunks: E, data: $ } = Rc(u, l);
7327
7370
  t({
7328
- data: { [a]: j },
7371
+ data: { [a]: $ },
7329
7372
  // @ts-expect-error hidden debug variable
7330
7373
  chunks: E,
7331
7374
  canLoadNextPage: Pc(u)
7332
7375
  });
7333
- }, _ = (E, j) => {
7334
- u.set(rt(E, j.afterInclusive), j), S();
7335
- }, T = (E, j) => {
7336
- l.set(rt(E), j), C(), S();
7337
- }, M = (E, j) => {
7376
+ }, m = (E, $) => {
7377
+ u.set(rt(E, $.afterInclusive), $), S();
7378
+ }, T = (E, $) => {
7379
+ l.set(rt(E), $), P(), S();
7380
+ }, C = (E, $) => {
7338
7381
  var A, k;
7339
- const { cursor: R } = Ar(E), U = f.get(Ne("reverse", R));
7340
- U == null || U();
7341
- const L = n.subscribeQuery({
7382
+ const { cursor: j } = Ar(E), x = f.get(Ne("reverse", j));
7383
+ x == null || x();
7384
+ const N = n.subscribeQuery({
7342
7385
  [a]: {
7343
7386
  ...i,
7344
7387
  $: {
7345
- after: R,
7346
- before: j.endCursor,
7388
+ after: j,
7389
+ before: $.endCursor,
7347
7390
  beforeInclusive: !0,
7348
7391
  where: (A = i.$) == null ? void 0 : A.where,
7349
7392
  fields: (k = i.$) == null ? void 0 : k.fields,
@@ -7352,33 +7395,33 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7352
7395
  }
7353
7396
  }, (K) => {
7354
7397
  if (K.error)
7355
- return m(K.error);
7398
+ return _(K.error);
7356
7399
  const H = K.data[a], Y = K.pageInfo[a];
7357
- Ze(H && Y, "Expected query subscription to contain rows and pageInfo"), T(R, {
7400
+ Ze(H && Y, "Expected query subscription to contain rows and pageInfo"), T(j, {
7358
7401
  data: H,
7359
7402
  status: "frozen",
7360
7403
  hasMore: Y.hasNextPage,
7361
7404
  endCursor: Y.endCursor
7362
7405
  });
7363
7406
  }, r);
7364
- f.set(Ne("reverse", R), L);
7407
+ f.set(Ne("reverse", j), N);
7365
7408
  }, O = (E) => {
7366
- var R, U;
7367
- const j = n.subscribeQuery({
7409
+ var j, x;
7410
+ const $ = n.subscribeQuery({
7368
7411
  [a]: {
7369
7412
  ...i,
7370
7413
  $: {
7371
7414
  limit: o,
7372
7415
  after: E,
7373
- where: (R = i.$) == null ? void 0 : R.where,
7374
- fields: (U = i.$) == null ? void 0 : U.fields,
7416
+ where: (j = i.$) == null ? void 0 : j.where,
7417
+ fields: (x = i.$) == null ? void 0 : x.fields,
7375
7418
  order: Or(c)
7376
7419
  }
7377
7420
  }
7378
- }, (L) => {
7379
- if (L.error)
7380
- return m(L.error);
7381
- const A = L.data[a], k = L.pageInfo[a];
7421
+ }, (N) => {
7422
+ if (N.error)
7423
+ return _(N.error);
7424
+ const A = N.data[a], k = N.pageInfo[a];
7382
7425
  Ze(A && k, "Expected rows and pageInfo"), T(E, {
7383
7426
  data: A,
7384
7427
  status: "bootstrapping",
@@ -7386,48 +7429,48 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7386
7429
  endCursor: k.endCursor
7387
7430
  });
7388
7431
  }, r);
7389
- f.set(Ne("reverse", E), j);
7390
- }, F = (E, j = !1) => {
7391
- var U, L;
7392
- const R = n.subscribeQuery({
7432
+ f.set(Ne("reverse", E), $);
7433
+ }, M = (E, $ = !1) => {
7434
+ var x, N;
7435
+ const j = n.subscribeQuery({
7393
7436
  [a]: {
7394
7437
  ...i,
7395
7438
  $: {
7396
7439
  limit: o,
7397
7440
  after: E,
7398
- afterInclusive: j,
7399
- where: (U = i.$) == null ? void 0 : U.where,
7400
- fields: (L = i.$) == null ? void 0 : L.fields,
7441
+ afterInclusive: $,
7442
+ where: (x = i.$) == null ? void 0 : x.where,
7443
+ fields: (N = i.$) == null ? void 0 : N.fields,
7401
7444
  order: c
7402
7445
  }
7403
7446
  }
7404
7447
  }, (A) => {
7405
7448
  if (A.error)
7406
- return m(A.error);
7449
+ return _(A.error);
7407
7450
  const k = A.data[a], K = A.pageInfo[a];
7408
- Ze(k && K, "Page info and rows"), _(E, {
7451
+ Ze(k && K, "Page info and rows"), m(E, {
7409
7452
  data: k,
7410
7453
  status: "bootstrapping",
7411
7454
  hasMore: K.hasNextPage,
7412
7455
  endCursor: K.endCursor,
7413
- afterInclusive: j
7456
+ afterInclusive: $
7414
7457
  });
7415
7458
  }, r);
7416
- f.set(Ne("forward", E, j), R);
7417
- }, P = (E, j = !1) => {
7459
+ f.set(Ne("forward", E, $), j);
7460
+ }, R = (E, $ = !1) => {
7418
7461
  var k, K;
7419
- const R = rt(E, j), U = f.get(Ne("forward", E, j));
7420
- U == null || U();
7421
- const L = u.get(R);
7422
- if (!(L != null && L.endCursor))
7462
+ const j = rt(E, $), x = f.get(Ne("forward", E, $));
7463
+ x == null || x();
7464
+ const N = u.get(j);
7465
+ if (!(N != null && N.endCursor))
7423
7466
  return;
7424
7467
  const A = n.subscribeQuery({
7425
7468
  [a]: {
7426
7469
  ...i,
7427
7470
  $: {
7428
7471
  after: E,
7429
- afterInclusive: L.afterInclusive,
7430
- before: L.endCursor,
7472
+ afterInclusive: N.afterInclusive,
7473
+ before: N.endCursor,
7431
7474
  beforeInclusive: !0,
7432
7475
  where: (k = i.$) == null ? void 0 : k.where,
7433
7476
  fields: (K = i.$) == null ? void 0 : K.fields,
@@ -7436,35 +7479,35 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7436
7479
  }
7437
7480
  }, (H) => {
7438
7481
  if (H.error)
7439
- return m(H.error);
7482
+ return _(H.error);
7440
7483
  const Y = H.data[a], oe = H.pageInfo[a];
7441
- Ze(Y && oe, "Expected rows and pageInfo"), _(E, {
7484
+ Ze(Y && oe, "Expected rows and pageInfo"), m(E, {
7442
7485
  data: Y,
7443
7486
  status: "frozen",
7444
7487
  hasMore: oe.hasNextPage,
7445
7488
  endCursor: oe.endCursor,
7446
- afterInclusive: L.afterInclusive
7489
+ afterInclusive: N.afterInclusive
7447
7490
  });
7448
7491
  }, r);
7449
- f.set(Ne("forward", E, j), A);
7450
- }, C = () => {
7492
+ f.set(Ne("forward", E, $), A);
7493
+ }, P = () => {
7451
7494
  const E = Array.from(l.entries()).at(-1);
7452
7495
  if (!E)
7453
7496
  return;
7454
- const [j, R] = E;
7455
- if (!(R != null && R.hasMore) || !Ic(R))
7497
+ const [$, j] = E;
7498
+ if (!(j != null && j.hasMore) || !Ic(j))
7456
7499
  return;
7457
- const U = `${j}:${Cc(R.endCursor)}`;
7458
- U != b && (b = U, M(j, R), O(R.endCursor));
7500
+ const x = `${$}:${Cc(j.endCursor)}`;
7501
+ x != y && (y = x, C($, j), O(j.endCursor));
7459
7502
  }, G = () => {
7460
7503
  const E = Array.from(u.entries()).at(-1);
7461
7504
  if (!E)
7462
7505
  return;
7463
- const [j, R] = E;
7464
- if (!R.endCursor)
7506
+ const [$, j] = E;
7507
+ if (!j.endCursor)
7465
7508
  return;
7466
- const { cursor: U, afterInclusive: L } = Ar(j);
7467
- P(U, L), F(R.endCursor);
7509
+ const { cursor: x, afterInclusive: N } = Ar($);
7510
+ R(x, N), M(j.endCursor);
7468
7511
  };
7469
7512
  return g = n.subscribeQuery({
7470
7513
  [a]: {
@@ -7477,32 +7520,32 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7477
7520
  }
7478
7521
  }
7479
7522
  }, async (E) => {
7480
- var L;
7523
+ var N;
7481
7524
  if (h)
7482
7525
  return;
7483
7526
  if (E.error)
7484
- return m(E.error);
7485
- const j = E.pageInfo[a], R = (L = E == null ? void 0 : E.data) == null ? void 0 : L[a];
7486
- if (Ze(R && j, "Expected rows and pageInfo"), R.length < o) {
7487
- _(Gt, {
7488
- data: R,
7527
+ return _(E.error);
7528
+ const $ = E.pageInfo[a], j = (N = E == null ? void 0 : E.data) == null ? void 0 : N[a];
7529
+ if (Ze(j && $, "Expected rows and pageInfo"), j.length < o) {
7530
+ m(Gt, {
7531
+ data: j,
7489
7532
  status: "pre-bootstrap"
7490
7533
  });
7491
7534
  return;
7492
7535
  }
7493
- const U = j.startCursor;
7494
- if (!U) {
7495
- _(Gt, {
7496
- data: R,
7536
+ const x = $.startCursor;
7537
+ if (!x) {
7538
+ m(Gt, {
7539
+ data: j,
7497
7540
  status: "pre-bootstrap"
7498
7541
  });
7499
7542
  return;
7500
7543
  }
7501
- u.delete(rt(Gt)), F(U, !0), O(j.startCursor), h = !0;
7544
+ u.delete(rt(Gt)), M(x, !0), O($.startCursor), h = !0;
7502
7545
  }, r), {
7503
7546
  unsubscribe: () => {
7504
- if (y) {
7505
- y = !1, g == null || g(), g = null;
7547
+ if (b) {
7548
+ b = !1, g == null || g(), g = null;
7506
7549
  for (const E of f.values())
7507
7550
  E == null || E();
7508
7551
  f.clear();
@@ -7518,8 +7561,8 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7518
7561
  data: void 0,
7519
7562
  error: void 0
7520
7563
  };
7521
- const { entityName: r, entityQuery: s } = Ts(e), i = ((u = s.$) == null ? void 0 : u.limit) || 10, o = ws((l = s.$) == null ? void 0 : l.order);
7522
- let a = e ? Ss({
7564
+ const { entityName: r, entityQuery: s } = Ss(e), i = ((u = s.$) == null ? void 0 : u.limit) || 10, o = ws((l = s.$) == null ? void 0 : l.order);
7565
+ let a = e ? Ts({
7523
7566
  [r]: {
7524
7567
  ...s,
7525
7568
  $: {
@@ -7540,7 +7583,7 @@ const Cc = (n) => JSON.stringify(n), rt = (n, e = !1) => JSON.stringify([n, e]),
7540
7583
  data: (c == null ? void 0 : c.data) || void 0,
7541
7584
  error: void 0
7542
7585
  };
7543
- }, Ts = (n) => {
7586
+ }, Ss = (n) => {
7544
7587
  if (Object.keys(n).length !== 1)
7545
7588
  throw new Q("subscribeInfiniteQuery expects exactly one entity");
7546
7589
  const [t, r] = Object.entries(n)[0];
@@ -7763,7 +7806,7 @@ class Lc {
7763
7806
  this.db = e;
7764
7807
  }
7765
7808
  }
7766
- function Ss(n) {
7809
+ function Ts(n) {
7767
7810
  return JSON.parse(JSON.stringify(n));
7768
7811
  }
7769
7812
  class Fc {
@@ -7851,7 +7894,7 @@ class Fc {
7851
7894
  * });
7852
7895
  */
7853
7896
  subscribeInfiniteQuery(e, t, r) {
7854
- return Rc(this, e, t, r);
7897
+ return Mc(this, e, t, r);
7855
7898
  }
7856
7899
  /**
7857
7900
  * Listen for the logged in state. This is useful
@@ -7907,6 +7950,20 @@ class Fc {
7907
7950
  subscribeConnectionStatus(e) {
7908
7951
  return this._reactor.subscribeConnectionStatus(e);
7909
7952
  }
7953
+ /**
7954
+ * Observe the app's maintenance-mode state. While read-only, reads and
7955
+ * live queries keep working but writes are rejected. The callback fires
7956
+ * immediately with the current state and again on every change.
7957
+ *
7958
+ * @example
7959
+ * const unsub = db.subscribeAppStatus(({ isLoading, isReadOnly }) => {
7960
+ * if (isLoading) return;
7961
+ * if (isReadOnly) showMaintenanceBanner();
7962
+ * });
7963
+ */
7964
+ subscribeAppStatus(e) {
7965
+ return this._reactor.subscribeAppStatus(e);
7966
+ }
7910
7967
  /**
7911
7968
  * Join a room to publish and subscribe to topics and presence.
7912
7969
  *
@@ -7975,7 +8032,7 @@ function Cr(n) {
7975
8032
  const e = kr.get(n);
7976
8033
  if (e)
7977
8034
  return e;
7978
- const t = se(n);
8035
+ const t = ie(n);
7979
8036
  return kr.set(n, t), t;
7980
8037
  }
7981
8038
  function Nc(n, e) {
@@ -8005,7 +8062,7 @@ function qc(n, e) {
8005
8062
  allowedHosts: ["localhost"],
8006
8063
  ...typeof e == "object" ? e : {}
8007
8064
  };
8008
- t.allowedHosts.includes(window.location.hostname) && Tc(n, t);
8065
+ t.allowedHosts.includes(window.location.hostname) && Sc(n, t);
8009
8066
  }
8010
8067
  const Ir = {
8011
8068
  isLoading: !0,
@@ -8024,9 +8081,9 @@ function Pr(n) {
8024
8081
  }
8025
8082
  function Wc(n, e, t, r) {
8026
8083
  e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
8027
- const s = e ? Ss(e) : null, i = se(s), o = ke(
8084
+ const s = e ? Ts(e) : null, i = ie(s), o = Oe(
8028
8085
  Pr(n._reactor.getPreviousResult(s))
8029
- ), a = ke(Ir), c = Ae(
8086
+ ), a = Oe(Ir), c = Te(
8030
8087
  (l) => (o.current = Pr(
8031
8088
  n._reactor.getPreviousResult(s)
8032
8089
  ), l(), s ? n.subscribeQuery(s, (h) => {
@@ -8045,7 +8102,7 @@ function Wc(n, e, t, r) {
8045
8102
  // Build a new subscribe function if the query changes
8046
8103
  [i]
8047
8104
  );
8048
- return { state: At(
8105
+ return { state: st(
8049
8106
  c,
8050
8107
  () => o.current,
8051
8108
  () => {
@@ -8068,10 +8125,10 @@ function Vc({
8068
8125
  query: e,
8069
8126
  opts: t
8070
8127
  }) {
8071
- const r = ke(null), s = se(e), i = se(t), o = Er(n, e, t), a = ke({
8128
+ const r = Oe(null), s = ie(e), i = ie(t), o = Er(n, e, t), a = Oe({
8072
8129
  ...o,
8073
8130
  isLoading: !o.data && !o.error
8074
- }), c = Ae(
8131
+ }), c = Te(
8075
8132
  (f) => {
8076
8133
  r.current = null;
8077
8134
  const h = Er(n, e, t);
@@ -8081,24 +8138,24 @@ function Vc({
8081
8138
  }, f(), !e)
8082
8139
  return () => {
8083
8140
  };
8084
- const y = n.subscribeInfiniteQuery(
8141
+ const b = n.subscribeInfiniteQuery(
8085
8142
  e,
8086
- (b) => {
8143
+ (y) => {
8087
8144
  a.current = {
8088
- ...b,
8145
+ ...y,
8089
8146
  isLoading: !1
8090
8147
  }, f();
8091
8148
  },
8092
8149
  t
8093
8150
  );
8094
- return r.current = y, () => {
8095
- y.unsubscribe(), r.current === y && (r.current = null);
8151
+ return r.current = b, () => {
8152
+ b.unsubscribe(), r.current === b && (r.current = null);
8096
8153
  };
8097
8154
  },
8098
8155
  [s, i]
8099
8156
  );
8100
8157
  return {
8101
- ...At(
8158
+ ...st(
8102
8159
  c,
8103
8160
  () => a.current,
8104
8161
  () => zc
@@ -8110,7 +8167,7 @@ function Vc({
8110
8167
  };
8111
8168
  }
8112
8169
  function Qc() {
8113
- const n = ke(null);
8170
+ const n = Oe(null);
8114
8171
  je(() => {
8115
8172
  t();
8116
8173
  }, []);
@@ -8124,7 +8181,7 @@ function Qc() {
8124
8181
  }
8125
8182
  const Bc = 1e3;
8126
8183
  function Gc(n, e, t) {
8127
- const r = ke(t);
8184
+ const r = Oe(t);
8128
8185
  r.current = t, je(() => n.core._reactor.subscribeTopic(
8129
8186
  n.type,
8130
8187
  n.id,
@@ -8135,7 +8192,7 @@ function Gc(n, e, t) {
8135
8192
  ), [n.id, e]);
8136
8193
  }
8137
8194
  function Hc(n, e) {
8138
- return je(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Ae(
8195
+ return je(() => n.core._reactor.joinRoom(n.type, n.id), [n.id]), Te(
8139
8196
  (r) => {
8140
8197
  n.core._reactor.publishTopic({
8141
8198
  roomType: n.type,
@@ -8149,7 +8206,7 @@ function Hc(n, e) {
8149
8206
  }
8150
8207
  function Jc(n, e = {}) {
8151
8208
  var o, a;
8152
- const [t, r] = Rr(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
8209
+ const [t, r] = Mr(() => n.core._reactor.getPresence(n.type, n.id, e) ?? {
8153
8210
  peers: {},
8154
8211
  isLoading: !0
8155
8212
  });
@@ -8161,7 +8218,7 @@ function Jc(n, e = {}) {
8161
8218
  r(u);
8162
8219
  }
8163
8220
  ), [n.id, e.user, (o = e.peers) == null ? void 0 : o.join(), (a = e.keys) == null ? void 0 : a.join()]);
8164
- const s = Ae(
8221
+ const s = Te(
8165
8222
  (c) => {
8166
8223
  n.core._reactor.publishPresence(n.type, n.id, c);
8167
8224
  },
@@ -8189,7 +8246,7 @@ function Zc(n, e, t = {}) {
8189
8246
  return t != null && t.writeOnly ? [] : Object.values((l == null ? void 0 : l.peers) ?? {}).filter(
8190
8247
  (f) => f[e] === !0
8191
8248
  );
8192
- }, [t == null ? void 0 : t.writeOnly, s]), o = Ae(
8249
+ }, [t == null ? void 0 : t.writeOnly, s]), o = Te(
8193
8250
  (l) => {
8194
8251
  n.core._reactor.publishPresence(n.type, n.id, {
8195
8252
  [e]: l
@@ -8200,13 +8257,13 @@ function Zc(n, e, t = {}) {
8200
8257
  }));
8201
8258
  },
8202
8259
  [n.type, n.id, e, t == null ? void 0 : t.timeout, r]
8203
- ), a = Ae(
8260
+ ), a = Te(
8204
8261
  (l) => {
8205
8262
  const h = !((t == null ? void 0 : t.stopOnEnter) && l.key === "Enter");
8206
8263
  o(h);
8207
8264
  },
8208
8265
  [t.stopOnEnter, o]
8209
- ), c = Ae(() => {
8266
+ ), c = Te(() => {
8210
8267
  o(!1);
8211
8268
  }, [o]), u = Jt(() => ({ onKeyDown: a, onBlur: c }), [a, c]);
8212
8269
  return {
@@ -8313,6 +8370,9 @@ const eu = {
8313
8370
  isLoading: !0,
8314
8371
  user: void 0,
8315
8372
  error: void 0
8373
+ }, tu = {
8374
+ isLoading: !0,
8375
+ isReadOnly: void 0
8316
8376
  };
8317
8377
  class Ht {
8318
8378
  constructor(e, t) {
@@ -8345,7 +8405,7 @@ class Ht {
8345
8405
  * console.log('Device ID:', deviceId)
8346
8406
  */
8347
8407
  p(this, "useLocalId", (e) => {
8348
- const [t, r] = Rr(null);
8408
+ const [t, r] = Mr(null);
8349
8409
  return je(() => {
8350
8410
  (async () => {
8351
8411
  const i = await this.getLocalId(e);
@@ -8460,7 +8520,7 @@ class Ht {
8460
8520
  p(this, "useUser", () => {
8461
8521
  const { user: e } = this.useAuth();
8462
8522
  if (!e)
8463
- throw new ie(
8523
+ throw new re(
8464
8524
  "useUser must be used within an auth-protected route"
8465
8525
  );
8466
8526
  return e;
@@ -8488,18 +8548,40 @@ class Ht {
8488
8548
  * }
8489
8549
  */
8490
8550
  p(this, "useConnectionStatus", () => {
8491
- const e = ke(
8551
+ const e = Oe(
8492
8552
  this.core._reactor.status
8493
- ), t = Ae((s) => this.core.subscribeConnectionStatus((o) => {
8553
+ ), t = Te((s) => this.core.subscribeConnectionStatus((o) => {
8494
8554
  o !== e.current && (e.current = o, s());
8495
8555
  }), []);
8496
- return At(
8556
+ return st(
8497
8557
  t,
8498
8558
  () => e.current,
8499
8559
  // For SSR, always return 'connecting' as the initial state
8500
8560
  () => "connecting"
8501
8561
  );
8502
8562
  });
8563
+ /**
8564
+ * Observe the app's maintenance-mode state. While read-only, reads and
8565
+ * live queries keep working but writes are rejected.
8566
+ *
8567
+ * @example
8568
+ * function App() {
8569
+ * const { isLoading, isReadOnly } = db.useAppStatus()
8570
+ * if (isLoading) return null
8571
+ * if (isReadOnly) return <MaintenanceBanner />
8572
+ * // ...
8573
+ * }
8574
+ */
8575
+ p(this, "useAppStatus", () => {
8576
+ const e = Oe(this.core._reactor._appStatusState), t = Te((s) => this.core.subscribeAppStatus((i) => {
8577
+ (i.isLoading !== e.current.isLoading || i.isReadOnly !== e.current.isReadOnly) && (e.current = i, s());
8578
+ }), []);
8579
+ return st(
8580
+ t,
8581
+ () => e.current,
8582
+ () => tu
8583
+ );
8584
+ });
8503
8585
  /**
8504
8586
  * Use this for one-off queries.
8505
8587
  * Returns local data if available, otherwise fetches from the server.
@@ -8554,7 +8636,7 @@ class Ht {
8554
8636
  */
8555
8637
  p(this, "SignedIn", ({ children: e }) => {
8556
8638
  const t = this.useAuth();
8557
- return t.isLoading || t.error || !t.user ? null : /* @__PURE__ */ ht.jsx(ht.Fragment, { children: e });
8639
+ return t.isLoading || t.error || !t.user ? null : /* @__PURE__ */ pt.jsx(pt.Fragment, { children: e });
8558
8640
  });
8559
8641
  /**
8560
8642
  * Only render children if the user is signed out.
@@ -8568,7 +8650,7 @@ class Ht {
8568
8650
  */
8569
8651
  p(this, "SignedOut", ({ children: e }) => {
8570
8652
  const t = this.useAuth();
8571
- return t.isLoading || t.error || t.user ? null : /* @__PURE__ */ ht.jsx(ht.Fragment, { children: e });
8653
+ return t.isLoading || t.error || t.user ? null : /* @__PURE__ */ pt.jsx(pt.Fragment, { children: e });
8572
8654
  });
8573
8655
  this.core = Kc(
8574
8656
  e,
@@ -8597,12 +8679,12 @@ class Ht {
8597
8679
  return new Xc(this.core, e, t);
8598
8680
  }
8599
8681
  _useAuth() {
8600
- const e = ke(
8682
+ const e = Oe(
8601
8683
  this.core._reactor._currentUserCached
8602
- ), t = Ae((s) => this.core.subscribeAuth((o) => {
8684
+ ), t = Te((s) => this.core.subscribeAuth((o) => {
8603
8685
  e.current = { isLoading: !1, ...o }, s();
8604
8686
  }), []);
8605
- return At(
8687
+ return st(
8606
8688
  t,
8607
8689
  () => e.current,
8608
8690
  () => eu