@instantdb/core 0.22.89-experimental.uuidfix.20281951052.1 → 0.22.89-experimental.uuidfix.20282483875.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/__tests__/src/Reactor.test.js +1 -1
  2. package/dist/commonjs/Reactor.js +10 -10
  3. package/dist/commonjs/Reactor.js.map +1 -1
  4. package/dist/commonjs/SyncTable.js +3 -3
  5. package/dist/commonjs/SyncTable.js.map +1 -1
  6. package/dist/commonjs/index.d.ts +1 -1
  7. package/dist/commonjs/index.d.ts.map +1 -1
  8. package/dist/commonjs/index.js +2 -2
  9. package/dist/commonjs/index.js.map +1 -1
  10. package/dist/commonjs/instaml.js +8 -8
  11. package/dist/commonjs/instaml.js.map +1 -1
  12. package/dist/commonjs/instaql.js +2 -2
  13. package/dist/commonjs/instaql.js.map +1 -1
  14. package/dist/commonjs/utils/{uuid.d.ts → id.d.ts} +1 -1
  15. package/dist/commonjs/utils/id.d.ts.map +1 -0
  16. package/dist/commonjs/utils/{uuid.js → id.js} +1 -1
  17. package/dist/commonjs/utils/id.js.map +1 -0
  18. package/dist/esm/Reactor.js +1 -1
  19. package/dist/esm/Reactor.js.map +1 -1
  20. package/dist/esm/SyncTable.js +1 -1
  21. package/dist/esm/SyncTable.js.map +1 -1
  22. package/dist/esm/index.d.ts +1 -1
  23. package/dist/esm/index.d.ts.map +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/instaml.js +1 -1
  27. package/dist/esm/instaml.js.map +1 -1
  28. package/dist/esm/instaql.js +1 -1
  29. package/dist/esm/instaql.js.map +1 -1
  30. package/dist/esm/utils/{uuid.d.ts → id.d.ts} +1 -1
  31. package/dist/esm/utils/id.d.ts.map +1 -0
  32. package/dist/esm/utils/{uuid.js → id.js} +1 -1
  33. package/dist/esm/utils/id.js.map +1 -0
  34. package/dist/standalone/index.js +275 -276
  35. package/dist/standalone/index.umd.cjs +3 -3
  36. package/package.json +4 -3
  37. package/src/Reactor.js +1 -1
  38. package/src/SyncTable.ts +1 -1
  39. package/src/index.ts +1 -1
  40. package/src/instaml.ts +1 -1
  41. package/src/instaql.ts +1 -1
  42. package/dist/commonjs/utils/uuid.d.ts.map +0 -1
  43. package/dist/commonjs/utils/uuid.js.map +0 -1
  44. package/dist/esm/utils/uuid.d.ts.map +0 -1
  45. package/dist/esm/utils/uuid.js.map +0 -1
  46. /package/src/utils/{uuid.ts → id.ts} +0 -0
