@runtypelabs/persona 4.32.2 → 4.34.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 (215) hide show
  1. package/dist/activity-ui.d.cts +3 -15
  2. package/dist/activity-ui.d.ts +3 -15
  3. package/dist/animations/glyph-cycle.d.cts +1 -3
  4. package/dist/animations/glyph-cycle.d.ts +1 -3
  5. package/dist/animations/wipe.d.cts +1 -3
  6. package/dist/animations/wipe.d.ts +1 -3
  7. package/dist/approval-ui.cjs +2 -2
  8. package/dist/approval-ui.d.cts +3 -15
  9. package/dist/approval-ui.d.ts +3 -15
  10. package/dist/approval-ui.js +1 -1
  11. package/dist/artifacts-ui.cjs +1 -1
  12. package/dist/artifacts-ui.d.cts +3 -21
  13. package/dist/artifacts-ui.d.ts +3 -21
  14. package/dist/background-runtime.d.cts +2 -3
  15. package/dist/background-runtime.d.ts +2 -3
  16. package/dist/{chunk-BbXc58OA.js → chunk-6CUrH_jm.js} +1 -1
  17. package/dist/{chunk-B_H0l3u2.js → chunk-BRM3bHcJ.js} +1 -1
  18. package/dist/{chunk-DNdeIFJ6.js → chunk-Brdx4NCz.js} +1 -1
  19. package/dist/chunk-C-rux8Q9.js +1 -0
  20. package/dist/{chunk-Ds_twaZn.js → chunk-C4v-HNhS.js} +1 -1
  21. package/dist/{chunk-Bkma5hIU.js → chunk-CE4seJxF.js} +1 -1
  22. package/dist/chunk-CEPM3FOp.js +1 -0
  23. package/dist/{chunk-BpjtKnGI.js → chunk-CV8EPIhT.js} +1 -1
  24. package/dist/{chunk-DVZ8ri1z.js → chunk-CWzHNuVK.js} +1 -1
  25. package/dist/{chunk-B3l7TOOv.js → chunk-CYpt7PsO.js} +1 -1
  26. package/dist/{chunk-2FnmZ9AA.js → chunk-Csr59G5V.js} +1 -1
  27. package/dist/{chunk-B9Zu-wrk.js → chunk-CxNPSY-b.js} +1 -1
  28. package/dist/{chunk-UWMfWW2a.js → chunk-D1G8tgYc.js} +1 -1
  29. package/dist/{chunk-DTGvDx8o.js → chunk-Dj2a9f9w.js} +1 -1
  30. package/dist/chunk-Dqa_GOcj.js +1 -0
  31. package/dist/chunk-DsWv3EGF.js +1 -0
  32. package/dist/{chunk-C7-m0EmI.js → chunk-NUNdcnAZ.js} +1 -1
  33. package/dist/{chunk-D0tcIZJM.js → chunk-YMkMvAsa.js} +2 -2
  34. package/dist/{chunk-C-EHtpbB.js → chunk-h5aOI_Pa.js} +1 -1
  35. package/dist/chunk-i4qGOJAL.js +1 -0
  36. package/dist/chunk-kizhspe5.js +1 -0
  37. package/dist/client-dispatch.js +1 -1
  38. package/dist/client-history.js +1 -1
  39. package/dist/client-stream.js +1 -1
  40. package/dist/{code-generators-DqauYyfX.d.cts → code-generators-DPAqTcAz.d.cts} +0 -2
  41. package/dist/{code-generators-DqauYyfX.d.ts → code-generators-DPAqTcAz.d.ts} +0 -2
  42. package/dist/codegen.cjs +1 -1
  43. package/dist/codegen.d.cts +1 -1
  44. package/dist/codegen.d.ts +1 -1
  45. package/dist/codegen.js +1 -1
  46. package/dist/composer-actions-runtime.cjs +1 -1
  47. package/dist/composer-actions-runtime.d.cts +4 -20
  48. package/dist/composer-actions-runtime.d.ts +4 -20
  49. package/dist/composer-actions-runtime.js +1 -1
  50. package/dist/{composer-input-dwg_o9Z-.d.ts → composer-input-i_FiUp6J.d.cts} +1 -7
  51. package/dist/{composer-input-dwg_o9Z-.d.cts → composer-input-i_FiUp6J.d.ts} +1 -7
  52. package/dist/{composer-store-Dw7Zbqxr.d.ts → composer-store-DhGNgG7Z.d.cts} +1 -3
  53. package/dist/{composer-store-Dw7Zbqxr.d.cts → composer-store-DhGNgG7Z.d.ts} +1 -3
  54. package/dist/config-diagnostics.d.cts +0 -2
  55. package/dist/config-diagnostics.d.ts +0 -2
  56. package/dist/{context-mention-manager-D2p0-JH-.d.ts → context-mention-manager-DL-xwGfL.d.cts} +2 -6
  57. package/dist/{context-mention-manager-D2p0-JH-.d.cts → context-mention-manager-DL-xwGfL.d.ts} +2 -6
  58. package/dist/context-mentions-inline.cjs +1 -1
  59. package/dist/context-mentions-inline.d.cts +2 -4
  60. package/dist/context-mentions-inline.d.ts +2 -4
  61. package/dist/context-mentions-inline.js +1 -1
  62. package/dist/context-mentions.cjs +1 -1
  63. package/dist/context-mentions.d.cts +3 -9
  64. package/dist/context-mentions.d.ts +3 -9
  65. package/dist/{defaults-CjX0kKzb.d.ts → defaults-Bga2Xrsp.d.cts} +2 -5
  66. package/dist/{defaults-CjX0kKzb.d.cts → defaults-Bga2Xrsp.d.ts} +2 -5
  67. package/dist/dictation-runtime.cjs +1 -1
  68. package/dist/dictation-runtime.d.cts +4 -13
  69. package/dist/dictation-runtime.d.ts +4 -13
  70. package/dist/dictation-runtime.js +1 -1
  71. package/dist/{dom-context-DHTabIn7.d.ts → dom-context-Bw-_9Evh.d.cts} +0 -2
  72. package/dist/{dom-context-DHTabIn7.d.cts → dom-context-Bw-_9Evh.d.ts} +0 -2
  73. package/dist/event-stream-view.cjs +1 -1
  74. package/dist/event-stream-view.d.cts +3 -16
  75. package/dist/event-stream-view.d.ts +3 -16
  76. package/dist/{fallback-speech-engine-DmF7MczI.d.ts → fallback-speech-engine-kLdyPcmk.d.cts} +1 -3
  77. package/dist/{fallback-speech-engine-DmF7MczI.d.cts → fallback-speech-engine-kLdyPcmk.d.ts} +1 -3
  78. package/dist/{feature-preferences-CVFDt9Xf.d.ts → feature-preferences-CmwZGKrf.d.cts} +1 -5
  79. package/dist/{feature-preferences-CVFDt9Xf.d.cts → feature-preferences-CmwZGKrf.d.ts} +1 -5
  80. package/dist/forms-ui.d.cts +2 -4
  81. package/dist/forms-ui.d.ts +2 -4
  82. package/dist/{history-confirm-dialog-DJEXsTyE.d.cts → history-confirm-dialog-i46-lPN_.d.cts} +2 -14
  83. package/dist/{history-confirm-dialog-DJEXsTyE.d.ts → history-confirm-dialog-i46-lPN_.d.ts} +2 -14
  84. package/dist/history-shell.cjs +1 -1
  85. package/dist/history-shell.d.cts +8 -27
  86. package/dist/history-shell.d.ts +8 -27
  87. package/dist/history-shell.js +1 -1
  88. package/dist/history-view.d.cts +1 -1
  89. package/dist/history-view.d.ts +1 -1
  90. package/dist/icons-extra.cjs +1 -1
  91. package/dist/icons-extra.d.cts +0 -2
  92. package/dist/icons-extra.d.ts +0 -2
  93. package/dist/index.cjs +44 -44
  94. package/dist/index.cjs.map +1 -1
  95. package/dist/index.d.cts +11 -11
  96. package/dist/index.d.ts +11 -11
  97. package/dist/index.global.js +1 -1
  98. package/dist/index.global.js.map +1 -1
  99. package/dist/index.js +46 -46
  100. package/dist/index.js.map +1 -1
  101. package/dist/install.global.js +1 -1
  102. package/dist/install.global.js.map +1 -1
  103. package/dist/launcher.global.js +2 -2
  104. package/dist/launcher.global.js.map +1 -1
  105. package/dist/{loading-label-runtime-loader-CPxnoaoi.d.ts → loading-label-runtime-loader-Ccr3ETd3.d.cts} +1 -3
  106. package/dist/{loading-label-runtime-loader-CPxnoaoi.d.cts → loading-label-runtime-loader-Ccr3ETd3.d.ts} +1 -3
  107. package/dist/loading-label-runtime.cjs +1 -1
  108. package/dist/loading-label-runtime.d.cts +1 -1
  109. package/dist/loading-label-runtime.d.ts +1 -1
  110. package/dist/loading-label-runtime.js +1 -1
  111. package/dist/markdown-parsers.js +1 -1
  112. package/dist/{message-bubble-CkZGlCLC.d.ts → message-bubble-C6AVaH7f.d.cts} +21 -4
  113. package/dist/{message-bubble-CkZGlCLC.d.cts → message-bubble-C6AVaH7f.d.ts} +21 -4
  114. package/dist/{plugin-kit-C1mRjLgW.d.cts → plugin-kit-BVggqE3C.d.cts} +0 -2
  115. package/dist/{plugin-kit-C1mRjLgW.d.ts → plugin-kit-BVggqE3C.d.ts} +0 -2
  116. package/dist/plugin-kit.d.cts +1 -1
  117. package/dist/plugin-kit.d.ts +1 -1
  118. package/dist/preferences-runtime.cjs +1 -1
  119. package/dist/preferences-runtime.d.cts +1 -1
  120. package/dist/preferences-runtime.d.ts +1 -1
  121. package/dist/preferences-runtime.js +1 -1
  122. package/dist/{preview-DdUvoLb4.d.cts → preview-BMdRffo4.d.cts} +2 -6
  123. package/dist/{preview-DdUvoLb4.d.ts → preview-BMdRffo4.d.ts} +2 -6
  124. package/dist/{registry-Dz4iHNST.d.ts → registry-B16l8s1b.d.cts} +1 -8
  125. package/dist/{registry-Dz4iHNST.d.cts → registry-B16l8s1b.d.ts} +1 -8
  126. package/dist/{session-Baxp9iRK.d.cts → session-CtZHe7fc.d.cts} +10 -93
  127. package/dist/{session-Baxp9iRK.d.ts → session-CtZHe7fc.d.ts} +10 -93
  128. package/dist/session-reconnect.d.cts +2 -4
  129. package/dist/session-reconnect.d.ts +2 -4
  130. package/dist/smart-dom-reader.d.cts +2 -8
  131. package/dist/smart-dom-reader.d.ts +2 -8
  132. package/dist/testing.d.cts +0 -2
  133. package/dist/testing.d.ts +0 -2
  134. package/dist/theme-editor-preview.cjs +42 -42
  135. package/dist/theme-editor-preview.d.cts +1 -1
  136. package/dist/theme-editor-preview.d.ts +1 -1
  137. package/dist/theme-editor-preview.js +25 -25
  138. package/dist/theme-editor.cjs +25 -5
  139. package/dist/theme-editor.d.cts +2 -22
  140. package/dist/theme-editor.d.ts +2 -22
  141. package/dist/theme-editor.js +1 -1
  142. package/dist/theme-reference.cjs +1 -1
  143. package/dist/theme-reference.d.cts +4 -4
  144. package/dist/theme-reference.d.ts +4 -4
  145. package/dist/theme-reference.js +1 -1
  146. package/dist/{tool-loading-animation-un3kA5Ur.d.ts → tool-loading-animation-D2cyFvmM.d.cts} +1 -7
  147. package/dist/{tool-loading-animation-un3kA5Ur.d.cts → tool-loading-animation-D2cyFvmM.d.ts} +1 -7
  148. package/dist/{tooltip-BkW-8MnD.d.cts → tooltip-DbXkAuJL.d.cts} +0 -2
  149. package/dist/{tooltip-BkW-8MnD.d.ts → tooltip-DbXkAuJL.d.ts} +0 -2
  150. package/dist/{turn-activity-ui-BGNhtMcH.d.cts → turn-activity-ui-Do1Nd-Ow.d.cts} +2 -12
  151. package/dist/{turn-activity-ui-BGNhtMcH.d.ts → turn-activity-ui-Do1Nd-Ow.d.ts} +2 -12
  152. package/dist/turn-activity-ui.d.cts +1 -1
  153. package/dist/turn-activity-ui.d.ts +1 -1
  154. package/dist/{types-BOZHQIk0.d.cts → types-BC7MRxO5.d.cts} +167 -36
  155. package/dist/{types-BOZHQIk0.d.ts → types-BC7MRxO5.d.ts} +167 -36
  156. package/dist/ui-extras.js +3 -3
  157. package/dist/voice-client-tools.d.cts +1 -3
  158. package/dist/voice-client-tools.d.ts +1 -3
  159. package/dist/voice-runtime.cjs +1 -1
  160. package/dist/voice-runtime.d.cts +2 -12
  161. package/dist/voice-runtime.d.ts +2 -12
  162. package/dist/voice-runtime.js +2 -2
  163. package/dist/voice-worklet-player.d.cts +2 -6
  164. package/dist/voice-worklet-player.d.ts +2 -6
  165. package/dist/{webmcp-runtime-entry-DuAG1_yF.d.ts → webmcp-runtime-entry-B8g46vS0.d.cts} +1 -5
  166. package/dist/{webmcp-runtime-entry-DuAG1_yF.d.cts → webmcp-runtime-entry-B8g46vS0.d.ts} +1 -5
  167. package/dist/webmcp-runtime.d.cts +1 -1
  168. package/dist/webmcp-runtime.d.ts +1 -1
  169. package/dist/widget.css +1 -1
  170. package/package.json +4 -4
  171. package/src/client-dispatch.ts +69 -16
  172. package/src/client.operator-role.test.ts +217 -0
  173. package/src/components/event-stream-view.test.ts +5 -0
  174. package/src/components/message-bubble.test.ts +169 -0
  175. package/src/components/message-bubble.ts +123 -34
  176. package/src/components/scroll-to-bottom.test.ts +135 -0
  177. package/src/components/scroll-to-bottom.ts +50 -13
  178. package/src/components/user-message-collapse.ts +117 -0
  179. package/src/defaults-parity.test.ts +14 -0
  180. package/src/defaults.ts +6 -0
  181. package/src/index-core.ts +7 -0
  182. package/src/session.resubmit-from.test.ts +27 -0
  183. package/src/session.test.ts +10 -0
  184. package/src/session.ts +8 -5
  185. package/src/styles/widget.css +79 -1
  186. package/src/theme-reference.ts +5 -3
  187. package/src/types/theme.ts +50 -0
  188. package/src/types.ts +120 -11
  189. package/src/ui.ask-user-question-plugin.test.ts +154 -0
  190. package/src/ui.operator-role.test.ts +336 -0
  191. package/src/ui.scroll-additive.test.ts +219 -117
  192. package/src/ui.scroll.test.ts +176 -13
  193. package/src/ui.ts +267 -119
  194. package/src/ui.turn-activity.test.ts +7 -7
  195. package/src/ui.user-message-collapse.test.ts +540 -0
  196. package/src/utils/__snapshots__/tokens-parity.test.ts.snap +236 -0
  197. package/src/utils/auto-follow.test.ts +0 -38
  198. package/src/utils/auto-follow.ts +0 -35
  199. package/src/utils/brand.test.ts +14 -0
  200. package/src/utils/brand.ts +8 -4
  201. package/src/utils/history-messages.test.ts +30 -0
  202. package/src/utils/history-messages.ts +26 -8
  203. package/src/utils/message-fingerprint.ts +4 -0
  204. package/src/utils/resubmit-turn.test.ts +13 -0
  205. package/src/utils/resubmit-turn.ts +12 -1
  206. package/src/utils/theme.test.ts +23 -0
  207. package/src/utils/tokens.ts +47 -0
  208. package/src/welcome.test.ts +16 -0
  209. package/src/welcome.ts +10 -2
  210. package/dist/chunk-BNE40cEG.js +0 -1
  211. package/dist/chunk-Bz9jAgba.js +0 -1
  212. package/dist/chunk-CVMIncEY.js +0 -1
  213. package/dist/chunk-CdpVP6LZ.js +0 -1
  214. package/dist/chunk-CjkechxR.js +0 -1
  215. package/dist/chunk-DgZZqy14.js +0 -1
