@sage-rsc/talking-head-react 1.0.60 → 1.0.61

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 Te, jsx as he } from "react/jsx-runtime";
2
- import { forwardRef as Re, useRef as Z, useState as ce, useEffect as pe, useCallback as T, useImperativeHandle as Ie, useLayoutEffect as Oe } from "react";
1
+ import { jsxs as Me, jsx as he } from "react/jsx-runtime";
2
+ import { forwardRef as Ie, useRef as X, useState as ue, useEffect as pe, useCallback as T, useImperativeHandle as Le, useLayoutEffect as Ne } from "react";
3
3
  import * as f from "three";
4
- import { OrbitControls as Ne } from "three/addons/controls/OrbitControls.js";
5
- import { GLTFLoader as Ue } from "three/addons/loaders/GLTFLoader.js";
6
- import { DRACOLoader as We } from "three/addons/loaders/DRACOLoader.js";
7
- import { FBXLoader as ke } from "three/addons/loaders/FBXLoader.js";
8
- import { RoomEnvironment as Ve } from "three/addons/environments/RoomEnvironment.js";
9
- import Ge from "three/addons/libs/stats.module.js";
10
- let m, K, $;
11
- const L = [0, 0, 0, 0], k = new f.Vector3(), fe = new f.Vector3(), Q = new f.Vector3(), xe = new f.Vector3();
4
+ import { OrbitControls as Ue } from "three/addons/controls/OrbitControls.js";
5
+ import { GLTFLoader as We } from "three/addons/loaders/GLTFLoader.js";
6
+ import { DRACOLoader as Ve } from "three/addons/loaders/DRACOLoader.js";
7
+ import { FBXLoader as we } from "three/addons/loaders/FBXLoader.js";
8
+ import { RoomEnvironment as Ge } from "three/addons/environments/RoomEnvironment.js";
9
+ import Ze from "three/addons/libs/stats.module.js";
10
+ let m, K, ee;
11
+ const L = [0, 0, 0, 0], k = new f.Vector3(), be = new f.Vector3(), Q = new f.Vector3(), ve = new f.Vector3();
12
12
  new f.Plane();
13
13
  new f.Ray();
14
14
  new f.Euler();
15
- const q = new f.Quaternion(), we = new f.Quaternion(), oe = new f.Matrix4(), se = new f.Matrix4();
15
+ const q = new f.Quaternion(), ze = new f.Quaternion(), oe = new f.Matrix4(), se = new f.Matrix4();
16
16
  new f.Vector3();
17
- const be = new f.Vector3(0, 0, 1), Ze = new f.Vector3(1, 0, 0), Xe = new f.Vector3(0, 1, 0), Ye = new f.Vector3(0, 0, 1);
18
- class je {
17
+ const Re = new f.Vector3(0, 0, 1), Xe = new f.Vector3(1, 0, 0), Ye = new f.Vector3(0, 1, 0), je = new f.Vector3(0, 0, 1);
18
+ class Qe {
19
19
  constructor(t = null) {
20
20
  this.opt = Object.assign({
21
21
  warmupMs: 2e3,
@@ -338,7 +338,7 @@ class je {
338
338
  ea: [0, 0, 0, 0]
339
339
  // External acceleration [m/s^2]
340
340
  };
341
- h.boneParent.matrixWorld.decompose(k, q, Q), k.copy(be).applyQuaternion(q).setY(0).normalize(), q.premultiply(we.setFromUnitVectors(be, k).invert()).normalize(), h.qWorldInverseYaw = q.clone().normalize(), this.data.push(h), this.dict[u] = h;
341
+ h.boneParent.matrixWorld.decompose(k, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(ze.setFromUnitVectors(Re, k).invert()).normalize(), h.qWorldInverseYaw = q.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 (r) {
@@ -369,9 +369,9 @@ class je {
369
369
  o.vBasis.y + L[1],
370
370
  o.vBasis.z - L[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, q, Q), k.copy(be).applyQuaternion(q).setY(0).normalize(), q.premultiply(we.setFromUnitVectors(be, k).invert()).normalize(), o.boneParent.quaternion.multiply(q.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(L[0] / o.l), q.setFromAxisAngle(Ye, -m), o.boneParent.quaternion.multiply(q)), o.isY && (m = o.l / 3, m = m * Math.tanh(L[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(L[2] / o.l), q.setFromAxisAngle(Ze, -m), o.boneParent.quaternion.multiply(q)), o.isT && (m = 1.5 * Math.tanh(L[3] * 1.5), q.setFromAxisAngle(Xe, -m), o.boneParent.quaternion.multiply(q)), 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, q, Q), k.copy(Re).applyQuaternion(q).setY(0).normalize(), q.premultiply(ze.setFromUnitVectors(Re, k).invert()).normalize(), o.boneParent.quaternion.multiply(q.invert()), o.boneParent.quaternion.multiply(o.qWorldInverseYaw)), o.isZ && (m = Math.atan(L[0] / o.l), q.setFromAxisAngle(je, -m), o.boneParent.quaternion.multiply(q)), o.isY && (m = o.l / 3, m = m * Math.tanh(L[1] / m), o.bone.position.setLength(o.l + m)), o.isX && (m = Math.atan(L[2] / o.l), q.setFromAxisAngle(Xe, -m), o.boneParent.quaternion.multiply(q)), o.isT && (m = 1.5 * Math.tanh(L[3] * 1.5), q.setFromAxisAngle(Ye, -m), o.boneParent.quaternion.multiply(q)), o.boneParent.updateWorldMatrix(!1, !0), o.excludes && this.opt.isExcludes)
373
373
  for (i = 0, s = o.excludes.length; i < s; i++)
374
- m = o.excludes[i], Q.set(0, 0, 0), m.deltaLocal && (Q.x += m.deltaLocal[0], Q.y += m.deltaLocal[1], Q.z += m.deltaLocal[2]), Q.applyMatrix4(m.bone.matrixWorld), se.copy(o.boneParent.matrixWorld).invert(), Q.applyMatrix4(se), k.copy(o.bone.position), !(k.distanceToSquared(Q) >= m.radiusSq) && ($ = k.length(), K = Q.length(), !(K > m.radius + $) && (K < Math.abs(m.radius - $) || (K = (K * K + $ * $ - m.radiusSq) / (2 * K), Q.normalize(), xe.copy(Q).multiplyScalar(K), K = Math.sqrt($ * $ - K * K), k.subVectors(k, xe).projectOnPlane(Q).normalize().multiplyScalar(K), fe.subVectors(o.vBasis, xe).projectOnPlane(Q).normalize(), $ = fe.dot(k), $ < 0 && ($ = Math.sqrt(K * K - $ * $), fe.multiplyScalar($), k.add(fe)), k.add(xe).normalize(), Q.copy(o.bone.position).normalize(), q.setFromUnitVectors(Q, k), o.boneParent.quaternion.premultiply(q), o.boneParent.updateWorldMatrix(!1, !0))));
374
+ m = o.excludes[i], Q.set(0, 0, 0), m.deltaLocal && (Q.x += m.deltaLocal[0], Q.y += m.deltaLocal[1], Q.z += m.deltaLocal[2]), Q.applyMatrix4(m.bone.matrixWorld), se.copy(o.boneParent.matrixWorld).invert(), Q.applyMatrix4(se), k.copy(o.bone.position), !(k.distanceToSquared(Q) >= m.radiusSq) && (ee = k.length(), K = Q.length(), !(K > m.radius + ee) && (K < Math.abs(m.radius - ee) || (K = (K * K + ee * ee - m.radiusSq) / (2 * K), Q.normalize(), ve.copy(Q).multiplyScalar(K), K = Math.sqrt(ee * ee - K * K), k.subVectors(k, ve).projectOnPlane(Q).normalize().multiplyScalar(K), be.subVectors(o.vBasis, ve).projectOnPlane(Q).normalize(), ee = be.dot(k), ee < 0 && (ee = Math.sqrt(K * K - ee * ee), be.multiplyScalar(ee), k.add(be)), k.add(ve).normalize(), Q.copy(o.bone.position).normalize(), q.setFromUnitVectors(Q, k), o.boneParent.quaternion.premultiply(q), o.boneParent.updateWorldMatrix(!1, !0))));
375
375
  }
376
376
  this.helpers.isActive && this.updateHelpers();
377
377
  }
@@ -489,7 +489,7 @@ class je {
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 Qe {
492
+ class qe {
493
493
  constructor(t) {
494
494
  this.audioContext = t, this.analyzer = null, this.dataArray = null, this.bufferLength = 0;
495
495
  }
@@ -814,7 +814,7 @@ class Qe {
814
814
  return n * s;
815
815
  }
816
816
  }
817
- class qe {
817
+ class _e {
818
818
  /**
819
819
  * @constructor
820
820
  */
@@ -1396,11 +1396,11 @@ class qe {
1396
1396
  return e;
1397
1397
  }
1398
1398
  }
1399
- const _e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1399
+ const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1400
1400
  __proto__: null,
1401
- LipsyncEn: qe
1401
+ LipsyncEn: _e
1402
1402
  }, Symbol.toStringTag, { value: "Module" }));
1403
- class Ke {
1403
+ class Je {
1404
1404
  /**
1405
1405
  * @constructor
1406
1406
  */
@@ -1754,11 +1754,11 @@ class Ke {
1754
1754
  return e;
1755
1755
  }
1756
1756
  }
1757
- const Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1757
+ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1758
1758
  __proto__: null,
1759
- LipsyncDe: Ke
1759
+ LipsyncDe: Je
1760
1760
  }, Symbol.toStringTag, { value: "Module" }));
1761
- class $e {
1761
+ class et {
1762
1762
  /**
1763
1763
  * @constructor
1764
1764
  */
@@ -2289,11 +2289,11 @@ class $e {
2289
2289
  return e;
2290
2290
  }
2291
2291
  }
2292
- const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2293
2293
  __proto__: null,
2294
- LipsyncFr: $e
2294
+ LipsyncFr: et
2295
2295
  }, Symbol.toStringTag, { value: "Module" }));
2296
- class tt {
2296
+ class it {
2297
2297
  /**
2298
2298
  * @constructor
2299
2299
  */
@@ -2436,11 +2436,11 @@ class tt {
2436
2436
  return e;
2437
2437
  }
2438
2438
  }
2439
- const it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2439
+ const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2440
2440
  __proto__: null,
2441
- LipsyncFi: tt
2441
+ LipsyncFi: it
2442
2442
  }, Symbol.toStringTag, { value: "Module" }));
