@peerbots/face 0.0.0-stage → 0.1.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-3fvAa51G.d.ts +57 -0
  3. package/dist/chunk-AT25NYX2.js +211 -0
  4. package/dist/chunk-AT25NYX2.js.map +1 -0
  5. package/dist/chunk-T7QJ6B66.js +1475 -0
  6. package/dist/chunk-T7QJ6B66.js.map +1 -0
  7. package/dist/chunk-XHICGN32.js +62 -0
  8. package/dist/chunk-XHICGN32.js.map +1 -0
  9. package/dist/index.cjs +4353 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.ts +525 -0
  12. package/dist/index.js +1408 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/pixi.cjs +2403 -0
  15. package/dist/pixi.cjs.map +1 -0
  16. package/dist/pixi.d.ts +9 -0
  17. package/dist/pixi.js +882 -0
  18. package/dist/pixi.js.map +1 -0
  19. package/dist/vizij.cjs +1546 -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 +114 -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.js ADDED
@@ -0,0 +1,1408 @@
1
+ import {
2
+ EMOTION_EMOJIS,
3
+ EMOTION_EMOTICONS,
4
+ EMOTION_ICON_FILES,
5
+ emotion_mapping,
6
+ getEmotionEyeSpritePaths,
7
+ getEmotionIconPath,
8
+ useMessageVisualState
9
+ } from "./chunk-AT25NYX2.js";
10
+ import {
11
+ DEFAULT_FACE_UI_LABELS,
12
+ resolveFaceUiLabels
13
+ } from "./chunk-XHICGN32.js";
14
+ import {
15
+ AudioAnalyzer,
16
+ CONNECTION_FACE_MESSAGE,
17
+ DEFAULT_FACE_MESSAGE,
18
+ FaceStoreContext,
19
+ FaceStoreProvider,
20
+ PEERBOTS_COLORS,
21
+ PEERBOTS_EMOTIONS,
22
+ TtsAudioCache,
23
+ audioAnalyzer,
24
+ availableFaces,
25
+ blobToArrayBuffer,
26
+ buildTtsCacheKey,
27
+ builtInFaces,
28
+ color_mapping,
29
+ createBuiltInFaces,
30
+ createBuiltInPixiFaces,
31
+ createCustomVizijFace,
32
+ createFaceRenderingSlice,
33
+ createFaceSpeechSlice,
34
+ createIncludedVizijFaces,
35
+ createPeerbotsFaceStore,
36
+ customFace,
37
+ deconstructRgba,
38
+ defaultFace,
39
+ defaultFaceSettings,
40
+ defaultTtsAudioCache,
41
+ estimateVisemesFromText,
42
+ findMatchingVoice,
43
+ font_color_mapping,
44
+ formatRbga,
45
+ formatRgba,
46
+ formatVoiceDisplayName,
47
+ getFaceCapabilities,
48
+ getLanguageName,
49
+ globalFaceStore,
50
+ hexToRgb,
51
+ hexToRgba,
52
+ includedVizijFaces,
53
+ interpolateColor,
54
+ mapVisemeToVizijTarget,
55
+ mergeFaceSettings,
56
+ normalizeAssetBaseUrl,
57
+ pollyVisemeToVizijPath,
58
+ possiblePollyVisemes,
59
+ rbgToRgba,
60
+ rgbToRgba,
61
+ rgbaToHex,
62
+ stopNativeSpeechSynthesis,
63
+ useFaceStore,
64
+ useFaceStoreInstance
65
+ } from "./chunk-T7QJ6B66.js";
66
+
67
+ // src/types/renderer.ts
68
+ var FaceRendererRegistry = class {
69
+ strategies = /* @__PURE__ */ new Map();
70
+ constructor(initialStrategies = []) {
71
+ for (const strategy of initialStrategies) {
72
+ this.register(strategy);
73
+ }
74
+ }
75
+ register(strategy) {
76
+ this.strategies.set(strategy.kind, strategy);
77
+ }
78
+ unregister(kind) {
79
+ return this.strategies.delete(kind);
80
+ }
81
+ get(kind) {
82
+ return this.strategies.get(kind);
83
+ }
84
+ has(kind) {
85
+ return this.strategies.has(kind);
86
+ }
87
+ list() {
88
+ return Array.from(this.strategies.values());
89
+ }
90
+ getCapabilities(face) {
91
+ if (!face) {
92
+ return getFaceCapabilities(void 0);
93
+ }
94
+ const strategy = this.strategies.get(face.kind);
95
+ if (strategy?.getCapabilities) {
96
+ return strategy.getCapabilities(face);
97
+ }
98
+ return getFaceCapabilities(face);
99
+ }
100
+ };
101
+
102
+ // src/helpers/environment.ts
103
+ function isWebGLAvailable() {
104
+ if (typeof window === "undefined" || typeof document === "undefined") {
105
+ return false;
106
+ }
107
+ try {
108
+ const canvas = document.createElement("canvas");
109
+ const gl = canvas.getContext("webgl2") || canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
110
+ return Boolean(gl);
111
+ } catch (err) {
112
+ void err;
113
+ return false;
114
+ }
115
+ }
116
+ function isHeadlessOrTestEnvironment() {
117
+ if (typeof window === "undefined" || typeof navigator === "undefined") {
118
+ return true;
119
+ }
120
+ const ua = navigator.userAgent || "";
121
+ if (ua.includes("peerbots-pa11y-ci") || ua.toLowerCase().includes("jsdom") || Boolean(navigator.webdriver) || Boolean(window.__VITEST_BROWSER__)) {
122
+ return true;
123
+ }
124
+ return !isWebGLAvailable();
125
+ }
126
+
127
+ // src/components/FaceView.tsx
128
+ import { lazy, Suspense } from "react";
129
+ import { cn as cn2 } from "@peerbots/core";
130
+
131
+ // src/components/FaceCaption.tsx
132
+ import { useEffect } from "react";
133
+ import { jsx } from "react/jsx-runtime";
134
+ function FaceCaption() {
135
+ const lastMessage = useFaceStore((state) => state.lastMessage);
136
+ const settings = useFaceStore((state) => state.faceSettings);
137
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
138
+ const { displayText, queueMessage, update } = useMessageVisualState(
139
+ isSpeaking,
140
+ {
141
+ msPerChar: 0,
142
+ persistenceDuration: 1e3
143
+ }
144
+ );
145
+ useEffect(() => {
146
+ queueMessage(lastMessage.speech);
147
+ }, [lastMessage.speech, queueMessage]);
148
+ useEffect(() => {
149
+ if (typeof requestAnimationFrame === "undefined") {
150
+ return;
151
+ }
152
+ let lastTime = performance.now();
153
+ let frameId;
154
+ const tick = (now) => {
155
+ const delta = now - lastTime;
156
+ lastTime = now;
157
+ update(delta);
158
+ frameId = requestAnimationFrame(tick);
159
+ };
160
+ frameId = requestAnimationFrame(tick);
161
+ return () => cancelAnimationFrame(frameId);
162
+ }, [update]);
163
+ if (!settings.captions || !settings.captions.enabled) {
164
+ return null;
165
+ }
166
+ if (!displayText || displayText.trim() === "") {
167
+ return null;
168
+ }
169
+ const offsetX = settings.captions.offset?.x ?? 0;
170
+ const offsetY = settings.captions.offset?.y ?? 0;
171
+ const fontSize = settings.captions.fontSize ?? 32;
172
+ return /* @__PURE__ */ jsx(
173
+ "div",
174
+ {
175
+ role: "status",
176
+ "aria-live": "polite",
177
+ "data-testid": "face-caption",
178
+ className: "absolute text-center w-[80%] pointer-events-none z-50 font-sans",
179
+ style: {
180
+ top: `calc(${offsetY}% + 80%)`,
181
+ left: `calc(50% + ${offsetX}px)`,
182
+ transform: "translate(-50%, -50%)",
183
+ fontSize: `${fontSize}px`,
184
+ color: "#ffffff",
185
+ backgroundColor: "rgba(15, 23, 42, 0.75)",
186
+ padding: "0.25rem 0.75rem",
187
+ borderRadius: "0.75rem"
188
+ },
189
+ children: displayText
190
+ }
191
+ );
192
+ }
193
+
194
+ // src/components/FaceViewSkeleton.tsx
195
+ import { Skeleton } from "@peerbots/core";
196
+ import { jsx as jsx2, jsxs } from "react/jsx-runtime";
197
+ function FaceViewSkeleton({
198
+ label = "Loading robot face"
199
+ } = {}) {
200
+ return /* @__PURE__ */ jsxs(
201
+ "div",
202
+ {
203
+ role: "status",
204
+ "aria-label": label,
205
+ "data-testid": "face-view-skeleton",
206
+ className: "flex flex-col items-center justify-center w-full h-full bg-sky-50 p-8 relative",
207
+ children: [
208
+ /* @__PURE__ */ jsxs("div", { className: "flex w-[80%] max-w-lg min-w-[260px] justify-around absolute top-1/3 px-12", children: [
209
+ /* @__PURE__ */ jsx2(Skeleton, { className: "w-16 h-16 md:w-24 md:h-24 rounded-full bg-slate-300" }),
210
+ /* @__PURE__ */ jsx2(Skeleton, { className: "w-16 h-16 md:w-24 md:h-24 rounded-full bg-slate-300" })
211
+ ] }),
212
+ /* @__PURE__ */ jsx2("div", { className: "mt-48", children: /* @__PURE__ */ jsx2(Skeleton, { className: "w-24 h-6 md:w-32 md:h-12 rounded-full bg-slate-300" }) })
213
+ ]
214
+ }
215
+ );
216
+ }
217
+
218
+ // src/components/StaticFaceFallback.tsx
219
+ import { cn } from "@peerbots/core";
220
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
221
+ function StaticFaceFallback({
222
+ showSprites = true,
223
+ className
224
+ }) {
225
+ const selectedFace = useFaceStore((state) => state.selectedFace);
226
+ const lastMessage = useFaceStore((state) => state.lastMessage);
227
+ const isSpeaking = useFaceStore((state) => state.isSpeaking);
228
+ const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
229
+ const faceSettings = useFaceStore((state) => state.faceSettings);
230
+ const bgColor = color_mapping[lastMessage.color] ?? color_mapping["Light Blue"];
231
+ const fgColor = font_color_mapping[lastMessage.color] ?? font_color_mapping["Light Blue"];
232
+ const accessibleLabel = `${selectedFace.name} robot face, emotion ${lastMessage.emotion}, color ${lastMessage.color}${isSpeaking ? ", speaking" : ""}`;
233
+ const pixiSettings = faceSettings.pixiSettings;
234
+ const isTextDisplay = selectedFace.kind === "PixiFace" && selectedFace.type === "text";
235
+ const isHugoStyleAvatar = selectedFace.kind === "PixiFace" && selectedFace.type === "avatar" && (selectedFace.name === "Hugo" || selectedFace.name === "Simple");
236
+ const eyePaths = getEmotionEyeSpritePaths(
237
+ lastMessage.emotion,
238
+ "Hugo",
239
+ assetBaseUrl
240
+ );
241
+ const emotionIconPath = getEmotionIconPath(lastMessage.emotion, assetBaseUrl);
242
+ const textEmotionMode = pixiSettings?.emotionDisplay ?? (isTextDisplay ? selectedFace.showEmotion : "emoticon");
243
+ return /* @__PURE__ */ jsx3(
244
+ "div",
245
+ {
246
+ role: "img",
247
+ "aria-label": accessibleLabel,
248
+ "data-testid": "static-face-fallback",
249
+ "data-face-name": selectedFace.name,
250
+ "data-face-kind": selectedFace.kind,
251
+ "data-emotion": lastMessage.emotion,
252
+ "data-color": lastMessage.color,
253
+ "data-speaking": String(isSpeaking),
254
+ className: cn(
255
+ "flex flex-col items-center justify-center w-full h-full p-6 select-none transition-colors duration-200",
256
+ className
257
+ ),
258
+ style: {
259
+ backgroundColor: bgColor,
260
+ color: fgColor
261
+ },
262
+ children: isTextDisplay ? /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center gap-3 font-mono text-center max-w-xl", children: [
263
+ textEmotionMode !== "none" && /* @__PURE__ */ jsx3("span", { className: "text-4xl font-bold", "aria-hidden": "true", children: textEmotionMode === "emoji" ? EMOTION_EMOJIS[lastMessage.emotion] : EMOTION_EMOTICONS[lastMessage.emotion] }),
264
+ lastMessage.speech && /* @__PURE__ */ jsx3("span", { className: "text-2xl font-semibold break-words", children: lastMessage.speech })
265
+ ] }) : showSprites && isHugoStyleAvatar ? /* @__PURE__ */ jsxs2(
266
+ "div",
267
+ {
268
+ className: "flex flex-col items-center justify-center gap-8",
269
+ "aria-hidden": "true",
270
+ children: [
271
+ pixiSettings?.eyeDisplay !== "none" && /* @__PURE__ */ jsxs2("div", { className: "flex items-center justify-center gap-16 md:gap-24", children: [
272
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center", children: [
273
+ /* @__PURE__ */ jsx3(
274
+ "img",
275
+ {
276
+ src: eyePaths.left,
277
+ alt: "",
278
+ className: "w-20 h-20 md:w-28 md:h-28 object-contain"
279
+ }
280
+ ),
281
+ selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ jsx3(
282
+ "img",
283
+ {
284
+ src: selectedFace.cheeks.path,
285
+ alt: "",
286
+ className: "w-8 h-4 object-contain mt-1"
287
+ }
288
+ )
289
+ ] }),
290
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center", children: [
291
+ /* @__PURE__ */ jsx3(
292
+ "img",
293
+ {
294
+ src: eyePaths.right,
295
+ alt: "",
296
+ className: "w-20 h-20 md:w-28 md:h-28 object-contain"
297
+ }
298
+ ),
299
+ selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ jsx3(
300
+ "img",
301
+ {
302
+ src: selectedFace.cheeks.path,
303
+ alt: "",
304
+ className: "w-8 h-4 object-contain mt-1"
305
+ }
306
+ )
307
+ ] })
308
+ ] }),
309
+ pixiSettings?.mouthDisplay !== "none" && /* @__PURE__ */ jsx3(
310
+ "div",
311
+ {
312
+ className: cn(
313
+ "rounded-b-full bg-black transition-all duration-150",
314
+ isSpeaking ? "w-16 h-8" : "w-14 h-3"
315
+ )
316
+ }
317
+ )
318
+ ]
319
+ }
320
+ ) : /* @__PURE__ */ jsxs2(
321
+ "div",
322
+ {
323
+ className: "flex flex-col items-center justify-center gap-3",
324
+ "aria-hidden": "true",
325
+ children: [
326
+ showSprites && /* @__PURE__ */ jsx3(
327
+ "img",
328
+ {
329
+ src: emotionIconPath,
330
+ alt: "",
331
+ className: "w-20 h-20 object-contain"
332
+ }
333
+ ),
334
+ /* @__PURE__ */ jsxs2("span", { className: "text-sm font-semibold tracking-wide", children: [
335
+ selectedFace.name,
336
+ " \u2022 ",
337
+ lastMessage.emotion
338
+ ] })
339
+ ]
340
+ }
341
+ )
342
+ }
343
+ );
344
+ }
345
+
346
+ // src/components/FaceView.tsx
347
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
348
+ var LazyPixiFaceView = lazy(
349
+ () => import("./pixi.js").then((module) => ({
350
+ default: module.PixiFaceView
351
+ }))
352
+ );
353
+ var LazyVizijFaceView = lazy(
354
+ () => import("./vizij.js").then((module) => ({
355
+ default: module.VizijFaceView
356
+ }))
357
+ );
358
+ var pixiFaceRendererStrategy = {
359
+ kind: "PixiFace",
360
+ displayName: "PixiJS 2D Face Renderer",
361
+ requiresWebGL: true,
362
+ getCapabilities: (face) => getFaceCapabilities(face),
363
+ render: ({ isPreview, frozen }) => /* @__PURE__ */ jsx4(LazyPixiFaceView, { isPreview, frozen })
364
+ };
365
+ var vizijFaceRendererStrategy = {
366
+ kind: "Vizij",
367
+ displayName: "Vizij 3D WebAssembly Face Renderer",
368
+ requiresWebGL: true,
369
+ getCapabilities: (face) => getFaceCapabilities(face),
370
+ render: () => /* @__PURE__ */ jsx4(LazyVizijFaceView, {})
371
+ };
372
+ function createDefaultFaceRendererRegistry() {
373
+ const registry = new FaceRendererRegistry();
374
+ registry.register(pixiFaceRendererStrategy);
375
+ registry.register(vizijFaceRendererStrategy);
376
+ return registry;
377
+ }
378
+ var defaultFaceRendererRegistry = createDefaultFaceRendererRegistry();
379
+ function FaceView({
380
+ isPreview = false,
381
+ frozen = false,
382
+ renderMode = "auto",
383
+ showStaticSprites = true,
384
+ registry = defaultFaceRendererRegistry,
385
+ labels,
386
+ className
387
+ } = {}) {
388
+ const uiLabels = resolveFaceUiLabels(labels);
389
+ const selectedFace = useFaceStore((state) => state.selectedFace);
390
+ const strategy = selectedFace ? registry.get(selectedFace.kind) : void 0;
391
+ const renderContent = () => {
392
+ if (!selectedFace || !strategy) {
393
+ return /* @__PURE__ */ jsx4(
394
+ "div",
395
+ {
396
+ role: "alert",
397
+ className: "flex items-center justify-center w-full h-full bg-slate-100 text-slate-800 text-sm p-4",
398
+ children: uiLabels.unknownFaceType
399
+ }
400
+ );
401
+ }
402
+ const useStaticFallback = renderMode === "static" || renderMode === "auto" && strategy.requiresWebGL && isHeadlessOrTestEnvironment();
403
+ if (useStaticFallback) {
404
+ return /* @__PURE__ */ jsx4(StaticFaceFallback, { showSprites: showStaticSprites });
405
+ }
406
+ return /* @__PURE__ */ jsx4(Suspense, { fallback: /* @__PURE__ */ jsx4(FaceViewSkeleton, { label: uiLabels.loading }), children: strategy.render({ face: selectedFace, isPreview, frozen }) });
407
+ };
408
+ return /* @__PURE__ */ jsxs3(
409
+ "div",
410
+ {
411
+ id: "face-view-container",
412
+ className: cn2(
413
+ "relative w-full h-full text-center overflow-hidden",
414
+ className
415
+ ),
416
+ children: [
417
+ renderContent(),
418
+ !isPreview && /* @__PURE__ */ jsx4(FaceCaption, {})
419
+ ]
420
+ }
421
+ );
422
+ }
423
+
424
+ // src/components/FaceAudioPrompt.tsx
425
+ import { useCallback } from "react";
426
+ import { Button, Icon, cn as cn3 } from "@peerbots/core";
427
+ import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
428
+ function FaceAudioPrompt({
429
+ className = "",
430
+ position = "absolute",
431
+ labels,
432
+ onEnable
433
+ }) {
434
+ const uiLabels = resolveFaceUiLabels(labels);
435
+ const speechAllowed = useFaceStore((state) => state.speechAllowed);
436
+ const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
437
+ const refreshVoices = useFaceStore((state) => state.refreshVoices);
438
+ const handleEnableAudio = useCallback(() => {
439
+ try {
440
+ if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
441
+ const utterance = new SpeechSynthesisUtterance(" ");
442
+ window.speechSynthesis.speak(utterance);
443
+ }
444
+ } catch (err) {
445
+ console.warn("Could not prime speechSynthesis:", err);
446
+ }
447
+ setSpeechAllowed(true);
448
+ void refreshVoices();
449
+ onEnable?.();
450
+ }, [setSpeechAllowed, refreshVoices, onEnable]);
451
+ if (speechAllowed) {
452
+ return null;
453
+ }
454
+ const positionClasses = position === "fixed" ? "fixed top-4 left-1/2 -translate-x-1/2 z-50" : position === "absolute" ? "absolute top-4 left-1/2 -translate-x-1/2 z-50" : "inline-flex";
455
+ return /* @__PURE__ */ jsx5(
456
+ "div",
457
+ {
458
+ className: cn3(positionClasses, className),
459
+ "data-testid": "face-audio-prompt",
460
+ children: /* @__PURE__ */ jsxs4(
461
+ Button,
462
+ {
463
+ variant: "solid",
464
+ color: "darkblue",
465
+ size: "sm",
466
+ onClick: handleEnableAudio,
467
+ className: "shadow-lg px-4 py-2 flex items-center gap-2 rounded-full cursor-pointer",
468
+ "aria-label": uiLabels.tapToEnableSound,
469
+ children: [
470
+ /* @__PURE__ */ jsx5(Icon, { name: "play", size: "sm", className: "w-3.5 h-3.5" }),
471
+ /* @__PURE__ */ jsx5("span", { className: "font-semibold text-xs tracking-wide", children: uiLabels.tapToEnableSound })
472
+ ]
473
+ }
474
+ )
475
+ }
476
+ );
477
+ }
478
+
479
+ // src/components/PoweredByVizij.tsx
480
+ import { cn as cn4 } from "@peerbots/core";
481
+ import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
482
+ function PoweredByVizij({
483
+ className,
484
+ poweredByLabel = DEFAULT_FACE_UI_LABELS.poweredBy
485
+ }) {
486
+ const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
487
+ return /* @__PURE__ */ jsxs5(
488
+ "a",
489
+ {
490
+ href: "https://vizij.ai",
491
+ target: "_blank",
492
+ rel: "noopener noreferrer",
493
+ className: cn4(
494
+ "inline-flex flex-col items-center gap-0.5 group transition-all hover:opacity-100 opacity-90",
495
+ className
496
+ ),
497
+ children: [
498
+ /* @__PURE__ */ jsx6("span", { className: "text-[9px] font-bold text-slate-600 uppercase tracking-[0.2em] leading-tight select-none", children: poweredByLabel }),
499
+ /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-1.5 focus-visible:outline-none", children: [
500
+ /* @__PURE__ */ jsx6("div", { className: "relative w-5 h-5 group-hover:scale-110 transition-transform duration-300 ease-out", children: /* @__PURE__ */ jsx6(
501
+ "img",
502
+ {
503
+ src: `${assetBaseUrl}/Vizij/brand.svg`,
504
+ alt: "Vizij Logo",
505
+ className: "w-full h-full object-contain"
506
+ }
507
+ ) }),
508
+ /* @__PURE__ */ jsx6(
509
+ "span",
510
+ {
511
+ style: {
512
+ fontFamily: "Gilroy, SFProRounded, ui-sans-serif, system-ui, sans-serif"
513
+ },
514
+ className: "text-lg font-bold tracking-tight text-teal-700",
515
+ children: "vizij"
516
+ }
517
+ )
518
+ ] })
519
+ ]
520
+ }
521
+ );
522
+ }
523
+
524
+ // src/components/FieldGroup.tsx
525
+ import { useId } from "react";
526
+ import { cn as cn5 } from "@peerbots/core";
527
+ import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
528
+ function FieldGroup({
529
+ label,
530
+ icon,
531
+ description,
532
+ children,
533
+ className,
534
+ id: customId
535
+ }) {
536
+ const generatedId = useId();
537
+ const labelId = customId || `field-group-${generatedId}`;
538
+ return /* @__PURE__ */ jsxs6(
539
+ "div",
540
+ {
541
+ role: "group",
542
+ "aria-labelledby": label ? labelId : void 0,
543
+ className: cn5("flex flex-col gap-1.5 w-full", className),
544
+ children: [
545
+ label && /* @__PURE__ */ jsxs6(
546
+ "span",
547
+ {
548
+ id: labelId,
549
+ className: "text-sm font-bold leading-6 text-slate-700 flex items-center gap-1",
550
+ children: [
551
+ icon && /* @__PURE__ */ jsx7("span", { className: "shrink-0", children: icon }),
552
+ label
553
+ ]
554
+ }
555
+ ),
556
+ children,
557
+ description && /* @__PURE__ */ jsx7("span", { className: "text-xs text-slate-600", children: description })
558
+ ]
559
+ }
560
+ );
561
+ }
562
+
563
+ // src/components/VoiceSelector.tsx
564
+ import { useMemo } from "react";
565
+ import { Select, Field, cn as cn6 } from "@peerbots/core";
566
+ import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
567
+ function VoiceSelector({
568
+ voices,
569
+ selectedVoiceUri,
570
+ selectedLanguage,
571
+ onVoiceChange,
572
+ onLanguageChange,
573
+ labels,
574
+ className
575
+ }) {
576
+ const uiLabels = resolveFaceUiLabels(labels);
577
+ const languages = useMemo(() => {
578
+ const unique = new Set(
579
+ voices.map((v) => getLanguageName(v.lang)).filter(Boolean)
580
+ );
581
+ if (selectedLanguage && !unique.has(selectedLanguage)) {
582
+ unique.add(selectedLanguage);
583
+ }
584
+ if (unique.size === 0) {
585
+ unique.add("English");
586
+ }
587
+ return Array.from(unique).sort().map((langName) => ({
588
+ label: langName,
589
+ value: langName
590
+ }));
591
+ }, [voices, selectedLanguage]);
592
+ const filteredVoices = useMemo(() => {
593
+ const list = voices.filter(
594
+ (v) => !selectedLanguage || getLanguageName(v.lang) === selectedLanguage
595
+ ).map((v) => ({
596
+ displayName: formatVoiceDisplayName(v.name || v.voiceURI),
597
+ voiceURI: v.voiceURI
598
+ })).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((voice) => ({
599
+ label: voice.displayName,
600
+ value: voice.voiceURI
601
+ }));
602
+ if (list.length === 0) {
603
+ return [
604
+ {
605
+ label: "System Default Voice",
606
+ value: selectedVoiceUri || "default"
607
+ }
608
+ ];
609
+ }
610
+ return list;
611
+ }, [voices, selectedLanguage, selectedVoiceUri]);
612
+ const activeVoiceValue = useMemo(() => {
613
+ if (!selectedVoiceUri) {
614
+ return filteredVoices[0]?.value ?? "";
615
+ }
616
+ const matched = findMatchingVoice(
617
+ filteredVoices.map((v) => ({ name: v.label, voiceURI: v.value })),
618
+ selectedVoiceUri
619
+ );
620
+ return matched ? matched.voiceURI : selectedVoiceUri;
621
+ }, [selectedVoiceUri, filteredVoices]);
622
+ return /* @__PURE__ */ jsxs7("div", { className: cn6("flex flex-col gap-3", className), children: [
623
+ /* @__PURE__ */ jsx8(Field, { label: uiLabels.voiceSelectorLanguage, className: "flex-col gap-1", children: /* @__PURE__ */ jsx8(
624
+ Select,
625
+ {
626
+ "aria-label": uiLabels.voiceSelectorLanguage,
627
+ className: "w-full",
628
+ value: selectedLanguage || languages[0]?.value || "English",
629
+ onChange: (val) => {
630
+ if (val && onLanguageChange) {
631
+ onLanguageChange(String(val));
632
+ }
633
+ },
634
+ options: languages
635
+ }
636
+ ) }),
637
+ /* @__PURE__ */ jsx8(Field, { label: uiLabels.voiceSelectorVoice, className: "flex-col gap-1", children: /* @__PURE__ */ jsx8(
638
+ Select,
639
+ {
640
+ "aria-label": uiLabels.voiceSelectorVoice,
641
+ className: "w-full",
642
+ value: activeVoiceValue,
643
+ onChange: (val) => {
644
+ if (val) {
645
+ onVoiceChange(String(val));
646
+ }
647
+ },
648
+ options: filteredVoices
649
+ }
650
+ ) })
651
+ ] });
652
+ }
653
+
654
+ // src/components/CharacterSelectionControls.tsx
655
+ import {
656
+ Select as Select2,
657
+ Field as Field2,
658
+ SettingsPanel,
659
+ Button as Button2,
660
+ Input,
661
+ Separator,
662
+ SliderWithNumberField,
663
+ TabRadio
664
+ } from "@peerbots/core";
665
+ import { Fragment, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
666
+ function CharacterSelectionControls({
667
+ enableVizij = true,
668
+ labels
669
+ } = {}) {
670
+ const uiLabels = resolveFaceUiLabels(labels);
671
+ const faceSettings = useFaceStore((state) => state.faceSettings);
672
+ const availableFaces2 = useFaceStore((state) => state.availableFaces);
673
+ const availableVoices = useFaceStore((state) => state.availableVoices);
674
+ const refreshVoices = useFaceStore((state) => state.refreshVoices);
675
+ const selectedFace = useFaceStore((state) => state.selectedFace);
676
+ const getSelectedVoice = useFaceStore((state) => state.getSelectedVoice);
677
+ const selectedVoiceUri = useFaceStore((state) => state.selectedVoiceUri);
678
+ const setLanguage = useFaceStore((state) => state.setLanguage);
679
+ const setVoice = useFaceStore((state) => state.setVoice);
680
+ const setFace = useFaceStore((state) => state.setFace);
681
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
682
+ const speechAllowed = useFaceStore((state) => state.speechAllowed);
683
+ const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
684
+ const currentVoiceUri = selectedVoiceUri || getSelectedVoice()?.voiceURI || "";
685
+ const selectableFaces = enableVizij ? availableFaces2 : availableFaces2.filter((f) => f.kind !== "Vizij");
686
+ const caps = getFaceCapabilities(selectedFace);
687
+ return /* @__PURE__ */ jsx9(SettingsPanel, { title: uiLabels.characterSelection, headingLevel: 4, children: /* @__PURE__ */ jsxs8("div", { className: "space-y-4", children: [
688
+ !speechAllowed && /* @__PURE__ */ jsxs8(Fragment, { children: [
689
+ /* @__PURE__ */ jsx9("div", { className: "flex", children: /* @__PURE__ */ jsx9(
690
+ Button2,
691
+ {
692
+ variant: "solid",
693
+ color: "darkblue",
694
+ size: "sm",
695
+ onClick: () => {
696
+ try {
697
+ if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
698
+ const utterance = new SpeechSynthesisUtterance(" ");
699
+ window.speechSynthesis.speak(utterance);
700
+ }
701
+ } catch (err) {
702
+ console.warn("SpeechSynthesis prime warning:", err);
703
+ }
704
+ setSpeechAllowed(true);
705
+ void refreshVoices();
706
+ },
707
+ children: uiLabels.allowSpeech
708
+ }
709
+ ) }),
710
+ /* @__PURE__ */ jsx9(Separator, {})
711
+ ] }),
712
+ /* @__PURE__ */ jsx9(
713
+ VoiceSelector,
714
+ {
715
+ voices: availableVoices,
716
+ selectedVoiceUri: currentVoiceUri,
717
+ selectedLanguage: faceSettings.selectedLanguage,
718
+ labels: uiLabels,
719
+ onLanguageChange: (newLang) => {
720
+ setLanguage(newLang);
721
+ const firstVoice = availableVoices.find(
722
+ (v) => getLanguageName(v.lang) === newLang
723
+ );
724
+ if (firstVoice) {
725
+ setVoice(firstVoice.voiceURI);
726
+ }
727
+ },
728
+ onVoiceChange: (newVoiceUri) => {
729
+ setVoice(newVoiceUri);
730
+ }
731
+ }
732
+ ),
733
+ /* @__PURE__ */ jsx9(Field2, { label: uiLabels.face, className: "flex-col gap-1", children: /* @__PURE__ */ jsx9(
734
+ Select2,
735
+ {
736
+ "aria-label": uiLabels.face,
737
+ className: "w-full",
738
+ value: selectedFace ? selectedFace.name : "Hugo",
739
+ onChange: (selectedName) => {
740
+ const found = selectableFaces.find(
741
+ (f) => f.name === String(selectedName)
742
+ );
743
+ if (found) {
744
+ setFace(found);
745
+ }
746
+ },
747
+ options: selectableFaces.map((face) => ({
748
+ label: face.name,
749
+ value: face.name
750
+ }))
751
+ }
752
+ ) }),
753
+ selectedFace?.name === "Custom Face" && /* @__PURE__ */ jsx9(Field2, { label: uiLabels.uploadGlb, className: "flex-col gap-1", children: /* @__PURE__ */ jsx9(
754
+ Input,
755
+ {
756
+ "aria-label": uiLabels.uploadGlb,
757
+ type: "file",
758
+ accept: ".glb",
759
+ className: "w-full text-sm text-slate-900",
760
+ onChange: (e) => {
761
+ const file = e.target.files?.[0];
762
+ if (file && selectedFace?.kind === "Vizij") {
763
+ const url = URL.createObjectURL(file);
764
+ const updatedFace = {
765
+ ...selectedFace,
766
+ assetBundle: {
767
+ ...selectedFace.assetBundle,
768
+ glb: {
769
+ kind: "url",
770
+ src: url,
771
+ aggressiveImport: true
772
+ }
773
+ }
774
+ };
775
+ setFace(updatedFace);
776
+ }
777
+ }
778
+ }
779
+ ) }),
780
+ selectedFace && /* @__PURE__ */ jsxs8("div", { className: "py-1.5 px-3 border-l-2 rtl:border-l-0 rtl:border-r-2 border-teal-700/30 bg-slate-50 rounded-r-md", children: [
781
+ /* @__PURE__ */ jsx9("span", { className: "text-[11px] font-bold text-slate-700 uppercase tracking-wider mb-1.5 block", children: uiLabels.faceCapabilities }),
782
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-row flex-wrap gap-x-4 gap-y-2", children: [
783
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-start gap-1.5 min-w-fit", children: [
784
+ /* @__PURE__ */ jsx9(
785
+ "span",
786
+ {
787
+ "aria-hidden": "true",
788
+ className: `mt-1 w-2 h-2 rounded-full ${caps.canExpressColor ? "bg-emerald-600" : "bg-slate-400"}`
789
+ }
790
+ ),
791
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col", children: [
792
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-semibold text-slate-800", children: uiLabels.color }),
793
+ typeof caps.canExpressColor === "string" && /* @__PURE__ */ jsx9("span", { className: "text-[11px] text-slate-600", children: caps.canExpressColor })
794
+ ] })
795
+ ] }),
796
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-start gap-1.5 min-w-fit", children: [
797
+ /* @__PURE__ */ jsx9(
798
+ "span",
799
+ {
800
+ "aria-hidden": "true",
801
+ className: `mt-1 w-2 h-2 rounded-full ${caps.canExpressEmotion ? "bg-emerald-600" : "bg-slate-400"}`
802
+ }
803
+ ),
804
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col", children: [
805
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-semibold text-slate-800", children: uiLabels.emotion }),
806
+ typeof caps.canExpressEmotion === "string" && /* @__PURE__ */ jsx9("span", { className: "text-[11px] text-slate-600", children: caps.canExpressEmotion })
807
+ ] })
808
+ ] }),
809
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-start gap-1.5 min-w-fit", children: [
810
+ /* @__PURE__ */ jsx9(
811
+ "span",
812
+ {
813
+ "aria-hidden": "true",
814
+ className: `mt-1 w-2 h-2 rounded-full ${caps.canLipSync ? "bg-emerald-600" : "bg-slate-400"}`
815
+ }
816
+ ),
817
+ /* @__PURE__ */ jsxs8("div", { className: "flex flex-col", children: [
818
+ /* @__PURE__ */ jsx9("span", { className: "text-xs font-semibold text-slate-800", children: uiLabels.speech }),
819
+ typeof caps.canLipSync === "string" && /* @__PURE__ */ jsx9("span", { className: "text-[11px] text-slate-600", children: caps.canLipSync })
820
+ ] })
821
+ ] })
822
+ ] })
823
+ ] }),
824
+ enableVizij && selectedFace?.kind === "Vizij" && /* @__PURE__ */ jsxs8(Fragment, { children: [
825
+ /* @__PURE__ */ jsx9(Separator, {}),
826
+ /* @__PURE__ */ jsxs8("div", { className: "space-y-3", children: [
827
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center justify-between", children: [
828
+ /* @__PURE__ */ jsx9("span", { className: "font-bold text-sm text-slate-800", children: uiLabels.faceSpecificSettings }),
829
+ /* @__PURE__ */ jsx9(PoweredByVizij, { poweredByLabel: uiLabels.poweredBy })
830
+ ] }),
831
+ /* @__PURE__ */ jsx9(FieldGroup, { label: uiLabels.faceExpressivity, children: /* @__PURE__ */ jsx9(
832
+ SliderWithNumberField,
833
+ {
834
+ "aria-label": uiLabels.faceExpressivity,
835
+ min: 0,
836
+ max: 1,
837
+ step: 0.05,
838
+ value: faceSettings.vizijSettings?.faceExpressivity ?? 1,
839
+ onChange: (val) => {
840
+ const vizijSettings = faceSettings.vizijSettings ?? defaultFaceSettings.vizijSettings;
841
+ setFaceSettings({
842
+ vizijSettings: {
843
+ ...vizijSettings,
844
+ faceExpressivity: val
845
+ }
846
+ });
847
+ }
848
+ }
849
+ ) })
850
+ ] })
851
+ ] }),
852
+ selectedFace?.kind === "PixiFace" && /* @__PURE__ */ jsxs8(Fragment, { children: [
853
+ /* @__PURE__ */ jsx9(Separator, {}),
854
+ /* @__PURE__ */ jsxs8("div", { className: "space-y-3", children: [
855
+ /* @__PURE__ */ jsx9("span", { className: "font-bold text-sm text-slate-800 block", children: uiLabels.faceSpecificSettings }),
856
+ selectedFace.type === "avatar" && /* @__PURE__ */ jsxs8("div", { className: "flex flex-col gap-3", children: [
857
+ /* @__PURE__ */ jsx9(
858
+ Field2,
859
+ {
860
+ label: uiLabels.eyes,
861
+ labelPlacement: "left",
862
+ className: "flex-row items-center justify-between",
863
+ children: /* @__PURE__ */ jsx9(
864
+ TabRadio,
865
+ {
866
+ "aria-label": uiLabels.eyes,
867
+ options: [
868
+ { value: "default", label: uiLabels.defaultOption },
869
+ { value: "none", label: uiLabels.noneOption }
870
+ ],
871
+ value: faceSettings.pixiSettings?.eyeDisplay ?? "default",
872
+ onChange: (val) => {
873
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
874
+ setFaceSettings({
875
+ pixiSettings: {
876
+ ...pixiSettings,
877
+ eyeDisplay: val || "default"
878
+ }
879
+ });
880
+ }
881
+ }
882
+ )
883
+ }
884
+ ),
885
+ /* @__PURE__ */ jsx9(
886
+ Field2,
887
+ {
888
+ label: uiLabels.mouth,
889
+ labelPlacement: "left",
890
+ className: "flex-row items-center justify-between",
891
+ children: /* @__PURE__ */ jsx9(
892
+ TabRadio,
893
+ {
894
+ "aria-label": uiLabels.mouth,
895
+ options: [
896
+ { value: "default", label: uiLabels.defaultOption },
897
+ { value: "none", label: uiLabels.noneOption }
898
+ ],
899
+ value: faceSettings.pixiSettings?.mouthDisplay ?? "default",
900
+ onChange: (val) => {
901
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
902
+ setFaceSettings({
903
+ pixiSettings: {
904
+ ...pixiSettings,
905
+ mouthDisplay: val || "default"
906
+ }
907
+ });
908
+ }
909
+ }
910
+ )
911
+ }
912
+ ),
913
+ /* @__PURE__ */ jsx9(
914
+ Field2,
915
+ {
916
+ label: uiLabels.cheeks,
917
+ labelPlacement: "left",
918
+ className: "flex-row items-center justify-between",
919
+ children: /* @__PURE__ */ jsx9(
920
+ TabRadio,
921
+ {
922
+ "aria-label": uiLabels.cheeks,
923
+ options: [
924
+ { value: "default", label: uiLabels.defaultOption },
925
+ { value: "none", label: uiLabels.noneOption }
926
+ ],
927
+ value: faceSettings.pixiSettings?.cheekDisplay ?? "default",
928
+ onChange: (val) => {
929
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
930
+ setFaceSettings({
931
+ pixiSettings: {
932
+ ...pixiSettings,
933
+ cheekDisplay: val || "default"
934
+ }
935
+ });
936
+ }
937
+ }
938
+ )
939
+ }
940
+ )
941
+ ] }),
942
+ selectedFace.type === "text" && /* @__PURE__ */ jsx9(
943
+ Field2,
944
+ {
945
+ label: uiLabels.emotionDisplay,
946
+ labelPlacement: "left",
947
+ className: "flex-row items-center justify-between",
948
+ children: /* @__PURE__ */ jsx9(
949
+ TabRadio,
950
+ {
951
+ "aria-label": uiLabels.emotionDisplay,
952
+ options: [
953
+ { value: "emoticon", label: uiLabels.emoticon },
954
+ { value: "emoji", label: uiLabels.emoji },
955
+ { value: "none", label: uiLabels.noneOption }
956
+ ],
957
+ value: faceSettings.pixiSettings?.emotionDisplay ?? "emoticon",
958
+ onChange: (val) => {
959
+ const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
960
+ setFaceSettings({
961
+ pixiSettings: {
962
+ ...pixiSettings,
963
+ emotionDisplay: val || "emoticon"
964
+ }
965
+ });
966
+ }
967
+ }
968
+ )
969
+ }
970
+ )
971
+ ] })
972
+ ] })
973
+ ] }) });
974
+ }
975
+ var CharacterSelectionSection = CharacterSelectionControls;
976
+
977
+ // src/components/FacePositioningControls.tsx
978
+ import {
979
+ Field as Field3,
980
+ SliderWithNumberField as SliderWithNumberField2,
981
+ Switch,
982
+ SettingsPanel as SettingsPanel2,
983
+ Button as Button3,
984
+ Separator as Separator2,
985
+ Icon as Icon2
986
+ } from "@peerbots/core";
987
+ import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
988
+ function FacePositioningControls({
989
+ labels
990
+ } = {}) {
991
+ const uiLabels = resolveFaceUiLabels(labels);
992
+ const faceSettings = useFaceStore((state) => state.faceSettings);
993
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
994
+ const resetPositioning = useFaceStore((state) => state.resetPositioning);
995
+ const isModified = faceSettings.zoom !== 1 || (faceSettings.offset?.x ?? 0) !== 0 || (faceSettings.offset?.y ?? 0) !== 0 || faceSettings.rotation !== 0;
996
+ return /* @__PURE__ */ jsx10(SettingsPanel2, { title: uiLabels.positioning, headingLevel: 4, children: /* @__PURE__ */ jsxs9("div", { className: "space-y-4", children: [
997
+ /* @__PURE__ */ jsxs9("div", { className: "flex w-full flex-wrap items-center justify-between gap-2", children: [
998
+ /* @__PURE__ */ jsx10(
999
+ Field3,
1000
+ {
1001
+ label: uiLabels.autoRotate,
1002
+ labelPlacement: "left",
1003
+ labelWeight: "normal",
1004
+ className: "flex-row items-center gap-2 mb-0 !w-auto",
1005
+ children: /* @__PURE__ */ jsx10(
1006
+ Switch,
1007
+ {
1008
+ "aria-label": uiLabels.autoRotate,
1009
+ checked: faceSettings.autoRotate,
1010
+ onChange: (checked) => {
1011
+ setFaceSettings({ autoRotate: checked });
1012
+ }
1013
+ }
1014
+ )
1015
+ }
1016
+ ),
1017
+ /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1.5 shrink-0", children: [
1018
+ /* @__PURE__ */ jsx10(
1019
+ Button3,
1020
+ {
1021
+ variant: "ghost",
1022
+ size: "sm",
1023
+ className: "p-1.5 text-xs whitespace-nowrap",
1024
+ onClick: () => {
1025
+ setFaceSettings({
1026
+ rotation: (faceSettings.rotation + 90) % 360
1027
+ });
1028
+ },
1029
+ leftIcon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowPath", className: "h-3.5 w-3.5" }),
1030
+ children: uiLabels.rotate
1031
+ }
1032
+ ),
1033
+ isModified && /* @__PURE__ */ jsx10(
1034
+ Button3,
1035
+ {
1036
+ variant: "ghost",
1037
+ size: "sm",
1038
+ className: "p-1.5 text-xs whitespace-nowrap",
1039
+ onClick: resetPositioning,
1040
+ leftIcon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowUturnLeft", className: "h-3.5 w-3.5" }),
1041
+ children: uiLabels.reset
1042
+ }
1043
+ )
1044
+ ] })
1045
+ ] }),
1046
+ /* @__PURE__ */ jsx10(Separator2, {}),
1047
+ /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-4", children: [
1048
+ /* @__PURE__ */ jsx10(
1049
+ FieldGroup,
1050
+ {
1051
+ label: uiLabels.zoom,
1052
+ icon: /* @__PURE__ */ jsx10(Icon2, { name: "magnifyingGlassPlus" }),
1053
+ children: /* @__PURE__ */ jsx10(
1054
+ SliderWithNumberField2,
1055
+ {
1056
+ "aria-label": uiLabels.zoom,
1057
+ min: 0.1,
1058
+ max: 3,
1059
+ step: 0.05,
1060
+ value: faceSettings.zoom,
1061
+ onChange: (val) => {
1062
+ setFaceSettings({ zoom: val });
1063
+ }
1064
+ }
1065
+ )
1066
+ }
1067
+ ),
1068
+ /* @__PURE__ */ jsx10(
1069
+ FieldGroup,
1070
+ {
1071
+ label: uiLabels.horizontalOffset,
1072
+ icon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowsRightLeft" }),
1073
+ children: /* @__PURE__ */ jsx10(
1074
+ SliderWithNumberField2,
1075
+ {
1076
+ "aria-label": uiLabels.horizontalOffset,
1077
+ min: -1e3,
1078
+ max: 1e3,
1079
+ value: faceSettings.offset?.x ?? 0,
1080
+ onChange: (val) => {
1081
+ setFaceSettings({
1082
+ offset: {
1083
+ x: val,
1084
+ y: faceSettings.offset?.y ?? 0
1085
+ }
1086
+ });
1087
+ }
1088
+ }
1089
+ )
1090
+ }
1091
+ ),
1092
+ /* @__PURE__ */ jsx10(
1093
+ FieldGroup,
1094
+ {
1095
+ label: uiLabels.verticalOffset,
1096
+ icon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowsUpDown" }),
1097
+ children: /* @__PURE__ */ jsx10(
1098
+ SliderWithNumberField2,
1099
+ {
1100
+ "aria-label": uiLabels.verticalOffset,
1101
+ min: -1e3,
1102
+ max: 1e3,
1103
+ value: faceSettings.offset?.y ?? 0,
1104
+ onChange: (val) => {
1105
+ setFaceSettings({
1106
+ offset: {
1107
+ x: faceSettings.offset?.x ?? 0,
1108
+ y: val
1109
+ }
1110
+ });
1111
+ }
1112
+ }
1113
+ )
1114
+ }
1115
+ )
1116
+ ] })
1117
+ ] }) });
1118
+ }
1119
+ var FacePositioningSection = FacePositioningControls;
1120
+
1121
+ // src/components/FaceBehaviorControls.tsx
1122
+ import {
1123
+ Field as Field4,
1124
+ Select as Select3,
1125
+ SliderWithNumberField as SliderWithNumberField3,
1126
+ SettingsPanel as SettingsPanel3,
1127
+ Separator as Separator3,
1128
+ Switch as Switch2
1129
+ } from "@peerbots/core";
1130
+ import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1131
+ function FaceBehaviorControls({
1132
+ labels
1133
+ } = {}) {
1134
+ const uiLabels = resolveFaceUiLabels(labels);
1135
+ const faceSettings = useFaceStore((state) => state.faceSettings);
1136
+ const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
1137
+ return /* @__PURE__ */ jsx11(SettingsPanel3, { title: uiLabels.faceSettings, headingLevel: 4, children: /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-4", children: [
1138
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2", children: [
1139
+ /* @__PURE__ */ jsx11("span", { className: "font-bold text-sm text-slate-800", children: uiLabels.onFaceButtons }),
1140
+ /* @__PURE__ */ jsx11(
1141
+ Field4,
1142
+ {
1143
+ label: uiLabels.showFullScreenButton,
1144
+ labelPlacement: "left",
1145
+ labelWeight: "normal",
1146
+ className: "flex-row items-center justify-between",
1147
+ children: /* @__PURE__ */ jsx11(
1148
+ Switch2,
1149
+ {
1150
+ "aria-label": uiLabels.showFullScreenButton,
1151
+ checked: faceSettings.showFullScreenButton,
1152
+ onChange: (checked) => {
1153
+ setFaceSettings({ showFullScreenButton: checked });
1154
+ }
1155
+ }
1156
+ )
1157
+ }
1158
+ ),
1159
+ /* @__PURE__ */ jsx11(
1160
+ Field4,
1161
+ {
1162
+ label: uiLabels.showScrollButton,
1163
+ labelPlacement: "left",
1164
+ labelWeight: "normal",
1165
+ className: "flex-row items-center justify-between",
1166
+ children: /* @__PURE__ */ jsx11(
1167
+ Switch2,
1168
+ {
1169
+ "aria-label": uiLabels.showScrollButton,
1170
+ checked: faceSettings.showScrollButton,
1171
+ onChange: (checked) => {
1172
+ setFaceSettings({ showScrollButton: checked });
1173
+ }
1174
+ }
1175
+ )
1176
+ }
1177
+ )
1178
+ ] }),
1179
+ /* @__PURE__ */ jsx11(Separator3, {}),
1180
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-2", children: [
1181
+ /* @__PURE__ */ jsx11("span", { className: "font-bold text-sm text-slate-800", children: uiLabels.speechBehavior }),
1182
+ /* @__PURE__ */ jsx11(Field4, { label: uiLabels.newButtonSpeech, className: "flex-col gap-1", children: /* @__PURE__ */ jsx11(
1183
+ Select3,
1184
+ {
1185
+ "aria-label": uiLabels.newButtonSpeech,
1186
+ className: "w-full",
1187
+ value: faceSettings.speechQueueMode || "interrupt",
1188
+ onChange: (val) => {
1189
+ if (val) {
1190
+ setFaceSettings({
1191
+ speechQueueMode: val
1192
+ });
1193
+ }
1194
+ },
1195
+ options: [
1196
+ {
1197
+ label: uiLabels.interruptSpeech,
1198
+ value: "interrupt"
1199
+ },
1200
+ {
1201
+ label: uiLabels.queueSpeech,
1202
+ value: "queue"
1203
+ }
1204
+ ]
1205
+ }
1206
+ ) })
1207
+ ] }),
1208
+ /* @__PURE__ */ jsx11(Separator3, {}),
1209
+ /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-3", children: [
1210
+ /* @__PURE__ */ jsx11(
1211
+ Field4,
1212
+ {
1213
+ label: uiLabels.captions,
1214
+ labelPlacement: "left",
1215
+ labelWeight: "bold",
1216
+ className: "flex-row items-center justify-between",
1217
+ children: /* @__PURE__ */ jsx11(
1218
+ Switch2,
1219
+ {
1220
+ "aria-label": uiLabels.captions,
1221
+ checked: faceSettings.captions?.enabled ?? false,
1222
+ onChange: (checked) => {
1223
+ setFaceSettings({
1224
+ captions: {
1225
+ ...faceSettings.captions,
1226
+ enabled: checked
1227
+ }
1228
+ });
1229
+ }
1230
+ }
1231
+ )
1232
+ }
1233
+ ),
1234
+ faceSettings.captions?.enabled && /* @__PURE__ */ jsxs10("div", { className: "flex flex-col gap-4 mt-1", children: [
1235
+ /* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.fontSize, children: /* @__PURE__ */ jsx11(
1236
+ SliderWithNumberField3,
1237
+ {
1238
+ "aria-label": uiLabels.fontSize,
1239
+ min: 10,
1240
+ max: 100,
1241
+ step: 1,
1242
+ value: faceSettings.captions?.fontSize ?? 32,
1243
+ onChange: (val) => {
1244
+ setFaceSettings({
1245
+ captions: {
1246
+ ...faceSettings.captions,
1247
+ fontSize: val
1248
+ }
1249
+ });
1250
+ }
1251
+ }
1252
+ ) }),
1253
+ /* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.horizontalOffset, children: /* @__PURE__ */ jsx11(
1254
+ SliderWithNumberField3,
1255
+ {
1256
+ "aria-label": uiLabels.horizontalOffset,
1257
+ min: -400,
1258
+ max: 400,
1259
+ step: 1,
1260
+ value: faceSettings.captions?.offset?.x ?? 0,
1261
+ onChange: (val) => {
1262
+ setFaceSettings({
1263
+ captions: {
1264
+ ...faceSettings.captions,
1265
+ offset: {
1266
+ x: val,
1267
+ y: faceSettings.captions?.offset?.y ?? 0
1268
+ }
1269
+ }
1270
+ });
1271
+ }
1272
+ }
1273
+ ) }),
1274
+ /* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.verticalPosition, children: /* @__PURE__ */ jsx11(
1275
+ SliderWithNumberField3,
1276
+ {
1277
+ "aria-label": uiLabels.verticalPosition,
1278
+ min: -50,
1279
+ max: 50,
1280
+ step: 1,
1281
+ value: faceSettings.captions?.offset?.y ?? 0,
1282
+ onChange: (val) => {
1283
+ setFaceSettings({
1284
+ captions: {
1285
+ ...faceSettings.captions,
1286
+ offset: {
1287
+ x: faceSettings.captions?.offset?.x ?? 0,
1288
+ y: val
1289
+ }
1290
+ }
1291
+ });
1292
+ }
1293
+ }
1294
+ ) })
1295
+ ] })
1296
+ ] })
1297
+ ] }) });
1298
+ }
1299
+ var ControlSettingsSection = FaceBehaviorControls;
1300
+
1301
+ // src/components/FaceSettingsPanel.tsx
1302
+ import { SettingsPanel as SettingsPanel4, cn as cn7 } from "@peerbots/core";
1303
+ import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1304
+ function FaceSettingsPanel({
1305
+ inline = false,
1306
+ enableVizij = true,
1307
+ columns = 3,
1308
+ labels,
1309
+ className
1310
+ } = {}) {
1311
+ const uiLabels = resolveFaceUiLabels(labels);
1312
+ const gridClass = columns === 1 ? "grid items-start gap-4 grid-cols-1" : "grid items-start gap-4 lg:gap-6 grid-cols-1 md:grid-cols-2 lg:grid-cols-3";
1313
+ const content = /* @__PURE__ */ jsxs11("div", { className: cn7(gridClass, className), children: [
1314
+ /* @__PURE__ */ jsx12("div", { className: "min-w-0 h-full", children: /* @__PURE__ */ jsx12(CharacterSelectionControls, { enableVizij, labels: uiLabels }) }),
1315
+ /* @__PURE__ */ jsx12("div", { className: "min-w-0 h-full", children: /* @__PURE__ */ jsx12(FacePositioningControls, { labels: uiLabels }) }),
1316
+ /* @__PURE__ */ jsx12("div", { className: "min-w-0 h-full", children: /* @__PURE__ */ jsx12(FaceBehaviorControls, { labels: uiLabels }) })
1317
+ ] });
1318
+ if (inline) {
1319
+ return content;
1320
+ }
1321
+ return /* @__PURE__ */ jsx12(SettingsPanel4, { title: uiLabels.faceSettings, children: content });
1322
+ }
1323
+ var FaceSettingsControl = FaceSettingsPanel;
1324
+ export {
1325
+ AudioAnalyzer,
1326
+ CONNECTION_FACE_MESSAGE,
1327
+ CharacterSelectionControls,
1328
+ CharacterSelectionSection,
1329
+ ControlSettingsSection,
1330
+ DEFAULT_FACE_MESSAGE,
1331
+ DEFAULT_FACE_UI_LABELS,
1332
+ EMOTION_EMOJIS,
1333
+ EMOTION_EMOTICONS,
1334
+ EMOTION_ICON_FILES,
1335
+ FaceAudioPrompt,
1336
+ FaceBehaviorControls,
1337
+ FaceCaption,
1338
+ FacePositioningControls,
1339
+ FacePositioningSection,
1340
+ FaceRendererRegistry,
1341
+ FaceSettingsControl,
1342
+ FaceSettingsPanel,
1343
+ FaceStoreContext,
1344
+ FaceStoreProvider,
1345
+ FaceView,
1346
+ FaceViewSkeleton,
1347
+ FieldGroup,
1348
+ PEERBOTS_COLORS,
1349
+ PEERBOTS_EMOTIONS,
1350
+ PoweredByVizij,
1351
+ StaticFaceFallback,
1352
+ TtsAudioCache,
1353
+ VoiceSelector,
1354
+ audioAnalyzer,
1355
+ availableFaces,
1356
+ blobToArrayBuffer,
1357
+ buildTtsCacheKey,
1358
+ builtInFaces,
1359
+ color_mapping,
1360
+ createBuiltInFaces,
1361
+ createBuiltInPixiFaces,
1362
+ createCustomVizijFace,
1363
+ createDefaultFaceRendererRegistry,
1364
+ createFaceRenderingSlice,
1365
+ createFaceSpeechSlice,
1366
+ createIncludedVizijFaces,
1367
+ createPeerbotsFaceStore,
1368
+ customFace,
1369
+ deconstructRgba,
1370
+ defaultFace,
1371
+ defaultFaceRendererRegistry,
1372
+ defaultFaceSettings,
1373
+ defaultTtsAudioCache,
1374
+ emotion_mapping,
1375
+ estimateVisemesFromText,
1376
+ findMatchingVoice,
1377
+ font_color_mapping,
1378
+ formatRbga,
1379
+ formatRgba,
1380
+ formatVoiceDisplayName,
1381
+ getEmotionEyeSpritePaths,
1382
+ getEmotionIconPath,
1383
+ getFaceCapabilities,
1384
+ getLanguageName,
1385
+ globalFaceStore,
1386
+ hexToRgb,
1387
+ hexToRgba,
1388
+ includedVizijFaces,
1389
+ interpolateColor,
1390
+ isHeadlessOrTestEnvironment,
1391
+ isWebGLAvailable,
1392
+ mapVisemeToVizijTarget,
1393
+ mergeFaceSettings,
1394
+ normalizeAssetBaseUrl,
1395
+ pixiFaceRendererStrategy,
1396
+ pollyVisemeToVizijPath,
1397
+ possiblePollyVisemes,
1398
+ rbgToRgba,
1399
+ resolveFaceUiLabels,
1400
+ rgbToRgba,
1401
+ rgbaToHex,
1402
+ stopNativeSpeechSynthesis,
1403
+ useFaceStore,
1404
+ useFaceStoreInstance,
1405
+ useMessageVisualState,
1406
+ vizijFaceRendererStrategy
1407
+ };
1408
+ //# sourceMappingURL=index.js.map