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