@instantdb/resumable-stream 0.22.149 → 0.22.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,50 +1,50 @@
1
- var En = Object.defineProperty;
1
+ var _n = Object.defineProperty;
2
2
  var Pt = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
- var _n = (e, t, n) => t in e ? En(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
- var d = (e, t, n) => _n(e, typeof t != "symbol" ? t + "" : t, n), st = (e, t, n) => t.has(e) || Pt("Cannot " + n);
7
- var b = (e, t, n) => (st(e, t, "read from private field"), n ? n.call(e) : t.get(e)), G = (e, t, n) => t.has(e) ? Pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), oe = (e, t, n, i) => (st(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), H = (e, t, n) => (st(e, t, "access private method"), n);
8
- const Cn = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
9
- function Te(e) {
10
- return typeof e == "string" && Cn.test(e);
11
- }
12
- const M = [];
5
+ var Cn = (e, t, n) => t in e ? _n(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var d = (e, t, n) => Cn(e, typeof t != "symbol" ? t + "" : t, n), st = (e, t, n) => t.has(e) || Pt("Cannot " + n);
7
+ var g = (e, t, n) => (st(e, t, "read from private field"), n ? n.call(e) : t.get(e)), G = (e, t, n) => t.has(e) ? Pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), ae = (e, t, n, i) => (st(e, t, "write to private field"), i ? i.call(e, n) : t.set(e, n), n), H = (e, t, n) => (st(e, t, "access private method"), n);
8
+ const xn = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
9
+ function Re(e) {
10
+ return typeof e == "string" && xn.test(e);
11
+ }
12
+ const j = [];
13
13
  for (let e = 0; e < 256; ++e)
14
- M.push((e + 256).toString(16).slice(1));
15
- function xn(e, t = 0) {
16
- return (M[e[t + 0]] + M[e[t + 1]] + M[e[t + 2]] + M[e[t + 3]] + "-" + M[e[t + 4]] + M[e[t + 5]] + "-" + M[e[t + 6]] + M[e[t + 7]] + "-" + M[e[t + 8]] + M[e[t + 9]] + "-" + M[e[t + 10]] + M[e[t + 11]] + M[e[t + 12]] + M[e[t + 13]] + M[e[t + 14]] + M[e[t + 15]]).toLowerCase();
14
+ j.push((e + 256).toString(16).slice(1));
15
+ function Tn(e, t = 0) {
16
+ return (j[e[t + 0]] + j[e[t + 1]] + j[e[t + 2]] + j[e[t + 3]] + "-" + j[e[t + 4]] + j[e[t + 5]] + "-" + j[e[t + 6]] + j[e[t + 7]] + "-" + j[e[t + 8]] + j[e[t + 9]] + "-" + j[e[t + 10]] + j[e[t + 11]] + j[e[t + 12]] + j[e[t + 13]] + j[e[t + 14]] + j[e[t + 15]]).toLowerCase();
17
17
  }
18
18
  let rt;
19
- const Tn = new Uint8Array(16);
20
- function Rn() {
19
+ const Rn = new Uint8Array(16);
20
+ function An() {
21
21
  if (!rt) {
22
22
  if (typeof crypto > "u" || !crypto.getRandomValues)
23
23
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
24
24
  rt = crypto.getRandomValues.bind(crypto);
25
25
  }
26
- return rt(Tn);
26
+ return rt(Rn);
27
27
  }
28
- const An = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), jt = { randomUUID: An };
29
- function Pn(e, t, n) {
28
+ const Pn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), jt = { randomUUID: Pn };
29
+ function jn(e, t, n) {
30
30
  var s;
31
31
  if (jt.randomUUID && !e)
32
32
  return jt.randomUUID();
33
33
  e = e || {};
34
- const i = e.random ?? ((s = e.rng) == null ? void 0 : s.call(e)) ?? Rn();
34
+ const i = e.random ?? ((s = e.rng) == null ? void 0 : s.call(e)) ?? An();
35
35
  if (i.length < 16)
36
36
  throw new Error("Random bytes length must be >= 16");
37
- return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, xn(i);
37
+ return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, Tn(i);
38
38
  }
39
39
  const T = {
40
40
  Remove: "remove",
41
41
  Replace: "replace",
42
42
  Add: "add"
43
- }, Xt = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Je = Symbol.iterator, Z = {
43
+ }, Xt = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), Ve = Symbol.iterator, ee = {
44
44
  mutable: "mutable",
45
45
  immutable: "immutable"
46
46
  }, _t = {};
47
- function Ne(e, t) {
47
+ function De(e, t) {
48
48
  return e instanceof Map ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
49
49
  }
50
50
  function Mt(e, t) {
@@ -79,19 +79,19 @@ function Ct(e) {
79
79
  const n = k(e);
80
80
  return n ? (t = n.copy) !== null && t !== void 0 ? t : n.original : e;
81
81
  }
82
- function Ie(e, t) {
82
+ function ve(e, t) {
83
83
  if (!e || typeof e != "object")
84
84
  return !1;
85
85
  let n;
86
- return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!(t != null && t.mark) && ((n = t.mark(e, Z)) === Z.immutable || typeof n == "function");
86
+ return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!(t != null && t.mark) && ((n = t.mark(e, ee)) === ee.immutable || typeof n == "function");
87
87
  }
88
88
  function en(e, t = []) {
89
89
  if (Object.hasOwnProperty.call(e, "key")) {
90
- const n = e.parent.copy, i = k(he(n, e.key));
90
+ const n = e.parent.copy, i = k(pe(n, e.key));
91
91
  if (i !== null && (i == null ? void 0 : i.original) !== e.original)
92
92
  return null;
93
93
  const s = e.parent.type === 3, r = s ? Array.from(e.parent.setMap.keys()).indexOf(e.key) : e.key;
94
- if (!(s && n.size > r || Ne(n, r)))
94
+ if (!(s && n.size > r || De(n, r)))
95
95
  return null;
96
96
  t.push(r);
97
97
  }
@@ -99,43 +99,43 @@ function en(e, t = []) {
99
99
  return en(e.parent, t);
100
100
  t.reverse();
101
101
  try {
102
- jn(e.copy, t);
102
+ Mn(e.copy, t);
103
103
  } catch {
104
104
  return null;
105
105
  }
106
106
  return t;
107
107
  }
108
- function ze(e) {
108
+ function Fe(e) {
109
109
  return Array.isArray(e) ? 1 : e instanceof Map ? 2 : e instanceof Set ? 3 : 0;
110
110
  }
111
- function he(e, t) {
112
- return ze(e) === 2 ? e.get(t) : e[t];
111
+ function pe(e, t) {
112
+ return Fe(e) === 2 ? e.get(t) : e[t];
113
113
  }
114
114
  function xt(e, t, n) {
115
- ze(e) === 2 ? e.set(t, n) : e[t] = n;
115
+ Fe(e) === 2 ? e.set(t, n) : e[t] = n;
116
116
  }
117
117
  function ot(e, t) {
118
118
  const n = k(e);
119
119
  return (n ? Q(n) : e)[t];
120
120
  }
121
- function we(e, t) {
121
+ function Se(e, t) {
122
122
  return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
123
123
  }
124
- function be(e, t) {
124
+ function ge(e, t) {
125
125
  return t ? e : [""].concat(e).map((n) => {
126
126
  const i = `${n}`;
127
127
  return i.indexOf("/") === -1 && i.indexOf("~") === -1 ? i : i.replace(/~/g, "~0").replace(/\//g, "~1");
128
128
  }).join("/");
129
129
  }
130
- function jn(e, t) {
130
+ function Mn(e, t) {
131
131
  for (let n = 0; n < t.length - 1; n += 1) {
132
132
  const i = t[n];
133
- if (e = he(ze(e) === 3 ? Array.from(e) : e, i), typeof e != "object")
133
+ if (e = pe(Fe(e) === 3 ? Array.from(e) : e, i), typeof e != "object")
134
134
  throw new Error(`Cannot resolve patch at '${t.join("/")}'.`);
135
135
  }
136
136
  return e;
137
137
  }
138
- function Mn(e) {
138
+ function Un(e) {
139
139
  const t = Object.create(Object.getPrototypeOf(e));
140
140
  return Reflect.ownKeys(e).forEach((n) => {
141
141
  let i = Reflect.getOwnPropertyDescriptor(e, n);
@@ -151,8 +151,8 @@ function Mn(e) {
151
151
  }), Reflect.defineProperty(t, n, i);
152
152
  }), t;
153
153
  }
154
- const Un = Object.prototype.propertyIsEnumerable;
155
- function Dn(e, t) {
154
+ const Dn = Object.prototype.propertyIsEnumerable;
155
+ function Nn(e, t) {
156
156
  let n;
157
157
  if (Array.isArray(e))
158
158
  return Array.prototype.concat.call(e);
@@ -168,9 +168,9 @@ function Dn(e, t) {
168
168
  return new i(e);
169
169
  }
170
170
  return new Map(e);
171
- } else if (t != null && t.mark && (n = t.mark(e, Z), n !== void 0) && n !== Z.mutable) {
172
- if (n === Z.immutable)
173
- return Mn(e);
171
+ } else if (t != null && t.mark && (n = t.mark(e, ee), n !== void 0) && n !== ee.mutable) {
172
+ if (n === ee.immutable)
173
+ return Un(e);
174
174
  if (typeof n == "function") {
175
175
  if (t.enablePatches || t.enableAutoFreeze)
176
176
  throw new Error("You can't use mark and patches or auto freeze together.");
@@ -182,23 +182,23 @@ function Dn(e, t) {
182
182
  return Object.keys(e).forEach((s) => {
183
183
  i[s] = e[s];
184
184
  }), Object.getOwnPropertySymbols(e).forEach((s) => {
185
- Un.call(e, s) && (i[s] = e[s]);
185
+ Dn.call(e, s) && (i[s] = e[s]);
186
186
  }), i;
187
187
  } else
188
188
  throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
189
189
  }
190
190
  function W(e) {
191
- e.copy || (e.copy = Dn(e.original, e.options));
191
+ e.copy || (e.copy = Nn(e.original, e.options));
192
192
  }
193
- function Me(e) {
194
- if (!Ie(e))
193
+ function je(e) {
194
+ if (!ve(e))
195
195
  return Ct(e);
196
196
  if (Array.isArray(e))
197
- return e.map(Me);
197
+ return e.map(je);
198
198
  if (e instanceof Map) {
199
199
  const n = Array.from(e.entries()).map(([i, s]) => [
200
200
  i,
201
- Me(s)
201
+ je(s)
202
202
  ]);
203
203
  if (!Zt(e)) {
204
204
  const i = Object.getPrototypeOf(e).constructor;
@@ -207,7 +207,7 @@ function Me(e) {
207
207
  return new Map(n);
208
208
  }
209
209
  if (e instanceof Set) {
210
- const n = Array.from(e).map(Me);
210
+ const n = Array.from(e).map(je);
211
211
  if (!Yt(e)) {
212
212
  const i = Object.getPrototypeOf(e).constructor;
213
213
  return new i(n);
@@ -216,18 +216,18 @@ function Me(e) {
216
216
  }
217
217
  const t = Object.create(Object.getPrototypeOf(e));
218
218
  for (const n in e)
219
- t[n] = Me(e[n]);
219
+ t[n] = je(e[n]);
220
220
  return t;
221
221
  }
222
- function Qe(e) {
223
- return lt(e) ? Me(e) : e;
222
+ function Je(e) {
223
+ return lt(e) ? je(e) : e;
224
224
  }
225
- function te(e) {
225
+ function se(e) {
226
226
  var t;
227
- e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && te(e.parent));
227
+ e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && se(e.parent));
228
228
  }
229
- function Nn(e, t) {
230
- const n = ze(e);
229
+ function Ln(e, t) {
230
+ const n = Fe(e);
231
231
  if (n === 0)
232
232
  Reflect.ownKeys(e).forEach((i) => {
233
233
  t(i, e[i], e);
@@ -240,10 +240,10 @@ function Nn(e, t) {
240
240
  e.forEach((i, s) => t(s, i, e));
241
241
  }
242
242
  function tn(e, t, n) {
243
- if (lt(e) || !Ie(e, n) || t.has(e) || Object.isFrozen(e))
243
+ if (lt(e) || !ve(e, n) || t.has(e) || Object.isFrozen(e))
244
244
  return;
245
245
  const i = e instanceof Set, s = i ? /* @__PURE__ */ new Map() : void 0;
246
- if (t.add(e), Nn(e, (r, o) => {
246
+ if (t.add(e), Ln(e, (r, o) => {
247
247
  var a;
248
248
  if (lt(o)) {
249
249
  const u = k(o);
@@ -259,9 +259,9 @@ function tn(e, t, n) {
259
259
  });
260
260
  }
261
261
  }
262
- function Ln(e, t) {
262
+ function Wn(e, t) {
263
263
  const n = e.type === 3 ? e.setMap : e.copy;
264
- e.finalities.revoke.length > 1 && e.assignedMap.get(t) && n && tn(he(n, t), e.finalities.handledSet, e.options);
264
+ e.finalities.revoke.length > 1 && e.assignedMap.get(t) && n && tn(pe(n, t), e.finalities.handledSet, e.options);
265
265
  }
266
266
  function dt(e) {
267
267
  e.type === 3 && e.copy && (e.copy.clear(), e.setMap.forEach((t) => {
@@ -282,46 +282,46 @@ function Tt(e, t, n, i) {
282
282
  s && (s.callbacks || (s.callbacks = []), s.callbacks.push((r, o) => {
283
283
  var a;
284
284
  const u = e.type === 3 ? e.setMap : e.copy;
285
- if (we(he(u, t), n)) {
285
+ if (Se(pe(u, t), n)) {
286
286
  let c = s.original;
287
287
  s.copy && (c = s.copy), dt(e), ht(e, i, r, o), e.options.enableAutoFreeze && (e.options.updatedValues = (a = e.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), e.options.updatedValues.set(c, s.original)), xt(u, t, c);
288
288
  }
289
- }), e.options.enableAutoFreeze && s.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), Ie(n, e.options) && e.finalities.draft.push(() => {
289
+ }), e.options.enableAutoFreeze && s.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), ve(n, e.options) && e.finalities.draft.push(() => {
290
290
  const r = e.type === 3 ? e.setMap : e.copy;
291
- we(he(r, t), n) && Ln(e, t);
291
+ Se(pe(r, t), n) && Wn(e, t);
292
292
  });
293
293
  }
294
- function Wn(e, t, n, i, s) {
294
+ function Fn(e, t, n, i, s) {
295
295
  let { original: r, assignedMap: o, options: a } = e, u = e.copy;
296
296
  u.length < r.length && ([r, u] = [u, r], [n, i] = [i, n]);
297
297
  for (let c = 0; c < r.length; c += 1)
298
298
  if (o.get(c.toString()) && u[c] !== r[c]) {
299
- const l = t.concat([c]), f = be(l, s);
299
+ const l = t.concat([c]), f = ge(l, s);
300
300
  n.push({
301
301
  op: T.Replace,
302
302
  path: f,
303
303
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
304
- value: Qe(u[c])
304
+ value: Je(u[c])
305
305
  }), i.push({
306
306
  op: T.Replace,
307
307
  path: f,
308
308
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
309
- value: Qe(r[c])
309
+ value: Je(r[c])
310
310
  });
311
311
  }
312
312
  for (let c = r.length; c < u.length; c += 1) {
313
- const l = t.concat([c]), f = be(l, s);
313
+ const l = t.concat([c]), f = ge(l, s);
314
314
  n.push({
315
315
  op: T.Add,
316
316
  path: f,
317
317
  // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
318
- value: Qe(u[c])
318
+ value: Je(u[c])
319
319
  });
320
320
  }
321
321
  if (r.length < u.length) {
322
322
  const { arrayLengthAssignment: c = !0 } = a.enablePatches;
323
323
  if (c) {
324
- const l = t.concat(["length"]), f = be(l, s);
324
+ const l = t.concat(["length"]), f = ge(l, s);
325
325
  i.push({
326
326
  op: T.Replace,
327
327
  path: f,
@@ -329,7 +329,7 @@ function Wn(e, t, n, i, s) {
329
329
  });
330
330
  } else
331
331
  for (let l = u.length; r.length < l; l -= 1) {
332
- const f = t.concat([l - 1]), m = be(f, s);
332
+ const f = t.concat([l - 1]), m = ge(f, s);
333
333
  i.push({
334
334
  op: T.Remove,
335
335
  path: m
@@ -337,20 +337,20 @@ function Wn(e, t, n, i, s) {
337
337
  }
338
338
  }
339
339
  }
340
- function Fn({ original: e, copy: t, assignedMap: n }, i, s, r, o) {
340
+ function zn({ original: e, copy: t, assignedMap: n }, i, s, r, o) {
341
341
  n.forEach((a, u) => {
342
- const c = he(e, u), l = Qe(he(t, u)), f = a ? Ne(e, u) ? T.Replace : T.Add : T.Remove;
343
- if (we(c, l) && f === T.Replace)
342
+ const c = pe(e, u), l = Je(pe(t, u)), f = a ? De(e, u) ? T.Replace : T.Add : T.Remove;
343
+ if (Se(c, l) && f === T.Replace)
344
344
  return;
345
- const m = i.concat(u), p = be(m, o);
346
- s.push(f === T.Remove ? { op: f, path: p } : { op: f, path: p, value: l }), r.push(f === T.Add ? { op: T.Remove, path: p } : f === T.Remove ? { op: T.Add, path: p, value: c } : { op: T.Replace, path: p, value: c });
345
+ const m = i.concat(u), y = ge(m, o);
346
+ s.push(f === T.Remove ? { op: f, path: y } : { op: f, path: y, value: l }), r.push(f === T.Add ? { op: T.Remove, path: y } : f === T.Remove ? { op: T.Add, path: y, value: c } : { op: T.Replace, path: y, value: c });
347
347
  });
348
348
  }
349
- function zn({ original: e, copy: t }, n, i, s, r) {
349
+ function Vn({ original: e, copy: t }, n, i, s, r) {
350
350
  let o = 0;
351
351
  e.forEach((a) => {
352
352
  if (!t.has(a)) {
353
- const u = n.concat([o]), c = be(u, r);
353
+ const u = n.concat([o]), c = ge(u, r);
354
354
  i.push({
355
355
  op: T.Remove,
356
356
  path: c,
@@ -364,7 +364,7 @@ function zn({ original: e, copy: t }, n, i, s, r) {
364
364
  o += 1;
365
365
  }), o = 0, t.forEach((a) => {
366
366
  if (!e.has(a)) {
367
- const u = n.concat([o]), c = be(u, r);
367
+ const u = n.concat([o]), c = ge(u, r);
368
368
  i.push({
369
369
  op: T.Add,
370
370
  path: c,
@@ -378,20 +378,20 @@ function zn({ original: e, copy: t }, n, i, s, r) {
378
378
  o += 1;
379
379
  });
380
380
  }
381
- function Fe(e, t, n, i) {
381
+ function We(e, t, n, i) {
382
382
  const { pathAsArray: s = !0 } = e.options.enablePatches;
383
383
  switch (e.type) {
384
384
  case 0:
385
385
  case 2:
386
- return Fn(e, t, n, i, s);
386
+ return zn(e, t, n, i, s);
387
387
  case 1:
388
- return Wn(e, t, n, i, s);
388
+ return Fn(e, t, n, i, s);
389
389
  case 3:
390
- return zn(e, t, n, i, s);
390
+ return Vn(e, t, n, i, s);
391
391
  }
392
392
  }
393
- const qe = (e, t, n = !1) => {
394
- if (typeof e == "object" && e !== null && (!Ie(e, t) || n))
393
+ const Be = (e, t, n = !1) => {
394
+ if (typeof e == "object" && e !== null && (!ve(e, t) || n))
395
395
  throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
396
396
  }, pt = {
397
397
  get size() {
@@ -402,18 +402,18 @@ const qe = (e, t, n = !1) => {
402
402
  },
403
403
  set(e, t) {
404
404
  const n = k(this), i = Q(n);
405
- return (!i.has(e) || !we(i.get(e), t)) && (W(n), te(n), n.assignedMap.set(e, !0), n.copy.set(e, t), Tt(n, e, t, Fe)), this;
405
+ return (!i.has(e) || !Se(i.get(e), t)) && (W(n), se(n), n.assignedMap.set(e, !0), n.copy.set(e, t), Tt(n, e, t, We)), this;
406
406
  },
407
407
  delete(e) {
408
408
  if (!this.has(e))
409
409
  return !1;
410
410
  const t = k(this);
411
- return W(t), te(t), t.original.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.copy.delete(e), !0;
411
+ return W(t), se(t), t.original.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.copy.delete(e), !0;
412
412
  },
413
413
  clear() {
414
414
  const e = k(this);
415
415
  if (this.size) {
416
- W(e), te(e), e.assignedMap = /* @__PURE__ */ new Map();
416
+ W(e), se(e), e.assignedMap = /* @__PURE__ */ new Map();
417
417
  for (const [t] of e.original)
418
418
  e.assignedMap.set(t, !1);
419
419
  e.copy.clear();
@@ -427,8 +427,8 @@ const qe = (e, t, n = !1) => {
427
427
  },
428
428
  get(e) {
429
429
  var t, n;
430
- const i = k(this), s = Q(i).get(e), r = ((n = (t = i.options).mark) === null || n === void 0 ? void 0 : n.call(t, s, Z)) === Z.mutable;
431
- if (i.options.strict && qe(s, i.options, r), r || i.finalized || !Ie(s, i.options) || s !== i.original.get(e))
430
+ const i = k(this), s = Q(i).get(e), r = ((n = (t = i.options).mark) === null || n === void 0 ? void 0 : n.call(t, s, ee)) === ee.mutable;
431
+ if (i.options.strict && Be(s, i.options, r), r || i.finalized || !ve(s, i.options) || s !== i.original.get(e))
432
432
  return s;
433
433
  const o = _t.createDraft({
434
434
  original: s,
@@ -445,7 +445,7 @@ const qe = (e, t, n = !1) => {
445
445
  values() {
446
446
  const e = this.keys();
447
447
  return {
448
- [Je]: () => this.values(),
448
+ [Ve]: () => this.values(),
449
449
  next: () => {
450
450
  const t = e.next();
451
451
  return t.done ? t : {
@@ -458,7 +458,7 @@ const qe = (e, t, n = !1) => {
458
458
  entries() {
459
459
  const e = this.keys();
460
460
  return {
461
- [Je]: () => this.entries(),
461
+ [Ve]: () => this.entries(),
462
462
  next: () => {
463
463
  const t = e.next();
464
464
  if (t.done)
@@ -471,18 +471,18 @@ const qe = (e, t, n = !1) => {
471
471
  }
472
472
  };
473
473
  },
474
- [Je]() {
474
+ [Ve]() {
475
475
  return this.entries();
476
476
  }
477
- }, Vn = Reflect.ownKeys(pt), Ut = (e, t, { isValuesIterator: n }) => () => {
477
+ }, Jn = Reflect.ownKeys(pt), Ut = (e, t, { isValuesIterator: n }) => () => {
478
478
  var i, s;
479
479
  const r = t.next();
480
480
  if (r.done)
481
481
  return r;
482
482
  const o = r.value;
483
483
  let a = e.setMap.get(o);
484
- const u = k(a), c = ((s = (i = e.options).mark) === null || s === void 0 ? void 0 : s.call(i, a, Z)) === Z.mutable;
485
- if (e.options.strict && qe(o, e.options, c), !c && !u && Ie(o, e.options) && !e.finalized && e.original.has(o)) {
484
+ const u = k(a), c = ((s = (i = e.options).mark) === null || s === void 0 ? void 0 : s.call(i, a, ee)) === ee.mutable;
485
+ if (e.options.strict && Be(o, e.options, c), !c && !u && ve(o, e.options) && !e.finalized && e.original.has(o)) {
486
486
  const l = _t.createDraft({
487
487
  original: o,
488
488
  parentDraft: e,
@@ -496,7 +496,7 @@ const qe = (e, t, n = !1) => {
496
496
  done: !1,
497
497
  value: n ? a : [a, a]
498
498
  };
499
- }, Ke = {
499
+ }, qe = {
500
500
  get size() {
501
501
  return k(this).setMap.size;
502
502
  },
@@ -510,13 +510,13 @@ const qe = (e, t, n = !1) => {
510
510
  },
511
511
  add(e) {
512
512
  const t = k(this);
513
- return this.has(e) || (W(t), te(t), t.assignedMap.set(e, !0), t.setMap.set(e, e), Tt(t, e, e, Fe)), this;
513
+ return this.has(e) || (W(t), se(t), t.assignedMap.set(e, !0), t.setMap.set(e, e), Tt(t, e, e, We)), this;
514
514
  },
515
515
  delete(e) {
516
516
  if (!this.has(e))
517
517
  return !1;
518
518
  const t = k(this);
519
- W(t), te(t);
519
+ W(t), se(t);
520
520
  const n = k(e);
521
521
  return n && t.setMap.has(n.original) ? (t.assignedMap.set(n.original, !1), t.setMap.delete(n.original)) : (!n && t.setMap.has(e) ? t.assignedMap.set(e, !1) : t.assignedMap.delete(e), t.setMap.delete(e));
522
522
  },
@@ -524,7 +524,7 @@ const qe = (e, t, n = !1) => {
524
524
  if (!this.size)
525
525
  return;
526
526
  const e = k(this);
527
- W(e), te(e);
527
+ W(e), se(e);
528
528
  for (const t of e.original)
529
529
  e.assignedMap.set(t, !1);
530
530
  e.setMap.clear();
@@ -552,7 +552,7 @@ const qe = (e, t, n = !1) => {
552
552
  keys() {
553
553
  return this.values();
554
554
  },
555
- [Je]() {
555
+ [Ve]() {
556
556
  return this.values();
557
557
  },
558
558
  forEach(e, t) {
@@ -562,7 +562,7 @@ const qe = (e, t, n = !1) => {
562
562
  e.call(t, i.value, i.value, this), i = n.next();
563
563
  }
564
564
  };
565
- Set.prototype.difference && Object.assign(Ke, {
565
+ Set.prototype.difference && Object.assign(qe, {
566
566
  intersection(e) {
567
567
  return Set.prototype.intersection.call(new Set(this.values()), e);
568
568
  },
@@ -585,7 +585,7 @@ Set.prototype.difference && Object.assign(Ke, {
585
585
  return Set.prototype.isDisjointFrom.call(new Set(this.values()), e);
586
586
  }
587
587
  });
588
- const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
588
+ const Qn = Reflect.ownKeys(qe), nn = /* @__PURE__ */ new WeakSet(), sn = {
589
589
  get(e, t, n) {
590
590
  var i, s;
591
591
  const r = (i = e.copy) === null || i === void 0 ? void 0 : i[t];
@@ -596,25 +596,25 @@ const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
596
596
  let o;
597
597
  if (e.options.mark) {
598
598
  const c = t === "size" && (e.original instanceof Map || e.original instanceof Set) ? Reflect.get(e.original, t) : Reflect.get(e.original, t, n);
599
- if (o = e.options.mark(c, Z), o === Z.mutable)
600
- return e.options.strict && qe(c, e.options, !0), c;
599
+ if (o = e.options.mark(c, ee), o === ee.mutable)
600
+ return e.options.strict && Be(c, e.options, !0), c;
601
601
  }
602
602
  const a = Q(e);
603
- if (a instanceof Map && Vn.includes(t)) {
603
+ if (a instanceof Map && Jn.includes(t)) {
604
604
  if (t === "size")
605
605
  return Object.getOwnPropertyDescriptor(pt, "size").get.call(e.proxy);
606
606
  const c = pt[t];
607
607
  if (c)
608
608
  return c.bind(e.proxy);
609
609
  }
610
- if (a instanceof Set && Jn.includes(t)) {
610
+ if (a instanceof Set && Qn.includes(t)) {
611
611
  if (t === "size")
612
- return Object.getOwnPropertyDescriptor(Ke, "size").get.call(e.proxy);
613
- const c = Ke[t];
612
+ return Object.getOwnPropertyDescriptor(qe, "size").get.call(e.proxy);
613
+ const c = qe[t];
614
614
  if (c)
615
615
  return c.bind(e.proxy);
616
616
  }
617
- if (!Ne(a, t)) {
617
+ if (!De(a, t)) {
618
618
  const c = Mt(a, t);
619
619
  return c ? "value" in c ? c.value : (
620
620
  // !case: support for getter
@@ -622,7 +622,7 @@ const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
622
622
  ) : void 0;
623
623
  }
624
624
  const u = a[t];
625
- if (e.options.strict && qe(u, e.options), e.finalized || !Ie(u, e.options))
625
+ if (e.options.strict && Be(u, e.options), e.finalized || !ve(u, e.options))
626
626
  return u;
627
627
  if (u === ot(e.original, t)) {
628
628
  if (W(e), e.copy[t] = rn({
@@ -633,7 +633,7 @@ const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
633
633
  options: e.options
634
634
  }), typeof o == "function") {
635
635
  const c = k(e.copy[t]);
636
- return W(c), te(c), c.copy;
636
+ return W(c), se(c), c.copy;
637
637
  }
638
638
  return e.copy[t];
639
639
  }
@@ -650,7 +650,7 @@ const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
650
650
  if (r != null && r.set)
651
651
  return r.set.call(e.proxy, n), !0;
652
652
  const o = ot(Q(e), t), a = k(o);
653
- return a && we(a.original, n) ? (e.copy[t] = n, e.assignedMap = (i = e.assignedMap) !== null && i !== void 0 ? i : /* @__PURE__ */ new Map(), e.assignedMap.set(t, !1), !0) : (we(n, o) && (n !== void 0 || Ne(e.original, t)) || (W(e), te(e), Ne(e.original, t) && we(n, e.original[t]) ? e.assignedMap.delete(t) : e.assignedMap.set(t, !0), e.copy[t] = n, Tt(e, t, n, Fe)), !0);
653
+ return a && Se(a.original, n) ? (e.copy[t] = n, e.assignedMap = (i = e.assignedMap) !== null && i !== void 0 ? i : /* @__PURE__ */ new Map(), e.assignedMap.set(t, !1), !0) : (Se(n, o) && (n !== void 0 || De(e.original, t)) || (W(e), se(e), De(e.original, t) && Se(n, e.original[t]) ? e.assignedMap.delete(t) : e.assignedMap.set(t, !0), e.copy[t] = n, Tt(e, t, n, We)), !0);
654
654
  },
655
655
  has(e, t) {
656
656
  return t in Q(e);
@@ -678,11 +678,11 @@ const Jn = Reflect.ownKeys(Ke), nn = /* @__PURE__ */ new WeakSet(), sn = {
678
678
  },
679
679
  deleteProperty(e, t) {
680
680
  var n;
681
- return e.type === 1 ? sn.set.call(this, e, t, void 0, e.proxy) : (ot(e.original, t) !== void 0 || t in e.original ? (W(e), te(e), e.assignedMap.set(t, !1)) : (e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.assignedMap.delete(t)), e.copy && delete e.copy[t], !0);
681
+ return e.type === 1 ? sn.set.call(this, e, t, void 0, e.proxy) : (ot(e.original, t) !== void 0 || t in e.original ? (W(e), se(e), e.assignedMap.set(t, !1)) : (e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.assignedMap.delete(t)), e.copy && delete e.copy[t], !0);
682
682
  }
683
683
  };
684
684
  function rn(e) {
685
- const { original: t, parentDraft: n, key: i, finalities: s, options: r } = e, o = ze(t), a = {
685
+ const { original: t, parentDraft: n, key: i, finalities: s, options: r } = e, o = Fe(t), a = {
686
686
  type: o,
687
687
  finalized: !1,
688
688
  parent: n,
@@ -699,36 +699,36 @@ function rn(e) {
699
699
  if (s.revoke.push(c), nn.add(u), a.proxy = u, n) {
700
700
  const l = n;
701
701
  l.finalities.draft.push((f, m) => {
702
- var p, I;
703
- const g = k(u);
702
+ var y, I;
703
+ const w = k(u);
704
704
  let h = l.type === 3 ? l.setMap : l.copy;
705
- const $ = he(h, i), w = k($);
706
- if (w) {
707
- let O = w.original;
708
- w.operated && (O = Ct($)), dt(w), ht(w, Fe, f, m), l.options.enableAutoFreeze && (l.options.updatedValues = (p = l.options.updatedValues) !== null && p !== void 0 ? p : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set(O, w.original)), xt(h, i, O);
705
+ const O = pe(h, i), b = k(O);
706
+ if (b) {
707
+ let $ = b.original;
708
+ b.operated && ($ = Ct(O)), dt(b), ht(b, We, f, m), l.options.enableAutoFreeze && (l.options.updatedValues = (y = l.options.updatedValues) !== null && y !== void 0 ? y : /* @__PURE__ */ new WeakMap(), l.options.updatedValues.set($, b.original)), xt(h, i, $);
709
709
  }
710
- (I = g.callbacks) === null || I === void 0 || I.forEach((O) => {
711
- O(f, m);
710
+ (I = w.callbacks) === null || I === void 0 || I.forEach(($) => {
711
+ $(f, m);
712
712
  });
713
713
  });
714
714
  } else {
715
715
  const l = k(u);
716
716
  l.finalities.draft.push((f, m) => {
717
- dt(l), ht(l, Fe, f, m);
717
+ dt(l), ht(l, We, f, m);
718
718
  });
719
719
  }
720
720
  return u;
721
721
  }
722
722
  _t.createDraft = rn;
723
723
  Object.prototype.constructor.toString();
724
- function Ee() {
725
- return Pn();
724
+ function _e() {
725
+ return jn();
726
726
  }
727
- function Qn(e, t) {
727
+ function Gn(e, t) {
728
728
  return e.localeCompare(t);
729
729
  }
730
- function Gn() {
731
- let e = Qn;
730
+ function Hn() {
731
+ let e = Gn;
732
732
  if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
733
733
  try {
734
734
  e = Intl.Collator("en-US").compare;
@@ -736,8 +736,8 @@ function Gn() {
736
736
  }
737
737
  return e;
738
738
  }
739
- Gn();
740
- function Hn() {
739
+ Hn();
740
+ function Bn() {
741
741
  const t = {
742
742
  __etype: 1,
743
743
  __ops: 1,
@@ -751,8 +751,8 @@ function Hn() {
751
751
  };
752
752
  return new Set(Object.keys(t));
753
753
  }
754
- const Bn = Hn();
755
- function Ge(e, t, n) {
754
+ const qn = Bn();
755
+ function Qe(e, t, n) {
756
756
  const i = {
757
757
  __etype: e,
758
758
  __ops: n
@@ -763,15 +763,15 @@ function Ge(e, t, n) {
763
763
  return n;
764
764
  if (r === "__etype")
765
765
  return e;
766
- if (Bn.has(r))
767
- return (o, a) => Ge(e, t, [
766
+ if (qn.has(r))
767
+ return (o, a) => Qe(e, t, [
768
768
  ...n,
769
769
  a ? [r, e, t, o, a] : [r, e, t, o]
770
770
  ]);
771
771
  }
772
772
  });
773
773
  }
774
- function qn(e, t) {
774
+ function Kn(e, t) {
775
775
  return `lookup__${e}__${JSON.stringify(t)}`;
776
776
  }
777
777
  function on(e) {
@@ -781,29 +781,29 @@ function Dt(e) {
781
781
  const [t, n, ...i] = e.split("__");
782
782
  return [n, JSON.parse(i.join("__"))];
783
783
  }
784
- function Kn(e) {
784
+ function Xn(e) {
785
785
  return new Proxy({
786
786
  __etype: e
787
787
  }, {
788
788
  get(t, n) {
789
789
  if (n === "lookup")
790
- return (s, r) => Ge(e, Dt(qn(s, r)), []);
790
+ return (s, r) => Qe(e, Dt(Kn(s, r)), []);
791
791
  if (n === "__etype")
792
792
  return e;
793
793
  const i = n;
794
- return on(i) ? Ge(e, Dt(i), []) : Ge(e, i, []);
794
+ return on(i) ? Qe(e, Dt(i), []) : Qe(e, i, []);
795
795
  }
796
796
  });
797
797
  }
798
798
  function an() {
799
799
  return new Proxy({}, {
800
800
  get(e, t) {
801
- return Kn(t);
801
+ return Xn(t);
802
802
  }
803
803
  });
804
804
  }
805
805
  an();
806
- function Xn(e) {
806
+ function Yn(e) {
807
807
  return e.__ops;
808
808
  }
809
809
  class B extends Error {
@@ -818,7 +818,7 @@ class B extends Error {
818
818
  return "InstantError";
819
819
  }
820
820
  }
821
- class Se extends B {
821
+ class Ie extends B {
822
822
  constructor(n) {
823
823
  var r;
824
824
  const i = ((r = n.body) == null ? void 0 : r.message) || `API Error (${n.status})`;
@@ -826,15 +826,15 @@ class Se extends B {
826
826
  d(this, "body");
827
827
  d(this, "status");
828
828
  const s = new.target.prototype;
829
- Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Se), this.name = "InstantAPIError", this.status = n.status, this.body = n.body;
829
+ Object.setPrototypeOf && Object.setPrototypeOf(this, s), Error.captureStackTrace && Error.captureStackTrace(this, Ie), this.name = "InstantAPIError", this.status = n.status, this.body = n.body;
830
830
  }
831
831
  get [Symbol.toStringTag]() {
832
832
  return "InstantAPIError";
833
833
  }
834
834
  }
835
835
  typeof window < "u" && typeof window.localStorage < "u" && (window.localStorage.getItem("devBackend"), window.localStorage.getItem("__instantLogging"), window.localStorage.getItem("__devtoolLocalDash"));
836
- const Re = "v0.22.149";
837
- class ce {
836
+ const Ae = "v0.22.150";
837
+ class ue {
838
838
  constructor(t, n, i, s = { indexed: !1, unique: !1 }) {
839
839
  d(this, "valueType");
840
840
  d(this, "required");
@@ -849,19 +849,19 @@ class ce {
849
849
  * and enforced for backend
850
850
  */
851
851
  clientRequired() {
852
- return new ce(this.valueType, !1, this.isIndexed, this.config);
852
+ return new ue(this.valueType, !1, this.isIndexed, this.config);
853
853
  }
854
854
  optional() {
855
- return new ce(this.valueType, !1, this.isIndexed, this.config);
855
+ return new ue(this.valueType, !1, this.isIndexed, this.config);
856
856
  }
857
857
  unique() {
858
- return new ce(this.valueType, this.required, this.isIndexed, {
858
+ return new ue(this.valueType, this.required, this.isIndexed, {
859
859
  ...this.config,
860
860
  unique: !0
861
861
  });
862
862
  }
863
863
  indexed() {
864
- return new ce(this.valueType, this.required, !0, {
864
+ return new ue(this.valueType, this.required, !0, {
865
865
  ...this.config,
866
866
  indexed: !0
867
867
  });
@@ -884,7 +884,7 @@ const Nt = [
884
884
  "before",
885
885
  "fields",
886
886
  "aggregate"
887
- ], Yn = (e) => e.valueType || "unknown", cn = (e, t, n = !1) => {
887
+ ], Zn = (e) => e.valueType || "unknown", cn = (e, t, n = !1) => {
888
888
  if (n || e == null)
889
889
  return !0;
890
890
  switch (t) {
@@ -899,7 +899,7 @@ const Nt = [
899
899
  default:
900
900
  return !0;
901
901
  }
902
- }, Zn = (e, t, n, i, s, r, o) => {
902
+ }, ei = (e, t, n, i, s, r, o) => {
903
903
  const a = r.valueType === "json", u = (c, l, f) => {
904
904
  if (!cn(f, l, a))
905
905
  throw new E(`Invalid value for operator '${c}' on attribute '${i}' in entity '${s}'. Expected ${l}, but received: ${typeof f}`, o);
@@ -931,17 +931,17 @@ const Nt = [
931
931
  default:
932
932
  throw new E(`Unknown operator '${e}' for attribute '${i}' in entity '${s}'`, o);
933
933
  }
934
- }, _e = (e, t, n, i, s) => {
935
- const r = Yn(n), o = n.valueType === "json";
934
+ }, Ce = (e, t, n, i, s) => {
935
+ const r = Zn(n), o = n.valueType === "json";
936
936
  if (typeof e == "object" && e !== null && !Array.isArray(e)) {
937
937
  if (o)
938
938
  return;
939
939
  const u = e;
940
940
  for (const [c, l] of Object.entries(u))
941
- Zn(c, l, r, t, i, n, `${s}.${c}`);
941
+ ei(c, l, r, t, i, n, `${s}.${c}`);
942
942
  } else if (!cn(e, r, o))
943
943
  throw new E(`Invalid value for attribute '${t}' in entity '${i}'. Expected ${r}, but received: ${typeof e}`, s);
944
- }, ei = (e, t, n, i, s) => {
944
+ }, ti = (e, t, n, i, s) => {
945
945
  const r = e.split(".");
946
946
  if (r.length < 2)
947
947
  throw new E(`Invalid dot notation path '${e}'. Must contain at least one dot.`, s);
@@ -950,34 +950,34 @@ const Nt = [
950
950
  const f = r[l], m = i.entities[o];
951
951
  if (!m)
952
952
  throw new E(`Entity '${o}' does not exist in schema while traversing dot notation path '${e}'.`, s);
953
- const p = m.links[f];
954
- if (!p) {
953
+ const y = m.links[f];
954
+ if (!y) {
955
955
  const I = Object.keys(m.links);
956
956
  throw new E(`Link '${f}' does not exist on entity '${o}' in dot notation path '${e}'. Available links: ${I.length > 0 ? I.join(", ") : "none"}`, s);
957
957
  }
958
- o = p.entityName;
958
+ o = y.entityName;
959
959
  }
960
960
  const a = r[r.length - 1], u = i.entities[o];
961
961
  if (!u)
962
962
  throw new E(`Target entity '${o}' does not exist in schema for dot notation path '${e}'.`, s);
963
963
  if (a === "id") {
964
- if (typeof t == "string" && !Te(t))
964
+ if (typeof t == "string" && !Re(t))
965
965
  throw new E(`Invalid value for id field in entity '${o}'. Expected a UUID, but received: ${t}`, s);
966
- _e(t, e, new ce("string", !1, !0), n, s);
966
+ Ce(t, e, new ue("string", !1, !0), n, s);
967
967
  return;
968
968
  }
969
969
  const c = u.attrs[a];
970
970
  if (Object.keys(u.links).includes(a)) {
971
- if (typeof t == "string" && !Te(t))
971
+ if (typeof t == "string" && !Re(t))
972
972
  throw new E(`Invalid value for link '${a}' in entity '${o}'. Expected a UUID, but received: ${t}`, s);
973
- _e(t, e, new ce("string", !1, !0), n, s);
973
+ Ce(t, e, new ue("string", !1, !0), n, s);
974
974
  return;
975
975
  }
976
976
  if (!c) {
977
977
  const l = Object.keys(u.attrs);
978
978
  throw new E(`Attribute '${a}' does not exist on entity '${o}' in dot notation path '${e}'. Available attributes: ${l.length > 0 ? l.join(", ") + ", id" : "id"}`, s);
979
979
  }
980
- _e(t, e, c, n, s);
980
+ Ce(t, e, c, n, s);
981
981
  }, un = (e, t, n, i) => {
982
982
  for (const [s, r] of Object.entries(e)) {
983
983
  if (s === "or" || s === "and") {
@@ -987,11 +987,11 @@ const Nt = [
987
987
  continue;
988
988
  }
989
989
  if (s === "id") {
990
- _e(r, "id", new ce("string", !1, !0), t, `${i}.id`);
990
+ Ce(r, "id", new ue("string", !1, !0), t, `${i}.id`);
991
991
  continue;
992
992
  }
993
993
  if (s.includes(".")) {
994
- ei(s, r, t, n, `${i}.${s}`);
994
+ ti(s, r, t, n, `${i}.${s}`);
995
995
  continue;
996
996
  }
997
997
  const o = n.entities[t];
@@ -1003,15 +1003,15 @@ const Nt = [
1003
1003
  throw new E(`Attribute or link '${s}' does not exist on entity '${t}'. Available attributes: ${c.length > 0 ? c.join(", ") : "none"}. Available links: ${l.length > 0 ? l.join(", ") : "none"}`, `${i}.${s}`);
1004
1004
  }
1005
1005
  if (a)
1006
- _e(r, s, a, t, `${i}.${s}`);
1006
+ Ce(r, s, a, t, `${i}.${s}`);
1007
1007
  else if (u) {
1008
- if (typeof r == "string" && !Te(r))
1008
+ if (typeof r == "string" && !Re(r))
1009
1009
  throw new E(`Invalid value for link '${s}' in entity '${t}'. Expected a UUID, but received: ${r}`, `${i}.${s}`);
1010
- const c = new ce("string", !1, !0);
1011
- _e(r, s, c, t, `${i}.${s}`);
1010
+ const c = new ue("string", !1, !0);
1011
+ Ce(r, s, c, t, `${i}.${s}`);
1012
1012
  }
1013
1013
  }
1014
- }, ti = (e, t, n, i, s = 0) => {
1014
+ }, ni = (e, t, n, i, s = 0) => {
1015
1015
  for (const o of Object.keys(e))
1016
1016
  if (!Nt.includes(o))
1017
1017
  throw new E(`Invalid query parameter '${o}' in $ object. Valid parameters are: ${Nt.join(", ")}. Found: ${o}`, i);
@@ -1050,7 +1050,7 @@ const Nt = [
1050
1050
  const a = e[o];
1051
1051
  if (typeof a != "object" || a === null)
1052
1052
  throw new E(`Query parameter '$' must be an object in entity '${t}', but received: ${typeof a}`, `${i}.$`);
1053
- ti(a, t, n, `${i}.$`, s);
1053
+ ni(a, t, n, `${i}.$`, s);
1054
1054
  }
1055
1055
  }, Lt = (e, t) => {
1056
1056
  if (typeof e != "object" || e === null)
@@ -1071,25 +1071,25 @@ const Nt = [
1071
1071
  fn(n[i], i, t, i, 0);
1072
1072
  }
1073
1073
  }
1074
- }, Wt = (e) => typeof e != "string" ? !1 : on(e) ? !0 : Te(e);
1074
+ }, Wt = (e) => typeof e != "string" ? !1 : on(e) ? !0 : Re(e);
1075
1075
  class q extends Error {
1076
1076
  constructor(t) {
1077
1077
  super(t), this.name = "TransactionValidationError";
1078
1078
  }
1079
1079
  }
1080
- const ln = (e) => e.length > 0 ? e.join(", ") : "none", ni = (e, t) => new q(`Entity '${e}' does not exist in schema. Available entities: ${ln(t)}`), at = {
1080
+ const ln = (e) => e.length > 0 ? e.join(", ") : "none", ii = (e, t) => new q(`Entity '${e}' does not exist in schema. Available entities: ${ln(t)}`), at = {
1081
1081
  string: (e) => typeof e == "string",
1082
1082
  number: (e) => typeof e == "number" && !isNaN(e),
1083
1083
  boolean: (e) => typeof e == "boolean",
1084
1084
  date: (e) => e instanceof Date || typeof e == "string" || typeof e == "number",
1085
1085
  json: () => !0
1086
- }, ii = (e, t) => {
1086
+ }, si = (e, t) => {
1087
1087
  var n;
1088
1088
  return e == null ? !0 : ((n = at[t.valueType]) == null ? void 0 : n.call(at, e)) ?? !1;
1089
1089
  }, dn = (e, t) => {
1090
1090
  const n = t.entities[e];
1091
1091
  if (!n)
1092
- throw ni(e, Object.keys(t.entities));
1092
+ throw ii(e, Object.keys(t.entities));
1093
1093
  return n;
1094
1094
  }, ct = (e, t, n) => {
1095
1095
  const i = dn(e, n);
@@ -1099,7 +1099,7 @@ const ln = (e) => e.length > 0 ? e.join(", ") : "none", ni = (e, t) => new q(`En
1099
1099
  if (s === "id")
1100
1100
  continue;
1101
1101
  const o = i.attrs[s];
1102
- if (o && !ii(r, o))
1102
+ if (o && !si(r, o))
1103
1103
  throw new q(`Invalid value for attribute '${s}' in entity '${e}'. Expected ${o.valueType}, but received: ${typeof r}`);
1104
1104
  }
1105
1105
  }, Ft = (e, t, n) => {
@@ -1120,7 +1120,7 @@ const ln = (e) => e.length > 0 ? e.join(", ") : "none", ni = (e, t) => new q(`En
1120
1120
  throw new q(`Invalid UUID in link '${s}' for entity '${e}'. Expected a UUID, but received: ${r}`);
1121
1121
  }
1122
1122
  }
1123
- }, si = {
1123
+ }, ri = {
1124
1124
  create: ct,
1125
1125
  update: ct,
1126
1126
  merge: ct,
@@ -1128,17 +1128,17 @@ const ln = (e) => e.length > 0 ? e.join(", ") : "none", ni = (e, t) => new q(`En
1128
1128
  unlink: Ft,
1129
1129
  delete: () => {
1130
1130
  }
1131
- }, ri = (e, t) => {
1131
+ }, oi = (e, t) => {
1132
1132
  if (!t)
1133
1133
  return;
1134
1134
  const [n, i, s, r] = e;
1135
- if (!Array.isArray(s) && !Te(s))
1135
+ if (!Array.isArray(s) && !Re(s))
1136
1136
  throw new q(`Invalid id for entity '${i}'. Expected a UUID, but received: ${s}`);
1137
1137
  if (typeof i != "string")
1138
1138
  throw new q(`Entity name must be a string, but received: ${typeof i}`);
1139
- const o = si[n];
1139
+ const o = ri[n];
1140
1140
  o && r !== void 0 && o(i, r, t);
1141
- }, oi = (e, t) => {
1141
+ }, ai = (e, t) => {
1142
1142
  const n = Array.isArray(e) ? e : [e];
1143
1143
  for (const i of n) {
1144
1144
  if (!i || typeof i != "object")
@@ -1148,12 +1148,12 @@ const ln = (e) => e.length > 0 ? e.join(", ") : "none", ni = (e, t) => new q(`En
1148
1148
  for (const s of i.__ops) {
1149
1149
  if (!Array.isArray(s))
1150
1150
  throw new q(`Transaction operation must be an array, but received: ${typeof s}`);
1151
- ri(s, t);
1151
+ oi(s, t);
1152
1152
  }
1153
1153
  }
1154
1154
  };
1155
- let ai = 0;
1156
- class ci {
1155
+ let ci = 0;
1156
+ class ui {
1157
1157
  constructor(t, n, i) {
1158
1158
  d(this, "type", "sse");
1159
1159
  d(this, "initParams", null);
@@ -1170,7 +1170,7 @@ class ci {
1170
1170
  d(this, "onmessage");
1171
1171
  d(this, "onclose");
1172
1172
  d(this, "onerror");
1173
- this.id = `${this.type}_${ai++}`, this.url = n, this.messageUrl = i || this.url, this.ES = t, this.conn = new t(n), this.sseInitTimeout = setTimeout(() => {
1173
+ this.id = `${this.type}_${ci++}`, this.url = n, this.messageUrl = i || this.url, this.ES = t, this.conn = new t(n), this.sseInitTimeout = setTimeout(() => {
1174
1174
  this.initParams || this.handleError();
1175
1175
  }, 1e4), this.conn.onmessage = (s) => {
1176
1176
  const r = JSON.parse(s.data);
@@ -1254,206 +1254,206 @@ var zt;
1254
1254
  (function(e) {
1255
1255
  e.InitialSyncBatch = "InitialSyncBatch", e.InitialSyncComplete = "InitialSyncComplete", e.LoadFromStorage = "LoadFromStorage", e.SyncTransaction = "SyncTransaction", e.Error = "Error";
1256
1256
  })(zt || (zt = {}));
1257
- function ui({ WStream: e, opts: t, startStream: n, appendStream: i, registerStream: s }) {
1257
+ function fi({ WStream: e, opts: t, startStream: n, appendStream: i, registerStream: s }) {
1258
1258
  const r = t.clientId;
1259
- let o = null, a = null;
1260
- const u = Ee();
1261
- let c = !1, l = !1;
1262
- const f = [], m = [], p = [];
1263
- let I = !1, g = 0, h = 0;
1264
- const $ = [], w = new TextEncoder();
1265
- function O() {
1266
- l = !0;
1267
- for (const y of f)
1268
- y();
1269
- }
1270
- function ne(y) {
1271
- return f.push(y), () => {
1272
- const v = f.indexOf(y);
1273
- v !== -1 && f.splice(v, 1);
1259
+ let o = null, a = null, u = null;
1260
+ const c = _e();
1261
+ let l = !1, f = !1;
1262
+ const m = [], y = [], I = [];
1263
+ let w = !1, h = 0, O = 0;
1264
+ const b = [], $ = new TextEncoder();
1265
+ function K() {
1266
+ f = !0;
1267
+ for (const p of m)
1268
+ p(a ?? void 0);
1269
+ }
1270
+ function P(p) {
1271
+ return m.push(p), f && p(a ?? void 0), () => {
1272
+ const v = m.indexOf(p);
1273
+ v !== -1 && m.splice(v, 1);
1274
1274
  };
1275
1275
  }
1276
- function P(y) {
1277
- return p.push(y), () => {
1278
- const v = p.indexOf(y);
1279
- v !== -1 && p.splice(v, 1);
1276
+ function U(p) {
1277
+ return I.push(p), () => {
1278
+ const v = I.indexOf(p);
1279
+ v !== -1 && I.splice(v, 1);
1280
1280
  };
1281
1281
  }
1282
- t.waitUntil && t.waitUntil(new Promise((y) => {
1283
- p.push(y);
1282
+ t.waitUntil && t.waitUntil(new Promise((p) => {
1283
+ I.push(p);
1284
1284
  }));
1285
- function j() {
1286
- for (const y of p)
1285
+ function F() {
1286
+ for (const p of I)
1287
1287
  try {
1288
- y();
1288
+ p();
1289
1289
  } catch {
1290
1290
  }
1291
1291
  }
1292
- function K(y) {
1293
- return m.push(y), () => {
1294
- const v = m.indexOf(y);
1295
- v !== -1 && m.splice(v, 1);
1292
+ function re(p) {
1293
+ return y.push(p), o && p(o), () => {
1294
+ const v = y.indexOf(p);
1295
+ v !== -1 && y.splice(v, 1);
1296
1296
  };
1297
1297
  }
1298
- function ie(y) {
1299
- o = y;
1300
- for (const v of m)
1298
+ function te(p) {
1299
+ o = p;
1300
+ for (const v of y)
1301
1301
  v(o);
1302
1302
  }
1303
- function V() {
1304
- I = !0;
1303
+ function me() {
1304
+ w = !0;
1305
1305
  }
1306
- function Ae(y) {
1307
- let v = g, D = 0, F = 0;
1308
- for (const { byteLen: X } of $) {
1309
- const re = v + X;
1310
- if (re > y)
1306
+ function nt(p) {
1307
+ let v = h, D = 0, z = 0;
1308
+ for (const { byteLen: Y } of b) {
1309
+ const oe = v + Y;
1310
+ if (oe > p)
1311
1311
  break;
1312
- v = re, D++, F += X;
1312
+ v = oe, D++, z += Y;
1313
1313
  }
1314
- D > 0 && (g += F, h -= F, $.splice(0, D));
1314
+ D > 0 && (h += z, O -= z, b.splice(0, D));
1315
1315
  }
1316
- function pe(y, v) {
1317
- O(), y.error(v), j();
1316
+ function X(p, v) {
1317
+ a = v, K(), p.error(v), F();
1318
1318
  }
1319
- async function me() {
1320
- const y = await n({
1319
+ async function ne() {
1320
+ const p = await n({
1321
1321
  clientId: r,
1322
- reconnectToken: u,
1322
+ reconnectToken: c,
1323
1323
  ruleParams: t.ruleParams
1324
1324
  });
1325
- switch (y.type) {
1325
+ switch (p.type) {
1326
1326
  case "ok": {
1327
- const { streamId: v, offset: D } = y;
1328
- o = v, Ae(D), $.length && i({
1327
+ const { streamId: v, offset: D } = p;
1328
+ o = v, nt(D), b.length && i({
1329
1329
  streamId: v,
1330
- chunks: $.map((F) => F.chunk),
1331
- offset: g
1332
- }), I = !1;
1330
+ chunks: b.map((z) => z.chunk),
1331
+ offset: h
1332
+ }), w = !1;
1333
1333
  break;
1334
1334
  }
1335
1335
  case "disconnect": {
1336
- V();
1336
+ me();
1337
1337
  break;
1338
1338
  }
1339
1339
  case "error": {
1340
- a && pe(a, y.error);
1340
+ u && X(u, p.error);
1341
1341
  break;
1342
1342
  }
1343
1343
  }
1344
1344
  }
1345
- function se() {
1346
- V(), me();
1345
+ function J() {
1346
+ me(), ne();
1347
1347
  }
1348
- function J({ offset: y, done: v }) {
1349
- Ae(y), v && (c = !0, j());
1348
+ function Pe({ offset: p, done: v }) {
1349
+ nt(p), v && (l = !0, F());
1350
1350
  }
1351
- function Pe(y) {
1352
- return c ? (pe(y, new B("Stream has been closed.")), null) : o || (pe(y, new B("Stream has not been initialized.")), null);
1351
+ function $n(p) {
1352
+ return l ? (X(p, new B("Stream has been closed.")), null) : o || (X(p, new B("Stream has not been initialized.")), null);
1353
1353
  }
1354
- async function $n(y) {
1355
- a = y;
1354
+ async function kn(p) {
1355
+ u = p;
1356
1356
  let v = !0, D = 0;
1357
1357
  for (; v; ) {
1358
- let F = Date.now() + Math.min(15e3, 500 * (D - 1));
1358
+ let z = Date.now() + Math.min(15e3, 500 * (D - 1));
1359
1359
  v = !1;
1360
- const X = await n({
1360
+ const Y = await n({
1361
1361
  clientId: t.clientId,
1362
- reconnectToken: u,
1362
+ reconnectToken: c,
1363
1363
  ruleParams: t.ruleParams
1364
1364
  });
1365
- switch (X.type) {
1365
+ switch (Y.type) {
1366
1366
  case "ok": {
1367
- const { streamId: re, offset: it } = X;
1367
+ const { streamId: oe, offset: it } = Y;
1368
1368
  if (it !== 0) {
1369
- const je = new B("Write stream is corrupted");
1370
- pe(y, je);
1369
+ const ye = new B("Write stream is corrupted");
1370
+ X(p, ye);
1371
1371
  return;
1372
1372
  }
1373
- ie(re), s(re, {
1374
- onDisconnect: V,
1375
- onFlush: J,
1376
- onConnectionReconnect: me,
1377
- onAppendFailed: se
1378
- }), I = !1;
1373
+ te(oe), s(oe, {
1374
+ onDisconnect: me,
1375
+ onFlush: Pe,
1376
+ onConnectionReconnect: ne,
1377
+ onAppendFailed: J
1378
+ }), w = !1;
1379
1379
  return;
1380
1380
  }
1381
1381
  case "disconnect": {
1382
- v = !0, V(), D++, await new Promise((re) => {
1383
- setTimeout(re, Math.max(0, F - Date.now()));
1382
+ v = !0, me(), D++, await new Promise((oe) => {
1383
+ setTimeout(oe, Math.max(0, z - Date.now()));
1384
1384
  });
1385
1385
  break;
1386
1386
  }
1387
1387
  case "error": {
1388
- pe(y, X.error);
1388
+ X(p, Y.error);
1389
1389
  return;
1390
1390
  }
1391
1391
  }
1392
1392
  }
1393
1393
  }
1394
- class kn extends e {
1394
+ class En extends e {
1395
1395
  constructor(v, D) {
1396
1396
  super(v, D);
1397
1397
  }
1398
1398
  async streamId() {
1399
1399
  return o || new Promise((v, D) => {
1400
- const F = [], X = () => {
1401
- for (const je of F)
1402
- je();
1403
- }, re = (je) => {
1404
- v(je), X();
1405
- }, it = () => {
1406
- D(new B("Stream is closed.")), X();
1400
+ const z = [], Y = () => {
1401
+ for (const ye of z)
1402
+ ye();
1403
+ }, oe = (ye) => {
1404
+ v(ye), Y();
1405
+ }, it = (ye) => {
1406
+ D(ye || new B("Stream is closed.")), Y();
1407
1407
  };
1408
- F.push(K(re)), F.push(ne(it));
1408
+ z.push(re(oe)), z.push(P(it));
1409
1409
  });
1410
1410
  }
1411
1411
  }
1412
1412
  return {
1413
- stream: new kn({
1413
+ stream: new En({
1414
1414
  // TODO(dww): accept a storage so that write streams can survive across
1415
1415
  // browser restarts
1416
- async start(y) {
1416
+ async start(p) {
1417
1417
  try {
1418
- await $n(y);
1418
+ await kn(p);
1419
1419
  } catch (v) {
1420
- pe(y, v);
1420
+ X(p, v);
1421
1421
  }
1422
1422
  },
1423
- write(y, v) {
1424
- const D = Pe(v);
1423
+ write(p, v) {
1424
+ const D = $n(v);
1425
1425
  if (D) {
1426
- const F = w.encode(y).length;
1427
- $.push({ chunk: y, byteLen: F });
1428
- const X = g + h;
1429
- h += F, I || i({ streamId: D, chunks: [y], offset: X });
1426
+ const z = $.encode(p).length;
1427
+ b.push({ chunk: p, byteLen: z });
1428
+ const Y = h + O;
1429
+ O += z, w || i({ streamId: D, chunks: [p], offset: Y });
1430
1430
  }
1431
1431
  },
1432
1432
  close() {
1433
1433
  o ? i({
1434
1434
  streamId: o,
1435
1435
  chunks: [],
1436
- offset: g + h,
1436
+ offset: h + O,
1437
1437
  isDone: !0
1438
- }) : j(), O();
1438
+ }) : F(), K();
1439
1439
  },
1440
- abort(y) {
1440
+ abort(p) {
1441
1441
  o ? i({
1442
1442
  streamId: o,
1443
1443
  chunks: [],
1444
- offset: g + h,
1444
+ offset: h + O,
1445
1445
  isDone: !0,
1446
- abortReason: y
1447
- }) : j(), O();
1446
+ abortReason: p
1447
+ }) : F(), K();
1448
1448
  }
1449
1449
  }),
1450
- addCompleteCb: P,
1450
+ addCompleteCb: U,
1451
1451
  closed() {
1452
- return l;
1452
+ return f;
1453
1453
  }
1454
1454
  };
1455
1455
  }
1456
- class fi {
1456
+ class li {
1457
1457
  constructor() {
1458
1458
  d(this, "items", []);
1459
1459
  d(this, "resolvers", []);
@@ -1487,115 +1487,115 @@ class fi {
1487
1487
  }
1488
1488
  }
1489
1489
  }
1490
- function li({ RStream: e, opts: t, startStream: n, cancelStream: i }) {
1490
+ function di({ RStream: e, opts: t, startStream: n, cancelStream: i }) {
1491
1491
  let s = t.byteOffset || 0, r = !1;
1492
1492
  const o = new TextDecoder("utf-8"), a = new TextEncoder();
1493
1493
  let u, c = !1;
1494
1494
  const l = [];
1495
1495
  function f() {
1496
1496
  c = !0;
1497
- for (const w of l)
1498
- w();
1497
+ for (const b of l)
1498
+ b();
1499
1499
  }
1500
- function m(w) {
1501
- return l.push(w), () => {
1502
- const O = l.indexOf(w);
1503
- O !== -1 && l.splice(O, 1);
1500
+ function m(b) {
1501
+ return l.push(b), () => {
1502
+ const $ = l.indexOf(b);
1503
+ $ !== -1 && l.splice($, 1);
1504
1504
  };
1505
1505
  }
1506
- function p(w, O) {
1507
- w.error(O), f();
1506
+ function y(b, $) {
1507
+ b.error($), f();
1508
1508
  }
1509
1509
  let I = 0;
1510
- async function g(w, O) {
1511
- u = Ee();
1512
- const ne = { ...w || {}, eventId: u };
1513
- for await (const P of n(ne)) {
1510
+ async function w(b, $) {
1511
+ u = _e();
1512
+ const K = { ...b || {}, eventId: u };
1513
+ for await (const P of n(K)) {
1514
1514
  if (r)
1515
1515
  return;
1516
1516
  if (P.type === "reconnect")
1517
1517
  return { retry: !0 };
1518
1518
  if (P.type === "error") {
1519
- p(O, P.error);
1519
+ y($, P.error);
1520
1520
  return;
1521
1521
  }
1522
1522
  if (P.offset > s) {
1523
- p(O, new B("Stream is corrupted.")), r = !0;
1523
+ y($, new B("Stream is corrupted.")), r = !0;
1524
1524
  return;
1525
1525
  }
1526
- let j = s - P.offset;
1526
+ let U = s - P.offset;
1527
1527
  if (P.files && P.files.length) {
1528
- const K = new AbortController();
1529
- let ie = fetch(P.files[0].url, {
1530
- signal: K.signal
1528
+ const F = new AbortController();
1529
+ let re = fetch(P.files[0].url, {
1530
+ signal: F.signal
1531
1531
  });
1532
- for (let V = 0; V < P.files.length; V++) {
1533
- const Ae = P.files[V + 1], me = await ie;
1534
- if (Ae && (ie = fetch(Ae.url, { signal: K.signal })), !me.ok) {
1532
+ for (let te = 0; te < P.files.length; te++) {
1533
+ const me = P.files[te + 1], X = await re;
1534
+ if (me && (re = fetch(me.url, { signal: F.signal })), !X.ok) {
1535
1535
  if (I++, I > 10) {
1536
- p(O, new B("Unable to process stream."));
1536
+ y($, new B("Unable to process stream."));
1537
1537
  return;
1538
1538
  }
1539
1539
  return { retry: !0 };
1540
1540
  }
1541
- if (me.body)
1542
- for await (const se of me.body) {
1541
+ if (X.body)
1542
+ for await (const ne of X.body) {
1543
1543
  if (r) {
1544
- K.abort();
1544
+ F.abort();
1545
1545
  return;
1546
1546
  }
1547
- let J = se;
1548
- if (j > 0 && (J = se.subarray(j), j -= se.length - J.length), !J.length)
1547
+ let J = ne;
1548
+ if (U > 0 && (J = ne.subarray(U), U -= ne.length - J.length), !J.length)
1549
1549
  continue;
1550
1550
  s += J.length;
1551
1551
  const Pe = o.decode(J);
1552
- O.enqueue(Pe);
1552
+ $.enqueue(Pe);
1553
1553
  }
1554
1554
  else {
1555
- const se = await me.arrayBuffer();
1556
- let J = se;
1555
+ const ne = await X.arrayBuffer();
1556
+ let J = ne;
1557
1557
  if (r) {
1558
- K.abort();
1558
+ F.abort();
1559
1559
  return;
1560
1560
  }
1561
- if (j > 0 && (J = new Uint8Array(se).subarray(j), j -= se.byteLength - J.length), !J.byteLength)
1561
+ if (U > 0 && (J = new Uint8Array(ne).subarray(U), U -= ne.byteLength - J.length), !J.byteLength)
1562
1562
  continue;
1563
1563
  s += J.byteLength;
1564
1564
  const Pe = o.decode(J);
1565
- O.enqueue(Pe);
1565
+ $.enqueue(Pe);
1566
1566
  }
1567
1567
  }
1568
1568
  }
1569
1569
  if (I = 0, P.content) {
1570
- let K = P.content, ie = a.encode(P.content);
1571
- if (j > 0) {
1572
- const V = ie.subarray(j);
1573
- if (j -= ie.length - V.length, !V.length)
1570
+ let F = P.content, re = a.encode(P.content);
1571
+ if (U > 0) {
1572
+ const te = re.subarray(U);
1573
+ if (U -= re.length - te.length, !te.length)
1574
1574
  continue;
1575
- ie = V, K = o.decode(V);
1575
+ re = te, F = o.decode(te);
1576
1576
  }
1577
- s += ie.length, O.enqueue(K);
1577
+ s += re.length, $.enqueue(F);
1578
1578
  }
1579
1579
  }
1580
1580
  }
1581
- async function h(w) {
1582
- let O = !0, ne = 0;
1583
- for (; O; ) {
1584
- O = !1;
1585
- let P = Date.now() + Math.min(15e3, 500 * (ne - 1));
1586
- const j = await g({ ...t, offset: s }, w);
1587
- j != null && j.retry && (O = !0, ne++, P < Date.now() - 3e5 && (ne = 0), await new Promise((K) => {
1588
- setTimeout(K, Math.max(0, P - Date.now()));
1581
+ async function h(b) {
1582
+ let $ = !0, K = 0;
1583
+ for (; $; ) {
1584
+ $ = !1;
1585
+ let P = Date.now() + Math.min(15e3, 500 * (K - 1));
1586
+ const U = await w({ ...t, offset: s }, b);
1587
+ U != null && U.retry && ($ = !0, K++, P < Date.now() - 3e5 && (K = 0), await new Promise((F) => {
1588
+ setTimeout(F, Math.max(0, P - Date.now()));
1589
1589
  }));
1590
1590
  }
1591
- !r && !c && (w.close(), f());
1591
+ !r && !c && (b.close(), f());
1592
1592
  }
1593
1593
  return {
1594
1594
  stream: new e({
1595
- start(w) {
1596
- h(w);
1595
+ start(b) {
1596
+ h(b);
1597
1597
  },
1598
- cancel(w) {
1598
+ cancel(b) {
1599
1599
  r = !0, u && i({ eventId: u }), f();
1600
1600
  }
1601
1601
  }),
@@ -1605,7 +1605,7 @@ function li({ RStream: e, opts: t, startStream: n, cancelStream: i }) {
1605
1605
  }
1606
1606
  };
1607
1607
  }
1608
- class di {
1608
+ class hi {
1609
1609
  constructor({ WStream: t, RStream: n, trySend: i, log: s }) {
1610
1610
  d(this, "trySend");
1611
1611
  d(this, "WStream");
@@ -1618,7 +1618,7 @@ class di {
1618
1618
  this.WStream = t, this.RStream = n, this.trySend = i, this.log = s;
1619
1619
  }
1620
1620
  createWriteStream(t) {
1621
- const { stream: n, addCompleteCb: i } = ui({
1621
+ const { stream: n, addCompleteCb: i } = fi({
1622
1622
  WStream: this.WStream,
1623
1623
  startStream: this.startWriteStream.bind(this),
1624
1624
  appendStream: this.appendStream.bind(this),
@@ -1630,7 +1630,7 @@ class di {
1630
1630
  }), n;
1631
1631
  }
1632
1632
  createReadStream(t) {
1633
- const { stream: n, addCloseCb: i } = li({
1633
+ const { stream: n, addCloseCb: i } = di({
1634
1634
  RStream: this.RStream,
1635
1635
  opts: t,
1636
1636
  startStream: this.startReadStream.bind(this),
@@ -1641,7 +1641,7 @@ class di {
1641
1641
  }), n;
1642
1642
  }
1643
1643
  startWriteStream(t) {
1644
- const n = Ee();
1644
+ const n = _e();
1645
1645
  let i = null;
1646
1646
  const s = new Promise((o) => {
1647
1647
  i = o;
@@ -1665,7 +1665,7 @@ class di {
1665
1665
  offset: s,
1666
1666
  done: !!i
1667
1667
  };
1668
- r && (o["abort-reason"] = r), this.trySend(Ee(), o);
1668
+ r && (o["abort-reason"] = r), this.trySend(_e(), o);
1669
1669
  }
1670
1670
  onAppendFailed(t) {
1671
1671
  const n = this.writeStreams[t["stream-id"]];
@@ -1692,7 +1692,7 @@ class di {
1692
1692
  if (!i && !n)
1693
1693
  throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");
1694
1694
  i && (o["stream-id"] = i), n && (o["client-id"] = n), s && (o.offset = s), r && (o["rule-params"] = r);
1695
- const a = new fi();
1695
+ const a = new li();
1696
1696
  return this.readStreamIterators[t] = a, this.trySend(t, o), a;
1697
1697
  }
1698
1698
  cancelReadStream({ eventId: t }) {
@@ -1700,7 +1700,7 @@ class di {
1700
1700
  op: "unsubscribe-stream",
1701
1701
  "subscribe-event-id": t
1702
1702
  };
1703
- this.trySend(Ee(), n), delete this.readStreamIterators[t];
1703
+ this.trySend(_e(), n), delete this.readStreamIterators[t];
1704
1704
  }
1705
1705
  onStreamAppend(t) {
1706
1706
  var s;
@@ -1726,7 +1726,7 @@ class di {
1726
1726
  onConnectionStatusChange(t) {
1727
1727
  for (const n of Object.values(this.startWriteStreamCbs))
1728
1728
  n({ type: "disconnect" });
1729
- if (this.startWriteStreamCbs = {}, t !== hi.AUTHENTICATED)
1729
+ if (this.startWriteStreamCbs = {}, t !== pi.AUTHENTICATED)
1730
1730
  for (const { onDisconnect: n } of Object.values(this.writeStreams))
1731
1731
  n();
1732
1732
  else {
@@ -1767,17 +1767,17 @@ class di {
1767
1767
  return this.activeStreams.size > 0;
1768
1768
  }
1769
1769
  }
1770
- const hi = {
1770
+ const pi = {
1771
1771
  AUTHENTICATED: "authenticated"
1772
1772
  };
1773
- function pi() {
1773
+ function mi() {
1774
1774
  return globalThis.__instantDbSchemaHashStore = globalThis.__instantDbSchemaHashStore ?? /* @__PURE__ */ new WeakMap(), globalThis.__instantDbSchemaHashStore;
1775
1775
  }
1776
- function mi() {
1776
+ function yi() {
1777
1777
  return globalThis.__instantDbStore = globalThis.__instantDbStore ?? {}, globalThis.__instantDbStore;
1778
1778
  }
1779
+ yi();
1779
1780
  mi();
1780
- pi();
1781
1781
  class Vt extends Error {
1782
1782
  constructor(t, n) {
1783
1783
  super(t), this.name = "ParseError", this.type = n.type, this.field = n.field, this.value = n.value, this.line = n.line;
@@ -1785,38 +1785,38 @@ class Vt extends Error {
1785
1785
  }
1786
1786
  function ut(e) {
1787
1787
  }
1788
- function yi(e) {
1788
+ function bi(e) {
1789
1789
  if (typeof e == "function")
1790
1790
  throw new TypeError(
1791
1791
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
1792
1792
  );
1793
1793
  const { onEvent: t = ut, onError: n = ut, onRetry: i = ut, onComment: s } = e;
1794
1794
  let r = "", o = !0, a, u = "", c = "";
1795
- function l(g) {
1796
- const h = o ? g.replace(/^\xEF\xBB\xBF/, "") : g, [$, w] = bi(`${r}${h}`);
1797
- for (const O of $)
1798
- f(O);
1799
- r = w, o = !1;
1800
- }
1801
- function f(g) {
1802
- if (g === "") {
1803
- p();
1795
+ function l(w) {
1796
+ const h = o ? w.replace(/^\xEF\xBB\xBF/, "") : w, [O, b] = gi(`${r}${h}`);
1797
+ for (const $ of O)
1798
+ f($);
1799
+ r = b, o = !1;
1800
+ }
1801
+ function f(w) {
1802
+ if (w === "") {
1803
+ y();
1804
1804
  return;
1805
1805
  }
1806
- if (g.startsWith(":")) {
1807
- s && s(g.slice(g.startsWith(": ") ? 2 : 1));
1806
+ if (w.startsWith(":")) {
1807
+ s && s(w.slice(w.startsWith(": ") ? 2 : 1));
1808
1808
  return;
1809
1809
  }
1810
- const h = g.indexOf(":");
1810
+ const h = w.indexOf(":");
1811
1811
  if (h !== -1) {
1812
- const $ = g.slice(0, h), w = g[h + 1] === " " ? 2 : 1, O = g.slice(h + w);
1813
- m($, O, g);
1812
+ const O = w.slice(0, h), b = w[h + 1] === " " ? 2 : 1, $ = w.slice(h + b);
1813
+ m(O, $, w);
1814
1814
  return;
1815
1815
  }
1816
- m(g, "", g);
1816
+ m(w, "", w);
1817
1817
  }
1818
- function m(g, h, $) {
1819
- switch (g) {
1818
+ function m(w, h, O) {
1819
+ switch (w) {
1820
1820
  case "event":
1821
1821
  c = h;
1822
1822
  break;
@@ -1832,21 +1832,21 @@ function yi(e) {
1832
1832
  new Vt(`Invalid \`retry\` value: "${h}"`, {
1833
1833
  type: "invalid-retry",
1834
1834
  value: h,
1835
- line: $
1835
+ line: O
1836
1836
  })
1837
1837
  );
1838
1838
  break;
1839
1839
  default:
1840
1840
  n(
1841
1841
  new Vt(
1842
- `Unknown field "${g.length > 20 ? `${g.slice(0, 20)}…` : g}"`,
1843
- { type: "unknown-field", field: g, value: h, line: $ }
1842
+ `Unknown field "${w.length > 20 ? `${w.slice(0, 20)}…` : w}"`,
1843
+ { type: "unknown-field", field: w, value: h, line: O }
1844
1844
  )
1845
1845
  );
1846
1846
  break;
1847
1847
  }
1848
1848
  }
1849
- function p() {
1849
+ function y() {
1850
1850
  u.length > 0 && t({
1851
1851
  id: a,
1852
1852
  event: c || void 0,
@@ -1856,12 +1856,12 @@ function yi(e) {
1856
1856
  `) ? u.slice(0, -1) : u
1857
1857
  }), a = void 0, u = "", c = "";
1858
1858
  }
1859
- function I(g = {}) {
1860
- r && g.consume && f(r), o = !0, a = void 0, u = "", c = "", r = "";
1859
+ function I(w = {}) {
1860
+ r && w.consume && f(r), o = !0, a = void 0, u = "", c = "", r = "";
1861
1861
  }
1862
1862
  return { feed: l, reset: I };
1863
1863
  }
1864
- function bi(e) {
1864
+ function gi(e) {
1865
1865
  const t = [];
1866
1866
  let n = "", i = 0;
1867
1867
  for (; i < e.length; ) {
@@ -1921,7 +1921,7 @@ class Jt extends Event {
1921
1921
  return t(Qt(this), n);
1922
1922
  }
1923
1923
  }
1924
- function gi(e) {
1924
+ function wi(e) {
1925
1925
  const t = globalThis.DOMException;
1926
1926
  return typeof t == "function" ? new t(e, "SyntaxError") : new SyntaxError(e);
1927
1927
  }
@@ -1940,69 +1940,69 @@ function Qt(e) {
1940
1940
  }
1941
1941
  var hn = (e) => {
1942
1942
  throw TypeError(e);
1943
- }, Rt = (e, t, n) => t.has(e) || hn("Cannot " + n), S = (e, t, n) => (Rt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), x = (e, t, n) => t.has(e) ? hn("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), _ = (e, t, n, i) => (Rt(e, t, "write to private field"), t.set(e, n), n), ae = (e, t, n) => (Rt(e, t, "access private method"), n), z, ye, ve, He, Xe, Le, ke, We, de, Oe, Ce, $e, Ue, Y, yt, bt, gt, Gt, wt, St, De, It, vt;
1944
- class ee extends EventTarget {
1943
+ }, Rt = (e, t, n) => t.has(e) || hn("Cannot " + n), S = (e, t, n) => (Rt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), x = (e, t, n) => t.has(e) ? hn("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), _ = (e, t, n, i) => (Rt(e, t, "write to private field"), t.set(e, n), n), ce = (e, t, n) => (Rt(e, t, "access private method"), n), V, be, Oe, Ge, Ke, Ne, Ee, Le, he, $e, xe, ke, Me, Z, yt, bt, gt, Gt, wt, St, Ue, It, vt;
1944
+ class ie extends EventTarget {
1945
1945
  constructor(t, n) {
1946
1946
  var i, s;
1947
- super(), x(this, Y), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, x(this, z), x(this, ye), x(this, ve), x(this, He), x(this, Xe), x(this, Le), x(this, ke), x(this, We, null), x(this, de), x(this, Oe), x(this, Ce, null), x(this, $e, null), x(this, Ue, null), x(this, bt, async (r) => {
1947
+ super(), x(this, Z), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, x(this, V), x(this, be), x(this, Oe), x(this, Ge), x(this, Ke), x(this, Ne), x(this, Ee), x(this, Le, null), x(this, he), x(this, $e), x(this, xe, null), x(this, ke, null), x(this, Me, null), x(this, bt, async (r) => {
1948
1948
  var o;
1949
- S(this, Oe).reset();
1949
+ S(this, $e).reset();
1950
1950
  const { body: a, redirected: u, status: c, headers: l } = r;
1951
1951
  if (c === 204) {
1952
- ae(this, Y, De).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
1952
+ ce(this, Z, Ue).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
1953
1953
  return;
1954
1954
  }
1955
- if (u ? _(this, ve, new URL(r.url)) : _(this, ve, void 0), c !== 200) {
1956
- ae(this, Y, De).call(this, `Non-200 status code (${c})`, c);
1955
+ if (u ? _(this, Oe, new URL(r.url)) : _(this, Oe, void 0), c !== 200) {
1956
+ ce(this, Z, Ue).call(this, `Non-200 status code (${c})`, c);
1957
1957
  return;
1958
1958
  }
1959
1959
  if (!(l.get("content-type") || "").startsWith("text/event-stream")) {
1960
- ae(this, Y, De).call(this, 'Invalid content type, expected "text/event-stream"', c);
1960
+ ce(this, Z, Ue).call(this, 'Invalid content type, expected "text/event-stream"', c);
1961
1961
  return;
1962
1962
  }
1963
- if (S(this, z) === this.CLOSED)
1963
+ if (S(this, V) === this.CLOSED)
1964
1964
  return;
1965
- _(this, z, this.OPEN);
1965
+ _(this, V, this.OPEN);
1966
1966
  const f = new Event("open");
1967
- if ((o = S(this, Ue)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
1968
- ae(this, Y, De).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
1967
+ if ((o = S(this, Me)) == null || o.call(this, f), this.dispatchEvent(f), typeof a != "object" || !a || !("getReader" in a)) {
1968
+ ce(this, Z, Ue).call(this, "Invalid response body, expected a web ReadableStream", c), this.close();
1969
1969
  return;
1970
1970
  }
1971
- const m = new TextDecoder(), p = a.getReader();
1971
+ const m = new TextDecoder(), y = a.getReader();
1972
1972
  let I = !0;
1973
1973
  do {
1974
- const { done: g, value: h } = await p.read();
1975
- h && S(this, Oe).feed(m.decode(h, { stream: !g })), g && (I = !1, S(this, Oe).reset(), ae(this, Y, It).call(this));
1974
+ const { done: w, value: h } = await y.read();
1975
+ h && S(this, $e).feed(m.decode(h, { stream: !w })), w && (I = !1, S(this, $e).reset(), ce(this, Z, It).call(this));
1976
1976
  } while (I);
1977
1977
  }), x(this, gt, (r) => {
1978
- _(this, de, void 0), !(r.name === "AbortError" || r.type === "aborted") && ae(this, Y, It).call(this, mt(r));
1978
+ _(this, he, void 0), !(r.name === "AbortError" || r.type === "aborted") && ce(this, Z, It).call(this, mt(r));
1979
1979
  }), x(this, wt, (r) => {
1980
- typeof r.id == "string" && _(this, We, r.id);
1980
+ typeof r.id == "string" && _(this, Le, r.id);
1981
1981
  const o = new MessageEvent(r.event || "message", {
1982
1982
  data: r.data,
1983
- origin: S(this, ve) ? S(this, ve).origin : S(this, ye).origin,
1983
+ origin: S(this, Oe) ? S(this, Oe).origin : S(this, be).origin,
1984
1984
  lastEventId: r.id || ""
1985
1985
  });
1986
- S(this, $e) && (!r.event || r.event === "message") && S(this, $e).call(this, o), this.dispatchEvent(o);
1986
+ S(this, ke) && (!r.event || r.event === "message") && S(this, ke).call(this, o), this.dispatchEvent(o);
1987
1987
  }), x(this, St, (r) => {
1988
- _(this, Le, r);
1988
+ _(this, Ne, r);
1989
1989
  }), x(this, vt, () => {
1990
- _(this, ke, void 0), S(this, z) === this.CONNECTING && ae(this, Y, yt).call(this);
1990
+ _(this, Ee, void 0), S(this, V) === this.CONNECTING && ce(this, Z, yt).call(this);
1991
1991
  });
1992
1992
  try {
1993
1993
  if (t instanceof URL)
1994
- _(this, ye, t);
1994
+ _(this, be, t);
1995
1995
  else if (typeof t == "string")
1996
- _(this, ye, new URL(t, wi()));
1996
+ _(this, be, new URL(t, Si()));
1997
1997
  else
1998
1998
  throw new Error("Invalid URL");
1999
1999
  } catch {
2000
- throw gi("An invalid or illegal string was specified");
2000
+ throw wi("An invalid or illegal string was specified");
2001
2001
  }
2002
- _(this, Oe, yi({
2002
+ _(this, $e, bi({
2003
2003
  onEvent: S(this, wt),
2004
2004
  onRetry: S(this, St)
2005
- })), _(this, z, this.CONNECTING), _(this, Le, 3e3), _(this, Xe, (i = n == null ? void 0 : n.fetch) != null ? i : globalThis.fetch), _(this, He, (s = n == null ? void 0 : n.withCredentials) != null ? s : !1), ae(this, Y, yt).call(this);
2005
+ })), _(this, V, this.CONNECTING), _(this, Ne, 3e3), _(this, Ke, (i = n == null ? void 0 : n.fetch) != null ? i : globalThis.fetch), _(this, Ge, (s = n == null ? void 0 : n.withCredentials) != null ? s : !1), ce(this, Z, yt).call(this);
2006
2006
  }
2007
2007
  /**
2008
2008
  * Returns the state of this EventSource object's connection. It can have the values described below.
@@ -2015,7 +2015,7 @@ class ee extends EventTarget {
2015
2015
  * @public
2016
2016
  */
2017
2017
  get readyState() {
2018
- return S(this, z);
2018
+ return S(this, V);
2019
2019
  }
2020
2020
  /**
2021
2021
  * Returns the URL providing the event stream.
@@ -2025,7 +2025,7 @@ class ee extends EventTarget {
2025
2025
  * @public
2026
2026
  */
2027
2027
  get url() {
2028
- return S(this, ye).href;
2028
+ return S(this, be).href;
2029
2029
  }
2030
2030
  /**
2031
2031
  * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
@@ -2033,28 +2033,28 @@ class ee extends EventTarget {
2033
2033
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
2034
2034
  */
2035
2035
  get withCredentials() {
2036
- return S(this, He);
2036
+ return S(this, Ge);
2037
2037
  }
2038
2038
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
2039
2039
  get onerror() {
2040
- return S(this, Ce);
2040
+ return S(this, xe);
2041
2041
  }
2042
2042
  set onerror(t) {
2043
- _(this, Ce, t);
2043
+ _(this, xe, t);
2044
2044
  }
2045
2045
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
2046
2046
  get onmessage() {
2047
- return S(this, $e);
2047
+ return S(this, ke);
2048
2048
  }
2049
2049
  set onmessage(t) {
2050
- _(this, $e, t);
2050
+ _(this, ke, t);
2051
2051
  }
2052
2052
  /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
2053
2053
  get onopen() {
2054
- return S(this, Ue);
2054
+ return S(this, Me);
2055
2055
  }
2056
2056
  set onopen(t) {
2057
- _(this, Ue, t);
2057
+ _(this, Me, t);
2058
2058
  }
2059
2059
  addEventListener(t, n, i) {
2060
2060
  const s = n;
@@ -2072,16 +2072,16 @@ class ee extends EventTarget {
2072
2072
  * @public
2073
2073
  */
2074
2074
  close() {
2075
- S(this, ke) && clearTimeout(S(this, ke)), S(this, z) !== this.CLOSED && (S(this, de) && S(this, de).abort(), _(this, z, this.CLOSED), _(this, de, void 0));
2075
+ S(this, Ee) && clearTimeout(S(this, Ee)), S(this, V) !== this.CLOSED && (S(this, he) && S(this, he).abort(), _(this, V, this.CLOSED), _(this, he, void 0));
2076
2076
  }
2077
2077
  }
2078
- z = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), Oe = /* @__PURE__ */ new WeakMap(), Ce = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), Y = /* @__PURE__ */ new WeakSet(), /**
2078
+ V = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), Oe = /* @__PURE__ */ new WeakMap(), Ge = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), Ne = /* @__PURE__ */ new WeakMap(), Ee = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap(), he = /* @__PURE__ */ new WeakMap(), $e = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap(), Me = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakSet(), /**
2079
2079
  * Connect to the given URL and start receiving events
2080
2080
  *
2081
2081
  * @internal
2082
2082
  */
2083
2083
  yt = function() {
2084
- _(this, z, this.CONNECTING), _(this, de, new AbortController()), S(this, Xe)(S(this, ye), ae(this, Y, Gt).call(this)).then(S(this, bt)).catch(S(this, gt));
2084
+ _(this, V, this.CONNECTING), _(this, he, new AbortController()), S(this, Ke)(S(this, be), ce(this, Z, Gt).call(this)).then(S(this, bt)).catch(S(this, gt));
2085
2085
  }, bt = /* @__PURE__ */ new WeakMap(), gt = /* @__PURE__ */ new WeakMap(), /**
2086
2086
  * Get request options for the `fetch()` request
2087
2087
  *
@@ -2095,9 +2095,9 @@ Gt = function() {
2095
2095
  // [spec] …will have their mode set to "cors"…
2096
2096
  mode: "cors",
2097
2097
  redirect: "follow",
2098
- headers: { Accept: "text/event-stream", ...S(this, We) ? { "Last-Event-ID": S(this, We) } : void 0 },
2098
+ headers: { Accept: "text/event-stream", ...S(this, Le) ? { "Last-Event-ID": S(this, Le) } : void 0 },
2099
2099
  cache: "no-store",
2100
- signal: (e = S(this, de)) == null ? void 0 : e.signal
2100
+ signal: (e = S(this, he)) == null ? void 0 : e.signal
2101
2101
  };
2102
2102
  return "window" in globalThis && (t.credentials = this.withCredentials ? "include" : "same-origin"), t;
2103
2103
  }, wt = /* @__PURE__ */ new WeakMap(), St = /* @__PURE__ */ new WeakMap(), /**
@@ -2107,11 +2107,11 @@ Gt = function() {
2107
2107
  * @param code - The HTTP status code, if available
2108
2108
  * @internal
2109
2109
  */
2110
- De = function(e, t) {
2110
+ Ue = function(e, t) {
2111
2111
  var n;
2112
- S(this, z) !== this.CLOSED && _(this, z, this.CLOSED);
2112
+ S(this, V) !== this.CLOSED && _(this, V, this.CLOSED);
2113
2113
  const i = new Jt("error", { code: t, message: e });
2114
- (n = S(this, Ce)) == null || n.call(this, i), this.dispatchEvent(i);
2114
+ (n = S(this, xe)) == null || n.call(this, i), this.dispatchEvent(i);
2115
2115
  }, /**
2116
2116
  * Schedules a reconnection attempt against the EventSource endpoint.
2117
2117
  *
@@ -2121,32 +2121,32 @@ De = function(e, t) {
2121
2121
  */
2122
2122
  It = function(e, t) {
2123
2123
  var n;
2124
- if (S(this, z) === this.CLOSED)
2124
+ if (S(this, V) === this.CLOSED)
2125
2125
  return;
2126
- _(this, z, this.CONNECTING);
2126
+ _(this, V, this.CONNECTING);
2127
2127
  const i = new Jt("error", { code: t, message: e });
2128
- (n = S(this, Ce)) == null || n.call(this, i), this.dispatchEvent(i), _(this, ke, setTimeout(S(this, vt), S(this, Le)));
2128
+ (n = S(this, xe)) == null || n.call(this, i), this.dispatchEvent(i), _(this, Ee, setTimeout(S(this, vt), S(this, Ne)));
2129
2129
  }, vt = /* @__PURE__ */ new WeakMap(), /**
2130
2130
  * ReadyState representing an EventSource currently trying to connect
2131
2131
  *
2132
2132
  * @public
2133
2133
  */
2134
- ee.CONNECTING = 0, /**
2134
+ ie.CONNECTING = 0, /**
2135
2135
  * ReadyState representing an EventSource connection that is open (eg connected)
2136
2136
  *
2137
2137
  * @public
2138
2138
  */
2139
- ee.OPEN = 1, /**
2139
+ ie.OPEN = 1, /**
2140
2140
  * ReadyState representing an EventSource connection that is closed (eg disconnected)
2141
2141
  *
2142
2142
  * @public
2143
2143
  */
2144
- ee.CLOSED = 2;
2145
- function wi() {
2144
+ ie.CLOSED = 2;
2145
+ function Si() {
2146
2146
  const e = "document" in globalThis ? globalThis.document : void 0;
2147
2147
  return e && typeof e == "object" && "baseURI" in e && typeof e.baseURI == "string" ? e.baseURI : void 0;
2148
2148
  }
2149
- function Si(e, t, n, i) {
2149
+ function Ii(e, t, n, i) {
2150
2150
  let s = null, r = !1;
2151
2151
  const o = [], a = (f) => {
2152
2152
  o.push(f), o.length > 100 && o.shift(), s && (s(), s = null);
@@ -2163,8 +2163,8 @@ function Si(e, t, n, i) {
2163
2163
  const f = o.shift();
2164
2164
  if (f)
2165
2165
  return { value: f, done: !1 };
2166
- await new Promise((p) => {
2167
- s = p;
2166
+ await new Promise((y) => {
2167
+ s = y;
2168
2168
  });
2169
2169
  }
2170
2170
  },
@@ -2177,7 +2177,7 @@ function Si(e, t, n, i) {
2177
2177
  }
2178
2178
  };
2179
2179
  }
2180
- function fe(e) {
2180
+ function le(e) {
2181
2181
  switch (e.readyState) {
2182
2182
  case e.CLOSED:
2183
2183
  return "closed";
@@ -2189,7 +2189,7 @@ function fe(e) {
2189
2189
  return "connecting";
2190
2190
  }
2191
2191
  }
2192
- function Ii(e) {
2192
+ function vi(e) {
2193
2193
  let t = null;
2194
2194
  return {
2195
2195
  ...e,
@@ -2214,23 +2214,23 @@ function Ht(e) {
2214
2214
  };
2215
2215
  return t;
2216
2216
  }
2217
- function vi(e, t, n) {
2217
+ function Oi(e, t, n) {
2218
2218
  let i, s = !1;
2219
- const r = Ee(), o = new ee(`${n.apiURI}/admin/subscribe-query?local_connection_id=${r}`, {
2220
- fetch(h, $) {
2219
+ const r = _e(), o = new ie(`${n.apiURI}/admin/subscribe-query?local_connection_id=${r}`, {
2220
+ fetch(h, O) {
2221
2221
  return i = null, fetch(h, {
2222
- ...$,
2222
+ ...O,
2223
2223
  method: "POST",
2224
2224
  headers: n.headers,
2225
2225
  body: JSON.stringify({
2226
2226
  query: e,
2227
2227
  "inference?": n.inference,
2228
2228
  versions: {
2229
- "@instantdb/admin": Re,
2230
- "@instantdb/core": Re
2229
+ "@instantdb/admin": Ae,
2230
+ "@instantdb/core": Ae
2231
2231
  }
2232
2232
  })
2233
- }).then((w) => (w.ok || (i = Ii(w)), w));
2233
+ }).then((b) => (b.ok || (i = vi(b)), b));
2234
2234
  }
2235
2235
  }), a = [], u = [], c = (h) => {
2236
2236
  a.push(h);
@@ -2241,50 +2241,50 @@ function vi(e, t, n) {
2241
2241
  };
2242
2242
  t && c(t);
2243
2243
  let m = null;
2244
- function p(h) {
2244
+ function y(h) {
2245
2245
  if (!s)
2246
- for (const $ of a)
2246
+ for (const O of a)
2247
2247
  try {
2248
- $(h);
2249
- } catch (w) {
2250
- console.error("Error in subscribeQuery callback", w);
2248
+ O(h);
2249
+ } catch (b) {
2250
+ console.error("Error in subscribeQuery callback", b);
2251
2251
  }
2252
2252
  }
2253
2253
  function I(h) {
2254
- var $, w;
2254
+ var O, b;
2255
2255
  switch (h.op) {
2256
2256
  case "sse-init": {
2257
- const O = h["machine-id"], ne = h["session-id"];
2258
- m = { machineId: O, sessionId: ne };
2257
+ const $ = h["machine-id"], K = h["session-id"];
2258
+ m = { machineId: $, sessionId: K };
2259
2259
  break;
2260
2260
  }
2261
2261
  case "add-query-ok": {
2262
- p({
2262
+ y({
2263
2263
  type: "ok",
2264
2264
  data: h.result,
2265
- pageInfo: Ht(($ = h["result-meta"]) == null ? void 0 : $["page-info"]),
2265
+ pageInfo: Ht((O = h["result-meta"]) == null ? void 0 : O["page-info"]),
2266
2266
  sessionInfo: m
2267
2267
  });
2268
2268
  break;
2269
2269
  }
2270
2270
  case "refresh-ok": {
2271
- h.computations.length && p({
2271
+ h.computations.length && y({
2272
2272
  type: "ok",
2273
2273
  data: h.computations[0]["instaql-result"],
2274
- pageInfo: Ht((w = h.computations[0]["result-meta"]) == null ? void 0 : w["page-info"]),
2274
+ pageInfo: Ht((b = h.computations[0]["result-meta"]) == null ? void 0 : b["page-info"]),
2275
2275
  sessionInfo: m
2276
2276
  });
2277
2277
  break;
2278
2278
  }
2279
2279
  case "error": {
2280
- p({
2280
+ y({
2281
2281
  type: "error",
2282
- error: new Se({ body: h, status: h.status }),
2282
+ error: new Ie({ body: h, status: h.status }),
2283
2283
  get readyState() {
2284
- return fe(o);
2284
+ return le(o);
2285
2285
  },
2286
2286
  get isClosed() {
2287
- return fe(o) === "closed";
2287
+ return le(o) === "closed";
2288
2288
  },
2289
2289
  sessionInfo: m
2290
2290
  });
@@ -2294,32 +2294,32 @@ function vi(e, t, n) {
2294
2294
  }
2295
2295
  return o.onerror = (h) => {
2296
2296
  if (i)
2297
- i.text().then(($) => {
2298
- let w = { type: void 0, message: $ };
2297
+ i.text().then((O) => {
2298
+ let b = { type: void 0, message: O };
2299
2299
  try {
2300
- w = JSON.parse($);
2300
+ b = JSON.parse(O);
2301
2301
  } catch {
2302
2302
  }
2303
- p({
2303
+ y({
2304
2304
  type: "error",
2305
- error: new Se({
2305
+ error: new Ie({
2306
2306
  status: i.status,
2307
- body: w
2307
+ body: b
2308
2308
  }),
2309
2309
  get readyState() {
2310
- return fe(o);
2310
+ return le(o);
2311
2311
  },
2312
2312
  get isClosed() {
2313
- return fe(o) === "closed";
2313
+ return le(o) === "closed";
2314
2314
  },
2315
2315
  sessionInfo: m
2316
2316
  });
2317
2317
  });
2318
2318
  else {
2319
- const $ = () => {
2320
- p({
2319
+ const O = () => {
2320
+ y({
2321
2321
  type: "error",
2322
- error: new Se({
2322
+ error: new Ie({
2323
2323
  status: h.code || 500,
2324
2324
  body: {
2325
2325
  type: void 0,
@@ -2327,20 +2327,20 @@ function vi(e, t, n) {
2327
2327
  }
2328
2328
  }),
2329
2329
  get readyState() {
2330
- return fe(o);
2330
+ return le(o);
2331
2331
  },
2332
2332
  get isClosed() {
2333
- return fe(o) === "closed";
2333
+ return le(o) === "closed";
2334
2334
  },
2335
2335
  sessionInfo: m
2336
2336
  });
2337
2337
  };
2338
- if (o.readyState === ee.CLOSED) {
2339
- $();
2338
+ if (o.readyState === ie.CLOSED) {
2339
+ O();
2340
2340
  return;
2341
2341
  }
2342
2342
  setTimeout(() => {
2343
- o.readyState !== ee.OPEN && $();
2343
+ o.readyState !== ie.OPEN && O();
2344
2344
  }, 5e3);
2345
2345
  }
2346
2346
  }, o.onmessage = (h) => {
@@ -2351,8 +2351,8 @@ function vi(e, t, n) {
2351
2351
  for (const h of u)
2352
2352
  try {
2353
2353
  h();
2354
- } catch ($) {
2355
- console.error("Error in onClose callback", $);
2354
+ } catch (O) {
2355
+ console.error("Error in onClose callback", O);
2356
2356
  }
2357
2357
  o.close();
2358
2358
  },
@@ -2363,31 +2363,31 @@ function vi(e, t, n) {
2363
2363
  return m;
2364
2364
  },
2365
2365
  get readyState() {
2366
- return fe(o);
2366
+ return le(o);
2367
2367
  },
2368
2368
  get isClosed() {
2369
- return fe(o) === "closed";
2369
+ return le(o) === "closed";
2370
2370
  },
2371
- [Symbol.asyncIterator]: Si.bind(this, c, f, l, () => 1)
2371
+ [Symbol.asyncIterator]: Ii.bind(this, c, f, l, () => 1)
2372
2372
  };
2373
2373
  }
2374
- var ue = {};
2375
- Object.defineProperty(ue, "__esModule", { value: !0 });
2376
- var Oi = ue.parseCookie = yn;
2377
- ue.parse = yn;
2378
- ue.stringifyCookie = xi;
2379
- ue.stringifySetCookie = nt;
2380
- ue.serialize = nt;
2381
- ue.parseSetCookie = Ti;
2382
- ue.stringifySetCookie = nt;
2383
- ue.serialize = nt;
2384
- const pn = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, mn = /^[\u0021-\u003A\u003C-\u007E]*$/, $i = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, ki = /^[\u0020-\u003A\u003D-\u007E]*$/, Ei = /^-?\d+$/, _i = Object.prototype.toString, Ci = /* @__PURE__ */ (() => {
2374
+ var fe = {};
2375
+ Object.defineProperty(fe, "__esModule", { value: !0 });
2376
+ var $i = fe.parseCookie = yn;
2377
+ fe.parse = yn;
2378
+ fe.stringifyCookie = Ti;
2379
+ fe.stringifySetCookie = tt;
2380
+ fe.serialize = tt;
2381
+ fe.parseSetCookie = Ri;
2382
+ fe.stringifySetCookie = tt;
2383
+ fe.serialize = tt;
2384
+ const pn = /^[\u0021-\u003A\u003C\u003E-\u007E]+$/, mn = /^[\u0021-\u003A\u003C-\u007E]*$/, ki = /^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i, Ei = /^[\u0020-\u003A\u003D-\u007E]*$/, _i = /^-?\d+$/, Ci = Object.prototype.toString, xi = /* @__PURE__ */ (() => {
2385
2385
  const e = function() {
2386
2386
  };
2387
2387
  return e.prototype = /* @__PURE__ */ Object.create(null), e;
2388
2388
  })();
2389
2389
  function yn(e, t) {
2390
- const n = new Ci(), i = e.length;
2390
+ const n = new xi(), i = e.length;
2391
2391
  if (i < 2)
2392
2392
  return n;
2393
2393
  const s = (t == null ? void 0 : t.decode) || bn;
@@ -2401,12 +2401,12 @@ function yn(e, t) {
2401
2401
  r = e.lastIndexOf(";", o - 1) + 1;
2402
2402
  continue;
2403
2403
  }
2404
- const u = le(e, r, o);
2405
- n[u] === void 0 && (n[u] = s(le(e, o + 1, a))), r = a + 1;
2404
+ const u = de(e, r, o);
2405
+ n[u] === void 0 && (n[u] = s(de(e, o + 1, a))), r = a + 1;
2406
2406
  } while (r < i);
2407
2407
  return n;
2408
2408
  }
2409
- function xi(e, t) {
2409
+ function Ti(e, t) {
2410
2410
  const n = (t == null ? void 0 : t.encode) || encodeURIComponent, i = [];
2411
2411
  for (const s of Object.keys(e)) {
2412
2412
  const r = e[s];
@@ -2421,7 +2421,7 @@ function xi(e, t) {
2421
2421
  }
2422
2422
  return i.join("; ");
2423
2423
  }
2424
- function nt(e, t, n) {
2424
+ function tt(e, t, n) {
2425
2425
  const i = typeof e == "object" ? e : { ...n, name: e, value: String(t) }, s = typeof t == "object" ? t : n, r = (s == null ? void 0 : s.encode) || encodeURIComponent;
2426
2426
  if (!pn.test(i.name))
2427
2427
  throw new TypeError(`argument name is invalid: ${i.name}`);
@@ -2435,17 +2435,17 @@ function nt(e, t, n) {
2435
2435
  a += "; Max-Age=" + i.maxAge;
2436
2436
  }
2437
2437
  if (i.domain) {
2438
- if (!$i.test(i.domain))
2438
+ if (!ki.test(i.domain))
2439
2439
  throw new TypeError(`option domain is invalid: ${i.domain}`);
2440
2440
  a += "; Domain=" + i.domain;
2441
2441
  }
2442
2442
  if (i.path) {
2443
- if (!ki.test(i.path))
2443
+ if (!Ei.test(i.path))
2444
2444
  throw new TypeError(`option path is invalid: ${i.path}`);
2445
2445
  a += "; Path=" + i.path;
2446
2446
  }
2447
2447
  if (i.expires) {
2448
- if (!Ri(i.expires) || !Number.isFinite(i.expires.valueOf()))
2448
+ if (!Ai(i.expires) || !Number.isFinite(i.expires.valueOf()))
2449
2449
  throw new TypeError(`option expires is invalid: ${i.expires}`);
2450
2450
  a += "; Expires=" + i.expires.toUTCString();
2451
2451
  }
@@ -2480,14 +2480,14 @@ function nt(e, t, n) {
2480
2480
  }
2481
2481
  return a;
2482
2482
  }
2483
- function Ti(e, t) {
2484
- const n = (t == null ? void 0 : t.decode) || bn, i = e.length, s = Ot(e, 0, i), r = $t(e, 0, s), o = r === -1 ? { name: "", value: n(le(e, 0, s)) } : {
2485
- name: le(e, 0, r),
2486
- value: n(le(e, r + 1, s))
2483
+ function Ri(e, t) {
2484
+ const n = (t == null ? void 0 : t.decode) || bn, i = e.length, s = Ot(e, 0, i), r = $t(e, 0, s), o = r === -1 ? { name: "", value: n(de(e, 0, s)) } : {
2485
+ name: de(e, 0, r),
2486
+ value: n(de(e, r + 1, s))
2487
2487
  };
2488
2488
  let a = s + 1;
2489
2489
  for (; a < i; ) {
2490
- const u = Ot(e, a, i), c = $t(e, a, u), l = c === -1 ? le(e, a, u) : le(e, a, c), f = c === -1 ? void 0 : le(e, c + 1, u);
2490
+ const u = Ot(e, a, i), c = $t(e, a, u), l = c === -1 ? de(e, a, u) : de(e, a, c), f = c === -1 ? void 0 : de(e, c + 1, u);
2491
2491
  switch (l.toLowerCase()) {
2492
2492
  case "httponly":
2493
2493
  o.httpOnly = !0;
@@ -2505,7 +2505,7 @@ function Ti(e, t) {
2505
2505
  o.path = f;
2506
2506
  break;
2507
2507
  case "max-age":
2508
- f && Ei.test(f) && (o.maxAge = Number(f));
2508
+ f && _i.test(f) && (o.maxAge = Number(f));
2509
2509
  break;
2510
2510
  case "expires":
2511
2511
  if (!f)
@@ -2516,8 +2516,8 @@ function Ti(e, t) {
2516
2516
  case "priority":
2517
2517
  if (!f)
2518
2518
  break;
2519
- const p = f.toLowerCase();
2520
- (p === "low" || p === "medium" || p === "high") && (o.priority = p);
2519
+ const y = f.toLowerCase();
2520
+ (y === "low" || y === "medium" || y === "high") && (o.priority = y);
2521
2521
  break;
2522
2522
  case "samesite":
2523
2523
  if (!f)
@@ -2538,7 +2538,7 @@ function $t(e, t, n) {
2538
2538
  const i = e.indexOf("=", t);
2539
2539
  return i < n ? i : -1;
2540
2540
  }
2541
- function le(e, t, n) {
2541
+ function de(e, t, n) {
2542
2542
  let i = t, s = n;
2543
2543
  do {
2544
2544
  const r = e.charCodeAt(i);
@@ -2562,64 +2562,64 @@ function bn(e) {
2562
2562
  return e;
2563
2563
  }
2564
2564
  }
2565
- function Ri(e) {
2566
- return _i.call(e) === "[object Date]";
2567
- }
2568
2565
  function Ai(e) {
2566
+ return Ci.call(e) === "[object Date]";
2567
+ }
2568
+ function Pi(e) {
2569
2569
  return { ...{
2570
2570
  apiURI: "https://api.instantdb.com"
2571
2571
  }, ...e };
2572
2572
  }
2573
- function Pi(e, t) {
2573
+ function ji(e, t) {
2574
2574
  return "email" in t ? e["as-email"] = t.email : "token" in t ? e["as-token"] = t.token : "guest" in t && (e["as-guest"] = "true"), e;
2575
2575
  }
2576
- function ji(e, t) {
2576
+ function Mi(e, t) {
2577
2577
  if (!(t && ("token" in t || "guest" in t)) && !e.adminToken)
2578
2578
  throw t && "email" in t ? new Error("Admin token required. To impersonate users with an email you must pass `adminToken` to `init`.") : new Error("Admin token required. To run this operation pass `adminToken` to `init`, or use `db.asUser`.");
2579
2579
  }
2580
2580
  function C(e, t) {
2581
- ji(e, t);
2581
+ Mi(e, t);
2582
2582
  const { adminToken: n, appId: i } = e, s = {
2583
2583
  "content-type": "application/json",
2584
2584
  "app-id": i
2585
2585
  };
2586
- return n && (s.authorization = `Bearer ${n}`), t ? Pi(s, t) : s;
2586
+ return n && (s.authorization = `Bearer ${n}`), t ? ji(s, t) : s;
2587
2587
  }
2588
- function Mi() {
2588
+ function Ui() {
2589
2589
  return (
2590
2590
  // NextJS 13 onwards added a `__nextPatched` property to the fetch function
2591
2591
  fetch.__nextPatched && // NextJS 15 onwards _also_ added a global `next-patch` symbol.
2592
2592
  !globalThis[Symbol.for("next-patch")]
2593
2593
  );
2594
2594
  }
2595
- function Ui() {
2596
- return Mi() ? { cache: "no-store" } : {};
2595
+ function Di() {
2596
+ return Ui() ? { cache: "no-store" } : {};
2597
2597
  }
2598
- async function Di(e, t) {
2598
+ async function Ni(e, t) {
2599
2599
  const n = await t.text();
2600
2600
  try {
2601
2601
  const i = JSON.parse(n);
2602
- return e(new Se({ status: t.status, body: i }));
2602
+ return e(new Ie({ status: t.status, body: i }));
2603
2603
  } catch {
2604
- return e(new Se({
2604
+ return e(new Ie({
2605
2605
  status: t.status,
2606
2606
  body: { type: void 0, message: n }
2607
2607
  }));
2608
2608
  }
2609
2609
  }
2610
2610
  async function R(e, t) {
2611
- const n = Ui(), i = {
2611
+ const n = Di(), i = {
2612
2612
  ...(t == null ? void 0 : t.headers) || {},
2613
- "Instant-Admin-Version": Re,
2614
- "Instant-Core-Version": Re
2613
+ "Instant-Admin-Version": Ae,
2614
+ "Instant-Core-Version": Ae
2615
2615
  }, s = await fetch(e, { ...n, ...t, headers: i });
2616
2616
  if (s.status === 200) {
2617
2617
  const r = await s.json();
2618
2618
  return Promise.resolve(r);
2619
2619
  }
2620
- return Di((r) => Promise.reject(r), s);
2620
+ return Ni((r) => Promise.reject(r), s);
2621
2621
  }
2622
- function Ni(e) {
2622
+ function Li(e) {
2623
2623
  var t, n, gn;
2624
2624
  return t = class {
2625
2625
  constructor(r) {
@@ -2653,7 +2653,7 @@ function Ni(e) {
2653
2653
  this.source.close();
2654
2654
  }
2655
2655
  }, n = new WeakSet(), gn = function(r) {
2656
- return new ee(r, {
2656
+ return new ie(r, {
2657
2657
  fetch(a, u) {
2658
2658
  return fetch(a, {
2659
2659
  ...u,
@@ -2662,18 +2662,18 @@ function Ni(e) {
2662
2662
  body: JSON.stringify({
2663
2663
  "inference?": e.inference,
2664
2664
  versions: {
2665
- "@instantdb/admin": Re,
2666
- "@instantdb/core": Re
2665
+ "@instantdb/admin": Ae,
2666
+ "@instantdb/core": Ae
2667
2667
  }
2668
2668
  })
2669
2669
  });
2670
2670
  }
2671
2671
  });
2672
- }, d(t, "OPEN", ee.OPEN), d(t, "CONNECTING", ee.CONNECTING), d(t, "CLOSED", ee.CLOSED), t;
2672
+ }, d(t, "OPEN", ie.OPEN), d(t, "CONNECTING", ie.CONNECTING), d(t, "CLOSED", ie.CLOSED), t;
2673
2673
  }
2674
- function Li(e) {
2674
+ function Wi(e) {
2675
2675
  var n, i;
2676
- (!e.appId || !Te(e.appId)) && console.warn("warning: Instant Admin DB must be initialized with a valid appId. Received: " + JSON.stringify(e.appId));
2676
+ (!e.appId || !Re(e.appId)) && console.warn("warning: Instant Admin DB must be initialized with a valid appId. Received: " + JSON.stringify(e.appId));
2677
2677
  const t = {
2678
2678
  ...e,
2679
2679
  appId: (n = e.appId) == null ? void 0 : n.trim(),
@@ -2683,9 +2683,9 @@ function Li(e) {
2683
2683
  return new kt(t);
2684
2684
  }
2685
2685
  function Bt(e) {
2686
- return (Array.isArray(e) ? e : [e]).flatMap(Xn);
2686
+ return (Array.isArray(e) ? e : [e]).flatMap(Yn);
2687
2687
  }
2688
- class Wi {
2688
+ class Fi {
2689
2689
  constructor(t) {
2690
2690
  d(this, "config");
2691
2691
  this.config = t;
@@ -2697,7 +2697,7 @@ class Wi {
2697
2697
  })).sessions || {};
2698
2698
  }
2699
2699
  }
2700
- class Fi {
2700
+ class zi {
2701
2701
  constructor(t) {
2702
2702
  d(this, "config");
2703
2703
  /**
@@ -2825,7 +2825,7 @@ class Fi {
2825
2825
  * @param opts Allow disabling validation of refresh token
2826
2826
  */
2827
2827
  d(this, "getUserFromRequest", async (t, n) => {
2828
- const i = t.headers.get("cookie") || "", s = Oi(i), r = "instant_user_" + this.config.appId;
2828
+ const i = t.headers.get("cookie") || "", s = $i(i), r = "instant_user_" + this.config.appId;
2829
2829
  if (!s[r])
2830
2830
  return null;
2831
2831
  const o = s[r], a = JSON.parse(o);
@@ -2850,7 +2850,7 @@ class Fi {
2850
2850
  });
2851
2851
  }
2852
2852
  }
2853
- const qt = (e) => e && typeof e == "object" && typeof e.pipe == "function" && typeof e.read == "function", zi = (e) => e && typeof e.getReader == "function";
2853
+ const qt = (e) => e && typeof e == "object" && typeof e.pipe == "function" && typeof e.read == "function", Vi = (e) => e && typeof e.getReader == "function";
2854
2854
  class Kt {
2855
2855
  constructor(t, n) {
2856
2856
  d(this, "config");
@@ -2870,7 +2870,7 @@ class Kt {
2870
2870
  };
2871
2871
  i.contentDisposition && (s["content-disposition"] = i.contentDisposition), delete s["content-type"], i.contentType && (s["content-type"] = i.contentType);
2872
2872
  let r;
2873
- if (qt(n) && (r = "half"), qt(n) || zi(n)) {
2873
+ if (qt(n) && (r = "half"), qt(n) || Vi(n)) {
2874
2874
  if (!i.fileSize)
2875
2875
  throw new Error("fileSize is required in metadata when uploading streams");
2876
2876
  s["content-length"] = i.fileSize.toString();
@@ -2973,10 +2973,10 @@ class Kt {
2973
2973
  this.config = t, this.impersonationOpts = n;
2974
2974
  }
2975
2975
  }
2976
- var xe;
2977
- class Vi {
2976
+ var Te;
2977
+ class Ji {
2978
2978
  constructor(t) {
2979
- G(this, xe);
2979
+ G(this, Te);
2980
2980
  /**
2981
2981
  * Creates a new ReadableStream for the given clientId.
2982
2982
  *
@@ -2986,7 +2986,7 @@ class Vi {
2986
2986
  * console.log(chunk);
2987
2987
  * }
2988
2988
  */
2989
- d(this, "createReadStream", (t) => b(this, xe).call(this).createReadStream(t));
2989
+ d(this, "createReadStream", (t) => g(this, Te).call(this).createReadStream(t));
2990
2990
  /**
2991
2991
  * Creates a new WritableStream for the given clientId.
2992
2992
  *
@@ -2996,12 +2996,12 @@ class Vi {
2996
2996
  * writer.write('Hello world');
2997
2997
  * writer.close();
2998
2998
  */
2999
- d(this, "createWriteStream", (t) => b(this, xe).call(this).createWriteStream(t));
3000
- oe(this, xe, t);
2999
+ d(this, "createWriteStream", (t) => g(this, Te).call(this).createWriteStream(t));
3000
+ ae(this, Te, t);
3001
3001
  }
3002
3002
  }
3003
- xe = new WeakMap();
3004
- function Ji(e) {
3003
+ Te = new WeakMap();
3004
+ function Qi(e) {
3005
3005
  return {
3006
3006
  info: e ? (...t) => console.info(...t) : () => {
3007
3007
  },
@@ -3011,7 +3011,7 @@ function Ji(e) {
3011
3011
  }
3012
3012
  };
3013
3013
  }
3014
- var U, ge, N, L, A, wn, Be, Sn, In, vn, Ye, Ze, et, Et, On, tt;
3014
+ var M, we, N, L, A, wn, He, Sn, In, vn, Xe, Ye, Ze, Et, On, et;
3015
3015
  const At = class At {
3016
3016
  constructor(t) {
3017
3017
  G(this, A);
@@ -3021,8 +3021,8 @@ const At = class At {
3021
3021
  d(this, "streams");
3022
3022
  d(this, "rooms");
3023
3023
  d(this, "impersonationOpts");
3024
- G(this, U, null);
3025
- G(this, ge, 0);
3024
+ G(this, M, null);
3025
+ G(this, we, 0);
3026
3026
  G(this, N, null);
3027
3027
  G(this, L);
3028
3028
  d(this, "tx", an());
@@ -3095,7 +3095,7 @@ const At = class At {
3095
3095
  * db.tx.goals[goalId].link({todos: todoId}),
3096
3096
  * ])
3097
3097
  */
3098
- d(this, "transact", (t) => (this.config.disableValidation || oi(t, this.config.schema), R(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`, {
3098
+ d(this, "transact", (t) => (this.config.disableValidation || ai(t, this.config.schema), R(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`, {
3099
3099
  method: "POST",
3100
3100
  headers: C(this.config, this.impersonationOpts),
3101
3101
  body: JSON.stringify({
@@ -3169,52 +3169,52 @@ const At = class At {
3169
3169
  body: JSON.stringify(i)
3170
3170
  });
3171
3171
  });
3172
- G(this, Ye, (t) => {
3172
+ G(this, Xe, (t) => {
3173
3173
  var n;
3174
- if (t.target !== b(this, U)) {
3175
- b(this, L).info("[socket][open]", t.target.id, "skip; this is no longer the current transport");
3174
+ if (t.target !== g(this, M)) {
3175
+ g(this, L).info("[socket][open]", t.target.id, "skip; this is no longer the current transport");
3176
3176
  return;
3177
3177
  }
3178
- b(this, L).info("[socket][open]", t.target.id), oe(this, ge, 0), (n = b(this, N)) == null || n.onConnectionStatusChange("authenticated");
3178
+ g(this, L).info("[socket][open]", t.target.id), ae(this, we, 0), (n = g(this, N)) == null || n.onConnectionStatusChange("authenticated");
3179
3179
  });
3180
- G(this, Ze, (t) => {
3180
+ G(this, Ye, (t) => {
3181
3181
  var n;
3182
- if (t.target !== b(this, U)) {
3183
- b(this, L).info("[socket][close]", t.target.id, "skip; this is no longer the current transport");
3182
+ if (t.target !== g(this, M)) {
3183
+ g(this, L).info("[socket][close]", t.target.id, "skip; this is no longer the current transport");
3184
3184
  return;
3185
3185
  }
3186
- b(this, L).info("[socket][close]", t.target.id), (n = b(this, N)) == null || n.onConnectionStatusChange("closed"), b(this, U) && (oe(this, U, null), H(this, A, Et).call(this) || (setTimeout(() => H(this, A, Be).call(this), b(this, ge)), oe(this, ge, Math.min(15e3, Math.max(b(this, ge), 500) * 2))));
3186
+ g(this, L).info("[socket][close]", t.target.id), (n = g(this, N)) == null || n.onConnectionStatusChange("closed"), g(this, M) && (ae(this, M, null), H(this, A, Et).call(this) || (setTimeout(() => H(this, A, He).call(this), g(this, we)), ae(this, we, Math.min(15e3, Math.max(g(this, we), 500) * 2))));
3187
3187
  });
3188
- G(this, et, (t) => {
3188
+ G(this, Ze, (t) => {
3189
3189
  var n;
3190
- if (t.target !== b(this, U)) {
3191
- b(this, L).info("[socket][error]", t.target.id, "skip; this is no longer the current transport");
3190
+ if (t.target !== g(this, M)) {
3191
+ g(this, L).info("[socket][error]", t.target.id, "skip; this is no longer the current transport");
3192
3192
  return;
3193
3193
  }
3194
- b(this, L).info("[socket][error]", t.target.id), (n = b(this, N)) == null || n.onConnectionStatusChange("closed");
3194
+ g(this, L).info("[socket][error]", t.target.id), (n = g(this, N)) == null || n.onConnectionStatusChange("closed");
3195
3195
  });
3196
- G(this, tt, (t) => {
3196
+ G(this, et, (t) => {
3197
3197
  var i, s, r, o, a, u;
3198
- if (t.target !== b(this, U)) {
3199
- b(this, L).info("[socket][message]", t.target.id, "skip; this is no longer the current transport");
3198
+ if (t.target !== g(this, M)) {
3199
+ g(this, L).info("[socket][message]", t.target.id, "skip; this is no longer the current transport");
3200
3200
  return;
3201
3201
  }
3202
3202
  const n = t.message;
3203
- switch (b(this, L).info("[receive]", n), n.op) {
3203
+ switch (g(this, L).info("[receive]", n), n.op) {
3204
3204
  case "start-stream-ok": {
3205
- (i = b(this, N)) == null || i.onStartStreamOk(n);
3205
+ (i = g(this, N)) == null || i.onStartStreamOk(n);
3206
3206
  break;
3207
3207
  }
3208
3208
  case "stream-flushed": {
3209
- (s = b(this, N)) == null || s.onStreamFlushed(n);
3209
+ (s = g(this, N)) == null || s.onStreamFlushed(n);
3210
3210
  break;
3211
3211
  }
3212
3212
  case "append-failed": {
3213
- (r = b(this, N)) == null || r.onAppendFailed(n);
3213
+ (r = g(this, N)) == null || r.onAppendFailed(n);
3214
3214
  break;
3215
3215
  }
3216
3216
  case "stream-append": {
3217
- (o = b(this, N)) == null || o.onStreamAppend(n);
3217
+ (o = g(this, N)) == null || o.onStreamAppend(n);
3218
3218
  break;
3219
3219
  }
3220
3220
  case "error": {
@@ -3223,7 +3223,7 @@ const At = class At {
3223
3223
  case "append-stream":
3224
3224
  case "subscribe-stream":
3225
3225
  case "unsubscribe-stream": {
3226
- (u = b(this, N)) == null || u.onRecieveError(n);
3226
+ (u = g(this, N)) == null || u.onRecieveError(n);
3227
3227
  break;
3228
3228
  }
3229
3229
  }
@@ -3232,7 +3232,7 @@ const At = class At {
3232
3232
  }
3233
3233
  H(this, A, On).call(this);
3234
3234
  });
3235
- this.config = Ai(t), this.auth = new Fi(this.config), this.storage = new Kt(this.config, this.impersonationOpts), this.streams = new Vi(H(this, A, vn).bind(this)), this.rooms = new Wi(this.config), oe(this, L, Ji(!!this.config.verbose));
3235
+ this.config = Pi(t), this.auth = new zi(this.config), this.storage = new Kt(this.config, this.impersonationOpts), this.streams = new Ji(H(this, A, vn).bind(this)), this.rooms = new Fi(this.config), ae(this, L, Qi(!!this.config.verbose));
3236
3236
  }
3237
3237
  /**
3238
3238
  * Use this to to get a live view of your data!
@@ -3275,50 +3275,50 @@ const At = class At {
3275
3275
  ...(i.fetchOpts || {}).headers || {},
3276
3276
  ...C(this.config, this.impersonationOpts)
3277
3277
  }, a = !!this.config.schema;
3278
- return vi(t, n, {
3278
+ return Oi(t, n, {
3279
3279
  headers: o,
3280
3280
  inference: a,
3281
3281
  apiURI: this.config.apiURI
3282
3282
  });
3283
3283
  }
3284
3284
  };
3285
- U = new WeakMap(), ge = new WeakMap(), N = new WeakMap(), L = new WeakMap(), A = new WeakSet(), wn = function() {
3286
- b(this, U) && b(this, U).close();
3285
+ M = new WeakMap(), we = new WeakMap(), N = new WeakMap(), L = new WeakMap(), A = new WeakSet(), wn = function() {
3286
+ g(this, M) && g(this, M).close();
3287
3287
  const t = {
3288
3288
  ...C(this.config, this.impersonationOpts)
3289
- }, n = !!this.config.schema, i = Ni({ headers: t, inference: n }), s = new ci(i, `${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`, `${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);
3290
- return s.onopen = b(this, Ye), s.onmessage = b(this, tt), s.onclose = b(this, Ze), s.onerror = b(this, et), oe(this, U, s), s;
3291
- }, Be = function() {
3292
- return b(this, U) || H(this, A, wn).call(this);
3289
+ }, n = !!this.config.schema, i = Li({ headers: t, inference: n }), s = new ui(i, `${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`, `${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);
3290
+ return s.onopen = g(this, Xe), s.onmessage = g(this, et), s.onclose = g(this, Ye), s.onerror = g(this, Ze), ae(this, M, s), s;
3291
+ }, He = function() {
3292
+ return g(this, M) || H(this, A, wn).call(this);
3293
3293
  }, Sn = function(t, n) {
3294
- const i = H(this, A, Be).call(this);
3295
- b(this, L).info("[send]", t, n, {
3294
+ const i = H(this, A, He).call(this);
3295
+ g(this, L).info("[send]", t, n, {
3296
3296
  isOpen: i.isOpen()
3297
3297
  }), i.isOpen() && i.send({ "client-event-id": t, ...n });
3298
3298
  }, In = function() {
3299
- H(this, A, Be).call(this);
3300
- const t = new di({
3299
+ H(this, A, He).call(this);
3300
+ const t = new hi({
3301
3301
  WStream: this.config.WritableStream || WritableStream,
3302
3302
  RStream: this.config.ReadableStream || ReadableStream,
3303
3303
  trySend: (n, i) => {
3304
3304
  H(this, A, Sn).call(this, n, i);
3305
3305
  },
3306
- log: b(this, L)
3306
+ log: g(this, L)
3307
3307
  });
3308
- return oe(this, N, t), t;
3308
+ return ae(this, N, t), t;
3309
3309
  }, vn = function() {
3310
- return b(this, N) || H(this, A, In).call(this);
3311
- }, Ye = new WeakMap(), Ze = new WeakMap(), et = new WeakMap(), Et = function() {
3312
- return !b(this, N) || !b(this, N).hasActiveStreams();
3310
+ return g(this, N) || H(this, A, In).call(this);
3311
+ }, Xe = new WeakMap(), Ye = new WeakMap(), Ze = new WeakMap(), Et = function() {
3312
+ return !g(this, N) || !g(this, N).hasActiveStreams();
3313
3313
  }, On = function() {
3314
- if (b(this, U) && H(this, A, Et).call(this)) {
3315
- const t = b(this, U);
3316
- b(this, L).info("cleaning up unused socket", t.id), oe(this, U, null), t.close();
3314
+ if (g(this, M) && H(this, A, Et).call(this)) {
3315
+ const t = g(this, M);
3316
+ g(this, L).info("cleaning up unused socket", t.id), ae(this, M, null), t.close();
3317
3317
  }
3318
- }, tt = new WeakMap();
3318
+ }, et = new WeakMap();
3319
3319
  let kt = At;
3320
3320
  var ft = {};
3321
- function Ve(e) {
3321
+ function ze(e) {
3322
3322
  let t = e;
3323
3323
  return new TransformStream({
3324
3324
  transform(n, i) {
@@ -3335,7 +3335,7 @@ function Ve(e) {
3335
3335
  }
3336
3336
  });
3337
3337
  }
3338
- function Bi(e) {
3338
+ function qi(e) {
3339
3339
  const t = e.appId || ft.INSTANT_APP_ID;
3340
3340
  if (!t)
3341
3341
  throw new Error(
@@ -3346,7 +3346,7 @@ function Bi(e) {
3346
3346
  throw new Error(
3347
3347
  "Missing adminToken. Pass it as an argument to createResumableStreamContext or set the INSTANT_APP_ADMIN_TOKEN environment variable."
3348
3348
  );
3349
- const i = e.apiURI || ft.INSTANT_API_URI, s = Li({
3349
+ const i = e.apiURI || ft.INSTANT_API_URI, s = Wi({
3350
3350
  appId: t,
3351
3351
  adminToken: n,
3352
3352
  apiURI: i
@@ -3357,31 +3357,31 @@ function Bi(e) {
3357
3357
  waitUntil: e.waitUntil ?? void 0
3358
3358
  });
3359
3359
  try {
3360
- const p = await m.streamId();
3360
+ const y = await m.streamId();
3361
3361
  l().pipeTo(m);
3362
- const g = s.streams.createReadStream({ streamId: p });
3363
- return f ? g.pipeThrough(
3364
- Ve(f)
3365
- ) : g;
3362
+ const w = s.streams.createReadStream({ streamId: y });
3363
+ return f ? w.pipeThrough(
3364
+ ze(f)
3365
+ ) : w;
3366
3366
  } catch {
3367
3367
  const I = s.streams.createReadStream({ clientId: c });
3368
3368
  return f ? I.pipeThrough(
3369
- Ve(f)
3369
+ ze(f)
3370
3370
  ) : I;
3371
3371
  }
3372
3372
  }
3373
3373
  async function o(c, l) {
3374
3374
  const f = s.streams.createReadStream({ clientId: c });
3375
- return l ? f.pipeThrough(Ve(l)) : f;
3375
+ return l ? f.pipeThrough(ze(l)) : f;
3376
3376
  }
3377
3377
  async function a(c, l, f) {
3378
- const m = l(), p = s.streams.createWriteStream({
3378
+ const m = l(), y = s.streams.createWriteStream({
3379
3379
  clientId: c,
3380
3380
  waitUntil: e.waitUntil ?? void 0
3381
3381
  });
3382
- await p.streamId(), m.pipeTo(p);
3382
+ await y.streamId(), m.pipeTo(y);
3383
3383
  const I = s.streams.createReadStream({ clientId: c });
3384
- return f ? I.pipeThrough(Ve(f)) : I;
3384
+ return f ? I.pipeThrough(ze(f)) : I;
3385
3385
  }
3386
3386
  async function u(c) {
3387
3387
  var m;
@@ -3398,5 +3398,5 @@ function Bi(e) {
3398
3398
  };
3399
3399
  }
3400
3400
  export {
3401
- Bi as createResumableStreamContext
3401
+ qi as createResumableStreamContext
3402
3402
  };