@instantdb/resumable-stream 1.0.39 → 1.0.40-branch-simplify-llm-rules.26480747371.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +8 -8
- package/dist/standalone/index.js +181 -181
- package/dist/standalone/index.umd.cjs +1 -1
- package/package.json +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
|
|
2
|
-
> @instantdb/resumable-stream@1.0.
|
|
2
|
+
> @instantdb/resumable-stream@1.0.40-branch-simplify-llm-rules.26480747371.1 build /home/runner/work/instant/instant/client/packages/resumable-stream
|
|
3
3
|
> rm -rf dist; npm run build:tshy && npm run build:standalone && npm run check-exports
|
|
4
4
|
|
|
5
5
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
6
6
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
7
7
|
|
|
8
|
-
> @instantdb/resumable-stream@1.0.
|
|
8
|
+
> @instantdb/resumable-stream@1.0.40-branch-simplify-llm-rules.26480747371.1 build:tshy
|
|
9
9
|
> tshy
|
|
10
10
|
|
|
11
11
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
12
12
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
13
13
|
|
|
14
|
-
> @instantdb/resumable-stream@1.0.
|
|
14
|
+
> @instantdb/resumable-stream@1.0.40-branch-simplify-llm-rules.26480747371.1 build:standalone
|
|
15
15
|
> vite build
|
|
16
16
|
|
|
17
17
|
[36mvite v5.4.14 [32mbuilding for production...[36m[39m
|
|
@@ -19,17 +19,17 @@ transforming...
|
|
|
19
19
|
[32m✓[39m 78 modules transformed.
|
|
20
20
|
rendering chunks...
|
|
21
21
|
computing gzip size...
|
|
22
|
-
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m77.
|
|
23
|
-
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m131.
|
|
24
|
-
[32m✓ built in 1.
|
|
22
|
+
[2mdist/standalone/[22m[36mindex.umd.cjs [39m[1m[2m77.92 kB[22m[1m[22m[2m │ gzip: 24.71 kB[22m
|
|
23
|
+
[2mdist/standalone/[22m[36mindex.js [39m[1m[2m131.63 kB[22m[1m[22m[2m │ gzip: 35.40 kB[22m
|
|
24
|
+
[32m✓ built in 1.10s[39m
|
|
25
25
|
npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
26
26
|
npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
27
27
|
|
|
28
|
-
> @instantdb/resumable-stream@1.0.
|
|
28
|
+
> @instantdb/resumable-stream@1.0.40-branch-simplify-llm-rules.26480747371.1 check-exports
|
|
29
29
|
> attw --pack .
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
@instantdb/resumable-stream v1.0.
|
|
32
|
+
@instantdb/resumable-stream v1.0.40-branch-simplify-llm-rules.26480747371.1
|
|
33
33
|
|
|
34
34
|
Build tools:
|
|
35
35
|
- @arethetypeswrong/cli@^0.17.4
|
package/dist/standalone/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var Xt = (e) => {
|
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
5
|
var Kn = (e, t, n) => t in e ? Hn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
6
|
-
var
|
|
6
|
+
var l = (e, t, n) => Kn(e, typeof t != "symbol" ? t + "" : t, n), wt = (e, t, n) => t.has(e) || Xt("Cannot " + n);
|
|
7
7
|
var y = (e, t, n) => (wt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), j = (e, t, n) => t.has(e) ? Xt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), J = (e, t, n, s) => (wt(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), R = (e, t, n) => (wt(e, t, "access private method"), n);
|
|
8
8
|
const qn = /^(?:[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
9
|
function Fe(e) {
|
|
@@ -296,7 +296,7 @@ function is(e, t, n, s, r) {
|
|
|
296
296
|
c.length < o.length && ([o, c] = [c, o], [n, s] = [s, n]);
|
|
297
297
|
for (let u = 0; u < o.length; u += 1)
|
|
298
298
|
if (i.get(u.toString()) && c[u] !== o[u]) {
|
|
299
|
-
const
|
|
299
|
+
const d = t.concat([u]), f = ve(d, r);
|
|
300
300
|
n.push({
|
|
301
301
|
op: N.Replace,
|
|
302
302
|
path: f,
|
|
@@ -310,7 +310,7 @@ function is(e, t, n, s, r) {
|
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
312
|
for (let u = o.length; u < c.length; u += 1) {
|
|
313
|
-
const
|
|
313
|
+
const d = t.concat([u]), f = ve(d, r);
|
|
314
314
|
n.push({
|
|
315
315
|
op: N.Add,
|
|
316
316
|
path: f,
|
|
@@ -321,15 +321,15 @@ function is(e, t, n, s, r) {
|
|
|
321
321
|
if (o.length < c.length) {
|
|
322
322
|
const { arrayLengthAssignment: u = !0 } = a.enablePatches;
|
|
323
323
|
if (u) {
|
|
324
|
-
const
|
|
324
|
+
const d = t.concat(["length"]), f = ve(d, r);
|
|
325
325
|
s.push({
|
|
326
326
|
op: N.Replace,
|
|
327
327
|
path: f,
|
|
328
328
|
value: o.length
|
|
329
329
|
});
|
|
330
330
|
} else
|
|
331
|
-
for (let
|
|
332
|
-
const f = t.concat([
|
|
331
|
+
for (let d = c.length; o.length < d; d -= 1) {
|
|
332
|
+
const f = t.concat([d - 1]), p = ve(f, r);
|
|
333
333
|
s.push({
|
|
334
334
|
op: N.Remove,
|
|
335
335
|
path: p
|
|
@@ -339,11 +339,11 @@ function is(e, t, n, s, r) {
|
|
|
339
339
|
}
|
|
340
340
|
function os({ original: e, copy: t, assignedMap: n }, s, r, o, i) {
|
|
341
341
|
n.forEach((a, c) => {
|
|
342
|
-
const u = ge(e, c),
|
|
343
|
-
if (Ee(u,
|
|
342
|
+
const u = ge(e, c), d = st(ge(t, c)), f = a ? He(e, c) ? N.Replace : N.Add : N.Remove;
|
|
343
|
+
if (Ee(u, d) && f === N.Replace)
|
|
344
344
|
return;
|
|
345
345
|
const p = s.concat(c), m = ve(p, i);
|
|
346
|
-
r.push(f === N.Remove ? { op: f, path: m } : { op: f, path: m, value:
|
|
346
|
+
r.push(f === N.Remove ? { op: f, path: m } : { op: f, path: m, value: d }), o.push(f === N.Add ? { op: N.Remove, path: m } : f === N.Remove ? { op: N.Add, path: m, value: u } : { op: N.Replace, path: m, value: u });
|
|
347
347
|
});
|
|
348
348
|
}
|
|
349
349
|
function as({ original: e, copy: t }, n, s, r, o) {
|
|
@@ -483,14 +483,14 @@ const ct = (e, t, n = !1) => {
|
|
|
483
483
|
let a = e.setMap.get(i);
|
|
484
484
|
const c = $(a), u = ((r = (s = e.options).mark) === null || r === void 0 ? void 0 : r.call(s, a, ae)) === ae.mutable;
|
|
485
485
|
if (e.options.strict && ct(i, e.options, u), !u && !c && Ce(i, e.options) && !e.finalized && e.original.has(i)) {
|
|
486
|
-
const
|
|
486
|
+
const d = zt.createDraft({
|
|
487
487
|
original: i,
|
|
488
488
|
parentDraft: e,
|
|
489
489
|
key: i,
|
|
490
490
|
finalities: e.finalities,
|
|
491
491
|
options: e.options
|
|
492
492
|
});
|
|
493
|
-
e.setMap.set(i,
|
|
493
|
+
e.setMap.set(i, d), a = d;
|
|
494
494
|
} else c && (a = c.proxy);
|
|
495
495
|
return {
|
|
496
496
|
done: !1,
|
|
@@ -697,24 +697,24 @@ function $n(e) {
|
|
|
697
697
|
(s || "key" in e) && (a.key = s);
|
|
698
698
|
const { proxy: c, revoke: u } = Proxy.revocable(i === 1 ? Object.assign([], a) : a, vn);
|
|
699
699
|
if (r.revoke.push(u), kn.add(c), a.proxy = c, n) {
|
|
700
|
-
const
|
|
701
|
-
|
|
700
|
+
const d = n;
|
|
701
|
+
d.finalities.draft.push((f, p) => {
|
|
702
702
|
var m, g;
|
|
703
703
|
const w = $(c);
|
|
704
|
-
let h =
|
|
704
|
+
let h = d.type === 3 ? d.setMap : d.copy;
|
|
705
705
|
const k = ge(h, s), v = $(k);
|
|
706
706
|
if (v) {
|
|
707
707
|
let z = v.original;
|
|
708
|
-
v.operated && (z = Vt(k)), Et(v), _t(v, Be, f, p),
|
|
708
|
+
v.operated && (z = Vt(k)), Et(v), _t(v, Be, f, p), d.options.enableAutoFreeze && (d.options.updatedValues = (m = d.options.updatedValues) !== null && m !== void 0 ? m : /* @__PURE__ */ new WeakMap(), d.options.updatedValues.set(z, v.original)), Jt(h, s, z);
|
|
709
709
|
}
|
|
710
710
|
(g = w.callbacks) === null || g === void 0 || g.forEach((z) => {
|
|
711
711
|
z(f, p);
|
|
712
712
|
});
|
|
713
713
|
});
|
|
714
714
|
} else {
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
Et(
|
|
715
|
+
const d = $(c);
|
|
716
|
+
d.finalities.draft.push((f, p) => {
|
|
717
|
+
Et(d), _t(d, Be, f, p);
|
|
718
718
|
});
|
|
719
719
|
}
|
|
720
720
|
return c;
|
|
@@ -727,7 +727,7 @@ function je() {
|
|
|
727
727
|
function fs(e, t) {
|
|
728
728
|
return e.localeCompare(t);
|
|
729
729
|
}
|
|
730
|
-
function
|
|
730
|
+
function ls() {
|
|
731
731
|
let e = fs;
|
|
732
732
|
if (typeof Intl == "object" && Intl.hasOwnProperty("Collator"))
|
|
733
733
|
try {
|
|
@@ -736,8 +736,8 @@ function ds() {
|
|
|
736
736
|
}
|
|
737
737
|
return e;
|
|
738
738
|
}
|
|
739
|
-
|
|
740
|
-
function
|
|
739
|
+
ls();
|
|
740
|
+
function ds() {
|
|
741
741
|
const t = {
|
|
742
742
|
__etype: 1,
|
|
743
743
|
__ops: 1,
|
|
@@ -751,7 +751,7 @@ function ls() {
|
|
|
751
751
|
};
|
|
752
752
|
return new Set(Object.keys(t));
|
|
753
753
|
}
|
|
754
|
-
const hs =
|
|
754
|
+
const hs = ds();
|
|
755
755
|
function rt(e, t, n) {
|
|
756
756
|
const s = {
|
|
757
757
|
__etype: e,
|
|
@@ -809,8 +809,8 @@ function ms(e) {
|
|
|
809
809
|
class _ extends Error {
|
|
810
810
|
constructor(n, s, r) {
|
|
811
811
|
super(n);
|
|
812
|
-
|
|
813
|
-
|
|
812
|
+
l(this, "hint");
|
|
813
|
+
l(this, "traceId");
|
|
814
814
|
this.hint = s, r && (this.traceId = r);
|
|
815
815
|
const o = new.target.prototype;
|
|
816
816
|
Object.setPrototypeOf && Object.setPrototypeOf(this, o), Error.captureStackTrace && Error.captureStackTrace(this, _), this.name = "InstantError";
|
|
@@ -819,29 +819,29 @@ class _ extends Error {
|
|
|
819
819
|
return "InstantError";
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
|
-
class
|
|
822
|
+
class de extends _ {
|
|
823
823
|
constructor(n) {
|
|
824
824
|
var o, i;
|
|
825
825
|
const s = ((o = n.body) == null ? void 0 : o.message) || `API Error (${n.status})`;
|
|
826
826
|
super(s, n.body.hint, ((i = n.body) == null ? void 0 : i.traceId) || n.body["trace-id"]);
|
|
827
|
-
|
|
828
|
-
|
|
827
|
+
l(this, "body");
|
|
828
|
+
l(this, "status");
|
|
829
829
|
const r = new.target.prototype;
|
|
830
|
-
Object.setPrototypeOf && Object.setPrototypeOf(this, r), Error.captureStackTrace && Error.captureStackTrace(this,
|
|
830
|
+
Object.setPrototypeOf && Object.setPrototypeOf(this, r), Error.captureStackTrace && Error.captureStackTrace(this, de), this.name = "InstantAPIError", this.status = n.status, this.body = n.body;
|
|
831
831
|
}
|
|
832
832
|
get [Symbol.toStringTag]() {
|
|
833
833
|
return "InstantAPIError";
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
836
|
typeof window < "u" && typeof window.localStorage < "u" && (window.localStorage.getItem("devBackend"), window.localStorage.getItem("__instantLogging"), window.localStorage.getItem("__devtoolLocalDash"));
|
|
837
|
-
const _e = "v1.0.
|
|
838
|
-
class
|
|
837
|
+
const _e = "v1.0.40-branch-simplify-llm-rules.26480747371.1";
|
|
838
|
+
class le {
|
|
839
839
|
constructor(t, n, s, r = { indexed: !1, unique: !1 }) {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
840
|
+
l(this, "valueType");
|
|
841
|
+
l(this, "required");
|
|
842
|
+
l(this, "isIndexed");
|
|
843
|
+
l(this, "config");
|
|
844
|
+
l(this, "metadata", {});
|
|
845
845
|
this.valueType = t, this.required = n, this.isIndexed = s, this.config = r;
|
|
846
846
|
}
|
|
847
847
|
/**
|
|
@@ -850,19 +850,19 @@ class de {
|
|
|
850
850
|
* and enforced for backend
|
|
851
851
|
*/
|
|
852
852
|
clientRequired() {
|
|
853
|
-
return new
|
|
853
|
+
return new le(this.valueType, !1, this.isIndexed, this.config);
|
|
854
854
|
}
|
|
855
855
|
optional() {
|
|
856
|
-
return new
|
|
856
|
+
return new le(this.valueType, !1, this.isIndexed, this.config);
|
|
857
857
|
}
|
|
858
858
|
unique() {
|
|
859
|
-
return new
|
|
859
|
+
return new le(this.valueType, this.required, this.isIndexed, {
|
|
860
860
|
...this.config,
|
|
861
861
|
unique: !0
|
|
862
862
|
});
|
|
863
863
|
}
|
|
864
864
|
indexed() {
|
|
865
|
-
return new
|
|
865
|
+
return new le(this.valueType, this.required, !0, {
|
|
866
866
|
...this.config,
|
|
867
867
|
indexed: !0
|
|
868
868
|
});
|
|
@@ -903,9 +903,9 @@ const nn = [
|
|
|
903
903
|
return !0;
|
|
904
904
|
}
|
|
905
905
|
}, ws = (e, t, n, s, r, o, i) => {
|
|
906
|
-
const a = o.valueType === "json", c = (u,
|
|
907
|
-
if (!_n(f,
|
|
908
|
-
throw new T(`Invalid value for operator '${u}' on attribute '${s}' in entity '${r}'. Expected ${
|
|
906
|
+
const a = o.valueType === "json", c = (u, d, f) => {
|
|
907
|
+
if (!_n(f, d, a))
|
|
908
|
+
throw new T(`Invalid value for operator '${u}' on attribute '${s}' in entity '${r}'. Expected ${d}, but received: ${typeof f}`, i);
|
|
909
909
|
};
|
|
910
910
|
switch (e) {
|
|
911
911
|
case "in":
|
|
@@ -940,8 +940,8 @@ const nn = [
|
|
|
940
940
|
if (i)
|
|
941
941
|
return;
|
|
942
942
|
const c = e;
|
|
943
|
-
for (const [u,
|
|
944
|
-
ws(u,
|
|
943
|
+
for (const [u, d] of Object.entries(c))
|
|
944
|
+
ws(u, d, o, t, s, n, `${r}.${u}`);
|
|
945
945
|
} else if (!_n(e, o, i))
|
|
946
946
|
throw new T(`Invalid value for attribute '${t}' in entity '${s}'. Expected ${o}, but received: ${typeof e}`, r);
|
|
947
947
|
}, gs = (e, t, n, s, r) => {
|
|
@@ -949,8 +949,8 @@ const nn = [
|
|
|
949
949
|
if (o.length < 2)
|
|
950
950
|
throw new T(`Invalid dot notation path '${e}'. Must contain at least one dot.`, r);
|
|
951
951
|
let i = n;
|
|
952
|
-
for (let
|
|
953
|
-
const f = o[
|
|
952
|
+
for (let d = 0; d < o.length - 1; d++) {
|
|
953
|
+
const f = o[d], p = s.entities[i];
|
|
954
954
|
if (!p)
|
|
955
955
|
throw new T(`Entity '${i}' does not exist in schema while traversing dot notation path '${e}'.`, r);
|
|
956
956
|
const m = p.links[f];
|
|
@@ -966,19 +966,19 @@ const nn = [
|
|
|
966
966
|
if (a === "id") {
|
|
967
967
|
if (typeof t == "string" && !Fe(t))
|
|
968
968
|
throw new T(`Invalid value for id field in entity '${i}'. Expected a UUID, but received: ${t}`, r);
|
|
969
|
-
Ue(t, e, new
|
|
969
|
+
Ue(t, e, new le("string", !1, !0), n, r);
|
|
970
970
|
return;
|
|
971
971
|
}
|
|
972
972
|
const u = c.attrs[a];
|
|
973
973
|
if (Object.keys(c.links).includes(a)) {
|
|
974
974
|
if (typeof t == "string" && !Fe(t))
|
|
975
975
|
throw new T(`Invalid value for link '${a}' in entity '${i}'. Expected a UUID, but received: ${t}`, r);
|
|
976
|
-
Ue(t, e, new
|
|
976
|
+
Ue(t, e, new le("string", !1, !0), n, r);
|
|
977
977
|
return;
|
|
978
978
|
}
|
|
979
979
|
if (!u) {
|
|
980
|
-
const
|
|
981
|
-
throw new T(`Attribute '${a}' does not exist on entity '${i}' in dot notation path '${e}'. Available attributes: ${
|
|
980
|
+
const d = Object.keys(c.attrs);
|
|
981
|
+
throw new T(`Attribute '${a}' does not exist on entity '${i}' in dot notation path '${e}'. Available attributes: ${d.length > 0 ? d.join(", ") + ", id" : "id"}`, r);
|
|
982
982
|
}
|
|
983
983
|
Ue(t, e, u, n, r);
|
|
984
984
|
}, Cn = (e, t, n, s) => {
|
|
@@ -990,7 +990,7 @@ const nn = [
|
|
|
990
990
|
continue;
|
|
991
991
|
}
|
|
992
992
|
if (r === "id") {
|
|
993
|
-
Ue(o, "id", new
|
|
993
|
+
Ue(o, "id", new le("string", !1, !0), t, `${s}.id`);
|
|
994
994
|
continue;
|
|
995
995
|
}
|
|
996
996
|
if (r.includes(".")) {
|
|
@@ -1002,15 +1002,15 @@ const nn = [
|
|
|
1002
1002
|
continue;
|
|
1003
1003
|
const a = i.attrs[r], c = i.links[r];
|
|
1004
1004
|
if (!a && !c) {
|
|
1005
|
-
const u = Object.keys(i.attrs),
|
|
1006
|
-
throw new T(`Attribute or link '${r}' does not exist on entity '${t}'. Available attributes: ${u.length > 0 ? u.join(", ") : "none"}. Available links: ${
|
|
1005
|
+
const u = Object.keys(i.attrs), d = Object.keys(i.links);
|
|
1006
|
+
throw new T(`Attribute or link '${r}' does not exist on entity '${t}'. Available attributes: ${u.length > 0 ? u.join(", ") : "none"}. Available links: ${d.length > 0 ? d.join(", ") : "none"}`, `${s}.${r}`);
|
|
1007
1007
|
}
|
|
1008
1008
|
if (a)
|
|
1009
1009
|
Ue(o, r, a, t, `${s}.${r}`);
|
|
1010
1010
|
else if (c) {
|
|
1011
1011
|
if (typeof o == "string" && !Fe(o))
|
|
1012
1012
|
throw new T(`Invalid value for link '${r}' in entity '${t}'. Expected a UUID, but received: ${o}`, `${s}.${r}`);
|
|
1013
|
-
const u = new
|
|
1013
|
+
const u = new le("string", !1, !0);
|
|
1014
1014
|
Ue(o, r, u, t, `${s}.${r}`);
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
@@ -1160,21 +1160,21 @@ const xn = (e) => e.length > 0 ? e.join(", ") : "none", Is = (e, t) => new te(`E
|
|
|
1160
1160
|
let Es = 0;
|
|
1161
1161
|
class _s {
|
|
1162
1162
|
constructor(t, n, s) {
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1163
|
+
l(this, "type", "sse");
|
|
1164
|
+
l(this, "initParams", null);
|
|
1165
|
+
l(this, "sendQueue", []);
|
|
1166
|
+
l(this, "sendPromise");
|
|
1167
|
+
l(this, "closeFired", !1);
|
|
1168
|
+
l(this, "sseInitTimeout");
|
|
1169
|
+
l(this, "ES");
|
|
1170
|
+
l(this, "messageUrl");
|
|
1171
|
+
l(this, "conn");
|
|
1172
|
+
l(this, "url");
|
|
1173
|
+
l(this, "id");
|
|
1174
|
+
l(this, "onopen");
|
|
1175
|
+
l(this, "onmessage");
|
|
1176
|
+
l(this, "onclose");
|
|
1177
|
+
l(this, "onerror");
|
|
1178
1178
|
this.id = `${this.type}_${Es++}`, this.url = n, this.messageUrl = s || this.url, this.ES = t, this.conn = new t(n), this.sseInitTimeout = setTimeout(() => {
|
|
1179
1179
|
this.initParams || this.handleError();
|
|
1180
1180
|
}, 1e4), this.conn.onmessage = (r) => {
|
|
@@ -1263,7 +1263,7 @@ function Cs({ WStream: e, opts: t, startStream: n, appendStream: s, registerStre
|
|
|
1263
1263
|
const o = t.clientId;
|
|
1264
1264
|
let i = null, a = null, c = null;
|
|
1265
1265
|
const u = je();
|
|
1266
|
-
let
|
|
1266
|
+
let d = !1, f = !1;
|
|
1267
1267
|
const p = [], m = [], g = [];
|
|
1268
1268
|
let w = !1, h = 0, k = 0;
|
|
1269
1269
|
const v = [], z = new TextEncoder();
|
|
@@ -1351,10 +1351,10 @@ function Cs({ WStream: e, opts: t, startStream: n, appendStream: s, registerStre
|
|
|
1351
1351
|
E(), ee();
|
|
1352
1352
|
}
|
|
1353
1353
|
function Ze({ offset: b, done: S }) {
|
|
1354
|
-
D(b), S && (
|
|
1354
|
+
D(b), S && (d = !0, x());
|
|
1355
1355
|
}
|
|
1356
1356
|
function Gt(b) {
|
|
1357
|
-
return
|
|
1357
|
+
return d ? (M(b, new _("Stream has been closed.")), null) : i || (M(b, new _("Stream has not been initialized.")), null);
|
|
1358
1358
|
}
|
|
1359
1359
|
async function Te(b) {
|
|
1360
1360
|
c = b;
|
|
@@ -1460,9 +1460,9 @@ function Cs({ WStream: e, opts: t, startStream: n, appendStream: s, registerStre
|
|
|
1460
1460
|
}
|
|
1461
1461
|
class Ts {
|
|
1462
1462
|
constructor() {
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1463
|
+
l(this, "items", []);
|
|
1464
|
+
l(this, "resolvers", []);
|
|
1465
|
+
l(this, "isClosed", !1);
|
|
1466
1466
|
}
|
|
1467
1467
|
push(t) {
|
|
1468
1468
|
if (this.isClosed)
|
|
@@ -1496,17 +1496,17 @@ function xs({ RStream: e, opts: t, startStream: n, cancelStream: s }) {
|
|
|
1496
1496
|
let r = t.byteOffset || 0, o = !1;
|
|
1497
1497
|
const i = new TextDecoder("utf-8"), a = new TextEncoder();
|
|
1498
1498
|
let c, u = !1;
|
|
1499
|
-
const
|
|
1499
|
+
const d = [], f = [];
|
|
1500
1500
|
let p = null, m = null;
|
|
1501
1501
|
function g(x) {
|
|
1502
1502
|
u = !0;
|
|
1503
|
-
for (const O of
|
|
1503
|
+
for (const O of d)
|
|
1504
1504
|
O(x);
|
|
1505
1505
|
}
|
|
1506
1506
|
function w(x) {
|
|
1507
|
-
return
|
|
1508
|
-
const O =
|
|
1509
|
-
O !== -1 &&
|
|
1507
|
+
return d.push(x), () => {
|
|
1508
|
+
const O = d.indexOf(x);
|
|
1509
|
+
O !== -1 && d.splice(O, 1);
|
|
1510
1510
|
};
|
|
1511
1511
|
}
|
|
1512
1512
|
function h(x) {
|
|
@@ -1652,14 +1652,14 @@ function xs({ RStream: e, opts: t, startStream: n, cancelStream: s }) {
|
|
|
1652
1652
|
}
|
|
1653
1653
|
class Rs {
|
|
1654
1654
|
constructor({ WStream: t, RStream: n, trySend: s, log: r }) {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1655
|
+
l(this, "trySend");
|
|
1656
|
+
l(this, "WStream");
|
|
1657
|
+
l(this, "RStream");
|
|
1658
|
+
l(this, "writeStreams", {});
|
|
1659
|
+
l(this, "startWriteStreamCbs", {});
|
|
1660
|
+
l(this, "readStreamIterators", {});
|
|
1661
|
+
l(this, "log");
|
|
1662
|
+
l(this, "activeStreams", /* @__PURE__ */ new Set());
|
|
1663
1663
|
this.WStream = t, this.RStream = n, this.trySend = s, this.log = r;
|
|
1664
1664
|
}
|
|
1665
1665
|
createWriteStream(t) {
|
|
@@ -1837,7 +1837,7 @@ function js(e) {
|
|
|
1837
1837
|
);
|
|
1838
1838
|
const { onEvent: t = vt, onError: n = vt, onRetry: s = vt, onComment: r } = e;
|
|
1839
1839
|
let o = "", i = !0, a, c = "", u = "";
|
|
1840
|
-
function
|
|
1840
|
+
function d(w) {
|
|
1841
1841
|
const h = i ? w.replace(/^\xEF\xBB\xBF/, "") : w, [k, v] = Us(`${o}${h}`);
|
|
1842
1842
|
for (const z of k)
|
|
1843
1843
|
f(z);
|
|
@@ -1904,7 +1904,7 @@ function js(e) {
|
|
|
1904
1904
|
function g(w = {}) {
|
|
1905
1905
|
o && w.consume && f(o), i = !0, a = void 0, c = "", u = "", o = "";
|
|
1906
1906
|
}
|
|
1907
|
-
return { feed:
|
|
1907
|
+
return { feed: d, reset: g };
|
|
1908
1908
|
}
|
|
1909
1909
|
function Us(e) {
|
|
1910
1910
|
const t = [];
|
|
@@ -1985,24 +1985,24 @@ function fn(e) {
|
|
|
1985
1985
|
}
|
|
1986
1986
|
var An = (e) => {
|
|
1987
1987
|
throw TypeError(e);
|
|
1988
|
-
}, Kt = (e, t, n) => t.has(e) || An("Cannot " + n), I = (e, t, n) => (Kt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), U = (e, t, n) => t.has(e) ? An("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), C = (e, t, n, s) => (Kt(e, t, "write to private field"), t.set(e, n), n), fe = (e, t, n) => (Kt(e, t, "access private method"), n), X, ke, Re, it, ft, ot, Ke, Me, qe, we, Ae, De, Pe, Ve, ie, xt, Rt, At,
|
|
1988
|
+
}, Kt = (e, t, n) => t.has(e) || An("Cannot " + n), I = (e, t, n) => (Kt(e, t, "read from private field"), n ? n.call(e) : t.get(e)), U = (e, t, n) => t.has(e) ? An("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), C = (e, t, n, s) => (Kt(e, t, "write to private field"), t.set(e, n), n), fe = (e, t, n) => (Kt(e, t, "access private method"), n), X, ke, Re, it, ft, ot, Ke, Me, qe, we, Ae, De, Pe, Ve, ie, xt, Rt, At, ln, Pt, Mt, Je, jt, Ut;
|
|
1989
1989
|
class oe extends EventTarget {
|
|
1990
1990
|
constructor(t, n) {
|
|
1991
1991
|
var s, r, o;
|
|
1992
1992
|
super(), U(this, ie), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, U(this, X), U(this, ke), U(this, Re), U(this, it), U(this, ft), U(this, ot), U(this, Ke), U(this, Me), U(this, qe, null), U(this, we), U(this, Ae), U(this, De, null), U(this, Pe, null), U(this, Ve, null), U(this, Rt, async (i) => {
|
|
1993
1993
|
var a;
|
|
1994
1994
|
I(this, Ae).reset();
|
|
1995
|
-
const { body: c, redirected: u, status:
|
|
1996
|
-
if (
|
|
1995
|
+
const { body: c, redirected: u, status: d, headers: f } = i;
|
|
1996
|
+
if (d === 204) {
|
|
1997
1997
|
fe(this, ie, Je).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
1998
1998
|
return;
|
|
1999
1999
|
}
|
|
2000
|
-
if (u ? C(this, Re, new URL(i.url)) : C(this, Re, void 0),
|
|
2001
|
-
fe(this, ie, Je).call(this, `Non-200 status code (${
|
|
2000
|
+
if (u ? C(this, Re, new URL(i.url)) : C(this, Re, void 0), d !== 200) {
|
|
2001
|
+
fe(this, ie, Je).call(this, `Non-200 status code (${d})`, d);
|
|
2002
2002
|
return;
|
|
2003
2003
|
}
|
|
2004
2004
|
if (!(f.get("content-type") || "").startsWith("text/event-stream")) {
|
|
2005
|
-
fe(this, ie, Je).call(this, 'Invalid content type, expected "text/event-stream"',
|
|
2005
|
+
fe(this, ie, Je).call(this, 'Invalid content type, expected "text/event-stream"', d);
|
|
2006
2006
|
return;
|
|
2007
2007
|
}
|
|
2008
2008
|
if (I(this, X) === this.CLOSED)
|
|
@@ -2010,7 +2010,7 @@ class oe extends EventTarget {
|
|
|
2010
2010
|
C(this, X, this.OPEN);
|
|
2011
2011
|
const p = new Event("open");
|
|
2012
2012
|
if ((a = I(this, Ve)) == null || a.call(this, p), this.dispatchEvent(p), typeof c != "object" || !c || !("getReader" in c)) {
|
|
2013
|
-
fe(this, ie, Je).call(this, "Invalid response body, expected a web ReadableStream",
|
|
2013
|
+
fe(this, ie, Je).call(this, "Invalid response body, expected a web ReadableStream", d), this.close();
|
|
2014
2014
|
return;
|
|
2015
2015
|
}
|
|
2016
2016
|
const m = new TextDecoder(), g = c.getReader();
|
|
@@ -2126,14 +2126,14 @@ X = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap(), Re = /* @
|
|
|
2126
2126
|
* @internal
|
|
2127
2127
|
*/
|
|
2128
2128
|
xt = function() {
|
|
2129
|
-
C(this, X, this.CONNECTING), C(this, we, new AbortController()), I(this, ft)(I(this, ke), fe(this, ie,
|
|
2129
|
+
C(this, X, this.CONNECTING), C(this, we, new AbortController()), I(this, ft)(I(this, ke), fe(this, ie, ln).call(this)).then(I(this, Rt)).catch(I(this, At));
|
|
2130
2130
|
}, Rt = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakMap(), /**
|
|
2131
2131
|
* Get request options for the `fetch()` request
|
|
2132
2132
|
*
|
|
2133
2133
|
* @returns The request options
|
|
2134
2134
|
* @internal
|
|
2135
2135
|
*/
|
|
2136
|
-
|
|
2136
|
+
ln = function() {
|
|
2137
2137
|
var e;
|
|
2138
2138
|
const t = {
|
|
2139
2139
|
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
@@ -2200,11 +2200,11 @@ function Ns() {
|
|
|
2200
2200
|
class Pn extends Event {
|
|
2201
2201
|
constructor(n, s) {
|
|
2202
2202
|
super(n);
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2203
|
+
l(this, "data");
|
|
2204
|
+
l(this, "origin");
|
|
2205
|
+
l(this, "lastEventId");
|
|
2206
|
+
l(this, "source");
|
|
2207
|
+
l(this, "ports");
|
|
2208
2208
|
this.data = (s == null ? void 0 : s.data) ?? null, this.origin = (s == null ? void 0 : s.origin) ?? "", this.lastEventId = (s == null ? void 0 : s.lastEventId) ?? "", this.source = (s == null ? void 0 : s.source) ?? null, this.ports = (s == null ? void 0 : s.ports) ?? [];
|
|
2209
2209
|
}
|
|
2210
2210
|
/** @deprecated */
|
|
@@ -2266,7 +2266,7 @@ function Ls(e) {
|
|
|
2266
2266
|
}
|
|
2267
2267
|
};
|
|
2268
2268
|
}
|
|
2269
|
-
function
|
|
2269
|
+
function dn(e) {
|
|
2270
2270
|
if (!e)
|
|
2271
2271
|
return;
|
|
2272
2272
|
const t = {};
|
|
@@ -2300,7 +2300,7 @@ function Fs(e, t, n) {
|
|
|
2300
2300
|
}
|
|
2301
2301
|
}), a = [], c = [], u = (h) => {
|
|
2302
2302
|
a.push(h);
|
|
2303
|
-
},
|
|
2303
|
+
}, d = (h) => {
|
|
2304
2304
|
a.splice(a.indexOf(h), 1);
|
|
2305
2305
|
}, f = (h) => {
|
|
2306
2306
|
c.push(h);
|
|
@@ -2328,7 +2328,7 @@ function Fs(e, t, n) {
|
|
|
2328
2328
|
m({
|
|
2329
2329
|
type: "ok",
|
|
2330
2330
|
data: h.result,
|
|
2331
|
-
pageInfo:
|
|
2331
|
+
pageInfo: dn((k = h["result-meta"]) == null ? void 0 : k["page-info"]),
|
|
2332
2332
|
sessionInfo: p
|
|
2333
2333
|
});
|
|
2334
2334
|
break;
|
|
@@ -2337,7 +2337,7 @@ function Fs(e, t, n) {
|
|
|
2337
2337
|
h.computations.length && m({
|
|
2338
2338
|
type: "ok",
|
|
2339
2339
|
data: h.computations[0]["instaql-result"],
|
|
2340
|
-
pageInfo:
|
|
2340
|
+
pageInfo: dn((v = h.computations[0]["result-meta"]) == null ? void 0 : v["page-info"]),
|
|
2341
2341
|
sessionInfo: p
|
|
2342
2342
|
});
|
|
2343
2343
|
break;
|
|
@@ -2345,7 +2345,7 @@ function Fs(e, t, n) {
|
|
|
2345
2345
|
case "error": {
|
|
2346
2346
|
m({
|
|
2347
2347
|
type: "error",
|
|
2348
|
-
error: new
|
|
2348
|
+
error: new de({ body: h, status: h.status }),
|
|
2349
2349
|
get readyState() {
|
|
2350
2350
|
return me(i);
|
|
2351
2351
|
},
|
|
@@ -2368,7 +2368,7 @@ function Fs(e, t, n) {
|
|
|
2368
2368
|
}
|
|
2369
2369
|
m({
|
|
2370
2370
|
type: "error",
|
|
2371
|
-
error: new
|
|
2371
|
+
error: new de({
|
|
2372
2372
|
status: s.status,
|
|
2373
2373
|
body: v
|
|
2374
2374
|
}),
|
|
@@ -2385,7 +2385,7 @@ function Fs(e, t, n) {
|
|
|
2385
2385
|
const k = () => {
|
|
2386
2386
|
m({
|
|
2387
2387
|
type: "error",
|
|
2388
|
-
error: new
|
|
2388
|
+
error: new de({
|
|
2389
2389
|
status: h.code || 500,
|
|
2390
2390
|
body: {
|
|
2391
2391
|
type: void 0,
|
|
@@ -2434,7 +2434,7 @@ function Fs(e, t, n) {
|
|
|
2434
2434
|
get isClosed() {
|
|
2435
2435
|
return me(i) === "closed";
|
|
2436
2436
|
},
|
|
2437
|
-
[Symbol.asyncIterator]: Ws.bind(this, u, f,
|
|
2437
|
+
[Symbol.asyncIterator]: Ws.bind(this, u, f, d, () => 1)
|
|
2438
2438
|
};
|
|
2439
2439
|
}
|
|
2440
2440
|
var he = {};
|
|
@@ -2553,8 +2553,8 @@ function Qs(e, t) {
|
|
|
2553
2553
|
};
|
|
2554
2554
|
let a = r + 1;
|
|
2555
2555
|
for (; a < s; ) {
|
|
2556
|
-
const c = Dt(e, a, s), u = Nt(e, a, c),
|
|
2557
|
-
switch (
|
|
2556
|
+
const c = Dt(e, a, s), u = Nt(e, a, c), d = u === -1 ? be(e, a, c) : be(e, a, u), f = u === -1 ? void 0 : be(e, u + 1, c);
|
|
2557
|
+
switch (d.toLowerCase()) {
|
|
2558
2558
|
case "httponly":
|
|
2559
2559
|
i.httpOnly = !0;
|
|
2560
2560
|
break;
|
|
@@ -2726,9 +2726,9 @@ async function ir(e, t) {
|
|
|
2726
2726
|
const n = await t.text();
|
|
2727
2727
|
try {
|
|
2728
2728
|
const s = JSON.parse(n);
|
|
2729
|
-
return e(new
|
|
2729
|
+
return e(new de({ status: t.status, body: s }));
|
|
2730
2730
|
} catch {
|
|
2731
|
-
return e(new
|
|
2731
|
+
return e(new de({
|
|
2732
2732
|
status: t.status,
|
|
2733
2733
|
body: { type: void 0, message: n }
|
|
2734
2734
|
}));
|
|
@@ -2928,15 +2928,15 @@ var Xe, $e;
|
|
|
2928
2928
|
const qt = class qt {
|
|
2929
2929
|
constructor(t, n) {
|
|
2930
2930
|
/** App this instance is bound to. */
|
|
2931
|
-
|
|
2931
|
+
l(this, "appId");
|
|
2932
2932
|
/** Schema used to type webhook payloads and handler records. */
|
|
2933
|
-
|
|
2933
|
+
l(this, "schema");
|
|
2934
2934
|
j(this, Xe);
|
|
2935
2935
|
/** Base URL for the Instant API. */
|
|
2936
|
-
|
|
2936
|
+
l(this, "apiURI");
|
|
2937
2937
|
j(this, $e);
|
|
2938
2938
|
/** Manage webhook subscriptions and inspect delivery events. */
|
|
2939
|
-
|
|
2939
|
+
l(this, "manager");
|
|
2940
2940
|
this.appId = t.appId, this.schema = t.schema, J(this, Xe, t.adminToken || t.token), this.apiURI = t.apiURI || "https://api.instantdb.com", J(this, $e, n || or), this.manager = new cr({
|
|
2941
2941
|
appId: this.appId,
|
|
2942
2942
|
apiURI: this.apiURI,
|
|
@@ -3030,8 +3030,8 @@ const qt = class qt {
|
|
|
3030
3030
|
async validate(t, n, s) {
|
|
3031
3031
|
const r = (s == null ? void 0 : s.receivedAt) || /* @__PURE__ */ new Date(), { t: o, kid: i, v1: a } = nr(t), c = (s == null ? void 0 : s.tolerance) ?? rr;
|
|
3032
3032
|
sr(r, o, c);
|
|
3033
|
-
const { alg: u, key:
|
|
3034
|
-
if (!await er(u,
|
|
3033
|
+
const { alg: u, key: d } = await this.keyOfKid(i), f = typeof n == "function" ? await n() : n, p = new TextEncoder().encode(`${o}.${f}`);
|
|
3034
|
+
if (!await er(u, d, tr(a), p))
|
|
3035
3035
|
throw new _("Instant Signature did not validate", {
|
|
3036
3036
|
header: t
|
|
3037
3037
|
});
|
|
@@ -3247,13 +3247,13 @@ const qt = class qt {
|
|
|
3247
3247
|
const a = typeof n.headers.host == "string" ? n.headers.host : "localhost", c = new URL(n.url ?? "/", `https://${a}`), u = new Headers();
|
|
3248
3248
|
for (const [f, p] of Object.entries(n.headers))
|
|
3249
3249
|
typeof p == "string" ? u.set(f, p) : Array.isArray(p) && u.set(f, p.join(", "));
|
|
3250
|
-
const
|
|
3250
|
+
const d = new Request(c, {
|
|
3251
3251
|
method: n.method ?? "POST",
|
|
3252
3252
|
headers: u,
|
|
3253
3253
|
body: r
|
|
3254
3254
|
});
|
|
3255
3255
|
try {
|
|
3256
|
-
await this.processRequest(t,
|
|
3256
|
+
await this.processRequest(t, d, s);
|
|
3257
3257
|
} catch (f) {
|
|
3258
3258
|
throw o && f instanceof _ && f.message === "Instant Signature did not validate" ? new _("Webhook signature did not validate. The request body was re-serialized from a parsed JSON object, which can produce different bytes than the server signed. Configure this route to receive the raw request body instead of parsed JSON.", { hint: f.hint }) : f;
|
|
3259
3259
|
}
|
|
@@ -3270,19 +3270,19 @@ function ur(e) {
|
|
|
3270
3270
|
function fr(e, t) {
|
|
3271
3271
|
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;
|
|
3272
3272
|
}
|
|
3273
|
-
function
|
|
3273
|
+
function lr(e, t) {
|
|
3274
3274
|
if (!(t && ("token" in t || "guest" in t)) && !e.adminToken)
|
|
3275
3275
|
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`.");
|
|
3276
3276
|
}
|
|
3277
3277
|
function P(e, t) {
|
|
3278
|
-
|
|
3278
|
+
lr(e, t);
|
|
3279
3279
|
const { adminToken: n, appId: s } = e, r = {
|
|
3280
3280
|
"content-type": "application/json",
|
|
3281
3281
|
"app-id": s
|
|
3282
3282
|
};
|
|
3283
3283
|
return n && (r.authorization = `Bearer ${n}`), t ? fr(r, t) : r;
|
|
3284
3284
|
}
|
|
3285
|
-
function
|
|
3285
|
+
function dr() {
|
|
3286
3286
|
return (
|
|
3287
3287
|
// NextJS 13 onwards added a `__nextPatched` property to the fetch function
|
|
3288
3288
|
fetch.__nextPatched && // NextJS 15 onwards _also_ added a global `next-patch` symbol.
|
|
@@ -3290,15 +3290,15 @@ function lr() {
|
|
|
3290
3290
|
);
|
|
3291
3291
|
}
|
|
3292
3292
|
function hr() {
|
|
3293
|
-
return
|
|
3293
|
+
return dr() ? { cache: "no-store" } : {};
|
|
3294
3294
|
}
|
|
3295
3295
|
async function pr(e, t) {
|
|
3296
3296
|
const n = await t.text();
|
|
3297
3297
|
try {
|
|
3298
3298
|
const s = JSON.parse(n);
|
|
3299
|
-
return e(new
|
|
3299
|
+
return e(new de({ status: t.status, body: s }));
|
|
3300
3300
|
} catch {
|
|
3301
|
-
return e(new
|
|
3301
|
+
return e(new de({
|
|
3302
3302
|
status: t.status,
|
|
3303
3303
|
body: { type: void 0, message: n }
|
|
3304
3304
|
}));
|
|
@@ -3321,8 +3321,8 @@ function yr(e) {
|
|
|
3321
3321
|
return t = class {
|
|
3322
3322
|
constructor(o) {
|
|
3323
3323
|
j(this, n);
|
|
3324
|
-
|
|
3325
|
-
|
|
3324
|
+
l(this, "source");
|
|
3325
|
+
l(this, "url");
|
|
3326
3326
|
this.url = o, this.source = R(this, n, Wn).call(this, o);
|
|
3327
3327
|
}
|
|
3328
3328
|
get onopen() {
|
|
@@ -3367,7 +3367,7 @@ function yr(e) {
|
|
|
3367
3367
|
});
|
|
3368
3368
|
}
|
|
3369
3369
|
});
|
|
3370
|
-
},
|
|
3370
|
+
}, l(t, "OPEN", oe.OPEN), l(t, "CONNECTING", oe.CONNECTING), l(t, "CLOSED", oe.CLOSED), t;
|
|
3371
3371
|
}
|
|
3372
3372
|
function mr(e) {
|
|
3373
3373
|
var n, s;
|
|
@@ -3385,7 +3385,7 @@ function pn(e) {
|
|
|
3385
3385
|
}
|
|
3386
3386
|
class br {
|
|
3387
3387
|
constructor(t) {
|
|
3388
|
-
|
|
3388
|
+
l(this, "config");
|
|
3389
3389
|
this.config = t;
|
|
3390
3390
|
}
|
|
3391
3391
|
async getPresence(t, n) {
|
|
@@ -3397,7 +3397,7 @@ class br {
|
|
|
3397
3397
|
}
|
|
3398
3398
|
class wr {
|
|
3399
3399
|
constructor(t) {
|
|
3400
|
-
|
|
3400
|
+
l(this, "config");
|
|
3401
3401
|
/**
|
|
3402
3402
|
* Generates a magic code for the user with the given email.
|
|
3403
3403
|
* This is useful if you want to use your own email provider
|
|
@@ -3411,7 +3411,7 @@ class wr {
|
|
|
3411
3411
|
*
|
|
3412
3412
|
* @see https://instantdb.com/docs/backend#custom-magic-codes
|
|
3413
3413
|
*/
|
|
3414
|
-
|
|
3414
|
+
l(this, "generateMagicCode", async (t) => A(`${this.config.apiURI}/admin/magic_code?app_id=${this.config.appId}`, {
|
|
3415
3415
|
method: "POST",
|
|
3416
3416
|
headers: P(this.config),
|
|
3417
3417
|
body: JSON.stringify({ email: t })
|
|
@@ -3426,7 +3426,7 @@ class wr {
|
|
|
3426
3426
|
*
|
|
3427
3427
|
* @see https://instantdb.com/docs/backend#custom-magic-codes
|
|
3428
3428
|
*/
|
|
3429
|
-
|
|
3429
|
+
l(this, "sendMagicCode", async (t) => A(`${this.config.apiURI}/admin/send_magic_code?app_id=${this.config.appId}`, {
|
|
3430
3430
|
method: "POST",
|
|
3431
3431
|
headers: P(this.config),
|
|
3432
3432
|
body: JSON.stringify({ email: t })
|
|
@@ -3437,7 +3437,7 @@ class wr {
|
|
|
3437
3437
|
*
|
|
3438
3438
|
* @see https://instantdb.com/docs/backend#custom-magic-codes
|
|
3439
3439
|
*/
|
|
3440
|
-
|
|
3440
|
+
l(this, "verifyMagicCode", async (t, n) => {
|
|
3441
3441
|
const { user: s } = await A(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`, {
|
|
3442
3442
|
method: "POST",
|
|
3443
3443
|
headers: P(this.config),
|
|
@@ -3459,7 +3459,7 @@ class wr {
|
|
|
3459
3459
|
*
|
|
3460
3460
|
* @see https://instantdb.com/docs/backend#custom-magic-codes
|
|
3461
3461
|
*/
|
|
3462
|
-
|
|
3462
|
+
l(this, "checkMagicCode", async (t, n, s) => {
|
|
3463
3463
|
const r = await A(`${this.config.apiURI}/admin/verify_magic_code?app_id=${this.config.appId}`, {
|
|
3464
3464
|
method: "POST",
|
|
3465
3465
|
headers: P(this.config),
|
|
@@ -3487,7 +3487,7 @@ class wr {
|
|
|
3487
3487
|
* })
|
|
3488
3488
|
* @see https://instantdb.com/docs/backend#custom-endpoints
|
|
3489
3489
|
*/
|
|
3490
|
-
|
|
3490
|
+
l(this, "verifyToken", async (t) => (await A(`${this.config.apiURI}/runtime/auth/verify_refresh_token?app_id=${this.config.appId}`, {
|
|
3491
3491
|
method: "POST",
|
|
3492
3492
|
headers: { "content-type": "application/json" },
|
|
3493
3493
|
body: JSON.stringify({
|
|
@@ -3510,7 +3510,7 @@ class wr {
|
|
|
3510
3510
|
*
|
|
3511
3511
|
* @see https://instantdb.com/docs/backend#retrieve-a-user
|
|
3512
3512
|
*/
|
|
3513
|
-
|
|
3513
|
+
l(this, "getUser", async (t) => {
|
|
3514
3514
|
const n = new URLSearchParams(Object.entries(t)).toString();
|
|
3515
3515
|
return (await A(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${n}`, {
|
|
3516
3516
|
method: "GET",
|
|
@@ -3535,7 +3535,7 @@ class wr {
|
|
|
3535
3535
|
*
|
|
3536
3536
|
* @see https://instantdb.com/docs/backend#delete-a-user
|
|
3537
3537
|
*/
|
|
3538
|
-
|
|
3538
|
+
l(this, "deleteUser", async (t) => {
|
|
3539
3539
|
const n = new URLSearchParams(Object.entries(t)).toString();
|
|
3540
3540
|
return (await A(`${this.config.apiURI}/admin/users?app_id=${this.config.appId}&${n}`, {
|
|
3541
3541
|
method: "DELETE",
|
|
@@ -3549,7 +3549,7 @@ class wr {
|
|
|
3549
3549
|
* @param req The request containing a cookie synced with createInstantRouteHandler
|
|
3550
3550
|
* @param opts Allow disabling validation of refresh token
|
|
3551
3551
|
*/
|
|
3552
|
-
|
|
3552
|
+
l(this, "getUserFromRequest", async (t, n) => {
|
|
3553
3553
|
const s = t.headers.get("cookie") || "", r = zs(s), o = "instant_user_" + this.config.appId;
|
|
3554
3554
|
if (!r[o])
|
|
3555
3555
|
return null;
|
|
@@ -3578,8 +3578,8 @@ class wr {
|
|
|
3578
3578
|
const yn = (e) => e && typeof e == "object" && typeof e.pipe == "function" && typeof e.read == "function", gr = (e) => e && typeof e.getReader == "function";
|
|
3579
3579
|
class mn {
|
|
3580
3580
|
constructor(t, n) {
|
|
3581
|
-
|
|
3582
|
-
|
|
3581
|
+
l(this, "config");
|
|
3582
|
+
l(this, "impersonationOpts");
|
|
3583
3583
|
/**
|
|
3584
3584
|
* Uploads file at the provided path. Accepts a Buffer or a Readable stream.
|
|
3585
3585
|
*
|
|
@@ -3588,7 +3588,7 @@ class mn {
|
|
|
3588
3588
|
* const buffer = fs.readFileSync('demo.png');
|
|
3589
3589
|
* const isSuccess = await db.storage.uploadFile('photos/demo.png', buffer);
|
|
3590
3590
|
*/
|
|
3591
|
-
|
|
3591
|
+
l(this, "uploadFile", async (t, n, s = {}) => {
|
|
3592
3592
|
const r = {
|
|
3593
3593
|
...P(this.config, this.impersonationOpts),
|
|
3594
3594
|
path: t
|
|
@@ -3621,7 +3621,7 @@ class mn {
|
|
|
3621
3621
|
*
|
|
3622
3622
|
* @see https://instantdb.com/docs/storage
|
|
3623
3623
|
*/
|
|
3624
|
-
|
|
3624
|
+
l(this, "delete", async (t) => A(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}&filename=${encodeURIComponent(t)}`, {
|
|
3625
3625
|
method: "DELETE",
|
|
3626
3626
|
headers: P(this.config, this.impersonationOpts)
|
|
3627
3627
|
}));
|
|
@@ -3636,7 +3636,7 @@ class mn {
|
|
|
3636
3636
|
*
|
|
3637
3637
|
* @see https://instantdb.com/docs/storage
|
|
3638
3638
|
*/
|
|
3639
|
-
|
|
3639
|
+
l(this, "deleteMany", async (t) => A(`${this.config.apiURI}/admin/storage/files/delete?app_id=${this.config.appId}`, {
|
|
3640
3640
|
method: "POST",
|
|
3641
3641
|
headers: P(this.config, this.impersonationOpts),
|
|
3642
3642
|
body: JSON.stringify({ filenames: t })
|
|
@@ -3645,7 +3645,7 @@ class mn {
|
|
|
3645
3645
|
* @deprecated. This method will be removed in the future. Use `uploadFile`
|
|
3646
3646
|
* instead
|
|
3647
3647
|
*/
|
|
3648
|
-
|
|
3648
|
+
l(this, "upload", async (t, n, s = {}) => {
|
|
3649
3649
|
const { data: r } = await A(`${this.config.apiURI}/admin/storage/signed-upload-url?app_id=${this.config.appId}`, {
|
|
3650
3650
|
method: "POST",
|
|
3651
3651
|
headers: P(this.config),
|
|
@@ -3667,7 +3667,7 @@ class mn {
|
|
|
3667
3667
|
* @example
|
|
3668
3668
|
* const files = await db.query({ $files: {}})
|
|
3669
3669
|
*/
|
|
3670
|
-
|
|
3670
|
+
l(this, "list", async () => {
|
|
3671
3671
|
const { data: t } = await A(`${this.config.apiURI}/admin/storage/files?app_id=${this.config.appId}`, {
|
|
3672
3672
|
method: "GET",
|
|
3673
3673
|
headers: P(this.config)
|
|
@@ -3688,7 +3688,7 @@ class mn {
|
|
|
3688
3688
|
* }
|
|
3689
3689
|
* })
|
|
3690
3690
|
*/
|
|
3691
|
-
|
|
3691
|
+
l(this, "getDownloadUrl", async (t) => {
|
|
3692
3692
|
const { data: n } = await A(`${this.config.apiURI}/admin/storage/signed-download-url?app_id=${this.config.appId}&filename=${encodeURIComponent(t)}`, {
|
|
3693
3693
|
method: "GET",
|
|
3694
3694
|
headers: P(this.config)
|
|
@@ -3711,7 +3711,7 @@ class Sr {
|
|
|
3711
3711
|
* console.log(chunk);
|
|
3712
3712
|
* }
|
|
3713
3713
|
*/
|
|
3714
|
-
|
|
3714
|
+
l(this, "createReadStream", (t) => y(this, Le).call(this).createReadStream(t));
|
|
3715
3715
|
/**
|
|
3716
3716
|
* Creates a new WritableStream for the given clientId.
|
|
3717
3717
|
*
|
|
@@ -3721,7 +3721,7 @@ class Sr {
|
|
|
3721
3721
|
* writer.write('Hello world');
|
|
3722
3722
|
* writer.close();
|
|
3723
3723
|
*/
|
|
3724
|
-
|
|
3724
|
+
l(this, "createWriteStream", (t) => y(this, Le).call(this).createWriteStream(t));
|
|
3725
3725
|
J(this, Le, t);
|
|
3726
3726
|
}
|
|
3727
3727
|
}
|
|
@@ -3736,22 +3736,22 @@ function Ir(e) {
|
|
|
3736
3736
|
}
|
|
3737
3737
|
};
|
|
3738
3738
|
}
|
|
3739
|
-
var H, Oe, q, B, W, Ln, at, Fn, zn, Vn,
|
|
3739
|
+
var H, Oe, q, B, W, Ln, at, Fn, zn, Vn, lt, dt, ht, Ft, Jn, pt;
|
|
3740
3740
|
const Bt = class Bt {
|
|
3741
3741
|
constructor(t) {
|
|
3742
3742
|
j(this, W);
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3743
|
+
l(this, "config");
|
|
3744
|
+
l(this, "auth");
|
|
3745
|
+
l(this, "storage");
|
|
3746
|
+
l(this, "streams");
|
|
3747
|
+
l(this, "rooms");
|
|
3748
|
+
l(this, "impersonationOpts");
|
|
3749
|
+
l(this, "webhooks");
|
|
3750
3750
|
j(this, H, null);
|
|
3751
3751
|
j(this, Oe, 0);
|
|
3752
3752
|
j(this, q, null);
|
|
3753
3753
|
j(this, B);
|
|
3754
|
-
|
|
3754
|
+
l(this, "tx", En());
|
|
3755
3755
|
/**
|
|
3756
3756
|
* Sometimes you want to scope queries to a specific user.
|
|
3757
3757
|
*
|
|
@@ -3761,7 +3761,7 @@ const Bt = class Bt {
|
|
|
3761
3761
|
* @example
|
|
3762
3762
|
* await db.asUser({email: "stopa@instantdb.com"}).query({ goals: {} })
|
|
3763
3763
|
*/
|
|
3764
|
-
|
|
3764
|
+
l(this, "asUser", (t) => {
|
|
3765
3765
|
const n = new Bt({
|
|
3766
3766
|
...this.config
|
|
3767
3767
|
});
|
|
@@ -3782,7 +3782,7 @@ const Bt = class Bt {
|
|
|
3782
3782
|
* // all goals, _alongside_ their todos
|
|
3783
3783
|
* await db.query({ goals: { todos: {} } })
|
|
3784
3784
|
*/
|
|
3785
|
-
|
|
3785
|
+
l(this, "query", (t, n = {}) => {
|
|
3786
3786
|
t && n && "ruleParams" in n && (t = { $$ruleParams: n.ruleParams, ...t }), this.config.disableValidation || sn(t, this.config.schema);
|
|
3787
3787
|
const s = n.fetchOpts || {}, r = s.headers || {};
|
|
3788
3788
|
return A(`${this.config.apiURI}/admin/query?app_id=${this.config.appId}`, {
|
|
@@ -3821,7 +3821,7 @@ const Bt = class Bt {
|
|
|
3821
3821
|
* db.tx.goals[goalId].link({todos: todoId}),
|
|
3822
3822
|
* ])
|
|
3823
3823
|
*/
|
|
3824
|
-
|
|
3824
|
+
l(this, "transact", (t) => (this.config.disableValidation || Os(t, this.config.schema), A(`${this.config.apiURI}/admin/transact?app_id=${this.config.appId}`, {
|
|
3825
3825
|
method: "POST",
|
|
3826
3826
|
headers: P(this.config, this.impersonationOpts),
|
|
3827
3827
|
body: JSON.stringify({
|
|
@@ -3850,7 +3850,7 @@ const Bt = class Bt {
|
|
|
3850
3850
|
* { rules: { goals: { allow: { read: "auth.id != null" } } }
|
|
3851
3851
|
* )
|
|
3852
3852
|
*/
|
|
3853
|
-
|
|
3853
|
+
l(this, "debugQuery", async (t, n) => {
|
|
3854
3854
|
t && n && "ruleParams" in n && (t = { $$ruleParams: n.ruleParams, ...t });
|
|
3855
3855
|
const s = {
|
|
3856
3856
|
query: t,
|
|
@@ -3886,7 +3886,7 @@ const Bt = class Bt {
|
|
|
3886
3886
|
* { rules: { goals: { allow: { update: "auth.id != null" } } }
|
|
3887
3887
|
* )
|
|
3888
3888
|
*/
|
|
3889
|
-
|
|
3889
|
+
l(this, "debugTransact", (t, n) => {
|
|
3890
3890
|
const s = {
|
|
3891
3891
|
steps: pn(t),
|
|
3892
3892
|
"rules-override": n == null ? void 0 : n.rules,
|
|
@@ -3899,7 +3899,7 @@ const Bt = class Bt {
|
|
|
3899
3899
|
body: JSON.stringify(s)
|
|
3900
3900
|
});
|
|
3901
3901
|
});
|
|
3902
|
-
j(this,
|
|
3902
|
+
j(this, lt, (t) => {
|
|
3903
3903
|
var n;
|
|
3904
3904
|
if (t.target !== y(this, H)) {
|
|
3905
3905
|
y(this, B).info("[socket][open]", t.target.id, "skip; this is no longer the current transport");
|
|
@@ -3907,7 +3907,7 @@ const Bt = class Bt {
|
|
|
3907
3907
|
}
|
|
3908
3908
|
y(this, B).info("[socket][open]", t.target.id), J(this, Oe, 0), (n = y(this, q)) == null || n.onConnectionStatusChange("authenticated");
|
|
3909
3909
|
});
|
|
3910
|
-
j(this,
|
|
3910
|
+
j(this, dt, (t) => {
|
|
3911
3911
|
var n;
|
|
3912
3912
|
if (t.target !== y(this, H)) {
|
|
3913
3913
|
y(this, B).info("[socket][close]", t.target.id, "skip; this is no longer the current transport");
|
|
@@ -4017,7 +4017,7 @@ H = new WeakMap(), Oe = new WeakMap(), q = new WeakMap(), B = new WeakMap(), W =
|
|
|
4017
4017
|
const t = {
|
|
4018
4018
|
...P(this.config, this.impersonationOpts)
|
|
4019
4019
|
}, n = !!this.config.schema, s = yr({ headers: t, inference: n }), r = new _s(s, `${this.config.apiURI}/admin/sse?app_id=${this.config.appId}`, `${this.config.apiURI}/admin/sse/push?app_id=${this.config.appId}`);
|
|
4020
|
-
return r.onopen = y(this,
|
|
4020
|
+
return r.onopen = y(this, lt), r.onmessage = y(this, pt), r.onclose = y(this, dt), r.onerror = y(this, ht), J(this, H, r), r;
|
|
4021
4021
|
}, at = function() {
|
|
4022
4022
|
return y(this, H) || R(this, W, Ln).call(this);
|
|
4023
4023
|
}, Fn = function(t, n) {
|
|
@@ -4038,7 +4038,7 @@ H = new WeakMap(), Oe = new WeakMap(), q = new WeakMap(), B = new WeakMap(), W =
|
|
|
4038
4038
|
return J(this, q, t), t;
|
|
4039
4039
|
}, Vn = function() {
|
|
4040
4040
|
return y(this, q) || R(this, W, zn).call(this);
|
|
4041
|
-
},
|
|
4041
|
+
}, lt = new WeakMap(), dt = new WeakMap(), ht = new WeakMap(), Ft = function() {
|
|
4042
4042
|
return !y(this, q) || !y(this, q).hasActiveStreams();
|
|
4043
4043
|
}, Jn = function() {
|
|
4044
4044
|
if (y(this, H) && R(this, W, Ft).call(this)) {
|
|
@@ -4079,9 +4079,9 @@ function $r(e) {
|
|
|
4079
4079
|
const s = { appId: t, adminToken: n }, r = e.apiURI || et.INSTANT_API_URI;
|
|
4080
4080
|
r && (s.apiURI = r), e.verbose && (s.verbose = e.verbose);
|
|
4081
4081
|
const o = mr(s);
|
|
4082
|
-
async function i(
|
|
4082
|
+
async function i(d, f, p) {
|
|
4083
4083
|
const m = o.streams.createWriteStream({
|
|
4084
|
-
clientId:
|
|
4084
|
+
clientId: d,
|
|
4085
4085
|
waitUntil: e.waitUntil ?? void 0
|
|
4086
4086
|
});
|
|
4087
4087
|
try {
|
|
@@ -4092,15 +4092,15 @@ function $r(e) {
|
|
|
4092
4092
|
tt(p)
|
|
4093
4093
|
) : h;
|
|
4094
4094
|
} catch {
|
|
4095
|
-
const w = o.streams.createReadStream({ clientId:
|
|
4095
|
+
const w = o.streams.createReadStream({ clientId: d });
|
|
4096
4096
|
return p ? w.pipeThrough(
|
|
4097
4097
|
tt(p)
|
|
4098
4098
|
) : w;
|
|
4099
4099
|
}
|
|
4100
4100
|
}
|
|
4101
|
-
async function a(
|
|
4101
|
+
async function a(d, f) {
|
|
4102
4102
|
var m, g, w;
|
|
4103
|
-
const p = o.streams.createReadStream({ clientId:
|
|
4103
|
+
const p = o.streams.createReadStream({ clientId: d });
|
|
4104
4104
|
try {
|
|
4105
4105
|
await p.streamId();
|
|
4106
4106
|
} catch (h) {
|
|
@@ -4110,19 +4110,19 @@ function $r(e) {
|
|
|
4110
4110
|
}
|
|
4111
4111
|
return f ? p.pipeThrough(tt(f)) : p;
|
|
4112
4112
|
}
|
|
4113
|
-
async function c(
|
|
4113
|
+
async function c(d, f, p) {
|
|
4114
4114
|
const m = f(), g = o.streams.createWriteStream({
|
|
4115
|
-
clientId:
|
|
4115
|
+
clientId: d,
|
|
4116
4116
|
waitUntil: e.waitUntil ?? void 0
|
|
4117
4117
|
});
|
|
4118
4118
|
await g.streamId(), m.pipeTo(g);
|
|
4119
|
-
const w = o.streams.createReadStream({ clientId:
|
|
4119
|
+
const w = o.streams.createReadStream({ clientId: d });
|
|
4120
4120
|
return p ? w.pipeThrough(tt(p)) : w;
|
|
4121
4121
|
}
|
|
4122
|
-
async function u(
|
|
4122
|
+
async function u(d) {
|
|
4123
4123
|
var m;
|
|
4124
4124
|
const f = await o.query({
|
|
4125
|
-
$streams: { $: { where: { clientId:
|
|
4125
|
+
$streams: { $: { where: { clientId: d } } }
|
|
4126
4126
|
}), p = (m = f == null ? void 0 : f.$streams) == null ? void 0 : m[0];
|
|
4127
4127
|
return p != null && p.done ? "DONE" : p ? !0 : null;
|
|
4128
4128
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function($,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):($=typeof globalThis<"u"?globalThis:$||self,E($.instant={}))})(this,function($){"use strict";var Ir=Object.defineProperty;var Ln=$=>{throw TypeError($)};var vr=($,E,A)=>E in $?Ir($,E,{enumerable:!0,configurable:!0,writable:!0,value:A}):$[E]=A;var d=($,E,A)=>vr($,typeof E!="symbol"?E+"":E,A),Qt=($,E,A)=>E.has($)||Ln("Cannot "+A);var y=($,E,A)=>(Qt($,E,"read from private field"),A?A.call($):E.get($)),L=($,E,A)=>E.has($)?Ln("Cannot add the same private member more than once"):E instanceof WeakSet?E.add($):E.set($,A),B=($,E,A,D)=>(Qt($,E,"write to private field"),D?D.call($,A):E.set($,A),A),M=($,E,A)=>(Qt($,E,"access private method"),A);var G,Ye,Le,Fe,Ze,ne,fe,et,Ce,ze,H,Te,X,Y,z,zn,bt,Vn,Jn,Hn,lt,ht,pt,Gt,Kn,yt;const E=/^(?:[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;function A(e){return typeof e=="string"&&E.test(e)}const D=[];for(let e=0;e<256;++e)D.push((e+256).toString(16).slice(1));function qn(e,t=0){return(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase()}let wt;const Bn=new Uint8Array(16);function Qn(){if(!wt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");wt=crypto.getRandomValues.bind(crypto)}return wt(Bn)}const Xt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Gn(e,t,n){var r;if(Xt.randomUUID&&!e)return Xt.randomUUID();e=e||{};const s=e.random??((r=e.rng)==null?void 0:r.call(e))??Qn();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,qn(s)}const F={Remove:"remove",Replace:"replace",Add:"add"},Yt=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),tt=Symbol.iterator,ie={mutable:"mutable",immutable:"immutable"},gt={};function Je(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Zt(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const s=Reflect.getOwnPropertyDescriptor(n,t);if(s)return s;n=Reflect.getPrototypeOf(n)}}}function en(e){return Object.getPrototypeOf(e)===Set.prototype}function tn(e){return Object.getPrototypeOf(e)===Map.prototype}function te(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function St(e){return!!O(e)}function O(e){return typeof e!="object"?null:e==null?void 0:e[Yt]}function It(e){var t;const n=O(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function ke(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(t!=null&&t.mark)&&((n=t.mark(e,ie))===ie.immutable||typeof n=="function")}function nn(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,s=O(be(n,e.key));if(s!==null&&(s==null?void 0:s.original)!==e.original)return null;const r=e.parent.type===3,o=r?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(r&&n.size>o||Je(n,o)))return null;t.push(o)}if(e.parent)return nn(e.parent,t);t.reverse();try{Xn(e.copy,t)}catch{return null}return t}function He(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function be(e,t){return He(e)===2?e.get(t):e[t]}function vt(e,t,n){He(e)===2?e.set(t,n):e[t]=n}function kt(e,t){const n=O(e);return(n?te(n):e)[t]}function $e(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Oe(e,t){return t?e:[""].concat(e).map(n=>{const s=`${n}`;return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Xn(e,t){for(let n=0;n<t.length-1;n+=1){const s=t[n];if(e=be(He(e)===3?Array.from(e):e,s),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function Yn(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let s=Reflect.getOwnPropertyDescriptor(e,n);if(s.enumerable&&s.configurable&&s.writable){t[n]=e[n];return}s.writable||(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(s={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]}),Reflect.defineProperty(t,n,s)}),t}const Zn=Object.prototype.propertyIsEnumerable;function es(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!en(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!tn(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e)}return new Map(e)}else if(t!=null&&t.mark&&(n=t.mark(e,ie),n!==void 0)&&n!==ie.mutable){if(n===ie.immutable)return Yn(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){const s={};return Object.keys(e).forEach(r=>{s[r]=e[r]}),Object.getOwnPropertySymbols(e).forEach(r=>{Zn.call(e,r)&&(s[r]=e[r])}),s}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=es(e.original,e.options))}function Ke(e){if(!ke(e))return It(e);if(Array.isArray(e))return e.map(Ke);if(e instanceof Map){const n=Array.from(e.entries()).map(([s,r])=>[s,Ke(r)]);if(!tn(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Map(n)}if(e instanceof Set){const n=Array.from(e).map(Ke);if(!en(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Set(n)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Ke(e[n]);return t}function nt(e){return St(e)?Ke(e):e}function de(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&de(e.parent))}function ts(e,t){const n=He(e);if(n===0)Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)});else if(n===1){let s=0;for(const r of e)t(s,r,e),s+=1}else e.forEach((s,r)=>t(r,s,e))}function sn(e,t,n){if(St(e)||!ke(e,n)||t.has(e)||Object.isFrozen(e))return;const s=e instanceof Set,r=s?new Map:void 0;if(t.add(e),ts(e,(o,i)=>{var a;if(St(i)){const c=O(i);Q(c);const u=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;vt(s?r:e,o,u)}else sn(i,t,n)}),r){const o=e,i=Array.from(o);o.clear(),i.forEach(a=>{o.add(r.has(a)?r.get(a):a)})}}function ns(e,t){const n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&sn(be(n,t),e.finalities.handledSet,e.options)}function $t(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(It(t))}))}function Ot(e,t,n,s){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&s){const o=nn(e);o&&t(e,o,n,s)}e.finalized=!0}}function Et(e,t,n,s){const r=O(n);r&&(r.callbacks||(r.callbacks=[]),r.callbacks.push((o,i)=>{var a;const c=e.type===3?e.setMap:e.copy;if($e(be(c,t),n)){let u=r.original;r.copy&&(u=r.copy),$t(e),Ot(e,s,o,i),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(u,r.original)),vt(c,t,u)}}),e.options.enableAutoFreeze&&r.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),ke(n,e.options)&&e.finalities.draft.push(()=>{const o=e.type===3?e.setMap:e.copy;$e(be(o,t),n)&&ns(e,t)})}function ss(e,t,n,s,r){let{original:o,assignedMap:i,options:a}=e,c=e.copy;c.length<o.length&&([o,c]=[c,o],[n,s]=[s,n]);for(let u=0;u<o.length;u+=1)if(i.get(u.toString())&&c[u]!==o[u]){const l=t.concat([u]),f=Oe(l,r);n.push({op:F.Replace,path:f,value:nt(c[u])}),s.push({op:F.Replace,path:f,value:nt(o[u])})}for(let u=o.length;u<c.length;u+=1){const l=t.concat([u]),f=Oe(l,r);n.push({op:F.Add,path:f,value:nt(c[u])})}if(o.length<c.length){const{arrayLengthAssignment:u=!0}=a.enablePatches;if(u){const l=t.concat(["length"]),f=Oe(l,r);s.push({op:F.Replace,path:f,value:o.length})}else for(let l=c.length;o.length<l;l-=1){const f=t.concat([l-1]),p=Oe(f,r);s.push({op:F.Remove,path:p})}}}function rs({original:e,copy:t,assignedMap:n},s,r,o,i){n.forEach((a,c)=>{const u=be(e,c),l=nt(be(t,c)),f=a?Je(e,c)?F.Replace:F.Add:F.Remove;if($e(u,l)&&f===F.Replace)return;const p=s.concat(c),m=Oe(p,i);r.push(f===F.Remove?{op:f,path:m}:{op:f,path:m,value:l}),o.push(f===F.Add?{op:F.Remove,path:m}:f===F.Remove?{op:F.Add,path:m,value:u}:{op:F.Replace,path:m,value:u})})}function is({original:e,copy:t},n,s,r,o){let i=0;e.forEach(a=>{if(!t.has(a)){const c=n.concat([i]),u=Oe(c,o);s.push({op:F.Remove,path:u,value:a}),r.unshift({op:F.Add,path:u,value:a})}i+=1}),i=0,t.forEach(a=>{if(!e.has(a)){const c=n.concat([i]),u=Oe(c,o);s.push({op:F.Add,path:u,value:a}),r.unshift({op:F.Remove,path:u,value:a})}i+=1})}function qe(e,t,n,s){const{pathAsArray:r=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return rs(e,t,n,s,r);case 1:return ss(e,t,n,s,r);case 3:return is(e,t,n,s,r)}}const st=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!ke(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},_t={get size(){return te(O(this)).size},has(e){return te(O(this)).has(e)},set(e,t){const n=O(this),s=te(n);return(!s.has(e)||!$e(s.get(e),t))&&(Q(n),de(n),n.assignedMap.set(e,!0),n.copy.set(e,t),Et(n,e,t,qe)),this},delete(e){if(!this.has(e))return!1;const t=O(this);return Q(t),de(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=O(this);if(this.size){Q(e),de(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){const n=O(this);te(n).forEach((s,r)=>{e.call(t,this.get(r),r,this)})},get(e){var t,n;const s=O(this),r=te(s).get(e),o=((n=(t=s.options).mark)===null||n===void 0?void 0:n.call(t,r,ie))===ie.mutable;if(s.options.strict&&st(r,s.options,o),o||s.finalized||!ke(r,s.options)||r!==s.original.get(e))return r;const i=gt.createDraft({original:r,parentDraft:s,key:e,finalities:s.finalities,options:s.options});return Q(s),s.copy.set(e,i),i},keys(){return te(O(this)).keys()},values(){const e=this.keys();return{[tt]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[tt]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[tt](){return this.entries()}},os=Reflect.ownKeys(_t),rn=(e,t,{isValuesIterator:n})=>()=>{var s,r;const o=t.next();if(o.done)return o;const i=o.value;let a=e.setMap.get(i);const c=O(a),u=((r=(s=e.options).mark)===null||r===void 0?void 0:r.call(s,a,ie))===ie.mutable;if(e.options.strict&&st(i,e.options,u),!u&&!c&&ke(i,e.options)&&!e.finalized&&e.original.has(i)){const l=gt.createDraft({original:i,parentDraft:e,key:i,finalities:e.finalities,options:e.options});e.setMap.set(i,l),a=l}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},rt={get size(){return O(this).setMap.size},has(e){const t=O(this);if(t.setMap.has(e))return!0;Q(t);const n=O(e);return!!(n&&t.setMap.has(n.original))},add(e){const t=O(this);return this.has(e)||(Q(t),de(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),Et(t,e,e,qe)),this},delete(e){if(!this.has(e))return!1;const t=O(this);Q(t),de(t);const n=O(e);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))},clear(){if(!this.size)return;const e=O(this);Q(e),de(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=O(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:rn(e,t,{isValuesIterator:!0})}},entries(){const e=O(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:rn(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[tt](){return this.values()},forEach(e,t){const n=this.values();let s=n.next();for(;!s.done;)e.call(t,s.value,s.value,this),s=n.next()}};Set.prototype.difference&&Object.assign(rt,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const as=Reflect.ownKeys(rt),on=new WeakSet,an={get(e,t,n){var s,r;const o=(s=e.copy)===null||s===void 0?void 0:s[t];if(o&&on.has(o))return o;if(t===Yt)return e;let i;if(e.options.mark){const u=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(i=e.options.mark(u,ie),i===ie.mutable)return e.options.strict&&st(u,e.options,!0),u}const a=te(e);if(a instanceof Map&&os.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(_t,"size").get.call(e.proxy);const u=_t[t];if(u)return u.bind(e.proxy)}if(a instanceof Set&&as.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(rt,"size").get.call(e.proxy);const u=rt[t];if(u)return u.bind(e.proxy)}if(!Je(a,t)){const u=Zt(a,t);return u?"value"in u?u.value:(r=u.get)===null||r===void 0?void 0:r.call(e.proxy):void 0}const c=a[t];if(e.options.strict&&st(c,e.options),e.finalized||!ke(c,e.options))return c;if(c===kt(e.original,t)){if(Q(e),e.copy[t]=cn({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof i=="function"){const u=O(e.copy[t]);return Q(u),de(u),u.copy}return e.copy[t]}return c},set(e,t,n){var s;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let r;if(e.type===1&&t!=="length"&&!(Number.isInteger(r=Number(t))&&r>=0&&(t===0||r===0||String(r)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const o=Zt(te(e),t);if(o!=null&&o.set)return o.set.call(e.proxy,n),!0;const i=kt(te(e),t),a=O(i);return a&&$e(a.original,n)?(e.copy[t]=n,e.assignedMap=(s=e.assignedMap)!==null&&s!==void 0?s:new Map,e.assignedMap.set(t,!1),!0):($e(n,i)&&(n!==void 0||Je(e.original,t))||(Q(e),de(e),Je(e.original,t)&&$e(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,Et(e,t,n,qe)),!0)},has(e,t){return t in te(e)},ownKeys(e){return Reflect.ownKeys(te(e))},getOwnPropertyDescriptor(e,t){const n=te(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?an.set.call(this,e,t,void 0,e.proxy):(kt(e.original,t)!==void 0||t in e.original?(Q(e),de(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function cn(e){const{original:t,parentDraft:n,key:s,finalities:r,options:o}=e,i=He(t),a={type:i,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:r,options:o,setMap:i===3?new Map(t.entries()):void 0};(s||"key"in e)&&(a.key=s);const{proxy:c,revoke:u}=Proxy.revocable(i===1?Object.assign([],a):a,an);if(r.revoke.push(u),on.add(c),a.proxy=c,n){const l=n;l.finalities.draft.push((f,p)=>{var m,g;const w=O(c);let h=l.type===3?l.setMap:l.copy;const v=be(h,s),k=O(v);if(k){let K=k.original;k.operated&&(K=It(v)),$t(k),Ot(k,qe,f,p),l.options.enableAutoFreeze&&(l.options.updatedValues=(m=l.options.updatedValues)!==null&&m!==void 0?m:new WeakMap,l.options.updatedValues.set(K,k.original)),vt(h,s,K)}(g=w.callbacks)===null||g===void 0||g.forEach(K=>{K(f,p)})})}else{const l=O(c);l.finalities.draft.push((f,p)=>{$t(l),Ot(l,qe,f,p)})}return c}gt.createDraft=cn,Object.prototype.constructor.toString();function Ae(){return Gn()}function cs(e,t){return e.localeCompare(t)}function us(){let e=cs;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{e=Intl.Collator("en-US").compare}catch{}return e}us();function fs(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const ds=fs();function it(e,t,n){const s={__etype:e,__ops:n};return new Proxy(s,{get:(r,o)=>{if(o==="__ops")return n;if(o==="__etype")return e;if(ds.has(o))return(i,a)=>it(e,t,[...n,a?[o,e,t,i,a]:[o,e,t,i]])}})}function ls(e,t){return`lookup__${e}__${JSON.stringify(t)}`}function un(e){return e.startsWith("lookup__")}function fn(e){const[t,n,...s]=e.split("__");return[n,JSON.parse(s.join("__"))]}function hs(e){return new Proxy({__etype:e},{get(t,n){if(n==="lookup")return(r,o)=>it(e,fn(ls(r,o)),[]);if(n==="__etype")return e;const s=n;return un(s)?it(e,fn(s),[]):it(e,s,[])}})}function dn(){return new Proxy({},{get(e,t){return hs(t)}})}dn();function ps(e){return e.__ops}class C extends Error{constructor(n,s,r){super(n);d(this,"hint");d(this,"traceId");this.hint=s,r&&(this.traceId=r);const o=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,o),Error.captureStackTrace&&Error.captureStackTrace(this,C),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class le extends C{constructor(n){var o,i;const s=((o=n.body)==null?void 0:o.message)||`API Error (${n.status})`;super(s,n.body.hint,((i=n.body)==null?void 0:i.traceId)||n.body["trace-id"]);d(this,"body");d(this,"status");const r=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,r),Error.captureStackTrace&&Error.captureStackTrace(this,le),this.name="InstantAPIError",this.status=n.status,this.body=n.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ee="v1.0.39";class he{constructor(t,n,s,r={indexed:!1,unique:!1}){d(this,"valueType");d(this,"required");d(this,"isIndexed");d(this,"config");d(this,"metadata",{});this.valueType=t,this.required=n,this.isIndexed=s,this.config=r}clientRequired(){return new he(this.valueType,!1,this.isIndexed,this.config)}optional(){return new he(this.valueType,!1,this.isIndexed,this.config)}unique(){return new he(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new he(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class x extends Error{constructor(t,n){const s=n?`At path '${n}': ${t}`:t;super(s),this.name="QueryValidationError"}}const ln=["where","order","limit","last","first","offset","after","afterInclusive","before","beforeInclusive","fields","aggregate"],ys=e=>e.valueType||"unknown",hn=(e,t,n=!1)=>{if(n||e==null)return!0;switch(t){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!isNaN(e);case"boolean":return typeof e=="boolean";case"date":return e instanceof Date||typeof e=="string"||typeof e=="number";default:return!0}},ms=(e,t,n,s,r,o,i)=>{const a=o.valueType==="json",c=(u,l,f)=>{if(!hn(f,l,a))throw new x(`Invalid value for operator '${u}' on attribute '${s}' in entity '${r}'. Expected ${l}, but received: ${typeof f}`,i)};switch(e){case"in":case"$in":if(!Array.isArray(t))throw new x(`Operator '${e}' for attribute '${s}' in entity '${r}' must be an array, but received: ${typeof t}`,i);for(const u of t)c(e,n,u);break;case"$not":case"$ne":case"$gt":case"$lt":case"$gte":case"$lte":c(e,n,t);break;case"$like":case"$ilike":if(c(e,"string",t),e==="$ilike"&&!o.isIndexed)throw new x(`Operator '${e}' can only be used with indexed attributes, but '${s}' in entity '${r}' is not indexed`,i);break;case"$isNull":c(e,"boolean",t);break;default:throw new x(`Unknown operator '${e}' for attribute '${s}' in entity '${r}'`,i)}},Pe=(e,t,n,s,r)=>{const o=ys(n),i=n.valueType==="json";if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(i)return;const c=e;for(const[u,l]of Object.entries(c))ms(u,l,o,t,s,n,`${r}.${u}`)}else if(!hn(e,o,i))throw new x(`Invalid value for attribute '${t}' in entity '${s}'. Expected ${o}, but received: ${typeof e}`,r)},bs=(e,t,n,s,r)=>{const o=e.split(".");if(o.length<2)throw new x(`Invalid dot notation path '${e}'. Must contain at least one dot.`,r);let i=n;for(let l=0;l<o.length-1;l++){const f=o[l],p=s.entities[i];if(!p)throw new x(`Entity '${i}' does not exist in schema while traversing dot notation path '${e}'.`,r);const m=p.links[f];if(!m){const g=Object.keys(p.links);throw new x(`Link '${f}' does not exist on entity '${i}' in dot notation path '${e}'. Available links: ${g.length>0?g.join(", "):"none"}`,r)}i=m.entityName}const a=o[o.length-1],c=s.entities[i];if(!c)throw new x(`Target entity '${i}' does not exist in schema for dot notation path '${e}'.`,r);if(a==="id"){if(typeof t=="string"&&!A(t))throw new x(`Invalid value for id field in entity '${i}'. Expected a UUID, but received: ${t}`,r);Pe(t,e,new he("string",!1,!0),n,r);return}const u=c.attrs[a];if(Object.keys(c.links).includes(a)){if(typeof t=="string"&&!A(t))throw new x(`Invalid value for link '${a}' in entity '${i}'. Expected a UUID, but received: ${t}`,r);Pe(t,e,new he("string",!1,!0),n,r);return}if(!u){const l=Object.keys(c.attrs);throw new x(`Attribute '${a}' does not exist on entity '${i}' in dot notation path '${e}'. Available attributes: ${l.length>0?l.join(", ")+", id":"id"}`,r)}Pe(t,e,u,n,r)},pn=(e,t,n,s)=>{for(const[r,o]of Object.entries(e)){if(r==="or"||r==="and"){if(Array.isArray(o))for(const u of o)typeof u=="object"&&u!==null&&pn(u,t,n,`${s}.${r}[${u}]`);continue}if(r==="id"){Pe(o,"id",new he("string",!1,!0),t,`${s}.id`);continue}if(r.includes(".")){bs(r,o,t,n,`${s}.${r}`);continue}const i=n.entities[t];if(!i)continue;const a=i.attrs[r],c=i.links[r];if(!a&&!c){const u=Object.keys(i.attrs),l=Object.keys(i.links);throw new x(`Attribute or link '${r}' does not exist on entity '${t}'. Available attributes: ${u.length>0?u.join(", "):"none"}. Available links: ${l.length>0?l.join(", "):"none"}`,`${s}.${r}`)}if(a)Pe(o,r,a,t,`${s}.${r}`);else if(c){if(typeof o=="string"&&!A(o))throw new x(`Invalid value for link '${r}' in entity '${t}'. Expected a UUID, but received: ${o}`,`${s}.${r}`);const u=new he("string",!1,!0);Pe(o,r,u,t,`${s}.${r}`)}}},ws=(e,t,n,s,r=0)=>{for(const i of Object.keys(e))if(!ln.includes(i))throw new x(`Invalid query parameter '${i}' in $ object. Valid parameters are: ${ln.join(", ")}. Found: ${i}`,s);const o=["offset","before","beforeInclusive","after","afterInclusive","first","last"];for(const i of o)if(e[i]!==void 0&&r>0)throw new x(`'${i}' can only be used on top-level namespaces. It cannot be used in nested queries.`,s);if(e.where&&n){if(typeof e.where!="object"||e.where===null)throw new x(`'where' clause must be an object in entity '${t}', but received: ${typeof e.where}`,s?`${s}.where`:void 0);pn(e.where,t,n,s?`${s}.where`:"where")}},yn=(e,t,n,s,r=0)=>{var o;if(!e||typeof e!="object")throw new x(`Query part for entity '${t}' must be an object, but received: ${typeof e}`,s);for(const i of Object.keys(e))if(i!=="$"){if(n&&!(i in n.entities[t].links)){const c=Object.keys(n.entities[t].links);throw new x(`Link '${i}' does not exist on entity '${t}'. Available links: ${c.length>0?c.join(", "):"none"}`,`${s}.${i}`)}const a=e[i];if(typeof a=="object"&&a!==null){const c=(o=n==null?void 0:n.entities[t].links[i])==null?void 0:o.entityName;c&&yn(a,c,n,`${s}.${i}`,r+1)}}else{const a=e[i];if(typeof a!="object"||a===null)throw new x(`Query parameter '$' must be an object in entity '${t}', but received: ${typeof a}`,`${s}.$`);ws(a,t,n,`${s}.$`,r)}},mn=(e,t)=>{if(typeof e!="object"||e===null)throw new x(`Query must be an object, but received: ${typeof e}${e===null?" (null)":""}`);if(Array.isArray(e))throw new x(`Query must be an object, but received: ${typeof e}`);const n=e;for(const s of Object.keys(n)){if(Array.isArray(e[s]))throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(typeof s!="string")throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(s!=="$$ruleParams"){if(t&&!t.entities[s]){const r=Object.keys(t.entities);throw new x(`Entity '${s}' does not exist in schema. Available entities: ${r.length>0?r.join(", "):"none"}`,s)}yn(n[s],s,t,s,0)}}},bn=e=>typeof e!="string"?!1:un(e)?!0:A(e);class se extends Error{constructor(t){super(t),this.name="TransactionValidationError"}}const wn=e=>e.length>0?e.join(", "):"none",gs=(e,t)=>new se(`Entity '${e}' does not exist in schema. Available entities: ${wn(t)}`),Ct={string:e=>typeof e=="string",number:e=>typeof e=="number"&&!isNaN(e),boolean:e=>typeof e=="boolean",date:e=>e instanceof Date||typeof e=="string"||typeof e=="number",json:()=>!0},Ss=(e,t)=>{var n;return e==null?!0:((n=Ct[t.valueType])==null?void 0:n.call(Ct,e))??!1},gn=(e,t)=>{const n=t.entities[e];if(!n)throw gs(e,Object.keys(t.entities));return n},Tt=(e,t,n)=>{const s=gn(e,n);if(typeof t!="object"||t===null)throw new se(`Arguments for data operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[r,o]of Object.entries(t)){if(r==="id")continue;const i=s.attrs[r];if(i&&!Ss(o,i))throw new se(`Invalid value for attribute '${r}' in entity '${e}'. Expected ${i.valueType}, but received: ${typeof o}`)}},Sn=(e,t,n)=>{const s=gn(e,n);if(typeof t!="object"||t===null)throw new se(`Arguments for link operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[r,o]of Object.entries(t)){if(!s.links[r]){const a=Object.keys(s.links);throw new se(`Link '${r}' does not exist on entity '${e}'. Available links: ${wn(a)}`)}if(o!=null){if(Array.isArray(o)){for(const a of o)if(!bn(a))throw new se(`Invalid entity ID in link '${r}' for entity '${e}'. Expected a UUID or a lookup, but received: ${a}`)}else if(!bn(o))throw new se(`Invalid UUID in link '${r}' for entity '${e}'. Expected a UUID, but received: ${o}`)}}},Is={create:Tt,update:Tt,merge:Tt,link:Sn,unlink:Sn,delete:()=>{}},vs=(e,t)=>{if(!t)return;const[n,s,r,o]=e;if(!Array.isArray(r)&&!A(r))throw new se(`Invalid id for entity '${s}'. Expected a UUID, but received: ${r}`);if(typeof s!="string")throw new se(`Entity name must be a string, but received: ${typeof s}`);const i=Is[n];i&&o!==void 0&&i(s,o,t)},ks=(e,t)=>{const n=Array.isArray(e)?e:[e];for(const s of n){if(!s||typeof s!="object")throw new se(`Transaction chunk must be an object, but received: ${typeof s}`);if(!Array.isArray(s.__ops))throw new se(`Transaction chunk must have __ops array, but received: ${typeof s.__ops}`);for(const r of s.__ops){if(!Array.isArray(r))throw new se(`Transaction operation must be an array, but received: ${typeof r}`);vs(r,t)}}};let $s=0;class Os{constructor(t,n,s){d(this,"type","sse");d(this,"initParams",null);d(this,"sendQueue",[]);d(this,"sendPromise");d(this,"closeFired",!1);d(this,"sseInitTimeout");d(this,"ES");d(this,"messageUrl");d(this,"conn");d(this,"url");d(this,"id");d(this,"onopen");d(this,"onmessage");d(this,"onclose");d(this,"onerror");this.id=`${this.type}_${$s++}`,this.url=n,this.messageUrl=s||this.url,this.ES=t,this.conn=new t(n),this.sseInitTimeout=setTimeout(()=>{this.initParams||this.handleError()},1e4),this.conn.onmessage=r=>{const o=JSON.parse(r.data);if(Array.isArray(o))for(const i of o)this.handleMessage(i);else this.handleMessage(o)},this.conn.onerror=r=>{this.handleError()}}handleMessage(t){if(t.op==="sse-init"){this.initParams={machineId:t["machine-id"],sessionId:t["session-id"],sseToken:t["sse-token"]},this.onopen&&this.onopen({target:this}),clearTimeout(this.sseInitTimeout);return}this.onmessage&&this.onmessage({target:this,message:t})}handleError(){try{this.onerror&&this.onerror({target:this})}finally{this.handleClose()}}handleClose(){this.conn.close(),this.onclose&&!this.closeFired&&(this.closeFired=!0,this.onclose({target:this}))}async postMessages(t){var n,s,r;try{(await fetch(this.messageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machine_id:(n=this.initParams)==null?void 0:n.machineId,session_id:(s=this.initParams)==null?void 0:s.sessionId,sse_token:(r=this.initParams)==null?void 0:r.sseToken,messages:t})})).ok||this.handleError()}catch{this.handleError()}}async flushQueue(){if(this.sendPromise||!this.sendQueue.length)return;const t=this.sendQueue;this.sendQueue=[];const n=this.postMessages(t);this.sendPromise=n,n.then(()=>{this.sendPromise=null,this.flushQueue()})}send(t){if(!this.isOpen()||!this.initParams)throw this.isConnecting()?new Error("Failed to execute 'send' on 'EventSource': Still in CONNECTING state."):this.conn.readyState===this.ES.CLOSED?new Error("EventSource is already in CLOSING or CLOSED state."):new Error("EventSource is in invalid state.");this.sendQueue.push(t),this.flushQueue()}isOpen(){return this.conn.readyState===this.ES.OPEN&&this.initParams!==null}isConnecting(){return this.conn.readyState===this.ES.CONNECTING||this.conn.readyState===this.ES.OPEN&&this.initParams===null}close(){this.handleClose()}}var In;(function(e){e.InitialSyncBatch="InitialSyncBatch",e.InitialSyncComplete="InitialSyncComplete",e.LoadFromStorage="LoadFromStorage",e.SyncTransaction="SyncTransaction",e.Error="Error"})(In||(In={}));function Es({WStream:e,opts:t,startStream:n,appendStream:s,registerStream:r}){const o=t.clientId;let i=null,a=null,c=null;const u=Ae();let l=!1,f=!1;const p=[],m=[],g=[];let w=!1,h=0,v=0;const k=[],K=new TextEncoder;function xe(){f=!0;for(const b of p)b(a??void 0)}function qt(b){return p.push(b),f&&b(a??void 0),()=>{const S=p.indexOf(b);S!==-1&&p.splice(S,1)}}function Nn(b){return g.push(b),()=>{const S=g.indexOf(b);S!==-1&&g.splice(S,1)}}t.waitUntil&&t.waitUntil(new Promise(b=>{g.push(b)}));function P(){for(const b of g)try{b()}catch{}}function _(b){return m.push(b),i&&b(i),()=>{const S=m.indexOf(b);S!==-1&&m.splice(S,1)}}function ce(b){i=b;for(const S of m)S(i)}function T(){w=!0}function V(b){let S=h,J=0,ee=0;for(const{byteLen:ue}of k){const me=S+ue;if(me>b)break;S=me,J++,ee+=ue}J>0&&(h+=ee,v-=ee,k.splice(0,J))}function W(b,S){a=S,xe(),b.error(S),P()}async function re(){const b=await n({clientId:o,reconnectToken:u,ruleParams:t.ruleParams});switch(b.type){case"ok":{const{streamId:S,offset:J}=b;i=S,V(J),k.length&&s({streamId:S,chunks:k.map(ee=>ee.chunk),offset:h}),w=!1;break}case"disconnect":{T();break}case"error":{c&&W(c,b.error);break}}}function q(){T(),re()}function mt({offset:b,done:S}){V(b),S&&(l=!0,P())}function Wn(b){return l?(W(b,new C("Stream has been closed.")),null):i||(W(b,new C("Stream has not been initialized.")),null)}async function Ve(b){c=b;let S=!0,J=0;for(;S;){let ee=Date.now()+Math.min(15e3,500*(J-1));S=!1;const ue=await n({clientId:t.clientId,reconnectToken:u,ruleParams:t.ruleParams});switch(ue.type){case"ok":{const{streamId:me,offset:Bt}=ue;if(Bt!==0){const Re=new C("Write stream is corrupted");W(b,Re);return}ce(me),r(me,{onDisconnect:T,onFlush:mt,onConnectionReconnect:re,onAppendFailed:q}),w=!1;return}case"disconnect":{S=!0,T(),J++,await new Promise(me=>{setTimeout(me,Math.max(0,ee-Date.now()))});break}case"error":{W(b,ue.error);return}}}}class Ie extends e{constructor(S,J){super(S,J)}async streamId(){return i||new Promise((S,J)=>{const ee=[],ue=()=>{for(const Re of ee)Re()},me=Re=>{S(Re),ue()},Bt=Re=>{J(Re||new C("Stream is closed.")),ue()};ee.push(_(me)),ee.push(qt(Bt))})}}return{stream:new Ie({async start(b){try{await Ve(b)}catch(S){W(b,S)}},write(b,S){const J=Wn(S);if(J){const ee=K.encode(b).length;k.push({chunk:b,byteLen:ee});const ue=h+v;v+=ee,w||s({streamId:J,chunks:[b],offset:ue})}},close(){i?s({streamId:i,chunks:[],offset:h+v,isDone:!0}):P(),xe()},abort(b){i?s({streamId:i,chunks:[],offset:h+v,isDone:!0,abortReason:b}):P(),xe()}}),addCompleteCb:Nn,closed(){return f}}}class _s{constructor(){d(this,"items",[]);d(this,"resolvers",[]);d(this,"isClosed",!1)}push(t){if(this.isClosed)return;const n=this.resolvers.shift();n?n({value:t,done:!1}):this.items.push(t)}close(){for(this.isClosed=!0;this.resolvers.length>0;)this.resolvers.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.items.length>0)yield this.items.shift();else{if(this.isClosed)return;{const{value:t,done:n}=await new Promise(s=>{this.resolvers.push(s)});if(n||!t)return;yield t}}}}function Cs({RStream:e,opts:t,startStream:n,cancelStream:s}){let r=t.byteOffset||0,o=!1;const i=new TextDecoder("utf-8"),a=new TextEncoder;let c,u=!1;const l=[],f=[];let p=null,m=null;function g(P){u=!0;for(const _ of l)_(P)}function w(P){return l.push(P),()=>{const _=l.indexOf(P);_!==-1&&l.splice(_,1)}}function h(P){return f.push(P),p&&P(p),()=>{const _=f.indexOf(P);_!==-1&&f.splice(_,1)}}function v(P,_){m=_,P.error(_),g(_)}let k=0;async function K(P,_){c=Ae();const ce={...P||{},eventId:c};for await(const T of n(ce)){if(o)return;if(T.type==="reconnect")return{retry:!0};if(T.type==="error"){v(_,T.error);return}if(T.offset>r){v(_,new C("Stream is corrupted.")),o=!0;return}p=T.streamId;for(const W of f)W(p);let V=r-T.offset;if(T.files&&T.files.length){const W=new AbortController;let re=fetch(T.files[0].url,{signal:W.signal});for(let q=0;q<T.files.length;q++){const mt=T.files[q+1],Ve=await re;if(mt&&(re=fetch(mt.url,{signal:W.signal})),!Ve.ok){if(k++,k>10){v(_,new C("Unable to process stream."));return}return{retry:!0}}if(Ve.body){const Ie=Ve.body.getReader();try{for(;;){const{done:ve,value:b}=await Ie.read();if(ve)break;if(o){W.abort();return}let S=b;if(V>0&&(S=b.subarray(V),V-=b.length-S.length),!S.length)continue;r+=S.length;const J=i.decode(S);_.enqueue(J)}}finally{Ie.releaseLock()}}else{const Ie=await Ve.arrayBuffer();let ve=Ie;if(o){W.abort();return}if(V>0&&(ve=new Uint8Array(Ie).subarray(V),V-=Ie.byteLength-ve.length),!ve.byteLength)continue;r+=ve.byteLength;const b=i.decode(ve);_.enqueue(b)}}}if(k=0,T.content){let W=T.content,re=a.encode(T.content);if(V>0){const q=re.subarray(V);if(V-=re.length-q.length,!q.length)continue;re=q,W=i.decode(q)}r+=re.length,_.enqueue(W)}}}async function xe(P){let _=!0,ce=0;for(;_;){_=!1;let T=Date.now()+Math.min(15e3,500*(ce-1));const V=await K({...t,offset:r},P);V!=null&&V.retry&&(_=!0,ce++,T<Date.now()-3e5&&(ce=0),await new Promise(W=>{setTimeout(W,Math.max(0,T-Date.now()))}))}!o&&!u&&(P.close(),g())}class qt extends e{constructor(_,ce){super(_,ce)}async streamId(){if(p)return p;if(m)throw m;return new Promise((_,ce)=>{const T=[],V=()=>{for(const q of T)q()},W=q=>{_(q),V()},re=q=>{ce(q||new C("Stream is closed.")),V()};T.push(h(W)),T.push(w(re))})}}return{stream:new qt({start(P){xe(P)},cancel(P){o=!0,c&&s({eventId:c}),g()}}),addCloseCb:w,closed(){return u}}}class Ts{constructor({WStream:t,RStream:n,trySend:s,log:r}){d(this,"trySend");d(this,"WStream");d(this,"RStream");d(this,"writeStreams",{});d(this,"startWriteStreamCbs",{});d(this,"readStreamIterators",{});d(this,"log");d(this,"activeStreams",new Set);this.WStream=t,this.RStream=n,this.trySend=s,this.log=r}createWriteStream(t){const{stream:n,addCompleteCb:s}=Es({WStream:this.WStream,startStream:this.startWriteStream.bind(this),appendStream:this.appendStream.bind(this),registerStream:this.registerWriteStream.bind(this),opts:t});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}createReadStream(t){const{stream:n,addCloseCb:s}=Cs({RStream:this.RStream,opts:t,startStream:this.startReadStream.bind(this),cancelStream:this.cancelReadStream.bind(this)});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}startWriteStream(t){const n=Ae();let s=null;const r=new Promise(i=>{s=i});this.startWriteStreamCbs[n]=s;const o={op:"start-stream","client-id":t.clientId,"reconnect-token":t.reconnectToken};return t.ruleParams&&(o["rule-params"]=t.ruleParams),this.trySend(n,o),r}registerWriteStream(t,n){this.writeStreams[t]=n}appendStream({streamId:t,chunks:n,isDone:s,offset:r,abortReason:o}){const i={op:"append-stream","stream-id":t,chunks:n,offset:r,done:!!s};o&&(i["abort-reason"]=o),this.trySend(Ae(),i)}onAppendFailed(t){const n=this.writeStreams[t["stream-id"]];n&&n.onAppendFailed()}onStartStreamOk(t){const n=this.startWriteStreamCbs[t["client-event-id"]];if(!n){this.log.info("No stream for start-stream-ok",t);return}n({type:"ok",streamId:t["stream-id"],offset:t.offset}),delete this.startWriteStreamCbs[t["client-event-id"]]}onStreamFlushed(t){const n=t["stream-id"],s=this.writeStreams[n];if(!s){this.log.info("No stream cbs for stream-flushed",t);return}s.onFlush({offset:t.offset,done:t.done}),t.done&&delete this.writeStreams[n]}startReadStream({eventId:t,clientId:n,streamId:s,offset:r,ruleParams:o}){const i={op:"subscribe-stream"};if(!s&&!n)throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");s&&(i["stream-id"]=s),n&&(i["client-id"]=n),r&&(i.offset=r),o&&(i["rule-params"]=o);const a=new _s;return this.readStreamIterators[t]=a,this.trySend(t,i),a}cancelReadStream({eventId:t}){const n={op:"unsubscribe-stream","subscribe-event-id":t};this.trySend(Ae(),n),delete this.readStreamIterators[t]}onStreamAppend(t){const n=t["client-event-id"],s=this.readStreamIterators[n];if(!s){this.log.info("No iterator for read stream",t);return}if(t.error){t.retry?s.push({type:"reconnect"}):s.push({type:"error",error:new C(t.error)}),s.close(),delete this.readStreamIterators[n];return}s.push({type:"append",offset:t.offset,files:t.files,content:t.content,streamId:t["stream-id"]}),t.done&&(s.close(),delete this.readStreamIterators[n])}onConnectionStatusChange(t){for(const n of Object.values(this.startWriteStreamCbs))n({type:"disconnect"});if(this.startWriteStreamCbs={},t!==xs.AUTHENTICATED)for(const{onDisconnect:n}of Object.values(this.writeStreams))n();else{for(const{onConnectionReconnect:n}of Object.values(this.writeStreams))n();for(const n of Object.values(this.readStreamIterators))n.push({type:"reconnect"}),n.close();this.readStreamIterators={}}}onRecieveError(t){const n=t["original-event"];switch(n.op){case"append-stream":{const s=n["stream-id"],r=this.writeStreams[s];r==null||r.onAppendFailed();break}case"start-stream":{const s=t["client-event-id"],r=this.startWriteStreamCbs[s];r&&(r({type:"error",error:new C(t.message||"Unknown error",t.hint)}),delete this.startWriteStreamCbs[s]);break}case"subscribe-stream":{const s=t["client-event-id"],r=this.readStreamIterators[s];r&&(r.push({type:"error",error:new C(t.message||"Unknown error",t.hint)}),r.close(),delete this.readStreamIterators[s]);break}}}hasActiveStreams(){return this.activeStreams.size>0}}const xs={AUTHENTICATED:"authenticated"};function Rs(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function As(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}As(),Rs();class vn extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function xt(e){}function Ps(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=xt,onError:n=xt,onRetry:s=xt,onComment:r}=e;let o="",i=!0,a,c="",u="";function l(w){const h=i?w.replace(/^\xEF\xBB\xBF/,""):w,[v,k]=Ms(`${o}${h}`);for(const K of v)f(K);o=k,i=!1}function f(w){if(w===""){m();return}if(w.startsWith(":")){r&&r(w.slice(w.startsWith(": ")?2:1));return}const h=w.indexOf(":");if(h!==-1){const v=w.slice(0,h),k=w[h+1]===" "?2:1,K=w.slice(h+k);p(v,K,w);return}p(w,"",w)}function p(w,h,v){switch(w){case"event":u=h;break;case"data":c=`${c}${h}
|
|
1
|
+
(function($,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):($=typeof globalThis<"u"?globalThis:$||self,E($.instant={}))})(this,function($){"use strict";var Ir=Object.defineProperty;var Ln=$=>{throw TypeError($)};var vr=($,E,A)=>E in $?Ir($,E,{enumerable:!0,configurable:!0,writable:!0,value:A}):$[E]=A;var d=($,E,A)=>vr($,typeof E!="symbol"?E+"":E,A),Qt=($,E,A)=>E.has($)||Ln("Cannot "+A);var y=($,E,A)=>(Qt($,E,"read from private field"),A?A.call($):E.get($)),L=($,E,A)=>E.has($)?Ln("Cannot add the same private member more than once"):E instanceof WeakSet?E.add($):E.set($,A),B=($,E,A,D)=>(Qt($,E,"write to private field"),D?D.call($,A):E.set($,A),A),M=($,E,A)=>(Qt($,E,"access private method"),A);var G,Ye,Le,Fe,Ze,ne,fe,et,Ce,ze,H,Te,X,Y,z,zn,bt,Vn,Jn,Hn,lt,ht,pt,Gt,Kn,yt;const E=/^(?:[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;function A(e){return typeof e=="string"&&E.test(e)}const D=[];for(let e=0;e<256;++e)D.push((e+256).toString(16).slice(1));function qn(e,t=0){return(D[e[t+0]]+D[e[t+1]]+D[e[t+2]]+D[e[t+3]]+"-"+D[e[t+4]]+D[e[t+5]]+"-"+D[e[t+6]]+D[e[t+7]]+"-"+D[e[t+8]]+D[e[t+9]]+"-"+D[e[t+10]]+D[e[t+11]]+D[e[t+12]]+D[e[t+13]]+D[e[t+14]]+D[e[t+15]]).toLowerCase()}let wt;const Bn=new Uint8Array(16);function Qn(){if(!wt){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");wt=crypto.getRandomValues.bind(crypto)}return wt(Bn)}const Xt={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Gn(e,t,n){var r;if(Xt.randomUUID&&!e)return Xt.randomUUID();e=e||{};const s=e.random??((r=e.rng)==null?void 0:r.call(e))??Qn();if(s.length<16)throw new Error("Random bytes length must be >= 16");return s[6]=s[6]&15|64,s[8]=s[8]&63|128,qn(s)}const F={Remove:"remove",Replace:"replace",Add:"add"},Yt=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),tt=Symbol.iterator,ie={mutable:"mutable",immutable:"immutable"},gt={};function Je(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Zt(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const s=Reflect.getOwnPropertyDescriptor(n,t);if(s)return s;n=Reflect.getPrototypeOf(n)}}}function en(e){return Object.getPrototypeOf(e)===Set.prototype}function tn(e){return Object.getPrototypeOf(e)===Map.prototype}function te(e){var t;return(t=e.copy)!==null&&t!==void 0?t:e.original}function St(e){return!!O(e)}function O(e){return typeof e!="object"?null:e==null?void 0:e[Yt]}function It(e){var t;const n=O(e);return n?(t=n.copy)!==null&&t!==void 0?t:n.original:e}function ke(e,t){if(!e||typeof e!="object")return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(t!=null&&t.mark)&&((n=t.mark(e,ie))===ie.immutable||typeof n=="function")}function nn(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,s=O(be(n,e.key));if(s!==null&&(s==null?void 0:s.original)!==e.original)return null;const r=e.parent.type===3,o=r?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(r&&n.size>o||Je(n,o)))return null;t.push(o)}if(e.parent)return nn(e.parent,t);t.reverse();try{Xn(e.copy,t)}catch{return null}return t}function He(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function be(e,t){return He(e)===2?e.get(t):e[t]}function vt(e,t,n){He(e)===2?e.set(t,n):e[t]=n}function kt(e,t){const n=O(e);return(n?te(n):e)[t]}function $e(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Oe(e,t){return t?e:[""].concat(e).map(n=>{const s=`${n}`;return s.indexOf("/")===-1&&s.indexOf("~")===-1?s:s.replace(/~/g,"~0").replace(/\//g,"~1")}).join("/")}function Xn(e,t){for(let n=0;n<t.length-1;n+=1){const s=t[n];if(e=be(He(e)===3?Array.from(e):e,s),typeof e!="object")throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}return e}function Yn(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach(n=>{let s=Reflect.getOwnPropertyDescriptor(e,n);if(s.enumerable&&s.configurable&&s.writable){t[n]=e[n];return}s.writable||(s.writable=!0,s.configurable=!0),(s.get||s.set)&&(s={configurable:!0,writable:!0,enumerable:s.enumerable,value:e[n]}),Reflect.defineProperty(t,n,s)}),t}const Zn=Object.prototype.propertyIsEnumerable;function es(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set){if(!en(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e.values())}return Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values())}else if(e instanceof Map){if(!tn(e)){const s=Object.getPrototypeOf(e).constructor;return new s(e)}return new Map(e)}else if(t!=null&&t.mark&&(n=t.mark(e,ie),n!==void 0)&&n!==ie.mutable){if(n===ie.immutable)return Yn(e);if(typeof n=="function"){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}else if(typeof e=="object"&&Object.getPrototypeOf(e)===Object.prototype){const s={};return Object.keys(e).forEach(r=>{s[r]=e[r]}),Object.getOwnPropertySymbols(e).forEach(r=>{Zn.call(e,r)&&(s[r]=e[r])}),s}else throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=es(e.original,e.options))}function Ke(e){if(!ke(e))return It(e);if(Array.isArray(e))return e.map(Ke);if(e instanceof Map){const n=Array.from(e.entries()).map(([s,r])=>[s,Ke(r)]);if(!tn(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Map(n)}if(e instanceof Set){const n=Array.from(e).map(Ke);if(!en(e)){const s=Object.getPrototypeOf(e).constructor;return new s(n)}return new Set(n)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Ke(e[n]);return t}function nt(e){return St(e)?Ke(e):e}function de(e){var t;e.assignedMap=(t=e.assignedMap)!==null&&t!==void 0?t:new Map,e.operated||(e.operated=!0,e.parent&&de(e.parent))}function ts(e,t){const n=He(e);if(n===0)Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)});else if(n===1){let s=0;for(const r of e)t(s,r,e),s+=1}else e.forEach((s,r)=>t(r,s,e))}function sn(e,t,n){if(St(e)||!ke(e,n)||t.has(e)||Object.isFrozen(e))return;const s=e instanceof Set,r=s?new Map:void 0;if(t.add(e),ts(e,(o,i)=>{var a;if(St(i)){const c=O(i);Q(c);const u=!((a=c.assignedMap)===null||a===void 0)&&a.size||c.operated?c.copy:c.original;vt(s?r:e,o,u)}else sn(i,t,n)}),r){const o=e,i=Array.from(o);o.clear(),i.forEach(a=>{o.add(r.has(a)?r.get(a):a)})}}function ns(e,t){const n=e.type===3?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&sn(be(n,t),e.finalities.handledSet,e.options)}function $t(e){e.type===3&&e.copy&&(e.copy.clear(),e.setMap.forEach(t=>{e.copy.add(It(t))}))}function Ot(e,t,n,s){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&s){const o=nn(e);o&&t(e,o,n,s)}e.finalized=!0}}function Et(e,t,n,s){const r=O(n);r&&(r.callbacks||(r.callbacks=[]),r.callbacks.push((o,i)=>{var a;const c=e.type===3?e.setMap:e.copy;if($e(be(c,t),n)){let u=r.original;r.copy&&(u=r.copy),$t(e),Ot(e,s,o,i),e.options.enableAutoFreeze&&(e.options.updatedValues=(a=e.options.updatedValues)!==null&&a!==void 0?a:new WeakMap,e.options.updatedValues.set(u,r.original)),vt(c,t,u)}}),e.options.enableAutoFreeze&&r.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),ke(n,e.options)&&e.finalities.draft.push(()=>{const o=e.type===3?e.setMap:e.copy;$e(be(o,t),n)&&ns(e,t)})}function ss(e,t,n,s,r){let{original:o,assignedMap:i,options:a}=e,c=e.copy;c.length<o.length&&([o,c]=[c,o],[n,s]=[s,n]);for(let u=0;u<o.length;u+=1)if(i.get(u.toString())&&c[u]!==o[u]){const l=t.concat([u]),f=Oe(l,r);n.push({op:F.Replace,path:f,value:nt(c[u])}),s.push({op:F.Replace,path:f,value:nt(o[u])})}for(let u=o.length;u<c.length;u+=1){const l=t.concat([u]),f=Oe(l,r);n.push({op:F.Add,path:f,value:nt(c[u])})}if(o.length<c.length){const{arrayLengthAssignment:u=!0}=a.enablePatches;if(u){const l=t.concat(["length"]),f=Oe(l,r);s.push({op:F.Replace,path:f,value:o.length})}else for(let l=c.length;o.length<l;l-=1){const f=t.concat([l-1]),p=Oe(f,r);s.push({op:F.Remove,path:p})}}}function rs({original:e,copy:t,assignedMap:n},s,r,o,i){n.forEach((a,c)=>{const u=be(e,c),l=nt(be(t,c)),f=a?Je(e,c)?F.Replace:F.Add:F.Remove;if($e(u,l)&&f===F.Replace)return;const p=s.concat(c),m=Oe(p,i);r.push(f===F.Remove?{op:f,path:m}:{op:f,path:m,value:l}),o.push(f===F.Add?{op:F.Remove,path:m}:f===F.Remove?{op:F.Add,path:m,value:u}:{op:F.Replace,path:m,value:u})})}function is({original:e,copy:t},n,s,r,o){let i=0;e.forEach(a=>{if(!t.has(a)){const c=n.concat([i]),u=Oe(c,o);s.push({op:F.Remove,path:u,value:a}),r.unshift({op:F.Add,path:u,value:a})}i+=1}),i=0,t.forEach(a=>{if(!e.has(a)){const c=n.concat([i]),u=Oe(c,o);s.push({op:F.Add,path:u,value:a}),r.unshift({op:F.Remove,path:u,value:a})}i+=1})}function qe(e,t,n,s){const{pathAsArray:r=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return rs(e,t,n,s,r);case 1:return ss(e,t,n,s,r);case 3:return is(e,t,n,s,r)}}const st=(e,t,n=!1)=>{if(typeof e=="object"&&e!==null&&(!ke(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},_t={get size(){return te(O(this)).size},has(e){return te(O(this)).has(e)},set(e,t){const n=O(this),s=te(n);return(!s.has(e)||!$e(s.get(e),t))&&(Q(n),de(n),n.assignedMap.set(e,!0),n.copy.set(e,t),Et(n,e,t,qe)),this},delete(e){if(!this.has(e))return!1;const t=O(this);return Q(t),de(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=O(this);if(this.size){Q(e),de(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){const n=O(this);te(n).forEach((s,r)=>{e.call(t,this.get(r),r,this)})},get(e){var t,n;const s=O(this),r=te(s).get(e),o=((n=(t=s.options).mark)===null||n===void 0?void 0:n.call(t,r,ie))===ie.mutable;if(s.options.strict&&st(r,s.options,o),o||s.finalized||!ke(r,s.options)||r!==s.original.get(e))return r;const i=gt.createDraft({original:r,parentDraft:s,key:e,finalities:s.finalities,options:s.options});return Q(s),s.copy.set(e,i),i},keys(){return te(O(this)).keys()},values(){const e=this.keys();return{[tt]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[tt]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[tt](){return this.entries()}},os=Reflect.ownKeys(_t),rn=(e,t,{isValuesIterator:n})=>()=>{var s,r;const o=t.next();if(o.done)return o;const i=o.value;let a=e.setMap.get(i);const c=O(a),u=((r=(s=e.options).mark)===null||r===void 0?void 0:r.call(s,a,ie))===ie.mutable;if(e.options.strict&&st(i,e.options,u),!u&&!c&&ke(i,e.options)&&!e.finalized&&e.original.has(i)){const l=gt.createDraft({original:i,parentDraft:e,key:i,finalities:e.finalities,options:e.options});e.setMap.set(i,l),a=l}else c&&(a=c.proxy);return{done:!1,value:n?a:[a,a]}},rt={get size(){return O(this).setMap.size},has(e){const t=O(this);if(t.setMap.has(e))return!0;Q(t);const n=O(e);return!!(n&&t.setMap.has(n.original))},add(e){const t=O(this);return this.has(e)||(Q(t),de(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),Et(t,e,e,qe)),this},delete(e){if(!this.has(e))return!1;const t=O(this);Q(t),de(t);const n=O(e);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))},clear(){if(!this.size)return;const e=O(this);Q(e),de(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=O(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:rn(e,t,{isValuesIterator:!0})}},entries(){const e=O(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:rn(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[tt](){return this.values()},forEach(e,t){const n=this.values();let s=n.next();for(;!s.done;)e.call(t,s.value,s.value,this),s=n.next()}};Set.prototype.difference&&Object.assign(rt,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const as=Reflect.ownKeys(rt),on=new WeakSet,an={get(e,t,n){var s,r;const o=(s=e.copy)===null||s===void 0?void 0:s[t];if(o&&on.has(o))return o;if(t===Yt)return e;let i;if(e.options.mark){const u=t==="size"&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(i=e.options.mark(u,ie),i===ie.mutable)return e.options.strict&&st(u,e.options,!0),u}const a=te(e);if(a instanceof Map&&os.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(_t,"size").get.call(e.proxy);const u=_t[t];if(u)return u.bind(e.proxy)}if(a instanceof Set&&as.includes(t)){if(t==="size")return Object.getOwnPropertyDescriptor(rt,"size").get.call(e.proxy);const u=rt[t];if(u)return u.bind(e.proxy)}if(!Je(a,t)){const u=Zt(a,t);return u?"value"in u?u.value:(r=u.get)===null||r===void 0?void 0:r.call(e.proxy):void 0}const c=a[t];if(e.options.strict&&st(c,e.options),e.finalized||!ke(c,e.options))return c;if(c===kt(e.original,t)){if(Q(e),e.copy[t]=cn({original:e.original[t],parentDraft:e,key:e.type===1?Number(t):t,finalities:e.finalities,options:e.options}),typeof i=="function"){const u=O(e.copy[t]);return Q(u),de(u),u.copy}return e.copy[t]}return c},set(e,t,n){var s;if(e.type===3||e.type===2)throw new Error("Map/Set draft does not support any property assignment.");let r;if(e.type===1&&t!=="length"&&!(Number.isInteger(r=Number(t))&&r>=0&&(t===0||r===0||String(r)===String(t))))throw new Error("Only supports setting array indices and the 'length' property.");const o=Zt(te(e),t);if(o!=null&&o.set)return o.set.call(e.proxy,n),!0;const i=kt(te(e),t),a=O(i);return a&&$e(a.original,n)?(e.copy[t]=n,e.assignedMap=(s=e.assignedMap)!==null&&s!==void 0?s:new Map,e.assignedMap.set(t,!1),!0):($e(n,i)&&(n!==void 0||Je(e.original,t))||(Q(e),de(e),Je(e.original,t)&&$e(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,Et(e,t,n,qe)),!0)},has(e,t){return t in te(e)},ownKeys(e){return Reflect.ownKeys(te(e))},getOwnPropertyDescriptor(e,t){const n=te(e),s=Reflect.getOwnPropertyDescriptor(n,t);return s&&{writable:!0,configurable:e.type!==1||t!=="length",enumerable:s.enumerable,value:n[t]}},getPrototypeOf(e){return Reflect.getPrototypeOf(e.original)},setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return e.type===1?an.set.call(this,e,t,void 0,e.proxy):(kt(e.original,t)!==void 0||t in e.original?(Q(e),de(e),e.assignedMap.set(t,!1)):(e.assignedMap=(n=e.assignedMap)!==null&&n!==void 0?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function cn(e){const{original:t,parentDraft:n,key:s,finalities:r,options:o}=e,i=He(t),a={type:i,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:r,options:o,setMap:i===3?new Map(t.entries()):void 0};(s||"key"in e)&&(a.key=s);const{proxy:c,revoke:u}=Proxy.revocable(i===1?Object.assign([],a):a,an);if(r.revoke.push(u),on.add(c),a.proxy=c,n){const l=n;l.finalities.draft.push((f,p)=>{var m,g;const w=O(c);let h=l.type===3?l.setMap:l.copy;const v=be(h,s),k=O(v);if(k){let K=k.original;k.operated&&(K=It(v)),$t(k),Ot(k,qe,f,p),l.options.enableAutoFreeze&&(l.options.updatedValues=(m=l.options.updatedValues)!==null&&m!==void 0?m:new WeakMap,l.options.updatedValues.set(K,k.original)),vt(h,s,K)}(g=w.callbacks)===null||g===void 0||g.forEach(K=>{K(f,p)})})}else{const l=O(c);l.finalities.draft.push((f,p)=>{$t(l),Ot(l,qe,f,p)})}return c}gt.createDraft=cn,Object.prototype.constructor.toString();function Ae(){return Gn()}function cs(e,t){return e.localeCompare(t)}function us(){let e=cs;if(typeof Intl=="object"&&Intl.hasOwnProperty("Collator"))try{e=Intl.Collator("en-US").compare}catch{}return e}us();function fs(){const t={__etype:1,__ops:1,create:1,update:1,link:1,unlink:1,delete:1,merge:1,ruleParams:1};return new Set(Object.keys(t))}const ds=fs();function it(e,t,n){const s={__etype:e,__ops:n};return new Proxy(s,{get:(r,o)=>{if(o==="__ops")return n;if(o==="__etype")return e;if(ds.has(o))return(i,a)=>it(e,t,[...n,a?[o,e,t,i,a]:[o,e,t,i]])}})}function ls(e,t){return`lookup__${e}__${JSON.stringify(t)}`}function un(e){return e.startsWith("lookup__")}function fn(e){const[t,n,...s]=e.split("__");return[n,JSON.parse(s.join("__"))]}function hs(e){return new Proxy({__etype:e},{get(t,n){if(n==="lookup")return(r,o)=>it(e,fn(ls(r,o)),[]);if(n==="__etype")return e;const s=n;return un(s)?it(e,fn(s),[]):it(e,s,[])}})}function dn(){return new Proxy({},{get(e,t){return hs(t)}})}dn();function ps(e){return e.__ops}class C extends Error{constructor(n,s,r){super(n);d(this,"hint");d(this,"traceId");this.hint=s,r&&(this.traceId=r);const o=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,o),Error.captureStackTrace&&Error.captureStackTrace(this,C),this.name="InstantError"}get[Symbol.toStringTag](){return"InstantError"}}class le extends C{constructor(n){var o,i;const s=((o=n.body)==null?void 0:o.message)||`API Error (${n.status})`;super(s,n.body.hint,((i=n.body)==null?void 0:i.traceId)||n.body["trace-id"]);d(this,"body");d(this,"status");const r=new.target.prototype;Object.setPrototypeOf&&Object.setPrototypeOf(this,r),Error.captureStackTrace&&Error.captureStackTrace(this,le),this.name="InstantAPIError",this.status=n.status,this.body=n.body}get[Symbol.toStringTag](){return"InstantAPIError"}}typeof window<"u"&&typeof window.localStorage<"u"&&(window.localStorage.getItem("devBackend"),window.localStorage.getItem("__instantLogging"),window.localStorage.getItem("__devtoolLocalDash"));const Ee="v1.0.40-branch-simplify-llm-rules.26480747371.1";class he{constructor(t,n,s,r={indexed:!1,unique:!1}){d(this,"valueType");d(this,"required");d(this,"isIndexed");d(this,"config");d(this,"metadata",{});this.valueType=t,this.required=n,this.isIndexed=s,this.config=r}clientRequired(){return new he(this.valueType,!1,this.isIndexed,this.config)}optional(){return new he(this.valueType,!1,this.isIndexed,this.config)}unique(){return new he(this.valueType,this.required,this.isIndexed,{...this.config,unique:!0})}indexed(){return new he(this.valueType,this.required,!0,{...this.config,indexed:!0})}}class x extends Error{constructor(t,n){const s=n?`At path '${n}': ${t}`:t;super(s),this.name="QueryValidationError"}}const ln=["where","order","limit","last","first","offset","after","afterInclusive","before","beforeInclusive","fields","aggregate"],ys=e=>e.valueType||"unknown",hn=(e,t,n=!1)=>{if(n||e==null)return!0;switch(t){case"string":return typeof e=="string";case"number":return typeof e=="number"&&!isNaN(e);case"boolean":return typeof e=="boolean";case"date":return e instanceof Date||typeof e=="string"||typeof e=="number";default:return!0}},ms=(e,t,n,s,r,o,i)=>{const a=o.valueType==="json",c=(u,l,f)=>{if(!hn(f,l,a))throw new x(`Invalid value for operator '${u}' on attribute '${s}' in entity '${r}'. Expected ${l}, but received: ${typeof f}`,i)};switch(e){case"in":case"$in":if(!Array.isArray(t))throw new x(`Operator '${e}' for attribute '${s}' in entity '${r}' must be an array, but received: ${typeof t}`,i);for(const u of t)c(e,n,u);break;case"$not":case"$ne":case"$gt":case"$lt":case"$gte":case"$lte":c(e,n,t);break;case"$like":case"$ilike":if(c(e,"string",t),e==="$ilike"&&!o.isIndexed)throw new x(`Operator '${e}' can only be used with indexed attributes, but '${s}' in entity '${r}' is not indexed`,i);break;case"$isNull":c(e,"boolean",t);break;default:throw new x(`Unknown operator '${e}' for attribute '${s}' in entity '${r}'`,i)}},Pe=(e,t,n,s,r)=>{const o=ys(n),i=n.valueType==="json";if(typeof e=="object"&&e!==null&&!Array.isArray(e)){if(i)return;const c=e;for(const[u,l]of Object.entries(c))ms(u,l,o,t,s,n,`${r}.${u}`)}else if(!hn(e,o,i))throw new x(`Invalid value for attribute '${t}' in entity '${s}'. Expected ${o}, but received: ${typeof e}`,r)},bs=(e,t,n,s,r)=>{const o=e.split(".");if(o.length<2)throw new x(`Invalid dot notation path '${e}'. Must contain at least one dot.`,r);let i=n;for(let l=0;l<o.length-1;l++){const f=o[l],p=s.entities[i];if(!p)throw new x(`Entity '${i}' does not exist in schema while traversing dot notation path '${e}'.`,r);const m=p.links[f];if(!m){const g=Object.keys(p.links);throw new x(`Link '${f}' does not exist on entity '${i}' in dot notation path '${e}'. Available links: ${g.length>0?g.join(", "):"none"}`,r)}i=m.entityName}const a=o[o.length-1],c=s.entities[i];if(!c)throw new x(`Target entity '${i}' does not exist in schema for dot notation path '${e}'.`,r);if(a==="id"){if(typeof t=="string"&&!A(t))throw new x(`Invalid value for id field in entity '${i}'. Expected a UUID, but received: ${t}`,r);Pe(t,e,new he("string",!1,!0),n,r);return}const u=c.attrs[a];if(Object.keys(c.links).includes(a)){if(typeof t=="string"&&!A(t))throw new x(`Invalid value for link '${a}' in entity '${i}'. Expected a UUID, but received: ${t}`,r);Pe(t,e,new he("string",!1,!0),n,r);return}if(!u){const l=Object.keys(c.attrs);throw new x(`Attribute '${a}' does not exist on entity '${i}' in dot notation path '${e}'. Available attributes: ${l.length>0?l.join(", ")+", id":"id"}`,r)}Pe(t,e,u,n,r)},pn=(e,t,n,s)=>{for(const[r,o]of Object.entries(e)){if(r==="or"||r==="and"){if(Array.isArray(o))for(const u of o)typeof u=="object"&&u!==null&&pn(u,t,n,`${s}.${r}[${u}]`);continue}if(r==="id"){Pe(o,"id",new he("string",!1,!0),t,`${s}.id`);continue}if(r.includes(".")){bs(r,o,t,n,`${s}.${r}`);continue}const i=n.entities[t];if(!i)continue;const a=i.attrs[r],c=i.links[r];if(!a&&!c){const u=Object.keys(i.attrs),l=Object.keys(i.links);throw new x(`Attribute or link '${r}' does not exist on entity '${t}'. Available attributes: ${u.length>0?u.join(", "):"none"}. Available links: ${l.length>0?l.join(", "):"none"}`,`${s}.${r}`)}if(a)Pe(o,r,a,t,`${s}.${r}`);else if(c){if(typeof o=="string"&&!A(o))throw new x(`Invalid value for link '${r}' in entity '${t}'. Expected a UUID, but received: ${o}`,`${s}.${r}`);const u=new he("string",!1,!0);Pe(o,r,u,t,`${s}.${r}`)}}},ws=(e,t,n,s,r=0)=>{for(const i of Object.keys(e))if(!ln.includes(i))throw new x(`Invalid query parameter '${i}' in $ object. Valid parameters are: ${ln.join(", ")}. Found: ${i}`,s);const o=["offset","before","beforeInclusive","after","afterInclusive","first","last"];for(const i of o)if(e[i]!==void 0&&r>0)throw new x(`'${i}' can only be used on top-level namespaces. It cannot be used in nested queries.`,s);if(e.where&&n){if(typeof e.where!="object"||e.where===null)throw new x(`'where' clause must be an object in entity '${t}', but received: ${typeof e.where}`,s?`${s}.where`:void 0);pn(e.where,t,n,s?`${s}.where`:"where")}},yn=(e,t,n,s,r=0)=>{var o;if(!e||typeof e!="object")throw new x(`Query part for entity '${t}' must be an object, but received: ${typeof e}`,s);for(const i of Object.keys(e))if(i!=="$"){if(n&&!(i in n.entities[t].links)){const c=Object.keys(n.entities[t].links);throw new x(`Link '${i}' does not exist on entity '${t}'. Available links: ${c.length>0?c.join(", "):"none"}`,`${s}.${i}`)}const a=e[i];if(typeof a=="object"&&a!==null){const c=(o=n==null?void 0:n.entities[t].links[i])==null?void 0:o.entityName;c&&yn(a,c,n,`${s}.${i}`,r+1)}}else{const a=e[i];if(typeof a!="object"||a===null)throw new x(`Query parameter '$' must be an object in entity '${t}', but received: ${typeof a}`,`${s}.$`);ws(a,t,n,`${s}.$`,r)}},mn=(e,t)=>{if(typeof e!="object"||e===null)throw new x(`Query must be an object, but received: ${typeof e}${e===null?" (null)":""}`);if(Array.isArray(e))throw new x(`Query must be an object, but received: ${typeof e}`);const n=e;for(const s of Object.keys(n)){if(Array.isArray(e[s]))throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(typeof s!="string")throw new x(`Query keys must be strings, but found key of type: ${typeof s}`,s);if(s!=="$$ruleParams"){if(t&&!t.entities[s]){const r=Object.keys(t.entities);throw new x(`Entity '${s}' does not exist in schema. Available entities: ${r.length>0?r.join(", "):"none"}`,s)}yn(n[s],s,t,s,0)}}},bn=e=>typeof e!="string"?!1:un(e)?!0:A(e);class se extends Error{constructor(t){super(t),this.name="TransactionValidationError"}}const wn=e=>e.length>0?e.join(", "):"none",gs=(e,t)=>new se(`Entity '${e}' does not exist in schema. Available entities: ${wn(t)}`),Ct={string:e=>typeof e=="string",number:e=>typeof e=="number"&&!isNaN(e),boolean:e=>typeof e=="boolean",date:e=>e instanceof Date||typeof e=="string"||typeof e=="number",json:()=>!0},Ss=(e,t)=>{var n;return e==null?!0:((n=Ct[t.valueType])==null?void 0:n.call(Ct,e))??!1},gn=(e,t)=>{const n=t.entities[e];if(!n)throw gs(e,Object.keys(t.entities));return n},Tt=(e,t,n)=>{const s=gn(e,n);if(typeof t!="object"||t===null)throw new se(`Arguments for data operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[r,o]of Object.entries(t)){if(r==="id")continue;const i=s.attrs[r];if(i&&!Ss(o,i))throw new se(`Invalid value for attribute '${r}' in entity '${e}'. Expected ${i.valueType}, but received: ${typeof o}`)}},Sn=(e,t,n)=>{const s=gn(e,n);if(typeof t!="object"||t===null)throw new se(`Arguments for link operation on entity '${e}' must be an object, but received: ${typeof t}`);for(const[r,o]of Object.entries(t)){if(!s.links[r]){const a=Object.keys(s.links);throw new se(`Link '${r}' does not exist on entity '${e}'. Available links: ${wn(a)}`)}if(o!=null){if(Array.isArray(o)){for(const a of o)if(!bn(a))throw new se(`Invalid entity ID in link '${r}' for entity '${e}'. Expected a UUID or a lookup, but received: ${a}`)}else if(!bn(o))throw new se(`Invalid UUID in link '${r}' for entity '${e}'. Expected a UUID, but received: ${o}`)}}},Is={create:Tt,update:Tt,merge:Tt,link:Sn,unlink:Sn,delete:()=>{}},vs=(e,t)=>{if(!t)return;const[n,s,r,o]=e;if(!Array.isArray(r)&&!A(r))throw new se(`Invalid id for entity '${s}'. Expected a UUID, but received: ${r}`);if(typeof s!="string")throw new se(`Entity name must be a string, but received: ${typeof s}`);const i=Is[n];i&&o!==void 0&&i(s,o,t)},ks=(e,t)=>{const n=Array.isArray(e)?e:[e];for(const s of n){if(!s||typeof s!="object")throw new se(`Transaction chunk must be an object, but received: ${typeof s}`);if(!Array.isArray(s.__ops))throw new se(`Transaction chunk must have __ops array, but received: ${typeof s.__ops}`);for(const r of s.__ops){if(!Array.isArray(r))throw new se(`Transaction operation must be an array, but received: ${typeof r}`);vs(r,t)}}};let $s=0;class Os{constructor(t,n,s){d(this,"type","sse");d(this,"initParams",null);d(this,"sendQueue",[]);d(this,"sendPromise");d(this,"closeFired",!1);d(this,"sseInitTimeout");d(this,"ES");d(this,"messageUrl");d(this,"conn");d(this,"url");d(this,"id");d(this,"onopen");d(this,"onmessage");d(this,"onclose");d(this,"onerror");this.id=`${this.type}_${$s++}`,this.url=n,this.messageUrl=s||this.url,this.ES=t,this.conn=new t(n),this.sseInitTimeout=setTimeout(()=>{this.initParams||this.handleError()},1e4),this.conn.onmessage=r=>{const o=JSON.parse(r.data);if(Array.isArray(o))for(const i of o)this.handleMessage(i);else this.handleMessage(o)},this.conn.onerror=r=>{this.handleError()}}handleMessage(t){if(t.op==="sse-init"){this.initParams={machineId:t["machine-id"],sessionId:t["session-id"],sseToken:t["sse-token"]},this.onopen&&this.onopen({target:this}),clearTimeout(this.sseInitTimeout);return}this.onmessage&&this.onmessage({target:this,message:t})}handleError(){try{this.onerror&&this.onerror({target:this})}finally{this.handleClose()}}handleClose(){this.conn.close(),this.onclose&&!this.closeFired&&(this.closeFired=!0,this.onclose({target:this}))}async postMessages(t){var n,s,r;try{(await fetch(this.messageUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({machine_id:(n=this.initParams)==null?void 0:n.machineId,session_id:(s=this.initParams)==null?void 0:s.sessionId,sse_token:(r=this.initParams)==null?void 0:r.sseToken,messages:t})})).ok||this.handleError()}catch{this.handleError()}}async flushQueue(){if(this.sendPromise||!this.sendQueue.length)return;const t=this.sendQueue;this.sendQueue=[];const n=this.postMessages(t);this.sendPromise=n,n.then(()=>{this.sendPromise=null,this.flushQueue()})}send(t){if(!this.isOpen()||!this.initParams)throw this.isConnecting()?new Error("Failed to execute 'send' on 'EventSource': Still in CONNECTING state."):this.conn.readyState===this.ES.CLOSED?new Error("EventSource is already in CLOSING or CLOSED state."):new Error("EventSource is in invalid state.");this.sendQueue.push(t),this.flushQueue()}isOpen(){return this.conn.readyState===this.ES.OPEN&&this.initParams!==null}isConnecting(){return this.conn.readyState===this.ES.CONNECTING||this.conn.readyState===this.ES.OPEN&&this.initParams===null}close(){this.handleClose()}}var In;(function(e){e.InitialSyncBatch="InitialSyncBatch",e.InitialSyncComplete="InitialSyncComplete",e.LoadFromStorage="LoadFromStorage",e.SyncTransaction="SyncTransaction",e.Error="Error"})(In||(In={}));function Es({WStream:e,opts:t,startStream:n,appendStream:s,registerStream:r}){const o=t.clientId;let i=null,a=null,c=null;const u=Ae();let l=!1,f=!1;const p=[],m=[],g=[];let w=!1,h=0,v=0;const k=[],K=new TextEncoder;function xe(){f=!0;for(const b of p)b(a??void 0)}function qt(b){return p.push(b),f&&b(a??void 0),()=>{const S=p.indexOf(b);S!==-1&&p.splice(S,1)}}function Nn(b){return g.push(b),()=>{const S=g.indexOf(b);S!==-1&&g.splice(S,1)}}t.waitUntil&&t.waitUntil(new Promise(b=>{g.push(b)}));function P(){for(const b of g)try{b()}catch{}}function _(b){return m.push(b),i&&b(i),()=>{const S=m.indexOf(b);S!==-1&&m.splice(S,1)}}function ce(b){i=b;for(const S of m)S(i)}function T(){w=!0}function V(b){let S=h,J=0,ee=0;for(const{byteLen:ue}of k){const me=S+ue;if(me>b)break;S=me,J++,ee+=ue}J>0&&(h+=ee,v-=ee,k.splice(0,J))}function W(b,S){a=S,xe(),b.error(S),P()}async function re(){const b=await n({clientId:o,reconnectToken:u,ruleParams:t.ruleParams});switch(b.type){case"ok":{const{streamId:S,offset:J}=b;i=S,V(J),k.length&&s({streamId:S,chunks:k.map(ee=>ee.chunk),offset:h}),w=!1;break}case"disconnect":{T();break}case"error":{c&&W(c,b.error);break}}}function q(){T(),re()}function mt({offset:b,done:S}){V(b),S&&(l=!0,P())}function Wn(b){return l?(W(b,new C("Stream has been closed.")),null):i||(W(b,new C("Stream has not been initialized.")),null)}async function Ve(b){c=b;let S=!0,J=0;for(;S;){let ee=Date.now()+Math.min(15e3,500*(J-1));S=!1;const ue=await n({clientId:t.clientId,reconnectToken:u,ruleParams:t.ruleParams});switch(ue.type){case"ok":{const{streamId:me,offset:Bt}=ue;if(Bt!==0){const Re=new C("Write stream is corrupted");W(b,Re);return}ce(me),r(me,{onDisconnect:T,onFlush:mt,onConnectionReconnect:re,onAppendFailed:q}),w=!1;return}case"disconnect":{S=!0,T(),J++,await new Promise(me=>{setTimeout(me,Math.max(0,ee-Date.now()))});break}case"error":{W(b,ue.error);return}}}}class Ie extends e{constructor(S,J){super(S,J)}async streamId(){return i||new Promise((S,J)=>{const ee=[],ue=()=>{for(const Re of ee)Re()},me=Re=>{S(Re),ue()},Bt=Re=>{J(Re||new C("Stream is closed.")),ue()};ee.push(_(me)),ee.push(qt(Bt))})}}return{stream:new Ie({async start(b){try{await Ve(b)}catch(S){W(b,S)}},write(b,S){const J=Wn(S);if(J){const ee=K.encode(b).length;k.push({chunk:b,byteLen:ee});const ue=h+v;v+=ee,w||s({streamId:J,chunks:[b],offset:ue})}},close(){i?s({streamId:i,chunks:[],offset:h+v,isDone:!0}):P(),xe()},abort(b){i?s({streamId:i,chunks:[],offset:h+v,isDone:!0,abortReason:b}):P(),xe()}}),addCompleteCb:Nn,closed(){return f}}}class _s{constructor(){d(this,"items",[]);d(this,"resolvers",[]);d(this,"isClosed",!1)}push(t){if(this.isClosed)return;const n=this.resolvers.shift();n?n({value:t,done:!1}):this.items.push(t)}close(){for(this.isClosed=!0;this.resolvers.length>0;)this.resolvers.shift()({value:void 0,done:!0})}async*[Symbol.asyncIterator](){for(;;)if(this.items.length>0)yield this.items.shift();else{if(this.isClosed)return;{const{value:t,done:n}=await new Promise(s=>{this.resolvers.push(s)});if(n||!t)return;yield t}}}}function Cs({RStream:e,opts:t,startStream:n,cancelStream:s}){let r=t.byteOffset||0,o=!1;const i=new TextDecoder("utf-8"),a=new TextEncoder;let c,u=!1;const l=[],f=[];let p=null,m=null;function g(P){u=!0;for(const _ of l)_(P)}function w(P){return l.push(P),()=>{const _=l.indexOf(P);_!==-1&&l.splice(_,1)}}function h(P){return f.push(P),p&&P(p),()=>{const _=f.indexOf(P);_!==-1&&f.splice(_,1)}}function v(P,_){m=_,P.error(_),g(_)}let k=0;async function K(P,_){c=Ae();const ce={...P||{},eventId:c};for await(const T of n(ce)){if(o)return;if(T.type==="reconnect")return{retry:!0};if(T.type==="error"){v(_,T.error);return}if(T.offset>r){v(_,new C("Stream is corrupted.")),o=!0;return}p=T.streamId;for(const W of f)W(p);let V=r-T.offset;if(T.files&&T.files.length){const W=new AbortController;let re=fetch(T.files[0].url,{signal:W.signal});for(let q=0;q<T.files.length;q++){const mt=T.files[q+1],Ve=await re;if(mt&&(re=fetch(mt.url,{signal:W.signal})),!Ve.ok){if(k++,k>10){v(_,new C("Unable to process stream."));return}return{retry:!0}}if(Ve.body){const Ie=Ve.body.getReader();try{for(;;){const{done:ve,value:b}=await Ie.read();if(ve)break;if(o){W.abort();return}let S=b;if(V>0&&(S=b.subarray(V),V-=b.length-S.length),!S.length)continue;r+=S.length;const J=i.decode(S);_.enqueue(J)}}finally{Ie.releaseLock()}}else{const Ie=await Ve.arrayBuffer();let ve=Ie;if(o){W.abort();return}if(V>0&&(ve=new Uint8Array(Ie).subarray(V),V-=Ie.byteLength-ve.length),!ve.byteLength)continue;r+=ve.byteLength;const b=i.decode(ve);_.enqueue(b)}}}if(k=0,T.content){let W=T.content,re=a.encode(T.content);if(V>0){const q=re.subarray(V);if(V-=re.length-q.length,!q.length)continue;re=q,W=i.decode(q)}r+=re.length,_.enqueue(W)}}}async function xe(P){let _=!0,ce=0;for(;_;){_=!1;let T=Date.now()+Math.min(15e3,500*(ce-1));const V=await K({...t,offset:r},P);V!=null&&V.retry&&(_=!0,ce++,T<Date.now()-3e5&&(ce=0),await new Promise(W=>{setTimeout(W,Math.max(0,T-Date.now()))}))}!o&&!u&&(P.close(),g())}class qt extends e{constructor(_,ce){super(_,ce)}async streamId(){if(p)return p;if(m)throw m;return new Promise((_,ce)=>{const T=[],V=()=>{for(const q of T)q()},W=q=>{_(q),V()},re=q=>{ce(q||new C("Stream is closed.")),V()};T.push(h(W)),T.push(w(re))})}}return{stream:new qt({start(P){xe(P)},cancel(P){o=!0,c&&s({eventId:c}),g()}}),addCloseCb:w,closed(){return u}}}class Ts{constructor({WStream:t,RStream:n,trySend:s,log:r}){d(this,"trySend");d(this,"WStream");d(this,"RStream");d(this,"writeStreams",{});d(this,"startWriteStreamCbs",{});d(this,"readStreamIterators",{});d(this,"log");d(this,"activeStreams",new Set);this.WStream=t,this.RStream=n,this.trySend=s,this.log=r}createWriteStream(t){const{stream:n,addCompleteCb:s}=Es({WStream:this.WStream,startStream:this.startWriteStream.bind(this),appendStream:this.appendStream.bind(this),registerStream:this.registerWriteStream.bind(this),opts:t});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}createReadStream(t){const{stream:n,addCloseCb:s}=Cs({RStream:this.RStream,opts:t,startStream:this.startReadStream.bind(this),cancelStream:this.cancelReadStream.bind(this)});return this.activeStreams.add(n),s(()=>{this.activeStreams.delete(n)}),n}startWriteStream(t){const n=Ae();let s=null;const r=new Promise(i=>{s=i});this.startWriteStreamCbs[n]=s;const o={op:"start-stream","client-id":t.clientId,"reconnect-token":t.reconnectToken};return t.ruleParams&&(o["rule-params"]=t.ruleParams),this.trySend(n,o),r}registerWriteStream(t,n){this.writeStreams[t]=n}appendStream({streamId:t,chunks:n,isDone:s,offset:r,abortReason:o}){const i={op:"append-stream","stream-id":t,chunks:n,offset:r,done:!!s};o&&(i["abort-reason"]=o),this.trySend(Ae(),i)}onAppendFailed(t){const n=this.writeStreams[t["stream-id"]];n&&n.onAppendFailed()}onStartStreamOk(t){const n=this.startWriteStreamCbs[t["client-event-id"]];if(!n){this.log.info("No stream for start-stream-ok",t);return}n({type:"ok",streamId:t["stream-id"],offset:t.offset}),delete this.startWriteStreamCbs[t["client-event-id"]]}onStreamFlushed(t){const n=t["stream-id"],s=this.writeStreams[n];if(!s){this.log.info("No stream cbs for stream-flushed",t);return}s.onFlush({offset:t.offset,done:t.done}),t.done&&delete this.writeStreams[n]}startReadStream({eventId:t,clientId:n,streamId:s,offset:r,ruleParams:o}){const i={op:"subscribe-stream"};if(!s&&!n)throw new Error("Must provide one of streamId or clientId to subscribe to the stream.");s&&(i["stream-id"]=s),n&&(i["client-id"]=n),r&&(i.offset=r),o&&(i["rule-params"]=o);const a=new _s;return this.readStreamIterators[t]=a,this.trySend(t,i),a}cancelReadStream({eventId:t}){const n={op:"unsubscribe-stream","subscribe-event-id":t};this.trySend(Ae(),n),delete this.readStreamIterators[t]}onStreamAppend(t){const n=t["client-event-id"],s=this.readStreamIterators[n];if(!s){this.log.info("No iterator for read stream",t);return}if(t.error){t.retry?s.push({type:"reconnect"}):s.push({type:"error",error:new C(t.error)}),s.close(),delete this.readStreamIterators[n];return}s.push({type:"append",offset:t.offset,files:t.files,content:t.content,streamId:t["stream-id"]}),t.done&&(s.close(),delete this.readStreamIterators[n])}onConnectionStatusChange(t){for(const n of Object.values(this.startWriteStreamCbs))n({type:"disconnect"});if(this.startWriteStreamCbs={},t!==xs.AUTHENTICATED)for(const{onDisconnect:n}of Object.values(this.writeStreams))n();else{for(const{onConnectionReconnect:n}of Object.values(this.writeStreams))n();for(const n of Object.values(this.readStreamIterators))n.push({type:"reconnect"}),n.close();this.readStreamIterators={}}}onRecieveError(t){const n=t["original-event"];switch(n.op){case"append-stream":{const s=n["stream-id"],r=this.writeStreams[s];r==null||r.onAppendFailed();break}case"start-stream":{const s=t["client-event-id"],r=this.startWriteStreamCbs[s];r&&(r({type:"error",error:new C(t.message||"Unknown error",t.hint)}),delete this.startWriteStreamCbs[s]);break}case"subscribe-stream":{const s=t["client-event-id"],r=this.readStreamIterators[s];r&&(r.push({type:"error",error:new C(t.message||"Unknown error",t.hint)}),r.close(),delete this.readStreamIterators[s]);break}}}hasActiveStreams(){return this.activeStreams.size>0}}const xs={AUTHENTICATED:"authenticated"};function Rs(){return globalThis.__instantDbSchemaHashStore=globalThis.__instantDbSchemaHashStore??new WeakMap,globalThis.__instantDbSchemaHashStore}function As(){return globalThis.__instantDbStore=globalThis.__instantDbStore??{},globalThis.__instantDbStore}As(),Rs();class vn extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}function xt(e){}function Ps(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=xt,onError:n=xt,onRetry:s=xt,onComment:r}=e;let o="",i=!0,a,c="",u="";function l(w){const h=i?w.replace(/^\xEF\xBB\xBF/,""):w,[v,k]=Ms(`${o}${h}`);for(const K of v)f(K);o=k,i=!1}function f(w){if(w===""){m();return}if(w.startsWith(":")){r&&r(w.slice(w.startsWith(": ")?2:1));return}const h=w.indexOf(":");if(h!==-1){const v=w.slice(0,h),k=w[h+1]===" "?2:1,K=w.slice(h+k);p(v,K,w);return}p(w,"",w)}function p(w,h,v){switch(w){case"event":u=h;break;case"data":c=`${c}${h}
|
|
2
2
|
`;break;case"id":a=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?s(parseInt(h,10)):n(new vn(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:v}));break;default:n(new vn(`Unknown field "${w.length>20?`${w.slice(0,20)}…`:w}"`,{type:"unknown-field",field:w,value:h,line:v}));break}}function m(){c.length>0&&t({id:a,event:u||void 0,data:c.endsWith(`
|
|
3
3
|
`)?c.slice(0,-1):c}),a=void 0,c="",u=""}function g(w={}){o&&w.consume&&f(o),i=!0,a=void 0,c="",u="",o=""}return{feed:l,reset:g}}function Ms(e){const t=[];let n="",s=0;for(;s<e.length;){const r=e.indexOf("\r",s),o=e.indexOf(`
|
|
4
4
|
`,s);let i=-1;if(r!==-1&&o!==-1?i=Math.min(r,o):r!==-1?r===e.length-1?i=-1:i=r:o!==-1&&(i=o),i===-1){n=e.slice(s);break}else{const a=e.slice(s,i);t.push(a),s=i+1,e[s-1]==="\r"&&e[s]===`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instantdb/resumable-stream",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.40-branch-simplify-llm-rules.26480747371.1",
|
|
4
4
|
"description": "Instant's drop-in replacement for Vercel's resumable-stream package.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/instantdb/instant/tree/main/client/packages/resumable-stream",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"vitest": "^1.6.0"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@instantdb/admin": "1.0.
|
|
54
|
+
"@instantdb/admin": "1.0.40-branch-simplify-llm-rules.26480747371.1"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"test": "vitest",
|