@instantdb/react 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.
@@ -1875,22 +1875,21 @@ function Po() {
1875
1875
  const Mo = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Sr = { randomUUID: Mo };
1876
1876
  function Ro(t, e, n) {
1877
1877
  var i;
1878
+ if (Sr.randomUUID && !t)
1879
+ return Sr.randomUUID();
1878
1880
  t = t || {};
1879
1881
  const r = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? Po();
1880
1882
  if (r.length < 16)
1881
1883
  throw new Error("Random bytes length must be >= 16");
1882
1884
  return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Co(r);
1883
1885
  }
1884
- function xo(t, e, n) {
1885
- return Sr.randomUUID ? Sr.randomUUID() : Ro(t);
1886
- }
1887
1886
  function Or(t) {
1888
1887
  const e = t.replace(/-/g, ""), n = [];
1889
1888
  for (let r = 0; r < e.length; r += 2)
1890
1889
  n.push(parseInt(e.substring(r, r + 2), 16));
1891
1890
  return n;
1892
1891
  }
1893
- function $o(t, e) {
1892
+ function xo(t, e) {
1894
1893
  for (let n = 0; n < t.length; n++) {
1895
1894
  if (t[n] < e[n])
1896
1895
  return -1;
@@ -1899,17 +1898,17 @@ function $o(t, e) {
1899
1898
  }
1900
1899
  return 0;
1901
1900
  }
1902
- function Do(t, e) {
1903
- return $o(Or(t), Or(e));
1901
+ function $o(t, e) {
1902
+ return xo(Or(t), Or(e));
1904
1903
  }
1905
1904
  function W() {
1906
- return xo();
1905
+ return Ro();
1907
1906
  }
1908
- function Uo(t, e) {
1907
+ function Do(t, e) {
1909
1908
  return t.localeCompare(e);
1910
1909
  }
1911
- function Lo() {
1912
- let t = Uo;
1910
+ function Uo() {
1911
+ let t = Do;
1913
1912
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
1914
1913
  try {
1915
1914
  t = Intl.Collator("en-US").compare;
@@ -1917,10 +1916,10 @@ function Lo() {
1917
1916
  }
1918
1917
  return t;
1919
1918
  }
1920
- const Fo = Lo();
1921
- let No = 0;
1919
+ const Lo = Uo();
1920
+ let Fo = 0;
1922
1921
  function nt(t) {
1923
- return $t(`_${t}`, No++);
1922
+ return $t(`_${t}`, Fo++);
1924
1923
  }
1925
1924
  function $t(t, e) {
1926
1925
  return `?${t}-${e}`;
@@ -1930,24 +1929,24 @@ class Ke extends Error {
1930
1929
  super(e), this.name = "AttrNotFoundError";
1931
1930
  }
1932
1931
  }
1933
- function Ko(t, e) {
1932
+ function No(t, e) {
1934
1933
  const n = ki(t, e);
1935
1934
  if (!n)
1936
1935
  throw new Ke(`Could not find id attr for ${e}`);
1937
1936
  return n;
1938
1937
  }
1939
1938
  function Er(t, e, n, r) {
1940
- return [qo(t, e, n, r)];
1939
+ return [Ko(t, e, n, r)];
1941
1940
  }
1942
- function qo(t, e, n, r) {
1941
+ function Ko(t, e, n, r) {
1943
1942
  return [
1944
1943
  t(n, r),
1945
- Ko(e, n).id,
1944
+ No(e, n).id,
1946
1945
  t(n, r),
1947
1946
  t("time", r)
1948
1947
  ];
1949
1948
  }
1950
- function Wo(t, e, n) {
1949
+ function qo(t, e, n) {
1951
1950
  return t.map((r) => r === e ? n : r);
1952
1951
  }
1953
1952
  function Ci(t, e, n, r, i) {
@@ -1979,7 +1978,7 @@ function Ar(t, e) {
1979
1978
  return typeof o != "string" ? !1 : i.test(o);
1980
1979
  };
1981
1980
  }
1982
- function zo(t, e) {
1981
+ function Wo(t, e) {
1983
1982
  if (typeof e != "object" || e.hasOwnProperty("$in") || e.hasOwnProperty("in"))
1984
1983
  return e;
1985
1984
  const n = t["checked-data-type"] === "date";
@@ -2039,7 +2038,7 @@ function zo(t, e) {
2039
2038
  }
2040
2039
  return e;
2041
2040
  }
2042
- function Vo(t, e, n, r, i, s) {
2041
+ function zo(t, e, n, r, i, s) {
2043
2042
  const o = K(e, n, i), u = Ie(e, n, i), a = o || u;
2044
2043
  if (!a)
2045
2044
  throw new Ke(`No attr for etype = ${n} label = ${i}`);
@@ -2057,11 +2056,11 @@ function Vo(t, e, n, r, i, s) {
2057
2056
  return o ? [
2058
2057
  t(n, r),
2059
2058
  a.id,
2060
- zo(a, s),
2059
+ Wo(a, s),
2061
2060
  nt("time")
2062
2061
  ] : [s, a.id, t(n, r), nt("time")];
2063
2062
  }
2064
- function Bo(t, e, n, r, i) {
2063
+ function Vo(t, e, n, r, i) {
2065
2064
  const [s, o, u] = i.reduce((a, c) => {
2066
2065
  const [d, f, l] = a, [p, y, b] = Ci(t, e, d, f, c);
2067
2066
  return [p, y, [...l, b]];
@@ -2069,19 +2068,19 @@ function Bo(t, e, n, r, i) {
2069
2068
  return [s, o, u];
2070
2069
  }
2071
2070
  function fn(t, e, n, r, i, s) {
2072
- const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Bo(t, e, n, r, o), f = Vo(t, e, a, c, u, s);
2071
+ const o = i.slice(0, i.length - 1), u = i[i.length - 1], [a, c, d] = Vo(t, e, n, r, o), f = zo(t, e, a, c, u, s);
2073
2072
  return d.concat([f]);
2074
2073
  }
2075
- function Go(t, e) {
2074
+ function Bo(t, e) {
2076
2075
  return e ? [e].concat(t) : t;
2077
2076
  }
2078
- function Qo([t, e]) {
2077
+ function Go([t, e]) {
2079
2078
  return t === "or" && Array.isArray(e);
2080
2079
  }
2081
- function Ho([t, e]) {
2080
+ function Qo([t, e]) {
2082
2081
  return t === "and" && Array.isArray(e);
2083
2082
  }
2084
- function Yo(t, e, n) {
2083
+ function Ho(t, e, n) {
2085
2084
  return (r, i) => {
2086
2085
  const s = t(r, i);
2087
2086
  return e == s ? s : `${s}-${n}`;
@@ -2089,27 +2088,27 @@ function Yo(t, e, n) {
2089
2088
  }
2090
2089
  function kr(t, e, n, r, i, s) {
2091
2090
  const o = t(r, i), u = s.map((a, c) => {
2092
- const d = Yo(t, o, c);
2091
+ const d = Ho(t, o, c);
2093
2092
  return Ii(d, n, r, i, a);
2094
2093
  });
2095
2094
  return { [e]: { patterns: u, joinSym: o } };
2096
2095
  }
2097
- function Jo(t) {
2096
+ function Yo(t) {
2098
2097
  const e = [];
2099
2098
  for (let n = 1; n <= t.length; n++)
2100
2099
  e.push(t.slice(0, n));
2101
2100
  return e;
2102
2101
  }
2103
2102
  function jr(t, e, n, r, i) {
2104
- return Jo(i).map((s) => fn(t, e, n, r, s, {
2103
+ return Yo(i).map((s) => fn(t, e, n, r, s, {
2105
2104
  $isNull: !0
2106
2105
  }));
2107
2106
  }
2108
2107
  function Ii(t, e, n, r, i) {
2109
2108
  return Object.entries(i).flatMap(([s, o]) => {
2110
- if (Qo([s, o]))
2109
+ if (Go([s, o]))
2111
2110
  return kr(t, "or", e, n, r, o);
2112
- if (Ho([s, o]))
2111
+ if (Qo([s, o]))
2113
2112
  return kr(t, "and", e, n, r, o);
2114
2113
  if (s === "$entityIdStartsWith")
2115
2114
  return [];
@@ -2135,25 +2134,25 @@ function Ii(t, e, n, r, i) {
2135
2134
  ] : fn(t, e, n, r, u, o);
2136
2135
  });
2137
2136
  }
2138
- function Zo(t, e, n, r) {
2137
+ function Jo(t, e, n, r) {
2139
2138
  const i = $t;
2140
2139
  return r ? Ii(i, t, e, n, r).concat(Er(i, t, e, n)) : Er(i, t, e, n);
2141
2140
  }
2142
- function Xo(t, e, n) {
2141
+ function Zo(t, e, n) {
2143
2142
  return [t(e, n), t("time", n)];
2144
2143
  }
2145
- function eu(t, e, n, r, i, s) {
2146
- const [o, u, a, c, d] = Ci(t, e, n, r, i), f = Wo(a, t(n, r), s);
2144
+ function Xo(t, e, n, r, i, s) {
2145
+ const [o, u, a, c, d] = Ci(t, e, n, r, i), f = qo(a, t(n, r), s);
2147
2146
  return [o, u, f, c, d];
2148
2147
  }
2149
- function tu(t, e, n, { etype: r, level: i, form: s }, o) {
2148
+ function eu(t, e, n, { etype: r, level: i, form: s }, o) {
2150
2149
  const u = Object.keys(s).filter((a) => a !== "$");
2151
2150
  return u.length ? Object.entries(o).map(function([c, d]) {
2152
2151
  return u.map(function(p) {
2153
2152
  var y, b, _;
2154
2153
  const T = !!(e.cardinalityInference && (!((_ = (b = (y = n.linkIndex) === null || y === void 0 ? void 0 : y[r]) === null || b === void 0 ? void 0 : b[p]) === null || _ === void 0) && _.isSingular));
2155
2154
  try {
2156
- const [g, m, O] = eu(t, n, r, i, p, c), S = Mi(e, n, {
2155
+ const [g, m, O] = Xo(t, n, r, i, p, c), S = Mi(e, n, {
2157
2156
  etype: g,
2158
2157
  level: m,
2159
2158
  form: s[p],
@@ -2170,11 +2169,11 @@ function tu(t, e, n, { etype: r, level: i, form: s }, o) {
2170
2169
  }, d);
2171
2170
  }) : Object.values(o);
2172
2171
  }
2173
- function nu(t, e, n) {
2174
- return n === "string" ? Fo(t, e) : t > e ? 1 : -1;
2172
+ function tu(t, e, n) {
2173
+ return n === "string" ? Lo(t, e) : t > e ? 1 : -1;
2175
2174
  }
2176
2175
  function Ze(t, e, n, r, i) {
2177
- return e === r || e == null && r == null ? Do(t, n) : r == null ? 1 : e == null ? -1 : nu(e, r, i);
2176
+ return e === r || e == null && r == null ? $o(t, n) : r == null ? 1 : e == null ? -1 : tu(e, r, i);
2178
2177
  }
2179
2178
  function Pt([t, e], [n, r], i) {
2180
2179
  return Ze(t, e, n, r, i);
@@ -2182,7 +2181,7 @@ function Pt([t, e], [n, r], i) {
2182
2181
  function ln(t) {
2183
2182
  return t == null ? t : new Date(t).getTime();
2184
2183
  }
2185
- function ru(t, e, n, r) {
2184
+ function nu(t, e, n, r) {
2186
2185
  var i;
2187
2186
  const [s, o, u, a] = t, c = n === "desc" ? 1 : -1;
2188
2187
  if (((i = e["forward-identity"]) === null || i === void 0 ? void 0 : i[2]) === "id")
@@ -2190,21 +2189,21 @@ function ru(t, e, n, r) {
2190
2189
  const [d, f] = r, l = e["checked-data-type"], p = l === "date" ? ln(f) : f, y = l === "date" ? ln(u) : u;
2191
2190
  return Pt([d, p], [s, y], l) === c;
2192
2191
  }
2193
- function iu(t, e) {
2192
+ function ru(t, e) {
2194
2193
  const n = e[1];
2195
2194
  return t.getAttr(n);
2196
2195
  }
2197
- function su(t, e, n) {
2196
+ function iu(t, e, n) {
2198
2197
  const r = Object.keys(n)[0];
2199
2198
  return K(t, e, r);
2200
2199
  }
2201
- function ou(t, e, n, r) {
2200
+ function su(t, e, n, r) {
2202
2201
  if (n)
2203
- return iu(t, n);
2202
+ return ru(t, n);
2204
2203
  if (r)
2205
- return su(t, e, r);
2204
+ return iu(t, e, r);
2206
2205
  }
2207
- function uu(t, e, n) {
2206
+ function ou(t, e, n) {
2208
2207
  var r, i;
2209
2208
  if (!Array.isArray(n.fields))
2210
2209
  return yo(t, e);
@@ -2219,11 +2218,11 @@ function uu(t, e, n) {
2219
2218
  }
2220
2219
  return s;
2221
2220
  }
2222
- function au(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2221
+ function uu(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2223
2222
  var o, u;
2224
- const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = cu(s);
2223
+ const a = (o = s == null ? void 0 : s.$) === null || o === void 0 ? void 0 : o.order, c = Pi(s), d = au(s);
2225
2224
  let f = Ao(t, i);
2226
- const l = r == null ? void 0 : r["start-cursor"], p = ou(e, n, l, a);
2225
+ const l = r == null ? void 0 : r["start-cursor"], p = su(e, n, l, a);
2227
2226
  if (p && ((u = p == null ? void 0 : p["forward-identity"]) === null || u === void 0 ? void 0 : u[2]) !== "id") {
2228
2227
  const _ = p["checked-data-type"] === "date", T = p.id;
2229
2228
  f = f.map(([g]) => {
@@ -2238,17 +2237,17 @@ function au(t, e, { etype: n, pageInfo: r, dq: i, form: s }) {
2238
2237
  return Pt(g, T, p == null ? void 0 : p["checked-data-type"]);
2239
2238
  });
2240
2239
  let y = {};
2241
- const b = uu(e, n, i);
2240
+ const b = ou(e, n, i);
2242
2241
  for (const _ of f) {
2243
2242
  const [T] = _;
2244
- if (y[T] || !c && l && p && ru(l, p, d, _))
2243
+ if (y[T] || !c && l && p && nu(l, p, d, _))
2245
2244
  continue;
2246
2245
  const g = po(t, b, T);
2247
2246
  g && (y[T] = g);
2248
2247
  }
2249
2248
  return y;
2250
2249
  }
2251
- function cu(t) {
2250
+ function au(t) {
2252
2251
  var e;
2253
2252
  const n = (e = t.$) === null || e === void 0 ? void 0 : e.order;
2254
2253
  return n && n[Object.keys(n)[0]] || "asc";
@@ -2258,11 +2257,11 @@ function Pi(t) {
2258
2257
  const i = (e = t.$) === null || e === void 0 ? void 0 : e.offset, s = (n = t.$) === null || n === void 0 ? void 0 : n.before, o = (r = t.$) === null || r === void 0 ? void 0 : r.after;
2259
2258
  return !i && !s && !o;
2260
2259
  }
2261
- function du(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2260
+ function cu(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2262
2261
  var u, a, c, d, f;
2263
2262
  if (!Pi(i) && (!o || !o["start-cursor"]))
2264
2263
  return [];
2265
- const l = Go(Zo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Xo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = au(t, e, {
2264
+ const l = Bo(Jo(e, n, r, (u = i.$) === null || u === void 0 ? void 0 : u.where), s), p = Zo($t, n, r), y = (a = i.$) === null || a === void 0 ? void 0 : a.fields, b = uu(t, e, {
2266
2265
  etype: n,
2267
2266
  pageInfo: o,
2268
2267
  form: i,
@@ -2275,9 +2274,9 @@ function du(t, e, { etype: n, level: r, form: i, join: s, pageInfo: o }) {
2275
2274
  }
2276
2275
  return b;
2277
2276
  }
2278
- function fu(t, e, n) {
2277
+ function du(t, e, n) {
2279
2278
  try {
2280
- return du(t, e, n);
2279
+ return cu(t, e, n);
2281
2280
  } catch (r) {
2282
2281
  if (r instanceof Ke)
2283
2282
  return {};
@@ -2285,10 +2284,10 @@ function fu(t, e, n) {
2285
2284
  }
2286
2285
  }
2287
2286
  function Mi(t, e, n) {
2288
- const r = fu(t, e, n);
2289
- return tu($t, t, e, n, r);
2287
+ const r = du(t, e, n);
2288
+ return eu($t, t, e, n, r);
2290
2289
  }
2291
- function lu(t) {
2290
+ function fu(t) {
2292
2291
  const e = {};
2293
2292
  for (const [n, r] of Object.entries(t))
2294
2293
  e[n] = {
@@ -2308,9 +2307,9 @@ function Ri({ store: t, attrsStore: e, pageInfo: n, aggregate: r }, i) {
2308
2307
  pageInfo: n == null ? void 0 : n[c]
2309
2308
  })), a;
2310
2309
  }, {}) };
2311
- return n && (o.pageInfo = lu(n)), r && (o.aggregate = r), o;
2310
+ return n && (o.pageInfo = fu(n)), r && (o.aggregate = r), o;
2312
2311
  }
2313
- function hu() {
2312
+ function lu() {
2314
2313
  const e = {
2315
2314
  __etype: 1,
2316
2315
  __ops: 1,
@@ -2324,7 +2323,7 @@ function hu() {
2324
2323
  };
2325
2324
  return new Set(Object.keys(e));
2326
2325
  }
2327
- const pu = hu();
2326
+ const hu = lu();
2328
2327
  function hn(t, e, n) {
2329
2328
  const r = {
2330
2329
  __etype: t,
@@ -2336,7 +2335,7 @@ function hn(t, e, n) {
2336
2335
  return n;
2337
2336
  if (s === "__etype")
2338
2337
  return t;
2339
- if (pu.has(s))
2338
+ if (hu.has(s))
2340
2339
  return (o, u) => hn(t, e, [
2341
2340
  ...n,
2342
2341
  u ? [s, t, e, o, u] : [s, t, e, o]
@@ -2344,7 +2343,7 @@ function hn(t, e, n) {
2344
2343
  }
2345
2344
  });
2346
2345
  }
2347
- function Lc(t, e) {
2346
+ function Uc(t, e) {
2348
2347
  return `lookup__${t}__${JSON.stringify(e)}`;
2349
2348
  }
2350
2349
  function Mt(t) {
@@ -2354,7 +2353,7 @@ function xi(t) {
2354
2353
  const [e, n, ...r] = t.split("__");
2355
2354
  return [n, JSON.parse(r.join("__"))];
2356
2355
  }
2357
- function yu(t) {
2356
+ function pu(t) {
2358
2357
  return new Proxy({
2359
2358
  __etype: t
2360
2359
  }, {
@@ -2369,15 +2368,15 @@ function yu(t) {
2369
2368
  function Kn() {
2370
2369
  return new Proxy({}, {
2371
2370
  get(t, e) {
2372
- return yu(e);
2371
+ return pu(e);
2373
2372
  }
2374
2373
  });
2375
2374
  }
2376
- const Fc = Kn();
2377
- function bu(t) {
2375
+ const Lc = Kn();
2376
+ function yu(t) {
2378
2377
  return t.__ops;
2379
2378
  }
2380
- function _u(t, e) {
2379
+ function bu(t, e) {
2381
2380
  const { attrIdMap: n, refSwapAttrIds: r } = t, i = [];
2382
2381
  for (const o of e) {
2383
2382
  const u = n[o];
@@ -2396,7 +2395,7 @@ function _u(t, e) {
2396
2395
  }
2397
2396
  return i;
2398
2397
  }
2399
- function gu(t) {
2398
+ function _u(t) {
2400
2399
  if (Array.isArray(t))
2401
2400
  return t;
2402
2401
  const e = Object.entries(t);
@@ -2404,7 +2403,7 @@ function gu(t) {
2404
2403
  throw new Error("lookup must be an object with a single unique attr and value.");
2405
2404
  return e[0];
2406
2405
  }
2407
- function wu(t, e, n) {
2406
+ function gu(t, e, n) {
2408
2407
  return n.indexOf(".") !== -1 && // attr names can have `.` in them, so use the attr we find with a `.`
2409
2408
  // before assuming it's a ref lookup.
2410
2409
  !K(t, e, n);
@@ -2415,8 +2414,8 @@ function pn(t) {
2415
2414
  throw new Error(`${t} is not a valid lookup attribute.`);
2416
2415
  return e;
2417
2416
  }
2418
- function Tu(t, e, n) {
2419
- if (!wu(t, e, n))
2417
+ function wu(t, e, n) {
2418
+ if (!gu(t, e, n))
2420
2419
  return K(t, e, n);
2421
2420
  const r = pn(n), i = K(t, e, r) || Ie(t, e, r);
2422
2421
  if (i && i["value-type"] !== "ref")
@@ -2424,13 +2423,13 @@ function Tu(t, e, n) {
2424
2423
  return i;
2425
2424
  }
2426
2425
  function yn(t) {
2427
- return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : gu(t);
2426
+ return typeof t == "string" && !Mt(t) ? null : typeof t == "string" && Mt(t) ? xi(t) : _u(t);
2428
2427
  }
2429
2428
  function ee(t, e, n) {
2430
2429
  const r = yn(n);
2431
2430
  if (r === null)
2432
2431
  return n;
2433
- const [i, s] = r, o = Tu(t, e, i);
2432
+ const [i, s] = r, o = wu(t, e, i);
2434
2433
  if (!o || !o["unique?"])
2435
2434
  throw new Error(`${i} is not a unique attribute.`);
2436
2435
  return [o.id, s];
@@ -2445,7 +2444,7 @@ function $i(t, e, n, r) {
2445
2444
  s
2446
2445
  ]].concat(r) : r;
2447
2446
  }
2448
- function mu({ attrsStore: t }, [e, n, r]) {
2447
+ function Tu({ attrsStore: t }, [e, n, r]) {
2449
2448
  const i = Object.entries(r).flatMap(([s, o]) => {
2450
2449
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2451
2450
  return u.map((d) => a ? [
@@ -2466,7 +2465,7 @@ function mu({ attrsStore: t }, [e, n, r]) {
2466
2465
  });
2467
2466
  return $i(t, e, n, i);
2468
2467
  }
2469
- function vu({ attrsStore: t }, [e, n, r]) {
2468
+ function mu({ attrsStore: t }, [e, n, r]) {
2470
2469
  const i = Object.entries(r).flatMap(([s, o]) => {
2471
2470
  const u = Array.isArray(o) ? o : [o], a = K(t, e, s), c = Ie(t, e, s);
2472
2471
  return u.map((d) => a ? [
@@ -2487,7 +2486,7 @@ function vu({ attrsStore: t }, [e, n, r]) {
2487
2486
  });
2488
2487
  return $i(t, e, n, i);
2489
2488
  }
2490
- function Su(t, e, n, r) {
2489
+ function vu(t, e, n, r) {
2491
2490
  var i;
2492
2491
  if (Array.isArray(r)) {
2493
2492
  const [s, o] = r;
@@ -2511,16 +2510,16 @@ function Su(t, e, n, r) {
2511
2510
  return !1;
2512
2511
  }
2513
2512
  function Di({ stores: t, attrsStore: e }, [n, r, i, s]) {
2514
- return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : Su(t, e, n, r) ? { mode: "update" } : null;
2513
+ return (s == null ? void 0 : s.upsert) === !1 ? { mode: "update" } : (s == null ? void 0 : s.upsert) === !0 ? null : vu(t, e, n, r) ? { mode: "update" } : null;
2515
2514
  }
2516
- function Ou(t, e) {
2515
+ function Su(t, e) {
2517
2516
  const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i);
2518
2517
  return [["id", a]].concat(Object.entries(u)).map(([d, f]) => {
2519
2518
  const l = K(n, r, d);
2520
2519
  return l["checked-data-type"] === "date" && t.useDateObjects && (f = xt(f)), ["add-triple", a, l.id, f, { mode: "create" }];
2521
2520
  });
2522
2521
  }
2523
- function Eu(t, e) {
2522
+ function Ou(t, e) {
2524
2523
  const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), c = Di(t, [r, a, s, o]);
2525
2524
  return [["id", a]].concat(Object.entries(u)).map(([f, l]) => {
2526
2525
  const p = K(n, r, f);
@@ -2533,10 +2532,10 @@ function Eu(t, e) {
2533
2532
  ];
2534
2533
  });
2535
2534
  }
2536
- function Au({ attrsStore: t }, [e, n]) {
2535
+ function Eu({ attrsStore: t }, [e, n]) {
2537
2536
  return [["delete-entity", ee(t, e, n), e]];
2538
2537
  }
2539
- function ku(t, e) {
2538
+ function Au(t, e) {
2540
2539
  const { attrsStore: n } = t, [r, i, s, o] = e, u = Un(s), a = ee(n, r, i), c = Di(t, [r, a, s, o]), d = Object.entries(u).map(([l, p]) => {
2541
2540
  const y = K(n, r, l);
2542
2541
  return [
@@ -2555,38 +2554,38 @@ function ku(t, e) {
2555
2554
  ...c ? [c] : []
2556
2555
  ]].concat(d);
2557
2556
  }
2558
- function ju({ attrsStore: t }, [e, n, r]) {
2557
+ function ku({ attrsStore: t }, [e, n, r]) {
2559
2558
  return [["rule-params", ee(t, e, n), e, r]];
2560
2559
  }
2561
- function Cu(t) {
2560
+ function ju(t) {
2562
2561
  const [e, n, r, i, s] = t;
2563
2562
  if (!i)
2564
2563
  return t;
2565
2564
  const o = Object.assign({}, i);
2566
2565
  return delete o.id, [e, n, r, o, ...s ? [s] : []];
2567
2566
  }
2568
- function Iu(t, e) {
2569
- const [n, ...r] = Cu(e);
2567
+ function Cu(t, e) {
2568
+ const [n, ...r] = ju(e);
2570
2569
  switch (n) {
2571
2570
  case "merge":
2572
- return ku(t, r);
2571
+ return Au(t, r);
2573
2572
  case "create":
2574
- return Ou(t, r);
2573
+ return Su(t, r);
2575
2574
  case "update":
2576
- return Eu(t, r);
2575
+ return Ou(t, r);
2577
2576
  case "link":
2578
- return mu(t, r);
2577
+ return Tu(t, r);
2579
2578
  case "unlink":
2580
- return vu(t, r);
2579
+ return mu(t, r);
2581
2580
  case "delete":
2582
- return Au(t, r);
2581
+ return Eu(t, r);
2583
2582
  case "ruleParams":
2584
- return ju(t, r);
2583
+ return ku(t, r);
2585
2584
  default:
2586
2585
  throw new Error(`unsupported action ${n}`);
2587
2586
  }
2588
2587
  }
2589
- function Pu(t) {
2588
+ function Iu(t) {
2590
2589
  switch (t) {
2591
2590
  case "string":
2592
2591
  case "date":
@@ -2597,14 +2596,14 @@ function Pu(t) {
2597
2596
  return;
2598
2597
  }
2599
2598
  }
2600
- function Mu(t, e, n) {
2599
+ function Pu(t, e, n) {
2601
2600
  var r, i;
2602
2601
  const s = (i = (r = t.entities[e]) === null || r === void 0 ? void 0 : r.attrs) === null || i === void 0 ? void 0 : i[n];
2603
2602
  if (n === "id")
2604
2603
  return null;
2605
2604
  if (!s)
2606
2605
  throw new Error(`${e}.${n} does not exist in your schema`);
2607
- const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Pu(s == null ? void 0 : s.valueType);
2606
+ const { unique: o, indexed: u } = s == null ? void 0 : s.config, a = Iu(s == null ? void 0 : s.valueType);
2608
2607
  return {
2609
2608
  "index?": u,
2610
2609
  "unique?": o,
@@ -2612,14 +2611,14 @@ function Mu(t, e, n) {
2612
2611
  };
2613
2612
  }
2614
2613
  function wt(t, e, n, r) {
2615
- const i = t ? Mu(t, e, n) : null, s = W(), u = [W(), e, n];
2614
+ const i = t ? Pu(t, e, n) : null, s = W(), u = [W(), e, n];
2616
2615
  return Object.assign(Object.assign({ id: s, "forward-identity": u, "value-type": "blob", cardinality: "one", "unique?": !1, "index?": !1, isUnsynced: !0 }, i || {}), r || {});
2617
2616
  }
2618
- function Ru(t, e, n) {
2617
+ function Mu(t, e, n) {
2619
2618
  return Object.values(t.links).find((s) => s.forward.on === e && s.forward.label === n || s.reverse.on === e && s.reverse.label === n);
2620
2619
  }
2621
- function xu(t, e, n) {
2622
- const r = Ru(t, e, n);
2620
+ function Ru(t, e, n) {
2621
+ const r = Mu(t, e, n);
2623
2622
  if (!r)
2624
2623
  throw new Error(`Couldn't find the link ${e}.${n} in your schema`);
2625
2624
  const { forward: i, reverse: s } = r;
@@ -2633,7 +2632,7 @@ function xu(t, e, n) {
2633
2632
  };
2634
2633
  }
2635
2634
  function Cr(t, e, n, r) {
2636
- const i = t ? xu(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2635
+ const i = t ? Ru(t, e, n) : null, s = W(), o = [W(), e, n], u = [W(), n, e];
2637
2636
  return Object.assign(Object.assign({
2638
2637
  id: s,
2639
2638
  // @ts-ignore: ts thinks it's any[]
@@ -2648,7 +2647,7 @@ function Cr(t, e, n, r) {
2648
2647
  isUnsynced: !0
2649
2648
  }, i || {}), r || {});
2650
2649
  }
2651
- const $u = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), Du = /* @__PURE__ */ new Set(["link", "unlink"]), Uu = /* @__PURE__ */ new Set(["create", "update", "merge"]), Lu = /* @__PURE__ */ new Set([
2650
+ const xu = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink"]), $u = /* @__PURE__ */ new Set(["link", "unlink"]), Du = /* @__PURE__ */ new Set(["create", "update", "merge"]), Uu = /* @__PURE__ */ new Set([
2652
2651
  "link",
2653
2652
  "unlink",
2654
2653
  "create",
@@ -2656,10 +2655,10 @@ const $u = /* @__PURE__ */ new Set(["create", "update", "merge", "link", "unlink
2656
2655
  "merge",
2657
2656
  "delete",
2658
2657
  "ruleParams"
2659
- ]), bn = { "unique?": !0, "index?": !0 }, Fu = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2660
- function Nu(t) {
2658
+ ]), bn = { "unique?": !0, "index?": !0 }, Lu = Object.assign(Object.assign({}, bn), { cardinality: "one" });
2659
+ function Fu(t) {
2661
2660
  const e = [], [n, r, i, s] = t;
2662
- if (!Lu.has(n))
2661
+ if (!Uu.has(n))
2663
2662
  return e;
2664
2663
  const o = yn(i);
2665
2664
  if (o && e.push({ etype: r, lookupPair: o }), n === "link")
@@ -2676,7 +2675,7 @@ function Nu(t) {
2676
2675
  }
2677
2676
  return e;
2678
2677
  }
2679
- function Ku({ attrsStore: t, schema: e }, n) {
2678
+ function Nu({ attrsStore: t, schema: e }, n) {
2680
2679
  var r, i;
2681
2680
  const s = /* @__PURE__ */ new Set(), o = [], u = [];
2682
2681
  function a(y, b) {
@@ -2701,10 +2700,10 @@ function Ku({ attrsStore: t, schema: e }, n) {
2701
2700
  }
2702
2701
  function p(y, b) {
2703
2702
  const _ = a(y, b), T = c(y, b);
2704
- f(_), f(T), !_ && !T && d(Cr(e, y, b, Fu));
2703
+ f(_), f(T), !_ && !T && d(Cr(e, y, b, Lu));
2705
2704
  }
2706
2705
  for (const y of n)
2707
- for (const { etype: b, lookupPair: _, linkLabel: T } of Nu(y)) {
2706
+ for (const { etype: b, lookupPair: _, linkLabel: T } of Fu(y)) {
2708
2707
  const g = _[0];
2709
2708
  if (T) {
2710
2709
  p(b, T);
@@ -2726,12 +2725,12 @@ function Ku({ attrsStore: t, schema: e }, n) {
2726
2725
  }
2727
2726
  for (const y of n) {
2728
2727
  const [b, _, T, g] = y;
2729
- if ($u.has(b)) {
2728
+ if (xu.has(b)) {
2730
2729
  const m = a(_, "id");
2731
2730
  f(m), m || d(wt(e, _, "id", { "unique?": !0 }));
2732
2731
  for (const O of Object.keys(g)) {
2733
2732
  const S = a(_, O);
2734
- if (f(S), Uu.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), Du.has(b)) {
2733
+ if (f(S), Du.has(b) && (S || d(wt(e, _, O, O === "id" ? { "unique?": !0 } : null))), $u.has(b)) {
2735
2734
  const C = c(_, O);
2736
2735
  !S && !C && d(Cr(e, _, O)), f(C);
2737
2736
  }
@@ -2746,8 +2745,8 @@ function Ku({ attrsStore: t, schema: e }, n) {
2746
2745
  }
2747
2746
  return [t, u];
2748
2747
  }
2749
- function qu(t, e) {
2750
- const r = (Array.isArray(e) ? e : [e]).flatMap((a) => bu(a)), [i, s] = Ku(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Iu(o, a));
2748
+ function Ku(t, e) {
2749
+ const r = (Array.isArray(e) ? e : [e]).flatMap((a) => yu(a)), [i, s] = Nu(t, r), o = Object.assign(Object.assign({}, t), { attrsStore: i }), u = r.flatMap((a) => Cu(o, a));
2751
2750
  return [...s, ...u];
2752
2751
  }
2753
2752
  var de = function(t, e, n, r) {
@@ -2781,7 +2780,7 @@ function Ir(t, e) {
2781
2780
  typeof requestIdleCallback > "u" ? t() : requestIdleCallback(t, { timeout: e });
2782
2781
  }
2783
2782
  const rt = "__meta";
2784
- class Wu {
2783
+ class qu {
2785
2784
  constructor(e, n) {
2786
2785
  }
2787
2786
  }
@@ -3053,13 +3052,13 @@ var ye = function(t, e, n, r) {
3053
3052
  c((r = r.apply(t, e || [])).next());
3054
3053
  });
3055
3054
  };
3056
- const zu = 6, Vu = ["kv", "querySubs", "syncSubs"];
3057
- function Bu(t) {
3055
+ const Wu = 6, zu = ["kv", "querySubs", "syncSubs"];
3056
+ function Vu(t) {
3058
3057
  return function(n) {
3059
3058
  console.error("Error in IndexedDB event", { source: t, event: n });
3060
3059
  };
3061
3060
  }
3062
- function Gu(t) {
3061
+ function Bu(t) {
3063
3062
  return ye(this, void 0, void 0, function* () {
3064
3063
  return new Promise((e) => {
3065
3064
  const n = indexedDB.open(t);
@@ -3075,7 +3074,7 @@ function Gu(t) {
3075
3074
  });
3076
3075
  });
3077
3076
  }
3078
- function Qu(t, e, n) {
3077
+ function Gu(t, e, n) {
3079
3078
  return ye(this, void 0, void 0, function* () {
3080
3079
  const r = (
3081
3080
  // Backwards compatibility for older versions where we JSON.stringified before storing
@@ -3119,9 +3118,9 @@ function Pr(t, e, n) {
3119
3118
  });
3120
3119
  });
3121
3120
  }
3122
- function Hu(t, e) {
3121
+ function Qu(t, e) {
3123
3122
  return ye(this, void 0, void 0, function* () {
3124
- const n = yield Gu(`instant_${t}_5`);
3123
+ const n = yield Bu(`instant_${t}_5`);
3125
3124
  if (!n)
3126
3125
  return;
3127
3126
  const r = yield new Promise((d, f) => {
@@ -3144,7 +3143,7 @@ function Hu(t, e) {
3144
3143
  for (const [d, f] of r)
3145
3144
  switch (d) {
3146
3145
  case "querySubs": {
3147
- const l = Qu(d, f, o);
3146
+ const l = Gu(d, f, o);
3148
3147
  u.push(l);
3149
3148
  break;
3150
3149
  }
@@ -3167,9 +3166,9 @@ function Hu(t, e) {
3167
3166
  });
3168
3167
  }
3169
3168
  const Mr = /* @__PURE__ */ new Map();
3170
- class Ui extends Wu {
3169
+ class Ui extends qu {
3171
3170
  constructor(e, n) {
3172
- super(e, n), this.dbName = `instant_${e}_${zu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3171
+ super(e, n), this.dbName = `instant_${e}_${Wu}`, this._storeName = n, this._appId = e, this._dbPromise = this._init();
3173
3172
  }
3174
3173
  _init() {
3175
3174
  return new Promise((e, n) => {
@@ -3180,8 +3179,8 @@ class Ui extends Wu {
3180
3179
  }, i.onsuccess = (s) => {
3181
3180
  const u = s.target.result;
3182
3181
  if (r) {
3183
- const a = Hu(this._appId, u).catch((c) => {
3184
- Bu("Error upgrading store from version 5 to 6.")(c);
3182
+ const a = Qu(this._appId, u).catch((c) => {
3183
+ Vu("Error upgrading store from version 5 to 6.")(c);
3185
3184
  });
3186
3185
  Mr.set(this.dbName, a), a.then(() => e(u)).catch(() => e(u));
3187
3186
  } else {
@@ -3195,7 +3194,7 @@ class Ui extends Wu {
3195
3194
  }
3196
3195
  _upgradeStore(e) {
3197
3196
  const r = e.target.result;
3198
- for (const i of Vu)
3197
+ for (const i of zu)
3199
3198
  r.objectStoreNames.contains(i) || r.createObjectStore(i);
3200
3199
  }
3201
3200
  getItem(e) {
@@ -3270,7 +3269,7 @@ class Ui extends Wu {
3270
3269
  });
3271
3270
  }
3272
3271
  }
3273
- var Yu = function(t, e, n, r) {
3272
+ var Hu = function(t, e, n, r) {
3274
3273
  function i(s) {
3275
3274
  return s instanceof n ? s : new n(function(o) {
3276
3275
  o(s);
@@ -3299,7 +3298,7 @@ var Yu = function(t, e, n, r) {
3299
3298
  };
3300
3299
  class Li {
3301
3300
  static getIsOnline() {
3302
- return Yu(this, void 0, void 0, function* () {
3301
+ return Hu(this, void 0, void 0, function* () {
3303
3302
  return navigator.onLine;
3304
3303
  });
3305
3304
  }
@@ -3324,7 +3323,7 @@ class qe extends Error {
3324
3323
  return "InstantError";
3325
3324
  }
3326
3325
  }
3327
- var Ju = function(t, e, n, r) {
3326
+ var Yu = function(t, e, n, r) {
3328
3327
  function i(s) {
3329
3328
  return s instanceof n ? s : new n(function(o) {
3330
3329
  o(s);
@@ -3364,7 +3363,7 @@ class Dt extends qe {
3364
3363
  }
3365
3364
  }
3366
3365
  function ae(t, e) {
3367
- return Ju(this, void 0, void 0, function* () {
3366
+ return Yu(this, void 0, void 0, function* () {
3368
3367
  const n = yield fetch(t, e), r = yield n.json();
3369
3368
  return n.status === 200 ? Promise.resolve(r) : Promise.reject(new Dt({ status: n.status, body: r }));
3370
3369
  });
@@ -3396,14 +3395,14 @@ var ze = function(t, e, n, r) {
3396
3395
  c((r = r.apply(t, e || [])).next());
3397
3396
  });
3398
3397
  };
3399
- function Zu({ apiURI: t, appId: e, email: n }) {
3398
+ function Ju({ apiURI: t, appId: e, email: n }) {
3400
3399
  return ae(`${t}/runtime/auth/send_magic_code`, {
3401
3400
  method: "POST",
3402
3401
  headers: { "content-type": "application/json" },
3403
3402
  body: JSON.stringify({ "app-id": e, email: n })
3404
3403
  });
3405
3404
  }
3406
- function Xu(t) {
3405
+ function Zu(t) {
3407
3406
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, email: r, code: i, refreshToken: s }) {
3408
3407
  return yield ae(`${e}/runtime/auth/verify_magic_code`, {
3409
3408
  method: "POST",
@@ -3416,7 +3415,7 @@ function Xu(t) {
3416
3415
  });
3417
3416
  });
3418
3417
  }
3419
- function ea(t) {
3418
+ function Xu(t) {
3420
3419
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3421
3420
  return yield ae(`${e}/runtime/auth/verify_refresh_token`, {
3422
3421
  method: "POST",
@@ -3428,7 +3427,7 @@ function ea(t) {
3428
3427
  });
3429
3428
  });
3430
3429
  }
3431
- function ta(t) {
3430
+ function ea(t) {
3432
3431
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n }) {
3433
3432
  return yield ae(`${e}/runtime/auth/sign_in_guest`, {
3434
3433
  method: "POST",
@@ -3453,7 +3452,7 @@ function Rr(t) {
3453
3452
  });
3454
3453
  });
3455
3454
  }
3456
- function na(t) {
3455
+ function ta(t) {
3457
3456
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, nonce: r, idToken: i, clientName: s, refreshToken: o }) {
3458
3457
  return yield ae(`${e}/runtime/oauth/id_token`, {
3459
3458
  method: "POST",
@@ -3468,7 +3467,7 @@ function na(t) {
3468
3467
  });
3469
3468
  });
3470
3469
  }
3471
- function ra(t) {
3470
+ function na(t) {
3472
3471
  return ze(this, arguments, void 0, function* ({ apiURI: e, appId: n, refreshToken: r }) {
3473
3472
  return yield ae(`${e}/runtime/signout`, {
3474
3473
  method: "POST",
@@ -3509,7 +3508,7 @@ var dt = function(t, e, n, r) {
3509
3508
  c((r = r.apply(t, e || [])).next());
3510
3509
  });
3511
3510
  };
3512
- function ia(t) {
3511
+ function ra(t) {
3513
3512
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, file: i, refreshToken: s, contentType: o, contentDisposition: u }) {
3514
3513
  const a = {
3515
3514
  app_id: n,
@@ -3524,7 +3523,7 @@ function ia(t) {
3524
3523
  });
3525
3524
  });
3526
3525
  }
3527
- function sa(t) {
3526
+ function ia(t) {
3528
3527
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3529
3528
  const { data: s } = yield ae(`${e}/storage/files?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3530
3529
  method: "DELETE",
@@ -3536,7 +3535,7 @@ function sa(t) {
3536
3535
  return s;
3537
3536
  });
3538
3537
  }
3539
- function oa(t) {
3538
+ function sa(t) {
3540
3539
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, fileName: r, refreshToken: i, metadata: s = {} }) {
3541
3540
  const { data: o } = yield ae(`${e}/storage/signed-upload-url`, {
3542
3541
  method: "POST",
@@ -3552,7 +3551,7 @@ function oa(t) {
3552
3551
  return o;
3553
3552
  });
3554
3553
  }
3555
- function ua(t, e) {
3554
+ function oa(t, e) {
3556
3555
  return dt(this, void 0, void 0, function* () {
3557
3556
  return (yield fetch(t, {
3558
3557
  method: "PUT",
@@ -3563,7 +3562,7 @@ function ua(t, e) {
3563
3562
  })).ok;
3564
3563
  });
3565
3564
  }
3566
- function aa(t) {
3565
+ function ua(t) {
3567
3566
  return dt(this, arguments, void 0, function* ({ apiURI: e, appId: n, path: r, refreshToken: i }) {
3568
3567
  const { data: s } = yield ae(`${e}/storage/signed-download-url?app_id=${n}&filename=${encodeURIComponent(r)}`, {
3569
3568
  method: "GET",
@@ -3585,7 +3584,7 @@ function xr(t, e) {
3585
3584
  n[r] = t[r];
3586
3585
  }), n;
3587
3586
  }
3588
- function ca(t, e, n) {
3587
+ function aa(t, e, n) {
3589
3588
  var r, i;
3590
3589
  const s = {
3591
3590
  peers: {}
@@ -3603,7 +3602,7 @@ function ca(t, e, n) {
3603
3602
  }
3604
3603
  return s;
3605
3604
  }
3606
- function da(t, e) {
3605
+ function ca(t, e) {
3607
3606
  if (t.isLoading !== e.isLoading || t.error !== e.error || (t.user || e.user) && (!t.user || !e.user || !wr(t.user, e.user)) || !yi(t.peers, e.peers))
3608
3607
  return !0;
3609
3608
  for (const r of Object.keys(t.peers))
@@ -3651,8 +3650,8 @@ function Ur(t) {
3651
3650
  }, e;
3652
3651
  }, {});
3653
3652
  }
3654
- const Wn = "v0.22.89-experimental.uuidfix.20281951052.1";
3655
- function fa(t, e) {
3653
+ const Wn = "v0.22.89-experimental.uuidfix.20282483875.1";
3654
+ function da(t, e) {
3656
3655
  return {
3657
3656
  info: t ? (...n) => console.info(...n, e()) : () => {
3658
3657
  },
@@ -3736,7 +3735,7 @@ const Lr = [
3736
3735
  "before",
3737
3736
  "fields",
3738
3737
  "aggregate"
3739
- ], la = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3738
+ ], fa = (t) => t.valueType || "unknown", qi = (t, e, n = !1) => {
3740
3739
  if (n || t == null)
3741
3740
  return !0;
3742
3741
  switch (e) {
@@ -3751,7 +3750,7 @@ const Lr = [
3751
3750
  default:
3752
3751
  return !0;
3753
3752
  }
3754
- }, ha = (t, e, n, r, i, s, o) => {
3753
+ }, la = (t, e, n, r, i, s, o) => {
3755
3754
  const u = s.valueType === "json", a = (c, d, f) => {
3756
3755
  if (!qi(f, d, u))
3757
3756
  throw new R(`Invalid value for operator '${c}' on attribute '${r}' in entity '${i}'. Expected ${d}, but received: ${typeof f}`, o);
@@ -3784,16 +3783,16 @@ const Lr = [
3784
3783
  throw new R(`Unknown operator '${t}' for attribute '${r}' in entity '${i}'`, o);
3785
3784
  }
3786
3785
  }, Le = (t, e, n, r, i) => {
3787
- const s = la(n), o = n.valueType === "json";
3786
+ const s = fa(n), o = n.valueType === "json";
3788
3787
  if (typeof t == "object" && t !== null && !Array.isArray(t)) {
3789
3788
  if (o)
3790
3789
  return;
3791
3790
  const a = t;
3792
3791
  for (const [c, d] of Object.entries(a))
3793
- ha(c, d, s, e, r, n, `${i}.${c}`);
3792
+ la(c, d, s, e, r, n, `${i}.${c}`);
3794
3793
  } else if (!qi(t, s, o))
3795
3794
  throw new R(`Invalid value for attribute '${e}' in entity '${r}'. Expected ${s}, but received: ${typeof t}`, i);
3796
- }, pa = (t, e, n, r, i) => {
3795
+ }, ha = (t, e, n, r, i) => {
3797
3796
  const s = t.split(".");
3798
3797
  if (s.length < 2)
3799
3798
  throw new R(`Invalid dot notation path '${t}'. Must contain at least one dot.`, i);
@@ -3843,7 +3842,7 @@ const Lr = [
3843
3842
  continue;
3844
3843
  }
3845
3844
  if (i.includes(".")) {
3846
- pa(i, s, e, n, `${r}.${i}`);
3845
+ ha(i, s, e, n, `${r}.${i}`);
3847
3846
  continue;
3848
3847
  }
3849
3848
  const o = n.entities[e];
@@ -3863,7 +3862,7 @@ const Lr = [
3863
3862
  Le(s, i, c, e, `${r}.${i}`);
3864
3863
  }
3865
3864
  }
3866
- }, ya = (t, e, n, r, i = 0) => {
3865
+ }, pa = (t, e, n, r, i = 0) => {
3867
3866
  for (const o of Object.keys(t))
3868
3867
  if (!Lr.includes(o))
3869
3868
  throw new R(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Lr.join(", ")}. Found: ${o}`, r);
@@ -3902,7 +3901,7 @@ const Lr = [
3902
3901
  const u = t[o];
3903
3902
  if (typeof u != "object" || u === null)
3904
3903
  throw new R(`Query parameter '$' must be an object in entity '${e}', but received: ${typeof u}`, `${r}.$`);
3905
- ya(u, e, n, `${r}.$`, i);
3904
+ pa(u, e, n, `${r}.$`, i);
3906
3905
  }
3907
3906
  }, Fr = (t, e) => {
3908
3907
  if (typeof t != "object" || t === null)
@@ -3929,19 +3928,19 @@ class ie extends Error {
3929
3928
  super(e), this.name = "TransactionValidationError";
3930
3929
  }
3931
3930
  }
3932
- const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
3931
+ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ya = (t, e) => new ie(`Entity '${t}' does not exist in schema. Available entities: ${Vi(e)}`), Kr = {
3933
3932
  string: (t) => typeof t == "string",
3934
3933
  number: (t) => typeof t == "number" && !isNaN(t),
3935
3934
  boolean: (t) => typeof t == "boolean",
3936
3935
  date: (t) => t instanceof Date || typeof t == "string" || typeof t == "number",
3937
3936
  json: () => !0
3938
- }, _a = (t, e) => {
3937
+ }, ba = (t, e) => {
3939
3938
  var n, r;
3940
3939
  return t == null ? !0 : (r = (n = Kr[e.valueType]) === null || n === void 0 ? void 0 : n.call(Kr, t)) !== null && r !== void 0 ? r : !1;
3941
3940
  }, Bi = (t, e) => {
3942
3941
  const n = e.entities[t];
3943
3942
  if (!n)
3944
- throw ba(t, Object.keys(e.entities));
3943
+ throw ya(t, Object.keys(e.entities));
3945
3944
  return n;
3946
3945
  }, Yt = (t, e, n) => {
3947
3946
  const r = Bi(t, n);
@@ -3951,7 +3950,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`E
3951
3950
  if (i === "id")
3952
3951
  continue;
3953
3952
  const o = r.attrs[i];
3954
- if (o && !_a(s, o))
3953
+ if (o && !ba(s, o))
3955
3954
  throw new ie(`Invalid value for attribute '${i}' in entity '${t}'. Expected ${o.valueType}, but received: ${typeof s}`);
3956
3955
  }
3957
3956
  }, qr = (t, e, n) => {
@@ -3972,7 +3971,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`E
3972
3971
  throw new ie(`Invalid UUID in link '${i}' for entity '${t}'. Expected a UUID, but received: ${s}`);
3973
3972
  }
3974
3973
  }
3975
- }, ga = {
3974
+ }, _a = {
3976
3975
  create: Yt,
3977
3976
  update: Yt,
3978
3977
  merge: Yt,
@@ -3980,7 +3979,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`E
3980
3979
  unlink: qr,
3981
3980
  delete: () => {
3982
3981
  }
3983
- }, wa = (t, e) => {
3982
+ }, ga = (t, e) => {
3984
3983
  if (!e)
3985
3984
  return;
3986
3985
  const [n, r, i, s] = t;
@@ -3988,9 +3987,9 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`E
3988
3987
  throw new ie(`Invalid id for entity '${r}'. Expected a UUID, but received: ${i}`);
3989
3988
  if (typeof r != "string")
3990
3989
  throw new ie(`Entity name must be a string, but received: ${typeof r}`);
3991
- const o = ga[n];
3990
+ const o = _a[n];
3992
3991
  o && s !== void 0 && o(r, s, e);
3993
- }, Ta = (t, e) => {
3992
+ }, wa = (t, e) => {
3994
3993
  const n = Array.isArray(t) ? t : [t];
3995
3994
  for (const r of n) {
3996
3995
  if (!r || typeof r != "object")
@@ -4000,7 +3999,7 @@ const Vi = (t) => t.length > 0 ? t.join(", ") : "none", ba = (t, e) => new ie(`E
4000
3999
  for (const i of r.__ops) {
4001
4000
  if (!Array.isArray(i))
4002
4001
  throw new ie(`Transaction operation must be an array, but received: ${typeof i}`);
4003
- wa(i, e);
4002
+ ga(i, e);
4004
4003
  }
4005
4004
  }
4006
4005
  };
@@ -4062,7 +4061,7 @@ class zr {
4062
4061
  return this.conn.send(JSON.stringify(e));
4063
4062
  }
4064
4063
  }
4065
- class ma {
4064
+ class Ta {
4066
4065
  constructor(e, n) {
4067
4066
  this.type = "sse", this.initParams = null, this.sendQueue = [], this.closeFired = !1, this.sseInitTimeout = void 0, this.id = `${this.type}_${Gi++}`, this.url = n, this.ES = e, this.conn = new e(n), this.sseInitTimeout = setTimeout(() => {
4068
4067
  this.initParams || this.handleError();
@@ -4175,7 +4174,7 @@ var Vr = function(t, e, n, r) {
4175
4174
  c((r = r.apply(t, e || [])).next());
4176
4175
  });
4177
4176
  };
4178
- function va(t, e) {
4177
+ function ma(t, e) {
4179
4178
  const n = t.values;
4180
4179
  if (n) {
4181
4180
  const r = mi(n.attrsStore, null);
@@ -4187,7 +4186,7 @@ function va(t, e) {
4187
4186
  }
4188
4187
  return t;
4189
4188
  }
4190
- function Sa(t, e) {
4189
+ function va(t, e) {
4191
4190
  var n;
4192
4191
  if (e.values) {
4193
4192
  const r = [];
@@ -4199,7 +4198,7 @@ function Sa(t, e) {
4199
4198
  } else
4200
4199
  return e;
4201
4200
  }
4202
- function Oa(t, e, n) {
4201
+ function Sa(t, e, n) {
4203
4202
  var r, i;
4204
4203
  const s = (r = e == null ? void 0 : e.state) === null || r === void 0 ? void 0 : r.txId, o = (i = n == null ? void 0 : n.state) === null || i === void 0 ? void 0 : i.txId;
4205
4204
  return s && (!o || s > o) ? e : o && (!s || o > s) ? n : e || n;
@@ -4226,7 +4225,7 @@ function Gr(t, e, n) {
4226
4225
  break;
4227
4226
  }
4228
4227
  }
4229
- function Ea(t, e, n) {
4228
+ function Oa(t, e, n) {
4230
4229
  var r, i, s, o;
4231
4230
  const u = {};
4232
4231
  for (const { action: a, triple: c } of n) {
@@ -4254,14 +4253,14 @@ function Ea(t, e, n) {
4254
4253
  function Tt(t, e) {
4255
4254
  return { [t.table]: e.map((n) => n.entity) };
4256
4255
  }
4257
- function Aa(t, e) {
4256
+ function Ea(t, e) {
4258
4257
  var n;
4259
4258
  if (t.orderFieldType)
4260
4259
  return t.orderFieldType;
4261
4260
  const r = t.orderField === "serverCreatedAt" ? "number" : (n = K(e(), t.table, t.orderField)) === null || n === void 0 ? void 0 : n["checked-data-type"];
4262
4261
  return t.orderFieldType = r, r;
4263
4262
  }
4264
- function ka(t, e, n) {
4263
+ function Aa(t, e, n) {
4265
4264
  const r = e;
4266
4265
  if (t.orderField === "serverCreatedAt") {
4267
4266
  n.sort(t.orderDirection === "asc" ? function(o, u) {
@@ -4282,13 +4281,13 @@ var ve;
4282
4281
  (function(t) {
4283
4282
  t.InitialSyncBatch = "InitialSyncBatch", t.InitialSyncComplete = "InitialSyncComplete", t.LoadFromStorage = "LoadFromStorage", t.SyncTransaction = "SyncTransaction", t.Error = "Error";
4284
4283
  })(ve || (ve = {}));
4285
- class ja {
4284
+ class ka {
4286
4285
  constructor(e, n, r, i, s, o) {
4287
4286
  this.callbacks = {}, this.idToHash = {}, this.trySend = e, this.config = r, this.log = i, this.createStore = s, this.getAttrs = o, this.subs = new _n({
4288
4287
  persister: n,
4289
- merge: Oa,
4290
- serialize: Sa,
4291
- parse: (u, a) => va(a, this.config.useDateObjects),
4288
+ merge: Sa,
4289
+ serialize: va,
4290
+ parse: (u, a) => ma(a, this.config.useDateObjects),
4292
4291
  objectSize: (u) => {
4293
4292
  var a;
4294
4293
  return ((a = u.values) === null || a === void 0 ? void 0 : a.entities.length) || 0;
@@ -4490,7 +4489,7 @@ class ja {
4490
4489
  const S = p[O];
4491
4490
  if (io(S.store, g)) {
4492
4491
  Gr(S.store, l.attrsStore, m);
4493
- const C = Jt(u, S.store, l.attrsStore), $ = Ea(S.store, l.attrsStore, m)[g];
4492
+ const C = Jt(u, S.store, l.attrsStore), $ = Oa(S.store, l.attrsStore, m)[g];
4494
4493
  C ? (y.push({
4495
4494
  oldEntity: S.entity,
4496
4495
  newEntity: C,
@@ -4521,8 +4520,8 @@ class ja {
4521
4520
  const _ = [];
4522
4521
  for (const g of d.sort().reverse())
4523
4522
  _.push(p[g].entity), p.splice(g, 1);
4524
- const T = Aa(u, this.getAttrs);
4525
- ka(u, T, p), this.notifyCbs(o, {
4523
+ const T = Ea(u, this.getAttrs);
4524
+ Aa(u, T, p), this.notifyCbs(o, {
4526
4525
  type: ve.SyncTransaction,
4527
4526
  data: Tt(u, (i = u.values) === null || i === void 0 ? void 0 : i.entities),
4528
4527
  added: b,
@@ -4603,23 +4602,23 @@ const he = {
4603
4602
  AUTHENTICATED: "authenticated",
4604
4603
  CLOSED: "closed",
4605
4604
  ERRORED: "errored"
4606
- }, Ca = 3e4, Ia = 3e4, Pa = 200, Ma = {
4605
+ }, ja = 3e4, Ca = 3e4, Ia = 200, Pa = {
4607
4606
  apiURI: "https://api.instantdb.com",
4608
4607
  websocketURI: "wss://api.instantdb.com/runtime/session"
4609
4608
  }, Zt = "_instant_oauth_redirect", Ge = "currentUser";
4610
- function Ra({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4609
+ function Ma({ transportType: t, appId: e, apiURI: n, wsURI: r, EventSourceImpl: i }) {
4611
4610
  if (!i)
4612
4611
  return new zr(`${r}?app_id=${e}`);
4613
4612
  switch (t) {
4614
4613
  case "ws":
4615
4614
  return new zr(`${r}?app_id=${e}`);
4616
4615
  case "sse":
4617
- return new ma(i, `${n}/runtime/sse?app_id=${e}`);
4616
+ return new Ta(i, `${n}/runtime/sse?app_id=${e}`);
4618
4617
  default:
4619
4618
  throw new Error("Unknown transport type " + t);
4620
4619
  }
4621
4620
  }
4622
- function xa() {
4621
+ function Ra() {
4623
4622
  return typeof window < "u" || typeof chrome < "u";
4624
4623
  }
4625
4624
  const Qr = {
@@ -4628,7 +4627,7 @@ const Qr = {
4628
4627
  "refresh-presence": !0,
4629
4628
  "patch-presence": !0
4630
4629
  };
4631
- function $a(t, e) {
4630
+ function xa(t, e) {
4632
4631
  var n;
4633
4632
  const r = typeof t == "string" ? JSON.parse(t) : t;
4634
4633
  if (!((n = r == null ? void 0 : r.result) === null || n === void 0) && n.store) {
@@ -4640,7 +4639,7 @@ function $a(t, e) {
4640
4639
  }
4641
4640
  return r;
4642
4641
  }
4643
- function Da(t, e) {
4642
+ function $a(t, e) {
4644
4643
  const { result: n } = e, i = Qi(e, ["result"]);
4645
4644
  if (n) {
4646
4645
  const s = Object.assign(Object.assign({}, n), { store: wi(n.store), attrsStore: n.attrsStore.toJSON() });
@@ -4648,7 +4647,7 @@ function Da(t, e) {
4648
4647
  }
4649
4648
  return i;
4650
4649
  }
4651
- function Ua(t, e) {
4650
+ function Da(t, e) {
4652
4651
  switch (t) {
4653
4652
  case "pendingMutations":
4654
4653
  return new Map(typeof e == "string" ? JSON.parse(e) : e);
@@ -4656,7 +4655,7 @@ function Ua(t, e) {
4656
4655
  return e;
4657
4656
  }
4658
4657
  }
4659
- function La(t, e) {
4658
+ function Ua(t, e) {
4660
4659
  switch (t) {
4661
4660
  case "pendingMutations":
4662
4661
  return [...e.entries()];
@@ -4664,7 +4663,7 @@ function La(t, e) {
4664
4663
  return e;
4665
4664
  }
4666
4665
  }
4667
- function Fa(t, e, n) {
4666
+ function La(t, e, n) {
4668
4667
  const r = e == null ? void 0 : e.result, i = n == null ? void 0 : n.result;
4669
4668
  return r && !i && n && (n.result = r), n || e;
4670
4669
  }
@@ -4674,7 +4673,7 @@ function Hr(t) {
4674
4673
  return u == a ? r < s ? -1 : r > s ? 1 : 0 : u - a;
4675
4674
  });
4676
4675
  }
4677
- class Na {
4676
+ class Fa {
4678
4677
  constructor(e, n = Ui, r = Li, i, s) {
4679
4678
  var o, u, a;
4680
4679
  if (this._isOnline = !0, this._isShutdown = !1, this.status = he.CONNECTING, this.queryCbs = {}, this.queryOnceDfds = {}, this.authCbs = [], this.attrsCbs = [], this.mutationErrorCbs = [], this.connectionStatusCbs = [], this.mutationDeferredStore = /* @__PURE__ */ new Map(), this._reconnectTimeoutId = null, this._reconnectTimeoutMs = 0, this._transportType = "ws", this._wsOk = null, this._localIdPromises = {}, this._errorMessage = null, this._oauthCallbackResponse = null, this._linkIndex = null, this._rooms = {}, this._roomsPendingLeave = {}, this._presence = {}, this._broadcastQueue = [], this._broadcastSubs = {}, this._currentUserCached = { isLoading: !0, error: void 0, user: void 0 }, this._beforeUnloadCbs = [], this._dataForQueryCache = {}, this._inFlightMutationEventIds = /* @__PURE__ */ new Set(), this._onMergeKv = (c, d, f) => {
@@ -4707,9 +4706,9 @@ class Na {
4707
4706
  }, this.notifyQueryError = (c, d) => {
4708
4707
  (this.queryCbs[c] || []).forEach((l) => l.cb({ error: d }));
4709
4708
  }, this.pushTx = (c) => {
4710
- this.config.disableValidation || Ta(c, this.config.schema);
4709
+ this.config.disableValidation || wa(c, this.config.schema);
4711
4710
  try {
4712
- const d = qu({
4711
+ const d = Ku({
4713
4712
  attrsStore: this.optimisticAttrs(),
4714
4713
  schema: this.config.schema,
4715
4714
  stores: Object.values(this.querySubs.currentValue).map((f) => {
@@ -4798,7 +4797,7 @@ class Na {
4798
4797
  return;
4799
4798
  }
4800
4799
  this._log.info("[socket][close]", d.id, "schedule reconnect, ms =", this._reconnectTimeoutMs), this._scheduleReconnect();
4801
- }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Ma), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ia, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Pa, this._log = fa(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!xa()) {
4800
+ }, this._EventSource = s, this.config = Object.assign(Object.assign({}, Pa), e), this.queryCacheLimit = (o = this.config.queryCacheLimit) !== null && o !== void 0 ? o : 10, this._pendingTxCleanupTimeout = (u = this.config.pendingTxCleanupTimeout) !== null && u !== void 0 ? u : Ca, this._pendingMutationCleanupThreshold = (a = this.config.pendingMutationCleanupThreshold) !== null && a !== void 0 ? a : Ia, this._log = da(e.verbose || qn || Fi, () => this._reactorStats()), this.versions = Object.assign(Object.assign({}, i || {}), { "@instantdb/core": Wn }), this.config.schema && (this._linkIndex = Ur(this.config.schema)), !!Ra()) {
4802
4801
  if (!e.appId)
4803
4802
  throw new Error("Instant must be initialized with an appId.");
4804
4803
  if (!Ne(e.appId))
@@ -4813,7 +4812,7 @@ class Na {
4813
4812
  } catch (f) {
4814
4813
  this._log.error("[error] handle broadcast channel", f);
4815
4814
  }
4816
- }))), this._initStorage(n), this._syncTable = new ja(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4815
+ }))), this._initStorage(n), this._syncTable = new ka(this._trySendAuthed.bind(this), new n(this.config.appId, "syncSubs"), {
4817
4816
  useDateObjects: this.config.useDateObjects
4818
4817
  }, this._log, (c) => Et(this.ensureAttrs(), c, this.config.enableCardinalityInference, this.config.useDateObjects), () => this.ensureAttrs()), this._oauthCallbackResponse = this._oauthLoginInit(), this.getCurrentUser(), r.getIsOnline().then((c) => {
4819
4818
  this._isOnline = c, this._startSocket(), r.listen((d) => {
@@ -4843,9 +4842,9 @@ class Na {
4843
4842
  _initStorage(e) {
4844
4843
  this.querySubs = new _n({
4845
4844
  persister: new e(this.config.appId, "querySubs"),
4846
- merge: Fa,
4847
- serialize: Da,
4848
- parse: (n, r) => $a(r, this.config.useDateObjects),
4845
+ merge: La,
4846
+ serialize: $a,
4847
+ parse: (n, r) => xa(r, this.config.useDateObjects),
4849
4848
  // objectSize
4850
4849
  objectSize: (n) => {
4851
4850
  var r, i, s, o;
@@ -4864,8 +4863,8 @@ class Na {
4864
4863
  }), this.querySubs.onKeyLoaded = (n) => this._onQuerySubLoaded(n), this.kv = new _n({
4865
4864
  persister: new e(this.config.appId, "kv"),
4866
4865
  merge: this._onMergeKv,
4867
- serialize: La,
4868
- parse: Ua,
4866
+ serialize: Ua,
4867
+ parse: Da,
4869
4868
  objectSize: () => 0,
4870
4869
  logger: this._log,
4871
4870
  saveThrottleMs: 100,
@@ -5178,7 +5177,7 @@ class Na {
5178
5177
  if (!this.querySubs)
5179
5178
  return i.reject(new Error("We can't run `queryOnce` on the backend. Use adminAPI.query instead: https://www.instantdb.com/docs/backend#query")), i.promise;
5180
5179
  const s = B(e), o = this._startQuerySub(e, s);
5181
- return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), Ca), i.promise;
5180
+ return this.queryOnceDfds[s] = (r = this.queryOnceDfds[s]) !== null && r !== void 0 ? r : [], this.queryOnceDfds[s].push({ q: e, dfd: i, eventId: o }), setTimeout(() => i.reject(new Error("Query timed out")), ja), i.promise;
5182
5181
  }
5183
5182
  _completeQueryOnce(e, n, r) {
5184
5183
  this.queryOnceDfds[n] && (this.queryOnceDfds[n] = this.queryOnceDfds[n].filter((i) => i.dfd !== r), this._cleanupQuery(e, n));
@@ -5245,7 +5244,7 @@ class Na {
5245
5244
  u = !0;
5246
5245
  continue;
5247
5246
  }
5248
- const b = u ? _u(o, p) : p;
5247
+ const b = u ? bu(o, p) : p;
5249
5248
  l.push(b);
5250
5249
  }
5251
5250
  return u ? l : d;
@@ -5411,7 +5410,7 @@ class Na {
5411
5410
  return;
5412
5411
  }
5413
5412
  const e = this._transport;
5414
- this._transport = Ra({
5413
+ this._transport = Ma({
5415
5414
  transportType: this._transportType,
5416
5415
  appId: this.config.appId,
5417
5416
  apiURI: this.config.apiURI,
@@ -5614,7 +5613,7 @@ class Na {
5614
5613
  }), this._reconnectTimeoutMs = 0, this._transport.close(), this._oauthCallbackResponse = null, this.notifyAuthSubs(n);
5615
5614
  }
5616
5615
  sendMagicCode({ email: e }) {
5617
- return Zu({
5616
+ return Ju({
5618
5617
  apiURI: this.config.apiURI,
5619
5618
  appId: this.config.appId,
5620
5619
  email: e
@@ -5623,7 +5622,7 @@ class Na {
5623
5622
  signInWithMagicCode(e) {
5624
5623
  return N(this, arguments, void 0, function* ({ email: n, code: r }) {
5625
5624
  var i;
5626
- const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Xu({
5625
+ const s = yield this.getCurrentUser(), o = ((i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.type) === "guest", u = yield Zu({
5627
5626
  apiURI: this.config.apiURI,
5628
5627
  appId: this.config.appId,
5629
5628
  email: n,
@@ -5635,7 +5634,7 @@ class Na {
5635
5634
  }
5636
5635
  signInWithCustomToken(e) {
5637
5636
  return N(this, void 0, void 0, function* () {
5638
- const n = yield ea({
5637
+ const n = yield Xu({
5639
5638
  apiURI: this.config.apiURI,
5640
5639
  appId: this.config.appId,
5641
5640
  refreshToken: e
@@ -5645,7 +5644,7 @@ class Na {
5645
5644
  }
5646
5645
  signInAsGuest() {
5647
5646
  return N(this, void 0, void 0, function* () {
5648
- const e = yield ta({
5647
+ const e = yield ea({
5649
5648
  apiURI: this.config.apiURI,
5650
5649
  appId: this.config.appId
5651
5650
  });
@@ -5661,7 +5660,7 @@ class Na {
5661
5660
  this._log.info("[auth-invalidate] skipped invalidateToken");
5662
5661
  return;
5663
5662
  }
5664
- ra({
5663
+ na({
5665
5664
  apiURI: this.config.apiURI,
5666
5665
  appId: this.config.appId,
5667
5666
  refreshToken: i
@@ -5719,7 +5718,7 @@ class Na {
5719
5718
  signInWithIdToken(e) {
5720
5719
  return N(this, arguments, void 0, function* ({ idToken: n, clientName: r, nonce: i }) {
5721
5720
  var s;
5722
- const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield na({
5721
+ const o = yield this.getCurrentUser(), u = (s = o == null ? void 0 : o.user) === null || s === void 0 ? void 0 : s.refresh_token, a = yield ta({
5723
5722
  apiURI: this.config.apiURI,
5724
5723
  appId: this.config.appId,
5725
5724
  idToken: n,
@@ -5760,7 +5759,7 @@ class Na {
5760
5759
  // TODO: look into typing again
5761
5760
  getPresence(e, n, r = {}) {
5762
5761
  const i = this._rooms[n], s = this._presence[n];
5763
- return !i || !s || !s.result ? null : Object.assign(Object.assign({}, ca(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5762
+ return !i || !s || !s.result ? null : Object.assign(Object.assign({}, aa(s.result, r, this._sessionId)), { isLoading: !i.isConnected, error: i.error });
5764
5763
  }
5765
5764
  // TODO: look into typing again
5766
5765
  publishPresence(e, n, r) {
@@ -5810,7 +5809,7 @@ class Na {
5810
5809
  }
5811
5810
  _notifyPresenceSub(e, n) {
5812
5811
  const r = this.getPresence("", e, n);
5813
- r && (n.prev && !da(r, n.prev) || (n.prev = r, n.cb(r)));
5812
+ r && (n.prev && !ca(r, n.prev) || (n.prev = r, n.cb(r)));
5814
5813
  }
5815
5814
  _patchPresencePeers(e, n) {
5816
5815
  var r, i, s;
@@ -5884,14 +5883,14 @@ class Na {
5884
5883
  return N(this, void 0, void 0, function* () {
5885
5884
  var i;
5886
5885
  const s = yield this.getCurrentUser(), o = (i = s == null ? void 0 : s.user) === null || i === void 0 ? void 0 : i.refresh_token;
5887
- return ia(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5886
+ return ra(Object.assign(Object.assign({}, r), { apiURI: this.config.apiURI, appId: this.config.appId, path: e, file: n, refreshToken: o }));
5888
5887
  });
5889
5888
  }
5890
5889
  deleteFile(e) {
5891
5890
  return N(this, void 0, void 0, function* () {
5892
5891
  var n;
5893
5892
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5894
- return yield sa({
5893
+ return yield ia({
5895
5894
  apiURI: this.config.apiURI,
5896
5895
  appId: this.config.appId,
5897
5896
  path: e,
@@ -5904,20 +5903,20 @@ class Na {
5904
5903
  upload(e, n) {
5905
5904
  return N(this, void 0, void 0, function* () {
5906
5905
  var r;
5907
- const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield oa({
5906
+ const i = yield this.getCurrentUser(), s = (r = i == null ? void 0 : i.user) === null || r === void 0 ? void 0 : r.refresh_token, o = e || n.name, u = yield sa({
5908
5907
  apiURI: this.config.apiURI,
5909
5908
  appId: this.config.appId,
5910
5909
  fileName: o,
5911
5910
  refreshToken: s
5912
5911
  });
5913
- return yield ua(u, n);
5912
+ return yield oa(u, n);
5914
5913
  });
5915
5914
  }
5916
5915
  getDownloadUrl(e) {
5917
5916
  return N(this, void 0, void 0, function* () {
5918
5917
  var n;
5919
5918
  const r = yield this.getCurrentUser(), i = (n = r == null ? void 0 : r.user) === null || n === void 0 ? void 0 : n.refresh_token;
5920
- return yield aa({
5919
+ return yield ua({
5921
5920
  apiURI: this.config.apiURI,
5922
5921
  appId: this.config.appId,
5923
5922
  path: e,
@@ -5926,7 +5925,7 @@ class Na {
5926
5925
  });
5927
5926
  }
5928
5927
  }
5929
- function Ka(t, e) {
5928
+ function Na(t, e) {
5930
5929
  return new Lt(
5931
5930
  Hi(t, e),
5932
5931
  // (XXX): LinksDef<any> stems from TypeScript’s inability to reconcile the
@@ -5938,25 +5937,25 @@ function Ka(t, e) {
5938
5937
  void 0
5939
5938
  );
5940
5939
  }
5941
- function qa(t) {
5940
+ function Ka(t) {
5942
5941
  return new Ut(t, {});
5943
5942
  }
5944
- function Wa() {
5943
+ function qa() {
5945
5944
  return new H("string", !0, !1);
5946
5945
  }
5947
- function za() {
5946
+ function Wa() {
5948
5947
  return new H("number", !0, !1);
5949
5948
  }
5950
- function Va() {
5949
+ function za() {
5951
5950
  return new H("boolean", !0, !1);
5952
5951
  }
5953
- function Ba() {
5952
+ function Va() {
5954
5953
  return new H("date", !0, !1);
5955
5954
  }
5956
- function Ga() {
5955
+ function Ba() {
5957
5956
  return new H("json", !0, !1);
5958
5957
  }
5959
- function Qa() {
5958
+ function Ga() {
5960
5959
  return new H("json", !0, !1);
5961
5960
  }
5962
5961
  function Hi(t, e) {
@@ -5975,7 +5974,7 @@ function Hi(t, e) {
5975
5974
  new Ut(c.attrs, Object.assign(Object.assign({}, o.fwd[a]), o.rev[a]))
5976
5975
  ]));
5977
5976
  }
5978
- function Ha({ entities: t, links: e, rooms: n }) {
5977
+ function Qa({ entities: t, links: e, rooms: n }) {
5979
5978
  const r = e ?? {}, i = n ?? {};
5980
5979
  return new Lt(
5981
5980
  Hi(t, r),
@@ -5988,23 +5987,23 @@ function Ha({ entities: t, links: e, rooms: n }) {
5988
5987
  i
5989
5988
  );
5990
5989
  }
5991
- const Nc = {
5990
+ const Fc = {
5992
5991
  // constructs
5993
- graph: Ka,
5994
- schema: Ha,
5995
- entity: qa,
5992
+ graph: Na,
5993
+ schema: Qa,
5994
+ entity: Ka,
5996
5995
  // value types
5997
- string: Wa,
5998
- number: za,
5999
- boolean: Va,
6000
- date: Ba,
6001
- json: Ga,
6002
- any: Qa
5996
+ string: qa,
5997
+ number: Wa,
5998
+ boolean: za,
5999
+ date: Va,
6000
+ json: Ba,
6001
+ any: Ga
6003
6002
  };
6004
6003
  let mt;
6005
- function Ya(t, e) {
6004
+ function Ha(t, e) {
6006
6005
  mt == null || mt.dispose();
6007
- const n = nc(e), r = Xa(e, u), i = Za(Ja(t));
6006
+ const n = tc(e), r = Za(e, u), i = Ja(Ya(t));
6008
6007
  function s(d) {
6009
6008
  var f;
6010
6009
  d.source === i.element.contentWindow && ((f = d.data) === null || f === void 0 ? void 0 : f.type) === "close" && n.isVisible() && u();
@@ -6026,10 +6025,10 @@ function Ya(t, e) {
6026
6025
  }
6027
6026
  return c();
6028
6027
  }
6029
- function Ja(t) {
6028
+ function Ya(t) {
6030
6029
  return `${qn || Ni ? "http://localhost:3000" : "https://instantdb.com"}/_devtool?appId=${t}`;
6031
6030
  }
6032
- function Za(t) {
6031
+ function Ja(t) {
6033
6032
  const e = document.createElement("iframe");
6034
6033
  return e.src = t, e.className = "instant-devtool-iframe", Object.assign(e.style, {
6035
6034
  width: "100%",
@@ -6038,7 +6037,7 @@ function Za(t) {
6038
6037
  border: "none"
6039
6038
  }), { element: e };
6040
6039
  }
6041
- function Xa(t, e) {
6040
+ function Za(t, e) {
6042
6041
  const n = `
6043
6042
  <svg width="32" height="32" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
6044
6043
  <rect width="512" height="512" fill="black"/>
@@ -6048,7 +6047,7 @@ function Xa(t, e) {
6048
6047
  return r.innerHTML = n, r.className = "instant-devtool-toggler", Object.assign(r.style, Object.assign(Object.assign({
6049
6048
  // pos
6050
6049
  position: "fixed"
6051
- }, ec(t.position)), {
6050
+ }, Xa(t.position)), {
6052
6051
  height: "32px",
6053
6052
  width: "32px",
6054
6053
  // layout
@@ -6063,7 +6062,7 @@ function Xa(t, e) {
6063
6062
  cursor: "pointer"
6064
6063
  })), r.addEventListener("click", e), { element: r };
6065
6064
  }
6066
- function ec(t) {
6065
+ function Xa(t) {
6067
6066
  switch (t) {
6068
6067
  case "bottom-left":
6069
6068
  return { bottom: "24px", left: "24px" };
@@ -6075,7 +6074,7 @@ function ec(t) {
6075
6074
  return { top: "24px", left: "24px" };
6076
6075
  }
6077
6076
  }
6078
- function tc(t) {
6077
+ function ec(t) {
6079
6078
  switch (t) {
6080
6079
  case "bottom-left":
6081
6080
  return { bottom: "24px", right: "24px", left: "60px", top: "72px" };
@@ -6087,23 +6086,23 @@ function tc(t) {
6087
6086
  return { top: "24px", right: "24px", left: "60px", bottom: "72px" };
6088
6087
  }
6089
6088
  }
6090
- function nc(t) {
6089
+ function tc(t) {
6091
6090
  const e = document.createElement("div");
6092
- Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, tc(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6091
+ Object.assign(e.style, Object.assign(Object.assign({ position: "fixed" }, ec(t.position)), { display: "block", borderRadius: "4px", border: "1px #ccc solid", boxShadow: "0px 0px 8px #00000044", backgroundColor: "#eee", zIndex: "999990" })), e.style.display = "none", e.className = "instant-devtool-container";
6093
6092
  function n() {
6094
6093
  return e.style.display !== "none";
6095
6094
  }
6096
6095
  return { element: e, isVisible: n };
6097
6096
  }
6098
- const rc = {
6097
+ const nc = {
6099
6098
  apiURI: "https://api.instantdb.com",
6100
6099
  websocketURI: "wss://api.instantdb.com/runtime/session"
6101
6100
  };
6102
- function ic() {
6101
+ function rc() {
6103
6102
  var t;
6104
6103
  return globalThis.__instantDbSchemaHashStore = (t = globalThis.__instantDbSchemaHashStore) !== null && t !== void 0 ? t : /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
6105
6104
  }
6106
- function sc() {
6105
+ function ic() {
6107
6106
  var t;
6108
6107
  return globalThis.__instantDbStore = (t = globalThis.__instantDbStore) !== null && t !== void 0 ? t : {}, globalThis.__instantDbStore;
6109
6108
  }
@@ -6111,23 +6110,23 @@ function gn(t) {
6111
6110
  const e = t.__adminToken;
6112
6111
  return t.appId + "_" + (t.websocketURI || "default_ws_uri") + "_" + (t.apiURI || "default_api_uri") + "_" + (e || "client_only") + "_" + t.useDateObjects;
6113
6112
  }
6114
- const wn = sc(), Yr = ic();
6115
- class oc {
6113
+ const wn = ic(), Yr = rc();
6114
+ class sc {
6116
6115
  constructor(e) {
6117
6116
  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);
6118
6117
  }
6119
6118
  }
6120
- class uc {
6119
+ class oc {
6121
6120
  constructor(e) {
6122
6121
  this.db = e, this.uploadFile = (n, r, i = {}) => this.db.uploadFile(n, r, i), this.delete = (n) => this.db.deleteFile(n), this.upload = (n, r) => this.db.upload(n, r), this.put = this.upload, this.getDownloadUrl = (n) => this.db.getDownloadUrl(n);
6123
6122
  }
6124
6123
  }
6125
- function ac(t) {
6124
+ function uc(t) {
6126
6125
  return JSON.parse(JSON.stringify(t));
6127
6126
  }
6128
- class cc {
6127
+ class ac {
6129
6128
  constructor(e) {
6130
- this.tx = Kn(), this._reactor = e, this.auth = new oc(this._reactor), this.storage = new uc(this._reactor);
6129
+ this.tx = Kn(), this._reactor = e, this.auth = new sc(this._reactor), this.storage = new oc(this._reactor);
6131
6130
  }
6132
6131
  /**
6133
6132
  * Use this to write data! You can create, update, delete, and link objects
@@ -6310,22 +6309,22 @@ function Jr(t) {
6310
6309
  const n = B(t);
6311
6310
  return Yr.set(t, n), n;
6312
6311
  }
6313
- function dc(t, e) {
6312
+ function cc(t, e) {
6314
6313
  return Jr(t._reactor.config.schema) !== Jr(e);
6315
6314
  }
6316
- function fc(t, e, n, r, i) {
6315
+ function dc(t, e, n, r, i) {
6317
6316
  var s;
6318
6317
  const o = Object.assign(Object.assign({}, t), { useDateObjects: (s = t.useDateObjects) !== null && s !== void 0 ? s : !1 }), u = wn[gn(o)];
6319
6318
  if (u)
6320
- return dc(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6321
- const a = new Na(Object.assign(Object.assign(Object.assign({}, rc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new cc(a);
6322
- return wn[gn(o)] = c, lc(o.appId, o.devtool), c;
6319
+ return cc(u, o.schema) && u._reactor.updateSchema(o.schema), u;
6320
+ const a = new Fa(Object.assign(Object.assign(Object.assign({}, nc), o), { cardinalityInference: !!o.schema }), e || Ui, n || Li, Object.assign(Object.assign({}, r || {}), { "@instantdb/core": Wn }), i), c = new ac(a);
6321
+ return wn[gn(o)] = c, fc(o.appId, o.devtool), c;
6323
6322
  }
6324
- function lc(t, e) {
6323
+ function fc(t, e) {
6325
6324
  if (typeof window > "u" || typeof window.location > "u" || typeof document > "u" || typeof e == "boolean" && !e)
6326
6325
  return;
6327
6326
  const n = Object.assign({ position: "bottom-right", allowedHosts: ["localhost"] }, typeof e == "object" ? e : {});
6328
- n.allowedHosts.includes(window.location.hostname) && Ya(t, n);
6327
+ n.allowedHosts.includes(window.location.hostname) && Ha(t, n);
6329
6328
  }
6330
6329
  var Tn = { exports: {} }, Qe = {};
6331
6330
  /**
@@ -6338,7 +6337,7 @@ var Tn = { exports: {} }, Qe = {};
6338
6337
  * LICENSE file in the root directory of this source tree.
6339
6338
  */
6340
6339
  var Zr;
6341
- function hc() {
6340
+ function lc() {
6342
6341
  if (Zr) return Qe;
6343
6342
  Zr = 1;
6344
6343
  var t = oi, e = Symbol.for("react.element"), n = Symbol.for("react.fragment"), r = Object.prototype.hasOwnProperty, i = t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, s = { key: !0, ref: !0, __self: !0, __source: !0 };
@@ -6352,7 +6351,7 @@ function hc() {
6352
6351
  return Qe.Fragment = n, Qe.jsx = o, Qe.jsxs = o, Qe;
6353
6352
  }
6354
6353
  var He = {}, Xr;
6355
- function pc() {
6354
+ function hc() {
6356
6355
  if (Xr) return He;
6357
6356
  Xr = 1;
6358
6357
  var t = {};
@@ -6953,10 +6952,10 @@ React keys must be passed directly to JSX without using spread:
6953
6952
  He.Fragment = i, He.jsx = Ts, He.jsxs = ms;
6954
6953
  }(), He;
6955
6954
  }
6956
- var yc = {};
6957
- yc.NODE_ENV === "production" ? Tn.exports = hc() : Tn.exports = pc();
6955
+ var pc = {};
6956
+ pc.NODE_ENV === "production" ? Tn.exports = lc() : Tn.exports = hc();
6958
6957
  var V = Tn.exports;
6959
- const bc = {
6958
+ const yc = {
6960
6959
  isLoading: !0,
6961
6960
  data: void 0,
6962
6961
  pageInfo: void 0,
@@ -6965,9 +6964,9 @@ const bc = {
6965
6964
  function ei(t) {
6966
6965
  return Object.assign({ isLoading: !t, data: void 0, pageInfo: void 0, error: void 0 }, t || {});
6967
6966
  }
6968
- function _c(t, e, n) {
6967
+ function bc(t, e, n) {
6969
6968
  e && n && "ruleParams" in n && (e = Object.assign({ $$ruleParams: n.ruleParams }, e));
6970
- const r = e ? ac(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6969
+ const r = e ? uc(e) : null, i = B(r), s = ot(ei(t._reactor.getPreviousResult(r))), o = we(
6971
6970
  (a) => (s.current = ei(t._reactor.getPreviousResult(r)), r ? t.subscribeQuery(r, (d) => {
6972
6971
  s.current = Object.assign({
6973
6972
  isLoading: !d,
@@ -6983,9 +6982,9 @@ function _c(t, e, n) {
6983
6982
  // Build a new subscribe function if the query changes
6984
6983
  [i]
6985
6984
  );
6986
- return { state: en(o, () => s.current, () => bc), query: r };
6985
+ return { state: en(o, () => s.current, () => yc), query: r };
6987
6986
  }
6988
- function gc() {
6987
+ function _c() {
6989
6988
  const t = ot(null);
6990
6989
  ke(() => {
6991
6990
  n();
@@ -6998,14 +6997,14 @@ function gc() {
6998
6997
  }
6999
6998
  return { set: e, clear: n };
7000
6999
  }
7001
- const wc = 1e3;
7002
- function Tc(t, e, n) {
7000
+ const gc = 1e3;
7001
+ function wc(t, e, n) {
7003
7002
  const r = ot(n);
7004
7003
  r.current = n, ke(() => t.core._reactor.subscribeTopic(t.id, e, (s, o) => {
7005
7004
  r.current(s, o);
7006
7005
  }), [t.id, e]);
7007
7006
  }
7008
- function mc(t, e) {
7007
+ function Tc(t, e) {
7009
7008
  return ke(() => t.core._reactor.joinRoom(t.id), [t.id]), we((r) => {
7010
7009
  t.core._reactor.publishTopic({
7011
7010
  roomType: t.type,
@@ -7015,7 +7014,7 @@ function mc(t, e) {
7015
7014
  });
7016
7015
  }, [t.id, e]);
7017
7016
  }
7018
- function vc(t, e = {}) {
7017
+ function mc(t, e = {}) {
7019
7018
  var n, r;
7020
7019
  const [i, s] = ui(() => {
7021
7020
  var a;
@@ -7032,11 +7031,11 @@ function vc(t, e = {}) {
7032
7031
  }, [t.type, t.id]);
7033
7032
  return tn(() => Object.assign(Object.assign({}, i), { publishPresence: o }), [i, o]);
7034
7033
  }
7035
- function Sc(t, e, n) {
7034
+ function vc(t, e, n) {
7036
7035
  ke(() => t.core._reactor.joinRoom(t.id, e), [t.id]), ke(() => t.core._reactor.publishPresence(t.type, t.id, e), [t.type, t.id, n ?? JSON.stringify(e)]);
7037
7036
  }
7038
- function Oc(t, e, n = {}) {
7039
- const r = gc(), i = Se.usePresence(t, {
7037
+ function Sc(t, e, n = {}) {
7038
+ const r = _c(), i = Se.usePresence(t, {
7040
7039
  keys: [e]
7041
7040
  }), s = tn(() => {
7042
7041
  var d;
@@ -7046,7 +7045,7 @@ function Oc(t, e, n = {}) {
7046
7045
  var f;
7047
7046
  t.core._reactor.publishPresence(t.type, t.id, {
7048
7047
  [e]: d
7049
- }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : wc, () => {
7048
+ }), d && ((n == null ? void 0 : n.timeout) === null || (n == null ? void 0 : n.timeout) === 0 || r.set((f = n == null ? void 0 : n.timeout) !== null && f !== void 0 ? f : gc, () => {
7050
7049
  t.core._reactor.publishPresence(t.type, t.id, {
7051
7050
  [e]: null
7052
7051
  });
@@ -7064,20 +7063,20 @@ function Oc(t, e, n = {}) {
7064
7063
  };
7065
7064
  }
7066
7065
  const Se = {
7067
- useTopicEffect: Tc,
7068
- usePublishTopic: mc,
7069
- usePresence: vc,
7070
- useSyncPresence: Sc,
7071
- useTypingIndicator: Oc
7066
+ useTopicEffect: wc,
7067
+ usePublishTopic: Tc,
7068
+ usePresence: mc,
7069
+ useSyncPresence: vc,
7070
+ useTypingIndicator: Sc
7072
7071
  };
7073
- class Ec {
7072
+ class Oc {
7074
7073
  constructor(e, n, r) {
7075
7074
  this.useTopicEffect = (i, s) => {
7076
7075
  Se.useTopicEffect(this, i, s);
7077
7076
  }, this.usePublishTopic = (i) => Se.usePublishTopic(this, i), this.usePresence = (i = {}) => Se.usePresence(this, i), this.useSyncPresence = (i, s) => Se.useSyncPresence(this, i, s), this.useTypingIndicator = (i, s = {}) => Se.useTypingIndicator(this, i, s), this.core = e, this._core = this.core, this.type = n, this.id = r;
7078
7077
  }
7079
7078
  }
7080
- var Ac = function(t, e, n, r) {
7079
+ var Ec = function(t, e, n, r) {
7081
7080
  function i(s) {
7082
7081
  return s instanceof n ? s : new n(function(o) {
7083
7082
  o(s);
@@ -7104,26 +7103,26 @@ var Ac = function(t, e, n, r) {
7104
7103
  c((r = r.apply(t, e || [])).next());
7105
7104
  });
7106
7105
  };
7107
- const kc = {
7106
+ const Ac = {
7108
7107
  isLoading: !0,
7109
7108
  user: void 0,
7110
7109
  error: void 0
7111
7110
  };
7112
- class jc {
7111
+ class kc {
7113
7112
  constructor(e, n) {
7114
7113
  this.tx = Kn(), this.getLocalId = (r) => this.core.getLocalId(r), this.useLocalId = (r) => {
7115
7114
  const [i, s] = ui(null);
7116
7115
  return ke(() => {
7117
- Ac(this, void 0, void 0, function* () {
7116
+ Ec(this, void 0, void 0, function* () {
7118
7117
  const u = yield this.getLocalId(r);
7119
7118
  s(u);
7120
7119
  });
7121
7120
  }, [r]), i;
7122
- }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => _c(this.core, r, i).state, this.useAuth = () => {
7121
+ }, this.rooms = Se, this.transact = (r) => this.core.transact(r), this.useQuery = (r, i) => bc(this.core, r, i).state, this.useAuth = () => {
7123
7122
  const r = ot(this.core._reactor._currentUserCached), i = we((o) => this.core.subscribeAuth((a) => {
7124
7123
  r.current = Object.assign({ isLoading: !1 }, a), o();
7125
7124
  }), []);
7126
- return en(i, () => r.current, () => kc);
7125
+ return en(i, () => r.current, () => Ac);
7127
7126
  }, this.useUser = () => {
7128
7127
  const { user: r } = this.useAuth();
7129
7128
  if (!r)
@@ -7145,7 +7144,7 @@ class jc {
7145
7144
  }, this.SignedOut = ({ children: r }) => {
7146
7145
  const i = this.useAuth();
7147
7146
  return i.isLoading || i.error || i.user ? null : V.jsx(V.Fragment, { children: r });
7148
- }, this.core = fc(
7147
+ }, this.core = dc(
7149
7148
  e,
7150
7149
  // @ts-expect-error because TS can't resolve subclass statics
7151
7150
  this.constructor.Storage,
@@ -7169,7 +7168,7 @@ class jc {
7169
7168
  * const { peers } = db.rooms.usePresence(room);
7170
7169
  */
7171
7170
  room(e = "_defaultRoomType", n = "_defaultRoomId") {
7172
- return new Ec(this.core, e, n);
7171
+ return new Oc(this.core, e, n);
7173
7172
  }
7174
7173
  /**
7175
7174
  * One time query for the logged in state. This is useful
@@ -7192,7 +7191,7 @@ class ti extends Error {
7192
7191
  }
7193
7192
  function Xt(t) {
7194
7193
  }
7195
- function Cc(t) {
7194
+ function jc(t) {
7196
7195
  if (typeof t == "function")
7197
7196
  throw new TypeError(
7198
7197
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
@@ -7200,7 +7199,7 @@ function Cc(t) {
7200
7199
  const { onEvent: e = Xt, onError: n = Xt, onRetry: r = Xt, onComment: i } = t;
7201
7200
  let s = "", o = !0, u, a = "", c = "";
7202
7201
  function d(b) {
7203
- const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Ic(`${s}${_}`);
7202
+ const _ = o ? b.replace(/^\xEF\xBB\xBF/, "") : b, [T, g] = Cc(`${s}${_}`);
7204
7203
  for (const m of T)
7205
7204
  f(m);
7206
7205
  s = g, o = !1;
@@ -7268,7 +7267,7 @@ function Cc(t) {
7268
7267
  }
7269
7268
  return { feed: d, reset: y };
7270
7269
  }
7271
- function Ic(t) {
7270
+ function Cc(t) {
7272
7271
  const e = [];
7273
7272
  let n = "", r = 0;
7274
7273
  for (; r < t.length; ) {
@@ -7328,7 +7327,7 @@ class ni extends Event {
7328
7327
  return e(ri(this), n);
7329
7328
  }
7330
7329
  }
7331
- function Pc(t) {
7330
+ function Ic(t) {
7332
7331
  const e = globalThis.DOMException;
7333
7332
  return typeof e == "function" ? new e(t, "SyntaxError") : new SyntaxError(t);
7334
7333
  }
@@ -7400,13 +7399,13 @@ class kt extends EventTarget {
7400
7399
  if (e instanceof URL)
7401
7400
  x(this, Oe, e);
7402
7401
  else if (typeof e == "string")
7403
- x(this, Oe, new URL(e, Mc()));
7402
+ x(this, Oe, new URL(e, Pc()));
7404
7403
  else
7405
7404
  throw new Error("Invalid URL");
7406
7405
  } catch {
7407
- throw Pc("An invalid or illegal string was specified");
7406
+ throw Ic("An invalid or illegal string was specified");
7408
7407
  }
7409
- x(this, $e, Cc({
7408
+ x(this, $e, jc({
7410
7409
  onEvent: A(this, En),
7411
7410
  onRetry: A(this, An)
7412
7411
  })), x(this, J, this.CONNECTING), x(this, it, 3e3), x(this, Rt, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), x(this, At, (i = n == null ? void 0 : n.withCredentials) != null ? i : !1), pe(this, se, vn).call(this);
@@ -7549,15 +7548,15 @@ kt.OPEN = 1, /**
7549
7548
  * @public
7550
7549
  */
7551
7550
  kt.CLOSED = 2;
7552
- function Mc() {
7551
+ function Pc() {
7553
7552
  const t = "document" in globalThis ? globalThis.document : void 0;
7554
7553
  return t && typeof t == "object" && "baseURI" in t && typeof t.baseURI == "string" ? t.baseURI : void 0;
7555
7554
  }
7556
- const Vn = class Vn extends jc {
7555
+ const Vn = class Vn extends kc {
7557
7556
  };
7558
7557
  Vn.EventSourceImpl = kt;
7559
7558
  let Cn = Vn;
7560
- function Rc(t) {
7559
+ function Mc(t) {
7561
7560
  const e = {
7562
7561
  ...t,
7563
7562
  useDateObjects: t.useDateObjects ?? !1
@@ -7566,8 +7565,8 @@ function Rc(t) {
7566
7565
  "@instantdb/react": Wn
7567
7566
  });
7568
7567
  }
7569
- const Kc = Rc;
7570
- function qc({
7568
+ const Nc = Mc;
7569
+ function Kc({
7571
7570
  as: t = "div",
7572
7571
  spaceId: e,
7573
7572
  room: n,
@@ -7639,8 +7638,8 @@ function qc({
7639
7638
  {
7640
7639
  style: {
7641
7640
  ...si,
7642
- ...$c,
7643
- zIndex: c !== void 0 ? c : Dc
7641
+ ...xc,
7642
+ zIndex: c !== void 0 ? c : $c
7644
7643
  },
7645
7644
  children: Object.entries(f.peers).map(([g, m]) => {
7646
7645
  const O = m[d];
@@ -7656,7 +7655,7 @@ function qc({
7656
7655
  children: u ? u({
7657
7656
  color: O.color,
7658
7657
  presence: l == null ? void 0 : l.peers[g]
7659
- }) : /* @__PURE__ */ V.jsx(xc, { ...O })
7658
+ }) : /* @__PURE__ */ V.jsx(Rc, { ...O })
7660
7659
  },
7661
7660
  g
7662
7661
  ) : null;
@@ -7667,7 +7666,7 @@ function qc({
7667
7666
  ]
7668
7667
  );
7669
7668
  }
7670
- function xc({ color: t }) {
7669
+ function Rc({ color: t }) {
7671
7670
  const n = t || "black";
7672
7671
  return /* @__PURE__ */ V.jsxs(
7673
7672
  "svg",
@@ -7720,21 +7719,21 @@ const si = {
7720
7719
  left: 0,
7721
7720
  bottom: 0,
7722
7721
  right: 0
7723
- }, $c = {
7722
+ }, xc = {
7724
7723
  overflow: "hidden",
7725
7724
  pointerEvents: "none",
7726
7725
  userSelect: "none"
7727
- }, Dc = 99999;
7726
+ }, $c = 99999;
7728
7727
  export {
7729
- qc as Cursors,
7728
+ Kc as Cursors,
7730
7729
  Dt as InstantAPIError,
7731
- jc as InstantReactAbstractDatabase,
7730
+ kc as InstantReactAbstractDatabase,
7732
7731
  Cn as InstantReactWebDatabase,
7733
7732
  ve as SyncTableCallbackEventType,
7734
- Nc as i,
7733
+ Fc as i,
7735
7734
  W as id,
7736
- Rc as init,
7737
- Kc as init_experimental,
7738
- Lc as lookup,
7739
- Fc as tx
7735
+ Mc as init,
7736
+ Nc as init_experimental,
7737
+ Uc as lookup,
7738
+ Lc as tx
7740
7739
  };