@nightzeros/chatai-widget 1.2.0 → 1.4.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.
- package/README.md +8 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +1192 -162
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
import { render } from "preact";
|
|
3
3
|
|
|
4
4
|
// src/app.tsx
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import {
|
|
5
|
+
import { useEffect as useEffect5, useMemo, useRef as useRef5, useState } from "preact/hooks";
|
|
6
|
+
import {
|
|
7
|
+
createWidgetController,
|
|
8
|
+
isVoiceActive as isVoiceActive4,
|
|
9
|
+
mergeVoiceAppearance,
|
|
10
|
+
parseVoiceAppearance,
|
|
11
|
+
resolveVoiceAppearance
|
|
12
|
+
} from "@nightzeros/chatai-widget-core";
|
|
7
13
|
|
|
8
14
|
// src/markdown-message.tsx
|
|
9
15
|
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
@@ -182,6 +188,9 @@ function MarkdownMessage({
|
|
|
182
188
|
] });
|
|
183
189
|
}
|
|
184
190
|
|
|
191
|
+
// src/voice/voice-dock.tsx
|
|
192
|
+
import { useEffect as useEffect4, useRef as useRef4 } from "preact/hooks";
|
|
193
|
+
|
|
185
194
|
// src/voice-ui.tsx
|
|
186
195
|
import { useEffect, useRef } from "preact/hooks";
|
|
187
196
|
import {
|
|
@@ -311,9 +320,757 @@ function VoiceBar({
|
|
|
311
320
|
] });
|
|
312
321
|
}
|
|
313
322
|
|
|
314
|
-
// src/
|
|
323
|
+
// src/voice/voice-captions.tsx
|
|
315
324
|
import { jsx as jsx3, jsxs as jsxs3 } from "preact/jsx-runtime";
|
|
325
|
+
function VoiceCaptions({
|
|
326
|
+
messages,
|
|
327
|
+
open
|
|
328
|
+
}) {
|
|
329
|
+
if (!open) return null;
|
|
330
|
+
const turns = messages.filter((message) => message.modality === "voice");
|
|
331
|
+
if (turns.length === 0) {
|
|
332
|
+
return /* @__PURE__ */ jsx3("div", { className: "chatai-voice-captions is-empty", "aria-live": "polite", children: /* @__PURE__ */ jsx3("p", { children: "Captions appear as you talk." }) });
|
|
333
|
+
}
|
|
334
|
+
const recent = turns.slice(-6);
|
|
335
|
+
return /* @__PURE__ */ jsx3("div", { className: "chatai-voice-captions", "aria-live": "polite", children: recent.map((message, index) => /* @__PURE__ */ jsxs3(
|
|
336
|
+
"p",
|
|
337
|
+
{
|
|
338
|
+
className: `chatai-voice-caption ${message.role}${message.live ? " is-live" : ""}`,
|
|
339
|
+
children: [
|
|
340
|
+
/* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-who", children: message.role === "user" ? "You" : "Assistant" }),
|
|
341
|
+
/* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-text", children: message.content || "\u2026" }),
|
|
342
|
+
message.interrupted ? /* @__PURE__ */ jsx3("span", { className: "chatai-voice-caption-note", children: "Interrupted" }) : null
|
|
343
|
+
]
|
|
344
|
+
},
|
|
345
|
+
`${message.role}-${index}-${message.content.slice(0, 24)}`
|
|
346
|
+
)) });
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// src/voice/voice-companion.tsx
|
|
350
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "preact/hooks";
|
|
351
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "preact/jsx-runtime";
|
|
352
|
+
function prefersReducedMotion2() {
|
|
353
|
+
return typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
|
|
354
|
+
}
|
|
355
|
+
function VoiceCompanionCharacter({
|
|
356
|
+
motion,
|
|
357
|
+
levels,
|
|
358
|
+
reducedMotion
|
|
359
|
+
}) {
|
|
360
|
+
const ref = useRef2(null);
|
|
361
|
+
const motionRef = useRef2(motion);
|
|
362
|
+
motionRef.current = motion;
|
|
363
|
+
useEffect2(() => {
|
|
364
|
+
const el = ref.current;
|
|
365
|
+
if (!el) return;
|
|
366
|
+
const reduced = reducedMotion || prefersReducedMotion2();
|
|
367
|
+
if (reduced || typeof requestAnimationFrame === "undefined") {
|
|
368
|
+
el.style.removeProperty("--chatai-companion-energy");
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
let frame = 0;
|
|
372
|
+
const draw = () => {
|
|
373
|
+
const current = motionRef.current;
|
|
374
|
+
let energy = 0;
|
|
375
|
+
if (current === "hearing") {
|
|
376
|
+
energy = Math.min(1, levels().input * 8);
|
|
377
|
+
} else if (current === "speaking") {
|
|
378
|
+
energy = Math.min(1, levels().output * 8);
|
|
379
|
+
} else if (current === "processing" || current === "pending") {
|
|
380
|
+
energy = 0.35;
|
|
381
|
+
} else if (current === "listening") {
|
|
382
|
+
energy = 0.12;
|
|
383
|
+
}
|
|
384
|
+
el.style.setProperty("--chatai-companion-energy", energy.toFixed(3));
|
|
385
|
+
frame = requestAnimationFrame(draw);
|
|
386
|
+
};
|
|
387
|
+
frame = requestAnimationFrame(draw);
|
|
388
|
+
return () => {
|
|
389
|
+
cancelAnimationFrame(frame);
|
|
390
|
+
el.style.removeProperty("--chatai-companion-energy");
|
|
391
|
+
};
|
|
392
|
+
}, [levels, reducedMotion]);
|
|
393
|
+
return /* @__PURE__ */ jsxs4(
|
|
394
|
+
"div",
|
|
395
|
+
{
|
|
396
|
+
ref,
|
|
397
|
+
className: "chatai-companion-character",
|
|
398
|
+
"data-motion": motion,
|
|
399
|
+
"aria-hidden": "true",
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-body" }),
|
|
402
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-eye chatai-companion-eye-left" }),
|
|
403
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-eye chatai-companion-eye-right" }),
|
|
404
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-smile" }),
|
|
405
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-foot chatai-companion-foot-left" }),
|
|
406
|
+
/* @__PURE__ */ jsx4("span", { className: "chatai-companion-foot chatai-companion-foot-right" })
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function VoiceCompanionCanvas({
|
|
412
|
+
assistantName,
|
|
413
|
+
welcomeMessage,
|
|
414
|
+
voiceOffered,
|
|
415
|
+
onStart
|
|
416
|
+
}) {
|
|
417
|
+
const speech = welcomeMessage?.trim() || `Hi \u2014 I\u2019m ${assistantName}. Ready when you are.`;
|
|
418
|
+
return /* @__PURE__ */ jsxs4("div", { className: "chatai-companion", children: [
|
|
419
|
+
/* @__PURE__ */ jsx4("p", { className: "chatai-companion-kicker", children: "Live companion" }),
|
|
420
|
+
/* @__PURE__ */ jsx4("h3", { className: "chatai-companion-title", children: assistantName }),
|
|
421
|
+
/* @__PURE__ */ jsx4("p", { className: "chatai-companion-speech", "aria-live": "polite", children: speech }),
|
|
422
|
+
/* @__PURE__ */ jsx4(
|
|
423
|
+
VoiceCompanionCharacter,
|
|
424
|
+
{
|
|
425
|
+
motion: "static",
|
|
426
|
+
levels: () => ({ input: 0, output: 0 }),
|
|
427
|
+
reducedMotion: true
|
|
428
|
+
}
|
|
429
|
+
),
|
|
430
|
+
voiceOffered ? /* @__PURE__ */ jsx4(
|
|
431
|
+
"button",
|
|
432
|
+
{
|
|
433
|
+
type: "button",
|
|
434
|
+
className: "chatai-voice-primary chatai-companion-start",
|
|
435
|
+
onClick: onStart,
|
|
436
|
+
children: "Start conversation"
|
|
437
|
+
}
|
|
438
|
+
) : null,
|
|
439
|
+
/* @__PURE__ */ jsx4("p", { className: "chatai-companion-hint", children: "Stylized companion \xB7 tap Start to talk" })
|
|
440
|
+
] });
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/voice/voice-controls.tsx
|
|
444
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "preact/jsx-runtime";
|
|
445
|
+
function VoiceControls({
|
|
446
|
+
presentation,
|
|
447
|
+
captionsOpen,
|
|
448
|
+
onStart,
|
|
449
|
+
onEnd,
|
|
450
|
+
onMute,
|
|
451
|
+
onToggleCaptions,
|
|
452
|
+
onRetry,
|
|
453
|
+
onDismiss
|
|
454
|
+
}) {
|
|
455
|
+
const { canStart, canEnd, canMute, canToggleCaptions, canRetry, canDismiss, microphoneMuted } = presentation;
|
|
456
|
+
const startAgain = Boolean(presentation.notice || presentation.status === "Voice ended");
|
|
457
|
+
return /* @__PURE__ */ jsxs5("div", { className: "chatai-voice-controls", children: [
|
|
458
|
+
canStart ? /* @__PURE__ */ jsx5(
|
|
459
|
+
"button",
|
|
460
|
+
{
|
|
461
|
+
type: "button",
|
|
462
|
+
className: "chatai-voice-primary",
|
|
463
|
+
onClick: onStart,
|
|
464
|
+
"aria-label": startAgain ? "Start again" : "Start conversation",
|
|
465
|
+
children: startAgain ? "Start again" : /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
466
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Start conversation" }),
|
|
467
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "Start" })
|
|
468
|
+
] })
|
|
469
|
+
}
|
|
470
|
+
) : null,
|
|
471
|
+
canEnd ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-danger", onClick: onEnd, "aria-label": "End voice", children: "End" }) : null,
|
|
472
|
+
canMute ? /* @__PURE__ */ jsxs5(
|
|
473
|
+
"button",
|
|
474
|
+
{
|
|
475
|
+
type: "button",
|
|
476
|
+
className: `chatai-voice-secondary${microphoneMuted ? " is-pressed" : ""}`,
|
|
477
|
+
onClick: () => onMute(!microphoneMuted),
|
|
478
|
+
"aria-pressed": microphoneMuted,
|
|
479
|
+
"aria-label": microphoneMuted ? "Unmute microphone" : "Mute microphone",
|
|
480
|
+
children: [
|
|
481
|
+
/* @__PURE__ */ jsx5(MicGlyph, { off: microphoneMuted }),
|
|
482
|
+
/* @__PURE__ */ jsx5("span", { children: microphoneMuted ? "Unmute" : "Mute" })
|
|
483
|
+
]
|
|
484
|
+
}
|
|
485
|
+
) : null,
|
|
486
|
+
canToggleCaptions ? /* @__PURE__ */ jsxs5(
|
|
487
|
+
"button",
|
|
488
|
+
{
|
|
489
|
+
type: "button",
|
|
490
|
+
className: `chatai-voice-secondary${captionsOpen ? " is-pressed" : ""}`,
|
|
491
|
+
onClick: onToggleCaptions,
|
|
492
|
+
"aria-pressed": captionsOpen,
|
|
493
|
+
"aria-label": captionsOpen ? "Hide captions" : "Show captions",
|
|
494
|
+
children: [
|
|
495
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Captions" }),
|
|
496
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "CC" })
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
) : null,
|
|
500
|
+
canRetry ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-primary", onClick: onRetry, children: "Try again" }) : null,
|
|
501
|
+
canDismiss ? /* @__PURE__ */ jsx5("button", { type: "button", className: "chatai-voice-secondary", onClick: onDismiss, children: presentation.consentPending ? "Cancel" : /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
502
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-long", children: "Back to chat" }),
|
|
503
|
+
/* @__PURE__ */ jsx5("span", { className: "chatai-voice-label-short", children: "Chat" })
|
|
504
|
+
] }) }) : null
|
|
505
|
+
] });
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// src/voice/voice-orb.tsx
|
|
509
|
+
import { useEffect as useEffect3, useRef as useRef3 } from "preact/hooks";
|
|
510
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "preact/jsx-runtime";
|
|
511
|
+
function prefersReducedMotion3() {
|
|
512
|
+
return typeof window !== "undefined" && Boolean(window.matchMedia?.("(prefers-reduced-motion: reduce)").matches);
|
|
513
|
+
}
|
|
514
|
+
function VoiceOrb({
|
|
515
|
+
motion,
|
|
516
|
+
levels,
|
|
517
|
+
reducedMotion
|
|
518
|
+
}) {
|
|
519
|
+
const ref = useRef3(null);
|
|
520
|
+
const motionRef = useRef3(motion);
|
|
521
|
+
motionRef.current = motion;
|
|
522
|
+
useEffect3(() => {
|
|
523
|
+
const el = ref.current;
|
|
524
|
+
if (!el) return;
|
|
525
|
+
const reduced = reducedMotion || prefersReducedMotion3();
|
|
526
|
+
if (reduced || typeof requestAnimationFrame === "undefined") {
|
|
527
|
+
el.style.removeProperty("--chatai-orb-energy");
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
let frame = 0;
|
|
531
|
+
const draw = () => {
|
|
532
|
+
const current = motionRef.current;
|
|
533
|
+
let energy = 0;
|
|
534
|
+
if (current === "hearing") {
|
|
535
|
+
energy = Math.min(1, levels().input * 8);
|
|
536
|
+
} else if (current === "speaking") {
|
|
537
|
+
energy = Math.min(1, levels().output * 8);
|
|
538
|
+
} else if (current === "processing" || current === "pending") {
|
|
539
|
+
energy = 0.35;
|
|
540
|
+
} else if (current === "listening") {
|
|
541
|
+
energy = 0.12;
|
|
542
|
+
}
|
|
543
|
+
el.style.setProperty("--chatai-orb-energy", energy.toFixed(3));
|
|
544
|
+
frame = requestAnimationFrame(draw);
|
|
545
|
+
};
|
|
546
|
+
frame = requestAnimationFrame(draw);
|
|
547
|
+
return () => {
|
|
548
|
+
cancelAnimationFrame(frame);
|
|
549
|
+
el.style.removeProperty("--chatai-orb-energy");
|
|
550
|
+
};
|
|
551
|
+
}, [levels, reducedMotion]);
|
|
552
|
+
return /* @__PURE__ */ jsxs6(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
ref,
|
|
556
|
+
className: "chatai-orb",
|
|
557
|
+
"data-motion": motion,
|
|
558
|
+
"aria-hidden": "true",
|
|
559
|
+
children: [
|
|
560
|
+
/* @__PURE__ */ jsx6("span", { className: "chatai-orb-core" }),
|
|
561
|
+
/* @__PURE__ */ jsx6("span", { className: "chatai-orb-shine" }),
|
|
562
|
+
/* @__PURE__ */ jsx6("span", { className: "chatai-orb-shadow" })
|
|
563
|
+
]
|
|
564
|
+
}
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/voice/voice-presentation.ts
|
|
569
|
+
import {
|
|
570
|
+
isVoiceActive as isVoiceActive2
|
|
571
|
+
} from "@nightzeros/chatai-widget-core";
|
|
572
|
+
function voiceMeta2(voice) {
|
|
573
|
+
if (voice.mock) return "Test mode \xB7 no audio";
|
|
574
|
+
if (voice.ephemeral) return "Not saved";
|
|
575
|
+
const parts = [
|
|
576
|
+
voice.recording ? "Recording" : "",
|
|
577
|
+
voice.transcriptSaved === false ? "Voice transcript not saved" : ""
|
|
578
|
+
];
|
|
579
|
+
return parts.filter(Boolean).join(" \xB7 ");
|
|
580
|
+
}
|
|
581
|
+
function voiceStageVisible(voice) {
|
|
582
|
+
if (voice.consentPending) return true;
|
|
583
|
+
if (isVoiceActive2(voice.connection)) return true;
|
|
584
|
+
if (voice.connection === "failed") return true;
|
|
585
|
+
if (voice.connection === "ended") return true;
|
|
586
|
+
return false;
|
|
587
|
+
}
|
|
588
|
+
function presentVoice(voice) {
|
|
589
|
+
const active = isVoiceActive2(voice.connection);
|
|
590
|
+
const failed = voice.connection === "failed";
|
|
591
|
+
const ended = voice.connection === "ended";
|
|
592
|
+
const consentPending = Boolean(voice.consentPending);
|
|
593
|
+
const microphoneMuted = Boolean(voice.microphoneMuted);
|
|
594
|
+
const meta = voiceMeta2(voice);
|
|
595
|
+
if (consentPending) {
|
|
596
|
+
return {
|
|
597
|
+
status: "This voice conversation is recorded",
|
|
598
|
+
motion: "static",
|
|
599
|
+
canStart: false,
|
|
600
|
+
canEnd: false,
|
|
601
|
+
canMute: false,
|
|
602
|
+
canToggleCaptions: false,
|
|
603
|
+
canRetry: false,
|
|
604
|
+
canDismiss: true,
|
|
605
|
+
meta,
|
|
606
|
+
microphoneMuted: false,
|
|
607
|
+
consentPending: true
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
if (failed) {
|
|
611
|
+
return {
|
|
612
|
+
status: "Voice stopped",
|
|
613
|
+
motion: "static",
|
|
614
|
+
canStart: false,
|
|
615
|
+
canEnd: false,
|
|
616
|
+
canMute: false,
|
|
617
|
+
canToggleCaptions: false,
|
|
618
|
+
canRetry: voice.error?.code !== "unsupported",
|
|
619
|
+
canDismiss: true,
|
|
620
|
+
errorMessage: voice.error?.message,
|
|
621
|
+
meta,
|
|
622
|
+
microphoneMuted: false,
|
|
623
|
+
consentPending: false
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
if (ended) {
|
|
627
|
+
return {
|
|
628
|
+
status: "Voice ended",
|
|
629
|
+
motion: "static",
|
|
630
|
+
canStart: true,
|
|
631
|
+
canEnd: false,
|
|
632
|
+
canMute: false,
|
|
633
|
+
canToggleCaptions: true,
|
|
634
|
+
canRetry: false,
|
|
635
|
+
canDismiss: true,
|
|
636
|
+
notice: voice.notice,
|
|
637
|
+
meta,
|
|
638
|
+
microphoneMuted: false,
|
|
639
|
+
consentPending: false
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
if (!active) {
|
|
643
|
+
return {
|
|
644
|
+
status: "Ready when you are",
|
|
645
|
+
motion: "static",
|
|
646
|
+
canStart: true,
|
|
647
|
+
canEnd: false,
|
|
648
|
+
canMute: false,
|
|
649
|
+
canToggleCaptions: true,
|
|
650
|
+
canRetry: false,
|
|
651
|
+
canDismiss: true,
|
|
652
|
+
meta,
|
|
653
|
+
microphoneMuted: false,
|
|
654
|
+
consentPending: false
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
let status;
|
|
658
|
+
let motion;
|
|
659
|
+
switch (voice.phase) {
|
|
660
|
+
case "requesting_mic":
|
|
661
|
+
status = "Allow microphone access";
|
|
662
|
+
motion = "static";
|
|
663
|
+
break;
|
|
664
|
+
case "connecting":
|
|
665
|
+
status = "Connecting\u2026";
|
|
666
|
+
motion = "pending";
|
|
667
|
+
break;
|
|
668
|
+
case "listening":
|
|
669
|
+
status = "I\u2019m listening";
|
|
670
|
+
motion = "listening";
|
|
671
|
+
break;
|
|
672
|
+
case "user_speaking":
|
|
673
|
+
status = "Hearing you";
|
|
674
|
+
motion = "hearing";
|
|
675
|
+
break;
|
|
676
|
+
case "processing":
|
|
677
|
+
status = "Looking that up\u2026";
|
|
678
|
+
motion = "processing";
|
|
679
|
+
break;
|
|
680
|
+
case "assistant_speaking":
|
|
681
|
+
status = "Speaking";
|
|
682
|
+
motion = "speaking";
|
|
683
|
+
break;
|
|
684
|
+
case "interrupted":
|
|
685
|
+
status = "Interrupted \u2014 go ahead";
|
|
686
|
+
motion = "settle";
|
|
687
|
+
break;
|
|
688
|
+
case "reconnecting":
|
|
689
|
+
status = "Reconnecting\u2026";
|
|
690
|
+
motion = "static";
|
|
691
|
+
break;
|
|
692
|
+
default:
|
|
693
|
+
status = "I\u2019m listening";
|
|
694
|
+
motion = "listening";
|
|
695
|
+
}
|
|
696
|
+
if (microphoneMuted && voice.connection === "connected") {
|
|
697
|
+
status = "Microphone muted";
|
|
698
|
+
}
|
|
699
|
+
return {
|
|
700
|
+
status,
|
|
701
|
+
motion,
|
|
702
|
+
canStart: false,
|
|
703
|
+
canEnd: true,
|
|
704
|
+
canMute: voice.connection === "connected" || voice.connection === "reconnecting",
|
|
705
|
+
canToggleCaptions: true,
|
|
706
|
+
canRetry: false,
|
|
707
|
+
canDismiss: false,
|
|
708
|
+
meta,
|
|
709
|
+
microphoneMuted,
|
|
710
|
+
consentPending: false
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
// src/voice/voice-stage.tsx
|
|
715
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs7 } from "preact/jsx-runtime";
|
|
716
|
+
function VoiceStage({
|
|
717
|
+
assistantName,
|
|
718
|
+
voice,
|
|
719
|
+
messages,
|
|
720
|
+
levels,
|
|
721
|
+
captionsOpen,
|
|
722
|
+
layout = "orb",
|
|
723
|
+
visual = "orb",
|
|
724
|
+
reducedMotion,
|
|
725
|
+
accentColor,
|
|
726
|
+
onStart,
|
|
727
|
+
onEnd,
|
|
728
|
+
onMute,
|
|
729
|
+
onToggleCaptions,
|
|
730
|
+
onRetry,
|
|
731
|
+
onDismiss,
|
|
732
|
+
onAcceptConsent,
|
|
733
|
+
onDeclineConsent
|
|
734
|
+
}) {
|
|
735
|
+
const presentation = presentVoice(voice);
|
|
736
|
+
const statusId = "chatai-voice-stage-status";
|
|
737
|
+
const companion = visual === "companion";
|
|
738
|
+
return /* @__PURE__ */ jsxs7(
|
|
739
|
+
"div",
|
|
740
|
+
{
|
|
741
|
+
className: `chatai-voice-stage layout-${layout}${companion ? " visual-companion" : ""}`,
|
|
742
|
+
"data-phase": voice.phase,
|
|
743
|
+
"data-motion": presentation.motion,
|
|
744
|
+
style: accentColor ? { "--chatai-voice-accent": accentColor } : void 0,
|
|
745
|
+
children: [
|
|
746
|
+
/* @__PURE__ */ jsxs7("p", { className: "chatai-voice-identity", children: [
|
|
747
|
+
/* @__PURE__ */ jsx7("span", { className: "chatai-kicker", children: companion ? "Live companion" : "Live voice" }),
|
|
748
|
+
/* @__PURE__ */ jsx7("span", { className: "chatai-voice-name", children: assistantName })
|
|
749
|
+
] }),
|
|
750
|
+
companion ? /* @__PURE__ */ jsx7(
|
|
751
|
+
VoiceCompanionCharacter,
|
|
752
|
+
{
|
|
753
|
+
motion: presentation.motion,
|
|
754
|
+
levels,
|
|
755
|
+
reducedMotion
|
|
756
|
+
}
|
|
757
|
+
) : /* @__PURE__ */ jsx7(VoiceOrb, { motion: presentation.motion, levels, reducedMotion }),
|
|
758
|
+
/* @__PURE__ */ jsx7("p", { id: statusId, className: "chatai-voice-stage-status", role: "status", "aria-live": "polite", children: presentation.status }),
|
|
759
|
+
presentation.errorMessage ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-detail", role: "alert", children: presentation.errorMessage }) : null,
|
|
760
|
+
presentation.notice ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-detail", children: presentation.notice }) : null,
|
|
761
|
+
presentation.meta ? /* @__PURE__ */ jsx7("p", { className: "chatai-voice-stage-meta", children: presentation.meta }) : null,
|
|
762
|
+
presentation.consentPending ? /* @__PURE__ */ jsx7(VoiceConsent, { onAccept: onAcceptConsent, onCancel: onDeclineConsent }) : /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
763
|
+
/* @__PURE__ */ jsx7(VoiceCaptions, { messages, open: captionsOpen }),
|
|
764
|
+
/* @__PURE__ */ jsx7(
|
|
765
|
+
VoiceControls,
|
|
766
|
+
{
|
|
767
|
+
presentation,
|
|
768
|
+
captionsOpen,
|
|
769
|
+
onStart,
|
|
770
|
+
onEnd,
|
|
771
|
+
onMute,
|
|
772
|
+
onToggleCaptions,
|
|
773
|
+
onRetry,
|
|
774
|
+
onDismiss
|
|
775
|
+
}
|
|
776
|
+
)
|
|
777
|
+
] })
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
// src/voice/voice-dock.tsx
|
|
784
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "preact/jsx-runtime";
|
|
316
785
|
var FOCUSABLE = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
786
|
+
function VoiceDockSurface({
|
|
787
|
+
appearance,
|
|
788
|
+
assistantName,
|
|
789
|
+
voice,
|
|
790
|
+
messages,
|
|
791
|
+
levels,
|
|
792
|
+
captionsOpen,
|
|
793
|
+
onClose,
|
|
794
|
+
onStart,
|
|
795
|
+
onEnd,
|
|
796
|
+
onMute,
|
|
797
|
+
onToggleCaptions,
|
|
798
|
+
onRetry,
|
|
799
|
+
onDismiss,
|
|
800
|
+
onAcceptConsent,
|
|
801
|
+
onDeclineConsent
|
|
802
|
+
}) {
|
|
803
|
+
const surfaceRef = useRef4(null);
|
|
804
|
+
useEffect4(() => {
|
|
805
|
+
const node = surfaceRef.current;
|
|
806
|
+
if (!node) return;
|
|
807
|
+
const surface = node;
|
|
808
|
+
const focusables = () => Array.from(surface.querySelectorAll(FOCUSABLE));
|
|
809
|
+
focusables()[0]?.focus();
|
|
810
|
+
function onKeyDown(event) {
|
|
811
|
+
if (event.key === "Escape") {
|
|
812
|
+
event.preventDefault();
|
|
813
|
+
event.stopPropagation();
|
|
814
|
+
onClose();
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (event.key !== "Tab") return;
|
|
818
|
+
const nodes = focusables();
|
|
819
|
+
const first = nodes[0];
|
|
820
|
+
const last = nodes[nodes.length - 1];
|
|
821
|
+
if (!first || !last) return;
|
|
822
|
+
const rootNode = surface.getRootNode();
|
|
823
|
+
const active = rootNode instanceof ShadowRoot ? rootNode.activeElement : document.activeElement;
|
|
824
|
+
if (event.shiftKey && active === first) {
|
|
825
|
+
event.preventDefault();
|
|
826
|
+
last.focus();
|
|
827
|
+
} else if (!event.shiftKey && active === last) {
|
|
828
|
+
event.preventDefault();
|
|
829
|
+
first.focus();
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
surface.addEventListener("keydown", onKeyDown);
|
|
833
|
+
return () => surface.removeEventListener("keydown", onKeyDown);
|
|
834
|
+
}, [onClose]);
|
|
835
|
+
return /* @__PURE__ */ jsx8(
|
|
836
|
+
"div",
|
|
837
|
+
{
|
|
838
|
+
ref: surfaceRef,
|
|
839
|
+
className: "chatai-dock-surface",
|
|
840
|
+
role: "dialog",
|
|
841
|
+
"aria-modal": "true",
|
|
842
|
+
"aria-label": `${assistantName} voice`,
|
|
843
|
+
children: /* @__PURE__ */ jsx8(
|
|
844
|
+
VoiceStage,
|
|
845
|
+
{
|
|
846
|
+
assistantName,
|
|
847
|
+
voice,
|
|
848
|
+
messages,
|
|
849
|
+
levels,
|
|
850
|
+
captionsOpen,
|
|
851
|
+
layout: "compact",
|
|
852
|
+
reducedMotion: appearance.motion === "reduced",
|
|
853
|
+
accentColor: appearance.accentColor,
|
|
854
|
+
onStart,
|
|
855
|
+
onEnd,
|
|
856
|
+
onMute,
|
|
857
|
+
onToggleCaptions,
|
|
858
|
+
onRetry,
|
|
859
|
+
onDismiss,
|
|
860
|
+
onAcceptConsent,
|
|
861
|
+
onDeclineConsent
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
}
|
|
865
|
+
);
|
|
866
|
+
}
|
|
867
|
+
function VoiceDockTalk({
|
|
868
|
+
open,
|
|
869
|
+
onOpen,
|
|
870
|
+
onClose
|
|
871
|
+
}) {
|
|
872
|
+
return /* @__PURE__ */ jsxs8(
|
|
873
|
+
"button",
|
|
874
|
+
{
|
|
875
|
+
type: "button",
|
|
876
|
+
className: `chatai-dock-talk${open ? " is-open" : ""}`,
|
|
877
|
+
onClick: () => open ? onClose() : onOpen(),
|
|
878
|
+
"aria-expanded": open,
|
|
879
|
+
"aria-haspopup": "dialog",
|
|
880
|
+
"aria-label": open ? "Close voice dock" : "Open voice talk",
|
|
881
|
+
children: [
|
|
882
|
+
/* @__PURE__ */ jsx8(MicGlyph, { off: open }),
|
|
883
|
+
/* @__PURE__ */ jsx8("span", { children: "Talk" })
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
// src/voice/voice-guided.tsx
|
|
890
|
+
import { isVoiceActive as isVoiceActive3 } from "@nightzeros/chatai-widget-core";
|
|
891
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "preact/jsx-runtime";
|
|
892
|
+
function VoiceGuidedCanvas({
|
|
893
|
+
assistantName,
|
|
894
|
+
welcomeMessage,
|
|
895
|
+
questions,
|
|
896
|
+
voiceOffered,
|
|
897
|
+
busy,
|
|
898
|
+
onStart,
|
|
899
|
+
onAsk
|
|
900
|
+
}) {
|
|
901
|
+
return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided", children: [
|
|
902
|
+
/* @__PURE__ */ jsx9("p", { className: "chatai-guided-kicker", children: "Live voice guide" }),
|
|
903
|
+
/* @__PURE__ */ jsx9("h3", { className: "chatai-guided-title", children: assistantName }),
|
|
904
|
+
welcomeMessage ? /* @__PURE__ */ jsx9("p", { className: "chatai-guided-welcome", children: welcomeMessage }) : null,
|
|
905
|
+
questions.length > 0 ? /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-choices", children: [
|
|
906
|
+
/* @__PURE__ */ jsx9("p", { className: "chatai-guided-choices-label", children: "Suggested questions" }),
|
|
907
|
+
questions.map((question) => /* @__PURE__ */ jsxs9(
|
|
908
|
+
"button",
|
|
909
|
+
{
|
|
910
|
+
type: "button",
|
|
911
|
+
className: "chatai-guided-choice",
|
|
912
|
+
onClick: () => onAsk(question),
|
|
913
|
+
disabled: busy,
|
|
914
|
+
children: [
|
|
915
|
+
/* @__PURE__ */ jsx9("span", { children: question }),
|
|
916
|
+
/* @__PURE__ */ jsx9("span", { className: "chatai-guided-choice-mark", "aria-hidden": "true", children: "\u2197" })
|
|
917
|
+
]
|
|
918
|
+
},
|
|
919
|
+
question
|
|
920
|
+
)),
|
|
921
|
+
/* @__PURE__ */ jsx9("p", { className: "chatai-guided-hint", children: "Tap a question to ask by text, or start voice below." })
|
|
922
|
+
] }) : /* @__PURE__ */ jsx9("p", { className: "chatai-guided-hint", children: "Start a voice conversation when you are ready." }),
|
|
923
|
+
voiceOffered ? /* @__PURE__ */ jsx9("button", { type: "button", className: "chatai-voice-primary chatai-guided-start", onClick: onStart, children: "Start conversation" }) : null
|
|
924
|
+
] });
|
|
925
|
+
}
|
|
926
|
+
function VoiceGuidedSpeakHints({ questions }) {
|
|
927
|
+
if (questions.length === 0) return null;
|
|
928
|
+
return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-speak-hints", children: [
|
|
929
|
+
/* @__PURE__ */ jsx9("p", { className: "chatai-guided-choices-label", children: "Try saying" }),
|
|
930
|
+
/* @__PURE__ */ jsx9("ul", { children: questions.slice(0, 4).map((question) => /* @__PURE__ */ jsx9("li", { children: question }, question)) })
|
|
931
|
+
] });
|
|
932
|
+
}
|
|
933
|
+
function VoiceGuidedStage({
|
|
934
|
+
appearance,
|
|
935
|
+
assistantName,
|
|
936
|
+
voice,
|
|
937
|
+
messages,
|
|
938
|
+
levels,
|
|
939
|
+
captionsOpen,
|
|
940
|
+
questions,
|
|
941
|
+
onStart,
|
|
942
|
+
onEnd,
|
|
943
|
+
onMute,
|
|
944
|
+
onToggleCaptions,
|
|
945
|
+
onRetry,
|
|
946
|
+
onDismiss,
|
|
947
|
+
onAcceptConsent,
|
|
948
|
+
onDeclineConsent
|
|
949
|
+
}) {
|
|
950
|
+
const showHints = isVoiceActive3(voice.connection) && voice.connection === "connected" && !voice.consentPending && questions.length > 0;
|
|
951
|
+
return /* @__PURE__ */ jsxs9("div", { className: "chatai-guided-stage", children: [
|
|
952
|
+
/* @__PURE__ */ jsx9(
|
|
953
|
+
VoiceStage,
|
|
954
|
+
{
|
|
955
|
+
assistantName,
|
|
956
|
+
voice,
|
|
957
|
+
messages,
|
|
958
|
+
levels,
|
|
959
|
+
captionsOpen,
|
|
960
|
+
layout: "orb",
|
|
961
|
+
reducedMotion: appearance.motion === "reduced",
|
|
962
|
+
accentColor: appearance.accentColor,
|
|
963
|
+
onStart,
|
|
964
|
+
onEnd,
|
|
965
|
+
onMute,
|
|
966
|
+
onToggleCaptions,
|
|
967
|
+
onRetry,
|
|
968
|
+
onDismiss,
|
|
969
|
+
onAcceptConsent,
|
|
970
|
+
onDeclineConsent
|
|
971
|
+
}
|
|
972
|
+
),
|
|
973
|
+
showHints ? /* @__PURE__ */ jsx9(VoiceGuidedSpeakHints, { questions }) : null
|
|
974
|
+
] });
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// src/voice/voice-experience.tsx
|
|
978
|
+
import { jsx as jsx10 } from "preact/jsx-runtime";
|
|
979
|
+
function VoiceExperience({
|
|
980
|
+
appearance,
|
|
981
|
+
assistantName,
|
|
982
|
+
voice,
|
|
983
|
+
messages,
|
|
984
|
+
levels,
|
|
985
|
+
captionsOpen,
|
|
986
|
+
questions = [],
|
|
987
|
+
onStart,
|
|
988
|
+
onEnd,
|
|
989
|
+
onMute,
|
|
990
|
+
onToggleCaptions,
|
|
991
|
+
onRetry,
|
|
992
|
+
onDismiss,
|
|
993
|
+
onAcceptConsent,
|
|
994
|
+
onDeclineConsent
|
|
995
|
+
}) {
|
|
996
|
+
if (appearance.experience === "guided" && voiceStageVisible(voice)) {
|
|
997
|
+
return /* @__PURE__ */ jsx10(
|
|
998
|
+
VoiceGuidedStage,
|
|
999
|
+
{
|
|
1000
|
+
appearance,
|
|
1001
|
+
assistantName,
|
|
1002
|
+
voice,
|
|
1003
|
+
messages,
|
|
1004
|
+
levels,
|
|
1005
|
+
captionsOpen,
|
|
1006
|
+
questions,
|
|
1007
|
+
onStart,
|
|
1008
|
+
onEnd,
|
|
1009
|
+
onMute,
|
|
1010
|
+
onToggleCaptions,
|
|
1011
|
+
onRetry,
|
|
1012
|
+
onDismiss,
|
|
1013
|
+
onAcceptConsent,
|
|
1014
|
+
onDeclineConsent
|
|
1015
|
+
}
|
|
1016
|
+
);
|
|
1017
|
+
}
|
|
1018
|
+
if (appearance.experience === "companion" && voiceStageVisible(voice)) {
|
|
1019
|
+
return /* @__PURE__ */ jsx10(
|
|
1020
|
+
VoiceStage,
|
|
1021
|
+
{
|
|
1022
|
+
assistantName,
|
|
1023
|
+
voice,
|
|
1024
|
+
messages,
|
|
1025
|
+
levels,
|
|
1026
|
+
captionsOpen,
|
|
1027
|
+
layout: "orb",
|
|
1028
|
+
visual: "companion",
|
|
1029
|
+
reducedMotion: appearance.motion === "reduced",
|
|
1030
|
+
accentColor: appearance.accentColor,
|
|
1031
|
+
onStart,
|
|
1032
|
+
onEnd,
|
|
1033
|
+
onMute,
|
|
1034
|
+
onToggleCaptions,
|
|
1035
|
+
onRetry,
|
|
1036
|
+
onDismiss,
|
|
1037
|
+
onAcceptConsent,
|
|
1038
|
+
onDeclineConsent
|
|
1039
|
+
}
|
|
1040
|
+
);
|
|
1041
|
+
}
|
|
1042
|
+
if ((appearance.experience === "orb" || appearance.experience === "side-panel") && voiceStageVisible(voice)) {
|
|
1043
|
+
return /* @__PURE__ */ jsx10(
|
|
1044
|
+
VoiceStage,
|
|
1045
|
+
{
|
|
1046
|
+
assistantName,
|
|
1047
|
+
voice,
|
|
1048
|
+
messages,
|
|
1049
|
+
levels,
|
|
1050
|
+
captionsOpen,
|
|
1051
|
+
layout: "orb",
|
|
1052
|
+
reducedMotion: appearance.motion === "reduced",
|
|
1053
|
+
accentColor: appearance.accentColor,
|
|
1054
|
+
onStart,
|
|
1055
|
+
onEnd,
|
|
1056
|
+
onMute,
|
|
1057
|
+
onToggleCaptions,
|
|
1058
|
+
onRetry,
|
|
1059
|
+
onDismiss,
|
|
1060
|
+
onAcceptConsent,
|
|
1061
|
+
onDeclineConsent
|
|
1062
|
+
}
|
|
1063
|
+
);
|
|
1064
|
+
}
|
|
1065
|
+
if (appearance.experience === "classic") {
|
|
1066
|
+
return /* @__PURE__ */ jsx10(VoiceBar, { voice, levels, onRetry, onDismiss });
|
|
1067
|
+
}
|
|
1068
|
+
return null;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
// src/app.tsx
|
|
1072
|
+
import { Fragment as Fragment4, jsx as jsx11, jsxs as jsxs10 } from "preact/jsx-runtime";
|
|
1073
|
+
var FOCUSABLE2 = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
317
1074
|
function settingOverrides(props) {
|
|
318
1075
|
return {
|
|
319
1076
|
primaryColor: props.primaryColor,
|
|
@@ -321,7 +1078,8 @@ function settingOverrides(props) {
|
|
|
321
1078
|
theme: props.theme,
|
|
322
1079
|
iconUrl: props.iconUrl,
|
|
323
1080
|
suggestedQuestions: props.suggestedQuestions,
|
|
324
|
-
showSources: props.showSources
|
|
1081
|
+
showSources: props.showSources,
|
|
1082
|
+
voiceAppearance: props.voiceAppearance
|
|
325
1083
|
};
|
|
326
1084
|
}
|
|
327
1085
|
var EMPTY_STATE = {
|
|
@@ -331,23 +1089,34 @@ var EMPTY_STATE = {
|
|
|
331
1089
|
};
|
|
332
1090
|
function settingsFrom(state, props) {
|
|
333
1091
|
const settings = state.config?.settings ?? {};
|
|
334
|
-
|
|
1092
|
+
const overrides = settingOverrides(props);
|
|
1093
|
+
const { voiceAppearance: overrideAppearance, ...flatOverrides } = overrides;
|
|
1094
|
+
const merged = {
|
|
335
1095
|
...settings,
|
|
336
|
-
...Object.fromEntries(Object.entries(
|
|
1096
|
+
...Object.fromEntries(Object.entries(flatOverrides).filter(([, value]) => value !== void 0)),
|
|
337
1097
|
theme: props.theme ?? settings.theme ?? "system",
|
|
338
1098
|
position: props.position ?? settings.position ?? "bottom-right"
|
|
339
1099
|
};
|
|
1100
|
+
const appearance = mergeVoiceAppearance(
|
|
1101
|
+
parseVoiceAppearance(settings.voiceAppearance),
|
|
1102
|
+
overrideAppearance !== void 0 ? parseVoiceAppearance(overrideAppearance) : void 0
|
|
1103
|
+
);
|
|
1104
|
+
if (Object.keys(appearance).length > 0) merged.voiceAppearance = appearance;
|
|
1105
|
+
return merged;
|
|
1106
|
+
}
|
|
1107
|
+
function voiceAppearanceFrom(state, props) {
|
|
1108
|
+
return resolveVoiceAppearance(settingsFrom(state, props).voiceAppearance);
|
|
340
1109
|
}
|
|
341
1110
|
function ChatGlyph() {
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
1111
|
+
return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
|
|
1112
|
+
/* @__PURE__ */ jsx11("path", { d: "M20 11.5a7.5 7.5 0 0 1-9.4 7.3L5 21l1.4-4.2A7.5 7.5 0 1 1 20 11.5Z" }),
|
|
1113
|
+
/* @__PURE__ */ jsx11("path", { d: "M8.5 11.5h.01M12 11.5h.01M15.5 11.5h.01", "stroke-linecap": "round" })
|
|
345
1114
|
] });
|
|
346
1115
|
}
|
|
347
1116
|
function ThumbUpGlyph() {
|
|
348
|
-
return /* @__PURE__ */
|
|
349
|
-
/* @__PURE__ */
|
|
350
|
-
/* @__PURE__ */
|
|
1117
|
+
return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
|
|
1118
|
+
/* @__PURE__ */ jsx11("path", { d: "M7 10v12", "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
1119
|
+
/* @__PURE__ */ jsx11(
|
|
351
1120
|
"path",
|
|
352
1121
|
{
|
|
353
1122
|
d: "M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",
|
|
@@ -358,9 +1127,9 @@ function ThumbUpGlyph() {
|
|
|
358
1127
|
] });
|
|
359
1128
|
}
|
|
360
1129
|
function ThumbDownGlyph() {
|
|
361
|
-
return /* @__PURE__ */
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */
|
|
1130
|
+
return /* @__PURE__ */ jsxs10("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", fill: "none", stroke: "currentColor", "stroke-width": "2", children: [
|
|
1131
|
+
/* @__PURE__ */ jsx11("path", { d: "M17 14V2", "stroke-linecap": "round", "stroke-linejoin": "round" }),
|
|
1132
|
+
/* @__PURE__ */ jsx11(
|
|
364
1133
|
"path",
|
|
365
1134
|
{
|
|
366
1135
|
d: "M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",
|
|
@@ -371,10 +1140,10 @@ function ThumbDownGlyph() {
|
|
|
371
1140
|
] });
|
|
372
1141
|
}
|
|
373
1142
|
function TypingIndicator() {
|
|
374
|
-
return /* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
/* @__PURE__ */
|
|
1143
|
+
return /* @__PURE__ */ jsxs10("div", { className: "chatai-typing", "aria-label": "Assistant is typing", role: "status", children: [
|
|
1144
|
+
/* @__PURE__ */ jsx11("span", {}),
|
|
1145
|
+
/* @__PURE__ */ jsx11("span", {}),
|
|
1146
|
+
/* @__PURE__ */ jsx11("span", {})
|
|
378
1147
|
] });
|
|
379
1148
|
}
|
|
380
1149
|
function WidgetApp(props) {
|
|
@@ -402,11 +1171,14 @@ function WidgetApp(props) {
|
|
|
402
1171
|
const [open, setOpen] = useState(false);
|
|
403
1172
|
const [closing, setClosing] = useState(false);
|
|
404
1173
|
const [draft, setDraft] = useState("");
|
|
405
|
-
const
|
|
406
|
-
const
|
|
407
|
-
const
|
|
408
|
-
const
|
|
409
|
-
|
|
1174
|
+
const [captionsOpen, setCaptionsOpen] = useState(true);
|
|
1175
|
+
const [dockOpen, setDockOpen] = useState(false);
|
|
1176
|
+
const launcherRef = useRef5(null);
|
|
1177
|
+
const panelRef = useRef5(null);
|
|
1178
|
+
const transcriptRef = useRef5(null);
|
|
1179
|
+
const wasOpenRef = useRef5(false);
|
|
1180
|
+
const wasDockOpenRef = useRef5(false);
|
|
1181
|
+
useEffect5(() => {
|
|
410
1182
|
const unsubscribe = controller.subscribe(setState);
|
|
411
1183
|
void controller.load();
|
|
412
1184
|
return () => {
|
|
@@ -415,9 +1187,17 @@ function WidgetApp(props) {
|
|
|
415
1187
|
};
|
|
416
1188
|
}, [controller]);
|
|
417
1189
|
const settings = settingsFrom(state, props);
|
|
1190
|
+
const appearance = voiceAppearanceFrom(state, props);
|
|
418
1191
|
const questions = settings.suggestedQuestions?.filter(Boolean) ?? [];
|
|
419
|
-
const voiceOn =
|
|
1192
|
+
const voiceOn = isVoiceActive4(state.voice.connection);
|
|
420
1193
|
const voiceOffered = props.voice !== false && Boolean(state.config?.voice?.enabled);
|
|
1194
|
+
const isDock = appearance.experience === "dock";
|
|
1195
|
+
const isGuided = appearance.experience === "guided";
|
|
1196
|
+
const isCompanion = appearance.experience === "companion";
|
|
1197
|
+
const isSidePanel = appearance.experience === "side-panel";
|
|
1198
|
+
const voiceStage = voiceOffered && (appearance.experience === "orb" || appearance.experience === "guided" || appearance.experience === "companion" || appearance.experience === "side-panel") && voiceStageVisible(state.voice);
|
|
1199
|
+
const guidedCanvas = voiceOffered && isGuided && !voiceStageVisible(state.voice);
|
|
1200
|
+
const companionCanvas = voiceOffered && isCompanion && !voiceStageVisible(state.voice);
|
|
421
1201
|
const streaming = state.status === "streaming";
|
|
422
1202
|
const busy = streaming || voiceOn;
|
|
423
1203
|
const panelShown = open || closing;
|
|
@@ -427,7 +1207,16 @@ function WidgetApp(props) {
|
|
|
427
1207
|
function reduceMotion() {
|
|
428
1208
|
return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
429
1209
|
}
|
|
1210
|
+
function releaseDockVoice() {
|
|
1211
|
+
void controller.endVoice();
|
|
1212
|
+
controller.dismissVoiceError();
|
|
1213
|
+
if (controller.getState().voice.consentPending) controller.declineRecordingConsent();
|
|
1214
|
+
}
|
|
430
1215
|
function openPanel() {
|
|
1216
|
+
if (dockOpen) {
|
|
1217
|
+
releaseDockVoice();
|
|
1218
|
+
setDockOpen(false);
|
|
1219
|
+
}
|
|
431
1220
|
setClosing(false);
|
|
432
1221
|
setOpen(true);
|
|
433
1222
|
}
|
|
@@ -446,6 +1235,21 @@ function WidgetApp(props) {
|
|
|
446
1235
|
if (open) closePanel();
|
|
447
1236
|
else openPanel();
|
|
448
1237
|
}
|
|
1238
|
+
function openDock() {
|
|
1239
|
+
setOpen(false);
|
|
1240
|
+
setClosing(false);
|
|
1241
|
+
setDockOpen(true);
|
|
1242
|
+
}
|
|
1243
|
+
function closeDock() {
|
|
1244
|
+
releaseDockVoice();
|
|
1245
|
+
setDockOpen(false);
|
|
1246
|
+
}
|
|
1247
|
+
function dismissDockToChat() {
|
|
1248
|
+
releaseDockVoice();
|
|
1249
|
+
setDockOpen(false);
|
|
1250
|
+
setClosing(false);
|
|
1251
|
+
setOpen(true);
|
|
1252
|
+
}
|
|
449
1253
|
function send(message) {
|
|
450
1254
|
if (!message.trim()) return;
|
|
451
1255
|
setDraft("");
|
|
@@ -461,11 +1265,11 @@ function WidgetApp(props) {
|
|
|
461
1265
|
if (voiceOn) void controller.endVoice();
|
|
462
1266
|
else void controller.startVoice();
|
|
463
1267
|
}
|
|
464
|
-
|
|
1268
|
+
useEffect5(() => {
|
|
465
1269
|
if (!panelShown) return;
|
|
466
1270
|
const panel = panelRef.current;
|
|
467
1271
|
if (!panel) return;
|
|
468
|
-
const focusables = () => Array.from(panel.querySelectorAll(
|
|
1272
|
+
const focusables = () => Array.from(panel.querySelectorAll(FOCUSABLE2));
|
|
469
1273
|
const initial = focusables();
|
|
470
1274
|
(initial.find((el) => el.id === "chatai-message-input") ?? initial[0])?.focus();
|
|
471
1275
|
function onKeyDown(event) {
|
|
@@ -489,25 +1293,73 @@ function WidgetApp(props) {
|
|
|
489
1293
|
}
|
|
490
1294
|
panel.addEventListener("keydown", onKeyDown);
|
|
491
1295
|
return () => panel.removeEventListener("keydown", onKeyDown);
|
|
492
|
-
}, [panelShown]);
|
|
493
|
-
|
|
1296
|
+
}, [panelShown, voiceStage]);
|
|
1297
|
+
useEffect5(() => {
|
|
494
1298
|
if (wasOpenRef.current && !open && !closing) {
|
|
495
1299
|
launcherRef.current?.focus();
|
|
496
1300
|
}
|
|
497
1301
|
wasOpenRef.current = open || closing;
|
|
498
1302
|
}, [open, closing]);
|
|
499
|
-
|
|
1303
|
+
useEffect5(() => {
|
|
500
1304
|
const el = transcriptRef.current;
|
|
501
1305
|
if (!el) return;
|
|
502
1306
|
el.scrollTop = el.scrollHeight;
|
|
503
1307
|
}, [state.messages, state.error, showTyping, panelShown]);
|
|
504
|
-
|
|
1308
|
+
useEffect5(() => {
|
|
1309
|
+
if (!voiceStage && !dockOpen) setCaptionsOpen(appearance.captionsDefault);
|
|
1310
|
+
}, [appearance.captionsDefault, voiceStage, dockOpen]);
|
|
1311
|
+
useEffect5(() => {
|
|
1312
|
+
if (wasDockOpenRef.current && !dockOpen) {
|
|
1313
|
+
launcherRef.current?.focus();
|
|
1314
|
+
}
|
|
1315
|
+
wasDockOpenRef.current = dockOpen;
|
|
1316
|
+
}, [dockOpen]);
|
|
1317
|
+
useEffect5(() => {
|
|
1318
|
+
if (!isDock && dockOpen) {
|
|
1319
|
+
void controller.endVoice();
|
|
1320
|
+
setDockOpen(false);
|
|
1321
|
+
}
|
|
1322
|
+
}, [isDock, dockOpen, controller]);
|
|
1323
|
+
const voiceHandlers = {
|
|
1324
|
+
onStart: () => void controller.startVoice(),
|
|
1325
|
+
onEnd: () => void controller.endVoice(),
|
|
1326
|
+
onMute: (muted) => controller.setVoiceMicrophoneMuted(muted),
|
|
1327
|
+
onToggleCaptions: () => setCaptionsOpen((value) => !value),
|
|
1328
|
+
onRetry: () => void controller.startVoice(),
|
|
1329
|
+
onDismiss: () => controller.dismissVoiceError(),
|
|
1330
|
+
onAcceptConsent: () => void controller.acceptRecordingConsent(),
|
|
1331
|
+
onDeclineConsent: () => controller.declineRecordingConsent()
|
|
1332
|
+
};
|
|
1333
|
+
return /* @__PURE__ */ jsxs10(
|
|
505
1334
|
"div",
|
|
506
1335
|
{
|
|
507
|
-
className: `chatai-widget ${isDark ? "theme-dark" : "theme-light"} ${settings.position === "bottom-left" ? "position-left" : "position-right"} ${props.layout === "contained" ? "layout-contained" : ""}`,
|
|
508
|
-
style: {
|
|
1336
|
+
className: `chatai-widget ${isDark ? "theme-dark" : "theme-light"} ${settings.position === "bottom-left" ? "position-left" : "position-right"} ${props.layout === "contained" ? "layout-contained" : ""}${isDock ? " experience-dock" : ""}${isSidePanel ? " experience-side-panel" : ""}`,
|
|
1337
|
+
style: {
|
|
1338
|
+
"--chatai-accent": settings.primaryColor ?? "#0F766E",
|
|
1339
|
+
...appearance.accentColor ? { "--chatai-voice-accent": appearance.accentColor } : {}
|
|
1340
|
+
},
|
|
509
1341
|
children: [
|
|
510
|
-
|
|
1342
|
+
dockOpen && voiceOffered && isDock ? /* @__PURE__ */ jsx11(
|
|
1343
|
+
VoiceDockSurface,
|
|
1344
|
+
{
|
|
1345
|
+
appearance,
|
|
1346
|
+
assistantName: state.config?.name ?? "Assistant",
|
|
1347
|
+
voice: state.voice,
|
|
1348
|
+
messages: state.messages,
|
|
1349
|
+
levels: () => controller.voiceLevels(),
|
|
1350
|
+
captionsOpen,
|
|
1351
|
+
onClose: closeDock,
|
|
1352
|
+
onStart: voiceHandlers.onStart,
|
|
1353
|
+
onEnd: voiceHandlers.onEnd,
|
|
1354
|
+
onMute: voiceHandlers.onMute,
|
|
1355
|
+
onToggleCaptions: voiceHandlers.onToggleCaptions,
|
|
1356
|
+
onRetry: voiceHandlers.onRetry,
|
|
1357
|
+
onDismiss: dismissDockToChat,
|
|
1358
|
+
onAcceptConsent: voiceHandlers.onAcceptConsent,
|
|
1359
|
+
onDeclineConsent: voiceHandlers.onDeclineConsent
|
|
1360
|
+
}
|
|
1361
|
+
) : null,
|
|
1362
|
+
panelShown ? /* @__PURE__ */ jsxs10(
|
|
511
1363
|
"section",
|
|
512
1364
|
{
|
|
513
1365
|
ref: panelRef,
|
|
@@ -519,149 +1371,303 @@ function WidgetApp(props) {
|
|
|
519
1371
|
if (closing) setClosing(false);
|
|
520
1372
|
},
|
|
521
1373
|
children: [
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
524
|
-
/* @__PURE__ */
|
|
525
|
-
/* @__PURE__ */
|
|
1374
|
+
/* @__PURE__ */ jsxs10("header", { className: "chatai-header", children: [
|
|
1375
|
+
/* @__PURE__ */ jsxs10("div", { children: [
|
|
1376
|
+
/* @__PURE__ */ jsx11("p", { className: "chatai-kicker", children: isSidePanel ? "Side panel" : "Knowledge assistant" }),
|
|
1377
|
+
/* @__PURE__ */ jsx11("h2", { children: state.config?.name ?? "Loading assistant\u2026" })
|
|
526
1378
|
] }),
|
|
527
|
-
/* @__PURE__ */
|
|
528
|
-
] }),
|
|
529
|
-
/* @__PURE__ */ jsxs3("div", { ref: transcriptRef, className: "chatai-transcript", "aria-live": voiceOn ? "off" : "polite", children: [
|
|
530
|
-
state.config?.welcomeMessage ? /* @__PURE__ */ jsx3("article", { className: "chatai-message assistant", children: /* @__PURE__ */ jsx3(MarkdownMessage, { content: state.config.welcomeMessage }) }) : null,
|
|
531
|
-
questions.length > 0 && state.messages.length === 0 ? /* @__PURE__ */ jsx3("div", { className: "chatai-prompts", children: questions.map((question) => /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => send(question), disabled: busy, children: question }, question)) }) : null,
|
|
532
|
-
state.messages.map((message, index) => {
|
|
533
|
-
const isLast = index === state.messages.length - 1;
|
|
534
|
-
const isStreamingPlaceholder = showTyping && isLast && message.role === "assistant";
|
|
535
|
-
const isStreamingContent = streaming && isLast && message.role === "assistant" && Boolean(message.content);
|
|
536
|
-
const isVoice = message.modality === "voice";
|
|
537
|
-
return /* @__PURE__ */ jsxs3(
|
|
538
|
-
"article",
|
|
539
|
-
{
|
|
540
|
-
className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}${message.live ? " is-live" : ""}`,
|
|
541
|
-
children: [
|
|
542
|
-
isVoice ? /* @__PURE__ */ jsxs3("span", { className: "chatai-voice-tag", children: [
|
|
543
|
-
/* @__PURE__ */ jsx3(VoiceGlyph, {}),
|
|
544
|
-
/* @__PURE__ */ jsx3("span", { className: "chatai-visually-hidden", children: message.role === "user" ? "You said:" : "Assistant said:" })
|
|
545
|
-
] }) : null,
|
|
546
|
-
isStreamingPlaceholder ? /* @__PURE__ */ jsx3(TypingIndicator, {}) : message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx3(MarkdownMessage, { content: message.content, streaming: isStreamingContent }) : /* @__PURE__ */ jsx3("p", { children: streaming ? "Thinking\u2026" : "" }) : /* @__PURE__ */ jsx3("p", { className: "chatai-user-text", children: message.content }),
|
|
547
|
-
message.interrupted ? /* @__PURE__ */ jsx3("p", { className: "chatai-voice-note", children: "Interrupted" }) : null,
|
|
548
|
-
message.role === "assistant" && message.id ? /* @__PURE__ */ jsxs3("div", { className: "chatai-feedback", children: [
|
|
549
|
-
/* @__PURE__ */ jsx3("span", { children: "Was this helpful?" }),
|
|
550
|
-
/* @__PURE__ */ jsx3(
|
|
551
|
-
"button",
|
|
552
|
-
{
|
|
553
|
-
type: "button",
|
|
554
|
-
"aria-label": "Mark response helpful",
|
|
555
|
-
"aria-pressed": message.feedback === "positive",
|
|
556
|
-
onClick: () => rate(message.id, "positive"),
|
|
557
|
-
children: /* @__PURE__ */ jsx3(ThumbUpGlyph, {})
|
|
558
|
-
}
|
|
559
|
-
),
|
|
560
|
-
/* @__PURE__ */ jsx3(
|
|
561
|
-
"button",
|
|
562
|
-
{
|
|
563
|
-
type: "button",
|
|
564
|
-
"aria-label": "Mark response not helpful",
|
|
565
|
-
"aria-pressed": message.feedback === "negative",
|
|
566
|
-
onClick: () => rate(message.id, "negative"),
|
|
567
|
-
children: /* @__PURE__ */ jsx3(ThumbDownGlyph, {})
|
|
568
|
-
}
|
|
569
|
-
)
|
|
570
|
-
] }) : null
|
|
571
|
-
]
|
|
572
|
-
},
|
|
573
|
-
`${message.role}-${index}`
|
|
574
|
-
);
|
|
575
|
-
}),
|
|
576
|
-
state.error ? /* @__PURE__ */ jsxs3("div", { className: "chatai-error", role: "alert", children: [
|
|
577
|
-
/* @__PURE__ */ jsx3("p", { children: state.error }),
|
|
578
|
-
/* @__PURE__ */ jsx3("button", { type: "button", className: "chatai-retry", onClick: retry, disabled: busy, children: "Retry" })
|
|
579
|
-
] }) : null
|
|
1379
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: "chatai-close", onClick: closePanel, "aria-label": "Close chat", children: "\xD7" })
|
|
580
1380
|
] }),
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
{
|
|
584
|
-
onAccept: () => void controller.acceptRecordingConsent(),
|
|
585
|
-
onCancel: () => {
|
|
586
|
-
controller.declineRecordingConsent();
|
|
587
|
-
panelRef.current?.querySelector("#chatai-message-input")?.focus();
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
) : null,
|
|
591
|
-
voiceOffered ? /* @__PURE__ */ jsx3(
|
|
592
|
-
VoiceBar,
|
|
1381
|
+
voiceStage ? /* @__PURE__ */ jsx11(
|
|
1382
|
+
VoiceExperience,
|
|
593
1383
|
{
|
|
1384
|
+
appearance,
|
|
1385
|
+
assistantName: state.config?.name ?? "Assistant",
|
|
594
1386
|
voice: state.voice,
|
|
1387
|
+
messages: state.messages,
|
|
595
1388
|
levels: () => controller.voiceLevels(),
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
) : null,
|
|
600
|
-
/* @__PURE__ */ jsxs3(
|
|
601
|
-
"form",
|
|
602
|
-
{
|
|
603
|
-
className: "chatai-composer",
|
|
604
|
-
onSubmit: (event) => {
|
|
605
|
-
event.preventDefault();
|
|
606
|
-
send(draft);
|
|
607
|
-
},
|
|
608
|
-
children: [
|
|
609
|
-
/* @__PURE__ */ jsx3("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
|
|
610
|
-
/* @__PURE__ */ jsx3(
|
|
611
|
-
"input",
|
|
612
|
-
{
|
|
613
|
-
id: "chatai-message-input",
|
|
614
|
-
value: draft,
|
|
615
|
-
onInput: (event) => setDraft(event.currentTarget.value),
|
|
616
|
-
placeholder: voiceOn ? "Voice is on \u2014 end it to type" : "Ask a question\u2026",
|
|
617
|
-
maxLength: 4e3,
|
|
618
|
-
disabled: busy
|
|
619
|
-
}
|
|
620
|
-
),
|
|
621
|
-
voiceOffered ? /* @__PURE__ */ jsx3(
|
|
622
|
-
"button",
|
|
623
|
-
{
|
|
624
|
-
type: "button",
|
|
625
|
-
className: `chatai-mic${voiceOn ? " is-active" : ""}`,
|
|
626
|
-
onClick: toggleVoice,
|
|
627
|
-
disabled: streaming,
|
|
628
|
-
"aria-pressed": voiceOn,
|
|
629
|
-
"aria-label": voiceOn ? "End voice conversation" : "Start voice conversation",
|
|
630
|
-
title: voiceOn ? "End voice" : "Talk instead",
|
|
631
|
-
children: /* @__PURE__ */ jsx3(MicGlyph, { off: voiceOn })
|
|
632
|
-
}
|
|
633
|
-
) : null,
|
|
634
|
-
/* @__PURE__ */ jsx3("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
|
|
635
|
-
]
|
|
1389
|
+
captionsOpen,
|
|
1390
|
+
questions,
|
|
1391
|
+
...voiceHandlers
|
|
636
1392
|
}
|
|
637
|
-
)
|
|
1393
|
+
) : guidedCanvas ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1394
|
+
/* @__PURE__ */ jsx11(
|
|
1395
|
+
VoiceGuidedCanvas,
|
|
1396
|
+
{
|
|
1397
|
+
assistantName: state.config?.name ?? "Assistant",
|
|
1398
|
+
welcomeMessage: state.config?.welcomeMessage,
|
|
1399
|
+
questions,
|
|
1400
|
+
voiceOffered,
|
|
1401
|
+
busy,
|
|
1402
|
+
onStart: () => void controller.startVoice(),
|
|
1403
|
+
onAsk: send
|
|
1404
|
+
}
|
|
1405
|
+
),
|
|
1406
|
+
state.messages.length > 0 ? /* @__PURE__ */ jsx11(
|
|
1407
|
+
"div",
|
|
1408
|
+
{
|
|
1409
|
+
ref: transcriptRef,
|
|
1410
|
+
className: "chatai-transcript chatai-guided-history",
|
|
1411
|
+
"aria-live": "polite",
|
|
1412
|
+
children: state.messages.map((message, index) => {
|
|
1413
|
+
const isVoice = message.modality === "voice";
|
|
1414
|
+
return /* @__PURE__ */ jsxs10(
|
|
1415
|
+
"article",
|
|
1416
|
+
{
|
|
1417
|
+
className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}`,
|
|
1418
|
+
children: [
|
|
1419
|
+
isVoice ? /* @__PURE__ */ jsx11("span", { className: "chatai-voice-tag", children: /* @__PURE__ */ jsx11(VoiceGlyph, {}) }) : null,
|
|
1420
|
+
message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content }) : null : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content })
|
|
1421
|
+
]
|
|
1422
|
+
},
|
|
1423
|
+
`${message.role}-${index}`
|
|
1424
|
+
);
|
|
1425
|
+
})
|
|
1426
|
+
}
|
|
1427
|
+
) : null,
|
|
1428
|
+
/* @__PURE__ */ jsxs10(
|
|
1429
|
+
"form",
|
|
1430
|
+
{
|
|
1431
|
+
className: "chatai-composer",
|
|
1432
|
+
onSubmit: (event) => {
|
|
1433
|
+
event.preventDefault();
|
|
1434
|
+
send(draft);
|
|
1435
|
+
},
|
|
1436
|
+
children: [
|
|
1437
|
+
/* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
|
|
1438
|
+
/* @__PURE__ */ jsx11(
|
|
1439
|
+
"input",
|
|
1440
|
+
{
|
|
1441
|
+
id: "chatai-message-input",
|
|
1442
|
+
value: draft,
|
|
1443
|
+
onInput: (event) => setDraft(event.currentTarget.value),
|
|
1444
|
+
placeholder: "Or type a question\u2026",
|
|
1445
|
+
maxLength: 4e3,
|
|
1446
|
+
disabled: busy
|
|
1447
|
+
}
|
|
1448
|
+
),
|
|
1449
|
+
/* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
|
|
1450
|
+
]
|
|
1451
|
+
}
|
|
1452
|
+
)
|
|
1453
|
+
] }) : companionCanvas ? /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1454
|
+
/* @__PURE__ */ jsx11(
|
|
1455
|
+
VoiceCompanionCanvas,
|
|
1456
|
+
{
|
|
1457
|
+
assistantName: state.config?.name ?? "Assistant",
|
|
1458
|
+
welcomeMessage: state.config?.welcomeMessage,
|
|
1459
|
+
voiceOffered,
|
|
1460
|
+
onStart: () => void controller.startVoice()
|
|
1461
|
+
}
|
|
1462
|
+
),
|
|
1463
|
+
state.messages.length > 0 ? /* @__PURE__ */ jsx11(
|
|
1464
|
+
"div",
|
|
1465
|
+
{
|
|
1466
|
+
ref: transcriptRef,
|
|
1467
|
+
className: "chatai-transcript chatai-companion-history",
|
|
1468
|
+
"aria-live": "polite",
|
|
1469
|
+
children: state.messages.map((message, index) => {
|
|
1470
|
+
const isVoice = message.modality === "voice";
|
|
1471
|
+
return /* @__PURE__ */ jsxs10(
|
|
1472
|
+
"article",
|
|
1473
|
+
{
|
|
1474
|
+
className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}`,
|
|
1475
|
+
children: [
|
|
1476
|
+
isVoice ? /* @__PURE__ */ jsx11("span", { className: "chatai-voice-tag", children: /* @__PURE__ */ jsx11(VoiceGlyph, {}) }) : null,
|
|
1477
|
+
message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content }) : null : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content })
|
|
1478
|
+
]
|
|
1479
|
+
},
|
|
1480
|
+
`${message.role}-${index}`
|
|
1481
|
+
);
|
|
1482
|
+
})
|
|
1483
|
+
}
|
|
1484
|
+
) : null,
|
|
1485
|
+
/* @__PURE__ */ jsxs10(
|
|
1486
|
+
"form",
|
|
1487
|
+
{
|
|
1488
|
+
className: "chatai-composer",
|
|
1489
|
+
onSubmit: (event) => {
|
|
1490
|
+
event.preventDefault();
|
|
1491
|
+
send(draft);
|
|
1492
|
+
},
|
|
1493
|
+
children: [
|
|
1494
|
+
/* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
|
|
1495
|
+
/* @__PURE__ */ jsx11(
|
|
1496
|
+
"input",
|
|
1497
|
+
{
|
|
1498
|
+
id: "chatai-message-input",
|
|
1499
|
+
value: draft,
|
|
1500
|
+
onInput: (event) => setDraft(event.currentTarget.value),
|
|
1501
|
+
placeholder: "Or type a message\u2026",
|
|
1502
|
+
maxLength: 4e3,
|
|
1503
|
+
disabled: busy
|
|
1504
|
+
}
|
|
1505
|
+
),
|
|
1506
|
+
/* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
)
|
|
1510
|
+
] }) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1511
|
+
/* @__PURE__ */ jsxs10(
|
|
1512
|
+
"div",
|
|
1513
|
+
{
|
|
1514
|
+
ref: transcriptRef,
|
|
1515
|
+
className: "chatai-transcript",
|
|
1516
|
+
"aria-live": voiceOn ? "off" : "polite",
|
|
1517
|
+
children: [
|
|
1518
|
+
state.config?.welcomeMessage ? /* @__PURE__ */ jsx11("article", { className: "chatai-message assistant", children: /* @__PURE__ */ jsx11(MarkdownMessage, { content: state.config.welcomeMessage }) }) : null,
|
|
1519
|
+
questions.length > 0 && state.messages.length === 0 ? /* @__PURE__ */ jsx11("div", { className: "chatai-prompts", children: questions.map((question) => /* @__PURE__ */ jsx11(
|
|
1520
|
+
"button",
|
|
1521
|
+
{
|
|
1522
|
+
type: "button",
|
|
1523
|
+
onClick: () => send(question),
|
|
1524
|
+
disabled: busy,
|
|
1525
|
+
children: question
|
|
1526
|
+
},
|
|
1527
|
+
question
|
|
1528
|
+
)) }) : null,
|
|
1529
|
+
state.messages.map((message, index) => {
|
|
1530
|
+
const isLast = index === state.messages.length - 1;
|
|
1531
|
+
const isStreamingPlaceholder = showTyping && isLast && message.role === "assistant";
|
|
1532
|
+
const isStreamingContent = streaming && isLast && message.role === "assistant" && Boolean(message.content);
|
|
1533
|
+
const isVoice = message.modality === "voice";
|
|
1534
|
+
return /* @__PURE__ */ jsxs10(
|
|
1535
|
+
"article",
|
|
1536
|
+
{
|
|
1537
|
+
className: `chatai-message ${message.role}${isVoice ? " is-voice" : ""}${message.live ? " is-live" : ""}`,
|
|
1538
|
+
children: [
|
|
1539
|
+
isVoice ? /* @__PURE__ */ jsxs10("span", { className: "chatai-voice-tag", children: [
|
|
1540
|
+
/* @__PURE__ */ jsx11(VoiceGlyph, {}),
|
|
1541
|
+
/* @__PURE__ */ jsx11("span", { className: "chatai-visually-hidden", children: message.role === "user" ? "You said:" : "Assistant said:" })
|
|
1542
|
+
] }) : null,
|
|
1543
|
+
isStreamingPlaceholder ? /* @__PURE__ */ jsx11(TypingIndicator, {}) : message.role === "assistant" && !isVoice ? message.content ? /* @__PURE__ */ jsx11(MarkdownMessage, { content: message.content, streaming: isStreamingContent }) : /* @__PURE__ */ jsx11("p", { children: streaming ? "Thinking\u2026" : "" }) : /* @__PURE__ */ jsx11("p", { className: "chatai-user-text", children: message.content }),
|
|
1544
|
+
message.interrupted ? /* @__PURE__ */ jsx11("p", { className: "chatai-voice-note", children: "Interrupted" }) : null,
|
|
1545
|
+
message.role === "assistant" && message.id ? /* @__PURE__ */ jsxs10("div", { className: "chatai-feedback", children: [
|
|
1546
|
+
/* @__PURE__ */ jsx11("span", { children: "Was this helpful?" }),
|
|
1547
|
+
/* @__PURE__ */ jsx11(
|
|
1548
|
+
"button",
|
|
1549
|
+
{
|
|
1550
|
+
type: "button",
|
|
1551
|
+
"aria-label": "Mark response helpful",
|
|
1552
|
+
"aria-pressed": message.feedback === "positive",
|
|
1553
|
+
onClick: () => rate(message.id, "positive"),
|
|
1554
|
+
children: /* @__PURE__ */ jsx11(ThumbUpGlyph, {})
|
|
1555
|
+
}
|
|
1556
|
+
),
|
|
1557
|
+
/* @__PURE__ */ jsx11(
|
|
1558
|
+
"button",
|
|
1559
|
+
{
|
|
1560
|
+
type: "button",
|
|
1561
|
+
"aria-label": "Mark response not helpful",
|
|
1562
|
+
"aria-pressed": message.feedback === "negative",
|
|
1563
|
+
onClick: () => rate(message.id, "negative"),
|
|
1564
|
+
children: /* @__PURE__ */ jsx11(ThumbDownGlyph, {})
|
|
1565
|
+
}
|
|
1566
|
+
)
|
|
1567
|
+
] }) : null
|
|
1568
|
+
]
|
|
1569
|
+
},
|
|
1570
|
+
`${message.role}-${index}`
|
|
1571
|
+
);
|
|
1572
|
+
}),
|
|
1573
|
+
state.error ? /* @__PURE__ */ jsxs10("div", { className: "chatai-error", role: "alert", children: [
|
|
1574
|
+
/* @__PURE__ */ jsx11("p", { children: state.error }),
|
|
1575
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: "chatai-retry", onClick: retry, disabled: busy, children: "Retry" })
|
|
1576
|
+
] }) : null
|
|
1577
|
+
]
|
|
1578
|
+
}
|
|
1579
|
+
),
|
|
1580
|
+
voiceOffered && state.voice.consentPending ? /* @__PURE__ */ jsx11(
|
|
1581
|
+
VoiceConsent,
|
|
1582
|
+
{
|
|
1583
|
+
onAccept: () => void controller.acceptRecordingConsent(),
|
|
1584
|
+
onCancel: () => {
|
|
1585
|
+
controller.declineRecordingConsent();
|
|
1586
|
+
panelRef.current?.querySelector("#chatai-message-input")?.focus();
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
) : null,
|
|
1590
|
+
voiceOffered && appearance.experience === "classic" ? /* @__PURE__ */ jsx11(
|
|
1591
|
+
VoiceExperience,
|
|
1592
|
+
{
|
|
1593
|
+
appearance,
|
|
1594
|
+
assistantName: state.config?.name ?? "Assistant",
|
|
1595
|
+
voice: state.voice,
|
|
1596
|
+
messages: state.messages,
|
|
1597
|
+
levels: () => controller.voiceLevels(),
|
|
1598
|
+
captionsOpen,
|
|
1599
|
+
...voiceHandlers
|
|
1600
|
+
}
|
|
1601
|
+
) : null,
|
|
1602
|
+
/* @__PURE__ */ jsxs10(
|
|
1603
|
+
"form",
|
|
1604
|
+
{
|
|
1605
|
+
className: "chatai-composer",
|
|
1606
|
+
onSubmit: (event) => {
|
|
1607
|
+
event.preventDefault();
|
|
1608
|
+
send(draft);
|
|
1609
|
+
},
|
|
1610
|
+
children: [
|
|
1611
|
+
/* @__PURE__ */ jsx11("label", { className: "chatai-visually-hidden", htmlFor: "chatai-message-input", children: "Message" }),
|
|
1612
|
+
/* @__PURE__ */ jsx11(
|
|
1613
|
+
"input",
|
|
1614
|
+
{
|
|
1615
|
+
id: "chatai-message-input",
|
|
1616
|
+
value: draft,
|
|
1617
|
+
onInput: (event) => setDraft(event.currentTarget.value),
|
|
1618
|
+
placeholder: voiceOn ? "Voice is on \u2014 end it to type" : "Ask a question\u2026",
|
|
1619
|
+
maxLength: 4e3,
|
|
1620
|
+
disabled: busy
|
|
1621
|
+
}
|
|
1622
|
+
),
|
|
1623
|
+
voiceOffered && !isDock && !isGuided ? /* @__PURE__ */ jsx11(
|
|
1624
|
+
"button",
|
|
1625
|
+
{
|
|
1626
|
+
type: "button",
|
|
1627
|
+
className: `chatai-mic${voiceOn ? " is-active" : ""}`,
|
|
1628
|
+
onClick: toggleVoice,
|
|
1629
|
+
disabled: streaming,
|
|
1630
|
+
"aria-pressed": voiceOn,
|
|
1631
|
+
"aria-label": voiceOn ? "End voice conversation" : "Start voice conversation",
|
|
1632
|
+
title: voiceOn ? "End voice" : "Talk instead",
|
|
1633
|
+
children: /* @__PURE__ */ jsx11(MicGlyph, { off: voiceOn })
|
|
1634
|
+
}
|
|
1635
|
+
) : null,
|
|
1636
|
+
/* @__PURE__ */ jsx11("button", { type: "submit", disabled: busy || !draft.trim(), "aria-label": "Send message", children: "\u2191" })
|
|
1637
|
+
]
|
|
1638
|
+
}
|
|
1639
|
+
)
|
|
1640
|
+
] })
|
|
638
1641
|
]
|
|
639
1642
|
}
|
|
640
1643
|
) : null,
|
|
641
|
-
/* @__PURE__ */
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
1644
|
+
/* @__PURE__ */ jsxs10("div", { className: "chatai-launch-row", children: [
|
|
1645
|
+
voiceOffered && isDock ? /* @__PURE__ */ jsx11(VoiceDockTalk, { open: dockOpen, onOpen: openDock, onClose: closeDock }) : null,
|
|
1646
|
+
/* @__PURE__ */ jsx11(
|
|
1647
|
+
"button",
|
|
1648
|
+
{
|
|
1649
|
+
ref: launcherRef,
|
|
1650
|
+
type: "button",
|
|
1651
|
+
className: "chatai-launcher",
|
|
1652
|
+
onClick: togglePanel,
|
|
1653
|
+
"aria-label": open || closing ? "Close chat" : "Open chat",
|
|
1654
|
+
"aria-expanded": open && !closing,
|
|
1655
|
+
"aria-haspopup": "dialog",
|
|
1656
|
+
children: settings.iconUrl ? /* @__PURE__ */ jsx11("img", { src: settings.iconUrl, alt: "" }) : /* @__PURE__ */ jsx11(ChatGlyph, {})
|
|
1657
|
+
}
|
|
1658
|
+
)
|
|
1659
|
+
] })
|
|
654
1660
|
]
|
|
655
1661
|
}
|
|
656
1662
|
);
|
|
657
1663
|
}
|
|
658
1664
|
|
|
659
1665
|
// src/styles.generated.ts
|
|
660
|
-
var styles = ':host {\n all: initial;\n}\n\n.chatai-widget {\n --chatai-accent: #0f766e;\n --chatai-ink: #14241e;\n --chatai-surface: #f6f6f0;\n --chatai-panel: #fffef9;\n --chatai-muted: #6d766f;\n --chatai-border: #d9ddd7;\n display: flex;\n width: fit-content;\n max-width: calc(100vw - 32px);\n flex-direction: column;\n align-items: flex-end;\n position: fixed;\n z-index: 2147483647;\n bottom: 20px;\n font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;\n color: var(--chatai-ink);\n}\n\n.chatai-widget.position-right {\n right: 20px;\n align-items: flex-end;\n}\n\n.chatai-widget.position-left {\n left: 20px;\n align-items: flex-start;\n}\n\n.chatai-widget.layout-contained {\n position: absolute;\n z-index: 1;\n max-width: 100%;\n}\n\n.chatai-widget-host-contained {\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.chatai-widget.layout-contained .chatai-panel {\n width: min(380px, 100%);\n height: min(570px, calc(100% - 70px));\n}\n\n.chatai-widget.layout-contained.position-right {\n right: 12px;\n}\n\n.chatai-widget.layout-contained.position-left {\n left: 12px;\n}\n\n.chatai-widget.theme-dark {\n --chatai-ink: #ecf4ec;\n --chatai-surface: #17231d;\n --chatai-panel: #101a14;\n --chatai-muted: #a9b8ad;\n --chatai-border: #2d4135;\n}\n\n.chatai-widget *,\n.chatai-widget *::before,\n.chatai-widget *::after {\n box-sizing: border-box;\n}\n\n.chatai-launcher {\n display: grid;\n flex-shrink: 0;\n width: 56px;\n height: 56px;\n padding: 0;\n place-items: center;\n border: 0;\n border-radius: 50% 50% 14% 50%;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n box-shadow: 0 12px 28px rgb(20 36 30 / 26%);\n transition: transform 160ms ease, box-shadow 160ms ease;\n}\n\n.chatai-widget.position-left .chatai-launcher {\n border-radius: 50% 50% 50% 14%;\n}\n\n.chatai-launcher[aria-expanded="true"] {\n transform: rotate(8deg) scale(0.96);\n}\n\n.chatai-launcher:hover {\n transform: translateY(-2px) rotate(-3deg);\n box-shadow: 0 16px 32px rgb(20 36 30 / 34%);\n}\n\n.chatai-launcher:focus-visible,\n.chatai-close:focus-visible,\n.chatai-prompts button:focus-visible,\n.chatai-composer input:focus-visible,\n.chatai-composer button:focus-visible,\n.chatai-retry:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-launcher svg,\n.chatai-launcher img {\n width: 24px;\n height: 24px;\n}\n\n.chatai-launcher img {\n border-radius: 50%;\n object-fit: cover;\n}\n\n.chatai-panel {\n display: flex;\n width: min(380px, calc(100vw - 32px));\n height: min(570px, calc(100dvh - 104px));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 24px 24px 8px 24px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-panel {\n border-radius: 24px 24px 24px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-panel.is-closing {\n animation: chatai-panel-out 140ms ease-in forwards;\n}\n\n@keyframes chatai-panel-in {\n from {\n opacity: 0;\n transform: translateY(10px) scale(0.98);\n }\n\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n@keyframes chatai-panel-out {\n from {\n opacity: 1;\n transform: none;\n }\n\n to {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.chatai-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 20px 16px;\n border-bottom: 1px solid var(--chatai-border);\n background: linear-gradient(135deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-widget.position-left .chatai-header {\n background: linear-gradient(225deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-kicker {\n margin: 0 0 5px;\n color: var(--chatai-muted);\n font-size: 10px;\n font-weight: 750;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-header h2 {\n margin: 0;\n font-size: 18px;\n letter-spacing: -0.03em;\n}\n\n.chatai-close {\n display: grid;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 1px solid var(--chatai-border);\n border-radius: 50%;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font-size: 22px;\n line-height: 1;\n}\n\n.chatai-transcript {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n overflow-y: auto;\n padding: 18px;\n background:\n radial-gradient(circle at 95% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-widget.position-left .chatai-transcript {\n background:\n radial-gradient(circle at 5% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-message {\n max-width: 87%;\n padding: 12px 13px;\n border-radius: 15px;\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-message p,\n.chatai-user-text {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-message.assistant {\n align-self: flex-start;\n border: 1px solid var(--chatai-border);\n border-radius: 5px 15px 15px;\n background: var(--chatai-panel);\n}\n\n.chatai-message.user {\n align-self: flex-end;\n border-radius: 15px 5px 15px 15px;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-md {\n font-size: 14px;\n line-height: 1.5;\n}\n\n.chatai-md-p {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-md-p + .chatai-md-p,\n.chatai-md-p + .chatai-md-ul,\n.chatai-md-p + .chatai-md-ol,\n.chatai-md-p + .chatai-md-pre,\n.chatai-md-ul + .chatai-md-p,\n.chatai-md-ol + .chatai-md-p,\n.chatai-md-pre + .chatai-md-p {\n margin-top: 0.55em;\n}\n\n.chatai-md-ul,\n.chatai-md-ol {\n margin: 0.45em 0;\n padding-left: 1.25em;\n}\n\n.chatai-md-ul {\n list-style: disc;\n}\n\n.chatai-md-ol {\n list-style: decimal;\n}\n\n.chatai-md-link {\n color: var(--chatai-accent);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n.chatai-md-link:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.chatai-md-code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.1em 0.35em;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.85em;\n}\n\n.chatai-md-pre {\n margin: 0.55em 0;\n overflow-x: auto;\n border-radius: 8px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.65em 0.75em;\n font-size: 0.85em;\n}\n\n.chatai-md-pre code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n white-space: pre;\n}\n\n.chatai-md-caret {\n display: inline-block;\n width: 2px;\n height: 0.9em;\n margin-left: 2px;\n vertical-align: middle;\n background: var(--chatai-ink);\n animation: chatai-caret-pulse 1s ease-in-out infinite;\n}\n\n@keyframes chatai-caret-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.2;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-md-caret {\n animation: none;\n opacity: 0.7;\n }\n}\n\n.chatai-prompts {\n display: flex;\n flex-wrap: wrap;\n gap: 7px;\n}\n\n.chatai-prompts button {\n border: 1px solid color-mix(in srgb, var(--chatai-accent), var(--chatai-border) 60%);\n border-radius: 999px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n line-height: 1.25;\n padding: 8px 10px;\n text-align: left;\n}\n\n.chatai-feedback {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-top: 10px;\n padding-top: 9px;\n border-top: 1px solid var(--chatai-border);\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-feedback span {\n margin-right: 2px;\n}\n\n.chatai-feedback button {\n display: inline-grid;\n place-items: center;\n width: 25px;\n height: 25px;\n border: 1px solid var(--chatai-border);\n border-radius: 6px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n line-height: 1;\n padding: 0;\n}\n\n.chatai-feedback button svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-feedback button[aria-pressed="true"] {\n border-color: var(--chatai-accent);\n background: color-mix(in srgb, var(--chatai-accent), transparent 90%);\n color: var(--chatai-accent);\n}\n\n.chatai-error {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n margin: 0;\n padding: 10px 12px;\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 55%);\n border-radius: 12px;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n font-size: 12px;\n text-align: center;\n}\n\n.chatai-error p {\n margin: 0;\n line-height: 1.4;\n}\n\n.chatai-retry {\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 40%);\n border-radius: 8px;\n background: var(--chatai-panel);\n color: #b42318;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n padding: 6px 12px;\n}\n\n.chatai-retry:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-typing {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-height: 1.2em;\n}\n\n.chatai-typing span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--chatai-muted);\n animation: chatai-typing-dot 1s ease-in-out infinite;\n}\n\n.chatai-typing span:nth-child(2) {\n animation-delay: 0.15s;\n}\n\n.chatai-typing span:nth-child(3) {\n animation-delay: 0.3s;\n}\n\n@keyframes chatai-typing-dot {\n 0%,\n 80%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n\n 40% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n\n.chatai-composer {\n display: flex;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n}\n\n.chatai-composer input {\n min-width: 0;\n flex: 1;\n border: 1px solid var(--chatai-border);\n border-radius: 10px;\n background: transparent;\n color: var(--chatai-ink);\n font: inherit;\n font-size: 14px;\n padding: 10px 11px;\n}\n\n.chatai-composer button {\n width: 40px;\n border: 0;\n border-radius: 10px;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n font-size: 18px;\n}\n\n.chatai-composer button:disabled,\n.chatai-prompts button:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-composer input:disabled {\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.chatai-composer .chatai-mic {\n display: grid;\n place-items: center;\n border: 1px solid var(--chatai-border);\n background: transparent;\n color: var(--chatai-ink);\n}\n\n.chatai-composer .chatai-mic svg {\n width: 18px;\n height: 18px;\n}\n\n.chatai-composer .chatai-mic.is-active {\n border-color: #b42318;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 44px;\n padding: 8px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n}\n\n.chatai-voice-bar.is-error {\n flex-wrap: wrap;\n justify-content: center;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n text-align: center;\n}\n\n.chatai-voice-bar.is-notice {\n flex-wrap: wrap;\n justify-content: center;\n text-align: center;\n}\n\n.chatai-voice-error {\n width: 100%;\n margin: 0;\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-actions {\n display: flex;\n gap: 8px;\n}\n\n.chatai-voice-consent {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n line-height: 1.45;\n}\n\n.chatai-voice-consent:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: -2px;\n}\n\n.chatai-voice-consent-title {\n margin: 0;\n font-weight: 650;\n}\n\n.chatai-voice-consent-text {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-consent-accept,\n.chatai-consent-cancel {\n min-height: 36px;\n padding: 0 14px;\n border-radius: 8px;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n\n.chatai-consent-accept {\n border: 0;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-consent-cancel {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-label {\n font-weight: 650;\n}\n\n.chatai-voice-meta {\n margin-left: auto;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-wave {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n height: 22px;\n}\n\n.chatai-wave span {\n display: block;\n width: 4px;\n height: 22px;\n border-radius: 2px;\n background: var(--chatai-accent);\n transform: scaleY(0.22);\n transition: transform 80ms linear;\n}\n\n.chatai-voice-bar[data-phase="requesting_mic"] .chatai-wave span,\n.chatai-voice-bar[data-phase="connecting"] .chatai-wave span,\n.chatai-voice-bar[data-phase="processing"] .chatai-wave span {\n animation: chatai-wave-idle 1.1s ease-in-out infinite;\n}\n\n.chatai-wave span:nth-child(2) {\n animation-delay: 0.1s;\n}\n\n.chatai-wave span:nth-child(3) {\n animation-delay: 0.2s;\n}\n\n.chatai-wave span:nth-child(4) {\n animation-delay: 0.3s;\n}\n\n.chatai-wave span:nth-child(5) {\n animation-delay: 0.4s;\n}\n\n.chatai-voice-bar[data-phase="interrupted"] .chatai-wave span {\n background: #b54708;\n}\n\n.chatai-voice-bar[data-phase="reconnecting"] .chatai-wave span {\n background: var(--chatai-muted);\n}\n\n@keyframes chatai-wave-idle {\n 0%,\n 100% {\n transform: scaleY(0.22);\n }\n\n 50% {\n transform: scaleY(0.6);\n }\n}\n\n.chatai-voice-tag {\n display: inline-flex;\n float: right;\n margin: -2px -3px 2px 8px;\n opacity: 0.65;\n}\n\n.chatai-voice-tag svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-message.is-live {\n opacity: 0.85;\n}\n\n.chatai-message.is-live .chatai-user-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-note {\n margin-top: 6px;\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-message.user .chatai-voice-note {\n color: rgb(255 255 255 / 80%);\n}\n\n.chatai-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n\n@media (max-width: 480px) {\n .chatai-widget {\n bottom: 12px;\n }\n\n .chatai-widget.position-right {\n right: 12px;\n }\n\n .chatai-widget.position-left {\n left: 12px;\n }\n\n .chatai-panel {\n width: calc(100vw - 24px);\n height: min(600px, calc(100dvh - 88px));\n }\n\n .chatai-composer button {\n min-width: 44px;\n min-height: 44px;\n }\n\n .chatai-composer input {\n font-size: 16px;\n }\n\n .chatai-retry {\n min-height: 40px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-launcher,\n .chatai-launcher:hover,\n .chatai-launcher[aria-expanded="true"] {\n transition: none;\n transform: none;\n }\n\n .chatai-panel,\n .chatai-panel.is-closing {\n animation: none;\n }\n\n .chatai-typing span {\n animation: none;\n opacity: 0.7;\n }\n\n .chatai-wave span,\n .chatai-voice-bar .chatai-wave span {\n animation: none;\n transition: none;\n transform: scaleY(0.45);\n }\n}\n';
|
|
1666
|
+
var styles = ':host {\n all: initial;\n}\n\n.chatai-widget {\n --chatai-accent: #0f766e;\n --chatai-ink: #14241e;\n --chatai-surface: #f6f6f0;\n --chatai-panel: #fffef9;\n --chatai-muted: #6d766f;\n --chatai-border: #d9ddd7;\n --chatai-safe-bottom: env(safe-area-inset-bottom, 0px);\n --chatai-safe-top: env(safe-area-inset-top, 0px);\n --chatai-safe-left: env(safe-area-inset-left, 0px);\n --chatai-safe-right: env(safe-area-inset-right, 0px);\n display: flex;\n width: fit-content;\n max-width: calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right));\n flex-direction: column;\n align-items: flex-end;\n position: fixed;\n z-index: 2147483647;\n bottom: max(20px, var(--chatai-safe-bottom));\n font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", sans-serif;\n color: var(--chatai-ink);\n}\n\n.chatai-widget.position-right {\n right: max(20px, var(--chatai-safe-right));\n align-items: flex-end;\n}\n\n.chatai-widget.position-left {\n left: max(20px, var(--chatai-safe-left));\n align-items: flex-start;\n}\n\n.chatai-widget.layout-contained {\n position: absolute;\n z-index: 1;\n max-width: 100%;\n}\n\n.chatai-widget-host-contained {\n position: relative;\n display: block;\n width: 100%;\n height: 100%;\n}\n\n.chatai-widget.layout-contained .chatai-panel {\n width: min(380px, 100%);\n height: min(570px, calc(100% - 70px));\n}\n\n.chatai-widget.layout-contained.position-right {\n right: 12px;\n}\n\n.chatai-widget.layout-contained.position-left {\n left: 12px;\n}\n\n/* Side panel \u2014 tall edge sheet beside host page content (no page scrape / context claims). */\n.chatai-widget.experience-side-panel .chatai-panel {\n width: min(360px, calc(100vw - 24px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n height: min(calc(100dvh - 88px - var(--chatai-safe-bottom) - var(--chatai-safe-top)), 860px);\n border-radius: 18px 18px 8px 18px;\n}\n\n.chatai-widget.experience-side-panel.position-left .chatai-panel {\n border-radius: 18px 18px 18px 8px;\n}\n\n.chatai-widget.experience-side-panel.layout-contained .chatai-panel {\n width: min(360px, 100%);\n height: min(calc(100% - 70px), 100%);\n}\n\n.chatai-widget.theme-dark {\n --chatai-ink: #ecf4ec;\n --chatai-surface: #17231d;\n --chatai-panel: #101a14;\n --chatai-muted: #a9b8ad;\n --chatai-border: #2d4135;\n}\n\n.chatai-widget *,\n.chatai-widget *::before,\n.chatai-widget *::after {\n box-sizing: border-box;\n}\n\n.chatai-launcher {\n display: grid;\n flex-shrink: 0;\n width: 56px;\n height: 56px;\n padding: 0;\n place-items: center;\n border: 0;\n border-radius: 50% 50% 14% 50%;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n box-shadow: 0 12px 28px rgb(20 36 30 / 26%);\n transition: transform 160ms ease, box-shadow 160ms ease;\n}\n\n.chatai-widget.position-left .chatai-launcher {\n border-radius: 50% 50% 50% 14%;\n}\n\n.chatai-launcher[aria-expanded="true"] {\n transform: rotate(8deg) scale(0.96);\n}\n\n.chatai-launcher:hover {\n transform: translateY(-2px) rotate(-3deg);\n box-shadow: 0 16px 32px rgb(20 36 30 / 34%);\n}\n\n.chatai-launcher:focus-visible,\n.chatai-close:focus-visible,\n.chatai-prompts button:focus-visible,\n.chatai-composer input:focus-visible,\n.chatai-composer button:focus-visible,\n.chatai-retry:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-launcher svg,\n.chatai-launcher img {\n width: 24px;\n height: 24px;\n}\n\n.chatai-launcher img {\n border-radius: 50%;\n object-fit: cover;\n}\n\n.chatai-panel {\n display: flex;\n width: min(380px, calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n height: min(570px, calc(100dvh - 104px - var(--chatai-safe-bottom) - var(--chatai-safe-top)));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 24px 24px 8px 24px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-panel {\n border-radius: 24px 24px 24px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-panel.is-closing {\n animation: chatai-panel-out 140ms ease-in forwards;\n}\n\n@keyframes chatai-panel-in {\n from {\n opacity: 0;\n transform: translateY(10px) scale(0.98);\n }\n\n to {\n opacity: 1;\n transform: none;\n }\n}\n\n@keyframes chatai-panel-out {\n from {\n opacity: 1;\n transform: none;\n }\n\n to {\n opacity: 0;\n transform: translateY(8px) scale(0.98);\n }\n}\n\n.chatai-header {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n padding: 20px 20px 16px;\n border-bottom: 1px solid var(--chatai-border);\n background: linear-gradient(135deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-widget.position-left .chatai-header {\n background: linear-gradient(225deg, color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 90%), var(--chatai-panel));\n}\n\n.chatai-kicker {\n margin: 0 0 5px;\n color: var(--chatai-muted);\n font-size: 10px;\n font-weight: 750;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-header h2 {\n margin: 0;\n font-size: 18px;\n letter-spacing: -0.03em;\n}\n\n.chatai-close {\n display: grid;\n width: 30px;\n height: 30px;\n place-items: center;\n border: 1px solid var(--chatai-border);\n border-radius: 50%;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font-size: 22px;\n line-height: 1;\n}\n\n.chatai-transcript {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n overflow-y: auto;\n padding: 18px;\n background:\n radial-gradient(circle at 95% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-widget.position-left .chatai-transcript {\n background:\n radial-gradient(circle at 5% 4%, color-mix(in srgb, var(--chatai-accent), transparent 90%), transparent 30%),\n var(--chatai-surface);\n}\n\n.chatai-message {\n max-width: 87%;\n padding: 12px 13px;\n border-radius: 15px;\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-message p,\n.chatai-user-text {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-message.assistant {\n align-self: flex-start;\n border: 1px solid var(--chatai-border);\n border-radius: 5px 15px 15px;\n background: var(--chatai-panel);\n}\n\n.chatai-message.user {\n align-self: flex-end;\n border-radius: 15px 5px 15px 15px;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-md {\n font-size: 14px;\n line-height: 1.5;\n}\n\n.chatai-md-p {\n margin: 0;\n white-space: pre-wrap;\n}\n\n.chatai-md-p + .chatai-md-p,\n.chatai-md-p + .chatai-md-ul,\n.chatai-md-p + .chatai-md-ol,\n.chatai-md-p + .chatai-md-pre,\n.chatai-md-ul + .chatai-md-p,\n.chatai-md-ol + .chatai-md-p,\n.chatai-md-pre + .chatai-md-p {\n margin-top: 0.55em;\n}\n\n.chatai-md-ul,\n.chatai-md-ol {\n margin: 0.45em 0;\n padding-left: 1.25em;\n}\n\n.chatai-md-ul {\n list-style: disc;\n}\n\n.chatai-md-ol {\n list-style: decimal;\n}\n\n.chatai-md-link {\n color: var(--chatai-accent);\n text-decoration: underline;\n text-underline-offset: 2px;\n}\n\n.chatai-md-link:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: 2px;\n border-radius: 2px;\n}\n\n.chatai-md-code {\n border-radius: 4px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.1em 0.35em;\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n font-size: 0.85em;\n}\n\n.chatai-md-pre {\n margin: 0.55em 0;\n overflow-x: auto;\n border-radius: 8px;\n background: color-mix(in srgb, var(--chatai-border), transparent 55%);\n padding: 0.65em 0.75em;\n font-size: 0.85em;\n}\n\n.chatai-md-pre code {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;\n white-space: pre;\n}\n\n.chatai-md-caret {\n display: inline-block;\n width: 2px;\n height: 0.9em;\n margin-left: 2px;\n vertical-align: middle;\n background: var(--chatai-ink);\n animation: chatai-caret-pulse 1s ease-in-out infinite;\n}\n\n@keyframes chatai-caret-pulse {\n 0%,\n 100% {\n opacity: 1;\n }\n 50% {\n opacity: 0.2;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-md-caret {\n animation: none;\n opacity: 0.7;\n }\n}\n\n.chatai-prompts {\n display: flex;\n flex-wrap: wrap;\n gap: 7px;\n}\n\n.chatai-prompts button {\n border: 1px solid color-mix(in srgb, var(--chatai-accent), var(--chatai-border) 60%);\n border-radius: 999px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n line-height: 1.25;\n padding: 8px 10px;\n text-align: left;\n}\n\n.chatai-feedback {\n display: flex;\n align-items: center;\n gap: 5px;\n margin-top: 10px;\n padding-top: 9px;\n border-top: 1px solid var(--chatai-border);\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-feedback span {\n margin-right: 2px;\n}\n\n.chatai-feedback button {\n display: inline-grid;\n place-items: center;\n width: 25px;\n height: 25px;\n border: 1px solid var(--chatai-border);\n border-radius: 6px;\n background: transparent;\n color: var(--chatai-ink);\n cursor: pointer;\n font: inherit;\n line-height: 1;\n padding: 0;\n}\n\n.chatai-feedback button svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-feedback button[aria-pressed="true"] {\n border-color: var(--chatai-accent);\n background: color-mix(in srgb, var(--chatai-accent), transparent 90%);\n color: var(--chatai-accent);\n}\n\n.chatai-error {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n margin: 0;\n padding: 10px 12px;\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 55%);\n border-radius: 12px;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n font-size: 12px;\n text-align: center;\n}\n\n.chatai-error p {\n margin: 0;\n line-height: 1.4;\n}\n\n.chatai-retry {\n border: 1px solid color-mix(in srgb, #b42318, var(--chatai-border) 40%);\n border-radius: 8px;\n background: var(--chatai-panel);\n color: #b42318;\n cursor: pointer;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n padding: 6px 12px;\n}\n\n.chatai-retry:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-typing {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n min-height: 1.2em;\n}\n\n.chatai-typing span {\n width: 6px;\n height: 6px;\n border-radius: 50%;\n background: var(--chatai-muted);\n animation: chatai-typing-dot 1s ease-in-out infinite;\n}\n\n.chatai-typing span:nth-child(2) {\n animation-delay: 0.15s;\n}\n\n.chatai-typing span:nth-child(3) {\n animation-delay: 0.3s;\n}\n\n@keyframes chatai-typing-dot {\n 0%,\n 80%,\n 100% {\n opacity: 0.35;\n transform: translateY(0);\n }\n\n 40% {\n opacity: 1;\n transform: translateY(-2px);\n }\n}\n\n.chatai-composer {\n display: flex;\n gap: 8px;\n padding: 12px;\n border-top: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n}\n\n.chatai-composer input {\n min-width: 0;\n flex: 1;\n border: 1px solid var(--chatai-border);\n border-radius: 10px;\n background: transparent;\n color: var(--chatai-ink);\n font: inherit;\n font-size: 14px;\n padding: 10px 11px;\n}\n\n.chatai-composer button {\n width: 40px;\n border: 0;\n border-radius: 10px;\n background: var(--chatai-accent);\n color: white;\n cursor: pointer;\n font-size: 18px;\n}\n\n.chatai-composer button:disabled,\n.chatai-prompts button:disabled {\n cursor: not-allowed;\n opacity: 0.48;\n}\n\n.chatai-composer input:disabled {\n cursor: not-allowed;\n opacity: 0.7;\n}\n\n.chatai-composer .chatai-mic {\n display: grid;\n place-items: center;\n border: 1px solid var(--chatai-border);\n background: transparent;\n color: var(--chatai-ink);\n}\n\n.chatai-composer .chatai-mic svg {\n width: 18px;\n height: 18px;\n}\n\n.chatai-composer .chatai-mic.is-active {\n border-color: #b42318;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-bar {\n display: flex;\n align-items: center;\n gap: 10px;\n min-height: 44px;\n padding: 8px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n}\n\n.chatai-voice-bar.is-error {\n flex-wrap: wrap;\n justify-content: center;\n background: color-mix(in srgb, #b42318, transparent 92%);\n color: #b42318;\n text-align: center;\n}\n\n.chatai-voice-bar.is-notice {\n flex-wrap: wrap;\n justify-content: center;\n text-align: center;\n}\n\n.chatai-voice-error {\n width: 100%;\n margin: 0;\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-actions {\n display: flex;\n gap: 8px;\n}\n\n.chatai-voice-consent {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 12px 14px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-accent), var(--chatai-panel) 92%);\n font-size: 13px;\n line-height: 1.45;\n}\n\n.chatai-voice-consent:focus-visible {\n outline: 2px solid var(--chatai-accent);\n outline-offset: -2px;\n}\n\n.chatai-voice-consent-title {\n margin: 0;\n font-weight: 650;\n}\n\n.chatai-voice-consent-text {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-consent-accept,\n.chatai-consent-cancel {\n min-height: 36px;\n padding: 0 14px;\n border-radius: 8px;\n font: inherit;\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n}\n\n.chatai-consent-accept {\n border: 0;\n background: var(--chatai-accent);\n color: #fff;\n}\n\n.chatai-consent-cancel {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-label {\n font-weight: 650;\n}\n\n.chatai-voice-meta {\n margin-left: auto;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-wave {\n display: inline-flex;\n align-items: center;\n gap: 3px;\n height: 22px;\n}\n\n.chatai-wave span {\n display: block;\n width: 4px;\n height: 22px;\n border-radius: 2px;\n background: var(--chatai-accent);\n transform: scaleY(0.22);\n transition: transform 80ms linear;\n}\n\n.chatai-voice-bar[data-phase="requesting_mic"] .chatai-wave span,\n.chatai-voice-bar[data-phase="connecting"] .chatai-wave span,\n.chatai-voice-bar[data-phase="processing"] .chatai-wave span {\n animation: chatai-wave-idle 1.1s ease-in-out infinite;\n}\n\n.chatai-wave span:nth-child(2) {\n animation-delay: 0.1s;\n}\n\n.chatai-wave span:nth-child(3) {\n animation-delay: 0.2s;\n}\n\n.chatai-wave span:nth-child(4) {\n animation-delay: 0.3s;\n}\n\n.chatai-wave span:nth-child(5) {\n animation-delay: 0.4s;\n}\n\n.chatai-voice-bar[data-phase="interrupted"] .chatai-wave span {\n background: #b54708;\n}\n\n.chatai-voice-bar[data-phase="reconnecting"] .chatai-wave span {\n background: var(--chatai-muted);\n}\n\n@keyframes chatai-wave-idle {\n 0%,\n 100% {\n transform: scaleY(0.22);\n }\n\n 50% {\n transform: scaleY(0.6);\n }\n}\n\n.chatai-voice-tag {\n display: inline-flex;\n float: right;\n margin: -2px -3px 2px 8px;\n opacity: 0.65;\n}\n\n.chatai-voice-tag svg {\n width: 13px;\n height: 13px;\n}\n\n.chatai-message.is-live {\n opacity: 0.85;\n}\n\n.chatai-message.is-live .chatai-user-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-note {\n margin-top: 6px;\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-message.user .chatai-voice-note {\n color: rgb(255 255 255 / 80%);\n}\n\n.chatai-visually-hidden {\n position: absolute;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0 0 0 0);\n white-space: nowrap;\n}\n\n/* Orb / Dock voice stage \u2014 replaces transcript + composer while Voice is active. */\n.chatai-voice-stage {\n --chatai-voice-accent: var(--chatai-accent);\n --chatai-orb-energy: 0;\n display: flex;\n flex: 1;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n min-height: 0;\n padding: 18px 16px calc(14px + var(--chatai-safe-bottom));\n overflow: auto;\n overscroll-behavior: contain;\n text-align: center;\n -webkit-overflow-scrolling: touch;\n}\n\n.chatai-voice-label-short {\n display: none;\n}\n\n.chatai-voice-identity {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n}\n\n.chatai-voice-name {\n font-size: 17px;\n font-weight: 650;\n letter-spacing: -0.02em;\n}\n\n.chatai-orb {\n position: relative;\n width: 148px;\n height: 148px;\n margin: 8px 0 4px;\n flex-shrink: 0;\n}\n\n.chatai-orb-core,\n.chatai-orb-shine,\n.chatai-orb-shadow {\n position: absolute;\n inset: 0;\n border-radius: 48% 52% 57% 43% / 53% 42% 58% 47%;\n}\n\n.chatai-orb-core {\n background: radial-gradient(\n ellipse at 28% 20%,\n #fff8e8 0%,\n color-mix(in srgb, var(--chatai-voice-accent), #fff 55%) 26%,\n var(--chatai-voice-accent) 54%,\n color-mix(in srgb, var(--chatai-voice-accent), #1a1a12 55%) 82%\n );\n box-shadow:\n inset -12px -18px 22px rgb(20 36 30 / 42%),\n inset 4px 6px 16px rgb(255 255 255 / 42%);\n transform: scale(calc(0.96 + var(--chatai-orb-energy) * 0.12));\n transition: transform 180ms ease, border-radius 500ms ease;\n}\n\n.chatai-orb-shine {\n inset: 10% 18% auto 14%;\n height: 28%;\n border-radius: 50%;\n background: linear-gradient(180deg, rgb(255 255 255 / 55%), transparent);\n pointer-events: none;\n}\n\n.chatai-orb-shadow {\n inset: auto 12% -6% 12%;\n height: 18%;\n border-radius: 50%;\n background: radial-gradient(ellipse, rgb(20 36 30 / 22%), transparent 70%);\n filter: blur(2px);\n pointer-events: none;\n}\n\n.chatai-voice-stage[data-motion="listening"] .chatai-orb-core {\n border-radius: 55% 45% 42% 58% / 43% 60% 40% 57%;\n}\n\n.chatai-voice-stage[data-motion="hearing"] .chatai-orb-core {\n border-radius: 52% 48% 60% 40% / 48% 55% 45% 52%;\n}\n\n.chatai-voice-stage[data-motion="speaking"] .chatai-orb-core {\n border-radius: 40% 60% 52% 48% / 58% 45% 55% 42%;\n}\n\n.chatai-voice-stage[data-motion="processing"] .chatai-orb-core,\n.chatai-voice-stage[data-motion="pending"] .chatai-orb-core {\n border-radius: 50% 50% 46% 54% / 54% 46% 54% 46%;\n}\n\n.chatai-voice-stage[data-motion="settle"] .chatai-orb-core {\n border-radius: 47% 53% 50% 50% / 50% 48% 52% 50%;\n}\n\n.chatai-voice-stage-status {\n margin: 0;\n font-size: 15px;\n font-weight: 650;\n}\n\n.chatai-voice-stage-detail {\n margin: 0;\n max-width: 28ch;\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-voice-stage-meta {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-voice-captions {\n display: flex;\n flex: 1 1 auto;\n flex-direction: column;\n gap: 8px;\n width: 100%;\n min-height: 0;\n max-height: min(140px, 28%);\n margin-top: 4px;\n padding: 10px 12px;\n overflow: auto;\n overscroll-behavior: contain;\n border-radius: 12px;\n background: color-mix(in srgb, var(--chatai-voice-accent), var(--chatai-panel) 92%);\n text-align: left;\n -webkit-overflow-scrolling: touch;\n}\n\n.chatai-voice-captions.is-empty {\n text-align: center;\n color: var(--chatai-muted);\n font-size: 12px;\n}\n\n.chatai-voice-captions.is-empty p {\n margin: 0;\n}\n\n.chatai-voice-caption {\n display: grid;\n gap: 2px;\n margin: 0;\n font-size: 13px;\n line-height: 1.35;\n}\n\n.chatai-voice-caption-who {\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n}\n\n.chatai-voice-caption.user .chatai-voice-caption-who {\n color: var(--chatai-voice-accent);\n}\n\n.chatai-voice-caption.is-live .chatai-voice-caption-text::after {\n content: "\u2026";\n}\n\n.chatai-voice-caption-note {\n color: var(--chatai-muted);\n font-size: 11px;\n font-style: italic;\n}\n\n.chatai-voice-controls {\n display: flex;\n flex-wrap: wrap;\n justify-content: center;\n gap: 8px;\n width: 100%;\n margin-top: auto;\n padding-top: 10px;\n flex-shrink: 0;\n}\n\n.chatai-voice-primary,\n.chatai-voice-secondary,\n.chatai-voice-danger {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n min-height: 44px;\n padding: 0 14px;\n border-radius: 10px;\n font: inherit;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n touch-action: manipulation;\n transition: transform 120ms ease-out, opacity 120ms ease-out;\n}\n\n.chatai-voice-primary:active,\n.chatai-voice-secondary:active,\n.chatai-voice-danger:active {\n transform: scale(0.97);\n}\n\n.chatai-voice-primary {\n border: 0;\n background: var(--chatai-voice-accent);\n color: #fff;\n}\n\n.chatai-voice-secondary {\n border: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n}\n\n.chatai-voice-secondary.is-pressed {\n border-color: var(--chatai-voice-accent);\n background: color-mix(in srgb, var(--chatai-voice-accent), var(--chatai-panel) 88%);\n}\n\n.chatai-voice-danger {\n border: 0;\n background: #b42318;\n color: #fff;\n}\n\n.chatai-voice-controls svg {\n width: 16px;\n height: 16px;\n}\n\n.chatai-voice-stage .chatai-voice-consent {\n width: 100%;\n border-top: 0;\n border-radius: 12px;\n text-align: left;\n}\n\n.chatai-voice-stage .chatai-voice-actions {\n flex-wrap: wrap;\n justify-content: stretch;\n}\n\n.chatai-voice-stage .chatai-consent-accept,\n.chatai-voice-stage .chatai-consent-cancel {\n flex: 1;\n min-height: 44px;\n}\n\n.chatai-voice-primary:focus-visible,\n.chatai-voice-secondary:focus-visible,\n.chatai-voice-danger:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-voice-accent), white 55%);\n outline-offset: 2px;\n}\n\n/* Launch controls stay put; panel/dock surfaces sit above them in the column. */\n.chatai-launch-row {\n display: flex;\n flex-direction: row;\n flex-shrink: 0;\n align-items: center;\n gap: 10px;\n}\n\n.chatai-dock-talk {\n display: inline-flex;\n box-sizing: border-box;\n align-items: center;\n justify-content: center;\n gap: 8px;\n width: 5.75rem;\n min-height: 48px;\n padding: 0 14px;\n border: 0;\n border-radius: 999px;\n background: var(--chatai-voice-accent, var(--chatai-accent));\n color: #fff;\n font: inherit;\n font-size: 14px;\n font-weight: 650;\n cursor: pointer;\n box-shadow: 0 10px 22px rgb(20 36 30 / 22%);\n}\n\n.chatai-dock-talk svg {\n width: 18px;\n height: 18px;\n flex-shrink: 0;\n}\n\n.chatai-dock-talk.is-open {\n background: color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), #1a1a12 28%);\n}\n\n.chatai-dock-talk:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), white 55%);\n outline-offset: 2px;\n}\n\n/* Same placement model as .chatai-panel: above the launch row, bottom-anchored. */\n.chatai-dock-surface {\n display: flex;\n width: min(320px, calc(100vw - 32px - var(--chatai-safe-left) - var(--chatai-safe-right)));\n max-height: min(420px, calc(100dvh - 104px - var(--chatai-safe-bottom) - var(--chatai-safe-top)));\n margin-bottom: 14px;\n flex-direction: column;\n flex-shrink: 0;\n overflow: hidden;\n border: 1px solid var(--chatai-border);\n border-radius: 20px 20px 8px 20px;\n background: var(--chatai-panel);\n box-shadow: 0 24px 70px rgb(20 36 30 / 24%);\n transform-origin: bottom right;\n animation: chatai-panel-in 180ms ease-out;\n}\n\n.chatai-widget.position-left .chatai-dock-surface {\n border-radius: 20px 20px 20px 8px;\n transform-origin: bottom left;\n}\n\n.chatai-widget.position-left .chatai-launch-row {\n flex-direction: row-reverse;\n}\n\n.chatai-dock-surface .chatai-voice-stage {\n flex: 1;\n min-height: 0;\n overflow: auto;\n}\n\n.chatai-guided {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 12px;\n min-height: 0;\n padding: 18px 16px 12px;\n overflow: auto;\n}\n\n.chatai-guided-kicker {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.12em;\n text-transform: uppercase;\n}\n\n.chatai-guided-title {\n margin: 0;\n font-size: 22px;\n font-weight: 650;\n letter-spacing: -0.03em;\n line-height: 1.15;\n}\n\n.chatai-guided-welcome {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 14px;\n line-height: 1.45;\n}\n\n.chatai-guided-choices {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 4px;\n}\n\n.chatai-guided-choices-label {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.06em;\n text-transform: uppercase;\n}\n\n.chatai-guided-choice {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 10px;\n min-height: 44px;\n padding: 10px 12px;\n border: 1px solid var(--chatai-border);\n border-radius: 12px;\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n font: inherit;\n font-size: 13px;\n font-weight: 550;\n text-align: left;\n cursor: pointer;\n}\n\n.chatai-guided-choice:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n\n.chatai-guided-choice:focus-visible {\n outline: 3px solid color-mix(in srgb, var(--chatai-accent), white 55%);\n outline-offset: 2px;\n}\n\n.chatai-guided-choice-mark {\n color: var(--chatai-muted);\n font-size: 14px;\n}\n\n.chatai-guided-hint {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.4;\n}\n\n.chatai-guided-start {\n align-self: stretch;\n margin-top: auto;\n}\n\n.chatai-guided-history {\n flex: 0 1 40%;\n max-height: 40%;\n border-top: 1px solid var(--chatai-border);\n}\n\n.chatai-guided-stage {\n display: flex;\n flex: 1;\n flex-direction: column;\n min-height: 0;\n}\n\n.chatai-guided-stage .chatai-voice-stage {\n flex: 1;\n min-height: 0;\n}\n\n.chatai-guided-speak-hints {\n flex-shrink: 0;\n padding: 8px 14px 12px;\n border-top: 1px solid var(--chatai-border);\n background: color-mix(in srgb, var(--chatai-voice-accent, var(--chatai-accent)), var(--chatai-panel) 94%);\n}\n\n.chatai-guided-speak-hints ul {\n display: flex;\n flex-direction: column;\n gap: 4px;\n margin: 6px 0 0;\n padding: 0;\n list-style: none;\n}\n\n.chatai-guided-speak-hints li {\n color: var(--chatai-muted);\n font-size: 12px;\n line-height: 1.35;\n}\n\n.chatai-guided-speak-hints li::before {\n content: "\u201C";\n}\n\n.chatai-guided-speak-hints li::after {\n content: "\u201D";\n}\n\n/* Companion \u2014 abstract character + idle canvas */\n.chatai-companion {\n display: flex;\n flex: 1;\n flex-direction: column;\n align-items: center;\n gap: 10px;\n padding: 18px 16px 12px;\n overflow: auto;\n text-align: center;\n}\n\n.chatai-companion-kicker {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n font-weight: 650;\n letter-spacing: 0.14em;\n text-transform: uppercase;\n}\n\n.chatai-companion-title {\n margin: 0;\n font-size: 20px;\n font-weight: 700;\n letter-spacing: -0.02em;\n}\n\n.chatai-companion-speech {\n position: relative;\n max-width: 28ch;\n margin: 4px 0 0;\n padding: 12px 14px;\n border: 1px solid var(--chatai-border);\n border-radius: 16px;\n background: var(--chatai-panel);\n color: var(--chatai-ink);\n font-size: 13px;\n line-height: 1.4;\n}\n\n.chatai-companion-speech::after {\n content: "";\n position: absolute;\n bottom: -7px;\n left: 50%;\n width: 12px;\n height: 12px;\n margin-left: -6px;\n border-right: 1px solid var(--chatai-border);\n border-bottom: 1px solid var(--chatai-border);\n background: var(--chatai-panel);\n transform: rotate(45deg);\n}\n\n.chatai-companion-character {\n --chatai-companion-energy: 0;\n --chatai-companion-accent: var(--chatai-voice-accent, var(--chatai-accent));\n position: relative;\n width: 132px;\n height: 148px;\n margin: 18px 0 8px;\n}\n\n.chatai-companion-body {\n position: absolute;\n inset: 0 8% 18% 8%;\n border-radius: 52% 48% 38% 42%;\n background: radial-gradient(\n ellipse at 27% 25%,\n color-mix(in srgb, var(--chatai-companion-accent), #fff 62%) 0%,\n var(--chatai-companion-accent) 52%,\n color-mix(in srgb, var(--chatai-companion-accent), #1a1a12 45%) 88%\n );\n box-shadow:\n inset -10px -12px 18px rgb(20 36 30 / 28%),\n inset 4px 6px 14px rgb(255 255 255 / 35%),\n 0 14px 16px rgb(20 36 30 / 14%);\n transform: rotate(calc(-6deg + var(--chatai-companion-energy) * 12deg))\n translateY(calc(var(--chatai-companion-energy) * -6px))\n scale(calc(0.97 + var(--chatai-companion-energy) * 0.08));\n transition: transform 180ms ease, border-radius 480ms ease;\n}\n\n.chatai-companion-eye {\n position: absolute;\n top: 38%;\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: #1a1a12;\n box-shadow: inset 0 -1px 0 rgb(255 255 255 / 35%);\n}\n\n.chatai-companion-eye-left {\n left: 34%;\n}\n\n.chatai-companion-eye-right {\n right: 34%;\n}\n\n.chatai-companion-smile {\n position: absolute;\n top: 52%;\n left: 50%;\n width: 22px;\n height: 10px;\n margin-left: -11px;\n border: 2px solid #1a1a12;\n border-top: 0;\n border-radius: 0 0 14px 14px;\n opacity: 0.85;\n}\n\n.chatai-companion-foot {\n position: absolute;\n bottom: 4%;\n width: 22px;\n height: 14px;\n border-radius: 40% 40% 50% 50%;\n background: color-mix(in srgb, var(--chatai-companion-accent), #1a1a12 35%);\n box-shadow: 0 3px 4px rgb(20 36 30 / 18%);\n}\n\n.chatai-companion-foot-left {\n left: 28%;\n}\n\n.chatai-companion-foot-right {\n right: 28%;\n}\n\n.chatai-voice-stage[data-motion="listening"] .chatai-companion-body,\n.chatai-companion-character[data-motion="listening"] .chatai-companion-body {\n border-radius: 48% 52% 42% 40%;\n}\n\n.chatai-voice-stage[data-motion="hearing"] .chatai-companion-body,\n.chatai-companion-character[data-motion="hearing"] .chatai-companion-body {\n border-radius: 42% 58% 45% 35%;\n}\n\n.chatai-voice-stage[data-motion="speaking"] .chatai-companion-body,\n.chatai-companion-character[data-motion="speaking"] .chatai-companion-body {\n border-radius: 40% 60% 48% 38%;\n}\n\n.chatai-voice-stage[data-motion="processing"] .chatai-companion-body,\n.chatai-voice-stage[data-motion="pending"] .chatai-companion-body,\n.chatai-companion-character[data-motion="processing"] .chatai-companion-body,\n.chatai-companion-character[data-motion="pending"] .chatai-companion-body {\n border-radius: 50% 50% 44% 46%;\n}\n\n.chatai-companion-hint {\n margin: 0;\n color: var(--chatai-muted);\n font-size: 11px;\n}\n\n.chatai-companion-start {\n margin-top: 4px;\n min-width: 11rem;\n}\n\n.chatai-companion-history {\n flex: 0 1 auto;\n max-height: 28%;\n border-top: 1px solid var(--chatai-border);\n}\n\n.chatai-voice-stage.visual-companion .chatai-companion-character {\n margin: 8px 0;\n}\n\n.chatai-voice-stage.layout-compact {\n padding: 14px 12px calc(12px + var(--chatai-safe-bottom));\n gap: 8px;\n}\n\n.chatai-voice-stage.layout-compact .chatai-orb {\n width: 108px;\n height: 108px;\n margin: 4px 0;\n}\n\n.chatai-voice-stage.layout-compact .chatai-voice-name {\n font-size: 15px;\n}\n\n.chatai-voice-stage.layout-compact .chatai-voice-captions {\n max-height: 96px;\n}\n\n/* Phones \u2014 near full-viewport sheet so Voice and chat feel native. */\n@media (max-width: 480px) {\n .chatai-widget {\n bottom: max(10px, var(--chatai-safe-bottom));\n max-width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n }\n\n .chatai-widget.position-right {\n right: max(10px, var(--chatai-safe-right));\n }\n\n .chatai-widget.position-left {\n left: max(10px, var(--chatai-safe-left));\n }\n\n .chatai-panel {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n max-height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n margin-bottom: 10px;\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-widget.position-left .chatai-panel {\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-launcher {\n width: 52px;\n height: 52px;\n }\n\n .chatai-composer button,\n .chatai-composer .chatai-mic {\n min-width: 44px;\n min-height: 44px;\n }\n\n .chatai-composer input {\n font-size: 16px; /* avoid iOS zoom on focus */\n }\n\n .chatai-retry {\n min-height: 44px;\n }\n\n .chatai-header {\n padding: 12px 14px;\n }\n\n .chatai-header h2 {\n font-size: 16px;\n }\n\n .chatai-voice-stage {\n gap: 8px;\n padding: 12px 12px calc(10px + var(--chatai-safe-bottom));\n }\n\n .chatai-orb {\n width: 112px;\n height: 112px;\n margin: 4px 0;\n }\n\n .chatai-voice-name {\n font-size: 16px;\n }\n\n .chatai-voice-stage-status {\n font-size: 14px;\n }\n\n .chatai-voice-captions {\n max-height: min(28vh, 112px);\n padding: 8px 10px;\n }\n\n .chatai-voice-controls {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n }\n\n .chatai-voice-primary,\n .chatai-voice-danger {\n grid-column: 1 / -1;\n }\n\n .chatai-voice-primary,\n .chatai-voice-secondary,\n .chatai-voice-danger {\n min-height: 48px;\n width: 100%;\n padding: 0 12px;\n }\n\n .chatai-voice-label-long {\n display: none;\n }\n\n .chatai-voice-label-short {\n display: inline;\n }\n\n .chatai-voice-stage .chatai-consent-accept,\n .chatai-voice-stage .chatai-consent-cancel {\n min-height: 48px;\n }\n\n .chatai-dock-surface {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n max-height: min(52dvh, calc(100dvh - 88px - var(--chatai-safe-bottom)));\n margin-bottom: 10px;\n border-radius: 18px 18px 12px 12px;\n }\n\n .chatai-widget.position-left .chatai-dock-surface {\n border-radius: 18px 18px 12px 12px;\n }\n\n .chatai-dock-talk {\n width: auto;\n min-width: 5rem;\n min-height: 48px;\n padding: 0 16px;\n }\n\n .chatai-widget.experience-side-panel .chatai-panel {\n width: calc(100vw - 16px - var(--chatai-safe-left) - var(--chatai-safe-right));\n height: calc(100dvh - 72px - var(--chatai-safe-bottom) - var(--chatai-safe-top));\n max-height: none;\n border-radius: 20px 20px 14px 14px;\n }\n\n .chatai-guided,\n .chatai-companion {\n padding: 14px 12px 10px;\n gap: 10px;\n }\n\n .chatai-guided-title,\n .chatai-companion-title {\n font-size: 20px;\n }\n\n .chatai-guided-history,\n .chatai-companion-history {\n max-height: 30%;\n }\n\n .chatai-guided-speak-hints {\n padding: 8px 12px 10px;\n }\n\n .chatai-voice-bar {\n gap: 8px;\n padding: 8px 12px;\n font-size: 12px;\n }\n}\n\n/* Short phones / landscape \u2014 keep orb + controls visible without scroll fights. */\n@media (max-height: 640px) {\n .chatai-orb {\n width: 96px;\n height: 96px;\n margin: 2px 0;\n }\n\n .chatai-voice-stage.layout-compact .chatai-orb {\n width: 88px;\n height: 88px;\n }\n\n .chatai-voice-captions {\n max-height: min(22vh, 88px);\n }\n\n .chatai-voice-identity .chatai-kicker {\n display: none;\n }\n\n .chatai-guided-welcome {\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n .chatai-launcher,\n .chatai-launcher:hover,\n .chatai-launcher[aria-expanded="true"] {\n transition: none;\n transform: none;\n }\n\n .chatai-panel,\n .chatai-panel.is-closing,\n .chatai-dock-surface {\n animation: none;\n }\n\n .chatai-typing span {\n animation: none;\n opacity: 0.7;\n }\n\n .chatai-wave span,\n .chatai-voice-bar .chatai-wave span {\n animation: none;\n transition: none;\n transform: scaleY(0.45);\n }\n\n .chatai-voice-primary:active,\n .chatai-voice-secondary:active,\n .chatai-voice-danger:active {\n transform: none;\n }\n\n .chatai-orb-core,\n .chatai-companion-body {\n transition: none;\n transform: none;\n }\n}\n';
|
|
661
1667
|
var styles_generated_default = styles;
|
|
662
1668
|
|
|
663
1669
|
// src/mount.tsx
|
|
664
|
-
import { jsx as
|
|
1670
|
+
import { jsx as jsx12 } from "preact/jsx-runtime";
|
|
665
1671
|
function mountWidget(target, options) {
|
|
666
1672
|
const root = target.shadowRoot ?? target.attachShadow({ mode: "open" });
|
|
667
1673
|
const style = document.createElement("style");
|
|
@@ -669,8 +1675,17 @@ function mountWidget(target, options) {
|
|
|
669
1675
|
const host = document.createElement("div");
|
|
670
1676
|
host.className = options.layout === "contained" ? "chatai-widget-host-contained" : "";
|
|
671
1677
|
root.replaceChildren(style, host);
|
|
672
|
-
|
|
1678
|
+
let current = options;
|
|
1679
|
+
const paint = () => {
|
|
1680
|
+
host.className = current.layout === "contained" ? "chatai-widget-host-contained" : "";
|
|
1681
|
+
render(/* @__PURE__ */ jsx12(WidgetApp, { ...current }), host);
|
|
1682
|
+
};
|
|
1683
|
+
paint();
|
|
673
1684
|
return {
|
|
1685
|
+
update(next) {
|
|
1686
|
+
current = { ...current, ...next };
|
|
1687
|
+
paint();
|
|
1688
|
+
},
|
|
674
1689
|
destroy() {
|
|
675
1690
|
render(null, host);
|
|
676
1691
|
root.replaceChildren();
|
|
@@ -679,10 +1694,23 @@ function mountWidget(target, options) {
|
|
|
679
1694
|
}
|
|
680
1695
|
|
|
681
1696
|
// src/bootstrap.ts
|
|
682
|
-
import {
|
|
1697
|
+
import {
|
|
1698
|
+
resolveApiUrl,
|
|
1699
|
+
VOICE_EXPERIENCES
|
|
1700
|
+
} from "@nightzeros/chatai-widget-core";
|
|
683
1701
|
function option(value, allowed) {
|
|
684
1702
|
return value && allowed.includes(value) ? value : void 0;
|
|
685
1703
|
}
|
|
1704
|
+
function voiceAppearanceFromScript(script) {
|
|
1705
|
+
const experience = option(script.dataset.voiceExperience, VOICE_EXPERIENCES);
|
|
1706
|
+
const captions = script.dataset.voiceCaptions;
|
|
1707
|
+
const captionsDefault = captions === "on" ? true : captions === "off" ? false : void 0;
|
|
1708
|
+
if (experience === void 0 && captionsDefault === void 0) return void 0;
|
|
1709
|
+
return {
|
|
1710
|
+
...experience !== void 0 ? { experience } : {},
|
|
1711
|
+
...captionsDefault !== void 0 ? { captionsDefault } : {}
|
|
1712
|
+
};
|
|
1713
|
+
}
|
|
686
1714
|
function optionsFromScript(script) {
|
|
687
1715
|
const assistantId = script.dataset.assistantId?.trim();
|
|
688
1716
|
if (!assistantId) {
|
|
@@ -690,13 +1718,15 @@ function optionsFromScript(script) {
|
|
|
690
1718
|
}
|
|
691
1719
|
const apiUrl = resolveApiUrl(script.dataset.apiUrl ?? script.src);
|
|
692
1720
|
const signEndpoint = script.dataset.signEndpoint?.trim() || void 0;
|
|
1721
|
+
const voiceAppearance = voiceAppearanceFromScript(script);
|
|
693
1722
|
return {
|
|
694
1723
|
assistantId,
|
|
695
1724
|
apiUrl,
|
|
696
1725
|
...signEndpoint ? { signEndpoint } : {},
|
|
697
1726
|
theme: option(script.dataset.theme, ["light", "dark", "system"]),
|
|
698
1727
|
position: option(script.dataset.position, ["bottom-left", "bottom-right"]),
|
|
699
|
-
...script.dataset.voice === "off" ? { voice: false } : {}
|
|
1728
|
+
...script.dataset.voice === "off" ? { voice: false } : {},
|
|
1729
|
+
...voiceAppearance ? { voiceAppearance } : {}
|
|
700
1730
|
};
|
|
701
1731
|
}
|
|
702
1732
|
export {
|