@peerbots/face 0.0.0-stage → 0.2.0

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.
Files changed (50) hide show
  1. package/README.md +30 -2
  2. package/dist/VizijFaceView-DEMuLMAb.d.ts +63 -0
  3. package/dist/chunk-EAYBAWGE.js +1487 -0
  4. package/dist/chunk-EAYBAWGE.js.map +1 -0
  5. package/dist/chunk-QGFC2GUD.js +211 -0
  6. package/dist/chunk-QGFC2GUD.js.map +1 -0
  7. package/dist/chunk-ZEXL2QPJ.js +68 -0
  8. package/dist/chunk-ZEXL2QPJ.js.map +1 -0
  9. package/dist/index.cjs +4639 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.ts +557 -0
  12. package/dist/index.js +1660 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/pixi.cjs +2421 -0
  15. package/dist/pixi.cjs.map +1 -0
  16. package/dist/pixi.d.ts +33 -0
  17. package/dist/pixi.js +889 -0
  18. package/dist/pixi.js.map +1 -0
  19. package/dist/vizij.cjs +1556 -0
  20. package/dist/vizij.cjs.map +1 -0
  21. package/dist/vizij.d.ts +2 -0
  22. package/dist/vizij.js +193 -0
  23. package/dist/vizij.js.map +1 -0
  24. package/package.json +116 -4
  25. package/public/FaceAssets/Hugo/cheek.png +0 -0
  26. package/public/FaceAssets/Hugo/concerned_l.png +0 -0
  27. package/public/FaceAssets/Hugo/concerned_r.png +0 -0
  28. package/public/FaceAssets/Hugo/happy_l.png +0 -0
  29. package/public/FaceAssets/Hugo/happy_r.png +0 -0
  30. package/public/FaceAssets/Hugo/hugo_spritesheet.json +97 -0
  31. package/public/FaceAssets/Hugo/hugo_spritesheet.png +0 -0
  32. package/public/FaceAssets/Hugo/neutral_l.png +0 -0
  33. package/public/FaceAssets/Hugo/neutral_r.png +0 -0
  34. package/public/FaceAssets/Hugo/sad_l.png +0 -0
  35. package/public/FaceAssets/Hugo/sad_r.png +0 -0
  36. package/public/FaceAssets/Hugo/sleepy_l.png +0 -0
  37. package/public/FaceAssets/Hugo/sleepy_r.png +0 -0
  38. package/public/FaceAssets/Hugo/surprised_l.png +0 -0
  39. package/public/FaceAssets/Hugo/surprised_r.png +0 -0
  40. package/public/FaceAssets/Icons/Concerned.png +0 -0
  41. package/public/FaceAssets/Icons/Neutral.png +0 -0
  42. package/public/FaceAssets/Icons/Sad.png +0 -0
  43. package/public/FaceAssets/Icons/Sleep.png +0 -0
  44. package/public/FaceAssets/Icons/Surprised.png +0 -0
  45. package/public/FaceAssets/Misty/misty_spritesheet.json +97 -0
  46. package/public/FaceAssets/Misty/misty_spritesheet.png +0 -0
  47. package/public/FaceAssets/Robotic/robotic_spritesheet.json +97 -0
  48. package/public/FaceAssets/Robotic/robotic_spritesheet.png +0 -0
  49. package/public/FaceAssets/Vizij/Hugo.glb +0 -0
  50. package/public/FaceAssets/Vizij/brand.svg +15 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,4639 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __esm = (fn, res) => function __init() {
7
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
8
+ };
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
+
23
+ // src/types/face.ts
24
+ function normalizeAssetBaseUrl(assetBaseUrl = "/FaceAssets") {
25
+ const trimmed = assetBaseUrl.trim();
26
+ if (!trimmed) {
27
+ return "/FaceAssets";
28
+ }
29
+ return trimmed.endsWith("/") ? trimmed.slice(0, -1) : trimmed;
30
+ }
31
+ function createBuiltInPixiFaces(assetBaseUrl) {
32
+ const base = normalizeAssetBaseUrl(assetBaseUrl);
33
+ return [
34
+ {
35
+ kind: "PixiFace",
36
+ type: "avatar",
37
+ name: "Hugo",
38
+ mouth: "Hugo",
39
+ eyes: {
40
+ kind: "spritesheet",
41
+ path: `${base}/Hugo/hugo_spritesheet.json`
42
+ },
43
+ cheeks: {
44
+ kind: "texture",
45
+ path: `${base}/Hugo/cheek.png`
46
+ },
47
+ eyebrows: "Hugo"
48
+ },
49
+ {
50
+ kind: "PixiFace",
51
+ type: "avatar",
52
+ name: "Simple",
53
+ mouth: "Ellipse",
54
+ eyes: {
55
+ kind: "spritesheet",
56
+ path: `${base}/Hugo/hugo_spritesheet.json`
57
+ },
58
+ cheeks: null,
59
+ eyebrows: null
60
+ },
61
+ {
62
+ kind: "PixiFace",
63
+ type: "avatar",
64
+ name: "Robotic",
65
+ mouth: "ZigZag",
66
+ eyes: {
67
+ kind: "spritesheet",
68
+ path: `${base}/Robotic/robotic_spritesheet.json`
69
+ },
70
+ cheeks: null,
71
+ eyebrows: null
72
+ },
73
+ {
74
+ kind: "PixiFace",
75
+ type: "text",
76
+ name: "Display",
77
+ showEmotion: "emoticon",
78
+ showText: true
79
+ }
80
+ ];
81
+ }
82
+ function createCustomVizijFace(glbUrl = "") {
83
+ return {
84
+ kind: "Vizij",
85
+ name: "Custom Face",
86
+ assetBundle: {
87
+ namespace: "custom",
88
+ glb: {
89
+ kind: "url",
90
+ src: glbUrl,
91
+ aggressiveImport: true
92
+ }
93
+ }
94
+ };
95
+ }
96
+ function createIncludedVizijFaces(assetBaseUrl) {
97
+ const base = normalizeAssetBaseUrl(assetBaseUrl);
98
+ return [
99
+ {
100
+ kind: "Vizij",
101
+ name: "Hugo - Expressive",
102
+ assetBundle: {
103
+ namespace: "hugo",
104
+ glb: {
105
+ kind: "url",
106
+ src: `${base}/Vizij/Hugo.glb`,
107
+ aggressiveImport: true
108
+ }
109
+ }
110
+ },
111
+ createCustomVizijFace("")
112
+ ];
113
+ }
114
+ function createBuiltInFaces(assetBaseUrl) {
115
+ return [
116
+ ...createBuiltInPixiFaces(assetBaseUrl),
117
+ ...createIncludedVizijFaces(assetBaseUrl)
118
+ ];
119
+ }
120
+ var PEERBOTS_COLORS, PEERBOTS_EMOTIONS, DEFAULT_FACE_MESSAGE, CONNECTION_FACE_MESSAGE, defaultFaceSettings, builtInFaces, customFace, includedVizijFaces, availableFaces, defaultFace, getFaceCapabilities;
121
+ var init_face = __esm({
122
+ "src/types/face.ts"() {
123
+ "use strict";
124
+ PEERBOTS_COLORS = [
125
+ "Light Blue",
126
+ "Blue",
127
+ "Green",
128
+ "Red",
129
+ "Purple",
130
+ "Pink",
131
+ "Yellow",
132
+ "Orange",
133
+ "Grey",
134
+ "Black",
135
+ "White"
136
+ ];
137
+ PEERBOTS_EMOTIONS = [
138
+ "Neutral",
139
+ "Surprised",
140
+ "Happy",
141
+ "Sad",
142
+ "Concerned",
143
+ "Sleepy"
144
+ ];
145
+ DEFAULT_FACE_MESSAGE = {
146
+ title: "Ready",
147
+ speech: "",
148
+ color: "Light Blue",
149
+ emotion: "Neutral"
150
+ };
151
+ CONNECTION_FACE_MESSAGE = {
152
+ title: "Connecting",
153
+ speech: "Connecting",
154
+ color: "Light Blue",
155
+ emotion: "Neutral"
156
+ };
157
+ defaultFaceSettings = {
158
+ zoom: 1,
159
+ offset: { x: 0, y: 0 },
160
+ rotation: 0,
161
+ autoRotate: true,
162
+ showFullScreenButton: true,
163
+ showScrollButton: true,
164
+ amplitudeGain: 1,
165
+ vizijSettings: {
166
+ faceExpressivity: 1
167
+ },
168
+ pixiSettings: {
169
+ eyeDisplay: "default",
170
+ mouthDisplay: "default",
171
+ cheekDisplay: "default",
172
+ emotionDisplay: "emoticon"
173
+ },
174
+ selectedLanguage: "English",
175
+ speechQueueMode: "interrupt",
176
+ captions: {
177
+ enabled: false,
178
+ fontSize: 32,
179
+ offset: { x: 0, y: 0 }
180
+ }
181
+ };
182
+ builtInFaces = createBuiltInPixiFaces();
183
+ customFace = createCustomVizijFace();
184
+ includedVizijFaces = createIncludedVizijFaces();
185
+ availableFaces = [...builtInFaces, ...includedVizijFaces];
186
+ defaultFace = builtInFaces[0];
187
+ getFaceCapabilities = (face) => {
188
+ if (!face) {
189
+ return {
190
+ canExpressColor: false,
191
+ canExpressEmotion: false,
192
+ canLipSync: false
193
+ };
194
+ }
195
+ if (face.kind === "PixiFace" && "type" in face) {
196
+ const pixiFace = face;
197
+ if (pixiFace.type === "avatar") {
198
+ return {
199
+ canExpressColor: "Background Color Change",
200
+ canExpressEmotion: "Image Swap",
201
+ canLipSync: pixiFace.mouth === "ZigZag" ? "Random mouth motions" : "Timed mouth motions"
202
+ };
203
+ }
204
+ if (pixiFace.type === "text") {
205
+ return {
206
+ canExpressColor: "Background Color Change",
207
+ canExpressEmotion: pixiFace.showEmotion === "none" ? false : pixiFace.showEmotion,
208
+ canLipSync: "Cursor movement"
209
+ };
210
+ }
211
+ }
212
+ if (face.kind === "Vizij") {
213
+ return {
214
+ canExpressColor: "Background Color Change",
215
+ canExpressEmotion: "Animated Expression",
216
+ canLipSync: "Lip-sync or random mouth motions"
217
+ };
218
+ }
219
+ return {
220
+ canExpressColor: false,
221
+ canExpressEmotion: false,
222
+ canLipSync: false
223
+ };
224
+ };
225
+ }
226
+ });
227
+
228
+ // src/types/labels.ts
229
+ function resolveFaceUiLabels(overrides) {
230
+ if (!overrides) {
231
+ return DEFAULT_FACE_UI_LABELS;
232
+ }
233
+ return {
234
+ ...DEFAULT_FACE_UI_LABELS,
235
+ ...overrides
236
+ };
237
+ }
238
+ var DEFAULT_FACE_UI_LABELS;
239
+ var init_labels = __esm({
240
+ "src/types/labels.ts"() {
241
+ "use strict";
242
+ DEFAULT_FACE_UI_LABELS = {
243
+ loading: "Loading...",
244
+ poweredBy: "Powered by",
245
+ tapToEnableSound: "Tap to enable sound",
246
+ allowSpeech: "Allow Speech",
247
+ characterSelection: "Character & Voice",
248
+ face: "Character",
249
+ uploadGlb: "Upload .GLB Rig",
250
+ vizijUploadGlb: "Upload a .glb file in Face Settings to preview Custom Face",
251
+ vizijErrorPrefix: "3D Face Error:",
252
+ faceCapabilities: "Face Capabilities",
253
+ color: "Color",
254
+ emotion: "Emotion",
255
+ speech: "Speech",
256
+ faceSpecificSettings: "Face-Specific Settings",
257
+ faceExpressivity: "Face Expressivity",
258
+ eyes: "Eyes",
259
+ mouth: "Mouth",
260
+ cheeks: "Cheeks",
261
+ emotionDisplay: "Emotion Display",
262
+ defaultOption: "Default",
263
+ noneOption: "None",
264
+ emoticon: "Emoticon",
265
+ emoji: "Emoji",
266
+ positioning: "Face Positioning",
267
+ autoRotate: "Auto-Rotate",
268
+ rotate: "Rotate 90\xB0",
269
+ reset: "Reset",
270
+ zoom: "Zoom",
271
+ horizontalOffset: "Horizontal Offset",
272
+ verticalOffset: "Vertical Offset",
273
+ faceSettings: "Face Settings",
274
+ onFaceButtons: "On-Face Controls",
275
+ showFullScreenButton: "Show Fullscreen Button",
276
+ showScrollButton: "Show Scroll-to-Top Button",
277
+ speechBehavior: "Speech Playback Behavior",
278
+ newButtonSpeech: "When new speech arrives",
279
+ interruptSpeech: "Interrupt current speech",
280
+ queueSpeech: "Queue after current speech",
281
+ captions: "Captions",
282
+ fontSize: "Caption Font Size",
283
+ verticalPosition: "Vertical Position",
284
+ voiceSelectorLanguage: "Language",
285
+ voiceSelectorVoice: "Voice",
286
+ unknownFaceType: "Unknown Face Type",
287
+ sendEmotion: "Send Emotion",
288
+ sendColor: "Send Color",
289
+ textToSpeakPlaceholder: "Enter text to speak",
290
+ textToSpeakAria: "Text to speak",
291
+ speak: "Speak",
292
+ testFace: "Test Face"
293
+ };
294
+ }
295
+ });
296
+
297
+ // src/helpers/viseme_mapper.ts
298
+ function mapVisemeToVizijTarget(viseme) {
299
+ if (Object.prototype.hasOwnProperty.call(pollyVisemeToVizijPath, viseme)) {
300
+ return pollyVisemeToVizijPath[viseme];
301
+ }
302
+ return "";
303
+ }
304
+ function estimateVisemesFromText(text, msPerChar = 65) {
305
+ const cleaned = text.trim();
306
+ if (!cleaned) {
307
+ return [];
308
+ }
309
+ const visemes = [];
310
+ const durationSec = Math.max(0.03, msPerChar / 1e3);
311
+ for (const ch of cleaned.toLowerCase()) {
312
+ const mapped = CHAR_TO_POLLY_VISEME[ch] ?? "sil";
313
+ const prev = visemes[visemes.length - 1];
314
+ if (prev && prev.value === mapped) {
315
+ prev.time = Number((prev.time + durationSec).toFixed(4));
316
+ } else {
317
+ visemes.push({
318
+ time: Number(durationSec.toFixed(4)),
319
+ type: "viseme",
320
+ value: mapped
321
+ });
322
+ }
323
+ }
324
+ if (visemes[visemes.length - 1]?.value !== "sil") {
325
+ visemes.push({
326
+ time: 0.1,
327
+ type: "viseme",
328
+ value: "sil"
329
+ });
330
+ }
331
+ return visemes;
332
+ }
333
+ var pollyVisemeToVizijPath, possiblePollyVisemes, CHAR_TO_POLLY_VISEME;
334
+ var init_viseme_mapper = __esm({
335
+ "src/helpers/viseme_mapper.ts"() {
336
+ "use strict";
337
+ pollyVisemeToVizijPath = {
338
+ "@": "pose_pzzzfnvy",
339
+ a: "a",
340
+ e: "e_2",
341
+ E: "e",
342
+ f: "f",
343
+ i: "i",
344
+ k: "k",
345
+ l: "r",
346
+ o: "o",
347
+ O: "o_2",
348
+ p: "p",
349
+ r: "r",
350
+ s: "s",
351
+ S: "s",
352
+ t: "t",
353
+ T: "t_2",
354
+ u: "u",
355
+ sil: ""
356
+ };
357
+ possiblePollyVisemes = Array.from(
358
+ new Set(Object.values(pollyVisemeToVizijPath).filter((v) => v.length > 0))
359
+ );
360
+ CHAR_TO_POLLY_VISEME = {
361
+ a: "a",
362
+ b: "p",
363
+ c: "k",
364
+ d: "t",
365
+ e: "e",
366
+ f: "f",
367
+ g: "k",
368
+ h: "@",
369
+ i: "i",
370
+ j: "S",
371
+ k: "k",
372
+ l: "l",
373
+ m: "p",
374
+ n: "t",
375
+ o: "o",
376
+ p: "p",
377
+ q: "k",
378
+ r: "r",
379
+ s: "s",
380
+ t: "t",
381
+ u: "u",
382
+ v: "f",
383
+ w: "u",
384
+ x: "s",
385
+ y: "i",
386
+ z: "s"
387
+ };
388
+ }
389
+ });
390
+
391
+ // src/helpers/emotion_mapper.ts
392
+ function getEmotionIconPath(emotion, assetBaseUrl) {
393
+ const base = normalizeAssetBaseUrl(assetBaseUrl);
394
+ const file = EMOTION_ICON_FILES[emotion] ?? EMOTION_ICON_FILES.Neutral;
395
+ return `${base}/Icons/${file}`;
396
+ }
397
+ function getEmotionEyeSpritePaths(emotion, character = "Hugo", assetBaseUrl) {
398
+ const base = normalizeAssetBaseUrl(assetBaseUrl);
399
+ const key = emotion.toLowerCase();
400
+ return {
401
+ left: `${base}/${character}/${key}_l.png`,
402
+ right: `${base}/${character}/${key}_r.png`
403
+ };
404
+ }
405
+ var EMOTION_EMOTICONS, EMOTION_EMOJIS, EMOTION_ICON_FILES, emotion_mapping;
406
+ var init_emotion_mapper = __esm({
407
+ "src/helpers/emotion_mapper.ts"() {
408
+ "use strict";
409
+ init_face();
410
+ EMOTION_EMOTICONS = {
411
+ Happy: ":D",
412
+ Sad: ":(",
413
+ Surprised: ":o",
414
+ Neutral: ":)",
415
+ Sleepy: ":z",
416
+ Concerned: ":/"
417
+ };
418
+ EMOTION_EMOJIS = {
419
+ Happy: "\u{1F600}",
420
+ Sad: "\u{1F622}",
421
+ Surprised: "\u{1F62E}",
422
+ Neutral: "\u{1F610}",
423
+ Sleepy: "\u{1F634}",
424
+ Concerned: "\u{1F61F}"
425
+ };
426
+ EMOTION_ICON_FILES = {
427
+ Neutral: "Neutral.png",
428
+ Surprised: "Surprised.png",
429
+ Happy: "Neutral.png",
430
+ Sad: "Sad.png",
431
+ Concerned: "Concerned.png",
432
+ Sleepy: "Sleep.png"
433
+ };
434
+ emotion_mapping = {
435
+ Neutral: getEmotionIconPath("Neutral"),
436
+ Surprised: getEmotionIconPath("Surprised"),
437
+ Happy: getEmotionIconPath("Happy"),
438
+ Sad: getEmotionIconPath("Sad"),
439
+ Concerned: getEmotionIconPath("Concerned"),
440
+ Sleepy: getEmotionIconPath("Sleepy")
441
+ };
442
+ }
443
+ });
444
+
445
+ // src/helpers/color_mappers.ts
446
+ function hexToRgb(hex) {
447
+ const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
448
+ const expanded = hex.replace(shorthandRegex, (_m, r, g, b) => {
449
+ return r + r + g + g + b + b;
450
+ });
451
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(expanded);
452
+ return result ? {
453
+ r: parseInt(result[1], 16),
454
+ g: parseInt(result[2], 16),
455
+ b: parseInt(result[3], 16)
456
+ } : null;
457
+ }
458
+ function rgbaToHex(orig) {
459
+ const rgb = orig.replace(/\s/g, "").match(/^rgba?\((\d+),(\d+),(\d+),?([^,\s)]+)?/i);
460
+ if (!rgb) {
461
+ return orig;
462
+ }
463
+ const alphaStr = (rgb[4] || "").trim();
464
+ const hexRgb = (Number(rgb[1]) | 1 << 8).toString(16).slice(1) + (Number(rgb[2]) | 1 << 8).toString(16).slice(1) + (Number(rgb[3]) | 1 << 8).toString(16).slice(1);
465
+ const numericAlpha = alphaStr !== "" ? Number(alphaStr) : 1;
466
+ const clampedAlpha = Math.max(0, Math.min(1, Number.isNaN(numericAlpha) ? 1 : numericAlpha));
467
+ const hexAlpha = (Math.round(clampedAlpha * 255) | 1 << 8).toString(16).slice(1);
468
+ return hexRgb + hexAlpha;
469
+ }
470
+ var color_mapping, font_color_mapping, hexToRgba, rgbToRgba, rbgToRgba, deconstructRgba, formatRgba, formatRbga, interpolateColor;
471
+ var init_color_mappers = __esm({
472
+ "src/helpers/color_mappers.ts"() {
473
+ "use strict";
474
+ color_mapping = {
475
+ "Light Blue": "#ABE3FA",
476
+ Blue: "#5F94D6",
477
+ Green: "#65C77D",
478
+ Red: "#E6817E",
479
+ Purple: "#9B86F3",
480
+ Pink: "#EBA4E4",
481
+ Yellow: "#F8EDB1",
482
+ Orange: "#E6A575",
483
+ Grey: "#CECECE",
484
+ Black: "#4D4D4D",
485
+ White: "#FDFEFE"
486
+ };
487
+ font_color_mapping = {
488
+ "Light Blue": "#020307",
489
+ Blue: "#020307",
490
+ Green: "#020307",
491
+ Red: "#020307",
492
+ Purple: "#020307",
493
+ Pink: "#020307",
494
+ Yellow: "#020307",
495
+ Orange: "#020307",
496
+ Grey: "#020307",
497
+ Black: "#FDFEFE",
498
+ White: "#020307"
499
+ };
500
+ hexToRgba = (color, alpha = 1) => {
501
+ const rgb = hexToRgb(color);
502
+ if (rgb !== null) {
503
+ return `rgba(${rgb.r},${rgb.g},${rgb.b},${alpha})`;
504
+ }
505
+ return null;
506
+ };
507
+ rgbToRgba = (color, alpha = 1) => {
508
+ const [r = "0", g = "0", b = "0"] = color.replace(/[^\d,]/g, "").split(",");
509
+ return `rgba(${r},${g},${b},${alpha})`;
510
+ };
511
+ rbgToRgba = rgbToRgba;
512
+ deconstructRgba = (rgba) => {
513
+ return rgba.replace(/[^\d.,]/g, "").split(",").map((x) => Number(x));
514
+ };
515
+ formatRgba = (color) => {
516
+ return `rgba(${color.r},${color.g},${color.b},${color.a})`;
517
+ };
518
+ formatRbga = formatRgba;
519
+ interpolateColor = (colorA, colorB, progress) => {
520
+ const rgbaColorA = hexToRgba(colorA);
521
+ const rgbaColorB = hexToRgba(colorB);
522
+ if (rgbaColorA && rgbaColorB) {
523
+ const [r1, g1, b1, a1] = deconstructRgba(rgbaColorA);
524
+ const [r2, g2, b2, a2] = deconstructRgba(rgbaColorB);
525
+ const clampedProgress = Math.max(0, Math.min(1, progress));
526
+ return formatRgba({
527
+ r: Math.round(r1 + (r2 - r1) * clampedProgress),
528
+ g: Math.round(g1 + (g2 - g1) * clampedProgress),
529
+ b: Math.round(b1 + (b2 - b1) * clampedProgress),
530
+ a: Number((a1 + (a2 - a1) * clampedProgress).toFixed(3))
531
+ });
532
+ }
533
+ return null;
534
+ };
535
+ }
536
+ });
537
+
538
+ // src/helpers/voice_helpers.ts
539
+ function getLanguageName(code) {
540
+ if (!code) {
541
+ return "";
542
+ }
543
+ try {
544
+ const baseCode = code.split("-")[0];
545
+ if (!baseCode || !languageDisplayNames) {
546
+ return code;
547
+ }
548
+ return languageDisplayNames.of(baseCode) || code;
549
+ } catch (err) {
550
+ void err;
551
+ return code;
552
+ }
553
+ }
554
+ function formatVoiceDisplayName(rawName) {
555
+ if (!rawName) return "";
556
+ let name = rawName.replace(/^AWS - /, "").trim();
557
+ if (name.startsWith("aws:")) {
558
+ const parts = name.split(":");
559
+ name = parts[1] || name.slice(4);
560
+ }
561
+ if (!name.includes("com.apple.") && !name.includes("com.google.")) {
562
+ return name;
563
+ }
564
+ if (name.includes("com.google.")) {
565
+ const afterColon = name.split(":").pop() || name;
566
+ return afterColon.replace(/[-_]/g, " ").trim();
567
+ }
568
+ const siriMatch = name.match(
569
+ /siri_([a-zA-Z]+)_[a-zA-Z0-9-_]+?(?:_(compact|premium|enhanced))?$/i
570
+ );
571
+ if (siriMatch) {
572
+ const gender = siriMatch[1].charAt(0).toUpperCase() + siriMatch[1].slice(1).toLowerCase();
573
+ const quality = siriMatch[2] && siriMatch[2].toLowerCase() !== "compact" ? ` (${siriMatch[2].charAt(0).toUpperCase() + siriMatch[2].slice(1).toLowerCase()})` : "";
574
+ return `Siri ${gender}${quality}`;
575
+ }
576
+ const ttsMatch = name.match(
577
+ /com\.apple\.ttsbundle\.([a-zA-Z0-9]+)(?:-(compact|premium|enhanced))?/i
578
+ );
579
+ if (ttsMatch) {
580
+ const base = ttsMatch[1].replace(/([a-z])([A-Z])/g, "$1 $2");
581
+ const quality = ttsMatch[2] && ttsMatch[2].toLowerCase() !== "compact" ? ` (${ttsMatch[2].charAt(0).toUpperCase() + ttsMatch[2].slice(1).toLowerCase()})` : "";
582
+ return `${base}${quality}`;
583
+ }
584
+ const speechMatch = name.match(
585
+ /com\.apple\.speech\.synthesis\.voice\.([a-zA-Z0-9_-]+)/i
586
+ );
587
+ if (speechMatch) {
588
+ return speechMatch[1].replace(/([a-z])([A-Z])/g, "$1 $2");
589
+ }
590
+ const tierMatch = name.match(
591
+ /com\.apple\.voice\.(compact|enhanced|premium)\.[^.]+\.([a-zA-Z0-9_-]+)/i
592
+ );
593
+ if (tierMatch) {
594
+ const base = tierMatch[2].replace(/([a-z])([A-Z])/g, "$1 $2");
595
+ const quality = tierMatch[1].toLowerCase() !== "compact" ? ` (${tierMatch[1].charAt(0).toUpperCase() + tierMatch[1].slice(1).toLowerCase()})` : "";
596
+ return `${base}${quality}`;
597
+ }
598
+ const eloquenceMatch = name.match(
599
+ /com\.apple\.eloquence\.[^.]+\.([a-zA-Z0-9_-]+)/i
600
+ );
601
+ if (eloquenceMatch) {
602
+ return eloquenceMatch[1].replace(/([a-z])([A-Z])/g, "$1 $2");
603
+ }
604
+ const segments = name.split(".");
605
+ let last = segments[segments.length - 1] || name;
606
+ last = last.replace(/[-_](compact|premium|enhanced)$/i, "");
607
+ last = last.replace(/([a-z])([A-Z])/g, "$1 $2");
608
+ last = last.replace(/[-_]/g, " ").trim();
609
+ return last || name;
610
+ }
611
+ function findMatchingVoice(voices, target) {
612
+ if (!target) return void 0;
613
+ const directUri = voices.find((v) => v.voiceURI === target);
614
+ if (directUri) return directUri;
615
+ const directName = voices.find((v) => v.name === target);
616
+ if (directName) return directName;
617
+ const targetClean = formatVoiceDisplayName(target).toLowerCase();
618
+ const cleanMatch = voices.find(
619
+ (v) => formatVoiceDisplayName(v.name).toLowerCase() === targetClean || formatVoiceDisplayName(v.voiceURI).toLowerCase() === targetClean
620
+ );
621
+ if (cleanMatch) return cleanMatch;
622
+ const lowerTarget = target.toLowerCase();
623
+ return voices.find(
624
+ (v) => v.voiceURI.toLowerCase() === lowerTarget || v.name.toLowerCase() === lowerTarget
625
+ );
626
+ }
627
+ var languageDisplayNames;
628
+ var init_voice_helpers = __esm({
629
+ "src/helpers/voice_helpers.ts"() {
630
+ "use strict";
631
+ languageDisplayNames = typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function" ? new Intl.DisplayNames(["en"], { type: "language" }) : null;
632
+ }
633
+ });
634
+
635
+ // src/services/AudioAnalyzer.ts
636
+ var AudioAnalyzer, audioAnalyzer;
637
+ var init_AudioAnalyzer = __esm({
638
+ "src/services/AudioAnalyzer.ts"() {
639
+ "use strict";
640
+ AudioAnalyzer = class {
641
+ ctx = null;
642
+ analyzer = null;
643
+ data = null;
644
+ connectedElements = /* @__PURE__ */ new WeakSet();
645
+ connect(audio) {
646
+ if (typeof window === "undefined") {
647
+ return;
648
+ }
649
+ const AudioContextCtor = window.AudioContext || window.webkitAudioContext;
650
+ if (!AudioContextCtor) {
651
+ return;
652
+ }
653
+ try {
654
+ if (!this.ctx) {
655
+ this.ctx = new AudioContextCtor();
656
+ this.analyzer = this.ctx.createAnalyser();
657
+ this.analyzer.fftSize = 256;
658
+ this.data = new Uint8Array(new ArrayBuffer(this.analyzer.frequencyBinCount));
659
+ }
660
+ if (!this.connectedElements.has(audio) && this.analyzer) {
661
+ const source = this.ctx.createMediaElementSource(audio);
662
+ source.connect(this.analyzer);
663
+ this.analyzer.connect(this.ctx.destination);
664
+ this.connectedElements.add(audio);
665
+ }
666
+ } catch (error) {
667
+ console.warn("AudioAnalyzer connect error:", error);
668
+ }
669
+ }
670
+ getAmplitude() {
671
+ if (!this.analyzer || !this.data) {
672
+ return 0;
673
+ }
674
+ this.analyzer.getByteTimeDomainData(this.data);
675
+ let sum = 0;
676
+ for (const v of this.data) {
677
+ const normalized = (v - 128) / 128;
678
+ sum += normalized * normalized;
679
+ }
680
+ return Math.sqrt(sum / this.data.length);
681
+ }
682
+ };
683
+ audioAnalyzer = new AudioAnalyzer();
684
+ }
685
+ });
686
+
687
+ // src/services/ttsAudioCache.ts
688
+ function buildTtsCacheKey(params) {
689
+ const voice = params.voiceId.trim();
690
+ const engine = (params.engine ?? "default").trim() || "default";
691
+ const normalizedText = params.text.trim();
692
+ if (params.rate === void 0 && params.pitch === void 0) {
693
+ return `${voice}:${engine}:${normalizedText}`;
694
+ }
695
+ const rate = params.rate ?? 1;
696
+ const pitch = params.pitch ?? 1;
697
+ return `${voice}:${engine}:${rate}:${pitch}:${normalizedText}`;
698
+ }
699
+ async function blobToArrayBuffer(blob) {
700
+ if (typeof blob.arrayBuffer === "function") {
701
+ return blob.arrayBuffer();
702
+ }
703
+ return new Promise((resolve, reject) => {
704
+ const reader = new FileReader();
705
+ reader.onload = () => {
706
+ if (reader.result instanceof ArrayBuffer) {
707
+ resolve(reader.result);
708
+ } else {
709
+ reject(new Error("Failed to read Blob as ArrayBuffer"));
710
+ }
711
+ };
712
+ reader.onerror = () => {
713
+ reject(reader.error ?? new Error("FileReader error"));
714
+ };
715
+ reader.readAsArrayBuffer(blob);
716
+ });
717
+ }
718
+ var TtsAudioCache, defaultTtsAudioCache;
719
+ var init_ttsAudioCache = __esm({
720
+ "src/services/ttsAudioCache.ts"() {
721
+ "use strict";
722
+ TtsAudioCache = class {
723
+ maxEntries;
724
+ enableIndexedDb;
725
+ dbName;
726
+ storeName;
727
+ memory = /* @__PURE__ */ new Map();
728
+ dbPromise = null;
729
+ constructor(options = {}) {
730
+ this.maxEntries = Math.max(1, options.maxEntries ?? 100);
731
+ this.enableIndexedDb = options.enableIndexedDb ?? true;
732
+ this.dbName = options.dbName ?? "peerbots-tts-cache";
733
+ this.storeName = options.storeName ?? "entries";
734
+ }
735
+ get size() {
736
+ return this.memory.size;
737
+ }
738
+ hasInMemory(key) {
739
+ return this.memory.has(key);
740
+ }
741
+ async get(key) {
742
+ const existing = this.memory.get(key);
743
+ if (existing) {
744
+ this.memory.delete(key);
745
+ this.memory.set(key, existing);
746
+ return existing;
747
+ }
748
+ const fromIdb = await this.readFromIndexedDb(key);
749
+ if (fromIdb) {
750
+ this.putInMemory(key, fromIdb);
751
+ return fromIdb;
752
+ }
753
+ return void 0;
754
+ }
755
+ async set(key, entry) {
756
+ const fullEntry = {
757
+ ...entry,
758
+ createdAt: entry.createdAt ?? Date.now()
759
+ };
760
+ this.putInMemory(key, fullEntry);
761
+ await this.writeToIndexedDb(key, fullEntry);
762
+ }
763
+ async delete(key) {
764
+ const removedMem = this.memory.delete(key);
765
+ const removedIdb = await this.deleteFromIndexedDb(key);
766
+ return removedMem || removedIdb;
767
+ }
768
+ async clear() {
769
+ this.memory.clear();
770
+ await this.clearIndexedDb();
771
+ }
772
+ createObjectUrl(entry) {
773
+ return URL.createObjectURL(entry.audioBlob);
774
+ }
775
+ putInMemory(key, entry) {
776
+ if (this.memory.has(key)) {
777
+ this.memory.delete(key);
778
+ }
779
+ this.memory.set(key, entry);
780
+ while (this.memory.size > this.maxEntries) {
781
+ const oldestKey = this.memory.keys().next().value;
782
+ if (oldestKey !== void 0) {
783
+ this.memory.delete(oldestKey);
784
+ } else {
785
+ break;
786
+ }
787
+ }
788
+ }
789
+ openDatabase() {
790
+ if (!this.enableIndexedDb || typeof indexedDB === "undefined") {
791
+ return Promise.resolve(null);
792
+ }
793
+ if (this.dbPromise) {
794
+ return this.dbPromise;
795
+ }
796
+ this.dbPromise = new Promise((resolve) => {
797
+ try {
798
+ const request = indexedDB.open(this.dbName, 1);
799
+ request.onupgradeneeded = () => {
800
+ const db = request.result;
801
+ if (!db.objectStoreNames.contains(this.storeName)) {
802
+ db.createObjectStore(this.storeName, { keyPath: "key" });
803
+ }
804
+ };
805
+ request.onsuccess = () => resolve(request.result);
806
+ request.onerror = () => resolve(null);
807
+ } catch (err) {
808
+ void err;
809
+ resolve(null);
810
+ }
811
+ });
812
+ return this.dbPromise;
813
+ }
814
+ async readFromIndexedDb(key) {
815
+ const db = await this.openDatabase();
816
+ if (!db) {
817
+ return void 0;
818
+ }
819
+ return new Promise((resolve) => {
820
+ try {
821
+ const tx = db.transaction(this.storeName, "readonly");
822
+ const store = tx.objectStore(this.storeName);
823
+ const req = store.get(key);
824
+ req.onsuccess = () => {
825
+ const record = req.result;
826
+ if (!record || !record.audioBuffer) {
827
+ resolve(void 0);
828
+ return;
829
+ }
830
+ resolve({
831
+ audioBlob: new Blob([record.audioBuffer], {
832
+ type: record.mimeType || "audio/mpeg"
833
+ }),
834
+ mimeType: record.mimeType || "audio/mpeg",
835
+ visemes: record.visemes,
836
+ amplitudeData: record.amplitudeData,
837
+ extrema: record.extrema,
838
+ createdAt: record.createdAt
839
+ });
840
+ };
841
+ req.onerror = () => resolve(void 0);
842
+ } catch (err) {
843
+ void err;
844
+ resolve(void 0);
845
+ }
846
+ });
847
+ }
848
+ async writeToIndexedDb(key, entry) {
849
+ const db = await this.openDatabase();
850
+ if (!db) {
851
+ return;
852
+ }
853
+ try {
854
+ const audioBuffer = await blobToArrayBuffer(entry.audioBlob);
855
+ await new Promise((resolve) => {
856
+ const tx = db.transaction(this.storeName, "readwrite");
857
+ const store = tx.objectStore(this.storeName);
858
+ const record = {
859
+ key,
860
+ audioBuffer,
861
+ mimeType: entry.mimeType,
862
+ visemes: entry.visemes,
863
+ amplitudeData: entry.amplitudeData,
864
+ extrema: entry.extrema,
865
+ createdAt: entry.createdAt
866
+ };
867
+ const req = store.put(record);
868
+ req.onsuccess = () => resolve();
869
+ req.onerror = () => resolve();
870
+ });
871
+ } catch (err) {
872
+ void err;
873
+ }
874
+ }
875
+ async deleteFromIndexedDb(key) {
876
+ const db = await this.openDatabase();
877
+ if (!db) {
878
+ return false;
879
+ }
880
+ return new Promise((resolve) => {
881
+ try {
882
+ const tx = db.transaction(this.storeName, "readwrite");
883
+ const store = tx.objectStore(this.storeName);
884
+ const req = store.delete(key);
885
+ req.onsuccess = () => resolve(true);
886
+ req.onerror = () => resolve(false);
887
+ } catch (err) {
888
+ void err;
889
+ resolve(false);
890
+ }
891
+ });
892
+ }
893
+ async clearIndexedDb() {
894
+ const db = await this.openDatabase();
895
+ if (!db) {
896
+ return;
897
+ }
898
+ await new Promise((resolve) => {
899
+ try {
900
+ const tx = db.transaction(this.storeName, "readwrite");
901
+ const store = tx.objectStore(this.storeName);
902
+ const req = store.clear();
903
+ req.onsuccess = () => resolve();
904
+ req.onerror = () => resolve();
905
+ } catch (err) {
906
+ void err;
907
+ resolve();
908
+ }
909
+ });
910
+ }
911
+ };
912
+ defaultTtsAudioCache = new TtsAudioCache();
913
+ }
914
+ });
915
+
916
+ // src/hooks/useMessageVisualState.ts
917
+ function useMessageVisualState(isSpeaking, config = {}) {
918
+ const {
919
+ msPerChar = 50,
920
+ persistenceDuration = 3e3,
921
+ pauseBeforeNextMsg = 500
922
+ } = config;
923
+ const [displayText, setDisplayText] = (0, import_react.useState)("");
924
+ const [visualState, setVisualState] = (0, import_react.useState)("IDLE");
925
+ const stateRef = (0, import_react.useRef)("IDLE");
926
+ const displayTextRef = (0, import_react.useRef)("");
927
+ const currentMsgRef = (0, import_react.useRef)(null);
928
+ const nextMsgRef = (0, import_react.useRef)(null);
929
+ const timerRef = (0, import_react.useRef)(0);
930
+ const charTimerRef = (0, import_react.useRef)(0);
931
+ const typingIndexRef = (0, import_react.useRef)(0);
932
+ const startShowing = (0, import_react.useCallback)(
933
+ (speech) => {
934
+ currentMsgRef.current = speech;
935
+ nextMsgRef.current = null;
936
+ stateRef.current = "SHOWING";
937
+ setVisualState("SHOWING");
938
+ typingIndexRef.current = 0;
939
+ charTimerRef.current = 0;
940
+ if (msPerChar <= 0) {
941
+ setDisplayText(speech);
942
+ displayTextRef.current = speech;
943
+ typingIndexRef.current = speech.length;
944
+ } else {
945
+ setDisplayText("");
946
+ displayTextRef.current = "";
947
+ }
948
+ },
949
+ [msPerChar]
950
+ );
951
+ const queueMessage = (0, import_react.useCallback)(
952
+ (speech) => {
953
+ if (stateRef.current === "IDLE" || stateRef.current === "PERSISTING") {
954
+ startShowing(speech);
955
+ return;
956
+ }
957
+ nextMsgRef.current = speech;
958
+ },
959
+ [startShowing]
960
+ );
961
+ const update = (0, import_react.useCallback)(
962
+ (ms) => {
963
+ const prevState = stateRef.current;
964
+ switch (stateRef.current) {
965
+ case "IDLE":
966
+ if (displayTextRef.current !== "") {
967
+ setDisplayText("");
968
+ displayTextRef.current = "";
969
+ }
970
+ if (nextMsgRef.current) {
971
+ startShowing(nextMsgRef.current);
972
+ }
973
+ break;
974
+ case "SHOWING":
975
+ if (!currentMsgRef.current) {
976
+ stateRef.current = "IDLE";
977
+ break;
978
+ }
979
+ if (msPerChar <= 0) {
980
+ if (nextMsgRef.current) {
981
+ stateRef.current = "PAUSED";
982
+ timerRef.current = 0;
983
+ } else {
984
+ stateRef.current = "WAITING_FOR_AUDIO";
985
+ }
986
+ break;
987
+ }
988
+ charTimerRef.current += ms;
989
+ if (charTimerRef.current > msPerChar) {
990
+ const fullText = currentMsgRef.current;
991
+ const charCountToAdd = Math.floor(charTimerRef.current / msPerChar);
992
+ charTimerRef.current %= msPerChar;
993
+ const nextIndex = typingIndexRef.current + charCountToAdd;
994
+ if (nextIndex >= fullText.length) {
995
+ setDisplayText(fullText);
996
+ displayTextRef.current = fullText;
997
+ typingIndexRef.current = fullText.length;
998
+ if (nextMsgRef.current) {
999
+ stateRef.current = "PAUSED";
1000
+ timerRef.current = 0;
1001
+ } else {
1002
+ stateRef.current = "WAITING_FOR_AUDIO";
1003
+ }
1004
+ } else {
1005
+ typingIndexRef.current = nextIndex;
1006
+ const partial = fullText.substring(0, nextIndex);
1007
+ setDisplayText(partial);
1008
+ displayTextRef.current = partial;
1009
+ }
1010
+ }
1011
+ break;
1012
+ case "WAITING_FOR_AUDIO":
1013
+ if (nextMsgRef.current) {
1014
+ stateRef.current = "PAUSED";
1015
+ timerRef.current = 0;
1016
+ break;
1017
+ }
1018
+ if (!isSpeaking) {
1019
+ stateRef.current = "PERSISTING";
1020
+ timerRef.current = 0;
1021
+ }
1022
+ break;
1023
+ case "PERSISTING":
1024
+ if (nextMsgRef.current) {
1025
+ stateRef.current = "PAUSED";
1026
+ timerRef.current = 0;
1027
+ break;
1028
+ }
1029
+ timerRef.current += ms;
1030
+ if (timerRef.current > persistenceDuration) {
1031
+ stateRef.current = "IDLE";
1032
+ }
1033
+ break;
1034
+ case "PAUSED":
1035
+ timerRef.current += ms;
1036
+ if (timerRef.current > pauseBeforeNextMsg) {
1037
+ if (nextMsgRef.current) {
1038
+ startShowing(nextMsgRef.current);
1039
+ } else {
1040
+ stateRef.current = "WAITING_FOR_AUDIO";
1041
+ }
1042
+ }
1043
+ break;
1044
+ }
1045
+ if (stateRef.current !== prevState) {
1046
+ setVisualState(stateRef.current);
1047
+ }
1048
+ },
1049
+ [
1050
+ isSpeaking,
1051
+ msPerChar,
1052
+ persistenceDuration,
1053
+ pauseBeforeNextMsg,
1054
+ startShowing
1055
+ ]
1056
+ );
1057
+ return {
1058
+ displayText,
1059
+ visualState,
1060
+ queueMessage,
1061
+ update
1062
+ };
1063
+ }
1064
+ var import_react;
1065
+ var init_useMessageVisualState = __esm({
1066
+ "src/hooks/useMessageVisualState.ts"() {
1067
+ "use strict";
1068
+ import_react = require("react");
1069
+ }
1070
+ });
1071
+
1072
+ // src/store/faceRenderingSlice.ts
1073
+ function clampUnit(value) {
1074
+ if (Number.isNaN(value)) {
1075
+ return 0;
1076
+ }
1077
+ return Math.max(-1, Math.min(1, value));
1078
+ }
1079
+ function mergeFaceSettings(base, patch) {
1080
+ if (!patch) {
1081
+ return {
1082
+ ...base,
1083
+ offset: { ...base.offset },
1084
+ captions: {
1085
+ ...base.captions,
1086
+ offset: { ...base.captions.offset }
1087
+ },
1088
+ pixiSettings: base.pixiSettings ? { ...base.pixiSettings } : void 0,
1089
+ vizijSettings: base.vizijSettings ? { ...base.vizijSettings } : void 0
1090
+ };
1091
+ }
1092
+ return {
1093
+ ...defaultFaceSettings,
1094
+ ...base,
1095
+ ...patch,
1096
+ offset: {
1097
+ ...defaultFaceSettings.offset,
1098
+ ...base.offset || {},
1099
+ ...patch.offset || {}
1100
+ },
1101
+ captions: {
1102
+ ...defaultFaceSettings.captions,
1103
+ ...base.captions || {},
1104
+ ...patch.captions || {},
1105
+ offset: {
1106
+ ...defaultFaceSettings.captions.offset,
1107
+ ...base.captions?.offset || {},
1108
+ ...patch.captions?.offset || {}
1109
+ }
1110
+ },
1111
+ pixiSettings: {
1112
+ ...defaultFaceSettings.pixiSettings,
1113
+ ...base.pixiSettings || {},
1114
+ ...patch.pixiSettings || {}
1115
+ },
1116
+ vizijSettings: {
1117
+ ...defaultFaceSettings.vizijSettings,
1118
+ ...base.vizijSettings || {},
1119
+ ...patch.vizijSettings || {}
1120
+ }
1121
+ };
1122
+ }
1123
+ function createFaceRenderingSlice(options = {}) {
1124
+ const initialBaseUrl = normalizeAssetBaseUrl(options.assetBaseUrl);
1125
+ const initialFaces = createBuiltInFaces(initialBaseUrl);
1126
+ const initialSelectedFace = options.initialFace ?? initialFaces[0];
1127
+ const initialMergedSettings = mergeFaceSettings(
1128
+ defaultFaceSettings,
1129
+ options.initialSettings
1130
+ );
1131
+ return (set, get) => ({
1132
+ assetBaseUrl: initialBaseUrl,
1133
+ availableFaces: initialFaces,
1134
+ selectedFace: initialSelectedFace,
1135
+ faceSettings: initialMergedSettings,
1136
+ gaze: { x: 0, y: 0 },
1137
+ setFace: (face) => {
1138
+ set({ selectedFace: face });
1139
+ },
1140
+ setFaceByName: (name) => {
1141
+ const found = get().availableFaces.find((f) => f.name === name);
1142
+ if (found) {
1143
+ set({ selectedFace: found });
1144
+ }
1145
+ },
1146
+ setFaceSettings: (settings) => {
1147
+ set((state) => ({
1148
+ faceSettings: mergeFaceSettings(state.faceSettings, settings)
1149
+ }));
1150
+ },
1151
+ resetPositioning: () => {
1152
+ set((state) => ({
1153
+ faceSettings: mergeFaceSettings(state.faceSettings, {
1154
+ zoom: 1,
1155
+ offset: { x: 0, y: 0 },
1156
+ rotation: 0
1157
+ })
1158
+ }));
1159
+ },
1160
+ setGaze: (gaze) => {
1161
+ set({
1162
+ gaze: {
1163
+ x: clampUnit(gaze.x),
1164
+ y: clampUnit(gaze.y)
1165
+ }
1166
+ });
1167
+ },
1168
+ setLanguage: (lang) => {
1169
+ set((state) => ({
1170
+ faceSettings: mergeFaceSettings(state.faceSettings, {
1171
+ selectedLanguage: lang
1172
+ })
1173
+ }));
1174
+ },
1175
+ setAssetBaseUrl: (assetBaseUrl) => {
1176
+ const normalized = normalizeAssetBaseUrl(assetBaseUrl);
1177
+ const updatedFaces = createBuiltInFaces(normalized);
1178
+ const currentName = get().selectedFace?.name;
1179
+ const matchingUpdated = updatedFaces.find((f) => f.name === currentName);
1180
+ set({
1181
+ assetBaseUrl: normalized,
1182
+ availableFaces: updatedFaces,
1183
+ selectedFace: matchingUpdated ?? get().selectedFace
1184
+ });
1185
+ }
1186
+ });
1187
+ }
1188
+ var init_faceRenderingSlice = __esm({
1189
+ "src/store/faceRenderingSlice.ts"() {
1190
+ "use strict";
1191
+ init_face();
1192
+ }
1193
+ });
1194
+
1195
+ // src/store/faceSpeechSlice.ts
1196
+ function isNativeSpeechSynthesisVoice(voice) {
1197
+ if (!voice || typeof voice !== "object") {
1198
+ return false;
1199
+ }
1200
+ if (typeof SpeechSynthesisVoice !== "undefined" && voice instanceof SpeechSynthesisVoice) {
1201
+ return true;
1202
+ }
1203
+ return Object.prototype.toString.call(voice) === "[object SpeechSynthesisVoice]";
1204
+ }
1205
+ function matchesLanguage(voiceLang, selectedLang) {
1206
+ if (!voiceLang || !selectedLang) {
1207
+ return false;
1208
+ }
1209
+ return getLanguageName(voiceLang) === selectedLang || voiceLang === selectedLang || voiceLang.toLowerCase() === selectedLang.toLowerCase() || voiceLang.toLowerCase().startsWith(selectedLang.toLowerCase()) || selectedLang.toLowerCase().startsWith(voiceLang.toLowerCase());
1210
+ }
1211
+ function stopNativeSpeechSynthesis() {
1212
+ if (typeof window !== "undefined" && "speechSynthesis" in window) {
1213
+ try {
1214
+ if (window.speechSynthesis.speaking || window.speechSynthesis.pending) {
1215
+ window.speechSynthesis.cancel();
1216
+ }
1217
+ } catch (err) {
1218
+ void err;
1219
+ }
1220
+ }
1221
+ }
1222
+ function createFaceSpeechSlice(sliceOptions = {}) {
1223
+ let adapter = sliceOptions.speechAdapter ?? null;
1224
+ const cache = sliceOptions.ttsCache === false ? null : sliceOptions.ttsCache ?? defaultTtsAudioCache;
1225
+ const analyzer = sliceOptions.audioAnalyzer ?? audioAnalyzer;
1226
+ const utteranceDeferMs = sliceOptions.utteranceDeferMs ?? 10;
1227
+ let activeAudio = null;
1228
+ let activeObjectUrl = null;
1229
+ let activeUtterance = null;
1230
+ let activeTimer = null;
1231
+ let activeBoundaryTimer = null;
1232
+ let activeGeneration = 0;
1233
+ const revokeActiveObjectUrl = () => {
1234
+ if (activeObjectUrl) {
1235
+ try {
1236
+ URL.revokeObjectURL(activeObjectUrl);
1237
+ } catch (err) {
1238
+ void err;
1239
+ }
1240
+ activeObjectUrl = null;
1241
+ }
1242
+ };
1243
+ const cleanupActivePlayback = () => {
1244
+ activeGeneration += 1;
1245
+ if (activeTimer !== null) {
1246
+ clearTimeout(activeTimer);
1247
+ activeTimer = null;
1248
+ }
1249
+ if (activeBoundaryTimer !== null) {
1250
+ clearTimeout(activeBoundaryTimer);
1251
+ activeBoundaryTimer = null;
1252
+ }
1253
+ if (activeAudio) {
1254
+ activeAudio.onplay = null;
1255
+ activeAudio.onended = null;
1256
+ activeAudio.onerror = null;
1257
+ try {
1258
+ activeAudio.pause();
1259
+ activeAudio.currentTime = 0;
1260
+ } catch (err) {
1261
+ void err;
1262
+ }
1263
+ activeAudio = null;
1264
+ }
1265
+ revokeActiveObjectUrl();
1266
+ if (activeUtterance) {
1267
+ activeUtterance.onstart = null;
1268
+ activeUtterance.onend = null;
1269
+ activeUtterance.onerror = null;
1270
+ activeUtterance.onboundary = null;
1271
+ activeUtterance = null;
1272
+ }
1273
+ stopNativeSpeechSynthesis();
1274
+ };
1275
+ return (set, get) => {
1276
+ const playNextFromQueue = () => {
1277
+ const queue = get().speechQueue;
1278
+ if (queue.length > 0) {
1279
+ const [next, ...rest] = queue;
1280
+ set({ speechQueue: rest });
1281
+ void get().express(next.message, next.options);
1282
+ }
1283
+ };
1284
+ const finishGeneration = (gen) => {
1285
+ if (gen !== activeGeneration) {
1286
+ return;
1287
+ }
1288
+ if (activeBoundaryTimer !== null) {
1289
+ clearTimeout(activeBoundaryTimer);
1290
+ activeBoundaryTimer = null;
1291
+ }
1292
+ activeAudio = null;
1293
+ activeUtterance = null;
1294
+ revokeActiveObjectUrl();
1295
+ set({
1296
+ isSpeaking: false,
1297
+ speechStartTime: null,
1298
+ currentAmplitude: 0
1299
+ });
1300
+ playNextFromQueue();
1301
+ };
1302
+ const expressImpl = async (message, options) => {
1303
+ const speechText = (message.speech ?? "").trim();
1304
+ const hasWords = speechText.length > 0;
1305
+ if (sliceOptions.isSilent || options?.silent || !hasWords) {
1306
+ set({
1307
+ lastMessage: message,
1308
+ isSpeaking: false
1309
+ });
1310
+ return;
1311
+ }
1312
+ const effectiveQueueMode = options?.queueMode ?? get().faceSettings?.speechQueueMode ?? "interrupt";
1313
+ const currentlyPlaying = get().isSpeaking || activeAudio !== null || activeUtterance !== null || activeTimer !== null;
1314
+ if (effectiveQueueMode === "queue" && currentlyPlaying) {
1315
+ set((state) => ({
1316
+ speechQueue: [...state.speechQueue, { message, options }]
1317
+ }));
1318
+ return;
1319
+ }
1320
+ cleanupActivePlayback();
1321
+ const myGeneration = activeGeneration;
1322
+ set({
1323
+ lastMessage: message,
1324
+ isSpeaking: true
1325
+ });
1326
+ const selectedVoice = get().getSelectedVoice();
1327
+ const shouldUseAdapter = adapter !== null && typeof adapter.synthesizeSpeech === "function" && (adapter.canHandleVoice ? adapter.canHandleVoice(selectedVoice.voiceURI, selectedVoice) : true);
1328
+ if (shouldUseAdapter && adapter?.synthesizeSpeech) {
1329
+ try {
1330
+ const cacheKey = buildTtsCacheKey({
1331
+ voiceId: selectedVoice.voiceURI,
1332
+ engine: selectedVoice.engine,
1333
+ text: speechText
1334
+ });
1335
+ const cached = cache ? await cache.get(cacheKey) : void 0;
1336
+ if (myGeneration !== activeGeneration) {
1337
+ return;
1338
+ }
1339
+ let playbackUrl;
1340
+ let shouldRevokeUrl = false;
1341
+ let visemes = null;
1342
+ let ampData = null;
1343
+ let extrema = null;
1344
+ if (cached && cache) {
1345
+ playbackUrl = cache.createObjectUrl(cached);
1346
+ shouldRevokeUrl = true;
1347
+ visemes = cached.visemes ?? null;
1348
+ ampData = cached.amplitudeData ?? null;
1349
+ extrema = cached.extrema ?? null;
1350
+ } else {
1351
+ const synthesized = await adapter.synthesizeSpeech(
1352
+ speechText,
1353
+ selectedVoice.voiceURI,
1354
+ {
1355
+ engine: selectedVoice.engine,
1356
+ language: get().faceSettings?.selectedLanguage
1357
+ }
1358
+ );
1359
+ if (myGeneration !== activeGeneration) {
1360
+ return;
1361
+ }
1362
+ visemes = synthesized.visemes ?? null;
1363
+ ampData = synthesized.amplitudeData ?? null;
1364
+ extrema = synthesized.extrema ?? null;
1365
+ const mimeType = synthesized.mimeType || "audio/mpeg";
1366
+ let blobToCache = null;
1367
+ if (synthesized.audioBlob) {
1368
+ blobToCache = synthesized.audioBlob;
1369
+ } else if (synthesized.audioBuffer) {
1370
+ blobToCache = new Blob([synthesized.audioBuffer], { type: mimeType });
1371
+ }
1372
+ if (blobToCache) {
1373
+ if (cache) {
1374
+ await cache.set(cacheKey, {
1375
+ audioBlob: blobToCache,
1376
+ mimeType,
1377
+ visemes: synthesized.visemes,
1378
+ amplitudeData: synthesized.amplitudeData,
1379
+ extrema: synthesized.extrema
1380
+ });
1381
+ }
1382
+ playbackUrl = URL.createObjectURL(blobToCache);
1383
+ shouldRevokeUrl = true;
1384
+ } else if (synthesized.audioUrl) {
1385
+ playbackUrl = synthesized.audioUrl;
1386
+ }
1387
+ }
1388
+ if (playbackUrl && typeof Audio !== "undefined") {
1389
+ get().setSpokenVisemes(visemes);
1390
+ get().setAmplitudeData(ampData, extrema);
1391
+ const audio = new Audio(playbackUrl);
1392
+ audio.crossOrigin = "anonymous";
1393
+ activeAudio = audio;
1394
+ if (shouldRevokeUrl) {
1395
+ activeObjectUrl = playbackUrl;
1396
+ }
1397
+ analyzer.connect(audio);
1398
+ audio.onplay = () => {
1399
+ if (myGeneration !== activeGeneration) {
1400
+ return;
1401
+ }
1402
+ set({
1403
+ isSpeaking: true,
1404
+ speechStartTime: performance.now()
1405
+ });
1406
+ const pollAmplitude = () => {
1407
+ if (myGeneration === activeGeneration && activeAudio === audio && !audio.paused && !audio.ended) {
1408
+ get().setCurrentAmplitude(analyzer.getAmplitude());
1409
+ if (typeof requestAnimationFrame === "function") {
1410
+ requestAnimationFrame(pollAmplitude);
1411
+ }
1412
+ } else if (myGeneration === activeGeneration) {
1413
+ get().setCurrentAmplitude(0);
1414
+ }
1415
+ };
1416
+ pollAmplitude();
1417
+ };
1418
+ audio.onended = () => {
1419
+ finishGeneration(myGeneration);
1420
+ };
1421
+ audio.onerror = () => {
1422
+ finishGeneration(myGeneration);
1423
+ };
1424
+ await audio.play();
1425
+ return;
1426
+ }
1427
+ } catch (adapterError) {
1428
+ console.warn(
1429
+ "SpeechSynthesizerAdapter failed; falling back to Web Speech API:",
1430
+ adapterError
1431
+ );
1432
+ if (myGeneration !== activeGeneration) {
1433
+ return;
1434
+ }
1435
+ }
1436
+ }
1437
+ if (typeof window === "undefined" || typeof SpeechSynthesisUtterance === "undefined" || typeof window.speechSynthesis === "undefined") {
1438
+ finishGeneration(myGeneration);
1439
+ return;
1440
+ }
1441
+ const utterance = new SpeechSynthesisUtterance(speechText);
1442
+ activeUtterance = utterance;
1443
+ if (isNativeSpeechSynthesisVoice(selectedVoice)) {
1444
+ utterance.voice = selectedVoice;
1445
+ } else {
1446
+ const nativeVoices = window.speechSynthesis.getVoices();
1447
+ const matched = findMatchingVoice(nativeVoices, selectedVoice.voiceURI) || findMatchingVoice(nativeVoices, selectedVoice.name);
1448
+ if (matched) {
1449
+ utterance.voice = matched;
1450
+ }
1451
+ }
1452
+ utterance.lang = selectedVoice.lang || get().faceSettings?.selectedLanguage || "en-US";
1453
+ const estimatedVisemes = estimateVisemesFromText(speechText);
1454
+ set({
1455
+ spokenVisemes: estimatedVisemes,
1456
+ amplitudeData: null,
1457
+ amplitudeExtrema: null,
1458
+ currentAmplitude: 0
1459
+ });
1460
+ utterance.onstart = () => {
1461
+ if (myGeneration !== activeGeneration) {
1462
+ return;
1463
+ }
1464
+ set({
1465
+ isSpeaking: true,
1466
+ speechStartTime: performance.now()
1467
+ });
1468
+ };
1469
+ utterance.onboundary = (event) => {
1470
+ if (myGeneration !== activeGeneration) {
1471
+ return;
1472
+ }
1473
+ if (event.name === "word") {
1474
+ get().setCurrentAmplitude(1);
1475
+ if (activeBoundaryTimer !== null) {
1476
+ clearTimeout(activeBoundaryTimer);
1477
+ }
1478
+ activeBoundaryTimer = setTimeout(() => {
1479
+ if (myGeneration === activeGeneration) {
1480
+ get().setCurrentAmplitude(0);
1481
+ }
1482
+ }, 100);
1483
+ }
1484
+ };
1485
+ utterance.onend = () => {
1486
+ finishGeneration(myGeneration);
1487
+ };
1488
+ utterance.onerror = (event) => {
1489
+ if (event.error === "not-allowed") {
1490
+ get().setSpeechAllowed(false);
1491
+ }
1492
+ finishGeneration(myGeneration);
1493
+ };
1494
+ const invokeSpeak = () => {
1495
+ activeTimer = null;
1496
+ if (myGeneration !== activeGeneration) {
1497
+ return;
1498
+ }
1499
+ try {
1500
+ if (window.speechSynthesis.paused) {
1501
+ window.speechSynthesis.resume();
1502
+ }
1503
+ window.speechSynthesis.speak(utterance);
1504
+ } catch (speakErr) {
1505
+ console.warn("SpeechSynthesis speak invocation error:", speakErr);
1506
+ finishGeneration(myGeneration);
1507
+ }
1508
+ };
1509
+ if (utteranceDeferMs <= 0) {
1510
+ invokeSpeak();
1511
+ } else {
1512
+ activeTimer = setTimeout(invokeSpeak, utteranceDeferMs);
1513
+ }
1514
+ };
1515
+ return {
1516
+ lastMessage: sliceOptions.initialMessage ?? DEFAULT_FACE_MESSAGE,
1517
+ isSpeaking: false,
1518
+ speechAllowed: false,
1519
+ selectedVoiceUri: null,
1520
+ availableVoices: [],
1521
+ spokenVisemes: null,
1522
+ amplitudeData: null,
1523
+ amplitudeExtrema: null,
1524
+ currentAmplitude: 0,
1525
+ speechStartTime: null,
1526
+ speechQueue: [],
1527
+ setSpeechAllowed: (allowed) => {
1528
+ set({ speechAllowed: allowed });
1529
+ },
1530
+ setAvailableVoices: (voices) => {
1531
+ set({ availableVoices: voices });
1532
+ },
1533
+ refreshVoices: async () => {
1534
+ const collected = [];
1535
+ const seen = /* @__PURE__ */ new Set();
1536
+ if (typeof window !== "undefined" && "speechSynthesis" in window) {
1537
+ const browserVoices = window.speechSynthesis.getVoices();
1538
+ for (const v of browserVoices) {
1539
+ if (!seen.has(v.voiceURI)) {
1540
+ seen.add(v.voiceURI);
1541
+ collected.push(v);
1542
+ }
1543
+ }
1544
+ }
1545
+ if (adapter?.fetchVoices) {
1546
+ try {
1547
+ const remoteVoices = await adapter.fetchVoices();
1548
+ for (const v of remoteVoices) {
1549
+ if (!seen.has(v.voiceURI)) {
1550
+ seen.add(v.voiceURI);
1551
+ collected.push(v);
1552
+ }
1553
+ }
1554
+ } catch (err) {
1555
+ console.warn("Failed to fetch adapter voices:", err);
1556
+ }
1557
+ }
1558
+ set({ availableVoices: collected });
1559
+ return collected;
1560
+ },
1561
+ getDefaultVoice: () => {
1562
+ const voices = get().availableVoices;
1563
+ const selectedLang = get().faceSettings?.selectedLanguage;
1564
+ if (selectedLang) {
1565
+ const langVoice = voices.find(
1566
+ (v) => matchesLanguage(v.lang, selectedLang)
1567
+ );
1568
+ if (langVoice) {
1569
+ return langVoice;
1570
+ }
1571
+ }
1572
+ const defaultFlagged = voices.find((v) => v.default === true);
1573
+ if (defaultFlagged) {
1574
+ return defaultFlagged;
1575
+ }
1576
+ if (voices.length > 0) {
1577
+ return voices[0];
1578
+ }
1579
+ return {
1580
+ ...FALLBACK_DEFAULT_VOICE,
1581
+ lang: selectedLang || "en-US"
1582
+ };
1583
+ },
1584
+ getSelectedVoice: () => {
1585
+ const uri = get().selectedVoiceUri;
1586
+ const voices = get().availableVoices;
1587
+ if (uri !== null) {
1588
+ const matched = findMatchingVoice(voices, uri);
1589
+ if (matched) {
1590
+ return matched;
1591
+ }
1592
+ }
1593
+ return get().getDefaultVoice();
1594
+ },
1595
+ setVoice: (voiceUri, voiceOptions) => {
1596
+ const prevVoice = get().selectedVoiceUri || get().getSelectedVoice()?.voiceURI;
1597
+ set({ selectedVoiceUri: voiceUri });
1598
+ if (!sliceOptions.isSilent && !voiceOptions?.silent && prevVoice && prevVoice !== voiceUri) {
1599
+ void get().express({
1600
+ title: "Switching voice",
1601
+ speech: "Switching voice",
1602
+ color: "Light Blue",
1603
+ emotion: "Neutral"
1604
+ });
1605
+ }
1606
+ },
1607
+ setSpokenVisemes: (visemes) => {
1608
+ set({ spokenVisemes: visemes });
1609
+ },
1610
+ setAmplitudeData: (data, extrema) => {
1611
+ set({
1612
+ amplitudeData: data,
1613
+ amplitudeExtrema: extrema
1614
+ });
1615
+ },
1616
+ setIsSpeaking: (isSpeaking) => {
1617
+ set({ isSpeaking });
1618
+ },
1619
+ setCurrentAmplitude: (amplitude) => {
1620
+ const gain = get().faceSettings?.amplitudeGain ?? 1;
1621
+ const scaled = amplitude * gain;
1622
+ const clamped = Number.isNaN(scaled) ? 0 : Math.min(1, Math.max(0, scaled));
1623
+ set({ currentAmplitude: clamped });
1624
+ },
1625
+ setSpeechAdapter: (nextAdapter) => {
1626
+ adapter = nextAdapter;
1627
+ },
1628
+ express: expressImpl,
1629
+ _express: expressImpl,
1630
+ updateLastMessage: async (message) => {
1631
+ await get().express(message);
1632
+ },
1633
+ stopSpeech: () => {
1634
+ cleanupActivePlayback();
1635
+ set({
1636
+ isSpeaking: false,
1637
+ speechStartTime: null,
1638
+ currentAmplitude: 0,
1639
+ spokenVisemes: null,
1640
+ amplitudeData: null,
1641
+ amplitudeExtrema: null,
1642
+ speechQueue: []
1643
+ });
1644
+ }
1645
+ };
1646
+ };
1647
+ }
1648
+ var FALLBACK_DEFAULT_VOICE;
1649
+ var init_faceSpeechSlice = __esm({
1650
+ "src/store/faceSpeechSlice.ts"() {
1651
+ "use strict";
1652
+ init_face();
1653
+ init_voice_helpers();
1654
+ init_viseme_mapper();
1655
+ init_AudioAnalyzer();
1656
+ init_ttsAudioCache();
1657
+ FALLBACK_DEFAULT_VOICE = {
1658
+ default: false,
1659
+ lang: "en-US",
1660
+ localService: false,
1661
+ name: "en-US-Standard-B",
1662
+ voiceURI: "en-US-Standard-B"
1663
+ };
1664
+ }
1665
+ });
1666
+
1667
+ // src/store/createPeerbotsFaceStore.ts
1668
+ function restorePersistedFace(persistedSelection, builtIns, fallback) {
1669
+ if (typeof persistedSelection === "string") {
1670
+ return builtIns.find((f) => f.name === persistedSelection) ?? fallback;
1671
+ }
1672
+ if (persistedSelection && typeof persistedSelection === "object") {
1673
+ const selectionObj = persistedSelection;
1674
+ if (typeof selectionObj.name === "string") {
1675
+ const found = builtIns.find((f) => f.name === selectionObj.name);
1676
+ if (found) {
1677
+ if (found.kind === "Vizij" && selectionObj.assetBundle && typeof selectionObj.assetBundle === "object") {
1678
+ const persistedBundle = selectionObj.assetBundle;
1679
+ const persistedGlb = persistedBundle.glb && typeof persistedBundle.glb === "object" ? persistedBundle.glb : {};
1680
+ return {
1681
+ ...found,
1682
+ assetBundle: {
1683
+ ...found.assetBundle,
1684
+ ...persistedBundle,
1685
+ glb: {
1686
+ ...found.assetBundle.glb,
1687
+ ...persistedGlb
1688
+ }
1689
+ }
1690
+ };
1691
+ }
1692
+ return found;
1693
+ }
1694
+ if (typeof selectionObj.kind === "string") {
1695
+ return persistedSelection;
1696
+ }
1697
+ }
1698
+ }
1699
+ return fallback;
1700
+ }
1701
+ function createPeerbotsFaceStore(options = {}) {
1702
+ const stateInitializer = (...args) => ({
1703
+ ...createFaceRenderingSlice(options)(...args),
1704
+ ...createFaceSpeechSlice(options)(...args)
1705
+ });
1706
+ if (!options.persistName) {
1707
+ return (0, import_zustand.createStore)()(stateInitializer);
1708
+ }
1709
+ const builtIns = createBuiltInFaces(options.assetBaseUrl);
1710
+ const fallbackFace = options.initialFace ?? builtIns[0];
1711
+ return (0, import_zustand.createStore)()(
1712
+ (0, import_middleware.persist)(stateInitializer, {
1713
+ name: options.persistName,
1714
+ version: 1,
1715
+ partialize: (state) => ({
1716
+ selectedFace: state.selectedFace,
1717
+ faceSettings: state.faceSettings,
1718
+ selectedVoiceUri: state.selectedVoiceUri,
1719
+ lastMessage: state.lastMessage
1720
+ }),
1721
+ merge: (persistedState, currentState) => {
1722
+ const persisted = persistedState ?? {};
1723
+ const restoredFace = restorePersistedFace(
1724
+ persisted.selectedFace,
1725
+ currentState.availableFaces,
1726
+ fallbackFace
1727
+ );
1728
+ const restoredSettings = persisted.faceSettings ? mergeFaceSettings(
1729
+ defaultFaceSettings,
1730
+ persisted.faceSettings
1731
+ ) : currentState.faceSettings;
1732
+ return {
1733
+ ...currentState,
1734
+ selectedFace: restoredFace,
1735
+ selectedVoiceUri: persisted.selectedVoiceUri ?? null,
1736
+ faceSettings: restoredSettings,
1737
+ lastMessage: persisted.lastMessage ?? options.initialMessage ?? DEFAULT_FACE_MESSAGE,
1738
+ isSpeaking: false
1739
+ };
1740
+ }
1741
+ })
1742
+ );
1743
+ }
1744
+ var import_zustand, import_middleware, globalFaceStore;
1745
+ var init_createPeerbotsFaceStore = __esm({
1746
+ "src/store/createPeerbotsFaceStore.ts"() {
1747
+ "use strict";
1748
+ import_zustand = require("zustand");
1749
+ import_middleware = require("zustand/middleware");
1750
+ init_face();
1751
+ init_faceRenderingSlice();
1752
+ init_faceSpeechSlice();
1753
+ globalFaceStore = createPeerbotsFaceStore({
1754
+ persistName: "faceSettings"
1755
+ });
1756
+ }
1757
+ });
1758
+
1759
+ // src/store/FaceStoreContext.tsx
1760
+ function FaceStoreProvider({
1761
+ children,
1762
+ store,
1763
+ options
1764
+ }) {
1765
+ const [internalStore] = (0, import_react2.useState)(
1766
+ () => store ?? createPeerbotsFaceStore(options)
1767
+ );
1768
+ const resolvedStore = store ?? internalStore;
1769
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FaceStoreContext.Provider, { value: resolvedStore, children });
1770
+ }
1771
+ function setGlobalFaceStore(store) {
1772
+ activeGlobalFaceStore = store;
1773
+ }
1774
+ function getGlobalFaceStore() {
1775
+ return activeGlobalFaceStore;
1776
+ }
1777
+ function useFaceStoreInstance() {
1778
+ const context = (0, import_react2.useContext)(FaceStoreContext);
1779
+ return context ?? activeGlobalFaceStore;
1780
+ }
1781
+ function useFaceStoreBase(selector) {
1782
+ const store = useFaceStoreInstance();
1783
+ return (0, import_zustand2.useStore)(store, selector);
1784
+ }
1785
+ var import_react2, import_zustand2, import_jsx_runtime, FaceStoreContext, activeGlobalFaceStore, useFaceStore;
1786
+ var init_FaceStoreContext = __esm({
1787
+ "src/store/FaceStoreContext.tsx"() {
1788
+ "use strict";
1789
+ import_react2 = require("react");
1790
+ import_zustand2 = require("zustand");
1791
+ init_createPeerbotsFaceStore();
1792
+ import_jsx_runtime = require("react/jsx-runtime");
1793
+ FaceStoreContext = (0, import_react2.createContext)(null);
1794
+ activeGlobalFaceStore = globalFaceStore;
1795
+ useFaceStore = Object.assign(useFaceStoreBase, {
1796
+ getState: () => activeGlobalFaceStore.getState(),
1797
+ setState: ((...args) => activeGlobalFaceStore.setState(...args)),
1798
+ subscribe: ((...args) => activeGlobalFaceStore.subscribe(...args))
1799
+ });
1800
+ }
1801
+ });
1802
+
1803
+ // src/components/FaceEyes.tsx
1804
+ function FaceEyes({
1805
+ scale,
1806
+ frozen = false
1807
+ }) {
1808
+ const message = useFaceStore((state) => state.lastMessage);
1809
+ const face = useFaceStore((state) => state.selectedFace);
1810
+ const gaze = useFaceStore((state) => state.gaze);
1811
+ const pixiSettings = useFaceStore((state) => state.faceSettings.pixiSettings);
1812
+ (0, import_react4.useExtend)({ Container: import_pixi.Container, Sprite: import_pixi.Sprite, Graphics: import_pixi.Graphics });
1813
+ const [faceSheet, setFaceSheet] = (0, import_react5.useState)(null);
1814
+ const [cheekTexture, setCheekTexture] = (0, import_react5.useState)(null);
1815
+ const [eyeBrows, setEyeBrows] = (0, import_react5.useState)("Hugo");
1816
+ const leftEyeTexture = (0, import_react5.useMemo)(() => {
1817
+ if (!faceSheet) return import_pixi.Texture.EMPTY;
1818
+ const emotion = message?.emotion || "Neutral";
1819
+ return faceSheet.textures?.[`${emotion.toLowerCase()}_l.png`] || faceSheet.textures?.["neutral_l.png"] || import_pixi.Texture.EMPTY;
1820
+ }, [message, faceSheet]);
1821
+ const rightEyeTexture = (0, import_react5.useMemo)(() => {
1822
+ if (!faceSheet) return import_pixi.Texture.EMPTY;
1823
+ const emotion = message?.emotion || "Neutral";
1824
+ return faceSheet.textures?.[`${emotion.toLowerCase()}_r.png`] || faceSheet.textures?.["neutral_r.png"] || import_pixi.Texture.EMPTY;
1825
+ }, [message, faceSheet]);
1826
+ const breathingScaleRef = (0, import_react5.useRef)(1);
1827
+ const breathingTimeRef = (0, import_react5.useRef)(0);
1828
+ const blinkScaleRef = (0, import_react5.useRef)(1);
1829
+ const isBlinkingRef = (0, import_react5.useRef)(false);
1830
+ const blinkEveryRef = (0, import_react5.useRef)(500);
1831
+ const blinkTimerRef = (0, import_react5.useRef)(0);
1832
+ const blinkTargetScaleRef = (0, import_react5.useRef)(1);
1833
+ const currentGazeRef = (0, import_react5.useRef)({ x: 0, y: 0 });
1834
+ const leftEyeContainerRef = (0, import_react5.useRef)(null);
1835
+ const rightEyeContainerRef = (0, import_react5.useRef)(null);
1836
+ const leftEyebrowRef = (0, import_react5.useRef)(null);
1837
+ const rightEyebrowRef = (0, import_react5.useRef)(null);
1838
+ const leftEyeSpriteRef = (0, import_react5.useRef)(null);
1839
+ const rightEyeSpriteRef = (0, import_react5.useRef)(null);
1840
+ const leftCheekRef = (0, import_react5.useRef)(null);
1841
+ const rightCheekRef = (0, import_react5.useRef)(null);
1842
+ const positions = (0, import_react5.useMemo)(() => {
1843
+ return {
1844
+ leftEyeX: -300 * scale,
1845
+ rightEyeX: 300 * scale,
1846
+ leftEyeY: 0,
1847
+ rightEyeY: 0,
1848
+ leftEyeToRightEyeScaleRatio: 1.1,
1849
+ cheekYOffset: 150 * scale,
1850
+ eyebrowMultiplier: 7.5 * scale,
1851
+ eyebrowOffset: -180 * scale
1852
+ };
1853
+ }, [scale]);
1854
+ (0, import_react4.useTick)((ticker) => {
1855
+ const deltaTime = frozen ? 0 : ticker.deltaTime;
1856
+ const frequency = 785e-5;
1857
+ breathingTimeRef.current += deltaTime;
1858
+ breathingScaleRef.current = 1 + 0.1 * Math.sin(breathingTimeRef.current * frequency);
1859
+ const blinkDuration = 20;
1860
+ const blinkSpeed = 0.5;
1861
+ blinkTimerRef.current += deltaTime;
1862
+ if (isBlinkingRef.current) {
1863
+ if (blinkTimerRef.current > blinkDuration) {
1864
+ blinkEveryRef.current = 200 + Math.random() * 400;
1865
+ blinkTargetScaleRef.current = 1;
1866
+ isBlinkingRef.current = false;
1867
+ blinkTimerRef.current = 0;
1868
+ }
1869
+ } else if (blinkTimerRef.current > blinkEveryRef.current) {
1870
+ blinkTargetScaleRef.current = 0.05;
1871
+ isBlinkingRef.current = true;
1872
+ blinkTimerRef.current = 0;
1873
+ }
1874
+ blinkScaleRef.current += (blinkTargetScaleRef.current - blinkScaleRef.current) * blinkSpeed * deltaTime;
1875
+ currentGazeRef.current.x += (gaze.x - currentGazeRef.current.x) * 0.15;
1876
+ currentGazeRef.current.y += (gaze.y - currentGazeRef.current.y) * 0.15;
1877
+ const gazeOffsetX = currentGazeRef.current.x * 40 * scale;
1878
+ const gazeOffsetY = currentGazeRef.current.y * 30 * scale;
1879
+ if (leftEyeContainerRef.current) {
1880
+ leftEyeContainerRef.current.x = positions.leftEyeX + gazeOffsetX;
1881
+ leftEyeContainerRef.current.y = positions.leftEyeY + gazeOffsetY;
1882
+ }
1883
+ if (rightEyeContainerRef.current) {
1884
+ rightEyeContainerRef.current.x = positions.rightEyeX + gazeOffsetX;
1885
+ rightEyeContainerRef.current.y = positions.rightEyeY + gazeOffsetY;
1886
+ }
1887
+ const breathe = breathingScaleRef.current;
1888
+ const blink = blinkScaleRef.current;
1889
+ if (leftEyeSpriteRef.current) {
1890
+ leftEyeSpriteRef.current.scale.x = positions.leftEyeToRightEyeScaleRatio * breathe * scale;
1891
+ leftEyeSpriteRef.current.scale.y = positions.leftEyeToRightEyeScaleRatio * breathe * blink * scale;
1892
+ }
1893
+ if (rightEyeSpriteRef.current) {
1894
+ rightEyeSpriteRef.current.scale.x = 1 * breathe * scale;
1895
+ rightEyeSpriteRef.current.scale.y = 1 * breathe * blink * scale;
1896
+ }
1897
+ if (leftCheekRef.current) {
1898
+ leftCheekRef.current.scale.x = 0.08 * breathe * scale;
1899
+ leftCheekRef.current.scale.y = 0.04 * breathe * scale;
1900
+ }
1901
+ if (rightCheekRef.current) {
1902
+ rightCheekRef.current.scale.x = 0.08 * breathe * scale;
1903
+ rightCheekRef.current.scale.y = 0.04 * breathe * scale;
1904
+ }
1905
+ const strokeWidth = Math.max(1.5, 3 * scale);
1906
+ if (leftEyebrowRef.current) {
1907
+ const g = leftEyebrowRef.current;
1908
+ g.clear();
1909
+ const mult = positions.eyebrowMultiplier * breathe;
1910
+ g.moveTo(EYEBROW_POINTS[0].x * mult, EYEBROW_POINTS[0].y * mult);
1911
+ for (let i = 1; i < EYEBROW_POINTS.length; i++) {
1912
+ g.lineTo(EYEBROW_POINTS[i].x * mult, EYEBROW_POINTS[i].y * mult);
1913
+ }
1914
+ g.stroke({
1915
+ width: strokeWidth,
1916
+ color: "black",
1917
+ cap: "round",
1918
+ join: "round"
1919
+ });
1920
+ }
1921
+ if (rightEyebrowRef.current) {
1922
+ const g = rightEyebrowRef.current;
1923
+ g.clear();
1924
+ const mult = positions.eyebrowMultiplier * breathe;
1925
+ g.moveTo(EYEBROW_POINTS[0].x * mult, EYEBROW_POINTS[0].y * mult);
1926
+ for (let i = 1; i < EYEBROW_POINTS.length; i++) {
1927
+ g.lineTo(EYEBROW_POINTS[i].x * mult, EYEBROW_POINTS[i].y * mult);
1928
+ }
1929
+ g.stroke({
1930
+ width: strokeWidth,
1931
+ color: "black",
1932
+ cap: "round",
1933
+ join: "round"
1934
+ });
1935
+ }
1936
+ });
1937
+ const drawEyebrow = (0, import_react5.useCallback)(
1938
+ (g) => {
1939
+ g.clear();
1940
+ const mult = positions.eyebrowMultiplier * breathingScaleRef.current;
1941
+ const strokeWidth = Math.max(1.5, 3 * scale);
1942
+ g.moveTo(EYEBROW_POINTS[0].x * mult, EYEBROW_POINTS[0].y * mult);
1943
+ for (let i = 1; i < EYEBROW_POINTS.length; i++) {
1944
+ g.lineTo(EYEBROW_POINTS[i].x * mult, EYEBROW_POINTS[i].y * mult);
1945
+ }
1946
+ g.stroke({
1947
+ width: strokeWidth,
1948
+ color: "black",
1949
+ cap: "round",
1950
+ join: "round"
1951
+ });
1952
+ },
1953
+ [positions.eyebrowMultiplier, scale]
1954
+ );
1955
+ (0, import_react5.useEffect)(() => {
1956
+ let cancelled = false;
1957
+ async function loadAvatarTextures(currentFace) {
1958
+ if (currentFace?.kind !== "PixiFace" || currentFace.type !== "avatar") {
1959
+ return;
1960
+ }
1961
+ try {
1962
+ if (currentFace.eyes?.kind === "spritesheet") {
1963
+ const sheet = await import_pixi.Assets.load(currentFace.eyes.path);
1964
+ if (!cancelled) {
1965
+ setFaceSheet(sheet);
1966
+ }
1967
+ }
1968
+ if (currentFace.cheeks?.kind === "texture") {
1969
+ const cheek = await import_pixi.Assets.load(currentFace.cheeks.path);
1970
+ if (!cancelled) {
1971
+ setCheekTexture(cheek);
1972
+ }
1973
+ } else if (!cancelled) {
1974
+ setCheekTexture(null);
1975
+ }
1976
+ if (!cancelled) {
1977
+ setEyeBrows(currentFace.eyebrows);
1978
+ }
1979
+ } catch (err) {
1980
+ console.warn("Failed to load PixiFace textures:", err);
1981
+ }
1982
+ }
1983
+ void loadAvatarTextures(face);
1984
+ return () => {
1985
+ cancelled = true;
1986
+ };
1987
+ }, [face]);
1988
+ if (pixiSettings?.eyeDisplay === "none") {
1989
+ return null;
1990
+ }
1991
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1992
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1993
+ "pixiContainer",
1994
+ {
1995
+ ref: leftEyeContainerRef,
1996
+ position: { x: positions.leftEyeX, y: positions.leftEyeY },
1997
+ label: "LeftEyeContainer",
1998
+ children: [
1999
+ eyeBrows === "Hugo" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2000
+ "pixiGraphics",
2001
+ {
2002
+ ref: leftEyebrowRef,
2003
+ label: "LeftEyebrow",
2004
+ position: { x: 0, y: positions.eyebrowOffset },
2005
+ draw: drawEyebrow
2006
+ }
2007
+ ),
2008
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2009
+ "pixiSprite",
2010
+ {
2011
+ ref: leftEyeSpriteRef,
2012
+ label: "LeftEye",
2013
+ anchor: { x: 0.5, y: 0.5 },
2014
+ position: { x: 0, y: 0 },
2015
+ texture: leftEyeTexture,
2016
+ pivot: { x: 0.5, y: 0.5 }
2017
+ }
2018
+ ),
2019
+ cheekTexture && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2020
+ "pixiSprite",
2021
+ {
2022
+ ref: leftCheekRef,
2023
+ label: "LeftCheek",
2024
+ texture: cheekTexture,
2025
+ pivot: { x: 0.5, y: 0.5 },
2026
+ anchor: { x: 0.5, y: 0.5 },
2027
+ position: { x: 0, y: positions.cheekYOffset }
2028
+ }
2029
+ )
2030
+ ]
2031
+ }
2032
+ ),
2033
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2034
+ "pixiContainer",
2035
+ {
2036
+ ref: rightEyeContainerRef,
2037
+ position: { x: positions.rightEyeX, y: positions.rightEyeY },
2038
+ label: "RightEyeContainer",
2039
+ children: [
2040
+ eyeBrows === "Hugo" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2041
+ "pixiGraphics",
2042
+ {
2043
+ ref: rightEyebrowRef,
2044
+ label: "RightEyebrow",
2045
+ position: { x: 0, y: positions.eyebrowOffset },
2046
+ draw: drawEyebrow
2047
+ }
2048
+ ),
2049
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2050
+ "pixiSprite",
2051
+ {
2052
+ ref: rightEyeSpriteRef,
2053
+ label: "RightEye",
2054
+ position: { x: 0, y: 0 },
2055
+ pivot: { x: 0.5, y: 0.5 },
2056
+ anchor: { x: 0.5, y: 0.5 },
2057
+ texture: rightEyeTexture
2058
+ }
2059
+ ),
2060
+ cheekTexture && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2061
+ "pixiSprite",
2062
+ {
2063
+ ref: rightCheekRef,
2064
+ label: "RightCheek",
2065
+ texture: cheekTexture,
2066
+ pivot: { x: 0.5, y: 0.5 },
2067
+ anchor: { x: 0.5, y: 0.5 },
2068
+ position: { x: 0, y: positions.cheekYOffset }
2069
+ }
2070
+ )
2071
+ ]
2072
+ }
2073
+ )
2074
+ ] });
2075
+ }
2076
+ var import_pixi, import_react4, import_react5, import_jsx_runtime5, EYEBROW_POINTS;
2077
+ var init_FaceEyes = __esm({
2078
+ "src/components/FaceEyes.tsx"() {
2079
+ "use strict";
2080
+ import_pixi = require("pixi.js");
2081
+ import_react4 = require("@pixi/react");
2082
+ import_react5 = require("react");
2083
+ init_FaceStoreContext();
2084
+ import_jsx_runtime5 = require("react/jsx-runtime");
2085
+ EYEBROW_POINTS = [
2086
+ { x: -5, y: 2.5 },
2087
+ { x: -4, y: 1.6 },
2088
+ { x: -3, y: 0.9 },
2089
+ { x: -2, y: 0.4 },
2090
+ { x: -1, y: 0.1 },
2091
+ { x: 0, y: 0 },
2092
+ { x: 1, y: 0.1 },
2093
+ { x: 2, y: 0.4 },
2094
+ { x: 3, y: 0.9 },
2095
+ { x: 4, y: 1.6 },
2096
+ { x: 5, y: 2.5 }
2097
+ ];
2098
+ }
2099
+ });
2100
+
2101
+ // src/components/FaceMouth.tsx
2102
+ function FaceMouth({
2103
+ scale,
2104
+ frozen = false
2105
+ }) {
2106
+ (0, import_react7.useExtend)({ Graphics: import_pixi2.Graphics });
2107
+ const talking = useFaceStore((state) => state.isSpeaking);
2108
+ const face = useFaceStore((state) => state.selectedFace);
2109
+ const pixiSettings = useFaceStore((state) => state.faceSettings.pixiSettings);
2110
+ const currentAmplitude = useFaceStore((state) => state.currentAmplitude);
2111
+ const amplitudeData = useFaceStore((state) => state.amplitudeData);
2112
+ const speechStartTime = useFaceStore((state) => state.speechStartTime);
2113
+ const talkingScaleRef = (0, import_react6.useRef)(1);
2114
+ const talkingTimeRef = (0, import_react6.useRef)(0);
2115
+ const talkingShape = (0, import_react6.useMemo)(
2116
+ () => face?.kind === "PixiFace" && face.type === "avatar" ? face.mouth : "Ellipse",
2117
+ [face]
2118
+ );
2119
+ const graphicsRef = (0, import_react6.useRef)(null);
2120
+ const getAmplitudeAtTime = (0, import_react6.useCallback)(
2121
+ (timeMs) => {
2122
+ if (!amplitudeData || amplitudeData.length === 0) return 0;
2123
+ const point = amplitudeData.find((p, i) => {
2124
+ const nextPoint = amplitudeData[i + 1];
2125
+ return p.time <= timeMs && (!nextPoint || nextPoint.time > timeMs);
2126
+ });
2127
+ return point ? point.value : 0;
2128
+ },
2129
+ [amplitudeData]
2130
+ );
2131
+ const drawMouth = (0, import_react6.useCallback)(
2132
+ (graphics) => {
2133
+ graphics.clear();
2134
+ const talkingScale = talkingScaleRef.current;
2135
+ const talkingTime = talkingTimeRef.current;
2136
+ switch (talkingShape) {
2137
+ case "Hugo": {
2138
+ const width = 40 * scale;
2139
+ const smileDepth = 20 * scale;
2140
+ const openHeight = talking ? talkingScale * 30 * scale : 0;
2141
+ const topLipLift = talking ? talkingScale * 10 * scale : 0;
2142
+ const centerY = scale * 240;
2143
+ graphics.moveTo(-width, centerY);
2144
+ graphics.quadraticCurveTo(
2145
+ 0,
2146
+ centerY + smileDepth * 0.5 - topLipLift,
2147
+ width,
2148
+ centerY
2149
+ );
2150
+ graphics.quadraticCurveTo(
2151
+ 0,
2152
+ centerY + smileDepth + openHeight * 1.5,
2153
+ -width,
2154
+ centerY
2155
+ );
2156
+ graphics.fill({ color: "black" });
2157
+ break;
2158
+ }
2159
+ case "Beak": {
2160
+ SMILEY_POINTS.forEach((eachPoint, index) => {
2161
+ const y = talkingScale * (Math.pow(40, 1.1) - Math.pow(Math.abs(eachPoint.x), 1.1)) + scale * 240;
2162
+ if (index === 0) {
2163
+ graphics.moveTo(eachPoint.x, y);
2164
+ }
2165
+ graphics.lineTo(eachPoint.x, y);
2166
+ });
2167
+ graphics.moveTo(SMILEY_POINTS[0].x, -1 * SMILEY_POINTS[0].y);
2168
+ SMILEY_POINTS.forEach((eachPoint, index) => {
2169
+ const y = -1 * talkingScale * (Math.pow(40, 1.1) - Math.pow(Math.abs(eachPoint.x), 1.1)) + scale * 240;
2170
+ if (index === 0) {
2171
+ graphics.moveTo(eachPoint.x, y);
2172
+ }
2173
+ graphics.lineTo(eachPoint.x, y);
2174
+ });
2175
+ break;
2176
+ }
2177
+ case "ZigZag": {
2178
+ ZIG_ZAG_POINTS.forEach((eachPoint, index) => {
2179
+ const x = eachPoint.x - ZIG_ZAG_POINTS[ZIG_ZAG_POINTS.length - 1].x / 2;
2180
+ const y = talking ? Math.sin(talkingTime * 0.3 + index * 5) * (10 * talkingScale) + scale * 240 : eachPoint.y + scale * 240;
2181
+ if (index === 0) {
2182
+ graphics.moveTo(x, y);
2183
+ }
2184
+ graphics.lineTo(x, y);
2185
+ });
2186
+ break;
2187
+ }
2188
+ case "Ellipse":
2189
+ default: {
2190
+ graphics.ellipse(
2191
+ 0,
2192
+ scale * 240,
2193
+ scale * 60,
2194
+ talking ? 2 + talkingScale * scale * 15 : 4
2195
+ );
2196
+ graphics.fill({ color: "black" });
2197
+ break;
2198
+ }
2199
+ }
2200
+ graphics.stroke({ color: "black", width: 2 });
2201
+ },
2202
+ [scale, talking, talkingShape]
2203
+ );
2204
+ (0, import_react7.useTick)((time) => {
2205
+ if (frozen) return;
2206
+ let targetScale;
2207
+ if (talking) {
2208
+ if (currentAmplitude > 0) {
2209
+ targetScale = Math.min(currentAmplitude * 1.5, 1);
2210
+ } else if (amplitudeData && speechStartTime) {
2211
+ const elapsed = performance.now() - speechStartTime;
2212
+ targetScale = Math.min(getAmplitudeAtTime(elapsed) * 1.5, 1);
2213
+ } else {
2214
+ targetScale = Math.abs(Math.sin(time.lastTime * 0.1));
2215
+ }
2216
+ talkingTimeRef.current = time.lastTime;
2217
+ } else {
2218
+ targetScale = 0;
2219
+ }
2220
+ const lerpAlpha = 0.2;
2221
+ talkingScaleRef.current += (targetScale - talkingScaleRef.current) * lerpAlpha;
2222
+ if (graphicsRef.current) {
2223
+ drawMouth(graphicsRef.current);
2224
+ }
2225
+ });
2226
+ if (pixiSettings?.mouthDisplay === "none") return null;
2227
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("pixiGraphics", { ref: graphicsRef, label: "Mouth", draw: drawMouth });
2228
+ }
2229
+ var import_react6, import_pixi2, import_react7, import_jsx_runtime6, ZIG_ZAG_POINTS, SMILEY_POINTS;
2230
+ var init_FaceMouth = __esm({
2231
+ "src/components/FaceMouth.tsx"() {
2232
+ "use strict";
2233
+ import_react6 = require("react");
2234
+ import_pixi2 = require("pixi.js");
2235
+ import_react7 = require("@pixi/react");
2236
+ init_FaceStoreContext();
2237
+ import_jsx_runtime6 = require("react/jsx-runtime");
2238
+ ZIG_ZAG_POINTS = [
2239
+ { x: 0, y: -10 },
2240
+ { x: 10, y: 10 },
2241
+ { x: 20, y: -10 },
2242
+ { x: 30, y: 10 },
2243
+ { x: 40, y: -10 },
2244
+ { x: 50, y: 10 },
2245
+ { x: 60, y: -10 },
2246
+ { x: 70, y: 10 },
2247
+ { x: 80, y: -10 },
2248
+ { x: 90, y: 10 },
2249
+ { x: 100, y: -10 },
2250
+ { x: 110, y: 10 }
2251
+ ];
2252
+ SMILEY_POINTS = [
2253
+ { x: -40, y: 40 },
2254
+ { x: -30, y: 30 },
2255
+ { x: -20, y: 20 },
2256
+ { x: -10, y: 10 },
2257
+ { x: 0, y: 0 },
2258
+ { x: 10, y: 10 },
2259
+ { x: 20, y: 20 },
2260
+ { x: 30, y: 30 },
2261
+ { x: 40, y: 40 }
2262
+ ];
2263
+ }
2264
+ });
2265
+
2266
+ // src/components/FaceText.tsx
2267
+ function FaceText({ scale }) {
2268
+ (0, import_react9.useExtend)({ Text: import_pixi3.Text });
2269
+ const lastMessage = useFaceStore((state) => state.lastMessage);
2270
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
2271
+ const selectedFace = useFaceStore((state) => state.selectedFace);
2272
+ const pixiSettings = useFaceStore((state) => state.faceSettings.pixiSettings);
2273
+ const emotionType = (0, import_react8.useMemo)(() => {
2274
+ if (pixiSettings?.emotionDisplay) {
2275
+ return pixiSettings.emotionDisplay;
2276
+ }
2277
+ if (selectedFace?.kind === "PixiFace" && selectedFace.type === "text") {
2278
+ return selectedFace.showEmotion;
2279
+ }
2280
+ return "emoticon";
2281
+ }, [pixiSettings?.emotionDisplay, selectedFace]);
2282
+ const { displayText, queueMessage, update } = useMessageVisualState(
2283
+ isSpeaking,
2284
+ {
2285
+ msPerChar: MS_PER_CHAR,
2286
+ persistenceDuration: TEXT_PERSISTENCE_DURATION,
2287
+ pauseBeforeNextMsg: PAUSE_BEFORE_NEXT_MSG
2288
+ }
2289
+ );
2290
+ (0, import_react8.useEffect)(() => {
2291
+ queueMessage(lastMessage.speech);
2292
+ }, [lastMessage.speech, queueMessage]);
2293
+ (0, import_react9.useTick)((delta) => {
2294
+ update(delta.deltaMS);
2295
+ });
2296
+ const emotionStyle = (0, import_react8.useMemo)(
2297
+ () => new import_pixi3.TextStyle({
2298
+ fontFamily: FONT_FAMILY,
2299
+ fontSize: Math.max(12, 48 * scale),
2300
+ fill: "black",
2301
+ align: "center"
2302
+ }),
2303
+ [scale]
2304
+ );
2305
+ const bodyStyle = (0, import_react8.useMemo)(
2306
+ () => new import_pixi3.TextStyle({
2307
+ fontFamily: FONT_FAMILY,
2308
+ fontSize: Math.max(12, 48 * scale),
2309
+ fill: "black",
2310
+ align: "center",
2311
+ wordWrap: true,
2312
+ wordWrapWidth: Math.max(200, 800 * scale)
2313
+ }),
2314
+ [scale]
2315
+ );
2316
+ const emotionSymbol = emotionType === "emoji" ? EMOTION_EMOJIS[lastMessage.emotion] : EMOTION_EMOTICONS[lastMessage.emotion];
2317
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2318
+ emotionType !== "none" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2319
+ "pixiText",
2320
+ {
2321
+ anchor: 0.5,
2322
+ x: 0,
2323
+ y: -50 * scale,
2324
+ text: emotionSymbol,
2325
+ style: emotionStyle
2326
+ }
2327
+ ),
2328
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2329
+ "pixiText",
2330
+ {
2331
+ text: displayText,
2332
+ anchor: 0.5,
2333
+ x: 0,
2334
+ y: 0,
2335
+ style: bodyStyle
2336
+ }
2337
+ )
2338
+ ] });
2339
+ }
2340
+ var import_react8, import_pixi3, import_react9, import_jsx_runtime7, FONT_FAMILY, TEXT_PERSISTENCE_DURATION, MS_PER_CHAR, PAUSE_BEFORE_NEXT_MSG;
2341
+ var init_FaceText = __esm({
2342
+ "src/components/FaceText.tsx"() {
2343
+ "use strict";
2344
+ import_react8 = require("react");
2345
+ import_pixi3 = require("pixi.js");
2346
+ import_react9 = require("@pixi/react");
2347
+ init_FaceStoreContext();
2348
+ init_emotion_mapper();
2349
+ init_useMessageVisualState();
2350
+ import_jsx_runtime7 = require("react/jsx-runtime");
2351
+ FONT_FAMILY = "Courier New, Courier, monospace";
2352
+ TEXT_PERSISTENCE_DURATION = 3e3;
2353
+ MS_PER_CHAR = 50;
2354
+ PAUSE_BEFORE_NEXT_MSG = 500;
2355
+ }
2356
+ });
2357
+
2358
+ // src/components/FaceBackground.tsx
2359
+ function createRadialGradientTexture(size) {
2360
+ if (typeof document === "undefined") {
2361
+ return import_pixi4.Texture.EMPTY;
2362
+ }
2363
+ const canvas = document.createElement("canvas");
2364
+ canvas.width = size;
2365
+ canvas.height = size;
2366
+ const ctx = canvas.getContext("2d");
2367
+ if (!ctx) return import_pixi4.Texture.EMPTY;
2368
+ const gradient = ctx.createRadialGradient(
2369
+ size / 2,
2370
+ size / 2,
2371
+ 0,
2372
+ size / 2,
2373
+ size / 2,
2374
+ size / 2
2375
+ );
2376
+ gradient.addColorStop(0, "rgba(255, 255, 255, 0.7)");
2377
+ gradient.addColorStop(0.4, "rgba(255, 255, 255, 0.2)");
2378
+ gradient.addColorStop(1, "rgba(255, 255, 255, 0)");
2379
+ ctx.fillStyle = gradient;
2380
+ ctx.fillRect(0, 0, size, size);
2381
+ return import_pixi4.Texture.from(canvas);
2382
+ }
2383
+ function FaceBackground() {
2384
+ (0, import_react11.useExtend)({ Sprite: import_pixi4.Sprite });
2385
+ const { app, isInitialised } = (0, import_react11.useApplication)();
2386
+ const texture = (0, import_react10.useMemo)(() => createRadialGradientTexture(1024), []);
2387
+ if (!app || !isInitialised || !app.renderer) return null;
2388
+ const screenWidth = app.renderer.screen && app.renderer.screen.width || app.renderer.width || 2e3;
2389
+ const screenHeight = app.renderer.screen && app.renderer.screen.height || app.renderer.height || 2e3;
2390
+ const size = Math.max(screenWidth, screenHeight) * 2;
2391
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2392
+ "pixiSprite",
2393
+ {
2394
+ texture,
2395
+ anchor: 0.5,
2396
+ width: size,
2397
+ height: size,
2398
+ x: 0,
2399
+ y: 0,
2400
+ blendMode: "screen",
2401
+ alpha: 0.5
2402
+ }
2403
+ );
2404
+ }
2405
+ var import_react10, import_pixi4, import_react11, import_jsx_runtime8;
2406
+ var init_FaceBackground = __esm({
2407
+ "src/components/FaceBackground.tsx"() {
2408
+ "use strict";
2409
+ import_react10 = require("react");
2410
+ import_pixi4 = require("pixi.js");
2411
+ import_react11 = require("@pixi/react");
2412
+ import_jsx_runtime8 = require("react/jsx-runtime");
2413
+ }
2414
+ });
2415
+
2416
+ // src/components/FaceContainer.tsx
2417
+ function stepRendererBackgroundColor(renderer, targetHex) {
2418
+ try {
2419
+ const currentHex = renderer.background.color.toHex();
2420
+ if (currentHex.toLowerCase() === targetHex.toLowerCase()) {
2421
+ return;
2422
+ }
2423
+ const interpolated = interpolateColor(currentHex, targetHex, 0.1);
2424
+ if (interpolated !== null) {
2425
+ renderer.background.color = rgbaToHex(interpolated);
2426
+ }
2427
+ } catch (err) {
2428
+ void err;
2429
+ }
2430
+ }
2431
+ function FaceContainer({ frozen = false }) {
2432
+ (0, import_react13.useExtend)({ Container: import_pixi5.Container });
2433
+ const settings = useFaceStore((state) => state.faceSettings);
2434
+ const selectedFace = useFaceStore((state) => state.selectedFace);
2435
+ const lastMessage = useFaceStore((state) => state.lastMessage);
2436
+ const { app, isInitialised } = (0, import_react13.useApplication)();
2437
+ const [layout, setLayout] = (0, import_react12.useState)({
2438
+ landscape: true,
2439
+ scale: 1,
2440
+ x: 400,
2441
+ y: 300
2442
+ });
2443
+ const isAvatar = selectedFace?.kind === "PixiFace" && selectedFace.type === "avatar";
2444
+ (0, import_react12.useEffect)(() => {
2445
+ if (!app || !isInitialised || !app.renderer) return;
2446
+ const updateLayout = () => {
2447
+ if (!app?.renderer) return;
2448
+ const width = app.renderer.screen && app.renderer.screen.width || app.renderer.width || 800;
2449
+ const height = app.renderer.screen && app.renderer.screen.height || app.renderer.height || 600;
2450
+ const isLandscape = width > height;
2451
+ const baseScale = isLandscape ? width / 1200 : height / 1200;
2452
+ const effectiveLandscape = settings.autoRotate ? isLandscape : true;
2453
+ setLayout({
2454
+ landscape: effectiveLandscape,
2455
+ scale: baseScale,
2456
+ x: width / 2,
2457
+ y: height / 2
2458
+ });
2459
+ };
2460
+ updateLayout();
2461
+ const onResize = () => {
2462
+ if (app?.renderer) {
2463
+ updateLayout();
2464
+ }
2465
+ };
2466
+ window.addEventListener("resize", onResize);
2467
+ window.addEventListener("orientationchange", onResize);
2468
+ app.renderer.on("resize", onResize);
2469
+ return () => {
2470
+ window.removeEventListener("resize", onResize);
2471
+ window.removeEventListener("orientationchange", onResize);
2472
+ if (app?.renderer) {
2473
+ app.renderer.off("resize", onResize);
2474
+ }
2475
+ };
2476
+ }, [app, isInitialised, settings.autoRotate]);
2477
+ (0, import_react13.useTick)(() => {
2478
+ if (app?.renderer && lastMessage) {
2479
+ const targetColor = color_mapping[lastMessage.color] ?? color_mapping["Light Blue"];
2480
+ stepRendererBackgroundColor(app.renderer, targetColor);
2481
+ }
2482
+ });
2483
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
2484
+ "pixiContainer",
2485
+ {
2486
+ label: "FaceContainer",
2487
+ position: {
2488
+ x: layout.x + (settings.offset?.x ?? 0),
2489
+ y: layout.y + (settings.offset?.y ?? 0)
2490
+ },
2491
+ pivot: { x: 0.5, y: 0.5 },
2492
+ angle: layout.landscape ? settings.rotation : 90 + settings.rotation,
2493
+ children: [
2494
+ isAvatar && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FaceBackground, {}),
2495
+ selectedFace?.kind === "PixiFace" && selectedFace.type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FaceText, { scale: layout.scale * settings.zoom }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
2496
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FaceEyes, { scale: layout.scale * settings.zoom, frozen }),
2497
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FaceMouth, { scale: layout.scale * settings.zoom, frozen })
2498
+ ] })
2499
+ ]
2500
+ }
2501
+ );
2502
+ }
2503
+ var import_react12, import_pixi5, import_react13, import_jsx_runtime9;
2504
+ var init_FaceContainer = __esm({
2505
+ "src/components/FaceContainer.tsx"() {
2506
+ "use strict";
2507
+ import_react12 = require("react");
2508
+ import_pixi5 = require("pixi.js");
2509
+ import_react13 = require("@pixi/react");
2510
+ init_FaceStoreContext();
2511
+ init_color_mappers();
2512
+ init_FaceEyes();
2513
+ init_FaceMouth();
2514
+ init_FaceText();
2515
+ init_FaceBackground();
2516
+ import_jsx_runtime9 = require("react/jsx-runtime");
2517
+ }
2518
+ });
2519
+
2520
+ // src/components/FaceFullScreenButton.tsx
2521
+ function FaceFullScreenButton() {
2522
+ (0, import_react15.useExtend)({ Graphics: import_pixi6.Graphics, Container: import_pixi6.Container });
2523
+ const { app } = (0, import_react15.useApplication)();
2524
+ const [fullScreen, setFullScreen] = (0, import_react14.useState)(false);
2525
+ (0, import_react14.useEffect)(() => {
2526
+ if (typeof document === "undefined") {
2527
+ return;
2528
+ }
2529
+ const handleFullscreenChange = () => {
2530
+ setFullScreen(Boolean(document.fullscreenElement));
2531
+ };
2532
+ document.addEventListener("fullscreenchange", handleFullscreenChange);
2533
+ return () => {
2534
+ document.removeEventListener("fullscreenchange", handleFullscreenChange);
2535
+ };
2536
+ }, []);
2537
+ const toggleFullScreen = (0, import_react14.useCallback)(() => {
2538
+ if (typeof document === "undefined") {
2539
+ return;
2540
+ }
2541
+ if (fullScreen) {
2542
+ void document.exitFullscreen().catch((err) => {
2543
+ console.warn("Exit fullscreen error:", err);
2544
+ });
2545
+ } else {
2546
+ const container = document.getElementById("face-view-container");
2547
+ if (container) {
2548
+ container.requestFullscreen().catch((err) => {
2549
+ console.warn("Container fullscreen error:", err);
2550
+ if (app?.canvas) {
2551
+ void app.canvas.requestFullscreen().catch((canvasErr) => {
2552
+ console.warn("Canvas fullscreen error:", canvasErr);
2553
+ });
2554
+ }
2555
+ });
2556
+ } else if (app?.canvas) {
2557
+ void app.canvas.requestFullscreen().catch((err) => {
2558
+ console.warn("Canvas fullscreen error:", err);
2559
+ });
2560
+ }
2561
+ }
2562
+ }, [app, fullScreen]);
2563
+ const drawIcon = (0, import_react14.useCallback)(
2564
+ (graphics) => {
2565
+ graphics.clear();
2566
+ const pathD = fullScreen ? import_core2.iconPaths.arrowsPointingIn : import_core2.iconPaths.arrowsPointingOut;
2567
+ graphics.svg(`
2568
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="black">
2569
+ <path strokeLinecap="round" strokeLinejoin="round" d="${pathD}" />
2570
+ </svg>
2571
+ `);
2572
+ },
2573
+ [fullScreen]
2574
+ );
2575
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2576
+ "pixiContainer",
2577
+ {
2578
+ label: "FullScreenToggle",
2579
+ x: 20,
2580
+ y: 20,
2581
+ eventMode: "static",
2582
+ onPointerDown: toggleFullScreen,
2583
+ hitArea: new import_pixi6.Rectangle(0, 0, 50, 50),
2584
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2585
+ "pixiGraphics",
2586
+ {
2587
+ onPointerDown: toggleFullScreen,
2588
+ eventMode: "static",
2589
+ draw: drawIcon
2590
+ }
2591
+ )
2592
+ }
2593
+ );
2594
+ }
2595
+ var import_react14, import_react15, import_pixi6, import_core2, import_jsx_runtime10;
2596
+ var init_FaceFullScreenButton = __esm({
2597
+ "src/components/FaceFullScreenButton.tsx"() {
2598
+ "use strict";
2599
+ import_react14 = require("react");
2600
+ import_react15 = require("@pixi/react");
2601
+ import_pixi6 = require("pixi.js");
2602
+ import_core2 = require("@peerbots/core");
2603
+ import_jsx_runtime10 = require("react/jsx-runtime");
2604
+ }
2605
+ });
2606
+
2607
+ // src/components/FaceScrollToTopButton.tsx
2608
+ function FaceScrollToTopButton() {
2609
+ (0, import_react17.useExtend)({ Graphics: import_pixi7.Graphics, Container: import_pixi7.Container });
2610
+ const [xPos, setXPos] = (0, import_react16.useState)(
2611
+ () => typeof window !== "undefined" ? window.innerWidth - 50 : 750
2612
+ );
2613
+ const scrollToTop = (0, import_react16.useCallback)(() => {
2614
+ if (typeof window !== "undefined") {
2615
+ window.scrollTo(0, 0);
2616
+ }
2617
+ }, []);
2618
+ (0, import_react16.useLayoutEffect)(() => {
2619
+ if (typeof window === "undefined") {
2620
+ return;
2621
+ }
2622
+ const calculatePositionBasedOnWindow = () => {
2623
+ setXPos(window.innerWidth - 50);
2624
+ };
2625
+ const orientation = typeof screen !== "undefined" ? screen.orientation : void 0;
2626
+ orientation?.addEventListener("change", calculatePositionBasedOnWindow);
2627
+ window.addEventListener("resize", calculatePositionBasedOnWindow);
2628
+ return () => {
2629
+ orientation?.removeEventListener("change", calculatePositionBasedOnWindow);
2630
+ window.removeEventListener("resize", calculatePositionBasedOnWindow);
2631
+ };
2632
+ }, []);
2633
+ const drawChevron = (0, import_react16.useCallback)((graphics) => {
2634
+ graphics.clear();
2635
+ graphics.svg(`
2636
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth="1.5" stroke="black">
2637
+ <path strokeLinecap="round" strokeLinejoin="round" d="${import_core3.iconPaths.chevronUpSmall}" />
2638
+ </svg>
2639
+ `);
2640
+ }, []);
2641
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2642
+ "pixiContainer",
2643
+ {
2644
+ label: "ScrollToTopButton",
2645
+ x: xPos,
2646
+ y: 20,
2647
+ eventMode: "static",
2648
+ onPointerDown: scrollToTop,
2649
+ hitArea: new import_pixi7.Rectangle(0, 0, 50, 50),
2650
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
2651
+ "pixiGraphics",
2652
+ {
2653
+ onPointerDown: scrollToTop,
2654
+ eventMode: "static",
2655
+ draw: drawChevron
2656
+ }
2657
+ )
2658
+ }
2659
+ );
2660
+ }
2661
+ var import_react16, import_react17, import_pixi7, import_core3, import_jsx_runtime11;
2662
+ var init_FaceScrollToTopButton = __esm({
2663
+ "src/components/FaceScrollToTopButton.tsx"() {
2664
+ "use strict";
2665
+ import_react16 = require("react");
2666
+ import_react17 = require("@pixi/react");
2667
+ import_pixi7 = require("pixi.js");
2668
+ import_core3 = require("@peerbots/core");
2669
+ import_jsx_runtime11 = require("react/jsx-runtime");
2670
+ }
2671
+ });
2672
+
2673
+ // src/components/PixiFaceView.tsx
2674
+ var PixiFaceView_exports = {};
2675
+ __export(PixiFaceView_exports, {
2676
+ FaceBackground: () => FaceBackground,
2677
+ FaceContainer: () => FaceContainer,
2678
+ FaceEyes: () => FaceEyes,
2679
+ FaceFullScreenButton: () => FaceFullScreenButton,
2680
+ FaceMouth: () => FaceMouth,
2681
+ FaceScrollToTopButton: () => FaceScrollToTopButton,
2682
+ FaceText: () => FaceText,
2683
+ PixiFaceView: () => PixiFaceView,
2684
+ default: () => PixiFaceView_default
2685
+ });
2686
+ function PixiFaceView({
2687
+ isPreview = false,
2688
+ frozen = false
2689
+ } = {}) {
2690
+ (0, import_react19.useExtend)({ Container: import_pixi8.Container, Graphics: import_pixi8.Graphics, Sprite: import_pixi8.Sprite, Text: import_pixi8.Text });
2691
+ const settings = useFaceStore((state) => state.faceSettings);
2692
+ const currentStore = useFaceStoreInstance();
2693
+ const [containerEl, setContainerEl] = (0, import_react18.useState)(null);
2694
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2695
+ "div",
2696
+ {
2697
+ ref: setContainerEl,
2698
+ className: "pbf:w-full pbf:h-full pbf:relative pbf:overflow-hidden",
2699
+ "data-testid": "pixi-face-view",
2700
+ children: containerEl ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2701
+ import_react19.Application,
2702
+ {
2703
+ resizeTo: containerEl,
2704
+ backgroundColor: "#ABE3FA",
2705
+ className: "pbf:w-full pbf:h-full pbf:block",
2706
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(FaceStoreContext.Provider, { value: currentStore, children: [
2707
+ !isPreview && settings.showFullScreenButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FaceFullScreenButton, {}),
2708
+ !isPreview && settings.showScrollButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FaceScrollToTopButton, {}),
2709
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(FaceContainer, { frozen })
2710
+ ] })
2711
+ }
2712
+ ) : null
2713
+ }
2714
+ );
2715
+ }
2716
+ var import_react18, import_react19, import_pixi8, import_jsx_runtime12, PixiFaceView_default;
2717
+ var init_PixiFaceView = __esm({
2718
+ "src/components/PixiFaceView.tsx"() {
2719
+ "use strict";
2720
+ import_react18 = require("react");
2721
+ import_react19 = require("@pixi/react");
2722
+ import_pixi8 = require("pixi.js");
2723
+ init_FaceStoreContext();
2724
+ init_FaceContainer();
2725
+ init_FaceFullScreenButton();
2726
+ init_FaceScrollToTopButton();
2727
+ init_FaceContainer();
2728
+ init_FaceEyes();
2729
+ init_FaceMouth();
2730
+ init_FaceText();
2731
+ init_FaceBackground();
2732
+ init_FaceFullScreenButton();
2733
+ init_FaceScrollToTopButton();
2734
+ import_jsx_runtime12 = require("react/jsx-runtime");
2735
+ PixiFaceView_default = PixiFaceView;
2736
+ }
2737
+ });
2738
+
2739
+ // src/components/VizijFaceView.tsx
2740
+ var VizijFaceView_exports = {};
2741
+ __export(VizijFaceView_exports, {
2742
+ VizijFaceView: () => VizijFaceView,
2743
+ default: () => VizijFaceView_default
2744
+ });
2745
+ function VizijFallback({ labels }) {
2746
+ const { loading, error, ready } = (0, import_runtime_react.useVizijRuntime)();
2747
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:text-white pbf:bg-slate-900 pbf:p-4 pbf:text-sm", children: [
2748
+ (loading || !ready) && !error && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { children: labels.loading }),
2749
+ error && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { children: [
2750
+ labels.vizijErrorPrefix,
2751
+ " ",
2752
+ error.message
2753
+ ] })
2754
+ ] });
2755
+ }
2756
+ function VizijPoseSetter() {
2757
+ const { ready, animateValue, faceId, setInput } = (0, import_runtime_react.useVizijRuntime)();
2758
+ const settings = useFaceStore((state) => state.faceSettings);
2759
+ const lastMessage = useFaceStore((state) => state.lastMessage);
2760
+ const selectedFace = useFaceStore((state) => state.selectedFace);
2761
+ const spokenVisemes = useFaceStore((state) => state.spokenVisemes);
2762
+ const expressEmotion = (0, import_react20.useCallback)(
2763
+ (emotion) => {
2764
+ const expressivity = settings.vizijSettings?.faceExpressivity ?? 1;
2765
+ void animateValue(
2766
+ `rig/${faceId}/emotions/surprise.weight`,
2767
+ (emotion === "Surprised" ? 1 : 0) * expressivity,
2768
+ { duration: 0.2 }
2769
+ );
2770
+ void animateValue(
2771
+ `rig/${faceId}/emotions/happy.weight`,
2772
+ (emotion === "Happy" ? 1 : 0) * expressivity,
2773
+ { duration: 0.2 }
2774
+ );
2775
+ void animateValue(
2776
+ `rig/${faceId}/emotions/sad.weight`,
2777
+ (emotion === "Sad" ? 1 : 0) * expressivity,
2778
+ { duration: 0.2 }
2779
+ );
2780
+ void animateValue(
2781
+ `rig/${faceId}/emotions/concerned.weight`,
2782
+ (emotion === "Concerned" ? 1 : 0) * expressivity,
2783
+ { duration: 0.2 }
2784
+ );
2785
+ void animateValue(
2786
+ `rig/${faceId}/emotions/sleepy.weight`,
2787
+ (emotion === "Sleepy" ? 1 : 0) * expressivity,
2788
+ { duration: 0.2 }
2789
+ );
2790
+ },
2791
+ [animateValue, faceId, settings.vizijSettings?.faceExpressivity]
2792
+ );
2793
+ const expressColor = (0, import_react20.useCallback)(
2794
+ (color) => {
2795
+ const rgbColor = hexToRgb(color_mapping[color]) ?? {
2796
+ r: 0,
2797
+ g: 0,
2798
+ b: 0
2799
+ };
2800
+ void animateValue(`rig/${faceId}/background/color/r`, rgbColor.r / 255, {
2801
+ duration: 0.2
2802
+ });
2803
+ void animateValue(`rig/${faceId}/background/color/g`, rgbColor.g / 255, {
2804
+ duration: 0.2
2805
+ });
2806
+ void animateValue(`rig/${faceId}/background/color/b`, rgbColor.b / 255, {
2807
+ duration: 0.2
2808
+ });
2809
+ },
2810
+ [faceId, animateValue]
2811
+ );
2812
+ const expressViseme = (0, import_react20.useCallback)(
2813
+ (viseme, durationSec, prevViseme) => {
2814
+ const visemeVizijPath = pollyVisemeToVizijPath[viseme];
2815
+ const promises = [];
2816
+ if (viseme === "sil") {
2817
+ possiblePollyVisemes.forEach((target) => {
2818
+ promises.push(
2819
+ animateValue(`rig/${faceId}/visemes/${target}.weight`, 0, {
2820
+ duration: durationSec
2821
+ })
2822
+ );
2823
+ });
2824
+ } else if (visemeVizijPath) {
2825
+ promises.push(
2826
+ animateValue(`rig/${faceId}/visemes/${visemeVizijPath}.weight`, 1, {
2827
+ duration: durationSec
2828
+ })
2829
+ );
2830
+ if (prevViseme) {
2831
+ const prevMappedViseme = pollyVisemeToVizijPath[prevViseme];
2832
+ if (prevMappedViseme && prevMappedViseme !== visemeVizijPath) {
2833
+ promises.push(
2834
+ animateValue(
2835
+ `rig/${faceId}/visemes/${prevMappedViseme}.weight`,
2836
+ 0,
2837
+ { duration: durationSec }
2838
+ )
2839
+ );
2840
+ }
2841
+ }
2842
+ }
2843
+ return Promise.all(promises);
2844
+ },
2845
+ [animateValue, faceId]
2846
+ );
2847
+ const expressTimedVisemes = (0, import_react20.useCallback)(
2848
+ async (visemes) => {
2849
+ let prevViseme;
2850
+ for (const viseme of visemes) {
2851
+ const visemeValue = viseme.value;
2852
+ await expressViseme(visemeValue, viseme.time, prevViseme);
2853
+ prevViseme = visemeValue;
2854
+ }
2855
+ },
2856
+ [expressViseme]
2857
+ );
2858
+ (0, import_react20.useEffect)(() => {
2859
+ if (ready) {
2860
+ expressColor(lastMessage.color);
2861
+ expressEmotion(lastMessage.emotion);
2862
+ }
2863
+ }, [
2864
+ ready,
2865
+ lastMessage.color,
2866
+ lastMessage.emotion,
2867
+ expressColor,
2868
+ expressEmotion
2869
+ ]);
2870
+ (0, import_react20.useEffect)(() => {
2871
+ if (ready && selectedFace?.kind === "Vizij") {
2872
+ setInput(`rig/${faceId}/scene/scale/x`, settings.zoom);
2873
+ setInput(`rig/${faceId}/scene/scale/y`, settings.zoom);
2874
+ setInput(
2875
+ `rig/${faceId}/scene/translation/x`,
2876
+ (settings.offset?.x ?? 0) / 620 - 1
2877
+ );
2878
+ setInput(
2879
+ `rig/${faceId}/scene/translation/y`,
2880
+ (settings.offset?.y ?? 0) / 144 + 1
2881
+ );
2882
+ }
2883
+ }, [ready, selectedFace?.kind, faceId, setInput, settings]);
2884
+ (0, import_react20.useEffect)(() => {
2885
+ if (spokenVisemes !== null && ready) {
2886
+ void expressTimedVisemes(spokenVisemes);
2887
+ }
2888
+ }, [spokenVisemes, ready, expressTimedVisemes]);
2889
+ return null;
2890
+ }
2891
+ function VizijFaceView({ labels } = {}) {
2892
+ const uiLabels = resolveFaceUiLabels(labels);
2893
+ const selectedFace = useFaceStore((state) => state.selectedFace);
2894
+ const settings = useFaceStore((state) => state.faceSettings);
2895
+ if (selectedFace?.kind !== "Vizij") {
2896
+ return null;
2897
+ }
2898
+ const normalizedRot = (settings.rotation % 360 + 360) % 360;
2899
+ const rotClass = ROTATION_CLASS[normalizedRot] ?? ROTATION_CLASS[0];
2900
+ const glb = selectedFace.assetBundle?.glb;
2901
+ const hasGlbUrl = Boolean(glb) && "kind" in glb && glb.kind === "url" && Boolean(glb.src);
2902
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: rotClass, "data-testid": "vizij-face-view", children: hasGlbUrl ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_runtime_react.VizijRuntimeProvider, { assetBundle: selectedFace.assetBundle, autostart: true, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react20.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VizijFallback, { labels: uiLabels }), children: [
2903
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_runtime_react.VizijRuntimeFace, { className: "pbf:bg-black pbf:w-full pbf:h-full" }),
2904
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(VizijPoseSetter, {})
2905
+ ] }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "pbf:flex pbf:items-center pbf:justify-center pbf:h-full pbf:text-white pbf:bg-slate-900 pbf:p-4 pbf:text-sm", children: uiLabels.vizijUploadGlb }) });
2906
+ }
2907
+ var import_react20, import_runtime_react, import_jsx_runtime13, ROTATION_CLASS, VizijFaceView_default;
2908
+ var init_VizijFaceView = __esm({
2909
+ "src/components/VizijFaceView.tsx"() {
2910
+ "use strict";
2911
+ import_react20 = require("react");
2912
+ import_runtime_react = require("@vizij/runtime-react");
2913
+ init_FaceStoreContext();
2914
+ init_viseme_mapper();
2915
+ init_color_mappers();
2916
+ init_labels();
2917
+ import_jsx_runtime13 = require("react/jsx-runtime");
2918
+ ROTATION_CLASS = {
2919
+ 0: "pbf:rotate-0 pbf:w-full pbf:h-full",
2920
+ 90: "pbf:rotate-90 pbf:w-full pbf:h-full",
2921
+ 180: "pbf:rotate-180 pbf:w-full pbf:h-full",
2922
+ 270: "pbf:rotate-270 pbf:w-full pbf:h-full"
2923
+ };
2924
+ VizijFaceView_default = VizijFaceView;
2925
+ }
2926
+ });
2927
+
2928
+ // src/index.ts
2929
+ var src_exports = {};
2930
+ __export(src_exports, {
2931
+ AmplitudeGraph: () => AmplitudeGraph,
2932
+ AudioAnalyzer: () => AudioAnalyzer,
2933
+ CONNECTION_FACE_MESSAGE: () => CONNECTION_FACE_MESSAGE,
2934
+ CharacterSelectionControls: () => CharacterSelectionControls,
2935
+ CharacterSelectionSection: () => CharacterSelectionSection,
2936
+ ControlSettingsSection: () => ControlSettingsSection,
2937
+ DEFAULT_FACE_MESSAGE: () => DEFAULT_FACE_MESSAGE,
2938
+ DEFAULT_FACE_UI_LABELS: () => DEFAULT_FACE_UI_LABELS,
2939
+ EMOTION_EMOJIS: () => EMOTION_EMOJIS,
2940
+ EMOTION_EMOTICONS: () => EMOTION_EMOTICONS,
2941
+ EMOTION_ICON_FILES: () => EMOTION_ICON_FILES,
2942
+ FaceAudioPrompt: () => FaceAudioPrompt,
2943
+ FaceBehaviorControls: () => FaceBehaviorControls,
2944
+ FaceCaption: () => FaceCaption,
2945
+ FacePositioningControls: () => FacePositioningControls,
2946
+ FacePositioningSection: () => FacePositioningSection,
2947
+ FaceRendererRegistry: () => FaceRendererRegistry,
2948
+ FaceSettingsControl: () => FaceSettingsControl,
2949
+ FaceSettingsPanel: () => FaceSettingsPanel,
2950
+ FaceStoreContext: () => FaceStoreContext,
2951
+ FaceStoreProvider: () => FaceStoreProvider,
2952
+ FaceTester: () => FaceTester,
2953
+ FaceTesterSection: () => FaceTesterSection,
2954
+ FaceView: () => FaceView,
2955
+ FaceViewSkeleton: () => FaceViewSkeleton,
2956
+ FieldGroup: () => FieldGroup,
2957
+ PEERBOTS_COLORS: () => PEERBOTS_COLORS,
2958
+ PEERBOTS_EMOTIONS: () => PEERBOTS_EMOTIONS,
2959
+ PoweredByVizij: () => PoweredByVizij,
2960
+ StaticFaceFallback: () => StaticFaceFallback,
2961
+ TtsAudioCache: () => TtsAudioCache,
2962
+ VoiceSelector: () => VoiceSelector,
2963
+ audioAnalyzer: () => audioAnalyzer,
2964
+ availableFaces: () => availableFaces,
2965
+ blobToArrayBuffer: () => blobToArrayBuffer,
2966
+ buildTtsCacheKey: () => buildTtsCacheKey,
2967
+ builtInFaces: () => builtInFaces,
2968
+ color_mapping: () => color_mapping,
2969
+ createBuiltInFaces: () => createBuiltInFaces,
2970
+ createBuiltInPixiFaces: () => createBuiltInPixiFaces,
2971
+ createCustomVizijFace: () => createCustomVizijFace,
2972
+ createDefaultFaceRendererRegistry: () => createDefaultFaceRendererRegistry,
2973
+ createFaceRenderingSlice: () => createFaceRenderingSlice,
2974
+ createFaceSpeechSlice: () => createFaceSpeechSlice,
2975
+ createIncludedVizijFaces: () => createIncludedVizijFaces,
2976
+ createPeerbotsFaceStore: () => createPeerbotsFaceStore,
2977
+ customFace: () => customFace,
2978
+ deconstructRgba: () => deconstructRgba,
2979
+ defaultFace: () => defaultFace,
2980
+ defaultFaceRendererRegistry: () => defaultFaceRendererRegistry,
2981
+ defaultFaceSettings: () => defaultFaceSettings,
2982
+ defaultTtsAudioCache: () => defaultTtsAudioCache,
2983
+ emotion_mapping: () => emotion_mapping,
2984
+ estimateVisemesFromText: () => estimateVisemesFromText,
2985
+ findMatchingVoice: () => findMatchingVoice,
2986
+ font_color_mapping: () => font_color_mapping,
2987
+ formatRbga: () => formatRbga,
2988
+ formatRgba: () => formatRgba,
2989
+ formatVoiceDisplayName: () => formatVoiceDisplayName,
2990
+ getEmotionEyeSpritePaths: () => getEmotionEyeSpritePaths,
2991
+ getEmotionIconPath: () => getEmotionIconPath,
2992
+ getFaceCapabilities: () => getFaceCapabilities,
2993
+ getGlobalFaceStore: () => getGlobalFaceStore,
2994
+ getLanguageName: () => getLanguageName,
2995
+ globalFaceStore: () => globalFaceStore,
2996
+ hexToRgb: () => hexToRgb,
2997
+ hexToRgba: () => hexToRgba,
2998
+ includedVizijFaces: () => includedVizijFaces,
2999
+ interpolateColor: () => interpolateColor,
3000
+ isHeadlessOrTestEnvironment: () => isHeadlessOrTestEnvironment,
3001
+ isWebGLAvailable: () => isWebGLAvailable,
3002
+ mapVisemeToVizijTarget: () => mapVisemeToVizijTarget,
3003
+ mergeFaceSettings: () => mergeFaceSettings,
3004
+ normalizeAssetBaseUrl: () => normalizeAssetBaseUrl,
3005
+ pixiFaceRendererStrategy: () => pixiFaceRendererStrategy,
3006
+ pollyVisemeToVizijPath: () => pollyVisemeToVizijPath,
3007
+ possiblePollyVisemes: () => possiblePollyVisemes,
3008
+ rbgToRgba: () => rbgToRgba,
3009
+ resolveFaceUiLabels: () => resolveFaceUiLabels,
3010
+ rgbToRgba: () => rgbToRgba,
3011
+ rgbaToHex: () => rgbaToHex,
3012
+ setGlobalFaceStore: () => setGlobalFaceStore,
3013
+ stopNativeSpeechSynthesis: () => stopNativeSpeechSynthesis,
3014
+ useFaceStore: () => useFaceStore,
3015
+ useFaceStoreInstance: () => useFaceStoreInstance,
3016
+ useMessageVisualState: () => useMessageVisualState,
3017
+ vizijFaceRendererStrategy: () => vizijFaceRendererStrategy
3018
+ });
3019
+ module.exports = __toCommonJS(src_exports);
3020
+
3021
+ // #style-inject:#style-inject
3022
+ function styleInject(css, { insertAt } = {}) {
3023
+ if (!css || typeof document === "undefined") return;
3024
+ const head = document.head || document.getElementsByTagName("head")[0];
3025
+ const style = document.createElement("style");
3026
+ style.type = "text/css";
3027
+ if (insertAt === "top") {
3028
+ if (head.firstChild) {
3029
+ head.insertBefore(style, head.firstChild);
3030
+ } else {
3031
+ head.appendChild(style);
3032
+ }
3033
+ } else {
3034
+ head.appendChild(style);
3035
+ }
3036
+ if (style.styleSheet) {
3037
+ style.styleSheet.cssText = css;
3038
+ } else {
3039
+ style.appendChild(document.createTextNode(css));
3040
+ }
3041
+ }
3042
+
3043
+ // src/styles/index.css
3044
+ styleInject('/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */\n@layer properties;\n@layer theme, base, components, utilities;\n@layer theme {\n :root,\n :host {\n --pbf-font-sans:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n Roboto,\n "Helvetica Neue",\n "Noto Sans",\n Arial,\n sans-serif,\n "Apple Color Emoji",\n "Segoe UI Emoji",\n "Segoe UI Symbol",\n "Noto Color Emoji";\n --pbf-font-mono:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n --pbf-color-green-400: oklch(79.2% 0.209 151.711);\n --pbf-color-green-500: oklch(72.3% 0.219 149.579);\n --pbf-color-emerald-600: oklch(59.6% 0.145 163.225);\n --pbf-color-teal-700: oklch(51.1% 0.096 186.391);\n --pbf-color-sky-50: oklch(97.7% 0.013 236.62);\n --pbf-color-blue-500: oklch(62.3% 0.214 259.815);\n --pbf-color-blue-600: oklch(54.6% 0.245 262.881);\n --pbf-color-slate-50: oklch(98.4% 0.003 247.858);\n --pbf-color-slate-100: oklch(96.8% 0.007 247.896);\n --pbf-color-slate-300: oklch(86.9% 0.022 252.894);\n --pbf-color-slate-400: oklch(70.4% 0.04 256.788);\n --pbf-color-slate-600: oklch(44.6% 0.043 257.281);\n --pbf-color-slate-700: oklch(37.2% 0.044 257.287);\n --pbf-color-slate-800: oklch(27.9% 0.041 260.031);\n --pbf-color-slate-900: oklch(20.8% 0.042 265.755);\n --pbf-color-gray-50: oklch(98.5% 0.002 247.839);\n --pbf-color-gray-100: oklch(96.7% 0.003 264.542);\n --pbf-color-gray-200: oklch(92.8% 0.006 264.531);\n --pbf-color-gray-500: oklch(55.1% 0.027 264.364);\n --pbf-color-black: #000;\n --pbf-color-white: #fff;\n --pbf-spacing: 0.25rem;\n --pbf-container-lg: 32rem;\n --pbf-container-xl: 36rem;\n --pbf-text-xs: 0.75rem;\n --pbf-text-xs--line-height: calc(1 / 0.75);\n --pbf-text-sm: 0.875rem;\n --pbf-text-sm--line-height: calc(1.25 / 0.875);\n --pbf-text-lg: 1.125rem;\n --pbf-text-lg--line-height: calc(1.75 / 1.125);\n --pbf-text-2xl: 1.5rem;\n --pbf-text-2xl--line-height: calc(2 / 1.5);\n --pbf-text-4xl: 2.25rem;\n --pbf-text-4xl--line-height: calc(2.5 / 2.25);\n --pbf-font-weight-medium: 500;\n --pbf-font-weight-semibold: 600;\n --pbf-font-weight-bold: 700;\n --pbf-tracking-tight: -0.025em;\n --pbf-tracking-wide: 0.025em;\n --pbf-tracking-wider: 0.05em;\n --pbf-leading-tight: 1.25;\n --pbf-radius-md: 0.375rem;\n --pbf-radius-lg: 0.5rem;\n --pbf-ease-out: cubic-bezier(0, 0, 0.2, 1);\n --pbf-animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --pbf-default-transition-duration: 150ms;\n --pbf-default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --pbf-default-font-family: var(--pbf-font-sans);\n --pbf-default-mono-font-family: var(--pbf-font-mono);\n }\n}\n@layer base {\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n }\n html,\n :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n font-family: var(--pbf-default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");\n font-feature-settings: var(--pbf-default-font-feature-settings, normal);\n font-variation-settings: var(--pbf-default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b,\n strong {\n font-weight: bolder;\n }\n code,\n kbd,\n samp,\n pre {\n font-family: var(--pbf-default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);\n font-feature-settings: var(--pbf-default-mono-font-feature-settings, normal);\n font-variation-settings: var(--pbf-default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n sub {\n bottom: -0.25em;\n }\n sup {\n top: -0.5em;\n }\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n progress {\n vertical-align: baseline;\n }\n summary {\n display: list-item;\n }\n ol,\n ul,\n menu {\n list-style: none;\n }\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n vertical-align: middle;\n }\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentcolor;\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n ::-webkit-datetime-edit,\n ::-webkit-datetime-edit-year-field,\n ::-webkit-datetime-edit-month-field,\n ::-webkit-datetime-edit-day-field,\n ::-webkit-datetime-edit-hour-field,\n ::-webkit-datetime-edit-minute-field,\n ::-webkit-datetime-edit-second-field,\n ::-webkit-datetime-edit-millisecond-field,\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button,\n input:where([type=button], [type=reset], [type=submit]),\n ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden=until-found])) {\n display: none !important;\n }\n}\n@layer utilities {\n .pbf\\:pointer-events-none {\n pointer-events: none;\n }\n .pbf\\:absolute {\n position: absolute;\n }\n .pbf\\:fixed {\n position: fixed;\n }\n .pbf\\:relative {\n position: relative;\n }\n .pbf\\:top-1\\/3 {\n top: calc(1 / 3 * 100%);\n }\n .pbf\\:top-4 {\n top: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:left-1\\/2 {\n left: calc(1 / 2 * 100%);\n }\n .pbf\\:z-50 {\n z-index: 50;\n }\n .pbf\\:m-4 {\n margin: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:my-2 {\n margin-block: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:mt-1 {\n margin-top: var(--pbf-spacing);\n }\n .pbf\\:mt-2 {\n margin-top: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:mt-4 {\n margin-top: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:mt-48 {\n margin-top: calc(var(--pbf-spacing) * 48);\n }\n .pbf\\:mb-0 {\n margin-bottom: 0px;\n }\n .pbf\\:mb-1 {\n margin-bottom: var(--pbf-spacing);\n }\n .pbf\\:mb-1\\.5 {\n margin-bottom: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:mb-2 {\n margin-bottom: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:block {\n display: block;\n }\n .pbf\\:flex {\n display: flex;\n }\n .pbf\\:grid {\n display: grid;\n }\n .pbf\\:inline-flex {\n display: inline-flex;\n }\n .pbf\\:h-2 {\n height: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:h-3 {\n height: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:h-3\\.5 {\n height: calc(var(--pbf-spacing) * 3.5);\n }\n .pbf\\:h-4 {\n height: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:h-5 {\n height: calc(var(--pbf-spacing) * 5);\n }\n .pbf\\:h-6 {\n height: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:h-8 {\n height: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:h-16 {\n height: calc(var(--pbf-spacing) * 16);\n }\n .pbf\\:h-20 {\n height: calc(var(--pbf-spacing) * 20);\n }\n .pbf\\:h-full {\n height: 100%;\n }\n .pbf\\:max-h-32 {\n max-height: calc(var(--pbf-spacing) * 32);\n }\n .pbf\\:\\!w-auto {\n width: auto !important;\n }\n .pbf\\:w-2 {\n width: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:w-3 {\n width: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:w-3\\.5 {\n width: calc(var(--pbf-spacing) * 3.5);\n }\n .pbf\\:w-5 {\n width: calc(var(--pbf-spacing) * 5);\n }\n .pbf\\:w-8 {\n width: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:w-14 {\n width: calc(var(--pbf-spacing) * 14);\n }\n .pbf\\:w-16 {\n width: calc(var(--pbf-spacing) * 16);\n }\n .pbf\\:w-20 {\n width: calc(var(--pbf-spacing) * 20);\n }\n .pbf\\:w-24 {\n width: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:w-\\[80\\%\\] {\n width: 80%;\n }\n .pbf\\:w-full {\n width: 100%;\n }\n .pbf\\:max-w-lg {\n max-width: var(--pbf-container-lg);\n }\n .pbf\\:max-w-xl {\n max-width: var(--pbf-container-xl);\n }\n .pbf\\:min-w-0 {\n min-width: 0px;\n }\n .pbf\\:min-w-\\[260px\\] {\n min-width: 260px;\n }\n .pbf\\:min-w-fit {\n min-width: fit-content;\n }\n .pbf\\:flex-1 {\n flex: 1;\n }\n .pbf\\:shrink-0 {\n flex-shrink: 0;\n }\n .pbf\\:-translate-x-1\\/2 {\n --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .pbf\\:rotate-0 {\n rotate: 0deg;\n }\n .pbf\\:rotate-90 {\n rotate: 90deg;\n }\n .pbf\\:rotate-180 {\n rotate: 180deg;\n }\n .pbf\\:rotate-270 {\n rotate: 270deg;\n }\n .pbf\\:animate-ping {\n animation: var(--pbf-animate-ping);\n }\n .pbf\\:cursor-pointer {\n cursor: pointer;\n }\n .pbf\\:grid-cols-1 {\n grid-template-columns: repeat(1, minmax(0, 1fr));\n }\n .pbf\\:grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .pbf\\:flex-col {\n flex-direction: column;\n }\n .pbf\\:flex-row {\n flex-direction: row;\n }\n .pbf\\:flex-wrap {\n flex-wrap: wrap;\n }\n .pbf\\:items-center {\n align-items: center;\n }\n .pbf\\:items-start {\n align-items: flex-start;\n }\n .pbf\\:justify-around {\n justify-content: space-around;\n }\n .pbf\\:justify-between {\n justify-content: space-between;\n }\n .pbf\\:justify-center {\n justify-content: center;\n }\n .pbf\\:gap-0\\.5 {\n gap: calc(var(--pbf-spacing) * 0.5);\n }\n .pbf\\:gap-1 {\n gap: var(--pbf-spacing);\n }\n .pbf\\:gap-1\\.5 {\n gap: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:gap-2 {\n gap: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:gap-3 {\n gap: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:gap-4 {\n gap: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:gap-8 {\n gap: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:gap-16 {\n gap: calc(var(--pbf-spacing) * 16);\n }\n :where(.pbf\\:space-y-3 > :not(:last-child)) {\n --tw-space-y-reverse: 0;\n margin-block-start: calc(calc(var(--pbf-spacing) * 3) * var(--tw-space-y-reverse));\n margin-block-end: calc(calc(var(--pbf-spacing) * 3) * calc(1 - var(--tw-space-y-reverse)));\n }\n :where(.pbf\\:space-y-4 > :not(:last-child)) {\n --tw-space-y-reverse: 0;\n margin-block-start: calc(calc(var(--pbf-spacing) * 4) * var(--tw-space-y-reverse));\n margin-block-end: calc(calc(var(--pbf-spacing) * 4) * calc(1 - var(--tw-space-y-reverse)));\n }\n .pbf\\:gap-x-4 {\n column-gap: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:gap-y-2 {\n row-gap: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:overflow-hidden {\n overflow: hidden;\n }\n .pbf\\:overflow-y-auto {\n overflow-y: auto;\n }\n .pbf\\:rounded {\n border-radius: 0.25rem;\n }\n .pbf\\:rounded-full {\n border-radius: calc(infinity * 1px);\n }\n .pbf\\:rounded-lg {\n border-radius: var(--pbf-radius-lg);\n }\n .pbf\\:rounded-r-md {\n border-top-right-radius: var(--pbf-radius-md);\n border-bottom-right-radius: var(--pbf-radius-md);\n }\n .pbf\\:rounded-b-full {\n border-bottom-right-radius: calc(infinity * 1px);\n border-bottom-left-radius: calc(infinity * 1px);\n }\n .pbf\\:border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .pbf\\:border-t {\n border-top-style: var(--tw-border-style);\n border-top-width: 1px;\n }\n .pbf\\:border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n .pbf\\:border-l-2 {\n border-left-style: var(--tw-border-style);\n border-left-width: 2px;\n }\n .pbf\\:border-gray-100 {\n border-color: var(--pbf-color-gray-100);\n }\n .pbf\\:border-gray-200 {\n border-color: var(--pbf-color-gray-200);\n }\n .pbf\\:border-teal-700\\/30 {\n border-color: var(--pbf-color-teal-700);\n @supports (color: color-mix(in lab, red, red)) {\n border-color: color-mix(in oklab, var(--pbf-color-teal-700) 30%, transparent);\n }\n }\n .pbf\\:bg-black {\n background-color: var(--pbf-color-black);\n }\n .pbf\\:bg-blue-500 {\n background-color: var(--pbf-color-blue-500);\n }\n .pbf\\:bg-emerald-600 {\n background-color: var(--pbf-color-emerald-600);\n }\n .pbf\\:bg-gray-50 {\n background-color: var(--pbf-color-gray-50);\n }\n .pbf\\:bg-gray-200 {\n background-color: var(--pbf-color-gray-200);\n }\n .pbf\\:bg-green-400 {\n background-color: var(--pbf-color-green-400);\n }\n .pbf\\:bg-green-500 {\n background-color: var(--pbf-color-green-500);\n }\n .pbf\\:bg-sky-50 {\n background-color: var(--pbf-color-sky-50);\n }\n .pbf\\:bg-slate-50 {\n background-color: var(--pbf-color-slate-50);\n }\n .pbf\\:bg-slate-100 {\n background-color: var(--pbf-color-slate-100);\n }\n .pbf\\:bg-slate-300 {\n background-color: var(--pbf-color-slate-300);\n }\n .pbf\\:bg-slate-400 {\n background-color: var(--pbf-color-slate-400);\n }\n .pbf\\:bg-slate-900 {\n background-color: var(--pbf-color-slate-900);\n }\n .pbf\\:bg-white {\n background-color: var(--pbf-color-white);\n }\n .pbf\\:object-contain {\n object-fit: contain;\n }\n .pbf\\:p-1\\.5 {\n padding: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:p-2 {\n padding: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:p-4 {\n padding: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:p-6 {\n padding: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:p-8 {\n padding: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:px-3 {\n padding-inline: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:px-4 {\n padding-inline: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:px-12 {\n padding-inline: calc(var(--pbf-spacing) * 12);\n }\n .pbf\\:py-0\\.5 {\n padding-block: calc(var(--pbf-spacing) * 0.5);\n }\n .pbf\\:py-1\\.5 {\n padding-block: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:py-2 {\n padding-block: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:pt-1 {\n padding-top: var(--pbf-spacing);\n }\n .pbf\\:pt-2 {\n padding-top: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:text-center {\n text-align: center;\n }\n .pbf\\:font-mono {\n font-family: var(--pbf-font-mono);\n }\n .pbf\\:font-sans {\n font-family: var(--pbf-font-sans);\n }\n .pbf\\:text-2xl {\n font-size: var(--pbf-text-2xl);\n line-height: var(--tw-leading, var(--pbf-text-2xl--line-height));\n }\n .pbf\\:text-4xl {\n font-size: var(--pbf-text-4xl);\n line-height: var(--tw-leading, var(--pbf-text-4xl--line-height));\n }\n .pbf\\:text-lg {\n font-size: var(--pbf-text-lg);\n line-height: var(--tw-leading, var(--pbf-text-lg--line-height));\n }\n .pbf\\:text-sm {\n font-size: var(--pbf-text-sm);\n line-height: var(--tw-leading, var(--pbf-text-sm--line-height));\n }\n .pbf\\:text-xs {\n font-size: var(--pbf-text-xs);\n line-height: var(--tw-leading, var(--pbf-text-xs--line-height));\n }\n .pbf\\:text-\\[9px\\] {\n font-size: 9px;\n }\n .pbf\\:text-\\[11px\\] {\n font-size: 11px;\n }\n .pbf\\:leading-6 {\n --tw-leading: calc(var(--pbf-spacing) * 6);\n line-height: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:leading-tight {\n --tw-leading: var(--pbf-leading-tight);\n line-height: var(--pbf-leading-tight);\n }\n .pbf\\:font-bold {\n --tw-font-weight: var(--pbf-font-weight-bold);\n font-weight: var(--pbf-font-weight-bold);\n }\n .pbf\\:font-medium {\n --tw-font-weight: var(--pbf-font-weight-medium);\n font-weight: var(--pbf-font-weight-medium);\n }\n .pbf\\:font-semibold {\n --tw-font-weight: var(--pbf-font-weight-semibold);\n font-weight: var(--pbf-font-weight-semibold);\n }\n .pbf\\:tracking-\\[0\\.2em\\] {\n --tw-tracking: 0.2em;\n letter-spacing: 0.2em;\n }\n .pbf\\:tracking-tight {\n --tw-tracking: var(--pbf-tracking-tight);\n letter-spacing: var(--pbf-tracking-tight);\n }\n .pbf\\:tracking-wide {\n --tw-tracking: var(--pbf-tracking-wide);\n letter-spacing: var(--pbf-tracking-wide);\n }\n .pbf\\:tracking-wider {\n --tw-tracking: var(--pbf-tracking-wider);\n letter-spacing: var(--pbf-tracking-wider);\n }\n .pbf\\:break-words {\n overflow-wrap: break-word;\n }\n .pbf\\:whitespace-nowrap {\n white-space: nowrap;\n }\n .pbf\\:text-blue-600 {\n color: var(--pbf-color-blue-600);\n }\n .pbf\\:text-gray-500 {\n color: var(--pbf-color-gray-500);\n }\n .pbf\\:text-slate-600 {\n color: var(--pbf-color-slate-600);\n }\n .pbf\\:text-slate-700 {\n color: var(--pbf-color-slate-700);\n }\n .pbf\\:text-slate-800 {\n color: var(--pbf-color-slate-800);\n }\n .pbf\\:text-slate-900 {\n color: var(--pbf-color-slate-900);\n }\n .pbf\\:text-teal-700 {\n color: var(--pbf-color-teal-700);\n }\n .pbf\\:text-white {\n color: var(--pbf-color-white);\n }\n .pbf\\:uppercase {\n text-transform: uppercase;\n }\n .pbf\\:italic {\n font-style: italic;\n }\n .pbf\\:opacity-75 {\n opacity: 75%;\n }\n .pbf\\:opacity-90 {\n opacity: 90%;\n }\n .pbf\\:shadow-lg {\n --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow),\n var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow),\n var(--tw-ring-shadow),\n var(--tw-shadow);\n }\n .pbf\\:shadow-xl {\n --tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow),\n var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow),\n var(--tw-ring-shadow),\n var(--tw-shadow);\n }\n .pbf\\:transition-all {\n transition-property: all;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:transition-colors {\n transition-property:\n color,\n background-color,\n border-color,\n outline-color,\n text-decoration-color,\n fill,\n stroke,\n --tw-gradient-from,\n --tw-gradient-via,\n --tw-gradient-to;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:transition-transform {\n transition-property:\n transform,\n translate,\n scale,\n rotate;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:duration-75 {\n --tw-duration: 75ms;\n transition-duration: 75ms;\n }\n .pbf\\:duration-150 {\n --tw-duration: 150ms;\n transition-duration: 150ms;\n }\n .pbf\\:duration-200 {\n --tw-duration: 200ms;\n transition-duration: 200ms;\n }\n .pbf\\:duration-300 {\n --tw-duration: 300ms;\n transition-duration: 300ms;\n }\n .pbf\\:ease-out {\n --tw-ease: var(--pbf-ease-out);\n transition-timing-function: var(--pbf-ease-out);\n }\n .pbf\\:select-none {\n -webkit-user-select: none;\n user-select: none;\n }\n @media (hover: hover) {\n :is(:where(.pbf\\:group):hover .pbf\\:group-hover\\:scale-110) {\n --tw-scale-x: 110%;\n --tw-scale-y: 110%;\n --tw-scale-z: 110%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n }\n .pbf\\:last\\:border-0:last-child {\n border-style: var(--tw-border-style);\n border-width: 0px;\n }\n @media (hover: hover) {\n .pbf\\:hover\\:opacity-100:hover {\n opacity: 100%;\n }\n }\n .pbf\\:focus-visible\\:outline-none:focus-visible {\n --tw-outline-style: none;\n outline-style: none;\n }\n @media (width >= 48rem) {\n .pbf\\:md\\:h-12 {\n height: calc(var(--pbf-spacing) * 12);\n }\n .pbf\\:md\\:h-24 {\n height: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:md\\:h-28 {\n height: calc(var(--pbf-spacing) * 28);\n }\n .pbf\\:md\\:w-24 {\n width: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:md\\:w-28 {\n width: calc(var(--pbf-spacing) * 28);\n }\n .pbf\\:md\\:w-32 {\n width: calc(var(--pbf-spacing) * 32);\n }\n .pbf\\:md\\:grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .pbf\\:md\\:gap-24 {\n gap: calc(var(--pbf-spacing) * 24);\n }\n }\n @media (width >= 64rem) {\n .pbf\\:lg\\:grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n .pbf\\:lg\\:gap-6 {\n gap: calc(var(--pbf-spacing) * 6);\n }\n }\n .pbf\\:rtl\\:border-r-2:where(:dir(rtl), [dir=rtl], [dir=rtl] *) {\n border-right-style: var(--tw-border-style);\n border-right-width: 2px;\n }\n .pbf\\:rtl\\:border-l-0:where(:dir(rtl), [dir=rtl], [dir=rtl] *) {\n border-left-style: var(--tw-border-style);\n border-left-width: 0px;\n }\n}\n@property --tw-translate-x { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-translate-y { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-translate-z { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-space-y-reverse { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-border-style { syntax: "*"; inherits: false; initial-value: solid; }\n@property --tw-leading { syntax: "*"; inherits: false; }\n@property --tw-font-weight { syntax: "*"; inherits: false; }\n@property --tw-tracking { syntax: "*"; inherits: false; }\n@property --tw-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-shadow-color { syntax: "*"; inherits: false; }\n@property --tw-shadow-alpha { syntax: "<percentage>"; inherits: false; initial-value: 100%; }\n@property --tw-inset-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-inset-shadow-color { syntax: "*"; inherits: false; }\n@property --tw-inset-shadow-alpha { syntax: "<percentage>"; inherits: false; initial-value: 100%; }\n@property --tw-ring-color { syntax: "*"; inherits: false; }\n@property --tw-ring-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-inset-ring-color { syntax: "*"; inherits: false; }\n@property --tw-inset-ring-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-ring-inset { syntax: "*"; inherits: false; }\n@property --tw-ring-offset-width { syntax: "<length>"; inherits: false; initial-value: 0px; }\n@property --tw-ring-offset-color { syntax: "*"; inherits: false; initial-value: #fff; }\n@property --tw-ring-offset-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-duration { syntax: "*"; inherits: false; }\n@property --tw-ease { syntax: "*"; inherits: false; }\n@property --tw-scale-x { syntax: "*"; inherits: false; initial-value: 1; }\n@property --tw-scale-y { syntax: "*"; inherits: false; initial-value: 1; }\n@property --tw-scale-z { syntax: "*"; inherits: false; initial-value: 1; }\n@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n}\n@layer properties {\n @supports ((-webkit-hyphens: none) and (not (margin-trim: block))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {\n *,\n ::before,\n ::after,\n ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-space-y-reverse: 0;\n --tw-border-style: solid;\n --tw-leading: initial;\n --tw-font-weight: initial;\n --tw-tracking: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-duration: initial;\n --tw-ease: initial;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-scale-z: 1;\n }\n }\n}\n', { insertAt: "top" });
3045
+
3046
+ // src/types/index.ts
3047
+ init_face();
3048
+
3049
+ // src/types/renderer.ts
3050
+ init_face();
3051
+ var FaceRendererRegistry = class {
3052
+ strategies = /* @__PURE__ */ new Map();
3053
+ constructor(initialStrategies = []) {
3054
+ for (const strategy of initialStrategies) {
3055
+ this.register(strategy);
3056
+ }
3057
+ }
3058
+ register(strategy) {
3059
+ this.strategies.set(strategy.kind, strategy);
3060
+ }
3061
+ unregister(kind) {
3062
+ return this.strategies.delete(kind);
3063
+ }
3064
+ get(kind) {
3065
+ return this.strategies.get(kind);
3066
+ }
3067
+ has(kind) {
3068
+ return this.strategies.has(kind);
3069
+ }
3070
+ list() {
3071
+ return Array.from(this.strategies.values());
3072
+ }
3073
+ getCapabilities(face) {
3074
+ if (!face) {
3075
+ return getFaceCapabilities(void 0);
3076
+ }
3077
+ const strategy = this.strategies.get(face.kind);
3078
+ if (strategy?.getCapabilities) {
3079
+ return strategy.getCapabilities(face);
3080
+ }
3081
+ return getFaceCapabilities(face);
3082
+ }
3083
+ };
3084
+
3085
+ // src/types/index.ts
3086
+ init_labels();
3087
+
3088
+ // src/helpers/index.ts
3089
+ init_viseme_mapper();
3090
+ init_emotion_mapper();
3091
+ init_color_mappers();
3092
+ init_voice_helpers();
3093
+
3094
+ // src/helpers/environment.ts
3095
+ function isWebGLAvailable() {
3096
+ if (typeof window === "undefined" || typeof document === "undefined") {
3097
+ return false;
3098
+ }
3099
+ try {
3100
+ const canvas = document.createElement("canvas");
3101
+ const gl = canvas.getContext("webgl2") || canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
3102
+ return Boolean(gl);
3103
+ } catch (err) {
3104
+ void err;
3105
+ return false;
3106
+ }
3107
+ }
3108
+ function isHeadlessOrTestEnvironment() {
3109
+ if (typeof window === "undefined" || typeof navigator === "undefined") {
3110
+ return true;
3111
+ }
3112
+ const ua = navigator.userAgent || "";
3113
+ if (ua.includes("peerbots-pa11y-ci") || ua.toLowerCase().includes("jsdom") || Boolean(navigator.webdriver) || Boolean(window.__VITEST_BROWSER__)) {
3114
+ return true;
3115
+ }
3116
+ return !isWebGLAvailable();
3117
+ }
3118
+
3119
+ // src/services/index.ts
3120
+ init_AudioAnalyzer();
3121
+ init_ttsAudioCache();
3122
+
3123
+ // src/hooks/index.ts
3124
+ init_useMessageVisualState();
3125
+
3126
+ // src/store/index.ts
3127
+ init_faceRenderingSlice();
3128
+ init_faceSpeechSlice();
3129
+ init_createPeerbotsFaceStore();
3130
+ init_FaceStoreContext();
3131
+
3132
+ // src/components/FaceView.tsx
3133
+ var import_react21 = require("react");
3134
+
3135
+ // src/helpers/cn.ts
3136
+ var import_clsx = require("clsx");
3137
+ var import_tailwind_merge = require("tailwind-merge");
3138
+ var faceTwMerge = (0, import_tailwind_merge.extendTailwindMerge)({
3139
+ experimentalParseClassName({ className, parseClassName }) {
3140
+ if (className.startsWith("pbf:")) {
3141
+ return parseClassName(className.slice(4));
3142
+ }
3143
+ if (className.startsWith("pb:")) {
3144
+ return parseClassName(className.slice(3));
3145
+ }
3146
+ return parseClassName(className);
3147
+ }
3148
+ });
3149
+ function faceCn(...inputs) {
3150
+ return faceTwMerge((0, import_clsx.clsx)(inputs));
3151
+ }
3152
+
3153
+ // src/components/FaceView.tsx
3154
+ init_FaceStoreContext();
3155
+ init_face();
3156
+ init_labels();
3157
+
3158
+ // src/components/FaceCaption.tsx
3159
+ var import_react3 = require("react");
3160
+ init_FaceStoreContext();
3161
+ init_useMessageVisualState();
3162
+ var import_jsx_runtime2 = require("react/jsx-runtime");
3163
+ function FaceCaption() {
3164
+ const lastMessage = useFaceStore((state) => state.lastMessage);
3165
+ const settings = useFaceStore((state) => state.faceSettings);
3166
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
3167
+ const { displayText, queueMessage, update } = useMessageVisualState(
3168
+ isSpeaking,
3169
+ {
3170
+ msPerChar: 0,
3171
+ persistenceDuration: 1e3
3172
+ }
3173
+ );
3174
+ (0, import_react3.useEffect)(() => {
3175
+ queueMessage(lastMessage.speech);
3176
+ }, [lastMessage.speech, queueMessage]);
3177
+ (0, import_react3.useEffect)(() => {
3178
+ if (typeof requestAnimationFrame === "undefined") {
3179
+ return;
3180
+ }
3181
+ let lastTime = performance.now();
3182
+ let frameId;
3183
+ const tick = (now) => {
3184
+ const delta = now - lastTime;
3185
+ lastTime = now;
3186
+ update(delta);
3187
+ frameId = requestAnimationFrame(tick);
3188
+ };
3189
+ frameId = requestAnimationFrame(tick);
3190
+ return () => cancelAnimationFrame(frameId);
3191
+ }, [update]);
3192
+ if (!settings.captions || !settings.captions.enabled) {
3193
+ return null;
3194
+ }
3195
+ if (!displayText || displayText.trim() === "") {
3196
+ return null;
3197
+ }
3198
+ const offsetX = settings.captions.offset?.x ?? 0;
3199
+ const offsetY = settings.captions.offset?.y ?? 0;
3200
+ const fontSize = settings.captions.fontSize ?? 32;
3201
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
3202
+ "div",
3203
+ {
3204
+ role: "status",
3205
+ "aria-live": "polite",
3206
+ "data-testid": "face-caption",
3207
+ className: "pbf:absolute pbf:text-center pbf:w-[80%] pbf:pointer-events-none pbf:z-50 pbf:font-sans",
3208
+ style: {
3209
+ top: `calc(${offsetY}% + 80%)`,
3210
+ left: `calc(50% + ${offsetX}px)`,
3211
+ transform: "translate(-50%, -50%)",
3212
+ fontSize: `${fontSize}px`,
3213
+ color: "#ffffff",
3214
+ backgroundColor: "rgba(15, 23, 42, 0.75)",
3215
+ padding: "0.25rem 0.75rem",
3216
+ borderRadius: "0.75rem"
3217
+ },
3218
+ children: displayText
3219
+ }
3220
+ );
3221
+ }
3222
+
3223
+ // src/components/FaceViewSkeleton.tsx
3224
+ var import_core = require("@peerbots/core");
3225
+ var import_jsx_runtime3 = require("react/jsx-runtime");
3226
+ function FaceViewSkeleton({
3227
+ label = "Loading robot face"
3228
+ } = {}) {
3229
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3230
+ "div",
3231
+ {
3232
+ role: "status",
3233
+ "aria-label": label,
3234
+ "data-testid": "face-view-skeleton",
3235
+ className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:bg-sky-50 pbf:p-8 pbf:relative",
3236
+ children: [
3237
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "pbf:flex pbf:w-[80%] pbf:max-w-lg pbf:min-w-[260px] pbf:justify-around pbf:absolute pbf:top-1/3 pbf:px-12", children: [
3238
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.Skeleton, { className: "pbf:w-16 pbf:h-16 pbf:md:w-24 pbf:md:h-24 pbf:rounded-full pbf:bg-slate-300" }),
3239
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.Skeleton, { className: "pbf:w-16 pbf:h-16 pbf:md:w-24 pbf:md:h-24 pbf:rounded-full pbf:bg-slate-300" })
3240
+ ] }),
3241
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "pbf:mt-48", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_core.Skeleton, { className: "pbf:w-24 pbf:h-6 pbf:md:w-32 pbf:md:h-12 pbf:rounded-full pbf:bg-slate-300" }) })
3242
+ ]
3243
+ }
3244
+ );
3245
+ }
3246
+
3247
+ // src/components/StaticFaceFallback.tsx
3248
+ init_FaceStoreContext();
3249
+ init_color_mappers();
3250
+ init_emotion_mapper();
3251
+ var import_jsx_runtime4 = require("react/jsx-runtime");
3252
+ function StaticFaceFallback({
3253
+ showSprites = true,
3254
+ className
3255
+ }) {
3256
+ const selectedFace = useFaceStore((state) => state.selectedFace);
3257
+ const lastMessage = useFaceStore((state) => state.lastMessage);
3258
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
3259
+ const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
3260
+ const faceSettings = useFaceStore((state) => state.faceSettings);
3261
+ const bgColor = color_mapping[lastMessage.color] ?? color_mapping["Light Blue"];
3262
+ const fgColor = font_color_mapping[lastMessage.color] ?? font_color_mapping["Light Blue"];
3263
+ const accessibleLabel = `${selectedFace.name} robot face, emotion ${lastMessage.emotion}, color ${lastMessage.color}${isSpeaking ? ", speaking" : ""}`;
3264
+ const pixiSettings = faceSettings.pixiSettings;
3265
+ const isTextDisplay = selectedFace.kind === "PixiFace" && selectedFace.type === "text";
3266
+ const isHugoStyleAvatar = selectedFace.kind === "PixiFace" && selectedFace.type === "avatar" && (selectedFace.name === "Hugo" || selectedFace.name === "Simple");
3267
+ const eyePaths = getEmotionEyeSpritePaths(
3268
+ lastMessage.emotion,
3269
+ "Hugo",
3270
+ assetBaseUrl
3271
+ );
3272
+ const emotionIconPath = getEmotionIconPath(lastMessage.emotion, assetBaseUrl);
3273
+ const textEmotionMode = pixiSettings?.emotionDisplay ?? (isTextDisplay ? selectedFace.showEmotion : "emoticon");
3274
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3275
+ "div",
3276
+ {
3277
+ role: "img",
3278
+ "aria-label": accessibleLabel,
3279
+ "data-testid": "static-face-fallback",
3280
+ "data-face-name": selectedFace.name,
3281
+ "data-face-kind": selectedFace.kind,
3282
+ "data-emotion": lastMessage.emotion,
3283
+ "data-color": lastMessage.color,
3284
+ "data-speaking": String(isSpeaking),
3285
+ className: faceCn(
3286
+ "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:p-6 pbf:select-none pbf:transition-colors pbf:duration-200",
3287
+ className
3288
+ ),
3289
+ style: {
3290
+ backgroundColor: bgColor,
3291
+ color: fgColor
3292
+ },
3293
+ children: isTextDisplay ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:items-center pbf:gap-3 pbf:font-mono pbf:text-center pbf:max-w-xl", children: [
3294
+ textEmotionMode !== "none" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "pbf:text-4xl pbf:font-bold", "aria-hidden": "true", children: textEmotionMode === "emoji" ? EMOTION_EMOJIS[lastMessage.emotion] : EMOTION_EMOTICONS[lastMessage.emotion] }),
3295
+ lastMessage.speech && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "pbf:text-2xl pbf:font-semibold pbf:break-words", children: lastMessage.speech })
3296
+ ] }) : showSprites && isHugoStyleAvatar ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
3297
+ "div",
3298
+ {
3299
+ className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:gap-8",
3300
+ "aria-hidden": "true",
3301
+ children: [
3302
+ pixiSettings?.eyeDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:justify-center pbf:gap-16 pbf:md:gap-24", children: [
3303
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:items-center", children: [
3304
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3305
+ "img",
3306
+ {
3307
+ src: eyePaths.left,
3308
+ alt: "",
3309
+ className: "pbf:w-20 pbf:h-20 pbf:md:w-28 pbf:md:h-28 pbf:object-contain"
3310
+ }
3311
+ ),
3312
+ selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3313
+ "img",
3314
+ {
3315
+ src: selectedFace.cheeks.path,
3316
+ alt: "",
3317
+ className: "pbf:w-8 pbf:h-4 pbf:object-contain pbf:mt-1"
3318
+ }
3319
+ )
3320
+ ] }),
3321
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:items-center", children: [
3322
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3323
+ "img",
3324
+ {
3325
+ src: eyePaths.right,
3326
+ alt: "",
3327
+ className: "pbf:w-20 pbf:h-20 pbf:md:w-28 pbf:md:h-28 pbf:object-contain"
3328
+ }
3329
+ ),
3330
+ selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3331
+ "img",
3332
+ {
3333
+ src: selectedFace.cheeks.path,
3334
+ alt: "",
3335
+ className: "pbf:w-8 pbf:h-4 pbf:object-contain pbf:mt-1"
3336
+ }
3337
+ )
3338
+ ] })
3339
+ ] }),
3340
+ pixiSettings?.mouthDisplay !== "none" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3341
+ "div",
3342
+ {
3343
+ className: faceCn(
3344
+ "pbf:rounded-b-full pbf:bg-black pbf:transition-all pbf:duration-150",
3345
+ isSpeaking ? "pbf:w-16 pbf:h-8" : "pbf:w-14 pbf:h-3"
3346
+ )
3347
+ }
3348
+ )
3349
+ ]
3350
+ }
3351
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
3352
+ "div",
3353
+ {
3354
+ className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:gap-3",
3355
+ "aria-hidden": "true",
3356
+ children: [
3357
+ showSprites && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
3358
+ "img",
3359
+ {
3360
+ src: emotionIconPath,
3361
+ alt: "",
3362
+ className: "pbf:w-20 pbf:h-20 pbf:object-contain"
3363
+ }
3364
+ ),
3365
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: "pbf:text-sm pbf:font-semibold pbf:tracking-wide", children: [
3366
+ selectedFace.name,
3367
+ " \u2022 ",
3368
+ lastMessage.emotion
3369
+ ] })
3370
+ ]
3371
+ }
3372
+ )
3373
+ }
3374
+ );
3375
+ }
3376
+
3377
+ // src/components/FaceView.tsx
3378
+ var import_jsx_runtime14 = require("react/jsx-runtime");
3379
+ var LazyPixiFaceView = (0, import_react21.lazy)(
3380
+ () => Promise.resolve().then(() => (init_PixiFaceView(), PixiFaceView_exports)).then((module2) => ({
3381
+ default: module2.PixiFaceView
3382
+ }))
3383
+ );
3384
+ var LazyVizijFaceView = (0, import_react21.lazy)(
3385
+ () => Promise.resolve().then(() => (init_VizijFaceView(), VizijFaceView_exports)).then((module2) => ({
3386
+ default: module2.VizijFaceView
3387
+ }))
3388
+ );
3389
+ var pixiFaceRendererStrategy = {
3390
+ kind: "PixiFace",
3391
+ displayName: "PixiJS 2D Face Renderer",
3392
+ requiresWebGL: true,
3393
+ getCapabilities: (face) => getFaceCapabilities(face),
3394
+ render: ({ isPreview, frozen }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LazyPixiFaceView, { isPreview, frozen })
3395
+ };
3396
+ var vizijFaceRendererStrategy = {
3397
+ kind: "Vizij",
3398
+ displayName: "Vizij 3D WebAssembly Face Renderer",
3399
+ requiresWebGL: true,
3400
+ getCapabilities: (face) => getFaceCapabilities(face),
3401
+ render: () => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(LazyVizijFaceView, {})
3402
+ };
3403
+ function createDefaultFaceRendererRegistry() {
3404
+ const registry = new FaceRendererRegistry();
3405
+ registry.register(pixiFaceRendererStrategy);
3406
+ registry.register(vizijFaceRendererStrategy);
3407
+ return registry;
3408
+ }
3409
+ var defaultFaceRendererRegistry = createDefaultFaceRendererRegistry();
3410
+ function FaceView({
3411
+ isPreview = false,
3412
+ frozen = false,
3413
+ renderMode = "auto",
3414
+ showStaticSprites = true,
3415
+ registry = defaultFaceRendererRegistry,
3416
+ labels,
3417
+ className
3418
+ } = {}) {
3419
+ const uiLabels = resolveFaceUiLabels(labels);
3420
+ const selectedFace = useFaceStore((state) => state.selectedFace);
3421
+ const strategy = selectedFace ? registry.get(selectedFace.kind) : void 0;
3422
+ const renderContent = () => {
3423
+ if (!selectedFace || !strategy) {
3424
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
3425
+ "div",
3426
+ {
3427
+ role: "alert",
3428
+ className: "pbf:flex pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:bg-slate-100 pbf:text-slate-800 pbf:text-sm pbf:p-4",
3429
+ children: uiLabels.unknownFaceType
3430
+ }
3431
+ );
3432
+ }
3433
+ const useStaticFallback = renderMode === "static" || renderMode === "auto" && strategy.requiresWebGL && isHeadlessOrTestEnvironment();
3434
+ if (useStaticFallback) {
3435
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(StaticFaceFallback, { showSprites: showStaticSprites });
3436
+ }
3437
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react21.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FaceViewSkeleton, { label: uiLabels.loading }), children: strategy.render({ face: selectedFace, isPreview, frozen }) });
3438
+ };
3439
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
3440
+ "div",
3441
+ {
3442
+ id: "face-view-container",
3443
+ className: faceCn(
3444
+ "pbf:relative pbf:w-full pbf:h-full pbf:text-center pbf:overflow-hidden",
3445
+ className
3446
+ ),
3447
+ children: [
3448
+ renderContent(),
3449
+ !isPreview && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(FaceCaption, {})
3450
+ ]
3451
+ }
3452
+ );
3453
+ }
3454
+
3455
+ // src/components/FaceAudioPrompt.tsx
3456
+ var import_react22 = require("react");
3457
+ var import_core4 = require("@peerbots/core");
3458
+ init_FaceStoreContext();
3459
+ init_labels();
3460
+ var import_jsx_runtime15 = require("react/jsx-runtime");
3461
+ function FaceAudioPrompt({
3462
+ className = "",
3463
+ position = "absolute",
3464
+ labels,
3465
+ onEnable
3466
+ }) {
3467
+ const uiLabels = resolveFaceUiLabels(labels);
3468
+ const speechAllowed = useFaceStore((state) => state.speechAllowed);
3469
+ const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
3470
+ const refreshVoices = useFaceStore((state) => state.refreshVoices);
3471
+ const handleEnableAudio = (0, import_react22.useCallback)(() => {
3472
+ try {
3473
+ if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
3474
+ const utterance = new SpeechSynthesisUtterance(" ");
3475
+ window.speechSynthesis.speak(utterance);
3476
+ }
3477
+ } catch (err) {
3478
+ console.warn("Could not prime speechSynthesis:", err);
3479
+ }
3480
+ setSpeechAllowed(true);
3481
+ void refreshVoices();
3482
+ onEnable?.();
3483
+ }, [setSpeechAllowed, refreshVoices, onEnable]);
3484
+ if (speechAllowed) {
3485
+ return null;
3486
+ }
3487
+ const positionClasses = position === "fixed" ? "pbf:fixed pbf:top-4 pbf:left-1/2 pbf:-translate-x-1/2 pbf:z-50" : position === "absolute" ? "pbf:absolute pbf:top-4 pbf:left-1/2 pbf:-translate-x-1/2 pbf:z-50" : "pbf:inline-flex";
3488
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
3489
+ "div",
3490
+ {
3491
+ className: faceCn(positionClasses, className),
3492
+ "data-testid": "face-audio-prompt",
3493
+ children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
3494
+ import_core4.Button,
3495
+ {
3496
+ variant: "solid",
3497
+ color: "darkblue",
3498
+ size: "sm",
3499
+ onClick: handleEnableAudio,
3500
+ className: "pbf:shadow-lg pbf:px-4 pbf:py-2 pbf:flex pbf:items-center pbf:gap-2 pbf:rounded-full pbf:cursor-pointer",
3501
+ "aria-label": uiLabels.tapToEnableSound,
3502
+ children: [
3503
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_core4.Icon, { name: "play", size: "sm", className: "pbf:w-3.5 pbf:h-3.5" }),
3504
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "pbf:font-semibold pbf:text-xs pbf:tracking-wide", children: uiLabels.tapToEnableSound })
3505
+ ]
3506
+ }
3507
+ )
3508
+ }
3509
+ );
3510
+ }
3511
+
3512
+ // src/components/PoweredByVizij.tsx
3513
+ init_FaceStoreContext();
3514
+ init_labels();
3515
+ var import_jsx_runtime16 = require("react/jsx-runtime");
3516
+ function PoweredByVizij({
3517
+ className,
3518
+ poweredByLabel = DEFAULT_FACE_UI_LABELS.poweredBy
3519
+ }) {
3520
+ const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
3521
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
3522
+ "a",
3523
+ {
3524
+ href: "https://vizij.ai",
3525
+ target: "_blank",
3526
+ rel: "noopener noreferrer",
3527
+ className: faceCn(
3528
+ "pbf:inline-flex pbf:flex-col pbf:items-center pbf:gap-0.5 pbf:group pbf:transition-all pbf:hover:opacity-100 pbf:opacity-90",
3529
+ className
3530
+ ),
3531
+ children: [
3532
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "pbf:text-[9px] pbf:font-bold pbf:text-slate-600 pbf:uppercase pbf:tracking-[0.2em] pbf:leading-tight pbf:select-none", children: poweredByLabel }),
3533
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:gap-1.5 pbf:focus-visible:outline-none", children: [
3534
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "pbf:relative pbf:w-5 pbf:h-5 pbf:group-hover:scale-110 pbf:transition-transform pbf:duration-300 pbf:ease-out", children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3535
+ "img",
3536
+ {
3537
+ src: `${assetBaseUrl}/Vizij/brand.svg`,
3538
+ alt: "Vizij Logo",
3539
+ className: "pbf:w-full pbf:h-full pbf:object-contain"
3540
+ }
3541
+ ) }),
3542
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3543
+ "span",
3544
+ {
3545
+ style: {
3546
+ fontFamily: "Gilroy, SFProRounded, ui-sans-serif, system-ui, sans-serif"
3547
+ },
3548
+ className: "pbf:text-lg pbf:font-bold pbf:tracking-tight pbf:text-teal-700",
3549
+ children: "vizij"
3550
+ }
3551
+ )
3552
+ ] })
3553
+ ]
3554
+ }
3555
+ );
3556
+ }
3557
+
3558
+ // src/components/FieldGroup.tsx
3559
+ var import_react23 = require("react");
3560
+ var import_jsx_runtime17 = require("react/jsx-runtime");
3561
+ function FieldGroup({
3562
+ label,
3563
+ icon,
3564
+ description,
3565
+ children,
3566
+ className,
3567
+ id: customId
3568
+ }) {
3569
+ const generatedId = (0, import_react23.useId)();
3570
+ const labelId = customId || `field-group-${generatedId}`;
3571
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
3572
+ "div",
3573
+ {
3574
+ role: "group",
3575
+ "aria-labelledby": label ? labelId : void 0,
3576
+ className: faceCn("pbf:flex pbf:flex-col pbf:gap-1.5 pbf:w-full", className),
3577
+ children: [
3578
+ label && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
3579
+ "span",
3580
+ {
3581
+ id: labelId,
3582
+ className: "pbf:text-sm pbf:font-bold pbf:leading-6 pbf:text-slate-700 pbf:flex pbf:items-center pbf:gap-1",
3583
+ children: [
3584
+ icon && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "pbf:shrink-0", children: icon }),
3585
+ label
3586
+ ]
3587
+ }
3588
+ ),
3589
+ children,
3590
+ description && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "pbf:text-xs pbf:text-slate-600", children: description })
3591
+ ]
3592
+ }
3593
+ );
3594
+ }
3595
+
3596
+ // src/components/VoiceSelector.tsx
3597
+ var import_react24 = require("react");
3598
+ var import_core5 = require("@peerbots/core");
3599
+ init_voice_helpers();
3600
+ init_labels();
3601
+ var import_jsx_runtime18 = require("react/jsx-runtime");
3602
+ function VoiceSelector({
3603
+ voices,
3604
+ selectedVoiceUri,
3605
+ selectedLanguage,
3606
+ onVoiceChange,
3607
+ onLanguageChange,
3608
+ labels,
3609
+ className
3610
+ }) {
3611
+ const uiLabels = resolveFaceUiLabels(labels);
3612
+ const languages = (0, import_react24.useMemo)(() => {
3613
+ const unique = new Set(
3614
+ voices.map((v) => getLanguageName(v.lang)).filter(Boolean)
3615
+ );
3616
+ if (selectedLanguage && !unique.has(selectedLanguage)) {
3617
+ unique.add(selectedLanguage);
3618
+ }
3619
+ if (unique.size === 0) {
3620
+ unique.add("English");
3621
+ }
3622
+ return Array.from(unique).sort().map((langName) => ({
3623
+ label: langName,
3624
+ value: langName
3625
+ }));
3626
+ }, [voices, selectedLanguage]);
3627
+ const filteredVoices = (0, import_react24.useMemo)(() => {
3628
+ const list = voices.filter(
3629
+ (v) => !selectedLanguage || getLanguageName(v.lang) === selectedLanguage
3630
+ ).map((v) => ({
3631
+ displayName: formatVoiceDisplayName(v.name || v.voiceURI),
3632
+ voiceURI: v.voiceURI
3633
+ })).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((voice) => ({
3634
+ label: voice.displayName,
3635
+ value: voice.voiceURI
3636
+ }));
3637
+ if (list.length === 0) {
3638
+ return [
3639
+ {
3640
+ label: "System Default Voice",
3641
+ value: selectedVoiceUri || "default"
3642
+ }
3643
+ ];
3644
+ }
3645
+ return list;
3646
+ }, [voices, selectedLanguage, selectedVoiceUri]);
3647
+ const activeVoiceValue = (0, import_react24.useMemo)(() => {
3648
+ if (!selectedVoiceUri) {
3649
+ return filteredVoices[0]?.value ?? "";
3650
+ }
3651
+ const matched = findMatchingVoice(
3652
+ filteredVoices.map((v) => ({ name: v.label, voiceURI: v.value })),
3653
+ selectedVoiceUri
3654
+ );
3655
+ return matched ? matched.voiceURI : selectedVoiceUri;
3656
+ }, [selectedVoiceUri, filteredVoices]);
3657
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: faceCn("pbf:flex pbf:flex-col pbf:gap-3", className), children: [
3658
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_core5.Field, { label: uiLabels.voiceSelectorLanguage, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3659
+ import_core5.Select,
3660
+ {
3661
+ "aria-label": uiLabels.voiceSelectorLanguage,
3662
+ className: "pbf:w-full",
3663
+ value: selectedLanguage || languages[0]?.value || "English",
3664
+ onChange: (val) => {
3665
+ if (val && onLanguageChange) {
3666
+ onLanguageChange(String(val));
3667
+ }
3668
+ },
3669
+ options: languages
3670
+ }
3671
+ ) }),
3672
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_core5.Field, { label: uiLabels.voiceSelectorVoice, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3673
+ import_core5.Select,
3674
+ {
3675
+ "aria-label": uiLabels.voiceSelectorVoice,
3676
+ className: "pbf:w-full",
3677
+ value: activeVoiceValue,
3678
+ onChange: (val) => {
3679
+ if (val) {
3680
+ onVoiceChange(String(val));
3681
+ }
3682
+ },
3683
+ options: filteredVoices
3684
+ }
3685
+ ) })
3686
+ ] });
3687
+ }
3688
+
3689
+ // src/components/CharacterSelectionControls.tsx
3690
+ var import_core6 = require("@peerbots/core");
3691
+ init_face();
3692
+ init_labels();
3693
+ init_FaceStoreContext();
3694
+ init_voice_helpers();
3695
+ var import_jsx_runtime19 = require("react/jsx-runtime");
3696
+ function CharacterSelectionControls({
3697
+ enableVizij = true,
3698
+ labels
3699
+ } = {}) {
3700
+ const uiLabels = resolveFaceUiLabels(labels);
3701
+ const faceSettings = useFaceStore((state) => state.faceSettings);
3702
+ const availableFaces2 = useFaceStore((state) => state.availableFaces);
3703
+ const availableVoices = useFaceStore((state) => state.availableVoices);
3704
+ const refreshVoices = useFaceStore((state) => state.refreshVoices);
3705
+ const selectedFace = useFaceStore((state) => state.selectedFace);
3706
+ const getSelectedVoice = useFaceStore((state) => state.getSelectedVoice);
3707
+ const selectedVoiceUri = useFaceStore((state) => state.selectedVoiceUri);
3708
+ const setLanguage = useFaceStore((state) => state.setLanguage);
3709
+ const setVoice = useFaceStore((state) => state.setVoice);
3710
+ const setFace = useFaceStore((state) => state.setFace);
3711
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
3712
+ const speechAllowed = useFaceStore((state) => state.speechAllowed);
3713
+ const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
3714
+ const currentVoiceUri = selectedVoiceUri || getSelectedVoice()?.voiceURI || "";
3715
+ const selectableFaces = enableVizij ? availableFaces2 : availableFaces2.filter((f) => f.kind !== "Vizij");
3716
+ const caps = getFaceCapabilities(selectedFace);
3717
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.SettingsPanel, { title: uiLabels.characterSelection, headingLevel: 4, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:space-y-4", children: [
3718
+ !speechAllowed && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
3719
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "pbf:flex", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3720
+ import_core6.Button,
3721
+ {
3722
+ variant: "solid",
3723
+ color: "darkblue",
3724
+ size: "sm",
3725
+ onClick: () => {
3726
+ try {
3727
+ if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
3728
+ const utterance = new SpeechSynthesisUtterance(" ");
3729
+ window.speechSynthesis.speak(utterance);
3730
+ }
3731
+ } catch (err) {
3732
+ console.warn("SpeechSynthesis prime warning:", err);
3733
+ }
3734
+ setSpeechAllowed(true);
3735
+ void refreshVoices();
3736
+ },
3737
+ children: uiLabels.allowSpeech
3738
+ }
3739
+ ) }),
3740
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.Separator, {})
3741
+ ] }),
3742
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3743
+ VoiceSelector,
3744
+ {
3745
+ voices: availableVoices,
3746
+ selectedVoiceUri: currentVoiceUri,
3747
+ selectedLanguage: faceSettings.selectedLanguage,
3748
+ labels: uiLabels,
3749
+ onLanguageChange: (newLang) => {
3750
+ setLanguage(newLang);
3751
+ const firstVoice = availableVoices.find(
3752
+ (v) => getLanguageName(v.lang) === newLang
3753
+ );
3754
+ if (firstVoice) {
3755
+ setVoice(firstVoice.voiceURI);
3756
+ }
3757
+ },
3758
+ onVoiceChange: (newVoiceUri) => {
3759
+ setVoice(newVoiceUri);
3760
+ }
3761
+ }
3762
+ ),
3763
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.Field, { label: uiLabels.face, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3764
+ import_core6.Select,
3765
+ {
3766
+ "aria-label": uiLabels.face,
3767
+ className: "pbf:w-full",
3768
+ value: selectedFace ? selectedFace.name : "Hugo",
3769
+ onChange: (selectedName) => {
3770
+ const found = selectableFaces.find(
3771
+ (f) => f.name === String(selectedName)
3772
+ );
3773
+ if (found) {
3774
+ setFace(found);
3775
+ }
3776
+ },
3777
+ options: selectableFaces.map((face) => ({
3778
+ label: face.name,
3779
+ value: face.name
3780
+ }))
3781
+ }
3782
+ ) }),
3783
+ selectedFace?.name === "Custom Face" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.Field, { label: uiLabels.uploadGlb, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3784
+ import_core6.Input,
3785
+ {
3786
+ "aria-label": uiLabels.uploadGlb,
3787
+ type: "file",
3788
+ accept: ".glb",
3789
+ className: "pbf:w-full pbf:text-sm pbf:text-slate-900",
3790
+ onChange: (e) => {
3791
+ const file = e.target.files?.[0];
3792
+ if (file && selectedFace?.kind === "Vizij") {
3793
+ const url = URL.createObjectURL(file);
3794
+ const updatedFace = {
3795
+ ...selectedFace,
3796
+ assetBundle: {
3797
+ ...selectedFace.assetBundle,
3798
+ glb: {
3799
+ kind: "url",
3800
+ src: url,
3801
+ aggressiveImport: true
3802
+ }
3803
+ }
3804
+ };
3805
+ setFace(updatedFace);
3806
+ }
3807
+ }
3808
+ }
3809
+ ) }),
3810
+ selectedFace && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:py-1.5 pbf:px-3 pbf:border-l-2 pbf:rtl:border-l-0 pbf:rtl:border-r-2 pbf:border-teal-700/30 pbf:bg-slate-50 pbf:rounded-r-md", children: [
3811
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-[11px] pbf:font-bold pbf:text-slate-700 pbf:uppercase pbf:tracking-wider pbf:mb-1.5 pbf:block", children: uiLabels.faceCapabilities }),
3812
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:flex-row pbf:flex-wrap pbf:gap-x-4 pbf:gap-y-2", children: [
3813
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
3814
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3815
+ "span",
3816
+ {
3817
+ "aria-hidden": "true",
3818
+ className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canExpressColor ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
3819
+ }
3820
+ ),
3821
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:flex-col", children: [
3822
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.color }),
3823
+ typeof caps.canExpressColor === "string" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canExpressColor })
3824
+ ] })
3825
+ ] }),
3826
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
3827
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3828
+ "span",
3829
+ {
3830
+ "aria-hidden": "true",
3831
+ className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canExpressEmotion ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
3832
+ }
3833
+ ),
3834
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:flex-col", children: [
3835
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.emotion }),
3836
+ typeof caps.canExpressEmotion === "string" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canExpressEmotion })
3837
+ ] })
3838
+ ] }),
3839
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
3840
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3841
+ "span",
3842
+ {
3843
+ "aria-hidden": "true",
3844
+ className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canLipSync ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
3845
+ }
3846
+ ),
3847
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:flex-col", children: [
3848
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.speech }),
3849
+ typeof caps.canLipSync === "string" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canLipSync })
3850
+ ] })
3851
+ ] })
3852
+ ] })
3853
+ ] }),
3854
+ enableVizij && selectedFace?.kind === "Vizij" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
3855
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.Separator, {}),
3856
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:space-y-3", children: [
3857
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:justify-between", children: [
3858
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.faceSpecificSettings }),
3859
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PoweredByVizij, { poweredByLabel: uiLabels.poweredBy })
3860
+ ] }),
3861
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(FieldGroup, { label: uiLabels.faceExpressivity, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3862
+ import_core6.SliderWithNumberField,
3863
+ {
3864
+ "aria-label": uiLabels.faceExpressivity,
3865
+ min: 0,
3866
+ max: 1,
3867
+ step: 0.05,
3868
+ value: faceSettings.vizijSettings?.faceExpressivity ?? 1,
3869
+ onChange: (val) => {
3870
+ const vizijSettings = faceSettings.vizijSettings ?? defaultFaceSettings.vizijSettings;
3871
+ setFaceSettings({
3872
+ vizijSettings: {
3873
+ ...vizijSettings,
3874
+ faceExpressivity: val
3875
+ }
3876
+ });
3877
+ }
3878
+ }
3879
+ ) })
3880
+ ] })
3881
+ ] }),
3882
+ selectedFace?.kind === "PixiFace" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
3883
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_core6.Separator, {}),
3884
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:space-y-3", children: [
3885
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800 pbf:block", children: uiLabels.faceSpecificSettings }),
3886
+ selectedFace.type === "avatar" && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-3", children: [
3887
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3888
+ import_core6.Field,
3889
+ {
3890
+ label: uiLabels.eyes,
3891
+ labelPlacement: "left",
3892
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
3893
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3894
+ import_core6.TabRadio,
3895
+ {
3896
+ "aria-label": uiLabels.eyes,
3897
+ options: [
3898
+ { value: "default", label: uiLabels.defaultOption },
3899
+ { value: "none", label: uiLabels.noneOption }
3900
+ ],
3901
+ value: faceSettings.pixiSettings?.eyeDisplay ?? "default",
3902
+ onChange: (val) => {
3903
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
3904
+ setFaceSettings({
3905
+ pixiSettings: {
3906
+ ...pixiSettings,
3907
+ eyeDisplay: val || "default"
3908
+ }
3909
+ });
3910
+ }
3911
+ }
3912
+ )
3913
+ }
3914
+ ),
3915
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3916
+ import_core6.Field,
3917
+ {
3918
+ label: uiLabels.mouth,
3919
+ labelPlacement: "left",
3920
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
3921
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3922
+ import_core6.TabRadio,
3923
+ {
3924
+ "aria-label": uiLabels.mouth,
3925
+ options: [
3926
+ { value: "default", label: uiLabels.defaultOption },
3927
+ { value: "none", label: uiLabels.noneOption }
3928
+ ],
3929
+ value: faceSettings.pixiSettings?.mouthDisplay ?? "default",
3930
+ onChange: (val) => {
3931
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
3932
+ setFaceSettings({
3933
+ pixiSettings: {
3934
+ ...pixiSettings,
3935
+ mouthDisplay: val || "default"
3936
+ }
3937
+ });
3938
+ }
3939
+ }
3940
+ )
3941
+ }
3942
+ ),
3943
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3944
+ import_core6.Field,
3945
+ {
3946
+ label: uiLabels.cheeks,
3947
+ labelPlacement: "left",
3948
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
3949
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3950
+ import_core6.TabRadio,
3951
+ {
3952
+ "aria-label": uiLabels.cheeks,
3953
+ options: [
3954
+ { value: "default", label: uiLabels.defaultOption },
3955
+ { value: "none", label: uiLabels.noneOption }
3956
+ ],
3957
+ value: faceSettings.pixiSettings?.cheekDisplay ?? "default",
3958
+ onChange: (val) => {
3959
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
3960
+ setFaceSettings({
3961
+ pixiSettings: {
3962
+ ...pixiSettings,
3963
+ cheekDisplay: val || "default"
3964
+ }
3965
+ });
3966
+ }
3967
+ }
3968
+ )
3969
+ }
3970
+ )
3971
+ ] }),
3972
+ selectedFace.type === "text" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3973
+ import_core6.Field,
3974
+ {
3975
+ label: uiLabels.emotionDisplay,
3976
+ labelPlacement: "left",
3977
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
3978
+ children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
3979
+ import_core6.TabRadio,
3980
+ {
3981
+ "aria-label": uiLabels.emotionDisplay,
3982
+ options: [
3983
+ { value: "emoticon", label: uiLabels.emoticon },
3984
+ { value: "emoji", label: uiLabels.emoji },
3985
+ { value: "none", label: uiLabels.noneOption }
3986
+ ],
3987
+ value: faceSettings.pixiSettings?.emotionDisplay ?? "emoticon",
3988
+ onChange: (val) => {
3989
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
3990
+ setFaceSettings({
3991
+ pixiSettings: {
3992
+ ...pixiSettings,
3993
+ emotionDisplay: val || "emoticon"
3994
+ }
3995
+ });
3996
+ }
3997
+ }
3998
+ )
3999
+ }
4000
+ )
4001
+ ] })
4002
+ ] })
4003
+ ] }) });
4004
+ }
4005
+ var CharacterSelectionSection = CharacterSelectionControls;
4006
+
4007
+ // src/components/FacePositioningControls.tsx
4008
+ var import_core7 = require("@peerbots/core");
4009
+ init_FaceStoreContext();
4010
+ init_labels();
4011
+ var import_jsx_runtime20 = require("react/jsx-runtime");
4012
+ function FacePositioningControls({
4013
+ labels
4014
+ } = {}) {
4015
+ const uiLabels = resolveFaceUiLabels(labels);
4016
+ const faceSettings = useFaceStore((state) => state.faceSettings);
4017
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
4018
+ const resetPositioning = useFaceStore((state) => state.resetPositioning);
4019
+ const isModified = faceSettings.zoom !== 1 || (faceSettings.offset?.x ?? 0) !== 0 || (faceSettings.offset?.y ?? 0) !== 0 || faceSettings.rotation !== 0;
4020
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.SettingsPanel, { title: uiLabels.positioning, headingLevel: 4, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "pbf:space-y-4", children: [
4021
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "pbf:flex pbf:w-full pbf:flex-wrap pbf:items-center pbf:justify-between pbf:gap-2", children: [
4022
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4023
+ import_core7.Field,
4024
+ {
4025
+ label: uiLabels.autoRotate,
4026
+ labelPlacement: "left",
4027
+ labelWeight: "normal",
4028
+ className: "pbf:flex-row pbf:items-center pbf:gap-2 pbf:mb-0 pbf:!w-auto",
4029
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4030
+ import_core7.Switch,
4031
+ {
4032
+ "aria-label": uiLabels.autoRotate,
4033
+ checked: faceSettings.autoRotate,
4034
+ onChange: (checked) => {
4035
+ setFaceSettings({ autoRotate: checked });
4036
+ }
4037
+ }
4038
+ )
4039
+ }
4040
+ ),
4041
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:gap-1.5 pbf:shrink-0", children: [
4042
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4043
+ import_core7.Button,
4044
+ {
4045
+ variant: "ghost",
4046
+ size: "sm",
4047
+ className: "pbf:p-1.5 pbf:text-xs pbf:whitespace-nowrap",
4048
+ onClick: () => {
4049
+ setFaceSettings({
4050
+ rotation: (faceSettings.rotation + 90) % 360
4051
+ });
4052
+ },
4053
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Icon, { name: "arrowPath", className: "pbf:h-3.5 pbf:w-3.5" }),
4054
+ children: uiLabels.rotate
4055
+ }
4056
+ ),
4057
+ isModified && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4058
+ import_core7.Button,
4059
+ {
4060
+ variant: "ghost",
4061
+ size: "sm",
4062
+ className: "pbf:p-1.5 pbf:text-xs pbf:whitespace-nowrap",
4063
+ onClick: resetPositioning,
4064
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Icon, { name: "arrowUturnLeft", className: "pbf:h-3.5 pbf:w-3.5" }),
4065
+ children: uiLabels.reset
4066
+ }
4067
+ )
4068
+ ] })
4069
+ ] }),
4070
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Separator, {}),
4071
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-4", children: [
4072
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4073
+ FieldGroup,
4074
+ {
4075
+ label: uiLabels.zoom,
4076
+ icon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Icon, { name: "magnifyingGlassPlus" }),
4077
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4078
+ import_core7.SliderWithNumberField,
4079
+ {
4080
+ "aria-label": uiLabels.zoom,
4081
+ min: 0.1,
4082
+ max: 3,
4083
+ step: 0.05,
4084
+ value: faceSettings.zoom,
4085
+ onChange: (val) => {
4086
+ setFaceSettings({ zoom: val });
4087
+ }
4088
+ }
4089
+ )
4090
+ }
4091
+ ),
4092
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4093
+ FieldGroup,
4094
+ {
4095
+ label: uiLabels.horizontalOffset,
4096
+ icon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Icon, { name: "arrowsRightLeft" }),
4097
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4098
+ import_core7.SliderWithNumberField,
4099
+ {
4100
+ "aria-label": uiLabels.horizontalOffset,
4101
+ min: -1e3,
4102
+ max: 1e3,
4103
+ value: faceSettings.offset?.x ?? 0,
4104
+ onChange: (val) => {
4105
+ setFaceSettings({
4106
+ offset: {
4107
+ x: val,
4108
+ y: faceSettings.offset?.y ?? 0
4109
+ }
4110
+ });
4111
+ }
4112
+ }
4113
+ )
4114
+ }
4115
+ ),
4116
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4117
+ FieldGroup,
4118
+ {
4119
+ label: uiLabels.verticalOffset,
4120
+ icon: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_core7.Icon, { name: "arrowsUpDown" }),
4121
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
4122
+ import_core7.SliderWithNumberField,
4123
+ {
4124
+ "aria-label": uiLabels.verticalOffset,
4125
+ min: -1e3,
4126
+ max: 1e3,
4127
+ value: faceSettings.offset?.y ?? 0,
4128
+ onChange: (val) => {
4129
+ setFaceSettings({
4130
+ offset: {
4131
+ x: faceSettings.offset?.x ?? 0,
4132
+ y: val
4133
+ }
4134
+ });
4135
+ }
4136
+ }
4137
+ )
4138
+ }
4139
+ )
4140
+ ] })
4141
+ ] }) });
4142
+ }
4143
+ var FacePositioningSection = FacePositioningControls;
4144
+
4145
+ // src/components/FaceBehaviorControls.tsx
4146
+ var import_core8 = require("@peerbots/core");
4147
+ init_labels();
4148
+ init_FaceStoreContext();
4149
+ var import_jsx_runtime21 = require("react/jsx-runtime");
4150
+ function FaceBehaviorControls({
4151
+ labels
4152
+ } = {}) {
4153
+ const uiLabels = resolveFaceUiLabels(labels);
4154
+ const faceSettings = useFaceStore((state) => state.faceSettings);
4155
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
4156
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core8.SettingsPanel, { title: uiLabels.faceSettings, headingLevel: 4, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-4", children: [
4157
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-2", children: [
4158
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.onFaceButtons }),
4159
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4160
+ import_core8.Field,
4161
+ {
4162
+ label: uiLabels.showFullScreenButton,
4163
+ labelPlacement: "left",
4164
+ labelWeight: "normal",
4165
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
4166
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4167
+ import_core8.Switch,
4168
+ {
4169
+ "aria-label": uiLabels.showFullScreenButton,
4170
+ checked: faceSettings.showFullScreenButton,
4171
+ onChange: (checked) => {
4172
+ setFaceSettings({ showFullScreenButton: checked });
4173
+ }
4174
+ }
4175
+ )
4176
+ }
4177
+ ),
4178
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4179
+ import_core8.Field,
4180
+ {
4181
+ label: uiLabels.showScrollButton,
4182
+ labelPlacement: "left",
4183
+ labelWeight: "normal",
4184
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
4185
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4186
+ import_core8.Switch,
4187
+ {
4188
+ "aria-label": uiLabels.showScrollButton,
4189
+ checked: faceSettings.showScrollButton,
4190
+ onChange: (checked) => {
4191
+ setFaceSettings({ showScrollButton: checked });
4192
+ }
4193
+ }
4194
+ )
4195
+ }
4196
+ )
4197
+ ] }),
4198
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core8.Separator, {}),
4199
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-2", children: [
4200
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.speechBehavior }),
4201
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core8.Field, { label: uiLabels.newButtonSpeech, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4202
+ import_core8.Select,
4203
+ {
4204
+ "aria-label": uiLabels.newButtonSpeech,
4205
+ className: "pbf:w-full",
4206
+ value: faceSettings.speechQueueMode || "interrupt",
4207
+ onChange: (val) => {
4208
+ if (val) {
4209
+ setFaceSettings({
4210
+ speechQueueMode: val
4211
+ });
4212
+ }
4213
+ },
4214
+ options: [
4215
+ {
4216
+ label: uiLabels.interruptSpeech,
4217
+ value: "interrupt"
4218
+ },
4219
+ {
4220
+ label: uiLabels.queueSpeech,
4221
+ value: "queue"
4222
+ }
4223
+ ]
4224
+ }
4225
+ ) })
4226
+ ] }),
4227
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(import_core8.Separator, {}),
4228
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-3", children: [
4229
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4230
+ import_core8.Field,
4231
+ {
4232
+ label: uiLabels.captions,
4233
+ labelPlacement: "left",
4234
+ labelWeight: "bold",
4235
+ className: "pbf:flex-row pbf:items-center pbf:justify-between",
4236
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4237
+ import_core8.Switch,
4238
+ {
4239
+ "aria-label": uiLabels.captions,
4240
+ checked: faceSettings.captions?.enabled ?? false,
4241
+ onChange: (checked) => {
4242
+ setFaceSettings({
4243
+ captions: {
4244
+ ...faceSettings.captions,
4245
+ enabled: checked
4246
+ }
4247
+ });
4248
+ }
4249
+ }
4250
+ )
4251
+ }
4252
+ ),
4253
+ faceSettings.captions?.enabled && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "pbf:flex pbf:flex-col pbf:gap-4 pbf:mt-1", children: [
4254
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FieldGroup, { label: uiLabels.fontSize, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4255
+ import_core8.SliderWithNumberField,
4256
+ {
4257
+ "aria-label": uiLabels.fontSize,
4258
+ min: 10,
4259
+ max: 100,
4260
+ step: 1,
4261
+ value: faceSettings.captions?.fontSize ?? 32,
4262
+ onChange: (val) => {
4263
+ setFaceSettings({
4264
+ captions: {
4265
+ ...faceSettings.captions,
4266
+ fontSize: val
4267
+ }
4268
+ });
4269
+ }
4270
+ }
4271
+ ) }),
4272
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FieldGroup, { label: uiLabels.horizontalOffset, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4273
+ import_core8.SliderWithNumberField,
4274
+ {
4275
+ "aria-label": uiLabels.horizontalOffset,
4276
+ min: -400,
4277
+ max: 400,
4278
+ step: 1,
4279
+ value: faceSettings.captions?.offset?.x ?? 0,
4280
+ onChange: (val) => {
4281
+ setFaceSettings({
4282
+ captions: {
4283
+ ...faceSettings.captions,
4284
+ offset: {
4285
+ x: val,
4286
+ y: faceSettings.captions?.offset?.y ?? 0
4287
+ }
4288
+ }
4289
+ });
4290
+ }
4291
+ }
4292
+ ) }),
4293
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(FieldGroup, { label: uiLabels.verticalPosition, children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4294
+ import_core8.SliderWithNumberField,
4295
+ {
4296
+ "aria-label": uiLabels.verticalPosition,
4297
+ min: -50,
4298
+ max: 50,
4299
+ step: 1,
4300
+ value: faceSettings.captions?.offset?.y ?? 0,
4301
+ onChange: (val) => {
4302
+ setFaceSettings({
4303
+ captions: {
4304
+ ...faceSettings.captions,
4305
+ offset: {
4306
+ x: faceSettings.captions?.offset?.x ?? 0,
4307
+ y: val
4308
+ }
4309
+ }
4310
+ });
4311
+ }
4312
+ }
4313
+ ) })
4314
+ ] })
4315
+ ] })
4316
+ ] }) });
4317
+ }
4318
+ var ControlSettingsSection = FaceBehaviorControls;
4319
+
4320
+ // src/components/FaceSettingsPanel.tsx
4321
+ var import_core9 = require("@peerbots/core");
4322
+ init_labels();
4323
+ var import_jsx_runtime22 = require("react/jsx-runtime");
4324
+ function FaceSettingsPanel({
4325
+ inline = false,
4326
+ enableVizij = true,
4327
+ columns = 3,
4328
+ labels,
4329
+ className
4330
+ } = {}) {
4331
+ const uiLabels = resolveFaceUiLabels(labels);
4332
+ const gridClass = columns === 1 ? "pbf:grid pbf:items-start pbf:gap-4 pbf:grid-cols-1" : "pbf:grid pbf:items-start pbf:gap-4 pbf:lg:gap-6 pbf:grid-cols-1 pbf:md:grid-cols-2 pbf:lg:grid-cols-3";
4333
+ const content = /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { className: faceCn(gridClass, className), children: [
4334
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CharacterSelectionControls, { enableVizij, labels: uiLabels }) }),
4335
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FacePositioningControls, { labels: uiLabels }) }),
4336
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(FaceBehaviorControls, { labels: uiLabels }) })
4337
+ ] });
4338
+ if (inline) {
4339
+ return content;
4340
+ }
4341
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(import_core9.SettingsPanel, { title: uiLabels.faceSettings, children: content });
4342
+ }
4343
+ var FaceSettingsControl = FaceSettingsPanel;
4344
+
4345
+ // src/components/FaceTester.tsx
4346
+ var import_react25 = require("react");
4347
+ var import_core10 = require("@peerbots/core");
4348
+ init_FaceStoreContext();
4349
+ init_labels();
4350
+ var import_jsx_runtime23 = require("react/jsx-runtime");
4351
+ function FaceTester({ labels, onSendMessage } = {}) {
4352
+ const uiLabels = resolveFaceUiLabels(labels);
4353
+ const textToSpeak = (0, import_react25.useRef)(null);
4354
+ const lastMessage = useFaceStore((state) => state.lastMessage);
4355
+ const updateLastMessage = useFaceStore((state) => state.updateLastMessage);
4356
+ const dispatchMessage = (next) => {
4357
+ if (onSendMessage) {
4358
+ onSendMessage(next, "system");
4359
+ return;
4360
+ }
4361
+ updateLastMessage(next, "system");
4362
+ };
4363
+ const triggerSpeak = () => {
4364
+ if (!textToSpeak.current) return;
4365
+ const text = textToSpeak.current.value;
4366
+ dispatchMessage({ ...lastMessage, speech: text });
4367
+ textToSpeak.current.value = "";
4368
+ };
4369
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4370
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "pbf:flex pbf:my-2", children: [
4371
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4372
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "pbf:text-xs", children: uiLabels.sendEmotion }),
4373
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4374
+ import_core10.EmotionSelector,
4375
+ {
4376
+ selectedEmotion: "",
4377
+ onEmotionSelect: (emotion) => {
4378
+ dispatchMessage({ ...lastMessage, emotion, speech: "" });
4379
+ }
4380
+ }
4381
+ )
4382
+ ] }),
4383
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "pbf:flex-1" }),
4384
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { children: [
4385
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "pbf:text-xs", children: uiLabels.sendColor }),
4386
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4387
+ import_core10.PeerbotsColorSelector,
4388
+ {
4389
+ selectedColor: "",
4390
+ onColorSelect: (color) => {
4391
+ dispatchMessage({ ...lastMessage, color, speech: "" });
4392
+ }
4393
+ }
4394
+ )
4395
+ ] })
4396
+ ] }),
4397
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("div", { className: "pbf:flex pbf:mt-2 pbf:pt-2 pbf:gap-2", children: [
4398
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
4399
+ import_core10.Input,
4400
+ {
4401
+ ref: textToSpeak,
4402
+ placeholder: uiLabels.textToSpeakPlaceholder,
4403
+ "aria-label": uiLabels.textToSpeakAria,
4404
+ onKeyDown: (e) => {
4405
+ if (e.key === "Enter") {
4406
+ triggerSpeak();
4407
+ }
4408
+ }
4409
+ }
4410
+ ),
4411
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(import_core10.Button, { onClick: triggerSpeak, children: uiLabels.speak })
4412
+ ] })
4413
+ ] });
4414
+ }
4415
+
4416
+ // src/components/FaceTesterSection.tsx
4417
+ var import_core11 = require("@peerbots/core");
4418
+ init_labels();
4419
+ var import_jsx_runtime24 = require("react/jsx-runtime");
4420
+ function FaceTesterSection({
4421
+ defaultOpen = false,
4422
+ collapsible = true,
4423
+ headingLevel = 4,
4424
+ labels,
4425
+ onSendMessage
4426
+ } = {}) {
4427
+ const uiLabels = resolveFaceUiLabels(labels);
4428
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
4429
+ import_core11.SettingsPanel,
4430
+ {
4431
+ title: uiLabels.testFace,
4432
+ collapsible,
4433
+ defaultOpen,
4434
+ headingLevel,
4435
+ children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(FaceTester, { labels: uiLabels, onSendMessage })
4436
+ }
4437
+ );
4438
+ }
4439
+
4440
+ // src/components/AmplitudeGraph.tsx
4441
+ var import_core12 = require("@peerbots/core");
4442
+ init_FaceStoreContext();
4443
+ var import_jsx_runtime25 = require("react/jsx-runtime");
4444
+ function AmplitudeGraph() {
4445
+ const amplitudeData = useFaceStore((state) => state.amplitudeData);
4446
+ const amplitudeExtrema = useFaceStore((state) => state.amplitudeExtrema);
4447
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
4448
+ const currentAmplitude = useFaceStore((state) => state.currentAmplitude);
4449
+ if (!isSpeaking && (!amplitudeData || amplitudeData.length === 0)) {
4450
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "pbf:p-4 pbf:text-gray-500 pbf:italic", children: "No amplitude data available. Speak something to see data." });
4451
+ }
4452
+ const hasData = Boolean(amplitudeData && amplitudeData.length > 0);
4453
+ const maxTime = hasData && amplitudeData ? amplitudeData[amplitudeData.length - 1].time : 1e3;
4454
+ const height = 200;
4455
+ const padding = 20;
4456
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:m-4 pbf:p-4 pbf:bg-white pbf:shadow-xl pbf:rounded-lg pbf:border pbf:border-gray-100", children: [
4457
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:flex pbf:items-center pbf:justify-between pbf:mb-2", children: [
4458
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_core12.Heading, { level: 3, children: "Audio Amplitude Visualization" }),
4459
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:flex pbf:gap-4 pbf:items-center", children: [
4460
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:text-sm pbf:font-medium", children: [
4461
+ "Live:",
4462
+ " ",
4463
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "pbf:text-blue-600", children: [
4464
+ (currentAmplitude * 100).toFixed(1),
4465
+ "%"
4466
+ ] })
4467
+ ] }),
4468
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "pbf:flex-1 pbf:h-4 pbf:w-24 pbf:bg-gray-200 pbf:rounded-full pbf:overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4469
+ "div",
4470
+ {
4471
+ className: "pbf:h-full pbf:bg-blue-500 pbf:transition-all pbf:duration-75",
4472
+ style: { width: `${currentAmplitude * 100}%` }
4473
+ }
4474
+ ) }),
4475
+ isSpeaking && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "pbf:flex pbf:h-3 pbf:w-3 pbf:relative", children: [
4476
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:animate-ping pbf:absolute pbf:inline-flex pbf:h-full pbf:w-full pbf:rounded-full pbf:bg-green-400 pbf:opacity-75" }),
4477
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:relative pbf:inline-flex pbf:rounded-full pbf:h-3 pbf:w-3 pbf:bg-green-500" })
4478
+ ] })
4479
+ ] })
4480
+ ] }),
4481
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
4482
+ import_core12.LineGraph,
4483
+ {
4484
+ data: amplitudeData?.map((p) => ({ x: p.time, y: p.value })) ?? [],
4485
+ highlightPoints: amplitudeExtrema?.map((p) => ({
4486
+ x: p.time,
4487
+ y: p.value,
4488
+ color: p.value > 0.1 ? "#ef4444" : "#10b981",
4489
+ label: `Time: ${p.time} ms, Value: ${p.value}`
4490
+ })),
4491
+ minX: 0,
4492
+ maxX: maxTime,
4493
+ minY: 0,
4494
+ maxY: 1,
4495
+ height,
4496
+ strokeColor: "#3b82f6",
4497
+ xUnit: "ms",
4498
+ padding
4499
+ }
4500
+ ),
4501
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:mt-4 pbf:grid pbf:grid-cols-2 pbf:gap-4 pbf:text-xs", children: [
4502
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
4503
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "pbf:font-bold pbf:block pbf:mb-1", children: [
4504
+ "Local Extrema (",
4505
+ amplitudeExtrema?.length || 0,
4506
+ ")"
4507
+ ] }),
4508
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:max-h-32 pbf:overflow-y-auto pbf:bg-gray-50 pbf:p-2 pbf:rounded pbf:border pbf:border-gray-200", children: [
4509
+ amplitudeExtrema?.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
4510
+ "div",
4511
+ {
4512
+ className: "pbf:flex pbf:justify-between pbf:py-0.5 pbf:border-b pbf:border-gray-100 pbf:last:border-0",
4513
+ children: [
4514
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { children: [
4515
+ p.time,
4516
+ "ms"
4517
+ ] }),
4518
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:font-mono", children: p.value.toFixed(4) })
4519
+ ]
4520
+ },
4521
+ i
4522
+ )),
4523
+ !amplitudeExtrema?.length && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "pbf:text-slate-700 pbf:italic", children: "No extrema found" })
4524
+ ] })
4525
+ ] }),
4526
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { children: [
4527
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:font-bold pbf:block pbf:mb-1", children: "Stats" }),
4528
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:bg-gray-50 pbf:p-2 pbf:rounded pbf:border pbf:border-gray-200", children: [
4529
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:flex pbf:justify-between", children: [
4530
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Duration:" }),
4531
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("span", { className: "pbf:font-mono", children: [
4532
+ maxTime,
4533
+ "ms"
4534
+ ] })
4535
+ ] }),
4536
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:flex pbf:justify-between", children: [
4537
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Data Points:" }),
4538
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:font-mono", children: amplitudeData?.length || 0 })
4539
+ ] }),
4540
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "pbf:flex pbf:justify-between pbf:mt-1 pbf:pt-1 pbf:border-t pbf:border-gray-200", children: [
4541
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { children: "Method:" }),
4542
+ /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "pbf:text-blue-600 pbf:font-medium", children: hasData ? "Pre-calculated" : currentAmplitude > 0 ? "Real-time/Simulated" : "Idle" })
4543
+ ] })
4544
+ ] })
4545
+ ] })
4546
+ ] })
4547
+ ] });
4548
+ }
4549
+ // Annotate the CommonJS export names for ESM import in node:
4550
+ 0 && (module.exports = {
4551
+ AmplitudeGraph,
4552
+ AudioAnalyzer,
4553
+ CONNECTION_FACE_MESSAGE,
4554
+ CharacterSelectionControls,
4555
+ CharacterSelectionSection,
4556
+ ControlSettingsSection,
4557
+ DEFAULT_FACE_MESSAGE,
4558
+ DEFAULT_FACE_UI_LABELS,
4559
+ EMOTION_EMOJIS,
4560
+ EMOTION_EMOTICONS,
4561
+ EMOTION_ICON_FILES,
4562
+ FaceAudioPrompt,
4563
+ FaceBehaviorControls,
4564
+ FaceCaption,
4565
+ FacePositioningControls,
4566
+ FacePositioningSection,
4567
+ FaceRendererRegistry,
4568
+ FaceSettingsControl,
4569
+ FaceSettingsPanel,
4570
+ FaceStoreContext,
4571
+ FaceStoreProvider,
4572
+ FaceTester,
4573
+ FaceTesterSection,
4574
+ FaceView,
4575
+ FaceViewSkeleton,
4576
+ FieldGroup,
4577
+ PEERBOTS_COLORS,
4578
+ PEERBOTS_EMOTIONS,
4579
+ PoweredByVizij,
4580
+ StaticFaceFallback,
4581
+ TtsAudioCache,
4582
+ VoiceSelector,
4583
+ audioAnalyzer,
4584
+ availableFaces,
4585
+ blobToArrayBuffer,
4586
+ buildTtsCacheKey,
4587
+ builtInFaces,
4588
+ color_mapping,
4589
+ createBuiltInFaces,
4590
+ createBuiltInPixiFaces,
4591
+ createCustomVizijFace,
4592
+ createDefaultFaceRendererRegistry,
4593
+ createFaceRenderingSlice,
4594
+ createFaceSpeechSlice,
4595
+ createIncludedVizijFaces,
4596
+ createPeerbotsFaceStore,
4597
+ customFace,
4598
+ deconstructRgba,
4599
+ defaultFace,
4600
+ defaultFaceRendererRegistry,
4601
+ defaultFaceSettings,
4602
+ defaultTtsAudioCache,
4603
+ emotion_mapping,
4604
+ estimateVisemesFromText,
4605
+ findMatchingVoice,
4606
+ font_color_mapping,
4607
+ formatRbga,
4608
+ formatRgba,
4609
+ formatVoiceDisplayName,
4610
+ getEmotionEyeSpritePaths,
4611
+ getEmotionIconPath,
4612
+ getFaceCapabilities,
4613
+ getGlobalFaceStore,
4614
+ getLanguageName,
4615
+ globalFaceStore,
4616
+ hexToRgb,
4617
+ hexToRgba,
4618
+ includedVizijFaces,
4619
+ interpolateColor,
4620
+ isHeadlessOrTestEnvironment,
4621
+ isWebGLAvailable,
4622
+ mapVisemeToVizijTarget,
4623
+ mergeFaceSettings,
4624
+ normalizeAssetBaseUrl,
4625
+ pixiFaceRendererStrategy,
4626
+ pollyVisemeToVizijPath,
4627
+ possiblePollyVisemes,
4628
+ rbgToRgba,
4629
+ resolveFaceUiLabels,
4630
+ rgbToRgba,
4631
+ rgbaToHex,
4632
+ setGlobalFaceStore,
4633
+ stopNativeSpeechSynthesis,
4634
+ useFaceStore,
4635
+ useFaceStoreInstance,
4636
+ useMessageVisualState,
4637
+ vizijFaceRendererStrategy
4638
+ });
4639
+ //# sourceMappingURL=index.cjs.map