@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
@@ -58,6 +58,7 @@ __export(theme_editor_exports, {
58
58
  ROLE_INTENSITIES: () => ROLE_INTENSITIES,
59
59
  ROLE_LINKS_FOCUS: () => ROLE_LINKS_FOCUS,
60
60
  ROLE_PRIMARY_ACTIONS: () => ROLE_PRIMARY_ACTIONS,
61
+ ROLE_SCROLL_TO_BOTTOM: () => ROLE_SCROLL_TO_BOTTOM,
61
62
  ROLE_SURFACES: () => ROLE_SURFACES,
62
63
  ROLE_USER_MESSAGES: () => ROLE_USER_MESSAGES,
63
64
  SEMANTIC_COLORS_SECTION: () => SEMANTIC_COLORS_SECTION,
@@ -403,7 +404,8 @@ var DEFAULT_COMPONENTS = {
403
404
  borderRadius: "palette.radius.lg",
404
405
  border: "palette.colors.gray.200",
405
406
  shadow: "palette.shadows.sm"
406
- }
407
+ },
408
+ border: "semantic.colors.border"
407
409
  },
408
410
  toolBubble: {
409
411
  shadow: "palette.shadows.sm"
@@ -425,8 +427,30 @@ var DEFAULT_COMPONENTS = {
425
427
  },
426
428
  prose: {
427
429
  fontFamily: "inherit"
430
+ },
431
+ codeBlock: {
432
+ background: "semantic.colors.container",
433
+ borderColor: "semantic.colors.border",
434
+ textColor: "inherit"
435
+ },
436
+ table: {
437
+ headerBackground: "semantic.colors.container",
438
+ borderColor: "semantic.colors.border"
439
+ },
440
+ hr: {
441
+ color: "semantic.colors.divider"
442
+ },
443
+ blockquote: {
444
+ borderColor: "palette.colors.gray.900",
445
+ background: "transparent",
446
+ textColor: "palette.colors.gray.500"
428
447
  }
429
448
  },
