@streamoji/avatar-widget 0.2.5 → 0.2.6

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,100 +1,100 @@
1
- import { jsx as l, jsxs as se } from "react/jsx-runtime";
2
- import { useGLTF as at, Environment as jt } from "@react-three/drei";
3
- import { useFrame as Jt, Canvas as qt, useThree as Gt } from "@react-three/fiber";
4
- import { memo as zt, useMemo as ut, useRef as c, useState as _, useEffect as P, useCallback as Ye, useLayoutEffect as Yt, Suspense as Qt } from "react";
5
- import * as We from "three";
6
- import { GLTFLoader as Xt } from "three/examples/jsm/loaders/GLTFLoader.js";
7
- const ct = "https://ai.streamoji.com", U = (...f) => {
8
- }, Kt = (...f) => {
9
- }, At = ({ analyser: f }) => {
10
- const L = c(null), w = c(null);
1
+ import { jsx as l, jsxs as oe } from "react/jsx-runtime";
2
+ import { useGLTF as ct, Environment as zt } from "@react-three/drei";
3
+ import { useFrame as Yt, Canvas as Qt, useThree as Xt } from "@react-three/fiber";
4
+ import { memo as Kt, useMemo as dt, useRef as c, useState as b, useEffect as P, useCallback as Qe, useLayoutEffect as Zt, Suspense as en } from "react";
5
+ import * as Ve from "three";
6
+ import { GLTFLoader as tn } from "three/examples/jsm/loaders/GLTFLoader.js";
7
+ const lt = "https://ai.streamoji.com", B = (...f) => {
8
+ }, nn = (...f) => {
9
+ }, Tt = ({ analyser: f }) => {
10
+ const A = c(null), w = c(null);
11
11
  return P(() => {
12
- const g = L.current;
12
+ const g = A.current;
13
13
  if (!g) return;
14
14
  const T = g.getContext("2d", { alpha: !0 });
15
15
  if (!T) return;
16
- let W, E = null;
16
+ let V, E = null;
17
17
  f && (f.fftSize = 128, E = new Uint8Array(f.frequencyBinCount));
18
- const Z = () => {
19
- W = requestAnimationFrame(Z), (g.width !== g.offsetWidth || g.height !== g.offsetHeight) && (g.width = g.offsetWidth, g.height = g.offsetHeight);
20
- const ie = g.width, F = g.height;
21
- if (ie === 0 || F === 0) return;
22
- const H = F / 2;
23
- T.clearRect(0, 0, ie, F), T.fillStyle = "#1e293b";
24
- const b = 2, p = b + 2, Y = ie * 0.95, $ = Math.floor(Y / p);
18
+ const ee = () => {
19
+ V = requestAnimationFrame(ee), (g.width !== g.offsetWidth || g.height !== g.offsetHeight) && (g.width = g.offsetWidth, g.height = g.offsetHeight);
20
+ const ae = g.width, N = g.height;
21
+ if (ae === 0 || N === 0) return;
22
+ const U = N / 2;
23
+ T.clearRect(0, 0, ae, N), T.fillStyle = "#1e293b";
24
+ const _ = 2, m = _ + 2, Y = ae * 0.95, $ = Math.floor(Y / m);
25
25
  (!w.current || w.current.length !== $) && (w.current = new Float32Array($).fill(2));
26
- const he = $ * p, k = (ie - he) / 2;
26
+ const pe = $ * m, k = (ae - pe) / 2;
27
27
  f && E && f.getByteFrequencyData(E);
28
- const Ve = E ? E.length : 0, q = Math.floor(Ve * 0.7) / $, pe = new Float32Array($);
28
+ const He = E ? E.length : 0, q = Math.floor(He * 0.7) / $, ge = new Float32Array($);
29
29
  for (let I = 0; I < $; I++) {
30
30
  let C = 0;
31
31
  if (E && q > 0) {
32
- const me = Math.floor(I * q), R = Math.floor((I + 1) * q);
33
- for (let v = me; v < R; v++) {
32
+ const be = Math.floor(I * q), L = Math.floor((I + 1) * q);
33
+ for (let v = be; v < L; v++) {
34
34
  const y = E[v] || 0;
35
35
  y > C && (C = y);
36
36
  }
37
37
  }
38
38
  C < 10 && (C = 0);
39
- const B = C / 255, M = C > 0 ? Math.max(2, Math.pow(B, 1.4) * F * 0.25) : 2;
40
- pe[I] = M;
39
+ const W = C / 255, M = C > 0 ? Math.max(2, Math.pow(W, 1.4) * N * 0.25) : 2;
40
+ ge[I] = M;
41
41
  }
42
42
  for (let I = 0; I < $; I++) {
43
- const C = $ - 1 - I, B = Math.max(pe[I], pe[C]), M = w.current[I] + (B - w.current[I]) * 0.3;
43
+ const C = $ - 1 - I, W = Math.max(ge[I], ge[C]), M = w.current[I] + (W - w.current[I]) * 0.3;
44
44
  w.current[I] = M;
45
- const me = k + I * p, R = H - M / 2;
46
- T.beginPath(), T.roundRect ? T.roundRect(me, R, b, M, 4) : T.fillRect(me, R, b, M), T.fill();
45
+ const be = k + I * m, L = U - M / 2;
46
+ T.beginPath(), T.roundRect ? T.roundRect(be, L, _, M, 4) : T.fillRect(be, L, _, M), T.fill();
47
47
  }
48
48
  };
49
- return Z(), () => {
50
- cancelAnimationFrame(W);
49
+ return ee(), () => {
50
+ cancelAnimationFrame(V);
51
51
  };
52
52
  }, [f]), /* @__PURE__ */ l(
53
53
  "canvas",
54
54
  {
55
- ref: L,
55
+ ref: A,
56
56
  style: { width: "100%", height: "100%", display: "block" }
57
57
  }
58
58
  );
59
- }, Zt = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", Lt = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/fullbodyavatarmale.glb";
60
- async function en(f) {
61
- const L = await crypto.subtle.digest(
59
+ }, rn = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", Et = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/fullbodyavatarmale.glb";
60
+ async function sn(f) {
61
+ const A = await crypto.subtle.digest(
62
62
  "SHA-256",
63
63
  new TextEncoder().encode(f)
64
64
  );
65
- return Array.from(new Uint8Array(L)).map((w) => w.toString(16).padStart(2, "0")).join("");
65
+ return Array.from(new Uint8Array(A)).map((w) => w.toString(16).padStart(2, "0")).join("");
66
66
  }
67
- function tn(f) {
68
- const [L, w] = _(null);
67
+ function on(f) {
68
+ const [A, w] = b(null);
69
69
  return P(() => {
70
70
  if (!f) {
71
71
  w(null);
72
72
  return;
73
73
  }
74
74
  let g = !1;
75
- return en(f).then((T) => {
75
+ return sn(f).then((T) => {
76
76
  if (g) return;
77
- const W = `${Zt}/${T}.glb`;
78
- fetch(W, { method: "HEAD" }).then((E) => {
79
- g || w(E.ok ? W : Lt);
77
+ const V = `${rn}/${T}.glb`;
78
+ fetch(V, { method: "HEAD" }).then((E) => {
79
+ g || w(E.ok ? V : Et);
80
80
  }).catch(() => {
81
- g || w(Lt);
81
+ g || w(Et);
82
82
  });
83
83
  }), () => {
84
84
  g = !0;
85
85
  };
86
- }, [f]), L;
86
+ }, [f]), A;
87
87
  }
88
- const nn = [
88
+ const an = [
89
89
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
90
90
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_002.glb",
91
91
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_002.glb",
92
92
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_005.glb"
93
- ], rn = [
93
+ ], cn = [
94
94
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_001.glb",
95
95
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb",
96
96
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb"
97
- ], sn = [
97
+ ], ln = [
98
98
  {
99
99
  id: "m_expr_01",
100
100
  name: "Friendly Wave",
@@ -260,17 +260,17 @@ const nn = [
260
260
  name: "Take It Easy",
261
261
  url: "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_006.glb"
262
262
  }
263
- ], on = [
263
+ ], un = [
264
264
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_005.glb",
265
265
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_007.glb"
266
- ], an = {
266
+ ], dn = {
267
267
  zoom: 0.85,
268
268
  position: [0.15, -0.8, 0],
269
269
  scale: 1.5,
270
270
  rotation: [0.15, 0.02, 0]
271
- }, cn = [-0.45, 1.9, 0.1], ln = {
271
+ }, fn = [-0.45, 1.9, 0.1], hn = {
272
272
  browInnerUp: 0.2
273
- }, lt = 0.18, un = 1, Qe = {
273
+ }, ut = 0.18, mn = 1, It = "__branding__", Xe = {
274
274
  neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
275
275
  happy: {
276
276
  mouthSmileLeft: 0.2,
@@ -352,7 +352,7 @@ const nn = [
352
352
  mouthUpperUpLeft: 0.1,
353
353
  mouthUpperUpRight: 0.1
354
354
  }
355
- }, dn = [
355
+ }, pn = [
356
356
  { key: "viseme_aa", mix: { jawOpen: 0.6 } },
357
357
  {
358
358
  key: "viseme_E",
@@ -448,7 +448,7 @@ const nn = [
448
448
  }
449
449
  },
450
450
  { key: "viseme_sil", mix: {} }
451
- ], fn = {
451
+ ], gn = {
452
452
  aei: [
453
453
  { v: "E", w: 0.8 },
454
454
  { v: "I", w: 0.2 }
@@ -477,109 +477,109 @@ const nn = [
477
477
  ],
478
478
  sil: [{ v: "sil", w: 1 }]
479
479
  };
480
- function hn(f) {
480
+ function bn(f) {
481
481
  if (!f) return [{ v: "sil", w: 1 }];
482
- const L = f.toLowerCase();
483
- return fn[L] ?? [{ v: "sil", w: 1 }];
482
+ const A = f.toLowerCase();
483
+ return gn[A] ?? [{ v: "sil", w: 1 }];
484
484
  }
485
- function pn({ target: f }) {
486
- const { camera: L } = Gt();
485
+ function _n({ target: f }) {
486
+ const { camera: A } = Xt();
487
487
  return P(() => {
488
- L.lookAt(...f);
489
- }, [L, f]), null;
488
+ A.lookAt(...f);
489
+ }, [A, f]), null;
490
490
  }
491
- function z(f, L, w) {
491
+ function z(f, A, w) {
492
492
  if (!f || !f.morphTargetDictionary)
493
493
  return;
494
- const g = f, T = g.morphTargetDictionary, W = g.morphTargetInfluences;
495
- if (W)
494
+ const g = f, T = g.morphTargetDictionary, V = g.morphTargetInfluences;
495
+ if (V)
496
496
  for (const E in T)
497
- E.toLowerCase() === L.toLowerCase() && (W[T[E]] = w);
497
+ E.toLowerCase() === A.toLowerCase() && (V[T[E]] = w);
498
498
  }
499
- function Rt(f, L = 0.97) {
499
+ function Mt(f, A = 0.97) {
500
500
  if (!f) return;
501
501
  const w = f;
502
502
  if (w.morphTargetInfluences)
503
503
  for (let g = 0; g < w.morphTargetInfluences.length; g++)
504
- w.morphTargetInfluences[g] *= L;
504
+ w.morphTargetInfluences[g] *= A;
505
505
  }
506
- const mn = zt(
506
+ const wn = Kt(
507
507
  ({
508
508
  avatarUrl: f,
509
- isPlayingRef: L,
509
+ isPlayingRef: A,
510
510
  visemeQueueRef: w,
511
511
  audioContextRef: g,
512
512
  responseAudioStartTimeRef: T,
513
- adjustments: W,
513
+ adjustments: V,
514
514
  mood: E,
515
- expression: Z,
516
- agentResponse: ie,
517
- isSpeaking: F,
518
- nextStartTimeRef: H,
519
- stopPlayback: b,
520
- setIsSpeaking: oe,
521
- expressionUrl: p,
515
+ expression: ee,
516
+ agentResponse: ae,
517
+ isSpeaking: N,
518
+ nextStartTimeRef: U,
519
+ stopPlayback: _,
520
+ setIsSpeaking: ce,
521
+ expressionUrl: m,
522
522
  onExpressionFinished: Y,
523
523
  isNudgeResponse: $,
524
- avatarGender: he
524
+ avatarGender: pe
525
525
  }) => {
526
- const { scene: k } = at(f), ye = at(he === "female" ? rn : nn), q = ut(
527
- () => ye.flatMap((d) => d.animations),
528
- [ye]
529
- ), pe = at(on), I = ut(
530
- () => pe.flatMap((d) => d.animations),
531
- [pe]
532
- ), C = c(null), B = c(null), M = c(null), me = c([]), [R] = _(() => new We.AnimationMixer(k)), v = c({}), y = c(null), ge = c(0), Te = c(!1), be = c(0), ae = c(null);
526
+ const { scene: k } = ct(f), xe = ct(pe === "female" ? cn : an), q = dt(
527
+ () => xe.flatMap((d) => d.animations),
528
+ [xe]
529
+ ), ge = ct(un), I = dt(
530
+ () => ge.flatMap((d) => d.animations),
531
+ [ge]
532
+ ), C = c(null), W = c(null), M = c(null), be = c([]), [L] = b(() => new Ve.AnimationMixer(k)), v = c({}), y = c(null), _e = c(0), Ie = c(!1), we = c(0), le = c(null);
533
533
  P(() => {
534
534
  if (!(!q || !k)) {
535
535
  if (q.forEach((d, u) => {
536
536
  const i = `idle_${u}`;
537
537
  if (!v.current[i]) {
538
- const r = R.clipAction(d, k);
539
- r.name = i, r.setLoop(We.LoopOnce, 1), r.clampWhenFinished = !0, v.current[i] = r;
538
+ const r = L.clipAction(d, k);
539
+ r.name = i, r.setLoop(Ve.LoopOnce, 1), r.clampWhenFinished = !0, v.current[i] = r;
540
540
  }
541
541
  }), I.forEach((d, u) => {
542
542
  const i = `talk_${u}`;
543
543
  if (!v.current[i]) {
544
- const r = R.clipAction(d, k);
545
- r.name = i, r.setLoop(We.LoopOnce, 1), r.clampWhenFinished = !0, v.current[i] = r;
544
+ const r = L.clipAction(d, k);
545
+ r.name = i, r.setLoop(Ve.LoopOnce, 1), r.clampWhenFinished = !0, v.current[i] = r;
546
546
  }
547
547
  }), q.length > 0) {
548
- const d = v.current.idle_0, u = y.current && R.existingAction(y.current.getClip());
548
+ const d = v.current.idle_0, u = y.current && L.existingAction(y.current.getClip());
549
549
  d && !u && (d.reset().fadeIn(0.5).play(), y.current = d);
550
550
  }
551
551
  return () => {
552
- R.stopAllAction(), v.current = {}, y.current = null;
552
+ L.stopAllAction(), v.current = {}, y.current = null;
553
553
  };
554
554
  }
555
- }, [q, I, k, R]);
556
- const _e = c("");
555
+ }, [q, I, k, L]);
556
+ const ve = c("");
557
557
  P(() => {
558
- if (!p || !k || p === _e.current) return;
559
- _e.current = p, ae.current = p, new Xt().load(
560
- p,
558
+ if (!m || !k || m === ve.current) return;
559
+ ve.current = m, le.current = m, new tn().load(
560
+ m,
561
561
  (u) => {
562
562
  if (u.animations && u.animations.length > 0) {
563
- const i = u.animations[0], r = R.clipAction(i, k);
564
- if (r.name = `EXPR_${p}`, r.setLoop(We.LoopOnce, 1), r.clampWhenFinished = !0, v.current[`EXPR_${p}`] = r, F && ae.current === p) {
563
+ const i = u.animations[0], r = L.clipAction(i, k);
564
+ if (r.name = `EXPR_${m}`, r.setLoop(Ve.LoopOnce, 1), r.clampWhenFinished = !0, v.current[`EXPR_${m}`] = r, N && le.current === m) {
565
565
  const h = y.current;
566
- r.reset().fadeIn(0.3).play(), h && h !== r && h.crossFadeTo(r, 0.3, !0), y.current = r, ae.current = null;
566
+ r.reset().fadeIn(0.3).play(), h && h !== r && h.crossFadeTo(r, 0.3, !0), y.current = r, le.current = null;
567
567
  }
568
568
  }
569
569
  },
570
570
  void 0,
571
571
  (u) => {
572
- console.error(`[ANIMATION] Failed to load ${p}`, u);
572
+ console.error(`[ANIMATION] Failed to load ${m}`, u);
573
573
  }
574
574
  );
575
- }, [p, k, R, F]), P(() => {
575
+ }, [m, k, L, N]), P(() => {
576
576
  const d = (u) => {
577
577
  const i = u.action, r = i.name || "";
578
578
  if (r.startsWith("idle_")) {
579
579
  const G = (parseInt(r.split("_")[1]) + 1) % q.length, Q = v.current[`idle_${G}`];
580
580
  Q && (Q.reset().fadeIn(0.5).play(), i.crossFadeTo(Q, 0.5, !0), y.current = Q);
581
581
  } else if (r.startsWith("EXPR_")) {
582
- if (F) {
582
+ if (N) {
583
583
  const h = v.current.talk_0;
584
584
  h && (h.reset().fadeIn(0.5).play(), i.crossFadeTo(h, 0.5, !0), y.current = h);
585
585
  } else {
@@ -588,7 +588,7 @@ const mn = zt(
588
588
  }
589
589
  Y && Y();
590
590
  } else if (r.startsWith("talk_"))
591
- if (F && !$) {
591
+ if (N && !$) {
592
592
  const G = (parseInt(r.split("_")[1]) + 1) % I.length, Q = v.current[`talk_${G}`];
593
593
  Q && (Q.reset().fadeIn(0.3).play(), i.crossFadeTo(Q, 0.3, !0), y.current = Q);
594
594
  } else {
@@ -596,23 +596,23 @@ const mn = zt(
596
596
  h && (h.reset().fadeIn(0.5).play(), i.crossFadeTo(h, 0.5, !0), y.current = h);
597
597
  }
598
598
  };
599
- return R.addEventListener("finished", d), () => R.removeEventListener("finished", d);
599
+ return L.addEventListener("finished", d), () => L.removeEventListener("finished", d);
600
600
  }, [
601
- R,
601
+ L,
602
602
  q,
603
603
  I,
604
- F,
604
+ N,
605
605
  $,
606
606
  Y
607
607
  ]), P(() => {
608
- if (F && k) {
608
+ if (N && k) {
609
609
  const d = y.current, u = d?.name || "";
610
610
  if (u.startsWith("idle_") || u.startsWith("talk_") || u === "") {
611
- const i = ae.current;
611
+ const i = le.current;
612
612
  if (i) {
613
613
  const r = v.current[`EXPR_${i}`];
614
614
  if (r) {
615
- r.reset().fadeIn(0.3).play(), d && d !== r && d.crossFadeTo(r, 0.3, !0), y.current = r, ae.current = null;
615
+ r.reset().fadeIn(0.3).play(), d && d !== r && d.crossFadeTo(r, 0.3, !0), y.current = r, le.current = null;
616
616
  return;
617
617
  }
618
618
  }
@@ -621,22 +621,22 @@ const mn = zt(
621
621
  r && (r.reset().fadeIn(0.5).play(), d && d.crossFadeTo(r, 0.5, !0), y.current = r);
622
622
  }
623
623
  }
624
- } else if (!F && k) {
624
+ } else if (!N && k) {
625
625
  const d = y.current, u = d?.name || "";
626
626
  if (u.startsWith("talk_") || u.startsWith("EXPR_")) {
627
627
  const i = v.current.idle_0;
628
628
  i && (i.reset().fadeIn(0.5).play(), d && d.crossFadeTo(i, 0.5, !0), y.current = i);
629
629
  }
630
630
  }
631
- }, [F, k, p]), P(() => {
631
+ }, [N, k, m]), P(() => {
632
632
  if (!k) return;
633
633
  k.traverse((i) => {
634
634
  if (i.isMesh && i.morphTargetDictionary) {
635
635
  const r = i.name.toLowerCase();
636
- (r.includes("head") || r.includes("avatar")) && (B.current = i, U(`[ANIMATION] Found head mesh: ${i.name}`)), r.includes("teeth") && (M.current = i, U(`[ANIMATION] Found teeth mesh: ${i.name}`));
636
+ (r.includes("head") || r.includes("avatar")) && (W.current = i, B(`[ANIMATION] Found head mesh: ${i.name}`)), r.includes("teeth") && (M.current = i, B(`[ANIMATION] Found teeth mesh: ${i.name}`));
637
637
  }
638
638
  });
639
- const d = B.current?.morphTargetDictionary;
639
+ const d = W.current?.morphTargetDictionary;
640
640
  d && Object.keys(d).filter(
641
641
  (i) => i.toLowerCase().includes("brow")
642
642
  );
@@ -646,126 +646,138 @@ const mn = zt(
646
646
  const h = i.morphTargetDictionary;
647
647
  h && Object.keys(h).some((G) => G.toLowerCase().includes("brow")) && u.push(i);
648
648
  }
649
- }), me.current = u, u.length > 0 && U("[ANIMATION] Meshes with brow morphs:", u.length);
649
+ }), be.current = u, u.length > 0 && B("[ANIMATION] Meshes with brow morphs:", u.length);
650
650
  }, [k]);
651
651
  const Ne = (d, u = 1) => {
652
- const i = `viseme_${d}`.toLowerCase(), r = dn.find((h) => h.key.toLowerCase() === i);
652
+ const i = `viseme_${d}`.toLowerCase(), r = pn.find((h) => h.key.toLowerCase() === i);
653
653
  if (r)
654
654
  for (const h in r.mix) {
655
655
  const G = r.mix[h] * u;
656
- z(B.current, h, G), z(M.current, h, G);
656
+ z(W.current, h, G), z(M.current, h, G);
657
657
  }
658
- }, Se = (d) => {
659
- const u = Qe[d] ?? Qe.neutral;
658
+ }, ke = (d) => {
659
+ const u = Xe[d] ?? Xe.neutral;
660
660
  for (const i in u)
661
- z(B.current, i, u[i]), z(M.current, i, u[i]);
661
+ z(W.current, i, u[i]), z(M.current, i, u[i]);
662
662
  };
663
- return Jt((d, u) => {
663
+ return Yt((d, u) => {
664
664
  const i = Math.pow(0.88, 60 * u);
665
- Rt(B.current, i), Rt(M.current, i), Se(E);
665
+ Mt(W.current, i), Mt(M.current, i), ke(E);
666
666
  const r = d.clock.elapsedTime;
667
667
  let h = 0;
668
668
  if (Math.floor(r) % 5 === 0 && Math.floor((r - u) % 5) !== 0) {
669
669
  let J = null;
670
- k.traverse((te) => {
671
- te.name.toLowerCase().includes("hips") && (J = te);
670
+ k.traverse((ne) => {
671
+ ne.name.toLowerCase().includes("hips") && (J = ne);
672
672
  });
673
- const ve = J ? `Hips Y: ${J.position.y.toFixed(4)}` : "Hips not found";
674
- U(`[ANIMATION] Mixer Time: ${R.time.toFixed(2)}, ${ve}`);
673
+ const ye = J ? `Hips Y: ${J.position.y.toFixed(4)}` : "Hips not found";
674
+ B(`[ANIMATION] Mixer Time: ${L.time.toFixed(2)}, ${ye}`);
675
675
  }
676
- if (R.update(u), r > ge.current && !Te.current && (Te.current = !0, be.current = r), Te.current) {
677
- const ve = (r - be.current) / 0.3;
678
- if (ve >= 1)
679
- Te.current = !1, ge.current = r + 2 + Math.random() * 5;
676
+ if (L.update(u), r > _e.current && !Ie.current && (Ie.current = !0, we.current = r), Ie.current) {
677
+ const ye = (r - we.current) / 0.3;
678
+ if (ye >= 1)
679
+ Ie.current = !1, _e.current = r + 2 + Math.random() * 5;
680
680
  else {
681
- const te = ve < 0.5 ? ve * 2 : (1 - ve) * 2;
682
- z(B.current, "eyeBlinkLeft", te), z(B.current, "eyeBlinkRight", te), z(M.current, "eyeBlinkLeft", te), z(M.current, "eyeBlinkRight", te), h = te * ln.browInnerUp;
681
+ const ne = ye < 0.5 ? ye * 2 : (1 - ye) * 2;
682
+ z(W.current, "eyeBlinkLeft", ne), z(W.current, "eyeBlinkRight", ne), z(M.current, "eyeBlinkLeft", ne), z(M.current, "eyeBlinkRight", ne), h = ne * hn.browInnerUp;
683
683
  }
684
684
  }
685
- const G = Qe[E] ?? Qe.neutral, Q = G.browInnerUp ?? 0, Xe = G.browOuterUpLeft ?? 0, He = G.browOuterUpRight ?? 0, Fe = r * un, xe = lt * Math.sin(Fe), we = lt * 0.7 * Math.sin(Fe + 0.7), $e = lt * 0.7 * Math.sin(Fe + 1.3), ee = (J) => Math.max(0, Math.min(1, J)), ke = ee(Q + xe), Ae = ee(Xe + we), Ue = ee(He + $e), Ee = ee(ke + h);
686
- if (z(B.current, "browInnerUp", Ee), z(M.current, "browInnerUp", Ee), z(B.current, "browOuterUpLeft", Ae), z(M.current, "browOuterUpLeft", Ae), z(B.current, "browOuterUpRight", Ue), z(M.current, "browOuterUpRight", Ue), C.current) {
687
- const J = L.current ? 0 : W.rotation[1];
688
- C.current.rotation.y = We.MathUtils.lerp(
685
+ const G = Xe[E] ?? Xe.neutral, Q = G.browInnerUp ?? 0, Ke = G.browOuterUpLeft ?? 0, $e = G.browOuterUpRight ?? 0, Ue = r * mn, Re = ut * Math.sin(Ue), K = ut * 0.7 * Math.sin(Ue + 0.7), je = ut * 0.7 * Math.sin(Ue + 1.3), te = (J) => Math.max(0, Math.min(1, J)), Ae = te(Q + Re), Le = te(Ke + K), Be = te($e + je), Me = te(Ae + h);
686
+ if (z(W.current, "browInnerUp", Me), z(M.current, "browInnerUp", Me), z(W.current, "browOuterUpLeft", Le), z(M.current, "browOuterUpLeft", Le), z(W.current, "browOuterUpRight", Be), z(M.current, "browOuterUpRight", Be), C.current) {
687
+ const J = A.current ? 0 : V.rotation[1];
688
+ C.current.rotation.y = Ve.MathUtils.lerp(
689
689
  C.current.rotation.y,
690
690
  J,
691
691
  0.1
692
- ), C.current.position.set(...W.position), C.current.scale.setScalar(W.scale), C.current.rotation.x = W.rotation[0], C.current.rotation.z = W.rotation[2];
692
+ ), C.current.position.set(...V.position), C.current.scale.setScalar(V.scale), C.current.rotation.x = V.rotation[0], C.current.rotation.z = V.rotation[2];
693
693
  }
694
- if (L.current && g.current) {
695
- const J = g.current.currentTime, Ie = (J - T.current) * 1e3 - -150;
696
- for (let K = 0; K < w.current.length; K++) {
697
- const ce = w.current[K];
698
- Ie >= ce.vtime && Ie < ce.vtime + ce.vduration && Ne(ce.viseme, ce.weight ?? 1);
694
+ if (A.current && g.current) {
695
+ const J = g.current.currentTime, De = (J - T.current) * 1e3 - -150;
696
+ for (let Z = 0; Z < w.current.length; Z++) {
697
+ const re = w.current[Z];
698
+ De >= re.vtime && De < re.vtime + re.vduration && Ne(re.viseme, re.weight ?? 1);
699
699
  }
700
- J > H.current + 0.5 && (b(), oe(!1));
700
+ J > U.current + 0.5 && (_(), ce(!1));
701
701
  }
702
702
  }), /* @__PURE__ */ l("group", { ref: C, children: /* @__PURE__ */ l("primitive", { object: k }) });
703
703
  }
704
704
  );
705
- function gn(f) {
705
+ function vn(f) {
706
706
  return f ? f.charAt(0).toUpperCase() + f.slice(1).toLowerCase() : "";
707
707
  }
708
- const bn = ({
708
+ const yn = ({
709
709
  token: f,
710
- agentToken: L,
710
+ agentToken: A,
711
711
  onNavigationRequested: w,
712
712
  avatarGender: g
713
713
  } = {}) => {
714
- const T = f ?? L ?? "", W = tn(T || void 0), [E, Z] = _(""), [ie, F] = _(""), [H, b] = _("Ready"), [oe, p] = _(!1), [Y, $] = _(!1), [he, k] = _([]), [Ve, ye] = _(""), q = c(null), [pe, I] = _(
714
+ const T = f ?? A ?? "", V = on(T || void 0), [E, ee] = b(""), [ae, N] = b(""), [U, _] = b("Ready"), [ce, m] = b(!1), [Y, $] = b(!1), [pe, k] = b([]), [He, xe] = b(""), q = c(null), [ge, I] = b(
715
715
  () => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
716
716
  );
717
717
  P(() => {
718
718
  const e = window.matchMedia("(max-width: 480px)"), t = () => I(e.matches);
719
719
  return e.addEventListener("change", t), () => e.removeEventListener("change", t);
720
720
  }, []);
721
- const C = pe ? 80 : 600, B = c(!1), M = c([]), me = c(0), R = c(!1), v = c([]), y = c(null), ge = c([]);
721
+ const C = ge ? 80 : 600, W = c(!1), M = c([]), be = c(0), L = c(!1), v = c([]), y = c(null), _e = c([]);
722
722
  c([]);
723
- const Te = c([]), be = c(0), ae = c(0), _e = c(0), Ne = c(0), Se = c(!1), [d, u] = _(
723
+ const Ie = c([]), we = c(0), le = c(0), ve = c(0), Ne = c(0), ke = c(!1), [d, u] = b(
724
724
  null
725
- ), i = c(null), [r, h] = _("neutral"), [G, Q] = _(""), [Xe, He] = _(""), [Fe, xe] = _("Chat with us"), [we, $e] = _(
725
+ ), i = c(null), [r, h] = b("neutral"), [G, Q] = b(""), [Ke, $e] = b(""), [Ue, Re] = b("Chat with us"), [K, je] = b(
726
726
  null
727
- ), [ee, ke] = _("hidden"), [Ae, Ue] = _(""), Ee = c(null), J = c(ee);
728
- J.current = ee;
729
- const [ve, te] = _(null), Ie = c(null), K = c(null), [ce, dt] = _(!1), ft = c(null), [Me, je] = _("hidden"), [ht, Tt] = _(""), Ke = c(Me);
730
- Ke.current = Me;
731
- const de = c(""), De = c(!1), Ce = c(""), pt = c(Date.now()), Ze = c([]), Be = c(!1), [et, Pe] = _(!1), mt = "__branding__", Oe = ut(() => ce ? "Try again" : H === "Busy" ? "Busy" : H === "Thinking..." || H === "Processing Voice..." ? H : we != null && we !== "" && we !== "none" && we !== "<none>" ? `Enter ${gn(we)}` : mt, [H, we, ce]), Je = Oe != null && Oe !== "";
727
+ ), [te, Ae] = b("hidden"), [Le, Be] = b(""), Me = c(null), J = c(te);
728
+ J.current = te;
729
+ const [ye, ne] = b(null), De = c(null), Z = c(null), [re, ft] = b(!1), ht = c(null), [ue, Je] = b("hidden"), [mt, Dt] = b(""), Ze = c(ue);
730
+ Ze.current = ue;
731
+ const he = c(""), Ce = c(!1), Oe = c(""), pt = c(Date.now()), et = c([]), Pe = c(!1), [tt, We] = b(!1), [gt, bt] = b(!1), Se = c(null), Fe = dt(() => re ? "Try again" : U === "Busy" ? "Busy" : U === "Thinking..." || U === "Processing Voice..." ? U : K != null && K !== "" && K !== "none" && K !== "<none>" ? `Enter ${vn(K)}` : ue !== "hidden" || !gt ? null : It, [U, K, re, ue, gt]), _t = !re && U !== "Busy" && U !== "Thinking..." && U !== "Processing Voice..." && (K == null || K === "" || K === "none" || K === "<none>");
732
+ P(() => {
733
+ if (ue !== "hidden" || !_t) {
734
+ bt(!1), Se.current != null && (clearTimeout(Se.current), Se.current = null);
735
+ return;
736
+ }
737
+ return Se.current = setTimeout(() => {
738
+ Se.current = null, bt(!0);
739
+ }, 400), () => {
740
+ Se.current != null && (clearTimeout(Se.current), Se.current = null);
741
+ };
742
+ }, [ue, _t]);
743
+ const qe = Fe != null && Fe !== "";
732
744
  P(() => {
733
745
  const e = J.current;
734
746
  if (!(e === "exiting" || e === "entering")) {
735
747
  if (e === "hidden") {
736
- Je && (Ue(Oe ?? ""), ke("entering"));
748
+ qe && (Be(Fe ?? ""), Ae("entering"));
737
749
  return;
738
750
  }
739
- e === "visible" && (!Je || Oe !== Ae) && (Ee.current = Je ? Oe : null, ke("exiting"));
751
+ e === "visible" && (!qe || Fe !== Le) && (Me.current = qe ? Fe : null, Ae("exiting"));
740
752
  }
741
753
  }, [
742
- Je,
743
- Oe,
744
- ee,
745
- Ae
754
+ qe,
755
+ Fe,
756
+ te,
757
+ Le
746
758
  ]), P(() => {
747
- if (H !== "Busy") {
748
- K.current != null && (clearTimeout(K.current), K.current = null);
759
+ if (U !== "Busy") {
760
+ Z.current != null && (clearTimeout(Z.current), Z.current = null);
749
761
  return;
750
762
  }
751
- return K.current = setTimeout(() => {
752
- K.current = null, b("Ready"), dt(!0);
763
+ return Z.current = setTimeout(() => {
764
+ Z.current = null, _("Ready"), ft(!0);
753
765
  }, 12e3), () => {
754
- K.current != null && (clearTimeout(K.current), K.current = null);
766
+ Z.current != null && (clearTimeout(Z.current), Z.current = null);
755
767
  };
756
- }, [H]), P(() => {
757
- if (!ce) return;
758
- const e = setTimeout(() => dt(!1), 2500);
768
+ }, [U]), P(() => {
769
+ if (!re) return;
770
+ const e = setTimeout(() => ft(!1), 2500);
759
771
  return () => clearTimeout(e);
760
- }, [ce]);
761
- const Et = Ye(() => {
772
+ }, [re]);
773
+ const Ct = Qe(() => {
762
774
  const e = J.current;
763
775
  if (e === "exiting") {
764
- ke("hidden");
765
- const t = Ee.current;
766
- Ee.current = null, t != null && t !== "" && (Ue(t), ke("entering"));
767
- } else e === "entering" && ke("visible");
768
- }, []), It = (e) => {
776
+ Ae("hidden");
777
+ const t = Me.current;
778
+ Me.current = null, t != null && t !== "" && (Be(t), Ae("entering"));
779
+ } else e === "entering" && Ae("visible");
780
+ }, []), Ot = (e) => {
769
781
  if (!e) return;
770
782
  if (e.mood != null) {
771
783
  const n = String(e.mood).toLowerCase();
@@ -774,12 +786,12 @@ const bn = ({
774
786
  if (e.expression != null) {
775
787
  const n = String(e.expression).trim();
776
788
  Q(n);
777
- const a = sn.find(
778
- (m) => m.name.toLowerCase() === n.toLowerCase()
789
+ const a = ln.find(
790
+ (p) => p.name.toLowerCase() === n.toLowerCase()
779
791
  );
780
- U(
792
+ B(
781
793
  `[STREAM] Animation match for "${n}": ${a ? a.name : "NONE"}`
782
- ), He(a?.url ?? "");
794
+ ), $e(a?.url ?? "");
783
795
  }
784
796
  if (e.navigation != null) {
785
797
  const n = String(e.navigation).trim();
@@ -788,10 +800,10 @@ const bn = ({
788
800
  const t = e.ask_for || e.lead_capture?.ask_for, s = t ? String(t).trim().toLowerCase() : "", o = s === "none" || s === "<none>";
789
801
  if (t && !o) {
790
802
  const n = s;
791
- $e(n || null), xe(n === "email" ? "Enter your email" : n === "name" ? "Enter your name" : n === "phone" ? "Enter your phone number" : "Chat with us");
792
- } else (o || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && ($e(null), Fe !== "Chat with us" && xe("Chat with us"));
803
+ je(n || null), Re(n === "email" ? "Enter your email" : n === "name" ? "Enter your name" : n === "phone" ? "Enter your phone number" : "Chat with us");
804
+ } else (o || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && (je(null), Ue !== "Chat with us" && Re("Chat with us"));
793
805
  e.collected, e.valid;
794
- }, Mt = (e) => {
806
+ }, Ft = (e) => {
795
807
  const t = e.trim();
796
808
  if (!t) return null;
797
809
  if (t.startsWith("{"))
@@ -805,21 +817,21 @@ const bn = ({
805
817
  return { [o]: n };
806
818
  }
807
819
  return null;
808
- }, Dt = Ye(() => {
809
- }, []), gt = (e) => {
810
- if (De.current)
811
- e === "§" ? De.current = !1 : (Ce.current += e, F((t) => t + e));
820
+ }, Nt = Qe(() => {
821
+ }, []), wt = (e) => {
822
+ if (Ce.current)
823
+ e === "§" ? Ce.current = !1 : (Oe.current += e, N((t) => t + e));
812
824
  else if (e === "§") {
813
- De.current = !0;
825
+ Ce.current = !0;
814
826
  return;
815
827
  } else
816
- for (de.current += e; de.current.includes(`
828
+ for (he.current += e; he.current.includes(`
817
829
  `); ) {
818
- const t = de.current.indexOf(`
819
- `), s = de.current.slice(0, t).trim();
820
- de.current = de.current.slice(t + 1);
821
- const o = Mt(s);
822
- o && It(o);
830
+ const t = he.current.indexOf(`
831
+ `), s = he.current.slice(0, t).trim();
832
+ he.current = he.current.slice(t + 1);
833
+ const o = Ft(s);
834
+ o && Ot(o);
823
835
  }
824
836
  };
825
837
  P(() => {
@@ -835,12 +847,12 @@ const bn = ({
835
847
  { name: "HMAC", hash: "SHA-256" },
836
848
  !1,
837
849
  ["sign"]
838
- ), m = await crypto.subtle.sign(
850
+ ), p = await crypto.subtle.sign(
839
851
  "HMAC",
840
852
  a,
841
853
  n.encode(o)
842
- ), S = Array.from(new Uint8Array(m)).map((x) => x.toString(16).padStart(2, "0")).join("");
843
- sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", S), U("[SESSION] New HMAC UID generated and saved:", S);
854
+ ), S = Array.from(new Uint8Array(p)).map((x) => x.toString(16).padStart(2, "0")).join("");
855
+ sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", S), B("[SESSION] New HMAC UID generated and saved:", S);
844
856
  } catch (n) {
845
857
  console.error("[SESSION] HMAC generation failed:", n);
846
858
  const a = Math.random().toString(36) + Date.now().toString();
@@ -854,55 +866,55 @@ const bn = ({
854
866
  })();
855
867
  }, []), P(() => {
856
868
  const e = () => {
857
- pt.current = Date.now(), Be.current && (Be.current = !1, Pe(!1), k([]), ye(""), F(""), $(!1));
869
+ pt.current = Date.now(), Pe.current && (Pe.current = !1, We(!1), k([]), xe(""), N(""), $(!1));
858
870
  };
859
871
  window.addEventListener("mousemove", e), window.addEventListener("keydown", e), window.addEventListener("mousedown", e), window.addEventListener("touchstart", e);
860
872
  const t = setInterval(async () => {
861
- if (Date.now() - pt.current >= 3e4 && !Y && !oe && H === "Ready" && !Be.current)
862
- if (Be.current = !0, Ze.current.length > 0)
863
- Pe(!0), k(Ze.current);
873
+ if (Date.now() - pt.current >= 3e4 && !Y && !ce && U === "Ready" && !Pe.current)
874
+ if (Pe.current = !0, et.current.length > 0)
875
+ We(!0), k(et.current);
864
876
  else
865
877
  try {
866
- const n = `${ct}/nudgeUser`, a = {
878
+ const n = `${lt}/nudgeUser`, a = {
867
879
  navigationUrl: window.location.href,
868
880
  token: T
869
- }, m = await fetch(n, {
881
+ }, p = await fetch(n, {
870
882
  method: "POST",
871
883
  headers: {
872
884
  "Content-Type": "application/json"
873
885
  },
874
886
  body: JSON.stringify(a)
875
887
  });
876
- if (m.ok) {
877
- const S = (await m.json()).nudge_questions;
878
- S && S.length > 0 && (U("[NUDGE] Received nudge questions from API:", S), Ze.current = S, Pe(!0), k(S));
888
+ if (p.ok) {
889
+ const S = (await p.json()).nudge_questions;
890
+ S && S.length > 0 && (B("[NUDGE] Received nudge questions from API:", S), et.current = S, We(!0), k(S));
879
891
  }
880
892
  } catch (n) {
881
- console.error("[NUDGE] Error calling /nudgeUser:", n), Be.current = !1;
893
+ console.error("[NUDGE] Error calling /nudgeUser:", n), Pe.current = !1;
882
894
  }
883
895
  }, 1e3);
884
896
  return () => {
885
897
  window.removeEventListener("mousemove", e), window.removeEventListener("keydown", e), window.removeEventListener("mousedown", e), window.removeEventListener("touchstart", e), clearInterval(t);
886
898
  };
887
- }, [T, Y, oe, H]), P(() => {
888
- if (he.length === 0) return;
899
+ }, [T, Y, ce, U]), P(() => {
900
+ if (pe.length === 0) return;
889
901
  let e = 0, t = 0, s = !1, o = 100;
890
902
  const n = () => {
891
- const a = he[e];
903
+ const a = pe[e];
892
904
  if (s) {
893
- const m = a.substring(0, t - 1);
894
- ye(m), t--, o = 50;
905
+ const p = a.substring(0, t - 1);
906
+ xe(p), t--, o = 50;
895
907
  } else {
896
- const m = a.substring(0, t + 1);
897
- ye(m), t++, o = 100;
908
+ const p = a.substring(0, t + 1);
909
+ xe(p), t++, o = 100;
898
910
  }
899
- !s && t === a.length ? (s = !0, o = 3e3) : s && t === 0 && (s = !1, e = (e + 1) % he.length, o = 500), q.current = setTimeout(n, o);
911
+ !s && t === a.length ? (s = !0, o = 3e3) : s && t === 0 && (s = !1, e = (e + 1) % pe.length, o = 500), q.current = setTimeout(n, o);
900
912
  };
901
913
  return n(), () => {
902
914
  q.current && clearTimeout(q.current);
903
915
  };
904
- }, [he]);
905
- const bt = () => {
916
+ }, [pe]);
917
+ const vt = () => {
906
918
  try {
907
919
  return JSON.parse(
908
920
  sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]"
@@ -910,95 +922,95 @@ const bn = ({
910
922
  } catch {
911
923
  return [];
912
924
  }
913
- }, Ct = (e) => {
925
+ }, Ut = (e) => {
914
926
  sessionStorage.setItem(
915
927
  "STREAMOJI_LEADS_SESSION_MESSAGES",
916
928
  JSON.stringify(e)
917
929
  );
918
- }, [tt, nt] = _(!1), [_t, rt] = _(0), le = c(null), qe = c([]), wt = c(0), [vt, Ot] = _(
930
+ }, [nt, rt] = b(!1), [yt, st] = b(0), de = c(null), Ge = c([]), St = c(0), [xt, Bt] = b(
919
931
  null
920
- ), [Nt, st] = _(
932
+ ), [Pt, it] = b(
921
933
  null
922
- ), fe = c(null), Le = c(
934
+ ), me = c(null), Te = c(
923
935
  null
924
- ), Ge = Ye((e = !1) => {
925
- e && (Se.current = !0, p(!1), b("Ready")), v.current = [], M.current = [], R.current = !1, $(!1), be.current = 0, ae.current = 0, _e.current = 0, ge.current.forEach((t) => {
936
+ ), ze = Qe((e = !1) => {
937
+ e && (ke.current = !0, m(!1), _("Ready")), v.current = [], M.current = [], L.current = !1, $(!1), we.current = 0, le.current = 0, ve.current = 0, _e.current.forEach((t) => {
926
938
  try {
927
939
  t.stop();
928
940
  } catch {
929
941
  }
930
- }), Ie.current && (clearTimeout(Ie.current), Ie.current = null), te(null), He(""), ge.current = [];
931
- }, []), Ft = async () => {
942
+ }), De.current && (clearTimeout(De.current), De.current = null), ne(null), $e(""), _e.current = [];
943
+ }, []), Wt = async () => {
932
944
  try {
933
945
  const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext, s = new t(), o = s.createMediaStreamSource(e), n = s.createAnalyser();
934
- n.fftSize = 64, o.connect(n), fe.current = s, Le.current = o, st(n);
946
+ n.fftSize = 64, o.connect(n), me.current = s, Te.current = o, it(n);
935
947
  const a = new MediaRecorder(e);
936
- le.current = a, qe.current = [], a.ondataavailable = (m) => {
937
- m.data.size > 0 && qe.current.push(m.data);
948
+ de.current = a, Ge.current = [], a.ondataavailable = (p) => {
949
+ p.data.size > 0 && Ge.current.push(p.data);
938
950
  }, a.onstop = async () => {
939
- const m = Date.now() - wt.current;
940
- if (st(null), Le.current && (Le.current.disconnect(), Le.current = null), fe.current && fe.current.state !== "closed" && (fe.current.close(), fe.current = null), m < 1e3) {
941
- b("Recording too short. Hold or click longer."), p(!1);
951
+ const p = Date.now() - St.current;
952
+ if (it(null), Te.current && (Te.current.disconnect(), Te.current = null), me.current && me.current.state !== "closed" && (me.current.close(), me.current = null), p < 1e3) {
953
+ _("Recording too short. Hold or click longer."), m(!1);
942
954
  return;
943
955
  }
944
- const A = new Blob(qe.current, {
956
+ const R = new Blob(Ge.current, {
945
957
  type: "audio/wav"
946
958
  });
947
- await Wt(A);
948
- }, wt.current = Date.now(), a.start(100), nt(!0), b("Listening...");
959
+ await jt(R);
960
+ }, St.current = Date.now(), a.start(100), rt(!0), _("Listening...");
949
961
  } catch (e) {
950
- console.error("Error accessing microphone:", e), b("Mic Access Error");
962
+ console.error("Error accessing microphone:", e), _("Mic Access Error");
951
963
  }
952
- }, Ut = () => {
953
- le.current && le.current.state !== "inactive" && (le.current.stop(), le.current.stream.getTracks().forEach((e) => e.stop()), nt(!1));
954
- }, Bt = () => {
955
- le.current && le.current.state !== "inactive" && (le.current.onstop = null, le.current.stop(), le.current.stream.getTracks().forEach((e) => e.stop()), st(null), Le.current && (Le.current.disconnect(), Le.current = null), fe.current && fe.current.state !== "closed" && (fe.current.close(), fe.current = null), nt(!1), qe.current = [], b("Ready"));
964
+ }, Vt = () => {
965
+ de.current && de.current.state !== "inactive" && (de.current.stop(), de.current.stream.getTracks().forEach((e) => e.stop()), rt(!1));
966
+ }, Ht = () => {
967
+ de.current && de.current.state !== "inactive" && (de.current.onstop = null, de.current.stop(), de.current.stream.getTracks().forEach((e) => e.stop()), it(null), Te.current && (Te.current.disconnect(), Te.current = null), me.current && me.current.state !== "closed" && (me.current.close(), me.current = null), rt(!1), Ge.current = [], _("Ready"));
956
968
  };
957
969
  P(() => {
958
970
  if (!Y) return;
959
971
  const e = () => {
960
- const t = _e.current;
972
+ const t = ve.current;
961
973
  if (t <= 0) return;
962
- const s = y.current, o = be.current;
974
+ const s = y.current, o = we.current;
963
975
  if (!s) return;
964
- const n = s.currentTime - o, a = Math.min(Math.max(0, n), t), m = ie.trim().length;
965
- if (m <= 0) return;
966
- const A = Math.min(
967
- Math.round(a / t * m),
968
- m
976
+ const n = s.currentTime - o, a = Math.min(Math.max(0, n), t), p = ae.trim().length;
977
+ if (p <= 0) return;
978
+ const R = Math.min(
979
+ Math.round(a / t * p),
980
+ p
969
981
  );
970
- u(A);
982
+ u(R);
971
983
  };
972
984
  return clearInterval(i.current ?? void 0), i.current = setInterval(e, 90), () => clearInterval(i.current ?? void 0);
973
- }, [Y, ie, _e.current]), P(() => {
985
+ }, [Y, ae, ve.current]), P(() => {
974
986
  let e;
975
- return tt ? (rt(0), e = window.setInterval(() => {
976
- rt((t) => t + 1);
977
- }, 1e3)) : rt(0), () => clearInterval(e);
978
- }, [tt]);
979
- const Pt = (e) => {
987
+ return nt ? (st(0), e = window.setInterval(() => {
988
+ st((t) => t + 1);
989
+ }, 1e3)) : st(0), () => clearInterval(e);
990
+ }, [nt]);
991
+ const $t = (e) => {
980
992
  const t = e.numberOfChannels, s = e.length * t * 2 + 44, o = new ArrayBuffer(s), n = new DataView(o);
981
993
  let a = 0;
982
- const m = (O) => {
994
+ const p = (O) => {
983
995
  n.setUint16(a, O, !0), a += 2;
984
- }, A = (O) => {
996
+ }, R = (O) => {
985
997
  n.setUint32(a, O, !0), a += 4;
986
998
  };
987
- A(1179011410), A(s - 8), A(1163280727), A(544501094), A(16), m(1), m(t), A(e.sampleRate), A(e.sampleRate * 2 * t), m(t * 2), m(16), A(1635017060), A(s - a - 4);
999
+ R(1179011410), R(s - 8), R(1163280727), R(544501094), R(16), p(1), p(t), R(e.sampleRate), R(e.sampleRate * 2 * t), p(t * 2), p(16), R(1635017060), R(s - a - 4);
988
1000
  const S = [];
989
1001
  for (let O = 0; O < t; O++) S.push(e.getChannelData(O));
990
1002
  let x = 0;
991
1003
  for (; a < s; ) {
992
1004
  for (let O = 0; O < t; O++) {
993
- let V = Math.max(-1, Math.min(1, S[O][x]));
994
- V = V < 0 ? V * 32768 : V * 32767, n.setInt16(a, V, !0), a += 2;
1005
+ let H = Math.max(-1, Math.min(1, S[O][x]));
1006
+ H = H < 0 ? H * 32768 : H * 32767, n.setInt16(a, H, !0), a += 2;
995
1007
  }
996
1008
  x++;
997
1009
  }
998
1010
  return new Blob([o], { type: "audio/wav" });
999
- }, it = async (e, t, s = !1) => {
1000
- if (!Se.current) {
1001
- if (B.current) {
1011
+ }, ot = async (e, t, s = !1) => {
1012
+ if (!ke.current) {
1013
+ if (W.current) {
1002
1014
  M.current.push({
1003
1015
  audio: e,
1004
1016
  visemes: t,
@@ -1006,136 +1018,136 @@ const bn = ({
1006
1018
  });
1007
1019
  return;
1008
1020
  }
1009
- B.current = !0;
1021
+ W.current = !0;
1010
1022
  try {
1011
1023
  const o = window.AudioContext || window.webkitAudioContext, n = y.current ?? new o();
1012
1024
  n.state === "suspended" && await n.resume(), y.current = n;
1013
- const a = window.atob(e), m = new Uint8Array(a.length);
1014
- for (let N = 0; N < a.length; N++)
1015
- m[N] = a.charCodeAt(N);
1016
- const A = await n.decodeAudioData(m.buffer.slice(0));
1017
- _e.current += A.duration;
1025
+ const a = window.atob(e), p = new Uint8Array(a.length);
1026
+ for (let F = 0; F < a.length; F++)
1027
+ p[F] = a.charCodeAt(F);
1028
+ const R = await n.decodeAudioData(p.buffer.slice(0));
1029
+ ve.current += R.duration;
1018
1030
  const S = n.currentTime;
1019
- let x = ae.current;
1020
- const O = !R.current;
1021
- x < S && (x = S + 0.1), ae.current = x + A.duration;
1022
- const V = n.createBufferSource();
1023
- V.buffer = A;
1024
- let j = vt;
1025
- if ((!j || j.context !== n) && (j = n.createAnalyser(), j.fftSize = 64, j.connect(n.destination), Ot(j)), V.connect(j), ge.current.push(V), Se.current) {
1026
- ge.current = ge.current.filter((N) => N !== V);
1031
+ let x = le.current;
1032
+ const O = !L.current;
1033
+ x < S && (x = S + 0.1), le.current = x + R.duration;
1034
+ const H = n.createBufferSource();
1035
+ H.buffer = R;
1036
+ let j = xt;
1037
+ if ((!j || j.context !== n) && (j = n.createAnalyser(), j.fftSize = 64, j.connect(n.destination), Bt(j)), H.connect(j), _e.current.push(H), ke.current) {
1038
+ _e.current = _e.current.filter((F) => F !== H);
1027
1039
  return;
1028
1040
  }
1029
1041
  if (O) {
1030
- R.current = !0, $(!0), U(
1042
+ L.current = !0, $(!0), B(
1031
1043
  `[AUDIO] setIsSpeaking(true) - First chunk starting at ${x.toFixed(
1032
1044
  3
1033
1045
  )}`
1034
- ), be.current = x;
1035
- const N = (x - S) * 1e3;
1036
- me.current = performance.now() + N, U(
1046
+ ), we.current = x;
1047
+ const F = (x - S) * 1e3;
1048
+ be.current = performance.now() + F, B(
1037
1049
  `[AUDIO] Response started. Initial startTime: ${x.toFixed(
1038
1050
  3
1039
1051
  )}, CT: ${S.toFixed(3)}`
1040
1052
  );
1041
1053
  }
1042
- V.start(x);
1043
- const X = (x - be.current) * 1e3;
1044
- s && (Ne.current = X, U(
1054
+ H.start(x);
1055
+ const X = (x - we.current) * 1e3;
1056
+ s && (Ne.current = X, B(
1045
1057
  `[AUDIO] New segment detected at +${X.toFixed(
1046
1058
  0
1047
1059
  )}ms. Resetting segment offset.`
1048
- )), t.forEach((N, ne) => {
1049
- const D = N.symbol ?? "";
1060
+ )), t.forEach((F, se) => {
1061
+ const D = F.symbol ?? "";
1050
1062
  if (D) {
1051
- const re = hn(D), ue = Math.round(N.start * 1e3), Re = Math.round((N.duration ?? 0) * 1e3), xt = Ne.current + ue;
1052
- ne < 3 && U(
1053
- `[AUDIO] Viseme "${D}": segment_relative=${ue}ms, segment_offset=${Ne.current.toFixed(
1063
+ const ie = bn(D), fe = Math.round(F.start * 1e3), Ee = Math.round((F.duration ?? 0) * 1e3), At = Ne.current + fe;
1064
+ se < 3 && B(
1065
+ `[AUDIO] Viseme "${D}": segment_relative=${fe}ms, segment_offset=${Ne.current.toFixed(
1054
1066
  0
1055
- )}ms => vtime=${xt}ms`
1056
- ), re.forEach((kt) => {
1067
+ )}ms => vtime=${At}ms`
1068
+ ), ie.forEach((Lt) => {
1057
1069
  v.current.push({
1058
- viseme: kt.v,
1059
- weight: kt.w,
1060
- vtime: xt,
1061
- vduration: Re
1070
+ viseme: Lt.v,
1071
+ weight: Lt.w,
1072
+ vtime: At,
1073
+ vduration: Ee
1062
1074
  });
1063
1075
  });
1064
1076
  }
1065
- }), b("Speaking...");
1077
+ }), _("Speaking...");
1066
1078
  } finally {
1067
- if (B.current = !1, M.current.length > 0) {
1079
+ if (W.current = !1, M.current.length > 0) {
1068
1080
  const o = M.current.shift();
1069
- o && it(o.audio, o.visemes, o.isNewSegment);
1081
+ o && ot(o.audio, o.visemes, o.isNewSegment);
1070
1082
  }
1071
1083
  }
1072
1084
  }
1073
- }, Wt = async (e) => {
1085
+ }, jt = async (e) => {
1074
1086
  try {
1075
- p(!0), Pe(!1), Ce.current = "", F(""), b("Processing Voice...");
1076
- const t = await e.arrayBuffer(), o = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), n = Pt(o), a = new FileReader();
1087
+ m(!0), We(!1), Oe.current = "", N(""), _("Processing Voice...");
1088
+ const t = await e.arrayBuffer(), o = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), n = $t(o), a = new FileReader();
1077
1089
  a.readAsDataURL(n), a.onloadend = async () => {
1078
- const m = a.result.split(",")[1];
1079
- Ge(), Z(""), de.current = "", De.current = !1;
1080
- const A = `${ct}/stt?token=${encodeURIComponent(
1090
+ const p = a.result.split(",")[1];
1091
+ ze(), ee(""), he.current = "", Ce.current = !1;
1092
+ const R = `${lt}/stt?token=${encodeURIComponent(
1081
1093
  T
1082
- )}`, S = await fetch(A, {
1094
+ )}`, S = await fetch(R, {
1083
1095
  method: "POST",
1084
1096
  headers: { "Content-Type": "application/json" },
1085
1097
  body: JSON.stringify({
1086
- audio_base64: m,
1098
+ audio_base64: p,
1087
1099
  audio_format: "wav"
1088
1100
  })
1089
1101
  });
1090
1102
  if (S.status === 429) {
1091
1103
  try {
1092
- const ne = await S.text(), D = JSON.parse(ne);
1093
- U("[STT] 429 agent at capacity:", D?.detail);
1104
+ const se = await S.text(), D = JSON.parse(se);
1105
+ B("[STT] 429 agent at capacity:", D?.detail);
1094
1106
  } catch {
1095
1107
  }
1096
- Z(""), b("Busy"), p(!1);
1108
+ ee(""), _("Busy"), m(!1);
1097
1109
  return;
1098
1110
  }
1099
1111
  if (!S.ok) {
1100
- const ne = await S.text();
1112
+ const se = await S.text();
1101
1113
  let D = "STT Failed";
1102
1114
  try {
1103
- D = JSON.parse(ne).error || D;
1115
+ D = JSON.parse(se).error || D;
1104
1116
  } catch {
1105
- ne && (D = ne.slice(0, 200));
1117
+ se && (D = se.slice(0, 200));
1106
1118
  }
1107
1119
  throw new Error(D);
1108
1120
  }
1109
1121
  const x = S.body;
1110
- if (U("this is body" + x), !x) {
1111
- b("STT Failed"), p(!1);
1122
+ if (B("this is body" + x), !x) {
1123
+ _("STT Failed"), m(!1);
1112
1124
  return;
1113
1125
  }
1114
1126
  const O = x.getReader();
1115
- Se.current = !1;
1116
- const V = new TextDecoder();
1127
+ ke.current = !1;
1128
+ const H = new TextDecoder();
1117
1129
  let j = "", X = !1;
1118
- const N = async (ne, D) => {
1119
- switch (ne) {
1130
+ const F = async (se, D) => {
1131
+ switch (se) {
1120
1132
  case "transcript":
1121
- D.transcript != null && Z(String(D.transcript));
1133
+ D.transcript != null && ee(String(D.transcript));
1122
1134
  break;
1123
1135
  case "text": {
1124
- const re = D.delta ?? D.text ?? "";
1125
- re && gt(re);
1136
+ const ie = D.delta ?? D.text ?? "";
1137
+ ie && wt(ie);
1126
1138
  break;
1127
1139
  }
1128
1140
  case "audio": {
1129
- const re = D.chunk, ue = D.visemes ?? [], Re = !!D.is_new_segment;
1130
- re && await it(re, ue, Re);
1141
+ const ie = D.chunk, fe = D.visemes ?? [], Ee = !!D.is_new_segment;
1142
+ ie && await ot(ie, fe, Ee);
1131
1143
  break;
1132
1144
  }
1133
1145
  case "done": {
1134
- X = !0, b("Ready"), p(!1);
1146
+ X = !0, _("Ready"), m(!1);
1135
1147
  break;
1136
1148
  }
1137
1149
  case "error": {
1138
- X = !0, b("STT Failed"), p(!1);
1150
+ X = !0, _("STT Failed"), m(!1);
1139
1151
  break;
1140
1152
  }
1141
1153
  default:
@@ -1143,32 +1155,32 @@ const bn = ({
1143
1155
  }
1144
1156
  };
1145
1157
  for (; ; ) {
1146
- const { done: ne, value: D } = await O.read();
1147
- D && (j += V.decode(D, { stream: !0 }));
1148
- const re = j.split(`
1158
+ const { done: se, value: D } = await O.read();
1159
+ D && (j += H.decode(D, { stream: !0 }));
1160
+ const ie = j.split(`
1149
1161
 
1150
1162
  `);
1151
- j = re.pop() ?? "";
1152
- for (const ue of re) {
1153
- const Re = ze(ue);
1154
- Re && await N(Re.event, Re.data);
1163
+ j = ie.pop() ?? "";
1164
+ for (const fe of ie) {
1165
+ const Ee = Ye(fe);
1166
+ Ee && await F(Ee.event, Ee.data);
1155
1167
  }
1156
- if (ne) {
1168
+ if (se) {
1157
1169
  if (j.trim()) {
1158
- const ue = ze(j.trim());
1159
- ue && await N(ue.event, ue.data);
1170
+ const fe = Ye(j.trim());
1171
+ fe && await F(fe.event, fe.data);
1160
1172
  }
1161
- X || (b("Ready"), p(!1));
1173
+ X || (_("Ready"), m(!1));
1162
1174
  break;
1163
1175
  }
1164
1176
  }
1165
1177
  };
1166
1178
  } catch (t) {
1167
- console.error("Audio Submission Error:", t), b("STT Failed"), p(!1);
1179
+ console.error("Audio Submission Error:", t), _("STT Failed"), m(!1);
1168
1180
  }
1169
- }, Vt = async (e) => {
1170
- e && e.preventDefault(), Pe(!1), Ce.current = "", F(""), !(!E || oe) && await Ht(E);
1171
- }, ze = (e) => {
1181
+ }, Jt = async (e) => {
1182
+ e && e.preventDefault(), We(!1), Oe.current = "", N(""), !(!E || ce) && await qt(E);
1183
+ }, Ye = (e) => {
1172
1184
  const t = e.split(/\r?\n/);
1173
1185
  let s = "", o = "";
1174
1186
  for (const a of t)
@@ -1182,45 +1194,45 @@ const bn = ({
1182
1194
  n = { raw: o };
1183
1195
  }
1184
1196
  return { event: s, data: n };
1185
- }, yt = (e, t) => {
1197
+ }, kt = (e, t) => {
1186
1198
  switch (e) {
1187
1199
  case "connected":
1188
- de.current = "", De.current = !1;
1200
+ he.current = "", Ce.current = !1;
1189
1201
  break;
1190
1202
  case "text": {
1191
1203
  const s = t.delta ?? "";
1192
- s && gt(s);
1204
+ s && wt(s);
1193
1205
  break;
1194
1206
  }
1195
1207
  case "audio": {
1196
1208
  const s = t.chunk, o = t.visemes ?? [];
1197
- s && it(s, o);
1209
+ s && ot(s, o);
1198
1210
  break;
1199
1211
  }
1200
1212
  case "done": {
1201
- const s = bt(), o = Ce.current.trim(), n = [
1213
+ const s = vt(), o = Oe.current.trim(), n = [
1202
1214
  ...s,
1203
1215
  { role: "user", content: E || "..." },
1204
1216
  { role: "assistant", content: o }
1205
1217
  ];
1206
- Ct(n), Te.current = [...v.current], b("Ready"), p(!1), Z("");
1218
+ Ut(n), Ie.current = [...v.current], _("Ready"), m(!1), ee("");
1207
1219
  break;
1208
1220
  }
1209
1221
  case "error": {
1210
1222
  const s = t.message ?? "Unknown error";
1211
- Ce.current = s, F(s), b("Agent Failed"), p(!1);
1223
+ Oe.current = s, N(s), _("Agent Failed"), m(!1);
1212
1224
  break;
1213
1225
  }
1214
1226
  }
1215
- }, Ht = async (e) => {
1216
- p(!0), b("Thinking..."), Ce.current = "", de.current = "", De.current = !1, Ge(), _e.current = 0, u(0);
1217
- const t = `${ct}/agent/chat?token=${encodeURIComponent(
1227
+ }, qt = async (e) => {
1228
+ m(!0), _("Thinking..."), Oe.current = "", he.current = "", Ce.current = !1, ze(), ve.current = 0, u(0);
1229
+ const t = `${lt}/agent/chat?token=${encodeURIComponent(
1218
1230
  T
1219
1231
  )}`;
1220
1232
  try {
1221
- const s = bt();
1233
+ const s = vt();
1222
1234
  let o = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
1223
- o || (Kt(
1235
+ o || (nn(
1224
1236
  "[CHAT] Session UID missing at send time! Generating emergency backup."
1225
1237
  ), o = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", o));
1226
1238
  const n = {
@@ -1228,7 +1240,7 @@ const bn = ({
1228
1240
  question: e,
1229
1241
  lead_id: o
1230
1242
  };
1231
- U("[CHAT] Sending payload:", n);
1243
+ B("[CHAT] Sending payload:", n);
1232
1244
  const a = await fetch(t, {
1233
1245
  method: "POST",
1234
1246
  headers: {
@@ -1240,72 +1252,72 @@ const bn = ({
1240
1252
  if (a.status === 429) {
1241
1253
  try {
1242
1254
  const O = await a.json();
1243
- U("[CHAT] 429 agent at capacity:", O?.detail);
1255
+ B("[CHAT] 429 agent at capacity:", O?.detail);
1244
1256
  } catch {
1245
1257
  }
1246
- Z(""), b("Busy"), p(!1);
1258
+ ee(""), _("Busy"), m(!1);
1247
1259
  return;
1248
1260
  }
1249
1261
  if (!a.ok)
1250
1262
  throw new Error("Agent request failed");
1251
- const m = a.body;
1252
- if (!m) {
1253
- b("Agent Failed"), p(!1);
1263
+ const p = a.body;
1264
+ if (!p) {
1265
+ _("Agent Failed"), m(!1);
1254
1266
  return;
1255
1267
  }
1256
- const A = m.getReader();
1257
- Se.current = !1;
1268
+ const R = p.getReader();
1269
+ ke.current = !1;
1258
1270
  const S = new TextDecoder();
1259
1271
  let x = "";
1260
1272
  for (; ; ) {
1261
- const { done: O, value: V } = await A.read();
1262
- U(
1263
- `[SSE] Chunk received. done=${O}, length=${V?.length || 0}`
1264
- ), V && (x += S.decode(V, { stream: !0 }));
1273
+ const { done: O, value: H } = await R.read();
1274
+ B(
1275
+ `[SSE] Chunk received. done=${O}, length=${H?.length || 0}`
1276
+ ), H && (x += S.decode(H, { stream: !0 }));
1265
1277
  const j = x.split(`
1266
1278
 
1267
1279
  `);
1268
1280
  x = j.pop() ?? "";
1269
1281
  for (const X of j) {
1270
- U(`[SSE] Processing block: ${X.slice(0, 50)}...`);
1271
- const N = ze(X);
1272
- N && (U(`[SSE] Event: ${N.event}`), yt(N.event, N.data));
1282
+ B(`[SSE] Processing block: ${X.slice(0, 50)}...`);
1283
+ const F = Ye(X);
1284
+ F && (B(`[SSE] Event: ${F.event}`), kt(F.event, F.data));
1273
1285
  }
1274
1286
  if (O) {
1275
- if (U("[SSE] Stream finished"), x.trim()) {
1276
- const X = ze(x.trim());
1277
- X && yt(X.event, X.data);
1287
+ if (B("[SSE] Stream finished"), x.trim()) {
1288
+ const X = Ye(x.trim());
1289
+ X && kt(X.event, X.data);
1278
1290
  }
1279
- b("Ready"), p(!1), Z("");
1291
+ _("Ready"), m(!1), ee("");
1280
1292
  break;
1281
1293
  }
1282
1294
  }
1283
1295
  } catch (s) {
1284
- console.error("Chat Error:", s), b("Agent Failed"), p(!1);
1296
+ console.error("Chat Error:", s), _("Agent Failed"), m(!1);
1285
1297
  }
1286
- }, St = ie.trim(), ot = St && Y ? St.slice(
1298
+ }, Rt = ae.trim(), at = Rt && Y ? Rt.slice(
1287
1299
  0,
1288
1300
  d != null && d > 0 ? d : 0
1289
1301
  ) : "";
1290
1302
  P(() => {
1291
- const e = Ke.current;
1292
- e !== "exiting" && (ot ? (Tt(ot), e === "hidden" && je("entering")) : (e === "visible" || e === "entering") && je("exiting"));
1293
- }, [ot, Me]);
1294
- const $t = Ye(() => {
1295
- const e = Ke.current;
1296
- e === "entering" ? je("visible") : e === "exiting" && je("hidden");
1303
+ const e = Ze.current;
1304
+ e !== "exiting" && (at ? (Dt(at), e === "hidden" && Je("entering")) : (e === "visible" || e === "entering") && Je("exiting"));
1305
+ }, [at, ue]);
1306
+ const Gt = Qe(() => {
1307
+ const e = Ze.current;
1308
+ e === "entering" ? Je("visible") : e === "exiting" && Je("hidden");
1297
1309
  }, []);
1298
- return Yt(() => {
1299
- const e = ft.current;
1310
+ return Zt(() => {
1311
+ const e = ht.current;
1300
1312
  e && (e.scrollTop = e.scrollHeight);
1301
- }, [ht]), /* @__PURE__ */ se("div", { className: "avatar-widget-container", children: [
1302
- /* @__PURE__ */ se("div", { className: "avatar-input-area", children: [
1303
- ee !== "hidden" ? /* @__PURE__ */ l(
1313
+ }, [mt]), /* @__PURE__ */ oe("div", { className: "avatar-widget-container", children: [
1314
+ /* @__PURE__ */ oe("div", { className: "avatar-input-area", children: [
1315
+ te !== "hidden" ? /* @__PURE__ */ l(
1304
1316
  "div",
1305
1317
  {
1306
- className: `avatar-thinking-tab${ee === "exiting" ? " avatar-thinking-tab--exiting" : ee === "entering" ? " avatar-thinking-tab--entering" : ""}`,
1307
- onAnimationEnd: Et,
1308
- children: Ae === mt ? /* @__PURE__ */ l(
1318
+ className: `avatar-thinking-tab${te === "exiting" ? " avatar-thinking-tab--exiting" : te === "entering" ? " avatar-thinking-tab--entering" : ""}`,
1319
+ onAnimationEnd: Ct,
1320
+ children: Le === It ? /* @__PURE__ */ l(
1309
1321
  "a",
1310
1322
  {
1311
1323
  href: "https://leads.streamoji.com",
@@ -1313,7 +1325,7 @@ const bn = ({
1313
1325
  rel: "noopener noreferrer",
1314
1326
  children: "Made by Streamoji Leads"
1315
1327
  }
1316
- ) : Ae
1328
+ ) : Le
1317
1329
  }
1318
1330
  ) : null,
1319
1331
  /* @__PURE__ */ l("div", { className: "avatar-input-container", children: /* @__PURE__ */ l(
@@ -1325,15 +1337,15 @@ const bn = ({
1325
1337
  width: "100%",
1326
1338
  height: "100%"
1327
1339
  },
1328
- children: tt ? /* @__PURE__ */ se("div", { className: "avatar-input-recording", children: [
1340
+ children: nt ? /* @__PURE__ */ oe("div", { className: "avatar-input-recording", children: [
1329
1341
  /* @__PURE__ */ l(
1330
1342
  "button",
1331
1343
  {
1332
1344
  type: "button",
1333
1345
  className: "avatar-recording-cancel",
1334
- onClick: Bt,
1346
+ onClick: Ht,
1335
1347
  title: "Cancel",
1336
- children: /* @__PURE__ */ se(
1348
+ children: /* @__PURE__ */ oe(
1337
1349
  "svg",
1338
1350
  {
1339
1351
  width: "18",
@@ -1353,7 +1365,7 @@ const bn = ({
1353
1365
  )
1354
1366
  }
1355
1367
  ),
1356
- /* @__PURE__ */ se(
1368
+ /* @__PURE__ */ oe(
1357
1369
  "div",
1358
1370
  {
1359
1371
  style: {
@@ -1365,8 +1377,8 @@ const bn = ({
1365
1377
  minWidth: 0
1366
1378
  },
1367
1379
  children: [
1368
- /* @__PURE__ */ l("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ l(At, { analyser: Nt }) }),
1369
- /* @__PURE__ */ se(
1380
+ /* @__PURE__ */ l("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ l(Tt, { analyser: Pt }) }),
1381
+ /* @__PURE__ */ oe(
1370
1382
  "span",
1371
1383
  {
1372
1384
  style: {
@@ -1379,9 +1391,9 @@ const bn = ({
1379
1391
  fontVariantNumeric: "tabular-nums"
1380
1392
  },
1381
1393
  children: [
1382
- Math.floor(_t / 60),
1394
+ Math.floor(yt / 60),
1383
1395
  ":",
1384
- String(_t % 60).padStart(2, "0")
1396
+ String(yt % 60).padStart(2, "0")
1385
1397
  ]
1386
1398
  }
1387
1399
  )
@@ -1393,7 +1405,7 @@ const bn = ({
1393
1405
  {
1394
1406
  type: "button",
1395
1407
  className: "avatar-recording-confirm",
1396
- onClick: Ut,
1408
+ onClick: Vt,
1397
1409
  title: "Send",
1398
1410
  children: /* @__PURE__ */ l(
1399
1411
  "svg",
@@ -1412,7 +1424,7 @@ const bn = ({
1412
1424
  )
1413
1425
  }
1414
1426
  )
1415
- ] }) : Y && !et ? /* @__PURE__ */ se("div", { className: "avatar-input-speaking", children: [
1427
+ ] }) : Y && !tt ? /* @__PURE__ */ oe("div", { className: "avatar-input-speaking", children: [
1416
1428
  /* @__PURE__ */ l(
1417
1429
  "div",
1418
1430
  {
@@ -1423,7 +1435,7 @@ const bn = ({
1423
1435
  alignItems: "center",
1424
1436
  paddingRight: "8px"
1425
1437
  },
1426
- children: /* @__PURE__ */ l(At, { analyser: vt })
1438
+ children: /* @__PURE__ */ l(Tt, { analyser: xt })
1427
1439
  }
1428
1440
  ),
1429
1441
  /* @__PURE__ */ l(
@@ -1431,12 +1443,12 @@ const bn = ({
1431
1443
  {
1432
1444
  type: "button",
1433
1445
  className: "avatar-speaking-stop",
1434
- onClick: () => Ge(!0),
1446
+ onClick: () => ze(!0),
1435
1447
  title: "Stop",
1436
1448
  children: /* @__PURE__ */ l("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
1437
1449
  }
1438
1450
  )
1439
- ] }) : oe ? /* @__PURE__ */ l(
1451
+ ] }) : ce ? /* @__PURE__ */ l(
1440
1452
  "div",
1441
1453
  {
1442
1454
  style: {
@@ -1448,10 +1460,10 @@ const bn = ({
1448
1460
  },
1449
1461
  children: /* @__PURE__ */ l("div", { className: "avatar-input-loader" })
1450
1462
  }
1451
- ) : /* @__PURE__ */ se(
1463
+ ) : /* @__PURE__ */ oe(
1452
1464
  "form",
1453
1465
  {
1454
- onSubmit: Vt,
1466
+ onSubmit: Jt,
1455
1467
  style: {
1456
1468
  flex: 1,
1457
1469
  display: "flex",
@@ -1465,14 +1477,14 @@ const bn = ({
1465
1477
  id: "avatar-text-input",
1466
1478
  type: "text",
1467
1479
  value: E,
1468
- onChange: (e) => Z(e.target.value),
1469
- placeholder: H === "Busy" ? "Assisting another user" : Ve || "Ask me anything",
1470
- disabled: oe || H === "Busy",
1480
+ onChange: (e) => ee(e.target.value),
1481
+ placeholder: U === "Busy" ? "Assisting another user" : He || "Ask me anything",
1482
+ disabled: ce || U === "Busy",
1471
1483
  autoComplete: "off",
1472
1484
  style: { width: "100%", height: "100%" }
1473
1485
  }
1474
1486
  ),
1475
- H === "Busy" ? /* @__PURE__ */ l(
1487
+ U === "Busy" ? /* @__PURE__ */ l(
1476
1488
  "button",
1477
1489
  {
1478
1490
  type: "button",
@@ -1504,10 +1516,10 @@ const bn = ({
1504
1516
  {
1505
1517
  type: "button",
1506
1518
  className: "mic-button",
1507
- onClick: Ft,
1508
- disabled: oe,
1519
+ onClick: Wt,
1520
+ disabled: ce,
1509
1521
  style: { backgroundColor: "#1e4a5e" },
1510
- children: /* @__PURE__ */ se(
1522
+ children: /* @__PURE__ */ oe(
1511
1523
  "svg",
1512
1524
  {
1513
1525
  width: "28",
@@ -1539,7 +1551,7 @@ const bn = ({
1539
1551
  {
1540
1552
  type: "submit",
1541
1553
  className: "mic-button",
1542
- disabled: oe,
1554
+ disabled: ce,
1543
1555
  style: { backgroundColor: "#1e4a5e" },
1544
1556
  title: "Send",
1545
1557
  children: /* @__PURE__ */ l(
@@ -1570,13 +1582,13 @@ const bn = ({
1570
1582
  }
1571
1583
  ) })
1572
1584
  ] }),
1573
- /* @__PURE__ */ l("div", { className: "avatar-wrapper", children: /* @__PURE__ */ se("div", { className: "avatar-scene-wrapper", children: [
1574
- Me !== "hidden" && /* @__PURE__ */ l(
1585
+ /* @__PURE__ */ l("div", { className: "avatar-wrapper", children: /* @__PURE__ */ oe("div", { className: "avatar-scene-wrapper", children: [
1586
+ ue !== "hidden" && /* @__PURE__ */ l(
1575
1587
  "div",
1576
1588
  {
1577
- className: `avatar-bubble${Me === "entering" ? " avatar-bubble--entering" : Me === "exiting" ? " avatar-bubble--exiting" : ""}`,
1578
- onAnimationEnd: $t,
1579
- children: /* @__PURE__ */ l("div", { ref: ft, className: `avatar-bubble__content${et ? " avatar-bubble__content--nudge" : ""}`, children: ht })
1589
+ className: `avatar-bubble${ue === "entering" ? " avatar-bubble--entering" : ue === "exiting" ? " avatar-bubble--exiting" : ""}`,
1590
+ onAnimationEnd: Gt,
1591
+ children: /* @__PURE__ */ l("div", { ref: ht, className: `avatar-bubble__content${tt ? " avatar-bubble__content--nudge" : ""}`, children: mt })
1580
1592
  }
1581
1593
  ),
1582
1594
  /* @__PURE__ */ l(
@@ -1584,8 +1596,8 @@ const bn = ({
1584
1596
  {
1585
1597
  className: "avatar-canvas-layer",
1586
1598
  style: { width: C, height: C },
1587
- children: /* @__PURE__ */ se(
1588
- qt,
1599
+ children: /* @__PURE__ */ oe(
1600
+ Qt,
1589
1601
  {
1590
1602
  shadows: !0,
1591
1603
  camera: { position: [0.2, 1.4, 3], fov: 42 },
@@ -1593,29 +1605,29 @@ const bn = ({
1593
1605
  dpr: 1.8,
1594
1606
  style: { pointerEvents: "none", width: "100%", height: "100%" },
1595
1607
  children: [
1596
- /* @__PURE__ */ l(pn, { target: cn }),
1608
+ /* @__PURE__ */ l(_n, { target: fn }),
1597
1609
  /* @__PURE__ */ l("ambientLight", { intensity: 0.7 }),
1598
1610
  /* @__PURE__ */ l("directionalLight", { position: [0, 2, 2], intensity: 1 }),
1599
- /* @__PURE__ */ l(jt, { preset: "city" }),
1600
- /* @__PURE__ */ l(Qt, { fallback: null, children: W !== null && /* @__PURE__ */ l(
1601
- mn,
1611
+ /* @__PURE__ */ l(zt, { preset: "city" }),
1612
+ /* @__PURE__ */ l(en, { fallback: null, children: V !== null && /* @__PURE__ */ l(
1613
+ wn,
1602
1614
  {
1603
- avatarUrl: W,
1604
- isPlayingRef: R,
1615
+ avatarUrl: V,
1616
+ isPlayingRef: L,
1605
1617
  visemeQueueRef: v,
1606
1618
  audioContextRef: y,
1607
- responseAudioStartTimeRef: be,
1608
- adjustments: an,
1619
+ responseAudioStartTimeRef: we,
1620
+ adjustments: dn,
1609
1621
  mood: r,
1610
1622
  expression: G,
1611
- agentResponse: ie,
1623
+ agentResponse: ae,
1612
1624
  isSpeaking: Y,
1613
- nextStartTimeRef: ae,
1614
- stopPlayback: Ge,
1625
+ nextStartTimeRef: le,
1626
+ stopPlayback: ze,
1615
1627
  setIsSpeaking: $,
1616
- expressionUrl: Xe,
1617
- onExpressionFinished: Dt,
1618
- isNudgeResponse: et,
1628
+ expressionUrl: Ke,
1629
+ onExpressionFinished: Nt,
1630
+ isNudgeResponse: tt,
1619
1631
  avatarGender: g
1620
1632
  }
1621
1633
  ) })
@@ -1626,17 +1638,17 @@ const bn = ({
1626
1638
  )
1627
1639
  ] }) })
1628
1640
  ] });
1629
- }, xn = ({
1641
+ }, Ln = ({
1630
1642
  token: f,
1631
- onNavigationRequested: L
1643
+ onNavigationRequested: A
1632
1644
  }) => /* @__PURE__ */ l(
1633
- bn,
1645
+ yn,
1634
1646
  {
1635
1647
  token: f,
1636
- onNavigationRequested: L
1648
+ onNavigationRequested: A
1637
1649
  }
1638
1650
  );
1639
1651
  export {
1640
- xn as AvatarWidget
1652
+ Ln as AvatarWidget
1641
1653
  };
1642
1654
  //# sourceMappingURL=avatar-widget.js.map