@sage-rsc/talking-head-react 1.0.66 → 1.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- import { jsxs as Ee, jsx as de } from "react/jsx-runtime";
2
- import { forwardRef as Le, useRef as Z, useState as ge, useEffect as ye, useCallback as E, useImperativeHandle as Ae, useLayoutEffect as We } from "react";
1
+ import { jsxs as De, jsx as ge } from "react/jsx-runtime";
2
+ import { forwardRef as ze, useRef as N, useState as be, useEffect as Re, useCallback as M, useImperativeHandle as Ce, useLayoutEffect as Xe } from "react";
3
3
  import * as f from "three";
4
- import { OrbitControls as Ve } from "three/addons/controls/OrbitControls.js";
5
- import { GLTFLoader as Ge } from "three/addons/loaders/GLTFLoader.js";
6
- import { DRACOLoader as Ze } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as ze } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as Xe } from "three/addons/environments/RoomEnvironment.js";
9
- import Ye from "three/addons/libs/stats.module.js";
10
- let m, $, ne;
11
- const A = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(), _ = new f.Vector3(), ve = new f.Vector3();
4
+ import { OrbitControls as Ye } from "three/addons/controls/OrbitControls.js";
5
+ import { GLTFLoader as je } from "three/addons/loaders/GLTFLoader.js";
6
+ import { DRACOLoader as Qe } from "three/addons/loaders/DRACOLoader.js";
7
+ import { FBXLoader as Me } from "three/addons/loaders/FBXLoader.js";
8
+ import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
9
+ import _e from "three/addons/libs/stats.module.js";
10
+ let m, ee, ne;
11
+ const A = [0, 0, 0, 0], k = new f.Vector3(), Ae = new f.Vector3(), _ = new f.Vector3(), Se = new f.Vector3();
12
12
  new f.Plane();
13
13
  new f.Ray();
14
14
  new f.Euler();
15
- const K = new f.Quaternion(), Ce = new f.Quaternion(), re = new f.Matrix4(), le = new f.Matrix4();
15
+ const K = new f.Quaternion(), Ee = new f.Quaternion(), le = new f.Matrix4(), he = new f.Matrix4();
16
16
  new f.Vector3();
