@streamoji/avatar-widget 0.5.2 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/avatar-widget.cjs +6 -6
- package/dist/avatar-widget.js +865 -850
- package/dist/avatar-widget.umd.js +158 -158
- package/package.json +1 -1
package/dist/avatar-widget.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useGLTF as
|
|
1
|
+
import { jsx as h, jsxs as _e } from "react/jsx-runtime";
|
|
2
|
+
import { useGLTF as Dt, Environment as Sn } from "@react-three/drei";
|
|
3
3
|
import { useFrame as kn, Canvas as Rn, useThree as xn } from "@react-three/fiber";
|
|
4
|
-
import { memo as Tn, useMemo as
|
|
5
|
-
import * as
|
|
6
|
-
import { GLTFLoader as
|
|
7
|
-
const
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
const
|
|
11
|
-
return
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
const j =
|
|
4
|
+
import { memo as Tn, useMemo as Pt, useRef as a, useState as k, useEffect as B, useCallback as at, useLayoutEffect as Mn, Suspense as An } from "react";
|
|
5
|
+
import * as gt from "three";
|
|
6
|
+
import { GLTFLoader as En } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
7
|
+
const ct = "https://ai.streamoji.com", N = (...u) => {
|
|
8
|
+
}, In = (...u) => {
|
|
9
|
+
}, Qt = ({ analyser: u }) => {
|
|
10
|
+
const w = a(null), S = a(null);
|
|
11
|
+
return B(() => {
|
|
12
|
+
const y = w.current;
|
|
13
|
+
if (!y) return;
|
|
14
|
+
const j = y.getContext("2d", { alpha: !0 });
|
|
15
15
|
if (!j) return;
|
|
16
16
|
let Q, ee = null;
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
Q = requestAnimationFrame(
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
j.clearRect(0, 0,
|
|
24
|
-
const
|
|
25
|
-
(!
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
const
|
|
17
|
+
u && (u.fftSize = 128, ee = new Uint8Array(u.frequencyBinCount));
|
|
18
|
+
const Ze = () => {
|
|
19
|
+
Q = requestAnimationFrame(Ze), (y.width !== y.offsetWidth || y.height !== y.offsetHeight) && (y.width = y.offsetWidth, y.height = y.offsetHeight);
|
|
20
|
+
const We = y.width, U = y.height;
|
|
21
|
+
if (We === 0 || U === 0) return;
|
|
22
|
+
const ut = U / 2;
|
|
23
|
+
j.clearRect(0, 0, We, U), j.fillStyle = "#1e293b";
|
|
24
|
+
const ke = 2, G = ke + 2, Ae = We * 0.95, q = Math.floor(Ae / G);
|
|
25
|
+
(!S.current || S.current.length !== q) && (S.current = new Float32Array(q).fill(2));
|
|
26
|
+
const ae = q * G, O = (We - ae) / 2;
|
|
27
|
+
u && ee && u.getByteFrequencyData(ee);
|
|
28
|
+
const we = ee ? ee.length : 0, g = Math.floor(we * 0.7) / q, ce = new Float32Array(q);
|
|
29
29
|
for (let m = 0; m < q; m++) {
|
|
30
|
-
let
|
|
31
|
-
if (ee &&
|
|
32
|
-
const
|
|
33
|
-
for (let Y =
|
|
30
|
+
let D = 0;
|
|
31
|
+
if (ee && g > 0) {
|
|
32
|
+
const F = Math.floor(m * g), $ = Math.floor((m + 1) * g);
|
|
33
|
+
for (let Y = F; Y < $; Y++) {
|
|
34
34
|
const X = ee[Y] || 0;
|
|
35
|
-
X >
|
|
35
|
+
X > D && (D = X);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
const z =
|
|
40
|
-
|
|
38
|
+
D < 10 && (D = 0);
|
|
39
|
+
const z = D / 255, A = D > 0 ? Math.max(2, Math.pow(z, 1.4) * U * 0.25) : 2;
|
|
40
|
+
ce[m] = A;
|
|
41
41
|
}
|
|
42
42
|
for (let m = 0; m < q; m++) {
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
j.beginPath(), j.roundRect ? j.roundRect(
|
|
43
|
+
const D = q - 1 - m, z = Math.max(ce[m], ce[D]), A = S.current[m] + (z - S.current[m]) * 0.3;
|
|
44
|
+
S.current[m] = A;
|
|
45
|
+
const F = O + m * G, $ = ut - A / 2;
|
|
46
|
+
j.beginPath(), j.roundRect ? j.roundRect(F, $, ke, A, 4) : j.fillRect(F, $, ke, A), j.fill();
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
return
|
|
49
|
+
return Ze(), () => {
|
|
50
50
|
cancelAnimationFrame(Q);
|
|
51
51
|
};
|
|
52
|
-
}, [
|
|
52
|
+
}, [u]), /* @__PURE__ */ h(
|
|
53
53
|
"canvas",
|
|
54
54
|
{
|
|
55
|
-
ref:
|
|
55
|
+
ref: w,
|
|
56
56
|
style: { width: "100%", height: "100%", display: "block" }
|
|
57
57
|
}
|
|
58
58
|
);
|
|
59
|
-
},
|
|
60
|
-
function
|
|
61
|
-
const [
|
|
62
|
-
return
|
|
63
|
-
if (!
|
|
64
|
-
|
|
59
|
+
}, On = "https://pub-48df6f7d60d6440bbd01676ea5d90e55.r2.dev", Xt = "https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/default-models/avatar-blue-suit.glb";
|
|
60
|
+
function Dn(u) {
|
|
61
|
+
const [w, S] = k(null);
|
|
62
|
+
return B(() => {
|
|
63
|
+
if (!u) {
|
|
64
|
+
S(null);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
|
-
let
|
|
68
|
-
const j = `${
|
|
67
|
+
let y = !1;
|
|
68
|
+
const j = `${On}/${u}.glb`;
|
|
69
69
|
return fetch(j, { method: "HEAD" }).then((Q) => {
|
|
70
|
-
|
|
70
|
+
y || S(Q.ok ? j : Xt);
|
|
71
71
|
}).catch(() => {
|
|
72
|
-
|
|
72
|
+
y || S(Xt);
|
|
73
73
|
}), () => {
|
|
74
|
-
|
|
74
|
+
y = !0;
|
|
75
75
|
};
|
|
76
|
-
}, [
|
|
76
|
+
}, [u]), w;
|
|
77
77
|
}
|
|
78
78
|
const Cn = [
|
|
79
79
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_001.glb",
|
|
80
80
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_002.glb",
|
|
81
81
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_002.glb",
|
|
82
82
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/M_Standing_Idle_Variations_005.glb"
|
|
83
|
-
],
|
|
83
|
+
], Nn = [
|
|
84
84
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_001.glb",
|
|
85
85
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb",
|
|
86
86
|
"https://pub-be53cae7bd99457a8c1f11b4d38f1672.r2.dev/masculine/idle/F_Standing_Idle_Variations_003.glb"
|
|
87
|
-
],
|
|
87
|
+
], Un = [
|
|
88
88
|
{
|
|
89
89
|
id: "m_expr_01",
|
|
90
90
|
name: "Friendly Wave",
|
|
@@ -264,9 +264,9 @@ const Cn = [
|
|
|
264
264
|
position: [0.15, -0.8, 0],
|
|
265
265
|
scale: 1.5,
|
|
266
266
|
rotation: [0.15, 0.02, 0]
|
|
267
|
-
},
|
|
267
|
+
}, $n = [-0.45, 1.9, 0.1], Vn = [-0.45, 1.75, 0.1], Wn = {
|
|
268
268
|
browInnerUp: 0.2
|
|
269
|
-
},
|
|
269
|
+
}, Ct = 0.18, Hn = 1, jn = 0.5, Zt = 3, vt = 0.55, Nt = 0.12, en = 2, tn = 2, Lt = 4, nn = 8, Gn = 1, rn = 0.38, on = 0.32, sn = "__branding__", St = {
|
|
270
270
|
neutral: { eyeLookDownLeft: 0.1, eyeLookDownRight: 0.1 },
|
|
271
271
|
happy: {
|
|
272
272
|
mouthSmileLeft: 0.2,
|
|
@@ -348,84 +348,65 @@ const Cn = [
|
|
|
348
348
|
mouthUpperUpLeft: 0.1,
|
|
349
349
|
mouthUpperUpRight: 0.1
|
|
350
350
|
}
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
key: "viseme_aa",
|
|
354
|
-
mix: { jawOpen: 0.4, mouthSmileLeft: 0.15, mouthSmileRight: 0.15 },
|
|
355
|
-
teethMix: { jawOpen: 0.2, mouthSmileLeft: 0.15, mouthSmileRight: 0.15 }
|
|
356
|
-
},
|
|
351
|
+
}, un = [
|
|
352
|
+
{ key: "viseme_aa", mix: { jawOpen: 0.6 }, teethMix: { jawOpen: 0.6 } },
|
|
357
353
|
{
|
|
358
354
|
key: "viseme_E",
|
|
359
355
|
mix: {
|
|
360
|
-
mouthPressLeft: 0.
|
|
361
|
-
mouthPressRight: 0.
|
|
356
|
+
mouthPressLeft: 0.8,
|
|
357
|
+
mouthPressRight: 0.8,
|
|
362
358
|
mouthDimpleLeft: 1,
|
|
363
359
|
mouthDimpleRight: 1,
|
|
364
|
-
jawOpen: 0.
|
|
365
|
-
mouthFunnel: 0.1
|
|
360
|
+
jawOpen: 0.3
|
|
366
361
|
},
|
|
367
362
|
teethMix: {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
mouthPressRight: 0.65,
|
|
363
|
+
mouthPressLeft: 0.8,
|
|
364
|
+
mouthPressRight: 0.8,
|
|
371
365
|
mouthDimpleLeft: 1,
|
|
372
366
|
mouthDimpleRight: 1,
|
|
373
|
-
|
|
367
|
+
jawOpen: 0.3
|
|
374
368
|
}
|
|
375
369
|
},
|
|
376
370
|
{
|
|
377
371
|
key: "viseme_I",
|
|
378
372
|
mix: {
|
|
379
|
-
mouthPressLeft: 0.
|
|
380
|
-
mouthPressRight: 0.
|
|
381
|
-
mouthDimpleLeft:
|
|
382
|
-
mouthDimpleRight:
|
|
383
|
-
jawOpen: 0.
|
|
384
|
-
mouthFunnel: 0.05
|
|
373
|
+
mouthPressLeft: 0.6,
|
|
374
|
+
mouthPressRight: 0.6,
|
|
375
|
+
mouthDimpleLeft: 0.6,
|
|
376
|
+
mouthDimpleRight: 0.6,
|
|
377
|
+
jawOpen: 0.2
|
|
385
378
|
},
|
|
386
379
|
teethMix: {
|
|
387
|
-
mouthPressLeft: 0.
|
|
388
|
-
mouthPressRight: 0.
|
|
389
|
-
mouthDimpleLeft:
|
|
390
|
-
mouthDimpleRight:
|
|
391
|
-
jawOpen: 0.
|
|
392
|
-
mouthFunnel: 0.05
|
|
380
|
+
mouthPressLeft: 0.6,
|
|
381
|
+
mouthPressRight: 0.6,
|
|
382
|
+
mouthDimpleLeft: 0.6,
|
|
383
|
+
mouthDimpleRight: 0.6,
|
|
384
|
+
jawOpen: 0.2
|
|
393
385
|
}
|
|
394
386
|
},
|
|
395
387
|
{
|
|
396
388
|
key: "viseme_O",
|
|
397
|
-
mix: { mouthPucker:
|
|
398
|
-
teethMix: { jawForward: 0.6, jawOpen: 0.2
|
|
389
|
+
mix: { mouthPucker: 1, jawForward: 0.6, jawOpen: 0.2 },
|
|
390
|
+
teethMix: { mouthPucker: 1, jawForward: 0.6, jawOpen: 0.2 }
|
|
399
391
|
},
|
|
400
392
|
{
|
|
401
393
|
key: "viseme_U",
|
|
402
|
-
mix: { mouthFunnel: 1
|
|
403
|
-
teethMix: {
|
|
404
|
-
mouthFunnel: 1,
|
|
405
|
-
mouthClose: 0.2
|
|
406
|
-
}
|
|
394
|
+
mix: { mouthFunnel: 1 },
|
|
395
|
+
teethMix: { mouthFunnel: 1 }
|
|
407
396
|
},
|
|
408
397
|
{
|
|
409
398
|
key: "viseme_PP",
|
|
410
399
|
mix: {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
mouthRollLower: 0.3,
|
|
416
|
-
mouthRollUpper: 0.3,
|
|
417
|
-
mouthPressLeft: 0.5,
|
|
418
|
-
mouthPressRight: 0.5
|
|
400
|
+
mouthRollLower: 0.8,
|
|
401
|
+
mouthRollUpper: 0.8,
|
|
402
|
+
mouthUpperUpLeft: 0.3,
|
|
403
|
+
mouthUpperUpRight: 0.3
|
|
419
404
|
},
|
|
420
405
|
teethMix: {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
mouthRollLower: 0.3,
|
|
426
|
-
mouthRollUpper: 0.3,
|
|
427
|
-
mouthPressLeft: 0.5,
|
|
428
|
-
mouthPressRight: 0.5
|
|
406
|
+
mouthRollLower: 0.8,
|
|
407
|
+
mouthRollUpper: 0.8,
|
|
408
|
+
mouthUpperUpLeft: 0.3,
|
|
409
|
+
mouthUpperUpRight: 0.3
|
|
429
410
|
}
|
|
430
411
|
},
|
|
431
412
|
{
|
|
@@ -433,43 +414,35 @@ const Cn = [
|
|
|
433
414
|
mix: {
|
|
434
415
|
mouthPucker: 1,
|
|
435
416
|
mouthShrugUpper: 1,
|
|
417
|
+
mouthLowerDownLeft: 0.2,
|
|
418
|
+
mouthLowerDownRight: 0.2,
|
|
436
419
|
mouthDimpleLeft: 1,
|
|
437
420
|
mouthDimpleRight: 1,
|
|
438
|
-
|
|
439
|
-
mouthStretchRight: 0.5,
|
|
440
|
-
mouthPressLeft: 0.3,
|
|
441
|
-
mouthPressRight: 0.3,
|
|
442
|
-
mouthRollLower: 0.1
|
|
421
|
+
mouthRollLower: 1
|
|
443
422
|
},
|
|
444
423
|
teethMix: {
|
|
445
424
|
mouthPucker: 1,
|
|
446
425
|
mouthShrugUpper: 1,
|
|
426
|
+
mouthLowerDownLeft: 0.2,
|
|
427
|
+
mouthLowerDownRight: 0.2,
|
|
447
428
|
mouthDimpleLeft: 1,
|
|
448
429
|
mouthDimpleRight: 1,
|
|
449
|
-
|
|
450
|
-
mouthStretchRight: 0.5,
|
|
451
|
-
mouthPressLeft: 0.3,
|
|
452
|
-
mouthPressRight: 0.3,
|
|
453
|
-
mouthRollLower: 0.1
|
|
430
|
+
mouthRollLower: 1
|
|
454
431
|
}
|
|
455
432
|
},
|
|
456
433
|
{
|
|
457
434
|
key: "viseme_DD",
|
|
458
435
|
mix: {
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
mouthFunnel: 0.7,
|
|
464
|
-
jawOpen: 0.1
|
|
436
|
+
mouthPressLeft: 0.8,
|
|
437
|
+
mouthPressRight: 0.8,
|
|
438
|
+
mouthFunnel: 0.5,
|
|
439
|
+
jawOpen: 0.2
|
|
465
440
|
},
|
|
466
441
|
teethMix: {
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
mouthFunnel: 0.7,
|
|
472
|
-
jawOpen: 0.1
|
|
442
|
+
mouthPressLeft: 0.8,
|
|
443
|
+
mouthPressRight: 0.8,
|
|
444
|
+
mouthFunnel: 0.5,
|
|
445
|
+
jawOpen: 0.2
|
|
473
446
|
}
|
|
474
447
|
},
|
|
475
448
|
{
|
|
@@ -477,113 +450,79 @@ const Cn = [
|
|
|
477
450
|
mix: {
|
|
478
451
|
mouthPressLeft: 0.8,
|
|
479
452
|
mouthPressRight: 0.8,
|
|
480
|
-
mouthLowerDownLeft: 0.
|
|
481
|
-
mouthLowerDownRight: 0.
|
|
453
|
+
mouthLowerDownLeft: 0.5,
|
|
454
|
+
mouthLowerDownRight: 0.5,
|
|
482
455
|
jawOpen: 0.1
|
|
483
456
|
},
|
|
484
457
|
teethMix: {
|
|
485
458
|
mouthPressLeft: 0.8,
|
|
486
459
|
mouthPressRight: 0.8,
|
|
487
|
-
mouthLowerDownLeft: 0.
|
|
488
|
-
mouthLowerDownRight: 0.
|
|
460
|
+
mouthLowerDownLeft: 0.5,
|
|
461
|
+
mouthLowerDownRight: 0.5,
|
|
489
462
|
jawOpen: 0.1
|
|
490
463
|
}
|
|
491
464
|
},
|
|
492
465
|
{
|
|
493
466
|
key: "viseme_TH",
|
|
494
|
-
mix: {
|
|
495
|
-
teethMix: {
|
|
496
|
-
mouthStretchLeft: 0.4,
|
|
497
|
-
mouthStretchRight: 0.4,
|
|
498
|
-
mouthDimpleLeft: 1,
|
|
499
|
-
mouthDimpleRight: 1,
|
|
500
|
-
mouthFunnel: 0.4,
|
|
501
|
-
jawOpen: 0.15,
|
|
502
|
-
mouthShrugLower: 0.45,
|
|
503
|
-
mouthShrugUpper: 0.45
|
|
504
|
-
}
|
|
467
|
+
mix: { mouthRollUpper: 0.6, jawOpen: 0.2, tongueOut: 0.4 },
|
|
468
|
+
teethMix: { mouthRollUpper: 0.6, jawOpen: 0.2, tongueOut: 0.4 }
|
|
505
469
|
},
|
|
506
470
|
{
|
|
507
471
|
key: "viseme_CH",
|
|
508
|
-
mix: {
|
|
509
|
-
|
|
510
|
-
mouthShrugLower: 0.7,
|
|
511
|
-
mouthShrugUpper: 0.2,
|
|
512
|
-
mouthLowerDownLeft: 0.6,
|
|
513
|
-
mouthLowerDownRight: 0.6,
|
|
514
|
-
mouthDimpleLeft: 0.5,
|
|
515
|
-
mouthDimpleRight: 0.5,
|
|
516
|
-
mouthUpperUpLeft: 0.8,
|
|
517
|
-
mouthUpperUpRight: 0.8,
|
|
518
|
-
jawOpen: 0.2
|
|
519
|
-
},
|
|
520
|
-
teethMix: {
|
|
521
|
-
mouthPucker: 0.8,
|
|
522
|
-
mouthShrugLower: 0.7,
|
|
523
|
-
mouthShrugUpper: 0.2,
|
|
524
|
-
mouthLowerDownLeft: 0.6,
|
|
525
|
-
mouthLowerDownRight: 0.6,
|
|
526
|
-
mouthDimpleLeft: 0.5,
|
|
527
|
-
mouthDimpleRight: 0.5,
|
|
528
|
-
mouthUpperUpLeft: 0.8,
|
|
529
|
-
mouthUpperUpRight: 0.8,
|
|
530
|
-
jawOpen: 0.2
|
|
531
|
-
}
|
|
472
|
+
mix: { mouthPucker: 0.5, jawOpen: 0.2 },
|
|
473
|
+
teethMix: { mouthPucker: 0.5, jawOpen: 0.2 }
|
|
532
474
|
},
|
|
533
475
|
{
|
|
534
476
|
key: "viseme_RR",
|
|
535
|
-
mix: { mouthPucker: 0.
|
|
536
|
-
teethMix: {
|
|
537
|
-
mouthPucker: 0.4,
|
|
538
|
-
jawOpen: 0.2,
|
|
539
|
-
mouthShrugUpper: 0.5,
|
|
540
|
-
mouthFunnel: 0.15,
|
|
541
|
-
mouthDimpleLeft: 0.5,
|
|
542
|
-
mouthDimpleRight: 0.5
|
|
543
|
-
}
|
|
477
|
+
mix: { mouthPucker: 0.5, jawOpen: 0.2 },
|
|
478
|
+
teethMix: { mouthPucker: 0.5, jawOpen: 0.2 }
|
|
544
479
|
},
|
|
545
480
|
{
|
|
546
481
|
key: "viseme_kk",
|
|
547
482
|
mix: {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
483
|
+
mouthLowerDownLeft: 0.4,
|
|
484
|
+
mouthLowerDownRight: 0.4,
|
|
485
|
+
mouthDimpleLeft: 0.3,
|
|
486
|
+
mouthDimpleRight: 0.3,
|
|
487
|
+
mouthFunnel: 0.3,
|
|
488
|
+
mouthPucker: 0.3,
|
|
489
|
+
jawOpen: 0.15
|
|
554
490
|
},
|
|
555
491
|
teethMix: {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
492
|
+
mouthLowerDownLeft: 0.4,
|
|
493
|
+
mouthLowerDownRight: 0.4,
|
|
494
|
+
mouthDimpleLeft: 0.3,
|
|
495
|
+
mouthDimpleRight: 0.3,
|
|
496
|
+
mouthFunnel: 0.3,
|
|
497
|
+
mouthPucker: 0.3,
|
|
498
|
+
jawOpen: 0.15
|
|
562
499
|
}
|
|
563
500
|
},
|
|
564
501
|
{
|
|
565
502
|
key: "viseme_nn",
|
|
566
503
|
mix: {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
mouthFunnel: 0.
|
|
572
|
-
|
|
573
|
-
|
|
504
|
+
mouthLowerDownLeft: 0.4,
|
|
505
|
+
mouthLowerDownRight: 0.4,
|
|
506
|
+
mouthDimpleLeft: 0.3,
|
|
507
|
+
mouthDimpleRight: 0.3,
|
|
508
|
+
mouthFunnel: 0.3,
|
|
509
|
+
mouthPucker: 0.3,
|
|
510
|
+
jawOpen: 0.15,
|
|
511
|
+
tongueOut: 0.2
|
|
574
512
|
},
|
|
575
513
|
teethMix: {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
mouthFunnel: 0.
|
|
581
|
-
|
|
582
|
-
|
|
514
|
+
mouthLowerDownLeft: 0.4,
|
|
515
|
+
mouthLowerDownRight: 0.4,
|
|
516
|
+
mouthDimpleLeft: 0.3,
|
|
517
|
+
mouthDimpleRight: 0.3,
|
|
518
|
+
mouthFunnel: 0.3,
|
|
519
|
+
mouthPucker: 0.3,
|
|
520
|
+
jawOpen: 0.15,
|
|
521
|
+
tongueOut: 0.2
|
|
583
522
|
}
|
|
584
523
|
},
|
|
585
524
|
{ key: "viseme_sil", mix: {} }
|
|
586
|
-
],
|
|
525
|
+
], Jn = {
|
|
587
526
|
aei: [
|
|
588
527
|
{ v: "E", w: 0.8 },
|
|
589
528
|
{ v: "I", w: 0.2 }
|
|
@@ -611,484 +550,543 @@ const Cn = [
|
|
|
611
550
|
{ v: "SS", w: 0.4 }
|
|
612
551
|
],
|
|
613
552
|
sil: [{ v: "sil", w: 1 }]
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
553
|
+
}, Ut = new Set(
|
|
554
|
+
un.flatMap((u) => [
|
|
555
|
+
...Object.keys(u.mix),
|
|
556
|
+
...u.teethMix ? Object.keys(u.teethMix) : []
|
|
557
|
+
])
|
|
558
|
+
);
|
|
559
|
+
function an(u) {
|
|
560
|
+
const w = Math.max(0, Math.min(1, u));
|
|
561
|
+
return w * w * (3 - 2 * w);
|
|
562
|
+
}
|
|
563
|
+
function qn(u, w, S) {
|
|
564
|
+
if (S <= 0) return 0;
|
|
565
|
+
const y = (u - w) / S;
|
|
566
|
+
return y < 0 || y > 1 ? 0 : y < 0.25 ? an(y / 0.25) : y > 0.75 ? an((1 - y) / 0.25) : 1;
|
|
567
|
+
}
|
|
568
|
+
function zn(u) {
|
|
569
|
+
if (!u) return [{ v: "sil", w: 1 }];
|
|
570
|
+
const w = u.toLowerCase();
|
|
571
|
+
return Jn[w] ?? [{ v: "sil", w: 1 }];
|
|
619
572
|
}
|
|
620
|
-
function Yn({ target:
|
|
621
|
-
const { camera:
|
|
622
|
-
return
|
|
623
|
-
|
|
624
|
-
}, [
|
|
573
|
+
function Yn({ target: u }) {
|
|
574
|
+
const { camera: w } = xn();
|
|
575
|
+
return B(() => {
|
|
576
|
+
w.lookAt(...u);
|
|
577
|
+
}, [w, u]), null;
|
|
625
578
|
}
|
|
626
|
-
function u
|
|
627
|
-
if (!
|
|
579
|
+
function c(u, w, S) {
|
|
580
|
+
if (!u || !u.morphTargetDictionary)
|
|
628
581
|
return;
|
|
629
|
-
const
|
|
582
|
+
const y = u, j = y.morphTargetDictionary, Q = y.morphTargetInfluences;
|
|
630
583
|
if (Q)
|
|
631
584
|
for (const ee in j)
|
|
632
|
-
ee.toLowerCase() ===
|
|
633
|
-
}
|
|
634
|
-
function Ot(g, v = 0.97) {
|
|
635
|
-
if (!g) return;
|
|
636
|
-
const y = g;
|
|
637
|
-
if (y.morphTargetInfluences)
|
|
638
|
-
for (let S = 0; S < y.morphTargetInfluences.length; S++)
|
|
639
|
-
y.morphTargetInfluences[S] *= v;
|
|
585
|
+
ee.toLowerCase() === w.toLowerCase() && (Q[j[ee]] = S);
|
|
640
586
|
}
|
|
641
587
|
const Kn = Tn(
|
|
642
588
|
({
|
|
643
|
-
avatarUrl:
|
|
644
|
-
isPlayingRef:
|
|
645
|
-
visemeQueueRef:
|
|
646
|
-
audioContextRef:
|
|
589
|
+
avatarUrl: u,
|
|
590
|
+
isPlayingRef: w,
|
|
591
|
+
visemeQueueRef: S,
|
|
592
|
+
audioContextRef: y,
|
|
647
593
|
responseAudioStartTimeRef: j,
|
|
648
594
|
adjustments: Q,
|
|
649
595
|
mood: ee,
|
|
650
|
-
expression:
|
|
651
|
-
agentResponse:
|
|
596
|
+
expression: Ze,
|
|
597
|
+
agentResponse: We,
|
|
652
598
|
isSpeaking: U,
|
|
653
|
-
nextStartTimeRef:
|
|
654
|
-
stopPlayback:
|
|
655
|
-
setIsSpeaking:
|
|
599
|
+
nextStartTimeRef: ut,
|
|
600
|
+
stopPlayback: ke,
|
|
601
|
+
setIsSpeaking: et,
|
|
656
602
|
expressionUrl: G,
|
|
657
603
|
onExpressionFinished: Ae,
|
|
658
604
|
isNudgeResponse: q,
|
|
659
|
-
avatarGender:
|
|
605
|
+
avatarGender: ae
|
|
660
606
|
}) => {
|
|
661
|
-
const { scene:
|
|
662
|
-
() => H.flatMap((
|
|
607
|
+
const { scene: O } = Dt(u), H = Dt(ae === "female" ? Nn : Cn), g = Pt(
|
|
608
|
+
() => H.flatMap((b) => b.animations),
|
|
663
609
|
[H]
|
|
664
|
-
), m =
|
|
665
|
-
() => m.flatMap((
|
|
610
|
+
), m = Dt(ae === "female" ? Pn : Fn), D = Pt(
|
|
611
|
+
() => m.flatMap((b) => b.animations),
|
|
666
612
|
[m]
|
|
667
|
-
), z =
|
|
668
|
-
|
|
669
|
-
if (!(!
|
|
670
|
-
if (
|
|
671
|
-
const
|
|
672
|
-
if (!J.current[
|
|
673
|
-
const
|
|
674
|
-
|
|
613
|
+
), z = a(null), A = a(null), F = a(null), $ = a(null), Y = a(null), X = a(null), kt = a([]), [te] = k(() => new gt.AnimationMixer(O)), J = a({}), V = a(null), Ee = a(0), tt = a(!1), He = a(0), Ie = a(!1), ye = a(null), Oe = a(Zt), bt = a(-1), De = a("left"), je = a(Lt + Math.random() * (nn - Lt)), he = a(0), Ce = a("smile"), Ne = a({});
|
|
614
|
+
B(() => {
|
|
615
|
+
if (!(!g || !O)) {
|
|
616
|
+
if (g.forEach((b, p) => {
|
|
617
|
+
const o = `idle_${p}`;
|
|
618
|
+
if (!J.current[o]) {
|
|
619
|
+
const l = te.clipAction(b, O);
|
|
620
|
+
l.name = o, l.setLoop(gt.LoopOnce, 1), l.clampWhenFinished = !0, J.current[o] = l;
|
|
675
621
|
}
|
|
676
|
-
}),
|
|
677
|
-
const
|
|
678
|
-
if (!J.current[
|
|
679
|
-
const
|
|
680
|
-
|
|
622
|
+
}), D.forEach((b, p) => {
|
|
623
|
+
const o = `talk_${p}`;
|
|
624
|
+
if (!J.current[o]) {
|
|
625
|
+
const l = te.clipAction(b, O);
|
|
626
|
+
l.name = o, l.setLoop(gt.LoopOnce, 1), l.clampWhenFinished = !0, J.current[o] = l;
|
|
681
627
|
}
|
|
682
|
-
}),
|
|
683
|
-
const
|
|
684
|
-
|
|
628
|
+
}), g.length > 0) {
|
|
629
|
+
const b = J.current.idle_0, p = V.current && te.existingAction(V.current.getClip());
|
|
630
|
+
b && !p && (b.reset().fadeIn(0.5).play(), V.current = b);
|
|
685
631
|
}
|
|
686
632
|
return () => {
|
|
687
633
|
te.stopAllAction(), J.current = {}, V.current = null;
|
|
688
634
|
};
|
|
689
635
|
}
|
|
690
|
-
}, [
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
if (!G || !
|
|
694
|
-
|
|
636
|
+
}, [g, D, O, te]);
|
|
637
|
+
const nt = a("");
|
|
638
|
+
B(() => {
|
|
639
|
+
if (!G || !O || G === nt.current) return;
|
|
640
|
+
nt.current = G, ye.current = G, new En().load(
|
|
695
641
|
G,
|
|
696
|
-
(
|
|
697
|
-
if (
|
|
698
|
-
const
|
|
699
|
-
if (
|
|
700
|
-
const
|
|
701
|
-
|
|
642
|
+
(p) => {
|
|
643
|
+
if (p.animations && p.animations.length > 0) {
|
|
644
|
+
const o = p.animations[0], l = te.clipAction(o, O);
|
|
645
|
+
if (l.name = `EXPR_${G}`, l.setLoop(gt.LoopOnce, 1), l.clampWhenFinished = !0, J.current[`EXPR_${G}`] = l, U && ye.current === G) {
|
|
646
|
+
const L = V.current;
|
|
647
|
+
l.reset().fadeIn(0.3).play(), L && L !== l && L.crossFadeTo(l, 0.3, !0), V.current = l, ye.current = null;
|
|
702
648
|
}
|
|
703
649
|
}
|
|
704
650
|
},
|
|
705
651
|
void 0,
|
|
706
|
-
(
|
|
707
|
-
console.error(`[ANIMATION] Failed to load ${G}`,
|
|
652
|
+
(p) => {
|
|
653
|
+
console.error(`[ANIMATION] Failed to load ${G}`, p);
|
|
708
654
|
}
|
|
709
655
|
);
|
|
710
|
-
}, [G,
|
|
711
|
-
const
|
|
712
|
-
const
|
|
713
|
-
if (
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
} else if (
|
|
656
|
+
}, [G, O, te, U]), B(() => {
|
|
657
|
+
const b = (p) => {
|
|
658
|
+
const o = p.action, l = o.name || "";
|
|
659
|
+
if (l.startsWith("idle_")) {
|
|
660
|
+
const ne = (parseInt(l.split("_")[1]) + 1) % g.length, re = J.current[`idle_${ne}`];
|
|
661
|
+
re && (re.reset().fadeIn(0.5).play(), o.crossFadeTo(re, 0.5, !0), V.current = re);
|
|
662
|
+
} else if (l.startsWith("EXPR_")) {
|
|
717
663
|
if (U) {
|
|
718
|
-
const
|
|
719
|
-
Math.random() *
|
|
720
|
-
),
|
|
721
|
-
|
|
664
|
+
const L = Math.floor(
|
|
665
|
+
Math.random() * D.length
|
|
666
|
+
), ne = J.current[`talk_${L}`];
|
|
667
|
+
ne && (ne.reset().fadeIn(0.5).play(), o.crossFadeTo(ne, 0.5, !0), V.current = ne);
|
|
722
668
|
} else {
|
|
723
|
-
const
|
|
724
|
-
|
|
669
|
+
const L = J.current.idle_0;
|
|
670
|
+
L && (L.reset().fadeIn(0.5).play(), o.crossFadeTo(L, 0.5, !0), V.current = L);
|
|
725
671
|
}
|
|
726
672
|
Ae && Ae();
|
|
727
|
-
} else if (
|
|
673
|
+
} else if (l.startsWith("talk_"))
|
|
728
674
|
if (U && !q) {
|
|
729
|
-
const
|
|
730
|
-
|
|
675
|
+
const ne = (parseInt(l.split("_")[1]) + 1) % D.length, re = J.current[`talk_${ne}`];
|
|
676
|
+
re && (re.reset().fadeIn(0.3).play(), o.crossFadeTo(re, 0.3, !0), V.current = re);
|
|
731
677
|
} else {
|
|
732
|
-
const
|
|
733
|
-
|
|
678
|
+
const L = J.current.idle_0;
|
|
679
|
+
L && (L.reset().fadeIn(0.5).play(), o.crossFadeTo(L, 0.5, !0), V.current = L);
|
|
734
680
|
}
|
|
735
681
|
};
|
|
736
|
-
return te.addEventListener("finished",
|
|
682
|
+
return te.addEventListener("finished", b), () => te.removeEventListener("finished", b);
|
|
737
683
|
}, [
|
|
738
684
|
te,
|
|
739
|
-
|
|
740
|
-
|
|
685
|
+
g,
|
|
686
|
+
D,
|
|
741
687
|
U,
|
|
742
688
|
q,
|
|
743
689
|
Ae
|
|
744
|
-
]),
|
|
745
|
-
if (U &&
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
748
|
-
const
|
|
749
|
-
if (
|
|
750
|
-
const
|
|
751
|
-
if (
|
|
752
|
-
|
|
690
|
+
]), B(() => {
|
|
691
|
+
if (U && O) {
|
|
692
|
+
const b = V.current, p = b?.name || "";
|
|
693
|
+
if (p.startsWith("idle_") || p.startsWith("talk_") || p === "") {
|
|
694
|
+
const o = ye.current;
|
|
695
|
+
if (o) {
|
|
696
|
+
const l = J.current[`EXPR_${o}`];
|
|
697
|
+
if (l) {
|
|
698
|
+
l.reset().fadeIn(0.3).play(), b && b !== l && b.crossFadeTo(l, 0.3, !0), V.current = l, ye.current = null;
|
|
753
699
|
return;
|
|
754
700
|
}
|
|
755
701
|
}
|
|
756
|
-
if (
|
|
757
|
-
const
|
|
758
|
-
Math.random() *
|
|
759
|
-
),
|
|
760
|
-
|
|
702
|
+
if (p.startsWith("idle_") || p === "") {
|
|
703
|
+
const l = Math.floor(
|
|
704
|
+
Math.random() * D.length
|
|
705
|
+
), L = J.current[`talk_${l}`];
|
|
706
|
+
L && (L.reset().fadeIn(0.5).play(), b && b.crossFadeTo(L, 0.5, !0), V.current = L);
|
|
761
707
|
}
|
|
762
708
|
}
|
|
763
|
-
} else if (!U &&
|
|
764
|
-
const
|
|
765
|
-
if (
|
|
766
|
-
const
|
|
767
|
-
|
|
709
|
+
} else if (!U && O) {
|
|
710
|
+
const b = V.current, p = b?.name || "";
|
|
711
|
+
if (p.startsWith("talk_") || p.startsWith("EXPR_")) {
|
|
712
|
+
const o = J.current.idle_0;
|
|
713
|
+
o && (o.reset().fadeIn(0.5).play(), b && b.crossFadeTo(o, 0.5, !0), V.current = o);
|
|
768
714
|
}
|
|
769
715
|
}
|
|
770
|
-
}, [U,
|
|
771
|
-
if (!
|
|
772
|
-
|
|
773
|
-
if (
|
|
774
|
-
const
|
|
775
|
-
(
|
|
716
|
+
}, [U, O, G]), B(() => {
|
|
717
|
+
if (!O) return;
|
|
718
|
+
O.traverse((o) => {
|
|
719
|
+
if (o.isMesh && o.morphTargetDictionary) {
|
|
720
|
+
const l = o.name.toLowerCase();
|
|
721
|
+
(l.includes("head") || l.includes("avatar")) && (A.current = o, N(`[ANIMATION] Found head mesh: ${o.name}`)), l.includes("teeth") && (F.current = o, N(`[ANIMATION] Found teeth mesh: ${o.name}`)), l.includes("beard") && ($.current = o, N(`[ANIMATION] Found beard mesh: ${o.name}`)), l.includes("eyeleft") && (Y.current = o, N(`[ANIMATION] Found eye left mesh: ${o.name}`)), l.includes("eyeright") && (X.current = o, N(`[ANIMATION] Found eye right mesh: ${o.name}`));
|
|
776
722
|
}
|
|
777
723
|
});
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
(
|
|
724
|
+
const b = A.current?.morphTargetDictionary;
|
|
725
|
+
b && Object.keys(b).filter(
|
|
726
|
+
(o) => o.toLowerCase().includes("brow")
|
|
781
727
|
);
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
if (
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
}), yt.current = h, h.length > 0 && N("[ANIMATION] Meshes with brow morphs:", h.length);
|
|
789
|
-
}, [I]);
|
|
790
|
-
const ot = (p, h = 1) => {
|
|
791
|
-
const a = `viseme_${p}`.toLowerCase(), o = Jn.find((d) => d.key.toLowerCase() === a);
|
|
792
|
-
if (o) {
|
|
793
|
-
for (const d in o.mix) {
|
|
794
|
-
const D = o.mix[d] * h;
|
|
795
|
-
u(A.current, d, D), u(F.current, d, D), (!o.teethMix || !(d in o.teethMix)) && u(M.current, d, D);
|
|
728
|
+
const p = [];
|
|
729
|
+
O.traverse((o) => {
|
|
730
|
+
if (o.isMesh) {
|
|
731
|
+
const L = o.morphTargetDictionary;
|
|
732
|
+
L && Object.keys(L).some((ne) => ne.toLowerCase().includes("brow")) && p.push(o);
|
|
796
733
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
}, it = (p) => {
|
|
804
|
-
const h = wt[p] ?? wt.neutral;
|
|
805
|
-
for (const a in h)
|
|
806
|
-
u(A.current, a, h[a]), u(M.current, a, h[a]), u(F.current, a, h[a]);
|
|
734
|
+
}), kt.current = p, p.length > 0 && N("[ANIMATION] Meshes with brow morphs:", p.length);
|
|
735
|
+
}, [O]);
|
|
736
|
+
const lt = (b) => {
|
|
737
|
+
const p = St[b] ?? St.neutral;
|
|
738
|
+
for (const o in p)
|
|
739
|
+
c(A.current, o, p[o]), c(F.current, o, p[o]), c($.current, o, p[o]);
|
|
807
740
|
};
|
|
808
|
-
return kn((
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
P.name.toLowerCase().includes("hips") && (_ = P);
|
|
741
|
+
return kn((b, p) => {
|
|
742
|
+
lt(ee);
|
|
743
|
+
const o = b.clock.elapsedTime;
|
|
744
|
+
let l = 0;
|
|
745
|
+
if (Math.floor(o) % 5 === 0 && Math.floor((o - p) % 5) !== 0) {
|
|
746
|
+
let d = null;
|
|
747
|
+
O.traverse((T) => {
|
|
748
|
+
T.name.toLowerCase().includes("hips") && (d = T);
|
|
817
749
|
});
|
|
818
|
-
const
|
|
819
|
-
N(`[ANIMATION] Mixer Time: ${te.time.toFixed(2)}, ${
|
|
750
|
+
const I = d ? `Hips Y: ${d.position.y.toFixed(4)}` : "Hips not found";
|
|
751
|
+
N(`[ANIMATION] Mixer Time: ${te.time.toFixed(2)}, ${I}`);
|
|
820
752
|
}
|
|
821
|
-
if (te.update(
|
|
822
|
-
const
|
|
823
|
-
if (
|
|
824
|
-
if (
|
|
825
|
-
const
|
|
826
|
-
Ee.current = o +
|
|
753
|
+
if (te.update(p), o > Ee.current && !tt.current && (tt.current = !0, He.current = o), tt.current) {
|
|
754
|
+
const d = U ? 0.2 : 0.3, I = (o - He.current) / d;
|
|
755
|
+
if (I >= 1)
|
|
756
|
+
if (tt.current = !1, Ie.current) {
|
|
757
|
+
const T = U ? 1 : 2.5;
|
|
758
|
+
Ee.current = o + T, Ie.current = !1;
|
|
827
759
|
} else
|
|
828
760
|
Ee.current = o + 0.12, Ie.current = !0;
|
|
829
761
|
else {
|
|
830
|
-
const
|
|
831
|
-
|
|
762
|
+
const T = I < 0.5 ? I * 2 : (1 - I) * 2;
|
|
763
|
+
c(A.current, "eyeBlinkLeft", T), c(A.current, "eyeBlinkRight", T), c(F.current, "eyeBlinkLeft", T), c(F.current, "eyeBlinkRight", T), c($.current, "eyeBlinkLeft", T), c($.current, "eyeBlinkRight", T), l = T * Wn.browInnerUp;
|
|
832
764
|
}
|
|
833
765
|
}
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
o >
|
|
838
|
-
const
|
|
839
|
-
(
|
|
840
|
-
const
|
|
841
|
-
if (De.current === "up" ? (
|
|
842
|
-
|
|
843
|
-
const
|
|
844
|
-
|
|
766
|
+
const L = St[ee] ?? St.neutral, ne = L.browInnerUp ?? 0, re = L.browOuterUpLeft ?? 0, ue = L.browOuterUpRight ?? 0, rt = o * Hn, Ue = Ct * Math.sin(rt), Ge = Ct * 0.7 * Math.sin(rt + 0.7), ot = Ct * 0.7 * Math.sin(rt + 1.3), x = (d) => Math.max(0, Math.min(1, d)), dt = x(ne + Ue), Je = x(re + Ge), qe = x(ue + ot), ze = x(dt + l);
|
|
767
|
+
c(A.current, "browInnerUp", ze), c(F.current, "browInnerUp", ze), c($.current, "browInnerUp", ze), c(A.current, "browOuterUpLeft", Je), c(F.current, "browOuterUpLeft", Je), c($.current, "browOuterUpLeft", Je), c(A.current, "browOuterUpRight", qe), c(F.current, "browOuterUpRight", qe), c($.current, "browOuterUpRight", qe);
|
|
768
|
+
const Re = Oe.current, oe = Re + vt, Fe = oe + Nt;
|
|
769
|
+
o > Fe && (Oe.current += vt + Nt + Zt);
|
|
770
|
+
const Ye = !U && o >= Re && o < oe, Pe = !U && o >= oe && o < Fe;
|
|
771
|
+
(Ye || Pe) && bt.current !== Re && (bt.current = Re, De.current = Math.random() < 0.7 ? "left" : "up");
|
|
772
|
+
const le = Ye ? o - Re : Pe ? vt : 0, Ke = Ye || Pe ? Math.min(1, le / vt) : 0, ft = Ke <= 0 ? 0 : Math.sin(Ke * Math.PI), Rt = Pe ? 1 - (o - oe) / Nt : 1, ht = Ye ? ft : Pe ? ft * Rt : 0, K = jn * ht, E = (d) => L[d] ?? 0;
|
|
773
|
+
if (De.current === "up" ? (c(Y.current, "eyeLookUpLeft", x(E("eyeLookUpLeft") + K)), c(Y.current, "eyeLookDownLeft", x(E("eyeLookDownLeft"))), c(Y.current, "eyeLookOutLeft", x(E("eyeLookOutLeft"))), c(Y.current, "eyeLookInLeft", x(E("eyeLookInLeft"))), c(X.current, "eyeLookUpRight", x(E("eyeLookUpRight") + K)), c(X.current, "eyeLookDownRight", x(E("eyeLookDownRight"))), c(X.current, "eyeLookOutRight", x(E("eyeLookOutRight"))), c(X.current, "eyeLookInRight", x(E("eyeLookInRight")))) : (c(Y.current, "eyeLookUpLeft", x(E("eyeLookUpLeft"))), c(Y.current, "eyeLookDownLeft", x(E("eyeLookDownLeft"))), c(Y.current, "eyeLookOutLeft", x(E("eyeLookOutLeft"))), c(Y.current, "eyeLookInLeft", x(E("eyeLookInLeft") + K)), c(X.current, "eyeLookUpRight", x(E("eyeLookUpRight"))), c(X.current, "eyeLookDownRight", x(E("eyeLookDownRight"))), c(X.current, "eyeLookOutRight", x(E("eyeLookOutRight") + K)), c(X.current, "eyeLookInRight", x(E("eyeLookInRight")))), !U && o >= je.current) {
|
|
774
|
+
he.current = o, Ce.current = Math.random() < 0.5 ? "pucker" : "smile";
|
|
775
|
+
const d = Ce.current === "pucker" ? tn : en;
|
|
776
|
+
je.current = o + d + Lt + Math.random() * (nn - Lt);
|
|
845
777
|
}
|
|
846
|
-
const
|
|
847
|
-
const
|
|
848
|
-
return 1 -
|
|
849
|
-
})(),
|
|
850
|
-
if (
|
|
851
|
-
if (
|
|
852
|
-
const
|
|
853
|
-
|
|
778
|
+
const de = Ce.current === "pucker" ? tn : en, mt = !U && o >= he.current && o < he.current + de, Be = mt ? (o - he.current) / de : 0, me = Be <= 0 ? 0 : Be < 0.5 ? Be * 2 : (() => {
|
|
779
|
+
const d = (Be - 0.5) * 2;
|
|
780
|
+
return 1 - d * d * (3 - 2 * d);
|
|
781
|
+
})(), xe = (d) => L[d] ?? 0;
|
|
782
|
+
if (mt)
|
|
783
|
+
if (Ce.current === "pucker") {
|
|
784
|
+
const d = x(xe("mouthPucker") + Gn * me);
|
|
785
|
+
c(A.current, "mouthPucker", d), c(F.current, "mouthPucker", d), c($.current, "mouthPucker", d);
|
|
854
786
|
} else {
|
|
855
|
-
const
|
|
856
|
-
|
|
787
|
+
const d = x(xe("mouthSmileLeft") + rn * me), I = x(xe("mouthSmileRight") + rn * me), T = x(xe("mouthDimpleLeft") + on * me), ve = x(xe("mouthDimpleRight") + on * me);
|
|
788
|
+
c(A.current, "mouthSmileLeft", d), c(A.current, "mouthSmileRight", I), c(A.current, "mouthDimpleLeft", T), c(A.current, "mouthDimpleRight", ve), c(F.current, "mouthSmileLeft", d), c(F.current, "mouthSmileRight", I), c(F.current, "mouthDimpleLeft", T), c(F.current, "mouthDimpleRight", ve), c($.current, "mouthSmileLeft", d), c($.current, "mouthSmileRight", I), c($.current, "mouthDimpleLeft", T), c($.current, "mouthDimpleRight", ve);
|
|
857
789
|
}
|
|
858
790
|
if (z.current) {
|
|
859
|
-
const
|
|
860
|
-
z.current.rotation.y =
|
|
791
|
+
const d = w.current ? 0 : Q.rotation[1];
|
|
792
|
+
z.current.rotation.y = gt.MathUtils.lerp(
|
|
861
793
|
z.current.rotation.y,
|
|
862
|
-
|
|
794
|
+
d,
|
|
863
795
|
0.1
|
|
864
796
|
), z.current.position.set(...Q.position), z.current.scale.setScalar(Q.scale), z.current.rotation.x = Q.rotation[0], z.current.rotation.z = Q.rotation[2];
|
|
865
797
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
798
|
+
const fe = {};
|
|
799
|
+
if (Ut.forEach((d) => {
|
|
800
|
+
fe[d] = 0;
|
|
801
|
+
}), w.current && y.current) {
|
|
802
|
+
const d = y.current.currentTime, ve = (d - j.current) * 1e3 - -150;
|
|
803
|
+
for (let $e = 0; $e < S.current.length; $e++) {
|
|
804
|
+
const Te = S.current[$e];
|
|
805
|
+
if (ve < Te.vtime || ve >= Te.vtime + Te.vduration)
|
|
806
|
+
continue;
|
|
807
|
+
const _t = qn(
|
|
808
|
+
ve,
|
|
809
|
+
Te.vtime,
|
|
810
|
+
Te.vduration
|
|
811
|
+
), xt = `viseme_${Te.viseme}`.toLowerCase(), Ve = un.find((ie) => ie.key.toLowerCase() === xt);
|
|
812
|
+
if (!Ve) continue;
|
|
813
|
+
const pe = (Te.weight ?? 1) * _t;
|
|
814
|
+
for (const ie in Ve.mix)
|
|
815
|
+
fe[ie] = (fe[ie] ?? 0) + Ve.mix[ie] * pe;
|
|
816
|
+
if (Ve.teethMix)
|
|
817
|
+
for (const ie in Ve.teethMix)
|
|
818
|
+
fe[ie] = (fe[ie] ?? 0) + Ve.teethMix[ie] * pe;
|
|
871
819
|
}
|
|
872
|
-
|
|
820
|
+
d > ut.current + 0.5 && (ke(), et(!1));
|
|
873
821
|
}
|
|
874
|
-
|
|
822
|
+
const it = Ne.current;
|
|
823
|
+
Ut.forEach((d) => {
|
|
824
|
+
const I = fe[d] ?? 0, T = it[d] ?? 0;
|
|
825
|
+
it[d] = Math.max(
|
|
826
|
+
0,
|
|
827
|
+
Math.min(
|
|
828
|
+
1,
|
|
829
|
+
T + (I - T) * (1 - Math.exp(-12 * p))
|
|
830
|
+
)
|
|
831
|
+
);
|
|
832
|
+
}), Ut.forEach((d) => {
|
|
833
|
+
const I = it[d] ?? 0;
|
|
834
|
+
c(A.current, d, I), c($.current, d, I), c(F.current, d, I);
|
|
835
|
+
});
|
|
836
|
+
}), /* @__PURE__ */ h("group", { ref: z, children: /* @__PURE__ */ h("primitive", { object: O }) });
|
|
875
837
|
}
|
|
876
838
|
);
|
|
877
|
-
function Qn(
|
|
878
|
-
return
|
|
839
|
+
function Qn(u) {
|
|
840
|
+
return u ? u.charAt(0).toUpperCase() + u.slice(1).toLowerCase() : "";
|
|
879
841
|
}
|
|
880
|
-
function
|
|
881
|
-
return
|
|
842
|
+
function cn(u) {
|
|
843
|
+
return u.replace(/\*(.*?)\*/g, " $1 ").replace(/\[.*?\]/g, " ").replace(/<.*?\/>/g, " ").replace(/<.*?>.*?<\/.*?>/g, " ").replace(/\s+/g, " ").trim();
|
|
882
844
|
}
|
|
883
|
-
const
|
|
884
|
-
onNavigationRequested:
|
|
885
|
-
agentId:
|
|
886
|
-
presetUserDetails:
|
|
887
|
-
onAvatarReady:
|
|
845
|
+
const Ft = /* @__PURE__ */ new Map(), Xn = ({
|
|
846
|
+
onNavigationRequested: u,
|
|
847
|
+
agentId: w,
|
|
848
|
+
presetUserDetails: S,
|
|
849
|
+
onAvatarReady: y
|
|
888
850
|
}) => {
|
|
889
|
-
const [j, Q] =
|
|
890
|
-
|
|
891
|
-
if (!
|
|
892
|
-
|
|
851
|
+
const [j, Q] = k(""), [ee, Ze] = k("male"), [We, U] = k(""), [ut, ke] = k(!1), et = j, G = ee;
|
|
852
|
+
B(() => {
|
|
853
|
+
if (!w) {
|
|
854
|
+
ke(!0);
|
|
893
855
|
return;
|
|
894
856
|
}
|
|
895
857
|
let e = !1;
|
|
896
858
|
return (async () => {
|
|
897
|
-
console.log(">> fetchConfig RUNNING for",
|
|
859
|
+
console.log(">> fetchConfig RUNNING for", w);
|
|
898
860
|
try {
|
|
899
|
-
const r = `agent_config_${
|
|
861
|
+
const r = `agent_config_${w}`, i = sessionStorage.getItem(r);
|
|
900
862
|
if (i)
|
|
901
863
|
try {
|
|
902
864
|
const s = JSON.parse(i);
|
|
903
|
-
e || (s.encryptedAgentToken && Q(s.encryptedAgentToken), s.avatarGender &&
|
|
865
|
+
e || (s.encryptedAgentToken && Q(s.encryptedAgentToken), s.avatarGender && Ze(s.avatarGender), s.agent_id && U(s.agent_id), ke(!0));
|
|
904
866
|
return;
|
|
905
867
|
} catch (s) {
|
|
906
868
|
console.error("Failed to parse cached avatar config:", s), sessionStorage.removeItem(r);
|
|
907
869
|
}
|
|
908
|
-
let
|
|
909
|
-
if (
|
|
910
|
-
console.log(">> REUSING in-flight fetch for",
|
|
870
|
+
let n;
|
|
871
|
+
if (Ft.has(w))
|
|
872
|
+
console.log(">> REUSING in-flight fetch for", w), n = await Ft.get(w);
|
|
911
873
|
else {
|
|
912
874
|
const s = (async () => {
|
|
913
|
-
console.log(">> INITIATING visitedWebsite fetch for",
|
|
914
|
-
const f = { agentId:
|
|
875
|
+
console.log(">> INITIATING visitedWebsite fetch for", w);
|
|
876
|
+
const f = { agentId: w }, _ = await fetch(`${ct}/visitedWebsite`, {
|
|
915
877
|
method: "POST",
|
|
916
878
|
headers: { "Content-Type": "application/json" },
|
|
917
879
|
body: JSON.stringify(f)
|
|
918
880
|
});
|
|
919
|
-
if (!
|
|
920
|
-
const
|
|
921
|
-
return sessionStorage.setItem(r, JSON.stringify(
|
|
881
|
+
if (!_.ok) throw new Error(`Fetch failed: ${_.status}`);
|
|
882
|
+
const v = await _.json();
|
|
883
|
+
return sessionStorage.setItem(r, JSON.stringify(v)), v;
|
|
922
884
|
})();
|
|
923
|
-
|
|
885
|
+
Ft.set(w, s), n = await s;
|
|
924
886
|
}
|
|
925
887
|
if (e) return;
|
|
926
|
-
|
|
888
|
+
n && (n.encryptedAgentToken && Q(n.encryptedAgentToken), n.avatarGender && Ze(n.avatarGender), n.agent_id && U(n.agent_id));
|
|
927
889
|
} catch (r) {
|
|
928
890
|
console.error("Failed to fetch avatar config:", r);
|
|
929
891
|
} finally {
|
|
930
|
-
e ||
|
|
892
|
+
e || ke(!0);
|
|
931
893
|
}
|
|
932
894
|
})(), () => {
|
|
933
895
|
e = !0;
|
|
934
896
|
};
|
|
935
|
-
}, [
|
|
936
|
-
const Ae =
|
|
897
|
+
}, [w]);
|
|
898
|
+
const Ae = Dn(w ?? We), [q, ae] = k(""), [O, we] = k(""), [H, g] = k("Ready"), [ce, m] = k(!1), [D, z] = k(!1), [A, F] = k([]), [$, Y] = k(""), X = a(null), [kt, te] = k(
|
|
937
899
|
() => typeof window < "u" ? window.matchMedia("(max-width: 480px)").matches : !1
|
|
938
900
|
);
|
|
939
|
-
|
|
940
|
-
const e = window.matchMedia("(max-width: 480px)"),
|
|
941
|
-
return e.addEventListener("change",
|
|
901
|
+
B(() => {
|
|
902
|
+
const e = window.matchMedia("(max-width: 480px)"), t = () => te(e.matches);
|
|
903
|
+
return e.addEventListener("change", t), () => e.removeEventListener("change", t);
|
|
942
904
|
}, []);
|
|
943
|
-
const J =
|
|
944
|
-
|
|
945
|
-
const
|
|
946
|
-
null
|
|
947
|
-
), p = c(null), [h, a] = L("neutral"), [o, d] = L(""), [D, ne] = L(""), [St, $e] = L("Chat with us"), [re, ut] = L(
|
|
905
|
+
const J = kt ? 80 : 600, V = a(!1), Ee = a([]), tt = a(0), He = a(!1), Ie = a([]), ye = a(null), Oe = a([]);
|
|
906
|
+
a([]);
|
|
907
|
+
const bt = a([]), De = a(0), je = a(0), he = a(0), Ce = a(0), Ne = a(!1), [nt, lt] = k(
|
|
948
908
|
null
|
|
949
|
-
), [
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
909
|
+
), b = a(null), [p, o] = k("neutral"), [l, L] = k(""), [ne, re] = k(""), [ue, rt] = k(
|
|
910
|
+
() => {
|
|
911
|
+
if (typeof window > "u") return null;
|
|
912
|
+
try {
|
|
913
|
+
const e = window.sessionStorage.getItem("leadCaptureAskFor");
|
|
914
|
+
return e && e !== "" ? e : null;
|
|
915
|
+
} catch {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
), [Ue, Ge] = k("hidden"), [ot, x] = k(""), dt = a(null), Je = a(Ue);
|
|
920
|
+
Je.current = Ue;
|
|
921
|
+
const [qe, ze] = k(null), Re = a(null), oe = a(null), [Fe, Ye] = k(!1), Pe = a(null), [le, Ke] = k("hidden"), [ft, Rt] = k(""), ht = a(le);
|
|
922
|
+
ht.current = le;
|
|
923
|
+
const K = a(""), E = a(!1), de = a(""), mt = a(Date.now()), Be = a([]), me = a(!1), [xe, fe] = k(!1), [it, d] = k(!1), I = a(null), T = Pt(() => Fe ? "Try again" : H === "Busy" ? "Busy" : H === "Thinking..." || H === "Processing Voice..." ? H : ue != null && ue !== "" && ue !== "none" && ue !== "<none>" ? `Enter ${Qn(ue)}` : le !== "hidden" || !it ? null : sn, [H, ue, Fe, le, it]), ve = !Fe && H !== "Busy" && H !== "Thinking..." && H !== "Processing Voice..." && (ue == null || ue === "" || ue === "none" || ue === "<none>");
|
|
924
|
+
B(() => {
|
|
925
|
+
if (le !== "hidden" || !ve) {
|
|
926
|
+
d(!1), I.current != null && (clearTimeout(I.current), I.current = null);
|
|
957
927
|
return;
|
|
958
928
|
}
|
|
959
|
-
return
|
|
960
|
-
|
|
929
|
+
return I.current = setTimeout(() => {
|
|
930
|
+
I.current = null, d(!0);
|
|
961
931
|
}, 400), () => {
|
|
962
|
-
|
|
932
|
+
I.current != null && (clearTimeout(I.current), I.current = null);
|
|
963
933
|
};
|
|
964
|
-
}, [
|
|
965
|
-
const
|
|
966
|
-
|
|
967
|
-
const e =
|
|
934
|
+
}, [le, ve]);
|
|
935
|
+
const $e = T != null && T !== "";
|
|
936
|
+
B(() => {
|
|
937
|
+
const e = Je.current;
|
|
968
938
|
if (!(e === "exiting" || e === "entering")) {
|
|
969
939
|
if (e === "hidden") {
|
|
970
|
-
|
|
940
|
+
$e && (x(T ?? ""), Ge("entering"));
|
|
971
941
|
return;
|
|
972
942
|
}
|
|
973
|
-
e === "visible" && (
|
|
943
|
+
e === "visible" && (!$e || T !== ot) && (dt.current = $e ? T : null, Ge("exiting"));
|
|
974
944
|
}
|
|
975
945
|
}, [
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
]),
|
|
946
|
+
$e,
|
|
947
|
+
T,
|
|
948
|
+
Ue,
|
|
949
|
+
ot
|
|
950
|
+
]), B(() => {
|
|
981
951
|
if (H !== "Busy") {
|
|
982
|
-
|
|
952
|
+
oe.current != null && (clearTimeout(oe.current), oe.current = null);
|
|
983
953
|
return;
|
|
984
954
|
}
|
|
985
|
-
return
|
|
986
|
-
|
|
955
|
+
return oe.current = setTimeout(() => {
|
|
956
|
+
oe.current = null, g("Ready"), Ye(!0);
|
|
987
957
|
}, 12e3), () => {
|
|
988
|
-
|
|
958
|
+
oe.current != null && (clearTimeout(oe.current), oe.current = null);
|
|
989
959
|
};
|
|
990
|
-
}, [H]),
|
|
991
|
-
if (!
|
|
992
|
-
const e = setTimeout(() =>
|
|
960
|
+
}, [H]), B(() => {
|
|
961
|
+
if (!Fe) return;
|
|
962
|
+
const e = setTimeout(() => Ye(!1), 2500);
|
|
993
963
|
return () => clearTimeout(e);
|
|
994
|
-
}, [
|
|
995
|
-
const
|
|
996
|
-
const e =
|
|
964
|
+
}, [Fe]);
|
|
965
|
+
const Te = at(() => {
|
|
966
|
+
const e = Je.current;
|
|
997
967
|
if (e === "exiting") {
|
|
998
|
-
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
} else e === "entering" &&
|
|
1002
|
-
}, []),
|
|
968
|
+
Ge("hidden");
|
|
969
|
+
const t = dt.current;
|
|
970
|
+
dt.current = null, t != null && t !== "" && (x(t), Ge("entering"));
|
|
971
|
+
} else e === "entering" && Ge("visible");
|
|
972
|
+
}, []), _t = (e) => {
|
|
1003
973
|
if (!e) return;
|
|
1004
974
|
if (e.mood != null) {
|
|
1005
|
-
const
|
|
1006
|
-
|
|
975
|
+
const n = String(e.mood).toLowerCase();
|
|
976
|
+
o(n);
|
|
1007
977
|
}
|
|
1008
978
|
if (e.expression != null) {
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1011
|
-
const s =
|
|
1012
|
-
(f) => f.name.toLowerCase() ===
|
|
979
|
+
const n = String(e.expression).trim();
|
|
980
|
+
L(n);
|
|
981
|
+
const s = Un.find(
|
|
982
|
+
(f) => f.name.toLowerCase() === n.toLowerCase()
|
|
1013
983
|
);
|
|
1014
984
|
N(
|
|
1015
|
-
`[STREAM] Animation match for "${
|
|
1016
|
-
),
|
|
985
|
+
`[STREAM] Animation match for "${n}": ${s ? s.name : "NONE"}`
|
|
986
|
+
), re(s?.url ?? "");
|
|
1017
987
|
}
|
|
1018
988
|
if (e.navigation != null) {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
989
|
+
const n = String(e.navigation).trim();
|
|
990
|
+
if (n !== "") {
|
|
991
|
+
let s = !1;
|
|
992
|
+
if (typeof window < "u")
|
|
993
|
+
try {
|
|
994
|
+
const f = new URL(window.location.href), _ = new URL(n, window.location.href);
|
|
995
|
+
if (_.origin !== f.origin) {
|
|
996
|
+
N("[STREAM] Navigation rejected: different origin");
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
const v = (M) => M.replace(/\/+$/, "") || "/";
|
|
1000
|
+
s = v(f.pathname) === v(_.pathname);
|
|
1001
|
+
} catch {
|
|
1002
|
+
}
|
|
1003
|
+
if (s)
|
|
1004
|
+
return;
|
|
1005
|
+
u ? u(n) : ze(n);
|
|
1006
|
+
}
|
|
1021
1007
|
}
|
|
1022
|
-
const
|
|
1023
|
-
if (
|
|
1024
|
-
const
|
|
1025
|
-
if (
|
|
1008
|
+
const t = e.ask_for || e.lead_capture?.ask_for, r = t ? String(t).trim().toLowerCase() : "", i = r === "none" || r === "<none>";
|
|
1009
|
+
if (t && !i) {
|
|
1010
|
+
const n = r;
|
|
1011
|
+
if (S && (n === "email" && S.email || n === "name" && S.name || n === "phone" && S.phone))
|
|
1026
1012
|
return;
|
|
1027
|
-
|
|
1028
|
-
|
|
1013
|
+
if (typeof window < "u")
|
|
1014
|
+
try {
|
|
1015
|
+
window.sessionStorage.setItem("leadCaptureAskFor", n);
|
|
1016
|
+
} catch {
|
|
1017
|
+
}
|
|
1018
|
+
rt(n || null);
|
|
1019
|
+
} else if (i || e.ask_for === null || e.lead_capture && e.lead_capture.ask_for === null || e.ask_for === "none") {
|
|
1020
|
+
if (typeof window < "u")
|
|
1021
|
+
try {
|
|
1022
|
+
window.sessionStorage.removeItem("leadCaptureAskFor");
|
|
1023
|
+
} catch {
|
|
1024
|
+
}
|
|
1025
|
+
rt(null);
|
|
1026
|
+
}
|
|
1029
1027
|
e.collected, e.valid;
|
|
1030
|
-
},
|
|
1031
|
-
const
|
|
1032
|
-
if (!
|
|
1033
|
-
if (
|
|
1028
|
+
}, xt = (e) => {
|
|
1029
|
+
const t = e.trim();
|
|
1030
|
+
if (!t) return null;
|
|
1031
|
+
if (t.startsWith("{"))
|
|
1034
1032
|
try {
|
|
1035
|
-
return JSON.parse(
|
|
1033
|
+
return JSON.parse(t);
|
|
1036
1034
|
} catch {
|
|
1037
1035
|
return null;
|
|
1038
1036
|
}
|
|
1039
|
-
if (
|
|
1040
|
-
const r =
|
|
1041
|
-
return { [i]:
|
|
1037
|
+
if (t.includes(":")) {
|
|
1038
|
+
const r = t.split(":"), i = r[0].trim().toLowerCase(), n = r.slice(1).join(":").trim();
|
|
1039
|
+
return { [i]: n };
|
|
1042
1040
|
}
|
|
1043
1041
|
return null;
|
|
1044
|
-
},
|
|
1045
|
-
}, []),
|
|
1046
|
-
for (;
|
|
1042
|
+
}, Ve = at(() => {
|
|
1043
|
+
}, []), pe = "§", ie = () => {
|
|
1044
|
+
for (; K.current.includes(`
|
|
1047
1045
|
`); ) {
|
|
1048
|
-
const e =
|
|
1049
|
-
`),
|
|
1050
|
-
|
|
1051
|
-
const r =
|
|
1052
|
-
r &&
|
|
1046
|
+
const e = K.current.indexOf(`
|
|
1047
|
+
`), t = K.current.slice(0, e).trim();
|
|
1048
|
+
K.current = K.current.slice(e + 1);
|
|
1049
|
+
const r = xt(t);
|
|
1050
|
+
r && _t(r);
|
|
1053
1051
|
}
|
|
1054
|
-
},
|
|
1055
|
-
if (
|
|
1056
|
-
if (e.includes(
|
|
1057
|
-
const
|
|
1058
|
-
r && (
|
|
1059
|
-
} else e ===
|
|
1060
|
-
else if (e.includes(
|
|
1061
|
-
const
|
|
1062
|
-
|
|
1063
|
-
} else if (e ===
|
|
1064
|
-
|
|
1052
|
+
}, Bt = (e) => {
|
|
1053
|
+
if (E.current)
|
|
1054
|
+
if (e.includes(pe)) {
|
|
1055
|
+
const t = e.indexOf(pe), r = e.slice(0, t), i = e.slice(t + pe.length);
|
|
1056
|
+
r && (de.current += r, we((n) => n + r)), E.current = !1, i && (K.current += i, ie());
|
|
1057
|
+
} else e === pe ? E.current = !1 : (de.current += e, we((t) => t + e));
|
|
1058
|
+
else if (e.includes(pe)) {
|
|
1059
|
+
const t = e.indexOf(pe), r = e.slice(0, t), i = e.slice(t + pe.length);
|
|
1060
|
+
K.current += r, ie(), E.current = !0, i && (de.current += i, we((n) => n + i));
|
|
1061
|
+
} else if (e === pe) {
|
|
1062
|
+
E.current = !0;
|
|
1065
1063
|
return;
|
|
1066
1064
|
} else
|
|
1067
|
-
|
|
1065
|
+
K.current += e, ie();
|
|
1068
1066
|
};
|
|
1069
|
-
|
|
1067
|
+
B(() => {
|
|
1070
1068
|
(async () => {
|
|
1071
1069
|
if (!sessionStorage.getItem(
|
|
1072
1070
|
"STREAMOJI_LEADS_SESSION_LEAD_ID"
|
|
1073
1071
|
)) {
|
|
1074
|
-
const
|
|
1072
|
+
const n = "secret", s = Math.floor(Date.now() / 1e3).toString();
|
|
1075
1073
|
try {
|
|
1076
|
-
const f = new TextEncoder(),
|
|
1074
|
+
const f = new TextEncoder(), _ = await globalThis.crypto.subtle.importKey(
|
|
1077
1075
|
"raw",
|
|
1078
|
-
f.encode(
|
|
1076
|
+
f.encode(n),
|
|
1079
1077
|
{ name: "HMAC", hash: "SHA-256" },
|
|
1080
1078
|
!1,
|
|
1081
1079
|
["sign"]
|
|
1082
|
-
),
|
|
1080
|
+
), v = await globalThis.crypto.subtle.sign(
|
|
1083
1081
|
"HMAC",
|
|
1084
|
-
|
|
1082
|
+
_,
|
|
1085
1083
|
f.encode(s)
|
|
1086
|
-
),
|
|
1087
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
1084
|
+
), R = Array.from(new Uint8Array(v)).map((C) => C.toString(16).padStart(2, "0")).join("");
|
|
1085
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", R), N("[SESSION] New HMAC UID generated and saved:", R);
|
|
1088
1086
|
} catch (f) {
|
|
1089
1087
|
console.error("[SESSION] HMAC generation failed:", f);
|
|
1090
|
-
const
|
|
1091
|
-
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID",
|
|
1088
|
+
const _ = Math.random().toString(36) + Date.now().toString();
|
|
1089
|
+
sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", _);
|
|
1092
1090
|
}
|
|
1093
1091
|
}
|
|
1094
1092
|
const r = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES");
|
|
@@ -1099,7 +1097,7 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1099
1097
|
} catch {
|
|
1100
1098
|
i = [];
|
|
1101
1099
|
}
|
|
1102
|
-
i.length === 0 &&
|
|
1100
|
+
i.length === 0 && S && (S.name || S.email) ? (i = [{ role: "user", content: `PRESET_USER_DETAILS: Name is "${S.name || ""}" , Email is "${S.email || ""}"` }], sessionStorage.setItem(
|
|
1103
1101
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
1104
1102
|
JSON.stringify(i)
|
|
1105
1103
|
)) : r || sessionStorage.setItem(
|
|
@@ -1107,21 +1105,21 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1107
1105
|
JSON.stringify([])
|
|
1108
1106
|
);
|
|
1109
1107
|
})();
|
|
1110
|
-
}, [
|
|
1108
|
+
}, [S]), B(() => {
|
|
1111
1109
|
const e = () => {
|
|
1112
|
-
|
|
1110
|
+
mt.current = Date.now(), me.current && (me.current = !1, fe(!1), F([]), Y(""), we(""), z(!1));
|
|
1113
1111
|
};
|
|
1114
1112
|
window.addEventListener("mousemove", e), window.addEventListener("keydown", e), window.addEventListener("mousedown", e), window.addEventListener("touchstart", e);
|
|
1115
|
-
const
|
|
1116
|
-
if (Date.now() -
|
|
1117
|
-
if (me.current = !0,
|
|
1118
|
-
|
|
1113
|
+
const t = setInterval(async () => {
|
|
1114
|
+
if (Date.now() - mt.current >= 3e4 && !D && !ce && H === "Ready" && !me.current)
|
|
1115
|
+
if (me.current = !0, Be.current.length > 0)
|
|
1116
|
+
fe(!0), F(Be.current);
|
|
1119
1117
|
else
|
|
1120
1118
|
try {
|
|
1121
|
-
const
|
|
1119
|
+
const n = `${ct}/nudgeUser`, s = {
|
|
1122
1120
|
navigationUrl: window.location.href,
|
|
1123
|
-
agentId:
|
|
1124
|
-
}, f = await fetch(
|
|
1121
|
+
agentId: w
|
|
1122
|
+
}, f = await fetch(n, {
|
|
1125
1123
|
method: "POST",
|
|
1126
1124
|
headers: {
|
|
1127
1125
|
"Content-Type": "application/json"
|
|
@@ -1129,35 +1127,35 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1129
1127
|
body: JSON.stringify(s)
|
|
1130
1128
|
});
|
|
1131
1129
|
if (f.ok) {
|
|
1132
|
-
const
|
|
1133
|
-
|
|
1130
|
+
const v = (await f.json()).nudge_questions;
|
|
1131
|
+
v && v.length > 0 && (N("[NUDGE] Received nudge questions from API:", v), Be.current = v, fe(!0), F(v));
|
|
1134
1132
|
}
|
|
1135
|
-
} catch (
|
|
1136
|
-
console.error("[NUDGE] Error calling /nudgeUser:",
|
|
1133
|
+
} catch (n) {
|
|
1134
|
+
console.error("[NUDGE] Error calling /nudgeUser:", n), me.current = !1;
|
|
1137
1135
|
}
|
|
1138
1136
|
}, 1e3);
|
|
1139
1137
|
return () => {
|
|
1140
|
-
window.removeEventListener("mousemove", e), window.removeEventListener("keydown", e), window.removeEventListener("mousedown", e), window.removeEventListener("touchstart", e), clearInterval(
|
|
1138
|
+
window.removeEventListener("mousemove", e), window.removeEventListener("keydown", e), window.removeEventListener("mousedown", e), window.removeEventListener("touchstart", e), clearInterval(t);
|
|
1141
1139
|
};
|
|
1142
|
-
}, [
|
|
1140
|
+
}, [et, D, ce, H]), B(() => {
|
|
1143
1141
|
if (A.length === 0) return;
|
|
1144
|
-
let e = 0,
|
|
1145
|
-
const
|
|
1142
|
+
let e = 0, t = 0, r = !1, i = 100;
|
|
1143
|
+
const n = () => {
|
|
1146
1144
|
const s = A[e];
|
|
1147
1145
|
if (r) {
|
|
1148
|
-
const f = s.substring(0,
|
|
1149
|
-
Y(f),
|
|
1146
|
+
const f = s.substring(0, t - 1);
|
|
1147
|
+
Y(f), t--, i = 50;
|
|
1150
1148
|
} else {
|
|
1151
|
-
const f = s.substring(0,
|
|
1152
|
-
Y(f),
|
|
1149
|
+
const f = s.substring(0, t + 1);
|
|
1150
|
+
Y(f), t++, i = 100;
|
|
1153
1151
|
}
|
|
1154
|
-
!r &&
|
|
1152
|
+
!r && t === s.length ? (r = !0, i = 3e3) : r && t === 0 && (r = !1, e = (e + 1) % A.length, i = 500), X.current = setTimeout(n, i);
|
|
1155
1153
|
};
|
|
1156
|
-
return
|
|
1154
|
+
return n(), () => {
|
|
1157
1155
|
X.current && clearTimeout(X.current);
|
|
1158
1156
|
};
|
|
1159
1157
|
}, [A]);
|
|
1160
|
-
const
|
|
1158
|
+
const $t = () => {
|
|
1161
1159
|
try {
|
|
1162
1160
|
return JSON.parse(
|
|
1163
1161
|
sessionStorage.getItem("STREAMOJI_LEADS_SESSION_MESSAGES") || "[]"
|
|
@@ -1170,169 +1168,171 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1170
1168
|
"STREAMOJI_LEADS_SESSION_MESSAGES",
|
|
1171
1169
|
JSON.stringify(e)
|
|
1172
1170
|
);
|
|
1173
|
-
}, [
|
|
1171
|
+
}, [Tt, Mt] = k(!1), [Vt, At] = k(0), Le = a(null), wt = a([]), Wt = a(0), [Ht, dn] = k(
|
|
1174
1172
|
null
|
|
1175
|
-
), [
|
|
1173
|
+
), [fn, Et] = k(
|
|
1176
1174
|
null
|
|
1177
|
-
),
|
|
1175
|
+
), Me = a(null), Qe = a(
|
|
1178
1176
|
null
|
|
1179
|
-
),
|
|
1180
|
-
e && (
|
|
1177
|
+
), pt = at((e = !1) => {
|
|
1178
|
+
e && (Ne.current = !0, m(!1), g("Ready")), Ie.current = [], Ee.current = [], He.current = !1, z(!1), De.current = 0, je.current = 0, he.current = 0, Oe.current.forEach((t) => {
|
|
1181
1179
|
try {
|
|
1182
|
-
|
|
1180
|
+
t.stop();
|
|
1183
1181
|
} catch {
|
|
1184
1182
|
}
|
|
1185
|
-
}),
|
|
1186
|
-
|
|
1183
|
+
}), Re.current && (clearTimeout(Re.current), Re.current = null), setTimeout(() => {
|
|
1184
|
+
ze(null), re("");
|
|
1185
|
+
}, 10), Oe.current = [];
|
|
1186
|
+
}, []), hn = async () => {
|
|
1187
1187
|
try {
|
|
1188
|
-
const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }),
|
|
1189
|
-
|
|
1188
|
+
const e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = window.AudioContext || window.webkitAudioContext, r = new t(), i = r.createMediaStreamSource(e), n = r.createAnalyser();
|
|
1189
|
+
n.fftSize = 64, i.connect(n), Me.current = r, Qe.current = i, Et(n);
|
|
1190
1190
|
const s = new MediaRecorder(e);
|
|
1191
|
-
|
|
1192
|
-
f.data.size > 0 &&
|
|
1191
|
+
Le.current = s, wt.current = [], s.ondataavailable = (f) => {
|
|
1192
|
+
f.data.size > 0 && wt.current.push(f.data);
|
|
1193
1193
|
}, s.onstop = async () => {
|
|
1194
|
-
const f = Date.now() -
|
|
1195
|
-
if (
|
|
1196
|
-
|
|
1194
|
+
const f = Date.now() - Wt.current;
|
|
1195
|
+
if (Et(null), Qe.current && (Qe.current.disconnect(), Qe.current = null), Me.current && Me.current.state !== "closed" && (Me.current.close(), Me.current = null), f < 1e3) {
|
|
1196
|
+
g("Recording too short. Hold or click longer."), m(!1);
|
|
1197
1197
|
return;
|
|
1198
1198
|
}
|
|
1199
|
-
const
|
|
1199
|
+
const _ = new Blob(wt.current, {
|
|
1200
1200
|
type: "audio/wav"
|
|
1201
1201
|
});
|
|
1202
|
-
await bn(
|
|
1203
|
-
},
|
|
1202
|
+
await bn(_);
|
|
1203
|
+
}, Wt.current = Date.now(), s.start(100), Mt(!0), g("Listening...");
|
|
1204
1204
|
} catch (e) {
|
|
1205
|
-
console.error("Error accessing microphone:", e),
|
|
1205
|
+
console.error("Error accessing microphone:", e), g("Mic Access Error");
|
|
1206
1206
|
}
|
|
1207
1207
|
}, mn = () => {
|
|
1208
|
-
|
|
1208
|
+
Le.current && Le.current.state !== "inactive" && (Le.current.stop(), Le.current.stream.getTracks().forEach((e) => e.stop()), Mt(!1));
|
|
1209
1209
|
}, pn = () => {
|
|
1210
|
-
|
|
1210
|
+
Le.current && Le.current.state !== "inactive" && (Le.current.onstop = null, Le.current.stop(), Le.current.stream.getTracks().forEach((e) => e.stop()), Et(null), Qe.current && (Qe.current.disconnect(), Qe.current = null), Me.current && Me.current.state !== "closed" && (Me.current.close(), Me.current = null), Mt(!1), wt.current = [], g("Ready"));
|
|
1211
1211
|
};
|
|
1212
|
-
|
|
1213
|
-
if (!
|
|
1212
|
+
B(() => {
|
|
1213
|
+
if (!D) return;
|
|
1214
1214
|
const e = () => {
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1217
|
-
const r =
|
|
1215
|
+
const t = he.current;
|
|
1216
|
+
if (t <= 0) return;
|
|
1217
|
+
const r = ye.current, i = De.current;
|
|
1218
1218
|
if (!r) return;
|
|
1219
|
-
const
|
|
1220
|
-
if (
|
|
1221
|
-
const
|
|
1222
|
-
Math.round(s /
|
|
1223
|
-
|
|
1219
|
+
const n = r.currentTime - i, s = Math.min(Math.max(0, n), t), _ = cn(O).trim().length;
|
|
1220
|
+
if (_ <= 0) return;
|
|
1221
|
+
const v = Math.min(
|
|
1222
|
+
Math.round(s / t * _),
|
|
1223
|
+
_
|
|
1224
1224
|
);
|
|
1225
|
-
|
|
1225
|
+
lt(v);
|
|
1226
1226
|
};
|
|
1227
|
-
return clearInterval(
|
|
1228
|
-
}, [
|
|
1227
|
+
return clearInterval(b.current ?? void 0), b.current = setInterval(e, 90), () => clearInterval(b.current ?? void 0);
|
|
1228
|
+
}, [D, O, he.current]), B(() => {
|
|
1229
1229
|
let e;
|
|
1230
|
-
return
|
|
1231
|
-
|
|
1232
|
-
}, 1e3)) :
|
|
1233
|
-
}, [
|
|
1230
|
+
return Tt ? (At(0), e = window.setInterval(() => {
|
|
1231
|
+
At((t) => t + 1);
|
|
1232
|
+
}, 1e3)) : At(0), () => clearInterval(e);
|
|
1233
|
+
}, [Tt]);
|
|
1234
1234
|
const gn = (e) => {
|
|
1235
|
-
const
|
|
1235
|
+
const t = e.numberOfChannels, r = e.length * t * 2 + 44, i = new ArrayBuffer(r), n = new DataView(i);
|
|
1236
1236
|
let s = 0;
|
|
1237
|
-
const f = (
|
|
1238
|
-
|
|
1239
|
-
},
|
|
1240
|
-
|
|
1237
|
+
const f = (R) => {
|
|
1238
|
+
n.setUint16(s, R, !0), s += 2;
|
|
1239
|
+
}, _ = (R) => {
|
|
1240
|
+
n.setUint32(s, R, !0), s += 4;
|
|
1241
1241
|
};
|
|
1242
|
-
|
|
1243
|
-
const
|
|
1244
|
-
for (let
|
|
1245
|
-
let
|
|
1242
|
+
_(1179011410), _(r - 8), _(1163280727), _(544501094), _(16), f(1), f(t), _(e.sampleRate), _(e.sampleRate * 2 * t), f(t * 2), f(16), _(1635017060), _(r - s - 4);
|
|
1243
|
+
const v = [];
|
|
1244
|
+
for (let R = 0; R < t; R++) v.push(e.getChannelData(R));
|
|
1245
|
+
let M = 0;
|
|
1246
1246
|
for (; s < r; ) {
|
|
1247
|
-
for (let
|
|
1248
|
-
let C = Math.max(-1, Math.min(1,
|
|
1249
|
-
C = C < 0 ? C * 32768 : C * 32767,
|
|
1247
|
+
for (let R = 0; R < t; R++) {
|
|
1248
|
+
let C = Math.max(-1, Math.min(1, v[R][M]));
|
|
1249
|
+
C = C < 0 ? C * 32768 : C * 32767, n.setInt16(s, C, !0), s += 2;
|
|
1250
1250
|
}
|
|
1251
|
-
|
|
1251
|
+
M++;
|
|
1252
1252
|
}
|
|
1253
1253
|
return new Blob([i], { type: "audio/wav" });
|
|
1254
|
-
},
|
|
1255
|
-
if (!
|
|
1254
|
+
}, It = async (e, t, r = !1) => {
|
|
1255
|
+
if (!Ne.current) {
|
|
1256
1256
|
if (V.current) {
|
|
1257
1257
|
Ee.current.push({
|
|
1258
1258
|
audio: e,
|
|
1259
|
-
visemes:
|
|
1259
|
+
visemes: t,
|
|
1260
1260
|
isNewSegment: r
|
|
1261
1261
|
});
|
|
1262
1262
|
return;
|
|
1263
1263
|
}
|
|
1264
1264
|
V.current = !0;
|
|
1265
1265
|
try {
|
|
1266
|
-
const i = window.AudioContext || window.webkitAudioContext,
|
|
1267
|
-
|
|
1266
|
+
const i = window.AudioContext || window.webkitAudioContext, n = ye.current ?? new i();
|
|
1267
|
+
n.state === "suspended" && await n.resume(), ye.current = n;
|
|
1268
1268
|
const s = window.atob(e), f = new Uint8Array(s.length);
|
|
1269
|
-
for (let
|
|
1270
|
-
f[
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1273
|
-
const
|
|
1274
|
-
let
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
const C =
|
|
1278
|
-
C.buffer =
|
|
1279
|
-
let Z =
|
|
1280
|
-
if ((!Z || Z.context !==
|
|
1281
|
-
|
|
1269
|
+
for (let W = 0; W < s.length; W++)
|
|
1270
|
+
f[W] = s.charCodeAt(W);
|
|
1271
|
+
const _ = await n.decodeAudioData(f.buffer.slice(0));
|
|
1272
|
+
he.current += _.duration;
|
|
1273
|
+
const v = n.currentTime;
|
|
1274
|
+
let M = je.current;
|
|
1275
|
+
const R = !He.current;
|
|
1276
|
+
M < v && (M = v + 0.1), je.current = M + _.duration;
|
|
1277
|
+
const C = n.createBufferSource();
|
|
1278
|
+
C.buffer = _;
|
|
1279
|
+
let Z = Ht;
|
|
1280
|
+
if ((!Z || Z.context !== n) && (Z = n.createAnalyser(), Z.fftSize = 64, Z.connect(n.destination), dn(Z)), C.connect(Z), Oe.current.push(C), Ne.current) {
|
|
1281
|
+
Oe.current = Oe.current.filter((W) => W !== C);
|
|
1282
1282
|
return;
|
|
1283
1283
|
}
|
|
1284
|
-
if (
|
|
1285
|
-
|
|
1286
|
-
`[AUDIO] setIsSpeaking(true) - First chunk starting at ${
|
|
1284
|
+
if (R) {
|
|
1285
|
+
He.current = !0, z(!0), N(
|
|
1286
|
+
`[AUDIO] setIsSpeaking(true) - First chunk starting at ${M.toFixed(
|
|
1287
1287
|
3
|
|
1288
1288
|
)}`
|
|
1289
|
-
), De.current =
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
`[AUDIO] Response started. Initial startTime: ${
|
|
1289
|
+
), De.current = M;
|
|
1290
|
+
const W = (M - v) * 1e3;
|
|
1291
|
+
tt.current = performance.now() + W, N(
|
|
1292
|
+
`[AUDIO] Response started. Initial startTime: ${M.toFixed(
|
|
1293
1293
|
3
|
|
1294
|
-
)}, CT: ${
|
|
1294
|
+
)}, CT: ${v.toFixed(3)}`
|
|
1295
1295
|
);
|
|
1296
1296
|
}
|
|
1297
|
-
C.start(
|
|
1298
|
-
const
|
|
1299
|
-
r && (
|
|
1300
|
-
`[AUDIO] New segment detected at +${
|
|
1297
|
+
C.start(M);
|
|
1298
|
+
const se = (M - De.current) * 1e3;
|
|
1299
|
+
r && (Ce.current = se, N(
|
|
1300
|
+
`[AUDIO] New segment detected at +${se.toFixed(
|
|
1301
1301
|
0
|
|
1302
1302
|
)}ms. Resetting segment offset.`
|
|
1303
|
-
)),
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1306
|
-
const
|
|
1307
|
-
|
|
1308
|
-
`[AUDIO] Viseme "${
|
|
1303
|
+
)), t.forEach((W, ge) => {
|
|
1304
|
+
const P = W.symbol ?? "";
|
|
1305
|
+
if (P) {
|
|
1306
|
+
const be = zn(P), Se = Math.round(W.start * 1e3), Xe = Math.round((W.duration ?? 0) * 1e3), Yt = Ce.current + Se;
|
|
1307
|
+
ge < 3 && N(
|
|
1308
|
+
`[AUDIO] Viseme "${P}": segment_relative=${Se}ms, segment_offset=${Ce.current.toFixed(
|
|
1309
1309
|
0
|
|
1310
|
-
)}ms => vtime=${
|
|
1311
|
-
),
|
|
1310
|
+
)}ms => vtime=${Yt}ms`
|
|
1311
|
+
), be.forEach((Kt) => {
|
|
1312
1312
|
Ie.current.push({
|
|
1313
|
-
viseme:
|
|
1314
|
-
weight:
|
|
1315
|
-
vtime:
|
|
1316
|
-
vduration:
|
|
1313
|
+
viseme: Kt.v,
|
|
1314
|
+
weight: Kt.w,
|
|
1315
|
+
vtime: Yt,
|
|
1316
|
+
vduration: Xe
|
|
1317
1317
|
});
|
|
1318
1318
|
});
|
|
1319
1319
|
}
|
|
1320
|
-
}),
|
|
1320
|
+
}), g("Speaking...");
|
|
1321
1321
|
} finally {
|
|
1322
1322
|
if (V.current = !1, Ee.current.length > 0) {
|
|
1323
1323
|
const i = Ee.current.shift();
|
|
1324
|
-
i &&
|
|
1324
|
+
i && It(i.audio, i.visemes, i.isNewSegment);
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
1327
|
}
|
|
1328
1328
|
}, bn = async (e) => {
|
|
1329
1329
|
try {
|
|
1330
|
-
m(!0),
|
|
1331
|
-
const
|
|
1332
|
-
s.readAsDataURL(
|
|
1330
|
+
m(!0), fe(!1), de.current = "", we(""), g("Processing Voice...");
|
|
1331
|
+
const t = await e.arrayBuffer(), i = await new (window.AudioContext || window.webkitAudioContext)().decodeAudioData(t), n = gn(i), s = new FileReader();
|
|
1332
|
+
s.readAsDataURL(n), s.onloadend = async () => {
|
|
1333
1333
|
const f = s.result.split(",")[1];
|
|
1334
|
-
|
|
1335
|
-
const
|
|
1334
|
+
pt(), ae(""), K.current = "", E.current = !1;
|
|
1335
|
+
const _ = `${ct}/stt?token=${encodeURIComponent(et)}`, v = await fetch(_, {
|
|
1336
1336
|
method: "POST",
|
|
1337
1337
|
headers: { "Content-Type": "application/json" },
|
|
1338
1338
|
body: JSON.stringify({
|
|
@@ -1340,55 +1340,55 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1340
1340
|
audio_format: "wav"
|
|
1341
1341
|
})
|
|
1342
1342
|
});
|
|
1343
|
-
if (
|
|
1343
|
+
if (v.status === 429) {
|
|
1344
1344
|
try {
|
|
1345
|
-
const
|
|
1346
|
-
N("[STT] 429 agent at capacity:",
|
|
1345
|
+
const ge = await v.text(), P = JSON.parse(ge);
|
|
1346
|
+
N("[STT] 429 agent at capacity:", P?.detail);
|
|
1347
1347
|
} catch {
|
|
1348
1348
|
}
|
|
1349
|
-
|
|
1349
|
+
ae(""), g("Busy"), m(!1);
|
|
1350
1350
|
return;
|
|
1351
1351
|
}
|
|
1352
|
-
if (!
|
|
1353
|
-
const
|
|
1354
|
-
let
|
|
1352
|
+
if (!v.ok) {
|
|
1353
|
+
const ge = await v.text();
|
|
1354
|
+
let P = "STT Failed";
|
|
1355
1355
|
try {
|
|
1356
|
-
|
|
1356
|
+
P = JSON.parse(ge).error || P;
|
|
1357
1357
|
} catch {
|
|
1358
|
-
|
|
1358
|
+
ge && (P = ge.slice(0, 200));
|
|
1359
1359
|
}
|
|
1360
|
-
throw new Error(
|
|
1360
|
+
throw new Error(P);
|
|
1361
1361
|
}
|
|
1362
|
-
const
|
|
1363
|
-
if (N("this is body" +
|
|
1364
|
-
|
|
1362
|
+
const M = v.body;
|
|
1363
|
+
if (N("this is body" + M), !M) {
|
|
1364
|
+
g("STT Failed"), m(!1);
|
|
1365
1365
|
return;
|
|
1366
1366
|
}
|
|
1367
|
-
const
|
|
1368
|
-
|
|
1367
|
+
const R = M.getReader();
|
|
1368
|
+
Ne.current = !1;
|
|
1369
1369
|
const C = new TextDecoder();
|
|
1370
|
-
let Z = "",
|
|
1371
|
-
const
|
|
1372
|
-
switch (
|
|
1370
|
+
let Z = "", se = !1;
|
|
1371
|
+
const W = async (ge, P) => {
|
|
1372
|
+
switch (ge) {
|
|
1373
1373
|
case "transcript":
|
|
1374
|
-
|
|
1374
|
+
P.transcript != null && ae(String(P.transcript));
|
|
1375
1375
|
break;
|
|
1376
1376
|
case "text": {
|
|
1377
|
-
const
|
|
1378
|
-
|
|
1377
|
+
const be = P.delta ?? P.text ?? "";
|
|
1378
|
+
be && Bt(be);
|
|
1379
1379
|
break;
|
|
1380
1380
|
}
|
|
1381
1381
|
case "audio": {
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1382
|
+
const be = P.chunk, Se = P.visemes ?? [], Xe = !!P.is_new_segment;
|
|
1383
|
+
be && await It(be, Se, Xe);
|
|
1384
1384
|
break;
|
|
1385
1385
|
}
|
|
1386
1386
|
case "done": {
|
|
1387
|
-
|
|
1387
|
+
se = !0, g("Ready"), m(!1);
|
|
1388
1388
|
break;
|
|
1389
1389
|
}
|
|
1390
1390
|
case "error": {
|
|
1391
|
-
|
|
1391
|
+
se = !0, g("STT Failed"), m(!1);
|
|
1392
1392
|
break;
|
|
1393
1393
|
}
|
|
1394
1394
|
default:
|
|
@@ -1396,228 +1396,243 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1396
1396
|
}
|
|
1397
1397
|
};
|
|
1398
1398
|
for (; ; ) {
|
|
1399
|
-
const { done:
|
|
1400
|
-
|
|
1401
|
-
const
|
|
1399
|
+
const { done: ge, value: P } = await R.read();
|
|
1400
|
+
P && (Z += C.decode(P, { stream: !0 }));
|
|
1401
|
+
const be = Z.split(`
|
|
1402
1402
|
|
|
1403
1403
|
`);
|
|
1404
|
-
Z =
|
|
1405
|
-
for (const
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1404
|
+
Z = be.pop() ?? "";
|
|
1405
|
+
for (const Se of be) {
|
|
1406
|
+
const Xe = st(Se);
|
|
1407
|
+
Xe && await W(Xe.event, Xe.data);
|
|
1408
1408
|
}
|
|
1409
|
-
if (
|
|
1409
|
+
if (ge) {
|
|
1410
1410
|
if (Z.trim()) {
|
|
1411
|
-
const
|
|
1412
|
-
|
|
1411
|
+
const Se = st(Z.trim());
|
|
1412
|
+
Se && await W(Se.event, Se.data);
|
|
1413
1413
|
}
|
|
1414
|
-
|
|
1414
|
+
se || (g("Ready"), m(!1));
|
|
1415
1415
|
break;
|
|
1416
1416
|
}
|
|
1417
1417
|
}
|
|
1418
1418
|
};
|
|
1419
|
-
} catch (
|
|
1420
|
-
console.error("Audio Submission Error:",
|
|
1419
|
+
} catch (t) {
|
|
1420
|
+
console.error("Audio Submission Error:", t), g("STT Failed"), m(!1);
|
|
1421
1421
|
}
|
|
1422
1422
|
}, _n = async (e) => {
|
|
1423
|
-
e && e.preventDefault(),
|
|
1424
|
-
},
|
|
1425
|
-
const
|
|
1423
|
+
e && e.preventDefault(), fe(!1), de.current = "", we(""), !(!q || ce) && await wn(q);
|
|
1424
|
+
}, st = (e) => {
|
|
1425
|
+
const t = e.split(/\r?\n/);
|
|
1426
1426
|
let r = "", i = "";
|
|
1427
|
-
for (const s of
|
|
1427
|
+
for (const s of t)
|
|
1428
1428
|
s.startsWith("event:") ? r = s.slice(6).trim() : s.startsWith("data:") && (i = s.slice(5).trim());
|
|
1429
1429
|
if (!r) return null;
|
|
1430
|
-
let
|
|
1430
|
+
let n = {};
|
|
1431
1431
|
if (i)
|
|
1432
1432
|
try {
|
|
1433
|
-
|
|
1433
|
+
n = JSON.parse(i);
|
|
1434
1434
|
} catch {
|
|
1435
|
-
|
|
1435
|
+
n = { raw: i };
|
|
1436
1436
|
}
|
|
1437
|
-
return { event: r, data:
|
|
1438
|
-
},
|
|
1437
|
+
return { event: r, data: n };
|
|
1438
|
+
}, yt = (e, t) => {
|
|
1439
1439
|
switch (e) {
|
|
1440
1440
|
case "connected":
|
|
1441
|
-
|
|
1441
|
+
K.current = "", E.current = !1;
|
|
1442
1442
|
break;
|
|
1443
1443
|
case "text": {
|
|
1444
|
-
const r =
|
|
1445
|
-
r &&
|
|
1444
|
+
const r = t.delta ?? "";
|
|
1445
|
+
r && Bt(r);
|
|
1446
1446
|
break;
|
|
1447
1447
|
}
|
|
1448
1448
|
case "metadata": {
|
|
1449
|
-
|
|
1449
|
+
_t(t);
|
|
1450
1450
|
break;
|
|
1451
1451
|
}
|
|
1452
1452
|
case "audio": {
|
|
1453
|
-
const r =
|
|
1454
|
-
r &&
|
|
1453
|
+
const r = t.chunk, i = t.visemes ?? [], n = t.is_new_segment ?? !1;
|
|
1454
|
+
r && It(r, i, n);
|
|
1455
1455
|
break;
|
|
1456
1456
|
}
|
|
1457
1457
|
case "done": {
|
|
1458
|
-
const r =
|
|
1458
|
+
const r = $t(), i = de.current.trim(), n = [
|
|
1459
1459
|
...r,
|
|
1460
1460
|
{ role: "user", content: q || "..." },
|
|
1461
1461
|
{ role: "assistant", content: i }
|
|
1462
1462
|
];
|
|
1463
|
-
ln(
|
|
1463
|
+
ln(n), bt.current = [...Ie.current], g("Ready"), m(!1), ae("");
|
|
1464
1464
|
break;
|
|
1465
1465
|
}
|
|
1466
1466
|
case "error": {
|
|
1467
|
-
const r =
|
|
1468
|
-
|
|
1467
|
+
const r = t.message ?? "Unknown error";
|
|
1468
|
+
de.current = r, we(r), g("Agent Failed"), m(!1);
|
|
1469
1469
|
break;
|
|
1470
1470
|
}
|
|
1471
1471
|
}
|
|
1472
|
-
},
|
|
1473
|
-
m(!0),
|
|
1472
|
+
}, jt = async (e, t) => {
|
|
1473
|
+
m(!0), g("Thinking..."), de.current = "", K.current = "", E.current = !1, pt(), he.current = 0, lt(0);
|
|
1474
1474
|
try {
|
|
1475
1475
|
const r = await fetch(e, {
|
|
1476
1476
|
method: "POST",
|
|
1477
1477
|
headers: { "Content-Type": "application/json" },
|
|
1478
|
-
body: JSON.stringify(
|
|
1478
|
+
body: JSON.stringify(t)
|
|
1479
1479
|
});
|
|
1480
1480
|
if (r.status === 429) {
|
|
1481
|
-
|
|
1481
|
+
g("Busy"), m(!1);
|
|
1482
1482
|
return;
|
|
1483
1483
|
}
|
|
1484
1484
|
if (!r.ok) throw new Error("Request failed");
|
|
1485
1485
|
const i = r.body;
|
|
1486
1486
|
if (!i) {
|
|
1487
|
-
|
|
1487
|
+
g("Failed"), m(!1);
|
|
1488
1488
|
return;
|
|
1489
1489
|
}
|
|
1490
|
-
const
|
|
1491
|
-
|
|
1490
|
+
const n = i.getReader();
|
|
1491
|
+
Ne.current = !1;
|
|
1492
1492
|
const s = new TextDecoder();
|
|
1493
1493
|
let f = "";
|
|
1494
1494
|
for (; ; ) {
|
|
1495
|
-
const { done:
|
|
1496
|
-
|
|
1497
|
-
const
|
|
1495
|
+
const { done: _, value: v } = await n.read();
|
|
1496
|
+
v && (f += s.decode(v, { stream: !0 }));
|
|
1497
|
+
const M = f.split(`
|
|
1498
1498
|
|
|
1499
1499
|
`);
|
|
1500
|
-
f =
|
|
1501
|
-
for (const
|
|
1502
|
-
const C =
|
|
1503
|
-
C &&
|
|
1500
|
+
f = M.pop() ?? "";
|
|
1501
|
+
for (const R of M) {
|
|
1502
|
+
const C = st(R);
|
|
1503
|
+
C && yt(C.event, C.data);
|
|
1504
1504
|
}
|
|
1505
|
-
if (
|
|
1505
|
+
if (_) {
|
|
1506
1506
|
if (f.trim()) {
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1507
|
+
const R = st(f.trim());
|
|
1508
|
+
R && yt(R.event, R.data);
|
|
1509
1509
|
}
|
|
1510
|
-
|
|
1510
|
+
g("Ready"), m(!1);
|
|
1511
1511
|
break;
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
} catch (r) {
|
|
1515
|
-
console.error("Streaming Error:", r),
|
|
1515
|
+
console.error("Streaming Error:", r), g("Failed"), m(!1);
|
|
1516
1516
|
}
|
|
1517
|
-
},
|
|
1518
|
-
const r = `${
|
|
1519
|
-
await
|
|
1520
|
-
}, []),
|
|
1521
|
-
const
|
|
1522
|
-
await
|
|
1523
|
-
}, []),
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
}, [
|
|
1517
|
+
}, Gt = at(async (e, t) => {
|
|
1518
|
+
const r = `${ct}/avatar_tts`;
|
|
1519
|
+
await jt(r, { user_query: e, llm_prompt: t });
|
|
1520
|
+
}, []), Jt = at(async (e, t, r, i) => {
|
|
1521
|
+
const n = `${ct}/avatar_ttsWithKnowledge`;
|
|
1522
|
+
await jt(n, { user_query: e, llm_prompt: t, knowledge: r, history: i });
|
|
1523
|
+
}, []), qt = a(!1);
|
|
1524
|
+
B(() => {
|
|
1525
|
+
y && !qt.current && (y({ avatarSpeak: Gt, avatarRespond: Jt }), qt.current = !0);
|
|
1526
|
+
}, [y, Gt, Jt]);
|
|
1527
1527
|
const wn = async (e) => {
|
|
1528
|
-
m(!0),
|
|
1529
|
-
const
|
|
1528
|
+
m(!0), g("Thinking..."), de.current = "", K.current = "", E.current = !1, pt(), he.current = 0, lt(0);
|
|
1529
|
+
const t = `${ct}/agent/chat?token=${encodeURIComponent(et)}`;
|
|
1530
1530
|
try {
|
|
1531
|
-
const r =
|
|
1531
|
+
const r = $t();
|
|
1532
1532
|
let i = sessionStorage.getItem("STREAMOJI_LEADS_SESSION_LEAD_ID");
|
|
1533
|
-
i || (
|
|
1533
|
+
i || (In(
|
|
1534
1534
|
"[CHAT] Session UID missing at send time! Generating emergency backup."
|
|
1535
1535
|
), i = "emergency-" + Math.random().toString(36).substring(7), sessionStorage.setItem("STREAMOJI_LEADS_SESSION_LEAD_ID", i));
|
|
1536
|
-
const
|
|
1536
|
+
const n = {
|
|
1537
1537
|
history: r,
|
|
1538
1538
|
question: e,
|
|
1539
1539
|
lead_id: i
|
|
1540
1540
|
};
|
|
1541
|
-
N("[CHAT] Sending payload:",
|
|
1542
|
-
const s = await fetch(
|
|
1541
|
+
N("[CHAT] Sending payload:", n);
|
|
1542
|
+
const s = await fetch(t, {
|
|
1543
1543
|
method: "POST",
|
|
1544
1544
|
headers: {
|
|
1545
1545
|
"Content-Type": "application/json"
|
|
1546
1546
|
},
|
|
1547
|
-
body: JSON.stringify(
|
|
1547
|
+
body: JSON.stringify(n),
|
|
1548
1548
|
cache: "default"
|
|
1549
1549
|
});
|
|
1550
1550
|
if (s.status === 429) {
|
|
1551
1551
|
try {
|
|
1552
|
-
const
|
|
1553
|
-
N("[CHAT] 429 agent at capacity:",
|
|
1552
|
+
const R = await s.json();
|
|
1553
|
+
N("[CHAT] 429 agent at capacity:", R?.detail);
|
|
1554
1554
|
} catch {
|
|
1555
1555
|
}
|
|
1556
|
-
|
|
1556
|
+
ae(""), g("Busy"), m(!1);
|
|
1557
1557
|
return;
|
|
1558
1558
|
}
|
|
1559
1559
|
if (!s.ok)
|
|
1560
1560
|
throw new Error("Agent request failed");
|
|
1561
1561
|
const f = s.body;
|
|
1562
1562
|
if (!f) {
|
|
1563
|
-
|
|
1563
|
+
g("Agent Failed"), m(!1);
|
|
1564
1564
|
return;
|
|
1565
1565
|
}
|
|
1566
|
-
const
|
|
1567
|
-
|
|
1568
|
-
const
|
|
1569
|
-
let
|
|
1566
|
+
const _ = f.getReader();
|
|
1567
|
+
Ne.current = !1;
|
|
1568
|
+
const v = new TextDecoder();
|
|
1569
|
+
let M = "";
|
|
1570
1570
|
for (; ; ) {
|
|
1571
|
-
const { done:
|
|
1571
|
+
const { done: R, value: C } = await _.read();
|
|
1572
1572
|
N(
|
|
1573
|
-
`[SSE] Chunk received. done=${
|
|
1574
|
-
), C && (
|
|
1575
|
-
const Z =
|
|
1573
|
+
`[SSE] Chunk received. done=${R}, length=${C?.length || 0}`
|
|
1574
|
+
), C && (M += v.decode(C, { stream: !0 }));
|
|
1575
|
+
const Z = M.split(`
|
|
1576
1576
|
|
|
1577
1577
|
`);
|
|
1578
|
-
|
|
1579
|
-
for (const
|
|
1580
|
-
N(`[SSE] Processing block: ${
|
|
1581
|
-
const
|
|
1582
|
-
|
|
1578
|
+
M = Z.pop() ?? "";
|
|
1579
|
+
for (const se of Z) {
|
|
1580
|
+
N(`[SSE] Processing block: ${se.slice(0, 50)}...`);
|
|
1581
|
+
const W = st(se);
|
|
1582
|
+
W && (N(`[SSE] Event: ${W.event}`), yt(W.event, W.data));
|
|
1583
1583
|
}
|
|
1584
|
-
if (
|
|
1585
|
-
if (N("[SSE] Stream finished"),
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1584
|
+
if (R) {
|
|
1585
|
+
if (N("[SSE] Stream finished"), M.trim()) {
|
|
1586
|
+
const se = st(M.trim());
|
|
1587
|
+
se && yt(se.event, se.data);
|
|
1588
1588
|
}
|
|
1589
|
-
|
|
1589
|
+
g("Ready"), m(!1), ae("");
|
|
1590
1590
|
break;
|
|
1591
1591
|
}
|
|
1592
1592
|
}
|
|
1593
1593
|
} catch (r) {
|
|
1594
|
-
console.error("Chat Error:", r),
|
|
1594
|
+
console.error("Chat Error:", r), g("Agent Failed"), m(!1);
|
|
1595
1595
|
}
|
|
1596
|
-
}, yn =
|
|
1596
|
+
}, yn = O.trim(), zt = cn(yn), Ot = zt && D ? zt.slice(
|
|
1597
1597
|
0,
|
|
1598
|
-
|
|
1598
|
+
nt != null && nt > 0 ? nt : 0
|
|
1599
1599
|
) : "";
|
|
1600
|
-
|
|
1601
|
-
const e =
|
|
1602
|
-
e !== "exiting"
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1600
|
+
B(() => {
|
|
1601
|
+
const e = ht.current;
|
|
1602
|
+
if (e !== "exiting") {
|
|
1603
|
+
if (Ot)
|
|
1604
|
+
Rt(Ot), e === "hidden" && Ke("entering");
|
|
1605
|
+
else if (e === "visible" || e === "entering") {
|
|
1606
|
+
if (!u && qe) {
|
|
1607
|
+
const t = qe;
|
|
1608
|
+
try {
|
|
1609
|
+
window.location.href = t;
|
|
1610
|
+
} catch {
|
|
1611
|
+
window.location.assign(t);
|
|
1612
|
+
}
|
|
1613
|
+
ze(null);
|
|
1614
|
+
}
|
|
1615
|
+
Ke("exiting");
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}, [Ot, le, u, qe]);
|
|
1619
|
+
const vn = at(() => {
|
|
1620
|
+
const e = ht.current;
|
|
1621
|
+
e === "entering" ? Ke("visible") : e === "exiting" && Ke("hidden");
|
|
1607
1622
|
}, []);
|
|
1608
|
-
|
|
1609
|
-
const e =
|
|
1623
|
+
Mn(() => {
|
|
1624
|
+
const e = Pe.current;
|
|
1610
1625
|
e && (e.scrollTop = e.scrollHeight);
|
|
1611
1626
|
}, [ft]);
|
|
1612
|
-
const Ln = G === "female" ? Vn :
|
|
1613
|
-
return
|
|
1614
|
-
/* @__PURE__ */
|
|
1615
|
-
|
|
1627
|
+
const Ln = G === "female" ? Vn : $n;
|
|
1628
|
+
return ut ? /* @__PURE__ */ _e("div", { className: "avatar-widget-container", children: [
|
|
1629
|
+
/* @__PURE__ */ _e("div", { className: "avatar-input-area", children: [
|
|
1630
|
+
Ue !== "hidden" ? /* @__PURE__ */ h(
|
|
1616
1631
|
"div",
|
|
1617
1632
|
{
|
|
1618
|
-
className: `avatar-thinking-tab${
|
|
1619
|
-
onAnimationEnd:
|
|
1620
|
-
children:
|
|
1633
|
+
className: `avatar-thinking-tab${Ue === "exiting" ? " avatar-thinking-tab--exiting" : Ue === "entering" ? " avatar-thinking-tab--entering" : ""}`,
|
|
1634
|
+
onAnimationEnd: Te,
|
|
1635
|
+
children: ot === sn ? /* @__PURE__ */ h(
|
|
1621
1636
|
"a",
|
|
1622
1637
|
{
|
|
1623
1638
|
href: "https://leads.streamoji.com",
|
|
@@ -1625,10 +1640,10 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1625
1640
|
rel: "noopener noreferrer",
|
|
1626
1641
|
children: "Made by Streamoji Leads"
|
|
1627
1642
|
}
|
|
1628
|
-
) :
|
|
1643
|
+
) : ot
|
|
1629
1644
|
}
|
|
1630
1645
|
) : null,
|
|
1631
|
-
/* @__PURE__ */
|
|
1646
|
+
/* @__PURE__ */ h("div", { className: "avatar-input-container", children: /* @__PURE__ */ h(
|
|
1632
1647
|
"div",
|
|
1633
1648
|
{
|
|
1634
1649
|
style: {
|
|
@@ -1637,15 +1652,15 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1637
1652
|
width: "100%",
|
|
1638
1653
|
height: "100%"
|
|
1639
1654
|
},
|
|
1640
|
-
children:
|
|
1641
|
-
/* @__PURE__ */
|
|
1655
|
+
children: Tt ? /* @__PURE__ */ _e("div", { className: "avatar-input-recording", children: [
|
|
1656
|
+
/* @__PURE__ */ h(
|
|
1642
1657
|
"button",
|
|
1643
1658
|
{
|
|
1644
1659
|
type: "button",
|
|
1645
1660
|
className: "avatar-recording-cancel",
|
|
1646
1661
|
onClick: pn,
|
|
1647
1662
|
title: "Cancel",
|
|
1648
|
-
children: /* @__PURE__ */
|
|
1663
|
+
children: /* @__PURE__ */ _e(
|
|
1649
1664
|
"svg",
|
|
1650
1665
|
{
|
|
1651
1666
|
width: "18",
|
|
@@ -1658,14 +1673,14 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1658
1673
|
strokeLinejoin: "round",
|
|
1659
1674
|
style: { display: "block" },
|
|
1660
1675
|
children: [
|
|
1661
|
-
/* @__PURE__ */
|
|
1662
|
-
/* @__PURE__ */
|
|
1676
|
+
/* @__PURE__ */ h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1677
|
+
/* @__PURE__ */ h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1663
1678
|
]
|
|
1664
1679
|
}
|
|
1665
1680
|
)
|
|
1666
1681
|
}
|
|
1667
1682
|
),
|
|
1668
|
-
/* @__PURE__ */
|
|
1683
|
+
/* @__PURE__ */ _e(
|
|
1669
1684
|
"div",
|
|
1670
1685
|
{
|
|
1671
1686
|
style: {
|
|
@@ -1677,8 +1692,8 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1677
1692
|
minWidth: 0
|
|
1678
1693
|
},
|
|
1679
1694
|
children: [
|
|
1680
|
-
/* @__PURE__ */
|
|
1681
|
-
/* @__PURE__ */
|
|
1695
|
+
/* @__PURE__ */ h("div", { style: { flex: 1, height: "100%" }, children: /* @__PURE__ */ h(Qt, { analyser: fn }) }),
|
|
1696
|
+
/* @__PURE__ */ _e(
|
|
1682
1697
|
"span",
|
|
1683
1698
|
{
|
|
1684
1699
|
style: {
|
|
@@ -1691,23 +1706,23 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1691
1706
|
fontVariantNumeric: "tabular-nums"
|
|
1692
1707
|
},
|
|
1693
1708
|
children: [
|
|
1694
|
-
Math.floor(
|
|
1709
|
+
Math.floor(Vt / 60),
|
|
1695
1710
|
":",
|
|
1696
|
-
String(
|
|
1711
|
+
String(Vt % 60).padStart(2, "0")
|
|
1697
1712
|
]
|
|
1698
1713
|
}
|
|
1699
1714
|
)
|
|
1700
1715
|
]
|
|
1701
1716
|
}
|
|
1702
1717
|
),
|
|
1703
|
-
/* @__PURE__ */
|
|
1718
|
+
/* @__PURE__ */ h(
|
|
1704
1719
|
"button",
|
|
1705
1720
|
{
|
|
1706
1721
|
type: "button",
|
|
1707
1722
|
className: "avatar-recording-confirm",
|
|
1708
1723
|
onClick: mn,
|
|
1709
1724
|
title: "Send",
|
|
1710
|
-
children: /* @__PURE__ */
|
|
1725
|
+
children: /* @__PURE__ */ h(
|
|
1711
1726
|
"svg",
|
|
1712
1727
|
{
|
|
1713
1728
|
width: "18",
|
|
@@ -1719,13 +1734,13 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1719
1734
|
strokeLinecap: "round",
|
|
1720
1735
|
strokeLinejoin: "round",
|
|
1721
1736
|
style: { display: "block" },
|
|
1722
|
-
children: /* @__PURE__ */
|
|
1737
|
+
children: /* @__PURE__ */ h("polyline", { points: "20 6 9 17 4 12" })
|
|
1723
1738
|
}
|
|
1724
1739
|
)
|
|
1725
1740
|
}
|
|
1726
1741
|
)
|
|
1727
|
-
] }) :
|
|
1728
|
-
/* @__PURE__ */
|
|
1742
|
+
] }) : D && !xe ? /* @__PURE__ */ _e("div", { className: "avatar-input-speaking", children: [
|
|
1743
|
+
/* @__PURE__ */ h(
|
|
1729
1744
|
"div",
|
|
1730
1745
|
{
|
|
1731
1746
|
style: {
|
|
@@ -1735,20 +1750,20 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1735
1750
|
alignItems: "center",
|
|
1736
1751
|
paddingRight: "8px"
|
|
1737
1752
|
},
|
|
1738
|
-
children: /* @__PURE__ */
|
|
1753
|
+
children: /* @__PURE__ */ h(Qt, { analyser: Ht })
|
|
1739
1754
|
}
|
|
1740
1755
|
),
|
|
1741
|
-
/* @__PURE__ */
|
|
1756
|
+
/* @__PURE__ */ h(
|
|
1742
1757
|
"button",
|
|
1743
1758
|
{
|
|
1744
1759
|
type: "button",
|
|
1745
1760
|
className: "avatar-speaking-stop",
|
|
1746
|
-
onClick: () =>
|
|
1761
|
+
onClick: () => pt(!0),
|
|
1747
1762
|
title: "Stop",
|
|
1748
|
-
children: /* @__PURE__ */
|
|
1763
|
+
children: /* @__PURE__ */ h("span", { className: "avatar-speaking-stop__icon", "aria-hidden": !0 })
|
|
1749
1764
|
}
|
|
1750
1765
|
)
|
|
1751
|
-
] }) :
|
|
1766
|
+
] }) : ce ? /* @__PURE__ */ h(
|
|
1752
1767
|
"div",
|
|
1753
1768
|
{
|
|
1754
1769
|
style: {
|
|
@@ -1758,9 +1773,9 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1758
1773
|
alignItems: "center",
|
|
1759
1774
|
justifyContent: "center"
|
|
1760
1775
|
},
|
|
1761
|
-
children: /* @__PURE__ */
|
|
1776
|
+
children: /* @__PURE__ */ h("div", { className: "avatar-input-loader" })
|
|
1762
1777
|
}
|
|
1763
|
-
) : /* @__PURE__ */
|
|
1778
|
+
) : /* @__PURE__ */ _e(
|
|
1764
1779
|
"form",
|
|
1765
1780
|
{
|
|
1766
1781
|
onSubmit: _n,
|
|
@@ -1771,20 +1786,20 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1771
1786
|
alignItems: "center"
|
|
1772
1787
|
},
|
|
1773
1788
|
children: [
|
|
1774
|
-
/* @__PURE__ */
|
|
1789
|
+
/* @__PURE__ */ h(
|
|
1775
1790
|
"input",
|
|
1776
1791
|
{
|
|
1777
1792
|
id: "avatar-text-input",
|
|
1778
1793
|
type: "text",
|
|
1779
1794
|
value: q,
|
|
1780
|
-
onChange: (e) =>
|
|
1781
|
-
placeholder: H === "Busy" ? "Assisting another user" :
|
|
1782
|
-
disabled:
|
|
1795
|
+
onChange: (e) => ae(e.target.value),
|
|
1796
|
+
placeholder: H === "Busy" ? "Assisting another user" : $ || "Ask me anything",
|
|
1797
|
+
disabled: ce || H === "Busy",
|
|
1783
1798
|
autoComplete: "off",
|
|
1784
1799
|
style: { width: "100%", height: "100%" }
|
|
1785
1800
|
}
|
|
1786
1801
|
),
|
|
1787
|
-
H === "Busy" ? /* @__PURE__ */
|
|
1802
|
+
H === "Busy" ? /* @__PURE__ */ h(
|
|
1788
1803
|
"button",
|
|
1789
1804
|
{
|
|
1790
1805
|
type: "button",
|
|
@@ -1792,7 +1807,7 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1792
1807
|
disabled: !0,
|
|
1793
1808
|
style: { backgroundColor: "#1e4a5e" },
|
|
1794
1809
|
title: "Agent at capacity",
|
|
1795
|
-
children: /* @__PURE__ */
|
|
1810
|
+
children: /* @__PURE__ */ h(
|
|
1796
1811
|
"svg",
|
|
1797
1812
|
{
|
|
1798
1813
|
width: "24",
|
|
@@ -1801,7 +1816,7 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1801
1816
|
fill: "none",
|
|
1802
1817
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1803
1818
|
"aria-hidden": "true",
|
|
1804
|
-
children: /* @__PURE__ */
|
|
1819
|
+
children: /* @__PURE__ */ h(
|
|
1805
1820
|
"path",
|
|
1806
1821
|
{
|
|
1807
1822
|
d: "M4 2L20 2L12 10L4 2z M12 14L4 22L20 22L12 14z",
|
|
@@ -1811,15 +1826,15 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1811
1826
|
}
|
|
1812
1827
|
)
|
|
1813
1828
|
}
|
|
1814
|
-
) : q.trim() === "" ? /* @__PURE__ */
|
|
1829
|
+
) : q.trim() === "" ? /* @__PURE__ */ h(
|
|
1815
1830
|
"button",
|
|
1816
1831
|
{
|
|
1817
1832
|
type: "button",
|
|
1818
1833
|
className: "mic-button",
|
|
1819
|
-
onClick:
|
|
1820
|
-
disabled:
|
|
1834
|
+
onClick: hn,
|
|
1835
|
+
disabled: ce,
|
|
1821
1836
|
style: { backgroundColor: "#1e4a5e" },
|
|
1822
|
-
children: /* @__PURE__ */
|
|
1837
|
+
children: /* @__PURE__ */ _e(
|
|
1823
1838
|
"svg",
|
|
1824
1839
|
{
|
|
1825
1840
|
width: "28",
|
|
@@ -1828,14 +1843,14 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1828
1843
|
fill: "none",
|
|
1829
1844
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1830
1845
|
children: [
|
|
1831
|
-
/* @__PURE__ */
|
|
1846
|
+
/* @__PURE__ */ h(
|
|
1832
1847
|
"path",
|
|
1833
1848
|
{
|
|
1834
1849
|
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",
|
|
1835
1850
|
fill: "white"
|
|
1836
1851
|
}
|
|
1837
1852
|
),
|
|
1838
|
-
/* @__PURE__ */
|
|
1853
|
+
/* @__PURE__ */ h(
|
|
1839
1854
|
"path",
|
|
1840
1855
|
{
|
|
1841
1856
|
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",
|
|
@@ -1846,15 +1861,15 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1846
1861
|
}
|
|
1847
1862
|
)
|
|
1848
1863
|
}
|
|
1849
|
-
) : /* @__PURE__ */
|
|
1864
|
+
) : /* @__PURE__ */ h(
|
|
1850
1865
|
"button",
|
|
1851
1866
|
{
|
|
1852
1867
|
type: "submit",
|
|
1853
1868
|
className: "mic-button",
|
|
1854
|
-
disabled:
|
|
1869
|
+
disabled: ce,
|
|
1855
1870
|
style: { backgroundColor: "#1e4a5e" },
|
|
1856
1871
|
title: "Send",
|
|
1857
|
-
children: /* @__PURE__ */
|
|
1872
|
+
children: /* @__PURE__ */ h(
|
|
1858
1873
|
"svg",
|
|
1859
1874
|
{
|
|
1860
1875
|
width: 24,
|
|
@@ -1862,7 +1877,7 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1862
1877
|
viewBox: "0 0 24 24",
|
|
1863
1878
|
fill: "none",
|
|
1864
1879
|
"aria-hidden": "true",
|
|
1865
|
-
children: /* @__PURE__ */
|
|
1880
|
+
children: /* @__PURE__ */ h(
|
|
1866
1881
|
"path",
|
|
1867
1882
|
{
|
|
1868
1883
|
d: "M19 12H5M19 12L14 17M19 12L14 7",
|
|
@@ -1882,21 +1897,21 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1882
1897
|
}
|
|
1883
1898
|
) })
|
|
1884
1899
|
] }),
|
|
1885
|
-
/* @__PURE__ */
|
|
1886
|
-
|
|
1900
|
+
/* @__PURE__ */ h("div", { className: "avatar-wrapper", children: /* @__PURE__ */ _e("div", { className: "avatar-scene-wrapper", children: [
|
|
1901
|
+
le !== "hidden" && /* @__PURE__ */ h(
|
|
1887
1902
|
"div",
|
|
1888
1903
|
{
|
|
1889
|
-
className: `avatar-bubble${
|
|
1890
|
-
onAnimationEnd:
|
|
1891
|
-
children: /* @__PURE__ */
|
|
1904
|
+
className: `avatar-bubble${le === "entering" ? " avatar-bubble--entering" : le === "exiting" ? " avatar-bubble--exiting" : ""}`,
|
|
1905
|
+
onAnimationEnd: vn,
|
|
1906
|
+
children: /* @__PURE__ */ h("div", { ref: Pe, className: `avatar-bubble__content${xe ? " avatar-bubble__content--nudge" : ""}`, children: ft })
|
|
1892
1907
|
}
|
|
1893
1908
|
),
|
|
1894
|
-
/* @__PURE__ */
|
|
1909
|
+
/* @__PURE__ */ h(
|
|
1895
1910
|
"div",
|
|
1896
1911
|
{
|
|
1897
1912
|
className: "avatar-canvas-layer",
|
|
1898
1913
|
style: { width: J, height: J },
|
|
1899
|
-
children: /* @__PURE__ */
|
|
1914
|
+
children: /* @__PURE__ */ _e(
|
|
1900
1915
|
Rn,
|
|
1901
1916
|
{
|
|
1902
1917
|
shadows: !0,
|
|
@@ -1905,29 +1920,29 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1905
1920
|
dpr: 1.8,
|
|
1906
1921
|
style: { pointerEvents: "none", width: "100%", height: "100%" },
|
|
1907
1922
|
children: [
|
|
1908
|
-
/* @__PURE__ */
|
|
1909
|
-
/* @__PURE__ */
|
|
1910
|
-
/* @__PURE__ */
|
|
1911
|
-
/* @__PURE__ */
|
|
1912
|
-
/* @__PURE__ */
|
|
1923
|
+
/* @__PURE__ */ h(Yn, { target: Ln }),
|
|
1924
|
+
/* @__PURE__ */ h("ambientLight", { intensity: 0.7 }),
|
|
1925
|
+
/* @__PURE__ */ h("directionalLight", { position: [0, 2, 2], intensity: 1 }),
|
|
1926
|
+
/* @__PURE__ */ h(Sn, { preset: "city" }),
|
|
1927
|
+
/* @__PURE__ */ h(An, { fallback: null, children: Ae !== null && /* @__PURE__ */ h(
|
|
1913
1928
|
Kn,
|
|
1914
1929
|
{
|
|
1915
1930
|
avatarUrl: Ae,
|
|
1916
|
-
isPlayingRef:
|
|
1931
|
+
isPlayingRef: He,
|
|
1917
1932
|
visemeQueueRef: Ie,
|
|
1918
|
-
audioContextRef:
|
|
1933
|
+
audioContextRef: ye,
|
|
1919
1934
|
responseAudioStartTimeRef: De,
|
|
1920
1935
|
adjustments: Bn,
|
|
1921
|
-
mood:
|
|
1922
|
-
expression:
|
|
1923
|
-
agentResponse:
|
|
1924
|
-
isSpeaking:
|
|
1925
|
-
nextStartTimeRef:
|
|
1926
|
-
stopPlayback:
|
|
1936
|
+
mood: p,
|
|
1937
|
+
expression: l,
|
|
1938
|
+
agentResponse: O,
|
|
1939
|
+
isSpeaking: D,
|
|
1940
|
+
nextStartTimeRef: je,
|
|
1941
|
+
stopPlayback: pt,
|
|
1927
1942
|
setIsSpeaking: z,
|
|
1928
|
-
expressionUrl:
|
|
1929
|
-
onExpressionFinished:
|
|
1930
|
-
isNudgeResponse:
|
|
1943
|
+
expressionUrl: ne,
|
|
1944
|
+
onExpressionFinished: Ve,
|
|
1945
|
+
isNudgeResponse: xe,
|
|
1931
1946
|
avatarGender: G
|
|
1932
1947
|
}
|
|
1933
1948
|
) })
|
|
@@ -1939,17 +1954,17 @@ const Ct = /* @__PURE__ */ new Map(), Xn = ({
|
|
|
1939
1954
|
] }) })
|
|
1940
1955
|
] }) : null;
|
|
1941
1956
|
}, or = ({
|
|
1942
|
-
agentId:
|
|
1943
|
-
onNavigationRequested:
|
|
1944
|
-
presetUserDetails:
|
|
1945
|
-
onAvatarReady:
|
|
1946
|
-
}) => /* @__PURE__ */
|
|
1957
|
+
agentId: u,
|
|
1958
|
+
onNavigationRequested: w,
|
|
1959
|
+
presetUserDetails: S,
|
|
1960
|
+
onAvatarReady: y
|
|
1961
|
+
}) => /* @__PURE__ */ h(
|
|
1947
1962
|
Xn,
|
|
1948
1963
|
{
|
|
1949
|
-
agentId:
|
|
1950
|
-
onNavigationRequested:
|
|
1951
|
-
presetUserDetails:
|
|
1952
|
-
onAvatarReady:
|
|
1964
|
+
agentId: u,
|
|
1965
|
+
onNavigationRequested: w,
|
|
1966
|
+
presetUserDetails: S,
|
|
1967
|
+
onAvatarReady: y
|
|
1953
1968
|
}
|
|
1954
1969
|
);
|
|
1955
1970
|
export {
|