@clockworkdog/cogs-client 3.0.1 → 3.0.3
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/dist/CogsConnection.js
CHANGED
|
@@ -139,6 +139,26 @@ export default class CogsConnection {
|
|
|
139
139
|
case 'data_store_items':
|
|
140
140
|
this.store.handleDataStoreItemsMessage(message);
|
|
141
141
|
break;
|
|
142
|
+
// From cogs-client@3.0.0 legacy media events are no longer supported.
|
|
143
|
+
// COGS will continue sending them with an added 'media_strategy' field for backwards compatibility.
|
|
144
|
+
// If media_strategy is not present, the user is attempting to use a new cogs-client with an old COGS.
|
|
145
|
+
case 'audio_play':
|
|
146
|
+
case 'audio_pause':
|
|
147
|
+
case 'audio_stop':
|
|
148
|
+
case 'audio_set_clip_volume':
|
|
149
|
+
case 'video_play':
|
|
150
|
+
case 'video_pause':
|
|
151
|
+
case 'video_stop':
|
|
152
|
+
case 'video_set_volume':
|
|
153
|
+
case 'video_set_fit':
|
|
154
|
+
case 'image_show':
|
|
155
|
+
case 'image_hide':
|
|
156
|
+
case 'image_set_fit': {
|
|
157
|
+
const { type } = message;
|
|
158
|
+
if (!('media_strategy' in message)) {
|
|
159
|
+
console.warn(`Legacy ${type} message received, this is no longer supported. Please upgrade to COGS 5.10 or downgrade to cogs-client@2.11`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
142
162
|
}
|
|
143
163
|
this.dispatchEvent(new CogsMessageEvent(message));
|
|
144
164
|
}
|
package/dist/browser/index.mjs
CHANGED
|
@@ -443,13 +443,13 @@ function sn({ interval: e, send: t, onChange: n = en, syncSampleSize: r = rn, sy
|
|
|
443
443
|
async function i() {
|
|
444
444
|
const h = [];
|
|
445
445
|
for (let m = 0; m < r; m++) {
|
|
446
|
-
const
|
|
446
|
+
const y = new Promise((I) => {
|
|
447
447
|
const H = nn(), de = Date.now(), fe = performance.now();
|
|
448
448
|
t({ timesync: { id: H } });
|
|
449
449
|
const S = (z, N) => I({ sentAt: fe, receivedAt: z, serverNow: N, clientNow: de });
|
|
450
450
|
s[H] = { complete: S }, setTimeout(() => I(null), o);
|
|
451
451
|
});
|
|
452
|
-
h.push(
|
|
452
|
+
h.push(y), await y;
|
|
453
453
|
}
|
|
454
454
|
const f = (await Promise.all(h)).filter((m) => m !== null), d = cn(f);
|
|
455
455
|
isNaN(d) || n(Date.now() + d);
|
|
@@ -527,13 +527,33 @@ class dc {
|
|
|
527
527
|
break;
|
|
528
528
|
case "media_config_update":
|
|
529
529
|
this._mediaConfig = m;
|
|
530
|
-
for (const
|
|
531
|
-
m[
|
|
530
|
+
for (const y of ["preferOptimizedAudio", "preferOptimizedVideo", "preferOptimizedImages"])
|
|
531
|
+
m[y] ? this.urlParams.set(y, "true") : this.urlParams.delete(y);
|
|
532
532
|
this.dispatchEvent(new mn(m));
|
|
533
533
|
break;
|
|
534
534
|
case "data_store_items":
|
|
535
535
|
this.store.handleDataStoreItemsMessage(m);
|
|
536
536
|
break;
|
|
537
|
+
// From cogs-client@3.0.0 legacy media events are no longer supported.
|
|
538
|
+
// COGS will continue sending them with an added 'media_strategy' field for backwards compatibility.
|
|
539
|
+
// If media_strategy is not present, the user is attempting to use a new cogs-client with an old COGS.
|
|
540
|
+
case "audio_play":
|
|
541
|
+
case "audio_pause":
|
|
542
|
+
case "audio_stop":
|
|
543
|
+
case "audio_set_clip_volume":
|
|
544
|
+
case "video_play":
|
|
545
|
+
case "video_pause":
|
|
546
|
+
case "video_stop":
|
|
547
|
+
case "video_set_volume":
|
|
548
|
+
case "video_set_fit":
|
|
549
|
+
case "image_show":
|
|
550
|
+
case "image_hide":
|
|
551
|
+
case "image_set_fit": {
|
|
552
|
+
const { type: y } = m;
|
|
553
|
+
"media_strategy" in m || console.warn(
|
|
554
|
+
`Legacy ${y} message received, this is no longer supported. Please upgrade to COGS 5.10 or downgrade to cogs-client@2.11`
|
|
555
|
+
);
|
|
556
|
+
}
|
|
537
557
|
}
|
|
538
558
|
this.dispatchEvent(new hn(m));
|
|
539
559
|
}
|
|
@@ -833,7 +853,7 @@ function _(e, t, n) {
|
|
|
833
853
|
configurable: !0
|
|
834
854
|
});
|
|
835
855
|
}
|
|
836
|
-
function
|
|
856
|
+
function L(e, t, n) {
|
|
837
857
|
Object.defineProperty(e, t, {
|
|
838
858
|
value: n,
|
|
839
859
|
writable: !0,
|
|
@@ -841,7 +861,7 @@ function j(e, t, n) {
|
|
|
841
861
|
configurable: !0
|
|
842
862
|
});
|
|
843
863
|
}
|
|
844
|
-
function
|
|
864
|
+
function j(...e) {
|
|
845
865
|
const t = {};
|
|
846
866
|
for (const n of e) {
|
|
847
867
|
const r = Object.getOwnPropertyDescriptors(n);
|
|
@@ -914,7 +934,7 @@ const En = {
|
|
|
914
934
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
915
935
|
};
|
|
916
936
|
function zn(e, t) {
|
|
917
|
-
const n = e._zod.def, r =
|
|
937
|
+
const n = e._zod.def, r = j(e._zod.def, {
|
|
918
938
|
get shape() {
|
|
919
939
|
const o = {};
|
|
920
940
|
for (const s in t) {
|
|
@@ -922,14 +942,14 @@ function zn(e, t) {
|
|
|
922
942
|
throw new Error(`Unrecognized key: "${s}"`);
|
|
923
943
|
t[s] && (o[s] = n.shape[s]);
|
|
924
944
|
}
|
|
925
|
-
return
|
|
945
|
+
return L(this, "shape", o), o;
|
|
926
946
|
},
|
|
927
947
|
checks: []
|
|
928
948
|
});
|
|
929
949
|
return R(e, r);
|
|
930
950
|
}
|
|
931
951
|
function $n(e, t) {
|
|
932
|
-
const n = e._zod.def, r =
|
|
952
|
+
const n = e._zod.def, r = j(e._zod.def, {
|
|
933
953
|
get shape() {
|
|
934
954
|
const o = { ...e._zod.def.shape };
|
|
935
955
|
for (const s in t) {
|
|
@@ -937,7 +957,7 @@ function $n(e, t) {
|
|
|
937
957
|
throw new Error(`Unrecognized key: "${s}"`);
|
|
938
958
|
t[s] && delete o[s];
|
|
939
959
|
}
|
|
940
|
-
return
|
|
960
|
+
return L(this, "shape", o), o;
|
|
941
961
|
},
|
|
942
962
|
checks: []
|
|
943
963
|
});
|
|
@@ -949,10 +969,10 @@ function Zn(e, t) {
|
|
|
949
969
|
const n = e._zod.def.checks;
|
|
950
970
|
if (n && n.length > 0)
|
|
951
971
|
throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
|
|
952
|
-
const o =
|
|
972
|
+
const o = j(e._zod.def, {
|
|
953
973
|
get shape() {
|
|
954
974
|
const s = { ...e._zod.def.shape, ...t };
|
|
955
|
-
return
|
|
975
|
+
return L(this, "shape", s), s;
|
|
956
976
|
},
|
|
957
977
|
checks: []
|
|
958
978
|
});
|
|
@@ -965,17 +985,17 @@ function Sn(e, t) {
|
|
|
965
985
|
...e._zod.def,
|
|
966
986
|
get shape() {
|
|
967
987
|
const r = { ...e._zod.def.shape, ...t };
|
|
968
|
-
return
|
|
988
|
+
return L(this, "shape", r), r;
|
|
969
989
|
},
|
|
970
990
|
checks: e._zod.def.checks
|
|
971
991
|
};
|
|
972
992
|
return R(e, n);
|
|
973
993
|
}
|
|
974
994
|
function On(e, t) {
|
|
975
|
-
const n =
|
|
995
|
+
const n = j(e._zod.def, {
|
|
976
996
|
get shape() {
|
|
977
997
|
const r = { ...e._zod.def.shape, ...t._zod.def.shape };
|
|
978
|
-
return
|
|
998
|
+
return L(this, "shape", r), r;
|
|
979
999
|
},
|
|
980
1000
|
get catchall() {
|
|
981
1001
|
return t._zod.def.catchall;
|
|
@@ -986,7 +1006,7 @@ function On(e, t) {
|
|
|
986
1006
|
return R(e, n);
|
|
987
1007
|
}
|
|
988
1008
|
function Tn(e, t, n) {
|
|
989
|
-
const r =
|
|
1009
|
+
const r = j(t._zod.def, {
|
|
990
1010
|
get shape() {
|
|
991
1011
|
const o = t._zod.def.shape, s = { ...o };
|
|
992
1012
|
if (n)
|
|
@@ -1004,14 +1024,14 @@ function Tn(e, t, n) {
|
|
|
1004
1024
|
type: "optional",
|
|
1005
1025
|
innerType: o[i]
|
|
1006
1026
|
}) : o[i];
|
|
1007
|
-
return
|
|
1027
|
+
return L(this, "shape", s), s;
|
|
1008
1028
|
},
|
|
1009
1029
|
checks: []
|
|
1010
1030
|
});
|
|
1011
1031
|
return R(t, r);
|
|
1012
1032
|
}
|
|
1013
1033
|
function In(e, t, n) {
|
|
1014
|
-
const r =
|
|
1034
|
+
const r = j(t._zod.def, {
|
|
1015
1035
|
get shape() {
|
|
1016
1036
|
const o = t._zod.def.shape, s = { ...o };
|
|
1017
1037
|
if (n)
|
|
@@ -1029,7 +1049,7 @@ function In(e, t, n) {
|
|
|
1029
1049
|
type: "nonoptional",
|
|
1030
1050
|
innerType: o[i]
|
|
1031
1051
|
});
|
|
1032
|
-
return
|
|
1052
|
+
return L(this, "shape", s), s;
|
|
1033
1053
|
},
|
|
1034
1054
|
checks: []
|
|
1035
1055
|
});
|
|
@@ -1149,13 +1169,13 @@ const Ze = (e) => (t, n, r, o) => {
|
|
|
1149
1169
|
}, Dn = (e) => (t, n, r) => Ze(e)(t, n, r), xn = (e) => async (t, n, r) => {
|
|
1150
1170
|
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
|
|
1151
1171
|
return Se(e)(t, n, o);
|
|
1152
|
-
},
|
|
1172
|
+
}, Ln = (e) => async (t, n, r) => Se(e)(t, n, r), jn = (e) => (t, n, r) => {
|
|
1153
1173
|
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
|
|
1154
1174
|
return ue(e)(t, n, o);
|
|
1155
1175
|
}, Un = (e) => (t, n, r) => ue(e)(t, n, r), Mn = (e) => async (t, n, r) => {
|
|
1156
1176
|
const o = r ? Object.assign(r, { direction: "backward" }) : { direction: "backward" };
|
|
1157
1177
|
return ae(e)(t, n, o);
|
|
1158
|
-
}, Fn = (e) => async (t, n, r) => ae(e)(t, n, r), Kn = /^[cC][^\s-]{8,}$/, Vn = /^[0-9a-z]+$/, Wn = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Gn = /^[0-9a-vA-V]{20}$/, Bn = /^[A-Za-z0-9]{27}$/, Jn = /^[a-zA-Z0-9_-]{21}$/, Hn = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Yn = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,
|
|
1178
|
+
}, Fn = (e) => async (t, n, r) => ae(e)(t, n, r), Kn = /^[cC][^\s-]{8,}$/, Vn = /^[0-9a-z]+$/, Wn = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Gn = /^[0-9a-vA-V]{20}$/, Bn = /^[A-Za-z0-9]{27}$/, Jn = /^[a-zA-Z0-9_-]{21}$/, Hn = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Yn = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, Le = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, qn = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, Xn = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1159
1179
|
function Qn() {
|
|
1160
1180
|
return new RegExp(Xn, "u");
|
|
1161
1181
|
}
|
|
@@ -1581,9 +1601,9 @@ const Tr = {
|
|
|
1581
1601
|
}[t.version];
|
|
1582
1602
|
if (r === void 0)
|
|
1583
1603
|
throw new Error(`Invalid UUID version: "${t.version}"`);
|
|
1584
|
-
t.pattern ?? (t.pattern =
|
|
1604
|
+
t.pattern ?? (t.pattern = Le(r));
|
|
1585
1605
|
} else
|
|
1586
|
-
t.pattern ?? (t.pattern =
|
|
1606
|
+
t.pattern ?? (t.pattern = Le());
|
|
1587
1607
|
b.init(e, t);
|
|
1588
1608
|
}), Cr = /* @__PURE__ */ u("$ZodEmail", (e, t) => {
|
|
1589
1609
|
t.pattern ?? (t.pattern = qn), b.init(e, t);
|
|
@@ -1627,9 +1647,9 @@ const Tr = {
|
|
|
1627
1647
|
t.pattern ?? (t.pattern = Kn), b.init(e, t);
|
|
1628
1648
|
}), xr = /* @__PURE__ */ u("$ZodCUID2", (e, t) => {
|
|
1629
1649
|
t.pattern ?? (t.pattern = Vn), b.init(e, t);
|
|
1630
|
-
}),
|
|
1650
|
+
}), Lr = /* @__PURE__ */ u("$ZodULID", (e, t) => {
|
|
1631
1651
|
t.pattern ?? (t.pattern = Wn), b.init(e, t);
|
|
1632
|
-
}),
|
|
1652
|
+
}), jr = /* @__PURE__ */ u("$ZodXID", (e, t) => {
|
|
1633
1653
|
t.pattern ?? (t.pattern = Gn), b.init(e, t);
|
|
1634
1654
|
}), Ur = /* @__PURE__ */ u("$ZodKSUID", (e, t) => {
|
|
1635
1655
|
t.pattern ?? (t.pattern = Bn), b.init(e, t);
|
|
@@ -1806,7 +1826,7 @@ const eo = /* @__PURE__ */ u("$ZodJWT", (e, t) => {
|
|
|
1806
1826
|
inst: e
|
|
1807
1827
|
}), n);
|
|
1808
1828
|
});
|
|
1809
|
-
function
|
|
1829
|
+
function je(e, t, n) {
|
|
1810
1830
|
e.issues.length && t.issues.push(...x(n, e.issues)), t.value[n] = e.value;
|
|
1811
1831
|
}
|
|
1812
1832
|
const io = /* @__PURE__ */ u("$ZodArray", (e, t) => {
|
|
@@ -1826,7 +1846,7 @@ const io = /* @__PURE__ */ u("$ZodArray", (e, t) => {
|
|
|
1826
1846
|
value: c,
|
|
1827
1847
|
issues: []
|
|
1828
1848
|
}, r);
|
|
1829
|
-
a instanceof Promise ? s.push(a.then((l) =>
|
|
1849
|
+
a instanceof Promise ? s.push(a.then((l) => je(l, n, i))) : je(a, n, i);
|
|
1830
1850
|
}
|
|
1831
1851
|
return s.length ? Promise.all(s).then(() => n) : n;
|
|
1832
1852
|
};
|
|
@@ -1907,25 +1927,25 @@ const co = /* @__PURE__ */ u("$ZodObject", (e, t) => {
|
|
|
1907
1927
|
c.value = {};
|
|
1908
1928
|
const h = [], f = i.shape;
|
|
1909
1929
|
for (const d of i.keys) {
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1930
|
+
const y = f[d]._zod.run({ value: l[d], issues: [] }, a);
|
|
1931
|
+
y instanceof Promise ? h.push(y.then((I) => se(I, c, d, l))) : se(y, c, d, l);
|
|
1912
1932
|
}
|
|
1913
1933
|
return s ? It(h, l, c, a, r.value, e) : h.length ? Promise.all(h).then(() => c) : c;
|
|
1914
1934
|
};
|
|
1915
1935
|
}), uo = /* @__PURE__ */ u("$ZodObjectJIT", (e, t) => {
|
|
1916
1936
|
co.init(e, t);
|
|
1917
1937
|
const n = e._zod.parse, r = ke(() => Tt(t)), o = (d) => {
|
|
1918
|
-
const m = new Or(["shape", "payload", "ctx"]),
|
|
1938
|
+
const m = new Or(["shape", "payload", "ctx"]), y = r.value, I = (S) => {
|
|
1919
1939
|
const z = xe(S);
|
|
1920
1940
|
return `shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`;
|
|
1921
1941
|
};
|
|
1922
1942
|
m.write("const input = payload.value;");
|
|
1923
1943
|
const H = /* @__PURE__ */ Object.create(null);
|
|
1924
1944
|
let de = 0;
|
|
1925
|
-
for (const S of
|
|
1945
|
+
for (const S of y.keys)
|
|
1926
1946
|
H[S] = `key_${de++}`;
|
|
1927
1947
|
m.write("const newResult = {};");
|
|
1928
|
-
for (const S of
|
|
1948
|
+
for (const S of y.keys) {
|
|
1929
1949
|
const z = H[S], N = xe(S);
|
|
1930
1950
|
m.write(`const ${z} = ${I(S)};`), m.write(`
|
|
1931
1951
|
if (${z}.issues.length) {
|
|
@@ -1955,11 +1975,11 @@ const co = /* @__PURE__ */ u("$ZodObject", (e, t) => {
|
|
|
1955
1975
|
let f;
|
|
1956
1976
|
e._zod.parse = (d, m) => {
|
|
1957
1977
|
f ?? (f = r.value);
|
|
1958
|
-
const
|
|
1959
|
-
return i(
|
|
1978
|
+
const y = d.value;
|
|
1979
|
+
return i(y) ? c && l && m?.async === !1 && m.jitless !== !0 ? (s || (s = o(t.shape)), d = s(d, m), h ? It([], y, d, m, f, e) : d) : n(d, m) : (d.issues.push({
|
|
1960
1980
|
expected: "object",
|
|
1961
1981
|
code: "invalid_type",
|
|
1962
|
-
input:
|
|
1982
|
+
input: y,
|
|
1963
1983
|
inst: e
|
|
1964
1984
|
}), d);
|
|
1965
1985
|
};
|
|
@@ -2458,7 +2478,7 @@ function xo(e, t) {
|
|
|
2458
2478
|
...p(t)
|
|
2459
2479
|
});
|
|
2460
2480
|
}
|
|
2461
|
-
function
|
|
2481
|
+
function Lo(e, t) {
|
|
2462
2482
|
return new e({
|
|
2463
2483
|
type: "string",
|
|
2464
2484
|
format: "cuid2",
|
|
@@ -2467,7 +2487,7 @@ function jo(e, t) {
|
|
|
2467
2487
|
...p(t)
|
|
2468
2488
|
});
|
|
2469
2489
|
}
|
|
2470
|
-
function
|
|
2490
|
+
function jo(e, t) {
|
|
2471
2491
|
return new e({
|
|
2472
2492
|
type: "string",
|
|
2473
2493
|
format: "ulid",
|
|
@@ -2805,25 +2825,25 @@ function ws(e, t) {
|
|
|
2805
2825
|
return n._zod.check = e, n;
|
|
2806
2826
|
}
|
|
2807
2827
|
const ys = /* @__PURE__ */ u("ZodISODateTime", (e, t) => {
|
|
2808
|
-
Mr.init(e, t),
|
|
2828
|
+
Mr.init(e, t), k.init(e, t);
|
|
2809
2829
|
});
|
|
2810
2830
|
function ks(e) {
|
|
2811
2831
|
return Yo(ys, e);
|
|
2812
2832
|
}
|
|
2813
2833
|
const Es = /* @__PURE__ */ u("ZodISODate", (e, t) => {
|
|
2814
|
-
Fr.init(e, t),
|
|
2834
|
+
Fr.init(e, t), k.init(e, t);
|
|
2815
2835
|
});
|
|
2816
2836
|
function zs(e) {
|
|
2817
2837
|
return qo(Es, e);
|
|
2818
2838
|
}
|
|
2819
2839
|
const $s = /* @__PURE__ */ u("ZodISOTime", (e, t) => {
|
|
2820
|
-
Kr.init(e, t),
|
|
2840
|
+
Kr.init(e, t), k.init(e, t);
|
|
2821
2841
|
});
|
|
2822
2842
|
function Zs(e) {
|
|
2823
2843
|
return Xo($s, e);
|
|
2824
2844
|
}
|
|
2825
2845
|
const Ss = /* @__PURE__ */ u("ZodISODuration", (e, t) => {
|
|
2826
|
-
Vr.init(e, t),
|
|
2846
|
+
Vr.init(e, t), k.init(e, t);
|
|
2827
2847
|
});
|
|
2828
2848
|
function Os(e) {
|
|
2829
2849
|
return Qo(Ss, e);
|
|
@@ -2859,12 +2879,12 @@ const Ts = (e, t) => {
|
|
|
2859
2879
|
});
|
|
2860
2880
|
}, Z = /* @__PURE__ */ u("ZodError", Ts, {
|
|
2861
2881
|
Parent: Error
|
|
2862
|
-
}), Is = /* @__PURE__ */ Ze(Z), Ps = /* @__PURE__ */ Se(Z), Cs = /* @__PURE__ */ ue(Z), As = /* @__PURE__ */ ae(Z), Rs = /* @__PURE__ */ Nn(Z), Ns = /* @__PURE__ */ Dn(Z), Ds = /* @__PURE__ */ xn(Z), xs = /* @__PURE__ */
|
|
2882
|
+
}), Is = /* @__PURE__ */ Ze(Z), Ps = /* @__PURE__ */ Se(Z), Cs = /* @__PURE__ */ ue(Z), As = /* @__PURE__ */ ae(Z), Rs = /* @__PURE__ */ Nn(Z), Ns = /* @__PURE__ */ Dn(Z), Ds = /* @__PURE__ */ xn(Z), xs = /* @__PURE__ */ Ln(Z), Ls = /* @__PURE__ */ jn(Z), js = /* @__PURE__ */ Un(Z), Us = /* @__PURE__ */ Mn(Z), Ms = /* @__PURE__ */ Fn(Z), w = /* @__PURE__ */ u("ZodType", (e, t) => (g.init(e, t), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => e.clone(j(t, {
|
|
2863
2883
|
checks: [
|
|
2864
2884
|
...t.checks ?? [],
|
|
2865
2885
|
...n.map((r) => typeof r == "function" ? { _zod: { check: r, def: { check: "custom" }, onattach: [] } } : r)
|
|
2866
2886
|
]
|
|
2867
|
-
})), e.clone = (n, r) => R(e, n, r), e.brand = () => e, e.register = (n, r) => (n.add(e, r), e), e.parse = (n, r) => Is(e, n, r, { callee: e.parse }), e.safeParse = (n, r) => Cs(e, n, r), e.parseAsync = async (n, r) => Ps(e, n, r, { callee: e.parseAsync }), e.safeParseAsync = async (n, r) => As(e, n, r), e.spa = e.safeParseAsync, e.encode = (n, r) => Rs(e, n, r), e.decode = (n, r) => Ns(e, n, r), e.encodeAsync = async (n, r) => Ds(e, n, r), e.decodeAsync = async (n, r) => xs(e, n, r), e.safeEncode = (n, r) =>
|
|
2887
|
+
})), e.clone = (n, r) => R(e, n, r), e.brand = () => e, e.register = (n, r) => (n.add(e, r), e), e.parse = (n, r) => Is(e, n, r, { callee: e.parse }), e.safeParse = (n, r) => Cs(e, n, r), e.parseAsync = async (n, r) => Ps(e, n, r, { callee: e.parseAsync }), e.safeParseAsync = async (n, r) => As(e, n, r), e.spa = e.safeParseAsync, e.encode = (n, r) => Rs(e, n, r), e.decode = (n, r) => Ns(e, n, r), e.encodeAsync = async (n, r) => Ds(e, n, r), e.decodeAsync = async (n, r) => xs(e, n, r), e.safeEncode = (n, r) => Ls(e, n, r), e.safeDecode = (n, r) => js(e, n, r), e.safeEncodeAsync = async (n, r) => Us(e, n, r), e.safeDecodeAsync = async (n, r) => Ms(e, n, r), e.refine = (n, r) => e.check(Li(n, r)), e.superRefine = (n) => e.check(ji(n)), e.overwrite = (n) => e.check(J(n)), e.optional = () => tt(e), e.nullable = () => nt(e), e.nullish = () => tt(nt(e)), e.nonoptional = (n) => Pi(e, n), e.array = () => pi(e), e.or = (n) => U([e, n]), e.and = (n) => vi(e, n), e.transform = (n) => rt(e, $i(n)), e.default = (n) => Oi(e, n), e.prefault = (n) => Ii(e, n), e.catch = (n) => Ai(e, n), e.pipe = (n) => rt(e, n), e.readonly = () => Di(e), e.describe = (n) => {
|
|
2868
2888
|
const r = e.clone();
|
|
2869
2889
|
return te.add(r, { description: n }), r;
|
|
2870
2890
|
}, Object.defineProperty(e, "description", {
|
|
@@ -2882,51 +2902,51 @@ const Ts = (e, t) => {
|
|
|
2882
2902
|
const n = e._zod.bag;
|
|
2883
2903
|
e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, e.regex = (...r) => e.check(is(...r)), e.includes = (...r) => e.check(as(...r)), e.startsWith = (...r) => e.check(ls(...r)), e.endsWith = (...r) => e.check(hs(...r)), e.min = (...r) => e.check(ie(...r)), e.max = (...r) => e.check(Pt(...r)), e.length = (...r) => e.check(Ct(...r)), e.nonempty = (...r) => e.check(ie(1, ...r)), e.lowercase = (r) => e.check(cs(r)), e.uppercase = (r) => e.check(us(r)), e.trim = () => e.check(fs()), e.normalize = (...r) => e.check(ds(...r)), e.toLowerCase = () => e.check(ps()), e.toUpperCase = () => e.check(ms()), e.slugify = () => e.check(_s());
|
|
2884
2904
|
}), Fs = /* @__PURE__ */ u("ZodString", (e, t) => {
|
|
2885
|
-
Oe.init(e, t), At.init(e, t), e.email = (n) => e.check(To(Ks, n)), e.url = (n) => e.check(Ro(Vs, n)), e.jwt = (n) => e.check(Ho(si, n)), e.emoji = (n) => e.check(No(Ws, n)), e.guid = (n) => e.check(Je(Xe, n)), e.uuid = (n) => e.check(Io(ne, n)), e.uuidv4 = (n) => e.check(Po(ne, n)), e.uuidv6 = (n) => e.check(Co(ne, n)), e.uuidv7 = (n) => e.check(Ao(ne, n)), e.nanoid = (n) => e.check(Do(Gs, n)), e.guid = (n) => e.check(Je(Xe, n)), e.cuid = (n) => e.check(xo(Bs, n)), e.cuid2 = (n) => e.check(
|
|
2905
|
+
Oe.init(e, t), At.init(e, t), e.email = (n) => e.check(To(Ks, n)), e.url = (n) => e.check(Ro(Vs, n)), e.jwt = (n) => e.check(Ho(si, n)), e.emoji = (n) => e.check(No(Ws, n)), e.guid = (n) => e.check(Je(Xe, n)), e.uuid = (n) => e.check(Io(ne, n)), e.uuidv4 = (n) => e.check(Po(ne, n)), e.uuidv6 = (n) => e.check(Co(ne, n)), e.uuidv7 = (n) => e.check(Ao(ne, n)), e.nanoid = (n) => e.check(Do(Gs, n)), e.guid = (n) => e.check(Je(Xe, n)), e.cuid = (n) => e.check(xo(Bs, n)), e.cuid2 = (n) => e.check(Lo(Js, n)), e.ulid = (n) => e.check(jo(Hs, n)), e.base64 = (n) => e.check(Go(ni, n)), e.base64url = (n) => e.check(Bo(ri, n)), e.xid = (n) => e.check(Uo(Ys, n)), e.ksuid = (n) => e.check(Mo(qs, n)), e.ipv4 = (n) => e.check(Fo(Xs, n)), e.ipv6 = (n) => e.check(Ko(Qs, n)), e.cidrv4 = (n) => e.check(Vo(ei, n)), e.cidrv6 = (n) => e.check(Wo(ti, n)), e.e164 = (n) => e.check(Jo(oi, n)), e.datetime = (n) => e.check(ks(n)), e.date = (n) => e.check(zs(n)), e.time = (n) => e.check(Zs(n)), e.duration = (n) => e.check(Os(n));
|
|
2886
2906
|
});
|
|
2887
2907
|
function W(e) {
|
|
2888
2908
|
return Oo(Fs, e);
|
|
2889
2909
|
}
|
|
2890
|
-
const
|
|
2910
|
+
const k = /* @__PURE__ */ u("ZodStringFormat", (e, t) => {
|
|
2891
2911
|
b.init(e, t), At.init(e, t);
|
|
2892
2912
|
}), Ks = /* @__PURE__ */ u("ZodEmail", (e, t) => {
|
|
2893
|
-
Cr.init(e, t),
|
|
2913
|
+
Cr.init(e, t), k.init(e, t);
|
|
2894
2914
|
}), Xe = /* @__PURE__ */ u("ZodGUID", (e, t) => {
|
|
2895
|
-
Ir.init(e, t),
|
|
2915
|
+
Ir.init(e, t), k.init(e, t);
|
|
2896
2916
|
}), ne = /* @__PURE__ */ u("ZodUUID", (e, t) => {
|
|
2897
|
-
Pr.init(e, t),
|
|
2917
|
+
Pr.init(e, t), k.init(e, t);
|
|
2898
2918
|
}), Vs = /* @__PURE__ */ u("ZodURL", (e, t) => {
|
|
2899
|
-
Ar.init(e, t),
|
|
2919
|
+
Ar.init(e, t), k.init(e, t);
|
|
2900
2920
|
}), Ws = /* @__PURE__ */ u("ZodEmoji", (e, t) => {
|
|
2901
|
-
Rr.init(e, t),
|
|
2921
|
+
Rr.init(e, t), k.init(e, t);
|
|
2902
2922
|
}), Gs = /* @__PURE__ */ u("ZodNanoID", (e, t) => {
|
|
2903
|
-
Nr.init(e, t),
|
|
2923
|
+
Nr.init(e, t), k.init(e, t);
|
|
2904
2924
|
}), Bs = /* @__PURE__ */ u("ZodCUID", (e, t) => {
|
|
2905
|
-
Dr.init(e, t),
|
|
2925
|
+
Dr.init(e, t), k.init(e, t);
|
|
2906
2926
|
}), Js = /* @__PURE__ */ u("ZodCUID2", (e, t) => {
|
|
2907
|
-
xr.init(e, t),
|
|
2927
|
+
xr.init(e, t), k.init(e, t);
|
|
2908
2928
|
}), Hs = /* @__PURE__ */ u("ZodULID", (e, t) => {
|
|
2909
|
-
|
|
2929
|
+
Lr.init(e, t), k.init(e, t);
|
|
2910
2930
|
}), Ys = /* @__PURE__ */ u("ZodXID", (e, t) => {
|
|
2911
|
-
|
|
2931
|
+
jr.init(e, t), k.init(e, t);
|
|
2912
2932
|
}), qs = /* @__PURE__ */ u("ZodKSUID", (e, t) => {
|
|
2913
|
-
Ur.init(e, t),
|
|
2933
|
+
Ur.init(e, t), k.init(e, t);
|
|
2914
2934
|
}), Xs = /* @__PURE__ */ u("ZodIPv4", (e, t) => {
|
|
2915
|
-
Wr.init(e, t),
|
|
2935
|
+
Wr.init(e, t), k.init(e, t);
|
|
2916
2936
|
}), Qs = /* @__PURE__ */ u("ZodIPv6", (e, t) => {
|
|
2917
|
-
Gr.init(e, t),
|
|
2937
|
+
Gr.init(e, t), k.init(e, t);
|
|
2918
2938
|
}), ei = /* @__PURE__ */ u("ZodCIDRv4", (e, t) => {
|
|
2919
|
-
Br.init(e, t),
|
|
2939
|
+
Br.init(e, t), k.init(e, t);
|
|
2920
2940
|
}), ti = /* @__PURE__ */ u("ZodCIDRv6", (e, t) => {
|
|
2921
|
-
Jr.init(e, t),
|
|
2941
|
+
Jr.init(e, t), k.init(e, t);
|
|
2922
2942
|
}), ni = /* @__PURE__ */ u("ZodBase64", (e, t) => {
|
|
2923
|
-
Hr.init(e, t),
|
|
2943
|
+
Hr.init(e, t), k.init(e, t);
|
|
2924
2944
|
}), ri = /* @__PURE__ */ u("ZodBase64URL", (e, t) => {
|
|
2925
|
-
qr.init(e, t),
|
|
2945
|
+
qr.init(e, t), k.init(e, t);
|
|
2926
2946
|
}), oi = /* @__PURE__ */ u("ZodE164", (e, t) => {
|
|
2927
|
-
Xr.init(e, t),
|
|
2947
|
+
Xr.init(e, t), k.init(e, t);
|
|
2928
2948
|
}), si = /* @__PURE__ */ u("ZodJWT", (e, t) => {
|
|
2929
|
-
eo.init(e, t),
|
|
2949
|
+
eo.init(e, t), k.init(e, t);
|
|
2930
2950
|
}), Rt = /* @__PURE__ */ u("ZodNumber", (e, t) => {
|
|
2931
2951
|
Ot.init(e, t), w.init(e, t), e.gt = (r, o) => e.check(Ye(r, o)), e.gte = (r, o) => e.check(me(r, o)), e.min = (r, o) => e.check(me(r, o)), e.lt = (r, o) => e.check(He(r, o)), e.lte = (r, o) => e.check(pe(r, o)), e.max = (r, o) => e.check(pe(r, o)), e.int = (r) => e.check(Qe(r)), e.safe = (r) => e.check(Qe(r)), e.positive = (r) => e.check(Ye(0, r)), e.nonnegative = (r) => e.check(me(0, r)), e.negative = (r) => e.check(He(0, r)), e.nonpositive = (r) => e.check(pe(0, r)), e.multipleOf = (r, o) => e.check(qe(r, o)), e.step = (r, o) => e.check(qe(r, o)), e.finite = () => e;
|
|
2932
2952
|
const n = e._zod.bag;
|
|
@@ -3190,10 +3210,10 @@ function Di(e) {
|
|
|
3190
3210
|
const xi = /* @__PURE__ */ u("ZodCustom", (e, t) => {
|
|
3191
3211
|
$o.init(e, t), w.init(e, t);
|
|
3192
3212
|
});
|
|
3193
|
-
function
|
|
3213
|
+
function Li(e, t = {}) {
|
|
3194
3214
|
return vs(xi, e, t);
|
|
3195
3215
|
}
|
|
3196
|
-
function
|
|
3216
|
+
function ji(e) {
|
|
3197
3217
|
return bs(e);
|
|
3198
3218
|
}
|
|
3199
3219
|
const he = v({
|
|
@@ -3286,14 +3306,14 @@ const he = v({
|
|
|
3286
3306
|
}), qi = v({
|
|
3287
3307
|
...Fi.shape,
|
|
3288
3308
|
keyframes: T([Ji], U([Bi, Te]))
|
|
3289
|
-
}), Xi = yi(W(), U([Hi, Yi, qi])),
|
|
3309
|
+
}), Xi = yi(W(), U([Hi, Yi, qi])), Lt = {
|
|
3290
3310
|
opacity: 1,
|
|
3291
3311
|
zIndex: 0
|
|
3292
3312
|
}, Ie = {
|
|
3293
3313
|
t: 0,
|
|
3294
3314
|
rate: 1,
|
|
3295
3315
|
volume: 1
|
|
3296
|
-
},
|
|
3316
|
+
}, jt = {
|
|
3297
3317
|
t: 0,
|
|
3298
3318
|
rate: 1,
|
|
3299
3319
|
volume: 1,
|
|
@@ -3303,8 +3323,8 @@ const he = v({
|
|
|
3303
3323
|
__proto__: null,
|
|
3304
3324
|
MediaSurfaceStateSchema: Xi,
|
|
3305
3325
|
defaultAudioOptions: Ie,
|
|
3306
|
-
defaultImageOptions:
|
|
3307
|
-
defaultVideoOptions:
|
|
3326
|
+
defaultImageOptions: Lt,
|
|
3327
|
+
defaultVideoOptions: jt
|
|
3308
3328
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3309
3329
|
function Pe(e, t) {
|
|
3310
3330
|
if (!e.keyframes.filter((r) => r[1] === null).some((r) => r[0] <= t))
|
|
@@ -3313,7 +3333,7 @@ function Pe(e, t) {
|
|
|
3313
3333
|
if (e.keyframes[0][0] > t)
|
|
3314
3334
|
return;
|
|
3315
3335
|
const o = e.keyframes.filter((i) => i[1] !== null), s = _e(o, t);
|
|
3316
|
-
return { ...
|
|
3336
|
+
return { ...Lt, ...s };
|
|
3317
3337
|
}
|
|
3318
3338
|
case "audio": {
|
|
3319
3339
|
const r = e.keyframes.filter((i) => i[1] !== null), o = ot(r, t);
|
|
@@ -3327,7 +3347,7 @@ function Pe(e, t) {
|
|
|
3327
3347
|
if (!o)
|
|
3328
3348
|
return;
|
|
3329
3349
|
const s = _e(r, t);
|
|
3330
|
-
return { ...
|
|
3350
|
+
return { ...jt, ...s, ...o };
|
|
3331
3351
|
}
|
|
3332
3352
|
}
|
|
3333
3353
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(w,F){typeof exports=="object"&&typeof module<"u"?F(exports):typeof define=="function"&&define.amd?define(["exports"],F):(w=typeof globalThis<"u"?globalThis:w||self,F(w.COGS={}))})(this,function(w){"use strict";var F=(e=>(e.Setup="setup",e.Preshow="pre-show",e.InProgress="in progress",e.Finished="finished",e))(F||{});/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
4
4
|
this file except in compliance with the License. You may obtain a copy of the
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
* by Pedro Ladaria <pedro.ladaria@gmail.com>
|
|
17
17
|
* https://github.com/pladaria/reconnecting-websocket
|
|
18
18
|
* License MIT
|
|
19
|
-
*/var cn=function(){if(typeof WebSocket<"u")return WebSocket},un=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},D={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},an=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?D.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?D.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=tn(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,rn(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?D.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?D.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?D.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?D.maxRetries:r,s=n.connectionTimeout,i=s===void 0?D.connectionTimeout:s,c=n.WebSocket,a=c===void 0?cn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!un(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new on(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new sn(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const xe=12095;function Me(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${xe}${n}`}async function ln(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class hn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class _e extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class ge extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const q=globalThis.Date;function dn(e){const t=Math.round(e-q.now());function n(...o){return o.length===0?new q(n.now()):new q(...o)}const r=Object.getOwnPropertyDescriptors(q);Object.defineProperties(n,r),n.now=function(){return q.now()+t},globalThis.Date=n}let fn=0;function pn(){return++fn}const mn=5,_n=1e4;function gn({interval:e,send:t,onChange:n=dn,syncSampleSize:r=mn,syncRequestTimeout:o=_n}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(P=>{const Q=pn(),De=Date.now(),je=performance.now();t({timesync:{id:Q}});const O=(S,M)=>P({sentAt:je,receivedAt:S,serverNow:M,clientNow:De});s[Q]={complete:O},setTimeout(()=>P(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=vn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function vn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class bn{constructor(t,{hostname:n=document.location.hostname,port:r=xe}={},o,s){this.manifest=t,this.currentState={...o},this.store=new hn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=wn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new an(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Fe),this.setState(this.currentState),h=gn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new Ke)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new We(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ge(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new Be(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new He(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Je(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break}this.dispatchEvent(new Ve(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=F.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${Me(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function wn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Fe extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class Ke extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Ve extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class We extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ge extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class Be extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Je extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class He extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class K extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ye extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const qe={};function A(e){return qe}function yn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function we(e){return e==null}function ye(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function kn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Xe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xe)return r===void 0&&(r=Xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zn=be(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(ee(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ee(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const $n=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Zn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function On(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return j(this,"shape",o),o},checks:[]});return R(e,r)}function Tn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return j(this,"shape",o),o},checks:[]});return R(e,r)}function In(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return j(this,"shape",s),s},checks:[]});return R(e,o)}function Cn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return j(this,"shape",r),r},checks:e._zod.def.checks};return R(e,n)}function Pn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return j(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return R(e,n)}function An(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return j(this,"shape",s),s},checks:[]});return R(t,r)}function Rn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return j(this,"shape",s),s},checks:[]});return R(t,r)}function G(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function U(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function N(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=te(e.inst?._zod.def?.error?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function X(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const nt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=u("$ZodError",nt),ot=u("$ZodError",nt,{Parent:Error});function Nn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dn(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new K;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ze=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ne=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new K;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},jn=ne(ot),re=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},Ln=re(ot),Un=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},xn=e=>(t,n,r)=>Ee(e)(t,n,r),Mn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,o)},Fn=e=>async(t,n,r)=>ze(e)(t,n,r),Kn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Vn=e=>(t,n,r)=>ne(e)(t,n,r),Wn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,o)},Gn=e=>async(t,n,r)=>re(e)(t,n,r),Bn=/^[cC][^\s-]{8,}$/,Jn=/^[0-9a-z]+$/,Hn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/,Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,er=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,st=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rr(){return new RegExp(nr,"u")}const or=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ir=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,ar=/^\+(?:[0-9]){6,14}[0-9]$/,ct="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",lr=new RegExp(`^${ct}$`);function ut(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hr(e){return new RegExp(`^${ut(e)}$`)}function dr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${r})$`)}const fr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?/,_r=/^(?:true|false)$/i,gr=/^null$/i,vr=/^[^A-Z]*$/,br=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),at={number:"number",bigint:"bigint",object:"date"},lt=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):kn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),yr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Sn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=pr)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),kr=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ke(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ke(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!we(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ke(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),oe=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$r=u("$ZodCheckRegex",(e,t)=>{oe.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vr),oe.init(e,t)}),Sr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=br),oe.init(e,t)}),Or=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Tr=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ir=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Pr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
19
|
+
*/var cn=function(){if(typeof WebSocket<"u")return WebSocket},un=function(e){return typeof e<"u"&&!!e&&e.CLOSING===2},D={maxReconnectionDelay:1e4,minReconnectionDelay:1e3+Math.random()*4e3,minUptime:5e3,reconnectionDelayGrowFactor:1.3,connectionTimeout:4e3,maxRetries:1/0,maxEnqueuedMessages:1/0},an=function(){function e(t,n,r){var o=this;r===void 0&&(r={}),this._listeners={error:[],message:[],open:[],close:[]},this._retryCount=-1,this._shouldReconnect=!0,this._connectLock=!1,this._binaryType="blob",this._closeCalled=!1,this._messageQueue=[],this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this._handleOpen=function(s){o._debug("open event");var i=o._options.minUptime,c=i===void 0?D.minUptime:i;clearTimeout(o._connectTimeout),o._uptimeTimeout=setTimeout(function(){return o._acceptOpen()},c),o._ws.binaryType=o._binaryType,o._messageQueue.forEach(function(a){return o._ws.send(a)}),o._messageQueue=[],o.onopen&&o.onopen(s),o._listeners.open.forEach(function(a){return o._callEventListener(s,a)})},this._handleMessage=function(s){o._debug("message event"),o.onmessage&&o.onmessage(s),o._listeners.message.forEach(function(i){return o._callEventListener(s,i)})},this._handleError=function(s){o._debug("error event",s.message),o._disconnect(void 0,s.message==="TIMEOUT"?"timeout":void 0),o.onerror&&o.onerror(s),o._debug("exec error listeners"),o._listeners.error.forEach(function(i){return o._callEventListener(s,i)}),o._connect()},this._handleClose=function(s){o._debug("close event"),o._clearTimeouts(),o._shouldReconnect&&o._connect(),o.onclose&&o.onclose(s),o._listeners.close.forEach(function(i){return o._callEventListener(s,i)})},this._url=t,this._protocols=n,this._options=r,this._options.startClosed&&(this._shouldReconnect=!1),this._connect()}return Object.defineProperty(e,"CONNECTING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OPEN",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CLOSED",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CONNECTING",{get:function(){return e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"OPEN",{get:function(){return e.OPEN},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSING",{get:function(){return e.CLOSING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"CLOSED",{get:function(){return e.CLOSED},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"binaryType",{get:function(){return this._ws?this._ws.binaryType:this._binaryType},set:function(t){this._binaryType=t,this._ws&&(this._ws.binaryType=t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"retryCount",{get:function(){return Math.max(this._retryCount,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var t=this._messageQueue.reduce(function(n,r){return typeof r=="string"?n+=r.length:r instanceof Blob?n+=r.size:n+=r.byteLength,n},0);return t+(this._ws?this._ws.bufferedAmount:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this._ws?this._ws.extensions:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this._ws?this._ws.protocol:""},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._ws?this._ws.readyState:this._options.startClosed?e.CLOSED:e.CONNECTING},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"url",{get:function(){return this._ws?this._ws.url:""},enumerable:!0,configurable:!0}),e.prototype.close=function(t,n){if(t===void 0&&(t=1e3),this._closeCalled=!0,this._shouldReconnect=!1,this._clearTimeouts(),!this._ws){this._debug("close enqueued: no ws instance");return}if(this._ws.readyState===this.CLOSED){this._debug("close: already closed");return}this._ws.close(t,n)},e.prototype.reconnect=function(t,n){this._shouldReconnect=!0,this._closeCalled=!1,this._retryCount=-1,!this._ws||this._ws.readyState===this.CLOSED?this._connect():(this._disconnect(t,n),this._connect())},e.prototype.send=function(t){if(this._ws&&this._ws.readyState===this.OPEN)this._debug("send",t),this._ws.send(t);else{var n=this._options.maxEnqueuedMessages,r=n===void 0?D.maxEnqueuedMessages:n;this._messageQueue.length<r&&(this._debug("enqueue",t),this._messageQueue.push(t))}},e.prototype.addEventListener=function(t,n){this._listeners[t]&&this._listeners[t].push(n)},e.prototype.dispatchEvent=function(t){var n,r,o=this._listeners[t.type];if(o)try{for(var s=tn(o),i=s.next();!i.done;i=s.next()){var c=i.value;this._callEventListener(t,c)}}catch(a){n={error:a}}finally{try{i&&!i.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return!0},e.prototype.removeEventListener=function(t,n){this._listeners[t]&&(this._listeners[t]=this._listeners[t].filter(function(r){return r!==n}))},e.prototype._debug=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];this._options.debug&&console.log.apply(console,rn(["RWS>"],t))},e.prototype._getNextDelay=function(){var t=this._options,n=t.reconnectionDelayGrowFactor,r=n===void 0?D.reconnectionDelayGrowFactor:n,o=t.minReconnectionDelay,s=o===void 0?D.minReconnectionDelay:o,i=t.maxReconnectionDelay,c=i===void 0?D.maxReconnectionDelay:i,a=0;return this._retryCount>0&&(a=s*Math.pow(r,this._retryCount-1),a>c&&(a=c)),this._debug("next delay",a),a},e.prototype._wait=function(){var t=this;return new Promise(function(n){setTimeout(n,t._getNextDelay())})},e.prototype._getNextUrl=function(t){if(typeof t=="string")return Promise.resolve(t);if(typeof t=="function"){var n=t();if(typeof n=="string")return Promise.resolve(n);if(n.then)return n}throw Error("Invalid URL")},e.prototype._connect=function(){var t=this;if(!(this._connectLock||!this._shouldReconnect)){this._connectLock=!0;var n=this._options,r=n.maxRetries,o=r===void 0?D.maxRetries:r,s=n.connectionTimeout,i=s===void 0?D.connectionTimeout:s,c=n.WebSocket,a=c===void 0?cn():c;if(this._retryCount>=o){this._debug("max retries reached",this._retryCount,">=",o);return}if(this._retryCount++,this._debug("connect",this._retryCount),this._removeListeners(),!un(a))throw Error("No valid WebSocket class provided");this._wait().then(function(){return t._getNextUrl(t._url)}).then(function(l){t._closeCalled||(t._debug("connect",{url:l,protocols:t._protocols}),t._ws=t._protocols?new a(l,t._protocols):new a(l),t._ws.binaryType=t._binaryType,t._connectLock=!1,t._addListeners(),t._connectTimeout=setTimeout(function(){return t._handleTimeout()},i))})}},e.prototype._handleTimeout=function(){this._debug("timeout event"),this._handleError(new on(Error("TIMEOUT"),this))},e.prototype._disconnect=function(t,n){if(t===void 0&&(t=1e3),this._clearTimeouts(),!!this._ws){this._removeListeners();try{this._ws.close(t,n),this._handleClose(new sn(t,n,this))}catch{}}},e.prototype._acceptOpen=function(){this._debug("accept open"),this._retryCount=0},e.prototype._callEventListener=function(t,n){"handleEvent"in n?n.handleEvent(t):n(t)},e.prototype._removeListeners=function(){this._ws&&(this._debug("removeListeners"),this._ws.removeEventListener("open",this._handleOpen),this._ws.removeEventListener("close",this._handleClose),this._ws.removeEventListener("message",this._handleMessage),this._ws.removeEventListener("error",this._handleError))},e.prototype._addListeners=function(){this._ws&&(this._debug("addListeners"),this._ws.addEventListener("open",this._handleOpen),this._ws.addEventListener("close",this._handleClose),this._ws.addEventListener("message",this._handleMessage),this._ws.addEventListener("error",this._handleError))},e.prototype._clearTimeouts=function(){clearTimeout(this._connectTimeout),clearTimeout(this._uptimeTimeout)},e}();const xe=12095;function Me(e){const t=typeof window<"u"?window.location:void 0,n=`/assets/${encodeURIComponent(e)}`;return`${t?.protocol}//${t?.hostname}:${xe}${n}`}async function ln(e){const t=await fetch(e);return URL.createObjectURL(new Blob([await t.arrayBuffer()]))}class hn{_items;#e=new EventTarget;constructor(t){this._items={...t}}handleDataStoreItemsMessage(t){this._items={...this._items,...t.items},Object.entries(t.items).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t.items))}get items(){return this._items}getItem(t){return this._items[t]}setItems(t){return this._items={...this._items,...t},Object.entries(t).forEach(([n,r])=>{this.dispatchEvent(new _e(n,r))}),this.dispatchEvent(new ge(t)),this}addEventListener(t,n,r){this.#e.addEventListener(t,n,r)}removeEventListener(t,n,r){this.#e.removeEventListener(t,n,r)}dispatchEvent(t){this.#e.dispatchEvent(t)}}class _e extends Event{constructor(t,n){super("item"),this.key=t,this.value=n}_cogsConnectionEventType="item"}class ge extends Event{constructor(t){super("items"),this.items=t}_cogsConnectionEventType="item"}const q=globalThis.Date;function dn(e){const t=Math.round(e-q.now());function n(...o){return o.length===0?new q(n.now()):new q(...o)}const r=Object.getOwnPropertyDescriptors(q);Object.defineProperties(n,r),n.now=function(){return q.now()+t},globalThis.Date=n}let fn=0;function pn(){return++fn}const mn=5,_n=1e4;function gn({interval:e,send:t,onChange:n=dn,syncSampleSize:r=mn,syncRequestTimeout:o=_n}){const s={};async function i(){const h=[];for(let m=0;m<r;m++){const E=new Promise(P=>{const Q=pn(),De=Date.now(),je=performance.now();t({timesync:{id:Q}});const O=(S,M)=>P({sentAt:je,receivedAt:S,serverNow:M,clientNow:De});s[Q]={complete:O},setTimeout(()=>P(null),o)});h.push(E),await E}const p=(await Promise.all(h)).filter(m=>m!==null),d=vn(p);isNaN(d)||n(Date.now()+d)}const c=h=>{const p=performance.now(),d=s[h.timesync.id];d&&d.complete(p,h.timesync.now)};i();const a=setInterval(i,e);return{receive:c,destroy:()=>{clearInterval(a)}}}function vn(e){return e.map(({sentAt:t,receivedAt:n,clientNow:r,serverNow:o})=>{const s=(n-t)/2;return o-r-s}).reduce((t,n)=>t+n,0)/e.length}class bn{constructor(t,{hostname:n=document.location.hostname,port:r=xe}={},o,s){this.manifest=t,this.currentState={...o},this.store=new hn(s??{});const{useReconnectingWebsocket:i,path:c,pathParams:a}=yn(document.location.href);this.urlParams=new URLSearchParams(a),this.urlParams.set("screenWidth",window.screen.width.toString()),this.urlParams.set("screenHeight",window.screen.height.toString()),this.urlParams.set("screenPixelRatio",window.devicePixelRatio.toString());const l=`ws://${n}:${r}${c}?${this.urlParams}`;this.websocket=i?new an(l):new WebSocket(l);let h;this.websocket.onopen=()=>{this.currentConfig={},this.currentState={},this.dispatchEvent(new Fe),this.setState(this.currentState),h=gn({interval:6e4,send:p=>{this.websocket.send(JSON.stringify(p))}})},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);if(typeof d=="object"&&d!==null&&"timesync"in d){const m=d;h?.receive(m)}}catch(d){console.error(d)}}),this.websocket.onclose=()=>{h?.destroy(),this.dispatchEvent(new Ke)},this.websocket.addEventListener("message",({data:p})=>{try{const d=JSON.parse(p);try{if(d.config)this.currentConfig=d.config,this.dispatchEvent(new We(this.currentConfig));else if(d.updates)this.currentState={...this.currentState,...d.updates},this.dispatchEvent(new Ge(d.updates));else if(d.event&&d.event.key)this.dispatchEvent(new Be(d.event.key,d.event.value));else if(typeof d.message=="object"){const m=d.message;switch(m.type){case"adjustable_timer_update":this._timerState={startedAt:Date.now(),durationMillis:m.durationMillis,ticking:m.ticking};break;case"show_phase":this._showPhase=m.phase,this.dispatchEvent(new He(m.phase));break;case"media_config_update":this._mediaConfig=m;for(const E of["preferOptimizedAudio","preferOptimizedVideo","preferOptimizedImages"])m[E]?this.urlParams.set(E,"true"):this.urlParams.delete(E);this.dispatchEvent(new Je(m));break;case"data_store_items":this.store.handleDataStoreItemsMessage(m);break;case"audio_play":case"audio_pause":case"audio_stop":case"audio_set_clip_volume":case"video_play":case"video_pause":case"video_stop":case"video_set_volume":case"video_set_fit":case"image_show":case"image_hide":case"image_set_fit":{const{type:E}=m;"media_strategy"in m||console.warn(`Legacy ${E} message received, this is no longer supported. Please upgrade to COGS 5.10 or downgrade to cogs-client@2.11`)}}this.dispatchEvent(new Ve(m))}}catch(m){console.warn("Error handling data",p,m)}}catch(d){console.error("Unable to parse incoming data from server",p,d)}}),this.store.addEventListener("items",p=>{this.sendDataStoreItems(p.items)});{const p=async()=>{if(navigator.mediaDevices){const d=(await navigator.mediaDevices.enumerateDevices()).filter(({kind:m})=>m==="audiooutput");this.sendAudioOutputs(d),this.audioOutputs=d}};this.eventTarget.addEventListener("open",p),navigator.mediaDevices?.addEventListener("devicechange",p),p()}}websocket;eventTarget=new EventTarget;currentConfig={};get config(){return{...this.currentConfig}}currentState={};get state(){return{...this.currentState}}_showPhase=F.Setup;get showPhase(){return this._showPhase}_timerState=null;get timerState(){return this._timerState?{...this._timerState}:null}_mediaConfig=null;get mediaConfig(){return this._mediaConfig?{...this._mediaConfig}:null}getAssetUrl(t){return`${Me(t)}?${this.urlParams?.toString()??""}`}audioOutputs=void 0;_selectedAudioOutput="";get selectedAudioOutput(){return this._selectedAudioOutput}store;urlParams;get isConnected(){return this.websocket.readyState===WebSocket.OPEN}close(){this.websocket.close()}sendEvent(t,...[n]){this.isConnected&&this.websocket.send(JSON.stringify({event:{key:t,value:n}}))}setState(t){this.currentState={...this.currentState,...t},this.isConnected&&this.websocket.send(JSON.stringify({updates:t}))}getAudioSinkId(t){return t?this.audioOutputs?.find(({label:n})=>n===t)?.deviceId:""}sendAudioOutputs(t){this.isConnected&&this.websocket.send(JSON.stringify({audioOutputs:t}))}sendDataStoreItems(t){this.isConnected&&this.websocket.send(JSON.stringify({dataStoreItems:t}))}setPluginWindowVisible(t){this.isConnected&&this.websocket.send(JSON.stringify({window:{visible:t}}))}addEventListener(t,n,r){this.eventTarget.addEventListener(t,n,r)}removeEventListener(t,n,r){this.eventTarget.removeEventListener(t,n,r)}dispatchEvent(t){this.eventTarget.dispatchEvent(t)}}function yn(e){const t=new URL(e),n=new URLSearchParams(t.searchParams),r=n.get("local_id"),o=n.get("simulator")==="true",s=n.get("display")??"",i=t.pathname.startsWith("/plugin/")?decodeURIComponent(t.pathname.split("/")[2]):void 0;if(r){const c=n.get("t")??"";return n.delete("local_id"),{path:`/local/${encodeURIComponent(r)}`,pathParams:new URLSearchParams({t:c}),useReconnectingWebsocket:!0}}else if(o){const c=n.get("name")??"";return n.delete("simulator"),n.delete("name"),{path:`/simulator/${encodeURIComponent(c)}`,pathParams:n,useReconnectingWebsocket:!0}}else if(s){const c=n.get("displayIdIndex")??"";return n.delete("display"),n.delete("displayIdIndex"),{path:`/display/${encodeURIComponent(s)}/${encodeURIComponent(c)}`}}else{if(i)return{path:`/plugin/${encodeURIComponent(i)}`,useReconnectingWebsocket:!0};{const c=n.get("serial")??"";return n.delete("serial"),{path:`/client/${encodeURIComponent(c)}`,pathParams:n}}}}class Fe extends Event{_cogsConnectionEventType="open";constructor(){super("open")}}class Ke extends Event{_cogsConnectionEventType="close";constructor(){super("close")}}class Ve extends Event{constructor(t){super("message"),this.message=t}_cogsConnectionEventType="message"}class We extends Event{constructor(t){super("config"),this.config=t}_cogsConnectionEventType="config"}class Ge extends Event{constructor(t){super("state"),this.state=t}_cogsConnectionEventType="state"}class Be extends Event{constructor(t,n){super("event"),this.name=t,this.value=n}_cogsConnectionEventType="event"}class Je extends Event{constructor(t){super("mediaConfig"),this.mediaConfig=t}_cogsConnectionEventType="mediaConfig"}class He extends Event{constructor(t){super("showPhase"),this.showPhase=t}_cogsConnectionEventType="showPhase"}function u(e,t,n){function r(c,a){if(c._zod||Object.defineProperty(c,"_zod",{value:{def:a,constr:i,traits:new Set},enumerable:!1}),c._zod.traits.has(e))return;c._zod.traits.add(e),t(c,a);const l=i.prototype,h=Object.keys(l);for(let p=0;p<h.length;p++){const d=h[p];d in c||(c[d]=l[d].bind(c))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(c){var a;const l=n?.Parent?new s:this;r(l,c),(a=l._zod).deferred??(a.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:c=>n?.Parent&&c instanceof n.Parent?!0:c?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class K extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ye extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const qe={};function A(e){return qe}function wn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ve(e,t){return typeof t=="bigint"?t.toString():t}function be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ye(e){return e==null}function we(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function kn(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(o===0&&/\d?e-\d?/.test(r)){const a=r.match(/\d?e-(\d?)/);a?.[1]&&(o=Number.parseInt(a[1]))}const s=n>o?n:o,i=Number.parseInt(e.toFixed(s).replace(".","")),c=Number.parseInt(t.toFixed(s).replace(".",""));return i%c/10**s}const Xe=Symbol("evaluating");function _(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Xe)return r===void 0&&(r=Xe,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function L(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function Qe(e){return JSON.stringify(e)}function En(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const et="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ee(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zn=be(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function V(e){if(ee(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ee(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function tt(e){return V(e)?{...e}:Array.isArray(e)?[...e]:e}const $n=new Set(["string","number","symbol"]);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function R(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function f(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Zn(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sn={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function On(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&(o[s]=n.shape[s])}return j(this,"shape",o),o},checks:[]});return R(e,r)}function Tn(e,t){const n=e._zod.def,r=L(e._zod.def,{get shape(){const o={...e._zod.def.shape};for(const s in t){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);t[s]&&delete o[s]}return j(this,"shape",o),o},checks:[]});return R(e,r)}function In(e,t){if(!V(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const o=L(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return j(this,"shape",s),s},checks:[]});return R(e,o)}function Cn(e,t){if(!V(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return j(this,"shape",r),r},checks:e._zod.def.checks};return R(e,n)}function Pn(e,t){const n=L(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return j(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return R(e,n)}function An(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in o))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=e?new e({type:"optional",innerType:o[i]}):o[i])}else for(const i in o)s[i]=e?new e({type:"optional",innerType:o[i]}):o[i];return j(this,"shape",s),s},checks:[]});return R(t,r)}function Rn(e,t,n){const r=L(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return j(this,"shape",s),s},checks:[]});return R(t,r)}function G(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function U(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e?.message}function N(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=te(e.inst?._zod.def?.error?.(e))??te(t?.error?.(e))??te(n.customError?.(e))??te(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ke(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function X(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const nt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ve,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},rt=u("$ZodError",nt),ot=u("$ZodError",nt,{Parent:Error});function Nn(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dn(e,t=n=>n.message){const n={_errors:[]},r=o=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(i=>r({issues:i}));else if(s.code==="invalid_key")r({issues:s.issues});else if(s.code==="invalid_element")r({issues:s.issues});else if(s.path.length===0)n._errors.push(t(s));else{let i=n,c=0;for(;c<s.path.length;){const a=s.path[c];c===s.path.length-1?(i[a]=i[a]||{_errors:[]},i[a]._errors.push(t(s))):i[a]=i[a]||{_errors:[]},i=i[a],c++}}};return r(e),n}const Ee=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new K;if(i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ze=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const c=new(o?.Err??e)(i.issues.map(a=>N(a,s,A())));throw et(c,o?.callee),c}return i.value},ne=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new K;return s.issues.length?{success:!1,error:new(e??rt)(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},jn=ne(ot),re=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>N(i,o,A())))}:{success:!0,data:s.value}},Ln=re(ot),Un=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return Ee(e)(t,n,o)},xn=e=>(t,n,r)=>Ee(e)(t,n,r),Mn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ze(e)(t,n,o)},Fn=e=>async(t,n,r)=>ze(e)(t,n,r),Kn=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return ne(e)(t,n,o)},Vn=e=>(t,n,r)=>ne(e)(t,n,r),Wn=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return re(e)(t,n,o)},Gn=e=>async(t,n,r)=>re(e)(t,n,r),Bn=/^[cC][^\s-]{8,}$/,Jn=/^[0-9a-z]+$/,Hn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Yn=/^[0-9a-vA-V]{20}$/,qn=/^[A-Za-z0-9]{27}$/,Xn=/^[a-zA-Z0-9_-]{21}$/,Qn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,er=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,st=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function rr(){return new RegExp(nr,"u")}const or=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,sr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ir=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cr=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ur=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,ar=/^\+(?:[0-9]){6,14}[0-9]$/,ct="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",lr=new RegExp(`^${ct}$`);function ut(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hr(e){return new RegExp(`^${ut(e)}$`)}function dr(e){const t=ut({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${ct}T(?:${r})$`)}const fr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pr=/^-?\d+$/,mr=/^-?\d+(?:\.\d+)?/,_r=/^(?:true|false)$/i,gr=/^null$/i,vr=/^[^A-Z]*$/,br=/^[^a-z]*$/,z=u("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),at={number:"number",bigint:"bigint",object:"date"},lt=u("$ZodCheckLessThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ht=u("$ZodCheckGreaterThan",(e,t)=>{z.init(e,t);const n=at[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yr=u("$ZodCheckMultipleOf",(e,t)=>{z.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):kn(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),wr=u("$ZodCheckNumberFormat",(e,t)=>{z.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Sn[t.format];e._zod.onattach.push(i=>{const c=i._zod.bag;c.format=t.format,c.minimum=o,c.maximum=s,n&&(c.pattern=pr)}),e._zod.check=i=>{const c=i.value;if(n){if(!Number.isInteger(c)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?i.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):i.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort});return}}c<o&&i.issues.push({origin:"number",input:c,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),c>s&&i.issues.push({origin:"number",input:c,code:"too_big",maximum:s,inst:e})}}),kr=u("$ZodCheckMaxLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ye(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=ke(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Er=u("$ZodCheckMinLength",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ye(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=ke(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),zr=u("$ZodCheckLengthEquals",(e,t)=>{var n;z.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!ye(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=ke(o),c=s>t.length;r.issues.push({origin:i,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),oe=u("$ZodCheckStringFormat",(e,t)=>{var n,r;z.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),$r=u("$ZodCheckRegex",(e,t)=>{oe.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Zr=u("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vr),oe.init(e,t)}),Sr=u("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=br),oe.init(e,t)}),Or=u("$ZodCheckIncludes",(e,t)=>{z.init(e,t);const n=W(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Tr=u("$ZodCheckStartsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`^${W(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ir=u("$ZodCheckEndsWith",(e,t)=>{z.init(e,t);const n=new RegExp(`.*${W(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Cr=u("$ZodCheckOverwrite",(e,t)=>{z.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Pr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
20
20
|
`).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
21
|
-
`))}}const Ar={major:4,minor:1,patch:13},g=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,a)=>{let l=G(i),h;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(i))continue}else if(l)continue;const d=i.issues.length,m=p._zod.check(i);if(m instanceof Promise&&a?.async===!1)throw new K;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,i.issues.length!==d&&(l||(l=G(i,d)))});else{if(i.issues.length===d)continue;l||(l=G(i,d))}}return h?h.then(()=>i):i},s=(i,c,a)=>{if(G(i))return i.aborted=!0,i;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new K;return l.then(h=>e._zod.parse(h,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(h=>s(h,i,c)):s(l,i,c)}const a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new K;return a.then(l=>o(l,r,c))}return o(a,r,c)}}e["~standard"]={validate:o=>{try{const s=jn(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Ln(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),$e=u("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),v=u("$ZodStringFormat",(e,t)=>{oe.init(e,t),$e.init(e,t)}),Rr=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=er),v.init(e,t)}),Nr=u("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(r))}else t.pattern??(t.pattern=st());v.init(e,t)}),Dr=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tr),v.init(e,t)}),jr=u("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Lr=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rr()),v.init(e,t)}),Ur=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xn),v.init(e,t)}),xr=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bn),v.init(e,t)}),Mr=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jn),v.init(e,t)}),Fr=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hn),v.init(e,t)}),Kr=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yn),v.init(e,t)}),Vr=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qn),v.init(e,t)}),Wr=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dr(t)),v.init(e,t)}),Gr=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lr),v.init(e,t)}),Br=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hr(t)),v.init(e,t)}),Jr=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qn),v.init(e,t)}),Hr=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=or),v.init(e,t),e._zod.bag.format="ipv4"}),Yr=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sr),v.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),qr=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ir),v.init(e,t)}),Xr=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cr),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eo(e){if(!it.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const to=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=it),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{eo(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),no=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ar),v.init(e,t)});function ro(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const oo=u("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{ro(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=u("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),so=u("$ZodNumberFormat",(e,t)=>{
|
|
21
|
+
`))}}const Ar={major:4,minor:1,patch:13},g=u("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,c,a)=>{let l=G(i),h;for(const p of c){if(p._zod.def.when){if(!p._zod.def.when(i))continue}else if(l)continue;const d=i.issues.length,m=p._zod.check(i);if(m instanceof Promise&&a?.async===!1)throw new K;if(h||m instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await m,i.issues.length!==d&&(l||(l=G(i,d)))});else{if(i.issues.length===d)continue;l||(l=G(i,d))}}return h?h.then(()=>i):i},s=(i,c,a)=>{if(G(i))return i.aborted=!0,i;const l=o(c,r,a);if(l instanceof Promise){if(a.async===!1)throw new K;return l.then(h=>e._zod.parse(h,a))}return e._zod.parse(l,a)};e._zod.run=(i,c)=>{if(c.skipChecks)return e._zod.parse(i,c);if(c.direction==="backward"){const l=e._zod.parse({value:i.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(h=>s(h,i,c)):s(l,i,c)}const a=e._zod.parse(i,c);if(a instanceof Promise){if(c.async===!1)throw new K;return a.then(l=>o(l,r,c))}return o(a,r,c)}}e["~standard"]={validate:o=>{try{const s=jn(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Ln(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),$e=u("$ZodString",(e,t)=>{g.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??fr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),v=u("$ZodStringFormat",(e,t)=>{oe.init(e,t),$e.init(e,t)}),Rr=u("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=er),v.init(e,t)}),Nr=u("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=st(r))}else t.pattern??(t.pattern=st());v.init(e,t)}),Dr=u("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=tr),v.init(e,t)}),jr=u("$ZodURL",(e,t)=>{v.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Lr=u("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=rr()),v.init(e,t)}),Ur=u("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Xn),v.init(e,t)}),xr=u("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bn),v.init(e,t)}),Mr=u("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Jn),v.init(e,t)}),Fr=u("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Hn),v.init(e,t)}),Kr=u("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Yn),v.init(e,t)}),Vr=u("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=qn),v.init(e,t)}),Wr=u("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dr(t)),v.init(e,t)}),Gr=u("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=lr),v.init(e,t)}),Br=u("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=hr(t)),v.init(e,t)}),Jr=u("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Qn),v.init(e,t)}),Hr=u("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=or),v.init(e,t),e._zod.bag.format="ipv4"}),Yr=u("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=sr),v.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),qr=u("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ir),v.init(e,t)}),Xr=u("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=cr),v.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function dt(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=u("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ur),v.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{dt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function eo(e){if(!it.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return dt(n)}const to=u("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=it),v.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{eo(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),no=u("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ar),v.init(e,t)});function ro(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const oo=u("$ZodJWT",(e,t)=>{v.init(e,t),e._zod.check=n=>{ro(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),ft=u("$ZodNumber",(e,t)=>{g.init(e,t),e._zod.pattern=e._zod.bag.pattern??mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),so=u("$ZodNumberFormat",(e,t)=>{wr.init(e,t),ft.init(e,t)}),io=u("$ZodBoolean",(e,t)=>{g.init(e,t),e._zod.pattern=_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),co=u("$ZodNull",(e,t)=>{g.init(e,t),e._zod.pattern=gr,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),uo=u("$ZodUnknown",(e,t)=>{g.init(e,t),e._zod.parse=n=>n}),ao=u("$ZodNever",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function pt(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const lo=u("$ZodArray",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const c=o[i],a=t.element._zod.run({value:c,issues:[]},r);a instanceof Promise?s.push(a.then(l=>pt(l,n,i))):pt(a,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function se(e,t,n,r){e.issues.length&&t.issues.push(...U(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function mt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Zn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function _t(e,t,n,r,o,s){const i=[],c=o.keySet,a=o.catchall._zod,l=a.def.type;for(const h in t){if(c.has(h))continue;if(l==="never"){i.push(h);continue}const p=a.run({value:t[h],issues:[]},r);p instanceof Promise?e.push(p.then(d=>se(d,n,h,t))):se(p,n,h,t)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const ho=u("$ZodObject",(e,t)=>{if(g.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const c=t.shape;Object.defineProperty(t,"shape",{get:()=>{const a={...c};return Object.defineProperty(t,"shape",{value:a}),a}})}const r=be(()=>mt(t));_(e._zod,"propValues",()=>{const c=t.shape,a={};for(const l in c){const h=c[l]._zod;if(h.values){a[l]??(a[l]=new Set);for(const p of h.values)a[l].add(p)}}return a});const o=ee,s=t.catchall;let i;e._zod.parse=(c,a)=>{i??(i=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;c.value={};const h=[],p=i.shape;for(const d of i.keys){const E=p[d]._zod.run({value:l[d],issues:[]},a);E instanceof Promise?h.push(E.then(P=>se(P,c,d,l))):se(E,c,d,l)}return s?_t(h,l,c,a,r.value,e):h.length?Promise.all(h).then(()=>c):c}}),fo=u("$ZodObjectJIT",(e,t)=>{ho.init(e,t);const n=e._zod.parse,r=be(()=>mt(t)),o=d=>{const m=new Pr(["shape","payload","ctx"]),E=r.value,P=O=>{const S=Qe(O);return`shape[${S}]._zod.run({ value: input[${S}], issues: [] }, ctx)`};m.write("const input = payload.value;");const Q=Object.create(null);let De=0;for(const O of E.keys)Q[O]=`key_${De++}`;m.write("const newResult = {};");for(const O of E.keys){const S=Q[O],M=Qe(O);m.write(`const ${S} = ${P(O)};`),m.write(`
|
|
22
22
|
if (${S}.issues.length) {
|
|
23
23
|
payload.issues = payload.issues.concat(${S}.issues.map(iss => ({
|
|
24
24
|
...iss,
|
|
@@ -35,4 +35,4 @@
|
|
|
35
35
|
newResult[${M}] = ${S}.value;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
`)}m.write("payload.value = newResult;"),m.write("return payload;");const je=m.compile();return(O,S)=>je(d,O,S)};let s;const i=ee,c=!qe.jitless,l=c&&zn.value,h=t.catchall;let p;e._zod.parse=(d,m)=>{p??(p=r.value);const E=d.value;return i(E)?c&&l&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),d=s(d,m),h?_t([],E,d,m,p,e):d):n(d,m):(d.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),d)}});function gt(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!G(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>N(i,r,A())))}),t)}const po=u("$ZodUnion",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>ye(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(a=>gt(a,o,e,s)):gt(c,o,e,s)}}),mo=u("$ZodIntersection",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,l])=>vt(n,a,l)):vt(n,s,i)}});function Ze(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(V(e)&&V(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Ze(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=Ze(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),G(e))return e;const r=Ze(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const _o=u("$ZodTuple",(e,t)=>{g.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const i=[],c=[...n].reverse().findIndex(h=>h._zod.optin!=="optional"),a=c===-1?0:n.length-c;if(!t.rest){const h=s.length>n.length,p=s.length<a-1;if(h||p)return r.issues.push({...h?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:s,inst:e,origin:"array"}),r}let l=-1;for(const h of n){if(l++,l>=s.length&&l>=a)continue;const p=h._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(d=>ie(d,r,l))):ie(p,r,l)}if(t.rest){const h=s.slice(n.length);for(const p of h){l++;const d=t.rest._zod.run({value:p,issues:[]},o);d instanceof Promise?i.push(d.then(m=>ie(m,r,l))):ie(d,r,l)}}return i.length?Promise.all(i).then(()=>r):r}});function ie(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const go=u("$ZodRecord",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!V(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const c=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:o[l],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&n.issues.push(...U(l,p.issues)),n.value[l]=p.value})):(h.issues.length&&n.issues.push(...U(l,h.issues)),n.value[l]=h.value)}let a;for(const l in o)c.has(l)||(a=a??[],a.push(l));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;const a=t.keyType._zod.run({value:c,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(h=>N(h,r,A())),input:c,path:[c],inst:e}),n.value[a.value]=a.value;continue}const l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?s.push(l.then(h=>{h.issues.length&&n.issues.push(...U(c,h.issues)),n.value[a.value]=h.value})):(l.issues.length&&n.issues.push(...U(c,l.issues)),n.value[a.value]=l.value)}}return s.length?Promise.all(s).then(()=>n):n}}),vo=u("$ZodEnum",(e,t)=>{g.init(e,t);const n=yn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>$n.has(typeof o)).map(o=>typeof o=="string"?W(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),bo=u("$ZodLiteral",(e,t)=>{if(g.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?W(r):r?W(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),wo=u("$ZodTransform",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new K;return n.value=o,n}});function bt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const yo=u("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ye(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>bt(s,n.value)):bt(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ko=u("$ZodNullable",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ye(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Eo=u("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>wt(s,t)):wt(o,t)}});function wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zo=u("$ZodPrefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$o=u("$ZodNonOptional",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>yt(s,e)):yt(o,e)}});function yt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Zo=u("$ZodCatch",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>N(i,r,A()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>N(s,r,A()))},input:n.value}),n.issues=[]),n)}}),So=u("$ZodPipe",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>ce(i,t.in,r)):ce(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>ce(s,t.out,r)):ce(o,t.out,r)}});function ce(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Oo=u("$ZodReadonly",(e,t)=>{g.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(kt):kt(o)}});function kt(e){return e.value=Object.freeze(e.value),e}const To=u("$ZodCustom",(e,t)=>{z.init(e,t),g.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Et(s,n,r,e));Et(o,n,r,e)}});function Et(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(X(o))}}var zt;class Io{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Co(){return new Io}(zt=globalThis).__zod_globalRegistry??(zt.__zod_globalRegistry=Co());const ue=globalThis.__zod_globalRegistry;function Po(e,t){return new e({type:"string",...f(t)})}function Ao(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...f(t)})}function $t(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...f(t)})}function Ro(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...f(t)})}function No(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...f(t)})}function Do(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...f(t)})}function jo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...f(t)})}function Lo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...f(t)})}function Uo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...f(t)})}function xo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...f(t)})}function Mo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...f(t)})}function Fo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...f(t)})}function Ko(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...f(t)})}function Vo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...f(t)})}function Wo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...f(t)})}function Go(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...f(t)})}function Bo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...f(t)})}function Jo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...f(t)})}function Ho(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...f(t)})}function Yo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...f(t)})}function qo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...f(t)})}function Xo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...f(t)})}function Qo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...f(t)})}function es(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...f(t)})}function ts(e,t){return new e({type:"string",format:"date",check:"string_format",...f(t)})}function ns(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...f(t)})}function rs(e,t){return new e({type:"string",format:"duration",check:"string_format",...f(t)})}function os(e,t){return new e({type:"number",checks:[],...f(t)})}function ss(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...f(t)})}function is(e,t){return new e({type:"boolean",...f(t)})}function cs(e,t){return new e({type:"null",...f(t)})}function us(e){return new e({type:"unknown"})}function as(e,t){return new e({type:"never",...f(t)})}function Zt(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!1})}function Se(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!0})}function St(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!1})}function Oe(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!0})}function Ot(e,t){return new wr({check:"multiple_of",...f(t),value:e})}function Tt(e,t){return new kr({check:"max_length",...f(t),maximum:e})}function ae(e,t){return new Er({check:"min_length",...f(t),minimum:e})}function It(e,t){return new zr({check:"length_equals",...f(t),length:e})}function ls(e,t){return new $r({check:"string_format",format:"regex",...f(t),pattern:e})}function hs(e){return new Zr({check:"string_format",format:"lowercase",...f(e)})}function ds(e){return new Sr({check:"string_format",format:"uppercase",...f(e)})}function fs(e,t){return new Or({check:"string_format",format:"includes",...f(t),includes:e})}function ps(e,t){return new Tr({check:"string_format",format:"starts_with",...f(t),prefix:e})}function ms(e,t){return new Ir({check:"string_format",format:"ends_with",...f(t),suffix:e})}function B(e){return new Cr({check:"overwrite",tx:e})}function _s(e){return B(t=>t.normalize(e))}function gs(){return B(e=>e.trim())}function vs(){return B(e=>e.toLowerCase())}function bs(){return B(e=>e.toUpperCase())}function ws(){return B(e=>En(e))}function ys(e,t,n){return new e({type:"array",element:t,...f(n)})}function ks(e,t,n){return new e({type:"custom",check:"custom",fn:t,...f(n)})}function Es(e){const t=zs(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(X(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(X(o))}},e(n.value,n)));return t}function zs(e,t){const n=new z({check:"custom",...f(t)});return n._zod.check=e,n}const $s=u("ZodISODateTime",(e,t)=>{Wr.init(e,t),k.init(e,t)});function Zs(e){return es($s,e)}const Ss=u("ZodISODate",(e,t)=>{Gr.init(e,t),k.init(e,t)});function Os(e){return ts(Ss,e)}const Ts=u("ZodISOTime",(e,t)=>{Br.init(e,t),k.init(e,t)});function Is(e){return ns(Ts,e)}const Cs=u("ZodISODuration",(e,t)=>{Jr.init(e,t),k.init(e,t)});function Ps(e){return rs(Cs,e)}const $=u("ZodError",(e,t)=>{rt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Dn(e,n)},flatten:{value:n=>Nn(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),As=Ee($),Rs=ze($),Ns=ne($),Ds=re($),js=Un($),Ls=xn($),Us=Mn($),xs=Fn($),Ms=Kn($),Fs=Vn($),Ks=Wn($),Vs=Gn($),b=u("ZodType",(e,t)=>(g.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(L(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>R(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>As(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Ns(e,n,r),e.parseAsync=async(n,r)=>Rs(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ds(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>js(e,n,r),e.decode=(n,r)=>Ls(e,n,r),e.encodeAsync=async(n,r)=>Us(e,n,r),e.decodeAsync=async(n,r)=>xs(e,n,r),e.safeEncode=(n,r)=>Ms(e,n,r),e.safeDecode=(n,r)=>Fs(e,n,r),e.safeEncodeAsync=async(n,r)=>Ks(e,n,r),e.safeDecodeAsync=async(n,r)=>Vs(e,n,r),e.refine=(n,r)=>e.check(Mi(n,r)),e.superRefine=n=>e.check(Fi(n)),e.overwrite=n=>e.check(B(n)),e.optional=()=>Lt(e),e.nullable=()=>Ut(e),e.nullish=()=>Lt(Ut(e)),e.nonoptional=n=>Ri(e,n),e.array=()=>gi(e),e.or=n=>x([e,n]),e.and=n=>yi(e,n),e.transform=n=>Mt(e,Oi(n)),e.default=n=>Ci(e,n),e.prefault=n=>Ai(e,n),e.catch=n=>Di(e,n),e.pipe=n=>Mt(e,n),e.readonly=()=>Ui(e),e.describe=n=>{const r=e.clone();return ue.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ue.get(e);const r=e.clone();return ue.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ct=u("_ZodString",(e,t)=>{$e.init(e,t),b.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(ls(...r)),e.includes=(...r)=>e.check(fs(...r)),e.startsWith=(...r)=>e.check(ps(...r)),e.endsWith=(...r)=>e.check(ms(...r)),e.min=(...r)=>e.check(ae(...r)),e.max=(...r)=>e.check(Tt(...r)),e.length=(...r)=>e.check(It(...r)),e.nonempty=(...r)=>e.check(ae(1,...r)),e.lowercase=r=>e.check(hs(r)),e.uppercase=r=>e.check(ds(r)),e.trim=()=>e.check(gs()),e.normalize=(...r)=>e.check(_s(...r)),e.toLowerCase=()=>e.check(vs()),e.toUpperCase=()=>e.check(bs()),e.slugify=()=>e.check(ws())}),Ws=u("ZodString",(e,t)=>{$e.init(e,t),Ct.init(e,t),e.email=n=>e.check(Ao(Gs,n)),e.url=n=>e.check(Lo(Bs,n)),e.jwt=n=>e.check(Qo(ui,n)),e.emoji=n=>e.check(Uo(Js,n)),e.guid=n=>e.check($t(Pt,n)),e.uuid=n=>e.check(Ro(le,n)),e.uuidv4=n=>e.check(No(le,n)),e.uuidv6=n=>e.check(Do(le,n)),e.uuidv7=n=>e.check(jo(le,n)),e.nanoid=n=>e.check(xo(Hs,n)),e.guid=n=>e.check($t(Pt,n)),e.cuid=n=>e.check(Mo(Ys,n)),e.cuid2=n=>e.check(Fo(qs,n)),e.ulid=n=>e.check(Ko(Xs,n)),e.base64=n=>e.check(Yo(si,n)),e.base64url=n=>e.check(qo(ii,n)),e.xid=n=>e.check(Vo(Qs,n)),e.ksuid=n=>e.check(Wo(ei,n)),e.ipv4=n=>e.check(Go(ti,n)),e.ipv6=n=>e.check(Bo(ni,n)),e.cidrv4=n=>e.check(Jo(ri,n)),e.cidrv6=n=>e.check(Ho(oi,n)),e.e164=n=>e.check(Xo(ci,n)),e.datetime=n=>e.check(Zs(n)),e.date=n=>e.check(Os(n)),e.time=n=>e.check(Is(n)),e.duration=n=>e.check(Ps(n))});function J(e){return Po(Ws,e)}const k=u("ZodStringFormat",(e,t)=>{v.init(e,t),Ct.init(e,t)}),Gs=u("ZodEmail",(e,t)=>{Dr.init(e,t),k.init(e,t)}),Pt=u("ZodGUID",(e,t)=>{Rr.init(e,t),k.init(e,t)}),le=u("ZodUUID",(e,t)=>{Nr.init(e,t),k.init(e,t)}),Bs=u("ZodURL",(e,t)=>{jr.init(e,t),k.init(e,t)}),Js=u("ZodEmoji",(e,t)=>{Lr.init(e,t),k.init(e,t)}),Hs=u("ZodNanoID",(e,t)=>{Ur.init(e,t),k.init(e,t)}),Ys=u("ZodCUID",(e,t)=>{xr.init(e,t),k.init(e,t)}),qs=u("ZodCUID2",(e,t)=>{Mr.init(e,t),k.init(e,t)}),Xs=u("ZodULID",(e,t)=>{Fr.init(e,t),k.init(e,t)}),Qs=u("ZodXID",(e,t)=>{Kr.init(e,t),k.init(e,t)}),ei=u("ZodKSUID",(e,t)=>{Vr.init(e,t),k.init(e,t)}),ti=u("ZodIPv4",(e,t)=>{Hr.init(e,t),k.init(e,t)}),ni=u("ZodIPv6",(e,t)=>{Yr.init(e,t),k.init(e,t)}),ri=u("ZodCIDRv4",(e,t)=>{qr.init(e,t),k.init(e,t)}),oi=u("ZodCIDRv6",(e,t)=>{Xr.init(e,t),k.init(e,t)}),si=u("ZodBase64",(e,t)=>{Qr.init(e,t),k.init(e,t)}),ii=u("ZodBase64URL",(e,t)=>{to.init(e,t),k.init(e,t)}),ci=u("ZodE164",(e,t)=>{no.init(e,t),k.init(e,t)}),ui=u("ZodJWT",(e,t)=>{oo.init(e,t),k.init(e,t)}),At=u("ZodNumber",(e,t)=>{ft.init(e,t),b.init(e,t),e.gt=(r,o)=>e.check(St(r,o)),e.gte=(r,o)=>e.check(Oe(r,o)),e.min=(r,o)=>e.check(Oe(r,o)),e.lt=(r,o)=>e.check(Zt(r,o)),e.lte=(r,o)=>e.check(Se(r,o)),e.max=(r,o)=>e.check(Se(r,o)),e.int=r=>e.check(Rt(r)),e.safe=r=>e.check(Rt(r)),e.positive=r=>e.check(St(0,r)),e.nonnegative=r=>e.check(Oe(0,r)),e.negative=r=>e.check(Zt(0,r)),e.nonpositive=r=>e.check(Se(0,r)),e.multipleOf=(r,o)=>e.check(Ot(r,o)),e.step=(r,o)=>e.check(Ot(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return os(At,e)}const ai=u("ZodNumberFormat",(e,t)=>{so.init(e,t),At.init(e,t)});function Rt(e){return ss(ai,e)}const li=u("ZodBoolean",(e,t)=>{io.init(e,t),b.init(e,t)});function Nt(e){return is(li,e)}const hi=u("ZodNull",(e,t)=>{co.init(e,t),b.init(e,t)});function di(e){return cs(hi,e)}const fi=u("ZodUnknown",(e,t)=>{uo.init(e,t),b.init(e,t)});function Dt(){return us(fi)}const pi=u("ZodNever",(e,t)=>{ao.init(e,t),b.init(e,t)});function mi(e){return as(pi,e)}const _i=u("ZodArray",(e,t)=>{lo.init(e,t),b.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(ae(n,r)),e.nonempty=n=>e.check(ae(1,n)),e.max=(n,r)=>e.check(Tt(n,r)),e.length=(n,r)=>e.check(It(n,r)),e.unwrap=()=>e.element});function gi(e,t){return ys(_i,e,t)}const vi=u("ZodObject",(e,t)=>{fo.init(e,t),b.init(e,t),_(e,"shape",()=>t.shape),e.keyof=()=>$i(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Dt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Dt()}),e.strict=()=>e.clone({...e._zod.def,catchall:mi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>In(e,n),e.safeExtend=n=>Cn(e,n),e.merge=n=>Pn(e,n),e.pick=n=>On(e,n),e.omit=n=>Tn(e,n),e.partial=(...n)=>An(jt,e,n[0]),e.required=(...n)=>Rn(xt,e,n[0])});function w(e,t){const n={type:"object",shape:e??{},...f(t)};return new vi(n)}const bi=u("ZodUnion",(e,t)=>{po.init(e,t),b.init(e,t),e.options=t.options});function x(e,t){return new bi({type:"union",options:e,...f(t)})}const wi=u("ZodIntersection",(e,t)=>{mo.init(e,t),b.init(e,t)});function yi(e,t){return new wi({type:"intersection",left:e,right:t})}const ki=u("ZodTuple",(e,t)=>{_o.init(e,t),b.init(e,t),e.rest=n=>e.clone({...e._zod.def,rest:n})});function T(e,t,n){const r=t instanceof g,o=r?n:t,s=r?t:null;return new ki({type:"tuple",items:e,rest:s,...f(o)})}const Ei=u("ZodRecord",(e,t)=>{go.init(e,t),b.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function zi(e,t,n){return new Ei({type:"record",keyType:e,valueType:t,...f(n)})}const Te=u("ZodEnum",(e,t)=>{vo.init(e,t),b.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})}});function $i(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Te({type:"enum",entries:n,...f(t)})}const Zi=u("ZodLiteral",(e,t)=>{bo.init(e,t),b.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new Zi({type:"literal",values:Array.isArray(e)?e:[e],...f(t)})}const Si=u("ZodTransform",(e,t)=>{wo.init(e,t),b.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(X(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(X(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function Oi(e){return new Si({type:"transform",transform:e})}const jt=u("ZodOptional",(e,t)=>{yo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lt(e){return new jt({type:"optional",innerType:e})}const Ti=u("ZodNullable",(e,t)=>{ko.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ut(e){return new Ti({type:"nullable",innerType:e})}const Ii=u("ZodDefault",(e,t)=>{Eo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ci(e,t){return new Ii({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Pi=u("ZodPrefault",(e,t)=>{zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ai(e,t){return new Pi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const xt=u("ZodNonOptional",(e,t)=>{$o.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ri(e,t){return new xt({type:"nonoptional",innerType:e,...f(t)})}const Ni=u("ZodCatch",(e,t)=>{Zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Di(e,t){return new Ni({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ji=u("ZodPipe",(e,t)=>{So.init(e,t),b.init(e,t),e.in=t.in,e.out=t.out});function Mt(e,t){return new ji({type:"pipe",in:e,out:t})}const Li=u("ZodReadonly",(e,t)=>{Oo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Li({type:"readonly",innerType:e})}const xi=u("ZodCustom",(e,t)=>{To.init(e,t),b.init(e,t)});function Mi(e,t={}){return ks(xi,e,t)}function Fi(e){return Es(e)}const he=w({t:Z().gte(0),rate:Z().gte(0)}),H=w({opacity:Z().gte(0).lte(1),zIndex:Z().default(0)}),Y=w({volume:Z().gte(0).lte(1)}),Ki=w({type:C("image"),file:J(),fit:x([C("contain"),C("cover"),C("none")])}),Vi=w({type:C("audio"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt()}),Wi=w({type:C("video"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt(),fit:x([C("contain"),C("cover"),C("none")])}),Ie=T([Z(),di()]),Gi=T([Z(),w({set:w({...H.shape}).partial()}).partial()]),Bi=T([Z(),w({set:w({...H.shape}).partial(),lerp:w({...H.shape}).partial()}).partial()]),Ji=T([Z(),w({set:w({...he.shape,...Y.shape}).partial()}).partial()]),Hi=T([Z(),w({set:w({...he.shape,...Y.shape}).partial(),lerp:w({...Y.shape}).partial()}).partial()]),Yi=T([Z(),w({set:w({...he.shape,...Y.shape,...H.shape}).partial()}).partial()]),qi=T([Z(),w({set:w({...he.shape,...Y.shape,...H.shape}).partial(),lerp:w({...Y.shape,...H.shape}).partial()}).partial()]),Xi=w({...Ki.shape,keyframes:T([Bi],x([Gi,Ie]))}),Qi=w({...Vi.shape,keyframes:T([Hi],x([Ji,Ie]))}),ec=w({...Wi.shape,keyframes:T([qi],x([Yi,Ie]))}),tc=zi(J(),x([Xi,Qi,ec])),Ft={opacity:1,zIndex:0},Ce={t:0,rate:1,volume:1},Kt={t:0,rate:1,volume:1,opacity:1,zIndex:0},nc=Object.freeze(Object.defineProperty({__proto__:null,MediaSurfaceStateSchema:tc,defaultAudioOptions:Ce,defaultImageOptions:Ft,defaultVideoOptions:Kt},Symbol.toStringTag,{value:"Module"}));function de(e,t){if(!e.keyframes.filter(r=>r[1]===null).some(r=>r[0]<=t))switch(e.type){case"image":{if(e.keyframes[0][0]>t)return;const o=e.keyframes.filter(i=>i[1]!==null),s=Pe(o,t);return{...Ft,...s}}case"audio":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Ce,...s,...o}}case"video":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Kt,...s,...o}}}}function Pe(e,t){const n={};for(const[o,s]of e)o<=t?(Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]}),Object.entries(s.set??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]})):Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].after===void 0&&(n[i].after=[o,c])});const r={};return Object.entries(n).forEach(([o,{before:s,after:i}])=>{if(i===void 0&&s){r[o]=s[1];return}if(s&&i&&s[0]===i[0]){r[o]=i[1];return}if(s&&typeof s[1]=="number"&&i&&typeof i[1]=="number"){r[o]=s[1]+(t-s[0])*(i[1]-s[1])/(i[0]-s[0]);return}}),r}function Vt(e,t){const n=e[0];if(!n||n[0]>t)return;let r=0,{t:o,rate:s}=Ce;for(const[l,h]of e){if(l>t)break;const{set:p}=h;if(!p)continue;const{t:d,rate:m}=p;if(d!==void 0){r=l,o=d,m!==void 0&&(s=m);continue}if(m!==void 0){const P=(l-r)*s;r=l,o+=P,s=m}}const c=(t-r)*s,a=o+c;return{rate:s,t:a}}const rc=typeof navigator<"u"&&typeof navigator.standalone<"u",oc="GestureEvent"in window;function fe(e,t){return(e%t+t)%t}function sc(e,t,n){return e=fe(e,n),t=fe(t,n),Math.abs(e-t)<n/2?e-t:e<t?e+n-t:e-(t+n)}const Ae=e=>{try{const{pathname:t}=new URL(e,window.location.href);return t}catch{return}};class Re{constructor(t,n,r,o,s,i){this.surfaceElement=t,this.clipElement=n,this.constructAssetURL=o,this.getAudioOutput=s,this.mediaPreloader=i,this._state=r}isConnected(t){return!(!this.surfaceElement||!this.clipElement||!this.surfaceElement.contains(this.clipElement)||t&&!this.clipElement.contains(t))}_state;setState(t){this._state=t}timeout;loop=async()=>{clearTimeout(this.timeout),this.isConnected()?(this.update(),this.timeout=setTimeout(this.loop,Yt)):this.destroy()}}function Ne(e,t,n,r,o){let s;const i=r(n.file),c=Ae(i);switch(n.type){case"image":s=e instanceof HTMLImageElement?e:document.createElement("img"),Ae(s.src)!==c&&(s.src=i);break;case"audio":case"video":{if(e!==void 0){const a=Ae(e.src);e.tagName.toLowerCase()===n.type&&a!==void 0&&a===c&&(s=e)}s||(s=o.getElement(n.file,n.type)),s instanceof HTMLVideoElement&&!s.playsInline&&(s.playsInline=!0);break}}return(t.children.length!==1||t.childNodes[0]!==s)&&t.replaceChildren(s),s.style.position="absolute",s.style.width="100%",s.style.height="100%",s}function Wt(e,t,n){const r=String(t.opacity);e.style.opacity!==r&&(e.style.opacity=r);const o=Math.round(t.zIndex??0);parseInt(e.style.zIndex)!==o&&(e.style.zIndex=String(o)),e.style.objectFit!==n&&(e.style.objectFit=n)}function Gt(e,t,n,r){const o=t.volume*r;if(rc)o===0&&!e.muted?e.muted=!0:o>0&&e.muted&&(e.muted=!1);else if(e.muted&&(e.muted=!1),e.volume!==o&&(e.volume=o),e.sinkId!==n)try{e.setSinkId(n).catch(()=>{})}catch{}}const Bt=2e3,ic=1e3,Jt=100,Ht=50,Yt=5,pe=1e3,cc=10,uc=5,ac=.3,lc=.1;function hc(e){return Math.sign(e)*Math.pow(Math.abs(e)/pe,ac)*lc}function I(e,t){e.playbackRate!==t&&(e.playbackRate=t),e.paused&&e.play().catch(()=>{})}function qt(e,t,n,r,o){const s=o&&!oc;let i=!1;if(e.duration){const h=n.filter(([p,d])=>p>t.t&&(d?.set?.t!==void 0||d?.set?.rate!==void 0))[0];if(h?.[1]?.set?.t===0){const p=(e.duration-t.t)/t.rate,d=h[0]-t.t;i=Math.abs(p-d)<=uc,e.loop!==i&&(e.loop=i)}}const c=e.currentTime*1e3,a=i&&e.duration!==void 0?sc(c,t.t,e.duration*1e3):c-t.t,l=Math.abs(a);switch(!0){case(!s&&r.state==="idle"&&t.rate>0&&l>Bt):{const h=(t.t+t.rate*ic)/1e3;return e.duration!==void 0&&h>e.duration&&!i?{state:"idle"}:(I(e,0),e.currentTime=i?fe(h,e.duration*1e3):h,{state:"seeking-ahead"})}case(r.state==="seeking-ahead"&&e.seeking===!0):return{state:"seeking-ahead"};case(r.state==="seeking-ahead"&&e.seeking===!1):return I(e,0),{state:"seeked-ahead"};case(r.state==="seeked-ahead"&&a<-Jt):return I(e,t.rate),console.warn("Failed to seek ahead in time"),{state:"idle"};case(r.state==="seeked-ahead"&&l<=Jt):return I(e,t.rate),{state:"idle"};case(r.state==="seeked-ahead"&&l>Bt*1.5):return console.warn("Failed to seek ahead"),{state:"idle"};case r.state==="seeked-ahead":return{state:"seeked-ahead"};case(s&&r.state==="idle"&&t.rate>0&&l>Ht&&l<=pe):{const h=hc(a),p=Math.max(0,t.rate-h);return I(e,p),{state:"intercepting"}}case(r.state==="intercepting"&&l<=Yt):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&Math.sign(a)===Math.sign(e.playbackRate-t.rate)):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&l<pe*2):return{state:"intercepting"};case r.state==="intercepting":return I(e,t.rate),{state:"idle"};case(s&&r.state==="idle"&&l>pe):{const h=(t.t+t.rate*cc)/1e3;return e.currentTime=i?fe(h,e.duration*1e3):h,I(e,t.rate),{state:"seeking"}}case(r.state==="seeking"&&e.seeking):return{state:"seeking"};case(r.state==="seeking"&&!e.seeking):return{state:"idle"};case r.state==="idle":return I(e,t.rate),t.rate===0&&l>Ht&&(e.currentTime=t.t/1e3),{state:"idle"};default:return{state:"idle"}}}class dc extends Re{imageElement;update(){const t=de(this._state,Date.now());t?this.imageElement=Ne(this.imageElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.imageElement&&this.destroy(),!(!t||!this.imageElement)&&Wt(this.imageElement,t,this._state.fit)}destroy(){this.imageElement&&(this.imageElement.remove(),this.imageElement.src="",this.imageElement=void 0)}}class Xt extends Re{syncState={state:"idle"};audioElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.audioElement=Ne(this.audioElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.audioElement)return;const n=this.getAudioOutput(this._state.audioOutput);Gt(this.audioElement,t,n,this.volume);const r=qt(this.audioElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.audioElement&&(this.audioElement.pause(),this.audioElement.remove(),this.audioElement.volume=0,this.audioElement.currentTime=0,this.mediaPreloader.releaseElement(this.audioElement)),this.audioElement=void 0}}class Qt extends Re{syncState={state:"idle"};videoElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.videoElement=Ne(this.videoElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.videoElement)return;const n=this.getAudioOutput(this._state.audioOutput);Wt(this.videoElement,t,this._state.fit),Gt(this.videoElement,t,n,this.volume);const r=qt(this.videoElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.videoElement&&(this.videoElement.pause(),this.videoElement.remove(),this.videoElement.volume=0,this.videoElement.currentTime=0,this.mediaPreloader.releaseElement(this.videoElement)),this.videoElement=void 0}}class en{_state;_elements={};_constructAssetURL;constructor(t,n={}){this._constructAssetURL=t,this._state=n}get state(){return{...this._state}}setState(t){this._state=t,this.update()}update(){for(const[t,n]of Object.entries(this._elements)){if(!(t in this._state)){if(n.inUse){console.warn(`Failed to clean up element ${n.element.src}`);continue}n.element.src="",n.element.load(),delete this._elements[t]}n.inUse=n.element.isConnected}for(const[t,n]of Object.entries(this._state)){if(t in this._elements)continue;let r;switch(n.preload===!0?r="auto":n.preload===!1?r="none":r=n.preload,n.type){case"audio":{const o=document.createElement("audio");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"audio"};break}case"video":{const o=document.createElement("video");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"video"};break}}}}getElement(t,n){const r=this._elements[t];if(r&&r.inUse===!1)return r.inUse=!0,r.element;{const o=document.createElement(n);return o.src=this._constructAssetURL(t),n==="video"&&(this._elements[t]={element:o,type:n,inUse:!0}),o}}releaseElement(t){if(typeof t=="string"){const n=this._elements[t];n&&(n.inUse=!1)}else Object.values(this._elements).forEach(n=>{n.element===t&&(n.inUse=!1)})}}const fc="data-clip-id";class pc{constructor(t,n,r,o=new en(t)){this.constructAssetUrl=t,this.getAudioOutput=n,this.mediaPreloader=o,this._element=document.createElement("div"),this._element.className="surface-manager",this._element.style.width="100%",this._element.style.height="100%",this._state=r||{},this.update()}_state={};setState(t){this._state=t,this.update()}_volume=1;get volume(){return this._volume}set volume(t){this._volume=t,Object.values(this.resources).forEach(({manager:n})=>{(n instanceof Xt||n instanceof Qt)&&(n.volume=t)})}_element;get element(){return this._element}resources={};update(){Object.entries(this.resources).forEach(([n,{element:r,manager:o}])=>{n in this._state||(delete this.resources[n],r.remove(),o?.destroy())});const t=Object.keys(this._state).toSorted().map(n=>{const r=this.resources[n];if(r)return r.element;{const o=document.createElement("div");return o.setAttribute(fc,n),this.resources[n]={element:o},o}});this._element.replaceChildren(...t),Object.keys(this._state).toSorted().forEach(n=>{const r=this._state[n],o=this.resources[n];if(!o)throw new Error("Failed to create resource");if(o.manager)o.manager.setState(r);else switch(r.type){case"image":o.manager=new dc(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader),o.manager.loop();break;case"audio":{const s=new Xt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}case"video":{const s=new Qt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}}})}}const mc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));y.CogsConfigChangedEvent=We,y.CogsConnection=bn,y.CogsConnectionCloseEvent=Ke,y.CogsConnectionOpenEvent=Fe,y.CogsIncomingEvent=Be,y.CogsMediaConfigChangedEvent=Je,y.CogsMessageEvent=Ve,y.CogsShowPhaseChangedEvent=He,y.CogsStateChangedEvent=Ge,y.DataStoreItemEvent=_e,y.DataStoreItemsEvent=ge,y.ManifestTypes=mc,y.MediaPreloader=en,y.MediaSchema=nc,y.SurfaceManager=pc,y.assetUrl=Me,y.getStateAtTime=de,y.preloadUrl=ln,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"})});
|
|
38
|
+
`)}m.write("payload.value = newResult;"),m.write("return payload;");const je=m.compile();return(O,S)=>je(d,O,S)};let s;const i=ee,c=!qe.jitless,l=c&&zn.value,h=t.catchall;let p;e._zod.parse=(d,m)=>{p??(p=r.value);const E=d.value;return i(E)?c&&l&&m?.async===!1&&m.jitless!==!0?(s||(s=o(t.shape)),d=s(d,m),h?_t([],E,d,m,p,e):d):n(d,m):(d.issues.push({expected:"object",code:"invalid_type",input:E,inst:e}),d)}});function gt(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!G(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>N(i,r,A())))}),t)}const po=u("$ZodUnion",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),_(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),_(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),_(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>we(s.source)).join("|")})$`)}});const n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(o,s)=>{if(n)return r(o,s);let i=!1;const c=[];for(const a of t.options){const l=a._zod.run({value:o.value,issues:[]},s);if(l instanceof Promise)c.push(l),i=!0;else{if(l.issues.length===0)return l;c.push(l)}}return i?Promise.all(c).then(a=>gt(a,o,e,s)):gt(c,o,e,s)}}),mo=u("$ZodIntersection",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([a,l])=>vt(n,a,l)):vt(n,s,i)}});function Ze(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(V(e)&&V(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Ze(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=Ze(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),G(e))return e;const r=Ze(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const _o=u("$ZodTuple",(e,t)=>{g.init(e,t);const n=t.items;e._zod.parse=(r,o)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=[];const i=[],c=[...n].reverse().findIndex(h=>h._zod.optin!=="optional"),a=c===-1?0:n.length-c;if(!t.rest){const h=s.length>n.length,p=s.length<a-1;if(h||p)return r.issues.push({...h?{code:"too_big",maximum:n.length}:{code:"too_small",minimum:n.length},input:s,inst:e,origin:"array"}),r}let l=-1;for(const h of n){if(l++,l>=s.length&&l>=a)continue;const p=h._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(d=>ie(d,r,l))):ie(p,r,l)}if(t.rest){const h=s.slice(n.length);for(const p of h){l++;const d=t.rest._zod.run({value:p,issues:[]},o);d instanceof Promise?i.push(d.then(m=>ie(m,r,l))):ie(d,r,l)}}return i.length?Promise.all(i).then(()=>r):r}});function ie(e,t,n){e.issues.length&&t.issues.push(...U(n,e.issues)),t.value[n]=e.value}const go=u("$ZodRecord",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!V(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const c=new Set;for(const l of i)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){c.add(typeof l=="number"?l.toString():l);const h=t.valueType._zod.run({value:o[l],issues:[]},r);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&n.issues.push(...U(l,p.issues)),n.value[l]=p.value})):(h.issues.length&&n.issues.push(...U(l,h.issues)),n.value[l]=h.value)}let a;for(const l in o)c.has(l)||(a=a??[],a.push(l));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const c of Reflect.ownKeys(o)){if(c==="__proto__")continue;const a=t.keyType._zod.run({value:c,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:a.issues.map(h=>N(h,r,A())),input:c,path:[c],inst:e}),n.value[a.value]=a.value;continue}const l=t.valueType._zod.run({value:o[c],issues:[]},r);l instanceof Promise?s.push(l.then(h=>{h.issues.length&&n.issues.push(...U(c,h.issues)),n.value[a.value]=h.value})):(l.issues.length&&n.issues.push(...U(c,l.issues)),n.value[a.value]=l.value)}}return s.length?Promise.all(s).then(()=>n):n}}),vo=u("$ZodEnum",(e,t)=>{g.init(e,t);const n=wn(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>$n.has(typeof o)).map(o=>typeof o=="string"?W(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),bo=u("$ZodLiteral",(e,t)=>{if(g.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?W(r):r?W(r.toString()):String(r)).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return n.has(s)||r.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),r}}),yo=u("$ZodTransform",(e,t)=>{g.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n));if(o instanceof Promise)throw new K;return n.value=o,n}});function bt(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const wo=u("$ZodOptional",(e,t)=>{g.init(e,t),e._zod.optin="optional",e._zod.optout="optional",_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${we(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>bt(s,n.value)):bt(o,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),ko=u("$ZodNullable",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${we(n.source)}|null)$`):void 0}),_(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Eo=u("$ZodDefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>yt(s,t)):yt(o,t)}});function yt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const zo=u("$ZodPrefault",(e,t)=>{g.init(e,t),e._zod.optin="optional",_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),$o=u("$ZodNonOptional",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>wt(s,e)):wt(o,e)}});function wt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Zo=u("$ZodCatch",(e,t)=>{g.init(e,t),_(e._zod,"optin",()=>t.innerType._zod.optin),_(e._zod,"optout",()=>t.innerType._zod.optout),_(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>N(i,r,A()))},input:n.value}),n.issues=[]),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>N(s,r,A()))},input:n.value}),n.issues=[]),n)}}),So=u("$ZodPipe",(e,t)=>{g.init(e,t),_(e._zod,"values",()=>t.in._zod.values),_(e._zod,"optin",()=>t.in._zod.optin),_(e._zod,"optout",()=>t.out._zod.optout),_(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>ce(i,t.in,r)):ce(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>ce(s,t.out,r)):ce(o,t.out,r)}});function ce(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Oo=u("$ZodReadonly",(e,t)=>{g.init(e,t),_(e._zod,"propValues",()=>t.innerType._zod.propValues),_(e._zod,"values",()=>t.innerType._zod.values),_(e._zod,"optin",()=>t.innerType?._zod?.optin),_(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(kt):kt(o)}});function kt(e){return e.value=Object.freeze(e.value),e}const To=u("$ZodCustom",(e,t)=>{z.init(e,t),g.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>Et(s,n,r,e));Et(o,n,r,e)}});function Et(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(X(o))}}var zt;class Io{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Co(){return new Io}(zt=globalThis).__zod_globalRegistry??(zt.__zod_globalRegistry=Co());const ue=globalThis.__zod_globalRegistry;function Po(e,t){return new e({type:"string",...f(t)})}function Ao(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...f(t)})}function $t(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...f(t)})}function Ro(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...f(t)})}function No(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...f(t)})}function Do(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...f(t)})}function jo(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...f(t)})}function Lo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...f(t)})}function Uo(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...f(t)})}function xo(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...f(t)})}function Mo(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...f(t)})}function Fo(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...f(t)})}function Ko(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...f(t)})}function Vo(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...f(t)})}function Wo(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...f(t)})}function Go(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...f(t)})}function Bo(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...f(t)})}function Jo(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...f(t)})}function Ho(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...f(t)})}function Yo(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...f(t)})}function qo(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...f(t)})}function Xo(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...f(t)})}function Qo(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...f(t)})}function es(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...f(t)})}function ts(e,t){return new e({type:"string",format:"date",check:"string_format",...f(t)})}function ns(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...f(t)})}function rs(e,t){return new e({type:"string",format:"duration",check:"string_format",...f(t)})}function os(e,t){return new e({type:"number",checks:[],...f(t)})}function ss(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...f(t)})}function is(e,t){return new e({type:"boolean",...f(t)})}function cs(e,t){return new e({type:"null",...f(t)})}function us(e){return new e({type:"unknown"})}function as(e,t){return new e({type:"never",...f(t)})}function Zt(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!1})}function Se(e,t){return new lt({check:"less_than",...f(t),value:e,inclusive:!0})}function St(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!1})}function Oe(e,t){return new ht({check:"greater_than",...f(t),value:e,inclusive:!0})}function Ot(e,t){return new yr({check:"multiple_of",...f(t),value:e})}function Tt(e,t){return new kr({check:"max_length",...f(t),maximum:e})}function ae(e,t){return new Er({check:"min_length",...f(t),minimum:e})}function It(e,t){return new zr({check:"length_equals",...f(t),length:e})}function ls(e,t){return new $r({check:"string_format",format:"regex",...f(t),pattern:e})}function hs(e){return new Zr({check:"string_format",format:"lowercase",...f(e)})}function ds(e){return new Sr({check:"string_format",format:"uppercase",...f(e)})}function fs(e,t){return new Or({check:"string_format",format:"includes",...f(t),includes:e})}function ps(e,t){return new Tr({check:"string_format",format:"starts_with",...f(t),prefix:e})}function ms(e,t){return new Ir({check:"string_format",format:"ends_with",...f(t),suffix:e})}function B(e){return new Cr({check:"overwrite",tx:e})}function _s(e){return B(t=>t.normalize(e))}function gs(){return B(e=>e.trim())}function vs(){return B(e=>e.toLowerCase())}function bs(){return B(e=>e.toUpperCase())}function ys(){return B(e=>En(e))}function ws(e,t,n){return new e({type:"array",element:t,...f(n)})}function ks(e,t,n){return new e({type:"custom",check:"custom",fn:t,...f(n)})}function Es(e){const t=zs(n=>(n.addIssue=r=>{if(typeof r=="string")n.issues.push(X(r,n.value,t._zod.def));else{const o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),n.issues.push(X(o))}},e(n.value,n)));return t}function zs(e,t){const n=new z({check:"custom",...f(t)});return n._zod.check=e,n}const $s=u("ZodISODateTime",(e,t)=>{Wr.init(e,t),k.init(e,t)});function Zs(e){return es($s,e)}const Ss=u("ZodISODate",(e,t)=>{Gr.init(e,t),k.init(e,t)});function Os(e){return ts(Ss,e)}const Ts=u("ZodISOTime",(e,t)=>{Br.init(e,t),k.init(e,t)});function Is(e){return ns(Ts,e)}const Cs=u("ZodISODuration",(e,t)=>{Jr.init(e,t),k.init(e,t)});function Ps(e){return rs(Cs,e)}const $=u("ZodError",(e,t)=>{rt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Dn(e,n)},flatten:{value:n=>Nn(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,ve,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,ve,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),As=Ee($),Rs=ze($),Ns=ne($),Ds=re($),js=Un($),Ls=xn($),Us=Mn($),xs=Fn($),Ms=Kn($),Fs=Vn($),Ks=Wn($),Vs=Gn($),b=u("ZodType",(e,t)=>(g.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(L(t,{checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]})),e.clone=(n,r)=>R(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e),e.parse=(n,r)=>As(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>Ns(e,n,r),e.parseAsync=async(n,r)=>Rs(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>Ds(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>js(e,n,r),e.decode=(n,r)=>Ls(e,n,r),e.encodeAsync=async(n,r)=>Us(e,n,r),e.decodeAsync=async(n,r)=>xs(e,n,r),e.safeEncode=(n,r)=>Ms(e,n,r),e.safeDecode=(n,r)=>Fs(e,n,r),e.safeEncodeAsync=async(n,r)=>Ks(e,n,r),e.safeDecodeAsync=async(n,r)=>Vs(e,n,r),e.refine=(n,r)=>e.check(Mi(n,r)),e.superRefine=n=>e.check(Fi(n)),e.overwrite=n=>e.check(B(n)),e.optional=()=>Lt(e),e.nullable=()=>Ut(e),e.nullish=()=>Lt(Ut(e)),e.nonoptional=n=>Ri(e,n),e.array=()=>gi(e),e.or=n=>x([e,n]),e.and=n=>wi(e,n),e.transform=n=>Mt(e,Oi(n)),e.default=n=>Ci(e,n),e.prefault=n=>Ai(e,n),e.catch=n=>Di(e,n),e.pipe=n=>Mt(e,n),e.readonly=()=>Ui(e),e.describe=n=>{const r=e.clone();return ue.add(r,{description:n}),r},Object.defineProperty(e,"description",{get(){return ue.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return ue.get(e);const r=e.clone();return ue.add(r,n[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ct=u("_ZodString",(e,t)=>{$e.init(e,t),b.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...r)=>e.check(ls(...r)),e.includes=(...r)=>e.check(fs(...r)),e.startsWith=(...r)=>e.check(ps(...r)),e.endsWith=(...r)=>e.check(ms(...r)),e.min=(...r)=>e.check(ae(...r)),e.max=(...r)=>e.check(Tt(...r)),e.length=(...r)=>e.check(It(...r)),e.nonempty=(...r)=>e.check(ae(1,...r)),e.lowercase=r=>e.check(hs(r)),e.uppercase=r=>e.check(ds(r)),e.trim=()=>e.check(gs()),e.normalize=(...r)=>e.check(_s(...r)),e.toLowerCase=()=>e.check(vs()),e.toUpperCase=()=>e.check(bs()),e.slugify=()=>e.check(ys())}),Ws=u("ZodString",(e,t)=>{$e.init(e,t),Ct.init(e,t),e.email=n=>e.check(Ao(Gs,n)),e.url=n=>e.check(Lo(Bs,n)),e.jwt=n=>e.check(Qo(ui,n)),e.emoji=n=>e.check(Uo(Js,n)),e.guid=n=>e.check($t(Pt,n)),e.uuid=n=>e.check(Ro(le,n)),e.uuidv4=n=>e.check(No(le,n)),e.uuidv6=n=>e.check(Do(le,n)),e.uuidv7=n=>e.check(jo(le,n)),e.nanoid=n=>e.check(xo(Hs,n)),e.guid=n=>e.check($t(Pt,n)),e.cuid=n=>e.check(Mo(Ys,n)),e.cuid2=n=>e.check(Fo(qs,n)),e.ulid=n=>e.check(Ko(Xs,n)),e.base64=n=>e.check(Yo(si,n)),e.base64url=n=>e.check(qo(ii,n)),e.xid=n=>e.check(Vo(Qs,n)),e.ksuid=n=>e.check(Wo(ei,n)),e.ipv4=n=>e.check(Go(ti,n)),e.ipv6=n=>e.check(Bo(ni,n)),e.cidrv4=n=>e.check(Jo(ri,n)),e.cidrv6=n=>e.check(Ho(oi,n)),e.e164=n=>e.check(Xo(ci,n)),e.datetime=n=>e.check(Zs(n)),e.date=n=>e.check(Os(n)),e.time=n=>e.check(Is(n)),e.duration=n=>e.check(Ps(n))});function J(e){return Po(Ws,e)}const k=u("ZodStringFormat",(e,t)=>{v.init(e,t),Ct.init(e,t)}),Gs=u("ZodEmail",(e,t)=>{Dr.init(e,t),k.init(e,t)}),Pt=u("ZodGUID",(e,t)=>{Rr.init(e,t),k.init(e,t)}),le=u("ZodUUID",(e,t)=>{Nr.init(e,t),k.init(e,t)}),Bs=u("ZodURL",(e,t)=>{jr.init(e,t),k.init(e,t)}),Js=u("ZodEmoji",(e,t)=>{Lr.init(e,t),k.init(e,t)}),Hs=u("ZodNanoID",(e,t)=>{Ur.init(e,t),k.init(e,t)}),Ys=u("ZodCUID",(e,t)=>{xr.init(e,t),k.init(e,t)}),qs=u("ZodCUID2",(e,t)=>{Mr.init(e,t),k.init(e,t)}),Xs=u("ZodULID",(e,t)=>{Fr.init(e,t),k.init(e,t)}),Qs=u("ZodXID",(e,t)=>{Kr.init(e,t),k.init(e,t)}),ei=u("ZodKSUID",(e,t)=>{Vr.init(e,t),k.init(e,t)}),ti=u("ZodIPv4",(e,t)=>{Hr.init(e,t),k.init(e,t)}),ni=u("ZodIPv6",(e,t)=>{Yr.init(e,t),k.init(e,t)}),ri=u("ZodCIDRv4",(e,t)=>{qr.init(e,t),k.init(e,t)}),oi=u("ZodCIDRv6",(e,t)=>{Xr.init(e,t),k.init(e,t)}),si=u("ZodBase64",(e,t)=>{Qr.init(e,t),k.init(e,t)}),ii=u("ZodBase64URL",(e,t)=>{to.init(e,t),k.init(e,t)}),ci=u("ZodE164",(e,t)=>{no.init(e,t),k.init(e,t)}),ui=u("ZodJWT",(e,t)=>{oo.init(e,t),k.init(e,t)}),At=u("ZodNumber",(e,t)=>{ft.init(e,t),b.init(e,t),e.gt=(r,o)=>e.check(St(r,o)),e.gte=(r,o)=>e.check(Oe(r,o)),e.min=(r,o)=>e.check(Oe(r,o)),e.lt=(r,o)=>e.check(Zt(r,o)),e.lte=(r,o)=>e.check(Se(r,o)),e.max=(r,o)=>e.check(Se(r,o)),e.int=r=>e.check(Rt(r)),e.safe=r=>e.check(Rt(r)),e.positive=r=>e.check(St(0,r)),e.nonnegative=r=>e.check(Oe(0,r)),e.negative=r=>e.check(Zt(0,r)),e.nonpositive=r=>e.check(Se(0,r)),e.multipleOf=(r,o)=>e.check(Ot(r,o)),e.step=(r,o)=>e.check(Ot(r,o)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Z(e){return os(At,e)}const ai=u("ZodNumberFormat",(e,t)=>{so.init(e,t),At.init(e,t)});function Rt(e){return ss(ai,e)}const li=u("ZodBoolean",(e,t)=>{io.init(e,t),b.init(e,t)});function Nt(e){return is(li,e)}const hi=u("ZodNull",(e,t)=>{co.init(e,t),b.init(e,t)});function di(e){return cs(hi,e)}const fi=u("ZodUnknown",(e,t)=>{uo.init(e,t),b.init(e,t)});function Dt(){return us(fi)}const pi=u("ZodNever",(e,t)=>{ao.init(e,t),b.init(e,t)});function mi(e){return as(pi,e)}const _i=u("ZodArray",(e,t)=>{lo.init(e,t),b.init(e,t),e.element=t.element,e.min=(n,r)=>e.check(ae(n,r)),e.nonempty=n=>e.check(ae(1,n)),e.max=(n,r)=>e.check(Tt(n,r)),e.length=(n,r)=>e.check(It(n,r)),e.unwrap=()=>e.element});function gi(e,t){return ws(_i,e,t)}const vi=u("ZodObject",(e,t)=>{fo.init(e,t),b.init(e,t),_(e,"shape",()=>t.shape),e.keyof=()=>$i(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Dt()}),e.loose=()=>e.clone({...e._zod.def,catchall:Dt()}),e.strict=()=>e.clone({...e._zod.def,catchall:mi()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>In(e,n),e.safeExtend=n=>Cn(e,n),e.merge=n=>Pn(e,n),e.pick=n=>On(e,n),e.omit=n=>Tn(e,n),e.partial=(...n)=>An(jt,e,n[0]),e.required=(...n)=>Rn(xt,e,n[0])});function y(e,t){const n={type:"object",shape:e??{},...f(t)};return new vi(n)}const bi=u("ZodUnion",(e,t)=>{po.init(e,t),b.init(e,t),e.options=t.options});function x(e,t){return new bi({type:"union",options:e,...f(t)})}const yi=u("ZodIntersection",(e,t)=>{mo.init(e,t),b.init(e,t)});function wi(e,t){return new yi({type:"intersection",left:e,right:t})}const ki=u("ZodTuple",(e,t)=>{_o.init(e,t),b.init(e,t),e.rest=n=>e.clone({...e._zod.def,rest:n})});function T(e,t,n){const r=t instanceof g,o=r?n:t,s=r?t:null;return new ki({type:"tuple",items:e,rest:s,...f(o)})}const Ei=u("ZodRecord",(e,t)=>{go.init(e,t),b.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function zi(e,t,n){return new Ei({type:"record",keyType:e,valueType:t,...f(n)})}const Te=u("ZodEnum",(e,t)=>{vo.init(e,t),b.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Te({...t,checks:[],...f(o),entries:s})}});function $i(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Te({type:"enum",entries:n,...f(t)})}const Zi=u("ZodLiteral",(e,t)=>{bo.init(e,t),b.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new Zi({type:"literal",values:Array.isArray(e)?e:[e],...f(t)})}const Si=u("ZodTransform",(e,t)=>{yo.init(e,t),b.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Ye(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(X(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(X(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n)):(n.value=o,n)}});function Oi(e){return new Si({type:"transform",transform:e})}const jt=u("ZodOptional",(e,t)=>{wo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Lt(e){return new jt({type:"optional",innerType:e})}const Ti=u("ZodNullable",(e,t)=>{ko.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ut(e){return new Ti({type:"nullable",innerType:e})}const Ii=u("ZodDefault",(e,t)=>{Eo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ci(e,t){return new Ii({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const Pi=u("ZodPrefault",(e,t)=>{zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ai(e,t){return new Pi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():tt(t)}})}const xt=u("ZodNonOptional",(e,t)=>{$o.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ri(e,t){return new xt({type:"nonoptional",innerType:e,...f(t)})}const Ni=u("ZodCatch",(e,t)=>{Zo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Di(e,t){return new Ni({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ji=u("ZodPipe",(e,t)=>{So.init(e,t),b.init(e,t),e.in=t.in,e.out=t.out});function Mt(e,t){return new ji({type:"pipe",in:e,out:t})}const Li=u("ZodReadonly",(e,t)=>{Oo.init(e,t),b.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ui(e){return new Li({type:"readonly",innerType:e})}const xi=u("ZodCustom",(e,t)=>{To.init(e,t),b.init(e,t)});function Mi(e,t={}){return ks(xi,e,t)}function Fi(e){return Es(e)}const he=y({t:Z().gte(0),rate:Z().gte(0)}),H=y({opacity:Z().gte(0).lte(1),zIndex:Z().default(0)}),Y=y({volume:Z().gte(0).lte(1)}),Ki=y({type:C("image"),file:J(),fit:x([C("contain"),C("cover"),C("none")])}),Vi=y({type:C("audio"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt()}),Wi=y({type:C("video"),file:J(),audioOutput:J(),enablePlaybackRateAdjustment:Nt(),fit:x([C("contain"),C("cover"),C("none")])}),Ie=T([Z(),di()]),Gi=T([Z(),y({set:y({...H.shape}).partial()}).partial()]),Bi=T([Z(),y({set:y({...H.shape}).partial(),lerp:y({...H.shape}).partial()}).partial()]),Ji=T([Z(),y({set:y({...he.shape,...Y.shape}).partial()}).partial()]),Hi=T([Z(),y({set:y({...he.shape,...Y.shape}).partial(),lerp:y({...Y.shape}).partial()}).partial()]),Yi=T([Z(),y({set:y({...he.shape,...Y.shape,...H.shape}).partial()}).partial()]),qi=T([Z(),y({set:y({...he.shape,...Y.shape,...H.shape}).partial(),lerp:y({...Y.shape,...H.shape}).partial()}).partial()]),Xi=y({...Ki.shape,keyframes:T([Bi],x([Gi,Ie]))}),Qi=y({...Vi.shape,keyframes:T([Hi],x([Ji,Ie]))}),ec=y({...Wi.shape,keyframes:T([qi],x([Yi,Ie]))}),tc=zi(J(),x([Xi,Qi,ec])),Ft={opacity:1,zIndex:0},Ce={t:0,rate:1,volume:1},Kt={t:0,rate:1,volume:1,opacity:1,zIndex:0},nc=Object.freeze(Object.defineProperty({__proto__:null,MediaSurfaceStateSchema:tc,defaultAudioOptions:Ce,defaultImageOptions:Ft,defaultVideoOptions:Kt},Symbol.toStringTag,{value:"Module"}));function de(e,t){if(!e.keyframes.filter(r=>r[1]===null).some(r=>r[0]<=t))switch(e.type){case"image":{if(e.keyframes[0][0]>t)return;const o=e.keyframes.filter(i=>i[1]!==null),s=Pe(o,t);return{...Ft,...s}}case"audio":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Ce,...s,...o}}case"video":{const r=e.keyframes.filter(i=>i[1]!==null),o=Vt(r,t);if(!o)return;const s=Pe(r,t);return{...Kt,...s,...o}}}}function Pe(e,t){const n={};for(const[o,s]of e)o<=t?(Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]}),Object.entries(s.set??{}).forEach(([i,c])=>{n[i]??={},n[i].before=[o,c]})):Object.entries(s.lerp??{}).forEach(([i,c])=>{n[i]??={},n[i].after===void 0&&(n[i].after=[o,c])});const r={};return Object.entries(n).forEach(([o,{before:s,after:i}])=>{if(i===void 0&&s){r[o]=s[1];return}if(s&&i&&s[0]===i[0]){r[o]=i[1];return}if(s&&typeof s[1]=="number"&&i&&typeof i[1]=="number"){r[o]=s[1]+(t-s[0])*(i[1]-s[1])/(i[0]-s[0]);return}}),r}function Vt(e,t){const n=e[0];if(!n||n[0]>t)return;let r=0,{t:o,rate:s}=Ce;for(const[l,h]of e){if(l>t)break;const{set:p}=h;if(!p)continue;const{t:d,rate:m}=p;if(d!==void 0){r=l,o=d,m!==void 0&&(s=m);continue}if(m!==void 0){const P=(l-r)*s;r=l,o+=P,s=m}}const c=(t-r)*s,a=o+c;return{rate:s,t:a}}const rc=typeof navigator<"u"&&typeof navigator.standalone<"u",oc="GestureEvent"in window;function fe(e,t){return(e%t+t)%t}function sc(e,t,n){return e=fe(e,n),t=fe(t,n),Math.abs(e-t)<n/2?e-t:e<t?e+n-t:e-(t+n)}const Ae=e=>{try{const{pathname:t}=new URL(e,window.location.href);return t}catch{return}};class Re{constructor(t,n,r,o,s,i){this.surfaceElement=t,this.clipElement=n,this.constructAssetURL=o,this.getAudioOutput=s,this.mediaPreloader=i,this._state=r}isConnected(t){return!(!this.surfaceElement||!this.clipElement||!this.surfaceElement.contains(this.clipElement)||t&&!this.clipElement.contains(t))}_state;setState(t){this._state=t}timeout;loop=async()=>{clearTimeout(this.timeout),this.isConnected()?(this.update(),this.timeout=setTimeout(this.loop,Yt)):this.destroy()}}function Ne(e,t,n,r,o){let s;const i=r(n.file),c=Ae(i);switch(n.type){case"image":s=e instanceof HTMLImageElement?e:document.createElement("img"),Ae(s.src)!==c&&(s.src=i);break;case"audio":case"video":{if(e!==void 0){const a=Ae(e.src);e.tagName.toLowerCase()===n.type&&a!==void 0&&a===c&&(s=e)}s||(s=o.getElement(n.file,n.type)),s instanceof HTMLVideoElement&&!s.playsInline&&(s.playsInline=!0);break}}return(t.children.length!==1||t.childNodes[0]!==s)&&t.replaceChildren(s),s.style.position="absolute",s.style.width="100%",s.style.height="100%",s}function Wt(e,t,n){const r=String(t.opacity);e.style.opacity!==r&&(e.style.opacity=r);const o=Math.round(t.zIndex??0);parseInt(e.style.zIndex)!==o&&(e.style.zIndex=String(o)),e.style.objectFit!==n&&(e.style.objectFit=n)}function Gt(e,t,n,r){const o=t.volume*r;if(rc)o===0&&!e.muted?e.muted=!0:o>0&&e.muted&&(e.muted=!1);else if(e.muted&&(e.muted=!1),e.volume!==o&&(e.volume=o),e.sinkId!==n)try{e.setSinkId(n).catch(()=>{})}catch{}}const Bt=2e3,ic=1e3,Jt=100,Ht=50,Yt=5,pe=1e3,cc=10,uc=5,ac=.3,lc=.1;function hc(e){return Math.sign(e)*Math.pow(Math.abs(e)/pe,ac)*lc}function I(e,t){e.playbackRate!==t&&(e.playbackRate=t),e.paused&&e.play().catch(()=>{})}function qt(e,t,n,r,o){const s=o&&!oc;let i=!1;if(e.duration){const h=n.filter(([p,d])=>p>t.t&&(d?.set?.t!==void 0||d?.set?.rate!==void 0))[0];if(h?.[1]?.set?.t===0){const p=(e.duration-t.t)/t.rate,d=h[0]-t.t;i=Math.abs(p-d)<=uc,e.loop!==i&&(e.loop=i)}}const c=e.currentTime*1e3,a=i&&e.duration!==void 0?sc(c,t.t,e.duration*1e3):c-t.t,l=Math.abs(a);switch(!0){case(!s&&r.state==="idle"&&t.rate>0&&l>Bt):{const h=(t.t+t.rate*ic)/1e3;return e.duration!==void 0&&h>e.duration&&!i?{state:"idle"}:(I(e,0),e.currentTime=i?fe(h,e.duration*1e3):h,{state:"seeking-ahead"})}case(r.state==="seeking-ahead"&&e.seeking===!0):return{state:"seeking-ahead"};case(r.state==="seeking-ahead"&&e.seeking===!1):return I(e,0),{state:"seeked-ahead"};case(r.state==="seeked-ahead"&&a<-Jt):return I(e,t.rate),console.warn("Failed to seek ahead in time"),{state:"idle"};case(r.state==="seeked-ahead"&&l<=Jt):return I(e,t.rate),{state:"idle"};case(r.state==="seeked-ahead"&&l>Bt*1.5):return console.warn("Failed to seek ahead"),{state:"idle"};case r.state==="seeked-ahead":return{state:"seeked-ahead"};case(s&&r.state==="idle"&&t.rate>0&&l>Ht&&l<=pe):{const h=hc(a),p=Math.max(0,t.rate-h);return I(e,p),{state:"intercepting"}}case(r.state==="intercepting"&&l<=Yt):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&Math.sign(a)===Math.sign(e.playbackRate-t.rate)):return I(e,t.rate),{state:"idle"};case(r.state==="intercepting"&&l<pe*2):return{state:"intercepting"};case r.state==="intercepting":return I(e,t.rate),{state:"idle"};case(s&&r.state==="idle"&&l>pe):{const h=(t.t+t.rate*cc)/1e3;return e.currentTime=i?fe(h,e.duration*1e3):h,I(e,t.rate),{state:"seeking"}}case(r.state==="seeking"&&e.seeking):return{state:"seeking"};case(r.state==="seeking"&&!e.seeking):return{state:"idle"};case r.state==="idle":return I(e,t.rate),t.rate===0&&l>Ht&&(e.currentTime=t.t/1e3),{state:"idle"};default:return{state:"idle"}}}class dc extends Re{imageElement;update(){const t=de(this._state,Date.now());t?this.imageElement=Ne(this.imageElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.imageElement&&this.destroy(),!(!t||!this.imageElement)&&Wt(this.imageElement,t,this._state.fit)}destroy(){this.imageElement&&(this.imageElement.remove(),this.imageElement.src="",this.imageElement=void 0)}}class Xt extends Re{syncState={state:"idle"};audioElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.audioElement=Ne(this.audioElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.audioElement)return;const n=this.getAudioOutput(this._state.audioOutput);Gt(this.audioElement,t,n,this.volume);const r=qt(this.audioElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.audioElement&&(this.audioElement.pause(),this.audioElement.remove(),this.audioElement.volume=0,this.audioElement.currentTime=0,this.mediaPreloader.releaseElement(this.audioElement)),this.audioElement=void 0}}class Qt extends Re{syncState={state:"idle"};videoElement;volume=1;update(){const t=de(this._state,Date.now());if(t?this.videoElement=Ne(this.videoElement,this.clipElement,this._state,this.constructAssetURL,this.mediaPreloader):this.destroy(),!t||!this.videoElement)return;const n=this.getAudioOutput(this._state.audioOutput);Wt(this.videoElement,t,this._state.fit),Gt(this.videoElement,t,n,this.volume);const r=qt(this.videoElement,t,this._state.keyframes,this.syncState,this._state.enablePlaybackRateAdjustment);this.syncState=r}destroy(){this.videoElement&&(this.videoElement.pause(),this.videoElement.remove(),this.videoElement.volume=0,this.videoElement.currentTime=0,this.mediaPreloader.releaseElement(this.videoElement)),this.videoElement=void 0}}class en{_state;_elements={};_constructAssetURL;constructor(t,n={}){this._constructAssetURL=t,this._state=n}get state(){return{...this._state}}setState(t){this._state=t,this.update()}update(){for(const[t,n]of Object.entries(this._elements)){if(!(t in this._state)){if(n.inUse){console.warn(`Failed to clean up element ${n.element.src}`);continue}n.element.src="",n.element.load(),delete this._elements[t]}n.inUse=n.element.isConnected}for(const[t,n]of Object.entries(this._state)){if(t in this._elements)continue;let r;switch(n.preload===!0?r="auto":n.preload===!1?r="none":r=n.preload,n.type){case"audio":{const o=document.createElement("audio");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"audio"};break}case"video":{const o=document.createElement("video");o.src=this._constructAssetURL(t),o.preload=r,this._elements[t]={element:o,inUse:!1,type:"video"};break}}}}getElement(t,n){const r=this._elements[t];if(r&&r.inUse===!1)return r.inUse=!0,r.element;{const o=document.createElement(n);return o.src=this._constructAssetURL(t),n==="video"&&(this._elements[t]={element:o,type:n,inUse:!0}),o}}releaseElement(t){if(typeof t=="string"){const n=this._elements[t];n&&(n.inUse=!1)}else Object.values(this._elements).forEach(n=>{n.element===t&&(n.inUse=!1)})}}const fc="data-clip-id";class pc{constructor(t,n,r,o=new en(t)){this.constructAssetUrl=t,this.getAudioOutput=n,this.mediaPreloader=o,this._element=document.createElement("div"),this._element.className="surface-manager",this._element.style.width="100%",this._element.style.height="100%",this._state=r||{},this.update()}_state={};setState(t){this._state=t,this.update()}_volume=1;get volume(){return this._volume}set volume(t){this._volume=t,Object.values(this.resources).forEach(({manager:n})=>{(n instanceof Xt||n instanceof Qt)&&(n.volume=t)})}_element;get element(){return this._element}resources={};update(){Object.entries(this.resources).forEach(([n,{element:r,manager:o}])=>{n in this._state||(delete this.resources[n],r.remove(),o?.destroy())});const t=Object.keys(this._state).toSorted().map(n=>{const r=this.resources[n];if(r)return r.element;{const o=document.createElement("div");return o.setAttribute(fc,n),this.resources[n]={element:o},o}});this._element.replaceChildren(...t),Object.keys(this._state).toSorted().forEach(n=>{const r=this._state[n],o=this.resources[n];if(!o)throw new Error("Failed to create resource");if(o.manager)o.manager.setState(r);else switch(r.type){case"image":o.manager=new dc(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader),o.manager.loop();break;case"audio":{const s=new Xt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}case"video":{const s=new Qt(this._element,o.element,r,this.constructAssetUrl,this.getAudioOutput,this.mediaPreloader);o.manager=s,s.volume=this._volume,s.loop();break}}})}}const mc=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));w.CogsConfigChangedEvent=We,w.CogsConnection=bn,w.CogsConnectionCloseEvent=Ke,w.CogsConnectionOpenEvent=Fe,w.CogsIncomingEvent=Be,w.CogsMediaConfigChangedEvent=Je,w.CogsMessageEvent=Ve,w.CogsShowPhaseChangedEvent=He,w.CogsStateChangedEvent=Ge,w.DataStoreItemEvent=_e,w.DataStoreItemsEvent=ge,w.ManifestTypes=mc,w.MediaPreloader=en,w.MediaSchema=nc,w.SurfaceManager=pc,w.assetUrl=Me,w.getStateAtTime=de,w.preloadUrl=ln,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -17,10 +17,6 @@ interface TextHintsUpdateMessage {
|
|
|
17
17
|
type: 'text_hints_update';
|
|
18
18
|
lastSentHint: string;
|
|
19
19
|
}
|
|
20
|
-
interface CogsEnvironmentMessage {
|
|
21
|
-
type: 'cogs_environment';
|
|
22
|
-
cogsVersion: string;
|
|
23
|
-
}
|
|
24
20
|
export interface DataStoreItemsClientMessage {
|
|
25
21
|
type: 'data_store_items';
|
|
26
22
|
items: {
|
|
@@ -114,5 +110,5 @@ type MediaStateClientMessage = {
|
|
|
114
110
|
state: MediaSurfaceState;
|
|
115
111
|
};
|
|
116
112
|
type MediaClientMessage = MediaEventClientMessage | MediaStateClientMessage;
|
|
117
|
-
export type CogsClientMessage<CustomConfig = {}> = ShowResetMessage | ShowPhaseMessage | AdjustableTimerUpdateMessage | TextHintsUpdateMessage | (MediaClientConfigMessage & CustomConfig) |
|
|
113
|
+
export type CogsClientMessage<CustomConfig = {}> = ShowResetMessage | ShowPhaseMessage | AdjustableTimerUpdateMessage | TextHintsUpdateMessage | (MediaClientConfigMessage & CustomConfig) | MediaClientMessage | DataStoreItemsClientMessage;
|
|
118
114
|
export default CogsClientMessage;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Connect to COGS to build a custom Media Master",
|
|
4
4
|
"author": "Clockwork Dog <info@clockwork.dog>",
|
|
5
5
|
"homepage": "https://github.com/clockwork-dog/cogs-sdk/tree/main/packages/javascript",
|
|
6
|
-
"version": "3.0.
|
|
6
|
+
"version": "3.0.3",
|
|
7
7
|
"keywords": [],
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"cy:generate": "cypress run --e2e"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@clockworkdog/timesync": "^3.0.
|
|
40
|
+
"@clockworkdog/timesync": "^3.0.3",
|
|
41
41
|
"reconnecting-websocket": "^4.4.0",
|
|
42
42
|
"zod": "^4.1.13"
|
|
43
43
|
},
|