2443
- class nt {
2443
+ class ot {
2444
2444
  /**
2445
2445
  * @constructor
2446
2446
  */
@@ -2620,24 +2620,24 @@ class nt {
2620
2620
  return e;
2621
2621
  }
2622
2622
  }
2623
- const ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2623
+ const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2624
2624
  __proto__: null,
2625
- LipsyncLt: nt
2626
- }, Symbol.toStringTag, { value: "Module" })), st = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2UuYmluZCh0aGlzKTsKCiAgICB0aGlzLl9zYW1wbGVSYXRlID0gb3B0aW9ucz8ucHJvY2Vzc29yT3B0aW9ucz8uc2FtcGxlUmF0ZSB8fCBzYW1wbGVSYXRlOwogICAgdGhpcy5fc2NhbGUgPSAxIC8gMzI3Njg7IC8vIFBDTTE2IC0+IGZsb2F0CgogICAgLy8gU2lsZW5jZSBkZXRlY3Rpb24gdGhyZXNob2xkICgxIHNlY29uZCkgYXMgYSBmYWxsYmFjayBzYWZldHkgbmV0CiAgICBjb25zdCB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HRoaXMuX2N1cnJlbnRDaHVuayA9IHRoaXMuX2J1ZmZlclF1ZXVlLnNoaWZ0KCk7CiAgICAgICAgICB0aGlzLl9jdXJyZW50Q2h1bmtPZmZzZXQgPSAwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAvLyBCdWZmZXIgaXMgZW1wdHkuIENoZWNrIGZvciBlbmQgY29uZGl0aW9ucy4KICAgICAgICAgIGNvbnN0IGlzVGltZWRPdXQgPSB0aGlzLl9zaWxlbmNlRnJhbWVzQ291bnQgPiB0aGlzLl9zaWxlbmNlVGhyZXNob2xkQmxvY2tzOwoKICAgICAgICAgIGlmICh0aGlzLl9ub01vcmVEYXRhUmVjZWl2ZWQgfHwgaXNUaW1lZE91dCkgewogICAgICAgICAgICAvLyBFTkQgT0YgUExBWUJBQ0s6IEVpdGhlciBleHBsaWNpdGx5IHNpZ25hbGVkIG9yIHRpbWVkIG91dC4KICAgICAgICAgICAgaWYgKCF0aGlzLl9oYXNTZW50RW5kZWQpIHsKICAgICAgICAgICAgICB0aGlzLnBvcnQucG9zdE1lc3NhZ2UoeyB0eXBlOiAicGxheWJhY2stZW5kZWQiIH0pOwogICAgICAgICAgICAgIHRoaXMuX2hhc1NlbnRFbmRlZCA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgLy8gU2VuZCBmaW5hbCBtZXRyaWNzIHNob3dpbmcgY2xlYXJlZCBzdGF0ZQogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7CiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIC8vIElmIHdlIGhhdmUgYSBjaHVuayAoY291bGQgYmUgYSBuZXcgb25lIGZyb20gdGhlIGxvZ2ljIGFib3ZlKSwgcHJvY2VzcyBpdC4KICAgICAgaWYgKHRoaXMuX2N1cnJlbnRDaHVuaykgewogICAgICAgIGNvbnN0IHNhbXBsZXNUb0NvcHkgPSBNYXRoLm1pbigKICAgICA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KiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), ze = {
2627
- en: _e,
2628
- de: Je,
2629
- fr: et,
2630
- fi: it,
2631
- lt: ot
2632
- }, W = new f.Quaternion(), M = new f.Euler(), ae = new f.Vector3(), le = new f.Vector3(), Ce = new f.Box3();
2625
+ LipsyncLt: ot
2626
+ }, Symbol.toStringTag, { value: "Module" })), at = new URL("data:text/javascript;base64,Y2xhc3MgUGxheWJhY2tXb3JrbGV0IGV4dGVuZHMgQXVkaW9Xb3JrbGV0UHJvY2Vzc29yIHsKICBzdGF0aWMgRlNNID0gewogICAgSURMRTogMCwKICAgIFBMQVlJTkc6IDEsCiAgfTsKCiAgY29uc3RydWN0b3Iob3B0aW9ucykgewogICAgc3VwZXIoKTsKICAgIHRoaXMucG9ydC5vbm1lc3NhZ2UgPSB0aGlzLmhhbmRsZU1lc3NhZ2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pZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHsKICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgdGhpcy5wb3J0LnBvc3RNZXNzYWdlKHsKICAgICAgICAgICAgICAgICAgdHlwZTogIm1ldHJpY3MiLAogICAgICAgICAgICAgICAgICBkYXRhOiB7CiAgICAgICAgICAgICAgICAgICAgc3RhdGU6IFBsYXliYWNrV29ya2xldC5GU00uSURMRSwKICAgICAgICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzOiAwLAogICAgICAgICAgICAgICAgICAgIHF1ZXVlZE1zOiAwLAogICAgICAgICAgICAgICAgICAgIG1heFF1ZXVlZE1zOiBNYXRoLnJvdW5kKCh0aGlzLl9tYXhRdWV1ZVNhbXBsZXMgLyB0aGlzLl9zYW1wbGVSYXRlKSAqIDEwMDApLAogICAgICAgICAgICAgICAgICAgIHVuZGVycnVuQmxvY2tzOiB0aGlzLl91bmRlcnJ1bkJsb2NrcywKICAgICAgICAgICAgICAgICAgICBmcmFtZXNQcm9jZXNzZWQ6IHRoaXMuX2ZyYW1lc1Byb2Nlc3NlZAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9KTsKICAgICAgICAgICAgICB9IGNhdGNoIChfKSB7IH0KICAgICAgICAgICAgfQogICAgICAgICAgICB0aGlzLnJlc2V0KCk7IC8vIFJlc2V0IHRvIElETEUgc3RhdGUgZm9yIHJldXNlCiAgICAgICAgICAgIGJyZWFrOyAvLyBFeGl0IHdoaWxlIGxvb3AKICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgIC8vIEJVRkZFUiBVTkRFUlJVTiAoTEFHKTogUGxheSBzaWxlbmNlIGFuZCB3YWl0IGZvciBtb3JlIGRhdGEuCiAgICAgICAgICAgIHRoaXMuX3NpbGVuY2VGcmFtZXNDb3VudCsrOwogICAgICAgICAgICBpZiAodGhpcy5fbWV0cmljc0VuYWJsZWQpIHRoaXMuX3VuZGVycnVuQmxvY2tzKys7C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gICAgICAgdHJ5IHsKICAgICAgICAgIHRoaXMucG9ydC5wb3N0TWVzc2FnZSh7CiAgICAgICAgICAgIHR5cGU6ICJtZXRyaWNzIiwKICAgICAgICAgICAgZGF0YTogewogICAgICAgICAgICAgIHN0YXRlOiB0aGlzLl9zdGF0ZSwKICAgICAgICAgICAgICBxdWV1ZWRTYW1wbGVzLAogICAgICAgICAgICAgIHF1ZXVlZE1zOiBNYXRoLnJvdW5kKChxdWV1ZWRTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICBtYXhRdWV1ZWRNczogTWF0aC5yb3VuZCgodGhpcy5fbWF4UXVldWVTYW1wbGVzIC8gdGhpcy5fc2FtcGxlUmF0ZSkgKiAxMDAwKSwKICAgICAgICAgICAgICB1bmRlcnJ1bkJsb2NrczogdGhpcy5fdW5kZXJydW5CbG9ja3MsCiAgICAgICAgICAgICAgZnJhbWVzUHJvY2Vzc2VkOiB0aGlzLl9mcmFtZXNQcm9jZXNzZWQKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfSBjYXRjaCAoXykgeyB9CiAgICAgICAgLy8gRG9uJ3QgcmVzZXQgbWF4IHRyYWNrZXIgLSBrZWVwIHNlc3Npb24gcGVhayB1bnRpbCBpZGxlCiAgICAgIH0KICAgIH0KCiAgICAvLyBBTFdBWVMgcmV0dXJuIHRydWUgdG8ga2VlcCB0aGUgcHJvY2Vzc29yIGFsaXZlIGZvciByZXVzZS4KICAgIHJldHVybiB0cnVlOwogIH0KfQoKcmVnaXN0ZXJQcm9jZXNzb3IoInBsYXliYWNrLXdvcmtsZXQiLCBQbGF5YmFja1dvcmtsZXQpOwo=", import.meta.url), Ce = {
2627
+ en: Ke,
2628
+ de: $e,
2629
+ fr: tt,
2630
+ fi: nt,
2631
+ lt: st
2632
+ }, W = new f.Quaternion(), M = new f.Euler(), re = new f.Vector3(), le = new f.Vector3(), He = new f.Box3();
2633
2633
  new f.Matrix4();
2634
2634
  new f.Matrix4();
2635
2635
  new f.Vector3();
2636
2636
  new f.Vector3(0, 0, 1);
2637
- const at = new f.Vector3(1, 0, 0);
2637
+ const rt = new f.Vector3(1, 0, 0);
2638
2638
  new f.Vector3(0, 1, 0);
2639
2639
  new f.Vector3(0, 0, 1);
