@clockworkdog/cogs-client 3.0.0-alpha.6 → 3.0.0-alpha.8
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/browser/index.mjs +818 -758
- package/dist/browser/index.umd.js +5 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/state-based/AudioManager.d.ts +3 -1
- package/dist/state-based/AudioManager.js +10 -8
- package/dist/state-based/ClipManager.d.ts +2 -1
- package/dist/state-based/ClipManager.js +6 -1
- package/dist/state-based/ImageManager.d.ts +1 -1
- package/dist/state-based/ImageManager.js +6 -5
- package/dist/state-based/MediaPreloader.d.ts +14 -0
- package/dist/state-based/MediaPreloader.js +86 -0
- package/dist/state-based/SurfaceManager.d.ts +4 -1
- package/dist/state-based/SurfaceManager.js +11 -5
- package/dist/state-based/VideoManager.d.ts +3 -1
- package/dist/state-based/VideoManager.js +10 -7
- package/package.json +2 -2
package/dist/browser/index.mjs
CHANGED
|
@@ -98,7 +98,7 @@ var un = function() {
|
|
|
98
98
|
return WebSocket;
|
|
99
99
|
}, cn = function(e) {
|
|
100
100
|
return typeof e < "u" && !!e && e.CLOSING === 2;
|
|
101
|
-
},
|
|
101
|
+
}, F = {
|
|
102
102
|
maxReconnectionDelay: 1e4,
|
|
103
103
|
minReconnectionDelay: 1e3 + Math.random() * 4e3,
|
|
104
104
|
minUptime: 5e3,
|
|
@@ -118,13 +118,13 @@ var un = function() {
|
|
|
118
118
|
close: []
|
|
119
119
|
}, 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(a) {
|
|
120
120
|
r._debug("open event");
|
|
121
|
-
var c = r._options.minUptime, l = c === void 0 ?
|
|
121
|
+
var c = r._options.minUptime, l = c === void 0 ? F.minUptime : c;
|
|
122
122
|
clearTimeout(r._connectTimeout), r._uptimeTimeout = setTimeout(function() {
|
|
123
123
|
return r._acceptOpen();
|
|
124
|
-
}, l), r._ws.binaryType = r._binaryType, r._messageQueue.forEach(function(
|
|
125
|
-
return r._ws.send(
|
|
126
|
-
}), r._messageQueue = [], r.onopen && r.onopen(a), r._listeners.open.forEach(function(
|
|
127
|
-
return r._callEventListener(a,
|
|
124
|
+
}, l), r._ws.binaryType = r._binaryType, r._messageQueue.forEach(function(d) {
|
|
125
|
+
return r._ws.send(d);
|
|
126
|
+
}), r._messageQueue = [], r.onopen && r.onopen(a), r._listeners.open.forEach(function(d) {
|
|
127
|
+
return r._callEventListener(a, d);
|
|
128
128
|
});
|
|
129
129
|
}, this._handleMessage = function(a) {
|
|
130
130
|
r._debug("message event"), r.onmessage && r.onmessage(a), r._listeners.message.forEach(function(c) {
|
|
@@ -276,7 +276,7 @@ var un = function() {
|
|
|
276
276
|
if (this._ws && this._ws.readyState === this.OPEN)
|
|
277
277
|
this._debug("send", t), this._ws.send(t);
|
|
278
278
|
else {
|
|
279
|
-
var n = this._options.maxEnqueuedMessages, o = n === void 0 ?
|
|
279
|
+
var n = this._options.maxEnqueuedMessages, o = n === void 0 ? F.maxEnqueuedMessages : n;
|
|
280
280
|
this._messageQueue.length < o && (this._debug("enqueue", t), this._messageQueue.push(t));
|
|
281
281
|
}
|
|
282
282
|
}, e.prototype.addEventListener = function(t, n) {
|
|
@@ -289,8 +289,8 @@ var un = function() {
|
|
|
289
289
|
var l = c.value;
|
|
290
290
|
this._callEventListener(t, l);
|
|
291
291
|
}
|
|
292
|
-
} catch (
|
|
293
|
-
n = { error:
|
|
292
|
+
} catch (d) {
|
|
293
|
+
n = { error: d };
|
|
294
294
|
} finally {
|
|
295
295
|
try {
|
|
296
296
|
c && !c.done && (o = a.return) && o.call(a);
|
|
@@ -308,8 +308,8 @@ var un = function() {
|
|
|
308
308
|
t[n] = arguments[n];
|
|
309
309
|
this._options.debug && console.log.apply(console, rn(["RWS>"], t));
|
|
310
310
|
}, e.prototype._getNextDelay = function() {
|
|
311
|
-
var t = this._options, n = t.reconnectionDelayGrowFactor, o = n === void 0 ?
|
|
312
|
-
return this._retryCount > 0 && (
|
|
311
|
+
var t = this._options, n = t.reconnectionDelayGrowFactor, o = n === void 0 ? F.reconnectionDelayGrowFactor : n, r = t.minReconnectionDelay, a = r === void 0 ? F.minReconnectionDelay : r, c = t.maxReconnectionDelay, l = c === void 0 ? F.maxReconnectionDelay : c, d = 0;
|
|
312
|
+
return this._retryCount > 0 && (d = a * Math.pow(o, this._retryCount - 1), d > l && (d = l)), this._debug("next delay", d), d;
|
|
313
313
|
}, e.prototype._wait = function() {
|
|
314
314
|
var t = this;
|
|
315
315
|
return new Promise(function(n) {
|
|
@@ -330,17 +330,17 @@ var un = function() {
|
|
|
330
330
|
var t = this;
|
|
331
331
|
if (!(this._connectLock || !this._shouldReconnect)) {
|
|
332
332
|
this._connectLock = !0;
|
|
333
|
-
var n = this._options, o = n.maxRetries, r = o === void 0 ?
|
|
333
|
+
var n = this._options, o = n.maxRetries, r = o === void 0 ? F.maxRetries : o, a = n.connectionTimeout, c = a === void 0 ? F.connectionTimeout : a, l = n.WebSocket, d = l === void 0 ? un() : l;
|
|
334
334
|
if (this._retryCount >= r) {
|
|
335
335
|
this._debug("max retries reached", this._retryCount, ">=", r);
|
|
336
336
|
return;
|
|
337
337
|
}
|
|
338
|
-
if (this._retryCount++, this._debug("connect", this._retryCount), this._removeListeners(), !cn(
|
|
338
|
+
if (this._retryCount++, this._debug("connect", this._retryCount), this._removeListeners(), !cn(d))
|
|
339
339
|
throw Error("No valid WebSocket class provided");
|
|
340
340
|
this._wait().then(function() {
|
|
341
341
|
return t._getNextUrl(t._url);
|
|
342
|
-
}).then(function(
|
|
343
|
-
t._closeCalled || (t._debug("connect", { url:
|
|
342
|
+
}).then(function(f) {
|
|
343
|
+
t._closeCalled || (t._debug("connect", { url: f, protocols: t._protocols }), t._ws = t._protocols ? new d(f, t._protocols) : new d(f), t._ws.binaryType = t._binaryType, t._connectLock = !1, t._addListeners(), t._connectTimeout = setTimeout(function() {
|
|
344
344
|
return t._handleTimeout();
|
|
345
345
|
}, c));
|
|
346
346
|
});
|
|
@@ -373,7 +373,7 @@ function dn(e) {
|
|
|
373
373
|
const t = typeof window < "u" ? window.location : void 0, n = `/assets/${encodeURIComponent(e)}`;
|
|
374
374
|
return `${t?.protocol}//${t?.hostname}:${zt}${n}`;
|
|
375
375
|
}
|
|
376
|
-
async function
|
|
376
|
+
async function za(e) {
|
|
377
377
|
const t = await fetch(e);
|
|
378
378
|
return URL.createObjectURL(new Blob([await t.arrayBuffer()]));
|
|
379
379
|
}
|
|
@@ -443,11 +443,11 @@ function gn({ interval: e, send: t, onChange: n = hn, syncSampleSize: o = mn, sy
|
|
|
443
443
|
async function c() {
|
|
444
444
|
const y = [];
|
|
445
445
|
for (let s = 0; s < o; s++) {
|
|
446
|
-
const u = new Promise((
|
|
447
|
-
const
|
|
448
|
-
t({ timesync: { id:
|
|
449
|
-
const w = (E, k) =>
|
|
450
|
-
a[
|
|
446
|
+
const u = new Promise((p) => {
|
|
447
|
+
const h = _n(), v = Date.now(), _ = performance.now();
|
|
448
|
+
t({ timesync: { id: h } });
|
|
449
|
+
const w = (E, k) => p({ sentAt: _, receivedAt: E, serverNow: k, clientNow: v });
|
|
450
|
+
a[h] = { complete: w }, setTimeout(() => p(null), r);
|
|
451
451
|
});
|
|
452
452
|
y.push(u), await u;
|
|
453
453
|
}
|
|
@@ -459,11 +459,11 @@ function gn({ interval: e, send: t, onChange: n = hn, syncSampleSize: o = mn, sy
|
|
|
459
459
|
i && i.complete(g, y.timesync.now);
|
|
460
460
|
};
|
|
461
461
|
c();
|
|
462
|
-
const
|
|
462
|
+
const d = setInterval(c, e);
|
|
463
463
|
return {
|
|
464
464
|
receive: l,
|
|
465
465
|
destroy: () => {
|
|
466
|
-
clearInterval(
|
|
466
|
+
clearInterval(d);
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
469
|
}
|
|
@@ -473,13 +473,13 @@ function yn(e) {
|
|
|
473
473
|
return r - o - a;
|
|
474
474
|
}).reduce((t, n) => t + n, 0) / e.length;
|
|
475
475
|
}
|
|
476
|
-
class
|
|
476
|
+
class Ia {
|
|
477
477
|
constructor(t, { hostname: n = document.location.hostname, port: o = zt } = {}, r, a) {
|
|
478
478
|
this.manifest = t, this.currentState = { ...r }, this.store = new pn(a ?? {});
|
|
479
|
-
const { useReconnectingWebsocket: c, path: l, pathParams:
|
|
480
|
-
this.urlParams = new URLSearchParams(
|
|
481
|
-
const
|
|
482
|
-
this.websocket = c ? new ln(
|
|
479
|
+
const { useReconnectingWebsocket: c, path: l, pathParams: d } = bn(document.location.href);
|
|
480
|
+
this.urlParams = new URLSearchParams(d), this.urlParams.set("screenWidth", window.screen.width.toString()), this.urlParams.set("screenHeight", window.screen.height.toString()), this.urlParams.set("screenPixelRatio", window.devicePixelRatio.toString());
|
|
481
|
+
const f = `ws://${n}:${o}${l}?${this.urlParams}`;
|
|
482
|
+
this.websocket = c ? new ln(f) : new WebSocket(f);
|
|
483
483
|
let y;
|
|
484
484
|
this.websocket.onopen = () => {
|
|
485
485
|
this.currentConfig = {}, this.currentState = {}, this.dispatchEvent(new wn()), this.setState(this.currentState), y = gn({
|
|
@@ -741,21 +741,21 @@ class zn extends Event {
|
|
|
741
741
|
}
|
|
742
742
|
// @__NO_SIDE_EFFECTS__
|
|
743
743
|
function m(e, t, n) {
|
|
744
|
-
function o(l,
|
|
744
|
+
function o(l, d) {
|
|
745
745
|
if (l._zod || Object.defineProperty(l, "_zod", {
|
|
746
746
|
value: {
|
|
747
|
-
def:
|
|
747
|
+
def: d,
|
|
748
748
|
constr: c,
|
|
749
749
|
traits: /* @__PURE__ */ new Set()
|
|
750
750
|
},
|
|
751
751
|
enumerable: !1
|
|
752
752
|
}), l._zod.traits.has(e))
|
|
753
753
|
return;
|
|
754
|
-
l._zod.traits.add(e), t(l,
|
|
755
|
-
const
|
|
754
|
+
l._zod.traits.add(e), t(l, d);
|
|
755
|
+
const f = c.prototype, y = Object.keys(f);
|
|
756
756
|
for (let g = 0; g < y.length; g++) {
|
|
757
757
|
const i = y[g];
|
|
758
|
-
i in l || (l[i] =
|
|
758
|
+
i in l || (l[i] = f[i].bind(l));
|
|
759
759
|
}
|
|
760
760
|
}
|
|
761
761
|
const r = n?.Parent ?? Object;
|
|
@@ -763,12 +763,12 @@ function m(e, t, n) {
|
|
|
763
763
|
}
|
|
764
764
|
Object.defineProperty(a, "name", { value: e });
|
|
765
765
|
function c(l) {
|
|
766
|
-
var
|
|
767
|
-
const
|
|
768
|
-
o(
|
|
769
|
-
for (const y of
|
|
766
|
+
var d;
|
|
767
|
+
const f = n?.Parent ? new a() : this;
|
|
768
|
+
o(f, l), (d = f._zod).deferred ?? (d.deferred = []);
|
|
769
|
+
for (const y of f._zod.deferred)
|
|
770
770
|
y();
|
|
771
|
-
return
|
|
771
|
+
return f;
|
|
772
772
|
}
|
|
773
773
|
return Object.defineProperty(c, "init", { value: o }), Object.defineProperty(c, Symbol.hasInstance, {
|
|
774
774
|
value: (l) => n?.Parent && l instanceof n.Parent ? !0 : l?._zod?.traits?.has(e)
|
|
@@ -792,7 +792,7 @@ function In(e) {
|
|
|
792
792
|
const t = Object.values(e).filter((o) => typeof o == "number");
|
|
793
793
|
return Object.entries(e).filter(([o, r]) => t.indexOf(+o) === -1).map(([o, r]) => r);
|
|
794
794
|
}
|
|
795
|
-
function
|
|
795
|
+
function Pe(e, t) {
|
|
796
796
|
return typeof t == "bigint" ? t.toString() : t;
|
|
797
797
|
}
|
|
798
798
|
function Re(e) {
|
|
@@ -816,8 +816,8 @@ function $n(e, t) {
|
|
|
816
816
|
const n = (e.toString().split(".")[1] || "").length, o = t.toString();
|
|
817
817
|
let r = (o.split(".")[1] || "").length;
|
|
818
818
|
if (r === 0 && /\d?e-\d?/.test(o)) {
|
|
819
|
-
const
|
|
820
|
-
|
|
819
|
+
const d = o.match(/\d?e-(\d?)/);
|
|
820
|
+
d?.[1] && (r = Number.parseInt(d[1]));
|
|
821
821
|
}
|
|
822
822
|
const a = n > r ? n : r, c = Number.parseInt(e.toFixed(a).replace(".", "")), l = Number.parseInt(t.toFixed(a).replace(".", ""));
|
|
823
823
|
return c % l / 10 ** a;
|
|
@@ -866,7 +866,7 @@ const Ot = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
|
866
866
|
function he(e) {
|
|
867
867
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
868
868
|
}
|
|
869
|
-
const
|
|
869
|
+
const Pn = Re(() => {
|
|
870
870
|
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
|
|
871
871
|
return !1;
|
|
872
872
|
try {
|
|
@@ -885,10 +885,10 @@ function H(e) {
|
|
|
885
885
|
const n = t.prototype;
|
|
886
886
|
return !(he(n) === !1 || Object.prototype.hasOwnProperty.call(n, "isPrototypeOf") === !1);
|
|
887
887
|
}
|
|
888
|
-
function
|
|
888
|
+
function Pt(e) {
|
|
889
889
|
return H(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
|
|
890
890
|
}
|
|
891
|
-
const
|
|
891
|
+
const Zn = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
892
892
|
function J(e) {
|
|
893
893
|
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
894
894
|
}
|
|
@@ -977,7 +977,7 @@ function Dn(e, t) {
|
|
|
977
977
|
};
|
|
978
978
|
return D(e, n);
|
|
979
979
|
}
|
|
980
|
-
function
|
|
980
|
+
function Un(e, t) {
|
|
981
981
|
const n = B(e._zod.def, {
|
|
982
982
|
get shape() {
|
|
983
983
|
const o = { ...e._zod.def.shape, ...t._zod.def.shape };
|
|
@@ -991,7 +991,7 @@ function Fn(e, t) {
|
|
|
991
991
|
});
|
|
992
992
|
return D(e, n);
|
|
993
993
|
}
|
|
994
|
-
function
|
|
994
|
+
function Fn(e, t, n) {
|
|
995
995
|
const o = B(t._zod.def, {
|
|
996
996
|
get shape() {
|
|
997
997
|
const r = t._zod.def.shape, a = { ...r };
|
|
@@ -1016,7 +1016,7 @@ function Mn(e, t, n) {
|
|
|
1016
1016
|
});
|
|
1017
1017
|
return D(t, o);
|
|
1018
1018
|
}
|
|
1019
|
-
function
|
|
1019
|
+
function Mn(e, t, n) {
|
|
1020
1020
|
const o = B(t._zod.def, {
|
|
1021
1021
|
get shape() {
|
|
1022
1022
|
const r = t._zod.def.shape, a = { ...r };
|
|
@@ -1049,7 +1049,7 @@ function q(e, t = 0) {
|
|
|
1049
1049
|
return !0;
|
|
1050
1050
|
return !1;
|
|
1051
1051
|
}
|
|
1052
|
-
function
|
|
1052
|
+
function M(e, t) {
|
|
1053
1053
|
return t.map((n) => {
|
|
1054
1054
|
var o;
|
|
1055
1055
|
return (o = n).path ?? (o.path = []), n.path.unshift(e), n;
|
|
@@ -1078,18 +1078,18 @@ function re(...e) {
|
|
|
1078
1078
|
inst: o
|
|
1079
1079
|
} : { ...t };
|
|
1080
1080
|
}
|
|
1081
|
-
const
|
|
1081
|
+
const Zt = (e, t) => {
|
|
1082
1082
|
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
1083
1083
|
value: e._zod,
|
|
1084
1084
|
enumerable: !1
|
|
1085
1085
|
}), Object.defineProperty(e, "issues", {
|
|
1086
1086
|
value: t,
|
|
1087
1087
|
enumerable: !1
|
|
1088
|
-
}), e.message = JSON.stringify(t,
|
|
1088
|
+
}), e.message = JSON.stringify(t, Pe, 2), Object.defineProperty(e, "toString", {
|
|
1089
1089
|
value: () => e.message,
|
|
1090
1090
|
enumerable: !1
|
|
1091
1091
|
});
|
|
1092
|
-
}, xt = /* @__PURE__ */ m("$ZodError",
|
|
1092
|
+
}, xt = /* @__PURE__ */ m("$ZodError", Zt), Lt = /* @__PURE__ */ m("$ZodError", Zt, { Parent: Error });
|
|
1093
1093
|
function Vn(e, t = (n) => n.message) {
|
|
1094
1094
|
const n = {}, o = [];
|
|
1095
1095
|
for (const r of e.issues)
|
|
@@ -1110,27 +1110,27 @@ function Bn(e, t = (n) => n.message) {
|
|
|
1110
1110
|
else {
|
|
1111
1111
|
let c = n, l = 0;
|
|
1112
1112
|
for (; l < a.path.length; ) {
|
|
1113
|
-
const
|
|
1114
|
-
l === a.path.length - 1 ? (c[
|
|
1113
|
+
const d = a.path[l];
|
|
1114
|
+
l === a.path.length - 1 ? (c[d] = c[d] || { _errors: [] }, c[d]._errors.push(t(a))) : c[d] = c[d] || { _errors: [] }, c = c[d], l++;
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
};
|
|
1118
1118
|
return o(e), n;
|
|
1119
1119
|
}
|
|
1120
|
-
const
|
|
1120
|
+
const Ue = (e) => (t, n, o, r) => {
|
|
1121
1121
|
const a = o ? Object.assign(o, { async: !1 }) : { async: !1 }, c = t._zod.run({ value: n, issues: [] }, a);
|
|
1122
1122
|
if (c instanceof Promise)
|
|
1123
1123
|
throw new K();
|
|
1124
1124
|
if (c.issues.length) {
|
|
1125
|
-
const l = new (r?.Err ?? e)(c.issues.map((
|
|
1125
|
+
const l = new (r?.Err ?? e)(c.issues.map((d) => N(d, a, j())));
|
|
1126
1126
|
throw Ot(l, r?.callee), l;
|
|
1127
1127
|
}
|
|
1128
1128
|
return c.value;
|
|
1129
|
-
},
|
|
1129
|
+
}, Fe = (e) => async (t, n, o, r) => {
|
|
1130
1130
|
const a = o ? Object.assign(o, { async: !0 }) : { async: !0 };
|
|
1131
1131
|
let c = t._zod.run({ value: n, issues: [] }, a);
|
|
1132
1132
|
if (c instanceof Promise && (c = await c), c.issues.length) {
|
|
1133
|
-
const l = new (r?.Err ?? e)(c.issues.map((
|
|
1133
|
+
const l = new (r?.Err ?? e)(c.issues.map((d) => N(d, a, j())));
|
|
1134
1134
|
throw Ot(l, r?.callee), l;
|
|
1135
1135
|
}
|
|
1136
1136
|
return c.value;
|
|
@@ -1151,11 +1151,11 @@ const Fe = (e) => (t, n, o, r) => {
|
|
|
1151
1151
|
} : { success: !0, data: a.value };
|
|
1152
1152
|
}, Wn = /* @__PURE__ */ ge(Lt), qn = (e) => (t, n, o) => {
|
|
1153
1153
|
const r = o ? Object.assign(o, { direction: "backward" }) : { direction: "backward" };
|
|
1154
|
-
return
|
|
1155
|
-
}, Kn = (e) => (t, n, o) =>
|
|
1154
|
+
return Ue(e)(t, n, r);
|
|
1155
|
+
}, Kn = (e) => (t, n, o) => Ue(e)(t, n, o), Hn = (e) => async (t, n, o) => {
|
|
1156
1156
|
const r = o ? Object.assign(o, { direction: "backward" }) : { direction: "backward" };
|
|
1157
|
-
return
|
|
1158
|
-
}, Jn = (e) => async (t, n, o) =>
|
|
1157
|
+
return Fe(e)(t, n, r);
|
|
1158
|
+
}, Jn = (e) => async (t, n, o) => Fe(e)(t, n, o), Yn = (e) => (t, n, o) => {
|
|
1159
1159
|
const r = o ? Object.assign(o, { direction: "backward" }) : { direction: "backward" };
|
|
1160
1160
|
return ve(e)(t, n, r);
|
|
1161
1161
|
}, Qn = (e) => (t, n, o) => ve(e)(t, n, o), Xn = (e) => async (t, n, o) => {
|
|
@@ -1189,7 +1189,7 @@ const Eo = (e) => {
|
|
|
1189
1189
|
number: "number",
|
|
1190
1190
|
bigint: "bigint",
|
|
1191
1191
|
object: "date"
|
|
1192
|
-
},
|
|
1192
|
+
}, Ut = /* @__PURE__ */ m("$ZodCheckLessThan", (e, t) => {
|
|
1193
1193
|
O.init(e, t);
|
|
1194
1194
|
const n = Dt[typeof t.value];
|
|
1195
1195
|
e._zod.onattach.push((o) => {
|
|
@@ -1206,7 +1206,7 @@ const Eo = (e) => {
|
|
|
1206
1206
|
continue: !t.abort
|
|
1207
1207
|
});
|
|
1208
1208
|
};
|
|
1209
|
-
}),
|
|
1209
|
+
}), Ft = /* @__PURE__ */ m("$ZodCheckGreaterThan", (e, t) => {
|
|
1210
1210
|
O.init(e, t);
|
|
1211
1211
|
const n = Dt[typeof t.value];
|
|
1212
1212
|
e._zod.onattach.push((o) => {
|
|
@@ -1342,7 +1342,7 @@ const Eo = (e) => {
|
|
|
1342
1342
|
continue: !t.abort
|
|
1343
1343
|
});
|
|
1344
1344
|
};
|
|
1345
|
-
}),
|
|
1345
|
+
}), Po = /* @__PURE__ */ m("$ZodCheckLengthEquals", (e, t) => {
|
|
1346
1346
|
var n;
|
|
1347
1347
|
O.init(e, t), (n = e._zod.def).when ?? (n.when = (o) => {
|
|
1348
1348
|
const r = o.value;
|
|
@@ -1382,7 +1382,7 @@ const Eo = (e) => {
|
|
|
1382
1382
|
});
|
|
1383
1383
|
}) : (o = e._zod).check ?? (o.check = () => {
|
|
1384
1384
|
});
|
|
1385
|
-
}),
|
|
1385
|
+
}), Zo = /* @__PURE__ */ m("$ZodCheckRegex", (e, t) => {
|
|
1386
1386
|
ye.init(e, t), e._zod.check = (n) => {
|
|
1387
1387
|
t.pattern.lastIndex = 0, !t.pattern.test(n.value) && n.issues.push({
|
|
1388
1388
|
origin: "string",
|
|
@@ -1454,7 +1454,7 @@ const Eo = (e) => {
|
|
|
1454
1454
|
n.value = t.tx(n.value);
|
|
1455
1455
|
};
|
|
1456
1456
|
});
|
|
1457
|
-
class
|
|
1457
|
+
class Uo {
|
|
1458
1458
|
constructor(t = []) {
|
|
1459
1459
|
this.content = [], this.indent = 0, this && (this.args = t);
|
|
1460
1460
|
}
|
|
@@ -1477,13 +1477,13 @@ class Fo {
|
|
|
1477
1477
|
`));
|
|
1478
1478
|
}
|
|
1479
1479
|
}
|
|
1480
|
-
const
|
|
1480
|
+
const Fo = {
|
|
1481
1481
|
major: 4,
|
|
1482
1482
|
minor: 1,
|
|
1483
1483
|
patch: 13
|
|
1484
1484
|
}, A = /* @__PURE__ */ m("$ZodType", (e, t) => {
|
|
1485
1485
|
var n;
|
|
1486
|
-
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version =
|
|
1486
|
+
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = Fo;
|
|
1487
1487
|
const o = [...e._zod.def.checks ?? []];
|
|
1488
1488
|
e._zod.traits.has("$ZodCheck") && o.unshift(e);
|
|
1489
1489
|
for (const r of o)
|
|
@@ -1494,53 +1494,53 @@ const Mo = {
|
|
|
1494
1494
|
e._zod.run = e._zod.parse;
|
|
1495
1495
|
});
|
|
1496
1496
|
else {
|
|
1497
|
-
const r = (c, l,
|
|
1498
|
-
let
|
|
1497
|
+
const r = (c, l, d) => {
|
|
1498
|
+
let f = q(c), y;
|
|
1499
1499
|
for (const g of l) {
|
|
1500
1500
|
if (g._zod.def.when) {
|
|
1501
1501
|
if (!g._zod.def.when(c))
|
|
1502
1502
|
continue;
|
|
1503
|
-
} else if (
|
|
1503
|
+
} else if (f)
|
|
1504
1504
|
continue;
|
|
1505
1505
|
const i = c.issues.length, s = g._zod.check(c);
|
|
1506
|
-
if (s instanceof Promise &&
|
|
1506
|
+
if (s instanceof Promise && d?.async === !1)
|
|
1507
1507
|
throw new K();
|
|
1508
1508
|
if (y || s instanceof Promise)
|
|
1509
1509
|
y = (y ?? Promise.resolve()).then(async () => {
|
|
1510
|
-
await s, c.issues.length !== i && (
|
|
1510
|
+
await s, c.issues.length !== i && (f || (f = q(c, i)));
|
|
1511
1511
|
});
|
|
1512
1512
|
else {
|
|
1513
1513
|
if (c.issues.length === i)
|
|
1514
1514
|
continue;
|
|
1515
|
-
|
|
1515
|
+
f || (f = q(c, i));
|
|
1516
1516
|
}
|
|
1517
1517
|
}
|
|
1518
1518
|
return y ? y.then(() => c) : c;
|
|
1519
|
-
}, a = (c, l,
|
|
1519
|
+
}, a = (c, l, d) => {
|
|
1520
1520
|
if (q(c))
|
|
1521
1521
|
return c.aborted = !0, c;
|
|
1522
|
-
const
|
|
1523
|
-
if (
|
|
1524
|
-
if (
|
|
1522
|
+
const f = r(l, o, d);
|
|
1523
|
+
if (f instanceof Promise) {
|
|
1524
|
+
if (d.async === !1)
|
|
1525
1525
|
throw new K();
|
|
1526
|
-
return
|
|
1526
|
+
return f.then((y) => e._zod.parse(y, d));
|
|
1527
1527
|
}
|
|
1528
|
-
return e._zod.parse(
|
|
1528
|
+
return e._zod.parse(f, d);
|
|
1529
1529
|
};
|
|
1530
1530
|
e._zod.run = (c, l) => {
|
|
1531
1531
|
if (l.skipChecks)
|
|
1532
1532
|
return e._zod.parse(c, l);
|
|
1533
1533
|
if (l.direction === "backward") {
|
|
1534
|
-
const
|
|
1535
|
-
return
|
|
1534
|
+
const f = e._zod.parse({ value: c.value, issues: [] }, { ...l, skipChecks: !0 });
|
|
1535
|
+
return f instanceof Promise ? f.then((y) => a(y, c, l)) : a(f, c, l);
|
|
1536
1536
|
}
|
|
1537
|
-
const
|
|
1538
|
-
if (
|
|
1537
|
+
const d = e._zod.parse(c, l);
|
|
1538
|
+
if (d instanceof Promise) {
|
|
1539
1539
|
if (l.async === !1)
|
|
1540
1540
|
throw new K();
|
|
1541
|
-
return
|
|
1541
|
+
return d.then((f) => r(f, o, l));
|
|
1542
1542
|
}
|
|
1543
|
-
return r(
|
|
1543
|
+
return r(d, o, l);
|
|
1544
1544
|
};
|
|
1545
1545
|
}
|
|
1546
1546
|
e["~standard"] = {
|
|
@@ -1555,7 +1555,7 @@ const Mo = {
|
|
|
1555
1555
|
vendor: "zod",
|
|
1556
1556
|
version: 1
|
|
1557
1557
|
};
|
|
1558
|
-
}),
|
|
1558
|
+
}), Me = /* @__PURE__ */ m("$ZodString", (e, t) => {
|
|
1559
1559
|
A.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? Eo(e._zod.bag), e._zod.parse = (n, o) => {
|
|
1560
1560
|
if (t.coerce)
|
|
1561
1561
|
try {
|
|
@@ -1570,8 +1570,8 @@ const Mo = {
|
|
|
1570
1570
|
}), n;
|
|
1571
1571
|
};
|
|
1572
1572
|
}), z = /* @__PURE__ */ m("$ZodStringFormat", (e, t) => {
|
|
1573
|
-
ye.init(e, t),
|
|
1574
|
-
}),
|
|
1573
|
+
ye.init(e, t), Me.init(e, t);
|
|
1574
|
+
}), Mo = /* @__PURE__ */ m("$ZodGUID", (e, t) => {
|
|
1575
1575
|
t.pattern ?? (t.pattern = uo), z.init(e, t);
|
|
1576
1576
|
}), Vo = /* @__PURE__ */ m("$ZodUUID", (e, t) => {
|
|
1577
1577
|
if (t.version) {
|
|
@@ -1691,7 +1691,7 @@ const Mo = {
|
|
|
1691
1691
|
}
|
|
1692
1692
|
};
|
|
1693
1693
|
});
|
|
1694
|
-
function
|
|
1694
|
+
function Mt(e) {
|
|
1695
1695
|
if (e === "")
|
|
1696
1696
|
return !0;
|
|
1697
1697
|
if (e.length % 4 !== 0)
|
|
@@ -1704,7 +1704,7 @@ function Ut(e) {
|
|
|
1704
1704
|
}
|
|
1705
1705
|
const ai = /* @__PURE__ */ m("$ZodBase64", (e, t) => {
|
|
1706
1706
|
t.pattern ?? (t.pattern = vo), z.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (n) => {
|
|
1707
|
-
|
|
1707
|
+
Mt(n.value) || n.issues.push({
|
|
1708
1708
|
code: "invalid_format",
|
|
1709
1709
|
format: "base64",
|
|
1710
1710
|
input: n.value,
|
|
@@ -1717,7 +1717,7 @@ function ui(e) {
|
|
|
1717
1717
|
if (!Rt.test(e))
|
|
1718
1718
|
return !1;
|
|
1719
1719
|
const t = e.replace(/[-_]/g, (o) => o === "-" ? "+" : "/"), n = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
|
|
1720
|
-
return
|
|
1720
|
+
return Mt(n);
|
|
1721
1721
|
}
|
|
1722
1722
|
const ci = /* @__PURE__ */ m("$ZodBase64URL", (e, t) => {
|
|
1723
1723
|
t.pattern ?? (t.pattern = Rt), z.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (n) => {
|
|
@@ -1798,7 +1798,7 @@ const pi = /* @__PURE__ */ m("$ZodJWT", (e, t) => {
|
|
|
1798
1798
|
}), n);
|
|
1799
1799
|
});
|
|
1800
1800
|
function Xe(e, t, n) {
|
|
1801
|
-
e.issues.length && t.issues.push(...
|
|
1801
|
+
e.issues.length && t.issues.push(...M(n, e.issues)), t.value[n] = e.value;
|
|
1802
1802
|
}
|
|
1803
1803
|
const vi = /* @__PURE__ */ m("$ZodArray", (e, t) => {
|
|
1804
1804
|
A.init(e, t), e._zod.parse = (n, o) => {
|
|
@@ -1813,17 +1813,17 @@ const vi = /* @__PURE__ */ m("$ZodArray", (e, t) => {
|
|
|
1813
1813
|
n.value = Array(r.length);
|
|
1814
1814
|
const a = [];
|
|
1815
1815
|
for (let c = 0; c < r.length; c++) {
|
|
1816
|
-
const l = r[c],
|
|
1816
|
+
const l = r[c], d = t.element._zod.run({
|
|
1817
1817
|
value: l,
|
|
1818
1818
|
issues: []
|
|
1819
1819
|
}, o);
|
|
1820
|
-
|
|
1820
|
+
d instanceof Promise ? a.push(d.then((f) => Xe(f, n, c))) : Xe(d, n, c);
|
|
1821
1821
|
}
|
|
1822
1822
|
return a.length ? Promise.all(a).then(() => n) : n;
|
|
1823
1823
|
};
|
|
1824
1824
|
});
|
|
1825
1825
|
function fe(e, t, n, o) {
|
|
1826
|
-
e.issues.length && t.issues.push(...
|
|
1826
|
+
e.issues.length && t.issues.push(...M(n, e.issues)), e.value === void 0 ? n in o && (t.value[n] = void 0) : t.value[n] = e.value;
|
|
1827
1827
|
}
|
|
1828
1828
|
function Bt(e) {
|
|
1829
1829
|
const t = Object.keys(e.shape);
|
|
@@ -1840,15 +1840,15 @@ function Bt(e) {
|
|
|
1840
1840
|
};
|
|
1841
1841
|
}
|
|
1842
1842
|
function Gt(e, t, n, o, r, a) {
|
|
1843
|
-
const c = [], l = r.keySet,
|
|
1843
|
+
const c = [], l = r.keySet, d = r.catchall._zod, f = d.def.type;
|
|
1844
1844
|
for (const y in t) {
|
|
1845
1845
|
if (l.has(y))
|
|
1846
1846
|
continue;
|
|
1847
|
-
if (
|
|
1847
|
+
if (f === "never") {
|
|
1848
1848
|
c.push(y);
|
|
1849
1849
|
continue;
|
|
1850
1850
|
}
|
|
1851
|
-
const g =
|
|
1851
|
+
const g = d.run({ value: t[y], issues: [] }, o);
|
|
1852
1852
|
g instanceof Promise ? e.push(g.then((i) => fe(i, n, y, t))) : fe(g, n, y, t);
|
|
1853
1853
|
}
|
|
1854
1854
|
return c.length && n.issues.push({
|
|
@@ -1863,62 +1863,62 @@ const gi = /* @__PURE__ */ m("$ZodObject", (e, t) => {
|
|
|
1863
1863
|
const l = t.shape;
|
|
1864
1864
|
Object.defineProperty(t, "shape", {
|
|
1865
1865
|
get: () => {
|
|
1866
|
-
const
|
|
1866
|
+
const d = { ...l };
|
|
1867
1867
|
return Object.defineProperty(t, "shape", {
|
|
1868
|
-
value:
|
|
1869
|
-
}),
|
|
1868
|
+
value: d
|
|
1869
|
+
}), d;
|
|
1870
1870
|
}
|
|
1871
1871
|
});
|
|
1872
1872
|
}
|
|
1873
1873
|
const o = Re(() => Bt(t));
|
|
1874
1874
|
C(e._zod, "propValues", () => {
|
|
1875
|
-
const l = t.shape,
|
|
1876
|
-
for (const
|
|
1877
|
-
const y = l[
|
|
1875
|
+
const l = t.shape, d = {};
|
|
1876
|
+
for (const f in l) {
|
|
1877
|
+
const y = l[f]._zod;
|
|
1878
1878
|
if (y.values) {
|
|
1879
|
-
|
|
1879
|
+
d[f] ?? (d[f] = /* @__PURE__ */ new Set());
|
|
1880
1880
|
for (const g of y.values)
|
|
1881
|
-
|
|
1881
|
+
d[f].add(g);
|
|
1882
1882
|
}
|
|
1883
1883
|
}
|
|
1884
|
-
return
|
|
1884
|
+
return d;
|
|
1885
1885
|
});
|
|
1886
1886
|
const r = he, a = t.catchall;
|
|
1887
1887
|
let c;
|
|
1888
|
-
e._zod.parse = (l,
|
|
1888
|
+
e._zod.parse = (l, d) => {
|
|
1889
1889
|
c ?? (c = o.value);
|
|
1890
|
-
const
|
|
1891
|
-
if (!r(
|
|
1890
|
+
const f = l.value;
|
|
1891
|
+
if (!r(f))
|
|
1892
1892
|
return l.issues.push({
|
|
1893
1893
|
expected: "object",
|
|
1894
1894
|
code: "invalid_type",
|
|
1895
|
-
input:
|
|
1895
|
+
input: f,
|
|
1896
1896
|
inst: e
|
|
1897
1897
|
}), l;
|
|
1898
1898
|
l.value = {};
|
|
1899
1899
|
const y = [], g = c.shape;
|
|
1900
1900
|
for (const i of c.keys) {
|
|
1901
|
-
const u = g[i]._zod.run({ value:
|
|
1902
|
-
u instanceof Promise ? y.push(u.then((
|
|
1901
|
+
const u = g[i]._zod.run({ value: f[i], issues: [] }, d);
|
|
1902
|
+
u instanceof Promise ? y.push(u.then((p) => fe(p, l, i, f))) : fe(u, l, i, f);
|
|
1903
1903
|
}
|
|
1904
|
-
return a ? Gt(y,
|
|
1904
|
+
return a ? Gt(y, f, l, d, o.value, e) : y.length ? Promise.all(y).then(() => l) : l;
|
|
1905
1905
|
};
|
|
1906
1906
|
}), yi = /* @__PURE__ */ m("$ZodObjectJIT", (e, t) => {
|
|
1907
1907
|
gi.init(e, t);
|
|
1908
1908
|
const n = e._zod.parse, o = Re(() => Bt(t)), r = (i) => {
|
|
1909
|
-
const s = new
|
|
1909
|
+
const s = new Uo(["shape", "payload", "ctx"]), u = o.value, p = (w) => {
|
|
1910
1910
|
const E = Ye(w);
|
|
1911
1911
|
return `shape[${E}]._zod.run({ value: input[${E}], issues: [] }, ctx)`;
|
|
1912
1912
|
};
|
|
1913
1913
|
s.write("const input = payload.value;");
|
|
1914
|
-
const
|
|
1914
|
+
const h = /* @__PURE__ */ Object.create(null);
|
|
1915
1915
|
let v = 0;
|
|
1916
1916
|
for (const w of u.keys)
|
|
1917
|
-
|
|
1917
|
+
h[w] = `key_${v++}`;
|
|
1918
1918
|
s.write("const newResult = {};");
|
|
1919
1919
|
for (const w of u.keys) {
|
|
1920
|
-
const E =
|
|
1921
|
-
s.write(`const ${E} = ${
|
|
1920
|
+
const E = h[w], k = Ye(w);
|
|
1921
|
+
s.write(`const ${E} = ${p(w)};`), s.write(`
|
|
1922
1922
|
if (${E}.issues.length) {
|
|
1923
1923
|
payload.issues = payload.issues.concat(${E}.issues.map(iss => ({
|
|
1924
1924
|
...iss,
|
|
@@ -1942,12 +1942,12 @@ const gi = /* @__PURE__ */ m("$ZodObject", (e, t) => {
|
|
|
1942
1942
|
return (w, E) => _(i, w, E);
|
|
1943
1943
|
};
|
|
1944
1944
|
let a;
|
|
1945
|
-
const c = he, l = !$t.jitless,
|
|
1945
|
+
const c = he, l = !$t.jitless, f = l && Pn.value, y = t.catchall;
|
|
1946
1946
|
let g;
|
|
1947
1947
|
e._zod.parse = (i, s) => {
|
|
1948
1948
|
g ?? (g = o.value);
|
|
1949
1949
|
const u = i.value;
|
|
1950
|
-
return c(u) ? l &&
|
|
1950
|
+
return c(u) ? l && f && s?.async === !1 && s.jitless !== !0 ? (a || (a = r(t.shape)), i = a(i, s), y ? Gt([], u, i, s, g, e) : i) : n(i, s) : (i.issues.push({
|
|
1951
1951
|
expected: "object",
|
|
1952
1952
|
code: "invalid_type",
|
|
1953
1953
|
input: u,
|
|
@@ -1983,28 +1983,28 @@ const bi = /* @__PURE__ */ m("$ZodUnion", (e, t) => {
|
|
|
1983
1983
|
return o(r, a);
|
|
1984
1984
|
let c = !1;
|
|
1985
1985
|
const l = [];
|
|
1986
|
-
for (const
|
|
1987
|
-
const
|
|
1986
|
+
for (const d of t.options) {
|
|
1987
|
+
const f = d._zod.run({
|
|
1988
1988
|
value: r.value,
|
|
1989
1989
|
issues: []
|
|
1990
1990
|
}, a);
|
|
1991
|
-
if (
|
|
1992
|
-
l.push(
|
|
1991
|
+
if (f instanceof Promise)
|
|
1992
|
+
l.push(f), c = !0;
|
|
1993
1993
|
else {
|
|
1994
|
-
if (
|
|
1995
|
-
return
|
|
1996
|
-
l.push(
|
|
1994
|
+
if (f.issues.length === 0)
|
|
1995
|
+
return f;
|
|
1996
|
+
l.push(f);
|
|
1997
1997
|
}
|
|
1998
1998
|
}
|
|
1999
|
-
return c ? Promise.all(l).then((
|
|
1999
|
+
return c ? Promise.all(l).then((d) => et(d, r, e, a)) : et(l, r, e, a);
|
|
2000
2000
|
};
|
|
2001
2001
|
}), wi = /* @__PURE__ */ m("$ZodIntersection", (e, t) => {
|
|
2002
2002
|
A.init(e, t), e._zod.parse = (n, o) => {
|
|
2003
2003
|
const r = n.value, a = t.left._zod.run({ value: r, issues: [] }, o), c = t.right._zod.run({ value: r, issues: [] }, o);
|
|
2004
|
-
return a instanceof Promise || c instanceof Promise ? Promise.all([a, c]).then(([
|
|
2004
|
+
return a instanceof Promise || c instanceof Promise ? Promise.all([a, c]).then(([d, f]) => tt(n, d, f)) : tt(n, a, c);
|
|
2005
2005
|
};
|
|
2006
2006
|
});
|
|
2007
|
-
function
|
|
2007
|
+
function Ze(e, t) {
|
|
2008
2008
|
if (e === t)
|
|
2009
2009
|
return { valid: !0, data: e };
|
|
2010
2010
|
if (e instanceof Date && t instanceof Date && +e == +t)
|
|
@@ -2012,7 +2012,7 @@ function Pe(e, t) {
|
|
|
2012
2012
|
if (H(e) && H(t)) {
|
|
2013
2013
|
const n = Object.keys(t), o = Object.keys(e).filter((a) => n.indexOf(a) !== -1), r = { ...e, ...t };
|
|
2014
2014
|
for (const a of o) {
|
|
2015
|
-
const c =
|
|
2015
|
+
const c = Ze(e[a], t[a]);
|
|
2016
2016
|
if (!c.valid)
|
|
2017
2017
|
return {
|
|
2018
2018
|
valid: !1,
|
|
@@ -2027,7 +2027,7 @@ function Pe(e, t) {
|
|
|
2027
2027
|
return { valid: !1, mergeErrorPath: [] };
|
|
2028
2028
|
const n = [];
|
|
2029
2029
|
for (let o = 0; o < e.length; o++) {
|
|
2030
|
-
const r = e[o], a = t[o], c =
|
|
2030
|
+
const r = e[o], a = t[o], c = Ze(r, a);
|
|
2031
2031
|
if (!c.valid)
|
|
2032
2032
|
return {
|
|
2033
2033
|
valid: !1,
|
|
@@ -2042,7 +2042,7 @@ function Pe(e, t) {
|
|
|
2042
2042
|
function tt(e, t, n) {
|
|
2043
2043
|
if (t.issues.length && e.issues.push(...t.issues), n.issues.length && e.issues.push(...n.issues), q(e))
|
|
2044
2044
|
return e;
|
|
2045
|
-
const o =
|
|
2045
|
+
const o = Ze(t.value, n.value);
|
|
2046
2046
|
if (!o.valid)
|
|
2047
2047
|
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);
|
|
2048
2048
|
return e.value = o.data, e;
|
|
@@ -2060,9 +2060,9 @@ const Ei = /* @__PURE__ */ m("$ZodTuple", (e, t) => {
|
|
|
2060
2060
|
code: "invalid_type"
|
|
2061
2061
|
}), o;
|
|
2062
2062
|
o.value = [];
|
|
2063
|
-
const c = [], l = [...n].reverse().findIndex((y) => y._zod.optin !== "optional"),
|
|
2063
|
+
const c = [], l = [...n].reverse().findIndex((y) => y._zod.optin !== "optional"), d = l === -1 ? 0 : n.length - l;
|
|
2064
2064
|
if (!t.rest) {
|
|
2065
|
-
const y = a.length > n.length, g = a.length <
|
|
2065
|
+
const y = a.length > n.length, g = a.length < d - 1;
|
|
2066
2066
|
if (y || g)
|
|
2067
2067
|
return o.issues.push({
|
|
2068
2068
|
...y ? { code: "too_big", maximum: n.length } : { code: "too_small", minimum: n.length },
|
|
@@ -2071,32 +2071,32 @@ const Ei = /* @__PURE__ */ m("$ZodTuple", (e, t) => {
|
|
|
2071
2071
|
origin: "array"
|
|
2072
2072
|
}), o;
|
|
2073
2073
|
}
|
|
2074
|
-
let
|
|
2074
|
+
let f = -1;
|
|
2075
2075
|
for (const y of n) {
|
|
2076
|
-
if (
|
|
2076
|
+
if (f++, f >= a.length && f >= d)
|
|
2077
2077
|
continue;
|
|
2078
2078
|
const g = y._zod.run({
|
|
2079
|
-
value: a[
|
|
2079
|
+
value: a[f],
|
|
2080
2080
|
issues: []
|
|
2081
2081
|
}, r);
|
|
2082
|
-
g instanceof Promise ? c.push(g.then((i) => ue(i, o,
|
|
2082
|
+
g instanceof Promise ? c.push(g.then((i) => ue(i, o, f))) : ue(g, o, f);
|
|
2083
2083
|
}
|
|
2084
2084
|
if (t.rest) {
|
|
2085
2085
|
const y = a.slice(n.length);
|
|
2086
2086
|
for (const g of y) {
|
|
2087
|
-
|
|
2087
|
+
f++;
|
|
2088
2088
|
const i = t.rest._zod.run({
|
|
2089
2089
|
value: g,
|
|
2090
2090
|
issues: []
|
|
2091
2091
|
}, r);
|
|
2092
|
-
i instanceof Promise ? c.push(i.then((s) => ue(s, o,
|
|
2092
|
+
i instanceof Promise ? c.push(i.then((s) => ue(s, o, f))) : ue(i, o, f);
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
2095
|
return c.length ? Promise.all(c).then(() => o) : o;
|
|
2096
2096
|
};
|
|
2097
2097
|
});
|
|
2098
2098
|
function ue(e, t, n) {
|
|
2099
|
-
e.issues.length && t.issues.push(...
|
|
2099
|
+
e.issues.length && t.issues.push(...M(n, e.issues)), t.value[n] = e.value;
|
|
2100
2100
|
}
|
|
2101
2101
|
const ki = /* @__PURE__ */ m("$ZodRecord", (e, t) => {
|
|
2102
2102
|
A.init(e, t), e._zod.parse = (n, o) => {
|
|
@@ -2112,46 +2112,46 @@ const ki = /* @__PURE__ */ m("$ZodRecord", (e, t) => {
|
|
|
2112
2112
|
if (c) {
|
|
2113
2113
|
n.value = {};
|
|
2114
2114
|
const l = /* @__PURE__ */ new Set();
|
|
2115
|
-
for (const
|
|
2116
|
-
if (typeof
|
|
2117
|
-
l.add(typeof
|
|
2118
|
-
const y = t.valueType._zod.run({ value: r[
|
|
2115
|
+
for (const f of c)
|
|
2116
|
+
if (typeof f == "string" || typeof f == "number" || typeof f == "symbol") {
|
|
2117
|
+
l.add(typeof f == "number" ? f.toString() : f);
|
|
2118
|
+
const y = t.valueType._zod.run({ value: r[f], issues: [] }, o);
|
|
2119
2119
|
y instanceof Promise ? a.push(y.then((g) => {
|
|
2120
|
-
g.issues.length && n.issues.push(...
|
|
2121
|
-
})) : (y.issues.length && n.issues.push(...
|
|
2120
|
+
g.issues.length && n.issues.push(...M(f, g.issues)), n.value[f] = g.value;
|
|
2121
|
+
})) : (y.issues.length && n.issues.push(...M(f, y.issues)), n.value[f] = y.value);
|
|
2122
2122
|
}
|
|
2123
|
-
let
|
|
2124
|
-
for (const
|
|
2125
|
-
l.has(
|
|
2126
|
-
|
|
2123
|
+
let d;
|
|
2124
|
+
for (const f in r)
|
|
2125
|
+
l.has(f) || (d = d ?? [], d.push(f));
|
|
2126
|
+
d && d.length > 0 && n.issues.push({
|
|
2127
2127
|
code: "unrecognized_keys",
|
|
2128
2128
|
input: r,
|
|
2129
2129
|
inst: e,
|
|
2130
|
-
keys:
|
|
2130
|
+
keys: d
|
|
2131
2131
|
});
|
|
2132
2132
|
} else {
|
|
2133
2133
|
n.value = {};
|
|
2134
2134
|
for (const l of Reflect.ownKeys(r)) {
|
|
2135
2135
|
if (l === "__proto__")
|
|
2136
2136
|
continue;
|
|
2137
|
-
const
|
|
2138
|
-
if (
|
|
2137
|
+
const d = t.keyType._zod.run({ value: l, issues: [] }, o);
|
|
2138
|
+
if (d instanceof Promise)
|
|
2139
2139
|
throw new Error("Async schemas not supported in object keys currently");
|
|
2140
|
-
if (
|
|
2140
|
+
if (d.issues.length) {
|
|
2141
2141
|
n.issues.push({
|
|
2142
2142
|
code: "invalid_key",
|
|
2143
2143
|
origin: "record",
|
|
2144
|
-
issues:
|
|
2144
|
+
issues: d.issues.map((y) => N(y, o, j())),
|
|
2145
2145
|
input: l,
|
|
2146
2146
|
path: [l],
|
|
2147
2147
|
inst: e
|
|
2148
|
-
}), n.value[
|
|
2148
|
+
}), n.value[d.value] = d.value;
|
|
2149
2149
|
continue;
|
|
2150
2150
|
}
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2153
|
-
y.issues.length && n.issues.push(...
|
|
2154
|
-
})) : (
|
|
2151
|
+
const f = t.valueType._zod.run({ value: r[l], issues: [] }, o);
|
|
2152
|
+
f instanceof Promise ? a.push(f.then((y) => {
|
|
2153
|
+
y.issues.length && n.issues.push(...M(l, y.issues)), n.value[d.value] = y.value;
|
|
2154
|
+
})) : (f.issues.length && n.issues.push(...M(l, f.issues)), n.value[d.value] = f.value);
|
|
2155
2155
|
}
|
|
2156
2156
|
}
|
|
2157
2157
|
return a.length ? Promise.all(a).then(() => n) : n;
|
|
@@ -2159,7 +2159,7 @@ const ki = /* @__PURE__ */ m("$ZodRecord", (e, t) => {
|
|
|
2159
2159
|
}), Ci = /* @__PURE__ */ m("$ZodEnum", (e, t) => {
|
|
2160
2160
|
A.init(e, t);
|
|
2161
2161
|
const n = In(t.entries), o = new Set(n);
|
|
2162
|
-
e._zod.values = o, e._zod.pattern = new RegExp(`^(${n.filter((r) =>
|
|
2162
|
+
e._zod.values = o, e._zod.pattern = new RegExp(`^(${n.filter((r) => Zn.has(typeof r)).map((r) => typeof r == "string" ? J(r) : r.toString()).join("|")})$`), e._zod.parse = (r, a) => {
|
|
2163
2163
|
const c = r.value;
|
|
2164
2164
|
return o.has(c) || r.issues.push({
|
|
2165
2165
|
code: "invalid_value",
|
|
@@ -2244,7 +2244,7 @@ function it(e, t) {
|
|
|
2244
2244
|
inst: t
|
|
2245
2245
|
}), e;
|
|
2246
2246
|
}
|
|
2247
|
-
const
|
|
2247
|
+
const Pi = /* @__PURE__ */ m("$ZodCatch", (e, t) => {
|
|
2248
2248
|
A.init(e, t), C(e._zod, "optin", () => t.innerType._zod.optin), C(e._zod, "optout", () => t.innerType._zod.optout), C(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (n, o) => {
|
|
2249
2249
|
if (o.direction === "backward")
|
|
2250
2250
|
return t.innerType._zod.run(n, o);
|
|
@@ -2263,7 +2263,7 @@ const Zi = /* @__PURE__ */ m("$ZodCatch", (e, t) => {
|
|
|
2263
2263
|
input: n.value
|
|
2264
2264
|
}), n.issues = []), n);
|
|
2265
2265
|
};
|
|
2266
|
-
}),
|
|
2266
|
+
}), Zi = /* @__PURE__ */ m("$ZodPipe", (e, t) => {
|
|
2267
2267
|
A.init(e, t), C(e._zod, "values", () => t.in._zod.values), C(e._zod, "optin", () => t.in._zod.optin), C(e._zod, "optout", () => t.out._zod.optout), C(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (n, o) => {
|
|
2268
2268
|
if (o.direction === "backward") {
|
|
2269
2269
|
const a = t.out._zod.run(n, o);
|
|
@@ -2374,7 +2374,7 @@ function ut(e, t) {
|
|
|
2374
2374
|
...b(t)
|
|
2375
2375
|
});
|
|
2376
2376
|
}
|
|
2377
|
-
function
|
|
2377
|
+
function Ui(e, t) {
|
|
2378
2378
|
return new e({
|
|
2379
2379
|
type: "string",
|
|
2380
2380
|
format: "uuid",
|
|
@@ -2383,7 +2383,7 @@ function Fi(e, t) {
|
|
|
2383
2383
|
...b(t)
|
|
2384
2384
|
});
|
|
2385
2385
|
}
|
|
2386
|
-
function
|
|
2386
|
+
function Fi(e, t) {
|
|
2387
2387
|
return new e({
|
|
2388
2388
|
type: "string",
|
|
2389
2389
|
format: "uuid",
|
|
@@ -2393,7 +2393,7 @@ function Mi(e, t) {
|
|
|
2393
2393
|
...b(t)
|
|
2394
2394
|
});
|
|
2395
2395
|
}
|
|
2396
|
-
function
|
|
2396
|
+
function Mi(e, t) {
|
|
2397
2397
|
return new e({
|
|
2398
2398
|
type: "string",
|
|
2399
2399
|
format: "uuid",
|
|
@@ -2627,7 +2627,7 @@ function fr(e, t) {
|
|
|
2627
2627
|
});
|
|
2628
2628
|
}
|
|
2629
2629
|
function ct(e, t) {
|
|
2630
|
-
return new
|
|
2630
|
+
return new Ut({
|
|
2631
2631
|
check: "less_than",
|
|
2632
2632
|
...b(t),
|
|
2633
2633
|
value: e,
|
|
@@ -2635,7 +2635,7 @@ function ct(e, t) {
|
|
|
2635
2635
|
});
|
|
2636
2636
|
}
|
|
2637
2637
|
function Ce(e, t) {
|
|
2638
|
-
return new
|
|
2638
|
+
return new Ut({
|
|
2639
2639
|
check: "less_than",
|
|
2640
2640
|
...b(t),
|
|
2641
2641
|
value: e,
|
|
@@ -2643,7 +2643,7 @@ function Ce(e, t) {
|
|
|
2643
2643
|
});
|
|
2644
2644
|
}
|
|
2645
2645
|
function lt(e, t) {
|
|
2646
|
-
return new
|
|
2646
|
+
return new Ft({
|
|
2647
2647
|
check: "greater_than",
|
|
2648
2648
|
...b(t),
|
|
2649
2649
|
value: e,
|
|
@@ -2651,7 +2651,7 @@ function lt(e, t) {
|
|
|
2651
2651
|
});
|
|
2652
2652
|
}
|
|
2653
2653
|
function Ae(e, t) {
|
|
2654
|
-
return new
|
|
2654
|
+
return new Ft({
|
|
2655
2655
|
check: "greater_than",
|
|
2656
2656
|
...b(t),
|
|
2657
2657
|
value: e,
|
|
@@ -2680,14 +2680,14 @@ function _e(e, t) {
|
|
|
2680
2680
|
});
|
|
2681
2681
|
}
|
|
2682
2682
|
function qt(e, t) {
|
|
2683
|
-
return new
|
|
2683
|
+
return new Po({
|
|
2684
2684
|
check: "length_equals",
|
|
2685
2685
|
...b(t),
|
|
2686
2686
|
length: e
|
|
2687
2687
|
});
|
|
2688
2688
|
}
|
|
2689
2689
|
function _r(e, t) {
|
|
2690
|
-
return new
|
|
2690
|
+
return new Zo({
|
|
2691
2691
|
check: "string_format",
|
|
2692
2692
|
format: "regex",
|
|
2693
2693
|
...b(t),
|
|
@@ -2795,11 +2795,11 @@ const $r = /* @__PURE__ */ m("ZodISODateTime", (e, t) => {
|
|
|
2795
2795
|
function Or(e) {
|
|
2796
2796
|
return sr($r, e);
|
|
2797
2797
|
}
|
|
2798
|
-
const
|
|
2798
|
+
const Pr = /* @__PURE__ */ m("ZodISODate", (e, t) => {
|
|
2799
2799
|
ei.init(e, t), $.init(e, t);
|
|
2800
2800
|
});
|
|
2801
|
-
function
|
|
2802
|
-
return ar(
|
|
2801
|
+
function Zr(e) {
|
|
2802
|
+
return ar(Pr, e);
|
|
2803
2803
|
}
|
|
2804
2804
|
const xr = /* @__PURE__ */ m("ZodISOTime", (e, t) => {
|
|
2805
2805
|
ti.init(e, t), $.init(e, t);
|
|
@@ -2825,13 +2825,13 @@ const Nr = (e, t) => {
|
|
|
2825
2825
|
},
|
|
2826
2826
|
addIssue: {
|
|
2827
2827
|
value: (n) => {
|
|
2828
|
-
e.issues.push(n), e.message = JSON.stringify(e.issues,
|
|
2828
|
+
e.issues.push(n), e.message = JSON.stringify(e.issues, Pe, 2);
|
|
2829
2829
|
}
|
|
2830
2830
|
// enumerable: false,
|
|
2831
2831
|
},
|
|
2832
2832
|
addIssues: {
|
|
2833
2833
|
value: (n) => {
|
|
2834
|
-
e.issues.push(...n), e.message = JSON.stringify(e.issues,
|
|
2834
|
+
e.issues.push(...n), e.message = JSON.stringify(e.issues, Pe, 2);
|
|
2835
2835
|
}
|
|
2836
2836
|
// enumerable: false,
|
|
2837
2837
|
},
|
|
@@ -2842,14 +2842,14 @@ const Nr = (e, t) => {
|
|
|
2842
2842
|
// enumerable: false,
|
|
2843
2843
|
}
|
|
2844
2844
|
});
|
|
2845
|
-
},
|
|
2845
|
+
}, Z = /* @__PURE__ */ m("ZodError", Nr, {
|
|
2846
2846
|
Parent: Error
|
|
2847
|
-
}), Dr = /* @__PURE__ */
|
|
2847
|
+
}), Dr = /* @__PURE__ */ Ue(Z), Ur = /* @__PURE__ */ Fe(Z), Fr = /* @__PURE__ */ ve(Z), Mr = /* @__PURE__ */ ge(Z), Vr = /* @__PURE__ */ qn(Z), Br = /* @__PURE__ */ Kn(Z), Gr = /* @__PURE__ */ Hn(Z), Wr = /* @__PURE__ */ Jn(Z), qr = /* @__PURE__ */ Yn(Z), Kr = /* @__PURE__ */ Qn(Z), Hr = /* @__PURE__ */ Xn(Z), Jr = /* @__PURE__ */ eo(Z), I = /* @__PURE__ */ m("ZodType", (e, t) => (A.init(e, t), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...n) => e.clone(B(t, {
|
|
2848
2848
|
checks: [
|
|
2849
2849
|
...t.checks ?? [],
|
|
2850
2850
|
...n.map((o) => typeof o == "function" ? { _zod: { check: o, def: { check: "custom" }, onattach: [] } } : o)
|
|
2851
2851
|
]
|
|
2852
|
-
})), e.clone = (n, o) => D(e, n, o), e.brand = () => e, e.register = (n, o) => (n.add(e, o), e), e.parse = (n, o) => Dr(e, n, o, { callee: e.parse }), e.safeParse = (n, o) =>
|
|
2852
|
+
})), e.clone = (n, o) => D(e, n, o), e.brand = () => e, e.register = (n, o) => (n.add(e, o), e), e.parse = (n, o) => Dr(e, n, o, { callee: e.parse }), e.safeParse = (n, o) => Fr(e, n, o), e.parseAsync = async (n, o) => Ur(e, n, o, { callee: e.parseAsync }), e.safeParseAsync = async (n, o) => Mr(e, n, o), e.spa = e.safeParseAsync, e.encode = (n, o) => Vr(e, n, o), e.decode = (n, o) => Br(e, n, o), e.encodeAsync = async (n, o) => Gr(e, n, o), e.decodeAsync = async (n, o) => Wr(e, n, o), e.safeEncode = (n, o) => qr(e, n, o), e.safeDecode = (n, o) => Kr(e, n, o), e.safeEncodeAsync = async (n, o) => Hr(e, n, o), e.safeDecodeAsync = async (n, o) => Jr(e, n, o), e.refine = (n, o) => e.check(Ws(n, o)), e.superRefine = (n) => e.check(qs(n)), e.overwrite = (n) => e.check(ee(n)), e.optional = () => _t(e), e.nullable = () => mt(e), e.nullish = () => _t(mt(e)), e.nonoptional = (n) => Ds(e, n), e.array = () => Es(e), e.or = (n) => G([e, n]), e.and = (n) => Ts(e, n), e.transform = (n) => vt(e, Zs(n)), e.default = (n) => Rs(e, n), e.prefault = (n) => Ns(e, n), e.catch = (n) => Fs(e, n), e.pipe = (n) => vt(e, n), e.readonly = () => Bs(e), e.describe = (n) => {
|
|
2853
2853
|
const o = e.clone();
|
|
2854
2854
|
return le.add(o, { description: n }), o;
|
|
2855
2855
|
}, Object.defineProperty(e, "description", {
|
|
@@ -2863,11 +2863,11 @@ const Nr = (e, t) => {
|
|
|
2863
2863
|
const o = e.clone();
|
|
2864
2864
|
return le.add(o, n[0]), o;
|
|
2865
2865
|
}, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e)), Kt = /* @__PURE__ */ m("_ZodString", (e, t) => {
|
|
2866
|
-
|
|
2866
|
+
Me.init(e, t), I.init(e, t);
|
|
2867
2867
|
const n = e._zod.bag;
|
|
2868
2868
|
e.format = n.format ?? null, e.minLength = n.minimum ?? null, e.maxLength = n.maximum ?? null, e.regex = (...o) => e.check(_r(...o)), e.includes = (...o) => e.check(gr(...o)), e.startsWith = (...o) => e.check(yr(...o)), e.endsWith = (...o) => e.check(br(...o)), e.min = (...o) => e.check(_e(...o)), e.max = (...o) => e.check(Wt(...o)), e.length = (...o) => e.check(qt(...o)), e.nonempty = (...o) => e.check(_e(1, ...o)), e.lowercase = (o) => e.check(mr(o)), e.uppercase = (o) => e.check(vr(o)), e.trim = () => e.check(Er()), e.normalize = (...o) => e.check(wr(...o)), e.toLowerCase = () => e.check(kr()), e.toUpperCase = () => e.check(Cr()), e.slugify = () => e.check(Ar());
|
|
2869
2869
|
}), Yr = /* @__PURE__ */ m("ZodString", (e, t) => {
|
|
2870
|
-
|
|
2870
|
+
Me.init(e, t), Kt.init(e, t), e.email = (n) => e.check(Di(Qr, n)), e.url = (n) => e.check(Bi(Xr, n)), e.jwt = (n) => e.check(rr(fs, n)), e.emoji = (n) => e.check(Gi(es, n)), e.guid = (n) => e.check(ut(pt, n)), e.uuid = (n) => e.check(Ui(de, n)), e.uuidv4 = (n) => e.check(Fi(de, n)), e.uuidv6 = (n) => e.check(Mi(de, n)), e.uuidv7 = (n) => e.check(Vi(de, n)), e.nanoid = (n) => e.check(Wi(ts, n)), e.guid = (n) => e.check(ut(pt, n)), e.cuid = (n) => e.check(qi(ns, n)), e.cuid2 = (n) => e.check(Ki(os, n)), e.ulid = (n) => e.check(Hi(is, n)), e.base64 = (n) => e.check(nr(ds, n)), e.base64url = (n) => e.check(or(ps, n)), e.xid = (n) => e.check(Ji(rs, n)), e.ksuid = (n) => e.check(Yi(ss, n)), e.ipv4 = (n) => e.check(Qi(as, n)), e.ipv6 = (n) => e.check(Xi(us, n)), e.cidrv4 = (n) => e.check(er(cs, n)), e.cidrv6 = (n) => e.check(tr(ls, n)), e.e164 = (n) => e.check(ir(hs, n)), e.datetime = (n) => e.check(Or(n)), e.date = (n) => e.check(Zr(n)), e.time = (n) => e.check(Lr(n)), e.duration = (n) => e.check(jr(n));
|
|
2871
2871
|
});
|
|
2872
2872
|
function Y(e) {
|
|
2873
2873
|
return Ni(Yr, e);
|
|
@@ -2877,7 +2877,7 @@ const $ = /* @__PURE__ */ m("ZodStringFormat", (e, t) => {
|
|
|
2877
2877
|
}), Qr = /* @__PURE__ */ m("ZodEmail", (e, t) => {
|
|
2878
2878
|
Bo.init(e, t), $.init(e, t);
|
|
2879
2879
|
}), pt = /* @__PURE__ */ m("ZodGUID", (e, t) => {
|
|
2880
|
-
|
|
2880
|
+
Mo.init(e, t), $.init(e, t);
|
|
2881
2881
|
}), de = /* @__PURE__ */ m("ZodUUID", (e, t) => {
|
|
2882
2882
|
Vo.init(e, t), $.init(e, t);
|
|
2883
2883
|
}), Xr = /* @__PURE__ */ m("ZodURL", (e, t) => {
|
|
@@ -2917,7 +2917,7 @@ const $ = /* @__PURE__ */ m("ZodStringFormat", (e, t) => {
|
|
|
2917
2917
|
const n = e._zod.bag;
|
|
2918
2918
|
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 ?? 0.5), e.isFinite = !0, e.format = n.format ?? null;
|
|
2919
2919
|
});
|
|
2920
|
-
function
|
|
2920
|
+
function P(e) {
|
|
2921
2921
|
return lr(Ht, e);
|
|
2922
2922
|
}
|
|
2923
2923
|
const _s = /* @__PURE__ */ m("ZodNumberFormat", (e, t) => {
|
|
@@ -2951,7 +2951,7 @@ function Es(e, t) {
|
|
|
2951
2951
|
return Tr(ws, e, t);
|
|
2952
2952
|
}
|
|
2953
2953
|
const ks = /* @__PURE__ */ m("ZodObject", (e, t) => {
|
|
2954
|
-
yi.init(e, t), I.init(e, t), C(e, "shape", () => t.shape), e.keyof = () => $s(Object.keys(e._zod.def.shape)), e.catchall = (n) => e.clone({ ...e._zod.def, catchall: n }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: ft() }), e.loose = () => e.clone({ ...e._zod.def, catchall: ft() }), e.strict = () => e.clone({ ...e._zod.def, catchall: bs() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (n) => Nn(e, n), e.safeExtend = (n) => Dn(e, n), e.merge = (n) =>
|
|
2954
|
+
yi.init(e, t), I.init(e, t), C(e, "shape", () => t.shape), e.keyof = () => $s(Object.keys(e._zod.def.shape)), e.catchall = (n) => e.clone({ ...e._zod.def, catchall: n }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: ft() }), e.loose = () => e.clone({ ...e._zod.def, catchall: ft() }), e.strict = () => e.clone({ ...e._zod.def, catchall: bs() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (n) => Nn(e, n), e.safeExtend = (n) => Dn(e, n), e.merge = (n) => Un(e, n), e.pick = (n) => Rn(e, n), e.omit = (n) => jn(e, n), e.partial = (...n) => Fn(Jt, e, n[0]), e.required = (...n) => Mn(Yt, e, n[0]);
|
|
2955
2955
|
});
|
|
2956
2956
|
function S(e, t) {
|
|
2957
2957
|
const n = {
|
|
@@ -3062,7 +3062,7 @@ function R(e, t) {
|
|
|
3062
3062
|
...b(t)
|
|
3063
3063
|
});
|
|
3064
3064
|
}
|
|
3065
|
-
const
|
|
3065
|
+
const Ps = /* @__PURE__ */ m("ZodTransform", (e, t) => {
|
|
3066
3066
|
Ti.init(e, t), I.init(e, t), e._zod.parse = (n, o) => {
|
|
3067
3067
|
if (o.direction === "backward")
|
|
3068
3068
|
throw new It(e.constructor.name);
|
|
@@ -3078,8 +3078,8 @@ const Zs = /* @__PURE__ */ m("ZodTransform", (e, t) => {
|
|
|
3078
3078
|
return r instanceof Promise ? r.then((a) => (n.value = a, n)) : (n.value = r, n);
|
|
3079
3079
|
};
|
|
3080
3080
|
});
|
|
3081
|
-
function
|
|
3082
|
-
return new
|
|
3081
|
+
function Zs(e) {
|
|
3082
|
+
return new Ps({
|
|
3083
3083
|
type: "transform",
|
|
3084
3084
|
transform: e
|
|
3085
3085
|
});
|
|
@@ -3110,7 +3110,7 @@ function Rs(e, t) {
|
|
|
3110
3110
|
type: "default",
|
|
3111
3111
|
innerType: e,
|
|
3112
3112
|
get defaultValue() {
|
|
3113
|
-
return typeof t == "function" ? t() :
|
|
3113
|
+
return typeof t == "function" ? t() : Pt(t);
|
|
3114
3114
|
}
|
|
3115
3115
|
});
|
|
3116
3116
|
}
|
|
@@ -3122,7 +3122,7 @@ function Ns(e, t) {
|
|
|
3122
3122
|
type: "prefault",
|
|
3123
3123
|
innerType: e,
|
|
3124
3124
|
get defaultValue() {
|
|
3125
|
-
return typeof t == "function" ? t() :
|
|
3125
|
+
return typeof t == "function" ? t() : Pt(t);
|
|
3126
3126
|
}
|
|
3127
3127
|
});
|
|
3128
3128
|
}
|
|
@@ -3136,21 +3136,21 @@ function Ds(e, t) {
|
|
|
3136
3136
|
...b(t)
|
|
3137
3137
|
});
|
|
3138
3138
|
}
|
|
3139
|
-
const
|
|
3140
|
-
|
|
3139
|
+
const Us = /* @__PURE__ */ m("ZodCatch", (e, t) => {
|
|
3140
|
+
Pi.init(e, t), I.init(e, t), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
|
|
3141
3141
|
});
|
|
3142
|
-
function
|
|
3143
|
-
return new
|
|
3142
|
+
function Fs(e, t) {
|
|
3143
|
+
return new Us({
|
|
3144
3144
|
type: "catch",
|
|
3145
3145
|
innerType: e,
|
|
3146
3146
|
catchValue: typeof t == "function" ? t : () => t
|
|
3147
3147
|
});
|
|
3148
3148
|
}
|
|
3149
|
-
const
|
|
3150
|
-
|
|
3149
|
+
const Ms = /* @__PURE__ */ m("ZodPipe", (e, t) => {
|
|
3150
|
+
Zi.init(e, t), I.init(e, t), e.in = t.in, e.out = t.out;
|
|
3151
3151
|
});
|
|
3152
3152
|
function vt(e, t) {
|
|
3153
|
-
return new
|
|
3153
|
+
return new Ms({
|
|
3154
3154
|
type: "pipe",
|
|
3155
3155
|
in: e,
|
|
3156
3156
|
out: t
|
|
@@ -3176,13 +3176,13 @@ function qs(e) {
|
|
|
3176
3176
|
return zr(e);
|
|
3177
3177
|
}
|
|
3178
3178
|
const be = S({
|
|
3179
|
-
t:
|
|
3180
|
-
rate:
|
|
3179
|
+
t: P().gte(0),
|
|
3180
|
+
rate: P().gte(0)
|
|
3181
3181
|
}), Q = S({
|
|
3182
|
-
opacity:
|
|
3183
|
-
zIndex:
|
|
3182
|
+
opacity: P().gte(0).lte(1),
|
|
3183
|
+
zIndex: P()
|
|
3184
3184
|
}), X = S({
|
|
3185
|
-
volume:
|
|
3185
|
+
volume: P().gte(0).lte(1)
|
|
3186
3186
|
}), Ks = S({
|
|
3187
3187
|
type: R("image"),
|
|
3188
3188
|
file: Y(),
|
|
@@ -3196,15 +3196,15 @@ const be = S({
|
|
|
3196
3196
|
file: Y(),
|
|
3197
3197
|
audioOutput: Y(),
|
|
3198
3198
|
fit: G([R("contain"), R("cover"), R("none")])
|
|
3199
|
-
}), Ve = L([
|
|
3200
|
-
|
|
3199
|
+
}), Ve = L([P(), vs()]), Ys = L([
|
|
3200
|
+
P(),
|
|
3201
3201
|
S({
|
|
3202
3202
|
set: S({
|
|
3203
3203
|
...Q.shape
|
|
3204
3204
|
}).partial()
|
|
3205
3205
|
}).partial()
|
|
3206
3206
|
]), Qs = L([
|
|
3207
|
-
|
|
3207
|
+
P(),
|
|
3208
3208
|
S({
|
|
3209
3209
|
set: S({
|
|
3210
3210
|
...Q.shape
|
|
@@ -3214,7 +3214,7 @@ const be = S({
|
|
|
3214
3214
|
}).partial()
|
|
3215
3215
|
}).partial()
|
|
3216
3216
|
]), Xs = L([
|
|
3217
|
-
|
|
3217
|
+
P(),
|
|
3218
3218
|
S({
|
|
3219
3219
|
set: S({
|
|
3220
3220
|
...be.shape,
|
|
@@ -3222,7 +3222,7 @@ const be = S({
|
|
|
3222
3222
|
}).partial()
|
|
3223
3223
|
}).partial()
|
|
3224
3224
|
]), ea = L([
|
|
3225
|
-
|
|
3225
|
+
P(),
|
|
3226
3226
|
S({
|
|
3227
3227
|
set: S({
|
|
3228
3228
|
...be.shape,
|
|
@@ -3233,7 +3233,7 @@ const be = S({
|
|
|
3233
3233
|
}).partial()
|
|
3234
3234
|
}).partial()
|
|
3235
3235
|
]), ta = L([
|
|
3236
|
-
|
|
3236
|
+
P(),
|
|
3237
3237
|
S({
|
|
3238
3238
|
set: S({
|
|
3239
3239
|
...be.shape,
|
|
@@ -3242,7 +3242,7 @@ const be = S({
|
|
|
3242
3242
|
}).partial()
|
|
3243
3243
|
}).partial()
|
|
3244
3244
|
]), na = L([
|
|
3245
|
-
|
|
3245
|
+
P(),
|
|
3246
3246
|
S({
|
|
3247
3247
|
set: S({
|
|
3248
3248
|
...be.shape,
|
|
@@ -3276,52 +3276,426 @@ const be = S({
|
|
|
3276
3276
|
volume: 1,
|
|
3277
3277
|
opacity: 1,
|
|
3278
3278
|
zIndex: 0
|
|
3279
|
-
},
|
|
3279
|
+
}, $a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3280
3280
|
__proto__: null,
|
|
3281
3281
|
MediaSurfaceStateSchema: sa,
|
|
3282
3282
|
defaultAudioOptions: we,
|
|
3283
3283
|
defaultImageOptions: me,
|
|
3284
3284
|
defaultVideoOptions: ie
|
|
3285
3285
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
n
|
|
3296
|
-
|
|
3297
|
-
return
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3286
|
+
function Ee(e, t) {
|
|
3287
|
+
switch (e.type) {
|
|
3288
|
+
case "image": {
|
|
3289
|
+
if (e.keyframes[0][0] > t)
|
|
3290
|
+
return;
|
|
3291
|
+
const o = e.keyframes.filter((a) => a[1] !== null), r = Te(o, t);
|
|
3292
|
+
return { ...me, ...r };
|
|
3293
|
+
}
|
|
3294
|
+
case "audio": {
|
|
3295
|
+
const n = e.keyframes.filter((a) => a[1] !== null), o = gt(n, t);
|
|
3296
|
+
if (!o)
|
|
3297
|
+
return;
|
|
3298
|
+
const r = Te(n, t);
|
|
3299
|
+
return { ...we, ...r, ...o };
|
|
3300
|
+
}
|
|
3301
|
+
case "video": {
|
|
3302
|
+
const n = e.keyframes.filter((a) => a[1] !== null), o = gt(n, t);
|
|
3303
|
+
if (!o)
|
|
3304
|
+
return;
|
|
3305
|
+
const r = Te(n, t);
|
|
3306
|
+
return { ...ie, ...r, ...o };
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
function Te(e, t) {
|
|
3311
|
+
const n = {};
|
|
3312
|
+
for (const [r, a] of e)
|
|
3313
|
+
r <= t ? (Object.entries(a.lerp ?? {}).forEach(([c, l]) => {
|
|
3314
|
+
n[c] ??= {}, n[c].before = [r, l];
|
|
3315
|
+
}), Object.entries(a.set ?? {}).forEach(([c, l]) => {
|
|
3316
|
+
n[c] ??= {}, n[c].before = [r, l];
|
|
3317
|
+
})) : Object.entries(a.lerp ?? {}).forEach(([c, l]) => {
|
|
3318
|
+
n[c] ??= {}, n[c].after === void 0 && (n[c].after = [r, l]);
|
|
3319
|
+
});
|
|
3320
|
+
const o = {};
|
|
3321
|
+
return Object.entries(n).forEach(
|
|
3322
|
+
([r, { before: a, after: c }]) => {
|
|
3323
|
+
if (c === void 0 && a) {
|
|
3324
|
+
o[r] = a[1];
|
|
3325
|
+
return;
|
|
3326
|
+
}
|
|
3327
|
+
if (a && c && a[0] === c[0]) {
|
|
3328
|
+
o[r] = c[1];
|
|
3329
|
+
return;
|
|
3330
|
+
}
|
|
3331
|
+
if (a && typeof a[1] == "number" && c && typeof c[1] == "number") {
|
|
3332
|
+
o[r] = a[1] + (t - a[0]) * (c[1] - a[1]) / (c[0] - a[0]);
|
|
3333
|
+
return;
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
), o;
|
|
3337
|
+
}
|
|
3338
|
+
function gt(e, t) {
|
|
3339
|
+
const n = e[0];
|
|
3340
|
+
if (!n || n[0] > t)
|
|
3341
|
+
return;
|
|
3342
|
+
let o = 0, { t: r, rate: a } = we;
|
|
3343
|
+
for (const [f, y] of e) {
|
|
3344
|
+
if (f > t) break;
|
|
3345
|
+
const { set: g } = y;
|
|
3346
|
+
if (!g) continue;
|
|
3347
|
+
const { t: i, rate: s } = g;
|
|
3348
|
+
if (i !== void 0) {
|
|
3349
|
+
o = f, r = i, s !== void 0 && (a = s);
|
|
3350
|
+
continue;
|
|
3351
|
+
}
|
|
3352
|
+
if (s !== void 0) {
|
|
3353
|
+
const p = (f - o) * a;
|
|
3354
|
+
o = f, r += p, a = s;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
const l = (t - o) * a, d = r + l;
|
|
3358
|
+
return {
|
|
3359
|
+
rate: a,
|
|
3360
|
+
t: d
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
const aa = 1e3;
|
|
3364
|
+
class Be {
|
|
3365
|
+
constructor(t, n, o, r) {
|
|
3366
|
+
this.surfaceElement = t, this.clipElement = n, this.constructAssetURL = r, this._state = o, setTimeout(this.loop);
|
|
3367
|
+
}
|
|
3368
|
+
/**
|
|
3369
|
+
* This is the delay to be used in the update loop.
|
|
3370
|
+
* It is intended to be dynamic for each loop.
|
|
3371
|
+
*/
|
|
3372
|
+
delay = aa;
|
|
3373
|
+
isConnected(t) {
|
|
3374
|
+
return !(!this.surfaceElement || !this.clipElement || !this.surfaceElement.contains(this.clipElement) || t && !this.clipElement.contains(t));
|
|
3375
|
+
}
|
|
3376
|
+
_state;
|
|
3377
|
+
setState(t) {
|
|
3378
|
+
if (this._state.file !== t.file)
|
|
3379
|
+
throw new Error(`Cannot change from ${this._state.file} to ${t.file}. Create a new clip instead.`);
|
|
3380
|
+
this._state = t, clearTimeout(this.timeout), this.loop();
|
|
3381
|
+
}
|
|
3382
|
+
timeout;
|
|
3383
|
+
loop = async () => {
|
|
3384
|
+
this.isConnected() ? (this.update(), isFinite(this.delay) && (this.timeout = setTimeout(this.loop, this.delay))) : this.destroy();
|
|
3385
|
+
};
|
|
3386
|
+
}
|
|
3387
|
+
class ua extends Be {
|
|
3388
|
+
imageElement;
|
|
3389
|
+
constructor(t, n, o, r) {
|
|
3390
|
+
super(t, n, o, r), this.clipElement = n;
|
|
3391
|
+
}
|
|
3392
|
+
updateImageElement() {
|
|
3393
|
+
this.imageElement = document.createElement("img"), this.clipElement.replaceChildren(this.imageElement), this.imageElement.style.position = "absolute", this.imageElement.style.height = "100%", this.imageElement.style.widows = "100%";
|
|
3394
|
+
}
|
|
3395
|
+
update() {
|
|
3396
|
+
const t = Ee(this._state, Date.now());
|
|
3397
|
+
if (t ? (!this.imageElement || !this.isConnected(this.imageElement)) && this.updateImageElement() : (this.imageElement?.remove(), this.imageElement = void 0), !this.imageElement || !t) return;
|
|
3398
|
+
const n = this.constructAssetURL(this._state.file);
|
|
3399
|
+
this.imageElement.src.includes(n) || (this.imageElement.src = n), this.imageElement.style.objectFit !== this._state.fit && (this.imageElement.style.objectFit = this._state.fit), parseFloat(this.imageElement.style.opacity) !== t.opacity && (this.imageElement.style.opacity = String(t.opacity ?? me.opacity));
|
|
3400
|
+
const o = Math.round(t.zIndex ?? me.zIndex);
|
|
3401
|
+
parseInt(this.imageElement.style.zIndex) !== o && (this.imageElement.style.zIndex = String(o));
|
|
3402
|
+
const { opacity: r } = t;
|
|
3403
|
+
typeof r == "string" && r !== this.imageElement.style.opacity && (this.imageElement.style.opacity = r);
|
|
3404
|
+
}
|
|
3405
|
+
destroy() {
|
|
3406
|
+
this.imageElement?.remove();
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
const ca = 1e3, Se = 10, Qt = 1e3, la = 200, da = 0.15, yt = 0.7, pa = 0.3;
|
|
3410
|
+
function ha(e) {
|
|
3411
|
+
return -Math.sign(e) * Math.pow(Math.abs(e) / Qt, pa) * da;
|
|
3412
|
+
}
|
|
3413
|
+
const fa = 5;
|
|
3414
|
+
function _a(e, t, n) {
|
|
3415
|
+
const o = Ee(e, t);
|
|
3416
|
+
if (!o) return !1;
|
|
3417
|
+
const { t: r, rate: a } = o;
|
|
3418
|
+
if (r === void 0 || a === void 0) return !1;
|
|
3419
|
+
const c = e.keyframes.filter(([f, y]) => f > t && (y?.set?.t !== void 0 || y?.set?.rate !== void 0))[0];
|
|
3420
|
+
if (c?.[1]?.set?.t !== 0) return !1;
|
|
3421
|
+
const l = (n - r) / a, d = c[0] - t;
|
|
3422
|
+
return Math.abs(l - d) <= fa;
|
|
3423
|
+
}
|
|
3424
|
+
class ma extends Be {
|
|
3425
|
+
constructor(t, n, o, r, a) {
|
|
3426
|
+
super(t, n, o, r), this.mediaPreloader = a, this.clipElement = n;
|
|
3427
|
+
}
|
|
3428
|
+
videoElement;
|
|
3429
|
+
// We seek to another part of the video and do nothing until we get there
|
|
3430
|
+
isSeeking = !1;
|
|
3431
|
+
// We change playbackRate to intercept the server time of the video and don't change course until we intercept
|
|
3432
|
+
timeToIntercept = void 0;
|
|
3433
|
+
updateVideoElement() {
|
|
3434
|
+
const t = this.mediaPreloader.getElement(this._state.file, "video");
|
|
3435
|
+
this.videoElement = t, this.clipElement.replaceChildren(this.videoElement), this.videoElement.style.position = "absolute", this.videoElement.style.width = "100%", this.videoElement.style.height = "100%";
|
|
3436
|
+
}
|
|
3437
|
+
get videoDuration() {
|
|
3438
|
+
if (this.videoElement && !(this.videoElement.readyState < HTMLMediaElement.HAVE_METADATA))
|
|
3439
|
+
return this.videoElement.duration * 1e3;
|
|
3440
|
+
}
|
|
3441
|
+
/**
|
|
3442
|
+
* Helper function to seek to a specified time.
|
|
3443
|
+
* Works with the update loop to poll until seeked event has fired.
|
|
3444
|
+
*/
|
|
3445
|
+
seekTo(t) {
|
|
3446
|
+
this.videoElement && (this.videoElement.addEventListener(
|
|
3447
|
+
"seeked",
|
|
3448
|
+
() => {
|
|
3449
|
+
console.debug("seeked"), this.isSeeking = !1;
|
|
3450
|
+
},
|
|
3451
|
+
{ once: !0, passive: !0 }
|
|
3452
|
+
), this.videoElement.currentTime = t / 1e3);
|
|
3453
|
+
}
|
|
3454
|
+
update() {
|
|
3455
|
+
if (this.isSeeking) return;
|
|
3456
|
+
const t = Date.now(), n = Ee(this._state, t);
|
|
3457
|
+
if (n ? (!this.videoElement || !this.isConnected(this.videoElement)) && this.updateVideoElement() : (this.videoElement?.remove(), this.videoElement = void 0), !n || !this.videoElement) return;
|
|
3458
|
+
const { t: o, rate: r, volume: a } = { ...ie, ...n }, c = this.constructAssetURL(this._state.file);
|
|
3459
|
+
this.videoElement.src.includes(c) || this.updateVideoElement(), this.videoElement.style.objectFit !== this._state.fit && (this.videoElement.style.objectFit = this._state.fit), parseFloat(this.videoElement.style.opacity) !== n.opacity && (this.videoElement.style.opacity = String(n.opacity ?? ie.opacity));
|
|
3460
|
+
const l = Math.round(n.zIndex ?? ie.zIndex);
|
|
3461
|
+
parseInt(this.videoElement.style.zIndex) !== l && (this.videoElement.style.zIndex = String(l)), this.videoElement.volume !== a && (this.videoElement.volume = a);
|
|
3462
|
+
const d = this.videoDuration;
|
|
3463
|
+
if (d !== void 0) {
|
|
3464
|
+
if (_a(this._state, t, d))
|
|
3465
|
+
this.videoElement.loop || (console.debug("starting loop"), this.videoElement.loop = !0);
|
|
3466
|
+
else if (this.videoElement.loop && (console.debug("stopping loop"), this.videoElement.loop = !1), o > d) {
|
|
3467
|
+
console.debug("ended"), this.delay = 1 / 0;
|
|
3468
|
+
return;
|
|
3469
|
+
}
|
|
3470
|
+
}
|
|
3471
|
+
this.videoElement.paused && r > 0 && (d === void 0 || d > o) && this.videoElement.play().catch(() => {
|
|
3472
|
+
});
|
|
3473
|
+
const y = this.videoElement.currentTime * 1e3 - o, g = Math.abs(y);
|
|
3474
|
+
if (this.timeToIntercept !== void 0)
|
|
3475
|
+
if (g <= Se)
|
|
3476
|
+
console.log("intercepted", `${y.toFixed(0)}ms`), this.timeToIntercept = void 0;
|
|
3477
|
+
else {
|
|
3478
|
+
const i = y / (r - this.videoElement.playbackRate);
|
|
3479
|
+
i < this.timeToIntercept && i > 0 ? (console.debug(`intercepting ${i.toFixed(0)}ms`, `${y.toFixed(0)}ms`), this.timeToIntercept = i) : (console.debug("missed intercept", y, this.timeToIntercept, i), this.timeToIntercept = void 0);
|
|
3480
|
+
}
|
|
3481
|
+
switch (!0) {
|
|
3482
|
+
case g <= Se: {
|
|
3483
|
+
console.debug(`${r}x`, y.toFixed(0)), this.timeToIntercept = void 0, this.videoElement.playbackRate !== r && (this.videoElement.playbackRate = r), this.delay = ca;
|
|
3484
|
+
break;
|
|
3485
|
+
}
|
|
3486
|
+
case this.timeToIntercept !== void 0:
|
|
3487
|
+
this.delay = this.timeToIntercept * yt;
|
|
3488
|
+
break;
|
|
3489
|
+
case (r > 0 && g > Se && g <= Qt && this.timeToIntercept === void 0): {
|
|
3490
|
+
const i = ha(y), s = Math.max(0, r + i);
|
|
3491
|
+
this.timeToIntercept = y / (r - s), console.debug(`${s.toFixed(2)}x`, `${y.toFixed(0)}ms`), this.videoElement.playbackRate !== s && (this.videoElement.playbackRate = s), this.delay = this.timeToIntercept * yt;
|
|
3492
|
+
break;
|
|
3493
|
+
}
|
|
3494
|
+
default: {
|
|
3495
|
+
this.videoElement.playbackRate !== r && (this.videoElement.playbackRate = r), console.debug("seeking"), this.delay = 10, this.seekTo(o + r * la);
|
|
3496
|
+
break;
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
}
|
|
3500
|
+
destroy() {
|
|
3501
|
+
this.videoElement && (this.mediaPreloader.releaseElement(this.videoElement), this.videoElement.remove());
|
|
3502
|
+
}
|
|
3503
|
+
}
|
|
3504
|
+
const va = 1e3, bt = 10, Xt = 1e3, ga = 200, ya = 0.2, ba = 0.5;
|
|
3505
|
+
function wa(e) {
|
|
3506
|
+
return Math.sign(e) * Math.pow(Math.abs(e) / Xt, ba) * ya;
|
|
3507
|
+
}
|
|
3508
|
+
class Ea extends Be {
|
|
3509
|
+
constructor(t, n, o, r, a) {
|
|
3510
|
+
super(t, n, o, r), this.mediaPreloader = a, this.clipElement = n;
|
|
3511
|
+
}
|
|
3512
|
+
audioElement;
|
|
3513
|
+
isSeeking = !1;
|
|
3514
|
+
updateAudioElement() {
|
|
3515
|
+
const t = this.mediaPreloader.getElement(this._state.file, "audio");
|
|
3516
|
+
this.audioElement = t, this.clipElement.replaceChildren(this.audioElement);
|
|
3517
|
+
}
|
|
3518
|
+
/**
|
|
3519
|
+
* Helper function to seek to a specified time.
|
|
3520
|
+
* Works with the update loop to poll until seeked event has fired.
|
|
3521
|
+
*/
|
|
3522
|
+
seekTo(t) {
|
|
3523
|
+
this.audioElement && (this.audioElement.addEventListener(
|
|
3524
|
+
"seeked",
|
|
3525
|
+
() => {
|
|
3526
|
+
this.isSeeking = !1;
|
|
3527
|
+
},
|
|
3528
|
+
{ once: !0, passive: !0 }
|
|
3529
|
+
), this.audioElement.currentTime = t / 1e3);
|
|
3530
|
+
}
|
|
3531
|
+
update() {
|
|
3532
|
+
if (this.isSeeking) return;
|
|
3533
|
+
this.delay = va;
|
|
3534
|
+
const t = Ee(this._state, Date.now());
|
|
3535
|
+
if (t ? (!this.audioElement || !this.isConnected(this.audioElement)) && this.updateAudioElement() : this.destroy(), !t || !this.audioElement) return;
|
|
3536
|
+
const { t: n, rate: o, volume: r } = { ...we, ...t }, a = this.constructAssetURL(this._state.file);
|
|
3537
|
+
this.audioElement.src.includes(a) || this.updateAudioElement(), this.audioElement.volume !== r && (this.audioElement.volume = r), this.audioElement.paused && o > 0 && this.audioElement.play().catch(() => {
|
|
3538
|
+
});
|
|
3539
|
+
const l = this.audioElement.currentTime * 1e3 - n, d = Math.abs(l);
|
|
3540
|
+
switch (this.delay = 100, !0) {
|
|
3541
|
+
case d <= bt:
|
|
3542
|
+
this.audioElement.playbackRate !== o && (this.audioElement.playbackRate = o);
|
|
3543
|
+
break;
|
|
3544
|
+
case (o > 0 && d > bt && d <= Xt): {
|
|
3545
|
+
const f = wa(l), y = Math.max(0, o - f);
|
|
3546
|
+
this.audioElement.playbackRate !== y && (this.audioElement.playbackRate = y);
|
|
3547
|
+
break;
|
|
3548
|
+
}
|
|
3549
|
+
default: {
|
|
3550
|
+
this.audioElement.playbackRate !== o && (this.audioElement.playbackRate = o), this.delay = 10, this.seekTo(n + o * (ga / 1e3));
|
|
3551
|
+
break;
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
destroy() {
|
|
3556
|
+
this.audioElement && this.audioElement.remove();
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
class ka {
|
|
3560
|
+
_state;
|
|
3561
|
+
_elements = {};
|
|
3562
|
+
_constructAssetURL;
|
|
3563
|
+
constructor(t, n = {}) {
|
|
3564
|
+
this._constructAssetURL = t, this._state = n;
|
|
3565
|
+
}
|
|
3566
|
+
get state() {
|
|
3567
|
+
return { ...this._state };
|
|
3568
|
+
}
|
|
3569
|
+
setState(t) {
|
|
3570
|
+
this._state = t, this.update();
|
|
3571
|
+
}
|
|
3572
|
+
update() {
|
|
3573
|
+
for (const [t, n] of Object.entries(this._elements))
|
|
3574
|
+
t in this._state || (n.element.src = "", delete this._elements[t]), n.inUse = n.element.isConnected;
|
|
3575
|
+
for (const [t, n] of Object.entries(this._state)) {
|
|
3576
|
+
if (t in this._elements)
|
|
3577
|
+
continue;
|
|
3578
|
+
let o;
|
|
3579
|
+
switch (n.preload === !0 ? o = "auto" : n.preload === !1 ? o = "none" : o = n.preload, n.type) {
|
|
3580
|
+
case "audio": {
|
|
3581
|
+
const r = document.createElement("audio");
|
|
3582
|
+
r.src = this._constructAssetURL(t), r.preload = o, this._elements[t] = { element: r, inUse: !1, type: "audio" };
|
|
3583
|
+
break;
|
|
3308
3584
|
}
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
for (var u = 0; u < s._howls.length; u++) if (!s._howls[u]._webAudio) for (var d = s._howls[u]._getSoundIds(), f = 0; f < d.length; f++) {
|
|
3314
|
-
var v = s._howls[u]._soundById(d[f]);
|
|
3315
|
-
v && v._node && (v._node.muted = !!i || v._muted);
|
|
3585
|
+
case "video": {
|
|
3586
|
+
const r = document.createElement("video");
|
|
3587
|
+
r.src = this._constructAssetURL(t), r.preload = o, this._elements[t] = { element: r, inUse: !1, type: "video" };
|
|
3588
|
+
break;
|
|
3316
3589
|
}
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
getElement(t, n) {
|
|
3594
|
+
const o = this._elements[t];
|
|
3595
|
+
if (o && o.inUse === !1)
|
|
3596
|
+
return o.inUse = !0, o.element;
|
|
3597
|
+
{
|
|
3598
|
+
const r = document.createElement(n);
|
|
3599
|
+
return r.src = this._constructAssetURL(t), this._elements[t] = { element: r, type: n, inUse: !0 }, r;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
releaseElement(t) {
|
|
3603
|
+
if (typeof t == "string") {
|
|
3604
|
+
const n = this._elements[t];
|
|
3605
|
+
n && (n.inUse = !1);
|
|
3606
|
+
} else
|
|
3607
|
+
Object.entries(this._elements).forEach(([n, o]) => {
|
|
3608
|
+
o.element === t && delete this._elements[n];
|
|
3609
|
+
});
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
const Ca = "data-clip-id";
|
|
3613
|
+
class Oa {
|
|
3614
|
+
constructor(t, n = {}, o = new ka(t)) {
|
|
3615
|
+
this.constructAssetUrl = t, 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 = n || {}, this.update();
|
|
3616
|
+
}
|
|
3617
|
+
_state = {};
|
|
3618
|
+
setState(t) {
|
|
3619
|
+
this._state = t, this.update();
|
|
3620
|
+
}
|
|
3621
|
+
_element;
|
|
3622
|
+
get element() {
|
|
3623
|
+
return this._element;
|
|
3624
|
+
}
|
|
3625
|
+
resources = {};
|
|
3626
|
+
update() {
|
|
3627
|
+
Object.entries(this.resources).forEach(([n, { element: o, manager: r }]) => {
|
|
3628
|
+
n in this._state || (delete this.resources[n], o.remove(), r?.destroy());
|
|
3629
|
+
});
|
|
3630
|
+
const t = Object.keys(this._state).toSorted().map((n) => {
|
|
3631
|
+
const o = this.resources[n];
|
|
3632
|
+
if (o)
|
|
3633
|
+
return o.element;
|
|
3634
|
+
{
|
|
3635
|
+
const r = document.createElement("div");
|
|
3636
|
+
return r.setAttribute(Ca, n), this.resources[n] = { element: r }, r;
|
|
3637
|
+
}
|
|
3638
|
+
});
|
|
3639
|
+
this._element.replaceChildren(...t), Object.keys(this._state).toSorted().forEach((n) => {
|
|
3640
|
+
const o = this._state[n], r = this.resources[n];
|
|
3641
|
+
if (!r)
|
|
3642
|
+
throw new Error("Failed to create resource");
|
|
3643
|
+
if (r.manager)
|
|
3644
|
+
r.manager.setState(o);
|
|
3645
|
+
else
|
|
3646
|
+
switch (o.type) {
|
|
3647
|
+
case "image":
|
|
3648
|
+
r.manager = new ua(this._element, r.element, o, this.constructAssetUrl);
|
|
3649
|
+
break;
|
|
3650
|
+
case "audio":
|
|
3651
|
+
r.manager = new Ea(this._element, r.element, o, this.constructAssetUrl, this.mediaPreloader);
|
|
3652
|
+
break;
|
|
3653
|
+
case "video":
|
|
3654
|
+
r.manager = new ma(this._element, r.element, o, this.constructAssetUrl, this.mediaPreloader);
|
|
3655
|
+
break;
|
|
3656
|
+
}
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
var ze = {}, wt;
|
|
3661
|
+
function Aa() {
|
|
3662
|
+
return wt || (wt = 1, function(e) {
|
|
3663
|
+
var t = {};
|
|
3664
|
+
/*! howler.js v2.2.1 | (c) 2013-2020, James Simpson of GoldFire Studios | MIT License | howlerjs.com */
|
|
3665
|
+
(function() {
|
|
3666
|
+
var n = function() {
|
|
3667
|
+
this.init();
|
|
3668
|
+
};
|
|
3669
|
+
n.prototype = { init: function() {
|
|
3670
|
+
var i = this || o;
|
|
3671
|
+
return i._counter = 1e3, i._html5AudioPool = [], i.html5PoolSize = 10, i._codecs = {}, i._howls = [], i._muted = !1, i._volume = 1, i._canPlayEvent = "canplaythrough", i._navigator = typeof window < "u" && window.navigator ? window.navigator : null, i.masterGain = null, i.noAudio = !1, i.usingWebAudio = !0, i.autoSuspend = !0, i.ctx = null, i.autoUnlock = !0, i._setup(), i;
|
|
3672
|
+
}, volume: function(i) {
|
|
3673
|
+
var s = this || o;
|
|
3674
|
+
if (i = parseFloat(i), s.ctx || g(), i !== void 0 && i >= 0 && i <= 1) {
|
|
3675
|
+
if (s._volume = i, s._muted) return s;
|
|
3676
|
+
s.usingWebAudio && s.masterGain.gain.setValueAtTime(i, o.ctx.currentTime);
|
|
3677
|
+
for (var u = 0; u < s._howls.length; u++) if (!s._howls[u]._webAudio) for (var p = s._howls[u]._getSoundIds(), h = 0; h < p.length; h++) {
|
|
3678
|
+
var v = s._howls[u]._soundById(p[h]);
|
|
3679
|
+
v && v._node && (v._node.volume = v._volume * i);
|
|
3680
|
+
}
|
|
3681
|
+
return s;
|
|
3682
|
+
}
|
|
3683
|
+
return s._volume;
|
|
3684
|
+
}, mute: function(i) {
|
|
3685
|
+
var s = this || o;
|
|
3686
|
+
s.ctx || g(), s._muted = i, s.usingWebAudio && s.masterGain.gain.setValueAtTime(i ? 0 : s._volume, o.ctx.currentTime);
|
|
3687
|
+
for (var u = 0; u < s._howls.length; u++) if (!s._howls[u]._webAudio) for (var p = s._howls[u]._getSoundIds(), h = 0; h < p.length; h++) {
|
|
3688
|
+
var v = s._howls[u]._soundById(p[h]);
|
|
3689
|
+
v && v._node && (v._node.muted = !!i || v._muted);
|
|
3690
|
+
}
|
|
3691
|
+
return s;
|
|
3692
|
+
}, stop: function() {
|
|
3693
|
+
for (var i = this || o, s = 0; s < i._howls.length; s++) i._howls[s].stop();
|
|
3694
|
+
return i;
|
|
3695
|
+
}, unload: function() {
|
|
3696
|
+
for (var i = this || o, s = i._howls.length - 1; s >= 0; s--) i._howls[s].unload();
|
|
3697
|
+
return i.usingWebAudio && i.ctx && i.ctx.close !== void 0 && (i.ctx.close(), i.ctx = null, g()), i;
|
|
3698
|
+
}, codecs: function(i) {
|
|
3325
3699
|
return (this || o)._codecs[i.replace(/^x-/, "")];
|
|
3326
3700
|
}, _setup: function() {
|
|
3327
3701
|
var i = this || o;
|
|
@@ -3346,22 +3720,22 @@ function aa() {
|
|
|
3346
3720
|
return i;
|
|
3347
3721
|
}
|
|
3348
3722
|
if (!s || typeof s.canPlayType != "function") return i;
|
|
3349
|
-
var u = s.canPlayType("audio/mpeg;").replace(/^no$/, ""),
|
|
3350
|
-
return i._codecs = { mp3: !(
|
|
3723
|
+
var u = s.canPlayType("audio/mpeg;").replace(/^no$/, ""), p = i._navigator && i._navigator.userAgent.match(/OPR\/([0-6].)/g), h = p && parseInt(p[0].split("/")[1], 10) < 33;
|
|
3724
|
+
return i._codecs = { mp3: !(h || !u && !s.canPlayType("audio/mp3;").replace(/^no$/, "")), mpeg: !!u, opus: !!s.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ""), ogg: !!s.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""), oga: !!s.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""), wav: !!(s.canPlayType('audio/wav; codecs="1"') || s.canPlayType("audio/wav")).replace(/^no$/, ""), aac: !!s.canPlayType("audio/aac;").replace(/^no$/, ""), caf: !!s.canPlayType("audio/x-caf;").replace(/^no$/, ""), m4a: !!(s.canPlayType("audio/x-m4a;") || s.canPlayType("audio/m4a;") || s.canPlayType("audio/aac;")).replace(/^no$/, ""), m4b: !!(s.canPlayType("audio/x-m4b;") || s.canPlayType("audio/m4b;") || s.canPlayType("audio/aac;")).replace(/^no$/, ""), mp4: !!(s.canPlayType("audio/x-mp4;") || s.canPlayType("audio/mp4;") || s.canPlayType("audio/aac;")).replace(/^no$/, ""), weba: !!s.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ""), webm: !!s.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, ""), dolby: !!s.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ""), flac: !!(s.canPlayType("audio/x-flac;") || s.canPlayType("audio/flac;")).replace(/^no$/, "") }, i;
|
|
3351
3725
|
}, _unlockAudio: function() {
|
|
3352
3726
|
var i = this || o;
|
|
3353
3727
|
if (!i._audioUnlocked && i.ctx) {
|
|
3354
3728
|
i._audioUnlocked = !1, i.autoUnlock = !1, i._mobileUnloaded || i.ctx.sampleRate === 44100 || (i._mobileUnloaded = !0, i.unload()), i._scratchBuffer = i.ctx.createBuffer(1, 1, 22050);
|
|
3355
3729
|
var s = function(u) {
|
|
3356
3730
|
for (; i._html5AudioPool.length < i.html5PoolSize; ) try {
|
|
3357
|
-
var
|
|
3358
|
-
|
|
3731
|
+
var p = new Audio();
|
|
3732
|
+
p._unlocked = !0, i._releaseHtml5Audio(p);
|
|
3359
3733
|
} catch {
|
|
3360
3734
|
i.noAudio = !0;
|
|
3361
3735
|
break;
|
|
3362
3736
|
}
|
|
3363
|
-
for (var
|
|
3364
|
-
var w = i._howls[
|
|
3737
|
+
for (var h = 0; h < i._howls.length; h++) if (!i._howls[h]._webAudio) for (var v = i._howls[h]._getSoundIds(), _ = 0; _ < v.length; _++) {
|
|
3738
|
+
var w = i._howls[h]._soundById(v[_]);
|
|
3365
3739
|
w && w._node && !w._node._unlocked && (w._node._unlocked = !0, w._node.load());
|
|
3366
3740
|
}
|
|
3367
3741
|
i._autoResume();
|
|
@@ -3392,10 +3766,10 @@ function aa() {
|
|
|
3392
3766
|
return i._suspendTimer && clearTimeout(i._suspendTimer), i._suspendTimer = setTimeout(function() {
|
|
3393
3767
|
if (i.autoSuspend) {
|
|
3394
3768
|
i._suspendTimer = null, i.state = "suspending";
|
|
3395
|
-
var
|
|
3769
|
+
var p = function() {
|
|
3396
3770
|
i.state = "suspended", i._resumeAfterSuspend && (delete i._resumeAfterSuspend, i._autoResume());
|
|
3397
3771
|
};
|
|
3398
|
-
i.ctx.suspend().then(
|
|
3772
|
+
i.ctx.suspend().then(p, p);
|
|
3399
3773
|
}
|
|
3400
3774
|
}, 3e4), i;
|
|
3401
3775
|
}
|
|
@@ -3421,46 +3795,46 @@ function aa() {
|
|
|
3421
3795
|
if (o.noAudio) return void i._emit("loaderror", null, "No audio support.");
|
|
3422
3796
|
typeof i._src == "string" && (i._src = [i._src]);
|
|
3423
3797
|
for (var u = 0; u < i._src.length; u++) {
|
|
3424
|
-
var
|
|
3425
|
-
if (i._format && i._format[u])
|
|
3798
|
+
var p, h;
|
|
3799
|
+
if (i._format && i._format[u]) p = i._format[u];
|
|
3426
3800
|
else {
|
|
3427
|
-
if (typeof (
|
|
3801
|
+
if (typeof (h = i._src[u]) != "string") {
|
|
3428
3802
|
i._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
|
|
3429
3803
|
continue;
|
|
3430
3804
|
}
|
|
3431
|
-
|
|
3805
|
+
p = /^data:audio\/([^;,]+);/i.exec(h), p || (p = /\.([^.]+)$/.exec(h.split("?", 1)[0])), p && (p = p[1].toLowerCase());
|
|
3432
3806
|
}
|
|
3433
|
-
if (
|
|
3807
|
+
if (p || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'), p && o.codecs(p)) {
|
|
3434
3808
|
s = i._src[u];
|
|
3435
3809
|
break;
|
|
3436
3810
|
}
|
|
3437
3811
|
}
|
|
3438
3812
|
return s ? (i._src = s, i._state = "loading", window.location.protocol === "https:" && s.slice(0, 5) === "http:" && (i._html5 = !0, i._webAudio = !1), new a(i), i._webAudio && l(i), i) : void i._emit("loaderror", null, "No codec support for selected audio sources.");
|
|
3439
3813
|
}, play: function(i, s) {
|
|
3440
|
-
var u = this,
|
|
3441
|
-
if (typeof i == "number")
|
|
3814
|
+
var u = this, p = null;
|
|
3815
|
+
if (typeof i == "number") p = i, i = null;
|
|
3442
3816
|
else {
|
|
3443
3817
|
if (typeof i == "string" && u._state === "loaded" && !u._sprite[i]) return null;
|
|
3444
3818
|
if (i === void 0 && (i = "__default", !u._playLock)) {
|
|
3445
|
-
for (var
|
|
3446
|
-
|
|
3819
|
+
for (var h = 0, v = 0; v < u._sounds.length; v++) u._sounds[v]._paused && !u._sounds[v]._ended && (h++, p = u._sounds[v]._id);
|
|
3820
|
+
h === 1 ? i = null : p = null;
|
|
3447
3821
|
}
|
|
3448
3822
|
}
|
|
3449
|
-
var _ =
|
|
3823
|
+
var _ = p ? u._soundById(p) : u._inactiveSound();
|
|
3450
3824
|
if (!_) return null;
|
|
3451
|
-
if (
|
|
3825
|
+
if (p && !i && (i = _._sprite || "__default"), u._state !== "loaded") {
|
|
3452
3826
|
_._sprite = i, _._ended = !1;
|
|
3453
3827
|
var w = _._id;
|
|
3454
3828
|
return u._queue.push({ event: "play", action: function() {
|
|
3455
3829
|
u.play(w);
|
|
3456
3830
|
} }), w;
|
|
3457
3831
|
}
|
|
3458
|
-
if (
|
|
3832
|
+
if (p && !_._paused) return s || u._loadQueue("play"), _._id;
|
|
3459
3833
|
u._webAudio && o._autoResume();
|
|
3460
|
-
var E = Math.max(0, _._seek > 0 ? _._seek : u._sprite[i][0] / 1e3), k = Math.max(0, (u._sprite[i][0] + u._sprite[i][1]) / 1e3 - E), x = 1e3 * k / Math.abs(_._rate),
|
|
3834
|
+
var E = Math.max(0, _._seek > 0 ? _._seek : u._sprite[i][0] / 1e3), k = Math.max(0, (u._sprite[i][0] + u._sprite[i][1]) / 1e3 - E), x = 1e3 * k / Math.abs(_._rate), U = u._sprite[i][0] / 1e3, se = (u._sprite[i][0] + u._sprite[i][1]) / 1e3;
|
|
3461
3835
|
_._sprite = i, _._ended = !1;
|
|
3462
3836
|
var ke = function() {
|
|
3463
|
-
_._paused = !1, _._seek = E, _._start =
|
|
3837
|
+
_._paused = !1, _._seek = E, _._start = U, _._stop = se, _._loop = !(!_._loop && !u._sprite[i][2]);
|
|
3464
3838
|
};
|
|
3465
3839
|
if (E >= se) return void u._ended(_);
|
|
3466
3840
|
var T = _._node;
|
|
@@ -3507,14 +3881,14 @@ function aa() {
|
|
|
3507
3881
|
if (s._state !== "loaded" || s._playLock) return s._queue.push({ event: "pause", action: function() {
|
|
3508
3882
|
s.pause(i);
|
|
3509
3883
|
} }), s;
|
|
3510
|
-
for (var u = s._getSoundIds(i),
|
|
3511
|
-
s._clearTimer(u[
|
|
3512
|
-
var
|
|
3513
|
-
if (
|
|
3514
|
-
if (!
|
|
3515
|
-
|
|
3516
|
-
} else isNaN(
|
|
3517
|
-
arguments[1] || s._emit("pause",
|
|
3884
|
+
for (var u = s._getSoundIds(i), p = 0; p < u.length; p++) {
|
|
3885
|
+
s._clearTimer(u[p]);
|
|
3886
|
+
var h = s._soundById(u[p]);
|
|
3887
|
+
if (h && !h._paused && (h._seek = s.seek(u[p]), h._rateSeek = 0, h._paused = !0, s._stopFade(u[p]), h._node)) if (s._webAudio) {
|
|
3888
|
+
if (!h._node.bufferSource) continue;
|
|
3889
|
+
h._node.bufferSource.stop === void 0 ? h._node.bufferSource.noteOff(0) : h._node.bufferSource.stop(0), s._cleanBuffer(h._node);
|
|
3890
|
+
} else isNaN(h._node.duration) && h._node.duration !== 1 / 0 || h._node.pause();
|
|
3891
|
+
arguments[1] || s._emit("pause", h ? h._id : null);
|
|
3518
3892
|
}
|
|
3519
3893
|
return s;
|
|
3520
3894
|
}, stop: function(i, s) {
|
|
@@ -3522,10 +3896,10 @@ function aa() {
|
|
|
3522
3896
|
if (u._state !== "loaded" || u._playLock) return u._queue.push({ event: "stop", action: function() {
|
|
3523
3897
|
u.stop(i, s);
|
|
3524
3898
|
} }), u;
|
|
3525
|
-
for (var
|
|
3526
|
-
u._clearTimer(
|
|
3527
|
-
var v = u._soundById(
|
|
3528
|
-
v && (v._seek = v._start || 0, v._rateSeek = 0, v._paused = !0, v._ended = !0, u._stopFade(
|
|
3899
|
+
for (var p = u._getSoundIds(i), h = 0; h < p.length; h++) {
|
|
3900
|
+
u._clearTimer(p[h]);
|
|
3901
|
+
var v = u._soundById(p[h]);
|
|
3902
|
+
v && (v._seek = v._start || 0, v._rateSeek = 0, v._paused = !0, v._ended = !0, u._stopFade(p[h]), v._node && (u._webAudio ? v._node.bufferSource && (v._node.bufferSource.stop === void 0 ? v._node.bufferSource.noteOff(0) : v._node.bufferSource.stop(0), u._cleanBuffer(v._node)) : isNaN(v._node.duration) && v._node.duration !== 1 / 0 || (v._node.currentTime = v._start || 0, v._node.pause(), v._node.duration === 1 / 0 && u._clearSound(v._node))), s || u._emit("stop", v._id));
|
|
3529
3903
|
}
|
|
3530
3904
|
return u;
|
|
3531
3905
|
}, mute: function(i, s) {
|
|
@@ -3537,69 +3911,69 @@ function aa() {
|
|
|
3537
3911
|
if (typeof i != "boolean") return u._muted;
|
|
3538
3912
|
u._muted = i;
|
|
3539
3913
|
}
|
|
3540
|
-
for (var
|
|
3541
|
-
var v = u._soundById(
|
|
3914
|
+
for (var p = u._getSoundIds(s), h = 0; h < p.length; h++) {
|
|
3915
|
+
var v = u._soundById(p[h]);
|
|
3542
3916
|
v && (v._muted = i, v._interval && u._stopFade(v._id), u._webAudio && v._node ? v._node.gain.setValueAtTime(i ? 0 : v._volume, o.ctx.currentTime) : v._node && (v._node.muted = !!o._muted || i), u._emit("mute", v._id));
|
|
3543
3917
|
}
|
|
3544
3918
|
return u;
|
|
3545
3919
|
}, volume: function() {
|
|
3546
|
-
var i, s, u = this,
|
|
3547
|
-
if (
|
|
3548
|
-
|
|
3549
|
-
var
|
|
3550
|
-
if (!(i !== void 0 && i >= 0 && i <= 1)) return
|
|
3920
|
+
var i, s, u = this, p = arguments;
|
|
3921
|
+
if (p.length === 0) return u._volume;
|
|
3922
|
+
p.length === 1 || p.length === 2 && p[1] === void 0 ? u._getSoundIds().indexOf(p[0]) >= 0 ? s = parseInt(p[0], 10) : i = parseFloat(p[0]) : p.length >= 2 && (i = parseFloat(p[0]), s = parseInt(p[1], 10));
|
|
3923
|
+
var h;
|
|
3924
|
+
if (!(i !== void 0 && i >= 0 && i <= 1)) return h = s ? u._soundById(s) : u._sounds[0], h ? h._volume : 0;
|
|
3551
3925
|
if (u._state !== "loaded" || u._playLock) return u._queue.push({ event: "volume", action: function() {
|
|
3552
|
-
u.volume.apply(u,
|
|
3926
|
+
u.volume.apply(u, p);
|
|
3553
3927
|
} }), u;
|
|
3554
3928
|
s === void 0 && (u._volume = i), s = u._getSoundIds(s);
|
|
3555
|
-
for (var v = 0; v < s.length; v++) (
|
|
3929
|
+
for (var v = 0; v < s.length; v++) (h = u._soundById(s[v])) && (h._volume = i, p[2] || u._stopFade(s[v]), u._webAudio && h._node && !h._muted ? h._node.gain.setValueAtTime(i, o.ctx.currentTime) : h._node && !h._muted && (h._node.volume = i * o.volume()), u._emit("volume", h._id));
|
|
3556
3930
|
return u;
|
|
3557
|
-
}, fade: function(i, s, u,
|
|
3558
|
-
var
|
|
3559
|
-
if (
|
|
3560
|
-
|
|
3561
|
-
} }),
|
|
3562
|
-
i = Math.min(Math.max(0, parseFloat(i)), 1), s = Math.min(Math.max(0, parseFloat(s)), 1), u = parseFloat(u),
|
|
3563
|
-
for (var v =
|
|
3564
|
-
var w =
|
|
3931
|
+
}, fade: function(i, s, u, p) {
|
|
3932
|
+
var h = this;
|
|
3933
|
+
if (h._state !== "loaded" || h._playLock) return h._queue.push({ event: "fade", action: function() {
|
|
3934
|
+
h.fade(i, s, u, p);
|
|
3935
|
+
} }), h;
|
|
3936
|
+
i = Math.min(Math.max(0, parseFloat(i)), 1), s = Math.min(Math.max(0, parseFloat(s)), 1), u = parseFloat(u), h.volume(i, p);
|
|
3937
|
+
for (var v = h._getSoundIds(p), _ = 0; _ < v.length; _++) {
|
|
3938
|
+
var w = h._soundById(v[_]);
|
|
3565
3939
|
if (w) {
|
|
3566
|
-
if (
|
|
3940
|
+
if (p || h._stopFade(v[_]), h._webAudio && !w._muted) {
|
|
3567
3941
|
var E = o.ctx.currentTime, k = E + u / 1e3;
|
|
3568
3942
|
w._volume = i, w._node.gain.setValueAtTime(i, E), w._node.gain.linearRampToValueAtTime(s, k);
|
|
3569
3943
|
}
|
|
3570
|
-
|
|
3944
|
+
h._startFadeInterval(w, i, s, u, v[_], p === void 0);
|
|
3571
3945
|
}
|
|
3572
3946
|
}
|
|
3573
|
-
return
|
|
3574
|
-
}, _startFadeInterval: function(i, s, u,
|
|
3575
|
-
var _ = this, w = s, E = u - s, k = Math.abs(E / 0.01), x = Math.max(4, k > 0 ?
|
|
3947
|
+
return h;
|
|
3948
|
+
}, _startFadeInterval: function(i, s, u, p, h, v) {
|
|
3949
|
+
var _ = this, w = s, E = u - s, k = Math.abs(E / 0.01), x = Math.max(4, k > 0 ? p / k : p), U = Date.now();
|
|
3576
3950
|
i._fadeTo = u, i._interval = setInterval(function() {
|
|
3577
|
-
var se = (Date.now() -
|
|
3578
|
-
|
|
3951
|
+
var se = (Date.now() - U) / p;
|
|
3952
|
+
U = Date.now(), w += E * se, w = Math.round(100 * w) / 100, w = E < 0 ? Math.max(u, w) : Math.min(u, w), _._webAudio ? i._volume = w : _.volume(w, i._id, !0), v && (_._volume = w), (u < s && w <= u || u > s && w >= u) && (clearInterval(i._interval), i._interval = null, i._fadeTo = null, _.volume(u, i._id), _._emit("fade", i._id));
|
|
3579
3953
|
}, x);
|
|
3580
3954
|
}, _stopFade: function(i) {
|
|
3581
3955
|
var s = this, u = s._soundById(i);
|
|
3582
3956
|
return u && u._interval && (s._webAudio && u._node.gain.cancelScheduledValues(o.ctx.currentTime), clearInterval(u._interval), u._interval = null, s.volume(u._fadeTo, i), u._fadeTo = null, s._emit("fade", i)), s;
|
|
3583
3957
|
}, loop: function() {
|
|
3584
|
-
var i, s, u,
|
|
3585
|
-
if (
|
|
3586
|
-
if (
|
|
3587
|
-
if (typeof
|
|
3588
|
-
i =
|
|
3589
|
-
} else
|
|
3590
|
-
for (var v =
|
|
3591
|
-
return
|
|
3958
|
+
var i, s, u, p = this, h = arguments;
|
|
3959
|
+
if (h.length === 0) return p._loop;
|
|
3960
|
+
if (h.length === 1) {
|
|
3961
|
+
if (typeof h[0] != "boolean") return !!(u = p._soundById(parseInt(h[0], 10))) && u._loop;
|
|
3962
|
+
i = h[0], p._loop = i;
|
|
3963
|
+
} else h.length === 2 && (i = h[0], s = parseInt(h[1], 10));
|
|
3964
|
+
for (var v = p._getSoundIds(s), _ = 0; _ < v.length; _++) (u = p._soundById(v[_])) && (u._loop = i, p._webAudio && u._node && u._node.bufferSource && (u._node.bufferSource.loop = i, i && (u._node.bufferSource.loopStart = u._start || 0, u._node.bufferSource.loopEnd = u._stop)));
|
|
3965
|
+
return p;
|
|
3592
3966
|
}, rate: function() {
|
|
3593
|
-
var i, s, u = this,
|
|
3594
|
-
if (
|
|
3595
|
-
else if (
|
|
3596
|
-
var
|
|
3597
|
-
v >= 0 ? s = parseInt(
|
|
3598
|
-
} else
|
|
3967
|
+
var i, s, u = this, p = arguments;
|
|
3968
|
+
if (p.length === 0) s = u._sounds[0]._id;
|
|
3969
|
+
else if (p.length === 1) {
|
|
3970
|
+
var h = u._getSoundIds(), v = h.indexOf(p[0]);
|
|
3971
|
+
v >= 0 ? s = parseInt(p[0], 10) : i = parseFloat(p[0]);
|
|
3972
|
+
} else p.length === 2 && (i = parseFloat(p[0]), s = parseInt(p[1], 10));
|
|
3599
3973
|
var _;
|
|
3600
3974
|
if (typeof i != "number") return _ = u._soundById(s), _ ? _._rate : u._rate;
|
|
3601
3975
|
if (u._state !== "loaded" || u._playLock) return u._queue.push({ event: "rate", action: function() {
|
|
3602
|
-
u.rate.apply(u,
|
|
3976
|
+
u.rate.apply(u, p);
|
|
3603
3977
|
} }), u;
|
|
3604
3978
|
s === void 0 && (u._rate = i), s = u._getSoundIds(s);
|
|
3605
3979
|
for (var w = 0; w < s.length; w++) if (_ = u._soundById(s[w])) {
|
|
@@ -3609,15 +3983,15 @@ function aa() {
|
|
|
3609
3983
|
}
|
|
3610
3984
|
return u;
|
|
3611
3985
|
}, seek: function() {
|
|
3612
|
-
var i, s, u = this,
|
|
3613
|
-
if (
|
|
3614
|
-
else if (
|
|
3615
|
-
var
|
|
3616
|
-
v >= 0 ? s = parseInt(
|
|
3617
|
-
} else
|
|
3986
|
+
var i, s, u = this, p = arguments;
|
|
3987
|
+
if (p.length === 0) s = u._sounds[0]._id;
|
|
3988
|
+
else if (p.length === 1) {
|
|
3989
|
+
var h = u._getSoundIds(), v = h.indexOf(p[0]);
|
|
3990
|
+
v >= 0 ? s = parseInt(p[0], 10) : u._sounds.length && (s = u._sounds[0]._id, i = parseFloat(p[0]));
|
|
3991
|
+
} else p.length === 2 && (i = parseFloat(p[0]), s = parseInt(p[1], 10));
|
|
3618
3992
|
if (s === void 0) return u;
|
|
3619
3993
|
if (typeof i == "number" && (u._state !== "loaded" || u._playLock)) return u._queue.push({ event: "seek", action: function() {
|
|
3620
|
-
u.seek.apply(u,
|
|
3994
|
+
u.seek.apply(u, p);
|
|
3621
3995
|
} }), u;
|
|
3622
3996
|
var _ = u._soundById(s);
|
|
3623
3997
|
if (_) {
|
|
@@ -3634,10 +4008,10 @@ function aa() {
|
|
|
3634
4008
|
u._emit("seek", s), k && u.play(s, !0);
|
|
3635
4009
|
};
|
|
3636
4010
|
if (k && !u._webAudio) {
|
|
3637
|
-
var
|
|
3638
|
-
u._playLock ? setTimeout(
|
|
4011
|
+
var U = function() {
|
|
4012
|
+
u._playLock ? setTimeout(U, 0) : x();
|
|
3639
4013
|
};
|
|
3640
|
-
setTimeout(
|
|
4014
|
+
setTimeout(U, 0);
|
|
3641
4015
|
} else x();
|
|
3642
4016
|
}
|
|
3643
4017
|
return u;
|
|
@@ -3647,49 +4021,49 @@ function aa() {
|
|
|
3647
4021
|
var u = s._soundById(i);
|
|
3648
4022
|
return !!u && !u._paused;
|
|
3649
4023
|
}
|
|
3650
|
-
for (var
|
|
4024
|
+
for (var p = 0; p < s._sounds.length; p++) if (!s._sounds[p]._paused) return !0;
|
|
3651
4025
|
return !1;
|
|
3652
4026
|
}, duration: function(i) {
|
|
3653
|
-
var s = this, u = s._duration,
|
|
3654
|
-
return
|
|
4027
|
+
var s = this, u = s._duration, p = s._soundById(i);
|
|
4028
|
+
return p && (u = s._sprite[p._sprite][1] / 1e3), u;
|
|
3655
4029
|
}, state: function() {
|
|
3656
4030
|
return this._state;
|
|
3657
4031
|
}, unload: function() {
|
|
3658
4032
|
for (var i = this, s = i._sounds, u = 0; u < s.length; u++) s[u]._paused || i.stop(s[u]._id), i._webAudio || (i._clearSound(s[u]._node), s[u]._node.removeEventListener("error", s[u]._errorFn, !1), s[u]._node.removeEventListener(o._canPlayEvent, s[u]._loadFn, !1), s[u]._node.removeEventListener("ended", s[u]._endFn, !1), o._releaseHtml5Audio(s[u]._node)), delete s[u]._node, i._clearTimer(s[u]._id);
|
|
3659
|
-
var
|
|
3660
|
-
|
|
3661
|
-
var
|
|
4033
|
+
var p = o._howls.indexOf(i);
|
|
4034
|
+
p >= 0 && o._howls.splice(p, 1);
|
|
4035
|
+
var h = !0;
|
|
3662
4036
|
for (u = 0; u < o._howls.length; u++) if (o._howls[u]._src === i._src || i._src.indexOf(o._howls[u]._src) >= 0) {
|
|
3663
|
-
|
|
4037
|
+
h = !1;
|
|
3664
4038
|
break;
|
|
3665
4039
|
}
|
|
3666
|
-
return c &&
|
|
3667
|
-
}, on: function(i, s, u,
|
|
3668
|
-
var
|
|
3669
|
-
return typeof s == "function" && v.push(
|
|
4040
|
+
return c && h && delete c[i._src], o.noAudio = !1, i._state = "unloaded", i._sounds = [], i = null, null;
|
|
4041
|
+
}, on: function(i, s, u, p) {
|
|
4042
|
+
var h = this, v = h["_on" + i];
|
|
4043
|
+
return typeof s == "function" && v.push(p ? { id: u, fn: s, once: p } : { id: u, fn: s }), h;
|
|
3670
4044
|
}, off: function(i, s, u) {
|
|
3671
|
-
var
|
|
3672
|
-
if (typeof s == "number" && (u = s, s = null), s || u) for (v = 0; v <
|
|
3673
|
-
var _ = u ===
|
|
3674
|
-
if (s ===
|
|
3675
|
-
|
|
4045
|
+
var p = this, h = p["_on" + i], v = 0;
|
|
4046
|
+
if (typeof s == "number" && (u = s, s = null), s || u) for (v = 0; v < h.length; v++) {
|
|
4047
|
+
var _ = u === h[v].id;
|
|
4048
|
+
if (s === h[v].fn && _ || !s && _) {
|
|
4049
|
+
h.splice(v, 1);
|
|
3676
4050
|
break;
|
|
3677
4051
|
}
|
|
3678
4052
|
}
|
|
3679
|
-
else if (i)
|
|
4053
|
+
else if (i) p["_on" + i] = [];
|
|
3680
4054
|
else {
|
|
3681
|
-
var w = Object.keys(
|
|
3682
|
-
for (v = 0; v < w.length; v++) w[v].indexOf("_on") === 0 && Array.isArray(
|
|
4055
|
+
var w = Object.keys(p);
|
|
4056
|
+
for (v = 0; v < w.length; v++) w[v].indexOf("_on") === 0 && Array.isArray(p[w[v]]) && (p[w[v]] = []);
|
|
3683
4057
|
}
|
|
3684
|
-
return
|
|
4058
|
+
return p;
|
|
3685
4059
|
}, once: function(i, s, u) {
|
|
3686
|
-
var
|
|
3687
|
-
return
|
|
4060
|
+
var p = this;
|
|
4061
|
+
return p.on(i, s, u, 1), p;
|
|
3688
4062
|
}, _emit: function(i, s, u) {
|
|
3689
|
-
for (var
|
|
4063
|
+
for (var p = this, h = p["_on" + i], v = h.length - 1; v >= 0; v--) h[v].id && h[v].id !== s && i !== "load" || (setTimeout((function(_) {
|
|
3690
4064
|
_.call(this, s, u);
|
|
3691
|
-
}).bind(
|
|
3692
|
-
return
|
|
4065
|
+
}).bind(p, h[v].fn), 0), h[v].once && p.off(i, h[v].fn, h[v].id));
|
|
4066
|
+
return p._loadQueue(i), p;
|
|
3693
4067
|
}, _loadQueue: function(i) {
|
|
3694
4068
|
var s = this;
|
|
3695
4069
|
if (s._queue.length > 0) {
|
|
@@ -3700,13 +4074,13 @@ function aa() {
|
|
|
3700
4074
|
}, _ended: function(i) {
|
|
3701
4075
|
var s = this, u = i._sprite;
|
|
3702
4076
|
if (!s._webAudio && i._node && !i._node.paused && !i._node.ended && i._node.currentTime < i._stop) return setTimeout(s._ended.bind(s, i), 100), s;
|
|
3703
|
-
var
|
|
3704
|
-
if (s._emit("end", i._id), !s._webAudio &&
|
|
4077
|
+
var p = !(!i._loop && !s._sprite[u][2]);
|
|
4078
|
+
if (s._emit("end", i._id), !s._webAudio && p && s.stop(i._id, !0).play(i._id), s._webAudio && p) {
|
|
3705
4079
|
s._emit("play", i._id), i._seek = i._start || 0, i._rateSeek = 0, i._playStart = o.ctx.currentTime;
|
|
3706
|
-
var
|
|
3707
|
-
s._endTimers[i._id] = setTimeout(s._ended.bind(s, i),
|
|
4080
|
+
var h = 1e3 * (i._stop - i._start) / Math.abs(i._rate);
|
|
4081
|
+
s._endTimers[i._id] = setTimeout(s._ended.bind(s, i), h);
|
|
3708
4082
|
}
|
|
3709
|
-
return s._webAudio && !
|
|
4083
|
+
return s._webAudio && !p && (i._paused = !0, i._ended = !0, i._seek = i._start || 0, i._rateSeek = 0, s._clearTimer(i._id), s._cleanBuffer(i._node), o._autoSuspend()), s._webAudio || p || s.stop(i._id, !0), s;
|
|
3710
4084
|
}, _clearTimer: function(i) {
|
|
3711
4085
|
var s = this;
|
|
3712
4086
|
if (s._endTimers[i]) {
|
|
@@ -3727,18 +4101,18 @@ function aa() {
|
|
|
3727
4101
|
for (var s = 0; s < i._sounds.length; s++) if (i._sounds[s]._ended) return i._sounds[s].reset();
|
|
3728
4102
|
return new a(i);
|
|
3729
4103
|
}, _drain: function() {
|
|
3730
|
-
var i = this, s = i._pool, u = 0,
|
|
4104
|
+
var i = this, s = i._pool, u = 0, p = 0;
|
|
3731
4105
|
if (!(i._sounds.length < s)) {
|
|
3732
|
-
for (
|
|
3733
|
-
for (
|
|
4106
|
+
for (p = 0; p < i._sounds.length; p++) i._sounds[p]._ended && u++;
|
|
4107
|
+
for (p = i._sounds.length - 1; p >= 0; p--) {
|
|
3734
4108
|
if (u <= s) return;
|
|
3735
|
-
i._sounds[
|
|
4109
|
+
i._sounds[p]._ended && (i._webAudio && i._sounds[p]._node && i._sounds[p]._node.disconnect(0), i._sounds.splice(p, 1), u--);
|
|
3736
4110
|
}
|
|
3737
4111
|
}
|
|
3738
4112
|
}, _getSoundIds: function(i) {
|
|
3739
4113
|
var s = this;
|
|
3740
4114
|
if (i === void 0) {
|
|
3741
|
-
for (var u = [],
|
|
4115
|
+
for (var u = [], p = 0; p < s._sounds.length; p++) u.push(s._sounds[p]._id);
|
|
3742
4116
|
return u;
|
|
3743
4117
|
}
|
|
3744
4118
|
return [i];
|
|
@@ -3781,8 +4155,8 @@ function aa() {
|
|
|
3781
4155
|
var s = i._src;
|
|
3782
4156
|
if (c[s]) return i._duration = c[s].duration, void y(i);
|
|
3783
4157
|
if (/^data:[^;]+;base64,/.test(s)) {
|
|
3784
|
-
for (var u = atob(s.split(",")[1]),
|
|
3785
|
-
|
|
4158
|
+
for (var u = atob(s.split(",")[1]), p = new Uint8Array(u.length), h = 0; h < u.length; ++h) p[h] = u.charCodeAt(h);
|
|
4159
|
+
f(p.buffer, i);
|
|
3786
4160
|
} else {
|
|
3787
4161
|
var v = new XMLHttpRequest();
|
|
3788
4162
|
v.open(i._xhr.method, s, !0), v.withCredentials = i._xhr.withCredentials, v.responseType = "arraybuffer", i._xhr.headers && Object.keys(i._xhr.headers).forEach(function(_) {
|
|
@@ -3790,24 +4164,24 @@ function aa() {
|
|
|
3790
4164
|
}), v.onload = function() {
|
|
3791
4165
|
var _ = (v.status + "")[0];
|
|
3792
4166
|
if (_ !== "0" && _ !== "2" && _ !== "3") return void i._emit("loaderror", null, "Failed loading audio file with status: " + v.status + ".");
|
|
3793
|
-
|
|
4167
|
+
f(v.response, i);
|
|
3794
4168
|
}, v.onerror = function() {
|
|
3795
4169
|
i._webAudio && (i._html5 = !0, i._webAudio = !1, i._sounds = [], delete c[s], i.load());
|
|
3796
|
-
},
|
|
4170
|
+
}, d(v);
|
|
3797
4171
|
}
|
|
3798
|
-
},
|
|
4172
|
+
}, d = function(i) {
|
|
3799
4173
|
try {
|
|
3800
4174
|
i.send();
|
|
3801
4175
|
} catch {
|
|
3802
4176
|
i.onerror();
|
|
3803
4177
|
}
|
|
3804
|
-
},
|
|
4178
|
+
}, f = function(i, s) {
|
|
3805
4179
|
var u = function() {
|
|
3806
4180
|
s._emit("loaderror", null, "Decoding audio data failed.");
|
|
3807
|
-
},
|
|
3808
|
-
|
|
4181
|
+
}, p = function(h) {
|
|
4182
|
+
h && s._sounds.length > 0 ? (c[s._src] = h, y(s, h)) : u();
|
|
3809
4183
|
};
|
|
3810
|
-
typeof Promise < "u" && o.ctx.decodeAudioData.length === 1 ? o.ctx.decodeAudioData(i).then(
|
|
4184
|
+
typeof Promise < "u" && o.ctx.decodeAudioData.length === 1 ? o.ctx.decodeAudioData(i).then(p).catch(u) : o.ctx.decodeAudioData(i, p, u);
|
|
3811
4185
|
}, y = function(i, s) {
|
|
3812
4186
|
s && !i._duration && (i._duration = s.duration), Object.keys(i._sprite).length === 0 && (i._sprite = { __default: [0, 1e3 * i._duration] }), i._state !== "loaded" && (i._state = "loaded", i._emit("load"), i._loadQueue());
|
|
3813
4187
|
}, g = function() {
|
|
@@ -3820,19 +4194,19 @@ function aa() {
|
|
|
3820
4194
|
o.ctx || (o.usingWebAudio = !1);
|
|
3821
4195
|
var i = /iP(hone|od|ad)/.test(o._navigator && o._navigator.platform), s = o._navigator && o._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), u = s ? parseInt(s[1], 10) : null;
|
|
3822
4196
|
if (i && u && u < 9) {
|
|
3823
|
-
var
|
|
3824
|
-
o._navigator && !
|
|
4197
|
+
var p = /safari/.test(o._navigator && o._navigator.userAgent.toLowerCase());
|
|
4198
|
+
o._navigator && !p && (o.usingWebAudio = !1);
|
|
3825
4199
|
}
|
|
3826
4200
|
o.usingWebAudio && (o.masterGain = o.ctx.createGain === void 0 ? o.ctx.createGainNode() : o.ctx.createGain(), o.masterGain.gain.setValueAtTime(o._muted ? 0 : o._volume, o.ctx.currentTime), o.masterGain.connect(o.ctx.destination)), o._setup();
|
|
3827
4201
|
}
|
|
3828
4202
|
};
|
|
3829
4203
|
e.Howler = o, e.Howl = r, typeof t < "u" ? (t.HowlerGlobal = n, t.Howler = o, t.Howl = r, t.Sound = a) : typeof window < "u" && (window.HowlerGlobal = n, window.Howler = o, window.Howl = r, window.Sound = a);
|
|
3830
4204
|
})();
|
|
3831
|
-
}(
|
|
4205
|
+
}(ze)), ze;
|
|
3832
4206
|
}
|
|
3833
|
-
var
|
|
3834
|
-
const
|
|
3835
|
-
class
|
|
4207
|
+
var Et = Aa();
|
|
4208
|
+
const Ta = typeof navigator < "u" && typeof navigator.standalone < "u";
|
|
4209
|
+
class Pa {
|
|
3836
4210
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3837
4211
|
constructor(t) {
|
|
3838
4212
|
this.cogsConnection = t, this.addEventListener("audioClipState", ({ detail: o }) => {
|
|
@@ -3868,8 +4242,8 @@ class $a {
|
|
|
3868
4242
|
const n = () => {
|
|
3869
4243
|
const o = Object.entries(this.audioClipPlayers).map(([r, a]) => {
|
|
3870
4244
|
const c = Object.values(a.activeClips), l = c.some(
|
|
3871
|
-
({ state:
|
|
3872
|
-
) ? "playing" : c.some(({ state:
|
|
4245
|
+
({ state: d }) => d.type === "playing" || d.type === "pausing" || d.type === "stopping" || d.type === "play_requested" || d.type === "pause_requested" || d.type === "stop_requested"
|
|
4246
|
+
) ? "playing" : c.some(({ state: d }) => d.type === "paused") ? "paused" : "stopped";
|
|
3873
4247
|
return [r, l];
|
|
3874
4248
|
});
|
|
3875
4249
|
t.sendInitialMediaClipStates({ mediaType: "audio", files: o });
|
|
@@ -3881,20 +4255,20 @@ class $a {
|
|
|
3881
4255
|
audioClipPlayers = {};
|
|
3882
4256
|
sinkId = "";
|
|
3883
4257
|
setGlobalVolume(t) {
|
|
3884
|
-
this.globalVolume = t,
|
|
4258
|
+
this.globalVolume = t, Et.Howler.volume(t), this.notifyStateListeners();
|
|
3885
4259
|
}
|
|
3886
4260
|
playAudioClip(t, { playId: n, volume: o, fade: r, loop: a }) {
|
|
3887
4261
|
t in this.audioClipPlayers || (this.audioClipPlayers[t] = this.createClip(t, { preload: !1, ephemeral: !0 })), this.updateAudioClipPlayer(t, (c) => {
|
|
3888
|
-
const l = Object.entries(c.activeClips).filter(([, { state: g }]) => g.type === "paused").map(([g]) => parseInt(g)),
|
|
4262
|
+
const l = Object.entries(c.activeClips).filter(([, { state: g }]) => g.type === "paused").map(([g]) => parseInt(g)), d = Object.entries(c.activeClips).filter(([, { state: g }]) => g.type === "pausing").map(([g]) => parseInt(g));
|
|
3889
4263
|
l.forEach((g) => {
|
|
3890
4264
|
c.player.play(g);
|
|
3891
4265
|
});
|
|
3892
|
-
const
|
|
3893
|
-
return
|
|
3894
|
-
c.player.off("fade", void 0, g), c.player.loop(a, g), this.updateActiveAudioClip(t, g, (i) => ({ ...i, state: { type: "playing" } })), ne(r) ? oe(c.player, o, r * 1e3, g) :
|
|
3895
|
-
}), [...l, ...
|
|
4266
|
+
const f = Object.entries(c.activeClips).filter(([, { state: g }]) => g.type === "pause_requested").map(([g]) => parseInt(g)), y = l.length > 0 || d.length > 0 || f.length > 0 ? [] : [c.player.play()];
|
|
4267
|
+
return d.forEach((g) => {
|
|
4268
|
+
c.player.off("fade", void 0, g), c.player.loop(a, g), this.updateActiveAudioClip(t, g, (i) => ({ ...i, state: { type: "playing" } })), ne(r) ? oe(c.player, o, r * 1e3, g) : $e(c.player, o, g);
|
|
4269
|
+
}), [...l, ...f, ...y].forEach((g) => {
|
|
3896
4270
|
c.player.loop(a, g), c.player.off("play", void 0, g), c.player.off("pause", void 0, g), c.player.off("fade", void 0, g), c.player.off("end", void 0, g), c.player.off("stop", void 0, g), c.player.once("play", () => {
|
|
3897
|
-
|
|
4271
|
+
Ie(c.player, this.sinkId);
|
|
3898
4272
|
}), c.player.once("stop", () => this.handleStoppedClip(t, n, g), g), c.player.on(
|
|
3899
4273
|
"end",
|
|
3900
4274
|
() => {
|
|
@@ -3921,35 +4295,35 @@ class $a {
|
|
|
3921
4295
|
oe(c.player, o, r * 1e3, g);
|
|
3922
4296
|
},
|
|
3923
4297
|
g
|
|
3924
|
-
)) :
|
|
4298
|
+
)) : $e(c.player, o, g), c.activeClips = { ...c.activeClips, [g]: i };
|
|
3925
4299
|
}), c;
|
|
3926
4300
|
}), this.notifyClipStateListeners(n, t, "playing");
|
|
3927
4301
|
}
|
|
3928
4302
|
pauseAudioClip(t, { fade: n }, o, r) {
|
|
3929
4303
|
Object.keys(this.audioClipPlayers[t]?.activeClips ?? {}).length !== 0 && this.updateAudioClipPlayer(t, (a) => (a.activeClips = Object.fromEntries(
|
|
3930
4304
|
Object.entries(a.activeClips).map(([c, l]) => {
|
|
3931
|
-
const
|
|
3932
|
-
return (o === void 0 || o ===
|
|
4305
|
+
const d = parseInt(c);
|
|
4306
|
+
return (o === void 0 || o === d) && (r && l.state.type === "pause_requested" || l.state.type === "playing" || l.state.type === "pausing" ? ne(n) ? (a.player.once(
|
|
3933
4307
|
"fade",
|
|
3934
|
-
(
|
|
3935
|
-
a.player.pause(
|
|
4308
|
+
(f) => {
|
|
4309
|
+
a.player.pause(f), this.updateActiveAudioClip(t, f, (y) => ({ ...y, state: { type: "paused" } })), this.notifyClipStateListeners(l.playId, t, "paused");
|
|
3936
4310
|
},
|
|
3937
|
-
|
|
3938
|
-
), oe(a.player, 0, n * 1e3,
|
|
4311
|
+
d
|
|
4312
|
+
), oe(a.player, 0, n * 1e3, d), l.state = { type: "pausing" }) : (a.player.pause(d), l.state = { type: "paused" }, this.notifyClipStateListeners(l.playId, t, "paused")) : (l.state.type === "play_requested" || l.state.type === "pause_requested") && (l.state = { type: "pause_requested", fade: n })), [c, l];
|
|
3939
4313
|
})
|
|
3940
4314
|
), a));
|
|
3941
4315
|
}
|
|
3942
4316
|
stopAudioClip(t, { fade: n }, o, r) {
|
|
3943
|
-
|
|
4317
|
+
Sa("Stop audio clip", { activeClips: this.audioClipPlayers[t]?.activeClips }), Object.keys(this.audioClipPlayers[t]?.activeClips ?? {}).length !== 0 && this.updateAudioClipPlayer(t, (a) => (a.activeClips = Object.fromEntries(
|
|
3944
4318
|
Object.entries(a.activeClips).map(([c, l]) => {
|
|
3945
|
-
const
|
|
3946
|
-
return (o === void 0 || o ===
|
|
4319
|
+
const d = parseInt(c);
|
|
4320
|
+
return (o === void 0 || o === d) && (r && l.state.type === "stop_requested" || l.state.type === "playing" || l.state.type === "pausing" || l.state.type === "paused" || l.state.type === "stopping" ? ne(n) && l.state.type !== "paused" ? (a.player.off("fade", d), oe(a.player, 0, n * 1e3, d), a.player.once(
|
|
3947
4321
|
"fade",
|
|
3948
|
-
(
|
|
3949
|
-
a.player.loop(!1,
|
|
4322
|
+
(f) => {
|
|
4323
|
+
a.player.loop(!1, f), a.player.stop(f);
|
|
3950
4324
|
},
|
|
3951
|
-
|
|
3952
|
-
), l.state = { type: "stopping" }) : (a.player.loop(!1,
|
|
4325
|
+
d
|
|
4326
|
+
), l.state = { type: "stopping" }) : (a.player.loop(!1, d), a.player.stop(d)) : (l.state.type === "play_requested" || l.state.type === "pause_requested" || l.state.type === "stop_requested") && (l.state = { type: "stop_requested", fade: n })), [c, l];
|
|
3953
4327
|
})
|
|
3954
4328
|
), a));
|
|
3955
4329
|
}
|
|
@@ -3967,7 +4341,7 @@ class $a {
|
|
|
3967
4341
|
Object.entries(r.activeClips).map(([a, c]) => {
|
|
3968
4342
|
if (c.state.type !== "pausing" && c.state.type !== "stopping") {
|
|
3969
4343
|
const l = parseInt(a);
|
|
3970
|
-
return ne(o) ? oe(r.player, n, o * 1e3, l) :
|
|
4344
|
+
return ne(o) ? oe(r.player, n, o * 1e3, l) : $e(r.player, n, l), [a, { ...c, volume: n }];
|
|
3971
4345
|
} else
|
|
3972
4346
|
return [a, c];
|
|
3973
4347
|
})
|
|
@@ -3989,7 +4363,7 @@ class $a {
|
|
|
3989
4363
|
}
|
|
3990
4364
|
setAudioSink(t) {
|
|
3991
4365
|
for (const n of Object.values(this.audioClipPlayers))
|
|
3992
|
-
|
|
4366
|
+
Ie(n.player, t);
|
|
3993
4367
|
this.sinkId = t;
|
|
3994
4368
|
}
|
|
3995
4369
|
updateConfig(t) {
|
|
@@ -4002,13 +4376,13 @@ class $a {
|
|
|
4002
4376
|
this.audioClipPlayers = (() => {
|
|
4003
4377
|
const r = { ...o };
|
|
4004
4378
|
return Object.keys(o).filter(
|
|
4005
|
-
(
|
|
4006
|
-
).forEach((
|
|
4007
|
-
o[
|
|
4008
|
-
}), Object.entries(n).filter(([
|
|
4009
|
-
r[
|
|
4010
|
-
}), Object.keys(o).filter((
|
|
4011
|
-
r[
|
|
4379
|
+
(d) => !(d in n) && !o[d].config.ephemeral
|
|
4380
|
+
).forEach((d) => {
|
|
4381
|
+
o[d].player.unload(), delete r[d];
|
|
4382
|
+
}), Object.entries(n).filter(([d]) => !o[d]).forEach(([d, f]) => {
|
|
4383
|
+
r[d] = this.createClip(d, { ...f, ephemeral: !1 });
|
|
4384
|
+
}), Object.keys(o).filter((d) => d in n).forEach((d) => {
|
|
4385
|
+
r[d] = this.updatedClip(d, r[d], { ...n[d], ephemeral: !1 });
|
|
4012
4386
|
}), r;
|
|
4013
4387
|
})(), this.notifyStateListeners();
|
|
4014
4388
|
}
|
|
@@ -4042,7 +4416,7 @@ class $a {
|
|
|
4042
4416
|
this.eventTarget.dispatchEvent(new CustomEvent(t, { detail: n }));
|
|
4043
4417
|
}
|
|
4044
4418
|
createPlayer(t, n) {
|
|
4045
|
-
const o = new
|
|
4419
|
+
const o = new Et.Howl({
|
|
4046
4420
|
src: this.cogsConnection.getAssetUrl(t),
|
|
4047
4421
|
autoplay: !1,
|
|
4048
4422
|
loop: !1,
|
|
@@ -4050,7 +4424,7 @@ class $a {
|
|
|
4050
4424
|
html5: !0,
|
|
4051
4425
|
preload: n.preload
|
|
4052
4426
|
});
|
|
4053
|
-
return
|
|
4427
|
+
return Ie(o, this.sinkId), o;
|
|
4054
4428
|
}
|
|
4055
4429
|
createClip(t, n) {
|
|
4056
4430
|
return {
|
|
@@ -4064,24 +4438,24 @@ class $a {
|
|
|
4064
4438
|
return n.config.preload !== o.preload && (r.player.unload(), r.player = this.createPlayer(t, o)), r;
|
|
4065
4439
|
}
|
|
4066
4440
|
}
|
|
4067
|
-
function
|
|
4441
|
+
function Sa(...e) {
|
|
4068
4442
|
}
|
|
4069
4443
|
function ne(e) {
|
|
4070
|
-
return !
|
|
4444
|
+
return !Ta && typeof e == "number" && !isNaN(e) && e > 0;
|
|
4071
4445
|
}
|
|
4072
|
-
function
|
|
4446
|
+
function Ie(e, t) {
|
|
4073
4447
|
t !== void 0 && (e._html5 ? e._sounds?.forEach((n) => {
|
|
4074
4448
|
n._node?.setSinkId?.(t);
|
|
4075
4449
|
}) : console.warn("Cannot set sink ID: web audio not supported", e));
|
|
4076
4450
|
}
|
|
4077
|
-
function
|
|
4451
|
+
function $e(e, t, n) {
|
|
4078
4452
|
e.volume(t, n), e.mute(t === 0, n);
|
|
4079
4453
|
}
|
|
4080
4454
|
function oe(e, t, n, o) {
|
|
4081
4455
|
e.fade(e.volume(o), t, n, o);
|
|
4082
4456
|
}
|
|
4083
4457
|
var Le = /* @__PURE__ */ ((e) => (e.Paused = "paused", e.Playing = "playing", e))(Le || {});
|
|
4084
|
-
class
|
|
4458
|
+
class Za {
|
|
4085
4459
|
constructor(t, n = document.body) {
|
|
4086
4460
|
this.cogsConnection = t, this.parentElement = n, this.addEventListener("videoClipState", ({ detail: r }) => {
|
|
4087
4461
|
t.sendMediaClipState(r);
|
|
@@ -4185,21 +4559,21 @@ class Oa {
|
|
|
4185
4559
|
}
|
|
4186
4560
|
setAudioSink(t) {
|
|
4187
4561
|
for (const n of Object.values(this.videoClipPlayers))
|
|
4188
|
-
|
|
4562
|
+
Ct(n, t);
|
|
4189
4563
|
this.sinkId = t;
|
|
4190
4564
|
}
|
|
4191
4565
|
updateConfig(t) {
|
|
4192
4566
|
const n = Object.fromEntries(Object.entries(t).filter(([, { type: r }]) => r === "video" || !r)), o = this.videoClipPlayers;
|
|
4193
4567
|
this.videoClipPlayers = (() => {
|
|
4194
4568
|
const r = { ...o };
|
|
4195
|
-
return Object.keys(o).filter((
|
|
4196
|
-
this.activeClip?.path ===
|
|
4197
|
-
}), Object.entries(n).filter(([
|
|
4198
|
-
r[
|
|
4199
|
-
}), Object.entries(o).filter(([
|
|
4200
|
-
|
|
4569
|
+
return Object.keys(o).filter((d) => !(d in n)).forEach((d) => {
|
|
4570
|
+
this.activeClip?.path === d && o[d]?.config.ephemeral === !1 ? this.updateVideoClipPlayer(d, (f) => (f.config = { ...f.config, ephemeral: !0 }, f)) : (this.unloadClip(d), delete r[d]);
|
|
4571
|
+
}), Object.entries(n).filter(([d]) => !o[d]).forEach(([d, f]) => {
|
|
4572
|
+
r[d] = this.createClipPlayer(d, { ...f, preload: kt(f.preload), ephemeral: !1, fit: "contain" });
|
|
4573
|
+
}), Object.entries(o).filter(([d]) => d in n).forEach(([d, f]) => {
|
|
4574
|
+
f.config.preload !== n[d].preload && this.updateVideoClipPlayer(d, (y) => (y.config = {
|
|
4201
4575
|
...y.config,
|
|
4202
|
-
preload:
|
|
4576
|
+
preload: kt(n[d].preload),
|
|
4203
4577
|
ephemeral: !1
|
|
4204
4578
|
}, y.videoElement.preload = y.config.preload, y));
|
|
4205
4579
|
}), r;
|
|
@@ -4262,7 +4636,7 @@ class Oa {
|
|
|
4262
4636
|
videoElement: this.createVideoElement(t, n, { volume: 1 }),
|
|
4263
4637
|
volume: 1
|
|
4264
4638
|
};
|
|
4265
|
-
return
|
|
4639
|
+
return Ct(r, this.sinkId), r;
|
|
4266
4640
|
}
|
|
4267
4641
|
unloadClip(t) {
|
|
4268
4642
|
if (this.activeClip?.path === t) {
|
|
@@ -4272,338 +4646,22 @@ class Oa {
|
|
|
4272
4646
|
this.videoClipPlayers[t]?.videoElement.remove(), this.updateVideoClipPlayer(t, () => null);
|
|
4273
4647
|
}
|
|
4274
4648
|
}
|
|
4275
|
-
function
|
|
4649
|
+
function kt(e) {
|
|
4276
4650
|
return typeof e == "string" ? e : e ? "auto" : "none";
|
|
4277
4651
|
}
|
|
4278
|
-
function
|
|
4652
|
+
function Ct(e, t) {
|
|
4279
4653
|
t !== void 0 && typeof e.videoElement.setSinkId == "function" && e.videoElement.setSinkId(t);
|
|
4280
4654
|
}
|
|
4281
4655
|
function pe(e, t) {
|
|
4282
4656
|
e.volume = t, e.muted = t === 0;
|
|
4283
4657
|
}
|
|
4284
|
-
|
|
4285
|
-
switch (e.type) {
|
|
4286
|
-
case "image": {
|
|
4287
|
-
if (e.keyframes[0][0] > t)
|
|
4288
|
-
return;
|
|
4289
|
-
const o = e.keyframes.filter((a) => a[1] !== null), r = Ie(o, t);
|
|
4290
|
-
return { ...me, ...r };
|
|
4291
|
-
}
|
|
4292
|
-
case "audio": {
|
|
4293
|
-
const n = e.keyframes.filter((a) => a[1] !== null), o = Et(n, t);
|
|
4294
|
-
if (!o)
|
|
4295
|
-
return;
|
|
4296
|
-
const r = Ie(n, t);
|
|
4297
|
-
return { ...we, ...r, ...o };
|
|
4298
|
-
}
|
|
4299
|
-
case "video": {
|
|
4300
|
-
const n = e.keyframes.filter((a) => a[1] !== null), o = Et(n, t);
|
|
4301
|
-
if (!o)
|
|
4302
|
-
return;
|
|
4303
|
-
const r = Ie(n, t);
|
|
4304
|
-
return { ...ie, ...r, ...o };
|
|
4305
|
-
}
|
|
4306
|
-
}
|
|
4307
|
-
}
|
|
4308
|
-
function Ie(e, t) {
|
|
4309
|
-
const n = {};
|
|
4310
|
-
for (const [r, a] of e)
|
|
4311
|
-
r <= t ? (Object.entries(a.lerp ?? {}).forEach(([c, l]) => {
|
|
4312
|
-
n[c] ??= {}, n[c].before = [r, l];
|
|
4313
|
-
}), Object.entries(a.set ?? {}).forEach(([c, l]) => {
|
|
4314
|
-
n[c] ??= {}, n[c].before = [r, l];
|
|
4315
|
-
})) : Object.entries(a.lerp ?? {}).forEach(([c, l]) => {
|
|
4316
|
-
n[c] ??= {}, n[c].after === void 0 && (n[c].after = [r, l]);
|
|
4317
|
-
});
|
|
4318
|
-
const o = {};
|
|
4319
|
-
return Object.entries(n).forEach(
|
|
4320
|
-
([r, { before: a, after: c }]) => {
|
|
4321
|
-
if (c === void 0 && a) {
|
|
4322
|
-
o[r] = a[1];
|
|
4323
|
-
return;
|
|
4324
|
-
}
|
|
4325
|
-
if (a && c && a[0] === c[0]) {
|
|
4326
|
-
o[r] = c[1];
|
|
4327
|
-
return;
|
|
4328
|
-
}
|
|
4329
|
-
if (a && typeof a[1] == "number" && c && typeof c[1] == "number") {
|
|
4330
|
-
o[r] = a[1] + (t - a[0]) * (c[1] - a[1]) / (c[0] - a[0]);
|
|
4331
|
-
return;
|
|
4332
|
-
}
|
|
4333
|
-
}
|
|
4334
|
-
), o;
|
|
4335
|
-
}
|
|
4336
|
-
function Et(e, t) {
|
|
4337
|
-
const n = e[0];
|
|
4338
|
-
if (!n || n[0] > t)
|
|
4339
|
-
return;
|
|
4340
|
-
let o = 0, { t: r, rate: a } = we;
|
|
4341
|
-
for (const [h, y] of e) {
|
|
4342
|
-
if (h > t) break;
|
|
4343
|
-
const { set: g } = y;
|
|
4344
|
-
if (!g) continue;
|
|
4345
|
-
const { t: i, rate: s } = g;
|
|
4346
|
-
if (i !== void 0) {
|
|
4347
|
-
o = h, r = i, s !== void 0 && (a = s);
|
|
4348
|
-
continue;
|
|
4349
|
-
}
|
|
4350
|
-
if (s !== void 0) {
|
|
4351
|
-
const d = (h - o) * a;
|
|
4352
|
-
o = h, r += d, a = s;
|
|
4353
|
-
}
|
|
4354
|
-
}
|
|
4355
|
-
const l = (t - o) * a, p = r + l;
|
|
4356
|
-
return {
|
|
4357
|
-
rate: a,
|
|
4358
|
-
t: p
|
|
4359
|
-
};
|
|
4360
|
-
}
|
|
4361
|
-
const la = 1e3;
|
|
4362
|
-
class Be {
|
|
4363
|
-
constructor(t, n, o) {
|
|
4364
|
-
this.surfaceElement = t, this.clipElement = n, this._state = o, setTimeout(this.loop);
|
|
4365
|
-
}
|
|
4366
|
-
/**
|
|
4367
|
-
* This is the delay to be used in the update loop.
|
|
4368
|
-
* It is intended to be dynamic for each loop.
|
|
4369
|
-
*/
|
|
4370
|
-
delay = la;
|
|
4371
|
-
isConnected(t) {
|
|
4372
|
-
return !(!this.surfaceElement || !this.clipElement || !this.surfaceElement.contains(this.clipElement) || t && !this.clipElement.contains(t));
|
|
4373
|
-
}
|
|
4374
|
-
_state;
|
|
4375
|
-
setState(t) {
|
|
4376
|
-
this._state = t, clearTimeout(this.timeout), this.loop();
|
|
4377
|
-
}
|
|
4378
|
-
timeout;
|
|
4379
|
-
loop = async () => {
|
|
4380
|
-
this.isConnected() ? (this.update(), isFinite(this.delay) && (this.timeout = setTimeout(this.loop, this.delay))) : this.destroy();
|
|
4381
|
-
};
|
|
4382
|
-
}
|
|
4383
|
-
class da extends Be {
|
|
4384
|
-
imageElement;
|
|
4385
|
-
constructor(t, n, o) {
|
|
4386
|
-
super(t, n, o), this.clipElement = n;
|
|
4387
|
-
}
|
|
4388
|
-
updateImageElement() {
|
|
4389
|
-
this.imageElement = document.createElement("img"), this.clipElement.replaceChildren(this.imageElement), this.imageElement.style.position = "absolute", this.imageElement.style.height = "100%", this.imageElement.style.widows = "100%";
|
|
4390
|
-
}
|
|
4391
|
-
update() {
|
|
4392
|
-
const t = Ee(this._state, Date.now());
|
|
4393
|
-
if (t ? (!this.imageElement || !this.isConnected(this.imageElement)) && this.updateImageElement() : (this.imageElement?.remove(), this.imageElement = void 0), !this.imageElement || !t) return;
|
|
4394
|
-
this.imageElement.src.startsWith(this._state.file) || (this.imageElement.src = this._state.file), this.imageElement.style.objectFit !== this._state.fit && (this.imageElement.style.objectFit = this._state.fit), parseFloat(this.imageElement.style.opacity) !== t.opacity && (this.imageElement.style.opacity = String(t.opacity ?? me.opacity));
|
|
4395
|
-
const n = Math.round(t.zIndex ?? me.zIndex);
|
|
4396
|
-
parseInt(this.imageElement.style.zIndex) !== n && (this.imageElement.style.zIndex = String(n));
|
|
4397
|
-
const { opacity: o } = t;
|
|
4398
|
-
typeof o == "string" && o !== this.imageElement.style.opacity && (this.imageElement.style.opacity = o);
|
|
4399
|
-
}
|
|
4400
|
-
destroy() {
|
|
4401
|
-
this.imageElement?.remove();
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
const pa = 1e3, $e = 10, Qt = 1e3, ha = 200, fa = 0.15, kt = 0.7, _a = 0.3;
|
|
4405
|
-
function ma(e) {
|
|
4406
|
-
return -Math.sign(e) * Math.pow(Math.abs(e) / Qt, _a) * fa;
|
|
4407
|
-
}
|
|
4408
|
-
const va = 5;
|
|
4409
|
-
function ga(e, t, n) {
|
|
4410
|
-
const o = Ee(e, t);
|
|
4411
|
-
if (!o) return !1;
|
|
4412
|
-
const { t: r, rate: a } = o;
|
|
4413
|
-
if (r === void 0 || a === void 0) return !1;
|
|
4414
|
-
const c = e.keyframes.filter(([h, y]) => h > t && (y?.set?.t !== void 0 || y?.set?.rate !== void 0))[0];
|
|
4415
|
-
if (c?.[1]?.set?.t !== 0) return !1;
|
|
4416
|
-
const l = (n - r) / a, p = c[0] - t;
|
|
4417
|
-
return Math.abs(l - p) <= va;
|
|
4418
|
-
}
|
|
4419
|
-
class ya extends Be {
|
|
4420
|
-
videoElement;
|
|
4421
|
-
// We seek to another part of the video and do nothing until we get there
|
|
4422
|
-
isSeeking = !1;
|
|
4423
|
-
// We change playbackRate to intercept the server time of the video and don't change course until we intercept
|
|
4424
|
-
timeToIntercept = void 0;
|
|
4425
|
-
constructor(t, n, o) {
|
|
4426
|
-
super(t, n, o), this.clipElement = n;
|
|
4427
|
-
}
|
|
4428
|
-
updateVideoElement() {
|
|
4429
|
-
this.destroy(), this.videoElement = document.createElement("video"), this.clipElement.replaceChildren(this.videoElement), this.videoElement.style.position = "absolute", this.videoElement.style.width = "100%", this.videoElement.style.height = "100%";
|
|
4430
|
-
}
|
|
4431
|
-
get videoDuration() {
|
|
4432
|
-
if (this.videoElement && !(this.videoElement.readyState < HTMLMediaElement.HAVE_METADATA))
|
|
4433
|
-
return this.videoElement.duration * 1e3;
|
|
4434
|
-
}
|
|
4435
|
-
/**
|
|
4436
|
-
* Helper function to seek to a specified time.
|
|
4437
|
-
* Works with the update loop to poll until seeked event has fired.
|
|
4438
|
-
*/
|
|
4439
|
-
seekTo(t) {
|
|
4440
|
-
this.videoElement && (this.videoElement.addEventListener(
|
|
4441
|
-
"seeked",
|
|
4442
|
-
() => {
|
|
4443
|
-
console.debug("seeked"), this.isSeeking = !1;
|
|
4444
|
-
},
|
|
4445
|
-
{ once: !0, passive: !0 }
|
|
4446
|
-
), this.videoElement.currentTime = t / 1e3);
|
|
4447
|
-
}
|
|
4448
|
-
update() {
|
|
4449
|
-
if (this.isSeeking) return;
|
|
4450
|
-
const t = Date.now(), n = Ee(this._state, t);
|
|
4451
|
-
if (n ? (!this.videoElement || !this.isConnected(this.videoElement)) && this.updateVideoElement() : (this.videoElement?.remove(), this.videoElement = void 0), !n || !this.videoElement) return;
|
|
4452
|
-
const { t: o, rate: r, volume: a } = { ...ie, ...n };
|
|
4453
|
-
this.videoElement.src.endsWith(this._state.file) || (this.videoElement.src = this._state.file), this.videoElement.style.objectFit !== this._state.fit && (this.videoElement.style.objectFit = this._state.fit), parseFloat(this.videoElement.style.opacity) !== n.opacity && (this.videoElement.style.opacity = String(n.opacity ?? ie.opacity));
|
|
4454
|
-
const c = Math.round(n.zIndex ?? ie.zIndex);
|
|
4455
|
-
parseInt(this.videoElement.style.zIndex) !== c && (this.videoElement.style.zIndex = String(c)), this.videoElement.volume !== a && (this.videoElement.volume = a);
|
|
4456
|
-
const l = this.videoDuration;
|
|
4457
|
-
if (l !== void 0) {
|
|
4458
|
-
if (ga(this._state, t, l))
|
|
4459
|
-
this.videoElement.loop || (console.debug("starting loop"), this.videoElement.loop = !0);
|
|
4460
|
-
else if (this.videoElement.loop && (console.debug("stopping loop"), this.videoElement.loop = !1), o > l) {
|
|
4461
|
-
console.debug("ended"), this.delay = 1 / 0;
|
|
4462
|
-
return;
|
|
4463
|
-
}
|
|
4464
|
-
}
|
|
4465
|
-
this.videoElement.paused && r > 0 && (l === void 0 || l > o) && this.videoElement.play().catch(() => {
|
|
4466
|
-
});
|
|
4467
|
-
const h = this.videoElement.currentTime * 1e3 - o, y = Math.abs(h);
|
|
4468
|
-
if (this.timeToIntercept !== void 0)
|
|
4469
|
-
if (y <= $e)
|
|
4470
|
-
console.log("intercepted", `${h.toFixed(0)}ms`), this.timeToIntercept = void 0;
|
|
4471
|
-
else {
|
|
4472
|
-
const g = h / (r - this.videoElement.playbackRate);
|
|
4473
|
-
g < this.timeToIntercept && g > 0 ? (console.debug(`intercepting ${g.toFixed(0)}ms`, `${h.toFixed(0)}ms`), this.timeToIntercept = g) : (console.debug("missed intercept", h, this.timeToIntercept, g), this.timeToIntercept = void 0);
|
|
4474
|
-
}
|
|
4475
|
-
switch (!0) {
|
|
4476
|
-
case y <= $e: {
|
|
4477
|
-
console.debug(`${r}x`, h.toFixed(0)), this.timeToIntercept = void 0, this.videoElement.playbackRate !== r && (this.videoElement.playbackRate = r), this.delay = pa;
|
|
4478
|
-
break;
|
|
4479
|
-
}
|
|
4480
|
-
case this.timeToIntercept !== void 0:
|
|
4481
|
-
this.delay = this.timeToIntercept * kt;
|
|
4482
|
-
break;
|
|
4483
|
-
case (r > 0 && y > $e && y <= Qt && this.timeToIntercept === void 0): {
|
|
4484
|
-
const g = ma(h), i = Math.max(0, r + g);
|
|
4485
|
-
this.timeToIntercept = h / (r - i), console.debug(`${i.toFixed(2)}x`, `${h.toFixed(0)}ms`), this.videoElement.playbackRate !== i && (this.videoElement.playbackRate = i), this.delay = this.timeToIntercept * kt;
|
|
4486
|
-
break;
|
|
4487
|
-
}
|
|
4488
|
-
default: {
|
|
4489
|
-
this.videoElement.playbackRate !== r && (this.videoElement.playbackRate = r), console.debug("seeking"), this.delay = 10, this.seekTo(o + r * ha);
|
|
4490
|
-
break;
|
|
4491
|
-
}
|
|
4492
|
-
}
|
|
4493
|
-
}
|
|
4494
|
-
destroy() {
|
|
4495
|
-
this.videoElement && (this.videoElement.src = "", this.videoElement.remove());
|
|
4496
|
-
}
|
|
4497
|
-
}
|
|
4498
|
-
const ba = 1e3, Ct = 10, Xt = 1e3, wa = 200, Ea = 0.2, ka = 0.5;
|
|
4499
|
-
function Ca(e) {
|
|
4500
|
-
return Math.sign(e) * Math.pow(Math.abs(e) / Xt, ka) * Ea;
|
|
4501
|
-
}
|
|
4502
|
-
class Aa extends Be {
|
|
4503
|
-
audioElement;
|
|
4504
|
-
isSeeking = !1;
|
|
4505
|
-
constructor(t, n, o) {
|
|
4506
|
-
super(t, n, o), this.clipElement = n;
|
|
4507
|
-
}
|
|
4508
|
-
updateAudioElement() {
|
|
4509
|
-
this.destroy(), this.audioElement = document.createElement("audio"), this.clipElement.replaceChildren(this.audioElement);
|
|
4510
|
-
}
|
|
4511
|
-
/**
|
|
4512
|
-
* Helper function to seek to a specified time.
|
|
4513
|
-
* Works with the update loop to poll until seeked event has fired.
|
|
4514
|
-
*/
|
|
4515
|
-
seekTo(t) {
|
|
4516
|
-
this.audioElement && (this.audioElement.addEventListener(
|
|
4517
|
-
"seeked",
|
|
4518
|
-
() => {
|
|
4519
|
-
this.isSeeking = !1;
|
|
4520
|
-
},
|
|
4521
|
-
{ once: !0, passive: !0 }
|
|
4522
|
-
), this.audioElement.currentTime = t / 1e3);
|
|
4523
|
-
}
|
|
4524
|
-
update() {
|
|
4525
|
-
if (this.isSeeking) return;
|
|
4526
|
-
this.delay = ba;
|
|
4527
|
-
const t = Ee(this._state, Date.now());
|
|
4528
|
-
if (t ? (!this.audioElement || !this.isConnected(this.audioElement)) && this.updateAudioElement() : this.destroy(), !t || !this.audioElement) return;
|
|
4529
|
-
const { t: n, rate: o, volume: r } = { ...we, ...t };
|
|
4530
|
-
this.audioElement.src.endsWith(this._state.file) || (this.audioElement.src = this._state.file), this.audioElement.volume !== r && (this.audioElement.volume = r), this.audioElement.paused && o > 0 && this.audioElement.play().catch(() => {
|
|
4531
|
-
});
|
|
4532
|
-
const c = this.audioElement.currentTime * 1e3 - n, l = Math.abs(c);
|
|
4533
|
-
switch (this.delay = 100, !0) {
|
|
4534
|
-
case l <= Ct:
|
|
4535
|
-
this.audioElement.playbackRate !== o && (this.audioElement.playbackRate = o);
|
|
4536
|
-
break;
|
|
4537
|
-
case (o > 0 && l > Ct && l <= Xt): {
|
|
4538
|
-
const p = Ca(c), h = Math.max(0, o - p);
|
|
4539
|
-
this.audioElement.playbackRate !== h && (this.audioElement.playbackRate = h);
|
|
4540
|
-
break;
|
|
4541
|
-
}
|
|
4542
|
-
default: {
|
|
4543
|
-
this.audioElement.playbackRate !== o && (this.audioElement.playbackRate = o), this.delay = 10, this.seekTo(n + o * (wa / 1e3));
|
|
4544
|
-
break;
|
|
4545
|
-
}
|
|
4546
|
-
}
|
|
4547
|
-
}
|
|
4548
|
-
destroy() {
|
|
4549
|
-
this.audioElement && (this.audioElement.src = "", this.audioElement.remove());
|
|
4550
|
-
}
|
|
4551
|
-
}
|
|
4552
|
-
const Ta = "data-clip-id";
|
|
4553
|
-
class Za {
|
|
4554
|
-
_state = {};
|
|
4555
|
-
setState(t) {
|
|
4556
|
-
this._state = t, this.update();
|
|
4557
|
-
}
|
|
4558
|
-
_element;
|
|
4559
|
-
get element() {
|
|
4560
|
-
return this._element;
|
|
4561
|
-
}
|
|
4562
|
-
resources = {};
|
|
4563
|
-
constructor(t) {
|
|
4564
|
-
this._element = document.createElement("div"), this._element.style.width = "100%", this._element.style.height = "100%", this._state = t || {}, this.update();
|
|
4565
|
-
}
|
|
4566
|
-
update() {
|
|
4567
|
-
Object.entries(this.resources).forEach(([n, { element: o, manager: r }]) => {
|
|
4568
|
-
n in this._state || (delete this.resources[n], o.remove(), r?.destroy());
|
|
4569
|
-
});
|
|
4570
|
-
const t = Object.keys(this._state).toSorted().map((n) => {
|
|
4571
|
-
const o = this.resources[n];
|
|
4572
|
-
if (o)
|
|
4573
|
-
return o.element;
|
|
4574
|
-
{
|
|
4575
|
-
const r = document.createElement("div");
|
|
4576
|
-
return r.setAttribute(Ta, n), this.resources[n] = { element: r }, r;
|
|
4577
|
-
}
|
|
4578
|
-
});
|
|
4579
|
-
this._element.replaceChildren(...t), Object.keys(this._state).toSorted().forEach((n) => {
|
|
4580
|
-
const o = this._state[n], r = this.resources[n];
|
|
4581
|
-
if (!r)
|
|
4582
|
-
throw new Error("Failed to create resource");
|
|
4583
|
-
if (r.manager)
|
|
4584
|
-
r.manager.setState(o);
|
|
4585
|
-
else
|
|
4586
|
-
switch (o.type) {
|
|
4587
|
-
case "image":
|
|
4588
|
-
r.manager = new da(this._element, r.element, o);
|
|
4589
|
-
break;
|
|
4590
|
-
case "audio":
|
|
4591
|
-
r.manager = new Aa(this._element, r.element, o);
|
|
4592
|
-
break;
|
|
4593
|
-
case "video":
|
|
4594
|
-
r.manager = new ya(this._element, r.element, o);
|
|
4595
|
-
break;
|
|
4596
|
-
}
|
|
4597
|
-
});
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4658
|
+
const xa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4601
4659
|
__proto__: null
|
|
4602
4660
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
4603
4661
|
export {
|
|
4604
|
-
|
|
4662
|
+
Pa as CogsAudioPlayer,
|
|
4605
4663
|
Cn as CogsConfigChangedEvent,
|
|
4606
|
-
|
|
4664
|
+
Ia as CogsConnection,
|
|
4607
4665
|
En as CogsConnectionCloseEvent,
|
|
4608
4666
|
wn as CogsConnectionOpenEvent,
|
|
4609
4667
|
Tn as CogsIncomingEvent,
|
|
@@ -4611,13 +4669,15 @@ export {
|
|
|
4611
4669
|
kn as CogsMessageEvent,
|
|
4612
4670
|
zn as CogsShowPhaseChangedEvent,
|
|
4613
4671
|
An as CogsStateChangedEvent,
|
|
4614
|
-
|
|
4672
|
+
Za as CogsVideoPlayer,
|
|
4673
|
+
Ca as DATA_CLIP_ID,
|
|
4615
4674
|
Ke as DataStoreItemEvent,
|
|
4616
4675
|
He as DataStoreItemsEvent,
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4676
|
+
xa as ManifestTypes,
|
|
4677
|
+
ka as MediaPreloader,
|
|
4678
|
+
$a as MediaSchema,
|
|
4679
|
+
Oa as SurfaceManager,
|
|
4620
4680
|
dn as assetUrl,
|
|
4621
4681
|
Ee as getStateAtTime,
|
|
4622
|
-
|
|
4682
|
+
za as preloadUrl
|
|
4623
4683
|
};
|