@sage-rsc/talking-head-react 1.7.5 → 1.7.7

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 Se, jsx as $ } from "react/jsx-runtime";
2
- import { forwardRef as Xe, useRef as W, useState as ae, useEffect as xe, useCallback as N, useImperativeHandle as je, useLayoutEffect as st } from "react";
3
- import * as x from "three";
4
- import { OrbitControls as rt } from "three/addons/controls/OrbitControls.js";
5
- import { GLTFLoader as at } from "three/addons/loaders/GLTFLoader.js";
6
- import { DRACOLoader as lt } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as _e } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as ut } from "three/addons/environments/RoomEnvironment.js";
9
- import ct from "three/addons/libs/stats.module.js";
10
- let m, fe, Re;
11
- const z = [0, 0, 0, 0], B = new x.Vector3(), We = new x.Vector3(), he = new x.Vector3(), Ve = new x.Vector3();
12
- new x.Plane();
13
- new x.Ray();
14
- new x.Euler();
15
- const de = new x.Quaternion(), Ke = new x.Quaternion(), we = new x.Matrix4(), Ce = new x.Matrix4();
16
- new x.Vector3();
17
- const Ge = new x.Vector3(0, 0, 1), ht = new x.Vector3(1, 0, 0), dt = new x.Vector3(0, 1, 0), mt = new x.Vector3(0, 0, 1);
18
- class pt {
1
+ import { jsxs as we, jsx as J } from "react/jsx-runtime";
2
+ import { forwardRef as Ye, useRef as V, useState as le, useEffect as Re, useCallback as N, useImperativeHandle as Qe, useLayoutEffect as rt } from "react";
3
+ import * as b from "three";
4
+ import { OrbitControls as at } from "three/addons/controls/OrbitControls.js";
5
+ import { GLTFLoader as lt } from "three/addons/loaders/GLTFLoader.js";
6
+ import { DRACOLoader as ut } from "three/addons/loaders/DRACOLoader.js";
7
+ import { FBXLoader as Je } from "three/addons/loaders/FBXLoader.js";
8
+ import { RoomEnvironment as ct } from "three/addons/environments/RoomEnvironment.js";
9
+ import ht from "three/addons/libs/stats.module.js";
10
+ let p, be, Le;
11
+ const z = [0, 0, 0, 0], O = new b.Vector3(), Ge = new b.Vector3(), pe = new b.Vector3(), Ze = new b.Vector3();
12
+ new b.Plane();
13
+ new b.Ray();
14
+ new b.Euler();
15
+ const ge = new b.Quaternion(), $e = new b.Quaternion(), ze = new b.Matrix4(), He = new b.Matrix4();
16
+ new b.Vector3();
17
+ const Xe = new b.Vector3(0, 0, 1), dt = new b.Vector3(1, 0, 0), mt = new b.Vector3(0, 1, 0), pt = new b.Vector3(0, 0, 1);
18
+ class gt {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
21
21
  warmupMs: 2e3,
@@ -264,7 +264,7 @@ class pt {
264
264
  "pivot",
265
265
  "helper"
266
266
  ].forEach((n) => {
267
- m = this.getValue(t.name, n), m && (e[n] = m);
267
+ p = this.getValue(t.name, n), p && (e[n] = p);
268
268
  }), e;
269
269
  });
270
270
  }
