@runtypelabs/persona 4.25.0 → 4.26.1

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 (236) hide show
  1. package/dist/animations/glyph-cycle.d.cts +1 -1
  2. package/dist/animations/glyph-cycle.d.ts +1 -1
  3. package/dist/animations/{types-Db61aI9J.d.cts → types-BwKTZhg9.d.cts} +14 -0
  4. package/dist/animations/{types-Db61aI9J.d.ts → types-BwKTZhg9.d.ts} +14 -0
  5. package/dist/animations/wipe.d.cts +1 -1
  6. package/dist/animations/wipe.d.ts +1 -1
  7. package/dist/animations-extra.d.cts +14 -0
  8. package/dist/animations-extra.d.ts +14 -0
  9. package/dist/approval-ui-QAKWNFNM.js +1 -0
  10. package/dist/approval-ui.cjs +2 -2
  11. package/dist/approval-ui.d.cts +186 -8
  12. package/dist/approval-ui.d.ts +186 -8
  13. package/dist/approval-ui.js +2 -2
  14. package/dist/{artifacts-ui-IGB5YKLO.js → artifacts-ui-NJGMM27I.js} +1 -1
  15. package/dist/artifacts-ui.cjs +4 -4
  16. package/dist/artifacts-ui.d.cts +186 -8
  17. package/dist/artifacts-ui.d.ts +186 -8
  18. package/dist/artifacts-ui.js +5 -5
  19. package/dist/chunk-2ANTRKTV.js +1 -0
  20. package/dist/chunk-4HPTPUC6.js +1 -0
  21. package/dist/chunk-6V3MNEKB.js +1 -0
  22. package/dist/chunk-GKPCIQPB.js +1 -0
  23. package/dist/chunk-HGUCGM3K.js +9 -0
  24. package/dist/chunk-IO5VVUKP.js +3 -0
  25. package/dist/chunk-J4J3Y2P2.js +1 -0
  26. package/dist/chunk-K6HKIP5K.js +1 -0
  27. package/dist/chunk-K7NA7G7J.js +1 -0
  28. package/dist/chunk-MXUTS3LB.js +1 -0
  29. package/dist/chunk-PDPVORUF.js +1 -0
  30. package/dist/chunk-QRKGQPU7.js +1 -0
  31. package/dist/chunk-S6PBWE75.js +1 -0
  32. package/dist/chunk-T7QM7YMF.js +1 -0
  33. package/dist/chunk-TR2H475E.js +1 -0
  34. package/dist/chunk-UPO4GUFC.js +1 -0
  35. package/dist/chunk-ZC66NAIR.js +1 -0
  36. package/dist/client-history-GOZWBDA5.js +1 -0
  37. package/dist/client-history.js +1 -0
  38. package/dist/client-stream-42FOI3EC.js +4 -0
  39. package/dist/client-stream.js +5 -0
  40. package/dist/codegen.cjs +1 -1
  41. package/dist/codegen.js +1 -1
  42. package/dist/context-mentions-E7HJYWO6.js +161 -0
  43. package/dist/{context-mentions-inline-I2RDEBAK.js → context-mentions-inline-QVESLW55.js} +1 -1
  44. package/dist/context-mentions.cjs +7 -7
  45. package/dist/context-mentions.d.cts +186 -8
  46. package/dist/context-mentions.d.ts +186 -8
  47. package/dist/context-mentions.js +8 -8
  48. package/dist/event-stream-view-FOIJHFQO.js +1 -0
  49. package/dist/event-stream-view.cjs +1 -1
  50. package/dist/event-stream-view.d.cts +189 -31
  51. package/dist/event-stream-view.d.ts +189 -31
  52. package/dist/event-stream-view.js +1 -1
  53. package/dist/forms-ui.d.cts +227 -667
  54. package/dist/forms-ui.d.ts +227 -667
  55. package/dist/history-shell-QDQ44PSE.js +3 -0
  56. package/dist/history-shell.js +3 -0
  57. package/dist/{history-view-BD6OXLNA.js → history-view-NCFBI5GR.js} +2 -2
  58. package/dist/history-view.cjs +2 -2
  59. package/dist/history-view.d.cts +35 -1
  60. package/dist/history-view.d.ts +35 -1
  61. package/dist/history-view.js +2 -2
  62. package/dist/index.cjs +80 -74
  63. package/dist/index.cjs.map +1 -1
  64. package/dist/index.d.cts +233 -738
  65. package/dist/index.d.ts +233 -738
  66. package/dist/index.global.js +3 -215
  67. package/dist/index.global.js.map +1 -1
  68. package/dist/index.js +81 -75
  69. package/dist/index.js.map +1 -1
  70. package/dist/install.global.js +1 -1
  71. package/dist/install.global.js.map +1 -1
  72. package/dist/launcher.global.js +3 -67
  73. package/dist/launcher.global.js.map +1 -1
  74. package/dist/markdown-parsers.js +22 -22
  75. package/dist/runtype-tts-entry-NFBVWR7N.js +1 -0
  76. package/dist/runtype-tts.js +1 -1
  77. package/dist/session-actions-ISSKSI66.js +1 -0
  78. package/dist/session-actions.js +1 -0
  79. package/dist/session-reconnect.d.cts +186 -8
  80. package/dist/session-reconnect.d.ts +186 -8
  81. package/dist/smart-dom-reader.cjs +13 -13
  82. package/dist/smart-dom-reader.d.cts +186 -8
  83. package/dist/smart-dom-reader.d.ts +186 -8
  84. package/dist/smart-dom-reader.js +11 -11
  85. package/dist/theme-editor-preview.cjs +116 -98
  86. package/dist/theme-editor-preview.d.cts +188 -8
  87. package/dist/theme-editor-preview.d.ts +188 -8
  88. package/dist/theme-editor-preview.js +49 -54
  89. package/dist/theme-editor.cjs +2 -2
  90. package/dist/theme-editor.d.cts +187 -23
  91. package/dist/theme-editor.d.ts +187 -23
  92. package/dist/theme-editor.js +2 -2
  93. package/dist/theme-reference.d.cts +14 -0
  94. package/dist/theme-reference.d.ts +14 -0
  95. package/dist/ui-extras-entry-WAYFKVNW.js +3 -0
  96. package/dist/ui-extras.js +72 -0
  97. package/dist/voice-runtime-XLU6YK2N.js +17 -0
  98. package/dist/voice-runtime.cjs +17 -1
  99. package/dist/voice-runtime.d.cts +11656 -232
  100. package/dist/voice-runtime.d.ts +11656 -232
  101. package/dist/voice-runtime.js +17 -1
  102. package/dist/voice-worklet-player.cjs +19 -4
  103. package/dist/voice-worklet-player.d.cts +9 -10
  104. package/dist/voice-worklet-player.d.ts +9 -10
  105. package/dist/voice-worklet-player.js +19 -4
  106. package/dist/webmcp-polyfill.js +1 -1
  107. package/dist/webmcp-runtime-V6ZWW3PI.js +6 -0
  108. package/dist/webmcp-runtime.cjs +2 -2
  109. package/dist/webmcp-runtime.d.cts +1 -33
  110. package/dist/webmcp-runtime.d.ts +1 -33
  111. package/dist/webmcp-runtime.js +2 -2
  112. package/dist/widget.css +1 -1
  113. package/package.json +11 -5
  114. package/src/approval-paused-tool-settle.test.ts +325 -0
  115. package/src/client-approve.test.ts +311 -0
  116. package/src/client-history-eager.ts +9 -0
  117. package/src/client-history-loader.ts +23 -0
  118. package/src/client-history.ts +579 -0
  119. package/src/client-resume.ts +177 -0
  120. package/src/client-stream-eager.ts +12 -0
  121. package/src/client-stream-loader.ts +25 -0
  122. package/src/client-stream.ts +1880 -0
  123. package/src/client.test.ts +31 -1
  124. package/src/client.ts +293 -2607
  125. package/src/components/approval-actions.test.ts +27 -0
  126. package/src/components/approval-actions.ts +27 -3
  127. package/src/components/message-bubble.test.ts +19 -0
  128. package/src/components/message-bubble.ts +2 -0
  129. package/src/components/registry.ts +6 -6
  130. package/src/components/tool-bubble.test.ts +9 -0
  131. package/src/components/tool-bubble.ts +1 -0
  132. package/src/history-shell-bundle.test.ts +54 -0
  133. package/src/history-shell-eager.ts +12 -0
  134. package/src/history-shell-loader.ts +27 -0
  135. package/src/history-shell.ts +2362 -0
  136. package/src/history-view-loader.ts +2 -0
  137. package/src/history-view.ts +3 -0
  138. package/src/index-core.ts +6 -0
  139. package/src/index-global.ts +90 -248
  140. package/src/index.ts +13 -0
  141. package/src/install.ts +6 -4
  142. package/src/internal/runtype-history-provider.test.ts +1 -0
  143. package/src/internal/runtype-history-provider.ts +28 -13
  144. package/src/plugins/registry.ts +8 -8
  145. package/src/session-actions-chunk.test.ts +55 -0
  146. package/src/session-actions-eager.ts +11 -0
  147. package/src/session-actions-loader.ts +37 -0
  148. package/src/session-actions.ts +909 -0
  149. package/src/session-history.test.ts +3 -1
  150. package/src/session.ts +895 -1538
  151. package/src/session.voice.test.ts +1171 -5
  152. package/src/styles/widget.css +58 -0
  153. package/src/theme-editor/state.ts +91 -91
  154. package/src/types.ts +204 -5
  155. package/src/ui-ask-user-sheet.ts +382 -0
  156. package/src/ui-extras-eager.ts +10 -0
  157. package/src/ui-extras-entry.ts +9 -0
  158. package/src/ui-extras-loader.ts +26 -0
  159. package/src/ui.artifact-rail-resize.test.ts +2 -1
  160. package/src/ui.ask-user-chunk.test.ts +93 -0
  161. package/src/ui.history-chunk.test.ts +2 -1
  162. package/src/ui.history-config-provider.test.ts +2 -1
  163. package/src/ui.history-confirm-fallback.test.ts +142 -0
  164. package/src/ui.history-controller.test.ts +2 -1
  165. package/src/ui.history-lifecycle.test.ts +2 -1
  166. package/src/ui.history-render-hooks.test.ts +2 -1
  167. package/src/ui.history-shell.test.ts +2 -1
  168. package/src/ui.rail-overlay.test.ts +2 -1
  169. package/src/ui.rail-resize.test.ts +2 -1
  170. package/src/ui.rail-trigger-pending.test.ts +2 -1
  171. package/src/ui.ts +340 -2770
  172. package/src/utils/attachment-manager.ts +67 -67
  173. package/src/utils/constants.ts +3 -0
  174. package/src/utils/context-mention-controller.ts +323 -323
  175. package/src/utils/context-mention-manager.ts +40 -40
  176. package/src/utils/context-mention-orchestrator.ts +28 -0
  177. package/src/utils/event-stream-buffer.ts +50 -50
  178. package/src/utils/event-stream-store.ts +43 -43
  179. package/src/utils/throughput-tracker.ts +34 -34
  180. package/src/utils/virtual-scroller.ts +67 -67
  181. package/src/utils/visitor-store.test.ts +50 -0
  182. package/src/utils/visitor-store.ts +23 -5
  183. package/src/voice/__fixtures__/voice-wire/README.md +1 -0
  184. package/src/voice/__fixtures__/voice-wire/client/cancel.json +3 -0
  185. package/src/voice/__fixtures__/voice-wire/client/context.json +4 -0
  186. package/src/voice/__fixtures__/voice-wire/client/delegation_result.json +6 -0
  187. package/src/voice/__fixtures__/voice-wire/client/delegation_update.json +6 -0
  188. package/src/voice/__fixtures__/voice-wire/client/ping.json +3 -0
  189. package/src/voice/__fixtures__/voice-wire/client/playback_progress.json +5 -0
  190. package/src/voice/__fixtures__/voice-wire/client/start.json +3 -0
  191. package/src/voice/__fixtures__/voice-wire/server/artifact.json +11 -0
  192. package/src/voice/__fixtures__/voice-wire/server/attached.json +4 -0
  193. package/src/voice/__fixtures__/voice-wire/server/audio_clear.json +4 -0
  194. package/src/voice/__fixtures__/voice-wire/server/audio_end.json +3 -0
  195. package/src/voice/__fixtures__/voice-wire/server/delegation_cancelled.json +5 -0
  196. package/src/voice/__fixtures__/voice-wire/server/delegation_completed.json +8 -0
  197. package/src/voice/__fixtures__/voice-wire/server/delegation_started.json +15 -0
  198. package/src/voice/__fixtures__/voice-wire/server/error.json +6 -0
  199. package/src/voice/__fixtures__/voice-wire/server/metrics.json +10 -0
  200. package/src/voice/__fixtures__/voice-wire/server/pong.json +3 -0
  201. package/src/voice/__fixtures__/voice-wire/server/session_config.json +16 -0
  202. package/src/voice/__fixtures__/voice-wire/server/transcript_final.json +7 -0
  203. package/src/voice/__fixtures__/voice-wire/server/transcript_interim.json +4 -0
  204. package/src/voice/__fixtures__/voice-wire/server/transcript_partial.json +6 -0
  205. package/src/voice/__fixtures__/voice-wire/server/transcript_update.json +10 -0
  206. package/src/voice/__fixtures__/voice-wire/server/warning.json +5 -0
  207. package/src/voice/audio-playback-manager.test.ts +57 -0
  208. package/src/voice/audio-playback-manager.ts +120 -98
  209. package/src/voice/browser-voice-provider.ts +37 -37
  210. package/src/voice/fallback-speech-engine.ts +22 -16
  211. package/src/voice/keyed-voice-transcript.ts +314 -0
  212. package/src/voice/mic-state-styles.ts +182 -0
  213. package/src/voice/read-aloud-controller.ts +46 -44
  214. package/src/voice/runtype-speech-engine.ts +35 -33
  215. package/src/voice/runtype-voice-provider.ts +680 -189
  216. package/src/voice/session-voice-wiring.ts +266 -0
  217. package/src/voice/voice-delegation.test.ts +71 -0
  218. package/src/voice/voice-delegation.ts +364 -0
  219. package/src/voice/voice-turn-tracker.ts +6 -6
  220. package/src/voice/voice.test.ts +1060 -8
  221. package/src/voice/worklet-playback-engine.test.ts +81 -0
  222. package/src/voice/worklet-playback-engine.ts +21 -3
  223. package/src/voice-runtime-loader.ts +4 -1
  224. package/src/voice-runtime.ts +7 -0
  225. package/src/webmcp-runtime-entry.ts +41 -39
  226. package/dist/approval-ui-3NMYNXBD.js +0 -1
  227. package/dist/chunk-5EIIHQLQ.js +0 -1
  228. package/dist/chunk-7CO4T5KB.js +0 -1
  229. package/dist/chunk-EFJBUH5F.js +0 -1
  230. package/dist/chunk-R2TMIMDI.js +0 -3
  231. package/dist/chunk-UTVLOTWB.js +0 -9
  232. package/dist/context-mentions-45MODWOY.js +0 -161
  233. package/dist/event-stream-view-GL3ADRY2.js +0 -1
  234. package/dist/runtype-tts-entry-UJAEF7NZ.js +0 -1
  235. package/dist/voice-runtime-7DA7MJH4.js +0 -1
  236. package/dist/webmcp-runtime-JI7T4QYF.js +0 -6
