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

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,20 +1,20 @@
1
- import { jsxs as De, jsx as ge } from "react/jsx-runtime";
2
- import { forwardRef as ze, useRef as N, useState as be, useEffect as Re, useCallback as M, useImperativeHandle as Ce, useLayoutEffect as Xe } from "react";
1
+ import { jsxs as Oe, jsx as ge } from "react/jsx-runtime";
2
+ import { forwardRef as ze, useRef as N, useState as be, useEffect as Ie, useCallback as M, useImperativeHandle as Ce, useLayoutEffect as Xe } from "react";
3
3
  import * as f from "three";
4
4
  import { OrbitControls as Ye } from "three/addons/controls/OrbitControls.js";
5
5
  import { GLTFLoader as je } from "three/addons/loaders/GLTFLoader.js";
6
6
  import { DRACOLoader as Qe } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as Me } from "three/addons/loaders/FBXLoader.js";
7
+ import { FBXLoader as Ee } from "three/addons/loaders/FBXLoader.js";
8
8
  import { RoomEnvironment as qe } from "three/addons/environments/RoomEnvironment.js";
9
9
  import _e from "three/addons/libs/stats.module.js";
10
- let m, ee, ne;
11
- const A = [0, 0, 0, 0], k = new f.Vector3(), Ae = new f.Vector3(), _ = new f.Vector3(), Se = new f.Vector3();
10
+ let m, te, ne;
11
+ const A = [0, 0, 0, 0], k = new f.Vector3(), Se = new f.Vector3(), _ = new f.Vector3(), ke = new f.Vector3();
12
12
  new f.Plane();
13
13
  new f.Ray();
14
14
  new f.Euler();
15
- const K = new f.Quaternion(), Ee = new f.Quaternion(), le = new f.Matrix4(), he = new f.Matrix4();
15
+ const K = new f.Quaternion(), Fe = new f.Quaternion(), le = new f.Matrix4(), he = new f.Matrix4();
16
16
  new f.Vector3();