449
+ collapsibleWidget: {
450
+ container: "palette.colors.gray.50",
451
+ surface: "semantic.colors.surface",
452
+ border: "semantic.colors.border"
453
+ },
430
454
  voice: {
431
455
  recording: {
432
456
  indicator: "palette.colors.error.500",
@@ -466,6 +490,18 @@ var DEFAULT_COMPONENTS = {
466
490
  border: "palette.colors.gray.200"
467
491
  }
468
492
  },
493
+ scrollToBottom: {
494
+ background: "components.button.primary.background",
495
+ foreground: "components.button.primary.foreground",
496
+ border: "semantic.colors.primary",
497
+ size: "40px",
498
+ borderRadius: "palette.radius.full",
499
+ shadow: "palette.shadows.sm",
500
+ padding: "0.5rem 0.875rem",
501
+ gap: "0.5rem",
502
+ fontSize: "0.875rem",
503
+ iconSize: "14px"
504
+ },
469
505
  artifact: {
470
506
  pane: {
471
507
  background: "semantic.colors.container",
@@ -647,7 +683,7 @@ function createTheme(userConfig, options = {}) {
647
683
  return theme;
648
684
  }
649
685
  function themeToCssVariables(theme) {
650
- 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;
686
+ 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;
651
687
  const resolved = resolveTokens(theme);
652
688
  const cssVars = {};
653
689
  for (const [path, token] of Object.entries(resolved)) {
@@ -687,44 +723,55 @@ function themeToCssVariables(theme) {
687
723
  cssVars["--persona-radius-md"] = (_B = cssVars["--persona-palette-radius-md"]) != null ? _B : "0.375rem";
688
724
  cssVars["--persona-radius-lg"] = (_C = cssVars["--persona-palette-radius-lg"]) != null ? _C : "0.5rem";
689
725
  cssVars["--persona-radius-xl"] = (_D = cssVars["--persona-palette-radius-xl"]) != null ? _D : "0.75rem";
690
- cssVars["--persona-launcher-radius"] = (_F = (_E = cssVars["--persona-components-launcher-borderRadius"]) != null ? _E : cssVars["--persona-palette-radius-full"]) != null ? _F : "9999px";
691
- cssVars["--persona-launcher-bg"] = (_G = cssVars["--persona-components-launcher-background"]) != null ? _G : cssVars["--persona-primary"];
692
- cssVars["--persona-launcher-fg"] = (_H = cssVars["--persona-components-launcher-foreground"]) != null ? _H : cssVars["--persona-text-inverse"];
693
- cssVars["--persona-launcher-border"] = (_I = cssVars["--persona-components-launcher-border"]) != null ? _I : cssVars["--persona-border"];
694
- cssVars["--persona-button-primary-bg"] = (_J = cssVars["--persona-components-button-primary-background"]) != null ? _J : cssVars["--persona-primary"];
695
- cssVars["--persona-button-primary-fg"] = (_K = cssVars["--persona-components-button-primary-foreground"]) != null ? _K : cssVars["--persona-text-inverse"];
696
- cssVars["--persona-button-radius"] = (_M = (_L = cssVars["--persona-components-button-primary-borderRadius"]) != null ? _L : cssVars["--persona-palette-radius-full"]) != null ? _M : "9999px";
697
- cssVars["--persona-panel-radius"] = (_O = (_N = cssVars["--persona-components-panel-borderRadius"]) != null ? _N : cssVars["--persona-radius-xl"]) != null ? _O : "0.75rem";
698
- cssVars["--persona-panel-border"] = (_P = cssVars["--persona-components-panel-border"]) != null ? _P : `1px solid ${cssVars["--persona-border"]}`;
699
- 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)";
700
- cssVars["--persona-input-radius"] = (_T = (_S = cssVars["--persona-components-input-borderRadius"]) != null ? _S : cssVars["--persona-radius-lg"]) != null ? _T : "0.5rem";
701
- cssVars["--persona-message-user-radius"] = (_V = (_U = cssVars["--persona-components-message-user-borderRadius"]) != null ? _U : cssVars["--persona-radius-lg"]) != null ? _V : "0.5rem";
702
- cssVars["--persona-message-assistant-radius"] = (_X = (_W = cssVars["--persona-components-message-assistant-borderRadius"]) != null ? _W : cssVars["--persona-radius-lg"]) != null ? _X : "0.5rem";
703
- cssVars["--persona-header-bg"] = (_Y = cssVars["--persona-components-header-background"]) != null ? _Y : cssVars["--persona-surface"];
704
- cssVars["--persona-header-border"] = (_Z = cssVars["--persona-components-header-border"]) != null ? _Z : cssVars["--persona-divider"];
705
- cssVars["--persona-header-icon-bg"] = (__ = cssVars["--persona-components-header-iconBackground"]) != null ? __ : cssVars["--persona-primary"];
706
- cssVars["--persona-header-icon-fg"] = (_$ = cssVars["--persona-components-header-iconForeground"]) != null ? _$ : cssVars["--persona-text-inverse"];
707
- cssVars["--persona-header-title-fg"] = (_aa = cssVars["--persona-components-header-titleForeground"]) != null ? _aa : cssVars["--persona-primary"];
708
- cssVars["--persona-header-subtitle-fg"] = (_ba = cssVars["--persona-components-header-subtitleForeground"]) != null ? _ba : cssVars["--persona-text-muted"];
709
- cssVars["--persona-header-action-icon-fg"] = (_ca = cssVars["--persona-components-header-actionIconForeground"]) != null ? _ca : cssVars["--persona-muted"];
710
- const headerTokens = (_da = theme.components) == null ? void 0 : _da.header;
726
+ cssVars["--persona-radius-full"] = (_E = cssVars["--persona-palette-radius-full"]) != null ? _E : "9999px";
727
+ cssVars["--persona-launcher-radius"] = (_G = (_F = cssVars["--persona-components-launcher-borderRadius"]) != null ? _F : cssVars["--persona-palette-radius-full"]) != null ? _G : "9999px";
728
+ cssVars["--persona-launcher-bg"] = (_H = cssVars["--persona-components-launcher-background"]) != null ? _H : cssVars["--persona-primary"];
729
+ cssVars["--persona-launcher-fg"] = (_I = cssVars["--persona-components-launcher-foreground"]) != null ? _I : cssVars["--persona-text-inverse"];
730
+ cssVars["--persona-launcher-border"] = (_J = cssVars["--persona-components-launcher-border"]) != null ? _J : cssVars["--persona-border"];
731
+ cssVars["--persona-button-primary-bg"] = (_K = cssVars["--persona-components-button-primary-background"]) != null ? _K : cssVars["--persona-primary"];
732
+ cssVars["--persona-button-primary-fg"] = (_L = cssVars["--persona-components-button-primary-foreground"]) != null ? _L : cssVars["--persona-text-inverse"];
733
+ cssVars["--persona-button-radius"] = (_N = (_M = cssVars["--persona-components-button-primary-borderRadius"]) != null ? _M : cssVars["--persona-palette-radius-full"]) != null ? _N : "9999px";
734
+ cssVars["--persona-panel-radius"] = (_P = (_O = cssVars["--persona-components-panel-borderRadius"]) != null ? _O : cssVars["--persona-radius-xl"]) != null ? _P : "0.75rem";
735
+ cssVars["--persona-panel-border"] = (_Q = cssVars["--persona-components-panel-border"]) != null ? _Q : `1px solid ${cssVars["--persona-border"]}`;
736
+ 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)";
737
+ cssVars["--persona-input-radius"] = (_U = (_T = cssVars["--persona-components-input-borderRadius"]) != null ? _T : cssVars["--persona-radius-lg"]) != null ? _U : "0.5rem";
738
+ cssVars["--persona-message-user-radius"] = (_W = (_V = cssVars["--persona-components-message-user-borderRadius"]) != null ? _V : cssVars["--persona-radius-lg"]) != null ? _W : "0.5rem";
739
+ cssVars["--persona-message-assistant-radius"] = (_Y = (_X = cssVars["--persona-components-message-assistant-borderRadius"]) != null ? _X : cssVars["--persona-radius-lg"]) != null ? _Y : "0.5rem";
740
+ cssVars["--persona-header-bg"] = (_Z = cssVars["--persona-components-header-background"]) != null ? _Z : cssVars["--persona-surface"];
741
+ cssVars["--persona-header-border"] = (__ = cssVars["--persona-components-header-border"]) != null ? __ : cssVars["--persona-divider"];
742
+ cssVars["--persona-header-icon-bg"] = (_$ = cssVars["--persona-components-header-iconBackground"]) != null ? _$ : cssVars["--persona-primary"];
743
+ cssVars["--persona-header-icon-fg"] = (_aa = cssVars["--persona-components-header-iconForeground"]) != null ? _aa : cssVars["--persona-text-inverse"];
744
+ cssVars["--persona-header-title-fg"] = (_ba = cssVars["--persona-components-header-titleForeground"]) != null ? _ba : cssVars["--persona-primary"];
745
+ cssVars["--persona-header-subtitle-fg"] = (_ca = cssVars["--persona-components-header-subtitleForeground"]) != null ? _ca : cssVars["--persona-text-muted"];
746
+ cssVars["--persona-header-action-icon-fg"] = (_da = cssVars["--persona-components-header-actionIconForeground"]) != null ? _da : cssVars["--persona-muted"];
747
+ const headerTokens = (_ea = theme.components) == null ? void 0 : _ea.header;
711
748
  if (headerTokens == null ? void 0 : headerTokens.shadow) cssVars["--persona-header-shadow"] = headerTokens.shadow;
712
749
  if (headerTokens == null ? void 0 : headerTokens.borderBottom) cssVars["--persona-header-border-bottom"] = headerTokens.borderBottom;
713
- cssVars["--persona-input-background"] = (_ea = cssVars["--persona-components-input-background"]) != null ? _ea : cssVars["--persona-surface"];
714
- cssVars["--persona-input-placeholder"] = (_fa = cssVars["--persona-components-input-placeholder"]) != null ? _fa : cssVars["--persona-text-muted"];
715
- cssVars["--persona-message-user-bg"] = (_ga = cssVars["--persona-components-message-user-background"]) != null ? _ga : cssVars["--persona-accent"];
716
- cssVars["--persona-message-user-text"] = (_ha = cssVars["--persona-components-message-user-text"]) != null ? _ha : cssVars["--persona-text-inverse"];
717
- cssVars["--persona-message-user-shadow"] = (_ia = cssVars["--persona-components-message-user-shadow"]) != null ? _ia : "0 5px 15px rgba(15, 23, 42, 0.08)";
718
- cssVars["--persona-message-assistant-bg"] = (_ja = cssVars["--persona-components-message-assistant-background"]) != null ? _ja : cssVars["--persona-surface"];
719
- cssVars["--persona-message-assistant-text"] = (_ka = cssVars["--persona-components-message-assistant-text"]) != null ? _ka : cssVars["--persona-text"];
720
- cssVars["--persona-message-assistant-border"] = (_la = cssVars["--persona-components-message-assistant-border"]) != null ? _la : cssVars["--persona-border"];
721
- cssVars["--persona-message-assistant-shadow"] = (_ma = cssVars["--persona-components-message-assistant-shadow"]) != null ? _ma : "0 1px 2px 0 rgb(0 0 0 / 0.05)";
722
- cssVars["--persona-tool-bubble-shadow"] = (_na = cssVars["--persona-components-toolBubble-shadow"]) != null ? _na : "0 5px 15px rgba(15, 23, 42, 0.08)";
723
- cssVars["--persona-reasoning-bubble-shadow"] = (_oa = cssVars["--persona-components-reasoningBubble-shadow"]) != null ? _oa : "0 5px 15px rgba(15, 23, 42, 0.08)";
724
- cssVars["--persona-composer-shadow"] = (_pa = cssVars["--persona-components-composer-shadow"]) != null ? _pa : "none";
725
- cssVars["--persona-md-inline-code-bg"] = (_qa = cssVars["--persona-components-markdown-inlineCode-background"]) != null ? _qa : cssVars["--persona-container"];
726
- cssVars["--persona-md-inline-code-color"] = (_ra = cssVars["--persona-components-markdown-inlineCode-foreground"]) != null ? _ra : cssVars["--persona-text"];
727
- cssVars["--persona-md-link-color"] = (_ta = (_sa = cssVars["--persona-components-markdown-link-foreground"]) != null ? _sa : cssVars["--persona-accent"]) != null ? _ta : "#0f0f0f";
750
+ cssVars["--persona-input-background"] = (_fa = cssVars["--persona-components-input-background"]) != null ? _fa : cssVars["--persona-surface"];
751
+ cssVars["--persona-input-placeholder"] = (_ga = cssVars["--persona-components-input-placeholder"]) != null ? _ga : cssVars["--persona-text-muted"];
752
+ cssVars["--persona-message-user-bg"] = (_ha = cssVars["--persona-components-message-user-background"]) != null ? _ha : cssVars["--persona-accent"];
753
+ cssVars["--persona-message-user-text"] = (_ia = cssVars["--persona-components-message-user-text"]) != null ? _ia : cssVars["--persona-text-inverse"];
754
+ cssVars["--persona-message-user-shadow"] = (_ja = cssVars["--persona-components-message-user-shadow"]) != null ? _ja : "0 5px 15px rgba(15, 23, 42, 0.08)";
755
+ cssVars["--persona-message-assistant-bg"] = (_ka = cssVars["--persona-components-message-assistant-background"]) != null ? _ka : cssVars["--persona-surface"];
756
+ cssVars["--persona-message-assistant-text"] = (_la = cssVars["--persona-components-message-assistant-text"]) != null ? _la : cssVars["--persona-text"];
757
+ cssVars["--persona-message-assistant-border"] = (_ma = cssVars["--persona-components-message-assistant-border"]) != null ? _ma : cssVars["--persona-border"];
758
+ cssVars["--persona-message-assistant-shadow"] = (_na = cssVars["--persona-components-message-assistant-shadow"]) != null ? _na : "0 1px 2px 0 rgb(0 0 0 / 0.05)";
759
+ 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"];
760
+ 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"];
761
+ cssVars["--persona-scroll-to-bottom-border"] = (_sa = cssVars["--persona-components-scrollToBottom-border"]) != null ? _sa : cssVars["--persona-primary"];
762
+ cssVars["--persona-scroll-to-bottom-size"] = (_ta = cssVars["--persona-components-scrollToBottom-size"]) != null ? _ta : "40px";
763
+ 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";
764
+ 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)";
765
+ cssVars["--persona-scroll-to-bottom-padding"] = (_za = cssVars["--persona-components-scrollToBottom-padding"]) != null ? _za : "0.5rem 0.875rem";
766
+ cssVars["--persona-scroll-to-bottom-gap"] = (_Aa = cssVars["--persona-components-scrollToBottom-gap"]) != null ? _Aa : "0.5rem";
767
+ 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";
768
+ cssVars["--persona-scroll-to-bottom-icon-size"] = (_Da = cssVars["--persona-components-scrollToBottom-iconSize"]) != null ? _Da : "14px";
769
+ cssVars["--persona-tool-bubble-shadow"] = (_Ea = cssVars["--persona-components-toolBubble-shadow"]) != null ? _Ea : "0 5px 15px rgba(15, 23, 42, 0.08)";
770
+ cssVars["--persona-reasoning-bubble-shadow"] = (_Fa = cssVars["--persona-components-reasoningBubble-shadow"]) != null ? _Fa : "0 5px 15px rgba(15, 23, 42, 0.08)";
771
+ cssVars["--persona-composer-shadow"] = (_Ga = cssVars["--persona-components-composer-shadow"]) != null ? _Ga : "none";
772
+ cssVars["--persona-md-inline-code-bg"] = (_Ha = cssVars["--persona-components-markdown-inlineCode-background"]) != null ? _Ha : cssVars["--persona-container"];
773
+ cssVars["--persona-md-inline-code-color"] = (_Ia = cssVars["--persona-components-markdown-inlineCode-foreground"]) != null ? _Ia : cssVars["--persona-text"];
774
+ cssVars["--persona-md-link-color"] = (_Ka = (_Ja = cssVars["--persona-components-markdown-link-foreground"]) != null ? _Ja : cssVars["--persona-accent"]) != null ? _Ka : "#0f0f0f";
728
775
  const mdH1Size = cssVars["--persona-components-markdown-heading-h1-fontSize"];
729
776
  if (mdH1Size) cssVars["--persona-md-h1-size"] = mdH1Size;
730
777
  const mdH1Weight = cssVars["--persona-components-markdown-heading-h1-fontWeight"];
@@ -737,6 +784,19 @@ function themeToCssVariables(theme) {
737
784
  if (mdProseFont && mdProseFont !== "inherit") {
738
785
  cssVars["--persona-md-prose-font-family"] = mdProseFont;
739
786
  }
787
+ cssVars["--persona-md-code-block-bg"] = (_La = cssVars["--persona-components-markdown-codeBlock-background"]) != null ? _La : cssVars["--persona-container"];
788
+ cssVars["--persona-md-code-block-border-color"] = (_Ma = cssVars["--persona-components-markdown-codeBlock-borderColor"]) != null ? _Ma : cssVars["--persona-border"];
789
+ cssVars["--persona-md-code-block-text-color"] = (_Na = cssVars["--persona-components-markdown-codeBlock-textColor"]) != null ? _Na : "inherit";
790
+ cssVars["--persona-md-table-header-bg"] = (_Oa = cssVars["--persona-components-markdown-table-headerBackground"]) != null ? _Oa : cssVars["--persona-container"];
791
+ cssVars["--persona-md-table-border-color"] = (_Pa = cssVars["--persona-components-markdown-table-borderColor"]) != null ? _Pa : cssVars["--persona-border"];
792
+ cssVars["--persona-md-hr-color"] = (_Qa = cssVars["--persona-components-markdown-hr-color"]) != null ? _Qa : cssVars["--persona-divider"];
793
+ cssVars["--persona-md-blockquote-border-color"] = (_Ra = cssVars["--persona-components-markdown-blockquote-borderColor"]) != null ? _Ra : cssVars["--persona-palette-colors-gray-900"];
794
+ cssVars["--persona-md-blockquote-bg"] = (_Sa = cssVars["--persona-components-markdown-blockquote-background"]) != null ? _Sa : "transparent";
795
+ cssVars["--persona-md-blockquote-text-color"] = (_Ta = cssVars["--persona-components-markdown-blockquote-textColor"]) != null ? _Ta : cssVars["--persona-palette-colors-gray-500"];
796
+ cssVars["--cw-container"] = (_Ua = cssVars["--persona-components-collapsibleWidget-container"]) != null ? _Ua : cssVars["--persona-surface"];
797
+ cssVars["--cw-surface"] = (_Va = cssVars["--persona-components-collapsibleWidget-surface"]) != null ? _Va : cssVars["--persona-surface"];
798
+ cssVars["--cw-border"] = (_Wa = cssVars["--persona-components-collapsibleWidget-border"]) != null ? _Wa : cssVars["--persona-border"];
799
+ cssVars["--persona-message-border"] = (_Xa = cssVars["--persona-components-message-border"]) != null ? _Xa : cssVars["--persona-border"];
740
800
  const components = theme.components;
741
801
  const iconBtn = components == null ? void 0 : components.iconButton;
742
802
  if (iconBtn) {
@@ -783,23 +843,23 @@ function themeToCssVariables(theme) {
783
843
  if (t.copyPadding) cssVars["--persona-artifact-toolbar-copy-padding"] = t.copyPadding;
784
844
  if (t.copyMenuBackground) {
785
845
  cssVars["--persona-artifact-toolbar-copy-menu-bg"] = t.copyMenuBackground;
786
- cssVars["--persona-dropdown-bg"] = (_ua = cssVars["--persona-dropdown-bg"]) != null ? _ua : t.copyMenuBackground;
846
+ cssVars["--persona-dropdown-bg"] = (_Ya = cssVars["--persona-dropdown-bg"]) != null ? _Ya : t.copyMenuBackground;
787
847
  }
788
848
  if (t.copyMenuBorder) {
789
849
  cssVars["--persona-artifact-toolbar-copy-menu-border"] = t.copyMenuBorder;
790
- cssVars["--persona-dropdown-border"] = (_va = cssVars["--persona-dropdown-border"]) != null ? _va : t.copyMenuBorder;
850
+ cssVars["--persona-dropdown-border"] = (_Za = cssVars["--persona-dropdown-border"]) != null ? _Za : t.copyMenuBorder;
791
851
  }
792
852
  if (t.copyMenuShadow) {
793
853
  cssVars["--persona-artifact-toolbar-copy-menu-shadow"] = t.copyMenuShadow;
794
- cssVars["--persona-dropdown-shadow"] = (_wa = cssVars["--persona-dropdown-shadow"]) != null ? _wa : t.copyMenuShadow;
854
+ cssVars["--persona-dropdown-shadow"] = (__a = cssVars["--persona-dropdown-shadow"]) != null ? __a : t.copyMenuShadow;
795
855
  }
796
856
  if (t.copyMenuBorderRadius) {
797
857
  cssVars["--persona-artifact-toolbar-copy-menu-radius"] = t.copyMenuBorderRadius;
798
- cssVars["--persona-dropdown-radius"] = (_xa = cssVars["--persona-dropdown-radius"]) != null ? _xa : t.copyMenuBorderRadius;
858
+ cssVars["--persona-dropdown-radius"] = (_$a = cssVars["--persona-dropdown-radius"]) != null ? _$a : t.copyMenuBorderRadius;
799
859
  }
800
860
  if (t.copyMenuItemHoverBackground) {
801
861
  cssVars["--persona-artifact-toolbar-copy-menu-item-hover-bg"] = t.copyMenuItemHoverBackground;
802
- cssVars["--persona-dropdown-item-hover-bg"] = (_ya = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ya : t.copyMenuItemHoverBackground;
862
+ cssVars["--persona-dropdown-item-hover-bg"] = (_ab = cssVars["--persona-dropdown-item-hover-bg"]) != null ? _ab : t.copyMenuItemHoverBackground;
803
863
  }
804
864
  if (t.iconBackground) cssVars["--persona-artifact-toolbar-icon-bg"] = t.iconBackground;
805
865
  if (t.toolbarBorder) cssVars["--persona-artifact-toolbar-border"] = t.toolbarBorder;
@@ -819,7 +879,7 @@ function themeToCssVariables(theme) {
819
879
  if (artifact == null ? void 0 : artifact.pane) {
820
880
  const t = artifact.pane;
821
881
  if (t.toolbarBackground) {
822
- const toolbarBg = (_za = resolveTokenValue(theme, t.toolbarBackground)) != null ? _za : t.toolbarBackground;
882
+ const toolbarBg = (_bb = resolveTokenValue(theme, t.toolbarBackground)) != null ? _bb : t.toolbarBackground;
823
883
  cssVars["--persona-artifact-toolbar-bg"] = toolbarBg;
824
884
  }
825
885
  }
@@ -1136,7 +1196,12 @@ var DEFAULT_WIDGET_CONFIG = {
1136
1196
  },
1137
1197
  features: {
1138
1198
  showReasoning: true,
1139
- showToolCalls: true
1199
+ showToolCalls: true,
1200
+ scrollToBottom: {
1201
+ enabled: true,
1202
+ iconName: "arrow-down",
1203
+ label: ""
1204
+ }
1140
1205
  },
1141
1206
  suggestionChips: [
1142
1207
  "What can you help me with?",
@@ -1238,9 +1303,11 @@ function mergeWithDefaults(config) {
1238
1303
  ...config.voiceRecognition
1239
1304
  },
1240
1305
  features: (() => {
1241
- var _a2, _b2;
1306
+ var _a2, _b2, _c2, _d2;
1242
1307
  const da = (_a2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _a2.artifacts;
1243
1308
  const ca = (_b2 = config.features) == null ? void 0 : _b2.artifacts;
1309
+ const dsb = (_c2 = DEFAULT_WIDGET_CONFIG.features) == null ? void 0 : _c2.scrollToBottom;
1310
+ const csb = (_d2 = config.features) == null ? void 0 : _d2.scrollToBottom;
1244
1311
  const mergedArtifacts = da === void 0 && ca === void 0 ? void 0 : {
1245
1312
  ...da,
1246
1313
  ...ca,
@@ -1249,9 +1316,14 @@ function mergeWithDefaults(config) {
1249
1316
  ...ca == null ? void 0 : ca.layout
1250
1317
  }
1251
1318
  };
1319
+ const mergedScrollToBottom = dsb === void 0 && csb === void 0 ? void 0 : {
1320
+ ...dsb,
1321
+ ...csb
1322
+ };
1252
1323
  return {
1253
1324
  ...DEFAULT_WIDGET_CONFIG.features,
1254
1325
  ...config.features,
1326
+ ...mergedScrollToBottom !== void 0 ? { scrollToBottom: mergedScrollToBottom } : {},
1255
1327
  ...mergedArtifacts !== void 0 ? { artifacts: mergedArtifacts } : {}
1256
1328
  };
1257
1329
  })(),
@@ -1780,6 +1852,16 @@ var ROLE_PRIMARY_ACTIONS = {
1780
1852
  { path: "semantic.colors.interactive.hover", kind: "accent" }
1781
1853
  ]
1782
1854
  };
1855
+ var ROLE_SCROLL_TO_BOTTOM = {
1856
+ roleId: "role-scroll-to-bottom",
1857
+ helper: "Scroll-to-bottom affordances in transcript and event stream",
1858
+ intensities: ROLE_INTENSITIES,
1859
+ targets: [
1860
+ { path: "components.scrollToBottom.background", kind: "background" },
1861
+ { path: "components.scrollToBottom.foreground", kind: "foreground" },
1862
+ { path: "components.scrollToBottom.border", kind: "border" }
1863
+ ]
1864
+ };
1783
1865
  var ROLE_INPUT = {
1784
1866
  roleId: "role-input",
1785
1867
  helper: "Message input field",
@@ -1818,6 +1900,7 @@ var ALL_ROLES = [
1818
1900
  ROLE_USER_MESSAGES,
1819
1901
  ROLE_ASSISTANT_MESSAGES,
1820
1902
  ROLE_PRIMARY_ACTIONS,
1903
+ ROLE_SCROLL_TO_BOTTOM,
1821
1904
  ROLE_INPUT,
1822
1905
  ROLE_LINKS_FOCUS,
1823
1906
  ROLE_BORDERS
@@ -2290,6 +2373,35 @@ var buttonColorsSectionDef = {
2290
2373
  { id: "btn-ghost-fg", label: "Ghost Foreground", type: "token-ref", path: "theme.components.button.ghost.foreground", defaultValue: "semantic.colors.text", tokenRef: { tokenType: "color" } }
2291
2374
  ]
2292
2375
  };
2376
+ var scrollToBottomSectionDef = {
2377
+ id: "scroll-to-bottom-style",
2378
+ title: "Scroll To Bottom",
2379
+ description: "Style the floating jump-to-latest affordance.",
2380
+ collapsed: true,
2381
+ fields: [
2382
+ { id: "scroll-bottom-bg", label: "Background", type: "token-ref", path: "theme.components.scrollToBottom.background", defaultValue: "components.button.primary.background", tokenRef: { tokenType: "color" } },
2383
+ { id: "scroll-bottom-fg", label: "Foreground", type: "token-ref", path: "theme.components.scrollToBottom.foreground", defaultValue: "components.button.primary.foreground", tokenRef: { tokenType: "color" } },
2384
+ { id: "scroll-bottom-border", label: "Border", type: "token-ref", path: "theme.components.scrollToBottom.border", defaultValue: "semantic.colors.primary", tokenRef: { tokenType: "color" } },
2385
+ { id: "scroll-bottom-size", label: "Size", type: "text", path: "theme.components.scrollToBottom.size", defaultValue: "40px" },
2386
+ { id: "scroll-bottom-radius", label: "Border Radius", type: "select", path: "theme.components.scrollToBottom.borderRadius", defaultValue: "palette.radius.full", options: [
2387
+ { value: "palette.radius.md", label: "Medium" },
2388
+ { value: "palette.radius.lg", label: "Large" },
2389
+ { value: "palette.radius.xl", label: "Extra Large" },
2390
+ { value: "palette.radius.full", label: "Full" }
2391
+ ] },
2392
+ { id: "scroll-bottom-shadow", label: "Shadow", type: "select", path: "theme.components.scrollToBottom.shadow", defaultValue: "palette.shadows.sm", options: [
2393
+ { value: "palette.shadows.none", label: "None" },
2394
+ { value: "palette.shadows.sm", label: "Small" },
2395
+ { value: "palette.shadows.md", label: "Medium" },
2396
+ { value: "palette.shadows.lg", label: "Large" },
2397
+ { value: "palette.shadows.xl", label: "Extra Large" }
2398
+ ] },
2399
+ { id: "scroll-bottom-padding", label: "Padding", type: "text", path: "theme.components.scrollToBottom.padding", defaultValue: "0.5rem 0.875rem" },
2400
+ { id: "scroll-bottom-gap", label: "Gap", type: "text", path: "theme.components.scrollToBottom.gap", defaultValue: "0.5rem" },
2401
+ { id: "scroll-bottom-font-size", label: "Font Size", type: "text", path: "theme.components.scrollToBottom.fontSize", defaultValue: "0.875rem" },
2402
+ { id: "scroll-bottom-icon-size", label: "Icon Size", type: "text", path: "theme.components.scrollToBottom.iconSize", defaultValue: "14px" }
2403
+ ]
2404
+ };
2293
2405
  var COMPONENT_SHAPE_SECTIONS = [
2294
2406
  panelLayoutSectionDef,
2295
2407
  launcherLayoutSectionDef,
@@ -2301,7 +2413,8 @@ var COMPONENT_COLOR_SECTIONS = [
2301
2413
  headerColorsSectionDef,
2302
2414
  messageColorsSectionDef,
2303
2415
  inputColorsSectionDef,
2304
- buttonColorsSectionDef
2416
+ buttonColorsSectionDef,
2417
+ scrollToBottomSectionDef
2305
2418
  ];
2306
2419
  var COMPONENTS_SECTIONS = [
2307
2420
  ...COMPONENT_SHAPE_SECTIONS,
@@ -2528,7 +2641,10 @@ var featuresSectionDef = {
2528
2641
  collapsed: true,
2529
2642
  fields: [
2530
2643
  { id: "feat-voice", label: "Voice Recognition", description: "Enable voice input", type: "toggle", path: "voiceRecognition.enabled", defaultValue: false },
2531
- { id: "feat-auto-focus", label: "Auto Focus Input", description: "Focus input after panel opens", type: "toggle", path: "autoFocusInput", defaultValue: false }
2644
+ { id: "feat-auto-focus", label: "Auto Focus Input", description: "Focus input after panel opens", type: "toggle", path: "autoFocusInput", defaultValue: false },
2645
+ { 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 },
2646
+ { id: "feat-scroll-bottom-icon", label: "Scroll To Bottom Icon", type: "text", path: "features.scrollToBottom.iconName", defaultValue: "arrow-down" },
2647
+ { id: "feat-scroll-bottom-label", label: "Scroll To Bottom Label", description: "Leave empty for icon-only mode", type: "text", path: "features.scrollToBottom.label", defaultValue: "" }
2532
2648
  ]
2533
2649
  };
2534
2650
  var attachmentsSectionDef = {
@@ -2694,6 +2810,13 @@ var INTERFACE_ROLES_SECTION = {
2694
2810
  path: "theme.components.button.primary.background",
2695
2811
  roleAssignment: ROLE_PRIMARY_ACTIONS
2696
2812
  },
2813
+ {
2814
+ id: "role-scroll-to-bottom",
2815
+ label: "Scroll To Bottom",
2816
+ type: "role-assignment",
2817
+ path: "theme.components.scrollToBottom.background",
2818
+ roleAssignment: ROLE_SCROLL_TO_BOTTOM
2819
+ },
2697
2820
  {
2698
2821
  id: "role-input",
2699
2822
  label: "Input Field",
@@ -7639,6 +7762,72 @@ function pruneCache(cache, activeMessageIds) {
7639
7762
  }
7640
7763
  }
7641
7764
 
7765
+ // src/utils/auto-follow.ts
7766
+ function createFollowStateController(initiallyFollowing = true) {
7767
+ let following = initiallyFollowing;
7768
+ return {
7769
+ isFollowing: () => following,
7770
+ pause: () => {
7771
+ if (!following) return false;
7772
+ following = false;
7773
+ return true;
7774
+ },
7775
+ resume: () => {
7776
+ if (following) return false;
7777
+ following = true;
7778
+ return true;
7779
+ }
7780
+ };
7781
+ }
7782
+ function getScrollBottomOffset(element) {
7783
+ return Math.max(0, element.scrollHeight - element.clientHeight);
7784
+ }
7785
+ function isElementNearBottom(element, threshold) {
7786
+ return getScrollBottomOffset(element) - element.scrollTop <= threshold;
7787
+ }
7788
+ function resolveFollowStateFromScroll(input) {
7789
+ const {
7790
+ following,
7791
+ currentScrollTop,
7792
+ lastScrollTop,
7793
+ nearBottom,
7794
+ userScrollThreshold,
7795
+ isAutoScrolling = false,
7796
+ pauseOnUpwardScroll = false,
7797
+ pauseWhenAwayFromBottom = true,
7798
+ resumeRequiresDownwardScroll = false
7799
+ } = input;
7800
+ const delta = currentScrollTop - lastScrollTop;
7801
+ if (isAutoScrolling || Math.abs(delta) < userScrollThreshold) {
7802
+ return { action: "none", delta, nextLastScrollTop: currentScrollTop };
7803
+ }
7804
+ if (!following && nearBottom && (!resumeRequiresDownwardScroll || delta > 0)) {
7805
+ return { action: "resume", delta, nextLastScrollTop: currentScrollTop };
7806
+ }
7807
+ if (following && pauseOnUpwardScroll && delta < 0) {
7808
+ return { action: "pause", delta, nextLastScrollTop: currentScrollTop };
7809
+ }
7810
+ if (following && pauseWhenAwayFromBottom && !nearBottom) {
7811
+ return { action: "pause", delta, nextLastScrollTop: currentScrollTop };
7812
+ }
7813
+ return { action: "none", delta, nextLastScrollTop: currentScrollTop };
7814
+ }
7815
+ function resolveFollowStateFromWheel(input) {
7816
+ const {
7817
+ following,
7818
+ deltaY,
7819
+ nearBottom = false,
7820
+ resumeWhenNearBottom = false
7821
+ } = input;
7822
+ if (following && deltaY < 0) {
7823
+ return "pause";
7824
+ }
7825
+ if (!following && resumeWhenNearBottom && deltaY > 0 && nearBottom) {
7826
+ return "resume";
7827
+ }
7828
+ return "none";
7829
+ }
7830
+
7642
7831
  // src/utils/constants.ts
7643
7832
  var statusCopy = {
7644
7833
  idle: "Online",
@@ -7646,6 +7835,70 @@ var statusCopy = {
7646
7835
  connected: "Streaming\u2026",
7647
7836
  error: "Offline"
7648
7837
  };
7838
+ var DEFAULT_OVERLAY_Z_INDEX = 1e5;
7839
+ var PORTALED_OVERLAY_Z_INDEX = DEFAULT_OVERLAY_Z_INDEX + 1;
7840
+
7841
+ // src/utils/overlay-host-stacking.ts
7842
+ function syncOverlayHostStacking(host, zIndex = DEFAULT_OVERLAY_Z_INDEX) {
7843
+ const originalPosition = host.style.position;
7844
+ const originalZIndex = host.style.zIndex;
7845
+ const originalIsolation = host.style.isolation;
7846
+ const computed = getComputedStyle(host);
7847
+ const positionWasSet = computed.position === "static" || computed.position === "";
7848
+ if (positionWasSet) {
7849
+ host.style.position = "relative";
7850
+ }
7851
+ host.style.zIndex = String(zIndex);
7852
+ host.style.isolation = "isolate";
7853
+ return () => {
7854
+ if (positionWasSet) {
7855
+ host.style.position = originalPosition;
7856
+ }
7857
+ host.style.zIndex = originalZIndex;
7858
+ host.style.isolation = originalIsolation;
7859
+ };
7860
+ }
7861
+
7862
+ // src/utils/scroll-lock.ts
7863
+ var lockCount = 0;
7864
+ var savedState = null;
7865
+ function acquireScrollLock(doc = document) {
7866
+ var _a;
7867
+ lockCount++;
7868
+ if (lockCount === 1) {
7869
+ const body = doc.body;
7870
+ const win = (_a = doc.defaultView) != null ? _a : window;
7871
+ const scrollY = win.scrollY || doc.documentElement.scrollTop;
7872
+ savedState = {
7873
+ originalOverflow: body.style.overflow,
7874
+ originalPosition: body.style.position,
7875
+ originalTop: body.style.top,
7876
+ originalWidth: body.style.width,
7877
+ scrollY
7878
+ };
7879
+ body.style.overflow = "hidden";
7880
+ body.style.position = "fixed";
7881
+ body.style.top = `-${scrollY}px`;
7882
+ body.style.width = "100%";
7883
+ }
7884
+ let released = false;
7885
+ return () => {
7886
+ var _a2;
7887
+ if (released) return;
7888
+ released = true;
7889
+ lockCount = Math.max(0, lockCount - 1);
7890
+ if (lockCount === 0 && savedState) {
7891
+ const body = doc.body;
7892
+ const win = (_a2 = doc.defaultView) != null ? _a2 : window;
7893
+ body.style.overflow = savedState.originalOverflow;
7894
+ body.style.position = savedState.originalPosition;
7895
+ body.style.top = savedState.originalTop;
7896
+ body.style.width = savedState.originalWidth;
7897
+ win.scrollTo(0, savedState.scrollY);
7898
+ savedState = null;
7899
+ }
7900
+ };
7901
+ }
7649
7902
 
7650
7903
  // src/utils/dock.ts
7651
7904
  var DEFAULT_DOCK_CONFIG = {
@@ -7692,7 +7945,7 @@ var createLauncherButton = (config, onToggle) => {
7692
7945
  `;
7693
7946
  button.addEventListener("click", onToggle);
7694
7947
  const update = (newConfig) => {
7695
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
7948
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
7696
7949
  const launcher = (_a = newConfig.launcher) != null ? _a : {};
7697
7950
  const dockedMode = isDockedMountMode(newConfig);
7698
7951
  const titleEl = button.querySelector("[data-role='launcher-title']");
@@ -7803,13 +8056,16 @@ var createLauncherButton = (config, onToggle) => {
7803
8056
  }
7804
8057
  }
7805
8058
  const positionClass = launcher.position && positionMap[launcher.position] ? positionMap[launcher.position] : positionMap["bottom-right"];
7806
- 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";
8059
+ 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";
7807
8060
  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";
7808
8061
  button.className = dockedMode ? dockedBase : `${floatingBase} ${positionClass}`;
8062
+ if (!dockedMode) {
8063
+ button.style.zIndex = String((_k = launcher.zIndex) != null ? _k : DEFAULT_OVERLAY_Z_INDEX);
8064
+ }
7809
8065
  const defaultBorder = "1px solid var(--persona-border, #e5e7eb)";
7810
8066
  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))";
7811
- button.style.border = (_k = launcher.border) != null ? _k : defaultBorder;
7812
- button.style.boxShadow = (_l = launcher.shadow) != null ? _l : defaultShadow;
8067
+ button.style.border = (_l = launcher.border) != null ? _l : defaultBorder;
8068
+ button.style.boxShadow = (_m = launcher.shadow) != null ? _m : defaultShadow;
7813
8069
  if (dockedMode) {
7814
8070
  button.style.width = "0";
7815
8071
  button.style.minWidth = "0";
@@ -7821,7 +8077,7 @@ var createLauncherButton = (config, onToggle) => {
7821
8077
  } else {
7822
8078
  button.style.width = "";
7823
8079
  button.style.minWidth = "";
7824
- button.style.maxWidth = (_m = launcher.collapsedMaxWidth) != null ? _m : "";
8080
+ button.style.maxWidth = (_n = launcher.collapsedMaxWidth) != null ? _n : "";
7825
8081
  button.style.justifyContent = "";
7826
8082
  button.style.padding = "";
7827
8083
  button.style.overflow = "";
@@ -7991,6 +8247,7 @@ var buildHeader = (context) => {
7991
8247
  portaledTooltip.appendChild(arrow);
7992
8248
  const buttonRect = clearChatButton.getBoundingClientRect();
7993
8249
  portaledTooltip.style.position = "fixed";
8250
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
7994
8251
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
7995
8252
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
7996
8253
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -8102,6 +8359,7 @@ var buildHeader = (context) => {
8102
8359
  portaledTooltip.appendChild(arrow);
8103
8360
  const buttonRect = closeButton.getBoundingClientRect();
8104
8361
  portaledTooltip.style.position = "fixed";
8362
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
8105
8363
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
8106
8364
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
8107
8365
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -8163,7 +8421,7 @@ function createDropdownMenu(options) {
8163
8421
  menu.setAttribute("data-persona-theme-zone", "dropdown");
8164
8422
  if (portal) {
8165
8423
  menu.style.position = "fixed";
8166
- menu.style.zIndex = "10000";
8424
+ menu.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
8167
8425
  } else {
8168
8426
  menu.style.position = "absolute";
8169
8427
  menu.style.top = "100%";
@@ -9006,7 +9264,7 @@ var buildComposer = (context) => {
9006
9264
 
9007
9265
  // src/components/panel.ts
9008
9266
  var createWrapper = (config) => {
9009
- var _a, _b, _c, _d, _e, _f, _g;
9267
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
9010
9268
  const launcherEnabled = (_b = (_a = config == null ? void 0 : config.launcher) == null ? void 0 : _a.enabled) != null ? _b : true;
9011
9269
  const dockedMode = isDockedMountMode(config);
9012
9270
  if (dockedMode) {
@@ -9040,13 +9298,14 @@ var createWrapper = (config) => {
9040
9298
  const position = launcher.position && positionMap[launcher.position] ? positionMap[launcher.position] : positionMap["bottom-right"];
9041
9299
  const wrapper = createElement(
9042
9300
  "div",
9043
- `persona-widget-wrapper persona-fixed ${position} persona-z-50 persona-transition`
9301
+ `persona-widget-wrapper persona-fixed ${position} persona-transition`
9044
9302
  );
9303
+ wrapper.style.zIndex = String((_g = (_f = config == null ? void 0 : config.launcher) == null ? void 0 : _f.zIndex) != null ? _g : DEFAULT_OVERLAY_Z_INDEX);
9045
9304
  const panel = createElement(
9046
9305
  "div",
9047
9306
  "persona-widget-panel persona-relative persona-min-h-[320px]"
9048
9307
  );
9049
- const launcherWidth = (_g = (_f = config == null ? void 0 : config.launcher) == null ? void 0 : _f.width) != null ? _g : config == null ? void 0 : config.launcherWidth;
9308
+ const launcherWidth = (_i = (_h = config == null ? void 0 : config.launcher) == null ? void 0 : _h.width) != null ? _i : config == null ? void 0 : config.launcherWidth;
9050
9309
  const width = launcherWidth != null ? launcherWidth : "min(400px, calc(100vw - 24px))";
9051
9310
  panel.style.width = width;
9052
9311
  panel.style.maxWidth = width;
@@ -10609,7 +10868,7 @@ function renderEventRow(event, index, firstTimestamp, esConfig, expandedSet, onT
10609
10868
  }
10610
10869
  }
10611
10870
  function createEventStreamView(options) {
10612
- var _a, _b;
10871
+ var _a, _b, _c, _d, _e;
10613
10872
  const {
10614
10873
  buffer,
10615
10874
  getFullHistory,
@@ -10617,7 +10876,11 @@ function createEventStreamView(options) {
10617
10876
  config,
10618
10877
  plugins = []
10619
10878
  } = options;
10620
- const esConfig = (_b = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.eventStream) != null ? _b : {};
10879
+ const scrollToBottomConfig = (_a = config == null ? void 0 : config.features) == null ? void 0 : _a.scrollToBottom;
10880
+ const scrollToBottomEnabled = (scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.enabled) !== false;
10881
+ const scrollToBottomIconName = (_b = scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.iconName) != null ? _b : "arrow-down";
10882
+ const scrollToBottomLabel = (_c = scrollToBottomConfig == null ? void 0 : scrollToBottomConfig.label) != null ? _c : "";
10883
+ const esConfig = (_e = (_d = config == null ? void 0 : config.features) == null ? void 0 : _d.eventStream) != null ? _e : {};
10621
10884
  const viewPlugin = plugins.find((p) => p.renderEventStreamView);
10622
10885
  if ((viewPlugin == null ? void 0 : viewPlugin.renderEventStreamView) && config) {
10623
10886
  const customView = viewPlugin.renderEventStreamView({
@@ -10651,7 +10914,7 @@ function createEventStreamView(options) {
10651
10914
  let lastKnownTypes = [];
10652
10915
  let lastTypeCounts = {};
10653
10916
  let lastFilteredCount = 0;
10654
- let userScrolledUp = false;
10917
+ const autoFollow = createFollowStateController();
10655
10918
  let newEventsSincePause = 0;
10656
10919
  let lastRenderTime = 0;
10657
10920
  let pendingUpdate = false;
@@ -10804,18 +11067,23 @@ function createEventStreamView(options) {
10804
11067
  eventsList.style.height = "100%";
10805
11068
  const scrollIndicator = createElement(
10806
11069
  "div",
10807
- "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"
11070
+ "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"
10808
11071
  );
10809
11072
  applyCustomClasses(scrollIndicator, customClasses == null ? void 0 : customClasses.scrollIndicator);
10810
11073
  scrollIndicator.style.display = "none";
11074
+ scrollIndicator.setAttribute(
11075
+ "data-persona-scroll-to-bottom-has-label",
11076
+ scrollToBottomLabel ? "true" : "false"
11077
+ );
10811
11078
  const arrowIcon = renderLucideIcon(
10812
- "arrow-down",
10813
- "12px",
11079
+ scrollToBottomIconName,
11080
+ "14px",
10814
11081
  "currentColor",
10815
11082
  2
10816
11083
  );
10817
11084
  if (arrowIcon) scrollIndicator.appendChild(arrowIcon);
10818
11085
  const indicatorText = createElement("span", "");
11086
+ indicatorText.textContent = scrollToBottomLabel;
10819
11087
  scrollIndicator.appendChild(indicatorText);
10820
11088
  const noResultsMsg = createElement(
10821
11089
  "div",
@@ -10887,7 +11155,7 @@ function createEventStreamView(options) {
10887
11155
  function resetScrollState() {
10888
11156
  lastFilteredCount = 0;
10889
11157
  newEventsSincePause = 0;
10890
- userScrolledUp = false;
11158
+ autoFollow.resume();
10891
11159
  scrollIndicator.style.display = "none";
10892
11160
  }
10893
11161
  function toggleExpand(eventId) {
@@ -10898,17 +11166,18 @@ function createEventStreamView(options) {
10898
11166
  }
10899
11167
  dirtyExpandId = eventId;
10900
11168
  const savedScrollTop = eventsList.scrollTop;
10901
- const wasUserScrolledUp = userScrolledUp;
11169
+ const wasAutoFollowing = autoFollow.isFollowing();
10902
11170
  suppressScrollHandler = true;
10903
- userScrolledUp = true;
11171
+ autoFollow.pause();
10904
11172
  updateNow();
10905
11173
  eventsList.scrollTop = savedScrollTop;
10906
- userScrolledUp = wasUserScrolledUp;
11174
+ if (wasAutoFollowing) {
11175
+ autoFollow.resume();
11176
+ }
10907
11177
  suppressScrollHandler = false;
10908
11178
  }
10909
11179
  function isNearBottom() {
10910
- const threshold = 50;
10911
- return eventsList.scrollHeight - eventsList.scrollTop - eventsList.clientHeight <= threshold;
11180
+ return isElementNearBottom(eventsList, 50);
10912
11181
  }
10913
11182
  function updateNow() {
10914
11183
  lastRenderTime = Date.now();
@@ -10938,9 +11207,9 @@ function createEventStreamView(options) {
10938
11207
  if (copyAllBtn) {
10939
11208
  copyAllBtn.title = hasActiveFilters() ? `Copy Filtered (${newCount})` : "Copy All";
10940
11209
  }
10941
- if (userScrolledUp && newCount > lastFilteredCount) {
11210
+ if (scrollToBottomEnabled && !autoFollow.isFollowing() && newCount > lastFilteredCount) {
10942
11211
  newEventsSincePause += newCount - lastFilteredCount;
10943
- indicatorText.textContent = `${newEventsSincePause} new event${newEventsSincePause === 1 ? "" : "s"}`;
11212
+ indicatorText.textContent = scrollToBottomLabel ? `${scrollToBottomLabel}${newEventsSincePause > 0 ? ` (${newEventsSincePause})` : ""}` : "";
10944
11213
  scrollIndicator.style.display = "";
10945
11214
  }
10946
11215
  lastFilteredCount = newCount;
@@ -11024,7 +11293,7 @@ function createEventStreamView(options) {
11024
11293
  }
11025
11294
  }
11026
11295
  }
11027
- if (!userScrolledUp) {
11296
+ if (autoFollow.isFollowing()) {
11028
11297
  eventsList.scrollTop = eventsList.scrollHeight;
11029
11298
  }
11030
11299
  }
@@ -11133,24 +11402,50 @@ function createEventStreamView(options) {
11133
11402
  const handleListScroll = () => {
11134
11403
  if (suppressScrollHandler) return;
11135
11404
  const currentScrollTop = eventsList.scrollTop;
11136
- const scrollingDown = currentScrollTop > lastScrollTop;
11137
- lastScrollTop = currentScrollTop;
11138
- if (isNearBottom() && scrollingDown) {
11139
- userScrolledUp = false;
11405
+ const { action, nextLastScrollTop } = resolveFollowStateFromScroll({
11406
+ following: autoFollow.isFollowing(),
11407
+ currentScrollTop,
11408
+ lastScrollTop,
11409
+ nearBottom: isNearBottom(),
11410
+ userScrollThreshold: 1,
11411
+ resumeRequiresDownwardScroll: true
11412
+ });
11413
+ lastScrollTop = nextLastScrollTop;
11414
+ if (action === "resume") {
11415
+ autoFollow.resume();
11140
11416
  newEventsSincePause = 0;
11141
11417
  scrollIndicator.style.display = "none";
11142
- } else if (!isNearBottom()) {
11143
- userScrolledUp = true;
11418
+ } else if (action === "pause") {
11419
+ autoFollow.pause();
11420
+ if (scrollToBottomEnabled) {
11421
+ indicatorText.textContent = scrollToBottomLabel;
11422
+ scrollIndicator.style.display = "";
11423
+ }
11144
11424
  }
11145
11425
  };
11146
11426
  const handleWheel = (e) => {
11147
- if (e.deltaY < 0) {
11148
- userScrolledUp = true;
11427
+ const action = resolveFollowStateFromWheel({
11428
+ following: autoFollow.isFollowing(),
11429
+ deltaY: e.deltaY,
11430
+ nearBottom: isNearBottom(),
11431
+ resumeWhenNearBottom: true
11432
+ });
11433
+ if (action === "pause") {
11434
+ autoFollow.pause();
11435
+ if (scrollToBottomEnabled) {
11436
+ indicatorText.textContent = scrollToBottomLabel;
11437
+ scrollIndicator.style.display = "";
11438
+ }
11439
+ } else if (action === "resume") {
11440
+ autoFollow.resume();
11441
+ newEventsSincePause = 0;
11442
+ scrollIndicator.style.display = "none";
11149
11443
  }
11150
11444
  };
11151
11445
  const handleScrollIndicatorClick = () => {
11446
+ if (!scrollToBottomEnabled) return;
11152
11447
  eventsList.scrollTop = eventsList.scrollHeight;
11153
- userScrolledUp = false;
11448
+ autoFollow.resume();
11154
11449
  newEventsSincePause = 0;
11155
11450
  scrollIndicator.style.display = "none";
11156
11451
  };
@@ -11232,7 +11527,7 @@ function renderDefaultArtifactCard(props, _context) {
11232
11527
  const root = document.createElement("div");
11233
11528
  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";
11234
11529
  root.style.border = "1px solid var(--persona-border, #e5e7eb)";
11235
- root.style.backgroundColor = "var(--persona-bg, #ffffff)";
11530
+ root.style.backgroundColor = "var(--persona-surface, #ffffff)";
11236
11531
  root.style.cursor = "pointer";
11237
11532
  root.tabIndex = 0;
11238
11533
  root.setAttribute("role", "button");
@@ -12769,7 +13064,7 @@ var buildPostprocessor = (cfg, actionManager, onResubmitRequested) => {
12769
13064
  };
12770
13065
  };
12771
13066
  var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12772
- 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;
13067
+ 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;
12773
13068
  if (mount.id && !mount.getAttribute("data-persona-instance")) {
12774
13069
  mount.setAttribute("data-persona-instance", mount.id);
12775
13070
  }
@@ -12887,10 +13182,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12887
13182
  let showReasoning = (_l = (_k = config.features) == null ? void 0 : _k.showReasoning) != null ? _l : true;
12888
13183
  let showToolCalls = (_n = (_m = config.features) == null ? void 0 : _m.showToolCalls) != null ? _n : true;
12889
13184
  let showEventStreamToggle = (_p = (_o = config.features) == null ? void 0 : _o.showEventStreamToggle) != null ? _p : false;
12890
- const persistKeyPrefix = (_r = typeof config.persistState === "object" ? (_q = config.persistState) == null ? void 0 : _q.keyPrefix : void 0) != null ? _r : "persona-";
13185
+ let scrollToBottomFeature = (_r = (_q = config.features) == null ? void 0 : _q.scrollToBottom) != null ? _r : {};
13186
+ const persistKeyPrefix = (_t = typeof config.persistState === "object" ? (_s = config.persistState) == null ? void 0 : _s.keyPrefix : void 0) != null ? _t : "persona-";
12891
13187
  const eventStreamDbName = `${persistKeyPrefix}event-stream`;
12892
13188
  let eventStreamStore = showEventStreamToggle ? new EventStreamStore(eventStreamDbName) : null;
12893
- const eventStreamMaxEvents = (_u = (_t = (_s = config.features) == null ? void 0 : _s.eventStream) == null ? void 0 : _t.maxEvents) != null ? _u : 2e3;
13189
+ const eventStreamMaxEvents = (_w = (_v = (_u = config.features) == null ? void 0 : _u.eventStream) == null ? void 0 : _v.maxEvents) != null ? _w : 2e3;
12894
13190
  let eventStreamBuffer = showEventStreamToggle ? new EventStreamBuffer(eventStreamMaxEvents, eventStreamStore) : null;
12895
13191
  let eventStreamView = null;
12896
13192
  let eventStreamVisible = false;
@@ -12927,7 +13223,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12927
13223
  (_b2 = (_a2 = config.messageActions) == null ? void 0 : _a2.onFeedback) == null ? void 0 : _b2.call(_a2, feedback);
12928
13224
  }
12929
13225
  };
12930
- const statusConfig = (_v = config.statusIndicator) != null ? _v : {};
13226
+ const statusConfig = (_x = config.statusIndicator) != null ? _x : {};
12931
13227
  const _getStatusText = (status) => {
12932
13228
  var _a2, _b2, _c2, _d2;
12933
13229
  if (status === "idle") return (_a2 = statusConfig.idleText) != null ? _a2 : statusCopy.idle;
@@ -12981,6 +13277,52 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
12981
13277
  let attachmentButtonWrapper = panelElements.attachmentButtonWrapper;
12982
13278
  let attachmentInput = panelElements.attachmentInput;
12983
13279
  let attachmentPreviewsContainer = panelElements.attachmentPreviewsContainer;
13280
+ container.classList.add("persona-relative");
13281
+ body.classList.add("persona-relative");
13282
+ const SCROLL_TO_BOTTOM_EDGE_OFFSET = 12;
13283
+ const getScrollToBottomLabel = () => {
13284
+ var _a2;
13285
+ return (_a2 = scrollToBottomFeature.label) != null ? _a2 : "";
13286
+ };
13287
+ const getScrollToBottomIconName = () => {
13288
+ var _a2;
13289
+ return (_a2 = scrollToBottomFeature.iconName) != null ? _a2 : "arrow-down";
13290
+ };
13291
+ const isScrollToBottomEnabled = () => scrollToBottomFeature.enabled !== false;
13292
+ const scrollToBottomButton = createElement(
13293
+ "button",
13294
+ "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"
13295
+ );
13296
+ scrollToBottomButton.type = "button";
13297
+ scrollToBottomButton.style.display = "none";
13298
+ scrollToBottomButton.setAttribute("data-persona-scroll-to-bottom", "true");
13299
+ const scrollToBottomIcon = createElement("span", "persona-flex persona-items-center");
13300
+ const scrollToBottomLabel = createElement("span", "");
13301
+ scrollToBottomButton.append(scrollToBottomIcon, scrollToBottomLabel);
13302
+ container.appendChild(scrollToBottomButton);
13303
+ const updateScrollToBottomButtonOffset = () => {
13304
+ const footerHidden = footer.style.display === "none";
13305
+ const footerHeight = footerHidden ? 0 : footer.offsetHeight;
13306
+ scrollToBottomButton.style.bottom = `${footerHeight + SCROLL_TO_BOTTOM_EDGE_OFFSET}px`;
13307
+ };
13308
+ updateScrollToBottomButtonOffset();
13309
+ const renderScrollToBottomButton = () => {
13310
+ const hasLabel = Boolean(getScrollToBottomLabel());
13311
+ scrollToBottomButton.setAttribute("aria-label", getScrollToBottomLabel() || "Jump to latest");
13312
+ scrollToBottomButton.title = getScrollToBottomLabel();
13313
+ scrollToBottomButton.setAttribute("data-persona-scroll-to-bottom-has-label", hasLabel ? "true" : "false");
13314
+ scrollToBottomIcon.innerHTML = "";
13315
+ const icon = renderLucideIcon(getScrollToBottomIconName(), "14px", "currentColor", 2);
13316
+ if (icon) {
13317
+ scrollToBottomIcon.appendChild(icon);
13318
+ scrollToBottomIcon.style.display = "";
13319
+ } else {
13320
+ scrollToBottomIcon.style.display = "none";
13321
+ }
13322
+ scrollToBottomLabel.textContent = getScrollToBottomLabel();
13323
+ scrollToBottomLabel.style.display = hasLabel ? "" : "none";
13324
+ };
13325
+ renderScrollToBottomButton();
12984
13326
  let attachmentManager = null;
12985
13327
  let composerVoiceBridge = null;
12986
13328
  const headerPlugin = plugins.find((p) => p.renderHeader);
@@ -13036,6 +13378,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13036
13378
  };
13037
13379
  eventStreamLastUpdate = 0;
13038
13380
  eventStreamRAF = requestAnimationFrame(rafLoop);
13381
+ syncScrollToBottomButton();
13039
13382
  eventBus.emit("eventStream:opened", { timestamp: Date.now() });
13040
13383
  };
13041
13384
  const toggleEventStreamOff = () => {
@@ -13055,11 +13398,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13055
13398
  cancelAnimationFrame(eventStreamRAF);
13056
13399
  eventStreamRAF = null;
13057
13400
  }
13401
+ syncScrollToBottomButton();
13058
13402
  eventBus.emit("eventStream:closed", { timestamp: Date.now() });
13059
13403
  };
13060
13404
  let eventStreamToggleBtn = null;
13061
13405
  if (showEventStreamToggle) {
13062
- const esClassNames = (_x = (_w = config.features) == null ? void 0 : _w.eventStream) == null ? void 0 : _x.classNames;
13406
+ const esClassNames = (_z = (_y = config.features) == null ? void 0 : _y.eventStream) == null ? void 0 : _z.classNames;
13063
13407
  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 : "");
13064
13408
  eventStreamToggleBtn = createElement("button", toggleBtnClasses);
13065
13409
  eventStreamToggleBtn.style.width = "28px";
@@ -13138,7 +13482,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13138
13482
  onModelChange: (modelId) => {
13139
13483
  config.composer = { ...config.composer, selectedModelId: modelId };
13140
13484
  },
13141
- onVoiceToggle: ((_y = config.voiceRecognition) == null ? void 0 : _y.enabled) === true ? () => {
13485
+ onVoiceToggle: ((_A = config.voiceRecognition) == null ? void 0 : _A.enabled) === true ? () => {
13142
13486
  composerVoiceBridge == null ? void 0 : composerVoiceBridge();
13143
13487
  } : void 0
13144
13488
  });
@@ -13177,7 +13521,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13177
13521
  };
13178
13522
  ensureComposerAttachmentSurface(footer);
13179
13523
  bindComposerRefsFromFooter(footer);
13180
- const contentMaxWidth = (_z = config.layout) == null ? void 0 : _z.contentMaxWidth;
13524
+ const contentMaxWidth = (_B = config.layout) == null ? void 0 : _B.contentMaxWidth;
13181
13525
  if (contentMaxWidth && composerForm) {
13182
13526
  composerForm.style.maxWidth = contentMaxWidth;
13183
13527
  composerForm.style.marginLeft = "auto";
@@ -13188,7 +13532,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13188
13532
  attachmentPreviewsContainer.style.marginLeft = "auto";
13189
13533
  attachmentPreviewsContainer.style.marginRight = "auto";
13190
13534
  }
13191
- if (((_A = config.attachments) == null ? void 0 : _A.enabled) && attachmentInput && attachmentPreviewsContainer) {
13535
+ if (((_C = config.attachments) == null ? void 0 : _C.enabled) && attachmentInput && attachmentPreviewsContainer) {
13192
13536
  attachmentManager = AttachmentManager.fromConfig(config.attachments);
13193
13537
  attachmentManager.setPreviewsContainer(attachmentPreviewsContainer);
13194
13538
  attachmentInput.addEventListener("change", (e) => {
@@ -13681,7 +14025,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13681
14025
  }
13682
14026
  mount.appendChild(wrapper);
13683
14027
  const applyFullHeightStyles = () => {
13684
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2;
14028
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2, _w2;
13685
14029
  const dockedMode = isDockedMountMode(config);
13686
14030
  const sidebarMode = (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.sidebarMode) != null ? _b2 : false;
13687
14031
  const fullHeight = dockedMode || sidebarMode || ((_d2 = (_c2 = config.launcher) == null ? void 0 : _c2.fullHeight) != null ? _d2 : false);
@@ -13700,7 +14044,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13700
14044
  const shouldGoFullscreen = mobileFullscreen && isMobileViewport && launcherEnabled;
13701
14045
  const position = (_n2 = (_m2 = config.launcher) == null ? void 0 : _m2.position) != null ? _n2 : "bottom-left";
13702
14046
  const isLeftSidebar = position === "bottom-left" || position === "top-left";
13703
- const overlayZIndex = (_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.zIndex) != null ? _p2 : 9999;
14047
+ const overlayZIndex = (_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.zIndex) != null ? _p2 : DEFAULT_OVERLAY_Z_INDEX;
13704
14048
  let defaultPanelBorder = sidebarMode || shouldGoFullscreen ? "none" : "1px solid var(--persona-border)";
13705
14049
  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))";
13706
14050
  if (dockedMode && !shouldGoFullscreen) {
@@ -13911,7 +14255,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13911
14255
  if (!isInlineEmbed && !dockedMode) {
13912
14256
  const maxHeightStyles = "max-height: -moz-available !important; max-height: stretch !important;";
13913
14257
  const paddingStyles = sidebarMode ? "" : "padding-top: 1.25em !important;";
13914
- const zIndexStyles = !sidebarMode && ((_v2 = config.launcher) == null ? void 0 : _v2.zIndex) != null ? `z-index: ${config.launcher.zIndex} !important;` : "";
14258
+ const zIndexStyles = !sidebarMode ? `z-index: ${(_w2 = (_v2 = config.launcher) == null ? void 0 : _v2.zIndex) != null ? _w2 : DEFAULT_OVERLAY_Z_INDEX} !important;` : "";
13915
14259
  wrapper.style.cssText += maxHeightStyles + paddingStyles + zIndexStyles;
13916
14260
  }
13917
14261
  };
@@ -13920,6 +14264,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13920
14264
  applyArtifactLayoutCssVars(mount, config);
13921
14265
  applyArtifactPaneAppearance(mount, config);
13922
14266
  const destroyCallbacks = [];
14267
+ let teardownHostStacking = null;
14268
+ let releaseScrollLock = null;
14269
+ destroyCallbacks.push(() => {
14270
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
14271
+ teardownHostStacking = null;
14272
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
14273
+ releaseScrollLock = null;
14274
+ });
13923
14275
  if (artifactPanelResizeObs) {
13924
14276
  destroyCallbacks.push(() => {
13925
14277
  artifactPanelResizeObs == null ? void 0 : artifactPanelResizeObs.disconnect();
@@ -13975,17 +14327,12 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13975
14327
  let isStreaming = false;
13976
14328
  const messageCache = createMessageCache();
13977
14329
  let configVersion = 0;
13978
- let shouldAutoScroll = true;
14330
+ const autoFollow = createFollowStateController();
13979
14331
  let lastScrollTop = 0;
13980
- let lastAutoScrollTime = 0;
13981
14332
  let scrollRAF = null;
13982
- let isAutoScrollBlocked = false;
13983
- let blockUntilTime = 0;
13984
14333
  let isAutoScrolling = false;
13985
- const AUTO_SCROLL_THROTTLE = 125;
13986
- const AUTO_SCROLL_BLOCK_TIME = 2e3;
13987
- const USER_SCROLL_THRESHOLD = 5;
13988
- const BOTTOM_THRESHOLD = 50;
14334
+ const USER_SCROLL_THRESHOLD = 1;
14335
+ const BOTTOM_THRESHOLD = 8;
13989
14336
  const messageState = /* @__PURE__ */ new Map();
13990
14337
  const voiceState = {
13991
14338
  active: false,
@@ -13993,7 +14340,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
13993
14340
  lastUserMessageWasVoice: false,
13994
14341
  lastUserMessageId: null
13995
14342
  };
13996
- const voiceAutoResumeMode = (_C = (_B = config.voiceRecognition) == null ? void 0 : _B.autoResume) != null ? _C : false;
14343
+ const voiceAutoResumeMode = (_E = (_D = config.voiceRecognition) == null ? void 0 : _D.autoResume) != null ? _E : false;
13997
14344
  const emitVoiceState = (source) => {
13998
14345
  eventBus.emit("voice:state", {
13999
14346
  active: voiceState.active,
@@ -14059,56 +14406,79 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14059
14406
  }
14060
14407
  }
14061
14408
  }
14062
- const scheduleAutoScroll = (force = false) => {
14063
- if (!shouldAutoScroll) return;
14064
- const now = Date.now();
14065
- if (isAutoScrollBlocked && now < blockUntilTime) {
14066
- if (!force) return;
14067
- }
14068
- if (isAutoScrollBlocked && now >= blockUntilTime) {
14069
- isAutoScrollBlocked = false;
14409
+ let smoothScrollRAF = null;
14410
+ const getScrollableContainer = () => {
14411
+ const scrollable = wrapper.querySelector("#persona-scroll-container");
14412
+ return scrollable || body;
14413
+ };
14414
+ const cancelSmoothScroll = () => {
14415
+ if (smoothScrollRAF !== null) {
14416
+ cancelAnimationFrame(smoothScrollRAF);
14417
+ smoothScrollRAF = null;
14070
14418
  }
14071
- if (!force && !isStreaming) return;
14072
- if (now - lastAutoScrollTime < AUTO_SCROLL_THROTTLE) return;
14073
- lastAutoScrollTime = now;
14074
- if (scrollRAF) {
14419
+ isAutoScrolling = false;
14420
+ };
14421
+ const cancelAutoScroll = () => {
14422
+ if (scrollRAF !== null) {
14075
14423
  cancelAnimationFrame(scrollRAF);
14424
+ scrollRAF = null;
14076
14425
  }
14426
+ cancelSmoothScroll();
14427
+ };
14428
+ const syncScrollToBottomButton = () => {
14429
+ if (!isScrollToBottomEnabled() || eventStreamVisible) {
14430
+ if (scrollToBottomButton.parentNode) {
14431
+ scrollToBottomButton.remove();
14432
+ }
14433
+ scrollToBottomButton.style.display = "none";
14434
+ return;
14435
+ }
14436
+ if (scrollToBottomButton.parentNode !== container) {
14437
+ container.appendChild(scrollToBottomButton);
14438
+ }
14439
+ updateScrollToBottomButtonOffset();
14440
+ const hasOverflow = getScrollBottomOffset(body) > 0;
14441
+ scrollToBottomButton.style.display = autoFollow.isFollowing() || !hasOverflow ? "none" : "";
14442
+ };
14443
+ const pauseAutoScroll = () => {
14444
+ if (!autoFollow.pause()) return;
14445
+ cancelAutoScroll();
14446
+ syncScrollToBottomButton();
14447
+ };
14448
+ const resumeAutoScroll = () => {
14449
+ autoFollow.resume();
14450
+ syncScrollToBottomButton();
14451
+ };
14452
+ const scheduleAutoScroll = (force = false) => {
14453
+ if (!autoFollow.isFollowing()) return;
14454
+ if (!force && !isStreaming) return;
14455
+ cancelAutoScroll();
14077
14456
  scrollRAF = requestAnimationFrame(() => {
14078
- if (isAutoScrollBlocked || !shouldAutoScroll) return;
14079
- isAutoScrolling = true;
14080
- body.scrollTop = body.scrollHeight;
14081
- lastScrollTop = body.scrollTop;
14082
- requestAnimationFrame(() => {
14083
- isAutoScrolling = false;
14084
- });
14085
14457
  scrollRAF = null;
14458
+ if (!autoFollow.isFollowing()) return;
14459
+ smoothScrollToBottom(getScrollableContainer(), force ? 220 : 140);
14086
14460
  });
14087
14461
  };
14088
- let smoothScrollRAF = null;
14089
- const getScrollableContainer = () => {
14090
- const scrollable = wrapper.querySelector("#persona-scroll-container");
14091
- return scrollable || body;
14092
- };
14093
14462
  const smoothScrollToBottom = (element, duration = 500) => {
14094
14463
  const start = element.scrollTop;
14095
- const clientHeight = element.clientHeight;
14096
- let target = element.scrollHeight;
14464
+ let target = getScrollBottomOffset(element);
14097
14465
  let distance = target - start;
14098
- const isAtBottom = start + clientHeight >= target - 2;
14099
- if (isAtBottom || Math.abs(distance) < 5) {
14466
+ if (Math.abs(distance) < 1) {
14467
+ lastScrollTop = element.scrollTop;
14100
14468
  return;
14101
14469
  }
14102
- if (smoothScrollRAF !== null) {
14103
- cancelAnimationFrame(smoothScrollRAF);
14104
- smoothScrollRAF = null;
14105
- }
14470
+ cancelSmoothScroll();
14106
14471
  const startTime = performance.now();
14472
+ isAutoScrolling = true;
14107
14473
  const easeOutCubic = (t) => {
14108
14474
  return 1 - Math.pow(1 - t, 3);
14109
14475
  };
14110
14476
  const animate = (currentTime) => {
14111
- const currentTarget = element.scrollHeight;
14477
+ if (!autoFollow.isFollowing()) {
14478
+ cancelSmoothScroll();
14479
+ return;
14480
+ }
14481
+ const currentTarget = getScrollBottomOffset(element);
14112
14482
  if (currentTarget !== target) {
14113
14483
  target = currentTarget;
14114
14484
  distance = target - start;
@@ -14118,11 +14488,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14118
14488
  const eased = easeOutCubic(progress);
14119
14489
  const currentScroll = start + distance * eased;
14120
14490
  element.scrollTop = currentScroll;
14491
+ lastScrollTop = element.scrollTop;
14121
14492
  if (progress < 1) {
14122
14493
  smoothScrollRAF = requestAnimationFrame(animate);
14123
14494
  } else {
14124
- element.scrollTop = element.scrollHeight;
14495
+ element.scrollTop = target;
14496
+ lastScrollTop = element.scrollTop;
14125
14497
  smoothScrollRAF = null;
14498
+ isAutoScrolling = false;
14126
14499
  }
14127
14500
  };
14128
14501
  smoothScrollRAF = requestAnimationFrame(animate);
@@ -14462,15 +14835,6 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14462
14835
  }
14463
14836
  }
14464
14837
  morphMessages(container2, tempContainer);
14465
- if (shouldAutoScroll && !isAutoScrollBlocked) {
14466
- requestAnimationFrame(() => {
14467
- requestAnimationFrame(() => {
14468
- if (!shouldAutoScroll || isAutoScrollBlocked) return;
14469
- const scrollableContainer = getScrollableContainer();
14470
- smoothScrollToBottom(scrollableContainer);
14471
- });
14472
- });
14473
- }
14474
14838
  };
14475
14839
  const renderMessagesWithPlugins = renderMessagesWithPluginsImpl;
14476
14840
  const updateOpenState = () => {
@@ -14521,11 +14885,42 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14521
14885
  }
14522
14886
  };
14523
14887
  const setOpenState = (nextOpen, source = "user") => {
14888
+ var _a2, _b2;
14524
14889
  if (!launcherEnabled) return;
14525
14890
  if (open === nextOpen) return;
14526
14891
  const prevOpen = open;
14527
14892
  open = nextOpen;
14528
14893
  updateOpenState();
14894
+ const isViewportCovering = (() => {
14895
+ var _a3, _b3, _c2, _d2, _e2, _f2, _g2;
14896
+ const sm = (_b3 = (_a3 = config.launcher) == null ? void 0 : _a3.sidebarMode) != null ? _b3 : false;
14897
+ const ow = (_c2 = mount.ownerDocument.defaultView) != null ? _c2 : window;
14898
+ const mf = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.mobileFullscreen) != null ? _e2 : true;
14899
+ const mb = (_g2 = (_f2 = config.launcher) == null ? void 0 : _f2.mobileBreakpoint) != null ? _g2 : 640;
14900
+ const isMobile = ow.innerWidth <= mb;
14901
+ const dockedMF = isDockedMountMode(config) && mf && isMobile;
14902
+ return sm || mf && isMobile && launcherEnabled || dockedMF;
14903
+ })();
14904
+ if (open && isViewportCovering) {
14905
+ if (!teardownHostStacking) {
14906
+ const root = mount.getRootNode();
14907
+ const hostEl = root instanceof ShadowRoot ? root.host : mount.closest(".persona-host");
14908
+ if (hostEl) {
14909
+ teardownHostStacking = syncOverlayHostStacking(
14910
+ hostEl,
14911
+ (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.zIndex) != null ? _b2 : DEFAULT_OVERLAY_Z_INDEX
14912
+ );
14913
+ }
14914
+ }
14915
+ if (!releaseScrollLock) {
14916
+ releaseScrollLock = acquireScrollLock(mount.ownerDocument);
14917
+ }
14918
+ } else if (!open) {
14919
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
14920
+ teardownHostStacking = null;
14921
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
14922
+ releaseScrollLock = null;
14923
+ }
14529
14924
  if (open) {
14530
14925
  recalcPanelHeight();
14531
14926
  scheduleAutoScroll(true);
@@ -14688,7 +15083,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
14688
15083
  }
14689
15084
  });
14690
15085
  sessionRef.current = session;
14691
- if (((_E = (_D = config.voiceRecognition) == null ? void 0 : _D.provider) == null ? void 0 : _E.type) === "runtype") {
15086
+ if (((_G = (_F = config.voiceRecognition) == null ? void 0 : _F.provider) == null ? void 0 : _G.type) === "runtype") {
14692
15087
  try {
14693
15088
  session.setupVoice();
14694
15089
  } catch (err) {
@@ -15217,7 +15612,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15217
15612
  }
15218
15613
  }
15219
15614
  const recalcPanelHeight = () => {
15220
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
15615
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2, _q2, _r2, _s2, _t2, _u2, _v2;
15221
15616
  const dockedMode = isDockedMountMode(config);
15222
15617
  const sidebarMode = (_b2 = (_a2 = config.launcher) == null ? void 0 : _a2.sidebarMode) != null ? _b2 : false;
15223
15618
  const fullHeight = dockedMode || sidebarMode || ((_d2 = (_c2 = config.launcher) == null ? void 0 : _c2.fullHeight) != null ? _d2 : false);
@@ -15259,38 +15654,94 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15259
15654
  panel.style.height = `${finalHeight}px`;
15260
15655
  }
15261
15656
  } finally {
15657
+ updateScrollToBottomButtonOffset();
15262
15658
  updateOpenState();
15659
+ if (open && launcherEnabled) {
15660
+ const ow = (_n2 = mount.ownerDocument.defaultView) != null ? _n2 : window;
15661
+ const isMobile = ow.innerWidth <= ((_p2 = (_o2 = config.launcher) == null ? void 0 : _o2.mobileBreakpoint) != null ? _p2 : 640);
15662
+ const sm = (_r2 = (_q2 = config.launcher) == null ? void 0 : _q2.sidebarMode) != null ? _r2 : false;
15663
+ const mf = (_t2 = (_s2 = config.launcher) == null ? void 0 : _s2.mobileFullscreen) != null ? _t2 : true;
15664
+ const dockedMF = isDockedMountMode(config) && mf && isMobile;
15665
+ const isVC = sm || mf && isMobile && launcherEnabled || dockedMF;
15666
+ if (isVC && !releaseScrollLock) {
15667
+ const root = mount.getRootNode();
15668
+ const hostEl = root instanceof ShadowRoot ? root.host : mount.closest(".persona-host");
15669
+ if (hostEl && !teardownHostStacking) {
15670
+ teardownHostStacking = syncOverlayHostStacking(
15671
+ hostEl,
15672
+ (_v2 = (_u2 = config.launcher) == null ? void 0 : _u2.zIndex) != null ? _v2 : DEFAULT_OVERLAY_Z_INDEX
15673
+ );
15674
+ }
15675
+ releaseScrollLock = acquireScrollLock(mount.ownerDocument);
15676
+ } else if (!isVC) {
15677
+ teardownHostStacking == null ? void 0 : teardownHostStacking();
15678
+ teardownHostStacking = null;
15679
+ releaseScrollLock == null ? void 0 : releaseScrollLock();
15680
+ releaseScrollLock = null;
15681
+ }
15682
+ }
15263
15683
  }
15264
15684
  };
15265
15685
  recalcPanelHeight();
15266
- const ownerWindow = (_F = mount.ownerDocument.defaultView) != null ? _F : window;
15686
+ const ownerWindow = (_H = mount.ownerDocument.defaultView) != null ? _H : window;
15267
15687
  ownerWindow.addEventListener("resize", recalcPanelHeight);
15268
15688
  destroyCallbacks.push(() => ownerWindow.removeEventListener("resize", recalcPanelHeight));
15689
+ if (typeof ResizeObserver !== "undefined") {
15690
+ const footerResizeObserver = new ResizeObserver(() => {
15691
+ updateScrollToBottomButtonOffset();
15692
+ });
15693
+ footerResizeObserver.observe(footer);
15694
+ destroyCallbacks.push(() => footerResizeObserver.disconnect());
15695
+ }
15269
15696
  lastScrollTop = body.scrollTop;
15270
15697
  const handleScroll = () => {
15271
15698
  const scrollTop = body.scrollTop;
15272
- const scrollHeight = body.scrollHeight;
15273
- const clientHeight = body.clientHeight;
15274
- const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
15275
- const delta = Math.abs(scrollTop - lastScrollTop);
15276
- lastScrollTop = scrollTop;
15277
- if (isAutoScrolling) return;
15278
- if (delta <= USER_SCROLL_THRESHOLD) return;
15279
- if (!shouldAutoScroll && distanceFromBottom < BOTTOM_THRESHOLD) {
15280
- isAutoScrollBlocked = false;
15281
- shouldAutoScroll = true;
15699
+ const { action, nextLastScrollTop } = resolveFollowStateFromScroll({
15700
+ following: autoFollow.isFollowing(),
15701
+ currentScrollTop: scrollTop,
15702
+ lastScrollTop,
15703
+ nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
15704
+ userScrollThreshold: USER_SCROLL_THRESHOLD,
15705
+ isAutoScrolling,
15706
+ pauseOnUpwardScroll: true,
15707
+ pauseWhenAwayFromBottom: false,
15708
+ resumeRequiresDownwardScroll: true
15709
+ });
15710
+ lastScrollTop = nextLastScrollTop;
15711
+ if (action === "resume") {
15712
+ resumeAutoScroll();
15282
15713
  return;
15283
15714
  }
15284
- if (shouldAutoScroll && distanceFromBottom > BOTTOM_THRESHOLD) {
15285
- isAutoScrollBlocked = true;
15286
- blockUntilTime = Date.now() + AUTO_SCROLL_BLOCK_TIME;
15287
- shouldAutoScroll = false;
15715
+ if (action === "pause") {
15716
+ pauseAutoScroll();
15288
15717
  }
15289
15718
  };
15290
15719
  body.addEventListener("scroll", handleScroll, { passive: true });
15291
15720
  destroyCallbacks.push(() => body.removeEventListener("scroll", handleScroll));
15721
+ const handleWheel = (event) => {
15722
+ const action = resolveFollowStateFromWheel({
15723
+ following: autoFollow.isFollowing(),
15724
+ deltaY: event.deltaY,
15725
+ nearBottom: isElementNearBottom(body, BOTTOM_THRESHOLD),
15726
+ resumeWhenNearBottom: true
15727
+ });
15728
+ if (action === "pause") {
15729
+ pauseAutoScroll();
15730
+ } else if (action === "resume") {
15731
+ resumeAutoScroll();
15732
+ }
15733
+ };
15734
+ body.addEventListener("wheel", handleWheel, { passive: true });
15735
+ destroyCallbacks.push(() => body.removeEventListener("wheel", handleWheel));
15736
+ scrollToBottomButton.addEventListener("click", () => {
15737
+ body.scrollTop = body.scrollHeight;
15738
+ lastScrollTop = body.scrollTop;
15739
+ resumeAutoScroll();
15740
+ scheduleAutoScroll(true);
15741
+ });
15742
+ destroyCallbacks.push(() => scrollToBottomButton.remove());
15292
15743
  destroyCallbacks.push(() => {
15293
- if (scrollRAF) cancelAnimationFrame(scrollRAF);
15744
+ cancelAutoScroll();
15294
15745
  });
15295
15746
  const refreshCloseButton = () => {
15296
15747
  if (!closeButton) return;
@@ -15315,6 +15766,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15315
15766
  clearChatButton.addEventListener("click", () => {
15316
15767
  session.clearMessages();
15317
15768
  messageCache.clear();
15769
+ resumeAutoScroll();
15318
15770
  try {
15319
15771
  localStorage.removeItem(DEFAULT_CHAT_HISTORY_STORAGE_KEY);
15320
15772
  if (config.debug) {
@@ -15386,7 +15838,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15386
15838
  }
15387
15839
  const controller = {
15388
15840
  update(nextConfig) {
15389
- 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;
15841
+ 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;
15390
15842
  const previousToolCallConfig = config.toolCall;
15391
15843
  const previousMessageActions = config.messageActions;
15392
15844
  const previousLayoutMessages = (_a2 = config.layout) == null ? void 0 : _a2.messages;
@@ -15409,8 +15861,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15409
15861
  autoExpand = (_e2 = (_d2 = config.launcher) == null ? void 0 : _d2.autoExpand) != null ? _e2 : false;
15410
15862
  showReasoning = (_g2 = (_f2 = config.features) == null ? void 0 : _f2.showReasoning) != null ? _g2 : true;
15411
15863
  showToolCalls = (_i2 = (_h2 = config.features) == null ? void 0 : _h2.showToolCalls) != null ? _i2 : true;
15864
+ scrollToBottomFeature = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.scrollToBottom) != null ? _k2 : {};
15865
+ renderScrollToBottomButton();
15866
+ syncScrollToBottomButton();
15412
15867
  const prevShowEventStreamToggle = showEventStreamToggle;
15413
- showEventStreamToggle = (_k2 = (_j2 = config.features) == null ? void 0 : _j2.showEventStreamToggle) != null ? _k2 : false;
15868
+ showEventStreamToggle = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.showEventStreamToggle) != null ? _m2 : false;
15414
15869
  if (showEventStreamToggle && !prevShowEventStreamToggle) {
15415
15870
  if (!eventStreamBuffer) {
15416
15871
  eventStreamStore = new EventStreamStore(eventStreamDbName);
@@ -15427,7 +15882,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15427
15882
  });
15428
15883
  }
15429
15884
  if (!eventStreamToggleBtn && header) {
15430
- const dynEsClassNames = (_m2 = (_l2 = config.features) == null ? void 0 : _l2.eventStream) == null ? void 0 : _m2.classNames;
15885
+ const dynEsClassNames = (_o2 = (_n2 = config.features) == null ? void 0 : _n2.eventStream) == null ? void 0 : _o2.classNames;
15431
15886
  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 : "");
15432
15887
  eventStreamToggleBtn = createElement("button", dynToggleBtnClasses);
15433
15888
  eventStreamToggleBtn.style.width = "28px";
@@ -15465,15 +15920,15 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15465
15920
  eventStreamBuffer = null;
15466
15921
  eventStreamStore = null;
15467
15922
  }
15468
- if (((_n2 = config.launcher) == null ? void 0 : _n2.enabled) === false && launcherButtonInstance) {
15923
+ if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) === false && launcherButtonInstance) {
15469
15924
  launcherButtonInstance.destroy();
15470
15925
  launcherButtonInstance = null;
15471
15926
  }
15472
- if (((_o2 = config.launcher) == null ? void 0 : _o2.enabled) === false && customLauncherElement) {
15927
+ if (((_q2 = config.launcher) == null ? void 0 : _q2.enabled) === false && customLauncherElement) {
15473
15928
  customLauncherElement.remove();
15474
15929
  customLauncherElement = null;
15475
15930
  }
15476
- if (((_p2 = config.launcher) == null ? void 0 : _p2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
15931
+ if (((_r2 = config.launcher) == null ? void 0 : _r2.enabled) !== false && !launcherButtonInstance && !customLauncherElement) {
15477
15932
  const launcherPlugin = plugins.find((p) => p.renderLauncher);
15478
15933
  if (launcherPlugin == null ? void 0 : launcherPlugin.renderLauncher) {
15479
15934
  const customLauncher = launcherPlugin.renderLauncher({
@@ -15497,13 +15952,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15497
15952
  if (launcherButtonInstance) {
15498
15953
  launcherButtonInstance.update(config);
15499
15954
  }
15500
- if (headerTitle && ((_q2 = config.launcher) == null ? void 0 : _q2.title) !== void 0) {
15955
+ if (headerTitle && ((_s2 = config.launcher) == null ? void 0 : _s2.title) !== void 0) {
15501
15956
  headerTitle.textContent = config.launcher.title;
15502
15957
  }
15503
- if (headerSubtitle && ((_r2 = config.launcher) == null ? void 0 : _r2.subtitle) !== void 0) {
15958
+ if (headerSubtitle && ((_t2 = config.launcher) == null ? void 0 : _t2.subtitle) !== void 0) {
15504
15959
  headerSubtitle.textContent = config.launcher.subtitle;
15505
15960
  }
15506
- const headerLayoutConfig = (_s2 = config.layout) == null ? void 0 : _s2.header;
15961
+ const headerLayoutConfig = (_u2 = config.layout) == null ? void 0 : _u2.header;
15507
15962
  const headerLayoutChanged = (headerLayoutConfig == null ? void 0 : headerLayoutConfig.layout) !== prevHeaderLayout;
15508
15963
  if (headerLayoutChanged && header) {
15509
15964
  const newHeaderElements = headerLayoutConfig ? buildHeaderWithLayout(config, headerLayoutConfig, {
@@ -15549,14 +16004,16 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15549
16004
  }
15550
16005
  }
15551
16006
  }
15552
- const showHeader = ((_t2 = config.layout) == null ? void 0 : _t2.showHeader) !== false;
16007
+ const showHeader = ((_v2 = config.layout) == null ? void 0 : _v2.showHeader) !== false;
15553
16008
  if (header) {
15554
16009
  header.style.display = showHeader ? "" : "none";
15555
16010
  }
15556
- const showFooter = ((_u2 = config.layout) == null ? void 0 : _u2.showFooter) !== false;
16011
+ const showFooter = ((_w2 = config.layout) == null ? void 0 : _w2.showFooter) !== false;
15557
16012
  if (footer) {
15558
16013
  footer.style.display = showFooter ? "" : "none";
15559
16014
  }
16015
+ updateScrollToBottomButtonOffset();
16016
+ syncScrollToBottomButton();
15560
16017
  const launcherEnabledChanged = launcherEnabled !== prevLauncherEnabled;
15561
16018
  const autoExpandChanged = autoExpand !== prevAutoExpand;
15562
16019
  if (launcherEnabledChanged) {
@@ -15575,20 +16032,20 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15575
16032
  refreshCloseButton();
15576
16033
  const toolCallConfigChanged = JSON.stringify(nextConfig.toolCall) !== JSON.stringify(previousToolCallConfig);
15577
16034
  const messageActionsChanged = JSON.stringify(config.messageActions) !== JSON.stringify(previousMessageActions);
15578
- const layoutMessagesChanged = JSON.stringify((_v2 = config.layout) == null ? void 0 : _v2.messages) !== JSON.stringify(previousLayoutMessages);
15579
- 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);
16035
+ const layoutMessagesChanged = JSON.stringify((_x2 = config.layout) == null ? void 0 : _x2.messages) !== JSON.stringify(previousLayoutMessages);
16036
+ 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);
15580
16037
  const iterationDisplayChanged = config.iterationDisplay !== previousIterationDisplay;
15581
16038
  const messagesConfigChanged = toolCallConfigChanged || messageActionsChanged || layoutMessagesChanged || loadingIndicatorChanged || iterationDisplayChanged;
15582
16039
  if (messagesConfigChanged && session) {
15583
16040
  configVersion++;
15584
16041
  renderMessagesWithPlugins(messagesWrapper, session.getMessages(), postprocess);
15585
16042
  }
15586
- const launcher = (_z2 = config.launcher) != null ? _z2 : {};
15587
- const headerIconHidden = (_A2 = launcher.headerIconHidden) != null ? _A2 : false;
15588
- const layoutShowIcon = (_C2 = (_B2 = config.layout) == null ? void 0 : _B2.header) == null ? void 0 : _C2.showIcon;
16043
+ const launcher = (_B2 = config.launcher) != null ? _B2 : {};
16044
+ const headerIconHidden = (_C2 = launcher.headerIconHidden) != null ? _C2 : false;
16045
+ const layoutShowIcon = (_E2 = (_D2 = config.layout) == null ? void 0 : _D2.header) == null ? void 0 : _E2.showIcon;
15589
16046
  const shouldHideIcon = headerIconHidden || layoutShowIcon === false;
15590
16047
  const headerIconName = launcher.headerIconName;
15591
- const headerIconSize = (_D2 = launcher.headerIconSize) != null ? _D2 : "48px";
16048
+ const headerIconSize = (_F2 = launcher.headerIconSize) != null ? _F2 : "48px";
15592
16049
  if (iconHolder) {
15593
16050
  const headerEl = container.querySelector(".persona-border-b-persona-divider");
15594
16051
  const headerCopy = headerEl == null ? void 0 : headerEl.querySelector(".persona-flex-col");
@@ -15615,7 +16072,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15615
16072
  if (iconSvg) {
15616
16073
  iconHolder.replaceChildren(iconSvg);
15617
16074
  } else {
15618
- iconHolder.textContent = (_E2 = launcher.agentIconText) != null ? _E2 : "\u{1F4AC}";
16075
+ iconHolder.textContent = (_G2 = launcher.agentIconText) != null ? _G2 : "\u{1F4AC}";
15619
16076
  }
15620
16077
  } else if (launcher.iconUrl) {
15621
16078
  const img2 = iconHolder.querySelector("img");
@@ -15638,7 +16095,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15638
16095
  if (existingSvg || existingImg) {
15639
16096
  iconHolder.replaceChildren();
15640
16097
  }
15641
- iconHolder.textContent = (_F2 = launcher.agentIconText) != null ? _F2 : "\u{1F4AC}";
16098
+ iconHolder.textContent = (_H2 = launcher.agentIconText) != null ? _H2 : "\u{1F4AC}";
15642
16099
  }
15643
16100
  const img = iconHolder.querySelector("img");
15644
16101
  if (img) {
@@ -15647,8 +16104,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15647
16104
  }
15648
16105
  }
15649
16106
  }
15650
- const layoutShowTitle = (_H2 = (_G2 = config.layout) == null ? void 0 : _G2.header) == null ? void 0 : _H2.showTitle;
15651
- const layoutShowSubtitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showSubtitle;
16107
+ const layoutShowTitle = (_J2 = (_I2 = config.layout) == null ? void 0 : _I2.header) == null ? void 0 : _J2.showTitle;
16108
+ const layoutShowSubtitle = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showSubtitle;
15652
16109
  if (headerTitle) {
15653
16110
  headerTitle.style.display = layoutShowTitle === false ? "none" : "";
15654
16111
  }
@@ -15656,14 +16113,14 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15656
16113
  headerSubtitle.style.display = layoutShowSubtitle === false ? "none" : "";
15657
16114
  }
15658
16115
  if (closeButton) {
15659
- const layoutShowCloseButton = (_L2 = (_K2 = config.layout) == null ? void 0 : _K2.header) == null ? void 0 : _L2.showCloseButton;
16116
+ const layoutShowCloseButton = (_N2 = (_M2 = config.layout) == null ? void 0 : _M2.header) == null ? void 0 : _N2.showCloseButton;
15660
16117
  if (layoutShowCloseButton === false) {
15661
16118
  closeButton.style.display = "none";
15662
16119
  } else {
15663
16120
  closeButton.style.display = "";
15664
16121
  }
15665
- const closeButtonSize = (_M = launcher.closeButtonSize) != null ? _M : "32px";
15666
- const closeButtonPlacement = (_N = launcher.closeButtonPlacement) != null ? _N : "inline";
16122
+ const closeButtonSize = (_O = launcher.closeButtonSize) != null ? _O : "32px";
16123
+ const closeButtonPlacement = (_P = launcher.closeButtonPlacement) != null ? _P : "inline";
15667
16124
  closeButton.style.height = closeButtonSize;
15668
16125
  closeButton.style.width = closeButtonSize;
15669
16126
  const { closeButtonWrapper } = panelElements;
@@ -15676,8 +16133,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15676
16133
  container.style.position = "relative";
15677
16134
  container.appendChild(closeButtonWrapper);
15678
16135
  } else {
15679
- const clearChatPlacement = (_P = (_O = launcher.clearChat) == null ? void 0 : _O.placement) != null ? _P : "inline";
15680
- const clearChatEnabled = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.enabled) != null ? _R : true;
16136
+ const clearChatPlacement = (_R = (_Q = launcher.clearChat) == null ? void 0 : _Q.placement) != null ? _R : "inline";
16137
+ const clearChatEnabled = (_T = (_S = launcher.clearChat) == null ? void 0 : _S.enabled) != null ? _T : true;
15681
16138
  closeButtonWrapper.className = clearChatEnabled && clearChatPlacement === "inline" ? "" : "persona-ml-auto";
15682
16139
  const header2 = container.querySelector(".persona-border-b-persona-divider");
15683
16140
  if (header2) {
@@ -15723,8 +16180,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15723
16180
  closeButton.style.paddingTop = "";
15724
16181
  closeButton.style.paddingBottom = "";
15725
16182
  }
15726
- const closeButtonIconName = (_S = launcher.closeButtonIconName) != null ? _S : "x";
15727
- const closeButtonIconText = (_T = launcher.closeButtonIconText) != null ? _T : "\xD7";
16183
+ const closeButtonIconName = (_U = launcher.closeButtonIconName) != null ? _U : "x";
16184
+ const closeButtonIconText = (_V = launcher.closeButtonIconText) != null ? _V : "\xD7";
15728
16185
  closeButton.innerHTML = "";
15729
16186
  const iconSvg = renderLucideIcon(closeButtonIconName, "20px", "currentColor", 2);
15730
16187
  if (iconSvg) {
@@ -15732,8 +16189,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15732
16189
  } else {
15733
16190
  closeButton.textContent = closeButtonIconText;
15734
16191
  }
15735
- const closeButtonTooltipText = (_U = launcher.closeButtonTooltipText) != null ? _U : "Close chat";
15736
- const closeButtonShowTooltip = (_V = launcher.closeButtonShowTooltip) != null ? _V : true;
16192
+ const closeButtonTooltipText = (_W = launcher.closeButtonTooltipText) != null ? _W : "Close chat";
16193
+ const closeButtonShowTooltip = (_X = launcher.closeButtonShowTooltip) != null ? _X : true;
15737
16194
  closeButton.setAttribute("aria-label", closeButtonTooltipText);
15738
16195
  if (closeButtonWrapper) {
15739
16196
  if (closeButtonWrapper._cleanupTooltip) {
@@ -15758,6 +16215,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15758
16215
  portaledTooltip.appendChild(arrow);
15759
16216
  const buttonRect = closeButton.getBoundingClientRect();
15760
16217
  portaledTooltip.style.position = "fixed";
16218
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
15761
16219
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
15762
16220
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
15763
16221
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -15789,11 +16247,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15789
16247
  }
15790
16248
  const { clearChatButton, clearChatButtonWrapper } = panelElements;
15791
16249
  if (clearChatButton) {
15792
- const clearChatConfig = (_W = launcher.clearChat) != null ? _W : {};
15793
- const clearChatEnabled = (_X = clearChatConfig.enabled) != null ? _X : true;
15794
- const layoutShowClearChat = (_Z = (_Y = config.layout) == null ? void 0 : _Y.header) == null ? void 0 : _Z.showClearChat;
16250
+ const clearChatConfig = (_Y = launcher.clearChat) != null ? _Y : {};
16251
+ const clearChatEnabled = (_Z = clearChatConfig.enabled) != null ? _Z : true;
16252
+ const layoutShowClearChat = (_$ = (__ = config.layout) == null ? void 0 : __.header) == null ? void 0 : _$.showClearChat;
15795
16253
  const shouldShowClearChat = layoutShowClearChat !== void 0 ? layoutShowClearChat : clearChatEnabled;
15796
- const clearChatPlacement = (__ = clearChatConfig.placement) != null ? __ : "inline";
16254
+ const clearChatPlacement = (_aa = clearChatConfig.placement) != null ? _aa : "inline";
15797
16255
  if (clearChatButtonWrapper) {
15798
16256
  clearChatButtonWrapper.style.display = shouldShowClearChat ? "" : "none";
15799
16257
  const { closeButtonWrapper } = panelElements;
@@ -15835,11 +16293,11 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15835
16293
  }
15836
16294
  }
15837
16295
  if (shouldShowClearChat) {
15838
- const clearChatSize = (_$ = clearChatConfig.size) != null ? _$ : "32px";
16296
+ const clearChatSize = (_ba = clearChatConfig.size) != null ? _ba : "32px";
15839
16297
  clearChatButton.style.height = clearChatSize;
15840
16298
  clearChatButton.style.width = clearChatSize;
15841
- const clearChatIconName = (_aa = clearChatConfig.iconName) != null ? _aa : "refresh-cw";
15842
- const clearChatIconColor = (_ba = clearChatConfig.iconColor) != null ? _ba : "";
16299
+ const clearChatIconName = (_ca = clearChatConfig.iconName) != null ? _ca : "refresh-cw";
16300
+ const clearChatIconColor = (_da = clearChatConfig.iconColor) != null ? _da : "";
15843
16301
  clearChatButton.style.color = clearChatIconColor || HEADER_THEME_CSS.actionIconColor;
15844
16302
  clearChatButton.innerHTML = "";
15845
16303
  const iconSvg = renderLucideIcon(clearChatIconName, "20px", "currentColor", 2);
@@ -15883,8 +16341,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15883
16341
  clearChatButton.style.paddingTop = "";
15884
16342
  clearChatButton.style.paddingBottom = "";
15885
16343
  }
15886
- const clearChatTooltipText = (_ca = clearChatConfig.tooltipText) != null ? _ca : "Clear chat";
15887
- const clearChatShowTooltip = (_da = clearChatConfig.showTooltip) != null ? _da : true;
16344
+ const clearChatTooltipText = (_ea = clearChatConfig.tooltipText) != null ? _ea : "Clear chat";
16345
+ const clearChatShowTooltip = (_fa = clearChatConfig.showTooltip) != null ? _fa : true;
15888
16346
  clearChatButton.setAttribute("aria-label", clearChatTooltipText);
15889
16347
  if (clearChatButtonWrapper) {
15890
16348
  if (clearChatButtonWrapper._cleanupTooltip) {
@@ -15909,6 +16367,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15909
16367
  portaledTooltip.appendChild(arrow);
15910
16368
  const buttonRect = clearChatButton.getBoundingClientRect();
15911
16369
  portaledTooltip.style.position = "fixed";
16370
+ portaledTooltip.style.zIndex = String(PORTALED_OVERLAY_Z_INDEX);
15912
16371
  portaledTooltip.style.left = `${buttonRect.left + buttonRect.width / 2}px`;
15913
16372
  portaledTooltip.style.top = `${buttonRect.top - 8}px`;
15914
16373
  portaledTooltip.style.transform = "translate(-50%, -100%)";
@@ -15959,9 +16418,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15959
16418
  suggestionsManager.render(config.suggestionChips, session, textarea, void 0, config.suggestionChipsConfig);
15960
16419
  updateCopy();
15961
16420
  setComposerDisabled(session.isStreaming());
15962
- const voiceRecognitionEnabled = ((_ea = config.voiceRecognition) == null ? void 0 : _ea.enabled) === true;
16421
+ const voiceRecognitionEnabled = ((_ga = config.voiceRecognition) == null ? void 0 : _ga.enabled) === true;
15963
16422
  const hasSpeechRecognition = typeof window !== "undefined" && (typeof window.webkitSpeechRecognition !== "undefined" || typeof window.SpeechRecognition !== "undefined");
15964
- const hasRuntypeProvider = ((_ga = (_fa = config.voiceRecognition) == null ? void 0 : _fa.provider) == null ? void 0 : _ga.type) === "runtype";
16423
+ const hasRuntypeProvider = ((_ia = (_ha = config.voiceRecognition) == null ? void 0 : _ha.provider) == null ? void 0 : _ia.type) === "runtype";
15965
16424
  const hasVoiceInput = hasSpeechRecognition || hasRuntypeProvider;
15966
16425
  if (voiceRecognitionEnabled && hasVoiceInput) {
15967
16426
  if (!micButton || !micButtonWrapper) {
@@ -15974,17 +16433,17 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15974
16433
  micButton.disabled = session.isStreaming();
15975
16434
  }
15976
16435
  } else {
15977
- const voiceConfig = (_ha = config.voiceRecognition) != null ? _ha : {};
15978
- const sendButtonConfig2 = (_ia = config.sendButton) != null ? _ia : {};
15979
- const micIconName = (_ja = voiceConfig.iconName) != null ? _ja : "mic";
15980
- const buttonSize2 = (_ka = sendButtonConfig2.size) != null ? _ka : "40px";
15981
- const micIconSize = (_la = voiceConfig.iconSize) != null ? _la : buttonSize2;
16436
+ const voiceConfig = (_ja = config.voiceRecognition) != null ? _ja : {};
16437
+ const sendButtonConfig2 = (_ka = config.sendButton) != null ? _ka : {};
16438
+ const micIconName = (_la = voiceConfig.iconName) != null ? _la : "mic";
16439
+ const buttonSize2 = (_ma = sendButtonConfig2.size) != null ? _ma : "40px";
16440
+ const micIconSize = (_na = voiceConfig.iconSize) != null ? _na : buttonSize2;
15982
16441
  const micIconSizeNum = parseFloat(micIconSize) || 24;
15983
16442
  micButton.style.width = micIconSize;
15984
16443
  micButton.style.height = micIconSize;
15985
16444
  micButton.style.minWidth = micIconSize;
15986
16445
  micButton.style.minHeight = micIconSize;
15987
- const iconColor = (_na = (_ma = voiceConfig.iconColor) != null ? _ma : sendButtonConfig2.textColor) != null ? _na : "currentColor";
16446
+ const iconColor = (_pa = (_oa = voiceConfig.iconColor) != null ? _oa : sendButtonConfig2.textColor) != null ? _pa : "currentColor";
15988
16447
  micButton.innerHTML = "";
15989
16448
  const micIconSvg = renderLucideIcon(micIconName, micIconSizeNum, iconColor, 2);
15990
16449
  if (micIconSvg) {
@@ -15992,7 +16451,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
15992
16451
  } else {
15993
16452
  micButton.textContent = "\u{1F3A4}";
15994
16453
  }
15995
- const backgroundColor2 = (_oa = voiceConfig.backgroundColor) != null ? _oa : sendButtonConfig2.backgroundColor;
16454
+ const backgroundColor2 = (_qa = voiceConfig.backgroundColor) != null ? _qa : sendButtonConfig2.backgroundColor;
15996
16455
  if (backgroundColor2) {
15997
16456
  micButton.style.backgroundColor = backgroundColor2;
15998
16457
  } else {
@@ -16030,8 +16489,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16030
16489
  micButton.style.paddingBottom = "";
16031
16490
  }
16032
16491
  const tooltip2 = micButtonWrapper == null ? void 0 : micButtonWrapper.querySelector(".persona-send-button-tooltip");
16033
- const tooltipText2 = (_pa = voiceConfig.tooltipText) != null ? _pa : "Start voice recognition";
16034
- const showTooltip2 = (_qa = voiceConfig.showTooltip) != null ? _qa : false;
16492
+ const tooltipText2 = (_ra = voiceConfig.tooltipText) != null ? _ra : "Start voice recognition";
16493
+ const showTooltip2 = (_sa = voiceConfig.showTooltip) != null ? _sa : false;
16035
16494
  if (showTooltip2 && tooltipText2) {
16036
16495
  if (!tooltip2) {
16037
16496
  const newTooltip = document.createElement("div");
@@ -16051,19 +16510,19 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16051
16510
  } else {
16052
16511
  if (micButton && micButtonWrapper) {
16053
16512
  micButtonWrapper.style.display = "none";
16054
- if (((_sa = (_ra = config.voiceRecognition) == null ? void 0 : _ra.provider) == null ? void 0 : _sa.type) === "runtype") {
16513
+ if (((_ua = (_ta = config.voiceRecognition) == null ? void 0 : _ta.provider) == null ? void 0 : _ua.type) === "runtype") {
16055
16514
  if (session.isVoiceActive()) session.toggleVoice();
16056
16515
  } else if (isRecording) {
16057
16516
  stopVoiceRecognition();
16058
16517
  }
16059
16518
  }
16060
16519
  }
16061
- const attachmentsEnabled = ((_ta = config.attachments) == null ? void 0 : _ta.enabled) === true;
16520
+ const attachmentsEnabled = ((_va = config.attachments) == null ? void 0 : _va.enabled) === true;
16062
16521
  if (attachmentsEnabled) {
16063
16522
  if (!attachmentButtonWrapper || !attachmentButton) {
16064
- const attachmentsConfig = (_ua = config.attachments) != null ? _ua : {};
16065
- const sendButtonConfig2 = (_va = config.sendButton) != null ? _va : {};
16066
- const buttonSize2 = (_wa = sendButtonConfig2.size) != null ? _wa : "40px";
16523
+ const attachmentsConfig = (_wa = config.attachments) != null ? _wa : {};
16524
+ const sendButtonConfig2 = (_xa = config.sendButton) != null ? _xa : {};
16525
+ const buttonSize2 = (_ya = sendButtonConfig2.size) != null ? _ya : "40px";
16067
16526
  if (!attachmentPreviewsContainer) {
16068
16527
  attachmentPreviewsContainer = createElement("div", "persona-attachment-previews persona-flex persona-flex-wrap persona-gap-2 persona-mb-2");
16069
16528
  attachmentPreviewsContainer.style.display = "none";
@@ -16072,8 +16531,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16072
16531
  if (!attachmentInput) {
16073
16532
  attachmentInput = document.createElement("input");
16074
16533
  attachmentInput.type = "file";
16075
- attachmentInput.accept = ((_xa = attachmentsConfig.allowedTypes) != null ? _xa : ALL_SUPPORTED_MIME_TYPES).join(",");
16076
- attachmentInput.multiple = ((_ya = attachmentsConfig.maxFiles) != null ? _ya : 4) > 1;
16534
+ attachmentInput.accept = ((_za = attachmentsConfig.allowedTypes) != null ? _za : ALL_SUPPORTED_MIME_TYPES).join(",");
16535
+ attachmentInput.multiple = ((_Aa = attachmentsConfig.maxFiles) != null ? _Aa : 4) > 1;
16077
16536
  attachmentInput.style.display = "none";
16078
16537
  attachmentInput.setAttribute("aria-label", "Attach files");
16079
16538
  composerForm.insertBefore(attachmentInput, textarea);
@@ -16084,8 +16543,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16084
16543
  "persona-rounded-button persona-flex persona-items-center persona-justify-center disabled:persona-opacity-50 persona-cursor-pointer persona-attachment-button"
16085
16544
  );
16086
16545
  attachmentButton.type = "button";
16087
- attachmentButton.setAttribute("aria-label", (_za = attachmentsConfig.buttonTooltipText) != null ? _za : "Attach file");
16088
- const attachIconName = (_Aa = attachmentsConfig.buttonIconName) != null ? _Aa : "paperclip";
16546
+ attachmentButton.setAttribute("aria-label", (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file");
16547
+ const attachIconName = (_Ca = attachmentsConfig.buttonIconName) != null ? _Ca : "paperclip";
16089
16548
  const attachIconSize = buttonSize2;
16090
16549
  const buttonSizeNum = parseFloat(attachIconSize) || 40;
16091
16550
  const attachIconSizeNum = Math.round(buttonSizeNum * 0.6);
@@ -16117,7 +16576,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16117
16576
  attachmentInput == null ? void 0 : attachmentInput.click();
16118
16577
  });
16119
16578
  attachmentButtonWrapper.appendChild(attachmentButton);
16120
- const attachTooltipText = (_Ba = attachmentsConfig.buttonTooltipText) != null ? _Ba : "Attach file";
16579
+ const attachTooltipText = (_Da = attachmentsConfig.buttonTooltipText) != null ? _Da : "Attach file";
16121
16580
  const tooltip2 = createElement("div", "persona-send-button-tooltip");
16122
16581
  tooltip2.textContent = attachTooltipText;
16123
16582
  attachmentButtonWrapper.appendChild(tooltip2);
@@ -16134,10 +16593,10 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16134
16593
  }
16135
16594
  } else {
16136
16595
  attachmentButtonWrapper.style.display = "";
16137
- const attachmentsConfig = (_Ca = config.attachments) != null ? _Ca : {};
16596
+ const attachmentsConfig = (_Ea = config.attachments) != null ? _Ea : {};
16138
16597
  if (attachmentInput) {
16139
- attachmentInput.accept = ((_Da = attachmentsConfig.allowedTypes) != null ? _Da : ALL_SUPPORTED_MIME_TYPES).join(",");
16140
- attachmentInput.multiple = ((_Ea = attachmentsConfig.maxFiles) != null ? _Ea : 4) > 1;
16598
+ attachmentInput.accept = ((_Fa = attachmentsConfig.allowedTypes) != null ? _Fa : ALL_SUPPORTED_MIME_TYPES).join(",");
16599
+ attachmentInput.multiple = ((_Ga = attachmentsConfig.maxFiles) != null ? _Ga : 4) > 1;
16141
16600
  }
16142
16601
  if (attachmentManager) {
16143
16602
  attachmentManager.updateConfig({
@@ -16155,13 +16614,13 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16155
16614
  attachmentManager.clearAttachments();
16156
16615
  }
16157
16616
  }
16158
- const sendButtonConfig = (_Fa = config.sendButton) != null ? _Fa : {};
16159
- const useIcon = (_Ga = sendButtonConfig.useIcon) != null ? _Ga : false;
16160
- const iconText = (_Ha = sendButtonConfig.iconText) != null ? _Ha : "\u2191";
16617
+ const sendButtonConfig = (_Ha = config.sendButton) != null ? _Ha : {};
16618
+ const useIcon = (_Ia = sendButtonConfig.useIcon) != null ? _Ia : false;
16619
+ const iconText = (_Ja = sendButtonConfig.iconText) != null ? _Ja : "\u2191";
16161
16620
  const iconName = sendButtonConfig.iconName;
16162
- const tooltipText = (_Ia = sendButtonConfig.tooltipText) != null ? _Ia : "Send message";
16163
- const showTooltip = (_Ja = sendButtonConfig.showTooltip) != null ? _Ja : false;
16164
- const buttonSize = (_Ka = sendButtonConfig.size) != null ? _Ka : "40px";
16621
+ const tooltipText = (_Ka = sendButtonConfig.tooltipText) != null ? _Ka : "Send message";
16622
+ const showTooltip = (_La = sendButtonConfig.showTooltip) != null ? _La : false;
16623
+ const buttonSize = (_Ma = sendButtonConfig.size) != null ? _Ma : "40px";
16165
16624
  const backgroundColor = sendButtonConfig.backgroundColor;
16166
16625
  const textColor = sendButtonConfig.textColor;
16167
16626
  if (useIcon) {
@@ -16198,7 +16657,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16198
16657
  sendButton.classList.add("persona-bg-persona-primary");
16199
16658
  }
16200
16659
  } else {
16201
- sendButton.textContent = (_Ma = (_La = config.copy) == null ? void 0 : _La.sendButtonLabel) != null ? _Ma : "Send";
16660
+ sendButton.textContent = (_Oa = (_Na = config.copy) == null ? void 0 : _Na.sendButtonLabel) != null ? _Oa : "Send";
16202
16661
  sendButton.style.width = "";
16203
16662
  sendButton.style.height = "";
16204
16663
  sendButton.style.minWidth = "";
@@ -16258,7 +16717,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16258
16717
  } else if (tooltip) {
16259
16718
  tooltip.style.display = "none";
16260
16719
  }
16261
- const updatedContentMaxWidth = (_Na = config.layout) == null ? void 0 : _Na.contentMaxWidth;
16720
+ const updatedContentMaxWidth = (_Pa = config.layout) == null ? void 0 : _Pa.contentMaxWidth;
16262
16721
  if (updatedContentMaxWidth) {
16263
16722
  messagesWrapper.style.maxWidth = updatedContentMaxWidth;
16264
16723
  messagesWrapper.style.marginLeft = "auto";
@@ -16280,8 +16739,8 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16280
16739
  composerForm.style.marginRight = "";
16281
16740
  }
16282
16741
  }
16283
- const statusIndicatorConfig = (_Oa = config.statusIndicator) != null ? _Oa : {};
16284
- const isVisible = (_Pa = statusIndicatorConfig.visible) != null ? _Pa : true;
16742
+ const statusIndicatorConfig = (_Qa = config.statusIndicator) != null ? _Qa : {};
16743
+ const isVisible = (_Ra = statusIndicatorConfig.visible) != null ? _Ra : true;
16285
16744
  statusText.style.display = isVisible ? "" : "none";
16286
16745
  if (session) {
16287
16746
  const currentStatus = session.getStatus();
@@ -16315,6 +16774,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16315
16774
  artifactsPaneUserHidden = false;
16316
16775
  session.clearMessages();
16317
16776
  messageCache.clear();
16777
+ resumeAutoScroll();
16318
16778
  try {
16319
16779
  localStorage.removeItem(DEFAULT_CHAT_HISTORY_STORAGE_KEY);
16320
16780
  if (config.debug) {
@@ -16635,7 +17095,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16635
17095
  }
16636
17096
  }
16637
17097
  };
16638
- const shouldExposeDebugApi = ((_G = runtimeOptions == null ? void 0 : runtimeOptions.debugTools) != null ? _G : false) || Boolean(config.debug);
17098
+ const shouldExposeDebugApi = ((_I = runtimeOptions == null ? void 0 : runtimeOptions.debugTools) != null ? _I : false) || Boolean(config.debug);
16639
17099
  if (shouldExposeDebugApi && typeof window !== "undefined") {
16640
17100
  const previousDebug = window.AgentWidgetBrowser;
16641
17101
  const debugApi = {
@@ -16738,9 +17198,9 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16738
17198
  const voiceKey = `${persistConfig.keyPrefix}widget-voice`;
16739
17199
  const voiceModeKey = `${persistConfig.keyPrefix}widget-voice-mode`;
16740
17200
  if (storage) {
16741
- const wasOpen = ((_H = persistConfig.persist) == null ? void 0 : _H.openState) && storage.getItem(openKey) === "true";
16742
- const wasVoiceActive = ((_I = persistConfig.persist) == null ? void 0 : _I.voiceState) && storage.getItem(voiceKey) === "true";
16743
- const wasInVoiceMode = ((_J = persistConfig.persist) == null ? void 0 : _J.voiceState) && storage.getItem(voiceModeKey) === "true";
17201
+ const wasOpen = ((_J = persistConfig.persist) == null ? void 0 : _J.openState) && storage.getItem(openKey) === "true";
17202
+ const wasVoiceActive = ((_K = persistConfig.persist) == null ? void 0 : _K.voiceState) && storage.getItem(voiceKey) === "true";
17203
+ const wasInVoiceMode = ((_L = persistConfig.persist) == null ? void 0 : _L.voiceState) && storage.getItem(voiceModeKey) === "true";
16744
17204
  if (wasOpen) {
16745
17205
  setTimeout(() => {
16746
17206
  controller.open();
@@ -16757,7 +17217,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16757
17217
  }, 100);
16758
17218
  }, 0);
16759
17219
  }
16760
- if ((_K = persistConfig.persist) == null ? void 0 : _K.openState) {
17220
+ if ((_M = persistConfig.persist) == null ? void 0 : _M.openState) {
16761
17221
  eventBus.on("widget:opened", () => {
16762
17222
  storage.setItem(openKey, "true");
16763
17223
  });
@@ -16765,7 +17225,7 @@ var createAgentExperience = (mount, initialConfig, runtimeOptions) => {
16765
17225
  storage.setItem(openKey, "false");
16766
17226
  });
16767
17227
  }
16768
- if ((_L = persistConfig.persist) == null ? void 0 : _L.voiceState) {
17228
+ if ((_N = persistConfig.persist) == null ? void 0 : _N.voiceState) {
16769
17229
  eventBus.on("voice:state", (event) => {
16770
17230
  storage.setItem(voiceKey, event.active ? "true" : "false");
16771
17231
  });
@@ -16938,7 +17398,7 @@ var applyDockStyles = (shell, pushTrack, contentSlot, dockSlot, host, config, ex
16938
17398
  dockSlot.style.minWidth = "0";
16939
17399
  dockSlot.style.minHeight = "0";
16940
17400
  dockSlot.style.overflow = "hidden";
16941
- dockSlot.style.zIndex = String((_f = (_e = config == null ? void 0 : config.launcher) == null ? void 0 : _e.zIndex) != null ? _f : 9999);
17401
+ dockSlot.style.zIndex = String((_f = (_e = config == null ? void 0 : config.launcher) == null ? void 0 : _e.zIndex) != null ? _f : DEFAULT_OVERLAY_Z_INDEX);
16942
17402
  dockSlot.style.transform = "none";
16943
17403
  dockSlot.style.transition = "none";
16944
17404
  dockSlot.style.pointerEvents = "auto";
@@ -17684,6 +18144,7 @@ function createThemePreview(container, initialOptions) {
17684
18144
  ROLE_INTENSITIES,
17685
18145
  ROLE_LINKS_FOCUS,
17686
18146
  ROLE_PRIMARY_ACTIONS,
18147
+ ROLE_SCROLL_TO_BOTTOM,
17687
18148
  ROLE_SURFACES,
17688
18149
  ROLE_USER_MESSAGES,
17689
18150
  SEMANTIC_COLORS_SECTION,