@@ -1907,39 +1907,38 @@ function Xr() {
1907
1907
  const es = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Et = { randomUUID: es };
1908
1908
  function ts(t, e, n) {
1909
1909
  var s;
1910
+ if (Et.randomUUID && !t)
1911
+ return Et.randomUUID();
1910
1912
  t = t || {};
1911
1913
  const r = t.random ?? ((s = t.rng) == null ? void 0 : s.call(t)) ?? Xr();
1912
1914
  if (r.length < 16)
1913
1915
  throw new Error("Random bytes length must be >= 16");
1914
1916
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Yr(r);
1915
1917
  }
1916
- function ns(t, e, n) {
1917
- return Et.randomUUID ? Et.randomUUID() : ts(t);
1918
- }
1919
1918
  function It(t) {
1920
1919
  const e = t.replace(/-/g, ""), n = [];
1921
1920
  for (let r = 0; r < e.length; r += 2)
1922
1921
  n.push(parseInt(e.substring(r, r + 2), 16));
1923
1922
  return n;
1924
1923
  }
1925
- function rs(t, e) {
1924
+ function ns(t, e) {
1926
1925
  for (let n = 0; n < t.length; n++) {
1927
1926
  if (t[n] < e[n]) return -1;
1928
1927
  if (t[n] > e[n]) return 1;
1929
1928
  }
1930
1929
  return 0;
1931
1930
  }
1932
- function ss(t, e) {
1933
- return rs(It(t), It(e));
1931
+ function rs(t, e) {
1932
+ return ns(It(t), It(e));
1934
1933
  }
1935
1934
  function I() {
1936
- return ns();
1935
+ return ts();
1937
1936
  }
1938
- function is(t, e) {
1937
+ function ss(t, e) {
1939
1938
  return t.localeCompare(e);
1940
1939
  }
1941
- function os() {
1942
- let t = is;
1940
+ function is() {
1941
+ let t = ss;
1943
1942
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1944
1943
  try {
1945
1944
  t = Intl.Collator("en-US").compare;
@@ -1947,10 +1946,10 @@ function os() {
1947
1946
  }
1948
1947
  return t;
1949
1948
  }
1950
- const as = os();
1951
- let cs = 0;
1949
+ const os = is();
1950
+ let as = 0;
1952
1951
  function ue(t) {
1953
- return Ce(`_${t}`, cs++);
1952
+ return Ce(`_${t}`, as++);
1954
1953
  }
1955
1954
  function Ce(t, e) {
1956
1955
  return `?${t}-${e}`;
@@ -1960,24 +1959,24 @@ class ne extends Error {
1960
1959
  super(e), this.name = "AttrNotFoundError";
1961
1960
  }
1962
1961
  }
1963
- function us(t, e) {
1962
+ function cs(t, e) {
1964
1963
  const n = wn(t, e);
1965
1964
  if (!n)
1966
1965
  throw new ne(`Could not find id attr for ${e}`);
1967
1966
  return n;
1968
1967
  }
1969
1968
  function Ct(t, e, n, r) {
1970
- return [ls(t, e, n, r)];
1969
+ return [us(t, e, n, r)];
1971
1970
  }
1972
- function ls(t, e, n, r) {
1971
+ function us(t, e, n, r) {
1973
1972
  return [
1974
1973
  t(n, r),
1975
- us(e, n).id,
1974
+ cs(e, n).id,
1976
1975
  t(n, r),
1977
1976
  t("time", r)
1978
1977
  ];
1979
1978
  }
1980
- function fs(t, e, n) {
1979
+ function ls(t, e, n) {
1981
1980
  return t.map((r) => r === e ? n : r);
1982
1981
  }
1983
1982
  function mn(t, e, n, r, s) {
@@ -2012,7 +2011,7 @@ function Mt(t, e) {
2012
2011
  return typeof o != "string" ? !1 : s.test(o);
2013
2012
  };
2014
2013
  }
2015
- function ds(t, e) {
2014
+ function fs(t, e) {
2016
2015
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
2017
2016
  return e;
2018
2017
  const n = t["checked-data-type"] === "date";
@@ -2072,7 +2071,7 @@ function ds(t, e) {
2072
2071
  }
2073
2072
  return e;
2074
2073
  }
2075
- function hs(t, e, n, r, s, i) {
2074
+ function ds(t, e, n, r, s, i) {
2076
2075
  const o = E(e, n, s), a = Z(
2077
2076
  e,
2078
2077
  n,
@@ -2098,11 +2097,11 @@ function hs(t, e, n, r, s, i) {
2098
2097
  return o ? [
2099
2098
  t(n, r),
2100
2099
  c.id,
2101
- ds(c, i),
2100
+ fs(c, i),
2102
2101
  ue("time")
2103
2102
  ] : [i, c.id, t(n, r), ue("time")];
2104
2103
  }
2105
- function ps(t, e, n, r, s) {
2104
+ function hs(t, e, n, r, s) {
2106
2105
  const [i, o, a] = s.reduce(
2107
2106
  (c, u) => {
2108
2107
  const [l, f, d] = c, [h, p, y] = mn(
@@ -2119,13 +2118,13 @@ function ps(t, e, n, r, s) {
2119
2118
  return [i, o, a];
2120
2119
  }
2121
2120
  function Be(t, e, n, r, s, i) {
2122
- const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = ps(
2121
+ const o = s.slice(0, s.length - 1), a = s[s.length - 1], [c, u, l] = hs(
2123
2122
  t,
2124
2123
  e,
2125
2124
  n,
2126
2125
  r,
2127
2126
  o
2128
- ), f = hs(
2127
+ ), f = ds(
2129
2128
  t,
2130
2129
  e,
2131
2130
  c,
@@ -2135,16 +2134,16 @@ function Be(t, e, n, r, s, i) {
2135
2134
  );
2136
2135
  return l.concat([f]);
2137
2136
  }
2138
- function ys(t, e) {
2137
+ function ps(t, e) {
2139
2138
  return e ? [e].concat(t) : t;
2140
2139
  }
2141
- function bs([t, e]) {
2140
+ function ys([t, e]) {
2142
2141
  return t === "or" && Array.isArray(e);
2143
2142
  }
2144
- function _s([t, e]) {
2143
+ function bs([t, e]) {
2145
2144
  return t === "and" && Array.isArray(e);
2146
2145
  }
2147
- function gs(t, e, n) {
2146
+ function _s(t, e, n) {
2148
2147
  return (r, s) => {
2149
2148
  const i = t(r, s);
2150
2149
  return e == i ? i : `${i}-${n}`;
@@ -2152,19 +2151,19 @@ function gs(t, e, n) {
2152
2151
  }
2153
2152
  function Pt(t, e, n, r, s, i) {
2154
2153
  const o = t(r, s), a = i.map((c, u) => {
2155
- const l = gs(t, o, u);
2154
+ const l = _s(t, o, u);
2156
2155
  return Sn(l, n, r, s, c);
2157
2156
  });
2158
2157
  return { [e]: { patterns: a, joinSym: o } };
2159
2158
  }
2160
- function ws(t) {
2159
+ function gs(t) {
2161
2160
  const e = [];
2162
2161
  for (let n = 1; n <= t.length; n++)
2163
2162
  e.push(t.slice(0, n));
2164
2163
  return e;
2165
2164
  }
2166
2165
  function jt(t, e, n, r, s) {
2167
- return ws(s).map(
2166
+ return gs(s).map(
2168
2167
  (i) => Be(t, e, n, r, i, {
2169
2168
  $isNull: !0
2170
2169
  })
@@ -2172,9 +2171,9 @@ function jt(t, e, n, r, s) {
2172
2171
  }
2173
2172
  function Sn(t, e, n, r, s) {
2174
2173
  return Object.entries(s).flatMap(([i, o]) => {
2175
- if (bs([i, o]))
2174
+ if (ys([i, o]))
2176
2175
  return Pt(t, "or", e, n, r, o);
2177
- if (_s([i, o]))
2176
+ if (bs([i, o]))
2178
2177
  return Pt(t, "and", e, n, r, o);
2179
2178
  if (i === "$entityIdStartsWith")
2180
2179
  return [];
@@ -2219,31 +2218,31 @@ function Sn(t, e, n, r, s) {
2219
2218
  ] : Be(t, e, n, r, a, o);
2220
2219
  });
2221
2220
  }
2222
- function Ts(t, e, n, r) {
2221
+ function ws(t, e, n, r) {
2223
2222
  const s = Ce;
2224
2223
  return r ? Sn(s, t, e, n, r).concat(Ct(s, t, e, n)) : Ct(s, t, e, n);
2225
2224
  }
2226
- function ms(t, e, n) {
2225
+ function Ts(t, e, n) {
2227
2226
  return [t(e, n), t("time", n)];
2228
2227
  }
2229
- function Ss(t, e, n, r, s, i) {
2228
+ function ms(t, e, n, r, s, i) {
2230
2229
  const [o, a, c, u, l] = mn(
2231
2230
  t,
2232
2231
  e,
2233
2232
  n,
2234
2233
  r,
2235
2234
  s
2236
- ), f = fs(c, t(n, r), i);
2235
+ ), f = ls(c, t(n, r), i);
2237
2236
  return [o, a, f, u, l];
2238
2237
  }
2239
- function As(t, e, n, { etype: r, level: s, form: i }, o) {
2238
+ function Ss(t, e, n, { etype: r, level: s, form: i }, o) {
2240
2239
  const a = Object.keys(i).filter((c) => c !== "$");
2241
2240
  return a.length ? Object.entries(o).map(function([u, l]) {
2242
2241
  return a.map(function(h) {
2243
2242
  var y, b, g;
2244
2243
  const p = !!(e.cardinalityInference && ((g = (b = (y = n.linkIndex) == null ? void 0 : y[r]) == null ? void 0 : b[h]) != null && g.isSingular));
2245
2244
  try {
2246
- const [_, T, A] = Ss(
2245
+ const [_, T, A] = ms(
2247
2246
  t,
2248
2247
  n,
2249
2248
  r,
@@ -2267,11 +2266,11 @@ function As(t, e, n, { etype: r, level: s, form: i }, o) {
2267
2266
  }, l);
2268
2267
  }) : Object.values(o);
2269
2268
  }
2270
- function vs(t, e, n) {
2271
- return n === "string" ? as(t, e) : t > e ? 1 : -1;
2269
+ function As(t, e, n) {
2270
+ return n === "string" ? os(t, e) : t > e ? 1 : -1;
2272
2271
  }
2273
2272
  function ae(t, e, n, r, s) {
2274
- return e === r || e == null && r == null ? ss(t, n) : r == null ? 1 : e == null ? -1 : vs(e, r, s);
2273
+ return e === r || e == null && r == null ? rs(t, n) : r == null ? 1 : e == null ? -1 : As(e, r, s);
2275
2274
  }
2276
2275
  function ke([t, e], [n, r], s) {
2277
2276
  return ae(t, e, n, r, s);
@@ -2279,7 +2278,7 @@ function ke([t, e], [n, r], s) {
2279
2278
  function He(t) {
2280
2279
  return t == null ? t : new Date(t).getTime();
2281
2280
  }
2282
- function Os(t, e, n, r) {
2281
+ function vs(t, e, n, r) {
2283
2282
  var p;
2284
2283
  const [s, i, o, a] = t, c = n === "desc" ? 1 : -1;
2285
2284
  if (((p = e["forward-identity"]) == null ? void 0 : p[2]) === "id")
@@ -2287,21 +2286,21 @@ function Os(t, e, n, r) {
2287
2286
  const [u, l] = r, f = e["checked-data-type"], d = f === "date" ? He(l) : l, h = f === "date" ? He(o) : o;
2288
2287
  return ke([u, d], [s, h], f) === c;
2289
2288
  }
2290
- function ks(t, e) {
2289
+ function Os(t, e) {
2291
2290
  const n = e[1];
2292
2291
  return t.getAttr(n);
2293
2292
  }
2294
- function Es(t, e, n) {
2293
+ function ks(t, e, n) {
2295
2294
  const r = Object.keys(n)[0];
2296
2295
  return E(t, e, r);
2297
2296
  }
2298
- function Is(t, e, n, r) {
2297
+ function Es(t, e, n, r) {
2299
2298
  if (n)
2300
- return ks(t, n);
2299
+ return Os(t, n);
2301
2300
  if (r)
2302
- return Es(t, e, r);
2301
+ return ks(t, e, r);
2303
2302
  }
2304
- function Cs(t, e, n) {
2303
+ function Is(t, e, n) {
2305
2304
  var s, i;
2306
2305
  if (!Array.isArray(n.fields))
2307
2306
  return Ur(t, e);
@@ -2316,11 +2315,11 @@ function Cs(t, e, n) {
2316
2315
  }
2317
2316
  return r;
2318
2317
  }
2319
- function Ms(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2318
+ function Cs(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2320
2319
  var p, y;
2321
- const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Ps(i);
2320
+ const o = (p = i == null ? void 0 : i.$) == null ? void 0 : p.order, a = An(i), c = Ms(i);
2322
2321
  let u = Br(t, s);
2323
- const l = r == null ? void 0 : r["start-cursor"], f = Is(e, n, l, o);
2322
+ const l = r == null ? void 0 : r["start-cursor"], f = Es(e, n, l, o);
2324
2323
  if (f && ((y = f == null ? void 0 : f["forward-identity"]) == null ? void 0 : y[2]) !== "id") {
2325
2324
  const b = f["checked-data-type"] === "date", g = f.id;
2326
2325
  u = u.map(([_]) => {
@@ -2337,17 +2336,17 @@ function Ms(t, e, { etype: n, pageInfo: r, dq: s, form: i }) {
2337
2336
  }
2338
2337
  );
2339
2338
  let d = {};
2340
- const h = Cs(e, n, s);
2339
+ const h = Is(e, n, s);
2341
2340
  for (const b of u) {
2342
2341
  const [g] = b;
2343
- if (d[g] || !a && l && f && Os(l, f, c, b))
2342
+ if (d[g] || !a && l && f && vs(l, f, c, b))
2344
2343
  continue;
2345
2344
  const _ = xr(t, h, g);
2346
2345
  _ && (d[g] = _);
2347
2346
  }
2348
2347
  return d;
2349
2348
  }
2350
- function Ps(t) {
2349
+ function Ms(t) {
2351
2350
  var n;
2352
2351
  const e = (n = t.$) == null ? void 0 : n.order;
2353
2352
  return e && e[Object.keys(e)[0]] || "asc";
@@ -2357,14 +2356,14 @@ function An(t) {
2357
2356
  const e = (s = t.$) == null ? void 0 : s.offset, n = (i = t.$) == null ? void 0 : i.before, r = (o = t.$) == null ? void 0 : o.after;
2358
2357
  return !e && !n && !r;
2359
2358
  }
2360
- function js(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2359
+ function Ps(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2361
2360
  var d, h, p, y, b;
2362
2361
  if (!An(s) && (!o || !o["start-cursor"]))
2363
2362
  return [];
2364
- const a = ys(
2365
- Ts(e, n, r, (d = s.$) == null ? void 0 : d.where),
2363
+ const a = ps(
2364
+ ws(e, n, r, (d = s.$) == null ? void 0 : d.where),
2366
2365
  i
2367
- ), c = ms(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Ms(t, e, {
2366
+ ), c = Ts(Ce, n, r), u = (h = s.$) == null ? void 0 : h.fields, l = Cs(t, e, {
2368
2367
  etype: n,
2369
2368
  pageInfo: o,
2370
2369
  form: s,
@@ -2379,9 +2378,9 @@ function js(t, e, { etype: n, level: r, form: s, join: i, pageInfo: o }) {
2379
2378
  }
2380
2379
  return l;
2381
2380
  }
2382
- function $s(t, e, n) {
2381
+ function js(t, e, n) {
2383
2382
  try {
2384
- return js(t, e, n);
2383
+ return Ps(t, e, n);
2385
2384
  } catch (r) {
2386
2385
  if (r instanceof ne)
2387
2386
  return {};
@@ -2389,10 +2388,10 @@ function $s(t, e, n) {
2389
2388
  }
2390
2389
  }
2391
2390
  function vn(t, e, n) {
2392
- const r = $s(t, e, n);
2393
- return As(Ce, t, e, n, r);
2391
+ const r = js(t, e, n);
2392
+ return Ss(Ce, t, e, n, r);
2394
2393
  }
2395
- function Ds(t) {
2394
+ function $s(t) {
2396
2395
  const e = {};
2397
2396
  for (const [n, r] of Object.entries(t))
2398
2397
  e[n] = {
@@ -2417,9 +2416,9 @@ function On({
2417
2416
  pageInfo: n == null ? void 0 : n[u]
2418
2417
  })), c;
2419
2418
  }, {}) };
2420
- return n && (o.pageInfo = Ds(n)), r && (o.aggregate = r), o;
2419
+ return n && (o.pageInfo = $s(n)), r && (o.aggregate = r), o;
2421
2420
  }
2422
- function Rs() {
2421
+ function Ds() {
2423
2422
  const e = {
2424
2423
  __etype: 1,
2425
2424
  __ops: 1,
@@ -2433,7 +2432,7 @@ function Rs() {
2433
2432
  };
2434
2433
  return new Set(Object.keys(e));
2435
2434
  }
2436
- const xs = Rs();
2435
+ const Rs = Ds();
2437
2436
  function Je(t, e, n) {
2438
2437
  const r = {
2439
2438
  __etype: t,
@@ -2443,7 +2442,7 @@ function Je(t, e, n) {
2443
2442
  get: (s, i) => {
2444
2443
  if (i === "__ops") return n;
2445
2444
  if (i === "__etype") return t;
2446
- if (xs.has(i))
2445
+ if (Rs.has(i))
2447
2446
  return (o, a) => Je(t, e, [
2448
2447
  ...n,
2449
2448
  a ? [i, t, e, o, a] : [i, t, e, o]
@@ -2451,7 +2450,7 @@ function Je(t, e, n) {
2451
2450
  }
2452
2451
  });
2453
2452
  }
2454
- function Ro(t, e) {
2453
+ function Do(t, e) {
2455
2454
  return `lookup__${t}__${JSON.stringify(e)}`;
2456
2455
  }
2457
2456
  function Ee(t) {
@@ -2461,7 +2460,7 @@ function kn(t) {
2461
2460
  const [e, n, ...r] = t.split("__");
2462
2461
  return [n, JSON.parse(r.join("__"))];
2463
2462
  }
2464
- function Us(t) {
2463
+ function xs(t) {
2465
2464
  return new Proxy(
2466
2465
  {
2467
2466
  __etype: t
@@ -2480,16 +2479,16 @@ function En() {
2480
2479
  {},
2481
2480
  {
2482
2481
  get(t, e) {
2483
- return Us(e);
2482
+ return xs(e);
2484
2483
  }
2485
2484
  }
2486
2485
  );
2487
2486
  }
2488
- const xo = En();
2489
- function Ls(t) {
2487
+ const Ro = En();
2488
+ function Us(t) {
2490
2489
  return t.__ops;
2491
2490
  }
2492
- function Fs(t, e) {
2491
+ function Ls(t, e) {
2493
2492
  const { attrIdMap: n, refSwapAttrIds: r } = t, s = [];
2494
2493
  for (const o of e) {
2495
2494
  const a = n[o];
@@ -2508,7 +2507,7 @@ function Fs(t, e) {
2508
2507
  }
2509
2508
  return s;
2510
2509
  }
2511
- function Ns(t) {
2510
+ function Fs(t) {
2512
2511
  if (Array.isArray(t))
2513
2512
  return t;
2514
2513
  const e = Object.entries(t);
@@ -2518,7 +2517,7 @@ function Ns(t) {
2518
2517
  );
2519
2518
  return e[0];
2520
2519
  }
2521
- function Ks(t, e, n) {
2520
+ function Ns(t, e, n) {
2522
2521
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2523
2522
  // before assuming it's a ref lookup.
2524
2523
  !E(t, e, n);
@@ -2529,8 +2528,8 @@ function Ye(t) {
2529
2528
  throw new Error(`${t} is not a valid lookup attribute.`);
2530
2529
  return e;
2531
2530
  }
2532
- function qs(t, e, n) {
2533
- if (!Ks(t, e, n))
2531
+ function Ks(t, e, n) {
2532
+ if (!Ns(t, e, n))
2534
2533
  return E(t, e, n);
2535
2534
  const r = Ye(n), s = E(t, e, r) || Z(t, e, r);
2536
2535
  if (s && s["value-type"] !== "ref")
@@ -2538,13 +2537,13 @@ function qs(t, e, n) {
2538
2537
  return s;
2539
2538
  }
2540
2539
  function Ze(t) {
2541
- return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Ns(t);
2540
+ return typeof t == "string" && !Ee(t) ? null : typeof t == "string" && Ee(t) ? kn(t) : Fs(t);
2542
2541
  }
2543
2542
  function x(t, e, n) {
2544
2543
  const r = Ze(n);
2545
2544
  if (r === null)
2546
2545
  return n;
2547
- const [s, i] = r, o = qs(t, e, s);
2546
+ const [s, i] = r, o = Ks(t, e, s);
2548
2547
  if (!o || !o["unique?"])
2549
2548
  throw new Error(`${s} is not a unique attribute.`);
2550
2549
  return [o.id, i];
@@ -2559,7 +2558,7 @@ function In(t, e, n, r) {
2559
2558
  s
2560
2559
  ]].concat(r) : r;
2561
2560
  }
2562
- function zs({ attrsStore: t }, [e, n, r]) {
2561
+ function qs({ attrsStore: t }, [e, n, r]) {
2563
2562
  const s = Object.entries(r).flatMap(([i, o]) => {
2564
2563
  const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2565
2564
  return a.map((l) => c ? [
@@ -2580,7 +2579,7 @@ function zs({ attrsStore: t }, [e, n, r]) {
2580
2579
  });
2581
2580
  return In(t, e, n, s);
2582
2581
  }
2583
- function Vs({ attrsStore: t }, [e, n, r]) {
2582
+ function zs({ attrsStore: t }, [e, n, r]) {
2584
2583
  const s = Object.entries(r).flatMap(([i, o]) => {
2585
2584
  const a = Array.isArray(o) ? o : [o], c = E(t, e, i), u = Z(t, e, i);
2586
2585
  return a.map((l) => c ? [
@@ -2601,7 +2600,7 @@ function Vs({ attrsStore: t }, [e, n, r]) {
2601
2600
  });
2602
2601
  return In(t, e, n, s);
2603
2602
  }
2604
- function Ws(t, e, n, r) {
2603
+ function Vs(t, e, n, r) {
2605
2604
  var s;
2606
2605
  if (Array.isArray(r)) {
2607
2606
  const [i, o] = r;
@@ -2625,16 +2624,16 @@ function Ws(t, e, n, r) {
2625
2624
  return !1;
2626
2625
  }
2627
2626
  function Cn({ stores: t, attrsStore: e }, [n, r, s, i]) {
2628
- return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Ws(t, e, n, r) ? { mode: "update" } : null;
2627
+ return (i == null ? void 0 : i.upsert) === !1 ? { mode: "update" } : (i == null ? void 0 : i.upsert) === !0 ? null : Vs(t, e, n, r) ? { mode: "update" } : null;
2629
2628
  }
2630
- function Qs(t, e) {
2629
+ function Ws(t, e) {
2631
2630
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s);
2632
2631
  return [["id", c]].concat(Object.entries(a)).map(([l, f]) => {
2633
2632
  const d = E(n, r, l);
2634
2633
  return d["checked-data-type"] === "date" && t.useDateObjects && (f = Ie(f)), ["add-triple", c, d.id, f, { mode: "create" }];
2635
2634
  });
2636
2635
  }
2637
- function Gs(t, e) {
2636
+ function Qs(t, e) {
2638
2637
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]);
2639
2638
  return [["id", c]].concat(Object.entries(a)).map(([f, d]) => {
2640
2639
  const h = E(n, r, f);
@@ -2647,10 +2646,10 @@ function Gs(t, e) {
2647
2646
  ];
2648
2647
  });
2649
2648
  }
2650
- function Bs({ attrsStore: t }, [e, n]) {
2649
+ function Gs({ attrsStore: t }, [e, n]) {
2651
2650
  return [["delete-entity", x(t, e, n), e]];
2652
2651
  }
2653
- function Hs(t, e) {
2652
+ function Bs(t, e) {
2654
2653
  const { attrsStore: n } = t, [r, s, i, o] = e, a = lt(i), c = x(n, r, s), u = Cn(t, [r, c, i, o]), l = Object.entries(a).map(([d, h]) => {
2655
2654
  const p = E(n, r, d);
2656
2655
  return [
@@ -2669,38 +2668,38 @@ function Hs(t, e) {
2669
2668
  ...u ? [u] : []
2670
2669
  ]].concat(l);
2671
2670
  }
2672
- function Js({ attrsStore: t }, [e, n, r]) {
2671
+ function Hs({ attrsStore: t }, [e, n, r]) {
2673
2672
  return [["rule-params", x(t, e, n), e, r]];
2674
2673
  }
2675
- function Ys(t) {
2674
+ function Js(t) {
2676
2675
  const [e, n, r, s, i] = t;
2677
2676
  if (!s)
2678
2677
  return t;
2679
2678
  const o = { ...s };
2680
2679
  return delete o.id, [e, n, r, o, ...i ? [i] : []];
2681
2680
  }
2682
- function Zs(t, e) {
2683
- const [n, ...r] = Ys(e);
2681
+ function Ys(t, e) {
2682
+ const [n, ...r] = Js(e);
2684
2683
  switch (n) {
2685
2684
  case "merge":
2686
- return Hs(t, r);
2685
+ return Bs(t, r);
2687
2686
  case "create":
2688
- return Qs(t, r);
2687
+ return Ws(t, r);
2689
2688
  case "update":
2690
- return Gs(t, r);
2689
+ return Qs(t, r);
2691
2690
  case "link":
2692
- return zs(t, r);
2691
+ return qs(t, r);
2693
2692
  case "unlink":
2694
- return Vs(t, r);
2693
+ return zs(t, r);
2695
2694
  case "delete":
2696
- return Bs(t, r);
2695
+ return Gs(t, r);
2697
2696
  case "ruleParams":
2698
- return Js(t, r);
2697
+ return Hs(t, r);
2699
2698
  default:
2700
2699
  throw new Error(`unsupported action ${n}`);
2701
2700
  }
2702
2701
  }
2703
- function Xs(t) {
2702
+ function Zs(t) {
2704
2703
  switch (t) {
2705
2704
  case "string":
2706
2705
  case "date":
@@ -2711,13 +2710,13 @@ function Xs(t) {
2711
2710
  return;
2712
2711
  }
2713
2712
  }
2714
- function ei(t, e, n) {
2713
+ function Xs(t, e, n) {
2715
2714
  var a, c;
2716
2715
  const r = (c = (a = t.entities[e]) == null ? void 0 : a.attrs) == null ? void 0 : c[n];
2717
2716
  if (n === "id") return null;
2718
2717
  if (!r)
2719
2718
  throw new Error(`${e}.${n} does not exist in your schema`);
2720
- const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Xs(r == null ? void 0 : r.valueType);
2719
+ const { unique: s, indexed: i } = r == null ? void 0 : r.config, o = Zs(r == null ? void 0 : r.valueType);
2721
2720
  return {
2722
2721
  "index?": i,
2723
2722
  "unique?": s,
@@ -2725,7 +2724,7 @@ function ei(t, e, n) {
2725
2724
  };
2726
2725
  }
2727
2726
  function be(t, e, n, r) {
2728
- const s = t ? ei(t, e, n) : null, i = I(), a = [I(), e, n];
2727
+ const s = t ? Xs(t, e, n) : null, i = I(), a = [I(), e, n];
2729
2728
  return {
2730
2729
  id: i,
2731
2730
  "forward-identity": a,
@@ -2738,11 +2737,11 @@ function be(t, e, n, r) {
2738
2737
  ...r || {}
2739
2738
  };
2740
2739
  }
2741
- function ti(t, e, n) {
2740
+ function ei(t, e, n) {
2742
2741
  return Object.values(t.links).find((i) => i.forward.on === e && i.forward.label === n || i.reverse.on === e && i.reverse.label === n);
2743
2742
  }
2744
- function ni(t, e, n) {
2745
- const r = ti(t, e, n);
2743
+ function ti(t, e, n) {
2744
+ const r = ei(t, e, n);
2746
2745
  if (!r)
2747
2746
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2748
2747
  const { forward: s, reverse: i } = r;
@@ -2756,7 +2755,7 @@ function ni(t, e, n) {
2756
2755
  };
2757
2756
  }
2758
2757
  function $t(t, e, n, r) {
2759
- const s = t ? ni(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2758
+ const s = t ? ti(t, e, n) : null, i = I(), o = [I(), e, n], a = [I(), n, e];
2760
2759
  return {
2761
2760
  id: i,
2762
2761
  // @ts-ignore: ts thinks it's any[]
@@ -2773,7 +2772,7 @@ function $t(t, e, n, r) {
2773
2772
  ...r || {}
2774
2773
  };
2775
2774
  }
2776
- const ri = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), si = /* @__PURE__ */ new Set(["link", "unlink"]), ii = /* @__PURE__ */ new Set(["create", "update", "merge"]), oi = /* @__PURE__ */ new Set([
2775
+ const ni = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), ri = /* @__PURE__ */ new Set(["link", "unlink"]), si = /* @__PURE__ */ new Set(["create", "update", "merge"]), ii = /* @__PURE__ */ new Set([
2777
2776
  "link",
2778
2777
  "unlink",
2779
2778
  "create",
@@ -2781,13 +2780,13 @@ const ri = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2781
2780
  "merge",
2782
2781
  "delete",
2783
2782
  "ruleParams"
2784
- ]), Xe = { "unique?": !0, "index?": !0 }, ai = {
2783
+ ]), Xe = { "unique?": !0, "index?": !0 }, oi = {
2785
2784
  ...Xe,
2786
2785
  cardinality: "one"
2787
2786
  };
2788
- function ci(t) {
2787
+ function ai(t) {
2789
2788
  const e = [], [n, r, s, i] = t;
2790
- if (!oi.has(n))
2789
+ if (!ii.has(n))
2791
2790
  return e;
2792
2791
  const o = Ze(s);
2793
2792
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -2804,7 +2803,7 @@ function ci(t) {
2804
2803
  }
2805
2804
  return e;
2806
2805
  }
2807
- function ui({ attrsStore: t, schema: e }, n) {
2806
+ function ci({ attrsStore: t, schema: e }, n) {
2808
2807
  var d, h;
2809
2808
  const r = /* @__PURE__ */ new Set(), s = [], i = [];
2810
2809
  function o(p, y) {
@@ -2833,10 +2832,10 @@ function ui({ attrsStore: t, schema: e }, n) {
2833
2832
  }
2834
2833
  function f(p, y) {
2835
2834
  const b = o(p, y), g = a(p, y);
2836
- u(b), u(g), !b && !g && c($t(e, p, y, ai));
2835
+ u(b), u(g), !b && !g && c($t(e, p, y, oi));
2837
2836
  }
2838
2837
  for (const p of n)
2839
- for (const { etype: y, lookupPair: b, linkLabel: g } of ci(p)) {
2838
+ for (const { etype: y, lookupPair: b, linkLabel: g } of ai(p)) {
2840
2839
  const _ = b[0];
2841
2840
  if (g) {
2842
2841
  f(y, g);
@@ -2860,19 +2859,19 @@ function ui({ attrsStore: t, schema: e }, n) {
2860
2859
  }
2861
2860
  for (const p of n) {
2862
2861
  const [y, b, g, _] = p;
2863
- if (ri.has(y)) {
2862
+ if (ni.has(y)) {
2864
2863
  const T = o(b, "id");
2865
2864
  u(T), T || c(be(e, b, "id", { "unique?": !0 }));
2866
2865
  for (const A of Object.keys(_)) {
2867
2866
  const m = o(b, A);
2868
- if (u(m), ii.has(y) && (m || c(
2867
+ if (u(m), si.has(y) && (m || c(
2869
2868
  be(
2870
2869
  e,
2871
2870
  b,
2872
2871
  A,
2873
2872
  A === "id" ? { "unique?": !0 } : null
2874
2873
  )
2875
- )), si.has(y)) {
2874
+ )), ri.has(y)) {
2876
2875
  const O = a(b, A);
2877
2876
  !m && !O && c($t(e, b, A)), u(O);
2878
2877
  }
@@ -2887,15 +2886,15 @@ function ui({ attrsStore: t, schema: e }, n) {
2887
2886
  }
2888
2887
  return [t, i];
2889
2888
  }
2890
- function li(t, e) {
2891
- const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Ls(c)), [s, i] = ui(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Zs(o, c));
2889
+ function ui(t, e) {
2890
+ const r = (Array.isArray(e) ? e : [e]).flatMap((c) => Us(c)), [s, i] = ci(t, r), o = { ...t, attrsStore: s }, a = r.flatMap((c) => Ys(o, c));
2892
2891
  return [...i, ...a];
2893
2892
  }
2894
2893
  function Dt(t, e) {
2895
2894
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2896
2895
  }
2897
2896
  const le = "__meta";
2898
- class fi {
2897
+ class li {
2899
2898
  constructor(e, n) {
2900
2899
  }
2901
2900
  }
@@ -3128,13 +3127,13 @@ class et {
3128
3127
  };
3129
3128
  }
3130
3129
  }
3131
- const di = 6, hi = ["kv", "querySubs", "syncSubs"];
3132
- function pi(t) {
3130
+ const fi = 6, di = ["kv", "querySubs", "syncSubs"];
3131
+ function hi(t) {
3133
3132
  return function(n) {
3134
3133
  console.error("Error in IndexedDB event", { source: t, event: n });
3135
3134
  };
3136
3135
  }
3137
- async function yi(t) {
3136
+ async function pi(t) {
3138
3137
  return new Promise((e) => {
3139
3138
  const n = indexedDB.open(t);
3140
3139
  n.onerror = (r) => {
@@ -3148,7 +3147,7 @@ async function yi(t) {
3148
3147
  };
3149
3148
  });
3150
3149
  }
3151
- async function bi(t, e, n) {
3150
+ async function yi(t, e, n) {
3152
3151
  const r = (
3153
3152
  // Backwards compatibility for older versions where we JSON.stringified before storing
3154
3153
  typeof e == "string" ? JSON.parse(e) : e
@@ -3188,8 +3187,8 @@ async function Rt(t, e, n) {
3188
3187
  r.onsuccess = () => s(), r.onerror = (o) => i(o);
3189
3188
  });
3190
3189
  }
3191
- async function _i(t, e) {
3192
- const n = await yi(`instant_${t}_5`);
3190
+ async function bi(t, e) {
3191
+ const n = await pi(`instant_${t}_5`);
3193
3192
  if (!n)
3194
3193
  return;
3195
3194
  const r = await new Promise((l, f) => {
@@ -3212,7 +3211,7 @@ async function _i(t, e) {
3212
3211
  for (const [l, f] of r)
3213
3212
  switch (l) {
3214
3213
  case "querySubs": {
3215
- const d = bi(l, f, o);
3214
+ const d = yi(l, f, o);
3216
3215
  a.push(d);
3217
3216
  break;
3218
3217
  }
@@ -3234,9 +3233,9 @@ async function _i(t, e) {
3234
3233
  });
3235
3234
  }
3236
3235
  const xt = /* @__PURE__ */ new Map();
3237
- class Mn extends fi {
3236
+ class Mn extends li {
3238
3237
  constructor(e, n) {
3239
- super(e, n), this.dbName = `instant_${e}_${di}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3238
+ super(e, n), this.dbName = `instant_${e}_${fi}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3240
3239
  }
3241
3240
  _init() {
3242
3241
  return new Promise((e, n) => {
@@ -3247,8 +3246,8 @@ class Mn extends fi {
3247
3246
  }, s.onsuccess = (i) => {
3248
3247
  const a = i.target.result;
3249
3248
  if (r) {
3250
- const c = _i(this._appId, a).catch((u) => {
3251
- pi("Error upgrading store from version 5 to 6.")(u);
3249
+ const c = bi(this._appId, a).catch((u) => {
3250
+ hi("Error upgrading store from version 5 to 6.")(u);
3252
3251
  });
3253
3252
  xt.set(this.dbName, c), c.then(() => e(a)).catch(() => e(a));
3254
3253
  } else {
@@ -3262,7 +3261,7 @@ class Mn extends fi {
3262
3261
  }
3263
3262
  _upgradeStore(e) {
3264
3263
  const r = e.target.result;
3265
- for (const s of hi)
3264
+ for (const s of di)
3266
3265
  r.objectStoreNames.contains(s) || r.createObjectStore(s);
3267
3266
  }
3268
3267
  async getItem(e) {
@@ -3368,7 +3367,7 @@ async function z(t, e) {
3368
3367
  const n = await fetch(t, e), r = await n.json();
3369
3368
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Me({ status: n.status, body: r }));
3370
3369
  }
3371
- function gi({
3370
+ function _i({
3372
3371
  apiURI: t,
3373
3372
  appId: e,
3374
3373
  email: n
@@ -3379,7 +3378,7 @@ function gi({
3379
3378
  body: JSON.stringify({ "app-id": e, email: n })
3380
3379
  });
3381
3380
  }
3382
- async function wi({
3381
+ async function gi({
3383
3382
  apiURI: t,
3384
3383
  appId: e,
3385
3384
  email: n,
@@ -3397,7 +3396,7 @@ async function wi({
3397
3396
  })
3398
3397
  });
3399
3398
  }
3400
- async function Ti({
3399
+ async function wi({
3401
3400
  apiURI: t,
3402
3401
  appId: e,
3403
3402
  refreshToken: n
@@ -3411,7 +3410,7 @@ async function Ti({
3411
3410
  })
3412
3411
  });
3413
3412
  }
3414
- async function mi({
3413
+ async function Ti({
3415
3414
  apiURI: t,
3416
3415
  appId: e
3417
3416
  }) {
@@ -3441,7 +3440,7 @@ async function Ut({
3441
3440
  })
3442
3441
  });
3443
3442
  }
3444
- async function Si({
3443
+ async function mi({
3445
3444
  apiURI: t,
3446
3445
  appId: e,
3447
3446
  nonce: n,
@@ -3461,7 +3460,7 @@ async function Si({
3461
3460
  })
3462
3461
  });
3463
3462
  }
3464
- async function Ai({
3463
+ async function Si({
3465
3464
  apiURI: t,
3466
3465
  appId: e,
3467
3466
  refreshToken: n
@@ -3477,7 +3476,7 @@ async function Ai({
3477
3476
  })
3478
3477
  });
3479
3478
  }
3480
- async function vi({
3479
+ async function Ai({
3481
3480
  apiURI: t,
3482
3481
  appId: e,
3483
3482
  path: n,
@@ -3498,7 +3497,7 @@ async function vi({
3498
3497
  body: r
3499
3498
  });
3500
3499
  }
3501
- async function Oi({
3500
+ async function vi({
3502
3501
  apiURI: t,
3503
3502
  appId: e,
3504
3503
  path: n,
@@ -3516,7 +3515,7 @@ async function Oi({
3516
3515
  );
3517
3516
  return s;
3518
3517
  }
3519
- async function ki({
3518
+ async function Oi({
3520
3519
  apiURI: t,
3521
3520
  appId: e,
3522
3521
  fileName: n,
@@ -3536,7 +3535,7 @@ async function ki({
3536
3535
  });
3537
3536
  return i;
3538
3537
  }
3539
- async function Ei(t, e) {
3538
+ async function ki(t, e) {
3540
3539
  return (await fetch(t, {
3541
3540
  method: "PUT",
3542
3541
  body: e,
@@ -3545,7 +3544,7 @@ async function Ei(t, e) {
3545
3544
  }
3546
3545
  })).ok;
3547
3546
  }
3548
- async function Ii({
3547
+ async function Ei({
3549
3548
  apiURI: t,
3550
3549
  appId: e,
3551
3550
  path: n,
@@ -3574,7 +3573,7 @@ function Lt(t, e) {
3574
3573
  n[r] = t[r];
3575
3574
  }), n;
3576
3575
  }
3577
- function Ci(t, e, n) {
3576
+ function Ii(t, e, n) {
3578
3577
  const r = {
3579
3578
  peers: {}
3580
3579
  };
@@ -3591,7 +3590,7 @@ function Ci(t, e, n) {
3591
3590
  }
3592
3591
  return r;
3593
3592
  }
3594
- function Mi(t, e) {
3593
+ function Ci(t, e) {
3595
3594
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !At(t.user, e.user)) || !an(t.peers, e.peers)) return !0;
3596
3595
  for (const r of Object.keys(t.peers))
3597
3596
  if (!At(t.peers[r], e.peers[r])) return !0;
@@ -3640,8 +3639,8 @@ function Kt(t) {
3640
3639
  }, e;
3641
3640
  }, {});
3642
3641
  }
3643
- const Rn = "v0.22.89-experimental.uuidfix.20281951052.1";
3644
- function Pi(t, e) {
3642
+ const Rn = "v0.22.89-experimental.uuidfix.20282483875.1";
3643
+ function Mi(t, e) {
3645
3644
  return {
3646
3645
  info: t ? (...n) => console.info(...n, e()) : () => {
3647
3646
  },
@@ -3761,7 +3760,7 @@ const qt = [
3761
3760
  "before",
3762
3761
  "fields",
3763
3762
  "aggregate"
3764
- ], ji = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3763
+ ], Pi = (t) => t.valueType || "unknown", xn = (t, e, n = !1) => {
3765
3764
  if (n || t == null) return !0;
3766
3765
  switch (e) {
3767
3766
  case "string":
@@ -3775,7 +3774,7 @@ const qt = [
3775
3774
  default:
3776
3775
  return !0;
3777
3776
  }
3778
- }, $i = (t, e, n, r, s, i, o) => {
3777
+ }, ji = (t, e, n, r, s, i, o) => {
3779
3778
  const a = i.valueType === "json", c = (u, l, f) => {
3780
3779
  if (!xn(f, l, a))
3781
3780
  throw new v(
@@ -3820,13 +3819,13 @@ const qt = [
3820
3819
  );
3821
3820
  }
3822
3821
  }, ee = (t, e, n, r, s) => {
3823
- const i = ji(n), o = n.valueType === "json";
3822
+ const i = Pi(n), o = n.valueType === "json";
3824
3823
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3825
3824
  if (o)
3826
3825
  return;
3827
3826
  const c = t;
3828
3827
  for (const [u, l] of Object.entries(c))
3829
- $i(
3828
+ ji(
3830
3829
  u,
3831
3830
  l,
3832
3831
  i,
@@ -3840,7 +3839,7 @@ const qt = [
3840
3839
  `Invalid value for attribute '${e}' in entity '${r}'. Expected ${i}, but received: ${typeof t}`,
3841
3840
  s
3842
3841
  );
3843
- }, Di = (t, e, n, r, s) => {
3842
+ }, $i = (t, e, n, r, s) => {
3844
3843
  const i = t.split(".");
3845
3844
  if (i.length < 2)
3846
3845
  throw new v(
@@ -3934,7 +3933,7 @@ const qt = [
3934
3933
  continue;
3935
3934
  }
3936
3935
  if (s.includes(".")) {
3937
- Di(
3936
+ $i(
3938
3937
  s,
3939
3938
  i,
3940
3939
  e,
@@ -3977,7 +3976,7 @@ const qt = [
3977
3976
  );
3978
3977
  }
3979
3978
  }
3980
- }, Ri = (t, e, n, r, s = 0) => {
3979
+ }, Di = (t, e, n, r, s = 0) => {
3981
3980
  for (const o of Object.keys(t))
3982
3981
  if (!qt.includes(o))
3983
3982
  throw new v(
@@ -4045,7 +4044,7 @@ const qt = [
4045
4044
  `Query parameter '$' must be an object in entity '${e}', but received: ${typeof a}`,
4046
4045
  `${r}.$`
4047
4046
  );
4048
- Ri(
4047
+ Di(
4049
4048
  a,
4050
4049
  e,
4051
4050
  n,
@@ -4098,7 +4097,7 @@ class N extends Error {
4098
4097
  super(e), this.name = "TransactionValidationError";
4099
4098
  }
4100
4099
  }
4101
- const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4100
+ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", Ri = (t, e) => new N(
4102
4101
  `Entity '${t}' does not exist in schema. Available entities: ${Fn(e)}`
4103
4102
  ), xe = {
4104
4103
  string: (t) => typeof t == "string",
@@ -4106,13 +4105,13 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4106
4105
  boolean: (t) => typeof t == "boolean",
4107
4106
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
4108
4107
  json: () => !0
4109
- }, Ui = (t, e) => {
4108
+ }, xi = (t, e) => {
4110
4109
  var n;
4111
4110
  return t == null ? !0 : ((n = xe[e.valueType]) == null ? void 0 : n.call(xe, t)) ?? !1;
4112
4111
  }, Nn = (t, e) => {
4113
4112
  const n = e.entities[t];
4114
4113
  if (!n)
4115
- throw xi(t, Object.keys(e.entities));
4114
+ throw Ri(t, Object.keys(e.entities));
4116
4115
  return n;
4117
4116
  }, Ue = (t, e, n) => {
4118
4117
  const r = Nn(t, n);
@@ -4123,7 +4122,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4123
4122
  for (const [s, i] of Object.entries(e)) {
4124
4123
  if (s === "id") continue;
4125
4124
  const o = r.attrs[s];
4126
- if (o && !Ui(i, o))
4125
+ if (o && !xi(i, o))
4127
4126
  throw new N(
4128
4127
  `Invalid value for attribute '${s}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof i}`
4129
4128
  );
@@ -4154,7 +4153,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4154
4153
  );
4155
4154
  }
4156
4155
  }
4157
- }, Li = {
4156
+ }, Ui = {
4158
4157
  create: Ue,
4159
4158
  update: Ue,
4160
4159
  merge: Ue,
@@ -4162,7 +4161,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4162
4161
  unlink: Wt,
4163
4162
  delete: () => {
4164
4163
  }
4165
- }, Fi = (t, e) => {
4164
+ }, Li = (t, e) => {
4166
4165
  if (!e) return;
4167
4166
  const [n, r, s, i] = t;
4168
4167
  if (!Array.isArray(s) && !te(s))
@@ -4173,9 +4172,9 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4173
4172
  throw new N(
4174
4173
  `Entity name must be a string, but received: ${typeof r}`
4175
4174
  );
4176
- const o = Li[n];
4175
+ const o = Ui[n];
4177
4176
  o && i !== void 0 && o(r, i, e);
4178
- }, Ni = (t, e) => {
4177
+ }, Fi = (t, e) => {
4179
4178
  const n = Array.isArray(t) ? t : [t];
4180
4179
  for (const r of n) {
4181
4180
  if (!r || typeof r != "object")
@@ -4191,7 +4190,7 @@ const Fn = (t) => t.length > 0 ? t.join(", ") : "none", xi = (t, e) => new N(
4191
4190
  throw new N(
4192
4191
  `Transaction operation must be an array, but received: ${typeof s}`
4193
4192
  );
4194
- Fi(s, e);
4193
+ Li(s, e);
4195
4194
  }
4196
4195
  }
4197
4196
  };
@@ -4224,7 +4223,7 @@ class Qt {
4224
4223
  return this.conn.send(JSON.stringify(e));
4225
4224
  }
4226
4225
  }
4227
- class Ki {
4226
+ class Ni {
4228
4227
  constructor(e, n) {
4229
4228
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Kn++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4230
4229
  this.initParams || this.handleError();
@@ -4307,7 +4306,7 @@ class Ki {
4307
4306
  this.handleClose();
4308
4307
  }
4309
4308
  }
4310
- function qi(t, e) {
4309
+ function Ki(t, e) {
4311
4310
  const n = t.values;
4312
4311
  if (n) {
4313
4312
  const r = hn(n.attrsStore, null);
@@ -4319,7 +4318,7 @@ function qi(t, e) {
4319
4318
  }
4320
4319
  return t;
4321
4320
  }
4322
- function zi(t, e) {
4321
+ function qi(t, e) {
4323
4322
  var n;
4324
4323
  if (e.values) {
4325
4324
  const r = [];
@@ -4334,7 +4333,7 @@ function zi(t, e) {
4334
4333
  } else
4335
4334
  return e;
4336
4335
  }
4337
- function Vi(t, e, n) {
4336
+ function zi(t, e, n) {
4338
4337
  var i, o;
4339
4338
  const r = (i = e == null ? void 0 : e.state) == null ? void 0 : i.txId, s = (o = n == null ? void 0 : n.state) == null ? void 0 : o.txId;
4340
4339
  return r && (!s || r > s) ? e : s && (!r || s > r) ? n : e || n;
@@ -4364,7 +4363,7 @@ function Bt(t, e, n) {
4364
4363
  break;
4365
4364
  }
4366
4365
  }
4367
- function Wi(t, e, n) {
4366
+ function Vi(t, e, n) {
4368
4367
  var s, i;
4369
4368
  const r = {};
4370
4369
  for (const { action: o, triple: a } of n) {
@@ -4391,14 +4390,14 @@ function Wi(t, e, n) {
4391
4390
  function _e(t, e) {
4392
4391
  return { [t.table]: e.map((n) => n.entity) };
4393
4392
  }
4394
- function Qi(t, e) {
4393
+ function Wi(t, e) {
4395
4394
  var r;
4396
4395
  if (t.orderFieldType)
4397
4396
  return t.orderFieldType;
4398
4397
  const n = t.orderField === "serverCreatedAt" ? "number" : (r = E(e(), t.table, t.orderField)) == null ? void 0 : r["checked-data-type"];
4399
4398
  return t.orderFieldType = n, n;
4400
4399
  }
4401
- function Gi(t, e, n) {
4400
+ function Qi(t, e, n) {
4402
4401
  const r = e;
4403
4402
  if (t.orderField === "serverCreatedAt") {
4404
4403
  n.sort(
@@ -4443,14 +4442,14 @@ function Gi(t, e, n) {
4443
4442
  }
4444
4443
  );
4445
4444
  }
4446
- var Bi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Bi || {});
4447
- class Hi {
4445
+ var Gi = /* @__PURE__ */ ((t) => (t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error", t))(Gi || {});
4446
+ class Bi {
4448
4447
  constructor(e, n, r, s, i, o) {
4449
4448
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = s, this.createStore = i, this.getAttrs = o, this.subs = new et({
4450
4449
  persister: n,
4451
- merge: Vi,
4452
- serialize: zi,
4453
- parse: (a, c) => qi(c, this.config.useDateObjects),
4450
+ merge: zi,
4451
+ serialize: qi,
4452
+ parse: (a, c) => Ki(c, this.config.useDateObjects),
4454
4453
  objectSize: (a) => {
4455
4454
  var c;
4456
4455
  return ((c = a.values) == null ? void 0 : c.entities.length) || 0;
@@ -4662,7 +4661,7 @@ class Hi {
4662
4661
  const T = f[_];
4663
4662
  if (Er(T.store, b)) {
4664
4663
  Bt(T.store, l.attrsStore, g);
4665
- const A = Le(s, T.store, l.attrsStore), m = Wi(
4664
+ const A = Le(s, T.store, l.attrsStore), m = Vi(
4666
4665
  T.store,
4667
4666
  l.attrsStore,
4668
4667
  g
@@ -4702,8 +4701,8 @@ class Hi {
4702
4701
  const p = [];
4703
4702
  for (const b of c.sort().reverse())
4704
4703
  p.push(f[b].entity), f.splice(b, 1);
4705
- const y = Qi(s, this.getAttrs);
4706
- Gi(s, y, f), this.notifyCbs(r, {
4704
+ const y = Wi(s, this.getAttrs);
4705
+ Qi(s, y, f), this.notifyCbs(r, {
4707
4706
  type: "SyncTransaction",
4708
4707
  data: _e(s, (o = s.values) == null ? void 0 : o.entities),
4709
4708
  added: h,
@@ -4750,11 +4749,11 @@ const W = {
4750
4749
  AUTHENTICATED: "authenticated",
4751
4750
  CLOSED: "closed",
4752
4751
  ERRORED: "errored"
4753
- }, Ji = 3e4, Yi = 3e4, Zi = 200, Xi = {
4752
+ }, Hi = 3e4, Ji = 3e4, Yi = 200, Zi = {
4754
4753
  apiURI: "https://api.instantdb.com",
4755
4754
  websocketURI: "wss://api.instantdb.com/runtime/session"
4756
4755
  }, Fe = "_instant_oauth_redirect", se = "currentUser";
4757
- function eo({
4756
+ function Xi({
4758
4757
  transportType: t,
4759
4758
  appId: e,
4760
4759
  apiURI: n,
@@ -4767,7 +4766,7 @@ function eo({
4767
4766
  case "ws":
4768
4767
  return new Qt(`${r}?app_id=${e}`);
4769
4768
  case "sse":
4770
- return new Ki(
4769
+ return new Ni(
4771
4770
  s,
4772
4771
  `${n}/runtime/sse?app_id=${e}`
4773
4772
  );
@@ -4775,7 +4774,7 @@ function eo({
4775
4774
  throw new Error("Unknown transport type " + t);
4776
4775
  }
4777
4776
  }
4778
- function to() {
4777
+ function eo() {
4779
4778
  return typeof window < "u" || typeof chrome < "u";
4780
4779
  }
4781
4780
  const Ht = {
@@ -4784,7 +4783,7 @@ const Ht = {
4784
4783
  "refresh-presence": !0,
4785
4784
  "patch-presence": !0
4786
4785
  };
4787
- function no(t, e) {
4786
+ function to(t, e) {
4788
4787
  var r;
4789
4788
  const n = typeof t == "string" ? JSON.parse(t) : t;
4790
4789
  if ((r = n == null ? void 0 : n.result) != null && r.store) {
@@ -4802,7 +4801,7 @@ function no(t, e) {
4802
4801
  }
4803
4802
  return n;
4804
4803
  }
4805
- function ro(t, e) {
4804
+ function no(t, e) {
4806
4805
  const { result: n, ...r } = e, s = (
4807
4806
  /** @type {import('./reactorTypes.ts').QuerySubInStorage} */
4808
4807
  r
@@ -4817,7 +4816,7 @@ function ro(t, e) {
4817
4816
  }
4818
4817
  return s;
4819
4818
  }
4820
- function so(t, e) {
4819
+ function ro(t, e) {
4821
4820
  switch (t) {
4822
4821
  case "pendingMutations":
4823
4822
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4825,7 +4824,7 @@ function so(t, e) {
4825
4824
  return e;
4826
4825
  }
4827
4826
  }
4828
- function io(t, e) {
4827
+ function so(t, e) {
4829
4828
  switch (t) {
4830
4829
  case "pendingMutations":
4831
4830
  return [...e.entries()];
@@ -4833,7 +4832,7 @@ function io(t, e) {
4833
4832
  return e;
4834
4833
  }
4835
4834
  }
4836
- function oo(t, e, n) {
4835
+ function io(t, e, n) {
4837
4836
  const r = e == null ? void 0 : e.result, s = n == null ? void 0 : n.result;
4838
4837
  return r && !s && n && (n.result = r), n || e;
4839
4838
  }
@@ -4843,7 +4842,7 @@ function Jt(t) {
4843
4842
  return a == c ? r < i ? -1 : r > i ? 1 : 0 : a - c;
4844
4843
  });
4845
4844
  }
4846
- class ao {
4845
+ class oo {
4847
4846
  constructor(e, n = Mn, r = Pn, s, i) {
4848
4847
  /** @type {s.AttrsStore | undefined} */
4849
4848
  w(this, "attrs");
@@ -4938,9 +4937,9 @@ class ao {
4938
4937
  });
4939
4938
  /** Applies transactions locally and sends transact message to server */
4940
4939
  w(this, "pushTx", (e) => {
4941
- this.config.disableValidation || Ni(e, this.config.schema);
4940
+ this.config.disableValidation || Fi(e, this.config.schema);
4942
4941
  try {
4943
- const n = li(
4942
+ const n = ui(
4944
4943
  {
4945
4944
  attrsStore: this.optimisticAttrs(),
4946
4945
  schema: this.config.schema,
@@ -5079,10 +5078,10 @@ class ao {
5079
5078
  this._reconnectTimeoutMs
5080
5079
  ), this._scheduleReconnect();
5081
5080
  });
5082
- if (this._EventSource = i, this.config = { ...Xi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Yi, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Zi, this._log = Pi(
5081
+ if (this._EventSource = i, this.config = { ...Zi, ...e }, this.queryCacheLimit = this.config.queryCacheLimit ?? 10, this._pendingTxCleanupTimeout = this.config.pendingTxCleanupTimeout ?? Ji, this._pendingMutationCleanupThreshold = this.config.pendingMutationCleanupThreshold ?? Yi, this._log = Mi(
5083
5082
  e.verbose || pt || jn,
5084
5083
  () => this._reactorStats()
5085
- ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!to()) {
5084
+ ), this.versions = { ...s || {}, "@instantdb/core": Rn }, this.config.schema && (this._linkIndex = Kt(this.config.schema)), !!eo()) {
5086
5085
  if (!e.appId)
5087
5086
  throw new Error("Instant must be initialized with an appId.");
5088
5087
  if (!te(e.appId))
@@ -5099,7 +5098,7 @@ class ao {
5099
5098
  } catch (c) {
5100
5099
  this._log.error("[error] handle broadcast channel", c);
5101
5100
  }
5102
- })), this._initStorage(n), this._syncTable = new Hi(
5101
+ })), this._initStorage(n), this._syncTable = new Bi(
5103
5102
  this._trySendAuthed.bind(this),
5104
5103
  new n(this.config.appId, "syncSubs"),
5105
5104
  {
@@ -5150,9 +5149,9 @@ class ao {
5150
5149
  _initStorage(e) {
5151
5150
  this.querySubs = new et({
5152
5151
  persister: new e(this.config.appId, "querySubs"),
5153
- merge: oo,
5154
- serialize: ro,
5155
- parse: (n, r) => no(r, this.config.useDateObjects),
5152
+ merge: io,
5153
+ serialize: no,
5154
+ parse: (n, r) => to(r, this.config.useDateObjects),
5156
5155
  // objectSize
5157
5156
  objectSize: (n) => {
5158
5157
  var r, s, i;
@@ -5171,8 +5170,8 @@ class ao {
5171
5170
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new et({
5172
5171
  persister: new e(this.config.appId, "kv"),
5173
5172
  merge: this._onMergeKv,
5174
- serialize: io,
5175
- parse: so,
5173
+ serialize: so,
5174
+ parse: ro,
5176
5175
  objectSize: () => 0,
5177
5176
  logger: this._log,
5178
5177
  saveThrottleMs: 100,
@@ -5530,7 +5529,7 @@ class ao {
5530
5529
  const s = P(e), i = this._startQuerySub(e, s);
5531
5530
  return this.queryOnceDfds[s] = this.queryOnceDfds[s] ?? [], this.queryOnceDfds[s].push({ q: e, dfd: r, eventId: i }), setTimeout(
5532
5531
  () => r.reject(new Error("Query timed out")),
5533
- Ji
5532
+ Hi
5534
5533
  ), r.promise;
5535
5534
  }
5536
5535
  _completeQueryOnce(e, n, r) {
@@ -5598,7 +5597,7 @@ class ao {
5598
5597
  a = !0;
5599
5598
  continue;
5600
5599
  }
5601
- const y = a ? Fs(o, h) : h;
5600
+ const y = a ? Ls(o, h) : h;
5602
5601
  d.push(y);
5603
5602
  }
5604
5603
  return a ? d : l;
@@ -5787,7 +5786,7 @@ class ao {
5787
5786
  return;
5788
5787
  }
5789
5788
  const e = this._transport;
5790
- this._transport = eo({
5789
+ this._transport = Xi({
5791
5790
  transportType: this._transportType,
5792
5791
  appId: this.config.appId,
5793
5792
  apiURI: this.config.apiURI,
@@ -5981,7 +5980,7 @@ class ao {
5981
5980
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5982
5981
  }
5983
5982
  sendMagicCode({ email: e }) {
5984
- return gi({
5983
+ return _i({
5985
5984
  apiURI: this.config.apiURI,
5986
5985
  appId: this.config.appId,
5987
5986
  email: e
@@ -5989,7 +5988,7 @@ class ao {
5989
5988
  }
5990
5989
  async signInWithMagicCode({ email: e, code: n }) {
5991
5990
  var o;
5992
- const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await wi({
5991
+ const r = await this.getCurrentUser(), s = ((o = r == null ? void 0 : r.user) == null ? void 0 : o.type) === "guest", i = await gi({
5993
5992
  apiURI: this.config.apiURI,
5994
5993
  appId: this.config.appId,
5995
5994
  email: e,
@@ -5999,7 +5998,7 @@ class ao {
5999
5998
  return await this.changeCurrentUser(i.user), i;
6000
5999
  }
6001
6000
  async signInWithCustomToken(e) {
6002
- const n = await Ti({
6001
+ const n = await wi({
6003
6002
  apiURI: this.config.apiURI,
6004
6003
  appId: this.config.appId,
6005
6004
  refreshToken: e
@@ -6007,7 +6006,7 @@ class ao {
6007
6006
  return await this.changeCurrentUser(n.user), n;
6008
6007
  }
6009
6008
  async signInAsGuest() {
6010
- const e = await mi({
6009
+ const e = await Ti({
6011
6010
  apiURI: this.config.apiURI,
6012
6011
  appId: this.config.appId
6013
6012
  });
@@ -6022,7 +6021,7 @@ class ao {
6022
6021
  this._log.info("[auth-invalidate] skipped invalidateToken");
6023
6022
  return;
6024
6023
  }
6025
- Ai({
6024
+ Si({
6026
6025
  apiURI: this.config.apiURI,
6027
6026
  appId: this.config.appId,
6028
6027
  refreshToken: r
@@ -6075,7 +6074,7 @@ class ao {
6075
6074
  */
6076
6075
  async signInWithIdToken({ idToken: e, clientName: n, nonce: r }) {
6077
6076
  var a;
6078
- const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await Si({
6077
+ const s = await this.getCurrentUser(), i = (a = s == null ? void 0 : s.user) == null ? void 0 : a.refresh_token, o = await mi({
6079
6078
  apiURI: this.config.apiURI,
6080
6079
  appId: this.config.appId,
6081
6080
  idToken: e,
@@ -6116,7 +6115,7 @@ class ao {
6116
6115
  getPresence(e, n, r = {}) {
6117
6116
  const s = this._rooms[n], i = this._presence[n];
6118
6117
  return !s || !i || !i.result ? null : {
6119
- ...Ci(i.result, r, this._sessionId),
6118
+ ...Ii(i.result, r, this._sessionId),
6120
6119
  isLoading: !s.isConnected,
6121
6120
  error: s.error
6122
6121
  };
@@ -6172,7 +6171,7 @@ class ao {
6172
6171
  }
6173
6172
  _notifyPresenceSub(e, n) {
6174
6173
  const r = this.getPresence("", e, n);
6175
- r && (n.prev && !Mi(r, n.prev) || (n.prev = r, n.cb(r)));
6174
+ r && (n.prev && !Ci(r, n.prev) || (n.prev = r, n.cb(r)));
6176
6175
  }
6177
6176
  _patchPresencePeers(e, n) {
6178
6177
  var o, a, c;
@@ -6248,7 +6247,7 @@ class ao {
6248
6247
  async uploadFile(e, n, r) {
6249
6248
  var o;
6250
6249
  const s = await this.getCurrentUser(), i = (o = s == null ? void 0 : s.user) == null ? void 0 : o.refresh_token;
6251
- return vi({
6250
+ return Ai({
6252
6251
  ...r,
6253
6252
  apiURI: this.config.apiURI,
6254
6253
  appId: this.config.appId,
@@ -6260,7 +6259,7 @@ class ao {
6260
6259
  async deleteFile(e) {
6261
6260
  var i;
6262
6261
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6263
- return await Oi({
6262
+ return await vi({
6264
6263
  apiURI: this.config.apiURI,
6265
6264
  appId: this.config.appId,
6266
6265
  path: e,
@@ -6271,18 +6270,18 @@ class ao {
6271
6270
  // ---------------------------------
6272
6271
  async upload(e, n) {
6273
6272
  var c;
6274
- const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await ki({
6273
+ const r = await this.getCurrentUser(), s = (c = r == null ? void 0 : r.user) == null ? void 0 : c.refresh_token, i = e || n.name, o = await Oi({
6275
6274
  apiURI: this.config.apiURI,
6276
6275
  appId: this.config.appId,
6277
6276
  fileName: i,
6278
6277
  refreshToken: s
6279
6278
  });
6280
- return await Ei(o, n);
6279
+ return await ki(o, n);
6281
6280
  }
6282
6281
  async getDownloadUrl(e) {
6283
6282
  var i;
6284
6283
  const n = await this.getCurrentUser(), r = (i = n == null ? void 0 : n.user) == null ? void 0 : i.refresh_token;
6285
- return await Ii({
6284
+ return await Ei({
6286
6285
  apiURI: this.config.apiURI,
6287
6286
  appId: this.config.appId,
6288
6287
  path: e,
@@ -6290,7 +6289,7 @@ class ao {
6290
6289
  });
6291
6290
  }
6292
6291
  }
6293
- function co(t, e) {
6292
+ function ao(t, e) {
6294
6293
  return new je(
6295
6294
  qn(t, e),
6296
6295
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -6302,25 +6301,25 @@ function co(t, e) {
6302
6301
  void 0
6303
6302
  );
6304
6303
  }
6305
- function uo(t) {
6304
+ function co(t) {
6306
6305
  return new Pe(t, {});
6307
6306
  }
6308
- function lo() {
6307
+ function uo() {
6309
6308
  return new $("string", !0, !1);
6310
6309
  }
6311
- function fo() {
6310
+ function lo() {
6312
6311
  return new $("number", !0, !1);
6313
6312
  }
6314
- function ho() {
6313
+ function fo() {
6315
6314
  return new $("boolean", !0, !1);
6316
6315
  }
6317
- function po() {
6316
+ function ho() {
6318
6317
  return new $("date", !0, !1);
6319
6318
  }
6320
- function yo() {
6319
+ function po() {
6321
6320
  return new $("json", !0, !1);
6322
6321
  }
6323
- function bo() {
6322
+ function yo() {
6324
6323
  return new $("json", !0, !1);
6325
6324
  }
6326
6325
  function qn(t, e) {
@@ -6344,7 +6343,7 @@ function qn(t, e) {
6344
6343
  ])
6345
6344
  );
6346
6345
  }
6347
- function _o({
6346
+ function bo({
6348
6347
  entities: t,
6349
6348
  links: e,
6350
6349
  rooms: n
@@ -6361,23 +6360,23 @@ function _o({
6361
6360
  s
6362
6361
  );
6363
6362
  }
6364
- const Uo = {
6363
+ const xo = {
6365
6364
  // constructs
6366
- graph: co,
6367
- schema: _o,
6368
- entity: uo,
6365
+ graph: ao,
6366
+ schema: bo,
6367
+ entity: co,
6369
6368
  // value types
6370
- string: lo,
6371
- number: fo,
6372
- boolean: ho,
6373
- date: po,
6374
- json: yo,
6375
- any: bo
6369
+ string: uo,
6370
+ number: lo,
6371
+ boolean: fo,
6372
+ date: ho,
6373
+ json: po,
6374
+ any: yo
6376
6375
  };
6377
6376
  let ge;
6378
- function go(t, e) {
6377
+ function _o(t, e) {
6379
6378
  ge == null || ge.dispose();
6380
- const n = vo(e), r = mo(e, a), s = To(wo(t));
6379
+ const n = Ao(e), r = To(e, a), s = wo(go(t));
6381
6380
  function i(l) {
6382
6381
  var f;
6383
6382
  l.source === s.element.contentWindow && ((f = l.data) == null ? void 0 : f.type) === "close" && n.isVisible() && a();
@@ -6399,10 +6398,10 @@ function go(t, e) {
6399
6398
  }
6400
6399
  return u();
6401
6400
  }
6402
- function wo(t) {
6401
+ function go(t) {
6403
6402
  return `${pt || $n ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6404
6403
  }
6405
- function To(t) {
6404
+ function wo(t) {
6406
6405
  const e = document.createElement("iframe");
6407
6406
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6408
6407
  width: "100%",
@@ -6411,7 +6410,7 @@ function To(t) {
6411
6410
  border: "none"
6412
6411
  }), { element: e };
6413
6412
  }
6414
- function mo(t, e) {
6413
+ function To(t, e) {
6415
6414
  const n = `
6416
6415
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6417
6416
  <rect width="512" height="512" fill="black"/>
@@ -6421,7 +6420,7 @@ function mo(t, e) {
6421
6420
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, {
6422
6421
  // pos
6423
6422
  position: "fixed",
6424
- ...So(t.position),
6423
+ ...mo(t.position),
6425
6424
  height: "32px",
6426
6425
  width: "32px",
6427
6426
  // layout
@@ -6436,7 +6435,7 @@ function mo(t, e) {
6436
6435
  cursor: "pointer"
6437
6436
  }), r.addEventListener("click", e), { element: r };
6438
6437
  }
6439
- function So(t) {
6438
+ function mo(t) {
6440
6439
  switch (t) {
6441
6440
  case "bottom-left":
6442
6441
  return { bottom: "24px", left: "24px" };
@@ -6448,7 +6447,7 @@ function So(t) {
6448
6447
  return { top: "24px", left: "24px" };
6449
6448
  }
6450
6449
  }
6451
- function Ao(t) {
6450
+ function So(t) {
6452
6451
  switch (t) {
6453
6452
  case "bottom-left":
6454
6453
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6460,11 +6459,11 @@ function Ao(t) {
6460
6459
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6461
6460
  }
6462
6461
  }
6463
- function vo(t) {
6462
+ function Ao(t) {
6464
6463
  const e = document.createElement("div");
6465
6464
  Object.assign(e.style, {
6466
6465
  position: "fixed",
6467
- ...Ao(t.position),
6466
+ ...So(t.position),
6468
6467
  display: "block",
6469
6468
  borderRadius: "4px",
6470
6469
  border: "1px #ccc solid",
@@ -6477,37 +6476,37 @@ function vo(t) {
6477
6476
  }
6478
6477
  return { element: e, isVisible: n };
6479
6478
  }
6480
- const Oo = {
6479
+ const vo = {
6481
6480
  apiURI: "https://api.instantdb.com",
6482
6481
  websocketURI: "wss://api.instantdb.com/runtime/session"
6483
6482
  };
6484
- function ko() {
6483
+ function Oo() {
6485
6484
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6486
6485
  }
6487
- function Eo() {
6486
+ function ko() {
6488
6487
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
6489
6488
  }
6490
6489
  function tt(t) {
6491
6490
  const e = t.__adminToken;
6492
6491
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6493
6492
  }
6494
- const nt = Eo(), Yt = ko();
6495
- class Io {
6493
+ const nt = ko(), Yt = Oo();
6494
+ class Eo {
6496
6495
  constructor(e) {
6497
6496
  this.db = e, this.sendMagicCode = (n) => this.db.sendMagicCode(n), this.signInWithMagicCode = (n) => this.db.signInWithMagicCode(n), this.signInWithToken = (n) => this.db.signInWithCustomToken(n), this.signInAsGuest = () => this.db.signInAsGuest(), this.createAuthorizationURL = (n) => this.db.createAuthorizationURL(n), this.signInWithIdToken = (n) => this.db.signInWithIdToken(n), this.exchangeOAuthCode = (n) => this.db.exchangeCodeForToken(n), this.issuerURI = () => this.db.issuerURI(), this.signOut = (n = { invalidateToken: !0 }) => this.db.signOut(n);
6498
6497
  }
6499
6498
  }
6500
- class Co {
6499
+ class Io {
6501
6500
  constructor(e) {
6502
6501
  this.db = e, this.uploadFile = (n, r, s = {}) => this.db.uploadFile(n, r, s), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
6503
6502
  }
6504
6503
  }
6505
- function Lo(t) {
6504
+ function Uo(t) {
6506
6505
  return JSON.parse(JSON.stringify(t));
6507
6506
  }
6508
- class Mo {
6507
+ class Co {
6509
6508
  constructor(e) {
6510
- this.tx = En(), this._reactor = e, this.auth = new Io(this._reactor), this.storage = new Co(this._reactor);
6509
+ this.tx = En(), this._reactor = e, this.auth = new Eo(this._reactor), this.storage = new Io(this._reactor);
6511
6510
  }
6512
6511
  /**
6513
6512
  * Use this to write data! You can create, update, delete, and link objects
@@ -6690,19 +6689,19 @@ function Zt(t) {
6690
6689
  const n = P(t);
6691
6690
  return Yt.set(t, n), n;
6692
6691
  }
6693
- function Po(t, e) {
6692
+ function Mo(t, e) {
6694
6693
  return Zt(t._reactor.config.schema) !== Zt(e);
6695
6694
  }
6696
- function jo(t, e, n, r, s) {
6695
+ function Po(t, e, n, r, s) {
6697
6696
  const i = {
6698
6697
  ...t,
6699
6698
  useDateObjects: t.useDateObjects ?? !1
6700
6699
  }, o = nt[tt(i)];
6701
6700
  if (o)
6702
- return Po(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6703
- const a = new ao(
6701
+ return Mo(o, i.schema) && o._reactor.updateSchema(i.schema), o;
6702
+ const a = new oo(
6704
6703
  {
6705
- ...Oo,
6704
+ ...vo,
6706
6705
  ...i,
6707
6706
  cardinalityInference: !!i.schema
6708
6707
  },
@@ -6710,10 +6709,10 @@ function jo(t, e, n, r, s) {
6710
6709
  n || Pn,
6711
6710
  { ...r || {}, "@instantdb/core": Rn },
6712
6711
  s
6713
- ), c = new Mo(a);
6714
- return nt[tt(i)] = c, $o(i.appId, i.devtool), c;
6712
+ ), c = new Co(a);
6713
+ return nt[tt(i)] = c, jo(i.appId, i.devtool), c;
6715
6714
  }
6716
- function $o(t, e) {
6715
+ function jo(t, e) {
6717
6716
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6718
6717
  return;
6719
6718
  const n = {
@@ -6721,33 +6720,33 @@ function $o(t, e) {
6721
6720
  allowedHosts: ["localhost"],
6722
6721
  ...typeof e == "object" ? e : {}
6723
6722
  };
6724
- n.allowedHosts.includes(window.location.hostname) && go(t, n);
6723
+ n.allowedHosts.includes(window.location.hostname) && _o(t, n);
6725
6724
  }
6726
- const Fo = jo;
6725
+ const Lo = Po;
6727
6726
  export {
6728
- Io as Auth,
6727
+ Eo as Auth,
6729
6728
  Mn as IndexedDBStorage,
6730
6729
  Me as InstantAPIError,
6731
- Mo as InstantCoreDatabase,
6730
+ Co as InstantCoreDatabase,
6732
6731
  de as InstantError,
6733
6732
  v as QueryValidationError,
6734
- Co as Storage,
6735
- fi as StorageInterface,
6736
- Bi as SyncTableCallbackEventType,
6733
+ Io as Storage,
6734
+ li as StorageInterface,
6735
+ Gi as SyncTableCallbackEventType,
6737
6736
  N as TransactionValidationError,
6738
6737
  Pn as WindowNetworkListener,
6739
- Lo as coerceQuery,
6738
+ Uo as coerceQuery,
6740
6739
  Ie as coerceToDate,
6741
- Ls as getOps,
6742
- Uo as i,
6740
+ Us as getOps,
6741
+ xo as i,
6743
6742
  I as id,
6744
- jo as init,
6745
- Fo as init_experimental,
6746
- Ro as lookup,
6747
- xo as tx,
6743
+ Po as init,
6744
+ Lo as init_experimental,
6745
+ Do as lookup,
6746
+ Ro as tx,
6748
6747
  En as txInit,
6749
6748
  zt as validateQuery,
6750
- Ni as validateTransactions,
6749
+ Fi as validateTransactions,
6751
6750
  Rn as version,
6752
6751
  P as weakHash
6753
6752
  };