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