@runtypelabs/persona 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/index.cjs +40 -40
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +73 -4
  4. package/dist/index.d.ts +73 -4
  5. package/dist/index.global.js +69 -69
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +40 -40
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme-editor.cjs +704 -243
  10. package/dist/theme-editor.d.cts +75 -5
  11. package/dist/theme-editor.d.ts +75 -5
  12. package/dist/theme-editor.js +703 -243
  13. package/dist/theme-reference.cjs +1 -1
  14. package/dist/theme-reference.d.cts +53 -0
  15. package/dist/theme-reference.d.ts +53 -0
  16. package/dist/theme-reference.js +1 -1
  17. package/dist/widget.css +44 -0
  18. package/package.json +1 -1
  19. package/src/components/artifact-card.ts +1 -1
  20. package/src/components/demo-carousel.ts +1 -1
  21. package/src/components/event-stream-view.test.ts +142 -0
  22. package/src/components/event-stream-view.ts +67 -28
  23. package/src/components/header-builder.ts +3 -0
  24. package/src/components/launcher.ts +7 -2
  25. package/src/components/panel.ts +3 -1
  26. package/src/defaults.ts +15 -0
  27. package/src/runtime/host-layout.test.ts +1 -1
  28. package/src/runtime/host-layout.ts +2 -1
  29. package/src/scroll-to-bottom-defaults.test.ts +13 -0
  30. package/src/styles/widget.css +44 -0
  31. package/src/theme-editor/index.ts +1 -0
  32. package/src/theme-editor/role-mappings.ts +12 -0
  33. package/src/theme-editor/sections.test.ts +43 -0
  34. package/src/theme-editor/sections.ts +42 -0
  35. package/src/theme-reference.ts +8 -0
  36. package/src/types/theme.ts +45 -0
  37. package/src/types.ts +31 -4
  38. package/src/ui.overlay-z-index.test.ts +34 -2
  39. package/src/ui.scroll.test.ts +554 -0
  40. package/src/ui.ts +264 -90
  41. package/src/utils/auto-follow.test.ts +110 -0
  42. package/src/utils/auto-follow.ts +112 -0
  43. package/src/utils/constants.ts +13 -0
  44. package/src/utils/dropdown.ts +2 -1
  45. package/src/utils/overlay-host-stacking.test.ts +61 -0
  46. package/src/utils/overlay-host-stacking.ts +38 -0
  47. package/src/utils/scroll-lock.test.ts +64 -0
  48. package/src/utils/scroll-lock.ts +62 -0
  49. package/src/utils/theme.test.ts +34 -0
  50. package/src/utils/tokens.ts +112 -0
@@ -299,7 +299,8 @@ var DEFAULT_COMPONENTS = {
299
299
  borderRadius: "palette.radius.lg",
300
300
  border: "palette.colors.gray.200",
301
301
  shadow: "palette.shadows.sm"
302
- }
302
+ },
303
+ border: "semantic.colors.border"
303
304
  },
304
305
  toolBubble: {
305
306
  shadow: "palette.shadows.sm"
@@ -321,8 +322,30 @@ var DEFAULT_COMPONENTS = {
321
322
  },
322
323
  prose: {
323
324
  fontFamily: "inherit"
325
+ },
326
+ codeBlock: {
327
+ background: "semantic.colors.container",
328
+ borderColor: "semantic.colors.border",
329
+ textColor: "inherit"
330
+ },
331
+ table: {
332
+ headerBackground: "semantic.colors.container",
333
+ borderColor: "semantic.colors.border"
334
+ },
335
+ hr: {
336
+ color: "semantic.colors.divider"
337
+ },
338
+ blockquote: {
339
+ borderColor: "palette.colors.gray.900",
340
+ background: "transparent",
341
+ textColor: "palette.colors.gray.500"
324
342
  }
325
343
  },