@@ -1,6 +1,5 @@
1
- import { Ct as AgentWidgetMessage, k as AgentWidgetConfig } from "./types-BOZHQIk0.js";
2
- import { t as AgentWidgetSession } from "./session-Baxp9iRK.js";
3
- //#region src/components/forms.d.ts
1
+ import { Ct as AgentWidgetMessage, k as AgentWidgetConfig } from "./types-BC7MRxO5.js";
2
+ import { t as AgentWidgetSession } from "./session-CtZHe7fc.js";
4
3
  export declare const formDefinitions: Record<string, {
5
4
  title: string;
6
5
  description?: string;
@@ -14,5 +13,4 @@ export declare const formDefinitions: Record<string, {
14
13
  submitLabel?: string;
15
14
  }>;
16
15
  export declare const enhanceWithForms: (bubble: HTMLElement, message: AgentWidgetMessage, config: AgentWidgetConfig, session: AgentWidgetSession) => void;
17
- //#endregion
18
16
  export {}
@@ -1,20 +1,13 @@
1
- import { Aa as HistoryOperationContext, Na as HistoryProvider, ct as AgentWidgetHistoryListAction, ii as HistoryIdentityStatus, lt as AgentWidgetHistoryRenderActions, ni as HistoryConversationSummary, ot as AgentWidgetHistoryCopy } from "./types-BOZHQIk0.cjs";
2
- import { n as TooltipOptions, t as TooltipHandle } from "./tooltip-BkW-8MnD.cjs";
3
- //#region src/components/history-view/copy.d.ts
1
+ import { Fa as HistoryOperationContext, Ra as HistoryProvider, ct as AgentWidgetHistoryListAction, li as HistoryIdentityStatus, lt as AgentWidgetHistoryRenderActions, ot as AgentWidgetHistoryCopy, si as HistoryConversationSummary } from "./types-BC7MRxO5.cjs";
2
+ import { n as TooltipOptions, t as TooltipHandle } from "./tooltip-DbXkAuJL.cjs";
4
3
  type HistoryViewCopyInput = AgentWidgetHistoryCopy;
5
4
  type ResolvedHistoryViewCopy = Required<AgentWidgetHistoryCopy>;
6
5
  declare const HISTORY_VIEW_COPY_DEFAULTS: ResolvedHistoryViewCopy;
7
6
  /** Idempotent: safe to call on an already-resolved copy object. */
8
7
  declare function resolveHistoryViewCopy(copy: HistoryViewCopyInput | undefined): ResolvedHistoryViewCopy;
9
- //#endregion
10
- //#region src/components/history-view/grouping.d.ts
11
8
  /** `features.history.grouping`. Starred rows keep their pinned group in both. */
12
9
  type HistoryGroupingMode = "time" | "none";
13
- //#endregion
14
- //#region src/components/history-view/rows.d.ts
15
10
  type RowPending = "opening" | "deleting" | null;
16
- //#endregion
17
- //#region src/components/history-view/state.d.ts
18
11
  type HistoryListErrorReason = "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
19
12
  type HistoryListState = {
20
13
  kind: "loading";
@@ -33,8 +26,6 @@ type HistoryListState = {
33
26
  } | {
34
27
  kind: "new_conversation_required";
35
28
  };
36
- //#endregion
37
- //#region src/components/history-view.d.ts
38
29
  type HistoryViewPresentation = "panel" | "rail";
39
30
  /**
40
31
  * Where the top bar's contents live. `"external"` hands them to the shell,
@@ -296,8 +287,6 @@ interface HistoryViewHandle {
296
287
  destroy(): void;
297
288
  }
298
289
  declare function createHistoryView(options: HistoryViewOptions): HistoryViewHandle;
299
- //#endregion
300
- //#region src/components/history-confirm-dialog.d.ts
301
290
  /**
302
291
  * Shell-owned destructive confirmation for history actions
303
292
  * (`docs/visitor-history-implementation-plan.md` D7, accessibility contract).
@@ -317,6 +306,5 @@ interface HistoryConfirmOptions {
317
306
  }
318
307
  /** Resolves `true` only for the confirming action. */
319
308
  declare function showHistoryConfirm(options: HistoryConfirmOptions): Promise<boolean>;
320
- //#endregion
321
309
  export { HistoryViewPresentation as a, HistoryListState as c, ResolvedHistoryViewCopy as d, resolveHistoryViewCopy as f, HistoryViewPendingAction as i, HISTORY_VIEW_COPY_DEFAULTS as l, HistoryViewHandle as n, createHistoryView as o, HistoryViewOptions as r, HistoryListErrorReason as s, showHistoryConfirm as t, HistoryViewCopyInput as u };
322
310
  export {}
@@ -1,20 +1,13 @@
1
- import { Aa as HistoryOperationContext, Na as HistoryProvider, ct as AgentWidgetHistoryListAction, ii as HistoryIdentityStatus, lt as AgentWidgetHistoryRenderActions, ni as HistoryConversationSummary, ot as AgentWidgetHistoryCopy } from "./types-BOZHQIk0.js";
2
- import { n as TooltipOptions, t as TooltipHandle } from "./tooltip-BkW-8MnD.js";
3
- //#region src/components/history-view/copy.d.ts
1
+ import { Fa as HistoryOperationContext, Ra as HistoryProvider, ct as AgentWidgetHistoryListAction, li as HistoryIdentityStatus, lt as AgentWidgetHistoryRenderActions, ot as AgentWidgetHistoryCopy, si as HistoryConversationSummary } from "./types-BC7MRxO5.js";
2
+ import { n as TooltipOptions, t as TooltipHandle } from "./tooltip-DbXkAuJL.js";
4
3
  type HistoryViewCopyInput = AgentWidgetHistoryCopy;
5
4
  type ResolvedHistoryViewCopy = Required<AgentWidgetHistoryCopy>;
6
5
  declare const HISTORY_VIEW_COPY_DEFAULTS: ResolvedHistoryViewCopy;
7
6
  /** Idempotent: safe to call on an already-resolved copy object. */
8
7
  declare function resolveHistoryViewCopy(copy: HistoryViewCopyInput | undefined): ResolvedHistoryViewCopy;
9
- //#endregion
10
- //#region src/components/history-view/grouping.d.ts
11
8
  /** `features.history.grouping`. Starred rows keep their pinned group in both. */
12
9
  type HistoryGroupingMode = "time" | "none";
13
- //#endregion
14
- //#region src/components/history-view/rows.d.ts
15
10
  type RowPending = "opening" | "deleting" | null;
16
- //#endregion
17
- //#region src/components/history-view/state.d.ts
18
11
  type HistoryListErrorReason = "unavailable" | "authentication_failed" | "authentication_required" | "identity_provider_failed" | "proof_not_admitted" | "unsupported_scope" | "unknown";
19
12
  type HistoryListState = {
20
13
  kind: "loading";
@@ -33,8 +26,6 @@ type HistoryListState = {
33
26
  } | {
34
27
  kind: "new_conversation_required";
35
28
  };
36
- //#endregion
37
- //#region src/components/history-view.d.ts
38
29
  type HistoryViewPresentation = "panel" | "rail";
39
30
  /**
40
31
  * Where the top bar's contents live. `"external"` hands them to the shell,
@@ -296,8 +287,6 @@ interface HistoryViewHandle {
296
287
  destroy(): void;
297
288
  }
298
289
  declare function createHistoryView(options: HistoryViewOptions): HistoryViewHandle;
299
- //#endregion
300
- //#region src/components/history-confirm-dialog.d.ts
301
290
  /**
302
291
  * Shell-owned destructive confirmation for history actions
303
292
  * (`docs/visitor-history-implementation-plan.md` D7, accessibility contract).
@@ -317,6 +306,5 @@ interface HistoryConfirmOptions {
317
306
  }
318
307
  /** Resolves `true` only for the confirming action. */
319
308
  declare function showHistoryConfirm(options: HistoryConfirmOptions): Promise<boolean>;
320
- //#endregion
321
309
  export { HistoryViewPresentation as a, HistoryListState as c, ResolvedHistoryViewCopy as d, resolveHistoryViewCopy as f, HistoryViewPendingAction as i, HISTORY_VIEW_COPY_DEFAULTS as l, HistoryViewHandle as n, createHistoryView as o, HistoryViewOptions as r, HistoryListErrorReason as s, showHistoryConfirm as t, HistoryViewCopyInput as u };
322
310
  export {}
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>e?.layout?.embedded===!0&&e.launcher?.enabled===!1&&!e.launcher.sidebarMode&&(e.launcher.mountMode??`floating`)===`floating`,t=t=>t?.layout?.showHeader??!e(t),n=/* @__PURE__ */ `viewTitle.openHistoryLabel.openHistoryBusyLabel.newConversationLabel.expandLabel.collapseLabel.resizeLabel.showEarlierMessagesLabel.openConversationLoadingLabel.openConversationErrorTitle.openConversationRetryLabel.openConversationBackLabel.confirmCancelLabel.deleteConversationConfirmTitle.deleteConversationConfirm.deleteConversationConfirmLabel.clearHistoryConfirmTitle.clearHistoryConfirm.clearHistoryVerifiedConfirm.clearHistoryConfirmLabel.resetIdentityConfirmTitle.resetIdentityConfirm.resetIdentityConfirmLabel.conversationDeletedNotice.identityResetNotice.identityResetUnconfirmedNotice`.split(`.`),r={viewTitle:`Messages`,openHistoryLabel:`Messages`,openHistoryBusyLabel:`Messages, available once the reply finishes`,newConversationLabel:`New conversation`,expandLabel:`Expand conversation list`,collapseLabel:`Collapse conversation list`,resizeLabel:`Resize conversation list`,showEarlierMessagesLabel:`Show earlier messages`,openConversationLoadingLabel:`Loading conversation`,openConversationErrorTitle:`Could not open the conversation.`,openConversationRetryLabel:`Try again`,openConversationBackLabel:`Back to messages`,confirmCancelLabel:`Cancel`,deleteConversationConfirmTitle:`Delete conversation`,deleteConversationConfirm:`Delete this conversation? This cannot be undone.`,deleteConversationConfirmLabel:`Delete`,clearHistoryConfirmTitle:`Delete all conversations`,clearHistoryConfirm:`Delete all conversations for this assistant on this browser? This cannot be undone.`,clearHistoryVerifiedConfirm:`Delete all conversations for this assistant and signed-in user? This cannot be undone.`,clearHistoryConfirmLabel:`Delete all`,resetIdentityConfirmTitle:`Forget this device`,resetIdentityConfirm:`Forget this device? All Persona data stored in this browser is cleared. Records are not deleted elsewhere.`,resetIdentityConfirmLabel:`Forget this device`,conversationDeletedNotice:`That conversation was deleted. You are now in a new conversation.`,identityResetNotice:`This device was forgotten.`,identityResetUnconfirmedNotice:`This device was cleared here, but the server could not confirm it.`};function i(e){if(!e)return r;let t={...r};for(let r of n){let n=e[r];typeof n==`string`&&n.length>0&&(t[r]=n)}return t}const a=(e,t)=>{console.warn(`[persona] ${e} threw`,t)},o=e=>Object.freeze({...e}),s=e=>Object.freeze({id:e.id,title:e.title,targetId:e.targetId,preview:e.preview,messageCount:e.messageCount,createdAt:e.createdAt,updatedAt:e.updatedAt}),c=e=>e?o(e):null;function l(e){let{plugins:t,config:n}=e,r=!1,i=!1,l=!1,u=!1,d=null,f=[],p=()=>{for(let e of f.splice(0))try{e()}catch(e){a(`renderHistoryView cleanup`,e)}},m=(e,n)=>{for(let r of t){let t=r[e];if(t)try{let e=t(n);if(e)return e}catch(t){a(e,t)}}return null},h=()=>({presentation:e.getPresentation(),config:n}),g={header:t=>u?m(`renderHistoryHeader`,Object.freeze({...h(),returnSurface:e.getReturnSurface(),identityStatus:o(t.identityStatus),pendingAction:c(t.pendingAction),copy:o(t.copy),actions:Object.freeze({close:y.close,startNewConversation:y.startNewConversation}),defaultRenderer:t.defaultRenderer})):null,conversation:e=>u?m(`renderHistoryConversation`,Object.freeze({...h(),conversation:s(e.conversation),active:e.active,pending:e.pending,open:e.open,requestDelete:e.requestDelete,defaultRenderer:e.defaultRenderer})):null,state:e=>u?m(`renderHistoryState`,Object.freeze({...h(),state:o(e.state),identityStatus:o(e.identityStatus),copy:o(e.copy),...e.retry?{retry:e.retry}:{},...e.startNewConversation?{startNewConversation:e.startNewConversation}:{},defaultRenderer:e.defaultRenderer})):null},_=t.flatMap(t=>(t.railSections??[]).map(t=>({...t,placement:t.placement??`above-conversations`,items:[],render:n=>t.render(Object.freeze({collapsed:n,presentation:e.getPresentation(),actions:y}))}))),v=e.createView({slots:g,renderDom:!1,onModelChange:()=>C(),railSections:_}),y=Object.freeze({...v.operations,close:e.close}),b=()=>(u=!0,v.setDomRenderEnabled(!0),v.element),x=t=>Object.freeze({conversations:Object.freeze(t.conversations.map(s)),activeConversationId:t.activeConversationId,state:o(t.state),pendingAction:c(t.pendingAction),identityStatus:o(t.identityStatus),nextCursor:t.nextCursor,presentation:e.getPresentation(),returnSurface:e.getReturnSurface(),config:n,copy:o(v.copy),actions:y,defaultRenderer:b,requestRender:()=>C(),onCleanup:e=>{f.push(e)}}),S=()=>{u=!1;let e=null;for(let n of t)if(n.renderHistoryView){try{e=n.renderHistoryView(x(v.getModel()))}catch(t){a(`renderHistoryView`,t),e=null}if(e)break}let n=!e||e.contains(v.element);return u=n,v.setDomRenderEnabled(n),e??v.element};function C(){if(!(!l||r||i)){i=!0;try{p();let t=S();if(t===d)return;let n=d;d=t,e.onElementChanged(t,n)}finally{i=!1}}}return l=!0,C(),{view:v,get element(){return d??v.element},requestRender:C,dispose:()=>{r=!0,p()}}}const u=(e,t)=>{let n=document.createElement(e);return t&&(n.className=t),n},d=(e,t={},...n)=>{let r=document.createElement(e);if(t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text),t.attrs)for(let[e,n]of Object.entries(t.attrs))r.setAttribute(e,n);if(t.style){let e=r.style,n=t.style;for(let t of Object.keys(n)){let r=n[t];r!=null&&(e[t]=r)}}let i=n.filter(e=>e!=null);return i.length>0&&r.append(...i),r},f=(...e)=>e.filter(Boolean).join(` `);function p(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function m(e){return typeof e!=`string`&&e.some(e=>e.type===`image`)}function h(e){return{type:`text`,text:e}}function g(e,t){return{type:`image`,image:e,...t?.mimeType&&{mimeType:t.mimeType},...t?.alt&&{alt:t.alt}}}const _=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`],v=[`application/pdf`,`text/plain`,`text/markdown`,`text/csv`,`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-excel`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/json`];[..._,...v];function y(e,t,n){return{type:`file`,data:e,mimeType:t,filename:n}}const b=[`user`,`assistant`,`system`];function x(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function S(e){return typeof e==`string`?e:void 0}function C(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`text`:return typeof t.text==`string`?h(t.text):null;case`image`:return typeof t.image==`string`?g(t.image,{mimeType:S(t.mimeType),alt:S(t.alt)}):null;case`file`:return typeof t.data==`string`&&typeof t.mimeType==`string`&&typeof t.filename==`string`?y(t.data,t.mimeType,t.filename):null;case`audio`:return typeof t.audio==`string`?{type:`audio`,audio:t.audio,...S(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;case`video`:return typeof t.video==`string`?{type:`video`,video:t.video,...S(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;default:return null}}function ee(e,t){let n=x(t),r=e.map(e=>x(e.timestamp)),i=Array(e.length),a=0;for(;a<r.length;){let e=r[a];if(e!==null){i[a]=e,a+=1;continue}let t=a;for(;t+1<r.length&&r[t+1]===null;)t+=1;let o=t-a+1,s=a>0?i[a-1]:null,c=t+1<r.length?r[t+1]:null,l=c!==null&&n!==null?Math.min(c,n):c??n;for(let e=0;e<o;e+=1)i[a+e]=l===null?s===null?0+e:s+e+1:l-(o-e);a=t+1}return i.map(e=>new Date(e).toISOString())}function w(e,t){let n=ee(e,t?.beforeCreatedAt),r=[];return e.forEach((e,t)=>{if(typeof e?.id!=`string`||e.id===``||!b.includes(e.role))return;let i=e.role,a=n[t];if(e.displayAvailable===!1)r.push({id:e.id,role:i,content:``,createdAt:a,agentMetadata:{historyDisplayUnavailable:!0}});else if(typeof e.displayContent==`string`)r.push({id:e.id,role:i,content:e.displayContent,createdAt:a});else if(typeof e.content==`string`)r.push({id:e.id,role:i,content:e.content,createdAt:a});else if(Array.isArray(e.content)){let t=e.content.map(C).filter(e=>e!==null),n=p(t);r.push({id:e.id,role:i,content:n||(m(t)?`[Image]`:``),createdAt:a,...t.length>0&&{contentParts:t}})}else r.push({id:e.id,role:i,content:``,createdAt:a})}),r}function te(e,t){let n=/* @__PURE__ */ new Map;for(let t of e)n.set(t.id,t);for(let e of t)n.set(e.id,e);return[...n.values()].sort((e,t)=>{let n=new Date(e.createdAt).getTime(),r=new Date(t.createdAt).getTime();if(!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r)return n-r;let i=e.sequence??0,a=t.sequence??0;return i===a?e.id.localeCompare(t.id):i-a})}const ne=/* @__PURE__ */ new Map([[`not_found`,`not_found`],[`conversation_deleted`,`not_found`],[`rate_limited`,`rate_limited`],[`authentication_required`,`authentication_required`],[`invalid_identity_proof`,`authentication_required`],[`visitor_identity_mismatch`,`authentication_required`],[`visitor_required`,`authentication_required`],[`identity_provider_failed`,`identity_provider_failed`],[`proof_not_admitted`,`proof_not_admitted`],[`identity_contract_violation`,`proof_not_admitted`],[`unauthorized`,`authentication_failed`],[`visitor_token_missing`,`authentication_failed`],[`conversation_credential_missing`,`authentication_failed`]]),re=/* @__PURE__ */ new Map([[`not_found`,`That conversation is no longer available.`],[`rate_limited`,`Too many history requests.`],[`authentication_failed`,`History access was not authorized.`],[`authentication_required`,`Sign in again to view account history.`],[`identity_provider_failed`,`The identity provider did not respond.`],[`proof_not_admitted`,`Account history is not available for this configuration.`],[`unsupported_scope`,`This history scope is not supported.`],[`unavailable`,`Conversation history is unavailable right now.`]]),T=e=>re.get(e)??`Conversation history is unavailable right now.`;function ie(e,{HistoryClientError:t,HistoryProviderError:n}){if(e instanceof n)return e;if(e instanceof t){let t=ne.get(e.code)??`unavailable`;return new n(t,T(t),{...e.retryAfterSeconds===void 0?{}:{retryAfterSeconds:e.retryAfterSeconds}})}return new n(`unavailable`,T(`unavailable`))}function ae(e){let{HistoryProviderError:t}=e.errors,n=()=>e.getClient?.()??e.client,r=e.getIdentityProofConfigured()?[`browser`,`verified-user`]:[`browser`],i={scopes:r},a=e=>{if(!r.includes(e))throw new t(`unsupported_scope`,T(`unsupported_scope`))},o=async(t,n)=>{a(t);try{return await n()}catch(t){throw ie(t,e.errors)}},s=t=>{let n=!1;return{conversationId:t.session.conversationId??``,conversationRevision:t.session.conversationRevision??``,async commit(){n||(n=!0,t.commit(),await e.onActivationCommitted(t.session))},discard(){n||(n=!0,t.discard())}}};return{capabilities:i,getIdentityStatus(){return n().getHistoryIdentityStatus()},subscribeIdentityStatus(e){return n().subscribeHistoryIdentityStatus(e)},subscribeAvailability(e){return n().subscribeHistoryAvailability(e)},async list(e){return o(e.context.scope,async()=>{let t=await n().listConversations({...e.cursor?{cursor:e.cursor}:{},...e.limit===void 0?{}:{limit:e.limit},...e.targetId?{targetId:e.targetId}:{},scope:e.context.scope});return{items:t.data,nextCursor:t.nextCursor}})},async getPage(e,t){return o(t.context.scope,async()=>{let r=await n().getConversation(e,{...t.cursor?{messageCursor:t.cursor}:{},scope:t.context.scope}),i=w(r.messages,{...t.beforeCreatedAt?{beforeCreatedAt:t.beforeCreatedAt}:{}});return{summary:r.summary,messages:te([],i),conversationRevision:r.conversationRevision??``,nextCursor:r.nextMessageCursor}})},async prepareOpen(e,t){return o(t.context.scope,async()=>s(await n().prepareConversationSession(e)))},async prepareStartNew(e){return o(e.context.scope,async()=>s(await n().prepareNewConversationSession()))},async delete(e,t){await o(t.context.scope,()=>n().deleteConversation(e,{scope:t.context.scope}))},async deleteAll(e){return o(e.context.scope,()=>n().deleteAllConversations({...e.targetId===void 0?{}:{targetId:e.targetId},scope:e.context.scope}))},async resetDevice(){try{return await n().resetVisitor(),{remoteRevocationConfirmed:!0}}catch{return{remoteRevocationConfirmed:!1}}}}}const oe=e=>{let n=i(e.config.features?.history?.copy),r=null,a=!1,o=null,s=null,c=`conversation`,p=null,m=null,h=null,g=null,_=0,v=null,y=null,b=null,x=`persona-history-${Math.random().toString(36).slice(2,8)}`,S=()=>e.historyFeatureEnabled()&&!!r&&!a,C=()=>{let t=e.session.getStatus();return e.isStreaming||t===`paused`||t===`resuming`},ee=()=>{let t=e.config.features?.history?.scope;if(t)return t;let n=e.config.getIdentityProof?`verified-user`:`browser`,i=r?.capabilities.scopes;return!i||i.includes(n)?n:i[0]??n},w=()=>s?.scope??ee(),te=()=>e.session.getClientSession()?.targetId??null,ne=e=>`${e.state}:${`reason`in e?e.reason:``}`,re=t=>{let n=ne(t);n!==g&&(g=n,e.eventBus.emit(`history:identityStatusChanged`,{status:t,timestamp:Date.now()}))},T=null,ie=null,oe=()=>{if(!e.historyFeatureEnabled())return null;let t=e.getHistoryProviderFactory();if(t)return t();let n=e.config.features?.history?.provider;return n?typeof n==`function`?(T!==n&&(T=n,ie=n()),ie):n:e.session.isClientTokenMode()?ae({errors:e.historyErrors,client:e.session.getClient(),getIdentityProofConfigured:()=>typeof e.config.getIdentityProof==`function`,onActivationCommitted:t=>e.session.bindActivatedSession(t),getClient:()=>e.session.getClient()}):null},se=()=>{y?.(),y=null,b?.(),b=null,a=!1;let t=r;r=oe(),t&&t!==r&&e.discardConversationContinuity();let n={...e.historyInternals};r?n.historyProvider=r:delete n.historyProvider,e.historyInternals=n,e.session.setHistoryInternals(e.historyInternals),r&&(y=r.subscribeAvailability?.(e=>{a=!e,e||q({restoreFocus:!1}),$()})??null,b=r.subscribeIdentityStatus(e=>re(e)),g=ne(r.getIdentityStatus()))},ce=()=>{let t=e.config.features?.history?.presentation??`panel`;if(t===`panel`||t===`auto`&&e.launcherEnabled&&!e.isDockedMountMode(e.config))return`panel`;let n=e.artifactSplitRoot??e.container;return(n.getBoundingClientRect().width||n.clientWidth)>=720?`rail`:`panel`},E=(e,t)=>{t?(e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``)):(e.removeAttribute(`aria-hidden`),e.removeAttribute(`inert`))},le=`data-persona-history-suppressed`,D=null,O=null,k=null,ue=null,de=null,fe=``,pe=()=>e.header===de?fe:t(e.config)?``:`none`,me=()=>e.historyPresentation===`panel`&&!!k&&ue===k.element&&t(e.config)&&pe()!==`none`,he=()=>{for(let t of Array.from(e.header.children))t!==D&&t.setAttribute(le,``)},ge=()=>{for(let t of Array.from(e.container.querySelectorAll(`[${le}]`)))t.removeAttribute(le)},_e=()=>{let t=k;if(!t)return;if(Array.from(e.header.children).some(e=>e!==D&&!e.hasAttribute(le))){O&&O!==e.header&&(O.style.removeProperty(`min-height`),O=null);let t=e.header.offsetHeight;t>0&&(e.header.style.minHeight=`${t}px`,O=e.header)}D||=u(`div`,`persona-history-header-host`),t.setHeaderPlacement(`external`);let n=t.getHeaderElement();n.parentNode!==D&&D.replaceChildren(n),D.parentNode!==e.header&&e.header.appendChild(D),he()},ve=()=>{O&&=(O.style.removeProperty(`min-height`),null),D&&(k?.setHeaderPlacement(`inline`),D.remove(),D=null,ge())},ye=null,be=()=>{ye&&(e.body.style.display=`none`,E(e.body,!0),e.footer.hidden=!0,E(e.footer,!0),e.panelSuggestions.style.display=`none`,E(e.panelSuggestions,!0),e.panelSuggestionsFade.style.display=`none`,me()?(_e(),e.header.style.display=pe(),E(e.header,!1)):(ve(),e.header.style.display=`none`,E(e.header,!0)))};e.reapplyHistoryHostChrome=be;let xe=n=>{let r=e.body.style.display,i=e.footer.hidden,a=e.panelSuggestions.style.display,o=e.panelSuggestionsFade.style.display,s=e.footer,c=e.header,l=e.header.style.display;de=c,fe=l,ye=()=>{ye=null,ve(),de=null,e.body.style.display=r,E(e.body,!1),e.panelSuggestions.style.display=a,E(e.panelSuggestions,!1),e.panelSuggestionsFade.style.display=o,s.hidden=i,E(s,!1),e.footer!==s&&(e.footer.hidden=!1,E(e.footer,!1)),c.style.display=l,E(c,!1),e.header!==c&&(e.header.style.display=t(e.config)?``:`none`,E(e.header,!1))},e.container.insertBefore(n,e.footer.parentNode===e.container?e.footer:e.panelSuggestions),be()},A=null,j=null,Se=null,M=null,Ce=()=>[e.header,e.panelElements.closeButtonWrapper,e.panelElements.clearChatButtonWrapper,e.body,e.footer,e.scrollToBottomButton],we=()=>e.config.features?.history?.rail?.collapsible!==!1,N=()=>e.config.features?.history?.rail?.side===`right`?`right`:`left`,Te=e=>Math.min(400,Math.max(200,Math.round(e))),Ee=()=>e.config.features?.history?.rail?.resizable===!0,P,De=()=>{if(P===void 0&&(P=null,e.config.persistState!==!1))try{let t=Number(window.localStorage.getItem(`${e.currentKeyPrefix()}rail-width`));t&&(P=t)}catch{}return P},F=()=>Te(De()??e.config.features?.history?.rail?.width??260),Oe=t=>{if(P=t,e.config.persistState!==!1)try{window.localStorage.setItem(`${e.currentKeyPrefix()}rail-width`,String(t))}catch{}},ke=()=>we()&&e.config.features?.history?.rail?.collapsedBehavior===`overlay`,I=!1,Ae=e=>{let t=u(`img`);return t.src=e,t.alt=``,t.setAttribute(`aria-hidden`,`true`),t},je=()=>{let t=e.config.features?.history?.rail?.brand;if(!t)return;let n=!1,r;return i=>{if(t.render)try{return t.render({collapsed:i})??null}catch(e){return n||(n=!0,console.warn(`[persona] history rail brand threw`,e)),null}return r===void 0&&(r=t.iconUrl?Ae(t.iconUrl):t.icon?e.renderLucideIcon(t.icon,20):null),r?r.cloneNode(!0):null}},Me=()=>e.config.features?.history?.rail?.sections?.map(t=>{let n=!1,r=e=>{n||(n=!0,console.warn(`[persona] history rail section threw`,t.id,e))};return{id:t.id,title:t.title,placement:t.placement??`above-conversations`,items:t.items.map(t=>{let n;return{id:t.id,label:t.label,badge:t.badge,iconNode:()=>{if(n!==void 0)return n;try{n=t.renderIcon?t.renderIcon()??null:t.iconUrl?Ae(t.iconUrl):t.icon?e.renderLucideIcon(t.icon,20):null}catch(e){r(e),n=null}return n},onSelect:()=>{try{t.onSelect()}catch(e){r(e)}}}})}})??[],Ne=e=>{let t=Me();for(let n of e)t.some(e=>e.id===n.id)?console.warn(`[persona] duplicate history rail section id`,n.id):t.push(n);return t.length?t:void 0},L=null,Pe=()=>`${e.currentKeyPrefix()}rail-collapsed`,Fe=()=>{if(L===null&&(L=e.config.features?.history?.rail?.defaultCollapsed===!0,e.config.persistState!==!1))try{let e=window.localStorage.getItem(Pe());e&&(L=e===`1`)}catch{}return L},Ie=t=>{if(L=t,e.config.persistState!==!1)try{window.localStorage.setItem(Pe(),t?`1`:`0`)}catch{}},R=()=>e.historyPresentation===`rail`&&we()&&!ke()&&Fe(),Le=()=>{},Re=()=>{ke()?Le():(Ie(!Fe()),o?.view.setCollapsed(R()),e.applyRailChrome(),e.repinAnchoredMessage())},ze=()=>{let t=e.config.features?.history?.rail?.collapseShortcut;return!t||!e.parseCombo(t)?null:{combo:t,hint:e.formatCombo(t),aria:e.ariaCombo(t)}},Be=`var(--persona-history-overlay-margin,8px)`,z=null,B=null,Ve=0,V=null,H=null,U=!1,He=0,Ue=()=>window.matchMedia?.(`(pointer: coarse)`).matches===!0,W=()=>S()&&ke()&&(e.historyPresentation??ce())===`rail`,We=()=>e.historyVisible&&!I,G=()=>{H!==null&&clearTimeout(H),H=null},Ge=()=>{e.loadHistoryView().catch(()=>{})},Ke=()=>{G(),I&&(H=setTimeout(()=>{H=null,!U&&I&&(V?.contains(document.activeElement)||q({restoreFocus:!1}))},300))},qe=(e,t)=>{let n=V?.getBoundingClientRect();if(!n)return!1;let r=z?.getBoundingClientRect(),i=r?Math.min(r.top,n.top):n.top;return e>=n.left&&e<=n.right&&t>=i&&t<=n.bottom||!!r&&e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},Je=e=>{I&&(U=qe(e.clientX,e.clientY),U?G():H===null&&Ke())},Ye=t=>{!e.historyVisible&&W()&&(I=!0,gt({invoker:z,keyboard:t?.keyboard===!0}).then(()=>{e.historyVisible?!U&&document.activeElement!==z&&q():I=!1}))},Xe=()=>{let e=ue?.querySelector(`[data-persona-history-focus="collapse"]`);e&&(e.setAttribute(`aria-label`,I?n.expandLabel:n.collapseLabel),e.setAttribute(`aria-expanded`,I?`false`:`true`))},Ze=()=>{Ie(!1);let t=o;if(!I||!t){gt({invoker:z});return}let n=document.activeElement===z;I=!1,ut(),t.element.remove(),ft(t.element),Xe(),n&&ht(),e.repinAnchoredMessage(),$()},Qe=()=>{Ie(!0),q()};Le=()=>{!e.historyVisible||I?Ze():Qe()};let $e=()=>{let t=ze(),r=e.createHeaderIconButton({ariaLabel:n.expandLabel,iconName:`panel-left`,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`,extraClassName:`persona-rail-trigger`,tooltip:!1,attrs:{"data-persona-rail-trigger":``,"aria-controls":x,...t?{"aria-keyshortcuts":t.aria}:{}}}),i=r.button;i.addEventListener(`mouseenter`,()=>{U=!0,G(),!(Ue()||Date.now()<He)&&Ye()}),i.addEventListener(`mouseleave`,()=>{U=!1,He=0,Ke()}),i.addEventListener(`focus`,()=>{e.historyVisible||Ge()}),i.addEventListener(`click`,t=>{S()&&(t.detail!==0&&Ue()&&!e.historyVisible?Ye():Ze())}),z=i,B=r.wrapper},et=()=>{if(B&&!B.isConnected&&(B=null,z=null),!W()){B?.remove(),B=null,z=null;return}z||$e();let t=B,r=z;if(!t||!r)return;let i=N()===`right`?null:e.header.firstChild;(i??e.header.lastChild)!==t&&e.header.insertBefore(t,i),t.style.display=We()||Ve>0?`none`:``,r.setAttribute(`aria-label`,n.expandLabel),r.setAttribute(`aria-expanded`,e.historyVisible?`true`:`false`),V&&e.applyRailChrome()},tt=e=>{if(!I)return;let t=e.target;t instanceof Node&&(V?.contains(t)||B?.contains(t)||t instanceof Element&&t.closest(`.persona-dropdown-menu,[role="alertdialog"]`)||q({restoreFocus:!1}))};document.addEventListener(`pointerdown`,tt,!0),e.destroyCallbacks.push(()=>{document.removeEventListener(`pointerdown`,tt,!0),document.removeEventListener(`pointermove`,Je),K?.(),G()});let nt=null,K=null,rt=t=>{Oe(Te(t)),e.applyRailChrome(),e.repinAnchoredMessage()},it=()=>{let t=u(`div`,`persona-rail-resizer`);return t.tabIndex=0,t.setAttribute(`role`,`separator`),t.setAttribute(`aria-orientation`,`vertical`),t.setAttribute(`aria-valuemin`,`200`),t.setAttribute(`aria-valuemax`,`400`),t.addEventListener(`pointerdown`,n=>{let r=j;if(!r||n.button!==0)return;n.preventDefault(),K?.();let i=n.clientX,a=r.getBoundingClientRect().width||F(),o=N()===`right`?-1:1,s=a,c=e.mount.ownerDocument;r.style.transition=`none`;let l=e=>{s=Te(a+o*(e.clientX-i)),r.style.flex=`0 0 ${s}px`,t.setAttribute(`aria-valuenow`,String(s))},u=()=>{K=null,c.removeEventListener(`pointermove`,l),c.removeEventListener(`pointerup`,u),c.removeEventListener(`pointercancel`,u),r.style.removeProperty(`transition`);try{t.releasePointerCapture(n.pointerId)}catch{}rt(s)};K=u,c.addEventListener(`pointermove`,l),c.addEventListener(`pointerup`,u),c.addEventListener(`pointercancel`,u);try{t.setPointerCapture(n.pointerId)}catch{}}),t.addEventListener(`keydown`,e=>{let t=N()===`right`?-16:16,n=F(),r=e.key===`ArrowRight`?n+t:e.key===`ArrowLeft`?n-t:e.key===`Home`?200:e.key===`End`?400:null;r!==null&&(e.preventDefault(),rt(r))}),t},at=(e,t)=>{if(!Ee()||R()){K?.(),nt?.remove();return}let r=nt??it();nt=r,r.setAttribute(`aria-label`,n.resizeLabel),r.setAttribute(`aria-valuenow`,String(F())),r.nextElementSibling!==t&&e.insertBefore(r,t)};e.applyRailChrome=()=>{o?.view.setRailSide(N());let t=N()===`right`,n=V;if(n){let r=z?z.getBoundingClientRect().bottom-e.container.getBoundingClientRect().top:0;n.style.top=`calc(${Math.max(0,Math.round(r))}px + ${Be})`,n.style.width=`${F()}px`,n.style.left=t?``:Be,n.style.right=t?Be:``}let r=j,i=A,a=Se;if(!r||!i||!a)return;r.style.flex=`0 0 ${R()?52:F()}px`;let s=`1px solid var(--persona-divider,#e5e7eb)`;r.style.borderRight=t?``:s,r.style.borderLeft=t?s:``;let c=t?a:r;i.firstElementChild!==c&&i.append(c,t?r:a),at(i,t?r:a)};let ot=t=>{if(M&&j){M.replaceWith(t),M=null,e.applyRailChrome();return}let n=u(`div`,`persona-history-rail-shell`);n.style.cssText=`display:flex;flex-direction:row;flex:1 1 auto;min-height:0`;let r=u(`div`,`persona-history-rail-conversation`);r.style.cssText=`display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0;position:relative`;let i=u(`div`,`persona-history-rail-host`);i.style.cssText=`display:flex;min-height:0;overflow:hidden`,e.container.insertBefore(n,e.header.parentNode===e.container?e.header:e.body);for(let t of Ce())t?.parentNode===e.container&&r.appendChild(t);n.append(i,r),i.appendChild(t),A=n,j=i,Se=r,e.applyRailChrome()},st=()=>{if(A)return;let t=u(`div`,`persona-history-rail-placeholder`);t.style.cssText=`flex:1 1 auto;min-height:0`,M=t,ot(t),e.repinAnchoredMessage()},ct=()=>{M&&(ut(),e.repinAnchoredMessage())},lt=t=>{let n=u(`div`,`persona-history-rail-overlay`);n.style.cssText=`position:absolute;bottom:${Be};display:flex;overflow:hidden;z-index:100000;border-radius:var(--persona-history-overlay-radius,16px);background:var(--persona-history-overlay-bg,var(--persona-container,#f7f7f8));box-shadow:var(--persona-history-overlay-shadow,0 12px 40px rgba(0,0,0,0.25))`,e.container.style.position=`relative`,e.container.appendChild(n),n.appendChild(t),document.addEventListener(`pointermove`,Je),V=n,e.applyRailChrome(),Xe()},ut=()=>{ye?.(),V&&=(U&&(He=Date.now()+150),document.removeEventListener(`pointermove`,Je),V.remove(),null);let t=A;if(t){K?.();for(let n of Ce())if(n&&t.contains(n)){let r=n===e.scrollToBottomButton?e.panelSuggestions:t;e.container.insertBefore(n,r)}t.remove(),A=null,j=null,Se=null,M=null}},dt=e=>{ue=e,e.id=x,e.style.flex=`1 1 auto`,e.style.minHeight=`0`},ft=t=>{dt(t),(e.historyPresentation!==`rail`||I)&&ct(),e.historyPresentation===`rail`?I?lt(t):ot(t):xe(t)},pt=()=>{if(et(),Vt(),!e.historyVisible||!o)return;let t=ce();if(t===e.historyPresentation)return;let n=document.activeElement,r=n instanceof HTMLElement&&(o.element.contains(n)||D?.contains(n)===!0)?n:null;ut(),o.element.remove(),o.view.setHeaderPlacement(`inline`),e.historyPresentation=t,o.view.setPresentation(t),o.view.setCollapsed(R()),o.requestRender(),o.element.isConnected||ft(o.element),r?.isConnected?r.focus():ht(),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$()},mt=(e,t)=>D?.querySelector(t)??e.querySelector(t),ht=()=>{let e=o?.element??ue;if(!e)return;let t=mt(e,`[data-persona-history-focus="close"],[data-persona-history-focus="collapse"]`);if(t){t.focus();return}let n=mt(e,`.persona-history-title`)??e;n.tabIndex=-1,n.focus()},gt=async i=>{if(!S()||e.historyVisible)return;let a=r;if(!a)return;if(!I&&W()&&Fe()){et();return}_t();let u=++_;c=i?.returnSurface??`conversation`,p=i?.invoker??m;let d=W()&&!I;d&&(Ve+=1,et(),st());let f;try{f=await e.loadHistoryView()}catch{e.announceHistory(n.openHistoryLabel),d&&(--Ve,u===_&&(ct(),et()));return}if(d&&--Ve,u!==_||e.historyVisible)return;s={scope:ee()},e.historyPresentation=ce(),e.historyVisible=!0;let h=e.historyPresentation===`panel`&&t(e.config)&&e.header.style.display!==`none`?`external`:`inline`,g=e.config.features?.history?.rowAvatar,v=ze(),y=v?{hint:v.hint,aria:v.aria}:null,b={provider:a,context:s,targetId:te(),presentation:e.historyPresentation,collapsible:we(),collapsed:R(),railSide:N(),renderRailHeader:e.config.features?.history?.rail?.renderHeader,railBrand:je(),onToggleCollapse:Re,...y?{collapseShortcut:y}:{},headerPlacement:h,showScopeStatus:e.config.features?.history?.showScopeStatus!==!1,showDelete:e.config.features?.history?.showDelete!==!1,showDeleteAll:e.config.features?.history?.showDeleteAll!==!1,...e.config.features?.history?.listActions?.length?{listActions:e.config.features.history.listActions}:{},rowAvatar:g===!1?!1:typeof g==`string`?g:e.config.launcher?.iconUrl,activeConversationId:e.session.getActiveConversationId(),...e.config.features?.history?.grouping?{grouping:e.config.features.history.grouping}:{},...e.config.features?.history?.copy?{copy:e.config.features.history.copy}:{},...e.config.features?.history?.pageSize===void 0?{}:{pageSize:e.config.features.history.pageSize},onSelect:e=>kt(e,{focusComposer:!0}).catch(()=>{}),onActiveConversationChange:t=>e.setActiveConversationSummary(t),attachTooltip:e.attachTooltip,onStartNew:()=>At({focusComposer:!0}),onClose:()=>q(),onRequestDeleteConversation:e=>Lt(e),onRequestClearHistory:()=>Rt(),...a.resetDevice?{onRequestResetIdentity:()=>zt()}:{}};o=l({plugins:e.plugins,config:e.config,getPresentation:()=>e.historyPresentation??`panel`,getReturnSurface:()=>c,close:()=>q(),createView:({slots:t,renderDom:n,onModelChange:r,railSections:i})=>(k=f.createHistoryView({...b,railSections:Ne(i),slots:t,renderDom:n,onModelChange:r,onAnnounce:e.announceHistory}),k),onElementChanged:(e,t)=>{if(!t?.isConnected)return ft(e);dt(e),t.replaceWith(e),be()}}),o.view.setNewConversationRequired(e.historySessionState.recovery===`new_conversation_required`),i?.focus!==!1&&(e.historyPresentation!==`rail`||i?.keyboard===!0)&&ht(),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$(),e.eventBus.emit(`history:opened`,{presentation:e.historyPresentation,returnSurface:c,timestamp:Date.now()})},_t=()=>{},q=t=>{if(!e.historyVisible)return;_+=1;let n=c,r=p,i=o,a=t?.restoreFocus!==!1;e.historyVisible=!1;let l=!1,u=null,d=()=>{if(!l){if(l=!0,_t=()=>{},u!==null&&clearTimeout(u),I=!1,G(),ut(),i?.dispose(),i?.view.destroy(),i?.element.remove(),o===i&&(o=null,k=null,ue=null,e.historyPresentation=null,s=null,p=null),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$(),a){let t=r??m;t?.isConnected?t.focus():e.maybeFocusInput()}e.eventBus.emit(`history:closed`,{returnSurface:n,timestamp:Date.now()})}},f=i&&i.element===i.view.element?i.view.playExit():null;f?(_t=d,u=setTimeout(d,250),f.then(d)):d()},vt=t=>{if(t.key===`Escape`&&e.historyVisible&&o){if(e.historyPresentation===`rail`){let e=t.target;if(!(e instanceof Node)||!(o.element.contains(e)||I&&B?.contains(e)===!0))return}t.preventDefault(),t.stopPropagation(),q()}};e.container.addEventListener(`keydown`,vt),e.destroyCallbacks.push(()=>e.container.removeEventListener(`keydown`,vt));let yt=0,J=null,bt=null,Y=()=>{bt&&clearTimeout(bt),bt=null};e.destroyCallbacks.push(Y);let xt=()=>{Y();let t=e.conversationOpenPendingEl;t&&(e.conversationOpenTakeover=!0,t.hidden=!1,e.messagesWrapper.style.display=`none`,e.updateWelcome())},X=()=>{yt+=1,Y(),J?.remove(),J=null,e.conversationOpenPendingEl&&(e.conversationOpenPendingEl.remove(),e.conversationOpenPendingEl=null,e.conversationOpenTakeover=!1,e.messagesWrapper.style.removeProperty(`display`),E(e.footer,!1),e.updateWelcome())},St=()=>{try{if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches)return;e.messagesWrapper.animate([{opacity:0},{opacity:1}],{duration:150,easing:`ease-out`})}catch{}},Ct=t=>{let n=e.config.layout?.messages?.layout??`bubble`,r=d(`div`,{className:`persona-flex`,attrs:{"aria-hidden":`true`}});e.applyMessageRowLayout(r,t);let i=d(`div`,{className:f(e.getBubbleClasses(t,n).join(` `),`persona-conversation-loading-bubble`),attrs:{"data-persona-theme-zone":`${t}-message`},style:{width:t===`user`?`64%`:`100%`,backgroundColor:n===`flat`?`transparent`:`var(--persona-message-${t}-bg, var(--persona-${t===`user`?`accent`:`container`}))`,color:`var(--persona-message-${t}-text, ${t===`user`&&n!==`flat`?`white`:`var(--persona-text)`})`}},...[`94%`,...t===`assistant`?[`86%`]:[],`62%`].map(e=>d(`div`,{className:`persona-conversation-loading-line`,style:{width:e}})));return e.applyBubbleGeometry(i,t,n,{...e.resolveThemeDefaults(e.config.future).components.message[t],...e.config.theme?.components?.message?.[t],...e.config.darkTheme?.components?.message?.[t]}),r.appendChild(i),r},wt=()=>d(`div`,{className:`persona-conversation-loading-body`,style:{gap:e.messagesWrapper.style.gap}},Ct(`user`),Ct(`assistant`),Ct(`user`),Ct(`assistant`)),Tt=()=>e.config.loadingIndicator?.conversationOpenVariant===`skeleton`?wt():d(`div`,{className:`persona-conversation-loading-spinner`,attrs:{"aria-hidden":`true`}},d(`span`,{className:`persona-conversation-loading-ring`})),Et=t=>{e.conversationOpenPendingEl?.remove(),e.conversationOpenPendingEl=t,t.hidden=!e.conversationOpenTakeover,e.body.insertBefore(t,e.messagesWrapper),Y(),e.conversationOpenTakeover||(bt=setTimeout(xt,250)),E(e.footer,!0)},Dt=()=>{let t={config:e.config,streaming:!1,location:`conversation-open`,defaultRenderer:Tt},r=null,i=e.plugins.find(e=>e.renderLoadingIndicator);i?.renderLoadingIndicator&&(r=i.renderLoadingIndicator(t)),r===null&&e.config.loadingIndicator?.render&&(r=e.config.loadingIndicator.render(t));let a=r??Tt();Et(d(`div`,{className:f(`persona-conversation-loading`,a.classList.contains(`persona-conversation-loading-spinner`)&&`persona-conversation-loading--centered`),attrs:{role:`status`,"aria-label":n.openConversationLoadingLabel},style:{maxWidth:e.messagesWrapper.style.maxWidth||`none`}},a))},Ot=t=>{let r=()=>{kt(t,{focusComposer:!0}).catch(()=>{})},i=S()?()=>{X(),gt()}:void 0,a=(e,t)=>{let n=d(`button`,{className:`persona-conversation-loading-error-action`,attrs:{type:`button`},text:e});return n.addEventListener(`click`,t),n},o=()=>d(`div`,{className:`persona-conversation-loading-error-body`},d(`p`,{className:`persona-conversation-loading-error-title`,text:n.openConversationErrorTitle}),d(`div`,{className:`persona-conversation-loading-error-actions`},a(n.openConversationRetryLabel,r),i?a(n.openConversationBackLabel,i):null)),s=Object.freeze({conversationId:t,config:e.config,copy:Object.freeze({title:n.openConversationErrorTitle,retryLabel:n.openConversationRetryLabel,backLabel:n.openConversationBackLabel}),retry:r,...i?{back:i}:{},defaultRenderer:o}),c=null;for(let t of e.plugins)if(t.renderHistoryOpenError){try{c=t.renderHistoryOpenError(s)}catch(e){console.warn(`[persona] renderHistoryOpenError threw`,e),c=null}if(c)break}if(J?.remove(),J=d(`div`,{className:`persona-conversation-loading-error`,attrs:{role:`alert`}},c??o()),!e.session.getActiveConversationId()&&e.session.getMessages().length===0&&!e.composerStore.getState().text&&!e.attachmentManager?.hasAttachments()){let e=J;J=null,Et(e),xt()}else e.body.insertBefore(J,e.messagesWrapper);e.announceHistory(n.openConversationErrorTitle)};e.eventBus.on(`history:closed`,()=>{e.conversationOpenPendingEl&&E(e.footer,!0)});let kt=async(t,{focusComposer:n=!1,busy:r=`reject`}={})=>{let i=w();if(r===`background`&&(e.session.assertBackgroundSwitchable(),e.composerStore.getState().phase===`preparing`))throw new e.SessionHistoryError(`conversation_busy`,`Finish preparing this turn before switching conversations`);if(r===`reject`&&(e.session.isStreaming()||[`paused`,`resuming`].includes(e.session.getStatus())||e.composerStore.getState().phase===`preparing`))throw new e.SessionHistoryError(`conversation_busy`,`Finish or stop the current turn before switching conversations`);r===`stop`&&(++e.composerConversationGeneration,e.submissionAbort?.abort(),e.submissionAbort=null,e.composerStore.setPreparing(!1),e.session.cancel());let a=e.conversationStateKey();(!e.conversationOpenPendingEl||e.pendingConversationReading?.key!==a)&&(e.pendingConversationReading={key:a,reading:e.captureConversationReading()});let s=null,c=!!o;o?.view.setActiveConversationId(t),X();let l=yt;Dt(),e.historyVisible&&(e.historyPresentation===`panel`||I)&&q({restoreFocus:!1}),e.suppressScrollSend=!0;try{await e.session.openConversation(t,{scope:i,busy:r,onBeforeCommit:()=>{e.saveConversationContinuity(),s=e.composerConversationGeneration,e.conversationPersistenceOwner=s},onCommitted:()=>{e.restoreConversationContinuity(),e.conversationPersistenceOwner===s&&(e.conversationPersistenceOwner=null),e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),e.persistState()}})}catch(n){if(e.conversationPersistenceOwner===s&&(e.conversationPersistenceOwner=null),s===e.composerConversationGeneration&&e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),l===yt){let n=e.pendingConversationReading?.reading;X(),n&&e.restoreConversationReading(n),e.pendingConversationReading=null,o?.view.setActiveConversationId(e.session.getActiveConversationId()),Ot(t),e.suppressScrollSend=!1}throw n}finally{(l===yt||!e.conversationOpenPendingEl)&&(e.suppressScrollSend=!1)}l===yt&&(X(),e.pendingConversationReading=null,e.messageCache.clear(),St(),Q(),c||e.setActiveConversationSummary(null),e.eventBus.emit(`history:conversationOpened`,{conversationId:t,title:e.activeConversationTitle,scope:i,timestamp:Date.now()}),n&&e.maybeFocusInput())},At=async({focusComposer:t=!1}={})=>{X();let n=null;try{await e.session.startNewConversation({scope:w(),onBeforeCommit:()=>{e.saveConversationContinuity(),n=e.composerConversationGeneration,e.conversationPersistenceOwner=n},onCommitted:()=>{e.restoreConversationContinuity(!0),e.conversationPersistenceOwner===n&&(e.conversationPersistenceOwner=null),e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),e.persistState(),e.pendingConversationReading=null}})}catch(t){throw e.conversationPersistenceOwner===n&&(e.conversationPersistenceOwner=null),n===e.composerConversationGeneration&&e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),t}e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),e.jumpToBottomInstant(),Q();let r=e.session.getActiveConversationId();o?.view.setActiveConversationId(r),e.eventBus.emit(`history:conversationStarted`,{conversationId:r,timestamp:Date.now()}),e.historyVisible&&(e.historyPresentation===`panel`||I)&&q({restoreFocus:!1}),t&&e.maybeFocusInput()},jt=async(t,n)=>{let r=await e.session.updateConversation(t,{...n,...n.title===void 0?{}:{title:n.title.trim()}});return o?.view.applyConversationSummary(r),!o&&t===e.session.getActiveConversationId()&&e.setActiveConversationSummary(r),r},Mt=async t=>{let n=w(),r=e.session.getActiveConversationId()===t;await e.session.deleteConversation(t,{scope:n}),e.discardConversationContinuity(t),r&&(e.attachmentManager?.destroy({release:!0}),e.attachmentManager=null,e.restoreConversationContinuity(!0)),o?.view.removeConversationSummary(t),r&&(e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),Q()),e.eventBus.emit(`history:conversationDeleted`,{conversationId:t,scope:n,wasActive:r,timestamp:Date.now()})},Nt=async t=>{let n=t?.scope??w(),r=t?.allTargets?null:t?.targetId??te(),i=await e.session.clearConversationHistory({...r?{targetId:r}:{},scope:n});return e.discardConversationContinuity(),e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),Q(),e.eventBus.emit(`history:cleared`,{deleted:i.deleted,scope:n,targetId:r,timestamp:Date.now()}),i},Pt=async()=>{if(!r?.resetDevice)throw Error(`[Persona] resetHistoryIdentity() requires a history provider that can reset this device`);let t=!1;try{t=(await e.session.resetHistoryDevice()).remoteRevocationConfirmed}finally{e.discardConversationContinuity(),X(),e.setActiveConversationSummary(null),e.session.clearArtifacts(),e.messageCache.clear(),e.lastAppliedMessages=null,e.config.clearStoredSessionId?.(),e.config.clearStoredConversationId?.(),e.persistentMetadata={},e.actionManager.syncFromMetadata(),e.clearPersistedDraft();let t=e.storageAdapter;t?.clear&&e.runStorageMutation(()=>t.clear(),`[AgentWidget] Failed to clear storage adapter:`),e.resetAnchorState(),e.resumeAutoScroll(),Q(),q({restoreFocus:!1}),e.maybeFocusInput(),e.open||e.launcherSurfaceInstance?.launcher.element.focus()}return e.announceHistory(t?n.identityResetNotice:n.identityResetUnconfirmedNotice),e.eventBus.emit(`history:identityReset`,{remoteRevocationConfirmed:t,timestamp:Date.now()}),{remoteRevocationConfirmed:t}},Ft=()=>e.artifactSplitRoot?e.panel:e.container,It=async t=>{let n=await e.loadHistoryView().catch(()=>null);return typeof n?.showHistoryConfirm==`function`?n.showHistoryConfirm(t):window.confirm(`${t.title}\n\n${t.description}`)},Lt=async e=>await It({host:Ft(),title:n.deleteConversationConfirmTitle,description:n.deleteConversationConfirm,confirmLabel:n.deleteConversationConfirmLabel,cancelLabel:n.confirmCancelLabel})?(await Mt(e),`deleted`):`cancelled`,Rt=async()=>{let e=w()===`verified-user`;return await It({host:Ft(),title:n.clearHistoryConfirmTitle,description:e?n.clearHistoryVerifiedConfirm:n.clearHistoryConfirm,confirmLabel:n.clearHistoryConfirmLabel,cancelLabel:n.confirmCancelLabel})?(await Nt(),`cleared`):`cancelled`},zt=async()=>{if(!await It({host:Ft(),title:n.resetIdentityConfirmTitle,description:n.resetIdentityConfirm,confirmLabel:n.resetIdentityConfirmLabel,cancelLabel:n.confirmCancelLabel}))return{outcome:`cancelled`};let{remoteRevocationConfirmed:e}=await Pt();return{outcome:`reset`,remoteRevocationConfirmed:e}},Z=u(`button`,`persona-history-earlier`);Z.type=`button`,Z.textContent=n.showEarlierMessagesLabel,Z.setAttribute(`data-persona-history-earlier`,``),Object.assign(Z.style,{alignSelf:`center`,minHeight:`44px`,padding:`0 16px`,borderRadius:`999px`,border:`1px solid var(--persona-border, rgba(0,0,0,0.12))`,background:`transparent`,color:`inherit`,font:`inherit`,cursor:`pointer`,flexShrink:`0`});let Q=()=>{S()&&e.historySessionState.nextMessageCursor&&e.session.getActiveConversationId()?(Z.textContent=n.showEarlierMessagesLabel,Z.parentNode!==e.body&&e.body.insertBefore(Z,e.body.firstChild)):Z.remove()};Z.addEventListener(`click`,()=>{let t=e.session.getActiveConversationId(),n=e.historySessionState.nextMessageCursor;if(!t||!n||Z.disabled)return;Z.disabled=!0;let r=e.body.scrollHeight,i=e.body.scrollTop;e.session.loadOlderMessages(t,n,{scope:w()}).then(()=>{e.body.scrollTop=i+(e.body.scrollHeight-r),e.repinAnchoredMessage()}).catch(()=>{}).finally(()=>{Z.disabled=!1,Q()})});let Bt=()=>{let t=e.createHeaderIconButton({ariaLabel:n.openHistoryLabel,iconName:`history`,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`,extraClassName:`persona-history-toggle`,attrs:{"data-persona-history-toggle":``}});return t.button.addEventListener(`click`,n=>{S()&&!C()&&(e.historyVisible?q():gt({invoker:t.button,keyboard:n.detail===0}))}),t},Vt=()=>{if(!S()){h?.remove(),m=null,h=null;return}if(h&&!h.isConnected&&(m=null,h=null),!m&&e.header){let t=Bt();m=t.button,h=t.wrapper;let n=e.panelElements.clearChatButtonWrapper||e.panelElements.closeButtonWrapper;n?.parentNode&&e.header.contains(n)?n.parentNode.insertBefore(h,n):e.header.appendChild(h)}if(!m||!h)return;let t=W()||e.historyVisible&&e.historyPresentation===`rail`;if(h.style.display=t?`none`:``,t){document.activeElement===m&&ht();return}let r=C();m.disabled=r,m.setAttribute(`aria-disabled`,r?`true`:`false`);let i=r?n.openHistoryBusyLabel:n.openHistoryLabel;m.setAttribute(`aria-label`,i),(e.config.features?.history?.presentation??`panel`)===`panel`?(m.removeAttribute(`aria-expanded`),m.removeAttribute(`aria-controls`)):(m.setAttribute(`aria-expanded`,e.historyVisible?`true`:`false`),m.setAttribute(`aria-controls`,x))},Ht=!1,Ut=()=>{let t=e.panelElements.clearChatButton;t&&(S()?(Ht||=(v=t.getAttribute(`aria-label`)??``,!0),t.setAttribute(`aria-label`,n.newConversationLabel),t.removeAttribute(`title`)):Ht&&(Ht=!1,v&&t.setAttribute(`aria-label`,v)))},$=()=>{n=i(e.config.features?.history?.copy),Vt(),et(),Ut(),Q()};return e.historyChromeSync=$,se(),$(),e.destroyCallbacks.push(()=>{y?.(),b?.(),_+=1,_t(),o?.dispose(),o?.view.destroy(),o=null}),{clearConversationOpenPending:X,cancelConversationOpenTakeover:Y,historyOperationScope:w,discardConversationContinuity:e.discardConversationContinuity,historyAvailable:S,historyScope:ee,installHistoryProvider:se,syncHistoryChromeImpl:$,syncHistoryPresentation:pt,syncEarlierMessagesPill:Q,openHistory:gt,closeHistory:q,openHistoryConversation:kt,startNewConversation:At,updateHistoryConversation:jt,deleteHistoryConversation:Mt,requestDeleteConversation:Lt,clearConversationHistory:Nt,resetHistoryIdentity:Pt,railCollapseShortcut:ze,railCollapsible:we,railTriggerApplies:W,railOverlayMode:ke,toggleRailCollapsed:Re,toggleRailPinned:()=>Le(),get historyProvider(){return r},get historySurface(){return o},get railShell(){return A},get railHost(){return j},get railColumn(){return Se}}};exports.createHistoryShell=oe;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=e=>e?.layout?.embedded===!0&&e.launcher?.enabled===!1&&!e.launcher.sidebarMode&&(e.launcher.mountMode??`floating`)===`floating`,t=t=>t?.layout?.showHeader??!e(t),n=/* @__PURE__ */ `viewTitle.openHistoryLabel.openHistoryBusyLabel.newConversationLabel.expandLabel.collapseLabel.resizeLabel.showEarlierMessagesLabel.openConversationLoadingLabel.openConversationErrorTitle.openConversationRetryLabel.openConversationBackLabel.confirmCancelLabel.deleteConversationConfirmTitle.deleteConversationConfirm.deleteConversationConfirmLabel.clearHistoryConfirmTitle.clearHistoryConfirm.clearHistoryVerifiedConfirm.clearHistoryConfirmLabel.resetIdentityConfirmTitle.resetIdentityConfirm.resetIdentityConfirmLabel.conversationDeletedNotice.identityResetNotice.identityResetUnconfirmedNotice`.split(`.`),r={viewTitle:`Messages`,openHistoryLabel:`Messages`,openHistoryBusyLabel:`Messages, available once the reply finishes`,newConversationLabel:`New conversation`,expandLabel:`Expand conversation list`,collapseLabel:`Collapse conversation list`,resizeLabel:`Resize conversation list`,showEarlierMessagesLabel:`Show earlier messages`,openConversationLoadingLabel:`Loading conversation`,openConversationErrorTitle:`Could not open the conversation.`,openConversationRetryLabel:`Try again`,openConversationBackLabel:`Back to messages`,confirmCancelLabel:`Cancel`,deleteConversationConfirmTitle:`Delete conversation`,deleteConversationConfirm:`Delete this conversation? This cannot be undone.`,deleteConversationConfirmLabel:`Delete`,clearHistoryConfirmTitle:`Delete all conversations`,clearHistoryConfirm:`Delete all conversations for this assistant on this browser? This cannot be undone.`,clearHistoryVerifiedConfirm:`Delete all conversations for this assistant and signed-in user? This cannot be undone.`,clearHistoryConfirmLabel:`Delete all`,resetIdentityConfirmTitle:`Forget this device`,resetIdentityConfirm:`Forget this device? All Persona data stored in this browser is cleared. Records are not deleted elsewhere.`,resetIdentityConfirmLabel:`Forget this device`,conversationDeletedNotice:`That conversation was deleted. You are now in a new conversation.`,identityResetNotice:`This device was forgotten.`,identityResetUnconfirmedNotice:`This device was cleared here, but the server could not confirm it.`};function i(e){if(!e)return r;let t={...r};for(let r of n){let n=e[r];typeof n==`string`&&n.length>0&&(t[r]=n)}return t}const a=(e,t)=>{console.warn(`[persona] ${e} threw`,t)},o=e=>Object.freeze({...e}),s=e=>Object.freeze({id:e.id,title:e.title,targetId:e.targetId,preview:e.preview,messageCount:e.messageCount,createdAt:e.createdAt,updatedAt:e.updatedAt}),c=e=>e?o(e):null;function l(e){let{plugins:t,config:n}=e,r=!1,i=!1,l=!1,u=!1,d=null,f=[],p=()=>{for(let e of f.splice(0))try{e()}catch(e){a(`renderHistoryView cleanup`,e)}},m=(e,n)=>{for(let r of t){let t=r[e];if(t)try{let e=t(n);if(e)return e}catch(t){a(e,t)}}return null},h=()=>({presentation:e.getPresentation(),config:n}),g={header:t=>u?m(`renderHistoryHeader`,Object.freeze({...h(),returnSurface:e.getReturnSurface(),identityStatus:o(t.identityStatus),pendingAction:c(t.pendingAction),copy:o(t.copy),actions:Object.freeze({close:y.close,startNewConversation:y.startNewConversation}),defaultRenderer:t.defaultRenderer})):null,conversation:e=>u?m(`renderHistoryConversation`,Object.freeze({...h(),conversation:s(e.conversation),active:e.active,pending:e.pending,open:e.open,requestDelete:e.requestDelete,defaultRenderer:e.defaultRenderer})):null,state:e=>u?m(`renderHistoryState`,Object.freeze({...h(),state:o(e.state),identityStatus:o(e.identityStatus),copy:o(e.copy),...e.retry?{retry:e.retry}:{},...e.startNewConversation?{startNewConversation:e.startNewConversation}:{},defaultRenderer:e.defaultRenderer})):null},_=t.flatMap(t=>(t.railSections??[]).map(t=>({...t,placement:t.placement??`above-conversations`,items:[],render:n=>t.render(Object.freeze({collapsed:n,presentation:e.getPresentation(),actions:y}))}))),v=e.createView({slots:g,renderDom:!1,onModelChange:()=>C(),railSections:_}),y=Object.freeze({...v.operations,close:e.close}),b=()=>(u=!0,v.setDomRenderEnabled(!0),v.element),x=t=>Object.freeze({conversations:Object.freeze(t.conversations.map(s)),activeConversationId:t.activeConversationId,state:o(t.state),pendingAction:c(t.pendingAction),identityStatus:o(t.identityStatus),nextCursor:t.nextCursor,presentation:e.getPresentation(),returnSurface:e.getReturnSurface(),config:n,copy:o(v.copy),actions:y,defaultRenderer:b,requestRender:()=>C(),onCleanup:e=>{f.push(e)}}),S=()=>{u=!1;let e=null;for(let n of t)if(n.renderHistoryView){try{e=n.renderHistoryView(x(v.getModel()))}catch(t){a(`renderHistoryView`,t),e=null}if(e)break}let n=!e||e.contains(v.element);return u=n,v.setDomRenderEnabled(n),e??v.element};function C(){if(!(!l||r||i)){i=!0;try{p();let t=S();if(t===d)return;let n=d;d=t,e.onElementChanged(t,n)}finally{i=!1}}}return l=!0,C(),{view:v,get element(){return d??v.element},requestRender:C,dispose:()=>{r=!0,p()}}}const u=(e,t)=>{let n=document.createElement(e);return t&&(n.className=t),n},d=(e,t={},...n)=>{let r=document.createElement(e);if(t.className&&(r.className=t.className),t.text!==void 0&&(r.textContent=t.text),t.attrs)for(let[e,n]of Object.entries(t.attrs))r.setAttribute(e,n);if(t.style){let e=r.style,n=t.style;for(let t of Object.keys(n)){let r=n[t];r!=null&&(e[t]=r)}}let i=n.filter(e=>e!=null);return i.length>0&&r.append(...i),r},f=(...e)=>e.filter(Boolean).join(` `);function p(e){return typeof e==`string`?e:e.filter(e=>e.type===`text`).map(e=>e.text).join(``)}function m(e){return typeof e!=`string`&&e.some(e=>e.type===`image`)}function h(e){return{type:`text`,text:e}}function g(e,t){return{type:`image`,image:e,...t?.mimeType&&{mimeType:t.mimeType},...t?.alt&&{alt:t.alt}}}const _=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`],v=[`application/pdf`,`text/plain`,`text/markdown`,`text/csv`,`application/msword`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.ms-excel`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/json`];[..._,...v];function y(e,t,n){return{type:`file`,data:e,mimeType:t,filename:n}}const b=[`user`,`assistant`,`system`,`operator`];function x(e){if(typeof e!=`string`||e===``)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function S(e){return typeof e==`string`?e:void 0}function C(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`text`:return typeof t.text==`string`?h(t.text):null;case`image`:return typeof t.image==`string`?g(t.image,{mimeType:S(t.mimeType),alt:S(t.alt)}):null;case`file`:return typeof t.data==`string`&&typeof t.mimeType==`string`&&typeof t.filename==`string`?y(t.data,t.mimeType,t.filename):null;case`audio`:return typeof t.audio==`string`?{type:`audio`,audio:t.audio,...S(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;case`video`:return typeof t.video==`string`?{type:`video`,video:t.video,...S(t.mimeType)!==void 0&&{mimeType:t.mimeType}}:null;default:return null}}function ee(e,t){let n=x(t),r=e.map(e=>x(e.timestamp)),i=Array(e.length),a=0;for(;a<r.length;){let e=r[a];if(e!==null){i[a]=e,a+=1;continue}let t=a;for(;t+1<r.length&&r[t+1]===null;)t+=1;let o=t-a+1,s=a>0?i[a-1]:null,c=t+1<r.length?r[t+1]:null,l=c!==null&&n!==null?Math.min(c,n):c??n;for(let e=0;e<o;e+=1)i[a+e]=l===null?s===null?0+e:s+e+1:l-(o-e);a=t+1}return i.map(e=>new Date(e).toISOString())}function w(e,t){let n=ee(e,t?.beforeCreatedAt),r=[];return e.forEach((e,t)=>{if(typeof e?.id!=`string`||e.id===``||!b.includes(e.role))return;let i=e.role,a=n[t],o=e.author,s=o&&typeof o==`object`?{...typeof o.id==`string`&&{id:o.id},...typeof o.displayName==`string`&&{displayName:o.displayName},...[`human`,`ai`,`system`].includes(o.kind??``)&&{kind:o.kind}}:void 0;if(e.displayAvailable===!1){let t={historyDisplayUnavailable:!0};r.push({id:e.id,role:i,...s&&{author:s},content:``,createdAt:a,agentMetadata:t})}else if(typeof e.displayContent==`string`)r.push({id:e.id,role:i,...s&&{author:s},content:e.displayContent,createdAt:a});else if(typeof e.content==`string`)r.push({id:e.id,role:i,...s&&{author:s},content:e.content,createdAt:a});else if(Array.isArray(e.content)){let t=e.content.map(C).filter(e=>e!==null),n=p(t);r.push({id:e.id,role:i,...s&&{author:s},content:n||(m(t)?`[Image]`:``),createdAt:a,...t.length>0&&{contentParts:t}})}else r.push({id:e.id,role:i,...s&&{author:s},content:``,createdAt:a})}),r}function te(e,t){let n=/* @__PURE__ */ new Map;for(let t of e)n.set(t.id,t);for(let e of t)n.set(e.id,e);return[...n.values()].sort((e,t)=>{let n=new Date(e.createdAt).getTime(),r=new Date(t.createdAt).getTime();if(!Number.isNaN(n)&&!Number.isNaN(r)&&n!==r)return n-r;let i=e.sequence??0,a=t.sequence??0;return i===a?e.id.localeCompare(t.id):i-a})}const ne=/* @__PURE__ */ new Map([[`not_found`,`not_found`],[`conversation_deleted`,`not_found`],[`rate_limited`,`rate_limited`],[`authentication_required`,`authentication_required`],[`invalid_identity_proof`,`authentication_required`],[`visitor_identity_mismatch`,`authentication_required`],[`visitor_required`,`authentication_required`],[`identity_provider_failed`,`identity_provider_failed`],[`proof_not_admitted`,`proof_not_admitted`],[`identity_contract_violation`,`proof_not_admitted`],[`unauthorized`,`authentication_failed`],[`visitor_token_missing`,`authentication_failed`],[`conversation_credential_missing`,`authentication_failed`]]),re=/* @__PURE__ */ new Map([[`not_found`,`That conversation is no longer available.`],[`rate_limited`,`Too many history requests.`],[`authentication_failed`,`History access was not authorized.`],[`authentication_required`,`Sign in again to view account history.`],[`identity_provider_failed`,`The identity provider did not respond.`],[`proof_not_admitted`,`Account history is not available for this configuration.`],[`unsupported_scope`,`This history scope is not supported.`],[`unavailable`,`Conversation history is unavailable right now.`]]),T=e=>re.get(e)??`Conversation history is unavailable right now.`;function ie(e,{HistoryClientError:t,HistoryProviderError:n}){if(e instanceof n)return e;if(e instanceof t){let t=ne.get(e.code)??`unavailable`;return new n(t,T(t),{...e.retryAfterSeconds===void 0?{}:{retryAfterSeconds:e.retryAfterSeconds}})}return new n(`unavailable`,T(`unavailable`))}function ae(e){let{HistoryProviderError:t}=e.errors,n=()=>e.getClient?.()??e.client,r=e.getIdentityProofConfigured()?[`browser`,`verified-user`]:[`browser`],i={scopes:r},a=e=>{if(!r.includes(e))throw new t(`unsupported_scope`,T(`unsupported_scope`))},o=async(t,n)=>{a(t);try{return await n()}catch(t){throw ie(t,e.errors)}},s=t=>{let n=!1;return{conversationId:t.session.conversationId??``,conversationRevision:t.session.conversationRevision??``,async commit(){n||(n=!0,t.commit(),await e.onActivationCommitted(t.session))},discard(){n||(n=!0,t.discard())}}};return{capabilities:i,getIdentityStatus(){return n().getHistoryIdentityStatus()},subscribeIdentityStatus(e){return n().subscribeHistoryIdentityStatus(e)},subscribeAvailability(e){return n().subscribeHistoryAvailability(e)},async list(e){return o(e.context.scope,async()=>{let t=await n().listConversations({...e.cursor?{cursor:e.cursor}:{},...e.limit===void 0?{}:{limit:e.limit},...e.targetId?{targetId:e.targetId}:{},scope:e.context.scope});return{items:t.data,nextCursor:t.nextCursor}})},async getPage(e,t){return o(t.context.scope,async()=>{let r=await n().getConversation(e,{...t.cursor?{messageCursor:t.cursor}:{},scope:t.context.scope}),i=w(r.messages,{...t.beforeCreatedAt?{beforeCreatedAt:t.beforeCreatedAt}:{}});return{summary:r.summary,messages:te([],i),conversationRevision:r.conversationRevision??``,nextCursor:r.nextMessageCursor}})},async prepareOpen(e,t){return o(t.context.scope,async()=>s(await n().prepareConversationSession(e)))},async prepareStartNew(e){return o(e.context.scope,async()=>s(await n().prepareNewConversationSession()))},async delete(e,t){await o(t.context.scope,()=>n().deleteConversation(e,{scope:t.context.scope}))},async deleteAll(e){return o(e.context.scope,()=>n().deleteAllConversations({...e.targetId===void 0?{}:{targetId:e.targetId},scope:e.context.scope}))},async resetDevice(){try{return await n().resetVisitor(),{remoteRevocationConfirmed:!0}}catch{return{remoteRevocationConfirmed:!1}}}}}const oe=e=>{let n=i(e.config.features?.history?.copy),r=null,a=!1,o=null,s=null,c=`conversation`,p=null,m=null,h=null,g=null,_=0,v=null,y=null,b=null,x=`persona-history-${Math.random().toString(36).slice(2,8)}`,S=()=>e.historyFeatureEnabled()&&!!r&&!a,C=()=>{let t=e.session.getStatus();return e.isStreaming||t===`paused`||t===`resuming`},ee=()=>{let t=e.config.features?.history?.scope;if(t)return t;let n=e.config.getIdentityProof?`verified-user`:`browser`,i=r?.capabilities.scopes;return!i||i.includes(n)?n:i[0]??n},w=()=>s?.scope??ee(),te=()=>e.session.getClientSession()?.targetId??null,ne=e=>`${e.state}:${`reason`in e?e.reason:``}`,re=t=>{let n=ne(t);n!==g&&(g=n,e.eventBus.emit(`history:identityStatusChanged`,{status:t,timestamp:Date.now()}))},T=null,ie=null,oe=()=>{if(!e.historyFeatureEnabled())return null;let t=e.getHistoryProviderFactory();if(t)return t();let n=e.config.features?.history?.provider;return n?typeof n==`function`?(T!==n&&(T=n,ie=n()),ie):n:e.session.isClientTokenMode()?ae({errors:e.historyErrors,client:e.session.getClient(),getIdentityProofConfigured:()=>typeof e.config.getIdentityProof==`function`,onActivationCommitted:t=>e.session.bindActivatedSession(t),getClient:()=>e.session.getClient()}):null},se=()=>{y?.(),y=null,b?.(),b=null,a=!1;let t=r;r=oe(),t&&t!==r&&e.discardConversationContinuity();let n={...e.historyInternals};r?n.historyProvider=r:delete n.historyProvider,e.historyInternals=n,e.session.setHistoryInternals(e.historyInternals),r&&(y=r.subscribeAvailability?.(e=>{a=!e,e||q({restoreFocus:!1}),$()})??null,b=r.subscribeIdentityStatus(e=>re(e)),g=ne(r.getIdentityStatus()))},ce=()=>{let t=e.config.features?.history?.presentation??`panel`;if(t===`panel`||t===`auto`&&e.launcherEnabled&&!e.isDockedMountMode(e.config))return`panel`;let n=e.artifactSplitRoot??e.container;return(n.getBoundingClientRect().width||n.clientWidth)>=720?`rail`:`panel`},E=(e,t)=>{t?(e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``)):(e.removeAttribute(`aria-hidden`),e.removeAttribute(`inert`))},le=`data-persona-history-suppressed`,D=null,O=null,k=null,ue=null,de=null,fe=``,pe=()=>e.header===de?fe:t(e.config)?``:`none`,me=()=>e.historyPresentation===`panel`&&!!k&&ue===k.element&&t(e.config)&&pe()!==`none`,he=()=>{for(let t of Array.from(e.header.children))t!==D&&t.setAttribute(le,``)},ge=()=>{for(let t of Array.from(e.container.querySelectorAll(`[${le}]`)))t.removeAttribute(le)},_e=()=>{let t=k;if(!t)return;if(Array.from(e.header.children).some(e=>e!==D&&!e.hasAttribute(le))){O&&O!==e.header&&(O.style.removeProperty(`min-height`),O=null);let t=e.header.offsetHeight;t>0&&(e.header.style.minHeight=`${t}px`,O=e.header)}D||=u(`div`,`persona-history-header-host`),t.setHeaderPlacement(`external`);let n=t.getHeaderElement();n.parentNode!==D&&D.replaceChildren(n),D.parentNode!==e.header&&e.header.appendChild(D),he()},ve=()=>{O&&=(O.style.removeProperty(`min-height`),null),D&&(k?.setHeaderPlacement(`inline`),D.remove(),D=null,ge())},ye=null,be=()=>{ye&&(e.body.style.display=`none`,E(e.body,!0),e.footer.hidden=!0,E(e.footer,!0),e.panelSuggestions.style.display=`none`,E(e.panelSuggestions,!0),e.panelSuggestionsFade.style.display=`none`,me()?(_e(),e.header.style.display=pe(),E(e.header,!1)):(ve(),e.header.style.display=`none`,E(e.header,!0)))};e.reapplyHistoryHostChrome=be;let xe=n=>{let r=e.body.style.display,i=e.footer.hidden,a=e.panelSuggestions.style.display,o=e.panelSuggestionsFade.style.display,s=e.footer,c=e.header,l=e.header.style.display;de=c,fe=l,ye=()=>{ye=null,ve(),de=null,e.body.style.display=r,E(e.body,!1),e.panelSuggestions.style.display=a,E(e.panelSuggestions,!1),e.panelSuggestionsFade.style.display=o,s.hidden=i,E(s,!1),e.footer!==s&&(e.footer.hidden=!1,E(e.footer,!1)),c.style.display=l,E(c,!1),e.header!==c&&(e.header.style.display=t(e.config)?``:`none`,E(e.header,!1))},e.container.insertBefore(n,e.footer.parentNode===e.container?e.footer:e.panelSuggestions),be()},A=null,j=null,Se=null,M=null,Ce=()=>[e.header,e.panelElements.closeButtonWrapper,e.panelElements.clearChatButtonWrapper,e.body,e.footer,e.scrollToBottomButton],we=()=>e.config.features?.history?.rail?.collapsible!==!1,N=()=>e.config.features?.history?.rail?.side===`right`?`right`:`left`,Te=e=>Math.min(400,Math.max(200,Math.round(e))),Ee=()=>e.config.features?.history?.rail?.resizable===!0,P,De=()=>{if(P===void 0&&(P=null,e.config.persistState!==!1))try{let t=Number(window.localStorage.getItem(`${e.currentKeyPrefix()}rail-width`));t&&(P=t)}catch{}return P},F=()=>Te(De()??e.config.features?.history?.rail?.width??260),Oe=t=>{if(P=t,e.config.persistState!==!1)try{window.localStorage.setItem(`${e.currentKeyPrefix()}rail-width`,String(t))}catch{}},ke=()=>we()&&e.config.features?.history?.rail?.collapsedBehavior===`overlay`,I=!1,Ae=e=>{let t=u(`img`);return t.src=e,t.alt=``,t.setAttribute(`aria-hidden`,`true`),t},je=()=>{let t=e.config.features?.history?.rail?.brand;if(!t)return;let n=!1,r;return i=>{if(t.render)try{return t.render({collapsed:i})??null}catch(e){return n||(n=!0,console.warn(`[persona] history rail brand threw`,e)),null}return r===void 0&&(r=t.iconUrl?Ae(t.iconUrl):t.icon?e.renderLucideIcon(t.icon,20):null),r?r.cloneNode(!0):null}},Me=()=>e.config.features?.history?.rail?.sections?.map(t=>{let n=!1,r=e=>{n||(n=!0,console.warn(`[persona] history rail section threw`,t.id,e))};return{id:t.id,title:t.title,placement:t.placement??`above-conversations`,items:t.items.map(t=>{let n;return{id:t.id,label:t.label,badge:t.badge,iconNode:()=>{if(n!==void 0)return n;try{n=t.renderIcon?t.renderIcon()??null:t.iconUrl?Ae(t.iconUrl):t.icon?e.renderLucideIcon(t.icon,20):null}catch(e){r(e),n=null}return n},onSelect:()=>{try{t.onSelect()}catch(e){r(e)}}}})}})??[],Ne=e=>{let t=Me();for(let n of e)t.some(e=>e.id===n.id)?console.warn(`[persona] duplicate history rail section id`,n.id):t.push(n);return t.length?t:void 0},L=null,Pe=()=>`${e.currentKeyPrefix()}rail-collapsed`,Fe=()=>{if(L===null&&(L=e.config.features?.history?.rail?.defaultCollapsed===!0,e.config.persistState!==!1))try{let e=window.localStorage.getItem(Pe());e&&(L=e===`1`)}catch{}return L},Ie=t=>{if(L=t,e.config.persistState!==!1)try{window.localStorage.setItem(Pe(),t?`1`:`0`)}catch{}},R=()=>e.historyPresentation===`rail`&&we()&&!ke()&&Fe(),Le=()=>{},Re=()=>{ke()?Le():(Ie(!Fe()),o?.view.setCollapsed(R()),e.applyRailChrome(),e.repinAnchoredMessage())},ze=()=>{let t=e.config.features?.history?.rail?.collapseShortcut;return!t||!e.parseCombo(t)?null:{combo:t,hint:e.formatCombo(t),aria:e.ariaCombo(t)}},Be=`var(--persona-history-overlay-margin,8px)`,z=null,B=null,Ve=0,V=null,H=null,U=!1,He=0,Ue=()=>window.matchMedia?.(`(pointer: coarse)`).matches===!0,W=()=>S()&&ke()&&(e.historyPresentation??ce())===`rail`,We=()=>e.historyVisible&&!I,G=()=>{H!==null&&clearTimeout(H),H=null},Ge=()=>{e.loadHistoryView().catch(()=>{})},Ke=()=>{G(),I&&(H=setTimeout(()=>{H=null,!U&&I&&(V?.contains(document.activeElement)||q({restoreFocus:!1}))},300))},qe=(e,t)=>{let n=V?.getBoundingClientRect();if(!n)return!1;let r=z?.getBoundingClientRect(),i=r?Math.min(r.top,n.top):n.top;return e>=n.left&&e<=n.right&&t>=i&&t<=n.bottom||!!r&&e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},Je=e=>{I&&(U=qe(e.clientX,e.clientY),U?G():H===null&&Ke())},Ye=t=>{!e.historyVisible&&W()&&(I=!0,gt({invoker:z,keyboard:t?.keyboard===!0}).then(()=>{e.historyVisible?!U&&document.activeElement!==z&&q():I=!1}))},Xe=()=>{let e=ue?.querySelector(`[data-persona-history-focus="collapse"]`);e&&(e.setAttribute(`aria-label`,I?n.expandLabel:n.collapseLabel),e.setAttribute(`aria-expanded`,I?`false`:`true`))},Ze=()=>{Ie(!1);let t=o;if(!I||!t){gt({invoker:z});return}let n=document.activeElement===z;I=!1,ut(),t.element.remove(),ft(t.element),Xe(),n&&ht(),e.repinAnchoredMessage(),$()},Qe=()=>{Ie(!0),q()};Le=()=>{!e.historyVisible||I?Ze():Qe()};let $e=()=>{let t=ze(),r=e.createHeaderIconButton({ariaLabel:n.expandLabel,iconName:`panel-left`,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`,extraClassName:`persona-rail-trigger`,tooltip:!1,attrs:{"data-persona-rail-trigger":``,"aria-controls":x,...t?{"aria-keyshortcuts":t.aria}:{}}}),i=r.button;i.addEventListener(`mouseenter`,()=>{U=!0,G(),!(Ue()||Date.now()<He)&&Ye()}),i.addEventListener(`mouseleave`,()=>{U=!1,He=0,Ke()}),i.addEventListener(`focus`,()=>{e.historyVisible||Ge()}),i.addEventListener(`click`,t=>{S()&&(t.detail!==0&&Ue()&&!e.historyVisible?Ye():Ze())}),z=i,B=r.wrapper},et=()=>{if(B&&!B.isConnected&&(B=null,z=null),!W()){B?.remove(),B=null,z=null;return}z||$e();let t=B,r=z;if(!t||!r)return;let i=N()===`right`?null:e.header.firstChild;(i??e.header.lastChild)!==t&&e.header.insertBefore(t,i),t.style.display=We()||Ve>0?`none`:``,r.setAttribute(`aria-label`,n.expandLabel),r.setAttribute(`aria-expanded`,e.historyVisible?`true`:`false`),V&&e.applyRailChrome()},tt=e=>{if(!I)return;let t=e.target;t instanceof Node&&(V?.contains(t)||B?.contains(t)||t instanceof Element&&t.closest(`.persona-dropdown-menu,[role="alertdialog"]`)||q({restoreFocus:!1}))};document.addEventListener(`pointerdown`,tt,!0),e.destroyCallbacks.push(()=>{document.removeEventListener(`pointerdown`,tt,!0),document.removeEventListener(`pointermove`,Je),K?.(),G()});let nt=null,K=null,rt=t=>{Oe(Te(t)),e.applyRailChrome(),e.repinAnchoredMessage()},it=()=>{let t=u(`div`,`persona-rail-resizer`);return t.tabIndex=0,t.setAttribute(`role`,`separator`),t.setAttribute(`aria-orientation`,`vertical`),t.setAttribute(`aria-valuemin`,`200`),t.setAttribute(`aria-valuemax`,`400`),t.addEventListener(`pointerdown`,n=>{let r=j;if(!r||n.button!==0)return;n.preventDefault(),K?.();let i=n.clientX,a=r.getBoundingClientRect().width||F(),o=N()===`right`?-1:1,s=a,c=e.mount.ownerDocument;r.style.transition=`none`;let l=e=>{s=Te(a+o*(e.clientX-i)),r.style.flex=`0 0 ${s}px`,t.setAttribute(`aria-valuenow`,String(s))},u=()=>{K=null,c.removeEventListener(`pointermove`,l),c.removeEventListener(`pointerup`,u),c.removeEventListener(`pointercancel`,u),r.style.removeProperty(`transition`);try{t.releasePointerCapture(n.pointerId)}catch{}rt(s)};K=u,c.addEventListener(`pointermove`,l),c.addEventListener(`pointerup`,u),c.addEventListener(`pointercancel`,u);try{t.setPointerCapture(n.pointerId)}catch{}}),t.addEventListener(`keydown`,e=>{let t=N()===`right`?-16:16,n=F(),r=e.key===`ArrowRight`?n+t:e.key===`ArrowLeft`?n-t:e.key===`Home`?200:e.key===`End`?400:null;r!==null&&(e.preventDefault(),rt(r))}),t},at=(e,t)=>{if(!Ee()||R()){K?.(),nt?.remove();return}let r=nt??it();nt=r,r.setAttribute(`aria-label`,n.resizeLabel),r.setAttribute(`aria-valuenow`,String(F())),r.nextElementSibling!==t&&e.insertBefore(r,t)};e.applyRailChrome=()=>{o?.view.setRailSide(N());let t=N()===`right`,n=V;if(n){let r=z?z.getBoundingClientRect().bottom-e.container.getBoundingClientRect().top:0;n.style.top=`calc(${Math.max(0,Math.round(r))}px + ${Be})`,n.style.width=`${F()}px`,n.style.left=t?``:Be,n.style.right=t?Be:``}let r=j,i=A,a=Se;if(!r||!i||!a)return;r.style.flex=`0 0 ${R()?52:F()}px`;let s=`1px solid var(--persona-divider,#e5e7eb)`;r.style.borderRight=t?``:s,r.style.borderLeft=t?s:``;let c=t?a:r;i.firstElementChild!==c&&i.append(c,t?r:a),at(i,t?r:a)};let ot=t=>{if(M&&j){M.replaceWith(t),M=null,e.applyRailChrome();return}let n=u(`div`,`persona-history-rail-shell`);n.style.cssText=`display:flex;flex-direction:row;flex:1 1 auto;min-height:0`;let r=u(`div`,`persona-history-rail-conversation`);r.style.cssText=`display:flex;flex-direction:column;flex:1 1 auto;min-width:0;min-height:0;position:relative`;let i=u(`div`,`persona-history-rail-host`);i.style.cssText=`display:flex;min-height:0;overflow:hidden`,e.container.insertBefore(n,e.header.parentNode===e.container?e.header:e.body);for(let t of Ce())t?.parentNode===e.container&&r.appendChild(t);n.append(i,r),i.appendChild(t),A=n,j=i,Se=r,e.applyRailChrome()},st=()=>{if(A)return;let t=u(`div`,`persona-history-rail-placeholder`);t.style.cssText=`flex:1 1 auto;min-height:0`,M=t,ot(t),e.repinAnchoredMessage()},ct=()=>{M&&(ut(),e.repinAnchoredMessage())},lt=t=>{let n=u(`div`,`persona-history-rail-overlay`);n.style.cssText=`position:absolute;bottom:${Be};display:flex;overflow:hidden;z-index:100000;border-radius:var(--persona-history-overlay-radius,16px);background:var(--persona-history-overlay-bg,var(--persona-container,#f7f7f8));box-shadow:var(--persona-history-overlay-shadow,0 12px 40px rgba(0,0,0,0.25))`,e.container.style.position=`relative`,e.container.appendChild(n),n.appendChild(t),document.addEventListener(`pointermove`,Je),V=n,e.applyRailChrome(),Xe()},ut=()=>{ye?.(),V&&=(U&&(He=Date.now()+150),document.removeEventListener(`pointermove`,Je),V.remove(),null);let t=A;if(t){K?.();for(let n of Ce())if(n&&t.contains(n)){let r=n===e.scrollToBottomButton?e.panelSuggestions:t;e.container.insertBefore(n,r)}t.remove(),A=null,j=null,Se=null,M=null}},dt=e=>{ue=e,e.id=x,e.style.flex=`1 1 auto`,e.style.minHeight=`0`},ft=t=>{dt(t),(e.historyPresentation!==`rail`||I)&&ct(),e.historyPresentation===`rail`?I?lt(t):ot(t):xe(t)},pt=()=>{if(et(),Vt(),!e.historyVisible||!o)return;let t=ce();if(t===e.historyPresentation)return;let n=document.activeElement,r=n instanceof HTMLElement&&(o.element.contains(n)||D?.contains(n)===!0)?n:null;ut(),o.element.remove(),o.view.setHeaderPlacement(`inline`),e.historyPresentation=t,o.view.setPresentation(t),o.view.setCollapsed(R()),o.requestRender(),o.element.isConnected||ft(o.element),r?.isConnected?r.focus():ht(),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$()},mt=(e,t)=>D?.querySelector(t)??e.querySelector(t),ht=()=>{let e=o?.element??ue;if(!e)return;let t=mt(e,`[data-persona-history-focus="close"],[data-persona-history-focus="collapse"]`);if(t){t.focus();return}let n=mt(e,`.persona-history-title`)??e;n.tabIndex=-1,n.focus()},gt=async i=>{if(!S()||e.historyVisible)return;let a=r;if(!a)return;if(!I&&W()&&Fe()){et();return}_t();let u=++_;c=i?.returnSurface??`conversation`,p=i?.invoker??m;let d=W()&&!I;d&&(Ve+=1,et(),st());let f;try{f=await e.loadHistoryView()}catch{e.announceHistory(n.openHistoryLabel),d&&(--Ve,u===_&&(ct(),et()));return}if(d&&--Ve,u!==_||e.historyVisible)return;s={scope:ee()},e.historyPresentation=ce(),e.historyVisible=!0;let h=e.historyPresentation===`panel`&&t(e.config)&&e.header.style.display!==`none`?`external`:`inline`,g=e.config.features?.history?.rowAvatar,v=ze(),y=v?{hint:v.hint,aria:v.aria}:null,b={provider:a,context:s,targetId:te(),presentation:e.historyPresentation,collapsible:we(),collapsed:R(),railSide:N(),renderRailHeader:e.config.features?.history?.rail?.renderHeader,railBrand:je(),onToggleCollapse:Re,...y?{collapseShortcut:y}:{},headerPlacement:h,showScopeStatus:e.config.features?.history?.showScopeStatus!==!1,showDelete:e.config.features?.history?.showDelete!==!1,showDeleteAll:e.config.features?.history?.showDeleteAll!==!1,...e.config.features?.history?.listActions?.length?{listActions:e.config.features.history.listActions}:{},rowAvatar:g===!1?!1:typeof g==`string`?g:e.config.launcher?.iconUrl,activeConversationId:e.session.getActiveConversationId(),...e.config.features?.history?.grouping?{grouping:e.config.features.history.grouping}:{},...e.config.features?.history?.copy?{copy:e.config.features.history.copy}:{},...e.config.features?.history?.pageSize===void 0?{}:{pageSize:e.config.features.history.pageSize},onSelect:e=>kt(e,{focusComposer:!0}).catch(()=>{}),onActiveConversationChange:t=>e.setActiveConversationSummary(t),attachTooltip:e.attachTooltip,onStartNew:()=>At({focusComposer:!0}),onClose:()=>q(),onRequestDeleteConversation:e=>Lt(e),onRequestClearHistory:()=>Rt(),...a.resetDevice?{onRequestResetIdentity:()=>zt()}:{}};o=l({plugins:e.plugins,config:e.config,getPresentation:()=>e.historyPresentation??`panel`,getReturnSurface:()=>c,close:()=>q(),createView:({slots:t,renderDom:n,onModelChange:r,railSections:i})=>(k=f.createHistoryView({...b,railSections:Ne(i),slots:t,renderDom:n,onModelChange:r,onAnnounce:e.announceHistory}),k),onElementChanged:(e,t)=>{if(!t?.isConnected)return ft(e);dt(e),t.replaceWith(e),be()}}),o.view.setNewConversationRequired(e.historySessionState.recovery===`new_conversation_required`),i?.focus!==!1&&(e.historyPresentation!==`rail`||i?.keyboard===!0)&&ht(),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$(),e.eventBus.emit(`history:opened`,{presentation:e.historyPresentation,returnSurface:c,timestamp:Date.now()})},_t=()=>{},q=t=>{if(!e.historyVisible)return;_+=1;let n=c,r=p,i=o,a=t?.restoreFocus!==!1;e.historyVisible=!1;let l=!1,u=null,d=()=>{if(!l){if(l=!0,_t=()=>{},u!==null&&clearTimeout(u),I=!1,G(),ut(),i?.dispose(),i?.view.destroy(),i?.element.remove(),o===i&&(o=null,k=null,ue=null,e.historyPresentation=null,s=null,p=null),e.syncScrollToBottomButton(),e.repinAnchoredMessage(),$(),a){let t=r??m;t?.isConnected?t.focus():e.maybeFocusInput()}e.eventBus.emit(`history:closed`,{returnSurface:n,timestamp:Date.now()})}},f=i&&i.element===i.view.element?i.view.playExit():null;f?(_t=d,u=setTimeout(d,250),f.then(d)):d()},vt=t=>{if(t.key===`Escape`&&e.historyVisible&&o){if(e.historyPresentation===`rail`){let e=t.target;if(!(e instanceof Node)||!(o.element.contains(e)||I&&B?.contains(e)===!0))return}t.preventDefault(),t.stopPropagation(),q()}};e.container.addEventListener(`keydown`,vt),e.destroyCallbacks.push(()=>e.container.removeEventListener(`keydown`,vt));let yt=0,J=null,bt=null,Y=()=>{bt&&clearTimeout(bt),bt=null};e.destroyCallbacks.push(Y);let xt=()=>{Y();let t=e.conversationOpenPendingEl;t&&(e.conversationOpenTakeover=!0,t.hidden=!1,e.messagesWrapper.style.display=`none`,e.updateWelcome())},X=()=>{yt+=1,Y(),J?.remove(),J=null,e.conversationOpenPendingEl&&(e.conversationOpenPendingEl.remove(),e.conversationOpenPendingEl=null,e.conversationOpenTakeover=!1,e.messagesWrapper.style.removeProperty(`display`),E(e.footer,!1),e.updateWelcome())},St=()=>{try{if(window.matchMedia?.(`(prefers-reduced-motion: reduce)`)?.matches)return;e.messagesWrapper.animate([{opacity:0},{opacity:1}],{duration:150,easing:`ease-out`})}catch{}},Ct=t=>{let n=e.config.layout?.messages?.layout??`bubble`,r=d(`div`,{className:`persona-flex`,attrs:{"aria-hidden":`true`}});e.applyMessageRowLayout(r,t);let i=d(`div`,{className:f(e.getBubbleClasses(t,n).join(` `),`persona-conversation-loading-bubble`),attrs:{"data-persona-theme-zone":`${t}-message`},style:{width:t===`user`?`64%`:`100%`,backgroundColor:n===`flat`?`transparent`:`var(--persona-message-${t}-bg, var(--persona-${t===`user`?`accent`:`container`}))`,color:`var(--persona-message-${t}-text, ${t===`user`&&n!==`flat`?`white`:`var(--persona-text)`})`}},...[`94%`,...t===`assistant`?[`86%`]:[],`62%`].map(e=>d(`div`,{className:`persona-conversation-loading-line`,style:{width:e}})));return e.applyBubbleGeometry(i,t,n,{...e.resolveThemeDefaults(e.config.future).components.message[t],...e.config.theme?.components?.message?.[t],...e.config.darkTheme?.components?.message?.[t]}),r.appendChild(i),r},wt=()=>d(`div`,{className:`persona-conversation-loading-body`,style:{gap:e.messagesWrapper.style.gap}},Ct(`user`),Ct(`assistant`),Ct(`user`),Ct(`assistant`)),Tt=()=>e.config.loadingIndicator?.conversationOpenVariant===`skeleton`?wt():d(`div`,{className:`persona-conversation-loading-spinner`,attrs:{"aria-hidden":`true`}},d(`span`,{className:`persona-conversation-loading-ring`})),Et=t=>{e.conversationOpenPendingEl?.remove(),e.conversationOpenPendingEl=t,t.hidden=!e.conversationOpenTakeover,e.body.insertBefore(t,e.messagesWrapper),Y(),e.conversationOpenTakeover||(bt=setTimeout(xt,250)),E(e.footer,!0)},Dt=()=>{let t={config:e.config,streaming:!1,location:`conversation-open`,defaultRenderer:Tt},r=null,i=e.plugins.find(e=>e.renderLoadingIndicator);i?.renderLoadingIndicator&&(r=i.renderLoadingIndicator(t)),r===null&&e.config.loadingIndicator?.render&&(r=e.config.loadingIndicator.render(t));let a=r??Tt();Et(d(`div`,{className:f(`persona-conversation-loading`,a.classList.contains(`persona-conversation-loading-spinner`)&&`persona-conversation-loading--centered`),attrs:{role:`status`,"aria-label":n.openConversationLoadingLabel},style:{maxWidth:e.messagesWrapper.style.maxWidth||`none`}},a))},Ot=t=>{let r=()=>{kt(t,{focusComposer:!0}).catch(()=>{})},i=S()?()=>{X(),gt()}:void 0,a=(e,t)=>{let n=d(`button`,{className:`persona-conversation-loading-error-action`,attrs:{type:`button`},text:e});return n.addEventListener(`click`,t),n},o=()=>d(`div`,{className:`persona-conversation-loading-error-body`},d(`p`,{className:`persona-conversation-loading-error-title`,text:n.openConversationErrorTitle}),d(`div`,{className:`persona-conversation-loading-error-actions`},a(n.openConversationRetryLabel,r),i?a(n.openConversationBackLabel,i):null)),s=Object.freeze({conversationId:t,config:e.config,copy:Object.freeze({title:n.openConversationErrorTitle,retryLabel:n.openConversationRetryLabel,backLabel:n.openConversationBackLabel}),retry:r,...i?{back:i}:{},defaultRenderer:o}),c=null;for(let t of e.plugins)if(t.renderHistoryOpenError){try{c=t.renderHistoryOpenError(s)}catch(e){console.warn(`[persona] renderHistoryOpenError threw`,e),c=null}if(c)break}if(J?.remove(),J=d(`div`,{className:`persona-conversation-loading-error`,attrs:{role:`alert`}},c??o()),!e.session.getActiveConversationId()&&e.session.getMessages().length===0&&!e.composerStore.getState().text&&!e.attachmentManager?.hasAttachments()){let e=J;J=null,Et(e),xt()}else e.body.insertBefore(J,e.messagesWrapper);e.announceHistory(n.openConversationErrorTitle)};e.eventBus.on(`history:closed`,()=>{e.conversationOpenPendingEl&&E(e.footer,!0)});let kt=async(t,{focusComposer:n=!1,busy:r=`reject`}={})=>{let i=w();if(r===`background`&&(e.session.assertBackgroundSwitchable(),e.composerStore.getState().phase===`preparing`))throw new e.SessionHistoryError(`conversation_busy`,`Finish preparing this turn before switching conversations`);if(r===`reject`&&(e.session.isStreaming()||[`paused`,`resuming`].includes(e.session.getStatus())||e.composerStore.getState().phase===`preparing`))throw new e.SessionHistoryError(`conversation_busy`,`Finish or stop the current turn before switching conversations`);r===`stop`&&(++e.composerConversationGeneration,e.submissionAbort?.abort(),e.submissionAbort=null,e.composerStore.setPreparing(!1),e.session.cancel());let a=e.conversationStateKey();e.conversationOpenPendingEl&&e.pendingConversationReading?.key===a||(e.pendingConversationReading={key:a,reading:e.captureConversationReading()});let s=null,c=!!o;o?.view.setActiveConversationId(t),X();let l=yt;Dt(),e.historyVisible&&(e.historyPresentation===`panel`||I)&&q({restoreFocus:!1}),e.suppressScrollSend=!0;try{await e.session.openConversation(t,{scope:i,busy:r,onBeforeCommit:()=>{e.saveConversationContinuity(),s=e.composerConversationGeneration,e.conversationPersistenceOwner=s},onCommitted:()=>{e.restoreConversationContinuity(),e.conversationPersistenceOwner===s&&(e.conversationPersistenceOwner=null),e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),e.persistState()}})}catch(n){if(e.conversationPersistenceOwner===s&&(e.conversationPersistenceOwner=null),s===e.composerConversationGeneration&&e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),l===yt){let n=e.pendingConversationReading?.reading;X(),n&&e.restoreConversationReading(n),e.pendingConversationReading=null,o?.view.setActiveConversationId(e.session.getActiveConversationId()),Ot(t),e.suppressScrollSend=!1}throw n}finally{l!==yt&&e.conversationOpenPendingEl||(e.suppressScrollSend=!1)}l===yt&&(X(),e.pendingConversationReading=null,e.messageCache.clear(),St(),Q(),c||e.setActiveConversationSummary(null),e.eventBus.emit(`history:conversationOpened`,{conversationId:t,title:e.activeConversationTitle,scope:i,timestamp:Date.now()}),n&&e.maybeFocusInput())},At=async({focusComposer:t=!1}={})=>{X();let n=null;try{await e.session.startNewConversation({scope:w(),onBeforeCommit:()=>{e.saveConversationContinuity(),n=e.composerConversationGeneration,e.conversationPersistenceOwner=n},onCommitted:()=>{e.restoreConversationContinuity(!0),e.conversationPersistenceOwner===n&&(e.conversationPersistenceOwner=null),e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),e.persistState(),e.pendingConversationReading=null}})}catch(t){throw e.conversationPersistenceOwner===n&&(e.conversationPersistenceOwner=null),n===e.composerConversationGeneration&&e.usesSessionVoiceForConfig(e.config)&&e.session.setupVoice(),t}e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),e.jumpToBottomInstant(),Q();let r=e.session.getActiveConversationId();o?.view.setActiveConversationId(r),e.eventBus.emit(`history:conversationStarted`,{conversationId:r,timestamp:Date.now()}),e.historyVisible&&(e.historyPresentation===`panel`||I)&&q({restoreFocus:!1}),t&&e.maybeFocusInput()},jt=async(t,n)=>{let r=await e.session.updateConversation(t,{...n,...n.title===void 0?{}:{title:n.title.trim()}});return o?.view.applyConversationSummary(r),!o&&t===e.session.getActiveConversationId()&&e.setActiveConversationSummary(r),r},Mt=async t=>{let n=w(),r=e.session.getActiveConversationId()===t;await e.session.deleteConversation(t,{scope:n}),e.discardConversationContinuity(t),r&&(e.attachmentManager?.destroy({release:!0}),e.attachmentManager=null,e.restoreConversationContinuity(!0)),o?.view.removeConversationSummary(t),r&&(e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),Q()),e.eventBus.emit(`history:conversationDeleted`,{conversationId:t,scope:n,wasActive:r,timestamp:Date.now()})},Nt=async t=>{let n=t?.scope??w(),r=t?.allTargets?null:t?.targetId??te(),i=await e.session.clearConversationHistory({...r?{targetId:r}:{},scope:n});return e.discardConversationContinuity(),e.setActiveConversationSummary(null),e.messageCache.clear(),e.resetAnchorState(),e.resumeAutoScroll(),Q(),e.eventBus.emit(`history:cleared`,{deleted:i.deleted,scope:n,targetId:r,timestamp:Date.now()}),i},Pt=async()=>{if(!r?.resetDevice)throw Error(`[Persona] resetHistoryIdentity() requires a history provider that can reset this device`);let t=!1;try{t=(await e.session.resetHistoryDevice()).remoteRevocationConfirmed}finally{e.discardConversationContinuity(),X(),e.setActiveConversationSummary(null),e.session.clearArtifacts(),e.messageCache.clear(),e.lastAppliedMessages=null,e.config.clearStoredSessionId?.(),e.config.clearStoredConversationId?.(),e.persistentMetadata={},e.actionManager.syncFromMetadata(),e.clearPersistedDraft();let t=e.storageAdapter;t?.clear&&e.runStorageMutation(()=>t.clear(),`[AgentWidget] Failed to clear storage adapter:`),e.resetAnchorState(),e.resumeAutoScroll(),Q(),q({restoreFocus:!1}),e.maybeFocusInput(),e.open||e.launcherSurfaceInstance?.launcher.element.focus()}return e.announceHistory(t?n.identityResetNotice:n.identityResetUnconfirmedNotice),e.eventBus.emit(`history:identityReset`,{remoteRevocationConfirmed:t,timestamp:Date.now()}),{remoteRevocationConfirmed:t}},Ft=()=>e.artifactSplitRoot?e.panel:e.container,It=async t=>{let n=await e.loadHistoryView().catch(()=>null);return typeof n?.showHistoryConfirm==`function`?n.showHistoryConfirm(t):window.confirm(`${t.title}\n\n${t.description}`)},Lt=async e=>await It({host:Ft(),title:n.deleteConversationConfirmTitle,description:n.deleteConversationConfirm,confirmLabel:n.deleteConversationConfirmLabel,cancelLabel:n.confirmCancelLabel})?(await Mt(e),`deleted`):`cancelled`,Rt=async()=>{let e=w()===`verified-user`;return await It({host:Ft(),title:n.clearHistoryConfirmTitle,description:e?n.clearHistoryVerifiedConfirm:n.clearHistoryConfirm,confirmLabel:n.clearHistoryConfirmLabel,cancelLabel:n.confirmCancelLabel})?(await Nt(),`cleared`):`cancelled`},zt=async()=>{if(!await It({host:Ft(),title:n.resetIdentityConfirmTitle,description:n.resetIdentityConfirm,confirmLabel:n.resetIdentityConfirmLabel,cancelLabel:n.confirmCancelLabel}))return{outcome:`cancelled`};let{remoteRevocationConfirmed:e}=await Pt();return{outcome:`reset`,remoteRevocationConfirmed:e}},Z=u(`button`,`persona-history-earlier`);Z.type=`button`,Z.textContent=n.showEarlierMessagesLabel,Z.setAttribute(`data-persona-history-earlier`,``),Object.assign(Z.style,{alignSelf:`center`,minHeight:`44px`,padding:`0 16px`,borderRadius:`999px`,border:`1px solid var(--persona-border, rgba(0,0,0,0.12))`,background:`transparent`,color:`inherit`,font:`inherit`,cursor:`pointer`,flexShrink:`0`});let Q=()=>{S()&&e.historySessionState.nextMessageCursor&&e.session.getActiveConversationId()?(Z.textContent=n.showEarlierMessagesLabel,Z.parentNode!==e.body&&e.body.insertBefore(Z,e.body.firstChild)):Z.remove()};Z.addEventListener(`click`,()=>{let t=e.session.getActiveConversationId(),n=e.historySessionState.nextMessageCursor;if(!t||!n||Z.disabled)return;Z.disabled=!0;let r=e.body.scrollHeight,i=e.body.scrollTop;e.session.loadOlderMessages(t,n,{scope:w()}).then(()=>{e.body.scrollTop=i+(e.body.scrollHeight-r),e.repinAnchoredMessage()}).catch(()=>{}).finally(()=>{Z.disabled=!1,Q()})});let Bt=()=>{let t=e.createHeaderIconButton({ariaLabel:n.openHistoryLabel,iconName:`history`,wrapperClassName:`persona-relative persona-inline-flex persona-items-center persona-justify-center`,extraClassName:`persona-history-toggle`,attrs:{"data-persona-history-toggle":``}});return t.button.addEventListener(`click`,n=>{S()&&!C()&&(e.historyVisible?q():gt({invoker:t.button,keyboard:n.detail===0}))}),t},Vt=()=>{if(!S()){h?.remove(),m=null,h=null;return}if(h&&!h.isConnected&&(m=null,h=null),!m&&e.header){let t=Bt();m=t.button,h=t.wrapper;let n=e.panelElements.clearChatButtonWrapper||e.panelElements.closeButtonWrapper;n?.parentNode&&e.header.contains(n)?n.parentNode.insertBefore(h,n):e.header.appendChild(h)}if(!m||!h)return;let t=W()||e.historyVisible&&e.historyPresentation===`rail`;if(h.style.display=t?`none`:``,t){document.activeElement===m&&ht();return}let r=C();m.disabled=r,m.setAttribute(`aria-disabled`,r?`true`:`false`);let i=r?n.openHistoryBusyLabel:n.openHistoryLabel;m.setAttribute(`aria-label`,i),(e.config.features?.history?.presentation??`panel`)===`panel`?(m.removeAttribute(`aria-expanded`),m.removeAttribute(`aria-controls`)):(m.setAttribute(`aria-expanded`,e.historyVisible?`true`:`false`),m.setAttribute(`aria-controls`,x))},Ht=!1,Ut=()=>{let t=e.panelElements.clearChatButton;t&&(S()?(Ht||=(v=t.getAttribute(`aria-label`)??``,!0),t.setAttribute(`aria-label`,n.newConversationLabel),t.removeAttribute(`title`)):Ht&&(Ht=!1,v&&t.setAttribute(`aria-label`,v)))},$=()=>{n=i(e.config.features?.history?.copy),Vt(),et(),Ut(),Q()};return e.historyChromeSync=$,se(),$(),e.destroyCallbacks.push(()=>{y?.(),b?.(),_+=1,_t(),o?.dispose(),o?.view.destroy(),o=null}),{clearConversationOpenPending:X,cancelConversationOpenTakeover:Y,historyOperationScope:w,discardConversationContinuity:e.discardConversationContinuity,historyAvailable:S,historyScope:ee,installHistoryProvider:se,syncHistoryChromeImpl:$,syncHistoryPresentation:pt,syncEarlierMessagesPill:Q,openHistory:gt,closeHistory:q,openHistoryConversation:kt,startNewConversation:At,updateHistoryConversation:jt,deleteHistoryConversation:Mt,requestDeleteConversation:Lt,clearConversationHistory:Nt,resetHistoryIdentity:Pt,railCollapseShortcut:ze,railCollapsible:we,railTriggerApplies:W,railOverlayMode:ke,toggleRailCollapsed:Re,toggleRailPinned:()=>Le(),get historyProvider(){return r},get historySurface(){return o},get railShell(){return A},get railHost(){return j},get railColumn(){return Se}}};exports.createHistoryShell=oe;
@@ -1,11 +1,10 @@
1
- import { Bo as formatCombo, Ct as AgentWidgetMessage, Ea as renderLucideIcon, Li as ResolvedHistoryPresentation, Mo as AgentWidgetPlugin, Na as HistoryProvider, Pa as HistoryProviderError, Vo as parseCombo, ba as WidgetHistoryInternals, k as AgentWidgetConfig, ni as HistoryConversationSummary, oi as HistoryReturnSurface, q as AgentWidgetControllerEventMap, si as HistoryScope, ti as HistoryConversationPatch, tn as AgentWidgetStorageAdapter, zo as ariaCombo } from "./types-BOZHQIk0.cjs";
2
- import { a as applyBubbleGeometry, u as getBubbleClasses } from "./message-bubble-CkZGlCLC.cjs";
3
- import { Ct as AttachmentManager, h as PanelElements, i as SessionHistoryState, nn as HistoryClientError, r as SessionHistoryError, t as AgentWidgetSession, vt as isDockedMountMode } from "./session-Baxp9iRK.cjs";
4
- import { p as resolveThemeDefaults } from "./defaults-CjX0kKzb.cjs";
5
- import { r as attachTooltip } from "./tooltip-BkW-8MnD.cjs";
6
- import { t as createComposerStore } from "./composer-store-Dw7Zbqxr.cjs";
7
- import { n as HistoryViewHandle, r as HistoryViewOptions, t as showHistoryConfirm } from "./history-confirm-dialog-DJEXsTyE.cjs";
8
- //#region src/components/launcher.d.ts
1
+ import { Ct as AgentWidgetMessage, Go as ariaCombo, Hi as ResolvedHistoryPresentation, Ko as formatCombo, Ra as HistoryProvider, Ro as AgentWidgetPlugin, Ta as WidgetHistoryInternals, di as HistoryReturnSurface, fi as HistoryScope, ja as renderLucideIcon, k as AgentWidgetConfig, oi as HistoryConversationPatch, on as AgentWidgetStorageAdapter, q as AgentWidgetControllerEventMap, qo as parseCombo, si as HistoryConversationSummary, za as HistoryProviderError } from "./types-BC7MRxO5.cjs";
2
+ import { a as applyBubbleGeometry, u as getBubbleClasses } from "./message-bubble-C6AVaH7f.cjs";
3
+ import { Ct as AttachmentManager, h as PanelElements, i as SessionHistoryState, nn as HistoryClientError, r as SessionHistoryError, t as AgentWidgetSession, vt as isDockedMountMode } from "./session-CtZHe7fc.cjs";
4
+ import { p as resolveThemeDefaults } from "./defaults-Bga2Xrsp.cjs";
5
+ import { r as attachTooltip } from "./tooltip-DbXkAuJL.cjs";
6
+ import { t as createComposerStore } from "./composer-store-DhGNgG7Z.cjs";
7
+ import { n as HistoryViewHandle, r as HistoryViewOptions, t as showHistoryConfirm } from "./history-confirm-dialog-i46-lPN_.cjs";
9
8
  interface LauncherButton {
10
9
  element: HTMLButtonElement;
11
10
  update: (config: AgentWidgetConfig) => void;
@@ -30,19 +29,13 @@ interface LauncherSurface {
30
29
  update: (config: AgentWidgetConfig) => void;
31
30
  destroy: () => void;
32
31
  }
33
- //#endregion
34
- //#region src/utils/message-fingerprint.d.ts
35
32
  type MessageCacheEntry = {
36
33
  fingerprint: string;
37
34
  wrapper: HTMLElement;
38
35
  };
39
36
  type MessageCache = Map<string, MessageCacheEntry>;
40
- //#endregion
41
- //#region src/utils/voice-support.d.ts
42
37
  /** Custom STT review is owned by the composer; a separate dictation provider can coexist with voice. */
43
38
  declare function usesSessionVoiceForConfig(config: AgentWidgetConfig): boolean;
44
- //#endregion
45
- //#region src/history-render.d.ts
46
39
  interface HistoryRenderSurface {
47
40
  readonly view: HistoryViewHandle;
48
41
  /** Currently arbitrated element: the default view, or a plugin's. */
@@ -52,26 +45,18 @@ interface HistoryRenderSurface {
52
45
  /** Runs pending cleanups and makes `requestRender()` inert. */
53
46
  dispose(): void;
54
47
  }
55
- //#endregion
56
- //#region src/internal/history-provider-registry.d.ts
57
48
  type HistoryProviderFactory = () => HistoryProvider;
58
49
  /** Non-destructive: each widget instance builds its own provider. */
59
50
  declare function getHistoryProviderFactory(): HistoryProviderFactory | null;
60
- //#endregion
61
- //#region src/internal/runtype-history-provider.d.ts
62
51
  type HistoryErrorClasses = {
63
52
  HistoryClientError: typeof HistoryClientError;
64
53
  HistoryProviderError: typeof HistoryProviderError;
65
54
  };
66
- //#endregion
67
- //#region src/history-view-loader.d.ts
68
55
  type HistoryViewModule = {
69
56
  createHistoryView: (options: HistoryViewOptions) => HistoryViewHandle;
70
57
  showHistoryConfirm: typeof showHistoryConfirm;
71
58
  };
72
59
  declare const loadHistoryView: () => Promise<HistoryViewModule>;
73
- //#endregion
74
- //#region src/components/header-parts.d.ts
75
60
  interface HeaderIconButtonParts {
76
61
  button: HTMLButtonElement;
77
62
  wrapper: HTMLElement;
@@ -126,8 +111,6 @@ interface CreateHeaderIconButtonOptions {
126
111
  * token-driven stylesheet rules.
127
112
  */
128
113
  declare const createHeaderIconButton: (options: CreateHeaderIconButtonOptions) => HeaderIconButtonParts;
129
- //#endregion
130
- //#region src/utils/events.d.ts
131
114
  type EventContext = Readonly<{
132
115
  instanceId: string;
133
116
  }>;
@@ -139,8 +122,6 @@ declare const createEventBus: <EventMap extends Record<string, any>>(context?: E
139
122
  emit: <K extends keyof EventMap>(event: K, payload: EventMap[K]) => void;
140
123
  dispose: () => void;
141
124
  };
142
- //#endregion
143
- //#region src/history-shell.d.ts
144
125
  /** The widget closure state the shell reads and writes. */
145
126
  export type ConversationReadingState = {
146
127
  top: number;
@@ -308,5 +289,5 @@ export declare const createHistoryShell: (ctx: HistoryShellContext) => {
308
289
  readonly railColumn: HTMLElement | null;
309
290
  };
310
291
  export type HistoryShell = ReturnType<typeof createHistoryShell>;
311
- //#endregion
292
+ export {};
312
293
  export {}
@@ -1,11 +1,10 @@
1
- import { Bo as formatCombo, Ct as AgentWidgetMessage, Ea as renderLucideIcon, Li as ResolvedHistoryPresentation, Mo as AgentWidgetPlugin, Na as HistoryProvider, Pa as HistoryProviderError, Vo as parseCombo, ba as WidgetHistoryInternals, k as AgentWidgetConfig, ni as HistoryConversationSummary, oi as HistoryReturnSurface, q as AgentWidgetControllerEventMap, si as HistoryScope, ti as HistoryConversationPatch, tn as AgentWidgetStorageAdapter, zo as ariaCombo } from "./types-BOZHQIk0.js";
2
- import { a as applyBubbleGeometry, u as getBubbleClasses } from "./message-bubble-CkZGlCLC.js";
3
- import { Ct as AttachmentManager, h as PanelElements, i as SessionHistoryState, nn as HistoryClientError, r as SessionHistoryError, t as AgentWidgetSession, vt as isDockedMountMode } from "./session-Baxp9iRK.js";
4
- import { p as resolveThemeDefaults } from "./defaults-CjX0kKzb.js";
5
- import { r as attachTooltip } from "./tooltip-BkW-8MnD.js";
6
- import { t as createComposerStore } from "./composer-store-Dw7Zbqxr.js";
7
- import { n as HistoryViewHandle, r as HistoryViewOptions, t as showHistoryConfirm } from "./history-confirm-dialog-DJEXsTyE.js";
8
- //#region src/components/launcher.d.ts
1
+ import { Ct as AgentWidgetMessage, Go as ariaCombo, Hi as ResolvedHistoryPresentation, Ko as formatCombo, Ra as HistoryProvider, Ro as AgentWidgetPlugin, Ta as WidgetHistoryInternals, di as HistoryReturnSurface, fi as HistoryScope, ja as renderLucideIcon, k as AgentWidgetConfig, oi as HistoryConversationPatch, on as AgentWidgetStorageAdapter, q as AgentWidgetControllerEventMap, qo as parseCombo, si as HistoryConversationSummary, za as HistoryProviderError } from "./types-BC7MRxO5.js";
2
+ import { a as applyBubbleGeometry, u as getBubbleClasses } from "./message-bubble-C6AVaH7f.js";
3
+ import { Ct as AttachmentManager, h as PanelElements, i as SessionHistoryState, nn as HistoryClientError, r as SessionHistoryError, t as AgentWidgetSession, vt as isDockedMountMode } from "./session-CtZHe7fc.js";
4
+ import { p as resolveThemeDefaults } from "./defaults-Bga2Xrsp.js";
5
+ import { r as attachTooltip } from "./tooltip-DbXkAuJL.js";
6
+ import { t as createComposerStore } from "./composer-store-DhGNgG7Z.js";
7
+ import { n as HistoryViewHandle, r as HistoryViewOptions, t as showHistoryConfirm } from "./history-confirm-dialog-i46-lPN_.js";
9
8
  interface LauncherButton {
10
9
  element: HTMLButtonElement;
11
10
  update: (config: AgentWidgetConfig) => void;
@@ -30,19 +29,13 @@ interface LauncherSurface {
30
29
  update: (config: AgentWidgetConfig) => void;
31
30
  destroy: () => void;
32
31
  }
33
- //#endregion
34
- //#region src/utils/message-fingerprint.d.ts
35
32
  type MessageCacheEntry = {
36
33
  fingerprint: string;
37
34
  wrapper: HTMLElement;
38
35
  };
39
36
  type MessageCache = Map<string, MessageCacheEntry>;
40
- //#endregion
41
- //#region src/utils/voice-support.d.ts
42
37
  /** Custom STT review is owned by the composer; a separate dictation provider can coexist with voice. */
43
38
  declare function usesSessionVoiceForConfig(config: AgentWidgetConfig): boolean;
44
- //#endregion
45
- //#region src/history-render.d.ts
46
39
  interface HistoryRenderSurface {
47
40
  readonly view: HistoryViewHandle;
48
41
  /** Currently arbitrated element: the default view, or a plugin's. */
@@ -52,26 +45,18 @@ interface HistoryRenderSurface {
52
45
  /** Runs pending cleanups and makes `requestRender()` inert. */
53
46
  dispose(): void;
54
47
  }
55
- //#endregion
56
- //#region src/internal/history-provider-registry.d.ts
57
48
  type HistoryProviderFactory = () => HistoryProvider;
58
49
  /** Non-destructive: each widget instance builds its own provider. */
59
50
  declare function getHistoryProviderFactory(): HistoryProviderFactory | null;
60
- //#endregion
61
- //#region src/internal/runtype-history-provider.d.ts
62
51
  type HistoryErrorClasses = {
63
52
  HistoryClientError: typeof HistoryClientError;
64
53
  HistoryProviderError: typeof HistoryProviderError;
65
54
  };
66
- //#endregion
67
- //#region src/history-view-loader.d.ts
68
55
  type HistoryViewModule = {
69
56
  createHistoryView: (options: HistoryViewOptions) => HistoryViewHandle;
70
57
  showHistoryConfirm: typeof showHistoryConfirm;
71
58
  };
72
59
  declare const loadHistoryView: () => Promise<HistoryViewModule>;
73
- //#endregion
74
- //#region src/components/header-parts.d.ts
75
60
  interface HeaderIconButtonParts {
76
61
  button: HTMLButtonElement;
77
62
  wrapper: HTMLElement;
@@ -126,8 +111,6 @@ interface CreateHeaderIconButtonOptions {
126
111
  * token-driven stylesheet rules.
127
112
  */
128
113
  declare const createHeaderIconButton: (options: CreateHeaderIconButtonOptions) => HeaderIconButtonParts;
129
- //#endregion
130
- //#region src/utils/events.d.ts
131
114
  type EventContext = Readonly<{
132
115
  instanceId: string;
133
116
  }>;
@@ -139,8 +122,6 @@ declare const createEventBus: <EventMap extends Record<string, any>>(context?: E
139
122
  emit: <K extends keyof EventMap>(event: K, payload: EventMap[K]) => void;
140
123
  dispose: () => void;
141
124
  };
142
- //#endregion
143
- //#region src/history-shell.d.ts
144
125
  /** The widget closure state the shell reads and writes. */
145
126
  export type ConversationReadingState = {
146
127
  top: number;
@@ -308,5 +289,5 @@ export declare const createHistoryShell: (ctx: HistoryShellContext) => {
308
289
  readonly railColumn: HTMLElement | null;
309
290
  };
310
291
  export type HistoryShell = ReturnType<typeof createHistoryShell>;
311
- //#endregion
292
+ export {};
312
293
  export {}