17
- const Re = new f.Vector3(0, 0, 1), je = new f.Vector3(1, 0, 0), Qe = new f.Vector3(0, 1, 0), qe = new f.Vector3(0, 0, 1);
18
- class _e {
17
+ const ke = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), Je = new f.Vector3(0, 1, 0), $e = new f.Vector3(0, 0, 1);
18
+ class et {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
21
21
  warmupMs: 2e3,
@@ -202,7 +202,7 @@ class _e {
202
202
  deltaLocal: null
203
203
  };
204
204
  if (s.deltaLocal) {
205
- if (!Array.isArray(s.deltaLocal) || s.deltaLocal.length !== 3 || s.deltaLocal.some((a) => Number.isNaN(a))) throw new Error("deltaLocal must be an array of three numbers in #" + o + " exclude.");
205
+ if (!Array.isArray(s.deltaLocal) || s.deltaLocal.length !== 3 || s.deltaLocal.some((r) => Number.isNaN(r))) throw new Error("deltaLocal must be an array of three numbers in #" + o + " exclude.");
206
206
  u.deltaLocal = [...s.deltaLocal];
207
207
  }
208
208
  i.excludes.push(u);
@@ -310,22 +310,22 @@ class _e {
310
310
  i(s.bone, l + "Bone not specified.");
311
311
  const u = s.bone;
312
312
  i(typeof u == "string" && u.length > 0, l + "Bone name must be a non-empty string.");
313
- const a = this.armature.getObjectByName(u);
314
- i(a, l + "Bone '" + u + "' not found."), i(a.parent?.isBone, l + "Bone must have a parent bone."), i(this.data.every((r) => r.bone !== a), l + "Bone '" + u + "' already exists."), a.updateMatrixWorld(!0);
313
+ const r = this.armature.getObjectByName(u);
314
+ i(r, l + "Bone '" + u + "' not found."), i(r.parent?.isBone, l + "Bone must have a parent bone."), i(this.data.every((a) => a.bone !== r), l + "Bone '" + u + "' already exists."), r.updateMatrixWorld(!0);
315
315
  const h = {
316
316
  name: u,
317
317
  // Bone name
318
- bone: a,
318
+ bone: r,
319
319
  // Bone object
320
- boneParent: a.parent,
320
+ boneParent: r.parent,
321
321
  /// Bone's parent object
322
- vBasis: a.position.clone(),
322
+ vBasis: r.position.clone(),
323
323
  // Original local position
324
- vWorld: a.parent.getWorldPosition(k).clone(),
324
+ vWorld: r.parent.getWorldPosition(k).clone(),
325
325
  // World position, parent
326
- qBasis: a.parent.quaternion.clone(),
326
+ qBasis: r.parent.quaternion.clone(),
327
327
  // Original quaternion, parent
328
- l: a.position.length(),
328
+ l: r.position.length(),
329
329
  // Bone length
330
330
  p: [0, 0, 0, 0],
331
331
  // Relative position [m]
@@ -338,11 +338,11 @@ class _e {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- h.boneParent.matrixWorld.decompose(k, K, _), k.copy(Re).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ h.boneParent.matrixWorld.decompose(k, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
342
342
  try {
343
343
  this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
344
- } catch (r) {
345
- i(!1, l + r);
344
+ } catch (a) {
345
+ i(!1, l + a);
346
346
  }
347
347
  }), this.sortBones(), this.start();
348
348
  }
@@ -356,22 +356,22 @@ class _e {
356
356
  for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, i = this.objectsUpdate.length; e < i; e++)
357
357
  o = this.objectsUpdate[e], o.updateMatrix(), o.parent === null ? o.matrixWorld.copy(o.matrix) : o.matrixWorld.multiplyMatrices(o.parent.matrixWorld, o.matrix), o.matrixWorldNeedsUpdate = !1;
358
358
  for (e = 0, i = this.data.length; e < i; e++) {
359
- if (o = this.data[e], k.copy(o.vWorld), re.copy(o.boneParent.matrixWorld), le.copy(re).invert(), o.vWorld.setFromMatrixPosition(re), k.applyMatrix4(le), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
359
+ if (o = this.data[e], k.copy(o.vWorld), le.copy(o.boneParent.matrixWorld), he.copy(le).invert(), o.vWorld.setFromMatrixPosition(le), k.applyMatrix4(he), k.length() > 0.5 && (console.info("Info: Unrealistic jump of " + k.length().toFixed(2) + " meters."), k.setLength(0.5)), k.applyQuaternion(o.bone.quaternion), A[0] = k.x, A[1] = k.y, A[2] = -k.z, A[3] = k.length() / 3, o.children)
360
360
  for (n = 0, s = o.children.length; n < s; n++)
361
361
  m = o.children[n], A[0] -= m.v[0] * t / 3, A[1] -= m.v[1] * t / 3, A[2] += m.v[2] * t / 3, A[3] -= m.v[3] * t / 3;
362
362
  if (m = this.opt.sensitivityFactor, A[0] *= o.ext * m, A[1] *= o.ext * m, A[2] *= o.ext * m, A[3] *= o.ext * m, o.isX && (m = A[0] / t, o.ea[0] = (m - o.ev[0]) / t, o.ev[0] = m, o.a[0] = -o.k[0] * o.p[0] - o.c[0] * o.v[0] - o.ea[0], o.p[0] += o.v[0] * t + o.a[0] * t * t / 2 + A[0], m = o.v[0] + o.a[0] * t / 2, m = -o.k[0] * o.p[0] - o.c[0] * m - o.ea[0], o.v[0] = o.v[0] + (m + o.a[0]) * t / 2), o.isY && (m = A[1] / t, o.ea[1] = (m - o.ev[1]) / t, o.ev[1] = m, o.a[1] = -o.k[1] * o.p[1] - o.c[1] * o.v[1] - o.ea[1], o.p[1] += o.v[1] * t + o.a[1] * t * t / 2 + A[1], m = o.v[1] + o.a[1] * t / 2, m = -o.k[1] * o.p[1] - o.c[1] * m - o.ea[1], o.v[1] = o.v[1] + (m + o.a[1]) * t / 2), o.isZ && (m = A[2] / t, o.ea[2] = (m - o.ev[2]) / t, o.ev[2] = m, o.a[2] = -o.k[2] * o.p[2] - o.c[2] * o.v[2] - o.ea[2], o.p[2] += o.v[2] * t + o.a[2] * t * t / 2 + A[2], m = o.v[2] + o.a[2] * t / 2, m = -o.k[2] * o.p[2] - o.c[2] * m - o.ea[2], o.v[2] = o.v[2] + (m + o.a[2]) * t / 2), o.isT && (m = A[3] / t, o.ea[3] = (m - o.ev[3]) / t, o.ev[3] = m, o.a[3] = -o.k[3] * o.p[3] - o.c[3] * o.v[3] - o.ea[3], o.p[3] += o.v[3] * t + o.a[3] * t * t / 2 + A[3], m = o.v[3] + o.a[3] * t / 2, m = -o.k[3] * o.p[3] - o.c[3] * m - o.ea[3], o.v[3] = o.v[3] + (m + o.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (o.v[0] *= 1e-4, o.p[0] *= 1e-4, o.v[1] *= 1e-4, o.p[1] *= 1e-4, o.v[2] *= 1e-4, o.p[2] *= 1e-4, o.v[3] *= 1e-4, o.p[3] *= 1e-4), A[0] = o.p[0], A[1] = o.p[1], A[2] = o.p[2], A[3] = o.p[3], m = this.opt.movementFactor, A[0] *= m, A[1] *= m, A[2] *= m, A[3] *= m, o.dl && (m = o.dl, A[0] += m[0], A[1] += m[1], A[2] += m[2]), o.dw && (m = o.dw, k.set(
363
363
  o.vBasis.x + A[0],
364
364
  o.vBasis.y + A[1],
365
365
  o.vBasis.z + A[2]
366
- ), k.applyMatrix4(re), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(le), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
366
+ ), k.applyMatrix4(le), k.x += m[0], k.y += m[1], k.z += m[2], k.applyMatrix4(he), A[0] += k.x - o.vBasis.x, A[1] += k.y - o.vBasis.y, A[2] += k.z - o.vBasis.z), o.limits && this.opt.isLimits && (m = o.limits, m[0] && (m[0][0] !== null && A[0] < m[0][0] && (A[0] = m[0][0]), m[0][1] !== null && A[0] > m[0][1] && (A[0] = m[0][1])), m[1] && (m[1][0] !== null && A[1] < m[1][0] && (A[1] = m[1][0]), m[1][1] !== null && A[1] > m[1][1] && (A[1] = m[1][1])), m[2] && (m[2][0] !== null && A[2] < m[2][0] && (A[2] = m[2][0]), m[2][1] !== null && A[2] > m[2][1] && (A[2] = m[2][1])), m[3] && (m[3][0] !== null && A[3] < m[3][0] && (A[3] = m[3][0]), m[3][1] !== null && A[3] > m[3][1] && (A[3] = m[3][1]))), o.isPoint)
367
367
  o.bone.position.set(
368
368
  o.vBasis.x + A[0],
369
369
  o.vBasis.y + A[1],
370
370
  o.vBasis.z - A[2]
371
371
  );
372
- else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, K, _), k.copy(Re).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ce.setFromUnitVectors(Re, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle(qe, -m), o.boneParent.quaternion.multiply(K)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), K.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Qe, -m), o.boneParent.quaternion.multiply(K)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
372
+ else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(K)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), K.setFromAxisAngle(Ke, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(K)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (n = 0, s = o.excludes.length; n < s; n++)
374
- m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), le.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(le), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), $ = _.length(), !($ > m.radius + ne) && ($ < Math.abs(m.radius - ne) || ($ = ($ * $ + ne * ne - m.radiusSq) / (2 * $), _.normalize(), ve.copy(_).multiplyScalar($), $ = Math.sqrt(ne * ne - $ * $), k.subVectors(k, ve).projectOnPlane(_).normalize().multiplyScalar($), be.subVectors(o.vBasis, ve).projectOnPlane(_).normalize(), ne = be.dot(k), ne < 0 && (ne = Math.sqrt($ * $ - ne * ne), be.multiplyScalar(ne), k.add(be)), k.add(ve).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), he.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(he), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), ee = _.length(), !(ee > m.radius + ne) && (ee < Math.abs(m.radius - ne) || (ee = (ee * ee + ne * ne - m.radiusSq) / (2 * ee), _.normalize(), Se.copy(_).multiplyScalar(ee), ee = Math.sqrt(ne * ne - ee * ee), k.subVectors(k, Se).projectOnPlane(_).normalize().multiplyScalar(ee), Ae.subVectors(o.vBasis, Se).projectOnPlane(_).normalize(), ne = Ae.dot(k), ne < 0 && (ne = Math.sqrt(ee * ee - ne * ne), Ae.multiplyScalar(ne), k.add(Ae)), k.add(Se).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -442,17 +442,17 @@ class _e {
442
442
  */
443
443
  updateHelpers() {
444
444
  if (m = this.helpers.points, m.bones.length) {
445
- le.copy(this.armature.matrixWorld).invert();
445
+ he.copy(this.armature.matrixWorld).invert();
446
446
  const t = m.object.geometry.getAttribute("position");
447
447
  for (let e = 0, n = m.bones.length; e < n; e++)
448
- re.multiplyMatrices(le, m.bones[e].matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(e, k.x, k.y, k.z);
448
+ le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(e, k.x, k.y, k.z);
449
449
  t.needsUpdate = !0, m.object.updateMatrixWorld();
450
450
  }
451
451
  if (m = this.helpers.lines, m.bones.length) {
452
- le.copy(this.armature.matrixWorld).invert();
452
+ he.copy(this.armature.matrixWorld).invert();
453
453
  const t = m.object.geometry.getAttribute("position");
454
454
  for (let e = 0, n = 0, i = m.bones.length; e < i; e++, n += 2)
455
- re.multiplyMatrices(le, m.bones[e].matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(n, k.x, k.y, k.z), re.multiplyMatrices(le, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(re), t.setXYZ(n + 1, k.x, k.y, k.z);
455
+ le.multiplyMatrices(he, m.bones[e].matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(n, k.x, k.y, k.z), le.multiplyMatrices(he, m.bones[e].parent.matrixWorld), k.setFromMatrixPosition(le), t.setXYZ(n + 1, k.x, k.y, k.z);
456
456
  t.needsUpdate = !0, m.object.updateMatrixWorld();
457
457
  }
458
458
  }
@@ -489,7 +489,7 @@ class _e {
489
489
  this.stop(), this.scene = null, this.armature = null, this.config = [], this.data = [], this.dict = {}, this.objectsUpdate = [], this.timerMs = 0;
490
490
  }
491
491
  }
492
- class Ke {
492
+ class tt {
493
493
  constructor(t) {
494
494
  this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
495
495
  }
@@ -519,8 +519,8 @@ class Ke {
519
519
  phonemeBoundaries: []
520
520
  }, i = 1024, s = 512, o = Math.floor((t.length - i) / s) + 1;
521
521
  for (let l = 0; l < o; l++) {
522
- const u = l * s, a = Math.min(u + i, t.length), h = t.slice(u, a), r = this.calculateEnergy(h);
523
- n.energy.push(r);
522
+ const u = l * s, r = Math.min(u + i, t.length), h = t.slice(u, r), a = this.calculateEnergy(h);
523
+ n.energy.push(a);
524
524
  const c = this.calculateSpectralCentroid(h);
525
525
  n.spectralCentroid.push(c);
526
526
  const d = this.calculateZeroCrossingRate(h);
@@ -604,12 +604,12 @@ class Ke {
604
604
  for (let i = 2; i <= e; i <<= 1) {
605
605
  const s = -2 * Math.PI / i, o = Math.cos(s), l = Math.sin(s);
606
606
  for (let u = 0; u < e; u += i) {
607
- let a = 1, h = 0;
608
- for (let r = 0; r < i / 2; r++) {
609
- const c = n[(u + r) * 2], d = n[(u + r) * 2 + 1], g = n[(u + r + i / 2) * 2] * a - n[(u + r + i / 2) * 2 + 1] * h, y = n[(u + r + i / 2) * 2] * h + n[(u + r + i / 2) * 2 + 1] * a;
610
- n[(u + r) * 2] = c + g, n[(u + r) * 2 + 1] = d + y, n[(u + r + i / 2) * 2] = c - g, n[(u + r + i / 2) * 2 + 1] = d - y;
611
- const x = a * o - h * l, I = a * l + h * o;
612
- a = x, h = I;
607
+ let r = 1, h = 0;
608
+ for (let a = 0; a < i / 2; a++) {
609
+ const c = n[(u + a) * 2], d = n[(u + a) * 2 + 1], g = n[(u + a + i / 2) * 2] * r - n[(u + a + i / 2) * 2 + 1] * h, y = n[(u + a + i / 2) * 2] * h + n[(u + a + i / 2) * 2 + 1] * r;
610
+ n[(u + a) * 2] = c + g, n[(u + a) * 2 + 1] = d + y, n[(u + a + i / 2) * 2] = c - g, n[(u + a + i / 2) * 2 + 1] = d - y;
611
+ const x = r * o - h * l, I = r * l + h * o;
612
+ r = x, h = I;
613
613
  }
614
614
  }
615
615
  }
@@ -637,8 +637,8 @@ class Ke {
637
637
  detectPhonemeBoundaries(t) {
638
638
  const e = [], { energy: n, spectralCentroid: i, zeroCrossingRate: s } = t;
639
639
  for (let o = 1; o < n.length; o++) {
640
- const l = o * 0.023, u = Math.abs(n[o] - n[o - 1]), a = Math.abs(i[o] - i[o - 1]), h = Math.abs(s[o] - s[o - 1]);
641
- u + a * 0.1 + h * 0.5 > 0.2 && e.push(l);
640
+ const l = o * 0.023, u = Math.abs(n[o] - n[o - 1]), r = Math.abs(i[o] - i[o - 1]), h = Math.abs(s[o] - s[o - 1]);
641
+ u + r * 0.1 + h * 0.5 > 0.2 && e.push(l);
642
642
  }
643
643
  return e;
644
644
  }
@@ -655,9 +655,9 @@ class Ke {
655
655
  const s = [];
656
656
  let o = 0;
657
657
  for (let u = 0; u < i.length; u++) {
658
- const a = i[u], h = this.estimateWordDuration(a, n / i.length);
658
+ const r = i[u], h = this.estimateWordDuration(r, n / i.length);
659
659
  s.push({
660
- word: a,
660
+ word: r,
661
661
  startTime: o,
662
662
  endTime: o + h,
663
663
  duration: h
@@ -702,10 +702,10 @@ class Ke {
702
702
  t.onsets;
703
703
  const o = this.textToVisemes(e);
704
704
  let l = 0, u = 0;
705
- for (let a = 0; a < s.length && l < o.length; a++) {
706
- const h = s[a], r = o[l], c = t.energy[Math.floor(h / 0.023)] || 0, d = this.calculateVisemeDuration(r, c);
705
+ for (let r = 0; r < s.length && l < o.length; r++) {
706
+ const h = s[r], a = o[l], c = t.energy[Math.floor(h / 0.023)] || 0, d = this.calculateVisemeDuration(a, c);
707
707
  i.push({
708
- viseme: r,
708
+ viseme: a,
709
709
  startTime: u,
710
710
  endTime: u + d,
711
711
  duration: d,
@@ -714,9 +714,9 @@ class Ke {
714
714
  }), u += d, l++;
715
715
  }
716
716
  for (; l < o.length; ) {
717
- const a = o[l], h = this.calculateVisemeDuration(a, 0.5);
717
+ const r = o[l], h = this.calculateVisemeDuration(r, 0.5);
718
718
  i.push({
719
- viseme: a,
719
+ viseme: r,
720
720
  startTime: u,
721
721
  endTime: u + h,
722
722
  duration: h,
@@ -776,9 +776,9 @@ class Ke {
776
776
  for (; o < s.length; ) {
777
777
  let l = !1;
778
778
  for (let u = 3; u >= 2; u--) {
779
- const a = s.substr(o, u);
780
- if (e[a]) {
781
- n.push(e[a]), o += u, l = !0;
779
+ const r = s.substr(o, u);
780
+ if (e[r]) {
781
+ n.push(e[r]), o += u, l = !0;
782
782
  break;
783
783
  }
784
784
  }
@@ -814,7 +814,7 @@ class Ke {
814
814
  return i * s;
815
815
  }
816
816
  }
817
- class Je {
817
+ class nt {
818
818
  /**
819
819
  * @constructor
820
820
  */
@@ -1206,13 +1206,13 @@ class Je {
1206
1206
  };
1207
1207
  Object.keys(this.rules).forEach((e) => {
1208
1208
  this.rules[e] = this.rules[e].map((n) => {
1209
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), a = n.substring(s + 1, o), h = n.substring(o + 1), r = { regex: "", move: 0, visemes: [] };
1209
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1210
1210
  let c = "";
1211
1211
  c += [...l].map((g) => t[g] || g).join("");
1212
1212
  const d = [...u];
1213
- return d[0] = d[0].toLowerCase(), c += d.join(""), r.move = d.length, c += [...a].map((g) => t[g] || g).join(""), r.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1214
- r.visemes.push(g);
1215
- }), r;
1213
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1214
+ a.visemes.push(g);
1215
+ }), a;
1216
1216
  });
1217
1217
  }), this.visemeDurations = {
1218
1218
  aa: 0.95,
@@ -1378,13 +1378,13 @@ class Je {
1378
1378
  for (let l = 0; l < o.length; l++) {
1379
1379
  const u = o[l];
1380
1380
  if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(u.regex)) {
1381
- u.visemes.forEach((r) => {
1382
- if (e.visemes.length && e.visemes[e.visemes.length - 1] === r) {
1383
- const c = 0.7 * (this.visemeDurations[r] || 1);
1381
+ u.visemes.forEach((a) => {
1382
+ if (e.visemes.length && e.visemes[e.visemes.length - 1] === a) {
1383
+ const c = 0.7 * (this.visemeDurations[a] || 1);
1384
1384
  e.durations[e.durations.length - 1] += c, n += c;
1385
1385
  } else {
1386
- const c = this.visemeDurations[r] || 1;
1387
- e.visemes.push(r), e.times.push(n), e.durations.push(c), n += c;
1386
+ const c = this.visemeDurations[a] || 1;
1387
+ e.visemes.push(a), e.times.push(n), e.durations.push(c), n += c;
1388
1388
  }
1389
1389
  }), e.i += u.move;
1390
1390
  break;
@@ -1396,11 +1396,11 @@ class Je {
1396
1396
  return e;
1397
1397
  }
1398
1398
  }
1399
- const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1399
+ const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1400
1400
  __proto__: null,
1401
- LipsyncEn: Je
1401
+ LipsyncEn: nt
1402
1402
  }, Symbol.toStringTag, { value: "Module" }));
1403
- class et {
1403
+ class ot {
1404
1404
  /**
1405
1405
  * @constructor
1406
1406
  */
@@ -1616,13 +1616,13 @@ class et {
1616
1616
  };
1617
1617
  Object.keys(this.rules).forEach((e) => {
1618
1618
  this.rules[e] = this.rules[e].map((n) => {
1619
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), a = n.substring(s + 1, o), h = n.substring(o + 1), r = { regex: "", move: 0, visemes: [] };
1619
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
1620
1620
  let c = "";
1621
1621
  c += [...l].map((g) => t[g] || g).join("");
1622
1622
  const d = [...u];
1623
- return d[0] = d[0].toLowerCase(), c += d.join(""), r.move = d.length, c += [...a].map((g) => t[g] || g).join(""), r.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1624
- r.visemes.push(g);
1625
- }), r;
1623
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c), h.length && h.split(" ").forEach((g) => {
1624
+ a.visemes.push(g);
1625
+ }), a;
1626
1626
  });
1627
1627
  }), this.visemeDurations = {
1628
1628
  aa: 1,
@@ -1733,9 +1733,9 @@ class et {
1733
1733
  if (o) {
1734
1734
  let l = !1;
1735
1735
  for (let u = 0; u < o.length; u++) {
1736
- const a = o[u];
1737
- if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(a.regex)) {
1738
- a.visemes.forEach((c) => {
1736
+ const r = o[u];
1737
+ if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(r.regex)) {
1738
+ r.visemes.forEach((c) => {
1739
1739
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
1740
1740
  const d = 0.7 * (this.visemeDurations[c] || 1);
1741
1741
  e.durations[e.durations.length - 1] += d, n += d;
@@ -1743,7 +1743,7 @@ class et {
1743
1743
  const d = this.visemeDurations[c] || 1;
1744
1744
  e.visemes.push(c), e.times.push(n), e.durations.push(d), n += d;
1745
1745
  }
1746
- }), e.i += a.move, l = !0;
1746
+ }), e.i += r.move, l = !0;
1747
1747
  break;
1748
1748
  }
1749
1749
  }
@@ -1754,11 +1754,11 @@ class et {
1754
1754
  return e;
1755
1755
  }
1756
1756
  }
1757
- const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1757
+ const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1758
1758
  __proto__: null,
1759
- LipsyncDe: et
1759
+ LipsyncDe: ot
1760
1760
  }, Symbol.toStringTag, { value: "Module" }));
1761
- class nt {
1761
+ class at {
1762
1762
  /**
1763
1763
  * @constructor
1764
1764
  */
@@ -2131,13 +2131,13 @@ class nt {
2131
2131
  };
2132
2132
  Object.keys(this.rules).forEach((e) => {
2133
2133
  this.rules[e] = this.rules[e].map((n) => {
2134
- const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), a = n.substring(s + 1, o), h = n.substring(o + 1), r = { regex: "", move: 0, visemes: [] };
2134
+ const i = n.indexOf("["), s = n.indexOf("]"), o = n.indexOf("="), l = n.substring(0, i), u = n.substring(i + 1, s), r = n.substring(s + 1, o), h = n.substring(o + 1), a = { regex: "", move: 0, visemes: [] };
2135
2135
  let c = "";
2136
2136
  c += [...l].map((g) => t[g] || g).join("");
2137
2137
  const d = [...u];
2138
- return d[0] = d[0].toLowerCase(), c += d.join(""), r.move = d.length, c += [...a].map((g) => t[g] || g).join(""), r.regex = new RegExp(c, "i"), h.length && h.split(" ").forEach((g) => {
2139
- g && r.visemes.push(g);
2140
- }), r;
2138
+ return d[0] = d[0].toLowerCase(), c += d.join(""), a.move = d.length, c += [...r].map((g) => t[g] || g).join(""), a.regex = new RegExp(c, "i"), h.length && h.split(" ").forEach((g) => {
2139
+ g && a.visemes.push(g);
2140
+ }), a;
2141
2141
  });
2142
2142
  }), this.visemeDurations = {
2143
2143
  aa: 1,
@@ -2268,9 +2268,9 @@ class nt {
2268
2268
  if (o) {
2269
2269
  let l = !1;
2270
2270
  for (let u = 0; u < o.length; u++) {
2271
- const a = o[u];
2272
- if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(a.regex)) {
2273
- a.visemes.forEach((c) => {
2271
+ const r = o[u];
2272
+ if ((e.words.substring(0, e.i) + s.toLowerCase() + e.words.substring(e.i + 1)).match(r.regex)) {
2273
+ r.visemes.forEach((c) => {
2274
2274
  if (e.visemes.length && e.visemes[e.visemes.length - 1] === c) {
2275
2275
  const d = 0.7 * (this.visemeDurations[c] || 1);
2276
2276
  e.durations[e.durations.length - 1] += d, n += d;
@@ -2278,7 +2278,7 @@ class nt {
2278
2278
  const d = this.visemeDurations[c] || 1;
2279
2279
  e.visemes.push(c), e.times.push(n), e.durations.push(d), n += d;
2280
2280
  }
2281
- }), e.i += a.move, l = !0;
2281
+ }), e.i += r.move, l = !0;
2282
2282
  break;
2283
2283
  }
2284
2284
  }
@@ -2289,11 +2289,11 @@ class nt {
2289
2289
  return e;
2290
2290
  }
2291
2291
  }
2292
- const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2293
2293
  __proto__: null,
2294
- LipsyncFr: nt
2294
+ LipsyncFr: at
2295
2295
  }, Symbol.toStringTag, { value: "Module" }));
2296
- class ot {
2296
+ class lt {
2297
2297
  /**
2298
2298
  * @constructor
2299
2299
  */
@@ -2381,10 +2381,10 @@ class ot {
2381
2381
  const e = [];
2382
2382
  let n = parseFloat(t);
2383
2383
  if (n === void 0) return t;
2384
- let i = (s, o, l, u, a) => {
2384
+ let i = (s, o, l, u, r) => {
2385
2385
  if (s < o) return s;
2386
2386
  const h = Math.floor(s / o);
2387
- return e.push(l + (h === 1 ? u : this.numberToFinnishWords(h.toString()) + a)), s - h * o;
2387
+ return e.push(l + (h === 1 ? u : this.numberToFinnishWords(h.toString()) + r)), s - h * o;
2388
2388
  };
2389
2389
  if (n < 0 && (e.push("miinus "), n = Math.abs(n)), n = i(n, 1e9, " ", "miljardi", " miljardia"), n = i(n, 1e6, " ", "miljoona", " miljoonaa"), n = i(n, 1e3, "", "tuhat", "tuhatta"), n = i(n, 100, " ", "sata", "sataa"), n > 20 && (n = i(n, 10, "", "", "kymmentä")), n >= 1) {
2390
2390
  let s = Math.floor(n);
@@ -2436,11 +2436,11 @@ class ot {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
- LipsyncFi: ot
2441
+ LipsyncFi: lt
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class at {
2443
+ class ut {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2559,10 +2559,10 @@ class at {
2559
2559
  const e = [];
2560
2560
  let n = parseFloat(t);
2561
2561
  if (n === void 0) return t;
2562
- let i = (s, o, l, u, a) => {
2562
+ let i = (s, o, l, u, r) => {
2563
2563
  if (s < o) return s;
2564
2564
  const h = Math.floor(s / o);
2565
- return h === 1 ? e.push(this.numbers[1]) : e.push(this.numberToLithuanianWords(h.toString())), h % 10 === 1 ? e.push(l) : h % 10 === 0 || h % 100 > 10 && h % 100 < 20 ? e.push(a) : e.push(u), s - h * o;
2565
+ return h === 1 ? e.push(this.numbers[1]) : e.push(this.numberToLithuanianWords(h.toString())), h % 10 === 1 ? e.push(l) : h % 10 === 0 || h % 100 > 10 && h % 100 < 20 ? e.push(r) : e.push(u), s - h * o;
2566
2566
  };
2567
2567
  n < 0 && (e.push("minus"), n = Math.abs(n)), n = i(n, 1e9, "milijardas", "milijardai", "milijardų"), n = i(n, 1e6, "milijonas", "milijonai", "milijonų"), n = i(n, 1e3, "tūkstantis", "tūkstančiai", "tūkstančių"), n = i(n, 100, "šimtas", "šimtai", "šimtų");
2568
2568
  for (let s = this.tens.length - 1; s >= 1; s--)
@@ -2620,24 +2620,24 @@ class at {
2620
2620
  return e;
2621
2621
  }
2622
2622
  }
2623
- const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
+ const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: at
2626
- }, Symbol.toStringTag, { value: "Module" })), lt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN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AgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VG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yYW1lcykgewogICAgICAgIHRoaXMuX2xhc3RNZXRyaWNzU2VudEF0RnJhbWUgPSB0aGlzLl9mcmFtZXNQcm9jZXNzZWQ7CiAgICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), He = {
2627
- en: $e,
2628
- de: tt,
2629
- fr: it,
2630
- fi: st,
2631
- lt: rt
2632
- }, V = new f.Quaternion(), F = new f.Euler(), ue = new f.Vector3(), ce = new f.Vector3(), Te = new f.Box3();
2625
+ LipsyncLt: ut
2626
+ }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhpcy5fbWV0cmljc0VuYWJsZWQgPSBtZXRyaWNzQ2ZnLmVuYWJsZWQgIT09IGZhbHNlOw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lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KIC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Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Fe = {
2627
+ en: it,
2628
+ de: st,
2629
+ fr: rt,
2630
+ fi: ht,
2631
+ lt: ct
2632
+ }, G = new f.Quaternion(), E = new f.Euler(), ce = new f.Vector3(), pe = new f.Vector3(), Pe = new f.Box3();
2633
2633
  new f.Matrix4();
2634
2634
  new f.Matrix4();
2635
2635
  new f.Vector3();
2636
2636
  new f.Vector3(0, 0, 1);
2637
- const ht = new f.Vector3(1, 0, 0);
2637
+ const mt = new f.Vector3(1, 0, 0);
2638
2638
  new f.Vector3(0, 1, 0);
2639
2639
  new f.Vector3(0, 0, 1);
2640
- class Fe {
2640
+ class Oe {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -2763,7 +2763,7 @@ class Fe {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Ye(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
2766
+ }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new _e(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
2767
2767
  side: {
2768
2768
  standing: !0,
2769
2769
  props: {
@@ -4062,7 +4062,7 @@ class Fe {
4062
4062
  this.opt.lightSpotDispersion
4063
4063
  ), this.setLighting(this.opt);
4064
4064
  const l = new f.PMREMGenerator(this.renderer);
4065
- l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Xe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ve(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4065
+ l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new qe()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ye(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4066
4066
  }
4067
4067
  this.ikMesh = new f.SkinnedMesh();
4068
4068
  const s = {
@@ -4078,16 +4078,16 @@ class Fe {
4078
4078
  RightHandMiddle1: "RightHand"
4079
4079
  }, o = [];
4080
4080
  Object.entries(s).forEach((l, u) => {
4081
- const a = new f.Bone();
4082
- a.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(a) : this.ikMesh.add(a), o.push(a);
4083
- }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new _e(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4081
+ const r = new f.Bone();
4082
+ r.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(r) : this.ikMesh.add(r), o.push(r);
4083
+ }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new et(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4084
4084
  }
4085
4085
  /**
4086
4086
  * Helper that re/creates the audio context and the other nodes.
4087
4087
  * @param {number} sampleRate
4088
4088
  */
4089
4089
  initAudioGraph(t = null) {
4090
- if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new Ke(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4090
+ if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new tt(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4091
4091
  this.opt.mixerGainSpeech,
4092
4092
  this.opt.mixerGainBackground
4093
4093
  ), this.workletLoaded = !1, this.streamWorkletNode) {
@@ -4126,9 +4126,9 @@ class Fe {
4126
4126
  let e = 3 * t.length / 4;
4127
4127
  t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
4128
4128
  const n = new ArrayBuffer(e), i = new Uint8Array(n);
4129
- let s, o = 0, l, u, a, h;
4129
+ let s, o = 0, l, u, r, h;
4130
4130
  for (s = 0; s < t.length; s += 4)
4131
- l = this.b64Lookup[t.charCodeAt(s)], u = this.b64Lookup[t.charCodeAt(s + 1)], a = this.b64Lookup[t.charCodeAt(s + 2)], h = this.b64Lookup[t.charCodeAt(s + 3)], i[o++] = l << 2 | u >> 4, i[o++] = (u & 15) << 4 | a >> 2, i[o++] = (a & 3) << 6 | h & 63;
4131
+ l = this.b64Lookup[t.charCodeAt(s)], u = this.b64Lookup[t.charCodeAt(s + 1)], r = this.b64Lookup[t.charCodeAt(s + 2)], h = this.b64Lookup[t.charCodeAt(s + 3)], i[o++] = l << 2 | u >> 4, i[o++] = (u & 15) << 4 | r >> 2, i[o++] = (r & 3) << 6 | h & 63;
4132
4132
  return n;
4133
4133
  }
4134
4134
  /**
@@ -4199,9 +4199,9 @@ class Fe {
4199
4199
  if (!i && s.morphTargetDictionary.hasOwnProperty(e)) return;
4200
4200
  const o = s.geometry;
4201
4201
  let l = null, u = null;
4202
- for (const [a, h] of Object.entries(n))
4203
- if (s.morphTargetDictionary.hasOwnProperty(a)) {
4204
- const r = s.morphTargetDictionary[a], c = o.morphAttributes.position[r], d = o.morphAttributes.normal?.[r];
4202
+ for (const [r, h] of Object.entries(n))
4203
+ if (s.morphTargetDictionary.hasOwnProperty(r)) {
4204
+ const a = s.morphTargetDictionary[r], c = o.morphAttributes.position[a], d = o.morphAttributes.normal?.[a];
4205
4205
  l || (l = new f.Float32BufferAttribute(c.count * 3, 3), d && (u = new f.Float32BufferAttribute(c.count * 3, 3)));
4206
4206
  for (let g = 0; g < c.count; g++) {
4207
4207
  const y = l.getX(g) + c.getX(g) * h, x = l.getY(g) + c.getY(g) * h, I = l.getZ(g) + c.getZ(g) * h;
@@ -4215,8 +4215,8 @@ class Fe {
4215
4215
  }
4216
4216
  if (l) {
4217
4217
  o.morphAttributes.position.push(l), u && o.morphAttributes.normal.push(u);
4218
- const a = o.morphAttributes.position.length - 1;
4219
- s.morphTargetInfluences[a] = 0, s.morphTargetDictionary[e] = a;
4218
+ const r = o.morphAttributes.position.length - 1;
4219
+ s.morphTargetInfluences[r] = 0, s.morphTargetDictionary[e] = r;
4220
4220
  }
4221
4221
  });
4222
4222
  }
@@ -4228,66 +4228,66 @@ class Fe {
4228
4228
  async showAvatar(t, e = null) {
4229
4229
  if (!t || !t.hasOwnProperty("url"))
4230
4230
  throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
4231
- const n = new Ge();
4231
+ const n = new je();
4232
4232
  if (this.dracoEnabled) {
4233
- const a = new Ze();
4234
- a.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(a);
4233
+ const r = new Qe();
4234
+ r.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(r);
4235
4235
  }
4236
4236
  let i = await n.loadAsync(t.url, e);
4237
4237
  const s = [this.opt.modelRoot];
4238
- if (this.posePropNames.forEach((a) => s.push(a.split(".")[0])), s.forEach((a) => {
4239
- if (!i.scene.getObjectByName(a))
4240
- throw new Error("Avatar object " + a + " not found");
4241
- }), this.stop(), this.avatar = t, this.bodyMovement = t.bodyMovement || "idle", this.movementIntensity = t.movementIntensity || 0.5, this.showFullAvatar = t.showFullAvatar || !1, this.fbxAnimationLoader = null, this.dynamicbones.dispose(), this.mixer = null, this.isAvatarOnly ? this.armature && this.clearThree(this.armature) : this.armature && this.clearThree(this.scene), this.armature = i.scene.getObjectByName(this.opt.modelRoot), this.armature.scale.setScalar(1), this.animations = i.animations, this.userData = i.userData, this.morphs = [], this.armature.traverse((a) => {
4242
- a.morphTargetInfluences && a.morphTargetInfluences.length && a.morphTargetDictionary && this.morphs.push(a), a.frustumCulled = !1;
4238
+ if (this.posePropNames.forEach((r) => s.push(r.split(".")[0])), s.forEach((r) => {
4239
+ if (!i.scene.getObjectByName(r))
4240
+ throw new Error("Avatar object " + r + " not found");
4241
+ }), this.stop(), this.avatar = t, this.bodyMovement = t.bodyMovement || "idle", this.movementIntensity = t.movementIntensity || 0.5, this.showFullAvatar = t.showFullAvatar || !1, this.fbxAnimationLoader = null, this.dynamicbones.dispose(), this.mixer = null, this.isAvatarOnly ? this.armature && this.clearThree(this.armature) : this.armature && this.clearThree(this.scene), this.armature = i.scene.getObjectByName(this.opt.modelRoot), this.armature.scale.setScalar(1), this.animations = i.animations, this.userData = i.userData, this.morphs = [], this.armature.traverse((r) => {
4242
+ r.morphTargetInfluences && r.morphTargetInfluences.length && r.morphTargetDictionary && this.morphs.push(r), r.frustumCulled = !1;
4243
4243
  }), this.morphs.length === 0)
4244
4244
  throw new Error("Blend shapes not found");
4245
4245
  const o = new Set(this.mtCustoms);
4246
- this.morphs.forEach((a) => {
4247
- Object.keys(a.morphTargetDictionary).forEach((h) => o.add(h));
4248
- }), this.mtExtras.forEach((a) => {
4249
- o.has(a.key) || (this.addMixedMorphTarget(this.morphs, a.key, a.mix), o.add(a.key));
4246
+ this.morphs.forEach((r) => {
4247
+ Object.keys(r.morphTargetDictionary).forEach((h) => o.add(h));
4248
+ }), this.mtExtras.forEach((r) => {
4249
+ o.has(r.key) || (this.addMixedMorphTarget(this.morphs, r.key, r.mix), o.add(r.key));
4250
4250
  });
4251
4251
  const l = {};
4252
- if (o.forEach((a) => {
4253
- l[a] = {
4252
+ if (o.forEach((r) => {
4253
+ l[r] = {
4254
4254
  fixed: null,
4255
4255
  realtime: null,
4256
4256
  system: null,
4257
4257
  systemd: null,
4258
4258
  newvalue: null,
4259
4259
  ref: null,
4260
- min: this.mtMinExceptions.hasOwnProperty(a) ? this.mtMinExceptions[a] : this.mtMinDefault,
4261
- max: this.mtMaxExceptions.hasOwnProperty(a) ? this.mtMaxExceptions[a] : this.mtMaxDefault,
4260
+ min: this.mtMinExceptions.hasOwnProperty(r) ? this.mtMinExceptions[r] : this.mtMinDefault,
4261
+ max: this.mtMaxExceptions.hasOwnProperty(r) ? this.mtMaxExceptions[r] : this.mtMaxDefault,
4262
4262
  easing: this.mtEasingDefault,
4263
4263
  base: null,
4264
4264
  v: 0,
4265
4265
  needsUpdate: !0,
4266
- acc: (this.mtAccExceptions.hasOwnProperty(a) ? this.mtAccExceptions[a] : this.mtAccDefault) / 1e3,
4267
- maxv: (this.mtMaxVExceptions.hasOwnProperty(a) ? this.mtMaxVExceptions[a] : this.mtMaxVDefault) / 1e3,
4268
- limit: this.mtLimits.hasOwnProperty(a) ? this.mtLimits[a] : null,
4269
- onchange: this.mtOnchange.hasOwnProperty(a) ? this.mtOnchange[a] : null,
4270
- baseline: this.avatar.baseline?.hasOwnProperty(a) ? this.avatar.baseline[a] : this.mtBaselineExceptions.hasOwnProperty(a) ? this.mtBaselineExceptions[a] : this.mtBaselineDefault,
4266
+ acc: (this.mtAccExceptions.hasOwnProperty(r) ? this.mtAccExceptions[r] : this.mtAccDefault) / 1e3,
4267
+ maxv: (this.mtMaxVExceptions.hasOwnProperty(r) ? this.mtMaxVExceptions[r] : this.mtMaxVDefault) / 1e3,
4268
+ limit: this.mtLimits.hasOwnProperty(r) ? this.mtLimits[r] : null,
4269
+ onchange: this.mtOnchange.hasOwnProperty(r) ? this.mtOnchange[r] : null,
4270
+ baseline: this.avatar.baseline?.hasOwnProperty(r) ? this.avatar.baseline[r] : this.mtBaselineExceptions.hasOwnProperty(r) ? this.mtBaselineExceptions[r] : this.mtBaselineDefault,
4271
4271
  ms: [],
4272
4272
  is: []
4273
- }, l[a].value = l[a].baseline, l[a].applied = l[a].baseline;
4274
- const h = this.mtAvatar[a];
4275
- h && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((r) => {
4276
- l[a][r] = h[r];
4277
- }), this.morphs.forEach((r) => {
4278
- const c = r.morphTargetDictionary[a];
4279
- c !== void 0 && (l[a].ms.push(r.morphTargetInfluences), l[a].is.push(c), r.morphTargetInfluences[c] = l[a].applied);
4273
+ }, l[r].value = l[r].baseline, l[r].applied = l[r].baseline;
4274
+ const h = this.mtAvatar[r];
4275
+ h && ["fixed", "system", "systemd", "realtime", "base", "v", "value", "applied"].forEach((a) => {
4276
+ l[r][a] = h[a];
4277
+ }), this.morphs.forEach((a) => {
4278
+ const c = a.morphTargetDictionary[r];
4279
+ c !== void 0 && (l[r].ms.push(a.morphTargetInfluences), l[r].is.push(c), a.morphTargetInfluences[c] = l[r].applied);
4280
4280
  });
4281
- }), this.mtAvatar = l, this.poseAvatar = { props: {} }, this.posePropNames.forEach((a) => {
4282
- const h = a.split("."), r = this.armature.getObjectByName(h[0]);
4283
- this.poseAvatar.props[a] = r[h[1]], this.poseBase.props.hasOwnProperty(a) ? this.poseAvatar.props[a].copy(this.poseBase.props[a]) : this.poseBase.props[a] = this.poseAvatar.props[a].clone(), this.poseDelta.props.hasOwnProperty(a) && !this.poseTarget.props.hasOwnProperty(a) && (this.poseTarget.props[a] = this.poseAvatar.props[a].clone()), this.poseTarget.props[a].t = this.animClock, this.poseTarget.props[a].d = 2e3;
4284
- }), this.ikMesh.traverse((a) => {
4285
- a.isBone && a.position.copy(this.armature.getObjectByName(a.name).position);
4281
+ }), this.mtAvatar = l, this.poseAvatar = { props: {} }, this.posePropNames.forEach((r) => {
4282
+ const h = r.split("."), a = this.armature.getObjectByName(h[0]);
4283
+ this.poseAvatar.props[r] = a[h[1]], this.poseBase.props.hasOwnProperty(r) ? this.poseAvatar.props[r].copy(this.poseBase.props[r]) : this.poseBase.props[r] = this.poseAvatar.props[r].clone(), this.poseDelta.props.hasOwnProperty(r) && !this.poseTarget.props.hasOwnProperty(r) && (this.poseTarget.props[r] = this.poseAvatar.props[r].clone()), this.poseTarget.props[r].t = this.animClock, this.poseTarget.props[r].d = 2e3;
4284
+ }), this.ikMesh.traverse((r) => {
4285
+ r.isBone && r.position.copy(this.armature.getObjectByName(r.name).position);
4286
4286
  }), this.isAvatarOnly ? this.scene && this.scene.add(this.armature) : (this.scene.add(i.scene), this.scene.add(this.lightAmbient), this.scene.add(this.lightDirect), this.scene.add(this.lightSpot), this.lightSpot.target = this.armature.getObjectByName("Head")), t.hasOwnProperty("modelDynamicBones"))
4287
4287
  try {
4288
4288
  this.dynamicbones.setup(this.scene, this.armature, t.modelDynamicBones);
4289
- } catch (a) {
4290
- console.error("Dynamic bones setup failed: " + a);
4289
+ } catch (r) {
4290
+ console.error("Dynamic bones setup failed: " + r);
4291
4291
  }
4292
4292
  this.objectLeftToeBase = this.armature.getObjectByName("LeftToeBase"), this.objectRightToeBase = this.armature.getObjectByName("RightToeBase"), this.objectLeftEye = this.armature.getObjectByName("LeftEye"), this.objectRightEye = this.armature.getObjectByName("RightEye"), this.objectLeftArm = this.armature.getObjectByName("LeftArm"), this.objectRightArm = this.armature.getObjectByName("RightArm"), this.objectHips = this.armature.getObjectByName("Hips"), this.objectHead = this.armature.getObjectByName("Head"), this.objectNeck = this.armature.getObjectByName("Neck");
4293
4293
  const u = new f.Vector3();
@@ -4320,21 +4320,21 @@ class Fe {
4320
4320
  }
4321
4321
  if (this.viewName = t || this.viewName, e = e || {}, this.isAvatarOnly) return;
4322
4322
  const n = e.hasOwnProperty("cameraX") ? e.cameraX : this.opt.cameraX, i = e.hasOwnProperty("cameraY") ? e.cameraY : this.opt.cameraY, s = e.hasOwnProperty("cameraDistance") ? e.cameraDistance : this.opt.cameraDistance, o = e.hasOwnProperty("cameraRotateX") ? e.cameraRotateX : this.opt.cameraRotateX, l = e.hasOwnProperty("cameraRotateY") ? e.cameraRotateY : this.opt.cameraRotateY, u = this.camera.fov * (Math.PI / 180);
4323
- let a = -n * Math.tan(u / 2), h = (1 - i) * Math.tan(u / 2), r = s;
4323
+ let r = -n * Math.tan(u / 2), h = (1 - i) * Math.tan(u / 2), a = s;
4324
4324
  switch (this.viewName) {
4325
4325
  case "head":
4326
- r += 2, h = h * r + 4 * this.avatarHeight / 5;
4326
+ a += 2, h = h * a + 4 * this.avatarHeight / 5;
4327
4327
  break;
4328
4328
  case "upper":
4329
- r += 4.5, h = h * r + 2 * this.avatarHeight / 3;
4329
+ a += 4.5, h = h * a + 2 * this.avatarHeight / 3;
4330
4330
  break;
4331
4331
  case "mid":
4332
- r += 8, h = h * r + this.avatarHeight / 3;
4332
+ a += 8, h = h * a + this.avatarHeight / 3;
4333
4333
  break;
4334
4334
  default:
4335
- r += 12, h = h * r;
4335
+ a += 12, h = h * a;
4336
4336
  }
4337
- a = a * r, this.controlsEnd = new f.Vector3(a, h, 0), this.cameraEnd = new f.Vector3(a, h, r).applyEuler(new f.Euler(o, l, 0)), this.cameraClock === null && (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)), this.controlsStart = this.controls.target.clone(), this.cameraStart = this.camera.position.clone(), this.cameraClock = 0;
4337
+ r = r * a, this.controlsEnd = new f.Vector3(r, h, 0), this.cameraEnd = new f.Vector3(r, h, a).applyEuler(new f.Euler(o, l, 0)), this.cameraClock === null && (this.controls.target.copy(this.controlsEnd), this.camera.position.copy(this.cameraEnd)), this.controlsStart = this.controls.target.clone(), this.cameraStart = this.camera.position.clone(), this.cameraClock = 0;
4338
4338
  }
4339
4339
  /**
4340
4340
  * Change light colors and intensities.
@@ -4374,9 +4374,9 @@ class Fe {
4374
4374
  updatePoseDelta() {
4375
4375
  for (const [t, e] of Object.entries(this.poseDelta.props)) {
4376
4376
  if (e.x === 0 && e.y === 0 && e.z === 0) continue;
4377
- F.set(e.x, e.y, e.z);
4377
+ E.set(e.x, e.y, e.z);
4378
4378
  const n = this.poseAvatar.props[t];
4379
- n.isQuaternion ? (V.setFromEuler(F), n.multiply(V)) : n.isVector3 && n.add(F);
4379
+ n.isQuaternion ? (G.setFromEuler(E), n.multiply(G)) : n.isVector3 && n.add(E);
4380
4380
  }
4381
4381
  }
4382
4382
  /**
@@ -4431,16 +4431,16 @@ class Fe {
4431
4431
  "HandMiddle",
4432
4432
  "HandRing",
4433
4433
  "HandPinky"
4434
- ].forEach((h, r) => {
4435
- r === 0 ? (this.poseDelta.props[o + h + "1.quaternion"].x = 0, this.poseDelta.props[o + h + "2.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied, this.poseDelta.props[o + h + "3.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied) : (this.poseDelta.props[o + h + "1.quaternion"].x = n.applied, this.poseDelta.props[o + h + "2.quaternion"].x = 1.5 * n.applied, this.poseDelta.props[o + h + "3.quaternion"].x = 1.5 * n.applied);
4434
+ ].forEach((h, a) => {
4435
+ a === 0 ? (this.poseDelta.props[o + h + "1.quaternion"].x = 0, this.poseDelta.props[o + h + "2.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied, this.poseDelta.props[o + h + "3.quaternion"].z = (o === "Left" ? -1 : 1) * n.applied) : (this.poseDelta.props[o + h + "1.quaternion"].x = n.applied, this.poseDelta.props[o + h + "2.quaternion"].x = 1.5 * n.applied, this.poseDelta.props[o + h + "3.quaternion"].x = 1.5 * n.applied);
4436
4436
  });
4437
4437
  break;
4438
4438
  case "chestInhale":
4439
- const l = n.applied / 20, u = { x: l, y: l / 2, z: 3 * l }, a = { x: 1 / (1 + l) - 1, y: 1 / (1 + l / 2) - 1, z: 1 / (1 + 3 * l) - 1 };
4440
- this.poseDelta.props["Spine1.scale"] = u, this.poseDelta.props["Neck.scale"] = a, this.poseDelta.props["LeftArm.scale"] = a, this.poseDelta.props["RightArm.scale"] = a;
4439
+ const l = n.applied / 20, u = { x: l, y: l / 2, z: 3 * l }, r = { x: 1 / (1 + l) - 1, y: 1 / (1 + l / 2) - 1, z: 1 / (1 + 3 * l) - 1 };
4440
+ this.poseDelta.props["Spine1.scale"] = u, this.poseDelta.props["Neck.scale"] = r, this.poseDelta.props["LeftArm.scale"] = r, this.poseDelta.props["RightArm.scale"] = r;
4441
4441
  break;
4442
4442
  default:
4443
- for (let h = 0, r = n.ms.length; h < r; h++)
4443
+ for (let h = 0, a = n.ms.length; h < a; h++)
4444
4444
  n.ms[h][n.is[h]] = n.applied;
4445
4445
  }
4446
4446
  }
@@ -4971,38 +4971,38 @@ class Fe {
4971
4971
  else if (this.avatar.body && l.hasOwnProperty(this.avatar.body))
4972
4972
  l = l[this.avatar.body];
4973
4973
  else if (l.hasOwnProperty("alt")) {
4974
- let a = l.alt[0];
4974
+ let r = l.alt[0];
4975
4975
  if (l.alt.length > 1) {
4976
4976
  const h = Math.random();
4977
- let r = 0;
4977
+ let a = 0;
4978
4978
  for (let c = 0; c < l.alt.length; c++) {
4979
4979
  let d = this.valueFn(l.alt[c].p);
4980
- if (r += d === void 0 ? (1 - r) / (l.alt.length - 1 - c) : d, h < r) {
4981
- a = l.alt[c];
4980
+ if (a += d === void 0 ? (1 - a) / (l.alt.length - 1 - c) : d, h < a) {
4981
+ r = l.alt[c];
4982
4982
  break;
4983
4983
  }
4984
4984
  }
4985
4985
  }
4986
- l = a;
4986
+ l = r;
4987
4987
  } else
4988
4988
  break;
4989
4989
  let u = this.valueFn(l.delay) || 0;
4990
4990
  if (Array.isArray(u) && (u = this.gaussianRandom(...u)), l.hasOwnProperty("dt"))
4991
- l.dt.forEach((a, h) => {
4992
- let r = this.valueFn(a);
4993
- Array.isArray(r) && (r = this.gaussianRandom(...r)), o.ts[h + 1] = o.ts[h] + r;
4991
+ l.dt.forEach((r, h) => {
4992
+ let a = this.valueFn(r);
4993
+ Array.isArray(a) && (a = this.gaussianRandom(...a)), o.ts[h + 1] = o.ts[h] + a;
4994
4994
  });
4995
4995
  else {
4996
- let a = Object.values(l.vs).reduce((h, r) => r.length > h ? r.length : h, 0);
4997
- o.ts = Array(a + 1).fill(0);
4996
+ let r = Object.values(l.vs).reduce((h, a) => a.length > h ? a.length : h, 0);
4997
+ o.ts = Array(r + 1).fill(0);
4998
4998
  }
4999
- s ? o.ts = o.ts.map((a) => u + a * n) : o.ts = o.ts.map((a) => this.animClock + u + a * n);
5000
- for (let [a, h] of Object.entries(l.vs)) {
5001
- const r = this.getBaselineValue(a), c = h.map((d) => (d = this.valueFn(d), d === null ? null : typeof d == "function" ? d : typeof d == "string" || d instanceof String ? d.slice() : Array.isArray(d) ? a === "gesture" ? d.slice() : (r === void 0 ? 0 : r) + i * this.gaussianRandom(...d) : typeof d == "boolean" ? d : d instanceof Object && d.constructor === Object ? Object.assign({}, d) : (r === void 0 ? 0 : r) + i * d));
5002
- a === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyeLookInLeft = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookOutRight = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookInRight = [null, ...c.map((d) => d > 0 ? d : 0)]) : a === "eyesRotateX" ? (o.vs.eyesLookDown = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyesLookUp = [null, ...c.map((d) => d > 0 ? 0 : -d)]) : o.vs[a] = [null, ...c];
4999
+ s ? o.ts = o.ts.map((r) => u + r * n) : o.ts = o.ts.map((r) => this.animClock + u + r * n);
5000
+ for (let [r, h] of Object.entries(l.vs)) {
5001
+ const a = this.getBaselineValue(r), c = h.map((d) => (d = this.valueFn(d), d === null ? null : typeof d == "function" ? d : typeof d == "string" || d instanceof String ? d.slice() : Array.isArray(d) ? r === "gesture" ? d.slice() : (a === void 0 ? 0 : a) + i * this.gaussianRandom(...d) : typeof d == "boolean" ? d : d instanceof Object && d.constructor === Object ? Object.assign({}, d) : (a === void 0 ? 0 : a) + i * d));
5002
+ r === "eyesRotateY" ? (o.vs.eyeLookOutLeft = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyeLookInLeft = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookOutRight = [null, ...c.map((d) => d > 0 ? 0 : -d)], o.vs.eyeLookInRight = [null, ...c.map((d) => d > 0 ? d : 0)]) : r === "eyesRotateX" ? (o.vs.eyesLookDown = [null, ...c.map((d) => d > 0 ? d : 0)], o.vs.eyesLookUp = [null, ...c.map((d) => d > 0 ? 0 : -d)]) : o.vs[r] = [null, ...c];
5003
5003
  }
5004
- for (let a of Object.keys(o.vs))
5005
- for (; o.vs[a].length <= o.ts.length; ) o.vs[a].push(o.vs[a][o.vs[a].length - 1]);
5004
+ for (let r of Object.keys(o.vs))
5005
+ for (; o.vs[r].length <= o.ts.length; ) o.vs[r].push(o.vs[r][o.vs[r].length - 1]);
5006
5006
  return t.hasOwnProperty("mood") && (o.mood = this.valueFn(t.mood).slice()), e && (o.loop = e), o;
5007
5007
  }
5008
5008
  /**
@@ -5080,13 +5080,13 @@ class Fe {
5080
5080
  if (this.isSpeaking)
5081
5081
  for (l = 0, this.audioAnalyzerNode.getByteFrequencyData(this.volumeFrequencyData), n = 2, s = 10; n < s; n++)
5082
5082
  this.volumeFrequencyData[n] > l && (l = this.volumeFrequencyData[n]);
5083
- let u = null, a = null;
5083
+ let u = null, r = null;
5084
5084
  const h = [];
5085
5085
  for (n = 0, s = this.animQueue.length; n < s; n++) {
5086
- const r = this.animQueue[n];
5087
- if (!(!r || !r.ts || !r.ts.length || this.animClock < r.ts[0])) {
5088
- for (i = r.ndx || 0, o = r.ts.length; i < o && !(this.animClock < r.ts[i]); i++)
5089
- for (let [c, d] of Object.entries(r.vs))
5086
+ const a = this.animQueue[n];
5087
+ if (!(!a || !a.ts || !a.ts.length || this.animClock < a.ts[0])) {
5088
+ for (i = a.ndx || 0, o = a.ts.length; i < o && !(this.animClock < a.ts[i]); i++)
5089
+ for (let [c, d] of Object.entries(a.vs))
5090
5090
  if (this.mtAvatar.hasOwnProperty(c)) {
5091
5091
  if (d[i + 1] === null) continue;
5092
5092
  const g = this.mtAvatar[c];
@@ -5094,9 +5094,9 @@ class Fe {
5094
5094
  g.newvalue = d[i];
5095
5095
  else {
5096
5096
  g.newvalue = d[i + 1];
5097
- const y = r.ts[i + 1] - r.ts[i];
5097
+ const y = a.ts[i + 1] - a.ts[i];
5098
5098
  let x = 1;
5099
- y > 1e-4 && (x = (this.animClock - r.ts[i]) / y), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) * d[i] + x * g.newvalue), g.ref && g.ref !== r.vs && g.ref.hasOwnProperty(c) && delete g.ref[c], g.ref = r.vs;
5099
+ y > 1e-4 && (x = (this.animClock - a.ts[i]) / y), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) * d[i] + x * g.newvalue), g.ref && g.ref !== a.vs && g.ref.hasOwnProperty(c) && delete g.ref[c], g.ref = a.vs;
5100
5100
  }
5101
5101
  if (l)
5102
5102
  switch (c) {
@@ -5108,12 +5108,12 @@ class Fe {
5108
5108
  g.newvalue *= 1 + l / 255 - 0.5;
5109
5109
  }
5110
5110
  g.needsUpdate = !0;
5111
- } else c === "eyeContact" && d[i] !== null && u !== !1 ? u = !!d[i] : c === "headMove" && d[i] !== null && a !== !1 ? d[i] === 0 ? a = !1 : (Math.random() < d[i] && (a = !0), d[i] = null) : d[i] !== null && (h.push({ mt: c, val: d[i] }), d[i] = null);
5112
- i === o ? (r.hasOwnProperty("mood") && this.setMood(r.mood), r.loop ? (o = this.isSpeaking && (r.template.name === "head" || r.template.name === "eyes") ? 4 : 1, this.animQueue[n] = this.animFactory(r.template, r.loop > 0 ? r.loop - 1 : r.loop, 1, 1 / o)) : (this.animQueue.splice(n--, 1), s--)) : r.ndx = i - 1;
5111
+ } else c === "eyeContact" && d[i] !== null && u !== !1 ? u = !!d[i] : c === "headMove" && d[i] !== null && r !== !1 ? d[i] === 0 ? r = !1 : (Math.random() < d[i] && (r = !0), d[i] = null) : d[i] !== null && (h.push({ mt: c, val: d[i] }), d[i] = null);
5112
+ i === o ? (a.hasOwnProperty("mood") && this.setMood(a.mood), a.loop ? (o = this.isSpeaking && (a.template.name === "head" || a.template.name === "eyes") ? 4 : 1, this.animQueue[n] = this.animFactory(a.template, a.loop > 0 ? a.loop - 1 : a.loop, 1, 1 / o)) : (this.animQueue.splice(n--, 1), s--)) : a.ndx = i - 1;
5113
5113
  }
5114
5114
  }
5115
- for (let r = 0, c = h.length; r < c; r++)
5116
- switch (i = h[r].val, h[r].mt) {
5115
+ for (let a = 0, c = h.length; a < c; a++)
5116
+ switch (i = h[a].val, h[a].mt) {
5117
5117
  case "speak":
5118
5118
  this.speakText(i);
5119
5119
  break;
@@ -5159,7 +5159,7 @@ class Fe {
5159
5159
  }, i.x ? new f.Vector3(i.x, i.y, i.z) : null, !0, i.d);
5160
5160
  break;
5161
5161
  }
5162
- if ((u || a) && (F.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), F.x = Math.max(-0.9, Math.min(0.9, 2 * F.x - 0.5)), F.y = Math.max(-0.9, Math.min(0.9, -2.5 * F.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: F.x < 0 ? -F.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: F.x < 0 ? 0 : F.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: F.y < 0 ? 0 : F.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: F.y < 0 ? -F.y : 0, needsUpdate: !0 }), a && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5162
+ if ((u || r) && (E.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), E.x = Math.max(-0.9, Math.min(0.9, 2 * E.x - 0.5)), E.y = Math.max(-0.9, Math.min(0.9, -2.5 * E.y)), u ? (Object.assign(this.mtAvatar.eyesLookDown, { system: E.x < 0 ? -E.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: E.x < 0 ? 0 : E.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: E.y < 0 ? 0 : E.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: E.y < 0 ? -E.y : 0, needsUpdate: !0 }), r && (n = -this.mtAvatar.bodyRotateY.value, i = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5163
5163
  name: "headmove",
5164
5164
  dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
5165
5165
  vs: {
@@ -5180,13 +5180,13 @@ class Fe {
5180
5180
  eyeLookOutRight: [null, 0],
5181
5181
  eyeContact: [0]
5182
5182
  }
5183
- })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (V.setFromAxisAngle(ht, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(V)), Te.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ue), ue.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectHips.position.y -= Te.min.y / 2, this.objectHips.position.x -= (ue.x + ce.x) / 4, this.objectHips.position.z -= (ue.z + ce.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5183
+ })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (G.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(G)), Pe.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(pe), pe.sub(this.armature.position), this.objectHips.position.y -= Pe.min.y / 2, this.objectHips.position.x -= (ce.x + pe.x) / 4, this.objectHips.position.z -= (ce.z + pe.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5184
5184
  this.stats && this.stats.end();
5185
5185
  else {
5186
5186
  if (this.cameraClock !== null && this.cameraClock < 1e3) {
5187
5187
  this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
5188
- let r = new f.Spherical().setFromVector3(this.cameraStart), c = new f.Spherical().setFromVector3(this.cameraEnd);
5189
- r.phi += this.easing(this.cameraClock / 1e3) * (c.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (c.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (c.radius - r.radius), r.makeSafe(), this.camera.position.setFromSpherical(r), this.controlsStart.x !== this.controlsEnd.x ? this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1e3))) : (r.setFromVector3(this.controlsStart), c.setFromVector3(this.controlsEnd), r.phi += this.easing(this.cameraClock / 1e3) * (c.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (c.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (c.radius - r.radius), r.makeSafe(), this.controls.target.setFromSpherical(r)), this.controls.update();
5188
+ let a = new f.Spherical().setFromVector3(this.cameraStart), c = new f.Spherical().setFromVector3(this.cameraEnd);
5189
+ a.phi += this.easing(this.cameraClock / 1e3) * (c.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (c.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (c.radius - a.radius), a.makeSafe(), this.camera.position.setFromSpherical(a), this.controlsStart.x !== this.controlsEnd.x ? this.controls.target.copy(this.controlsStart.lerp(this.controlsEnd, this.easing(this.cameraClock / 1e3))) : (a.setFromVector3(this.controlsStart), c.setFromVector3(this.controlsEnd), a.phi += this.easing(this.cameraClock / 1e3) * (c.phi - a.phi), a.theta += this.easing(this.cameraClock / 1e3) * (c.theta - a.theta), a.radius += this.easing(this.cameraClock / 1e3) * (c.radius - a.radius), a.makeSafe(), this.controls.target.setFromSpherical(a)), this.controls.update();
5190
5190
  }
5191
5191
  this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
5192
5192
  }
@@ -5211,8 +5211,8 @@ class Fe {
5211
5211
  if (!this.lipsync.hasOwnProperty(t)) {
5212
5212
  const n = t.toLowerCase(), i = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5213
5213
  try {
5214
- const s = He[n];
5215
- s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(He));
5214
+ const s = Fe[n];
5215
+ s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Fe));
5216
5216
  } catch (s) {
5217
5217
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5218
5218
  }
@@ -5247,16 +5247,16 @@ class Fe {
5247
5247
  */
5248
5248
  speakText(t, e = null, n = null, i = null) {
5249
5249
  e = e || {};
5250
- const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, o = /[ ]/ug, l = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, u = /[\p{Extended_Pictographic}]/ug, a = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
5251
- let h = "", r = "", c = 0, d = [], g = [];
5250
+ const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, o = /[ ]/ug, l = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, u = /[\p{Extended_Pictographic}]/ug, r = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
5251
+ let h = "", a = "", c = 0, d = [], g = [];
5252
5252
  const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
5253
5253
  for (let x = 0; x < y.length; x++) {
5254
- const I = x === y.length - 1, D = y[x].match(l);
5254
+ const I = x === y.length - 1, B = y[x].match(l);
5255
5255
  let p = y[x].match(s);
5256
- const C = y[x].match(u), z = y[x].match(o);
5257
- if (p && !I && !C && y[x + 1].match(s) && (p = !1), n && (h += y[x]), D && (!i || i.every((R) => x < R[0] || x > R[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
5256
+ const H = y[x].match(u), z = y[x].match(o);
5257
+ if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), B && (!i || i.every((R) => x < R[0] || x > R[1])) && (a += y[x]), (z || p || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5258
5258
  mark: c,
5259
- word: r
5259
+ word: a
5260
5260
  })), h.length && (g.push({
5261
5261
  mark: c,
5262
5262
  template: { name: "subtitles" },
@@ -5264,30 +5264,30 @@ class Fe {
5264
5264
  vs: {
5265
5265
  subtitles: [h]
5266
5266
  }
5267
- }), h = ""), r.length)) {
5268
- const R = this.lipsyncWordsToVisemes(r, a);
5267
+ }), h = ""), a.length)) {
5268
+ const R = this.lipsyncWordsToVisemes(a, r);
5269
5269
  if (R && R.visemes && R.visemes.length) {
5270
5270
  const T = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
5271
- for (let P = 0; P < R.visemes.length; P++)
5271
+ for (let F = 0; F < R.visemes.length; F++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(R.times[P] - 0.6) / T, (R.times[P] + 0.5) / T, (R.times[P] + R.durations[P] + 0.5) / T],
5275
+ ts: [(R.times[F] - 0.6) / T, (R.times[F] + 0.5) / T, (R.times[F] + R.durations[F] + 0.5) / T],
5276
5276
  vs: {
5277
- ["viseme_" + R.visemes[P]]: [null, R.visemes[P] === "PP" || R.visemes[P] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + R.visemes[F]]: [null, R.visemes[F] === "PP" || R.visemes[F] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
5281
- r = "", c++;
5281
+ a = "", c++;
5282
5282
  }
5283
5283
  if (p || I) {
5284
5284
  if (d.length || I && g.length) {
5285
5285
  const R = {
5286
5286
  anim: g
5287
5287
  };
5288
- n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], r = "", c = 0, g = [];
5288
+ n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], a = "", c = 0, g = [];
5289
5289
  }
5290
- if (C) {
5290
+ if (H) {
5291
5291
  let R = this.animEmojis[y[x]];
5292
5292
  R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
5293
5293
  }
@@ -5370,25 +5370,25 @@ class Fe {
5370
5370
  if (t.words) {
5371
5371
  let o = [];
5372
5372
  for (let l = 0; l < t.words.length; l++) {
5373
- const u = t.words[l], a = t.wtimes[l];
5373
+ const u = t.words[l], r = t.wtimes[l];
5374
5374
  let h = t.wdurations[l];
5375
5375
  if (u.length && (n && o.push({
5376
5376
  template: { name: "subtitles" },
5377
- ts: [a],
5377
+ ts: [r],
5378
5378
  vs: {
5379
5379
  subtitles: [" " + u]
5380
5380
  }
5381
5381
  }), !t.visemes)) {
5382
- const r = this.lipsyncPreProcessText(u, i), c = this.lipsyncWordsToVisemes(r, i);
5382
+ const a = this.lipsyncPreProcessText(u, i), c = this.lipsyncWordsToVisemes(a, i);
5383
5383
  if (c && c.visemes && c.visemes.length) {
5384
5384
  const d = c.times[c.visemes.length - 1] + c.durations[c.visemes.length - 1], g = Math.min(h, Math.max(0, h - c.visemes.length * 150));
5385
5385
  let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5386
5386
  if (h = Math.min(h, c.visemes.length * 200), d > 0)
5387
5387
  for (let x = 0; x < c.visemes.length; x++) {
5388
- const I = a + c.times[x] / d * h, D = c.durations[x] / d * h;
5388
+ const I = r + c.times[x] / d * h, B = c.durations[x] / d * h;
5389
5389
  o.push({
5390
5390
  template: { name: "viseme" },
5391
- ts: [I - Math.min(60, 2 * D / 3), I + Math.min(25, D / 2), I + D + Math.min(60, D / 2)],
5391
+ ts: [I - Math.min(60, 2 * B / 3), I + Math.min(25, B / 2), I + B + Math.min(60, B / 2)],
5392
5392
  vs: {
5393
5393
  ["viseme_" + c.visemes[x]]: [null, c.visemes[x] === "PP" || c.visemes[x] === "FF" ? 0.9 : y, 0]
5394
5394
  }
@@ -5399,10 +5399,10 @@ class Fe {
5399
5399
  }
5400
5400
  if (t.visemes)
5401
5401
  for (let l = 0; l < t.visemes.length; l++) {
5402
- const u = t.visemes[l], a = t.vtimes[l], h = t.vdurations[l];
5402
+ const u = t.visemes[l], r = t.vtimes[l], h = t.vdurations[l];
5403
5403
  o.push({
5404
5404
  template: { name: "viseme" },
5405
- ts: [a - 2 * h / 3, a + h / 2, a + h + h / 2],
5405
+ ts: [r - 2 * h / 3, r + h / 2, r + h + h / 2],
5406
5406
  vs: {
5407
5407
  ["viseme_" + u]: [null, u === "PP" || u === "FF" ? 0.9 : 0.6, 0]
5408
5408
  }
@@ -5410,10 +5410,10 @@ class Fe {
5410
5410
  }
5411
5411
  if (t.markers)
5412
5412
  for (let l = 0; l < t.markers.length; l++) {
5413
- const u = t.markers[l], a = t.mtimes[l];
5413
+ const u = t.markers[l], r = t.mtimes[l];
5414
5414
  o.push({
5415
5415
  template: { name: "markers" },
5416
- ts: [a],
5416
+ ts: [r],
5417
5417
  vs: { function: [u] }
5418
5418
  });
5419
5419
  }
@@ -5466,11 +5466,11 @@ class Fe {
5466
5466
  */
5467
5467
  async synthesizeWithBrowserTTS(t) {
5468
5468
  return new Promise((e, n) => {
5469
- const i = t.text.map((p) => p.word).join(" "), s = new SpeechSynthesisUtterance(i), o = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", l = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, u = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, a = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5470
- s.lang = o, s.rate = Math.max(0.1, Math.min(10, l)), s.pitch = Math.max(0, Math.min(2, u)), s.volume = Math.max(0, Math.min(1, a));
5471
- const h = speechSynthesis.getVoices(), r = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5472
- if (r && h.length > 0) {
5473
- const p = h.find((C) => C.name.includes(r) || C.lang === o);
5469
+ const i = t.text.map((p) => p.word).join(" "), s = new SpeechSynthesisUtterance(i), o = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", l = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, u = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, r = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5470
+ s.lang = o, s.rate = Math.max(0.1, Math.min(10, l)), s.pitch = Math.max(0, Math.min(2, u)), s.volume = Math.max(0, Math.min(1, r));
5471
+ const h = speechSynthesis.getVoices(), a = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5472
+ if (a && h.length > 0) {
5473
+ const p = h.find((H) => H.name.includes(a) || H.lang === o);
5474
5474
  p && (s.voice = p);
5475
5475
  }
5476
5476
  const c = i.length * 100 / s.rate, d = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (c / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", y = this.lipsyncPreProcessText(i, g), x = this.lipsyncWordsToVisemes(y, g);
@@ -5485,19 +5485,19 @@ class Fe {
5485
5485
  const I = [];
5486
5486
  if (x && x.visemes && x.visemes.length > 0) {
5487
5487
  const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
5488
- for (let C = 0; C < x.visemes.length; C++) {
5489
- const z = x.visemes[C], R = x.times[C] / p, T = x.durations[C] / p, P = R * c, ie = T * c;
5488
+ for (let H = 0; H < x.visemes.length; H++) {
5489
+ const z = x.visemes[H], R = x.times[H] / p, T = x.durations[H] / p, F = R * c, J = T * c;
5490
5490
  I.push({
5491
5491
  template: { name: "viseme" },
5492
- ts: [P - Math.min(60, 2 * ie / 3), P + Math.min(25, ie / 2), P + ie + Math.min(60, ie / 2)],
5492
+ ts: [F - Math.min(60, 2 * J / 3), F + Math.min(25, J / 2), F + J + Math.min(60, J / 2)],
5493
5493
  vs: {
5494
5494
  ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5495
5495
  }
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const D = [...t.anim, ...I];
5500
- this.audioPlaylist.push({ anim: D, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5499
+ const B = [...t.anim, ...I];
5500
+ this.audioPlaylist.push({ anim: B, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5501
5501
  e();
5502
5502
  }, s.onerror = (p) => {
5503
5503
  console.error("Speech synthesis error:", p.error), n(p.error);
@@ -5532,7 +5532,7 @@ class Fe {
5532
5532
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5533
5533
  console.log("Using text-based lip-sync for debugging...");
5534
5534
  const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5535
- let a;
5535
+ let r;
5536
5536
  try {
5537
5537
  console.log("Lip-sync modules available:", {
5538
5538
  hasLipsync: !!this.lipsync,
@@ -5545,7 +5545,7 @@ class Fe {
5545
5545
  lipsyncData: d,
5546
5546
  hasVisemes: d && d.visemes && d.visemes.length > 0
5547
5547
  }), d && d.visemes && d.visemes.length > 0)
5548
- a = {
5548
+ r = {
5549
5549
  visemes: d.visemes.map((g, y) => ({
5550
5550
  viseme: g,
5551
5551
  startTime: y * l.duration / d.visemes.length,
@@ -5567,7 +5567,7 @@ class Fe {
5567
5567
  let I = "aa";
5568
5568
  "aeiou".includes(x) ? I = "aa" : "bp".includes(x) ? I = "PP" : "fv".includes(x) ? I = "FF" : "st".includes(x) ? I = "SS" : "dln".includes(x) ? I = "DD" : "kg".includes(x) ? I = "kk" : "rw".includes(x) && (I = "RR"), g.push(I);
5569
5569
  }
5570
- a = {
5570
+ r = {
5571
5571
  visemes: g.map((y, x) => ({
5572
5572
  viseme: y,
5573
5573
  startTime: x * l.duration / g.length,
@@ -5583,20 +5583,20 @@ class Fe {
5583
5583
  console.log("ElevenLabs TTS Audio Analysis:", {
5584
5584
  text: e,
5585
5585
  audioDuration: l.duration,
5586
- visemeCount: a.visemes ? a.visemes.length : 0,
5587
- wordCount: a.words ? a.words.length : 0,
5586
+ visemeCount: r.visemes ? r.visemes.length : 0,
5587
+ wordCount: r.words ? r.words.length : 0,
5588
5588
  features: {
5589
- onsets: a.features && a.features.onsets ? a.features.onsets.length : 0,
5590
- boundaries: a.features && a.features.phonemeBoundaries ? a.features.phonemeBoundaries.length : 0
5589
+ onsets: r.features && r.features.onsets ? r.features.onsets.length : 0,
5590
+ boundaries: r.features && r.features.phonemeBoundaries ? r.features.phonemeBoundaries.length : 0
5591
5591
  },
5592
- visemes: a.visemes ? a.visemes.slice(0, 3) : []
5592
+ visemes: r.visemes ? r.visemes.slice(0, 3) : []
5593
5593
  // Show first 3 visemes for debugging
5594
5594
  });
5595
5595
  const h = [];
5596
- if (a.visemes && a.visemes.length > 0) {
5597
- console.log("ElevenLabs: Generating lip-sync animation from", a.visemes.length, "visemes");
5598
- for (let c = 0; c < a.visemes.length; c++) {
5599
- const d = a.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5596
+ if (r.visemes && r.visemes.length > 0) {
5597
+ console.log("ElevenLabs: Generating lip-sync animation from", r.visemes.length, "visemes");
5598
+ for (let c = 0; c < r.visemes.length; c++) {
5599
+ const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5600
5600
  h.push({
5601
5601
  template: { name: "viseme" },
5602
5602
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
@@ -5608,8 +5608,8 @@ class Fe {
5608
5608
  console.log("ElevenLabs: Generated", h.length, "lip-sync animation frames");
5609
5609
  } else
5610
5610
  console.warn("ElevenLabs: No visemes available for lip-sync animation");
5611
- const r = [...t.anim, ...h];
5612
- console.log("ElevenLabs: Combined animation frames:", r.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: r, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5611
+ const a = [...t.anim, ...h];
5612
+ console.log("ElevenLabs: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5613
5613
  }
5614
5614
  /**
5615
5615
  * Synthesize speech using Deepgram Aura-2 TTS
@@ -5630,7 +5630,7 @@ class Fe {
5630
5630
  const o = await s.arrayBuffer(), l = await this.audioCtx.decodeAudioData(o);
5631
5631
  console.log("Using text-based lip-sync for Deepgram...");
5632
5632
  const u = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en";
5633
- let a;
5633
+ let r;
5634
5634
  try {
5635
5635
  console.log("Lip-sync modules available:", {
5636
5636
  hasLipsync: !!this.lipsync,
@@ -5643,7 +5643,7 @@ class Fe {
5643
5643
  lipsyncData: d,
5644
5644
  hasVisemes: d && d.visemes && d.visemes.length > 0
5645
5645
  }), d && d.visemes && d.visemes.length > 0)
5646
- a = {
5646
+ r = {
5647
5647
  visemes: d.visemes.map((g, y) => ({
5648
5648
  viseme: g,
5649
5649
  startTime: y * l.duration / d.visemes.length,
@@ -5665,7 +5665,7 @@ class Fe {
5665
5665
  let I = "aa";
5666
5666
  "aeiou".includes(x) ? I = "aa" : "bp".includes(x) ? I = "PP" : "fv".includes(x) ? I = "FF" : "st".includes(x) ? I = "SS" : "dln".includes(x) ? I = "DD" : "kg".includes(x) ? I = "kk" : "rw".includes(x) && (I = "RR"), g.push(I);
5667
5667
  }
5668
- a = {
5668
+ r = {
5669
5669
  visemes: g.map((y, x) => ({
5670
5670
  viseme: y,
5671
5671
  startTime: x * l.duration / g.length,
@@ -5681,20 +5681,20 @@ class Fe {
5681
5681
  console.log("Deepgram TTS Audio Analysis:", {
5682
5682
  text: e,
5683
5683
  audioDuration: l.duration,
5684
- visemeCount: a.visemes ? a.visemes.length : 0,
5685
- wordCount: a.words ? a.words.length : 0,
5684
+ visemeCount: r.visemes ? r.visemes.length : 0,
5685
+ wordCount: r.words ? r.words.length : 0,
5686
5686
  features: {
5687
- onsets: a.features && a.features.onsets ? a.features.onsets.length : 0,
5688
- boundaries: a.features && a.features.phonemeBoundaries ? a.features.phonemeBoundaries.length : 0
5687
+ onsets: r.features && r.features.onsets ? r.features.onsets.length : 0,
5688
+ boundaries: r.features && r.features.phonemeBoundaries ? r.features.phonemeBoundaries.length : 0
5689
5689
  },
5690
- visemes: a.visemes ? a.visemes.slice(0, 3) : []
5690
+ visemes: r.visemes ? r.visemes.slice(0, 3) : []
5691
5691
  // Show first 3 visemes for debugging
5692
5692
  });
5693
5693
  const h = [];
5694
- if (a.visemes && a.visemes.length > 0) {
5695
- console.log("Deepgram: Generating lip-sync animation from", a.visemes.length, "visemes");
5696
- for (let c = 0; c < a.visemes.length; c++) {
5697
- const d = a.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5694
+ if (r.visemes && r.visemes.length > 0) {
5695
+ console.log("Deepgram: Generating lip-sync animation from", r.visemes.length, "visemes");
5696
+ for (let c = 0; c < r.visemes.length; c++) {
5697
+ const d = r.visemes[c], g = d.startTime * 1e3, y = d.duration * 1e3, x = d.intensity;
5698
5698
  h.push({
5699
5699
  template: { name: "viseme" },
5700
5700
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
@@ -5706,15 +5706,15 @@ class Fe {
5706
5706
  console.log("Deepgram: Generated", h.length, "lip-sync animation frames");
5707
5707
  } else
5708
5708
  console.warn("Deepgram: No visemes available for lip-sync animation");
5709
- const r = [...t.anim, ...h];
5710
- console.log("Deepgram: Combined animation frames:", r.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: r, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5709
+ const a = [...t.anim, ...h];
5710
+ console.log("Deepgram: Combined animation frames:", a.length, "(original:", t.anim.length, "+ lipsync:", h.length, ")"), this.audioPlaylist.push({ anim: a, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5711
5711
  }
5712
5712
  /**
5713
5713
  * Synthesize speech using Azure TTS
5714
5714
  * @param {Object} line Speech line object
5715
5715
  */
5716
5716
  async synthesizeWithAzureTTS(t) {
5717
- const e = t.text.map((r) => r.word).join(" "), i = `
5717
+ const e = t.text.map((a) => a.word).join(" "), i = `
5718
5718
  <speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="en-US">
5719
5719
  <voice name="${t.voice || this.avatar.ttsVoice || this.opt.ttsVoice || "en-US-AriaNeural"}">
5720
5720
  ${e}
@@ -5744,10 +5744,10 @@ class Fe {
5744
5744
  boundaries: u.features.phonemeBoundaries.length
5745
5745
  }
5746
5746
  });
5747
- const a = [];
5748
- for (let r = 0; r < u.visemes.length; r++) {
5749
- const c = u.visemes[r], d = c.startTime * 1e3, g = c.duration * 1e3, y = c.intensity;
5750
- a.push({
5747
+ const r = [];
5748
+ for (let a = 0; a < u.visemes.length; a++) {
5749
+ const c = u.visemes[a], d = c.startTime * 1e3, g = c.duration * 1e3, y = c.intensity;
5750
+ r.push({
5751
5751
  template: { name: "viseme" },
5752
5752
  ts: [d - Math.min(60, 2 * g / 3), d + Math.min(25, g / 2), d + g + Math.min(60, g / 2)],
5753
5753
  vs: {
@@ -5755,7 +5755,7 @@ class Fe {
5755
5755
  }
5756
5756
  });
5757
5757
  }
5758
- const h = [...t.anim, ...a];
5758
+ const h = [...t.anim, ...r];
5759
5759
  this.audioPlaylist.push({ anim: h, audio: l }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio();
5760
5760
  }
5761
5761
  /**
@@ -5796,11 +5796,11 @@ class Fe {
5796
5796
  const o = this.b64ToArrayBuffer(s.audioContent), l = await this.audioCtx.decodeAudioData(o);
5797
5797
  this.speakWithHands();
5798
5798
  const u = [0];
5799
- let a = 0;
5799
+ let r = 0;
5800
5800
  t.text.forEach((c, d) => {
5801
5801
  if (d > 0) {
5802
5802
  let g = u[u.length - 1];
5803
- s.timepoints[a] && (g = s.timepoints[a].timeSeconds * 1e3, s.timepoints[a].markName === "" + c.mark && a++), u.push(g);
5803
+ s.timepoints[r] && (g = s.timepoints[r].timeSeconds * 1e3, s.timepoints[r].markName === "" + c.mark && r++), u.push(g);
5804
5804
  }
5805
5805
  });
5806
5806
  const h = [{ mark: 0, time: 0 }];
@@ -5810,8 +5810,8 @@ class Fe {
5810
5810
  h[d - 1].duration = g, h.push({ mark: d, time: c });
5811
5811
  }
5812
5812
  });
5813
- let r = 1e3 * l.duration;
5814
- r > this.opt.ttsTrimEnd && (r = r - this.opt.ttsTrimEnd), h[h.length - 1].duration = r - h[h.length - 1].time, t.anim.forEach((c) => {
5813
+ let a = 1e3 * l.duration;
5814
+ a > this.opt.ttsTrimEnd && (a = a - this.opt.ttsTrimEnd), h[h.length - 1].duration = a - h[h.length - 1].time, t.anim.forEach((c) => {
5815
5815
  const d = h[c.mark];
5816
5816
  if (d)
5817
5817
  for (let g = 0; g < c.ts.length; g++)
@@ -5895,8 +5895,8 @@ class Fe {
5895
5895
  }
5896
5896
  if (!this.workletLoaded)
5897
5897
  try {
5898
- const l = this.audioCtx.audioWorklet.addModule(lt.href), u = new Promise(
5899
- (a, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5898
+ const l = this.audioCtx.audioWorklet.addModule(dt.href), u = new Promise(
5899
+ (r, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5900
5900
  );
5901
5901
  await Promise.race([l, u]), this.workletLoaded = !0;
5902
5902
  } catch (l) {
@@ -5932,7 +5932,7 @@ class Fe {
5932
5932
  } catch {
5933
5933
  }
5934
5934
  if (this.resetLips(), this.lookAtCamera(500), t.mood && this.setMood(t.mood), this.onSubtitles = i || null, this.audioCtx.state === "suspended" || this.audioCtx.state === "interrupted") {
5935
- const l = this.audioCtx.resume(), u = new Promise((a, h) => setTimeout(() => h("p2"), 1e3));
5935
+ const l = this.audioCtx.resume(), u = new Promise((r, h) => setTimeout(() => h("p2"), 1e3));
5936
5936
  try {
5937
5937
  await Promise.race([l, u]);
5938
5938
  } catch {
@@ -6031,18 +6031,18 @@ class Fe {
6031
6031
  subtitles: [" " + i]
6032
6032
  }
6033
6033
  }), this.streamLipsyncType == "words")) {
6034
- const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, u = this.lipsyncPreProcessText(i, l), a = this.lipsyncWordsToVisemes(u, l);
6035
- if (a && a.visemes && a.visemes.length) {
6036
- const h = a.times[a.visemes.length - 1] + a.durations[a.visemes.length - 1], r = Math.min(o, Math.max(0, o - a.visemes.length * 150));
6037
- let c = 0.6 + this.convertRange(r, [0, o], [0, 0.4]);
6038
- if (o = Math.min(o, a.visemes.length * 200), h > 0)
6039
- for (let d = 0; d < a.visemes.length; d++) {
6040
- const g = e + s + a.times[d] / h * o, y = a.durations[d] / h * o;
6034
+ const l = this.streamLipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang, u = this.lipsyncPreProcessText(i, l), r = this.lipsyncWordsToVisemes(u, l);
6035
+ if (r && r.visemes && r.visemes.length) {
6036
+ const h = r.times[r.visemes.length - 1] + r.durations[r.visemes.length - 1], a = Math.min(o, Math.max(0, o - r.visemes.length * 150));
6037
+ let c = 0.6 + this.convertRange(a, [0, o], [0, 0.4]);
6038
+ if (o = Math.min(o, r.visemes.length * 200), h > 0)
6039
+ for (let d = 0; d < r.visemes.length; d++) {
6040
+ const g = e + s + r.times[d] / h * o, y = r.durations[d] / h * o;
6041
6041
  this.animQueue.push({
6042
6042
  template: { name: "viseme" },
6043
6043
  ts: [g - Math.min(60, 2 * y / 3), g + Math.min(25, y / 2), g + y + Math.min(60, y / 2)],
6044
6044
  vs: {
6045
- ["viseme_" + a.visemes[d]]: [null, a.visemes[d] === "PP" || a.visemes[d] === "FF" ? 0.9 : c, 0]
6045
+ ["viseme_" + r.visemes[d]]: [null, r.visemes[d] === "PP" || r.visemes[d] === "FF" ? 0.9 : c, 0]
6046
6046
  }
6047
6047
  });
6048
6048
  }
@@ -6133,7 +6133,7 @@ class Fe {
6133
6133
  */
6134
6134
  lookAtCamera(t) {
6135
6135
  let e;
6136
- if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ue.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), ce.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ue, ce).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6136
+ if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ce.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ce, pe).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6137
6137
  if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
6138
6138
  if (this.avatar.avatarIgnoreCamera) {
6139
6139
  this.lookAhead(t);
@@ -6146,12 +6146,12 @@ class Fe {
6146
6146
  this.lookAt(null, null, t);
6147
6147
  return;
6148
6148
  }
6149
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ue.setFromMatrixPosition(this.objectLeftEye.matrixWorld), ce.setFromMatrixPosition(this.objectRightEye.matrixWorld), ue.add(ce).divideScalar(2), V.copy(this.armature.quaternion), V.multiply(this.poseTarget.props["Hips.quaternion"]), V.multiply(this.poseTarget.props["Spine.quaternion"]), V.multiply(this.poseTarget.props["Spine1.quaternion"]), V.multiply(this.poseTarget.props["Spine2.quaternion"]), V.multiply(this.poseTarget.props["Neck.quaternion"]), V.multiply(this.poseTarget.props["Head.quaternion"]);
6150
- const n = new f.Vector3().subVectors(e, ue).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
- F.set(s, i, 0, "YXZ");
6152
- const l = new f.Quaternion().setFromEuler(F), u = new f.Quaternion().copy(l).multiply(V.clone().invert());
6153
- F.setFromQuaternion(u, "YXZ");
6154
- let a = F.x / (40 / 24) + 0.2, h = F.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, a)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6149
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ce.setFromMatrixPosition(this.objectLeftEye.matrixWorld), pe.setFromMatrixPosition(this.objectRightEye.matrixWorld), ce.add(pe).divideScalar(2), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]);
6150
+ const n = new f.Vector3().subVectors(e, ce).normalize(), i = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6151
+ E.set(s, i, 0, "YXZ");
6152
+ const l = new f.Quaternion().setFromEuler(E), u = new f.Quaternion().copy(l).multiply(G.clone().invert());
6153
+ E.setFromQuaternion(u, "YXZ");
6154
+ let r = E.x / (40 / 24) + 0.2, h = E.y / (9 / 4), a = Math.min(0.6, Math.max(-0.3, r)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6155
6155
  if (t) {
6156
6156
  let y = this.animQueue.findIndex((I) => I.template.name === "lookat");
6157
6157
  y !== -1 && this.animQueue.splice(y, 1);
@@ -6159,7 +6159,7 @@ class Fe {
6159
6159
  name: "lookat",
6160
6160
  dt: [750, t],
6161
6161
  vs: {
6162
- bodyRotateX: [r + d],
6162
+ bodyRotateX: [a + d],
6163
6163
  bodyRotateY: [c + g],
6164
6164
  eyesRotateX: [-3 * d + 0.1],
6165
6165
  eyesRotateY: [-5 * g],
@@ -6185,21 +6185,21 @@ class Fe {
6185
6185
  this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0);
6186
6186
  const s = new f.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), o = new f.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), l = new f.Vector3().addVectors(s, o).divideScalar(2);
6187
6187
  l.project(this.camera);
6188
- let u = (l.x + 1) / 2 * i.width + i.left, a = -(l.y - 1) / 2 * i.height + i.top;
6189
- t === null && (t = u), e === null && (e = a), V.copy(this.armature.quaternion), V.multiply(this.poseTarget.props["Hips.quaternion"]), V.multiply(this.poseTarget.props["Spine.quaternion"]), V.multiply(this.poseTarget.props["Spine1.quaternion"]), V.multiply(this.poseTarget.props["Spine2.quaternion"]), V.multiply(this.poseTarget.props["Neck.quaternion"]), V.multiply(this.poseTarget.props["Head.quaternion"]), F.setFromQuaternion(V);
6190
- let h = F.x / (40 / 24), r = F.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
6188
+ let u = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6189
+ t === null && (t = u), e === null && (e = r), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(G);
6190
+ let h = E.x / (40 / 24), a = E.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - r, r), x = this.convertRange(e, [r - y, r + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - a + d;
6191
6191
  x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
6192
- let D = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6192
+ let B = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (n) {
6194
- let C = this.animQueue.findIndex((R) => R.template.name === "lookat");
6195
- C !== -1 && this.animQueue.splice(C, 1);
6194
+ let H = this.animQueue.findIndex((R) => R.template.name === "lookat");
6195
+ H !== -1 && this.animQueue.splice(H, 1);
6196
6196
  const z = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, n],
6199
6199
  vs: {
6200
- bodyRotateX: [x + D],
6200
+ bodyRotateX: [x + B],
6201
6201
  bodyRotateY: [I + p],
6202
- eyesRotateX: [-3 * D + 0.1],
6202
+ eyesRotateX: [-3 * B + 0.1],
6203
6203
  eyesRotateY: [-5 * p],
6204
6204
  browInnerUp: [[0, 0.7]],
6205
6205
  mouthLeft: [[0, 0.7]],
@@ -6226,10 +6226,10 @@ class Fe {
6226
6226
  s.setFromCamera(i, this.camera);
6227
6227
  const o = s.intersectObject(this.armature);
6228
6228
  if (o.length > 0) {
6229
- const l = o[0].point, u = new f.Vector3(), a = new f.Vector3();
6230
- this.objectLeftArm.getWorldPosition(u), this.objectRightArm.getWorldPosition(a);
6231
- const h = u.distanceToSquared(l), r = a.distanceToSquared(l);
6232
- h < r ? (this.ikSolve({
6229
+ const l = o[0].point, u = new f.Vector3(), r = new f.Vector3();
6230
+ this.objectLeftArm.getWorldPosition(u), this.objectRightArm.getWorldPosition(r);
6231
+ const h = u.distanceToSquared(l), a = r.distanceToSquared(l);
6232
+ h < a ? (this.ikSolve({
6233
6233
  iterations: 20,
6234
6234
  root: "LeftShoulder",
6235
6235
  effector: "LeftHandMiddle1",
@@ -6372,16 +6372,16 @@ class Fe {
6372
6372
  this.positionWasLocked = !o, o ? console.log("Position locking disabled for FBX animation:", t) : (this.lockAvatarPosition(), console.log("Position locked immediately before FBX animation:", t));
6373
6373
  let l = this.animClips.find((u) => u.url === t + "-" + i);
6374
6374
  if (l) {
6375
- let u = this.animQueue.find((r) => r.template.name === "pose");
6376
- u && (u.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((r) => {
6377
- this.poseBase.props[r[0]] = r[1].clone(), this.poseTarget.props[r[0]] = r[1].clone(), this.poseTarget.props[r[0]].t = 0, this.poseTarget.props[r[0]].d = 1e3;
6375
+ let u = this.animQueue.find((a) => a.template.name === "pose");
6376
+ u && (u.ts[0] = 1 / 0), Object.entries(l.pose.props).forEach((a) => {
6377
+ this.poseBase.props[a[0]] = a[1].clone(), this.poseTarget.props[a[0]] = a[1].clone(), this.poseTarget.props[a[0]].t = 0, this.poseTarget.props[a[0]].d = 1e3;
6378
6378
  }), this.mixer ? console.log("Using existing mixer for FBX animation, preserving morph targets") : (this.mixer = new f.AnimationMixer(this.armature), console.log("Created new mixer for FBX animation")), this.mixer.addEventListener("finished", this.stopAnimation.bind(this), { once: !0 });
6379
- const a = Math.ceil(n / l.clip.duration), h = this.mixer.clipAction(l.clip);
6380
- h.setLoop(f.LoopRepeat, a), h.clampWhenFinished = !0, this.currentFBXAction = h;
6379
+ const r = Math.ceil(n / l.clip.duration), h = this.mixer.clipAction(l.clip);
6380
+ h.setLoop(f.LoopRepeat, r), h.clampWhenFinished = !0, this.currentFBXAction = h;
6381
6381
  try {
6382
6382
  h.fadeIn(0.5).play(), console.log("FBX animation started successfully:", t);
6383
- } catch (r) {
6384
- console.warn("FBX animation failed to start:", r), this.stopAnimation();
6383
+ } catch (a) {
6384
+ console.warn("FBX animation failed to start:", a), this.stopAnimation();
6385
6385
  return;
6386
6386
  }
6387
6387
  if (h.getClip().tracks.length === 0) {
@@ -6393,20 +6393,20 @@ class Fe {
6393
6393
  console.error(`Invalid file type for FBX animation: ${t}. Expected .fbx file.`);
6394
6394
  return;
6395
6395
  }
6396
- let a = !1;
6396
+ let r = !1;
6397
6397
  try {
6398
6398
  const c = await fetch(t, { method: "HEAD" });
6399
- if (a = c.ok, !a) {
6399
+ if (r = c.ok, !r) {
6400
6400
  console.error(`FBX file not found at ${t}. Status: ${c.status}`), console.error("Please check:"), console.error("1. File path is correct (note: path is case-sensitive)"), console.error("2. File exists in your public folder"), console.error("3. File is accessible (not blocked by server)");
6401
6401
  return;
6402
6402
  }
6403
6403
  } catch (c) {
6404
6404
  console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
6405
6405
  }
6406
- const h = new ze();
6407
- let r;
6406
+ const h = new Me();
6407
+ let a;
6408
6408
  try {
6409
- r = await h.loadAsync(t, e);
6409
+ a = await h.loadAsync(t, e);
6410
6410
  } catch (c) {
6411
6411
  console.error(`Failed to load FBX animation from ${t}:`, c), console.error("Error details:", {
6412
6412
  message: c.message,
@@ -6426,8 +6426,8 @@ class Fe {
6426
6426
  }
6427
6427
  return;
6428
6428
  }
6429
- if (r && r.animations && r.animations[i]) {
6430
- let c = r.animations[i];
6429
+ if (a && a.animations && a.animations[i]) {
6430
+ let c = a.animations[i];
6431
6431
  const d = {};
6432
6432
  c.tracks.forEach((y) => {
6433
6433
  y.name = y.name.replaceAll("mixamorig", "");
@@ -6446,7 +6446,7 @@ class Fe {
6446
6446
  }), this.playAnimation(t, e, n, i, s);
6447
6447
  } else {
6448
6448
  const c = "Animation " + t + " (ndx=" + i + ") not found";
6449
- console.error(c), r && r.animations ? console.error(`FBX file loaded but has ${r.animations.length} animation(s), requested index ${i}`) : console.error(r ? "FBX file loaded but contains no animations" : "FBX file failed to load or is invalid");
6449
+ console.error(c), a && a.animations ? console.error(`FBX file loaded but has ${a.animations.length} animation(s), requested index ${i}`) : console.error(a ? "FBX file loaded but contains no animations" : "FBX file failed to load or is invalid");
6450
6450
  }
6451
6451
  }
6452
6452
  }
@@ -6480,23 +6480,23 @@ class Fe {
6480
6480
  let l = this.animQueue.find((u) => u.template.name === "pose");
6481
6481
  l && (l.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
6482
6482
  } else {
6483
- let u = await new ze().loadAsync(t, e);
6483
+ let u = await new Me().loadAsync(t, e);
6484
6484
  if (u && u.animations && u.animations[i]) {
6485
- let a = u.animations[i];
6485
+ let r = u.animations[i];
6486
6486
  const h = {};
6487
- a.tracks.forEach((c) => {
6487
+ r.tracks.forEach((c) => {
6488
6488
  c.name = c.name.replaceAll("mixamorig", "");
6489
6489
  const d = c.name.split(".");
6490
6490
  d[1] === "position" ? h[c.name] = new f.Vector3(c.values[0] * s, c.values[1] * s, c.values[2] * s) : d[1] === "quaternion" ? h[c.name] = new f.Quaternion(c.values[0], c.values[1], c.values[2], c.values[3]) : d[1] === "rotation" && (h[d[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(c.values[0], c.values[1], c.values[2], "XYZ")).normalize());
6491
6491
  });
6492
- const r = { props: h };
6493
- h["Hips.position"] && (h["Hips.position"].y < 0.5 ? r.lying = !0 : r.standing = !0), this.animPoses.push({
6492
+ const a = { props: h };
6493
+ h["Hips.position"] && (h["Hips.position"].y < 0.5 ? a.lying = !0 : a.standing = !0), this.animPoses.push({
6494
6494
  url: t + "-" + i,
6495
- pose: r
6495
+ pose: a
6496
6496
  }), this.playPose(t, e, n, i, s);
6497
6497
  } else {
6498
- const a = "Pose " + t + " (ndx=" + i + ") not found";
6499
- console.error(a);
6498
+ const r = "Pose " + t + " (ndx=" + i + ") not found";
6499
+ console.error(r);
6500
6500
  }
6501
6501
  }
6502
6502
  }
@@ -6521,8 +6521,8 @@ class Fe {
6521
6521
  this.gestureTimeout && (clearTimeout(this.gestureTimeout), this.gestureTimeout = null);
6522
6522
  let l = this.animQueue.findIndex((u) => u.template.name === "talkinghands");
6523
6523
  l !== -1 && (this.animQueue[l].ts = this.animQueue[l].ts.map((u) => 0)), this.gesture = this.propsToThreeObjects(s), n && (this.gesture = this.mirrorPose(this.gesture)), t === "namaste" && this.avatar.body === "M" && (this.gesture["RightArm.quaternion"].rotateTowards(new f.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new f.Quaternion(0, 1, 0, 0), -0.25));
6524
- for (let [u, a] of Object.entries(this.gesture))
6525
- a.t = this.animClock, a.d = i, this.poseTarget.props.hasOwnProperty(u) && (this.poseTarget.props[u].copy(a), this.poseTarget.props[u].t = this.animClock, this.poseTarget.props[u].d = i);
6524
+ for (let [u, r] of Object.entries(this.gesture))
6525
+ r.t = this.animClock, r.d = i, this.poseTarget.props.hasOwnProperty(u) && (this.poseTarget.props[u].copy(r), this.poseTarget.props[u].t = this.animClock, this.poseTarget.props[u].d = i);
6526
6526
  e && Number.isFinite(e) && (this.gestureTimeout = setTimeout(this.stopGesture.bind(this, i), 1e3 * e));
6527
6527
  }
6528
6528
  let o = this.animEmojis[t];
@@ -6568,7 +6568,7 @@ class Fe {
6568
6568
  * @param {numeric} [d=null] If set, apply in d milliseconds
6569
6569
  */
6570
6570
  ikSolve(t, e = null, n = !1, i = null) {
6571
- const s = new f.Vector3(), o = new f.Vector3(), l = new f.Vector3(), u = new f.Vector3(), a = new f.Quaternion(), h = new f.Vector3(), r = new f.Vector3(), c = new f.Vector3(), d = this.ikMesh.getObjectByName(t.root);
6571
+ const s = new f.Vector3(), o = new f.Vector3(), l = new f.Vector3(), u = new f.Vector3(), r = new f.Quaternion(), h = new f.Vector3(), a = new f.Vector3(), c = new f.Vector3(), d = this.ikMesh.getObjectByName(t.root);
6572
6572
  d.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), d.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(d.position);
6573
6573
  const g = this.ikMesh.getObjectByName(t.effector), y = t.links;
6574
6574
  y.forEach((I) => {
@@ -6577,12 +6577,12 @@ class Fe {
6577
6577
  const x = t.iterations || 10;
6578
6578
  if (e)
6579
6579
  for (let I = 0; I < x; I++) {
6580
- let D = !1;
6581
- for (let p = 0, C = y.length; p < C; p++) {
6580
+ let B = !1;
6581
+ for (let p = 0, H = y.length; p < H; p++) {
6582
6582
  const z = y[p].bone;
6583
- z.matrixWorld.decompose(u, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(a), l.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
6583
+ z.matrixWorld.decompose(u, r, h), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(r), l.normalize(), s.subVectors(e, u), s.applyQuaternion(r), s.normalize();
6584
6584
  let R = s.dot(l);
6585
- R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), V.setFromAxisAngle(r, R), z.quaternion.multiply(V), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6585
+ R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), G.setFromAxisAngle(a, R), z.quaternion.multiply(G), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6586
6586
  y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6587
6587
  y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6588
6588
  y[p].minz !== void 0 ? y[p].minz : -1 / 0
@@ -6590,9 +6590,9 @@ class Fe {
6590
6590
  y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6591
6591
  y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6592
6592
  y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6593
- ))), z.updateMatrixWorld(!0), D = !0);
6593
+ ))), z.updateMatrixWorld(!0), B = !0);
6594
6594
  }
6595
- if (!D) break;
6595
+ if (!B) break;
6596
6596
  }
6597
6597
  i && y.forEach((I) => {
6598
6598
  this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = i;
@@ -6605,7 +6605,7 @@ class Fe {
6605
6605
  this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
6606
6606
  }
6607
6607
  }
6608
- const fe = {
6608
+ const ve = {
6609
6609
  apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
6610
6610
  // Replace with your actual API key (should start with sk_)
6611
6611
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
@@ -6625,7 +6625,7 @@ const fe = {
6625
6625
  josh: "VR6AewLTigWG4xSOukaG"
6626
6626
  // Male, American
6627
6627
  }
6628
- }, Me = {
6628
+ }, Be = {
6629
6629
  defaultVoice: "aura-2-thalia-en",
6630
6630
  // Thalia (Female, English)
6631
6631
  voices: {
@@ -6645,26 +6645,26 @@ const fe = {
6645
6645
  // Male, English - Powerful
6646
6646
  }
6647
6647
  };
6648
- function Se() {
6648
+ function He() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
- endpoint: fe.endpoint,
6652
- apiKey: fe.apiKey,
6653
- defaultVoice: fe.defaultVoice,
6654
- voices: fe.voices
6651
+ endpoint: ve.endpoint,
6652
+ apiKey: ve.apiKey,
6653
+ defaultVoice: ve.defaultVoice,
6654
+ voices: ve.voices
6655
6655
  };
6656
6656
  }
6657
- function Rt() {
6658
- const O = Se(), t = [];
6659
- return Object.entries(O.voices).forEach(([e, n]) => {
6657
+ function St() {
6658
+ const U = He(), t = [];
6659
+ return Object.entries(U.voices).forEach(([e, n]) => {
6660
6660
  t.push({
6661
6661
  value: n,
6662
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${O.service})`
6662
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${U.service})`
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
- const Pe = Le(({
6667
- avatarUrl: O = "/avatars/brunette.glb",
6666
+ const Ne = ze(({
6667
+ avatarUrl: U = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
6670
6670
  ttsLang: n = "en",
@@ -6673,9 +6673,9 @@ const Pe = Le(({
6673
6673
  ttsApiKey: o = null,
6674
6674
  bodyMovement: l = "idle",
6675
6675
  movementIntensity: u = 0.5,
6676
- showFullAvatar: a = !0,
6676
+ showFullAvatar: r = !0,
6677
6677
  cameraView: h = "upper",
6678
- onReady: r = () => {
6678
+ onReady: a = () => {
6679
6679
  },
6680
6680
  onLoading: c = () => {
6681
6681
  },
@@ -6685,263 +6685,268 @@ const Pe = Le(({
6685
6685
  style: y = {},
6686
6686
  animations: x = {}
6687
6687
  }, I) => {
6688
- const D = Z(null), p = Z(null), C = Z(a), z = Z(null), R = Z(null), T = Z(!1), P = Z({ remainingText: null, originalText: null, options: null }), [ie, he] = ge(!0), [S, N] = ge(null), [X, Y] = ge(!1), [Q, J] = ge(!1);
6689
- ye(() => {
6690
- T.current = Q;
6691
- }, [Q]), ye(() => {
6692
- C.current = a;
6693
- }, [a]);
6694
- const oe = Se(), me = i || oe.service;
6695
- let se;
6696
- me === "browser" ? se = {
6688
+ const B = N(null), p = N(null), H = N(r), z = N(null), R = N(null), T = N(!1), F = N({ remainingText: null, originalText: null, options: null }), J = N([]), ye = N(0), [S, W] = be(!0), [Y, Z] = be(null), [$, se] = be(!1), [de, me] = be(!1);
6689
+ Re(() => {
6690
+ T.current = de;
6691
+ }, [de]), Re(() => {
6692
+ H.current = r;
6693
+ }, [r]);
6694
+ const ie = He(), fe = i || ie.service;
6695
+ let X;
6696
+ fe === "browser" ? X = {
6697
6697
  service: "browser",
6698
6698
  endpoint: "",
6699
6699
  apiKey: null,
6700
6700
  defaultVoice: "Google US English"
6701
- } : me === "elevenlabs" ? se = {
6701
+ } : fe === "elevenlabs" ? X = {
6702
6702
  service: "elevenlabs",
6703
6703
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6704
- apiKey: o || oe.apiKey,
6705
- defaultVoice: s || oe.defaultVoice || fe.defaultVoice,
6706
- voices: oe.voices || fe.voices
6707
- } : me === "deepgram" ? se = {
6704
+ apiKey: o || ie.apiKey,
6705
+ defaultVoice: s || ie.defaultVoice || ve.defaultVoice,
6706
+ voices: ie.voices || ve.voices
6707
+ } : fe === "deepgram" ? X = {
6708
6708
  service: "deepgram",
6709
6709
  endpoint: "https://api.deepgram.com/v1/speak",
6710
- apiKey: o || oe.apiKey,
6711
- defaultVoice: s || oe.defaultVoice || Me.defaultVoice,
6712
- voices: oe.voices || Me.voices
6713
- } : se = {
6714
- ...oe,
6710
+ apiKey: o || ie.apiKey,
6711
+ defaultVoice: s || ie.defaultVoice || Be.defaultVoice,
6712
+ voices: ie.voices || Be.voices
6713
+ } : X = {
6714
+ ...ie,
6715
6715
  // Override API key if provided via props
6716
- apiKey: o !== null ? o : oe.apiKey
6716
+ apiKey: o !== null ? o : ie.apiKey
6717
6717
  };
6718
- const pe = {
6719
- url: O,
6718
+ const b = {
6719
+ url: U,
6720
6720
  body: t,
6721
6721
  avatarMood: e,
6722
- ttsLang: me === "browser" ? "en-US" : n,
6723
- ttsVoice: s || se.defaultVoice,
6722
+ ttsLang: fe === "browser" ? "en-US" : n,
6723
+ ttsVoice: s || X.defaultVoice,
6724
6724
  lipsyncLang: "en",
6725
- showFullAvatar: a,
6725
+ showFullAvatar: r,
6726
6726
  bodyMovement: l,
6727
6727
  movementIntensity: u
6728
- }, ee = {
6729
- ttsEndpoint: se.endpoint,
6730
- ttsApikey: se.apiKey,
6731
- ttsService: me,
6728
+ }, v = {
6729
+ ttsEndpoint: X.endpoint,
6730
+ ttsApikey: X.apiKey,
6731
+ ttsService: fe,
6732
6732
  lipsyncModules: ["en"],
6733
6733
  cameraView: h
6734
- }, b = E(async () => {
6735
- if (!(!D.current || p.current))
6734
+ }, w = M(async () => {
6735
+ if (!(!B.current || p.current))
6736
6736
  try {
6737
- if (he(!0), N(null), p.current = new Fe(D.current, ee), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(pe, (G) => {
6738
- if (G.lengthComputable) {
6739
- const M = Math.min(100, Math.round(G.loaded / G.total * 100));
6740
- c(M);
6737
+ if (W(!0), Z(null), p.current = new Oe(B.current, v), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(b, (V) => {
6738
+ if (V.lengthComputable) {
6739
+ const Q = Math.min(100, Math.round(V.loaded / V.total * 100));
6740
+ c(Q);
6741
6741
  }
6742
- }), await new Promise((G) => {
6743
- const M = () => {
6744
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? G() : setTimeout(M, 100);
6742
+ }), await new Promise((V) => {
6743
+ const Q = () => {
6744
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? V() : setTimeout(Q, 100);
6745
6745
  };
6746
- M();
6746
+ Q();
6747
6747
  }), p.current && p.current.setShowFullAvatar)
6748
6748
  try {
6749
- p.current.setShowFullAvatar(a);
6750
- } catch (G) {
6751
- console.warn("Error setting full body mode on initialization:", G);
6749
+ p.current.setShowFullAvatar(r);
6750
+ } catch (V) {
6751
+ console.warn("Error setting full body mode on initialization:", V);
6752
6752
  }
6753
- p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), he(!1), Y(!0), r(p.current);
6754
- const B = () => {
6753
+ p.current && p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1, p.current.controls.update()), W(!1), se(!0), a(p.current);
6754
+ const P = () => {
6755
6755
  document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6756
6756
  };
6757
- return document.addEventListener("visibilitychange", B), () => {
6758
- document.removeEventListener("visibilitychange", B);
6757
+ return document.addEventListener("visibilitychange", P), () => {
6758
+ document.removeEventListener("visibilitychange", P);
6759
6759
  };
6760
6760
  } catch (L) {
6761
- console.error("Error initializing TalkingHead:", L), N(L.message || "Failed to initialize avatar"), he(!1), d(L);
6761
+ console.error("Error initializing TalkingHead:", L), Z(L.message || "Failed to initialize avatar"), W(!1), d(L);
6762
6762
  }
6763
- }, [O, t, e, n, i, s, o, a, l, u, h]);
6764
- ye(() => (b(), () => {
6763
+ }, [U, t, e, n, i, s, o, r, l, u, h]);
6764
+ Re(() => (w(), () => {
6765
6765
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6766
- }), [b]), ye(() => {
6767
- if (!D.current || !p.current) return;
6768
- const L = new ResizeObserver((G) => {
6769
- for (const M of G)
6766
+ }), [w]), Re(() => {
6767
+ if (!B.current || !p.current) return;
6768
+ const L = new ResizeObserver((V) => {
6769
+ for (const Q of V)
6770
6770
  p.current && p.current.onResize && p.current.onResize();
6771
6771
  });
6772
- L.observe(D.current);
6773
- const B = () => {
6772
+ L.observe(B.current);
6773
+ const P = () => {
6774
6774
  p.current && p.current.onResize && p.current.onResize();
6775
6775
  };
6776
- return window.addEventListener("resize", B), () => {
6777
- L.disconnect(), window.removeEventListener("resize", B);
6776
+ return window.addEventListener("resize", P), () => {
6777
+ L.disconnect(), window.removeEventListener("resize", P);
6778
6778
  };
6779
- }, [X]);
6780
- const v = E(async () => {
6779
+ }, [$]);
6780
+ const C = M(async () => {
6781
6781
  if (p.current && p.current.audioCtx)
6782
6782
  try {
6783
6783
  (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6784
6784
  } catch (L) {
6785
6785
  console.warn("Failed to resume audio context:", L);
6786
6786
  }
6787
- }, []), w = E(async (L, B = {}) => {
6788
- if (p.current && X)
6787
+ }, []), D = M(async (L, P = {}) => {
6788
+ if (p.current && $)
6789
6789
  try {
6790
- R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: B }, P.current = { remainingText: null, originalText: null, options: null }, J(!1), T.current = !1, await v();
6791
- const G = {
6792
- ...B,
6793
- lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
6790
+ R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: P }, F.current = { remainingText: null, originalText: null, options: null };
6791
+ const V = /[!\.\?\n\p{Extended_Pictographic}]/ug, Q = L.split(V).map((O) => O.trim()).filter((O) => O.length > 0);
6792
+ J.current = Q, ye.current = 0, me(!1), T.current = !1, await C();
6793
+ const ae = {
6794
+ ...P,
6795
+ lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
6794
6796
  };
6795
- if (B.onSpeechEnd && p.current) {
6796
- const M = p.current;
6797
- let W = null, ae = 0;
6798
- const ke = 1200;
6799
- let xe = !1;
6800
- W = setInterval(() => {
6801
- if (ae++, T.current)
6797
+ if (P.onSpeechEnd && p.current) {
6798
+ const O = p.current;
6799
+ let oe = null, Ie = 0;
6800
+ const xe = 1200;
6801
+ let ue = !1;
6802
+ oe = setInterval(() => {
6803
+ if (Ie++, T.current)
6802
6804
  return;
6803
- if (ae > ke) {
6804
- if (W && (clearInterval(W), W = null, R.current = null), !xe && !T.current) {
6805
- xe = !0;
6805
+ if (Ie > xe) {
6806
+ if (oe && (clearInterval(oe), oe = null, R.current = null), !ue && !T.current) {
6807
+ ue = !0;
6806
6808
  try {
6807
- B.onSpeechEnd();
6808
- } catch (we) {
6809
- console.error("Error in onSpeechEnd callback (timeout):", we);
6809
+ P.onSpeechEnd();
6810
+ } catch (Te) {
6811
+ console.error("Error in onSpeechEnd callback (timeout):", Te);
6810
6812
  }
6811
6813
  }
6812
6814
  return;
6813
6815
  }
6814
- const Oe = !M.speechQueue || M.speechQueue.length === 0, Ne = !M.audioPlaylist || M.audioPlaylist.length === 0;
6815
- M && M.isSpeaking === !1 && Oe && Ne && M.isAudioPlaying === !1 && !xe && !T.current && setTimeout(() => {
6816
- if (M && !T.current && M.isSpeaking === !1 && (!M.speechQueue || M.speechQueue.length === 0) && (!M.audioPlaylist || M.audioPlaylist.length === 0) && M.isAudioPlaying === !1 && !xe && !T.current) {
6817
- xe = !0, W && (clearInterval(W), W = null, R.current = null);
6816
+ const re = !O.speechQueue || O.speechQueue.length === 0, Le = !O.audioPlaylist || O.audioPlaylist.length === 0;
6817
+ O && O.isSpeaking === !1 && re && Le && O.isAudioPlaying === !1 && !ue && !T.current && setTimeout(() => {
6818
+ if (O && !T.current && O.isSpeaking === !1 && (!O.speechQueue || O.speechQueue.length === 0) && (!O.audioPlaylist || O.audioPlaylist.length === 0) && O.isAudioPlaying === !1 && !ue && !T.current) {
6819
+ ue = !0, oe && (clearInterval(oe), oe = null, R.current = null);
6818
6820
  try {
6819
- B.onSpeechEnd();
6820
- } catch (Ue) {
6821
- console.error("Error in onSpeechEnd callback:", Ue);
6821
+ P.onSpeechEnd();
6822
+ } catch (Ze) {
6823
+ console.error("Error in onSpeechEnd callback:", Ze);
6822
6824
  }
6823
6825
  }
6824
6826
  }, 100);
6825
- }, 100), R.current = W;
6827
+ }, 100), R.current = oe;
6826
6828
  }
6827
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, G)) : setTimeout(async () => {
6828
- await v(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, G));
6829
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae)) : setTimeout(async () => {
6830
+ await C(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae));
6829
6831
  }, 100);
6830
- } catch (G) {
6831
- console.error("Error speaking text:", G), N(G.message || "Failed to speak text");
6832
+ } catch (V) {
6833
+ console.error("Error speaking text:", V), Z(V.message || "Failed to speak text");
6832
6834
  }
6833
- }, [X, v, pe.lipsyncLang]), H = E(() => {
6834
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, J(!1));
6835
- }, []), U = E(() => {
6835
+ }, [$, C, b.lipsyncLang]), te = M(() => {
6836
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, me(!1));
6837
+ }, []), q = M(() => {
6836
6838
  if (p.current && p.current.pauseSpeaking) {
6837
6839
  const L = p.current;
6838
6840
  if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
6839
6841
  R.current && (clearInterval(R.current), R.current = null);
6840
- let G = "";
6841
- if (L.speechQueue && L.speechQueue.length > 0 && z.current) {
6842
- const M = L.speechQueue.filter((W) => W && W.text && Array.isArray(W.text) && W.text.length > 0).map((W) => W.text.map((ae) => ae.word || "").filter((ae) => ae.length > 0).join(" ")).filter((W) => W.length > 0).join(" ");
6843
- M && M.trim() && (G = M.trim());
6842
+ let V = "";
6843
+ if (z.current && J.current.length > 0) {
6844
+ const Q = J.current.length, ae = L.speechQueue ? L.speechQueue.filter((xe) => xe && xe.text && Array.isArray(xe.text) && xe.text.length > 0).length : 0, O = L.audioPlaylist && L.audioPlaylist.length > 0, oe = ae + (O ? 1 : 0), Ie = Q - oe;
6845
+ if (oe > 0 && Ie < Q && (V = J.current.slice(Ie).join(". ").trim(), !V && ae > 0 && L.speechQueue)) {
6846
+ const ue = L.speechQueue.filter((re) => re && re.text && Array.isArray(re.text) && re.text.length > 0).map((re) => re.text.map((Le) => Le.word || "").filter((Le) => Le.length > 0).join(" ")).filter((re) => re.length > 0).join(" ");
6847
+ ue && ue.trim() && (V = ue.trim());
6848
+ }
6844
6849
  }
6845
- z.current && (P.current = {
6846
- remainingText: G || null,
6850
+ z.current && (F.current = {
6851
+ remainingText: V || null,
6847
6852
  originalText: z.current.text,
6848
6853
  options: z.current.options
6849
- }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, J(!0);
6854
+ }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, me(!0);
6850
6855
  }
6851
6856
  }
6852
- }, []), te = E(async () => {
6853
- if (!p.current || !Q)
6857
+ }, []), j = M(async () => {
6858
+ if (!p.current || !de)
6854
6859
  return;
6855
- let L = "", B = {};
6856
- if (P.current && P.current.remainingText)
6857
- L = P.current.remainingText, B = P.current.options || {}, P.current = { remainingText: null, originalText: null, options: null };
6860
+ let L = "", P = {};
6861
+ if (F.current && F.current.remainingText)
6862
+ L = F.current.remainingText, P = F.current.options || {}, F.current = { remainingText: null, originalText: null, options: null };
6858
6863
  else if (z.current && z.current.text)
6859
- L = z.current.text, B = z.current.options || {};
6864
+ L = z.current.text, P = z.current.options || {};
6860
6865
  else {
6861
- console.warn("Resume called but no paused speech found"), J(!1), T.current = !1;
6866
+ console.warn("Resume called but no paused speech found"), me(!1), T.current = !1;
6862
6867
  return;
6863
6868
  }
6864
- J(!1), T.current = !1, await v();
6865
- const G = {
6866
- ...B,
6867
- lipsyncLang: B.lipsyncLang || pe.lipsyncLang || "en"
6869
+ me(!1), T.current = !1, await C();
6870
+ const V = {
6871
+ ...P,
6872
+ lipsyncLang: P.lipsyncLang || b.lipsyncLang || "en"
6868
6873
  };
6869
6874
  try {
6870
- await w(L, G);
6871
- } catch (M) {
6872
- console.error("Error resuming speech:", M), J(!1), T.current = !1;
6875
+ await D(L, V);
6876
+ } catch (Q) {
6877
+ console.error("Error resuming speech:", Q), me(!1), T.current = !1;
6873
6878
  }
6874
- }, [v, Q, w, pe]), q = E((L) => {
6879
+ }, [C, de, D, b]), we = M((L) => {
6875
6880
  p.current && p.current.setMood(L);
6876
- }, []), j = E((L) => {
6881
+ }, []), We = M((L) => {
6877
6882
  p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6878
- }, []), Ie = E((L, B = !1) => {
6883
+ }, []), Ve = M((L, P = !1) => {
6879
6884
  if (p.current && p.current.playAnimation) {
6880
6885
  if (x && x[L] && (L = x[L]), p.current.setShowFullAvatar)
6881
6886
  try {
6882
- p.current.setShowFullAvatar(C.current);
6883
- } catch (M) {
6884
- console.warn("Error setting full body mode:", M);
6887
+ p.current.setShowFullAvatar(H.current);
6888
+ } catch (Q) {
6889
+ console.warn("Error setting full body mode:", Q);
6885
6890
  }
6886
6891
  if (L.includes("."))
6887
6892
  try {
6888
- p.current.playAnimation(L, null, 10, 0, 0.01, B);
6889
- } catch (M) {
6890
- console.warn(`Failed to play ${L}:`, M);
6893
+ p.current.playAnimation(L, null, 10, 0, 0.01, P);
6894
+ } catch (Q) {
6895
+ console.warn(`Failed to play ${L}:`, Q);
6891
6896
  try {
6892
6897
  p.current.setBodyMovement("idle");
6893
- } catch (W) {
6894
- console.warn("Fallback animation also failed:", W);
6898
+ } catch (ae) {
6899
+ console.warn("Fallback animation also failed:", ae);
6895
6900
  }
6896
6901
  }
6897
6902
  else {
6898
- const M = [".fbx", ".glb", ".gltf"];
6899
- let W = !1;
6900
- for (const ae of M)
6903
+ const Q = [".fbx", ".glb", ".gltf"];
6904
+ let ae = !1;
6905
+ for (const O of Q)
6901
6906
  try {
6902
- p.current.playAnimation(L + ae, null, 10, 0, 0.01, B), W = !0;
6907
+ p.current.playAnimation(L + O, null, 10, 0, 0.01, P), ae = !0;
6903
6908
  break;
6904
6909
  } catch {
6905
6910
  }
6906
- if (!W) {
6911
+ if (!ae) {
6907
6912
  console.warn("Animation not found:", L);
6908
6913
  try {
6909
6914
  p.current.setBodyMovement("idle");
6910
- } catch (ae) {
6911
- console.warn("Fallback animation also failed:", ae);
6915
+ } catch (O) {
6916
+ console.warn("Fallback animation also failed:", O);
6912
6917
  }
6913
6918
  }
6914
6919
  }
6915
6920
  }
6916
- }, [x]), De = E(() => {
6921
+ }, [x]), Ge = M(() => {
6917
6922
  p.current && p.current.onResize && p.current.onResize();
6918
6923
  }, []);
6919
- return Ae(I, () => ({
6920
- speakText: w,
6921
- stopSpeaking: H,
6922
- pauseSpeaking: U,
6923
- resumeSpeaking: te,
6924
- resumeAudioContext: v,
6925
- setMood: q,
6926
- setTimingAdjustment: j,
6927
- playAnimation: Ie,
6928
- isReady: X,
6929
- isPaused: Q,
6924
+ return Ce(I, () => ({
6925
+ speakText: D,
6926
+ stopSpeaking: te,
6927
+ pauseSpeaking: q,
6928
+ resumeSpeaking: j,
6929
+ resumeAudioContext: C,
6930
+ setMood: we,
6931
+ setTimingAdjustment: We,
6932
+ playAnimation: Ve,
6933
+ isReady: $,
6934
+ isPaused: de,
6930
6935
  talkingHead: p.current,
6931
- handleResize: De,
6936
+ handleResize: Ge,
6932
6937
  setBodyMovement: (L) => {
6933
6938
  if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
6934
6939
  try {
6935
- p.current.setShowFullAvatar(C.current), p.current.setBodyMovement(L);
6936
- } catch (B) {
6937
- console.warn("Error setting body movement:", B);
6940
+ p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(L);
6941
+ } catch (P) {
6942
+ console.warn("Error setting body movement:", P);
6938
6943
  }
6939
6944
  },
6940
6945
  setMovementIntensity: (L) => p.current?.setMovementIntensity(L),
6941
6946
  playRandomDance: () => {
6942
6947
  if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
6943
6948
  try {
6944
- p.current.setShowFullAvatar(C.current), p.current.playRandomDance();
6949
+ p.current.setShowFullAvatar(H.current), p.current.playRandomDance();
6945
6950
  } catch (L) {
6946
6951
  console.warn("Error playing random dance:", L);
6947
6952
  }
@@ -6949,15 +6954,15 @@ const Pe = Le(({
6949
6954
  playReaction: (L) => {
6950
6955
  if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
6951
6956
  try {
6952
- p.current.setShowFullAvatar(C.current), p.current.playReaction(L);
6953
- } catch (B) {
6954
- console.warn("Error playing reaction:", B);
6957
+ p.current.setShowFullAvatar(H.current), p.current.playReaction(L);
6958
+ } catch (P) {
6959
+ console.warn("Error playing reaction:", P);
6955
6960
  }
6956
6961
  },
6957
6962
  playCelebration: () => {
6958
6963
  if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
6959
6964
  try {
6960
- p.current.setShowFullAvatar(C.current), p.current.playCelebration();
6965
+ p.current.setShowFullAvatar(H.current), p.current.playCelebration();
6961
6966
  } catch (L) {
6962
6967
  console.warn("Error playing celebration:", L);
6963
6968
  }
@@ -6965,9 +6970,9 @@ const Pe = Le(({
6965
6970
  setShowFullAvatar: (L) => {
6966
6971
  if (p.current && p.current.setShowFullAvatar)
6967
6972
  try {
6968
- C.current = L, p.current.setShowFullAvatar(L);
6969
- } catch (B) {
6970
- console.warn("Error setting showFullAvatar:", B);
6973
+ H.current = L, p.current.setShowFullAvatar(L);
6974
+ } catch (P) {
6975
+ console.warn("Error setting showFullAvatar:", P);
6971
6976
  }
6972
6977
  },
6973
6978
  lockAvatarPosition: () => {
@@ -6986,7 +6991,7 @@ const Pe = Le(({
6986
6991
  console.warn("Error unlocking avatar position:", L);
6987
6992
  }
6988
6993
  }
6989
- })), /* @__PURE__ */ Ee(
6994
+ })), /* @__PURE__ */ De(
6990
6995
  "div",
6991
6996
  {
6992
6997
  className: `talking-head-avatar ${g}`,
@@ -6997,10 +7002,10 @@ const Pe = Le(({
6997
7002
  ...y
6998
7003
  },
6999
7004
  children: [
7000
- /* @__PURE__ */ de(
7005
+ /* @__PURE__ */ ge(
7001
7006
  "div",
7002
7007
  {
7003
- ref: D,
7008
+ ref: B,
7004
7009
  className: "talking-head-viewer",
7005
7010
  style: {
7006
7011
  width: "100%",
@@ -7009,7 +7014,7 @@ const Pe = Le(({
7009
7014
  }
7010
7015
  }
7011
7016
  ),
7012
- ie && /* @__PURE__ */ de("div", { className: "loading-overlay", style: {
7017
+ S && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
7013
7018
  position: "absolute",
7014
7019
  top: "50%",
7015
7020
  left: "50%",
@@ -7018,7 +7023,7 @@ const Pe = Le(({
7018
7023
  fontSize: "18px",
7019
7024
  zIndex: 10
7020
7025
  }, children: "Loading avatar..." }),
7021
- S && /* @__PURE__ */ de("div", { className: "error-overlay", style: {
7026
+ Y && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7022
7027
  position: "absolute",
7023
7028
  top: "50%",
7024
7029
  left: "50%",
@@ -7029,14 +7034,14 @@ const Pe = Le(({
7029
7034
  zIndex: 10,
7030
7035
  padding: "20px",
7031
7036
  borderRadius: "8px"
7032
- }, children: S })
7037
+ }, children: Y })
7033
7038
  ]
7034
7039
  }
7035
7040
  );
7036
7041
  });
7037
- Pe.displayName = "TalkingHeadAvatar";
7038
- const ut = Le(({
7039
- text: O = "Hello! I'm a talking avatar. How are you today?",
7042
+ Ne.displayName = "TalkingHeadAvatar";
7043
+ const pt = ze(({
7044
+ text: U = "Hello! I'm a talking avatar. How are you today?",
7040
7045
  onLoading: t = () => {
7041
7046
  },
7042
7047
  onError: e = () => {
@@ -7047,7 +7052,7 @@ const ut = Le(({
7047
7052
  style: s = {},
7048
7053
  avatarConfig: o = {}
7049
7054
  }, l) => {
7050
- const u = Z(null), a = Z(null), [h, r] = ge(!0), [c, d] = ge(null), [g, y] = ge(!1), x = Se(), I = o.ttsService || x.service, D = I === "browser" ? {
7055
+ const u = N(null), r = N(null), [h, a] = be(!0), [c, d] = be(null), [g, y] = be(!1), x = He(), I = o.ttsService || x.service, B = I === "browser" ? {
7051
7056
  endpoint: "",
7052
7057
  apiKey: null,
7053
7058
  defaultVoice: "Google US English"
@@ -7063,7 +7068,7 @@ const ut = Le(({
7063
7068
  body: "F",
7064
7069
  avatarMood: "neutral",
7065
7070
  ttsLang: I === "browser" ? "en-US" : "en",
7066
- ttsVoice: o.ttsVoice || D.defaultVoice,
7071
+ ttsVoice: o.ttsVoice || B.defaultVoice,
7067
7072
  lipsyncLang: "en",
7068
7073
  // English lip-sync
7069
7074
  showFullAvatar: !0,
@@ -7071,176 +7076,176 @@ const ut = Le(({
7071
7076
  bodyMovement: "idle",
7072
7077
  movementIntensity: 0.5,
7073
7078
  ...o
7074
- }, C = {
7075
- ttsEndpoint: D.endpoint,
7076
- ttsApikey: D.apiKey,
7079
+ }, H = {
7080
+ ttsEndpoint: B.endpoint,
7081
+ ttsApikey: B.apiKey,
7077
7082
  ttsService: I,
7078
7083
  lipsyncModules: ["en"],
7079
7084
  cameraView: "upper"
7080
- }, z = E(async () => {
7081
- if (!(!u.current || a.current))
7085
+ }, z = M(async () => {
7086
+ if (!(!u.current || r.current))
7082
7087
  try {
7083
- if (r(!0), d(null), a.current = new Fe(u.current, C), await a.current.showAvatar(p, (X) => {
7084
- if (X.lengthComputable) {
7085
- const Y = Math.min(100, Math.round(X.loaded / X.total * 100));
7086
- t(Y);
7088
+ if (a(!0), d(null), r.current = new Oe(u.current, H), await r.current.showAvatar(p, (Y) => {
7089
+ if (Y.lengthComputable) {
7090
+ const Z = Math.min(100, Math.round(Y.loaded / Y.total * 100));
7091
+ t(Z);
7087
7092
  }
7088
- }), a.current.morphs && a.current.morphs.length > 0) {
7089
- const X = a.current.morphs[0].morphTargetDictionary;
7090
- console.log("Available morph targets:", Object.keys(X));
7091
- const Y = Object.keys(X).filter((Q) => Q.startsWith("viseme_"));
7092
- console.log("Viseme morph targets found:", Y), Y.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7093
+ }), r.current.morphs && r.current.morphs.length > 0) {
7094
+ const Y = r.current.morphs[0].morphTargetDictionary;
7095
+ console.log("Available morph targets:", Object.keys(Y));
7096
+ const Z = Object.keys(Y).filter(($) => $.startsWith("viseme_"));
7097
+ console.log("Viseme morph targets found:", Z), Z.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7093
7098
  }
7094
- if (await new Promise((X) => {
7095
- const Y = () => {
7096
- a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), X()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Y, 100));
7099
+ if (await new Promise((Y) => {
7100
+ const Z = () => {
7101
+ r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), Y()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
7097
7102
  };
7098
- Y();
7099
- }), a.current && a.current.setShowFullAvatar)
7103
+ Z();
7104
+ }), r.current && r.current.setShowFullAvatar)
7100
7105
  try {
7101
- a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7102
- } catch (X) {
7103
- console.warn("Error setting full body mode on initialization:", X);
7106
+ r.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7107
+ } catch (Y) {
7108
+ console.warn("Error setting full body mode on initialization:", Y);
7104
7109
  }
7105
- r(!1), y(!0), n(a.current);
7106
- const N = () => {
7107
- document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
7110
+ a(!1), y(!0), n(r.current);
7111
+ const W = () => {
7112
+ document.visibilityState === "visible" ? r.current?.start() : r.current?.stop();
7108
7113
  };
7109
- return document.addEventListener("visibilitychange", N), () => {
7110
- document.removeEventListener("visibilitychange", N);
7114
+ return document.addEventListener("visibilitychange", W), () => {
7115
+ document.removeEventListener("visibilitychange", W);
7111
7116
  };
7112
7117
  } catch (S) {
7113
- console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
7118
+ console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), a(!1), e(S);
7114
7119
  }
7115
7120
  }, []);
7116
- ye(() => (z(), () => {
7117
- a.current && (a.current.stop(), a.current.dispose(), a.current = null);
7121
+ Re(() => (z(), () => {
7122
+ r.current && (r.current.stop(), r.current.dispose(), r.current = null);
7118
7123
  }), [z]);
7119
- const R = E((S) => {
7120
- if (a.current && g)
7124
+ const R = M((S) => {
7125
+ if (r.current && g)
7121
7126
  try {
7122
- console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", a.current), a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7123
- a.current && a.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
7127
+ console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", r.current), r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), r.current.setSlowdownRate && (r.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), r.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7128
+ r.current && r.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), r.current.setSlowdownRate && (r.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), r.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
7124
7129
  }, 500));
7125
- } catch (N) {
7126
- console.error("Error speaking text:", N), d(N.message || "Failed to speak text");
7130
+ } catch (W) {
7131
+ console.error("Error speaking text:", W), d(W.message || "Failed to speak text");
7127
7132
  }
7128
7133
  else
7129
- console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
7130
- }, [g, p]), T = E(() => {
7131
- a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7132
- }, []), P = E((S) => {
7133
- a.current && a.current.setMood(S);
7134
- }, []), ie = E((S) => {
7135
- a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7136
- }, []), he = E((S, N = !1) => {
7137
- if (a.current && a.current.playAnimation) {
7138
- if (a.current.setShowFullAvatar)
7134
+ console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!r.current);
7135
+ }, [g, p]), T = M(() => {
7136
+ r.current && (r.current.stopSpeaking(), r.current.setSlowdownRate && (r.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7137
+ }, []), F = M((S) => {
7138
+ r.current && r.current.setMood(S);
7139
+ }, []), J = M((S) => {
7140
+ r.current && r.current.setSlowdownRate && (r.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7141
+ }, []), ye = M((S, W = !1) => {
7142
+ if (r.current && r.current.playAnimation) {
7143
+ if (r.current.setShowFullAvatar)
7139
7144
  try {
7140
- a.current.setShowFullAvatar(!0);
7141
- } catch (Y) {
7142
- console.warn("Error setting full body mode:", Y);
7145
+ r.current.setShowFullAvatar(!0);
7146
+ } catch (Z) {
7147
+ console.warn("Error setting full body mode:", Z);
7143
7148
  }
7144
7149
  if (S.includes("."))
7145
7150
  try {
7146
- a.current.playAnimation(S, null, 10, 0, 0.01, N), console.log("Playing animation:", S);
7147
- } catch (Y) {
7148
- console.log(`Failed to play ${S}:`, Y);
7151
+ r.current.playAnimation(S, null, 10, 0, 0.01, W), console.log("Playing animation:", S);
7152
+ } catch (Z) {
7153
+ console.log(`Failed to play ${S}:`, Z);
7149
7154
  try {
7150
- a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7151
- } catch (Q) {
7152
- console.warn("Fallback animation also failed:", Q);
7155
+ r.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7156
+ } catch ($) {
7157
+ console.warn("Fallback animation also failed:", $);
7153
7158
  }
7154
7159
  }
7155
7160
  else {
7156
- const Y = [".fbx", ".glb", ".gltf"];
7157
- let Q = !1;
7158
- for (const J of Y)
7161
+ const Z = [".fbx", ".glb", ".gltf"];
7162
+ let $ = !1;
7163
+ for (const se of Z)
7159
7164
  try {
7160
- a.current.playAnimation(S + J, null, 10, 0, 0.01, N), console.log("Playing animation:", S + J), Q = !0;
7165
+ r.current.playAnimation(S + se, null, 10, 0, 0.01, W), console.log("Playing animation:", S + se), $ = !0;
7161
7166
  break;
7162
7167
  } catch {
7163
- console.log(`Failed to play ${S}${J}, trying next format...`);
7168
+ console.log(`Failed to play ${S}${se}, trying next format...`);
7164
7169
  }
7165
- if (!Q) {
7170
+ if (!$) {
7166
7171
  console.warn("Animation system not available or animation not found:", S);
7167
7172
  try {
7168
- a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7169
- } catch (J) {
7170
- console.warn("Fallback animation also failed:", J);
7173
+ r.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7174
+ } catch (se) {
7175
+ console.warn("Fallback animation also failed:", se);
7171
7176
  }
7172
7177
  }
7173
7178
  }
7174
7179
  } else
7175
7180
  console.warn("Animation system not available or animation not found:", S);
7176
7181
  }, []);
7177
- return Ae(l, () => ({
7182
+ return Ce(l, () => ({
7178
7183
  speakText: R,
7179
7184
  stopSpeaking: T,
7180
- setMood: P,
7181
- setTimingAdjustment: ie,
7182
- playAnimation: he,
7185
+ setMood: F,
7186
+ setTimingAdjustment: J,
7187
+ playAnimation: ye,
7183
7188
  isReady: g,
7184
- talkingHead: a.current,
7189
+ talkingHead: r.current,
7185
7190
  setBodyMovement: (S) => {
7186
- if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
7191
+ if (r.current && r.current.setShowFullAvatar && r.current.setBodyMovement)
7187
7192
  try {
7188
- a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7189
- } catch (N) {
7190
- console.warn("Error setting body movement:", N);
7193
+ r.current.setShowFullAvatar(!0), r.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7194
+ } catch (W) {
7195
+ console.warn("Error setting body movement:", W);
7191
7196
  }
7192
7197
  },
7193
- setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
7198
+ setMovementIntensity: (S) => r.current?.setMovementIntensity(S),
7194
7199
  playRandomDance: () => {
7195
- if (a.current && a.current.setShowFullAvatar && a.current.playRandomDance)
7200
+ if (r.current && r.current.setShowFullAvatar && r.current.playRandomDance)
7196
7201
  try {
7197
- a.current.setShowFullAvatar(!0), a.current.playRandomDance(), console.log("Random dance played with full body mode");
7202
+ r.current.setShowFullAvatar(!0), r.current.playRandomDance(), console.log("Random dance played with full body mode");
7198
7203
  } catch (S) {
7199
7204
  console.warn("Error playing random dance:", S);
7200
7205
  }
7201
7206
  },
7202
7207
  playReaction: (S) => {
7203
- if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
7208
+ if (r.current && r.current.setShowFullAvatar && r.current.playReaction)
7204
7209
  try {
7205
- a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7206
- } catch (N) {
7207
- console.warn("Error playing reaction:", N);
7210
+ r.current.setShowFullAvatar(!0), r.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7211
+ } catch (W) {
7212
+ console.warn("Error playing reaction:", W);
7208
7213
  }
7209
7214
  },
7210
7215
  playCelebration: () => {
7211
- if (a.current && a.current.setShowFullAvatar && a.current.playCelebration)
7216
+ if (r.current && r.current.setShowFullAvatar && r.current.playCelebration)
7212
7217
  try {
7213
- a.current.setShowFullAvatar(!0), a.current.playCelebration(), console.log("Celebration played with full body mode");
7218
+ r.current.setShowFullAvatar(!0), r.current.playCelebration(), console.log("Celebration played with full body mode");
7214
7219
  } catch (S) {
7215
7220
  console.warn("Error playing celebration:", S);
7216
7221
  }
7217
7222
  },
7218
7223
  setShowFullAvatar: (S) => {
7219
- if (a.current && a.current.setShowFullAvatar)
7224
+ if (r.current && r.current.setShowFullAvatar)
7220
7225
  try {
7221
- a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7222
- } catch (N) {
7223
- console.warn("Error setting showFullAvatar:", N);
7226
+ r.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7227
+ } catch (W) {
7228
+ console.warn("Error setting showFullAvatar:", W);
7224
7229
  }
7225
7230
  },
7226
7231
  lockAvatarPosition: () => {
7227
- if (a.current && a.current.lockAvatarPosition)
7232
+ if (r.current && r.current.lockAvatarPosition)
7228
7233
  try {
7229
- a.current.lockAvatarPosition();
7234
+ r.current.lockAvatarPosition();
7230
7235
  } catch (S) {
7231
7236
  console.warn("Error locking avatar position:", S);
7232
7237
  }
7233
7238
  },
7234
7239
  unlockAvatarPosition: () => {
7235
- if (a.current && a.current.unlockAvatarPosition)
7240
+ if (r.current && r.current.unlockAvatarPosition)
7236
7241
  try {
7237
- a.current.unlockAvatarPosition();
7242
+ r.current.unlockAvatarPosition();
7238
7243
  } catch (S) {
7239
7244
  console.warn("Error unlocking avatar position:", S);
7240
7245
  }
7241
7246
  }
7242
- })), /* @__PURE__ */ Ee("div", { className: `talking-head-container ${i}`, style: s, children: [
7243
- /* @__PURE__ */ de(
7247
+ })), /* @__PURE__ */ De("div", { className: `talking-head-container ${i}`, style: s, children: [
7248
+ /* @__PURE__ */ ge(
7244
7249
  "div",
7245
7250
  {
7246
7251
  ref: u,
@@ -7252,7 +7257,7 @@ const ut = Le(({
7252
7257
  }
7253
7258
  }
7254
7259
  ),
7255
- h && /* @__PURE__ */ de("div", { className: "loading-overlay", style: {
7260
+ h && /* @__PURE__ */ ge("div", { className: "loading-overlay", style: {
7256
7261
  position: "absolute",
7257
7262
  top: "50%",
7258
7263
  left: "50%",
@@ -7261,7 +7266,7 @@ const ut = Le(({
7261
7266
  fontSize: "18px",
7262
7267
  zIndex: 10
7263
7268
  }, children: "Loading avatar..." }),
7264
- c && /* @__PURE__ */ de("div", { className: "error-overlay", style: {
7269
+ c && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7265
7270
  position: "absolute",
7266
7271
  top: "50%",
7267
7272
  left: "50%",
@@ -7275,9 +7280,9 @@ const ut = Le(({
7275
7280
  }, children: c })
7276
7281
  ] });
7277
7282
  });
7278
- ut.displayName = "TalkingHeadComponent";
7279
- const ct = Le(({
7280
- curriculumData: O = null,
7283
+ pt.displayName = "TalkingHeadComponent";
7284
+ const gt = ze(({
7285
+ curriculumData: U = null,
7281
7286
  avatarConfig: t = {},
7282
7287
  animations: e = {},
7283
7288
  onLessonStart: n = () => {
@@ -7291,8 +7296,8 @@ const ct = Le(({
7291
7296
  onCustomAction: l = () => {
7292
7297
  },
7293
7298
  autoStart: u = !1
7294
- }, a) => {
7295
- const h = Z(null), r = Z({
7299
+ }, r) => {
7300
+ const h = N(null), a = N({
7296
7301
  currentModuleIndex: 0,
7297
7302
  currentLessonIndex: 0,
7298
7303
  currentQuestionIndex: 0,
@@ -7302,18 +7307,18 @@ const ct = Le(({
7302
7307
  curriculumCompleted: !1,
7303
7308
  score: 0,
7304
7309
  totalQuestions: 0
7305
- }), c = Z({
7310
+ }), c = N({
7306
7311
  onLessonStart: n,
7307
7312
  onLessonComplete: i,
7308
7313
  onQuestionAnswer: s,
7309
7314
  onCurriculumComplete: o,
7310
7315
  onCustomAction: l
7311
- }), d = Z(null), g = Z(null), y = Z(null), x = Z(null), I = Z(null), D = Z(null), p = Z(null), C = Z(O?.curriculum || {
7316
+ }), d = N(null), g = N(null), y = N(null), x = N(null), I = N(null), B = N(null), p = N(null), H = N(U?.curriculum || {
7312
7317
  title: "Default Curriculum",
7313
7318
  description: "No curriculum data provided",
7314
7319
  language: "en",
7315
7320
  modules: []
7316
- }), z = Z({
7321
+ }), z = N({
7317
7322
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7318
7323
  avatarBody: t.avatarBody || "F",
7319
7324
  mood: t.mood || "happy",
@@ -7327,7 +7332,7 @@ const ct = Le(({
7327
7332
  animations: e,
7328
7333
  lipsyncLang: "en"
7329
7334
  });
7330
- ye(() => {
7335
+ Re(() => {
7331
7336
  c.current = {
7332
7337
  onLessonStart: n,
7333
7338
  onLessonComplete: i,
@@ -7335,8 +7340,8 @@ const ct = Le(({
7335
7340
  onCurriculumComplete: o,
7336
7341
  onCustomAction: l
7337
7342
  };
7338
- }, [n, i, s, o, l]), ye(() => {
7339
- C.current = O?.curriculum || {
7343
+ }, [n, i, s, o, l]), Re(() => {
7344
+ H.current = U?.curriculum || {
7340
7345
  title: "Default Curriculum",
7341
7346
  description: "No curriculum data provided",
7342
7347
  language: "en",
@@ -7355,23 +7360,23 @@ const ct = Le(({
7355
7360
  animations: e,
7356
7361
  lipsyncLang: "en"
7357
7362
  };
7358
- }, [O, t, e]);
7359
- const R = E(() => (C.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), T = E(() => R()?.questions[r.current.currentQuestionIndex], [R]), P = E((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), ie = E(() => {
7360
- r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
7361
- const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
7363
+ }, [U, t, e]);
7364
+ const R = M(() => (H.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), T = M(() => R()?.questions[a.current.currentQuestionIndex], [R]), F = M((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), J = M(() => {
7365
+ a.current.lessonCompleted = !0, a.current.isQuestionMode = !1;
7366
+ const b = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7362
7367
  let v = "Congratulations! You've completed this lesson";
7363
- if (r.current.totalQuestions > 0 ? v += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7364
- moduleIndex: r.current.currentModuleIndex,
7365
- lessonIndex: r.current.currentLessonIndex,
7366
- score: r.current.score,
7367
- totalQuestions: r.current.totalQuestions,
7368
+ if (a.current.totalQuestions > 0 ? v += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7369
+ moduleIndex: a.current.currentModuleIndex,
7370
+ lessonIndex: a.current.currentLessonIndex,
7371
+ score: a.current.score,
7372
+ totalQuestions: a.current.totalQuestions,
7368
7373
  percentage: b
7369
7374
  }), c.current.onCustomAction({
7370
7375
  type: "lessonComplete",
7371
- moduleIndex: r.current.currentModuleIndex,
7372
- lessonIndex: r.current.currentLessonIndex,
7373
- score: r.current.score,
7374
- totalQuestions: r.current.totalQuestions,
7376
+ moduleIndex: a.current.currentModuleIndex,
7377
+ lessonIndex: a.current.currentLessonIndex,
7378
+ score: a.current.score,
7379
+ totalQuestions: a.current.totalQuestions,
7375
7380
  percentage: b
7376
7381
  }), h.current) {
7377
7382
  if (h.current.setMood("happy"), e.lessonComplete)
@@ -7380,25 +7385,25 @@ const ct = Le(({
7380
7385
  } catch {
7381
7386
  h.current.playCelebration();
7382
7387
  }
7383
- const w = C.current || { modules: [] }, H = w.modules[r.current.currentModuleIndex], U = r.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = U || te, j = z.current || { lipsyncLang: "en" };
7388
+ const w = H.current || { modules: [] }, C = w.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = a.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = D || te, j = z.current || { lipsyncLang: "en" };
7384
7389
  h.current.speakText(v, {
7385
7390
  lipsyncLang: j.lipsyncLang,
7386
7391
  onSpeechEnd: () => {
7387
7392
  c.current.onCustomAction({
7388
7393
  type: "lessonCompleteFeedbackDone",
7389
- moduleIndex: r.current.currentModuleIndex,
7390
- lessonIndex: r.current.currentLessonIndex,
7391
- score: r.current.score,
7392
- totalQuestions: r.current.totalQuestions,
7394
+ moduleIndex: a.current.currentModuleIndex,
7395
+ lessonIndex: a.current.currentLessonIndex,
7396
+ score: a.current.score,
7397
+ totalQuestions: a.current.totalQuestions,
7393
7398
  percentage: b,
7394
7399
  hasNextLesson: q
7395
7400
  });
7396
7401
  }
7397
7402
  });
7398
7403
  }
7399
- }, [e.lessonComplete]), he = E(() => {
7400
- r.current.curriculumCompleted = !0;
7401
- const b = C.current || { modules: [] };
7404
+ }, [e.lessonComplete]), ye = M(() => {
7405
+ a.current.curriculumCompleted = !0;
7406
+ const b = H.current || { modules: [] };
7402
7407
  if (c.current.onCurriculumComplete({
7403
7408
  modules: b.modules.length,
7404
7409
  totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
@@ -7412,56 +7417,56 @@ const ct = Le(({
7412
7417
  const v = z.current || { lipsyncLang: "en" };
7413
7418
  h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
7414
7419
  }
7415
- }, [e.curriculumComplete]), S = E(() => {
7420
+ }, [e.curriculumComplete]), S = M(() => {
7416
7421
  const b = R();
7417
- r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = b?.questions?.length || 0, r.current.score = 0;
7422
+ a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = b?.questions?.length || 0, a.current.score = 0;
7418
7423
  const v = T();
7419
7424
  v && c.current.onCustomAction({
7420
7425
  type: "questionStart",
7421
- moduleIndex: r.current.currentModuleIndex,
7422
- lessonIndex: r.current.currentLessonIndex,
7423
- questionIndex: r.current.currentQuestionIndex,
7424
- totalQuestions: r.current.totalQuestions,
7426
+ moduleIndex: a.current.currentModuleIndex,
7427
+ lessonIndex: a.current.currentLessonIndex,
7428
+ questionIndex: a.current.currentQuestionIndex,
7429
+ totalQuestions: a.current.totalQuestions,
7425
7430
  question: v,
7426
- score: r.current.score
7431
+ score: a.current.score
7427
7432
  });
7428
7433
  const w = () => {
7429
7434
  if (!h.current || !v) return;
7430
7435
  if (h.current.setMood("happy"), e.questionStart)
7431
7436
  try {
7432
7437
  h.current.playAnimation(e.questionStart, !0);
7433
- } catch (U) {
7434
- console.warn("Failed to play questionStart animation:", U);
7438
+ } catch (D) {
7439
+ console.warn("Failed to play questionStart animation:", D);
7435
7440
  }
7436
- const H = z.current || { lipsyncLang: "en" };
7437
- v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: H.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: H.lipsyncLang });
7441
+ const C = z.current || { lipsyncLang: "en" };
7442
+ v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang });
7438
7443
  };
7439
7444
  if (h.current && h.current.isReady && v)
7440
7445
  w();
7441
7446
  else if (h.current && h.current.isReady) {
7442
- const H = z.current || { lipsyncLang: "en" };
7443
- h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: H.lipsyncLang });
7447
+ const C = z.current || { lipsyncLang: "en" };
7448
+ h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
7444
7449
  } else {
7445
- const H = setInterval(() => {
7446
- h.current && h.current.isReady && (clearInterval(H), v && w());
7450
+ const C = setInterval(() => {
7451
+ h.current && h.current.isReady && (clearInterval(C), v && w());
7447
7452
  }, 100);
7448
7453
  setTimeout(() => {
7449
- clearInterval(H);
7454
+ clearInterval(C);
7450
7455
  }, 5e3);
7451
7456
  }
7452
- }, [e.questionStart, R, T]), N = E(() => {
7457
+ }, [e.questionStart, R, T]), W = M(() => {
7453
7458
  const b = R();
7454
- if (r.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7455
- h.current && h.current.stopSpeaking && h.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
7459
+ if (a.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7460
+ h.current && h.current.stopSpeaking && h.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7456
7461
  const v = T();
7457
7462
  v && c.current.onCustomAction({
7458
7463
  type: "nextQuestion",
7459
- moduleIndex: r.current.currentModuleIndex,
7460
- lessonIndex: r.current.currentLessonIndex,
7461
- questionIndex: r.current.currentQuestionIndex,
7462
- totalQuestions: r.current.totalQuestions,
7464
+ moduleIndex: a.current.currentModuleIndex,
7465
+ lessonIndex: a.current.currentLessonIndex,
7466
+ questionIndex: a.current.currentQuestionIndex,
7467
+ totalQuestions: a.current.totalQuestions,
7463
7468
  question: v,
7464
- score: r.current.score
7469
+ score: a.current.score
7465
7470
  });
7466
7471
  const w = () => {
7467
7472
  if (!h.current || !v) return;
@@ -7471,124 +7476,130 @@ const ct = Le(({
7471
7476
  } catch (j) {
7472
7477
  console.warn("Failed to play nextQuestion animation:", j);
7473
7478
  }
7474
- const H = z.current || { lipsyncLang: "en" }, te = R()?.questions?.length || 0, q = r.current.currentQuestionIndex >= te - 1;
7479
+ const C = z.current || { lipsyncLang: "en" }, te = R()?.questions?.length || 0, q = a.current.currentQuestionIndex >= te - 1;
7475
7480
  if (v.type === "code_test") {
7476
7481
  const j = q ? `Great! Here's your final coding challenge: ${v.question}` : `Great! Now let's move on to your next coding challenge: ${v.question}`;
7477
7482
  h.current.speakText(j, {
7478
- lipsyncLang: H.lipsyncLang
7483
+ lipsyncLang: C.lipsyncLang
7479
7484
  });
7480
7485
  } else if (v.type === "multiple_choice") {
7481
7486
  const j = q ? `Alright! Here's your final question: ${v.question}` : `Alright! Here's your next question: ${v.question}`;
7482
7487
  h.current.speakText(j, {
7483
- lipsyncLang: H.lipsyncLang
7488
+ lipsyncLang: C.lipsyncLang
7484
7489
  });
7485
7490
  } else if (v.type === "true_false") {
7486
7491
  const j = q ? `Now let's try this final one: ${v.question}` : `Now let's try this one: ${v.question}`;
7487
7492
  h.current.speakText(j, {
7488
- lipsyncLang: H.lipsyncLang
7493
+ lipsyncLang: C.lipsyncLang
7489
7494
  });
7490
7495
  } else {
7491
7496
  const j = q ? `Here's your final question: ${v.question}` : `Here's the next question: ${v.question}`;
7492
7497
  h.current.speakText(j, {
7493
- lipsyncLang: H.lipsyncLang
7498
+ lipsyncLang: C.lipsyncLang
7494
7499
  });
7495
7500
  }
7496
7501
  };
7497
7502
  if (h.current && h.current.isReady && v)
7498
7503
  w();
7499
7504
  else if (v) {
7500
- const H = setInterval(() => {
7501
- h.current && h.current.isReady && (clearInterval(H), w());
7505
+ const C = setInterval(() => {
7506
+ h.current && h.current.isReady && (clearInterval(C), w());
7502
7507
  }, 100);
7503
7508
  setTimeout(() => {
7504
- clearInterval(H);
7509
+ clearInterval(C);
7505
7510
  }, 5e3);
7506
7511
  }
7507
7512
  } else
7508
7513
  c.current.onCustomAction({
7509
7514
  type: "allQuestionsComplete",
7510
- moduleIndex: r.current.currentModuleIndex,
7511
- lessonIndex: r.current.currentLessonIndex,
7512
- totalQuestions: r.current.totalQuestions,
7513
- score: r.current.score
7515
+ moduleIndex: a.current.currentModuleIndex,
7516
+ lessonIndex: a.current.currentLessonIndex,
7517
+ totalQuestions: a.current.totalQuestions,
7518
+ score: a.current.score
7514
7519
  });
7515
- }, [e.nextQuestion, R, T]), X = E(() => {
7516
- const b = C.current || { modules: [] }, v = b.modules[r.current.currentModuleIndex];
7517
- if (r.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7518
- r.current.currentLessonIndex += 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
7519
- const H = b.modules[r.current.currentModuleIndex], U = r.current.currentLessonIndex < (H?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = U || te;
7520
+ }, [e.nextQuestion, R, T]), Y = M(() => {
7521
+ const b = H.current || { modules: [] }, v = b.modules[a.current.currentModuleIndex];
7522
+ if (a.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7523
+ a.current.currentLessonIndex += 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7524
+ const C = b.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = D || te;
7520
7525
  c.current.onCustomAction({
7521
7526
  type: "lessonStart",
7522
- moduleIndex: r.current.currentModuleIndex,
7523
- lessonIndex: r.current.currentLessonIndex,
7527
+ moduleIndex: a.current.currentModuleIndex,
7528
+ lessonIndex: a.current.currentLessonIndex,
7524
7529
  hasNextLesson: q
7525
7530
  }), c.current.onLessonStart({
7526
- moduleIndex: r.current.currentModuleIndex,
7527
- lessonIndex: r.current.currentLessonIndex,
7531
+ moduleIndex: a.current.currentModuleIndex,
7532
+ lessonIndex: a.current.currentLessonIndex,
7528
7533
  lesson: R()
7529
7534
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7530
- } else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7531
- r.current.currentModuleIndex += 1, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0;
7532
- const U = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (U?.lessons?.length || 0) - 1, q = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, j = te || q;
7535
+ } else if (a.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7536
+ a.current.currentModuleIndex += 1, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7537
+ const D = b.modules[a.current.currentModuleIndex], te = a.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, q = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, j = te || q;
7533
7538
  c.current.onCustomAction({
7534
7539
  type: "lessonStart",
7535
- moduleIndex: r.current.currentModuleIndex,
7536
- lessonIndex: r.current.currentLessonIndex,
7540
+ moduleIndex: a.current.currentModuleIndex,
7541
+ lessonIndex: a.current.currentLessonIndex,
7537
7542
  hasNextLesson: j
7538
7543
  }), c.current.onLessonStart({
7539
- moduleIndex: r.current.currentModuleIndex,
7540
- lessonIndex: r.current.currentLessonIndex,
7544
+ moduleIndex: a.current.currentModuleIndex,
7545
+ lessonIndex: a.current.currentLessonIndex,
7541
7546
  lesson: R()
7542
7547
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7543
7548
  } else
7544
7549
  I.current && I.current();
7545
- }, []), Y = E(() => {
7550
+ }, []), Z = M(() => {
7546
7551
  const b = R();
7547
7552
  let v = null;
7548
7553
  if (b?.avatar_script && b?.body) {
7549
- const w = b.avatar_script.trim(), H = b.body.trim(), U = w.match(/[.!?]$/) ? " " : ". ";
7550
- v = `${w}${U}${H}`;
7554
+ const w = b.avatar_script.trim(), C = b.body.trim(), D = w.match(/[.!?]$/) ? " " : ". ";
7555
+ v = `${w}${D}${C}`;
7551
7556
  } else
7552
7557
  v = b?.avatar_script || b?.body || null;
7553
7558
  if (h.current && h.current.isReady && v) {
7554
- r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, h.current.setMood("happy");
7559
+ a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, h.current.setMood("happy");
7555
7560
  let w = !1;
7556
7561
  if (e.teaching)
7557
7562
  try {
7558
7563
  h.current.playAnimation(e.teaching, !0), w = !0;
7559
- } catch (U) {
7560
- console.warn("Failed to play teaching animation:", U);
7564
+ } catch (D) {
7565
+ console.warn("Failed to play teaching animation:", D);
7561
7566
  }
7562
7567
  w || h.current.setBodyMovement("gesturing");
7563
- const H = z.current || { lipsyncLang: "en" };
7568
+ const C = z.current || { lipsyncLang: "en" };
7564
7569
  c.current.onLessonStart({
7565
- moduleIndex: r.current.currentModuleIndex,
7566
- lessonIndex: r.current.currentLessonIndex,
7570
+ moduleIndex: a.current.currentModuleIndex,
7571
+ lessonIndex: a.current.currentLessonIndex,
7567
7572
  lesson: b
7568
7573
  }), c.current.onCustomAction({
7569
7574
  type: "teachingStart",
7570
- moduleIndex: r.current.currentModuleIndex,
7571
- lessonIndex: r.current.currentLessonIndex,
7575
+ moduleIndex: a.current.currentModuleIndex,
7576
+ lessonIndex: a.current.currentLessonIndex,
7572
7577
  lesson: b
7573
7578
  }), h.current.speakText(v, {
7574
- lipsyncLang: H.lipsyncLang,
7579
+ lipsyncLang: C.lipsyncLang,
7575
7580
  onSpeechEnd: () => {
7576
- r.current.isTeaching = !1, c.current.onCustomAction({
7581
+ a.current.isTeaching = !1, c.current.onCustomAction({
7577
7582
  type: "teachingComplete",
7578
- moduleIndex: r.current.currentModuleIndex,
7579
- lessonIndex: r.current.currentLessonIndex,
7583
+ moduleIndex: a.current.currentModuleIndex,
7584
+ lessonIndex: a.current.currentLessonIndex,
7580
7585
  lesson: b,
7581
7586
  hasQuestions: b.questions && b.questions.length > 0
7587
+ }), b?.code_example && c.current.onCustomAction({
7588
+ type: "codeExampleReady",
7589
+ moduleIndex: a.current.currentModuleIndex,
7590
+ lessonIndex: a.current.currentLessonIndex,
7591
+ lesson: b,
7592
+ codeExample: b.code_example
7582
7593
  });
7583
7594
  }
7584
7595
  });
7585
7596
  }
7586
- }, [e.teaching, R]), Q = E((b) => {
7587
- const v = T(), w = P(b, v);
7588
- if (w && (r.current.score += 1), c.current.onQuestionAnswer({
7589
- moduleIndex: r.current.currentModuleIndex,
7590
- lessonIndex: r.current.currentLessonIndex,
7591
- questionIndex: r.current.currentQuestionIndex,
7597
+ }, [e.teaching, R]), $ = M((b) => {
7598
+ const v = T(), w = F(b, v);
7599
+ if (w && (a.current.score += 1), c.current.onQuestionAnswer({
7600
+ moduleIndex: a.current.currentModuleIndex,
7601
+ lessonIndex: a.current.currentLessonIndex,
7602
+ questionIndex: a.current.currentQuestionIndex,
7592
7603
  answer: b,
7593
7604
  isCorrect: w,
7594
7605
  question: v
@@ -7601,21 +7612,21 @@ const ct = Le(({
7601
7612
  h.current.setBodyMovement("happy");
7602
7613
  }
7603
7614
  h.current.setBodyMovement("gesturing");
7604
- const U = R()?.questions?.length || 0;
7605
- r.current.currentQuestionIndex >= U - 1;
7615
+ const D = R()?.questions?.length || 0;
7616
+ a.current.currentQuestionIndex >= D - 1;
7606
7617
  const te = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
7607
7618
  h.current.speakText(te, {
7608
7619
  lipsyncLang: q.lipsyncLang,
7609
7620
  onSpeechEnd: () => {
7610
7621
  c.current.onCustomAction({
7611
7622
  type: "answerFeedbackComplete",
7612
- moduleIndex: r.current.currentModuleIndex,
7613
- lessonIndex: r.current.currentLessonIndex,
7614
- questionIndex: r.current.currentQuestionIndex,
7623
+ moduleIndex: a.current.currentModuleIndex,
7624
+ lessonIndex: a.current.currentLessonIndex,
7625
+ questionIndex: a.current.currentQuestionIndex,
7615
7626
  isCorrect: !0,
7616
- hasNextQuestion: r.current.currentQuestionIndex < U - 1,
7617
- score: r.current.score,
7618
- totalQuestions: r.current.totalQuestions
7627
+ hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7628
+ score: a.current.score,
7629
+ totalQuestions: a.current.totalQuestions
7619
7630
  });
7620
7631
  }
7621
7632
  });
@@ -7627,38 +7638,38 @@ const ct = Le(({
7627
7638
  h.current.setBodyMovement("idle");
7628
7639
  }
7629
7640
  h.current.setBodyMovement("gesturing");
7630
- const U = R()?.questions?.length || 0, te = r.current.currentQuestionIndex >= U - 1, q = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""}${te ? "" : " Let's move on to the next question."}`, j = z.current || { lipsyncLang: "en" };
7641
+ const D = R()?.questions?.length || 0, te = a.current.currentQuestionIndex >= D - 1, q = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""}${te ? "" : " Let's move on to the next question."}`, j = z.current || { lipsyncLang: "en" };
7631
7642
  h.current.speakText(q, {
7632
7643
  lipsyncLang: j.lipsyncLang,
7633
7644
  onSpeechEnd: () => {
7634
7645
  c.current.onCustomAction({
7635
7646
  type: "answerFeedbackComplete",
7636
- moduleIndex: r.current.currentModuleIndex,
7637
- lessonIndex: r.current.currentLessonIndex,
7638
- questionIndex: r.current.currentQuestionIndex,
7647
+ moduleIndex: a.current.currentModuleIndex,
7648
+ lessonIndex: a.current.currentLessonIndex,
7649
+ questionIndex: a.current.currentQuestionIndex,
7639
7650
  isCorrect: !1,
7640
- hasNextQuestion: r.current.currentQuestionIndex < U - 1,
7641
- score: r.current.score,
7642
- totalQuestions: r.current.totalQuestions
7651
+ hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7652
+ score: a.current.score,
7653
+ totalQuestions: a.current.totalQuestions
7643
7654
  });
7644
7655
  }
7645
7656
  });
7646
7657
  }
7647
7658
  else {
7648
- const U = R()?.questions?.length || 0;
7659
+ const D = R()?.questions?.length || 0;
7649
7660
  c.current.onCustomAction({
7650
7661
  type: "answerFeedbackComplete",
7651
- moduleIndex: r.current.currentModuleIndex,
7652
- lessonIndex: r.current.currentLessonIndex,
7653
- questionIndex: r.current.currentQuestionIndex,
7662
+ moduleIndex: a.current.currentModuleIndex,
7663
+ lessonIndex: a.current.currentLessonIndex,
7664
+ questionIndex: a.current.currentQuestionIndex,
7654
7665
  isCorrect: w,
7655
- hasNextQuestion: r.current.currentQuestionIndex < U - 1,
7656
- score: r.current.score,
7657
- totalQuestions: r.current.totalQuestions,
7666
+ hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7667
+ score: a.current.score,
7668
+ totalQuestions: a.current.totalQuestions,
7658
7669
  avatarNotReady: !0
7659
7670
  });
7660
7671
  }
7661
- }, [e.correct, e.incorrect, T, R, P]), J = E((b) => {
7672
+ }, [e.correct, e.incorrect, T, R, F]), se = M((b) => {
7662
7673
  const v = T();
7663
7674
  if (!b || typeof b != "object") {
7664
7675
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
@@ -7680,24 +7691,24 @@ const ct = Le(({
7680
7691
  };
7681
7692
  c.current.onCustomAction({
7682
7693
  type: "codeTestSubmitted",
7683
- moduleIndex: r.current.currentModuleIndex,
7684
- lessonIndex: r.current.currentLessonIndex,
7685
- questionIndex: r.current.currentQuestionIndex,
7694
+ moduleIndex: a.current.currentModuleIndex,
7695
+ lessonIndex: a.current.currentLessonIndex,
7696
+ questionIndex: a.current.currentQuestionIndex,
7686
7697
  testResult: w,
7687
7698
  question: v
7688
7699
  }), p.current && p.current(w);
7689
- }, [T, P]), oe = E(() => {
7690
- if (r.current.currentQuestionIndex > 0) {
7691
- r.current.currentQuestionIndex -= 1;
7700
+ }, [T, F]), de = M(() => {
7701
+ if (a.current.currentQuestionIndex > 0) {
7702
+ a.current.currentQuestionIndex -= 1;
7692
7703
  const b = T();
7693
7704
  b && c.current.onCustomAction({
7694
7705
  type: "questionStart",
7695
- moduleIndex: r.current.currentModuleIndex,
7696
- lessonIndex: r.current.currentLessonIndex,
7697
- questionIndex: r.current.currentQuestionIndex,
7698
- totalQuestions: r.current.totalQuestions,
7706
+ moduleIndex: a.current.currentModuleIndex,
7707
+ lessonIndex: a.current.currentLessonIndex,
7708
+ questionIndex: a.current.currentQuestionIndex,
7709
+ totalQuestions: a.current.totalQuestions,
7699
7710
  question: b,
7700
- score: r.current.score
7711
+ score: a.current.score
7701
7712
  });
7702
7713
  const v = () => {
7703
7714
  if (!h.current || !b) return;
@@ -7720,55 +7731,55 @@ const ct = Le(({
7720
7731
  }, 5e3);
7721
7732
  }
7722
7733
  }
7723
- }, [T]), me = E(() => {
7724
- const b = C.current || { modules: [] };
7725
- if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
7726
- r.current.currentLessonIndex -= 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
7734
+ }, [T]), me = M(() => {
7735
+ const b = H.current || { modules: [] };
7736
+ if (b.modules[a.current.currentModuleIndex], a.current.currentLessonIndex > 0)
7737
+ a.current.currentLessonIndex -= 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0, c.current.onCustomAction({
7727
7738
  type: "lessonStart",
7728
- moduleIndex: r.current.currentModuleIndex,
7729
- lessonIndex: r.current.currentLessonIndex
7739
+ moduleIndex: a.current.currentModuleIndex,
7740
+ lessonIndex: a.current.currentLessonIndex
7730
7741
  }), c.current.onLessonStart({
7731
- moduleIndex: r.current.currentModuleIndex,
7732
- lessonIndex: r.current.currentLessonIndex,
7742
+ moduleIndex: a.current.currentModuleIndex,
7743
+ lessonIndex: a.current.currentLessonIndex,
7733
7744
  lesson: R()
7734
7745
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7735
- else if (r.current.currentModuleIndex > 0) {
7736
- const H = b.modules[r.current.currentModuleIndex - 1];
7737
- r.current.currentModuleIndex -= 1, r.current.currentLessonIndex = (H?.lessons?.length || 1) - 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
7746
+ else if (a.current.currentModuleIndex > 0) {
7747
+ const C = b.modules[a.current.currentModuleIndex - 1];
7748
+ a.current.currentModuleIndex -= 1, a.current.currentLessonIndex = (C?.lessons?.length || 1) - 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0, c.current.onCustomAction({
7738
7749
  type: "lessonStart",
7739
- moduleIndex: r.current.currentModuleIndex,
7740
- lessonIndex: r.current.currentLessonIndex
7750
+ moduleIndex: a.current.currentModuleIndex,
7751
+ lessonIndex: a.current.currentLessonIndex
7741
7752
  }), c.current.onLessonStart({
7742
- moduleIndex: r.current.currentModuleIndex,
7743
- lessonIndex: r.current.currentLessonIndex,
7753
+ moduleIndex: a.current.currentModuleIndex,
7754
+ lessonIndex: a.current.currentLessonIndex,
7744
7755
  lesson: R()
7745
7756
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7746
7757
  }
7747
- }, [R]), se = E(() => {
7748
- r.current.currentModuleIndex = 0, r.current.currentLessonIndex = 0, r.current.currentQuestionIndex = 0, r.current.isTeaching = !1, r.current.isQuestionMode = !1, r.current.lessonCompleted = !1, r.current.curriculumCompleted = !1, r.current.score = 0, r.current.totalQuestions = 0;
7749
- }, []), pe = E((b) => {
7758
+ }, [R]), ie = M(() => {
7759
+ a.current.currentModuleIndex = 0, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.isTeaching = !1, a.current.isQuestionMode = !1, a.current.lessonCompleted = !1, a.current.curriculumCompleted = !1, a.current.score = 0, a.current.totalQuestions = 0;
7760
+ }, []), fe = M((b) => {
7750
7761
  console.log("Avatar is ready!", b);
7751
7762
  const v = R(), w = v?.avatar_script || v?.body;
7752
7763
  u && w && setTimeout(() => {
7753
7764
  d.current && d.current();
7754
7765
  }, 10);
7755
7766
  }, [u, R]);
7756
- We(() => {
7757
- d.current = Y, g.current = X, y.current = ie, x.current = N, I.current = he, D.current = S, p.current = Q;
7758
- }), Ae(a, () => ({
7767
+ Xe(() => {
7768
+ d.current = Z, g.current = Y, y.current = J, x.current = W, I.current = ye, B.current = S, p.current = $;
7769
+ }), Ce(r, () => ({
7759
7770
  // Curriculum control methods
7760
- startTeaching: Y,
7771
+ startTeaching: Z,
7761
7772
  startQuestions: S,
7762
- handleAnswerSelect: Q,
7763
- handleCodeTestResult: J,
7764
- nextQuestion: N,
7765
- previousQuestion: oe,
7766
- nextLesson: X,
7773
+ handleAnswerSelect: $,
7774
+ handleCodeTestResult: se,
7775
+ nextQuestion: W,
7776
+ previousQuestion: de,
7777
+ nextLesson: Y,
7767
7778
  previousLesson: me,
7768
- completeLesson: ie,
7769
- completeCurriculum: he,
7770
- resetCurriculum: se,
7771
- getState: () => ({ ...r.current }),
7779
+ completeLesson: J,
7780
+ completeCurriculum: ye,
7781
+ resetCurriculum: ie,
7782
+ getState: () => ({ ...a.current }),
7772
7783
  getCurrentQuestion: () => T(),
7773
7784
  getCurrentLesson: () => R(),
7774
7785
  // Direct access to avatar ref (always returns current value)
@@ -7814,15 +7825,15 @@ const ct = Le(({
7814
7825
  c.current.onCustomAction({
7815
7826
  type: b,
7816
7827
  ...v,
7817
- state: { ...r.current }
7828
+ state: { ...a.current }
7818
7829
  });
7819
7830
  },
7820
7831
  // Responsive resize handler
7821
7832
  handleResize: () => h.current?.handleResize(),
7822
7833
  // Avatar readiness check (always returns current value)
7823
7834
  isAvatarReady: () => h.current?.isReady || !1
7824
- }), [Y, S, Q, J, N, X, ie, he, se, T, R]);
7825
- const ee = z.current || {
7835
+ }), [Z, S, $, se, W, Y, J, ye, ie, T, R]);
7836
+ const X = z.current || {
7826
7837
  avatarUrl: "/avatars/brunette.glb",
7827
7838
  avatarBody: "F",
7828
7839
  mood: "happy",
@@ -7835,23 +7846,23 @@ const ct = Le(({
7835
7846
  showFullAvatar: !1,
7836
7847
  animations: e
7837
7848
  };
7838
- return /* @__PURE__ */ de("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ de(
7839
- Pe,
7849
+ return /* @__PURE__ */ ge("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ge(
7850
+ Ne,
7840
7851
  {
7841
7852
  ref: h,
7842
- avatarUrl: ee.avatarUrl,
7843
- avatarBody: ee.avatarBody,
7844
- mood: ee.mood,
7845
- ttsLang: ee.ttsLang,
7846
- ttsService: ee.ttsService,
7847
- ttsVoice: ee.ttsVoice,
7848
- ttsApiKey: ee.ttsApiKey,
7849
- bodyMovement: ee.bodyMovement,
7850
- movementIntensity: ee.movementIntensity,
7851
- showFullAvatar: ee.showFullAvatar,
7853
+ avatarUrl: X.avatarUrl,
7854
+ avatarBody: X.avatarBody,
7855
+ mood: X.mood,
7856
+ ttsLang: X.ttsLang,
7857
+ ttsService: X.ttsService,
7858
+ ttsVoice: X.ttsVoice,
7859
+ ttsApiKey: X.ttsApiKey,
7860
+ bodyMovement: X.bodyMovement,
7861
+ movementIntensity: X.movementIntensity,
7862
+ showFullAvatar: X.showFullAvatar,
7852
7863
  cameraView: "upper",
7853
- animations: ee.animations,
7854
- onReady: pe,
7864
+ animations: X.animations,
7865
+ onReady: fe,
7855
7866
  onLoading: () => {
7856
7867
  },
7857
7868
  onError: (b) => {
@@ -7860,8 +7871,8 @@ const ct = Le(({
7860
7871
  }
7861
7872
  ) });
7862
7873
  });
7863
- ct.displayName = "CurriculumLearning";
7864
- const Be = {
7874
+ gt.displayName = "CurriculumLearning";
7875
+ const Ue = {
7865
7876
  // Code-based dance animations (no FBX required)
7866
7877
  dance: {
7867
7878
  name: "dance",
@@ -7964,14 +7975,14 @@ const Be = {
7964
7975
  duration: 5e3,
7965
7976
  description: "Excited, energetic movement"
7966
7977
  }
7967
- }, It = (O) => Be[O] || null, Lt = (O) => Be.hasOwnProperty(O);
7978
+ }, kt = (U) => Ue[U] || null, wt = (U) => Ue.hasOwnProperty(U);
7968
7979
  export {
7969
- ct as CurriculumLearning,
7970
- Pe as TalkingHeadAvatar,
7971
- ut as TalkingHeadComponent,
7972
- Be as animations,
7973
- Se as getActiveTTSConfig,
7974
- It as getAnimation,
7975
- Rt as getVoiceOptions,
7976
- Lt as hasAnimation
7980
+ gt as CurriculumLearning,
7981
+ Ne as TalkingHeadAvatar,
7982
+ pt as TalkingHeadComponent,
7983
+ Ue as animations,
7984
+ He as getActiveTTSConfig,
7985
+ kt as getAnimation,
7986
+ St as getVoiceOptions,
7987
+ wt as hasAnimation
7977
7988
  };