UNPKG

oh-my-live2d

Version:

live2d component for web. 看板娘组件, 支持 model2、model3、model4

1,525 lines 150 kB
import { E as Tt, u as Et, M as pt, T as Ie, P as Le, C as Te, O as Ee, a as vt } from "./oml2d.app.js"; var H = Math.pow, b = (s, t, e) => new Promise((i, r) => { var a = (l) => { try { o(e.next(l)); } catch (h) { r(h); } }, n = (l) => { try { o(e.throw(l)); } catch (h) { r(h); } }, o = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(a, n); o((e = e.apply(s, t)).next()); }); class Ft { constructor() { this._breathParameters = [], this._currentTime = 0; } static create() { return new Ft(); } setParameters(t) { this._breathParameters = t; } getParameters() { return this._breathParameters; } updateParameters(t, e) { this._currentTime += e; const i = this._currentTime * 2 * 3.14159; for (let r = 0; r < this._breathParameters.length; ++r) { const a = this._breathParameters[r]; t.addParameterValueById(a.parameterId, a.offset + a.peak * Math.sin(i / a.cycle), a.weight); } } } class st { constructor(t, e, i, r, a) { this.parameterId = t == null ? void 0 : t, this.offset = e == null ? 0 : e, this.peak = i == null ? 0 : i, this.cycle = r == null ? 0 : r, this.weight = a == null ? 0 : a; } } const St = class { static create(s) { return new St(s); } setBlinkingInterval(s) { this._blinkingIntervalSeconds = s; } setBlinkingSetting(s, t, e) { this._closingSeconds = s, this._closedSeconds = t, this._openingSeconds = e; } setParameterIds(s) { this._parameterIds = s; } getParameterIds() { return this._parameterIds; } updateParameters(s, t) { this._userTimeSeconds += t; let e, i = 0; switch (this._blinkingState) { case A.EyeState_Closing: i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closingSeconds, i >= 1 && (i = 1, this._blinkingState = A.EyeState_Closed, this._stateStartTimeSeconds = this._userTimeSeconds), e = 1 - i; break; case A.EyeState_Closed: i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closedSeconds, i >= 1 && (this._blinkingState = A.EyeState_Opening, this._stateStartTimeSeconds = this._userTimeSeconds), e = 0; break; case A.EyeState_Opening: i = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._openingSeconds, i >= 1 && (i = 1, this._blinkingState = A.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming()), e = i; break; case A.EyeState_Interval: this._nextBlinkingTime < this._userTimeSeconds && (this._blinkingState = A.EyeState_Closing, this._stateStartTimeSeconds = this._userTimeSeconds), e = 1; break; case A.EyeState_First: default: this._blinkingState = A.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming(), e = 1; break; } St.CloseIfZero || (e = -e); for (let r = 0; r < this._parameterIds.length; ++r) s.setParameterValueById(this._parameterIds[r], e); } constructor(s) { var t, e; this._blinkingState = A.EyeState_First, this._nextBlinkingTime = 0, this._stateStartTimeSeconds = 0, this._blinkingIntervalSeconds = 4, this._closingSeconds = 0.1, this._closedSeconds = 0.05, this._openingSeconds = 0.15, this._userTimeSeconds = 0, this._parameterIds = [], s != null && (this._parameterIds = (e = (t = s.getEyeBlinkParameters()) == null ? void 0 : t.slice()) != null ? e : this._parameterIds); } determinNextBlinkingTiming() { const s = Math.random(); return this._userTimeSeconds + s * (2 * this._blinkingIntervalSeconds - 1); } }; let ue = St; ue.CloseIfZero = !0; var A = /* @__PURE__ */ ((s) => (s[s.EyeState_First = 0] = "EyeState_First", s[s.EyeState_Interval = 1] = "EyeState_Interval", s[s.EyeState_Closing = 2] = "EyeState_Closing", s[s.EyeState_Closed = 3] = "EyeState_Closed", s[s.EyeState_Opening = 4] = "EyeState_Opening", s))(A || {}); const Fe = 1e-3, Wt = 0.5; class Dt { static create(t) { const e = new Dt(); typeof t.FadeInTime == "number" && (e._fadeTimeSeconds = t.FadeInTime, e._fadeTimeSeconds <= 0 && (e._fadeTimeSeconds = Wt)); const i = t.Groups, r = i.length; for (let a = 0; a < r; ++a) { const n = i[a], o = n.length; let l = 0; for (let h = 0; h < o; ++h) { const u = n[h], c = new _t(); c.partId = u.Id; const d = u.Link; if (d) { const _ = d.length; for (let p = 0; p < _; ++p) { const x = new _t(); x.partId = d[p], c.link.push(x); } } e._partGroups.push(c), ++l; } e._partGroupCounts.push(l); } return e; } updateParameters(t, e) { t != this._lastModel && this.reset(t), this._lastModel = t, e < 0 && (e = 0); let i = 0; for (let r = 0; r < this._partGroupCounts.length; r++) { const a = this._partGroupCounts[r]; this.doFade(t, e, i, a), i += a; } this.copyPartOpacities(t); } reset(t) { let e = 0; for (let i = 0; i < this._partGroupCounts.length; ++i) { const r = this._partGroupCounts[i]; for (let a = e; a < e + r; ++a) { this._partGroups[a].initialize(t); const n = this._partGroups[a].partIndex, o = this._partGroups[a].parameterIndex; if (!(n < 0)) { t.setPartOpacityByIndex(n, a == e ? 1 : 0), t.setParameterValueByIndex(o, a == e ? 1 : 0); for (let l = 0; l < this._partGroups[a].link.length; ++l) this._partGroups[a].link[l].initialize(t); } } e += r; } } copyPartOpacities(t) { for (let e = 0; e < this._partGroups.length; ++e) { const i = this._partGroups[e]; if (i.link.length == 0) continue; const r = this._partGroups[e].partIndex, a = t.getPartOpacityByIndex(r); for (let n = 0; n < i.link.length; ++n) { const l = i.link[n].partIndex; l < 0 || t.setPartOpacityByIndex(l, a); } } } doFade(t, e, i, r) { let a = -1, n = 1; const o = 0.5, l = 0.15; for (let h = i; h < i + r; ++h) { const u = this._partGroups[h].partIndex, c = this._partGroups[h].parameterIndex; if (t.getParameterValueByIndex(c) > Fe) { if (a >= 0) break; a = h, n = t.getPartOpacityByIndex(u), n += e / this._fadeTimeSeconds, n > 1 && (n = 1); } } a < 0 && (a = 0, n = 1); for (let h = i; h < i + r; ++h) { const u = this._partGroups[h].partIndex; if (a == h) t.setPartOpacityByIndex(u, n); else { let c = t.getPartOpacityByIndex(u), d; n < o ? d = n * (o - 1) / o + 1 : d = (1 - n) * o / (1 - o), (1 - d) * (1 - n) > l && (d = 1 - l / (1 - n)), c > d && (c = d), t.setPartOpacityByIndex(u, c); } } } constructor() { this._fadeTimeSeconds = Wt, this._lastModel = void 0, this._partGroups = [], this._partGroupCounts = []; } } class _t { constructor(t) { this.parameterIndex = 0, this.partIndex = 0, this.partId = "", this.link = [], t != null && this.assignment(t); } assignment(t) { return this.partId = t.partId, this.link = t.link.map((e) => e.clone()), this; } initialize(t) { this.parameterIndex = t.getParameterIndex(this.partId), this.partIndex = t.getPartIndex(this.partId), t.setParameterValueByIndex(this.parameterIndex, 1); } clone() { const t = new _t(); return t.partId = this.partId, t.parameterIndex = this.parameterIndex, t.partIndex = this.partIndex, t.link = this.link.map((e) => e.clone()), t; } } class y { constructor(t, e) { this.x = t || 0, this.y = e || 0; } add(t) { const e = new y(0, 0); return e.x = this.x + t.x, e.y = this.y + t.y, e; } substract(t) { const e = new y(0, 0); return e.x = this.x - t.x, e.y = this.y - t.y, e; } multiply(t) { const e = new y(0, 0); return e.x = this.x * t.x, e.y = this.y * t.y, e; } multiplyByScaler(t) { return this.multiply(new y(t, t)); } division(t) { const e = new y(0, 0); return e.x = this.x / t.x, e.y = this.y / t.y, e; } divisionByScalar(t) { return this.division(new y(t, t)); } getLength() { return Math.sqrt(this.x * this.x + this.y * this.y); } getDistanceWith(t) { return Math.sqrt((this.x - t.x) * (this.x - t.x) + (this.y - t.y) * (this.y - t.y)); } dot(t) { return this.x * t.x + this.y * t.y; } normalize() { const t = Math.pow(this.x * this.x + this.y * this.y, 0.5); this.x = this.x / t, this.y = this.y / t; } isEqual(t) { return this.x == t.x && this.y == t.y; } isNotEqual(t) { return !this.isEqual(t); } } const gt = class { static range(s, t, e) { return s < t ? s = t : s > e && (s = e), s; } static sin(s) { return Math.sin(s); } static cos(s) { return Math.cos(s); } static abs(s) { return Math.abs(s); } static sqrt(s) { return Math.sqrt(s); } static cbrt(s) { if (s === 0) return s; let t = s; const e = t < 0; e && (t = -t); let i; return t === 1 / 0 ? i = 1 / 0 : (i = Math.exp(Math.log(t) / 3), i = (t / (i * i) + 2 * i) / 3), e ? -i : i; } static getEasingSine(s) { return s < 0 ? 0 : s > 1 ? 1 : 0.5 - 0.5 * this.cos(s * Math.PI); } static max(s, t) { return s > t ? s : t; } static min(s, t) { return s > t ? t : s; } static degreesToRadian(s) { return s / 180 * Math.PI; } static radianToDegrees(s) { return s * 180 / Math.PI; } static directionToRadian(s, t) { const e = Math.atan2(t.y, t.x), i = Math.atan2(s.y, s.x); let r = e - i; for (; r < -Math.PI; ) r += Math.PI * 2; for (; r > Math.PI; ) r -= Math.PI * 2; return r; } static directionToDegrees(s, t) { const e = this.directionToRadian(s, t); let i = this.radianToDegrees(e); return t.x - s.x > 0 && (i = -i), i; } static radianToDirection(s) { const t = new y(); return t.x = this.sin(s), t.y = this.cos(s), t; } static quadraticEquation(s, t, e) { return this.abs(s) < gt.Epsilon ? this.abs(t) < gt.Epsilon ? -e : -e / t : -(t + this.sqrt(t * t - 4 * s * e)) / (2 * s); } static cardanoAlgorithmForBezier(s, t, e, i) { if (this.sqrt(s) < gt.Epsilon) return this.range(this.quadraticEquation(t, e, i), 0, 1); const r = t / s, a = e / s, n = i / s, o = (3 * a - r * r) / 3, l = o / 3, h = (2 * r * r * r - 9 * r * a + 27 * n) / 27, u = h / 2, c = u * u + l * l * l, d = 0.5, _ = d + 0.01; if (c < 0) { const f = -o / 3, v = f * f * f, P = this.sqrt(v), I = -h / (2 * P), M = this.range(I, -1, 1), V = Math.acos(M), N = 2 * this.cbrt(P), Yt = N * this.cos(V / 3) - r / 3; if (this.abs(Yt - d) < _) return this.range(Yt, 0, 1); const Ht = N * this.cos((V + 2 * Math.PI) / 3) - r / 3; if (this.abs(Ht - d) < _) return this.range(Ht, 0, 1); const we = N * this.cos((V + 4 * Math.PI) / 3) - r / 3; return this.range(we, 0, 1); } if (c == 0) { let f; u < 0 ? f = this.cbrt(-u) : f = -this.cbrt(u); const v = 2 * f - r / 3; if (this.abs(v - d) < _) return this.range(v, 0, 1); const P = -f - r / 3; return this.range(P, 0, 1); } const p = this.sqrt(c), x = this.cbrt(p - u), g = this.cbrt(p + u), m = x - g - r / 3; return this.range(m, 0, 1); } constructor() { } }; let S = gt; S.Epsilon = 1e-5; class R { constructor() { this._tr = new Float32Array(16), this.loadIdentity(); } static multiply(t, e, i) { const r = new Float32Array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]), a = 4; for (let n = 0; n < a; ++n) for (let o = 0; o < a; ++o) for (let l = 0; l < a; ++l) r[o + n * 4] += t[l + n * 4] * e[o + l * 4]; for (let n = 0; n < 16; ++n) i[n] = r[n]; } loadIdentity() { const t = new Float32Array([ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]); this.setMatrix(t); } setMatrix(t) { for (let e = 0; e < 16; ++e) this._tr[e] = t[e]; } getArray() { return this._tr; } getScaleX() { return this._tr[0]; } getScaleY() { return this._tr[5]; } getTranslateX() { return this._tr[12]; } getTranslateY() { return this._tr[13]; } transformX(t) { return this._tr[0] * t + this._tr[12]; } transformY(t) { return this._tr[5] * t + this._tr[13]; } invertTransformX(t) { return (t - this._tr[12]) / this._tr[0]; } invertTransformY(t) { return (t - this._tr[13]) / this._tr[5]; } translateRelative(t, e) { const i = new Float32Array([ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, t, e, 0, 1 ]); R.multiply(i, this._tr, this._tr); } translate(t, e) { this._tr[12] = t, this._tr[13] = e; } translateX(t) { this._tr[12] = t; } translateY(t) { this._tr[13] = t; } scaleRelative(t, e) { const i = new Float32Array([ t, 0, 0, 0, 0, e, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]); R.multiply(i, this._tr, this._tr); } scale(t, e) { this._tr[0] = t, this._tr[5] = e; } multiplyByMatrix(t) { R.multiply(t.getArray(), this._tr, this._tr); } clone() { const t = new R(); for (let e = 0; e < this._tr.length; e++) t._tr[e] = this._tr[e]; return t; } } class At { initialize(t) { this._model = t; } drawModel() { this.getModel() != null && this.doDrawModel(); } setMvpMatrix(t) { this._mvpMatrix4x4.setMatrix(t.getArray()); } getMvpMatrix() { return this._mvpMatrix4x4; } setModelColor(t, e, i, r) { t < 0 ? t = 0 : t > 1 && (t = 1), e < 0 ? e = 0 : e > 1 && (e = 1), i < 0 ? i = 0 : i > 1 && (i = 1), r < 0 ? r = 0 : r > 1 && (r = 1), this._modelColor.R = t, this._modelColor.G = e, this._modelColor.B = i, this._modelColor.A = r; } getModelColor() { return Object.assign({}, this._modelColor); } setIsPremultipliedAlpha(t) { this._isPremultipliedAlpha = t; } isPremultipliedAlpha() { return this._isPremultipliedAlpha; } setIsCulling(t) { this._isCulling = t; } isCulling() { return this._isCulling; } setAnisotropy(t) { this._anisortopy = t; } getAnisotropy() { return this._anisortopy; } getModel() { return this._model; } constructor() { this._isCulling = !1, this._isPremultipliedAlpha = !1, this._anisortopy = 0, this._modelColor = new at(), this._mvpMatrix4x4 = new R(), this._mvpMatrix4x4.loadIdentity(); } } var z = /* @__PURE__ */ ((s) => (s[s.CubismBlendMode_Normal = 0] = "CubismBlendMode_Normal", s[s.CubismBlendMode_Additive = 1] = "CubismBlendMode_Additive", s[s.CubismBlendMode_Multiplicative = 2] = "CubismBlendMode_Multiplicative", s))(z || {}); class at { constructor() { this.R = 1, this.G = 1, this.B = 1, this.A = 1; } } let O = !1, K = !1, Q; const xt = { vertexOffset: 0, vertexStep: 2 }; class ht { static startUp(t) { if (O) return rt("CubismFramework.startUp() is already done."), O; if (Live2DCubismCore._isStarted) return O = !0, !0; if (Live2DCubismCore._isStarted = !0, Q = t, Q && Live2DCubismCore.Logging.csmSetLogFunction(Q.logFunction), O = !0, O) { const e = Live2DCubismCore.Version.csmGetVersion(), i = (e & 4278190080) >> 24, r = (e & 16711680) >> 16, a = e & 65535, n = e; rt("Live2D Cubism Core version: {0}.{1}.{2} ({3})", ("00" + i).slice(-2), ("00" + r).slice(-2), ("0000" + a).slice(-4), n); } return rt("CubismFramework.startUp() is complete."), O; } static cleanUp() { O = !1, K = !1, Q = void 0; } static initialize() { if (!O) { nt("CubismFramework is not started."); return; } if (K) { nt("CubismFramework.initialize() skipped, already initialized."); return; } K = !0, rt("CubismFramework.initialize() is complete."); } static dispose() { if (!O) { nt("CubismFramework is not started."); return; } if (!K) { nt("CubismFramework.dispose() skipped, not initialized."); return; } At.staticRelease(), K = !1, rt("CubismFramework.dispose() is complete."); } static isStarted() { return O; } static isInitialized() { return K; } static coreLogFunction(t) { Live2DCubismCore.Logging.csmGetLogFunction() && Live2DCubismCore.Logging.csmGetLogFunction()(t); } static getLoggingLevel() { return Q != null ? Q.loggingLevel : Y.LogLevel_Off; } constructor() { } } var Y = /* @__PURE__ */ ((s) => (s[s.LogLevel_Verbose = 0] = "LogLevel_Verbose", s[s.LogLevel_Debug = 1] = "LogLevel_Debug", s[s.LogLevel_Info = 2] = "LogLevel_Info", s[s.LogLevel_Warning = 3] = "LogLevel_Warning", s[s.LogLevel_Error = 4] = "LogLevel_Error", s[s.LogLevel_Off = 5] = "LogLevel_Off", s))(Y || {}); const ct = () => { }; function ns(s, ...t) { dt.print(Y.LogLevel_Verbose, "[CSM][V]" + s + ` `, t); } function qt(s, ...t) { dt.print(Y.LogLevel_Debug, "[CSM][D]" + s + ` `, t); } function rt(s, ...t) { dt.print(Y.LogLevel_Info, "[CSM][I]" + s + ` `, t); } function nt(s, ...t) { dt.print(Y.LogLevel_Warning, "[CSM][W]" + s + ` `, t); } function tt(s, ...t) { dt.print(Y.LogLevel_Error, "[CSM][E]" + s + ` `, t); } class dt { static print(t, e, i) { if (t < ht.getLoggingLevel()) return; const r = ht.coreLogFunction; if (!r) return; const a = e.replace(/{(\d+)}/g, (n, o) => i[o]); r(a); } static dumpBytes(t, e, i) { for (let r = 0; r < i; r++) r % 16 == 0 && r > 0 ? this.print(t, ` `) : r % 8 == 0 && r > 0 && this.print(t, " "), this.print(t, "{0} ", [e[r] & 255]); this.print(t, ` `); } constructor() { } } class De { update() { this._model.update(), this._model.drawables.resetDynamicFlags(); } getCanvasWidth() { return this._model == null ? 0 : this._model.canvasinfo.CanvasWidth / this._model.canvasinfo.PixelsPerUnit; } getCanvasHeight() { return this._model == null ? 0 : this._model.canvasinfo.CanvasHeight / this._model.canvasinfo.PixelsPerUnit; } saveParameters() { const t = this._model.parameters.count, e = this._savedParameters.length; for (let i = 0; i < t; ++i) i < e ? this._savedParameters[i] = this._parameterValues[i] : this._savedParameters.push(this._parameterValues[i]); } getModel() { return this._model; } getPartIndex(t) { let e; const i = this._model.parts.count; for (e = 0; e < i; ++e) if (t == this._partIds[e]) return e; return t in this._notExistPartId ? this._notExistPartId[t] : (e = i + this._notExistPartId.length, this._notExistPartId[t] = e, this._notExistPartOpacities[e] = 0, e); } getPartCount() { return this._model.parts.count; } setPartOpacityByIndex(t, e) { if (t in this._notExistPartOpacities) { this._notExistPartOpacities[t] = e; return; } ct(0 <= t && t < this.getPartCount()), this._partOpacities[t] = e; } setPartOpacityById(t, e) { const i = this.getPartIndex(t); i < 0 || this.setPartOpacityByIndex(i, e); } getPartOpacityByIndex(t) { return t in this._notExistPartOpacities ? this._notExistPartOpacities[t] : (ct(0 <= t && t < this.getPartCount()), this._partOpacities[t]); } getPartOpacityById(t) { const e = this.getPartIndex(t); return e < 0 ? 0 : this.getPartOpacityByIndex(e); } getParameterIndex(t) { let e; const i = this._model.parameters.count; for (e = 0; e < i; ++e) if (t == this._parameterIds[e]) return e; return t in this._notExistParameterId ? this._notExistParameterId[t] : (e = this._model.parameters.count + Object.keys(this._notExistParameterId).length, this._notExistParameterId[t] = e, this._notExistParameterValues[e] = 0, e); } getParameterCount() { return this._model.parameters.count; } getParameterMaximumValue(t) { return this._model.parameters.maximumValues[t]; } getParameterMinimumValue(t) { return this._model.parameters.minimumValues[t]; } getParameterDefaultValue(t) { return this._model.parameters.defaultValues[t]; } getParameterValueByIndex(t) { return t in this._notExistParameterValues ? this._notExistParameterValues[t] : (ct(0 <= t && t < this.getParameterCount()), this._parameterValues[t]); } getParameterValueById(t) { const e = this.getParameterIndex(t); return this.getParameterValueByIndex(e); } setParameterValueByIndex(t, e, i = 1) { if (t in this._notExistParameterValues) { this._notExistParameterValues[t] = i == 1 ? e : this._notExistParameterValues[t] * (1 - i) + e * i; return; } ct(0 <= t && t < this.getParameterCount()), this._model.parameters.maximumValues[t] < e && (e = this._model.parameters.maximumValues[t]), this._model.parameters.minimumValues[t] > e && (e = this._model.parameters.minimumValues[t]), this._parameterValues[t] = i == 1 ? e : this._parameterValues[t] = this._parameterValues[t] * (1 - i) + e * i; } setParameterValueById(t, e, i = 1) { const r = this.getParameterIndex(t); this.setParameterValueByIndex(r, e, i); } addParameterValueByIndex(t, e, i = 1) { this.setParameterValueByIndex(t, this.getParameterValueByIndex(t) + e * i); } addParameterValueById(t, e, i = 1) { const r = this.getParameterIndex(t); this.addParameterValueByIndex(r, e, i); } multiplyParameterValueById(t, e, i = 1) { const r = this.getParameterIndex(t); this.multiplyParameterValueByIndex(r, e, i); } multiplyParameterValueByIndex(t, e, i = 1) { this.setParameterValueByIndex(t, this.getParameterValueByIndex(t) * (1 + (e - 1) * i)); } getDrawableIds() { return this._drawableIds.slice(); } getDrawableIndex(t) { const e = this._model.drawables.count; for (let i = 0; i < e; ++i) if (this._drawableIds[i] == t) return i; return -1; } getDrawableCount() { return this._model.drawables.count; } getDrawableId(t) { return this._model.drawables.ids[t]; } getDrawableRenderOrders() { return this._model.drawables.renderOrders; } getDrawableTextureIndices(t) { return this._model.drawables.textureIndices[t]; } getDrawableDynamicFlagVertexPositionsDidChange(t) { const e = this._model.drawables.dynamicFlags; return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(e[t]); } getDrawableVertexIndexCount(t) { return this._model.drawables.indexCounts[t]; } getDrawableVertexCount(t) { return this._model.drawables.vertexCounts[t]; } getDrawableVertices(t) { return this.getDrawableVertexPositions(t); } getDrawableVertexIndices(t) { return this._model.drawables.indices[t]; } getDrawableVertexPositions(t) { return this._model.drawables.vertexPositions[t]; } getDrawableVertexUvs(t) { return this._model.drawables.vertexUvs[t]; } getDrawableOpacity(t) { return this._model.drawables.opacities[t]; } getDrawableCulling(t) { const e = this._model.drawables.constantFlags; return !Live2DCubismCore.Utils.hasIsDoubleSidedBit(e[t]); } getDrawableBlendMode(t) { const e = this._model.drawables.constantFlags; return Live2DCubismCore.Utils.hasBlendAdditiveBit(e[t]) ? z.CubismBlendMode_Additive : Live2DCubismCore.Utils.hasBlendMultiplicativeBit(e[t]) ? z.CubismBlendMode_Multiplicative : z.CubismBlendMode_Normal; } getDrawableInvertedMaskBit(t) { const e = this._model.drawables.constantFlags; return Live2DCubismCore.Utils.hasIsInvertedMaskBit(e[t]); } getDrawableMasks() { return this._model.drawables.masks; } getDrawableMaskCounts() { return this._model.drawables.maskCounts; } isUsingMasking() { for (let t = 0; t < this._model.drawables.count; ++t) if (!(this._model.drawables.maskCounts[t] <= 0)) return !0; return !1; } getDrawableDynamicFlagIsVisible(t) { const e = this._model.drawables.dynamicFlags; return Live2DCubismCore.Utils.hasIsVisibleBit(e[t]); } getDrawableDynamicFlagVisibilityDidChange(t) { const e = this._model.drawables.dynamicFlags; return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(e[t]); } getDrawableDynamicFlagOpacityDidChange(t) { const e = this._model.drawables.dynamicFlags; return Live2DCubismCore.Utils.hasOpacityDidChangeBit(e[t]); } getDrawableDynamicFlagRenderOrderDidChange(t) { const e = this._model.drawables.dynamicFlags; return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(e[t]); } loadParameters() { let t = this._model.parameters.count; const e = this._savedParameters.length; t > e && (t = e); for (let i = 0; i < t; ++i) this._parameterValues[i] = this._savedParameters[i]; } initialize() { this._parameterValues = this._model.parameters.values, this._partOpacities = this._model.parts.opacities, this._parameterMaximumValues = this._model.parameters.maximumValues, this._parameterMinimumValues = this._model.parameters.minimumValues; { const t = this._model.parameters.ids, e = this._model.parameters.count; for (let i = 0; i < e; ++i) this._parameterIds.push(t[i]); } { const t = this._model.parts.ids, e = this._model.parts.count; for (let i = 0; i < e; ++i) this._partIds.push(t[i]); } { const t = this._model.drawables.ids, e = this._model.drawables.count; for (let i = 0; i < e; ++i) this._drawableIds.push(t[i]); } } constructor(t) { this._model = t, this._savedParameters = [], this._parameterIds = [], this._drawableIds = [], this._partIds = [], this._notExistPartId = {}, this._notExistParameterId = {}, this._notExistParameterValues = {}, this._notExistPartOpacities = {}, this.initialize(); } release() { this._model.release(), this._model = void 0; } } class Bt { static create(t) { const e = Live2DCubismCore.Moc.fromArrayBuffer(t); if (e) return new Bt(e); throw new Error("Unknown error"); } createModel() { let t; const e = Live2DCubismCore.Model.fromMoc(this._moc); if (e) return t = new De(e), ++this._modelCount, t; throw new Error("Unknown error"); } deleteModel(t) { t != null && --this._modelCount; } constructor(t) { this._moc = t, this._modelCount = 0; } release() { this._moc._release(), this._moc = void 0; } } class Ae { constructor(t, e) { this._json = t; } release() { this._json = void 0; } getUserDataCount() { return this._json.Meta.UserDataCount; } getTotalUserDataSize() { return this._json.Meta.TotalUserDataSize; } getUserDataTargetType(t) { return this._json.UserData[t].Target; } getUserDataId(t) { return this._json.UserData[t].Id; } getUserDataValue(t) { return this._json.UserData[t].Value; } } const Be = "ArtMesh"; class de { static create(t, e) { const i = new de(); return i.parseUserData(t, e), i; } getArtMeshUserDatas() { return this._artMeshUserDataNode; } parseUserData(t, e) { let i = new Ae(t, e); const r = Be, a = i.getUserDataCount(); for (let n = 0; n < a; n++) { const o = { targetId: i.getUserDataId(n), targetType: i.getUserDataTargetType(n), value: i.getUserDataValue(n) }; this._userDataNodes.push(o), o.targetType == r && this._artMeshUserDataNode.push(o); } i.release(); } constructor() { this._userDataNodes = [], this._artMeshUserDataNode = []; } release() { this._userDataNodes = null; } } class ce { constructor() { this._fadeInSeconds = -1, this._fadeOutSeconds = -1, this._weight = 1, this._offsetSeconds = 0, this._firedEventValues = []; } release() { this._weight = 0; } updateParameters(t, e, i) { if (!e.isAvailable() || e.isFinished()) return; if (!e.isStarted()) { e.setIsStarted(!0), e.setStartTime(i - this._offsetSeconds), e.setFadeInStartTime(i); const o = this.getDuration(); e.getEndTime() < 0 && e.setEndTime(o <= 0 ? -1 : e.getStartTime() + o); } let r = this._weight; const a = this._fadeInSeconds == 0 ? 1 : S.getEasingSine((i - e.getFadeInStartTime()) / this._fadeInSeconds), n = this._fadeOutSeconds == 0 || e.getEndTime() < 0 ? 1 : S.getEasingSine((e.getEndTime() - i) / this._fadeOutSeconds); r = r * a * n, e.setState(i, r), this.doUpdateParameters(t, i, r, e), e.getEndTime() > 0 && e.getEndTime() < i && e.setIsFinished(!0); } setFadeInTime(t) { this._fadeInSeconds = t; } setFadeOutTime(t) { this._fadeOutSeconds = t; } getFadeOutTime() { return this._fadeOutSeconds; } getFadeInTime() { return this._fadeInSeconds; } setWeight(t) { this._weight = t; } getWeight() { return this._weight; } getDuration() { return -1; } getLoopDuration() { return -1; } setOffsetTime(t) { this._offsetSeconds = t; } getFiredEvent(t, e) { return this._firedEventValues; } setFinishedMotionHandler(t) { this._onFinishedMotion = t; } getFinishedMotionHandler() { return this._onFinishedMotion; } } const $t = 1; class Rt extends ce { constructor() { super(), this._parameters = []; } static create(t) { const e = new Rt(), i = t.FadeInTime, r = t.FadeOutTime; e.setFadeInTime(i !== void 0 ? i : $t), e.setFadeOutTime(r !== void 0 ? r : $t); const a = t.Parameters || []; for (let n = 0; n < a.length; ++n) { const o = a[n], l = o.Id, h = o.Value; let u; switch (o.Blend) { case "Multiply": u = q.ExpressionBlendType_Multiply; break; case "Overwrite": u = q.ExpressionBlendType_Overwrite; break; case "Add": default: u = q.ExpressionBlendType_Add; break; } const c = { parameterId: l, blendType: u, value: h }; e._parameters.push(c); } return e; } doUpdateParameters(t, e, i, r) { for (let a = 0; a < this._parameters.length; ++a) { const n = this._parameters[a]; switch (n.blendType) { case q.ExpressionBlendType_Add: { t.addParameterValueById(n.parameterId, n.value, i); break; } case q.ExpressionBlendType_Multiply: { t.multiplyParameterValueById(n.parameterId, n.value, i); break; } case q.ExpressionBlendType_Overwrite: { t.setParameterValueById(n.parameterId, n.value, i); break; } } } } } var q = /* @__PURE__ */ ((s) => (s[s.ExpressionBlendType_Add = 0] = "ExpressionBlendType_Add", s[s.ExpressionBlendType_Multiply = 1] = "ExpressionBlendType_Multiply", s[s.ExpressionBlendType_Overwrite = 2] = "ExpressionBlendType_Overwrite", s))(q || {}), ut; ((s) => { s.supportMoreMaskDivisions = !0, s.setOpacityFromMotion = !1; })(ut || (ut = {})); var $ = /* @__PURE__ */ ((s) => (s[s.CubismMotionCurveTarget_Model = 0] = "CubismMotionCurveTarget_Model", s[s.CubismMotionCurveTarget_Parameter = 1] = "CubismMotionCurveTarget_Parameter", s[s.CubismMotionCurveTarget_PartOpacity = 2] = "CubismMotionCurveTarget_PartOpacity", s))($ || {}), k = /* @__PURE__ */ ((s) => (s[s.CubismMotionSegmentType_Linear = 0] = "CubismMotionSegmentType_Linear", s[s.CubismMotionSegmentType_Bezier = 1] = "CubismMotionSegmentType_Bezier", s[s.CubismMotionSegmentType_Stepped = 2] = "CubismMotionSegmentType_Stepped", s[s.CubismMotionSegmentType_InverseStepped = 3] = "CubismMotionSegmentType_InverseStepped", s))(k || {}); class j { constructor(t = 0, e = 0) { this.time = t, this.value = e; } } class Re { constructor() { this.basePointIndex = 0, this.segmentType = 0; } } class Oe { constructor() { this.id = "", this.type = 0, this.segmentCount = 0, this.baseSegmentIndex = 0, this.fadeInTime = 0, this.fadeOutTime = 0; } } class ke { constructor() { this.fireTime = 0, this.value = ""; } } class Ue { constructor() { this.duration = 0, this.loop = !1, this.curveCount = 0, this.eventCount = 0, this.fps = 0, this.curves = [], this.segments = [], this.points = [], this.events = []; } } class me { constructor(t) { this._json = t; } release() { this._json = void 0; } getMotionDuration() { return this._json.Meta.Duration; } isMotionLoop() { return this._json.Meta.Loop || !1; } getEvaluationOptionFlag(t) { return Ot.EvaluationOptionFlag_AreBeziersRistricted == t ? !!this._json.Meta.AreBeziersRestricted : !1; } getMotionCurveCount() { return this._json.Meta.CurveCount; } getMotionFps() { return this._json.Meta.Fps; } getMotionTotalSegmentCount() { return this._json.Meta.TotalSegmentCount; } getMotionTotalPointCount() { return this._json.Meta.TotalPointCount; } getMotionFadeInTime() { return this._json.Meta.FadeInTime; } getMotionFadeOutTime() { return this._json.Meta.FadeOutTime; } getMotionCurveTarget(t) { return this._json.Curves[t].Target; } getMotionCurveId(t) { return this._json.Curves[t].Id; } getMotionCurveFadeInTime(t) { return this._json.Curves[t].FadeInTime; } getMotionCurveFadeOutTime(t) { return this._json.Curves[t].FadeOutTime; } getMotionCurveSegmentCount(t) { return this._json.Curves[t].Segments.length; } getMotionCurveSegment(t, e) { return this._json.Curves[t].Segments[e]; } getEventCount() { return this._json.Meta.UserDataCount || 0; } getTotalEventValueSize() { return this._json.Meta.TotalUserDataSize; } getEventTime(t) { return this._json.UserData[t].Time; } getEventValue(t) { return this._json.UserData[t].Value; } } var Ot = /* @__PURE__ */ ((s) => (s[s.EvaluationOptionFlag_AreBeziersRistricted = 0] = "EvaluationOptionFlag_AreBeziersRistricted", s))(Ot || {}); const Ve = "EyeBlink", Ne = "LipSync", Ge = "Model", je = "Parameter", ze = "PartOpacity", Xe = !1; function B(s, t, e) { const i = new j(); return i.time = s.time + (t.time - s.time) * e, i.value = s.value + (t.value - s.value) * e, i; } function Ye(s, t) { let e = (t - s[0].time) / (s[1].time - s[0].time); return e < 0 && (e = 0), s[0].value + (s[1].value - s[0].value) * e; } function He(s, t) { let e = (t - s[0].time) / (s[3].time - s[0].time); e < 0 && (e = 0); const i = B(s[0], s[1], e), r = B(s[1], s[2], e), a = B(s[2], s[3], e), n = B(i, r, e), o = B(r, a, e); return B(n, o, e).value; } function We(s, t) { const e = t, i = s[0].time, r = s[3].time, a = s[1].time, n = s[2].time, o = r - 3 * n + 3 * a - i, l = 3 * n - 6 * a + 3 * i, h = 3 * a - 3 * i, u = i - e, c = S.cardanoAlgorithmForBezier(o, l, h, u), d = B(s[0], s[1], c), _ = B(s[1], s[2], c), p = B(s[2], s[3], c), x = B(d, _, c), g = B(_, p, c); return B(x, g, c).value; } function qe(s, t) { return s[0].value; } function $e(s, t) { return s[1].value; } function Pt(s, t, e) { const i = s.curves[t]; let r = -1; const a = i.baseSegmentIndex + i.segmentCount; let n = 0; for (let l = i.baseSegmentIndex; l < a; ++l) if (n = s.segments[l].basePointIndex + (s.segments[l].segmentType == k.CubismMotionSegmentType_Bezier ? 3 : 1), s.points[n].time > e) { r = l; break; } if (r == -1) return s.points[n].value; const o = s.segments[r]; return o.evaluate(s.points.slice(o.basePointIndex), e); } class kt extends ce { constructor() { super(), this._eyeBlinkParameterIds = [], this._lipSyncParameterIds = [], this._sourceFrameRate = 30, this._loopDurationSeconds = -1, this._isLoop = !1, this._isLoopFadeIn = !0, this._lastWeight = 0; } static create(t, e) { const i = new kt(); return i.parse(t), i._sourceFrameRate = i._motionData.fps, i._loopDurationSeconds = i._motionData.duration, i._onFinishedMotion = e, i; } doUpdateParameters(t, e, i, r) { this._modelCurveIdEyeBlink == null && (this._modelCurveIdEyeBlink = Ve), this._modelCurveIdLipSync == null && (this._modelCurveIdLipSync = Ne); let a = e - r.getStartTime(); a < 0 && (a = 0); let n = Number.MAX_VALUE, o = Number.MAX_VALUE; const l = 64; let h = 0, u = 0; this._eyeBlinkParameterIds.length > l && qt("too many eye blink targets : {0}", this._eyeBlinkParameterIds.length), this._lipSyncParameterIds.length > l && qt("too many lip sync targets : {0}", this._lipSyncParameterIds.length); const c = this._fadeInSeconds <= 0 ? 1 : S.getEasingSine((e - r.getFadeInStartTime()) / this._fadeInSeconds), d = this._fadeOutSeconds <= 0 || r.getEndTime() < 0 ? 1 : S.getEasingSine((r.getEndTime() - e) / this._fadeOutSeconds); let _, p, x, g = a; if (this._isLoop) for (; g > this._motionData.duration; ) g -= this._motionData.duration; const m = this._motionData.curves; for (p = 0; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_Model; ++p) _ = Pt(this._motionData, p, g), m[p].id == this._modelCurveIdEyeBlink ? o = _ : m[p].id == this._modelCurveIdLipSync && (n = _); for (; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_Parameter; ++p) { if (x = t.getParameterIndex(m[p].id), x == -1) continue; const f = t.getParameterValueByIndex(x); if (_ = Pt(this._motionData, p, g), o != Number.MAX_VALUE) { for (let P = 0; P < this._eyeBlinkParameterIds.length && P < l; ++P) if (this._eyeBlinkParameterIds[P] == m[p].id) { _ *= o, u |= 1 << P; break; } } if (n != Number.MAX_VALUE) { for (let P = 0; P < this._lipSyncParameterIds.length && P < l; ++P) if (this._lipSyncParameterIds[P] == m[p].id) { _ += n, h |= 1 << P; break; } } let v; if (m[p].fadeInTime < 0 && m[p].fadeOutTime < 0) v = f + (_ - f) * i; else { let P, I; m[p].fadeInTime < 0 ? P = c : P = m[p].fadeInTime == 0 ? 1 : S.getEasingSine((e - r.getFadeInStartTime()) / m[p].fadeInTime), m[p].fadeOutTime < 0 ? I = d : I = m[p].fadeOutTime == 0 || r.getEndTime() < 0 ? 1 : S.getEasingSine((r.getEndTime() - e) / m[p].fadeOutTime); const M = this._weight * P * I; v = f + (_ - f) * M; } t.setParameterValueByIndex(x, v, 1); } { if (o != Number.MAX_VALUE) for (let f = 0; f < this._eyeBlinkParameterIds.length && f < l; ++f) { const v = t.getParameterValueById(this._eyeBlinkParameterIds[f]); if (u >> f & 1) continue; const P = v + (o - v) * i; t.setParameterValueById(this._eyeBlinkParameterIds[f], P); } if (n != Number.MAX_VALUE) for (let f = 0; f < this._lipSyncParameterIds.length && f < l; ++f) { const v = t.getParameterValueById(this._lipSyncParameterIds[f]); if (h >> f & 1) continue; const P = v + (n - v) * i; t.setParameterValueById(this._lipSyncParameterIds[f], P); } } for (; p < this._motionData.curveCount && m[p].type == $.CubismMotionCurveTarget_PartOpacity; ++p) if (_ = Pt(this._motionData, p, g), ut.setOpacityFromMotion) t.setPartOpacityById(m[p].id, _); else { if (x = t.getParameterIndex(m[p].id), x == -1) continue; t.setParameterValueByIndex(x, _); } a >= this._motionData.duration && (this._isLoop ? (r.setStartTime(e), this._isLoopFadeIn && r.setFadeInStartTime(e)) : (this._onFinishedMotion && this._onFinishedMotion(this), r.setIsFinished(!0))), this._lastWeight = i; } setIsLoop(t) { this._isLoop = t; } isLoop() { return this._isLoop; } setIsLoopFadeIn(t) { this._isLoopFadeIn = t; } isLoopFadeIn() { return this._isLoopFadeIn; } getDuration() { return this._isLoop ? -1 : this._loopDurationSeconds; } getLoopDuration() { return this._loopDurationSeconds; } setParameterFadeInTime(t, e) { const i = this._motionData.curves; for (let r = 0; r < this._motionData.curveCount; ++r) if (t == i[r].id) { i[r].fadeInTime = e; return; } } setParameterFadeOutTime(t, e) { const i = this._motionData.curves; for (let r = 0; r < this._motionData.curveCount; ++r) if (t == i[r].id) { i[r].fadeOutTime = e; return; } } getParameterFadeInTime(t) { const e = this._motionData.curves; for (let i = 0; i < this._motionData.curveCount; ++i) if (t == e[i].id) return e[i].fadeInTime; return -1; } getParameterFadeOutTime(t) { const e = this._motionData.curves; for (let i = 0; i < this._motionData.curveCount; ++i) if (t == e[i].id) return e[i].fadeOutTime; return -1; } setEffectIds(t, e) { this._eyeBlinkParameterIds = t, this._lipSyncParameterIds = e; } release() { this._motionData = void 0; } parse(t) { this._motionData = new Ue(); let e = new me(t); this._motionData.duration = e.getMotionDuration(), this._motionData.loop = e.isMotionLoop(), this._motionData.curveCount = e.getMotionCurveCount(), this._motionData.fps = e.getMotionFps(), this._motionData.eventCount = e.getEventCount(); const i = e.getEvaluationOptionFlag(Ot.EvaluationOptionFlag_AreBeziersRistricted), r = e.getMotionFadeInTime(), a = e.getMotionFadeOutTime(); r !== void 0 ? this._fadeInSeconds = r < 0 ? 1 : r : this._fadeInSeconds = 1, a !== void 0 ? this._fadeOutSeconds = a < 0 ? 1 : a : this._fadeOutSeconds = 1, this._motionData.curves = Array.from({ length: this._motionData.curveCount }).map(() => new Oe()), this._motionData.segments = Array.from({ length: e.getMotionTotalSegmentCount() }).map(() => new Re()), this._motionData.events = Array.from({ length: this._motionData.eventCount }).map(() => new ke()), this._motionData.points = []; let n = 0, o = 0; for (let l = 0; l < this._motionData.curveCount; ++l) { const h = this._motionData.curves[l]; switch (e.getMotionCurveTarget(l)) { case Ge: h.type = $.CubismMotionCurveTarget_Model; break; case je: h.type = $.CubismMotionCurveTarget_Parameter; break; case ze: h.type = $.CubismMotionCurveTarget_PartOpacity; break; default: nt('Warning : Unable to get segment type from Curve! The number of "CurveCount" may be incorrect!'); } h.id = e.getMotionCurveId(l), h.baseSegmentIndex = o; const u = e.getMotionCurveFadeInTime(l), c = e.getMotionCurveFadeOutTime(l); h.fadeInTime = u !== void 0 ? u : -1, h.fadeOutTime = c !== void 0 ? c : -1; for (let d = 0; d < e.getMotionCurveSegmentCount(l); ) { switch (d == 0 ? (this._motionData.segments[o].basePointIndex = n, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d), e.getMotionCurveSegment(l, d + 1)), n += 1, d += 2) : this._motionData.segments[o].basePointIndex = n - 1, e.getMotionCurveSegment(l, d)) { case k.CubismMotionSegmentType_Linear: { this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Linear, this._motionData.segments[o].evaluate = Ye, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3; break; } case k.CubismMotionSegmentType_Bezier: { this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Bezier, i || Xe ? this._motionData.segments[o].evaluate = He : this._motionData.segments[o].evaluate = We, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), this._motionData.points[n + 1] = new j(e.getMotionCurveSegment(l, d + 3), e.getMotionCurveSegment(l, d + 4)), this._motionData.points[n + 2] = new j(e.getMotionCurveSegment(l, d + 5), e.getMotionCurveSegment(l, d + 6)), n += 3, d += 7; break; } case k.CubismMotionSegmentType_Stepped: { this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_Stepped, this._motionData.segments[o].evaluate = qe, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3; break; } case k.CubismMotionSegmentType_InverseStepped: { this._motionData.segments[o].segmentType = k.CubismMotionSegmentType_InverseStepped, this._motionData.segments[o].evaluate = $e, this._motionData.points[n] = new j(e.getMotionCurveSegment(l, d + 1), e.getMotionCurveSegment(l, d + 2)), n += 1, d += 3; break; } } ++h.segmentCount, ++o; } this._motionData.curves.push(h); } for (let l = 0; l < e.getEventCount(); ++l) this._motionData.events[l].fireTime = e.getEventTime(l), this._motionData.events[l].value = e.getEventValue(l); e.release(); } getFiredEvent(t, e) { this._firedEventValues.length = 0; for (let i = 0; i < this._motionData.eventCount; ++i) this._motionData.events[i].fireTime > t && this._motionData.events[i].fireTime <= e && this._firedEventValues.push(this._motionData.events[i].value); return this._firedEventValues; } } class Je { constructor() { this._autoDelete = !1, this._available = !0, this._finished = !1, this._started = !1, this._startTimeSeconds = -1, this._fadeInStartTimeSeconds = 0, this._endTimeSeconds = -1, this._stateTimeSeconds = 0, this._stateWeight = 0, this._lastEventCheckSeconds = 0, this._motionQueueEntryHandle = this, this._fadeOutSeconds = 0, this._isTriggeredFadeOut = !1; } release() { this._autoDelete && this._motion && this._motion.release(); } setFadeOut(t) { this._fadeOutSeconds = t, this._isTriggeredFadeOut = !0; } startFadeOut(t, e) { const i = e + t; this._isTriggeredFadeOut = !0, (this._endTimeSeconds < 0 || i < this._endTimeSeconds) && (this._endTimeSeconds = i); } isFinished() { return this._finished; } isStarted() { return this._started; } getStartTime() { return this._startTimeSeconds; } getFadeInStartTime() { return this._fadeInStartTimeSeconds; } getEndTime() { return this._endTimeSeconds; } setStartTime(t) { this._startTimeSeconds = t; } setFadeInStartTime(t) { this._fadeInStartTimeSeconds = t; } setEndTime(t) { this._endTimeSeconds = t; } setIsFinished(t) { this._finished = t; } setIsStarted(t) { this._started = t; } isAvailable() { return this._available; } setIsAvailable(t) { this._available = t; } setState(t, e) { this._stateTimeSeconds = t, this._stateWeight = e; } getStateTime() { return this._stateTimeSeconds; } getStateWeight() { return this._stateWeight; } getLastCheckEventSeconds() { return this._lastEventCheckSeconds; } setLastCheckEventSeconds(t) { this._lastEventCheckSeconds = t; } isTriggeredFadeOut() { return this._isTriggeredFadeOut; } getFadeOutSeconds() { return this._fadeOutSeconds; } } class Ut { constructor() { this._userTimeSeconds = 0, this._eventCustomData = null, this._motions = []; } release() { for (let t = 0; t < this._motions.length; ++t) this._motions[t] && this._motions[t].release(); this._motions = void 0; } startMotion(t, e, i) { if (t == null) return Ze; let r; for (let a = 0; a < this._motions.length; ++a) r = this._motions[a], r != null && r.setFadeOut(r._motion.getFadeOutTime()); return r = new Je(), r._autoDelete = e, r._motion = t, this._motions.push(r), r._motionQueueEntryHandle; } isFinished() { let t = 0; for (; t < this._motions.length; ) { const e = this._motions[t]; if (e == null) { this._motions.splice(t, 1); continue; } if (e._motion == null) { e.release(), this._motions.splice(t, 1); continue; } if (!e.isFinished()) return !1; t++; } return !0; } isFinishedByHandle(t) { for (let e = 0; e < this._motions.length; e++) { const i = this._motions[e]; if (i != null && i._motionQueueEntryHandle == t && !i.isFinished()) return !1; } return !0; } stopAllMotions() { for (let t = 0; t < this._motions.length; t++) { const e = this._motions[t]; e != null && e.release(); } this._motions = []; } getCubismMotionQueueEntry(t) { return this._motions.find((e) => e != null && e._motionQueueEntryHandle == t); } setEventCallback(t, e = null) { this._eventCallBack = t, this._eventCustomData = e; } doUpdateMotion(t, e) { let i = !1, r = 0; for (; r < this._motions.length; ) { const a = this._motions[r]; if (a == null) { this._motions.splice(r, 1); continue; } const n = a._motion; if (n == null) { a.release(), this._motions.splice(r, 1); continue; } n.updateParameters(t, a, e), i = !0; const o = n.getFiredEvent(a.getLastCheckEventSeconds() - a.getStartTime(), e - a.getStartTime()); for (let l = 0; l < o.length; ++l) this._eventCallBack(this, o[l], this._eventCustomData); a.setLastCheckEventSeconds(e), a.isFinished() ? (a.release(), this._motions.splice(r, 1)) : (a.isTriggeredFadeOut() && a.startFadeOut(a.getFadeOutSeconds(), e), r++); } return i; } } const Ze = -1; class os extends Ut { constructor() { super(), this._currentPriority = 0, this._reservePriority = 0; } getCurrentPriority() { return this._currentPr