17
- const ke = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), Je = new f.Vector3(0, 1, 0), $e = new f.Vector3(0, 0, 1);
17
+ const we = new f.Vector3(0, 0, 1), Ke = new f.Vector3(1, 0, 0), Je = new f.Vector3(0, 1, 0), $e = new f.Vector3(0, 0, 1);
18
18
  class et {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
@@ -338,7 +338,7 @@ class et {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- h.boneParent.matrixWorld.decompose(k, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ h.boneParent.matrixWorld.decompose(k, K, _), k.copy(we).applyQuaternion(K).setY(0).normalize(), K.premultiply(Fe.setFromUnitVectors(we, k).invert()).normalize(), h.qWorldInverseYaw = K.clone().normalize(), this.data.push(h), this.dict[u] = h;
342
342
  try {
343
343
  this.setValue(u, "type", s.type), this.setValue(u, "stiffness", s.stiffness), this.setValue(u, "damping", s.damping), this.setValue(u, "external", s.external), this.setValue(u, "limits", s.limits), this.setValue(u, "excludes", s.excludes), this.setValue(u, "deltaLocal", s.deltaLocal), this.setValue(u, "deltaWorld", s.deltaWorld), this.setValue(u, "pivot", s.pivot), this.setValue(u, "helper", s.helper);
344
344
  } catch (a) {
@@ -369,9 +369,9 @@ class et {
369
369
  o.vBasis.y + A[1],
370
370
  o.vBasis.z - A[2]
371
371
  );
372
- else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, K, _), k.copy(ke).applyQuaternion(K).setY(0).normalize(), K.premultiply(Ee.setFromUnitVectors(ke, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(K)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), K.setFromAxisAngle(Ke, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(K)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
372
+ else if (o.boneParent.quaternion.copy(o.qBasis), o.pivot && this.opt.isPivots && (o.boneParent.updateWorldMatrix(!1, !1), o.boneParent.matrixWorld.decompose(k, K, _), k.copy(we).applyQuaternion(K).setY(0).normalize(), K.premultiply(Fe.setFromUnitVectors(we, k).invert()).normalize(), o.boneParent.quaternion.multiply(K.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(A[0] / o.l), K.setFromAxisAngle($e, -m), o.boneParent.quaternion.multiply(K)), o.isY && (m = o.l / 3, m = m * Math.tanh(A[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(A[2] / o.l), K.setFromAxisAngle(Ke, -m), o.boneParent.quaternion.multiply(K)), o.isT && (m = 1.5 * Math.tanh(A[3] * 1.5), K.setFromAxisAngle(Je, -m), o.boneParent.quaternion.multiply(K)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (n = 0, s = o.excludes.length; n < s; n++)
374
- m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), he.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(he), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), ee = _.length(), !(ee > m.radius + ne) && (ee < Math.abs(m.radius - ne) || (ee = (ee * ee + ne * ne - m.radiusSq) / (2 * ee), _.normalize(), Se.copy(_).multiplyScalar(ee), ee = Math.sqrt(ne * ne - ee * ee), k.subVectors(k, Se).projectOnPlane(_).normalize().multiplyScalar(ee), Ae.subVectors(o.vBasis, Se).projectOnPlane(_).normalize(), ne = Ae.dot(k), ne < 0 && (ne = Math.sqrt(ee * ee - ne * ne), Ae.multiplyScalar(ne), k.add(Ae)), k.add(Se).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[n], _.set(0, 0, 0), m.deltaLocal && (_.x += m.deltaLocal[0], _.y += m.deltaLocal[1], _.z += m.deltaLocal[2]), _.applyMatrix4(m.bone.matrixWorld), he.copy(o.boneParent.matrixWorld).invert(), _.applyMatrix4(he), k.copy(o.bone.position), !(k.distanceToSquared(_) >= m.radiusSq) && (ne = k.length(), te = _.length(), !(te > m.radius + ne) && (te < Math.abs(m.radius - ne) || (te = (te * te + ne * ne - m.radiusSq) / (2 * te), _.normalize(), ke.copy(_).multiplyScalar(te), te = Math.sqrt(ne * ne - te * te), k.subVectors(k, ke).projectOnPlane(_).normalize().multiplyScalar(te), Se.subVectors(o.vBasis, ke).projectOnPlane(_).normalize(), ne = Se.dot(k), ne < 0 && (ne = Math.sqrt(te * te - ne * ne), Se.multiplyScalar(ne), k.add(Se)), k.add(ke).normalize(), _.copy(o.bone.position).normalize(), K.setFromUnitVectors(_, k), o.boneParent.quaternion.premultiply(K), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -608,8 +608,8 @@ class tt {
608
608
  for (let a = 0; a < i / 2; a++) {
609
609
  const c = n[(u + a) * 2], d = n[(u + a) * 2 + 1], g = n[(u + a + i / 2) * 2] * r - n[(u + a + i / 2) * 2 + 1] * h, y = n[(u + a + i / 2) * 2] * h + n[(u + a + i / 2) * 2 + 1] * r;
610
610
  n[(u + a) * 2] = c + g, n[(u + a) * 2 + 1] = d + y, n[(u + a + i / 2) * 2] = c - g, n[(u + a + i / 2) * 2 + 1] = d - y;
611
- const x = r * o - h * l, I = r * l + h * o;
612
- r = x, h = I;
611
+ const x = r * o - h * l, v = r * l + h * o;
612
+ r = x, h = v;
613
613
  }
614
614
  }
615
615
  }
@@ -2623,13 +2623,13 @@ class ut {
2623
2623
  const ct = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
2625
  LipsyncLt: ut
2626
- }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy5fc2FtcGxlUmF0ZSAqIHNpbGVuY2VEdXJhdGlvblNlY29uZHMpIC8gMTI4KTsKCiAgICAvLyBNZXRyaWNzIGNvbmZpZ3VyYXRpb24gdmlhIG9wdGlvbnMKICAgIGNvbnN0IG1ldHJpY3NDZmcgPSBvcHRpb25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mNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm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QKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Fe = {
2626
+ }, Symbol.toStringTag, { value: "Module" })), dt = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCBzaWxlbmNlRHVyYXRpb25TZWNvbmRzID0gMS4wOwogICAgdGhpcy5fc2lsZW5jZVRocmVzaG9sZEJsb2NrcyA9IE1hdGguY2VpbCgodGhpcy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PZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRd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cGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Pe = {
2627
2627
  en: it,
2628
2628
  de: st,
2629
2629
  fr: rt,
2630
2630
  fi: ht,
2631
2631
  lt: ct
2632
- }, G = new f.Quaternion(), E = new f.Euler(), ce = new f.Vector3(), pe = new f.Vector3(), Pe = new f.Box3();
2632
+ }, G = new f.Quaternion(), E = new f.Euler(), ce = new f.Vector3(), pe = new f.Vector3(), Be = new f.Box3();
2633
2633
  new f.Matrix4();
2634
2634
  new f.Matrix4();
2635
2635
  new f.Vector3();
@@ -2637,7 +2637,7 @@ new f.Vector3(0, 0, 1);
2637
2637
  const mt = new f.Vector3(1, 0, 0);
2638
2638
  new f.Vector3(0, 1, 0);
2639
2639
  new f.Vector3(0, 0, 1);
2640
- class Oe {
2640
+ class Ne {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -4204,13 +4204,13 @@ class Oe {
4204
4204
  const a = s.morphTargetDictionary[r], c = o.morphAttributes.position[a], d = o.morphAttributes.normal?.[a];
4205
4205
  l || (l = new f.Float32BufferAttribute(c.count * 3, 3), d && (u = new f.Float32BufferAttribute(c.count * 3, 3)));
4206
4206
  for (let g = 0; g < c.count; g++) {
4207
- const y = l.getX(g) + c.getX(g) * h, x = l.getY(g) + c.getY(g) * h, I = l.getZ(g) + c.getZ(g) * h;
4208
- l.setXYZ(g, y, x, I);
4207
+ const y = l.getX(g) + c.getX(g) * h, x = l.getY(g) + c.getY(g) * h, v = l.getZ(g) + c.getZ(g) * h;
4208
+ l.setXYZ(g, y, x, v);
4209
4209
  }
4210
4210
  if (d)
4211
4211
  for (let g = 0; g < c.count; g++) {
4212
- const y = u.getX(g) + d.getX(g) * h, x = u.getY(g) + d.getY(g) * h, I = u.getZ(g) + d.getZ(g) * h;
4213
- u.setXYZ(g, y, x, I);
4212
+ const y = u.getX(g) + d.getX(g) * h, x = u.getY(g) + d.getY(g) * h, v = u.getZ(g) + d.getZ(g) * h;
4213
+ u.setXYZ(g, y, x, v);
4214
4214
  }
4215
4215
  }
4216
4216
  if (l) {
@@ -5180,7 +5180,7 @@ class Oe {
5180
5180
  eyeLookOutRight: [null, 0],
5181
5181
  eyeContact: [0]
5182
5182
  }
5183
- })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (G.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(G)), Pe.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(pe), pe.sub(this.armature.position), this.objectHips.position.y -= Pe.min.y / 2, this.objectHips.position.x -= (ce.x + pe.x) / 4, this.objectHips.position.z -= (ce.z + pe.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5183
+ })))), e > 2 * this.animFrameDur && (e = 2 * this.animFrameDur), (this.viewName !== "full" || this.isAvatarOnly) && (n = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], i = this.mtAvatar[n], i.needsUpdate || Object.assign(i, { base: (this.mood.baseline[n] || 0) + (1 + l / 255) * Math.random() / 5, needsUpdate: !0 })), this.updatePoseBase(this.animClock), this.mixer && this.mixer.update(e / 1e3 * this.mixer.timeScale), this.updatePoseDelta(), (this.isSpeaking || this.isListening) && u ? l > this.volumeMax ? (this.volumeHeadBase = 0.05, Math.random() > 0.6 && (this.volumeHeadTarget = -0.05 - Math.random() / 15), this.volumeMax = l) : (this.volumeMax *= 0.92, this.volumeHeadTarget = this.volumeHeadBase - 0.9 * (this.volumeHeadBase - this.volumeHeadTarget)) : (this.volumeHeadTarget = 0, this.volumeMax = 0), n = this.volumeHeadTarget - this.volumeHeadCurrent, i = Math.abs(n), i > 1e-4 && (o = i * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / i) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(n) * Math.min(i, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (G.setFromAxisAngle(mt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(G)), Be.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ce), ce.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(pe), pe.sub(this.armature.position), this.objectHips.position.y -= Be.min.y / 2, this.objectHips.position.x -= (ce.x + pe.x) / 4, this.objectHips.position.z -= (ce.z + pe.z) / 2, this.dynamicbones.update(e), this.fbxAnimationLoader && this.fbxAnimationLoader.update(), this.opt.update && this.opt.update(e), this.updateMorphTargets(e), this.isAvatarOnly)
5184
5184
  this.stats && this.stats.end();
5185
5185
  else {
5186
5186
  if (this.cameraClock !== null && this.cameraClock < 1e3) {
@@ -5211,8 +5211,8 @@ class Oe {
5211
5211
  if (!this.lipsync.hasOwnProperty(t)) {
5212
5212
  const n = t.toLowerCase(), i = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5213
5213
  try {
5214
- const s = Fe[n];
5215
- s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Fe));
5214
+ const s = Pe[n];
5215
+ s && s[i] ? (this.lipsync[t] = new s[i](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Pe));
5216
5216
  } catch (s) {
5217
5217
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5218
5218
  }
@@ -5251,10 +5251,10 @@ class Oe {
5251
5251
  let h = "", a = "", c = 0, d = [], g = [];
5252
5252
  const y = Array.from(this.segmenter.segment(t), (x) => x.segment);
5253
5253
  for (let x = 0; x < y.length; x++) {
5254
- const I = x === y.length - 1, B = y[x].match(l);
5254
+ const v = x === y.length - 1, B = y[x].match(l);
5255
5255
  let p = y[x].match(s);
5256
5256
  const H = y[x].match(u), z = y[x].match(o);
5257
- if (p && !I && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), B && (!i || i.every((R) => x < R[0] || x > R[1])) && (a += y[x]), (z || p || I) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5257
+ if (p && !v && !H && y[x + 1].match(s) && (p = !1), n && (h += y[x]), B && (!i || i.every((I) => x < I[0] || x > I[1])) && (a += y[x]), (z || p || v) && (a.length && (a = this.lipsyncPreProcessText(a, r), a.length && d.push({
5258
5258
  mark: c,
5259
5259
  word: a
5260
5260
  })), h.length && (g.push({
@@ -5265,31 +5265,31 @@ class Oe {
5265
5265
  subtitles: [h]
5266
5266
  }
5267
5267
  }), h = ""), a.length)) {
5268
- const R = this.lipsyncWordsToVisemes(a, r);
5269
- if (R && R.visemes && R.visemes.length) {
5270
- const T = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
5271
- for (let F = 0; F < R.visemes.length; F++)
5268
+ const I = this.lipsyncWordsToVisemes(a, r);
5269
+ if (I && I.visemes && I.visemes.length) {
5270
+ const T = I.times[I.visemes.length - 1] + I.durations[I.visemes.length - 1];
5271
+ for (let F = 0; F < I.visemes.length; F++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(R.times[F] - 0.6) / T, (R.times[F] + 0.5) / T, (R.times[F] + R.durations[F] + 0.5) / T],
5275
+ ts: [(I.times[F] - 0.6) / T, (I.times[F] + 0.5) / T, (I.times[F] + I.durations[F] + 0.5) / T],
5276
5276
  vs: {
5277
- ["viseme_" + R.visemes[F]]: [null, R.visemes[F] === "PP" || R.visemes[F] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + I.visemes[F]]: [null, I.visemes[F] === "PP" || I.visemes[F] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
5281
5281
  a = "", c++;
5282
5282
  }
5283
- if (p || I) {
5284
- if (d.length || I && g.length) {
5285
- const R = {
5283
+ if (p || v) {
5284
+ if (d.length || v && g.length) {
5285
+ const I = {
5286
5286
  anim: g
5287
5287
  };
5288
- n && (R.onSubtitles = n), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], a = "", c = 0, g = [];
5288
+ n && (I.onSubtitles = n), d.length && !e.avatarMute && (I.text = d, e.avatarMood && (I.mood = e.avatarMood), e.ttsLang && (I.lang = e.ttsLang), e.ttsVoice && (I.voice = e.ttsVoice), e.ttsRate && (I.rate = e.ttsRate), e.ttsVoice && (I.pitch = e.ttsPitch), e.ttsVolume && (I.volume = e.ttsVolume)), this.speechQueue.push(I), d = [], a = "", c = 0, g = [];
5289
5289
  }
5290
5290
  if (H) {
5291
- let R = this.animEmojis[y[x]];
5292
- R && R.link && (R = this.animEmojis[R.link]), R && this.speechQueue.push({ emoji: R });
5291
+ let I = this.animEmojis[y[x]];
5292
+ I && I.link && (I = this.animEmojis[I.link]), I && this.speechQueue.push({ emoji: I });
5293
5293
  }
5294
5294
  this.speechQueue.push({ break: 100 });
5295
5295
  }
@@ -5385,10 +5385,10 @@ class Oe {
5385
5385
  let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5386
5386
  if (h = Math.min(h, c.visemes.length * 200), d > 0)
5387
5387
  for (let x = 0; x < c.visemes.length; x++) {
5388
- const I = r + c.times[x] / d * h, B = c.durations[x] / d * h;
5388
+ const v = r + c.times[x] / d * h, B = c.durations[x] / d * h;
5389
5389
  o.push({
5390
5390
  template: { name: "viseme" },
5391
- ts: [I - Math.min(60, 2 * B / 3), I + Math.min(25, B / 2), I + B + Math.min(60, B / 2)],
5391
+ ts: [v - Math.min(60, 2 * B / 3), v + Math.min(25, B / 2), v + B + Math.min(60, B / 2)],
5392
5392
  vs: {
5393
5393
  ["viseme_" + c.visemes[x]]: [null, c.visemes[x] === "PP" || c.visemes[x] === "FF" ? 0.9 : y, 0]
5394
5394
  }
@@ -5482,12 +5482,12 @@ class Oe {
5482
5482
  hasVisemes: x && x.visemes && x.visemes.length > 0,
5483
5483
  estimatedDuration: c
5484
5484
  });
5485
- const I = [];
5485
+ const v = [];
5486
5486
  if (x && x.visemes && x.visemes.length > 0) {
5487
5487
  const p = x.times[x.visemes.length - 1] + x.durations[x.visemes.length - 1];
5488
5488
  for (let H = 0; H < x.visemes.length; H++) {
5489
- const z = x.visemes[H], R = x.times[H] / p, T = x.durations[H] / p, F = R * c, J = T * c;
5490
- I.push({
5489
+ const z = x.visemes[H], I = x.times[H] / p, T = x.durations[H] / p, F = I * c, J = T * c;
5490
+ v.push({
5491
5491
  template: { name: "viseme" },
5492
5492
  ts: [F - Math.min(60, 2 * J / 3), F + Math.min(25, J / 2), F + J + Math.min(60, J / 2)],
5493
5493
  vs: {
@@ -5496,7 +5496,7 @@ class Oe {
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const B = [...t.anim, ...I];
5499
+ const B = [...t.anim, ...v];
5500
5500
  this.audioPlaylist.push({ anim: B, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5501
5501
  e();
5502
5502
  }, s.onerror = (p) => {
@@ -5564,8 +5564,8 @@ class Oe {
5564
5564
  const d = e.toLowerCase().split(/\s+/), g = [];
5565
5565
  for (const y of d)
5566
5566
  for (const x of y) {
5567
- let I = "aa";
5568
- "aeiou".includes(x) ? I = "aa" : "bp".includes(x) ? I = "PP" : "fv".includes(x) ? I = "FF" : "st".includes(x) ? I = "SS" : "dln".includes(x) ? I = "DD" : "kg".includes(x) ? I = "kk" : "rw".includes(x) && (I = "RR"), g.push(I);
5567
+ let v = "aa";
5568
+ "aeiou".includes(x) ? v = "aa" : "bp".includes(x) ? v = "PP" : "fv".includes(x) ? v = "FF" : "st".includes(x) ? v = "SS" : "dln".includes(x) ? v = "DD" : "kg".includes(x) ? v = "kk" : "rw".includes(x) && (v = "RR"), g.push(v);
5569
5569
  }
5570
5570
  r = {
5571
5571
  visemes: g.map((y, x) => ({
@@ -5662,8 +5662,8 @@ class Oe {
5662
5662
  const d = e.toLowerCase().split(/\s+/), g = [];
5663
5663
  for (const y of d)
5664
5664
  for (const x of y) {
5665
- let I = "aa";
5666
- "aeiou".includes(x) ? I = "aa" : "bp".includes(x) ? I = "PP" : "fv".includes(x) ? I = "FF" : "st".includes(x) ? I = "SS" : "dln".includes(x) ? I = "DD" : "kg".includes(x) ? I = "kk" : "rw".includes(x) && (I = "RR"), g.push(I);
5665
+ let v = "aa";
5666
+ "aeiou".includes(x) ? v = "aa" : "bp".includes(x) ? v = "PP" : "fv".includes(x) ? v = "FF" : "st".includes(x) ? v = "SS" : "dln".includes(x) ? v = "DD" : "kg".includes(x) ? v = "kk" : "rw".includes(x) && (v = "RR"), g.push(v);
5667
5667
  }
5668
5668
  r = {
5669
5669
  visemes: g.map((y, x) => ({
@@ -6153,7 +6153,7 @@ class Oe {
6153
6153
  E.setFromQuaternion(u, "YXZ");
6154
6154
  let r = E.x / (40 / 24) + 0.2, h = E.y / (9 / 4), a = Math.min(0.6, Math.max(-0.3, r)), c = Math.min(0.8, Math.max(-0.8, h)), d = (Math.random() - 0.5) / 4, g = (Math.random() - 0.5) / 4;
6155
6155
  if (t) {
6156
- let y = this.animQueue.findIndex((I) => I.template.name === "lookat");
6156
+ let y = this.animQueue.findIndex((v) => v.template.name === "lookat");
6157
6157
  y !== -1 && this.animQueue.splice(y, 1);
6158
6158
  const x = {
6159
6159
  name: "lookat",
@@ -6187,18 +6187,18 @@ class Oe {
6187
6187
  l.project(this.camera);
6188
6188
  let u = (l.x + 1) / 2 * i.width + i.left, r = -(l.y - 1) / 2 * i.height + i.top;
6189
6189
  t === null && (t = u), e === null && (e = r), G.copy(this.armature.quaternion), G.multiply(this.poseTarget.props["Hips.quaternion"]), G.multiply(this.poseTarget.props["Spine.quaternion"]), G.multiply(this.poseTarget.props["Spine1.quaternion"]), G.multiply(this.poseTarget.props["Spine2.quaternion"]), G.multiply(this.poseTarget.props["Neck.quaternion"]), G.multiply(this.poseTarget.props["Head.quaternion"]), E.setFromQuaternion(G);
6190
- let h = E.x / (40 / 24), a = E.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - r, r), x = this.convertRange(e, [r - y, r + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - a + d;
6191
- x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
6190
+ let h = E.x / (40 / 24), a = E.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - r, r), x = this.convertRange(e, [r - y, r + y], [-0.3, 0.6]) - h + c, v = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - a + d;
6191
+ x = Math.min(0.6, Math.max(-0.3, x)), v = Math.min(0.8, Math.max(-0.8, v));
6192
6192
  let B = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (n) {
6194
- let H = this.animQueue.findIndex((R) => R.template.name === "lookat");
6194
+ let H = this.animQueue.findIndex((I) => I.template.name === "lookat");
6195
6195
  H !== -1 && this.animQueue.splice(H, 1);
6196
6196
  const z = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, n],
6199
6199
  vs: {
6200
6200
  bodyRotateX: [x + B],
6201
- bodyRotateY: [I + p],
6201
+ bodyRotateY: [v + p],
6202
6202
  eyesRotateX: [-3 * B + 0.1],
6203
6203
  eyesRotateY: [-5 * p],
6204
6204
  browInnerUp: [[0, 0.7]],
@@ -6403,7 +6403,7 @@ class Oe {
6403
6403
  } catch (c) {
6404
6404
  console.warn(`Could not verify file existence for ${t}, attempting to load anyway:`, c);
6405
6405
  }
6406
- const h = new Me();
6406
+ const h = new Ee();
6407
6407
  let a;
6408
6408
  try {
6409
6409
  a = await h.loadAsync(t, e);
@@ -6433,8 +6433,8 @@ class Oe {
6433
6433
  y.name = y.name.replaceAll("mixamorig", "");
6434
6434
  const x = y.name.split(".");
6435
6435
  if (x[1] === "position") {
6436
- for (let I = 0; I < y.values.length; I++)
6437
- y.values[I] = y.values[I] * s;
6436
+ for (let v = 0; v < y.values.length; v++)
6437
+ y.values[v] = y.values[v] * s;
6438
6438
  d[y.name] = new f.Vector3(y.values[0], y.values[1], y.values[2]);
6439
6439
  } else x[1] === "quaternion" ? d[y.name] = new f.Quaternion(y.values[0], y.values[1], y.values[2], y.values[3]) : x[1] === "rotation" && (d[x[0] + ".quaternion"] = new f.Quaternion().setFromEuler(new f.Euler(y.values[0], y.values[1], y.values[2], "XYZ")).normalize());
6440
6440
  });
@@ -6480,7 +6480,7 @@ class Oe {
6480
6480
  let l = this.animQueue.find((u) => u.template.name === "pose");
6481
6481
  l && (l.ts[0] = this.animClock + n * 1e3 + 2e3), this.setPoseFromTemplate(o);
6482
6482
  } else {
6483
- let u = await new Me().loadAsync(t, e);
6483
+ let u = await new Ee().loadAsync(t, e);
6484
6484
  if (u && u.animations && u.animations[i]) {
6485
6485
  let r = u.animations[i];
6486
6486
  const h = {};
@@ -6535,7 +6535,7 @@ class Oe {
6535
6535
  const c = [];
6536
6536
  for (let y = 1; y < l.ts.length; y++) c.push(l.ts[y] - l.ts[y - 1]);
6537
6537
  const d = o.template?.rescale || c.map((y) => y / h), g = e * 1e3 - h;
6538
- l.ts = l.ts.map((y, x, I) => x === 0 ? u : I[x - 1] + c[x - 1] + d[x - 1] * g);
6538
+ l.ts = l.ts.map((y, x, v) => x === 0 ? u : v[x - 1] + c[x - 1] + d[x - 1] * g);
6539
6539
  } else {
6540
6540
  const c = e * 1e3 / h;
6541
6541
  l.ts = l.ts.map((d) => u + c * (d - u));
@@ -6571,18 +6571,18 @@ class Oe {
6571
6571
  const s = new f.Vector3(), o = new f.Vector3(), l = new f.Vector3(), u = new f.Vector3(), r = new f.Quaternion(), h = new f.Vector3(), a = new f.Vector3(), c = new f.Vector3(), d = this.ikMesh.getObjectByName(t.root);
6572
6572
  d.position.setFromMatrixPosition(this.armature.getObjectByName(t.root).matrixWorld), d.quaternion.setFromRotationMatrix(this.armature.getObjectByName(t.root).matrixWorld), e && n && e.applyQuaternion(this.armature.quaternion).add(d.position);
6573
6573
  const g = this.ikMesh.getObjectByName(t.effector), y = t.links;
6574
- y.forEach((I) => {
6575
- I.bone = this.ikMesh.getObjectByName(I.link), I.bone.quaternion.copy(this.getPoseTemplateProp(I.link + ".quaternion"));
6574
+ y.forEach((v) => {
6575
+ v.bone = this.ikMesh.getObjectByName(v.link), v.bone.quaternion.copy(this.getPoseTemplateProp(v.link + ".quaternion"));
6576
6576
  }), d.updateMatrixWorld(!0);
6577
6577
  const x = t.iterations || 10;
6578
6578
  if (e)
6579
- for (let I = 0; I < x; I++) {
6579
+ for (let v = 0; v < x; v++) {
6580
6580
  let B = !1;
6581
6581
  for (let p = 0, H = y.length; p < H; p++) {
6582
6582
  const z = y[p].bone;
6583
6583
  z.matrixWorld.decompose(u, r, h), r.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(r), l.normalize(), s.subVectors(e, u), s.applyQuaternion(r), s.normalize();
6584
- let R = s.dot(l);
6585
- R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), G.setFromAxisAngle(a, R), z.quaternion.multiply(G), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6584
+ let I = s.dot(l);
6585
+ I > 1 ? I = 1 : I < -1 && (I = -1), I = Math.acos(I), !(I < 1e-5) && (y[p].minAngle !== void 0 && I < y[p].minAngle && (I = y[p].minAngle), y[p].maxAngle !== void 0 && I > y[p].maxAngle && (I = y[p].maxAngle), a.crossVectors(l, s), a.normalize(), G.setFromAxisAngle(a, I), z.quaternion.multiply(G), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6586
6586
  y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6587
6587
  y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6588
6588
  y[p].minz !== void 0 ? y[p].minz : -1 / 0
@@ -6594,8 +6594,8 @@ class Oe {
6594
6594
  }
6595
6595
  if (!B) break;
6596
6596
  }
6597
- i && y.forEach((I) => {
6598
- this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = i;
6597
+ i && y.forEach((v) => {
6598
+ this.poseTarget.props[v.link + ".quaternion"].copy(v.bone.quaternion), this.poseTarget.props[v.link + ".quaternion"].t = this.animClock, this.poseTarget.props[v.link + ".quaternion"].d = i;
6599
6599
  });
6600
6600
  }
6601
6601
  /**
@@ -6605,7 +6605,7 @@ class Oe {
6605
6605
  this.isRunning = !1, this.stop(), this.stopSpeaking(), this.streamStop(), this.isAvatarOnly ? this.armature && (this.armature.parent && this.armature.parent.remove(this.armature), this.clearThree(this.armature)) : (this.clearThree(this.scene), this.resizeobserver.disconnect(), this.renderer && (this.renderer.dispose(), this.renderer.domElement && this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement), this.renderer = null)), this.clearThree(this.ikMesh), this.dynamicbones.dispose();
6606
6606
  }
6607
6607
  }
6608
- const ve = {
6608
+ const Re = {
6609
6609
  apiKey: "sk_ace57ef3ef65a92b9d3bee2a00183b78ca790bc3e10964f2",
6610
6610
  // Replace with your actual API key (should start with sk_)
6611
6611
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
@@ -6625,7 +6625,7 @@ const ve = {
6625
6625
  josh: "VR6AewLTigWG4xSOukaG"
6626
6626
  // Male, American
6627
6627
  }
6628
- }, Be = {
6628
+ }, De = {
6629
6629
  defaultVoice: "aura-2-thalia-en",
6630
6630
  // Thalia (Female, English)
6631
6631
  voices: {
@@ -6648,10 +6648,10 @@ const ve = {
6648
6648
  function He() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
- endpoint: ve.endpoint,
6652
- apiKey: ve.apiKey,
6653
- defaultVoice: ve.defaultVoice,
6654
- voices: ve.voices
6651
+ endpoint: Re.endpoint,
6652
+ apiKey: Re.apiKey,
6653
+ defaultVoice: Re.defaultVoice,
6654
+ voices: Re.voices
6655
6655
  };
6656
6656
  }
6657
6657
  function St() {
@@ -6663,7 +6663,7 @@ function St() {
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
- const Ne = ze(({
6666
+ const Ue = ze(({
6667
6667
  avatarUrl: U = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
@@ -6684,11 +6684,11 @@ const Ne = ze(({
6684
6684
  className: g = "",
6685
6685
  style: y = {},
6686
6686
  animations: x = {}
6687
- }, I) => {
6688
- const B = N(null), p = N(null), H = N(r), z = N(null), R = N(null), T = N(!1), F = N({ remainingText: null, originalText: null, options: null }), J = N([]), ye = N(0), [S, W] = be(!0), [Y, Z] = be(null), [$, se] = be(!1), [de, me] = be(!1);
6689
- Re(() => {
6687
+ }, v) => {
6688
+ const B = N(null), p = N(null), H = N(r), z = N(null), I = N(null), T = N(!1), F = N({ remainingText: null, originalText: null, options: null }), J = N([]), ye = N(0), [S, W] = be(!0), [j, Z] = be(null), [$, se] = be(!1), [de, me] = be(!1);
6689
+ Ie(() => {
6690
6690
  T.current = de;
6691
- }, [de]), Re(() => {
6691
+ }, [de]), Ie(() => {
6692
6692
  H.current = r;
6693
6693
  }, [r]);
6694
6694
  const ie = He(), fe = i || ie.service;
@@ -6702,14 +6702,14 @@ const Ne = ze(({
6702
6702
  service: "elevenlabs",
6703
6703
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6704
6704
  apiKey: o || ie.apiKey,
6705
- defaultVoice: s || ie.defaultVoice || ve.defaultVoice,
6706
- voices: ie.voices || ve.voices
6705
+ defaultVoice: s || ie.defaultVoice || Re.defaultVoice,
6706
+ voices: ie.voices || Re.voices
6707
6707
  } : fe === "deepgram" ? X = {
6708
6708
  service: "deepgram",
6709
6709
  endpoint: "https://api.deepgram.com/v1/speak",
6710
6710
  apiKey: o || ie.apiKey,
6711
- defaultVoice: s || ie.defaultVoice || Be.defaultVoice,
6712
- voices: ie.voices || Be.voices
6711
+ defaultVoice: s || ie.defaultVoice || De.defaultVoice,
6712
+ voices: ie.voices || De.voices
6713
6713
  } : X = {
6714
6714
  ...ie,
6715
6715
  // Override API key if provided via props
@@ -6725,7 +6725,7 @@ const Ne = ze(({
6725
6725
  showFullAvatar: r,
6726
6726
  bodyMovement: l,
6727
6727
  movementIntensity: u
6728
- }, v = {
6728
+ }, R = {
6729
6729
  ttsEndpoint: X.endpoint,
6730
6730
  ttsApikey: X.apiKey,
6731
6731
  ttsService: fe,
@@ -6734,7 +6734,7 @@ const Ne = ze(({
6734
6734
  }, w = M(async () => {
6735
6735
  if (!(!B.current || p.current))
6736
6736
  try {
6737
- if (W(!0), Z(null), p.current = new Oe(B.current, v), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(b, (V) => {
6737
+ if (W(!0), Z(null), p.current = new Ne(B.current, R), p.current.controls && (p.current.controls.enableRotate = !1, p.current.controls.enableZoom = !1, p.current.controls.enablePan = !1, p.current.controls.enableDamping = !1), x && Object.keys(x).length > 0 && (p.current.customAnimations = x), await p.current.showAvatar(b, (V) => {
6738
6738
  if (V.lengthComputable) {
6739
6739
  const Q = Math.min(100, Math.round(V.loaded / V.total * 100));
6740
6740
  c(Q);
@@ -6761,9 +6761,9 @@ const Ne = ze(({
6761
6761
  console.error("Error initializing TalkingHead:", L), Z(L.message || "Failed to initialize avatar"), W(!1), d(L);
6762
6762
  }
6763
6763
  }, [U, t, e, n, i, s, o, r, l, u, h]);
6764
- Re(() => (w(), () => {
6764
+ Ie(() => (w(), () => {
6765
6765
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6766
- }), [w]), Re(() => {
6766
+ }), [w]), Ie(() => {
6767
6767
  if (!B.current || !p.current) return;
6768
6768
  const L = new ResizeObserver((V) => {
6769
6769
  for (const Q of V)
@@ -6787,7 +6787,7 @@ const Ne = ze(({
6787
6787
  }, []), D = M(async (L, P = {}) => {
6788
6788
  if (p.current && $)
6789
6789
  try {
6790
- R.current && (clearInterval(R.current), R.current = null), z.current = { text: L, options: P }, F.current = { remainingText: null, originalText: null, options: null };
6790
+ I.current && (clearInterval(I.current), I.current = null), z.current = { text: L, options: P }, F.current = { remainingText: null, originalText: null, options: null };
6791
6791
  const V = /[!\.\?\n\p{Extended_Pictographic}]/ug, Q = L.split(V).map((O) => O.trim()).filter((O) => O.length > 0);
6792
6792
  J.current = Q, ye.current = 0, me(!1), T.current = !1, await C();
6793
6793
  const ae = {
@@ -6796,27 +6796,27 @@ const Ne = ze(({
6796
6796
  };
6797
6797
  if (P.onSpeechEnd && p.current) {
6798
6798
  const O = p.current;
6799
- let oe = null, Ie = 0;
6799
+ let oe = null, Le = 0;
6800
6800
  const xe = 1200;
6801
6801
  let ue = !1;
6802
6802
  oe = setInterval(() => {
6803
- if (Ie++, T.current)
6803
+ if (Le++, T.current)
6804
6804
  return;
6805
- if (Ie > xe) {
6806
- if (oe && (clearInterval(oe), oe = null, R.current = null), !ue && !T.current) {
6805
+ if (Le > xe) {
6806
+ if (oe && (clearInterval(oe), oe = null, I.current = null), !ue && !T.current) {
6807
6807
  ue = !0;
6808
6808
  try {
6809
6809
  P.onSpeechEnd();
6810
- } catch (Te) {
6811
- console.error("Error in onSpeechEnd callback (timeout):", Te);
6810
+ } catch (Me) {
6811
+ console.error("Error in onSpeechEnd callback (timeout):", Me);
6812
6812
  }
6813
6813
  }
6814
6814
  return;
6815
6815
  }
6816
- const re = !O.speechQueue || O.speechQueue.length === 0, Le = !O.audioPlaylist || O.audioPlaylist.length === 0;
6817
- O && O.isSpeaking === !1 && re && Le && O.isAudioPlaying === !1 && !ue && !T.current && setTimeout(() => {
6816
+ const re = !O.speechQueue || O.speechQueue.length === 0, Ae = !O.audioPlaylist || O.audioPlaylist.length === 0;
6817
+ O && O.isSpeaking === !1 && re && Ae && O.isAudioPlaying === !1 && !ue && !T.current && setTimeout(() => {
6818
6818
  if (O && !T.current && O.isSpeaking === !1 && (!O.speechQueue || O.speechQueue.length === 0) && (!O.audioPlaylist || O.audioPlaylist.length === 0) && O.isAudioPlaying === !1 && !ue && !T.current) {
6819
- ue = !0, oe && (clearInterval(oe), oe = null, R.current = null);
6819
+ ue = !0, oe && (clearInterval(oe), oe = null, I.current = null);
6820
6820
  try {
6821
6821
  P.onSpeechEnd();
6822
6822
  } catch (Ze) {
@@ -6824,7 +6824,7 @@ const Ne = ze(({
6824
6824
  }
6825
6825
  }
6826
6826
  }, 100);
6827
- }, 100), R.current = oe;
6827
+ }, 100), I.current = oe;
6828
6828
  }
6829
6829
  p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae)) : setTimeout(async () => {
6830
6830
  await C(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(L, ae));
@@ -6832,18 +6832,18 @@ const Ne = ze(({
6832
6832
  } catch (V) {
6833
6833
  console.error("Error speaking text:", V), Z(V.message || "Failed to speak text");
6834
6834
  }
6835
- }, [$, C, b.lipsyncLang]), te = M(() => {
6835
+ }, [$, C, b.lipsyncLang]), ee = M(() => {
6836
6836
  p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, me(!1));
6837
6837
  }, []), q = M(() => {
6838
6838
  if (p.current && p.current.pauseSpeaking) {
6839
6839
  const L = p.current;
6840
6840
  if (L.isSpeaking || L.audioPlaylist && L.audioPlaylist.length > 0 || L.speechQueue && L.speechQueue.length > 0) {
6841
- R.current && (clearInterval(R.current), R.current = null);
6841
+ I.current && (clearInterval(I.current), I.current = null);
6842
6842
  let V = "";
6843
6843
  if (z.current && J.current.length > 0) {
6844
- const Q = J.current.length, ae = L.speechQueue ? L.speechQueue.filter((xe) => xe && xe.text && Array.isArray(xe.text) && xe.text.length > 0).length : 0, O = L.audioPlaylist && L.audioPlaylist.length > 0, oe = ae + (O ? 1 : 0), Ie = Q - oe;
6845
- if (oe > 0 && Ie < Q && (V = J.current.slice(Ie).join(". ").trim(), !V && ae > 0 && L.speechQueue)) {
6846
- const ue = L.speechQueue.filter((re) => re && re.text && Array.isArray(re.text) && re.text.length > 0).map((re) => re.text.map((Le) => Le.word || "").filter((Le) => Le.length > 0).join(" ")).filter((re) => re.length > 0).join(" ");
6844
+ const Q = J.current.length, ae = L.speechQueue ? L.speechQueue.filter((xe) => xe && xe.text && Array.isArray(xe.text) && xe.text.length > 0).length : 0, O = L.audioPlaylist && L.audioPlaylist.length > 0, oe = ae + (O ? 1 : 0), Le = Q - oe;
6845
+ if (oe > 0 && Le < Q && (V = J.current.slice(Le).join(". ").trim(), !V && ae > 0 && L.speechQueue)) {
6846
+ const ue = L.speechQueue.filter((re) => re && re.text && Array.isArray(re.text) && re.text.length > 0).map((re) => re.text.map((Ae) => Ae.word || "").filter((Ae) => Ae.length > 0).join(" ")).filter((re) => re.length > 0).join(" ");
6847
6847
  ue && ue.trim() && (V = ue.trim());
6848
6848
  }
6849
6849
  }
@@ -6854,7 +6854,7 @@ const Ne = ze(({
6854
6854
  }), L.speechQueue && (L.speechQueue.length = 0), p.current.pauseSpeaking(), T.current = !0, me(!0);
6855
6855
  }
6856
6856
  }
6857
- }, []), j = M(async () => {
6857
+ }, []), Y = M(async () => {
6858
6858
  if (!p.current || !de)
6859
6859
  return;
6860
6860
  let L = "", P = {};
@@ -6876,9 +6876,9 @@ const Ne = ze(({
6876
6876
  } catch (Q) {
6877
6877
  console.error("Error resuming speech:", Q), me(!1), T.current = !1;
6878
6878
  }
6879
- }, [C, de, D, b]), we = M((L) => {
6879
+ }, [C, de, D, b]), ve = M((L) => {
6880
6880
  p.current && p.current.setMood(L);
6881
- }, []), We = M((L) => {
6881
+ }, []), Te = M((L) => {
6882
6882
  p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(L);
6883
6883
  }, []), Ve = M((L, P = !1) => {
6884
6884
  if (p.current && p.current.playAnimation) {
@@ -6921,14 +6921,14 @@ const Ne = ze(({
6921
6921
  }, [x]), Ge = M(() => {
6922
6922
  p.current && p.current.onResize && p.current.onResize();
6923
6923
  }, []);
6924
- return Ce(I, () => ({
6924
+ return Ce(v, () => ({
6925
6925
  speakText: D,
6926
- stopSpeaking: te,
6926
+ stopSpeaking: ee,
6927
6927
  pauseSpeaking: q,
6928
- resumeSpeaking: j,
6928
+ resumeSpeaking: Y,
6929
6929
  resumeAudioContext: C,
6930
- setMood: we,
6931
- setTimingAdjustment: We,
6930
+ setMood: ve,
6931
+ setTimingAdjustment: Te,
6932
6932
  playAnimation: Ve,
6933
6933
  isReady: $,
6934
6934
  isPaused: de,
@@ -6991,7 +6991,7 @@ const Ne = ze(({
6991
6991
  console.warn("Error unlocking avatar position:", L);
6992
6992
  }
6993
6993
  }
6994
- })), /* @__PURE__ */ De(
6994
+ })), /* @__PURE__ */ Oe(
6995
6995
  "div",
6996
6996
  {
6997
6997
  className: `talking-head-avatar ${g}`,
@@ -7023,7 +7023,7 @@ const Ne = ze(({
7023
7023
  fontSize: "18px",
7024
7024
  zIndex: 10
7025
7025
  }, children: "Loading avatar..." }),
7026
- Y && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7026
+ j && /* @__PURE__ */ ge("div", { className: "error-overlay", style: {
7027
7027
  position: "absolute",
7028
7028
  top: "50%",
7029
7029
  left: "50%",
@@ -7034,12 +7034,12 @@ const Ne = ze(({
7034
7034
  zIndex: 10,
7035
7035
  padding: "20px",
7036
7036
  borderRadius: "8px"
7037
- }, children: Y })
7037
+ }, children: j })
7038
7038
  ]
7039
7039
  }
7040
7040
  );
7041
7041
  });
7042
- Ne.displayName = "TalkingHeadAvatar";
7042
+ Ue.displayName = "TalkingHeadAvatar";
7043
7043
  const pt = ze(({
7044
7044
  text: U = "Hello! I'm a talking avatar. How are you today?",
7045
7045
  onLoading: t = () => {
@@ -7052,7 +7052,7 @@ const pt = ze(({
7052
7052
  style: s = {},
7053
7053
  avatarConfig: o = {}
7054
7054
  }, l) => {
7055
- const u = N(null), r = N(null), [h, a] = be(!0), [c, d] = be(null), [g, y] = be(!1), x = He(), I = o.ttsService || x.service, B = I === "browser" ? {
7055
+ const u = N(null), r = N(null), [h, a] = be(!0), [c, d] = be(null), [g, y] = be(!1), x = He(), v = o.ttsService || x.service, B = v === "browser" ? {
7056
7056
  endpoint: "",
7057
7057
  apiKey: null,
7058
7058
  defaultVoice: "Google US English"
@@ -7061,13 +7061,13 @@ const pt = ze(({
7061
7061
  // Override API key if provided via avatarConfig
7062
7062
  apiKey: o.ttsApiKey !== void 0 && o.ttsApiKey !== null ? o.ttsApiKey : x.apiKey,
7063
7063
  // Override endpoint for ElevenLabs if service is explicitly set
7064
- endpoint: I === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : x.endpoint
7064
+ endpoint: v === "elevenlabs" && o.ttsApiKey ? "https://api.elevenlabs.io/v1/text-to-speech" : x.endpoint
7065
7065
  }, p = {
7066
7066
  url: "/avatars/brunette.glb",
7067
7067
  // Use brunette avatar (working glTF file)
7068
7068
  body: "F",
7069
7069
  avatarMood: "neutral",
7070
- ttsLang: I === "browser" ? "en-US" : "en",
7070
+ ttsLang: v === "browser" ? "en-US" : "en",
7071
7071
  ttsVoice: o.ttsVoice || B.defaultVoice,
7072
7072
  lipsyncLang: "en",
7073
7073
  // English lip-sync
@@ -7079,33 +7079,33 @@ const pt = ze(({
7079
7079
  }, H = {
7080
7080
  ttsEndpoint: B.endpoint,
7081
7081
  ttsApikey: B.apiKey,
7082
- ttsService: I,
7082
+ ttsService: v,
7083
7083
  lipsyncModules: ["en"],
7084
7084
  cameraView: "upper"
7085
7085
  }, z = M(async () => {
7086
7086
  if (!(!u.current || r.current))
7087
7087
  try {
7088
- if (a(!0), d(null), r.current = new Oe(u.current, H), await r.current.showAvatar(p, (Y) => {
7089
- if (Y.lengthComputable) {
7090
- const Z = Math.min(100, Math.round(Y.loaded / Y.total * 100));
7088
+ if (a(!0), d(null), r.current = new Ne(u.current, H), await r.current.showAvatar(p, (j) => {
7089
+ if (j.lengthComputable) {
7090
+ const Z = Math.min(100, Math.round(j.loaded / j.total * 100));
7091
7091
  t(Z);
7092
7092
  }
7093
7093
  }), r.current.morphs && r.current.morphs.length > 0) {
7094
- const Y = r.current.morphs[0].morphTargetDictionary;
7095
- console.log("Available morph targets:", Object.keys(Y));
7096
- const Z = Object.keys(Y).filter(($) => $.startsWith("viseme_"));
7094
+ const j = r.current.morphs[0].morphTargetDictionary;
7095
+ console.log("Available morph targets:", Object.keys(j));
7096
+ const Z = Object.keys(j).filter(($) => $.startsWith("viseme_"));
7097
7097
  console.log("Viseme morph targets found:", Z), Z.length === 0 && (console.warn("No viseme morph targets found! Lip-sync will not work properly."), console.log("Expected viseme targets: viseme_aa, viseme_E, viseme_I, viseme_O, viseme_U, viseme_PP, viseme_SS, viseme_TH, viseme_DD, viseme_FF, viseme_kk, viseme_nn, viseme_RR, viseme_CH, viseme_sil"));
7098
7098
  }
7099
- if (await new Promise((Y) => {
7099
+ if (await new Promise((j) => {
7100
7100
  const Z = () => {
7101
- r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), Y()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
7101
+ r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), j()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(Z, 100));
7102
7102
  };
7103
7103
  Z();
7104
7104
  }), r.current && r.current.setShowFullAvatar)
7105
7105
  try {
7106
7106
  r.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7107
- } catch (Y) {
7108
- console.warn("Error setting full body mode on initialization:", Y);
7107
+ } catch (j) {
7108
+ console.warn("Error setting full body mode on initialization:", j);
7109
7109
  }
7110
7110
  a(!1), y(!0), n(r.current);
7111
7111
  const W = () => {
@@ -7118,10 +7118,10 @@ const pt = ze(({
7118
7118
  console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), a(!1), e(S);
7119
7119
  }
7120
7120
  }, []);
7121
- Re(() => (z(), () => {
7121
+ Ie(() => (z(), () => {
7122
7122
  r.current && (r.current.stop(), r.current.dispose(), r.current = null);
7123
7123
  }), [z]);
7124
- const R = M((S) => {
7124
+ const I = M((S) => {
7125
7125
  if (r.current && g)
7126
7126
  try {
7127
7127
  console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", r.current), r.current.lipsync && Object.keys(r.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(r.current.lipsync)), r.current.setSlowdownRate && (r.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), r.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
@@ -7180,7 +7180,7 @@ const pt = ze(({
7180
7180
  console.warn("Animation system not available or animation not found:", S);
7181
7181
  }, []);
7182
7182
  return Ce(l, () => ({
7183
- speakText: R,
7183
+ speakText: I,
7184
7184
  stopSpeaking: T,
7185
7185
  setMood: F,
7186
7186
  setTimingAdjustment: J,
@@ -7244,7 +7244,7 @@ const pt = ze(({
7244
7244
  console.warn("Error unlocking avatar position:", S);
7245
7245
  }
7246
7246
  }
7247
- })), /* @__PURE__ */ De("div", { className: `talking-head-container ${i}`, style: s, children: [
7247
+ })), /* @__PURE__ */ Oe("div", { className: `talking-head-container ${i}`, style: s, children: [
7248
7248
  /* @__PURE__ */ ge(
7249
7249
  "div",
7250
7250
  {
@@ -7313,7 +7313,7 @@ const gt = ze(({
7313
7313
  onQuestionAnswer: s,
7314
7314
  onCurriculumComplete: o,
7315
7315
  onCustomAction: l
7316
- }), d = N(null), g = N(null), y = N(null), x = N(null), I = N(null), B = N(null), p = N(null), H = N(U?.curriculum || {
7316
+ }), d = N(null), g = N(null), y = N(null), x = N(null), v = N(null), B = N(null), p = N(null), H = N(U?.curriculum || {
7317
7317
  title: "Default Curriculum",
7318
7318
  description: "No curriculum data provided",
7319
7319
  language: "en",
@@ -7332,7 +7332,7 @@ const gt = ze(({
7332
7332
  animations: e,
7333
7333
  lipsyncLang: "en"
7334
7334
  });
7335
- Re(() => {
7335
+ Ie(() => {
7336
7336
  c.current = {
7337
7337
  onLessonStart: n,
7338
7338
  onLessonComplete: i,
@@ -7340,7 +7340,7 @@ const gt = ze(({
7340
7340
  onCurriculumComplete: o,
7341
7341
  onCustomAction: l
7342
7342
  };
7343
- }, [n, i, s, o, l]), Re(() => {
7343
+ }, [n, i, s, o, l]), Ie(() => {
7344
7344
  H.current = U?.curriculum || {
7345
7345
  title: "Default Curriculum",
7346
7346
  description: "No curriculum data provided",
@@ -7361,11 +7361,11 @@ const gt = ze(({
7361
7361
  lipsyncLang: "en"
7362
7362
  };
7363
7363
  }, [U, t, e]);
7364
- const R = M(() => (H.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), T = M(() => R()?.questions[a.current.currentQuestionIndex], [R]), F = M((b, v) => v.type === "multiple_choice" || v.type === "true_false" ? b === v.answer : v.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), J = M(() => {
7364
+ const I = M(() => (H.current || { modules: [] }).modules[a.current.currentModuleIndex]?.lessons[a.current.currentLessonIndex], []), T = M(() => I()?.questions[a.current.currentQuestionIndex], [I]), F = M((b, R) => R.type === "multiple_choice" || R.type === "true_false" ? b === R.answer : R.type === "code_test" && typeof b == "object" && b !== null ? b.passed === !0 : !1, []), J = M(() => {
7365
7365
  a.current.lessonCompleted = !0, a.current.isQuestionMode = !1;
7366
7366
  const b = a.current.totalQuestions > 0 ? Math.round(a.current.score / a.current.totalQuestions * 100) : 100;
7367
- let v = "Congratulations! You've completed this lesson";
7368
- if (a.current.totalQuestions > 0 ? v += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7367
+ let R = "Congratulations! You've completed this lesson";
7368
+ if (a.current.totalQuestions > 0 ? R += ` You got ${a.current.score} correct out of ${a.current.totalQuestions} question${a.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : R += "! ", b >= 80 ? R += "Excellent work! You have a great understanding of this topic." : b >= 60 ? R += "Good job! You understand most of the concepts." : R += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7369
7369
  moduleIndex: a.current.currentModuleIndex,
7370
7370
  lessonIndex: a.current.currentLessonIndex,
7371
7371
  score: a.current.score,
@@ -7385,9 +7385,9 @@ const gt = ze(({
7385
7385
  } catch {
7386
7386
  h.current.playCelebration();
7387
7387
  }
7388
- const w = H.current || { modules: [] }, C = w.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = a.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = D || te, j = z.current || { lipsyncLang: "en" };
7389
- h.current.speakText(v, {
7390
- lipsyncLang: j.lipsyncLang,
7388
+ const w = H.current || { modules: [] }, C = w.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ee = a.current.currentModuleIndex < (w.modules?.length || 0) - 1, q = D || ee, Y = z.current || { lipsyncLang: "en" };
7389
+ h.current.speakText(R, {
7390
+ lipsyncLang: Y.lipsyncLang,
7391
7391
  onSpeechEnd: () => {
7392
7392
  c.current.onCustomAction({
7393
7393
  type: "lessonCompleteFeedbackDone",
@@ -7406,7 +7406,7 @@ const gt = ze(({
7406
7406
  const b = H.current || { modules: [] };
7407
7407
  if (c.current.onCurriculumComplete({
7408
7408
  modules: b.modules.length,
7409
- totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
7409
+ totalLessons: b.modules.reduce((R, w) => R + w.lessons.length, 0)
7410
7410
  }), h.current) {
7411
7411
  if (h.current.setMood("celebrating"), e.curriculumComplete)
7412
7412
  try {
@@ -7414,24 +7414,24 @@ const gt = ze(({
7414
7414
  } catch {
7415
7415
  h.current.playCelebration();
7416
7416
  }
7417
- const v = z.current || { lipsyncLang: "en" };
7418
- h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: v.lipsyncLang });
7417
+ const R = z.current || { lipsyncLang: "en" };
7418
+ h.current.speakText("Amazing! You've completed the entire curriculum! You're now ready to move on to more advanced topics. Well done!", { lipsyncLang: R.lipsyncLang });
7419
7419
  }
7420
7420
  }, [e.curriculumComplete]), S = M(() => {
7421
- const b = R();
7421
+ const b = I();
7422
7422
  a.current.isQuestionMode = !0, a.current.currentQuestionIndex = 0, a.current.totalQuestions = b?.questions?.length || 0, a.current.score = 0;
7423
- const v = T();
7424
- v && c.current.onCustomAction({
7423
+ const R = T();
7424
+ R && c.current.onCustomAction({
7425
7425
  type: "questionStart",
7426
7426
  moduleIndex: a.current.currentModuleIndex,
7427
7427
  lessonIndex: a.current.currentLessonIndex,
7428
7428
  questionIndex: a.current.currentQuestionIndex,
7429
7429
  totalQuestions: a.current.totalQuestions,
7430
- question: v,
7430
+ question: R,
7431
7431
  score: a.current.score
7432
7432
  });
7433
7433
  const w = () => {
7434
- if (!h.current || !v) return;
7434
+ if (!h.current || !R) return;
7435
7435
  if (h.current.setMood("happy"), e.questionStart)
7436
7436
  try {
7437
7437
  h.current.playAnimation(e.questionStart, !0);
@@ -7439,69 +7439,69 @@ const gt = ze(({
7439
7439
  console.warn("Failed to play questionStart animation:", D);
7440
7440
  }
7441
7441
  const C = z.current || { lipsyncLang: "en" };
7442
- v.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : v.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${v.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${v.question}`, { lipsyncLang: C.lipsyncLang });
7442
+ R.type === "code_test" ? h.current.speakText(`Let's test your coding skills! Here's your first challenge: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "multiple_choice" ? h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : R.type === "true_false" ? h.current.speakText(`Let's start with some true or false questions. First question: ${R.question}`, { lipsyncLang: C.lipsyncLang }) : h.current.speakText(`Now let me ask you some questions. Here's the first one: ${R.question}`, { lipsyncLang: C.lipsyncLang });
7443
7443
  };
7444
- if (h.current && h.current.isReady && v)
7444
+ if (h.current && h.current.isReady && R)
7445
7445
  w();
7446
7446
  else if (h.current && h.current.isReady) {
7447
7447
  const C = z.current || { lipsyncLang: "en" };
7448
7448
  h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
7449
7449
  } else {
7450
7450
  const C = setInterval(() => {
7451
- h.current && h.current.isReady && (clearInterval(C), v && w());
7451
+ h.current && h.current.isReady && (clearInterval(C), R && w());
7452
7452
  }, 100);
7453
7453
  setTimeout(() => {
7454
7454
  clearInterval(C);
7455
7455
  }, 5e3);
7456
7456
  }
7457
- }, [e.questionStart, R, T]), W = M(() => {
7458
- const b = R();
7457
+ }, [e.questionStart, I, T]), W = M(() => {
7458
+ const b = I();
7459
7459
  if (a.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7460
7460
  h.current && h.current.stopSpeaking && h.current.stopSpeaking(), a.current.currentQuestionIndex += 1;
7461
- const v = T();
7462
- v && c.current.onCustomAction({
7461
+ const R = T();
7462
+ R && c.current.onCustomAction({
7463
7463
  type: "nextQuestion",
7464
7464
  moduleIndex: a.current.currentModuleIndex,
7465
7465
  lessonIndex: a.current.currentLessonIndex,
7466
7466
  questionIndex: a.current.currentQuestionIndex,
7467
7467
  totalQuestions: a.current.totalQuestions,
7468
- question: v,
7468
+ question: R,
7469
7469
  score: a.current.score
7470
7470
  });
7471
7471
  const w = () => {
7472
- if (!h.current || !v) return;
7472
+ if (!h.current || !R) return;
7473
7473
  if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
7474
7474
  try {
7475
7475
  h.current.playAnimation(e.nextQuestion, !0);
7476
- } catch (j) {
7477
- console.warn("Failed to play nextQuestion animation:", j);
7476
+ } catch (Y) {
7477
+ console.warn("Failed to play nextQuestion animation:", Y);
7478
7478
  }
7479
- const C = z.current || { lipsyncLang: "en" }, te = R()?.questions?.length || 0, q = a.current.currentQuestionIndex >= te - 1;
7480
- if (v.type === "code_test") {
7481
- const j = q ? `Great! Here's your final coding challenge: ${v.question}` : `Great! Now let's move on to your next coding challenge: ${v.question}`;
7482
- h.current.speakText(j, {
7479
+ const C = z.current || { lipsyncLang: "en" }, ee = I()?.questions?.length || 0, q = a.current.currentQuestionIndex >= ee - 1;
7480
+ if (R.type === "code_test") {
7481
+ const Y = q ? `Great! Here's your final coding challenge: ${R.question}` : `Great! Now let's move on to your next coding challenge: ${R.question}`;
7482
+ h.current.speakText(Y, {
7483
7483
  lipsyncLang: C.lipsyncLang
7484
7484
  });
7485
- } else if (v.type === "multiple_choice") {
7486
- const j = q ? `Alright! Here's your final question: ${v.question}` : `Alright! Here's your next question: ${v.question}`;
7487
- h.current.speakText(j, {
7485
+ } else if (R.type === "multiple_choice") {
7486
+ const Y = q ? `Alright! Here's your final question: ${R.question}` : `Alright! Here's your next question: ${R.question}`;
7487
+ h.current.speakText(Y, {
7488
7488
  lipsyncLang: C.lipsyncLang
7489
7489
  });
7490
- } else if (v.type === "true_false") {
7491
- const j = q ? `Now let's try this final one: ${v.question}` : `Now let's try this one: ${v.question}`;
7492
- h.current.speakText(j, {
7490
+ } else if (R.type === "true_false") {
7491
+ const Y = q ? `Now let's try this final one: ${R.question}` : `Now let's try this one: ${R.question}`;
7492
+ h.current.speakText(Y, {
7493
7493
  lipsyncLang: C.lipsyncLang
7494
7494
  });
7495
7495
  } else {
7496
- const j = q ? `Here's your final question: ${v.question}` : `Here's the next question: ${v.question}`;
7497
- h.current.speakText(j, {
7496
+ const Y = q ? `Here's your final question: ${R.question}` : `Here's the next question: ${R.question}`;
7497
+ h.current.speakText(Y, {
7498
7498
  lipsyncLang: C.lipsyncLang
7499
7499
  });
7500
7500
  }
7501
7501
  };
7502
- if (h.current && h.current.isReady && v)
7502
+ if (h.current && h.current.isReady && R)
7503
7503
  w();
7504
- else if (v) {
7504
+ else if (R) {
7505
7505
  const C = setInterval(() => {
7506
7506
  h.current && h.current.isReady && (clearInterval(C), w());
7507
7507
  }, 100);
@@ -7517,11 +7517,11 @@ const gt = ze(({
7517
7517
  totalQuestions: a.current.totalQuestions,
7518
7518
  score: a.current.score
7519
7519
  });
7520
- }, [e.nextQuestion, R, T]), Y = M(() => {
7521
- const b = H.current || { modules: [] }, v = b.modules[a.current.currentModuleIndex];
7522
- if (a.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7520
+ }, [e.nextQuestion, I, T]), j = M(() => {
7521
+ const b = H.current || { modules: [] }, R = b.modules[a.current.currentModuleIndex];
7522
+ if (a.current.currentLessonIndex < (R?.lessons?.length || 0) - 1) {
7523
7523
  a.current.currentLessonIndex += 1, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7524
- const C = b.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = D || te;
7524
+ const C = b.modules[a.current.currentModuleIndex], D = a.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, ee = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, q = D || ee;
7525
7525
  c.current.onCustomAction({
7526
7526
  type: "lessonStart",
7527
7527
  moduleIndex: a.current.currentModuleIndex,
@@ -7530,32 +7530,32 @@ const gt = ze(({
7530
7530
  }), c.current.onLessonStart({
7531
7531
  moduleIndex: a.current.currentModuleIndex,
7532
7532
  lessonIndex: a.current.currentLessonIndex,
7533
- lesson: R()
7533
+ lesson: I()
7534
7534
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7535
7535
  } else if (a.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7536
7536
  a.current.currentModuleIndex += 1, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.lessonCompleted = !1, a.current.isQuestionMode = !1, a.current.isTeaching = !1, a.current.score = 0, a.current.totalQuestions = 0;
7537
- const D = b.modules[a.current.currentModuleIndex], te = a.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, q = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, j = te || q;
7537
+ const D = b.modules[a.current.currentModuleIndex], ee = a.current.currentLessonIndex < (D?.lessons?.length || 0) - 1, q = a.current.currentModuleIndex < (b.modules?.length || 0) - 1, Y = ee || q;
7538
7538
  c.current.onCustomAction({
7539
7539
  type: "lessonStart",
7540
7540
  moduleIndex: a.current.currentModuleIndex,
7541
7541
  lessonIndex: a.current.currentLessonIndex,
7542
- hasNextLesson: j
7542
+ hasNextLesson: Y
7543
7543
  }), c.current.onLessonStart({
7544
7544
  moduleIndex: a.current.currentModuleIndex,
7545
7545
  lessonIndex: a.current.currentLessonIndex,
7546
- lesson: R()
7546
+ lesson: I()
7547
7547
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7548
7548
  } else
7549
- I.current && I.current();
7549
+ v.current && v.current();
7550
7550
  }, []), Z = M(() => {
7551
- const b = R();
7552
- let v = null;
7551
+ const b = I();
7552
+ let R = null;
7553
7553
  if (b?.avatar_script && b?.body) {
7554
7554
  const w = b.avatar_script.trim(), C = b.body.trim(), D = w.match(/[.!?]$/) ? " " : ". ";
7555
- v = `${w}${D}${C}`;
7555
+ R = `${w}${D}${C}`;
7556
7556
  } else
7557
- v = b?.avatar_script || b?.body || null;
7558
- if (h.current && h.current.isReady && v) {
7557
+ R = b?.avatar_script || b?.body || null;
7558
+ if (h.current && h.current.isReady && R) {
7559
7559
  a.current.isTeaching = !0, a.current.isQuestionMode = !1, a.current.score = 0, a.current.totalQuestions = 0, h.current.setMood("happy");
7560
7560
  let w = !1;
7561
7561
  if (e.teaching)
@@ -7575,7 +7575,7 @@ const gt = ze(({
7575
7575
  moduleIndex: a.current.currentModuleIndex,
7576
7576
  lessonIndex: a.current.currentLessonIndex,
7577
7577
  lesson: b
7578
- }), h.current.speakText(v, {
7578
+ }), h.current.speakText(R, {
7579
7579
  lipsyncLang: C.lipsyncLang,
7580
7580
  onSpeechEnd: () => {
7581
7581
  a.current.isTeaching = !1, c.current.onCustomAction({
@@ -7594,15 +7594,15 @@ const gt = ze(({
7594
7594
  }
7595
7595
  });
7596
7596
  }
7597
- }, [e.teaching, R]), $ = M((b) => {
7598
- const v = T(), w = F(b, v);
7597
+ }, [e.teaching, I]), $ = M((b) => {
7598
+ const R = T(), w = F(b, R);
7599
7599
  if (w && (a.current.score += 1), c.current.onQuestionAnswer({
7600
7600
  moduleIndex: a.current.currentModuleIndex,
7601
7601
  lessonIndex: a.current.currentLessonIndex,
7602
7602
  questionIndex: a.current.currentQuestionIndex,
7603
7603
  answer: b,
7604
7604
  isCorrect: w,
7605
- question: v
7605
+ question: R
7606
7606
  }), h.current)
7607
7607
  if (w) {
7608
7608
  if (h.current.setMood("happy"), e.correct)
@@ -7612,11 +7612,13 @@ const gt = ze(({
7612
7612
  h.current.setBodyMovement("happy");
7613
7613
  }
7614
7614
  h.current.setBodyMovement("gesturing");
7615
- const D = R()?.questions?.length || 0;
7615
+ const D = I()?.questions?.length || 0;
7616
7616
  a.current.currentQuestionIndex >= D - 1;
7617
- const te = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, q = z.current || { lipsyncLang: "en" };
7618
- h.current.speakText(te, {
7619
- lipsyncLang: q.lipsyncLang,
7617
+ const ee = a.current.currentQuestionIndex < D - 1;
7618
+ console.log("[CurriculumLearning] Answer feedback - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", D, "hasNextQuestion:", ee);
7619
+ const q = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, Y = z.current || { lipsyncLang: "en" };
7620
+ h.current.speakText(q, {
7621
+ lipsyncLang: Y.lipsyncLang,
7620
7622
  onSpeechEnd: () => {
7621
7623
  c.current.onCustomAction({
7622
7624
  type: "answerFeedbackComplete",
@@ -7624,7 +7626,7 @@ const gt = ze(({
7624
7626
  lessonIndex: a.current.currentLessonIndex,
7625
7627
  questionIndex: a.current.currentQuestionIndex,
7626
7628
  isCorrect: !0,
7627
- hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7629
+ hasNextQuestion: ee,
7628
7630
  score: a.current.score,
7629
7631
  totalQuestions: a.current.totalQuestions
7630
7632
  });
@@ -7638,9 +7640,11 @@ const gt = ze(({
7638
7640
  h.current.setBodyMovement("idle");
7639
7641
  }
7640
7642
  h.current.setBodyMovement("gesturing");
7641
- const D = R()?.questions?.length || 0, te = a.current.currentQuestionIndex >= D - 1, q = v.type === "code_test" ? `Your code didn't pass all the tests. ${v.explanation || "Try again!"}` : `Not quite right, but don't worry! ${v.explanation || ""}${te ? "" : " Let's move on to the next question."}`, j = z.current || { lipsyncLang: "en" };
7642
- h.current.speakText(q, {
7643
- lipsyncLang: j.lipsyncLang,
7643
+ const D = I()?.questions?.length || 0, ee = a.current.currentQuestionIndex >= D - 1, q = a.current.currentQuestionIndex < D - 1;
7644
+ console.log("[CurriculumLearning] Answer feedback (incorrect) - questionIndex:", a.current.currentQuestionIndex, "totalQuestions:", D, "hasNextQuestion:", q);
7645
+ const Y = R.type === "code_test" ? `Your code didn't pass all the tests. ${R.explanation || "Try again!"}` : `Not quite right, but don't worry! ${R.explanation || ""}${ee ? "" : " Let's move on to the next question."}`, ve = z.current || { lipsyncLang: "en" };
7646
+ h.current.speakText(Y, {
7647
+ lipsyncLang: ve.lipsyncLang,
7644
7648
  onSpeechEnd: () => {
7645
7649
  c.current.onCustomAction({
7646
7650
  type: "answerFeedbackComplete",
@@ -7648,7 +7652,7 @@ const gt = ze(({
7648
7652
  lessonIndex: a.current.currentLessonIndex,
7649
7653
  questionIndex: a.current.currentQuestionIndex,
7650
7654
  isCorrect: !1,
7651
- hasNextQuestion: a.current.currentQuestionIndex < D - 1,
7655
+ hasNextQuestion: q,
7652
7656
  score: a.current.score,
7653
7657
  totalQuestions: a.current.totalQuestions
7654
7658
  });
@@ -7656,7 +7660,7 @@ const gt = ze(({
7656
7660
  });
7657
7661
  }
7658
7662
  else {
7659
- const D = R()?.questions?.length || 0;
7663
+ const D = I()?.questions?.length || 0;
7660
7664
  c.current.onCustomAction({
7661
7665
  type: "answerFeedbackComplete",
7662
7666
  moduleIndex: a.current.currentModuleIndex,
@@ -7669,13 +7673,13 @@ const gt = ze(({
7669
7673
  avatarNotReady: !0
7670
7674
  });
7671
7675
  }
7672
- }, [e.correct, e.incorrect, T, R, F]), se = M((b) => {
7673
- const v = T();
7676
+ }, [e.correct, e.incorrect, T, I, F]), se = M((b) => {
7677
+ const R = T();
7674
7678
  if (!b || typeof b != "object") {
7675
7679
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
7676
7680
  return;
7677
7681
  }
7678
- if (v?.type !== "code_test") {
7682
+ if (R?.type !== "code_test") {
7679
7683
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
7680
7684
  return;
7681
7685
  }
@@ -7695,7 +7699,7 @@ const gt = ze(({
7695
7699
  lessonIndex: a.current.currentLessonIndex,
7696
7700
  questionIndex: a.current.currentQuestionIndex,
7697
7701
  testResult: w,
7698
- question: v
7702
+ question: R
7699
7703
  }), p.current && p.current(w);
7700
7704
  }, [T, F]), de = M(() => {
7701
7705
  if (a.current.currentQuestionIndex > 0) {
@@ -7710,7 +7714,7 @@ const gt = ze(({
7710
7714
  question: b,
7711
7715
  score: a.current.score
7712
7716
  });
7713
- const v = () => {
7717
+ const R = () => {
7714
7718
  if (!h.current || !b) return;
7715
7719
  h.current.setMood("happy"), h.current.setBodyMovement("idle");
7716
7720
  const w = z.current || { lipsyncLang: "en" };
@@ -7721,10 +7725,10 @@ const gt = ze(({
7721
7725
  });
7722
7726
  };
7723
7727
  if (h.current && h.current.isReady && b)
7724
- v();
7728
+ R();
7725
7729
  else if (b) {
7726
7730
  const w = setInterval(() => {
7727
- h.current && h.current.isReady && (clearInterval(w), v());
7731
+ h.current && h.current.isReady && (clearInterval(w), R());
7728
7732
  }, 100);
7729
7733
  setTimeout(() => {
7730
7734
  clearInterval(w);
@@ -7741,7 +7745,7 @@ const gt = ze(({
7741
7745
  }), c.current.onLessonStart({
7742
7746
  moduleIndex: a.current.currentModuleIndex,
7743
7747
  lessonIndex: a.current.currentLessonIndex,
7744
- lesson: R()
7748
+ lesson: I()
7745
7749
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7746
7750
  else if (a.current.currentModuleIndex > 0) {
7747
7751
  const C = b.modules[a.current.currentModuleIndex - 1];
@@ -7752,20 +7756,20 @@ const gt = ze(({
7752
7756
  }), c.current.onLessonStart({
7753
7757
  moduleIndex: a.current.currentModuleIndex,
7754
7758
  lessonIndex: a.current.currentLessonIndex,
7755
- lesson: R()
7759
+ lesson: I()
7756
7760
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7757
7761
  }
7758
- }, [R]), ie = M(() => {
7762
+ }, [I]), ie = M(() => {
7759
7763
  a.current.currentModuleIndex = 0, a.current.currentLessonIndex = 0, a.current.currentQuestionIndex = 0, a.current.isTeaching = !1, a.current.isQuestionMode = !1, a.current.lessonCompleted = !1, a.current.curriculumCompleted = !1, a.current.score = 0, a.current.totalQuestions = 0;
7760
7764
  }, []), fe = M((b) => {
7761
7765
  console.log("Avatar is ready!", b);
7762
- const v = R(), w = v?.avatar_script || v?.body;
7766
+ const R = I(), w = R?.avatar_script || R?.body;
7763
7767
  u && w && setTimeout(() => {
7764
7768
  d.current && d.current();
7765
7769
  }, 10);
7766
- }, [u, R]);
7770
+ }, [u, I]);
7767
7771
  Xe(() => {
7768
- d.current = Z, g.current = Y, y.current = J, x.current = W, I.current = ye, B.current = S, p.current = $;
7772
+ d.current = Z, g.current = j, y.current = J, x.current = W, v.current = ye, B.current = S, p.current = $;
7769
7773
  }), Ce(r, () => ({
7770
7774
  // Curriculum control methods
7771
7775
  startTeaching: Z,
@@ -7774,31 +7778,31 @@ const gt = ze(({
7774
7778
  handleCodeTestResult: se,
7775
7779
  nextQuestion: W,
7776
7780
  previousQuestion: de,
7777
- nextLesson: Y,
7781
+ nextLesson: j,
7778
7782
  previousLesson: me,
7779
7783
  completeLesson: J,
7780
7784
  completeCurriculum: ye,
7781
7785
  resetCurriculum: ie,
7782
7786
  getState: () => ({ ...a.current }),
7783
7787
  getCurrentQuestion: () => T(),
7784
- getCurrentLesson: () => R(),
7788
+ getCurrentLesson: () => I(),
7785
7789
  // Direct access to avatar ref (always returns current value)
7786
7790
  getAvatarRef: () => h.current,
7787
7791
  // Convenience methods that delegate to avatar (always check current ref)
7788
- speakText: async (b, v = {}) => {
7792
+ speakText: async (b, R = {}) => {
7789
7793
  await h.current?.resumeAudioContext?.();
7790
7794
  const w = z.current || { lipsyncLang: "en" };
7791
- h.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || w.lipsyncLang });
7795
+ h.current?.speakText(b, { ...R, lipsyncLang: R.lipsyncLang || w.lipsyncLang });
7792
7796
  },
7793
7797
  resumeAudioContext: async () => {
7794
7798
  if (h.current?.resumeAudioContext)
7795
7799
  return await h.current.resumeAudioContext();
7796
7800
  const b = h.current?.talkingHead;
7797
7801
  if (b?.audioCtx) {
7798
- const v = b.audioCtx;
7799
- if (v.state === "suspended" || v.state === "interrupted")
7802
+ const R = b.audioCtx;
7803
+ if (R.state === "suspended" || R.state === "interrupted")
7800
7804
  try {
7801
- await v.resume(), console.log("Audio context resumed via talkingHead");
7805
+ await R.resume(), console.log("Audio context resumed via talkingHead");
7802
7806
  } catch (w) {
7803
7807
  console.warn("Failed to resume audio context:", w);
7804
7808
  }
@@ -7810,7 +7814,7 @@ const gt = ze(({
7810
7814
  resumeSpeaking: async () => await h.current?.resumeSpeaking(),
7811
7815
  isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
7812
7816
  setMood: (b) => h.current?.setMood(b),
7813
- playAnimation: (b, v) => h.current?.playAnimation(b, v),
7817
+ playAnimation: (b, R) => h.current?.playAnimation(b, R),
7814
7818
  setBodyMovement: (b) => h.current?.setBodyMovement(b),
7815
7819
  setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
7816
7820
  playRandomDance: () => h.current?.playRandomDance(),
@@ -7821,10 +7825,10 @@ const gt = ze(({
7821
7825
  lockAvatarPosition: () => h.current?.lockAvatarPosition(),
7822
7826
  unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
7823
7827
  // Custom action trigger
7824
- triggerCustomAction: (b, v) => {
7828
+ triggerCustomAction: (b, R) => {
7825
7829
  c.current.onCustomAction({
7826
7830
  type: b,
7827
- ...v,
7831
+ ...R,
7828
7832
  state: { ...a.current }
7829
7833
  });
7830
7834
  },
@@ -7832,7 +7836,7 @@ const gt = ze(({
7832
7836
  handleResize: () => h.current?.handleResize(),
7833
7837
  // Avatar readiness check (always returns current value)
7834
7838
  isAvatarReady: () => h.current?.isReady || !1
7835
- }), [Z, S, $, se, W, Y, J, ye, ie, T, R]);
7839
+ }), [Z, S, $, se, W, j, J, ye, ie, T, I]);
7836
7840
  const X = z.current || {
7837
7841
  avatarUrl: "/avatars/brunette.glb",
7838
7842
  avatarBody: "F",
@@ -7847,7 +7851,7 @@ const gt = ze(({
7847
7851
  animations: e
7848
7852
  };
7849
7853
  return /* @__PURE__ */ ge("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ ge(
7850
- Ne,
7854
+ Ue,
7851
7855
  {
7852
7856
  ref: h,
7853
7857
  avatarUrl: X.avatarUrl,
@@ -7872,7 +7876,7 @@ const gt = ze(({
7872
7876
  ) });
7873
7877
  });
7874
7878
  gt.displayName = "CurriculumLearning";
7875
- const Ue = {
7879
+ const We = {
7876
7880
  // Code-based dance animations (no FBX required)
7877
7881
  dance: {
7878
7882
  name: "dance",
@@ -7975,12 +7979,12 @@ const Ue = {
7975
7979
  duration: 5e3,
7976
7980
  description: "Excited, energetic movement"
7977
7981
  }
7978
- }, kt = (U) => Ue[U] || null, wt = (U) => Ue.hasOwnProperty(U);
7982
+ }, kt = (U) => We[U] || null, wt = (U) => We.hasOwnProperty(U);
7979
7983
  export {
7980
7984
  gt as CurriculumLearning,
7981
- Ne as TalkingHeadAvatar,
7985
+ Ue as TalkingHeadAvatar,
7982
7986
  pt as TalkingHeadComponent,
7983
- Ue as animations,
7987
+ We as animations,
7984
7988
  He as getActiveTTSConfig,
7985
7989
  kt as getAnimation,
7986
7990
  St as getVoiceOptions,