344
+ collapsibleWidget: {
345
+ container: "palette.colors.gray.50",
346
+ surface: "semantic.colors.surface",
347
+ border: "semantic.colors.border"
348
+ },
326
349
  voice: {
327
350
  recording: {
328
351
  indicator: "palette.colors.error.500",
@@ -362,6 +385,18 @@ var DEFAULT_COMPONENTS = {
362
385
  border: "palette.colors.gray.200"
363
386
  }
364
387
  },
388
+ scrollToBottom: {
389
+ background: "components.button.primary.background",
390
+ foreground: "components.button.primary.foreground",
391
+ border: "semantic.colors.primary",
392
+ size: "40px",
393
+ borderRadius: "palette.radius.full",
394
+ shadow: "palette.shadows.sm",
395
+ padding: "0.5rem 0.875rem",
396
+ gap: "0.5rem",
397
+ fontSize: "0.875rem",
398
+ iconSize: "14px"
399
+ },
365
400
  artifact: {
366
401
  pane: {
367
402
  background: "semantic.colors.container",
@@ -543,7 +578,7 @@ function createTheme(userConfig, options = {}) {
543
578
  return theme;
544
579
  }
545
580
  function themeToCssVariables(theme) {
546
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za;
581
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb;
547
582
  const resolved = resolveTokens(theme);
548
583
  const cssVars = {};
549
584
  for (const [path, token] of Object.entries(resolved)) {
@@ -583,44 +618,55 @@ function themeToCssVariables(theme) {
583
618
  cssVars["--persona-radius-md"] = (_B = cssVars["--persona-palette-radius-md"]) != null ? _B : "0.375rem";
584
619
  cssVars["--persona-radius-lg"] = (_C = cssVars["--persona-palette-radius-lg"]) != null ? _C : "0.5rem";
585
620
  cssVars["--persona-radius-xl"] = (_D = cssVars["--persona-palette-radius-xl"]) != null ? _D : "0.75rem";
586
- cssVars["--persona-launcher-radius"] = (_F = (_E = cssVars["--persona-components-launcher-borderRadius"]) != null ? _E : cssVars["--persona-palette-radius-full"]) != null ? _F : "9999px";
587
- cssVars["--persona-launcher-bg"] = (_G = cssVars["--persona-components-launcher-background"]) != null ? _G : cssVars["--persona-primary"];
588
- cssVars["--persona-launcher-fg"] = (_H = cssVars["--persona-components-launcher-foreground"]) != null ? _H : cssVars["--persona-text-inverse"];
589
- cssVars["--persona-launcher-border"] = (_I = cssVars["--persona-components-launcher-border"]) != null ? _I : cssVars["--persona-border"];
590
- cssVars["--persona-button-primary-bg"] = (_J = cssVars["--persona-components-button-primary-background"]) != null ? _J : cssVars["--persona-primary"];
591
- cssVars["--persona-button-primary-fg"] = (_K = cssVars["--persona-components-button-primary-foreground"]) != null ? _K : cssVars["--persona-text-inverse"];
592
- cssVars["--persona-button-radius"] = (_M = (_L = cssVars["--persona-components-button-primary-borderRadius"]) != null ? _L : cssVars["--persona-palette-radius-full"]) != null ? _M : "9999px";
593
- cssVars["--persona-panel-radius"] = (_O = (_N = cssVars["--persona-components-panel-borderRadius"]) != null ? _N : cssVars["--persona-radius-xl"]) != null ? _O : "0.75rem";
594
- cssVars["--persona-panel-border"] = (_P = cssVars["--persona-components-panel-border"]) != null ? _P : `1px solid ${cssVars["--persona-border"]}`;
595
- cssVars["--persona-panel-shadow"] = (_R = (_Q = cssVars["--persona-components-panel-shadow"]) != null ? _Q : cssVars["--persona-palette-shadows-xl"]) != null ? _R : "0 25px 50px -12px rgba(0, 0, 0, 0.25)";
596
- cssVars["--persona-input-radius"] = (_T = (_S = cssVars["--persona-components-input-borderRadius"]) != null ? _S : cssVars["--persona-radius-lg"]) != null ? _T : "0.5rem";
597
- cssVars["--persona-message-user-radius"] = (_V = (_U = cssVars["--persona-components-message-user-borderRadius"]) != null ? _U : cssVars["--persona-radius-lg"]) != null ? _V : "0.5rem";
598
- cssVars["--persona-message-assistant-radius"] = (_X = (_W = cssVars["--persona-components-message-assistant-borderRadius"]) != null ? _W : cssVars["--persona-radius-lg"]) != null ? _X : "0.5rem";
599
- cssVars["--persona-header-bg"] = (_Y = cssVars["--persona-components-header-background"]) != null ? _Y : cssVars["--persona-surface"];
600
- cssVars["--persona-header-border"] = (_Z = cssVars["--persona-components-header-border"]) != null ? _Z : cssVars["--persona-divider"];
601
- cssVars["--persona-header-icon-bg"] = (__ = cssVars["--persona-components-header-iconBackground"]) != null ? __ : cssVars["--persona-primary"];
602
- cssVars["--persona-header-icon-fg"] = (_$ = cssVars["--persona-components-header-iconForeground"]) != null ? _$ : cssVars["--persona-text-inverse"];
603
- cssVars["--persona-header-title-fg"] = (_aa = cssVars["--persona-components-header-titleForeground"]) != null ? _aa : cssVars["--persona-primary"];
604
- cssVars["--persona-header-subtitle-fg"] = (_ba = cssVars["--persona-components-header-subtitleForeground"]) != null ? _ba : cssVars["--persona-text-muted"];
605
- cssVars["--persona-header-action-icon-fg"] = (_ca = cssVars["--persona-components-header-actionIconForeground"]) != null ? _ca : cssVars["--persona-muted"];
606
- const headerTokens = (_da = theme.components) == null ? void 0 : _da.header;
621
+ cssVars["--persona-radius-full"] = (_E = cssVars["--persona-palette-radius-full"]) != null ? _E : "9999px";
622
+ cssVars["--persona-launcher-radius"] = (_G = (_F = cssVars["--persona-components-launcher-borderRadius"]) != null ? _F : cssVars["--persona-palette-radius-full"]) != null ? _G : "9999px";
623
+ cssVars["--persona-launcher-bg"] = (_H = cssVars["--persona-components-launcher-background"]) != null ? _H : cssVars["--persona-primary"];
624
+ cssVars["--persona-launcher-fg"] = (_I = cssVars["--persona-components-launcher-foreground"]) != null ? _I : cssVars["--persona-text-inverse"];
625
+ cssVars["--persona-launcher-border"] = (_J = cssVars["--persona-components-launcher-border"]) != null ? _J : cssVars["--persona-border"];
626
+ cssVars["--persona-button-primary-bg"] = (_K = cssVars["--persona-components-button-primary-background"]) != null ? _K : cssVars["--persona-primary"];
627
+ cssVars["--persona-button-primary-fg"] = (_L = cssVars["--persona-components-button-primary-foreground"]) != null ? _L : cssVars["--persona-text-inverse"];
628
+ cssVars["--persona-button-radius"] = (_N = (_M = cssVars["--persona-components-button-primary-borderRadius"]) != null ? _M : cssVars["--persona-palette-radius-full"]) != null ? _N : "9999px";
629
+ cssVars["--persona-panel-radius"] = (_P = (_O = cssVars["--persona-components-panel-borderRadius"]) != null ? _O : cssVars["--persona-radius-xl"]) != null ? _P : "0.75rem";
630
+ cssVars["--persona-panel-border"] = (_Q = cssVars["--persona-components-panel-border"]) != null ? _Q : `1px solid ${cssVars["--persona-border"]}`;
631
+ cssVars["--persona-panel-shadow"] = (_S = (_R = cssVars["--persona-components-panel-shadow"]) != null ? _R : cssVars["--persona-palette-shadows-xl"]) != null ? _S : "0 25px 50px -12px rgba(0, 0, 0, 0.25)";
632
+ cssVars["--persona-input-radius"] = (_U = (_T = cssVars["--persona-components-input-borderRadius"]) != null ? _T : cssVars["--persona-radius-lg"]) != null ? _U : "0.5rem";
633
+ cssVars["--persona-message-user-radius"] = (_W = (_V = cssVars["--persona-components-message-user-borderRadius"]) != null ? _V : cssVars["--persona-radius-lg"]) != null ? _W : "0.5rem";
634
+ cssVars["--persona-message-assistant-radius"] = (_Y = (_X = cssVars["--persona-components-message-assistant-borderRadius"]) != null ? _X : cssVars["--persona-radius-lg"]) != null ? _Y : "0.5rem";
635
+ cssVars["--persona-header-bg"] = (_Z = cssVars["--persona-components-header-background"]) != null ? _Z : cssVars["--persona-surface"];
636
+ cssVars["--persona-header-border"] = (__ = cssVars["--persona-components-header-border"]) != null ? __ : cssVars["--persona-divider"];
637
+ cssVars["--persona-header-icon-bg"] = (_$ = cssVars["--persona-components-header-iconBackground"]) != null ? _$ : cssVars["--persona-primary"];
638
+ cssVars["--persona-header-icon-fg"] = (_aa = cssVars["--persona-components-header-iconForeground"]) != null ? _aa : cssVars["--persona-text-inverse"];
639
+ cssVars["--persona-header-title-fg"] = (_ba = cssVars["--persona-components-header-titleForeground"]) != null ? _ba : cssVars["--persona-primary"];
640
+ cssVars["--persona-header-subtitle-fg"] = (_ca = cssVars["--persona-components-header-subtitleForeground"]) != null ? _ca : cssVars["--persona-text-muted"];
641
+ cssVars["--persona-header-action-icon-fg"] = (_da = cssVars["--persona-components-header-actionIconForeground"]) != null ? _da : cssVars["--persona-muted"];
642
+ const headerTokens = (_ea = theme.components) == null ? void 0 : _ea.header;
607
643
  if (headerTokens == null ? void 0 : headerTokens.shadow) cssVars["--persona-header-shadow"] = headerTokens.shadow;
608
644
  if (headerTokens == null ? void 0 : headerTokens.borderBottom) cssVars["--persona-header-border-bottom"] = headerTokens.borderBottom;
609
- cssVars["--persona-input-background"] = (_ea = cssVars["--persona-components-input-background"]) != null ? _ea : cssVars["--persona-surface"];
610
- cssVars["--persona-input-placeholder"] = (_fa = cssVars["--persona-components-input-placeholder"]) != null ? _fa : cssVars["--persona-text-muted"];
611
- cssVars["--persona-message-user-bg"] = (_ga = cssVars["--persona-components-message-user-background"]) != null ? _ga : cssVars["--persona-accent"];
612
- cssVars["--persona-message-user-text"] = (_ha = cssVars["--persona-components-message-user-text"]) != null ? _ha : cssVars["--persona-text-inverse"];
613
- cssVars["--persona-message-user-shadow"] = (_ia = cssVars["--persona-components-message-user-shadow"]) != null ? _ia : "0 5px 15px rgba(15, 23, 42, 0.08)";
614
- cssVars["--persona-message-assistant-bg"] = (_ja = cssVars["--persona-components-message-assistant-background"]) != null ? _ja : cssVars["--persona-surface"];
615
- cssVars["--persona-message-assistant-text"] = (_ka = cssVars["--persona-components-message-assistant-text"]) != null ? _ka : cssVars["--persona-text"];
616
- cssVars["--persona-message-assistant-border"] = (_la = cssVars["--persona-components-message-assistant-border"]) != null ? _la : cssVars["--persona-border"];
617
- cssVars["--persona-message-assistant-shadow"] = (_ma = cssVars["--persona-components-message-assistant-shadow"]) != null ? _ma : "0 1px 2px 0 rgb(0 0 0 / 0.05)";
618
- cssVars["--persona-tool-bubble-shadow"] = (_na = cssVars["--persona-components-toolBubble-shadow"]) != null ? _na : "0 5px 15px rgba(15, 23, 42, 0.08)";
619
- cssVars["--persona-reasoning-bubble-shadow"] = (_oa = cssVars["--persona-components-reasoningBubble-shadow"]) != null ? _oa : "0 5px 15px rgba(15, 23, 42, 0.08)";
620
- cssVars["--persona-composer-shadow"] = (_pa = cssVars["--persona-components-composer-shadow"]) != null ? _pa : "none";
621
- cssVars["--persona-md-inline-code-bg"] = (_qa = cssVars["--persona-components-markdown-inlineCode-background"]) != null ? _qa : cssVars["--persona-container"];
622
- cssVars["--persona-md-inline-code-color"] = (_ra = cssVars["--persona-components-markdown-inlineCode-foreground"]) != null ? _ra : cssVars["--persona-text"];
623
- cssVars["--persona-md-link-color"] = (_ta = (_sa = cssVars["--persona-components-markdown-link-foreground"]) != null ? _sa : cssVars["--persona-accent"]) != null ? _ta : "#0f0f0f";
645
+ cssVars["--persona-input-background"] = (_fa = cssVars["--persona-components-input-background"]) != null ? _fa : cssVars["--persona-surface"];
646
+ cssVars["--persona-input-placeholder"] = (_ga = cssVars["--persona-components-input-placeholder"]) != null ? _ga : cssVars["--persona-text-muted"];
647
+ cssVars["--persona-message-user-bg"] = (_ha = cssVars["--persona-components-message-user-background"]) != null ? _ha : cssVars["--persona-accent"];
648
+ cssVars["--persona-message-user-text"] = (_ia = cssVars["--persona-components-message-user-text"]) != null ? _ia : cssVars["--persona-text-inverse"];
649
+ cssVars["--persona-message-user-shadow"] = (_ja = cssVars["--persona-components-message-user-shadow"]) != null ? _ja : "0 5px 15px rgba(15, 23, 42, 0.08)";
650
+ cssVars["--persona-message-assistant-bg"] = (_ka = cssVars["--persona-components-message-assistant-background"]) != null ? _ka : cssVars["--persona-surface"];
651
+ cssVars["--persona-message-assistant-text"] = (_la = cssVars["--persona-components-message-assistant-text"]) != null ? _la : cssVars["--persona-text"];
652
+ cssVars["--persona-message-assistant-border"] = (_ma = cssVars["--persona-components-message-assistant-border"]) != null ? _ma : cssVars["--persona-border"];
653
+ cssVars["--persona-message-assistant-shadow"] = (_na = cssVars["--persona-components-message-assistant-shadow"]) != null ? _na : "0 1px 2px 0 rgb(0 0 0 / 0.05)";
654
+ cssVars["--persona-scroll-to-bottom-bg"] = (_pa = (_oa = cssVars["--persona-components-scrollToBottom-background"]) != null ? _oa : cssVars["--persona-button-primary-bg"]) != null ? _pa : cssVars["--persona-accent"];
655
+ cssVars["--persona-scroll-to-bottom-fg"] = (_ra = (_qa = cssVars["--persona-components-scrollToBottom-foreground"]) != null ? _qa : cssVars["--persona-button-primary-fg"]) != null ? _ra : cssVars["--persona-text-inverse"];
656
+ cssVars["--persona-scroll-to-bottom-border"] = (_sa = cssVars["--persona-components-scrollToBottom-border"]) != null ? _sa : cssVars["--persona-primary"];
657
+ cssVars["--persona-scroll-to-bottom-size"] = (_ta = cssVars["--persona-components-scrollToBottom-size"]) != null ? _ta : "40px";
658
+ cssVars["--persona-scroll-to-bottom-radius"] = (_wa = (_va = (_ua = cssVars["--persona-components-scrollToBottom-borderRadius"]) != null ? _ua : cssVars["--persona-button-radius"]) != null ? _va : cssVars["--persona-radius-full"]) != null ? _wa : "9999px";
659
+ cssVars["--persona-scroll-to-bottom-shadow"] = (_ya = (_xa = cssVars["--persona-components-scrollToBottom-shadow"]) != null ? _xa : cssVars["--persona-palette-shadows-sm"]) != null ? _ya : "0 1px 2px 0 rgb(0 0 0 / 0.05)";
660
+ cssVars["--persona-scroll-to-bottom-padding"] = (_za = cssVars["--persona-components-scrollToBottom-padding"]) != null ? _za : "0.5rem 0.875rem";
661
+ cssVars["--persona-scroll-to-bottom-gap"] = (_Aa = cssVars["--persona-components-scrollToBottom-gap"]) != null ? _Aa : "0.5rem";
662
+ cssVars["--persona-scroll-to-bottom-font-size"] = (_Ca = (_Ba = cssVars["--persona-components-scrollToBottom-fontSize"]) != null ? _Ba : cssVars["--persona-palette-typography-fontSize-sm"]) != null ? _Ca : "0.875rem";
663
+ cssVars["--persona-scroll-to-bottom-icon-size"] = (_Da = cssVars["--persona-components-scrollToBottom-iconSize"]) != null ? _Da : "14px";
664
+ cssVars["--persona-tool-bubble-shadow"] = (_Ea = cssVars["--persona-components-toolBubble-shadow"]) != null ? _Ea : "0 5px 15px rgba(15, 23, 42, 0.08)";
665
+ cssVars["--persona-reasoning-bubble-shadow"] = (_Fa = cssVars["--persona-components-reasoningBubble-shadow"]) != null ? _Fa : "0 5px 15px rgba(15, 23, 42, 0.08)";
666
+ cssVars["--persona-composer-shadow"] = (_Ga = cssVars["--persona-components-composer-shadow"]) != null ? _Ga : "none";
667
+ cssVars["--persona-md-inline-code-bg"] = (_Ha = cssVars["--persona-components-markdown-inlineCode-background"]) != null ? _Ha : cssVars["--persona-container"];
668
+ cssVars["--persona-md-inline-code-color"] = (_Ia = cssVars["--persona-components-markdown-inlineCode-foreground"]) != null ? _Ia : cssVars["--persona-text"];
669
+ cssVars["--persona-md-link-color"] = (_Ka = (_Ja = cssVars["--persona-components-markdown-link-foreground"]) != null ? _Ja : cssVars["--persona-accent"]) != null ? _Ka : "#0f0f0f";
624
670
  const mdH1Size = cssVars["--persona-components-markdown-heading-h1-fontSize"];
625
671
  if (mdH1Size) cssVars["--persona-md-h1-size"] = mdH1Size;
626
672
  const mdH1Weight = cssVars["--persona-components-markdown-heading-h1-fontWeight"];
@@ -633,6 +679,19 @@ function themeToCssVariables(theme) {
633
679
  if (mdProseFont && mdProseFont !== "inherit") {
634
680
  cssVars["--persona-md-prose-font-family"] = mdProseFont;
635
681
  }
682
+ cssVars["--persona-md-code-block-bg"] = (_La = cssVars["--persona-components-markdown-codeBlock-background"]) != null ? _La : cssVars["--persona-container"];
683
+ cssVars["--persona-md-code-block-border-color"] = (_Ma = cssVars["--persona-components-markdown-codeBlock-borderColor"]) != null ? _Ma : cssVars["--persona-border"];
684
+ cssVars["--persona-md-code-block-text-color"] = (_Na = cssVars["--persona-components-markdown-codeBlock-textColor"]) != null ? _Na : "inherit";
685
+ cssVars["--persona-md-table-header-bg"] = (_Oa = cssVars["--persona-components-markdown-table-headerBackground"]) != null ? _Oa : cssVars["--persona-container"];
686
+ cssVars["--persona-md-table-border-color"] = (_Pa = cssVars["--persona-components-markdown-table-borderColor"]) != null ? _Pa : cssVars["--persona-border"];
687
+ cssVars["--persona-md-hr-color"] = (_Qa = cssVars["--persona-components-markdown-hr-color"]) != null ? _Qa : cssVars["--persona-divider"];
688
+ cssVars["--persona-md-blockquote-border-color"] = (_Ra = cssVars["--persona-components-markdown-blockquote-borderColor"]) != null ? _Ra : cssVars["--persona-palette-colors-gray-900"];
689
+ cssVars["--persona-md-blockquote-bg"] = (_Sa = cssVars["--persona-components-markdown-blockquote-background"]) != null ? _Sa : "transparent";
690
+ cssVars["--persona-md-blockquote-text-color"] = (_Ta = cssVars["--persona-components-markdown-blockquote-textColor"]) != null ? _Ta : cssVars["--persona-palette-colors-gray-500"];
691
+ cssVars["--cw-container"] = (_Ua = cssVars["--persona-components-collapsibleWidget-container"]) != null ? _Ua : cssVars["--persona-surface"];
692
+ cssVars["--cw-surface"] = (_Va = cssVars["--persona-components-collapsibleWidget-surface"]) != null ? _Va : cssVars["--persona-surface"];
693
+ cssVars["--cw-border"] = (_Wa = cssVars["--persona-components-collapsibleWidget-border"]) != null ? _Wa : cssVars["--persona-border"];
694
+ cssVars["--persona-message-border"] = (_Xa = cssVars["--persona-components-message-border"]) != null ? _Xa : cssVars["--persona-border"];
636
695
  const components = theme.components;
637
696
  const iconBtn = components == null ? void 0 : components.iconButton;
638
697
  if (iconBtn) {
@@ -679,23 +738,23 @@ function themeToCssVariables(theme) {
679
738
  if (t.copyPadding) cssVars["--persona-artifact-toolbar-copy-padding"] = t.copyPadding;
680
739
  if (t.copyMenuBackground) {
681
740
  cssVars["--persona-artifact-toolbar-copy-menu-bg"] = t.copyMenuBackground;
682
- cssVars["--persona-dropdown-bg"] = (_ua = cssVars["--persona-dropdown-bg"]) != null ? _ua : t.copyMenuBackground;
741
+ cssVars["--persona-dropdown-bg"] = (_Ya = cssVars["--persona-dropdown-bg"]) != null ? _Ya : t.copyMenuBackground;
683
742
  }
684
743
  if (t.copyMenuBorder) {
685
744
  cssVars["--persona-artifact-toolbar-copy-menu-border"] = t.copyMenuBorder;
686
- cssVars["--persona-dropdown-border"] = (_va = cssVars["--persona-dropdown-border"]) != null ? _va : t.copyMenuBorder;
745
+ cssVars["--persona-dropdown-border"] = (_Za = cssVars["--persona-dropdown-border"]) != null ? _Za : t.copyMenuBorder;
687
746
  }
688
747
  if (t.copyMenuShadow) {
689
748
  cssVars["--persona-artifact-toolbar-copy-menu-shadow"] = t.copyMenuShadow;
690
- cssVars["--persona-dropdown-shadow"] = (_wa = cssVars["--persona-dropdown-shadow"]) != null ? _wa : t.copyMenuShadow;
749
+ cssVars["--persona-dropdown-shadow"] = (__a = cssVars["--persona-dropdown-shadow"]) != null ? __a : t.copyMenuShadow;
691
750
  }
692
751
  if (t.copyMenuBorderRadius) {
693
752
  cssVars["--persona-artifact-toolbar-copy-menu-radius"] = t.copyMenuBorderRadius;
694
- cssVars["--persona-dropdown-radius"] = (_xa = cssVars["--persona-dropdown-radius"]) != null ? _xa : t.copyMenuBorderRadius;
753
+ cssVars["--persona-dropdown-radius"] = (_$a = cssVars["--persona-dropdown-radius"]) != null ? _$a : t.copyMenuBorderRadius;
695
754
  }
696
755
  if (t.copyMenuItemHoverBackground) {
697
756
  cssVars["--persona-artifact-toolbar-copy-menu-item-hover-bg"] = t.copyMenuItemHoverBackground;
698
- cssVars["--persona-dropdown-item-hover-bg"] = (_ya = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ya : t.copyMenuItemHoverBackground;
757
+ cssVars["--persona-dropdown-item-hover-bg"] = (_ab = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ab : t.copyMenuItemHoverBackground;
699
758
  }
700
759
  if (t.iconBackground) cssVars["--persona-artifact-toolbar-icon-bg"] = t.iconBackground;
701
760
  if (t.toolbarBorder) cssVars["--persona-artifact-toolbar-border"] = t.toolbarBorder;
@@ -715,7 +774,7 @@ function themeToCssVariables(theme) {
715
774
  if (artifact == null ? void 0 : artifact.pane) {
716
775
  const t = artifact.pane;
717
776
  if (t.toolbarBackground) {
718
- const toolbarBg = (_za = resolveTokenValue(theme, t.toolbarBackground)) != null ? _za : t.toolbarBackground;
777
+ const toolbarBg = (_bb = resolveTokenValue(theme, t.toolbarBackground)) != null ? _bb : t.toolbarBackground;
719
778
  cssVars["--persona-artifact-toolbar-bg"] = toolbarBg;
720
779
  }
721
780
  }
@@ -1032,7 +1091,12 @@ var DEFAULT_WIDGET_CONFIG = {
1032
1091
  },
1033
1092
  features: {
1034
1093
  showReasoning: true,
1035
- showToolCalls: true
1094
+ showToolCalls: true,
1095
+ scrollToBottom: {
1096
+ enabled: true,
1097
+ iconName: "arrow-down",
1098
+ label: ""
1099
+ }
1036
1100
  },
1037
1101
  suggestionChips: [
1038
1102
  "What can you help me with?",
@@ -1134,9 +1198,11 @@ function mergeWithDefaults(config) {
1134
1198
  ...config.voiceRecognition
1135
1199
  },
1136
1200
  features: (() => {
1137
- var _a2, _b2;
1201
+ var _a2, _b2, _c2, _d2;
1138
1202
  const da = (_a2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _a2.artifacts;
1139
1203
  const ca = (_b2 = config.features) == null ? void 0 : _b2.artifacts;
1204
+ const dsb = (_c2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _c2.scrollToBottom;
1205
+ const csb = (_d2 = config.features) == null ? void 0 : _d2.scrollToBottom;
1140
1206
  const mergedArtifacts = da === void 0 && ca === void 0 ? void 0 : {
1141
1207
  ...da,
1142
1208
  ...ca,
@@ -1145,9 +1211,14 @@ function mergeWithDefaults(config) {
1145
1211
  ...ca == null ? void 0 : ca.layout
1146
1212
  }
1147
1213
  };
1214
+ const mergedScrollToBottom = dsb === void 0 && csb === void 0 ? void 0 : {
1215
+ ...dsb,
1216
+ ...csb
1217
+ };
1148
1218
  return {
1149
1219
  ...DEFAULT_WIDGET_CONFIG.features,
1150
1220
  ...config.features,
1221
+ ...mergedScrollToBottom !== void 0 ? { scrollToBottom: mergedScrollToBottom } : {},
1151
1222
  ...mergedArtifacts !== void 0 ? { artifacts: mergedArtifacts } : {}
1152
1223
  };
1153
1224
  })(),
@@ -1676,6 +1747,16 @@ var ROLE_PRIMARY_ACTIONS = {
1676
1747
  { path: "semantic.colors.interactive.hover", kind: "accent" }
1677
1748
  ]
1678
1749
  };
1750
+ var ROLE_SCROLL_TO_BOTTOM = {
1751
+ roleId: "role-scroll-to-bottom",
1752
+ helper: "Scroll-to-bottom affordances in transcript and event stream",
1753
+ intensities: ROLE_INTENSITIES,
1754
+ targets: [
1755
+ { path: "components.scrollToBottom.background", kind: "background" },
1756
+ { path: "components.scrollToBottom.foreground", kind: "foreground" },
1757
+ { path: "components.scrollToBottom.border", kind: "border" }
1758
+ ]
1759
+ };
1679
1760
  var ROLE_INPUT = {
1680
1761
  roleId: "role-input",
1681
1762
  helper: "Message input field",
@@ -1714,6 +1795,7 @@ var ALL_ROLES = [
1714
1795
  ROLE_USER_MESSAGES,
1715
1796
  ROLE_ASSISTANT_MESSAGES,
1716
1797
  ROLE_PRIMARY_ACTIONS,
1798
+ ROLE_SCROLL_TO_BOTTOM,
1717
1799
  ROLE_INPUT,
1718
1800
  ROLE_LINKS_FOCUS,
1719
1801
  ROLE_BORDERS
@@ -2186,6 +2268,35 @@ var buttonColorsSectionDef = {
2186
2268
  { id: "btn-ghost-fg", label: "Ghost Foreground", type: "token-ref", path: "theme.components.button.ghost.foreground", defaultValue: "semantic.colors.text", tokenRef: { tokenType: "color" } }
2187
2269
  ]
2188
2270
  };
2271
+ var scrollToBottomSectionDef = {
2272
+ id: "scroll-to-bottom-style",
2273
+ title: "Scroll To Bottom",
2274
+ description: "Style the floating jump-to-latest affordance.",
2275
+ collapsed: true,
2276
+ fields: [
2277
+ { id: "scroll-bottom-bg", label: "Background", type: "token-ref", path: "theme.components.scrollToBottom.background", defaultValue: "components.button.primary.background", tokenRef: { tokenType: "color" } },
2278
+ { id: "scroll-bottom-fg", label: "Foreground", type: "token-ref", path: "theme.components.scrollToBottom.foreground", defaultValue: "components.button.primary.foreground", tokenRef: { tokenType: "color" } },
2279
+ { id: "scroll-bottom-border", label: "Border", type: "token-ref", path: "theme.components.scrollToBottom.border", defaultValue: "semantic.colors.primary", tokenRef: { tokenType: "color" } },
2280
+ { id: "scroll-bottom-size", label: "Size", type: "text", path: "theme.components.scrollToBottom.size", defaultValue: "40px" },
2281
+ { id: "scroll-bottom-radius", label: "Border Radius", type: "select", path: "theme.components.scrollToBottom.borderRadius", defaultValue: "palette.radius.full", options: [
2282
+ { value: "palette.radius.md", label: "Medium" },
2283
+ { value: "palette.radius.lg", label: "Large" },
2284
+ { value: "palette.radius.xl", label: "Extra Large" },
2285
+ { value: "palette.radius.full", label: "Full" }
2286
+ ] },
2287
+ { id: "scroll-bottom-shadow", label: "Shadow", type: "select", path: "theme.components.scrollToBottom.shadow", defaultValue: "palette.shadows.sm", options: [
2288
+ { value: "palette.shadows.none", label: "None" },
2289
+ { value: "palette.shadows.sm", label: "Small" },
2290
+ { value: "palette.shadows.md", label: "Medium" },
2291
+ { value: "palette.shadows.lg", label: "Large" },
2292
+ { value: "palette.shadows.xl", label: "Extra Large" }
2293
+ ] },
2294
+ { id: "scroll-bottom-padding", label: "Padding", type: "text", path: "theme.components.scrollToBottom.padding", defaultValue: "0.5rem 0.875rem" },
2295
+ { id: "scroll-bottom-gap", label: "Gap", type: "text", path: "theme.components.scrollToBottom.gap", defaultValue: "0.5rem" },
2296
+ { id: "scroll-bottom-font-size", label: "Font Size", type: "text", path: "theme.components.scrollToBottom.fontSize", defaultValue: "0.875rem" },
2297
+ { id: "scroll-bottom-icon-size", label: "Icon Size", type: "text", path: "theme.components.scrollToBottom.iconSize", defaultValue: "14px" }
2298
+ ]
2299
+ };
2189
2300
  var COMPONENT_SHAPE_SECTIONS = [
2190
2301
  panelLayoutSectionDef,
2191
2302
  launcherLayoutSectionDef,
@@ -2197,7 +2308,8 @@ var COMPONENT_COLOR_SECTIONS = [
2197
2308
  headerColorsSectionDef,
2198
2309
  messageColorsSectionDef,
2199
2310
  inputColorsSectionDef,
2200
- buttonColorsSectionDef
2311
+ buttonColorsSectionDef,
2312
+ scrollToBottomSectionDef
2201
2313
  ];
2202
2314
  var COMPONENTS_SECTIONS = [
2203
2315
  ...COMPONENT_SHAPE_SECTIONS,
@@ -2424,7 +2536,10 @@ var featuresSectionDef = {
2424
2536
  collapsed: true,
2425
2537
  fields: [
2426
2538
  { id: "feat-voice", label: "Voice Recognition", description: "Enable voice input", type: "toggle", path: "voiceRecognition.enabled", defaultValue: false },
2427
- { id: "feat-auto-focus", label: "Auto Focus Input", description: "Focus input after panel opens", type: "toggle", path: "autoFocusInput", defaultValue: false }
2539
+ { id: "feat-auto-focus", label: "Auto Focus Input", description: "Focus input after panel opens", type: "toggle", path: "autoFocusInput", defaultValue: false },
2540
+ { id: "feat-scroll-bottom-enabled", label: "Scroll To Bottom", description: "Show a jump-to-latest affordance when the user scrolls away from new content", type: "toggle", path: "features.scrollToBottom.enabled", defaultValue: true },
2541
+ { id: "feat-scroll-bottom-icon", label: "Scroll To Bottom Icon", type: "text", path: "features.scrollToBottom.iconName", defaultValue: "arrow-down" },
2542
+ { id: "feat-scroll-bottom-label", label: "Scroll To Bottom Label", description: "Leave empty for icon-only mode", type: "text", path: "features.scrollToBottom.label", defaultValue: "" }
2428
2543
  ]
2429
2544
  };
2430
2545
  var attachmentsSectionDef = {
@@ -2590,6 +2705,13 @@ var INTERFACE_ROLES_SECTION = {
2590
2705
  path: "theme.components.button.primary.background",
2591
2706
  roleAssignment: ROLE_PRIMARY_ACTIONS
2592
2707
  },
2708
+ {
2709
+ id: "role-scroll-to-bottom",
2710
+ label: "Scroll To Bottom",
2711
+ type: "role-assignment",
2712
+ path: "theme.components.scrollToBottom.background",
2713
+ roleAssignment: ROLE_SCROLL_TO_BOTTOM
2714
+ },
2593
2715
  {
2594
2716
  id: "role-input",
2595
2717
  label: "Input Field",
@@ -7535,6 +7657,72 @@ function pruneCache(cache, activeMessageIds) {
7535
7657
  }
7536
7658
  }
7537
7659
 
7660
+ // src/utils/auto-follow.ts
7661
+ function createFollowStateController(initiallyFollowing = true) {
7662
+ let following = initiallyFollowing;
7663
+ return {
7664
+ isFollowing: () => following,
7665
+ pause: () => {
7666
+ if (!following) return false;
7667
+ following = false;
7668
+ return true;
7669
+ },
7670
+ resume: () => {
7671
+ if (following) return false;
7672
+ following = true;
7673
+ return true;
7674
+ }
7675
+ };
7676
+ }
7677
+ function getScrollBottomOffset(element) {
7678
+ return Math.max(0, element.scrollHeight - element.clientHeight);
7679
+ }
7680
+ function isElementNearBottom(element, threshold) {
7681
+ return getScrollBottomOffset(element) - element.scrollTop <= threshold;
7682
+ }
7683
+ function resolveFollowStateFromScroll(input) {
7684
+ const {
7685
+ following,
7686
+ currentScrollTop,
7687
+ lastScrollTop,
7688
+ nearBottom,
7689
+ userScrollThreshold,
7690
+ isAutoScrolling = false,
7691
+ pauseOnUpwardScroll = false,
7692
+ pauseWhenAwayFromBottom = true,
7693
+ resumeRequiresDownwardScroll = false
7694
+ } = input;
7695
+ const delta = currentScrollTop - lastScrollTop;
7696
+ if (isAutoScrolling || Math.abs(delta) < userScrollThreshold) {
7697
+ return { action: "none", delta, nextLastScrollTop: currentScrollTop };
7698
+ }
7699
+ if (!following && nearBottom && (!resumeRequiresDownwardScroll || delta > 0)) {
7700
+ return { action: "resume", delta, nextLastScrollTop: currentScrollTop };
7701
+ }
7702
+ if (following && pauseOnUpwardScroll && delta < 0) {
7703
+ return { action: "pause", delta, nextLastScrollTop: currentScrollTop };
7704
+ }
7705
+ if (following && pauseWhenAwayFromBottom && !nearBottom) {
7706
+ return { action: "pause", delta, nextLastScrollTop: currentScrollTop };
7707
+ }
7708
+ return { action: "none", delta, nextLastScrollTop: currentScrollTop };
7709
+ }
7710
+ function resolveFollowStateFromWheel(input) {
7711
+ const {
7712
+ following,
7713
+ deltaY,
7714
+ nearBottom = false,
7715
+ resumeWhenNearBottom = false
7716
+ } = input;
7717
+ if (following && deltaY < 0) {
7718
+ return "pause";
7719
+ }
7720
+ if (!following && resumeWhenNearBottom && deltaY > 0 && nearBottom) {
7721
+ return "resume";
7722
+ }
7723
+ return "none";
7724
+ }
7725
+
7538
7726
  // src/utils/constants.ts
7539
7727
  var statusCopy = {
7540
7728
  idle: "Online",
@@ -7542,6 +7730,70 @@ var statusCopy = {
7542
7730
  connected: "Streaming\u2026",
7543
7731
  error: "Offline"
7544
7732
  };
7733
+ var DEFAULT_OVERLAY_Z_INDEX = 1e5;
7734
+ var PORTALED_OVERLAY_Z_INDEX = DEFAULT_OVERLAY_Z_INDEX + 1;
7735
+
7736
+ // src/utils/overlay-host-stacking.ts
7737
+ function syncOverlayHostStacking(host, zIndex = DEFAULT_OVERLAY_Z_INDEX) {
7738
+ const originalPosition = host.style.position;
7739
+ const originalZIndex = host.style.zIndex;
7740
+ const originalIsolation = host.style.isolation;
7741
+ const computed = getComputedStyle(host);
7742
+ const positionWasSet = computed.position === "static" || computed.position === "";
7743
+ if (positionWasSet) {
7744
+ host.style.position = "relative";
7745
+ }
7746
+ host.style.zIndex = String(zIndex);
7747
+ host.style.isolation = "isolate";
7748
+ return () => {
7749
+ if (positionWasSet) {
7750
+ host.style.position = originalPosition;
7751
+ }
7752
+ host.style.zIndex = originalZIndex;
7753
+ host.style.isolation = originalIsolation;
7754
+ };
7755
+ }
7756
+
7757
+ // src/utils/scroll-lock.ts
7758
+ var lockCount = 0;
7759
+ var savedState = null;
7760
+ function acquireScrollLock(doc = document) {
7761
+ var _a;
7762
+ lockCount++;
7763
+ if (lockCount === 1) {
7764
+ const body = doc.body;
7765
+ const win = (_a = doc.defaultView) != null ? _a : window;
7766
+ const scrollY = win.scrollY || doc.documentElement.scrollTop;
7767
+ savedState = {
7768
+ originalOverflow: body.style.overflow,
7769
+ originalPosition: body.style.position,
7770
+ originalTop: body.style.top,
7771
+ originalWidth: body.style.width,
7772
+ scrollY
7773
+ };
7774
+ body.style.overflow = "hidden";
7775
+ body.style.position = "fixed";
7776
+ body.style.top = `-${scrollY}px`;
7777
+ body.style.width = "100%";
7778
+ }
7779
+ let released = false;
7780
+ return () => {
7781
+ var _a2;
7782
+ if (released) return;
7783
+ released = true;
7784
+ lockCount = Math.max(0, lockCount - 1);
7785
+ if (lockCount === 0 && savedState) {
7786
+ const body = doc.body;
7787
+ const win = (_a2 = doc.defaultView) != null ? _a2 : window;
7788
+ body.style.overflow = savedState.originalOverflow;
7789
+ body.style.position = savedState.originalPosition;
7790
+ body.style.top = savedState.originalTop;
7791
+ body.style.width = savedState.originalWidth;
7792
+ win.scrollTo(0, savedState.scrollY);
7793
+ savedState = null;
7794
+ }
7795
+ };
7796
+ }
7545
7797
 
7546
7798
  // src/utils/dock.ts
7547
7799
  var DEFAULT_DOCK_CONFIG = {
@@ -7588,7 +7840,7 @@ var createLauncherButton = (config, onToggle) => {
7588
7840
  `;
7589
7841
  button.addEventListener("click", onToggle);
7590
7842
  const update = (newConfig) => {
7591
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
7843
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
7592
7844
  const launcher = (_a = newConfig.launcher) != null ? _a : {};
7593
7845
  const dockedMode = isDockedMountMode(newConfig);
7594
7846
  const titleEl = button.querySelector("[data-role='launcher-title']");
@@ -7699,13 +7951,16 @@ var createLauncherButton = (config, onToggle) => {
7699
7951
  }
7700
7952
  }
7701
7953
  const positionClass = launcher.position && positionMap[launcher.position] ? positionMap[launcher.position] : positionMap["bottom-right"];
7702
- const floatingBase = "persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer persona-z-50";
7954
+ const floatingBase = "persona-fixed persona-flex persona-items-center persona-gap-3 persona-rounded-launcher persona-bg-persona-surface persona-py-2.5 persona-pl-3 persona-pr-3 persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";
7703
7955
  const dockedBase = "persona-relative persona-mt-4 persona-mb-4 persona-mx-auto persona-flex persona-items-center persona-justify-center persona-rounded-launcher persona-bg-persona-surface persona-transition hover:persona-translate-y-[-2px] persona-cursor-pointer";
7704
7956
  button.className = dockedMode ? dockedBase : `${floatingBase} ${positionClass}`;
7957
+ if (!dockedMode) {
7958
+ button.style.zIndex = String((_k = launcher.zIndex) != null ? _k : DEFAULT_OVERLAY_Z_INDEX);
7959
+ }
7705
7960
  const defaultBorder = "1px solid var(--persona-border, #e5e7eb)";
7706
7961
  const defaultShadow = "var(--persona-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1))";
7707
- button.style.border = (_k = launcher.border) != null ? _k : defaultBorder;
7708
- button.style.boxShadow = (_l = launcher.shadow) != null ? _l : defaultShadow;
7962
+ button.style.border = (_l = launcher.border) != null ? _l : defaultBorder;
7963
+ button.style.boxShadow = (_m = launcher.shadow) != null ? _m : defaultShadow;
7709
7964
  if (dockedMode) {
7710
7965
  button.style.width = "0";
7711
7966
  button.style.minWidth = "0";
@@ -7717,7 +7972,7 @@ var createLauncherButton = (config, onToggle) => {
7717
7972
  } else {
7718
7973
  button.style.width = "";
7719
7974
  button.style.minWidth = "";
7720
- button.style.maxWidth = (_m = launcher.collapsedMaxWidth) != null ? _m : "";
7975
+ button.style.maxWidth = (_n = launcher.collapsedMaxWidth) != null ? _n : "";
7721
7976
  button.style.justifyContent = "";
7722
7977
  button.style.padding = "";
7723
7978
  button.style.overflow = "";
@@ -7887,6 +8142,7 @@ var buildHeader = (context) => {
7887
8142
  portaledTooltip.appendChild(arrow);
7888
8143
  const buttonRect = clearChatButton.getBoundingClientRect();
7889
8144
  portaledTooltip.style.position = "fixed";
8145
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
7890
8146
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
7891
8147
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
7892
8148
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -7998,6 +8254,7 @@ var buildHeader = (context) => {
7998
8254
  portaledTooltip.appendChild(arrow);
7999
8255
  const buttonRect = closeButton.getBoundingClientRect();
8000
8256
  portaledTooltip.style.position = "fixed";
8257
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
8001
8258
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
8002
8259
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
8003
8260
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -8059,7 +8316,7 @@ function createDropdownMenu(options) {
8059
8316
  menu.setAttribute("data-persona-theme-zone", "dropdown");
8060
8317
  if (portal) {
8061
8318
  menu.style.position = "fixed";
8062
- menu.style.zIndex = "10000";
8319
+ menu.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
8063
8320
  } else {
8064
8321
  menu.style.position = "absolute";
8065
8322
  menu.style.top = "100%";
@@ -8902,7 +9159,7 @@ var buildComposer = (context) => {
8902
9159
 
8903
9160
  // src/components/panel.ts
8904
9161
  var createWrapper = (config) => {
8905
- var _a, _b, _c, _d, _e, _f, _g;
9162
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
8906
9163
  const launcherEnabled = (_b = (_a = config == null ? void 0 : config.launcher) == null ? void 0 : _a.enabled) != null ? _b : true;
8907
9164
  const dockedMode = isDockedMountMode(config);
8908
9165
  if (dockedMode) {
@@ -8936,13 +9193,14 @@ var createWrapper = (config) => {
8936
9193
  const position = launcher.position && positionMap[launcher.position] ? positionMap[launcher.position] : positionMap["bottom-right"];
8937
9194
  const wrapper = createElement(
8938
9195
  "div",
8939
- `persona-widget-wrapper persona-fixed ${position} persona-z-50 persona-transition`
9196
+ `persona-widget-wrapper persona-fixed ${position} persona-transition`
8940
9197
  );
9198
+ wrapper.style.zIndex = String((_g = (_f = config == null ? void 0 : config.launcher) == null ? void 0 : _f.zIndex) != null ? _g : DEFAULT_OVERLAY_Z_INDEX);
8941
9199
  const panel = createElement(
8942
9200
  "div",
8943
9201
  "persona-widget-panel persona-relative persona-min-h-[320px]"
8944
9202
  );
8945
- const launcherWidth = (_g = (_f = config == null ? void 0 : config.launcher) == null ? void 0 : _f.width) != null ? _g : config == null ? void 0 : config.launcherWidth;
9203
+ const launcherWidth = (_i = (_h = config == null ? void 0 : config.launcher) == null ? void 0 : _h.width) != null ? _i : config == null ? void 0 : config.launcherWidth;
8946
9204
  const width = launcherWidth != null ? launcherWidth : "min(400px, calc(100vw - 24px))";
8947
9205
  panel.style.width = width;
8948
9206
  panel.style.maxWidth = width;
@@ -10505,7 +10763,7 @@ function renderEventRow(event, index, firstTimestamp, esConfig, expandedSet, onT
10505
10763
  }
10506
10764
  }
10507
10765
  function createEventStreamView(options) {
10508
- var _a, _b;
10766
+ var _a, _b, _c, _d, _e;
10509
10767
  const {
10510
10768
  buffer,
10511
10769
  getFullHistory,
@@ -10513,7 +10771,11 @@ function createEventStreamView(options) {
10513
10771
  config,
10514
10772
  plugins = []
10515
10773
  } = options;
10516
- const esConfig = (_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.eventStream) != null ? _b : {};
10774
+ const scrollToBottomConfig = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.scrollToBottom;
10775
+ const scrollToBottomEnabled = (scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.enabled) !== false;
10776
+ const scrollToBottomIconName = (_b = scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.iconName) != null ? _b : "arrow-down";
10777
+ const scrollToBottomLabel = (_c = scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.label) != null ? _c : "";
10778
+ const esConfig = (_e = (_d = config == null ? void 0 : config.features) == null ? void 0 : _d.eventStream) != null ? _e : {};
10517
10779
  const viewPlugin = plugins.find((p) => p.renderEventStreamView);
10518
10780
  if ((viewPlugin == null ? void 0 : viewPlugin.renderEventStreamView) && config) {
10519
10781
  const customView = viewPlugin.renderEventStreamView({
@@ -10547,7 +10809,7 @@ function createEventStreamView(options) {
10547
10809
  let lastKnownTypes = [];
10548
10810
  let lastTypeCounts = {};
10549
10811
  let lastFilteredCount = 0;
10550
- let userScrolledUp = false;
10812
+ const autoFollow = createFollowStateController();
10551
10813
  let newEventsSincePause = 0;
10552
10814
  let lastRenderTime = 0;
10553
10815
  let pendingUpdate = false;
@@ -10700,18 +10962,23 @@ function createEventStreamView(options) {
10700
10962
  eventsList.style.height = "100%";
10701
10963
  const scrollIndicator = createElement(
10702
10964
  "div",
10703
- "persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-bg-persona-accent persona-text-white persona-text-xs persona-px-3 persona-py-1.5 persona-rounded-full persona-cursor-pointer persona-shadow-md persona-z-10 persona-flex persona-items-center persona-gap-1"
10965
+ "persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-transform persona--translate-x-1/2 persona-cursor-pointer persona-z-10 persona-text-xs"
10704
10966
  );
10705
10967
  applyCustomClasses(scrollIndicator, customClasses == null ? void 0 : customClasses.scrollIndicator);
10706
10968
  scrollIndicator.style.display = "none";
10969
+ scrollIndicator.setAttribute(
10970
+ "data-persona-scroll-to-bottom-has-label",
10971
+ scrollToBottomLabel ? "true" : "false"
10972
+ );
10707
10973
  const arrowIcon = renderLucideIcon(
10708
- "arrow-down",
10709
- "12px",
10974
+ scrollToBottomIconName,
10975
+ "14px",
10710
10976
  "currentColor",
10711
10977
  2
10712
10978
  );
10713
10979
  if (arrowIcon) scrollIndicator.appendChild(arrowIcon);
10714
10980
  const indicatorText = createElement("span", "");
10981
+ indicatorText.textContent = scrollToBottomLabel;
10715
10982
  scrollIndicator.appendChild(indicatorText);
10716
10983
  const noResultsMsg = createElement(
10717
10984
  "div",
@@ -10783,7 +11050,7 @@ function createEventStreamView(options) {
10783
11050
  function resetScrollState() {
10784
11051
  lastFilteredCount = 0;
10785
11052
  newEventsSincePause = 0;
10786
- userScrolledUp = false;
11053
+ autoFollow.resume();
10787
11054
  scrollIndicator.style.display = "none";
10788
11055
  }
10789
11056
  function toggleExpand(eventId) {
@@ -10794,17 +11061,18 @@ function createEventStreamView(options) {
10794
11061
  }
10795
11062
  dirtyExpandId = eventId;
10796
11063
  const savedScrollTop = eventsList.scrollTop;
10797
- const wasUserScrolledUp = userScrolledUp;
11064
+ const wasAutoFollowing = autoFollow.isFollowing();
10798
11065
  suppressScrollHandler = true;
10799
- userScrolledUp = true;
11066
+ autoFollow.pause();
10800
11067
  updateNow();
10801
11068
  eventsList.scrollTop = savedScrollTop;
10802
- userScrolledUp = wasUserScrolledUp;
11069
+ if (wasAutoFollowing) {
11070
+ autoFollow.resume();
11071
+ }
10803
11072
  suppressScrollHandler = false;
10804
11073
  }
10805
11074
  function isNearBottom() {
10806
- const threshold = 50;
10807
- return eventsList.scrollHeight - eventsList.scrollTop - eventsList.clientHeight <= threshold;
11075
+ return isElementNearBottom(eventsList, 50);
10808
11076
  }
10809
11077
  function updateNow() {
10810
11078
  lastRenderTime = Date.now();
@@ -10834,9 +11102,9 @@ function createEventStreamView(options) {
10834
11102
  if (copyAllBtn) {
10835
11103
  copyAllBtn.title = hasActiveFilters() ? `Copy Filtered (${newCount})` : "Copy All";
10836
11104
  }
10837
- if (userScrolledUp && newCount > lastFilteredCount) {
11105
+ if (scrollToBottomEnabled && !autoFollow.isFollowing() && newCount > lastFilteredCount) {
10838
11106
  newEventsSincePause += newCount - lastFilteredCount;
10839
- indicatorText.textContent = `${newEventsSincePause} new event${newEventsSincePause === 1 ? "" : "s"}`;
11107
+ indicatorText.textContent = scrollToBottomLabel ? `${scrollToBottomLabel}${newEventsSincePause > 0 ? ` (${newEventsSincePause})` : ""}` : "";
10840
11108
  scrollIndicator.style.display = "";
10841
11109
  }
10842
11110
  lastFilteredCount = newCount;
@@ -10920,7 +11188,7 @@ function createEventStreamView(options) {
10920
11188
  }
10921
11189
  }
10922
11190
  }
10923
- if (!userScrolledUp) {
11191
+ if (autoFollow.isFollowing()) {
10924
11192
  eventsList.scrollTop = eventsList.scrollHeight;
10925
11193
  }
10926
11194
  }
@@ -11029,24 +11297,50 @@ function createEventStreamView(options) {
11029
11297
  const handleListScroll = () => {
11030
11298
  if (suppressScrollHandler) return;
11031
11299
  const currentScrollTop = eventsList.scrollTop;
11032
- const scrollingDown = currentScrollTop > lastScrollTop;
11033
- lastScrollTop = currentScrollTop;
11034
- if (isNearBottom() && scrollingDown) {
11035
- userScrolledUp = false;
11300
+ const { action, nextLastScrollTop } = resolveFollowStateFromScroll({
11301
+ following: autoFollow.isFollowing(),
11302
+ currentScrollTop,
11303
+ lastScrollTop,
11304
+ nearBottom: isNearBottom(),
11305
+ userScrollThreshold: 1,
11306
+ resumeRequiresDownwardScroll: true
11307
+ });
11308
+ lastScrollTop = nextLastScrollTop;
11309
+ if (action === "resume") {
11310
+ autoFollow.resume();
11036
11311
  newEventsSincePause = 0;
11037
11312
  scrollIndicator.style.display = "none";
11038
- } else if (!isNearBottom()) {
11039
- userScrolledUp = true;
11313
+ } else if (action === "pause") {
11314
+ autoFollow.pause();
11315
+ if (scrollToBottomEnabled) {
11316
+ indicatorText.textContent = scrollToBottomLabel;
11317
+ scrollIndicator.style.display = "";
11318
+ }
11040
11319
  }
11041
11320
  };
11042
11321
  const handleWheel = (e) => {
11043
- if (e.deltaY < 0) {
11044
- userScrolledUp = true;
11322
+ const action = resolveFollowStateFromWheel({
11323
+ following: autoFollow.isFollowing(),
11324
+ deltaY: e.deltaY,
11325
+ nearBottom: isNearBottom(),
11326
+ resumeWhenNearBottom: true
11327
+ });
11328
+ if (action === "pause") {
11329
+ autoFollow.pause();
11330
+ if (scrollToBottomEnabled) {
11331
+ indicatorText.textContent = scrollToBottomLabel;
11332
+ scrollIndicator.style.display = "";
11333
+ }
11334
+ } else if (action === "resume") {
11335
+ autoFollow.resume();
11336
+ newEventsSincePause = 0;
11337
+ scrollIndicator.style.display = "none";
11045
11338
  }
11046
11339
  };
11047
11340
  const handleScrollIndicatorClick = () => {
11341
+ if (!scrollToBottomEnabled) return;
11048
11342
  eventsList.scrollTop = eventsList.scrollHeight;
11049
- userScrolledUp = false;
11343
+ autoFollow.resume();
11050
11344
  newEventsSincePause = 0;
11051
11345
  scrollIndicator.style.display = "none";
11052
11346
  };
@@ -11128,7 +11422,7 @@ function renderDefaultArtifactCard(props, _context) {
11128
11422
  const root = document.createElement("div");
11129
11423
  root.className = "persona-flex persona-w-full persona-max-w-full persona-items-center persona-gap-3 persona-rounded-xl persona-px-4 persona-py-3";
11130
11424
  root.style.border = "1px solid var(--persona-border, #e5e7eb)";
11131
- root.style.backgroundColor = "var(--persona-bg, #ffffff)";
11425
+ root.style.backgroundColor = "var(--persona-surface, #ffffff)";
11132
11426
  root.style.cursor = "pointer";
11133
11427
  root.tabIndex = 0;
11134
11428
  root.setAttribute("role", "button");
@@ -12665,7 +12959,7 @@ var buildPostprocessor = (cfg, actionManager, onResubmitRequested) => {
12665
12959
  };
12666
12960
  };
12667
12961
  var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12668
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
12962
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
12669
12963
  if (mount.id && !mount.getAttribute("data-persona-instance")) {
12670
12964
  mount.setAttribute("data-persona-instance", mount.id);
12671
12965
  }
@@ -12783,10 +13077,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12783
13077
  let showReasoning = (_l = (_k = config.features) == null ? void 0 : _k.showReasoning) != null ? _l : true;
12784
13078
  let showToolCalls = (_n = (_m = config.features) == null ? void 0 : _m.showToolCalls) != null ? _n : true;
12785
13079
  let showEventStreamToggle = (_p = (_o = config.features) == null ? void 0 : _o.showEventStreamToggle) != null ? _p : false;
12786
- const persistKeyPrefix = (_r = typeof config.persistState === "object" ? (_q = config.persistState) == null ? void 0 : _q.keyPrefix : void 0) != null ? _r : "persona-";
13080
+ let scrollToBottomFeature = (_r = (_q = config.features) == null ? void 0 : _q.scrollToBottom) != null ? _r : {};
13081
+ const persistKeyPrefix = (_t = typeof config.persistState === "object" ? (_s = config.persistState) == null ? void 0 : _s.keyPrefix : void 0) != null ? _t : "persona-";
12787
13082
  const eventStreamDbName = `${persistKeyPrefix}event-stream`;
12788
13083
  let eventStreamStore = showEventStreamToggle ? new EventStreamStore(eventStreamDbName) : null;
12789
- const eventStreamMaxEvents = (_u = (_t = (_s = config.features) == null ? void 0 : _s.eventStream) == null ? void 0 : _t.maxEvents) != null ? _u : 2e3;
13084
+ const eventStreamMaxEvents = (_w = (_v = (_u = config.features) == null ? void 0 : _u.eventStream) == null ? void 0 : _v.maxEvents) != null ? _w : 2e3;
12790
13085
  let eventStreamBuffer = showEventStreamToggle ? new EventStreamBuffer(eventStreamMaxEvents, eventStreamStore) : null;
12791
13086
  let eventStreamView = null;
12792
13087
  let eventStreamVisible = false;
@@ -12823,7 +13118,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12823
13118
  (_b2 = (_a2 = config.messageActions) == null ? void 0 : _a2.onFeedback) == null ? void 0 : _b2.call(_a2, feedback);
12824
13119
  }
12825
13120
  };
12826
- const statusConfig = (_v = config.statusIndicator) != null ? _v : {};
13121
+ const statusConfig = (_x = config.statusIndicator) != null ? _x : {};
12827
13122
  const _getStatusText = (status) => {
12828
13123
  var _a2, _b2, _c2, _d2;
12829
13124
  if (status === "idle") return (_a2 = statusConfig.idleText) != null ? _a2 : statusCopy.idle;
@@ -12877,6 +13172,52 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12877
13172
  let attachmentButtonWrapper = panelElements.attachmentButtonWrapper;
12878
13173
  let attachmentInput = panelElements.attachmentInput;
12879
13174
  let attachmentPreviewsContainer = panelElements.attachmentPreviewsContainer;
13175
+ container.classList.add("persona-relative");
13176
+ body.classList.add("persona-relative");
13177
+ const SCROLL_TO_BOTTOM_EDGE_OFFSET = 12;
13178
+ const getScrollToBottomLabel = () => {
13179
+ var _a2;
13180
+ return (_a2 = scrollToBottomFeature.label) != null ? _a2 : "";
13181
+ };
13182
+ const getScrollToBottomIconName = () => {
13183
+ var _a2;
13184
+ return (_a2 = scrollToBottomFeature.iconName) != null ? _a2 : "arrow-down";
13185
+ };
13186
+ const isScrollToBottomEnabled = () => scrollToBottomFeature.enabled !== false;
13187
+ const scrollToBottomButton = createElement(
13188
+ "button",
13189
+ "persona-scroll-to-bottom-indicator persona-absolute persona-bottom-3 persona-left-1/2 persona-z-10 persona-flex persona-items-center persona-gap-1 persona-text-xs persona-transform persona--translate-x-1/2 persona-cursor-pointer"
13190
+ );
13191
+ scrollToBottomButton.type = "button";
13192
+ scrollToBottomButton.style.display = "none";
13193
+ scrollToBottomButton.setAttribute("data-persona-scroll-to-bottom", "true");
13194
+ const scrollToBottomIcon = createElement("span", "persona-flex persona-items-center");
13195
+ const scrollToBottomLabel = createElement("span", "");
13196
+ scrollToBottomButton.append(scrollToBottomIcon, scrollToBottomLabel);
13197
+ container.appendChild(scrollToBottomButton);
13198
+ const updateScrollToBottomButtonOffset = () => {
13199
+ const footerHidden = footer.style.display === "none";
13200
+ const footerHeight = footerHidden ? 0 : footer.offsetHeight;
13201
+ scrollToBottomButton.style.bottom = `${footerHeight + SCROLL_TO_BOTTOM_EDGE_OFFSET}px`;
13202
+ };
13203
+ updateScrollToBottomButtonOffset();
13204
+ const renderScrollToBottomButton = () => {
13205
+ const hasLabel = Boolean(getScrollToBottomLabel());
13206
+ scrollToBottomButton.setAttribute("aria-label", getScrollToBottomLabel() || "Jump to latest");
13207
+ scrollToBottomButton.title = getScrollToBottomLabel();
13208
+ scrollToBottomButton.setAttribute("data-persona-scroll-to-bottom-has-label", hasLabel ? "true" : "false");
13209
+ scrollToBottomIcon.innerHTML = "";
13210
+ const icon = renderLucideIcon(getScrollToBottomIconName(), "14px", "currentColor", 2);
13211
+ if (icon) {
13212
+ scrollToBottomIcon.appendChild(icon);
13213
+ scrollToBottomIcon.style.display = "";
13214
+ } else {
13215
+ scrollToBottomIcon.style.display = "none";
13216
+ }
13217
+ scrollToBottomLabel.textContent = getScrollToBottomLabel();
13218
+ scrollToBottomLabel.style.display = hasLabel ? "" : "none";
13219
+ };
13220
+ renderScrollToBottomButton();
12880
13221
  let attachmentManager = null;
12881
13222
  let composerVoiceBridge = null;
12882
13223
  const headerPlugin = plugins.find((p) => p.renderHeader);
@@ -12932,6 +13273,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12932
13273
  };
12933
13274
  eventStreamLastUpdate = 0;
12934
13275
  eventStreamRAF = requestAnimationFrame(rafLoop);
13276
+ syncScrollToBottomButton();
12935
13277
  eventBus.emit("eventStream:opened", { timestamp: Date.now() });
12936
13278
  };
12937
13279
  const toggleEventStreamOff = () => {
@@ -12951,11 +13293,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12951
13293
  cancelAnimationFrame(eventStreamRAF);
12952
13294
  eventStreamRAF = null;
12953
13295
  }
13296
+ syncScrollToBottomButton();
12954
13297
  eventBus.emit("eventStream:closed", { timestamp: Date.now() });
12955
13298
  };
12956
13299
  let eventStreamToggleBtn = null;
12957
13300
  if (showEventStreamToggle) {
12958
- const esClassNames = (_x = (_w = config.features) == null ? void 0 : _w.eventStream) == null ? void 0 : _x.classNames;
13301
+ const esClassNames = (_z = (_y = config.features) == null ? void 0 : _y.eventStream) == null ? void 0 : _z.classNames;
12959
13302
  const toggleBtnClasses = "persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1" + ((esClassNames == null ? void 0 : esClassNames.toggleButton) ? " " + esClassNames.toggleButton : "");
12960
13303
  eventStreamToggleBtn = createElement("button", toggleBtnClasses);
12961
13304
  eventStreamToggleBtn.style.width = "28px";
@@ -13034,7 +13377,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13034
13377
  onModelChange: (modelId) => {
13035
13378
  config.composer = { ...config.composer, selectedModelId: modelId };
13036
13379
  },
13037
- onVoiceToggle: ((_y = config.voiceRecognition) == null ? void 0 : _y.enabled) === true ? () => {
13380
+ onVoiceToggle: ((_A = config.voiceRecognition) == null ? void 0 : _A.enabled) === true ? () => {
13038
13381
  composerVoiceBridge == null ? void 0 : composerVoiceBridge();
13039
13382
  } : void 0
13040
13383
  });
@@ -13073,7 +13416,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13073
13416
  };
13074
13417
  ensureComposerAttachmentSurface(footer);
13075
13418
  bindComposerRefsFromFooter(footer);
13076
- const contentMaxWidth = (_z = config.layout) == null ? void 0 : _z.contentMaxWidth;
13419
+ const contentMaxWidth = (_B = config.layout) == null ? void 0 : _B.contentMaxWidth;
13077
13420
  if (contentMaxWidth && composerForm) {
13078
13421
  composerForm.style.maxWidth = contentMaxWidth;
13079
13422
  composerForm.style.marginLeft = "auto";
@@ -13084,7 +13427,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13084
13427
  attachmentPreviewsContainer.style.marginLeft = "auto";
13085
13428
  attachmentPreviewsContainer.style.marginRight = "auto";
13086
13429
  }
13087
- if (((_A = config.attachments) == null ? void 0 : _A.enabled) && attachmentInput && attachmentPreviewsContainer) {
13430
+ if (((_C = config.attachments) == null ? void 0 : _C.enabled) && attachmentInput && attachmentPreviewsContainer) {
13088
13431
  attachmentManager = AttachmentManager.fromConfig(config.attachments);
13089
13432
  attachmentManager.setPreviewsContainer(attachmentPreviewsContainer);
13090
13433
  attachmentInput.addEventListener("change", (e) => {
@@ -13577,7 +13920,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13577
13920
  }
13578
13921
  mount.appendChild(wrapper);
13579
13922
  const applyFullHeightStyles = () => {
13580
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2;
13923
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2;
13581
13924
  const dockedMode = isDockedMountMode(config);
13582
13925
  const sidebarMode = (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.sidebarMode) != null ? _b2 : false;
13583
13926
  const fullHeight = dockedMode || sidebarMode || ((_d2 = (_c2 = config.launcher) == null ? void 0 : _c2.fullHeight) != null ? _d2 : false);
@@ -13596,7 +13939,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13596
13939
  const shouldGoFullscreen = mobileFullscreen && isMobileViewport && launcherEnabled;
13597
13940
  const position = (_n2 = (_m2 = config.launcher) == null ? void 0 : _m2.position) != null ? _n2 : "bottom-left";
13598
13941
  const isLeftSidebar = position === "bottom-left" || position === "top-left";
13599
- const overlayZIndex = (_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.zIndex) != null ? _p2 : 9999;
13942
+ const overlayZIndex = (_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.zIndex) != null ? _p2 : DEFAULT_OVERLAY_Z_INDEX;
13600
13943
  let defaultPanelBorder = sidebarMode || shouldGoFullscreen ? "none" : "1px solid var(--persona-border)";
13601
13944
  let defaultPanelShadow = shouldGoFullscreen ? "none" : sidebarMode ? isLeftSidebar ? "var(--persona-palette-shadows-sidebar-left, 2px 0 12px rgba(0, 0, 0, 0.08))" : "var(--persona-palette-shadows-sidebar-right, -2px 0 12px rgba(0, 0, 0, 0.08))" : "var(--persona-palette-shadows-xl, 0 25px 50px -12px rgba(0, 0, 0, 0.25))";
13602
13945
  if (dockedMode && !shouldGoFullscreen) {
@@ -13807,7 +14150,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13807
14150
  if (!isInlineEmbed && !dockedMode) {
13808
14151
  const maxHeightStyles = "max-height: -moz-available !important; max-height: stretch !important;";
13809
14152
  const paddingStyles = sidebarMode ? "" : "padding-top: 1.25em !important;";
13810
- const zIndexStyles = !sidebarMode && ((_v2 = config.launcher) == null ? void 0 : _v2.zIndex) != null ? `z-index: ${config.launcher.zIndex} !important;` : "";
14153
+ const zIndexStyles = !sidebarMode ? `z-index: ${(_w2 = (_v2 = config.launcher) == null ? void 0 : _v2.zIndex) != null ? _w2 : DEFAULT_OVERLAY_Z_INDEX} !important;` : "";
13811
14154
  wrapper.style.cssText += maxHeightStyles + paddingStyles + zIndexStyles;
13812
14155
  }
13813
14156
  };
@@ -13816,6 +14159,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13816
14159
  applyArtifactLayoutCssVars(mount, config);
13817
14160
  applyArtifactPaneAppearance(mount, config);
13818
14161
  const destroyCallbacks = [];
14162
+ let teardownHostStacking = null;
14163
+ let releaseScrollLock = null;
14164
+ destroyCallbacks.push(() => {
14165
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
14166
+ teardownHostStacking = null;
14167
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
14168
+ releaseScrollLock = null;
14169
+ });
13819
14170
  if (artifactPanelResizeObs) {
13820
14171
  destroyCallbacks.push(() => {
13821
14172
  artifactPanelResizeObs == null ? void 0 : artifactPanelResizeObs.disconnect();
@@ -13871,17 +14222,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13871
14222
  let isStreaming = false;
13872
14223
  const messageCache = createMessageCache();
13873
14224
  let configVersion = 0;
13874
- let shouldAutoScroll = true;
14225
+ const autoFollow = createFollowStateController();
13875
14226
  let lastScrollTop = 0;
13876
- let lastAutoScrollTime = 0;
13877
14227
  let scrollRAF = null;
13878
- let isAutoScrollBlocked = false;
13879
- let blockUntilTime = 0;
13880
14228
  let isAutoScrolling = false;
13881
- const AUTO_SCROLL_THROTTLE = 125;
13882
- const AUTO_SCROLL_BLOCK_TIME = 2e3;
13883
- const USER_SCROLL_THRESHOLD = 5;
13884
- const BOTTOM_THRESHOLD = 50;
14229
+ const USER_SCROLL_THRESHOLD = 1;
14230
+ const BOTTOM_THRESHOLD = 8;
13885
14231
  const messageState = /* @__PURE__ */ new Map();
13886
14232
  const voiceState = {
13887
14233
  active: false,
@@ -13889,7 +14235,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13889
14235
  lastUserMessageWasVoice: false,
13890
14236
  lastUserMessageId: null
13891
14237
  };
13892
- const voiceAutoResumeMode = (_C = (_B = config.voiceRecognition) == null ? void 0 : _B.autoResume) != null ? _C : false;
14238
+ const voiceAutoResumeMode = (_E = (_D = config.voiceRecognition) == null ? void 0 : _D.autoResume) != null ? _E : false;
13893
14239
  const emitVoiceState = (source) => {
13894
14240
  eventBus.emit("voice:state", {
13895
14241
  active: voiceState.active,
@@ -13955,56 +14301,79 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13955
14301
  }
13956
14302
  }
13957
14303
  }
13958
- const scheduleAutoScroll = (force = false) => {
13959
- if (!shouldAutoScroll) return;
13960
- const now = Date.now();
13961
- if (isAutoScrollBlocked && now < blockUntilTime) {
13962
- if (!force) return;
13963
- }
13964
- if (isAutoScrollBlocked && now >= blockUntilTime) {
13965
- isAutoScrollBlocked = false;
14304
+ let smoothScrollRAF = null;
14305
+ const getScrollableContainer = () => {
14306
+ const scrollable = wrapper.querySelector("#persona-scroll-container");
14307
+ return scrollable || body;
14308
+ };
14309
+ const cancelSmoothScroll = () => {
14310
+ if (smoothScrollRAF !== null) {
14311
+ cancelAnimationFrame(smoothScrollRAF);
14312
+ smoothScrollRAF = null;
13966
14313
  }
13967
- if (!force && !isStreaming) return;
13968
- if (now - lastAutoScrollTime < AUTO_SCROLL_THROTTLE) return;
13969
- lastAutoScrollTime = now;
13970
- if (scrollRAF) {
14314
+ isAutoScrolling = false;
14315
+ };
14316
+ const cancelAutoScroll = () => {
14317
+ if (scrollRAF !== null) {
13971
14318
  cancelAnimationFrame(scrollRAF);
14319
+ scrollRAF = null;
13972
14320
  }
14321
+ cancelSmoothScroll();
14322
+ };
14323
+ const syncScrollToBottomButton = () => {
14324
+ if (!isScrollToBottomEnabled() || eventStreamVisible) {
14325
+ if (scrollToBottomButton.parentNode) {
14326
+ scrollToBottomButton.remove();
14327
+ }
14328
+ scrollToBottomButton.style.display = "none";
14329
+ return;
14330
+ }
14331
+ if (scrollToBottomButton.parentNode !== container) {
14332
+ container.appendChild(scrollToBottomButton);
14333
+ }
14334
+ updateScrollToBottomButtonOffset();
14335
+ const hasOverflow = getScrollBottomOffset(body) > 0;
14336
+ scrollToBottomButton.style.display = autoFollow.isFollowing() || !hasOverflow ? "none" : "";
14337
+ };
14338
+ const pauseAutoScroll = () => {
14339
+ if (!autoFollow.pause()) return;
14340
+ cancelAutoScroll();
14341
+ syncScrollToBottomButton();
14342
+ };
14343
+ const resumeAutoScroll = () => {
14344
+ autoFollow.resume();
14345
+ syncScrollToBottomButton();
14346
+ };
14347
+ const scheduleAutoScroll = (force = false) => {
14348
+ if (!autoFollow.isFollowing()) return;
14349
+ if (!force && !isStreaming) return;
14350
+ cancelAutoScroll();
13973
14351
  scrollRAF = requestAnimationFrame(() => {
13974
- if (isAutoScrollBlocked || !shouldAutoScroll) return;
13975
- isAutoScrolling = true;
13976
- body.scrollTop = body.scrollHeight;
13977
- lastScrollTop = body.scrollTop;
13978
- requestAnimationFrame(() => {
13979
- isAutoScrolling = false;
13980
- });
13981
14352
  scrollRAF = null;
14353
+ if (!autoFollow.isFollowing()) return;
14354
+ smoothScrollToBottom(getScrollableContainer(), force ? 220 : 140);
13982
14355
  });
13983
14356
  };
13984
- let smoothScrollRAF = null;
13985
- const getScrollableContainer = () => {
13986
- const scrollable = wrapper.querySelector("#persona-scroll-container");
13987
- return scrollable || body;
13988
- };
13989
14357
  const smoothScrollToBottom = (element, duration = 500) => {
13990
14358
  const start = element.scrollTop;
13991
- const clientHeight = element.clientHeight;
13992
- let target = element.scrollHeight;
14359
+ let target = getScrollBottomOffset(element);
13993
14360
  let distance = target - start;
13994
- const isAtBottom = start + clientHeight >= target - 2;
13995
- if (isAtBottom || Math.abs(distance) < 5) {
14361
+ if (Math.abs(distance) < 1) {
14362
+ lastScrollTop = element.scrollTop;
13996
14363
  return;
13997
14364
  }
13998
- if (smoothScrollRAF !== null) {
13999
- cancelAnimationFrame(smoothScrollRAF);
14000
- smoothScrollRAF = null;
14001
- }
14365
+ cancelSmoothScroll();
14002
14366
  const startTime = performance.now();
14367
+ isAutoScrolling = true;
14003
14368
  const easeOutCubic = (t) => {
14004
14369
  return 1 - Math.pow(1 - t, 3);
14005
14370
  };
14006
14371
  const animate = (currentTime) => {
14007
- const currentTarget = element.scrollHeight;
14372
+ if (!autoFollow.isFollowing()) {
14373
+ cancelSmoothScroll();
14374
+ return;
14375
+ }
14376
+ const currentTarget = getScrollBottomOffset(element);
14008
14377
  if (currentTarget !== target) {
14009
14378
  target = currentTarget;
14010
14379
  distance = target - start;
@@ -14014,11 +14383,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14014
14383
  const eased = easeOutCubic(progress);
14015
14384
  const currentScroll = start + distance * eased;
14016
14385
  element.scrollTop = currentScroll;
14386
+ lastScrollTop = element.scrollTop;
14017
14387
  if (progress < 1) {
14018
14388
  smoothScrollRAF = requestAnimationFrame(animate);
14019
14389
  } else {
14020
- element.scrollTop = element.scrollHeight;
14390
+ element.scrollTop = target;
14391
+ lastScrollTop = element.scrollTop;
14021
14392
  smoothScrollRAF = null;
14393
+ isAutoScrolling = false;
14022
14394
  }
14023
14395
  };
14024
14396
  smoothScrollRAF = requestAnimationFrame(animate);
@@ -14358,15 +14730,6 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14358
14730
  }
14359
14731
  }
14360
14732
  morphMessages(container2, tempContainer);
14361
- if (shouldAutoScroll && !isAutoScrollBlocked) {
14362
- requestAnimationFrame(() => {
14363
- requestAnimationFrame(() => {
14364
- if (!shouldAutoScroll || isAutoScrollBlocked) return;
14365
- const scrollableContainer = getScrollableContainer();
14366
- smoothScrollToBottom(scrollableContainer);
14367
- });
14368
- });
14369
- }
14370
14733
  };
14371
14734
  const renderMessagesWithPlugins = renderMessagesWithPluginsImpl;
14372
14735
  const updateOpenState = () => {
@@ -14417,11 +14780,42 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14417
14780
  }
14418
14781
  };
14419
14782
  const setOpenState = (nextOpen, source = "user") => {
14783
+ var _a2, _b2;
14420
14784
  if (!launcherEnabled) return;
14421
14785
  if (open === nextOpen) return;
14422
14786
  const prevOpen = open;
14423
14787
  open = nextOpen;
14424
14788
  updateOpenState();
14789
+ const isViewportCovering = (() => {
14790
+ var _a3, _b3, _c2, _d2, _e2, _f2, _g2;
14791
+ const sm = (_b3 = (_a3 = config.launcher) == null ? void 0 : _a3.sidebarMode) != null ? _b3 : false;
14792
+ const ow = (_c2 = mount.ownerDocument.defaultView) != null ? _c2 : window;
14793
+ const mf = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.mobileFullscreen) != null ? _e2 : true;
14794
+ const mb = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.mobileBreakpoint) != null ? _g2 : 640;
14795
+ const isMobile = ow.innerWidth <= mb;
14796
+ const dockedMF = isDockedMountMode(config) && mf && isMobile;
14797
+ return sm || mf && isMobile && launcherEnabled || dockedMF;
14798
+ })();
14799
+ if (open && isViewportCovering) {
14800
+ if (!teardownHostStacking) {
14801
+ const root = mount.getRootNode();
14802
+ const hostEl = root instanceof ShadowRoot ? root.host : mount.closest(".persona-host");
14803
+ if (hostEl) {
14804
+ teardownHostStacking = syncOverlayHostStacking(
14805
+ hostEl,
14806
+ (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.zIndex) != null ? _b2 : DEFAULT_OVERLAY_Z_INDEX
14807
+ );
14808
+ }
14809
+ }
14810
+ if (!releaseScrollLock) {
14811
+ releaseScrollLock = acquireScrollLock(mount.ownerDocument);
14812
+ }
14813
+ } else if (!open) {
14814
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
14815
+ teardownHostStacking = null;
14816
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
14817
+ releaseScrollLock = null;
14818
+ }
14425
14819
  if (open) {
14426
14820
  recalcPanelHeight();
14427
14821
  scheduleAutoScroll(true);
@@ -14584,7 +14978,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14584
14978
  }
14585
14979
  });
14586
14980
  sessionRef.current = session;
14587
- if (((_E = (_D = config.voiceRecognition) == null ? void 0 : _D.provider) == null ? void 0 : _E.type) === "runtype") {
14981
+ if (((_G = (_F = config.voiceRecognition) == null ? void 0 : _F.provider) == null ? void 0 : _G.type) === "runtype") {
14588
14982
  try {
14589
14983
  session.setupVoice();
14590
14984
  } catch (err) {
@@ -15113,7 +15507,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15113
15507
  }
15114
15508
  }
15115
15509
  const recalcPanelHeight = () => {
15116
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
15510
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2;
15117
15511
  const dockedMode = isDockedMountMode(config);
15118
15512
  const sidebarMode = (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.sidebarMode) != null ? _b2 : false;
15119
15513
  const fullHeight = dockedMode || sidebarMode || ((_d2 = (_c2 = config.launcher) == null ? void 0 : _c2.fullHeight) != null ? _d2 : false);
@@ -15155,38 +15549,94 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15155
15549
  panel.style.height = `${finalHeight}px`;
15156
15550
  }
15157
15551
  } finally {
15552
+ updateScrollToBottomButtonOffset();
15158
15553
  updateOpenState();
15554
+ if (open && launcherEnabled) {
15555
+ const ow = (_n2 = mount.ownerDocument.defaultView) != null ? _n2 : window;
15556
+ const isMobile = ow.innerWidth <= ((_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.mobileBreakpoint) != null ? _p2 : 640);
15557
+ const sm = (_r2 = (_q2 = config.launcher) == null ? void 0 : _q2.sidebarMode) != null ? _r2 : false;
15558
+ const mf = (_t2 = (_s2 = config.launcher) == null ? void 0 : _s2.mobileFullscreen) != null ? _t2 : true;
15559
+ const dockedMF = isDockedMountMode(config) && mf && isMobile;
15560
+ const isVC = sm || mf && isMobile && launcherEnabled || dockedMF;
15561
+ if (isVC && !releaseScrollLock) {
15562
+ const root = mount.getRootNode();
15563
+ const hostEl = root instanceof ShadowRoot ? root.host : mount.closest(".persona-host");
15564
+ if (hostEl && !teardownHostStacking) {
15565
+ teardownHostStacking = syncOverlayHostStacking(
15566
+ hostEl,
15567
+ (_v2 = (_u2 = config.launcher) == null ? void 0 : _u2.zIndex) != null ? _v2 : DEFAULT_OVERLAY_Z_INDEX
15568
+ );
15569
+ }
15570
+ releaseScrollLock = acquireScrollLock(mount.ownerDocument);
15571
+ } else if (!isVC) {
15572
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
15573
+ teardownHostStacking = null;
15574
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
15575
+ releaseScrollLock = null;
15576
+ }
15577
+ }
15159
15578
  }
15160
15579
  };
15161
15580
  recalcPanelHeight();
15162
- const ownerWindow = (_F = mount.ownerDocument.defaultView) != null ? _F : window;
15581
+ const ownerWindow = (_H = mount.ownerDocument.defaultView) != null ? _H : window;
15163
15582
  ownerWindow.addEventListener("resize", recalcPanelHeight);
15164
15583
  destroyCallbacks.push(() => ownerWindow.removeEventListener("resize", recalcPanelHeight));
15584
+ if (typeof ResizeObserver !== "undefined") {
15585
+ const footerResizeObserver = new ResizeObserver(() => {
15586
+ updateScrollToBottomButtonOffset();
15587
+ });
15588
+ footerResizeObserver.observe(footer);
15589
+ destroyCallbacks.push(() => footerResizeObserver.disconnect());
15590
+ }
15165
15591
  lastScrollTop = body.scrollTop;
15166
15592
  const handleScroll = () => {
15167
15593
  const scrollTop = body.scrollTop;
15168
- const scrollHeight = body.scrollHeight;
15169
- const clientHeight = body.clientHeight;
15170
- const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
15171
- const delta = Math.abs(scrollTop - lastScrollTop);
15172
- lastScrollTop = scrollTop;
15173
- if (isAutoScrolling) return;
15174
- if (delta <= USER_SCROLL_THRESHOLD) return;
15175
- if (!shouldAutoScroll && distanceFromBottom < BOTTOM_THRESHOLD) {
15176
- isAutoScrollBlocked = false;
15177
- shouldAutoScroll = true;
15594
+ const { action, nextLastScrollTop } = resolveFollowStateFromScroll({
15595
+ following: autoFollow.isFollowing(),
15596
+ currentScrollTop: scrollTop,
15597
+ lastScrollTop,
15598
+ nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
15599
+ userScrollThreshold: USER_SCROLL_THRESHOLD,
15600
+ isAutoScrolling,
15601
+ pauseOnUpwardScroll: true,
15602
+ pauseWhenAwayFromBottom: false,
15603
+ resumeRequiresDownwardScroll: true
15604
+ });
15605
+ lastScrollTop = nextLastScrollTop;
15606
+ if (action === "resume") {
15607
+ resumeAutoScroll();
15178
15608
  return;
15179
15609
  }
15180
- if (shouldAutoScroll && distanceFromBottom > BOTTOM_THRESHOLD) {
15181
- isAutoScrollBlocked = true;
15182
- blockUntilTime = Date.now() + AUTO_SCROLL_BLOCK_TIME;
15183
- shouldAutoScroll = false;
15610
+ if (action === "pause") {
15611
+ pauseAutoScroll();
15184
15612
  }
15185
15613
  };
15186
15614
  body.addEventListener("scroll", handleScroll, { passive: true });
15187
15615
  destroyCallbacks.push(() => body.removeEventListener("scroll", handleScroll));
15616
+ const handleWheel = (event) => {
15617
+ const action = resolveFollowStateFromWheel({
15618
+ following: autoFollow.isFollowing(),
15619
+ deltaY: event.deltaY,
15620
+ nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
15621
+ resumeWhenNearBottom: true
15622
+ });
15623
+ if (action === "pause") {
15624
+ pauseAutoScroll();
15625
+ } else if (action === "resume") {
15626
+ resumeAutoScroll();
15627
+ }
15628
+ };
15629
+ body.addEventListener("wheel", handleWheel, { passive: true });
15630
+ destroyCallbacks.push(() => body.removeEventListener("wheel", handleWheel));
15631
+ scrollToBottomButton.addEventListener("click", () => {
15632
+ body.scrollTop = body.scrollHeight;
15633
+ lastScrollTop = body.scrollTop;
15634
+ resumeAutoScroll();
15635
+ scheduleAutoScroll(true);
15636
+ });
15637
+ destroyCallbacks.push(() => scrollToBottomButton.remove());
15188
15638
  destroyCallbacks.push(() => {
15189
- if (scrollRAF) cancelAnimationFrame(scrollRAF);
15639
+ cancelAutoScroll();
15190
15640
  });
15191
15641
  const refreshCloseButton = () => {
15192
15642
  if (!closeButton) return;
@@ -15211,6 +15661,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15211
15661
  clearChatButton.addEventListener("click", () => {
15212
15662
  session.clearMessages();
15213
15663
  messageCache.clear();
15664
+ resumeAutoScroll();
15214
15665
  try {
15215
15666
  localStorage.removeItem(DEFAULT_CHAT_HISTORY_STORAGE_KEY);
15216
15667
  if (config.debug) {
@@ -15282,7 +15733,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15282
15733
  }
15283
15734
  const controller = {
15284
15735
  update(nextConfig) {
15285
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z2, _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2, _I2, _J2, _K2, _L2, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa;
15736
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2, _x2, _y2, _z2, _A2, _B2, _C2, _D2, _E2, _F2, _G2, _H2, _I2, _J2, _K2, _L2, _M2, _N2, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra;
15286
15737
  const previousToolCallConfig = config.toolCall;
15287
15738
  const previousMessageActions = config.messageActions;
15288
15739
  const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
@@ -15305,8 +15756,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15305
15756
  autoExpand = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.autoExpand) != null ? _e2 : false;
15306
15757
  showReasoning = (_g2 = (_f2 = config.features) == null ? void 0 : _f2.showReasoning) != null ? _g2 : true;
15307
15758
  showToolCalls = (_i2 = (_h2 = config.features) == null ? void 0 : _h2.showToolCalls) != null ? _i2 : true;
15759
+ scrollToBottomFeature = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.scrollToBottom) != null ? _k2 : {};
15760
+ renderScrollToBottomButton();
15761
+ syncScrollToBottomButton();
15308
15762
  const prevShowEventStreamToggle = showEventStreamToggle;
15309
- showEventStreamToggle = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showEventStreamToggle) != null ? _k2 : false;
15763
+ showEventStreamToggle = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showEventStreamToggle) != null ? _m2 : false;
15310
15764
  if (showEventStreamToggle && !prevShowEventStreamToggle) {
15311
15765
  if (!eventStreamBuffer) {
15312
15766
  eventStreamStore = new EventStreamStore(eventStreamDbName);
@@ -15323,7 +15777,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15323
15777
  });
15324
15778
  }
15325
15779
  if (!eventStreamToggleBtn && header) {
15326
- const dynEsClassNames = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.eventStream) == null ? void 0 : _m2.classNames;
15780
+ const dynEsClassNames = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.eventStream) == null ? void 0 : _o2.classNames;
15327
15781
  const dynToggleBtnClasses = "persona-inline-flex persona-items-center persona-justify-center persona-rounded-full hover:persona-opacity-80 persona-cursor-pointer persona-border-none persona-bg-transparent persona-p-1" + ((dynEsClassNames == null ? void 0 : dynEsClassNames.toggleButton) ? " " + dynEsClassNames.toggleButton : "");
15328
15782
  eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
15329
15783
  eventStreamToggleBtn.style.width = "28px";
@@ -15361,15 +15815,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15361
15815
  eventStreamBuffer = null;
15362
15816
  eventStreamStore = null;
15363
15817
  }
15364
- if (((_n2 = config.launcher) == null ? void 0 : _n2.enabled) === false && launcherButtonInstance) {
15818
+ if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) === false && launcherButtonInstance) {
15365
15819
  launcherButtonInstance.destroy();
15366
15820
  launcherButtonInstance = null;
15367
15821
  }
15368
- if (((_o2 = config.launcher) == null ? void 0 : _o2.enabled) === false && customLauncherElement) {
15822
+ if (((_q2 = config.launcher) == null ? void 0 : _q2.enabled) === false && customLauncherElement) {
15369
15823
  customLauncherElement.remove();
15370
15824
  customLauncherElement = null;
15371
15825
  }
15372
- if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
15826
+ if (((_r2 = config.launcher) == null ? void 0 : _r2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
15373
15827
  const launcherPlugin = plugins.find((p) => p.renderLauncher);
15374
15828
  if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
15375
15829
  const customLauncher = launcherPlugin.renderLauncher({
@@ -15393,13 +15847,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15393
15847
  if (launcherButtonInstance) {
15394
15848
  launcherButtonInstance.update(config);
15395
15849
  }
15396
- if (headerTitle && ((_q2 = config.launcher) == null ? void 0 : _q2.title) !== void 0) {
15850
+ if (headerTitle && ((_s2 = config.launcher) == null ? void 0 : _s2.title) !== void 0) {
15397
15851
  headerTitle.textContent = config.launcher.title;
15398
15852
  }
15399
- if (headerSubtitle && ((_r2 = config.launcher) == null ? void 0 : _r2.subtitle) !== void 0) {
15853
+ if (headerSubtitle && ((_t2 = config.launcher) == null ? void 0 : _t2.subtitle) !== void 0) {
15400
15854
  headerSubtitle.textContent = config.launcher.subtitle;
15401
15855
  }
15402
- const headerLayoutConfig = (_s2 = config.layout) == null ? void 0 : _s2.header;
15856
+ const headerLayoutConfig = (_u2 = config.layout) == null ? void 0 : _u2.header;
15403
15857
  const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
15404
15858
  if (headerLayoutChanged && header) {
15405
15859
  const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
@@ -15445,14 +15899,16 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15445
15899
  }
15446
15900
  }
15447
15901
  }
15448
- const showHeader = ((_t2 = config.layout) == null ? void 0 : _t2.showHeader) !== false;
15902
+ const showHeader = ((_v2 = config.layout) == null ? void 0 : _v2.showHeader) !== false;
15449
15903
  if (header) {
15450
15904
  header.style.display = showHeader ? "" : "none";
15451
15905
  }
15452
- const showFooter = ((_u2 = config.layout) == null ? void 0 : _u2.showFooter) !== false;
15906
+ const showFooter = ((_w2 = config.layout) == null ? void 0 : _w2.showFooter) !== false;
15453
15907
  if (footer) {
15454
15908
  footer.style.display = showFooter ? "" : "none";
15455
15909
  }
15910
+ updateScrollToBottomButtonOffset();
15911
+ syncScrollToBottomButton();
15456
15912
  const launcherEnabledChanged = launcherEnabled !== prevLauncherEnabled;
15457
15913
  const autoExpandChanged = autoExpand !== prevAutoExpand;
15458
15914
  if (launcherEnabledChanged) {
@@ -15471,20 +15927,20 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15471
15927
  refreshCloseButton();
15472
15928
  const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
15473
15929
  const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
15474
- const layoutMessagesChanged = JSON.stringify((_v2 = config.layout) == null ? void 0 : _v2.messages) !== JSON.stringify(previousLayoutMessages);
15475
- const loadingIndicatorChanged = ((_w2 = config.loadingIndicator) == null ? void 0 : _w2.render) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.render) || ((_x2 = config.loadingIndicator) == null ? void 0 : _x2.renderIdle) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.renderIdle) || ((_y2 = config.loadingIndicator) == null ? void 0 : _y2.showBubble) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.showBubble);
15930
+ const layoutMessagesChanged = JSON.stringify((_x2 = config.layout) == null ? void 0 : _x2.messages) !== JSON.stringify(previousLayoutMessages);
15931
+ const loadingIndicatorChanged = ((_y2 = config.loadingIndicator) == null ? void 0 : _y2.render) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.render) || ((_z2 = config.loadingIndicator) == null ? void 0 : _z2.renderIdle) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.renderIdle) || ((_A2 = config.loadingIndicator) == null ? void 0 : _A2.showBubble) !== (previousLoadingIndicator == null ? void 0 : previousLoadingIndicator.showBubble);
15476
15932
  const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
15477
15933
  const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged;
15478
15934
  if (messagesConfigChanged && session) {
15479
15935
  configVersion++;
15480
15936
  renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
15481
15937
  }
15482
- const launcher = (_z2 = config.launcher) != null ? _z2 : {};
15483
- const headerIconHidden = (_A2 = launcher.headerIconHidden) != null ? _A2 : false;
15484
- const layoutShowIcon = (_C2 = (_B2 = config.layout) == null ? void 0 : _B2.header) == null ? void 0 : _C2.showIcon;
15938
+ const launcher = (_B2 = config.launcher) != null ? _B2 : {};
15939
+ const headerIconHidden = (_C2 = launcher.headerIconHidden) != null ? _C2 : false;
15940
+ const layoutShowIcon = (_E2 = (_D2 = config.layout) == null ? void 0 : _D2.header) == null ? void 0 : _E2.showIcon;
15485
15941
  const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
15486
15942
  const headerIconName = launcher.headerIconName;
15487
- const headerIconSize = (_D2 = launcher.headerIconSize) != null ? _D2 : "48px";
15943
+ const headerIconSize = (_F2 = launcher.headerIconSize) != null ? _F2 : "48px";
15488
15944
  if (iconHolder) {
15489
15945
  const headerEl = container.querySelector(".persona-border-b-persona-divider");
15490
15946
  const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
@@ -15511,7 +15967,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15511
15967
  if (iconSvg) {
15512
15968
  iconHolder.replaceChildren(iconSvg);
15513
15969
  } else {
15514
- iconHolder.textContent = (_E2 = launcher.agentIconText) != null ? _E2 : "\u{1F4AC}";
15970
+ iconHolder.textContent = (_G2 = launcher.agentIconText) != null ? _G2 : "\u{1F4AC}";
15515
15971
  }
15516
15972
  } else if (launcher.iconUrl) {
15517
15973
  const img2 = iconHolder.querySelector("img");
@@ -15534,7 +15990,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15534
15990
  if (existingSvg || existingImg) {
15535
15991
  iconHolder.replaceChildren();
15536
15992
  }
15537
- iconHolder.textContent = (_F2 = launcher.agentIconText) != null ? _F2 : "\u{1F4AC}";
15993
+ iconHolder.textContent = (_H2 = launcher.agentIconText) != null ? _H2 : "\u{1F4AC}";
15538
15994
  }
15539
15995
  const img = iconHolder.querySelector("img");
15540
15996
  if (img) {
@@ -15543,8 +15999,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15543
15999
  }
15544
16000
  }
15545
16001
  }
15546
- const layoutShowTitle = (_H2 = (_G2 = config.layout) == null ? void 0 : _G2.header) == null ? void 0 : _H2.showTitle;
15547
- const layoutShowSubtitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showSubtitle;
16002
+ const layoutShowTitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showTitle;
16003
+ const layoutShowSubtitle = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showSubtitle;
15548
16004
  if (headerTitle) {
15549
16005
  headerTitle.style.display = layoutShowTitle === false ? "none" : "";
15550
16006
  }
@@ -15552,14 +16008,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15552
16008
  headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
15553
16009
  }
15554
16010
  if (closeButton) {
15555
- const layoutShowCloseButton = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showCloseButton;
16011
+ const layoutShowCloseButton = (_N2 = (_M2 = config.layout) == null ? void 0 : _M2.header) == null ? void 0 : _N2.showCloseButton;
15556
16012
  if (layoutShowCloseButton === false) {
15557
16013
  closeButton.style.display = "none";
15558
16014
  } else {
15559
16015
  closeButton.style.display = "";
15560
16016
  }
15561
- const closeButtonSize = (_M = launcher.closeButtonSize) != null ? _M : "32px";
15562
- const closeButtonPlacement = (_N = launcher.closeButtonPlacement) != null ? _N : "inline";
16017
+ const closeButtonSize = (_O = launcher.closeButtonSize) != null ? _O : "32px";
16018
+ const closeButtonPlacement = (_P = launcher.closeButtonPlacement) != null ? _P : "inline";
15563
16019
  closeButton.style.height = closeButtonSize;
15564
16020
  closeButton.style.width = closeButtonSize;
15565
16021
  const { closeButtonWrapper } = panelElements;
@@ -15572,8 +16028,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15572
16028
  container.style.position = "relative";
15573
16029
  container.appendChild(closeButtonWrapper);
15574
16030
  } else {
15575
- const clearChatPlacement = (_P = (_O = launcher.clearChat) == null ? void 0 : _O.placement) != null ? _P : "inline";
15576
- const clearChatEnabled = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.enabled) != null ? _R : true;
16031
+ const clearChatPlacement = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.placement) != null ? _R : "inline";
16032
+ const clearChatEnabled = (_T = (_S = launcher.clearChat) == null ? void 0 : _S.enabled) != null ? _T : true;
15577
16033
  closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
15578
16034
  const header2 = container.querySelector(".persona-border-b-persona-divider");
15579
16035
  if (header2) {
@@ -15619,8 +16075,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15619
16075
  closeButton.style.paddingTop = "";
15620
16076
  closeButton.style.paddingBottom = "";
15621
16077
  }
15622
- const closeButtonIconName = (_S = launcher.closeButtonIconName) != null ? _S : "x";
15623
- const closeButtonIconText = (_T = launcher.closeButtonIconText) != null ? _T : "\xD7";
16078
+ const closeButtonIconName = (_U = launcher.closeButtonIconName) != null ? _U : "x";
16079
+ const closeButtonIconText = (_V = launcher.closeButtonIconText) != null ? _V : "\xD7";
15624
16080
  closeButton.innerHTML = "";
15625
16081
  const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
15626
16082
  if (iconSvg) {
@@ -15628,8 +16084,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15628
16084
  } else {
15629
16085
  closeButton.textContent = closeButtonIconText;
15630
16086
  }
15631
- const closeButtonTooltipText = (_U = launcher.closeButtonTooltipText) != null ? _U : "Close chat";
15632
- const closeButtonShowTooltip = (_V = launcher.closeButtonShowTooltip) != null ? _V : true;
16087
+ const closeButtonTooltipText = (_W = launcher.closeButtonTooltipText) != null ? _W : "Close chat";
16088
+ const closeButtonShowTooltip = (_X = launcher.closeButtonShowTooltip) != null ? _X : true;
15633
16089
  closeButton.setAttribute("aria-label", closeButtonTooltipText);
15634
16090
  if (closeButtonWrapper) {
15635
16091
  if (closeButtonWrapper._cleanupTooltip) {
@@ -15654,6 +16110,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15654
16110
  portaledTooltip.appendChild(arrow);
15655
16111
  const buttonRect = closeButton.getBoundingClientRect();
15656
16112
  portaledTooltip.style.position = "fixed";
16113
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
15657
16114
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
15658
16115
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
15659
16116
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -15685,11 +16142,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15685
16142
  }
15686
16143
  const { clearChatButton, clearChatButtonWrapper } = panelElements;
15687
16144
  if (clearChatButton) {
15688
- const clearChatConfig = (_W = launcher.clearChat) != null ? _W : {};
15689
- const clearChatEnabled = (_X = clearChatConfig.enabled) != null ? _X : true;
15690
- const layoutShowClearChat = (_Z = (_Y = config.layout) == null ? void 0 : _Y.header) == null ? void 0 : _Z.showClearChat;
16145
+ const clearChatConfig = (_Y = launcher.clearChat) != null ? _Y : {};
16146
+ const clearChatEnabled = (_Z = clearChatConfig.enabled) != null ? _Z : true;
16147
+ const layoutShowClearChat = (_$ = (__ = config.layout) == null ? void 0 : __.header) == null ? void 0 : _$.showClearChat;
15691
16148
  const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
15692
- const clearChatPlacement = (__ = clearChatConfig.placement) != null ? __ : "inline";
16149
+ const clearChatPlacement = (_aa = clearChatConfig.placement) != null ? _aa : "inline";
15693
16150
  if (clearChatButtonWrapper) {
15694
16151
  clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
15695
16152
  const { closeButtonWrapper } = panelElements;
@@ -15731,11 +16188,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15731
16188
  }
15732
16189
  }
15733
16190
  if (shouldShowClearChat) {
15734
- const clearChatSize = (_$ = clearChatConfig.size) != null ? _$ : "32px";
16191
+ const clearChatSize = (_ba = clearChatConfig.size) != null ? _ba : "32px";
15735
16192
  clearChatButton.style.height = clearChatSize;
15736
16193
  clearChatButton.style.width = clearChatSize;
15737
- const clearChatIconName = (_aa = clearChatConfig.iconName) != null ? _aa : "refresh-cw";
15738
- const clearChatIconColor = (_ba = clearChatConfig.iconColor) != null ? _ba : "";
16194
+ const clearChatIconName = (_ca = clearChatConfig.iconName) != null ? _ca : "refresh-cw";
16195
+ const clearChatIconColor = (_da = clearChatConfig.iconColor) != null ? _da : "";
15739
16196
  clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
15740
16197
  clearChatButton.innerHTML = "";
15741
16198
  const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
@@ -15779,8 +16236,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15779
16236
  clearChatButton.style.paddingTop = "";
15780
16237
  clearChatButton.style.paddingBottom = "";
15781
16238
  }
15782
- const clearChatTooltipText = (_ca = clearChatConfig.tooltipText) != null ? _ca : "Clear chat";
15783
- const clearChatShowTooltip = (_da = clearChatConfig.showTooltip) != null ? _da : true;
16239
+ const clearChatTooltipText = (_ea = clearChatConfig.tooltipText) != null ? _ea : "Clear chat";
16240
+ const clearChatShowTooltip = (_fa = clearChatConfig.showTooltip) != null ? _fa : true;
15784
16241
  clearChatButton.setAttribute("aria-label", clearChatTooltipText);
15785
16242
  if (clearChatButtonWrapper) {
15786
16243
  if (clearChatButtonWrapper._cleanupTooltip) {
@@ -15805,6 +16262,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15805
16262
  portaledTooltip.appendChild(arrow);
15806
16263
  const buttonRect = clearChatButton.getBoundingClientRect();
15807
16264
  portaledTooltip.style.position = "fixed";
16265
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
15808
16266
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
15809
16267
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
15810
16268
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -15855,9 +16313,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15855
16313
  suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
15856
16314
  updateCopy();
15857
16315
  setComposerDisabled(session.isStreaming());
15858
- const voiceRecognitionEnabled = ((_ea = config.voiceRecognition) == null ? void 0 : _ea.enabled) === true;
16316
+ const voiceRecognitionEnabled = ((_ga = config.voiceRecognition) == null ? void 0 : _ga.enabled) === true;
15859
16317
  const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
15860
- const hasRuntypeProvider = ((_ga = (_fa = config.voiceRecognition) == null ? void 0 : _fa.provider) == null ? void 0 : _ga.type) === "runtype";
16318
+ const hasRuntypeProvider = ((_ia = (_ha = config.voiceRecognition) == null ? void 0 : _ha.provider) == null ? void 0 : _ia.type) === "runtype";
15861
16319
  const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
15862
16320
  if (voiceRecognitionEnabled && hasVoiceInput) {
15863
16321
  if (!micButton || !micButtonWrapper) {
@@ -15870,17 +16328,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15870
16328
  micButton.disabled = session.isStreaming();
15871
16329
  }
15872
16330
  } else {
15873
- const voiceConfig = (_ha = config.voiceRecognition) != null ? _ha : {};
15874
- const sendButtonConfig2 = (_ia = config.sendButton) != null ? _ia : {};
15875
- const micIconName = (_ja = voiceConfig.iconName) != null ? _ja : "mic";
15876
- const buttonSize2 = (_ka = sendButtonConfig2.size) != null ? _ka : "40px";
15877
- const micIconSize = (_la = voiceConfig.iconSize) != null ? _la : buttonSize2;
16331
+ const voiceConfig = (_ja = config.voiceRecognition) != null ? _ja : {};
16332
+ const sendButtonConfig2 = (_ka = config.sendButton) != null ? _ka : {};
16333
+ const micIconName = (_la = voiceConfig.iconName) != null ? _la : "mic";
16334
+ const buttonSize2 = (_ma = sendButtonConfig2.size) != null ? _ma : "40px";
16335
+ const micIconSize = (_na = voiceConfig.iconSize) != null ? _na : buttonSize2;
15878
16336
  const micIconSizeNum = parseFloat(micIconSize) || 24;
15879
16337
  micButton.style.width = micIconSize;
15880
16338
  micButton.style.height = micIconSize;
15881
16339
  micButton.style.minWidth = micIconSize;
15882
16340
  micButton.style.minHeight = micIconSize;
15883
- const iconColor = (_na = (_ma = voiceConfig.iconColor) != null ? _ma : sendButtonConfig2.textColor) != null ? _na : "currentColor";
16341
+ const iconColor = (_pa = (_oa = voiceConfig.iconColor) != null ? _oa : sendButtonConfig2.textColor) != null ? _pa : "currentColor";
15884
16342
  micButton.innerHTML = "";
15885
16343
  const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
15886
16344
  if (micIconSvg) {
@@ -15888,7 +16346,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15888
16346
  } else {
15889
16347
  micButton.textContent = "\u{1F3A4}";
15890
16348
  }
15891
- const backgroundColor2 = (_oa = voiceConfig.backgroundColor) != null ? _oa : sendButtonConfig2.backgroundColor;
16349
+ const backgroundColor2 = (_qa = voiceConfig.backgroundColor) != null ? _qa : sendButtonConfig2.backgroundColor;
15892
16350
  if (backgroundColor2) {
15893
16351
  micButton.style.backgroundColor = backgroundColor2;
15894
16352
  } else {
@@ -15926,8 +16384,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15926
16384
  micButton.style.paddingBottom = "";
15927
16385
  }
15928
16386
  const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
15929
- const tooltipText2 = (_pa = voiceConfig.tooltipText) != null ? _pa : "Start voice recognition";
15930
- const showTooltip2 = (_qa = voiceConfig.showTooltip) != null ? _qa : false;
16387
+ const tooltipText2 = (_ra = voiceConfig.tooltipText) != null ? _ra : "Start voice recognition";
16388
+ const showTooltip2 = (_sa = voiceConfig.showTooltip) != null ? _sa : false;
15931
16389
  if (showTooltip2 && tooltipText2) {
15932
16390
  if (!tooltip2) {
15933
16391
  const newTooltip = document.createElement("div");
@@ -15947,19 +16405,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15947
16405
  } else {
15948
16406
  if (micButton && micButtonWrapper) {
15949
16407
  micButtonWrapper.style.display = "none";
15950
- if (((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype") {
16408
+ if (((_ua = (_ta = config.voiceRecognition) == null ? void 0 : _ta.provider) == null ? void 0 : _ua.type) === "runtype") {
15951
16409
  if (session.isVoiceActive()) session.toggleVoice();
15952
16410
  } else if (isRecording) {
15953
16411
  stopVoiceRecognition();
15954
16412
  }
15955
16413
  }
15956
16414
  }
15957
- const attachmentsEnabled = ((_ta = config.attachments) == null ? void 0 : _ta.enabled) === true;
16415
+ const attachmentsEnabled = ((_va = config.attachments) == null ? void 0 : _va.enabled) === true;
15958
16416
  if (attachmentsEnabled) {
15959
16417
  if (!attachmentButtonWrapper || !attachmentButton) {
15960
- const attachmentsConfig = (_ua = config.attachments) != null ? _ua : {};
15961
- const sendButtonConfig2 = (_va = config.sendButton) != null ? _va : {};
15962
- const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
16418
+ const attachmentsConfig = (_wa = config.attachments) != null ? _wa : {};
16419
+ const sendButtonConfig2 = (_xa = config.sendButton) != null ? _xa : {};
16420
+ const buttonSize2 = (_ya = sendButtonConfig2.size) != null ? _ya : "40px";
15963
16421
  if (!attachmentPreviewsContainer) {
15964
16422
  attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
15965
16423
  attachmentPreviewsContainer.style.display = "none";
@@ -15968,8 +16426,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15968
16426
  if (!attachmentInput) {
15969
16427
  attachmentInput = document.createElement("input");
15970
16428
  attachmentInput.type = "file";
15971
- attachmentInput.accept = ((_xa = attachmentsConfig.allowedTypes) != null ? _xa : ALL_SUPPORTED_MIME_TYPES).join(",");
15972
- attachmentInput.multiple = ((_ya = attachmentsConfig.maxFiles) != null ? _ya : 4) > 1;
16429
+ attachmentInput.accept = ((_za = attachmentsConfig.allowedTypes) != null ? _za : ALL_SUPPORTED_MIME_TYPES).join(",");
16430
+ attachmentInput.multiple = ((_Aa = attachmentsConfig.maxFiles) != null ? _Aa : 4) > 1;
15973
16431
  attachmentInput.style.display = "none";
15974
16432
  attachmentInput.setAttribute("aria-label", "Attach files");
15975
16433
  composerForm.insertBefore(attachmentInput, textarea);
@@ -15980,8 +16438,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15980
16438
  "persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
15981
16439
  );
15982
16440
  attachmentButton.type = "button";
15983
- attachmentButton.setAttribute("aria-label", (_za = attachmentsConfig.buttonTooltipText) != null ? _za : "Attach file");
15984
- const attachIconName = (_Aa = attachmentsConfig.buttonIconName) != null ? _Aa : "paperclip";
16441
+ attachmentButton.setAttribute("aria-label", (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file");
16442
+ const attachIconName = (_Ca = attachmentsConfig.buttonIconName) != null ? _Ca : "paperclip";
15985
16443
  const attachIconSize = buttonSize2;
15986
16444
  const buttonSizeNum = parseFloat(attachIconSize) || 40;
15987
16445
  const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
@@ -16013,7 +16471,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16013
16471
  attachmentInput == null ? void 0 : attachmentInput.click();
16014
16472
  });
16015
16473
  attachmentButtonWrapper.appendChild(attachmentButton);
16016
- const attachTooltipText = (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file";
16474
+ const attachTooltipText = (_Da = attachmentsConfig.buttonTooltipText) != null ? _Da : "Attach file";
16017
16475
  const tooltip2 = createElement("div", "persona-send-button-tooltip");
16018
16476
  tooltip2.textContent = attachTooltipText;
16019
16477
  attachmentButtonWrapper.appendChild(tooltip2);
@@ -16030,10 +16488,10 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16030
16488
  }
16031
16489
  } else {
16032
16490
  attachmentButtonWrapper.style.display = "";
16033
- const attachmentsConfig = (_Ca = config.attachments) != null ? _Ca : {};
16491
+ const attachmentsConfig = (_Ea = config.attachments) != null ? _Ea : {};
16034
16492
  if (attachmentInput) {
16035
- attachmentInput.accept = ((_Da = attachmentsConfig.allowedTypes) != null ? _Da : ALL_SUPPORTED_MIME_TYPES).join(",");
16036
- attachmentInput.multiple = ((_Ea = attachmentsConfig.maxFiles) != null ? _Ea : 4) > 1;
16493
+ attachmentInput.accept = ((_Fa = attachmentsConfig.allowedTypes) != null ? _Fa : ALL_SUPPORTED_MIME_TYPES).join(",");
16494
+ attachmentInput.multiple = ((_Ga = attachmentsConfig.maxFiles) != null ? _Ga : 4) > 1;
16037
16495
  }
16038
16496
  if (attachmentManager) {
16039
16497
  attachmentManager.updateConfig({
@@ -16051,13 +16509,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16051
16509
  attachmentManager.clearAttachments();
16052
16510
  }
16053
16511
  }
16054
- const sendButtonConfig = (_Fa = config.sendButton) != null ? _Fa : {};
16055
- const useIcon = (_Ga = sendButtonConfig.useIcon) != null ? _Ga : false;
16056
- const iconText = (_Ha = sendButtonConfig.iconText) != null ? _Ha : "\u2191";
16512
+ const sendButtonConfig = (_Ha = config.sendButton) != null ? _Ha : {};
16513
+ const useIcon = (_Ia = sendButtonConfig.useIcon) != null ? _Ia : false;
16514
+ const iconText = (_Ja = sendButtonConfig.iconText) != null ? _Ja : "\u2191";
16057
16515
  const iconName = sendButtonConfig.iconName;
16058
- const tooltipText = (_Ia = sendButtonConfig.tooltipText) != null ? _Ia : "Send message";
16059
- const showTooltip = (_Ja = sendButtonConfig.showTooltip) != null ? _Ja : false;
16060
- const buttonSize = (_Ka = sendButtonConfig.size) != null ? _Ka : "40px";
16516
+ const tooltipText = (_Ka = sendButtonConfig.tooltipText) != null ? _Ka : "Send message";
16517
+ const showTooltip = (_La = sendButtonConfig.showTooltip) != null ? _La : false;
16518
+ const buttonSize = (_Ma = sendButtonConfig.size) != null ? _Ma : "40px";
16061
16519
  const backgroundColor = sendButtonConfig.backgroundColor;
16062
16520
  const textColor = sendButtonConfig.textColor;
16063
16521
  if (useIcon) {
@@ -16094,7 +16552,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16094
16552
  sendButton.classList.add("persona-bg-persona-primary");
16095
16553
  }
16096
16554
  } else {
16097
- sendButton.textContent = (_Ma = (_La = config.copy) == null ? void 0 : _La.sendButtonLabel) != null ? _Ma : "Send";
16555
+ sendButton.textContent = (_Oa = (_Na = config.copy) == null ? void 0 : _Na.sendButtonLabel) != null ? _Oa : "Send";
16098
16556
  sendButton.style.width = "";
16099
16557
  sendButton.style.height = "";
16100
16558
  sendButton.style.minWidth = "";
@@ -16154,7 +16612,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16154
16612
  } else if (tooltip) {
16155
16613
  tooltip.style.display = "none";
16156
16614
  }
16157
- const updatedContentMaxWidth = (_Na = config.layout) == null ? void 0 : _Na.contentMaxWidth;
16615
+ const updatedContentMaxWidth = (_Pa = config.layout) == null ? void 0 : _Pa.contentMaxWidth;
16158
16616
  if (updatedContentMaxWidth) {
16159
16617
  messagesWrapper.style.maxWidth = updatedContentMaxWidth;
16160
16618
  messagesWrapper.style.marginLeft = "auto";
@@ -16176,8 +16634,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16176
16634
  composerForm.style.marginRight = "";
16177
16635
  }
16178
16636
  }
16179
- const statusIndicatorConfig = (_Oa = config.statusIndicator) != null ? _Oa : {};
16180
- const isVisible = (_Pa = statusIndicatorConfig.visible) != null ? _Pa : true;
16637
+ const statusIndicatorConfig = (_Qa = config.statusIndicator) != null ? _Qa : {};
16638
+ const isVisible = (_Ra = statusIndicatorConfig.visible) != null ? _Ra : true;
16181
16639
  statusText.style.display = isVisible ? "" : "none";
16182
16640
  if (session) {
16183
16641
  const currentStatus = session.getStatus();
@@ -16211,6 +16669,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16211
16669
  artifactsPaneUserHidden = false;
16212
16670
  session.clearMessages();
16213
16671
  messageCache.clear();
16672
+ resumeAutoScroll();
16214
16673
  try {
16215
16674
  localStorage.removeItem(DEFAULT_CHAT_HISTORY_STORAGE_KEY);
16216
16675
  if (config.debug) {
@@ -16531,7 +16990,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16531
16990
  }
16532
16991
  }
16533
16992
  };
16534
- const shouldExposeDebugApi = ((_G = runtimeOptions == null ? void 0 : runtimeOptions.debugTools) != null ? _G : false) || Boolean(config.debug);
16993
+ const shouldExposeDebugApi = ((_I = runtimeOptions == null ? void 0 : runtimeOptions.debugTools) != null ? _I : false) || Boolean(config.debug);
16535
16994
  if (shouldExposeDebugApi && typeof window !== "undefined") {
16536
16995
  const previousDebug = window.AgentWidgetBrowser;
16537
16996
  const debugApi = {
@@ -16634,9 +17093,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16634
17093
  const voiceKey = `${persistConfig.keyPrefix}widget-voice`;
16635
17094
  const voiceModeKey = `${persistConfig.keyPrefix}widget-voice-mode`;
16636
17095
  if (storage) {
16637
- const wasOpen = ((_H = persistConfig.persist) == null ? void 0 : _H.openState) && storage.getItem(openKey) === "true";
16638
- const wasVoiceActive = ((_I = persistConfig.persist) == null ? void 0 : _I.voiceState) && storage.getItem(voiceKey) === "true";
16639
- const wasInVoiceMode = ((_J = persistConfig.persist) == null ? void 0 : _J.voiceState) && storage.getItem(voiceModeKey) === "true";
17096
+ const wasOpen = ((_J = persistConfig.persist) == null ? void 0 : _J.openState) && storage.getItem(openKey) === "true";
17097
+ const wasVoiceActive = ((_K = persistConfig.persist) == null ? void 0 : _K.voiceState) && storage.getItem(voiceKey) === "true";
17098
+ const wasInVoiceMode = ((_L = persistConfig.persist) == null ? void 0 : _L.voiceState) && storage.getItem(voiceModeKey) === "true";
16640
17099
  if (wasOpen) {
16641
17100
  setTimeout(() => {
16642
17101
  controller.open();
@@ -16653,7 +17112,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16653
17112
  }, 100);
16654
17113
  }, 0);
16655
17114
  }
16656
- if ((_K = persistConfig.persist) == null ? void 0 : _K.openState) {
17115
+ if ((_M = persistConfig.persist) == null ? void 0 : _M.openState) {
16657
17116
  eventBus.on("widget:opened", () => {
16658
17117
  storage.setItem(openKey, "true");
16659
17118
  });
@@ -16661,7 +17120,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16661
17120
  storage.setItem(openKey, "false");
16662
17121
  });
16663
17122
  }
16664
- if ((_L = persistConfig.persist) == null ? void 0 : _L.voiceState) {
17123
+ if ((_N = persistConfig.persist) == null ? void 0 : _N.voiceState) {
16665
17124
  eventBus.on("voice:state", (event) => {
16666
17125
  storage.setItem(voiceKey, event.active ? "true" : "false");
16667
17126
  });
@@ -16834,7 +17293,7 @@ var applyDockStyles = (shell, pushTrack, contentSlot, dockSlot, host, config, ex
16834
17293
  dockSlot.style.minWidth = "0";
16835
17294
  dockSlot.style.minHeight = "0";
16836
17295
  dockSlot.style.overflow = "hidden";
16837
- dockSlot.style.zIndex = String((_f = (_e = config == null ? void 0 : config.launcher) == null ? void 0 : _e.zIndex) != null ? _f : 9999);
17296
+ dockSlot.style.zIndex = String((_f = (_e = config == null ? void 0 : config.launcher) == null ? void 0 : _e.zIndex) != null ? _f : DEFAULT_OVERLAY_Z_INDEX);
16838
17297
  dockSlot.style.transform = "none";
16839
17298
  dockSlot.style.transition = "none";
16840
17299
  dockSlot.style.pointerEvents = "auto";
@@ -17579,6 +18038,7 @@ export {
17579
18038
  ROLE_INTENSITIES,
17580
18039
  ROLE_LINKS_FOCUS,
17581
18040
  ROLE_PRIMARY_ACTIONS,
18041
+ ROLE_SCROLL_TO_BOTTOM,
17582
18042
  ROLE_SURFACES,
17583
18043
  ROLE_USER_MESSAGES,
17584
18044
  SEMANTIC_COLORS_SECTION,