@streamoji/avatar-widget 0.2.2 → 0.2.3

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.
@@ -1,30 +1,30 @@
1
- import { jsx as f, jsxs as ne } from "react/jsx-runtime";
2
- import { useGLTF as Qe, Environment as Mt } from "@react-three/drei";
1
+ import { jsx as u, jsxs as ne } from "react/jsx-runtime";
2
+ import { useGLTF as Qe, Environment as Et } from "@react-three/drei";
3
3
  import { useFrame as Tt, Canvas as It, useThree as Ct } from "@react-three/fiber";
4
4
  import { memo as Dt, useMemo as et, useRef as o, useState as y, useEffect as z, useCallback as $e, useLayoutEffect as Ot, Suspense as Ft } from "react";
5
5
  import * as Fe from "three";
6
6
  import { GLTFLoader as Ut } from "three/examples/jsm/loaders/GLTFLoader.js";
7
- const B = (...u) => {
8
- }, Nt = (...u) => {
9
- }, ut = ({ analyser: u }) => {
7
+ const B = (...d) => {
8
+ }, Nt = (...d) => {
9
+ }, ut = ({ analyser: d }) => {
10
10
  const x = o(null), w = o(null);
11
11
  return z(() => {
12
12
  const p = x.current;
13
13
  if (!p) return;
14
14
  const D = p.getContext("2d", { alpha: !0 });
15
15
  if (!D) return;
16
- let M, L = null;
17
- u && (u.fftSize = 128, L = new Uint8Array(u.frequencyBinCount));
16
+ let E, L = null;
17
+ d && (d.fftSize = 128, L = new Uint8Array(d.frequencyBinCount));
18
18
  const he = () => {
19
- M = requestAnimationFrame(he), (p.width !== p.offsetWidth || p.height !== p.offsetHeight) && (p.width = p.offsetWidth, p.height = p.offsetHeight);
19
+ E = requestAnimationFrame(he), (p.width !== p.offsetWidth || p.height !== p.offsetHeight) && (p.width = p.offsetWidth, p.height = p.offsetHeight);
20
20
  const re = p.width, O = p.height;
21
21
  if (re === 0 || O === 0) return;
22
22
  const k = O / 2;
23
23
  D.clearRect(0, 0, re, O), D.fillStyle = "#1e293b";
24
- const Q = 2, E = Q + 2, ce = re * 0.95, g = Math.floor(ce / E);
24
+ const Q = 2, M = Q + 2, ce = re * 0.95, g = Math.floor(ce / M);
25
25
  (!w.current || w.current.length !== g) && (w.current = new Float32Array(g).fill(2));
26
- const ke = g * E, Z = (re - ke) / 2;
27
- u && L && u.getByteFrequencyData(L);
26
+ const ke = g * M, Z = (re - ke) / 2;
27
+ d && L && d.getByteFrequencyData(L);
28
28
  const pe = L ? L.length : 0, J = Math.floor(pe * 0.7) / g, I = new Float32Array(g);
29
29
  for (let m = 0; m < g; m++) {
30
30
  let $ = 0;
@@ -42,14 +42,14 @@ const B = (...u) => {
42
42
  for (let m = 0; m < g; m++) {
43
43
  const $ = g - 1 - m, R = Math.max(I[m], I[$]), v = w.current[m] + (R - w.current[m]) * 0.3;
44
44
  w.current[m] = v;
45
- const b = Z + m * E, K = k - v / 2;
45
+ const b = Z + m * M, K = k - v / 2;
46
46
  D.beginPath(), D.roundRect ? D.roundRect(b, K, Q, v, 4) : D.fillRect(b, K, Q, v), D.fill();
47
47
  }
48
48
  };
49
49
  return he(), () => {
50
- cancelAnimationFrame(M);
50
+ cancelAnimationFrame(E);
51
51
  };
52
- }, [u]), /* @__PURE__ */ f(
52
+ }, [d]), /* @__PURE__ */ u(
53
53
  "canvas",
54
54
  {
55
55
  ref: x,
@@ -57,33 +57,33 @@ const B = (...u) => {
57
57
  }
58
58
  );
59
59
  }, dt = "https://ai.streamoji.com", Wt = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", ft = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/fullbodyavatarmale.glb";
60
- async function Pt(u) {
60
+ async function Pt(d) {
61
61
  const x = await crypto.subtle.digest(
62
62
  "SHA-256",
63
- new TextEncoder().encode(u)
63
+ new TextEncoder().encode(d)
64
64
  );
65
65
  return Array.from(new Uint8Array(x)).map((w) => w.toString(16).padStart(2, "0")).join("");
66
66
  }
67
- function Vt(u) {
67
+ function Vt(d) {
68
68
  const [x, w] = y(null);
69
69
  return z(() => {
70
- if (!u) {
70
+ if (!d) {
71
71
  w(null);
72
72
  return;
73
73
  }
74
74
  let p = !1;
75
- return Pt(u).then((D) => {
75
+ return Pt(d).then((D) => {
76
76
  if (p) return;
77
- const M = `${Wt}/${D}.glb`;
78
- fetch(M, { method: "HEAD" }).then((L) => {
79
- p || w(L.ok ? M : ft);
77
+ const E = `${Wt}/${D}.glb`;
78
+ fetch(E, { method: "HEAD" }).then((L) => {
79
+ p || w(L.ok ? E : ft);
80
80
  }).catch(() => {
81
81
  p || w(ft);
82
82
  });
83
83
  }), () => {
84
84
  p = !0;
85
85
  };
86
- }, [u]), x;
86
+ }, [d]), x;
87
87
  }
88
88
  const Bt = [
89
89
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
@@ -473,40 +473,40 @@ const Bt = [
473
473
  ],
474
474
  sil: [{ v: "sil", w: 1 }]
475
475
  };
476
- function Xt(u) {
477
- if (!u) return [{ v: "sil", w: 1 }];
478
- const x = u.toLowerCase();
476
+ function Xt(d) {
477
+ if (!d) return [{ v: "sil", w: 1 }];
478
+ const x = d.toLowerCase();
479
479
  return Yt[x] ?? [{ v: "sil", w: 1 }];
480
480
  }
481
- function Kt({ target: u }) {
481
+ function Kt({ target: d }) {
482
482
  const { camera: x } = Ct();
483
483
  return z(() => {
484
- x.lookAt(...u);
485
- }, [x, u]), null;
484
+ x.lookAt(...d);
485
+ }, [x, d]), null;
486
486
  }
487
- function G(u, x, w) {
488
- if (!u || !u.morphTargetDictionary)
487
+ function G(d, x, w) {
488
+ if (!d || !d.morphTargetDictionary)
489
489
  return;
490
- const p = u, D = p.morphTargetDictionary, M = p.morphTargetInfluences;
491
- if (M)
490
+ const p = d, D = p.morphTargetDictionary, E = p.morphTargetInfluences;
491
+ if (E)
492
492
  for (const L in D)
493
- L.toLowerCase() === x.toLowerCase() && (M[D[L]] = w);
493
+ L.toLowerCase() === x.toLowerCase() && (E[D[L]] = w);
494
494
  }
495
- function ht(u, x = 0.97) {
496
- if (!u) return;
497
- const w = u;
495
+ function ht(d, x = 0.97) {
496
+ if (!d) return;
497
+ const w = d;
498
498
  if (w.morphTargetInfluences)
499
499
  for (let p = 0; p < w.morphTargetInfluences.length; p++)
500
500
  w.morphTargetInfluences[p] *= x;
501
501
  }
502
502
  const Qt = Dt(
503
503
  ({
504
- avatarUrl: u,
504
+ avatarUrl: d,
505
505
  isPlayingRef: x,
506
506
  visemeQueueRef: w,
507
507
  audioContextRef: p,
508
508
  responseAudioStartTimeRef: D,
509
- adjustments: M,
509
+ adjustments: E,
510
510
  mood: L,
511
511
  expression: he,
512
512
  agentResponse: re,
@@ -514,33 +514,33 @@ const Qt = Dt(
514
514
  nextStartTimeRef: k,
515
515
  stopPlayback: Q,
516
516
  setIsSpeaking: U,
517
- expressionUrl: E,
517
+ expressionUrl: M,
518
518
  onExpressionFinished: ce
519
519
  }) => {
520
- const { scene: g } = Qe(u), ke = Qe(Bt), Z = et(
521
- () => ke.flatMap((d) => d.animations),
520
+ const { scene: g } = Qe(d), ke = Qe(Bt), Z = et(
521
+ () => ke.flatMap((f) => f.animations),
522
522
  [ke]
523
523
  ), pe = Qe(Ht), se = et(
524
- () => pe.flatMap((d) => d.animations),
524
+ () => pe.flatMap((f) => f.animations),
525
525
  [pe]
526
526
  ), J = o(null), I = o(null), m = o(null), $ = o([]), [R] = y(() => new Fe.AnimationMixer(g)), v = o({}), b = o(null), K = o(0), q = o(!1), le = o(0), ee = o(null);
527
527
  z(() => {
528
528
  if (!(!Z || !g)) {
529
- if (Z.forEach((d, c) => {
529
+ if (Z.forEach((f, c) => {
530
530
  const s = `idle_${c}`;
531
531
  if (!v.current[s]) {
532
- const n = R.clipAction(d, g);
532
+ const n = R.clipAction(f, g);
533
533
  n.name = s, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[s] = n;
534
534
  }
535
- }), se.forEach((d, c) => {
535
+ }), se.forEach((f, c) => {
536
536
  const s = `talk_${c}`;
537
537
  if (!v.current[s]) {
538
- const n = R.clipAction(d, g);
538
+ const n = R.clipAction(f, g);
539
539
  n.name = s, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[s] = n;
540
540
  }
541
541
  }), Z.length > 0) {
542
- const d = v.current.idle_0, c = b.current && R.existingAction(b.current.getClip());
543
- d && !c && (d.reset().fadeIn(0.5).play(), b.current = d);
542
+ const f = v.current.idle_0, c = b.current && R.existingAction(b.current.getClip());
543
+ f && !c && (f.reset().fadeIn(0.5).play(), b.current = f);
544
544
  }
545
545
  return () => {
546
546
  R.stopAllAction(), v.current = {}, b.current = null;
@@ -549,13 +549,13 @@ const Qt = Dt(
549
549
  }, [Z, se, g, R]);
550
550
  const Re = o("");
551
551
  z(() => {
552
- if (!E || !g || E === Re.current) return;
553
- Re.current = E, ee.current = E, new Ut().load(
554
- E,
552
+ if (!M || !g || M === Re.current) return;
553
+ Re.current = M, ee.current = M, new Ut().load(
554
+ M,
555
555
  (c) => {
556
556
  if (c.animations && c.animations.length > 0) {
557
557
  const s = c.animations[0], n = R.clipAction(s, g);
558
- if (n.name = `EXPR_${E}`, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[`EXPR_${E}`] = n, O && ee.current === E) {
558
+ if (n.name = `EXPR_${M}`, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[`EXPR_${M}`] = n, O && ee.current === M) {
559
559
  const h = b.current;
560
560
  n.reset().fadeIn(0.3).play(), h && h !== n && h.crossFadeTo(n, 0.3, !0), b.current = n, ee.current = null;
561
561
  }
@@ -563,11 +563,11 @@ const Qt = Dt(
563
563
  },
564
564
  void 0,
565
565
  (c) => {
566
- console.error(`[ANIMATION] Failed to load ${E}`, c);
566
+ console.error(`[ANIMATION] Failed to load ${M}`, c);
567
567
  }
568
568
  );
569
- }, [E, g, R, O]), z(() => {
570
- const d = (c) => {
569
+ }, [M, g, R, O]), z(() => {
570
+ const f = (c) => {
571
571
  const s = c.action, n = s.name || "";
572
572
  if (n.startsWith("idle_")) {
573
573
  const H = (parseInt(n.split("_")[1]) + 1) % Z.length, Y = v.current[`idle_${H}`];
@@ -590,7 +590,7 @@ const Qt = Dt(
590
590
  h && (h.reset().fadeIn(0.5).play(), s.crossFadeTo(h, 0.5, !0), b.current = h);
591
591
  }
592
592
  };
593
- return R.addEventListener("finished", d), () => R.removeEventListener("finished", d);
593
+ return R.addEventListener("finished", f), () => R.removeEventListener("finished", f);
594
594
  }, [
595
595
  R,
596
596
  Z,
@@ -599,29 +599,29 @@ const Qt = Dt(
599
599
  ce
600
600
  ]), z(() => {
601
601
  if (O && g) {
602
- const d = b.current, c = d?.name || "";
602
+ const f = b.current, c = f?.name || "";
603
603
  if (c.startsWith("idle_") || c.startsWith("talk_") || c === "") {
604
604
  const s = ee.current;
605
605
  if (s) {
606
606
  const n = v.current[`EXPR_${s}`];
607
607
  if (n) {
608
- n.reset().fadeIn(0.3).play(), d && d !== n && d.crossFadeTo(n, 0.3, !0), b.current = n, ee.current = null;
608
+ n.reset().fadeIn(0.3).play(), f && f !== n && f.crossFadeTo(n, 0.3, !0), b.current = n, ee.current = null;
609
609
  return;
610
610
  }
611
611
  }
612
612
  if (c.startsWith("idle_") || c === "") {
613
613
  const n = v.current.talk_0;
614
- n && (n.reset().fadeIn(0.5).play(), d && d.crossFadeTo(n, 0.5, !0), b.current = n);
614
+ n && (n.reset().fadeIn(0.5).play(), f && f.crossFadeTo(n, 0.5, !0), b.current = n);
615
615
  }
616
616
  }
617
617
  } else if (!O && g) {
618
- const d = b.current, c = d?.name || "";
618
+ const f = b.current, c = f?.name || "";
619
619
  if (c.startsWith("talk_") || c.startsWith("EXPR_")) {
620
620
  const s = v.current.idle_0;
621
- s && (s.reset().fadeIn(0.5).play(), d && d.crossFadeTo(s, 0.5, !0), b.current = s);
621
+ s && (s.reset().fadeIn(0.5).play(), f && f.crossFadeTo(s, 0.5, !0), b.current = s);
622
622
  }
623
623
  }
624
- }, [O, g, E]), z(() => {
624
+ }, [O, g, M]), z(() => {
625
625
  if (!g) return;
626
626
  g.traverse((s) => {
627
627
  if (s.isMesh && s.morphTargetDictionary) {
@@ -629,8 +629,8 @@ const Qt = Dt(
629
629
  (n.includes("head") || n.includes("avatar")) && (I.current = s, B(`[ANIMATION] Found head mesh: ${s.name}`)), n.includes("teeth") && (m.current = s, B(`[ANIMATION] Found teeth mesh: ${s.name}`));
630
630
  }
631
631
  });
632
- const d = I.current?.morphTargetDictionary;
633
- d && Object.keys(d).filter(
632
+ const f = I.current?.morphTargetDictionary;
633
+ f && Object.keys(f).filter(
634
634
  (s) => s.toLowerCase().includes("brow")
635
635
  );
636
636
  const c = [];
@@ -641,22 +641,22 @@ const Qt = Dt(
641
641
  }
642
642
  }), $.current = c, c.length > 0 && B("[ANIMATION] Meshes with brow morphs:", c.length);
643
643
  }, [g]);
644
- const Ue = (d, c = 1) => {
645
- const s = `viseme_${d}`.toLowerCase(), n = zt.find((h) => h.key.toLowerCase() === s);
644
+ const Ue = (f, c = 1) => {
645
+ const s = `viseme_${f}`.toLowerCase(), n = zt.find((h) => h.key.toLowerCase() === s);
646
646
  if (n)
647
647
  for (const h in n.mix) {
648
648
  const H = n.mix[h] * c;
649
649
  G(I.current, h, H), G(m.current, h, H);
650
650
  }
651
- }, Ce = (d) => {
652
- const c = He[d] ?? He.neutral;
651
+ }, Ce = (f) => {
652
+ const c = He[f] ?? He.neutral;
653
653
  for (const s in c)
654
654
  G(I.current, s, c[s]), G(m.current, s, c[s]);
655
655
  };
656
- return Tt((d, c) => {
656
+ return Tt((f, c) => {
657
657
  const s = Math.pow(0.88, 60 * c);
658
658
  ht(I.current, s), ht(m.current, s), Ce(L);
659
- const n = d.clock.elapsedTime;
659
+ const n = f.clock.elapsedTime;
660
660
  let h = 0;
661
661
  if (Math.floor(n) % 5 === 0 && Math.floor((n - c) % 5) !== 0) {
662
662
  let j = null;
@@ -677,33 +677,33 @@ const Qt = Dt(
677
677
  }
678
678
  const H = He[L] ?? He.neutral, Y = H.browInnerUp ?? 0, be = H.browOuterUpLeft ?? 0, me = H.browOuterUpRight ?? 0, Ae = n * Gt, ge = Ze * Math.sin(Ae), _e = Ze * 0.7 * Math.sin(Ae + 0.7), De = Ze * 0.7 * Math.sin(Ae + 1.3), we = (j) => Math.max(0, Math.min(1, j)), Oe = we(Y + ge), Le = we(be + _e), je = we(me + De), Ne = we(Oe + h);
679
679
  if (G(I.current, "browInnerUp", Ne), G(m.current, "browInnerUp", Ne), G(I.current, "browOuterUpLeft", Le), G(m.current, "browOuterUpLeft", Le), G(I.current, "browOuterUpRight", je), G(m.current, "browOuterUpRight", je), J.current) {
680
- const j = x.current ? 0 : M.rotation[1];
680
+ const j = x.current ? 0 : E.rotation[1];
681
681
  J.current.rotation.y = Fe.MathUtils.lerp(
682
682
  J.current.rotation.y,
683
683
  j,
684
684
  0.1
685
- ), J.current.position.set(...M.position), J.current.scale.setScalar(M.scale), J.current.rotation.x = M.rotation[0], J.current.rotation.z = M.rotation[2];
685
+ ), J.current.position.set(...E.position), J.current.scale.setScalar(E.scale), J.current.rotation.x = E.rotation[0], J.current.rotation.z = E.rotation[2];
686
686
  }
687
687
  if (x.current && p.current) {
688
688
  const j = p.current.currentTime, ve = (j - D.current) * 1e3 - -150;
689
- for (let Ee = 0; Ee < w.current.length; Ee++) {
690
- const Se = w.current[Ee];
689
+ for (let Me = 0; Me < w.current.length; Me++) {
690
+ const Se = w.current[Me];
691
691
  ve >= Se.vtime && ve < Se.vtime + Se.vduration && Ue(Se.viseme, Se.weight ?? 1);
692
692
  }
693
693
  j > k.current + 0.5 && (Q(), U(!1));
694
694
  }
695
- }), /* @__PURE__ */ f("group", { ref: J, children: /* @__PURE__ */ f("primitive", { object: g }) });
695
+ }), /* @__PURE__ */ u("group", { ref: J, children: /* @__PURE__ */ u("primitive", { object: g }) });
696
696
  }
697
697
  );
698
- function Zt(u) {
699
- return u ? u.charAt(0).toUpperCase() + u.slice(1).toLowerCase() : "";
698
+ function Zt(d) {
699
+ return d ? d.charAt(0).toUpperCase() + d.slice(1).toLowerCase() : "";
700
700
  }
701
701
  const en = ({
702
- token: u,
702
+ token: d,
703
703
  agentToken: x,
704
704
  onNavigationRequested: w
705
705
  } = {}) => {
706
- const p = u ?? x ?? "", D = Vt(p || void 0), [M, L] = y(""), [he, re] = y(""), [O, k] = y("Ready"), [Q, U] = y(!1), [E, ce] = y(!1), [g, ke] = y(
706
+ const p = d ?? x ?? "", D = Vt(p || void 0), [E, L] = y(""), [he, re] = y(""), [O, k] = y("Ready"), [Q, U] = y(!1), [M, ce] = y(!1), [g, ke] = y(
707
707
  () => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
708
708
  );
709
709
  z(() => {
@@ -714,13 +714,13 @@ const en = ({
714
714
  o([]);
715
715
  const v = o([]), b = o(0), K = o(0), q = o(0), le = o(0), ee = o(!1), [Re, Ue] = y(
716
716
  null
717
- ), Ce = o(null), [d, c] = y("neutral"), [s, n] = y(""), [h, H] = y(""), [Y, be] = y("Chat with us"), [me, Ae] = y(
717
+ ), Ce = o(null), [f, c] = y("neutral"), [s, n] = y(""), [h, H] = y(""), [Y, be] = y("Chat with us"), [me, Ae] = y(
718
718
  null
719
719
  ), [ge, _e] = y("hidden"), [De, we] = y(""), Oe = o(null), Le = o(ge);
720
720
  Le.current = ge;
721
- const [je, Ne] = y(null), j = o(null), ie = o(null), [W, ve] = y("hidden"), [Ee, Se] = y(""), Je = o(W);
721
+ const [je, Ne] = y(null), j = o(null), ie = o(null), [W, ve] = y("hidden"), [Me, Se] = y(""), Je = o(W);
722
722
  Je.current = W;
723
- const ue = o(""), Me = o(!1), Te = o(""), Ie = et(() => O === "Thinking..." || O === "Processing Voice..." ? O : me != null && me !== "" && me !== "none" && me !== "<none>" ? `Enter ${Zt(me)}` : null, [O, me]), We = Ie != null && Ie !== "";
723
+ const ue = o(""), Ee = o(!1), Te = o(""), Ie = et(() => O === "Thinking..." || O === "Processing Voice..." ? O : me != null && me !== "" && me !== "none" && me !== "<none>" ? `Enter ${Zt(me)}` : null, [O, me]), We = Ie != null && Ie !== "";
724
724
  z(() => {
725
725
  const e = Le.current;
726
726
  if (!(e === "exiting" || e === "entering")) {
@@ -785,10 +785,10 @@ const en = ({
785
785
  return null;
786
786
  }, bt = $e(() => {
787
787
  }, []), tt = (e) => {
788
- if (Me.current)
789
- e === "§" ? Me.current = !1 : (Te.current += e, re((t) => t + e));
788
+ if (Ee.current)
789
+ e === "§" ? Ee.current = !1 : (Te.current += e, re((t) => t + e));
790
790
  else if (e === "§") {
791
- Me.current = !0;
791
+ Ee.current = !0;
792
792
  return;
793
793
  } else
794
794
  for (ue.current += e; ue.current.includes(`
@@ -884,7 +884,7 @@ const en = ({
884
884
  oe.current && oe.current.state !== "inactive" && (oe.current.onstop = null, oe.current.stop(), oe.current.stream.getTracks().forEach((e) => e.stop()), Ye(null), ye.current && (ye.current.disconnect(), ye.current = null), de.current && de.current.state !== "closed" && (de.current.close(), de.current = null), Ge(!1), Pe.current = [], k("Ready"));
885
885
  };
886
886
  z(() => {
887
- if (!E) return;
887
+ if (!M) return;
888
888
  const e = () => {
889
889
  const t = q.current;
890
890
  if (t <= 0) return;
@@ -899,7 +899,7 @@ const en = ({
899
899
  Ue(A);
900
900
  };
901
901
  return clearInterval(Ce.current ?? void 0), Ce.current = setInterval(e, 90), () => clearInterval(Ce.current ?? void 0);
902
- }, [E, he, q.current]), z(() => {
902
+ }, [M, he, q.current]), z(() => {
903
903
  let e;
904
904
  return qe ? (ze(0), e = window.setInterval(() => {
905
905
  ze((t) => t + 1);
@@ -1005,7 +1005,7 @@ const en = ({
1005
1005
  const t = await e.arrayBuffer(), a = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), r = kt(a), l = new FileReader();
1006
1006
  l.readAsDataURL(r), l.onloadend = async () => {
1007
1007
  const _ = l.result.split(",")[1];
1008
- Ve(), L(""), ue.current = "", Me.current = !1;
1008
+ Ve(), L(""), ue.current = "", Ee.current = !1;
1009
1009
  const A = `${dt}/stt?token=${encodeURIComponent(
1010
1010
  p
1011
1011
  )}`, P = await fetch(A, {
@@ -1087,7 +1087,7 @@ const en = ({
1087
1087
  console.error("Audio Submission Error:", t), k("STT Failed"), U(!1);
1088
1088
  }
1089
1089
  }, At = async (e) => {
1090
- e && e.preventDefault(), Te.current = "", re(""), !(!M || Q) && await Lt(M);
1090
+ e && e.preventDefault(), Te.current = "", re(""), !(!E || Q) && await Lt(E);
1091
1091
  }, Be = (e) => {
1092
1092
  const t = e.split(/\r?\n/);
1093
1093
  let i = "", a = "";
@@ -1105,7 +1105,7 @@ const en = ({
1105
1105
  }, ot = (e, t) => {
1106
1106
  switch (e) {
1107
1107
  case "connected":
1108
- ue.current = "", Me.current = !1;
1108
+ ue.current = "", Ee.current = !1;
1109
1109
  break;
1110
1110
  case "text": {
1111
1111
  const i = t.delta ?? "";
@@ -1120,7 +1120,7 @@ const en = ({
1120
1120
  case "done": {
1121
1121
  const i = nt(), a = Te.current.trim(), r = [
1122
1122
  ...i,
1123
- { role: "user", content: M || "..." },
1123
+ { role: "user", content: E || "..." },
1124
1124
  { role: "assistant", content: a }
1125
1125
  ];
1126
1126
  _t(r), v.current = [...m.current], k("Ready"), U(!1), L("");
@@ -1133,7 +1133,7 @@ const en = ({
1133
1133
  }
1134
1134
  }
1135
1135
  }, Lt = async (e) => {
1136
- U(!0), k("Thinking..."), Te.current = "", ue.current = "", Me.current = !1, Ve(), q.current = 0, Ue(0);
1136
+ U(!0), k("Thinking..."), Te.current = "", ue.current = "", Ee.current = !1, Ve(), q.current = 0, Ue(0);
1137
1137
  const t = `${dt}/agent/chat?token=${encodeURIComponent(
1138
1138
  p
1139
1139
  )}`;
@@ -1194,7 +1194,7 @@ const en = ({
1194
1194
  } catch (i) {
1195
1195
  console.error("Chat Error:", i), k("Agent Failed"), U(!1);
1196
1196
  }
1197
- }, at = he.trim(), Ke = at && E ? at.slice(
1197
+ }, at = he.trim(), Ke = at && M ? at.slice(
1198
1198
  0,
1199
1199
  Re != null && Re > 0 ? Re : 0
1200
1200
  ) : "";
@@ -1202,16 +1202,16 @@ const en = ({
1202
1202
  const e = Je.current;
1203
1203
  e !== "exiting" && (Ke ? (Se(Ke), e === "hidden" && ve("entering")) : (e === "visible" || e === "entering") && ve("exiting"));
1204
1204
  }, [Ke, W]);
1205
- const Et = $e(() => {
1205
+ const Mt = $e(() => {
1206
1206
  const e = Je.current;
1207
1207
  e === "entering" ? ve("visible") : e === "exiting" && ve("hidden");
1208
1208
  }, []);
1209
1209
  return Ot(() => {
1210
1210
  const e = ie.current;
1211
1211
  e && (e.scrollTop = e.scrollHeight);
1212
- }, [Ee]), /* @__PURE__ */ ne("div", { className: "avatar-widget-container", children: [
1212
+ }, [Me]), /* @__PURE__ */ ne("div", { className: "avatar-widget-container", children: [
1213
1213
  /* @__PURE__ */ ne("div", { className: "avatar-input-area", children: [
1214
- ge !== "hidden" ? /* @__PURE__ */ f(
1214
+ ge !== "hidden" ? /* @__PURE__ */ u(
1215
1215
  "div",
1216
1216
  {
1217
1217
  className: `avatar-thinking-tab${ge === "exiting" ? " avatar-thinking-tab--exiting" : ge === "entering" ? " avatar-thinking-tab--entering" : ""}`,
@@ -1219,7 +1219,7 @@ const en = ({
1219
1219
  children: De
1220
1220
  }
1221
1221
  ) : null,
1222
- /* @__PURE__ */ f("div", { className: "avatar-input-container", children: /* @__PURE__ */ f(
1222
+ /* @__PURE__ */ u("div", { className: "avatar-input-container", children: /* @__PURE__ */ u(
1223
1223
  "div",
1224
1224
  {
1225
1225
  style: {
@@ -1229,7 +1229,7 @@ const en = ({
1229
1229
  height: "100%"
1230
1230
  },
1231
1231
  children: qe ? /* @__PURE__ */ ne("div", { className: "avatar-input-recording", children: [
1232
- /* @__PURE__ */ f(
1232
+ /* @__PURE__ */ u(
1233
1233
  "button",
1234
1234
  {
1235
1235
  type: "button",
@@ -1249,8 +1249,8 @@ const en = ({
1249
1249
  strokeLinejoin: "round",
1250
1250
  style: { display: "block" },
1251
1251
  children: [
1252
- /* @__PURE__ */ f("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1253
- /* @__PURE__ */ f("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1252
+ /* @__PURE__ */ u("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
1253
+ /* @__PURE__ */ u("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
1254
1254
  ]
1255
1255
  }
1256
1256
  )
@@ -1268,7 +1268,7 @@ const en = ({
1268
1268
  minWidth: 0
1269
1269
  },
1270
1270
  children: [
1271
- /* @__PURE__ */ f("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ f(ut, { analyser: vt }) }),
1271
+ /* @__PURE__ */ u("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ u(ut, { analyser: vt }) }),
1272
1272
  /* @__PURE__ */ ne(
1273
1273
  "span",
1274
1274
  {
@@ -1291,14 +1291,14 @@ const en = ({
1291
1291
  ]
1292
1292
  }
1293
1293
  ),
1294
- /* @__PURE__ */ f(
1294
+ /* @__PURE__ */ u(
1295
1295
  "button",
1296
1296
  {
1297
1297
  type: "button",
1298
1298
  className: "avatar-recording-confirm",
1299
1299
  onClick: yt,
1300
1300
  title: "Send",
1301
- children: /* @__PURE__ */ f(
1301
+ children: /* @__PURE__ */ u(
1302
1302
  "svg",
1303
1303
  {
1304
1304
  width: "18",
@@ -1310,13 +1310,13 @@ const en = ({
1310
1310
  strokeLinecap: "round",
1311
1311
  strokeLinejoin: "round",
1312
1312
  style: { display: "block" },
1313
- children: /* @__PURE__ */ f("polyline", { points: "20 6 9 17 4 12" })
1313
+ children: /* @__PURE__ */ u("polyline", { points: "20 6 9 17 4 12" })
1314
1314
  }
1315
1315
  )
1316
1316
  }
1317
1317
  )
1318
- ] }) : E ? /* @__PURE__ */ ne("div", { className: "avatar-input-speaking", children: [
1319
- /* @__PURE__ */ f(
1318
+ ] }) : M ? /* @__PURE__ */ ne("div", { className: "avatar-input-speaking", children: [
1319
+ /* @__PURE__ */ u(
1320
1320
  "div",
1321
1321
  {
1322
1322
  style: {
@@ -1326,20 +1326,20 @@ const en = ({
1326
1326
  alignItems: "center",
1327
1327
  paddingRight: "8px"
1328
1328
  },
1329
- children: /* @__PURE__ */ f(ut, { analyser: it })
1329
+ children: /* @__PURE__ */ u(ut, { analyser: it })
1330
1330
  }
1331
1331
  ),
1332
- /* @__PURE__ */ f(
1332
+ /* @__PURE__ */ u(
1333
1333
  "button",
1334
1334
  {
1335
1335
  type: "button",
1336
1336
  className: "avatar-speaking-stop",
1337
1337
  onClick: () => Ve(!0),
1338
1338
  title: "Stop",
1339
- children: /* @__PURE__ */ f("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
1339
+ children: /* @__PURE__ */ u("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
1340
1340
  }
1341
1341
  )
1342
- ] }) : Q ? /* @__PURE__ */ f(
1342
+ ] }) : Q ? /* @__PURE__ */ u(
1343
1343
  "div",
1344
1344
  {
1345
1345
  style: {
@@ -1349,7 +1349,7 @@ const en = ({
1349
1349
  alignItems: "center",
1350
1350
  justifyContent: "center"
1351
1351
  },
1352
- children: /* @__PURE__ */ f("div", { className: "avatar-input-loader" })
1352
+ children: /* @__PURE__ */ u("div", { className: "avatar-input-loader" })
1353
1353
  }
1354
1354
  ) : /* @__PURE__ */ ne(
1355
1355
  "form",
@@ -1362,12 +1362,12 @@ const en = ({
1362
1362
  alignItems: "center"
1363
1363
  },
1364
1364
  children: [
1365
- /* @__PURE__ */ f(
1365
+ /* @__PURE__ */ u(
1366
1366
  "input",
1367
1367
  {
1368
1368
  id: "avatar-text-input",
1369
1369
  type: "text",
1370
- value: M,
1370
+ value: E,
1371
1371
  onChange: (e) => L(e.target.value),
1372
1372
  placeholder: "Ask me anything",
1373
1373
  disabled: Q,
@@ -1375,7 +1375,7 @@ const en = ({
1375
1375
  style: { width: "100%", height: "100%" }
1376
1376
  }
1377
1377
  ),
1378
- M.trim() === "" ? /* @__PURE__ */ f(
1378
+ E.trim() === "" ? /* @__PURE__ */ u(
1379
1379
  "button",
1380
1380
  {
1381
1381
  type: "button",
@@ -1392,14 +1392,14 @@ const en = ({
1392
1392
  fill: "none",
1393
1393
  xmlns: "http://www.w3.org/2000/svg",
1394
1394
  children: [
1395
- /* @__PURE__ */ f(
1395
+ /* @__PURE__ */ u(
1396
1396
  "path",
1397
1397
  {
1398
1398
  d: "M12 14C13.66 14 15 12.66 15 11V5C15 3.34 13.66 2 12 2C10.34 2 9 3.34 9 5V11C9 12.66 10.34 14 12 14Z",
1399
1399
  fill: "white"
1400
1400
  }
1401
1401
  ),
1402
- /* @__PURE__ */ f(
1402
+ /* @__PURE__ */ u(
1403
1403
  "path",
1404
1404
  {
1405
1405
  d: "M17 11C17 13.76 14.76 16 12 16C9.24 16 7 13.76 7 11H5C5 14.53 7.61 17.43 11 17.93V21H13V17.93C16.39 17.43 19 14.53 19 11H17Z",
@@ -1410,7 +1410,7 @@ const en = ({
1410
1410
  }
1411
1411
  )
1412
1412
  }
1413
- ) : /* @__PURE__ */ f(
1413
+ ) : /* @__PURE__ */ u(
1414
1414
  "button",
1415
1415
  {
1416
1416
  type: "submit",
@@ -1418,7 +1418,26 @@ const en = ({
1418
1418
  disabled: Q,
1419
1419
  style: { backgroundColor: "#1e4a5e" },
1420
1420
  title: "Send",
1421
- children: /* @__PURE__ */ f("img", { src: "/assets/leadmoji-logo-send.png", alt: "Send", width: 24, height: 24 })
1421
+ children: /* @__PURE__ */ u(
1422
+ "svg",
1423
+ {
1424
+ width: 24,
1425
+ height: 24,
1426
+ viewBox: "0 0 24 24",
1427
+ fill: "none",
1428
+ "aria-hidden": "true",
1429
+ children: /* @__PURE__ */ u(
1430
+ "path",
1431
+ {
1432
+ d: "M19 12H5M19 12L14 17M19 12L14 7",
1433
+ stroke: "white",
1434
+ strokeWidth: "2",
1435
+ strokeLinecap: "round",
1436
+ strokeLinejoin: "round"
1437
+ }
1438
+ )
1439
+ }
1440
+ )
1422
1441
  }
1423
1442
  )
1424
1443
  ]
@@ -1427,16 +1446,16 @@ const en = ({
1427
1446
  }
1428
1447
  ) })
1429
1448
  ] }),
1430
- /* @__PURE__ */ f("div", { className: "avatar-wrapper", children: /* @__PURE__ */ ne("div", { className: "avatar-scene-wrapper", children: [
1431
- W !== "hidden" && /* @__PURE__ */ f(
1449
+ /* @__PURE__ */ u("div", { className: "avatar-wrapper", children: /* @__PURE__ */ ne("div", { className: "avatar-scene-wrapper", children: [
1450
+ W !== "hidden" && /* @__PURE__ */ u(
1432
1451
  "div",
1433
1452
  {
1434
1453
  className: `avatar-bubble${W === "entering" ? " avatar-bubble--entering" : W === "exiting" ? " avatar-bubble--exiting" : ""}`,
1435
- onAnimationEnd: Et,
1436
- children: /* @__PURE__ */ f("div", { ref: ie, className: "avatar-bubble__content", children: Ee })
1454
+ onAnimationEnd: Mt,
1455
+ children: /* @__PURE__ */ u("div", { ref: ie, className: "avatar-bubble__content", children: Me })
1437
1456
  }
1438
1457
  ),
1439
- /* @__PURE__ */ f(
1458
+ /* @__PURE__ */ u(
1440
1459
  "div",
1441
1460
  {
1442
1461
  className: "avatar-canvas-layer",
@@ -1450,11 +1469,11 @@ const en = ({
1450
1469
  dpr: 1.8,
1451
1470
  style: { pointerEvents: "none", width: "100%", height: "100%" },
1452
1471
  children: [
1453
- /* @__PURE__ */ f(Kt, { target: Jt }),
1454
- /* @__PURE__ */ f("ambientLight", { intensity: 0.7 }),
1455
- /* @__PURE__ */ f("directionalLight", { position: [0, 2, 2], intensity: 1 }),
1456
- /* @__PURE__ */ f(Mt, { preset: "city" }),
1457
- /* @__PURE__ */ f(Ft, { fallback: null, children: D !== null && /* @__PURE__ */ f(
1472
+ /* @__PURE__ */ u(Kt, { target: Jt }),
1473
+ /* @__PURE__ */ u("ambientLight", { intensity: 0.7 }),
1474
+ /* @__PURE__ */ u("directionalLight", { position: [0, 2, 2], intensity: 1 }),
1475
+ /* @__PURE__ */ u(Et, { preset: "city" }),
1476
+ /* @__PURE__ */ u(Ft, { fallback: null, children: D !== null && /* @__PURE__ */ u(
1458
1477
  Qt,
1459
1478
  {
1460
1479
  avatarUrl: D,
@@ -1463,10 +1482,10 @@ const en = ({
1463
1482
  audioContextRef: $,
1464
1483
  responseAudioStartTimeRef: b,
1465
1484
  adjustments: jt,
1466
- mood: d,
1485
+ mood: f,
1467
1486
  expression: s,
1468
1487
  agentResponse: he,
1469
- isSpeaking: E,
1488
+ isSpeaking: M,
1470
1489
  nextStartTimeRef: K,
1471
1490
  stopPlayback: Ve,
1472
1491
  setIsSpeaking: ce,
@@ -1482,12 +1501,12 @@ const en = ({
1482
1501
  ] }) })
1483
1502
  ] });
1484
1503
  }, an = ({
1485
- token: u,
1504
+ token: d,
1486
1505
  onNavigationRequested: x
1487
- }) => /* @__PURE__ */ f(
1506
+ }) => /* @__PURE__ */ u(
1488
1507
  en,
1489
1508
  {
1490
- token: u,
1509
+ token: d,
1491
1510
  onNavigationRequested: x
1492
1511
  }
1493
1512
  );