@@ -1,4 +1,4 @@
1
- "use strict";var Ie=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var Yt=(e,t)=>{for(var o in t)Ie(e,o,{get:t[o],enumerable:!0})},jt=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Bt(t))!Wt.call(e,a)&&a!==o&&Ie(e,a,{get:()=>t[a],enumerable:!(i=Kt(t,a))||i.enumerable});return e};var Gt=e=>jt(Ie({},"__esModule",{value:!0}),e);var br={};Yt(br,{HISTORY_VIEW_COPY_DEFAULTS:()=>te,createHistoryView:()=>$e,resolveHistoryViewCopy:()=>re});module.exports=Gt(br);var me=e=>e.nodeType===Node.DOCUMENT_NODE,lt=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host!==void 0;function at(e){let t=e.getRootNode?.();return t&&lt(t)||t&&me(t)?t:e.ownerDocument??document}function he(e,t,o){let i=me(e)?e.head:e,a=t.replace(/["\\]/g,"\\$&");if(i.querySelector(`style[data-persona-plugin-style="${a}"]`))return;let u=(me(e)?e:e.ownerDocument??document).createElement("style");u.setAttribute("data-persona-plugin-style",t),u.textContent=o,i.appendChild(u)}function pt(e,t,o){if(me(e)||lt(e)){he(e,t,o);return}let i=e;if(i.isConnected){he(at(i),t,o);return}let a=i.ownerDocument??document;he(a,t,o),queueMicrotask(()=>{let l=at(i);l!==a&&he(l,t,o)})}var s=(e,t={},...o)=>{let i=document.createElement(e);if(t.className&&(i.className=t.className),t.text!==void 0&&(i.textContent=t.text),t.attrs)for(let[l,u]of Object.entries(t.attrs))i.setAttribute(l,u);if(t.style){let l=i.style,u=t.style;for(let c of Object.keys(u)){let h=u[c];h!=null&&(l[c]=h)}}let a=o.filter(l=>l!=null);return a.length>0&&i.append(...a),i},T=(...e)=>e.filter(Boolean).join(" ");function dt(){let e=document.createElement("div");e.className="persona-history-sr-only",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-persona-history-live-region","");let t;return{element:e,announce(o){t!==void 0&&clearTimeout(t),e.textContent="",t=setTimeout(()=>{t=void 0,e.textContent=o},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}var ct=`
1
+ "use strict";var Oe=Object.defineProperty;var Wt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Yt=Object.prototype.hasOwnProperty;var jt=(e,t)=>{for(var o in t)Oe(e,o,{get:t[o],enumerable:!0})},Gt=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Bt(t))!Yt.call(e,a)&&a!==o&&Oe(e,a,{get:()=>t[a],enumerable:!(i=Wt(t,a))||i.enumerable});return e};var Ut=e=>Gt(Oe({},"__esModule",{value:!0}),e);var xr={};jt(xr,{HISTORY_VIEW_COPY_DEFAULTS:()=>oe,createHistoryView:()=>$e,resolveHistoryViewCopy:()=>ne,showHistoryConfirm:()=>Ht});module.exports=Ut(xr);var ve=e=>e.nodeType===Node.DOCUMENT_NODE,pt=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host!==void 0;function lt(e){let t=e.getRootNode?.();return t&&pt(t)||t&&ve(t)?t:e.ownerDocument??document}function me(e,t,o){let i=ve(e)?e.head:e,a=t.replace(/["\\]/g,"\\$&");if(i.querySelector(`style[data-persona-plugin-style="${a}"]`))return;let d=(ve(e)?e:e.ownerDocument??document).createElement("style");d.setAttribute("data-persona-plugin-style",t),d.textContent=o,i.appendChild(d)}function dt(e,t,o){if(ve(e)||pt(e)){me(e,t,o);return}let i=e;if(i.isConnected){me(lt(i),t,o);return}let a=i.ownerDocument??document;me(a,t,o),queueMicrotask(()=>{let l=lt(i);l!==a&&me(l,t,o)})}var s=(e,t={},...o)=>{let i=document.createElement(e);if(t.className&&(i.className=t.className),t.text!==void 0&&(i.textContent=t.text),t.attrs)for(let[l,d]of Object.entries(t.attrs))i.setAttribute(l,d);if(t.style){let l=i.style,d=t.style;for(let c of Object.keys(d)){let y=d[c];y!=null&&(l[c]=y)}}let a=o.filter(l=>l!=null);return a.length>0&&i.append(...a),i},T=(...e)=>e.filter(Boolean).join(" ");function ct(){let e=document.createElement("div");e.className="persona-history-sr-only",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-persona-history-live-region","");let t;return{element:e,announce(o){t!==void 0&&clearTimeout(t),e.textContent="",t=setTimeout(()=>{t=void 0,e.textContent=o},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}var yt=`
2
2
  .persona-history-view {
3
3
  --persona-history-surface-bg: var(--persona-surface, #ffffff);
4
4
  --persona-history-topbar-bg: var(--persona-header-bg, var(--persona-surface, #ffffff));
@@ -895,4 +895,4 @@
895
895
  .persona-history-view .persona-history-skeleton-bar { animation: none; }
896
896
  .persona-history-rail-host { transition: none; }
897
897
  }
898
- `;var yt={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."};var te={...yt,emptyTitle:"No conversations yet",emptyDescription:"Start a conversation and it will show up here.",errorTitle:"Could not load conversations",errorDescription:"Something went wrong. Please try again.",retryLabel:"Retry",rateLimitedTitle:"Too many requests",rateLimitedDescription:"Please wait a moment before trying again.",groupStarred:"Starred",groupToday:"Today",groupYesterday:"Yesterday",groupPrevious7Days:"Previous 7 days",groupPrevious30Days:"Previous 30 days",groupMonthYear:"{month} {year}",browserOnlyTitle:"On this device",browserOnlyDescription:"Another browser or device keeps its own separate history.",verifyingTitle:"Checking your account",verifyingDescription:"Looking for messages linked to your account.",verifiedTitle:"Available across signed-in devices",verifiedDescription:"This list refreshes when the chat opens rather than syncing live.",authenticationRequiredTitle:"Sign in to see your messages",authenticationRequiredDescription:"Your session expired. Sign in again to load account history.",identityProviderFailedTitle:"Account history is unavailable",identityProviderFailedDescription:"We could not verify your account, so account history is not shown here.",proofNotAdmittedTitle:"Account history is unavailable",proofNotAdmittedDescription:"This assistant is not set up to accept your account identity.",retryIdentityLabel:"Try again",backLabel:"Back to conversation",closeLabel:"Close conversation list",loadingLabel:"Loading conversations",loadMoreLabel:"Load more",loadingMoreLabel:"Loading more conversations",conversationsTitle:"Conversations",rowActionsLabel:"Conversation options",listOptionsLabel:"Conversation options",deleteConversationLabel:"Delete",clearHistoryLabel:"Delete all conversations",resetIdentityLabel:"Forget this device",messageCountLabel:"{count} messages",messageCountLabelOne:"1 message",conversationRemovedNotice:"Conversation deleted.",historyClearedNotice:"All conversations were deleted.",unavailableTitle:"Conversation history is unavailable",unavailableDescription:"Try again later.",newConversationRequiredTitle:"Start a new conversation",newConversationRequiredDescription:"The previous conversation is gone. Start a new one to keep chatting.",rateLimitedWaitDescription:"You can try again in {seconds} seconds.",openFailedLabel:"Could not open that conversation.",deleteFailedLabel:"Could not delete that conversation.",relativeNow:"now",relativeMinutes:"{value}m",relativeHours:"{value}h",relativeDays:"{value}d",relativeWeeks:"{value}w",relativeYears:"{value}y"};function re(e){if(!e)return te;let t={...te};for(let[o,i]of Object.entries(e))typeof i=="string"&&i.length>0&&(t[o]=i);return t}function E(e,t){return e.replace(/\{(\w+)\}/g,(o,i)=>i in t?String(t[i]):o)}var Oe=864e5;function Ut(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Ve(e,t){let o=Date.parse(e);return Number.isFinite(o)?o:t}function Xt(e,t){let o=Ve(e,t),i=Ut(t);if(o>=i)return"today";if(o>=i-Oe)return"yesterday";if(o>=i-7*Oe)return"previous-7-days";if(o>=i-30*Oe)return"previous-30-days";let a=new Date(o);return`month:${a.getFullYear()}-${a.getMonth()}`}function Zt(e,t,o,i){if(e==="today")return i.groupToday;if(e==="yesterday")return i.groupYesterday;if(e==="previous-7-days")return i.groupPrevious7Days;if(e==="previous-30-days")return i.groupPrevious30Days;let a=new Date(Ve(t,o));return E(i.groupMonthYear,{month:a.toLocaleString(void 0,{month:"long"}),year:a.getFullYear()})}function ut(e,t,o,i="time"){let a=e.filter(u=>u.starred),l=a.length>0?[{key:"starred",label:o.groupStarred,items:a}]:[];if(i==="none"){let u=e.filter(c=>!c.starred);return u.length>0&&l.push({key:"recent",label:o.conversationsTitle,items:u}),l}for(let u of e){if(u.starred)continue;let c=Xt(u.updatedAt,t),h=l[l.length-1];if(h&&h.key===c){h.items.push(u);continue}l.push({key:c,label:Zt(c,u.updatedAt,t,o),items:[u]})}return l}function ht(e,t,o){let i=Math.max(0,t-Ve(e,t)),a=Math.floor(i/6e4);if(a<1)return o.relativeNow;if(a<60)return E(o.relativeMinutes,{value:a});let l=Math.floor(a/60);if(l<24)return E(o.relativeHours,{value:l});let u=Math.floor(l/24);if(u<7)return E(o.relativeDays,{value:u});let c=Math.floor(u/7);return u<365?E(o.relativeWeeks,{value:c}):E(o.relativeYears,{value:Math.floor(u/365)})}function mt(e,t){return e===1?t.messageCountLabelOne:E(t.messageCountLabel,{count:e})}var ve="http://www.w3.org/2000/svg",Jt={"arrow-left":["m12 19-7-7 7-7","M19 12H5"],plus:["M5 12h14","M12 5v14"],star:["m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z"],x:["M18 6 6 18","m6 6 12 12"],"panel-left":["M9 3v18"],monitor:["M8 21h8","M12 17v4"],ellipsis:[]},Qt={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function _(e,t=20){let o=document.createElementNS(ve,"svg");if(o.setAttribute("width",String(t)),o.setAttribute("height",String(t)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),e==="ellipsis"){for(let a of[12,19,5]){let l=document.createElementNS(ve,"circle");l.setAttribute("cx",String(a)),l.setAttribute("cy","12"),l.setAttribute("r","1"),o.appendChild(l)}return o}let i=Qt[e];if(i){let a=document.createElementNS(ve,"rect");a.setAttribute("x",String(i[0])),a.setAttribute("y",String(i[1])),a.setAttribute("width",String(i[2])),a.setAttribute("height",String(i[3])),a.setAttribute("rx","2"),o.appendChild(a)}for(let a of Jt[e]){let l=document.createElementNS(ve,"path");l.setAttribute("d",a),o.appendChild(l)}return o}var er=/^(https?:|\/|data:)/i;function tr(e){let t=s("span",{className:"persona-history-row-avatar",attrs:{"aria-hidden":"true"}});return er.test(e)?t.appendChild(s("img",{attrs:{src:e,alt:"",loading:"lazy"}})):t.textContent=e,t}var rr=e=>`row:${e}`,or=e=>`menu:${e}`,oe=e=>`menu-item:${e}`;function vt(e){let{conversation:t,copy:o,busy:i,pending:a}=e,l=i||a!==null,u=t.title.trim().length>0,c=t.starred?(()=>{let M=_("star",11);return M.setAttribute("fill","currentColor"),M.setAttribute("stroke-width","1"),s("span",{className:"persona-history-row-star"},M,s("span",{className:"persona-history-sr-only",text:o.groupStarred}))})():null,h=s("div",{className:"persona-history-row-head"},s("span",{className:"persona-history-row-title persona-history-truncate",text:u?t.title:t.preview??""}),c,s("time",{className:"persona-history-row-time",attrs:{datetime:t.updatedAt},text:ht(t.updatedAt,e.nowMs,o)})),C=u&&t.preview?s("span",{className:"persona-history-row-preview persona-history-truncate",text:t.preview}):null,b=s("button",{className:T("persona-history-row",e.active&&"persona-history-row--active",a&&`persona-history-row--${a}`),attrs:{type:"button","data-persona-history-focus":rr(t.id),"data-persona-history-conversation":t.id,...e.active?{"aria-current":"page"}:{},...l?{"aria-disabled":"true"}:{},...a?{"aria-busy":"true"}:{}}},e.avatar?tr(e.avatar):null,s("div",{className:"persona-history-row-body"},h,C,s("span",{className:"persona-history-row-count persona-history-sr-only",text:mt(t.messageCount,o)})));b.addEventListener("click",()=>{l||e.onOpen()});let ie=e.showDelete?ze({className:"persona-history-row-menu-button",label:`${o.rowActionsLabel}: ${t.title}`,focusKey:or(t.id),open:e.menuOpen,inert:l,onToggle:e.onToggleMenu}):null;return s("li",{className:T("persona-history-item",!e.showDelete&&"persona-history-item--no-menu"),attrs:{"data-persona-history-item":t.id}},b,ie,e.menuOpen&&e.showDelete?nr(e):null,e.error?ir(e.error,o,t.id):null)}function nr(e){let{conversation:t,copy:o}=e;return Fe({label:`${o.rowActionsLabel}: ${t.title}`,items:[{label:o.deleteConversationLabel,focusKey:oe(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function ze(e){let t=s("button",{className:T("persona-history-icon-button",e.className),attrs:{type:"button","aria-label":e.label,"aria-haspopup":"menu","aria-expanded":e.open?"true":"false","data-persona-history-focus":e.focusKey,...e.inert?{"aria-disabled":"true"}:{}}});t.appendChild(_("ellipsis",e.iconSize));let o=()=>t.getAttribute("aria-disabled")==="true";return t.addEventListener("click",i=>{i.stopPropagation(),!o()&&e.onToggle()}),t.addEventListener("keydown",i=>{i.key!=="ArrowDown"&&i.key!=="ArrowUp"||(i.preventDefault(),!(o()||t.getAttribute("aria-expanded")==="true")&&e.onToggle())}),t}function Fe(e){let t=s("div",{className:"persona-history-menu",attrs:{role:"menu","aria-label":e.label}});for(let o of e.items){let i=s("button",{className:T("persona-history-menu-item",o.danger&&"persona-history-menu-item--danger"),text:o.label,attrs:{type:"button",role:"menuitem",tabindex:"0","data-persona-history-focus":o.focusKey}});i.addEventListener("click",()=>{e.onCloseMenu(),o.onSelect()}),t.appendChild(i)}return t.addEventListener("keydown",o=>{let i=Array.from(t.querySelectorAll('[role="menuitem"]'));if(i.length===0)return;let a=i.indexOf(document.activeElement);if(o.key==="Tab"){e.onCloseMenu({restoreFocus:!0});return}if(o.key==="ArrowDown"){o.preventDefault(),i[(a+1+i.length)%i.length]?.focus();return}if(o.key==="ArrowUp"){o.preventDefault(),i[(a-1+i.length)%i.length]?.focus();return}if(o.key==="Home"){o.preventDefault(),i[0]?.focus();return}o.key==="End"&&(o.preventDefault(),i[i.length-1]?.focus())}),t}function ir(e,t,o){let i=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":`row-retry:${o}`}});return i.addEventListener("click",e.retry),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:e.message}),i)}var qe=class extends Error{constructor(t,o,i){super(o),this.name="HistoryProviderError",this.code=t,i?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=i.retryAfterSeconds)}};function ge(e){return e instanceof qe}function sr(e){switch(e){case"authentication_failed":case"authentication_required":case"identity_provider_failed":case"proof_not_admitted":case"unsupported_scope":case"unavailable":return e;default:return"unknown"}}function gt(e){if(ge(e)){if(e.code==="rate_limited")return{kind:"rate_limited",retryAfterSeconds:e.retryAfterSeconds??0};let t=sr(e.code);return{kind:"error",reason:t,retryable:t!=="unsupported_scope"}}return{kind:"error",reason:"unknown",retryable:!0}}function ar(e,t){switch(e.state){case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function lr(e,t){switch(e){case"authentication_required":case"authentication_failed":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"proof_not_admitted":case"unsupported_scope":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function fe(e,t,o,i){let a=s("button",{className:"persona-history-secondary persona-history-state-action",text:e,attrs:{type:"button","data-persona-history-focus":t,...o?{"aria-disabled":"true"}:{}}});return a.addEventListener("click",()=>{o||i()}),a}function ne(e,t,o,i,a){return s("div",{className:"persona-history-state",attrs:{"data-persona-history-state":e,...a?{role:"alert"}:{role:"status"}}},s("p",{className:"persona-history-state-title",text:t}),s("p",{className:"persona-history-state-description",text:o}),i)}function pr(e){let t=["42%","58%","34%"],o=["94%","78%","88%"],i=[0,1,2].map(a=>s("div",{className:"persona-history-skeleton-row",attrs:{"aria-hidden":"true"}},s("div",{className:"persona-history-skeleton-head"},s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--title",style:{width:t[a]}}),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--time"})),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--preview",style:{width:o[a]}})));return s("div",{className:"persona-history-view-loading",attrs:{"data-persona-history-state":"loading",role:"status","aria-label":e.loadingLabel}},...i)}function ft(e){let{state:t,copy:o,busy:i}=e;if(t.kind==="loading")return pr(o);if(t.kind==="empty"){let c=ar(e.identityStatus,o);return c?ne("identity",c.title,c.description,e.onRetry?fe(o.retryIdentityLabel,"state-retry",i,e.onRetry):null,!0):ne("empty",o.emptyTitle,o.emptyDescription,null,!1)}if(t.kind==="rate_limited"){let c=t.retryAfterSeconds>0?E(o.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):o.rateLimitedDescription;return ne("rate_limited",o.rateLimitedTitle,c,e.onRetry?fe(o.retryLabel,"state-retry",i,e.onRetry):null,!1)}if(t.kind==="new_conversation_required")return ne("new_conversation_required",o.newConversationRequiredTitle,o.newConversationRequiredDescription,e.onStartNew?fe(o.newConversationLabel,"state-retry",i,e.onStartNew):null,!0);let{title:a,description:l}=lr(t.reason,o),u=t.reason==="authentication_required"||t.reason==="authentication_failed"||t.reason==="identity_provider_failed"?o.retryIdentityLabel:o.retryLabel;return ne("error",a,l,t.retryable&&e.onRetry?fe(u,"state-retry",i,e.onRetry):null,!0)}var dr=25,F="persona:list-options",cr=180,bt=120,yr=160,ur="cubic-bezier(0.4, 0, 1, 1)",hr={panel:20,rail:12},mr=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,vr=e=>e.finished?e.finished.then(()=>{},()=>{}):Promise.resolve();function be(e){return`${e.state}:${"reason"in e?e.reason:""}`}function wt(e,t){switch(e.state){case"verified":return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case"verifying":case"resetting":return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function gr(e){return e.state==="verified"||e.state==="browser_only"}function fr(e){return e.state==="authentication_required"||e.state==="identity_provider_failed"||e.state==="configuration_error"}function $e(e){let t=re(e.copy),o=e.now??(()=>Date.now()),i=e.pageSize??dr,a=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,l=[],u=null,c={kind:"loading",phase:"initial"},h=null,C=e.activeConversationId,b=e.provider.getIdentityStatus(),ie=be(b),x=null,M=!1,m=!1,Y=0,S=e.presentation,xt=e.collapsible!==!1,R=e.collapsed===!0,Ke=e.railSide==="right",j=e.renderDom!==!1,I=new Map,A=null,we=dt(),se=r=>{!j&&e.onAnnounce?e.onAnnounce(r):we.announce(r)},w=()=>h!==null,Be=`${a}-body`,f=s("button",{className:"persona-history-icon-button persona-history-back",attrs:{type:"button"}}),G=()=>S==="rail"&&xt,ae,Ht=()=>{if(e.railBrand){if(!G()){f.classList.remove("persona-history-back--branded");return}if(ae===void 0){let r=e.railBrand(!0);ae=r?s("span",{className:"persona-history-brand-mark persona-history-toggle-brand",attrs:{"aria-hidden":"true"}},r):null}ae&&(f.classList.add("persona-history-back--branded"),f.appendChild(ae))}},xe=()=>{let r=G(),n=S==="rail";f.setAttribute("data-persona-history-focus",r?"collapse":"close"),f.setAttribute("aria-label",r?R?t.expandLabel:t.collapseLabel:n?t.closeLabel:t.backLabel),r?(f.setAttribute("aria-expanded",R?"false":"true"),f.setAttribute("aria-controls",Be),e.collapseShortcut?.aria&&f.setAttribute("aria-keyshortcuts",e.collapseShortcut.aria)):(f.removeAttribute("aria-expanded"),f.removeAttribute("aria-controls"),f.removeAttribute("aria-keyshortcuts")),f.replaceChildren(_(r?"panel-left":n?"x":"arrow-left")),Ht()};xe(),f.addEventListener("click",()=>{G()?e.onToggleCollapse?.():e.onClose()});let He=s("h2",{className:"persona-history-title",text:t.viewTitle,attrs:{id:a}}),We=s("span",{className:"persona-history-scope-title"}),q=s("p",{className:"persona-history-scope"},s("span",{className:"persona-history-scope-icon",attrs:{"aria-hidden":"true"}},_("monitor",14)),We),le=s("div",{className:"persona-history-heading-group"},He),Ye=!1,pe,Ce=()=>{let r=S==="rail",n=r?e.renderRailHeader:void 0,p=null,y=n!==void 0;if(n)try{p=n({collapsed:R,defaultTitle:t.viewTitle})}catch(d){y=!1,Ye||(Ye=!0,console.warn("[persona] history rail renderHeader threw",d))}if(!y&&r&&e.railBrand){if(pe===void 0){let d=e.railBrand(!1);pe=d?s("span",{className:"persona-history-heading-brand",attrs:{"aria-hidden":"true"}},s("span",{className:"persona-history-brand-mark"},d),s("span",{className:"persona-history-wordmark",text:t.viewTitle})):null}pe&&(y=!0,p=pe)}He.classList.toggle("persona-history-sr-only",y),le.replaceChildren(He),p&&le.appendChild(p)};Ce();let $=s("button",{className:"persona-history-icon-button persona-history-new-icon",attrs:{type:"button","data-persona-history-focus":"new-icon","aria-label":t.newConversationLabel}});$.appendChild(_("plus")),$.addEventListener("click",()=>{ee()});let Ct=[f,$].map(r=>e.attachTooltip?.({anchor:r,text:()=>r.getAttribute("aria-label")??"",...r===f&&e.collapseShortcut?{hint:()=>G()?e.collapseShortcut.hint:""}:{}})),L=s("div",{className:"persona-history-topbar"}),je=null,Se=()=>{let r=S==="rail",n=r?Ke?"rail-right":"rail":"panel";n!==je&&(je=n,n==="rail"?L.append(le,f):L.append(f,le),r?$.remove():L.appendChild($),v.classList.toggle("persona-history-view--rail-right",n==="rail-right"))},O=s("div",{className:"persona-history-scope-alert"}),Ge=`${a}-scope`,St=_("plus",18),Le=s("button",{className:"persona-history-new",attrs:{type:"button","data-persona-history-focus":"new"}},St,s("span",{text:t.newConversationLabel}));Le.addEventListener("click",()=>{ee()});let ke=s("div",{className:"persona-history-list-region"}),Ue=e.showDeleteAll!==!1,Xe=!!e.provider.resetDevice,Ze=e.listActions??[],V=Ue||Xe||Ze.length>0?ze({className:"persona-history-list-options",label:t.listOptionsLabel,focusKey:`menu:${F}`,open:!1,inert:!0,iconSize:16,onToggle:()=>nt(F)}):null,Lt=s("h3",{className:"persona-history-conversations-title",text:t.conversationsTitle}),K=s("div",{className:"persona-history-caption",attrs:{"data-persona-history-item":F}},Lt,e.showScopeStatus?q:null,V),B=s("div",{className:"persona-history-body",attrs:{id:Be}},e.showScopeStatus?O:null,Le,K,ke),U=e.headerPlacement??"inline";U==="external"&&L.classList.add("persona-history-topbar--shell","persona-history-topbar--shell-enter");let v=s("div",{className:T("persona-history-view",`persona-history-view--${e.presentation}`,"persona-history-view--enter"),attrs:{role:"region","aria-labelledby":a,"data-persona-history-presentation":e.presentation}},we.element,U==="inline"?L:null,B),Te=()=>{v.classList.toggle("persona-history-view--rail-collapsed",R&&G())};Te(),Se();let kt=(r,n)=>{let p=`${a}-s${n}`,y=s("div",{className:T("persona-history-nav",r.placement==="footer"&&"persona-history-nav--footer"),attrs:{role:"group","data-persona-rail-section":r.id,...r.title?{"aria-labelledby":p}:{"aria-label":r.id}}});r.title&&y.appendChild(s("h3",{className:"persona-history-group-heading",text:r.title,attrs:{id:p}}));for(let d of r.items){let H=d.iconNode?.()??null,D=s("button",{className:T("persona-history-nav-item",H&&"persona-history-nav-item--icon"),attrs:{type:"button","aria-label":d.label,"data-persona-rail-item":d.id}},H?s("span",{className:"persona-history-nav-icon"},H):null,s("span",{className:"persona-history-nav-label persona-history-truncate",text:d.label}),d.badge?s("span",{className:"persona-history-nav-badge",text:d.badge}):null);D.addEventListener("click",()=>d.onSelect()),y.appendChild(D)}return y},X=null,Je=null,Ee=()=>{!X||!j||S!=="rail"||R===Je||(Je=R,e.railSections.forEach((r,n)=>{if(!r.render)return;let p=X[n],y=r.title?p.firstElementChild:null,d=null;try{d=r.render(R)}catch(H){r.render=void 0,console.warn("[persona] history rail section threw",r.id,H)}p.replaceChildren(...y?[y]:[],...d?[d]:[]),p.hidden=!d}))},Qe=()=>{let r=e.railSections;if(v.classList.toggle("persona-history-view--has-nav",S==="rail"&&!!r?.some(n=>n.placement==="above-conversations")),!!r?.length){if(S!=="rail"){X?.forEach(n=>n.remove());return}X??(X=r.map(kt));for(let n of["above-conversations","below-conversations","footer"]){let p=n==="above-conversations"?K.parentNode===B?K:ke:null;r.forEach((y,d)=>{y.placement===n&&B.insertBefore(X[d],p)})}Ee()}};Qe(),pt(v,"persona-history-view",ct);let et=(r,n)=>{let p=v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r),y=Number.parseFloat(p??"");return Number.isFinite(y)&&y>=0?y:n},Tt=(r,n)=>v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r).trim()||n,Z=null,z=()=>{Z!==null&&(clearTimeout(Z),Z=null),v.removeEventListener("animationend",z),v.classList.remove("persona-history-view--enter")};v.addEventListener("animationend",z),Z=setTimeout(()=>{Z=setTimeout(z,et("--persona-history-enter-ms",cr)+60)},0);let J=null,Q=()=>{J!==null&&(clearTimeout(J),J=null),L.classList.remove("persona-history-topbar--shell-enter")},Et=()=>{Q(),L.classList.add("persona-history-topbar--shell-enter"),J=setTimeout(Q,bt+60)};U==="external"&&(J=setTimeout(Q,bt+60));let de=[],ce=null,Rt=()=>{if(ce)return ce;if(m||mr()||typeof v.animate!="function")return z(),null;let r=v.ownerDocument.defaultView?.getComputedStyle(B).opacity||"1";z(),v.style.pointerEvents="none",P.style.pointerEvents="none";let n={duration:et("--persona-history-exit-ms",yr),easing:Tt("--persona-history-exit-easing",ur),fill:"forwards"},p=hr[S];return de=[B.animate([{opacity:r,transform:"none"},{opacity:0,transform:`translateX(${p}px)`}],n)],ce=Promise.all(de.map(vr)).then(()=>{}),ce},Re=(r,n)=>{r&&(n?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"))},P=L,Ae=null,At=()=>{let r=e.slots?.header;if(!r)return;let n=`${S}|${be(b)}|${h?`${h.kind}:${"conversationId"in h?h.conversationId:""}`:""}`;if(n===Ae)return;Ae=n;let p=r({identityStatus:b,pendingAction:h,copy:t,defaultRenderer:()=>L})??L;p!==P&&(P.replaceWith(p),P=p)},tt=null,Nt=()=>{if(!e.showScopeStatus)return;let r=be(b);if(r===tt)return;tt=r;let n=wt(b,t);We.textContent=n.title;let p=gr(b);if(q.hidden=!p,O.replaceChildren(...p?[]:[s("span",{className:"persona-history-scope-alert-title",text:n.title})],s("span",{className:"persona-history-scope-description",text:n.description,attrs:{id:Ge}})),O.setAttribute("data-persona-history-scope-tone",p?"ambient":"attention"),p?q.setAttribute("aria-describedby",Ge):q.removeAttribute("aria-describedby"),n.pending?O.setAttribute("role","status"):O.removeAttribute("role"),O.setAttribute("data-persona-history-identity",b.state),q.setAttribute("data-persona-history-identity",b.state),fr(b)){let y=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryIdentityLabel,attrs:{type:"button","data-persona-history-focus":"identity-retry"}});y.addEventListener("click",()=>{w()||N("refresh")}),O.appendChild(y)}},rt=r=>h?h.kind==="open"&&h.conversationId===r?"opening":h.kind==="delete"&&h.conversationId===r?"deleting":null:null,Mt=()=>{let r=document.activeElement;return!(r instanceof HTMLElement)||!v.contains(r)?null:r.getAttribute("data-persona-history-focus")},Pt=r=>{if(M&&x){M=!1;let n=v.querySelector(`[data-persona-history-focus="${oe(x)}"]`);if(n){n.focus();return}}r&&v.querySelector(`[data-persona-history-focus="${r}"]`)?.focus()},Dt=()=>{if(!A)return null;let r=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":"action-retry"}}),n=A;return r.addEventListener("click",()=>{w()||n.retry()}),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:n.message}),r)},_t=()=>ut(l,o(),t,e.grouping).map((r,n)=>{let p=`${a}-g${n}`,y=s("ul",{className:"persona-history-list",attrs:{"aria-labelledby":p}});for(let d of r.items){let H=()=>vt({conversation:d,active:d.id===C,pending:rt(d.id),busy:w(),menuOpen:x===d.id,error:I.get(d.id)??null,avatar:e.rowAvatar,showDelete:e.showDelete!==!1,nowMs:o(),copy:t,onOpen:()=>{ye(d.id)},onToggleMenu:()=>nt(d.id),onCloseMenu:_e=>k(_e),onDelete:()=>{ue(d.id)}}),W=e.slots?.conversation?.({conversation:d,active:d.id===C,pending:rt(d.id),open:()=>ye(d.id),requestDelete:()=>ue(d.id),defaultRenderer:H})??H();y.appendChild(W instanceof HTMLLIElement?W:s("li",{className:"persona-history-item"},W))}return s("div",{className:"persona-history-group",attrs:{"data-persona-history-group":r.key}},s("h3",{className:T("persona-history-group-heading",r.key==="recent"&&"persona-history-sr-only"),text:r.label,attrs:{id:p}}),y)}),It=()=>{if(!u)return null;let r=h?.kind==="load-more"||c.kind==="loading"&&c.phase==="load-more",n=s("button",{className:"persona-history-secondary persona-history-load-more",text:r?t.loadingMoreLabel:t.loadMoreLabel,attrs:{type:"button","data-persona-history-focus":"load-more",...r?{"aria-busy":"true","aria-disabled":"true"}:{},...w()&&!r?{"aria-disabled":"true"}:{}}});return n.addEventListener("click",()=>{w()||N("load-more")}),n},Ot=()=>{let r=Mt(),n=[Dt()],p=l.length>0;if(p&&(n.push(..._t()),n.push(It())),c.kind!=="ready"&&!(c.kind==="loading"&&c.phase!=="initial"&&p)){let d=c,H=d.kind==="loading"?void 0:()=>N("refresh"),D=d.kind==="new_conversation_required"?()=>ee():void 0,W=()=>ft({state:d,copy:t,identityStatus:b,busy:w(),...H?{onRetry:()=>{H()}}:{},...D?{onStartNew:()=>{D()}}:{}}),_e=e.slots?.state?.({state:d,identityStatus:b,copy:t,...H?{retry:H}:{},...D?{startNewConversation:D}:{},defaultRenderer:W});n.push(_e??W())}ke.replaceChildren(...n.filter(d=>!!d)),Pt(r)},Vt=()=>{let r=c.kind==="loading"&&l.length===0,n=[],p=()=>n.length===0?oe(F):`${oe(F)}-${n.length}`;if(!r)for(let y of Ze)n.push({label:y.label,focusKey:p(),danger:y.danger===!0,onSelect:()=>{y.onSelect({conversations:[...l]})}});return Ue&&!(l.length===0&&(c.kind==="empty"||r))&&n.push({label:t.clearHistoryLabel,focusKey:p(),danger:!0,onSelect:()=>{Me()}}),Xe&&!r&&n.push({label:t.resetIdentityLabel,focusKey:p(),danger:!0,onSelect:()=>{De()}}),n},zt=()=>{if(Re(Le,w()),Re($,w()),V){let r=Vt(),n=c.kind==="loading"&&l.length===0;V.hidden=r.length===0&&!n,Re(V,w()||r.length===0),V.setAttribute("aria-expanded",x===F?"true":"false");let p=K.querySelector(".persona-history-menu");if(x!==F||r.length===0)p?.remove();else{let y=Fe({label:t.listOptionsLabel,items:r,onCloseMenu:d=>k(d)});p?p.replaceWith(y):K.appendChild(y)}}K.hidden=S!=="rail"&&(!V||V.hidden)&&(!e.showScopeStatus||q.hidden)},ot,Ft=()=>{let r=e.onActiveConversationChange;if(!r)return;let n=l.find(y=>y.id===C)??null,p=n?`${n.id}\0${n.title}\0${n.starred?1:0}`:"";p!==ot&&(ot=p,r(n))},g=()=>{if(!m){if(Ft(),!j){e.onModelChange?.();return}At(),Nt(),zt(),Ot(),Ee()}},k=r=>{if(!x)return;let n=x;x=null,M=!1,g(),r?.restoreFocus&&v.querySelector(`[data-persona-history-focus="menu:${n}"]`)?.focus()},nt=r=>{if(x===r){k({restoreFocus:!0});return}x=r,M=!0,g()},it=r=>{if(!x)return;let n=r.target;n instanceof Node&&v.contains(n)&&n.closest?.(`[data-persona-history-item="${x}"]`)||k()};document.addEventListener("pointerdown",it,!0);let st=r=>{r.key!=="Escape"||!x||(r.stopPropagation(),k({restoreFocus:!0}))};v.addEventListener("keydown",st);async function N(r){if(m)return;let n=++Y,p=r==="load-more"?u:null;if(!(r==="load-more"&&!p)){h={kind:r==="load-more"?"load-more":"refresh"},c={kind:"loading",phase:r},r!=="load-more"&&(I.clear(),A=null),k(),g();try{let y=await e.provider.list({limit:i,context:e.context,...p?{cursor:p}:{},...e.targetId?{targetId:e.targetId}:{}});if(m||n!==Y)return;l=p?[...l,...y.items]:y.items,u=y.nextCursor,c=l.length===0?{kind:"empty"}:{kind:"ready"}}catch(y){if(m||n!==Y)return;c=gt(y)}finally{!m&&n===Y&&(h=null,g())}}}let Ne=r=>{l=l.filter(n=>n.id!==r),I.delete(r),C===r&&(C=null),l.length===0&&!u&&(c={kind:"empty"})};async function ye(r){if(!(w()||m)){I.delete(r),k(),h={kind:"open",conversationId:r},g();try{if(await e.onSelect(r),m)return;C=r}catch{if(m)return;I.set(r,{message:t.openFailedLabel,retry:()=>{ye(r)}})}finally{m||(h=null,g())}}}async function ue(r){if(w()||m)return"cancelled";I.delete(r),h={kind:"delete",conversationId:r},g();try{let n=await e.onRequestDeleteConversation(r);return m||n==="deleted"&&(Ne(r),se(t.conversationRemovedNotice)),n}catch(n){return m||(ge(n)&&n.code==="not_found"?Ne(r):I.set(r,{message:t.deleteFailedLabel,retry:()=>{ue(r)}})),"cancelled"}finally{m||(h=null,g())}}async function ee(){if(!(w()||m)){A=null,k(),h={kind:"start-new"},g();try{if(await e.onStartNew(),m)return;c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"})}catch{if(m)return;A={message:t.errorDescription,retry:()=>{ee()}}}finally{m||(h=null,g())}}}async function Me(){if(w()||m)return"cancelled";A=null,k(),h={kind:"clear"},g();try{let r=await e.onRequestClearHistory();return m||r==="cleared"&&(l=[],u=null,C=null,c={kind:"empty"},se(t.historyClearedNotice)),r}catch{return m||(A={message:t.errorDescription,retry:()=>{Me()}}),"cancelled"}finally{m||(h=null,g())}}let Pe={outcome:"cancelled"};async function De(){if(w()||m||!e.onRequestResetIdentity)return Pe;A=null,k(),h={kind:"reset"},g();try{let r=await e.onRequestResetIdentity();return m||r.outcome==="reset"&&(se(r.remoteRevocationConfirmed?t.identityResetNotice:t.identityResetUnconfirmedNotice),h=null,await N("refresh")),r}catch{return m||(A={message:t.errorDescription,retry:()=>{De()}}),Pe}finally{!m&&h?.kind==="reset"&&(h=null,g())}}let qt=e.provider.subscribeIdentityStatus(r=>{if(m)return;let n=be(r),p=n!==ie;b=r,ie=n,g(),p&&r.state!=="verifying"&&se(wt(r,t).title)}),$t=e.provider.subscribeAvailability?.(r=>{if(!m){if(r){N("refresh");return}l=[],u=null,c={kind:"error",reason:"unavailable",retryable:!1},g()}});return g(),N("initial"),{element:v,copy:t,getModel:()=>({conversations:l,activeConversationId:C,state:c,pendingAction:h,identityStatus:b,nextCursor:u}),operations:{refresh:async()=>{w()||await N("refresh")},loadMore:async()=>{w()||await N("load-more")},openConversation:r=>ye(r),startNewConversation:()=>ee(),requestDeleteConversation:r=>ue(r),requestClearConversationHistory:()=>Me(),requestResetHistoryIdentity:()=>De()},setDomRenderEnabled:r=>{r!==j&&(j=r,r&&g())},refresh:()=>{N("refresh")},setPresentation:r=>{if(r===S)return;z(),S=r,Ae=null;let n=r==="rail";v.classList.toggle("persona-history-view--panel",!n),v.classList.toggle("persona-history-view--rail",n),v.setAttribute("data-persona-history-presentation",r),xe(),Te(),Se(),Ce(),Qe(),g()},setCollapsed:r=>{r!==R&&(R=r,Te(),xe(),Ce(),Ee())},setRailSide:r=>{Ke=r==="right",Se()},getHeaderElement:()=>P,setHeaderPlacement:r=>{if(r===U)return;U=r;let n=r==="external";if(L.classList.toggle("persona-history-topbar--shell",n),n){Et(),P.remove();return}Q(),v.insertBefore(P,B)},setActiveConversationId:r=>{C!==r&&(C=r,g())},applyConversationSummary:r=>{let n=l.findIndex(p=>p.id===r.id);n!==-1&&(l[n]=r,g())},removeConversationSummary:r=>{l.some(n=>n.id===r)&&(Ne(r),g())},setNewConversationRequired:r=>{r?c={kind:"new_conversation_required"}:c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"}),g()},playExit:Rt,destroy:()=>{m=!0,Y+=1,z(),Q(),Ct.forEach(r=>r?.destroy()),P.remove(),de.forEach(r=>r.cancel()),de=[],qt(),$t?.(),document.removeEventListener("pointerdown",it,!0),v.removeEventListener("keydown",st),we.destroy(),v.remove(),v.replaceChildren()}}}0&&(module.exports={HISTORY_VIEW_COPY_DEFAULTS,createHistoryView,resolveHistoryViewCopy});
898
+ `;var ut={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."};var oe={...ut,emptyTitle:"No conversations yet",emptyDescription:"Start a conversation and it will show up here.",errorTitle:"Could not load conversations",errorDescription:"Something went wrong. Please try again.",retryLabel:"Retry",rateLimitedTitle:"Too many requests",rateLimitedDescription:"Please wait a moment before trying again.",groupStarred:"Starred",groupToday:"Today",groupYesterday:"Yesterday",groupPrevious7Days:"Previous 7 days",groupPrevious30Days:"Previous 30 days",groupMonthYear:"{month} {year}",browserOnlyTitle:"On this device",browserOnlyDescription:"Another browser or device keeps its own separate history.",verifyingTitle:"Checking your account",verifyingDescription:"Looking for messages linked to your account.",verifiedTitle:"Available across signed-in devices",verifiedDescription:"This list refreshes when the chat opens rather than syncing live.",authenticationRequiredTitle:"Sign in to see your messages",authenticationRequiredDescription:"Your session expired. Sign in again to load account history.",identityProviderFailedTitle:"Account history is unavailable",identityProviderFailedDescription:"We could not verify your account, so account history is not shown here.",proofNotAdmittedTitle:"Account history is unavailable",proofNotAdmittedDescription:"This assistant is not set up to accept your account identity.",retryIdentityLabel:"Try again",backLabel:"Back to conversation",closeLabel:"Close conversation list",loadingLabel:"Loading conversations",loadMoreLabel:"Load more",loadingMoreLabel:"Loading more conversations",conversationsTitle:"Conversations",rowActionsLabel:"Conversation options",listOptionsLabel:"Conversation options",deleteConversationLabel:"Delete",clearHistoryLabel:"Delete all conversations",resetIdentityLabel:"Forget this device",messageCountLabel:"{count} messages",messageCountLabelOne:"1 message",conversationRemovedNotice:"Conversation deleted.",historyClearedNotice:"All conversations were deleted.",unavailableTitle:"Conversation history is unavailable",unavailableDescription:"Try again later.",newConversationRequiredTitle:"Start a new conversation",newConversationRequiredDescription:"The previous conversation is gone. Start a new one to keep chatting.",rateLimitedWaitDescription:"You can try again in {seconds} seconds.",openFailedLabel:"Could not open that conversation.",deleteFailedLabel:"Could not delete that conversation.",relativeNow:"now",relativeMinutes:"{value}m",relativeHours:"{value}h",relativeDays:"{value}d",relativeWeeks:"{value}w",relativeYears:"{value}y"};function ne(e){if(!e)return oe;let t={...oe};for(let[o,i]of Object.entries(e))typeof i=="string"&&i.length>0&&(t[o]=i);return t}function R(e,t){return e.replace(/\{(\w+)\}/g,(o,i)=>i in t?String(t[i]):o)}var Ve=864e5;function Xt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function ze(e,t){let o=Date.parse(e);return Number.isFinite(o)?o:t}function Zt(e,t){let o=ze(e,t),i=Xt(t);if(o>=i)return"today";if(o>=i-Ve)return"yesterday";if(o>=i-7*Ve)return"previous-7-days";if(o>=i-30*Ve)return"previous-30-days";let a=new Date(o);return`month:${a.getFullYear()}-${a.getMonth()}`}function Jt(e,t,o,i){if(e==="today")return i.groupToday;if(e==="yesterday")return i.groupYesterday;if(e==="previous-7-days")return i.groupPrevious7Days;if(e==="previous-30-days")return i.groupPrevious30Days;let a=new Date(ze(t,o));return R(i.groupMonthYear,{month:a.toLocaleString(void 0,{month:"long"}),year:a.getFullYear()})}function ht(e,t,o,i="time"){let a=e.filter(d=>d.starred),l=a.length>0?[{key:"starred",label:o.groupStarred,items:a}]:[];if(i==="none"){let d=e.filter(c=>!c.starred);return d.length>0&&l.push({key:"recent",label:o.conversationsTitle,items:d}),l}for(let d of e){if(d.starred)continue;let c=Zt(d.updatedAt,t),y=l[l.length-1];if(y&&y.key===c){y.items.push(d);continue}l.push({key:c,label:Jt(c,d.updatedAt,t,o),items:[d]})}return l}function mt(e,t,o){let i=Math.max(0,t-ze(e,t)),a=Math.floor(i/6e4);if(a<1)return o.relativeNow;if(a<60)return R(o.relativeMinutes,{value:a});let l=Math.floor(a/60);if(l<24)return R(o.relativeHours,{value:l});let d=Math.floor(l/24);if(d<7)return R(o.relativeDays,{value:d});let c=Math.floor(d/7);return d<365?R(o.relativeWeeks,{value:c}):R(o.relativeYears,{value:Math.floor(d/365)})}function vt(e,t){return e===1?t.messageCountLabelOne:R(t.messageCountLabel,{count:e})}var fe="http://www.w3.org/2000/svg",Qt={"arrow-left":["m12 19-7-7 7-7","M19 12H5"],plus:["M5 12h14","M12 5v14"],star:["m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z"],x:["M18 6 6 18","m6 6 12 12"],"panel-left":["M9 3v18"],monitor:["M8 21h8","M12 17v4"],ellipsis:[]},er={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function O(e,t=20){let o=document.createElementNS(fe,"svg");if(o.setAttribute("width",String(t)),o.setAttribute("height",String(t)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),e==="ellipsis"){for(let a of[12,19,5]){let l=document.createElementNS(fe,"circle");l.setAttribute("cx",String(a)),l.setAttribute("cy","12"),l.setAttribute("r","1"),o.appendChild(l)}return o}let i=er[e];if(i){let a=document.createElementNS(fe,"rect");a.setAttribute("x",String(i[0])),a.setAttribute("y",String(i[1])),a.setAttribute("width",String(i[2])),a.setAttribute("height",String(i[3])),a.setAttribute("rx","2"),o.appendChild(a)}for(let a of Qt[e]){let l=document.createElementNS(fe,"path");l.setAttribute("d",a),o.appendChild(l)}return o}var tr=/^(https?:|\/|data:)/i;function rr(e){let t=s("span",{className:"persona-history-row-avatar",attrs:{"aria-hidden":"true"}});return tr.test(e)?t.appendChild(s("img",{attrs:{src:e,alt:"",loading:"lazy"}})):t.textContent=e,t}var or=e=>`row:${e}`,nr=e=>`menu:${e}`,ie=e=>`menu-item:${e}`;function ft(e){let{conversation:t,copy:o,busy:i,pending:a}=e,l=i||a!==null,d=t.title.trim().length>0,c=t.starred?(()=>{let b=O("star",11);return b.setAttribute("fill","currentColor"),b.setAttribute("stroke-width","1"),s("span",{className:"persona-history-row-star"},b,s("span",{className:"persona-history-sr-only",text:o.groupStarred}))})():null,y=s("div",{className:"persona-history-row-head"},s("span",{className:"persona-history-row-title persona-history-truncate",text:d?t.title:t.preview??""}),c,s("time",{className:"persona-history-row-time",attrs:{datetime:t.updatedAt},text:mt(t.updatedAt,e.nowMs,o)})),g=d&&t.preview?s("span",{className:"persona-history-row-preview persona-history-truncate",text:t.preview}):null,w=s("button",{className:T("persona-history-row",e.active&&"persona-history-row--active",a&&`persona-history-row--${a}`),attrs:{type:"button","data-persona-history-focus":or(t.id),"data-persona-history-conversation":t.id,...e.active?{"aria-current":"page"}:{},...l?{"aria-disabled":"true"}:{},...a?{"aria-busy":"true"}:{}}},e.avatar?rr(e.avatar):null,s("div",{className:"persona-history-row-body"},y,g,s("span",{className:"persona-history-row-count persona-history-sr-only",text:vt(t.messageCount,o)})));w.addEventListener("click",()=>{l||e.onOpen()});let A=e.showDelete?Fe({className:"persona-history-row-menu-button",label:`${o.rowActionsLabel}: ${t.title}`,focusKey:nr(t.id),open:e.menuOpen,inert:l,onToggle:e.onToggleMenu}):null;return s("li",{className:T("persona-history-item",!e.showDelete&&"persona-history-item--no-menu"),attrs:{"data-persona-history-item":t.id}},w,A,e.menuOpen&&e.showDelete?ir(e):null,e.error?sr(e.error,o,t.id):null)}function ir(e){let{conversation:t,copy:o}=e;return qe({label:`${o.rowActionsLabel}: ${t.title}`,items:[{label:o.deleteConversationLabel,focusKey:ie(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function Fe(e){let t=s("button",{className:T("persona-history-icon-button",e.className),attrs:{type:"button","aria-label":e.label,"aria-haspopup":"menu","aria-expanded":e.open?"true":"false","data-persona-history-focus":e.focusKey,...e.inert?{"aria-disabled":"true"}:{}}});t.appendChild(O("ellipsis",e.iconSize));let o=()=>t.getAttribute("aria-disabled")==="true";return t.addEventListener("click",i=>{i.stopPropagation(),!o()&&e.onToggle()}),t.addEventListener("keydown",i=>{i.key!=="ArrowDown"&&i.key!=="ArrowUp"||(i.preventDefault(),!(o()||t.getAttribute("aria-expanded")==="true")&&e.onToggle())}),t}function qe(e){let t=s("div",{className:"persona-history-menu",attrs:{role:"menu","aria-label":e.label}});for(let o of e.items){let i=s("button",{className:T("persona-history-menu-item",o.danger&&"persona-history-menu-item--danger"),text:o.label,attrs:{type:"button",role:"menuitem",tabindex:"0","data-persona-history-focus":o.focusKey}});i.addEventListener("click",()=>{e.onCloseMenu(),o.onSelect()}),t.appendChild(i)}return t.addEventListener("keydown",o=>{let i=Array.from(t.querySelectorAll('[role="menuitem"]'));if(i.length===0)return;let a=i.indexOf(document.activeElement);if(o.key==="Tab"){e.onCloseMenu({restoreFocus:!0});return}if(o.key==="ArrowDown"){o.preventDefault(),i[(a+1+i.length)%i.length]?.focus();return}if(o.key==="ArrowUp"){o.preventDefault(),i[(a-1+i.length)%i.length]?.focus();return}if(o.key==="Home"){o.preventDefault(),i[0]?.focus();return}o.key==="End"&&(o.preventDefault(),i[i.length-1]?.focus())}),t}function sr(e,t,o){let i=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":`row-retry:${o}`}});return i.addEventListener("click",e.retry),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:e.message}),i)}var Ke=class extends Error{constructor(t,o,i){super(o),this.name="HistoryProviderError",this.code=t,i?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=i.retryAfterSeconds)}};function ge(e){return e instanceof Ke}function ar(e){switch(e){case"authentication_failed":case"authentication_required":case"identity_provider_failed":case"proof_not_admitted":case"unsupported_scope":case"unavailable":return e;default:return"unknown"}}function gt(e){if(ge(e)){if(e.code==="rate_limited")return{kind:"rate_limited",retryAfterSeconds:e.retryAfterSeconds??0};let t=ar(e.code);return{kind:"error",reason:t,retryable:t!=="unsupported_scope"}}return{kind:"error",reason:"unknown",retryable:!0}}function lr(e,t){switch(e.state){case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function pr(e,t){switch(e){case"authentication_required":case"authentication_failed":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"proof_not_admitted":case"unsupported_scope":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function be(e,t,o,i){let a=s("button",{className:"persona-history-secondary persona-history-state-action",text:e,attrs:{type:"button","data-persona-history-focus":t,...o?{"aria-disabled":"true"}:{}}});return a.addEventListener("click",()=>{o||i()}),a}function se(e,t,o,i,a){return s("div",{className:"persona-history-state",attrs:{"data-persona-history-state":e,...a?{role:"alert"}:{role:"status"}}},s("p",{className:"persona-history-state-title",text:t}),s("p",{className:"persona-history-state-description",text:o}),i)}function dr(e){let t=["42%","58%","34%"],o=["94%","78%","88%"],i=[0,1,2].map(a=>s("div",{className:"persona-history-skeleton-row",attrs:{"aria-hidden":"true"}},s("div",{className:"persona-history-skeleton-head"},s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--title",style:{width:t[a]}}),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--time"})),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--preview",style:{width:o[a]}})));return s("div",{className:"persona-history-view-loading",attrs:{"data-persona-history-state":"loading",role:"status","aria-label":e.loadingLabel}},...i)}function bt(e){let{state:t,copy:o,busy:i}=e;if(t.kind==="loading")return dr(o);if(t.kind==="empty"){let c=lr(e.identityStatus,o);return c?se("identity",c.title,c.description,e.onRetry?be(o.retryIdentityLabel,"state-retry",i,e.onRetry):null,!0):se("empty",o.emptyTitle,o.emptyDescription,null,!1)}if(t.kind==="rate_limited"){let c=t.retryAfterSeconds>0?R(o.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):o.rateLimitedDescription;return se("rate_limited",o.rateLimitedTitle,c,e.onRetry?be(o.retryLabel,"state-retry",i,e.onRetry):null,!1)}if(t.kind==="new_conversation_required")return se("new_conversation_required",o.newConversationRequiredTitle,o.newConversationRequiredDescription,e.onStartNew?be(o.newConversationLabel,"state-retry",i,e.onStartNew):null,!0);let{title:a,description:l}=pr(t.reason,o),d=t.reason==="authentication_required"||t.reason==="authentication_failed"||t.reason==="identity_provider_failed"?o.retryIdentityLabel:o.retryLabel;return se("error",a,l,t.retryable&&e.onRetry?be(d,"state-retry",i,e.onRetry):null,!0)}var cr=25,K="persona:list-options",yr=180,wt=120,ur=160,hr="cubic-bezier(0.4, 0, 1, 1)",mr={panel:20,rail:12},vr=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,fr=e=>e.finished?e.finished.then(()=>{},()=>{}):Promise.resolve();function we(e){return`${e.state}:${"reason"in e?e.reason:""}`}function xt(e,t){switch(e.state){case"verified":return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case"verifying":case"resetting":return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function gr(e){return e.state==="verified"||e.state==="browser_only"}function br(e){return e.state==="authentication_required"||e.state==="identity_provider_failed"||e.state==="configuration_error"}function $e(e){let t=ne(e.copy),o=e.now??(()=>Date.now()),i=e.pageSize??cr,a=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,l=[],d=null,c={kind:"loading",phase:"initial"},y=null,g=e.activeConversationId,w=e.provider.getIdentityStatus(),A=we(w),x=null,b=!1,m=!1,D=0,S=e.presentation,G=e.collapsible!==!1,N=e.collapsed===!0,We=e.railSide==="right",U=e.renderDom!==!1,V=new Map,M=null,xe=ct(),ae=r=>{!U&&e.onAnnounce?e.onAnnounce(r):xe.announce(r)},C=()=>y!==null,Be=`${a}-body`,H=s("button",{className:"persona-history-icon-button persona-history-back",attrs:{type:"button"}}),X=()=>S==="rail"&&G,le,Ct=()=>{if(e.railBrand){if(!X()){H.classList.remove("persona-history-back--branded");return}if(le===void 0){let r=e.railBrand(!0);le=r?s("span",{className:"persona-history-brand-mark persona-history-toggle-brand",attrs:{"aria-hidden":"true"}},r):null}le&&(H.classList.add("persona-history-back--branded"),H.appendChild(le))}},He=()=>{let r=X(),n=S==="rail";H.setAttribute("data-persona-history-focus",r?"collapse":"close"),H.setAttribute("aria-label",r?N?t.expandLabel:t.collapseLabel:n?t.closeLabel:t.backLabel),r?(H.setAttribute("aria-expanded",N?"false":"true"),H.setAttribute("aria-controls",Be),e.collapseShortcut?.aria&&H.setAttribute("aria-keyshortcuts",e.collapseShortcut.aria)):(H.removeAttribute("aria-expanded"),H.removeAttribute("aria-controls"),H.removeAttribute("aria-keyshortcuts")),H.replaceChildren(O(r?"panel-left":n?"x":"arrow-left")),Ct()};He(),H.addEventListener("click",()=>{X()?e.onToggleCollapse?.():e.onClose()});let Ce=s("h2",{className:"persona-history-title",text:t.viewTitle,attrs:{id:a}}),Ye=s("span",{className:"persona-history-scope-title"}),$=s("p",{className:"persona-history-scope"},s("span",{className:"persona-history-scope-icon",attrs:{"aria-hidden":"true"}},O("monitor",14)),Ye),pe=s("div",{className:"persona-history-heading-group"},Ce),je=!1,de,Se=()=>{let r=S==="rail",n=r?e.renderRailHeader:void 0,p=null,h=n!==void 0;if(n)try{p=n({collapsed:N,defaultTitle:t.viewTitle})}catch(u){h=!1,je||(je=!0,console.warn("[persona] history rail renderHeader threw",u))}if(!h&&r&&e.railBrand){if(de===void 0){let u=e.railBrand(!1);de=u?s("span",{className:"persona-history-heading-brand",attrs:{"aria-hidden":"true"}},s("span",{className:"persona-history-brand-mark"},u),s("span",{className:"persona-history-wordmark",text:t.viewTitle})):null}de&&(h=!0,p=de)}Ce.classList.toggle("persona-history-sr-only",h),pe.replaceChildren(Ce),p&&pe.appendChild(p)};Se();let W=s("button",{className:"persona-history-icon-button persona-history-new-icon",attrs:{type:"button","data-persona-history-focus":"new-icon","aria-label":t.newConversationLabel}});W.appendChild(O("plus")),W.addEventListener("click",()=>{re()});let St=[H,W].map(r=>e.attachTooltip?.({anchor:r,text:()=>r.getAttribute("aria-label")??"",...r===H&&e.collapseShortcut?{hint:()=>X()?e.collapseShortcut.hint:""}:{}})),k=s("div",{className:"persona-history-topbar"}),Ge=null,Le=()=>{let r=S==="rail",n=r?We?"rail-right":"rail":"panel";n!==Ge&&(Ge=n,n==="rail"?k.append(pe,H):k.append(H,pe),r?W.remove():k.appendChild(W),v.classList.toggle("persona-history-view--rail-right",n==="rail-right"))},z=s("div",{className:"persona-history-scope-alert"}),Ue=`${a}-scope`,Lt=O("plus",18),ke=s("button",{className:"persona-history-new",attrs:{type:"button","data-persona-history-focus":"new"}},Lt,s("span",{text:t.newConversationLabel}));ke.addEventListener("click",()=>{re()});let Ee=s("div",{className:"persona-history-list-region"}),Xe=e.showDeleteAll!==!1,Ze=!!e.provider.resetDevice,Je=e.listActions??[],F=Xe||Ze||Je.length>0?Fe({className:"persona-history-list-options",label:t.listOptionsLabel,focusKey:`menu:${K}`,open:!1,inert:!0,iconSize:16,onToggle:()=>it(K)}):null,kt=s("h3",{className:"persona-history-conversations-title",text:t.conversationsTitle}),B=s("div",{className:"persona-history-caption",attrs:{"data-persona-history-item":K}},kt,e.showScopeStatus?$:null,F),Y=s("div",{className:"persona-history-body",attrs:{id:Be}},e.showScopeStatus?z:null,ke,B,Ee),Z=e.headerPlacement??"inline";Z==="external"&&k.classList.add("persona-history-topbar--shell","persona-history-topbar--shell-enter");let v=s("div",{className:T("persona-history-view",`persona-history-view--${e.presentation}`,"persona-history-view--enter"),attrs:{role:"region","aria-labelledby":a,"data-persona-history-presentation":e.presentation}},xe.element,Z==="inline"?k:null,Y),Te=()=>{v.classList.toggle("persona-history-view--rail-collapsed",N&&X())};Te(),Le();let Et=(r,n)=>{let p=`${a}-s${n}`,h=s("div",{className:T("persona-history-nav",r.placement==="footer"&&"persona-history-nav--footer"),attrs:{role:"group","data-persona-rail-section":r.id,...r.title?{"aria-labelledby":p}:{"aria-label":r.id}}});r.title&&h.appendChild(s("h3",{className:"persona-history-group-heading",text:r.title,attrs:{id:p}}));for(let u of r.items){let L=u.iconNode?.()??null,I=s("button",{className:T("persona-history-nav-item",L&&"persona-history-nav-item--icon"),attrs:{type:"button","aria-label":u.label,"data-persona-rail-item":u.id}},L?s("span",{className:"persona-history-nav-icon"},L):null,s("span",{className:"persona-history-nav-label persona-history-truncate",text:u.label}),u.badge?s("span",{className:"persona-history-nav-badge",text:u.badge}):null);I.addEventListener("click",()=>u.onSelect()),h.appendChild(I)}return h},J=null,Qe=null,Re=()=>{!J||!U||S!=="rail"||N===Qe||(Qe=N,e.railSections.forEach((r,n)=>{if(!r.render)return;let p=J[n],h=r.title?p.firstElementChild:null,u=null;try{u=r.render(N)}catch(L){r.render=void 0,console.warn("[persona] history rail section threw",r.id,L)}p.replaceChildren(...h?[h]:[],...u?[u]:[]),p.hidden=!u}))},et=()=>{let r=e.railSections;if(v.classList.toggle("persona-history-view--has-nav",S==="rail"&&!!r?.some(n=>n.placement==="above-conversations")),!!r?.length){if(S!=="rail"){J?.forEach(n=>n.remove());return}J??=r.map(Et);for(let n of["above-conversations","below-conversations","footer"]){let p=n==="above-conversations"?B.parentNode===Y?B:Ee:null;r.forEach((h,u)=>{h.placement===n&&Y.insertBefore(J[u],p)})}Re()}};et(),dt(v,"persona-history-view",yt);let tt=(r,n)=>{let p=v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r),h=Number.parseFloat(p??"");return Number.isFinite(h)&&h>=0?h:n},Tt=(r,n)=>v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r).trim()||n,Q=null,q=()=>{Q!==null&&(clearTimeout(Q),Q=null),v.removeEventListener("animationend",q),v.classList.remove("persona-history-view--enter")};v.addEventListener("animationend",q),Q=setTimeout(()=>{Q=setTimeout(q,tt("--persona-history-enter-ms",yr)+60)},0);let ee=null,te=()=>{ee!==null&&(clearTimeout(ee),ee=null),k.classList.remove("persona-history-topbar--shell-enter")},Rt=()=>{te(),k.classList.add("persona-history-topbar--shell-enter"),ee=setTimeout(te,wt+60)};Z==="external"&&(ee=setTimeout(te,wt+60));let ce=[],ye=null,At=()=>{if(ye)return ye;if(m||vr()||typeof v.animate!="function")return q(),null;let r=v.ownerDocument.defaultView?.getComputedStyle(Y).opacity||"1";q(),v.style.pointerEvents="none",_.style.pointerEvents="none";let n={duration:tt("--persona-history-exit-ms",ur),easing:Tt("--persona-history-exit-easing",hr),fill:"forwards"},p=mr[S];return ce=[Y.animate([{opacity:r,transform:"none"},{opacity:0,transform:`translateX(${p}px)`}],n)],ye=Promise.all(ce.map(fr)).then(()=>{}),ye},Ae=(r,n)=>{r&&(n?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"))},_=k,Ne=null,Nt=()=>{let r=e.slots?.header;if(!r)return;let n=`${S}|${we(w)}|${y?`${y.kind}:${"conversationId"in y?y.conversationId:""}`:""}`;if(n===Ne)return;Ne=n;let p=r({identityStatus:w,pendingAction:y,copy:t,defaultRenderer:()=>k})??k;p!==_&&(_.replaceWith(p),_=p)},rt=null,Mt=()=>{if(!e.showScopeStatus)return;let r=we(w);if(r===rt)return;rt=r;let n=xt(w,t);Ye.textContent=n.title;let p=gr(w);if($.hidden=!p,z.replaceChildren(...p?[]:[s("span",{className:"persona-history-scope-alert-title",text:n.title})],s("span",{className:"persona-history-scope-description",text:n.description,attrs:{id:Ue}})),z.setAttribute("data-persona-history-scope-tone",p?"ambient":"attention"),p?$.setAttribute("aria-describedby",Ue):$.removeAttribute("aria-describedby"),n.pending?z.setAttribute("role","status"):z.removeAttribute("role"),z.setAttribute("data-persona-history-identity",w.state),$.setAttribute("data-persona-history-identity",w.state),br(w)){let h=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryIdentityLabel,attrs:{type:"button","data-persona-history-focus":"identity-retry"}});h.addEventListener("click",()=>{C()||P("refresh")}),z.appendChild(h)}},ot=r=>y?y.kind==="open"&&y.conversationId===r?"opening":y.kind==="delete"&&y.conversationId===r?"deleting":null:null,Pt=()=>{let r=document.activeElement;return!(r instanceof HTMLElement)||!v.contains(r)?null:r.getAttribute("data-persona-history-focus")},Dt=r=>{if(b&&x){b=!1;let n=v.querySelector(`[data-persona-history-focus="${ie(x)}"]`);if(n){n.focus();return}}r&&v.querySelector(`[data-persona-history-focus="${r}"]`)?.focus()},_t=()=>{if(!M)return null;let r=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":"action-retry"}}),n=M;return r.addEventListener("click",()=>{C()||n.retry()}),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:n.message}),r)},It=()=>ht(l,o(),t,e.grouping).map((r,n)=>{let p=`${a}-g${n}`,h=s("ul",{className:"persona-history-list",attrs:{"aria-labelledby":p}});for(let u of r.items){let L=()=>ft({conversation:u,active:u.id===g,pending:ot(u.id),busy:C(),menuOpen:x===u.id,error:V.get(u.id)??null,avatar:e.rowAvatar,showDelete:e.showDelete!==!1,nowMs:o(),copy:t,onOpen:()=>{ue(u.id)},onToggleMenu:()=>it(u.id),onCloseMenu:Ie=>E(Ie),onDelete:()=>{he(u.id)}}),j=e.slots?.conversation?.({conversation:u,active:u.id===g,pending:ot(u.id),open:()=>ue(u.id),requestDelete:()=>he(u.id),defaultRenderer:L})??L();h.appendChild(j instanceof HTMLLIElement?j:s("li",{className:"persona-history-item"},j))}return s("div",{className:"persona-history-group",attrs:{"data-persona-history-group":r.key}},s("h3",{className:T("persona-history-group-heading",r.key==="recent"&&"persona-history-sr-only"),text:r.label,attrs:{id:p}}),h)}),Ot=()=>{if(!d)return null;let r=y?.kind==="load-more"||c.kind==="loading"&&c.phase==="load-more",n=s("button",{className:"persona-history-secondary persona-history-load-more",text:r?t.loadingMoreLabel:t.loadMoreLabel,attrs:{type:"button","data-persona-history-focus":"load-more",...r?{"aria-busy":"true","aria-disabled":"true"}:{},...C()&&!r?{"aria-disabled":"true"}:{}}});return n.addEventListener("click",()=>{C()||P("load-more")}),n},Vt=()=>{let r=Pt(),n=[_t()],p=l.length>0;if(p&&(n.push(...It()),n.push(Ot())),c.kind!=="ready"&&!(c.kind==="loading"&&c.phase!=="initial"&&p)){let u=c,L=u.kind==="loading"?void 0:()=>P("refresh"),I=u.kind==="new_conversation_required"?()=>re():void 0,j=()=>bt({state:u,copy:t,identityStatus:w,busy:C(),...L?{onRetry:()=>{L()}}:{},...I?{onStartNew:()=>{I()}}:{}}),Ie=e.slots?.state?.({state:u,identityStatus:w,copy:t,...L?{retry:L}:{},...I?{startNewConversation:I}:{},defaultRenderer:j});n.push(Ie??j())}Ee.replaceChildren(...n.filter(u=>!!u)),Dt(r)},zt=()=>{let r=c.kind==="loading"&&l.length===0,n=[],p=()=>n.length===0?ie(K):`${ie(K)}-${n.length}`;if(!r)for(let h of Je)n.push({label:h.label,focusKey:p(),danger:h.danger===!0,onSelect:()=>{h.onSelect({conversations:[...l]})}});return Xe&&!(l.length===0&&(c.kind==="empty"||r))&&n.push({label:t.clearHistoryLabel,focusKey:p(),danger:!0,onSelect:()=>{Pe()}}),Ze&&!r&&n.push({label:t.resetIdentityLabel,focusKey:p(),danger:!0,onSelect:()=>{_e()}}),n},Ft=()=>{if(Ae(ke,C()),Ae(W,C()),F){let r=zt(),n=c.kind==="loading"&&l.length===0;F.hidden=r.length===0&&!n,Ae(F,C()||r.length===0),F.setAttribute("aria-expanded",x===K?"true":"false");let p=B.querySelector(".persona-history-menu");if(x!==K||r.length===0)p?.remove();else{let h=qe({label:t.listOptionsLabel,items:r,onCloseMenu:u=>E(u)});p?p.replaceWith(h):B.appendChild(h)}}B.hidden=S!=="rail"&&(!F||F.hidden)&&(!e.showScopeStatus||$.hidden)},nt,qt=()=>{let r=e.onActiveConversationChange;if(!r)return;let n=l.find(h=>h.id===g)??null,p=n?`${n.id}\0${n.title}\0${n.starred?1:0}`:"";p!==nt&&(nt=p,r(n))},f=()=>{if(!m){if(qt(),!U){e.onModelChange?.();return}Nt(),Mt(),Ft(),Vt(),Re()}},E=r=>{if(!x)return;let n=x;x=null,b=!1,f(),r?.restoreFocus&&v.querySelector(`[data-persona-history-focus="menu:${n}"]`)?.focus()},it=r=>{if(x===r){E({restoreFocus:!0});return}x=r,b=!0,f()},st=r=>{if(!x)return;let n=r.target;n instanceof Node&&v.contains(n)&&n.closest?.(`[data-persona-history-item="${x}"]`)||E()};document.addEventListener("pointerdown",st,!0);let at=r=>{r.key!=="Escape"||!x||(r.stopPropagation(),E({restoreFocus:!0}))};v.addEventListener("keydown",at);async function P(r){if(m)return;let n=++D,p=r==="load-more"?d:null;if(!(r==="load-more"&&!p)){y={kind:r==="load-more"?"load-more":"refresh"},c={kind:"loading",phase:r},r!=="load-more"&&(V.clear(),M=null),E(),f();try{let h=await e.provider.list({limit:i,context:e.context,...p?{cursor:p}:{},...e.targetId?{targetId:e.targetId}:{}});if(m||n!==D)return;l=p?[...l,...h.items]:h.items,d=h.nextCursor,c=l.length===0?{kind:"empty"}:{kind:"ready"}}catch(h){if(m||n!==D)return;c=gt(h)}finally{!m&&n===D&&(y=null,f())}}}let Me=r=>{l=l.filter(n=>n.id!==r),V.delete(r),g===r&&(g=null),l.length===0&&!d&&(c={kind:"empty"})};async function ue(r){if(!(C()||m)){V.delete(r),E(),y={kind:"open",conversationId:r},f();try{if(await e.onSelect(r),m)return;g=r}catch{if(m)return;V.set(r,{message:t.openFailedLabel,retry:()=>{ue(r)}})}finally{m||(y=null,f())}}}async function he(r){if(C()||m)return"cancelled";V.delete(r),y={kind:"delete",conversationId:r},f();try{let n=await e.onRequestDeleteConversation(r);return m||n==="deleted"&&(Me(r),ae(t.conversationRemovedNotice)),n}catch(n){return m||(ge(n)&&n.code==="not_found"?Me(r):V.set(r,{message:t.deleteFailedLabel,retry:()=>{he(r)}})),"cancelled"}finally{m||(y=null,f())}}async function re(){if(!(C()||m)){M=null,E(),y={kind:"start-new"},f();try{if(await e.onStartNew(),m)return;c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"})}catch{if(m)return;M={message:t.errorDescription,retry:()=>{re()}}}finally{m||(y=null,f())}}}async function Pe(){if(C()||m)return"cancelled";M=null,E(),y={kind:"clear"},f();try{let r=await e.onRequestClearHistory();return m||r==="cleared"&&(l=[],d=null,g=null,c={kind:"empty"},ae(t.historyClearedNotice)),r}catch{return m||(M={message:t.errorDescription,retry:()=>{Pe()}}),"cancelled"}finally{m||(y=null,f())}}let De={outcome:"cancelled"};async function _e(){if(C()||m||!e.onRequestResetIdentity)return De;M=null,E(),y={kind:"reset"},f();try{let r=await e.onRequestResetIdentity();return m||r.outcome==="reset"&&(ae(r.remoteRevocationConfirmed?t.identityResetNotice:t.identityResetUnconfirmedNotice),y=null,await P("refresh")),r}catch{return m||(M={message:t.errorDescription,retry:()=>{_e()}}),De}finally{!m&&y?.kind==="reset"&&(y=null,f())}}let Kt=e.provider.subscribeIdentityStatus(r=>{if(m)return;let n=we(r),p=n!==A;w=r,A=n,f(),p&&r.state!=="verifying"&&ae(xt(r,t).title)}),$t=e.provider.subscribeAvailability?.(r=>{if(!m){if(r){P("refresh");return}l=[],d=null,c={kind:"error",reason:"unavailable",retryable:!1},f()}});return f(),P("initial"),{element:v,copy:t,getModel:()=>({conversations:l,activeConversationId:g,state:c,pendingAction:y,identityStatus:w,nextCursor:d}),operations:{refresh:async()=>{C()||await P("refresh")},loadMore:async()=>{C()||await P("load-more")},openConversation:r=>ue(r),startNewConversation:()=>re(),requestDeleteConversation:r=>he(r),requestClearConversationHistory:()=>Pe(),requestResetHistoryIdentity:()=>_e()},setDomRenderEnabled:r=>{r!==U&&(U=r,r&&f())},refresh:()=>{P("refresh")},setPresentation:r=>{if(r===S)return;q(),S=r,Ne=null;let n=r==="rail";v.classList.toggle("persona-history-view--panel",!n),v.classList.toggle("persona-history-view--rail",n),v.setAttribute("data-persona-history-presentation",r),He(),Te(),Le(),Se(),et(),f()},setCollapsed:r=>{r!==N&&(N=r,Te(),He(),Se(),Re())},setRailSide:r=>{We=r==="right",Le()},getHeaderElement:()=>_,setHeaderPlacement:r=>{if(r===Z)return;Z=r;let n=r==="external";if(k.classList.toggle("persona-history-topbar--shell",n),n){Rt(),_.remove();return}te(),v.insertBefore(_,Y)},setActiveConversationId:r=>{g!==r&&(g=r,f())},applyConversationSummary:r=>{let n=l.findIndex(p=>p.id===r.id);n!==-1&&(l[n]=r,f())},removeConversationSummary:r=>{l.some(n=>n.id===r)&&(Me(r),f())},setNewConversationRequired:r=>{r?c={kind:"new_conversation_required"}:c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"}),f()},playExit:At,destroy:()=>{m=!0,D+=1,q(),te(),St.forEach(r=>r?.destroy()),_.remove(),ce.forEach(r=>r.cancel()),ce=[],Kt(),$t?.(),document.removeEventListener("pointerdown",st,!0),v.removeEventListener("keydown",at),xe.destroy(),v.remove(),v.replaceChildren()}}}var wr="button:not([disabled])";function Ht(e){let t=document.activeElement instanceof HTMLElement?document.activeElement:null,o=Math.random().toString(36).slice(2,8),i=`persona-history-confirm-title-${o}`,a=`persona-history-confirm-desc-${o}`,l=s("button",{className:"persona-history-confirm__cancel",text:e.cancelLabel,attrs:{type:"button"}}),d=s("button",{className:"persona-history-confirm__confirm",text:e.confirmLabel,attrs:{type:"button","data-persona-destructive":"true"}}),c=s("div",{className:"persona-history-confirm__dialog",attrs:{role:"alertdialog","aria-modal":"true","aria-labelledby":i,"aria-describedby":a},style:{maxWidth:"22rem",width:"100%",borderRadius:"var(--persona-radius-lg, 0.75rem)",background:"var(--persona-surface, #ffffff)",color:"var(--persona-text, #111827)",boxShadow:"var(--persona-history-confirm-shadow, 0 20px 40px -12px rgba(0, 0, 0, 0.35))",padding:"20px",display:"flex",flexDirection:"column",gap:"12px"}},s("h2",{className:"persona-history-confirm__title",text:e.title,attrs:{id:i},style:{margin:"0",fontSize:"1rem",fontWeight:"600"}}),s("p",{className:"persona-history-confirm__description",text:e.description,attrs:{id:a},style:{margin:"0",fontSize:"0.875rem",lineHeight:"1.4"}}),s("div",{className:"persona-history-confirm__actions",style:{display:"flex",gap:"8px",justifyContent:"flex-end",flexWrap:"wrap"}},l,d));for(let g of[l,d])g.style.minHeight="44px",g.style.minWidth="88px",g.style.padding="0 16px",g.style.borderRadius="var(--persona-radius-md, 0.5rem)",g.style.cursor="pointer",g.style.font="inherit";l.style.border="1px solid var(--persona-border, rgba(0,0,0,0.12))",l.style.background="transparent",l.style.color="inherit",d.style.border="none",d.style.background="var(--persona-danger, #b42318)",d.style.color="var(--persona-danger-fg, #ffffff)";let y=s("div",{className:"persona-history-confirm",style:{position:"absolute",inset:"0",zIndex:"40",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",background:"var(--persona-history-confirm-scrim, rgba(15, 23, 42, 0.45))"}},c);return new Promise(g=>{let w=!1,A=b=>{w||(w=!0,y.removeEventListener("keydown",x,!0),y.remove(),t?.focus(),g(b))};function x(b){if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),A(!1);return}if(b.key!=="Tab")return;let m=Array.from(c.querySelectorAll(wr));if(m.length===0)return;let D=m[0],S=m[m.length-1],G=document.activeElement;b.shiftKey&&(G===D||!c.contains(G))?(b.preventDefault(),S.focus()):!b.shiftKey&&G===S&&(b.preventDefault(),D.focus())}y.addEventListener("keydown",x,!0),y.addEventListener("pointerdown",b=>{b.target===y&&A(!1)}),l.addEventListener("click",()=>A(!1)),d.addEventListener("click",()=>A(!0)),e.host.appendChild(y),l.focus()})}0&&(module.exports={HISTORY_VIEW_COPY_DEFAULTS,createHistoryView,resolveHistoryViewCopy,showHistoryConfirm});
@@ -1130,6 +1130,11 @@ type AgentWidgetToolCall = {
1130
1130
  startedAt?: number;
1131
1131
  completedAt?: number;
1132
1132
  durationMs?: number;
1133
+ /**
1134
+ * The call paused for an approval that was granted, and the agent re-ran it
1135
+ * as a new tool call: that later call carries the result, this one has none.
1136
+ */
1137
+ superseded?: boolean;
1133
1138
  };
1134
1139
  /**
1135
1140
  * Represents a tool approval request in the chat conversation.
@@ -1151,6 +1156,8 @@ type AgentWidgetApproval = {
1151
1156
  */
1152
1157
  reason?: string;
1153
1158
  parameters?: unknown;
1159
+ /** The paused tool call this approval gates (`approval_start.toolCallId`). */
1160
+ toolCallId?: string;
1154
1161
  resolvedAt?: number;
1155
1162
  };
1156
1163
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
@@ -1250,6 +1257,13 @@ type AgentWidgetMessage = {
1250
1257
  * }
1251
1258
  */
1252
1259
  voiceProcessing?: boolean;
1260
+ /**
1261
+ * Display-only caption of full-duplex voice speech, such as the voice
1262
+ * model's own words, or something the visitor said that wasn't submitted
1263
+ * as a chat turn. It renders in the transcript but is never sent to the
1264
+ * model as conversation.
1265
+ */
1266
+ voiceCaption?: boolean;
1253
1267
  /**
1254
1268
  * Raw structured payload for this message (e.g., JSON action response).
1255
1269
  * Populated automatically when structured parsers run.
@@ -1643,4 +1657,24 @@ interface HistoryViewHandle {
1643
1657
  }
1644
1658
  declare function createHistoryView(options: HistoryViewOptions): HistoryViewHandle;
1645
1659
 
1646
- export { HISTORY_VIEW_COPY_DEFAULTS, type HistoryListErrorReason, type HistoryListState, type HistoryViewCopyInput, type HistoryViewHandle, type HistoryViewOptions, type HistoryViewPendingAction, type HistoryViewPresentation, type ResolvedHistoryViewCopy, createHistoryView, resolveHistoryViewCopy };
1660
+ /**
1661
+ * Shell-owned destructive confirmation for history actions
1662
+ * (`docs/visitor-history-implementation-plan.md` D7, accessibility contract).
1663
+ *
1664
+ * An alert dialog: labelled and described, focus-trapped, least-destructive
1665
+ * action focused first, Escape resolves `false`, and focus returns to whatever
1666
+ * was focused when it opened. Styling is inline so the dialog costs no bytes in
1667
+ * `widget.css`; colors come from the same theme variables the panel uses.
1668
+ */
1669
+ interface HistoryConfirmOptions {
1670
+ title: string;
1671
+ description: string;
1672
+ confirmLabel: string;
1673
+ cancelLabel: string;
1674
+ /** Where the modal mounts. Normally the widget container. */
1675
+ host: HTMLElement;
1676
+ }
1677
+ /** Resolves `true` only for the confirming action. */
1678
+ declare function showHistoryConfirm(options: HistoryConfirmOptions): Promise<boolean>;
1679
+
1680
+ export { HISTORY_VIEW_COPY_DEFAULTS, type HistoryListErrorReason, type HistoryListState, type HistoryViewCopyInput, type HistoryViewHandle, type HistoryViewOptions, type HistoryViewPendingAction, type HistoryViewPresentation, type ResolvedHistoryViewCopy, createHistoryView, resolveHistoryViewCopy, showHistoryConfirm };
@@ -1130,6 +1130,11 @@ type AgentWidgetToolCall = {
1130
1130
  startedAt?: number;
1131
1131
  completedAt?: number;
1132
1132
  durationMs?: number;
1133
+ /**
1134
+ * The call paused for an approval that was granted, and the agent re-ran it
1135
+ * as a new tool call: that later call carries the result, this one has none.
1136
+ */
1137
+ superseded?: boolean;
1133
1138
  };
1134
1139
  /**
1135
1140
  * Represents a tool approval request in the chat conversation.
@@ -1151,6 +1156,8 @@ type AgentWidgetApproval = {
1151
1156
  */
1152
1157
  reason?: string;
1153
1158
  parameters?: unknown;
1159
+ /** The paused tool call this approval gates (`approval_start.toolCallId`). */
1160
+ toolCallId?: string;
1154
1161
  resolvedAt?: number;
1155
1162
  };
1156
1163
  type AgentWidgetMessageVariant = "assistant" | "reasoning" | "tool" | "approval";
@@ -1250,6 +1257,13 @@ type AgentWidgetMessage = {
1250
1257
  * }
1251
1258
  */
1252
1259
  voiceProcessing?: boolean;
1260
+ /**
1261
+ * Display-only caption of full-duplex voice speech, such as the voice
1262
+ * model's own words, or something the visitor said that wasn't submitted
1263
+ * as a chat turn. It renders in the transcript but is never sent to the
1264
+ * model as conversation.
1265
+ */
1266
+ voiceCaption?: boolean;
1253
1267
  /**
1254
1268
  * Raw structured payload for this message (e.g., JSON action response).
1255
1269
  * Populated automatically when structured parsers run.
@@ -1643,4 +1657,24 @@ interface HistoryViewHandle {
1643
1657
  }
1644
1658
  declare function createHistoryView(options: HistoryViewOptions): HistoryViewHandle;
1645
1659
 
1646
- export { HISTORY_VIEW_COPY_DEFAULTS, type HistoryListErrorReason, type HistoryListState, type HistoryViewCopyInput, type HistoryViewHandle, type HistoryViewOptions, type HistoryViewPendingAction, type HistoryViewPresentation, type ResolvedHistoryViewCopy, createHistoryView, resolveHistoryViewCopy };
1660
+ /**
1661
+ * Shell-owned destructive confirmation for history actions
1662
+ * (`docs/visitor-history-implementation-plan.md` D7, accessibility contract).
1663
+ *
1664
+ * An alert dialog: labelled and described, focus-trapped, least-destructive
1665
+ * action focused first, Escape resolves `false`, and focus returns to whatever
1666
+ * was focused when it opened. Styling is inline so the dialog costs no bytes in
1667
+ * `widget.css`; colors come from the same theme variables the panel uses.
1668
+ */
1669
+ interface HistoryConfirmOptions {
1670
+ title: string;
1671
+ description: string;
1672
+ confirmLabel: string;
1673
+ cancelLabel: string;
1674
+ /** Where the modal mounts. Normally the widget container. */
1675
+ host: HTMLElement;
1676
+ }
1677
+ /** Resolves `true` only for the confirming action. */
1678
+ declare function showHistoryConfirm(options: HistoryConfirmOptions): Promise<boolean>;
1679
+
1680
+ export { HISTORY_VIEW_COPY_DEFAULTS, type HistoryListErrorReason, type HistoryListState, type HistoryViewCopyInput, type HistoryViewHandle, type HistoryViewOptions, type HistoryViewPendingAction, type HistoryViewPresentation, type ResolvedHistoryViewCopy, createHistoryView, resolveHistoryViewCopy, showHistoryConfirm };
@@ -1,4 +1,4 @@
1
- var ue=e=>e.nodeType===Node.DOCUMENT_NODE,st=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host!==void 0;function it(e){let t=e.getRootNode?.();return t&&st(t)||t&&ue(t)?t:e.ownerDocument??document}function ye(e,t,o){let i=ue(e)?e.head:e,a=t.replace(/["\\]/g,"\\$&");if(i.querySelector(`style[data-persona-plugin-style="${a}"]`))return;let u=(ue(e)?e:e.ownerDocument??document).createElement("style");u.setAttribute("data-persona-plugin-style",t),u.textContent=o,i.appendChild(u)}function at(e,t,o){if(ue(e)||st(e)){ye(e,t,o);return}let i=e;if(i.isConnected){ye(it(i),t,o);return}let a=i.ownerDocument??document;ye(a,t,o),queueMicrotask(()=>{let l=it(i);l!==a&&ye(l,t,o)})}var s=(e,t={},...o)=>{let i=document.createElement(e);if(t.className&&(i.className=t.className),t.text!==void 0&&(i.textContent=t.text),t.attrs)for(let[l,u]of Object.entries(t.attrs))i.setAttribute(l,u);if(t.style){let l=i.style,u=t.style;for(let c of Object.keys(u)){let h=u[c];h!=null&&(l[c]=h)}}let a=o.filter(l=>l!=null);return a.length>0&&i.append(...a),i},T=(...e)=>e.filter(Boolean).join(" ");function lt(){let e=document.createElement("div");e.className="persona-history-sr-only",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-persona-history-live-region","");let t;return{element:e,announce(o){t!==void 0&&clearTimeout(t),e.textContent="",t=setTimeout(()=>{t=void 0,e.textContent=o},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}var pt=`
1
+ var he=e=>e.nodeType===Node.DOCUMENT_NODE,at=e=>e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&e.host!==void 0;function st(e){let t=e.getRootNode?.();return t&&at(t)||t&&he(t)?t:e.ownerDocument??document}function ue(e,t,o){let i=he(e)?e.head:e,l=t.replace(/["\\]/g,"\\$&");if(i.querySelector(`style[data-persona-plugin-style="${l}"]`))return;let d=(he(e)?e:e.ownerDocument??document).createElement("style");d.setAttribute("data-persona-plugin-style",t),d.textContent=o,i.appendChild(d)}function lt(e,t,o){if(he(e)||at(e)){ue(e,t,o);return}let i=e;if(i.isConnected){ue(st(i),t,o);return}let l=i.ownerDocument??document;ue(l,t,o),queueMicrotask(()=>{let a=st(i);a!==l&&ue(a,t,o)})}var s=(e,t={},...o)=>{let i=document.createElement(e);if(t.className&&(i.className=t.className),t.text!==void 0&&(i.textContent=t.text),t.attrs)for(let[a,d]of Object.entries(t.attrs))i.setAttribute(a,d);if(t.style){let a=i.style,d=t.style;for(let c of Object.keys(d)){let y=d[c];y!=null&&(a[c]=y)}}let l=o.filter(a=>a!=null);return l.length>0&&i.append(...l),i},T=(...e)=>e.filter(Boolean).join(" ");function pt(){let e=document.createElement("div");e.className="persona-history-sr-only",e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),e.setAttribute("data-persona-history-live-region","");let t;return{element:e,announce(o){t!==void 0&&clearTimeout(t),e.textContent="",t=setTimeout(()=>{t=void 0,e.textContent=o},0)},destroy(){t!==void 0&&clearTimeout(t),e.remove()}}}var dt=`
2
2
  .persona-history-view {
3
3
  --persona-history-surface-bg: var(--persona-surface, #ffffff);
4
4
  --persona-history-topbar-bg: var(--persona-header-bg, var(--persona-surface, #ffffff));
@@ -895,4 +895,4 @@ var ue=e=>e.nodeType===Node.DOCUMENT_NODE,st=e=>e.nodeType===Node.DOCUMENT_FRAGM
895
895
  .persona-history-view .persona-history-skeleton-bar { animation: none; }
896
896
  .persona-history-rail-host { transition: none; }
897
897
  }
898
- `;var dt={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."};var he={...dt,emptyTitle:"No conversations yet",emptyDescription:"Start a conversation and it will show up here.",errorTitle:"Could not load conversations",errorDescription:"Something went wrong. Please try again.",retryLabel:"Retry",rateLimitedTitle:"Too many requests",rateLimitedDescription:"Please wait a moment before trying again.",groupStarred:"Starred",groupToday:"Today",groupYesterday:"Yesterday",groupPrevious7Days:"Previous 7 days",groupPrevious30Days:"Previous 30 days",groupMonthYear:"{month} {year}",browserOnlyTitle:"On this device",browserOnlyDescription:"Another browser or device keeps its own separate history.",verifyingTitle:"Checking your account",verifyingDescription:"Looking for messages linked to your account.",verifiedTitle:"Available across signed-in devices",verifiedDescription:"This list refreshes when the chat opens rather than syncing live.",authenticationRequiredTitle:"Sign in to see your messages",authenticationRequiredDescription:"Your session expired. Sign in again to load account history.",identityProviderFailedTitle:"Account history is unavailable",identityProviderFailedDescription:"We could not verify your account, so account history is not shown here.",proofNotAdmittedTitle:"Account history is unavailable",proofNotAdmittedDescription:"This assistant is not set up to accept your account identity.",retryIdentityLabel:"Try again",backLabel:"Back to conversation",closeLabel:"Close conversation list",loadingLabel:"Loading conversations",loadMoreLabel:"Load more",loadingMoreLabel:"Loading more conversations",conversationsTitle:"Conversations",rowActionsLabel:"Conversation options",listOptionsLabel:"Conversation options",deleteConversationLabel:"Delete",clearHistoryLabel:"Delete all conversations",resetIdentityLabel:"Forget this device",messageCountLabel:"{count} messages",messageCountLabelOne:"1 message",conversationRemovedNotice:"Conversation deleted.",historyClearedNotice:"All conversations were deleted.",unavailableTitle:"Conversation history is unavailable",unavailableDescription:"Try again later.",newConversationRequiredTitle:"Start a new conversation",newConversationRequiredDescription:"The previous conversation is gone. Start a new one to keep chatting.",rateLimitedWaitDescription:"You can try again in {seconds} seconds.",openFailedLabel:"Could not open that conversation.",deleteFailedLabel:"Could not delete that conversation.",relativeNow:"now",relativeMinutes:"{value}m",relativeHours:"{value}h",relativeDays:"{value}d",relativeWeeks:"{value}w",relativeYears:"{value}y"};function me(e){if(!e)return he;let t={...he};for(let[o,i]of Object.entries(e))typeof i=="string"&&i.length>0&&(t[o]=i);return t}function E(e,t){return e.replace(/\{(\w+)\}/g,(o,i)=>i in t?String(t[i]):o)}var Ie=864e5;function $t(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Oe(e,t){let o=Date.parse(e);return Number.isFinite(o)?o:t}function Kt(e,t){let o=Oe(e,t),i=$t(t);if(o>=i)return"today";if(o>=i-Ie)return"yesterday";if(o>=i-7*Ie)return"previous-7-days";if(o>=i-30*Ie)return"previous-30-days";let a=new Date(o);return`month:${a.getFullYear()}-${a.getMonth()}`}function Bt(e,t,o,i){if(e==="today")return i.groupToday;if(e==="yesterday")return i.groupYesterday;if(e==="previous-7-days")return i.groupPrevious7Days;if(e==="previous-30-days")return i.groupPrevious30Days;let a=new Date(Oe(t,o));return E(i.groupMonthYear,{month:a.toLocaleString(void 0,{month:"long"}),year:a.getFullYear()})}function ct(e,t,o,i="time"){let a=e.filter(u=>u.starred),l=a.length>0?[{key:"starred",label:o.groupStarred,items:a}]:[];if(i==="none"){let u=e.filter(c=>!c.starred);return u.length>0&&l.push({key:"recent",label:o.conversationsTitle,items:u}),l}for(let u of e){if(u.starred)continue;let c=Kt(u.updatedAt,t),h=l[l.length-1];if(h&&h.key===c){h.items.push(u);continue}l.push({key:c,label:Bt(c,u.updatedAt,t,o),items:[u]})}return l}function yt(e,t,o){let i=Math.max(0,t-Oe(e,t)),a=Math.floor(i/6e4);if(a<1)return o.relativeNow;if(a<60)return E(o.relativeMinutes,{value:a});let l=Math.floor(a/60);if(l<24)return E(o.relativeHours,{value:l});let u=Math.floor(l/24);if(u<7)return E(o.relativeDays,{value:u});let c=Math.floor(u/7);return u<365?E(o.relativeWeeks,{value:c}):E(o.relativeYears,{value:Math.floor(u/365)})}function ut(e,t){return e===1?t.messageCountLabelOne:E(t.messageCountLabel,{count:e})}var ve="http://www.w3.org/2000/svg",Wt={"arrow-left":["m12 19-7-7 7-7","M19 12H5"],plus:["M5 12h14","M12 5v14"],star:["m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z"],x:["M18 6 6 18","m6 6 12 12"],"panel-left":["M9 3v18"],monitor:["M8 21h8","M12 17v4"],ellipsis:[]},Yt={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function _(e,t=20){let o=document.createElementNS(ve,"svg");if(o.setAttribute("width",String(t)),o.setAttribute("height",String(t)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),e==="ellipsis"){for(let a of[12,19,5]){let l=document.createElementNS(ve,"circle");l.setAttribute("cx",String(a)),l.setAttribute("cy","12"),l.setAttribute("r","1"),o.appendChild(l)}return o}let i=Yt[e];if(i){let a=document.createElementNS(ve,"rect");a.setAttribute("x",String(i[0])),a.setAttribute("y",String(i[1])),a.setAttribute("width",String(i[2])),a.setAttribute("height",String(i[3])),a.setAttribute("rx","2"),o.appendChild(a)}for(let a of Wt[e]){let l=document.createElementNS(ve,"path");l.setAttribute("d",a),o.appendChild(l)}return o}var jt=/^(https?:|\/|data:)/i;function Gt(e){let t=s("span",{className:"persona-history-row-avatar",attrs:{"aria-hidden":"true"}});return jt.test(e)?t.appendChild(s("img",{attrs:{src:e,alt:"",loading:"lazy"}})):t.textContent=e,t}var Ut=e=>`row:${e}`,Xt=e=>`menu:${e}`,te=e=>`menu-item:${e}`;function ht(e){let{conversation:t,copy:o,busy:i,pending:a}=e,l=i||a!==null,u=t.title.trim().length>0,c=t.starred?(()=>{let M=_("star",11);return M.setAttribute("fill","currentColor"),M.setAttribute("stroke-width","1"),s("span",{className:"persona-history-row-star"},M,s("span",{className:"persona-history-sr-only",text:o.groupStarred}))})():null,h=s("div",{className:"persona-history-row-head"},s("span",{className:"persona-history-row-title persona-history-truncate",text:u?t.title:t.preview??""}),c,s("time",{className:"persona-history-row-time",attrs:{datetime:t.updatedAt},text:yt(t.updatedAt,e.nowMs,o)})),C=u&&t.preview?s("span",{className:"persona-history-row-preview persona-history-truncate",text:t.preview}):null,b=s("button",{className:T("persona-history-row",e.active&&"persona-history-row--active",a&&`persona-history-row--${a}`),attrs:{type:"button","data-persona-history-focus":Ut(t.id),"data-persona-history-conversation":t.id,...e.active?{"aria-current":"page"}:{},...l?{"aria-disabled":"true"}:{},...a?{"aria-busy":"true"}:{}}},e.avatar?Gt(e.avatar):null,s("div",{className:"persona-history-row-body"},h,C,s("span",{className:"persona-history-row-count persona-history-sr-only",text:ut(t.messageCount,o)})));b.addEventListener("click",()=>{l||e.onOpen()});let oe=e.showDelete?Ve({className:"persona-history-row-menu-button",label:`${o.rowActionsLabel}: ${t.title}`,focusKey:Xt(t.id),open:e.menuOpen,inert:l,onToggle:e.onToggleMenu}):null;return s("li",{className:T("persona-history-item",!e.showDelete&&"persona-history-item--no-menu"),attrs:{"data-persona-history-item":t.id}},b,oe,e.menuOpen&&e.showDelete?Zt(e):null,e.error?Jt(e.error,o,t.id):null)}function Zt(e){let{conversation:t,copy:o}=e;return ze({label:`${o.rowActionsLabel}: ${t.title}`,items:[{label:o.deleteConversationLabel,focusKey:te(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function Ve(e){let t=s("button",{className:T("persona-history-icon-button",e.className),attrs:{type:"button","aria-label":e.label,"aria-haspopup":"menu","aria-expanded":e.open?"true":"false","data-persona-history-focus":e.focusKey,...e.inert?{"aria-disabled":"true"}:{}}});t.appendChild(_("ellipsis",e.iconSize));let o=()=>t.getAttribute("aria-disabled")==="true";return t.addEventListener("click",i=>{i.stopPropagation(),!o()&&e.onToggle()}),t.addEventListener("keydown",i=>{i.key!=="ArrowDown"&&i.key!=="ArrowUp"||(i.preventDefault(),!(o()||t.getAttribute("aria-expanded")==="true")&&e.onToggle())}),t}function ze(e){let t=s("div",{className:"persona-history-menu",attrs:{role:"menu","aria-label":e.label}});for(let o of e.items){let i=s("button",{className:T("persona-history-menu-item",o.danger&&"persona-history-menu-item--danger"),text:o.label,attrs:{type:"button",role:"menuitem",tabindex:"0","data-persona-history-focus":o.focusKey}});i.addEventListener("click",()=>{e.onCloseMenu(),o.onSelect()}),t.appendChild(i)}return t.addEventListener("keydown",o=>{let i=Array.from(t.querySelectorAll('[role="menuitem"]'));if(i.length===0)return;let a=i.indexOf(document.activeElement);if(o.key==="Tab"){e.onCloseMenu({restoreFocus:!0});return}if(o.key==="ArrowDown"){o.preventDefault(),i[(a+1+i.length)%i.length]?.focus();return}if(o.key==="ArrowUp"){o.preventDefault(),i[(a-1+i.length)%i.length]?.focus();return}if(o.key==="Home"){o.preventDefault(),i[0]?.focus();return}o.key==="End"&&(o.preventDefault(),i[i.length-1]?.focus())}),t}function Jt(e,t,o){let i=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":`row-retry:${o}`}});return i.addEventListener("click",e.retry),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:e.message}),i)}var Fe=class extends Error{constructor(t,o,i){super(o),this.name="HistoryProviderError",this.code=t,i?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=i.retryAfterSeconds)}};function ge(e){return e instanceof Fe}function Qt(e){switch(e){case"authentication_failed":case"authentication_required":case"identity_provider_failed":case"proof_not_admitted":case"unsupported_scope":case"unavailable":return e;default:return"unknown"}}function mt(e){if(ge(e)){if(e.code==="rate_limited")return{kind:"rate_limited",retryAfterSeconds:e.retryAfterSeconds??0};let t=Qt(e.code);return{kind:"error",reason:t,retryable:t!=="unsupported_scope"}}return{kind:"error",reason:"unknown",retryable:!0}}function er(e,t){switch(e.state){case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function tr(e,t){switch(e){case"authentication_required":case"authentication_failed":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"proof_not_admitted":case"unsupported_scope":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function fe(e,t,o,i){let a=s("button",{className:"persona-history-secondary persona-history-state-action",text:e,attrs:{type:"button","data-persona-history-focus":t,...o?{"aria-disabled":"true"}:{}}});return a.addEventListener("click",()=>{o||i()}),a}function re(e,t,o,i,a){return s("div",{className:"persona-history-state",attrs:{"data-persona-history-state":e,...a?{role:"alert"}:{role:"status"}}},s("p",{className:"persona-history-state-title",text:t}),s("p",{className:"persona-history-state-description",text:o}),i)}function rr(e){let t=["42%","58%","34%"],o=["94%","78%","88%"],i=[0,1,2].map(a=>s("div",{className:"persona-history-skeleton-row",attrs:{"aria-hidden":"true"}},s("div",{className:"persona-history-skeleton-head"},s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--title",style:{width:t[a]}}),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--time"})),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--preview",style:{width:o[a]}})));return s("div",{className:"persona-history-view-loading",attrs:{"data-persona-history-state":"loading",role:"status","aria-label":e.loadingLabel}},...i)}function vt(e){let{state:t,copy:o,busy:i}=e;if(t.kind==="loading")return rr(o);if(t.kind==="empty"){let c=er(e.identityStatus,o);return c?re("identity",c.title,c.description,e.onRetry?fe(o.retryIdentityLabel,"state-retry",i,e.onRetry):null,!0):re("empty",o.emptyTitle,o.emptyDescription,null,!1)}if(t.kind==="rate_limited"){let c=t.retryAfterSeconds>0?E(o.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):o.rateLimitedDescription;return re("rate_limited",o.rateLimitedTitle,c,e.onRetry?fe(o.retryLabel,"state-retry",i,e.onRetry):null,!1)}if(t.kind==="new_conversation_required")return re("new_conversation_required",o.newConversationRequiredTitle,o.newConversationRequiredDescription,e.onStartNew?fe(o.newConversationLabel,"state-retry",i,e.onStartNew):null,!0);let{title:a,description:l}=tr(t.reason,o),u=t.reason==="authentication_required"||t.reason==="authentication_failed"||t.reason==="identity_provider_failed"?o.retryIdentityLabel:o.retryLabel;return re("error",a,l,t.retryable&&e.onRetry?fe(u,"state-retry",i,e.onRetry):null,!0)}var or=25,F="persona:list-options",nr=180,gt=120,ir=160,sr="cubic-bezier(0.4, 0, 1, 1)",ar={panel:20,rail:12},lr=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,pr=e=>e.finished?e.finished.then(()=>{},()=>{}):Promise.resolve();function be(e){return`${e.state}:${"reason"in e?e.reason:""}`}function ft(e,t){switch(e.state){case"verified":return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case"verifying":case"resetting":return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function dr(e){return e.state==="verified"||e.state==="browser_only"}function cr(e){return e.state==="authentication_required"||e.state==="identity_provider_failed"||e.state==="configuration_error"}function bt(e){let t=me(e.copy),o=e.now??(()=>Date.now()),i=e.pageSize??or,a=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,l=[],u=null,c={kind:"loading",phase:"initial"},h=null,C=e.activeConversationId,b=e.provider.getIdentityStatus(),oe=be(b),x=null,M=!1,m=!1,Y=0,S=e.presentation,wt=e.collapsible!==!1,R=e.collapsed===!0,qe=e.railSide==="right",j=e.renderDom!==!1,I=new Map,A=null,we=lt(),ne=r=>{!j&&e.onAnnounce?e.onAnnounce(r):we.announce(r)},w=()=>h!==null,$e=`${a}-body`,f=s("button",{className:"persona-history-icon-button persona-history-back",attrs:{type:"button"}}),G=()=>S==="rail"&&wt,ie,xt=()=>{if(e.railBrand){if(!G()){f.classList.remove("persona-history-back--branded");return}if(ie===void 0){let r=e.railBrand(!0);ie=r?s("span",{className:"persona-history-brand-mark persona-history-toggle-brand",attrs:{"aria-hidden":"true"}},r):null}ie&&(f.classList.add("persona-history-back--branded"),f.appendChild(ie))}},xe=()=>{let r=G(),n=S==="rail";f.setAttribute("data-persona-history-focus",r?"collapse":"close"),f.setAttribute("aria-label",r?R?t.expandLabel:t.collapseLabel:n?t.closeLabel:t.backLabel),r?(f.setAttribute("aria-expanded",R?"false":"true"),f.setAttribute("aria-controls",$e),e.collapseShortcut?.aria&&f.setAttribute("aria-keyshortcuts",e.collapseShortcut.aria)):(f.removeAttribute("aria-expanded"),f.removeAttribute("aria-controls"),f.removeAttribute("aria-keyshortcuts")),f.replaceChildren(_(r?"panel-left":n?"x":"arrow-left")),xt()};xe(),f.addEventListener("click",()=>{G()?e.onToggleCollapse?.():e.onClose()});let He=s("h2",{className:"persona-history-title",text:t.viewTitle,attrs:{id:a}}),Ke=s("span",{className:"persona-history-scope-title"}),q=s("p",{className:"persona-history-scope"},s("span",{className:"persona-history-scope-icon",attrs:{"aria-hidden":"true"}},_("monitor",14)),Ke),se=s("div",{className:"persona-history-heading-group"},He),Be=!1,ae,Ce=()=>{let r=S==="rail",n=r?e.renderRailHeader:void 0,p=null,y=n!==void 0;if(n)try{p=n({collapsed:R,defaultTitle:t.viewTitle})}catch(d){y=!1,Be||(Be=!0,console.warn("[persona] history rail renderHeader threw",d))}if(!y&&r&&e.railBrand){if(ae===void 0){let d=e.railBrand(!1);ae=d?s("span",{className:"persona-history-heading-brand",attrs:{"aria-hidden":"true"}},s("span",{className:"persona-history-brand-mark"},d),s("span",{className:"persona-history-wordmark",text:t.viewTitle})):null}ae&&(y=!0,p=ae)}He.classList.toggle("persona-history-sr-only",y),se.replaceChildren(He),p&&se.appendChild(p)};Ce();let $=s("button",{className:"persona-history-icon-button persona-history-new-icon",attrs:{type:"button","data-persona-history-focus":"new-icon","aria-label":t.newConversationLabel}});$.appendChild(_("plus")),$.addEventListener("click",()=>{ee()});let Ht=[f,$].map(r=>e.attachTooltip?.({anchor:r,text:()=>r.getAttribute("aria-label")??"",...r===f&&e.collapseShortcut?{hint:()=>G()?e.collapseShortcut.hint:""}:{}})),L=s("div",{className:"persona-history-topbar"}),We=null,Se=()=>{let r=S==="rail",n=r?qe?"rail-right":"rail":"panel";n!==We&&(We=n,n==="rail"?L.append(se,f):L.append(f,se),r?$.remove():L.appendChild($),v.classList.toggle("persona-history-view--rail-right",n==="rail-right"))},O=s("div",{className:"persona-history-scope-alert"}),Ye=`${a}-scope`,Ct=_("plus",18),Le=s("button",{className:"persona-history-new",attrs:{type:"button","data-persona-history-focus":"new"}},Ct,s("span",{text:t.newConversationLabel}));Le.addEventListener("click",()=>{ee()});let ke=s("div",{className:"persona-history-list-region"}),je=e.showDeleteAll!==!1,Ge=!!e.provider.resetDevice,Ue=e.listActions??[],V=je||Ge||Ue.length>0?Ve({className:"persona-history-list-options",label:t.listOptionsLabel,focusKey:`menu:${F}`,open:!1,inert:!0,iconSize:16,onToggle:()=>rt(F)}):null,St=s("h3",{className:"persona-history-conversations-title",text:t.conversationsTitle}),K=s("div",{className:"persona-history-caption",attrs:{"data-persona-history-item":F}},St,e.showScopeStatus?q:null,V),B=s("div",{className:"persona-history-body",attrs:{id:$e}},e.showScopeStatus?O:null,Le,K,ke),U=e.headerPlacement??"inline";U==="external"&&L.classList.add("persona-history-topbar--shell","persona-history-topbar--shell-enter");let v=s("div",{className:T("persona-history-view",`persona-history-view--${e.presentation}`,"persona-history-view--enter"),attrs:{role:"region","aria-labelledby":a,"data-persona-history-presentation":e.presentation}},we.element,U==="inline"?L:null,B),Te=()=>{v.classList.toggle("persona-history-view--rail-collapsed",R&&G())};Te(),Se();let Lt=(r,n)=>{let p=`${a}-s${n}`,y=s("div",{className:T("persona-history-nav",r.placement==="footer"&&"persona-history-nav--footer"),attrs:{role:"group","data-persona-rail-section":r.id,...r.title?{"aria-labelledby":p}:{"aria-label":r.id}}});r.title&&y.appendChild(s("h3",{className:"persona-history-group-heading",text:r.title,attrs:{id:p}}));for(let d of r.items){let H=d.iconNode?.()??null,D=s("button",{className:T("persona-history-nav-item",H&&"persona-history-nav-item--icon"),attrs:{type:"button","aria-label":d.label,"data-persona-rail-item":d.id}},H?s("span",{className:"persona-history-nav-icon"},H):null,s("span",{className:"persona-history-nav-label persona-history-truncate",text:d.label}),d.badge?s("span",{className:"persona-history-nav-badge",text:d.badge}):null);D.addEventListener("click",()=>d.onSelect()),y.appendChild(D)}return y},X=null,Xe=null,Ee=()=>{!X||!j||S!=="rail"||R===Xe||(Xe=R,e.railSections.forEach((r,n)=>{if(!r.render)return;let p=X[n],y=r.title?p.firstElementChild:null,d=null;try{d=r.render(R)}catch(H){r.render=void 0,console.warn("[persona] history rail section threw",r.id,H)}p.replaceChildren(...y?[y]:[],...d?[d]:[]),p.hidden=!d}))},Ze=()=>{let r=e.railSections;if(v.classList.toggle("persona-history-view--has-nav",S==="rail"&&!!r?.some(n=>n.placement==="above-conversations")),!!r?.length){if(S!=="rail"){X?.forEach(n=>n.remove());return}X??(X=r.map(Lt));for(let n of["above-conversations","below-conversations","footer"]){let p=n==="above-conversations"?K.parentNode===B?K:ke:null;r.forEach((y,d)=>{y.placement===n&&B.insertBefore(X[d],p)})}Ee()}};Ze(),at(v,"persona-history-view",pt);let Je=(r,n)=>{let p=v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r),y=Number.parseFloat(p??"");return Number.isFinite(y)&&y>=0?y:n},kt=(r,n)=>v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r).trim()||n,Z=null,z=()=>{Z!==null&&(clearTimeout(Z),Z=null),v.removeEventListener("animationend",z),v.classList.remove("persona-history-view--enter")};v.addEventListener("animationend",z),Z=setTimeout(()=>{Z=setTimeout(z,Je("--persona-history-enter-ms",nr)+60)},0);let J=null,Q=()=>{J!==null&&(clearTimeout(J),J=null),L.classList.remove("persona-history-topbar--shell-enter")},Tt=()=>{Q(),L.classList.add("persona-history-topbar--shell-enter"),J=setTimeout(Q,gt+60)};U==="external"&&(J=setTimeout(Q,gt+60));let le=[],pe=null,Et=()=>{if(pe)return pe;if(m||lr()||typeof v.animate!="function")return z(),null;let r=v.ownerDocument.defaultView?.getComputedStyle(B).opacity||"1";z(),v.style.pointerEvents="none",P.style.pointerEvents="none";let n={duration:Je("--persona-history-exit-ms",ir),easing:kt("--persona-history-exit-easing",sr),fill:"forwards"},p=ar[S];return le=[B.animate([{opacity:r,transform:"none"},{opacity:0,transform:`translateX(${p}px)`}],n)],pe=Promise.all(le.map(pr)).then(()=>{}),pe},Re=(r,n)=>{r&&(n?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"))},P=L,Ae=null,Rt=()=>{let r=e.slots?.header;if(!r)return;let n=`${S}|${be(b)}|${h?`${h.kind}:${"conversationId"in h?h.conversationId:""}`:""}`;if(n===Ae)return;Ae=n;let p=r({identityStatus:b,pendingAction:h,copy:t,defaultRenderer:()=>L})??L;p!==P&&(P.replaceWith(p),P=p)},Qe=null,At=()=>{if(!e.showScopeStatus)return;let r=be(b);if(r===Qe)return;Qe=r;let n=ft(b,t);Ke.textContent=n.title;let p=dr(b);if(q.hidden=!p,O.replaceChildren(...p?[]:[s("span",{className:"persona-history-scope-alert-title",text:n.title})],s("span",{className:"persona-history-scope-description",text:n.description,attrs:{id:Ye}})),O.setAttribute("data-persona-history-scope-tone",p?"ambient":"attention"),p?q.setAttribute("aria-describedby",Ye):q.removeAttribute("aria-describedby"),n.pending?O.setAttribute("role","status"):O.removeAttribute("role"),O.setAttribute("data-persona-history-identity",b.state),q.setAttribute("data-persona-history-identity",b.state),cr(b)){let y=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryIdentityLabel,attrs:{type:"button","data-persona-history-focus":"identity-retry"}});y.addEventListener("click",()=>{w()||N("refresh")}),O.appendChild(y)}},et=r=>h?h.kind==="open"&&h.conversationId===r?"opening":h.kind==="delete"&&h.conversationId===r?"deleting":null:null,Nt=()=>{let r=document.activeElement;return!(r instanceof HTMLElement)||!v.contains(r)?null:r.getAttribute("data-persona-history-focus")},Mt=r=>{if(M&&x){M=!1;let n=v.querySelector(`[data-persona-history-focus="${te(x)}"]`);if(n){n.focus();return}}r&&v.querySelector(`[data-persona-history-focus="${r}"]`)?.focus()},Pt=()=>{if(!A)return null;let r=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":"action-retry"}}),n=A;return r.addEventListener("click",()=>{w()||n.retry()}),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:n.message}),r)},Dt=()=>ct(l,o(),t,e.grouping).map((r,n)=>{let p=`${a}-g${n}`,y=s("ul",{className:"persona-history-list",attrs:{"aria-labelledby":p}});for(let d of r.items){let H=()=>ht({conversation:d,active:d.id===C,pending:et(d.id),busy:w(),menuOpen:x===d.id,error:I.get(d.id)??null,avatar:e.rowAvatar,showDelete:e.showDelete!==!1,nowMs:o(),copy:t,onOpen:()=>{de(d.id)},onToggleMenu:()=>rt(d.id),onCloseMenu:_e=>k(_e),onDelete:()=>{ce(d.id)}}),W=e.slots?.conversation?.({conversation:d,active:d.id===C,pending:et(d.id),open:()=>de(d.id),requestDelete:()=>ce(d.id),defaultRenderer:H})??H();y.appendChild(W instanceof HTMLLIElement?W:s("li",{className:"persona-history-item"},W))}return s("div",{className:"persona-history-group",attrs:{"data-persona-history-group":r.key}},s("h3",{className:T("persona-history-group-heading",r.key==="recent"&&"persona-history-sr-only"),text:r.label,attrs:{id:p}}),y)}),_t=()=>{if(!u)return null;let r=h?.kind==="load-more"||c.kind==="loading"&&c.phase==="load-more",n=s("button",{className:"persona-history-secondary persona-history-load-more",text:r?t.loadingMoreLabel:t.loadMoreLabel,attrs:{type:"button","data-persona-history-focus":"load-more",...r?{"aria-busy":"true","aria-disabled":"true"}:{},...w()&&!r?{"aria-disabled":"true"}:{}}});return n.addEventListener("click",()=>{w()||N("load-more")}),n},It=()=>{let r=Nt(),n=[Pt()],p=l.length>0;if(p&&(n.push(...Dt()),n.push(_t())),c.kind!=="ready"&&!(c.kind==="loading"&&c.phase!=="initial"&&p)){let d=c,H=d.kind==="loading"?void 0:()=>N("refresh"),D=d.kind==="new_conversation_required"?()=>ee():void 0,W=()=>vt({state:d,copy:t,identityStatus:b,busy:w(),...H?{onRetry:()=>{H()}}:{},...D?{onStartNew:()=>{D()}}:{}}),_e=e.slots?.state?.({state:d,identityStatus:b,copy:t,...H?{retry:H}:{},...D?{startNewConversation:D}:{},defaultRenderer:W});n.push(_e??W())}ke.replaceChildren(...n.filter(d=>!!d)),Mt(r)},Ot=()=>{let r=c.kind==="loading"&&l.length===0,n=[],p=()=>n.length===0?te(F):`${te(F)}-${n.length}`;if(!r)for(let y of Ue)n.push({label:y.label,focusKey:p(),danger:y.danger===!0,onSelect:()=>{y.onSelect({conversations:[...l]})}});return je&&!(l.length===0&&(c.kind==="empty"||r))&&n.push({label:t.clearHistoryLabel,focusKey:p(),danger:!0,onSelect:()=>{Me()}}),Ge&&!r&&n.push({label:t.resetIdentityLabel,focusKey:p(),danger:!0,onSelect:()=>{De()}}),n},Vt=()=>{if(Re(Le,w()),Re($,w()),V){let r=Ot(),n=c.kind==="loading"&&l.length===0;V.hidden=r.length===0&&!n,Re(V,w()||r.length===0),V.setAttribute("aria-expanded",x===F?"true":"false");let p=K.querySelector(".persona-history-menu");if(x!==F||r.length===0)p?.remove();else{let y=ze({label:t.listOptionsLabel,items:r,onCloseMenu:d=>k(d)});p?p.replaceWith(y):K.appendChild(y)}}K.hidden=S!=="rail"&&(!V||V.hidden)&&(!e.showScopeStatus||q.hidden)},tt,zt=()=>{let r=e.onActiveConversationChange;if(!r)return;let n=l.find(y=>y.id===C)??null,p=n?`${n.id}\0${n.title}\0${n.starred?1:0}`:"";p!==tt&&(tt=p,r(n))},g=()=>{if(!m){if(zt(),!j){e.onModelChange?.();return}Rt(),At(),Vt(),It(),Ee()}},k=r=>{if(!x)return;let n=x;x=null,M=!1,g(),r?.restoreFocus&&v.querySelector(`[data-persona-history-focus="menu:${n}"]`)?.focus()},rt=r=>{if(x===r){k({restoreFocus:!0});return}x=r,M=!0,g()},ot=r=>{if(!x)return;let n=r.target;n instanceof Node&&v.contains(n)&&n.closest?.(`[data-persona-history-item="${x}"]`)||k()};document.addEventListener("pointerdown",ot,!0);let nt=r=>{r.key!=="Escape"||!x||(r.stopPropagation(),k({restoreFocus:!0}))};v.addEventListener("keydown",nt);async function N(r){if(m)return;let n=++Y,p=r==="load-more"?u:null;if(!(r==="load-more"&&!p)){h={kind:r==="load-more"?"load-more":"refresh"},c={kind:"loading",phase:r},r!=="load-more"&&(I.clear(),A=null),k(),g();try{let y=await e.provider.list({limit:i,context:e.context,...p?{cursor:p}:{},...e.targetId?{targetId:e.targetId}:{}});if(m||n!==Y)return;l=p?[...l,...y.items]:y.items,u=y.nextCursor,c=l.length===0?{kind:"empty"}:{kind:"ready"}}catch(y){if(m||n!==Y)return;c=mt(y)}finally{!m&&n===Y&&(h=null,g())}}}let Ne=r=>{l=l.filter(n=>n.id!==r),I.delete(r),C===r&&(C=null),l.length===0&&!u&&(c={kind:"empty"})};async function de(r){if(!(w()||m)){I.delete(r),k(),h={kind:"open",conversationId:r},g();try{if(await e.onSelect(r),m)return;C=r}catch{if(m)return;I.set(r,{message:t.openFailedLabel,retry:()=>{de(r)}})}finally{m||(h=null,g())}}}async function ce(r){if(w()||m)return"cancelled";I.delete(r),h={kind:"delete",conversationId:r},g();try{let n=await e.onRequestDeleteConversation(r);return m||n==="deleted"&&(Ne(r),ne(t.conversationRemovedNotice)),n}catch(n){return m||(ge(n)&&n.code==="not_found"?Ne(r):I.set(r,{message:t.deleteFailedLabel,retry:()=>{ce(r)}})),"cancelled"}finally{m||(h=null,g())}}async function ee(){if(!(w()||m)){A=null,k(),h={kind:"start-new"},g();try{if(await e.onStartNew(),m)return;c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"})}catch{if(m)return;A={message:t.errorDescription,retry:()=>{ee()}}}finally{m||(h=null,g())}}}async function Me(){if(w()||m)return"cancelled";A=null,k(),h={kind:"clear"},g();try{let r=await e.onRequestClearHistory();return m||r==="cleared"&&(l=[],u=null,C=null,c={kind:"empty"},ne(t.historyClearedNotice)),r}catch{return m||(A={message:t.errorDescription,retry:()=>{Me()}}),"cancelled"}finally{m||(h=null,g())}}let Pe={outcome:"cancelled"};async function De(){if(w()||m||!e.onRequestResetIdentity)return Pe;A=null,k(),h={kind:"reset"},g();try{let r=await e.onRequestResetIdentity();return m||r.outcome==="reset"&&(ne(r.remoteRevocationConfirmed?t.identityResetNotice:t.identityResetUnconfirmedNotice),h=null,await N("refresh")),r}catch{return m||(A={message:t.errorDescription,retry:()=>{De()}}),Pe}finally{!m&&h?.kind==="reset"&&(h=null,g())}}let Ft=e.provider.subscribeIdentityStatus(r=>{if(m)return;let n=be(r),p=n!==oe;b=r,oe=n,g(),p&&r.state!=="verifying"&&ne(ft(r,t).title)}),qt=e.provider.subscribeAvailability?.(r=>{if(!m){if(r){N("refresh");return}l=[],u=null,c={kind:"error",reason:"unavailable",retryable:!1},g()}});return g(),N("initial"),{element:v,copy:t,getModel:()=>({conversations:l,activeConversationId:C,state:c,pendingAction:h,identityStatus:b,nextCursor:u}),operations:{refresh:async()=>{w()||await N("refresh")},loadMore:async()=>{w()||await N("load-more")},openConversation:r=>de(r),startNewConversation:()=>ee(),requestDeleteConversation:r=>ce(r),requestClearConversationHistory:()=>Me(),requestResetHistoryIdentity:()=>De()},setDomRenderEnabled:r=>{r!==j&&(j=r,r&&g())},refresh:()=>{N("refresh")},setPresentation:r=>{if(r===S)return;z(),S=r,Ae=null;let n=r==="rail";v.classList.toggle("persona-history-view--panel",!n),v.classList.toggle("persona-history-view--rail",n),v.setAttribute("data-persona-history-presentation",r),xe(),Te(),Se(),Ce(),Ze(),g()},setCollapsed:r=>{r!==R&&(R=r,Te(),xe(),Ce(),Ee())},setRailSide:r=>{qe=r==="right",Se()},getHeaderElement:()=>P,setHeaderPlacement:r=>{if(r===U)return;U=r;let n=r==="external";if(L.classList.toggle("persona-history-topbar--shell",n),n){Tt(),P.remove();return}Q(),v.insertBefore(P,B)},setActiveConversationId:r=>{C!==r&&(C=r,g())},applyConversationSummary:r=>{let n=l.findIndex(p=>p.id===r.id);n!==-1&&(l[n]=r,g())},removeConversationSummary:r=>{l.some(n=>n.id===r)&&(Ne(r),g())},setNewConversationRequired:r=>{r?c={kind:"new_conversation_required"}:c.kind==="new_conversation_required"&&(c=l.length===0?{kind:"empty"}:{kind:"ready"}),g()},playExit:Et,destroy:()=>{m=!0,Y+=1,z(),Q(),Ht.forEach(r=>r?.destroy()),P.remove(),le.forEach(r=>r.cancel()),le=[],Ft(),qt?.(),document.removeEventListener("pointerdown",ot,!0),v.removeEventListener("keydown",nt),we.destroy(),v.remove(),v.replaceChildren()}}}export{he as HISTORY_VIEW_COPY_DEFAULTS,bt as createHistoryView,me as resolveHistoryViewCopy};
898
+ `;var ct={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."};var me={...ct,emptyTitle:"No conversations yet",emptyDescription:"Start a conversation and it will show up here.",errorTitle:"Could not load conversations",errorDescription:"Something went wrong. Please try again.",retryLabel:"Retry",rateLimitedTitle:"Too many requests",rateLimitedDescription:"Please wait a moment before trying again.",groupStarred:"Starred",groupToday:"Today",groupYesterday:"Yesterday",groupPrevious7Days:"Previous 7 days",groupPrevious30Days:"Previous 30 days",groupMonthYear:"{month} {year}",browserOnlyTitle:"On this device",browserOnlyDescription:"Another browser or device keeps its own separate history.",verifyingTitle:"Checking your account",verifyingDescription:"Looking for messages linked to your account.",verifiedTitle:"Available across signed-in devices",verifiedDescription:"This list refreshes when the chat opens rather than syncing live.",authenticationRequiredTitle:"Sign in to see your messages",authenticationRequiredDescription:"Your session expired. Sign in again to load account history.",identityProviderFailedTitle:"Account history is unavailable",identityProviderFailedDescription:"We could not verify your account, so account history is not shown here.",proofNotAdmittedTitle:"Account history is unavailable",proofNotAdmittedDescription:"This assistant is not set up to accept your account identity.",retryIdentityLabel:"Try again",backLabel:"Back to conversation",closeLabel:"Close conversation list",loadingLabel:"Loading conversations",loadMoreLabel:"Load more",loadingMoreLabel:"Loading more conversations",conversationsTitle:"Conversations",rowActionsLabel:"Conversation options",listOptionsLabel:"Conversation options",deleteConversationLabel:"Delete",clearHistoryLabel:"Delete all conversations",resetIdentityLabel:"Forget this device",messageCountLabel:"{count} messages",messageCountLabelOne:"1 message",conversationRemovedNotice:"Conversation deleted.",historyClearedNotice:"All conversations were deleted.",unavailableTitle:"Conversation history is unavailable",unavailableDescription:"Try again later.",newConversationRequiredTitle:"Start a new conversation",newConversationRequiredDescription:"The previous conversation is gone. Start a new one to keep chatting.",rateLimitedWaitDescription:"You can try again in {seconds} seconds.",openFailedLabel:"Could not open that conversation.",deleteFailedLabel:"Could not delete that conversation.",relativeNow:"now",relativeMinutes:"{value}m",relativeHours:"{value}h",relativeDays:"{value}d",relativeWeeks:"{value}w",relativeYears:"{value}y"};function ve(e){if(!e)return me;let t={...me};for(let[o,i]of Object.entries(e))typeof i=="string"&&i.length>0&&(t[o]=i);return t}function R(e,t){return e.replace(/\{(\w+)\}/g,(o,i)=>i in t?String(t[i]):o)}var Oe=864e5;function Kt(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}function Ve(e,t){let o=Date.parse(e);return Number.isFinite(o)?o:t}function $t(e,t){let o=Ve(e,t),i=Kt(t);if(o>=i)return"today";if(o>=i-Oe)return"yesterday";if(o>=i-7*Oe)return"previous-7-days";if(o>=i-30*Oe)return"previous-30-days";let l=new Date(o);return`month:${l.getFullYear()}-${l.getMonth()}`}function Wt(e,t,o,i){if(e==="today")return i.groupToday;if(e==="yesterday")return i.groupYesterday;if(e==="previous-7-days")return i.groupPrevious7Days;if(e==="previous-30-days")return i.groupPrevious30Days;let l=new Date(Ve(t,o));return R(i.groupMonthYear,{month:l.toLocaleString(void 0,{month:"long"}),year:l.getFullYear()})}function yt(e,t,o,i="time"){let l=e.filter(d=>d.starred),a=l.length>0?[{key:"starred",label:o.groupStarred,items:l}]:[];if(i==="none"){let d=e.filter(c=>!c.starred);return d.length>0&&a.push({key:"recent",label:o.conversationsTitle,items:d}),a}for(let d of e){if(d.starred)continue;let c=$t(d.updatedAt,t),y=a[a.length-1];if(y&&y.key===c){y.items.push(d);continue}a.push({key:c,label:Wt(c,d.updatedAt,t,o),items:[d]})}return a}function ut(e,t,o){let i=Math.max(0,t-Ve(e,t)),l=Math.floor(i/6e4);if(l<1)return o.relativeNow;if(l<60)return R(o.relativeMinutes,{value:l});let a=Math.floor(l/60);if(a<24)return R(o.relativeHours,{value:a});let d=Math.floor(a/24);if(d<7)return R(o.relativeDays,{value:d});let c=Math.floor(d/7);return d<365?R(o.relativeWeeks,{value:c}):R(o.relativeYears,{value:Math.floor(d/365)})}function ht(e,t){return e===1?t.messageCountLabelOne:R(t.messageCountLabel,{count:e})}var fe="http://www.w3.org/2000/svg",Bt={"arrow-left":["m12 19-7-7 7-7","M19 12H5"],plus:["M5 12h14","M12 5v14"],star:["m12 2 2.9 6.2 6.8.7-5.1 4.5 1.4 6.6-6-3.4-6 3.4 1.4-6.6-5.1-4.5 6.8-.7z"],x:["M18 6 6 18","m6 6 12 12"],"panel-left":["M9 3v18"],monitor:["M8 21h8","M12 17v4"],ellipsis:[]},Yt={"panel-left":[3,3,18,18],monitor:[2,3,20,14]};function O(e,t=20){let o=document.createElementNS(fe,"svg");if(o.setAttribute("width",String(t)),o.setAttribute("height",String(t)),o.setAttribute("viewBox","0 0 24 24"),o.setAttribute("fill","none"),o.setAttribute("stroke","currentColor"),o.setAttribute("stroke-width","2"),o.setAttribute("stroke-linecap","round"),o.setAttribute("stroke-linejoin","round"),o.setAttribute("aria-hidden","true"),o.setAttribute("focusable","false"),e==="ellipsis"){for(let l of[12,19,5]){let a=document.createElementNS(fe,"circle");a.setAttribute("cx",String(l)),a.setAttribute("cy","12"),a.setAttribute("r","1"),o.appendChild(a)}return o}let i=Yt[e];if(i){let l=document.createElementNS(fe,"rect");l.setAttribute("x",String(i[0])),l.setAttribute("y",String(i[1])),l.setAttribute("width",String(i[2])),l.setAttribute("height",String(i[3])),l.setAttribute("rx","2"),o.appendChild(l)}for(let l of Bt[e]){let a=document.createElementNS(fe,"path");a.setAttribute("d",l),o.appendChild(a)}return o}var jt=/^(https?:|\/|data:)/i;function Gt(e){let t=s("span",{className:"persona-history-row-avatar",attrs:{"aria-hidden":"true"}});return jt.test(e)?t.appendChild(s("img",{attrs:{src:e,alt:"",loading:"lazy"}})):t.textContent=e,t}var Ut=e=>`row:${e}`,Xt=e=>`menu:${e}`,oe=e=>`menu-item:${e}`;function mt(e){let{conversation:t,copy:o,busy:i,pending:l}=e,a=i||l!==null,d=t.title.trim().length>0,c=t.starred?(()=>{let b=O("star",11);return b.setAttribute("fill","currentColor"),b.setAttribute("stroke-width","1"),s("span",{className:"persona-history-row-star"},b,s("span",{className:"persona-history-sr-only",text:o.groupStarred}))})():null,y=s("div",{className:"persona-history-row-head"},s("span",{className:"persona-history-row-title persona-history-truncate",text:d?t.title:t.preview??""}),c,s("time",{className:"persona-history-row-time",attrs:{datetime:t.updatedAt},text:ut(t.updatedAt,e.nowMs,o)})),g=d&&t.preview?s("span",{className:"persona-history-row-preview persona-history-truncate",text:t.preview}):null,w=s("button",{className:T("persona-history-row",e.active&&"persona-history-row--active",l&&`persona-history-row--${l}`),attrs:{type:"button","data-persona-history-focus":Ut(t.id),"data-persona-history-conversation":t.id,...e.active?{"aria-current":"page"}:{},...a?{"aria-disabled":"true"}:{},...l?{"aria-busy":"true"}:{}}},e.avatar?Gt(e.avatar):null,s("div",{className:"persona-history-row-body"},y,g,s("span",{className:"persona-history-row-count persona-history-sr-only",text:ht(t.messageCount,o)})));w.addEventListener("click",()=>{a||e.onOpen()});let A=e.showDelete?ze({className:"persona-history-row-menu-button",label:`${o.rowActionsLabel}: ${t.title}`,focusKey:Xt(t.id),open:e.menuOpen,inert:a,onToggle:e.onToggleMenu}):null;return s("li",{className:T("persona-history-item",!e.showDelete&&"persona-history-item--no-menu"),attrs:{"data-persona-history-item":t.id}},w,A,e.menuOpen&&e.showDelete?Zt(e):null,e.error?Jt(e.error,o,t.id):null)}function Zt(e){let{conversation:t,copy:o}=e;return Fe({label:`${o.rowActionsLabel}: ${t.title}`,items:[{label:o.deleteConversationLabel,focusKey:oe(t.id),danger:!0,onSelect:e.onDelete}],onCloseMenu:e.onCloseMenu})}function ze(e){let t=s("button",{className:T("persona-history-icon-button",e.className),attrs:{type:"button","aria-label":e.label,"aria-haspopup":"menu","aria-expanded":e.open?"true":"false","data-persona-history-focus":e.focusKey,...e.inert?{"aria-disabled":"true"}:{}}});t.appendChild(O("ellipsis",e.iconSize));let o=()=>t.getAttribute("aria-disabled")==="true";return t.addEventListener("click",i=>{i.stopPropagation(),!o()&&e.onToggle()}),t.addEventListener("keydown",i=>{i.key!=="ArrowDown"&&i.key!=="ArrowUp"||(i.preventDefault(),!(o()||t.getAttribute("aria-expanded")==="true")&&e.onToggle())}),t}function Fe(e){let t=s("div",{className:"persona-history-menu",attrs:{role:"menu","aria-label":e.label}});for(let o of e.items){let i=s("button",{className:T("persona-history-menu-item",o.danger&&"persona-history-menu-item--danger"),text:o.label,attrs:{type:"button",role:"menuitem",tabindex:"0","data-persona-history-focus":o.focusKey}});i.addEventListener("click",()=>{e.onCloseMenu(),o.onSelect()}),t.appendChild(i)}return t.addEventListener("keydown",o=>{let i=Array.from(t.querySelectorAll('[role="menuitem"]'));if(i.length===0)return;let l=i.indexOf(document.activeElement);if(o.key==="Tab"){e.onCloseMenu({restoreFocus:!0});return}if(o.key==="ArrowDown"){o.preventDefault(),i[(l+1+i.length)%i.length]?.focus();return}if(o.key==="ArrowUp"){o.preventDefault(),i[(l-1+i.length)%i.length]?.focus();return}if(o.key==="Home"){o.preventDefault(),i[0]?.focus();return}o.key==="End"&&(o.preventDefault(),i[i.length-1]?.focus())}),t}function Jt(e,t,o){let i=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":`row-retry:${o}`}});return i.addEventListener("click",e.retry),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:e.message}),i)}var qe=class extends Error{constructor(t,o,i){super(o),this.name="HistoryProviderError",this.code=t,i?.retryAfterSeconds!==void 0&&(this.retryAfterSeconds=i.retryAfterSeconds)}};function ge(e){return e instanceof qe}function Qt(e){switch(e){case"authentication_failed":case"authentication_required":case"identity_provider_failed":case"proof_not_admitted":case"unsupported_scope":case"unavailable":return e;default:return"unknown"}}function vt(e){if(ge(e)){if(e.code==="rate_limited")return{kind:"rate_limited",retryAfterSeconds:e.retryAfterSeconds??0};let t=Qt(e.code);return{kind:"error",reason:t,retryable:t!=="unsupported_scope"}}return{kind:"error",reason:"unknown",retryable:!0}}function er(e,t){switch(e.state){case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};default:return null}}function tr(e,t){switch(e){case"authentication_required":case"authentication_failed":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription};case"proof_not_admitted":case"unsupported_scope":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription};default:return{title:t.errorTitle,description:t.errorDescription}}}function be(e,t,o,i){let l=s("button",{className:"persona-history-secondary persona-history-state-action",text:e,attrs:{type:"button","data-persona-history-focus":t,...o?{"aria-disabled":"true"}:{}}});return l.addEventListener("click",()=>{o||i()}),l}function ne(e,t,o,i,l){return s("div",{className:"persona-history-state",attrs:{"data-persona-history-state":e,...l?{role:"alert"}:{role:"status"}}},s("p",{className:"persona-history-state-title",text:t}),s("p",{className:"persona-history-state-description",text:o}),i)}function rr(e){let t=["42%","58%","34%"],o=["94%","78%","88%"],i=[0,1,2].map(l=>s("div",{className:"persona-history-skeleton-row",attrs:{"aria-hidden":"true"}},s("div",{className:"persona-history-skeleton-head"},s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--title",style:{width:t[l]}}),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--time"})),s("div",{className:"persona-history-skeleton-bar persona-history-skeleton-bar--preview",style:{width:o[l]}})));return s("div",{className:"persona-history-view-loading",attrs:{"data-persona-history-state":"loading",role:"status","aria-label":e.loadingLabel}},...i)}function ft(e){let{state:t,copy:o,busy:i}=e;if(t.kind==="loading")return rr(o);if(t.kind==="empty"){let c=er(e.identityStatus,o);return c?ne("identity",c.title,c.description,e.onRetry?be(o.retryIdentityLabel,"state-retry",i,e.onRetry):null,!0):ne("empty",o.emptyTitle,o.emptyDescription,null,!1)}if(t.kind==="rate_limited"){let c=t.retryAfterSeconds>0?R(o.rateLimitedWaitDescription,{seconds:t.retryAfterSeconds}):o.rateLimitedDescription;return ne("rate_limited",o.rateLimitedTitle,c,e.onRetry?be(o.retryLabel,"state-retry",i,e.onRetry):null,!1)}if(t.kind==="new_conversation_required")return ne("new_conversation_required",o.newConversationRequiredTitle,o.newConversationRequiredDescription,e.onStartNew?be(o.newConversationLabel,"state-retry",i,e.onStartNew):null,!0);let{title:l,description:a}=tr(t.reason,o),d=t.reason==="authentication_required"||t.reason==="authentication_failed"||t.reason==="identity_provider_failed"?o.retryIdentityLabel:o.retryLabel;return ne("error",l,a,t.retryable&&e.onRetry?be(d,"state-retry",i,e.onRetry):null,!0)}var or=25,K="persona:list-options",nr=180,gt=120,ir=160,sr="cubic-bezier(0.4, 0, 1, 1)",ar={panel:20,rail:12},lr=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,pr=e=>e.finished?e.finished.then(()=>{},()=>{}):Promise.resolve();function we(e){return`${e.state}:${"reason"in e?e.reason:""}`}function bt(e,t){switch(e.state){case"verified":return{title:t.verifiedTitle,description:t.verifiedDescription,pending:!1};case"verifying":case"resetting":return{title:t.verifyingTitle,description:t.verifyingDescription,pending:!0};case"authentication_required":return{title:t.authenticationRequiredTitle,description:t.authenticationRequiredDescription,pending:!1};case"identity_provider_failed":return{title:t.identityProviderFailedTitle,description:t.identityProviderFailedDescription,pending:!1};case"configuration_error":return{title:t.proofNotAdmittedTitle,description:t.proofNotAdmittedDescription,pending:!1};case"unavailable":return{title:t.unavailableTitle,description:t.unavailableDescription,pending:!1};default:return{title:t.browserOnlyTitle,description:t.browserOnlyDescription,pending:!1}}}function dr(e){return e.state==="verified"||e.state==="browser_only"}function cr(e){return e.state==="authentication_required"||e.state==="identity_provider_failed"||e.state==="configuration_error"}function wt(e){let t=ve(e.copy),o=e.now??(()=>Date.now()),i=e.pageSize??or,l=`persona-history-title-${Math.random().toString(36).slice(2,8)}`,a=[],d=null,c={kind:"loading",phase:"initial"},y=null,g=e.activeConversationId,w=e.provider.getIdentityStatus(),A=we(w),x=null,b=!1,m=!1,D=0,S=e.presentation,G=e.collapsible!==!1,N=e.collapsed===!0,Ke=e.railSide==="right",U=e.renderDom!==!1,V=new Map,M=null,xe=pt(),ie=r=>{!U&&e.onAnnounce?e.onAnnounce(r):xe.announce(r)},C=()=>y!==null,$e=`${l}-body`,H=s("button",{className:"persona-history-icon-button persona-history-back",attrs:{type:"button"}}),X=()=>S==="rail"&&G,se,xt=()=>{if(e.railBrand){if(!X()){H.classList.remove("persona-history-back--branded");return}if(se===void 0){let r=e.railBrand(!0);se=r?s("span",{className:"persona-history-brand-mark persona-history-toggle-brand",attrs:{"aria-hidden":"true"}},r):null}se&&(H.classList.add("persona-history-back--branded"),H.appendChild(se))}},He=()=>{let r=X(),n=S==="rail";H.setAttribute("data-persona-history-focus",r?"collapse":"close"),H.setAttribute("aria-label",r?N?t.expandLabel:t.collapseLabel:n?t.closeLabel:t.backLabel),r?(H.setAttribute("aria-expanded",N?"false":"true"),H.setAttribute("aria-controls",$e),e.collapseShortcut?.aria&&H.setAttribute("aria-keyshortcuts",e.collapseShortcut.aria)):(H.removeAttribute("aria-expanded"),H.removeAttribute("aria-controls"),H.removeAttribute("aria-keyshortcuts")),H.replaceChildren(O(r?"panel-left":n?"x":"arrow-left")),xt()};He(),H.addEventListener("click",()=>{X()?e.onToggleCollapse?.():e.onClose()});let Ce=s("h2",{className:"persona-history-title",text:t.viewTitle,attrs:{id:l}}),We=s("span",{className:"persona-history-scope-title"}),$=s("p",{className:"persona-history-scope"},s("span",{className:"persona-history-scope-icon",attrs:{"aria-hidden":"true"}},O("monitor",14)),We),ae=s("div",{className:"persona-history-heading-group"},Ce),Be=!1,le,Se=()=>{let r=S==="rail",n=r?e.renderRailHeader:void 0,p=null,h=n!==void 0;if(n)try{p=n({collapsed:N,defaultTitle:t.viewTitle})}catch(u){h=!1,Be||(Be=!0,console.warn("[persona] history rail renderHeader threw",u))}if(!h&&r&&e.railBrand){if(le===void 0){let u=e.railBrand(!1);le=u?s("span",{className:"persona-history-heading-brand",attrs:{"aria-hidden":"true"}},s("span",{className:"persona-history-brand-mark"},u),s("span",{className:"persona-history-wordmark",text:t.viewTitle})):null}le&&(h=!0,p=le)}Ce.classList.toggle("persona-history-sr-only",h),ae.replaceChildren(Ce),p&&ae.appendChild(p)};Se();let W=s("button",{className:"persona-history-icon-button persona-history-new-icon",attrs:{type:"button","data-persona-history-focus":"new-icon","aria-label":t.newConversationLabel}});W.appendChild(O("plus")),W.addEventListener("click",()=>{re()});let Ht=[H,W].map(r=>e.attachTooltip?.({anchor:r,text:()=>r.getAttribute("aria-label")??"",...r===H&&e.collapseShortcut?{hint:()=>X()?e.collapseShortcut.hint:""}:{}})),k=s("div",{className:"persona-history-topbar"}),Ye=null,Le=()=>{let r=S==="rail",n=r?Ke?"rail-right":"rail":"panel";n!==Ye&&(Ye=n,n==="rail"?k.append(ae,H):k.append(H,ae),r?W.remove():k.appendChild(W),v.classList.toggle("persona-history-view--rail-right",n==="rail-right"))},z=s("div",{className:"persona-history-scope-alert"}),je=`${l}-scope`,Ct=O("plus",18),ke=s("button",{className:"persona-history-new",attrs:{type:"button","data-persona-history-focus":"new"}},Ct,s("span",{text:t.newConversationLabel}));ke.addEventListener("click",()=>{re()});let Ee=s("div",{className:"persona-history-list-region"}),Ge=e.showDeleteAll!==!1,Ue=!!e.provider.resetDevice,Xe=e.listActions??[],F=Ge||Ue||Xe.length>0?ze({className:"persona-history-list-options",label:t.listOptionsLabel,focusKey:`menu:${K}`,open:!1,inert:!0,iconSize:16,onToggle:()=>ot(K)}):null,St=s("h3",{className:"persona-history-conversations-title",text:t.conversationsTitle}),B=s("div",{className:"persona-history-caption",attrs:{"data-persona-history-item":K}},St,e.showScopeStatus?$:null,F),Y=s("div",{className:"persona-history-body",attrs:{id:$e}},e.showScopeStatus?z:null,ke,B,Ee),Z=e.headerPlacement??"inline";Z==="external"&&k.classList.add("persona-history-topbar--shell","persona-history-topbar--shell-enter");let v=s("div",{className:T("persona-history-view",`persona-history-view--${e.presentation}`,"persona-history-view--enter"),attrs:{role:"region","aria-labelledby":l,"data-persona-history-presentation":e.presentation}},xe.element,Z==="inline"?k:null,Y),Te=()=>{v.classList.toggle("persona-history-view--rail-collapsed",N&&X())};Te(),Le();let Lt=(r,n)=>{let p=`${l}-s${n}`,h=s("div",{className:T("persona-history-nav",r.placement==="footer"&&"persona-history-nav--footer"),attrs:{role:"group","data-persona-rail-section":r.id,...r.title?{"aria-labelledby":p}:{"aria-label":r.id}}});r.title&&h.appendChild(s("h3",{className:"persona-history-group-heading",text:r.title,attrs:{id:p}}));for(let u of r.items){let L=u.iconNode?.()??null,I=s("button",{className:T("persona-history-nav-item",L&&"persona-history-nav-item--icon"),attrs:{type:"button","aria-label":u.label,"data-persona-rail-item":u.id}},L?s("span",{className:"persona-history-nav-icon"},L):null,s("span",{className:"persona-history-nav-label persona-history-truncate",text:u.label}),u.badge?s("span",{className:"persona-history-nav-badge",text:u.badge}):null);I.addEventListener("click",()=>u.onSelect()),h.appendChild(I)}return h},J=null,Ze=null,Re=()=>{!J||!U||S!=="rail"||N===Ze||(Ze=N,e.railSections.forEach((r,n)=>{if(!r.render)return;let p=J[n],h=r.title?p.firstElementChild:null,u=null;try{u=r.render(N)}catch(L){r.render=void 0,console.warn("[persona] history rail section threw",r.id,L)}p.replaceChildren(...h?[h]:[],...u?[u]:[]),p.hidden=!u}))},Je=()=>{let r=e.railSections;if(v.classList.toggle("persona-history-view--has-nav",S==="rail"&&!!r?.some(n=>n.placement==="above-conversations")),!!r?.length){if(S!=="rail"){J?.forEach(n=>n.remove());return}J??=r.map(Lt);for(let n of["above-conversations","below-conversations","footer"]){let p=n==="above-conversations"?B.parentNode===Y?B:Ee:null;r.forEach((h,u)=>{h.placement===n&&Y.insertBefore(J[u],p)})}Re()}};Je(),lt(v,"persona-history-view",dt);let Qe=(r,n)=>{let p=v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r),h=Number.parseFloat(p??"");return Number.isFinite(h)&&h>=0?h:n},kt=(r,n)=>v.ownerDocument.defaultView?.getComputedStyle(v).getPropertyValue(r).trim()||n,Q=null,q=()=>{Q!==null&&(clearTimeout(Q),Q=null),v.removeEventListener("animationend",q),v.classList.remove("persona-history-view--enter")};v.addEventListener("animationend",q),Q=setTimeout(()=>{Q=setTimeout(q,Qe("--persona-history-enter-ms",nr)+60)},0);let ee=null,te=()=>{ee!==null&&(clearTimeout(ee),ee=null),k.classList.remove("persona-history-topbar--shell-enter")},Et=()=>{te(),k.classList.add("persona-history-topbar--shell-enter"),ee=setTimeout(te,gt+60)};Z==="external"&&(ee=setTimeout(te,gt+60));let pe=[],de=null,Tt=()=>{if(de)return de;if(m||lr()||typeof v.animate!="function")return q(),null;let r=v.ownerDocument.defaultView?.getComputedStyle(Y).opacity||"1";q(),v.style.pointerEvents="none",_.style.pointerEvents="none";let n={duration:Qe("--persona-history-exit-ms",ir),easing:kt("--persona-history-exit-easing",sr),fill:"forwards"},p=ar[S];return pe=[Y.animate([{opacity:r,transform:"none"},{opacity:0,transform:`translateX(${p}px)`}],n)],de=Promise.all(pe.map(pr)).then(()=>{}),de},Ae=(r,n)=>{r&&(n?r.setAttribute("aria-disabled","true"):r.removeAttribute("aria-disabled"))},_=k,Ne=null,Rt=()=>{let r=e.slots?.header;if(!r)return;let n=`${S}|${we(w)}|${y?`${y.kind}:${"conversationId"in y?y.conversationId:""}`:""}`;if(n===Ne)return;Ne=n;let p=r({identityStatus:w,pendingAction:y,copy:t,defaultRenderer:()=>k})??k;p!==_&&(_.replaceWith(p),_=p)},et=null,At=()=>{if(!e.showScopeStatus)return;let r=we(w);if(r===et)return;et=r;let n=bt(w,t);We.textContent=n.title;let p=dr(w);if($.hidden=!p,z.replaceChildren(...p?[]:[s("span",{className:"persona-history-scope-alert-title",text:n.title})],s("span",{className:"persona-history-scope-description",text:n.description,attrs:{id:je}})),z.setAttribute("data-persona-history-scope-tone",p?"ambient":"attention"),p?$.setAttribute("aria-describedby",je):$.removeAttribute("aria-describedby"),n.pending?z.setAttribute("role","status"):z.removeAttribute("role"),z.setAttribute("data-persona-history-identity",w.state),$.setAttribute("data-persona-history-identity",w.state),cr(w)){let h=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryIdentityLabel,attrs:{type:"button","data-persona-history-focus":"identity-retry"}});h.addEventListener("click",()=>{C()||P("refresh")}),z.appendChild(h)}},tt=r=>y?y.kind==="open"&&y.conversationId===r?"opening":y.kind==="delete"&&y.conversationId===r?"deleting":null:null,Nt=()=>{let r=document.activeElement;return!(r instanceof HTMLElement)||!v.contains(r)?null:r.getAttribute("data-persona-history-focus")},Mt=r=>{if(b&&x){b=!1;let n=v.querySelector(`[data-persona-history-focus="${oe(x)}"]`);if(n){n.focus();return}}r&&v.querySelector(`[data-persona-history-focus="${r}"]`)?.focus()},Pt=()=>{if(!M)return null;let r=s("button",{className:"persona-history-secondary persona-history-state-action",text:t.retryLabel,attrs:{type:"button","data-persona-history-focus":"action-retry"}}),n=M;return r.addEventListener("click",()=>{C()||n.retry()}),s("div",{className:"persona-history-row-error",attrs:{role:"alert"}},s("span",{text:n.message}),r)},Dt=()=>yt(a,o(),t,e.grouping).map((r,n)=>{let p=`${l}-g${n}`,h=s("ul",{className:"persona-history-list",attrs:{"aria-labelledby":p}});for(let u of r.items){let L=()=>mt({conversation:u,active:u.id===g,pending:tt(u.id),busy:C(),menuOpen:x===u.id,error:V.get(u.id)??null,avatar:e.rowAvatar,showDelete:e.showDelete!==!1,nowMs:o(),copy:t,onOpen:()=>{ce(u.id)},onToggleMenu:()=>ot(u.id),onCloseMenu:Ie=>E(Ie),onDelete:()=>{ye(u.id)}}),j=e.slots?.conversation?.({conversation:u,active:u.id===g,pending:tt(u.id),open:()=>ce(u.id),requestDelete:()=>ye(u.id),defaultRenderer:L})??L();h.appendChild(j instanceof HTMLLIElement?j:s("li",{className:"persona-history-item"},j))}return s("div",{className:"persona-history-group",attrs:{"data-persona-history-group":r.key}},s("h3",{className:T("persona-history-group-heading",r.key==="recent"&&"persona-history-sr-only"),text:r.label,attrs:{id:p}}),h)}),_t=()=>{if(!d)return null;let r=y?.kind==="load-more"||c.kind==="loading"&&c.phase==="load-more",n=s("button",{className:"persona-history-secondary persona-history-load-more",text:r?t.loadingMoreLabel:t.loadMoreLabel,attrs:{type:"button","data-persona-history-focus":"load-more",...r?{"aria-busy":"true","aria-disabled":"true"}:{},...C()&&!r?{"aria-disabled":"true"}:{}}});return n.addEventListener("click",()=>{C()||P("load-more")}),n},It=()=>{let r=Nt(),n=[Pt()],p=a.length>0;if(p&&(n.push(...Dt()),n.push(_t())),c.kind!=="ready"&&!(c.kind==="loading"&&c.phase!=="initial"&&p)){let u=c,L=u.kind==="loading"?void 0:()=>P("refresh"),I=u.kind==="new_conversation_required"?()=>re():void 0,j=()=>ft({state:u,copy:t,identityStatus:w,busy:C(),...L?{onRetry:()=>{L()}}:{},...I?{onStartNew:()=>{I()}}:{}}),Ie=e.slots?.state?.({state:u,identityStatus:w,copy:t,...L?{retry:L}:{},...I?{startNewConversation:I}:{},defaultRenderer:j});n.push(Ie??j())}Ee.replaceChildren(...n.filter(u=>!!u)),Mt(r)},Ot=()=>{let r=c.kind==="loading"&&a.length===0,n=[],p=()=>n.length===0?oe(K):`${oe(K)}-${n.length}`;if(!r)for(let h of Xe)n.push({label:h.label,focusKey:p(),danger:h.danger===!0,onSelect:()=>{h.onSelect({conversations:[...a]})}});return Ge&&!(a.length===0&&(c.kind==="empty"||r))&&n.push({label:t.clearHistoryLabel,focusKey:p(),danger:!0,onSelect:()=>{Pe()}}),Ue&&!r&&n.push({label:t.resetIdentityLabel,focusKey:p(),danger:!0,onSelect:()=>{_e()}}),n},Vt=()=>{if(Ae(ke,C()),Ae(W,C()),F){let r=Ot(),n=c.kind==="loading"&&a.length===0;F.hidden=r.length===0&&!n,Ae(F,C()||r.length===0),F.setAttribute("aria-expanded",x===K?"true":"false");let p=B.querySelector(".persona-history-menu");if(x!==K||r.length===0)p?.remove();else{let h=Fe({label:t.listOptionsLabel,items:r,onCloseMenu:u=>E(u)});p?p.replaceWith(h):B.appendChild(h)}}B.hidden=S!=="rail"&&(!F||F.hidden)&&(!e.showScopeStatus||$.hidden)},rt,zt=()=>{let r=e.onActiveConversationChange;if(!r)return;let n=a.find(h=>h.id===g)??null,p=n?`${n.id}\0${n.title}\0${n.starred?1:0}`:"";p!==rt&&(rt=p,r(n))},f=()=>{if(!m){if(zt(),!U){e.onModelChange?.();return}Rt(),At(),Vt(),It(),Re()}},E=r=>{if(!x)return;let n=x;x=null,b=!1,f(),r?.restoreFocus&&v.querySelector(`[data-persona-history-focus="menu:${n}"]`)?.focus()},ot=r=>{if(x===r){E({restoreFocus:!0});return}x=r,b=!0,f()},nt=r=>{if(!x)return;let n=r.target;n instanceof Node&&v.contains(n)&&n.closest?.(`[data-persona-history-item="${x}"]`)||E()};document.addEventListener("pointerdown",nt,!0);let it=r=>{r.key!=="Escape"||!x||(r.stopPropagation(),E({restoreFocus:!0}))};v.addEventListener("keydown",it);async function P(r){if(m)return;let n=++D,p=r==="load-more"?d:null;if(!(r==="load-more"&&!p)){y={kind:r==="load-more"?"load-more":"refresh"},c={kind:"loading",phase:r},r!=="load-more"&&(V.clear(),M=null),E(),f();try{let h=await e.provider.list({limit:i,context:e.context,...p?{cursor:p}:{},...e.targetId?{targetId:e.targetId}:{}});if(m||n!==D)return;a=p?[...a,...h.items]:h.items,d=h.nextCursor,c=a.length===0?{kind:"empty"}:{kind:"ready"}}catch(h){if(m||n!==D)return;c=vt(h)}finally{!m&&n===D&&(y=null,f())}}}let Me=r=>{a=a.filter(n=>n.id!==r),V.delete(r),g===r&&(g=null),a.length===0&&!d&&(c={kind:"empty"})};async function ce(r){if(!(C()||m)){V.delete(r),E(),y={kind:"open",conversationId:r},f();try{if(await e.onSelect(r),m)return;g=r}catch{if(m)return;V.set(r,{message:t.openFailedLabel,retry:()=>{ce(r)}})}finally{m||(y=null,f())}}}async function ye(r){if(C()||m)return"cancelled";V.delete(r),y={kind:"delete",conversationId:r},f();try{let n=await e.onRequestDeleteConversation(r);return m||n==="deleted"&&(Me(r),ie(t.conversationRemovedNotice)),n}catch(n){return m||(ge(n)&&n.code==="not_found"?Me(r):V.set(r,{message:t.deleteFailedLabel,retry:()=>{ye(r)}})),"cancelled"}finally{m||(y=null,f())}}async function re(){if(!(C()||m)){M=null,E(),y={kind:"start-new"},f();try{if(await e.onStartNew(),m)return;c.kind==="new_conversation_required"&&(c=a.length===0?{kind:"empty"}:{kind:"ready"})}catch{if(m)return;M={message:t.errorDescription,retry:()=>{re()}}}finally{m||(y=null,f())}}}async function Pe(){if(C()||m)return"cancelled";M=null,E(),y={kind:"clear"},f();try{let r=await e.onRequestClearHistory();return m||r==="cleared"&&(a=[],d=null,g=null,c={kind:"empty"},ie(t.historyClearedNotice)),r}catch{return m||(M={message:t.errorDescription,retry:()=>{Pe()}}),"cancelled"}finally{m||(y=null,f())}}let De={outcome:"cancelled"};async function _e(){if(C()||m||!e.onRequestResetIdentity)return De;M=null,E(),y={kind:"reset"},f();try{let r=await e.onRequestResetIdentity();return m||r.outcome==="reset"&&(ie(r.remoteRevocationConfirmed?t.identityResetNotice:t.identityResetUnconfirmedNotice),y=null,await P("refresh")),r}catch{return m||(M={message:t.errorDescription,retry:()=>{_e()}}),De}finally{!m&&y?.kind==="reset"&&(y=null,f())}}let Ft=e.provider.subscribeIdentityStatus(r=>{if(m)return;let n=we(r),p=n!==A;w=r,A=n,f(),p&&r.state!=="verifying"&&ie(bt(r,t).title)}),qt=e.provider.subscribeAvailability?.(r=>{if(!m){if(r){P("refresh");return}a=[],d=null,c={kind:"error",reason:"unavailable",retryable:!1},f()}});return f(),P("initial"),{element:v,copy:t,getModel:()=>({conversations:a,activeConversationId:g,state:c,pendingAction:y,identityStatus:w,nextCursor:d}),operations:{refresh:async()=>{C()||await P("refresh")},loadMore:async()=>{C()||await P("load-more")},openConversation:r=>ce(r),startNewConversation:()=>re(),requestDeleteConversation:r=>ye(r),requestClearConversationHistory:()=>Pe(),requestResetHistoryIdentity:()=>_e()},setDomRenderEnabled:r=>{r!==U&&(U=r,r&&f())},refresh:()=>{P("refresh")},setPresentation:r=>{if(r===S)return;q(),S=r,Ne=null;let n=r==="rail";v.classList.toggle("persona-history-view--panel",!n),v.classList.toggle("persona-history-view--rail",n),v.setAttribute("data-persona-history-presentation",r),He(),Te(),Le(),Se(),Je(),f()},setCollapsed:r=>{r!==N&&(N=r,Te(),He(),Se(),Re())},setRailSide:r=>{Ke=r==="right",Le()},getHeaderElement:()=>_,setHeaderPlacement:r=>{if(r===Z)return;Z=r;let n=r==="external";if(k.classList.toggle("persona-history-topbar--shell",n),n){Et(),_.remove();return}te(),v.insertBefore(_,Y)},setActiveConversationId:r=>{g!==r&&(g=r,f())},applyConversationSummary:r=>{let n=a.findIndex(p=>p.id===r.id);n!==-1&&(a[n]=r,f())},removeConversationSummary:r=>{a.some(n=>n.id===r)&&(Me(r),f())},setNewConversationRequired:r=>{r?c={kind:"new_conversation_required"}:c.kind==="new_conversation_required"&&(c=a.length===0?{kind:"empty"}:{kind:"ready"}),f()},playExit:Tt,destroy:()=>{m=!0,D+=1,q(),te(),Ht.forEach(r=>r?.destroy()),_.remove(),pe.forEach(r=>r.cancel()),pe=[],Ft(),qt?.(),document.removeEventListener("pointerdown",nt,!0),v.removeEventListener("keydown",it),xe.destroy(),v.remove(),v.replaceChildren()}}}var yr="button:not([disabled])";function ur(e){let t=document.activeElement instanceof HTMLElement?document.activeElement:null,o=Math.random().toString(36).slice(2,8),i=`persona-history-confirm-title-${o}`,l=`persona-history-confirm-desc-${o}`,a=s("button",{className:"persona-history-confirm__cancel",text:e.cancelLabel,attrs:{type:"button"}}),d=s("button",{className:"persona-history-confirm__confirm",text:e.confirmLabel,attrs:{type:"button","data-persona-destructive":"true"}}),c=s("div",{className:"persona-history-confirm__dialog",attrs:{role:"alertdialog","aria-modal":"true","aria-labelledby":i,"aria-describedby":l},style:{maxWidth:"22rem",width:"100%",borderRadius:"var(--persona-radius-lg, 0.75rem)",background:"var(--persona-surface, #ffffff)",color:"var(--persona-text, #111827)",boxShadow:"var(--persona-history-confirm-shadow, 0 20px 40px -12px rgba(0, 0, 0, 0.35))",padding:"20px",display:"flex",flexDirection:"column",gap:"12px"}},s("h2",{className:"persona-history-confirm__title",text:e.title,attrs:{id:i},style:{margin:"0",fontSize:"1rem",fontWeight:"600"}}),s("p",{className:"persona-history-confirm__description",text:e.description,attrs:{id:l},style:{margin:"0",fontSize:"0.875rem",lineHeight:"1.4"}}),s("div",{className:"persona-history-confirm__actions",style:{display:"flex",gap:"8px",justifyContent:"flex-end",flexWrap:"wrap"}},a,d));for(let g of[a,d])g.style.minHeight="44px",g.style.minWidth="88px",g.style.padding="0 16px",g.style.borderRadius="var(--persona-radius-md, 0.5rem)",g.style.cursor="pointer",g.style.font="inherit";a.style.border="1px solid var(--persona-border, rgba(0,0,0,0.12))",a.style.background="transparent",a.style.color="inherit",d.style.border="none",d.style.background="var(--persona-danger, #b42318)",d.style.color="var(--persona-danger-fg, #ffffff)";let y=s("div",{className:"persona-history-confirm",style:{position:"absolute",inset:"0",zIndex:"40",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",background:"var(--persona-history-confirm-scrim, rgba(15, 23, 42, 0.45))"}},c);return new Promise(g=>{let w=!1,A=b=>{w||(w=!0,y.removeEventListener("keydown",x,!0),y.remove(),t?.focus(),g(b))};function x(b){if(b.key==="Escape"){b.preventDefault(),b.stopPropagation(),A(!1);return}if(b.key!=="Tab")return;let m=Array.from(c.querySelectorAll(yr));if(m.length===0)return;let D=m[0],S=m[m.length-1],G=document.activeElement;b.shiftKey&&(G===D||!c.contains(G))?(b.preventDefault(),S.focus()):!b.shiftKey&&G===S&&(b.preventDefault(),D.focus())}y.addEventListener("keydown",x,!0),y.addEventListener("pointerdown",b=>{b.target===y&&A(!1)}),a.addEventListener("click",()=>A(!1)),d.addEventListener("click",()=>A(!0)),e.host.appendChild(y),a.focus()})}export{me as HISTORY_VIEW_COPY_DEFAULTS,wt as createHistoryView,ve as resolveHistoryViewCopy,ur as showHistoryConfirm};