@@ -279,7 +279,7 @@ class pt {
279
279
  this.armature.traverse((i) => {
280
280
  e.has(i) || (e.set(i, t), t++);
281
281
  }), this.data.sort((i, a) => e.get(i.bone) - e.get(a.bone)), this.data.forEach((i) => {
282
- m = this.dict[i.boneParent.name], m && (m.children || (m.children = []), m.children.push(i));
282
+ p = this.dict[i.boneParent.name], p && (p.children || (p.children = []), p.children.push(i));
283
283
  }), this.objectsUpdate = [];
284
284
  const n = /* @__PURE__ */ new WeakSet(), o = (i) => i.parent?.isBone ? [i, ...o(i.parent)] : [i], s = (i) => {
285
285
  o(i).forEach((c) => {
@@ -321,7 +321,7 @@ class pt {
321
321
  /// Bone's parent object
322
322
  vBasis: l.position.clone(),
323
323
  // Original local position
324
- vWorld: l.parent.getWorldPosition(B).clone(),
324
+ vWorld: l.parent.getWorldPosition(O).clone(),
325
325
  // World position, parent
326
326
  qBasis: l.parent.quaternion.clone(),
327
327
  // Original quaternion, parent
@@ -338,7 +338,7 @@ class pt {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- u.boneParent.matrixWorld.decompose(B, de, he), B.copy(Ge).applyQuaternion(de).setY(0).normalize(), de.premultiply(Ke.setFromUnitVectors(Ge, B).invert()).normalize(), u.qWorldInverseYaw = de.clone().normalize(), this.data.push(u), this.dict[c] = u;
341
+ u.boneParent.matrixWorld.decompose(O, ge, pe), O.copy(Xe).applyQuaternion(ge).setY(0).normalize(), ge.premultiply($e.setFromUnitVectors(Xe, O).invert()).normalize(), u.qWorldInverseYaw = ge.clone().normalize(), this.data.push(u), this.dict[c] = u;
342
342
  try {
343
343
  this.setValue(c, "type", s.type), this.setValue(c, "stiffness", s.stiffness), this.setValue(c, "damping", s.damping), this.setValue(c, "external", s.external), this.setValue(c, "limits", s.limits), this.setValue(c, "excludes", s.excludes), this.setValue(c, "deltaLocal", s.deltaLocal), this.setValue(c, "deltaWorld", s.deltaWorld), this.setValue(c, "pivot", s.pivot), this.setValue(c, "helper", s.helper);
344
344
  } catch (r) {
@@ -356,22 +356,22 @@ class pt {
356
356
  for (this.timerMs += t, t > 1e3 && (this.timerMs = 0), t /= 1e3, e = 0, o = this.objectsUpdate.length; e < o; e++)
357
357
  i = this.objectsUpdate[e], i.updateMatrix(), i.parent === null ? i.matrixWorld.copy(i.matrix) : i.matrixWorld.multiplyMatrices(i.parent.matrixWorld, i.matrix), i.matrixWorldNeedsUpdate = !1;
358
358
  for (e = 0, o = this.data.length; e < o; e++) {
359
- if (i = this.data[e], B.copy(i.vWorld), we.copy(i.boneParent.matrixWorld), Ce.copy(we).invert(), i.vWorld.setFromMatrixPosition(we), B.applyMatrix4(Ce), B.length() > 0.5 && (console.info("Info: Unrealistic jump of " + B.length().toFixed(2) + " meters."), B.setLength(0.5)), B.applyQuaternion(i.bone.quaternion), z[0] = B.x, z[1] = B.y, z[2] = -B.z, z[3] = B.length() / 3, i.children)
359
+ if (i = this.data[e], O.copy(i.vWorld), ze.copy(i.boneParent.matrixWorld), He.copy(ze).invert(), i.vWorld.setFromMatrixPosition(ze), O.applyMatrix4(He), O.length() > 0.5 && (console.info("Info: Unrealistic jump of " + O.length().toFixed(2) + " meters."), O.setLength(0.5)), O.applyQuaternion(i.bone.quaternion), z[0] = O.x, z[1] = O.y, z[2] = -O.z, z[3] = O.length() / 3, i.children)
360
360
  for (n = 0, s = i.children.length; n < s; n++)
361
- m = i.children[n], z[0] -= m.v[0] * t / 3, z[1] -= m.v[1] * t / 3, z[2] += m.v[2] * t / 3, z[3] -= m.v[3] * t / 3;
362
- if (m = this.opt.sensitivityFactor, z[0] *= i.ext * m, z[1] *= i.ext * m, z[2] *= i.ext * m, z[3] *= i.ext * m, i.isX && (m = z[0] / t, i.ea[0] = (m - i.ev[0]) / t, i.ev[0] = m, i.a[0] = -i.k[0] * i.p[0] - i.c[0] * i.v[0] - i.ea[0], i.p[0] += i.v[0] * t + i.a[0] * t * t / 2 + z[0], m = i.v[0] + i.a[0] * t / 2, m = -i.k[0] * i.p[0] - i.c[0] * m - i.ea[0], i.v[0] = i.v[0] + (m + i.a[0]) * t / 2), i.isY && (m = z[1] / t, i.ea[1] = (m - i.ev[1]) / t, i.ev[1] = m, i.a[1] = -i.k[1] * i.p[1] - i.c[1] * i.v[1] - i.ea[1], i.p[1] += i.v[1] * t + i.a[1] * t * t / 2 + z[1], m = i.v[1] + i.a[1] * t / 2, m = -i.k[1] * i.p[1] - i.c[1] * m - i.ea[1], i.v[1] = i.v[1] + (m + i.a[1]) * t / 2), i.isZ && (m = z[2] / t, i.ea[2] = (m - i.ev[2]) / t, i.ev[2] = m, i.a[2] = -i.k[2] * i.p[2] - i.c[2] * i.v[2] - i.ea[2], i.p[2] += i.v[2] * t + i.a[2] * t * t / 2 + z[2], m = i.v[2] + i.a[2] * t / 2, m = -i.k[2] * i.p[2] - i.c[2] * m - i.ea[2], i.v[2] = i.v[2] + (m + i.a[2]) * t / 2), i.isT && (m = z[3] / t, i.ea[3] = (m - i.ev[3]) / t, i.ev[3] = m, i.a[3] = -i.k[3] * i.p[3] - i.c[3] * i.v[3] - i.ea[3], i.p[3] += i.v[3] * t + i.a[3] * t * t / 2 + z[3], m = i.v[3] + i.a[3] * t / 2, m = -i.k[3] * i.p[3] - i.c[3] * m - i.ea[3], i.v[3] = i.v[3] + (m + i.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (i.v[0] *= 1e-4, i.p[0] *= 1e-4, i.v[1] *= 1e-4, i.p[1] *= 1e-4, i.v[2] *= 1e-4, i.p[2] *= 1e-4, i.v[3] *= 1e-4, i.p[3] *= 1e-4), z[0] = i.p[0], z[1] = i.p[1], z[2] = i.p[2], z[3] = i.p[3], m = this.opt.movementFactor, z[0] *= m, z[1] *= m, z[2] *= m, z[3] *= m, i.dl && (m = i.dl, z[0] += m[0], z[1] += m[1], z[2] += m[2]), i.dw && (m = i.dw, B.set(
361
+ p = i.children[n], z[0] -= p.v[0] * t / 3, z[1] -= p.v[1] * t / 3, z[2] += p.v[2] * t / 3, z[3] -= p.v[3] * t / 3;
362
+ if (p = this.opt.sensitivityFactor, z[0] *= i.ext * p, z[1] *= i.ext * p, z[2] *= i.ext * p, z[3] *= i.ext * p, i.isX && (p = z[0] / t, i.ea[0] = (p - i.ev[0]) / t, i.ev[0] = p, i.a[0] = -i.k[0] * i.p[0] - i.c[0] * i.v[0] - i.ea[0], i.p[0] += i.v[0] * t + i.a[0] * t * t / 2 + z[0], p = i.v[0] + i.a[0] * t / 2, p = -i.k[0] * i.p[0] - i.c[0] * p - i.ea[0], i.v[0] = i.v[0] + (p + i.a[0]) * t / 2), i.isY && (p = z[1] / t, i.ea[1] = (p - i.ev[1]) / t, i.ev[1] = p, i.a[1] = -i.k[1] * i.p[1] - i.c[1] * i.v[1] - i.ea[1], i.p[1] += i.v[1] * t + i.a[1] * t * t / 2 + z[1], p = i.v[1] + i.a[1] * t / 2, p = -i.k[1] * i.p[1] - i.c[1] * p - i.ea[1], i.v[1] = i.v[1] + (p + i.a[1]) * t / 2), i.isZ && (p = z[2] / t, i.ea[2] = (p - i.ev[2]) / t, i.ev[2] = p, i.a[2] = -i.k[2] * i.p[2] - i.c[2] * i.v[2] - i.ea[2], i.p[2] += i.v[2] * t + i.a[2] * t * t / 2 + z[2], p = i.v[2] + i.a[2] * t / 2, p = -i.k[2] * i.p[2] - i.c[2] * p - i.ea[2], i.v[2] = i.v[2] + (p + i.a[2]) * t / 2), i.isT && (p = z[3] / t, i.ea[3] = (p - i.ev[3]) / t, i.ev[3] = p, i.a[3] = -i.k[3] * i.p[3] - i.c[3] * i.v[3] - i.ea[3], i.p[3] += i.v[3] * t + i.a[3] * t * t / 2 + z[3], p = i.v[3] + i.a[3] * t / 2, p = -i.k[3] * i.p[3] - i.c[3] * p - i.ea[3], i.v[3] = i.v[3] + (p + i.a[3]) * t / 2), this.timerMs < this.opt.warmupMs && (i.v[0] *= 1e-4, i.p[0] *= 1e-4, i.v[1] *= 1e-4, i.p[1] *= 1e-4, i.v[2] *= 1e-4, i.p[2] *= 1e-4, i.v[3] *= 1e-4, i.p[3] *= 1e-4), z[0] = i.p[0], z[1] = i.p[1], z[2] = i.p[2], z[3] = i.p[3], p = this.opt.movementFactor, z[0] *= p, z[1] *= p, z[2] *= p, z[3] *= p, i.dl && (p = i.dl, z[0] += p[0], z[1] += p[1], z[2] += p[2]), i.dw && (p = i.dw, O.set(
363
363
  i.vBasis.x + z[0],
364
364
  i.vBasis.y + z[1],
365
365
  i.vBasis.z + z[2]
366
- ), B.applyMatrix4(we), B.x += m[0], B.y += m[1], B.z += m[2], B.applyMatrix4(Ce), z[0] += B.x - i.vBasis.x, z[1] += B.y - i.vBasis.y, z[2] += B.z - i.vBasis.z), i.limits && this.opt.isLimits && (m = i.limits, m[0] && (m[0][0] !== null && z[0] < m[0][0] && (z[0] = m[0][0]), m[0][1] !== null && z[0] > m[0][1] && (z[0] = m[0][1])), m[1] && (m[1][0] !== null && z[1] < m[1][0] && (z[1] = m[1][0]), m[1][1] !== null && z[1] > m[1][1] && (z[1] = m[1][1])), m[2] && (m[2][0] !== null && z[2] < m[2][0] && (z[2] = m[2][0]), m[2][1] !== null && z[2] > m[2][1] && (z[2] = m[2][1])), m[3] && (m[3][0] !== null && z[3] < m[3][0] && (z[3] = m[3][0]), m[3][1] !== null && z[3] > m[3][1] && (z[3] = m[3][1]))), i.isPoint)
366
+ ), O.applyMatrix4(ze), O.x += p[0], O.y += p[1], O.z += p[2], O.applyMatrix4(He), z[0] += O.x - i.vBasis.x, z[1] += O.y - i.vBasis.y, z[2] += O.z - i.vBasis.z), i.limits && this.opt.isLimits && (p = i.limits, p[0] && (p[0][0] !== null && z[0] < p[0][0] && (z[0] = p[0][0]), p[0][1] !== null && z[0] > p[0][1] && (z[0] = p[0][1])), p[1] && (p[1][0] !== null && z[1] < p[1][0] && (z[1] = p[1][0]), p[1][1] !== null && z[1] > p[1][1] && (z[1] = p[1][1])), p[2] && (p[2][0] !== null && z[2] < p[2][0] && (z[2] = p[2][0]), p[2][1] !== null && z[2] > p[2][1] && (z[2] = p[2][1])), p[3] && (p[3][0] !== null && z[3] < p[3][0] && (z[3] = p[3][0]), p[3][1] !== null && z[3] > p[3][1] && (z[3] = p[3][1]))), i.isPoint)
367
367
  i.bone.position.set(
368
368
  i.vBasis.x + z[0],
369
369
  i.vBasis.y + z[1],
370
370
  i.vBasis.z - z[2]
371
371
  );
372
- else if (i.boneParent.quaternion.copy(i.qBasis), i.pivot && this.opt.isPivots && (i.boneParent.updateWorldMatrix(!1, !1), i.boneParent.matrixWorld.decompose(B, de, he), B.copy(Ge).applyQuaternion(de).setY(0).normalize(), de.premultiply(Ke.setFromUnitVectors(Ge, B).invert()).normalize(), i.boneParent.quaternion.multiply(de.invert()), i.boneParent.quaternion.multiply(i.qWorldInverseYaw)), i.isZ && (m = Math.atan(z[0] / i.l), de.setFromAxisAngle(mt, -m), i.boneParent.quaternion.multiply(de)), i.isY && (m = i.l / 3, m = m * Math.tanh(z[1] / m), i.bone.position.setLength(i.l + m)), i.isX && (m = Math.atan(z[2] / i.l), de.setFromAxisAngle(ht, -m), i.boneParent.quaternion.multiply(de)), i.isT && (m = 1.5 * Math.tanh(z[3] * 1.5), de.setFromAxisAngle(dt, -m), i.boneParent.quaternion.multiply(de)), i.boneParent.updateWorldMatrix(!1, !0), i.excludes && this.opt.isExcludes)
372
+ else if (i.boneParent.quaternion.copy(i.qBasis), i.pivot && this.opt.isPivots && (i.boneParent.updateWorldMatrix(!1, !1), i.boneParent.matrixWorld.decompose(O, ge, pe), O.copy(Xe).applyQuaternion(ge).setY(0).normalize(), ge.premultiply($e.setFromUnitVectors(Xe, O).invert()).normalize(), i.boneParent.quaternion.multiply(ge.invert()), i.boneParent.quaternion.multiply(i.qWorldInverseYaw)), i.isZ && (p = Math.atan(z[0] / i.l), ge.setFromAxisAngle(pt, -p), i.boneParent.quaternion.multiply(ge)), i.isY && (p = i.l / 3, p = p * Math.tanh(z[1] / p), i.bone.position.setLength(i.l + p)), i.isX && (p = Math.atan(z[2] / i.l), ge.setFromAxisAngle(dt, -p), i.boneParent.quaternion.multiply(ge)), i.isT && (p = 1.5 * Math.tanh(z[3] * 1.5), ge.setFromAxisAngle(mt, -p), i.boneParent.quaternion.multiply(ge)), i.boneParent.updateWorldMatrix(!1, !0), i.excludes && this.opt.isExcludes)
373
373
  for (n = 0, s = i.excludes.length; n < s; n++)
374
- m = i.excludes[n], he.set(0, 0, 0), m.deltaLocal && (he.x += m.deltaLocal[0], he.y += m.deltaLocal[1], he.z += m.deltaLocal[2]), he.applyMatrix4(m.bone.matrixWorld), Ce.copy(i.boneParent.matrixWorld).invert(), he.applyMatrix4(Ce), B.copy(i.bone.position), !(B.distanceToSquared(he) >= m.radiusSq) && (Re = B.length(), fe = he.length(), !(fe > m.radius + Re) && (fe < Math.abs(m.radius - Re) || (fe = (fe * fe + Re * Re - m.radiusSq) / (2 * fe), he.normalize(), Ve.copy(he).multiplyScalar(fe), fe = Math.sqrt(Re * Re - fe * fe), B.subVectors(B, Ve).projectOnPlane(he).normalize().multiplyScalar(fe), We.subVectors(i.vBasis, Ve).projectOnPlane(he).normalize(), Re = We.dot(B), Re < 0 && (Re = Math.sqrt(fe * fe - Re * Re), We.multiplyScalar(Re), B.add(We)), B.add(Ve).normalize(), he.copy(i.bone.position).normalize(), de.setFromUnitVectors(he, B), i.boneParent.quaternion.premultiply(de), i.boneParent.updateWorldMatrix(!1, !0))));
374
+ p = i.excludes[n], pe.set(0, 0, 0), p.deltaLocal && (pe.x += p.deltaLocal[0], pe.y += p.deltaLocal[1], pe.z += p.deltaLocal[2]), pe.applyMatrix4(p.bone.matrixWorld), He.copy(i.boneParent.matrixWorld).invert(), pe.applyMatrix4(He), O.copy(i.bone.position), !(O.distanceToSquared(pe) >= p.radiusSq) && (Le = O.length(), be = pe.length(), !(be > p.radius + Le) && (be < Math.abs(p.radius - Le) || (be = (be * be + Le * Le - p.radiusSq) / (2 * be), pe.normalize(), Ze.copy(pe).multiplyScalar(be), be = Math.sqrt(Le * Le - be * be), O.subVectors(O, Ze).projectOnPlane(pe).normalize().multiplyScalar(be), Ge.subVectors(i.vBasis, Ze).projectOnPlane(pe).normalize(), Le = Ge.dot(O), Le < 0 && (Le = Math.sqrt(be * be - Le * Le), Ge.multiplyScalar(Le), O.add(Ge)), O.add(Ze).normalize(), pe.copy(i.bone.position).normalize(), ge.setFromUnitVectors(pe, O), i.boneParent.quaternion.premultiply(ge), i.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -382,18 +382,18 @@ class pt {
382
382
  * @param {boolean} [keepSetting=false] If true, keep the previos all setting
383
383
  */
384
384
  showHelpers(t) {
385
- if (this.hideHelpers(), this.helpers.isShowAll = t === void 0 ? this.helpers.isShowAll : t === !0, m = this.helpers, this.data.forEach((e) => {
386
- (this.helpers.isShowAll || e.helper === !0) && (m.points.bones.push(e.bone), m.points.pivots.push(e.pivot), e.type !== 0 && m.lines.bones.push(e.bone), e.excludes && e.excludes.forEach((n) => {
385
+ if (this.hideHelpers(), this.helpers.isShowAll = t === void 0 ? this.helpers.isShowAll : t === !0, p = this.helpers, this.data.forEach((e) => {
386
+ (this.helpers.isShowAll || e.helper === !0) && (p.points.bones.push(e.bone), p.points.pivots.push(e.pivot), e.type !== 0 && p.lines.bones.push(e.bone), e.excludes && e.excludes.forEach((n) => {
387
387
  let o = !1;
388
- for (let s = 0; s < m.excludes.bones.length; s++)
389
- if (m.excludes.bones[s] === n.bone && m.excludes.radii[s] === n.radius && !(m.excludes.deltaLocals[s] === null && n.deltaLocal !== null) && !(m.excludes.deltaLocals[s] !== null && n.deltaLocal === null) && !(m.excludes.deltaLocals[s] !== null && m.excludes.deltaLocals[s].some((i, a) => i !== n.deltaLocal[a]))) {
388
+ for (let s = 0; s < p.excludes.bones.length; s++)
389
+ if (p.excludes.bones[s] === n.bone && p.excludes.radii[s] === n.radius && !(p.excludes.deltaLocals[s] === null && n.deltaLocal !== null) && !(p.excludes.deltaLocals[s] !== null && n.deltaLocal === null) && !(p.excludes.deltaLocals[s] !== null && p.excludes.deltaLocals[s].some((i, a) => i !== n.deltaLocal[a]))) {
390
390
  o = !0;
391
391
  break;
392
392
  }
393
- o || (m.excludes.bones.push(n.bone), m.excludes.radii.push(n.radius), m.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), m.excludes.objects.push(null));
393
+ o || (p.excludes.bones.push(n.bone), p.excludes.radii.push(n.radius), p.excludes.deltaLocals.push(n.deltaLocal ? [...n.deltaLocal] : null), p.excludes.objects.push(null));
394
394
  }));
395
- }), m = this.helpers.excludes, this.opt.isExcludes && m.bones.length && m.bones.forEach((e, n) => {
396
- const o = new x.SphereGeometry(m.radii[n], 6, 6), s = new x.MeshBasicMaterial({
395
+ }), p = this.helpers.excludes, this.opt.isExcludes && p.bones.length && p.bones.forEach((e, n) => {
396
+ const o = new b.SphereGeometry(p.radii[n], 6, 6), s = new b.MeshBasicMaterial({
397
397
  depthTest: !1,
398
398
  depthWrite: !1,
399
399
  toneMapped: !1,
@@ -401,18 +401,18 @@ class pt {
401
401
  wireframe: !0,
402
402
  color: this.opt.helperExcludesColor
403
403
  });
404
- m.objects[n] = new x.Mesh(o, s), m.objects[n].renderOrder = 997, e.add(m.objects[n]), m.deltaLocals[n] && m.objects[n].position.set(
405
- m.deltaLocals[n][0],
406
- m.deltaLocals[n][1],
407
- m.deltaLocals[n][2]
404
+ p.objects[n] = new b.Mesh(o, s), p.objects[n].renderOrder = 997, e.add(p.objects[n]), p.deltaLocals[n] && p.objects[n].position.set(
405
+ p.deltaLocals[n][0],
406
+ p.deltaLocals[n][1],
407
+ p.deltaLocals[n][2]
408
408
  );
409
- }), m = this.helpers.points, m.bones.length) {
409
+ }), p = this.helpers.points, p.bones.length) {
410
410
  this.helpers.isActive = !0;
411
- const e = new x.BufferGeometry(), n = m.bones.map((c) => [0, 0, 0]).flat();
412
- e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
413
- const o = new x.Color(this.opt.helperBoneColor1), s = new x.Color(this.opt.helperBoneColor2), i = m.pivots.map((c) => c && this.opt.isPivots ? [s.r, s.g, s.b] : [o.r, o.g, o.b]).flat();
414
- e.setAttribute("color", new x.Float32BufferAttribute(i, 3));
415
- const a = new x.PointsMaterial({
411
+ const e = new b.BufferGeometry(), n = p.bones.map((c) => [0, 0, 0]).flat();
412
+ e.setAttribute("position", new b.Float32BufferAttribute(n, 3));
413
+ const o = new b.Color(this.opt.helperBoneColor1), s = new b.Color(this.opt.helperBoneColor2), i = p.pivots.map((c) => c && this.opt.isPivots ? [s.r, s.g, s.b] : [o.r, o.g, o.b]).flat();
414
+ e.setAttribute("color", new b.Float32BufferAttribute(i, 3));
415
+ const a = new b.PointsMaterial({
416
416
  depthTest: !1,
417
417
  depthWrite: !1,
418
418
  toneMapped: !1,
@@ -420,40 +420,40 @@ class pt {
420
420
  size: 0.2,
421
421
  vertexColors: !0
422
422
  });
423
- m.object = new x.Points(e, a), m.object.renderOrder = 998, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
423
+ p.object = new b.Points(e, a), p.object.renderOrder = 998, p.object.matrix = this.armature.matrixWorld, p.object.matrixAutoUpdate = !1, this.scene.add(p.object);
424
424
  }
425
- if (m = this.helpers.lines, m.bones.length) {
426
- const e = new x.BufferGeometry(), n = m.bones.map((c) => [0, 0, 0, 0, 0, 0]).flat();
427
- e.setAttribute("position", new x.Float32BufferAttribute(n, 3));
428
- const o = new x.Color(this.opt.helperLinkColor1), s = new x.Color(this.opt.helperLinkColor2), i = m.bones.map((c) => [o.r, o.g, o.b, s.r, s.g, s.b]).flat();
429
- e.setAttribute("color", new x.Float32BufferAttribute(i, 3));
430
- const a = new x.LineBasicMaterial({
425
+ if (p = this.helpers.lines, p.bones.length) {
426
+ const e = new b.BufferGeometry(), n = p.bones.map((c) => [0, 0, 0, 0, 0, 0]).flat();
427
+ e.setAttribute("position", new b.Float32BufferAttribute(n, 3));
428
+ const o = new b.Color(this.opt.helperLinkColor1), s = new b.Color(this.opt.helperLinkColor2), i = p.bones.map((c) => [o.r, o.g, o.b, s.r, s.g, s.b]).flat();
429
+ e.setAttribute("color", new b.Float32BufferAttribute(i, 3));
430
+ const a = new b.LineBasicMaterial({
431
431
  vertexColors: !0,
432
432
  depthTest: !1,
433
433
  depthWrite: !1,
434
434
  toneMapped: !1,
435
435
  transparent: !0
436
436
  });
437
- m.object = new x.LineSegments(e, a), m.object.renderOrder = 999, m.object.matrix = this.armature.matrixWorld, m.object.matrixAutoUpdate = !1, this.scene.add(m.object);
437
+ p.object = new b.LineSegments(e, a), p.object.renderOrder = 999, p.object.matrix = this.armature.matrixWorld, p.object.matrixAutoUpdate = !1, this.scene.add(p.object);
438
438
  }
439
439
  }
440
440
  /**
441
441
  * Update the positions of dynamic bone helpers.
442
442
  */
443
443
  updateHelpers() {
444
- if (m = this.helpers.points, m.bones.length) {
445
- Ce.copy(this.armature.matrixWorld).invert();
446
- const t = m.object.geometry.getAttribute("position");
447
- for (let e = 0, n = m.bones.length; e < n; e++)
448
- we.multiplyMatrices(Ce, m.bones[e].matrixWorld), B.setFromMatrixPosition(we), t.setXYZ(e, B.x, B.y, B.z);
449
- t.needsUpdate = !0, m.object.updateMatrixWorld();
444
+ if (p = this.helpers.points, p.bones.length) {
445
+ He.copy(this.armature.matrixWorld).invert();
446
+ const t = p.object.geometry.getAttribute("position");
447
+ for (let e = 0, n = p.bones.length; e < n; e++)
448
+ ze.multiplyMatrices(He, p.bones[e].matrixWorld), O.setFromMatrixPosition(ze), t.setXYZ(e, O.x, O.y, O.z);
449
+ t.needsUpdate = !0, p.object.updateMatrixWorld();
450
450
  }
451
- if (m = this.helpers.lines, m.bones.length) {
452
- Ce.copy(this.armature.matrixWorld).invert();
453
- const t = m.object.geometry.getAttribute("position");
454
- for (let e = 0, n = 0, o = m.bones.length; e < o; e++, n += 2)
455
- we.multiplyMatrices(Ce, m.bones[e].matrixWorld), B.setFromMatrixPosition(we), t.setXYZ(n, B.x, B.y, B.z), we.multiplyMatrices(Ce, m.bones[e].parent.matrixWorld), B.setFromMatrixPosition(we), t.setXYZ(n + 1, B.x, B.y, B.z);
456
- t.needsUpdate = !0, m.object.updateMatrixWorld();
451
+ if (p = this.helpers.lines, p.bones.length) {
452
+ He.copy(this.armature.matrixWorld).invert();
453
+ const t = p.object.geometry.getAttribute("position");
454
+ for (let e = 0, n = 0, o = p.bones.length; e < o; e++, n += 2)
455
+ ze.multiplyMatrices(He, p.bones[e].matrixWorld), O.setFromMatrixPosition(ze), t.setXYZ(n, O.x, O.y, O.z), ze.multiplyMatrices(He, p.bones[e].parent.matrixWorld), O.setFromMatrixPosition(ze), t.setXYZ(n + 1, O.x, O.y, O.z);
456
+ t.needsUpdate = !0, p.object.updateMatrixWorld();
457
457
  }
458
458
  }
459
459
  /**
@@ -462,9 +462,9 @@ class pt {
462
462
  hideHelpers() {
463
463
  [this.helpers.points, this.helpers.lines].forEach((t) => {
464
464
  t.bones = [], t.object && (this.scene.remove(t.object), t.object.geometry.dispose(), t.object.material.dispose(), t.object = null);
465
- }), m = this.helpers.excludes, m.objects.forEach((t, e) => {
466
- t && (m.bones[e].remove(t), t.geometry.dispose(), t.material.dispose());
467
- }), m.bones = [], m.deltaLocals = [], m.radii = [], m.objects = [], this.helpers.isActive = !1;
465
+ }), p = this.helpers.excludes, p.objects.forEach((t, e) => {
466
+ t && (p.bones[e].remove(t), t.geometry.dispose(), t.material.dispose());
467
+ }), p.bones = [], p.deltaLocals = [], p.radii = [], p.objects = [], this.helpers.isActive = !1;
468
468
  }
469
469
  /**
470
470
  * Start dynamic bones.
@@ -489,7 +489,7 @@ class pt {
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 gt {
492
+ class yt {
493
493
  constructor(t) {
494
494
  this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
495
495
  }
@@ -608,8 +608,8 @@ class gt {
608
608
  for (let r = 0; r < o / 2; r++) {
609
609
  const d = n[(c + r) * 2], h = n[(c + r) * 2 + 1], g = n[(c + r + o / 2) * 2] * l - n[(c + r + o / 2) * 2 + 1] * u, R = n[(c + r + o / 2) * 2] * u + n[(c + r + o / 2) * 2 + 1] * l;
610
610
  n[(c + r) * 2] = d + g, n[(c + r) * 2 + 1] = h + R, n[(c + r + o / 2) * 2] = d - g, n[(c + r + o / 2) * 2 + 1] = h - R;
611
- const b = l * i - u * a, k = l * a + u * i;
612
- l = b, u = k;
611
+ const x = l * i - u * a, k = l * a + u * i;
612
+ l = x, u = k;
613
613
  }
614
614
  }
615
615
  }
@@ -814,7 +814,7 @@ class gt {
814
814
  return o * s;
815
815
  }
816
816
  }
817
- class yt {
817
+ class ft {
818
818
  /**
819
819
  * @constructor
820
820
  */
@@ -1396,11 +1396,11 @@ class yt {
1396
1396
  return e;
1397
1397
  }
1398
1398
  }
1399
- const ft = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1399
+ const xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1400
1400
  __proto__: null,
1401
- LipsyncEn: yt
1401
+ LipsyncEn: ft
1402
1402
  }, Symbol.toStringTag, { value: "Module" }));
1403
- class xt {
1403
+ class bt {
1404
1404
  /**
1405
1405
  * @constructor
1406
1406
  */
@@ -1754,11 +1754,11 @@ class xt {
1754
1754
  return e;
1755
1755
  }
1756
1756
  }
1757
- const bt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1757
+ const Rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1758
1758
  __proto__: null,
1759
- LipsyncDe: xt
1759
+ LipsyncDe: bt
1760
1760
  }, Symbol.toStringTag, { value: "Module" }));
1761
- class Rt {
1761
+ class vt {
1762
1762
  /**
1763
1763
  * @constructor
1764
1764
  */
@@ -2289,11 +2289,11 @@ class Rt {
2289
2289
  return e;
2290
2290
  }
2291
2291
  }
2292
- const vt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ const It = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2293
2293
  __proto__: null,
2294
- LipsyncFr: Rt
2294
+ LipsyncFr: vt
2295
2295
  }, Symbol.toStringTag, { value: "Module" }));
2296
- class It {
2296
+ class At {
2297
2297
  /**
2298
2298
  * @constructor
2299
2299
  */
@@ -2436,11 +2436,11 @@ class It {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const Lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
- LipsyncFi: It
2441
+ LipsyncFi: At
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class Lt {
2443
+ class St {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2620,24 +2620,24 @@ class Lt {
2620
2620
  return e;
2621
2621
  }
2622
2622
  }
2623
- const St = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
+ const kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: Lt
2626
- }, Symbol.toStringTag, { value: "Module" })), kt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25zPy5wcm9jZXNzb3JPcHRpb25zPy5tZXRyaWNzIHx8IHt9OwogICAgdGhp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2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgIC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geyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), $e = {
2627
- en: ft,
2628
- de: bt,
2629
- fr: vt,
2630
- fi: At,
2631
- lt: St
2632
- }, oe = new x.Quaternion(), Q = new x.Euler(), Te = new x.Vector3(), Ee = new x.Vector3(), Je = new x.Box3();
2633
- new x.Matrix4();
2634
- new x.Matrix4();
2635
- new x.Vector3();
2636
- new x.Vector3(0, 0, 1);
2637
- const wt = new x.Vector3(1, 0, 0);
2638
- new x.Vector3(0, 1, 0);
2639
- new x.Vector3(0, 0, 1);
2640
- class Qe {
2625
+ LipsyncLt: St
2626
+ }, Symbol.toStringTag, { value: "Module" })), wt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE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OiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3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AgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), et = {
2627
+ en: xt,
2628
+ de: Rt,
2629
+ fr: It,
2630
+ fi: Lt,
2631
+ lt: kt
2632
+ }, ne = new b.Quaternion(), q = new b.Euler(), Te = new b.Vector3(), Ee = new b.Vector3(), tt = new b.Box3();
2633
+ new b.Matrix4();
2634
+ new b.Matrix4();
2635
+ new b.Vector3();
2636
+ new b.Vector3(0, 0, 1);
2637
+ const Ct = new b.Vector3(1, 0, 0);
2638
+ new b.Vector3(0, 1, 0);
2639
+ new b.Vector3(0, 0, 1);
2640
+ class _e {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -2763,7 +2763,7 @@ class Qe {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new ct(), 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 ht(), 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: {
@@ -4073,22 +4073,22 @@ class Qe {
4073
4073
  if (this.isAvatarOnly = this.opt.avatarOnly, this.isAvatarOnly)
4074
4074
  this.scene = this.opt.avatarOnlyScene, this.camera = this.opt.avatarOnlyCamera;
4075
4075
  else {
4076
- this.renderer = new x.WebGLRenderer({ antialias: !0, alpha: !0 }), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.renderer.outputColorSpace = x.SRGBColorSpace, this.renderer.toneMapping = x.ACESFilmicToneMapping, this.renderer.shadowMap.enabled = !1, this.nodeAvatar.appendChild(this.renderer.domElement), this.camera = new x.PerspectiveCamera(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2e3), this.scene = new x.Scene(), this.lightAmbient = new x.AmbientLight(
4077
- new x.Color(this.opt.lightAmbientColor),
4076
+ this.renderer = new b.WebGLRenderer({ antialias: !0, alpha: !0 }), this.renderer.setPixelRatio(this.opt.modelPixelRatio * window.devicePixelRatio), this.renderer.setSize(this.nodeAvatar.clientWidth, this.nodeAvatar.clientHeight), this.renderer.outputColorSpace = b.SRGBColorSpace, this.renderer.toneMapping = b.ACESFilmicToneMapping, this.renderer.shadowMap.enabled = !1, this.nodeAvatar.appendChild(this.renderer.domElement), this.camera = new b.PerspectiveCamera(10, this.nodeAvatar.clientWidth / this.nodeAvatar.clientHeight, 0.1, 2e3), this.scene = new b.Scene(), this.lightAmbient = new b.AmbientLight(
4077
+ new b.Color(this.opt.lightAmbientColor),
4078
4078
  this.opt.lightAmbientIntensity
4079
- ), this.lightDirect = new x.DirectionalLight(
4080
- new x.Color(this.opt.lightDirectColor),
4079
+ ), this.lightDirect = new b.DirectionalLight(
4080
+ new b.Color(this.opt.lightDirectColor),
4081
4081
  this.opt.lightDirectIntensity
4082
- ), this.lightSpot = new x.SpotLight(
4083
- new x.Color(this.opt.lightSpotColor),
4082
+ ), this.lightSpot = new b.SpotLight(
4083
+ new b.Color(this.opt.lightSpotColor),
4084
4084
  this.opt.lightSpotIntensity,
4085
4085
  0,
4086
4086
  this.opt.lightSpotDispersion
4087
4087
  ), this.setLighting(this.opt);
4088
- const a = new x.PMREMGenerator(this.renderer);
4089
- a.compileEquirectangularShader(), this.scene.environment = a.fromScene(new ut()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new rt(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;
4088
+ const a = new b.PMREMGenerator(this.renderer);
4089
+ a.compileEquirectangularShader(), this.scene.environment = a.fromScene(new ct()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new at(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;
4090
4090
  }
4091
- this.ikMesh = new x.SkinnedMesh();
4091
+ this.ikMesh = new b.SkinnedMesh();
4092
4092
  const s = {
4093
4093
  LeftShoulder: null,
4094
4094
  LeftArm: "LeftShoulder",
@@ -4102,16 +4102,16 @@ class Qe {
4102
4102
  RightHandMiddle1: "RightHand"
4103
4103
  }, i = [];
4104
4104
  Object.entries(s).forEach((a, c) => {
4105
- const l = new x.Bone();
4105
+ const l = new b.Bone();
4106
4106
  l.name = a[0], a[1] ? this.ikMesh.getObjectByName(a[1]).add(l) : this.ikMesh.add(l), i.push(l);
4107
- }), this.ikMesh.bind(new x.Skeleton(i)), this.dynamicbones = new pt(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4107
+ }), this.ikMesh.bind(new b.Skeleton(i)), this.dynamicbones = new gt(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4108
4108
  }
4109
4109
  /**
4110
4110
  * Helper that re/creates the audio context and the other nodes.
4111
4111
  * @param {number} sampleRate
4112
4112
  */
4113
4113
  initAudioGraph(t = null) {
4114
- 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 gt(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(
4114
+ 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 yt(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(
4115
4115
  this.opt.mixerGainSpeech,
4116
4116
  this.opt.mixerGainBackground
4117
4117
  ), this.workletLoaded = !1, this.streamWorkletNode) {
@@ -4194,7 +4194,7 @@ class Qe {
4194
4194
  for (let [n, o] of Object.entries(t)) {
4195
4195
  const s = n.split(".");
4196
4196
  let i = Array.isArray(o.x) ? this.gaussianRandom(...o.x) : o.x, a = Array.isArray(o.y) ? this.gaussianRandom(...o.y) : o.y, c = Array.isArray(o.z) ? this.gaussianRandom(...o.z) : o.z;
4197
- s[1] === "position" || s[1] === "scale" ? e[n] = new x.Vector3(i, a, c) : s[1] === "rotation" ? (n = s[0] + ".quaternion", e[n] = new x.Quaternion().setFromEuler(new x.Euler(i, a, c, "XYZ")).normalize()) : s[1] === "quaternion" && (e[n] = new x.Quaternion(i, a, c, o.w).normalize());
4197
+ s[1] === "position" || s[1] === "scale" ? e[n] = new b.Vector3(i, a, c) : s[1] === "rotation" ? (n = s[0] + ".quaternion", e[n] = new b.Quaternion().setFromEuler(new b.Euler(i, a, c, "XYZ")).normalize()) : s[1] === "quaternion" && (e[n] = new b.Quaternion(i, a, c, o.w).normalize());
4198
4198
  }
4199
4199
  return e;
4200
4200
  }
@@ -4226,15 +4226,15 @@ class Qe {
4226
4226
  for (const [l, u] of Object.entries(n))
4227
4227
  if (s.morphTargetDictionary.hasOwnProperty(l)) {
4228
4228
  const r = s.morphTargetDictionary[l], d = i.morphAttributes.position[r], h = i.morphAttributes.normal?.[r];
4229
- a || (a = new x.Float32BufferAttribute(d.count * 3, 3), h && (c = new x.Float32BufferAttribute(d.count * 3, 3)));
4229
+ a || (a = new b.Float32BufferAttribute(d.count * 3, 3), h && (c = new b.Float32BufferAttribute(d.count * 3, 3)));
4230
4230
  for (let g = 0; g < d.count; g++) {
4231
- const R = a.getX(g) + d.getX(g) * u, b = a.getY(g) + d.getY(g) * u, k = a.getZ(g) + d.getZ(g) * u;
4232
- a.setXYZ(g, R, b, k);
4231
+ const R = a.getX(g) + d.getX(g) * u, x = a.getY(g) + d.getY(g) * u, k = a.getZ(g) + d.getZ(g) * u;
4232
+ a.setXYZ(g, R, x, k);
4233
4233
  }
4234
4234
  if (h)
4235
4235
  for (let g = 0; g < d.count; g++) {
4236
- const R = c.getX(g) + h.getX(g) * u, b = c.getY(g) + h.getY(g) * u, k = c.getZ(g) + h.getZ(g) * u;
4237
- c.setXYZ(g, R, b, k);
4236
+ const R = c.getX(g) + h.getX(g) * u, x = c.getY(g) + h.getY(g) * u, k = c.getZ(g) + h.getZ(g) * u;
4237
+ c.setXYZ(g, R, x, k);
4238
4238
  }
4239
4239
  }
4240
4240
  if (a) {
@@ -4252,9 +4252,9 @@ class Qe {
4252
4252
  async showAvatar(t, e = null) {
4253
4253
  if (!t || !t.hasOwnProperty("url"))
4254
4254
  throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
4255
- const n = new at();
4255
+ const n = new lt();
4256
4256
  if (this.dracoEnabled) {
4257
- const l = new lt();
4257
+ const l = new ut();
4258
4258
  l.setDecoderPath(this.dracoDecoderPath), n.setDRACOLoader(l);
4259
4259
  }
4260
4260
  let o = await n.loadAsync(t.url, e);
@@ -4314,7 +4314,7 @@ class Qe {
4314
4314
  console.error("Dynamic bones setup failed: " + l);
4315
4315
  }
4316
4316
  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");
4317
- const c = new x.Vector3();
4317
+ const c = new b.Vector3();
4318
4318
  this.objectLeftEye.getWorldPosition(c), this.avatarHeight = c.y + 0.2, this.viewName || this.setView(this.opt.cameraView), this.setMood(this.avatar.avatarMood || this.moodName || this.opt.avatarMood), this.avatar.body === "M" && this.poseTemplates.wide && (this.poseName = "wide", this.setPoseFromTemplate(this.poseTemplates.wide, 0)), this.initializeFBXAnimationLoader(), this.bodyMovement && this.bodyMovement !== "idle" && this.applyBodyMovementAnimation(), this.start();
4319
4319
  }
4320
4320
  /**
@@ -4358,14 +4358,14 @@ class Qe {
4358
4358
  default:
4359
4359
  r += 12, u = u * r;
4360
4360
  }
4361
- l = l * r, this.controlsEnd = new x.Vector3(l, u, 0), this.cameraEnd = new x.Vector3(l, u, r).applyEuler(new x.Euler(i, a, 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;
4361
+ l = l * r, this.controlsEnd = new b.Vector3(l, u, 0), this.cameraEnd = new b.Vector3(l, u, r).applyEuler(new b.Euler(i, a, 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;
4362
4362
  }
4363
4363
  /**
4364
4364
  * Change light colors and intensities.
4365
4365
  * @param {Object} opt Options
4366
4366
  */
4367
4367
  setLighting(t) {
4368
- this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new x.Color(t.lightAmbientColor)), t.hasOwnProperty("lightAmbientIntensity") && (this.lightAmbient.intensity = t.lightAmbientIntensity, this.lightAmbient.visible = t.lightAmbientIntensity !== 0), t.hasOwnProperty("lightDirectColor") && this.lightDirect.color.set(new x.Color(t.lightDirectColor)), t.hasOwnProperty("lightDirectIntensity") && (this.lightDirect.intensity = t.lightDirectIntensity, this.lightDirect.visible = t.lightDirectIntensity !== 0), t.hasOwnProperty("lightDirectPhi") && t.hasOwnProperty("lightDirectTheta") && this.lightDirect.position.setFromSphericalCoords(2, t.lightDirectPhi, t.lightDirectTheta), t.hasOwnProperty("lightSpotColor") && this.lightSpot.color.set(new x.Color(t.lightSpotColor)), t.hasOwnProperty("lightSpotIntensity") && (this.lightSpot.intensity = t.lightSpotIntensity, this.lightSpot.visible = t.lightSpotIntensity !== 0), t.hasOwnProperty("lightSpotPhi") && t.hasOwnProperty("lightSpotTheta") && (this.lightSpot.position.setFromSphericalCoords(2, t.lightSpotPhi, t.lightSpotTheta), this.lightSpot.position.add(new x.Vector3(0, 1.5, 0))), t.hasOwnProperty("lightSpotDispersion") && (this.lightSpot.angle = t.lightSpotDispersion));
4368
+ this.isAvatarOnly || (t = t || {}, t.hasOwnProperty("lightAmbientColor") && this.lightAmbient.color.set(new b.Color(t.lightAmbientColor)), t.hasOwnProperty("lightAmbientIntensity") && (this.lightAmbient.intensity = t.lightAmbientIntensity, this.lightAmbient.visible = t.lightAmbientIntensity !== 0), t.hasOwnProperty("lightDirectColor") && this.lightDirect.color.set(new b.Color(t.lightDirectColor)), t.hasOwnProperty("lightDirectIntensity") && (this.lightDirect.intensity = t.lightDirectIntensity, this.lightDirect.visible = t.lightDirectIntensity !== 0), t.hasOwnProperty("lightDirectPhi") && t.hasOwnProperty("lightDirectTheta") && this.lightDirect.position.setFromSphericalCoords(2, t.lightDirectPhi, t.lightDirectTheta), t.hasOwnProperty("lightSpotColor") && this.lightSpot.color.set(new b.Color(t.lightSpotColor)), t.hasOwnProperty("lightSpotIntensity") && (this.lightSpot.intensity = t.lightSpotIntensity, this.lightSpot.visible = t.lightSpotIntensity !== 0), t.hasOwnProperty("lightSpotPhi") && t.hasOwnProperty("lightSpotTheta") && (this.lightSpot.position.setFromSphericalCoords(2, t.lightSpotPhi, t.lightSpotTheta), this.lightSpot.position.add(new b.Vector3(0, 1.5, 0))), t.hasOwnProperty("lightSpotDispersion") && (this.lightSpot.angle = t.lightSpotDispersion));
4369
4369
  }
4370
4370
  /**
4371
4371
  * Render scene.
@@ -4412,9 +4412,9 @@ class Qe {
4412
4412
  updatePoseDelta() {
4413
4413
  for (const [t, e] of Object.entries(this.poseDelta.props)) {
4414
4414
  if (e.x === 0 && e.y === 0 && e.z === 0) continue;
4415
- Q.set(e.x, e.y, e.z);
4415
+ q.set(e.x, e.y, e.z);
4416
4416
  const n = this.poseAvatar.props[t];
4417
- n.isQuaternion ? (oe.setFromEuler(Q), n.multiply(oe)) : n.isVector3 && n.add(Q);
4417
+ n.isQuaternion ? (ne.setFromEuler(q), n.multiply(ne)) : n.isVector3 && n.add(q);
4418
4418
  }
4419
4419
  }
4420
4420
  /**
@@ -4494,7 +4494,7 @@ class Qe {
4494
4494
  return Object.entries(t).forEach((o, s) => {
4495
4495
  const i = o[0].split(".");
4496
4496
  if (i[1] === "position" || i[1] === "rotation" || i[1] === "quaternion") {
4497
- const a = i[1] === "quaternion" ? i[0] + ".rotation" : o[0], c = o[1].isQuaternion ? new x.Euler().setFromQuaternion(o[1]) : o[1];
4497
+ const a = i[1] === "quaternion" ? i[0] + ".rotation" : o[0], c = o[1].isQuaternion ? new b.Euler().setFromQuaternion(o[1]) : o[1];
4498
4498
  n += (s ? ", " : "") + "'" + a + "':{", n += "x:" + Math.round(c.x * e) / e, n += ", y:" + Math.round(c.y * e) / e, n += ", z:" + Math.round(c.z * e) / e, n += "}";
4499
4499
  }
4500
4500
  }), n += "}", n;
@@ -5115,8 +5115,8 @@ class Qe {
5115
5115
  else {
5116
5116
  g.newvalue = h[o + 1];
5117
5117
  const R = r.ts[o + 1] - r.ts[o];
5118
- let b = 1;
5119
- R > 1e-4 && (b = (this.animClock - r.ts[o]) / R), b < 1 && (g.easing && (b = g.easing(b)), g.newvalue = (1 - b) * h[o] + b * g.newvalue), g.ref && g.ref !== r.vs && g.ref.hasOwnProperty(d) && delete g.ref[d], g.ref = r.vs;
5118
+ let x = 1;
5119
+ R > 1e-4 && (x = (this.animClock - r.ts[o]) / R), x < 1 && (g.easing && (x = g.easing(x)), g.newvalue = (1 - x) * h[o] + x * g.newvalue), g.ref && g.ref !== r.vs && g.ref.hasOwnProperty(d) && delete g.ref[d], g.ref = r.vs;
5120
5120
  }
5121
5121
  if (a)
5122
5122
  switch (d) {
@@ -5164,7 +5164,7 @@ class Qe {
5164
5164
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
5165
5165
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5166
5166
  ]
5167
- }, o.x ? new x.Vector3(o.x, o.y, o.z) : null, !0, o.d);
5167
+ }, o.x ? new b.Vector3(o.x, o.y, o.z) : null, !0, o.d);
5168
5168
  break;
5169
5169
  case "handRight":
5170
5170
  this.ikSolve({
@@ -5176,10 +5176,10 @@ class Qe {
5176
5176
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5, maxAngle: 0.2 },
5177
5177
  { link: "RightArm", minx: -1.5, maxx: 1.5, miny: 0, maxy: 0, minz: -1, maxz: 3 }
5178
5178
  ]
5179
- }, o.x ? new x.Vector3(o.x, o.y, o.z) : null, !0, o.d);
5179
+ }, o.x ? new b.Vector3(o.x, o.y, o.z) : null, !0, o.d);
5180
5180
  break;
5181
5181
  }
5182
- if ((c || l) && (Q.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), Q.x = Math.max(-0.9, Math.min(0.9, 2 * Q.x - 0.5)), Q.y = Math.max(-0.9, Math.min(0.9, -2.5 * Q.y)), c ? (Object.assign(this.mtAvatar.eyesLookDown, { system: Q.x < 0 ? -Q.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: Q.x < 0 ? 0 : Q.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: Q.y < 0 ? -Q.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: Q.y < 0 ? 0 : Q.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: Q.y < 0 ? 0 : Q.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: Q.y < 0 ? -Q.y : 0, needsUpdate: !0 }), l && (n = -this.mtAvatar.bodyRotateY.value, o = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5182
+ if ((c || l) && (q.setFromQuaternion(this.poseAvatar.props["Head.quaternion"]), q.x = Math.max(-0.9, Math.min(0.9, 2 * q.x - 0.5)), q.y = Math.max(-0.9, Math.min(0.9, -2.5 * q.y)), c ? (Object.assign(this.mtAvatar.eyesLookDown, { system: q.x < 0 ? -q.x : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyesLookUp, { system: q.x < 0 ? 0 : q.x, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInLeft, { system: q.y < 0 ? -q.y : 0, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutLeft, { system: q.y < 0 ? 0 : q.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookInRight, { system: q.y < 0 ? 0 : q.y, needsUpdate: !0 }), Object.assign(this.mtAvatar.eyeLookOutRight, { system: q.y < 0 ? -q.y : 0, needsUpdate: !0 }), l && (n = -this.mtAvatar.bodyRotateY.value, o = this.gaussianRandom(-0.2, 0.2), this.animQueue.push(this.animFactory({
5183
5183
  name: "headmove",
5184
5184
  dt: [[1e3, 2e3], [1e3, 2e3, 1, 2], [1e3, 2e3], [1e3, 2e3, 1, 2]],
5185
5185
  vs: {
@@ -5200,12 +5200,12 @@ class Qe {
5200
5200
  eyeLookOutRight: [null, 0],
5201
5201
  eyeContact: [0]
5202
5202
  }
5203
- })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], o = this.mtAvatar[n], o.needsUpdate || Object.assign(o, { base: (this.mood.baseline[n] || 0) + (1 + a / 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) && c ? a > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = a) : (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, o = Math.abs(n), o > 1e-4 && (i = o * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / o) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(o, i)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (oe.setFromAxisAngle(wt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(oe)), Je.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(Te), Te.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(Ee), Ee.sub(this.armature.position), this.objectHips.position.y -= Je.min.y / 2, this.objectHips.position.x -= (Te.x + Ee.x) / 4, this.objectHips.position.z -= (Te.z + Ee.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5203
+ })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], o = this.mtAvatar[n], o.needsUpdate || Object.assign(o, { base: (this.mood.baseline[n] || 0) + (1 + a / 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) && c ? a > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = a) : (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, o = Math.abs(n), o > 1e-4 && (i = o * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / o) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(o, i)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (ne.setFromAxisAngle(Ct, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(ne)), tt.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(Te), Te.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(Ee), Ee.sub(this.armature.position), this.objectHips.position.y -= tt.min.y / 2, this.objectHips.position.x -= (Te.x + Ee.x) / 4, this.objectHips.position.z -= (Te.z + Ee.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5204
5204
  this.stats && this.stats.end();
5205
5205
  else {
5206
5206
  if (this.cameraClock !== null && this.cameraClock < 1e3) {
5207
5207
  this.cameraClock += e, this.cameraClock > 1e3 && (this.cameraClock = 1e3);
5208
- let r = new x.Spherical().setFromVector3(this.cameraStart), d = new x.Spherical().setFromVector3(this.cameraEnd);
5208
+ let r = new b.Spherical().setFromVector3(this.cameraStart), d = new b.Spherical().setFromVector3(this.cameraEnd);
5209
5209
  r.phi += this.easing(this.cameraClock / 1e3) * (d.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (d.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (d.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), d.setFromVector3(this.controlsEnd), r.phi += this.easing(this.cameraClock / 1e3) * (d.phi - r.phi), r.theta += this.easing(this.cameraClock / 1e3) * (d.theta - r.theta), r.radius += this.easing(this.cameraClock / 1e3) * (d.radius - r.radius), r.makeSafe(), this.controls.target.setFromSpherical(r)), this.controls.update();
5210
5210
  }
5211
5211
  this.controls.autoRotate && this.controls.update(), this.stats && this.stats.end(), this.render();
@@ -5231,8 +5231,8 @@ class Qe {
5231
5231
  if (!this.lipsync.hasOwnProperty(t)) {
5232
5232
  const n = t.toLowerCase(), o = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5233
5233
  try {
5234
- const s = $e[n];
5235
- s && s[o] ? this.lipsync[t] = new s[o]() : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys($e));
5234
+ const s = et[n];
5235
+ s && s[o] ? this.lipsync[t] = new s[o]() : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(et));
5236
5236
  } catch (s) {
5237
5237
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5238
5238
  }
@@ -5269,12 +5269,12 @@ class Qe {
5269
5269
  e = e || {};
5270
5270
  const s = /[!\.\?\n\p{Extended_Pictographic}]/ug, i = /[ ]/ug, a = /[\p{L}\p{N},\.\p{Quotation_Mark}!€\$\+\p{Dash_Punctuation}%&\?]/ug, c = /[\p{Extended_Pictographic}]/ug, l = e.lipsyncLang || this.avatar.lipsyncLang || this.opt.lipsyncLang;
5271
5271
  let u = "", r = "", d = 0, h = [], g = [];
5272
- const R = Array.from(this.segmenter.segment(t), (b) => b.segment);
5273
- for (let b = 0; b < R.length; b++) {
5274
- const k = b === R.length - 1, T = R[b].match(a);
5275
- let p = R[b].match(s);
5276
- const O = R[b].match(c), E = R[b].match(i);
5277
- if (p && !k && !O && R[b + 1].match(s) && (p = !1), n && (u += R[b]), T && (!o || o.every((y) => b < y[0] || b > y[1])) && (r += R[b]), (E || p || k) && (r.length && (r = this.lipsyncPreProcessText(r, l), r.length && h.push({
5272
+ const R = Array.from(this.segmenter.segment(t), (x) => x.segment);
5273
+ for (let x = 0; x < R.length; x++) {
5274
+ const k = x === R.length - 1, G = R[x].match(a);
5275
+ let m = R[x].match(s);
5276
+ const B = R[x].match(c), M = R[x].match(i);
5277
+ if (m && !k && !B && R[x + 1].match(s) && (m = !1), n && (u += R[x]), G && (!o || o.every((y) => x < y[0] || x > y[1])) && (r += R[x]), (M || m || k) && (r.length && (r = this.lipsyncPreProcessText(r, l), r.length && h.push({
5278
5278
  mark: d,
5279
5279
  word: r
5280
5280
  })), u.length && (g.push({
@@ -5288,27 +5288,27 @@ class Qe {
5288
5288
  const y = this.lipsyncWordsToVisemes(r, l);
5289
5289
  if (y && y.visemes && y.visemes.length) {
5290
5290
  const F = y.times[y.visemes.length - 1] + y.durations[y.visemes.length - 1];
5291
- for (let f = 0; f < y.visemes.length; f++)
5291
+ for (let L = 0; L < y.visemes.length; L++)
5292
5292
  g.push({
5293
5293
  mark: d,
5294
5294
  template: { name: "viseme" },
5295
- ts: [(y.times[f] - 0.6) / F, (y.times[f] + 0.5) / F, (y.times[f] + y.durations[f] + 0.5) / F],
5295
+ ts: [(y.times[L] - 0.6) / F, (y.times[L] + 0.5) / F, (y.times[L] + y.durations[L] + 0.5) / F],
5296
5296
  vs: {
5297
- ["viseme_" + y.visemes[f]]: [null, y.visemes[f] === "PP" || y.visemes[f] === "FF" ? 0.9 : 0.6, 0]
5297
+ ["viseme_" + y.visemes[L]]: [null, y.visemes[L] === "PP" || y.visemes[L] === "FF" ? 0.9 : 0.6, 0]
5298
5298
  }
5299
5299
  });
5300
5300
  }
5301
5301
  r = "", d++;
5302
5302
  }
5303
- if (p || k) {
5303
+ if (m || k) {
5304
5304
  if (h.length || k && g.length) {
5305
5305
  const y = {
5306
5306
  anim: g
5307
5307
  };
5308
5308
  n && (y.onSubtitles = n), h.length && !e.avatarMute && (y.text = h, e.avatarMood && (y.mood = e.avatarMood), e.ttsLang && (y.lang = e.ttsLang), e.ttsVoice && (y.voice = e.ttsVoice), e.ttsRate && (y.rate = e.ttsRate), e.ttsVoice && (y.pitch = e.ttsPitch), e.ttsVolume && (y.volume = e.ttsVolume)), this.speechQueue.push(y), h = [], r = "", d = 0, g = [];
5309
5309
  }
5310
- if (O) {
5311
- let y = this.animEmojis[R[b]];
5310
+ if (B) {
5311
+ let y = this.animEmojis[R[x]];
5312
5312
  y && y.link && (y = this.animEmojis[y.link]), y && this.speechQueue.push({ emoji: y });
5313
5313
  }
5314
5314
  this.speechQueue.push({ break: 100 });
@@ -5404,13 +5404,13 @@ class Qe {
5404
5404
  const h = d.times[d.visemes.length - 1] + d.durations[d.visemes.length - 1], g = Math.min(u, Math.max(0, u - d.visemes.length * 150));
5405
5405
  let R = 0.6 + this.convertRange(g, [0, u], [0, 0.4]);
5406
5406
  if (u = Math.min(u, d.visemes.length * 200), h > 0)
5407
- for (let b = 0; b < d.visemes.length; b++) {
5408
- const k = l + d.times[b] / h * u, T = d.durations[b] / h * u;
5407
+ for (let x = 0; x < d.visemes.length; x++) {
5408
+ const k = l + d.times[x] / h * u, G = d.durations[x] / h * u;
5409
5409
  i.push({
5410
5410
  template: { name: "viseme" },
5411
- ts: [k - Math.min(60, 2 * T / 3), k + Math.min(25, T / 2), k + T + Math.min(60, T / 2)],
5411
+ ts: [k - Math.min(60, 2 * G / 3), k + Math.min(25, G / 2), k + G + Math.min(60, G / 2)],
5412
5412
  vs: {
5413
- ["viseme_" + d.visemes[b]]: [null, d.visemes[b] === "PP" || d.visemes[b] === "FF" ? 0.9 : R, 0]
5413
+ ["viseme_" + d.visemes[x]]: [null, d.visemes[x] === "PP" || d.visemes[x] === "FF" ? 0.9 : R, 0]
5414
5414
  }
5415
5415
  });
5416
5416
  }
@@ -5486,32 +5486,32 @@ class Qe {
5486
5486
  */
5487
5487
  async synthesizeWithBrowserTTS(t) {
5488
5488
  return new Promise((e, n) => {
5489
- const o = t.text.map((p) => p.word).join(" "), s = new SpeechSynthesisUtterance(o), i = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", a = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, c = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, l = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5489
+ const o = t.text.map((m) => m.word).join(" "), s = new SpeechSynthesisUtterance(o), i = t.lang || this.avatar.ttsLang || this.opt.ttsLang || "en-US", a = (t.rate || this.avatar.ttsRate || this.opt.ttsRate || 1) + this.mood.speech.deltaRate, c = (t.pitch || this.avatar.ttsPitch || this.opt.ttsPitch || 1) + this.mood.speech.deltaPitch, l = (t.volume || this.avatar.ttsVolume || this.opt.ttsVolume || 1) + this.mood.speech.deltaVolume;
5490
5490
  s.lang = i, s.rate = Math.max(0.1, Math.min(10, a)), s.pitch = Math.max(0, Math.min(2, c)), s.volume = Math.max(0, Math.min(1, l));
5491
5491
  const u = speechSynthesis.getVoices(), r = t.voice || this.avatar.ttsVoice || this.opt.ttsVoice;
5492
5492
  if (r && u.length > 0) {
5493
- const p = u.find((O) => O.name.includes(r) || O.lang === i);
5494
- p && (s.voice = p);
5493
+ const m = u.find((B) => B.name.includes(r) || B.lang === i);
5494
+ m && (s.voice = m);
5495
5495
  }
5496
- const d = o.length * 100 / s.rate, h = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (d / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", R = this.lipsyncPreProcessText(o, g), b = this.lipsyncWordsToVisemes(R, g), k = [];
5497
- if (b && b.visemes && b.visemes.length > 0) {
5498
- const p = b.times[b.visemes.length - 1] + b.durations[b.visemes.length - 1];
5499
- for (let O = 0; O < b.visemes.length; O++) {
5500
- const E = b.visemes[O], y = b.times[O] / p, F = b.durations[O] / p, f = y * d, w = F * d;
5496
+ const d = o.length * 100 / s.rate, h = this.audioCtx.createBuffer(1, this.audioCtx.sampleRate * (d / 1e3), this.audioCtx.sampleRate), g = this.avatar.lipsyncLang || this.opt.lipsyncLang || "en", R = this.lipsyncPreProcessText(o, g), x = this.lipsyncWordsToVisemes(R, g), k = [];
5497
+ if (x && x.visemes && x.visemes.length > 0) {
5498
+ const m = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
5499
+ for (let B = 0; B < x.visemes.length; B++) {
5500
+ const M = x.visemes[B], y = x.times[B] / m, F = x.durations[B] / m, L = y * d, f = F * d;
5501
5501
  k.push({
5502
5502
  template: { name: "viseme" },
5503
- ts: [f - Math.min(60, 2 * w / 3), f + Math.min(25, w / 2), f + w + Math.min(60, w / 2)],
5503
+ ts: [L - Math.min(60, 2 * f / 3), L + Math.min(25, f / 2), L + f + Math.min(60, f / 2)],
5504
5504
  vs: {
5505
- ["viseme_" + E]: [null, E === "PP" || E === "FF" ? 0.9 : 0.6, 0]
5505
+ ["viseme_" + M]: [null, M === "PP" || M === "FF" ? 0.9 : 0.6, 0]
5506
5506
  }
5507
5507
  });
5508
5508
  }
5509
5509
  }
5510
- const T = [...t.anim, ...k];
5511
- this.audioPlaylist.push({ anim: T, audio: h }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5510
+ const G = [...t.anim, ...k];
5511
+ this.audioPlaylist.push({ anim: G, audio: h }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5512
5512
  e();
5513
- }, s.onerror = (p) => {
5514
- console.error("Speech synthesis error:", p.error), n(p.error);
5513
+ }, s.onerror = (m) => {
5514
+ console.error("Speech synthesis error:", m.error), n(m.error);
5515
5515
  }, speechSynthesis.speak(s);
5516
5516
  });
5517
5517
  }
@@ -5572,15 +5572,15 @@ class Qe {
5572
5572
  console.error("Text-based lip-sync failed, using fallback:", d);
5573
5573
  const h = e.toLowerCase().split(/\s+/), g = [];
5574
5574
  for (const R of h)
5575
- for (const b of R) {
5575
+ for (const x of R) {
5576
5576
  let k = "aa";
5577
- "aeiou".includes(b) ? k = "aa" : "bp".includes(b) ? k = "PP" : "fv".includes(b) ? k = "FF" : "st".includes(b) ? k = "SS" : "dln".includes(b) ? k = "DD" : "kg".includes(b) ? k = "kk" : "rw".includes(b) && (k = "RR"), g.push(k);
5577
+ "aeiou".includes(x) ? k = "aa" : "bp".includes(x) ? k = "PP" : "fv".includes(x) ? k = "FF" : "st".includes(x) ? k = "SS" : "dln".includes(x) ? k = "DD" : "kg".includes(x) ? k = "kk" : "rw".includes(x) && (k = "RR"), g.push(k);
5578
5578
  }
5579
5579
  l = {
5580
- visemes: g.map((R, b) => ({
5580
+ visemes: g.map((R, x) => ({
5581
5581
  viseme: R,
5582
- startTime: b * a.duration / g.length,
5583
- endTime: (b + 1) * a.duration / g.length,
5582
+ startTime: x * a.duration / g.length,
5583
+ endTime: (x + 1) * a.duration / g.length,
5584
5584
  duration: a.duration / g.length,
5585
5585
  intensity: 0.6
5586
5586
  })),
@@ -5592,12 +5592,12 @@ class Qe {
5592
5592
  const u = [];
5593
5593
  if (l.visemes && l.visemes.length > 0)
5594
5594
  for (let d = 0; d < l.visemes.length; d++) {
5595
- const h = l.visemes[d], g = h.startTime * 1e3, R = h.duration * 1e3, b = h.intensity;
5595
+ const h = l.visemes[d], g = h.startTime * 1e3, R = h.duration * 1e3, x = h.intensity;
5596
5596
  u.push({
5597
5597
  template: { name: "viseme" },
5598
5598
  ts: [g - Math.min(60, 2 * R / 3), g + Math.min(25, R / 2), g + R + Math.min(60, R / 2)],
5599
5599
  vs: {
5600
- ["viseme_" + h.viseme]: [null, b, 0]
5600
+ ["viseme_" + h.viseme]: [null, x, 0]
5601
5601
  }
5602
5602
  });
5603
5603
  }
@@ -5654,15 +5654,15 @@ class Qe {
5654
5654
  console.error("Text-based lip-sync failed, using fallback:", d);
5655
5655
  const h = e.toLowerCase().split(/\s+/), g = [];
5656
5656
  for (const R of h)
5657
- for (const b of R) {
5657
+ for (const x of R) {
5658
5658
  let k = "aa";
5659
- "aeiou".includes(b) ? k = "aa" : "bp".includes(b) ? k = "PP" : "fv".includes(b) ? k = "FF" : "st".includes(b) ? k = "SS" : "dln".includes(b) ? k = "DD" : "kg".includes(b) ? k = "kk" : "rw".includes(b) && (k = "RR"), g.push(k);
5659
+ "aeiou".includes(x) ? k = "aa" : "bp".includes(x) ? k = "PP" : "fv".includes(x) ? k = "FF" : "st".includes(x) ? k = "SS" : "dln".includes(x) ? k = "DD" : "kg".includes(x) ? k = "kk" : "rw".includes(x) && (k = "RR"), g.push(k);
5660
5660
  }
5661
5661
  l = {
5662
- visemes: g.map((R, b) => ({
5662
+ visemes: g.map((R, x) => ({
5663
5663
  viseme: R,
5664
- startTime: b * a.duration / g.length,
5665
- endTime: (b + 1) * a.duration / g.length,
5664
+ startTime: x * a.duration / g.length,
5665
+ endTime: (x + 1) * a.duration / g.length,
5666
5666
  duration: a.duration / g.length,
5667
5667
  intensity: 0.6
5668
5668
  })),
@@ -5674,12 +5674,12 @@ class Qe {
5674
5674
  const u = [];
5675
5675
  if (l.visemes && l.visemes.length > 0)
5676
5676
  for (let d = 0; d < l.visemes.length; d++) {
5677
- const h = l.visemes[d], g = h.startTime * 1e3, R = h.duration * 1e3, b = h.intensity;
5677
+ const h = l.visemes[d], g = h.startTime * 1e3, R = h.duration * 1e3, x = h.intensity;
5678
5678
  u.push({
5679
5679
  template: { name: "viseme" },
5680
5680
  ts: [g - Math.min(60, 2 * R / 3), g + Math.min(25, R / 2), g + R + Math.min(60, R / 2)],
5681
5681
  vs: {
5682
- ["viseme_" + h.viseme]: [null, b, 0]
5682
+ ["viseme_" + h.viseme]: [null, x, 0]
5683
5683
  }
5684
5684
  });
5685
5685
  }
@@ -5861,7 +5861,7 @@ class Qe {
5861
5861
  }
5862
5862
  if (!this.workletLoaded)
5863
5863
  try {
5864
- const a = this.audioCtx.audioWorklet.addModule(kt.href), c = new Promise(
5864
+ const a = this.audioCtx.audioWorklet.addModule(wt.href), c = new Promise(
5865
5865
  (l, u) => setTimeout(() => u(new Error("Worklet loading timed out")), 5e3)
5866
5866
  );
5867
5867
  await Promise.race([a, c]), this.workletLoaded = !0;
@@ -6099,7 +6099,7 @@ class Qe {
6099
6099
  */
6100
6100
  lookAtCamera(t) {
6101
6101
  let e;
6102
- if (this.speakTo && (e = new x.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(Te, Ee).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) {
6102
+ if (this.speakTo && (e = new b.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(Te, Ee).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) {
6103
6103
  if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
6104
6104
  if (this.avatar.avatarIgnoreCamera) {
6105
6105
  this.lookAhead(t);
@@ -6112,16 +6112,16 @@ class Qe {
6112
6112
  this.lookAt(null, null, t);
6113
6113
  return;
6114
6114
  }
6115
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.objectRightEye.matrixWorld), Te.add(Ee).divideScalar(2), oe.copy(this.armature.quaternion), oe.multiply(this.poseTarget.props["Hips.quaternion"]), oe.multiply(this.poseTarget.props["Spine.quaternion"]), oe.multiply(this.poseTarget.props["Spine1.quaternion"]), oe.multiply(this.poseTarget.props["Spine2.quaternion"]), oe.multiply(this.poseTarget.props["Neck.quaternion"]), oe.multiply(this.poseTarget.props["Head.quaternion"]);
6116
- const n = new x.Vector3().subVectors(e, Te).normalize(), o = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6117
- Q.set(s, o, 0, "YXZ");
6118
- const a = new x.Quaternion().setFromEuler(Q), c = new x.Quaternion().copy(a).multiply(oe.clone().invert());
6119
- Q.setFromQuaternion(c, "YXZ");
6120
- let l = Q.x / (40 / 24) + 0.2, u = Q.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, l)), d = Math.min(0.8, Math.max(-0.8, u)), h = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6115
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), Te.setFromMatrixPosition(this.objectLeftEye.matrixWorld), Ee.setFromMatrixPosition(this.objectRightEye.matrixWorld), Te.add(Ee).divideScalar(2), ne.copy(this.armature.quaternion), ne.multiply(this.poseTarget.props["Hips.quaternion"]), ne.multiply(this.poseTarget.props["Spine.quaternion"]), ne.multiply(this.poseTarget.props["Spine1.quaternion"]), ne.multiply(this.poseTarget.props["Spine2.quaternion"]), ne.multiply(this.poseTarget.props["Neck.quaternion"]), ne.multiply(this.poseTarget.props["Head.quaternion"]);
6116
+ const n = new b.Vector3().subVectors(e, Te).normalize(), o = Math.atan2(n.x, n.z), s = Math.asin(-n.y);
6117
+ q.set(s, o, 0, "YXZ");
6118
+ const a = new b.Quaternion().setFromEuler(q), c = new b.Quaternion().copy(a).multiply(ne.clone().invert());
6119
+ q.setFromQuaternion(c, "YXZ");
6120
+ let l = q.x / (40 / 24) + 0.2, u = q.y / (9 / 4), r = Math.min(0.6, Math.max(-0.3, l)), d = Math.min(0.8, Math.max(-0.8, u)), h = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6121
6121
  if (t) {
6122
6122
  let R = this.animQueue.findIndex((k) => k.template.name === "lookat");
6123
6123
  R !== -1 && this.animQueue.splice(R, 1);
6124
- const b = {
6124
+ const x = {
6125
6125
  name: "lookat",
6126
6126
  dt: [750, t],
6127
6127
  vs: {
@@ -6136,7 +6136,7 @@ class Qe {
6136
6136
  headMove: [0]
6137
6137
  }
6138
6138
  };
6139
- this.animQueue.push(this.animFactory(b));
6139
+ this.animQueue.push(this.animFactory(x));
6140
6140
  }
6141
6141
  }
6142
6142
  /**
@@ -6149,24 +6149,24 @@ class Qe {
6149
6149
  if (!this.camera) return;
6150
6150
  const o = this.nodeAvatar.getBoundingClientRect();
6151
6151
  this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0);
6152
- const s = new x.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), i = new x.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), a = new x.Vector3().addVectors(s, i).divideScalar(2);
6152
+ const s = new b.Vector3().setFromMatrixPosition(this.objectLeftEye.matrixWorld), i = new b.Vector3().setFromMatrixPosition(this.objectRightEye.matrixWorld), a = new b.Vector3().addVectors(s, i).divideScalar(2);
6153
6153
  a.project(this.camera);
6154
6154
  let c = (a.x + 1) / 2 * o.width + o.left, l = -(a.y - 1) / 2 * o.height + o.top;
6155
- t === null && (t = c), e === null && (e = l), oe.copy(this.armature.quaternion), oe.multiply(this.poseTarget.props["Hips.quaternion"]), oe.multiply(this.poseTarget.props["Spine.quaternion"]), oe.multiply(this.poseTarget.props["Spine1.quaternion"]), oe.multiply(this.poseTarget.props["Spine2.quaternion"]), oe.multiply(this.poseTarget.props["Neck.quaternion"]), oe.multiply(this.poseTarget.props["Head.quaternion"]), Q.setFromQuaternion(oe);
6156
- let u = Q.x / (40 / 24), r = Q.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), h = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - c, c), R = Math.max(window.innerHeight - l, l), b = this.convertRange(e, [l - R, l + R], [-0.3, 0.6]) - u + d, k = this.convertRange(t, [c - g, c + g], [-0.8, 0.8]) - r + h;
6157
- b = Math.min(0.6, Math.max(-0.3, b)), k = Math.min(0.8, Math.max(-0.8, k));
6158
- let T = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6155
+ t === null && (t = c), e === null && (e = l), ne.copy(this.armature.quaternion), ne.multiply(this.poseTarget.props["Hips.quaternion"]), ne.multiply(this.poseTarget.props["Spine.quaternion"]), ne.multiply(this.poseTarget.props["Spine1.quaternion"]), ne.multiply(this.poseTarget.props["Spine2.quaternion"]), ne.multiply(this.poseTarget.props["Neck.quaternion"]), ne.multiply(this.poseTarget.props["Head.quaternion"]), q.setFromQuaternion(ne);
6156
+ let u = q.x / (40 / 24), r = q.y / (9 / 4), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), h = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - c, c), R = Math.max(window.innerHeight - l, l), x = this.convertRange(e, [l - R, l + R], [-0.3, 0.6]) - u + d, k = this.convertRange(t, [c - g, c + g], [-0.8, 0.8]) - r + h;
6157
+ x = Math.min(0.6, Math.max(-0.3, x)), k = Math.min(0.8, Math.max(-0.8, k));
6158
+ let G = (Math.random() - 0.5) / 4, m = (Math.random() - 0.5) / 4;
6159
6159
  if (n) {
6160
- let O = this.animQueue.findIndex((y) => y.template.name === "lookat");
6161
- O !== -1 && this.animQueue.splice(O, 1);
6162
- const E = {
6160
+ let B = this.animQueue.findIndex((y) => y.template.name === "lookat");
6161
+ B !== -1 && this.animQueue.splice(B, 1);
6162
+ const M = {
6163
6163
  name: "lookat",
6164
6164
  dt: [750, n],
6165
6165
  vs: {
6166
- bodyRotateX: [b + T],
6167
- bodyRotateY: [k + p],
6168
- eyesRotateX: [-3 * T + 0.1],
6169
- eyesRotateY: [-5 * p],
6166
+ bodyRotateX: [x + G],
6167
+ bodyRotateY: [k + m],
6168
+ eyesRotateX: [-3 * G + 0.1],
6169
+ eyesRotateY: [-5 * m],
6170
6170
  browInnerUp: [[0, 0.7]],
6171
6171
  mouthLeft: [[0, 0.7]],
6172
6172
  mouthRight: [[0, 0.7]],
@@ -6174,7 +6174,7 @@ class Qe {
6174
6174
  headMove: [0]
6175
6175
  }
6176
6176
  };
6177
- this.animQueue.push(this.animFactory(E));
6177
+ this.animQueue.push(this.animFactory(M));
6178
6178
  }
6179
6179
  }
6180
6180
  /**
@@ -6185,14 +6185,14 @@ class Qe {
6185
6185
  */
6186
6186
  touchAt(t, e) {
6187
6187
  if (!this.camera) return;
6188
- const n = this.nodeAvatar.getBoundingClientRect(), o = new x.Vector2(
6188
+ const n = this.nodeAvatar.getBoundingClientRect(), o = new b.Vector2(
6189
6189
  (t - n.left) / n.width * 2 - 1,
6190
6190
  -((e - n.top) / n.height) * 2 + 1
6191
- ), s = new x.Raycaster();
6191
+ ), s = new b.Raycaster();
6192
6192
  s.setFromCamera(o, this.camera);
6193
6193
  const i = s.intersectObject(this.armature);
6194
6194
  if (i.length > 0) {
6195
- const a = i[0].point, c = new x.Vector3(), l = new x.Vector3();
6195
+ const a = i[0].point, c = new b.Vector3(), l = new b.Vector3();
6196
6196
  this.objectLeftArm.getWorldPosition(c), this.objectRightArm.getWorldPosition(l);
6197
6197
  const u = c.distanceToSquared(a), r = l.distanceToSquared(a);
6198
6198
  u < r ? (this.ikSolve({
@@ -6236,7 +6236,7 @@ class Qe {
6236
6236
  { link: "LeftForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -0.5, maxz: 3 },
6237
6237
  { link: "LeftArm", minx: -1.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -1, maxz: 3 }
6238
6238
  ]
6239
- }, new x.Vector3(
6239
+ }, new b.Vector3(
6240
6240
  this.gaussianRandom(0, 0.5),
6241
6241
  this.gaussianRandom(-0.8, -0.2),
6242
6242
  this.gaussianRandom(0, 0.5)
@@ -6248,15 +6248,15 @@ class Qe {
6248
6248
  { link: "RightForeArm", minx: -0.5, maxx: 1.5, miny: -1.5, maxy: 1.5, minz: -3, maxz: 0.5 },
6249
6249
  { link: "RightArm" }
6250
6250
  ]
6251
- }, new x.Vector3(
6251
+ }, new b.Vector3(
6252
6252
  this.gaussianRandom(-0.5, 0),
6253
6253
  this.gaussianRandom(-0.8, -0.2),
6254
6254
  this.gaussianRandom(0, 0.5)
6255
6255
  ), !0);
6256
6256
  const n = [], o = [];
6257
6257
  n.push(100 + Math.round(Math.random() * 500)), o.push({ duration: 1e3, props: {
6258
- "LeftHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, -1 - Math.random(), 0)),
6259
- "RightHand.quaternion": new x.Quaternion().setFromEuler(new x.Euler(0, 1 + Math.random(), 0))
6258
+ "LeftHand.quaternion": new b.Quaternion().setFromEuler(new b.Euler(0, -1 - Math.random(), 0)),
6259
+ "RightHand.quaternion": new b.Quaternion().setFromEuler(new b.Euler(0, 1 + Math.random(), 0))
6260
6260
  } }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm"].forEach((i) => {
6261
6261
  o[0].props[i + ".quaternion"] = this.ikMesh.getObjectByName(i).quaternion.clone();
6262
6262
  }), n.push(1e3 + Math.round(Math.random() * 500)), o.push({ duration: 2e3, props: {} }), ["LeftArm", "LeftForeArm", "RightArm", "RightForeArm", "LeftHand", "RightHand"].forEach((i) => {
@@ -6341,7 +6341,7 @@ class Qe {
6341
6341
  let l = this.animQueue.find((h) => h.template.name === "pose");
6342
6342
  l && (l.ts[0] = 1 / 0), Object.entries(c.pose.props).forEach((h) => {
6343
6343
  this.poseBase.props[h[0]] = h[1].clone(), this.poseTarget.props[h[0]] = h[1].clone(), this.poseTarget.props[h[0]].t = 0, this.poseTarget.props[h[0]].d = 1e3;
6344
- }), this.mixer || (this.mixer = new x.AnimationMixer(this.armature)), this.animationFinishedCallback = a;
6344
+ }), this.mixer || (this.mixer = new b.AnimationMixer(this.armature)), this.animationFinishedCallback = a;
6345
6345
  const u = () => {
6346
6346
  this.animationFinishedCallback && (this.animationFinishedCallback(), this.animationFinishedCallback = null), this.stopAnimation();
6347
6347
  };
@@ -6349,7 +6349,7 @@ class Qe {
6349
6349
  let r = 1;
6350
6350
  n > 0 && (r = Math.ceil(n / c.clip.duration));
6351
6351
  const d = this.mixer.clipAction(c.clip);
6352
- if (d.setLoop(x.LoopRepeat, r), d.clampWhenFinished = !0, this.currentFBXAction && this.currentFBXAction.isRunning()) {
6352
+ if (d.setLoop(b.LoopRepeat, r), d.clampWhenFinished = !0, this.currentFBXAction && this.currentFBXAction.isRunning()) {
6353
6353
  this.currentFBXAction.fadeOut(0.3), setTimeout(() => {
6354
6354
  this.currentFBXAction = d;
6355
6355
  try {
@@ -6386,7 +6386,7 @@ class Qe {
6386
6386
  } catch (h) {
6387
6387
  console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, h);
6388
6388
  }
6389
- const r = new _e();
6389
+ const r = new Je();
6390
6390
  let d;
6391
6391
  try {
6392
6392
  d = await r.loadAsync(t, e);
@@ -6397,13 +6397,13 @@ class Qe {
6397
6397
  suggestion: "Make sure the file is a valid FBX file and the path is correct"
6398
6398
  }), h.message && h.message.includes("version number") && (console.error("FBX Loader Error: Cannot find version number"), console.error("This error usually means:"), console.error("1. The file is not a valid FBX file (might be GLB, corrupted, or wrong format)"), console.error("2. The file might be corrupted"), console.error("3. The file path might be incorrect"), console.error("4. The server returned an HTML error page instead of the FBX file"), console.error("5. The file might not exist at that path"), console.error(""), console.error("Solution: Please verify:"), console.error(` - File exists at: ${t}`), console.error(" - File is a valid FBX binary file"), console.error(" - File path matches your public folder structure"), console.error(" - File is not corrupted"));
6399
6399
  try {
6400
- const g = await fetch(t), R = g.headers.get("content-type"), b = await g.text();
6400
+ const g = await fetch(t), R = g.headers.get("content-type"), x = await g.text();
6401
6401
  console.error("Response details:", {
6402
6402
  status: g.status,
6403
6403
  contentType: R,
6404
- firstBytes: b.substring(0, 100),
6405
- isHTML: b.trim().startsWith("<!DOCTYPE") || b.trim().startsWith("<html")
6406
- }), (b.trim().startsWith("<!DOCTYPE") || b.trim().startsWith("<html")) && console.error("The server returned an HTML page instead of an FBX file. The file path is likely incorrect.");
6404
+ firstBytes: x.substring(0, 100),
6405
+ isHTML: x.trim().startsWith("<!DOCTYPE") || x.trim().startsWith("<html")
6406
+ }), (x.trim().startsWith("<!DOCTYPE") || x.trim().startsWith("<html")) && console.error("The server returned an HTML page instead of an FBX file. The file path is likely incorrect.");
6407
6407
  } catch (g) {
6408
6408
  console.error("Could not fetch file for debugging:", g);
6409
6409
  }
@@ -6415,36 +6415,36 @@ class Qe {
6415
6415
  this.armature && this.armature.traverse((y) => {
6416
6416
  (y.isBone || y.type === "Bone") && g.add(y.name);
6417
6417
  });
6418
- const R = /* @__PURE__ */ new Map(), b = (y) => {
6418
+ const R = /* @__PURE__ */ new Map(), x = (y) => {
6419
6419
  if (g.has(y))
6420
6420
  return y;
6421
6421
  let F = y.replace(/^mixamorig/i, "").replace(/^CC_Base_/i, "").replace(/^RPM_/i, "");
6422
6422
  if (g.has(F))
6423
6423
  return F;
6424
- const f = F.toLowerCase();
6425
- if (f.includes("left") && f.includes("arm")) {
6426
- if (f.includes("fore") || f.includes("lower")) {
6424
+ const L = F.toLowerCase();
6425
+ if (L.includes("left") && L.includes("arm")) {
6426
+ if (L.includes("fore") || L.includes("lower")) {
6427
6427
  if (g.has("LeftForeArm")) return "LeftForeArm";
6428
6428
  if (g.has("LeftForearm")) return "LeftForearm";
6429
- } else if (!f.includes("fore") && !f.includes("hand") && g.has("LeftArm"))
6429
+ } else if (!L.includes("fore") && !L.includes("hand") && g.has("LeftArm"))
6430
6430
  return "LeftArm";
6431
6431
  }
6432
- if (f.includes("right") && f.includes("arm")) {
6433
- if (f.includes("fore") || f.includes("lower")) {
6432
+ if (L.includes("right") && L.includes("arm")) {
6433
+ if (L.includes("fore") || L.includes("lower")) {
6434
6434
  if (g.has("RightForeArm")) return "RightForeArm";
6435
6435
  if (g.has("RightForearm")) return "RightForearm";
6436
- } else if (!f.includes("fore") && !f.includes("hand") && g.has("RightArm"))
6436
+ } else if (!L.includes("fore") && !L.includes("hand") && g.has("RightArm"))
6437
6437
  return "RightArm";
6438
6438
  }
6439
- if (f.includes("left") && f.includes("hand") && !f.includes("index") && !f.includes("thumb") && !f.includes("middle") && !f.includes("ring") && !f.includes("pinky") && g.has("LeftHand"))
6439
+ if (L.includes("left") && L.includes("hand") && !L.includes("index") && !L.includes("thumb") && !L.includes("middle") && !L.includes("ring") && !L.includes("pinky") && g.has("LeftHand"))
6440
6440
  return "LeftHand";
6441
- if (f.includes("right") && f.includes("hand") && !f.includes("index") && !f.includes("thumb") && !f.includes("middle") && !f.includes("ring") && !f.includes("pinky") && g.has("RightHand"))
6441
+ if (L.includes("right") && L.includes("hand") && !L.includes("index") && !L.includes("thumb") && !L.includes("middle") && !L.includes("ring") && !L.includes("pinky") && g.has("RightHand"))
6442
6442
  return "RightHand";
6443
- if (f.includes("left") && (f.includes("shoulder") || f.includes("clavicle")) && g.has("LeftShoulder"))
6443
+ if (L.includes("left") && (L.includes("shoulder") || L.includes("clavicle")) && g.has("LeftShoulder"))
6444
6444
  return "LeftShoulder";
6445
- if (f.includes("right") && (f.includes("shoulder") || f.includes("clavicle")) && g.has("RightShoulder"))
6445
+ if (L.includes("right") && (L.includes("shoulder") || L.includes("clavicle")) && g.has("RightShoulder"))
6446
6446
  return "RightShoulder";
6447
- const w = {
6447
+ const f = {
6448
6448
  // Arm bones - exact matches
6449
6449
  LeftArm: "LeftArm",
6450
6450
  leftArm: "LeftArm",
@@ -6484,18 +6484,18 @@ class Qe {
6484
6484
  Root: "Hips",
6485
6485
  root: "Hips"
6486
6486
  };
6487
- if (w[F]) {
6488
- const H = w[F];
6489
- if (g.has(H))
6490
- return H;
6487
+ if (f[F]) {
6488
+ const T = f[F];
6489
+ if (g.has(T))
6490
+ return T;
6491
6491
  }
6492
- for (const H of g)
6493
- if (H.toLowerCase() === f)
6494
- return H;
6495
- for (const H of g) {
6496
- const I = H.toLowerCase();
6497
- if ((f.includes("left") && I.includes("left") || f.includes("right") && I.includes("right")) && (f.includes("arm") && I.includes("arm") && !I.includes("fore") || f.includes("forearm") && I.includes("forearm") || f.includes("hand") && I.includes("hand") && !I.includes("index") && !I.includes("thumb") || f.includes("shoulder") && I.includes("shoulder")))
6498
- return H;
6492
+ for (const T of g)
6493
+ if (T.toLowerCase() === L)
6494
+ return T;
6495
+ for (const T of g) {
6496
+ const A = T.toLowerCase();
6497
+ if ((L.includes("left") && A.includes("left") || L.includes("right") && A.includes("right")) && (L.includes("arm") && A.includes("arm") && !A.includes("fore") || L.includes("forearm") && A.includes("forearm") || L.includes("hand") && A.includes("hand") && !A.includes("index") && !A.includes("thumb") || L.includes("shoulder") && A.includes("shoulder")))
6498
+ return T;
6499
6499
  }
6500
6500
  return null;
6501
6501
  }, k = /* @__PURE__ */ new Set();
@@ -6507,31 +6507,31 @@ class Qe {
6507
6507
  ), Array.from(g).filter(
6508
6508
  (y) => y.includes("Arm") || y.includes("Hand") || y.includes("Shoulder")
6509
6509
  );
6510
- const T = [], p = /* @__PURE__ */ new Set();
6510
+ const G = [], m = /* @__PURE__ */ new Set();
6511
6511
  h.tracks.forEach((y) => {
6512
- const f = y.name.replaceAll("mixamorig", "").split("."), w = f[0], H = f[1], I = b(w);
6513
- if (!(I && (I === "LeftShoulder" || I === "RightShoulder") && (H === "quaternion" || H === "rotation")))
6514
- if (I && H) {
6515
- const U = `${I}.${H}`, G = y.clone();
6516
- G.name = U, T.push(G), w !== I && R.set(w, I);
6512
+ const L = y.name.replaceAll("mixamorig", "").split("."), f = L[0], T = L[1], A = x(f);
6513
+ if (!(A && (A === "LeftShoulder" || A === "RightShoulder") && (T === "quaternion" || T === "rotation")))
6514
+ if (A && T) {
6515
+ const D = `${A}.${T}`, U = y.clone();
6516
+ U.name = D, G.push(U), f !== A && R.set(f, A);
6517
6517
  } else
6518
- p.add(w), (w.toLowerCase().includes("arm") || w.toLowerCase().includes("hand") || w.toLowerCase().includes("shoulder")) && console.warn(`⚠️ Arm bone "${w}" could not be mapped to avatar skeleton`);
6519
- }), T.length > 0 ? h = new x.AnimationClip(h.name, h.duration, T) : console.error("No tracks could be mapped! Animation may not work correctly.");
6520
- const O = {};
6518
+ m.add(f), (f.toLowerCase().includes("arm") || f.toLowerCase().includes("hand") || f.toLowerCase().includes("shoulder")) && console.warn(`⚠️ Arm bone "${f}" could not be mapped to avatar skeleton`);
6519
+ }), G.length > 0 ? h = new b.AnimationClip(h.name, h.duration, G) : console.error("No tracks could be mapped! Animation may not work correctly.");
6520
+ const B = {};
6521
6521
  h.tracks.forEach((y) => {
6522
6522
  y.name = y.name.replaceAll("mixamorig", "");
6523
6523
  const F = y.name.split(".");
6524
6524
  if (F[1] === "position") {
6525
- for (let f = 0; f < y.values.length; f++)
6526
- y.values[f] = y.values[f] * s;
6527
- O[y.name] = new x.Vector3(y.values[0], y.values[1], y.values[2]);
6528
- } else F[1] === "quaternion" ? O[y.name] = new x.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : F[1] === "rotation" && (O[F[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6525
+ for (let L = 0; L < y.values.length; L++)
6526
+ y.values[L] = y.values[L] * s;
6527
+ B[y.name] = new b.Vector3(y.values[0], y.values[1], y.values[2]);
6528
+ } else F[1] === "quaternion" ? B[y.name] = new b.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : F[1] === "rotation" && (B[F[0] + ".quaternion"] = new b.Quaternion().setFromEuler(new b.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6529
6529
  });
6530
- const E = { props: O };
6531
- O["Hips.position"] && (O["Hips.position"].y < 0.5 ? E.lying = !0 : E.standing = !0), this.animClips.push({
6530
+ const M = { props: B };
6531
+ B["Hips.position"] && (B["Hips.position"].y < 0.5 ? M.lying = !0 : M.standing = !0), this.animClips.push({
6532
6532
  url: t + "-" + o,
6533
6533
  clip: h,
6534
- pose: E
6534
+ pose: M
6535
6535
  }), this.playAnimation(t, e, n, o, s);
6536
6536
  } else {
6537
6537
  const h = "Animation " + t + " (ndx=" + o + ") not found";
@@ -6569,14 +6569,14 @@ class Qe {
6569
6569
  let a = this.animQueue.find((c) => c.template.name === "pose");
6570
6570
  a && (a.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(i);
6571
6571
  } else {
6572
- let c = await new _e().loadAsync(t, e);
6572
+ let c = await new Je().loadAsync(t, e);
6573
6573
  if (c && c.animations && c.animations[o]) {
6574
6574
  let l = c.animations[o];
6575
6575
  const u = {};
6576
6576
  l.tracks.forEach((d) => {
6577
6577
  d.name = d.name.replaceAll("mixamorig", "");
6578
6578
  const h = d.name.split(".");
6579
- h[1] === "position" ? u[d.name] = new x.Vector3(d.values[0] * s, d.values[1] * s, d.values[2] * s) : h[1] === "quaternion" ? u[d.name] = new x.Quaternion(d.values[0], d.values[1], d.values[2], d.values[3]) : h[1] === "rotation" && (u[h[0] + ".quaternion"] = new x.Quaternion().setFromEuler(new x.Euler(d.values[0], d.values[1], d.values[2], "XYZ")).normalize());
6579
+ h[1] === "position" ? u[d.name] = new b.Vector3(d.values[0] * s, d.values[1] * s, d.values[2] * s) : h[1] === "quaternion" ? u[d.name] = new b.Quaternion(d.values[0], d.values[1], d.values[2], d.values[3]) : h[1] === "rotation" && (u[h[0] + ".quaternion"] = new b.Quaternion().setFromEuler(new b.Euler(d.values[0], d.values[1], d.values[2], "XYZ")).normalize());
6580
6580
  });
6581
6581
  const r = { props: u };
6582
6582
  u["Hips.position"] && (u["Hips.position"].y < 0.5 ? r.lying = !0 : r.standing = !0), this.animPoses.push({
@@ -6609,7 +6609,7 @@ class Qe {
6609
6609
  if (s) {
6610
6610
  this.gestureTimeout && (clearTimeout(this.gestureTimeout), this.gestureTimeout = null);
6611
6611
  let a = this.animQueue.findIndex((c) => c.template.name === "talkinghands");
6612
- a !== -1 && (this.animQueue[a].ts = this.animQueue[a].ts.map((c) => 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 x.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new x.Quaternion(0, 1, 0, 0), -0.25));
6612
+ a !== -1 && (this.animQueue[a].ts = this.animQueue[a].ts.map((c) => 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 b.Quaternion(0, 1, 0, 0), -0.25), this.gesture["LeftArm.quaternion"].rotateTowards(new b.Quaternion(0, 1, 0, 0), -0.25));
6613
6613
  for (let [c, l] of Object.entries(this.gesture))
6614
6614
  l.t = this.animClock, l.d = o, this.poseTarget.props.hasOwnProperty(c) && (this.poseTarget.props[c].copy(l), this.poseTarget.props[c].t = this.animClock, this.poseTarget.props[c].d = o);
6615
6615
  e && Number.isFinite(e) && (this.gestureTimeout = setTimeout(this.stopGesture.bind(this, o), 1e3 * e));
@@ -6624,7 +6624,7 @@ class Qe {
6624
6624
  const d = [];
6625
6625
  for (let R = 1; R < a.ts.length; R++) d.push(a.ts[R] - a.ts[R - 1]);
6626
6626
  const h = i.template?.rescale || d.map((R) => R / u), g = e * 1e3 - u;
6627
- a.ts = a.ts.map((R, b, k) => b === 0 ? c : k[b - 1] + d[b - 1] + h[b - 1] * g);
6627
+ a.ts = a.ts.map((R, x, k) => x === 0 ? c : k[x - 1] + d[x - 1] + h[x - 1] * g);
6628
6628
  } else {
6629
6629
  const d = e * 1e3 / u;
6630
6630
  a.ts = a.ts.map((h) => c + d * (h - c));
@@ -6657,31 +6657,31 @@ class Qe {
6657
6657
  * @param {numeric} [d=null] If set, apply in d milliseconds
6658
6658
  */
6659
6659
  ikSolve(t, e = null, n = !1, o = null) {
6660
- const s = new x.Vector3(), i = new x.Vector3(), a = new x.Vector3(), c = new x.Vector3(), l = new x.Quaternion(), u = new x.Vector3(), r = new x.Vector3(), d = new x.Vector3(), h = this.ikMesh.getObjectByName(t.root);
6660
+ const s = new b.Vector3(), i = new b.Vector3(), a = new b.Vector3(), c = new b.Vector3(), l = new b.Quaternion(), u = new b.Vector3(), r = new b.Vector3(), d = new b.Vector3(), h = this.ikMesh.getObjectByName(t.root);
6661
6661
  h.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), h.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(h.position);
6662
6662
  const g = this.ikMesh.getObjectByName(t.effector), R = t.links;
6663
6663
  R.forEach((k) => {
6664
6664
  k.bone = this.ikMesh.getObjectByName(k.link), k.bone.quaternion.copy(this.getPoseTemplateProp(k.link + ".quaternion"));
6665
6665
  }), h.updateMatrixWorld(!0);
6666
- const b = t.iterations || 10;
6666
+ const x = t.iterations || 10;
6667
6667
  if (e)
6668
- for (let k = 0; k < b; k++) {
6669
- let T = !1;
6670
- for (let p = 0, O = R.length; p < O; p++) {
6671
- const E = R[p].bone;
6672
- E.matrixWorld.decompose(c, l, u), l.invert(), i.setFromMatrixPosition(g.matrixWorld), a.subVectors(i, c), a.applyQuaternion(l), a.normalize(), s.subVectors(e, c), s.applyQuaternion(l), s.normalize();
6668
+ for (let k = 0; k < x; k++) {
6669
+ let G = !1;
6670
+ for (let m = 0, B = R.length; m < B; m++) {
6671
+ const M = R[m].bone;
6672
+ M.matrixWorld.decompose(c, l, u), l.invert(), i.setFromMatrixPosition(g.matrixWorld), a.subVectors(i, c), a.applyQuaternion(l), a.normalize(), s.subVectors(e, c), s.applyQuaternion(l), s.normalize();
6673
6673
  let y = s.dot(a);
6674
- y > 1 ? y = 1 : y < -1 && (y = -1), y = Math.acos(y), !(y < 1e-5) && (R[p].minAngle !== void 0 && y < R[p].minAngle && (y = R[p].minAngle), R[p].maxAngle !== void 0 && y > R[p].maxAngle && (y = R[p].maxAngle), r.crossVectors(a, s), r.normalize(), oe.setFromAxisAngle(r, y), E.quaternion.multiply(oe), E.rotation.setFromVector3(d.setFromEuler(E.rotation).clamp(new x.Vector3(
6675
- R[p].minx !== void 0 ? R[p].minx : -1 / 0,
6676
- R[p].miny !== void 0 ? R[p].miny : -1 / 0,
6677
- R[p].minz !== void 0 ? R[p].minz : -1 / 0
6678
- ), new x.Vector3(
6679
- R[p].maxx !== void 0 ? R[p].maxx : 1 / 0,
6680
- R[p].maxy !== void 0 ? R[p].maxy : 1 / 0,
6681
- R[p].maxz !== void 0 ? R[p].maxz : 1 / 0
6682
- ))), E.updateMatrixWorld(!0), T = !0);
6674
+ y > 1 ? y = 1 : y < -1 && (y = -1), y = Math.acos(y), !(y < 1e-5) && (R[m].minAngle !== void 0 && y < R[m].minAngle && (y = R[m].minAngle), R[m].maxAngle !== void 0 && y > R[m].maxAngle && (y = R[m].maxAngle), r.crossVectors(a, s), r.normalize(), ne.setFromAxisAngle(r, y), M.quaternion.multiply(ne), M.rotation.setFromVector3(d.setFromEuler(M.rotation).clamp(new b.Vector3(
6675
+ R[m].minx !== void 0 ? R[m].minx : -1 / 0,
6676
+ R[m].miny !== void 0 ? R[m].miny : -1 / 0,
6677
+ R[m].minz !== void 0 ? R[m].minz : -1 / 0
6678
+ ), new b.Vector3(
6679
+ R[m].maxx !== void 0 ? R[m].maxx : 1 / 0,
6680
+ R[m].maxy !== void 0 ? R[m].maxy : 1 / 0,
6681
+ R[m].maxz !== void 0 ? R[m].maxz : 1 / 0
6682
+ ))), M.updateMatrixWorld(!0), G = !0);
6683
6683
  }
6684
- if (!T) break;
6684
+ if (!G) break;
6685
6685
  }
6686
6686
  o && R.forEach((k) => {
6687
6687
  this.poseTarget.props[k.link + ".quaternion"].copy(k.bone.quaternion), this.poseTarget.props[k.link + ".quaternion"].t = this.animClock, this.poseTarget.props[k.link + ".quaternion"].d = o;
@@ -6714,7 +6714,7 @@ const Pe = {
6714
6714
  josh: "VR6AewLTigWG4xSOukaG"
6715
6715
  // Male, American
6716
6716
  }
6717
- }, Ze = {
6717
+ }, je = {
6718
6718
  defaultVoice: "aura-2-thalia-en",
6719
6719
  // Thalia (Female, English)
6720
6720
  voices: {
@@ -6734,7 +6734,7 @@ const Pe = {
6734
6734
  // Male, English - Powerful
6735
6735
  }
6736
6736
  };
6737
- function Ye() {
6737
+ function qe() {
6738
6738
  return {
6739
6739
  service: "elevenlabs",
6740
6740
  endpoint: Pe.endpoint,
@@ -6743,17 +6743,17 @@ function Ye() {
6743
6743
  voices: Pe.voices
6744
6744
  };
6745
6745
  }
6746
- function Ut() {
6747
- const V = Ye(), t = [];
6748
- return Object.entries(V.voices).forEach(([e, n]) => {
6746
+ function Wt() {
6747
+ const W = qe(), t = [];
6748
+ return Object.entries(W.voices).forEach(([e, n]) => {
6749
6749
  t.push({
6750
6750
  value: n,
6751
- label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${V.service})`
6751
+ label: `${e.charAt(0).toUpperCase() + e.slice(1)} (${W.service})`
6752
6752
  });
6753
6753
  }), t;
6754
6754
  }
6755
- const tt = Xe(({
6756
- avatarUrl: V = "/avatars/brunette.glb",
6755
+ const it = Ye(({
6756
+ avatarUrl: W = "/avatars/brunette.glb",
6757
6757
  avatarBody: t = "F",
6758
6758
  mood: e = "neutral",
6759
6759
  ttsLang: n = "en",
@@ -6772,140 +6772,140 @@ const tt = Xe(({
6772
6772
  },
6773
6773
  className: g = "",
6774
6774
  style: R = {},
6775
- animations: b = {}
6775
+ animations: x = {}
6776
6776
  }, k) => {
6777
- const T = W(null), p = W(null), O = W(l), E = W(null), y = W(null), F = W(!1), f = W({ remainingText: null, originalText: null, options: null }), w = W([]), H = W(0), [I, U] = ae(!0), [G, X] = ae(null), [j, ue] = ae(!1), [le, ve] = ae(!1);
6778
- xe(() => {
6779
- F.current = le;
6780
- }, [le]), xe(() => {
6781
- O.current = l;
6777
+ const G = V(null), m = V(null), B = V(l), M = V(null), y = V(null), F = V(!1), L = V({ remainingText: null, originalText: null, options: null }), f = V([]), T = V(0), [A, D] = le(!0), [U, X] = le(null), [j, xe] = le(!1), [re, Se] = le(!1);
6778
+ Re(() => {
6779
+ F.current = re;
6780
+ }, [re]), Re(() => {
6781
+ B.current = l;
6782
6782
  }, [l]);
6783
- const re = Ye(), ze = o || re.service;
6784
- let J;
6785
- ze === "browser" ? J = {
6783
+ const ce = qe(), ye = o || ce.service;
6784
+ let ie;
6785
+ ye === "browser" ? ie = {
6786
6786
  service: "browser",
6787
6787
  endpoint: "",
6788
6788
  apiKey: null,
6789
6789
  defaultVoice: "Google US English"
6790
- } : ze === "elevenlabs" ? J = {
6790
+ } : ye === "elevenlabs" ? ie = {
6791
6791
  service: "elevenlabs",
6792
6792
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6793
- apiKey: i || re.apiKey,
6794
- defaultVoice: s || re.defaultVoice || Pe.defaultVoice,
6795
- voices: re.voices || Pe.voices
6796
- } : ze === "deepgram" ? J = {
6793
+ apiKey: i || ce.apiKey,
6794
+ defaultVoice: s || ce.defaultVoice || Pe.defaultVoice,
6795
+ voices: ce.voices || Pe.voices
6796
+ } : ye === "deepgram" ? ie = {
6797
6797
  service: "deepgram",
6798
6798
  endpoint: "https://api.deepgram.com/v1/speak",
6799
- apiKey: i || re.apiKey,
6800
- defaultVoice: s || re.defaultVoice || Ze.defaultVoice,
6801
- voices: re.voices || Ze.voices
6802
- } : J = {
6803
- ...re,
6799
+ apiKey: i || ce.apiKey,
6800
+ defaultVoice: s || ce.defaultVoice || je.defaultVoice,
6801
+ voices: ce.voices || je.voices
6802
+ } : ie = {
6803
+ ...ce,
6804
6804
  // Override API key if provided via props
6805
- apiKey: i !== null ? i : re.apiKey
6805
+ apiKey: i !== null ? i : ce.apiKey
6806
6806
  };
6807
6807
  const v = {
6808
- url: V,
6808
+ url: W,
6809
6809
  body: t,
6810
6810
  avatarMood: e,
6811
- ttsLang: ze === "browser" ? "en-US" : n,
6812
- ttsVoice: s || J.defaultVoice,
6811
+ ttsLang: ye === "browser" ? "en-US" : n,
6812
+ ttsVoice: s || ie.defaultVoice,
6813
6813
  lipsyncLang: "en",
6814
6814
  showFullAvatar: l,
6815
6815
  bodyMovement: a,
6816
6816
  movementIntensity: c
6817
- }, A = {
6818
- ttsEndpoint: J.endpoint,
6819
- ttsApikey: J.apiKey,
6820
- ttsService: ze,
6817
+ }, I = {
6818
+ ttsEndpoint: ie.endpoint,
6819
+ ttsApikey: ie.apiKey,
6820
+ ttsService: ye,
6821
6821
  lipsyncModules: ["en"],
6822
6822
  cameraView: u
6823
- }, M = N(async () => {
6824
- if (!(!T.current || p.current))
6823
+ }, H = N(async () => {
6824
+ if (!(!G.current || m.current))
6825
6825
  try {
6826
- if (U(!0), X(null), p.current = new Qe(T.current, A), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), b && Object.keys(b).length > 0 && (p.current.customAnimations = b), await p.current.showAvatar(v, (ee) => {
6826
+ if (D(!0), X(null), m.current = new _e(G.current, I), m.current.controls && (m.current.controls.enableRotate = !1, m.current.controls.enableZoom = !1, m.current.controls.enablePan = !1, m.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (m.current.customAnimations = x), await m.current.showAvatar(v, (ee) => {
6827
6827
  if (ee.lengthComputable) {
6828
- const ie = Math.min(100, Math.round(ee.loaded / ee.total * 100));
6829
- d(ie);
6828
+ const se = Math.min(100, Math.round(ee.loaded / ee.total * 100));
6829
+ d(se);
6830
6830
  }
6831
6831
  }), await new Promise((ee) => {
6832
- const ie = () => {
6833
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? ee() : setTimeout(ie, 100);
6832
+ const se = () => {
6833
+ m.current.lipsync && Object.keys(m.current.lipsync).length > 0 ? ee() : setTimeout(se, 100);
6834
6834
  };
6835
- ie();
6836
- }), p.current && p.current.setShowFullAvatar)
6835
+ se();
6836
+ }), m.current && m.current.setShowFullAvatar)
6837
6837
  try {
6838
- p.current.setShowFullAvatar(l);
6838
+ m.current.setShowFullAvatar(l);
6839
6839
  } catch (ee) {
6840
6840
  console.warn("Error setting full body mode on initialization:", ee);
6841
6841
  }
6842
- 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()), U(!1), ue(!0), r(p.current);
6842
+ m.current && m.current.controls && (m.current.controls.enableRotate = !1, m.current.controls.enableZoom = !1, m.current.controls.enablePan = !1, m.current.controls.enableDamping = !1, m.current.controls.update()), D(!1), xe(!0), r(m.current);
6843
6843
  const Y = () => {
6844
- document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6844
+ document.visibilityState === "visible" ? m.current?.start() : m.current?.stop();
6845
6845
  };
6846
6846
  return document.addEventListener("visibilitychange", Y), () => {
6847
6847
  document.removeEventListener("visibilitychange", Y);
6848
6848
  };
6849
- } catch (C) {
6850
- console.error("Error initializing TalkingHead:", C), X(C.message || "Failed to initialize avatar"), U(!1), h(C);
6849
+ } catch (w) {
6850
+ console.error("Error initializing TalkingHead:", w), X(w.message || "Failed to initialize avatar"), D(!1), h(w);
6851
6851
  }
6852
- }, [V, t, e, n, o, s, i, l, a, c, u]);
6853
- xe(() => (M(), () => {
6854
- p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6855
- }), [M]), xe(() => {
6856
- if (!T.current || !p.current) return;
6857
- const C = new ResizeObserver((ee) => {
6858
- for (const ie of ee)
6859
- p.current && p.current.onResize && p.current.onResize();
6852
+ }, [W, t, e, n, o, s, i, l, a, c, u]);
6853
+ Re(() => (H(), () => {
6854
+ m.current && (m.current.stop(), m.current.dispose(), m.current = null);
6855
+ }), [H]), Re(() => {
6856
+ if (!G.current || !m.current) return;
6857
+ const w = new ResizeObserver((ee) => {
6858
+ for (const se of ee)
6859
+ m.current && m.current.onResize && m.current.onResize();
6860
6860
  });
6861
- C.observe(T.current);
6861
+ w.observe(G.current);
6862
6862
  const Y = () => {
6863
- p.current && p.current.onResize && p.current.onResize();
6863
+ m.current && m.current.onResize && m.current.onResize();
6864
6864
  };
6865
6865
  return window.addEventListener("resize", Y), () => {
6866
- C.disconnect(), window.removeEventListener("resize", Y);
6866
+ w.disconnect(), window.removeEventListener("resize", Y);
6867
6867
  };
6868
6868
  }, [j]);
6869
- const D = N(async () => {
6870
- if (p.current && p.current.audioCtx)
6869
+ const E = N(async () => {
6870
+ if (m.current && m.current.audioCtx)
6871
6871
  try {
6872
- (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6873
- } catch (C) {
6874
- console.warn("Failed to resume audio context:", C);
6872
+ (m.current.audioCtx.state === "suspended" || m.current.audioCtx.state === "interrupted") && (await m.current.audioCtx.resume(), console.log("Audio context resumed"));
6873
+ } catch (w) {
6874
+ console.warn("Failed to resume audio context:", w);
6875
6875
  }
6876
- }, []), Z = N(async (C, Y = {}) => {
6877
- if (p.current && j)
6876
+ }, []), Z = N(async (w, Y = {}) => {
6877
+ if (m.current && j)
6878
6878
  try {
6879
- y.current && (clearInterval(y.current), y.current = null), E.current = { text: C, options: Y }, f.current = { remainingText: null, originalText: null, options: null };
6880
- const ee = /[!\.\?\n\p{Extended_Pictographic}]/ug, ie = C.split(ee).map((_) => _.trim()).filter((_) => _.length > 0);
6881
- w.current = ie, H.current = 0, ve(!1), F.current = !1, await D();
6882
- const be = {
6879
+ y.current && (clearInterval(y.current), y.current = null), M.current = { text: w, options: Y }, L.current = { remainingText: null, originalText: null, options: null };
6880
+ const ee = /[!\.\?\n\p{Extended_Pictographic}]/ug, se = w.split(ee).map((_) => _.trim()).filter((_) => _.length > 0);
6881
+ f.current = se, T.current = 0, Se(!1), F.current = !1, await E();
6882
+ const he = {
6883
6883
  ...Y,
6884
6884
  lipsyncLang: Y.lipsyncLang || v.lipsyncLang || "en"
6885
6885
  };
6886
- if (Y.onSpeechEnd && p.current) {
6887
- const _ = p.current;
6888
- let me = null, Me = 0;
6889
- const pe = 1200;
6890
- let ge = !1;
6891
- me = setInterval(() => {
6886
+ if (Y.onSpeechEnd && m.current) {
6887
+ const _ = m.current;
6888
+ let fe = null, Me = 0;
6889
+ const Ce = 1200;
6890
+ let ue = !1;
6891
+ fe = setInterval(() => {
6892
6892
  if (Me++, F.current)
6893
6893
  return;
6894
- if (Me > pe) {
6895
- if (me && (clearInterval(me), me = null, y.current = null), !ge && !F.current) {
6896
- ge = !0;
6894
+ if (Me > Ce) {
6895
+ if (fe && (clearInterval(fe), fe = null, y.current = null), !ue && !F.current) {
6896
+ ue = !0;
6897
6897
  try {
6898
6898
  Y.onSpeechEnd();
6899
- } catch (L) {
6900
- console.error("Error in onSpeechEnd callback (timeout):", L);
6899
+ } catch (We) {
6900
+ console.error("Error in onSpeechEnd callback (timeout):", We);
6901
6901
  }
6902
6902
  }
6903
6903
  return;
6904
6904
  }
6905
- const Ae = !_.speechQueue || _.speechQueue.length === 0, Be = !_.audioPlaylist || _.audioPlaylist.length === 0;
6906
- _ && _.isSpeaking === !1 && Ae && Be && _.isAudioPlaying === !1 && !ge && !F.current && setTimeout(() => {
6907
- if (_ && !F.current && _.isSpeaking === !1 && (!_.speechQueue || _.speechQueue.length === 0) && (!_.audioPlaylist || _.audioPlaylist.length === 0) && _.isAudioPlaying === !1 && !ge && !F.current) {
6908
- ge = !0, me && (clearInterval(me), me = null, y.current = null);
6905
+ const de = !_.speechQueue || _.speechQueue.length === 0, De = !_.audioPlaylist || _.audioPlaylist.length === 0;
6906
+ _ && _.isSpeaking === !1 && de && De && _.isAudioPlaying === !1 && !ue && !F.current && setTimeout(() => {
6907
+ if (_ && !F.current && _.isSpeaking === !1 && (!_.speechQueue || _.speechQueue.length === 0) && (!_.audioPlaylist || _.audioPlaylist.length === 0) && _.isAudioPlaying === !1 && !ue && !F.current) {
6908
+ ue = !0, fe && (clearInterval(fe), fe = null, y.current = null);
6909
6909
  try {
6910
6910
  Y.onSpeechEnd();
6911
6911
  } catch (S) {
@@ -6913,174 +6913,174 @@ const tt = Xe(({
6913
6913
  }
6914
6914
  }
6915
6915
  }, 100);
6916
- }, 100), y.current = me;
6916
+ }, 100), y.current = fe;
6917
6917
  }
6918
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(C, be)) : setTimeout(async () => {
6919
- await D(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(C, be));
6918
+ m.current.lipsync && Object.keys(m.current.lipsync).length > 0 ? (m.current.setSlowdownRate && m.current.setSlowdownRate(1.05), m.current.speakText(w, he)) : setTimeout(async () => {
6919
+ await E(), m.current && m.current.lipsync && (m.current.setSlowdownRate && m.current.setSlowdownRate(1.05), m.current.speakText(w, he));
6920
6920
  }, 100);
6921
6921
  } catch (ee) {
6922
6922
  console.error("Error speaking text:", ee), X(ee.message || "Failed to speak text");
6923
6923
  }
6924
- }, [j, D, v.lipsyncLang]), se = N(() => {
6925
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), E.current = null, ve(!1));
6926
- }, []), ne = N(() => {
6927
- if (p.current && p.current.pauseSpeaking) {
6928
- const C = p.current;
6929
- if (C.isSpeaking || C.audioPlaylist && C.audioPlaylist.length > 0 || C.speechQueue && C.speechQueue.length > 0) {
6924
+ }, [j, E, v.lipsyncLang]), oe = N(() => {
6925
+ m.current && (m.current.stopSpeaking(), m.current.setSlowdownRate && m.current.setSlowdownRate(1), M.current = null, Se(!1));
6926
+ }, []), $ = N(() => {
6927
+ if (m.current && m.current.pauseSpeaking) {
6928
+ const w = m.current;
6929
+ if (w.isSpeaking || w.audioPlaylist && w.audioPlaylist.length > 0 || w.speechQueue && w.speechQueue.length > 0) {
6930
6930
  y.current && (clearInterval(y.current), y.current = null);
6931
6931
  let ee = "";
6932
- if (E.current && w.current.length > 0) {
6933
- const ie = w.current.length, be = C.speechQueue ? C.speechQueue.filter((pe) => pe && pe.text && Array.isArray(pe.text) && pe.text.length > 0).length : 0, _ = C.audioPlaylist && C.audioPlaylist.length > 0, me = be + (_ ? 1 : 0), Me = ie - me;
6934
- if (me > 0 && Me < ie && (ee = w.current.slice(Me).join(". ").trim(), !ee && be > 0 && C.speechQueue)) {
6935
- const ge = C.speechQueue.filter((Ae) => Ae && Ae.text && Array.isArray(Ae.text) && Ae.text.length > 0).map((Ae) => Ae.text.map((Be) => Be.word || "").filter((Be) => Be.length > 0).join(" ")).filter((Ae) => Ae.length > 0).join(" ");
6936
- ge && ge.trim() && (ee = ge.trim());
6932
+ if (M.current && f.current.length > 0) {
6933
+ const se = f.current.length, he = w.speechQueue ? w.speechQueue.filter((Ce) => Ce && Ce.text && Array.isArray(Ce.text) && Ce.text.length > 0).length : 0, _ = w.audioPlaylist && w.audioPlaylist.length > 0, fe = he + (_ ? 1 : 0), Me = se - fe;
6934
+ if (fe > 0 && Me < se && (ee = f.current.slice(Me).join(". ").trim(), !ee && he > 0 && w.speechQueue)) {
6935
+ const ue = w.speechQueue.filter((de) => de && de.text && Array.isArray(de.text) && de.text.length > 0).map((de) => de.text.map((De) => De.word || "").filter((De) => De.length > 0).join(" ")).filter((de) => de.length > 0).join(" ");
6936
+ ue && ue.trim() && (ee = ue.trim());
6937
6937
  }
6938
6938
  }
6939
- E.current && (f.current = {
6939
+ M.current && (L.current = {
6940
6940
  remainingText: ee || null,
6941
- originalText: E.current.text,
6942
- options: E.current.options
6943
- }), C.speechQueue && (C.speechQueue.length = 0), p.current.pauseSpeaking(), F.current = !0, ve(!0);
6941
+ originalText: M.current.text,
6942
+ options: M.current.options
6943
+ }), w.speechQueue && (w.speechQueue.length = 0), m.current.pauseSpeaking(), F.current = !0, Se(!0);
6944
6944
  }
6945
6945
  }
6946
- }, []), q = N(async () => {
6947
- if (!p.current || !le)
6946
+ }, []), K = N(async () => {
6947
+ if (!m.current || !re)
6948
6948
  return;
6949
- let C = "", Y = {};
6950
- if (f.current && f.current.remainingText)
6951
- C = f.current.remainingText, Y = f.current.options || {}, f.current = { remainingText: null, originalText: null, options: null };
6952
- else if (E.current && E.current.text)
6953
- C = E.current.text, Y = E.current.options || {};
6949
+ let w = "", Y = {};
6950
+ if (L.current && L.current.remainingText)
6951
+ w = L.current.remainingText, Y = L.current.options || {}, L.current = { remainingText: null, originalText: null, options: null };
6952
+ else if (M.current && M.current.text)
6953
+ w = M.current.text, Y = M.current.options || {};
6954
6954
  else {
6955
- console.warn("Resume called but no paused speech found"), ve(!1), F.current = !1;
6955
+ console.warn("Resume called but no paused speech found"), Se(!1), F.current = !1;
6956
6956
  return;
6957
6957
  }
6958
- ve(!1), F.current = !1, await D();
6958
+ Se(!1), F.current = !1, await E();
6959
6959
  const ee = {
6960
6960
  ...Y,
6961
6961
  lipsyncLang: Y.lipsyncLang || v.lipsyncLang || "en"
6962
6962
  };
6963
6963
  try {
6964
- await Z(C, ee);
6965
- } catch (ie) {
6966
- console.error("Error resuming speech:", ie), ve(!1), F.current = !1;
6964
+ await Z(w, ee);
6965
+ } catch (se) {
6966
+ console.error("Error resuming speech:", se), Se(!1), F.current = !1;
6967
6967
  }
6968
- }, [D, le, Z, v]), ke = N((C) => {
6969
- p.current && p.current.setMood(C);
6970
- }, []), Ie = N((C) => {
6971
- p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(C);
6972
- }, []), Oe = N((C, Y = !1) => {
6973
- if (p.current && p.current.playAnimation) {
6974
- if (b && b[C] && (C = b[C]), p.current.setShowFullAvatar)
6968
+ }, [E, re, Z, v]), ve = N((w) => {
6969
+ m.current && m.current.setMood(w);
6970
+ }, []), Oe = N((w) => {
6971
+ m.current && m.current.setSlowdownRate && m.current.setSlowdownRate(w);
6972
+ }, []), ke = N((w, Y = !1) => {
6973
+ if (m.current && m.current.playAnimation) {
6974
+ if (x && x[w] && (w = x[w]), m.current.setShowFullAvatar)
6975
6975
  try {
6976
- p.current.setShowFullAvatar(O.current);
6977
- } catch (ie) {
6978
- console.warn("Error setting full body mode:", ie);
6976
+ m.current.setShowFullAvatar(B.current);
6977
+ } catch (se) {
6978
+ console.warn("Error setting full body mode:", se);
6979
6979
  }
6980
- if (C.includes("."))
6980
+ if (w.includes("."))
6981
6981
  try {
6982
- p.current.playAnimation(C, null, 10, 0, 0.01, Y);
6983
- } catch (ie) {
6984
- console.warn(`Failed to play ${C}:`, ie);
6982
+ m.current.playAnimation(w, null, 10, 0, 0.01, Y);
6983
+ } catch (se) {
6984
+ console.warn(`Failed to play ${w}:`, se);
6985
6985
  try {
6986
- p.current.setBodyMovement("idle");
6987
- } catch (be) {
6988
- console.warn("Fallback animation also failed:", be);
6986
+ m.current.setBodyMovement("idle");
6987
+ } catch (he) {
6988
+ console.warn("Fallback animation also failed:", he);
6989
6989
  }
6990
6990
  }
6991
6991
  else {
6992
- const ie = [".fbx", ".glb", ".gltf"];
6993
- let be = !1;
6994
- for (const _ of ie)
6992
+ const se = [".fbx", ".glb", ".gltf"];
6993
+ let he = !1;
6994
+ for (const _ of se)
6995
6995
  try {
6996
- p.current.playAnimation(C + _, null, 10, 0, 0.01, Y), be = !0;
6996
+ m.current.playAnimation(w + _, null, 10, 0, 0.01, Y), he = !0;
6997
6997
  break;
6998
6998
  } catch {
6999
6999
  }
7000
- if (!be) {
7001
- console.warn("Animation not found:", C);
7000
+ if (!he) {
7001
+ console.warn("Animation not found:", w);
7002
7002
  try {
7003
- p.current.setBodyMovement("idle");
7003
+ m.current.setBodyMovement("idle");
7004
7004
  } catch (_) {
7005
7005
  console.warn("Fallback animation also failed:", _);
7006
7006
  }
7007
7007
  }
7008
7008
  }
7009
7009
  }
7010
- }, [b]), He = N(() => {
7011
- p.current && p.current.onResize && p.current.onResize();
7010
+ }, [x]), Be = N(() => {
7011
+ m.current && m.current.onResize && m.current.onResize();
7012
7012
  }, []);
7013
- return je(k, () => ({
7013
+ return Qe(k, () => ({
7014
7014
  speakText: Z,
7015
- stopSpeaking: se,
7016
- pauseSpeaking: ne,
7017
- resumeSpeaking: q,
7018
- resumeAudioContext: D,
7019
- setMood: ke,
7020
- setTimingAdjustment: Ie,
7021
- playAnimation: Oe,
7015
+ stopSpeaking: oe,
7016
+ pauseSpeaking: $,
7017
+ resumeSpeaking: K,
7018
+ resumeAudioContext: E,
7019
+ setMood: ve,
7020
+ setTimingAdjustment: Oe,
7021
+ playAnimation: ke,
7022
7022
  isReady: j,
7023
- isPaused: le,
7024
- talkingHead: p.current,
7025
- handleResize: He,
7026
- setBodyMovement: (C) => {
7027
- if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
7023
+ isPaused: re,
7024
+ talkingHead: m.current,
7025
+ handleResize: Be,
7026
+ setBodyMovement: (w) => {
7027
+ if (m.current && m.current.setShowFullAvatar && m.current.setBodyMovement)
7028
7028
  try {
7029
- p.current.setShowFullAvatar(O.current), p.current.setBodyMovement(C);
7029
+ m.current.setShowFullAvatar(B.current), m.current.setBodyMovement(w);
7030
7030
  } catch (Y) {
7031
7031
  console.warn("Error setting body movement:", Y);
7032
7032
  }
7033
7033
  },
7034
- setMovementIntensity: (C) => p.current?.setMovementIntensity(C),
7034
+ setMovementIntensity: (w) => m.current?.setMovementIntensity(w),
7035
7035
  playRandomDance: () => {
7036
- if (p.current && p.current.setShowFullAvatar && p.current.playRandomDance)
7036
+ if (m.current && m.current.setShowFullAvatar && m.current.playRandomDance)
7037
7037
  try {
7038
- p.current.setShowFullAvatar(O.current), p.current.playRandomDance();
7039
- } catch (C) {
7040
- console.warn("Error playing random dance:", C);
7038
+ m.current.setShowFullAvatar(B.current), m.current.playRandomDance();
7039
+ } catch (w) {
7040
+ console.warn("Error playing random dance:", w);
7041
7041
  }
7042
7042
  },
7043
- playReaction: (C) => {
7044
- if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
7043
+ playReaction: (w) => {
7044
+ if (m.current && m.current.setShowFullAvatar && m.current.playReaction)
7045
7045
  try {
7046
- p.current.setShowFullAvatar(O.current), p.current.playReaction(C);
7046
+ m.current.setShowFullAvatar(B.current), m.current.playReaction(w);
7047
7047
  } catch (Y) {
7048
7048
  console.warn("Error playing reaction:", Y);
7049
7049
  }
7050
7050
  },
7051
7051
  playCelebration: () => {
7052
- if (p.current && p.current.setShowFullAvatar && p.current.playCelebration)
7052
+ if (m.current && m.current.setShowFullAvatar && m.current.playCelebration)
7053
7053
  try {
7054
- p.current.setShowFullAvatar(O.current), p.current.playCelebration();
7055
- } catch (C) {
7056
- console.warn("Error playing celebration:", C);
7054
+ m.current.setShowFullAvatar(B.current), m.current.playCelebration();
7055
+ } catch (w) {
7056
+ console.warn("Error playing celebration:", w);
7057
7057
  }
7058
7058
  },
7059
- setShowFullAvatar: (C) => {
7060
- if (p.current && p.current.setShowFullAvatar)
7059
+ setShowFullAvatar: (w) => {
7060
+ if (m.current && m.current.setShowFullAvatar)
7061
7061
  try {
7062
- O.current = C, p.current.setShowFullAvatar(C);
7062
+ B.current = w, m.current.setShowFullAvatar(w);
7063
7063
  } catch (Y) {
7064
7064
  console.warn("Error setting showFullAvatar:", Y);
7065
7065
  }
7066
7066
  },
7067
7067
  lockAvatarPosition: () => {
7068
- if (p.current && p.current.lockAvatarPosition)
7068
+ if (m.current && m.current.lockAvatarPosition)
7069
7069
  try {
7070
- p.current.lockAvatarPosition();
7071
- } catch (C) {
7072
- console.warn("Error locking avatar position:", C);
7070
+ m.current.lockAvatarPosition();
7071
+ } catch (w) {
7072
+ console.warn("Error locking avatar position:", w);
7073
7073
  }
7074
7074
  },
7075
7075
  unlockAvatarPosition: () => {
7076
- if (p.current && p.current.unlockAvatarPosition)
7076
+ if (m.current && m.current.unlockAvatarPosition)
7077
7077
  try {
7078
- p.current.unlockAvatarPosition();
7079
- } catch (C) {
7080
- console.warn("Error unlocking avatar position:", C);
7078
+ m.current.unlockAvatarPosition();
7079
+ } catch (w) {
7080
+ console.warn("Error unlocking avatar position:", w);
7081
7081
  }
7082
7082
  }
7083
- })), /* @__PURE__ */ Se(
7083
+ })), /* @__PURE__ */ we(
7084
7084
  "div",
7085
7085
  {
7086
7086
  className: `talking-head-avatar ${g}`,
@@ -7091,10 +7091,10 @@ const tt = Xe(({
7091
7091
  ...R
7092
7092
  },
7093
7093
  children: [
7094
- /* @__PURE__ */ $(
7094
+ /* @__PURE__ */ J(
7095
7095
  "div",
7096
7096
  {
7097
- ref: T,
7097
+ ref: G,
7098
7098
  className: "talking-head-viewer",
7099
7099
  style: {
7100
7100
  width: "100%",
@@ -7103,7 +7103,7 @@ const tt = Xe(({
7103
7103
  }
7104
7104
  }
7105
7105
  ),
7106
- I && /* @__PURE__ */ $("div", { className: "loading-overlay", style: {
7106
+ A && /* @__PURE__ */ J("div", { className: "loading-overlay", style: {
7107
7107
  position: "absolute",
7108
7108
  top: "50%",
7109
7109
  left: "50%",
@@ -7112,7 +7112,7 @@ const tt = Xe(({
7112
7112
  fontSize: "18px",
7113
7113
  zIndex: 10
7114
7114
  }, children: "Loading avatar..." }),
7115
- G && /* @__PURE__ */ $("div", { className: "error-overlay", style: {
7115
+ U && /* @__PURE__ */ J("div", { className: "error-overlay", style: {
7116
7116
  position: "absolute",
7117
7117
  top: "50%",
7118
7118
  left: "50%",
@@ -7123,14 +7123,14 @@ const tt = Xe(({
7123
7123
  zIndex: 10,
7124
7124
  padding: "20px",
7125
7125
  borderRadius: "8px"
7126
- }, children: G })
7126
+ }, children: U })
7127
7127
  ]
7128
7128
  }
7129
7129
  );
7130
7130
  });
7131
- tt.displayName = "TalkingHeadAvatar";
7132
- const Ct = Xe(({
7133
- text: V = "Hello! I'm a talking avatar. How are you today?",
7131
+ it.displayName = "TalkingHeadAvatar";
7132
+ const zt = Ye(({
7133
+ text: W = "Hello! I'm a talking avatar. How are you today?",
7134
7134
  onLoading: t = () => {
7135
7135
  },
7136
7136
  onError: e = () => {
@@ -7141,23 +7141,23 @@ const Ct = Xe(({
7141
7141
  style: s = {},
7142
7142
  avatarConfig: i = {}
7143
7143
  }, a) => {
7144
- const c = W(null), l = W(null), [u, r] = ae(!0), [d, h] = ae(null), [g, R] = ae(!1), b = Ye(), k = i.ttsService || b.service, T = k === "browser" ? {
7144
+ const c = V(null), l = V(null), [u, r] = le(!0), [d, h] = le(null), [g, R] = le(!1), x = qe(), k = i.ttsService || x.service, G = k === "browser" ? {
7145
7145
  endpoint: "",
7146
7146
  apiKey: null,
7147
7147
  defaultVoice: "Google US English"
7148
7148
  } : {
7149
- ...b,
7149
+ ...x,
7150
7150
  // Override API key if provided via avatarConfig
7151
- apiKey: i.ttsApiKey !== void 0 && i.ttsApiKey !== null ? i.ttsApiKey : b.apiKey,
7151
+ apiKey: i.ttsApiKey !== void 0 && i.ttsApiKey !== null ? i.ttsApiKey : x.apiKey,
7152
7152
  // Override endpoint for ElevenLabs if service is explicitly set
7153
- endpoint: k === "elevenlabs" && i.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : b.endpoint
7154
- }, p = {
7153
+ endpoint: k === "elevenlabs" && i.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : x.endpoint
7154
+ }, m = {
7155
7155
  url: "/avatars/brunette.glb",
7156
7156
  // Use brunette avatar (working glTF file)
7157
7157
  body: "F",
7158
7158
  avatarMood: "neutral",
7159
7159
  ttsLang: k === "browser" ? "en-US" : "en",
7160
- ttsVoice: i.ttsVoice || T.defaultVoice,
7160
+ ttsVoice: i.ttsVoice || G.defaultVoice,
7161
7161
  lipsyncLang: "en",
7162
7162
  // English lip-sync
7163
7163
  showFullAvatar: !0,
@@ -7165,69 +7165,69 @@ const Ct = Xe(({
7165
7165
  bodyMovement: "idle",
7166
7166
  movementIntensity: 0.5,
7167
7167
  ...i
7168
- }, O = {
7169
- ttsEndpoint: T.endpoint,
7170
- ttsApikey: T.apiKey,
7168
+ }, B = {
7169
+ ttsEndpoint: G.endpoint,
7170
+ ttsApikey: G.apiKey,
7171
7171
  ttsService: k,
7172
7172
  lipsyncModules: ["en"],
7173
7173
  cameraView: "upper"
7174
- }, E = N(async () => {
7174
+ }, M = N(async () => {
7175
7175
  if (!(!c.current || l.current))
7176
7176
  try {
7177
- if (r(!0), h(null), l.current = new Qe(c.current, O), await l.current.showAvatar(p, (G) => {
7178
- if (G.lengthComputable) {
7179
- const X = Math.min(100, Math.round(G.loaded / G.total * 100));
7177
+ if (r(!0), h(null), l.current = new _e(c.current, B), await l.current.showAvatar(m, (U) => {
7178
+ if (U.lengthComputable) {
7179
+ const X = Math.min(100, Math.round(U.loaded / U.total * 100));
7180
7180
  t(X);
7181
7181
  }
7182
7182
  }), l.current.morphs && l.current.morphs.length > 0) {
7183
- const G = l.current.morphs[0].morphTargetDictionary;
7184
- console.log("Available morph targets:", Object.keys(G));
7185
- const X = Object.keys(G).filter((j) => j.startsWith("viseme_"));
7183
+ const U = l.current.morphs[0].morphTargetDictionary;
7184
+ console.log("Available morph targets:", Object.keys(U));
7185
+ const X = Object.keys(U).filter((j) => j.startsWith("viseme_"));
7186
7186
  console.log("Viseme morph targets found:", X), X.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"));
7187
7187
  }
7188
- if (await new Promise((G) => {
7188
+ if (await new Promise((U) => {
7189
7189
  const X = () => {
7190
- l.current.lipsync && Object.keys(l.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(l.current.lipsync)), G()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(X, 100));
7190
+ l.current.lipsync && Object.keys(l.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(l.current.lipsync)), U()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(X, 100));
7191
7191
  };
7192
7192
  X();
7193
7193
  }), l.current && l.current.setShowFullAvatar)
7194
7194
  try {
7195
7195
  l.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7196
- } catch (G) {
7197
- console.warn("Error setting full body mode on initialization:", G);
7196
+ } catch (U) {
7197
+ console.warn("Error setting full body mode on initialization:", U);
7198
7198
  }
7199
7199
  r(!1), R(!0), n(l.current);
7200
- const U = () => {
7200
+ const D = () => {
7201
7201
  document.visibilityState === "visible" ? l.current?.start() : l.current?.stop();
7202
7202
  };
7203
- return document.addEventListener("visibilitychange", U), () => {
7204
- document.removeEventListener("visibilitychange", U);
7203
+ return document.addEventListener("visibilitychange", D), () => {
7204
+ document.removeEventListener("visibilitychange", D);
7205
7205
  };
7206
- } catch (I) {
7207
- console.error("Error initializing TalkingHead:", I), h(I.message || "Failed to initialize avatar"), r(!1), e(I);
7206
+ } catch (A) {
7207
+ console.error("Error initializing TalkingHead:", A), h(A.message || "Failed to initialize avatar"), r(!1), e(A);
7208
7208
  }
7209
7209
  }, []);
7210
- xe(() => (E(), () => {
7210
+ Re(() => (M(), () => {
7211
7211
  l.current && (l.current.stop(), l.current.dispose(), l.current = null);
7212
- }), [E]);
7213
- const y = N((I) => {
7212
+ }), [M]);
7213
+ const y = N((A) => {
7214
7214
  if (l.current && g)
7215
7215
  try {
7216
- console.log("Speaking text:", I), console.log("Avatar config:", p), console.log("TalkingHead instance:", l.current), l.current.lipsync && Object.keys(l.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(l.current.lipsync)), l.current.setSlowdownRate && (l.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), l.current.speakText(I)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7217
- l.current && l.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), l.current.setSlowdownRate && (l.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), l.current.speakText(I)) : console.error("Lip-sync still not ready after waiting");
7216
+ console.log("Speaking text:", A), console.log("Avatar config:", m), console.log("TalkingHead instance:", l.current), l.current.lipsync && Object.keys(l.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(l.current.lipsync)), l.current.setSlowdownRate && (l.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), l.current.speakText(A)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7217
+ l.current && l.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), l.current.setSlowdownRate && (l.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), l.current.speakText(A)) : console.error("Lip-sync still not ready after waiting");
7218
7218
  }, 500));
7219
- } catch (U) {
7220
- console.error("Error speaking text:", U), h(U.message || "Failed to speak text");
7219
+ } catch (D) {
7220
+ console.error("Error speaking text:", D), h(D.message || "Failed to speak text");
7221
7221
  }
7222
7222
  else
7223
7223
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!l.current);
7224
- }, [g, p]), F = N(() => {
7224
+ }, [g, m]), F = N(() => {
7225
7225
  l.current && (l.current.stopSpeaking(), l.current.setSlowdownRate && (l.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7226
- }, []), f = N((I) => {
7227
- l.current && l.current.setMood(I);
7228
- }, []), w = N((I) => {
7229
- l.current && l.current.setSlowdownRate && (l.current.setSlowdownRate(I), console.log("Timing adjustment set to:", I));
7230
- }, []), H = N((I, U = !1) => {
7226
+ }, []), L = N((A) => {
7227
+ l.current && l.current.setMood(A);
7228
+ }, []), f = N((A) => {
7229
+ l.current && l.current.setSlowdownRate && (l.current.setSlowdownRate(A), console.log("Timing adjustment set to:", A));
7230
+ }, []), T = N((A, D = !1) => {
7231
7231
  if (l.current && l.current.playAnimation) {
7232
7232
  if (l.current.setShowFullAvatar)
7233
7233
  try {
@@ -7235,11 +7235,11 @@ const Ct = Xe(({
7235
7235
  } catch (X) {
7236
7236
  console.warn("Error setting full body mode:", X);
7237
7237
  }
7238
- if (I.includes("."))
7238
+ if (A.includes("."))
7239
7239
  try {
7240
- l.current.playAnimation(I, null, 10, 0, 0.01, U), console.log("Playing animation:", I);
7240
+ l.current.playAnimation(A, null, 10, 0, 0.01, D), console.log("Playing animation:", A);
7241
7241
  } catch (X) {
7242
- console.log(`Failed to play ${I}:`, X);
7242
+ console.log(`Failed to play ${A}:`, X);
7243
7243
  try {
7244
7244
  l.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7245
7245
  } catch (j) {
@@ -7249,92 +7249,92 @@ const Ct = Xe(({
7249
7249
  else {
7250
7250
  const X = [".fbx", ".glb", ".gltf"];
7251
7251
  let j = !1;
7252
- for (const ue of X)
7252
+ for (const xe of X)
7253
7253
  try {
7254
- l.current.playAnimation(I + ue, null, 10, 0, 0.01, U), console.log("Playing animation:", I + ue), j = !0;
7254
+ l.current.playAnimation(A + xe, null, 10, 0, 0.01, D), console.log("Playing animation:", A + xe), j = !0;
7255
7255
  break;
7256
7256
  } catch {
7257
- console.log(`Failed to play ${I}${ue}, trying next format...`);
7257
+ console.log(`Failed to play ${A}${xe}, trying next format...`);
7258
7258
  }
7259
7259
  if (!j) {
7260
- console.warn("Animation system not available or animation not found:", I);
7260
+ console.warn("Animation system not available or animation not found:", A);
7261
7261
  try {
7262
7262
  l.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7263
- } catch (ue) {
7264
- console.warn("Fallback animation also failed:", ue);
7263
+ } catch (xe) {
7264
+ console.warn("Fallback animation also failed:", xe);
7265
7265
  }
7266
7266
  }
7267
7267
  }
7268
7268
  } else
7269
- console.warn("Animation system not available or animation not found:", I);
7269
+ console.warn("Animation system not available or animation not found:", A);
7270
7270
  }, []);
7271
- return je(a, () => ({
7271
+ return Qe(a, () => ({
7272
7272
  speakText: y,
7273
7273
  stopSpeaking: F,
7274
- setMood: f,
7275
- setTimingAdjustment: w,
7276
- playAnimation: H,
7274
+ setMood: L,
7275
+ setTimingAdjustment: f,
7276
+ playAnimation: T,
7277
7277
  isReady: g,
7278
7278
  talkingHead: l.current,
7279
- setBodyMovement: (I) => {
7279
+ setBodyMovement: (A) => {
7280
7280
  if (l.current && l.current.setShowFullAvatar && l.current.setBodyMovement)
7281
7281
  try {
7282
- l.current.setShowFullAvatar(!0), l.current.setBodyMovement(I), console.log("Body movement set with full body mode:", I);
7283
- } catch (U) {
7284
- console.warn("Error setting body movement:", U);
7282
+ l.current.setShowFullAvatar(!0), l.current.setBodyMovement(A), console.log("Body movement set with full body mode:", A);
7283
+ } catch (D) {
7284
+ console.warn("Error setting body movement:", D);
7285
7285
  }
7286
7286
  },
7287
- setMovementIntensity: (I) => l.current?.setMovementIntensity(I),
7287
+ setMovementIntensity: (A) => l.current?.setMovementIntensity(A),
7288
7288
  playRandomDance: () => {
7289
7289
  if (l.current && l.current.setShowFullAvatar && l.current.playRandomDance)
7290
7290
  try {
7291
7291
  l.current.setShowFullAvatar(!0), l.current.playRandomDance(), console.log("Random dance played with full body mode");
7292
- } catch (I) {
7293
- console.warn("Error playing random dance:", I);
7292
+ } catch (A) {
7293
+ console.warn("Error playing random dance:", A);
7294
7294
  }
7295
7295
  },
7296
- playReaction: (I) => {
7296
+ playReaction: (A) => {
7297
7297
  if (l.current && l.current.setShowFullAvatar && l.current.playReaction)
7298
7298
  try {
7299
- l.current.setShowFullAvatar(!0), l.current.playReaction(I), console.log("Reaction played with full body mode:", I);
7300
- } catch (U) {
7301
- console.warn("Error playing reaction:", U);
7299
+ l.current.setShowFullAvatar(!0), l.current.playReaction(A), console.log("Reaction played with full body mode:", A);
7300
+ } catch (D) {
7301
+ console.warn("Error playing reaction:", D);
7302
7302
  }
7303
7303
  },
7304
7304
  playCelebration: () => {
7305
7305
  if (l.current && l.current.setShowFullAvatar && l.current.playCelebration)
7306
7306
  try {
7307
7307
  l.current.setShowFullAvatar(!0), l.current.playCelebration(), console.log("Celebration played with full body mode");
7308
- } catch (I) {
7309
- console.warn("Error playing celebration:", I);
7308
+ } catch (A) {
7309
+ console.warn("Error playing celebration:", A);
7310
7310
  }
7311
7311
  },
7312
- setShowFullAvatar: (I) => {
7312
+ setShowFullAvatar: (A) => {
7313
7313
  if (l.current && l.current.setShowFullAvatar)
7314
7314
  try {
7315
- l.current.setShowFullAvatar(I), console.log("Show full avatar set to:", I);
7316
- } catch (U) {
7317
- console.warn("Error setting showFullAvatar:", U);
7315
+ l.current.setShowFullAvatar(A), console.log("Show full avatar set to:", A);
7316
+ } catch (D) {
7317
+ console.warn("Error setting showFullAvatar:", D);
7318
7318
  }
7319
7319
  },
7320
7320
  lockAvatarPosition: () => {
7321
7321
  if (l.current && l.current.lockAvatarPosition)
7322
7322
  try {
7323
7323
  l.current.lockAvatarPosition();
7324
- } catch (I) {
7325
- console.warn("Error locking avatar position:", I);
7324
+ } catch (A) {
7325
+ console.warn("Error locking avatar position:", A);
7326
7326
  }
7327
7327
  },
7328
7328
  unlockAvatarPosition: () => {
7329
7329
  if (l.current && l.current.unlockAvatarPosition)
7330
7330
  try {
7331
7331
  l.current.unlockAvatarPosition();
7332
- } catch (I) {
7333
- console.warn("Error unlocking avatar position:", I);
7332
+ } catch (A) {
7333
+ console.warn("Error unlocking avatar position:", A);
7334
7334
  }
7335
7335
  }
7336
- })), /* @__PURE__ */ Se("div", { className: `talking-head-container ${o}`, style: s, children: [
7337
- /* @__PURE__ */ $(
7336
+ })), /* @__PURE__ */ we("div", { className: `talking-head-container ${o}`, style: s, children: [
7337
+ /* @__PURE__ */ J(
7338
7338
  "div",
7339
7339
  {
7340
7340
  ref: c,
@@ -7346,7 +7346,7 @@ const Ct = Xe(({
7346
7346
  }
7347
7347
  }
7348
7348
  ),
7349
- u && /* @__PURE__ */ $("div", { className: "loading-overlay", style: {
7349
+ u && /* @__PURE__ */ J("div", { className: "loading-overlay", style: {
7350
7350
  position: "absolute",
7351
7351
  top: "50%",
7352
7352
  left: "50%",
@@ -7355,7 +7355,7 @@ const Ct = Xe(({
7355
7355
  fontSize: "18px",
7356
7356
  zIndex: 10
7357
7357
  }, children: "Loading avatar..." }),
7358
- d && /* @__PURE__ */ $("div", { className: "error-overlay", style: {
7358
+ d && /* @__PURE__ */ J("div", { className: "error-overlay", style: {
7359
7359
  position: "absolute",
7360
7360
  top: "50%",
7361
7361
  left: "50%",
@@ -7369,19 +7369,26 @@ const Ct = Xe(({
7369
7369
  }, children: d })
7370
7370
  ] });
7371
7371
  });
7372
- Ct.displayName = "TalkingHeadComponent";
7373
- async function Ne(V) {
7372
+ zt.displayName = "TalkingHeadComponent";
7373
+ async function Ue(W) {
7374
7374
  try {
7375
- const t = await fetch(V);
7376
- if (!t.ok)
7375
+ const t = await fetch(W);
7376
+ if (!t.ok) {
7377
+ if (t.status === 404)
7378
+ return {};
7377
7379
  throw new Error(`Failed to fetch manifest: ${t.status} ${t.statusText}`);
7378
- return (await t.json()).animations || {};
7380
+ }
7381
+ const e = t.headers.get("content-type");
7382
+ if (e && !e.includes("application/json"))
7383
+ return {};
7384
+ const n = await t.text();
7385
+ return n.trim().startsWith("<!") ? {} : JSON.parse(n).animations || {};
7379
7386
  } catch (t) {
7380
- return console.error("Failed to load animation manifest:", t), {};
7387
+ return t instanceof SyntaxError || console.warn("⚠️ Could not load animation manifest (this is optional):", W), {};
7381
7388
  }
7382
7389
  }
7383
- async function zt(V, t = "F") {
7384
- const e = [], n = V.replace(/\/$/, "");
7390
+ async function Ht(W, t = "F") {
7391
+ const e = [], n = W.replace(/\/$/, "");
7385
7392
  try {
7386
7393
  const i = [
7387
7394
  `${n}/.list.json`,
@@ -7424,19 +7431,19 @@ async function zt(V, t = "F") {
7424
7431
  }
7425
7432
  return e.length > 0, e;
7426
7433
  }
7427
- async function et(V, t = "F") {
7434
+ async function nt(W, t = "F") {
7428
7435
  const e = {};
7429
- for (const [n, o] of Object.entries(V))
7436
+ for (const [n, o] of Object.entries(W))
7430
7437
  try {
7431
- const s = await zt(o, t);
7438
+ const s = await Ht(o, t);
7432
7439
  s.length > 0 && (e[n] = s);
7433
7440
  } catch (s) {
7434
7441
  console.error(`❌ Failed to auto-load animations from ${o}:`, s);
7435
7442
  }
7436
7443
  return e;
7437
7444
  }
7438
- const Ht = Xe(({
7439
- text: V = null,
7445
+ const Tt = Ye(({
7446
+ text: W = null,
7440
7447
  avatarUrl: t = "/avatars/brunette.glb",
7441
7448
  avatarBody: e = "F",
7442
7449
  mood: n = "neutral",
@@ -7454,313 +7461,326 @@ const Ht = Xe(({
7454
7461
  },
7455
7462
  onError: g = () => {
7456
7463
  },
7457
- onSpeechEnd: R = () => {
7464
+ onSpeechStart: R = () => {
7458
7465
  },
7459
- className: b = "",
7460
- style: k = {},
7461
- animations: T = {},
7462
- autoAnimationGroup: p = null,
7466
+ onSpeechEnd: x = () => {
7467
+ },
7468
+ className: k = "",
7469
+ style: G = {},
7470
+ animations: m = {},
7471
+ autoAnimationGroup: B = null,
7463
7472
  // e.g., "talking" - will randomly select from this group when speaking
7464
- autoIdleGroup: O = null,
7473
+ autoIdleGroup: M = null,
7465
7474
  // e.g., "idle" - will randomly select from this group when idle
7466
- autoSpeak: E = !1
7467
- }, y) => {
7468
- const F = W(null), f = W(null), w = W(u), H = W(null), I = W(null), U = W(!1), G = W({ remainingText: null, originalText: null, options: null }), X = W([]), [j, ue] = ae(!0), [le, ve] = ae(null), [re, ze] = ae(!1), [J, v] = ae(!1), [A, M] = ae(T), D = W(null), Z = W(!1), se = W(null), ne = W([]), q = W([]);
7469
- xe(() => {
7470
- U.current = J;
7471
- }, [J]);
7472
- const ke = N((L) => {
7473
- let S = "F";
7474
- if (L) {
7475
- const P = L.toString().toUpperCase().trim();
7476
- P === "M" || P === "MALE" ? S = "M" : (P === "F" || P === "FEMALE") && (S = "F");
7475
+ autoSpeak: y = !1
7476
+ }, F) => {
7477
+ const L = V(null), f = V(null), T = V(u), A = V(null), D = V(null), U = V(!1), X = V({ remainingText: null, originalText: null, options: null }), j = V([]), [xe, re] = le(!0), [Se, ce] = le(null), [ye, ie] = le(!1), [v, I] = le(!1), [H, E] = le(m), Z = V(null), oe = V(!1), $ = V(null), K = V([]), ve = V([]);
7478
+ Re(() => {
7479
+ U.current = v;
7480
+ }, [v]);
7481
+ const Oe = N((S) => {
7482
+ let C = "F";
7483
+ if (S) {
7484
+ const P = S.toString().toUpperCase().trim();
7485
+ P === "M" || P === "MALE" ? C = "M" : (P === "F" || P === "FEMALE") && (C = "F");
7477
7486
  }
7478
- return S === "M" ? "male" : "female";
7487
+ return C === "M" ? "male" : "female";
7479
7488
  }, []);
7480
- xe(() => {
7489
+ Re(() => {
7481
7490
  (async () => {
7482
- if (T.manifest && T.auto)
7491
+ if (m.manifest && m.auto)
7483
7492
  try {
7484
- const S = await Ne(T.manifest);
7485
- M(S);
7493
+ const C = await Ue(m.manifest);
7494
+ E(C);
7486
7495
  return;
7487
7496
  } catch {
7488
7497
  }
7489
- if (T.manifest && !T.auto)
7490
- try {
7491
- const S = await Ne(T.manifest);
7492
- M(S);
7493
- } catch (S) {
7494
- console.error("Failed to load animation manifest:", S), M(T);
7495
- }
7496
- else if (T.auto)
7498
+ if (m.manifest && !m.auto) {
7499
+ const C = await Ue(m.manifest), P = Object.keys(C).length > 0;
7500
+ E(P ? C : m);
7501
+ } else if (m.auto)
7497
7502
  try {
7498
- let S = null;
7499
- if (T.manifest)
7503
+ let C = null;
7504
+ if (m.manifest)
7500
7505
  try {
7501
- S = await Ne(T.manifest);
7506
+ C = await Ue(m.manifest);
7502
7507
  } catch {
7503
7508
  }
7504
- if (typeof T.auto == "string") {
7505
- const P = T.auto, K = {
7509
+ if (typeof m.auto == "string") {
7510
+ const P = m.auto, Q = {
7506
7511
  talking: `${P}/talking`,
7507
7512
  idle: `${P}/idle`
7508
- }, te = ke(e);
7509
- K[`${te}_talking`] = `${P}/${te}/talking`, K[`${te}_idle`] = `${P}/${te}/idle`, K.shared_talking = `${P}/shared/talking`, K.shared_idle = `${P}/shared/idle`, console.log(`📁 Loading animations from folders with genderKey="${te}" for avatarBody="${e}"`);
7510
- const Le = await et(K, e);
7511
- if (!Object.values(Le).some((ce) => Array.isArray(ce) && ce.length > 0) && S) {
7512
- M(S);
7513
+ }, te = Oe(e);
7514
+ Q[`${te}_talking`] = `${P}/${te}/talking`, Q[`${te}_idle`] = `${P}/${te}/idle`, Q.shared_talking = `${P}/shared/talking`, Q.shared_idle = `${P}/shared/idle`;
7515
+ const Ie = await nt(Q, e);
7516
+ if (!Object.values(Ie).some((me) => Array.isArray(me) && me.length > 0) && C) {
7517
+ E(C);
7513
7518
  return;
7514
7519
  }
7515
- const ye = {
7520
+ const ae = {
7516
7521
  _genderSpecific: {
7517
7522
  [te]: {},
7518
7523
  shared: {}
7519
7524
  }
7520
7525
  };
7521
- Object.entries(Le).forEach(([ce, Fe]) => {
7522
- if (ce.includes("_")) {
7523
- const [Ue, ...ot] = ce.split("_"), De = ot.join("_");
7524
- Ue === "shared" ? (ye._genderSpecific.shared[De] || (ye._genderSpecific.shared[De] = []), ye._genderSpecific.shared[De].push(...Fe)) : Ue === te && (ye._genderSpecific[te][De] || (ye._genderSpecific[te][De] = []), ye._genderSpecific[te][De].push(...Fe));
7526
+ Object.entries(Ie).forEach(([me, Fe]) => {
7527
+ if (me.includes("_")) {
7528
+ const [Ve, ...st] = me.split("_"), Ne = st.join("_");
7529
+ Ve === "shared" ? (ae._genderSpecific.shared[Ne] || (ae._genderSpecific.shared[Ne] = []), ae._genderSpecific.shared[Ne].push(...Fe)) : Ve === te && (ae._genderSpecific[te][Ne] || (ae._genderSpecific[te][Ne] = []), ae._genderSpecific[te][Ne].push(...Fe));
7525
7530
  } else
7526
- ye[ce] = Fe;
7527
- }), S && (S._genderSpecific && Object.keys(S._genderSpecific).forEach((ce) => {
7528
- ye._genderSpecific[ce] || (ye._genderSpecific[ce] = {}), Object.entries(S._genderSpecific[ce]).forEach(([Fe, Ue]) => {
7529
- ye._genderSpecific[ce][Fe] || (ye._genderSpecific[ce][Fe] = Ue);
7531
+ ae[me] = Fe;
7532
+ }), C && (C._genderSpecific && Object.keys(C._genderSpecific).forEach((me) => {
7533
+ ae._genderSpecific[me] || (ae._genderSpecific[me] = {}), Object.entries(C._genderSpecific[me]).forEach(([Fe, Ve]) => {
7534
+ ae._genderSpecific[me][Fe] || (ae._genderSpecific[me][Fe] = Ve);
7530
7535
  });
7531
- }), Object.entries(S).forEach(([ce, Fe]) => {
7532
- ce !== "_genderSpecific" && !ye[ce] && (ye[ce] = Fe);
7533
- })), M(ye);
7534
- } else if (typeof T.auto == "object") {
7535
- const P = await et(T.auto, e), K = Object.values(P).some((te) => Array.isArray(te) && te.length > 0);
7536
- M(!K && S ? S : P);
7536
+ }), Object.entries(C).forEach(([me, Fe]) => {
7537
+ me !== "_genderSpecific" && !ae[me] && (ae[me] = Fe);
7538
+ })), E(ae);
7539
+ } else if (typeof m.auto == "object") {
7540
+ const P = await nt(m.auto, e), Q = Object.values(P).some((te) => Array.isArray(te) && te.length > 0);
7541
+ E(!Q && C ? C : P);
7537
7542
  }
7538
- } catch (S) {
7539
- if (console.error("Failed to auto-discover animations:", S), T.manifest)
7543
+ } catch (C) {
7544
+ if (console.error("Failed to auto-discover animations:", C), m.manifest)
7540
7545
  try {
7541
- const P = await Ne(T.manifest);
7542
- M(P);
7546
+ const P = await Ue(m.manifest);
7547
+ E(P);
7543
7548
  } catch {
7544
- M(T);
7549
+ E(m);
7545
7550
  }
7546
7551
  else
7547
- M(T);
7552
+ E(m);
7548
7553
  }
7549
7554
  else
7550
- M(T);
7555
+ E(m);
7551
7556
  })();
7552
- }, [T, e, ke]), xe(() => {
7553
- w.current = u;
7557
+ }, [m, e, Oe]), Re(() => {
7558
+ T.current = u;
7554
7559
  }, [u]);
7555
- const Ie = Ye(), Oe = s || Ie.service;
7556
- let He;
7557
- Oe === "browser" ? He = {
7560
+ const ke = qe(), Be = s || ke.service;
7561
+ let w;
7562
+ Be === "browser" ? w = {
7558
7563
  service: "browser",
7559
7564
  endpoint: "",
7560
7565
  apiKey: null,
7561
7566
  defaultVoice: "Google US English"
7562
- } : Oe === "elevenlabs" ? He = {
7567
+ } : Be === "elevenlabs" ? w = {
7563
7568
  service: "elevenlabs",
7564
7569
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
7565
- apiKey: a || Ie.apiKey,
7566
- defaultVoice: i || Ie.defaultVoice || Pe.defaultVoice,
7567
- voices: Ie.voices || Pe.voices
7568
- } : Oe === "deepgram" ? He = {
7570
+ apiKey: a || ke.apiKey,
7571
+ defaultVoice: i || ke.defaultVoice || Pe.defaultVoice,
7572
+ voices: ke.voices || Pe.voices
7573
+ } : Be === "deepgram" ? w = {
7569
7574
  service: "deepgram",
7570
7575
  endpoint: "https://api.deepgram.com/v1/speak",
7571
- apiKey: a || Ie.apiKey,
7572
- defaultVoice: i || Ie.defaultVoice || Ze.defaultVoice,
7573
- voices: Ie.voices || Ze.voices
7574
- } : He = {
7575
- ...Ie,
7576
- apiKey: a !== null ? a : Ie.apiKey
7576
+ apiKey: a || ke.apiKey,
7577
+ defaultVoice: i || ke.defaultVoice || je.defaultVoice,
7578
+ voices: ke.voices || je.voices
7579
+ } : w = {
7580
+ ...ke,
7581
+ apiKey: a !== null ? a : ke.apiKey
7577
7582
  };
7578
- const C = {
7583
+ const Y = {
7579
7584
  url: t,
7580
7585
  body: e,
7581
7586
  avatarMood: n,
7582
- ttsLang: Oe === "browser" ? "en-US" : o,
7583
- ttsVoice: i || He.defaultVoice,
7587
+ ttsLang: Be === "browser" ? "en-US" : o,
7588
+ ttsVoice: i || w.defaultVoice,
7584
7589
  lipsyncLang: "en",
7585
7590
  showFullAvatar: u,
7586
7591
  bodyMovement: c,
7587
7592
  movementIntensity: l
7588
- }, Y = {
7589
- ttsEndpoint: He.endpoint,
7590
- ttsApikey: He.apiKey,
7591
- ttsService: Oe,
7593
+ }, ee = {
7594
+ ttsEndpoint: w.endpoint,
7595
+ ttsApikey: w.apiKey,
7596
+ ttsService: Be,
7592
7597
  lipsyncModules: ["en"],
7593
7598
  cameraView: r
7594
- }, ee = N(async () => {
7595
- if (!(!F.current || f.current))
7599
+ }, se = N(async () => {
7600
+ if (!(!L.current || f.current))
7596
7601
  try {
7597
- ue(!0), ve(null), f.current = new Qe(F.current, Y), await f.current.showAvatar(C, (S) => {
7598
- if (S.lengthComputable) {
7599
- const P = Math.min(100, Math.round(S.loaded / S.total * 100));
7602
+ re(!0), ce(null), f.current = new _e(L.current, ee), await f.current.showAvatar(Y, (C) => {
7603
+ if (C.lengthComputable) {
7604
+ const P = Math.min(100, Math.round(C.loaded / C.total * 100));
7600
7605
  h(P);
7601
7606
  }
7602
- }), ue(!1), ze(!0), d(f.current);
7603
- const L = () => {
7607
+ }), re(!1), ie(!0), d(f.current);
7608
+ const S = () => {
7604
7609
  document.visibilityState === "visible" ? f.current?.start() : f.current?.stop();
7605
7610
  };
7606
- return document.addEventListener("visibilitychange", L), () => {
7607
- document.removeEventListener("visibilitychange", L);
7611
+ return document.addEventListener("visibilitychange", S), () => {
7612
+ document.removeEventListener("visibilitychange", S);
7608
7613
  };
7609
- } catch (L) {
7610
- console.error("Error initializing TalkingHead:", L), ve(L.message || "Failed to initialize avatar"), ue(!1), g(L);
7614
+ } catch (S) {
7615
+ console.error("Error initializing TalkingHead:", S), ce(S.message || "Failed to initialize avatar"), re(!1), g(S);
7611
7616
  }
7612
7617
  }, []);
7613
- xe(() => (ee(), () => {
7618
+ Re(() => (se(), () => {
7614
7619
  f.current && (f.current.stop(), f.current.dispose(), f.current = null);
7615
- }), [ee]);
7616
- const ie = N(async () => {
7620
+ }), [se]);
7621
+ const he = N(async () => {
7617
7622
  if (f.current)
7618
7623
  try {
7619
- const L = f.current.audioCtx || f.current.audioContext;
7620
- L && (L.state === "suspended" || L.state === "interrupted") && await L.resume();
7621
- } catch (L) {
7622
- console.warn("Failed to resume audio context:", L);
7624
+ const S = f.current.audioCtx || f.current.audioContext;
7625
+ S && (S.state === "suspended" || S.state === "interrupted") && await S.resume();
7626
+ } catch (S) {
7627
+ console.warn("Failed to resume audio context:", S);
7623
7628
  }
7624
- }, []), be = N((L) => {
7625
- if (!A)
7629
+ }, []), _ = N((S) => {
7630
+ if (!H)
7626
7631
  return [];
7627
- let S = null;
7628
- if (A._genderSpecific) {
7629
- const P = ke(e);
7630
- console.log(`🔍 Gender detection: avatarBody="${e}" -> genderKey="${P}"`);
7631
- const K = A._genderSpecific[P];
7632
- K && K[L] ? (S = K[L], console.log(`✅ Found ${P} animations for "${L}": ${Array.isArray(S) ? S.length : 1} animation(s)`)) : A._genderSpecific.shared && A._genderSpecific.shared[L] ? (S = A._genderSpecific.shared[L], console.log(`✅ Found shared animations for "${L}": ${Array.isArray(S) ? S.length : 1} animation(s)`)) : console.log(`⚠️ No ${P} or shared animations found for "${L}"`);
7632
+ let C = null;
7633
+ if (H._genderSpecific) {
7634
+ const P = Oe(e), Q = H._genderSpecific[P];
7635
+ Q && Q[S] ? C = Q[S] : H._genderSpecific.shared && H._genderSpecific.shared[S] && (C = H._genderSpecific.shared[S]);
7633
7636
  }
7634
- return !S && A[L] && (S = A[L], console.log(`✅ Found root-level animations for "${L}": ${Array.isArray(S) ? S.length : 1} animation(s)`)), S ? Array.isArray(S) ? [...S] : typeof S == "string" ? [S] : [] : (console.log(`❌ No animations found for "${L}"`), []);
7635
- }, [A, e, ke]), _ = N((L) => {
7636
- const S = [...L];
7637
- for (let P = S.length - 1; P > 0; P--) {
7638
- const K = Math.floor(Math.random() * (P + 1));
7639
- [S[P], S[K]] = [S[K], S[P]];
7637
+ return !C && H[S] && (C = H[S]), C ? Array.isArray(C) ? [...C] : typeof C == "string" ? [C] : [] : ((Object.keys(H).length > 0 || H._genderSpecific && Object.keys(H._genderSpecific).length > 0) && console.warn(`⚠️ No animations found for group "${S}". Make sure animations are configured correctly.`), []);
7638
+ }, [H, e, Oe]), fe = N((S) => {
7639
+ const C = [...S];
7640
+ for (let P = C.length - 1; P > 0; P--) {
7641
+ const Q = Math.floor(Math.random() * (P + 1));
7642
+ [C[P], C[Q]] = [C[Q], C[P]];
7640
7643
  }
7641
- return S;
7642
- }, []), me = N((L) => {
7643
- if (q.current.length === 0) {
7644
- const P = be(L);
7644
+ return C;
7645
+ }, []), Me = N((S) => {
7646
+ if (ve.current.length === 0) {
7647
+ const P = _(S);
7645
7648
  if (P.length === 0)
7646
7649
  return null;
7647
- q.current = _(P), ne.current = [];
7650
+ ve.current = fe(P), K.current = [];
7648
7651
  }
7649
- const S = q.current.shift();
7650
- return S && ne.current.push(S), S;
7651
- }, [be, _]), Me = N((L) => L ? L.split("/").pop().replace(".fbx", "").replace(/[-_]/g, " ") : "Unknown", []), pe = N((L, S = !1, P = null) => {
7652
+ const C = ve.current.shift();
7653
+ return C && K.current.push(C), C;
7654
+ }, [_, fe]), Ce = N((S) => S ? S.split("/").pop().replace(".fbx", "").replace(/[-_]/g, " ") : "Unknown", []), ue = N((S, C = !1, P = null) => {
7652
7655
  if (!f.current)
7653
7656
  return null;
7654
- const K = me(L);
7655
- if (K)
7657
+ const Q = Me(S);
7658
+ if (Q)
7656
7659
  try {
7657
- const te = Me(K);
7660
+ const te = Ce(Q);
7658
7661
  console.log(`🎬 Playing animation: "${te}"`);
7659
- const Le = () => {
7660
- Z.current && se.current === L && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) ? setTimeout(() => {
7661
- pe(L, S, P);
7662
- }, 100) : (Z.current = !1, se.current = null, P && P());
7662
+ const Ie = () => {
7663
+ oe.current && $.current === S && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) ? setTimeout(() => {
7664
+ ue(S, C, P);
7665
+ }, 100) : (oe.current = !1, $.current = null, P && P());
7663
7666
  };
7664
- return f.current.playAnimation(K, null, 0, 0, 0.01, S, Le), K;
7667
+ return f.current.playAnimation(Q, null, 0, 0, 0.01, C, Ie), Q;
7665
7668
  } catch (te) {
7666
7669
  return console.error("Failed to play animation:", te), null;
7667
7670
  }
7668
7671
  else
7669
- Z.current && se.current === L && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) && (q.current = [], ne.current = [], setTimeout(() => {
7670
- pe(L, S, P);
7672
+ oe.current && $.current === S && f.current && (f.current.isSpeaking || f.current.audioPlaylist && f.current.audioPlaylist.length > 0 || f.current.speechQueue && f.current.speechQueue.length > 0) && (ve.current = [], K.current = [], setTimeout(() => {
7673
+ ue(S, C, P);
7671
7674
  }, 100));
7672
7675
  return null;
7673
- }, [me, Me]), ge = N(async (L, S = {}) => {
7674
- if (!f.current || !re || !L || L.trim() === "")
7676
+ }, [Me, Ce]), de = N(async (S, C = {}) => {
7677
+ if (!f.current || !ye || !S || S.trim() === "")
7675
7678
  return;
7676
- await ie();
7677
- const P = S.animationGroup || p;
7678
- P && !S.skipAnimation && (Z.current = !0, se.current = P, q.current = [], ne.current = [], pe(P)), G.current = { remainingText: null, originalText: null, options: null }, X.current = [], H.current = { text: L, options: S }, I.current && (clearInterval(I.current), I.current = null), v(!1), U.current = !1;
7679
- const K = L.split(/[.!?]+/).filter((Le) => Le.trim().length > 0);
7680
- X.current = K;
7679
+ await he();
7680
+ const P = C.animationGroup || B;
7681
+ P && !C.skipAnimation && (oe.current = !0, $.current = P, ve.current = [], K.current = [], ue(P));
7682
+ try {
7683
+ R(S), C.onSpeechStart && C.onSpeechStart(S);
7684
+ } catch (Ie) {
7685
+ console.warn("Error in onSpeechStart callback:", Ie);
7686
+ }
7687
+ X.current = { remainingText: null, originalText: null, options: null }, j.current = [], A.current = { text: S, options: C }, D.current && (clearInterval(D.current), D.current = null), I(!1), U.current = !1;
7688
+ const Q = S.split(/[.!?]+/).filter((Ie) => Ie.trim().length > 0);
7689
+ j.current = Q;
7681
7690
  const te = {
7682
- lipsyncLang: S.lipsyncLang || "en",
7691
+ lipsyncLang: C.lipsyncLang || "en",
7683
7692
  onSpeechEnd: () => {
7684
- I.current && (clearInterval(I.current), I.current = null), Z.current = !1, se.current = null, q.current = [], ne.current = [], S.onSpeechEnd && S.onSpeechEnd(), R();
7693
+ D.current && (clearInterval(D.current), D.current = null), oe.current = !1, $.current = null, ve.current = [], K.current = [], C.onSpeechEnd && C.onSpeechEnd(), x();
7685
7694
  }
7686
7695
  };
7687
7696
  try {
7688
- f.current.speakText(L, te);
7689
- } catch (Le) {
7690
- console.error("Error speaking text:", Le), ve(Le.message || "Failed to speak text");
7697
+ f.current.speakText(S, te);
7698
+ } catch (Ie) {
7699
+ console.error("Error speaking text:", Ie), ce(Ie.message || "Failed to speak text");
7691
7700
  }
7692
- }, [re, R, ie, p, pe]);
7693
- xe(() => {
7694
- if (!re || !O || !f.current)
7701
+ }, [ye, x, he, B, ue]);
7702
+ Re(() => {
7703
+ if (!ye || !M || !f.current)
7695
7704
  return;
7696
- D.current && clearInterval(D.current);
7697
- const L = () => {
7698
- f.current && !U.current && pe(O);
7705
+ Z.current && clearInterval(Z.current);
7706
+ const S = () => {
7707
+ f.current && !U.current && ue(M);
7699
7708
  };
7700
- return L(), D.current = setInterval(() => {
7701
- L();
7709
+ return S(), Z.current = setInterval(() => {
7710
+ S();
7702
7711
  }, 12e3 + Math.random() * 3e3), () => {
7703
- D.current && (clearInterval(D.current), D.current = null);
7712
+ Z.current && (clearInterval(Z.current), Z.current = null);
7704
7713
  };
7705
- }, [re, O, pe]), xe(() => {
7706
- re && V && E && f.current && ge(V);
7707
- }, [re, V, E, ge]);
7708
- const Ae = N(() => {
7714
+ }, [ye, M, ue]), Re(() => {
7715
+ ye && W && y && f.current && de(W);
7716
+ }, [ye, W, y, de]);
7717
+ const De = N(() => {
7709
7718
  if (f.current)
7710
7719
  try {
7711
- const L = f.current.isSpeaking || !1, S = f.current.audioPlaylist || [], P = f.current.speechQueue || [];
7712
- if (L || S.length > 0 || P.length > 0) {
7713
- I.current && (clearInterval(I.current), I.current = null);
7714
- let K = "";
7715
- P.length > 0 && (K = P.map((te) => te.text && Array.isArray(te.text) ? te.text.map((Le) => Le.word).join(" ") : te.text || "").join(" ")), G.current = {
7716
- remainingText: K || null,
7717
- originalText: H.current?.text || null,
7718
- options: H.current?.options || null
7719
- }, f.current.speechQueue.length = 0, f.current.pauseSpeaking(), v(!0), U.current = !0;
7720
+ const S = f.current.isSpeaking || !1, C = f.current.audioPlaylist || [], P = f.current.speechQueue || [];
7721
+ if (S || C.length > 0 || P.length > 0) {
7722
+ D.current && (clearInterval(D.current), D.current = null);
7723
+ let Q = "";
7724
+ P.length > 0 && (Q = P.map((Ae) => Ae.text && Array.isArray(Ae.text) ? Ae.text.map((ae) => ae.word).join(" ") : Ae.text || "").join(" "));
7725
+ let te = "";
7726
+ C.length > 0 && (te = C.map((Ae) => Ae.text ? Array.isArray(Ae.text) ? Ae.text.map((ae) => ae.word).join(" ") : Ae.text : "").filter((Ae) => Ae.trim().length > 0).join(" "));
7727
+ const Ie = te ? te + (Q ? " " + Q : "") : Q;
7728
+ X.current = {
7729
+ remainingText: Ie || null,
7730
+ originalText: A.current?.text || null,
7731
+ options: A.current?.options || null
7732
+ }, f.current.speechQueue.length = 0, f.current.pauseSpeaking(), I(!0), U.current = !0;
7720
7733
  }
7721
- } catch (L) {
7722
- console.warn("Error pausing speech:", L);
7734
+ } catch (S) {
7735
+ console.warn("Error pausing speech:", S);
7723
7736
  }
7724
- }, []), Be = N(async () => {
7725
- if (!(!f.current || !J))
7737
+ }, []), Ke = N(async () => {
7738
+ if (!(!f.current || !v))
7726
7739
  try {
7727
- await ie(), v(!1), U.current = !1;
7728
- const L = G.current?.remainingText, S = G.current?.originalText || H.current?.text, P = G.current?.options || H.current?.options || {}, K = L || S;
7729
- K && ge(K, P);
7730
- } catch (L) {
7731
- console.warn("Error resuming speech:", L), v(!1), U.current = !1;
7740
+ await he(), I(!1), U.current = !1;
7741
+ const S = X.current?.remainingText, C = X.current?.originalText || A.current?.text, P = X.current?.options || A.current?.options || {}, Q = S || C;
7742
+ Q && de(Q, P);
7743
+ } catch (S) {
7744
+ console.warn("Error resuming speech:", S), I(!1), U.current = !1;
7732
7745
  }
7733
- }, [J, ge, ie]), qe = N(() => {
7734
- f.current && (f.current.stopSpeaking(), I.current && (clearInterval(I.current), I.current = null), Z.current = !1, se.current = null, q.current = [], ne.current = [], v(!1), U.current = !1);
7735
- }, []);
7736
- return je(y, () => ({
7737
- speakText: ge,
7738
- pauseSpeaking: Ae,
7739
- resumeSpeaking: Be,
7740
- stopSpeaking: qe,
7741
- resumeAudioContext: ie,
7742
- isPaused: () => J,
7743
- setMood: (L) => f.current?.setMood(L),
7744
- setBodyMovement: (L) => {
7745
- f.current && f.current.setBodyMovement(L);
7746
+ }, [v, de, he]), We = N(() => {
7747
+ if (f.current) {
7748
+ f.current.stopSpeaking(), D.current && (clearInterval(D.current), D.current = null), oe.current = !1, $.current = null, ve.current = [], K.current = [], I(!1), U.current = !1;
7749
+ try {
7750
+ x();
7751
+ } catch (S) {
7752
+ console.warn("Error in onSpeechEnd callback (stopSpeaking):", S);
7753
+ }
7754
+ }
7755
+ }, [x]);
7756
+ return Qe(F, () => ({
7757
+ speakText: de,
7758
+ pauseSpeaking: De,
7759
+ resumeSpeaking: Ke,
7760
+ stopSpeaking: We,
7761
+ resumeAudioContext: he,
7762
+ isPaused: () => v,
7763
+ setMood: (S) => f.current?.setMood(S),
7764
+ setBodyMovement: (S) => {
7765
+ f.current && f.current.setBodyMovement(S);
7746
7766
  },
7747
- playAnimation: (L, S = !1) => {
7748
- f.current && f.current.playAnimation && f.current.playAnimation(L, null, 10, 0, 0.01, S);
7767
+ playAnimation: (S, C = !1) => {
7768
+ f.current && f.current.playAnimation && f.current.playAnimation(S, null, 10, 0, 0.01, C);
7749
7769
  },
7750
- playRandomAnimation: (L, S = !1) => pe(L, S),
7751
- getRandomAnimation: (L) => getRandomAnimation(L),
7752
- playReaction: (L) => f.current?.playReaction(L),
7770
+ playRandomAnimation: (S, C = !1) => ue(S, C),
7771
+ getRandomAnimation: (S) => getRandomAnimation(S),
7772
+ playReaction: (S) => f.current?.playReaction(S),
7753
7773
  playCelebration: () => f.current?.playCelebration(),
7754
- setShowFullAvatar: (L) => {
7755
- f.current && (w.current = L, f.current.setShowFullAvatar(L));
7774
+ setShowFullAvatar: (S) => {
7775
+ f.current && (T.current = S, f.current.setShowFullAvatar(S));
7756
7776
  },
7757
- isReady: re,
7777
+ isReady: ye,
7758
7778
  talkingHead: f.current
7759
- })), /* @__PURE__ */ Se("div", { className: `simple-talking-avatar-container ${b}`, style: k, children: [
7760
- /* @__PURE__ */ $(
7779
+ })), /* @__PURE__ */ we("div", { className: `simple-talking-avatar-container ${k}`, style: G, children: [
7780
+ /* @__PURE__ */ J(
7761
7781
  "div",
7762
7782
  {
7763
- ref: F,
7783
+ ref: L,
7764
7784
  className: "talking-head-viewer",
7765
7785
  style: {
7766
7786
  width: "100%",
@@ -7769,7 +7789,7 @@ const Ht = Xe(({
7769
7789
  }
7770
7790
  }
7771
7791
  ),
7772
- j && /* @__PURE__ */ $("div", { className: "loading-overlay", style: {
7792
+ xe && /* @__PURE__ */ J("div", { className: "loading-overlay", style: {
7773
7793
  position: "absolute",
7774
7794
  top: "50%",
7775
7795
  left: "50%",
@@ -7778,7 +7798,7 @@ const Ht = Xe(({
7778
7798
  fontSize: "18px",
7779
7799
  zIndex: 10
7780
7800
  }, children: "Loading avatar..." }),
7781
- le && /* @__PURE__ */ $("div", { className: "error-overlay", style: {
7801
+ Se && /* @__PURE__ */ J("div", { className: "error-overlay", style: {
7782
7802
  position: "absolute",
7783
7803
  top: "50%",
7784
7804
  left: "50%",
@@ -7789,12 +7809,12 @@ const Ht = Xe(({
7789
7809
  zIndex: 10,
7790
7810
  padding: "20px",
7791
7811
  borderRadius: "8px"
7792
- }, children: le })
7812
+ }, children: Se })
7793
7813
  ] });
7794
7814
  });
7795
- Ht.displayName = "SimpleTalkingAvatar";
7796
- const Tt = Xe(({
7797
- curriculumData: V = null,
7815
+ Tt.displayName = "SimpleTalkingAvatar";
7816
+ const Mt = Ye(({
7817
+ curriculumData: W = null,
7798
7818
  avatarConfig: t = {},
7799
7819
  animations: e = {},
7800
7820
  onLessonStart: n = () => {
@@ -7809,7 +7829,7 @@ const Tt = Xe(({
7809
7829
  },
7810
7830
  autoStart: c = !1
7811
7831
  }, l) => {
7812
- const u = W(null), r = W({
7832
+ const u = V(null), r = V({
7813
7833
  currentModuleIndex: 0,
7814
7834
  currentLessonIndex: 0,
7815
7835
  currentQuestionIndex: 0,
@@ -7819,18 +7839,18 @@ const Tt = Xe(({
7819
7839
  curriculumCompleted: !1,
7820
7840
  score: 0,
7821
7841
  totalQuestions: 0
7822
- }), d = W({
7842
+ }), d = V({
7823
7843
  onLessonStart: n,
7824
7844
  onLessonComplete: o,
7825
7845
  onQuestionAnswer: s,
7826
7846
  onCurriculumComplete: i,
7827
7847
  onCustomAction: a
7828
- }), h = W(null), g = W(null), R = W(null), b = W(null), k = W(null), T = W(null), p = W(null), O = W(V?.curriculum || {
7848
+ }), h = V(null), g = V(null), R = V(null), x = V(null), k = V(null), G = V(null), m = V(null), B = V(W?.curriculum || {
7829
7849
  title: "Default Curriculum",
7830
7850
  description: "No curriculum data provided",
7831
7851
  language: "en",
7832
7852
  modules: []
7833
- }), E = W({
7853
+ }), M = V({
7834
7854
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7835
7855
  avatarBody: t.avatarBody || "F",
7836
7856
  mood: t.mood || "happy",
@@ -7844,7 +7864,7 @@ const Tt = Xe(({
7844
7864
  animations: e,
7845
7865
  lipsyncLang: "en"
7846
7866
  });
7847
- xe(() => {
7867
+ Re(() => {
7848
7868
  d.current = {
7849
7869
  onLessonStart: n,
7850
7870
  onLessonComplete: o,
@@ -7852,13 +7872,13 @@ const Tt = Xe(({
7852
7872
  onCurriculumComplete: i,
7853
7873
  onCustomAction: a
7854
7874
  };
7855
- }, [n, o, s, i, a]), xe(() => {
7856
- O.current = V?.curriculum || {
7875
+ }, [n, o, s, i, a]), Re(() => {
7876
+ B.current = W?.curriculum || {
7857
7877
  title: "Default Curriculum",
7858
7878
  description: "No curriculum data provided",
7859
7879
  language: "en",
7860
7880
  modules: []
7861
- }, E.current = {
7881
+ }, M.current = {
7862
7882
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7863
7883
  avatarBody: t.avatarBody || "F",
7864
7884
  mood: t.mood || "happy",
@@ -7872,12 +7892,12 @@ const Tt = Xe(({
7872
7892
  animations: e,
7873
7893
  lipsyncLang: "en"
7874
7894
  };
7875
- }, [V, t, e]);
7876
- const y = N(() => (O.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), F = N(() => y()?.questions[r.current.currentQuestionIndex], [y]), f = N((v, A) => A.type === "multiple_choice" || A.type === "true_false" ? v === A.answer : A.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), w = N(() => {
7895
+ }, [W, t, e]);
7896
+ const y = N(() => (B.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), F = N(() => y()?.questions[r.current.currentQuestionIndex], [y]), L = N((v, I) => I.type === "multiple_choice" || I.type === "true_false" ? v === I.answer : I.type === "code_test" && typeof v == "object" && v !== null ? v.passed === !0 : !1, []), f = N(() => {
7877
7897
  r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
7878
7898
  const v = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
7879
- let A = "Congratulations! You've completed this lesson";
7880
- if (r.current.totalQuestions > 0 ? A += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${v} percent. ` : A += "! ", v >= 80 ? A += "Excellent work! You have a great understanding of this topic." : v >= 60 ? A += "Good job! You understand most of the concepts." : A += "Keep practicing! You're making progress.", d.current.onLessonComplete({
7899
+ let I = "Congratulations! You've completed this lesson";
7900
+ if (r.current.totalQuestions > 0 ? I += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${v} percent. ` : I += "! ", v >= 80 ? I += "Excellent work! You have a great understanding of this topic." : v >= 60 ? I += "Good job! You understand most of the concepts." : I += "Keep practicing! You're making progress.", d.current.onLessonComplete({
7881
7901
  moduleIndex: r.current.currentModuleIndex,
7882
7902
  lessonIndex: r.current.currentLessonIndex,
7883
7903
  score: r.current.score,
@@ -7897,9 +7917,9 @@ const Tt = Xe(({
7897
7917
  } catch {
7898
7918
  u.current.playCelebration();
7899
7919
  }
7900
- const M = O.current || { modules: [] }, D = M.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, se = r.current.currentModuleIndex < (M.modules?.length || 0) - 1, ne = Z || se, q = E.current || { lipsyncLang: "en" };
7901
- u.current.speakText(A, {
7902
- lipsyncLang: q.lipsyncLang,
7920
+ const H = B.current || { modules: [] }, E = H.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (E?.lessons?.length || 0) - 1, oe = r.current.currentModuleIndex < (H.modules?.length || 0) - 1, $ = Z || oe, K = M.current || { lipsyncLang: "en" };
7921
+ u.current.speakText(I, {
7922
+ lipsyncLang: K.lipsyncLang,
7903
7923
  onSpeechEnd: () => {
7904
7924
  d.current.onCustomAction({
7905
7925
  type: "lessonCompleteFeedbackDone",
@@ -7908,17 +7928,17 @@ const Tt = Xe(({
7908
7928
  score: r.current.score,
7909
7929
  totalQuestions: r.current.totalQuestions,
7910
7930
  percentage: v,
7911
- hasNextLesson: ne
7931
+ hasNextLesson: $
7912
7932
  });
7913
7933
  }
7914
7934
  });
7915
7935
  }
7916
- }, [e.lessonComplete]), H = N(() => {
7936
+ }, [e.lessonComplete]), T = N(() => {
7917
7937
  r.current.curriculumCompleted = !0;
7918
- const v = O.current || { modules: [] };
7938
+ const v = B.current || { modules: [] };
7919
7939
  if (d.current.onCurriculumComplete({
7920
7940
  modules: v.modules.length,
7921
- totalLessons: v.modules.reduce((A, M) => A + M.lessons.length, 0)
7941
+ totalLessons: v.modules.reduce((I, H) => I + H.lessons.length, 0)
7922
7942
  }), u.current) {
7923
7943
  if (u.current.setMood("celebrating"), e.curriculumComplete)
7924
7944
  try {
@@ -7926,99 +7946,99 @@ const Tt = Xe(({
7926
7946
  } catch {
7927
7947
  u.current.playCelebration();
7928
7948
  }
7929
- const A = E.current || { lipsyncLang: "en" };
7930
- u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: A.lipsyncLang });
7949
+ const I = M.current || { lipsyncLang: "en" };
7950
+ u.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: I.lipsyncLang });
7931
7951
  }
7932
- }, [e.curriculumComplete]), I = N(() => {
7952
+ }, [e.curriculumComplete]), A = N(() => {
7933
7953
  const v = y();
7934
7954
  r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = v?.questions?.length || 0, r.current.score = 0;
7935
- const A = F();
7936
- A && d.current.onCustomAction({
7955
+ const I = F();
7956
+ I && d.current.onCustomAction({
7937
7957
  type: "questionStart",
7938
7958
  moduleIndex: r.current.currentModuleIndex,
7939
7959
  lessonIndex: r.current.currentLessonIndex,
7940
7960
  questionIndex: r.current.currentQuestionIndex,
7941
7961
  totalQuestions: r.current.totalQuestions,
7942
- question: A,
7962
+ question: I,
7943
7963
  score: r.current.score
7944
7964
  });
7945
- const M = () => {
7946
- if (!u.current || !A) return;
7965
+ const H = () => {
7966
+ if (!u.current || !I) return;
7947
7967
  if (u.current.setMood("happy"), e.questionStart)
7948
7968
  try {
7949
7969
  u.current.playAnimation(e.questionStart, !0);
7950
7970
  } catch (Z) {
7951
7971
  console.warn("Failed to play questionStart animation:", Z);
7952
7972
  }
7953
- const D = E.current || { lipsyncLang: "en" };
7954
- A.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${A.question}`, { lipsyncLang: D.lipsyncLang }) : A.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${A.question}`, { lipsyncLang: D.lipsyncLang }) : A.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${A.question}`, { lipsyncLang: D.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${A.question}`, { lipsyncLang: D.lipsyncLang });
7973
+ const E = M.current || { lipsyncLang: "en" };
7974
+ I.type === "code_test" ? u.current.speakText(`Let's test your coding skills! Here's your first challenge: ${I.question}`, { lipsyncLang: E.lipsyncLang }) : I.type === "multiple_choice" ? u.current.speakText(`Now let me ask you some questions. Here's the first one: ${I.question}`, { lipsyncLang: E.lipsyncLang }) : I.type === "true_false" ? u.current.speakText(`Let's start with some true or false questions. First question: ${I.question}`, { lipsyncLang: E.lipsyncLang }) : u.current.speakText(`Now let me ask you some questions. Here's the first one: ${I.question}`, { lipsyncLang: E.lipsyncLang });
7955
7975
  };
7956
- if (u.current && u.current.isReady && A)
7957
- M();
7976
+ if (u.current && u.current.isReady && I)
7977
+ H();
7958
7978
  else if (u.current && u.current.isReady) {
7959
- const D = E.current || { lipsyncLang: "en" };
7960
- u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: D.lipsyncLang });
7979
+ const E = M.current || { lipsyncLang: "en" };
7980
+ u.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: E.lipsyncLang });
7961
7981
  } else {
7962
- const D = setInterval(() => {
7963
- u.current && u.current.isReady && (clearInterval(D), A && M());
7982
+ const E = setInterval(() => {
7983
+ u.current && u.current.isReady && (clearInterval(E), I && H());
7964
7984
  }, 100);
7965
7985
  setTimeout(() => {
7966
- clearInterval(D);
7986
+ clearInterval(E);
7967
7987
  }, 5e3);
7968
7988
  }
7969
- }, [e.questionStart, y, F]), U = N(() => {
7989
+ }, [e.questionStart, y, F]), D = N(() => {
7970
7990
  const v = y();
7971
7991
  if (r.current.currentQuestionIndex < (v?.questions?.length || 0) - 1) {
7972
7992
  u.current && u.current.stopSpeaking && u.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
7973
- const A = F();
7974
- A && d.current.onCustomAction({
7993
+ const I = F();
7994
+ I && d.current.onCustomAction({
7975
7995
  type: "nextQuestion",
7976
7996
  moduleIndex: r.current.currentModuleIndex,
7977
7997
  lessonIndex: r.current.currentLessonIndex,
7978
7998
  questionIndex: r.current.currentQuestionIndex,
7979
7999
  totalQuestions: r.current.totalQuestions,
7980
- question: A,
8000
+ question: I,
7981
8001
  score: r.current.score
7982
8002
  });
7983
- const M = () => {
7984
- if (!u.current || !A) return;
8003
+ const H = () => {
8004
+ if (!u.current || !I) return;
7985
8005
  if (u.current.setMood("happy"), u.current.setBodyMovement("idle"), e.nextQuestion)
7986
8006
  try {
7987
8007
  u.current.playAnimation(e.nextQuestion, !0);
7988
- } catch (q) {
7989
- console.warn("Failed to play nextQuestion animation:", q);
8008
+ } catch (K) {
8009
+ console.warn("Failed to play nextQuestion animation:", K);
7990
8010
  }
7991
- const D = E.current || { lipsyncLang: "en" }, se = y()?.questions?.length || 0, ne = r.current.currentQuestionIndex >= se - 1;
7992
- if (A.type === "code_test") {
7993
- const q = ne ? `Great! Here's your final coding challenge: ${A.question}` : `Great! Now let's move on to your next coding challenge: ${A.question}`;
7994
- u.current.speakText(q, {
7995
- lipsyncLang: D.lipsyncLang
8011
+ const E = M.current || { lipsyncLang: "en" }, oe = y()?.questions?.length || 0, $ = r.current.currentQuestionIndex >= oe - 1;
8012
+ if (I.type === "code_test") {
8013
+ const K = $ ? `Great! Here's your final coding challenge: ${I.question}` : `Great! Now let's move on to your next coding challenge: ${I.question}`;
8014
+ u.current.speakText(K, {
8015
+ lipsyncLang: E.lipsyncLang
7996
8016
  });
7997
- } else if (A.type === "multiple_choice") {
7998
- const q = ne ? `Alright! Here's your final question: ${A.question}` : `Alright! Here's your next question: ${A.question}`;
7999
- u.current.speakText(q, {
8000
- lipsyncLang: D.lipsyncLang
8017
+ } else if (I.type === "multiple_choice") {
8018
+ const K = $ ? `Alright! Here's your final question: ${I.question}` : `Alright! Here's your next question: ${I.question}`;
8019
+ u.current.speakText(K, {
8020
+ lipsyncLang: E.lipsyncLang
8001
8021
  });
8002
- } else if (A.type === "true_false") {
8003
- const q = ne ? `Now let's try this final one: ${A.question}` : `Now let's try this one: ${A.question}`;
8004
- u.current.speakText(q, {
8005
- lipsyncLang: D.lipsyncLang
8022
+ } else if (I.type === "true_false") {
8023
+ const K = $ ? `Now let's try this final one: ${I.question}` : `Now let's try this one: ${I.question}`;
8024
+ u.current.speakText(K, {
8025
+ lipsyncLang: E.lipsyncLang
8006
8026
  });
8007
8027
  } else {
8008
- const q = ne ? `Here's your final question: ${A.question}` : `Here's the next question: ${A.question}`;
8009
- u.current.speakText(q, {
8010
- lipsyncLang: D.lipsyncLang
8028
+ const K = $ ? `Here's your final question: ${I.question}` : `Here's the next question: ${I.question}`;
8029
+ u.current.speakText(K, {
8030
+ lipsyncLang: E.lipsyncLang
8011
8031
  });
8012
8032
  }
8013
8033
  };
8014
- if (u.current && u.current.isReady && A)
8015
- M();
8016
- else if (A) {
8017
- const D = setInterval(() => {
8018
- u.current && u.current.isReady && (clearInterval(D), M());
8034
+ if (u.current && u.current.isReady && I)
8035
+ H();
8036
+ else if (I) {
8037
+ const E = setInterval(() => {
8038
+ u.current && u.current.isReady && (clearInterval(E), H());
8019
8039
  }, 100);
8020
8040
  setTimeout(() => {
8021
- clearInterval(D);
8041
+ clearInterval(E);
8022
8042
  }, 5e3);
8023
8043
  }
8024
8044
  } else
@@ -8029,16 +8049,16 @@ const Tt = Xe(({
8029
8049
  totalQuestions: r.current.totalQuestions,
8030
8050
  score: r.current.score
8031
8051
  });
8032
- }, [e.nextQuestion, y, F]), G = N(() => {
8033
- const v = O.current || { modules: [] }, A = v.modules[r.current.currentModuleIndex];
8034
- if (r.current.currentLessonIndex < (A?.lessons?.length || 0) - 1) {
8052
+ }, [e.nextQuestion, y, F]), U = N(() => {
8053
+ const v = B.current || { modules: [] }, I = v.modules[r.current.currentModuleIndex];
8054
+ if (r.current.currentLessonIndex < (I?.lessons?.length || 0) - 1) {
8035
8055
  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;
8036
- const D = v.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, se = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, ne = Z || se;
8056
+ const E = v.modules[r.current.currentModuleIndex], Z = r.current.currentLessonIndex < (E?.lessons?.length || 0) - 1, oe = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, $ = Z || oe;
8037
8057
  d.current.onCustomAction({
8038
8058
  type: "lessonStart",
8039
8059
  moduleIndex: r.current.currentModuleIndex,
8040
8060
  lessonIndex: r.current.currentLessonIndex,
8041
- hasNextLesson: ne
8061
+ hasNextLesson: $
8042
8062
  }), d.current.onLessonStart({
8043
8063
  moduleIndex: r.current.currentModuleIndex,
8044
8064
  lessonIndex: r.current.currentLessonIndex,
@@ -8046,12 +8066,12 @@ const Tt = Xe(({
8046
8066
  }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8047
8067
  } else if (r.current.currentModuleIndex < (v.modules?.length || 0) - 1) {
8048
8068
  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;
8049
- const Z = v.modules[r.current.currentModuleIndex], se = r.current.currentLessonIndex < (Z?.lessons?.length || 0) - 1, ne = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, q = se || ne;
8069
+ const Z = v.modules[r.current.currentModuleIndex], oe = r.current.currentLessonIndex < (Z?.lessons?.length || 0) - 1, $ = r.current.currentModuleIndex < (v.modules?.length || 0) - 1, K = oe || $;
8050
8070
  d.current.onCustomAction({
8051
8071
  type: "lessonStart",
8052
8072
  moduleIndex: r.current.currentModuleIndex,
8053
8073
  lessonIndex: r.current.currentLessonIndex,
8054
- hasNextLesson: q
8074
+ hasNextLesson: K
8055
8075
  }), d.current.onLessonStart({
8056
8076
  moduleIndex: r.current.currentModuleIndex,
8057
8077
  lessonIndex: r.current.currentLessonIndex,
@@ -8061,23 +8081,23 @@ const Tt = Xe(({
8061
8081
  k.current && k.current();
8062
8082
  }, []), X = N(() => {
8063
8083
  const v = y();
8064
- let A = null;
8084
+ let I = null;
8065
8085
  if (v?.avatar_script && v?.body) {
8066
- const M = v.avatar_script.trim(), D = v.body.trim(), Z = M.match(/[.!?]$/) ? " " : ". ";
8067
- A = `${M}${Z}${D}`;
8086
+ const H = v.avatar_script.trim(), E = v.body.trim(), Z = H.match(/[.!?]$/) ? " " : ". ";
8087
+ I = `${H}${Z}${E}`;
8068
8088
  } else
8069
- A = v?.avatar_script || v?.body || null;
8070
- if (u.current && u.current.isReady && A) {
8089
+ I = v?.avatar_script || v?.body || null;
8090
+ if (u.current && u.current.isReady && I) {
8071
8091
  r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, u.current.setMood("happy");
8072
- let M = !1;
8092
+ let H = !1;
8073
8093
  if (e.teaching)
8074
8094
  try {
8075
- u.current.playAnimation(e.teaching, !0), M = !0;
8095
+ u.current.playAnimation(e.teaching, !0), H = !0;
8076
8096
  } catch (Z) {
8077
8097
  console.warn("Failed to play teaching animation:", Z);
8078
8098
  }
8079
- M || u.current.setBodyMovement("gesturing");
8080
- const D = E.current || { lipsyncLang: "en" };
8099
+ H || u.current.setBodyMovement("gesturing");
8100
+ const E = M.current || { lipsyncLang: "en" };
8081
8101
  d.current.onLessonStart({
8082
8102
  moduleIndex: r.current.currentModuleIndex,
8083
8103
  lessonIndex: r.current.currentLessonIndex,
@@ -8087,8 +8107,8 @@ const Tt = Xe(({
8087
8107
  moduleIndex: r.current.currentModuleIndex,
8088
8108
  lessonIndex: r.current.currentLessonIndex,
8089
8109
  lesson: v
8090
- }), u.current.speakText(A, {
8091
- lipsyncLang: D.lipsyncLang,
8110
+ }), u.current.speakText(I, {
8111
+ lipsyncLang: E.lipsyncLang,
8092
8112
  onSpeechEnd: () => {
8093
8113
  r.current.isTeaching = !1, d.current.onCustomAction({
8094
8114
  type: "teachingComplete",
@@ -8107,16 +8127,16 @@ const Tt = Xe(({
8107
8127
  });
8108
8128
  }
8109
8129
  }, [e.teaching, y]), j = N((v) => {
8110
- const A = F(), M = f(v, A);
8111
- if (M && (r.current.score += 1), d.current.onQuestionAnswer({
8130
+ const I = F(), H = L(v, I);
8131
+ if (H && (r.current.score += 1), d.current.onQuestionAnswer({
8112
8132
  moduleIndex: r.current.currentModuleIndex,
8113
8133
  lessonIndex: r.current.currentLessonIndex,
8114
8134
  questionIndex: r.current.currentQuestionIndex,
8115
8135
  answer: v,
8116
- isCorrect: M,
8117
- question: A
8136
+ isCorrect: H,
8137
+ question: I
8118
8138
  }), u.current)
8119
- if (M) {
8139
+ if (H) {
8120
8140
  if (u.current.setMood("happy"), e.correct)
8121
8141
  try {
8122
8142
  u.current.playReaction("happy");
@@ -8126,11 +8146,11 @@ const Tt = Xe(({
8126
8146
  u.current.setBodyMovement("gesturing");
8127
8147
  const Z = y()?.questions?.length || 0;
8128
8148
  r.current.currentQuestionIndex >= Z - 1;
8129
- const se = r.current.currentQuestionIndex < Z - 1;
8130
- console.log("[CurriculumLearning] Answer feedback - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", se);
8131
- const ne = A.type === "code_test" ? `Great job! Your code passed all the tests! ${A.explanation || ""}` : `Excellent! That's correct! ${A.explanation || ""}`, q = E.current || { lipsyncLang: "en" };
8132
- u.current.speakText(ne, {
8133
- lipsyncLang: q.lipsyncLang,
8149
+ const oe = r.current.currentQuestionIndex < Z - 1;
8150
+ console.log("[CurriculumLearning] Answer feedback - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", oe);
8151
+ const $ = I.type === "code_test" ? `Great job! Your code passed all the tests! ${I.explanation || ""}` : `Excellent! That's correct! ${I.explanation || ""}`, K = M.current || { lipsyncLang: "en" };
8152
+ u.current.speakText($, {
8153
+ lipsyncLang: K.lipsyncLang,
8134
8154
  onSpeechEnd: () => {
8135
8155
  d.current.onCustomAction({
8136
8156
  type: "answerFeedbackComplete",
@@ -8138,7 +8158,7 @@ const Tt = Xe(({
8138
8158
  lessonIndex: r.current.currentLessonIndex,
8139
8159
  questionIndex: r.current.currentQuestionIndex,
8140
8160
  isCorrect: !0,
8141
- hasNextQuestion: se,
8161
+ hasNextQuestion: oe,
8142
8162
  score: r.current.score,
8143
8163
  totalQuestions: r.current.totalQuestions
8144
8164
  });
@@ -8152,11 +8172,11 @@ const Tt = Xe(({
8152
8172
  u.current.setBodyMovement("idle");
8153
8173
  }
8154
8174
  u.current.setBodyMovement("gesturing");
8155
- const Z = y()?.questions?.length || 0, se = r.current.currentQuestionIndex >= Z - 1, ne = r.current.currentQuestionIndex < Z - 1;
8156
- console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", ne);
8157
- const q = A.type === "code_test" ? `Your code didn't pass all the tests. ${A.explanation || "Try again!"}` : `Not quite right, but don't worry! ${A.explanation || ""}${se ? "" : " Let's move on to the next question."}`, ke = E.current || { lipsyncLang: "en" };
8158
- u.current.speakText(q, {
8159
- lipsyncLang: ke.lipsyncLang,
8175
+ const Z = y()?.questions?.length || 0, oe = r.current.currentQuestionIndex >= Z - 1, $ = r.current.currentQuestionIndex < Z - 1;
8176
+ console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", r.current.currentQuestionIndex, "totalQuestions:", Z, "hasNextQuestion:", $);
8177
+ const K = I.type === "code_test" ? `Your code didn't pass all the tests. ${I.explanation || "Try again!"}` : `Not quite right, but don't worry! ${I.explanation || ""}${oe ? "" : " Let's move on to the next question."}`, ve = M.current || { lipsyncLang: "en" };
8178
+ u.current.speakText(K, {
8179
+ lipsyncLang: ve.lipsyncLang,
8160
8180
  onSpeechEnd: () => {
8161
8181
  d.current.onCustomAction({
8162
8182
  type: "answerFeedbackComplete",
@@ -8164,7 +8184,7 @@ const Tt = Xe(({
8164
8184
  lessonIndex: r.current.currentLessonIndex,
8165
8185
  questionIndex: r.current.currentQuestionIndex,
8166
8186
  isCorrect: !1,
8167
- hasNextQuestion: ne,
8187
+ hasNextQuestion: $,
8168
8188
  score: r.current.score,
8169
8189
  totalQuestions: r.current.totalQuestions
8170
8190
  });
@@ -8178,24 +8198,24 @@ const Tt = Xe(({
8178
8198
  moduleIndex: r.current.currentModuleIndex,
8179
8199
  lessonIndex: r.current.currentLessonIndex,
8180
8200
  questionIndex: r.current.currentQuestionIndex,
8181
- isCorrect: M,
8201
+ isCorrect: H,
8182
8202
  hasNextQuestion: r.current.currentQuestionIndex < Z - 1,
8183
8203
  score: r.current.score,
8184
8204
  totalQuestions: r.current.totalQuestions,
8185
8205
  avatarNotReady: !0
8186
8206
  });
8187
8207
  }
8188
- }, [e.correct, e.incorrect, F, y, f]), ue = N((v) => {
8189
- const A = F();
8208
+ }, [e.correct, e.incorrect, F, y, L]), xe = N((v) => {
8209
+ const I = F();
8190
8210
  if (!v || typeof v != "object") {
8191
8211
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
8192
8212
  return;
8193
8213
  }
8194
- if (A?.type !== "code_test") {
8214
+ if (I?.type !== "code_test") {
8195
8215
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
8196
8216
  return;
8197
8217
  }
8198
- const M = {
8218
+ const H = {
8199
8219
  passed: v.passed === !0,
8200
8220
  results: v.results || [],
8201
8221
  output: v.output || "",
@@ -8210,10 +8230,10 @@ const Tt = Xe(({
8210
8230
  moduleIndex: r.current.currentModuleIndex,
8211
8231
  lessonIndex: r.current.currentLessonIndex,
8212
8232
  questionIndex: r.current.currentQuestionIndex,
8213
- testResult: M,
8214
- question: A
8215
- }), p.current && p.current(M);
8216
- }, [F, f]), le = N(() => {
8233
+ testResult: H,
8234
+ question: I
8235
+ }), m.current && m.current(H);
8236
+ }, [F, L]), re = N(() => {
8217
8237
  if (r.current.currentQuestionIndex > 0) {
8218
8238
  r.current.currentQuestionIndex -= 1;
8219
8239
  const v = F();
@@ -8226,29 +8246,29 @@ const Tt = Xe(({
8226
8246
  question: v,
8227
8247
  score: r.current.score
8228
8248
  });
8229
- const A = () => {
8249
+ const I = () => {
8230
8250
  if (!u.current || !v) return;
8231
8251
  u.current.setMood("happy"), u.current.setBodyMovement("idle");
8232
- const M = E.current || { lipsyncLang: "en" };
8252
+ const H = M.current || { lipsyncLang: "en" };
8233
8253
  v.type === "code_test" ? u.current.speakText(`Let's go back to this coding challenge: ${v.question}`, {
8234
- lipsyncLang: M.lipsyncLang
8254
+ lipsyncLang: H.lipsyncLang
8235
8255
  }) : u.current.speakText(`Going back to: ${v.question}`, {
8236
- lipsyncLang: M.lipsyncLang
8256
+ lipsyncLang: H.lipsyncLang
8237
8257
  });
8238
8258
  };
8239
8259
  if (u.current && u.current.isReady && v)
8240
- A();
8260
+ I();
8241
8261
  else if (v) {
8242
- const M = setInterval(() => {
8243
- u.current && u.current.isReady && (clearInterval(M), A());
8262
+ const H = setInterval(() => {
8263
+ u.current && u.current.isReady && (clearInterval(H), I());
8244
8264
  }, 100);
8245
8265
  setTimeout(() => {
8246
- clearInterval(M);
8266
+ clearInterval(H);
8247
8267
  }, 5e3);
8248
8268
  }
8249
8269
  }
8250
- }, [F]), ve = N(() => {
8251
- const v = O.current || { modules: [] };
8270
+ }, [F]), Se = N(() => {
8271
+ const v = B.current || { modules: [] };
8252
8272
  if (v.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
8253
8273
  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, d.current.onCustomAction({
8254
8274
  type: "lessonStart",
@@ -8260,8 +8280,8 @@ const Tt = Xe(({
8260
8280
  lesson: y()
8261
8281
  }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8262
8282
  else if (r.current.currentModuleIndex > 0) {
8263
- const D = v.modules[r.current.currentModuleIndex - 1];
8264
- r.current.currentModuleIndex -= 1, r.current.currentLessonIndex = (D?.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, d.current.onCustomAction({
8283
+ const E = v.modules[r.current.currentModuleIndex - 1];
8284
+ r.current.currentModuleIndex -= 1, r.current.currentLessonIndex = (E?.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, d.current.onCustomAction({
8265
8285
  type: "lessonStart",
8266
8286
  moduleIndex: r.current.currentModuleIndex,
8267
8287
  lessonIndex: r.current.currentLessonIndex
@@ -8271,52 +8291,52 @@ const Tt = Xe(({
8271
8291
  lesson: y()
8272
8292
  }), u.current && (u.current.setMood("happy"), u.current.setBodyMovement("idle"));
8273
8293
  }
8274
- }, [y]), re = N(() => {
8294
+ }, [y]), ce = N(() => {
8275
8295
  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;
8276
- }, []), ze = N((v) => {
8296
+ }, []), ye = N((v) => {
8277
8297
  console.log("Avatar is ready!", v);
8278
- const A = y(), M = A?.avatar_script || A?.body;
8279
- c && M && setTimeout(() => {
8298
+ const I = y(), H = I?.avatar_script || I?.body;
8299
+ c && H && setTimeout(() => {
8280
8300
  h.current && h.current();
8281
8301
  }, 10);
8282
8302
  }, [c, y]);
8283
- st(() => {
8284
- h.current = X, g.current = G, R.current = w, b.current = U, k.current = H, T.current = I, p.current = j;
8285
- }), je(l, () => ({
8303
+ rt(() => {
8304
+ h.current = X, g.current = U, R.current = f, x.current = D, k.current = T, G.current = A, m.current = j;
8305
+ }), Qe(l, () => ({
8286
8306
  // Curriculum control methods
8287
8307
  startTeaching: X,
8288
- startQuestions: I,
8308
+ startQuestions: A,
8289
8309
  handleAnswerSelect: j,
8290
- handleCodeTestResult: ue,
8291
- nextQuestion: U,
8292
- previousQuestion: le,
8293
- nextLesson: G,
8294
- previousLesson: ve,
8295
- completeLesson: w,
8296
- completeCurriculum: H,
8297
- resetCurriculum: re,
8310
+ handleCodeTestResult: xe,
8311
+ nextQuestion: D,
8312
+ previousQuestion: re,
8313
+ nextLesson: U,
8314
+ previousLesson: Se,
8315
+ completeLesson: f,
8316
+ completeCurriculum: T,
8317
+ resetCurriculum: ce,
8298
8318
  getState: () => ({ ...r.current }),
8299
8319
  getCurrentQuestion: () => F(),
8300
8320
  getCurrentLesson: () => y(),
8301
8321
  // Direct access to avatar ref (always returns current value)
8302
8322
  getAvatarRef: () => u.current,
8303
8323
  // Convenience methods that delegate to avatar (always check current ref)
8304
- speakText: async (v, A = {}) => {
8324
+ speakText: async (v, I = {}) => {
8305
8325
  await u.current?.resumeAudioContext?.();
8306
- const M = E.current || { lipsyncLang: "en" };
8307
- u.current?.speakText(v, { ...A, lipsyncLang: A.lipsyncLang || M.lipsyncLang });
8326
+ const H = M.current || { lipsyncLang: "en" };
8327
+ u.current?.speakText(v, { ...I, lipsyncLang: I.lipsyncLang || H.lipsyncLang });
8308
8328
  },
8309
8329
  resumeAudioContext: async () => {
8310
8330
  if (u.current?.resumeAudioContext)
8311
8331
  return await u.current.resumeAudioContext();
8312
8332
  const v = u.current?.talkingHead;
8313
8333
  if (v?.audioCtx) {
8314
- const A = v.audioCtx;
8315
- if (A.state === "suspended" || A.state === "interrupted")
8334
+ const I = v.audioCtx;
8335
+ if (I.state === "suspended" || I.state === "interrupted")
8316
8336
  try {
8317
- await A.resume(), console.log("Audio context resumed via talkingHead");
8318
- } catch (M) {
8319
- console.warn("Failed to resume audio context:", M);
8337
+ await I.resume(), console.log("Audio context resumed via talkingHead");
8338
+ } catch (H) {
8339
+ console.warn("Failed to resume audio context:", H);
8320
8340
  }
8321
8341
  } else
8322
8342
  console.warn("Audio context not available yet");
@@ -8326,7 +8346,7 @@ const Tt = Xe(({
8326
8346
  resumeSpeaking: async () => await u.current?.resumeSpeaking(),
8327
8347
  isPaused: () => u.current && typeof u.current.isPaused < "u" ? u.current.isPaused : !1,
8328
8348
  setMood: (v) => u.current?.setMood(v),
8329
- playAnimation: (v, A) => u.current?.playAnimation(v, A),
8349
+ playAnimation: (v, I) => u.current?.playAnimation(v, I),
8330
8350
  setBodyMovement: (v) => u.current?.setBodyMovement(v),
8331
8351
  setMovementIntensity: (v) => u.current?.setMovementIntensity(v),
8332
8352
  playRandomDance: () => u.current?.playRandomDance(),
@@ -8337,10 +8357,10 @@ const Tt = Xe(({
8337
8357
  lockAvatarPosition: () => u.current?.lockAvatarPosition(),
8338
8358
  unlockAvatarPosition: () => u.current?.unlockAvatarPosition(),
8339
8359
  // Custom action trigger
8340
- triggerCustomAction: (v, A) => {
8360
+ triggerCustomAction: (v, I) => {
8341
8361
  d.current.onCustomAction({
8342
8362
  type: v,
8343
- ...A,
8363
+ ...I,
8344
8364
  state: { ...r.current }
8345
8365
  });
8346
8366
  },
@@ -8348,8 +8368,8 @@ const Tt = Xe(({
8348
8368
  handleResize: () => u.current?.handleResize(),
8349
8369
  // Avatar readiness check (always returns current value)
8350
8370
  isAvatarReady: () => u.current?.isReady || !1
8351
- }), [X, I, j, ue, U, G, w, H, re, F, y]);
8352
- const J = E.current || {
8371
+ }), [X, A, j, xe, D, U, f, T, ce, F, y]);
8372
+ const ie = M.current || {
8353
8373
  avatarUrl: "/avatars/brunette.glb",
8354
8374
  avatarBody: "F",
8355
8375
  mood: "happy",
@@ -8362,23 +8382,23 @@ const Tt = Xe(({
8362
8382
  showFullAvatar: !1,
8363
8383
  animations: e
8364
8384
  };
8365
- return /* @__PURE__ */ $("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ $(
8366
- tt,
8385
+ return /* @__PURE__ */ J("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ J(
8386
+ it,
8367
8387
  {
8368
8388
  ref: u,
8369
- avatarUrl: J.avatarUrl,
8370
- avatarBody: J.avatarBody,
8371
- mood: J.mood,
8372
- ttsLang: J.ttsLang,
8373
- ttsService: J.ttsService,
8374
- ttsVoice: J.ttsVoice,
8375
- ttsApiKey: J.ttsApiKey,
8376
- bodyMovement: J.bodyMovement,
8377
- movementIntensity: J.movementIntensity,
8378
- showFullAvatar: J.showFullAvatar,
8389
+ avatarUrl: ie.avatarUrl,
8390
+ avatarBody: ie.avatarBody,
8391
+ mood: ie.mood,
8392
+ ttsLang: ie.ttsLang,
8393
+ ttsService: ie.ttsService,
8394
+ ttsVoice: ie.ttsVoice,
8395
+ ttsApiKey: ie.ttsApiKey,
8396
+ bodyMovement: ie.bodyMovement,
8397
+ movementIntensity: ie.movementIntensity,
8398
+ showFullAvatar: ie.showFullAvatar,
8379
8399
  cameraView: "upper",
8380
- animations: J.animations,
8381
- onReady: ze,
8400
+ animations: ie.animations,
8401
+ onReady: ye,
8382
8402
  onLoading: () => {
8383
8403
  },
8384
8404
  onError: (v) => {
@@ -8387,115 +8407,115 @@ const Tt = Xe(({
8387
8407
  }
8388
8408
  ) });
8389
8409
  });
8390
- Tt.displayName = "CurriculumLearning";
8391
- function Wt({
8392
- manifestPath: V = "/animations/manifest.json",
8410
+ Mt.displayName = "CurriculumLearning";
8411
+ function Vt({
8412
+ manifestPath: W = "/animations/manifest.json",
8393
8413
  avatarBody: t = "F",
8394
8414
  onAnimationPlay: e = null,
8395
8415
  onAnimationsSelected: n = null,
8396
8416
  onDeleteAnimations: o = null,
8397
8417
  style: s = {}
8398
8418
  }) {
8399
- const [i, a] = ae([]), [c, l] = ae(/* @__PURE__ */ new Set()), [u, r] = ae(!0), [d, h] = ae(null), [g, R] = ae("all"), [b, k] = ae("");
8400
- xe(() => {
8419
+ const [i, a] = le([]), [c, l] = le(/* @__PURE__ */ new Set()), [u, r] = le(!0), [d, h] = le(null), [g, R] = le("all"), [x, k] = le("");
8420
+ Re(() => {
8401
8421
  (async () => {
8402
8422
  r(!0), h(null);
8403
8423
  try {
8404
- const H = await Ne(V), I = [];
8405
- if (H._genderSpecific) {
8406
- const G = (t?.toUpperCase() || "F") === "M" ? "male" : "female";
8407
- H._genderSpecific[G] && Object.entries(H._genderSpecific[G]).forEach(([X, j]) => {
8408
- (Array.isArray(j) ? j : [j]).forEach((le) => {
8409
- I.push({
8410
- path: le,
8424
+ const T = await Ue(W), A = [];
8425
+ if (T._genderSpecific) {
8426
+ const U = (t?.toUpperCase() || "F") === "M" ? "male" : "female";
8427
+ T._genderSpecific[U] && Object.entries(T._genderSpecific[U]).forEach(([X, j]) => {
8428
+ (Array.isArray(j) ? j : [j]).forEach((re) => {
8429
+ A.push({
8430
+ path: re,
8411
8431
  group: X,
8412
- gender: G,
8413
- name: le.split("/").pop().replace(".fbx", "")
8432
+ gender: U,
8433
+ name: re.split("/").pop().replace(".fbx", "")
8414
8434
  });
8415
8435
  });
8416
- }), H._genderSpecific.shared && Object.entries(H._genderSpecific.shared).forEach(([X, j]) => {
8417
- (Array.isArray(j) ? j : [j]).forEach((le) => {
8418
- I.push({
8419
- path: le,
8436
+ }), T._genderSpecific.shared && Object.entries(T._genderSpecific.shared).forEach(([X, j]) => {
8437
+ (Array.isArray(j) ? j : [j]).forEach((re) => {
8438
+ A.push({
8439
+ path: re,
8420
8440
  group: X,
8421
8441
  gender: "shared",
8422
- name: le.split("/").pop().replace(".fbx", "")
8442
+ name: re.split("/").pop().replace(".fbx", "")
8423
8443
  });
8424
8444
  });
8425
8445
  });
8426
8446
  }
8427
- Object.entries(H).forEach(([U, G]) => {
8428
- U !== "_genderSpecific" && (Array.isArray(G) ? G : [G]).forEach((j) => {
8429
- typeof j == "string" && I.push({
8447
+ Object.entries(T).forEach(([D, U]) => {
8448
+ D !== "_genderSpecific" && (Array.isArray(U) ? U : [U]).forEach((j) => {
8449
+ typeof j == "string" && A.push({
8430
8450
  path: j,
8431
- group: U,
8451
+ group: D,
8432
8452
  gender: "root",
8433
8453
  name: j.split("/").pop().replace(".fbx", "")
8434
8454
  });
8435
8455
  });
8436
- }), a(I), r(!1);
8437
- } catch (H) {
8438
- console.error("Failed to load animations:", H), h(H.message), r(!1);
8456
+ }), a(A), r(!1);
8457
+ } catch (T) {
8458
+ console.error("Failed to load animations:", T), h(T.message), r(!1);
8439
8459
  }
8440
8460
  })();
8441
- }, [V, t]);
8442
- const T = ["all", ...new Set(i.map((w) => w.group))], p = i.filter((w) => {
8443
- const H = g === "all" || w.group === g, I = b === "" || w.name.toLowerCase().includes(b.toLowerCase()) || w.path.toLowerCase().includes(b.toLowerCase());
8444
- return H && I;
8445
- }), O = (w) => {
8446
- const H = new Set(c);
8447
- H.has(w) ? H.delete(w) : H.add(w), l(H), n && n(Array.from(H));
8448
- }, E = () => {
8449
- const w = new Set(c);
8450
- p.forEach((H) => {
8451
- w.add(H.path);
8452
- }), l(w), n && n(Array.from(w));
8461
+ }, [W, t]);
8462
+ const G = ["all", ...new Set(i.map((f) => f.group))], m = i.filter((f) => {
8463
+ const T = g === "all" || f.group === g, A = x === "" || f.name.toLowerCase().includes(x.toLowerCase()) || f.path.toLowerCase().includes(x.toLowerCase());
8464
+ return T && A;
8465
+ }), B = (f) => {
8466
+ const T = new Set(c);
8467
+ T.has(f) ? T.delete(f) : T.add(f), l(T), n && n(Array.from(T));
8468
+ }, M = () => {
8469
+ const f = new Set(c);
8470
+ m.forEach((T) => {
8471
+ f.add(T.path);
8472
+ }), l(f), n && n(Array.from(f));
8453
8473
  }, y = () => {
8454
- const w = new Set(c);
8455
- p.forEach((H) => {
8456
- w.delete(H.path);
8457
- }), l(w), n && n(Array.from(w));
8474
+ const f = new Set(c);
8475
+ m.forEach((T) => {
8476
+ f.delete(T.path);
8477
+ }), l(f), n && n(Array.from(f));
8458
8478
  }, F = () => {
8459
- const H = i.filter((I) => !c.has(I.path)).map((I) => I.path);
8460
- if (H.length === 0) {
8479
+ const T = i.filter((A) => !c.has(A.path)).map((A) => A.path);
8480
+ if (T.length === 0) {
8461
8481
  alert("No animations to delete. Select animations to keep, then delete will remove the unselected ones.");
8462
8482
  return;
8463
8483
  }
8464
- window.confirm(`Are you sure you want to delete ${H.length} animation(s)?
8484
+ window.confirm(`Are you sure you want to delete ${T.length} animation(s)?
8465
8485
 
8466
8486
  This will delete:
8467
- ${H.slice(0, 5).join(`
8468
- `)}${H.length > 5 ? `
8469
- ...` : ""}`) && (o && o(H), a(i.filter((I) => c.has(I.path))), l(/* @__PURE__ */ new Set()));
8470
- }, f = (w) => {
8471
- e && e(w);
8487
+ ${T.slice(0, 5).join(`
8488
+ `)}${T.length > 5 ? `
8489
+ ...` : ""}`) && (o && o(T), a(i.filter((A) => c.has(A.path))), l(/* @__PURE__ */ new Set()));
8490
+ }, L = (f) => {
8491
+ e && e(f);
8472
8492
  };
8473
- return u ? /* @__PURE__ */ $("div", { style: { padding: "20px", textAlign: "center", ...s }, children: /* @__PURE__ */ $("p", { children: "Loading animations..." }) }) : d ? /* @__PURE__ */ $("div", { style: { padding: "20px", color: "red", ...s }, children: /* @__PURE__ */ Se("p", { children: [
8493
+ return u ? /* @__PURE__ */ J("div", { style: { padding: "20px", textAlign: "center", ...s }, children: /* @__PURE__ */ J("p", { children: "Loading animations..." }) }) : d ? /* @__PURE__ */ J("div", { style: { padding: "20px", color: "red", ...s }, children: /* @__PURE__ */ we("p", { children: [
8474
8494
  "Error loading animations: ",
8475
8495
  d
8476
- ] }) }) : /* @__PURE__ */ Se("div", { style: {
8496
+ ] }) }) : /* @__PURE__ */ we("div", { style: {
8477
8497
  padding: "20px",
8478
8498
  backgroundColor: "#2a2a2a",
8479
8499
  borderRadius: "8px",
8480
8500
  color: "#fff",
8481
8501
  ...s
8482
8502
  }, children: [
8483
- /* @__PURE__ */ $("h2", { style: { marginTop: 0 }, children: "Animation Selector" }),
8484
- /* @__PURE__ */ $("p", { style: { color: "#aaa", fontSize: "14px" }, children: "Click buttons to play animations. Select animations to keep, then delete will remove the rest." }),
8485
- /* @__PURE__ */ Se("div", { style: {
8503
+ /* @__PURE__ */ J("h2", { style: { marginTop: 0 }, children: "Animation Selector" }),
8504
+ /* @__PURE__ */ J("p", { style: { color: "#aaa", fontSize: "14px" }, children: "Click buttons to play animations. Select animations to keep, then delete will remove the rest." }),
8505
+ /* @__PURE__ */ we("div", { style: {
8486
8506
  display: "flex",
8487
8507
  gap: "10px",
8488
8508
  marginBottom: "20px",
8489
8509
  flexWrap: "wrap",
8490
8510
  alignItems: "center"
8491
8511
  }, children: [
8492
- /* @__PURE__ */ $(
8512
+ /* @__PURE__ */ J(
8493
8513
  "input",
8494
8514
  {
8495
8515
  type: "text",
8496
8516
  placeholder: "Search animations...",
8497
- value: b,
8498
- onChange: (w) => k(w.target.value),
8517
+ value: x,
8518
+ onChange: (f) => k(f.target.value),
8499
8519
  style: {
8500
8520
  padding: "8px 12px",
8501
8521
  borderRadius: "6px",
@@ -8508,11 +8528,11 @@ ${H.slice(0, 5).join(`
8508
8528
  }
8509
8529
  }
8510
8530
  ),
8511
- /* @__PURE__ */ $(
8531
+ /* @__PURE__ */ J(
8512
8532
  "select",
8513
8533
  {
8514
8534
  value: g,
8515
- onChange: (w) => R(w.target.value),
8535
+ onChange: (f) => R(f.target.value),
8516
8536
  style: {
8517
8537
  padding: "8px 12px",
8518
8538
  borderRadius: "6px",
@@ -8521,13 +8541,13 @@ ${H.slice(0, 5).join(`
8521
8541
  color: "#fff",
8522
8542
  fontSize: "14px"
8523
8543
  },
8524
- children: T.map((w) => /* @__PURE__ */ $("option", { value: w, children: w === "all" ? "All Groups" : w }, w))
8544
+ children: G.map((f) => /* @__PURE__ */ J("option", { value: f, children: f === "all" ? "All Groups" : f }, f))
8525
8545
  }
8526
8546
  ),
8527
- /* @__PURE__ */ $(
8547
+ /* @__PURE__ */ J(
8528
8548
  "button",
8529
8549
  {
8530
- onClick: E,
8550
+ onClick: M,
8531
8551
  style: {
8532
8552
  padding: "8px 16px",
8533
8553
  backgroundColor: "#4CAF50",
@@ -8540,7 +8560,7 @@ ${H.slice(0, 5).join(`
8540
8560
  children: "Select All Visible"
8541
8561
  }
8542
8562
  ),
8543
- /* @__PURE__ */ $(
8563
+ /* @__PURE__ */ J(
8544
8564
  "button",
8545
8565
  {
8546
8566
  onClick: y,
@@ -8556,7 +8576,7 @@ ${H.slice(0, 5).join(`
8556
8576
  children: "Deselect All Visible"
8557
8577
  }
8558
8578
  ),
8559
- /* @__PURE__ */ Se(
8579
+ /* @__PURE__ */ we(
8560
8580
  "button",
8561
8581
  {
8562
8582
  onClick: F,
@@ -8578,7 +8598,7 @@ ${H.slice(0, 5).join(`
8578
8598
  }
8579
8599
  )
8580
8600
  ] }),
8581
- /* @__PURE__ */ Se("div", { style: {
8601
+ /* @__PURE__ */ we("div", { style: {
8582
8602
  marginBottom: "15px",
8583
8603
  fontSize: "14px",
8584
8604
  color: "#aaa"
@@ -8588,9 +8608,9 @@ ${H.slice(0, 5).join(`
8588
8608
  " | Selected: ",
8589
8609
  c.size,
8590
8610
  " | Showing: ",
8591
- p.length
8611
+ m.length
8592
8612
  ] }),
8593
- /* @__PURE__ */ $("div", { style: {
8613
+ /* @__PURE__ */ J("div", { style: {
8594
8614
  display: "grid",
8595
8615
  gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
8596
8616
  gap: "10px",
@@ -8599,52 +8619,52 @@ ${H.slice(0, 5).join(`
8599
8619
  padding: "10px",
8600
8620
  backgroundColor: "#1a1a1a",
8601
8621
  borderRadius: "6px"
8602
- }, children: p.map((w, H) => {
8603
- const I = c.has(w.path);
8604
- return /* @__PURE__ */ Se(
8622
+ }, children: m.map((f, T) => {
8623
+ const A = c.has(f.path);
8624
+ return /* @__PURE__ */ we(
8605
8625
  "div",
8606
8626
  {
8607
8627
  style: {
8608
- border: `2px solid ${I ? "#4CAF50" : "#555"}`,
8628
+ border: `2px solid ${A ? "#4CAF50" : "#555"}`,
8609
8629
  borderRadius: "6px",
8610
8630
  padding: "10px",
8611
- backgroundColor: I ? "#2a4a2a" : "#222",
8631
+ backgroundColor: A ? "#2a4a2a" : "#222",
8612
8632
  cursor: "pointer",
8613
8633
  transition: "all 0.2s"
8614
8634
  },
8615
- onClick: () => O(w.path),
8635
+ onClick: () => B(f.path),
8616
8636
  children: [
8617
- /* @__PURE__ */ Se("div", { style: { marginBottom: "8px" }, children: [
8618
- /* @__PURE__ */ $(
8637
+ /* @__PURE__ */ we("div", { style: { marginBottom: "8px" }, children: [
8638
+ /* @__PURE__ */ J(
8619
8639
  "input",
8620
8640
  {
8621
8641
  type: "checkbox",
8622
- checked: I,
8623
- onChange: () => O(w.path),
8624
- onClick: (U) => U.stopPropagation(),
8642
+ checked: A,
8643
+ onChange: () => B(f.path),
8644
+ onClick: (D) => D.stopPropagation(),
8625
8645
  style: {
8626
8646
  marginRight: "8px",
8627
8647
  cursor: "pointer"
8628
8648
  }
8629
8649
  }
8630
8650
  ),
8631
- /* @__PURE__ */ Se("span", { style: { fontSize: "12px", color: "#aaa" }, children: [
8632
- w.group,
8651
+ /* @__PURE__ */ we("span", { style: { fontSize: "12px", color: "#aaa" }, children: [
8652
+ f.group,
8633
8653
  " ",
8634
- w.gender !== "root" && `(${w.gender})`
8654
+ f.gender !== "root" && `(${f.gender})`
8635
8655
  ] })
8636
8656
  ] }),
8637
- /* @__PURE__ */ $("div", { style: {
8657
+ /* @__PURE__ */ J("div", { style: {
8638
8658
  fontSize: "13px",
8639
8659
  fontWeight: "bold",
8640
8660
  marginBottom: "8px",
8641
8661
  wordBreak: "break-word"
8642
- }, children: w.name }),
8643
- /* @__PURE__ */ $(
8662
+ }, children: f.name }),
8663
+ /* @__PURE__ */ J(
8644
8664
  "button",
8645
8665
  {
8646
- onClick: (U) => {
8647
- U.stopPropagation(), f(w.path);
8666
+ onClick: (D) => {
8667
+ D.stopPropagation(), L(f.path);
8648
8668
  },
8649
8669
  style: {
8650
8670
  width: "100%",
@@ -8661,17 +8681,17 @@ ${H.slice(0, 5).join(`
8661
8681
  )
8662
8682
  ]
8663
8683
  },
8664
- `${w.path}-${H}`
8684
+ `${f.path}-${T}`
8665
8685
  );
8666
8686
  }) }),
8667
- p.length === 0 && /* @__PURE__ */ $("div", { style: {
8687
+ m.length === 0 && /* @__PURE__ */ J("div", { style: {
8668
8688
  padding: "40px",
8669
8689
  textAlign: "center",
8670
8690
  color: "#aaa"
8671
8691
  }, children: "No animations found matching your filters." })
8672
8692
  ] });
8673
8693
  }
8674
- const nt = {
8694
+ const ot = {
8675
8695
  // Code-based dance animations (no FBX required)
8676
8696
  dance: {
8677
8697
  name: "dance",
@@ -8774,16 +8794,16 @@ const nt = {
8774
8794
  duration: 5e3,
8775
8795
  description: "Excited, energetic movement"
8776
8796
  }
8777
- }, Vt = (V) => nt[V] || null, Gt = (V) => nt.hasOwnProperty(V);
8797
+ }, Gt = (W) => ot[W] || null, Zt = (W) => ot.hasOwnProperty(W);
8778
8798
  export {
8779
- Wt as AnimationSelector,
8780
- Tt as CurriculumLearning,
8781
- Ht as SimpleTalkingAvatar,
8782
- tt as TalkingHeadAvatar,
8783
- Ct as TalkingHeadComponent,
8784
- nt as animations,
8785
- Ye as getActiveTTSConfig,
8786
- Vt as getAnimation,
8787
- Ut as getVoiceOptions,
8788
- Gt as hasAnimation
8799
+ Vt as AnimationSelector,
8800
+ Mt as CurriculumLearning,
8801
+ Tt as SimpleTalkingAvatar,
8802
+ it as TalkingHeadAvatar,
8803
+ zt as TalkingHeadComponent,
8804
+ ot as animations,
8805
+ qe as getActiveTTSConfig,
8806
+ Gt as getAnimation,
8807
+ Wt as getVoiceOptions,
8808
+ Zt as hasAnimation
8789
8809
  };