@seayoo-web/pixi-live2d 0.0.10 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3116 @@
1
+ import { Bt as e, Kt as t, Lt as n, Rt as r, dn as i, jt as a, nn as o, nt as s } from "./core-DiacFOEI.js";
2
+ //#region ../../node_modules/.pnpm/pixi-live2d-display@0.4.0_d39e0d9e955e28505b3b8642eca0c111/node_modules/pixi-live2d-display/dist/cubism4.es.js
3
+ var c = Math.pow, l = (e, t, n) => new Promise((r, i) => {
4
+ var a = (e) => {
5
+ try {
6
+ s(n.next(e));
7
+ } catch (e) {
8
+ i(e);
9
+ }
10
+ }, o = (e) => {
11
+ try {
12
+ s(n.throw(e));
13
+ } catch (e) {
14
+ i(e);
15
+ }
16
+ }, s = (e) => e.done ? r(e.value) : Promise.resolve(e.value).then(a, o);
17
+ s((n = n.apply(e, t)).next());
18
+ }), u = class e {
19
+ constructor() {
20
+ this._breathParameters = [], this._currentTime = 0;
21
+ }
22
+ static create() {
23
+ return new e();
24
+ }
25
+ setParameters(e) {
26
+ this._breathParameters = e;
27
+ }
28
+ getParameters() {
29
+ return this._breathParameters;
30
+ }
31
+ updateParameters(e, t) {
32
+ this._currentTime += t;
33
+ let n = this._currentTime * 2 * 3.14159;
34
+ for (let t = 0; t < this._breathParameters.length; ++t) {
35
+ let r = this._breathParameters[t];
36
+ e.addParameterValueById(r.parameterId, r.offset + r.peak * Math.sin(n / r.cycle), r.weight);
37
+ }
38
+ }
39
+ }, d = class {
40
+ constructor(e, t, n, r, i) {
41
+ this.parameterId = e ?? void 0, this.offset = t ?? 0, this.peak = n ?? 0, this.cycle = r ?? 0, this.weight = i ?? 0;
42
+ }
43
+ }, f = class {
44
+ static create(e) {
45
+ return new f(e);
46
+ }
47
+ setBlinkingInterval(e) {
48
+ this._blinkingIntervalSeconds = e;
49
+ }
50
+ setBlinkingSetting(e, t, n) {
51
+ this._closingSeconds = e, this._closedSeconds = t, this._openingSeconds = n;
52
+ }
53
+ setParameterIds(e) {
54
+ this._parameterIds = e;
55
+ }
56
+ getParameterIds() {
57
+ return this._parameterIds;
58
+ }
59
+ updateParameters(e, t) {
60
+ this._userTimeSeconds += t;
61
+ let n, r = 0;
62
+ switch (this._blinkingState) {
63
+ case m.EyeState_Closing:
64
+ r = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closingSeconds, r >= 1 && (r = 1, this._blinkingState = m.EyeState_Closed, this._stateStartTimeSeconds = this._userTimeSeconds), n = 1 - r;
65
+ break;
66
+ case m.EyeState_Closed:
67
+ r = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._closedSeconds, r >= 1 && (this._blinkingState = m.EyeState_Opening, this._stateStartTimeSeconds = this._userTimeSeconds), n = 0;
68
+ break;
69
+ case m.EyeState_Opening:
70
+ r = (this._userTimeSeconds - this._stateStartTimeSeconds) / this._openingSeconds, r >= 1 && (r = 1, this._blinkingState = m.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming()), n = r;
71
+ break;
72
+ case m.EyeState_Interval:
73
+ this._nextBlinkingTime < this._userTimeSeconds && (this._blinkingState = m.EyeState_Closing, this._stateStartTimeSeconds = this._userTimeSeconds), n = 1;
74
+ break;
75
+ case m.EyeState_First:
76
+ default:
77
+ this._blinkingState = m.EyeState_Interval, this._nextBlinkingTime = this.determinNextBlinkingTiming(), n = 1;
78
+ break;
79
+ }
80
+ f.CloseIfZero || (n = -n);
81
+ for (let t = 0; t < this._parameterIds.length; ++t) e.setParameterValueById(this._parameterIds[t], n);
82
+ }
83
+ constructor(e) {
84
+ this._blinkingState = m.EyeState_First, this._nextBlinkingTime = 0, this._stateStartTimeSeconds = 0, this._blinkingIntervalSeconds = 4, this._closingSeconds = .1, this._closedSeconds = .05, this._openingSeconds = .15, this._userTimeSeconds = 0, this._parameterIds = [], e != null && (this._parameterIds = e.getEyeBlinkParameters()?.slice() ?? this._parameterIds);
85
+ }
86
+ determinNextBlinkingTiming() {
87
+ let e = Math.random();
88
+ return this._userTimeSeconds + e * (2 * this._blinkingIntervalSeconds - 1);
89
+ }
90
+ }, p = f;
91
+ p.CloseIfZero = !0;
92
+ var m = /* @__PURE__ */ ((e) => (e[e.EyeState_First = 0] = "EyeState_First", e[e.EyeState_Interval = 1] = "EyeState_Interval", e[e.EyeState_Closing = 2] = "EyeState_Closing", e[e.EyeState_Closed = 3] = "EyeState_Closed", e[e.EyeState_Opening = 4] = "EyeState_Opening", e))(m || {}), h = .001, g = .5, _ = class e {
93
+ static create(t) {
94
+ let n = new e();
95
+ typeof t.FadeInTime == "number" && (n._fadeTimeSeconds = t.FadeInTime, n._fadeTimeSeconds <= 0 && (n._fadeTimeSeconds = g));
96
+ let r = t.Groups, i = r.length;
97
+ for (let e = 0; e < i; ++e) {
98
+ let t = r[e], i = t.length, a = 0;
99
+ for (let e = 0; e < i; ++e) {
100
+ let r = t[e], i = new ee();
101
+ i.partId = r.Id;
102
+ let o = r.Link;
103
+ if (o) {
104
+ let e = o.length;
105
+ for (let t = 0; t < e; ++t) {
106
+ let e = new ee();
107
+ e.partId = o[t], i.link.push(e);
108
+ }
109
+ }
110
+ n._partGroups.push(i), ++a;
111
+ }
112
+ n._partGroupCounts.push(a);
113
+ }
114
+ return n;
115
+ }
116
+ updateParameters(e, t) {
117
+ e != this._lastModel && this.reset(e), this._lastModel = e, t < 0 && (t = 0);
118
+ let n = 0;
119
+ for (let r = 0; r < this._partGroupCounts.length; r++) {
120
+ let i = this._partGroupCounts[r];
121
+ this.doFade(e, t, n, i), n += i;
122
+ }
123
+ this.copyPartOpacities(e);
124
+ }
125
+ reset(e) {
126
+ let t = 0;
127
+ for (let n = 0; n < this._partGroupCounts.length; ++n) {
128
+ let r = this._partGroupCounts[n];
129
+ for (let n = t; n < t + r; ++n) {
130
+ this._partGroups[n].initialize(e);
131
+ let r = this._partGroups[n].partIndex, i = this._partGroups[n].parameterIndex;
132
+ if (!(r < 0)) {
133
+ e.setPartOpacityByIndex(r, +(n == t)), e.setParameterValueByIndex(i, +(n == t));
134
+ for (let t = 0; t < this._partGroups[n].link.length; ++t) this._partGroups[n].link[t].initialize(e);
135
+ }
136
+ }
137
+ t += r;
138
+ }
139
+ }
140
+ copyPartOpacities(e) {
141
+ for (let t = 0; t < this._partGroups.length; ++t) {
142
+ let n = this._partGroups[t];
143
+ if (n.link.length == 0) continue;
144
+ let r = this._partGroups[t].partIndex, i = e.getPartOpacityByIndex(r);
145
+ for (let t = 0; t < n.link.length; ++t) {
146
+ let r = n.link[t].partIndex;
147
+ r < 0 || e.setPartOpacityByIndex(r, i);
148
+ }
149
+ }
150
+ }
151
+ doFade(e, t, n, r) {
152
+ let i = -1, a = 1, o = .5, s = .15;
153
+ for (let o = n; o < n + r; ++o) {
154
+ let n = this._partGroups[o].partIndex, r = this._partGroups[o].parameterIndex;
155
+ if (e.getParameterValueByIndex(r) > h) {
156
+ if (i >= 0) break;
157
+ i = o, a = e.getPartOpacityByIndex(n), a += t / this._fadeTimeSeconds, a > 1 && (a = 1);
158
+ }
159
+ }
160
+ i < 0 && (i = 0, a = 1);
161
+ for (let t = n; t < n + r; ++t) {
162
+ let n = this._partGroups[t].partIndex;
163
+ if (i == t) e.setPartOpacityByIndex(n, a);
164
+ else {
165
+ let t = e.getPartOpacityByIndex(n), r;
166
+ r = a < o ? a * (o - 1) / o + 1 : (1 - a) * o / (1 - o), (1 - r) * (1 - a) > s && (r = 1 - s / (1 - a)), t > r && (t = r), e.setPartOpacityByIndex(n, t);
167
+ }
168
+ }
169
+ }
170
+ constructor() {
171
+ this._fadeTimeSeconds = g, this._lastModel = void 0, this._partGroups = [], this._partGroupCounts = [];
172
+ }
173
+ }, ee = class e {
174
+ constructor(e) {
175
+ this.parameterIndex = 0, this.partIndex = 0, this.partId = "", this.link = [], e != null && this.assignment(e);
176
+ }
177
+ assignment(e) {
178
+ return this.partId = e.partId, this.link = e.link.map((e) => e.clone()), this;
179
+ }
180
+ initialize(e) {
181
+ this.parameterIndex = e.getParameterIndex(this.partId), this.partIndex = e.getPartIndex(this.partId), e.setParameterValueByIndex(this.parameterIndex, 1);
182
+ }
183
+ clone() {
184
+ let t = new e();
185
+ return t.partId = this.partId, t.parameterIndex = this.parameterIndex, t.partIndex = this.partIndex, t.link = this.link.map((e) => e.clone()), t;
186
+ }
187
+ }, v = class e {
188
+ constructor(e, t) {
189
+ this.x = e || 0, this.y = t || 0;
190
+ }
191
+ add(t) {
192
+ let n = new e(0, 0);
193
+ return n.x = this.x + t.x, n.y = this.y + t.y, n;
194
+ }
195
+ substract(t) {
196
+ let n = new e(0, 0);
197
+ return n.x = this.x - t.x, n.y = this.y - t.y, n;
198
+ }
199
+ multiply(t) {
200
+ let n = new e(0, 0);
201
+ return n.x = this.x * t.x, n.y = this.y * t.y, n;
202
+ }
203
+ multiplyByScaler(t) {
204
+ return this.multiply(new e(t, t));
205
+ }
206
+ division(t) {
207
+ let n = new e(0, 0);
208
+ return n.x = this.x / t.x, n.y = this.y / t.y, n;
209
+ }
210
+ divisionByScalar(t) {
211
+ return this.division(new e(t, t));
212
+ }
213
+ getLength() {
214
+ return Math.sqrt(this.x * this.x + this.y * this.y);
215
+ }
216
+ getDistanceWith(e) {
217
+ return Math.sqrt((this.x - e.x) * (this.x - e.x) + (this.y - e.y) * (this.y - e.y));
218
+ }
219
+ dot(e) {
220
+ return this.x * e.x + this.y * e.y;
221
+ }
222
+ normalize() {
223
+ let e = (this.x * this.x + this.y * this.y) ** .5;
224
+ this.x /= e, this.y /= e;
225
+ }
226
+ isEqual(e) {
227
+ return this.x == e.x && this.y == e.y;
228
+ }
229
+ isNotEqual(e) {
230
+ return !this.isEqual(e);
231
+ }
232
+ }, te = class {
233
+ static range(e, t, n) {
234
+ return e < t ? e = t : e > n && (e = n), e;
235
+ }
236
+ static sin(e) {
237
+ return Math.sin(e);
238
+ }
239
+ static cos(e) {
240
+ return Math.cos(e);
241
+ }
242
+ static abs(e) {
243
+ return Math.abs(e);
244
+ }
245
+ static sqrt(e) {
246
+ return Math.sqrt(e);
247
+ }
248
+ static cbrt(e) {
249
+ if (e === 0) return e;
250
+ let t = e, n = t < 0;
251
+ n && (t = -t);
252
+ let r;
253
+ return t === Infinity ? r = Infinity : (r = Math.exp(Math.log(t) / 3), r = (t / (r * r) + 2 * r) / 3), n ? -r : r;
254
+ }
255
+ static getEasingSine(e) {
256
+ return e < 0 ? 0 : e > 1 ? 1 : .5 - .5 * this.cos(e * Math.PI);
257
+ }
258
+ static max(e, t) {
259
+ return e > t ? e : t;
260
+ }
261
+ static min(e, t) {
262
+ return e > t ? t : e;
263
+ }
264
+ static degreesToRadian(e) {
265
+ return e / 180 * Math.PI;
266
+ }
267
+ static radianToDegrees(e) {
268
+ return e * 180 / Math.PI;
269
+ }
270
+ static directionToRadian(e, t) {
271
+ let n = Math.atan2(t.y, t.x) - Math.atan2(e.y, e.x);
272
+ for (; n < -Math.PI;) n += Math.PI * 2;
273
+ for (; n > Math.PI;) n -= Math.PI * 2;
274
+ return n;
275
+ }
276
+ static directionToDegrees(e, t) {
277
+ let n = this.directionToRadian(e, t), r = this.radianToDegrees(n);
278
+ return t.x - e.x > 0 && (r = -r), r;
279
+ }
280
+ static radianToDirection(e) {
281
+ let t = new v();
282
+ return t.x = this.sin(e), t.y = this.cos(e), t;
283
+ }
284
+ static quadraticEquation(e, t, n) {
285
+ return this.abs(e) < te.Epsilon ? this.abs(t) < te.Epsilon ? -n : -n / t : -(t + this.sqrt(t * t - 4 * e * n)) / (2 * e);
286
+ }
287
+ static cardanoAlgorithmForBezier(e, t, n, r) {
288
+ if (this.sqrt(e) < te.Epsilon) return this.range(this.quadraticEquation(t, n, r), 0, 1);
289
+ let i = t / e, a = n / e, o = r / e, s = (3 * a - i * i) / 3, c = s / 3, l = (2 * i * i * i - 9 * i * a + 27 * o) / 27, u = l / 2, d = u * u + c * c * c, f = .5, p = f + .01;
290
+ if (d < 0) {
291
+ let e = -s / 3, t = e * e * e, n = this.sqrt(t), r = -l / (2 * n), a = this.range(r, -1, 1), o = Math.acos(a), c = 2 * this.cbrt(n), u = c * this.cos(o / 3) - i / 3;
292
+ if (this.abs(u - f) < p) return this.range(u, 0, 1);
293
+ let d = c * this.cos((o + 2 * Math.PI) / 3) - i / 3;
294
+ if (this.abs(d - f) < p) return this.range(d, 0, 1);
295
+ let m = c * this.cos((o + 4 * Math.PI) / 3) - i / 3;
296
+ return this.range(m, 0, 1);
297
+ }
298
+ if (d == 0) {
299
+ let e;
300
+ e = u < 0 ? this.cbrt(-u) : -this.cbrt(u);
301
+ let t = 2 * e - i / 3;
302
+ if (this.abs(t - f) < p) return this.range(t, 0, 1);
303
+ let n = -e - i / 3;
304
+ return this.range(n, 0, 1);
305
+ }
306
+ let m = this.sqrt(d), h = this.cbrt(m - u) - this.cbrt(m + u) - i / 3;
307
+ return this.range(h, 0, 1);
308
+ }
309
+ constructor() {}
310
+ }, y = te;
311
+ y.Epsilon = 1e-5;
312
+ var b = class e {
313
+ constructor() {
314
+ this._tr = new Float32Array(16), this.loadIdentity();
315
+ }
316
+ static multiply(e, t, n) {
317
+ let r = new Float32Array([
318
+ 0,
319
+ 0,
320
+ 0,
321
+ 0,
322
+ 0,
323
+ 0,
324
+ 0,
325
+ 0,
326
+ 0,
327
+ 0,
328
+ 0,
329
+ 0,
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 0
334
+ ]);
335
+ for (let n = 0; n < 4; ++n) for (let i = 0; i < 4; ++i) for (let a = 0; a < 4; ++a) r[i + n * 4] += e[a + n * 4] * t[i + a * 4];
336
+ for (let e = 0; e < 16; ++e) n[e] = r[e];
337
+ }
338
+ loadIdentity() {
339
+ let e = new Float32Array([
340
+ 1,
341
+ 0,
342
+ 0,
343
+ 0,
344
+ 0,
345
+ 1,
346
+ 0,
347
+ 0,
348
+ 0,
349
+ 0,
350
+ 1,
351
+ 0,
352
+ 0,
353
+ 0,
354
+ 0,
355
+ 1
356
+ ]);
357
+ this.setMatrix(e);
358
+ }
359
+ setMatrix(e) {
360
+ for (let t = 0; t < 16; ++t) this._tr[t] = e[t];
361
+ }
362
+ getArray() {
363
+ return this._tr;
364
+ }
365
+ getScaleX() {
366
+ return this._tr[0];
367
+ }
368
+ getScaleY() {
369
+ return this._tr[5];
370
+ }
371
+ getTranslateX() {
372
+ return this._tr[12];
373
+ }
374
+ getTranslateY() {
375
+ return this._tr[13];
376
+ }
377
+ transformX(e) {
378
+ return this._tr[0] * e + this._tr[12];
379
+ }
380
+ transformY(e) {
381
+ return this._tr[5] * e + this._tr[13];
382
+ }
383
+ invertTransformX(e) {
384
+ return (e - this._tr[12]) / this._tr[0];
385
+ }
386
+ invertTransformY(e) {
387
+ return (e - this._tr[13]) / this._tr[5];
388
+ }
389
+ translateRelative(t, n) {
390
+ let r = new Float32Array([
391
+ 1,
392
+ 0,
393
+ 0,
394
+ 0,
395
+ 0,
396
+ 1,
397
+ 0,
398
+ 0,
399
+ 0,
400
+ 0,
401
+ 1,
402
+ 0,
403
+ t,
404
+ n,
405
+ 0,
406
+ 1
407
+ ]);
408
+ e.multiply(r, this._tr, this._tr);
409
+ }
410
+ translate(e, t) {
411
+ this._tr[12] = e, this._tr[13] = t;
412
+ }
413
+ translateX(e) {
414
+ this._tr[12] = e;
415
+ }
416
+ translateY(e) {
417
+ this._tr[13] = e;
418
+ }
419
+ scaleRelative(t, n) {
420
+ let r = new Float32Array([
421
+ t,
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0,
426
+ n,
427
+ 0,
428
+ 0,
429
+ 0,
430
+ 0,
431
+ 1,
432
+ 0,
433
+ 0,
434
+ 0,
435
+ 0,
436
+ 1
437
+ ]);
438
+ e.multiply(r, this._tr, this._tr);
439
+ }
440
+ scale(e, t) {
441
+ this._tr[0] = e, this._tr[5] = t;
442
+ }
443
+ multiplyByMatrix(t) {
444
+ e.multiply(t.getArray(), this._tr, this._tr);
445
+ }
446
+ clone() {
447
+ let t = new e();
448
+ for (let e = 0; e < this._tr.length; e++) t._tr[e] = this._tr[e];
449
+ return t;
450
+ }
451
+ }, ne = class {
452
+ initialize(e) {
453
+ this._model = e;
454
+ }
455
+ drawModel() {
456
+ this.getModel() != null && this.doDrawModel();
457
+ }
458
+ setMvpMatrix(e) {
459
+ this._mvpMatrix4x4.setMatrix(e.getArray());
460
+ }
461
+ getMvpMatrix() {
462
+ return this._mvpMatrix4x4;
463
+ }
464
+ setModelColor(e, t, n, r) {
465
+ e < 0 ? e = 0 : e > 1 && (e = 1), t < 0 ? t = 0 : t > 1 && (t = 1), n < 0 ? n = 0 : n > 1 && (n = 1), r < 0 ? r = 0 : r > 1 && (r = 1), this._modelColor.R = e, this._modelColor.G = t, this._modelColor.B = n, this._modelColor.A = r;
466
+ }
467
+ getModelColor() {
468
+ return Object.assign({}, this._modelColor);
469
+ }
470
+ setIsPremultipliedAlpha(e) {
471
+ this._isPremultipliedAlpha = e;
472
+ }
473
+ isPremultipliedAlpha() {
474
+ return this._isPremultipliedAlpha;
475
+ }
476
+ setIsCulling(e) {
477
+ this._isCulling = e;
478
+ }
479
+ isCulling() {
480
+ return this._isCulling;
481
+ }
482
+ setAnisotropy(e) {
483
+ this._anisortopy = e;
484
+ }
485
+ getAnisotropy() {
486
+ return this._anisortopy;
487
+ }
488
+ getModel() {
489
+ return this._model;
490
+ }
491
+ constructor() {
492
+ this._isCulling = !1, this._isPremultipliedAlpha = !1, this._anisortopy = 0, this._modelColor = new S(), this._mvpMatrix4x4 = new b(), this._mvpMatrix4x4.loadIdentity();
493
+ }
494
+ }, x = /* @__PURE__ */ ((e) => (e[e.CubismBlendMode_Normal = 0] = "CubismBlendMode_Normal", e[e.CubismBlendMode_Additive = 1] = "CubismBlendMode_Additive", e[e.CubismBlendMode_Multiplicative = 2] = "CubismBlendMode_Multiplicative", e))(x || {}), S = class {
495
+ constructor() {
496
+ this.R = 1, this.G = 1, this.B = 1, this.A = 1;
497
+ }
498
+ }, C = !1, w = !1, T = void 0, re = {
499
+ vertexOffset: 0,
500
+ vertexStep: 2
501
+ }, E = class {
502
+ static startUp(e) {
503
+ if (C) return O("CubismFramework.startUp() is already done."), C;
504
+ if (Live2DCubismCore._isStarted) return C = !0, !0;
505
+ if (Live2DCubismCore._isStarted = !0, T = e, T && Live2DCubismCore.Logging.csmSetLogFunction(T.logFunction), C = !0, C) {
506
+ let e = Live2DCubismCore.Version.csmGetVersion(), t = (e & 4278190080) >> 24, n = (e & 16711680) >> 16, r = e & 65535, i = e;
507
+ O("Live2D Cubism Core version: {0}.{1}.{2} ({3})", ("00" + t).slice(-2), ("00" + n).slice(-2), ("0000" + r).slice(-4), i);
508
+ }
509
+ return O("CubismFramework.startUp() is complete."), C;
510
+ }
511
+ static cleanUp() {
512
+ C = !1, w = !1, T = void 0;
513
+ }
514
+ static initialize() {
515
+ if (!C) {
516
+ k("CubismFramework is not started.");
517
+ return;
518
+ }
519
+ if (w) {
520
+ k("CubismFramework.initialize() skipped, already initialized.");
521
+ return;
522
+ }
523
+ w = !0, O("CubismFramework.initialize() is complete.");
524
+ }
525
+ static dispose() {
526
+ if (!C) {
527
+ k("CubismFramework is not started.");
528
+ return;
529
+ }
530
+ if (!w) {
531
+ k("CubismFramework.dispose() skipped, not initialized.");
532
+ return;
533
+ }
534
+ ne.staticRelease(), w = !1, O("CubismFramework.dispose() is complete.");
535
+ }
536
+ static isStarted() {
537
+ return C;
538
+ }
539
+ static isInitialized() {
540
+ return w;
541
+ }
542
+ static coreLogFunction(e) {
543
+ Live2DCubismCore.Logging.csmGetLogFunction() && Live2DCubismCore.Logging.csmGetLogFunction()(e);
544
+ }
545
+ static getLoggingLevel() {
546
+ return T == null ? D.LogLevel_Off : T.loggingLevel;
547
+ }
548
+ constructor() {}
549
+ }, D = /* @__PURE__ */ ((e) => (e[e.LogLevel_Verbose = 0] = "LogLevel_Verbose", e[e.LogLevel_Debug = 1] = "LogLevel_Debug", e[e.LogLevel_Info = 2] = "LogLevel_Info", e[e.LogLevel_Warning = 3] = "LogLevel_Warning", e[e.LogLevel_Error = 4] = "LogLevel_Error", e[e.LogLevel_Off = 5] = "LogLevel_Off", e))(D || {}), ie = () => {};
550
+ function ae(e, ...t) {
551
+ j.print(D.LogLevel_Verbose, "[CSM][V]" + e + "\n", t);
552
+ }
553
+ function oe(e, ...t) {
554
+ j.print(D.LogLevel_Debug, "[CSM][D]" + e + "\n", t);
555
+ }
556
+ function O(e, ...t) {
557
+ j.print(D.LogLevel_Info, "[CSM][I]" + e + "\n", t);
558
+ }
559
+ function k(e, ...t) {
560
+ j.print(D.LogLevel_Warning, "[CSM][W]" + e + "\n", t);
561
+ }
562
+ function A(e, ...t) {
563
+ j.print(D.LogLevel_Error, "[CSM][E]" + e + "\n", t);
564
+ }
565
+ var j = class {
566
+ static print(e, t, n) {
567
+ if (e < E.getLoggingLevel()) return;
568
+ let r = E.coreLogFunction;
569
+ r && r(t.replace(/{(\d+)}/g, (e, t) => n[t]));
570
+ }
571
+ static dumpBytes(e, t, n) {
572
+ for (let r = 0; r < n; r++) r % 16 == 0 && r > 0 ? this.print(e, "\n") : r % 8 == 0 && r > 0 && this.print(e, " "), this.print(e, "{0} ", [t[r] & 255]);
573
+ this.print(e, "\n");
574
+ }
575
+ constructor() {}
576
+ }, se = class {
577
+ update() {
578
+ this._model.update(), this._model.drawables.resetDynamicFlags();
579
+ }
580
+ getCanvasWidth() {
581
+ return this._model == null ? 0 : this._model.canvasinfo.CanvasWidth / this._model.canvasinfo.PixelsPerUnit;
582
+ }
583
+ getCanvasHeight() {
584
+ return this._model == null ? 0 : this._model.canvasinfo.CanvasHeight / this._model.canvasinfo.PixelsPerUnit;
585
+ }
586
+ saveParameters() {
587
+ let e = this._model.parameters.count, t = this._savedParameters.length;
588
+ for (let n = 0; n < e; ++n) n < t ? this._savedParameters[n] = this._parameterValues[n] : this._savedParameters.push(this._parameterValues[n]);
589
+ }
590
+ getModel() {
591
+ return this._model;
592
+ }
593
+ getPartIndex(e) {
594
+ let t, n = this._model.parts.count;
595
+ for (t = 0; t < n; ++t) if (e == this._partIds[t]) return t;
596
+ return e in this._notExistPartId ? this._notExistPartId[e] : (t = n + this._notExistPartId.length, this._notExistPartId[e] = t, this._notExistPartOpacities[t] = 0, t);
597
+ }
598
+ getPartCount() {
599
+ return this._model.parts.count;
600
+ }
601
+ setPartOpacityByIndex(e, t) {
602
+ if (e in this._notExistPartOpacities) {
603
+ this._notExistPartOpacities[e] = t;
604
+ return;
605
+ }
606
+ 0 <= e && this.getPartCount(), this._partOpacities[e] = t;
607
+ }
608
+ setPartOpacityById(e, t) {
609
+ let n = this.getPartIndex(e);
610
+ n < 0 || this.setPartOpacityByIndex(n, t);
611
+ }
612
+ getPartOpacityByIndex(e) {
613
+ return e in this._notExistPartOpacities ? this._notExistPartOpacities[e] : (0 <= e && this.getPartCount(), this._partOpacities[e]);
614
+ }
615
+ getPartOpacityById(e) {
616
+ let t = this.getPartIndex(e);
617
+ return t < 0 ? 0 : this.getPartOpacityByIndex(t);
618
+ }
619
+ getParameterIndex(e) {
620
+ let t, n = this._model.parameters.count;
621
+ for (t = 0; t < n; ++t) if (e == this._parameterIds[t]) return t;
622
+ return e in this._notExistParameterId ? this._notExistParameterId[e] : (t = this._model.parameters.count + Object.keys(this._notExistParameterId).length, this._notExistParameterId[e] = t, this._notExistParameterValues[t] = 0, t);
623
+ }
624
+ getParameterCount() {
625
+ return this._model.parameters.count;
626
+ }
627
+ getParameterMaximumValue(e) {
628
+ return this._model.parameters.maximumValues[e];
629
+ }
630
+ getParameterMinimumValue(e) {
631
+ return this._model.parameters.minimumValues[e];
632
+ }
633
+ getParameterDefaultValue(e) {
634
+ return this._model.parameters.defaultValues[e];
635
+ }
636
+ getParameterValueByIndex(e) {
637
+ return e in this._notExistParameterValues ? this._notExistParameterValues[e] : (0 <= e && this.getParameterCount(), this._parameterValues[e]);
638
+ }
639
+ getParameterValueById(e) {
640
+ let t = this.getParameterIndex(e);
641
+ return this.getParameterValueByIndex(t);
642
+ }
643
+ setParameterValueByIndex(e, t, n = 1) {
644
+ if (e in this._notExistParameterValues) {
645
+ this._notExistParameterValues[e] = n == 1 ? t : this._notExistParameterValues[e] * (1 - n) + t * n;
646
+ return;
647
+ }
648
+ 0 <= e && this.getParameterCount(), this._model.parameters.maximumValues[e] < t && (t = this._model.parameters.maximumValues[e]), this._model.parameters.minimumValues[e] > t && (t = this._model.parameters.minimumValues[e]), this._parameterValues[e] = n == 1 ? t : this._parameterValues[e] = this._parameterValues[e] * (1 - n) + t * n;
649
+ }
650
+ setParameterValueById(e, t, n = 1) {
651
+ let r = this.getParameterIndex(e);
652
+ this.setParameterValueByIndex(r, t, n);
653
+ }
654
+ addParameterValueByIndex(e, t, n = 1) {
655
+ this.setParameterValueByIndex(e, this.getParameterValueByIndex(e) + t * n);
656
+ }
657
+ addParameterValueById(e, t, n = 1) {
658
+ let r = this.getParameterIndex(e);
659
+ this.addParameterValueByIndex(r, t, n);
660
+ }
661
+ multiplyParameterValueById(e, t, n = 1) {
662
+ let r = this.getParameterIndex(e);
663
+ this.multiplyParameterValueByIndex(r, t, n);
664
+ }
665
+ multiplyParameterValueByIndex(e, t, n = 1) {
666
+ this.setParameterValueByIndex(e, this.getParameterValueByIndex(e) * (1 + (t - 1) * n));
667
+ }
668
+ getDrawableIds() {
669
+ return this._drawableIds.slice();
670
+ }
671
+ getDrawableIndex(e) {
672
+ let t = this._model.drawables.count;
673
+ for (let n = 0; n < t; ++n) if (this._drawableIds[n] == e) return n;
674
+ return -1;
675
+ }
676
+ getDrawableCount() {
677
+ return this._model.drawables.count;
678
+ }
679
+ getDrawableId(e) {
680
+ return this._model.drawables.ids[e];
681
+ }
682
+ getDrawableRenderOrders() {
683
+ return this._model.drawables.renderOrders;
684
+ }
685
+ getDrawableTextureIndices(e) {
686
+ return this._model.drawables.textureIndices[e];
687
+ }
688
+ getDrawableDynamicFlagVertexPositionsDidChange(e) {
689
+ let t = this._model.drawables.dynamicFlags;
690
+ return Live2DCubismCore.Utils.hasVertexPositionsDidChangeBit(t[e]);
691
+ }
692
+ getDrawableVertexIndexCount(e) {
693
+ return this._model.drawables.indexCounts[e];
694
+ }
695
+ getDrawableVertexCount(e) {
696
+ return this._model.drawables.vertexCounts[e];
697
+ }
698
+ getDrawableVertices(e) {
699
+ return this.getDrawableVertexPositions(e);
700
+ }
701
+ getDrawableVertexIndices(e) {
702
+ return this._model.drawables.indices[e];
703
+ }
704
+ getDrawableVertexPositions(e) {
705
+ return this._model.drawables.vertexPositions[e];
706
+ }
707
+ getDrawableVertexUvs(e) {
708
+ return this._model.drawables.vertexUvs[e];
709
+ }
710
+ getDrawableOpacity(e) {
711
+ return this._model.drawables.opacities[e];
712
+ }
713
+ getDrawableCulling(e) {
714
+ let t = this._model.drawables.constantFlags;
715
+ return !Live2DCubismCore.Utils.hasIsDoubleSidedBit(t[e]);
716
+ }
717
+ getDrawableBlendMode(e) {
718
+ let t = this._model.drawables.constantFlags;
719
+ return Live2DCubismCore.Utils.hasBlendAdditiveBit(t[e]) ? x.CubismBlendMode_Additive : Live2DCubismCore.Utils.hasBlendMultiplicativeBit(t[e]) ? x.CubismBlendMode_Multiplicative : x.CubismBlendMode_Normal;
720
+ }
721
+ getDrawableInvertedMaskBit(e) {
722
+ let t = this._model.drawables.constantFlags;
723
+ return Live2DCubismCore.Utils.hasIsInvertedMaskBit(t[e]);
724
+ }
725
+ getDrawableMasks() {
726
+ return this._model.drawables.masks;
727
+ }
728
+ getDrawableMaskCounts() {
729
+ return this._model.drawables.maskCounts;
730
+ }
731
+ isUsingMasking() {
732
+ for (let e = 0; e < this._model.drawables.count; ++e) if (!(this._model.drawables.maskCounts[e] <= 0)) return !0;
733
+ return !1;
734
+ }
735
+ getDrawableDynamicFlagIsVisible(e) {
736
+ let t = this._model.drawables.dynamicFlags;
737
+ return Live2DCubismCore.Utils.hasIsVisibleBit(t[e]);
738
+ }
739
+ getDrawableDynamicFlagVisibilityDidChange(e) {
740
+ let t = this._model.drawables.dynamicFlags;
741
+ return Live2DCubismCore.Utils.hasVisibilityDidChangeBit(t[e]);
742
+ }
743
+ getDrawableDynamicFlagOpacityDidChange(e) {
744
+ let t = this._model.drawables.dynamicFlags;
745
+ return Live2DCubismCore.Utils.hasOpacityDidChangeBit(t[e]);
746
+ }
747
+ getDrawableDynamicFlagRenderOrderDidChange(e) {
748
+ let t = this._model.drawables.dynamicFlags;
749
+ return Live2DCubismCore.Utils.hasRenderOrderDidChangeBit(t[e]);
750
+ }
751
+ loadParameters() {
752
+ let e = this._model.parameters.count, t = this._savedParameters.length;
753
+ e > t && (e = t);
754
+ for (let t = 0; t < e; ++t) this._parameterValues[t] = this._savedParameters[t];
755
+ }
756
+ initialize() {
757
+ this._parameterValues = this._model.parameters.values, this._partOpacities = this._model.parts.opacities, this._parameterMaximumValues = this._model.parameters.maximumValues, this._parameterMinimumValues = this._model.parameters.minimumValues;
758
+ {
759
+ let e = this._model.parameters.ids, t = this._model.parameters.count;
760
+ for (let n = 0; n < t; ++n) this._parameterIds.push(e[n]);
761
+ }
762
+ {
763
+ let e = this._model.parts.ids, t = this._model.parts.count;
764
+ for (let n = 0; n < t; ++n) this._partIds.push(e[n]);
765
+ }
766
+ {
767
+ let e = this._model.drawables.ids, t = this._model.drawables.count;
768
+ for (let n = 0; n < t; ++n) this._drawableIds.push(e[n]);
769
+ }
770
+ }
771
+ constructor(e) {
772
+ this._model = e, this._savedParameters = [], this._parameterIds = [], this._drawableIds = [], this._partIds = [], this._notExistPartId = {}, this._notExistParameterId = {}, this._notExistParameterValues = {}, this._notExistPartOpacities = {}, this.initialize();
773
+ }
774
+ release() {
775
+ this._model.release(), this._model = void 0;
776
+ }
777
+ }, ce = class e {
778
+ static create(t) {
779
+ let n = Live2DCubismCore.Moc.fromArrayBuffer(t);
780
+ if (n) return new e(n);
781
+ throw Error("Unknown error");
782
+ }
783
+ createModel() {
784
+ let e, t = Live2DCubismCore.Model.fromMoc(this._moc);
785
+ if (t) return e = new se(t), ++this._modelCount, e;
786
+ throw Error("Unknown error");
787
+ }
788
+ deleteModel(e) {
789
+ e != null && --this._modelCount;
790
+ }
791
+ constructor(e) {
792
+ this._moc = e, this._modelCount = 0;
793
+ }
794
+ release() {
795
+ this._moc._release(), this._moc = void 0;
796
+ }
797
+ }, le = class {
798
+ constructor(e, t) {
799
+ this._json = e;
800
+ }
801
+ release() {
802
+ this._json = void 0;
803
+ }
804
+ getUserDataCount() {
805
+ return this._json.Meta.UserDataCount;
806
+ }
807
+ getTotalUserDataSize() {
808
+ return this._json.Meta.TotalUserDataSize;
809
+ }
810
+ getUserDataTargetType(e) {
811
+ return this._json.UserData[e].Target;
812
+ }
813
+ getUserDataId(e) {
814
+ return this._json.UserData[e].Id;
815
+ }
816
+ getUserDataValue(e) {
817
+ return this._json.UserData[e].Value;
818
+ }
819
+ }, ue = "ArtMesh", de = class e {
820
+ static create(t, n) {
821
+ let r = new e();
822
+ return r.parseUserData(t, n), r;
823
+ }
824
+ getArtMeshUserDatas() {
825
+ return this._artMeshUserDataNode;
826
+ }
827
+ parseUserData(e, t) {
828
+ let n = new le(e, t), r = ue, i = n.getUserDataCount();
829
+ for (let e = 0; e < i; e++) {
830
+ let t = {
831
+ targetId: n.getUserDataId(e),
832
+ targetType: n.getUserDataTargetType(e),
833
+ value: n.getUserDataValue(e)
834
+ };
835
+ this._userDataNodes.push(t), t.targetType == r && this._artMeshUserDataNode.push(t);
836
+ }
837
+ n.release();
838
+ }
839
+ constructor() {
840
+ this._userDataNodes = [], this._artMeshUserDataNode = [];
841
+ }
842
+ release() {
843
+ this._userDataNodes = null;
844
+ }
845
+ }, fe = class {
846
+ constructor() {
847
+ this._fadeInSeconds = -1, this._fadeOutSeconds = -1, this._weight = 1, this._offsetSeconds = 0, this._firedEventValues = [];
848
+ }
849
+ release() {
850
+ this._weight = 0;
851
+ }
852
+ updateParameters(e, t, n) {
853
+ if (!t.isAvailable() || t.isFinished()) return;
854
+ if (!t.isStarted()) {
855
+ t.setIsStarted(!0), t.setStartTime(n - this._offsetSeconds), t.setFadeInStartTime(n);
856
+ let e = this.getDuration();
857
+ t.getEndTime() < 0 && t.setEndTime(e <= 0 ? -1 : t.getStartTime() + e);
858
+ }
859
+ let r = this._weight, i = this._fadeInSeconds == 0 ? 1 : y.getEasingSine((n - t.getFadeInStartTime()) / this._fadeInSeconds), a = this._fadeOutSeconds == 0 || t.getEndTime() < 0 ? 1 : y.getEasingSine((t.getEndTime() - n) / this._fadeOutSeconds);
860
+ r = r * i * a, t.setState(n, r), this.doUpdateParameters(e, n, r, t), t.getEndTime() > 0 && t.getEndTime() < n && t.setIsFinished(!0);
861
+ }
862
+ setFadeInTime(e) {
863
+ this._fadeInSeconds = e;
864
+ }
865
+ setFadeOutTime(e) {
866
+ this._fadeOutSeconds = e;
867
+ }
868
+ getFadeOutTime() {
869
+ return this._fadeOutSeconds;
870
+ }
871
+ getFadeInTime() {
872
+ return this._fadeInSeconds;
873
+ }
874
+ setWeight(e) {
875
+ this._weight = e;
876
+ }
877
+ getWeight() {
878
+ return this._weight;
879
+ }
880
+ getDuration() {
881
+ return -1;
882
+ }
883
+ getLoopDuration() {
884
+ return -1;
885
+ }
886
+ setOffsetTime(e) {
887
+ this._offsetSeconds = e;
888
+ }
889
+ getFiredEvent(e, t) {
890
+ return this._firedEventValues;
891
+ }
892
+ setFinishedMotionHandler(e) {
893
+ this._onFinishedMotion = e;
894
+ }
895
+ getFinishedMotionHandler() {
896
+ return this._onFinishedMotion;
897
+ }
898
+ }, pe = 1, me = class e extends fe {
899
+ constructor() {
900
+ super(), this._parameters = [];
901
+ }
902
+ static create(t) {
903
+ let n = new e(), r = t.FadeInTime, i = t.FadeOutTime;
904
+ n.setFadeInTime(r === void 0 ? pe : r), n.setFadeOutTime(i === void 0 ? pe : i);
905
+ let a = t.Parameters || [];
906
+ for (let e = 0; e < a.length; ++e) {
907
+ let t = a[e], r = t.Id, i = t.Value, o;
908
+ switch (t.Blend) {
909
+ case "Multiply":
910
+ o = M.ExpressionBlendType_Multiply;
911
+ break;
912
+ case "Overwrite":
913
+ o = M.ExpressionBlendType_Overwrite;
914
+ break;
915
+ default:
916
+ o = M.ExpressionBlendType_Add;
917
+ break;
918
+ }
919
+ let s = {
920
+ parameterId: r,
921
+ blendType: o,
922
+ value: i
923
+ };
924
+ n._parameters.push(s);
925
+ }
926
+ return n;
927
+ }
928
+ doUpdateParameters(e, t, n, r) {
929
+ for (let t = 0; t < this._parameters.length; ++t) {
930
+ let r = this._parameters[t];
931
+ switch (r.blendType) {
932
+ case M.ExpressionBlendType_Add:
933
+ e.addParameterValueById(r.parameterId, r.value, n);
934
+ break;
935
+ case M.ExpressionBlendType_Multiply:
936
+ e.multiplyParameterValueById(r.parameterId, r.value, n);
937
+ break;
938
+ case M.ExpressionBlendType_Overwrite:
939
+ e.setParameterValueById(r.parameterId, r.value, n);
940
+ break;
941
+ }
942
+ }
943
+ }
944
+ }, M = /* @__PURE__ */ ((e) => (e[e.ExpressionBlendType_Add = 0] = "ExpressionBlendType_Add", e[e.ExpressionBlendType_Multiply = 1] = "ExpressionBlendType_Multiply", e[e.ExpressionBlendType_Overwrite = 2] = "ExpressionBlendType_Overwrite", e))(M || {}), he;
945
+ ((e) => {
946
+ e.supportMoreMaskDivisions = !0, e.setOpacityFromMotion = !1;
947
+ })(he ||= {});
948
+ var N = /* @__PURE__ */ ((e) => (e[e.CubismMotionCurveTarget_Model = 0] = "CubismMotionCurveTarget_Model", e[e.CubismMotionCurveTarget_Parameter = 1] = "CubismMotionCurveTarget_Parameter", e[e.CubismMotionCurveTarget_PartOpacity = 2] = "CubismMotionCurveTarget_PartOpacity", e))(N || {}), P = /* @__PURE__ */ ((e) => (e[e.CubismMotionSegmentType_Linear = 0] = "CubismMotionSegmentType_Linear", e[e.CubismMotionSegmentType_Bezier = 1] = "CubismMotionSegmentType_Bezier", e[e.CubismMotionSegmentType_Stepped = 2] = "CubismMotionSegmentType_Stepped", e[e.CubismMotionSegmentType_InverseStepped = 3] = "CubismMotionSegmentType_InverseStepped", e))(P || {}), F = class {
949
+ constructor(e = 0, t = 0) {
950
+ this.time = e, this.value = t;
951
+ }
952
+ }, ge = class {
953
+ constructor() {
954
+ this.basePointIndex = 0, this.segmentType = 0;
955
+ }
956
+ }, _e = class {
957
+ constructor() {
958
+ this.id = "", this.type = 0, this.segmentCount = 0, this.baseSegmentIndex = 0, this.fadeInTime = 0, this.fadeOutTime = 0;
959
+ }
960
+ }, ve = class {
961
+ constructor() {
962
+ this.fireTime = 0, this.value = "";
963
+ }
964
+ }, ye = class {
965
+ constructor() {
966
+ this.duration = 0, this.loop = !1, this.curveCount = 0, this.eventCount = 0, this.fps = 0, this.curves = [], this.segments = [], this.points = [], this.events = [];
967
+ }
968
+ }, be = class {
969
+ constructor(e) {
970
+ this._json = e;
971
+ }
972
+ release() {
973
+ this._json = void 0;
974
+ }
975
+ getMotionDuration() {
976
+ return this._json.Meta.Duration;
977
+ }
978
+ isMotionLoop() {
979
+ return this._json.Meta.Loop || !1;
980
+ }
981
+ getEvaluationOptionFlag(e) {
982
+ return xe.EvaluationOptionFlag_AreBeziersRistricted == e ? !!this._json.Meta.AreBeziersRestricted : !1;
983
+ }
984
+ getMotionCurveCount() {
985
+ return this._json.Meta.CurveCount;
986
+ }
987
+ getMotionFps() {
988
+ return this._json.Meta.Fps;
989
+ }
990
+ getMotionTotalSegmentCount() {
991
+ return this._json.Meta.TotalSegmentCount;
992
+ }
993
+ getMotionTotalPointCount() {
994
+ return this._json.Meta.TotalPointCount;
995
+ }
996
+ getMotionFadeInTime() {
997
+ return this._json.Meta.FadeInTime;
998
+ }
999
+ getMotionFadeOutTime() {
1000
+ return this._json.Meta.FadeOutTime;
1001
+ }
1002
+ getMotionCurveTarget(e) {
1003
+ return this._json.Curves[e].Target;
1004
+ }
1005
+ getMotionCurveId(e) {
1006
+ return this._json.Curves[e].Id;
1007
+ }
1008
+ getMotionCurveFadeInTime(e) {
1009
+ return this._json.Curves[e].FadeInTime;
1010
+ }
1011
+ getMotionCurveFadeOutTime(e) {
1012
+ return this._json.Curves[e].FadeOutTime;
1013
+ }
1014
+ getMotionCurveSegmentCount(e) {
1015
+ return this._json.Curves[e].Segments.length;
1016
+ }
1017
+ getMotionCurveSegment(e, t) {
1018
+ return this._json.Curves[e].Segments[t];
1019
+ }
1020
+ getEventCount() {
1021
+ return this._json.Meta.UserDataCount || 0;
1022
+ }
1023
+ getTotalEventValueSize() {
1024
+ return this._json.Meta.TotalUserDataSize;
1025
+ }
1026
+ getEventTime(e) {
1027
+ return this._json.UserData[e].Time;
1028
+ }
1029
+ getEventValue(e) {
1030
+ return this._json.UserData[e].Value;
1031
+ }
1032
+ }, xe = /* @__PURE__ */ ((e) => (e[e.EvaluationOptionFlag_AreBeziersRistricted = 0] = "EvaluationOptionFlag_AreBeziersRistricted", e))(xe || {}), Se = "EyeBlink", Ce = "LipSync", we = "Model", Te = "Parameter", Ee = "PartOpacity", De = !1;
1033
+ function I(e, t, n) {
1034
+ let r = new F();
1035
+ return r.time = e.time + (t.time - e.time) * n, r.value = e.value + (t.value - e.value) * n, r;
1036
+ }
1037
+ function Oe(e, t) {
1038
+ let n = (t - e[0].time) / (e[1].time - e[0].time);
1039
+ return n < 0 && (n = 0), e[0].value + (e[1].value - e[0].value) * n;
1040
+ }
1041
+ function ke(e, t) {
1042
+ let n = (t - e[0].time) / (e[3].time - e[0].time);
1043
+ n < 0 && (n = 0);
1044
+ let r = I(e[0], e[1], n), i = I(e[1], e[2], n), a = I(e[2], e[3], n);
1045
+ return I(I(r, i, n), I(i, a, n), n).value;
1046
+ }
1047
+ function Ae(e, t) {
1048
+ let n = t, r = e[0].time, i = e[3].time, a = e[1].time, o = e[2].time, s = i - 3 * o + 3 * a - r, c = 3 * o - 6 * a + 3 * r, l = 3 * a - 3 * r, u = r - n, d = y.cardanoAlgorithmForBezier(s, c, l, u), f = I(e[0], e[1], d), p = I(e[1], e[2], d), m = I(e[2], e[3], d);
1049
+ return I(I(f, p, d), I(p, m, d), d).value;
1050
+ }
1051
+ function je(e, t) {
1052
+ return e[0].value;
1053
+ }
1054
+ function Me(e, t) {
1055
+ return e[1].value;
1056
+ }
1057
+ function Ne(e, t, n) {
1058
+ let r = e.curves[t], i = -1, a = r.baseSegmentIndex + r.segmentCount, o = 0;
1059
+ for (let t = r.baseSegmentIndex; t < a; ++t) if (o = e.segments[t].basePointIndex + (e.segments[t].segmentType == P.CubismMotionSegmentType_Bezier ? 3 : 1), e.points[o].time > n) {
1060
+ i = t;
1061
+ break;
1062
+ }
1063
+ if (i == -1) return e.points[o].value;
1064
+ let s = e.segments[i];
1065
+ return s.evaluate(e.points.slice(s.basePointIndex), n);
1066
+ }
1067
+ var Pe = class e extends fe {
1068
+ constructor() {
1069
+ super(), this._eyeBlinkParameterIds = [], this._lipSyncParameterIds = [], this._sourceFrameRate = 30, this._loopDurationSeconds = -1, this._isLoop = !1, this._isLoopFadeIn = !0, this._lastWeight = 0;
1070
+ }
1071
+ static create(t, n) {
1072
+ let r = new e();
1073
+ return r.parse(t), r._sourceFrameRate = r._motionData.fps, r._loopDurationSeconds = r._motionData.duration, r._onFinishedMotion = n, r;
1074
+ }
1075
+ doUpdateParameters(e, t, n, r) {
1076
+ this._modelCurveIdEyeBlink ??= Se, this._modelCurveIdLipSync ??= Ce;
1077
+ let i = t - r.getStartTime();
1078
+ i < 0 && (i = 0);
1079
+ let a = Number.MAX_VALUE, o = Number.MAX_VALUE, s = 0, c = 0;
1080
+ this._eyeBlinkParameterIds.length > 64 && oe("too many eye blink targets : {0}", this._eyeBlinkParameterIds.length), this._lipSyncParameterIds.length > 64 && oe("too many lip sync targets : {0}", this._lipSyncParameterIds.length);
1081
+ let l = this._fadeInSeconds <= 0 ? 1 : y.getEasingSine((t - r.getFadeInStartTime()) / this._fadeInSeconds), u = this._fadeOutSeconds <= 0 || r.getEndTime() < 0 ? 1 : y.getEasingSine((r.getEndTime() - t) / this._fadeOutSeconds), d, f, p, m = i;
1082
+ if (this._isLoop) for (; m > this._motionData.duration;) m -= this._motionData.duration;
1083
+ let h = this._motionData.curves;
1084
+ for (f = 0; f < this._motionData.curveCount && h[f].type == N.CubismMotionCurveTarget_Model; ++f) d = Ne(this._motionData, f, m), h[f].id == this._modelCurveIdEyeBlink ? o = d : h[f].id == this._modelCurveIdLipSync && (a = d);
1085
+ for (; f < this._motionData.curveCount && h[f].type == N.CubismMotionCurveTarget_Parameter; ++f) {
1086
+ if (p = e.getParameterIndex(h[f].id), p == -1) continue;
1087
+ let i = e.getParameterValueByIndex(p);
1088
+ if (d = Ne(this._motionData, f, m), o != Number.MAX_VALUE) {
1089
+ for (let e = 0; e < this._eyeBlinkParameterIds.length && e < 64; ++e) if (this._eyeBlinkParameterIds[e] == h[f].id) {
1090
+ d *= o, c |= 1 << e;
1091
+ break;
1092
+ }
1093
+ }
1094
+ if (a != Number.MAX_VALUE) {
1095
+ for (let e = 0; e < this._lipSyncParameterIds.length && e < 64; ++e) if (this._lipSyncParameterIds[e] == h[f].id) {
1096
+ d += a, s |= 1 << e;
1097
+ break;
1098
+ }
1099
+ }
1100
+ let g;
1101
+ if (h[f].fadeInTime < 0 && h[f].fadeOutTime < 0) g = i + (d - i) * n;
1102
+ else {
1103
+ let e, n;
1104
+ e = h[f].fadeInTime < 0 ? l : h[f].fadeInTime == 0 ? 1 : y.getEasingSine((t - r.getFadeInStartTime()) / h[f].fadeInTime), n = h[f].fadeOutTime < 0 ? u : h[f].fadeOutTime == 0 || r.getEndTime() < 0 ? 1 : y.getEasingSine((r.getEndTime() - t) / h[f].fadeOutTime);
1105
+ let a = this._weight * e * n;
1106
+ g = i + (d - i) * a;
1107
+ }
1108
+ e.setParameterValueByIndex(p, g, 1);
1109
+ }
1110
+ if (o != Number.MAX_VALUE) for (let t = 0; t < this._eyeBlinkParameterIds.length && t < 64; ++t) {
1111
+ let r = e.getParameterValueById(this._eyeBlinkParameterIds[t]);
1112
+ if (c >> t & 1) continue;
1113
+ let i = r + (o - r) * n;
1114
+ e.setParameterValueById(this._eyeBlinkParameterIds[t], i);
1115
+ }
1116
+ if (a != Number.MAX_VALUE) for (let t = 0; t < this._lipSyncParameterIds.length && t < 64; ++t) {
1117
+ let r = e.getParameterValueById(this._lipSyncParameterIds[t]);
1118
+ if (s >> t & 1) continue;
1119
+ let i = r + (a - r) * n;
1120
+ e.setParameterValueById(this._lipSyncParameterIds[t], i);
1121
+ }
1122
+ for (; f < this._motionData.curveCount && h[f].type == N.CubismMotionCurveTarget_PartOpacity; ++f) if (d = Ne(this._motionData, f, m), he.setOpacityFromMotion) e.setPartOpacityById(h[f].id, d);
1123
+ else {
1124
+ if (p = e.getParameterIndex(h[f].id), p == -1) continue;
1125
+ e.setParameterValueByIndex(p, d);
1126
+ }
1127
+ i >= this._motionData.duration && (this._isLoop ? (r.setStartTime(t), this._isLoopFadeIn && r.setFadeInStartTime(t)) : (this._onFinishedMotion && this._onFinishedMotion(this), r.setIsFinished(!0))), this._lastWeight = n;
1128
+ }
1129
+ setIsLoop(e) {
1130
+ this._isLoop = e;
1131
+ }
1132
+ isLoop() {
1133
+ return this._isLoop;
1134
+ }
1135
+ setIsLoopFadeIn(e) {
1136
+ this._isLoopFadeIn = e;
1137
+ }
1138
+ isLoopFadeIn() {
1139
+ return this._isLoopFadeIn;
1140
+ }
1141
+ getDuration() {
1142
+ return this._isLoop ? -1 : this._loopDurationSeconds;
1143
+ }
1144
+ getLoopDuration() {
1145
+ return this._loopDurationSeconds;
1146
+ }
1147
+ setParameterFadeInTime(e, t) {
1148
+ let n = this._motionData.curves;
1149
+ for (let r = 0; r < this._motionData.curveCount; ++r) if (e == n[r].id) {
1150
+ n[r].fadeInTime = t;
1151
+ return;
1152
+ }
1153
+ }
1154
+ setParameterFadeOutTime(e, t) {
1155
+ let n = this._motionData.curves;
1156
+ for (let r = 0; r < this._motionData.curveCount; ++r) if (e == n[r].id) {
1157
+ n[r].fadeOutTime = t;
1158
+ return;
1159
+ }
1160
+ }
1161
+ getParameterFadeInTime(e) {
1162
+ let t = this._motionData.curves;
1163
+ for (let n = 0; n < this._motionData.curveCount; ++n) if (e == t[n].id) return t[n].fadeInTime;
1164
+ return -1;
1165
+ }
1166
+ getParameterFadeOutTime(e) {
1167
+ let t = this._motionData.curves;
1168
+ for (let n = 0; n < this._motionData.curveCount; ++n) if (e == t[n].id) return t[n].fadeOutTime;
1169
+ return -1;
1170
+ }
1171
+ setEffectIds(e, t) {
1172
+ this._eyeBlinkParameterIds = e, this._lipSyncParameterIds = t;
1173
+ }
1174
+ release() {
1175
+ this._motionData = void 0;
1176
+ }
1177
+ parse(e) {
1178
+ this._motionData = new ye();
1179
+ let t = new be(e);
1180
+ this._motionData.duration = t.getMotionDuration(), this._motionData.loop = t.isMotionLoop(), this._motionData.curveCount = t.getMotionCurveCount(), this._motionData.fps = t.getMotionFps(), this._motionData.eventCount = t.getEventCount();
1181
+ let n = t.getEvaluationOptionFlag(xe.EvaluationOptionFlag_AreBeziersRistricted), r = t.getMotionFadeInTime(), i = t.getMotionFadeOutTime();
1182
+ r === void 0 ? this._fadeInSeconds = 1 : this._fadeInSeconds = r < 0 ? 1 : r, i === void 0 ? this._fadeOutSeconds = 1 : this._fadeOutSeconds = i < 0 ? 1 : i, this._motionData.curves = Array.from({ length: this._motionData.curveCount }).map(() => new _e()), this._motionData.segments = Array.from({ length: t.getMotionTotalSegmentCount() }).map(() => new ge()), this._motionData.events = Array.from({ length: this._motionData.eventCount }).map(() => new ve()), this._motionData.points = [];
1183
+ let a = 0, o = 0;
1184
+ for (let e = 0; e < this._motionData.curveCount; ++e) {
1185
+ let r = this._motionData.curves[e];
1186
+ switch (t.getMotionCurveTarget(e)) {
1187
+ case we:
1188
+ r.type = N.CubismMotionCurveTarget_Model;
1189
+ break;
1190
+ case Te:
1191
+ r.type = N.CubismMotionCurveTarget_Parameter;
1192
+ break;
1193
+ case Ee:
1194
+ r.type = N.CubismMotionCurveTarget_PartOpacity;
1195
+ break;
1196
+ default: k("Warning : Unable to get segment type from Curve! The number of \"CurveCount\" may be incorrect!");
1197
+ }
1198
+ r.id = t.getMotionCurveId(e), r.baseSegmentIndex = o;
1199
+ let i = t.getMotionCurveFadeInTime(e), s = t.getMotionCurveFadeOutTime(e);
1200
+ r.fadeInTime = i === void 0 ? -1 : i, r.fadeOutTime = s === void 0 ? -1 : s;
1201
+ for (let i = 0; i < t.getMotionCurveSegmentCount(e);) {
1202
+ switch (i == 0 ? (this._motionData.segments[o].basePointIndex = a, this._motionData.points[a] = new F(t.getMotionCurveSegment(e, i), t.getMotionCurveSegment(e, i + 1)), a += 1, i += 2) : this._motionData.segments[o].basePointIndex = a - 1, t.getMotionCurveSegment(e, i)) {
1203
+ case P.CubismMotionSegmentType_Linear:
1204
+ this._motionData.segments[o].segmentType = P.CubismMotionSegmentType_Linear, this._motionData.segments[o].evaluate = Oe, this._motionData.points[a] = new F(t.getMotionCurveSegment(e, i + 1), t.getMotionCurveSegment(e, i + 2)), a += 1, i += 3;
1205
+ break;
1206
+ case P.CubismMotionSegmentType_Bezier:
1207
+ this._motionData.segments[o].segmentType = P.CubismMotionSegmentType_Bezier, n || De ? this._motionData.segments[o].evaluate = ke : this._motionData.segments[o].evaluate = Ae, this._motionData.points[a] = new F(t.getMotionCurveSegment(e, i + 1), t.getMotionCurveSegment(e, i + 2)), this._motionData.points[a + 1] = new F(t.getMotionCurveSegment(e, i + 3), t.getMotionCurveSegment(e, i + 4)), this._motionData.points[a + 2] = new F(t.getMotionCurveSegment(e, i + 5), t.getMotionCurveSegment(e, i + 6)), a += 3, i += 7;
1208
+ break;
1209
+ case P.CubismMotionSegmentType_Stepped:
1210
+ this._motionData.segments[o].segmentType = P.CubismMotionSegmentType_Stepped, this._motionData.segments[o].evaluate = je, this._motionData.points[a] = new F(t.getMotionCurveSegment(e, i + 1), t.getMotionCurveSegment(e, i + 2)), a += 1, i += 3;
1211
+ break;
1212
+ case P.CubismMotionSegmentType_InverseStepped:
1213
+ this._motionData.segments[o].segmentType = P.CubismMotionSegmentType_InverseStepped, this._motionData.segments[o].evaluate = Me, this._motionData.points[a] = new F(t.getMotionCurveSegment(e, i + 1), t.getMotionCurveSegment(e, i + 2)), a += 1, i += 3;
1214
+ break;
1215
+ }
1216
+ ++r.segmentCount, ++o;
1217
+ }
1218
+ this._motionData.curves.push(r);
1219
+ }
1220
+ for (let e = 0; e < t.getEventCount(); ++e) this._motionData.events[e].fireTime = t.getEventTime(e), this._motionData.events[e].value = t.getEventValue(e);
1221
+ t.release();
1222
+ }
1223
+ getFiredEvent(e, t) {
1224
+ this._firedEventValues.length = 0;
1225
+ for (let n = 0; n < this._motionData.eventCount; ++n) this._motionData.events[n].fireTime > e && this._motionData.events[n].fireTime <= t && this._firedEventValues.push(this._motionData.events[n].value);
1226
+ return this._firedEventValues;
1227
+ }
1228
+ }, Fe = class {
1229
+ constructor() {
1230
+ 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;
1231
+ }
1232
+ release() {
1233
+ this._autoDelete && this._motion && this._motion.release();
1234
+ }
1235
+ setFadeOut(e) {
1236
+ this._fadeOutSeconds = e, this._isTriggeredFadeOut = !0;
1237
+ }
1238
+ startFadeOut(e, t) {
1239
+ let n = t + e;
1240
+ this._isTriggeredFadeOut = !0, (this._endTimeSeconds < 0 || n < this._endTimeSeconds) && (this._endTimeSeconds = n);
1241
+ }
1242
+ isFinished() {
1243
+ return this._finished;
1244
+ }
1245
+ isStarted() {
1246
+ return this._started;
1247
+ }
1248
+ getStartTime() {
1249
+ return this._startTimeSeconds;
1250
+ }
1251
+ getFadeInStartTime() {
1252
+ return this._fadeInStartTimeSeconds;
1253
+ }
1254
+ getEndTime() {
1255
+ return this._endTimeSeconds;
1256
+ }
1257
+ setStartTime(e) {
1258
+ this._startTimeSeconds = e;
1259
+ }
1260
+ setFadeInStartTime(e) {
1261
+ this._fadeInStartTimeSeconds = e;
1262
+ }
1263
+ setEndTime(e) {
1264
+ this._endTimeSeconds = e;
1265
+ }
1266
+ setIsFinished(e) {
1267
+ this._finished = e;
1268
+ }
1269
+ setIsStarted(e) {
1270
+ this._started = e;
1271
+ }
1272
+ isAvailable() {
1273
+ return this._available;
1274
+ }
1275
+ setIsAvailable(e) {
1276
+ this._available = e;
1277
+ }
1278
+ setState(e, t) {
1279
+ this._stateTimeSeconds = e, this._stateWeight = t;
1280
+ }
1281
+ getStateTime() {
1282
+ return this._stateTimeSeconds;
1283
+ }
1284
+ getStateWeight() {
1285
+ return this._stateWeight;
1286
+ }
1287
+ getLastCheckEventSeconds() {
1288
+ return this._lastEventCheckSeconds;
1289
+ }
1290
+ setLastCheckEventSeconds(e) {
1291
+ this._lastEventCheckSeconds = e;
1292
+ }
1293
+ isTriggeredFadeOut() {
1294
+ return this._isTriggeredFadeOut;
1295
+ }
1296
+ getFadeOutSeconds() {
1297
+ return this._fadeOutSeconds;
1298
+ }
1299
+ }, Ie = class {
1300
+ constructor() {
1301
+ this._userTimeSeconds = 0, this._eventCustomData = null, this._motions = [];
1302
+ }
1303
+ release() {
1304
+ for (let e = 0; e < this._motions.length; ++e) this._motions[e] && this._motions[e].release();
1305
+ this._motions = void 0;
1306
+ }
1307
+ startMotion(e, t, n) {
1308
+ if (e == null) return -1;
1309
+ let r;
1310
+ for (let e = 0; e < this._motions.length; ++e) r = this._motions[e], r?.setFadeOut(r._motion.getFadeOutTime());
1311
+ return r = new Fe(), r._autoDelete = t, r._motion = e, this._motions.push(r), r._motionQueueEntryHandle;
1312
+ }
1313
+ isFinished() {
1314
+ let e = 0;
1315
+ for (; e < this._motions.length;) {
1316
+ let t = this._motions[e];
1317
+ if (t == null) {
1318
+ this._motions.splice(e, 1);
1319
+ continue;
1320
+ }
1321
+ if (t._motion == null) {
1322
+ t.release(), this._motions.splice(e, 1);
1323
+ continue;
1324
+ }
1325
+ if (!t.isFinished()) return !1;
1326
+ e++;
1327
+ }
1328
+ return !0;
1329
+ }
1330
+ isFinishedByHandle(e) {
1331
+ for (let t = 0; t < this._motions.length; t++) {
1332
+ let n = this._motions[t];
1333
+ if (n != null && n._motionQueueEntryHandle == e && !n.isFinished()) return !1;
1334
+ }
1335
+ return !0;
1336
+ }
1337
+ stopAllMotions() {
1338
+ for (let e = 0; e < this._motions.length; e++) this._motions[e]?.release();
1339
+ this._motions = [];
1340
+ }
1341
+ getCubismMotionQueueEntry(e) {
1342
+ return this._motions.find((t) => t != null && t._motionQueueEntryHandle == e);
1343
+ }
1344
+ setEventCallback(e, t = null) {
1345
+ this._eventCallBack = e, this._eventCustomData = t;
1346
+ }
1347
+ doUpdateMotion(e, t) {
1348
+ let n = !1, r = 0;
1349
+ for (; r < this._motions.length;) {
1350
+ let i = this._motions[r];
1351
+ if (i == null) {
1352
+ this._motions.splice(r, 1);
1353
+ continue;
1354
+ }
1355
+ let a = i._motion;
1356
+ if (a == null) {
1357
+ i.release(), this._motions.splice(r, 1);
1358
+ continue;
1359
+ }
1360
+ a.updateParameters(e, i, t), n = !0;
1361
+ let o = a.getFiredEvent(i.getLastCheckEventSeconds() - i.getStartTime(), t - i.getStartTime());
1362
+ for (let e = 0; e < o.length; ++e) this._eventCallBack(this, o[e], this._eventCustomData);
1363
+ i.setLastCheckEventSeconds(t), i.isFinished() ? (i.release(), this._motions.splice(r, 1)) : (i.isTriggeredFadeOut() && i.startFadeOut(i.getFadeOutSeconds(), t), r++);
1364
+ }
1365
+ return n;
1366
+ }
1367
+ }, Le = -1, Re = class extends Ie {
1368
+ constructor() {
1369
+ super(), this._currentPriority = 0, this._reservePriority = 0;
1370
+ }
1371
+ getCurrentPriority() {
1372
+ return this._currentPriority;
1373
+ }
1374
+ getReservePriority() {
1375
+ return this._reservePriority;
1376
+ }
1377
+ setReservePriority(e) {
1378
+ this._reservePriority = e;
1379
+ }
1380
+ startMotionPriority(e, t, n) {
1381
+ return n == this._reservePriority && (this._reservePriority = 0), this._currentPriority = n, super.startMotion(e, t, this._userTimeSeconds);
1382
+ }
1383
+ updateMotion(e, t) {
1384
+ this._userTimeSeconds += t;
1385
+ let n = super.doUpdateMotion(e, this._userTimeSeconds);
1386
+ return this.isFinished() && (this._currentPriority = 0), n;
1387
+ }
1388
+ reserveMotion(e) {
1389
+ return e <= this._reservePriority || e <= this._currentPriority ? !1 : (this._reservePriority = e, !0);
1390
+ }
1391
+ }, ze = /* @__PURE__ */ ((e) => (e[e.CubismPhysicsTargetType_Parameter = 0] = "CubismPhysicsTargetType_Parameter", e))(ze || {}), L = /* @__PURE__ */ ((e) => (e[e.CubismPhysicsSource_X = 0] = "CubismPhysicsSource_X", e[e.CubismPhysicsSource_Y = 1] = "CubismPhysicsSource_Y", e[e.CubismPhysicsSource_Angle = 2] = "CubismPhysicsSource_Angle", e))(L || {}), Be = class {
1392
+ constructor() {
1393
+ this.gravity = new v(0, 0), this.wind = new v(0, 0);
1394
+ }
1395
+ }, Ve = class {
1396
+ constructor() {
1397
+ this.initialPosition = new v(0, 0), this.position = new v(0, 0), this.lastPosition = new v(0, 0), this.lastGravity = new v(0, 0), this.force = new v(0, 0), this.velocity = new v(0, 0);
1398
+ }
1399
+ }, He = class {
1400
+ constructor() {
1401
+ this.normalizationPosition = {}, this.normalizationAngle = {};
1402
+ }
1403
+ }, Ue = class {
1404
+ constructor() {
1405
+ this.source = {};
1406
+ }
1407
+ }, We = class {
1408
+ constructor() {
1409
+ this.destination = {}, this.translationScale = new v(0, 0);
1410
+ }
1411
+ }, Ge = class {
1412
+ constructor() {
1413
+ this.settings = [], this.inputs = [], this.outputs = [], this.particles = [], this.gravity = new v(0, 0), this.wind = new v(0, 0);
1414
+ }
1415
+ }, Ke = class {
1416
+ constructor(e) {
1417
+ this._json = e;
1418
+ }
1419
+ release() {
1420
+ this._json = void 0;
1421
+ }
1422
+ getGravity() {
1423
+ let e = new v(0, 0);
1424
+ return e.x = this._json.Meta.EffectiveForces.Gravity.X, e.y = this._json.Meta.EffectiveForces.Gravity.Y, e;
1425
+ }
1426
+ getWind() {
1427
+ let e = new v(0, 0);
1428
+ return e.x = this._json.Meta.EffectiveForces.Wind.X, e.y = this._json.Meta.EffectiveForces.Wind.Y, e;
1429
+ }
1430
+ getSubRigCount() {
1431
+ return this._json.Meta.PhysicsSettingCount;
1432
+ }
1433
+ getTotalInputCount() {
1434
+ return this._json.Meta.TotalInputCount;
1435
+ }
1436
+ getTotalOutputCount() {
1437
+ return this._json.Meta.TotalOutputCount;
1438
+ }
1439
+ getVertexCount() {
1440
+ return this._json.Meta.VertexCount;
1441
+ }
1442
+ getNormalizationPositionMinimumValue(e) {
1443
+ return this._json.PhysicsSettings[e].Normalization.Position.Minimum;
1444
+ }
1445
+ getNormalizationPositionMaximumValue(e) {
1446
+ return this._json.PhysicsSettings[e].Normalization.Position.Maximum;
1447
+ }
1448
+ getNormalizationPositionDefaultValue(e) {
1449
+ return this._json.PhysicsSettings[e].Normalization.Position.Default;
1450
+ }
1451
+ getNormalizationAngleMinimumValue(e) {
1452
+ return this._json.PhysicsSettings[e].Normalization.Angle.Minimum;
1453
+ }
1454
+ getNormalizationAngleMaximumValue(e) {
1455
+ return this._json.PhysicsSettings[e].Normalization.Angle.Maximum;
1456
+ }
1457
+ getNormalizationAngleDefaultValue(e) {
1458
+ return this._json.PhysicsSettings[e].Normalization.Angle.Default;
1459
+ }
1460
+ getInputCount(e) {
1461
+ return this._json.PhysicsSettings[e].Input.length;
1462
+ }
1463
+ getInputWeight(e, t) {
1464
+ return this._json.PhysicsSettings[e].Input[t].Weight;
1465
+ }
1466
+ getInputReflect(e, t) {
1467
+ return this._json.PhysicsSettings[e].Input[t].Reflect;
1468
+ }
1469
+ getInputType(e, t) {
1470
+ return this._json.PhysicsSettings[e].Input[t].Type;
1471
+ }
1472
+ getInputSourceId(e, t) {
1473
+ return this._json.PhysicsSettings[e].Input[t].Source.Id;
1474
+ }
1475
+ getOutputCount(e) {
1476
+ return this._json.PhysicsSettings[e].Output.length;
1477
+ }
1478
+ getOutputVertexIndex(e, t) {
1479
+ return this._json.PhysicsSettings[e].Output[t].VertexIndex;
1480
+ }
1481
+ getOutputAngleScale(e, t) {
1482
+ return this._json.PhysicsSettings[e].Output[t].Scale;
1483
+ }
1484
+ getOutputWeight(e, t) {
1485
+ return this._json.PhysicsSettings[e].Output[t].Weight;
1486
+ }
1487
+ getOutputDestinationId(e, t) {
1488
+ return this._json.PhysicsSettings[e].Output[t].Destination.Id;
1489
+ }
1490
+ getOutputType(e, t) {
1491
+ return this._json.PhysicsSettings[e].Output[t].Type;
1492
+ }
1493
+ getOutputReflect(e, t) {
1494
+ return this._json.PhysicsSettings[e].Output[t].Reflect;
1495
+ }
1496
+ getParticleCount(e) {
1497
+ return this._json.PhysicsSettings[e].Vertices.length;
1498
+ }
1499
+ getParticleMobility(e, t) {
1500
+ return this._json.PhysicsSettings[e].Vertices[t].Mobility;
1501
+ }
1502
+ getParticleDelay(e, t) {
1503
+ return this._json.PhysicsSettings[e].Vertices[t].Delay;
1504
+ }
1505
+ getParticleAcceleration(e, t) {
1506
+ return this._json.PhysicsSettings[e].Vertices[t].Acceleration;
1507
+ }
1508
+ getParticleRadius(e, t) {
1509
+ return this._json.PhysicsSettings[e].Vertices[t].Radius;
1510
+ }
1511
+ getParticlePosition(e, t) {
1512
+ let n = new v(0, 0);
1513
+ return n.x = this._json.PhysicsSettings[e].Vertices[t].Position.X, n.y = this._json.PhysicsSettings[e].Vertices[t].Position.Y, n;
1514
+ }
1515
+ }, qe = "X", Je = "Y", Ye = "Angle", Xe = 5, Ze = 100, Qe = .001, $e = class e {
1516
+ static create(t) {
1517
+ let n = new e();
1518
+ return n.parse(t), n._physicsRig.gravity.y = 0, n;
1519
+ }
1520
+ evaluate(e, t) {
1521
+ let n, r, i, a, o = new v(), s, c, l, u, d, f, p, m;
1522
+ d = e.getModel().parameters.values, f = e.getModel().parameters.maximumValues, p = e.getModel().parameters.minimumValues, m = e.getModel().parameters.defaultValues;
1523
+ for (let h = 0; h < this._physicsRig.subRigCount; ++h) {
1524
+ n = { angle: 0 }, o.x = 0, o.y = 0, s = this._physicsRig.settings[h], c = this._physicsRig.inputs.slice(s.baseInputIndex), l = this._physicsRig.outputs.slice(s.baseOutputIndex), u = this._physicsRig.particles.slice(s.baseParticleIndex);
1525
+ for (let t = 0; t < s.inputCount; ++t) r = c[t].weight / Ze, c[t].sourceParameterIndex == -1 && (c[t].sourceParameterIndex = e.getParameterIndex(c[t].source.id)), c[t].getNormalizedParameterValue(o, n, d[c[t].sourceParameterIndex], p[c[t].sourceParameterIndex], f[c[t].sourceParameterIndex], m[c[t].sourceParameterIndex], s.normalizationPosition, s.normalizationAngle, c[t].reflect, r);
1526
+ i = y.degreesToRadian(-n.angle), o.x = o.x * y.cos(i) - o.y * y.sin(i), o.y = o.x * y.sin(i) + o.y * y.cos(i), ft(u, s.particleCount, o, n.angle, this._options.wind, Qe * s.normalizationPosition.maximum, t, Xe);
1527
+ for (let t = 0; t < s.outputCount; ++t) {
1528
+ let n = l[t].vertexIndex;
1529
+ if (n < 1 || n >= s.particleCount) break;
1530
+ l[t].destinationParameterIndex == -1 && (l[t].destinationParameterIndex = e.getParameterIndex(l[t].destination.id));
1531
+ let r = new v();
1532
+ r.x = u[n].position.x - u[n - 1].position.x, r.y = u[n].position.y - u[n - 1].position.y, a = l[t].getValue(r, u, n, l[t].reflect, this._options.gravity);
1533
+ let i = l[t].destinationParameterIndex, o = !Float32Array.prototype.slice && "subarray" in Float32Array.prototype ? JSON.parse(JSON.stringify(d.subarray(i))) : d.slice(i);
1534
+ pt(o, p[i], f[i], a, l[t]);
1535
+ for (let e = i, t = 0; e < d.length; e++, t++) d[e] = o[t];
1536
+ }
1537
+ }
1538
+ }
1539
+ setOptions(e) {
1540
+ this._options = e;
1541
+ }
1542
+ getOption() {
1543
+ return this._options;
1544
+ }
1545
+ constructor() {
1546
+ this._options = new et(), this._options.gravity.y = -1, this._options.gravity.x = 0, this._options.wind.x = 0, this._options.wind.y = 0;
1547
+ }
1548
+ release() {
1549
+ this._physicsRig = void 0;
1550
+ }
1551
+ parse(e) {
1552
+ this._physicsRig = new Ge();
1553
+ let t = new Ke(e);
1554
+ this._physicsRig.gravity = t.getGravity(), this._physicsRig.wind = t.getWind(), this._physicsRig.subRigCount = t.getSubRigCount();
1555
+ let n = 0, r = 0, i = 0;
1556
+ for (let e = 0; e < this._physicsRig.subRigCount; ++e) {
1557
+ let a = new He();
1558
+ a.normalizationPosition.minimum = t.getNormalizationPositionMinimumValue(e), a.normalizationPosition.maximum = t.getNormalizationPositionMaximumValue(e), a.normalizationPosition.defalut = t.getNormalizationPositionDefaultValue(e), a.normalizationAngle.minimum = t.getNormalizationAngleMinimumValue(e), a.normalizationAngle.maximum = t.getNormalizationAngleMaximumValue(e), a.normalizationAngle.defalut = t.getNormalizationAngleDefaultValue(e), a.inputCount = t.getInputCount(e), a.baseInputIndex = n, n += a.inputCount;
1559
+ for (let n = 0; n < a.inputCount; ++n) {
1560
+ let r = new Ue();
1561
+ switch (r.sourceParameterIndex = -1, r.weight = t.getInputWeight(e, n), r.reflect = t.getInputReflect(e, n), t.getInputType(e, n)) {
1562
+ case qe:
1563
+ r.type = L.CubismPhysicsSource_X, r.getNormalizedParameterValue = tt;
1564
+ break;
1565
+ case Je:
1566
+ r.type = L.CubismPhysicsSource_Y, r.getNormalizedParameterValue = nt;
1567
+ break;
1568
+ case Ye:
1569
+ r.type = L.CubismPhysicsSource_Angle, r.getNormalizedParameterValue = rt;
1570
+ break;
1571
+ }
1572
+ r.source.targetType = ze.CubismPhysicsTargetType_Parameter, r.source.id = t.getInputSourceId(e, n), this._physicsRig.inputs.push(r);
1573
+ }
1574
+ a.outputCount = t.getOutputCount(e), a.baseOutputIndex = r, r += a.outputCount;
1575
+ for (let n = 0; n < a.outputCount; ++n) {
1576
+ let r = new We();
1577
+ switch (r.destinationParameterIndex = -1, r.vertexIndex = t.getOutputVertexIndex(e, n), r.angleScale = t.getOutputAngleScale(e, n), r.weight = t.getOutputWeight(e, n), r.destination.targetType = ze.CubismPhysicsTargetType_Parameter, r.destination.id = t.getOutputDestinationId(e, n), t.getOutputType(e, n)) {
1578
+ case qe:
1579
+ r.type = L.CubismPhysicsSource_X, r.getValue = it, r.getScale = lt;
1580
+ break;
1581
+ case Je:
1582
+ r.type = L.CubismPhysicsSource_Y, r.getValue = at, r.getScale = ut;
1583
+ break;
1584
+ case Ye:
1585
+ r.type = L.CubismPhysicsSource_Angle, r.getValue = ot, r.getScale = dt;
1586
+ break;
1587
+ }
1588
+ r.reflect = t.getOutputReflect(e, n), this._physicsRig.outputs.push(r);
1589
+ }
1590
+ a.particleCount = t.getParticleCount(e), a.baseParticleIndex = i, i += a.particleCount;
1591
+ for (let n = 0; n < a.particleCount; ++n) {
1592
+ let r = new Ve();
1593
+ r.mobility = t.getParticleMobility(e, n), r.delay = t.getParticleDelay(e, n), r.acceleration = t.getParticleAcceleration(e, n), r.radius = t.getParticleRadius(e, n), r.position = t.getParticlePosition(e, n), this._physicsRig.particles.push(r);
1594
+ }
1595
+ this._physicsRig.settings.push(a);
1596
+ }
1597
+ this.initialize(), t.release();
1598
+ }
1599
+ initialize() {
1600
+ let e, t, n;
1601
+ for (let r = 0; r < this._physicsRig.subRigCount; ++r) {
1602
+ t = this._physicsRig.settings[r], e = this._physicsRig.particles.slice(t.baseParticleIndex), e[0].initialPosition = new v(0, 0), e[0].lastPosition = new v(e[0].initialPosition.x, e[0].initialPosition.y), e[0].lastGravity = new v(0, -1), e[0].lastGravity.y *= -1, e[0].velocity = new v(0, 0), e[0].force = new v(0, 0);
1603
+ for (let r = 1; r < t.particleCount; ++r) n = new v(0, 0), n.y = e[r].radius, e[r].initialPosition = new v(e[r - 1].initialPosition.x + n.x, e[r - 1].initialPosition.y + n.y), e[r].position = new v(e[r].initialPosition.x, e[r].initialPosition.y), e[r].lastPosition = new v(e[r].initialPosition.x, e[r].initialPosition.y), e[r].lastGravity = new v(0, -1), e[r].lastGravity.y *= -1, e[r].velocity = new v(0, 0), e[r].force = new v(0, 0);
1604
+ }
1605
+ }
1606
+ }, et = class {
1607
+ constructor() {
1608
+ this.gravity = new v(0, 0), this.wind = new v(0, 0);
1609
+ }
1610
+ };
1611
+ function tt(e, t, n, r, i, a, o, s, c, l) {
1612
+ e.x += mt(n, r, i, a, o.minimum, o.maximum, o.defalut, c) * l;
1613
+ }
1614
+ function nt(e, t, n, r, i, a, o, s, c, l) {
1615
+ e.y += mt(n, r, i, a, o.minimum, o.maximum, o.defalut, c) * l;
1616
+ }
1617
+ function rt(e, t, n, r, i, a, o, s, c, l) {
1618
+ t.angle += mt(n, r, i, a, s.minimum, s.maximum, s.defalut, c) * l;
1619
+ }
1620
+ function it(e, t, n, r, i) {
1621
+ let a = e.x;
1622
+ return r && (a *= -1), a;
1623
+ }
1624
+ function at(e, t, n, r, i) {
1625
+ let a = e.y;
1626
+ return r && (a *= -1), a;
1627
+ }
1628
+ function ot(e, t, n, r, i) {
1629
+ let a;
1630
+ return i = n >= 2 ? t[n - 1].position.substract(t[n - 2].position) : i.multiplyByScaler(-1), a = y.directionToRadian(i, e), r && (a *= -1), a;
1631
+ }
1632
+ function st(e, t) {
1633
+ return Math.abs(Math.max(e, t) - Math.min(e, t));
1634
+ }
1635
+ function ct(e, t) {
1636
+ return Math.min(e, t) + st(e, t) / 2;
1637
+ }
1638
+ function lt(e, t) {
1639
+ return e.x;
1640
+ }
1641
+ function ut(e, t) {
1642
+ return e.y;
1643
+ }
1644
+ function dt(e, t) {
1645
+ return t;
1646
+ }
1647
+ function ft(e, t, n, r, i, a, o, s) {
1648
+ let c, l, u, d, f = new v(0, 0), p = new v(0, 0), m = new v(0, 0), h = new v(0, 0);
1649
+ e[0].position = new v(n.x, n.y), c = y.degreesToRadian(r), d = y.radianToDirection(c), d.normalize();
1650
+ for (let n = 1; n < t; ++n) e[n].force = d.multiplyByScaler(e[n].acceleration).add(i), e[n].lastPosition = new v(e[n].position.x, e[n].position.y), l = e[n].delay * o * 30, f = e[n].position.substract(e[n - 1].position), u = y.directionToRadian(e[n].lastGravity, d) / s, f.x = y.cos(u) * f.x - f.y * y.sin(u), f.y = y.sin(u) * f.x + f.y * y.cos(u), e[n].position = e[n - 1].position.add(f), p = e[n].velocity.multiplyByScaler(l), m = e[n].force.multiplyByScaler(l).multiplyByScaler(l), e[n].position = e[n].position.add(p).add(m), h = e[n].position.substract(e[n - 1].position), h.normalize(), e[n].position = e[n - 1].position.add(h.multiplyByScaler(e[n].radius)), y.abs(e[n].position.x) < a && (e[n].position.x = 0), l != 0 && (e[n].velocity = e[n].position.substract(e[n].lastPosition), e[n].velocity = e[n].velocity.divisionByScalar(l), e[n].velocity = e[n].velocity.multiplyByScaler(e[n].mobility)), e[n].force = new v(0, 0), e[n].lastGravity = new v(d.x, d.y);
1651
+ }
1652
+ function pt(e, t, n, r, i) {
1653
+ let a, o, s;
1654
+ a = i.getScale(i.translationScale, i.angleScale), o = r * a, o < t ? (o < i.valueBelowMinimum && (i.valueBelowMinimum = o), o = t) : o > n && (o > i.valueExceededMaximum && (i.valueExceededMaximum = o), o = n), s = i.weight / Ze, s >= 1 || (o = e[0] * (1 - s) + o * s), e[0] = o;
1655
+ }
1656
+ function mt(e, t, n, r, i, a, o, s) {
1657
+ let c = 0, l = y.max(n, t);
1658
+ l < e && (e = l);
1659
+ let u = y.min(n, t);
1660
+ u > e && (e = u);
1661
+ let d = y.min(i, a), f = y.max(i, a), p = o, m = ct(u, l), h = e - m;
1662
+ switch (Math.sign(h)) {
1663
+ case 1: {
1664
+ let e = f - p, t = l - m;
1665
+ t != 0 && (c = e / t * h, c += p);
1666
+ break;
1667
+ }
1668
+ case -1: {
1669
+ let e = d - p, t = u - m;
1670
+ t != 0 && (c = e / t * h, c += p);
1671
+ break;
1672
+ }
1673
+ case 0:
1674
+ c = p;
1675
+ break;
1676
+ }
1677
+ return s ? c : c * -1;
1678
+ }
1679
+ var ht = class {
1680
+ constructor(e = 0, t = 0, n = 0, r = 0) {
1681
+ this.x = e, this.y = t, this.width = n, this.height = r;
1682
+ }
1683
+ getCenterX() {
1684
+ return this.x + .5 * this.width;
1685
+ }
1686
+ getCenterY() {
1687
+ return this.y + .5 * this.height;
1688
+ }
1689
+ getRight() {
1690
+ return this.x + this.width;
1691
+ }
1692
+ getBottom() {
1693
+ return this.y + this.height;
1694
+ }
1695
+ setRect(e) {
1696
+ this.x = e.x, this.y = e.y, this.width = e.width, this.height = e.height;
1697
+ }
1698
+ expand(e, t) {
1699
+ this.x -= e, this.y -= t, this.width += e * 2, this.height += t * 2;
1700
+ }
1701
+ }, gt = 4, _t = 10, vt, R, yt, bt = class {
1702
+ getChannelFlagAsColor(e) {
1703
+ return this._channelColors[e];
1704
+ }
1705
+ getMaskRenderTexture() {
1706
+ let e = 0;
1707
+ if (this._maskTexture && this._maskTexture.texture != 0 && (this._maskTexture.frameNo = this._currentFrameNo, e = this._maskTexture.texture), e == 0) {
1708
+ let t = this._clippingMaskBufferSize;
1709
+ this._colorBuffer = this.gl.createTexture(), this.gl.bindTexture(this.gl.TEXTURE_2D, this._colorBuffer), this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, t, t, 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, null), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MIN_FILTER, this.gl.LINEAR), this.gl.texParameteri(this.gl.TEXTURE_2D, this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR), this.gl.bindTexture(this.gl.TEXTURE_2D, null), e = this.gl.createFramebuffer(), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, e), this.gl.framebufferTexture2D(this.gl.FRAMEBUFFER, this.gl.COLOR_ATTACHMENT0, this.gl.TEXTURE_2D, this._colorBuffer, 0), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, yt), this._maskTexture = new xt(this._currentFrameNo, e);
1710
+ }
1711
+ return e;
1712
+ }
1713
+ setGL(e) {
1714
+ this.gl = e;
1715
+ }
1716
+ calcClippedDrawTotalBounds(e, t) {
1717
+ let n = Number.MAX_VALUE, r = Number.MAX_VALUE, i = Number.MIN_VALUE, a = Number.MIN_VALUE, o = t._clippedDrawableIndexList.length;
1718
+ for (let s = 0; s < o; s++) {
1719
+ let o = t._clippedDrawableIndexList[s], c = e.getDrawableVertexCount(o), l = e.getDrawableVertices(o), u = Number.MAX_VALUE, d = Number.MAX_VALUE, f = Number.MIN_VALUE, p = Number.MIN_VALUE, m = c * re.vertexStep;
1720
+ for (let e = re.vertexOffset; e < m; e += re.vertexStep) {
1721
+ let t = l[e], n = l[e + 1];
1722
+ t < u && (u = t), t > f && (f = t), n < d && (d = n), n > p && (p = n);
1723
+ }
1724
+ if (u != Number.MAX_VALUE) if (u < n && (n = u), d < r && (r = d), f > i && (i = f), p > a && (a = p), n == Number.MAX_VALUE) t._allClippedDrawRect.x = 0, t._allClippedDrawRect.y = 0, t._allClippedDrawRect.width = 0, t._allClippedDrawRect.height = 0, t._isUsing = !1;
1725
+ else {
1726
+ t._isUsing = !0;
1727
+ let e = i - n, o = a - r;
1728
+ t._allClippedDrawRect.x = n, t._allClippedDrawRect.y = r, t._allClippedDrawRect.width = e, t._allClippedDrawRect.height = o;
1729
+ }
1730
+ }
1731
+ }
1732
+ constructor() {
1733
+ this._maskRenderTexture = null, this._colorBuffer = null, this._currentFrameNo = 0, this._clippingMaskBufferSize = 256, this._clippingContextListForMask = [], this._clippingContextListForDraw = [], this._channelColors = [], this._tmpBoundsOnModel = new ht(), this._tmpMatrix = new b(), this._tmpMatrixForMask = new b(), this._tmpMatrixForDraw = new b();
1734
+ let e = new S();
1735
+ e.R = 1, e.G = 0, e.B = 0, e.A = 0, this._channelColors.push(e), e = new S(), e.R = 0, e.G = 1, e.B = 0, e.A = 0, this._channelColors.push(e), e = new S(), e.R = 0, e.G = 0, e.B = 1, e.A = 0, this._channelColors.push(e), e = new S(), e.R = 0, e.G = 0, e.B = 0, e.A = 1, this._channelColors.push(e);
1736
+ }
1737
+ release() {
1738
+ var e, t, n;
1739
+ let r = this;
1740
+ for (let t = 0; t < this._clippingContextListForMask.length; t++) this._clippingContextListForMask[t] && ((e = this._clippingContextListForMask[t]) == null || e.release());
1741
+ r._clippingContextListForMask = void 0, r._clippingContextListForDraw = void 0, this._maskTexture && ((t = this.gl) == null || t.deleteFramebuffer(this._maskTexture.texture), r._maskTexture = void 0), r._channelColors = void 0, (n = this.gl) == null || n.deleteTexture(this._colorBuffer), this._colorBuffer = null;
1742
+ }
1743
+ initialize(e, t, n, r) {
1744
+ for (let e = 0; e < t; e++) {
1745
+ if (r[e] <= 0) {
1746
+ this._clippingContextListForDraw.push(null);
1747
+ continue;
1748
+ }
1749
+ let t = this.findSameClip(n[e], r[e]);
1750
+ t ?? (t = new St(this, n[e], r[e]), this._clippingContextListForMask.push(t)), t.addClippedDrawable(e), this._clippingContextListForDraw.push(t);
1751
+ }
1752
+ }
1753
+ setupClippingContext(e, t) {
1754
+ this._currentFrameNo++;
1755
+ let n = 0;
1756
+ for (let t = 0; t < this._clippingContextListForMask.length; t++) {
1757
+ let r = this._clippingContextListForMask[t];
1758
+ this.calcClippedDrawTotalBounds(e, r), r._isUsing && n++;
1759
+ }
1760
+ if (n > 0) {
1761
+ this.gl.viewport(0, 0, this._clippingMaskBufferSize, this._clippingMaskBufferSize), this._maskRenderTexture = this.getMaskRenderTexture(), t.getMvpMatrix(), t.preDraw(), this.setupLayoutBounds(n), this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, this._maskRenderTexture), this.gl.clearColor(1, 1, 1, 1), this.gl.clear(this.gl.COLOR_BUFFER_BIT);
1762
+ for (let n = 0; n < this._clippingContextListForMask.length; n++) {
1763
+ let r = this._clippingContextListForMask[n], i = r._allClippedDrawRect, a = r._layoutBounds, o = .05;
1764
+ this._tmpBoundsOnModel.setRect(i), this._tmpBoundsOnModel.expand(i.width * o, i.height * o);
1765
+ let s = a.width / this._tmpBoundsOnModel.width, c = a.height / this._tmpBoundsOnModel.height;
1766
+ this._tmpMatrix.loadIdentity(), this._tmpMatrix.translateRelative(-1, -1), this._tmpMatrix.scaleRelative(2, 2), this._tmpMatrix.translateRelative(a.x, a.y), this._tmpMatrix.scaleRelative(s, c), this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x, -this._tmpBoundsOnModel.y), this._tmpMatrixForMask.setMatrix(this._tmpMatrix.getArray()), this._tmpMatrix.loadIdentity(), this._tmpMatrix.translateRelative(a.x, a.y), this._tmpMatrix.scaleRelative(s, c), this._tmpMatrix.translateRelative(-this._tmpBoundsOnModel.x, -this._tmpBoundsOnModel.y), this._tmpMatrixForDraw.setMatrix(this._tmpMatrix.getArray()), r._matrixForMask.setMatrix(this._tmpMatrixForMask.getArray()), r._matrixForDraw.setMatrix(this._tmpMatrixForDraw.getArray());
1767
+ let l = r._clippingIdCount;
1768
+ for (let n = 0; n < l; n++) {
1769
+ let i = r._clippingIdList[n];
1770
+ e.getDrawableDynamicFlagVertexPositionsDidChange(i) && (t.setIsCulling(e.getDrawableCulling(i) != 0), t.setClippingContextBufferForMask(r), t.drawMesh(e.getDrawableTextureIndices(i), e.getDrawableVertexIndexCount(i), e.getDrawableVertexCount(i), e.getDrawableVertexIndices(i), e.getDrawableVertices(i), e.getDrawableVertexUvs(i), e.getDrawableOpacity(i), x.CubismBlendMode_Normal, !1));
1771
+ }
1772
+ }
1773
+ this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, yt), t.setClippingContextBufferForMask(null), this.gl.viewport(R[0], R[1], R[2], R[3]);
1774
+ }
1775
+ }
1776
+ findSameClip(e, t) {
1777
+ for (let n = 0; n < this._clippingContextListForMask.length; n++) {
1778
+ let r = this._clippingContextListForMask[n], i = r._clippingIdCount;
1779
+ if (i != t) continue;
1780
+ let a = 0;
1781
+ for (let t = 0; t < i; t++) {
1782
+ let n = r._clippingIdList[t];
1783
+ for (let t = 0; t < i; t++) if (e[t] == n) {
1784
+ a++;
1785
+ break;
1786
+ }
1787
+ }
1788
+ if (a == i) return r;
1789
+ }
1790
+ return null;
1791
+ }
1792
+ setupLayoutBounds(e) {
1793
+ let t = e / gt, n = e % gt;
1794
+ t = ~~t, n = ~~n;
1795
+ let r = 0;
1796
+ for (let e = 0; e < gt; e++) {
1797
+ let i = t + +(e < n);
1798
+ if (i != 0) if (i == 1) {
1799
+ let t = this._clippingContextListForMask[r++];
1800
+ t._layoutChannelNo = e, t._layoutBounds.x = 0, t._layoutBounds.y = 0, t._layoutBounds.width = 1, t._layoutBounds.height = 1;
1801
+ } else if (i == 2) for (let t = 0; t < i; t++) {
1802
+ let n = t % 2;
1803
+ n = ~~n;
1804
+ let i = this._clippingContextListForMask[r++];
1805
+ i._layoutChannelNo = e, i._layoutBounds.x = n * .5, i._layoutBounds.y = 0, i._layoutBounds.width = .5, i._layoutBounds.height = 1;
1806
+ }
1807
+ else if (i <= 4) for (let t = 0; t < i; t++) {
1808
+ let n = t % 2, i = t / 2;
1809
+ n = ~~n, i = ~~i;
1810
+ let a = this._clippingContextListForMask[r++];
1811
+ a._layoutChannelNo = e, a._layoutBounds.x = n * .5, a._layoutBounds.y = i * .5, a._layoutBounds.width = .5, a._layoutBounds.height = .5;
1812
+ }
1813
+ else if (i <= 9) for (let t = 0; t < i; t++) {
1814
+ let n = t % 3, i = t / 3;
1815
+ n = ~~n, i = ~~i;
1816
+ let a = this._clippingContextListForMask[r++];
1817
+ a._layoutChannelNo = e, a._layoutBounds.x = n / 3, a._layoutBounds.y = i / 3, a._layoutBounds.width = 1 / 3, a._layoutBounds.height = 1 / 3;
1818
+ }
1819
+ else if (he.supportMoreMaskDivisions && i <= 16) for (let t = 0; t < i; t++) {
1820
+ let n = t % 4, i = t / 4;
1821
+ n = ~~n, i = ~~i;
1822
+ let a = this._clippingContextListForMask[r++];
1823
+ a._layoutChannelNo = e, a._layoutBounds.x = n / 4, a._layoutBounds.y = i / 4, a._layoutBounds.width = 1 / 4, a._layoutBounds.height = 1 / 4;
1824
+ }
1825
+ else A("not supported mask count : {0}", i);
1826
+ }
1827
+ }
1828
+ getColorBuffer() {
1829
+ return this._colorBuffer;
1830
+ }
1831
+ getClippingContextListForDraw() {
1832
+ return this._clippingContextListForDraw;
1833
+ }
1834
+ setClippingMaskBufferSize(e) {
1835
+ this._clippingMaskBufferSize = e;
1836
+ }
1837
+ getClippingMaskBufferSize() {
1838
+ return this._clippingMaskBufferSize;
1839
+ }
1840
+ }, xt = class {
1841
+ constructor(e, t) {
1842
+ this.frameNo = e, this.texture = t;
1843
+ }
1844
+ }, St = class {
1845
+ constructor(e, t, n) {
1846
+ this._isUsing = !1, this._owner = e, this._clippingIdList = t, this._clippingIdCount = n, this._allClippedDrawRect = new ht(), this._layoutBounds = new ht(), this._clippedDrawableIndexList = [], this._matrixForMask = new b(), this._matrixForDraw = new b();
1847
+ }
1848
+ release() {
1849
+ let e = this;
1850
+ e._layoutBounds = void 0, e._allClippedDrawRect = void 0, e._clippedDrawableIndexList = void 0;
1851
+ }
1852
+ addClippedDrawable(e) {
1853
+ this._clippedDrawableIndexList.push(e);
1854
+ }
1855
+ getClippingManager() {
1856
+ return this._owner;
1857
+ }
1858
+ setGl(e) {
1859
+ this._owner.setGL(e);
1860
+ }
1861
+ }, z = class e {
1862
+ static getInstance() {
1863
+ return vt ??= new e(), vt;
1864
+ }
1865
+ static deleteInstance() {
1866
+ vt &&= (vt.release(), void 0);
1867
+ }
1868
+ constructor() {
1869
+ this._shaderSets = [];
1870
+ }
1871
+ release() {
1872
+ this.releaseShaderProgram();
1873
+ }
1874
+ setupShaderProgram(e, t, n, r, i, a, o, s, c, l, u, d, f) {
1875
+ u || A("NoPremultipliedAlpha is not allowed"), this._shaderSets.length == 0 && this.generateShaders();
1876
+ let p, m, h, g, _ = e.getClippingContextBufferForMask();
1877
+ if (_ != null) {
1878
+ let e = this._shaderSets[B.ShaderNames_SetupMask];
1879
+ this.gl.useProgram(e.shaderProgram), this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, t), this.gl.uniform1i(e.samplerTexture0Location, 0), o.vertex ??= this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.vertex), this.gl.bufferData(this.gl.ARRAY_BUFFER, r, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(e.attributePositionLocation), this.gl.vertexAttribPointer(e.attributePositionLocation, 2, this.gl.FLOAT, !1, 0, 0), o.uv ??= this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.uv), this.gl.bufferData(this.gl.ARRAY_BUFFER, a, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(e.attributeTexCoordLocation), this.gl.vertexAttribPointer(e.attributeTexCoordLocation, 2, this.gl.FLOAT, !1, 0, 0);
1880
+ let n = _._layoutChannelNo, i = _.getClippingManager().getChannelFlagAsColor(n);
1881
+ this.gl.uniform4f(e.uniformChannelFlagLocation, i.R, i.G, i.B, i.A), this.gl.uniformMatrix4fv(e.uniformClipMatrixLocation, !1, _._matrixForMask.getArray());
1882
+ let s = _._layoutBounds;
1883
+ this.gl.uniform4f(e.uniformBaseColorLocation, s.x * 2 - 1, s.y * 2 - 1, s.getRight() * 2 - 1, s.getBottom() * 2 - 1), p = this.gl.ZERO, m = this.gl.ONE_MINUS_SRC_COLOR, h = this.gl.ZERO, g = this.gl.ONE_MINUS_SRC_ALPHA;
1884
+ } else {
1885
+ let n = e.getClippingContextBufferForDraw(), i = n == null ? 0 : f ? 2 : 1, s;
1886
+ switch (c) {
1887
+ case x.CubismBlendMode_Normal:
1888
+ default:
1889
+ s = this._shaderSets[B.ShaderNames_NormalPremultipliedAlpha + i], p = this.gl.ONE, m = this.gl.ONE_MINUS_SRC_ALPHA, h = this.gl.ONE, g = this.gl.ONE_MINUS_SRC_ALPHA;
1890
+ break;
1891
+ case x.CubismBlendMode_Additive:
1892
+ s = this._shaderSets[B.ShaderNames_AddPremultipliedAlpha + i], p = this.gl.ONE, m = this.gl.ONE, h = this.gl.ZERO, g = this.gl.ONE;
1893
+ break;
1894
+ case x.CubismBlendMode_Multiplicative:
1895
+ s = this._shaderSets[B.ShaderNames_MultPremultipliedAlpha + i], p = this.gl.DST_COLOR, m = this.gl.ONE_MINUS_SRC_ALPHA, h = this.gl.ZERO, g = this.gl.ONE;
1896
+ break;
1897
+ }
1898
+ if (this.gl.useProgram(s.shaderProgram), o.vertex ??= this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.vertex), this.gl.bufferData(this.gl.ARRAY_BUFFER, r, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(s.attributePositionLocation), this.gl.vertexAttribPointer(s.attributePositionLocation, 2, this.gl.FLOAT, !1, 0, 0), o.uv ??= this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, o.uv), this.gl.bufferData(this.gl.ARRAY_BUFFER, a, this.gl.DYNAMIC_DRAW), this.gl.enableVertexAttribArray(s.attributeTexCoordLocation), this.gl.vertexAttribPointer(s.attributeTexCoordLocation, 2, this.gl.FLOAT, !1, 0, 0), n != null) {
1899
+ this.gl.activeTexture(this.gl.TEXTURE1);
1900
+ let e = n.getClippingManager().getColorBuffer();
1901
+ this.gl.bindTexture(this.gl.TEXTURE_2D, e), this.gl.uniform1i(s.samplerTexture1Location, 1), this.gl.uniformMatrix4fv(s.uniformClipMatrixLocation, !1, n._matrixForDraw.getArray());
1902
+ let t = n._layoutChannelNo, r = n.getClippingManager().getChannelFlagAsColor(t);
1903
+ this.gl.uniform4f(s.uniformChannelFlagLocation, r.R, r.G, r.B, r.A);
1904
+ }
1905
+ this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, t), this.gl.uniform1i(s.samplerTexture0Location, 0), this.gl.uniformMatrix4fv(s.uniformMatrixLocation, !1, d.getArray()), this.gl.uniform4f(s.uniformBaseColorLocation, l.R, l.G, l.B, l.A);
1906
+ }
1907
+ o.index ??= this.gl.createBuffer(), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, o.index), this.gl.bufferData(this.gl.ELEMENT_ARRAY_BUFFER, i, this.gl.DYNAMIC_DRAW), this.gl.blendFuncSeparate(p, m, h, g);
1908
+ }
1909
+ releaseShaderProgram() {
1910
+ for (let e = 0; e < this._shaderSets.length; e++) this.gl.deleteProgram(this._shaderSets[e].shaderProgram), this._shaderSets[e].shaderProgram = 0;
1911
+ this._shaderSets = [];
1912
+ }
1913
+ generateShaders() {
1914
+ for (let e = 0; e < _t; e++) this._shaderSets.push({});
1915
+ this._shaderSets[0].shaderProgram = this.loadShaderProgram(Ct, wt), this._shaderSets[1].shaderProgram = this.loadShaderProgram(Tt, Dt), this._shaderSets[2].shaderProgram = this.loadShaderProgram(Et, Ot), this._shaderSets[3].shaderProgram = this.loadShaderProgram(Et, kt), this._shaderSets[4].shaderProgram = this._shaderSets[1].shaderProgram, this._shaderSets[5].shaderProgram = this._shaderSets[2].shaderProgram, this._shaderSets[6].shaderProgram = this._shaderSets[3].shaderProgram, this._shaderSets[7].shaderProgram = this._shaderSets[1].shaderProgram, this._shaderSets[8].shaderProgram = this._shaderSets[2].shaderProgram, this._shaderSets[9].shaderProgram = this._shaderSets[3].shaderProgram, this._shaderSets[0].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[0].shaderProgram, "a_position"), this._shaderSets[0].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[0].shaderProgram, "a_texCoord"), this._shaderSets[0].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "s_texture0"), this._shaderSets[0].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_clipMatrix"), this._shaderSets[0].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_channelFlag"), this._shaderSets[0].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[0].shaderProgram, "u_baseColor"), this._shaderSets[1].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[1].shaderProgram, "a_position"), this._shaderSets[1].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[1].shaderProgram, "a_texCoord"), this._shaderSets[1].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "s_texture0"), this._shaderSets[1].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "u_matrix"), this._shaderSets[1].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[1].shaderProgram, "u_baseColor"), this._shaderSets[2].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[2].shaderProgram, "a_position"), this._shaderSets[2].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[2].shaderProgram, "a_texCoord"), this._shaderSets[2].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "s_texture0"), this._shaderSets[2].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "s_texture1"), this._shaderSets[2].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_matrix"), this._shaderSets[2].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_clipMatrix"), this._shaderSets[2].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_channelFlag"), this._shaderSets[2].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[2].shaderProgram, "u_baseColor"), this._shaderSets[3].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[3].shaderProgram, "a_position"), this._shaderSets[3].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[3].shaderProgram, "a_texCoord"), this._shaderSets[3].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "s_texture0"), this._shaderSets[3].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "s_texture1"), this._shaderSets[3].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_matrix"), this._shaderSets[3].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_clipMatrix"), this._shaderSets[3].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_channelFlag"), this._shaderSets[3].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[3].shaderProgram, "u_baseColor"), this._shaderSets[4].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[4].shaderProgram, "a_position"), this._shaderSets[4].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[4].shaderProgram, "a_texCoord"), this._shaderSets[4].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "s_texture0"), this._shaderSets[4].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "u_matrix"), this._shaderSets[4].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[4].shaderProgram, "u_baseColor"), this._shaderSets[5].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[5].shaderProgram, "a_position"), this._shaderSets[5].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[5].shaderProgram, "a_texCoord"), this._shaderSets[5].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "s_texture0"), this._shaderSets[5].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "s_texture1"), this._shaderSets[5].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_matrix"), this._shaderSets[5].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_clipMatrix"), this._shaderSets[5].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_channelFlag"), this._shaderSets[5].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[5].shaderProgram, "u_baseColor"), this._shaderSets[6].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[6].shaderProgram, "a_position"), this._shaderSets[6].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[6].shaderProgram, "a_texCoord"), this._shaderSets[6].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "s_texture0"), this._shaderSets[6].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "s_texture1"), this._shaderSets[6].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_matrix"), this._shaderSets[6].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_clipMatrix"), this._shaderSets[6].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_channelFlag"), this._shaderSets[6].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[6].shaderProgram, "u_baseColor"), this._shaderSets[7].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[7].shaderProgram, "a_position"), this._shaderSets[7].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[7].shaderProgram, "a_texCoord"), this._shaderSets[7].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "s_texture0"), this._shaderSets[7].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "u_matrix"), this._shaderSets[7].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[7].shaderProgram, "u_baseColor"), this._shaderSets[8].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[8].shaderProgram, "a_position"), this._shaderSets[8].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[8].shaderProgram, "a_texCoord"), this._shaderSets[8].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "s_texture0"), this._shaderSets[8].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "s_texture1"), this._shaderSets[8].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_matrix"), this._shaderSets[8].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_clipMatrix"), this._shaderSets[8].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_channelFlag"), this._shaderSets[8].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[8].shaderProgram, "u_baseColor"), this._shaderSets[9].attributePositionLocation = this.gl.getAttribLocation(this._shaderSets[9].shaderProgram, "a_position"), this._shaderSets[9].attributeTexCoordLocation = this.gl.getAttribLocation(this._shaderSets[9].shaderProgram, "a_texCoord"), this._shaderSets[9].samplerTexture0Location = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "s_texture0"), this._shaderSets[9].samplerTexture1Location = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "s_texture1"), this._shaderSets[9].uniformMatrixLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_matrix"), this._shaderSets[9].uniformClipMatrixLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_clipMatrix"), this._shaderSets[9].uniformChannelFlagLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_channelFlag"), this._shaderSets[9].uniformBaseColorLocation = this.gl.getUniformLocation(this._shaderSets[9].shaderProgram, "u_baseColor");
1916
+ }
1917
+ loadShaderProgram(e, t) {
1918
+ let n = this.gl.createProgram(), r = this.compileShaderSource(this.gl.VERTEX_SHADER, e);
1919
+ if (!r) return A("Vertex shader compile error!"), 0;
1920
+ let i = this.compileShaderSource(this.gl.FRAGMENT_SHADER, t);
1921
+ return i ? (this.gl.attachShader(n, r), this.gl.attachShader(n, i), this.gl.linkProgram(n), this.gl.getProgramParameter(n, this.gl.LINK_STATUS) ? (this.gl.deleteShader(r), this.gl.deleteShader(i), n) : (A("Failed to link program: {0}", n), this.gl.deleteShader(r), this.gl.deleteShader(i), n && this.gl.deleteProgram(n), 0)) : (A("Vertex shader compile error!"), 0);
1922
+ }
1923
+ compileShaderSource(e, t) {
1924
+ let n = t, r = this.gl.createShader(e);
1925
+ return this.gl.shaderSource(r, n), this.gl.compileShader(r), r || A("Shader compile log: {0} ", this.gl.getShaderInfoLog(r)), this.gl.getShaderParameter(r, this.gl.COMPILE_STATUS) ? r : (this.gl.deleteShader(r), null);
1926
+ }
1927
+ setGl(e) {
1928
+ this.gl = e;
1929
+ }
1930
+ }, B = /* @__PURE__ */ ((e) => (e[e.ShaderNames_SetupMask = 0] = "ShaderNames_SetupMask", e[e.ShaderNames_NormalPremultipliedAlpha = 1] = "ShaderNames_NormalPremultipliedAlpha", e[e.ShaderNames_NormalMaskedPremultipliedAlpha = 2] = "ShaderNames_NormalMaskedPremultipliedAlpha", e[e.ShaderNames_NomralMaskedInvertedPremultipliedAlpha = 3] = "ShaderNames_NomralMaskedInvertedPremultipliedAlpha", e[e.ShaderNames_AddPremultipliedAlpha = 4] = "ShaderNames_AddPremultipliedAlpha", e[e.ShaderNames_AddMaskedPremultipliedAlpha = 5] = "ShaderNames_AddMaskedPremultipliedAlpha", e[e.ShaderNames_AddMaskedPremultipliedAlphaInverted = 6] = "ShaderNames_AddMaskedPremultipliedAlphaInverted", e[e.ShaderNames_MultPremultipliedAlpha = 7] = "ShaderNames_MultPremultipliedAlpha", e[e.ShaderNames_MultMaskedPremultipliedAlpha = 8] = "ShaderNames_MultMaskedPremultipliedAlpha", e[e.ShaderNames_MultMaskedPremultipliedAlphaInverted = 9] = "ShaderNames_MultMaskedPremultipliedAlphaInverted", e))(B || {}), Ct = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_myPos;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_clipMatrix * a_position; v_myPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", wt = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_myPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;void main(){ float isInside = step(u_baseColor.x, v_myPos.x/v_myPos.w) * step(u_baseColor.y, v_myPos.y/v_myPos.w) * step(v_myPos.x/v_myPos.w, u_baseColor.z) * step(v_myPos.y/v_myPos.w, u_baseColor.w); gl_FragColor = u_channelFlag * texture2D(s_texture0, v_texCoord).a * isInside;}", Tt = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;uniform mat4 u_matrix;void main(){ gl_Position = u_matrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", Et = "attribute vec4 a_position;attribute vec2 a_texCoord;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform mat4 u_matrix;uniform mat4 u_clipMatrix;void main(){ gl_Position = u_matrix * a_position; v_clipPos = u_clipMatrix * a_position; v_texCoord = a_texCoord; v_texCoord.y = 1.0 - v_texCoord.y;}", Dt = "precision mediump float;varying vec2 v_texCoord;uniform vec4 u_baseColor;uniform sampler2D s_texture0;void main(){ gl_FragColor = texture2D(s_texture0 , v_texCoord) * u_baseColor;}", Ot = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform vec4 u_baseColor;uniform vec4 u_channelFlag;uniform sampler2D s_texture0;uniform sampler2D s_texture1;void main(){ vec4 col_formask = texture2D(s_texture0 , v_texCoord) * u_baseColor; vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag; float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a; col_formask = col_formask * maskVal; gl_FragColor = col_formask;}", kt = "precision mediump float;varying vec2 v_texCoord;varying vec4 v_clipPos;uniform sampler2D s_texture0;uniform sampler2D s_texture1;uniform vec4 u_channelFlag;uniform vec4 u_baseColor;void main(){vec4 col_formask = texture2D(s_texture0, v_texCoord) * u_baseColor;vec4 clipMask = (1.0 - texture2D(s_texture1, v_clipPos.xy / v_clipPos.w)) * u_channelFlag;float maskVal = clipMask.r + clipMask.g + clipMask.b + clipMask.a;col_formask = col_formask * (1.0 - maskVal);gl_FragColor = col_formask;}", At = class extends ne {
1931
+ constructor() {
1932
+ super(), this._clippingContextBufferForMask = null, this._clippingContextBufferForDraw = null, this._clippingManager = new bt(), this.firstDraw = !0, this._textures = {}, this._sortedDrawableIndexList = [], this._bufferData = {
1933
+ vertex: null,
1934
+ uv: null,
1935
+ index: null
1936
+ };
1937
+ }
1938
+ initialize(e) {
1939
+ e.isUsingMasking() && (this._clippingManager = new bt(), this._clippingManager.initialize(e, e.getDrawableCount(), e.getDrawableMasks(), e.getDrawableMaskCounts()));
1940
+ for (let t = e.getDrawableCount() - 1; t >= 0; t--) this._sortedDrawableIndexList[t] = 0;
1941
+ super.initialize(e);
1942
+ }
1943
+ bindTexture(e, t) {
1944
+ this._textures[e] = t;
1945
+ }
1946
+ getBindedTextures() {
1947
+ return this._textures;
1948
+ }
1949
+ setClippingMaskBufferSize(e) {
1950
+ this._clippingManager.release(), this._clippingManager = new bt(), this._clippingManager.setClippingMaskBufferSize(e), this._clippingManager.initialize(this.getModel(), this.getModel().getDrawableCount(), this.getModel().getDrawableMasks(), this.getModel().getDrawableMaskCounts());
1951
+ }
1952
+ getClippingMaskBufferSize() {
1953
+ return this._clippingManager.getClippingMaskBufferSize();
1954
+ }
1955
+ release() {
1956
+ var e, t, n;
1957
+ let r = this;
1958
+ this._clippingManager.release(), r._clippingManager = void 0, (e = this.gl) == null || e.deleteBuffer(this._bufferData.vertex), this._bufferData.vertex = null, (t = this.gl) == null || t.deleteBuffer(this._bufferData.uv), this._bufferData.uv = null, (n = this.gl) == null || n.deleteBuffer(this._bufferData.index), this._bufferData.index = null, r._bufferData = void 0, r._textures = void 0;
1959
+ }
1960
+ doDrawModel() {
1961
+ this.preDraw(), this._clippingManager != null && this._clippingManager.setupClippingContext(this.getModel(), this);
1962
+ let e = this.getModel().getDrawableCount(), t = this.getModel().getDrawableRenderOrders();
1963
+ for (let n = 0; n < e; ++n) {
1964
+ let e = t[n];
1965
+ this._sortedDrawableIndexList[e] = n;
1966
+ }
1967
+ for (let t = 0; t < e; ++t) {
1968
+ let e = this._sortedDrawableIndexList[t];
1969
+ this.getModel().getDrawableDynamicFlagIsVisible(e) && (this.setClippingContextBufferForDraw(this._clippingManager == null ? null : this._clippingManager.getClippingContextListForDraw()[e]), this.setIsCulling(this.getModel().getDrawableCulling(e)), this.drawMesh(this.getModel().getDrawableTextureIndices(e), this.getModel().getDrawableVertexIndexCount(e), this.getModel().getDrawableVertexCount(e), this.getModel().getDrawableVertexIndices(e), this.getModel().getDrawableVertices(e), this.getModel().getDrawableVertexUvs(e), this.getModel().getDrawableOpacity(e), this.getModel().getDrawableBlendMode(e), this.getModel().getDrawableInvertedMaskBit(e)));
1970
+ }
1971
+ }
1972
+ drawMesh(e, t, n, r, i, a, o, s, c) {
1973
+ this.isCulling() ? this.gl.enable(this.gl.CULL_FACE) : this.gl.disable(this.gl.CULL_FACE), this.gl.frontFace(this.gl.CCW);
1974
+ let l = this.getModelColor();
1975
+ this.getClippingContextBufferForMask() ?? (l.A *= o, this.isPremultipliedAlpha() && (l.R *= l.A, l.G *= l.A, l.B *= l.A));
1976
+ let u = null;
1977
+ this._textures[e] != null && (u = this._textures[e]), z.getInstance().setupShaderProgram(this, u, n, i, r, a, this._bufferData, o, s, l, this.isPremultipliedAlpha(), this.getMvpMatrix(), c), this.gl.drawElements(this.gl.TRIANGLES, t, this.gl.UNSIGNED_SHORT, 0), this.gl.useProgram(null), this.setClippingContextBufferForDraw(null), this.setClippingContextBufferForMask(null);
1978
+ }
1979
+ static doStaticRelease() {
1980
+ z.deleteInstance();
1981
+ }
1982
+ setRenderState(e, t) {
1983
+ yt = e, R = t;
1984
+ }
1985
+ preDraw() {
1986
+ this.firstDraw && (this.firstDraw = !1, this._anisortopy = this.gl.getExtension("EXT_texture_filter_anisotropic") || this.gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic") || this.gl.getExtension("MOZ_EXT_texture_filter_anisotropic")), this.gl.disable(this.gl.SCISSOR_TEST), this.gl.disable(this.gl.STENCIL_TEST), this.gl.disable(this.gl.DEPTH_TEST), this.gl.frontFace(this.gl.CW), this.gl.enable(this.gl.BLEND), this.gl.colorMask(!0, !0, !0, !0), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, null);
1987
+ }
1988
+ setClippingContextBufferForMask(e) {
1989
+ this._clippingContextBufferForMask = e;
1990
+ }
1991
+ getClippingContextBufferForMask() {
1992
+ return this._clippingContextBufferForMask;
1993
+ }
1994
+ setClippingContextBufferForDraw(e) {
1995
+ this._clippingContextBufferForDraw = e;
1996
+ }
1997
+ getClippingContextBufferForDraw() {
1998
+ return this._clippingContextBufferForDraw;
1999
+ }
2000
+ startUp(e) {
2001
+ this.gl = e, this._clippingManager.setGL(e), z.getInstance().setGl(e);
2002
+ }
2003
+ };
2004
+ ne.staticRelease = () => {
2005
+ At.doStaticRelease();
2006
+ };
2007
+ var jt = class {
2008
+ constructor(e) {
2009
+ this.groups = e.Groups, this.hitAreas = e.HitAreas, this.layout = e.Layout, this.moc = e.FileReferences.Moc, this.expressions = e.FileReferences.Expressions, this.motions = e.FileReferences.Motions, this.textures = e.FileReferences.Textures, this.physics = e.FileReferences.Physics, this.pose = e.FileReferences.Pose;
2010
+ }
2011
+ getEyeBlinkParameters() {
2012
+ return this.groups?.find((e) => e.Name === "EyeBlink")?.Ids;
2013
+ }
2014
+ getLipSyncParameters() {
2015
+ return this.groups?.find((e) => e.Name === "LipSync")?.Ids;
2016
+ }
2017
+ }, Mt = "HitArea", Nt = "Head", Pt = "Body", Ft = "Parts01Core", It = "Parts01Arm_", Lt = "Parts01ArmL_", Rt = "Parts01ArmR_", zt = "ParamAngleX", Bt = "ParamAngleY", Vt = "ParamAngleZ", Ht = "ParamEyeLOpen", Ut = "ParamEyeLSmile", Wt = "ParamEyeROpen", Gt = "ParamEyeRSmile", Kt = "ParamEyeBallX", qt = "ParamEyeBallY", Jt = "ParamEyeBallForm", Yt = "ParamBrowLY", Xt = "ParamBrowRY", Zt = "ParamBrowLX", Qt = "ParamBrowRX", $t = "ParamBrowLAngle", en = "ParamBrowRAngle", tn = "ParamBrowLForm", nn = "ParamBrowRForm", rn = "ParamMouthForm", an = "ParamMouthOpenY", on = "ParamCheek", sn = "ParamBodyAngleX", cn = "ParamBodyAngleY", ln = "ParamBodyAngleZ", un = "ParamBreath", dn = "ParamArmLA", fn = "ParamArmRA", pn = "ParamArmLB", mn = "ParamArmRB", hn = "ParamHandL", gn = "ParamHandR", _n = "ParamHairFront", vn = "ParamHairSide", yn = "ParamHairBack", bn = "ParamHairFluffy", xn = "ParamShoulderY", Sn = "ParamBustX", Cn = "ParamBustY", wn = "ParamBaseX", Tn = "ParamBaseY", En = "NONE:", Dn = 2, On = 2, V;
2018
+ ((e) => {
2019
+ e.LOG_LEVEL_VERBOSE = 0, e.LOG_LEVEL_WARNING = 1, e.LOG_LEVEL_ERROR = 2, e.LOG_LEVEL_NONE = 999, e.logLevel = e.LOG_LEVEL_WARNING, e.sound = !0, e.motionSync = !0, e.motionFadingDuration = 500, e.idleMotionFadingDuration = 2e3, e.expressionFadingDuration = 500, e.preserveExpressionOnMotion = !0, e.cubism4 = he;
2020
+ })(V ||= {});
2021
+ var kn = "0.4.0", H = {
2022
+ log(e, ...t) {
2023
+ V.logLevel <= V.LOG_LEVEL_VERBOSE && console.log(`[${e}]`, ...t);
2024
+ },
2025
+ warn(e, ...t) {
2026
+ V.logLevel <= V.LOG_LEVEL_WARNING && console.warn(`[${e}]`, ...t);
2027
+ },
2028
+ error(e, ...t) {
2029
+ V.logLevel <= V.LOG_LEVEL_ERROR && console.error(`[${e}]`, ...t);
2030
+ }
2031
+ };
2032
+ function An(e, t, n) {
2033
+ return e < t ? t : e > n ? n : e;
2034
+ }
2035
+ function jn(e, t) {
2036
+ return Math.random() * (t - e) + e;
2037
+ }
2038
+ function Mn(e, t, n, r, i) {
2039
+ let a = t[r];
2040
+ a !== null && typeof a === e && (n[i] = a);
2041
+ }
2042
+ function Nn(e, t, n, r, i) {
2043
+ let a = t[r];
2044
+ Array.isArray(a) && (n[i] = a.filter((t) => t !== null && typeof t === e));
2045
+ }
2046
+ function Pn(e, t) {
2047
+ t.forEach((t) => {
2048
+ Object.getOwnPropertyNames(t.prototype).forEach((n) => {
2049
+ n !== "constructor" && Object.defineProperty(e.prototype, n, Object.getOwnPropertyDescriptor(t.prototype, n));
2050
+ });
2051
+ });
2052
+ }
2053
+ function Fn(e) {
2054
+ let t = e.lastIndexOf("/");
2055
+ return t != -1 && (e = e.slice(0, t)), t = e.lastIndexOf("/"), t !== -1 && (e = e.slice(t + 1)), e;
2056
+ }
2057
+ function In(e, t) {
2058
+ let n = e.indexOf(t);
2059
+ n !== -1 && e.splice(n, 1);
2060
+ }
2061
+ var Ln = class extends o.default {
2062
+ constructor(e, t) {
2063
+ super(), this.expressions = [], this.reserveExpressionIndex = -1, this.destroyed = !1, this.settings = e, this.tag = `ExpressionManager(${e.name})`;
2064
+ }
2065
+ init() {
2066
+ this.defaultExpression = this.createExpression({}, void 0), this.currentExpression = this.defaultExpression, this.stopAllExpressions();
2067
+ }
2068
+ loadExpression(e) {
2069
+ return l(this, null, function* () {
2070
+ if (!this.definitions[e]) {
2071
+ H.warn(this.tag, `Undefined expression at [${e}]`);
2072
+ return;
2073
+ }
2074
+ if (this.expressions[e] === null) {
2075
+ H.warn(this.tag, `Cannot set expression at [${e}] because it's already failed in loading.`);
2076
+ return;
2077
+ }
2078
+ if (this.expressions[e]) return this.expressions[e];
2079
+ let t = yield this._loadExpression(e);
2080
+ return this.expressions[e] = t, t;
2081
+ });
2082
+ }
2083
+ _loadExpression(e) {
2084
+ throw Error("Not implemented.");
2085
+ }
2086
+ setRandomExpression() {
2087
+ return l(this, null, function* () {
2088
+ if (this.definitions.length) {
2089
+ let e = [];
2090
+ for (let t = 0; t < this.definitions.length; t++) this.expressions[t] !== null && this.expressions[t] !== this.currentExpression && t !== this.reserveExpressionIndex && e.push(t);
2091
+ if (e.length) {
2092
+ let t = Math.floor(Math.random() * e.length);
2093
+ return this.setExpression(t);
2094
+ }
2095
+ }
2096
+ return !1;
2097
+ });
2098
+ }
2099
+ resetExpression() {
2100
+ this._setExpression(this.defaultExpression);
2101
+ }
2102
+ restoreExpression() {
2103
+ this._setExpression(this.currentExpression);
2104
+ }
2105
+ setExpression(e) {
2106
+ return l(this, null, function* () {
2107
+ if (typeof e != "number" && (e = this.getExpressionIndex(e)), !(e > -1 && e < this.definitions.length) || e === this.expressions.indexOf(this.currentExpression)) return !1;
2108
+ this.reserveExpressionIndex = e;
2109
+ let t = yield this.loadExpression(e);
2110
+ return !t || this.reserveExpressionIndex !== e ? !1 : (this.reserveExpressionIndex = -1, this.currentExpression = t, this._setExpression(t), !0);
2111
+ });
2112
+ }
2113
+ update(e, t) {
2114
+ return this.isFinished() ? !1 : this.updateParameters(e, t);
2115
+ }
2116
+ destroy() {
2117
+ this.destroyed = !0, this.emit("destroy");
2118
+ let e = this;
2119
+ e.definitions = void 0, e.expressions = void 0;
2120
+ }
2121
+ }, Rn = .01, zn = 40 / 7.5, Bn = 1 / (.15 * 1e3), Vn = class {
2122
+ constructor() {
2123
+ this.targetX = 0, this.targetY = 0, this.x = 0, this.y = 0, this.vx = 0, this.vy = 0;
2124
+ }
2125
+ focus(e, t, n = !1) {
2126
+ this.targetX = An(e, -1, 1), this.targetY = An(t, -1, 1), n && (this.x = this.targetX, this.y = this.targetY);
2127
+ }
2128
+ update(e) {
2129
+ let t = this.targetX - this.x, n = this.targetY - this.y;
2130
+ if (Math.abs(t) < Rn && Math.abs(n) < Rn) return;
2131
+ let r = Math.sqrt(c(t, 2) + c(n, 2)), i = zn / (1e3 / e), a = t / r * i - this.vx, o = n / r * i - this.vy, s = Math.sqrt(c(a, 2) + c(o, 2)), l = i * Bn * e;
2132
+ s > l && (a *= l / s, o *= l / s), this.vx += a, this.vy += o;
2133
+ let u = Math.sqrt(c(this.vx, 2) + c(this.vy, 2)), d = .5 * (Math.sqrt(c(l, 2) + 8 * l * r) - l);
2134
+ u > d && (this.vx *= d / u, this.vy *= d / u), this.x += this.vx, this.y += this.vy;
2135
+ }
2136
+ }, Hn = class {
2137
+ constructor(e) {
2138
+ this.json = e;
2139
+ let t = e.url;
2140
+ if (typeof t != "string") throw TypeError("The `url` field in settings JSON must be defined as a string.");
2141
+ this.url = t, this.name = Fn(this.url);
2142
+ }
2143
+ resolveURL(e) {
2144
+ return i.resolve(this.url, e);
2145
+ }
2146
+ replaceFiles(e) {
2147
+ this.moc = e(this.moc, "moc"), this.pose !== void 0 && (this.pose = e(this.pose, "pose")), this.physics !== void 0 && (this.physics = e(this.physics, "physics"));
2148
+ for (let t = 0; t < this.textures.length; t++) this.textures[t] = e(this.textures[t], `textures[${t}]`);
2149
+ }
2150
+ getDefinedFiles() {
2151
+ let e = [];
2152
+ return this.replaceFiles((t) => (e.push(t), t)), e;
2153
+ }
2154
+ validateFiles(e) {
2155
+ let t = (t, n) => {
2156
+ let r = this.resolveURL(t);
2157
+ if (!e.includes(r)) {
2158
+ if (n) throw Error(`File "${t}" is defined in settings, but doesn't exist in given files`);
2159
+ return !1;
2160
+ }
2161
+ return !0;
2162
+ };
2163
+ return [this.moc, ...this.textures].forEach((e) => t(e, !0)), this.getDefinedFiles().filter((e) => t(e, !1));
2164
+ }
2165
+ }, Un = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.IDLE = 1] = "IDLE", e[e.NORMAL = 2] = "NORMAL", e[e.FORCE = 3] = "FORCE", e))(Un || {}), Wn = class {
2166
+ constructor() {
2167
+ this.debug = !1, this.currentPriority = 0, this.reservePriority = 0;
2168
+ }
2169
+ reserve(e, t, n) {
2170
+ if (n <= 0) return H.log(this.tag, "Cannot start a motion with MotionPriority.NONE."), !1;
2171
+ if (e === this.currentGroup && t === this.currentIndex) return H.log(this.tag, "Motion is already playing.", this.dump(e, t)), !1;
2172
+ if (e === this.reservedGroup && t === this.reservedIndex || e === this.reservedIdleGroup && t === this.reservedIdleIndex) return H.log(this.tag, "Motion is already reserved.", this.dump(e, t)), !1;
2173
+ if (n === 1) {
2174
+ if (this.currentPriority !== 0) return H.log(this.tag, "Cannot start idle motion because another motion is playing.", this.dump(e, t)), !1;
2175
+ if (this.reservedIdleGroup !== void 0) return H.log(this.tag, "Cannot start idle motion because another idle motion has reserved.", this.dump(e, t)), !1;
2176
+ this.setReservedIdle(e, t);
2177
+ } else {
2178
+ if (n < 3) {
2179
+ if (n <= this.currentPriority) return H.log(this.tag, "Cannot start motion because another motion is playing as an equivalent or higher priority.", this.dump(e, t)), !1;
2180
+ if (n <= this.reservePriority) return H.log(this.tag, "Cannot start motion because another motion has reserved as an equivalent or higher priority.", this.dump(e, t)), !1;
2181
+ }
2182
+ this.setReserved(e, t, n);
2183
+ }
2184
+ return !0;
2185
+ }
2186
+ start(e, t, n, r) {
2187
+ if (r === 1) {
2188
+ if (this.setReservedIdle(void 0, void 0), this.currentPriority !== 0) return H.log(this.tag, "Cannot start idle motion because another motion is playing.", this.dump(t, n)), !1;
2189
+ } else {
2190
+ if (t !== this.reservedGroup || n !== this.reservedIndex) return H.log(this.tag, "Cannot start motion because another motion has taken the place.", this.dump(t, n)), !1;
2191
+ this.setReserved(void 0, void 0, 0);
2192
+ }
2193
+ return e ? (this.setCurrent(t, n, r), !0) : !1;
2194
+ }
2195
+ complete() {
2196
+ this.setCurrent(void 0, void 0, 0);
2197
+ }
2198
+ setCurrent(e, t, n) {
2199
+ this.currentPriority = n, this.currentGroup = e, this.currentIndex = t;
2200
+ }
2201
+ setReserved(e, t, n) {
2202
+ this.reservePriority = n, this.reservedGroup = e, this.reservedIndex = t;
2203
+ }
2204
+ setReservedIdle(e, t) {
2205
+ this.reservedIdleGroup = e, this.reservedIdleIndex = t;
2206
+ }
2207
+ isActive(e, t) {
2208
+ return e === this.currentGroup && t === this.currentIndex || e === this.reservedGroup && t === this.reservedIndex || e === this.reservedIdleGroup && t === this.reservedIdleIndex;
2209
+ }
2210
+ reset() {
2211
+ this.setCurrent(void 0, void 0, 0), this.setReserved(void 0, void 0, 0), this.setReservedIdle(void 0, void 0);
2212
+ }
2213
+ shouldRequestIdleMotion() {
2214
+ return this.currentGroup === void 0 && this.reservedIdleGroup === void 0;
2215
+ }
2216
+ shouldOverrideExpression() {
2217
+ return !V.preserveExpressionOnMotion && this.currentPriority > 1;
2218
+ }
2219
+ dump(e, t) {
2220
+ return this.debug ? `
2221
+ <Requested> group = "${e}", index = ${t}
2222
+ ` + [
2223
+ "currentPriority",
2224
+ "reservePriority",
2225
+ "currentGroup",
2226
+ "currentIndex",
2227
+ "reservedGroup",
2228
+ "reservedIndex",
2229
+ "reservedIdleGroup",
2230
+ "reservedIdleIndex"
2231
+ ].map((e) => "[" + e + "] " + this[e]).join("\n") : "";
2232
+ }
2233
+ }, Gn = "SoundManager", Kn = .5, U = class {
2234
+ static get volume() {
2235
+ return this._volume;
2236
+ }
2237
+ static set volume(e) {
2238
+ this._volume = (e > 1 ? 1 : e < 0 ? 0 : e) || 0, this.audios.forEach((e) => e.volume = this._volume);
2239
+ }
2240
+ static add(e, t, n) {
2241
+ let r = new Audio(e);
2242
+ return r.volume = this._volume, r.preload = "auto", r.addEventListener("ended", () => {
2243
+ this.dispose(r), t?.();
2244
+ }), r.addEventListener("error", (t) => {
2245
+ this.dispose(r), H.warn(Gn, `Error occurred on "${e}"`, t.error), n?.(t.error);
2246
+ }), this.audios.push(r), r;
2247
+ }
2248
+ static play(e) {
2249
+ return new Promise((t, n) => {
2250
+ var r;
2251
+ (r = e.play()) == null || r.catch((t) => {
2252
+ e.dispatchEvent(new ErrorEvent("error", { error: t })), n(t);
2253
+ }), e.readyState === e.HAVE_ENOUGH_DATA ? t() : e.addEventListener("canplaythrough", t);
2254
+ });
2255
+ }
2256
+ static dispose(e) {
2257
+ e.pause(), e.removeAttribute("src"), In(this.audios, e);
2258
+ }
2259
+ static destroy() {
2260
+ for (let e = this.audios.length - 1; e >= 0; e--) this.dispose(this.audios[e]);
2261
+ }
2262
+ };
2263
+ U.audios = [], U._volume = Kn;
2264
+ var qn = /* @__PURE__ */ ((e) => (e.ALL = "ALL", e.IDLE = "IDLE", e.NONE = "NONE", e))(qn || {}), Jn = class extends o.default {
2265
+ constructor(e, t) {
2266
+ super(), this.motionGroups = {}, this.state = new Wn(), this.playing = !1, this.destroyed = !1, this.settings = e, this.tag = `MotionManager(${e.name})`, this.state.tag = this.tag;
2267
+ }
2268
+ init(e) {
2269
+ e?.idleMotionGroup && (this.groups.idle = e.idleMotionGroup), this.setupMotions(e), this.stopAllMotions();
2270
+ }
2271
+ setupMotions(e) {
2272
+ for (let e of Object.keys(this.definitions)) this.motionGroups[e] = [];
2273
+ let t;
2274
+ switch (e?.motionPreload) {
2275
+ case "NONE": return;
2276
+ case "ALL":
2277
+ t = Object.keys(this.definitions);
2278
+ break;
2279
+ default:
2280
+ t = [this.groups.idle];
2281
+ break;
2282
+ }
2283
+ for (let e of t) if (this.definitions[e]) for (let t = 0; t < this.definitions[e].length; t++) this.loadMotion(e, t).then();
2284
+ }
2285
+ loadMotion(e, t) {
2286
+ return l(this, null, function* () {
2287
+ if (!this.definitions[e]?.[t]) {
2288
+ H.warn(this.tag, `Undefined motion at "${e}"[${t}]`);
2289
+ return;
2290
+ }
2291
+ if (this.motionGroups[e][t] === null) {
2292
+ H.warn(this.tag, `Cannot start motion at "${e}"[${t}] because it's already failed in loading.`);
2293
+ return;
2294
+ }
2295
+ if (this.motionGroups[e][t]) return this.motionGroups[e][t];
2296
+ let n = yield this._loadMotion(e, t);
2297
+ if (!this.destroyed) return this.motionGroups[e][t] = n ?? null, n;
2298
+ });
2299
+ }
2300
+ _loadMotion(e, t) {
2301
+ throw Error("Not implemented.");
2302
+ }
2303
+ startMotion(e, t) {
2304
+ return l(this, arguments, function* (e, t, n = Un.NORMAL) {
2305
+ if (!this.state.reserve(e, t, n)) return !1;
2306
+ let r = this.definitions[e]?.[t];
2307
+ if (!r) return !1;
2308
+ this.currentAudio && U.dispose(this.currentAudio);
2309
+ let i;
2310
+ if (V.sound) {
2311
+ let e = this.getSoundFile(r);
2312
+ if (e) try {
2313
+ i = U.add(this.settings.resolveURL(e), () => this.currentAudio = void 0, () => this.currentAudio = void 0), this.currentAudio = i;
2314
+ } catch (t) {
2315
+ H.warn(this.tag, "Failed to create audio", e, t);
2316
+ }
2317
+ }
2318
+ let a = yield this.loadMotion(e, t);
2319
+ if (i) {
2320
+ let e = U.play(i).catch((e) => H.warn(this.tag, "Failed to play audio", i.src, e));
2321
+ V.motionSync && (yield e);
2322
+ }
2323
+ return this.state.start(a, e, t, n) ? (H.log(this.tag, "Start motion:", this.getMotionName(r)), this.emit("motionStart", e, t, i), this.state.shouldOverrideExpression() && this.expressionManager && this.expressionManager.resetExpression(), this.playing = !0, this._startMotion(a), !0) : (i && (U.dispose(i), this.currentAudio = void 0), !1);
2324
+ });
2325
+ }
2326
+ startRandomMotion(e, t) {
2327
+ return l(this, null, function* () {
2328
+ let n = this.definitions[e];
2329
+ if (n?.length) {
2330
+ let r = [];
2331
+ for (let t = 0; t < n.length; t++) this.motionGroups[e][t] !== null && !this.state.isActive(e, t) && r.push(t);
2332
+ if (r.length) {
2333
+ let n = Math.floor(Math.random() * r.length);
2334
+ return this.startMotion(e, r[n], t);
2335
+ }
2336
+ }
2337
+ return !1;
2338
+ });
2339
+ }
2340
+ stopAllMotions() {
2341
+ this._stopAllMotions(), this.state.reset(), this.currentAudio &&= (U.dispose(this.currentAudio), void 0);
2342
+ }
2343
+ update(e, t) {
2344
+ var n;
2345
+ return this.isFinished() && (this.playing && (this.playing = !1, this.emit("motionFinish")), this.state.shouldOverrideExpression() && ((n = this.expressionManager) == null || n.restoreExpression()), this.state.complete(), this.state.shouldRequestIdleMotion() && this.startRandomMotion(this.groups.idle, Un.IDLE)), this.updateParameters(e, t);
2346
+ }
2347
+ destroy() {
2348
+ var e;
2349
+ this.destroyed = !0, this.emit("destroy"), this.stopAllMotions(), (e = this.expressionManager) == null || e.destroy();
2350
+ let t = this;
2351
+ t.definitions = void 0, t.motionGroups = void 0;
2352
+ }
2353
+ }, Yn = {
2354
+ x: 0,
2355
+ y: 0,
2356
+ width: 0,
2357
+ height: 0
2358
+ }, Xn = class extends o.default {
2359
+ constructor() {
2360
+ super(...arguments), this.focusController = new Vn(), this.originalWidth = 0, this.originalHeight = 0, this.width = 0, this.height = 0, this.localTransform = new n(), this.drawingMatrix = new n(), this.hitAreas = {}, this.textureFlipY = !1, this.viewport = [
2361
+ 0,
2362
+ 0,
2363
+ 0,
2364
+ 0
2365
+ ], this.destroyed = !1;
2366
+ }
2367
+ init() {
2368
+ this.setupLayout(), this.setupHitAreas();
2369
+ }
2370
+ setupLayout() {
2371
+ let e = this, t = this.getSize();
2372
+ e.originalWidth = t[0], e.originalHeight = t[1];
2373
+ let n = Object.assign({
2374
+ width: 2,
2375
+ height: 2
2376
+ }, this.getLayout());
2377
+ this.localTransform.scale(n.width / 2, n.height / 2), e.width = this.originalWidth * this.localTransform.a, e.height = this.originalHeight * this.localTransform.d;
2378
+ let r = n.x !== void 0 && n.x - n.width / 2 || n.centerX !== void 0 && n.centerX || n.left !== void 0 && n.left - n.width / 2 || n.right !== void 0 && n.right + n.width / 2 || 0, i = n.y !== void 0 && n.y - n.height / 2 || n.centerY !== void 0 && n.centerY || n.top !== void 0 && n.top - n.height / 2 || n.bottom !== void 0 && n.bottom + n.height / 2 || 0;
2379
+ this.localTransform.translate(this.width * r, -this.height * i);
2380
+ }
2381
+ setupHitAreas() {
2382
+ let e = this.getHitAreaDefs().filter((e) => e.index >= 0);
2383
+ for (let t of e) this.hitAreas[t.name] = t;
2384
+ }
2385
+ hitTest(e, t) {
2386
+ return Object.keys(this.hitAreas).filter((n) => this.isHit(n, e, t));
2387
+ }
2388
+ isHit(e, t, n) {
2389
+ if (!this.hitAreas[e]) return !1;
2390
+ let r = this.hitAreas[e].index, i = this.getDrawableBounds(r, Yn);
2391
+ return i.x <= t && t <= i.x + i.width && i.y <= n && n <= i.y + i.height;
2392
+ }
2393
+ getDrawableBounds(e, t) {
2394
+ let n = this.getDrawableVertices(e), r = n[0], i = n[0], a = n[1], o = n[1];
2395
+ for (let e = 0; e < n.length; e += 2) {
2396
+ let t = n[e], s = n[e + 1];
2397
+ r = Math.min(t, r), i = Math.max(t, i), a = Math.min(s, a), o = Math.max(s, o);
2398
+ }
2399
+ return t ??= {}, t.x = r, t.y = a, t.width = i - r, t.height = o - a, t;
2400
+ }
2401
+ updateTransform(e) {
2402
+ this.drawingMatrix.copyFrom(e).append(this.localTransform);
2403
+ }
2404
+ update(e, t) {
2405
+ this.focusController.update(e);
2406
+ }
2407
+ destroy() {
2408
+ this.destroyed = !0, this.emit("destroy"), this.motionManager.destroy(), this.motionManager = void 0;
2409
+ }
2410
+ }, Zn = "XHRLoader", Qn = class extends Error {
2411
+ constructor(e, t, n, r = !1) {
2412
+ super(e), this.url = t, this.status = n, this.aborted = r;
2413
+ }
2414
+ }, W = class {
2415
+ static createXHR(e, t, n, r, i) {
2416
+ let a = new XMLHttpRequest();
2417
+ if (W.allXhrSet.add(a), e) {
2418
+ let t = W.xhrMap.get(e);
2419
+ t ? t.add(a) : (t = /* @__PURE__ */ new Set([a]), W.xhrMap.set(e, t)), e.listeners("destroy").includes(W.cancelXHRs) || e.once("destroy", W.cancelXHRs);
2420
+ }
2421
+ return a.open("GET", t), a.responseType = n, a.onload = () => {
2422
+ (a.status === 200 || a.status === 0) && a.response ? r(a.response) : a.onerror();
2423
+ }, a.onerror = () => {
2424
+ H.warn(Zn, `Failed to load resource as ${a.responseType} (Status ${a.status}): ${t}`), i(new Qn("Network error.", t, a.status));
2425
+ }, a.onabort = () => i(new Qn("Aborted.", t, a.status, !0)), a.onloadend = () => {
2426
+ var t;
2427
+ W.allXhrSet.delete(a), e && ((t = W.xhrMap.get(e)) == null || t.delete(a));
2428
+ }, a;
2429
+ }
2430
+ static cancelXHRs() {
2431
+ var e;
2432
+ (e = W.xhrMap.get(this)) == null || e.forEach((e) => {
2433
+ e.abort(), W.allXhrSet.delete(e);
2434
+ }), W.xhrMap.delete(this);
2435
+ }
2436
+ static release() {
2437
+ W.allXhrSet.forEach((e) => e.abort()), W.allXhrSet.clear(), W.xhrMap = /* @__PURE__ */ new WeakMap();
2438
+ }
2439
+ }, $n = W;
2440
+ $n.xhrMap = /* @__PURE__ */ new WeakMap(), $n.allXhrSet = /* @__PURE__ */ new Set(), $n.loader = (e, t) => new Promise((t, n) => {
2441
+ W.createXHR(e.target, e.settings ? e.settings.resolveURL(e.url) : e.url, e.type, (n) => {
2442
+ e.result = n, t();
2443
+ }, n).send();
2444
+ });
2445
+ function er(e, t) {
2446
+ let n = -1;
2447
+ return r(0);
2448
+ function r(i, a) {
2449
+ if (a) return Promise.reject(a);
2450
+ if (i <= n) return Promise.reject(/* @__PURE__ */ Error("next() called multiple times"));
2451
+ n = i;
2452
+ let o = e[i];
2453
+ if (!o) return Promise.resolve();
2454
+ try {
2455
+ return Promise.resolve(o(t, r.bind(null, i + 1)));
2456
+ } catch (e) {
2457
+ return Promise.reject(e);
2458
+ }
2459
+ }
2460
+ }
2461
+ var G = class {
2462
+ static load(e) {
2463
+ return er(this.middlewares, e).then(() => e.result);
2464
+ }
2465
+ };
2466
+ G.middlewares = [$n.loader];
2467
+ function tr(e, t = {}) {
2468
+ let n = { resourceOptions: { crossorigin: t.crossOrigin } };
2469
+ if (s.fromURL) return s.fromURL(e, n).catch((e) => {
2470
+ if (e instanceof Error) throw e;
2471
+ let t = /* @__PURE__ */ Error("Texture loading error");
2472
+ throw t.event = e, t;
2473
+ });
2474
+ n.resourceOptions.autoLoad = !1;
2475
+ let r = s.from(e, n);
2476
+ if (r.baseTexture.valid) return Promise.resolve(r);
2477
+ let i = r.baseTexture.resource;
2478
+ return i._live2d_load ??= new Promise((e, t) => {
2479
+ let n = (e) => {
2480
+ i.source.removeEventListener("error", n);
2481
+ let r = /* @__PURE__ */ Error("Texture loading error");
2482
+ r.event = e, t(r);
2483
+ };
2484
+ i.source.addEventListener("error", n), i.load().then(() => e(r)).catch(n);
2485
+ }), i._live2d_load;
2486
+ }
2487
+ var nr = "Live2DFactory", rr = (e, t) => l(void 0, null, function* () {
2488
+ if (typeof e.source == "string") {
2489
+ let t = yield G.load({
2490
+ url: e.source,
2491
+ type: "json",
2492
+ target: e.live2dModel
2493
+ });
2494
+ t.url = e.source, e.source = t, e.live2dModel.emit("settingsJSONLoaded", t);
2495
+ }
2496
+ return t();
2497
+ }), ir = (e, t) => l(void 0, null, function* () {
2498
+ if (e.source instanceof Hn) return e.settings = e.source, t();
2499
+ if (typeof e.source == "object") {
2500
+ let n = q.findRuntime(e.source);
2501
+ if (n) {
2502
+ let r = n.createModelSettings(e.source);
2503
+ return e.settings = r, e.live2dModel.emit("settingsLoaded", r), t();
2504
+ }
2505
+ }
2506
+ throw TypeError("Unknown settings format.");
2507
+ }), ar = (e, t) => {
2508
+ if (e.settings) {
2509
+ let n = q.findRuntime(e.settings);
2510
+ if (n) return n.ready().then(t);
2511
+ }
2512
+ return t();
2513
+ }, or = (e, t) => l(void 0, null, function* () {
2514
+ yield t();
2515
+ let n = e.internalModel;
2516
+ if (n) {
2517
+ let t = e.settings, r = q.findRuntime(t);
2518
+ if (r) {
2519
+ let i = [];
2520
+ t.pose && i.push(G.load({
2521
+ settings: t,
2522
+ url: t.pose,
2523
+ type: "json",
2524
+ target: n
2525
+ }).then((t) => {
2526
+ n.pose = r.createPose(n.coreModel, t), e.live2dModel.emit("poseLoaded", n.pose);
2527
+ }).catch((t) => {
2528
+ e.live2dModel.emit("poseLoadError", t), H.warn(nr, "Failed to load pose.", t);
2529
+ })), t.physics && i.push(G.load({
2530
+ settings: t,
2531
+ url: t.physics,
2532
+ type: "json",
2533
+ target: n
2534
+ }).then((t) => {
2535
+ n.physics = r.createPhysics(n.coreModel, t), e.live2dModel.emit("physicsLoaded", n.physics);
2536
+ }).catch((t) => {
2537
+ e.live2dModel.emit("physicsLoadError", t), H.warn(nr, "Failed to load physics.", t);
2538
+ })), i.length && (yield Promise.all(i));
2539
+ }
2540
+ }
2541
+ }), sr = (e, t) => l(void 0, null, function* () {
2542
+ if (e.settings) {
2543
+ let n = e.live2dModel, r = e.settings.textures.map((t) => tr(e.settings.resolveURL(t), { crossOrigin: e.options.crossOrigin }));
2544
+ if (yield t(), e.internalModel) n.internalModel = e.internalModel, n.emit("modelLoaded", e.internalModel);
2545
+ else throw TypeError("Missing internal model.");
2546
+ n.textures = yield Promise.all(r), n.emit("textureLoaded", n.textures);
2547
+ } else throw TypeError("Missing settings.");
2548
+ }), cr = (e, t) => l(void 0, null, function* () {
2549
+ let n = e.settings;
2550
+ if (n instanceof Hn) {
2551
+ let r = q.findRuntime(n);
2552
+ if (!r) throw TypeError("Unknown model settings.");
2553
+ let i = yield G.load({
2554
+ settings: n,
2555
+ url: n.moc,
2556
+ type: "arraybuffer",
2557
+ target: e.live2dModel
2558
+ });
2559
+ if (!r.isValidMoc(i)) throw Error("Invalid moc data");
2560
+ let a = r.createCoreModel(i);
2561
+ return e.internalModel = r.createInternalModel(a, n, e.options), t();
2562
+ }
2563
+ throw TypeError("Missing settings.");
2564
+ }), K = class {
2565
+ static registerRuntime(e) {
2566
+ K.runtimes.push(e), K.runtimes.sort((e, t) => t.version - e.version);
2567
+ }
2568
+ static findRuntime(e) {
2569
+ for (let t of K.runtimes) if (t.test(e)) return t;
2570
+ }
2571
+ static setupLive2DModel(e, t, n) {
2572
+ return l(this, null, function* () {
2573
+ let r = new Promise((t) => e.once("textureLoaded", t)), i = new Promise((t) => e.once("modelLoaded", t)), a = Promise.all([r, i]).then(() => e.emit("ready"));
2574
+ yield er(K.live2DModelMiddlewares, {
2575
+ live2dModel: e,
2576
+ source: t,
2577
+ options: n || {}
2578
+ }), yield a, e.emit("load");
2579
+ });
2580
+ }
2581
+ static loadMotion(e, t, n) {
2582
+ let r = (r) => e.emit("motionLoadError", t, n, r);
2583
+ try {
2584
+ let i = e.definitions[t]?.[n];
2585
+ if (!i) return Promise.resolve(void 0);
2586
+ e.listeners("destroy").includes(K.releaseTasks) || e.once("destroy", K.releaseTasks);
2587
+ let a = K.motionTasksMap.get(e);
2588
+ a || (a = {}, K.motionTasksMap.set(e, a));
2589
+ let o = a[t];
2590
+ o || (o = [], a[t] = o);
2591
+ let s = e.getMotionFile(i);
2592
+ return o[n] ?? (o[n] = G.load({
2593
+ url: s,
2594
+ settings: e.settings,
2595
+ type: e.motionDataType,
2596
+ target: e
2597
+ }).then((r) => {
2598
+ let a = K.motionTasksMap.get(e)?.[t];
2599
+ a && delete a[n];
2600
+ let o = e.createMotion(r, t, i);
2601
+ return e.emit("motionLoaded", t, n, o), o;
2602
+ }).catch((t) => {
2603
+ H.warn(e.tag, `Failed to load motion: ${s}
2604
+ `, t), r(t);
2605
+ })), o[n];
2606
+ } catch (i) {
2607
+ H.warn(e.tag, `Failed to load motion at "${t}"[${n}]
2608
+ `, i), r(i);
2609
+ }
2610
+ return Promise.resolve(void 0);
2611
+ }
2612
+ static loadExpression(e, t) {
2613
+ let n = (n) => e.emit("expressionLoadError", t, n);
2614
+ try {
2615
+ let r = e.definitions[t];
2616
+ if (!r) return Promise.resolve(void 0);
2617
+ e.listeners("destroy").includes(K.releaseTasks) || e.once("destroy", K.releaseTasks);
2618
+ let i = K.expressionTasksMap.get(e);
2619
+ i || (i = [], K.expressionTasksMap.set(e, i));
2620
+ let a = e.getExpressionFile(r);
2621
+ return i[t] ?? (i[t] = G.load({
2622
+ url: a,
2623
+ settings: e.settings,
2624
+ type: "json",
2625
+ target: e
2626
+ }).then((n) => {
2627
+ let i = K.expressionTasksMap.get(e);
2628
+ i && delete i[t];
2629
+ let a = e.createExpression(n, r);
2630
+ return e.emit("expressionLoaded", t, a), a;
2631
+ }).catch((t) => {
2632
+ H.warn(e.tag, `Failed to load expression: ${a}
2633
+ `, t), n(t);
2634
+ })), i[t];
2635
+ } catch (r) {
2636
+ H.warn(e.tag, `Failed to load expression at [${t}]
2637
+ `, r), n(r);
2638
+ }
2639
+ return Promise.resolve(void 0);
2640
+ }
2641
+ static releaseTasks() {
2642
+ this instanceof Jn ? K.motionTasksMap.delete(this) : K.expressionTasksMap.delete(this);
2643
+ }
2644
+ }, q = K;
2645
+ q.runtimes = [], q.urlToJSON = rr, q.jsonToSettings = ir, q.waitUntilReady = ar, q.setupOptionals = or, q.setupEssentials = sr, q.createInternalModel = cr, q.live2DModelMiddlewares = [
2646
+ rr,
2647
+ ir,
2648
+ ar,
2649
+ or,
2650
+ sr,
2651
+ cr
2652
+ ], q.motionTasksMap = /* @__PURE__ */ new WeakMap(), q.expressionTasksMap = /* @__PURE__ */ new WeakMap(), Jn.prototype._loadMotion = function(e, t) {
2653
+ return q.loadMotion(this, e, t);
2654
+ }, Ln.prototype._loadExpression = function(e) {
2655
+ return q.loadExpression(this, e);
2656
+ };
2657
+ var lr = class {
2658
+ constructor() {
2659
+ this._autoInteract = !1;
2660
+ }
2661
+ get autoInteract() {
2662
+ return this._autoInteract;
2663
+ }
2664
+ set autoInteract(e) {
2665
+ e !== this._autoInteract && (e ? this.on("pointertap", ur, this) : this.off("pointertap", ur, this), this._autoInteract = e);
2666
+ }
2667
+ registerInteraction(e) {
2668
+ e !== this.interactionManager && (this.unregisterInteraction(), this._autoInteract && e && (this.interactionManager = e, e.on("pointermove", dr, this)));
2669
+ }
2670
+ unregisterInteraction() {
2671
+ var e;
2672
+ this.interactionManager &&= ((e = this.interactionManager) == null || e.off("pointermove", dr, this), void 0);
2673
+ }
2674
+ };
2675
+ function ur(e) {
2676
+ this.tap(e.data.global.x, e.data.global.y);
2677
+ }
2678
+ function dr(e) {
2679
+ this.focus(e.data.global.x, e.data.global.y);
2680
+ }
2681
+ var fr = class extends t {}, J = new e(), pr = new n(), Y, mr = class extends a {
2682
+ constructor(e) {
2683
+ super(), this.tag = "Live2DModel(uninitialized)", this.textures = [], this.transform = new fr(), this.anchor = new r(this.onAnchorChange, this, 0, 0), this.glContextID = -1, this.elapsedTime = performance.now(), this.deltaTime = 0, this._autoUpdate = !1, this.once("modelLoaded", () => this.init(e));
2684
+ }
2685
+ static from(e, t) {
2686
+ let n = new this(t);
2687
+ return q.setupLive2DModel(n, e, t).then(() => n);
2688
+ }
2689
+ static fromSync(e, t) {
2690
+ let n = new this(t);
2691
+ return q.setupLive2DModel(n, e, t).then(t?.onLoad).catch(t?.onError), n;
2692
+ }
2693
+ static registerTicker(e) {
2694
+ Y = e;
2695
+ }
2696
+ get autoUpdate() {
2697
+ return this._autoUpdate;
2698
+ }
2699
+ set autoUpdate(e) {
2700
+ Y ||= window.PIXI?.Ticker, e ? this._destroyed || (Y ? (Y.shared.add(this.onTickerUpdate, this), this._autoUpdate = !0) : H.warn(this.tag, "No Ticker registered, please call Live2DModel.registerTicker(Ticker).")) : (Y?.shared.remove(this.onTickerUpdate, this), this._autoUpdate = !1);
2701
+ }
2702
+ init(e) {
2703
+ this.tag = `Live2DModel(${this.internalModel.settings.name})`;
2704
+ let t = Object.assign({
2705
+ autoUpdate: !0,
2706
+ autoInteract: !0
2707
+ }, e);
2708
+ t.autoInteract && (this.interactive = !0), this.autoInteract = t.autoInteract, this.autoUpdate = t.autoUpdate;
2709
+ }
2710
+ onAnchorChange() {
2711
+ this.pivot.set(this.anchor.x * this.internalModel.width, this.anchor.y * this.internalModel.height);
2712
+ }
2713
+ motion(e, t, n) {
2714
+ return t === void 0 ? this.internalModel.motionManager.startRandomMotion(e, n) : this.internalModel.motionManager.startMotion(e, t, n);
2715
+ }
2716
+ expression(e) {
2717
+ return this.internalModel.motionManager.expressionManager ? e === void 0 ? this.internalModel.motionManager.expressionManager.setRandomExpression() : this.internalModel.motionManager.expressionManager.setExpression(e) : Promise.resolve(!1);
2718
+ }
2719
+ focus(e, t, n = !1) {
2720
+ J.x = e, J.y = t, this.toModelPosition(J, J, !0);
2721
+ let r = J.x / this.internalModel.originalWidth * 2 - 1, i = J.y / this.internalModel.originalHeight * 2 - 1, a = Math.atan2(i, r);
2722
+ this.internalModel.focusController.focus(Math.cos(a), -Math.sin(a), n);
2723
+ }
2724
+ tap(e, t) {
2725
+ let n = this.hitTest(e, t);
2726
+ n.length && (H.log(this.tag, "Hit", n), this.emit("hit", n));
2727
+ }
2728
+ hitTest(e, t) {
2729
+ return J.x = e, J.y = t, this.toModelPosition(J, J), this.internalModel.hitTest(J.x, J.y);
2730
+ }
2731
+ toModelPosition(e, t = e.clone(), n) {
2732
+ return n || (this._recursivePostUpdateTransform(), this.parent ? this.displayObjectUpdateTransform() : (this.parent = this._tempDisplayObjectParent, this.displayObjectUpdateTransform(), this.parent = null)), this.transform.worldTransform.applyInverse(e, t), this.internalModel.localTransform.applyInverse(t, t), t;
2733
+ }
2734
+ containsPoint(e) {
2735
+ return this.getBounds(!0).contains(e.x, e.y);
2736
+ }
2737
+ _calculateBounds() {
2738
+ this._bounds.addFrame(this.transform, 0, 0, this.internalModel.width, this.internalModel.height);
2739
+ }
2740
+ onTickerUpdate() {
2741
+ this.update(Y.shared.deltaMS);
2742
+ }
2743
+ update(e) {
2744
+ this.deltaTime += e, this.elapsedTime += e;
2745
+ }
2746
+ _render(e) {
2747
+ this.registerInteraction(e.plugins.interaction), e.batch.reset(), e.geometry.reset(), e.shader.reset(), e.state.reset();
2748
+ let t = !1;
2749
+ this.glContextID !== e.CONTEXT_UID && (this.glContextID = e.CONTEXT_UID, this.internalModel.updateWebGLContext(e.gl, this.glContextID), t = !0);
2750
+ for (let n = 0; n < this.textures.length; n++) {
2751
+ let r = this.textures[n];
2752
+ r.valid && ((t || !r.baseTexture._glTextures[this.glContextID]) && (e.gl.pixelStorei(WebGLRenderingContext.UNPACK_FLIP_Y_WEBGL, this.internalModel.textureFlipY), e.texture.bind(r.baseTexture, 0)), this.internalModel.bindTexture(n, r.baseTexture._glTextures[this.glContextID].texture), r.baseTexture.touched = e.textureGC.count);
2753
+ }
2754
+ let n = e.framebuffer.viewport;
2755
+ this.internalModel.viewport = [
2756
+ n.x,
2757
+ n.y,
2758
+ n.width,
2759
+ n.height
2760
+ ], this.deltaTime &&= (this.internalModel.update(this.deltaTime, this.elapsedTime), 0);
2761
+ let r = pr.copyFrom(e.globalUniforms.uniforms.projectionMatrix).append(this.worldTransform);
2762
+ this.internalModel.updateTransform(r), this.internalModel.draw(e.gl), e.state.reset(), e.texture.reset();
2763
+ }
2764
+ destroy(e) {
2765
+ this.emit("destroy"), this.autoUpdate = !1, this.unregisterInteraction(), e?.texture && this.textures.forEach((t) => t.destroy(e.baseTexture)), this.internalModel.destroy(), super.destroy(e);
2766
+ }
2767
+ };
2768
+ Pn(mr, [lr]);
2769
+ var X = class {
2770
+ static resolveURL(e, t) {
2771
+ let n = X.filesMap[e]?.[t];
2772
+ if (n === void 0) throw Error("Cannot find this file from uploaded files: " + t);
2773
+ return n;
2774
+ }
2775
+ static upload(e, t) {
2776
+ return l(this, null, function* () {
2777
+ let n = {};
2778
+ for (let r of t.getDefinedFiles()) {
2779
+ let a = decodeURI(i.resolve(t.url, r)), o = e.find((e) => e.webkitRelativePath === a);
2780
+ o && (n[r] = URL.createObjectURL(o));
2781
+ }
2782
+ X.filesMap[t._objectURL] = n;
2783
+ });
2784
+ }
2785
+ static createSettings(e) {
2786
+ return l(this, null, function* () {
2787
+ let t = e.find((e) => e.name.endsWith("model.json") || e.name.endsWith("model3.json"));
2788
+ if (!t) throw TypeError("Settings file not found");
2789
+ let n = yield X.readText(t), r = JSON.parse(n);
2790
+ r.url = t.webkitRelativePath;
2791
+ let i = q.findRuntime(r);
2792
+ if (!i) throw Error("Unknown settings JSON");
2793
+ let a = i.createModelSettings(r);
2794
+ return a._objectURL = URL.createObjectURL(t), a;
2795
+ });
2796
+ }
2797
+ static readText(e) {
2798
+ return l(this, null, function* () {
2799
+ return new Promise((t, n) => {
2800
+ let r = new FileReader();
2801
+ r.onload = () => t(r.result), r.onerror = n, r.readAsText(e, "utf8");
2802
+ });
2803
+ });
2804
+ }
2805
+ }, hr = X;
2806
+ hr.filesMap = {}, hr.factory = (e, t) => l(void 0, null, function* () {
2807
+ if (Array.isArray(e.source) && e.source[0] instanceof File) {
2808
+ let t = e.source, n = t.settings;
2809
+ if (!n) n = yield X.createSettings(t);
2810
+ else if (!n._objectURL) throw Error("\"_objectURL\" must be specified in ModelSettings");
2811
+ n.validateFiles(t.map((e) => encodeURI(e.webkitRelativePath))), yield X.upload(t, n), n.resolveURL = function(e) {
2812
+ return X.resolveURL(this._objectURL, e);
2813
+ }, e.source = n, e.live2dModel.once("modelLoaded", (e) => {
2814
+ e.once("destroy", function() {
2815
+ let e = this.settings._objectURL;
2816
+ if (URL.revokeObjectURL(e), X.filesMap[e]) for (let t of Object.values(X.filesMap[e])) URL.revokeObjectURL(t);
2817
+ delete X.filesMap[e];
2818
+ });
2819
+ });
2820
+ }
2821
+ return t();
2822
+ }), q.live2DModelMiddlewares.unshift(hr.factory);
2823
+ var Z = class {
2824
+ static unzip(e, t) {
2825
+ return l(this, null, function* () {
2826
+ let n = yield Z.getFilePaths(e), r = [];
2827
+ for (let e of t.getDefinedFiles()) {
2828
+ let a = decodeURI(i.resolve(t.url, e));
2829
+ n.includes(a) && r.push(a);
2830
+ }
2831
+ let a = yield Z.getFiles(e, r);
2832
+ for (let e = 0; e < a.length; e++) {
2833
+ let t = r[e], n = a[e];
2834
+ Object.defineProperty(n, "webkitRelativePath", { value: t });
2835
+ }
2836
+ return a;
2837
+ });
2838
+ }
2839
+ static createSettings(e) {
2840
+ return l(this, null, function* () {
2841
+ let t = (yield Z.getFilePaths(e)).find((e) => e.endsWith("model.json") || e.endsWith("model3.json"));
2842
+ if (!t) throw Error("Settings file not found");
2843
+ let n = yield Z.readText(e, t);
2844
+ if (!n) throw Error("Empty settings file: " + t);
2845
+ let r = JSON.parse(n);
2846
+ r.url = t;
2847
+ let i = q.findRuntime(r);
2848
+ if (!i) throw Error("Unknown settings JSON");
2849
+ return i.createModelSettings(r);
2850
+ });
2851
+ }
2852
+ static zipReader(e, t) {
2853
+ return l(this, null, function* () {
2854
+ throw Error("Not implemented");
2855
+ });
2856
+ }
2857
+ static getFilePaths(e) {
2858
+ return l(this, null, function* () {
2859
+ throw Error("Not implemented");
2860
+ });
2861
+ }
2862
+ static getFiles(e, t) {
2863
+ return l(this, null, function* () {
2864
+ throw Error("Not implemented");
2865
+ });
2866
+ }
2867
+ static readText(e, t) {
2868
+ return l(this, null, function* () {
2869
+ throw Error("Not implemented");
2870
+ });
2871
+ }
2872
+ static releaseReader(e) {}
2873
+ }, Q = Z;
2874
+ if (Q.ZIP_PROTOCOL = "zip://", Q.uid = 0, Q.factory = (e, t) => l(void 0, null, function* () {
2875
+ let n = e.source, r, i, a;
2876
+ if (typeof n == "string" && (n.endsWith(".zip") || n.startsWith(Z.ZIP_PROTOCOL)) ? (r = n.startsWith(Z.ZIP_PROTOCOL) ? n.slice(Z.ZIP_PROTOCOL.length) : n, i = yield G.load({
2877
+ url: r,
2878
+ type: "blob",
2879
+ target: e.live2dModel
2880
+ })) : Array.isArray(n) && n.length === 1 && n[0] instanceof File && n[0].name.endsWith(".zip") && (i = n[0], r = URL.createObjectURL(i), a = n.settings), i) {
2881
+ if (!i.size) throw Error("Empty zip file");
2882
+ let t = yield Z.zipReader(i, r);
2883
+ a ||= yield Z.createSettings(t), a._objectURL = Z.ZIP_PROTOCOL + Z.uid + "/" + a.url;
2884
+ let n = yield Z.unzip(t, a);
2885
+ n.settings = a, e.source = n, r.startsWith("blob:") && e.live2dModel.once("modelLoaded", (e) => {
2886
+ e.once("destroy", function() {
2887
+ URL.revokeObjectURL(r);
2888
+ });
2889
+ }), Z.releaseReader(t);
2890
+ }
2891
+ return t();
2892
+ }), q.live2DModelMiddlewares.unshift(Q.factory), !window.Live2DCubismCore) throw Error("Could not find Cubism 4 runtime. This plugin requires live2dcubismcore.js to be loaded.");
2893
+ var gr = class extends Ln {
2894
+ constructor(e, t) {
2895
+ super(e, t), this.queueManager = new Ie(), this.definitions = e.expressions ?? [], this.init();
2896
+ }
2897
+ isFinished() {
2898
+ return this.queueManager.isFinished();
2899
+ }
2900
+ getExpressionIndex(e) {
2901
+ return this.definitions.findIndex((t) => t.Name === e);
2902
+ }
2903
+ getExpressionFile(e) {
2904
+ return e.File;
2905
+ }
2906
+ createExpression(e, t) {
2907
+ return me.create(e);
2908
+ }
2909
+ _setExpression(e) {
2910
+ return this.queueManager.startMotion(e, !1, performance.now());
2911
+ }
2912
+ stopAllExpressions() {
2913
+ this.queueManager.stopAllMotions();
2914
+ }
2915
+ updateParameters(e, t) {
2916
+ return this.queueManager.doUpdateMotion(e, t);
2917
+ }
2918
+ }, $ = class e extends Hn {
2919
+ constructor(t) {
2920
+ if (super(t), !e.isValidJSON(t)) throw TypeError("Invalid JSON.");
2921
+ Object.assign(this, new jt(t));
2922
+ }
2923
+ static isValidJSON(e) {
2924
+ return !!e?.FileReferences && typeof e.FileReferences.Moc == "string" && e.FileReferences.Textures?.length > 0 && e.FileReferences.Textures.every((e) => typeof e == "string");
2925
+ }
2926
+ replaceFiles(e) {
2927
+ if (super.replaceFiles(e), this.motions) for (let [t, n] of Object.entries(this.motions)) for (let r = 0; r < n.length; r++) n[r].File = e(n[r].File, `motions.${t}[${r}].File`), n[r].Sound !== void 0 && (n[r].Sound = e(n[r].Sound, `motions.${t}[${r}].Sound`));
2928
+ if (this.expressions) for (let t = 0; t < this.expressions.length; t++) this.expressions[t].File = e(this.expressions[t].File, `expressions[${t}].File`);
2929
+ }
2930
+ };
2931
+ Pn($, [jt]);
2932
+ var _r = class extends Jn {
2933
+ constructor(e, t) {
2934
+ super(e, t), this.groups = { idle: "Idle" }, this.motionDataType = "json", this.queueManager = new Ie(), this.definitions = e.motions ?? {}, this.eyeBlinkIds = e.getEyeBlinkParameters() || [], this.lipSyncIds = e.getLipSyncParameters() || [], this.init(t);
2935
+ }
2936
+ init(e) {
2937
+ super.init(e), this.settings.expressions && (this.expressionManager = new gr(this.settings, e)), this.queueManager.setEventCallback((e, t, n) => {
2938
+ this.emit("motion:" + t);
2939
+ });
2940
+ }
2941
+ isFinished() {
2942
+ return this.queueManager.isFinished();
2943
+ }
2944
+ _startMotion(e, t) {
2945
+ return e.setFinishedMotionHandler(t), this.queueManager.stopAllMotions(), this.queueManager.startMotion(e, !1, performance.now());
2946
+ }
2947
+ _stopAllMotions() {
2948
+ this.queueManager.stopAllMotions();
2949
+ }
2950
+ createMotion(e, t, n) {
2951
+ let r = Pe.create(e), i = new be(e), a = (t === this.groups.idle ? V.idleMotionFadingDuration : V.motionFadingDuration) / 1e3;
2952
+ return i.getMotionFadeInTime() === void 0 && r.setFadeInTime(n.FadeInTime > 0 ? n.FadeInTime : a), i.getMotionFadeOutTime() === void 0 && r.setFadeOutTime(n.FadeOutTime > 0 ? n.FadeOutTime : a), r.setEffectIds(this.eyeBlinkIds, this.lipSyncIds), r;
2953
+ }
2954
+ getMotionFile(e) {
2955
+ return e.File;
2956
+ }
2957
+ getMotionName(e) {
2958
+ return e.File;
2959
+ }
2960
+ getSoundFile(e) {
2961
+ return e.Sound;
2962
+ }
2963
+ updateParameters(e, t) {
2964
+ return this.queueManager.doUpdateMotion(e, t);
2965
+ }
2966
+ destroy() {
2967
+ super.destroy(), this.queueManager.release(), this.queueManager = void 0;
2968
+ }
2969
+ }, vr = new b(), yr = class extends Xn {
2970
+ constructor(e, t, r) {
2971
+ super(), this.lipSync = !0, this.breath = u.create(), this.renderer = new At(), this.idParamAngleX = zt, this.idParamAngleY = Bt, this.idParamAngleZ = Vt, this.idParamEyeBallX = Kt, this.idParamEyeBallY = qt, this.idParamBodyAngleX = sn, this.idParamBreath = un, this.pixelsPerUnit = 1, this.centeringTransform = new n(), this.coreModel = e, this.settings = t, this.motionManager = new _r(t, r), this.init();
2972
+ }
2973
+ init() {
2974
+ super.init(), this.settings.getEyeBlinkParameters()?.length > 0 && (this.eyeBlink = p.create(this.settings)), this.breath.setParameters([
2975
+ new d(this.idParamAngleX, 0, 15, 6.5345, .5),
2976
+ new d(this.idParamAngleY, 0, 8, 3.5345, .5),
2977
+ new d(this.idParamAngleZ, 0, 10, 5.5345, .5),
2978
+ new d(this.idParamBodyAngleX, 0, 4, 15.5345, .5),
2979
+ new d(this.idParamBreath, 0, .5, 3.2345, .5)
2980
+ ]), this.renderer.initialize(this.coreModel), this.renderer.setIsPremultipliedAlpha(!0);
2981
+ }
2982
+ getSize() {
2983
+ return [this.coreModel.getModel().canvasinfo.CanvasWidth, this.coreModel.getModel().canvasinfo.CanvasHeight];
2984
+ }
2985
+ getLayout() {
2986
+ let e = {};
2987
+ if (this.settings.layout) for (let t of Object.keys(this.settings.layout)) {
2988
+ let n = t.charAt(0).toLowerCase() + t.slice(1);
2989
+ e[n] = this.settings.layout[t];
2990
+ }
2991
+ return e;
2992
+ }
2993
+ setupLayout() {
2994
+ super.setupLayout(), this.pixelsPerUnit = this.coreModel.getModel().canvasinfo.PixelsPerUnit, this.centeringTransform.scale(this.pixelsPerUnit, this.pixelsPerUnit).translate(this.originalWidth / 2, this.originalHeight / 2);
2995
+ }
2996
+ updateWebGLContext(e, t) {
2997
+ this.renderer.firstDraw = !0, this.renderer._bufferData = {
2998
+ vertex: null,
2999
+ uv: null,
3000
+ index: null
3001
+ }, this.renderer.startUp(e), this.renderer._clippingManager._currentFrameNo = t, this.renderer._clippingManager._maskTexture = void 0, z.getInstance()._shaderSets = [];
3002
+ }
3003
+ bindTexture(e, t) {
3004
+ this.renderer.bindTexture(e, t);
3005
+ }
3006
+ getHitAreaDefs() {
3007
+ return this.settings.hitAreas?.map((e) => ({
3008
+ id: e.Id,
3009
+ name: e.Name,
3010
+ index: this.coreModel.getDrawableIndex(e.Id)
3011
+ })) ?? [];
3012
+ }
3013
+ getDrawableIDs() {
3014
+ return this.coreModel.getDrawableIds();
3015
+ }
3016
+ getDrawableIndex(e) {
3017
+ return this.coreModel.getDrawableIndex(e);
3018
+ }
3019
+ getDrawableVertices(e) {
3020
+ if (typeof e == "string" && (e = this.coreModel.getDrawableIndex(e), e === -1)) throw TypeError("Unable to find drawable ID: " + e);
3021
+ let t = this.coreModel.getDrawableVertices(e).slice();
3022
+ for (let e = 0; e < t.length; e += 2) t[e] = t[e] * this.pixelsPerUnit + this.originalWidth / 2, t[e + 1] = -t[e + 1] * this.pixelsPerUnit + this.originalHeight / 2;
3023
+ return t;
3024
+ }
3025
+ updateTransform(e) {
3026
+ this.drawingMatrix.copyFrom(this.centeringTransform).prepend(this.localTransform).prepend(e);
3027
+ }
3028
+ update(e, t) {
3029
+ var n, r, i, a;
3030
+ super.update(e, t), e /= 1e3, t /= 1e3;
3031
+ let o = this.coreModel;
3032
+ this.emit("beforeMotionUpdate");
3033
+ let s = this.motionManager.update(this.coreModel, t);
3034
+ this.emit("afterMotionUpdate"), o.saveParameters(), (n = this.motionManager.expressionManager) == null || n.update(o, t), s || (r = this.eyeBlink) == null || r.updateParameters(o, e), this.updateFocus(), this.updateNaturalMovements(e * 1e3, t * 1e3), (i = this.physics) == null || i.evaluate(o, e), (a = this.pose) == null || a.updateParameters(o, e), this.emit("beforeModelUpdate"), o.update(), o.loadParameters();
3035
+ }
3036
+ updateFocus() {
3037
+ this.coreModel.addParameterValueById(this.idParamEyeBallX, this.focusController.x), this.coreModel.addParameterValueById(this.idParamEyeBallY, this.focusController.y), this.coreModel.addParameterValueById(this.idParamAngleX, this.focusController.x * 30), this.coreModel.addParameterValueById(this.idParamAngleY, this.focusController.y * 30), this.coreModel.addParameterValueById(this.idParamAngleZ, this.focusController.x * this.focusController.y * -30), this.coreModel.addParameterValueById(this.idParamBodyAngleX, this.focusController.x * 10);
3038
+ }
3039
+ updateNaturalMovements(e, t) {
3040
+ var n;
3041
+ (n = this.breath) == null || n.updateParameters(this.coreModel, e / 1e3);
3042
+ }
3043
+ draw(e) {
3044
+ let t = this.drawingMatrix, n = vr.getArray();
3045
+ n[0] = t.a, n[1] = t.b, n[4] = -t.c, n[5] = -t.d, n[12] = t.tx, n[13] = t.ty, this.renderer.setMvpMatrix(vr), this.renderer.setRenderState(e.getParameter(e.FRAMEBUFFER_BINDING), this.viewport), this.renderer.drawModel();
3046
+ }
3047
+ destroy() {
3048
+ super.destroy(), this.renderer.release(), this.coreModel.release(), this.renderer = void 0, this.coreModel = void 0;
3049
+ }
3050
+ }, br, xr = 20;
3051
+ function Sr() {
3052
+ return E.isStarted() ? Promise.resolve() : (br ??= new Promise((e, t) => {
3053
+ function n() {
3054
+ try {
3055
+ Cr(), e();
3056
+ } catch (e) {
3057
+ if (xr--, xr < 0) {
3058
+ let n = /* @__PURE__ */ Error("Failed to start up Cubism 4 framework.");
3059
+ n.cause = e, t(n);
3060
+ return;
3061
+ }
3062
+ H.log("Cubism4", "Startup failed, retrying 10ms later..."), setTimeout(n, 10);
3063
+ }
3064
+ }
3065
+ n();
3066
+ }), br);
3067
+ }
3068
+ function Cr(e) {
3069
+ e = Object.assign({
3070
+ logFunction: console.log,
3071
+ loggingLevel: D.LogLevel_Verbose
3072
+ }, e), E.startUp(e), E.initialize();
3073
+ }
3074
+ q.registerRuntime({
3075
+ version: 4,
3076
+ ready: Sr,
3077
+ test(e) {
3078
+ return e instanceof $ || $.isValidJSON(e);
3079
+ },
3080
+ isValidMoc(e) {
3081
+ if (e.byteLength < 4) return !1;
3082
+ let t = new Int8Array(e, 0, 4);
3083
+ return String.fromCharCode(...t) === "MOC3";
3084
+ },
3085
+ createModelSettings(e) {
3086
+ return new $(e);
3087
+ },
3088
+ createCoreModel(e) {
3089
+ let t = ce.create(e);
3090
+ try {
3091
+ let e = t.createModel();
3092
+ return e.__moc = t, e;
3093
+ } catch (e) {
3094
+ try {
3095
+ t.release();
3096
+ } catch {}
3097
+ throw e;
3098
+ }
3099
+ },
3100
+ createInternalModel(e, t, n) {
3101
+ let r = new yr(e, t, n), i = e;
3102
+ return i.__moc && (r.__moc = i.__moc, delete i.__moc, r.once("destroy", wr)), r;
3103
+ },
3104
+ createPhysics(e, t) {
3105
+ return $e.create(t);
3106
+ },
3107
+ createPose(e, t) {
3108
+ return _.create(t);
3109
+ }
3110
+ });
3111
+ function wr() {
3112
+ var e;
3113
+ (e = this.__moc) == null || e.release();
3114
+ }
3115
+ //#endregion
3116
+ export { fe as ACubismMotion, d as BreathParameterData, ie as CSM_ASSERT, re as Constant, gr as Cubism4ExpressionManager, yr as Cubism4InternalModel, $ as Cubism4ModelSettings, _r as Cubism4MotionManager, x as CubismBlendMode, u as CubismBreath, St as CubismClippingContext, bt as CubismClippingManager_WebGL, he as CubismConfig, j as CubismDebug, me as CubismExpressionMotion, p as CubismEyeBlink, E as CubismFramework, oe as CubismLogDebug, A as CubismLogError, O as CubismLogInfo, ae as CubismLogVerbose, k as CubismLogWarning, y as CubismMath, b as CubismMatrix44, ce as CubismMoc, se as CubismModel, jt as CubismModelSettingsJson, de as CubismModelUserData, le as CubismModelUserDataJson, Pe as CubismMotion, _e as CubismMotionCurve, N as CubismMotionCurveTarget, ye as CubismMotionData, ve as CubismMotionEvent, be as CubismMotionJson, Re as CubismMotionManager, F as CubismMotionPoint, Fe as CubismMotionQueueEntry, Ie as CubismMotionQueueManager, ge as CubismMotionSegment, P as CubismMotionSegmentType, $e as CubismPhysics, Ue as CubismPhysicsInput, Ke as CubismPhysicsJson, We as CubismPhysicsOutput, Ve as CubismPhysicsParticle, Ge as CubismPhysicsRig, L as CubismPhysicsSource, He as CubismPhysicsSubRig, ze as CubismPhysicsTargetType, _ as CubismPose, xt as CubismRenderTextureResource, ne as CubismRenderer, At as CubismRenderer_WebGL, z as CubismShader_WebGL, S as CubismTextureColor, v as CubismVector2, xe as EvaluationOptionFlag, M as ExpressionBlendType, Ln as ExpressionManager, m as EyeState, hr as FileLoader, Vn as FocusController, Pt as HitAreaBody, Nt as HitAreaHead, Mt as HitAreaPrefix, lr as InteractionMixin, Xn as InternalModel, Le as InvalidMotionQueueEntryHandleValue, On as LOGICAL_HEIGHT, Dn as LOGICAL_WIDTH, q as Live2DFactory, G as Live2DLoader, mr as Live2DModel, fr as Live2DTransform, D as LogLevel, Hn as ModelSettings, Jn as MotionManager, qn as MotionPreloadStrategy, Un as MotionPriority, Wn as MotionState, et as Options, zt as ParamAngleX, Bt as ParamAngleY, Vt as ParamAngleZ, dn as ParamArmLA, pn as ParamArmLB, fn as ParamArmRA, mn as ParamArmRB, wn as ParamBaseX, Tn as ParamBaseY, sn as ParamBodyAngleX, cn as ParamBodyAngleY, ln as ParamBodyAngleZ, un as ParamBreath, $t as ParamBrowLAngle, tn as ParamBrowLForm, Zt as ParamBrowLX, Yt as ParamBrowLY, en as ParamBrowRAngle, nn as ParamBrowRForm, Qt as ParamBrowRX, Xt as ParamBrowRY, Sn as ParamBustX, Cn as ParamBustY, on as ParamCheek, Jt as ParamEyeBallForm, Kt as ParamEyeBallX, qt as ParamEyeBallY, Ht as ParamEyeLOpen, Ut as ParamEyeLSmile, Wt as ParamEyeROpen, Gt as ParamEyeRSmile, yn as ParamHairBack, bn as ParamHairFluffy, _n as ParamHairFront, vn as ParamHairSide, hn as ParamHandL, gn as ParamHandR, rn as ParamMouthForm, an as ParamMouthOpenY, En as ParamNONE, xn as ParamShoulderY, ee as PartData, Lt as PartsArmLPrefix, It as PartsArmPrefix, Rt as PartsArmRPrefix, Ft as PartsIdCore, Be as PhysicsJsonEffectiveForces, B as ShaderNames, U as SoundManager, kn as VERSION, $n as XHRLoader, Q as ZipLoader, Pn as applyMixins, An as clamp, V as config, Nn as copyArray, Mn as copyProperty, ht as csmRect, Sr as cubism4Ready, Fn as folderName, kt as fragmentShaderSrcMaskInvertedPremultipliedAlpha, Ot as fragmentShaderSrcMaskPremultipliedAlpha, Dt as fragmentShaderSrcPremultipliedAlpha, wt as fragmentShaderSrcsetupMask, H as logger, jn as rand, In as remove, Cr as startUpCubism4, Tt as vertexShaderSrc, Et as vertexShaderSrcMasked, Ct as vertexShaderSrcSetupMask };