@instantdb/core 0.22.133 → 0.22.134

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,6 +1,6 @@
1
- var Jn = Object.defineProperty;
2
- var Yn = (n, e, t) => e in n ? Jn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var p = (n, e, t) => Yn(n, typeof e != "symbol" ? e + "" : e, t);
1
+ var Yn = Object.defineProperty;
2
+ var Zn = (n, e, t) => e in n ? Yn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var p = (n, e, t) => Zn(n, typeof e != "symbol" ? e + "" : e, t);
4
4
  function C(n) {
5
5
  if (typeof n == "number")
6
6
  return (Math.abs(n * 2654435761) >>> 0).toString(16);
@@ -40,7 +40,7 @@ const I = {
40
40
  Remove: "remove",
41
41
  Replace: "replace",
42
42
  Add: "add"
43
- }, rn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Zn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ae = Symbol.iterator, F = {
43
+ }, rn = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Xn = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Ae = Symbol.iterator, F = {
44
44
  mutable: "mutable",
45
45
  immutable: "immutable"
46
46
  }, ct = {};
@@ -99,7 +99,7 @@ function sn(n, e = []) {
99
99
  return sn(n.parent, e);
100
100
  e.reverse();
101
101
  try {
102
- Xn(n.copy, e);
102
+ er(n.copy, e);
103
103
  } catch {
104
104
  return null;
105
105
  }
@@ -132,7 +132,7 @@ function J(n, e) {
132
132
  return r.indexOf("/") === -1 && r.indexOf("~") === -1 ? r : r.replace(/~/g, "~0").replace(/\//g, "~1");
133
133
  }).join("/");
134
134
  }
135
- function Xn(n, e) {
135
+ function er(n, e) {
136
136
  for (let t = 0; t < e.length - 1; t += 1) {
137
137
  const r = e[t];
138
138
  if (n = B(Z(n) === 3 ? Array.from(n) : n, r), typeof n != "object")
@@ -140,7 +140,7 @@ function Xn(n, e) {
140
140
  }
141
141
  return n;
142
142
  }
143
- function er(n) {
143
+ function tr(n) {
144
144
  const e = Object.create(Object.getPrototypeOf(n));
145
145
  return Reflect.ownKeys(n).forEach((t) => {
146
146
  let r = Reflect.getOwnPropertyDescriptor(n, t);
@@ -156,7 +156,7 @@ function er(n) {
156
156
  }), Reflect.defineProperty(e, t, r);
157
157
  }), e;
158
158
  }
159
- const tr = Object.prototype.propertyIsEnumerable;
159
+ const nr = Object.prototype.propertyIsEnumerable;
160
160
  function on(n, e) {
161
161
  let t;
162
162
  if (Array.isArray(n))
@@ -175,7 +175,7 @@ function on(n, e) {
175
175
  return new Map(n);
176
176
  } else if (e != null && e.mark && (t = e.mark(n, F), t !== void 0) && t !== F.mutable) {
177
177
  if (t === F.immutable)
178
- return er(n);
178
+ return tr(n);
179
179
  if (typeof t == "function") {
180
180
  if (e.enablePatches || e.enableAutoFreeze)
181
181
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -187,7 +187,7 @@ function on(n, e) {
187
187
  return Object.keys(n).forEach((s) => {
188
188
  r[s] = n[s];
189
189
  }), Object.getOwnPropertySymbols(n).forEach((s) => {
190
- tr.call(n, s) && (r[s] = n[s]);
190
+ nr.call(n, s) && (r[s] = n[s]);
191
191
  }), r;
192
192
  } else
193
193
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
@@ -313,7 +313,7 @@ function an(n, e, t) {
313
313
  });
314
314
  }
315
315
  }
316
- function nr(n, e) {
316
+ function rr(n, e) {
317
317
  const t = n.type === 3 ? n.setMap : n.copy;
318
318
  n.finalities.revoke.length > 1 && n.assignedMap.get(e) && t && an(B(t, e), n.finalities.handledSet, n.options);
319
319
  }
@@ -342,10 +342,10 @@ function ht(n, e, t, r) {
342
342
  }
343
343
  }), n.options.enableAutoFreeze && s.finalities !== n.finalities && (n.options.enableAutoFreeze = !1)), z(t, n.options) && n.finalities.draft.push(() => {
344
344
  const i = n.type === 3 ? n.setMap : n.copy;
345
- G(B(i, e), t) && nr(n, e);
345
+ G(B(i, e), t) && rr(n, e);
346
346
  });
347
347
  }
348
- function rr(n, e, t, r, s) {
348
+ function sr(n, e, t, r, s) {
349
349
  let { original: i, assignedMap: o, options: a } = n, c = n.copy;
350
350
  c.length < i.length && ([i, c] = [c, i], [t, r] = [r, t]);
351
351
  for (let u = 0; u < i.length; u += 1)
@@ -391,7 +391,7 @@ function rr(n, e, t, r, s) {
391
391
  }
392
392
  }
393
393
  }
