@webless/agent 0.6.11 → 0.7.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.
@@ -1617,6 +1617,20 @@ function latestTurnEvents(events) {
1617
1617
  }
1618
1618
  return startIndex >= 0 ? events.slice(startIndex) : [];
1619
1619
  }
1620
+ function streamIndexBeforeLastTurn(input) {
1621
+ let turnStart = -1;
1622
+ for (let index = input.events.length - 1; index >= 0; index -= 1) {
1623
+ if (input.events[index]?.type === "message.received") {
1624
+ turnStart = index;
1625
+ break;
1626
+ }
1627
+ }
1628
+ if (turnStart < 0) return null;
1629
+ return Math.max(
1630
+ 0,
1631
+ input.currentStreamIndex - (input.events.length - turnStart)
1632
+ );
1633
+ }
1620
1634
  function renderTurn(events) {
1621
1635
  let rendered = "";
1622
1636
  for (const event of events) {
@@ -1801,6 +1815,40 @@ var AgentSession = class {
1801
1815
  this.storeOptions
1802
1816
  );
1803
1817
  }
1818
+ async rewindBeforeLastTurn(signal) {
1819
+ const persisted = loadPersistedAgentSession(
1820
+ this.visitorSessionId,
1821
+ this.storeOptions
1822
+ );
1823
+ if (!persisted?.sessionId) return false;
1824
+ const client = this.ensureClient();
1825
+ const attached = client.sessions.attach(persisted.sessionId, {
1826
+ streamIndex: persisted.streamIndex
1827
+ });
1828
+ const snapshot = await withCapabilityRefresh(
1829
+ this.capability,
1830
+ () => attached.snapshot({ signal })
1831
+ );
1832
+ const rewindStreamIndex = streamIndexBeforeLastTurn({
1833
+ currentStreamIndex: snapshot.session.streamIndex,
1834
+ events: snapshot.events
1835
+ });
1836
+ if (rewindStreamIndex === null) return false;
1837
+ this.session = client.sessions.attach(persisted.sessionId, {
1838
+ streamIndex: rewindStreamIndex
1839
+ });
1840
+ savePersistedAgentSession(
1841
+ this.visitorSessionId,
1842
+ persisted.sessionId,
1843
+ rewindStreamIndex,
1844
+ this.storeOptions
1845
+ );
1846
+ return true;
1847
+ }
1848
+ async regenerateTurn(message, signal, handlers) {
1849
+ await this.rewindBeforeLastTurn(signal);
1850
+ return this.sendTurn(message, signal, handlers);
1851
+ }
1804
1852
  ensureClient() {
1805
1853
  const config = resolveAgentRuntimeConfig({
1806
1854
  indexId: this.indexId,
@@ -2136,6 +2184,11 @@ function createAgentClient(options) {
2136
2184
  respondOptions.signal ?? new AbortController().signal,
2137
2185
  respondOptions.handlers
2138
2186
  ),
2187
+ regenerateTurn: (message, regenerateOptions) => session.regenerateTurn(
2188
+ message,
2189
+ regenerateOptions.signal ?? new AbortController().signal,
2190
+ regenerateOptions.handlers
2191
+ ),
2139
2192
  reset: () => session.reset(),
2140
2193
  cancelActive: () => session.cancelActive(),
2141
2194
  getActiveSessionId: () => session.getActiveSessionId()
@@ -2736,6 +2789,7 @@ function useAgentChat({
2736
2789
  const {
2737
2790
  controller,
2738
2791
  initialText = "",
2792
+ regenerate: regenerate2 = false,
2739
2793
  responses,
2740
2794
  resume,
2741
2795
  visitorText
@@ -2847,6 +2901,9 @@ function useAgentChat({
2847
2901
  initialText,
2848
2902
  message: visitorText,
2849
2903
  signal
2904
+ }) : regenerate2 ? await clientRef.current.regenerateTurn(visitorText, {
2905
+ handlers,
2906
+ signal
2850
2907
  }) : await clientRef.current.sendTurn(visitorText, {
2851
2908
  handlers,
2852
2909
  signal
@@ -3063,6 +3120,49 @@ ${outgoing}` : outgoing;
3063
3120
  visitorText: visitorTurnText(visitorMessage)
3064
3121
  });
3065
3122
  }, [runTurn, state.messages]);
3123
+ const regenerate = useCallback(async () => {
3124
+ let lastVisitorIndex = -1;
3125
+ for (let index = state.messages.length - 1; index >= 0; index -= 1) {
3126
+ if (state.messages[index]?.role === "visitor") {
3127
+ lastVisitorIndex = index;
3128
+ break;
3129
+ }
3130
+ }
3131
+ const visitorMessage = lastVisitorIndex >= 0 ? state.messages[lastVisitorIndex] : void 0;
3132
+ if (!visitorMessage) return null;
3133
+ if (runRef.current) {
3134
+ runRef.current.abort();
3135
+ clientRef.current.cancelActive();
3136
+ }
3137
+ const controller = new AbortController();
3138
+ runRef.current = controller;
3139
+ setState((prev) => ({
3140
+ ...prev,
3141
+ phase: "thinking",
3142
+ messages: prev.messages.slice(0, lastVisitorIndex + 1),
3143
+ toolSteps: [
3144
+ {
3145
+ id: "planning",
3146
+ kind: "planning",
3147
+ label: "Understanding your question",
3148
+ state: "active"
3149
+ }
3150
+ ],
3151
+ journey: null,
3152
+ followUps: [],
3153
+ streamingText: "",
3154
+ pendingOffer: null,
3155
+ pendingInputs: [],
3156
+ toolResults: [],
3157
+ error: null
3158
+ }));
3159
+ return await runTurn({
3160
+ controller,
3161
+ regenerate: true,
3162
+ resume: false,
3163
+ visitorText: visitorTurnText(visitorMessage)
3164
+ });
3165
+ }, [runTurn, state.messages]);
3066
3166
  const respondToToolInput = useCallback(
3067
3167
  async (surface, values) => {
3068
3168
  await submit(`${surface.title} submitted`, {
@@ -3139,6 +3239,7 @@ ${outgoing}` : outgoing;
3139
3239
  state,
3140
3240
  reset,
3141
3241
  retry,
3242
+ regenerate,
3142
3243
  respondToInput,
3143
3244
  respondToToolInput,
3144
3245
  submit,
@@ -3244,8 +3345,505 @@ var defaultDarkAgentRailTheme = {
3244
3345
  danger: "#ff8da1"
3245
3346
  };
3246
3347
 
3348
+ // src/react/components/MessageActions/MessageActions.tsx
3349
+ import { useEffect as useEffect2, useLayoutEffect, useRef as useRef2, useState as useState2 } from "react";
3350
+ import { createPortal } from "react-dom";
3351
+
3352
+ // src/react/lib/speech.ts
3353
+ function toSpeechText(text) {
3354
+ let out = hideToolCardFences(text);
3355
+ out = out.replace(/```[\s\S]*?```/g, " ");
3356
+ out = out.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
3357
+ out = out.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1");
3358
+ out = out.replace(/^\s{0,3}#{1,6}\s+/gm, "");
3359
+ out = out.replace(/(\*\*|__)(.*?)\1/g, "$2");
3360
+ out = out.replace(/(\*|_)(.*?)\1/g, "$2");
3361
+ out = out.replace(/~~(.*?)~~/g, "$1");
3362
+ out = out.replace(/`([^`]*)`/g, "$1");
3363
+ out = out.replace(/^\s*>\s?/gm, "");
3364
+ out = out.replace(/^\s*[-*+]\s+/gm, "");
3365
+ out = out.replace(/^\s*\d+\.\s+/gm, "");
3366
+ out = out.replace(/\|/g, " ");
3367
+ out = out.replace(/^\s*[-:]{3,}\s*$/gm, " ");
3368
+ out = out.replace(/\s*\n\s*/g, ". ");
3369
+ out = out.replace(/(?:\.\s*){2,}/g, ". ");
3370
+ return out.replace(/\s{2,}/g, " ").trim();
3371
+ }
3372
+ function isSpeechSupported() {
3373
+ return typeof window !== "undefined" && "speechSynthesis" in window && typeof window.SpeechSynthesisUtterance === "function";
3374
+ }
3375
+
3376
+ // src/react/components/AgentRail/AgentRailOverlayContext.tsx
3377
+ import { createContext, useContext } from "react";
3378
+ var AgentRailOverlayContext = createContext(null);
3379
+ function useAgentRailPortalRoots() {
3380
+ return useContext(AgentRailOverlayContext);
3381
+ }
3382
+ function useAgentRailMenuPortalRoot() {
3383
+ return useContext(AgentRailOverlayContext)?.railRef ?? null;
3384
+ }
3385
+
3386
+ // src/react/components/MessageActions/MessageActions.tsx
3387
+ import { jsx, jsxs } from "react/jsx-runtime";
3388
+ function CopyIcon() {
3389
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3390
+ /* @__PURE__ */ jsx(
3391
+ "rect",
3392
+ {
3393
+ x: "5.75",
3394
+ y: "5.75",
3395
+ width: "7.5",
3396
+ height: "7.5",
3397
+ rx: "1.5",
3398
+ stroke: "currentColor",
3399
+ strokeWidth: "1.5"
3400
+ }
3401
+ ),
3402
+ /* @__PURE__ */ jsx(
3403
+ "path",
3404
+ {
3405
+ d: "M10.25 5.25V4.5a1.75 1.75 0 0 0-1.75-1.75h-4A1.75 1.75 0 0 0 2.75 4.5v4c0 .97.78 1.75 1.75 1.75h.75",
3406
+ stroke: "currentColor",
3407
+ strokeWidth: "1.5"
3408
+ }
3409
+ )
3410
+ ] });
3411
+ }
3412
+ function CheckIcon() {
3413
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
3414
+ "path",
3415
+ {
3416
+ d: "M3.5 8.5l3 3 6-7",
3417
+ stroke: "currentColor",
3418
+ strokeWidth: "1.6",
3419
+ strokeLinecap: "round",
3420
+ strokeLinejoin: "round"
3421
+ }
3422
+ ) });
3423
+ }
3424
+ function ThumbUpIcon() {
3425
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3426
+ /* @__PURE__ */ jsx(
3427
+ "path",
3428
+ {
3429
+ d: "M4.67 6.67v8",
3430
+ stroke: "currentColor",
3431
+ strokeWidth: "1.5",
3432
+ strokeLinecap: "round"
3433
+ }
3434
+ ),
3435
+ /* @__PURE__ */ jsx(
3436
+ "path",
3437
+ {
3438
+ d: "M10 3.92 9.33 6.67h3.89a1.33 1.33 0 0 1 1.28 1.7l-1.55 5.33a1.33 1.33 0 0 1-1.28.97H2.67a1.33 1.33 0 0 1-1.34-1.34V8a1.33 1.33 0 0 1 1.34-1.33h1.84a1.33 1.33 0 0 0 1.19-.74L8 1.33a2.09 2.09 0 0 1 2 2.59Z",
3439
+ stroke: "currentColor",
3440
+ strokeWidth: "1.5",
3441
+ strokeLinecap: "round",
3442
+ strokeLinejoin: "round"
3443
+ }
3444
+ )
3445
+ ] });
3446
+ }
3447
+ function ThumbDownIcon() {
3448
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsxs("g", { transform: "rotate(180 8 8)", children: [
3449
+ /* @__PURE__ */ jsx(
3450
+ "path",
3451
+ {
3452
+ d: "M4.67 6.67v8",
3453
+ stroke: "currentColor",
3454
+ strokeWidth: "1.5",
3455
+ strokeLinecap: "round"
3456
+ }
3457
+ ),
3458
+ /* @__PURE__ */ jsx(
3459
+ "path",
3460
+ {
3461
+ d: "M10 3.92 9.33 6.67h3.89a1.33 1.33 0 0 1 1.28 1.7l-1.55 5.33a1.33 1.33 0 0 1-1.28.97H2.67a1.33 1.33 0 0 1-1.34-1.34V8a1.33 1.33 0 0 1 1.34-1.33h1.84a1.33 1.33 0 0 0 1.19-.74L8 1.33a2.09 2.09 0 0 1 2 2.59Z",
3462
+ stroke: "currentColor",
3463
+ strokeWidth: "1.5",
3464
+ strokeLinecap: "round",
3465
+ strokeLinejoin: "round"
3466
+ }
3467
+ )
3468
+ ] }) });
3469
+ }
3470
+ function RegenerateIcon() {
3471
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3472
+ /* @__PURE__ */ jsx(
3473
+ "path",
3474
+ {
3475
+ d: "M2 8a6 6 0 0 1 6-6 6.5 6.5 0 0 1 4.5 1.83L14 5.33",
3476
+ stroke: "currentColor",
3477
+ strokeWidth: "1.5",
3478
+ strokeLinecap: "round"
3479
+ }
3480
+ ),
3481
+ /* @__PURE__ */ jsx(
3482
+ "path",
3483
+ {
3484
+ d: "M14 2v3.33h-3.33",
3485
+ stroke: "currentColor",
3486
+ strokeWidth: "1.5",
3487
+ strokeLinecap: "round",
3488
+ strokeLinejoin: "round"
3489
+ }
3490
+ ),
3491
+ /* @__PURE__ */ jsx(
3492
+ "path",
3493
+ {
3494
+ d: "M14 8a6 6 0 0 1-6 6 6.5 6.5 0 0 1-4.5-1.83L2 10.67",
3495
+ stroke: "currentColor",
3496
+ strokeWidth: "1.5",
3497
+ strokeLinecap: "round"
3498
+ }
3499
+ ),
3500
+ /* @__PURE__ */ jsx(
3501
+ "path",
3502
+ {
3503
+ d: "M5.33 10.67H2V14",
3504
+ stroke: "currentColor",
3505
+ strokeWidth: "1.5",
3506
+ strokeLinecap: "round",
3507
+ strokeLinejoin: "round"
3508
+ }
3509
+ )
3510
+ ] });
3511
+ }
3512
+ function MoreIcon() {
3513
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3514
+ /* @__PURE__ */ jsx("circle", { cx: "3.5", cy: "8", r: "1.15", fill: "currentColor" }),
3515
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "1.15", fill: "currentColor" }),
3516
+ /* @__PURE__ */ jsx("circle", { cx: "12.5", cy: "8", r: "1.15", fill: "currentColor" })
3517
+ ] });
3518
+ }
3519
+ function SourcesIcon() {
3520
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3521
+ /* @__PURE__ */ jsx(
3522
+ "path",
3523
+ {
3524
+ d: "M8 4.5C6.9 3.4 5.3 3 3.5 3c-.4 0-.8 0-1.2.1-.3 0-.5.3-.5.6v8.1c0 .4.4.7.8.6.3-.1.7-.1 1.1-.1 1.6 0 3.2.4 4.3 1.3 1.1-.9 2.7-1.3 4.3-1.3.4 0 .8 0 1.1.1.4.1.8-.2.8-.6V3.7c0-.3-.2-.6-.5-.6-.4-.1-.8-.1-1.2-.1-1.8 0-3.4.4-4.5 1.5Z",
3525
+ stroke: "currentColor",
3526
+ strokeWidth: "1.4",
3527
+ strokeLinecap: "round",
3528
+ strokeLinejoin: "round"
3529
+ }
3530
+ ),
3531
+ /* @__PURE__ */ jsx(
3532
+ "path",
3533
+ {
3534
+ d: "M8 4.5v9",
3535
+ stroke: "currentColor",
3536
+ strokeWidth: "1.4",
3537
+ strokeLinecap: "round"
3538
+ }
3539
+ )
3540
+ ] });
3541
+ }
3542
+ function ReadAloudIcon() {
3543
+ return /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
3544
+ /* @__PURE__ */ jsx(
3545
+ "path",
3546
+ {
3547
+ d: "M8.5 3.8 5.8 6H3.5c-.6 0-1 .4-1 1v2c0 .6.4 1 1 1h2.3l2.7 2.2c.4.3 1 0 1-.5V4.3c0-.5-.6-.8-1-.5Z",
3548
+ stroke: "currentColor",
3549
+ strokeWidth: "1.4",
3550
+ strokeLinecap: "round",
3551
+ strokeLinejoin: "round"
3552
+ }
3553
+ ),
3554
+ /* @__PURE__ */ jsx(
3555
+ "path",
3556
+ {
3557
+ d: "M11 6.2c.5.5.8 1.1.8 1.8s-.3 1.3-.8 1.8M12.8 4.5c.9.8 1.4 2 1.4 3.5s-.5 2.7-1.4 3.5",
3558
+ stroke: "currentColor",
3559
+ strokeWidth: "1.4",
3560
+ strokeLinecap: "round"
3561
+ }
3562
+ )
3563
+ ] });
3564
+ }
3565
+ function StopIcon() {
3566
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
3567
+ "rect",
3568
+ {
3569
+ x: "4",
3570
+ y: "4",
3571
+ width: "8",
3572
+ height: "8",
3573
+ rx: "1.5",
3574
+ stroke: "currentColor",
3575
+ strokeWidth: "1.5"
3576
+ }
3577
+ ) });
3578
+ }
3579
+ async function writeToClipboard(text) {
3580
+ try {
3581
+ await navigator.clipboard.writeText(text);
3582
+ } catch {
3583
+ const textarea = document.createElement("textarea");
3584
+ textarea.value = text;
3585
+ textarea.style.position = "fixed";
3586
+ textarea.style.opacity = "0";
3587
+ document.body.appendChild(textarea);
3588
+ textarea.select();
3589
+ document.execCommand("copy");
3590
+ textarea.remove();
3591
+ }
3592
+ }
3593
+ function formatAnsweredAt(answeredAt) {
3594
+ if (!answeredAt) return null;
3595
+ const date = new Date(answeredAt);
3596
+ if (Number.isNaN(date.getTime())) return null;
3597
+ return new Intl.DateTimeFormat(void 0, {
3598
+ dateStyle: "medium",
3599
+ timeStyle: "short"
3600
+ }).format(date);
3601
+ }
3602
+ function resolveMenuPosition(input) {
3603
+ const padding = 8;
3604
+ const { button, menuHeight, menuWidth, rail } = input;
3605
+ if (!rail) {
3606
+ return {
3607
+ left: button.left,
3608
+ top: button.top - menuHeight - 6
3609
+ };
3610
+ }
3611
+ let left = button.left - rail.left;
3612
+ let top = button.top - rail.top - menuHeight - 6;
3613
+ left = Math.min(
3614
+ Math.max(left, padding),
3615
+ rail.width - menuWidth - padding
3616
+ );
3617
+ if (top < padding) {
3618
+ top = button.bottom - rail.top + 6;
3619
+ }
3620
+ top = Math.min(top, rail.height - menuHeight - padding);
3621
+ return { left, top };
3622
+ }
3623
+ function MessageActions({
3624
+ answeredAt,
3625
+ copyText,
3626
+ disabled = false,
3627
+ onOpenReceipt,
3628
+ onRegenerate,
3629
+ onFeedback,
3630
+ readAloud = false,
3631
+ receiptSteps,
3632
+ speechText
3633
+ }) {
3634
+ const menuPortalRoot = useAgentRailMenuPortalRoot();
3635
+ const [copied, setCopied] = useState2(false);
3636
+ const [rating, setRating] = useState2(null);
3637
+ const [menuOpen, setMenuOpen] = useState2(false);
3638
+ const [menuPosition, setMenuPosition] = useState2(null);
3639
+ const [speaking, setSpeaking] = useState2(false);
3640
+ const copyTimerRef = useRef2(null);
3641
+ const menuRef = useRef2(null);
3642
+ const portaledMenuRef = useRef2(null);
3643
+ const moreButtonRef = useRef2(null);
3644
+ const answeredLabel = formatAnsweredAt(answeredAt ?? 0);
3645
+ const resolvedSpeechText = speechText ?? toSpeechText(copyText);
3646
+ const canReadAloud = readAloud && isSpeechSupported() && resolvedSpeechText;
3647
+ const showMenu = Boolean(answeredLabel) || Boolean(receiptSteps) || canReadAloud;
3648
+ const canOpenReceipt = Boolean(receiptSteps) && Boolean(onOpenReceipt);
3649
+ useLayoutEffect(() => {
3650
+ if (!menuOpen || !moreButtonRef.current || !portaledMenuRef.current) {
3651
+ setMenuPosition(null);
3652
+ return;
3653
+ }
3654
+ const button = moreButtonRef.current.getBoundingClientRect();
3655
+ const menu2 = portaledMenuRef.current;
3656
+ const rail = menuPortalRoot?.current?.getBoundingClientRect() ?? null;
3657
+ setMenuPosition(
3658
+ resolveMenuPosition({
3659
+ button,
3660
+ menuHeight: menu2.offsetHeight,
3661
+ menuWidth: menu2.offsetWidth || 190,
3662
+ rail
3663
+ })
3664
+ );
3665
+ }, [menuOpen, menuPortalRoot]);
3666
+ useEffect2(
3667
+ () => () => {
3668
+ if (copyTimerRef.current !== null) {
3669
+ window.clearTimeout(copyTimerRef.current);
3670
+ }
3671
+ if (speaking) window.speechSynthesis.cancel();
3672
+ },
3673
+ // Cancel speech only when this answer's actions unmount.
3674
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3675
+ []
3676
+ );
3677
+ useEffect2(() => {
3678
+ if (!menuOpen) return;
3679
+ const handlePointerDown = (event) => {
3680
+ const target = event.target;
3681
+ if (!menuRef.current?.contains(target) && !portaledMenuRef.current?.contains(target)) {
3682
+ setMenuOpen(false);
3683
+ }
3684
+ };
3685
+ const handleKeyDown = (event) => {
3686
+ if (event.key !== "Escape") return;
3687
+ event.preventDefault();
3688
+ event.stopPropagation();
3689
+ setMenuOpen(false);
3690
+ };
3691
+ document.addEventListener("pointerdown", handlePointerDown);
3692
+ document.addEventListener("keydown", handleKeyDown);
3693
+ return () => {
3694
+ document.removeEventListener("pointerdown", handlePointerDown);
3695
+ document.removeEventListener("keydown", handleKeyDown);
3696
+ };
3697
+ }, [menuOpen]);
3698
+ function handleCopy() {
3699
+ void writeToClipboard(copyText);
3700
+ setCopied(true);
3701
+ if (copyTimerRef.current !== null) {
3702
+ window.clearTimeout(copyTimerRef.current);
3703
+ }
3704
+ copyTimerRef.current = window.setTimeout(() => setCopied(false), 1600);
3705
+ }
3706
+ function handleFeedback(next) {
3707
+ const resolved = rating === next ? null : next;
3708
+ setRating(resolved);
3709
+ if (resolved) onFeedback?.(resolved);
3710
+ }
3711
+ function handleReadAloud() {
3712
+ if (!canReadAloud) return;
3713
+ setMenuOpen(false);
3714
+ if (speaking) {
3715
+ window.speechSynthesis.cancel();
3716
+ setSpeaking(false);
3717
+ return;
3718
+ }
3719
+ const utterance = new SpeechSynthesisUtterance(resolvedSpeechText);
3720
+ utterance.onend = () => setSpeaking(false);
3721
+ utterance.onerror = () => setSpeaking(false);
3722
+ window.speechSynthesis.cancel();
3723
+ window.speechSynthesis.speak(utterance);
3724
+ setSpeaking(true);
3725
+ }
3726
+ const menu = menuOpen ? /* @__PURE__ */ jsxs(
3727
+ "div",
3728
+ {
3729
+ className: "agent-message-actions__menu agent-message-actions__menu--portal",
3730
+ ref: portaledMenuRef,
3731
+ role: "menu",
3732
+ style: menuPosition ? {
3733
+ left: `${menuPosition.left}px`,
3734
+ top: `${menuPosition.top}px`
3735
+ } : { visibility: "hidden" },
3736
+ children: [
3737
+ answeredLabel ? /* @__PURE__ */ jsxs("p", { className: "agent-message-actions__menu-meta", children: [
3738
+ "Answered ",
3739
+ answeredLabel
3740
+ ] }) : null,
3741
+ canOpenReceipt ? /* @__PURE__ */ jsxs(
3742
+ "button",
3743
+ {
3744
+ type: "button",
3745
+ className: "agent-message-actions__menu-item",
3746
+ role: "menuitem",
3747
+ onClick: () => {
3748
+ setMenuOpen(false);
3749
+ onOpenReceipt?.();
3750
+ },
3751
+ children: [
3752
+ /* @__PURE__ */ jsx(SourcesIcon, {}),
3753
+ "View sources"
3754
+ ]
3755
+ }
3756
+ ) : null,
3757
+ canReadAloud ? /* @__PURE__ */ jsxs(
3758
+ "button",
3759
+ {
3760
+ type: "button",
3761
+ className: "agent-message-actions__menu-item",
3762
+ role: "menuitem",
3763
+ onClick: handleReadAloud,
3764
+ children: [
3765
+ speaking ? /* @__PURE__ */ jsx(StopIcon, {}) : /* @__PURE__ */ jsx(ReadAloudIcon, {}),
3766
+ speaking ? "Stop reading" : "Read aloud"
3767
+ ]
3768
+ }
3769
+ ) : null
3770
+ ]
3771
+ }
3772
+ ) : null;
3773
+ return /* @__PURE__ */ jsxs("div", { className: "agent-message-actions", "aria-label": "Answer actions", children: [
3774
+ /* @__PURE__ */ jsx(
3775
+ "button",
3776
+ {
3777
+ type: "button",
3778
+ className: `agent-message-actions__button${copied ? " is-copied" : ""}`,
3779
+ "aria-label": copied ? "Copied" : "Copy answer",
3780
+ title: copied ? "Copied" : "Copy answer",
3781
+ disabled,
3782
+ onClick: handleCopy,
3783
+ children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
3784
+ }
3785
+ ),
3786
+ /* @__PURE__ */ jsx(
3787
+ "button",
3788
+ {
3789
+ type: "button",
3790
+ className: `agent-message-actions__button${rating === "positive" ? " is-active" : ""}`,
3791
+ "aria-label": "Good answer",
3792
+ "aria-pressed": rating === "positive",
3793
+ title: "Good answer",
3794
+ disabled,
3795
+ onClick: () => handleFeedback("positive"),
3796
+ children: /* @__PURE__ */ jsx(ThumbUpIcon, {})
3797
+ }
3798
+ ),
3799
+ /* @__PURE__ */ jsx(
3800
+ "button",
3801
+ {
3802
+ type: "button",
3803
+ className: `agent-message-actions__button${rating === "negative" ? " is-active" : ""}`,
3804
+ "aria-label": "Bad answer",
3805
+ "aria-pressed": rating === "negative",
3806
+ title: "Bad answer",
3807
+ disabled,
3808
+ onClick: () => handleFeedback("negative"),
3809
+ children: /* @__PURE__ */ jsx(ThumbDownIcon, {})
3810
+ }
3811
+ ),
3812
+ onRegenerate ? /* @__PURE__ */ jsx(
3813
+ "button",
3814
+ {
3815
+ type: "button",
3816
+ className: "agent-message-actions__button",
3817
+ "aria-label": "Regenerate answer",
3818
+ title: "Regenerate answer",
3819
+ disabled,
3820
+ onClick: onRegenerate,
3821
+ children: /* @__PURE__ */ jsx(RegenerateIcon, {})
3822
+ }
3823
+ ) : null,
3824
+ showMenu ? /* @__PURE__ */ jsxs("div", { className: "agent-message-actions__more", ref: menuRef, children: [
3825
+ /* @__PURE__ */ jsx(
3826
+ "button",
3827
+ {
3828
+ ref: moreButtonRef,
3829
+ type: "button",
3830
+ className: `agent-message-actions__button${menuOpen ? " is-menu-open" : ""}`,
3831
+ "aria-label": "More actions",
3832
+ "aria-haspopup": "menu",
3833
+ "aria-expanded": menuOpen,
3834
+ title: "More actions",
3835
+ disabled,
3836
+ onClick: () => setMenuOpen((open) => !open),
3837
+ children: /* @__PURE__ */ jsx(MoreIcon, {})
3838
+ }
3839
+ ),
3840
+ menuPortalRoot?.current && menu ? createPortal(menu, menuPortalRoot.current) : menu
3841
+ ] }) : null
3842
+ ] });
3843
+ }
3844
+
3247
3845
  // src/react/components/AgentRail/AgentRail.tsx
3248
- import { useEffect as useEffect4, useRef as useRef4, useState as useState8 } from "react";
3846
+ import { useEffect as useEffect6, useRef as useRef6, useState as useState9 } from "react";
3249
3847
 
3250
3848
  // src/react/hooks/useAgentColorScheme.ts
3251
3849
  import { useSyncExternalStore } from "react";
@@ -3278,8 +3876,8 @@ function resolveAgentColorScheme(colorScheme = "auto", prefersDarkMode) {
3278
3876
  }
3279
3877
 
3280
3878
  // src/react/components/AgentActivityBubble/AgentActivityBubble.tsx
3281
- import { useState as useState2 } from "react";
3282
- import { jsx, jsxs } from "react/jsx-runtime";
3879
+ import { useState as useState3 } from "react";
3880
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
3283
3881
  function joinLabels(labels) {
3284
3882
  if (labels.length <= 1) return labels[0] ?? "";
3285
3883
  if (labels.length === 2) return `${labels[0]} and ${labels[1]}`;
@@ -3329,6 +3927,60 @@ function stepDetail(step, steps) {
3329
3927
  return "Searched this site";
3330
3928
  return step.detail;
3331
3929
  }
3930
+ function AgentWorkSteps({
3931
+ brandLabel = "",
3932
+ onRetryStep,
3933
+ steps
3934
+ }) {
3935
+ const delegationCount = steps.filter(
3936
+ (step) => step.kind === "specialist"
3937
+ ).length;
3938
+ const delegated = delegationCount > 0 && steps.some((step) => step.kind === "planning");
3939
+ const visibleSteps = steps.filter(
3940
+ (step) => step.kind !== "planning" || Boolean(brandLabel)
3941
+ );
3942
+ return /* @__PURE__ */ jsx2("ol", { className: "agent-activity-bubble__steps", children: visibleSteps.map((step) => {
3943
+ const detail = stepDetail(step, steps);
3944
+ const child = delegated && step.kind === "specialist";
3945
+ return /* @__PURE__ */ jsxs2(
3946
+ "li",
3947
+ {
3948
+ className: `agent-activity-bubble__step${child ? " agent-activity-bubble__step--child" : ""}`,
3949
+ "data-kind": step.kind,
3950
+ "data-state": step.state,
3951
+ children: [
3952
+ /* @__PURE__ */ jsx2(
3953
+ "span",
3954
+ {
3955
+ className: "agent-activity-bubble__step-icon",
3956
+ "aria-hidden": "true"
3957
+ }
3958
+ ),
3959
+ /* @__PURE__ */ jsxs2("span", { className: "agent-activity-bubble__step-copy", children: [
3960
+ /* @__PURE__ */ jsx2("span", { className: "agent-activity-bubble__step-heading", children: /* @__PURE__ */ jsx2("strong", { children: stepLabel(step, brandLabel) }) }),
3961
+ detail ? /* @__PURE__ */ jsx2("span", { className: "agent-activity-bubble__step-detail", children: detail }) : null,
3962
+ delegated && step.kind === "planning" ? /* @__PURE__ */ jsxs2("span", { className: "agent-activity-bubble__delegation", children: [
3963
+ "Delegated ",
3964
+ delegationCount,
3965
+ " ",
3966
+ delegationCount === 1 ? "task" : "tasks"
3967
+ ] }) : null,
3968
+ step.state === "error" && onRetryStep ? /* @__PURE__ */ jsx2(
3969
+ "button",
3970
+ {
3971
+ type: "button",
3972
+ className: "agent-activity-bubble__step-retry",
3973
+ onClick: () => onRetryStep(step),
3974
+ children: "Retry"
3975
+ }
3976
+ ) : null
3977
+ ] })
3978
+ ]
3979
+ },
3980
+ step.id
3981
+ );
3982
+ }) });
3983
+ }
3332
3984
  function AgentActivityBubble({
3333
3985
  brandLabel = "",
3334
3986
  failed = false,
@@ -3337,37 +3989,30 @@ function AgentActivityBubble({
3337
3989
  }) {
3338
3990
  const active = steps.some((step) => step.state === "active");
3339
3991
  const receiptId = steps.map((step) => step.id).join(":");
3340
- const [expandedReceiptId, setExpandedReceiptId] = useState2(
3992
+ const [expandedReceiptId, setExpandedReceiptId] = useState3(
3341
3993
  null
3342
3994
  );
3343
- const detailsOpen = active || expandedReceiptId === receiptId;
3344
- const delegationCount = steps.filter(
3345
- (step) => step.kind === "specialist"
3346
- ).length;
3347
- const delegated = delegationCount > 0 && steps.some((step) => step.kind === "planning");
3348
- const visibleSteps = steps.filter(
3349
- (step) => step.kind !== "planning" || Boolean(brandLabel)
3350
- );
3351
- return /* @__PURE__ */ jsxs("article", { className: "agent-activity-bubble", children: [
3352
- /* @__PURE__ */ jsxs("p", { className: "agent-activity-bubble__status", "aria-live": "polite", children: [
3353
- /* @__PURE__ */ jsx(
3995
+ const detailsOpen = !active && expandedReceiptId === receiptId;
3996
+ return /* @__PURE__ */ jsxs2("article", { className: "agent-activity-bubble", children: [
3997
+ /* @__PURE__ */ jsxs2("p", { className: "agent-activity-bubble__status", "aria-live": "polite", children: [
3998
+ /* @__PURE__ */ jsx2(
3354
3999
  "span",
3355
4000
  {
3356
4001
  className: `agent-activity-bubble__pulse${active ? " is-active" : failed ? " is-error" : ""}`,
3357
4002
  "aria-hidden": "true"
3358
4003
  }
3359
4004
  ),
3360
- workSummary(steps, failed, brandLabel)
4005
+ workSummary(steps, failed, brandLabel),
4006
+ active ? "\u2026" : ""
3361
4007
  ] }),
3362
- /* @__PURE__ */ jsxs("div", { className: "agent-activity-bubble__details", children: [
3363
- /* @__PURE__ */ jsx(
4008
+ !active ? /* @__PURE__ */ jsxs2("div", { className: "agent-activity-bubble__details", children: [
4009
+ /* @__PURE__ */ jsx2(
3364
4010
  "button",
3365
4011
  {
3366
4012
  type: "button",
3367
4013
  className: "agent-activity-bubble__summary",
3368
4014
  "aria-expanded": detailsOpen,
3369
4015
  onClick: () => {
3370
- if (active) return;
3371
4016
  setExpandedReceiptId(
3372
4017
  (current) => current === receiptId ? null : receiptId
3373
4018
  );
@@ -3375,61 +4020,138 @@ function AgentActivityBubble({
3375
4020
  children: "How this answer was made"
3376
4021
  }
3377
4022
  ),
3378
- detailsOpen ? /* @__PURE__ */ jsx("ol", { className: "agent-activity-bubble__steps", children: visibleSteps.map((step) => {
3379
- const detail = stepDetail(step, steps);
3380
- const child = delegated && step.kind === "specialist";
3381
- return /* @__PURE__ */ jsxs(
3382
- "li",
3383
- {
3384
- className: `agent-activity-bubble__step${child ? " agent-activity-bubble__step--child" : ""}`,
3385
- "data-kind": step.kind,
3386
- "data-state": step.state,
3387
- children: [
3388
- /* @__PURE__ */ jsx(
3389
- "span",
3390
- {
3391
- className: "agent-activity-bubble__step-icon",
3392
- "aria-hidden": "true"
3393
- }
3394
- ),
3395
- /* @__PURE__ */ jsxs("span", { className: "agent-activity-bubble__step-copy", children: [
3396
- /* @__PURE__ */ jsx("span", { className: "agent-activity-bubble__step-heading", children: /* @__PURE__ */ jsx("strong", { children: stepLabel(step, brandLabel) }) }),
3397
- detail ? /* @__PURE__ */ jsx("span", { className: "agent-activity-bubble__step-detail", children: detail }) : null,
3398
- delegated && step.kind === "planning" ? /* @__PURE__ */ jsxs("span", { className: "agent-activity-bubble__delegation", children: [
3399
- "Delegated ",
3400
- delegationCount,
3401
- " ",
3402
- delegationCount === 1 ? "task" : "tasks"
3403
- ] }) : null,
3404
- step.state === "error" && onRetryStep ? /* @__PURE__ */ jsx(
3405
- "button",
3406
- {
3407
- type: "button",
3408
- className: "agent-activity-bubble__step-retry",
3409
- onClick: () => onRetryStep(step),
3410
- children: "Retry"
3411
- }
3412
- ) : null
3413
- ] })
3414
- ]
3415
- },
3416
- step.id
3417
- );
3418
- }) }) : null
3419
- ] })
4023
+ detailsOpen ? /* @__PURE__ */ jsx2(
4024
+ AgentWorkSteps,
4025
+ {
4026
+ brandLabel,
4027
+ onRetryStep,
4028
+ steps
4029
+ }
4030
+ ) : null
4031
+ ] }) : null
4032
+ ] });
4033
+ }
4034
+
4035
+ // src/react/components/AnswerReceiptDialog/AnswerReceiptDialog.tsx
4036
+ import { useEffect as useEffect3, useRef as useRef3 } from "react";
4037
+ import { createPortal as createPortal2 } from "react-dom";
4038
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
4039
+ var FOCUSABLE_SELECTOR = 'button:not(:disabled), a[href], textarea:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])';
4040
+ function CloseIcon() {
4041
+ return /* @__PURE__ */ jsx3("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
4042
+ "path",
4043
+ {
4044
+ d: "M4 4l8 8M12 4l-8 8",
4045
+ stroke: "currentColor",
4046
+ strokeWidth: "1.5",
4047
+ strokeLinecap: "round"
4048
+ }
4049
+ ) });
4050
+ }
4051
+ function AnswerReceiptDialog({
4052
+ brandLabel = "",
4053
+ onClose,
4054
+ steps
4055
+ }) {
4056
+ const portalRoots = useAgentRailPortalRoots();
4057
+ const overlayRoot = portalRoots?.overlayRef ?? null;
4058
+ const cardRef = useRef3(null);
4059
+ const closeButtonRef = useRef3(null);
4060
+ const previouslyFocusedRef = useRef3(null);
4061
+ useEffect3(() => {
4062
+ previouslyFocusedRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
4063
+ closeButtonRef.current?.focus({ preventScroll: true });
4064
+ const handleKeyDown = (event) => {
4065
+ if (event.key === "Escape") {
4066
+ event.preventDefault();
4067
+ event.stopPropagation();
4068
+ onClose();
4069
+ return;
4070
+ }
4071
+ if (event.key !== "Tab" || !cardRef.current) return;
4072
+ const focusable = cardRef.current.querySelectorAll(
4073
+ FOCUSABLE_SELECTOR
4074
+ );
4075
+ if (focusable.length === 0) return;
4076
+ const first = focusable.item(0);
4077
+ const last = focusable.item(focusable.length - 1);
4078
+ if (event.shiftKey && document.activeElement === first) {
4079
+ event.preventDefault();
4080
+ last.focus({ preventScroll: true });
4081
+ } else if (!event.shiftKey && document.activeElement === last) {
4082
+ event.preventDefault();
4083
+ first.focus({ preventScroll: true });
4084
+ }
4085
+ };
4086
+ document.addEventListener("keydown", handleKeyDown);
4087
+ return () => {
4088
+ document.removeEventListener("keydown", handleKeyDown);
4089
+ previouslyFocusedRef.current?.focus({ preventScroll: true });
4090
+ };
4091
+ }, [onClose]);
4092
+ const content = /* @__PURE__ */ jsxs3("div", { className: "agent-receipt-dialog", children: [
4093
+ /* @__PURE__ */ jsx3(
4094
+ "button",
4095
+ {
4096
+ type: "button",
4097
+ className: "agent-receipt-dialog__backdrop",
4098
+ "aria-label": "Close",
4099
+ tabIndex: -1,
4100
+ onClick: onClose
4101
+ }
4102
+ ),
4103
+ /* @__PURE__ */ jsxs3(
4104
+ "div",
4105
+ {
4106
+ ref: cardRef,
4107
+ className: "agent-receipt-dialog__card",
4108
+ role: "dialog",
4109
+ "aria-modal": "true",
4110
+ "aria-labelledby": "agent-receipt-dialog-title",
4111
+ children: [
4112
+ /* @__PURE__ */ jsxs3("div", { className: "agent-receipt-dialog__header", children: [
4113
+ /* @__PURE__ */ jsx3(
4114
+ "p",
4115
+ {
4116
+ className: "agent-receipt-dialog__title",
4117
+ id: "agent-receipt-dialog-title",
4118
+ children: "How this answer was made"
4119
+ }
4120
+ ),
4121
+ /* @__PURE__ */ jsx3(
4122
+ "button",
4123
+ {
4124
+ ref: closeButtonRef,
4125
+ type: "button",
4126
+ className: "agent-receipt-dialog__close",
4127
+ "aria-label": "Close",
4128
+ onClick: onClose,
4129
+ children: /* @__PURE__ */ jsx3(CloseIcon, {})
4130
+ }
4131
+ )
4132
+ ] }),
4133
+ /* @__PURE__ */ jsx3("p", { className: "agent-receipt-dialog__summary", children: workSummary(steps, false, brandLabel) }),
4134
+ /* @__PURE__ */ jsx3("div", { className: "agent-receipt-dialog__body", children: /* @__PURE__ */ jsx3(AgentWorkSteps, { brandLabel, steps }) })
4135
+ ]
4136
+ }
4137
+ )
3420
4138
  ] });
4139
+ if (overlayRoot?.current) {
4140
+ return createPortal2(content, overlayRoot.current);
4141
+ }
4142
+ return content;
3421
4143
  }
3422
4144
 
3423
4145
  // src/react/components/Composer/Composer.tsx
3424
4146
  import {
3425
- useEffect as useEffect2,
4147
+ useEffect as useEffect4,
3426
4148
  useId,
3427
- useRef as useRef2,
3428
- useState as useState3
4149
+ useRef as useRef4,
4150
+ useState as useState4
3429
4151
  } from "react";
3430
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
4152
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
3431
4153
  function SendIcon() {
3432
- return /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(
4154
+ return /* @__PURE__ */ jsx4("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx4(
3433
4155
  "path",
3434
4156
  {
3435
4157
  d: "M8 12V4M8 4l-3 3M8 4l3 3",
@@ -3452,21 +4174,21 @@ function Composer({
3452
4174
  form = null,
3453
4175
  onSubmit
3454
4176
  }) {
3455
- const [value, setValue] = useState3("");
3456
- const [values, setValues] = useState3(
4177
+ const [value, setValue] = useState4("");
4178
+ const [values, setValues] = useState4(
3457
4179
  () => emptyValues(form)
3458
4180
  );
3459
- const [blurred, setBlurred] = useState3({});
3460
- const inputRef = useRef2(null);
3461
- const firstFieldRef = useRef2(null);
4181
+ const [blurred, setBlurred] = useState4({});
4182
+ const inputRef = useRef4(null);
4183
+ const firstFieldRef = useRef4(null);
3462
4184
  const formId = useId();
3463
4185
  const activeForm = form;
3464
4186
  const canSendForm = activeForm ? isComposerFormComplete(activeForm, values) : Boolean(value.trim());
3465
- useEffect2(() => {
4187
+ useEffect4(() => {
3466
4188
  setValues(emptyValues(form));
3467
4189
  setBlurred({});
3468
4190
  }, [form?.id]);
3469
- useEffect2(() => {
4191
+ useEffect4(() => {
3470
4192
  if (activeForm) firstFieldRef.current?.focus();
3471
4193
  }, [activeForm?.id]);
3472
4194
  function submitChat() {
@@ -3501,7 +4223,7 @@ function Composer({
3501
4223
  submitForm();
3502
4224
  }
3503
4225
  }
3504
- return /* @__PURE__ */ jsx2(
4226
+ return /* @__PURE__ */ jsx4(
3505
4227
  "form",
3506
4228
  {
3507
4229
  className: [
@@ -3510,7 +4232,7 @@ function Composer({
3510
4232
  activeForm ? "composer--form" : ""
3511
4233
  ].filter(Boolean).join(" "),
3512
4234
  onSubmit: handleSubmit,
3513
- children: activeForm ? /* @__PURE__ */ jsxs2("div", { className: "composer__sheet", role: "group", "aria-label": "Required details", children: [
4235
+ children: activeForm ? /* @__PURE__ */ jsxs4("div", { className: "composer__sheet", role: "group", "aria-label": "Required details", children: [
3514
4236
  activeForm.fields.map((field, index) => {
3515
4237
  const fieldId = `${formId}-${field.id}`;
3516
4238
  const invalid = Boolean(blurred[field.id]) && !isValidComposerFieldValue(field, values[field.id] ?? "");
@@ -3535,7 +4257,7 @@ function Composer({
3535
4257
  },
3536
4258
  onKeyDown: handleFormKeyDown
3537
4259
  };
3538
- return /* @__PURE__ */ jsxs2(
4260
+ return /* @__PURE__ */ jsxs4(
3539
4261
  "div",
3540
4262
  {
3541
4263
  className: [
@@ -3543,9 +4265,9 @@ function Composer({
3543
4265
  field.kind === "textarea" ? "composer__row--grow" : ""
3544
4266
  ].filter(Boolean).join(" "),
3545
4267
  children: [
3546
- /* @__PURE__ */ jsxs2("label", { className: "composer__label", htmlFor: fieldId, children: [
3547
- /* @__PURE__ */ jsx2("span", { className: "composer__sr-only", children: field.label }),
3548
- field.kind === "textarea" ? /* @__PURE__ */ jsx2(
4268
+ /* @__PURE__ */ jsxs4("label", { className: "composer__label", htmlFor: fieldId, children: [
4269
+ /* @__PURE__ */ jsx4("span", { className: "composer__sr-only", children: field.label }),
4270
+ field.kind === "textarea" ? /* @__PURE__ */ jsx4(
3549
4271
  "textarea",
3550
4272
  {
3551
4273
  ...controlProps,
@@ -3555,7 +4277,7 @@ function Composer({
3555
4277
  className: "composer__control composer__control--area",
3556
4278
  rows: 3
3557
4279
  }
3558
- ) : /* @__PURE__ */ jsx2(
4280
+ ) : /* @__PURE__ */ jsx4(
3559
4281
  "input",
3560
4282
  {
3561
4283
  ...controlProps,
@@ -3568,24 +4290,24 @@ function Composer({
3568
4290
  }
3569
4291
  )
3570
4292
  ] }),
3571
- invalid ? /* @__PURE__ */ jsx2("p", { className: "composer__error", id: `${fieldId}-error`, children: field.kind === "email" ? "Enter a valid email to continue." : `Add your ${field.label.toLowerCase()} to continue.` }) : null
4293
+ invalid ? /* @__PURE__ */ jsx4("p", { className: "composer__error", id: `${fieldId}-error`, children: field.kind === "email" ? "Enter a valid email to continue." : `Add your ${field.label.toLowerCase()} to continue.` }) : null
3572
4294
  ]
3573
4295
  },
3574
4296
  field.id
3575
4297
  );
3576
4298
  }),
3577
- /* @__PURE__ */ jsx2("div", { className: "composer__toolbar", children: /* @__PURE__ */ jsx2(
4299
+ /* @__PURE__ */ jsx4("div", { className: "composer__toolbar", children: /* @__PURE__ */ jsx4(
3578
4300
  "button",
3579
4301
  {
3580
4302
  type: "submit",
3581
4303
  className: "composer__send",
3582
4304
  disabled: disabled || !canSendForm,
3583
4305
  "aria-label": "Send details",
3584
- children: /* @__PURE__ */ jsx2(SendIcon, {})
4306
+ children: /* @__PURE__ */ jsx4(SendIcon, {})
3585
4307
  }
3586
4308
  ) })
3587
- ] }) : /* @__PURE__ */ jsxs2("div", { className: "composer__field", children: [
3588
- /* @__PURE__ */ jsx2(
4309
+ ] }) : /* @__PURE__ */ jsxs4("div", { className: "composer__field", children: [
4310
+ /* @__PURE__ */ jsx4(
3589
4311
  "textarea",
3590
4312
  {
3591
4313
  ref: inputRef,
@@ -3600,14 +4322,14 @@ function Composer({
3600
4322
  onKeyDown: handleChatKeyDown
3601
4323
  }
3602
4324
  ),
3603
- /* @__PURE__ */ jsx2(
4325
+ /* @__PURE__ */ jsx4(
3604
4326
  "button",
3605
4327
  {
3606
4328
  type: "submit",
3607
4329
  className: "composer__send",
3608
4330
  disabled: disabled || !value.trim(),
3609
4331
  "aria-label": "Send message",
3610
- children: /* @__PURE__ */ jsx2(SendIcon, {})
4332
+ children: /* @__PURE__ */ jsx4(SendIcon, {})
3611
4333
  }
3612
4334
  )
3613
4335
  ] })
@@ -3616,7 +4338,7 @@ function Composer({
3616
4338
  }
3617
4339
 
3618
4340
  // src/react/components/FollowUpChips/FollowUpChips.tsx
3619
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
4341
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
3620
4342
  function FollowUpChips({
3621
4343
  suggestions,
3622
4344
  disabled = false,
@@ -3626,7 +4348,7 @@ function FollowUpChips({
3626
4348
  }) {
3627
4349
  if (suggestions.length === 0) return null;
3628
4350
  if (variant === "dock") {
3629
- return /* @__PURE__ */ jsx3("div", { className: "followups followups--dock", children: /* @__PURE__ */ jsx3("div", { className: "followups__scroll", children: suggestions.map((suggestion) => /* @__PURE__ */ jsx3(
4351
+ return /* @__PURE__ */ jsx5("div", { className: "followups followups--dock", children: /* @__PURE__ */ jsx5("div", { className: "followups__scroll", children: suggestions.map((suggestion) => /* @__PURE__ */ jsx5(
3630
4352
  "button",
3631
4353
  {
3632
4354
  type: "button",
@@ -3638,9 +4360,9 @@ function FollowUpChips({
3638
4360
  suggestion.id
3639
4361
  )) }) });
3640
4362
  }
3641
- return /* @__PURE__ */ jsxs3("div", { className: "followups", children: [
3642
- /* @__PURE__ */ jsx3("span", { className: "followups__label", children: label }),
3643
- /* @__PURE__ */ jsx3("div", { className: "followups__list", children: suggestions.map((suggestion) => /* @__PURE__ */ jsx3(
4363
+ return /* @__PURE__ */ jsxs5("div", { className: "followups", children: [
4364
+ /* @__PURE__ */ jsx5("span", { className: "followups__label", children: label }),
4365
+ /* @__PURE__ */ jsx5("div", { className: "followups__list", children: suggestions.map((suggestion) => /* @__PURE__ */ jsx5(
3644
4366
  "button",
3645
4367
  {
3646
4368
  type: "button",
@@ -3655,17 +4377,17 @@ function FollowUpChips({
3655
4377
  }
3656
4378
 
3657
4379
  // src/react/components/MessageBubble/MessageBubble.tsx
3658
- import { useState as useState5 } from "react";
4380
+ import { useState as useState6 } from "react";
3659
4381
 
3660
4382
  // src/react/components/BookingCard/BookingCard.tsx
3661
4383
  import {
3662
- useEffect as useEffect3,
4384
+ useEffect as useEffect5,
3663
4385
  useId as useId2,
3664
4386
  useMemo as useMemo2,
3665
- useRef as useRef3,
3666
- useState as useState4
4387
+ useRef as useRef5,
4388
+ useState as useState5
3667
4389
  } from "react";
3668
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
4390
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
3669
4391
  var BOOKING_STEPS = [
3670
4392
  { id: "date", label: "Date" },
3671
4393
  { id: "time", label: "Time" },
@@ -3696,7 +4418,7 @@ function calendarCells(year, month) {
3696
4418
  return cells;
3697
4419
  }
3698
4420
  function BookingCardLoader() {
3699
- return /* @__PURE__ */ jsx4("section", { className: "booking-card", "aria-label": "Book a meeting", children: /* @__PURE__ */ jsx4("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) });
4421
+ return /* @__PURE__ */ jsx6("section", { className: "booking-card", "aria-label": "Book a meeting", children: /* @__PURE__ */ jsx6("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) });
3700
4422
  }
3701
4423
  function BookingCard({
3702
4424
  disabled = false,
@@ -3705,16 +4427,16 @@ function BookingCard({
3705
4427
  }) {
3706
4428
  const fieldId = useId2();
3707
4429
  const defaultType = offer.eventTypes[0]?.uri ?? offer.slots[0]?.eventTypeUri ?? "";
3708
- const [step, setStep] = useState4("date");
3709
- const [eventTypeUri, setEventTypeUri] = useState4(defaultType);
3710
- const [selectedDate, setSelectedDate] = useState4("");
3711
- const [startTime, setStartTime] = useState4("");
3712
- const [name, setName] = useState4("");
3713
- const [email, setEmail] = useState4("");
3714
- const activeStepRef = useRef3(null);
3715
- const previousStepRef = useRef3(step);
4430
+ const [step, setStep] = useState5("date");
4431
+ const [eventTypeUri, setEventTypeUri] = useState5(defaultType);
4432
+ const [selectedDate, setSelectedDate] = useState5("");
4433
+ const [startTime, setStartTime] = useState5("");
4434
+ const [name, setName] = useState5("");
4435
+ const [email, setEmail] = useState5("");
4436
+ const activeStepRef = useRef5(null);
4437
+ const previousStepRef = useRef5(step);
3716
4438
  const stepIndex = BOOKING_STEPS.findIndex((item) => item.id === step);
3717
- useEffect3(() => {
4439
+ useEffect5(() => {
3718
4440
  if (previousStepRef.current === step) return;
3719
4441
  previousStepRef.current = step;
3720
4442
  activeStepRef.current?.scrollIntoView({ block: "nearest" });
@@ -3731,7 +4453,7 @@ function BookingCard({
3731
4453
  }
3732
4454
  return next;
3733
4455
  }, [slots]);
3734
- const [visibleMonth, setVisibleMonth] = useState4(
4456
+ const [visibleMonth, setVisibleMonth] = useState5(
3735
4457
  () => firstAvailableBookingMonth(slots)
3736
4458
  );
3737
4459
  function selectEventType(nextType) {
@@ -3795,14 +4517,14 @@ function BookingCard({
3795
4517
  })
3796
4518
  });
3797
4519
  }
3798
- return /* @__PURE__ */ jsx4(
4520
+ return /* @__PURE__ */ jsx6(
3799
4521
  "section",
3800
4522
  {
3801
4523
  className: "booking-card",
3802
4524
  "aria-busy": disabled || void 0,
3803
4525
  "aria-label": "Book a meeting",
3804
- children: /* @__PURE__ */ jsxs4("form", { className: "booking-card__form", onSubmit: handleSubmit, children: [
3805
- /* @__PURE__ */ jsx4("ol", { className: "booking-card__steps", "aria-label": "Booking steps", children: BOOKING_STEPS.map((item, index) => /* @__PURE__ */ jsxs4(
4526
+ children: /* @__PURE__ */ jsxs6("form", { className: "booking-card__form", onSubmit: handleSubmit, children: [
4527
+ /* @__PURE__ */ jsx6("ol", { className: "booking-card__steps", "aria-label": "Booking steps", children: BOOKING_STEPS.map((item, index) => /* @__PURE__ */ jsxs6(
3806
4528
  "li",
3807
4529
  {
3808
4530
  className: [
@@ -3812,40 +4534,40 @@ function BookingCard({
3812
4534
  ].filter(Boolean).join(" "),
3813
4535
  "aria-current": index === stepIndex ? "step" : void 0,
3814
4536
  children: [
3815
- /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: index + 1 }),
3816
- /* @__PURE__ */ jsx4("span", { children: item.label })
4537
+ /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: index + 1 }),
4538
+ /* @__PURE__ */ jsx6("span", { children: item.label })
3817
4539
  ]
3818
4540
  },
3819
4541
  item.id
3820
4542
  )) }),
3821
- step === "date" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3822
- /* @__PURE__ */ jsx4("p", { className: "booking-card__title", children: selectedType?.name || "Pick a date" }),
3823
- timeZone ? /* @__PURE__ */ jsxs4("p", { className: "booking-card__tz", children: [
4543
+ step === "date" ? /* @__PURE__ */ jsxs6("div", { className: "booking-card__step", ref: activeStepRef, children: [
4544
+ /* @__PURE__ */ jsx6("p", { className: "booking-card__title", children: selectedType?.name || "Pick a date" }),
4545
+ timeZone ? /* @__PURE__ */ jsxs6("p", { className: "booking-card__tz", children: [
3824
4546
  "Times in ",
3825
4547
  timeZone
3826
4548
  ] }) : null,
3827
- offer.eventTypes.length > 1 ? /* @__PURE__ */ jsxs4(
4549
+ offer.eventTypes.length > 1 ? /* @__PURE__ */ jsxs6(
3828
4550
  "label",
3829
4551
  {
3830
4552
  className: "booking-card__field",
3831
4553
  htmlFor: `${fieldId}-type`,
3832
4554
  children: [
3833
- /* @__PURE__ */ jsx4("span", { children: "Meeting" }),
3834
- /* @__PURE__ */ jsx4(
4555
+ /* @__PURE__ */ jsx6("span", { children: "Meeting" }),
4556
+ /* @__PURE__ */ jsx6(
3835
4557
  "select",
3836
4558
  {
3837
4559
  id: `${fieldId}-type`,
3838
4560
  value: eventTypeUri,
3839
4561
  disabled,
3840
4562
  onChange: (event) => selectEventType(event.target.value),
3841
- children: offer.eventTypes.map((item) => /* @__PURE__ */ jsx4("option", { value: item.uri, children: item.name }, item.uri))
4563
+ children: offer.eventTypes.map((item) => /* @__PURE__ */ jsx6("option", { value: item.uri, children: item.name }, item.uri))
3842
4564
  }
3843
4565
  )
3844
4566
  ]
3845
4567
  }
3846
4568
  ) : null,
3847
- /* @__PURE__ */ jsxs4("div", { className: "booking-card__month", children: [
3848
- /* @__PURE__ */ jsx4(
4569
+ /* @__PURE__ */ jsxs6("div", { className: "booking-card__month", children: [
4570
+ /* @__PURE__ */ jsx6(
3849
4571
  "button",
3850
4572
  {
3851
4573
  type: "button",
@@ -3856,8 +4578,8 @@ function BookingCard({
3856
4578
  children: "\u2039"
3857
4579
  }
3858
4580
  ),
3859
- /* @__PURE__ */ jsx4("p", { className: "booking-card__month-title", children: formatMonthTitle(visibleMonth.year, visibleMonth.month) }),
3860
- /* @__PURE__ */ jsx4(
4581
+ /* @__PURE__ */ jsx6("p", { className: "booking-card__month-title", children: formatMonthTitle(visibleMonth.year, visibleMonth.month) }),
4582
+ /* @__PURE__ */ jsx6(
3861
4583
  "button",
3862
4584
  {
3863
4585
  type: "button",
@@ -3869,9 +4591,9 @@ function BookingCard({
3869
4591
  }
3870
4592
  )
3871
4593
  ] }),
3872
- /* @__PURE__ */ jsx4("div", { className: "booking-card__weekdays", children: weekdays.map((label) => /* @__PURE__ */ jsx4("span", { children: label }, label)) }),
3873
- offer.slots.length === 0 ? /* @__PURE__ */ jsx4("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) : null,
3874
- /* @__PURE__ */ jsx4(
4594
+ /* @__PURE__ */ jsx6("div", { className: "booking-card__weekdays", children: weekdays.map((label) => /* @__PURE__ */ jsx6("span", { children: label }, label)) }),
4595
+ offer.slots.length === 0 ? /* @__PURE__ */ jsx6("p", { className: "booking-card__loading", role: "status", children: "Finding available times\u2026" }) : null,
4596
+ /* @__PURE__ */ jsx6(
3875
4597
  "div",
3876
4598
  {
3877
4599
  className: "booking-card__calendar",
@@ -3879,7 +4601,7 @@ function BookingCard({
3879
4601
  "aria-label": "Available dates",
3880
4602
  children: cells.map((cell, index) => {
3881
4603
  if (!cell) {
3882
- return /* @__PURE__ */ jsx4(
4604
+ return /* @__PURE__ */ jsx6(
3883
4605
  "span",
3884
4606
  {
3885
4607
  className: "booking-card__day"
@@ -3889,7 +4611,7 @@ function BookingCard({
3889
4611
  }
3890
4612
  const available = availableByDate.has(cell.key);
3891
4613
  const selected = cell.key === selectedDate;
3892
- return /* @__PURE__ */ jsx4(
4614
+ return /* @__PURE__ */ jsx6(
3893
4615
  "button",
3894
4616
  {
3895
4617
  type: "button",
@@ -3909,9 +4631,9 @@ function BookingCard({
3909
4631
  }
3910
4632
  )
3911
4633
  ] }, "date") : null,
3912
- step === "time" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3913
- /* @__PURE__ */ jsxs4("div", { className: "booking-card__step-bar", children: [
3914
- /* @__PURE__ */ jsx4(
4634
+ step === "time" ? /* @__PURE__ */ jsxs6("div", { className: "booking-card__step", ref: activeStepRef, children: [
4635
+ /* @__PURE__ */ jsxs6("div", { className: "booking-card__step-bar", children: [
4636
+ /* @__PURE__ */ jsx6(
3915
4637
  "button",
3916
4638
  {
3917
4639
  type: "button",
@@ -3922,15 +4644,15 @@ function BookingCard({
3922
4644
  children: "\u2039"
3923
4645
  }
3924
4646
  ),
3925
- /* @__PURE__ */ jsxs4("div", { children: [
3926
- /* @__PURE__ */ jsx4("p", { className: "booking-card__title", children: selectedSample ? formatLongDate(selectedSample) : "Pick a time" }),
3927
- timeZone ? /* @__PURE__ */ jsxs4("p", { className: "booking-card__tz", children: [
4647
+ /* @__PURE__ */ jsxs6("div", { children: [
4648
+ /* @__PURE__ */ jsx6("p", { className: "booking-card__title", children: selectedSample ? formatLongDate(selectedSample) : "Pick a time" }),
4649
+ timeZone ? /* @__PURE__ */ jsxs6("p", { className: "booking-card__tz", children: [
3928
4650
  "Times in ",
3929
4651
  timeZone
3930
4652
  ] }) : null
3931
4653
  ] })
3932
4654
  ] }),
3933
- /* @__PURE__ */ jsx4("div", { className: "booking-card__times", children: daySlots.map((slot) => /* @__PURE__ */ jsx4(
4655
+ /* @__PURE__ */ jsx6("div", { className: "booking-card__times", children: daySlots.map((slot) => /* @__PURE__ */ jsx6(
3934
4656
  "button",
3935
4657
  {
3936
4658
  type: "button",
@@ -3942,9 +4664,9 @@ function BookingCard({
3942
4664
  slot.startTime
3943
4665
  )) })
3944
4666
  ] }, "time") : null,
3945
- step === "details" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3946
- /* @__PURE__ */ jsxs4("div", { className: "booking-card__step-bar", children: [
3947
- /* @__PURE__ */ jsx4(
4667
+ step === "details" ? /* @__PURE__ */ jsxs6("div", { className: "booking-card__step", ref: activeStepRef, children: [
4668
+ /* @__PURE__ */ jsxs6("div", { className: "booking-card__step-bar", children: [
4669
+ /* @__PURE__ */ jsx6(
3948
4670
  "button",
3949
4671
  {
3950
4672
  type: "button",
@@ -3955,21 +4677,21 @@ function BookingCard({
3955
4677
  children: "\u2039"
3956
4678
  }
3957
4679
  ),
3958
- /* @__PURE__ */ jsxs4("div", { children: [
3959
- /* @__PURE__ */ jsx4("p", { className: "booking-card__title", children: "Enter details" }),
3960
- /* @__PURE__ */ jsx4("p", { className: "booking-card__tz", children: formatSlotLabel(startTime) }),
3961
- selectedType?.location ? /* @__PURE__ */ jsx4("p", { className: "booking-card__tz", children: selectedType.location }) : null
4680
+ /* @__PURE__ */ jsxs6("div", { children: [
4681
+ /* @__PURE__ */ jsx6("p", { className: "booking-card__title", children: "Enter details" }),
4682
+ /* @__PURE__ */ jsx6("p", { className: "booking-card__tz", children: formatSlotLabel(startTime) }),
4683
+ selectedType?.location ? /* @__PURE__ */ jsx6("p", { className: "booking-card__tz", children: selectedType.location }) : null
3962
4684
  ] })
3963
4685
  ] }),
3964
- /* @__PURE__ */ jsxs4("div", { className: "booking-card__identity", children: [
3965
- /* @__PURE__ */ jsxs4(
4686
+ /* @__PURE__ */ jsxs6("div", { className: "booking-card__identity", children: [
4687
+ /* @__PURE__ */ jsxs6(
3966
4688
  "label",
3967
4689
  {
3968
4690
  className: "booking-card__field",
3969
4691
  htmlFor: `${fieldId}-name`,
3970
4692
  children: [
3971
- /* @__PURE__ */ jsx4("span", { children: "Name" }),
3972
- /* @__PURE__ */ jsx4(
4693
+ /* @__PURE__ */ jsx6("span", { children: "Name" }),
4694
+ /* @__PURE__ */ jsx6(
3973
4695
  "input",
3974
4696
  {
3975
4697
  id: `${fieldId}-name`,
@@ -3983,14 +4705,14 @@ function BookingCard({
3983
4705
  ]
3984
4706
  }
3985
4707
  ),
3986
- /* @__PURE__ */ jsxs4(
4708
+ /* @__PURE__ */ jsxs6(
3987
4709
  "label",
3988
4710
  {
3989
4711
  className: "booking-card__field",
3990
4712
  htmlFor: `${fieldId}-email`,
3991
4713
  children: [
3992
- /* @__PURE__ */ jsx4("span", { children: "Email" }),
3993
- /* @__PURE__ */ jsx4(
4714
+ /* @__PURE__ */ jsx6("span", { children: "Email" }),
4715
+ /* @__PURE__ */ jsx6(
3994
4716
  "input",
3995
4717
  {
3996
4718
  id: `${fieldId}-email`,
@@ -4006,7 +4728,7 @@ function BookingCard({
4006
4728
  }
4007
4729
  )
4008
4730
  ] }),
4009
- /* @__PURE__ */ jsx4(
4731
+ /* @__PURE__ */ jsx6(
4010
4732
  "button",
4011
4733
  {
4012
4734
  type: "submit",
@@ -4024,7 +4746,7 @@ function BookingCard({
4024
4746
  // src/react/components/MessageBubble/MessageBubble.tsx
4025
4747
  import { Streamdown } from "streamdown";
4026
4748
  import "streamdown/styles.css";
4027
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
4749
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
4028
4750
  function normalizeDedupeText(text) {
4029
4751
  return text.trim().replace(/\s+/g, " ").toLowerCase();
4030
4752
  }
@@ -4068,7 +4790,7 @@ function MessageBubble({
4068
4790
  onBook
4069
4791
  }) {
4070
4792
  const resolvedLogoUrl = brandLogoUrl?.trim();
4071
- const [failedLogoUrl, setFailedLogoUrl] = useState5(null);
4793
+ const [failedLogoUrl, setFailedLogoUrl] = useState6(null);
4072
4794
  const showBrandLogo = Boolean(resolvedLogoUrl) && failedLogoUrl !== resolvedLogoUrl;
4073
4795
  const cards = message.role === "agent" ? extractToolCards(message.text) : [];
4074
4796
  const extractedOffers = cards.filter(
@@ -4081,11 +4803,11 @@ function MessageBubble({
4081
4803
  offers.length > 0 ? sanitizeBookingOfferCopy(visibleText) : looksLikeBookingAvailabilityDump(visibleText) ? sanitizeBookingOfferCopy(visibleText) : visibleText || (isStreaming ? "" : message.text)
4082
4804
  );
4083
4805
  if (message.role === "visitor") {
4084
- return /* @__PURE__ */ jsx5("article", { className: "message-bubble message-bubble--visitor", children: /* @__PURE__ */ jsx5("p", { className: "message-bubble__text", children: message.text }) });
4806
+ return /* @__PURE__ */ jsx7("article", { className: "message-bubble message-bubble--visitor", children: /* @__PURE__ */ jsx7("p", { className: "message-bubble__text", children: message.text }) });
4085
4807
  }
4086
4808
  const citations = message.citations ?? [];
4087
- const agentText = /* @__PURE__ */ jsxs5("div", { className: "message-bubble__text", children: [
4088
- /* @__PURE__ */ jsx5(
4809
+ const agentText = /* @__PURE__ */ jsxs7("div", { className: "message-bubble__text", children: [
4810
+ /* @__PURE__ */ jsx7(
4089
4811
  Streamdown,
4090
4812
  {
4091
4813
  animated: isStreaming,
@@ -4099,8 +4821,8 @@ function MessageBubble({
4099
4821
  children: displayText
4100
4822
  }
4101
4823
  ),
4102
- citations.length > 0 ? /* @__PURE__ */ jsx5("ul", { className: "message-bubble__sources", "aria-label": "Sources", children: citations.map((citation) => /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs5("a", { href: citation.url, target: "_blank", rel: "noreferrer", children: [
4103
- /* @__PURE__ */ jsx5(
4824
+ citations.length > 0 ? /* @__PURE__ */ jsx7("ul", { className: "message-bubble__sources", "aria-label": "Sources", children: citations.map((citation) => /* @__PURE__ */ jsx7("li", { children: /* @__PURE__ */ jsxs7("a", { href: citation.url, target: "_blank", rel: "noreferrer", children: [
4825
+ /* @__PURE__ */ jsx7(
4104
4826
  "span",
4105
4827
  {
4106
4828
  className: "message-bubble__source-icon",
@@ -4108,12 +4830,12 @@ function MessageBubble({
4108
4830
  children: "\u25A6"
4109
4831
  }
4110
4832
  ),
4111
- /* @__PURE__ */ jsx5("span", { children: citation.label })
4833
+ /* @__PURE__ */ jsx7("span", { children: citation.label })
4112
4834
  ] }) }, citation.id)) }) : null
4113
4835
  ] });
4114
- return /* @__PURE__ */ jsxs5("article", { className: "message-bubble message-bubble--agent", children: [
4115
- displayText ? showBrandLogo ? /* @__PURE__ */ jsxs5("div", { className: "message-bubble__agent-row", children: [
4116
- /* @__PURE__ */ jsx5("span", { className: "message-bubble__agent-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx5(
4836
+ return /* @__PURE__ */ jsxs7("article", { className: "message-bubble message-bubble--agent", children: [
4837
+ displayText ? showBrandLogo ? /* @__PURE__ */ jsxs7("div", { className: "message-bubble__agent-row", children: [
4838
+ /* @__PURE__ */ jsx7("span", { className: "message-bubble__agent-avatar", "aria-hidden": "true", children: /* @__PURE__ */ jsx7(
4117
4839
  "img",
4118
4840
  {
4119
4841
  src: resolvedLogoUrl,
@@ -4125,7 +4847,7 @@ function MessageBubble({
4125
4847
  ) }),
4126
4848
  agentText
4127
4849
  ] }) : agentText : null,
4128
- offers.map((nextOffer, index) => /* @__PURE__ */ jsx5(
4850
+ offers.map((nextOffer, index) => /* @__PURE__ */ jsx7(
4129
4851
  BookingCard,
4130
4852
  {
4131
4853
  disabled: bookingDisabled,
@@ -4138,10 +4860,10 @@ function MessageBubble({
4138
4860
  }
4139
4861
 
4140
4862
  // src/react/components/HumanInputCard/HumanInputCard.tsx
4141
- import { useState as useState7 } from "react";
4863
+ import { useState as useState8 } from "react";
4142
4864
 
4143
4865
  // src/react/components/ConfirmationCard/ConfirmationCard.tsx
4144
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
4866
+ import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
4145
4867
  function ConfirmationCard({
4146
4868
  disabled = false,
4147
4869
  request,
@@ -4150,17 +4872,17 @@ function ConfirmationCard({
4150
4872
  const options = request.options ?? [];
4151
4873
  const heading = request.kind === "tool-approval" ? "Confirm this action" : request.prompt;
4152
4874
  const prompt = request.kind === "tool-approval" ? request.prompt : void 0;
4153
- return /* @__PURE__ */ jsxs6(
4875
+ return /* @__PURE__ */ jsxs8(
4154
4876
  "section",
4155
4877
  {
4156
4878
  className: "confirmation-card",
4157
4879
  "aria-labelledby": `confirmation-${request.requestId}`,
4158
4880
  children: [
4159
- /* @__PURE__ */ jsxs6("div", { className: "confirmation-card__heading", children: [
4160
- /* @__PURE__ */ jsx6("strong", { id: `confirmation-${request.requestId}`, children: heading }),
4161
- prompt ? /* @__PURE__ */ jsx6("p", { children: prompt }) : null
4881
+ /* @__PURE__ */ jsxs8("div", { className: "confirmation-card__heading", children: [
4882
+ /* @__PURE__ */ jsx8("strong", { id: `confirmation-${request.requestId}`, children: heading }),
4883
+ prompt ? /* @__PURE__ */ jsx8("p", { children: prompt }) : null
4162
4884
  ] }),
4163
- /* @__PURE__ */ jsx6("div", { className: "confirmation-card__actions", children: options.map((option) => /* @__PURE__ */ jsx6(
4885
+ /* @__PURE__ */ jsx8("div", { className: "confirmation-card__actions", children: options.map((option) => /* @__PURE__ */ jsx8(
4164
4886
  "button",
4165
4887
  {
4166
4888
  type: "button",
@@ -4180,8 +4902,8 @@ function ConfirmationCard({
4180
4902
  }
4181
4903
 
4182
4904
  // src/react/components/ToolInputCard/ToolInputCard.tsx
4183
- import { useState as useState6 } from "react";
4184
- import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
4905
+ import { useState as useState7 } from "react";
4906
+ import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
4185
4907
  function isRecord5(value) {
4186
4908
  return value !== null && typeof value === "object" && !Array.isArray(value);
4187
4909
  }
@@ -4305,7 +5027,7 @@ function FieldDescription({
4305
5027
  field,
4306
5028
  id
4307
5029
  }) {
4308
- return field.description ? /* @__PURE__ */ jsx7("span", { id, className: "tool-input-card__description", children: field.description }) : null;
5030
+ return field.description ? /* @__PURE__ */ jsx9("span", { id, className: "tool-input-card__description", children: field.description }) : null;
4309
5031
  }
4310
5032
  function ChoiceField({
4311
5033
  field,
@@ -4324,7 +5046,7 @@ function ChoiceField({
4324
5046
  const selectedIndex = options.findIndex(
4325
5047
  (option) => valuesMatch(option.value, value)
4326
5048
  );
4327
- return /* @__PURE__ */ jsxs7(
5049
+ return /* @__PURE__ */ jsxs9(
4328
5050
  "select",
4329
5051
  {
4330
5052
  id,
@@ -4339,13 +5061,13 @@ function ChoiceField({
4339
5061
  if (option) onChange(option.value);
4340
5062
  },
4341
5063
  children: [
4342
- /* @__PURE__ */ jsx7("option", { value: "", disabled: field.required, children: "Choose an option" }),
4343
- options.map((option, index) => /* @__PURE__ */ jsx7("option", { value: index, children: option.label }, optionKey(option)))
5064
+ /* @__PURE__ */ jsx9("option", { value: "", disabled: field.required, children: "Choose an option" }),
5065
+ options.map((option, index) => /* @__PURE__ */ jsx9("option", { value: index, children: option.label }, optionKey(option)))
4344
5066
  ]
4345
5067
  }
4346
5068
  );
4347
5069
  }
4348
- return /* @__PURE__ */ jsx7(
5070
+ return /* @__PURE__ */ jsx9(
4349
5071
  "div",
4350
5072
  {
4351
5073
  className: "tool-input-card__choices",
@@ -4356,8 +5078,8 @@ function ChoiceField({
4356
5078
  "aria-required": field.required,
4357
5079
  children: options.map((option, index) => {
4358
5080
  const checked = multiple ? selected.some((item) => valuesMatch(item, option.value)) : valuesMatch(value, option.value);
4359
- return /* @__PURE__ */ jsxs7("label", { className: "tool-input-card__choice", children: [
4360
- /* @__PURE__ */ jsx7(
5081
+ return /* @__PURE__ */ jsxs9("label", { className: "tool-input-card__choice", children: [
5082
+ /* @__PURE__ */ jsx9(
4361
5083
  "input",
4362
5084
  {
4363
5085
  type: multiple ? "checkbox" : "radio",
@@ -4379,7 +5101,7 @@ function ChoiceField({
4379
5101
  }
4380
5102
  }
4381
5103
  ),
4382
- /* @__PURE__ */ jsx7("span", { children: option.label })
5104
+ /* @__PURE__ */ jsx9("span", { children: option.label })
4383
5105
  ] }, optionKey(option));
4384
5106
  })
4385
5107
  }
@@ -4399,9 +5121,9 @@ function ToolField({
4399
5121
  error ? `${id}-error` : ""
4400
5122
  ].filter(Boolean).join(" ");
4401
5123
  if (field.kind === "checkbox" || field.kind === "confirmation") {
4402
- return /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__field", children: [
4403
- /* @__PURE__ */ jsxs7("label", { className: "tool-input-card__check", htmlFor: id, children: [
4404
- /* @__PURE__ */ jsx7(
5124
+ return /* @__PURE__ */ jsxs9("div", { className: "tool-input-card__field", children: [
5125
+ /* @__PURE__ */ jsxs9("label", { className: "tool-input-card__check", htmlFor: id, children: [
5126
+ /* @__PURE__ */ jsx9(
4405
5127
  "input",
4406
5128
  {
4407
5129
  id,
@@ -4414,17 +5136,17 @@ function ToolField({
4414
5136
  onChange: (event) => onChange(event.target.checked)
4415
5137
  }
4416
5138
  ),
4417
- /* @__PURE__ */ jsxs7("span", { children: [
4418
- /* @__PURE__ */ jsx7("strong", { children: field.label }),
4419
- field.description ? /* @__PURE__ */ jsx7("span", { id: `${id}-description`, children: field.description }) : null
5139
+ /* @__PURE__ */ jsxs9("span", { children: [
5140
+ /* @__PURE__ */ jsx9("strong", { children: field.label }),
5141
+ field.description ? /* @__PURE__ */ jsx9("span", { id: `${id}-description`, children: field.description }) : null
4420
5142
  ] })
4421
5143
  ] }),
4422
- error ? /* @__PURE__ */ jsx7("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
5144
+ error ? /* @__PURE__ */ jsx9("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
4423
5145
  ] });
4424
5146
  }
4425
- const label = /* @__PURE__ */ jsxs7("label", { id: `${id}-label`, htmlFor: id, children: [
5147
+ const label = /* @__PURE__ */ jsxs9("label", { id: `${id}-label`, htmlFor: id, children: [
4426
5148
  field.label,
4427
- field.required ? /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: " *" }) : null
5149
+ field.required ? /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", children: " *" }) : null
4428
5150
  ] });
4429
5151
  const common = {
4430
5152
  id,
@@ -4436,7 +5158,7 @@ function ToolField({
4436
5158
  };
4437
5159
  let control;
4438
5160
  if (field.kind === "select" || field.kind === "radio" || field.kind === "multi-select") {
4439
- control = /* @__PURE__ */ jsx7(
5161
+ control = /* @__PURE__ */ jsx9(
4440
5162
  ChoiceField,
4441
5163
  {
4442
5164
  field,
@@ -4450,7 +5172,7 @@ function ToolField({
4450
5172
  }
4451
5173
  );
4452
5174
  } else if (field.kind === "textarea" || field.kind === "json") {
4453
- control = /* @__PURE__ */ jsx7(
5175
+ control = /* @__PURE__ */ jsx9(
4454
5176
  "textarea",
4455
5177
  {
4456
5178
  ...common,
@@ -4464,8 +5186,8 @@ function ToolField({
4464
5186
  );
4465
5187
  } else if (field.kind === "range") {
4466
5188
  const numericValue = typeof value === "number" ? value : field.min ?? 0;
4467
- control = /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__range", children: [
4468
- /* @__PURE__ */ jsx7(
5189
+ control = /* @__PURE__ */ jsxs9("div", { className: "tool-input-card__range", children: [
5190
+ /* @__PURE__ */ jsx9(
4469
5191
  "input",
4470
5192
  {
4471
5193
  ...common,
@@ -4477,11 +5199,11 @@ function ToolField({
4477
5199
  onChange: (event) => onChange(Number(event.target.value))
4478
5200
  }
4479
5201
  ),
4480
- /* @__PURE__ */ jsx7("output", { htmlFor: id, children: numericValue })
5202
+ /* @__PURE__ */ jsx9("output", { htmlFor: id, children: numericValue })
4481
5203
  ] });
4482
5204
  } else {
4483
5205
  const type = field.kind === "date-time" ? "datetime-local" : field.kind === "calendar" ? "date" : field.kind;
4484
- control = /* @__PURE__ */ jsx7(
5206
+ control = /* @__PURE__ */ jsx9(
4485
5207
  "input",
4486
5208
  {
4487
5209
  ...common,
@@ -4499,11 +5221,11 @@ function ToolField({
4499
5221
  }
4500
5222
  );
4501
5223
  }
4502
- return /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__field", children: [
5224
+ return /* @__PURE__ */ jsxs9("div", { className: "tool-input-card__field", children: [
4503
5225
  label,
4504
- /* @__PURE__ */ jsx7(FieldDescription, { field, id: `${id}-description` }),
5226
+ /* @__PURE__ */ jsx9(FieldDescription, { field, id: `${id}-description` }),
4505
5227
  control,
4506
- error ? /* @__PURE__ */ jsx7("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
5228
+ error ? /* @__PURE__ */ jsx9("span", { id: `${id}-error`, className: "tool-input-card__error", children: error }) : null
4507
5229
  ] });
4508
5230
  }
4509
5231
  function ToolInputCard({
@@ -4511,11 +5233,11 @@ function ToolInputCard({
4511
5233
  surface,
4512
5234
  onSubmit
4513
5235
  }) {
4514
- const [values, setValues] = useState6(
5236
+ const [values, setValues] = useState7(
4515
5237
  () => initialValues(surface)
4516
5238
  );
4517
- const [touched, setTouched] = useState6(() => /* @__PURE__ */ new Set());
4518
- const [submitted, setSubmitted] = useState6(false);
5239
+ const [touched, setTouched] = useState7(() => /* @__PURE__ */ new Set());
5240
+ const [submitted, setSubmitted] = useState7(false);
4519
5241
  const errors = Object.fromEntries(
4520
5242
  surface.fields.map((field) => [
4521
5243
  field.path,
@@ -4540,14 +5262,14 @@ function ToolInputCard({
4540
5262
  onSubmit?.(surface, result);
4541
5263
  }
4542
5264
  if (submitted) {
4543
- return /* @__PURE__ */ jsxs7(
5265
+ return /* @__PURE__ */ jsxs9(
4544
5266
  "section",
4545
5267
  {
4546
5268
  className: "tool-input-card tool-input-card--submitted",
4547
5269
  role: "status",
4548
5270
  children: [
4549
- /* @__PURE__ */ jsx7("span", { "aria-hidden": "true", children: "\u2713" }),
4550
- /* @__PURE__ */ jsxs7("strong", { children: [
5271
+ /* @__PURE__ */ jsx9("span", { "aria-hidden": "true", children: "\u2713" }),
5272
+ /* @__PURE__ */ jsxs9("strong", { children: [
4551
5273
  surface.title,
4552
5274
  " submitted"
4553
5275
  ] })
@@ -4555,18 +5277,18 @@ function ToolInputCard({
4555
5277
  }
4556
5278
  );
4557
5279
  }
4558
- return /* @__PURE__ */ jsxs7(
5280
+ return /* @__PURE__ */ jsxs9(
4559
5281
  "section",
4560
5282
  {
4561
5283
  className: "tool-input-card",
4562
5284
  "aria-labelledby": `tool-input-${surface.id}`,
4563
5285
  children: [
4564
- /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__heading", children: [
4565
- /* @__PURE__ */ jsx7("strong", { id: `tool-input-${surface.id}`, children: surface.title }),
4566
- surface.description ? /* @__PURE__ */ jsx7("p", { children: surface.description }) : null
5286
+ /* @__PURE__ */ jsxs9("div", { className: "tool-input-card__heading", children: [
5287
+ /* @__PURE__ */ jsx9("strong", { id: `tool-input-${surface.id}`, children: surface.title }),
5288
+ surface.description ? /* @__PURE__ */ jsx9("p", { children: surface.description }) : null
4567
5289
  ] }),
4568
- /* @__PURE__ */ jsxs7("form", { noValidate: true, onSubmit: submit, children: [
4569
- /* @__PURE__ */ jsx7("div", { className: "tool-input-card__fields", children: surface.fields.map((field, index) => /* @__PURE__ */ jsx7(
5290
+ /* @__PURE__ */ jsxs9("form", { noValidate: true, onSubmit: submit, children: [
5291
+ /* @__PURE__ */ jsx9("div", { className: "tool-input-card__fields", children: surface.fields.map((field, index) => /* @__PURE__ */ jsx9(
4570
5292
  ToolField,
4571
5293
  {
4572
5294
  disabled,
@@ -4579,8 +5301,8 @@ function ToolInputCard({
4579
5301
  },
4580
5302
  field.path
4581
5303
  )) }),
4582
- /* @__PURE__ */ jsxs7("div", { className: "tool-input-card__actions", children: [
4583
- surface.actions?.some((action) => action.id === "reset") ? /* @__PURE__ */ jsx7(
5304
+ /* @__PURE__ */ jsxs9("div", { className: "tool-input-card__actions", children: [
5305
+ surface.actions?.some((action) => action.id === "reset") ? /* @__PURE__ */ jsx9(
4584
5306
  "button",
4585
5307
  {
4586
5308
  type: "button",
@@ -4593,7 +5315,7 @@ function ToolInputCard({
4593
5315
  children: surface.actions.find((action) => action.id === "reset")?.label ?? "Clear"
4594
5316
  }
4595
5317
  ) : null,
4596
- /* @__PURE__ */ jsx7("button", { type: "submit", disabled, children: surface.submitLabel ?? surface.actions?.find((action) => action.id === "submit")?.label ?? "Continue" })
5318
+ /* @__PURE__ */ jsx9("button", { type: "submit", disabled, children: surface.submitLabel ?? surface.actions?.find((action) => action.id === "submit")?.label ?? "Continue" })
4597
5319
  ] })
4598
5320
  ] })
4599
5321
  ]
@@ -4602,17 +5324,17 @@ function ToolInputCard({
4602
5324
  }
4603
5325
 
4604
5326
  // src/react/components/HumanInputCard/HumanInputCard.tsx
4605
- import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
5327
+ import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
4606
5328
  function HumanInputCard({
4607
5329
  disabled = false,
4608
5330
  request,
4609
5331
  onRespond
4610
5332
  }) {
4611
- const [text, setText] = useState7("");
5333
+ const [text, setText] = useState8("");
4612
5334
  const options = request.options ?? [];
4613
5335
  const showText = request.display === "text" || request.allowFreeform && options.length === 0;
4614
5336
  if (request.ui) {
4615
- return /* @__PURE__ */ jsx8(
5337
+ return /* @__PURE__ */ jsx10(
4616
5338
  ToolInputCard,
4617
5339
  {
4618
5340
  disabled,
@@ -4622,7 +5344,7 @@ function HumanInputCard({
4622
5344
  );
4623
5345
  }
4624
5346
  if (options.length > 0) {
4625
- return /* @__PURE__ */ jsx8(
5347
+ return /* @__PURE__ */ jsx10(
4626
5348
  ConfirmationCard,
4627
5349
  {
4628
5350
  disabled,
@@ -4637,17 +5359,17 @@ function HumanInputCard({
4637
5359
  if (!value || disabled) return;
4638
5360
  onRespond?.({ requestId: request.requestId, text: value });
4639
5361
  }
4640
- return /* @__PURE__ */ jsxs8(
5362
+ return /* @__PURE__ */ jsxs10(
4641
5363
  "section",
4642
5364
  {
4643
5365
  className: "human-input-card",
4644
5366
  "aria-labelledby": `human-input-${request.requestId}`,
4645
5367
  children: [
4646
- /* @__PURE__ */ jsx8("div", { className: "human-input-card__heading", children: /* @__PURE__ */ jsx8("strong", { id: `human-input-${request.requestId}`, children: request.prompt }) }),
4647
- showText ? /* @__PURE__ */ jsxs8("form", { onSubmit: submitText, children: [
4648
- /* @__PURE__ */ jsx8("label", { htmlFor: `human-input-text-${request.requestId}`, children: "Response" }),
4649
- /* @__PURE__ */ jsxs8("div", { children: [
4650
- /* @__PURE__ */ jsx8(
5368
+ /* @__PURE__ */ jsx10("div", { className: "human-input-card__heading", children: /* @__PURE__ */ jsx10("strong", { id: `human-input-${request.requestId}`, children: request.prompt }) }),
5369
+ showText ? /* @__PURE__ */ jsxs10("form", { onSubmit: submitText, children: [
5370
+ /* @__PURE__ */ jsx10("label", { htmlFor: `human-input-text-${request.requestId}`, children: "Response" }),
5371
+ /* @__PURE__ */ jsxs10("div", { children: [
5372
+ /* @__PURE__ */ jsx10(
4651
5373
  "input",
4652
5374
  {
4653
5375
  id: `human-input-text-${request.requestId}`,
@@ -4656,39 +5378,39 @@ function HumanInputCard({
4656
5378
  onChange: (event) => setText(event.target.value)
4657
5379
  }
4658
5380
  ),
4659
- /* @__PURE__ */ jsx8("button", { type: "submit", disabled: disabled || !text.trim(), children: "Send" })
5381
+ /* @__PURE__ */ jsx10("button", { type: "submit", disabled: disabled || !text.trim(), children: "Send" })
4660
5382
  ] })
4661
5383
  ] }) : null,
4662
- !showText && options.length === 0 ? /* @__PURE__ */ jsx8("p", { className: "human-input-card__unavailable", role: "status", children: "This request can\u2019t be answered here." }) : null
5384
+ !showText && options.length === 0 ? /* @__PURE__ */ jsx10("p", { className: "human-input-card__unavailable", role: "status", children: "This request can\u2019t be answered here." }) : null
4663
5385
  ]
4664
5386
  }
4665
5387
  );
4666
5388
  }
4667
5389
 
4668
5390
  // src/react/components/CollectionResultCard/CollectionResultCard.tsx
4669
- import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
5391
+ import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
4670
5392
  function CollectionResultCard({
4671
5393
  result
4672
5394
  }) {
4673
5395
  const empty = result.items.length === 0;
4674
- return /* @__PURE__ */ jsxs9(
5396
+ return /* @__PURE__ */ jsxs11(
4675
5397
  "section",
4676
5398
  {
4677
5399
  className: `collection-result-card tool-result-card tool-result-card--${result.status}`,
4678
5400
  "aria-label": result.title,
4679
5401
  children: [
4680
- /* @__PURE__ */ jsxs9("div", { className: "tool-result-card__heading", children: [
4681
- /* @__PURE__ */ jsx9("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4682
- /* @__PURE__ */ jsx9("strong", { children: result.title })
5402
+ /* @__PURE__ */ jsxs11("div", { className: "tool-result-card__heading", children: [
5403
+ /* @__PURE__ */ jsx11("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
5404
+ /* @__PURE__ */ jsx11("strong", { children: result.title })
4683
5405
  ] }),
4684
- empty ? /* @__PURE__ */ jsx9("p", { className: "collection-result-card__empty", children: "No matching record for the email you shared." }) : /* @__PURE__ */ jsx9("ul", { className: "collection-result-card__list", children: result.items.map((item) => /* @__PURE__ */ jsxs9("li", { children: [
4685
- /* @__PURE__ */ jsx9("div", { className: "collection-result-card__item-title", children: item.title }),
4686
- item.description ? /* @__PURE__ */ jsx9("p", { children: item.description }) : null,
4687
- item.details?.length ? /* @__PURE__ */ jsx9("dl", { children: item.details.map((detail) => /* @__PURE__ */ jsxs9("div", { children: [
4688
- /* @__PURE__ */ jsx9("dt", { children: detail.label }),
4689
- /* @__PURE__ */ jsx9("dd", { children: detail.value })
5406
+ empty ? /* @__PURE__ */ jsx11("p", { className: "collection-result-card__empty", children: "No matching record for the email you shared." }) : /* @__PURE__ */ jsx11("ul", { className: "collection-result-card__list", children: result.items.map((item) => /* @__PURE__ */ jsxs11("li", { children: [
5407
+ /* @__PURE__ */ jsx11("div", { className: "collection-result-card__item-title", children: item.title }),
5408
+ item.description ? /* @__PURE__ */ jsx11("p", { children: item.description }) : null,
5409
+ item.details?.length ? /* @__PURE__ */ jsx11("dl", { children: item.details.map((detail) => /* @__PURE__ */ jsxs11("div", { children: [
5410
+ /* @__PURE__ */ jsx11("dt", { children: detail.label }),
5411
+ /* @__PURE__ */ jsx11("dd", { children: detail.value })
4690
5412
  ] }, `${detail.label}:${detail.value}`)) }) : null,
4691
- item.href ? /* @__PURE__ */ jsx9("a", { href: item.href, target: "_blank", rel: "noreferrer", children: "Open record" }) : null
5413
+ item.href ? /* @__PURE__ */ jsx11("a", { href: item.href, target: "_blank", rel: "noreferrer", children: "Open record" }) : null
4692
5414
  ] }, item.title)) })
4693
5415
  ]
4694
5416
  }
@@ -4696,26 +5418,26 @@ function CollectionResultCard({
4696
5418
  }
4697
5419
 
4698
5420
  // src/react/components/EntityResultCard/EntityResultCard.tsx
4699
- import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
5421
+ import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
4700
5422
  function EntityResultCard({
4701
5423
  result
4702
5424
  }) {
4703
- return /* @__PURE__ */ jsxs10(
5425
+ return /* @__PURE__ */ jsxs12(
4704
5426
  "section",
4705
5427
  {
4706
5428
  className: `entity-result-card tool-result-card tool-result-card--${result.status}`,
4707
5429
  "aria-label": result.title,
4708
5430
  children: [
4709
- /* @__PURE__ */ jsxs10("div", { className: "tool-result-card__heading", children: [
4710
- /* @__PURE__ */ jsx10("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4711
- /* @__PURE__ */ jsx10("strong", { children: result.title })
5431
+ /* @__PURE__ */ jsxs12("div", { className: "tool-result-card__heading", children: [
5432
+ /* @__PURE__ */ jsx12("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
5433
+ /* @__PURE__ */ jsx12("strong", { children: result.title })
4712
5434
  ] }),
4713
- result.description ? /* @__PURE__ */ jsx10("p", { children: result.description }) : null,
4714
- result.details?.length ? /* @__PURE__ */ jsx10("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs10("div", { children: [
4715
- /* @__PURE__ */ jsx10("dt", { children: detail.label }),
4716
- /* @__PURE__ */ jsx10("dd", { children: detail.value })
5435
+ result.description ? /* @__PURE__ */ jsx12("p", { children: result.description }) : null,
5436
+ result.details?.length ? /* @__PURE__ */ jsx12("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs12("div", { children: [
5437
+ /* @__PURE__ */ jsx12("dt", { children: detail.label }),
5438
+ /* @__PURE__ */ jsx12("dd", { children: detail.value })
4717
5439
  ] }, `${detail.label}:${detail.value}`)) }) : null,
4718
- result.links?.length ? /* @__PURE__ */ jsx10("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx10(
5440
+ result.links?.length ? /* @__PURE__ */ jsx12("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx12(
4719
5441
  "a",
4720
5442
  {
4721
5443
  href: link.href,
@@ -4731,24 +5453,24 @@ function EntityResultCard({
4731
5453
  }
4732
5454
 
4733
5455
  // src/react/components/SignatureResultCard/SignatureResultCard.tsx
4734
- import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
5456
+ import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
4735
5457
  function SignatureResultCard({
4736
5458
  result
4737
5459
  }) {
4738
5460
  const primaryLink = result.links?.[0];
4739
- return /* @__PURE__ */ jsxs11(
5461
+ return /* @__PURE__ */ jsxs13(
4740
5462
  "section",
4741
5463
  {
4742
5464
  className: `signature-result-card tool-result-card tool-result-card--${result.status}`,
4743
5465
  "aria-label": result.title,
4744
5466
  children: [
4745
- /* @__PURE__ */ jsxs11("div", { className: "tool-result-card__heading", children: [
4746
- /* @__PURE__ */ jsx11("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4747
- /* @__PURE__ */ jsx11("strong", { children: result.title })
5467
+ /* @__PURE__ */ jsxs13("div", { className: "tool-result-card__heading", children: [
5468
+ /* @__PURE__ */ jsx13("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
5469
+ /* @__PURE__ */ jsx13("strong", { children: result.title })
4748
5470
  ] }),
4749
- result.statusLabel ? /* @__PURE__ */ jsx11("span", { className: "signature-result-card__badge", children: result.statusLabel }) : null,
4750
- result.description ? /* @__PURE__ */ jsx11("p", { children: result.description }) : null,
4751
- primaryLink ? /* @__PURE__ */ jsx11(
5471
+ result.statusLabel ? /* @__PURE__ */ jsx13("span", { className: "signature-result-card__badge", children: result.statusLabel }) : null,
5472
+ result.description ? /* @__PURE__ */ jsx13("p", { children: result.description }) : null,
5473
+ primaryLink ? /* @__PURE__ */ jsx13(
4752
5474
  "a",
4753
5475
  {
4754
5476
  className: "signature-result-card__cta",
@@ -4764,26 +5486,26 @@ function SignatureResultCard({
4764
5486
  }
4765
5487
 
4766
5488
  // src/react/components/ToolResultCard/ToolResultCard.tsx
4767
- import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
5489
+ import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
4768
5490
  function ToolResultCard({
4769
5491
  result
4770
5492
  }) {
4771
- return /* @__PURE__ */ jsxs12(
5493
+ return /* @__PURE__ */ jsxs14(
4772
5494
  "section",
4773
5495
  {
4774
5496
  className: `tool-result-card tool-result-card--${result.status}`,
4775
5497
  "aria-label": result.title,
4776
5498
  children: [
4777
- /* @__PURE__ */ jsxs12("div", { className: "tool-result-card__heading", children: [
4778
- /* @__PURE__ */ jsx12("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
4779
- /* @__PURE__ */ jsx12("strong", { children: result.title })
5499
+ /* @__PURE__ */ jsxs14("div", { className: "tool-result-card__heading", children: [
5500
+ /* @__PURE__ */ jsx14("span", { className: "tool-result-card__status", "aria-hidden": "true" }),
5501
+ /* @__PURE__ */ jsx14("strong", { children: result.title })
4780
5502
  ] }),
4781
- result.description ? /* @__PURE__ */ jsx12("p", { children: result.description }) : null,
4782
- result.details?.length ? /* @__PURE__ */ jsx12("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs12("div", { children: [
4783
- /* @__PURE__ */ jsx12("dt", { children: detail.label }),
4784
- /* @__PURE__ */ jsx12("dd", { children: detail.value })
5503
+ result.description ? /* @__PURE__ */ jsx14("p", { children: result.description }) : null,
5504
+ result.details?.length ? /* @__PURE__ */ jsx14("dl", { children: result.details.map((detail) => /* @__PURE__ */ jsxs14("div", { children: [
5505
+ /* @__PURE__ */ jsx14("dt", { children: detail.label }),
5506
+ /* @__PURE__ */ jsx14("dd", { children: detail.value })
4785
5507
  ] }, `${detail.label}:${detail.value}`)) }) : null,
4786
- result.links?.length ? /* @__PURE__ */ jsx12("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx12(
5508
+ result.links?.length ? /* @__PURE__ */ jsx14("div", { className: "tool-result-card__links", children: result.links.map((link) => /* @__PURE__ */ jsx14(
4787
5509
  "a",
4788
5510
  {
4789
5511
  href: link.href,
@@ -4799,14 +5521,14 @@ function ToolResultCard({
4799
5521
  }
4800
5522
 
4801
5523
  // src/react/components/VisitorToolResultView/VisitorToolResultView.tsx
4802
- import { jsx as jsx13 } from "react/jsx-runtime";
5524
+ import { jsx as jsx15 } from "react/jsx-runtime";
4803
5525
  function VisitorToolResultView({
4804
5526
  disabled = false,
4805
5527
  onToolInput,
4806
5528
  result
4807
5529
  }) {
4808
5530
  if (result.kind === "input") {
4809
- return /* @__PURE__ */ jsx13(
5531
+ return /* @__PURE__ */ jsx15(
4810
5532
  ToolInputCard,
4811
5533
  {
4812
5534
  disabled,
@@ -4816,16 +5538,16 @@ function VisitorToolResultView({
4816
5538
  );
4817
5539
  }
4818
5540
  if (result.kind === "entity") {
4819
- return /* @__PURE__ */ jsx13(EntityResultCard, { result });
5541
+ return /* @__PURE__ */ jsx15(EntityResultCard, { result });
4820
5542
  }
4821
5543
  if (result.kind === "collection") {
4822
- return /* @__PURE__ */ jsx13(CollectionResultCard, { result });
5544
+ return /* @__PURE__ */ jsx15(CollectionResultCard, { result });
4823
5545
  }
4824
5546
  if (result.kind === "signature") {
4825
- return /* @__PURE__ */ jsx13(SignatureResultCard, { result });
5547
+ return /* @__PURE__ */ jsx15(SignatureResultCard, { result });
4826
5548
  }
4827
5549
  if (result.kind === "summary") {
4828
- return /* @__PURE__ */ jsx13(ToolResultCard, { result });
5550
+ return /* @__PURE__ */ jsx15(ToolResultCard, { result });
4829
5551
  }
4830
5552
  return null;
4831
5553
  }
@@ -4834,9 +5556,9 @@ function isRenderableVisitorToolResult(result) {
4834
5556
  }
4835
5557
 
4836
5558
  // src/react/components/AgentRail/AgentRail.tsx
4837
- import { Fragment, jsx as jsx14, jsxs as jsxs13 } from "react/jsx-runtime";
5559
+ import { Fragment, jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
4838
5560
  function MinimizeIcon() {
4839
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5561
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
4840
5562
  "path",
4841
5563
  {
4842
5564
  d: "M3.5 8h9",
@@ -4846,8 +5568,8 @@ function MinimizeIcon() {
4846
5568
  }
4847
5569
  ) });
4848
5570
  }
4849
- function CloseIcon() {
4850
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5571
+ function CloseIcon2() {
5572
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
4851
5573
  "path",
4852
5574
  {
4853
5575
  d: "M4 4l8 8M12 4l-8 8",
@@ -4858,7 +5580,7 @@ function CloseIcon() {
4858
5580
  ) });
4859
5581
  }
4860
5582
  function NewChatIcon() {
4861
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5583
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
4862
5584
  "path",
4863
5585
  {
4864
5586
  d: "M9.5 3.5h3v3M12.25 3.75 8 8M7 4H4.5A1.5 1.5 0 0 0 3 5.5v6A1.5 1.5 0 0 0 4.5 13h6a1.5 1.5 0 0 0 1.5-1.5V9",
@@ -4870,7 +5592,7 @@ function NewChatIcon() {
4870
5592
  ) });
4871
5593
  }
4872
5594
  function ExpandIcon() {
4873
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5595
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
4874
5596
  "path",
4875
5597
  {
4876
5598
  d: "M6 3.5H3.5V6M10 3.5h2.5V6M10 12.5h2.5V10M6 12.5H3.5V10",
@@ -4882,7 +5604,7 @@ function ExpandIcon() {
4882
5604
  ) });
4883
5605
  }
4884
5606
  function RestoreIcon() {
4885
- return /* @__PURE__ */ jsx14("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5607
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
4886
5608
  "path",
4887
5609
  {
4888
5610
  d: "M5.5 5.5H3.5V7.5M10.5 5.5h2V7.5M10.5 10.5h2V8.5M5.5 10.5H3.5V8.5",
@@ -4893,6 +5615,19 @@ function RestoreIcon() {
4893
5615
  }
4894
5616
  ) });
4895
5617
  }
5618
+ function ChevronDownIcon() {
5619
+ return /* @__PURE__ */ jsx16("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
5620
+ "path",
5621
+ {
5622
+ d: "M4 6.5l4 4 4-4",
5623
+ stroke: "currentColor",
5624
+ strokeWidth: "1.6",
5625
+ strokeLinecap: "round",
5626
+ strokeLinejoin: "round"
5627
+ }
5628
+ ) });
5629
+ }
5630
+ var DEFAULT_DISCLAIMER_LABEL = "Agent can make mistakes. Check important info.";
4896
5631
  function AgentRail({
4897
5632
  state,
4898
5633
  theme,
@@ -4900,6 +5635,9 @@ function AgentRail({
4900
5635
  brandLabel = "",
4901
5636
  brandLogoUrl,
4902
5637
  poweredByLabel = "Powered by Webless",
5638
+ disclaimerLabel,
5639
+ answerReceipt = false,
5640
+ readAloud = false,
4903
5641
  composerPlaceholder = "Ask anything\u2026",
4904
5642
  mobileFullscreen = false,
4905
5643
  expanded = false,
@@ -4908,16 +5646,26 @@ function AgentRail({
4908
5646
  onExpandToggle,
4909
5647
  onReset,
4910
5648
  onRetry,
5649
+ onRegenerate,
5650
+ onFeedback,
4911
5651
  onSubmit,
4912
5652
  onFollowUpSelect,
4913
5653
  onBook,
4914
5654
  onInputResponse,
4915
5655
  onToolInput
4916
5656
  }) {
4917
- const transcriptRef = useRef4(null);
5657
+ const railRef = useRef6(null);
5658
+ const overlayRef = useRef6(null);
5659
+ const transcriptRef = useRef6(null);
5660
+ const pinnedToBottomRef = useRef6(true);
5661
+ const smoothScrollToLatestRef = useRef6(false);
5662
+ const lockedTranscriptScrollTopRef = useRef6(null);
5663
+ const [showJumpToLatest, setShowJumpToLatest] = useState9(false);
5664
+ const [receiptOpen, setReceiptOpen] = useState9(false);
4918
5665
  const resolvedBrandLabel = brandLabel.trim();
4919
5666
  const resolvedBrandLogoUrl = brandLogoUrl?.trim();
4920
- const [failedLogoUrl, setFailedLogoUrl] = useState8(null);
5667
+ const resolvedDisclaimerLabel = disclaimerLabel === void 0 ? DEFAULT_DISCLAIMER_LABEL : disclaimerLabel;
5668
+ const [failedLogoUrl, setFailedLogoUrl] = useState9(null);
4921
5669
  const showBrandLogo = Boolean(resolvedBrandLogoUrl) && failedLogoUrl !== resolvedBrandLogoUrl;
4922
5670
  const resolvedColorScheme = useAgentColorScheme(colorScheme);
4923
5671
  const brandedTheme = { ...defaultAgentRailTheme, ...theme };
@@ -4968,10 +5716,15 @@ function AgentRail({
4968
5716
  );
4969
5717
  const activeVisitorToolInput = [...visitorToolResults].reverse().find((result) => result.kind === "input");
4970
5718
  const visibleVisitorToolResults = activeVisitorToolInput ? [activeVisitorToolInput] : visitorToolResults;
4971
- const showActivity = state.toolSteps.length > 0 && visibleVisitorToolResults.length === 0 && pendingInputRequests.length === 0 && !state.pendingOffer;
5719
+ const activityActive = state.toolSteps.some((step) => step.state === "active");
5720
+ const showActivity = state.toolSteps.length > 0 && visibleVisitorToolResults.length === 0 && pendingInputRequests.length === 0 && !state.pendingOffer && activityActive;
4972
5721
  const hasVisitorMessages2 = state.messages.some(
4973
5722
  (message) => message.role === "visitor"
4974
5723
  );
5724
+ const hasAgentResponseAfterVisitor = state.messages.some(
5725
+ (message) => message.role === "agent" && message.id !== "greeting"
5726
+ );
5727
+ const showDisclaimerLabel = Boolean(resolvedDisclaimerLabel) && hasVisitorMessages2 && (hasAgentResponseAfterVisitor || state.phase === "streaming" && Boolean(state.streamingText));
4975
5728
  const showIdleFollowUps = !hasVisitorMessages2 && state.followUps.length > 0;
4976
5729
  const greeting = state.messages.find(
4977
5730
  (message) => message.role === "agent" && message.id === "greeting"
@@ -4993,6 +5746,7 @@ function AgentRail({
4993
5746
  }
4994
5747
  }
4995
5748
  const lastIsAgent = lastMessage?.role === "agent";
5749
+ const showMessageActions = state.phase === "complete" && lastIsAgent && hasVisitorMessages2;
4996
5750
  const streamingMessage = state.phase === "streaming" && state.streamingText && !lastIsAgent ? {
4997
5751
  createdAt: 0,
4998
5752
  id: "streaming-response",
@@ -5019,10 +5773,36 @@ function AgentRail({
5019
5773
  hasPendingConfirmation,
5020
5774
  enabled: lastIsAgent && !isBusy
5021
5775
  });
5022
- useEffect4(() => {
5776
+ const receiptSteps = answerReceipt && state.toolSteps.length > 0 ? state.toolSteps : void 0;
5777
+ useEffect6(() => {
5778
+ if (state.phase !== "complete") {
5779
+ setReceiptOpen(false);
5780
+ }
5781
+ }, [state.phase]);
5782
+ function handleSubmit(message) {
5783
+ setReceiptOpen(false);
5784
+ onSubmit?.(message);
5785
+ }
5786
+ function handleRegenerate() {
5787
+ setReceiptOpen(false);
5788
+ onRegenerate?.();
5789
+ }
5790
+ function handleReset() {
5791
+ setReceiptOpen(false);
5792
+ onReset?.();
5793
+ }
5794
+ function handleFollowUpSelect(label) {
5795
+ setReceiptOpen(false);
5796
+ onFollowUpSelect?.(label);
5797
+ }
5798
+ useEffect6(() => {
5023
5799
  const node = transcriptRef.current;
5024
5800
  if (!node) return;
5025
- node.scrollTop = node.scrollHeight;
5801
+ const lastMessage2 = state.messages.at(-1);
5802
+ const visitorJustSent = lastMessage2?.role === "visitor";
5803
+ if (pinnedToBottomRef.current || visitorJustSent) {
5804
+ node.scrollTop = node.scrollHeight;
5805
+ }
5026
5806
  }, [
5027
5807
  state.messages,
5028
5808
  state.toolSteps,
@@ -5030,10 +5810,75 @@ function AgentRail({
5030
5810
  state.followUps,
5031
5811
  state.journey
5032
5812
  ]);
5033
- return /* @__PURE__ */ jsxs13(
5813
+ useEffect6(() => {
5814
+ const node = transcriptRef.current;
5815
+ if (!node) return;
5816
+ const handleScroll = () => {
5817
+ if (node.clientHeight === 0) return;
5818
+ const distanceFromBottom = node.scrollHeight - node.scrollTop - node.clientHeight;
5819
+ const pinned = distanceFromBottom < 48 || smoothScrollToLatestRef.current;
5820
+ pinnedToBottomRef.current = pinned;
5821
+ setShowJumpToLatest(!pinned);
5822
+ };
5823
+ node.addEventListener("scroll", handleScroll, { passive: true });
5824
+ handleScroll();
5825
+ return () => node.removeEventListener("scroll", handleScroll);
5826
+ }, []);
5827
+ useEffect6(() => {
5828
+ const node = transcriptRef.current;
5829
+ if (!node) return;
5830
+ const observer = new ResizeObserver(() => {
5831
+ if (node.clientHeight === 0) return;
5832
+ if (pinnedToBottomRef.current) {
5833
+ node.scrollTo({ top: node.scrollHeight, behavior: "instant" });
5834
+ }
5835
+ });
5836
+ observer.observe(node);
5837
+ return () => observer.disconnect();
5838
+ }, []);
5839
+ useEffect6(() => {
5840
+ if (!receiptOpen) {
5841
+ lockedTranscriptScrollTopRef.current = null;
5842
+ return;
5843
+ }
5844
+ const node = transcriptRef.current;
5845
+ if (!node || lockedTranscriptScrollTopRef.current === null) return;
5846
+ node.scrollTop = lockedTranscriptScrollTopRef.current;
5847
+ }, [receiptOpen]);
5848
+ function openReceipt() {
5849
+ const node = transcriptRef.current;
5850
+ lockedTranscriptScrollTopRef.current = node?.scrollTop ?? null;
5851
+ setReceiptOpen(true);
5852
+ }
5853
+ function scrollToLatest() {
5854
+ const node = transcriptRef.current;
5855
+ if (!node) return;
5856
+ pinnedToBottomRef.current = true;
5857
+ setShowJumpToLatest(false);
5858
+ const reduceMotion = window.matchMedia(
5859
+ "(prefers-reduced-motion: reduce)"
5860
+ ).matches;
5861
+ if (reduceMotion) {
5862
+ node.scrollTo({ top: node.scrollHeight, behavior: "instant" });
5863
+ return;
5864
+ }
5865
+ smoothScrollToLatestRef.current = true;
5866
+ const settle = () => {
5867
+ smoothScrollToLatestRef.current = false;
5868
+ const distanceFromBottom = node.scrollHeight - node.scrollTop - node.clientHeight;
5869
+ const pinned = distanceFromBottom < 48;
5870
+ pinnedToBottomRef.current = pinned;
5871
+ setShowJumpToLatest(!pinned);
5872
+ };
5873
+ node.addEventListener("scrollend", settle, { once: true });
5874
+ window.setTimeout(settle, 900);
5875
+ node.scrollTo({ top: node.scrollHeight, behavior: "smooth" });
5876
+ }
5877
+ return /* @__PURE__ */ jsx16(
5034
5878
  "aside",
5035
5879
  {
5036
- className: `agent-rail not-typeset${mobileFullscreen ? " agent-rail--mobile-fullscreen" : ""}${expanded ? " agent-rail--expanded" : ""}`,
5880
+ ref: railRef,
5881
+ className: `agent-rail not-typeset${mobileFullscreen ? " agent-rail--mobile-fullscreen" : ""}${expanded ? " agent-rail--expanded" : ""}${receiptOpen ? " agent-rail--receipt-open" : ""}`,
5037
5882
  "data-not-typeset": "",
5038
5883
  "data-color-scheme": resolvedColorScheme,
5039
5884
  spellCheck: false,
@@ -5043,196 +5888,234 @@ function AgentRail({
5043
5888
  autoFocus: mobileFullscreen || expanded,
5044
5889
  role: mobileFullscreen || expanded ? "dialog" : void 0,
5045
5890
  tabIndex: mobileFullscreen || expanded ? -1 : void 0,
5046
- children: [
5047
- /* @__PURE__ */ jsx14("header", { className: "agent-rail__header", children: /* @__PURE__ */ jsxs13("div", { className: "agent-rail__brand-row", children: [
5048
- onCollapse ? /* @__PURE__ */ jsx14(
5049
- "button",
5050
- {
5051
- type: "button",
5052
- className: "agent-rail__collapse",
5053
- "aria-label": "Collapse assist",
5054
- onClick: onCollapse,
5055
- children: /* @__PURE__ */ jsx14(MinimizeIcon, {})
5056
- }
5057
- ) : onClose ? /* @__PURE__ */ jsx14(
5058
- "button",
5059
- {
5060
- type: "button",
5061
- className: "agent-rail__close",
5062
- "aria-label": "Close agent",
5063
- onClick: onClose,
5064
- children: /* @__PURE__ */ jsx14(CloseIcon, {})
5065
- }
5066
- ) : /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" }),
5067
- resolvedBrandLabel || showBrandLogo ? /* @__PURE__ */ jsxs13("span", { className: "agent-rail__identity", children: [
5068
- showBrandLogo ? /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx14(
5069
- "img",
5070
- {
5071
- className: "agent-rail__brand-logo",
5072
- src: resolvedBrandLogoUrl,
5073
- alt: "",
5074
- onError: () => {
5075
- setFailedLogoUrl(resolvedBrandLogoUrl ?? null);
5076
- }
5077
- }
5078
- ) }) : null,
5079
- resolvedBrandLabel ? /* @__PURE__ */ jsx14("span", { className: "agent-rail__brand-label", children: resolvedBrandLabel }) : null
5080
- ] }) : null,
5081
- /* @__PURE__ */ jsxs13("span", { className: "agent-rail__actions", children: [
5082
- onReset ? /* @__PURE__ */ jsx14(
5083
- "button",
5084
- {
5085
- type: "button",
5086
- className: "agent-rail__new-chat",
5087
- "aria-label": "Start a new conversation",
5088
- disabled: !hasVisitorMessages2,
5089
- onClick: onReset,
5090
- children: /* @__PURE__ */ jsx14(NewChatIcon, {})
5091
- }
5092
- ) : null,
5093
- onExpandToggle ? /* @__PURE__ */ jsx14(
5094
- "button",
5095
- {
5096
- type: "button",
5097
- className: "agent-rail__expand",
5098
- "aria-label": expanded ? "Exit full screen" : "Open full screen",
5099
- onClick: onExpandToggle,
5100
- children: expanded ? /* @__PURE__ */ jsx14(RestoreIcon, {}) : /* @__PURE__ */ jsx14(ExpandIcon, {})
5101
- }
5102
- ) : null
5103
- ] })
5104
- ] }) }),
5105
- /* @__PURE__ */ jsx14("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs13("div", { className: "agent-rail__thread", children: [
5106
- !hasVisitorMessages2 ? /* @__PURE__ */ jsxs13("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
5107
- greeting?.role === "agent" ? /* @__PURE__ */ jsx14(
5108
- MessageBubble,
5109
- {
5110
- message: greeting,
5111
- bookingDisabled: isBusy,
5112
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5113
- onBook
5114
- }
5115
- ) : null,
5116
- showIdleFollowUps ? /* @__PURE__ */ jsx14("div", { className: "agent-rail__followups-slot", children: /* @__PURE__ */ jsx14(
5117
- FollowUpChips,
5118
- {
5119
- suggestions: state.followUps,
5120
- disabled: isBusy,
5121
- label: "Start here",
5122
- onSelect: (suggestion) => onFollowUpSelect?.(suggestion.label)
5123
- }
5124
- ) }) : null,
5125
- showActivity ? /* @__PURE__ */ jsx14(
5126
- AgentActivityBubble,
5891
+ children: /* @__PURE__ */ jsxs15(
5892
+ AgentRailOverlayContext.Provider,
5893
+ {
5894
+ value: { railRef, overlayRef },
5895
+ children: [
5896
+ /* @__PURE__ */ jsxs15("div", { className: "agent-rail__surface", inert: receiptOpen || void 0, children: [
5897
+ /* @__PURE__ */ jsx16("header", { className: "agent-rail__header", children: /* @__PURE__ */ jsxs15("div", { className: "agent-rail__brand-row", children: [
5898
+ onCollapse ? /* @__PURE__ */ jsx16(
5899
+ "button",
5900
+ {
5901
+ type: "button",
5902
+ className: "agent-rail__collapse",
5903
+ "aria-label": "Collapse assist",
5904
+ onClick: onCollapse,
5905
+ children: /* @__PURE__ */ jsx16(MinimizeIcon, {})
5906
+ }
5907
+ ) : onClose ? /* @__PURE__ */ jsx16(
5908
+ "button",
5909
+ {
5910
+ type: "button",
5911
+ className: "agent-rail__close",
5912
+ "aria-label": "Close agent",
5913
+ onClick: onClose,
5914
+ children: /* @__PURE__ */ jsx16(CloseIcon2, {})
5915
+ }
5916
+ ) : /* @__PURE__ */ jsx16("span", { className: "agent-rail__brand-spacer", "aria-hidden": "true" }),
5917
+ resolvedBrandLabel || showBrandLogo ? /* @__PURE__ */ jsxs15("span", { className: "agent-rail__identity", children: [
5918
+ showBrandLogo ? /* @__PURE__ */ jsx16("span", { className: "agent-rail__brand-mark", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
5919
+ "img",
5920
+ {
5921
+ className: "agent-rail__brand-logo",
5922
+ src: resolvedBrandLogoUrl,
5923
+ alt: "",
5924
+ onError: () => {
5925
+ setFailedLogoUrl(resolvedBrandLogoUrl ?? null);
5926
+ }
5927
+ }
5928
+ ) }) : null,
5929
+ resolvedBrandLabel ? /* @__PURE__ */ jsx16("span", { className: "agent-rail__brand-label", children: resolvedBrandLabel }) : null
5930
+ ] }) : null,
5931
+ /* @__PURE__ */ jsxs15("span", { className: "agent-rail__actions", children: [
5932
+ onReset ? /* @__PURE__ */ jsx16(
5933
+ "button",
5934
+ {
5935
+ type: "button",
5936
+ className: "agent-rail__new-chat",
5937
+ "aria-label": "Start a new conversation",
5938
+ disabled: !hasVisitorMessages2,
5939
+ onClick: handleReset,
5940
+ children: /* @__PURE__ */ jsx16(NewChatIcon, {})
5941
+ }
5942
+ ) : null,
5943
+ onExpandToggle ? /* @__PURE__ */ jsx16(
5944
+ "button",
5945
+ {
5946
+ type: "button",
5947
+ className: "agent-rail__expand",
5948
+ "aria-label": expanded ? "Exit full screen" : "Open full screen",
5949
+ onClick: onExpandToggle,
5950
+ children: expanded ? /* @__PURE__ */ jsx16(RestoreIcon, {}) : /* @__PURE__ */ jsx16(ExpandIcon, {})
5951
+ }
5952
+ ) : null
5953
+ ] })
5954
+ ] }) }),
5955
+ /* @__PURE__ */ jsx16("div", { ref: transcriptRef, className: "agent-rail__transcript", children: /* @__PURE__ */ jsxs15("div", { className: "agent-rail__thread", children: [
5956
+ !hasVisitorMessages2 ? /* @__PURE__ */ jsxs15("section", { className: "agent-rail__welcome", "aria-label": "Welcome", children: [
5957
+ greeting?.role === "agent" ? /* @__PURE__ */ jsx16(
5958
+ MessageBubble,
5959
+ {
5960
+ message: greeting,
5961
+ bookingDisabled: isBusy,
5962
+ brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5963
+ onBook
5964
+ }
5965
+ ) : null,
5966
+ showIdleFollowUps ? /* @__PURE__ */ jsx16("div", { className: "agent-rail__followups-slot", children: /* @__PURE__ */ jsx16(
5967
+ FollowUpChips,
5968
+ {
5969
+ suggestions: state.followUps,
5970
+ disabled: isBusy,
5971
+ label: "Start here",
5972
+ onSelect: (suggestion) => handleFollowUpSelect(suggestion.label)
5973
+ }
5974
+ ) }) : null,
5975
+ showActivity ? /* @__PURE__ */ jsx16(
5976
+ AgentActivityBubble,
5977
+ {
5978
+ brandLabel: resolvedBrandLabel,
5979
+ brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5980
+ failed: state.phase === "error",
5981
+ steps: state.toolSteps
5982
+ }
5983
+ ) : null,
5984
+ visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx16(
5985
+ VisitorToolResultView,
5986
+ {
5987
+ result,
5988
+ disabled: semanticSurfaceDisabled,
5989
+ onToolInput
5990
+ },
5991
+ result.id
5992
+ )),
5993
+ pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx16(
5994
+ HumanInputCard,
5995
+ {
5996
+ request,
5997
+ onRespond: onInputResponse
5998
+ },
5999
+ request.requestId
6000
+ ))
6001
+ ] }) : null,
6002
+ visibleMessages.map((message, index) => /* @__PURE__ */ jsxs15("div", { className: "agent-rail__turn-block", children: [
6003
+ /* @__PURE__ */ jsx16(
6004
+ MessageBubble,
6005
+ {
6006
+ message,
6007
+ bookingDisabled: isBusy,
6008
+ brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6009
+ offer: index === lastAgentIndex ? state.pendingOffer : void 0,
6010
+ onBook
6011
+ }
6012
+ ),
6013
+ index === lastAgentIndex && showMessageActions && message.role === "agent" ? /* @__PURE__ */ jsx16(
6014
+ MessageActions,
6015
+ {
6016
+ answeredAt: message.createdAt,
6017
+ copyText: hideToolCardFences(message.text).trim() || message.text,
6018
+ readAloud,
6019
+ receiptSteps,
6020
+ onOpenReceipt: receiptSteps ? openReceipt : void 0,
6021
+ onRegenerate: onRegenerate ? handleRegenerate : void 0,
6022
+ onFeedback: onFeedback ? (rating) => onFeedback(rating, message) : void 0
6023
+ }
6024
+ ) : null,
6025
+ index === lastVisitorIndex ? /* @__PURE__ */ jsxs15(Fragment, { children: [
6026
+ showActivity ? /* @__PURE__ */ jsx16(
6027
+ AgentActivityBubble,
6028
+ {
6029
+ brandLabel: resolvedBrandLabel,
6030
+ brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6031
+ failed: state.phase === "error",
6032
+ steps: state.toolSteps
6033
+ }
6034
+ ) : null,
6035
+ visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx16(
6036
+ VisitorToolResultView,
6037
+ {
6038
+ result,
6039
+ disabled: semanticSurfaceDisabled,
6040
+ onToolInput
6041
+ },
6042
+ result.id
6043
+ )),
6044
+ pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx16(
6045
+ HumanInputCard,
6046
+ {
6047
+ request,
6048
+ onRespond: onInputResponse
6049
+ },
6050
+ request.requestId
6051
+ ))
6052
+ ] }) : null
6053
+ ] }, message.id)),
6054
+ streamingMessage ? /* @__PURE__ */ jsx16(
6055
+ MessageBubble,
6056
+ {
6057
+ message: streamingMessage,
6058
+ bookingDisabled: isBusy,
6059
+ brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
6060
+ offer: state.pendingOffer,
6061
+ onBook
6062
+ }
6063
+ ) : null,
6064
+ waitingForBooking ? /* @__PURE__ */ jsx16(BookingCardLoader, {}) : null,
6065
+ state.error ? /* @__PURE__ */ jsxs15("section", { className: "agent-rail__error", role: "alert", children: [
6066
+ /* @__PURE__ */ jsxs15("div", { children: [
6067
+ /* @__PURE__ */ jsx16("strong", { children: "Something went wrong" }),
6068
+ /* @__PURE__ */ jsx16("p", { children: state.error })
6069
+ ] }),
6070
+ onRetry ? /* @__PURE__ */ jsx16("button", { type: "button", onClick: onRetry, children: "Try again" }) : null
6071
+ ] }) : null
6072
+ ] }) }),
6073
+ showDisclaimerLabel ? /* @__PURE__ */ jsx16("div", { className: "agent-rail__disclaimer", children: /* @__PURE__ */ jsx16("p", { children: resolvedDisclaimerLabel }) }) : null,
6074
+ /* @__PURE__ */ jsxs15("div", { className: "agent-rail__composer-wrap", children: [
6075
+ showJumpToLatest ? /* @__PURE__ */ jsx16(
6076
+ "button",
6077
+ {
6078
+ type: "button",
6079
+ className: "agent-rail__jump-to-latest",
6080
+ "aria-label": "Jump to the latest message",
6081
+ title: "Jump to the latest message",
6082
+ onClick: scrollToLatest,
6083
+ children: /* @__PURE__ */ jsx16(ChevronDownIcon, {})
6084
+ }
6085
+ ) : null,
6086
+ /* @__PURE__ */ jsx16(
6087
+ Composer,
6088
+ {
6089
+ variant: expanded || mobileFullscreen ? "dock" : "default",
6090
+ disabled: isBusy,
6091
+ form: composerForm,
6092
+ placeholder: composerPlaceholder,
6093
+ onSubmit: handleSubmit
6094
+ }
6095
+ ),
6096
+ poweredByLabel ? /* @__PURE__ */ jsx16("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsx16("p", { children: /* @__PURE__ */ jsx16("span", { children: poweredByLabel }) }) }) : null
6097
+ ] })
6098
+ ] }),
6099
+ /* @__PURE__ */ jsx16("div", { ref: overlayRef, className: "agent-rail__overlay" }),
6100
+ receiptOpen && receiptSteps ? /* @__PURE__ */ jsx16(
6101
+ AnswerReceiptDialog,
5127
6102
  {
5128
6103
  brandLabel: resolvedBrandLabel,
5129
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5130
- failed: state.phase === "error",
5131
- steps: state.toolSteps
5132
- }
5133
- ) : null,
5134
- visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx14(
5135
- VisitorToolResultView,
5136
- {
5137
- result,
5138
- disabled: semanticSurfaceDisabled,
5139
- onToolInput
5140
- },
5141
- result.id
5142
- )),
5143
- pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx14(
5144
- HumanInputCard,
5145
- {
5146
- request,
5147
- onRespond: onInputResponse
5148
- },
5149
- request.requestId
5150
- ))
5151
- ] }) : null,
5152
- visibleMessages.map((message, index) => /* @__PURE__ */ jsxs13("div", { className: "agent-rail__turn-block", children: [
5153
- /* @__PURE__ */ jsx14(
5154
- MessageBubble,
5155
- {
5156
- message,
5157
- bookingDisabled: isBusy,
5158
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5159
- offer: index === lastAgentIndex ? state.pendingOffer : void 0,
5160
- onBook
6104
+ onClose: () => setReceiptOpen(false),
6105
+ steps: receiptSteps
5161
6106
  }
5162
- ),
5163
- index === lastVisitorIndex ? /* @__PURE__ */ jsxs13(Fragment, { children: [
5164
- showActivity ? /* @__PURE__ */ jsx14(
5165
- AgentActivityBubble,
5166
- {
5167
- brandLabel: resolvedBrandLabel,
5168
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5169
- failed: state.phase === "error",
5170
- steps: state.toolSteps
5171
- }
5172
- ) : null,
5173
- visibleVisitorToolResults.map((result) => /* @__PURE__ */ jsx14(
5174
- VisitorToolResultView,
5175
- {
5176
- result,
5177
- disabled: semanticSurfaceDisabled,
5178
- onToolInput
5179
- },
5180
- result.id
5181
- )),
5182
- pendingInputRequests.slice(0, 1).map((request) => /* @__PURE__ */ jsx14(
5183
- HumanInputCard,
5184
- {
5185
- request,
5186
- onRespond: onInputResponse
5187
- },
5188
- request.requestId
5189
- ))
5190
- ] }) : null
5191
- ] }, message.id)),
5192
- streamingMessage ? /* @__PURE__ */ jsx14(
5193
- MessageBubble,
5194
- {
5195
- message: streamingMessage,
5196
- bookingDisabled: isBusy,
5197
- brandLogoUrl: showBrandLogo ? resolvedBrandLogoUrl : void 0,
5198
- offer: state.pendingOffer,
5199
- onBook
5200
- }
5201
- ) : null,
5202
- waitingForBooking ? /* @__PURE__ */ jsx14(BookingCardLoader, {}) : null,
5203
- state.error ? /* @__PURE__ */ jsxs13("section", { className: "agent-rail__error", role: "alert", children: [
5204
- /* @__PURE__ */ jsxs13("div", { children: [
5205
- /* @__PURE__ */ jsx14("strong", { children: "Something went wrong" }),
5206
- /* @__PURE__ */ jsx14("p", { children: state.error })
5207
- ] }),
5208
- onRetry ? /* @__PURE__ */ jsx14("button", { type: "button", onClick: onRetry, children: "Try again" }) : null
5209
- ] }) : null
5210
- ] }) }),
5211
- /* @__PURE__ */ jsxs13("div", { className: "agent-rail__composer-wrap", children: [
5212
- /* @__PURE__ */ jsx14(
5213
- Composer,
5214
- {
5215
- variant: expanded || mobileFullscreen ? "dock" : "default",
5216
- disabled: isBusy,
5217
- form: composerForm,
5218
- placeholder: composerPlaceholder,
5219
- onSubmit
5220
- }
5221
- ),
5222
- /* @__PURE__ */ jsx14("div", { className: "agent-rail__footer", children: /* @__PURE__ */ jsxs13("p", { children: [
5223
- /* @__PURE__ */ jsx14("span", { children: "AI can make mistakes. Check important info." }),
5224
- /* @__PURE__ */ jsx14("span", { children: poweredByLabel })
5225
- ] }) })
5226
- ] })
5227
- ]
6107
+ ) : null
6108
+ ]
6109
+ }
6110
+ )
5228
6111
  }
5229
6112
  );
5230
6113
  }
5231
6114
 
5232
6115
  // src/react/components/AssistEdgeTab/AssistEdgeTab.tsx
5233
- import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
6116
+ import { Fragment as Fragment2, jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
5234
6117
  function SparklesIcon() {
5235
- return /* @__PURE__ */ jsxs14(
6118
+ return /* @__PURE__ */ jsxs16(
5236
6119
  "svg",
5237
6120
  {
5238
6121
  className: "assist-edge-tab__sparkles",
@@ -5240,21 +6123,21 @@ function SparklesIcon() {
5240
6123
  fill: "none",
5241
6124
  "aria-hidden": "true",
5242
6125
  children: [
5243
- /* @__PURE__ */ jsx15(
6126
+ /* @__PURE__ */ jsx17(
5244
6127
  "path",
5245
6128
  {
5246
6129
  d: "M8 1.2l.95 2.7 2.85.05-2.25 1.75.8 2.75L8 6.7 5.65 8.45l.8-2.75L4.2 3.95l2.85-.05L8 1.2z",
5247
6130
  fill: "currentColor"
5248
6131
  }
5249
6132
  ),
5250
- /* @__PURE__ */ jsx15(
6133
+ /* @__PURE__ */ jsx17(
5251
6134
  "path",
5252
6135
  {
5253
6136
  d: "M14.2 6.4l.55 1.55 1.65.03-1.3 1 .46 1.58-1.36-1-1.36 1 .46-1.58-1.3-1 1.65-.03.55-1.55z",
5254
6137
  fill: "currentColor"
5255
6138
  }
5256
6139
  ),
5257
- /* @__PURE__ */ jsx15(
6140
+ /* @__PURE__ */ jsx17(
5258
6141
  "path",
5259
6142
  {
5260
6143
  d: "M3.1 9.1l.4 1.15 1.22.02-.96.74.34 1.17-1-.74-1 .74.34-1.17-.96-.74 1.22-.02.4-1.15z",
@@ -5268,7 +6151,7 @@ function SparklesIcon() {
5268
6151
  function TabMarkIcon({ customIconUrl }) {
5269
6152
  const url = customIconUrl?.trim();
5270
6153
  if (url) {
5271
- return /* @__PURE__ */ jsx15(
6154
+ return /* @__PURE__ */ jsx17(
5272
6155
  "img",
5273
6156
  {
5274
6157
  alt: "",
@@ -5278,10 +6161,10 @@ function TabMarkIcon({ customIconUrl }) {
5278
6161
  }
5279
6162
  );
5280
6163
  }
5281
- return /* @__PURE__ */ jsx15(SparklesIcon, {});
6164
+ return /* @__PURE__ */ jsx17(SparklesIcon, {});
5282
6165
  }
5283
6166
  function ChevronLeftIcon() {
5284
- return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx15(
6167
+ return /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(
5285
6168
  "path",
5286
6169
  {
5287
6170
  d: "M10 4L6 8l4 4",
@@ -5292,8 +6175,8 @@ function ChevronLeftIcon() {
5292
6175
  }
5293
6176
  ) });
5294
6177
  }
5295
- function ChevronDownIcon() {
5296
- return /* @__PURE__ */ jsx15("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx15(
6178
+ function ChevronDownIcon2() {
6179
+ return /* @__PURE__ */ jsx17("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx17(
5297
6180
  "path",
5298
6181
  {
5299
6182
  d: "M4 6l4 4 4-4",
@@ -5305,7 +6188,7 @@ function ChevronDownIcon() {
5305
6188
  ) });
5306
6189
  }
5307
6190
  function DragDots() {
5308
- return /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__dots", "aria-hidden": "true", children: Array.from({ length: 12 }, (_, index) => /* @__PURE__ */ jsx15("i", {}, index)) });
6191
+ return /* @__PURE__ */ jsx17("span", { className: "assist-edge-tab__dots", "aria-hidden": "true", children: Array.from({ length: 12 }, (_, index) => /* @__PURE__ */ jsx17("i", {}, index)) });
5309
6192
  }
5310
6193
  var VARIANT_COPY = {
5311
6194
  outline: { label: "Ask anything", aria: "Ask anything" },
@@ -5351,7 +6234,7 @@ function AssistEdgeTab({
5351
6234
  ...resolvedTextColor ? { "--as-text": resolvedTextColor } : {},
5352
6235
  colorScheme: resolvedColorScheme
5353
6236
  };
5354
- return /* @__PURE__ */ jsxs14(
6237
+ return /* @__PURE__ */ jsxs16(
5355
6238
  "button",
5356
6239
  {
5357
6240
  type: "button",
@@ -5363,15 +6246,15 @@ function AssistEdgeTab({
5363
6246
  tabIndex: visible ? 0 : -1,
5364
6247
  onClick: onOpen,
5365
6248
  children: [
5366
- mobile ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5367
- /* @__PURE__ */ jsxs14(
6249
+ mobile ? /* @__PURE__ */ jsxs16(Fragment2, { children: [
6250
+ /* @__PURE__ */ jsxs16(
5368
6251
  "span",
5369
6252
  {
5370
6253
  className: "assist-edge-tab__mark assist-edge-tab__mark--mobile",
5371
6254
  "aria-hidden": "true",
5372
6255
  children: [
5373
- /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5374
- showLogo ? /* @__PURE__ */ jsx15(
6256
+ /* @__PURE__ */ jsx17(TabMarkIcon, { customIconUrl }),
6257
+ showLogo ? /* @__PURE__ */ jsx17(
5375
6258
  "img",
5376
6259
  {
5377
6260
  className: "assist-edge-tab__logo",
@@ -5385,11 +6268,11 @@ function AssistEdgeTab({
5385
6268
  ]
5386
6269
  }
5387
6270
  ),
5388
- /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel })
5389
- ] }) : variant === "outline" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5390
- /* @__PURE__ */ jsxs14("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
5391
- /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5392
- showLogo ? /* @__PURE__ */ jsx15(
6271
+ /* @__PURE__ */ jsx17("span", { className: "assist-edge-tab__label", children: visibleLabel })
6272
+ ] }) : variant === "outline" ? /* @__PURE__ */ jsxs16(Fragment2, { children: [
6273
+ /* @__PURE__ */ jsxs16("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
6274
+ /* @__PURE__ */ jsx17(TabMarkIcon, { customIconUrl }),
6275
+ showLogo ? /* @__PURE__ */ jsx17(
5393
6276
  "img",
5394
6277
  {
5395
6278
  className: "assist-edge-tab__logo",
@@ -5401,18 +6284,18 @@ function AssistEdgeTab({
5401
6284
  }
5402
6285
  ) : null
5403
6286
  ] }),
5404
- /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5405
- /* @__PURE__ */ jsx15(ChevronDownIcon, {})
6287
+ /* @__PURE__ */ jsx17("span", { className: "assist-edge-tab__label", children: visibleLabel }),
6288
+ /* @__PURE__ */ jsx17(ChevronDownIcon2, {})
5406
6289
  ] }) : null,
5407
- variant === "ask" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5408
- /* @__PURE__ */ jsx15(ChevronLeftIcon, {}),
5409
- /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5410
- /* @__PURE__ */ jsx15(DragDots, {})
6290
+ variant === "ask" ? /* @__PURE__ */ jsxs16(Fragment2, { children: [
6291
+ /* @__PURE__ */ jsx17(ChevronLeftIcon, {}),
6292
+ /* @__PURE__ */ jsx17("span", { className: "assist-edge-tab__label", children: visibleLabel }),
6293
+ /* @__PURE__ */ jsx17(DragDots, {})
5411
6294
  ] }) : null,
5412
- variant === "fill" ? /* @__PURE__ */ jsxs14(Fragment2, { children: [
5413
- /* @__PURE__ */ jsxs14("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
5414
- /* @__PURE__ */ jsx15(TabMarkIcon, { customIconUrl }),
5415
- showLogo ? /* @__PURE__ */ jsx15(
6295
+ variant === "fill" ? /* @__PURE__ */ jsxs16(Fragment2, { children: [
6296
+ /* @__PURE__ */ jsxs16("span", { className: "assist-edge-tab__mark", "aria-hidden": "true", children: [
6297
+ /* @__PURE__ */ jsx17(TabMarkIcon, { customIconUrl }),
6298
+ showLogo ? /* @__PURE__ */ jsx17(
5416
6299
  "img",
5417
6300
  {
5418
6301
  className: "assist-edge-tab__logo",
@@ -5424,19 +6307,75 @@ function AssistEdgeTab({
5424
6307
  }
5425
6308
  ) : null
5426
6309
  ] }),
5427
- /* @__PURE__ */ jsx15("span", { className: "assist-edge-tab__label", children: visibleLabel }),
5428
- /* @__PURE__ */ jsx15(ChevronLeftIcon, {})
6310
+ /* @__PURE__ */ jsx17("span", { className: "assist-edge-tab__label", children: visibleLabel }),
6311
+ /* @__PURE__ */ jsx17(ChevronLeftIcon, {})
5429
6312
  ] }) : null
5430
6313
  ]
5431
6314
  }
5432
6315
  );
5433
6316
  }
5434
6317
 
6318
+ // src/react/lib/agent-feedback.ts
6319
+ var AGENT_ANSWER_FEEDBACK_EVENT_TYPE = "agent_answer_feedback";
6320
+ function findPrecedingVisitorText(messages, agentMessageId) {
6321
+ const agentIndex = messages.findIndex(
6322
+ (message) => message.id === agentMessageId && message.role === "agent"
6323
+ );
6324
+ if (agentIndex < 0) return void 0;
6325
+ for (let index = agentIndex - 1; index >= 0; index -= 1) {
6326
+ const message = messages[index];
6327
+ if (message?.role === "visitor") {
6328
+ return message.text.trim() || void 0;
6329
+ }
6330
+ }
6331
+ return void 0;
6332
+ }
6333
+ function normalizeAgentFeedbackAnswerText(text) {
6334
+ const normalized = text.replace(/\s+/g, " ").trim();
6335
+ if (!normalized) return void 0;
6336
+ return normalized.length > 4e3 ? `${normalized.slice(0, 3997)}...` : normalized;
6337
+ }
6338
+ function buildAgentAnswerFeedbackEvent(input) {
6339
+ const positive = input.rating === "positive";
6340
+ const answer = input.answer ? normalizeAgentFeedbackAnswerText(input.answer) : void 0;
6341
+ return {
6342
+ event_type: AGENT_ANSWER_FEEDBACK_EVENT_TYPE,
6343
+ company: input.analytics.companyIndex,
6344
+ session_id: input.visitorSessionId,
6345
+ page: input.page,
6346
+ timestamp: Date.now(),
6347
+ tracking_consent: input.analytics.trackingConsent,
6348
+ feedback_value: positive ? 1 : -1,
6349
+ // Aggregate-safe rating enum, kept even for anonymous (no-consent) events.
6350
+ feedback_rating: positive ? "helpful" : "not_helpful",
6351
+ surface: "agent_panel",
6352
+ index_id: input.indexId,
6353
+ index_version: input.version,
6354
+ message_id: input.messageId,
6355
+ ...input.agentSessionId ? { agent_session_id: input.agentSessionId } : {},
6356
+ ...input.analytics.trackingConsent && input.query ? { query: input.query } : {},
6357
+ ...input.analytics.trackingConsent && answer ? { answer } : {}
6358
+ };
6359
+ }
6360
+ function sendAgentAnswerFeedback(eventUrl, event) {
6361
+ try {
6362
+ void fetch(eventUrl, {
6363
+ body: JSON.stringify(event),
6364
+ credentials: "omit",
6365
+ headers: { "Content-Type": "application/json" },
6366
+ keepalive: true,
6367
+ method: "POST"
6368
+ }).catch(() => {
6369
+ });
6370
+ } catch {
6371
+ }
6372
+ }
6373
+
5435
6374
  // src/react/components/AgentWidget/AgentWidget.tsx
5436
- import { useEffect as useEffect7, useRef as useRef5, useState as useState10 } from "react";
6375
+ import { useEffect as useEffect9, useRef as useRef7, useState as useState11 } from "react";
5437
6376
 
5438
6377
  // src/react/page-shift.ts
5439
- import { useEffect as useEffect5 } from "react";
6378
+ import { useEffect as useEffect7 } from "react";
5440
6379
  var PAGE_SHIFT_CLASS = "webless-agent-page-shift";
5441
6380
  var DEFAULT_RAIL_WIDTH_PX = 450;
5442
6381
  function shouldApplyPageShift(input) {
@@ -5488,7 +6427,7 @@ function clearPageMargin() {
5488
6427
  }
5489
6428
  function usePageShift(input) {
5490
6429
  const { active, railSlotRef } = input;
5491
- useEffect5(() => {
6430
+ useEffect7(() => {
5492
6431
  if (typeof document === "undefined") {
5493
6432
  return;
5494
6433
  }
@@ -5516,12 +6455,12 @@ function usePageShift(input) {
5516
6455
  }
5517
6456
 
5518
6457
  // src/react/hooks/useIsMobile.ts
5519
- import { useEffect as useEffect6, useState as useState9 } from "react";
6458
+ import { useEffect as useEffect8, useState as useState10 } from "react";
5520
6459
  function useIsMobile(breakpoint = 767) {
5521
- const [isMobile, setIsMobile] = useState9(
6460
+ const [isMobile, setIsMobile] = useState10(
5522
6461
  () => typeof window !== "undefined" && window.matchMedia(`(max-width: ${breakpoint}px)`).matches
5523
6462
  );
5524
- useEffect6(() => {
6463
+ useEffect8(() => {
5525
6464
  const media = window.matchMedia(`(max-width: ${breakpoint}px)`);
5526
6465
  const onChange = () => setIsMobile(media.matches);
5527
6466
  onChange();
@@ -5532,7 +6471,7 @@ function useIsMobile(breakpoint = 767) {
5532
6471
  }
5533
6472
 
5534
6473
  // src/react/components/AgentWidget/AgentWidget.tsx
5535
- import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
6474
+ import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
5536
6475
  function AgentWidget({
5537
6476
  indexId,
5538
6477
  customerId,
@@ -5546,13 +6485,14 @@ function AgentWidget({
5546
6485
  registerPanelController = false,
5547
6486
  colorScheme = "auto",
5548
6487
  branding,
6488
+ analytics,
5549
6489
  toolResultRegistry
5550
6490
  }) {
5551
6491
  const isMobile = useIsMobile();
5552
6492
  const placement = normalizeAgentPlacement(placementInput);
5553
- const railSlotRef = useRef5(null);
5554
- const [railCollapsed, setRailCollapsed] = useState10(defaultCollapsed);
5555
- const [railExpanded, setRailExpanded] = useState10(false);
6493
+ const railSlotRef = useRef7(null);
6494
+ const [railCollapsed, setRailCollapsed] = useState11(defaultCollapsed);
6495
+ const [railExpanded, setRailExpanded] = useState11(false);
5556
6496
  const pageShiftActive = shouldApplyPageShift({
5557
6497
  pageShift,
5558
6498
  isMobile,
@@ -5563,7 +6503,17 @@ function AgentWidget({
5563
6503
  active: pageShiftActive,
5564
6504
  railSlotRef
5565
6505
  });
5566
- const { state, reset, retry, respondToInput, respondToToolInput, submit } = useAgentChat({
6506
+ const {
6507
+ state,
6508
+ reset,
6509
+ retry,
6510
+ regenerate,
6511
+ respondToInput,
6512
+ respondToToolInput,
6513
+ submit,
6514
+ visitorSessionId,
6515
+ sessionId
6516
+ } = useAgentChat({
5567
6517
  customerId,
5568
6518
  getUnpublishedPreviewGrant,
5569
6519
  indexId,
@@ -5595,7 +6545,7 @@ function AgentWidget({
5595
6545
  } : {},
5596
6546
  ...branding?.colors?.border ? { border: branding.colors.border } : {}
5597
6547
  };
5598
- useEffect7(() => {
6548
+ useEffect9(() => {
5599
6549
  if (!registerPanelController) return;
5600
6550
  registerAgentPanelController(customerId, {
5601
6551
  open: () => setRailCollapsed(false),
@@ -5612,7 +6562,25 @@ function AgentWidget({
5612
6562
  if (isMobile) setRailCollapsed(false);
5613
6563
  await submit(message);
5614
6564
  }
5615
- useEffect7(() => {
6565
+ function handleFeedback(rating, message) {
6566
+ if (!analytics) return;
6567
+ sendAgentAnswerFeedback(
6568
+ analytics.eventUrl,
6569
+ buildAgentAnswerFeedbackEvent({
6570
+ agentSessionId: sessionId,
6571
+ analytics,
6572
+ indexId,
6573
+ messageId: message.id,
6574
+ page: window.location.href,
6575
+ query: findPrecedingVisitorText(state.messages, message.id),
6576
+ answer: message.text,
6577
+ rating,
6578
+ version: version ?? "published",
6579
+ visitorSessionId
6580
+ })
6581
+ );
6582
+ }
6583
+ useEffect9(() => {
5616
6584
  if (railCollapsed) return;
5617
6585
  const handleKeyDown = (event) => {
5618
6586
  if (event.key === "Tab" && (isMobile || railExpanded)) {
@@ -5646,19 +6614,19 @@ function AgentWidget({
5646
6614
  window.addEventListener("keydown", handleKeyDown);
5647
6615
  return () => window.removeEventListener("keydown", handleKeyDown);
5648
6616
  }, [isMobile, railCollapsed, railExpanded]);
5649
- return /* @__PURE__ */ jsxs15("div", { className: "webless-agent-root", children: [
5650
- /* @__PURE__ */ jsx16(
6617
+ return /* @__PURE__ */ jsxs17("div", { className: "webless-agent-root", children: [
6618
+ /* @__PURE__ */ jsx18(
5651
6619
  "div",
5652
6620
  {
5653
6621
  className: `webless-agent-root__shell${railCollapsed ? " webless-agent-root__shell--collapsed" : ""}${railExpanded ? " webless-agent-root__shell--expanded" : ""}`,
5654
- children: /* @__PURE__ */ jsx16(
6622
+ children: /* @__PURE__ */ jsx18(
5655
6623
  "div",
5656
6624
  {
5657
6625
  ref: railSlotRef,
5658
6626
  className: "webless-agent-root__rail-slot",
5659
6627
  inert: railCollapsed || void 0,
5660
6628
  "aria-hidden": railCollapsed,
5661
- children: /* @__PURE__ */ jsx16(
6629
+ children: /* @__PURE__ */ jsx18(
5662
6630
  AgentRail,
5663
6631
  {
5664
6632
  theme,
@@ -5667,6 +6635,9 @@ function AgentWidget({
5667
6635
  brandLogoUrl: branding?.logoUrl,
5668
6636
  composerPlaceholder: branding?.composerPlaceholder ?? "Ask a question\u2026",
5669
6637
  poweredByLabel: branding?.poweredByLabel ?? "Powered by Webless",
6638
+ disclaimerLabel: branding?.disclaimer,
6639
+ answerReceipt: branding?.answerReceipt,
6640
+ readAloud: branding?.readAloud,
5670
6641
  state,
5671
6642
  mobileFullscreen: isMobile && !railCollapsed,
5672
6643
  expanded: railExpanded,
@@ -5676,6 +6647,8 @@ function AgentWidget({
5676
6647
  onSubmit: handleSubmit,
5677
6648
  onReset: reset,
5678
6649
  onRetry: () => void retry(),
6650
+ onRegenerate: () => void regenerate(),
6651
+ onFeedback: analytics ? handleFeedback : void 0,
5679
6652
  onInputResponse: (response) => void respondToInput(response),
5680
6653
  onToolInput: (surface, values) => void respondToToolInput(surface, values),
5681
6654
  onFollowUpSelect: (label) => void handleSubmit(label),
@@ -5689,7 +6662,7 @@ function AgentWidget({
5689
6662
  )
5690
6663
  }
5691
6664
  ),
5692
- railCollapsed ? /* @__PURE__ */ jsx16(
6665
+ railCollapsed ? /* @__PURE__ */ jsx18(
5693
6666
  AssistEdgeTab,
5694
6667
  {
5695
6668
  variant: placement.variant,
@@ -5734,8 +6707,13 @@ export {
5734
6707
  submitAgentPanel,
5735
6708
  defaultAgentRailTheme,
5736
6709
  defaultDarkAgentRailTheme,
6710
+ MessageActions,
5737
6711
  AgentRail,
5738
6712
  AssistEdgeTab,
6713
+ AGENT_ANSWER_FEEDBACK_EVENT_TYPE,
6714
+ findPrecedingVisitorText,
6715
+ buildAgentAnswerFeedbackEvent,
6716
+ sendAgentAnswerFeedback,
5739
6717
  AgentWidget
5740
6718
  };
5741
- //# sourceMappingURL=chunk-YNF2UPGJ.js.map
6719
+ //# sourceMappingURL=chunk-CYI3OSWG.js.map