2640
- class Me {
2640
+ class Ee {
2641
2641
  /**
2642
2642
  * Avatar.
2643
2643
  * @typedef {Object} Avatar
@@ -2763,7 +2763,7 @@ class Me {
2763
2763
  avatarOnlyCamera: null,
2764
2764
  statsNode: null,
2765
2765
  statsStyle: null
2766
- }, Object.assign(this.opt, e || {}), this.opt.statsNode && (this.stats = new Ge(), 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 Ze(), this.opt.statsStyle && (this.stats.dom.style.cssText = this.opt.statsStyle), this.opt.statsNode.appendChild(this.stats.dom)), this.poseTemplates = {
2767
2767
  side: {
2768
2768
  standing: !0,
2769
2769
  props: {
@@ -4062,7 +4062,7 @@ class Me {
4062
4062
  this.opt.lightSpotDispersion
4063
4063
  ), this.setLighting(this.opt);
4064
4064
  const l = new f.PMREMGenerator(this.renderer);
4065
- l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Ve()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ne(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4065
+ l.compileEquirectangularShader(), this.scene.environment = l.fromScene(new Ge()).texture, this.resizeobserver = new ResizeObserver(this.onResize.bind(this)), this.resizeobserver.observe(this.nodeAvatar), this.controls = new Ue(this.camera, this.renderer.domElement), this.controls.enableZoom = this.opt.cameraZoomEnable, this.controls.enableRotate = this.opt.cameraRotateEnable, this.controls.enablePan = this.opt.cameraPanEnable, this.controls.minDistance = 2, this.controls.maxDistance = 2e3, this.controls.autoRotateSpeed = 0, this.controls.autoRotate = !1, this.controls.update(), this.cameraClock = null;
4066
4066
  }
4067
4067
  this.ikMesh = new f.SkinnedMesh();
4068
4068
  const s = {
@@ -4080,14 +4080,14 @@ class Me {
4080
4080
  Object.entries(s).forEach((l, u) => {
4081
4081
  const a = new f.Bone();
4082
4082
  a.name = l[0], l[1] ? this.ikMesh.getObjectByName(l[1]).add(a) : this.ikMesh.add(a), o.push(a);
4083
- }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new je(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4083
+ }), this.ikMesh.bind(new f.Skeleton(o)), this.dynamicbones = new Qe(), this.isStreaming = !1, this.streamWorkletNode = null, this.streamAudioStartTime = null, this.streamWaitForAudioChunks = !0, this.streamLipsyncLang = null, this.streamLipsyncType = "visemes", this.streamLipsyncQueue = [];
4084
4084
  }
4085
4085
  /**
4086
4086
  * Helper that re/creates the audio context and the other nodes.
4087
4087
  * @param {number} sampleRate
4088
4088
  */
4089
4089
  initAudioGraph(t = null) {
4090
- if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new Qe(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4090
+ if (this.audioCtx && this.audioCtx.state !== "closed" && this.audioCtx.close(), t ? this.audioCtx = new AudioContext({ sampleRate: t }) : this.audioCtx = new AudioContext(), this.audioSpeechSource = this.audioCtx.createBufferSource(), this.audioBackgroundSource = this.audioCtx.createBufferSource(), this.audioBackgroundGainNode = this.audioCtx.createGain(), this.audioSpeechGainNode = this.audioCtx.createGain(), this.audioStreamGainNode = this.audioCtx.createGain(), this.audioAnalyzerNode = this.audioCtx.createAnalyser(), this.audioAnalyzerNode.fftSize = 256, this.audioAnalyzerNode.smoothingTimeConstant = 0.1, this.audioAnalyzerNode.minDecibels = -70, this.audioAnalyzerNode.maxDecibels = -10, this.audioAnalyzer = new qe(this.audioCtx), this.audioReverbNode = this.audioCtx.createConvolver(), this.audioBackgroundGainNode.connect(this.audioReverbNode), this.audioAnalyzerNode.connect(this.audioSpeechGainNode), this.audioSpeechGainNode.connect(this.audioReverbNode), this.audioStreamGainNode.connect(this.audioReverbNode), this.audioReverbNode.connect(this.audioCtx.destination), this.setReverb(this.currentReverb || null), this.setMixerGain(
4091
4091
  this.opt.mixerGainSpeech,
4092
4092
  this.opt.mixerGainBackground
4093
4093
  ), this.workletLoaded = !1, this.streamWorkletNode) {
@@ -4228,9 +4228,9 @@ class Me {
4228
4228
  async showAvatar(t, e = null) {
4229
4229
  if (!t || !t.hasOwnProperty("url"))
4230
4230
  throw new Error("Invalid parameter. The avatar must have at least 'url' specified.");
4231
- const i = new Ue();
4231
+ const i = new We();
4232
4232
  if (this.dracoEnabled) {
4233
- const a = new We();
4233
+ const a = new Ve();
4234
4234
  a.setDecoderPath(this.dracoDecoderPath), i.setDRACOLoader(a);
4235
4235
  }
4236
4236
  let n = await i.loadAsync(t.url, e);
@@ -5180,7 +5180,7 @@ class Me {
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) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 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), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (W.setFromAxisAngle(at, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(W)), Ce.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(ae), ae.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(le), le.sub(this.armature.position), this.objectHips.position.y -= Ce.min.y / 2, this.objectHips.position.x -= (ae.x + le.x) / 4, this.objectHips.position.z -= (ae.z + le.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) && (i = this.mtRandomized[Math.floor(Math.random() * this.mtRandomized.length)], n = this.mtAvatar[i], n.needsUpdate || Object.assign(n, { base: (this.mood.baseline[i] || 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), i = this.volumeHeadTarget - this.volumeHeadCurrent, n = Math.abs(i), n > 1e-4 && (o = n * (this.volumeHeadEasing(Math.min(1, this.volumeHeadVelocity * e / 1e3 / n) / 2 + 0.5) - 0.5), this.volumeHeadCurrent += Math.sign(i) * Math.min(n, o)), Math.abs(this.volumeHeadCurrent) > 1e-4 && (W.setFromAxisAngle(rt, this.volumeHeadCurrent), this.objectNeck.quaternion.multiply(W)), He.setFromObject(this.armature), this.objectLeftToeBase.getWorldPosition(re), re.sub(this.armature.position), this.objectRightToeBase.getWorldPosition(le), le.sub(this.armature.position), this.objectHips.position.y -= He.min.y / 2, this.objectHips.position.x -= (re.x + le.x) / 4, this.objectHips.position.z -= (re.z + le.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 Me {
5211
5211
  if (!this.lipsync.hasOwnProperty(t)) {
5212
5212
  const i = t.toLowerCase(), n = "Lipsync" + t.charAt(0).toUpperCase() + t.slice(1);
5213
5213
  try {
5214
- const s = ze[i];
5215
- s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(ze));
5214
+ const s = Ce[i];
5215
+ s && s[n] ? (this.lipsync[t] = new s[n](), console.log(`Loaded lip-sync module for ${t}`)) : console.warn(`Lip-sync module for ${t} not found. Available modules:`, Object.keys(Ce));
5216
5216
  } catch (s) {
5217
5217
  console.warn(`Failed to load lip-sync module for ${t}:`, s);
5218
5218
  }
@@ -5251,10 +5251,10 @@ class Me {
5251
5251
  let h = "", r = "", 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, P = y[x].match(l);
5254
+ const I = x === y.length - 1, E = 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), i && (h += y[x]), P && (!n || n.every((R) => x < R[0] || x > R[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
5257
+ if (p && !I && !H && y[x + 1].match(s) && (p = !1), i && (h += y[x]), E && (!n || n.every((v) => x < v[0] || x > v[1])) && (r += y[x]), (z || p || I) && (r.length && (r = this.lipsyncPreProcessText(r, a), r.length && d.push({
5258
5258
  mark: c,
5259
5259
  word: r
5260
5260
  })), h.length && (g.push({
@@ -5265,16 +5265,16 @@ class Me {
5265
5265
  subtitles: [h]
5266
5266
  }
5267
5267
  }), h = ""), r.length)) {
5268
- const R = this.lipsyncWordsToVisemes(r, a);
5269
- if (R && R.visemes && R.visemes.length) {
5270
- const D = R.times[R.visemes.length - 1] + R.durations[R.visemes.length - 1];
5271
- for (let N = 0; N < R.visemes.length; N++)
5268
+ const v = this.lipsyncWordsToVisemes(r, a);
5269
+ if (v && v.visemes && v.visemes.length) {
5270
+ const N = v.times[v.visemes.length - 1] + v.durations[v.visemes.length - 1];
5271
+ for (let D = 0; D < v.visemes.length; D++)
5272
5272
  g.push({
5273
5273
  mark: c,
5274
5274
  template: { name: "viseme" },
5275
- ts: [(R.times[N] - 0.6) / D, (R.times[N] + 0.5) / D, (R.times[N] + R.durations[N] + 0.5) / D],
5275
+ ts: [(v.times[D] - 0.6) / N, (v.times[D] + 0.5) / N, (v.times[D] + v.durations[D] + 0.5) / N],
5276
5276
  vs: {
5277
- ["viseme_" + R.visemes[N]]: [null, R.visemes[N] === "PP" || R.visemes[N] === "FF" ? 0.9 : 0.6, 0]
5277
+ ["viseme_" + v.visemes[D]]: [null, v.visemes[D] === "PP" || v.visemes[D] === "FF" ? 0.9 : 0.6, 0]
5278
5278
  }
5279
5279
  });
5280
5280
  }
@@ -5282,14 +5282,14 @@ class Me {
5282
5282
  }
5283
5283
  if (p || I) {
5284
5284
  if (d.length || I && g.length) {
5285
- const R = {
5285
+ const v = {
5286
5286
  anim: g
5287
5287
  };
5288
- i && (R.onSubtitles = i), d.length && !e.avatarMute && (R.text = d, e.avatarMood && (R.mood = e.avatarMood), e.ttsLang && (R.lang = e.ttsLang), e.ttsVoice && (R.voice = e.ttsVoice), e.ttsRate && (R.rate = e.ttsRate), e.ttsVoice && (R.pitch = e.ttsPitch), e.ttsVolume && (R.volume = e.ttsVolume)), this.speechQueue.push(R), d = [], r = "", c = 0, g = [];
5288
+ i && (v.onSubtitles = i), d.length && !e.avatarMute && (v.text = d, e.avatarMood && (v.mood = e.avatarMood), e.ttsLang && (v.lang = e.ttsLang), e.ttsVoice && (v.voice = e.ttsVoice), e.ttsRate && (v.rate = e.ttsRate), e.ttsVoice && (v.pitch = e.ttsPitch), e.ttsVolume && (v.volume = e.ttsVolume)), this.speechQueue.push(v), d = [], r = "", 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 v = this.animEmojis[y[x]];
5292
+ v && v.link && (v = this.animEmojis[v.link]), v && this.speechQueue.push({ emoji: v });
5293
5293
  }
5294
5294
  this.speechQueue.push({ break: 100 });
5295
5295
  }
@@ -5385,10 +5385,10 @@ class Me {
5385
5385
  let y = 0.6 + this.convertRange(g, [0, h], [0, 0.4]);
5386
5386
  if (h = Math.min(h, c.visemes.length * 200), d > 0)
5387
5387
  for (let x = 0; x < c.visemes.length; x++) {
5388
- const I = a + c.times[x] / d * h, P = c.durations[x] / d * h;
5388
+ const I = a + c.times[x] / d * h, E = c.durations[x] / d * h;
5389
5389
  o.push({
5390
5390
  template: { name: "viseme" },
5391
- ts: [I - Math.min(60, 2 * P / 3), I + Math.min(25, P / 2), I + P + Math.min(60, P / 2)],
5391
+ ts: [I - Math.min(60, 2 * E / 3), I + Math.min(25, E / 2), I + E + Math.min(60, E / 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
  }
@@ -5486,18 +5486,18 @@ class Me {
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, D = x.durations[H] / p, N = R * c, _ = D * c;
5489
+ const z = x.visemes[H], v = x.times[H] / p, N = x.durations[H] / p, D = v * c, J = N * c;
5490
5490
  I.push({
5491
5491
  template: { name: "viseme" },
5492
- ts: [N - Math.min(60, 2 * _ / 3), N + Math.min(25, _ / 2), N + _ + Math.min(60, _ / 2)],
5492
+ ts: [D - Math.min(60, 2 * J / 3), D + Math.min(25, J / 2), D + J + Math.min(60, J / 2)],
5493
5493
  vs: {
5494
5494
  ["viseme_" + z]: [null, z === "PP" || z === "FF" ? 0.9 : 0.6, 0]
5495
5495
  }
5496
5496
  });
5497
5497
  }
5498
5498
  }
5499
- const P = [...t.anim, ...I];
5500
- this.audioPlaylist.push({ anim: P, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5499
+ const E = [...t.anim, ...I];
5500
+ this.audioPlaylist.push({ anim: E, audio: d }), this.onSubtitles = t.onSubtitles || null, this.resetLips(), t.mood && this.setMood(t.mood), this.playAudio(), s.onend = () => {
5501
5501
  e();
5502
5502
  }, s.onerror = (p) => {
5503
5503
  console.error("Speech synthesis error:", p.error), i(p.error);
@@ -5895,7 +5895,7 @@ class Me {
5895
5895
  }
5896
5896
  if (!this.workletLoaded)
5897
5897
  try {
5898
- const l = this.audioCtx.audioWorklet.addModule(st.href), u = new Promise(
5898
+ const l = this.audioCtx.audioWorklet.addModule(at.href), u = new Promise(
5899
5899
  (a, h) => setTimeout(() => h(new Error("Worklet loading timed out")), 5e3)
5900
5900
  );
5901
5901
  await Promise.race([l, u]), this.workletLoaded = !0;
@@ -6133,7 +6133,7 @@ class Me {
6133
6133
  */
6134
6134
  lookAtCamera(t) {
6135
6135
  let e;
6136
- if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), ae.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), le.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(ae, le).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6136
+ if (this.speakTo && (e = new f.Vector3(), this.speakTo.objectLeftEye?.isObject3D ? (this.speakTo.armature.objectHead, this.speakTo.objectLeftEye.updateMatrixWorld(!0), this.speakTo.objectRightEye.updateMatrixWorld(!0), re.setFromMatrixPosition(this.speakTo.objectLeftEye.matrixWorld), le.setFromMatrixPosition(this.speakTo.objectRightEye.matrixWorld), e.addVectors(re, le).divideScalar(2)) : this.speakTo.isObject3D ? this.speakTo.getWorldPosition(e) : this.speakTo.isVector3 ? e.set(this.speakTo) : this.speakTo.x && this.speakTo.y && this.speakTo.z && e.set(this.speakTo.x, this.speakTo.y, this.speakTo.z)), !e) {
6137
6137
  if (this.avatar.hasOwnProperty("avatarIgnoreCamera")) {
6138
6138
  if (this.avatar.avatarIgnoreCamera) {
6139
6139
  this.lookAhead(t);
@@ -6146,8 +6146,8 @@ class Me {
6146
6146
  this.lookAt(null, null, t);
6147
6147
  return;
6148
6148
  }
6149
- this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), ae.setFromMatrixPosition(this.objectLeftEye.matrixWorld), le.setFromMatrixPosition(this.objectRightEye.matrixWorld), ae.add(le).divideScalar(2), W.copy(this.armature.quaternion), W.multiply(this.poseTarget.props["Hips.quaternion"]), W.multiply(this.poseTarget.props["Spine.quaternion"]), W.multiply(this.poseTarget.props["Spine1.quaternion"]), W.multiply(this.poseTarget.props["Spine2.quaternion"]), W.multiply(this.poseTarget.props["Neck.quaternion"]), W.multiply(this.poseTarget.props["Head.quaternion"]);
6150
- const i = new f.Vector3().subVectors(e, ae).normalize(), n = Math.atan2(i.x, i.z), s = Math.asin(-i.y);
6149
+ this.objectLeftEye.updateMatrixWorld(!0), this.objectRightEye.updateMatrixWorld(!0), re.setFromMatrixPosition(this.objectLeftEye.matrixWorld), le.setFromMatrixPosition(this.objectRightEye.matrixWorld), re.add(le).divideScalar(2), W.copy(this.armature.quaternion), W.multiply(this.poseTarget.props["Hips.quaternion"]), W.multiply(this.poseTarget.props["Spine.quaternion"]), W.multiply(this.poseTarget.props["Spine1.quaternion"]), W.multiply(this.poseTarget.props["Spine2.quaternion"]), W.multiply(this.poseTarget.props["Neck.quaternion"]), W.multiply(this.poseTarget.props["Head.quaternion"]);
6150
+ const i = new f.Vector3().subVectors(e, re).normalize(), n = Math.atan2(i.x, i.z), s = Math.asin(-i.y);
6151
6151
  M.set(s, n, 0, "YXZ");
6152
6152
  const l = new f.Quaternion().setFromEuler(M), u = new f.Quaternion().copy(l).multiply(W.clone().invert());
6153
6153
  M.setFromQuaternion(u, "YXZ");
@@ -6189,17 +6189,17 @@ class Me {
6189
6189
  t === null && (t = u), e === null && (e = a), W.copy(this.armature.quaternion), W.multiply(this.poseTarget.props["Hips.quaternion"]), W.multiply(this.poseTarget.props["Spine.quaternion"]), W.multiply(this.poseTarget.props["Spine1.quaternion"]), W.multiply(this.poseTarget.props["Spine2.quaternion"]), W.multiply(this.poseTarget.props["Neck.quaternion"]), W.multiply(this.poseTarget.props["Head.quaternion"]), M.setFromQuaternion(W);
6190
6190
  let h = M.x / (40 / 24), r = M.y / (9 / 4), c = Math.min(0.4, Math.max(-0.4, this.camera.rotation.x)), d = Math.min(0.4, Math.max(-0.4, this.camera.rotation.y)), g = Math.max(window.innerWidth - u, u), y = Math.max(window.innerHeight - a, a), x = this.convertRange(e, [a - y, a + y], [-0.3, 0.6]) - h + c, I = this.convertRange(t, [u - g, u + g], [-0.8, 0.8]) - r + d;
6191
6191
  x = Math.min(0.6, Math.max(-0.3, x)), I = Math.min(0.8, Math.max(-0.8, I));
6192
- let P = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6192
+ let E = (Math.random() - 0.5) / 4, p = (Math.random() - 0.5) / 4;
6193
6193
  if (i) {
6194
- let H = this.animQueue.findIndex((R) => R.template.name === "lookat");
6194
+ let H = this.animQueue.findIndex((v) => v.template.name === "lookat");
6195
6195
  H !== -1 && this.animQueue.splice(H, 1);
6196
6196
  const z = {
6197
6197
  name: "lookat",
6198
6198
  dt: [750, i],
6199
6199
  vs: {
6200
- bodyRotateX: [x + P],
6200
+ bodyRotateX: [x + E],
6201
6201
  bodyRotateY: [I + p],
6202
- eyesRotateX: [-3 * P + 0.1],
6202
+ eyesRotateX: [-3 * E + 0.1],
6203
6203
  eyesRotateY: [-5 * p],
6204
6204
  browInnerUp: [[0, 0.7]],
6205
6205
  mouthLeft: [[0, 0.7]],
@@ -6403,7 +6403,7 @@ class Me {
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 ke();
6406
+ const h = new we();
6407
6407
  let r;
6408
6408
  try {
6409
6409
  r = await h.loadAsync(t, e);
@@ -6480,7 +6480,7 @@ class Me {
6480
6480
  let l = this.animQueue.find((u) => u.template.name === "pose");
6481
6481
  l && (l.ts[0] = this.animClock + i * 1e3 + 2e3), this.setPoseFromTemplate(o);
6482
6482
  } else {
6483
- let u = await new ke().loadAsync(t, e);
6483
+ let u = await new we().loadAsync(t, e);
6484
6484
  if (u && u.animations && u.animations[n]) {
6485
6485
  let a = u.animations[n];
6486
6486
  const h = {};
@@ -6577,12 +6577,12 @@ class Me {
6577
6577
  const x = t.iterations || 10;
6578
6578
  if (e)
6579
6579
  for (let I = 0; I < x; I++) {
6580
- let P = !1;
6580
+ let E = !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, a, h), a.invert(), o.setFromMatrixPosition(g.matrixWorld), l.subVectors(o, u), l.applyQuaternion(a), l.normalize(), s.subVectors(e, u), s.applyQuaternion(a), s.normalize();
6584
- let R = s.dot(l);
6585
- R > 1 ? R = 1 : R < -1 && (R = -1), R = Math.acos(R), !(R < 1e-5) && (y[p].minAngle !== void 0 && R < y[p].minAngle && (R = y[p].minAngle), y[p].maxAngle !== void 0 && R > y[p].maxAngle && (R = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), W.setFromAxisAngle(r, R), z.quaternion.multiply(W), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6584
+ let v = s.dot(l);
6585
+ v > 1 ? v = 1 : v < -1 && (v = -1), v = Math.acos(v), !(v < 1e-5) && (y[p].minAngle !== void 0 && v < y[p].minAngle && (v = y[p].minAngle), y[p].maxAngle !== void 0 && v > y[p].maxAngle && (v = y[p].maxAngle), r.crossVectors(l, s), r.normalize(), W.setFromAxisAngle(r, v), z.quaternion.multiply(W), z.rotation.setFromVector3(c.setFromEuler(z.rotation).clamp(new f.Vector3(
6586
6586
  y[p].minx !== void 0 ? y[p].minx : -1 / 0,
6587
6587
  y[p].miny !== void 0 ? y[p].miny : -1 / 0,
6588
6588
  y[p].minz !== void 0 ? y[p].minz : -1 / 0
@@ -6590,9 +6590,9 @@ class Me {
6590
6590
  y[p].maxx !== void 0 ? y[p].maxx : 1 / 0,
6591
6591
  y[p].maxy !== void 0 ? y[p].maxy : 1 / 0,
6592
6592
  y[p].maxz !== void 0 ? y[p].maxz : 1 / 0
6593
- ))), z.updateMatrixWorld(!0), P = !0);
6593
+ ))), z.updateMatrixWorld(!0), E = !0);
6594
6594
  }
6595
- if (!P) break;
6595
+ if (!E) break;
6596
6596
  }
6597
6597
  n && y.forEach((I) => {
6598
6598
  this.poseTarget.props[I.link + ".quaternion"].copy(I.bone.quaternion), this.poseTarget.props[I.link + ".quaternion"].t = this.animClock, this.poseTarget.props[I.link + ".quaternion"].d = n;
@@ -6625,7 +6625,7 @@ const me = {
6625
6625
  josh: "VR6AewLTigWG4xSOukaG"
6626
6626
  // Male, American
6627
6627
  }
6628
- }, He = {
6628
+ }, Te = {
6629
6629
  defaultVoice: "aura-2-thalia-en",
6630
6630
  // Thalia (Female, English)
6631
6631
  voices: {
@@ -6645,7 +6645,7 @@ const me = {
6645
6645
  // Male, English - Powerful
6646
6646
  }
6647
6647
  };
6648
- function Le() {
6648
+ function Ae() {
6649
6649
  return {
6650
6650
  service: "elevenlabs",
6651
6651
  endpoint: me.endpoint,
@@ -6654,8 +6654,8 @@ function Le() {
6654
6654
  voices: me.voices
6655
6655
  };
6656
6656
  }
6657
- function xt() {
6658
- const O = Le(), t = [];
6657
+ function bt() {
6658
+ const O = Ae(), t = [];
6659
6659
  return Object.entries(O.voices).forEach(([e, i]) => {
6660
6660
  t.push({
6661
6661
  value: i,
@@ -6663,7 +6663,7 @@ function xt() {
6663
6663
  });
6664
6664
  }), t;
6665
6665
  }
6666
- const Ee = Re(({
6666
+ const Fe = Ie(({
6667
6667
  avatarUrl: O = "/avatars/brunette.glb",
6668
6668
  avatarBody: t = "F",
6669
6669
  mood: e = "neutral",
@@ -6685,199 +6685,199 @@ const Ee = Re(({
6685
6685
  style: y = {},
6686
6686
  animations: x = {}
6687
6687
  }, I) => {
6688
- const P = Z(null), p = Z(null), H = Z(a), z = Z(null), [R, D] = ce(!0), [N, _] = ce(null), [ne, S] = ce(!1), [U, V] = ce(!1);
6688
+ const E = X(null), p = X(null), H = X(a), z = X(null), v = X(null), [N, D] = ue(!0), [J, ae] = ue(null), [S, G] = ue(!1), [B, U] = ue(!1);
6689
6689
  pe(() => {
6690
6690
  H.current = a;
6691
6691
  }, [a]);
6692
- const E = Le(), X = n || E.service;
6693
- let Y;
6694
- X === "browser" ? Y = {
6692
+ const Z = Ae(), _ = n || Z.service;
6693
+ let ne;
6694
+ _ === "browser" ? ne = {
6695
6695
  service: "browser",
6696
6696
  endpoint: "",
6697
6697
  apiKey: null,
6698
6698
  defaultVoice: "Google US English"
6699
- } : X === "elevenlabs" ? Y = {
6699
+ } : _ === "elevenlabs" ? ne = {
6700
6700
  service: "elevenlabs",
6701
6701
  endpoint: "https://api.elevenlabs.io/v1/text-to-speech",
6702
- apiKey: o || E.apiKey,
6703
- defaultVoice: s || E.defaultVoice || me.defaultVoice,
6704
- voices: E.voices || me.voices
6705
- } : X === "deepgram" ? Y = {
6702
+ apiKey: o || Z.apiKey,
6703
+ defaultVoice: s || Z.defaultVoice || me.defaultVoice,
6704
+ voices: Z.voices || me.voices
6705
+ } : _ === "deepgram" ? ne = {
6706
6706
  service: "deepgram",
6707
6707
  endpoint: "https://api.deepgram.com/v1/speak",
6708
- apiKey: o || E.apiKey,
6709
- defaultVoice: s || E.defaultVoice || He.defaultVoice,
6710
- voices: E.voices || He.voices
6711
- } : Y = {
6712
- ...E,
6708
+ apiKey: o || Z.apiKey,
6709
+ defaultVoice: s || Z.defaultVoice || Te.defaultVoice,
6710
+ voices: Z.voices || Te.voices
6711
+ } : ne = {
6712
+ ...Z,
6713
6713
  // Override API key if provided via props
6714
- apiKey: o !== null ? o : E.apiKey
6714
+ apiKey: o !== null ? o : Z.apiKey
6715
6715
  };
6716
- const ue = {
6716
+ const ce = {
6717
6717
  url: O,
6718
6718
  body: t,
6719
6719
  avatarMood: e,
6720
- ttsLang: X === "browser" ? "en-US" : i,
6721
- ttsVoice: s || Y.defaultVoice,
6720
+ ttsLang: _ === "browser" ? "en-US" : i,
6721
+ ttsVoice: s || ne.defaultVoice,
6722
6722
  lipsyncLang: "en",
6723
6723
  showFullAvatar: a,
6724
6724
  bodyMovement: l,
6725
6725
  movementIntensity: u
6726
- }, ve = {
6727
- ttsEndpoint: Y.endpoint,
6728
- ttsApikey: Y.apiKey,
6729
- ttsService: X,
6726
+ }, fe = {
6727
+ ttsEndpoint: ne.endpoint,
6728
+ ttsApikey: ne.apiKey,
6729
+ ttsService: _,
6730
6730
  lipsyncModules: ["en"],
6731
6731
  cameraView: h
6732
- }, ge = T(async () => {
6733
- if (!(!P.current || p.current))
6732
+ }, xe = T(async () => {
6733
+ if (!(!E.current || p.current))
6734
6734
  try {
6735
- if (D(!0), _(null), p.current = new Me(P.current, ve), 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(ue, (j) => {
6735
+ if (D(!0), ae(null), p.current = new Ee(E.current, fe), 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(ce, (j) => {
6736
6736
  if (j.lengthComputable) {
6737
- const B = Math.min(100, Math.round(j.loaded / j.total * 100));
6738
- c(B);
6737
+ const F = Math.min(100, Math.round(j.loaded / j.total * 100));
6738
+ c(F);
6739
6739
  }
6740
6740
  }), await new Promise((j) => {
6741
- const B = () => {
6742
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? j() : setTimeout(B, 100);
6741
+ const F = () => {
6742
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? j() : setTimeout(F, 100);
6743
6743
  };
6744
- B();
6744
+ F();
6745
6745
  }), p.current && p.current.setShowFullAvatar)
6746
6746
  try {
6747
6747
  p.current.setShowFullAvatar(a);
6748
6748
  } catch (j) {
6749
6749
  console.warn("Error setting full body mode on initialization:", j);
6750
6750
  }
6751
- 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()), D(!1), S(!0), r(p.current);
6752
- const F = () => {
6751
+ 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()), D(!1), G(!0), r(p.current);
6752
+ const P = () => {
6753
6753
  document.visibilityState === "visible" ? p.current?.start() : p.current?.stop();
6754
6754
  };
6755
- return document.addEventListener("visibilitychange", F), () => {
6756
- document.removeEventListener("visibilitychange", F);
6755
+ return document.addEventListener("visibilitychange", P), () => {
6756
+ document.removeEventListener("visibilitychange", P);
6757
6757
  };
6758
6758
  } catch (A) {
6759
- console.error("Error initializing TalkingHead:", A), _(A.message || "Failed to initialize avatar"), D(!1), d(A);
6759
+ console.error("Error initializing TalkingHead:", A), ae(A.message || "Failed to initialize avatar"), D(!1), d(A);
6760
6760
  }
6761
6761
  }, [O, t, e, i, n, s, o, a, l, u, h]);
6762
- pe(() => (ge(), () => {
6762
+ pe(() => (xe(), () => {
6763
6763
  p.current && (p.current.stop(), p.current.dispose(), p.current = null);
6764
- }), [ge]), pe(() => {
6765
- if (!P.current || !p.current) return;
6764
+ }), [xe]), pe(() => {
6765
+ if (!E.current || !p.current) return;
6766
6766
  const A = new ResizeObserver((j) => {
6767
- for (const B of j)
6767
+ for (const F of j)
6768
6768
  p.current && p.current.onResize && p.current.onResize();
6769
6769
  });
6770
- A.observe(P.current);
6771
- const F = () => {
6770
+ A.observe(E.current);
6771
+ const P = () => {
6772
6772
  p.current && p.current.onResize && p.current.onResize();
6773
6773
  };
6774
- return window.addEventListener("resize", F), () => {
6775
- A.disconnect(), window.removeEventListener("resize", F);
6774
+ return window.addEventListener("resize", P), () => {
6775
+ A.disconnect(), window.removeEventListener("resize", P);
6776
6776
  };
6777
- }, [ne]);
6778
- const re = T(async () => {
6777
+ }, [S]);
6778
+ const Y = T(async () => {
6779
6779
  if (p.current && p.current.audioCtx)
6780
6780
  try {
6781
6781
  (p.current.audioCtx.state === "suspended" || p.current.audioCtx.state === "interrupted") && (await p.current.audioCtx.resume(), console.log("Audio context resumed"));
6782
6782
  } catch (A) {
6783
6783
  console.warn("Failed to resume audio context:", A);
6784
6784
  }
6785
- }, []), J = T(async (A, F = {}) => {
6786
- if (p.current && ne)
6785
+ }, []), b = T(async (A, P = {}) => {
6786
+ if (p.current && S)
6787
6787
  try {
6788
- z.current = { text: A, options: F }, V(!1), await re();
6788
+ v.current && (clearInterval(v.current), v.current = null), z.current = { text: A, options: P }, U(!1), await Y();
6789
6789
  const j = {
6790
- ...F,
6791
- lipsyncLang: F.lipsyncLang || ue.lipsyncLang || "en"
6790
+ ...P,
6791
+ lipsyncLang: P.lipsyncLang || ce.lipsyncLang || "en"
6792
6792
  };
6793
- if (F.onSpeechEnd && p.current) {
6794
- const B = p.current;
6795
- let ee = null, de = 0;
6796
- const Ae = 1200;
6793
+ if (P.onSpeechEnd && p.current) {
6794
+ const F = p.current;
6795
+ let $ = null, de = 0;
6796
+ const Se = 1200;
6797
6797
  let ye = !1;
6798
- ee = setInterval(() => {
6799
- if (de++, de > Ae) {
6800
- if (ee && (clearInterval(ee), ee = null), !ye) {
6798
+ $ = setInterval(() => {
6799
+ if (de++, B)
6800
+ return;
6801
+ if (de > Se) {
6802
+ if ($ && (clearInterval($), $ = null, v.current = null), !ye && !B) {
6801
6803
  ye = !0;
6802
6804
  try {
6803
- F.onSpeechEnd();
6804
- } catch (Se) {
6805
- console.error("Error in onSpeechEnd callback (timeout):", Se);
6805
+ P.onSpeechEnd();
6806
+ } catch (ke) {
6807
+ console.error("Error in onSpeechEnd callback (timeout):", ke);
6806
6808
  }
6807
6809
  }
6808
6810
  return;
6809
6811
  }
6810
- const Pe = !B.speechQueue || B.speechQueue.length === 0, Be = !B.audioPlaylist || B.audioPlaylist.length === 0;
6811
- B && B.isSpeaking === !1 && Pe && Be && B.isAudioPlaying === !1 && !ye && setTimeout(() => {
6812
- if (B && B.isSpeaking === !1 && (!B.speechQueue || B.speechQueue.length === 0) && (!B.audioPlaylist || B.audioPlaylist.length === 0) && B.isAudioPlaying === !1 && !ye) {
6813
- ye = !0, ee && (clearInterval(ee), ee = null);
6812
+ const Be = !F.speechQueue || F.speechQueue.length === 0, De = !F.audioPlaylist || F.audioPlaylist.length === 0;
6813
+ F && F.isSpeaking === !1 && Be && De && F.isAudioPlaying === !1 && !ye && !B && setTimeout(() => {
6814
+ if (F && !B && F.isSpeaking === !1 && (!F.speechQueue || F.speechQueue.length === 0) && (!F.audioPlaylist || F.audioPlaylist.length === 0) && F.isAudioPlaying === !1 && !ye && !B) {
6815
+ ye = !0, $ && (clearInterval($), $ = null, v.current = null);
6814
6816
  try {
6815
- F.onSpeechEnd();
6816
- } catch (De) {
6817
- console.error("Error in onSpeechEnd callback:", De);
6817
+ P.onSpeechEnd();
6818
+ } catch (Oe) {
6819
+ console.error("Error in onSpeechEnd callback:", Oe);
6818
6820
  }
6819
6821
  }
6820
6822
  }, 100);
6821
- }, 100);
6823
+ }, 100), v.current = $;
6822
6824
  }
6823
6825
  p.current.lipsync && Object.keys(p.current.lipsync).length > 0 ? (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A, j)) : setTimeout(async () => {
6824
- await re(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A, j));
6826
+ await Y(), p.current && p.current.lipsync && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A, j));
6825
6827
  }, 100);
6826
6828
  } catch (j) {
6827
- console.error("Error speaking text:", j), _(j.message || "Failed to speak text");
6829
+ console.error("Error speaking text:", j), ae(j.message || "Failed to speak text");
6828
6830
  }
6829
- }, [ne, re, ue.lipsyncLang]), b = T(() => {
6830
- p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, V(!1));
6831
- }, []), v = T(() => {
6831
+ }, [S, Y, ce.lipsyncLang]), R = T(() => {
6832
+ p.current && (p.current.stopSpeaking(), p.current.setSlowdownRate && p.current.setSlowdownRate(1), z.current = null, U(!1));
6833
+ }, []), w = T(() => {
6832
6834
  if (p.current && p.current.pauseSpeaking) {
6833
- const A = p.current, F = A.isSpeaking || A.audioPlaylist && A.audioPlaylist.length > 0 || A.speechQueue && A.speechQueue.length > 0;
6834
- (F && z.current && z.current.text || F) && (p.current.pauseSpeaking(), V(!0));
6835
+ const A = p.current;
6836
+ (A.isSpeaking || A.audioPlaylist && A.audioPlaylist.length > 0 || A.speechQueue && A.speechQueue.length > 0) && (v.current && (clearInterval(v.current), v.current = null), A.speechQueue && (A.speechQueue.length = 0), p.current.pauseSpeaking(), U(!0));
6835
6837
  }
6836
- }, []), w = T(async () => {
6837
- if (p.current && U)
6838
- if (V(!1), await re(), z.current && z.current.text) {
6839
- const A = z.current;
6840
- z.current = null;
6841
- const F = {
6842
- ...A.options,
6843
- lipsyncLang: A.options.lipsyncLang || ue.lipsyncLang || "en"
6844
- };
6845
- p.current.lipsync && Object.keys(p.current.lipsync).length > 0 && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), p.current.speakText(A.text, F));
6846
- } else
6847
- z.current = null;
6848
- }, [re, U]), C = T((A) => {
6838
+ }, []), C = T(async () => {
6839
+ if (p.current && B && z.current && z.current.text) {
6840
+ const A = z.current, P = A.options || {};
6841
+ U(!1), await Y();
6842
+ const j = {
6843
+ ...P,
6844
+ lipsyncLang: P.lipsyncLang || ce.lipsyncLang || "en"
6845
+ };
6846
+ p.current.lipsync && Object.keys(p.current.lipsync).length > 0 && (p.current.setSlowdownRate && p.current.setSlowdownRate(1.05), await b(A.text, j));
6847
+ }
6848
+ }, [Y, B, b]), V = T((A) => {
6849
6849
  p.current && p.current.setMood(A);
6850
- }, []), G = T((A) => {
6850
+ }, []), te = T((A) => {
6851
6851
  p.current && p.current.setSlowdownRate && p.current.setSlowdownRate(A);
6852
- }, []), te = T((A, F = !1) => {
6852
+ }, []), ie = T((A, P = !1) => {
6853
6853
  if (p.current && p.current.playAnimation) {
6854
6854
  if (x && x[A] && (A = x[A]), p.current.setShowFullAvatar)
6855
6855
  try {
6856
6856
  p.current.setShowFullAvatar(H.current);
6857
- } catch (B) {
6858
- console.warn("Error setting full body mode:", B);
6857
+ } catch (F) {
6858
+ console.warn("Error setting full body mode:", F);
6859
6859
  }
6860
6860
  if (A.includes("."))
6861
6861
  try {
6862
- p.current.playAnimation(A, null, 10, 0, 0.01, F);
6863
- } catch (B) {
6864
- console.warn(`Failed to play ${A}:`, B);
6862
+ p.current.playAnimation(A, null, 10, 0, 0.01, P);
6863
+ } catch (F) {
6864
+ console.warn(`Failed to play ${A}:`, F);
6865
6865
  try {
6866
6866
  p.current.setBodyMovement("idle");
6867
- } catch (ee) {
6868
- console.warn("Fallback animation also failed:", ee);
6867
+ } catch ($) {
6868
+ console.warn("Fallback animation also failed:", $);
6869
6869
  }
6870
6870
  }
6871
6871
  else {
6872
- const B = [".fbx", ".glb", ".gltf"];
6873
- let ee = !1;
6874
- for (const de of B)
6872
+ const F = [".fbx", ".glb", ".gltf"];
6873
+ let $ = !1;
6874
+ for (const de of F)
6875
6875
  try {
6876
- p.current.playAnimation(A + de, null, 10, 0, 0.01, F), ee = !0;
6876
+ p.current.playAnimation(A + de, null, 10, 0, 0.01, P), $ = !0;
6877
6877
  break;
6878
6878
  } catch {
6879
6879
  }
6880
- if (!ee) {
6880
+ if (!$) {
6881
6881
  console.warn("Animation not found:", A);
6882
6882
  try {
6883
6883
  p.current.setBodyMovement("idle");
@@ -6887,28 +6887,28 @@ const Ee = Re(({
6887
6887
  }
6888
6888
  }
6889
6889
  }
6890
- }, [x]), ie = T(() => {
6890
+ }, [x]), ge = T(() => {
6891
6891
  p.current && p.current.onResize && p.current.onResize();
6892
6892
  }, []);
6893
- return Ie(I, () => ({
6894
- speakText: J,
6895
- stopSpeaking: b,
6896
- pauseSpeaking: v,
6897
- resumeSpeaking: w,
6898
- resumeAudioContext: re,
6899
- setMood: C,
6900
- setTimingAdjustment: G,
6901
- playAnimation: te,
6902
- isReady: ne,
6903
- isPaused: U,
6893
+ return Le(I, () => ({
6894
+ speakText: b,
6895
+ stopSpeaking: R,
6896
+ pauseSpeaking: w,
6897
+ resumeSpeaking: C,
6898
+ resumeAudioContext: Y,
6899
+ setMood: V,
6900
+ setTimingAdjustment: te,
6901
+ playAnimation: ie,
6902
+ isReady: S,
6903
+ isPaused: B,
6904
6904
  talkingHead: p.current,
6905
- handleResize: ie,
6905
+ handleResize: ge,
6906
6906
  setBodyMovement: (A) => {
6907
6907
  if (p.current && p.current.setShowFullAvatar && p.current.setBodyMovement)
6908
6908
  try {
6909
6909
  p.current.setShowFullAvatar(H.current), p.current.setBodyMovement(A);
6910
- } catch (F) {
6911
- console.warn("Error setting body movement:", F);
6910
+ } catch (P) {
6911
+ console.warn("Error setting body movement:", P);
6912
6912
  }
6913
6913
  },
6914
6914
  setMovementIntensity: (A) => p.current?.setMovementIntensity(A),
@@ -6924,8 +6924,8 @@ const Ee = Re(({
6924
6924
  if (p.current && p.current.setShowFullAvatar && p.current.playReaction)
6925
6925
  try {
6926
6926
  p.current.setShowFullAvatar(H.current), p.current.playReaction(A);
6927
- } catch (F) {
6928
- console.warn("Error playing reaction:", F);
6927
+ } catch (P) {
6928
+ console.warn("Error playing reaction:", P);
6929
6929
  }
6930
6930
  },
6931
6931
  playCelebration: () => {
@@ -6940,8 +6940,8 @@ const Ee = Re(({
6940
6940
  if (p.current && p.current.setShowFullAvatar)
6941
6941
  try {
6942
6942
  H.current = A, p.current.setShowFullAvatar(A);
6943
- } catch (F) {
6944
- console.warn("Error setting showFullAvatar:", F);
6943
+ } catch (P) {
6944
+ console.warn("Error setting showFullAvatar:", P);
6945
6945
  }
6946
6946
  },
6947
6947
  lockAvatarPosition: () => {
@@ -6960,7 +6960,7 @@ const Ee = Re(({
6960
6960
  console.warn("Error unlocking avatar position:", A);
6961
6961
  }
6962
6962
  }
6963
- })), /* @__PURE__ */ Te(
6963
+ })), /* @__PURE__ */ Me(
6964
6964
  "div",
6965
6965
  {
6966
6966
  className: `talking-head-avatar ${g}`,
@@ -6974,7 +6974,7 @@ const Ee = Re(({
6974
6974
  /* @__PURE__ */ he(
6975
6975
  "div",
6976
6976
  {
6977
- ref: P,
6977
+ ref: E,
6978
6978
  className: "talking-head-viewer",
6979
6979
  style: {
6980
6980
  width: "100%",
@@ -6983,7 +6983,7 @@ const Ee = Re(({
6983
6983
  }
6984
6984
  }
6985
6985
  ),
6986
- R && /* @__PURE__ */ he("div", { className: "loading-overlay", style: {
6986
+ N && /* @__PURE__ */ he("div", { className: "loading-overlay", style: {
6987
6987
  position: "absolute",
6988
6988
  top: "50%",
6989
6989
  left: "50%",
@@ -6992,7 +6992,7 @@ const Ee = Re(({
6992
6992
  fontSize: "18px",
6993
6993
  zIndex: 10
6994
6994
  }, children: "Loading avatar..." }),
6995
- N && /* @__PURE__ */ he("div", { className: "error-overlay", style: {
6995
+ J && /* @__PURE__ */ he("div", { className: "error-overlay", style: {
6996
6996
  position: "absolute",
6997
6997
  top: "50%",
6998
6998
  left: "50%",
@@ -7003,13 +7003,13 @@ const Ee = Re(({
7003
7003
  zIndex: 10,
7004
7004
  padding: "20px",
7005
7005
  borderRadius: "8px"
7006
- }, children: N })
7006
+ }, children: J })
7007
7007
  ]
7008
7008
  }
7009
7009
  );
7010
7010
  });
7011
- Ee.displayName = "TalkingHeadAvatar";
7012
- const rt = Re(({
7011
+ Fe.displayName = "TalkingHeadAvatar";
7012
+ const lt = Ie(({
7013
7013
  text: O = "Hello! I'm a talking avatar. How are you today?",
7014
7014
  onLoading: t = () => {
7015
7015
  },
@@ -7021,7 +7021,7 @@ const rt = Re(({
7021
7021
  style: s = {},
7022
7022
  avatarConfig: o = {}
7023
7023
  }, l) => {
7024
- const u = Z(null), a = Z(null), [h, r] = ce(!0), [c, d] = ce(null), [g, y] = ce(!1), x = Le(), I = o.ttsService || x.service, P = I === "browser" ? {
7024
+ const u = X(null), a = X(null), [h, r] = ue(!0), [c, d] = ue(null), [g, y] = ue(!1), x = Ae(), I = o.ttsService || x.service, E = I === "browser" ? {
7025
7025
  endpoint: "",
7026
7026
  apiKey: null,
7027
7027
  defaultVoice: "Google US English"
@@ -7037,7 +7037,7 @@ const rt = Re(({
7037
7037
  body: "F",
7038
7038
  avatarMood: "neutral",
7039
7039
  ttsLang: I === "browser" ? "en-US" : "en",
7040
- ttsVoice: o.ttsVoice || P.defaultVoice,
7040
+ ttsVoice: o.ttsVoice || E.defaultVoice,
7041
7041
  lipsyncLang: "en",
7042
7042
  // English lip-sync
7043
7043
  showFullAvatar: !0,
@@ -7046,42 +7046,42 @@ const rt = Re(({
7046
7046
  movementIntensity: 0.5,
7047
7047
  ...o
7048
7048
  }, H = {
7049
- ttsEndpoint: P.endpoint,
7050
- ttsApikey: P.apiKey,
7049
+ ttsEndpoint: E.endpoint,
7050
+ ttsApikey: E.apiKey,
7051
7051
  ttsService: I,
7052
7052
  lipsyncModules: ["en"],
7053
7053
  cameraView: "upper"
7054
7054
  }, z = T(async () => {
7055
7055
  if (!(!u.current || a.current))
7056
7056
  try {
7057
- if (r(!0), d(null), a.current = new Me(u.current, H), await a.current.showAvatar(p, (V) => {
7058
- if (V.lengthComputable) {
7059
- const E = Math.min(100, Math.round(V.loaded / V.total * 100));
7060
- t(E);
7057
+ if (r(!0), d(null), a.current = new Ee(u.current, H), await a.current.showAvatar(p, (B) => {
7058
+ if (B.lengthComputable) {
7059
+ const U = Math.min(100, Math.round(B.loaded / B.total * 100));
7060
+ t(U);
7061
7061
  }
7062
7062
  }), a.current.morphs && a.current.morphs.length > 0) {
7063
- const V = a.current.morphs[0].morphTargetDictionary;
7064
- console.log("Available morph targets:", Object.keys(V));
7065
- const E = Object.keys(V).filter((X) => X.startsWith("viseme_"));
7066
- console.log("Viseme morph targets found:", E), E.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"));
7063
+ const B = a.current.morphs[0].morphTargetDictionary;
7064
+ console.log("Available morph targets:", Object.keys(B));
7065
+ const U = Object.keys(B).filter((Z) => Z.startsWith("viseme_"));
7066
+ console.log("Viseme morph targets found:", U), U.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"));
7067
7067
  }
7068
- if (await new Promise((V) => {
7069
- const E = () => {
7070
- a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), V()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(E, 100));
7068
+ if (await new Promise((B) => {
7069
+ const U = () => {
7070
+ a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), B()) : (console.log("Waiting for lip-sync modules to load..."), setTimeout(U, 100));
7071
7071
  };
7072
- E();
7072
+ U();
7073
7073
  }), a.current && a.current.setShowFullAvatar)
7074
7074
  try {
7075
7075
  a.current.setShowFullAvatar(!0), console.log("Avatar initialized in full body mode");
7076
- } catch (V) {
7077
- console.warn("Error setting full body mode on initialization:", V);
7076
+ } catch (B) {
7077
+ console.warn("Error setting full body mode on initialization:", B);
7078
7078
  }
7079
7079
  r(!1), y(!0), i(a.current);
7080
- const U = () => {
7080
+ const G = () => {
7081
7081
  document.visibilityState === "visible" ? a.current?.start() : a.current?.stop();
7082
7082
  };
7083
- return document.addEventListener("visibilitychange", U), () => {
7084
- document.removeEventListener("visibilitychange", U);
7083
+ return document.addEventListener("visibilitychange", G), () => {
7084
+ document.removeEventListener("visibilitychange", G);
7085
7085
  };
7086
7086
  } catch (S) {
7087
7087
  console.error("Error initializing TalkingHead:", S), d(S.message || "Failed to initialize avatar"), r(!1), e(S);
@@ -7090,78 +7090,78 @@ const rt = Re(({
7090
7090
  pe(() => (z(), () => {
7091
7091
  a.current && (a.current.stop(), a.current.dispose(), a.current = null);
7092
7092
  }), [z]);
7093
- const R = T((S) => {
7093
+ const v = T((S) => {
7094
7094
  if (a.current && g)
7095
7095
  try {
7096
7096
  console.log("Speaking text:", S), console.log("Avatar config:", p), console.log("TalkingHead instance:", a.current), a.current.lipsync && Object.keys(a.current.lipsync).length > 0 ? (console.log("Lip-sync modules loaded:", Object.keys(a.current.lipsync)), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : (console.warn("Lip-sync modules not ready, waiting..."), setTimeout(() => {
7097
7097
  a.current && a.current.lipsync ? (console.log("Lip-sync now ready, speaking..."), a.current.setSlowdownRate && (a.current.setSlowdownRate(1.05), console.log("Applied timing adjustment for better lip-sync")), a.current.speakText(S)) : console.error("Lip-sync still not ready after waiting");
7098
7098
  }, 500));
7099
- } catch (U) {
7100
- console.error("Error speaking text:", U), d(U.message || "Failed to speak text");
7099
+ } catch (G) {
7100
+ console.error("Error speaking text:", G), d(G.message || "Failed to speak text");
7101
7101
  }
7102
7102
  else
7103
7103
  console.warn("Avatar not ready for speaking. isReady:", g, "talkingHeadRef:", !!a.current);
7104
- }, [g, p]), D = T(() => {
7104
+ }, [g, p]), N = T(() => {
7105
7105
  a.current && (a.current.stopSpeaking(), a.current.setSlowdownRate && (a.current.setSlowdownRate(1), console.log("Reset timing to normal")));
7106
- }, []), N = T((S) => {
7106
+ }, []), D = T((S) => {
7107
7107
  a.current && a.current.setMood(S);
7108
- }, []), _ = T((S) => {
7108
+ }, []), J = T((S) => {
7109
7109
  a.current && a.current.setSlowdownRate && (a.current.setSlowdownRate(S), console.log("Timing adjustment set to:", S));
7110
- }, []), ne = T((S, U = !1) => {
7110
+ }, []), ae = T((S, G = !1) => {
7111
7111
  if (a.current && a.current.playAnimation) {
7112
7112
  if (a.current.setShowFullAvatar)
7113
7113
  try {
7114
7114
  a.current.setShowFullAvatar(!0);
7115
- } catch (E) {
7116
- console.warn("Error setting full body mode:", E);
7115
+ } catch (U) {
7116
+ console.warn("Error setting full body mode:", U);
7117
7117
  }
7118
7118
  if (S.includes("."))
7119
7119
  try {
7120
- a.current.playAnimation(S, null, 10, 0, 0.01, U), console.log("Playing animation:", S);
7121
- } catch (E) {
7122
- console.log(`Failed to play ${S}:`, E);
7120
+ a.current.playAnimation(S, null, 10, 0, 0.01, G), console.log("Playing animation:", S);
7121
+ } catch (U) {
7122
+ console.log(`Failed to play ${S}:`, U);
7123
7123
  try {
7124
7124
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7125
- } catch (X) {
7126
- console.warn("Fallback animation also failed:", X);
7125
+ } catch (Z) {
7126
+ console.warn("Fallback animation also failed:", Z);
7127
7127
  }
7128
7128
  }
7129
7129
  else {
7130
- const E = [".fbx", ".glb", ".gltf"];
7131
- let X = !1;
7132
- for (const Y of E)
7130
+ const U = [".fbx", ".glb", ".gltf"];
7131
+ let Z = !1;
7132
+ for (const _ of U)
7133
7133
  try {
7134
- a.current.playAnimation(S + Y, null, 10, 0, 0.01, U), console.log("Playing animation:", S + Y), X = !0;
7134
+ a.current.playAnimation(S + _, null, 10, 0, 0.01, G), console.log("Playing animation:", S + _), Z = !0;
7135
7135
  break;
7136
7136
  } catch {
7137
- console.log(`Failed to play ${S}${Y}, trying next format...`);
7137
+ console.log(`Failed to play ${S}${_}, trying next format...`);
7138
7138
  }
7139
- if (!X) {
7139
+ if (!Z) {
7140
7140
  console.warn("Animation system not available or animation not found:", S);
7141
7141
  try {
7142
7142
  a.current.setBodyMovement("idle"), console.log("Fallback to idle animation");
7143
- } catch (Y) {
7144
- console.warn("Fallback animation also failed:", Y);
7143
+ } catch (_) {
7144
+ console.warn("Fallback animation also failed:", _);
7145
7145
  }
7146
7146
  }
7147
7147
  }
7148
7148
  } else
7149
7149
  console.warn("Animation system not available or animation not found:", S);
7150
7150
  }, []);
7151
- return Ie(l, () => ({
7152
- speakText: R,
7153
- stopSpeaking: D,
7154
- setMood: N,
7155
- setTimingAdjustment: _,
7156
- playAnimation: ne,
7151
+ return Le(l, () => ({
7152
+ speakText: v,
7153
+ stopSpeaking: N,
7154
+ setMood: D,
7155
+ setTimingAdjustment: J,
7156
+ playAnimation: ae,
7157
7157
  isReady: g,
7158
7158
  talkingHead: a.current,
7159
7159
  setBodyMovement: (S) => {
7160
7160
  if (a.current && a.current.setShowFullAvatar && a.current.setBodyMovement)
7161
7161
  try {
7162
7162
  a.current.setShowFullAvatar(!0), a.current.setBodyMovement(S), console.log("Body movement set with full body mode:", S);
7163
- } catch (U) {
7164
- console.warn("Error setting body movement:", U);
7163
+ } catch (G) {
7164
+ console.warn("Error setting body movement:", G);
7165
7165
  }
7166
7166
  },
7167
7167
  setMovementIntensity: (S) => a.current?.setMovementIntensity(S),
@@ -7177,8 +7177,8 @@ const rt = Re(({
7177
7177
  if (a.current && a.current.setShowFullAvatar && a.current.playReaction)
7178
7178
  try {
7179
7179
  a.current.setShowFullAvatar(!0), a.current.playReaction(S), console.log("Reaction played with full body mode:", S);
7180
- } catch (U) {
7181
- console.warn("Error playing reaction:", U);
7180
+ } catch (G) {
7181
+ console.warn("Error playing reaction:", G);
7182
7182
  }
7183
7183
  },
7184
7184
  playCelebration: () => {
@@ -7193,8 +7193,8 @@ const rt = Re(({
7193
7193
  if (a.current && a.current.setShowFullAvatar)
7194
7194
  try {
7195
7195
  a.current.setShowFullAvatar(S), console.log("Show full avatar set to:", S);
7196
- } catch (U) {
7197
- console.warn("Error setting showFullAvatar:", U);
7196
+ } catch (G) {
7197
+ console.warn("Error setting showFullAvatar:", G);
7198
7198
  }
7199
7199
  },
7200
7200
  lockAvatarPosition: () => {
@@ -7213,7 +7213,7 @@ const rt = Re(({
7213
7213
  console.warn("Error unlocking avatar position:", S);
7214
7214
  }
7215
7215
  }
7216
- })), /* @__PURE__ */ Te("div", { className: `talking-head-container ${n}`, style: s, children: [
7216
+ })), /* @__PURE__ */ Me("div", { className: `talking-head-container ${n}`, style: s, children: [
7217
7217
  /* @__PURE__ */ he(
7218
7218
  "div",
7219
7219
  {
@@ -7249,8 +7249,8 @@ const rt = Re(({
7249
7249
  }, children: c })
7250
7250
  ] });
7251
7251
  });
7252
- rt.displayName = "TalkingHeadComponent";
7253
- const lt = Re(({
7252
+ lt.displayName = "TalkingHeadComponent";
7253
+ const ht = Ie(({
7254
7254
  curriculumData: O = null,
7255
7255
  avatarConfig: t = {},
7256
7256
  animations: e = {},
@@ -7266,7 +7266,7 @@ const lt = Re(({
7266
7266
  },
7267
7267
  autoStart: u = !1
7268
7268
  }, a) => {
7269
- const h = Z(null), r = Z({
7269
+ const h = X(null), r = X({
7270
7270
  currentModuleIndex: 0,
7271
7271
  currentLessonIndex: 0,
7272
7272
  currentQuestionIndex: 0,
@@ -7276,18 +7276,18 @@ const lt = Re(({
7276
7276
  curriculumCompleted: !1,
7277
7277
  score: 0,
7278
7278
  totalQuestions: 0
7279
- }), c = Z({
7279
+ }), c = X({
7280
7280
  onLessonStart: i,
7281
7281
  onLessonComplete: n,
7282
7282
  onQuestionAnswer: s,
7283
7283
  onCurriculumComplete: o,
7284
7284
  onCustomAction: l
7285
- }), d = Z(null), g = Z(null), y = Z(null), x = Z(null), I = Z(null), P = Z(null), p = Z(null), H = Z(O?.curriculum || {
7285
+ }), d = X(null), g = X(null), y = X(null), x = X(null), I = X(null), E = X(null), p = X(null), H = X(O?.curriculum || {
7286
7286
  title: "Default Curriculum",
7287
7287
  description: "No curriculum data provided",
7288
7288
  language: "en",
7289
7289
  modules: []
7290
- }), z = Z({
7290
+ }), z = X({
7291
7291
  avatarUrl: t.avatarUrl || "/avatars/brunette.glb",
7292
7292
  avatarBody: t.avatarBody || "F",
7293
7293
  mood: t.mood || "happy",
@@ -7330,11 +7330,11 @@ const lt = Re(({
7330
7330
  lipsyncLang: "en"
7331
7331
  };
7332
7332
  }, [O, t, e]);
7333
- const R = T(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), D = T(() => R()?.questions[r.current.currentQuestionIndex], [R]), N = T((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, []), _ = T(() => {
7333
+ const v = T(() => (H.current || { modules: [] }).modules[r.current.currentModuleIndex]?.lessons[r.current.currentLessonIndex], []), N = T(() => v()?.questions[r.current.currentQuestionIndex], [v]), D = T((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 = T(() => {
7334
7334
  r.current.lessonCompleted = !0, r.current.isQuestionMode = !1;
7335
7335
  const b = r.current.totalQuestions > 0 ? Math.round(r.current.score / r.current.totalQuestions * 100) : 100;
7336
- let v = "Congratulations! You've completed this lesson";
7337
- if (r.current.totalQuestions > 0 ? v += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.current.totalQuestions === 1 ? "" : "s"}, achieving a score of ${b} percent. ` : v += "! ", b >= 80 ? v += "Excellent work! You have a great understanding of this topic." : b >= 60 ? v += "Good job! You understand most of the concepts." : v += "Keep practicing! You're making progress.", c.current.onLessonComplete({
7336
+ let R = "Congratulations! You've completed this lesson";
7337
+ if (r.current.totalQuestions > 0 ? R += ` You got ${r.current.score} correct out of ${r.current.totalQuestions} question${r.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({
7338
7338
  moduleIndex: r.current.currentModuleIndex,
7339
7339
  lessonIndex: r.current.currentLessonIndex,
7340
7340
  score: r.current.score,
@@ -7354,9 +7354,9 @@ const lt = Re(({
7354
7354
  } catch {
7355
7355
  h.current.playCelebration();
7356
7356
  }
7357
- const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], G = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, ie = G || te, A = z.current || { lipsyncLang: "en" };
7358
- h.current.speakText(v, {
7359
- lipsyncLang: A.lipsyncLang,
7357
+ const w = H.current || { modules: [] }, C = w.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (w.modules?.length || 0) - 1, ie = V || te, ge = z.current || { lipsyncLang: "en" };
7358
+ h.current.speakText(R, {
7359
+ lipsyncLang: ge.lipsyncLang,
7360
7360
  onSpeechEnd: () => {
7361
7361
  c.current.onCustomAction({
7362
7362
  type: "lessonCompleteFeedbackDone",
@@ -7370,12 +7370,12 @@ const lt = Re(({
7370
7370
  }
7371
7371
  });
7372
7372
  }
7373
- }, [e.lessonComplete]), ne = T(() => {
7373
+ }, [e.lessonComplete]), ae = T(() => {
7374
7374
  r.current.curriculumCompleted = !0;
7375
7375
  const b = H.current || { modules: [] };
7376
7376
  if (c.current.onCurriculumComplete({
7377
7377
  modules: b.modules.length,
7378
- totalLessons: b.modules.reduce((v, w) => v + w.lessons.length, 0)
7378
+ totalLessons: b.modules.reduce((R, w) => R + w.lessons.length, 0)
7379
7379
  }), h.current) {
7380
7380
  if (h.current.setMood("celebrating"), e.curriculumComplete)
7381
7381
  try {
@@ -7383,82 +7383,82 @@ const lt = Re(({
7383
7383
  } catch {
7384
7384
  h.current.playCelebration();
7385
7385
  }
7386
- const v = z.current || { lipsyncLang: "en" };
7387
- 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 });
7386
+ const R = z.current || { lipsyncLang: "en" };
7387
+ 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 });
7388
7388
  }
7389
7389
  }, [e.curriculumComplete]), S = T(() => {
7390
- const b = R();
7390
+ const b = v();
7391
7391
  r.current.isQuestionMode = !0, r.current.currentQuestionIndex = 0, r.current.totalQuestions = b?.questions?.length || 0, r.current.score = 0;
7392
- const v = D();
7393
- v && c.current.onCustomAction({
7392
+ const R = N();
7393
+ R && c.current.onCustomAction({
7394
7394
  type: "questionStart",
7395
7395
  moduleIndex: r.current.currentModuleIndex,
7396
7396
  lessonIndex: r.current.currentLessonIndex,
7397
7397
  questionIndex: r.current.currentQuestionIndex,
7398
7398
  totalQuestions: r.current.totalQuestions,
7399
- question: v,
7399
+ question: R,
7400
7400
  score: r.current.score
7401
7401
  });
7402
7402
  const w = () => {
7403
- if (!h.current || !v) return;
7403
+ if (!h.current || !R) return;
7404
7404
  if (h.current.setMood("happy"), e.questionStart)
7405
7405
  try {
7406
7406
  h.current.playAnimation(e.questionStart, !0);
7407
- } catch (G) {
7408
- console.warn("Failed to play questionStart animation:", G);
7407
+ } catch (V) {
7408
+ console.warn("Failed to play questionStart animation:", V);
7409
7409
  }
7410
7410
  const C = z.current || { lipsyncLang: "en" };
7411
- 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 });
7411
+ 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 });
7412
7412
  };
7413
- if (h.current && h.current.isReady && v)
7413
+ if (h.current && h.current.isReady && R)
7414
7414
  w();
7415
7415
  else if (h.current && h.current.isReady) {
7416
7416
  const C = z.current || { lipsyncLang: "en" };
7417
7417
  h.current.speakText("Now let me ask you some questions to test your understanding.", { lipsyncLang: C.lipsyncLang });
7418
7418
  } else {
7419
7419
  const C = setInterval(() => {
7420
- h.current && h.current.isReady && (clearInterval(C), v && w());
7420
+ h.current && h.current.isReady && (clearInterval(C), R && w());
7421
7421
  }, 100);
7422
7422
  setTimeout(() => {
7423
7423
  clearInterval(C);
7424
7424
  }, 5e3);
7425
7425
  }
7426
- }, [e.questionStart, R, D]), U = T(() => {
7427
- const b = R();
7426
+ }, [e.questionStart, v, N]), G = T(() => {
7427
+ const b = v();
7428
7428
  if (r.current.currentQuestionIndex < (b?.questions?.length || 0) - 1) {
7429
7429
  h.current && h.current.stopSpeaking && h.current.stopSpeaking(), r.current.currentQuestionIndex += 1;
7430
- const v = D();
7431
- v && c.current.onCustomAction({
7430
+ const R = N();
7431
+ R && c.current.onCustomAction({
7432
7432
  type: "nextQuestion",
7433
7433
  moduleIndex: r.current.currentModuleIndex,
7434
7434
  lessonIndex: r.current.currentLessonIndex,
7435
7435
  questionIndex: r.current.currentQuestionIndex,
7436
7436
  totalQuestions: r.current.totalQuestions,
7437
- question: v,
7437
+ question: R,
7438
7438
  score: r.current.score
7439
7439
  });
7440
7440
  const w = () => {
7441
- if (!h.current || !v) return;
7441
+ if (!h.current || !R) return;
7442
7442
  if (h.current.setMood("happy"), h.current.setBodyMovement("idle"), e.nextQuestion)
7443
7443
  try {
7444
7444
  h.current.playAnimation(e.nextQuestion, !0);
7445
- } catch (G) {
7446
- console.warn("Failed to play nextQuestion animation:", G);
7445
+ } catch (V) {
7446
+ console.warn("Failed to play nextQuestion animation:", V);
7447
7447
  }
7448
7448
  const C = z.current || { lipsyncLang: "en" };
7449
- v.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${v.question}`, {
7449
+ R.type === "code_test" ? h.current.speakText(`Great! Now let's move on to your next coding challenge: ${R.question}`, {
7450
7450
  lipsyncLang: C.lipsyncLang
7451
- }) : v.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${v.question}`, {
7451
+ }) : R.type === "multiple_choice" ? h.current.speakText(`Alright! Here's your next question: ${R.question}`, {
7452
7452
  lipsyncLang: C.lipsyncLang
7453
- }) : v.type === "true_false" ? h.current.speakText(`Now let's try this one: ${v.question}`, {
7453
+ }) : R.type === "true_false" ? h.current.speakText(`Now let's try this one: ${R.question}`, {
7454
7454
  lipsyncLang: C.lipsyncLang
7455
- }) : h.current.speakText(`Here's the next question: ${v.question}`, {
7455
+ }) : h.current.speakText(`Here's the next question: ${R.question}`, {
7456
7456
  lipsyncLang: C.lipsyncLang
7457
7457
  });
7458
7458
  };
7459
- if (h.current && h.current.isReady && v)
7459
+ if (h.current && h.current.isReady && R)
7460
7460
  w();
7461
- else if (v) {
7461
+ else if (R) {
7462
7462
  const C = setInterval(() => {
7463
7463
  h.current && h.current.isReady && (clearInterval(C), w());
7464
7464
  }, 100);
@@ -7474,11 +7474,11 @@ const lt = Re(({
7474
7474
  totalQuestions: r.current.totalQuestions,
7475
7475
  score: r.current.score
7476
7476
  });
7477
- }, [e.nextQuestion, R, D]), V = T(() => {
7478
- const b = H.current || { modules: [] }, v = b.modules[r.current.currentModuleIndex];
7479
- if (r.current.currentLessonIndex < (v?.lessons?.length || 0) - 1) {
7477
+ }, [e.nextQuestion, v, N]), B = T(() => {
7478
+ const b = H.current || { modules: [] }, R = b.modules[r.current.currentModuleIndex];
7479
+ if (r.current.currentLessonIndex < (R?.lessons?.length || 0) - 1) {
7480
7480
  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;
7481
- const C = b.modules[r.current.currentModuleIndex], G = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ie = G || te;
7481
+ const C = b.modules[r.current.currentModuleIndex], V = r.current.currentLessonIndex < (C?.lessons?.length || 0) - 1, te = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ie = V || te;
7482
7482
  c.current.onCustomAction({
7483
7483
  type: "lessonStart",
7484
7484
  moduleIndex: r.current.currentModuleIndex,
@@ -7487,39 +7487,39 @@ const lt = Re(({
7487
7487
  }), c.current.onLessonStart({
7488
7488
  moduleIndex: r.current.currentModuleIndex,
7489
7489
  lessonIndex: r.current.currentLessonIndex,
7490
- lesson: R()
7490
+ lesson: v()
7491
7491
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7492
7492
  } else if (r.current.currentModuleIndex < (b.modules?.length || 0) - 1) {
7493
7493
  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;
7494
- const G = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (G?.lessons?.length || 0) - 1, ie = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, A = te || ie;
7494
+ const V = b.modules[r.current.currentModuleIndex], te = r.current.currentLessonIndex < (V?.lessons?.length || 0) - 1, ie = r.current.currentModuleIndex < (b.modules?.length || 0) - 1, ge = te || ie;
7495
7495
  c.current.onCustomAction({
7496
7496
  type: "lessonStart",
7497
7497
  moduleIndex: r.current.currentModuleIndex,
7498
7498
  lessonIndex: r.current.currentLessonIndex,
7499
- hasNextLesson: A
7499
+ hasNextLesson: ge
7500
7500
  }), c.current.onLessonStart({
7501
7501
  moduleIndex: r.current.currentModuleIndex,
7502
7502
  lessonIndex: r.current.currentLessonIndex,
7503
- lesson: R()
7503
+ lesson: v()
7504
7504
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7505
7505
  } else
7506
7506
  I.current && I.current();
7507
- }, []), E = T(() => {
7508
- const b = R();
7509
- let v = null;
7507
+ }, []), U = T(() => {
7508
+ const b = v();
7509
+ let R = null;
7510
7510
  if (b?.avatar_script && b?.body) {
7511
- const w = b.avatar_script.trim(), C = b.body.trim(), G = w.match(/[.!?]$/) ? " " : ". ";
7512
- v = `${w}${G}${C}`;
7511
+ const w = b.avatar_script.trim(), C = b.body.trim(), V = w.match(/[.!?]$/) ? " " : ". ";
7512
+ R = `${w}${V}${C}`;
7513
7513
  } else
7514
- v = b?.avatar_script || b?.body || null;
7515
- if (h.current && h.current.isReady && v) {
7514
+ R = b?.avatar_script || b?.body || null;
7515
+ if (h.current && h.current.isReady && R) {
7516
7516
  r.current.isTeaching = !0, r.current.isQuestionMode = !1, r.current.score = 0, r.current.totalQuestions = 0, h.current.setMood("happy");
7517
7517
  let w = !1;
7518
7518
  if (e.teaching)
7519
7519
  try {
7520
7520
  h.current.playAnimation(e.teaching, !0), w = !0;
7521
- } catch (G) {
7522
- console.warn("Failed to play teaching animation:", G);
7521
+ } catch (V) {
7522
+ console.warn("Failed to play teaching animation:", V);
7523
7523
  }
7524
7524
  w || h.current.setBodyMovement("gesturing");
7525
7525
  const C = z.current || { lipsyncLang: "en" };
@@ -7532,7 +7532,7 @@ const lt = Re(({
7532
7532
  moduleIndex: r.current.currentModuleIndex,
7533
7533
  lessonIndex: r.current.currentLessonIndex,
7534
7534
  lesson: b
7535
- }), h.current.speakText(v, {
7535
+ }), h.current.speakText(R, {
7536
7536
  lipsyncLang: C.lipsyncLang,
7537
7537
  onSpeechEnd: () => {
7538
7538
  r.current.isTeaching = !1, c.current.onCustomAction({
@@ -7545,15 +7545,15 @@ const lt = Re(({
7545
7545
  }
7546
7546
  });
7547
7547
  }
7548
- }, [e.teaching, R]), X = T((b) => {
7549
- const v = D(), w = N(b, v);
7548
+ }, [e.teaching, v]), Z = T((b) => {
7549
+ const R = N(), w = D(b, R);
7550
7550
  if (w && (r.current.score += 1), c.current.onQuestionAnswer({
7551
7551
  moduleIndex: r.current.currentModuleIndex,
7552
7552
  lessonIndex: r.current.currentLessonIndex,
7553
7553
  questionIndex: r.current.currentQuestionIndex,
7554
7554
  answer: b,
7555
7555
  isCorrect: w,
7556
- question: v
7556
+ question: R
7557
7557
  }), h.current)
7558
7558
  if (w) {
7559
7559
  if (h.current.setMood("happy"), e.correct)
@@ -7563,11 +7563,11 @@ const lt = Re(({
7563
7563
  h.current.setBodyMovement("happy");
7564
7564
  }
7565
7565
  h.current.setBodyMovement("gesturing");
7566
- const C = v.type === "code_test" ? `Great job! Your code passed all the tests! ${v.explanation || ""}` : `Excellent! That's correct! ${v.explanation || ""}`, G = z.current || { lipsyncLang: "en" };
7566
+ const C = R.type === "code_test" ? `Great job! Your code passed all the tests! ${R.explanation || ""}` : `Excellent! That's correct! ${R.explanation || ""}`, V = z.current || { lipsyncLang: "en" };
7567
7567
  h.current.speakText(C, {
7568
- lipsyncLang: G.lipsyncLang,
7568
+ lipsyncLang: V.lipsyncLang,
7569
7569
  onSpeechEnd: () => {
7570
- const ie = R()?.questions?.length || 0;
7570
+ const ie = v()?.questions?.length || 0;
7571
7571
  c.current.onCustomAction({
7572
7572
  type: "answerFeedbackComplete",
7573
7573
  moduleIndex: r.current.currentModuleIndex,
@@ -7588,11 +7588,11 @@ const lt = Re(({
7588
7588
  h.current.setBodyMovement("idle");
7589
7589
  }
7590
7590
  h.current.setBodyMovement("gesturing");
7591
- const C = 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 || ""} Let's move on to the next question.`, G = z.current || { lipsyncLang: "en" };
7591
+ const C = 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 || ""} Let's move on to the next question.`, V = z.current || { lipsyncLang: "en" };
7592
7592
  h.current.speakText(C, {
7593
- lipsyncLang: G.lipsyncLang,
7593
+ lipsyncLang: V.lipsyncLang,
7594
7594
  onSpeechEnd: () => {
7595
- const ie = R()?.questions?.length || 0;
7595
+ const ie = v()?.questions?.length || 0;
7596
7596
  c.current.onCustomAction({
7597
7597
  type: "answerFeedbackComplete",
7598
7598
  moduleIndex: r.current.currentModuleIndex,
@@ -7607,26 +7607,26 @@ const lt = Re(({
7607
7607
  });
7608
7608
  }
7609
7609
  else {
7610
- const G = R()?.questions?.length || 0;
7610
+ const V = v()?.questions?.length || 0;
7611
7611
  c.current.onCustomAction({
7612
7612
  type: "answerFeedbackComplete",
7613
7613
  moduleIndex: r.current.currentModuleIndex,
7614
7614
  lessonIndex: r.current.currentLessonIndex,
7615
7615
  questionIndex: r.current.currentQuestionIndex,
7616
7616
  isCorrect: w,
7617
- hasNextQuestion: r.current.currentQuestionIndex < G - 1,
7617
+ hasNextQuestion: r.current.currentQuestionIndex < V - 1,
7618
7618
  score: r.current.score,
7619
7619
  totalQuestions: r.current.totalQuestions,
7620
7620
  avatarNotReady: !0
7621
7621
  });
7622
7622
  }
7623
- }, [e.correct, e.incorrect, D, R, N]), Y = T((b) => {
7624
- const v = D();
7623
+ }, [e.correct, e.incorrect, N, v, D]), _ = T((b) => {
7624
+ const R = N();
7625
7625
  if (!b || typeof b != "object") {
7626
7626
  console.error("Invalid code test result format. Expected object with {passed: boolean, ...}");
7627
7627
  return;
7628
7628
  }
7629
- if (v?.type !== "code_test") {
7629
+ if (R?.type !== "code_test") {
7630
7630
  console.warn("Current question is not a code test. Use handleAnswerSelect for other question types.");
7631
7631
  return;
7632
7632
  }
@@ -7646,12 +7646,12 @@ const lt = Re(({
7646
7646
  lessonIndex: r.current.currentLessonIndex,
7647
7647
  questionIndex: r.current.currentQuestionIndex,
7648
7648
  testResult: w,
7649
- question: v
7649
+ question: R
7650
7650
  }), p.current && p.current(w);
7651
- }, [D, N]), ue = T(() => {
7651
+ }, [N, D]), ne = T(() => {
7652
7652
  if (r.current.currentQuestionIndex > 0) {
7653
7653
  r.current.currentQuestionIndex -= 1;
7654
- const b = D();
7654
+ const b = N();
7655
7655
  b && c.current.onCustomAction({
7656
7656
  type: "questionStart",
7657
7657
  moduleIndex: r.current.currentModuleIndex,
@@ -7661,7 +7661,7 @@ const lt = Re(({
7661
7661
  question: b,
7662
7662
  score: r.current.score
7663
7663
  });
7664
- const v = () => {
7664
+ const R = () => {
7665
7665
  if (!h.current || !b) return;
7666
7666
  h.current.setMood("happy"), h.current.setBodyMovement("idle");
7667
7667
  const w = z.current || { lipsyncLang: "en" };
@@ -7672,17 +7672,17 @@ const lt = Re(({
7672
7672
  });
7673
7673
  };
7674
7674
  if (h.current && h.current.isReady && b)
7675
- v();
7675
+ R();
7676
7676
  else if (b) {
7677
7677
  const w = setInterval(() => {
7678
- h.current && h.current.isReady && (clearInterval(w), v());
7678
+ h.current && h.current.isReady && (clearInterval(w), R());
7679
7679
  }, 100);
7680
7680
  setTimeout(() => {
7681
7681
  clearInterval(w);
7682
7682
  }, 5e3);
7683
7683
  }
7684
7684
  }
7685
- }, [D]), ve = T(() => {
7685
+ }, [N]), ce = T(() => {
7686
7686
  const b = H.current || { modules: [] };
7687
7687
  if (b.modules[r.current.currentModuleIndex], r.current.currentLessonIndex > 0)
7688
7688
  r.current.currentLessonIndex -= 1, r.current.currentQuestionIndex = 0, r.current.lessonCompleted = !1, r.current.isQuestionMode = !1, r.current.isTeaching = !1, r.current.score = 0, r.current.totalQuestions = 0, c.current.onCustomAction({
@@ -7692,7 +7692,7 @@ const lt = Re(({
7692
7692
  }), c.current.onLessonStart({
7693
7693
  moduleIndex: r.current.currentModuleIndex,
7694
7694
  lessonIndex: r.current.currentLessonIndex,
7695
- lesson: R()
7695
+ lesson: v()
7696
7696
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7697
7697
  else if (r.current.currentModuleIndex > 0) {
7698
7698
  const C = b.modules[r.current.currentModuleIndex - 1];
@@ -7703,53 +7703,53 @@ const lt = Re(({
7703
7703
  }), c.current.onLessonStart({
7704
7704
  moduleIndex: r.current.currentModuleIndex,
7705
7705
  lessonIndex: r.current.currentLessonIndex,
7706
- lesson: R()
7706
+ lesson: v()
7707
7707
  }), h.current && (h.current.setMood("happy"), h.current.setBodyMovement("idle"));
7708
7708
  }
7709
- }, [R]), ge = T(() => {
7709
+ }, [v]), fe = T(() => {
7710
7710
  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;
7711
- }, []), re = T((b) => {
7711
+ }, []), xe = T((b) => {
7712
7712
  console.log("Avatar is ready!", b);
7713
- const v = R(), w = v?.avatar_script || v?.body;
7713
+ const R = v(), w = R?.avatar_script || R?.body;
7714
7714
  u && w && setTimeout(() => {
7715
7715
  d.current && d.current();
7716
7716
  }, 10);
7717
- }, [u, R]);
7718
- Oe(() => {
7719
- d.current = E, g.current = V, y.current = _, x.current = U, I.current = ne, P.current = S, p.current = X;
7720
- }), Ie(a, () => ({
7717
+ }, [u, v]);
7718
+ Ne(() => {
7719
+ d.current = U, g.current = B, y.current = J, x.current = G, I.current = ae, E.current = S, p.current = Z;
7720
+ }), Le(a, () => ({
7721
7721
  // Curriculum control methods
7722
- startTeaching: E,
7722
+ startTeaching: U,
7723
7723
  startQuestions: S,
7724
- handleAnswerSelect: X,
7725
- handleCodeTestResult: Y,
7726
- nextQuestion: U,
7727
- previousQuestion: ue,
7728
- nextLesson: V,
7729
- previousLesson: ve,
7730
- completeLesson: _,
7731
- completeCurriculum: ne,
7732
- resetCurriculum: ge,
7724
+ handleAnswerSelect: Z,
7725
+ handleCodeTestResult: _,
7726
+ nextQuestion: G,
7727
+ previousQuestion: ne,
7728
+ nextLesson: B,
7729
+ previousLesson: ce,
7730
+ completeLesson: J,
7731
+ completeCurriculum: ae,
7732
+ resetCurriculum: fe,
7733
7733
  getState: () => ({ ...r.current }),
7734
- getCurrentQuestion: () => D(),
7735
- getCurrentLesson: () => R(),
7734
+ getCurrentQuestion: () => N(),
7735
+ getCurrentLesson: () => v(),
7736
7736
  // Direct access to avatar ref (always returns current value)
7737
7737
  getAvatarRef: () => h.current,
7738
7738
  // Convenience methods that delegate to avatar (always check current ref)
7739
- speakText: async (b, v = {}) => {
7739
+ speakText: async (b, R = {}) => {
7740
7740
  await h.current?.resumeAudioContext?.();
7741
7741
  const w = z.current || { lipsyncLang: "en" };
7742
- h.current?.speakText(b, { ...v, lipsyncLang: v.lipsyncLang || w.lipsyncLang });
7742
+ h.current?.speakText(b, { ...R, lipsyncLang: R.lipsyncLang || w.lipsyncLang });
7743
7743
  },
7744
7744
  resumeAudioContext: async () => {
7745
7745
  if (h.current?.resumeAudioContext)
7746
7746
  return await h.current.resumeAudioContext();
7747
7747
  const b = h.current?.talkingHead;
7748
7748
  if (b?.audioCtx) {
7749
- const v = b.audioCtx;
7750
- if (v.state === "suspended" || v.state === "interrupted")
7749
+ const R = b.audioCtx;
7750
+ if (R.state === "suspended" || R.state === "interrupted")
7751
7751
  try {
7752
- await v.resume(), console.log("Audio context resumed via talkingHead");
7752
+ await R.resume(), console.log("Audio context resumed via talkingHead");
7753
7753
  } catch (w) {
7754
7754
  console.warn("Failed to resume audio context:", w);
7755
7755
  }
@@ -7761,7 +7761,7 @@ const lt = Re(({
7761
7761
  resumeSpeaking: async () => await h.current?.resumeSpeaking(),
7762
7762
  isPaused: () => h.current && typeof h.current.isPaused < "u" ? h.current.isPaused : !1,
7763
7763
  setMood: (b) => h.current?.setMood(b),
7764
- playAnimation: (b, v) => h.current?.playAnimation(b, v),
7764
+ playAnimation: (b, R) => h.current?.playAnimation(b, R),
7765
7765
  setBodyMovement: (b) => h.current?.setBodyMovement(b),
7766
7766
  setMovementIntensity: (b) => h.current?.setMovementIntensity(b),
7767
7767
  playRandomDance: () => h.current?.playRandomDance(),
@@ -7772,10 +7772,10 @@ const lt = Re(({
7772
7772
  lockAvatarPosition: () => h.current?.lockAvatarPosition(),
7773
7773
  unlockAvatarPosition: () => h.current?.unlockAvatarPosition(),
7774
7774
  // Custom action trigger
7775
- triggerCustomAction: (b, v) => {
7775
+ triggerCustomAction: (b, R) => {
7776
7776
  c.current.onCustomAction({
7777
7777
  type: b,
7778
- ...v,
7778
+ ...R,
7779
7779
  state: { ...r.current }
7780
7780
  });
7781
7781
  },
@@ -7783,8 +7783,8 @@ const lt = Re(({
7783
7783
  handleResize: () => h.current?.handleResize(),
7784
7784
  // Avatar readiness check (always returns current value)
7785
7785
  isAvatarReady: () => h.current?.isReady || !1
7786
- }), [E, S, X, Y, U, V, _, ne, ge, D, R]);
7787
- const J = z.current || {
7786
+ }), [U, S, Z, _, G, B, J, ae, fe, N, v]);
7787
+ const Y = z.current || {
7788
7788
  avatarUrl: "/avatars/brunette.glb",
7789
7789
  avatarBody: "F",
7790
7790
  mood: "happy",
@@ -7798,22 +7798,22 @@ const lt = Re(({
7798
7798
  animations: e
7799
7799
  };
7800
7800
  return /* @__PURE__ */ he("div", { style: { width: "100%", height: "100%" }, children: /* @__PURE__ */ he(
7801
- Ee,
7801
+ Fe,
7802
7802
  {
7803
7803
  ref: h,
7804
- avatarUrl: J.avatarUrl,
7805
- avatarBody: J.avatarBody,
7806
- mood: J.mood,
7807
- ttsLang: J.ttsLang,
7808
- ttsService: J.ttsService,
7809
- ttsVoice: J.ttsVoice,
7810
- ttsApiKey: J.ttsApiKey,
7811
- bodyMovement: J.bodyMovement,
7812
- movementIntensity: J.movementIntensity,
7813
- showFullAvatar: J.showFullAvatar,
7804
+ avatarUrl: Y.avatarUrl,
7805
+ avatarBody: Y.avatarBody,
7806
+ mood: Y.mood,
7807
+ ttsLang: Y.ttsLang,
7808
+ ttsService: Y.ttsService,
7809
+ ttsVoice: Y.ttsVoice,
7810
+ ttsApiKey: Y.ttsApiKey,
7811
+ bodyMovement: Y.bodyMovement,
7812
+ movementIntensity: Y.movementIntensity,
7813
+ showFullAvatar: Y.showFullAvatar,
7814
7814
  cameraView: "upper",
7815
- animations: J.animations,
7816
- onReady: re,
7815
+ animations: Y.animations,
7816
+ onReady: xe,
7817
7817
  onLoading: () => {
7818
7818
  },
7819
7819
  onError: (b) => {
@@ -7822,8 +7822,8 @@ const lt = Re(({
7822
7822
  }
7823
7823
  ) });
7824
7824
  });
7825
- lt.displayName = "CurriculumLearning";
7826
- const Fe = {
7825
+ ht.displayName = "CurriculumLearning";
7826
+ const Pe = {
7827
7827
  // Code-based dance animations (no FBX required)
7828
7828
  dance: {
7829
7829
  name: "dance",
@@ -7926,14 +7926,14 @@ const Fe = {
7926
7926
  duration: 5e3,
7927
7927
  description: "Excited, energetic movement"
7928
7928
  }
7929
- }, bt = (O) => Fe[O] || null, vt = (O) => Fe.hasOwnProperty(O);
7929
+ }, vt = (O) => Pe[O] || null, Rt = (O) => Pe.hasOwnProperty(O);
7930
7930
  export {
7931
- lt as CurriculumLearning,
7932
- Ee as TalkingHeadAvatar,
7933
- rt as TalkingHeadComponent,
7934
- Fe as animations,
7935
- Le as getActiveTTSConfig,
7936
- bt as getAnimation,
7937
- xt as getVoiceOptions,
7938
- vt as hasAnimation
7931
+ ht as CurriculumLearning,
7932
+ Fe as TalkingHeadAvatar,
7933
+ lt as TalkingHeadComponent,
7934
+ Pe as animations,
7935
+ Ae as getActiveTTSConfig,
7936
+ vt as getAnimation,
7937
+ bt as getVoiceOptions,
7938
+ Rt as hasAnimation
7939
7939
  };