394
- function sr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
394
+ function ir({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
395
395
  t.forEach((a, c) => {
396
396
  const u = B(n, c), l = Oe(B(e, c)), d = a ? de(n, c) ? I.Replace : I.Add : I.Remove;
397
397
  if (G(u, l) && d === I.Replace)
@@ -400,7 +400,7 @@ function sr({ original: n, copy: e, assignedMap: t }, r, s, i, o) {
400
400
  s.push(d === I.Remove ? { op: d, path: h } : { op: d, path: h, value: l }), i.push(d === I.Add ? { op: I.Remove, path: h } : d === I.Remove ? { op: I.Add, path: h, value: u } : { op: I.Replace, path: h, value: u });
401
401
  });
402
402
  }
403
- function ir({ original: n, copy: e }, t, r, s, i) {
403
+ function or({ original: n, copy: e }, t, r, s, i) {
404
404
  let o = 0;
405
405
  n.forEach((a) => {
406
406
  if (!e.has(a)) {
@@ -437,11 +437,11 @@ function pe(n, e, t, r) {
437
437
  switch (n.type) {
438
438
  case 0:
439
439
  case 2:
440
- return sr(n, e, t, r, s);
440
+ return ir(n, e, t, r, s);
441
441
  case 1:
442
- return rr(n, e, t, r, s);
442
+ return sr(n, e, t, r, s);
443
443
  case 3:
444
- return ir(n, e, t, r, s);
444
+ return or(n, e, t, r, s);
445
445
  }
446
446
  }
447
447
  const Ee = (n, e, t = !1) => {
@@ -528,7 +528,7 @@ const Ee = (n, e, t = !1) => {
528
528
  [Ae]() {
529
529
  return this.entries();
530
530
  }
531
- }, or = Reflect.ownKeys(Ge), Et = (n, e, { isValuesIterator: t }) => () => {
531
+ }, ar = Reflect.ownKeys(Ge), Et = (n, e, { isValuesIterator: t }) => () => {
532
532
  var r, s;
533
533
  const i = e.next();
534
534
  if (i.done)
@@ -639,7 +639,7 @@ Set.prototype.difference && Object.assign(Ie, {
639
639
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), n);
640
640
  }
641
641
  });
642
- const ar = Reflect.ownKeys(Ie), cn = /* @__PURE__ */ new WeakSet(), un = {
642
+ const cr = Reflect.ownKeys(Ie), cn = /* @__PURE__ */ new WeakSet(), un = {
643
643
  get(n, e, t) {
644
644
  var r, s;
645
645
  const i = (r = n.copy) === null || r === void 0 ? void 0 : r[e];
@@ -654,14 +654,14 @@ const ar = Reflect.ownKeys(Ie), cn = /* @__PURE__ */ new WeakSet(), un = {
654
654
  return n.options.strict && Ee(u, n.options, !0), u;
655
655
  }
656
656
  const a = N(n);
657
- if (a instanceof Map && or.includes(e)) {
657
+ if (a instanceof Map && ar.includes(e)) {
658
658
  if (e === "size")
659
659
  return Object.getOwnPropertyDescriptor(Ge, "size").get.call(n.proxy);
660
660
  const u = Ge[e];
661
661
  if (u)
662
662
  return u.bind(n.proxy);
663
663
  }
664
- if (a instanceof Set && ar.includes(e)) {
664
+ if (a instanceof Set && cr.includes(e)) {
665
665
  if (e === "size")
666
666
  return Object.getOwnPropertyDescriptor(Ie, "size").get.call(n.proxy);
667
667
  const u = Ie[e];
@@ -774,7 +774,7 @@ function pt(n) {
774
774
  return c;
775
775
  }
776
776
  ct.createDraft = pt;
777
- function cr(n, e, t, r, s) {
777
+ function ur(n, e, t, r, s) {
778
778
  var i;
779
779
  const o = S(n), a = (i = o == null ? void 0 : o.original) !== null && i !== void 0 ? i : n, c = !!e.length;
780
780
  if (o != null && o.operated)
@@ -787,7 +787,7 @@ function cr(n, e, t, r, s) {
787
787
  r && c ? [{ op: I.Replace, path: [], value: a }] : r
788
788
  ];
789
789
  }
790
- function ur(n, e) {
790
+ function lr(n, e) {
791
791
  var t;
792
792
  const r = {
793
793
  draft: [],
@@ -805,7 +805,7 @@ function ur(n, e) {
805
805
  return [
806
806
  a,
807
807
  (c = []) => {
808
- const [u, l, d] = cr(a, c, s, i, e.enableAutoFreeze);
808
+ const [u, l, d] = ur(a, c, s, i, e.enableAutoFreeze);
809
809
  return e.enablePatches ? [u, l, d] : u;
810
810
  }
811
811
  ];
@@ -862,7 +862,7 @@ function It(n) {
862
862
  throw new Error(`current() is only used for Draft, parameter: ${n}`);
863
863
  return ln(n);
864
864
  }
865
- const lr = (n) => function e(t, r, s) {
865
+ const dr = (n) => function e(t, r, s) {
866
866
  var i, o, a;
867
867
  if (typeof t == "function" && typeof r != "function")
868
868
  return function(m, ...O) {
@@ -889,7 +889,7 @@ const lr = (n) => function e(t, r, s) {
889
889
  };
890
890
  if (!z(d, _) && typeof d == "object" && d !== null)
891
891
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
892
- const [w, b] = ur(d, _);
892
+ const [w, b] = lr(d, _);
893
893
  if (typeof r != "function") {
894
894
  if (!z(d, _))
895
895
  throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
@@ -906,7 +906,7 @@ const lr = (n) => function e(t, r, s) {
906
906
  if (!Y(m)) {
907
907
  if (m !== void 0 && !G(m, w) && (O != null && O.operated))
908
908
  throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
909
- const L = m == null ? void 0 : m[Zn];
909
+ const L = m == null ? void 0 : m[Xn];
910
910
  if (L) {
911
911
  const ee = L[0];
912
912
  return _.strict && typeof m == "object" && m !== null && Be({
@@ -931,7 +931,7 @@ const lr = (n) => function e(t, r, s) {
931
931
  return T instanceof Promise ? T.then(A, (m) => {
932
932
  throw Ve(S(w)), m;
933
933
  }) : A(T);
934
- }, Me = lr();
934
+ }, Me = dr();
935
935
  Object.prototype.constructor.toString();
936
936
  function dn(n, e) {
937
937
  const t = Object.keys(n), r = Object.keys(e);
@@ -973,7 +973,7 @@ function fn(n, e) {
973
973
  function ue(n) {
974
974
  return typeof n == "object" && n !== null && !Array.isArray(n);
975
975
  }
976
- function dr(n, e, t) {
976
+ function fr(n, e, t) {
977
977
  if (!n || e.length === 0)
978
978
  return;
979
979
  let r = n || {};
@@ -1003,13 +1003,13 @@ function hn(n, e) {
1003
1003
  Array.isArray(n) ? n.splice(t, 1) : delete n[t];
1004
1004
  return;
1005
1005
  }
1006
- hn(n[t], r), fr(n[t]) && delete n[t];
1006
+ hn(n[t], r), hr(n[t]) && delete n[t];
1007
1007
  }
1008
1008
  }
1009
- function fr(n) {
1009
+ function hr(n) {
1010
1010
  return n && Object.keys(n).length === 0;
1011
1011
  }
1012
- const Pt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, hr = {
1012
+ const Pt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|WAST|WAKT|WADT|VUT|VOLT|VLAT|VLAST|VET|UZT|UZST|UYT|UYST|UTC|UT|ULAT|ULAST|UCT|TVT|TRUT|TOT|TMT|TKT|TJT|TFT|TAHT|SGT|SCT|SAST|SADT|RET|PYT|PYST|PWT|PST|PONT|PMST|PMDT|PKT|PKST|PHT|PGT|PETT|PETST|PET|PDT|OMST|OMSST|NZT|NZST|NZDT|NUT|NST|NPT|NOVT|NOVST|NFT|NDT|MYT|MVT|MUT|MUST|MST|MSK|MSD|MPT|MMT|MHT|MEZ|METDST|MET|MESZ|MEST|MDT|MAWT|MART|MAGT|MAGST|LKT|LINT|LIGT|LHST|LHDT|KST|KRAT|KRAST|KOST|KGT|KGST|KDT|JST|JAYT|IST|IRT|IRKT|IRKST|IOT|IDT|ICT|HST|HKT|GYT|GMT|GILT|GFT|GET|GEST|GAMT|GALT|FNT|FNST|FKT|FKST|FJT|FJST|FET|EST|EGT|EGST|EETDST|EET|EEST|EDT|EAT|EAST|EASST|DDUT|DAVT|CXT|CST|COT|CLT|CLST|CKT|CHUT|CHAST|CHADT|CETDST|CET|CEST|CDT|CCT|CAST|CADT|BTT|BST|BRT|BRST|BRA|BOT|BORT|BNT|BDT|BDST|AZT|AZST|AZOT|AZOST|AWST|AWSST|AST|ART|ARST|ANAT|ANAST|AMT|AMST|ALMT|ALMST|AKST|AKDT|AFT|AEST|AESST|AEDT|ADT|ACWST|ACT|ACST|ACSST|ACDT$/, pr = {
1013
1013
  ZULU: 0,
1014
1014
  YEKT: 18e3,
1015
1015
  YEKST: 21600,
@@ -1205,32 +1205,32 @@ const Pt = /ZULU|YEKT|YEKST|YAPT|YAKT|YAKST|XJT|WGT|WGST|WFT|WETDST|WET|WDT|WAT|
1205
1205
  ACSST: 37800,
1206
1206
  ACDT: 37800
1207
1207
  };
1208
- function pr(n) {
1208
+ function yr(n) {
1209
1209
  return new Date(n);
1210
1210
  }
1211
- function yr(n) {
1211
+ function br(n) {
1212
1212
  return /* @__PURE__ */ new Date(n + "Z");
1213
1213
  }
1214
- const br = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1215
- function gr(n) {
1216
- const e = n.match(br);
1214
+ const gr = /^(\d+)[\./-](\d+)[\./-](\d+)$/;
1215
+ function _r(n) {
1216
+ const e = n.match(gr);
1217
1217
  if (!e)
1218
1218
  return null;
1219
1219
  const [t, r, s, i] = e;
1220
1220
  return r <= 0 || s <= 0 || i <= 0 ? null : r > 999 ? new Date(Date.UTC(r, s - 1, i, 0, 0, 0, 0)) : new Date(Date.UTC(i, r - 1, s, 0, 0, 0, 0));
1221
1221
  }
1222
- function _r(n) {
1222
+ function wr(n) {
1223
1223
  const [e, t] = n.split(" ");
1224
1224
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1225
1225
  }
1226
- function wr(n) {
1226
+ function Tr(n) {
1227
1227
  const [e, t] = n.split(" ");
1228
1228
  return /* @__PURE__ */ new Date(e + "T" + t + "Z");
1229
1229
  }
1230
- function Tr(n) {
1230
+ function mr(n) {
1231
1231
  return new Date(n);
1232
1232
  }
1233
- function mr(n) {
1233
+ function Sr(n) {
1234
1234
  const e = /^(\w{3}) (\w{3}) (\d{2}) (\d{4})$/;
1235
1235
  if (!n.match(e))
1236
1236
  throw new Error(`Unable to parse \`${n}\` as a date.`);
@@ -1247,7 +1247,7 @@ function mr(n) {
1247
1247
  )
1248
1248
  );
1249
1249
  }
1250
- function Sr(n) {
1250
+ function Ar(n) {
1251
1251
  const e = /^(.+T.+)([+-])(\d{2})$/, t = n.match(e);
1252
1252
  if (t) {
1253
1253
  const [, r, s, i] = t, o = `${r}${s}${i}:00`;
@@ -1255,7 +1255,7 @@ function Sr(n) {
1255
1255
  }
1256
1256
  return null;
1257
1257
  }
1258
- function Ar(n) {
1258
+ function Or(n) {
1259
1259
  const e = /^(\d+)-(\d{1,2})-(\d{1,2})([ T])(.+)$/, t = n.match(e);
1260
1260
  if (t) {
1261
1261
  const [, r, s, i, o, a] = t, c = s.padStart(2, "0"), u = i.padStart(2, "0"), l = `${r}-${c}-${u}T${a}`;
@@ -1263,14 +1263,14 @@ function Ar(n) {
1263
1263
  }
1264
1264
  return null;
1265
1265
  }
1266
- function Or(n) {
1266
+ function vr(n) {
1267
1267
  const [e, t] = n.split(", "), [r, s, i] = e.split("/").map(Number), o = t.match(/(\d{1,2}):(\d{2}):(\d{2}) (AM|PM)/);
1268
1268
  if (!o)
1269
1269
  throw new Error(`Unable to parse time from: ${n}`);
1270
1270
  let [, a, c, u, l] = o;
1271
1271
  return a = Number(a), c = Number(c), u = Number(u), l === "PM" && a !== 12 ? a += 12 : l === "AM" && a === 12 && (a = 0), new Date(Date.UTC(i, r - 1, s, a, c, u));
1272
1272
  }
1273
- function vr(n) {
1273
+ function kr(n) {
1274
1274
  switch (n) {
1275
1275
  case "epoch":
1276
1276
  return /* @__PURE__ */ new Date(0);
@@ -1282,28 +1282,28 @@ function vr(n) {
1282
1282
  return null;
1283
1283
  }
1284
1284
  }
1285
- function kr(n) {
1285
+ function Er(n) {
1286
1286
  const e = n.match(Pt);
1287
1287
  if (!e)
1288
1288
  return null;
1289
- const [t] = e, r = hr[t], s = new Date(n.replace(Pt, "Z"));
1289
+ const [t] = e, r = pr[t], s = new Date(n.replace(Pt, "Z"));
1290
1290
  return new Date(s.getTime() - r * 1e3);
1291
1291
  }
1292
- const Er = [
1293
- gr,
1294
- wr,
1295
- mr,
1296
- Or,
1292
+ const Ir = [
1293
+ _r,
1297
1294
  Tr,
1298
- yr,
1299
1295
  Sr,
1300
- _r,
1301
- pr,
1302
1296
  vr,
1297
+ mr,
1298
+ br,
1299
+ Ar,
1300
+ wr,
1301
+ yr,
1303
1302
  kr,
1304
- Ar
1303
+ Er,
1304
+ Or
1305
1305
  ];
1306
- function Ir(n, e) {
1306
+ function Mr(n, e) {
1307
1307
  try {
1308
1308
  const t = n(e);
1309
1309
  return t instanceof Date && !isNaN(t.getTime()) ? t : null;
@@ -1312,14 +1312,14 @@ function Ir(n, e) {
1312
1312
  }
1313
1313
  }
1314
1314
  function He(n) {
1315
- for (const e of Er) {
1316
- const t = Ir(e, n);
1315
+ for (const e of Ir) {
1316
+ const t = Mr(e, n);
1317
1317
  if (t)
1318
1318
  return t;
1319
1319
  }
1320
1320
  return null;
1321
1321
  }
1322
- function Mr(n) {
1322
+ function Cr(n) {
1323
1323
  try {
1324
1324
  const e = JSON.parse(n);
1325
1325
  return typeof e == "string" ? He(e) : null;
@@ -1334,7 +1334,7 @@ function je(n) {
1334
1334
  if (n instanceof Date)
1335
1335
  return n;
1336
1336
  if (typeof n == "string") {
1337
- const e = He(n) || Mr(n) || He(n.trim());
1337
+ const e = He(n) || Cr(n) || He(n.trim());
1338
1338
  if (!e)
1339
1339
  throw new Error(`Unable to parse \`${n}\` as a date.`);
1340
1340
  return e;
@@ -1420,7 +1420,7 @@ class H {
1420
1420
  return { attrs: this.attrs, linkIndex: this.linkIndex };
1421
1421
  }
1422
1422
  }
1423
- function Cr(n) {
1423
+ function Pr(n) {
1424
1424
  return n.cardinality === "one";
1425
1425
  }
1426
1426
  function bt(n) {
@@ -1486,7 +1486,7 @@ function gn(n, e) {
1486
1486
  if (e && "__type" in e)
1487
1487
  return new H(e.attrs, e.linkIndex);
1488
1488
  }
1489
- function Pr(n, e) {
1489
+ function jr(n, e) {
1490
1490
  return oe(n.eav, [e]) !== void 0;
1491
1491
  }
1492
1492
  function ne(n, e, t, r) {
@@ -1531,12 +1531,12 @@ function _n(n, e, t) {
1531
1531
  const [s, i, o] = r, a = e.getAttr(i);
1532
1532
  a && (q(n.eav, [s, i, o]), q(n.aev, [i, s, o]), bt(a) && q(n.vae, [o, i, s]));
1533
1533
  }
1534
- let jr = 0;
1534
+ let $r = 0;
1535
1535
  function wn(n, e, t) {
1536
1536
  const [r, s, i] = t;
1537
1537
  let o;
1538
1538
  const a = oe(n.eav, [r, s, i]);
1539
- return a && (o = a[3]), o || Date.now() * 10 + jr++;
1539
+ return a && (o = a[3]), o || Date.now() * 10 + $r++;
1540
1540
  }
1541
1541
  function Tn(n, e, t) {
1542
1542
  const r = ge(n, t);
@@ -1548,9 +1548,9 @@ function Tn(n, e, t) {
1548
1548
  return;
1549
1549
  a["checked-data-type"] === "date" && n.useDateObjects && (o = je(o));
1550
1550
  const c = oe(n.eav, [s, i, o]), u = (c == null ? void 0 : c[3]) ?? wn(n, a, r), l = [s, i, o, u];
1551
- Cr(a) ? (R(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), R(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (R(n.eav, [s, i, o], l), R(n.aev, [i, s, o], l)), bt(a) && R(n.vae, [o, i, s], l);
1551
+ Pr(a) ? (R(n.eav, [s, i], /* @__PURE__ */ new Map([[o, l]])), R(n.aev, [i, s], /* @__PURE__ */ new Map([[o, l]]))) : (R(n.eav, [s, i, o], l), R(n.aev, [i, s, o], l)), bt(a) && R(n.vae, [o, i, s], l);
1552
1552
  }
1553
- function $r(n, e, t) {
1553
+ function Dr(n, e, t) {
1554
1554
  var h;
1555
1555
  const r = ge(n, t);
1556
1556
  if (!r)
@@ -1610,28 +1610,28 @@ function mn(n, e, t) {
1610
1610
  n[s] = r[s];
1611
1611
  });
1612
1612
  }
1613
- function Dr(n, [e]) {
1613
+ function Rr(n, [e]) {
1614
1614
  n.addAttr(e);
1615
1615
  }
1616
1616
  function Sn(n) {
1617
1617
  return x(n.eav, 3);
1618
1618
  }
1619
- function Rr(n, e, [t]) {
1619
+ function xr(n, e, [t]) {
1620
1620
  if (!e.getAttr(t)) return;
1621
1621
  const r = Sn(n).filter(([s, i]) => i !== t);
1622
1622
  e.deleteAttr(t), mn(n, e, r);
1623
1623
  }
1624
- function xr(n, e, [t]) {
1624
+ function Ur(n, e, [t]) {
1625
1625
  e.getAttr(t.id) && (e.updateAttr(t), mn(n, e, Sn(n)));
1626
1626
  }
1627
- function Ur(n, e, t) {
1627
+ function Lr(n, e, t) {
1628
1628
  const [r, ...s] = t;
1629
1629
  switch (r) {
1630
1630
  case "add-triple":
1631
1631
  Tn(n, e, s);
1632
1632
  break;
1633
1633
  case "deep-merge-triple":
1634
- $r(n, e, s);
1634
+ Dr(n, e, s);
1635
1635
  break;
1636
1636
  case "retract-triple":
1637
1637
  _n(n, e, s);
@@ -1640,13 +1640,13 @@ function Ur(n, e, t) {
1640
1640
  Je(n, e, s);
1641
1641
  break;
1642
1642
  case "add-attr":
1643
- Dr(e, s);
1643
+ Rr(e, s);
1644
1644
  break;
1645
1645
  case "delete-attr":
1646
- Rr(n, e, s);
1646
+ xr(n, e, s);
1647
1647
  break;
1648
1648
  case "update-attr":
1649
- xr(n, e, s);
1649
+ Ur(n, e, s);
1650
1650
  break;
1651
1651
  case "restore-attr":
1652
1652
  break;
@@ -1701,13 +1701,13 @@ function _e(n, e, t) {
1701
1701
  }
1702
1702
  return r;
1703
1703
  }
1704
- function Lr(n, e, t) {
1704
+ function Nr(n, e, t) {
1705
1705
  let r = "";
1706
1706
  return n !== void 0 && (r += "e"), e !== void 0 && (r += "a"), t !== void 0 && (r += "v"), r;
1707
1707
  }
1708
- function Nr(n, [e, t, r]) {
1708
+ function Fr(n, [e, t, r]) {
1709
1709
  var i, o;
1710
- switch (Lr(e, t, r)) {
1710
+ switch (Nr(e, t, r)) {
1711
1711
  case "e": {
1712
1712
  const a = n.eav.get(e);
1713
1713
  return x(a, 2);
@@ -1753,7 +1753,7 @@ function Nr(n, [e, t, r]) {
1753
1753
  return x(n.eav, 3);
1754
1754
  }
1755
1755
  }
1756
- function Fr(n, e, t) {
1756
+ function Kr(n, e, t) {
1757
1757
  var s;
1758
1758
  const r = {};
1759
1759
  if (!e)
@@ -1773,7 +1773,7 @@ function X(n, e, t) {
1773
1773
  var r;
1774
1774
  return (r = n.revIdents.get(e)) == null ? void 0 : r.get(t);
1775
1775
  }
1776
- function Kr(n, e) {
1776
+ function qr(n, e) {
1777
1777
  return n.blobAttrs.get(e);
1778
1778
  }
1779
1779
  function An(n, e) {
@@ -1781,7 +1781,7 @@ function An(n, e) {
1781
1781
  const t = n.primaryKeys.get(e);
1782
1782
  return t || ((r = n.forwardIdents.get(e)) == null ? void 0 : r.get("id"));
1783
1783
  }
1784
- function qr(n, e, t) {
1784
+ function zr(n, e, t) {
1785
1785
  const r = ge(n, t);
1786
1786
  if (!r)
1787
1787
  return;
@@ -1789,7 +1789,7 @@ function qr(n, e, t) {
1789
1789
  if (e.getAttr(i))
1790
1790
  return oe(n.eav, [s, i]);
1791
1791
  }
1792
- function zr(n, e, t) {
1792
+ function Vr(n, e, t) {
1793
1793
  const r = t.filter(
1794
1794
  ([s, i, o, a, c]) => {
1795
1795
  if (s !== "add-triple" && s !== "deep-merge-triple")
@@ -1804,7 +1804,7 @@ function zr(n, e, t) {
1804
1804
  e,
1805
1805
  d["forward-identity"][1]
1806
1806
  );
1807
- l = !!qr(n, e, [
1807
+ l = !!zr(n, e, [
1808
1808
  i,
1809
1809
  f == null ? void 0 : f.id,
1810
1810
  i
@@ -1817,7 +1817,7 @@ function zr(n, e, t) {
1817
1817
  { store: n, attrsStore: e },
1818
1818
  (s) => {
1819
1819
  r.forEach((i) => {
1820
- Ur(s.store, s.attrsStore, i);
1820
+ Lr(s.store, s.attrsStore, i);
1821
1821
  });
1822
1822
  },
1823
1823
  {
@@ -1828,10 +1828,10 @@ function zr(n, e, t) {
1828
1828
  }
1829
1829
  );
1830
1830
  }
1831
- function Vr(n) {
1831
+ function Qr(n) {
1832
1832
  return typeof n == "string" && n.startsWith("?");
1833
1833
  }
1834
- function Qr(n, e, t) {
1834
+ function Wr(n, e, t) {
1835
1835
  if (t.hasOwnProperty(n)) {
1836
1836
  const r = t[n];
1837
1837
  return On(r, e, t);
@@ -1841,15 +1841,15 @@ function Qr(n, e, t) {
1841
1841
  function jt(n, e, t) {
1842
1842
  return n === e ? t : null;
1843
1843
  }
1844
- function Wr(n) {
1844
+ function Gr(n) {
1845
1845
  switch (typeof n) {
1846
1846
  case "string":
1847
- return n.startsWith("?") ? Qr : jt;
1847
+ return n.startsWith("?") ? Wr : jt;
1848
1848
  default:
1849
1849
  return jt;
1850
1850
  }
1851
1851
  }
1852
- const Gr = [
1852
+ const Br = [
1853
1853
  "in",
1854
1854
  "$in",
1855
1855
  "$not",
@@ -1857,69 +1857,69 @@ const Gr = [
1857
1857
  "$comparator"
1858
1858
  // covers all of $gt, $lt, etc.
1859
1859
  ];
1860
- function Br(n) {
1861
- for (const e of Gr)
1860
+ function Hr(n) {
1861
+ for (const e of Br)
1862
1862
  if (n.hasOwnProperty(e))
1863
1863
  return !0;
1864
1864
  return !1;
1865
1865
  }
1866
1866
  function On(n, e, t) {
1867
- return t ? typeof n == "object" ? Br(n) ? t : null : Wr(n)(n, e, t) : null;
1867
+ return t ? typeof n == "object" ? Hr(n) ? t : null : Gr(n)(n, e, t) : null;
1868
1868
  }
1869
- function Hr(n, e, t) {
1869
+ function Jr(n, e, t) {
1870
1870
  return n.reduce((r, s, i) => {
1871
1871
  const o = e[i];
1872
1872
  return On(s, o, r);
1873
1873
  }, t);
1874
1874
  }
1875
- function Jr(n, e, t) {
1876
- return Xr(n, e, t).map((r) => Hr(e, r, t)).filter((r) => r);
1877
- }
1878
1875
  function Yr(n, e, t) {
1879
- return e.or ? e.or.patterns.flatMap((r) => Ye(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => Ye(n, s, r), t) : t.flatMap((r) => Jr(n, e, r));
1876
+ return es(n, e, t).map((r) => Jr(e, r, t)).filter((r) => r);
1877
+ }
1878
+ function Zr(n, e, t) {
1879
+ return e.or ? e.or.patterns.flatMap((r) => Ye(n, r, t)) : e.and ? e.and.patterns.reduce((r, s) => Ye(n, s, r), t) : t.flatMap((r) => Yr(n, e, r));
1880
1880
  }
1881
1881
  function Ye(n, e, t = [{}]) {
1882
- return e.reduce((r, s) => Yr(n, s, r), t);
1882
+ return e.reduce((r, s) => Zr(n, s, r), t);
1883
1883
  }
1884
1884
  function _t(n, e) {
1885
- return Array.isArray(e) ? e.map((t) => _t(n, t)) : Vr(e) ? n[e] : e;
1885
+ return Array.isArray(e) ? e.map((t) => _t(n, t)) : Qr(e) ? n[e] : e;
1886
1886
  }
1887
- function Zr(n, { find: e, where: t }) {
1887
+ function Xr(n, { find: e, where: t }) {
1888
1888
  return Ye(n, t).map((s) => _t(s, e));
1889
1889
  }
1890
- function Xr(n, e, t) {
1891
- return Nr(n, _t(t, e));
1890
+ function es(n, e, t) {
1891
+ return Fr(n, _t(t, e));
1892
1892
  }
1893
- const es = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1893
+ const ts = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
1894
1894
  function se(n) {
1895
- return typeof n == "string" && es.test(n);
1895
+ return typeof n == "string" && ts.test(n);
1896
1896
  }
1897
1897
  const j = [];
1898
1898
  for (let n = 0; n < 256; ++n)
1899
1899
  j.push((n + 256).toString(16).slice(1));
1900
- function ts(n, e = 0) {
1900
+ function ns(n, e = 0) {
1901
1901
  return (j[n[e + 0]] + j[n[e + 1]] + j[n[e + 2]] + j[n[e + 3]] + "-" + j[n[e + 4]] + j[n[e + 5]] + "-" + j[n[e + 6]] + j[n[e + 7]] + "-" + j[n[e + 8]] + j[n[e + 9]] + "-" + j[n[e + 10]] + j[n[e + 11]] + j[n[e + 12]] + j[n[e + 13]] + j[n[e + 14]] + j[n[e + 15]]).toLowerCase();
1902
1902
  }
1903
1903
  let Le;
1904
- const ns = new Uint8Array(16);
1905
- function rs() {
1904
+ const rs = new Uint8Array(16);
1905
+ function ss() {
1906
1906
  if (!Le) {
1907
1907
  if (typeof crypto > "u" || !crypto.getRandomValues)
1908
1908
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1909
1909
  Le = crypto.getRandomValues.bind(crypto);
1910
1910
  }
1911
- return Le(ns);
1911
+ return Le(rs);
1912
1912
  }
1913
- const ss = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), $t = { randomUUID: ss };
1914
- function is(n, e, t) {
1913
+ const is = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), $t = { randomUUID: is };
1914
+ function os(n, e, t) {
1915
1915
  var s;
1916
1916
  if ($t.randomUUID && !n)
1917
1917
  return $t.randomUUID();
1918
1918
  n = n || {};
1919
- const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? rs();
1919
+ const r = n.random ?? ((s = n.rng) == null ? void 0 : s.call(n)) ?? ss();
1920
1920
  if (r.length < 16)
1921
1921
  throw new Error("Random bytes length must be >= 16");
1922
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, ts(r);
1922
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, ns(r);
1923
1923
  }
1924
1924
  function Dt(n) {
1925
1925
  const e = n.replace(/-/g, ""), t = [];
@@ -1927,24 +1927,24 @@ function Dt(n) {
1927
1927
  t.push(parseInt(e.substring(r, r + 2), 16));
1928
1928
  return t;
1929
1929
  }
1930
- function os(n, e) {
1930
+ function as(n, e) {
1931
1931
  for (let t = 0; t < n.length; t++) {
1932
1932
  if (n[t] < e[t]) return -1;
1933
1933
  if (n[t] > e[t]) return 1;
1934
1934
  }
1935
1935
  return 0;
1936
1936
  }
1937
- function as(n, e) {
1938
- return os(Dt(n), Dt(e));
1937
+ function cs(n, e) {
1938
+ return as(Dt(n), Dt(e));
1939
1939
  }
1940
1940
  function P() {
1941
- return is();
1941
+ return os();
1942
1942
  }
1943
- function cs(n, e) {
1943
+ function us(n, e) {
1944
1944
  return n.localeCompare(e);
1945
1945
  }
1946
- function us() {
1947
- let n = cs;
1946
+ function ls() {
1947
+ let n = us;
1948
1948
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1949
1949
  try {
1950
1950
  n = Intl.Collator("en-US").compare;
@@ -1952,10 +1952,14 @@ function us() {
1952
1952
  }
1953
1953
  return n;
1954
1954
  }
1955
- const ls = us();
1956
- let ds = 0;
1955
+ const ds = ls();
1956
+ let vn = !0;
1957
+ const zo = (n) => {
1958
+ vn = n;
1959
+ };
1960
+ let fs = 0;
1957
1961
  function fe(n) {
1958
- return $e(`_${n}`, ds++);
1962
+ return $e(`_${n}`, fs++);
1959
1963
  }
1960
1964
  function $e(n, e) {
1961
1965
  return `?${n}-${e}`;
@@ -1965,27 +1969,27 @@ class ie extends Error {
1965
1969
  super(e), this.name = "AttrNotFoundError";
1966
1970
  }
1967
1971
  }
1968
- function fs(n, e) {
1972
+ function hs(n, e) {
1969
1973
  const t = An(n, e);
1970
1974
  if (!t)
1971
1975
  throw new ie(`Could not find id attr for ${e}`);
1972
1976
  return t;
1973
1977
  }
1974
1978
  function Rt(n, e, t, r) {
1975
- return [hs(n, e, t, r)];
1979
+ return [ps(n, e, t, r)];
1976
1980
  }
1977
- function hs(n, e, t, r) {
1981
+ function ps(n, e, t, r) {
1978
1982
  return [
1979
1983
  n(t, r),
1980
- fs(e, t).id,
1984
+ hs(e, t).id,
1981
1985
  n(t, r),
1982
1986
  n("time", r)
1983
1987
  ];
1984
1988
  }
1985
- function ps(n, e, t) {
1989
+ function ys(n, e, t) {
1986
1990
  return n.map((r) => r === e ? t : r);
1987
1991
  }
1988
- function vn(n, e, t, r, s) {
1992
+ function kn(n, e, t, r, s) {
1989
1993
  const i = M(e, t, s), o = X(e, t, s), a = i || o;
1990
1994
  if (!a)
1991
1995
  throw new ie(`Could not find attr for ${[t, s]}`);
@@ -2017,7 +2021,7 @@ function xt(n, e) {
2017
2021
  return typeof o != "string" ? !1 : s.test(o);
2018
2022
  };
2019
2023
  }
2020
- function ys(n, e) {
2024
+ function bs(n, e) {
2021
2025
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2022
2026
  return e;
2023
2027
  const t = n["checked-data-type"] === "date";
@@ -2077,7 +2081,7 @@ function ys(n, e) {
2077
2081
  }
2078
2082
  return e;
2079
2083
  }
2080
- function bs(n, e, t, r, s, i) {
2084
+ function gs(n, e, t, r, s, i) {
2081
2085
  const o = M(e, t, s), a = X(
2082
2086
  e,
2083
2087
  t,
@@ -2103,14 +2107,14 @@ function bs(n, e, t, r, s, i) {
2103
2107
  return o ? [
2104
2108
  n(t, r),
2105
2109
  c.id,
2106
- ys(c, i),
2110
+ bs(c, i),
2107
2111
  fe("time")
2108
2112
  ] : [i, c.id, n(t, r), fe("time")];
2109
2113
  }
2110
- function gs(n, e, t, r, s) {
2114
+ function _s(n, e, t, r, s) {
2111
2115
  const [i, o, a] = s.reduce(
2112
2116
  (c, u) => {
2113
- const [l, d, f] = c, [h, y, g] = vn(
2117
+ const [l, d, f] = c, [h, y, g] = kn(
2114
2118
  n,
2115
2119
  e,
2116
2120
  l,
@@ -2124,13 +2128,13 @@ function gs(n, e, t, r, s) {
2124
2128
  return [i, o, a];
2125
2129
  }
2126
2130
  function Ze(n, e, t, r, s, i) {
2127
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = gs(
2131
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = _s(
2128
2132
  n,
2129
2133
  e,
2130
2134
  t,
2131
2135
  r,
2132
2136
  o
2133
- ), d = bs(
2137
+ ), d = gs(
2134
2138
  n,
2135
2139
  e,
2136
2140
  c,
@@ -2140,16 +2144,16 @@ function Ze(n, e, t, r, s, i) {
2140
2144
  );
2141
2145
  return l.concat([d]);
2142
2146
  }
2143
- function _s(n, e) {
2147
+ function ws(n, e) {
2144
2148
  return e ? [e].concat(n) : n;
2145
2149
  }
2146
- function ws([n, e]) {
2150
+ function Ts([n, e]) {
2147
2151
  return n === "or" && Array.isArray(e);
2148
2152
  }
2149
- function Ts([n, e]) {
2153
+ function ms([n, e]) {
2150
2154
  return n === "and" && Array.isArray(e);
2151
2155
  }
2152
- function ms(n, e, t) {
2156
+ function Ss(n, e, t) {
2153
2157
  return (r, s) => {
2154
2158
  const i = n(r, s);
2155
2159
  return e == i ? i : `${i}-${t}`;
@@ -2157,29 +2161,29 @@ function ms(n, e, t) {
2157
2161
  }
2158
2162
  function Ut(n, e, t, r, s, i) {
2159
2163
  const o = n(r, s), a = i.map((c, u) => {
2160
- const l = ms(n, o, u);
2161
- return kn(l, t, r, s, c);
2164
+ const l = Ss(n, o, u);
2165
+ return En(l, t, r, s, c);
2162
2166
  });
2163
2167
  return { [e]: { patterns: a, joinSym: o } };
2164
2168
  }
2165
- function Ss(n) {
2169
+ function As(n) {
2166
2170
  const e = [];
2167
2171
  for (let t = 1; t <= n.length; t++)
2168
2172
  e.push(n.slice(0, t));
2169
2173
  return e;
2170
2174
  }
2171
2175
  function Lt(n, e, t, r, s) {
2172
- return Ss(s).map(
2176
+ return As(s).map(
2173
2177
  (i) => Ze(n, e, t, r, i, {
2174
2178
  $isNull: !0
2175
2179
  })
2176
2180
  );
2177
2181
  }
2178
- function kn(n, e, t, r, s) {
2182
+ function En(n, e, t, r, s) {
2179
2183
  return Object.entries(s).flatMap(([i, o]) => {
2180
- if (ws([i, o]))
2181
- return Ut(n, "or", e, t, r, o);
2182
2184
  if (Ts([i, o]))
2185
+ return Ut(n, "or", e, t, r, o);
2186
+ if (ms([i, o]))
2183
2187
  return Ut(n, "and", e, t, r, o);
2184
2188
  if (i === "$entityIdStartsWith")
2185
2189
  return [];
@@ -2224,38 +2228,38 @@ function kn(n, e, t, r, s) {
2224
2228
  ] : Ze(n, e, t, r, a, o);
2225
2229
  });
2226
2230
  }
2227
- function As(n, e, t, r) {
2231
+ function Os(n, e, t, r) {
2228
2232
  const s = $e;
2229
- return r ? kn(s, n, e, t, r).concat(Rt(s, n, e, t)) : Rt(s, n, e, t);
2233
+ return r ? En(s, n, e, t, r).concat(Rt(s, n, e, t)) : Rt(s, n, e, t);
2230
2234
  }
2231
- function Os(n, e, t) {
2235
+ function vs(n, e, t) {
2232
2236
  return [n(e, t), n("time", t)];
2233
2237
  }
2234
- function vs(n, e, t, r, s, i) {
2235
- const [o, a, c, u, l] = vn(
2238
+ function ks(n, e, t, r, s, i) {
2239
+ const [o, a, c, u, l] = kn(
2236
2240
  n,
2237
2241
  e,
2238
2242
  t,
2239
2243
  r,
2240
2244
  s
2241
- ), d = ps(c, n(t, r), i);
2245
+ ), d = ys(c, n(t, r), i);
2242
2246
  return [o, a, d, u, l];
2243
2247
  }
2244
- function ks(n, e, t, { etype: r, level: s, form: i }, o) {
2248
+ function Es(n, e, t, { etype: r, level: s, form: i }, o) {
2245
2249
  const a = Object.keys(i).filter((c) => c !== "$");
2246
2250
  return a.length ? Object.entries(o).map(function([u, l]) {
2247
2251
  return a.map(function(h) {
2248
2252
  var g, _, w;
2249
2253
  const y = !!(e.cardinalityInference && ((w = (_ = (g = t.linkIndex) == null ? void 0 : g[r]) == null ? void 0 : _[h]) != null && w.isSingular));
2250
2254
  try {
2251
- const [b, T, A] = vs(
2255
+ const [b, T, A] = ks(
2252
2256
  n,
2253
2257
  t,
2254
2258
  r,
2255
2259
  s,
2256
2260
  h,
2257
2261
  u
2258
- ), m = In(e, t, {
2262
+ ), m = Mn(e, t, {
2259
2263
  etype: b,
2260
2264
  level: T,
2261
2265
  form: i[h],
@@ -2272,11 +2276,11 @@ function ks(n, e, t, { etype: r, level: s, form: i }, o) {
2272
2276
  }, l);
2273
2277
  }) : Object.values(o);
2274
2278
  }
2275
- function Es(n, e, t) {
2276
- return t === "string" ? ls(n, e) : n > e ? 1 : -1;
2279
+ function Is(n, e, t) {
2280
+ return t === "string" ? ds(n, e) : n > e ? 1 : -1;
2277
2281
  }
2278
2282
  function le(n, e, t, r, s) {
2279
- return e === r || e == null && r == null ? as(n, t) : r == null ? 1 : e == null ? -1 : Es(e, r, s);
2283
+ return e === r || e == null && r == null ? cs(n, t) : r == null ? 1 : e == null ? -1 : Is(e, r, s);
2280
2284
  }
2281
2285
  function Ce([n, e], [t, r], s) {
2282
2286
  return le(n, e, t, r, s);
@@ -2284,7 +2288,7 @@ function Ce([n, e], [t, r], s) {
2284
2288
  function Xe(n) {
2285
2289
  return n == null ? n : new Date(n).getTime();
2286
2290
  }
2287
- function Is(n, e, t, r) {
2291
+ function Ms(n, e, t, r) {
2288
2292
  var y;
2289
2293
  const [s, i, o, a] = n, c = t === "desc" ? 1 : -1;
2290
2294
  if (((y = e["forward-identity"]) == null ? void 0 : y[2]) === "id")
@@ -2292,24 +2296,24 @@ function Is(n, e, t, r) {
2292
2296
  const [u, l] = r, d = e["checked-data-type"], f = d === "date" ? Xe(l) : l, h = d === "date" ? Xe(o) : o;
2293
2297
  return Ce([u, f], [s, h], d) === c;
2294
2298
  }
2295
- function Ms(n, e) {
2299
+ function Cs(n, e) {
2296
2300
  const t = e[1];
2297
2301
  return n.getAttr(t);
2298
2302
  }
2299
- function Cs(n, e, t) {
2303
+ function Ps(n, e, t) {
2300
2304
  const r = Object.keys(t)[0];
2301
2305
  return M(n, e, r);
2302
2306
  }
2303
- function Ps(n, e, t, r) {
2307
+ function js(n, e, t, r) {
2304
2308
  if (t)
2305
- return Ms(n, t);
2309
+ return Cs(n, t);
2306
2310
  if (r)
2307
- return Cs(n, e, r);
2311
+ return Ps(n, e, r);
2308
2312
  }
2309
- function js(n, e, t) {
2313
+ function $s(n, e, t) {
2310
2314
  var s, i;
2311
2315
  if (!Array.isArray(t.fields))
2312
- return Kr(n, e);
2316
+ return qr(n, e);
2313
2317
  const r = /* @__PURE__ */ new Map();
2314
2318
  for (const o of t.fields) {
2315
2319
  const a = M(n, e, o), c = (s = a == null ? void 0 : a["forward-identity"]) == null ? void 0 : s[2];
@@ -2321,11 +2325,11 @@ function js(n, e, t) {
2321
2325
  }
2322
2326
  return r;
2323
2327
  }
2324
- function $s(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2328
+ function Ds(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2325
2329
  var y, g;
2326
- const o = (y = i == null ? void 0 : i.$) == null ? void 0 : y.order, a = En(i), c = Ds(i);
2327
- let u = Zr(n, s);
2328
- const l = r == null ? void 0 : r["start-cursor"], d = Ps(e, t, l, o);
2330
+ const o = (y = i == null ? void 0 : i.$) == null ? void 0 : y.order, a = In(i), c = Rs(i);
2331
+ let u = Xr(n, s);
2332
+ const l = r == null ? void 0 : r["start-cursor"], d = js(e, t, l, o);
2329
2333
  if (d && ((g = d == null ? void 0 : d["forward-identity"]) == null ? void 0 : g[2]) !== "id") {
2330
2334
  const _ = d["checked-data-type"] === "date", w = d.id;
2331
2335
  u = u.map(([b]) => {
@@ -2342,41 +2346,41 @@ function $s(n, e, { etype: t, pageInfo: r, dq: s, form: i }) {
2342
2346
  }
2343
2347
  );
2344
2348
  let f = {};
2345
- const h = js(e, t, s);
2349
+ const h = $s(e, t, s);
2346
2350
  for (const _ of u) {
2347
2351
  const [w] = _;
2348
- if (f[w] || !a && l && d && Is(l, d, c, _))
2352
+ if (f[w] || !a && l && d && Ms(l, d, c, _))
2349
2353
  continue;
2350
- const b = Fr(n, h, w);
2354
+ const b = Kr(n, h, w);
2351
2355
  b && (f[w] = b);
2352
2356
  }
2353
2357
  return f;
2354
2358
  }
2355
- function Ds(n) {
2359
+ function Rs(n) {
2356
2360
  var t;
2357
2361
  const e = (t = n.$) == null ? void 0 : t.order;
2358
2362
  return e && e[Object.keys(e)[0]] || "asc";
2359
2363
  }
2360
- function En(n) {
2364
+ function In(n) {
2361
2365
  var s, i, o;
2362
2366
  const e = (s = n.$) == null ? void 0 : s.offset, t = (i = n.$) == null ? void 0 : i.before, r = (o = n.$) == null ? void 0 : o.after;
2363
2367
  return !e && !t && !r;
2364
2368
  }
2365
- function Rs(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2369
+ function xs(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2366
2370
  var f, h, y, g, _;
2367
- if (!En(s) && (!o || !o["start-cursor"]))
2371
+ if (!In(s) && (!o || !o["start-cursor"]))
2368
2372
  return [];
2369
- const a = _s(
2370
- As(e, t, r, (f = s.$) == null ? void 0 : f.where),
2373
+ const a = ws(
2374
+ Os(e, t, r, (f = s.$) == null ? void 0 : f.where),
2371
2375
  i
2372
- ), c = Os($e, t, r), u = (h = s.$) == null ? void 0 : h.fields, l = $s(n, e, {
2376
+ ), c = vs($e, t, r), u = (h = s.$) == null ? void 0 : h.fields, l = Ds(n, e, {
2373
2377
  etype: t,
2374
2378
  pageInfo: o,
2375
2379
  form: s,
2376
2380
  dq: { where: a, find: c, fields: u }
2377
2381
  }), d = ((y = s.$) == null ? void 0 : y.limit) || ((g = s.$) == null ? void 0 : g.first) || ((_ = s.$) == null ? void 0 : _.last);
2378
2382
  if (d != null) {
2379
- r > 0 && console.warn(
2383
+ r > 0 && vn && console.warn(
2380
2384
  "WARNING: Limits in child queries are only run client-side. Data returned from the server will not have a limit."
2381
2385
  );
2382
2386
  const w = Object.entries(l);
@@ -2384,20 +2388,20 @@ function Rs(n, e, { etype: t, level: r, form: s, join: i, pageInfo: o }) {
2384
2388
  }
2385
2389
  return l;
2386
2390
  }
2387
- function xs(n, e, t) {
2391
+ function Us(n, e, t) {
2388
2392
  try {
2389
- return Rs(n, e, t);
2393
+ return xs(n, e, t);
2390
2394
  } catch (r) {
2391
2395
  if (r instanceof ie)
2392
2396
  return {};
2393
2397
  throw r;
2394
2398
  }
2395
2399
  }
2396
- function In(n, e, t) {
2397
- const r = xs(n, e, t);
2398
- return ks($e, n, e, t, r);
2400
+ function Mn(n, e, t) {
2401
+ const r = Us(n, e, t);
2402
+ return Es($e, n, e, t, r);
2399
2403
  }
2400
- function Us(n) {
2404
+ function Ls(n) {
2401
2405
  const e = {};
2402
2406
  for (const [t, r] of Object.entries(n))
2403
2407
  e[t] = {
@@ -2415,16 +2419,16 @@ function wt({
2415
2419
  aggregate: r
2416
2420
  }, s) {
2417
2421
  const o = { data: Object.keys(s).reduce(function(c, u) {
2418
- return r != null && r[u] || u === "$$ruleParams" || (c[u] = In(n, e, {
2422
+ return r != null && r[u] || u === "$$ruleParams" || (c[u] = Mn(n, e, {
2419
2423
  etype: u,
2420
2424
  form: s[u],
2421
2425
  level: 0,
2422
2426
  pageInfo: t == null ? void 0 : t[u]
2423
2427
  })), c;
2424
2428
  }, {}) };
2425
- return t && (o.pageInfo = Us(t)), r && (o.aggregate = r), o;
2429
+ return t && (o.pageInfo = Ls(t)), r && (o.aggregate = r), o;
2426
2430
  }
2427
- function Ls() {
2431
+ function Ns() {
2428
2432
  const e = {
2429
2433
  __etype: 1,
2430
2434
  __ops: 1,
@@ -2438,7 +2442,7 @@ function Ls() {
2438
2442
  };
2439
2443
  return new Set(Object.keys(e));
2440
2444
  }
2441
- const Ns = Ls();
2445
+ const Fs = Ns();
2442
2446
  function ke(n, e, t) {
2443
2447
  const r = {
2444
2448
  __etype: n,
@@ -2448,7 +2452,7 @@ function ke(n, e, t) {
2448
2452
  get: (s, i) => {
2449
2453
  if (i === "__ops") return t;
2450
2454
  if (i === "__etype") return n;
2451
- if (Ns.has(i))
2455
+ if (Fs.has(i))
2452
2456
  return (o, a) => ke(n, e, [
2453
2457
  ...t,
2454
2458
  a ? [i, n, e, o, a] : [i, n, e, o]
@@ -2456,7 +2460,7 @@ function ke(n, e, t) {
2456
2460
  }
2457
2461
  });
2458
2462
  }
2459
- function Fs(n, e) {
2463
+ function Ks(n, e) {
2460
2464
  return `lookup__${n}__${JSON.stringify(e)}`;
2461
2465
  }
2462
2466
  function Pe(n) {
@@ -2466,7 +2470,7 @@ function et(n) {
2466
2470
  const [e, t, ...r] = n.split("__");
2467
2471
  return [t, JSON.parse(r.join("__"))];
2468
2472
  }
2469
- function Ks(n) {
2473
+ function qs(n) {
2470
2474
  return new Proxy(
2471
2475
  {
2472
2476
  __etype: n
@@ -2474,7 +2478,7 @@ function Ks(n) {
2474
2478
  {
2475
2479
  get(e, t) {
2476
2480
  if (t === "lookup")
2477
- return (s, i) => ke(n, et(Fs(s, i)), []);
2481
+ return (s, i) => ke(n, et(Ks(s, i)), []);
2478
2482
  if (t === "__etype") return n;
2479
2483
  const r = t;
2480
2484
  return Pe(r) ? ke(n, et(r), []) : ke(n, r, []);
@@ -2482,21 +2486,21 @@ function Ks(n) {
2482
2486
  }
2483
2487
  );
2484
2488
  }
2485
- function Mn() {
2489
+ function Cn() {
2486
2490
  return new Proxy(
2487
2491
  {},
2488
2492
  {
2489
2493
  get(n, e) {
2490
- return Ks(e);
2494
+ return qs(e);
2491
2495
  }
2492
2496
  }
2493
2497
  );
2494
2498
  }
2495
- const qo = Mn();
2496
- function qs(n) {
2499
+ const Vo = Cn();
2500
+ function zs(n) {
2497
2501
  return n.__ops;
2498
2502
  }
2499
- function zs(n, e) {
2503
+ function Vs(n, e) {
2500
2504
  const { attrIdMap: t, refSwapAttrIds: r } = n, s = [];
2501
2505
  for (const o of e) {
2502
2506
  const a = t[o];
@@ -2515,7 +2519,7 @@ function zs(n, e) {
2515
2519
  }
2516
2520
  return s;
2517
2521
  }
2518
- function Vs(n) {
2522
+ function Qs(n) {
2519
2523
  if (Array.isArray(n))
2520
2524
  return n;
2521
2525
  const e = Object.entries(n);
@@ -2525,7 +2529,7 @@ function Vs(n) {
2525
2529
  );
2526
2530
  return e[0];
2527
2531
  }
2528
- function Qs(n, e, t) {
2532
+ function Ws(n, e, t) {
2529
2533
  return t.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2530
2534
  // before assuming it's a ref lookup.
2531
2535
  !M(n, e, t);
@@ -2536,8 +2540,8 @@ function tt(n) {
2536
2540
  throw new Error(`${n} is not a valid lookup attribute.`);
2537
2541
  return e;
2538
2542
  }
2539
- function Ws(n, e, t) {
2540
- if (!Qs(n, e, t))
2543
+ function Gs(n, e, t) {
2544
+ if (!Ws(n, e, t))
2541
2545
  return M(n, e, t);
2542
2546
  const r = tt(t), s = M(n, e, r) || X(n, e, r);
2543
2547
  if (s && s["value-type"] !== "ref")
@@ -2545,18 +2549,18 @@ function Ws(n, e, t) {
2545
2549
  return s;
2546
2550
  }
2547
2551
  function nt(n) {
2548
- return typeof n == "string" && !Pe(n) ? null : typeof n == "string" && Pe(n) ? et(n) : Vs(n);
2552
+ return typeof n == "string" && !Pe(n) ? null : typeof n == "string" && Pe(n) ? et(n) : Qs(n);
2549
2553
  }
2550
2554
  function U(n, e, t) {
2551
2555
  const r = nt(t);
2552
2556
  if (r === null)
2553
2557
  return t;
2554
- const [s, i] = r, o = Ws(n, e, s);
2558
+ const [s, i] = r, o = Gs(n, e, s);
2555
2559
  if (!o || !o["unique?"])
2556
2560
  throw new Error(`${s} is not a unique attribute.`);
2557
2561
  return [o.id, i];
2558
2562
  }
2559
- function Cn(n, e, t, r) {
2563
+ function Pn(n, e, t, r) {
2560
2564
  var o;
2561
2565
  const s = U(n, e, t);
2562
2566
  return Array.isArray(s) ? [[
@@ -2566,7 +2570,7 @@ function Cn(n, e, t, r) {
2566
2570
  s
2567
2571
  ]].concat(r) : r;
2568
2572
  }
2569
- function Gs({ attrsStore: n }, [e, t, r]) {
2573
+ function Bs({ attrsStore: n }, [e, t, r]) {
2570
2574
  const s = Object.entries(r).flatMap(([i, o]) => {
2571
2575
  const a = Array.isArray(o) ? o : [o], c = M(n, e, i), u = X(n, e, i);
2572
2576
  return a.map((l) => c ? [
@@ -2585,9 +2589,9 @@ function Gs({ attrsStore: n }, [e, t, r]) {
2585
2589
  U(n, e, t)
2586
2590
  ]);
2587
2591
  });
2588
- return Cn(n, e, t, s);
2592
+ return Pn(n, e, t, s);
2589
2593
  }
2590
- function Bs({ attrsStore: n }, [e, t, r]) {
2594
+ function Hs({ attrsStore: n }, [e, t, r]) {
2591
2595
  const s = Object.entries(r).flatMap(([i, o]) => {
2592
2596
  const a = Array.isArray(o) ? o : [o], c = M(n, e, i), u = X(n, e, i);
2593
2597
  return a.map((l) => c ? [
@@ -2606,9 +2610,9 @@ function Bs({ attrsStore: n }, [e, t, r]) {
2606
2610
  U(n, e, t)
2607
2611
  ]);
2608
2612
  });
2609
- return Cn(n, e, t, s);
2613
+ return Pn(n, e, t, s);
2610
2614
  }
2611
- function Hs(n, e, t, r) {
2615
+ function Js(n, e, t, r) {
2612
2616
  var s;
2613
2617
  if (Array.isArray(r)) {
2614
2618
  const [i, o] = r;
@@ -2631,18 +2635,18 @@ function Hs(n, e, t, r) {
2631
2635
  }
2632
2636
  return !1;
2633
2637
  }
2634
- function Pn({ stores: n, attrsStore: e }, [t, r, s, i]) {
2635
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Hs(n, e, t, r) ? { mode: "update" } : null;
2638
+ function jn({ stores: n, attrsStore: e }, [t, r, s, i]) {
2639
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Js(n, e, t, r) ? { mode: "update" } : null;
2636
2640
  }
2637
- function Js(n, e) {
2641
+ function Ys(n, e) {
2638
2642
  const { attrsStore: t } = n, [r, s, i, o] = e, a = yt(i), c = U(t, r, s);
2639
2643
  return [["id", c]].concat(Object.entries(a)).map(([l, d]) => {
2640
2644
  const f = M(t, r, l);
2641
2645
  return f["checked-data-type"] === "date" && n.useDateObjects && (d = je(d)), ["add-triple", c, f.id, d, { mode: "create" }];
2642
2646
  });
2643
2647
  }
2644
- function Ys(n, e) {
2645
- const { attrsStore: t } = n, [r, s, i, o] = e, a = yt(i), c = U(t, r, s), u = Pn(n, [r, c, i, o]);
2648
+ function Zs(n, e) {
2649
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = yt(i), c = U(t, r, s), u = jn(n, [r, c, i, o]);
2646
2650
  return [["id", c]].concat(Object.entries(a)).map(([d, f]) => {
2647
2651
  const h = M(t, r, d);
2648
2652
  return h["checked-data-type"] === "date" && n.useDateObjects && (f = je(f)), [
@@ -2654,11 +2658,11 @@ function Ys(n, e) {
2654
2658
  ];
2655
2659
  });
2656
2660
  }
2657
- function Zs({ attrsStore: n }, [e, t]) {
2661
+ function Xs({ attrsStore: n }, [e, t]) {
2658
2662
  return [["delete-entity", U(n, e, t), e]];
2659
2663
  }
2660
- function Xs(n, e) {
2661
- const { attrsStore: t } = n, [r, s, i, o] = e, a = yt(i), c = U(t, r, s), u = Pn(n, [r, c, i, o]), l = Object.entries(a).map(([f, h]) => {
2664
+ function ei(n, e) {
2665
+ const { attrsStore: t } = n, [r, s, i, o] = e, a = yt(i), c = U(t, r, s), u = jn(n, [r, c, i, o]), l = Object.entries(a).map(([f, h]) => {
2662
2666
  const y = M(t, r, f);
2663
2667
  return [
2664
2668
  "deep-merge-triple",
@@ -2676,38 +2680,38 @@ function Xs(n, e) {
2676
2680
  ...u ? [u] : []
2677
2681
  ]].concat(l);
2678
2682
  }
2679
- function ei({ attrsStore: n }, [e, t, r]) {
2683
+ function ti({ attrsStore: n }, [e, t, r]) {
2680
2684
  return [["rule-params", U(n, e, t), e, r]];
2681
2685
  }
2682
- function ti(n) {
2686
+ function ni(n) {
2683
2687
  const [e, t, r, s, i] = n;
2684
2688
  if (!s)
2685
2689
  return n;
2686
2690
  const o = { ...s };
2687
2691
  return delete o.id, [e, t, r, o, ...i ? [i] : []];
2688
2692
  }
2689
- function ni(n, e) {
2690
- const [t, ...r] = ti(e);
2693
+ function ri(n, e) {
2694
+ const [t, ...r] = ni(e);
2691
2695
  switch (t) {
2692
2696
  case "merge":
2693
- return Xs(n, r);
2697
+ return ei(n, r);
2694
2698
  case "create":
2695
- return Js(n, r);
2696
- case "update":
2697
2699
  return Ys(n, r);
2700
+ case "update":
2701
+ return Zs(n, r);
2698
2702
  case "link":
2699
- return Gs(n, r);
2700
- case "unlink":
2701
2703
  return Bs(n, r);
2704
+ case "unlink":
2705
+ return Hs(n, r);
2702
2706
  case "delete":
2703
- return Zs(n, r);
2707
+ return Xs(n, r);
2704
2708
  case "ruleParams":
2705
- return ei(n, r);
2709
+ return ti(n, r);
2706
2710
  default:
2707
2711
  throw new Error(`unsupported action ${t}`);
2708
2712
  }
2709
2713
  }
2710
- function ri(n) {
2714
+ function si(n) {
2711
2715
  switch (n) {
2712
2716
  case "string":
2713
2717
  case "date":
@@ -2718,13 +2722,13 @@ function ri(n) {
2718
2722
  return;
2719
2723
  }
2720
2724
  }
2721
- function si(n, e, t) {
2725
+ function ii(n, e, t) {
2722
2726
  var a, c;
2723
2727
  const r = (c = (a = n.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[t];
2724
2728
  if (t === "id") return null;
2725
2729
  if (!r)
2726
2730
  throw new Error(`${e}.${t} does not exist in your schema`);
2727
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = ri(r == null ? void 0 : r.valueType);
2731
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = si(r == null ? void 0 : r.valueType);
2728
2732
  return {
2729
2733
  "index?": i,
2730
2734
  "unique?": s,
@@ -2732,7 +2736,7 @@ function si(n, e, t) {
2732
2736
  };
2733
2737
  }
2734
2738
  function we(n, e, t, r) {
2735
- const s = n ? si(n, e, t) : null, i = P(), a = [P(), e, t];
2739
+ const s = n ? ii(n, e, t) : null, i = P(), a = [P(), e, t];
2736
2740
  return {
2737
2741
  id: i,
2738
2742
  "forward-identity": a,
@@ -2745,11 +2749,11 @@ function we(n, e, t, r) {
2745
2749
  ...r || {}
2746
2750
  };
2747
2751
  }
2748
- function ii(n, e, t) {
2752
+ function oi(n, e, t) {
2749
2753
  return Object.values(n.links).find((i) => i.forward.on === e && i.forward.label === t || i.reverse.on === e && i.reverse.label === t);
2750
2754
  }
2751
- function oi(n, e, t) {
2752
- const r = ii(n, e, t);
2755
+ function ai(n, e, t) {
2756
+ const r = oi(n, e, t);
2753
2757
  if (!r)
2754
2758
  throw new Error(`Couldn't find the link ${e}.${t} in your schema`);
2755
2759
  const { forward: s, reverse: i } = r;
@@ -2763,7 +2767,7 @@ function oi(n, e, t) {
2763
2767
  };
2764
2768
  }
2765
2769
  function Nt(n, e, t, r) {
2766
- const s = n ? oi(n, e, t) : null, i = P(), o = [P(), e, t], a = [P(), t, e];
2770
+ const s = n ? ai(n, e, t) : null, i = P(), o = [P(), e, t], a = [P(), t, e];
2767
2771
  return {
2768
2772
  id: i,
2769
2773
  // @ts-ignore: ts thinks it's any[]
@@ -2780,7 +2784,7 @@ function Nt(n, e, t, r) {
2780
2784
  ...r || {}
2781
2785
  };
2782
2786
  }
2783
- const ai = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ci = /* @__PURE__ */ new Set(["link", "unlink"]), ui = /* @__PURE__ */ new Set(["create", "update", "merge"]), li = /* @__PURE__ */ new Set([
2787
+ const ci = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ui = /* @__PURE__ */ new Set(["link", "unlink"]), li = /* @__PURE__ */ new Set(["create", "update", "merge"]), di = /* @__PURE__ */ new Set([
2784
2788
  "link",
2785
2789
  "unlink",
2786
2790
  "create",
@@ -2788,13 +2792,13 @@ const ai = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2788
2792
  "merge",
2789
2793
  "delete",
2790
2794
  "ruleParams"
2791
- ]), rt = { "unique?": !0, "index?": !0 }, di = {
2795
+ ]), rt = { "unique?": !0, "index?": !0 }, fi = {
2792
2796
  ...rt,
2793
2797
  cardinality: "one"
2794
2798
  };
2795
- function fi(n) {
2799
+ function hi(n) {
2796
2800
  const e = [], [t, r, s, i] = n;
2797
- if (!li.has(t))
2801
+ if (!di.has(t))
2798
2802
  return e;
2799
2803
  const o = nt(s);
2800
2804
  if (o && e.push({ etype: r, lookupPair: o }), t === "link")
@@ -2811,7 +2815,7 @@ function fi(n) {
2811
2815
  }
2812
2816
  return e;
2813
2817
  }
2814
- function hi({ attrsStore: n, schema: e }, t) {
2818
+ function pi({ attrsStore: n, schema: e }, t) {
2815
2819
  var f, h;
2816
2820
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2817
2821
  function o(y, g) {
@@ -2840,10 +2844,10 @@ function hi({ attrsStore: n, schema: e }, t) {
2840
2844
  }
2841
2845
  function d(y, g) {
2842
2846
  const _ = o(y, g), w = a(y, g);
2843
- u(_), u(w), !_ && !w && c(Nt(e, y, g, di));
2847
+ u(_), u(w), !_ && !w && c(Nt(e, y, g, fi));
2844
2848
  }
2845
2849
  for (const y of t)
2846
- for (const { etype: g, lookupPair: _, linkLabel: w } of fi(y)) {
2850
+ for (const { etype: g, lookupPair: _, linkLabel: w } of hi(y)) {
2847
2851
  const b = _[0];
2848
2852
  if (w) {
2849
2853
  d(g, w);
@@ -2867,19 +2871,19 @@ function hi({ attrsStore: n, schema: e }, t) {
2867
2871
  }
2868
2872
  for (const y of t) {
2869
2873
  const [g, _, w, b] = y;
2870
- if (ai.has(g)) {
2874
+ if (ci.has(g)) {
2871
2875
  const T = o(_, "id");
2872
2876
  u(T), T || c(we(e, _, "id", { "unique?": !0 }));
2873
2877
  for (const A of Object.keys(b)) {
2874
2878
  const m = o(_, A);
2875
- if (u(m), ui.has(g) && (m || c(
2879
+ if (u(m), li.has(g) && (m || c(
2876
2880
  we(
2877
2881
  e,
2878
2882
  _,
2879
2883
  A,
2880
2884
  A === "id" ? { "unique?": !0 } : null
2881
2885
  )
2882
- )), ci.has(g)) {
2886
+ )), ui.has(g)) {
2883
2887
  const O = a(_, A);
2884
2888
  !m && !O && c(Nt(e, _, A)), u(O);
2885
2889
  }
@@ -2894,15 +2898,15 @@ function hi({ attrsStore: n, schema: e }, t) {
2894
2898
  }
2895
2899
  return [n, i];
2896
2900
  }
2897
- function pi(n, e) {
2898
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => qs(c)), [s, i] = hi(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => ni(o, c));
2901
+ function yi(n, e) {
2902
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => zs(c)), [s, i] = pi(n, r), o = { ...n, attrsStore: s }, a = r.flatMap((c) => ri(o, c));
2899
2903
  return [...i, ...a];
2900
2904
  }
2901
2905
  function Ft(n, e) {
2902
2906
  typeof requestIdleCallback > "u" ? n() : requestIdleCallback(n, { timeout: e });
2903
2907
  }
2904
2908
  const he = "__meta";
2905
- class jn {
2909
+ class $n {
2906
2910
  constructor(e, t) {
2907
2911
  }
2908
2912
  }
@@ -3154,13 +3158,13 @@ class st {
3154
3158
  };
3155
3159
  }
3156
3160
  }
3157
- const yi = 6, bi = ["kv", "querySubs", "syncSubs"];
3158
- function gi(n) {
3161
+ const bi = 6, gi = ["kv", "querySubs", "syncSubs"];
3162
+ function _i(n) {
3159
3163
  return function(t) {
3160
3164
  console.error("Error in IndexedDB event", { source: n, event: t });
3161
3165
  };
3162
3166
  }
3163
- async function _i(n) {
3167
+ async function wi(n) {
3164
3168
  return new Promise((e) => {
3165
3169
  const t = indexedDB.open(n);
3166
3170
  t.onerror = (r) => {
@@ -3174,7 +3178,7 @@ async function _i(n) {
3174
3178
  };
3175
3179
  });
3176
3180
  }
3177
- async function wi(n, e, t) {
3181
+ async function Ti(n, e, t) {
3178
3182
  const r = (
3179
3183
  // Backwards compatibility for older versions where we JSON.stringified before storing
3180
3184
  typeof e == "string" ? JSON.parse(e) : e
@@ -3214,8 +3218,8 @@ async function Kt(n, e, t) {
3214
3218
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3215
3219
  });
3216
3220
  }
3217
- async function Ti(n, e) {
3218
- const t = await _i(`instant_${n}_5`);
3221
+ async function mi(n, e) {
3222
+ const t = await wi(`instant_${n}_5`);
3219
3223
  if (!t)
3220
3224
  return;
3221
3225
  const r = await new Promise((l, d) => {
@@ -3238,7 +3242,7 @@ async function Ti(n, e) {
3238
3242
  for (const [l, d] of r)
3239
3243
  switch (l) {
3240
3244
  case "querySubs": {
3241
- const f = wi(l, d, o);
3245
+ const f = Ti(l, d, o);
3242
3246
  a.push(f);
3243
3247
  break;
3244
3248
  }
@@ -3260,7 +3264,7 @@ async function Ti(n, e) {
3260
3264
  });
3261
3265
  }
3262
3266
  const qt = /* @__PURE__ */ new Map();
3263
- class $n extends jn {
3267
+ class Dn extends $n {
3264
3268
  constructor(t, r) {
3265
3269
  super(t, r);
3266
3270
  p(this, "dbName");
@@ -3268,7 +3272,7 @@ class $n extends jn {
3268
3272
  p(this, "_appId");
3269
3273
  p(this, "_prefix");
3270
3274
  p(this, "_dbPromise");
3271
- this.dbName = `instant_${t}_${yi}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3275
+ this.dbName = `instant_${t}_${bi}`, this._storeName = r, this._appId = t, this._dbPromise = this._init();
3272
3276
  }
3273
3277
  _init() {
3274
3278
  return new Promise((t, r) => {
@@ -3279,8 +3283,8 @@ class $n extends jn {
3279
3283
  }, i.onsuccess = (o) => {
3280
3284
  const c = o.target.result;
3281
3285
  if (s) {
3282
- const u = Ti(this._appId, c).catch((l) => {
3283
- gi("Error upgrading store from version 5 to 6.")(l);
3286
+ const u = mi(this._appId, c).catch((l) => {
3287
+ _i("Error upgrading store from version 5 to 6.")(l);
3284
3288
  });
3285
3289
  qt.set(this.dbName, u), u.then(() => t(c)).catch(() => t(c));
3286
3290
  } else {
@@ -3294,7 +3298,7 @@ class $n extends jn {
3294
3298
  }
3295
3299
  _upgradeStore(t) {
3296
3300
  const s = t.target.result;
3297
- for (const i of bi)
3301
+ for (const i of gi)
3298
3302
  s.objectStoreNames.contains(i) || s.createObjectStore(i);
3299
3303
  }
3300
3304
  async getItem(t) {
@@ -3359,7 +3363,7 @@ class $n extends jn {
3359
3363
  });
3360
3364
  }
3361
3365
  }
3362
- class Dn {
3366
+ class Rn {
3363
3367
  static async getIsOnline() {
3364
3368
  return navigator.onLine;
3365
3369
  }
@@ -3404,7 +3408,7 @@ async function V(n, e) {
3404
3408
  const t = await fetch(n, e), r = await t.json();
3405
3409
  return t.status === 200 ? Promise.resolve(r) : Promise.reject(new De({ status: t.status, body: r }));
3406
3410
  }
3407
- function mi({
3411
+ function Si({
3408
3412
  apiURI: n,
3409
3413
  appId: e,
3410
3414
  email: t
@@ -3415,7 +3419,7 @@ function mi({
3415
3419
  body: JSON.stringify({ "app-id": e, email: t })
3416
3420
  });
3417
3421
  }
3418
- async function Si({
3422
+ async function Ai({
3419
3423
  apiURI: n,
3420
3424
  appId: e,
3421
3425
  email: t,
@@ -3433,7 +3437,7 @@ async function Si({
3433
3437
  })
3434
3438
  });
3435
3439
  }
3436
- async function Ai({
3440
+ async function Oi({
3437
3441
  apiURI: n,
3438
3442
  appId: e,
3439
3443
  refreshToken: t
@@ -3447,7 +3451,7 @@ async function Ai({
3447
3451
  })
3448
3452
  });
3449
3453
  }
3450
- async function Oi({
3454
+ async function vi({
3451
3455
  apiURI: n,
3452
3456
  appId: e
3453
3457
  }) {
@@ -3477,7 +3481,7 @@ async function zt({
3477
3481
  })
3478
3482
  });
3479
3483
  }
3480
- async function vi({
3484
+ async function ki({
3481
3485
  apiURI: n,
3482
3486
  appId: e,
3483
3487
  nonce: t,
@@ -3497,7 +3501,7 @@ async function vi({
3497
3501
  })
3498
3502
  });
3499
3503
  }
3500
- async function ki({
3504
+ async function Ei({
3501
3505
  apiURI: n,
3502
3506
  appId: e,
3503
3507
  refreshToken: t
@@ -3513,7 +3517,7 @@ async function ki({
3513
3517
  })
3514
3518
  });
3515
3519
  }
3516
- async function Ei({
3520
+ async function Ii({
3517
3521
  apiURI: n,
3518
3522
  appId: e,
3519
3523
  path: t,
@@ -3534,7 +3538,7 @@ async function Ei({
3534
3538
  body: r
3535
3539
  });
3536
3540
  }
3537
- async function Ii({
3541
+ async function Mi({
3538
3542
  apiURI: n,
3539
3543
  appId: e,
3540
3544
  path: t,
@@ -3552,7 +3556,7 @@ async function Ii({
3552
3556
  );
3553
3557
  return s;
3554
3558
  }
3555
- async function Mi({
3559
+ async function Ci({
3556
3560
  apiURI: n,
3557
3561
  appId: e,
3558
3562
  fileName: t,
@@ -3572,7 +3576,7 @@ async function Mi({
3572
3576
  });
3573
3577
  return i;
3574
3578
  }
3575
- async function Ci(n, e) {
3579
+ async function Pi(n, e) {
3576
3580
  return (await fetch(n, {
3577
3581
  method: "PUT",
3578
3582
  body: e,
@@ -3581,7 +3585,7 @@ async function Ci(n, e) {
3581
3585
  }
3582
3586
  })).ok;
3583
3587
  }
3584
- async function Pi({
3588
+ async function ji({
3585
3589
  apiURI: n,
3586
3590
  appId: e,
3587
3591
  path: t,
@@ -3601,8 +3605,8 @@ async function Pi({
3601
3605
  );
3602
3606
  return s;
3603
3607
  }
3604
- let Tt = !1, Rn = !1, xn = !1;
3605
- typeof window < "u" && typeof window.localStorage < "u" && (Tt = !!window.localStorage.getItem("devBackend"), Rn = !!window.localStorage.getItem("__instantLogging"), xn = !!window.localStorage.getItem("__devtoolLocalDash"));
3608
+ let Tt = !1, xn = !1, Un = !1;
3609
+ typeof window < "u" && typeof window.localStorage < "u" && (Tt = !!window.localStorage.getItem("devBackend"), xn = !!window.localStorage.getItem("__instantLogging"), Un = !!window.localStorage.getItem("__devtoolLocalDash"));
3606
3610
  function Vt(n, e) {
3607
3611
  if (!e) return n;
3608
3612
  const t = {};
@@ -3610,7 +3614,7 @@ function Vt(n, e) {
3610
3614
  t[r] = n[r];
3611
3615
  }), t;
3612
3616
  }
3613
- function ji(n, e, t) {
3617
+ function $i(n, e, t) {
3614
3618
  const r = {
3615
3619
  peers: {}
3616
3620
  };
@@ -3627,7 +3631,7 @@ function ji(n, e, t) {
3627
3631
  }
3628
3632
  return r;
3629
3633
  }
3630
- function $i(n, e) {
3634
+ function Di(n, e) {
3631
3635
  if (n.isLoading !== e.isLoading || n.error !== e.error || (n.user || e.user) && (!n.user || !e.user || !Mt(n.user, e.user)) || !dn(n.peers, e.peers)) return !0;
3632
3636
  for (const r of Object.keys(n.peers))
3633
3637
  if (!Mt(n.peers[r], e.peers[r])) return !0;
@@ -3649,18 +3653,18 @@ class Qt {
3649
3653
  this._reject(e);
3650
3654
  }
3651
3655
  }
3652
- function Un(n, e = []) {
3656
+ function Ln(n, e = []) {
3653
3657
  n.forEach((t) => {
3654
3658
  const { data: r } = t, { "datalog-result": s } = r, { "join-rows": i } = s;
3655
3659
  for (const o of i)
3656
3660
  for (const a of o)
3657
3661
  e.push(a);
3658
- Un(t["child-nodes"], e);
3662
+ Ln(t["child-nodes"], e);
3659
3663
  });
3660
3664
  }
3661
3665
  function Wt(n) {
3662
3666
  const e = [];
3663
- return Un(n, e), e;
3667
+ return Ln(n, e), e;
3664
3668
  }
3665
3669
  function it(n) {
3666
3670
  return Object.values(n.links).reduce((e, t) => {
@@ -3676,8 +3680,8 @@ function it(n) {
3676
3680
  }, e;
3677
3681
  }, {});
3678
3682
  }
3679
- const Ln = "v0.22.133";
3680
- function Di(n, e) {
3683
+ const Nn = "v0.22.134";
3684
+ function Ri(n, e) {
3681
3685
  return {
3682
3686
  info: n ? (...t) => console.info(...t, e()) : () => {
3683
3687
  },
@@ -3798,7 +3802,7 @@ const Gt = [
3798
3802
  "before",
3799
3803
  "fields",
3800
3804
  "aggregate"
3801
- ], Ri = (n) => n.valueType || "unknown", Nn = (n, e, t = !1) => {
3805
+ ], xi = (n) => n.valueType || "unknown", Fn = (n, e, t = !1) => {
3802
3806
  if (t || n == null) return !0;
3803
3807
  switch (e) {
3804
3808
  case "string":
@@ -3812,9 +3816,9 @@ const Gt = [
3812
3816
  default:
3813
3817
  return !0;
3814
3818
  }
3815
- }, xi = (n, e, t, r, s, i, o) => {
3819
+ }, Ui = (n, e, t, r, s, i, o) => {
3816
3820
  const a = i.valueType === "json", c = (u, l, d) => {
3817
- if (!Nn(d, l, a))
3821
+ if (!Fn(d, l, a))
3818
3822
  throw new k(
3819
3823
  `Invalid value for operator '${u}' on attribute '${r}' in entity '${s}'. Expected ${l}, but received: ${typeof d}`,
3820
3824
  o
@@ -3857,13 +3861,13 @@ const Gt = [
3857
3861
  );
3858
3862
  }
3859
3863
  }, re = (n, e, t, r, s) => {
3860
- const i = Ri(t), o = t.valueType === "json";
3864
+ const i = xi(t), o = t.valueType === "json";
3861
3865
  if (typeof n == "object" && n !== null && !Array.isArray(n)) {
3862
3866
  if (o)
3863
3867
  return;
3864
3868
  const c = n;
3865
3869
  for (const [u, l] of Object.entries(c))
3866
- xi(
3870
+ Ui(
3867
3871
  u,
3868
3872
  l,
3869
3873
  i,
@@ -3872,12 +3876,12 @@ const Gt = [
3872
3876
  t,
3873
3877
  `${s}.${u}`
3874
3878
  );
3875
- } else if (!Nn(n, i, o))
3879
+ } else if (!Fn(n, i, o))
3876
3880
  throw new k(
3877
3881
  `Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof n}`,
3878
3882
  s
3879
3883
  );
3880
- }, Ui = (n, e, t, r, s) => {
3884
+ }, Li = (n, e, t, r, s) => {
3881
3885
  const i = n.split(".");
3882
3886
  if (i.length < 2)
3883
3887
  throw new k(
@@ -3947,12 +3951,12 @@ const Gt = [
3947
3951
  );
3948
3952
  }
3949
3953
  re(e, n, u, t, s);
3950
- }, Fn = (n, e, t, r) => {
3954
+ }, Kn = (n, e, t, r) => {
3951
3955
  for (const [s, i] of Object.entries(n)) {
3952
3956
  if (s === "or" || s === "and") {
3953
3957
  if (Array.isArray(i))
3954
3958
  for (const u of i)
3955
- typeof u == "object" && u !== null && Fn(
3959
+ typeof u == "object" && u !== null && Kn(
3956
3960
  u,
3957
3961
  e,
3958
3962
  t,
@@ -3971,7 +3975,7 @@ const Gt = [
3971
3975
  continue;
3972
3976
  }
3973
3977
  if (s.includes(".")) {
3974
- Ui(
3978
+ Li(
3975
3979
  s,
3976
3980
  i,
3977
3981
  e,
@@ -4014,7 +4018,7 @@ const Gt = [
4014
4018
  );
4015
4019
  }
4016
4020
  }
4017
- }, Li = (n, e, t, r, s = 0) => {
4021
+ }, Ni = (n, e, t, r, s = 0) => {
4018
4022
  for (const o of Object.keys(n))
4019
4023
  if (!Gt.includes(o))
4020
4024
  throw new k(
@@ -4041,14 +4045,14 @@ const Gt = [
4041
4045
  `'where' clause must be an object in entity '${e}', but received: ${typeof n.where}`,
4042
4046
  r ? `${r}.where` : void 0
4043
4047
  );
4044
- Fn(
4048
+ Kn(
4045
4049
  n.where,
4046
4050
  e,
4047
4051
  t,
4048
4052
  r ? `${r}.where` : "where"
4049
4053
  );
4050
4054
  }
4051
- }, Kn = (n, e, t, r, s = 0) => {
4055
+ }, qn = (n, e, t, r, s = 0) => {
4052
4056
  var i;
4053
4057
  if (!n || typeof n != "object")
4054
4058
  throw new k(
@@ -4067,7 +4071,7 @@ const Gt = [
4067
4071
  const a = n[o];
4068
4072
  if (typeof a == "object" && a !== null) {
4069
4073
  const c = (i = t == null ? void 0 : t.entities[e].links[o]) == null ? void 0 : i.entityName;
4070
- c && Kn(
4074
+ c && qn(
4071
4075
  a,
4072
4076
  c,
4073
4077
  t,
@@ -4082,7 +4086,7 @@ const Gt = [
4082
4086
  `Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`,
4083
4087
  `${r}.$`
4084
4088
  );
4085
- Li(
4089
+ Ni(
4086
4090
  a,
4087
4091
  e,
4088
4092
  t,
@@ -4119,7 +4123,7 @@ const Gt = [
4119
4123
  r
4120
4124
  );
4121
4125
  }
4122
- Kn(
4126
+ qn(
4123
4127
  t[r],
4124
4128
  r,
4125
4129
  e,
@@ -4135,24 +4139,24 @@ class K extends Error {
4135
4139
  super(e), this.name = "TransactionValidationError";
4136
4140
  }
4137
4141
  }
4138
- const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4139
- `Entity '${n}' does not exist in schema. Available entities: ${qn(e)}`
4142
+ const zn = (n) => n.length > 0 ? n.join(", ") : "none", Fi = (n, e) => new K(
4143
+ `Entity '${n}' does not exist in schema. Available entities: ${zn(e)}`
4140
4144
  ), Ne = {
4141
4145
  string: (n) => typeof n == "string",
4142
4146
  number: (n) => typeof n == "number" && !isNaN(n),
4143
4147
  boolean: (n) => typeof n == "boolean",
4144
4148
  date: (n) => n instanceof Date || typeof n == "string" || typeof n == "number",
4145
4149
  json: () => !0
4146
- }, Fi = (n, e) => {
4150
+ }, Ki = (n, e) => {
4147
4151
  var t;
4148
4152
  return n == null ? !0 : ((t = Ne[e.valueType]) == null ? void 0 : t.call(Ne, n)) ?? !1;
4149
- }, zn = (n, e) => {
4153
+ }, Vn = (n, e) => {
4150
4154
  const t = e.entities[n];
4151
4155
  if (!t)
4152
- throw Ni(n, Object.keys(e.entities));
4156
+ throw Fi(n, Object.keys(e.entities));
4153
4157
  return t;
4154
4158
  }, Fe = (n, e, t) => {
4155
- const r = zn(n, t);
4159
+ const r = Vn(n, t);
4156
4160
  if (typeof e != "object" || e === null)
4157
4161
  throw new K(
4158
4162
  `Arguments for data operation on entity '${n}' must be an object, but received: ${typeof e}`
@@ -4160,13 +4164,13 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4160
4164
  for (const [s, i] of Object.entries(e)) {
4161
4165
  if (s === "id") continue;
4162
4166
  const o = r.attrs[s];
4163
- if (o && !Fi(i, o))
4167
+ if (o && !Ki(i, o))
4164
4168
  throw new K(
4165
4169
  `Invalid value for attribute '${s}' in entity '${n}'. Expected ${o.valueType}, but received: ${typeof i}`
4166
4170
  );
4167
4171
  }
4168
4172
  }, Jt = (n, e, t) => {
4169
- const r = zn(n, t);
4173
+ const r = Vn(n, t);
4170
4174
  if (typeof e != "object" || e === null)
4171
4175
  throw new K(
4172
4176
  `Arguments for link operation on entity '${n}' must be an object, but received: ${typeof e}`
@@ -4175,7 +4179,7 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4175
4179
  if (!r.links[s]) {
4176
4180
  const a = Object.keys(r.links);
4177
4181
  throw new K(
4178
- `Link '${s}' does not exist on entity '${n}'. Available links: ${qn(a)}`
4182
+ `Link '${s}' does not exist on entity '${n}'. Available links: ${zn(a)}`
4179
4183
  );
4180
4184
  }
4181
4185
  if (i != null) {
@@ -4191,7 +4195,7 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4191
4195
  );
4192
4196
  }
4193
4197
  }
4194
- }, Ki = {
4198
+ }, qi = {
4195
4199
  create: Fe,
4196
4200
  update: Fe,
4197
4201
  merge: Fe,
@@ -4199,7 +4203,7 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4199
4203
  unlink: Jt,
4200
4204
  delete: () => {
4201
4205
  }
4202
- }, qi = (n, e) => {
4206
+ }, zi = (n, e) => {
4203
4207
  if (!e) return;
4204
4208
  const [t, r, s, i] = n;
4205
4209
  if (!Array.isArray(s) && !se(s))
@@ -4210,9 +4214,9 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4210
4214
  throw new K(
4211
4215
  `Entity name must be a string, but received: ${typeof r}`
4212
4216
  );
4213
- const o = Ki[t];
4217
+ const o = qi[t];
4214
4218
  o && i !== void 0 && o(r, i, e);
4215
- }, zi = (n, e) => {
4219
+ }, Vi = (n, e) => {
4216
4220
  const t = Array.isArray(n) ? n : [n];
4217
4221
  for (const r of t) {
4218
4222
  if (!r || typeof r != "object")
@@ -4228,11 +4232,11 @@ const qn = (n) => n.length > 0 ? n.join(", ") : "none", Ni = (n, e) => new K(
4228
4232
  throw new K(
4229
4233
  `Transaction operation must be an array, but received: ${typeof s}`
4230
4234
  );
4231
- qi(s, e);
4235
+ zi(s, e);
4232
4236
  }
4233
4237
  }
4234
4238
  };
4235
- let Vn = 0;
4239
+ let Qn = 0;
4236
4240
  class Yt {
4237
4241
  constructor(e) {
4238
4242
  p(this, "type", "ws");
@@ -4242,7 +4246,7 @@ class Yt {
4242
4246
  p(this, "onmessage");
4243
4247
  p(this, "onclose");
4244
4248
  p(this, "onerror");
4245
- this.id = `${this.type}_${Vn++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4249
+ this.id = `${this.type}_${Qn++}`, this.conn = new WebSocket(e), this.conn.onopen = (t) => {
4246
4250
  this.onopen && this.onopen({ target: this });
4247
4251
  }, this.conn.onmessage = (t) => {
4248
4252
  this.onmessage && this.onmessage({
@@ -4268,7 +4272,7 @@ class Yt {
4268
4272
  return this.conn.send(JSON.stringify(e));
4269
4273
  }
4270
4274
  }
4271
- class Vi {
4275
+ class Qi {
4272
4276
  constructor(e, t) {
4273
4277
  p(this, "type", "sse");
4274
4278
  p(this, "initParams", null);
@@ -4284,7 +4288,7 @@ class Vi {
4284
4288
  p(this, "onmessage");
4285
4289
  p(this, "onclose");
4286
4290
  p(this, "onerror");
4287
- this.id = `${this.type}_${Vn++}`, this.url = t, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4291
+ this.id = `${this.type}_${Qn++}`, this.url = t, this.ES = e, this.conn = new e(t), this.sseInitTimeout = setTimeout(() => {
4288
4292
  this.initParams || this.handleError();
4289
4293
  }, 1e4), this.conn.onmessage = (r) => {
4290
4294
  const s = JSON.parse(r.data);
@@ -4365,7 +4369,7 @@ class Vi {
4365
4369
  this.handleClose();
4366
4370
  }
4367
4371
  }
4368
- function Qi(n, e) {
4372
+ function Wi(n, e) {
4369
4373
  const t = n.values;
4370
4374
  if (t) {
4371
4375
  const r = gn(t.attrsStore, null);
@@ -4377,7 +4381,7 @@ function Qi(n, e) {
4377
4381
  }
4378
4382
  return n;
4379
4383
  }
4380
- function Wi(n, e) {
4384
+ function Gi(n, e) {
4381
4385
  var t;
4382
4386
  if (e.values) {
4383
4387
  const r = [];
@@ -4392,7 +4396,7 @@ function Wi(n, e) {
4392
4396
  } else
4393
4397
  return e;
4394
4398
  }
4395
- function Gi(n, e, t) {
4399
+ function Bi(n, e, t) {
4396
4400
  var i, o;
4397
4401
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = t == null ? void 0 : t.state) == null ? void 0 : o.txId;
4398
4402
  return r && (!s || r > s) ? e : s && (!r || s > r) ? t : e || t;
@@ -4422,7 +4426,7 @@ function Xt(n, e, t) {
4422
4426
  break;
4423
4427
  }
4424
4428
  }
4425
- function Bi(n, e, t) {
4429
+ function Hi(n, e, t) {
4426
4430
  var s, i;
4427
4431
  const r = {};
4428
4432
  for (const { action: o, triple: a } of t) {
@@ -4449,14 +4453,14 @@ function Bi(n, e, t) {
4449
4453
  function Te(n, e) {
4450
4454
  return { [n.table]: e.map((t) => t.entity) };
4451
4455
  }
4452
- function Hi(n, e) {
4456
+ function Ji(n, e) {
4453
4457
  var r;
4454
4458
  if (n.orderFieldType)
4455
4459
  return n.orderFieldType;
4456
4460
  const t = n.orderField === "serverCreatedAt" ? "number" : (r = M(e(), n.table, n.orderField)) == null ? void 0 : r["checked-data-type"];
4457
4461
  return n.orderFieldType = t, t;
4458
4462
  }
4459
- function Ji(n, e, t) {
4463
+ function Yi(n, e, t) {
4460
4464
  const r = e;
4461
4465
  if (n.orderField === "serverCreatedAt") {
4462
4466
  t.sort(
@@ -4501,8 +4505,8 @@ function Ji(n, e, t) {
4501
4505
  }
4502
4506
  );
4503
4507
  }
4504
- var Yi = /* @__PURE__ */ ((n) => (n.InitialSyncBatch = "InitialSyncBatch", n.InitialSyncComplete = "InitialSyncComplete", n.LoadFromStorage = "LoadFromStorage", n.SyncTransaction = "SyncTransaction", n.Error = "Error", n))(Yi || {});
4505
- class Zi {
4508
+ var Zi = /* @__PURE__ */ ((n) => (n.InitialSyncBatch = "InitialSyncBatch", n.InitialSyncComplete = "InitialSyncComplete", n.LoadFromStorage = "LoadFromStorage", n.SyncTransaction = "SyncTransaction", n.Error = "Error", n))(Zi || {});
4509
+ class Xi {
4506
4510
  constructor(e, t, r, s, i, o) {
4507
4511
  p(this, "trySend");
4508
4512
  p(this, "subs");
@@ -4515,9 +4519,9 @@ class Zi {
4515
4519
  p(this, "getAttrs");
4516
4520
  this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new st({
4517
4521
  persister: t,
4518
- merge: Gi,
4519
- serialize: Wi,
4520
- parse: (a, c) => Qi(c, this.config.useDateObjects),
4522
+ merge: Bi,
4523
+ serialize: Gi,
4524
+ parse: (a, c) => Wi(c, this.config.useDateObjects),
4521
4525
  objectSize: (a) => {
4522
4526
  var c;
4523
4527
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4727,9 +4731,9 @@ class Zi {
4727
4731
  e: for (const [_, w] of Object.entries(u))
4728
4732
  for (let b = 0; b < d.length; b++) {
4729
4733
  const T = d[b];
4730
- if (Pr(T.store, _)) {
4734
+ if (jr(T.store, _)) {
4731
4735
  Xt(T.store, l.attrsStore, w);
4732
- const A = Ke(s, T.store, l.attrsStore), m = Bi(
4736
+ const A = Ke(s, T.store, l.attrsStore), m = Hi(
4733
4737
  T.store,
4734
4738
  l.attrsStore,
4735
4739
  w
@@ -4769,8 +4773,8 @@ class Zi {
4769
4773
  const y = [];
4770
4774
  for (const _ of c.sort().reverse())
4771
4775
  y.push(d[_].entity), d.splice(_, 1);
4772
- const g = Hi(s, this.getAttrs);
4773
- Ji(s, g, d), this.notifyCbs(r, {
4776
+ const g = Ji(s, this.getAttrs);
4777
+ Yi(s, g, d), this.notifyCbs(r, {
4774
4778
  type: "SyncTransaction",
4775
4779
  data: Te(s, (o = s.values) == null ? void 0 : o.entities),
4776
4780
  added: h,
@@ -4817,11 +4821,11 @@ const W = {
4817
4821
  AUTHENTICATED: "authenticated",
4818
4822
  CLOSED: "closed",
4819
4823
  ERRORED: "errored"
4820
- }, Xi = 3e4, eo = 3e4, to = 200, no = 1e3 * 60, ro = {
4824
+ }, eo = 3e4, to = 3e4, no = 200, ro = 1e3 * 60, so = {
4821
4825
  apiURI: "https://api.instantdb.com",
4822
4826
  websocketURI: "wss://api.instantdb.com/runtime/session"
4823
4827
  }, qe = "_instant_oauth_redirect", ae = "currentUser";
4824
- function so({
4828
+ function io({
4825
4829
  transportType: n,
4826
4830
  appId: e,
4827
4831
  apiURI: t,
@@ -4834,7 +4838,7 @@ function so({
4834
4838
  case "ws":
4835
4839
  return new Yt(`${r}?app_id=${e}`);
4836
4840
  case "sse":
4837
- return new Vi(
4841
+ return new Qi(
4838
4842
  s,
4839
4843
  `${t}/runtime/sse?app_id=${e}`
4840
4844
  );
@@ -4842,7 +4846,7 @@ function so({
4842
4846
  throw new Error("Unknown transport type " + n);
4843
4847
  }
4844
4848
  }
4845
- function io() {
4849
+ function oo() {
4846
4850
  return typeof window < "u" || typeof chrome < "u";
4847
4851
  }
4848
4852
  const en = {
@@ -4851,7 +4855,7 @@ const en = {
4851
4855
  "refresh-presence": !0,
4852
4856
  "patch-presence": !0
4853
4857
  };
4854
- function oo(n, e) {
4858
+ function ao(n, e) {
4855
4859
  var r;
4856
4860
  const t = typeof n == "string" ? JSON.parse(n) : n;
4857
4861
  if ((r = t == null ? void 0 : t.result) != null && r.store) {
@@ -4869,7 +4873,7 @@ function oo(n, e) {
4869
4873
  }
4870
4874
  return t;
4871
4875
  }
4872
- function ao(n, e) {
4876
+ function co(n, e) {
4873
4877
  const { result: t, ...r } = e, s = (
4874
4878
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
4875
4879
  r
@@ -4884,7 +4888,7 @@ function ao(n, e) {
4884
4888
  }
4885
4889
  return s;
4886
4890
  }
4887
- function co(n, e) {
4891
+ function uo(n, e) {
4888
4892
  switch (n) {
4889
4893
  case "pendingMutations":
4890
4894
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4892,7 +4896,7 @@ function co(n, e) {
4892
4896
  return e;
4893
4897
  }
4894
4898
  }
4895
- function uo(n, e) {
4899
+ function lo(n, e) {
4896
4900
  switch (n) {
4897
4901
  case "pendingMutations":
4898
4902
  return [...e.entries()];
@@ -4900,7 +4904,7 @@ function uo(n, e) {
4900
4904
  return e;
4901
4905
  }
4902
4906
  }
4903
- function lo(n, e, t) {
4907
+ function fo(n, e, t) {
4904
4908
  const r = e == null ? void 0 : e.result, s = t == null ? void 0 : t.result;
4905
4909
  return r && !s && t && (t.result = r), t || e;
4906
4910
  }
@@ -4910,8 +4914,8 @@ function ze(n) {
4910
4914
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
4911
4915
  });
4912
4916
  }
4913
- class fo {
4914
- constructor(e, t = $n, r = Dn, s, i) {
4917
+ class ho {
4918
+ constructor(e, t = Dn, r = Rn, s, i) {
4915
4919
  /** @type {s.AttrsStore | undefined} */
4916
4920
  p(this, "attrs");
4917
4921
  p(this, "_isOnline", !0);
@@ -5005,9 +5009,9 @@ class fo {
5005
5009
  });
5006
5010
  /** Applies transactions locally and sends transact message to server */
5007
5011
  p(this, "pushTx", (e) => {
5008
- this.config.disableValidation || zi(e, this.config.schema);
5012
+ this.config.disableValidation || Vi(e, this.config.schema);
5009
5013
  try {
5010
- const t = pi(
5014
+ const t = yi(
5011
5015
  {
5012
5016
  attrsStore: this.optimisticAttrs(),
5013
5017
  schema: this.config.schema,
@@ -5146,10 +5150,10 @@ class fo {
5146
5150
  this._reconnectTimeoutMs
5147
5151
  ), this._scheduleReconnect();
5148
5152
  });
5149
- if (this._EventSource = i, this.config = { ...ro, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? eo, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? to, this._log = Di(
5150
- e.verbose || Tt || Rn,
5153
+ if (this._EventSource = i, this.config = { ...so, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? to, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? no, this._log = Ri(
5154
+ e.verbose || Tt || xn,
5151
5155
  () => this._reactorStats()
5152
- ), this.versions = { ...s || {}, "@instantdb/core": Ln }, this.config.schema && (this._linkIndex = it(this.config.schema)), !!io()) {
5156
+ ), this.versions = { ...s || {}, "@instantdb/core": Nn }, this.config.schema && (this._linkIndex = it(this.config.schema)), !!oo()) {
5153
5157
  if (!e.appId)
5154
5158
  throw new Error("Instant must be initialized with an appId.");
5155
5159
  if (!se(e.appId))
@@ -5168,7 +5172,7 @@ class fo {
5168
5172
  } catch (c) {
5169
5173
  this._log.error("[error] handle broadcast channel", c);
5170
5174
  }
5171
- })), this._initStorage(t), this._syncTable = new Zi(
5175
+ })), this._initStorage(t), this._syncTable = new Xi(
5172
5176
  this._trySendAuthed.bind(this),
5173
5177
  new t(this.config.appId, "syncSubs"),
5174
5178
  {
@@ -5187,7 +5191,7 @@ class fo {
5187
5191
  }), setInterval(async () => {
5188
5192
  const o = await this.getCurrentUser();
5189
5193
  this.syncUserToEndpoint(o.user);
5190
- }, no), r.getIsOnline().then((o) => {
5194
+ }, ro), r.getIsOnline().then((o) => {
5191
5195
  this._isOnline = o, this._startSocket(), r.listen((a) => {
5192
5196
  a !== this._isOnline && (this._log.info("[network] online =", a), this._isOnline = a, this._isOnline ? this._startSocket() : (this._log.info(
5193
5197
  "Changing status from",
@@ -5224,9 +5228,9 @@ class fo {
5224
5228
  _initStorage(e) {
5225
5229
  this.querySubs = new st({
5226
5230
  persister: new e(this.config.appId, "querySubs"),
5227
- merge: lo,
5228
- serialize: ao,
5229
- parse: (t, r) => oo(r, this.config.useDateObjects),
5231
+ merge: fo,
5232
+ serialize: co,
5233
+ parse: (t, r) => ao(r, this.config.useDateObjects),
5230
5234
  // objectSize
5231
5235
  objectSize: (t) => {
5232
5236
  var r, s, i;
@@ -5245,8 +5249,8 @@ class fo {
5245
5249
  }), this.querySubs.onKeyLoaded = (t) => this._onQuerySubLoaded(t), this.kv = new st({
5246
5250
  persister: new e(this.config.appId, "kv"),
5247
5251
  merge: this._onMergeKv,
5248
- serialize: uo,
5249
- parse: co,
5252
+ serialize: lo,
5253
+ parse: uo,
5250
5254
  objectSize: () => 0,
5251
5255
  logger: this._log,
5252
5256
  saveThrottleMs: 100,
@@ -5409,19 +5413,19 @@ class fo {
5409
5413
  v,
5410
5414
  r,
5411
5415
  this.config.useDateObjects
5412
- ), { store: Wn, attrsStore: Gn } = this._applyOptimisticUpdates(
5416
+ ), { store: Gn, attrsStore: Bn } = this._applyOptimisticUpdates(
5413
5417
  ee,
5414
5418
  L,
5415
5419
  w,
5416
5420
  g
5417
- ), Bn = (St = (mt = m == null ? void 0 : m[0]) == null ? void 0 : mt.data) == null ? void 0 : St["page-info"], Hn = (Ot = (At = m == null ? void 0 : m[0]) == null ? void 0 : At.data) == null ? void 0 : Ot.aggregate;
5421
+ ), Hn = (St = (mt = m == null ? void 0 : m[0]) == null ? void 0 : mt.data) == null ? void 0 : St["page-info"], Jn = (Ot = (At = m == null ? void 0 : m[0]) == null ? void 0 : At.data) == null ? void 0 : Ot.aggregate;
5418
5422
  return {
5419
5423
  q: A,
5420
5424
  hash: O,
5421
- store: Wn,
5422
- attrsStore: Gn,
5423
- pageInfo: Bn,
5424
- aggregate: Hn
5425
+ store: Gn,
5426
+ attrsStore: Bn,
5427
+ pageInfo: Hn,
5428
+ aggregate: Jn
5425
5429
  };
5426
5430
  });
5427
5431
  b.forEach(
@@ -5633,7 +5637,7 @@ class fo {
5633
5637
  const s = C(e), i = this._startQuerySub(e, s);
5634
5638
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
5635
5639
  () => r.reject(new Error("Query timed out")),
5636
- Xi
5640
+ eo
5637
5641
  ), r.promise;
5638
5642
  }
5639
5643
  _completeQueryOnce(e, t, r) {
@@ -5701,7 +5705,7 @@ class fo {
5701
5705
  a = !0;
5702
5706
  continue;
5703
5707
  }
5704
- const g = a ? zs(o, h) : h;
5708
+ const g = a ? Vs(o, h) : h;
5705
5709
  f.push(g);
5706
5710
  }
5707
5711
  return a ? f : l;
@@ -5775,7 +5779,7 @@ class fo {
5775
5779
  _applyOptimisticUpdates(e, t, r, s) {
5776
5780
  for (const [i, o] of r)
5777
5781
  if (!o["tx-id"] || s && o["tx-id"] > s) {
5778
- const a = zr(e, t, o["tx-steps"]);
5782
+ const a = Vr(e, t, o["tx-steps"]);
5779
5783
  e = a.store, t = a.attrsStore;
5780
5784
  }
5781
5785
  return { store: e, attrsStore: t };
@@ -5904,7 +5908,7 @@ class fo {
5904
5908
  return;
5905
5909
  }
5906
5910
  const e = this._transport;
5907
- this._transport = so({
5911
+ this._transport = io({
5908
5912
  transportType: this._transportType,
5909
5913
  appId: this.config.appId,
5910
5914
  apiURI: this.config.apiURI,
@@ -6121,7 +6125,7 @@ class fo {
6121
6125
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(t);
6122
6126
  }
6123
6127
  sendMagicCode({ email: e }) {
6124
- return mi({
6128
+ return Si({
6125
6129
  apiURI: this.config.apiURI,
6126
6130
  appId: this.config.appId,
6127
6131
  email: e
@@ -6129,7 +6133,7 @@ class fo {
6129
6133
  }
6130
6134
  async signInWithMagicCode({ email: e, code: t }) {
6131
6135
  var o;
6132
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Si({
6136
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await Ai({
6133
6137
  apiURI: this.config.apiURI,
6134
6138
  appId: this.config.appId,
6135
6139
  email: e,
@@ -6139,7 +6143,7 @@ class fo {
6139
6143
  return await this.changeCurrentUser(i.user), i;
6140
6144
  }
6141
6145
  async signInWithCustomToken(e) {
6142
- const t = await Ai({
6146
+ const t = await Oi({
6143
6147
  apiURI: this.config.apiURI,
6144
6148
  appId: this.config.appId,
6145
6149
  refreshToken: e
@@ -6147,7 +6151,7 @@ class fo {
6147
6151
  return await this.changeCurrentUser(t.user), t;
6148
6152
  }
6149
6153
  async signInAsGuest() {
6150
- const e = await Oi({
6154
+ const e = await vi({
6151
6155
  apiURI: this.config.apiURI,
6152
6156
  appId: this.config.appId
6153
6157
  });
@@ -6162,7 +6166,7 @@ class fo {
6162
6166
  this._log.info("[auth-invalidate] skipped invalidateToken");
6163
6167
  return;
6164
6168
  }
6165
- ki({
6169
+ Ei({
6166
6170
  apiURI: this.config.apiURI,
6167
6171
  appId: this.config.appId,
6168
6172
  refreshToken: r
@@ -6215,7 +6219,7 @@ class fo {
6215
6219
  */
6216
6220
  async signInWithIdToken({ idToken: e, clientName: t, nonce: r }) {
6217
6221
  var a;
6218
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await vi({
6222
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await ki({
6219
6223
  apiURI: this.config.apiURI,
6220
6224
  appId: this.config.appId,
6221
6225
  idToken: e,
@@ -6258,7 +6262,7 @@ class fo {
6258
6262
  getPresence(e, t, r = {}) {
6259
6263
  const s = this._rooms[t], i = this._presence[t];
6260
6264
  return !s || !i || !i.result ? null : {
6261
- ...ji(i.result, r, this._sessionId),
6265
+ ...$i(i.result, r, this._sessionId),
6262
6266
  isLoading: !s.isConnected,
6263
6267
  error: s.error
6264
6268
  };
@@ -6320,7 +6324,7 @@ class fo {
6320
6324
  }
6321
6325
  _notifyPresenceSub(e, t) {
6322
6326
  const r = this.getPresence("", e, t);
6323
- r && (t.prev && !$i(r, t.prev) || (t.prev = r, t.cb(r)));
6327
+ r && (t.prev && !Di(r, t.prev) || (t.prev = r, t.cb(r)));
6324
6328
  }
6325
6329
  _patchPresencePeers(e, t) {
6326
6330
  var o, a, c;
@@ -6333,7 +6337,7 @@ class fo {
6333
6337
  for (let [l, d, f] of t)
6334
6338
  switch (d) {
6335
6339
  case "+":
6336
- dr(u, l, f);
6340
+ fr(u, l, f);
6337
6341
  break;
6338
6342
  case "r":
6339
6343
  Ct(u, l, f);
@@ -6396,7 +6400,7 @@ class fo {
6396
6400
  async uploadFile(e, t, r) {
6397
6401
  var o;
6398
6402
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
6399
- return Ei({
6403
+ return Ii({
6400
6404
  ...r,
6401
6405
  apiURI: this.config.apiURI,
6402
6406
  appId: this.config.appId,
@@ -6408,7 +6412,7 @@ class fo {
6408
6412
  async deleteFile(e) {
6409
6413
  var i;
6410
6414
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
6411
- return await Ii({
6415
+ return await Mi({
6412
6416
  apiURI: this.config.apiURI,
6413
6417
  appId: this.config.appId,
6414
6418
  path: e,
@@ -6419,18 +6423,18 @@ class fo {
6419
6423
  // ---------------------------------
6420
6424
  async upload(e, t) {
6421
6425
  var c;
6422
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await Mi({
6426
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || t.name, o = await Ci({
6423
6427
  apiURI: this.config.apiURI,
6424
6428
  appId: this.config.appId,
6425
6429
  fileName: i,
6426
6430
  refreshToken: s
6427
6431
  });
6428
- return await Ci(o, t);
6432
+ return await Pi(o, t);
6429
6433
  }
6430
6434
  async getDownloadUrl(e) {
6431
6435
  var i;
6432
6436
  const t = await this.getCurrentUser(), r = (i = t == null ? void 0 : t.user) == null ? void 0 : i.refresh_token;
6433
- return await Pi({
6437
+ return await ji({
6434
6438
  apiURI: this.config.apiURI,
6435
6439
  appId: this.config.appId,
6436
6440
  path: e,
@@ -6438,9 +6442,9 @@ class fo {
6438
6442
  });
6439
6443
  }
6440
6444
  }
6441
- function ho(n, e) {
6445
+ function po(n, e) {
6442
6446
  return new xe(
6443
- Qn(n, e),
6447
+ Wn(n, e),
6444
6448
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
6445
6449
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
6446
6450
  // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
@@ -6450,28 +6454,28 @@ function ho(n, e) {
6450
6454
  void 0
6451
6455
  );
6452
6456
  }
6453
- function po(n) {
6457
+ function yo(n) {
6454
6458
  return new Re(n, {});
6455
6459
  }
6456
- function yo() {
6460
+ function bo() {
6457
6461
  return new D("string", !0, !1);
6458
6462
  }
6459
- function bo() {
6463
+ function go() {
6460
6464
  return new D("number", !0, !1);
6461
6465
  }
6462
- function go() {
6466
+ function _o() {
6463
6467
  return new D("boolean", !0, !1);
6464
6468
  }
6465
- function _o() {
6469
+ function wo() {
6466
6470
  return new D("date", !0, !1);
6467
6471
  }
6468
- function wo() {
6472
+ function To() {
6469
6473
  return new D("json", !0, !1);
6470
6474
  }
6471
- function To() {
6475
+ function mo() {
6472
6476
  return new D("json", !0, !1);
6473
6477
  }
6474
- function Qn(n, e) {
6478
+ function Wn(n, e) {
6475
6479
  var s, i, o, a;
6476
6480
  const t = { fwd: {}, rev: {} };
6477
6481
  for (const c of Object.values(e))
@@ -6492,14 +6496,14 @@ function Qn(n, e) {
6492
6496
  ])
6493
6497
  );
6494
6498
  }
6495
- function mo({
6499
+ function So({
6496
6500
  entities: n,
6497
6501
  links: e,
6498
6502
  rooms: t
6499
6503
  }) {
6500
6504
  const r = e ?? {}, s = t ?? {};
6501
6505
  return new xe(
6502
- Qn(n, r),
6506
+ Wn(n, r),
6503
6507
  // (XXX): LinksDef<any> stems from TypeScript's inability to reconcile the
6504
6508
  // type EntitiesWithLinks<EntitiesWithoutLinks, Links> with
6505
6509
  // EntitiesWithoutLinks. TypeScript is strict about ensuring that types are
@@ -6511,21 +6515,21 @@ function mo({
6511
6515
  }
6512
6516
  const E = {
6513
6517
  // constructs
6514
- graph: ho,
6515
- schema: mo,
6516
- entity: po,
6518
+ graph: po,
6519
+ schema: So,
6520
+ entity: yo,
6517
6521
  // value types
6518
- string: yo,
6519
- number: bo,
6520
- boolean: go,
6521
- date: _o,
6522
- json: wo,
6523
- any: To
6522
+ string: bo,
6523
+ number: go,
6524
+ boolean: _o,
6525
+ date: wo,
6526
+ json: To,
6527
+ any: mo
6524
6528
  };
6525
6529
  let me;
6526
- function So(n, e) {
6530
+ function Ao(n, e) {
6527
6531
  me == null || me.dispose();
6528
- const t = Io(e), r = vo(e, a), s = Oo(Ao(n));
6532
+ const t = Mo(e), r = ko(e, a), s = vo(Oo(n));
6529
6533
  function i(l) {
6530
6534
  var d;
6531
6535
  l.source === s.element.contentWindow && ((d = l.data) == null ? void 0 : d.type) === "close" && t.isVisible() && a();
@@ -6547,10 +6551,10 @@ function So(n, e) {
6547
6551
  }
6548
6552
  return u();
6549
6553
  }
6550
- function Ao(n) {
6551
- return `${Tt || xn ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
6552
- }
6553
6554
  function Oo(n) {
6555
+ return `${Tt || Un ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${n}`;
6556
+ }
6557
+ function vo(n) {
6554
6558
  const e = document.createElement("iframe");
6555
6559
  return e.src = n, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6556
6560
  width: "100%",
@@ -6559,7 +6563,7 @@ function Oo(n) {
6559
6563
  border: "none"
6560
6564
  }), { element: e };
6561
6565
  }
6562
- function vo(n, e) {
6566
+ function ko(n, e) {
6563
6567
  const t = `
6564
6568
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6565
6569
  <rect width="512" height="512" fill="black"/>
@@ -6569,7 +6573,7 @@ function vo(n, e) {
6569
6573
  return r.innerHTML = t, r.className = "instant-devtool-toggler", Object.assign(r.style, {
6570
6574
  // pos
6571
6575
  position: "fixed",
6572
- ...ko(n.position),
6576
+ ...Eo(n.position),
6573
6577
  height: "32px",
6574
6578
  width: "32px",
6575
6579
  // layout
@@ -6584,7 +6588,7 @@ function vo(n, e) {
6584
6588
  cursor: "pointer"
6585
6589
  }), r.addEventListener("click", e), { element: r };
6586
6590
  }
6587
- function ko(n) {
6591
+ function Eo(n) {
6588
6592
  switch (n) {
6589
6593
  case "bottom-left":
6590
6594
  return { bottom: "24px", left: "24px" };
@@ -6596,7 +6600,7 @@ function ko(n) {
6596
6600
  return { top: "24px", left: "24px" };
6597
6601
  }
6598
6602
  }
6599
- function Eo(n) {
6603
+ function Io(n) {
6600
6604
  switch (n) {
6601
6605
  case "bottom-left":
6602
6606
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6608,11 +6612,11 @@ function Eo(n) {
6608
6612
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6609
6613
  }
6610
6614
  }
6611
- function Io(n) {
6615
+ function Mo(n) {
6612
6616
  const e = document.createElement("div");
6613
6617
  Object.assign(e.style, {
6614
6618
  position: "fixed",
6615
- ...Eo(n.position),
6619
+ ...Io(n.position),
6616
6620
  display: "block",
6617
6621
  borderRadius: "4px",
6618
6622
  border: "1px #ccc solid",
@@ -6625,7 +6629,7 @@ function Io(n) {
6625
6629
  }
6626
6630
  return { element: e, isVisible: t };
6627
6631
  }
6628
- function Mo(n, e) {
6632
+ function Co(n, e) {
6629
6633
  return e && e.refresh_token ? new Response(JSON.stringify({ ok: !0 }), {
6630
6634
  headers: {
6631
6635
  "Content-Type": "application/json",
@@ -6646,7 +6650,7 @@ function Se(n, e) {
6646
6650
  headers: { "Content-Type": "application/json" }
6647
6651
  });
6648
6652
  }
6649
- const zo = (n) => ({
6653
+ const Qo = (n) => ({
6650
6654
  POST: async (e) => {
6651
6655
  let t;
6652
6656
  try {
@@ -6660,12 +6664,12 @@ const zo = (n) => ({
6660
6664
  return Se(403, "App ID mismatch");
6661
6665
  switch (t.type) {
6662
6666
  case "sync-user":
6663
- return Mo(n, t.user ?? null);
6667
+ return Co(n, t.user ?? null);
6664
6668
  default:
6665
6669
  return Se(400, `Unknown type: ${t.type}`);
6666
6670
  }
6667
6671
  }
6668
- }), Vo = (n) => {
6672
+ }), Wo = (n) => {
6669
6673
  var i, o, a, c, u, l;
6670
6674
  const e = {};
6671
6675
  for (const [d, f] of Object.entries(n.entities)) {
@@ -6766,8 +6770,8 @@ const zo = (n) => ({
6766
6770
  links: t,
6767
6771
  rooms: r
6768
6772
  });
6769
- }, Co = typeof window > "u" || "Deno" in globalThis;
6770
- class Qo {
6773
+ }, Po = typeof window > "u" || "Deno" in globalThis;
6774
+ class Go {
6771
6775
  constructor(e) {
6772
6776
  p(this, "params");
6773
6777
  p(this, "db");
@@ -6786,7 +6790,7 @@ class Qo {
6786
6790
  data: t,
6787
6791
  promise: null,
6788
6792
  error: null
6789
- }), Co || (this.db._reactor.attrs || this.db._reactor._setAttrs(t.attrs), this.db._reactor._addQueryData(
6793
+ }), Po || (this.db._reactor.attrs || this.db._reactor._setAttrs(t.attrs), this.db._reactor._addQueryData(
6790
6794
  t.query,
6791
6795
  t,
6792
6796
  !!this.db._reactor.config.schema
@@ -6868,7 +6872,7 @@ class Qo {
6868
6872
  });
6869
6873
  p(this, "hashQuery", (e, t) => {
6870
6874
  e && t && "ruleParams" in t && (e = { $$ruleParams: t.ruleParams, ...e });
6871
- const r = e ? xo(e) : null;
6875
+ const r = e ? Uo(e) : null;
6872
6876
  return { hash: C(r), query: r };
6873
6877
  });
6874
6878
  // Run by the server to get triples and attrs
@@ -6913,22 +6917,22 @@ class Qo {
6913
6917
  this.params = e, this.db = e.db, this.resultMap = /* @__PURE__ */ new Map();
6914
6918
  }
6915
6919
  }
6916
- const Po = {
6920
+ const jo = {
6917
6921
  apiURI: "https://api.instantdb.com",
6918
6922
  websocketURI: "wss://api.instantdb.com/runtime/session"
6919
6923
  };
6920
- function jo() {
6924
+ function $o() {
6921
6925
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6922
6926
  }
6923
- function $o() {
6927
+ function Do() {
6924
6928
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6925
6929
  }
6926
6930
  function ot(n) {
6927
6931
  const e = n.__adminToken;
6928
6932
  return n.appId + "_" + (n.websocketURI || "default_ws_uri") + "_" + (n.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + n.useDateObjects;
6929
6933
  }
6930
- const at = $o(), tn = jo();
6931
- class Do {
6934
+ const at = Do(), tn = $o();
6935
+ class Ro {
6932
6936
  constructor(e) {
6933
6937
  /**
6934
6938
  * Sends a magic code to the user's email address.
@@ -7044,7 +7048,7 @@ class Do {
7044
7048
  this.db = e;
7045
7049
  }
7046
7050
  }
7047
- class Ro {
7051
+ class xo {
7048
7052
  constructor(e) {
7049
7053
  /**
7050
7054
  * Uploads file at the provided path.
@@ -7092,16 +7096,16 @@ class Ro {
7092
7096
  this.db = e;
7093
7097
  }
7094
7098
  }
7095
- function xo(n) {
7099
+ function Uo(n) {
7096
7100
  return JSON.parse(JSON.stringify(n));
7097
7101
  }
7098
- class Uo {
7102
+ class Lo {
7099
7103
  constructor(e) {
7100
7104
  p(this, "_reactor");
7101
7105
  p(this, "auth");
7102
7106
  p(this, "storage");
7103
- p(this, "tx", Mn());
7104
- this._reactor = e, this.auth = new Do(this._reactor), this.storage = new Ro(this._reactor);
7107
+ p(this, "tx", Cn());
7108
+ this._reactor = e, this.auth = new Ro(this._reactor), this.storage = new xo(this._reactor);
7105
7109
  }
7106
7110
  /**
7107
7111
  * Use this to write data! You can create, update, delete, and link objects
@@ -7288,10 +7292,10 @@ function nn(n) {
7288
7292
  const t = C(n);
7289
7293
  return tn.set(n, t), t;
7290
7294
  }
7291
- function Lo(n, e) {
7295
+ function No(n, e) {
7292
7296
  return nn(n._reactor.config.schema) !== nn(e);
7293
7297
  }
7294
- function No(n, e, t, r, s) {
7298
+ function Fo(n, e, t, r, s) {
7295
7299
  var u;
7296
7300
  const i = {
7297
7301
  ...n,
@@ -7299,21 +7303,21 @@ function No(n, e, t, r, s) {
7299
7303
  useDateObjects: n.useDateObjects ?? !1
7300
7304
  }, o = at[ot(i)];
7301
7305
  if (o)
7302
- return Lo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7303
- const a = new fo(
7306
+ return No(o, i.schema) && o._reactor.updateSchema(i.schema), o;
7307
+ const a = new ho(
7304
7308
  {
7305
- ...Po,
7309
+ ...jo,
7306
7310
  ...i,
7307
7311
  cardinalityInference: !!i.schema
7308
7312
  },
7309
- e || $n,
7310
- t || Dn,
7311
- { ...r || {}, "@instantdb/core": Ln },
7313
+ e || Dn,
7314
+ t || Rn,
7315
+ { ...r || {}, "@instantdb/core": Nn },
7312
7316
  s
7313
- ), c = new Uo(a);
7314
- return at[ot(i)] = c, Fo(i.appId, i.devtool), c;
7317
+ ), c = new Lo(a);
7318
+ return at[ot(i)] = c, Ko(i.appId, i.devtool), c;
7315
7319
  }
7316
- function Fo(n, e) {
7320
+ function Ko(n, e) {
7317
7321
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
7318
7322
  return;
7319
7323
  const t = {
@@ -7321,37 +7325,38 @@ function Fo(n, e) {
7321
7325
  allowedHosts: ["localhost"],
7322
7326
  ...typeof e == "object" ? e : {}
7323
7327
  };
7324
- t.allowedHosts.includes(window.location.hostname) && So(n, t);
7328
+ t.allowedHosts.includes(window.location.hostname) && Ao(n, t);
7325
7329
  }
7326
- const Wo = No, Go = jn;
7330
+ const Bo = Fo, Ho = $n;
7327
7331
  export {
7328
- Do as Auth,
7329
- Qo as FrameworkClient,
7330
- $n as IndexedDBStorage,
7332
+ Ro as Auth,
7333
+ Go as FrameworkClient,
7334
+ Dn as IndexedDBStorage,
7331
7335
  De as InstantAPIError,
7332
- Uo as InstantCoreDatabase,
7336
+ Lo as InstantCoreDatabase,
7333
7337
  ye as InstantError,
7334
7338
  k as QueryValidationError,
7335
- Ro as Storage,
7336
- Go as StorageInterface,
7337
- jn as StoreInterface,
7338
- Yi as SyncTableCallbackEventType,
7339
+ xo as Storage,
7340
+ Ho as StorageInterface,
7341
+ $n as StoreInterface,
7342
+ Zi as SyncTableCallbackEventType,
7339
7343
  K as TransactionValidationError,
7340
- Dn as WindowNetworkListener,
7341
- xo as coerceQuery,
7344
+ Rn as WindowNetworkListener,
7345
+ Uo as coerceQuery,
7342
7346
  je as coerceToDate,
7343
- zo as createInstantRouteHandler,
7344
- qs as getOps,
7347
+ Qo as createInstantRouteHandler,
7348
+ zs as getOps,
7345
7349
  E as i,
7346
7350
  P as id,
7347
- No as init,
7348
- Wo as init_experimental,
7349
- Fs as lookup,
7350
- Vo as parseSchemaFromJSON,
7351
- qo as tx,
7352
- Mn as txInit,
7351
+ Fo as init,
7352
+ Bo as init_experimental,
7353
+ Ks as lookup,
7354
+ Wo as parseSchemaFromJSON,
7355
+ zo as setInstantWarningsEnabled,
7356
+ Vo as tx,
7357
+ Cn as txInit,
7353
7358
  Bt as validateQuery,
7354
- zi as validateTransactions,
7355
- Ln as version,
7359
+ Vi as validateTransactions,
7360
+ Nn as version,
7356
7361
  C as weakHash
7357
7362
  };