@streamoji/avatar-widget 0.2.1 → 0.2.2

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,87 +1,96 @@
1
1
  import { jsx as f, jsxs as ne } from "react/jsx-runtime";
2
- import { memo as kt, useMemo as ze, useRef as c, useState as k, useEffect as z, useCallback as Ue, useLayoutEffect as Rt, Suspense as Lt } from "react";
3
- import { useFrame as At, Canvas as Mt, useThree as Et } from "@react-three/fiber";
4
- import { useGLTF as Ge, Environment as Tt } from "@react-three/drei";
5
- import * as Ie from "three";
6
- import { GLTFLoader as It } from "three/examples/jsm/loaders/GLTFLoader.js";
7
- const H = (...d) => {
8
- }, Ct = (...d) => {
9
- }, ot = ({ analyser: d }) => {
10
- const y = c(null), v = c(null);
2
+ import { useGLTF as Qe, Environment as Mt } from "@react-three/drei";
3
+ import { useFrame as Tt, Canvas as It, useThree as Ct } from "@react-three/fiber";
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
+ import * as Fe from "three";
6
+ import { GLTFLoader as Ut } from "three/examples/jsm/loaders/GLTFLoader.js";
7
+ const B = (...u) => {
8
+ }, Nt = (...u) => {
9
+ }, ut = ({ analyser: u }) => {
10
+ const x = o(null), w = o(null);
11
11
  return z(() => {
12
- const p = y.current;
12
+ const p = x.current;
13
13
  if (!p) return;
14
- const I = p.getContext("2d", { alpha: !0 });
15
- if (!I) return;
16
- let E, R = null;
17
- d && (d.fftSize = 128, R = new Uint8Array(d.frequencyBinCount));
18
- const ge = () => {
19
- E = requestAnimationFrame(ge), (p.width !== p.offsetWidth || p.height !== p.offsetHeight) && (p.width = p.offsetWidth, p.height = p.offsetHeight);
20
- const re = p.width, C = p.height;
21
- if (re === 0 || C === 0) return;
22
- const L = C / 2;
23
- I.clearRect(0, 0, re, C), I.fillStyle = "#1e293b";
24
- const Q = 2, A = Q + 2, le = re * 0.95, m = Math.floor(le / A);
25
- (!v.current || v.current.length !== m) && (v.current = new Float32Array(m).fill(2));
26
- const be = m * A, ie = (re - be) / 2;
27
- d && R && d.getByteFrequencyData(R);
28
- const ue = R ? R.length : 0, N = Math.floor(ue * 0.7) / m, O = new Float32Array(m);
29
- for (let b = 0; b < m; b++) {
30
- let P = 0;
31
- if (R && N > 0) {
32
- const _ = Math.floor(b * N), Z = Math.floor((b + 1) * N);
33
- for (let ee = _; ee < Z; ee++) {
34
- const de = R[ee] || 0;
35
- de > P && (P = de);
14
+ const D = p.getContext("2d", { alpha: !0 });
15
+ if (!D) return;
16
+ let M, L = null;
17
+ u && (u.fftSize = 128, L = new Uint8Array(u.frequencyBinCount));
18
+ const he = () => {
19
+ M = requestAnimationFrame(he), (p.width !== p.offsetWidth || p.height !== p.offsetHeight) && (p.width = p.offsetWidth, p.height = p.offsetHeight);
20
+ const re = p.width, O = p.height;
21
+ if (re === 0 || O === 0) return;
22
+ const k = O / 2;
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);
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);
28
+ const pe = L ? L.length : 0, J = Math.floor(pe * 0.7) / g, I = new Float32Array(g);
29
+ for (let m = 0; m < g; m++) {
30
+ let $ = 0;
31
+ if (L && J > 0) {
32
+ const b = Math.floor(m * J), K = Math.floor((m + 1) * J);
33
+ for (let q = b; q < K; q++) {
34
+ const le = L[q] || 0;
35
+ le > $ && ($ = le);
36
36
  }
37
37
  }
38
- P < 10 && (P = 0);
39
- const M = P / 255, g = P > 0 ? Math.max(2, Math.pow(M, 1.4) * C * 0.25) : 2;
40
- O[b] = g;
38
+ $ < 10 && ($ = 0);
39
+ const R = $ / 255, v = $ > 0 ? Math.max(2, Math.pow(R, 1.4) * O * 0.25) : 2;
40
+ I[m] = v;
41
41
  }
42
- for (let b = 0; b < m; b++) {
43
- const P = m - 1 - b, M = Math.max(O[b], O[P]), g = v.current[b] + (M - v.current[b]) * 0.3;
44
- v.current[b] = g;
45
- const _ = ie + b * A, Z = L - g / 2;
46
- I.beginPath(), I.roundRect ? I.roundRect(_, Z, Q, g, 4) : I.fillRect(_, Z, Q, g), I.fill();
42
+ for (let m = 0; m < g; m++) {
43
+ const $ = g - 1 - m, R = Math.max(I[m], I[$]), v = w.current[m] + (R - w.current[m]) * 0.3;
44
+ w.current[m] = v;
45
+ const b = Z + m * E, K = k - v / 2;
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
- return ge(), () => {
50
- cancelAnimationFrame(E);
49
+ return he(), () => {
50
+ cancelAnimationFrame(M);
51
51
  };
52
- }, [d]), /* @__PURE__ */ f("canvas", { ref: y, style: { width: "100%", height: "100%", display: "block" } });
53
- }, at = "https://ai.streamoji.com", Ot = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev";
54
- async function Dt(d) {
55
- const y = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(d));
56
- return Array.from(new Uint8Array(y)).map((v) => v.toString(16).padStart(2, "0")).join("");
52
+ }, [u]), /* @__PURE__ */ f(
53
+ "canvas",
54
+ {
55
+ ref: x,
56
+ style: { width: "100%", height: "100%", display: "block" }
57
+ }
58
+ );
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) {
61
+ const x = await crypto.subtle.digest(
62
+ "SHA-256",
63
+ new TextEncoder().encode(u)
64
+ );
65
+ return Array.from(new Uint8Array(x)).map((w) => w.toString(16).padStart(2, "0")).join("");
57
66
  }
58
- function Ft(d) {
59
- const [y, v] = k(null);
67
+ function Vt(u) {
68
+ const [x, w] = y(null);
60
69
  return z(() => {
61
- if (!d) {
62
- v(null);
70
+ if (!u) {
71
+ w(null);
63
72
  return;
64
73
  }
65
74
  let p = !1;
66
- return Dt(d).then((I) => {
75
+ return Pt(u).then((D) => {
67
76
  if (p) return;
68
- const E = `${Ot}/${I}.glb`;
69
- fetch(E, { method: "HEAD" }).then((R) => {
70
- p || v(R.ok ? E : null);
77
+ const M = `${Wt}/${D}.glb`;
78
+ fetch(M, { method: "HEAD" }).then((L) => {
79
+ p || w(L.ok ? M : ft);
71
80
  }).catch(() => {
72
- p || v(null);
81
+ p || w(ft);
73
82
  });
74
83
  }), () => {
75
84
  p = !0;
76
85
  };
77
- }, [d]), y;
86
+ }, [u]), x;
78
87
  }
79
- const Ut = [
88
+ const Bt = [
80
89
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
81
90
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_002.glb",
82
91
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_002.glb",
83
92
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_005.glb"
84
- ], Nt = [
93
+ ], $t = [
85
94
  {
86
95
  id: "m_expr_01",
87
96
  name: "Friendly Wave",
@@ -247,517 +256,806 @@ const Ut = [
247
256
  name: "Take It Easy",
248
257
  url: "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/F_Talking_Variations_006.glb"
249
258
  }
250
- ], Wt = [
259
+ ], Ht = [
251
260
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_005.glb",
252
261
  "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/expression/M_Talking_Variations_007.glb"
253
- ], Pt = {
262
+ ], jt = {
254
263
  zoom: 0.85,
255
264
  position: [0.15, -0.8, 0],
256
265
  scale: 1.5,
257
266
  rotation: [0.15, 0.02, 0]
258
- }, Vt = [-0.45, 1.9, 0.1], Bt = {
267
+ }, Jt = [-0.45, 1.9, 0.1], qt = {
259
268
  browInnerUp: 0.2
260
- }, Ye = 0.18, $t = 1, Ne = {
269
+ }, Ze = 0.18, Gt = 1, He = {
261
270
  neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
262
- happy: { mouthSmileLeft: 0.2, mouthSmileRight: 0.2, eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
263
- sad: { eyeLookDownLeft: 0.2, eyeLookDownRight: 0.2, browDownRight: 0.1, browInnerUp: 0.6, browOuterUpRight: 0.2, eyeSquintLeft: 0.7, eyeSquintRight: 0.7, mouthFrownLeft: 0.8, mouthFrownRight: 0.8, mouthLeft: 0.2, mouthPucker: 0.5, mouthRollLower: 0.2, mouthRollUpper: 0.2, mouthShrugLower: 0.2, mouthShrugUpper: 0.2, mouthStretchLeft: 0.4 },
264
- angry: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1, browDownLeft: 0.6, browDownRight: 0.6, jawForward: 0.3, mouthFrownLeft: 0.7, mouthFrownRight: 0.7, mouthRollLower: 0.2, mouthShrugLower: 0.3 },
265
- fear: { browInnerUp: 0.7, eyeSquintLeft: 0.5, eyeSquintRight: 0.5, eyeWideLeft: 0.6, eyeWideRight: 0.6, mouthClose: 0.1, mouthFunnel: 0.3, mouthShrugLower: 0.5, mouthShrugUpper: 0.5 },
266
- disgust: { browDownLeft: 0.7, browDownRight: 0.1, browInnerUp: 0.3, eyeSquintLeft: 1, eyeSquintRight: 1, eyeWideLeft: 0.5, eyeWideRight: 0.5, mouthLeft: 0.4, mouthPressLeft: 0.3, mouthRollLower: 0.3, mouthShrugLower: 0.3, mouthShrugUpper: 0.8, mouthUpperUpLeft: 0.3, noseSneerLeft: 1, noseSneerRight: 0.7 },
267
- love: { browInnerUp: 0.4, browOuterUpLeft: 0.2, browOuterUpRight: 0.2, mouthSmileLeft: 0.2, mouthSmileRight: 0.2, eyeBlinkLeft: 0.6, eyeBlinkRight: 0.6, eyeWideLeft: 0.7, eyeWideRight: 0.7, mouthDimpleLeft: 0.1, mouthDimpleRight: 0.1, mouthPressLeft: 0.2, mouthShrugUpper: 0.2, mouthUpperUpLeft: 0.1, mouthUpperUpRight: 0.1 }
268
- }, Ht = [
271
+ happy: {
272
+ mouthSmileLeft: 0.2,
273
+ mouthSmileRight: 0.2,
274
+ eyeLookDownLeft: 0.1,
275
+ eyeLookDownRight: 0.1
276
+ },
277
+ sad: {
278
+ eyeLookDownLeft: 0.2,
279
+ eyeLookDownRight: 0.2,
280
+ browDownRight: 0.1,
281
+ browInnerUp: 0.6,
282
+ browOuterUpRight: 0.2,
283
+ eyeSquintLeft: 0.7,
284
+ eyeSquintRight: 0.7,
285
+ mouthFrownLeft: 0.8,
286
+ mouthFrownRight: 0.8,
287
+ mouthLeft: 0.2,
288
+ mouthPucker: 0.5,
289
+ mouthRollLower: 0.2,
290
+ mouthRollUpper: 0.2,
291
+ mouthShrugLower: 0.2,
292
+ mouthShrugUpper: 0.2,
293
+ mouthStretchLeft: 0.4
294
+ },
295
+ angry: {
296
+ eyeLookDownLeft: 0.1,
297
+ eyeLookDownRight: 0.1,
298
+ browDownLeft: 0.6,
299
+ browDownRight: 0.6,
300
+ jawForward: 0.3,
301
+ mouthFrownLeft: 0.7,
302
+ mouthFrownRight: 0.7,
303
+ mouthRollLower: 0.2,
304
+ mouthShrugLower: 0.3
305
+ },
306
+ fear: {
307
+ browInnerUp: 0.7,
308
+ eyeSquintLeft: 0.5,
309
+ eyeSquintRight: 0.5,
310
+ eyeWideLeft: 0.6,
311
+ eyeWideRight: 0.6,
312
+ mouthClose: 0.1,
313
+ mouthFunnel: 0.3,
314
+ mouthShrugLower: 0.5,
315
+ mouthShrugUpper: 0.5
316
+ },
317
+ disgust: {
318
+ browDownLeft: 0.7,
319
+ browDownRight: 0.1,
320
+ browInnerUp: 0.3,
321
+ eyeSquintLeft: 1,
322
+ eyeSquintRight: 1,
323
+ eyeWideLeft: 0.5,
324
+ eyeWideRight: 0.5,
325
+ mouthLeft: 0.4,
326
+ mouthPressLeft: 0.3,
327
+ mouthRollLower: 0.3,
328
+ mouthShrugLower: 0.3,
329
+ mouthShrugUpper: 0.8,
330
+ mouthUpperUpLeft: 0.3,
331
+ noseSneerLeft: 1,
332
+ noseSneerRight: 0.7
333
+ },
334
+ love: {
335
+ browInnerUp: 0.4,
336
+ browOuterUpLeft: 0.2,
337
+ browOuterUpRight: 0.2,
338
+ mouthSmileLeft: 0.2,
339
+ mouthSmileRight: 0.2,
340
+ eyeBlinkLeft: 0.6,
341
+ eyeBlinkRight: 0.6,
342
+ eyeWideLeft: 0.7,
343
+ eyeWideRight: 0.7,
344
+ mouthDimpleLeft: 0.1,
345
+ mouthDimpleRight: 0.1,
346
+ mouthPressLeft: 0.2,
347
+ mouthShrugUpper: 0.2,
348
+ mouthUpperUpLeft: 0.1,
349
+ mouthUpperUpRight: 0.1
350
+ }
351
+ }, zt = [
269
352
  { key: "viseme_aa", mix: { jawOpen: 0.6 } },
270
- { key: "viseme_E", mix: { mouthPressLeft: 0.8, mouthPressRight: 0.8, mouthDimpleLeft: 1, mouthDimpleRight: 1, jawOpen: 0.3 } },
271
- { key: "viseme_I", mix: { mouthPressLeft: 0.6, mouthPressRight: 0.6, mouthDimpleLeft: 0.6, mouthDimpleRight: 0.6, jawOpen: 0.2 } },
353
+ {
354
+ key: "viseme_E",
355
+ mix: {
356
+ mouthPressLeft: 0.8,
357
+ mouthPressRight: 0.8,
358
+ mouthDimpleLeft: 1,
359
+ mouthDimpleRight: 1,
360
+ jawOpen: 0.3
361
+ }
362
+ },
363
+ {
364
+ key: "viseme_I",
365
+ mix: {
366
+ mouthPressLeft: 0.6,
367
+ mouthPressRight: 0.6,
368
+ mouthDimpleLeft: 0.6,
369
+ mouthDimpleRight: 0.6,
370
+ jawOpen: 0.2
371
+ }
372
+ },
272
373
  { key: "viseme_O", mix: { mouthPucker: 1, jawForward: 0.6, jawOpen: 0.2 } },
273
374
  { key: "viseme_U", mix: { mouthFunnel: 1 } },
274
- { key: "viseme_PP", mix: { mouthRollLower: 0.3, mouthRollUpper: 0.3, mouthUpperUpLeft: 0.3, mouthUpperUpRight: 0.3 } },
275
- { key: "viseme_FF", mix: { mouthPucker: 1, mouthShrugUpper: 1, mouthLowerDownLeft: 0.2, mouthLowerDownRight: 0.2, mouthDimpleLeft: 1, mouthDimpleRight: 1, mouthRollLower: 0.3 } },
276
- { key: "viseme_DD", mix: { mouthPressLeft: 0.8, mouthPressRight: 0.8, mouthFunnel: 0.5, jawOpen: 0.2 } },
277
- { key: "viseme_SS", mix: { mouthPressLeft: 0.8, mouthPressRight: 0.8, mouthLowerDownLeft: 0.5, mouthLowerDownRight: 0.5, jawOpen: 0.1 } },
278
- { key: "viseme_TH", mix: { mouthRollUpper: 0.3, jawOpen: 0.2, tongueOut: 0.4 } },
375
+ {
376
+ key: "viseme_PP",
377
+ mix: {
378
+ mouthRollLower: 0.3,
379
+ mouthRollUpper: 0.3,
380
+ mouthUpperUpLeft: 0.3,
381
+ mouthUpperUpRight: 0.3
382
+ }
383
+ },
384
+ {
385
+ key: "viseme_FF",
386
+ mix: {
387
+ mouthPucker: 1,
388
+ mouthShrugUpper: 1,
389
+ mouthLowerDownLeft: 0.2,
390
+ mouthLowerDownRight: 0.2,
391
+ mouthDimpleLeft: 1,
392
+ mouthDimpleRight: 1,
393
+ mouthRollLower: 0.3
394
+ }
395
+ },
396
+ {
397
+ key: "viseme_DD",
398
+ mix: {
399
+ mouthPressLeft: 0.8,
400
+ mouthPressRight: 0.8,
401
+ mouthFunnel: 0.5,
402
+ jawOpen: 0.2
403
+ }
404
+ },
405
+ {
406
+ key: "viseme_SS",
407
+ mix: {
408
+ mouthPressLeft: 0.8,
409
+ mouthPressRight: 0.8,
410
+ mouthLowerDownLeft: 0.5,
411
+ mouthLowerDownRight: 0.5,
412
+ jawOpen: 0.1
413
+ }
414
+ },
415
+ {
416
+ key: "viseme_TH",
417
+ mix: { mouthRollUpper: 0.3, jawOpen: 0.2, tongueOut: 0.4 }
418
+ },
279
419
  { key: "viseme_CH", mix: { mouthPucker: 0.5, jawOpen: 0.2 } },
280
420
  { key: "viseme_RR", mix: { mouthPucker: 0.5, jawOpen: 0.2 } },
281
- { key: "viseme_kk", mix: { mouthLowerDownLeft: 0.4, mouthLowerDownRight: 0.4, mouthDimpleLeft: 0.3, mouthDimpleRight: 0.3, mouthFunnel: 0.3, mouthPucker: 0.3, jawOpen: 0.15 } },
282
- { key: "viseme_nn", mix: { mouthLowerDownLeft: 0.4, mouthLowerDownRight: 0.4, mouthDimpleLeft: 0.3, mouthDimpleRight: 0.3, mouthFunnel: 0.3, mouthPucker: 0.3, jawOpen: 0.15, tongueOut: 0.2 } },
421
+ {
422
+ key: "viseme_kk",
423
+ mix: {
424
+ mouthLowerDownLeft: 0.4,
425
+ mouthLowerDownRight: 0.4,
426
+ mouthDimpleLeft: 0.3,
427
+ mouthDimpleRight: 0.3,
428
+ mouthFunnel: 0.3,
429
+ mouthPucker: 0.3,
430
+ jawOpen: 0.15
431
+ }
432
+ },
433
+ {
434
+ key: "viseme_nn",
435
+ mix: {
436
+ mouthLowerDownLeft: 0.4,
437
+ mouthLowerDownRight: 0.4,
438
+ mouthDimpleLeft: 0.3,
439
+ mouthDimpleRight: 0.3,
440
+ mouthFunnel: 0.3,
441
+ mouthPucker: 0.3,
442
+ jawOpen: 0.15,
443
+ tongueOut: 0.2
444
+ }
445
+ },
283
446
  { key: "viseme_sil", mix: {} }
284
- ], jt = {
285
- aei: [{ v: "E", w: 0.8 }, { v: "I", w: 0.2 }],
447
+ ], Yt = {
448
+ aei: [
449
+ { v: "E", w: 0.8 },
450
+ { v: "I", w: 0.2 }
451
+ ],
286
452
  ee: [{ v: "I", w: 1 }],
287
453
  oo: [{ v: "O", w: 1 }],
288
454
  u: [{ v: "U", w: 1 }],
289
455
  aa: [{ v: "aa", w: 1 }],
290
- ah: [{ v: "aa", w: 0.7 }, { v: "O", w: 0.3 }],
456
+ ah: [
457
+ { v: "aa", w: 0.7 },
458
+ { v: "O", w: 0.3 }
459
+ ],
291
460
  bmp: [{ v: "PP", w: 1 }],
292
461
  fv: [{ v: "FF", w: 1 }],
293
462
  th: [{ v: "TH", w: 1 }],
294
463
  l: [{ v: "nn", w: 1 }],
295
464
  r: [{ v: "RR", w: 1 }],
296
- qw: [{ v: "U", w: 0.6 }, { v: "O", w: 0.4 }],
465
+ qw: [
466
+ { v: "U", w: 0.6 },
467
+ { v: "O", w: 0.4 }
468
+ ],
297
469
  chjsh: [{ v: "CH", w: 1 }],
298
- cdgknstxyz: [{ v: "DD", w: 0.6 }, { v: "SS", w: 0.4 }],
470
+ cdgknstxyz: [
471
+ { v: "DD", w: 0.6 },
472
+ { v: "SS", w: 0.4 }
473
+ ],
299
474
  sil: [{ v: "sil", w: 1 }]
300
475
  };
301
- function Jt(d) {
302
- if (!d) return [{ v: "sil", w: 1 }];
303
- const y = d.toLowerCase();
304
- return jt[y] ?? [{ v: "sil", w: 1 }];
476
+ function Xt(u) {
477
+ if (!u) return [{ v: "sil", w: 1 }];
478
+ const x = u.toLowerCase();
479
+ return Yt[x] ?? [{ v: "sil", w: 1 }];
305
480
  }
306
- function qt({ target: d }) {
307
- const { camera: y } = Et();
481
+ function Kt({ target: u }) {
482
+ const { camera: x } = Ct();
308
483
  return z(() => {
309
- y.lookAt(...d);
310
- }, [y, d]), null;
484
+ x.lookAt(...u);
485
+ }, [x, u]), null;
311
486
  }
312
- function q(d, y, v) {
313
- if (!d || !d.morphTargetDictionary) return;
314
- const p = d, I = p.morphTargetDictionary, E = p.morphTargetInfluences;
315
- if (E)
316
- for (const R in I)
317
- R.toLowerCase() === y.toLowerCase() && (E[I[R]] = v);
487
+ function G(u, x, w) {
488
+ if (!u || !u.morphTargetDictionary)
489
+ return;
490
+ const p = u, D = p.morphTargetDictionary, M = p.morphTargetInfluences;
491
+ if (M)
492
+ for (const L in D)
493
+ L.toLowerCase() === x.toLowerCase() && (M[D[L]] = w);
318
494
  }
319
- function ct(d, y = 0.97) {
320
- if (!d) return;
321
- const v = d;
322
- if (v.morphTargetInfluences)
323
- for (let p = 0; p < v.morphTargetInfluences.length; p++)
324
- v.morphTargetInfluences[p] *= y;
495
+ function ht(u, x = 0.97) {
496
+ if (!u) return;
497
+ const w = u;
498
+ if (w.morphTargetInfluences)
499
+ for (let p = 0; p < w.morphTargetInfluences.length; p++)
500
+ w.morphTargetInfluences[p] *= x;
325
501
  }
326
- const Gt = kt(({ avatarUrl: d, isPlayingRef: y, visemeQueueRef: v, audioContextRef: p, responseAudioStartTimeRef: I, adjustments: E, mood: R, expression: ge, agentResponse: re, isSpeaking: C, nextStartTimeRef: L, stopPlayback: Q, setIsSpeaking: W, expressionUrl: A, onExpressionFinished: le }) => {
327
- const { scene: m } = Ge(d), be = Ge(Ut), ie = ze(() => be.flatMap((h) => h.animations), [be]), ue = Ge(Wt), se = ze(() => ue.flatMap((h) => h.animations), [ue]), N = c(null), O = c(null), b = c(null), P = c([]), [M] = k(() => new Ie.AnimationMixer(m)), g = c({}), _ = c(null), Z = c(0), ee = c(!1), de = c(0), _e = c(null);
328
- z(() => {
329
- if (!(!ie || !m)) {
330
- if (ie.forEach((h, o) => {
331
- const r = `idle_${o}`;
332
- if (!g.current[r]) {
333
- const t = M.clipAction(h, m);
334
- t.name = r, t.setLoop(Ie.LoopOnce, 1), t.clampWhenFinished = !0, g.current[r] = t;
335
- }
336
- }), se.forEach((h, o) => {
337
- const r = `talk_${o}`;
338
- if (!g.current[r]) {
339
- const t = M.clipAction(h, m);
340
- t.name = r, t.setLoop(Ie.LoopOnce, 1), t.clampWhenFinished = !0, g.current[r] = t;
502
+ const Qt = Dt(
503
+ ({
504
+ avatarUrl: u,
505
+ isPlayingRef: x,
506
+ visemeQueueRef: w,
507
+ audioContextRef: p,
508
+ responseAudioStartTimeRef: D,
509
+ adjustments: M,
510
+ mood: L,
511
+ expression: he,
512
+ agentResponse: re,
513
+ isSpeaking: O,
514
+ nextStartTimeRef: k,
515
+ stopPlayback: Q,
516
+ setIsSpeaking: U,
517
+ expressionUrl: E,
518
+ onExpressionFinished: ce
519
+ }) => {
520
+ const { scene: g } = Qe(u), ke = Qe(Bt), Z = et(
521
+ () => ke.flatMap((d) => d.animations),
522
+ [ke]
523
+ ), pe = Qe(Ht), se = et(
524
+ () => pe.flatMap((d) => d.animations),
525
+ [pe]
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
+ z(() => {
528
+ if (!(!Z || !g)) {
529
+ if (Z.forEach((d, c) => {
530
+ const s = `idle_${c}`;
531
+ if (!v.current[s]) {
532
+ const n = R.clipAction(d, g);
533
+ n.name = s, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[s] = n;
534
+ }
535
+ }), se.forEach((d, c) => {
536
+ const s = `talk_${c}`;
537
+ if (!v.current[s]) {
538
+ const n = R.clipAction(d, g);
539
+ n.name = s, n.setLoop(Fe.LoopOnce, 1), n.clampWhenFinished = !0, v.current[s] = n;
540
+ }
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);
341
544
  }
342
- }), ie.length > 0) {
343
- const h = g.current.idle_0, o = _.current && M.existingAction(_.current.getClip());
344
- h && !o && (h.reset().fadeIn(0.5).play(), _.current = h);
545
+ return () => {
546
+ R.stopAllAction(), v.current = {}, b.current = null;
547
+ };
345
548
  }
346
- return () => {
347
- M.stopAllAction(), g.current = {}, _.current = null;
549
+ }, [Z, se, g, R]);
550
+ const Re = o("");
551
+ z(() => {
552
+ if (!E || !g || E === Re.current) return;
553
+ Re.current = E, ee.current = E, new Ut().load(
554
+ E,
555
+ (c) => {
556
+ if (c.animations && c.animations.length > 0) {
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) {
559
+ const h = b.current;
560
+ n.reset().fadeIn(0.3).play(), h && h !== n && h.crossFadeTo(n, 0.3, !0), b.current = n, ee.current = null;
561
+ }
562
+ }
563
+ },
564
+ void 0,
565
+ (c) => {
566
+ console.error(`[ANIMATION] Failed to load ${E}`, c);
567
+ }
568
+ );
569
+ }, [E, g, R, O]), z(() => {
570
+ const d = (c) => {
571
+ const s = c.action, n = s.name || "";
572
+ if (n.startsWith("idle_")) {
573
+ const H = (parseInt(n.split("_")[1]) + 1) % Z.length, Y = v.current[`idle_${H}`];
574
+ Y && (Y.reset().fadeIn(0.5).play(), s.crossFadeTo(Y, 0.5, !0), b.current = Y);
575
+ } else if (n.startsWith("EXPR_")) {
576
+ if (O) {
577
+ const h = v.current.talk_0;
578
+ h && (h.reset().fadeIn(0.5).play(), s.crossFadeTo(h, 0.5, !0), b.current = h);
579
+ } else {
580
+ const h = v.current.idle_0;
581
+ h && (h.reset().fadeIn(0.5).play(), s.crossFadeTo(h, 0.5, !0), b.current = h);
582
+ }
583
+ ce && ce();
584
+ } else if (n.startsWith("talk_"))
585
+ if (O) {
586
+ const H = (parseInt(n.split("_")[1]) + 1) % se.length, Y = v.current[`talk_${H}`];
587
+ Y && (Y.reset().fadeIn(0.3).play(), s.crossFadeTo(Y, 0.3, !0), b.current = Y);
588
+ } else {
589
+ const h = v.current.idle_0;
590
+ h && (h.reset().fadeIn(0.5).play(), s.crossFadeTo(h, 0.5, !0), b.current = h);
591
+ }
348
592
  };
349
- }
350
- }, [ie, se, m, M]);
351
- const Ce = c("");
352
- z(() => {
353
- if (!A || !m || A === Ce.current) return;
354
- Ce.current = A, _e.current = A, new It().load(A, (o) => {
355
- if (o.animations && o.animations.length > 0) {
356
- const r = o.animations[0], t = M.clipAction(r, m);
357
- if (t.name = `EXPR_${A}`, t.setLoop(Ie.LoopOnce, 1), t.clampWhenFinished = !0, g.current[`EXPR_${A}`] = t, C && _e.current === A) {
358
- const l = _.current;
359
- t.reset().fadeIn(0.3).play(), l && l !== t && l.crossFadeTo(t, 0.3, !0), _.current = t, _e.current = null;
593
+ return R.addEventListener("finished", d), () => R.removeEventListener("finished", d);
594
+ }, [
595
+ R,
596
+ Z,
597
+ se,
598
+ O,
599
+ ce
600
+ ]), z(() => {
601
+ if (O && g) {
602
+ const d = b.current, c = d?.name || "";
603
+ if (c.startsWith("idle_") || c.startsWith("talk_") || c === "") {
604
+ const s = ee.current;
605
+ if (s) {
606
+ const n = v.current[`EXPR_${s}`];
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;
609
+ return;
610
+ }
611
+ }
612
+ if (c.startsWith("idle_") || c === "") {
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);
615
+ }
360
616
  }
361
- }
362
- }, void 0, (o) => {
363
- console.error(`[ANIMATION] Failed to load ${A}`, o);
364
- });
365
- }, [A, m, M, C]), z(() => {
366
- const h = (o) => {
367
- const r = o.action, t = r.name || "";
368
- if (t.startsWith("idle_")) {
369
- const j = (parseInt(t.split("_")[1]) + 1) % ie.length, D = g.current[`idle_${j}`];
370
- D && (D.reset().fadeIn(0.5).play(), r.crossFadeTo(D, 0.5, !0), _.current = D);
371
- } else if (t.startsWith("EXPR_")) {
372
- if (C) {
373
- const l = g.current.talk_0;
374
- l && (l.reset().fadeIn(0.5).play(), r.crossFadeTo(l, 0.5, !0), _.current = l);
375
- } else {
376
- const l = g.current.idle_0;
377
- l && (l.reset().fadeIn(0.5).play(), r.crossFadeTo(l, 0.5, !0), _.current = l);
617
+ } else if (!O && g) {
618
+ const d = b.current, c = d?.name || "";
619
+ if (c.startsWith("talk_") || c.startsWith("EXPR_")) {
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);
378
622
  }
379
- le && le();
380
- } else if (t.startsWith("talk_"))
381
- if (C) {
382
- const j = (parseInt(t.split("_")[1]) + 1) % se.length, D = g.current[`talk_${j}`];
383
- D && (D.reset().fadeIn(0.3).play(), r.crossFadeTo(D, 0.3, !0), _.current = D);
384
- } else {
385
- const l = g.current.idle_0;
386
- l && (l.reset().fadeIn(0.5).play(), r.crossFadeTo(l, 0.5, !0), _.current = l);
623
+ }
624
+ }, [O, g, E]), z(() => {
625
+ if (!g) return;
626
+ g.traverse((s) => {
627
+ if (s.isMesh && s.morphTargetDictionary) {
628
+ const n = s.name.toLowerCase();
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}`));
387
630
  }
388
- };
389
- return M.addEventListener("finished", h), () => M.removeEventListener("finished", h);
390
- }, [M, ie, se, C, le]), z(() => {
391
- if (C && m) {
392
- const h = _.current, o = h?.name || "";
393
- if (o.startsWith("idle_") || o.startsWith("talk_") || o === "") {
394
- const r = _e.current;
395
- if (r) {
396
- const t = g.current[`EXPR_${r}`];
397
- if (t) {
398
- t.reset().fadeIn(0.3).play(), h && h !== t && h.crossFadeTo(t, 0.3, !0), _.current = t, _e.current = null;
399
- return;
400
- }
631
+ });
632
+ const d = I.current?.morphTargetDictionary;
633
+ d && Object.keys(d).filter(
634
+ (s) => s.toLowerCase().includes("brow")
635
+ );
636
+ const c = [];
637
+ g.traverse((s) => {
638
+ if (s.isMesh) {
639
+ const h = s.morphTargetDictionary;
640
+ h && Object.keys(h).some((H) => H.toLowerCase().includes("brow")) && c.push(s);
401
641
  }
402
- if (o.startsWith("idle_") || o === "") {
403
- const t = g.current.talk_0;
404
- t && (t.reset().fadeIn(0.5).play(), h && h.crossFadeTo(t, 0.5, !0), _.current = t);
642
+ }), $.current = c, c.length > 0 && B("[ANIMATION] Meshes with brow morphs:", c.length);
643
+ }, [g]);
644
+ const Ue = (d, c = 1) => {
645
+ const s = `viseme_${d}`.toLowerCase(), n = zt.find((h) => h.key.toLowerCase() === s);
646
+ if (n)
647
+ for (const h in n.mix) {
648
+ const H = n.mix[h] * c;
649
+ G(I.current, h, H), G(m.current, h, H);
405
650
  }
651
+ }, Ce = (d) => {
652
+ const c = He[d] ?? He.neutral;
653
+ for (const s in c)
654
+ G(I.current, s, c[s]), G(m.current, s, c[s]);
655
+ };
656
+ return Tt((d, c) => {
657
+ const s = Math.pow(0.88, 60 * c);
658
+ ht(I.current, s), ht(m.current, s), Ce(L);
659
+ const n = d.clock.elapsedTime;
660
+ let h = 0;
661
+ if (Math.floor(n) % 5 === 0 && Math.floor((n - c) % 5) !== 0) {
662
+ let j = null;
663
+ g.traverse((W) => {
664
+ W.name.toLowerCase().includes("hips") && (j = W);
665
+ });
666
+ const ie = j ? `Hips Y: ${j.position.y.toFixed(4)}` : "Hips not found";
667
+ B(`[ANIMATION] Mixer Time: ${R.time.toFixed(2)}, ${ie}`);
406
668
  }
407
- } else if (!C && m) {
408
- const h = _.current, o = h?.name || "";
409
- if (o.startsWith("talk_") || o.startsWith("EXPR_")) {
410
- const r = g.current.idle_0;
411
- r && (r.reset().fadeIn(0.5).play(), h && h.crossFadeTo(r, 0.5, !0), _.current = r);
412
- }
413
- }
414
- }, [C, m, A]), z(() => {
415
- if (!m) return;
416
- m.traverse((r) => {
417
- if (r.isMesh && r.morphTargetDictionary) {
418
- const t = r.name.toLowerCase();
419
- (t.includes("head") || t.includes("avatar")) && (O.current = r, H(`[ANIMATION] Found head mesh: ${r.name}`)), t.includes("teeth") && (b.current = r, H(`[ANIMATION] Found teeth mesh: ${r.name}`));
420
- }
421
- });
422
- const h = O.current?.morphTargetDictionary;
423
- h && Object.keys(h).filter((r) => r.toLowerCase().includes("brow"));
424
- const o = [];
425
- m.traverse((r) => {
426
- if (r.isMesh) {
427
- const l = r.morphTargetDictionary;
428
- l && Object.keys(l).some((j) => j.toLowerCase().includes("brow")) && o.push(r);
429
- }
430
- }), P.current = o, o.length > 0 && H("[ANIMATION] Meshes with brow morphs:", o.length);
431
- }, [m]);
432
- const We = (h, o = 1) => {
433
- const r = `viseme_${h}`.toLowerCase(), t = Ht.find((l) => l.key.toLowerCase() === r);
434
- if (t)
435
- for (const l in t.mix) {
436
- const j = t.mix[l] * o;
437
- q(O.current, l, j), q(b.current, l, j);
669
+ if (R.update(c), n > K.current && !q.current && (q.current = !0, le.current = n), q.current) {
670
+ const ie = (n - le.current) / 0.3;
671
+ if (ie >= 1)
672
+ q.current = !1, K.current = n + 2 + Math.random() * 5;
673
+ else {
674
+ const W = ie < 0.5 ? ie * 2 : (1 - ie) * 2;
675
+ G(I.current, "eyeBlinkLeft", W), G(I.current, "eyeBlinkRight", W), G(m.current, "eyeBlinkLeft", W), G(m.current, "eyeBlinkRight", W), h = W * qt.browInnerUp;
676
+ }
438
677
  }
439
- }, Pe = (h) => {
440
- const o = Ne[h] ?? Ne.neutral;
441
- for (const r in o)
442
- q(O.current, r, o[r]), q(b.current, r, o[r]);
443
- };
444
- return At((h, o) => {
445
- const r = Math.pow(0.88, 60 * o);
446
- ct(O.current, r), ct(b.current, r), Pe(R);
447
- const t = h.clock.elapsedTime;
448
- let l = 0;
449
- if (Math.floor(t) % 5 === 0 && Math.floor((t - o) % 5) !== 0) {
450
- let J = null;
451
- m.traverse((G) => {
452
- G.name.toLowerCase().includes("hips") && (J = G);
453
- });
454
- const fe = J ? `Hips Y: ${J.position.y.toFixed(4)}` : "Hips not found";
455
- H(`[ANIMATION] Mixer Time: ${M.time.toFixed(2)}, ${fe}`);
456
- }
457
- if (M.update(o), t > Z.current && !ee.current && (ee.current = !0, de.current = t), ee.current) {
458
- const fe = (t - de.current) / 0.3;
459
- if (fe >= 1)
460
- ee.current = !1, Z.current = t + 2 + Math.random() * 5;
461
- else {
462
- const G = fe < 0.5 ? fe * 2 : (1 - fe) * 2;
463
- q(O.current, "eyeBlinkLeft", G), q(O.current, "eyeBlinkRight", G), q(b.current, "eyeBlinkLeft", G), q(b.current, "eyeBlinkRight", G), l = G * Bt.browInnerUp;
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
+ 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];
681
+ J.current.rotation.y = Fe.MathUtils.lerp(
682
+ J.current.rotation.y,
683
+ j,
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];
464
686
  }
465
- }
466
- const j = Ne[R] ?? Ne.neutral, D = j.browInnerUp ?? 0, we = j.browOuterUpLeft ?? 0, Le = j.browOuterUpRight ?? 0, xe = t * $t, Ae = Ye * Math.sin(xe), Me = Ye * 0.7 * Math.sin(xe + 0.7), Xe = Ye * 0.7 * Math.sin(xe + 1.3), ke = (J) => Math.max(0, Math.min(1, J)), Ee = ke(D + Ae), Te = ke(we + Me), he = ke(Le + Xe), ve = ke(Ee + l);
467
- if (q(O.current, "browInnerUp", ve), q(b.current, "browInnerUp", ve), q(O.current, "browOuterUpLeft", Te), q(b.current, "browOuterUpLeft", Te), q(O.current, "browOuterUpRight", he), q(b.current, "browOuterUpRight", he), N.current) {
468
- const J = y.current ? 0 : E.rotation[1];
469
- N.current.rotation.y = Ie.MathUtils.lerp(N.current.rotation.y, J, 0.1), N.current.position.set(...E.position), N.current.scale.setScalar(E.scale), N.current.rotation.x = E.rotation[0], N.current.rotation.z = E.rotation[2];
470
- }
471
- if (y.current && p.current) {
472
- const J = p.current.currentTime, X = (J - I.current) * 1e3 - -150;
473
- for (let oe = 0; oe < v.current.length; oe++) {
474
- const K = v.current[oe];
475
- X >= K.vtime && X < K.vtime + K.vduration && We(K.viseme, K.weight ?? 1);
687
+ if (x.current && p.current) {
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];
691
+ ve >= Se.vtime && ve < Se.vtime + Se.vduration && Ue(Se.viseme, Se.weight ?? 1);
692
+ }
693
+ j > k.current + 0.5 && (Q(), U(!1));
476
694
  }
477
- J > L.current + 0.5 && (Q(), W(!1));
478
- }
479
- }), /* @__PURE__ */ f("group", { ref: N, children: /* @__PURE__ */ f("primitive", { object: m }) });
480
- });
481
- function Yt(d) {
482
- return d ? d.charAt(0).toUpperCase() + d.slice(1).toLowerCase() : "";
695
+ }), /* @__PURE__ */ f("group", { ref: J, children: /* @__PURE__ */ f("primitive", { object: g }) });
696
+ }
697
+ );
698
+ function Zt(u) {
699
+ return u ? u.charAt(0).toUpperCase() + u.slice(1).toLowerCase() : "";
483
700
  }
484
- const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
485
- const p = d ?? y ?? "", I = Ft(p || void 0), [E, R] = k(""), [ge, re] = k(""), [C, L] = k("Ready"), [Q, W] = k(!1), [A, le] = k(!1), m = c(!1), be = c([]), ie = c(0), ue = c(!1), se = c([]), N = c(null), O = c([]);
486
- c([]);
487
- const b = c([]), P = c(0), M = c(0), g = c(0), _ = c(0), [Z, ee] = k(null), de = c(null), [_e, Ce] = k("neutral"), [We, Pe] = k(""), [h, o] = k(""), [r, t] = k("Chat with us"), [l, j] = k(null), [D, we] = k("hidden"), [Le, xe] = k(""), Ae = c(null), Me = c(D);
488
- Me.current = D;
489
- const [Xe, ke] = k(null), Ee = c(null), Te = c(null), [he, ve] = k("hidden"), [J, fe] = k(""), G = c(he);
490
- G.current = he;
491
- const X = c(""), oe = c(!1), K = c(""), Re = ze(() => C === "Thinking..." || C === "Processing Voice..." ? C : l != null && l !== "" && l !== "none" && l !== "<none>" ? `Enter ${Yt(l)}` : null, [C, l]), Oe = Re != null && Re !== "";
701
+ const en = ({
702
+ token: u,
703
+ agentToken: x,
704
+ onNavigationRequested: w
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(
707
+ () => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
708
+ );
709
+ z(() => {
710
+ const e = window.matchMedia("(max-width: 480px)"), t = () => ke(e.matches);
711
+ return e.addEventListener("change", t), () => e.removeEventListener("change", t);
712
+ }, []);
713
+ const Z = g ? 80 : 600, pe = o(!1), se = o([]), J = o(0), I = o(!1), m = o([]), $ = o(null), R = o([]);
714
+ o([]);
715
+ const v = o([]), b = o(0), K = o(0), q = o(0), le = o(0), ee = o(!1), [Re, Ue] = y(
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(
718
+ null
719
+ ), [ge, _e] = y("hidden"), [De, we] = y(""), Oe = o(null), Le = o(ge);
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);
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 !== "";
492
724
  z(() => {
493
- const e = Me.current;
725
+ const e = Le.current;
494
726
  if (!(e === "exiting" || e === "entering")) {
495
727
  if (e === "hidden") {
496
- Oe && (xe(Re ?? ""), we("entering"));
728
+ We && (we(Ie ?? ""), _e("entering"));
497
729
  return;
498
730
  }
499
- e === "visible" && (!Oe || Re !== Le) && (Ae.current = Oe ? Re : null, we("exiting"));
731
+ e === "visible" && (!We || Ie !== De) && (Oe.current = We ? Ie : null, _e("exiting"));
500
732
  }
501
- }, [Oe, Re, D, Le]);
502
- const lt = Ue(() => {
503
- const e = Me.current;
733
+ }, [
734
+ We,
735
+ Ie,
736
+ ge,
737
+ De
738
+ ]);
739
+ const pt = $e(() => {
740
+ const e = Le.current;
504
741
  if (e === "exiting") {
505
- we("hidden");
506
- const i = Ae.current;
507
- Ae.current = null, i != null && i !== "" && (xe(i), we("entering"));
508
- } else e === "entering" && we("visible");
509
- }, []), ut = (e) => {
742
+ _e("hidden");
743
+ const t = Oe.current;
744
+ Oe.current = null, t != null && t !== "" && (we(t), _e("entering"));
745
+ } else e === "entering" && _e("visible");
746
+ }, []), mt = (e) => {
510
747
  if (!e) return;
511
748
  if (e.mood != null) {
512
- const n = String(e.mood).toLowerCase();
513
- Ce(n);
749
+ const r = String(e.mood).toLowerCase();
750
+ c(r);
514
751
  }
515
752
  if (e.expression != null) {
516
- const n = String(e.expression).trim();
517
- Pe(n);
518
- const u = Nt.find((w) => w.name.toLowerCase() === n.toLowerCase());
519
- H(`[STREAM] Animation match for "${n}": ${u ? u.name : "NONE"}`), o(u?.url ?? "");
753
+ const r = String(e.expression).trim();
754
+ n(r);
755
+ const l = $t.find(
756
+ (_) => _.name.toLowerCase() === r.toLowerCase()
757
+ );
758
+ B(
759
+ `[STREAM] Animation match for "${r}": ${l ? l.name : "NONE"}`
760
+ ), H(l?.url ?? "");
520
761
  }
521
762
  if (e.navigation != null) {
522
- const n = String(e.navigation).trim();
523
- n !== "" && (v ? v(n) : window.open(n, "_blank"));
763
+ const r = String(e.navigation).trim();
764
+ r !== "" && (w ? w(r) : window.open(r, "_blank"));
524
765
  }
525
- const i = e.ask_for || e.lead_capture?.ask_for, s = i ? String(i).trim().toLowerCase() : "", a = s === "none" || s === "<none>";
526
- if (i && !a) {
527
- const n = s;
528
- j(n || null), t(n === "email" ? "Enter your email" : n === "name" ? "Enter your name" : n === "phone" ? "Enter your phone number" : "Chat with us");
529
- } else (a || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && (j(null), r !== "Chat with us" && t("Chat with us"));
766
+ const t = e.ask_for || e.lead_capture?.ask_for, i = t ? String(t).trim().toLowerCase() : "", a = i === "none" || i === "<none>";
767
+ if (t && !a) {
768
+ const r = i;
769
+ Ae(r || null), be(r === "email" ? "Enter your email" : r === "name" ? "Enter your name" : r === "phone" ? "Enter your phone number" : "Chat with us");
770
+ } else (a || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") && (Ae(null), Y !== "Chat with us" && be("Chat with us"));
530
771
  e.collected, e.valid;
531
- }, dt = (e) => {
532
- const i = e.trim();
533
- if (!i) return null;
534
- if (i.startsWith("{"))
772
+ }, gt = (e) => {
773
+ const t = e.trim();
774
+ if (!t) return null;
775
+ if (t.startsWith("{"))
535
776
  try {
536
- return JSON.parse(i);
777
+ return JSON.parse(t);
537
778
  } catch {
538
779
  return null;
539
780
  }
540
- if (i.includes(":")) {
541
- const s = i.split(":"), a = s[0].trim().toLowerCase(), n = s.slice(1).join(":").trim();
542
- return { [a]: n };
781
+ if (t.includes(":")) {
782
+ const i = t.split(":"), a = i[0].trim().toLowerCase(), r = i.slice(1).join(":").trim();
783
+ return { [a]: r };
543
784
  }
544
785
  return null;
545
- }, ht = Ue(() => {
546
- }, []), Ke = (e) => {
547
- if (oe.current)
548
- e === "§" ? oe.current = !1 : (K.current += e, re((i) => i + e));
786
+ }, bt = $e(() => {
787
+ }, []), tt = (e) => {
788
+ if (Me.current)
789
+ e === "§" ? Me.current = !1 : (Te.current += e, re((t) => t + e));
549
790
  else if (e === "§") {
550
- oe.current = !0;
791
+ Me.current = !0;
551
792
  return;
552
793
  } else
553
- for (X.current += e; X.current.includes(`
794
+ for (ue.current += e; ue.current.includes(`
554
795
  `); ) {
555
- const i = X.current.indexOf(`
556
- `), s = X.current.slice(0, i).trim();
557
- X.current = X.current.slice(i + 1);
558
- const a = dt(s);
559
- a && ut(a);
796
+ const t = ue.current.indexOf(`
797
+ `), i = ue.current.slice(0, t).trim();
798
+ ue.current = ue.current.slice(t + 1);
799
+ const a = gt(i);
800
+ a && mt(a);
560
801
  }
561
802
  };
562
803
  z(() => {
563
804
  (async () => {
564
- if (!sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID")) {
565
- const s = "secret", a = Math.floor(Date.now() / 1e3).toString();
805
+ if (!sessionStorage.getItem(
806
+ "STREAMOJI_LEADS_SESSION_LEAD_ID"
807
+ )) {
808
+ const i = "secret", a = Math.floor(Date.now() / 1e3).toString();
566
809
  try {
567
- const n = new TextEncoder(), u = await crypto.subtle.importKey(
810
+ const r = new TextEncoder(), l = await crypto.subtle.importKey(
568
811
  "raw",
569
- n.encode(s),
812
+ r.encode(i),
570
813
  { name: "HMAC", hash: "SHA-256" },
571
814
  !1,
572
815
  ["sign"]
573
- ), w = await crypto.subtle.sign(
816
+ ), _ = await crypto.subtle.sign(
574
817
  "HMAC",
575
- u,
576
- n.encode(a)
577
- ), V = Array.from(new Uint8Array(w)).map((S) => S.toString(16).padStart(2, "0")).join("");
578
- sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", V), H("[SESSION] New HMAC UID generated and saved:", V);
579
- } catch (n) {
580
- console.error("[SESSION] HMAC generation failed:", n);
581
- const u = Math.random().toString(36) + Date.now().toString();
582
- sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", u);
818
+ l,
819
+ r.encode(a)
820
+ ), P = Array.from(new Uint8Array(_)).map((S) => S.toString(16).padStart(2, "0")).join("");
821
+ sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", P), B("[SESSION] New HMAC UID generated and saved:", P);
822
+ } catch (r) {
823
+ console.error("[SESSION] HMAC generation failed:", r);
824
+ const l = Math.random().toString(36) + Date.now().toString();
825
+ sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", l);
583
826
  }
584
827
  }
585
- sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || sessionStorage.setItem("STREAMOJI_LEADS_SESSION_MESSAGES", JSON.stringify([]));
828
+ sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || sessionStorage.setItem(
829
+ "STREAMOJI_LEADS_SESSION_MESSAGES",
830
+ JSON.stringify([])
831
+ );
586
832
  })();
587
833
  }, []);
588
- const Qe = () => {
834
+ const nt = () => {
589
835
  try {
590
- return JSON.parse(sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]");
836
+ return JSON.parse(
837
+ sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]"
838
+ );
591
839
  } catch {
592
840
  return [];
593
841
  }
594
- }, ft = (e) => {
595
- sessionStorage.setItem("STREAMOJI_LEADS_SESSION_MESSAGES", JSON.stringify(e));
596
- }, [Ve, Be] = k(!1), [Ze, $e] = k(0), ae = c(null), De = c([]), et = c(0), [tt, pt] = k(null), [mt, He] = k(null), pe = c(null), Se = c(null), je = Ue(() => {
597
- se.current = [], ue.current = !1, le(!1), P.current = 0, M.current = 0, g.current = 0, O.current.forEach((e) => {
842
+ }, _t = (e) => {
843
+ sessionStorage.setItem(
844
+ "STREAMOJI_LEADS_SESSION_MESSAGES",
845
+ JSON.stringify(e)
846
+ );
847
+ }, [qe, Ge] = y(!1), [rt, ze] = y(0), oe = o(null), Pe = o([]), st = o(0), [it, wt] = y(
848
+ null
849
+ ), [vt, Ye] = y(
850
+ null
851
+ ), de = o(null), ye = o(
852
+ null
853
+ ), Ve = $e((e = !1) => {
854
+ e && (ee.current = !0, U(!1), k("Ready")), m.current = [], se.current = [], I.current = !1, ce(!1), b.current = 0, K.current = 0, q.current = 0, R.current.forEach((t) => {
598
855
  try {
599
- e.stop();
856
+ t.stop();
600
857
  } catch {
601
858
  }
602
- }), Ee.current && (clearTimeout(Ee.current), Ee.current = null), ke(null), o(""), O.current = [];
603
- }, []), gt = async () => {
859
+ }), j.current && (clearTimeout(j.current), j.current = null), Ne(null), H(""), R.current = [];
860
+ }, []), St = async () => {
604
861
  try {
605
- const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), i = window.AudioContext || window.webkitAudioContext, s = new i(), a = s.createMediaStreamSource(e), n = s.createAnalyser();
606
- n.fftSize = 64, a.connect(n), pe.current = s, Se.current = a, He(n);
607
- const u = new MediaRecorder(e);
608
- ae.current = u, De.current = [], u.ondataavailable = (w) => {
609
- w.data.size > 0 && De.current.push(w.data);
610
- }, u.onstop = async () => {
611
- const w = Date.now() - et.current;
612
- if (He(null), Se.current && (Se.current.disconnect(), Se.current = null), pe.current && pe.current.state !== "closed" && (pe.current.close(), pe.current = null), w < 1e3) {
613
- L("Recording too short. Hold or click longer."), W(!1);
862
+ const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext, i = new t(), a = i.createMediaStreamSource(e), r = i.createAnalyser();
863
+ r.fftSize = 64, a.connect(r), de.current = i, ye.current = a, Ye(r);
864
+ const l = new MediaRecorder(e);
865
+ oe.current = l, Pe.current = [], l.ondataavailable = (_) => {
866
+ _.data.size > 0 && Pe.current.push(_.data);
867
+ }, l.onstop = async () => {
868
+ const _ = Date.now() - st.current;
869
+ if (Ye(null), ye.current && (ye.current.disconnect(), ye.current = null), de.current && de.current.state !== "closed" && (de.current.close(), de.current = null), _ < 1e3) {
870
+ k("Recording too short. Hold or click longer."), U(!1);
614
871
  return;
615
872
  }
616
- const x = new Blob(De.current, { type: "audio/wav" });
617
- await vt(x);
618
- }, et.current = Date.now(), u.start(100), Be(!0), L("Listening...");
873
+ const A = new Blob(Pe.current, {
874
+ type: "audio/wav"
875
+ });
876
+ await Rt(A);
877
+ }, st.current = Date.now(), l.start(100), Ge(!0), k("Listening...");
619
878
  } catch (e) {
620
- console.error("Error accessing microphone:", e), L("Mic Access Error");
879
+ console.error("Error accessing microphone:", e), k("Mic Access Error");
621
880
  }
622
- }, bt = () => {
623
- ae.current && ae.current.state !== "inactive" && (ae.current.stop(), ae.current.stream.getTracks().forEach((e) => e.stop()), Be(!1));
624
- }, _t = () => {
625
- ae.current && ae.current.state !== "inactive" && (ae.current.onstop = null, ae.current.stop(), ae.current.stream.getTracks().forEach((e) => e.stop()), He(null), Se.current && (Se.current.disconnect(), Se.current = null), pe.current && pe.current.state !== "closed" && (pe.current.close(), pe.current = null), Be(!1), De.current = [], L("Ready"));
881
+ }, yt = () => {
882
+ oe.current && oe.current.state !== "inactive" && (oe.current.stop(), oe.current.stream.getTracks().forEach((e) => e.stop()), Ge(!1));
883
+ }, xt = () => {
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"));
626
885
  };
627
886
  z(() => {
628
- if (!A) return;
887
+ if (!E) return;
629
888
  const e = () => {
630
- const i = g.current;
631
- if (i <= 0) return;
632
- const s = N.current, a = P.current;
633
- if (!s) return;
634
- const n = s.currentTime - a, u = Math.min(Math.max(0, n), i), w = ge.trim().length;
635
- if (w <= 0) return;
636
- const x = Math.min(
637
- Math.round(u / i * w),
638
- w
889
+ const t = q.current;
890
+ if (t <= 0) return;
891
+ const i = $.current, a = b.current;
892
+ if (!i) return;
893
+ const r = i.currentTime - a, l = Math.min(Math.max(0, r), t), _ = he.trim().length;
894
+ if (_ <= 0) return;
895
+ const A = Math.min(
896
+ Math.round(l / t * _),
897
+ _
639
898
  );
640
- ee(x);
899
+ Ue(A);
641
900
  };
642
- return clearInterval(de.current ?? void 0), de.current = setInterval(e, 90), () => clearInterval(de.current ?? void 0);
643
- }, [A, ge, g.current]), z(() => {
901
+ return clearInterval(Ce.current ?? void 0), Ce.current = setInterval(e, 90), () => clearInterval(Ce.current ?? void 0);
902
+ }, [E, he, q.current]), z(() => {
644
903
  let e;
645
- return Ve ? ($e(0), e = window.setInterval(() => {
646
- $e((i) => i + 1);
647
- }, 1e3)) : $e(0), () => clearInterval(e);
648
- }, [Ve]);
649
- const wt = (e) => {
650
- const i = e.numberOfChannels, s = e.length * i * 2 + 44, a = new ArrayBuffer(s), n = new DataView(a);
651
- let u = 0;
652
- const w = (F) => {
653
- n.setUint16(u, F, !0), u += 2;
654
- }, x = (F) => {
655
- n.setUint32(u, F, !0), u += 4;
904
+ return qe ? (ze(0), e = window.setInterval(() => {
905
+ ze((t) => t + 1);
906
+ }, 1e3)) : ze(0), () => clearInterval(e);
907
+ }, [qe]);
908
+ const kt = (e) => {
909
+ const t = e.numberOfChannels, i = e.length * t * 2 + 44, a = new ArrayBuffer(i), r = new DataView(a);
910
+ let l = 0;
911
+ const _ = (F) => {
912
+ r.setUint16(l, F, !0), l += 2;
913
+ }, A = (F) => {
914
+ r.setUint32(l, F, !0), l += 4;
656
915
  };
657
- x(1179011410), x(s - 8), x(1163280727), x(544501094), x(16), w(1), w(i), x(e.sampleRate), x(e.sampleRate * 2 * i), w(i * 2), w(16), x(1635017060), x(s - u - 4);
658
- const V = [];
659
- for (let F = 0; F < i; F++) V.push(e.getChannelData(F));
916
+ A(1179011410), A(i - 8), A(1163280727), A(544501094), A(16), _(1), _(t), A(e.sampleRate), A(e.sampleRate * 2 * t), _(t * 2), _(16), A(1635017060), A(i - l - 4);
917
+ const P = [];
918
+ for (let F = 0; F < t; F++) P.push(e.getChannelData(F));
660
919
  let S = 0;
661
- for (; u < s; ) {
662
- for (let F = 0; F < i; F++) {
663
- let B = Math.max(-1, Math.min(1, V[F][S]));
664
- B = B < 0 ? B * 32768 : B * 32767, n.setInt16(u, B, !0), u += 2;
920
+ for (; l < i; ) {
921
+ for (let F = 0; F < t; F++) {
922
+ let N = Math.max(-1, Math.min(1, P[F][S]));
923
+ N = N < 0 ? N * 32768 : N * 32767, r.setInt16(l, N, !0), l += 2;
665
924
  }
666
925
  S++;
667
926
  }
668
927
  return new Blob([a], { type: "audio/wav" });
669
- }, Je = async (e, i, s = !1) => {
670
- if (m.current) {
671
- be.current.push({ audio: e, visemes: i, isNewSegment: s });
672
- return;
673
- }
674
- m.current = !0;
675
- try {
676
- const a = window.AudioContext || window.webkitAudioContext, n = N.current ?? new a();
677
- n.state === "suspended" && await n.resume(), N.current = n;
678
- const u = window.atob(e), w = new Uint8Array(u.length);
679
- for (let U = 0; U < u.length; U++) w[U] = u.charCodeAt(U);
680
- const x = await n.decodeAudioData(w.buffer.slice(0));
681
- g.current += x.duration;
682
- const V = n.currentTime;
683
- let S = M.current;
684
- const F = !ue.current;
685
- S < V && (S = V + 0.1), M.current = S + x.duration;
686
- const B = n.createBufferSource();
687
- B.buffer = x;
688
- let $ = tt;
689
- if ((!$ || $.context !== n) && ($ = n.createAnalyser(), $.fftSize = 64, $.connect(n.destination), pt($)), B.connect($), O.current.push(B), F) {
690
- ue.current = !0, le(!0), H(`[AUDIO] setIsSpeaking(true) - First chunk starting at ${S.toFixed(3)}`), P.current = S;
691
- const U = (S - V) * 1e3;
692
- ie.current = performance.now() + U, H(`[AUDIO] Response started. Initial startTime: ${S.toFixed(3)}, CT: ${V.toFixed(3)}`);
928
+ }, Xe = async (e, t, i = !1) => {
929
+ if (!ee.current) {
930
+ if (pe.current) {
931
+ se.current.push({
932
+ audio: e,
933
+ visemes: t,
934
+ isNewSegment: i
935
+ });
936
+ return;
693
937
  }
694
- B.start(S);
695
- const Y = (S - P.current) * 1e3;
696
- s && (_.current = Y, H(`[AUDIO] New segment detected at +${Y.toFixed(0)}ms. Resetting segment offset.`)), i.forEach((U, me) => {
697
- const T = U.symbol ?? "";
698
- if (T) {
699
- const te = Jt(T), ce = Math.round(U.start * 1e3), ye = Math.round((U.duration ?? 0) * 1e3), it = _.current + ce;
700
- me < 3 && H(`[AUDIO] Viseme "${T}": segment_relative=${ce}ms, segment_offset=${_.current.toFixed(0)}ms => vtime=${it}ms`), te.forEach((st) => {
701
- se.current.push({ viseme: st.v, weight: st.w, vtime: it, vduration: ye });
702
- });
938
+ pe.current = !0;
939
+ try {
940
+ const a = window.AudioContext || window.webkitAudioContext, r = $.current ?? new a();
941
+ r.state === "suspended" && await r.resume(), $.current = r;
942
+ const l = window.atob(e), _ = new Uint8Array(l.length);
943
+ for (let T = 0; T < l.length; T++)
944
+ _[T] = l.charCodeAt(T);
945
+ const A = await r.decodeAudioData(_.buffer.slice(0));
946
+ q.current += A.duration;
947
+ const P = r.currentTime;
948
+ let S = K.current;
949
+ const F = !I.current;
950
+ S < P && (S = P + 0.1), K.current = S + A.duration;
951
+ const N = r.createBufferSource();
952
+ N.buffer = A;
953
+ let V = it;
954
+ if ((!V || V.context !== r) && (V = r.createAnalyser(), V.fftSize = 64, V.connect(r.destination), wt(V)), N.connect(V), R.current.push(N), ee.current) {
955
+ R.current = R.current.filter((T) => T !== N);
956
+ return;
957
+ }
958
+ if (F) {
959
+ I.current = !0, ce(!0), B(
960
+ `[AUDIO] setIsSpeaking(true) - First chunk starting at ${S.toFixed(
961
+ 3
962
+ )}`
963
+ ), b.current = S;
964
+ const T = (S - P) * 1e3;
965
+ J.current = performance.now() + T, B(
966
+ `[AUDIO] Response started. Initial startTime: ${S.toFixed(
967
+ 3
968
+ )}, CT: ${P.toFixed(3)}`
969
+ );
970
+ }
971
+ N.start(S);
972
+ const X = (S - b.current) * 1e3;
973
+ i && (le.current = X, B(
974
+ `[AUDIO] New segment detected at +${X.toFixed(
975
+ 0
976
+ )}ms. Resetting segment offset.`
977
+ )), t.forEach((T, fe) => {
978
+ const C = T.symbol ?? "";
979
+ if (C) {
980
+ const te = Xt(C), ae = Math.round(T.start * 1e3), xe = Math.round((T.duration ?? 0) * 1e3), ct = le.current + ae;
981
+ fe < 3 && B(
982
+ `[AUDIO] Viseme "${C}": segment_relative=${ae}ms, segment_offset=${le.current.toFixed(
983
+ 0
984
+ )}ms => vtime=${ct}ms`
985
+ ), te.forEach((lt) => {
986
+ m.current.push({
987
+ viseme: lt.v,
988
+ weight: lt.w,
989
+ vtime: ct,
990
+ vduration: xe
991
+ });
992
+ });
993
+ }
994
+ }), k("Speaking...");
995
+ } finally {
996
+ if (pe.current = !1, se.current.length > 0) {
997
+ const a = se.current.shift();
998
+ a && Xe(a.audio, a.visemes, a.isNewSegment);
703
999
  }
704
- }), L("Speaking...");
705
- } finally {
706
- if (m.current = !1, be.current.length > 0) {
707
- const a = be.current.shift();
708
- a && Je(a.audio, a.visemes, a.isNewSegment);
709
1000
  }
710
1001
  }
711
- }, vt = async (e) => {
1002
+ }, Rt = async (e) => {
712
1003
  try {
713
- W(!0), K.current = "", re(""), L("Processing Voice...");
714
- const i = await e.arrayBuffer(), a = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(i), n = wt(a), u = new FileReader();
715
- u.readAsDataURL(n), u.onloadend = async () => {
716
- const w = u.result.split(",")[1];
717
- je(), R(""), X.current = "", oe.current = !1;
718
- const x = `${at}/stt?token=${encodeURIComponent(p)}`, V = await fetch(x, {
1004
+ U(!0), Te.current = "", re(""), k("Processing Voice...");
1005
+ const t = await e.arrayBuffer(), a = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), r = kt(a), l = new FileReader();
1006
+ l.readAsDataURL(r), l.onloadend = async () => {
1007
+ const _ = l.result.split(",")[1];
1008
+ Ve(), L(""), ue.current = "", Me.current = !1;
1009
+ const A = `${dt}/stt?token=${encodeURIComponent(
1010
+ p
1011
+ )}`, P = await fetch(A, {
719
1012
  method: "POST",
720
1013
  headers: { "Content-Type": "application/json" },
721
- body: JSON.stringify({ audio_base64: w, audio_format: "wav" })
1014
+ body: JSON.stringify({
1015
+ audio_base64: _,
1016
+ audio_format: "wav"
1017
+ })
722
1018
  });
723
- if (!V.ok) {
724
- const me = await V.text();
725
- let T = "STT Failed";
1019
+ if (!P.ok) {
1020
+ const fe = await P.text();
1021
+ let C = "STT Failed";
726
1022
  try {
727
- T = JSON.parse(me).error || T;
1023
+ C = JSON.parse(fe).error || C;
728
1024
  } catch {
729
- me && (T = me.slice(0, 200));
1025
+ fe && (C = fe.slice(0, 200));
730
1026
  }
731
- throw new Error(T);
1027
+ throw new Error(C);
732
1028
  }
733
- const S = V.body;
734
- if (H("this is body" + S), !S) {
735
- L("STT Failed"), W(!1);
1029
+ const S = P.body;
1030
+ if (B("this is body" + S), !S) {
1031
+ k("STT Failed"), U(!1);
736
1032
  return;
737
1033
  }
738
- const F = S.getReader(), B = new TextDecoder();
739
- let $ = "", Y = !1;
740
- const U = async (me, T) => {
741
- switch (me) {
1034
+ const F = S.getReader();
1035
+ ee.current = !1;
1036
+ const N = new TextDecoder();
1037
+ let V = "", X = !1;
1038
+ const T = async (fe, C) => {
1039
+ switch (fe) {
742
1040
  case "transcript":
743
- T.transcript != null && R(String(T.transcript));
1041
+ C.transcript != null && L(String(C.transcript));
744
1042
  break;
745
1043
  case "text": {
746
- const te = T.delta ?? T.text ?? "";
747
- te && Ke(te);
1044
+ const te = C.delta ?? C.text ?? "";
1045
+ te && tt(te);
748
1046
  break;
749
1047
  }
750
1048
  case "audio": {
751
- const te = T.chunk, ce = T.visemes ?? [], ye = !!T.is_new_segment;
752
- te && await Je(te, ce, ye);
1049
+ const te = C.chunk, ae = C.visemes ?? [], xe = !!C.is_new_segment;
1050
+ te && await Xe(te, ae, xe);
753
1051
  break;
754
1052
  }
755
1053
  case "done": {
756
- Y = !0, L("Ready"), W(!1);
1054
+ X = !0, k("Ready"), U(!1);
757
1055
  break;
758
1056
  }
759
1057
  case "error": {
760
- Y = !0, L("STT Failed"), W(!1);
1058
+ X = !0, k("STT Failed"), U(!1);
761
1059
  break;
762
1060
  }
763
1061
  default:
@@ -765,292 +1063,435 @@ const zt = ({ token: d, agentToken: y, onNavigationRequested: v } = {}) => {
765
1063
  }
766
1064
  };
767
1065
  for (; ; ) {
768
- const { done: me, value: T } = await F.read();
769
- T && ($ += B.decode(T, { stream: !0 }));
770
- const te = $.split(`
1066
+ const { done: fe, value: C } = await F.read();
1067
+ C && (V += N.decode(C, { stream: !0 }));
1068
+ const te = V.split(`
771
1069
 
772
1070
  `);
773
- $ = te.pop() ?? "";
774
- for (const ce of te) {
775
- const ye = Fe(ce);
776
- ye && await U(ye.event, ye.data);
1071
+ V = te.pop() ?? "";
1072
+ for (const ae of te) {
1073
+ const xe = Be(ae);
1074
+ xe && await T(xe.event, xe.data);
777
1075
  }
778
- if (me) {
779
- if ($.trim()) {
780
- const ce = Fe($.trim());
781
- ce && await U(ce.event, ce.data);
1076
+ if (fe) {
1077
+ if (V.trim()) {
1078
+ const ae = Be(V.trim());
1079
+ ae && await T(ae.event, ae.data);
782
1080
  }
783
- Y || (L("Ready"), W(!1));
1081
+ X || (k("Ready"), U(!1));
784
1082
  break;
785
1083
  }
786
1084
  }
787
1085
  };
788
- } catch (i) {
789
- console.error("Audio Submission Error:", i), L("STT Failed"), W(!1);
1086
+ } catch (t) {
1087
+ console.error("Audio Submission Error:", t), k("STT Failed"), U(!1);
790
1088
  }
791
- }, St = async (e) => {
792
- e && e.preventDefault(), K.current = "", re(""), !(!E || Q) && await yt(E);
793
- }, Fe = (e) => {
794
- const i = e.split(/\r?\n/);
795
- let s = "", a = "";
796
- for (const u of i)
797
- u.startsWith("event:") ? s = u.slice(6).trim() : u.startsWith("data:") && (a = u.slice(5).trim());
798
- if (!s) return null;
799
- let n = {};
1089
+ }, At = async (e) => {
1090
+ e && e.preventDefault(), Te.current = "", re(""), !(!M || Q) && await Lt(M);
1091
+ }, Be = (e) => {
1092
+ const t = e.split(/\r?\n/);
1093
+ let i = "", a = "";
1094
+ for (const l of t)
1095
+ l.startsWith("event:") ? i = l.slice(6).trim() : l.startsWith("data:") && (a = l.slice(5).trim());
1096
+ if (!i) return null;
1097
+ let r = {};
800
1098
  if (a)
801
1099
  try {
802
- n = JSON.parse(a);
1100
+ r = JSON.parse(a);
803
1101
  } catch {
804
- n = { raw: a };
1102
+ r = { raw: a };
805
1103
  }
806
- return { event: s, data: n };
807
- }, nt = (e, i) => {
1104
+ return { event: i, data: r };
1105
+ }, ot = (e, t) => {
808
1106
  switch (e) {
809
1107
  case "connected":
810
- X.current = "", oe.current = !1;
1108
+ ue.current = "", Me.current = !1;
811
1109
  break;
812
1110
  case "text": {
813
- const s = i.delta ?? "";
814
- s && Ke(s);
1111
+ const i = t.delta ?? "";
1112
+ i && tt(i);
815
1113
  break;
816
1114
  }
817
1115
  case "audio": {
818
- const s = i.chunk, a = i.visemes ?? [];
819
- s && Je(s, a);
1116
+ const i = t.chunk, a = t.visemes ?? [];
1117
+ i && Xe(i, a);
820
1118
  break;
821
1119
  }
822
1120
  case "done": {
823
- const s = Qe(), a = K.current.trim(), n = [
824
- ...s,
825
- { role: "user", content: E || "..." },
1121
+ const i = nt(), a = Te.current.trim(), r = [
1122
+ ...i,
1123
+ { role: "user", content: M || "..." },
826
1124
  { role: "assistant", content: a }
827
1125
  ];
828
- ft(n), b.current = [...se.current], L("Ready"), W(!1), R("");
1126
+ _t(r), v.current = [...m.current], k("Ready"), U(!1), L("");
829
1127
  break;
830
1128
  }
831
1129
  case "error": {
832
- const s = i.message ?? "Unknown error";
833
- K.current = s, re(s), L("Agent Failed"), W(!1);
1130
+ const i = t.message ?? "Unknown error";
1131
+ Te.current = i, re(i), k("Agent Failed"), U(!1);
834
1132
  break;
835
1133
  }
836
1134
  }
837
- }, yt = async (e) => {
838
- W(!0), L("Thinking..."), K.current = "", X.current = "", oe.current = !1, je(), g.current = 0, ee(0);
839
- const i = `${at}/agent/chat?token=${encodeURIComponent(p)}`;
1135
+ }, Lt = async (e) => {
1136
+ U(!0), k("Thinking..."), Te.current = "", ue.current = "", Me.current = !1, Ve(), q.current = 0, Ue(0);
1137
+ const t = `${dt}/agent/chat?token=${encodeURIComponent(
1138
+ p
1139
+ )}`;
840
1140
  try {
841
- const s = Qe();
1141
+ const i = nt();
842
1142
  let a = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
843
- a || (Ct("[CHAT] Session UID missing at send time! Generating emergency backup."), a = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", a));
844
- const n = {
845
- history: s,
1143
+ a || (Nt(
1144
+ "[CHAT] Session UID missing at send time! Generating emergency backup."
1145
+ ), a = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", a));
1146
+ const r = {
1147
+ history: i,
846
1148
  question: e,
847
1149
  lead_id: a
848
1150
  };
849
- H("[CHAT] Sending payload:", n);
850
- const u = await fetch(i, {
1151
+ B("[CHAT] Sending payload:", r);
1152
+ const l = await fetch(t, {
851
1153
  method: "POST",
852
1154
  headers: {
853
1155
  "Content-Type": "application/json"
854
1156
  },
855
- body: JSON.stringify(n),
1157
+ body: JSON.stringify(r),
856
1158
  cache: "default"
857
1159
  });
858
- if (!u.ok)
1160
+ if (!l.ok)
859
1161
  throw new Error("Agent request failed");
860
- const w = u.body;
861
- if (!w) {
862
- L("Agent Failed"), W(!1);
1162
+ const _ = l.body;
1163
+ if (!_) {
1164
+ k("Agent Failed"), U(!1);
863
1165
  return;
864
1166
  }
865
- const x = w.getReader(), V = new TextDecoder();
1167
+ const A = _.getReader();
1168
+ ee.current = !1;
1169
+ const P = new TextDecoder();
866
1170
  let S = "";
867
1171
  for (; ; ) {
868
- const { done: F, value: B } = await x.read();
869
- H(`[SSE] Chunk received. done=${F}, length=${B?.length || 0}`), B && (S += V.decode(B, { stream: !0 }));
870
- const $ = S.split(`
1172
+ const { done: F, value: N } = await A.read();
1173
+ B(
1174
+ `[SSE] Chunk received. done=${F}, length=${N?.length || 0}`
1175
+ ), N && (S += P.decode(N, { stream: !0 }));
1176
+ const V = S.split(`
871
1177
 
872
1178
  `);
873
- S = $.pop() ?? "";
874
- for (const Y of $) {
875
- H(`[SSE] Processing block: ${Y.slice(0, 50)}...`);
876
- const U = Fe(Y);
877
- U && (H(`[SSE] Event: ${U.event}`), nt(U.event, U.data));
1179
+ S = V.pop() ?? "";
1180
+ for (const X of V) {
1181
+ B(`[SSE] Processing block: ${X.slice(0, 50)}...`);
1182
+ const T = Be(X);
1183
+ T && (B(`[SSE] Event: ${T.event}`), ot(T.event, T.data));
878
1184
  }
879
1185
  if (F) {
880
- if (H("[SSE] Stream finished"), S.trim()) {
881
- const Y = Fe(S.trim());
882
- Y && nt(Y.event, Y.data);
1186
+ if (B("[SSE] Stream finished"), S.trim()) {
1187
+ const X = Be(S.trim());
1188
+ X && ot(X.event, X.data);
883
1189
  }
884
- L("Ready"), W(!1), R("");
1190
+ k("Ready"), U(!1), L("");
885
1191
  break;
886
1192
  }
887
1193
  }
888
- } catch (s) {
889
- console.error("Chat Error:", s), L("Agent Failed"), W(!1);
1194
+ } catch (i) {
1195
+ console.error("Chat Error:", i), k("Agent Failed"), U(!1);
890
1196
  }
891
- }, rt = ge.trim(), qe = rt && A ? rt.slice(0, Z != null && Z > 0 ? Z : 0) : "";
1197
+ }, at = he.trim(), Ke = at && E ? at.slice(
1198
+ 0,
1199
+ Re != null && Re > 0 ? Re : 0
1200
+ ) : "";
892
1201
  z(() => {
893
- const e = G.current;
894
- e !== "exiting" && (qe ? (fe(qe), e === "hidden" && ve("entering")) : (e === "visible" || e === "entering") && ve("exiting"));
895
- }, [qe, he]);
896
- const xt = Ue(() => {
897
- const e = G.current;
1202
+ const e = Je.current;
1203
+ e !== "exiting" && (Ke ? (Se(Ke), e === "hidden" && ve("entering")) : (e === "visible" || e === "entering") && ve("exiting"));
1204
+ }, [Ke, W]);
1205
+ const Et = $e(() => {
1206
+ const e = Je.current;
898
1207
  e === "entering" ? ve("visible") : e === "exiting" && ve("hidden");
899
1208
  }, []);
900
- return Rt(() => {
901
- const e = Te.current;
1209
+ return Ot(() => {
1210
+ const e = ie.current;
902
1211
  e && (e.scrollTop = e.scrollHeight);
903
- }, [J]), /* @__PURE__ */ ne("div", { className: "avatar-widget-container", children: [
1212
+ }, [Ee]), /* @__PURE__ */ ne("div", { className: "avatar-widget-container", children: [
904
1213
  /* @__PURE__ */ ne("div", { className: "avatar-input-area", children: [
905
- D !== "hidden" ? /* @__PURE__ */ f(
1214
+ ge !== "hidden" ? /* @__PURE__ */ f(
906
1215
  "div",
907
1216
  {
908
- className: `avatar-thinking-tab${D === "exiting" ? " avatar-thinking-tab--exiting" : D === "entering" ? " avatar-thinking-tab--entering" : ""}`,
909
- onAnimationEnd: lt,
910
- children: Le
1217
+ className: `avatar-thinking-tab${ge === "exiting" ? " avatar-thinking-tab--exiting" : ge === "entering" ? " avatar-thinking-tab--entering" : ""}`,
1218
+ onAnimationEnd: pt,
1219
+ children: De
911
1220
  }
912
1221
  ) : null,
913
- /* @__PURE__ */ f("div", { className: "avatar-input-container", children: /* @__PURE__ */ f("div", { style: { display: "flex", alignItems: "center", width: "100%", height: "100%" }, children: Ve ? /* @__PURE__ */ ne("div", { className: "avatar-input-recording", children: [
914
- /* @__PURE__ */ f(
915
- "button",
916
- {
917
- type: "button",
918
- className: "avatar-recording-cancel",
919
- onClick: _t,
920
- title: "Cancel",
921
- children: /* @__PURE__ */ ne("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", style: { display: "block" }, children: [
922
- /* @__PURE__ */ f("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
923
- /* @__PURE__ */ f("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
924
- ] })
925
- }
926
- ),
927
- /* @__PURE__ */ ne("div", { style: { flex: 1, height: "100%", position: "relative", display: "flex", alignItems: "center", minWidth: 0 }, children: [
928
- /* @__PURE__ */ f("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ f(ot, { analyser: mt }) }),
929
- /* @__PURE__ */ ne("span", { style: {
930
- fontSize: "0.75rem",
931
- color: "#64748b",
932
- fontWeight: 500,
933
- marginLeft: "4px",
934
- minWidth: "32px",
935
- textAlign: "right",
936
- fontVariantNumeric: "tabular-nums"
937
- }, children: [
938
- Math.floor(Ze / 60),
939
- ":",
940
- String(Ze % 60).padStart(2, "0")
941
- ] })
942
- ] }),
943
- /* @__PURE__ */ f(
944
- "button",
945
- {
946
- type: "button",
947
- className: "avatar-recording-confirm",
948
- onClick: bt,
949
- title: "Send",
950
- children: /* @__PURE__ */ f("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", style: { display: "block" }, children: /* @__PURE__ */ f("polyline", { points: "20 6 9 17 4 12" }) })
951
- }
952
- )
953
- ] }) : A ? /* @__PURE__ */ f("div", { style: { flex: 1, height: "100%", display: "flex", alignItems: "center", paddingRight: "8px" }, children: /* @__PURE__ */ f(ot, { analyser: tt }) }) : Q ? /* @__PURE__ */ f("div", { style: { flex: 1, height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ f("div", { className: "avatar-input-loader" }) }) : /* @__PURE__ */ ne("form", { onSubmit: St, style: { flex: 1, display: "flex", height: "100%", alignItems: "center" }, children: [
954
- /* @__PURE__ */ f(
955
- "input",
956
- {
957
- id: "avatar-text-input",
958
- type: "text",
959
- value: E,
960
- onChange: (e) => R(e.target.value),
961
- placeholder: "Ask me anything",
962
- disabled: Q,
963
- autoComplete: "off",
964
- style: { width: "100%", height: "100%" }
965
- }
966
- ),
967
- E.trim() === "" ? /* @__PURE__ */ f(
968
- "button",
969
- {
970
- type: "button",
971
- className: "mic-button",
972
- onClick: gt,
973
- disabled: Q,
974
- style: { backgroundColor: "#1e4a5e" },
975
- children: /* @__PURE__ */ ne("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
976
- /* @__PURE__ */ f("path", { 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", fill: "white" }),
977
- /* @__PURE__ */ f("path", { 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", fill: "white" })
978
- ] })
979
- }
980
- ) : /* @__PURE__ */ f(
981
- "button",
982
- {
983
- type: "submit",
984
- className: "mic-button",
985
- disabled: Q,
986
- style: { backgroundColor: "#1e4a5e" },
987
- title: "Send",
988
- children: /* @__PURE__ */ ne("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: [
989
- /* @__PURE__ */ f("path", { d: "M22 2L11 13", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }),
990
- /* @__PURE__ */ f("path", { d: "M22 2L15 22L11 13L2 9L22 2Z", stroke: "white", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" })
991
- ] })
992
- }
993
- )
994
- ] }) }) })
1222
+ /* @__PURE__ */ f("div", { className: "avatar-input-container", children: /* @__PURE__ */ f(
1223
+ "div",
1224
+ {
1225
+ style: {
1226
+ display: "flex",
1227
+ alignItems: "center",
1228
+ width: "100%",
1229
+ height: "100%"
1230
+ },
1231
+ children: qe ? /* @__PURE__ */ ne("div", { className: "avatar-input-recording", children: [
1232
+ /* @__PURE__ */ f(
1233
+ "button",
1234
+ {
1235
+ type: "button",
1236
+ className: "avatar-recording-cancel",
1237
+ onClick: xt,
1238
+ title: "Cancel",
1239
+ children: /* @__PURE__ */ ne(
1240
+ "svg",
1241
+ {
1242
+ width: "18",
1243
+ height: "18",
1244
+ viewBox: "0 0 24 24",
1245
+ fill: "none",
1246
+ stroke: "currentColor",
1247
+ strokeWidth: "2.5",
1248
+ strokeLinecap: "round",
1249
+ strokeLinejoin: "round",
1250
+ style: { display: "block" },
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" })
1254
+ ]
1255
+ }
1256
+ )
1257
+ }
1258
+ ),
1259
+ /* @__PURE__ */ ne(
1260
+ "div",
1261
+ {
1262
+ style: {
1263
+ flex: 1,
1264
+ height: "100%",
1265
+ position: "relative",
1266
+ display: "flex",
1267
+ alignItems: "center",
1268
+ minWidth: 0
1269
+ },
1270
+ children: [
1271
+ /* @__PURE__ */ f("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ f(ut, { analyser: vt }) }),
1272
+ /* @__PURE__ */ ne(
1273
+ "span",
1274
+ {
1275
+ style: {
1276
+ fontSize: "0.75rem",
1277
+ color: "#64748b",
1278
+ fontWeight: 500,
1279
+ marginLeft: "4px",
1280
+ minWidth: "32px",
1281
+ textAlign: "right",
1282
+ fontVariantNumeric: "tabular-nums"
1283
+ },
1284
+ children: [
1285
+ Math.floor(rt / 60),
1286
+ ":",
1287
+ String(rt % 60).padStart(2, "0")
1288
+ ]
1289
+ }
1290
+ )
1291
+ ]
1292
+ }
1293
+ ),
1294
+ /* @__PURE__ */ f(
1295
+ "button",
1296
+ {
1297
+ type: "button",
1298
+ className: "avatar-recording-confirm",
1299
+ onClick: yt,
1300
+ title: "Send",
1301
+ children: /* @__PURE__ */ f(
1302
+ "svg",
1303
+ {
1304
+ width: "18",
1305
+ height: "18",
1306
+ viewBox: "0 0 24 24",
1307
+ fill: "none",
1308
+ stroke: "currentColor",
1309
+ strokeWidth: "2.5",
1310
+ strokeLinecap: "round",
1311
+ strokeLinejoin: "round",
1312
+ style: { display: "block" },
1313
+ children: /* @__PURE__ */ f("polyline", { points: "20 6 9 17 4 12" })
1314
+ }
1315
+ )
1316
+ }
1317
+ )
1318
+ ] }) : E ? /* @__PURE__ */ ne("div", { className: "avatar-input-speaking", children: [
1319
+ /* @__PURE__ */ f(
1320
+ "div",
1321
+ {
1322
+ style: {
1323
+ flex: 1,
1324
+ height: "100%",
1325
+ display: "flex",
1326
+ alignItems: "center",
1327
+ paddingRight: "8px"
1328
+ },
1329
+ children: /* @__PURE__ */ f(ut, { analyser: it })
1330
+ }
1331
+ ),
1332
+ /* @__PURE__ */ f(
1333
+ "button",
1334
+ {
1335
+ type: "button",
1336
+ className: "avatar-speaking-stop",
1337
+ onClick: () => Ve(!0),
1338
+ title: "Stop",
1339
+ children: /* @__PURE__ */ f("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
1340
+ }
1341
+ )
1342
+ ] }) : Q ? /* @__PURE__ */ f(
1343
+ "div",
1344
+ {
1345
+ style: {
1346
+ flex: 1,
1347
+ height: "100%",
1348
+ display: "flex",
1349
+ alignItems: "center",
1350
+ justifyContent: "center"
1351
+ },
1352
+ children: /* @__PURE__ */ f("div", { className: "avatar-input-loader" })
1353
+ }
1354
+ ) : /* @__PURE__ */ ne(
1355
+ "form",
1356
+ {
1357
+ onSubmit: At,
1358
+ style: {
1359
+ flex: 1,
1360
+ display: "flex",
1361
+ height: "100%",
1362
+ alignItems: "center"
1363
+ },
1364
+ children: [
1365
+ /* @__PURE__ */ f(
1366
+ "input",
1367
+ {
1368
+ id: "avatar-text-input",
1369
+ type: "text",
1370
+ value: M,
1371
+ onChange: (e) => L(e.target.value),
1372
+ placeholder: "Ask me anything",
1373
+ disabled: Q,
1374
+ autoComplete: "off",
1375
+ style: { width: "100%", height: "100%" }
1376
+ }
1377
+ ),
1378
+ M.trim() === "" ? /* @__PURE__ */ f(
1379
+ "button",
1380
+ {
1381
+ type: "button",
1382
+ className: "mic-button",
1383
+ onClick: St,
1384
+ disabled: Q,
1385
+ style: { backgroundColor: "#1e4a5e" },
1386
+ children: /* @__PURE__ */ ne(
1387
+ "svg",
1388
+ {
1389
+ width: "28",
1390
+ height: "28",
1391
+ viewBox: "0 0 24 24",
1392
+ fill: "none",
1393
+ xmlns: "http://www.w3.org/2000/svg",
1394
+ children: [
1395
+ /* @__PURE__ */ f(
1396
+ "path",
1397
+ {
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
+ fill: "white"
1400
+ }
1401
+ ),
1402
+ /* @__PURE__ */ f(
1403
+ "path",
1404
+ {
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",
1406
+ fill: "white"
1407
+ }
1408
+ )
1409
+ ]
1410
+ }
1411
+ )
1412
+ }
1413
+ ) : /* @__PURE__ */ f(
1414
+ "button",
1415
+ {
1416
+ type: "submit",
1417
+ className: "mic-button",
1418
+ disabled: Q,
1419
+ style: { backgroundColor: "#1e4a5e" },
1420
+ title: "Send",
1421
+ children: /* @__PURE__ */ f("img", { src: "/assets/leadmoji-logo-send.png", alt: "Send", width: 24, height: 24 })
1422
+ }
1423
+ )
1424
+ ]
1425
+ }
1426
+ )
1427
+ }
1428
+ ) })
995
1429
  ] }),
996
1430
  /* @__PURE__ */ f("div", { className: "avatar-wrapper", children: /* @__PURE__ */ ne("div", { className: "avatar-scene-wrapper", children: [
997
- he !== "hidden" && /* @__PURE__ */ f(
1431
+ W !== "hidden" && /* @__PURE__ */ f(
998
1432
  "div",
999
1433
  {
1000
- className: `avatar-bubble${he === "entering" ? " avatar-bubble--entering" : he === "exiting" ? " avatar-bubble--exiting" : ""}`,
1001
- onAnimationEnd: xt,
1002
- children: /* @__PURE__ */ f("div", { ref: Te, className: "avatar-bubble__content", children: J })
1434
+ 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 })
1003
1437
  }
1004
1438
  ),
1005
- /* @__PURE__ */ f("div", { className: "avatar-canvas-layer", style: { width: 600, height: 600 }, children: /* @__PURE__ */ ne(
1006
- Mt,
1439
+ /* @__PURE__ */ f(
1440
+ "div",
1007
1441
  {
1008
- shadows: !0,
1009
- camera: { position: [0.2, 1.4, 3], fov: 42 },
1010
- gl: { alpha: !0 },
1011
- dpr: 1.8,
1012
- style: { pointerEvents: "none", width: "100%", height: "100%" },
1013
- children: [
1014
- /* @__PURE__ */ f(qt, { target: Vt }),
1015
- /* @__PURE__ */ f("ambientLight", { intensity: 0.7 }),
1016
- /* @__PURE__ */ f("directionalLight", { position: [0, 2, 2], intensity: 1 }),
1017
- /* @__PURE__ */ f(Tt, { preset: "city" }),
1018
- /* @__PURE__ */ f(Lt, { fallback: null, children: I !== null && /* @__PURE__ */ f(
1019
- Gt,
1020
- {
1021
- avatarUrl: I,
1022
- isPlayingRef: ue,
1023
- visemeQueueRef: se,
1024
- audioContextRef: N,
1025
- responseAudioStartTimeRef: P,
1026
- adjustments: Pt,
1027
- mood: _e,
1028
- expression: We,
1029
- agentResponse: ge,
1030
- isSpeaking: A,
1031
- nextStartTimeRef: M,
1032
- stopPlayback: je,
1033
- setIsSpeaking: le,
1034
- expressionUrl: h,
1035
- onExpressionFinished: ht
1036
- }
1037
- ) })
1038
- ]
1442
+ className: "avatar-canvas-layer",
1443
+ style: { width: Z, height: Z },
1444
+ children: /* @__PURE__ */ ne(
1445
+ It,
1446
+ {
1447
+ shadows: !0,
1448
+ camera: { position: [0.2, 1.4, 3], fov: 42 },
1449
+ gl: { alpha: !0 },
1450
+ dpr: 1.8,
1451
+ style: { pointerEvents: "none", width: "100%", height: "100%" },
1452
+ 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(
1458
+ Qt,
1459
+ {
1460
+ avatarUrl: D,
1461
+ isPlayingRef: I,
1462
+ visemeQueueRef: m,
1463
+ audioContextRef: $,
1464
+ responseAudioStartTimeRef: b,
1465
+ adjustments: jt,
1466
+ mood: d,
1467
+ expression: s,
1468
+ agentResponse: he,
1469
+ isSpeaking: E,
1470
+ nextStartTimeRef: K,
1471
+ stopPlayback: Ve,
1472
+ setIsSpeaking: ce,
1473
+ expressionUrl: h,
1474
+ onExpressionFinished: bt
1475
+ }
1476
+ ) })
1477
+ ]
1478
+ }
1479
+ )
1039
1480
  }
1040
- ) })
1481
+ )
1041
1482
  ] }) })
1042
1483
  ] });
1043
- }, tn = ({
1044
- token: d,
1045
- onNavigationRequested: y
1484
+ }, an = ({
1485
+ token: u,
1486
+ onNavigationRequested: x
1046
1487
  }) => /* @__PURE__ */ f(
1047
- zt,
1488
+ en,
1048
1489
  {
1049
- token: d,
1050
- onNavigationRequested: y
1490
+ token: u,
1491
+ onNavigationRequested: x
1051
1492
  }
1052
1493
  );
1053
1494
  export {
1054
- tn as AvatarWidget
1495
+ an as AvatarWidget
1055
1496
  };
1056
1497
  //# sourceMappingURL=avatar-widget.js.map