pisper 0.5.41-linux-x64.0 → 0.5.41

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 (318) hide show
  1. package/README.en.md +67 -0
  2. package/README.md +53 -53
  3. package/bin/pisper.mjs +48 -0
  4. package/lib/install.mjs +392 -0
  5. package/lib/npm-platform.mjs +41 -0
  6. package/lib/npm-update.mjs +165 -0
  7. package/lib/platform.mjs +43 -0
  8. package/lib/postinstall.mjs +3 -0
  9. package/package.json +36 -14
  10. package/updater.pubkey +1 -0
  11. package/web/.vite/manifest.json +2608 -0
  12. package/web/assets/AnimatedList-_pbK4tS3.js +1 -0
  13. package/web/assets/AppOverlays-3u0m45y3.js +1 -0
  14. package/web/assets/AppSelect-DI7c30Zx.js +1 -0
  15. package/web/assets/AppShortcuts-D66c2bOM.js +1 -0
  16. package/web/assets/AssetsPage-DvNN-AJS.js +1 -0
  17. package/web/assets/ChannelsPage-Bj8tjyyt.js +1 -0
  18. package/web/assets/ChatDockView-2djrL8P-.js +2 -0
  19. package/web/assets/ChatHistoryPage-BwduusB9.js +1 -0
  20. package/web/assets/ChatPage-BcAzVN5M.js +4 -0
  21. package/web/assets/ClickSpark-BhxL8WOQ.js +1 -0
  22. package/web/assets/ConfigPage-pd1Vp9Lc.js +1 -0
  23. package/web/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  24. package/web/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  25. package/web/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  26. package/web/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  27. package/web/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  28. package/web/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  29. package/web/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  30. package/web/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  31. package/web/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  32. package/web/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  33. package/web/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  34. package/web/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  35. package/web/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  36. package/web/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  37. package/web/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  38. package/web/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  39. package/web/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  40. package/web/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  41. package/web/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  42. package/web/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  43. package/web/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  44. package/web/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  45. package/web/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  46. package/web/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  47. package/web/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  48. package/web/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  49. package/web/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  50. package/web/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  51. package/web/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  52. package/web/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  53. package/web/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  54. package/web/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  55. package/web/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  56. package/web/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  57. package/web/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  58. package/web/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  59. package/web/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  60. package/web/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  61. package/web/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  62. package/web/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  63. package/web/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  64. package/web/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  65. package/web/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  66. package/web/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  67. package/web/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  68. package/web/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  69. package/web/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  70. package/web/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  71. package/web/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  72. package/web/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  73. package/web/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  74. package/web/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  75. package/web/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  76. package/web/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  77. package/web/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  78. package/web/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  79. package/web/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  80. package/web/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  81. package/web/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  82. package/web/assets/MarkdownMessage-CVfGm_CJ.js +2 -0
  83. package/web/assets/MemoryPage-Crtq8lcv.js +1 -0
  84. package/web/assets/MobileViewportStabilizer-CYh5obIv.js +1 -0
  85. package/web/assets/PageHeader-D4KgTxmG.js +1 -0
  86. package/web/assets/PluginsPage-BkTzF4ux.js +1 -0
  87. package/web/assets/PreviewPages-ChU0UYjv.js +1 -0
  88. package/web/assets/SchedulesPage-CGYTmMe9.js +1 -0
  89. package/web/assets/ShinyText-fuaKxKqJ.js +1 -0
  90. package/web/assets/SkillsPage-CQAMb5yt.js +1 -0
  91. package/web/assets/StarOrbit-BlI6MhVr.js +1 -0
  92. package/web/assets/TerminalPanel-BrP-ENHg.css +1 -0
  93. package/web/assets/TerminalPanel-DFKq2ejG.js +18 -0
  94. package/web/assets/Threads-DPFx-jxG.js +1 -0
  95. package/web/assets/WelcomeEffects-DYsg0gqD.js +1 -0
  96. package/web/assets/WorkflowsPage-BdsnJo_M.js +1 -0
  97. package/web/assets/WorkspacePicker-yKaIYXLh.js +1 -0
  98. package/web/assets/abort-signal-f4JsiYKX.js +1 -0
  99. package/web/assets/alert-B7D8joCd.js +1 -0
  100. package/web/assets/andromeeda-vGVdxbeo.js +1 -0
  101. package/web/assets/angular-html-17rlCfBS.js +1 -0
  102. package/web/assets/angular-ts-it3MaXWH.js +1 -0
  103. package/web/assets/api-B6CluO7V.js +3 -0
  104. package/web/assets/arrow-right-KWvgbo3p.js +1 -0
  105. package/web/assets/astro-BEVDzCov.js +1 -0
  106. package/web/assets/aurora-x-CDeNXAV0.js +1 -0
  107. package/web/assets/ayu-dark-DluEY0Gj.js +1 -0
  108. package/web/assets/ayu-light-C3h-C4tm.js +1 -0
  109. package/web/assets/ayu-mirage-Bqwy1Gya.js +1 -0
  110. package/web/assets/blade-B3yUZIOx.js +1 -0
  111. package/web/assets/brand-DIEc3fK8.js +1 -0
  112. package/web/assets/button-XhIEgIsg.js +1 -0
  113. package/web/assets/c-aGSZMVdM.js +1 -0
  114. package/web/assets/catppuccin-frappe-C9Q5zVZY.js +1 -0
  115. package/web/assets/catppuccin-latte-CtsyrtPq.js +1 -0
  116. package/web/assets/catppuccin-macchiato-R8nAf1vR.js +1 -0
  117. package/web/assets/catppuccin-mocha-DjuaAJKi.js +1 -0
  118. package/web/assets/chat-api-Bw89X8nw.js +1 -0
  119. package/web/assets/check-jIXqkGKr.js +1 -0
  120. package/web/assets/chevron-down-DT6AXwTP.js +1 -0
  121. package/web/assets/circle-dot-rl11gaty.js +1 -0
  122. package/web/assets/client-store-BSV7t02b.js +1 -0
  123. package/web/assets/code-xml-Z4K2ea1N.js +1 -0
  124. package/web/assets/coffee-ouOQ86EC.js +1 -0
  125. package/web/assets/collapsible-47_3Sj4S.js +1 -0
  126. package/web/assets/config-search-DUooaMjw.js +1 -0
  127. package/web/assets/copy-DS-8Hh_R.js +1 -0
  128. package/web/assets/cpp-Bm3vm43L.js +1 -0
  129. package/web/assets/css-CWcS1xXm.js +1 -0
  130. package/web/assets/csv-Dx-8-gkx.js +1 -0
  131. package/web/assets/dark-plus-Cs2F2srj.js +1 -0
  132. package/web/assets/dist-DU-EIBZd.js +1 -0
  133. package/web/assets/dist-Dt6AeZb2.js +1 -0
  134. package/web/assets/dracula-BHWKrbxM.js +1 -0
  135. package/web/assets/dracula-soft-5eyTD99u.js +1 -0
  136. package/web/assets/earth-DR_clkZ9.js +1 -0
  137. package/web/assets/embedded-D2rqyswH.js +269 -0
  138. package/web/assets/es2015-DOuE9leL.js +41 -0
  139. package/web/assets/everforest-dark-sB-x3p7T.js +1 -0
  140. package/web/assets/everforest-light-Df2xbC6M.js +1 -0
  141. package/web/assets/field-CsXLXjoI.js +1 -0
  142. package/web/assets/file-C8GNXmhJ.js +1 -0
  143. package/web/assets/file-code-corner-BKkXAMHR.js +1 -0
  144. package/web/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  145. package/web/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  146. package/web/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  147. package/web/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  148. package/web/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  149. package/web/assets/github-dark-C-LZuMrd.js +1 -0
  150. package/web/assets/github-dark-default-DXG-b-1a.js +1 -0
  151. package/web/assets/github-dark-dimmed-Bx1FflLF.js +1 -0
  152. package/web/assets/github-dark-high-contrast-B_tTalzw.js +1 -0
  153. package/web/assets/github-light-EUqPIrTm.js +1 -0
  154. package/web/assets/github-light-default-BXViO-2h.js +1 -0
  155. package/web/assets/github-light-high-contrast-B68TUdTA.js +1 -0
  156. package/web/assets/glsl-TOBAB6bO.js +1 -0
  157. package/web/assets/graphql-BEmIBNve.js +1 -0
  158. package/web/assets/gruvbox-dark-hard-C820rvS2.js +1 -0
  159. package/web/assets/gruvbox-dark-medium-BPjhmG05.js +1 -0
  160. package/web/assets/gruvbox-dark-soft-MrdJrrXF.js +1 -0
  161. package/web/assets/gruvbox-light-hard-BC_s9l72.js +1 -0
  162. package/web/assets/gruvbox-light-medium-BAWPOn9u.js +1 -0
  163. package/web/assets/gruvbox-light-soft-BSMLrYjP.js +1 -0
  164. package/web/assets/haml-CDWtFtU9.js +1 -0
  165. package/web/assets/handlebars-BNtjo3pL.js +1 -0
  166. package/web/assets/horizon-CE9ld1lL.js +1 -0
  167. package/web/assets/horizon-bright-DSNQnXHK.js +1 -0
  168. package/web/assets/houston-CsvMBhTu.js +1 -0
  169. package/web/assets/html-BVyvp26C.js +1 -0
  170. package/web/assets/html-derivative-BseLpURQ.js +1 -0
  171. package/web/assets/http-CkCfSMV9.js +1 -0
  172. package/web/assets/hurl-syYMt6Rn.js +1 -0
  173. package/web/assets/image-Dh7-wI1d.js +1 -0
  174. package/web/assets/imba-DsUTQ-LC.js +1 -0
  175. package/web/assets/index-DzCGpOH8.js +40 -0
  176. package/web/assets/index-qhttni0u.css +2 -0
  177. package/web/assets/input-D1QFzNMx.js +1 -0
  178. package/web/assets/java-duG_UTKe.js +1 -0
  179. package/web/assets/javascript-DWVbOe4X.js +1 -0
  180. package/web/assets/jinja-Boj4niAz.js +1 -0
  181. package/web/assets/jison-CHwnC1Pv.js +1 -0
  182. package/web/assets/json-qhed-kSA.js +1 -0
  183. package/web/assets/json5-BR5RXkoi.js +1 -0
  184. package/web/assets/jsonc-CYpm1nAK.js +1 -0
  185. package/web/assets/jsonl-CmCQp5Yx.js +1 -0
  186. package/web/assets/jsx-fcCEM_-L.js +1 -0
  187. package/web/assets/julia-VoF7UKfw.js +1 -0
  188. package/web/assets/kanagawa-dragon-Bozd7klA.js +1 -0
  189. package/web/assets/kanagawa-lotus-BmuOG9ZW.js +1 -0
  190. package/web/assets/kanagawa-wave-BML5mF2J.js +1 -0
  191. package/web/assets/laserwave-C_8bwKvT.js +1 -0
  192. package/web/assets/less-DVTAwKKz.js +1 -0
  193. package/web/assets/light-plus-DVQuIRkW.js +1 -0
  194. package/web/assets/link-2-CaZP6GWi.js +1 -0
  195. package/web/assets/loader-circle-72TYCcVQ.js +1 -0
  196. package/web/assets/markdown-BYOwaDjH.js +1 -0
  197. package/web/assets/marko-Cupn1xhw.js +1 -0
  198. package/web/assets/material-theme-Bm3Qr25_.js +1 -0
  199. package/web/assets/material-theme-darker-2IIEA8gg.js +1 -0
  200. package/web/assets/material-theme-lighter-uhdI0v04.js +1 -0
  201. package/web/assets/material-theme-ocean-CHQ94UKr.js +1 -0
  202. package/web/assets/material-theme-palenight-B5W6OYN7.js +1 -0
  203. package/web/assets/mdc-4FfK5iWR.js +1 -0
  204. package/web/assets/mdx-DQZ5AkYe.js +1 -0
  205. package/web/assets/message-circle-Bc_EzZop.js +1 -0
  206. package/web/assets/min-dark-BSWPekZh.js +1 -0
  207. package/web/assets/min-light-DDpmG2fV.js +1 -0
  208. package/web/assets/mobile-remote-fallback-JvG4VcPg.js +1 -0
  209. package/web/assets/mobile-runtime-recovery-tbTyacip.js +1 -0
  210. package/web/assets/monokai-B_bV9PQ9.js +1 -0
  211. package/web/assets/night-owl-DhmEMT88.js +1 -0
  212. package/web/assets/night-owl-light-eJ-hLW7d.js +1 -0
  213. package/web/assets/nord-Cb4Vim4T.js +1 -0
  214. package/web/assets/one-dark-pro-CLwyXe_n.js +1 -0
  215. package/web/assets/one-light-D7Lr4KcI.js +1 -0
  216. package/web/assets/panel-left-CVuoi3zo.js +1 -0
  217. package/web/assets/panel-top-CA2GX1Rj.js +1 -0
  218. package/web/assets/paperclip-BMRj9kRG.js +1 -0
  219. package/web/assets/pencil-CxA1IK0x.js +1 -0
  220. package/web/assets/php-CUREQQ7f.js +1 -0
  221. package/web/assets/pick-system-directory-BnIFt85A.js +1 -0
  222. package/web/assets/plastic-DQwYfKfQ.js +1 -0
  223. package/web/assets/play-N6mg4pFl.js +1 -0
  224. package/web/assets/poimandres-DRFjx7u4.js +1 -0
  225. package/web/assets/postcss-BXeXVLqQ.js +1 -0
  226. package/web/assets/progress-CG1oznsH.js +6 -0
  227. package/web/assets/pug-CQyGKZpv.js +1 -0
  228. package/web/assets/python-gzcpVVnB.js +1 -0
  229. package/web/assets/r-C5FwQflr.js +1 -0
  230. package/web/assets/react-bits-DQli9s7O.css +1 -0
  231. package/web/assets/red-DX1BQOs8.js +1 -0
  232. package/web/assets/regexp--aR2_iz7.js +1 -0
  233. package/web/assets/rolldown-runtime-B0Z9INg1.js +1 -0
  234. package/web/assets/rose-pine-aMsaMD1D.js +1 -0
  235. package/web/assets/rose-pine-dawn-8PwUyIlP.js +1 -0
  236. package/web/assets/rose-pine-moon-DO-qXg-I.js +1 -0
  237. package/web/assets/sass-DXrisJhu.js +1 -0
  238. package/web/assets/save-CVL5N6eP.js +1 -0
  239. package/web/assets/scroll-area-XsbbfbCb.js +1 -0
  240. package/web/assets/scss-Davl4E3T.js +1 -0
  241. package/web/assets/send-DcLH_sg0.js +1 -0
  242. package/web/assets/separator-PDMWTNcE.js +1 -0
  243. package/web/assets/shellscript-CLZ0U2zV.js +1 -0
  244. package/web/assets/shield-check-BQHFfxVy.js +1 -0
  245. package/web/assets/shortcuts-BIzphxhz.js +1 -0
  246. package/web/assets/slack-dark-DnToyrRv.js +1 -0
  247. package/web/assets/slack-ochin-B2OO5cIa.js +1 -0
  248. package/web/assets/smithy-Dgaz7aur.js +1 -0
  249. package/web/assets/snazzy-light-4G7pJPwS.js +1 -0
  250. package/web/assets/solarized-dark-UdsmMDCL.js +1 -0
  251. package/web/assets/solarized-light-C1IUL_tW.js +1 -0
  252. package/web/assets/speech-session-C_LNwJvG.js +3 -0
  253. package/web/assets/speech-stream-text-Bf0UhZti.js +2 -0
  254. package/web/assets/speech-text-Js_tr4qo.js +1 -0
  255. package/web/assets/sql-b92rrcVl.js +1 -0
  256. package/web/assets/square-BZ3Bi3O-.js +1 -0
  257. package/web/assets/square-terminal-DpCa0gzM.js +1 -0
  258. package/web/assets/storage-BE5DCCG3.js +1 -0
  259. package/web/assets/stylus-B6D30XZt.js +1 -0
  260. package/web/assets/svelte-BfstjgUc.js +1 -0
  261. package/web/assets/synthwave-84-nFMaYfgc.js +1 -0
  262. package/web/assets/tag-Csd134FL.js +1 -0
  263. package/web/assets/tokyo-night-oM2G3aXe.js +1 -0
  264. package/web/assets/tool-labels-BJhLig5u.js +1 -0
  265. package/web/assets/tooltip-9RtAt4Ma.js +1 -0
  266. package/web/assets/trash-2-mhzzyC6i.js +1 -0
  267. package/web/assets/ts-tags-Cckpt1jI.js +1 -0
  268. package/web/assets/tsx-JMDX3aQ7.js +1 -0
  269. package/web/assets/typescript-BAz-bF8J.js +1 -0
  270. package/web/assets/use-animation-visibility-C-GENY2Z.js +1 -0
  271. package/web/assets/use-i18n-DB8hT9cQ.js +1 -0
  272. package/web/assets/use-mobile-DhtiDyj5.js +1 -0
  273. package/web/assets/usePagePrimaryAction-Bw0OFTDZ.js +1 -0
  274. package/web/assets/utils-C8uzG5AZ.js +1 -0
  275. package/web/assets/vendor-dockview-D5adAaCg.css +1 -0
  276. package/web/assets/vendor-dockview-yY5mBM3U.js +1 -0
  277. package/web/assets/vendor-markdown-K9KdiImV.js +130 -0
  278. package/web/assets/vendor-markdown-plugins-DEcVZfaU.css +1 -0
  279. package/web/assets/vendor-markdown-plugins-Wv1dLaAO.js +263 -0
  280. package/web/assets/vendor-motion-XxgxfZSY.js +9 -0
  281. package/web/assets/vendor-react-CHuvPdJE.js +9 -0
  282. package/web/assets/vendor-router-Bw2aAdMs.js +4 -0
  283. package/web/assets/vendor-shiki-runtime-CxE5QolQ.js +153 -0
  284. package/web/assets/vendor-state-DE1O_s6m.js +1 -0
  285. package/web/assets/vendor-ui-DvrYggeS.js +1 -0
  286. package/web/assets/vendor-xyflow-CnjXtcyK.js +7 -0
  287. package/web/assets/vendor-xyflow-DLioOiRN.css +1 -0
  288. package/web/assets/vesper-DdrHHSXu.js +1 -0
  289. package/web/assets/vitesse-black-fwtXNY1n.js +1 -0
  290. package/web/assets/vitesse-dark-BZCL-v6S.js +1 -0
  291. package/web/assets/vitesse-light-VbXTXTou.js +1 -0
  292. package/web/assets/vue-3H7P6ncC.js +1 -0
  293. package/web/assets/vue-html-DZGW9MGR.js +1 -0
  294. package/web/assets/vue-vine-BECt67gq.js +1 -0
  295. package/web/assets/wasm-BnjxR4X6.js +1 -0
  296. package/web/assets/wasm-ByWQv1Qj.js +1 -0
  297. package/web/assets/web-preview-panel-CVgRDmCB.js +556 -0
  298. package/web/assets/welcome-brand-BmbgyFTk.js +1 -0
  299. package/web/assets/wgsl-BsKzXJz4.js +1 -0
  300. package/web/assets/wit-DdvCle-K.js +1 -0
  301. package/web/assets/wrench-BqeVhocX.js +1 -0
  302. package/web/assets/x-bw26XDZM.js +1 -0
  303. package/web/assets/xml-CNfvW5JP.js +1 -0
  304. package/web/assets/yaml-rwi0_p6S.js +1 -0
  305. package/web/assets/zap-CFsp4Y1u.js +1 -0
  306. package/web/favicon.svg +25 -0
  307. package/web/icons.svg +24 -0
  308. package/web/index.html +83 -0
  309. package/web/memory-galaxy-background.webp +0 -0
  310. package/web/mobile-startup.html +322 -0
  311. package/web/notification-sw.js +13 -0
  312. package/web/tauri-pet.css +117 -0
  313. package/web/tauri-pet.html +16 -0
  314. package/web/tauri-pet.js +149 -0
  315. package/components/runtime/Pisper_Runtime_Node_0.5.39_linux_x86_64.tar.gz +0 -0
  316. package/components/runtime/Pisper_Runtime_Node_0.5.39_linux_x86_64.tar.gz.sig +0 -1
  317. package/components/tui/Pisper_TUI_Component_0.5.23_linux_x86_64.tar.gz +0 -0
  318. package/components/tui/Pisper_TUI_Component_0.5.23_linux_x86_64.tar.gz.sig +0 -1
@@ -0,0 +1,556 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AnimatedList-_pbK4tS3.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-CHuvPdJE.js","assets/utils-C8uzG5AZ.js","assets/vendor-ui-DvrYggeS.js","assets/vendor-motion-XxgxfZSY.js","assets/react-bits-DQli9s7O.css","assets/ShinyText-fuaKxKqJ.js","assets/WelcomeEffects-DYsg0gqD.js","assets/welcome-brand-BmbgyFTk.js","assets/index-DzCGpOH8.js","assets/vendor-router-Bw2aAdMs.js","assets/chat-api-Bw89X8nw.js","assets/api-B6CluO7V.js","assets/abort-signal-f4JsiYKX.js","assets/button-XhIEgIsg.js","assets/use-i18n-DB8hT9cQ.js","assets/vendor-state-DE1O_s6m.js","assets/storage-BE5DCCG3.js","assets/use-mobile-DhtiDyj5.js","assets/dist-Dt6AeZb2.js","assets/es2015-DOuE9leL.js","assets/dist-DU-EIBZd.js","assets/separator-PDMWTNcE.js","assets/tooltip-9RtAt4Ma.js","assets/panel-left-CVuoi3zo.js","assets/client-store-BSV7t02b.js","assets/x-bw26XDZM.js","assets/input-D1QFzNMx.js","assets/index-qhttni0u.css","assets/ClickSpark-BhxL8WOQ.js","assets/speech-text-Js_tr4qo.js","assets/vendor-markdown-K9KdiImV.js","assets/vendor-markdown-plugins-Wv1dLaAO.js","assets/vendor-shiki-runtime-CxE5QolQ.js","assets/vendor-markdown-plugins-DEcVZfaU.css","assets/speech-stream-text-Bf0UhZti.js","assets/speech-session-C_LNwJvG.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./rolldown-runtime-B0Z9INg1.js";import{i as t,r as n,t as r}from"./vendor-react-CHuvPdJE.js";import{f as i}from"./vendor-router-Bw2aAdMs.js";import{t as a}from"./chat-api-Bw89X8nw.js";import{n as o,r as s,t as c}from"./abort-signal-f4JsiYKX.js";import{s as l,t as u}from"./api-B6CluO7V.js";import{i as d,n as f,o as p,t as m}from"./button-XhIEgIsg.js";import{d as h,h as g,m as _,o as v,p as y,s as b,t as x,u as S}from"./use-i18n-DB8hT9cQ.js";import{c as C,i as w,o as T,r as E,s as D}from"./use-mobile-DhtiDyj5.js";import{a as O,i as k,n as A,r as j,s as M,t as N,u as P}from"./es2015-DOuE9leL.js";import{n as F}from"./dist-Dt6AeZb2.js";import{a as I,c as L,i as R,o as z,s as ee,t as te}from"./collapsible-47_3Sj4S.js";import{t as B}from"./AppSelect-DI7c30Zx.js";import{i as V,n as ne,r as re,t as ie}from"./progress-CG1oznsH.js";import{n as ae,r as oe,t as se}from"./scroll-area-XsbbfbCb.js";import{i as H,n as U,t as W}from"./tooltip-9RtAt4Ma.js";import{t as ce}from"./utils-C8uzG5AZ.js";import{a as le,i as ue}from"./vendor-state-DE1O_s6m.js";import{t as de}from"./storage-BE5DCCG3.js";import{t as fe}from"./check-jIXqkGKr.js";import{t as pe}from"./chevron-down-DT6AXwTP.js";import{t as G}from"./circle-dot-rl11gaty.js";import{t as me}from"./code-xml-Z4K2ea1N.js";import{t as he}from"./file-C8GNXmhJ.js";import{t as ge}from"./loader-circle-72TYCcVQ.js";import{n as _e,r as ve,t as ye}from"./panel-top-CA2GX1Rj.js";import{t as be}from"./panel-left-CVuoi3zo.js";import{t as xe}from"./paperclip-BMRj9kRG.js";import{t as Se}from"./pencil-CxA1IK0x.js";import{t as Ce}from"./play-N6mg4pFl.js";import{t as we}from"./send-DcLH_sg0.js";import{a as Te,n as Ee,o as De}from"./client-store-BSV7t02b.js";import{t as Oe}from"./shield-check-BQHFfxVy.js";import{t as ke}from"./square-BZ3Bi3O-.js";import{t as K}from"./tag-Csd134FL.js";import{t as Ae}from"./trash-2-mhzzyC6i.js";import{t as je}from"./wrench-BqeVhocX.js";import{t as Me}from"./x-bw26XDZM.js";import{t as Ne}from"./input-D1QFzNMx.js";import{$ as Pe,A as Fe,At as Ie,Et as Le,F as Re,G as ze,I as Be,J as Ve,M as He,Mt as Ue,N as We,Ot as Ge,P as Ke,Q as qe,R as Je,V as Ye,Z as Xe,bt as q,d as Ze,et as Qe,f as $e,ht as et,j as tt,jt as nt,k as rt,kt as it,m as at,mt as J,n as ot,ot as st,t as ct,u as lt,ut,vt as dt,wt as ft,xt as pt,z as Y}from"./index-DzCGpOH8.js";import{i as mt,o as ht,r as gt,s as _t,t as vt}from"./shortcuts-BIzphxhz.js";import{t as yt}from"./vendor-motion-XxgxfZSY.js";import{t as bt}from"./MarkdownMessage-CVfGm_CJ.js";import{n as xt,t as St}from"./alert-B7D8joCd.js";import{i as Ct,r as wt}from"./tool-labels-BJhLig5u.js";import{t as Tt}from"./welcome-brand-BmbgyFTk.js";import{a as Et,c as Dt,i as Ot,l as kt,n as At,o as jt,s as Mt,t as Nt,u as Pt}from"./speech-session-C_LNwJvG.js";var X=e(t(),1),Z=r(),Ft=Object.defineProperty,It=(e,t)=>Ft(e,`name`,{value:t,configurable:!0}),Lt=`Checkbox`,[Rt,zt]=_(Lt),[Bt,Vt]=Rt(Lt);function Ht(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=h({prop:n,defaultProp:i??!1,onChange:c,caller:Lt}),[m,g]=X.useState(null),[_,v]=X.useState(null),y=X.useRef(!1),[b,x]=X.useReducer(e=>e+1,0),S=!m||!!o||!!m.closest(`form`),C={checked:f,disabled:a,setChecked:p,control:m,setControl:g,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:y,userInteractionCount:b,onUserInteraction:x,required:l,defaultChecked:!Zt(i)&&i,isFormControl:S,bubbleInput:_,setBubbleInput:v};return(0,Z.jsx)(Bt,{scope:t,...C,children:Xt(d)?d(C):r})}It(Ht,`CheckboxProvider`);var Ut=`CheckboxTrigger`,Wt=X.forwardRef(It(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:m,isFormControl:h,bubbleInput:_}=Vt(Ut,e),v=p(i,u),b=X.useRef(c);return X.useEffect(()=>{let e=a?.form;if(e){let t=It(()=>d(b.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,Z.jsx)(g.button,{type:`button`,role:`checkbox`,"aria-checked":Zt(c)?`mixed`:c,"aria-required":l,"data-state":Qt(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:v,onKeyDown:y(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:y(n,e=>{m(),d(e=>Zt(e)?!0:!e),_&&h&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),Gt=X.forwardRef(It(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,Z.jsx)(Ht,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wt,{...d,ref:t,__scopeCheckbox:n}),e&&(0,Z.jsx)(Yt,{__scopeCheckbox:n})]})})},`Checkbox`)),Kt=`CheckboxIndicator`,qt=X.forwardRef(It(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=Vt(Kt,n);return(0,Z.jsx)(P,{present:r||Zt(a.checked)||a.checked===!0,children:(0,Z.jsx)(g.span,{"data-state":Qt(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),Jt=`CheckboxBubbleInput`,Yt=X.forwardRef(It(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:m,bubbleInput:h,setBubbleInput:_}=Vt(Jt,e),v=p(r,_),b=S(i),x=X.useRef(!1),C=X.useRef(s),w=X.useRef(o);X.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==w.current;w.current=o;let i=C.current!==s;C.current=s;let c=!(r&&a.current);if(i&&n){x.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=Zt(s),n.call(e,!Zt(s)&&s),e.dispatchEvent(t),x.current=!1}},[h,s,a,o]);let T=X.useRef(!Zt(s)&&s);return(0,Z.jsx)(g.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??T.current,required:l,disabled:u,name:d,value:f,form:m,...n,tabIndex:-1,ref:v,onClick:y(t,e=>{x.current&&e.stopPropagation()}),style:{...n.style,...b,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function Xt(e){return typeof e==`function`}It(Xt,`isFunction`);function Zt(e){return e===`indeterminate`}It(Zt,`isIndeterminate`);function Qt(e){return Zt(e)?`indeterminate`:e?`checked`:`unchecked`}It(Qt,`getState`);var $t=Object.defineProperty,en=(e,t)=>$t(e,`name`,{value:t,configurable:!0}),tn=`Popover`,[nn,rn]=_(tn,[C]),an=C(),[on,sn]=nn(tn),cn=en(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=an(t),c=X.useRef(null),[l,u]=X.useState(!1),[d,f]=h({prop:r,defaultProp:i??!1,onChange:a,caller:tn});return(0,Z.jsx)(D,{...s,children:(0,Z.jsx)(on,{scope:t,contentId:F(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:X.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:X.useCallback(()=>u(!0),[]),onCustomAnchorRemove:X.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),ln=`PopoverTrigger`,un=X.forwardRef(en(function(e,t){let{__scopePopover:n,...r}=e,i=sn(ln,n),a=an(n),o=p(t,i.triggerRef),s=(0,Z.jsx)(g.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":xn(i.open),...r,ref:o,onClick:y(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,Z.jsx)(w,{asChild:!0,...a,children:s})},`PopoverTrigger`)),dn=`PopoverPortal`,[fn,pn]=nn(dn,{forceMount:void 0}),mn=en(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=sn(dn,t);return(0,Z.jsx)(fn,{scope:t,forceMount:n,children:(0,Z.jsx)(P,{present:n||a.open,children:(0,Z.jsx)(k,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),hn=`PopoverContent`,gn=X.forwardRef(en(function(e,t){let n=pn(hn,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=sn(hn,e.__scopePopover);return(0,Z.jsx)(P,{present:r||a.open,children:a.modal?(0,Z.jsx)(vn,{...i,ref:t}):(0,Z.jsx)(yn,{...i,ref:t})})},`PopoverContent`)),_n=d(`PopoverContent.RemoveScroll`),vn=X.forwardRef(en(function(e,t){let n=sn(hn,e.__scopePopover),r=X.useRef(null),i=p(t,r),a=X.useRef(!1);return X.useEffect(()=>{let e=r.current;if(e)return N(e)},[]),(0,Z.jsx)(A,{as:_n,allowPinchZoom:!0,children:(0,Z.jsx)(bn,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:y(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:y(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:y(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),yn=X.forwardRef(en(function(e,t){let n=sn(hn,e.__scopePopover),r=X.useRef(!1),i=X.useRef(!1);return(0,Z.jsx)(bn,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),bn=X.forwardRef(en(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=sn(hn,n),p=an(n);return j(),(0,Z.jsx)(O,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,Z.jsx)(M,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,Z.jsx)(T,{"data-state":xn(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})},`PopoverContentImpl`));function xn(e){return e?`open`:`closed`}en(xn,`getState`);var Sn=cn,Cn=un,wn=mn,Tn=gn,En=f(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),Dn=f(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),On=f(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),kn=f(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),An=f(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),jn=f(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),Mn=f(`bug`,[[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z`,key:`uouzyp`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M21 21a4 4 0 0 0-3.81-4`,key:`1b0z45`}],[`path`,{d:`M21 5a4 4 0 0 1-3.55 3.97`,key:`5cxbf6`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M3 21a4 4 0 0 1 3.81-4`,key:`1fjd4g`}],[`path`,{d:`M3 5a4 4 0 0 0 3.55 3.97`,key:`1d7oge`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M9 7.13V6a3 3 0 1 1 6 0v1.13`,key:`1vgav8`}]]),Nn=f(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Pn=f(`command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),Fn=f(`database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),In=f(`file-check-corner`,[[`path`,{d:`M10.5 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v6`,key:`g5mvt7`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14 20 2 2 4-4`,key:`15kota`}]]),Ln=f(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),Rn=f(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),zn=f(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),Bn=f(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Vn=f(`git-fork`,[[`circle`,{cx:`12`,cy:`18`,r:`3`,key:`1mpf1b`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`path`,{d:`M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9`,key:`1uq4wg`}],[`path`,{d:`M12 12v3`,key:`158kv8`}]]),Hn=f(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Un=f(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Wn=f(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),Gn=f(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),Kn=f(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),qn=f(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),Jn=f(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),Yn=f(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),Xn=f(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),Zn=f(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Qn=f(`search-check`,[[`path`,{d:`m8 11 2 2 4-4`,key:`1sed1v`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),$n=f(`shield-off`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),er=f(`sigma`,[[`path`,{d:`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`,key:`wuwx1p`}]]),tr=f(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),nr=f(`target`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`6`,key:`1vlfrh`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),rr=f(`tree-pine`,[[`path`,{d:`m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z`,key:`cpyugq`}],[`path`,{d:`M12 22v-3`,key:`kmzjlo`}]]),ir=f(`undo-2`,[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]),ar=f(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),or=f(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),sr=f(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]);function cr(e){if(!(!e||typeof e!=`object`)){if(Object.hasOwn(e,`plan`))return e.plan??null;if(Object.hasOwn(e,`taskList`))return e.taskList??null}}function lr(e,t){let n=cr(e);return n===void 0?t:n}function ur(e){return e===`plan_update`||e===`task_list_update`}function dr(e){return e===`get_plan`||e===`get_task_list`}function fr(e){return e===`update_plan`||e===`update_task_list`}function pr(e){return dr(e)||fr(e)}function mr(e){return cr(e)}var hr=Object.freeze({messages:[],tools:[],approvals:[],agents:[],team:null,currentActivity:null,activityFeed:[],lifecycle:null,sessionTreeRevision:0,thinkingText:``,queuedInputs:[],hadQueuedInput:!1,plan:null,executionMode:null,runMode:null,contextUsage:null,sessionUsage:null,promptCache:null,compaction:null,streaming:!1,error:``,loaded:!1,messageStart:null,hasOlder:!1,olderCursor:null});function gr(e,t){if(e===t)return!1;if(!e||!t)return!0;let n=new Set([...Object.keys(e),...Object.keys(t)]);for(let r of n)if(e[r]!==t[r])return!0;return!1}function _r(e,t){let n=e||hr,r=typeof t==`function`?t(n):{...n,...t};return gr(n,r)?r:n}function vr(e,t){return t===void 0?e||[]:Array.isArray(t)?t:[]}function yr(e,t){return Number.isSafeInteger(e.queueRevision)&&Number.isSafeInteger(t.queueRevision)&&t.queueRevision<e.queueRevision}function br(e,t){let n=t.removedInputId?[...new Set([...e.withdrawnInputIds||[],t.removedInputId])]:e.withdrawnInputIds||[],r=new Set(n),i=r.size?e.messages.filter(e=>!r.has(e.queuedInputId)):e.messages;if(yr(e,t))return{...e,messages:i,withdrawnInputIds:n};let a=vr(e.queuedInputs,t.queuedInputs);return{...e,messages:i,withdrawnInputIds:n,queuedInputs:r.size?a.filter(e=>!r.has(e.id)):a,...Number.isSafeInteger(t.queueRevision)?{queueRevision:t.queueRevision}:{},hadQueuedInput:!!(e.hadQueuedInput||a.length)}}function xr(e=[],t){let n=Array.isArray(e)?e:[],r=-1;for(let e=n.length-1;e>=0;--e)if(n[e]?.role===`agent`){r=e;break}return r<0?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function Sr(e){return!!(e?.streaming||e?.recovering||e?.agents?.some(e=>[`queued`,`starting`,`running`].includes(e.status)))}function Cr(e){return!!(e&&(e.streaming||String(e.thinkingText||``).trim()||e.tools?.length||e.currentActivity?.type===`agent`||e.activityFeed?.some(e=>e.type===`agent`)||e.team))}function wr(e,t,n){return t&&Cr(n)?n:Cr(e.runActivity)?e.runActivity:null}function Tr(e,t){if(e&&(e.loaded||e.streaming||cr(e)!==void 0))return lr(e,null);let n=cr(t);return n===void 0?lr(e,null):n}function Er(e,t={}){return!!e?.items?.length}var Dr=10485760,Or=20971520,kr=new Set([`txt`,`md`,`json`,`js`,`jsx`,`ts`,`tsx`,`css`,`html`,`xml`,`yaml`,`yml`,`csv`,`log`,`py`,`java`,`go`,`rs`,`sh`,`ps1`,`toml`,`sql`]),Ar=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`bmp`,`svg`]),jr=new Set([`pdf`,`docx`,`pptx`,`xlsx`,`odt`,`odp`,`ods`,`rtf`,`epub`]),Mr=[`image/*`,`text/*`,`application/json`,...[...Ar,...kr,...jr].map(e=>`.${e}`)].join(`,`);function Nr(e){let t=[...e?.files||[]];return t.length?t:[...e?.items||[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile?.()).filter(e=>!!e)}function Pr(e,t){return new Promise((n,r)=>{let i=new FileReader;i.onload=()=>n(String(i.result).split(`,`)[1]||``),i.onerror=()=>r(i.error||Error(t(`chat:attachments.couldNotReadFile`))),i.readAsDataURL(e)})}function Fr(e){return e.toLowerCase().split(`.`).at(-1)||``}async function Ir(e,t){let n=[...e].slice(0,8),r=[];for(let e of n){if(e.size>Dr)throw Error(t(`chat:attachments.nameExceedsThe10MBLimit`,{name:e.name}));let n=Fr(e.name),i={id:`${e.name}-${e.lastModified}-${e.size}`,name:e.name,mimeType:e.type||`application/octet-stream`,size:e.size};if(e.type.startsWith(`image/`)||Ar.has(n))r.push({...i,kind:`image`,data:await Pr(e,t)});else if(e.type.startsWith(`text/`)||e.type===`application/json`||kr.has(n))r.push({...i,kind:`text`,text:await e.text()});else if(jr.has(n))r.push({...i,kind:`document`,extension:n,data:await Pr(e,t)});else throw Error(t(`chat:attachments.nameIsNotSupportedChooseAnImageOrTextCodeFile`,{name:e.name}))}return r}function Lr(e){return e.split(/[\\/]/).filter(Boolean).at(-1)||e}function Rr(e){return[...e].map(e=>String(e||``).trim()).filter(Boolean).slice(0,8).map(e=>({id:`path:${e}`,kind:`path`,name:Lr(e),path:e}))}function zr(e=[],t){let n=(0,X.useCallback)((e,t)=>b(e,v(),t),[]),[r,i]=(0,X.useState)(()=>[...e]),[a,o]=(0,X.useState)(``),s=(0,X.useRef)([...e]),c=(0,X.useCallback)(e=>{s.current=e,i(e),t?.(e)},[t]),l=(0,X.useCallback)(async e=>{try{o(``);let t=await Ir(e||[],n),r=[...s.current,...t].slice(0,8);if(r.filter(e=>e.kind!==`path`).reduce((e,t)=>e+(t.size||0),0)>Or)throw Error(n(`chat:attachments.totalAttachmentSizeCannotExceed20MB`));return c(r),!0}catch(e){return o(e instanceof Error?e.message:String(e)),!1}},[c,n]);return{attachments:r,attachmentError:a,addFiles:l,pasteFiles:(0,X.useCallback)(e=>{let t=Nr(e.clipboardData);t.length&&(e.preventDefault(),l(t))},[l]),removeAttachment:(0,X.useCallback)(e=>{c(s.current.filter(t=>t.id!==e))},[c]),clearAttachments:(0,X.useCallback)(()=>c([]),[c]),addAttachments:(0,X.useCallback)(e=>{o(``);let t=[...s.current];for(let n of e)t.some(e=>e.id===n.id)||t.push(n);c(t.slice(0,8))},[c]),replaceAttachments:c,setError:(0,X.useCallback)(e=>{o(e instanceof Error?e.message:String(e||``))},[])}}function Br({className:e,...t}){return(0,Z.jsx)(Gt,{"data-slot":`checkbox`,className:ce(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,Z.jsx)(qt,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,Z.jsx)(fe,{})})})}function Vr({open:e,initialPath:t,onOpenChange:n,onSelect:r}){let{t:i}=x(),[a,o]=(0,X.useState)(t||``),[s,c]=(0,X.useState)(null),[l,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``),_=(0,X.useRef)(0),v=(0,X.useCallback)(async e=>{let t=++_.current;p(!0),g(``);try{let n=await u(`/api/workspace-entries?path=${encodeURIComponent(e.trim())}`);if(t!==_.current)return;o(n.path),c(n),d([])}catch(e){if(t!==_.current)return;g(e instanceof Error?e.message:String(e))}finally{t===_.current&&p(!1)}},[]);(0,X.useEffect)(()=>{if(!e){_.current+=1;return}o(t||``),c(null),d([]),v(t||``)},[v,t,e]);let y=e=>{e.preventDefault(),v(a)},b=(e,t)=>{d(n=>t?[...n.filter(t=>t!==e),e].slice(-8):n.filter(t=>t!==e))};return(0,Z.jsx)(rt,{open:e,onOpenChange:n,children:(0,Z.jsxs)(Fe,{className:`max-w-[calc(100vw-24px)]! gap-0 overflow-hidden p-0 sm:max-w-[680px]!`,children:[(0,Z.jsxs)(We,{className:`border-b px-4 py-3 pr-12`,children:[(0,Z.jsx)(Ke,{children:i(`chat:pathAttachmentPicker.title`)}),(0,Z.jsx)(tt,{children:i(`chat:pathAttachmentPicker.description`)})]}),(0,Z.jsxs)(`form`,{className:`flex min-w-0 items-center gap-2 px-4 py-3`,onSubmit:y,children:[(0,Z.jsx)(m,{type:`button`,variant:`outline`,size:`icon`,title:i(`common:workspacePicker.parentFolder`),"aria-label":i(`common:workspacePicker.parentFolder`),disabled:f||!s?.parent,onClick:()=>s?.parent&&void v(s.parent),children:(0,Z.jsx)(oe,{})}),(0,Z.jsx)(Ne,{className:`min-w-0 flex-1 font-mono text-[12px]`,value:a,"aria-label":i(`chat:pathAttachmentPicker.directoryPath`),onChange:e=>o(e.target.value)}),(0,Z.jsxs)(m,{type:`submit`,variant:`secondary`,disabled:f||!a.trim(),children:[f?(0,Z.jsx)(ge,{className:`animate-spin`}):(0,Z.jsx)(Ie,{}),i(`common:workspacePicker.go`)]})]}),(0,Z.jsx)(se,{className:`h-[min(400px,50dvh)] border-y bg-muted/20`,children:(0,Z.jsxs)(`div`,{className:`p-2`,children:[s?.directories.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`grid h-9 w-full grid-cols-[24px_minmax(0,1fr)_20px] items-center rounded-md px-2 text-left text-[13px] hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,title:e.path,disabled:f,onClick:()=>void v(e.path),children:[(0,Z.jsx)(ae,{className:`size-4 text-content-muted`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)(Ie,{className:`size-4 text-content-muted`})]},e.path)),s?.files.map(e=>{let t=l.includes(e.path);return(0,Z.jsxs)(`label`,{className:`grid h-9 cursor-pointer grid-cols-[24px_minmax(0,1fr)_24px] items-center rounded-md px-2 text-[13px] hover:bg-muted`,title:e.path,children:[(0,Z.jsx)(he,{className:`size-4 text-content-muted`}),(0,Z.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Z.jsx)(Br,{checked:t,"aria-label":i(`chat:pathAttachmentPicker.selectName`,{name:e.name}),onCheckedChange:t=>b(e.path,t===!0)})]},e.path)}),f&&(0,Z.jsxs)(`div`,{className:`flex h-32 items-center justify-center gap-2 text-content-muted`,children:[(0,Z.jsx)(ge,{className:`size-4 animate-spin`}),(0,Z.jsx)(`span`,{children:i(`common:workspacePicker.readingFolder`)})]}),!f&&s&&!s.directories.length&&!s.files.length&&(0,Z.jsx)(`div`,{className:`flex h-32 items-center justify-center text-content-muted`,children:i(`chat:pathAttachmentPicker.empty`)})]})}),h&&(0,Z.jsxs)(St,{variant:`destructive`,className:`mx-4 mt-3 w-auto`,children:[(0,Z.jsx)(et,{}),(0,Z.jsx)(xt,{children:h})]}),(0,Z.jsxs)(He,{className:`m-0 border-t-0 bg-transparent px-4 py-3`,children:[(0,Z.jsx)(m,{type:`button`,variant:`outline`,onClick:()=>n(!1),children:i(`common:ui.cancel`)}),(0,Z.jsx)(m,{type:`button`,variant:`secondary`,disabled:!l.length,onClick:()=>{l.length&&(r(l),n(!1))},children:i(`chat:pathAttachmentPicker.attachCount`,{count:l.length})})]})]})})}function Hr({cwd:e,selection:t}){let{t:n}=x(),r=Ee(),[i,a]=(0,X.useState)(!1),o=(0,X.useRef)(null),s=async()=>{if(r){o.current?.click();return}if(window.pisperDesktop?.pickFiles){try{let n=await window.pisperDesktop.pickFiles(e);t.addAttachments(Rr(n||[]))}catch(e){t.setError(e)}return}a(!0)};return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`input`,{ref:o,type:`file`,className:`hidden`,accept:Mr,multiple:!0,"aria-label":n(`chat:focusSession.addAttachment`),onChange:e=>{let n=[...e.currentTarget.files||[]];e.currentTarget.value=``,n.length&&t.addFiles(n)}}),(0,Z.jsxs)(`button`,{type:`button`,className:`attach-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] relative grid place-items-center border-0 rounded-[var(--r-xs)] bg-transparent text-[var(--text-muted)] cursor-pointer hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] [&_i]:absolute [&_i]:top-[-4px] [&_i]:right-[-4px] [&_i]:grid [&_i]:min-w-[14px] [&_i]:h-[14px] [&_i]:place-items-center [&_i]:[border:2px_solid_var(--solid)] [&_i]:rounded-[var(--r-pill)] [&_i]:bg-[var(--blue)] [&_i]:text-[var(--on-accent)] [&_i]:p-[0_3px] [&_i]:text-[13px] [&_i]:[font-style:normal]`,title:n(`chat:focusSession.addAttachment`),"aria-label":n(`chat:focusSession.addAttachment`),onClick:()=>void s(),children:[(0,Z.jsx)(xe,{size:17}),t.attachments.length>0&&(0,Z.jsx)(`i`,{children:t.attachments.length})]}),(0,Z.jsx)(Vr,{open:i,initialPath:e,onOpenChange:a,onSelect:e=>t.addAttachments(Rr(e))})]})}function Ur({attachments:e,onRemove:t,compact:n=!1}){let{t:r}=x();return e.length?(0,Z.jsx)(`div`,{className:`attachment-tray [&.compact]:max-h-[58px] flex max-h-[116px] flex-wrap gap-[6px] overflow-auto ${n?`compact`:``}`,children:e.map(e=>(0,Z.jsxs)(`div`,{className:`attachment-chip [&_>_img]:w-[30px] [&_>_img]:h-[30px] [&_>_img]:rounded-[var(--r-xs)] [&_>_img]:object-cover [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_>_button]:grid [&_>_button]:w-[32px] [&_>_button]:h-[32px] [&_>_button]:place-items-center [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-xs)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text-muted)] [&_>_button:hover]:bg-[var(--danger-soft)] [&_>_button:hover]:text-[var(--danger)] dark:bg-[var(--surface-subtle)] grid min-w-[150px] max-w-[250px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [padding:5px]`,children:[e.kind===`image`?(0,Z.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.data}`,alt:``}):(0,Z.jsx)(`span`,{className:`grid w-[30px] h-[30px] place-items-center rounded-[var(--r-xs)] bg-[var(--violet-soft)] text-[var(--violet-strong)]`,children:(0,Z.jsx)(he,{size:13})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsxs)(`small`,{children:[e.kind===`path`?r(`chat:focusSession.localPath`):e.kind===`image`?r(`chat:focusSession.image`):e.kind===`document`?r(`chat:focusSession.document`):r(`chat:focusSession.text`),e.kind===`path`?``:` · ${Je(e.size)}`,e.truncated?` · ${r(`chat:focusSession.truncated`)}`:``]})]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":r(`chat:focusSession.removeName`,{name:e.name}),onClick:()=>t(String(e.id||``)),children:(0,Z.jsx)(Me,{size:12})})]},e.id))}):null}function Wr({open:e,sessionId:t,onClose:n,onSelect:r,onCommandSelect:i}){let{t:o}=x(),s=Be(e=>e.capabilities),c=J(s,`workflows`),[l,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(`all`),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)({}),[S,C]=(0,X.useState)(!1),[w,T]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!e)return;let n=!0;return p(`all`),g(``),v(null),b({}),C(!0),T(``),Promise.all([a.getSessionCommands(t),c?u(`/api/workflows`):Promise.resolve({workflows:[]}),u(`/api/plugins?sessionId=${encodeURIComponent(t)}`)]).then(([e,t,r])=>{if(!n)return;let i=new Set(r.callableToolNames||[]);d([...(e.commands||[]).map(e=>({kind:e.source,id:e.name,name:e.name,description:e.description||``,inputs:[],argumentHint:e.argumentHint,invocation:e.invocation})),...(t.workflows||[]).filter(e=>e.status===`published`).map(e=>({kind:`workflow`,id:e.id,name:e.name,description:e.description||``,inputs:e.inputs||[]})),...(r.plugins||[]).flatMap(e=>(e.capabilities||[]).filter(e=>i.has(e.name)).map(t=>({kind:`tool`,id:t.name,name:t.id?Ct(t,o):String(t.label||t.name),description:t.id?wt(t,o):t.description,inputs:[],sourceName:e.name})))])}).catch(e=>{n&&(d([]),T(e instanceof Error?e.message:String(e)))}).finally(()=>n&&C(!1)),()=>{n=!1}},[e,t,o,c]);let E=(0,X.useMemo)(()=>({all:l.length,prompt:l.filter(e=>e.kind===`prompt`).length,skill:l.filter(e=>e.kind===`skill`).length,tool:l.filter(e=>e.kind===`tool`).length,workflow:l.filter(e=>e.kind===`workflow`).length}),[l]),D=(0,X.useMemo)(()=>{let e=h.trim().toLowerCase();return l.filter(t=>(f===`all`||t.kind===f)&&(!e||`${t.name} ${t.id} ${t.description} ${t.kind===`tool`?t.sourceName:``}`.toLowerCase().includes(e)))},[f,h,l]),O=e=>{let t=e;p(t),_&&t!==`all`&&_.kind!==t&&v(null)},k=e=>{v(e),b(Object.fromEntries(e.inputs.map(e=>[e.name,e.defaultValue??``])))};return(0,Z.jsx)(rt,{open:e,onOpenChange:e=>!e&&n(),children:(0,Z.jsxs)(Fe,{className:`chat-resource-dialog w-[min(820px,calc(100vw_-_32px))] h-[min(600px,calc(100dvh_-_32px))] max-w-[820px] sm:max-w-[820px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden max-[650px]:w-[calc(100vw_-_16px)] max-[650px]:h-[calc(100dvh_-_16px)] z-[220] gap-0 p-0 ring-0`,overlayClassName:`z-[220]`,showCloseButton:!1,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-head [&_[data-slot='dialog-title']]:text-[16px] [&_[data-slot='dialog-description']]:mt-[3px] [&_[data-slot='dialog-description']]:text-[12px] max-[650px]:p-[14px] flex items-start justify-between gap-[16px] [border-bottom:1px_solid_var(--stroke-soft)] [padding:17px_18px_14px]`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Ke,{children:o(`chat:resourcePicker.title`)}),(0,Z.jsx)(tt,{children:o(`chat:resourcePicker.description`)})]}),(0,Z.jsx)(m,{size:`icon-sm`,variant:`ghost`,"aria-label":o(`chat:resourcePicker.close`),onClick:n,children:(0,Z.jsx)(Me,{})})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 grid-cols-[minmax(0,1.1fr)_minmax(260px,.9fr)] overflow-hidden max-[650px]:grid-cols-[1fr] max-[650px]:grid-rows-[minmax(0,1fr)_minmax(190px,auto)] max-[650px]:overflow-hidden`,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-browser flex min-w-0 min-h-0 flex-col [border-right:1px_solid_var(--stroke-soft)] p-[12px] max-[650px]:min-h-0 max-[650px]:[border-right:0] max-[650px]:[border-bottom:1px_solid_var(--stroke-soft)]`,children:[(0,Z.jsx)(lt,{value:f,onValueChange:O,className:`chat-resource-tabs [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:h-[36px] [&_[data-slot='tabs-list']]:[border:1px_solid_var(--stroke-soft)] [&_[data-slot='tabs-list']]:rounded-[var(--r-sm)] [&_[data-slot='tabs-list']]:bg-[var(--surface-muted)] [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-[5px] [&_[data-slot='tabs-trigger']]:rounded-[var(--r-xs)] [&_[data-slot='tabs-trigger']]:[padding-inline:6px] [&_[data-slot='tabs-trigger']]:text-[11px] [&_[data-slot='tabs-trigger'][data-state='active']]:bg-[var(--solid)] [&_[data-slot='tabs-trigger'][data-state='active']]:text-[var(--text)] [&_[data-slot='tabs-trigger']_small]:text-[var(--text-muted)] [&_[data-slot='tabs-trigger']_small]:text-[10px] [&_[data-slot='tabs-trigger']_small]:font-[500] w-full ${c?`[&_[data-slot='tabs-list']]:grid-cols-[repeat(5,minmax(0,1fr))]`:`[&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))]`}`,children:(0,Z.jsxs)(Ze,{"aria-label":o(`chat:resourcePicker.categories`),children:[(0,Z.jsxs)($e,{value:`all`,children:[o(`chat:resourcePicker.all`),(0,Z.jsx)(`small`,{children:E.all})]}),(0,Z.jsxs)($e,{value:`prompt`,children:[o(`chat:resourcePicker.prompt`),(0,Z.jsx)(`small`,{children:E.prompt})]}),(0,Z.jsxs)($e,{value:`skill`,children:[o(`chat:resourcePicker.skill`),(0,Z.jsx)(`small`,{children:E.skill})]}),(0,Z.jsxs)($e,{value:`tool`,children:[o(`chat:resourcePicker.tool`),(0,Z.jsx)(`small`,{children:E.tool})]}),c&&(0,Z.jsxs)($e,{value:`workflow`,children:[o(`chat:resourcePicker.workflow`),(0,Z.jsx)(`small`,{children:E.workflow})]})]})}),(0,Z.jsxs)(`label`,{className:`chat-resource-search [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_2px_var(--focus-ring)] [&_input]:w-full [&_input]:h-[36px] [&_input]:border-0 [&_input]:[outline:0]! [&_input]:bg-transparent [&_input]:text-[var(--text)] [&_input]:text-[13px] flex items-center gap-[7px] [margin-top:8px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] [padding:0_10px] text-[var(--text-muted)]`,children:[(0,Z.jsx)(dt,{size:15}),(0,Z.jsx)(`input`,{autoFocus:!0,value:h,onChange:e=>g(e.target.value),placeholder:o(`chat:resourcePicker.search`)})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-list [&_>_button]:grid [&_>_button]:w-full [&_>_button]:grid-cols-[30px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:[border:1px_solid_transparent] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:p-[8px] [&_>_button]:text-[var(--text)] [&_>_button]:text-left [&_>_button]:cursor-pointer [&_>_button:hover]:bg-[var(--surface-hover)] [&_>_button.active]:border-[var(--focus)] [&_>_button.active]:bg-[var(--blue-soft)] [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_em]:text-[var(--text-muted)] [&_em]:text-[10px] [&_em]:[font-style:normal] [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] flex min-h-0 [flex:1_1_0] flex-col gap-[3px] overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [margin-top:9px]`,children:[D.map(e=>{let t=e.kind===`prompt`?Rn:e.kind===`skill`?V:e.kind===`tool`?je:Te;return(0,Z.jsxs)(`button`,{type:`button`,className:_?.kind===e.kind&&_.id===e.id?`active`:``,onClick:()=>k(e),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(t,{size:15})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsx)(`small`,{children:e.description})]}),(0,Z.jsx)(`em`,{children:e.kind===`prompt`?o(`chat:resourcePicker.prompt`):e.kind===`skill`?`Skill`:e.kind===`tool`?o(`chat:resourcePicker.tool`):o(`chat:resourcePicker.workflow`)})]},`${e.kind}:${e.id}`)}),!D.length&&(0,Z.jsx)(`p`,{children:S?o(`chat:resourcePicker.loading`):w||o(`chat:resourcePicker.empty`)})]})]}),(0,Z.jsx)(`div`,{className:`chat-resource-config [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] [&_>_div:first-child]:flex [&_>_div:first-child]:flex-col [&_>_div:first-child]:gap-[4px] [&_strong]:text-[14px] [&_p]:text-[var(--text-muted)] [&_p]:text-[12px] max-[650px]:min-h-0 max-[650px]:max-h-[230px] flex min-w-0 min-h-0 flex-col gap-[16px] overflow-y-auto [overscroll-behavior:contain] [padding:18px]`,children:_?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`strong`,{children:_.name}),(0,Z.jsx)(`p`,{children:_.description||o(`chat:resourcePicker.noDescription`)})]}),_.kind===`workflow`&&_.inputs.length>0&&(0,Z.jsx)(`div`,{className:`chat-resource-inputs [&_label]:grid [&_label]:gap-[5px] [&_label]:text-[12px] [&_label]:font-[600] [&_input[type='checkbox']]:w-[16px] [&_input[type='checkbox']]:h-[16px] [&_input[type='checkbox']]:[accent-color:var(--blue)] flex flex-col gap-[11px]`,children:_.inputs.map(e=>(0,Z.jsxs)(`label`,{children:[(0,Z.jsxs)(`span`,{children:[e.label,e.required?` *`:``]}),e.type===`boolean`?(0,Z.jsx)(`input`,{type:`checkbox`,checked:!!y[e.name],onChange:t=>b(n=>({...n,[e.name]:t.target.checked}))}):(0,Z.jsx)(Ne,{type:e.type===`number`?`number`:`text`,required:e.required,value:String(y[e.name]??``),onChange:t=>b(n=>({...n,[e.name]:t.target.value}))})]},e.id))}),_.kind===`prompt`&&_.argumentHint&&(0,Z.jsx)(`code`,{className:`w-fit max-w-[100%] [overflow-wrap:anywhere] rounded-[var(--r-xs)] bg-[var(--surface-muted)] text-[var(--text-secondary)] [padding:5px_7px] text-[11px]`,children:_.argumentHint}),(0,Z.jsx)(m,{className:`chat-resource-confirm hover:bg-[var(--star-hover)] hover:text-[var(--on-accent)] min-w-[112px] min-h-[36px] self-start bg-[var(--star)] text-[var(--on-accent)] font-[650]`,onClick:()=>{if(_){if(_.kind===`prompt`){i(_.invocation||`/${_.name}`),n();return}r({kind:_.kind,resourceId:_.id,resourceName:_.name,arguments:_.kind===`workflow`?y:void 0,behavior:_.kind===`workflow`?`background`:`foreground`}),n()}},children:_.kind===`prompt`?o(`chat:resourcePicker.insertPrompt`):o(`chat:resourcePicker.useResource`)})]}):(0,Z.jsx)(`p`,{children:o(`chat:resourcePicker.chooseResource`)})})]})]})})}var Gr=64,Kr=new Map;function qr(e,t){let n=t.match(/^\/[^\s]*(?:\s+([\s\S]*))?$/),r=(n?n[1]||``:t).trim();return`${e}${r?` ${r}`:` `}`}function Jr(e){return{text:e?.text||``,attachments:[...e?.attachments||[]]}}function Yr(e){return Jr(Kr.get(e))}function Xr(e,t){if(!e)return;let n={...Yr(e),...t};if(n.attachments=[...n.attachments],Kr.delete(e),!(!n.text&&!n.attachments.length))for(Kr.set(e,n);Kr.size>Gr;){let e=Kr.keys().next().value;if(typeof e!=`string`)break;Kr.delete(e)}}function Zr(e){Kr.delete(e)}function Qr(e,t){let n=[...e.attachments],r=new Set(n.map(e=>e.id));for(let e of t.attachments){let t=e.id;if(!t||r.has(t)){let n=1;do t=`${e.id||`attachment`}-restored-${n++}`;while(r.has(t))}r.add(t),n.push({...e,id:t})}return{text:e.text&&t.text?`${e.text}\n${t.text}`:e.text||t.text,attachments:n}}function $r(e){let t=(0,X.useRef)(e);t.current=e;let n=(0,X.useRef)(!0);(0,X.useEffect)(()=>(n.current=!0,()=>{n.current=!1}),[]);let r=(0,X.useRef)(Yr(e)),[i,a]=(0,X.useState)(r.current.text),o=(0,X.useCallback)(t=>Xr(e,{attachments:t}),[e]),s=zr(r.current.attachments,o),c=s.replaceAttachments,l=s.clearAttachments;return(0,X.useEffect)(()=>{let t=Yr(e);a(t.text),c(t.attachments)},[c,e]),{value:i,updateValue:(0,X.useCallback)(t=>{a(t),Xr(e,{text:t})},[e]),selection:s,clearDraft:(0,X.useCallback)(()=>{let r=Yr(e);r.text!==i||r.attachments.length!==s.attachments.length||r.attachments.some((e,t)=>e!==s.attachments[t])||(Zr(e),!(!n.current||t.current!==e)&&(a(``),l()))},[l,s.attachments,e,i]),restoreDraft:(0,X.useCallback)(r=>{let i=Qr(Yr(e),r);return Xr(e,i),!n.current||t.current!==e?!1:(a(i.text),c(i.attachments),!0)},[c,e])}}function ei({sessionId:e,value:t,onChange:n,inputRef:r}){let{t:i,language:o}=x(),s=(0,X.useId)(),c=t.match(/^\/([^\s]*)$/),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(0),y=!!(c&&l!==t),b=c?.[1]||``;(0,X.useEffect)(()=>{u(``),f(null),g(!1)},[e]),(0,X.useEffect)(()=>{if(!y||d)return;let t=!0;return m(!0),g(!1),a.getSessionCommands(e).then(e=>{t&&f(e.commands||[])}).catch(()=>{t&&(f([]),g(!0))}).finally(()=>t&&m(!1)),()=>{t=!1}},[d,y,e]);let S=(0,X.useMemo)(()=>{let e=b.toLocaleLowerCase(o);return e?(d||[]).filter(t=>`${t.invocation} ${t.name} ${t.description}`.toLocaleLowerCase(o).includes(e)):d||[]},[d,o,b]);(0,X.useEffect)(()=>{v(0)},[b,d]);let C=()=>{u(t)},w=e=>{let i=qr(e.invocation,t);n(i),u(i),requestAnimationFrame(()=>{let e=r.current;e&&(e.focus(),e.setSelectionRange(i.length,i.length),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})};(0,X.useEffect)(()=>{if(!y)return;let e=e=>{if(document.activeElement===r.current){if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),C();return}S.length&&(e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),v(e=>(e+1)%S.length)):e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),v(e=>(e-1+S.length)%S.length)):(e.key===`Tab`||e.key===`Enter`&&!e.shiftKey)&&(e.preventDefault(),e.stopPropagation(),w(S[Math.min(_,S.length-1)])))}};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)});let T={user:i(`chat:commands.scope.user`),project:i(`chat:commands.scope.project`),package:i(`chat:commands.scope.package`),custom:i(`chat:commands.scope.custom`)};return(0,Z.jsx)(Z.Fragment,{children:y&&(0,Z.jsx)(`div`,{className:`permission-mode-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] right-0 [bottom:calc(100%_+_8px)] w-[250px] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] composer-command-menu`,id:s,role:`listbox`,"aria-label":i(`chat:commands.open`),style:{right:8,left:8,width:`auto`,maxHeight:`min(330px, 48dvh)`,overflowY:`auto`,padding:6},children:(0,Z.jsxs)(`div`,{className:`chat-resource-list [&_>_button]:grid [&_>_button]:w-full [&_>_button]:grid-cols-[30px_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:[border:1px_solid_transparent] [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:p-[8px] [&_>_button]:text-[var(--text)] [&_>_button]:text-left [&_>_button]:cursor-pointer [&_>_button:hover]:bg-[var(--surface-hover)] [&_>_button.active]:border-[var(--focus)] [&_>_button.active]:bg-[var(--blue-soft)] [&_button_>_span:nth-child(2)]:flex [&_button_>_span:nth-child(2)]:min-w-0 [&_button_>_span:nth-child(2)]:flex-col [&_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_em]:text-[var(--text-muted)] [&_em]:text-[10px] [&_em]:[font-style:normal] [&_>_p]:m-[auto] [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[12px] flex min-h-0 [flex:1_1_0] flex-col gap-[3px] overflow-y-auto [overscroll-behavior:contain] [scrollbar-gutter:stable] [touch-action:pan-y] [margin-top:9px] composer-command-list`,style:{marginTop:0},children:[S.map((e,t)=>{let n=e.source===`prompt`?Rn:V;return(0,Z.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t===_,className:t===_?`active`:``,onMouseEnter:()=>v(t),onMouseDown:e=>e.preventDefault(),onClick:()=>w(e),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(n,{size:15})}),(0,Z.jsxs)(`span`,{className:`composer-command-copy`,children:[(0,Z.jsxs)(`strong`,{children:[e.invocation,e.argumentHint&&(0,Z.jsxs)(`small`,{children:[` `,e.argumentHint]})]}),(0,Z.jsx)(`small`,{children:e.description||i(`chat:commands.noDescription`)})]}),(0,Z.jsxs)(`em`,{children:[e.source===`prompt`?i(`chat:commands.prompt`):i(`chat:commands.skill`),` · `,T[e.scope]]})]},e.invocation)}),!S.length&&(0,Z.jsx)(`p`,{children:i(p?`chat:commands.loading`:h?`chat:commands.loadError`:`chat:commands.empty`)})]})})})}var ti=[`attachment`,`resource`,`visual`,`model`,`permission`,`run-mode`,`thinking`,`commands`,`git-changes`,`compact-context`,`session-actions`],ni=new Set(ti),ri={inline:[...ti],overflow:[]};function ii(e){return Array.isArray(e)?e.filter((e,t,n)=>typeof e==`string`&&ni.has(e)&&n.indexOf(e)===t):[]}function ai(e){let t=e&&typeof e==`object`?e:{},n=ii(t.inline),r=new Set(n),i=ii(t.overflow).filter(e=>!r.has(e)),a=new Set([...n,...i]);for(let e of ti)a.has(e)||n.push(e);return{inline:n,overflow:i}}function oi(e,t,n){let r=ai(e),i=r.inline.filter(e=>e!==t),a=r.overflow.filter(e=>e!==t);return n===`inline`?i.push(t):a.push(t),{inline:i,overflow:a}}function si(e,t,n){let r=ai(e),i=r.inline.includes(t)?`inline`:`overflow`,a=[...r[i]],o=a.indexOf(t),s=o+n;return o<0||s<0||s>=a.length?r:([a[o],a[s]]=[a[s],a[o]],{...r,[i]:a})}function ci(e,t,n){let r=ai(e),i=new Set(t),a=r.inline.filter(e=>i.has(e)),o=r.overflow.filter(e=>i.has(e)),s=Number.isFinite(n)?Math.max(0,Math.floor(n)):a.length,c=a.slice(0,s),l=a.slice(s);return{inline:c,automaticallyOverflowed:l,overflow:[...l,...o]}}var li=e(n(),1),ui=8,di=8;function fi({open:e,anchorRef:t,menuRef:n,placement:r=`top`,align:i=`start`,className:a,role:o,ariaLabel:s,onClose:c,children:l}){return(0,X.useEffect)(()=>{if(!e||!c)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,c]),(0,X.useLayoutEffect)(()=>{if(!e)return;let a=()=>{let e=n.current,a=t.current;if(!e||!a)return;let o=a.getBoundingClientRect(),s=window.innerWidth-ui,c=window.innerHeight-ui,l=Math.max(120,r===`top`?o.top-di-ui:c-o.bottom-di);e.style.maxHeight=`${l}px`,e.style.overflowY=`auto`,r===`top`?(e.style.top=`auto`,e.style.bottom=`${window.innerHeight-o.top+di}px`):(e.style.bottom=`auto`,e.style.top=`${o.bottom+di}px`),i===`end`?(e.style.left=`auto`,e.style.right=`${window.innerWidth-o.right}px`):(e.style.right=`auto`,e.style.left=`${o.left}px`);let u=e.getBoundingClientRect();u.right>s?(e.style.right=`auto`,e.style.left=`${Math.max(ui,s-u.width)}px`):u.left<ui&&(e.style.right=`auto`,e.style.left=`${ui}px`)};return a(),window.addEventListener(`resize`,a),window.addEventListener(`scroll`,a,!0),()=>{window.removeEventListener(`resize`,a),window.removeEventListener(`scroll`,a,!0)}},[e,t,n,r,i]),e?(0,li.createPortal)((0,Z.jsx)(`div`,{ref:n,className:a,style:{position:`fixed`,zIndex:65},role:o,"aria-label":s,children:l}),document.body):null}function pi({open:e,children:t,label:n,trayId:r,anchorRef:i,menuRef:a}){return(0,Z.jsx)(fi,{open:e,anchorRef:i,menuRef:a,placement:`top`,align:`start`,className:`composer-tool-tray-shell w-max max-w-[calc(100vw-16px)] overflow-visible rounded-[var(--r-md)] border border-[var(--stroke)] bg-[var(--solid)] p-1.5 shadow-[0_18px_42px_-18px_var(--menu-shadow)] motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-bottom-1`,role:`toolbar`,ariaLabel:n,children:(0,Z.jsx)(`div`,{id:r,className:`composer-tool-tray flex max-h-[min(52vh,360px)] min-h-9 w-max max-w-full min-w-0 flex-wrap items-center gap-1 overflow-x-hidden overflow-y-auto overscroll-contain`,children:t})})}var mi=le()(ue(e=>({layout:ri,setToolLocation:(t,n)=>e(e=>({layout:oi(e.layout,t,n)})),moveTool:(t,n)=>e(e=>({layout:si(e.layout,t,n)})),resetLayout:()=>e({layout:ri})}),{name:`pisper-composer-toolbar`,version:1,partialize:({layout:e})=>({layout:e}),merge:(e,t)=>({...t,layout:ai(e?.layout)})}));function hi(e,t){return e.inline.join(`\0`)===t.inline.join(`\0`)&&e.overflow.join(`\0`)===t.overflow.join(`\0`)}function gi({ids:e,location:t,labels:n,onMove:r,onReorder:i}){let{t:a}=x(),o=t===`inline`?`overflow`:`inline`,s=t===`inline`?En:Zn,c=a(t===`inline`?`chat:focusSession.moveShortcutToOverflow`:`chat:focusSession.pinShortcutToComposer`);return(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--stroke-soft)] border-y border-[var(--stroke-soft)]`,children:e.map((t,l)=>(0,Z.jsxs)(`div`,{className:`flex min-h-11 min-w-0 items-center gap-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap text-[13px] font-semibold text-[var(--text)]`,children:n[t]}),(0,Z.jsxs)(`div`,{className:`flex flex-none items-center gap-1`,children:[(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,title:a(`chat:focusSession.moveShortcutEarlier`),"aria-label":a(`chat:focusSession.moveShortcutEarlierName`,{name:n[t]}),disabled:l===0,onClick:()=>i(t,-1),children:(0,Z.jsx)(oe,{})}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,title:a(`chat:focusSession.moveShortcutLater`),"aria-label":a(`chat:focusSession.moveShortcutLaterName`,{name:n[t]}),disabled:l===e.length-1,onClick:()=>i(t,1),children:(0,Z.jsx)(Dn,{})}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,title:c,"aria-label":a(`chat:focusSession.moveShortcutName`,{name:n[t],location:c}),onClick:()=>r(t,o),children:(0,Z.jsx)(s,{})})]})]},t))})}function _i({labels:e}){let{t}=x(),n=mi(e=>e.layout),r=mi(e=>e.setToolLocation),i=mi(e=>e.moveTool),a=mi(e=>e.resetLayout);return(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(Re,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:`grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-muted)] text-[var(--text-muted)] hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)]`,title:t(`chat:focusSession.customizeShortcuts`),"aria-label":t(`chat:focusSession.customizeShortcuts`),children:(0,Z.jsx)(tr,{size:16})})}),(0,Z.jsxs)(Fe,{className:`gap-4 rounded-[var(--r-md)] p-4`,style:{width:`min(640px, calc(100vw - 24px))`,maxWidth:640},children:[(0,Z.jsxs)(We,{className:`pr-9`,children:[(0,Z.jsx)(Ke,{children:t(`chat:focusSession.customizeShortcuts`)}),(0,Z.jsx)(tt,{className:`sr-only`,children:t(`chat:focusSession.customizeShortcutsDescription`)})]}),(0,Z.jsxs)(`div`,{className:`grid min-w-0 grid-cols-2 gap-5 max-[650px]:grid-cols-1`,children:[(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`mb-2 text-[12px] font-bold text-[var(--text-soft)]`,children:t(`chat:focusSession.composerShortcuts`)}),(0,Z.jsx)(gi,{ids:n.inline,location:`inline`,labels:e,onMove:r,onReorder:i})]}),(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[(0,Z.jsx)(`h3`,{className:`mb-2 text-[12px] font-bold text-[var(--text-soft)]`,children:t(`chat:focusSession.overflowShortcuts`)}),n.overflow.length?(0,Z.jsx)(gi,{ids:n.overflow,location:`overflow`,labels:e,onMove:r,onReorder:i}):(0,Z.jsx)(`p`,{className:`border-y border-[var(--stroke-soft)] py-3 text-[12px] text-[var(--text-muted)]`,children:t(`chat:focusSession.noOverflowShortcuts`)})]})]}),(0,Z.jsx)(`div`,{className:`flex justify-end border-t border-[var(--stroke-soft)] pt-3`,children:(0,Z.jsxs)(m,{type:`button`,variant:`outline`,size:`sm`,disabled:hi(n,ri),onClick:a,children:[(0,Z.jsx)(I,{}),t(`chat:focusSession.restoreShortcutDefaults`)]})})]})]})}function vi({...e}){return(0,Z.jsx)(Sn,{"data-slot":`popover`,...e})}function yi({...e}){return(0,Z.jsx)(Cn,{"data-slot":`popover-trigger`,...e})}function bi({className:e,align:t=`center`,sideOffset:n=4,...r}){return(0,Z.jsx)(wn,{children:(0,Z.jsx)(Tn,{"data-slot":`popover-content`,align:t,sideOffset:n,className:ce(`z-[200] flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r})})}function xi({className:e,...t}){return(0,Z.jsx)(`div`,{"data-slot":`popover-title`,className:ce(`font-medium`,e),...t})}var Si={completed:`completed`,in_progress:`running`,blocked:`blocked`,pending:`pending`};function Ci(e){let t=new Map(e.map(e=>[String(e.id||``),e])),n=e=>e?.status===`completed`;return e.map(e=>{let r=String(e.id||``),i=(Array.isArray(e.dependsOn)?e.dependsOn:[]).map(e=>t.get(String(e))).filter(e=>!!e&&!n(e)),a=e.status!==`completed`&&(e.status===`blocked`||i.length>0);return{...e,id:r,blocked:a,blockedBy:i}})}function wi(e){return e===`completed`?fe:e===`in_progress`?G:e===`blocked`?Kn:G}function Ti({status:e,t}){let n=wi(e),r=t(e===`completed`?`chat:planBoard.completed`:e===`in_progress`?`chat:planBoard.inProgress`:e===`blocked`?`chat:planBoard.blocked`:`chat:planBoard.pending`);return(0,Z.jsxs)(`span`,{className:`plan-board-status [&.completed]:text-[var(--success)] [&.running]:text-[var(--star-strong)] inline-flex items-center gap-[4px] flex-none text-[11px] text-[var(--text-muted)] ${Si[String(e)]||`pending`}`,children:[(0,Z.jsx)(n,{size:12}),r]})}function Ei({item:e,current:t,t:n}){return(0,Z.jsxs)(`li`,{className:`plan-board-row flex flex-col gap-[2px] [padding:5px_6px] rounded-[var(--r-sm)] ${e.blocked?`blocked [.plan-board-summary_&]:text-[var(--star-strong)] [.plan-board-row&]:opacity-[.72] [.plan-board-status&]:text-[var(--danger)]`:``}`,"aria-current":t?`step`:void 0,"data-pisper-plan-current":t?`true`:void 0,"data-pisper-plan-id":e.id,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-[8px] min-w-0`,children:[(0,Z.jsx)(Ti,{status:e.blocked?`blocked`:e.status,t:n}),(0,Z.jsx)(`span`,{className:`flex-1 min-w-0 overflow-hidden text-[var(--text)] text-[13px] text-ellipsis whitespace-nowrap`,title:e.title,children:e.title}),e.assignee?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-[4px] flex-none [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[var(--stroke-soft)] [padding:1px_8px] text-[var(--text-secondary)] text-[11px] whitespace-nowrap`,title:n(`chat:planBoard.assignedTo`,{name:e.assignee}),children:[(0,Z.jsx)(or,{size:11}),e.assignee]}):e.status!==`completed`&&(0,Z.jsx)(`span`,{className:`flex-none text-[var(--text-muted)] text-[11px] [font-style:italic]`,children:n(`chat:planBoard.unassigned`)})]}),e.blockedBy.length>0&&(0,Z.jsxs)(`div`,{className:`inline-flex items-center gap-[5px] [padding-left:2px] text-[var(--text-muted)] text-[11px]`,children:[(0,Z.jsx)(Kn,{size:11}),n(`chat:planBoard.waitingFor`,{tasks:e.blockedBy.map(e=>e.title||e.id).join(` · `)})]})]})}function Di({plan:e,header:t,collapsible:n=!1}){let{t:r}=x(),i=(0,X.useRef)(null),[a,o]=(0,X.useState)(!0),s=e?.items||[],c=Ci(s),l=c.filter(e=>e.status===`completed`).length,u=c.filter(e=>e.status===`in_progress`&&!e.blocked).length,d=c.filter(e=>e.blocked).length,f=c.find(e=>e.status===`in_progress`&&!e.blocked)?.id??c.find(e=>e.blocked)?.id??c.find(e=>e.status===`pending`)?.id??c.at(-1)?.id;if((0,X.useLayoutEffect)(()=>{if(n&&!a)return;let e=i.current,t=e?.querySelector(`[data-pisper-plan-current="true"]`);if(!e||!t)return;let r=e.getBoundingClientRect(),o=t.getBoundingClientRect();o.top<r.top?e.scrollTop-=r.top-o.top:o.bottom>r.bottom&&(e.scrollTop+=o.bottom-r.bottom)},[n,f,a,c.length]),!s.length)return null;let p=c.find(e=>e.id===f),m=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Wn,{className:`flex-none text-[var(--star-strong)]`,size:15}),(0,Z.jsx)(`strong`,{children:r(`chat:planBoard.progress`,{completed:l,total:s.length})}),p?(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 overflow-hidden text-[var(--text-secondary)] text-ellipsis whitespace-nowrap`,title:p.title,children:p.title}):null,(0,Z.jsxs)(`span`,{className:`plan-board-counts @max-[470px]:hidden inline-flex flex-none items-center gap-[8px]`,children:[u>0&&(0,Z.jsx)(`span`,{children:r(`chat:planBoard.countInProgress`,{count:u})}),d>0&&(0,Z.jsx)(`span`,{className:`blocked [.plan-board-summary_&]:text-[var(--star-strong)] [.plan-board-row&]:opacity-[.72] [.plan-board-status&]:text-[var(--danger)]`,children:r(`chat:planBoard.countBlocked`,{count:d})})]}),t,n?(0,Z.jsx)(pe,{className:`plan-board-chevron [.plan-board-collapsible[open]_&]:[transform:rotate(180deg)] flex-none [transition:transform_var(--d1)_var(--ease-out)]`,size:15}):null]}),h=(0,Z.jsx)(`ul`,{ref:i,className:`plan-board-list [.plan-board-collapsible_>_&]:[border-top:1px_solid_var(--stroke-soft)] [.plan-board-collapsible_>_&]:p-[8px_10px_10px] flex flex-col gap-[2px] m-0 [padding:8px_0_0] [list-style:none]${c.length>4?` is-scrollable [.session-plan-popover_.plan-board-list&]:[block-size:min(250px,38dvh)] [.plan-board-list&]:[block-size:min(220px,34dvh)] [.plan-board-list&]:overflow-y-auto [.plan-board-list&]:[overscroll-behavior:contain] [.plan-board-list&]:pr-[4px] [.plan-board-list&]:[scrollbar-gutter:stable] [.plan-board-list&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-list&:focus-visible]:[outline-offset:2px]`:``}`,tabIndex:c.length>4?0:void 0,children:c.map(e=>(0,Z.jsx)(Ei,{item:e,current:e.id===f,t:r},e.id))});return n?(0,Z.jsxs)(`details`,{className:`plan-board flex flex-col w-[min(900px,100%)] m-[0_auto] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--main-surface-bg)] p-[10px_14px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0 plan-board-collapsible !p-0`,open:a,onToggle:e=>o(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{className:`plan-board-summary [&_strong]:flex-none [&_strong]:text-[var(--text)] [&_strong]:font-[600] [.plan-board-collapsible_>_&]:min-h-[38px] [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[7px_10px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:[list-style:none] [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-[var(--surface-hover)] [.plan-board-collapsible_>_&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-collapsible_>_&:focus-visible]:[outline-offset:-2px] @max-[470px]:[.plan-board-collapsible_>_&]:[padding-inline:8px] flex min-w-0 items-center gap-[8px] [padding-bottom:8px] [border-bottom:1px_solid_var(--stroke-soft)] text-[12px] text-[var(--text-secondary)]`,"aria-label":r(`chat:planBoard.toggleAriaLabel`),children:m}),h]}):(0,Z.jsxs)(`section`,{className:`plan-board flex flex-col w-[min(900px,100%)] m-[0_auto] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--main-surface-bg)] p-[10px_14px] [.session-plan-popover_&]:w-full [.session-plan-popover_&]:border-0 [.session-plan-popover_&]:bg-transparent [.session-plan-popover_&]:p-0`,"aria-label":r(`chat:planBoard.ariaLabel`),children:[(0,Z.jsx)(`div`,{className:`plan-board-summary [&_strong]:flex-none [&_strong]:text-[var(--text)] [&_strong]:font-[600] [.plan-board-collapsible_>_&]:min-h-[38px] [.plan-board-collapsible_>_&]:border-0 [.plan-board-collapsible_>_&]:p-[7px_10px] [.plan-board-collapsible_>_&]:cursor-pointer [.plan-board-collapsible_>_&]:[list-style:none] [.plan-board-collapsible_>_&::-webkit-details-marker]:hidden [.plan-board-collapsible_>_&:hover]:bg-[var(--surface-hover)] [.plan-board-collapsible_>_&:focus-visible]:[outline:2px_solid_var(--accent-border)] [.plan-board-collapsible_>_&:focus-visible]:[outline-offset:-2px] @max-[470px]:[.plan-board-collapsible_>_&]:[padding-inline:8px] flex min-w-0 items-center gap-[8px] [padding-bottom:8px] [border-bottom:1px_solid_var(--stroke-soft)] text-[12px] text-[var(--text-secondary)]`,children:m}),h]})}var Oi=(0,X.memo)(Di);function ki({usage:e,plan:t,compact:n=!1}){let{t:r}=x(),i=Math.max(0,Number(e?.processedTokens)||0),a=Array.isArray(t?.items)?t.items:[],o=a.filter(e=>e?.status===`completed`).length,s=a.length?r(`chat:planBoard.progress`,{completed:o,total:a.length}):``,c=Number(e?.cacheHitRate),l=e?.cacheHitRate!=null&&Number.isFinite(c),u=l?`${Math.round(Math.max(0,c))}%`:`—`,d=l?``:r(`chat:focusSession.cacheHitRateUnavailable`),f=[r(`chat:focusSession.sessionUsageDetail`,{processed:Y(i),input:Y(e?.input),output:Y(e?.output),cacheRead:Y(e?.cacheRead),cacheWrite:Y(e?.cacheWrite),reasoning:Y(e?.reasoning),requests:Math.max(0,Number(e?.requests)||0)}),d,s].filter(Boolean).join(`
3
+ `);return(0,Z.jsxs)(`div`,{className:`session-usage-metrics [&_>_span]:inline-flex [&_>_span]:min-w-0 [&_>_span]:items-center [&_>_span]:gap-[4px] [&_>_span]:whitespace-nowrap [&_small]:text-inherit [&_small]:text-[inherit] [&_strong]:text-[var(--text-secondary)] [&_strong]:text-[11px] [&_strong]:[font-variant-numeric:tabular-nums] [&_strong]:font-[600] [&_svg]:text-[var(--text-tertiary)] [&_svg]:opacity-[.9] [&_>_i]:w-[1px] [&_>_i]:h-[10px] [&_>_i]:bg-[var(--border-subtle,var(--stroke-soft,#ddd))] @max-[470px]:[&_small]:hidden flex min-w-0 min-h-[26px] items-center justify-start gap-[10px] m-0 text-inherit text-[10px] ${n?`[&_small]:hidden gap-[7px]`:``}`,title:f,"aria-label":f,children:[!n&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(Fn,{size:12}),(0,Z.jsx)(`small`,{children:r(`chat:focusSession.cacheHitRate`)}),(0,Z.jsx)(`strong`,{children:u})]}),(0,Z.jsx)(`i`,{"aria-hidden":`true`})]}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(er,{size:12}),(0,Z.jsx)(`small`,{children:r(`chat:focusSession.processedTokens`)}),(0,Z.jsx)(`strong`,{children:Y(i)})]}),s&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`i`,{"aria-hidden":`true`}),(0,Z.jsxs)(vi,{children:[(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`session-plan-progress inline-flex min-w-0 items-center gap-[4px] whitespace-nowrap hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] data-[state=open]:bg-[var(--surface-hover)] data-[state=open]:text-[var(--star-strong)] focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:1px] min-h-[24px] border-0 rounded-[var(--r-xs)] bg-transparent [padding:2px_5px] text-inherit cursor-pointer`,title:r(`chat:planBoard.openCurrentPlan`,{progress:s}),"aria-label":r(`chat:planBoard.openCurrentPlan`,{progress:s}),children:[(0,Z.jsx)(Gn,{size:12}),(0,Z.jsx)(`strong`,{children:s})]})}),(0,Z.jsx)(bi,{className:`session-plan-popover w-[min(440px,calc(100vw_-_24px))] max-h-[min(360px,55dvh)] overflow-auto [padding:6px]`,align:`start`,side:`top`,sideOffset:7,children:(0,Z.jsx)(Oi,{plan:t??null})})]})]})]})}function Ai({usage:e,onThresholdChange:t,compact:n=!1}){let{t:r}=x(),i=Number(e?.contextWindow)||0,a=e?.compactAtPercent==null?80:Number(e.compactAtPercent),o=Number.isFinite(a)?Math.round(a):80,[s,c]=(0,X.useState)(o),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(``),p=(0,X.useRef)(o),m=(0,X.useRef)(void 0);if((0,X.useEffect)(()=>{window.clearTimeout(m.current),c(o),p.current=o},[o]),(0,X.useEffect)(()=>()=>window.clearTimeout(m.current),[]),!i)return null;let h=e?.percent!=null&&Number.isFinite(Number(e.percent)),g=h?Math.max(0,Number(e.percent)):null,_=g==null?null:Math.round(g),v=Math.max(50,o-15),y=g==null?`unknown`:g>=o?`danger`:g>=v?`warning`:`normal`,b=h?e.estimated?r(`chat:focusSession.estimatedContextUsageTokensLimitTokensPercent`,{tokens:Y(e.tokens),limit:Y(i),percent:_}):r(`chat:focusSession.contextUsageTokensLimitTokensPercent`,{tokens:Y(e.tokens),limit:Y(i),percent:_}):r(`chat:focusSession.contextUsageWillUpdateAfterTheNextModelResponseLimitLimitTokens`,{limit:Y(i)}),S=e?.autoCompactEnabled?r(`chat:focusSession.autoCompactionThresholdAboutPercent`,{percent:o}):r(`chat:focusSession.automaticContextCompactionIsDisabled`),C=e?.autoCompactEnabled&&e.compactionCapacityPercent!=null?r(`chat:focusSession.contextUsageToCompactionTokensPercent`,{percent:Math.round(Number(e.compactionCapacityPercent)),tokens:Y(e.remainingBeforeCompaction)}):``,w=`${b} · ${S}${C?` · ${C}`:``}`,T=`${e?.tokens==null?`—`:Y(e.tokens)} / ${Y(i)}`,E=async e=>{let n=Math.min(95,Math.max(50,Math.round(e)));if(c(n),!(!t||n===p.current)){u(!0),f(``);try{await t(n),p.current=n}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},D=e=>{window.clearTimeout(m.current),c(e),m.current=window.setTimeout(()=>void E(e),250)},O=e=>{window.clearTimeout(m.current),E(e)};return(0,Z.jsxs)(vi,{children:[(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`context-usage-chip hover:opacity-100 [&_>_svg]:opacity-[.72] [&_>_span]:inline-flex [&_>_span]:[align-items:baseline] [&_>_span]:gap-[4px] [&_>_span]:whitespace-nowrap [&_>_span_strong]:text-inherit [&_>_span_strong]:text-[11px] [&_>_span_strong]:font-[500] [&_>_span_small]:text-inherit [&_>_span_small]:text-[10px] [&_>_span_small]:font-[600] [&_>_i]:block [&_>_i]:w-[24px] [&_>_i]:h-[2px] [&_>_i]:overflow-hidden [&_>_i]:rounded-[var(--r-pill)] [&_>_i]:bg-[var(--stroke-soft)] [&_>_i_>_b]:block [&_>_i_>_b]:h-full [&_>_i_>_b]:rounded-[inherit] [&_>_i_>_b]:bg-[var(--text-muted)] [&_>_i_>_b]:[transition:width_var(--d2)_var(--ease-out)] [&.warning_>_span_small]:text-[var(--warning-strong)] [&.warning_>_i_>_b]:bg-[var(--warning-strong)] [&.danger_>_span_small]:text-[var(--danger)] [&.danger_>_i_>_b]:bg-[var(--danger)] [&.unknown_>_i_>_b]:!w-[0] @max-[470px]:grid-cols-[auto_auto] @max-[470px]:[&_>_i]:hidden grid h-[24px] flex-none grid-cols-[auto_auto_24px] items-center gap-[4px] border-0 bg-transparent [padding:0_2px] text-[var(--text-tertiary)] text-[10px] opacity-[.78] cursor-pointer [transition:opacity_var(--d1)_var(--ease-out)] ${n?`!h-11 grid-cols-[auto_auto] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] px-2 opacity-100 [&.warning_>_span_strong]:text-[var(--warning-strong)] [&.danger_>_span_strong]:text-[var(--danger)]`:``} ${y}`,"aria-label":w,title:w,children:[(0,Z.jsx)(zn,{size:12}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n?_==null?`—`:`${_}%`:T}),!n&&(0,Z.jsx)(`small`,{children:_==null?`—`:`${_}%`})]}),!n&&(0,Z.jsx)(`i`,{"aria-hidden":`true`,children:(0,Z.jsx)(`b`,{style:{width:`${Math.min(100,g||0)}%`}})})]})}),(0,Z.jsxs)(bi,{className:`context-usage-popover [&_input[type='range']]:w-full [&_input[type='range']]:h-[20px] [&_input[type='range']]:m-0 [&_input[type='range']]:[accent-color:var(--brand-blue-strong)] [&_input[type='range']]:cursor-pointer [&_>_small]:min-h-[16px] [&_>_small]:text-[var(--text-muted)] [&_>_small]:text-[10px] [&_>_small]:leading-[1.4] [&_>_small.error]:text-[var(--danger)] w-[248px] gap-[8px] [padding:12px]`,align:`end`,sideOffset:8,children:[C&&(0,Z.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:C}),(0,Z.jsxs)(`div`,{className:`context-threshold-heading flex items-center justify-between [&_output]:text-[var(--brand-blue-strong)] [&_output]:[font-variant-numeric:tabular-nums] text-[var(--text)] text-[12px] font-[600]`,children:[(0,Z.jsx)(`span`,{children:r(`chat:focusSession.autoCompactionThreshold`)}),(0,Z.jsxs)(`output`,{children:[s,`%`]})]}),(0,Z.jsx)(`input`,{type:`range`,min:`50`,max:`95`,step:`1`,value:s,"aria-label":r(`chat:focusSession.autoCompactionThreshold`),disabled:l,onChange:e=>D(Number(e.currentTarget.value)),onBlur:e=>O(Number(e.currentTarget.value)),onPointerUp:e=>O(Number(e.currentTarget.value)),onKeyUp:e=>{[`ArrowLeft`,`ArrowRight`,`Home`,`End`,`PageUp`,`PageDown`].includes(e.key)&&O(Number(e.currentTarget.value))}}),(0,Z.jsxs)(`div`,{className:`context-threshold-scale flex items-center justify-between text-[var(--text-tertiary)] text-[10px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`span`,{children:`50%`}),(0,Z.jsx)(`span`,{children:`95%`})]}),(0,Z.jsx)(`small`,{className:d?`error`:``,children:d||(l?r(`chat:focusSession.savingCompactionThreshold`):`\xA0`)})]})]})}function ji({value:e,models:t,onChange:n,disabled:r,compact:i=!1}){let{t:a}=x(),o=t.find(t=>t.key===e),s=o?`${o.providerName} · ${o.label}`:e.split(`/`).at(-1);return(0,Z.jsxs)(`div`,{className:`session-model-select [&.compact]:max-w-[118px] [&.compact]:h-[32px] [&.compact]:rounded-[var(--r-xs)] [&_[data-slot='select-trigger']]:w-full [&_[data-slot='select-trigger']]:h-full [&_[data-slot='select-trigger']]:min-h-0 [&_[data-slot='select-trigger']]:overflow-hidden [&_[data-slot='select-trigger']]:border-0 [&_[data-slot='select-trigger']]:[outline:0] [&_[data-slot='select-trigger']]:bg-transparent [&_[data-slot='select-trigger']]:p-[0_22px_0_8px] [&_[data-slot='select-trigger']]:text-inherit [&_[data-slot='select-trigger']]:text-[13px] [&_[data-slot='select-trigger']]:font-[600] [&_[data-slot='select-trigger']]:text-ellipsis [&_[data-slot='select-trigger']]:whitespace-nowrap [&.compact_[data-slot='select-trigger']]:text-[12px] [&_>_svg]:absolute [&_>_svg]:right-[6px] [&_>_svg]:flex-none [&_>_svg]:pointer-events-none [&:has([data-slot='select-trigger']:disabled)]:[cursor:not-allowed] [&:has([data-slot='select-trigger']:disabled)]:opacity-[.55] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-composer_&]:h-[38px] [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] dark:bg-[var(--accent-soft)] relative flex max-w-[170px] h-[30px] items-center rounded-[var(--r-xs)] bg-[var(--accent-soft)] text-[var(--star-strong)] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${i?`compact`:``}`,title:a(r?`chat:focusSession.currentModelModelCannotSwitchWhileRunning`:`chat:focusSession.currentModelModelClickToSwitch`,{model:s}),children:[(0,Z.jsx)(Ue,{size:i?11:14}),(0,Z.jsxs)(B,{value:e,onChange:e=>n(e.target.value),disabled:r||t.length===0,"aria-label":a(`chat:focusSession.currentChatModel`),children:[!o&&(0,Z.jsx)(`option`,{value:e,children:e.split(`/`).at(-1)}),t.map(e=>(0,Z.jsxs)(`option`,{value:e.key,children:[e.providerName,` · `,e.label]},e.key))]})]})}function Mi({value:e,levels:t,status:n=`supported`,message:r=``,onChange:i,disabled:a,compact:o=!1}){let{t:s}=x(),c=e||t[0]||`off`,l=!n&&t.length===0,u=n!==`unsupported`&&t.length>0,d=u&&t.length<=1&&t.includes(c),f=l?s(`chat:focusSession.loadingThinkingLevels`):u?s(d?`chat:focusSession.thinkingLevelFixed`:a?`chat:focusSession.currentThinkingLevelLevelCannotSwitchWhileRunning`:`chat:focusSession.currentThinkingLevelLevelClickToSwitch`,{level:c}):r||s(`chat:focusSession.thinkingLevelUnsupported`);return(0,Z.jsxs)(`div`,{className:`session-model-select [&.compact]:max-w-[118px] [&.compact]:h-[32px] [&.compact]:rounded-[var(--r-xs)] [&_[data-slot='select-trigger']]:w-full [&_[data-slot='select-trigger']]:h-full [&_[data-slot='select-trigger']]:min-h-0 [&_[data-slot='select-trigger']]:overflow-hidden [&_[data-slot='select-trigger']]:border-0 [&_[data-slot='select-trigger']]:[outline:0] [&_[data-slot='select-trigger']]:bg-transparent [&_[data-slot='select-trigger']]:p-[0_22px_0_8px] [&_[data-slot='select-trigger']]:text-inherit [&_[data-slot='select-trigger']]:text-[13px] [&_[data-slot='select-trigger']]:font-[600] [&_[data-slot='select-trigger']]:text-ellipsis [&_[data-slot='select-trigger']]:whitespace-nowrap [&.compact_[data-slot='select-trigger']]:text-[12px] [&_>_svg]:absolute [&_>_svg]:right-[6px] [&_>_svg]:flex-none [&_>_svg]:pointer-events-none [&:has([data-slot='select-trigger']:disabled)]:[cursor:not-allowed] [&:has([data-slot='select-trigger']:disabled)]:opacity-[.55] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-composer_&]:h-[38px] [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] dark:bg-[var(--accent-soft)] relative flex max-w-[170px] h-[30px] items-center rounded-[var(--r-xs)] bg-[var(--accent-soft)] text-[var(--star-strong)] session-thinking-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none [.focus-composer_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${o?`compact`:``}`,title:f,children:[(0,Z.jsx)(nt,{size:o?11:14}),(0,Z.jsxs)(B,{value:c,onChange:e=>i(e.target.value),disabled:a||l||!u||d,"aria-label":s(`chat:focusSession.currentThinkingLevel`),children:[!t.includes(c)&&(0,Z.jsx)(`option`,{value:c,children:c}),t.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))]})]})}function Ni(e){return[[`approval-required`,e(`chat:focusSession.approvalRequired`),e(`chat:focusSession.approvalRequiredShowsADiffBeforeWriting`),In],[`workspace-write`,e(`chat:focusSession.workspaceWrite`),e(`chat:focusSession.workspaceWriteRunsCommandsWithAutomaticApproval`),kn],[`full-access`,e(`chat:focusSession.fullAccess`),e(`chat:focusSession.fullAccessRunsShellWithoutPerCommandApproval`),$n]]}function Pi({value:e,onChange:t,disabled:n,compact:r=!1}){let{t:i}=x(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)({left:0,top:0,width:270}),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=Ni(i),f=d.find(t=>t[0]===e)||d[0],p=f[3],m=(0,X.useCallback)(()=>{let e=l.current?.querySelector(`button`);if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(270,window.innerWidth-16),r=u.current?.offsetHeight||190,i=Math.max(8,Math.min(t.right-n,window.innerWidth-n-8)),a=t.top>=r+8+8?t.top-r-8:Math.min(t.bottom+8,window.innerHeight-r-8);c({left:i,top:Math.max(8,a),width:n})},[]);(0,X.useLayoutEffect)(()=>{if(a)return m(),window.addEventListener(`resize`,m),window.addEventListener(`scroll`,m,!0),()=>{window.removeEventListener(`resize`,m),window.removeEventListener(`scroll`,m,!0)}},[a,m]),(0,X.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.target instanceof Node?e.target:null;!l.current?.contains(t)&&!u.current?.contains(t)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a]);let h=a&&(0,li.createPortal)((0,Z.jsxs)(`div`,{ref:u,className:`permission-mode-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(250px,calc(100vw_-_76px))] absolute z-[35] right-0 [bottom:calc(100%_+_8px)] w-[250px] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] execution-mode-menu !fixed !right-auto !bottom-auto z-[80]`,style:s,role:`menu`,children:[(0,Z.jsx)(`div`,{className:`[padding:6px_8px_4px] text-[var(--text-muted)] text-[11px] font-[700] tracking-[.04em] [text-transform:uppercase]`,children:i(`chat:focusSession.approvalMode`)}),d.map(([e,n,r,i])=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===f[0],className:e===f[0]?`active`:``,onClick:()=>{t(e),o(!1)},children:[(0,Z.jsx)(`span`,{className:`permission-level [&.level-auto]:bg-[var(--accent-soft)] [&.level-auto]:text-[var(--star-strong)] [&.level-ignore]:bg-[var(--danger-soft)] [&.level-ignore]:text-[var(--danger)] [&.level-full-access]:bg-[var(--danger-soft)] [&.level-full-access]:text-[var(--danger)] grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)] level-${e}`,children:(0,Z.jsx)(i,{size:13})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n}),(0,Z.jsx)(`small`,{children:r})]}),e===f[0]&&(0,Z.jsx)(fe,{size:13})]},e))]}),document.body);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{ref:l,className:`permission-mode-select [&.compact]:min-w-[68px] [&.compact]:h-[32px] [.focus-composer_&]:h-[38px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] @max-[700px]:[.focus-composer_&]:min-w-0 max-[650px]:[.focus-composer_&]:min-w-0 relative min-w-[78px] h-[32px] text-[var(--text-tertiary)] execution-mode-select icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] ${r?`compact`:``} ${a?`open`:``}`,children:(0,Z.jsx)(`button`,{type:`button`,className:`permission-mode-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.permission-mode-select.open_&]:border-[var(--accent-border)] [.permission-mode-select.open_&]:bg-[var(--accent-soft)] [.permission-mode-select.open_&]:text-[var(--star-strong)] disabled:[cursor:not-allowed] disabled:opacity-[.55] [.permission-mode-select.compact_&]:gap-[3px] [.permission-mode-select.compact_&]:rounded-[var(--r-xs)] [.permission-mode-select.compact_&]:p-[0_4px] [.permission-mode-select.compact_&]:text-[13px] [.focus-composer_&]:rounded-[var(--r-sm)] dark:hover:bg-[var(--accent-soft)] grid w-full h-full grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[5px] [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit [padding:0_7px] text-[12px] font-[700] icon-only [.session-model-select&]:w-[38px] [.session-model-select&]:min-w-[38px] [.session-model-select&]:max-w-[none] [.session-model-select&]:overflow-hidden [.session-model-select&]:flex-none [.session-model-select&]:justify-center [.session-model-select&]:bg-[var(--surface-muted)] [.session-model-select&]:text-[var(--text-muted)] [.session-model-select&.compact]:w-[32px] [.session-model-select&.compact]:min-w-[32px] [.session-model-select&:hover]:bg-[var(--star-soft)] [.session-model-select&:hover]:text-[var(--star-strong)] [.session-model-select&_>_svg]:[position:static] [.session-model-select&_[data-slot='select-trigger']]:absolute [.session-model-select&_[data-slot='select-trigger']]:inset-0 [.session-model-select&_[data-slot='select-trigger']]:w-full [.session-model-select&_[data-slot='select-trigger']]:h-full [.session-model-select&_[data-slot='select-trigger']]:min-h-0 [.session-model-select&_[data-slot='select-trigger']]:p-0 [.session-model-select&_[data-slot='select-trigger']]:opacity-0 [.session-model-select&_[data-slot='select-trigger']]:cursor-pointer [[data-theme='dark']_.session-model-select&]:bg-[var(--surface-muted)] [.permission-mode-select&]:min-w-0 [.permission-mode-select.compact&]:min-w-0 [.permission-mode-trigger&]:relative [.permission-mode-trigger&]:w-[38px] [.permission-mode-trigger&]:grid-cols-[1fr] [.permission-mode-trigger&]:[justify-items:center] [.permission-mode-trigger&]:p-0 [.permission-mode-select.compact_.permission-mode-trigger&]:w-[32px] [.permission-mode-trigger&.mode-auto]:text-[var(--star-strong)] [.permission-mode-trigger&.mode-ignore]:text-[var(--danger)] [.permission-mode-trigger&.mode-full-access]:text-[var(--danger)] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:w-[36px] [.focus-session.has-conversation_.focus-composer_.permission-mode-trigger&]:h-[36px] @max-[700px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] max-[650px]:[.focus-composer_.permission-mode-trigger&]:w-[36px] mode-${f[0]}`,title:i(`chat:focusSession.approvalModeModeDescription`,{mode:f[1],description:f[2]}),disabled:n,"aria-haspopup":`menu`,"aria-expanded":a,"aria-label":i(`chat:focusSession.approvalModeMode`,{mode:f[1]}),onClick:()=>o(e=>!e),children:(0,Z.jsx)(p,{size:r?11:14})})}),h]})}function Fi(e,{threshold:t=64,onUnreadChange:n,requestFrame:r=e=>requestAnimationFrame(e),cancelFrame:i=e=>cancelAnimationFrame(e),reducedMotion:a}){let o=e.ownerDocument,s=o.defaultView?.matchMedia?.(`(prefers-reduced-motion: reduce)`),c=a||(()=>{let e=o.documentElement.dataset.motion;return e===`reduced`||e!==`full`&&!!s?.matches}),l=!0,u=!1,d=!1,f=null,p=null,m=null,h=e.scrollTop,g=!1,_=!1,v=null,y=()=>Math.max(0,e.scrollHeight-e.clientHeight),b=()=>_||v!==null,x=e=>{u!==e&&(u=e,n(e))},S=()=>{p!==null&&i(p),p=null},C=()=>{f!==null&&i(f),f=null,m=null,S(),g=!1,h=e.scrollTop},w=()=>{S(),g=!0},T=()=>{S(),p=r(()=>{p=r(()=>{if(p=null,l&&!b()&&Math.abs(y()-e.scrollTop)>1){O();return}g=!1,h=e.scrollTop})})},E=t=>{e.scrollTo({top:t,behavior:`instant`}),h=e.scrollTop},D=t=>{if(f=null,d||!l||b())return;let n=y(),i=n-e.scrollTop,a=m===null?1e3/60:Math.min(64,t-m);m=t;let o=1-.85**(Math.max(0,a)/(1e3/60));if(c()||Math.abs(i)<=1){i!==0&&E(n),m=null,T();return}E(e.scrollTop+Math.sign(i)*Math.min(Math.abs(i),Math.max(1,Math.abs(i)*o))),f=r(D)},O=()=>{d||!l||b()||(w(),f===null&&(f=r(D)))},k=()=>{d||(l=!1,C())},A=()=>{l=!0,x(!1),O()},j=()=>{let n=e.scrollTop-h;h=e.scrollTop,!(g||d)&&(n<-.5?k():n>.5&&y()-e.scrollTop<=t&&A())},M=t=>{t.ctrlKey||Math.abs(t.deltaX)>Math.abs(t.deltaY)||(t.deltaY<0?k():t.deltaY>0&&y()-e.scrollTop<=1&&A())},N=e=>{let t=e.touches[0];t&&(v={x:t.clientX,y:t.clientY},C())},P=e=>{let t=e.touches[0];if(!t||!v)return;let n=t.clientX-v.x,r=t.clientY-v.y;Math.abs(r)<2||(r>0&&r>Math.abs(n)&&k(),v={x:t.clientX,y:t.clientY})},F=()=>{v=null,O()},I=e=>{e.pointerType===`touch`||e.button>1||(_=!0,C())},L=()=>{_&&(_=!1,O())},R=e=>{let t=e.target;e.defaultPrevented||t?.closest?.(`input, textarea, select, [contenteditable]`)||(e.key===`ArrowUp`||e.key===`PageUp`||e.key===`Home`||e.key===` `&&e.shiftKey)&&k()};e.addEventListener(`scroll`,j,{passive:!0}),e.addEventListener(`wheel`,M,{passive:!0}),e.addEventListener(`touchstart`,N,{passive:!0}),e.addEventListener(`touchmove`,P,{passive:!0}),e.addEventListener(`touchend`,F,{passive:!0}),e.addEventListener(`touchcancel`,F,{passive:!0}),e.addEventListener(`pointerdown`,I,{passive:!0}),e.addEventListener(`keydown`,R),o.addEventListener(`pointerup`,L,{passive:!0}),o.addEventListener(`pointercancel`,L,{passive:!0}),s?.addEventListener?.(`change`,O);let z=typeof ResizeObserver>`u`?null:new ResizeObserver(O);return z?.observe(e),{maintainBottom:O,pauseFollowing:k,contentChanged(){d||(l?O():x(!0))},scrollToBottom(e=`auto`){d||(C(),l=!0,x(!1),e===`smooth`?O():(w(),E(y()),T()))},dispose(){d=!0,C(),z?.disconnect(),e.removeEventListener(`scroll`,j),e.removeEventListener(`wheel`,M),e.removeEventListener(`touchstart`,N),e.removeEventListener(`touchmove`,P),e.removeEventListener(`touchend`,F),e.removeEventListener(`touchcancel`,F),e.removeEventListener(`pointerdown`,I),e.removeEventListener(`keydown`,R),o.removeEventListener(`pointerup`,L),o.removeEventListener(`pointercancel`,L),s?.removeEventListener?.(`change`,O)}}}function Ii(e,{threshold:t=64,resetKey:n}={}){let r=(0,X.useRef)(null),[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null),l=(0,X.useCallback)(e=>{r.current=e,a(e)},[]);return(0,X.useLayoutEffect)(()=>{if(!i)return;let e=Fi(i,{threshold:t,onUnreadChange:s});return c.current=e,s(!1),e.scrollToBottom(),()=>{e.dispose(),c.current=null}},[n,i,t]),(0,X.useEffect)(()=>{c.current?.contentChanged()},[e]),{scrollRef:r,scrollElement:i,setScrollRef:l,hasUnread:o,scrollToBottom:(0,X.useCallback)((e=`auto`)=>{c.current?.scrollToBottom(e)},[]),maintainBottom:(0,X.useCallback)(()=>{c.current?.maintainBottom()},[]),pauseFollowing:(0,X.useCallback)(()=>{c.current?.pauseFollowing()},[])}}function Li(e){return e===`queued`?{titleKey:`{name} 等待调度`,tone:`waiting`}:e===`starting`?{titleKey:`{name} 正在启动`,tone:`running`}:e===`running`?{titleKey:`{name} 正在运行`,tone:`running`}:e===`completed`?{titleKey:`{name} 已完成`,tone:`completed`}:e===`interrupted`?{titleKey:`{name} 已中断`,tone:`stopped`}:e===`failed`?{titleKey:`{name} 执行失败`,tone:`failed`}:{titleKey:`{name} 状态已更新`,tone:`waiting`}}function Ri(e){let t=typeof e==`string`||typeof e==`number`||e instanceof Date?e:0,n=new Date(t).getTime();return Number.isFinite(n)?n:0}function zi({currentActivity:e,compaction:t,text:n,thinkingText:r,lastActivityAt:i}={}){return t?.active?{type:`compaction`,compaction:t,updatedAt:t.startedAt||i}:e&&[`model`,`compaction`,`retry`].includes(e.type)?e:{type:`model`,stage:e?.type===`tool`?e.status===`running`?`working`:`processing_result`:String(r||``).trim()?`thinking`:String(n||``).trim()?`responding`:`thinking`,updatedAt:e?.updatedAt||i}}function Bi(e=[]){return e.map(e=>`${e.type}:${e.id||e.agent?.id||``}:${e.status||e.stage||e.agent?.status||``}`).join(`|`)}function Vi(e,t=0){return e.type===`tool`?`tool:${e.id||e.name||t}`:e.type===`agent`?`agent:${e.agent?.id||e.agent?.canonicalName||t}:${e.agent?.status||e.status||``}`:e.type===`plan`?`plan:${e.id||mr(e)?.updatedAt||e.updatedAt||t}`:`${e.type||`activity`}:${e.id||e.startedAt||e.createdAt||t}`}function Hi(e){return e?.type?e.type===`tool`?`tool:${e.id||e.name||``}`:e.type===`agent`?`agent:${e.agent?.id||e.agent?.canonicalName||``}`:e.type===`plan`?`plan:${e.updatedAt||mr(e)?.updatedAt||``}`:e.type===`communication`?`communication:${e.id||``}`:e.type===`model`?`model:${e.stage||``}`:e.type===`compaction`?`compaction:${e.compaction?.status||e.compaction?.active||``}`:`${e.type}:${e.id||e.updatedAt||``}`:``}function Ui(e,t){let n=new Map((e?.items||[]).map(e=>[String(e.id||``),e])),r=new Map((t?.items||[]).map(e=>[String(e.id||``),e])),i=[];for(let e of r.values()){let t=n.get(String(e.id||``));t?(t.status!==e.status||t.title!==e.title||t.note!==e.note)&&i.push({id:e.id,title:e.title,status:e.status,previousStatus:t.status,kind:`updated`}):i.push({id:e.id,title:e.title,status:e.status,kind:`added`})}for(let e of n.values())r.has(String(e.id||``))||i.push({id:e.id,title:e.title,status:e.status,kind:`removed`});return i}function Wi(e=[],t,n=6){let r=Array.isArray(e)?e:[];if(![`tool`,`plan`,`agent`,`communication`].includes(t?.type))return r;let i=[...r];t.type===`plan`&&(i=i.filter(e=>e?.type!==`tool`||!pr(e.name))),t.type===`agent`&&(i=i.filter(e=>e?.type!==`tool`||![`spawn_agent`,`list_agents`,`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(e.name)));let a=Hi(t),o=i.findIndex(e=>Hi(e)===a);return o>=0?i[o]={...i[o],...t}:i.push(t),i.slice(-Math.max(1,Number(n)||6))}function Gi(e=[],{finishedAt:t=new Date().toISOString(),error:n=``}={}){return e.map(e=>e?.status===`running`?{...e,status:n?`error`:`done`,message:n||e.message||``,updatedAt:t,finishedAt:t}:e)}function Ki(e,t,n=Date.now()){let r=Ri(e);if(!r)return 0;let i=Ri(t)||n;return Math.max(0,i-r)}function qi(e,t=`zh-CN`){let n=Math.max(0,Math.round(Number(e)||0));if(n<1e3)return t===`en-US`?`${n}ms`:`${n} 毫秒`;let r=Math.floor(n/1e3);if(r<60)return t===`en-US`?`${r}s`:`${r} 秒`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}:${String(a).padStart(2,`0`)}`:`${Math.floor(i/60)}:${String(i%60).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`}function Ji(e){return(e||0)>0&&Number(e)<650?260:164}function Yi(e,t){return e.scrollTop+t-e.scrollHeight}function Xi(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Zi(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Qi(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var $i=(e,t)=>Math.abs(e-t)<1.01,ea=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},ta,na=()=>{if(ta!==void 0)return ta;if(typeof navigator>`u`)return ta=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return ta=!0;let e=navigator.maxTouchPoints;return ta=navigator.platform===`MacIntel`&&e!==void 0&&e>0},ra=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ia=e=>e,aa=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},oa=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(ra(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(ra(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},sa={passive:!0},ca=typeof window>`u`||`onscrollend`in window,la=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&ca,o=0,s=a?null:ea(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,sa),a&&r.addEventListener(`scrollend`,u,sa),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},ua=(e,t)=>la(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),da=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},fa=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},pa=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ia,rangeExtractor:aa,onChange:()=>{},measureElement:da,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Zi(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.targetWindow=this.scrollElement&&`ownerDocument`in this.scrollElement?this.scrollElement.ownerDocument.defaultView:this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!na()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,sa),e.addEventListener(`touchend`,n,sa),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(na()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Zi(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=Zi(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=Xi(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Zi(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=ga(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Zi(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=this.itemSizeCache.get(i)??n,s=t-o;if(s!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,c=a?this.getTotalSize():0,l=this.getScrollOffset()+this.scrollAdjustments,u=this.itemSizeCache.has(i)?r+o<=l&&this.scrollDirection!==`backward`:r<l,d=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?u:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},s,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++;let f=!1;a?f=this.applyScrollAdjustment(this.getTotalSize()-c):d&&(f=this.applyScrollAdjustment(s)),this.notify(f)}},this.getVirtualItems=Zi(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return Qi(t[ma(0,t.length-1,r?e=>n[e*2]:e=>Qi(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`){if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t]}if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){return e===0?!1:na()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?(this._iosDeferredAdjustment+=e,!1):(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0),!0)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&$i(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},ma=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function ha(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function ga(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=ha(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=ma(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var _a=typeof document<`u`?X.useLayoutEffect:X.useEffect;function va({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=X.useReducer(e=>e+1,0)[1],a=X.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}},s=e=>{let t=a.current;if(!t.enabled||!t.container)return;o(e);let n=!!e.options.horizontal,r=t.mode===`transform`,i=n?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let a of c){let o=a.start-s,c=e.elementsCache.get(a.key);c&&t.lastPositions.get(c)!==o&&(t.lastPositions.set(c,o),r?c.style.transform=n?`translate3d(${o}px, 0, 0)`:`translate3d(0, ${o}px, 0)`:c.style[i]=`${o}px`)}},c={...r,onChange:(t,n)=>{var o;let c=a.current,l=!0;if(c.enabled){s(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,li.flushSync)(i):i()),(o=r.onChange)==null||o.call(r,t,n)}},[l]=X.useState(()=>{let e=new pa(c);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return l.setOptions(c),_a(()=>l._didMount(),[]),_a(()=>(o(l),l._willUpdate())),_a(()=>{s(l)}),l}function ya(e){return va({observeElementRect:oa,observeElementOffset:ua,scrollToFn:fa,...e})}var ba=new Map,xa=e=>{let t=ba.get(e);return t||(t=yt.create(e),ba.set(e,t)),t};(0,X.memo)(({children:e,as:t=`p`,className:n,duration:r=2,spread:i=2})=>{let a=xa(t),o=(0,X.useMemo)(()=>(e?.length??0)*i,[e,i]);return(0,Z.jsx)(a,{animate:{backgroundPosition:`0% center`},className:ce(`relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent`,`[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]`,n),initial:{backgroundPosition:`100% center`},style:{"--spread":`${o}px`,backgroundImage:`var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))`},transition:{duration:r,ease:`linear`,repeat:1/0},children:e})});var Sa=(0,X.createContext)(null),Ca=({className:e,isStreaming:t=!1,children:n,...r})=>{let i=(0,X.useMemo)(()=>({isStreaming:t}),[t]);return(0,Z.jsx)(Sa.Provider,{value:i,children:(0,Z.jsx)(te,{asChild:!0,"data-slot":`plan`,...r,children:(0,Z.jsx)(at,{className:ce(`shadow-none`,e),children:n})})})},wa=({defaultOpen:e=!0,className:t,...n})=>(0,Z.jsx)(te,{className:ce(t),defaultOpen:e,...n}),Ta=4e3,Ea=`… earlier output omitted …`;function Da(e){let t=String(e||``),n=``;for(let e=0;e<t.length;e+=1){let r=t.charCodeAt(e);if(r===27){let n=t.charCodeAt(e+1);if(n===91)for(e+=2;e<t.length&&t.charCodeAt(e)<64;)e+=1;else if(n===93)for(e+=2;e<t.length;){let n=t.charCodeAt(e);if(n===7)break;if(n===27&&t.charCodeAt(e+1)===92){e+=1;break}e+=1}else e+=1;continue}(r===9||r===10||r===13||r>=32&&r!==127)&&(n+=t[e])}return n}function Oa(e,t=Ta){let n=String(e||``),r=Math.max(1,Math.floor(Number(t)||4e3));if(n.length<=r)return{text:Da(n),truncated:!1};let i=n.slice(-r),a=i.indexOf(`
4
+ `);return a>=0&&a<Math.floor(r/3)&&(i=i.slice(a+1)),{text:Da(`${Ea}\n${i}`),truncated:!0}}function ka(e,t){return e===`read`?t(`chat:agentRunActivity.readingFiles`):e===`grep`?t(`chat:agentRunActivity.searchingContent`):e===`find`?t(`chat:agentRunActivity.findingFiles`):e===`ls`?t(`chat:agentRunActivity.browsingDirectories`):e===`edit`?t(`chat:agentRunActivity.editingFiles`):e===`write`?t(`chat:agentRunActivity.writingFiles`):e===`bash`?t(`chat:agentRunActivity.runningCommands`):e===`memory_search`?t(`chat:agentRunActivity.searchingMemory`):e===`memory_remember`?t(`chat:agentRunActivity.savingMemory`):e===`spawn_agent`?t(`chat:agentRunActivity.startingSubagent`):e===`list_agents`?t(`chat:agentRunActivity.checkingSubagents`):e===`send_message`?t(`chat:agentRunActivity.messagingSubagent`):e===`send_team_message`?t(`chat:agentRunActivity.messagingTeamMember`):e===`list_team_members`?t(`chat:agentRunActivity.checkingTeamMembers`):e===`run_team_workflow`?t(`chat:agentRunActivity.runningTeamWorkflow`):e===`followup_task`?t(`chat:agentRunActivity.addingSubagentTask`):e===`wait_agent`?t(`chat:agentRunActivity.waitingForSubagent`):e===`interrupt_agent`?t(`chat:agentRunActivity.interruptingSubagent`):dr(e)?t(`chat:agentRunActivity.readingPlan`):fr(e)?t(`chat:agentRunActivity.updatingPlan`):e===`browser_automation`?t(`chat:agentRunActivity.controllingBrowser`):e===`generate_visual`?t(`chat:agentRunActivity.generatingVisualContent`):e===`discover_tools`?t(`chat:agentRunActivity.discoveringTools`):t(`chat:agentRunActivity.usingTool`,{tool:String(e||t(`chat:agentRunActivity.tools`))})}function Aa(e,t){return e===`read`?t(`chat:agentRunActivity.filesRead`):e===`grep`?t(`chat:agentRunActivity.searchCompleted`):e===`find`?t(`chat:agentRunActivity.findCompleted`):e===`ls`?t(`chat:agentRunActivity.directoriesBrowsed`):e===`edit`?t(`chat:agentRunActivity.filesEdited`):e===`write`?t(`chat:agentRunActivity.filesWritten`):e===`bash`?t(`chat:agentRunActivity.commandCompleted`):e===`spawn_agent`?t(`chat:agentRunActivity.subagentStarted`):e===`send_team_message`?t(`chat:agentRunActivity.teamMessageSent`):e===`list_team_members`?t(`chat:agentRunActivity.teamMembersListed`):e===`run_team_workflow`?t(`chat:agentRunActivity.teamWorkflowStarted`):e===`wait_agent`?t(`chat:agentRunActivity.subagentStatusUpdated`):fr(e)?t(`chat:agentRunActivity.planUpdated`):t(e===`discover_tools`?`chat:agentRunActivity.toolsDiscovered`:`chat:agentRunActivity.currentOperationCompleted`)}function ja(e,t,n){return n(e===`queued`?`chat:agentRunActivity.agentQueued`:e===`starting`?`chat:agentRunActivity.agentStarting`:e===`running`?`chat:agentRunActivity.agentRunning`:e===`completed`?`chat:agentRunActivity.agentCompleted`:e===`interrupted`?`chat:agentRunActivity.agentInterrupted`:e===`failed`?`chat:agentRunActivity.agentFailed`:`chat:agentRunActivity.agentStatusUpdated`,{name:t})}function Ma(e,t){let n=e?.items||[],r=e?.counts?.completed??n.filter(e=>e.status===`completed`).length,i=e?.counts?.inProgress??n.filter(e=>e.status===`in_progress`).length;return[n.length?t(`chat:agentRunActivity.completedTotalCompleted`,{completed:r,total:n.length}):``,i?t(`chat:agentRunActivity.countInProgress`,{count:i}):``].filter(Boolean).join(` · `)||t(`chat:agentRunActivity.planCleared`)}function Na(e,t){return e.kind===`removed`?t(`chat:agentRunActivity.removedTitle`,{title:e.title}):e.status===`completed`?t(`chat:agentRunActivity.completedTitle`,{title:e.title}):e.status===`in_progress`?t(`chat:agentRunActivity.inProgressTitle`,{title:e.title}):e.status===`blocked`?t(`chat:agentRunActivity.blockedTitle`,{title:e.title}):e.kind===`added`?t(`chat:agentRunActivity.addedTitle`,{title:e.title}):t(`chat:agentRunActivity.pendingTitle`,{title:e.title})}function Pa(e,t){return e?.active?e.reason===`overflow`?t(`chat:agentRunActivity.contextIsFullTheRequestWillRetryAfterCompaction`):e.reason===`manual`?t(`chat:agentRunActivity.summarizingOlderMessagesAsRequested`):t(`chat:agentRunActivity.contextIsNearingItsLimitSummarizingOlderMessages`):e?.tokensBefore!=null&&e?.estimatedTokensAfter!=null?t(`chat:agentRunActivity.contextCompactedBeforeAfterTokens`,{before:Y(e.tokensBefore),after:Y(e.estimatedTokensAfter)}):t(`chat:agentRunActivity.summarizingOlderMessages`)}var Fa=[],Ia=`agent-run-status-icon [.agent-thinking-window.running_&]:text-[var(--brand-blue-strong)] [.agent-run-summary.completed_&]:bg-[var(--success-soft)] [.agent-run-summary.completed_&]:text-[var(--success)] [.agent-run-summary.plan_&]:bg-[var(--success-soft)] [.agent-run-summary.plan_&]:text-[var(--success)] [.agent-run-overview.completed_&]:bg-[var(--success-soft)] [.agent-run-overview.completed_&]:text-[var(--success)] [.agent-run-overview.plan_&]:bg-[var(--success-soft)] [.agent-run-overview.plan_&]:text-[var(--success)] [.agent-run-summary.compacting_&]:bg-[var(--warning-soft)] [.agent-run-summary.compacting_&]:text-[var(--star-strong)] [.agent-run-overview.compacting_&]:bg-[var(--warning-soft)] [.agent-run-overview.compacting_&]:text-[var(--star-strong)] [.agent-run-summary.failed_&]:bg-[var(--danger-soft)] [.agent-run-summary.failed_&]:text-[var(--danger)] [.agent-run-overview.failed_&]:bg-[var(--danger-soft)] [.agent-run-overview.failed_&]:text-[var(--danger)] [.agent-run-summary.stopped_&]:text-[var(--text-muted)] [.agent-run-overview.stopped_&]:text-[var(--text-muted)] [.agent-run-activity.compact_&]:w-[24px] [.agent-run-activity.compact_&]:h-[24px] grid w-[28px] h-[28px] place-items-center rounded-[var(--r-xs)] bg-[var(--blue-soft)] text-[var(--brand-blue-strong)]`,La=(0,X.lazy)(()=>i(()=>import(`./AnimatedList-_pbK4tS3.js`).then(e=>({default:e.AnimatedList})),__vite__mapDeps([0,1,2,3,4,5,6]))),Ra=(0,X.lazy)(()=>i(()=>import(`./ShinyText-fuaKxKqJ.js`).then(e=>({default:e.ShinyText})),__vite__mapDeps([7,2,1,3,4,6])));function za(e,t){return t(e===`queued`?`chat:agentRunActivity.teamTaskQueued`:e===`starting`?`chat:agentRunActivity.teamTaskStarting`:e===`running`?`chat:agentRunActivity.teamTaskRunning`:e===`completed`?`chat:agentRunActivity.teamTaskCompleted`:e===`failed`?`chat:agentRunActivity.teamTaskFailed`:e===`interrupted`?`chat:agentRunActivity.teamTaskInterrupted`:e===`blocked`?`chat:agentRunActivity.teamTaskBlocked`:`chat:agentRunActivity.teamTaskStatusUpdated`)}function Ba(e){let[t,n]=(0,X.useState)(()=>Date.now());return(0,X.useEffect)(()=>{if(n(Date.now()),!e)return;let t=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(t)},[e]),t}function Va({startedAt:e,finishedAt:t,streaming:n,language:r}){let i=qi(Ki(e,t,Ba(n)),r);return(0,Z.jsxs)(`span`,{className:`agent-run-duration inline-flex items-center gap-[4px] pt-[3px] text-[var(--text-muted)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] text-[11px] whitespace-nowrap [.agent-run-activity.compact_&]:text-[10px]`,children:[(0,Z.jsx)(L,{size:12}),i]})}function Q(e){return String(e||``).replace(/\s+/g,` `).trim()}function Ha(e){let t=e?.args||{};return e?.name===`bash`?{text:String(t.command||``).trim(),command:!0}:[`read`,`edit`,`write`,`ls`].includes(e?.name)?{text:Q(t.path)}:e?.name===`grep`?{text:[t.pattern?`“${Q(t.pattern)}”`:``,Q(t.path)].filter(Boolean).join(` · `)}:e?.name===`find`?{text:[Q(t.pattern),Q(t.path)].filter(Boolean).join(` · `)}:e?.name===`browser_automation`?{text:[Q(t.action),Q(t.url||t.selector)].filter(Boolean).join(` · `)}:e?.name===`spawn_agent`?{text:Q(t.taskName)}:[`send_message`,`followup_task`,`wait_agent`,`interrupt_agent`].includes(e?.name)?{text:Q(t.target)}:e?.name===`generate_visual`?{text:Q(t.outputName||t.kind)}:e?.name===`discover_tools`?{text:Q(t.query)}:{text:``}}function Ua(e,{t,streaming:n,text:r,thinkingText:i,compaction:a,error:o,stopped:s,notice:c,lastActivityAt:l,now:u}){let d=`running`,f=t(`chat:agentRunActivity.understandingTheTask`),p=c||``,m=``,h=!1,g=e.startedAt,_=Fa;if(e.type===`tool`){let n=e.status===`error`,r=e.status===`done`;d=n?`failed`:r?`completed`:`running`,f=n?t(`chat:agentRunActivity.toolFailed`,{tool:ka(e.name,t)}):r?Aa(e.name,t):ka(e.name,t);let i=Ha(e);p=i.text,h=!!i.command,m=Q(e.message)}else if(e.type===`plan`){d=`plan`;let n=mr(e);f=n?.items?.length?t(`chat:agentRunActivity.planUpdated`):t(`chat:agentRunActivity.planCleared`),_=e.changes||Fa,p=_.length?t(`chat:agentRunActivity.countPlanChanges`,{count:_.length}):Ma(n,t)}else if(e.type===`agent`){let n=e.agent||{},r=Q(n.taskName)||t(`chat:agentRunActivity.subagent`),i=Li(n.status);f=ja(n.status,r,t),d=i.tone,p=(n.currentActivity?.type===`tool`?Ha(n.currentActivity).text||n.currentActivity.name:``)||Q(n.error||n.message),m=n.status===`running`?Q(n.output):``,g=n.startedAt||g}else if(e.type===`communication`){let n=e.communication||{};d=`running`,f=t(`chat:agentRunActivity.teamMessageActivity`),p=t(`chat:agentRunActivity.teamMessageDetail`,{from:n.fromTaskName||n.fromAgentId||`lead`,to:n.toTaskName||n.toAgentId||``}),m=Q(n.message)}else if(e.type===`compaction`)d=`compacting`,f=t(`chat:agentRunActivity.compactingContext`),p=Pa(e.compaction||a,t);else if(e.type===`retry`)d=`waiting`,f=t(`chat:agentRunActivity.retryingRequest`),p=e.message||c||``;else{let a=Math.max(0,u-new Date(l||u).getTime());o?(d=`failed`,f=t(`chat:agentRunActivity.thisRunFailed`),p=o):s?(d=`stopped`,f=t(`chat:agentRunActivity.runStopped`)):n?a>=1e4?(d=`waiting`,f=t(`chat:agentRunActivity.waitingForTheModel`),p=t(`chat:agentRunActivity.noNewProgressForCountS`,{count:Math.floor(a/1e3)})):f=e.stage===`starting`?t(`chat:agentRunActivity.startingTheModel`):e.stage===`responding`?t(`chat:agentRunActivity.preparingTheResponse`):e.stage===`processing_result`?t(`chat:agentRunActivity.processingToolResult`):e.stage===`waiting_retry`?t(`chat:agentRunActivity.waitingToRetry`):e.stage===`finalizing`?t(`chat:agentRunActivity.finalizingTheRun`):e.stage===`working`?t(`chat:agentRunActivity.advancingTheTask`):String(i||``).trim()?t(`chat:agentRunActivity.reasoningAboutTheNextStep`):String(r||``).trim()?t(`chat:agentRunActivity.preparingTheResponse`):t(`chat:agentRunActivity.understandingTheTask`):(d=`completed`,f=t(`chat:agentRunActivity.reasoningCompleted`),p=Q(i)),String(i||``).trim()&&(p=Q(i))}return{tone:d,title:f,detail:p,output:m,command:h,startedAt:g,changes:_}}function Wa({tone:e}){return e===`failed`?(0,Z.jsx)(et,{size:14}):e===`stopped`?(0,Z.jsx)(ke,{size:12}):[`completed`,`plan`].includes(e)?(0,Z.jsx)(fe,{size:14}):(0,Z.jsx)(q,{className:`animate-spin`,size:14})}function Ga({activity:e,className:t,children:n}){return e.type===`tool`?(0,Z.jsx)(`div`,{className:t,"data-pisper-activity-type":`tool`,children:n}):e.type===`plan`?(0,Z.jsx)(Ca,{className:`${t} !gap-0 !rounded-none !border-0 !bg-transparent !p-0 !shadow-none`,"data-pisper-activity-type":`plan`,children:n}):e.type===`agent`?(0,Z.jsx)(wa,{className:t,"data-pisper-activity-type":`agent`,children:n}):(0,Z.jsx)(`div`,{className:t,"data-pisper-activity-type":e.type,children:n})}function Ka({output:e,streaming:t,t:n}){let r=Oa(e),i=(0,X.useRef)(null);return(0,X.useEffect)(()=>{if(!t)return;let e=window.requestAnimationFrame(()=>{let e=i.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[r.text,t]),r.text.trim()?(0,Z.jsxs)(`details`,{className:`agent-run-command-output [.agent-run-feed:has(&[open])]:max-h-[320px] [&_>_summary]:grid [&_>_summary]:min-h-[30px] [&_>_summary]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_summary]:items-center [&_>_summary]:gap-[7px] [&_>_summary]:[list-style:none] [&_>_summary]:p-[5px_8px] [&_>_summary]:text-[var(--text-muted)] [&_>_summary]:text-[11px] [&_>_summary]:font-[600] [&_>_summary]:cursor-pointer [&_>_summary::-webkit-details-marker]:hidden [&_>_summary:hover]:bg-[var(--surface-hover)] [&_>_summary:hover]:text-[var(--text-secondary)] [&_>_summary:focus-visible]:[outline:2px_solid_var(--accent-border)] [&_>_summary:focus-visible]:[outline-offset:-2px] [&_>_summary_>_svg:first-child]:text-[var(--brand-blue-strong)] [&_>_pre]:max-h-[112px] [&_>_pre]:overflow-auto [&_>_pre]:m-0 [&_>_pre]:[border-top:1px_solid_var(--stroke-soft)] [&_>_pre]:bg-[var(--surface-subtle)] [&_>_pre]:p-[9px_10px] [&_>_pre]:text-[var(--text-secondary)] [&_>_pre]:font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] [&_>_pre]:text-[11px] [&_>_pre]:leading-[1.55] [&_>_pre]:whitespace-pre-wrap [&_>_pre]:[overflow-wrap:anywhere] [.agent-run-activity.compact_&]:[grid-column:1/-1] min-w-0 [grid-column:2/-1] overflow-hidden [margin:2px_0_1px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)]`,"data-truncated":r.truncated||void 0,open:t||void 0,children:[(0,Z.jsxs)(`summary`,{children:[(0,Z.jsx)(me,{size:13}),(0,Z.jsx)(`span`,{children:n(t?`chat:agentRunActivity.liveCommandOutput`:`chat:agentRunActivity.commandOutput`)}),(0,Z.jsx)(Ie,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:13})]}),(0,Z.jsx)(`pre`,{ref:i,children:r.text})]}):null}function qa(e,t){return e.activity!==t.activity||e.latest!==t.latest||e.t!==t.t||e.streaming!==t.streaming?!1:[`tool`,`plan`,`agent`].includes(t.activity.type)?!0:e.text===t.text&&e.thinkingText===t.thinkingText&&e.compaction===t.compaction&&e.error===t.error&&e.stopped===t.stopped&&e.notice===t.notice&&e.lastActivityAt===t.lastActivityAt}var Ja=(0,X.memo)(function({activity:e,latest:t,t:n,streaming:r,text:i,thinkingText:a,compaction:o,error:s,stopped:c,notice:l,lastActivityAt:u}){let d=Ua(e,{t:n,streaming:r,text:i,thinkingText:a,compaction:o,error:s,stopped:c,notice:l,lastActivityAt:u,now:Date.now()}),f=e.name===`bash`&&t&&!!e.output;return(0,Z.jsxs)(Ga,{activity:e,className:`agent-run-summary grid w-full min-h-[42px] grid-cols-[28px_minmax(0,1fr)] [align-items:start] gap-[9px] p-[6px_8px] hover:bg-[var(--surface-hover)] hover:opacity-100 [.agent-run-activity.compact_&]:min-h-[34px] [.agent-run-activity.compact_&]:grid-cols-[24px_minmax(0,1fr)] [.agent-run-activity.compact_&]:gap-[7px] [.agent-run-activity.compact_&]:p-[4px_5px] @max-[700px]:grid-cols-[28px_minmax(0,1fr)] @max-[700px]:[&_>_svg]:hidden flex-none [border:1px_solid_transparent] rounded-[var(--r-sm)] opacity-[.82] [transition:border-color_var(--d1)_var(--ease-out),_background_var(--d1)_var(--ease-out),_opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)] ${d.tone} ${t?`current [.agent-run-summary&]:border-[var(--stroke-soft)] [.agent-run-summary&]:bg-[var(--surface-subtle)] [.agent-run-summary&]:opacity-100`:``}`,children:[(0,Z.jsx)(`span`,{className:Ia,children:(0,Z.jsx)(Wa,{tone:d.tone})}),(0,Z.jsxs)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:[(0,Z.jsx)(`strong`,{children:d.title}),d.detail&&(d.command?(0,Z.jsxs)(`code`,{className:`agent-run-command overflow-hidden text-[var(--text-muted)] text-[12px] leading-[1.45] text-ellipsis whitespace-nowrap block max-h-[2.9em] p-[3px_7px] rounded-[var(--r-xs)] bg-[var(--surface-subtle)] text-[var(--text-secondary)] font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] whitespace-pre-wrap [overflow-wrap:anywhere] [.agent-run-activity.compact_&]:text-[11px]`,title:d.detail,children:[`$ `,d.detail]}):(0,Z.jsx)(`small`,{title:d.detail,children:d.detail})),d.changes.length>0&&(0,Z.jsxs)(`span`,{className:`agent-run-plan-changes [&_small]:text-[var(--text-secondary)] flex min-w-0 flex-col gap-[1px] [padding:1px_0_0_7px] [border-left:1px_solid_var(--stroke-soft)]`,children:[d.changes.slice(0,4).map(e=>(0,Z.jsx)(`small`,{children:Na(e,n)},`${e.id}-${e.kind}-${e.status}`)),d.changes.length>4&&(0,Z.jsx)(`small`,{children:n(`chat:agentRunActivity.countMoreChanges`,{count:d.changes.length-4})})]}),!f&&d.output&&d.output!==d.detail&&(0,Z.jsx)(`small`,{className:`text-[var(--text-tertiary)]`,title:d.output,children:d.output})]}),f&&(0,Z.jsx)(Ka,{output:e.output,streaming:!!(r&&e.status===`running`),t:n})]})},qa);function Ya({streaming:e,text:t,thinkingText:n,currentActivity:r,team:i,activityFeed:a=Fa,tools:o=Fa,compaction:s,error:c,stopped:l,notice:u,startedAt:d,lastActivityAt:f,finishedAt:p,compact:m=!1}){let{t:h,language:g}=x(),_=String(n||``).trim(),v=(0,X.useRef)(null),y=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!_)return;let e=window.requestAnimationFrame(()=>{let e=v.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(e)},[_]);let b=a.length?a:o,S=Bi(b),C=Array.isArray(i?.tasks)?i.tasks:[],w=Number(i?.completedTaskCount??0),T=Number(i?.taskCount??C.length),E=Number(i?.tokenUsed??i?.tokensUsed??0),D=Number(i?.tokenBudget??i?.teamTokenBudget??0),O=Array.isArray(i?.communications)?i.communications:[],k=T>0?Math.min(100,Math.round(w/T*100)):0;if((0,X.useEffect)(()=>{if(!e||!b.length)return;let t=window.requestAnimationFrame(()=>{let e=y.current;e&&(e.scrollTop=e.scrollHeight)});return()=>window.cancelAnimationFrame(t)},[S,b.length,e]),!e&&!_&&!b.length&&!i)return null;let A=Ua(zi({currentActivity:r,compaction:s,text:t,thinkingText:n,lastActivityAt:f}),{t:h,streaming:e,text:t,thinkingText:_?``:n,compaction:s,error:c,stopped:l,notice:u,lastActivityAt:f,now:Date.now()});!e&&b.length&&(A.title=h(`chat:agentRunActivity.currentOperationCompleted`),A.detail=``);let j=e?0:b.length,M=!!(e||s?.active||c||l),N=A.command&&b.length?h(`chat:agentRunActivity.countLiveOperations`,{count:b.length}):i&&T>0?h(`chat:agentRunActivity.teamProgress`,{completed:w,total:T}):A.detail,P=r=>r.map((i,a)=>(0,Z.jsx)(Ja,{activity:i,compaction:s,error:c,lastActivityAt:f,latest:a===r.length-1,notice:u,stopped:l,streaming:e,t:h,text:t,thinkingText:_?``:n},Vi(i,a))),F=P(b),I=P(b.slice(-1));return(0,Z.jsxs)(`section`,{className:`agent-run-activity [&.compact]:m-[4px_0_0_40px] w-full overflow-hidden [margin:1px_0_9px] text-[var(--text)] ${m?`compact`:``}`,"aria-live":`polite`,children:[_&&(0,Z.jsxs)(`details`,{className:`agent-thinking-window [&[open]]:border-[var(--stroke-soft)] [&.completed]:border-[transparent] [&.completed[open]]:border-[var(--stroke-soft)] overflow-hidden [margin:1px_0_8px] [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-transparent [transition:border-color_var(--d1)_var(--ease-out)] ${e?`running`:`completed`}`,"data-pisper-activity-type":`reasoning`,children:[(0,Z.jsxs)(`summary`,{className:`agent-thinking-head [summary&]:[list-style:none] [summary&]:cursor-pointer [summary&::-webkit-details-marker]:hidden [summary&:hover]:bg-[var(--surface-hover)] [summary&:focus-visible]:[outline:2px_solid_var(--accent-border)] [summary&:focus-visible]:[outline-offset:-2px] grid min-h-[40px] grid-cols-[28px_minmax(0,1fr)_auto] items-center gap-[9px] [padding:6px_8px]`,"aria-label":h(`chat:agentRunActivity.toggleReasoning`),children:[(0,Z.jsx)(`span`,{className:Ia,children:(0,Z.jsx)(Ie,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Z.jsx)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:(0,Z.jsxs)(`strong`,{children:[h(e?`chat:agentRunActivity.reasoningInProgress`:`chat:agentRunActivity.reasoningCompleted`),e?(0,Z.jsxs)(`span`,{className:`agent-thinking-dots [&_i]:w-[3px] [&_i]:h-[3px] [&_i]:rounded-[50%] [&_i]:bg-[currentColor] [&_i]:[animation:agent-thinking-dot_1.15s_ease-in-out_infinite] [&_i:nth-child(2)]:[animation-delay:.14s] [&_i:nth-child(3)]:[animation-delay:.28s] inline-flex items-end gap-[2px] [margin-left:5px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{}),(0,Z.jsx)(`i`,{})]}):null]})}),!M&&j===0&&(0,Z.jsx)(Va,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),(0,Z.jsx)(`div`,{ref:v,className:`agent-thinking-scroll max-h-[190px] overflow-auto [border-top:1px_solid_var(--stroke-soft)] [padding:9px_12px] [scroll-behavior:smooth]`,children:(0,Z.jsx)(bt,{streaming:e,children:_})})]}),M&&(0,Z.jsxs)(`div`,{className:`agent-run-overview grid w-full min-h-[42px] grid-cols-[28px_minmax(0,1fr)_auto] [align-items:start] gap-[9px] p-[6px_8px] rounded-[var(--r-sm)] bg-[var(--surface-subtle)] [.agent-run-activity.compact_&]:min-h-[34px] [.agent-run-activity.compact_&]:grid-cols-[24px_minmax(0,1fr)_auto] [.agent-run-activity.compact_&]:gap-[7px] [.agent-run-activity.compact_&]:p-[4px_5px] ${A.tone}`,"data-pisper-activity-type":`status`,children:[(0,Z.jsx)(`span`,{className:Ia,children:(0,Z.jsx)(Wa,{tone:A.tone})}),(0,Z.jsxs)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:[(0,Z.jsx)(`strong`,{children:e&&[`running`,`waiting`,`compacting`].includes(A.tone)?(0,Z.jsx)(X.Suspense,{fallback:A.title,children:(0,Z.jsx)(Ra,{children:A.title})}):A.title}),N&&(0,Z.jsx)(`small`,{title:N,children:N})]}),(0,Z.jsx)(Va,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),i&&(C.length>0||O.length>0||(i.blockers?.length??0)>0||(i.conflicts?.length??0)>0||!!i.scriptPath||!!i.summary?.text)&&(0,Z.jsxs)(`details`,{className:`agent-team-panel overflow-hidden rounded-[var(--r-sm)] [border:1px_solid_var(--stroke-soft)] [margin:5px_0_2px]`,children:[(0,Z.jsxs)(`summary`,{className:`flex min-h-[38px] cursor-pointer items-center justify-between gap-[8px] [list-style:none] [padding:6px_8px] [&::-webkit-details-marker]:hidden hover:bg-[var(--surface-hover)]`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-[6px]`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`team-status-dot h-[6px] w-[6px] shrink-0 rounded-full ${i.status===`complete`?`bg-[var(--success)]`:i.status===`stalled`||i.status===`budget_limited`?`bg-[var(--warning)]`:i.status===`paused`?`bg-[var(--text-muted)]`:`bg-[var(--accent-strong)] [animation:agent-status-pulse_1.6s_ease-in-out_infinite]`}`}),(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-[12px] font-[650]`,children:i.status===`complete`?h(`chat:agentRunActivity.teamComplete`):i.status===`budget_limited`?h(`chat:agentRunActivity.teamBudgetLimited`):i.status===`paused`?h(`chat:agentRunActivity.teamPaused`):i.status===`stalled`?h(`chat:agentRunActivity.teamStalled`):h(`chat:agentRunActivity.teamActive`)}),T>0&&(0,Z.jsxs)(`small`,{className:`shrink-0 text-[11px] font-[550] text-[var(--text-muted)]`,children:[w,`/`,T,` · `,k,`%`]})]}),(0,Z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-[8px]`,children:[D>0&&(0,Z.jsx)(`small`,{className:`whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamBudget`,{used:E,budget:D})}),(0,Z.jsx)(Ie,{size:14,className:`text-[var(--text-muted)] [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,"aria-hidden":`true`})]})]}),T>0&&(0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`team-progress-track mx-[8px] mb-[3px] h-[3px] overflow-hidden rounded-full bg-[var(--stroke-soft)]`,children:(0,Z.jsx)(`div`,{className:`team-progress-fill h-full rounded-full bg-[var(--accent-strong)] [transition:width_var(--d2)_var(--ease-out)]`,style:{width:`${k}%`}})}),(0,Z.jsxs)(`div`,{className:`grid max-h-[min(42vh,360px)] grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-[6px] overflow-y-auto overscroll-contain [border-top:1px_solid_var(--stroke-soft)] [padding:7px_8px]`,children:[C.map(e=>{let t=typeof e.role==`string`?e.role.trim():``,n=za(e.status,h);return(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-[4px] rounded-[var(--r-xs)] bg-[var(--surface-muted)] [border:1px_solid_var(--stroke-soft)] [padding:7px] text-[11px]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-[6px]`,children:[(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`team-task-dot h-[6px] w-[6px] shrink-0 rounded-full ${e.status===`running`?`bg-[var(--accent-strong)] [animation:agent-status-pulse_1.6s_ease-in-out_infinite]`:e.status===`completed`?`bg-[var(--success)]`:e.status===`failed`||e.status===`interrupted`?`bg-[var(--danger)]`:e.status===`blocked`?`bg-[var(--warning)]`:`bg-[var(--stroke-default)]`}`}),(0,Z.jsxs)(`span`,{className:`grid min-w-0 gap-[1px]`,children:[(0,Z.jsx)(`strong`,{className:`break-words font-[620]`,children:t?h(`chat:agentRunActivity.teamTaskStatus`,{name:e.taskName,role:t,status:n}):h(`chat:agentRunActivity.teamTaskStatusWithoutRole`,{name:e.taskName,status:n})}),(0,Z.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:n})]})]}),e.error&&(0,Z.jsx)(`small`,{className:`break-words text-[var(--danger)]`,children:e.error}),e.output&&(0,Z.jsx)(`small`,{className:`break-words text-[var(--text-muted)]`,children:e.output})]},e.id||e.taskName)}),(i.blockers?.length??0)>0&&(0,Z.jsx)(`small`,{className:`text-[var(--warning)]`,children:h(`chat:agentRunActivity.teamBlocked`,{count:i.blockers?.length??0})}),(i.conflicts?.length??0)>0&&(0,Z.jsx)(`small`,{className:`text-[var(--danger)]`,children:h(`chat:agentRunActivity.teamConflicts`,{count:i.conflicts?.length??0})}),i.scriptPath&&(0,Z.jsx)(`small`,{className:`break-all text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamScript`,{path:i.scriptPath})}),O.length>0&&(0,Z.jsxs)(`div`,{className:`grid gap-[3px] [border-top:1px_solid_var(--stroke-soft)] [padding-top:5px]`,children:[(0,Z.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamCommunicationCount`,{count:O.length})}),O.slice(-6).map(e=>(0,Z.jsxs)(`div`,{className:`grid min-w-0 gap-[1px] rounded-[var(--r-xs)] bg-[var(--surface-muted)] [border-left:2px_solid_var(--accent-border)] [padding:4px_6px]`,children:[(0,Z.jsxs)(`strong`,{className:`break-all text-[11px] font-[620]`,children:[e.fromTaskName||e.fromAgentId||`lead`,` ->`,` `,e.toTaskName||e.toAgentId]}),(0,Z.jsx)(`small`,{className:`break-words text-[var(--text-secondary)]`,children:e.message})]},e.id))]}),i.summary?.text&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`small`,{className:`text-[var(--text-muted)]`,children:h(`chat:agentRunActivity.teamSummary`)}),i.summary.text&&(0,Z.jsx)(`p`,{className:`m-0 line-clamp-4 text-[11px] leading-[1.45] text-[var(--text-secondary)]`,children:i.summary.text})]})]})]},String(i.id||i.scriptPath||`team`)),e&&b.length>0&&(0,Z.jsx)(`div`,{ref:y,className:`agent-run-feed focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:2px] [.agent-run-history_&.completed]:mt-[3px] flex max-h-[184px] flex-col gap-[4px] overflow-y-auto [overscroll-behavior:contain] [margin:5px_0_2px] [padding:2px_4px_2px_0] [scrollbar-gutter:stable] live`,"aria-label":h(`chat:agentRunActivity.toolActivityAriaLabel`),children:(0,Z.jsx)(X.Suspense,{fallback:I,children:(0,Z.jsx)(La,{children:I})})}),j>0&&(0,Z.jsxs)(`details`,{className:`agent-run-history [&_>_summary]:grid [&_>_summary]:min-h-[38px] [&_>_summary]:grid-cols-[28px_minmax(0,1fr)_auto] [&_>_summary]:items-center [&_>_summary]:gap-[9px] [&_>_summary]:[list-style:none] [&_>_summary]:rounded-[var(--r-sm)] [&_>_summary]:p-[5px_8px] [&_>_summary]:text-[var(--text-muted)] [&_>_summary]:cursor-pointer [&_>_summary::-webkit-details-marker]:hidden [&_>_summary:hover]:bg-[var(--surface-hover)] [&_>_summary:hover]:text-[var(--text)] [&_>_summary:focus-visible]:[outline:2px_solid_var(--accent-border)] [&_>_summary:focus-visible]:[outline-offset:-2px] w-full`,children:[(0,Z.jsxs)(`summary`,{children:[(0,Z.jsx)(`span`,{className:Ia,children:(0,Z.jsx)(Ie,{className:`agent-run-disclosure [details[open]_>_summary_&]:[transform:rotate(90deg)] [transition:transform_var(--d1)_var(--ease-out)]`,size:14})}),(0,Z.jsx)(`span`,{className:`agent-run-copy [&_strong]:overflow-hidden [&_strong]:text-[13px] [&_strong]:font-[620] [&_strong]:leading-[1.4] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[12px] [&_small]:leading-[1.45] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [.agent-run-activity.compact_&_strong]:text-[12px] [.agent-run-activity.compact_&_small]:text-[11px] flex min-w-0 flex-col gap-[3px] [padding-top:1px]`,children:(0,Z.jsx)(`strong`,{children:h(`chat:agentRunActivity.countCompletedOperations`,{count:j})})}),!M&&(0,Z.jsx)(Va,{startedAt:d,finishedAt:p,streaming:e,language:g})]}),(0,Z.jsx)(`div`,{className:`agent-run-feed focus-visible:[outline:2px_solid_var(--accent-border)] focus-visible:[outline-offset:2px] [.agent-run-history_&.completed]:mt-[3px] flex max-h-[184px] flex-col gap-[4px] overflow-y-auto [overscroll-behavior:contain] [margin:5px_0_2px] [padding:2px_4px_2px_0] [scrollbar-gutter:stable] completed`,"aria-label":h(`chat:agentRunActivity.toolActivityAriaLabel`),tabIndex:b.length>3?0:void 0,children:(0,Z.jsx)(X.Suspense,{fallback:F,children:F})})]})]})}function Xa(e,t){return e.streaming===t.streaming&&e.text===t.text&&e.thinkingText===t.thinkingText&&e.currentActivity===t.currentActivity&&e.team===t.team&&e.activityFeed===t.activityFeed&&e.compaction===t.compaction&&e.error===t.error&&e.stopped===t.stopped&&e.notice===t.notice&&e.startedAt===t.startedAt&&e.lastActivityAt===t.lastActivityAt&&e.finishedAt===t.finishedAt&&e.compact===t.compact&&e.tools===t.tools}var Za=(0,X.memo)(Ya,Xa);function $(e){return e instanceof Error?e.message:String(e)}function Qa(e){return/(?:当前会话已经结束运行|session .*?(?:ended|finished|no longer running))/i.test($(e))}function $a({className:e,from:t,...n}){return(0,Z.jsx)(`div`,{"data-ai-element":`message`,"data-role":t,className:ce(`group flex w-full max-w-[95%] flex-col gap-2`,t===`user`?`is-user ml-auto justify-end`:`is-assistant`,e),...n})}function eo({images:e,index:t,onClose:n,onNavigate:r}){let{t:i}=x(),a=(0,X.useRef)(null),o=e[t],s=t>0,c=t<e.length-1,l=(0,X.useCallback)(t=>{t>=0&&t<e.length&&r(t)},[e.length,r]);return(0,X.useEffect)(()=>{let e=document.body.style.overflow,r=e=>{e.key===`Escape`?n():e.key===`ArrowLeft`?(e.preventDefault(),l(t-1)):e.key===`ArrowRight`&&(e.preventDefault(),l(t+1))};return document.body.style.overflow=`hidden`,window.addEventListener(`keydown`,r),()=>{document.body.style.overflow=e,window.removeEventListener(`keydown`,r)}},[t,l,n]),o?(0,Z.jsxs)(`div`,{className:`image-lightbox [&_img]:h-full [&_img]:min-h-0 [&_img]:w-full [&_img]:object-contain fixed z-[100] inset-0 grid grid-rows-[auto_minmax(0,1fr)] gap-[12px] bg-[var(--lightbox-bg)] [padding:18px_72px_24px_24px] [backdrop-filter:blur(8px)] max-sm:[padding:12px_56px_16px_12px]`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`chat:chatMessage.fullScreenImagePreview`),children:[(0,Z.jsxs)(`div`,{className:`image-lightbox-toolbar flex min-w-0 items-center justify-between gap-[16px] text-[var(--on-ink)]`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-[10px]`,children:[(0,Z.jsx)(`span`,{className:`overflow-hidden text-[13px] font-[700] text-ellipsis whitespace-nowrap`,title:o.attachment.name,children:o.attachment.name||i(`chat:chatMessage.generatedImage`)}),e.length>1&&(0,Z.jsxs)(`span`,{className:`flex-none text-[12px] font-[600] text-[var(--on-ink)]/70`,children:[t+1,` / `,e.length]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-none items-center gap-[8px]`,children:[(0,Z.jsx)(m,{asChild:!0,size:`lg`,className:`border border-[var(--lightbox-action-border)] bg-[var(--lightbox-action-bg)] text-[var(--lightbox-action-text)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)]`,children:(0,Z.jsxs)(`a`,{href:o.attachment.downloadUrl||o.source,download:o.attachment.name||`generated-image`,"aria-label":i(`chat:chatMessage.downloadOriginal`),title:i(`chat:chatMessage.downloadOriginal`),children:[(0,Z.jsx)(Ge,{size:14}),(0,Z.jsx)(`span`,{className:`max-sm:hidden`,children:i(`chat:chatMessage.downloadOriginal`)})]})}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`size-11 bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)]`,"aria-label":i(`chat:chatMessage.closePreview`),title:i(`chat:chatMessage.closePreview`),onClick:n,children:(0,Z.jsx)(Me,{size:20})})]})]}),(0,Z.jsxs)(`div`,{className:`relative flex min-h-0 items-center justify-center [touch-action:pan-y]`,onTouchStart:e=>{a.current=e.changedTouches[0]?.clientX??null},onTouchEnd:e=>{let n=a.current;a.current=null;let r=e.changedTouches[0]?.clientX;n===null||r===void 0||Math.abs(r-n)<48||l(t+(r<n?1:-1))},onTouchCancel:()=>{a.current=null},children:[e.length>1&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`absolute left-0 z-10 size-11 rounded-full bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)] disabled:opacity-30`,"aria-label":i(`chat:chatMessage.previousImage`),title:i(`chat:chatMessage.previousImage`),disabled:!s,onClick:()=>l(t-1),children:(0,Z.jsx)(Nn,{size:22})}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`absolute right-0 z-10 size-11 rounded-full bg-[var(--lightbox-control-bg)] text-[var(--on-ink)] shadow-[0_8px_24px_var(--lightbox-action-shadow)] hover:bg-[var(--lightbox-control-bg)] hover:text-[var(--on-ink)] disabled:opacity-30`,"aria-label":i(`chat:chatMessage.nextImage`),title:i(`chat:chatMessage.nextImage`),disabled:!c,onClick:()=>l(t+1),children:(0,Z.jsx)(Ie,{size:22})})]}),(0,Z.jsx)(`img`,{alt:o.attachment.name||i(`chat:chatMessage.generatedImage`),decoding:`async`,src:o.source})]})]}):null}function to({attachments:e,compact:t=!1}){let{t:n}=x(),[r,i]=(0,X.useState)(null),a=e.flatMap((e,t)=>{let n=e.url||(e.data?`data:${e.mimeType};base64,${e.data}`:``);return e.kind===`image`&&n?[{attachment:e,source:n,attachmentIndex:t}]:[]});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`message-attachments flex flex-wrap gap-[6px] [margin-top:6px] ${t?`compact`:``}`,children:e.map((e,t)=>{let r=e.id||t,o=e.url||(e.data?`data:${e.mimeType};base64,${e.data}`:``);return e.kind===`image`&&o?(0,Z.jsxs)(`button`,{type:`button`,className:`generated-media [.message-attachments_&]:flex [.message-attachments_&]:w-[min(360px,100%)] [.message-attachments_&]:flex-col [.message-attachments_&]:gap-[5px] [.message-attachments_&]:text-[var(--text-muted)] [.message-attachments_&]:no-underline [.message-attachments_button&]:border-0 [.message-attachments_button&]:bg-transparent [.message-attachments_button&]:p-0 [.message-attachments_button&]:text-left [.message-attachments_button&]:[cursor:zoom-in] [.message-attachments_&_img]:w-full [.message-attachments_&_img]:max-h-[320px] [.message-attachments_&_img]:[border:1px_solid_var(--stroke)] [.message-attachments_&_img]:rounded-[var(--r-sm)] [.message-attachments_&_img]:object-contain [.message-attachments_&_img]:bg-[var(--media-bg)] [.message-attachments_&_video]:w-full [.message-attachments_&_video]:max-h-[320px] [.message-attachments_&_video]:[border:1px_solid_var(--stroke)] [.message-attachments_&_video]:rounded-[var(--r-sm)] [.message-attachments_&_video]:object-contain [.message-attachments_&_video]:bg-[var(--media-bg)] [.message-attachments_&_small]:overflow-hidden [.message-attachments_&_small]:text-[13px] [.message-attachments_&_small]:text-ellipsis [.message-attachments_&_small]:whitespace-nowrap [.message-attachments.compact_&]:w-[min(190px,100%)] [.message-attachments.compact_&_img]:max-h-[130px] [.message-attachments.compact_&_video]:max-h-[130px]`,onClick:()=>{let e=a.findIndex(e=>e.attachmentIndex===t);e>=0&&i({images:a,index:e})},title:n(`chat:chatMessage.openFullScreenPreview`),children:[(0,Z.jsx)(`img`,{alt:e.name||n(`chat:chatMessage.imageAttachment`),decoding:`async`,loading:`lazy`,src:o}),(0,Z.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedImage`)})]},r):e.kind===`video`&&o?(0,Z.jsxs)(`div`,{className:`generated-media [.message-attachments_&]:flex [.message-attachments_&]:w-[min(360px,100%)] [.message-attachments_&]:flex-col [.message-attachments_&]:gap-[5px] [.message-attachments_&]:text-[var(--text-muted)] [.message-attachments_&]:no-underline [.message-attachments_button&]:border-0 [.message-attachments_button&]:bg-transparent [.message-attachments_button&]:p-0 [.message-attachments_button&]:text-left [.message-attachments_button&]:[cursor:zoom-in] [.message-attachments_&_img]:w-full [.message-attachments_&_img]:max-h-[320px] [.message-attachments_&_img]:[border:1px_solid_var(--stroke)] [.message-attachments_&_img]:rounded-[var(--r-sm)] [.message-attachments_&_img]:object-contain [.message-attachments_&_img]:bg-[var(--media-bg)] [.message-attachments_&_video]:w-full [.message-attachments_&_video]:max-h-[320px] [.message-attachments_&_video]:[border:1px_solid_var(--stroke)] [.message-attachments_&_video]:rounded-[var(--r-sm)] [.message-attachments_&_video]:object-contain [.message-attachments_&_video]:bg-[var(--media-bg)] [.message-attachments_&_small]:overflow-hidden [.message-attachments_&_small]:text-[13px] [.message-attachments_&_small]:text-ellipsis [.message-attachments_&_small]:whitespace-nowrap [.message-attachments.compact_&]:w-[min(190px,100%)] [.message-attachments.compact_&_img]:max-h-[130px] [.message-attachments.compact_&_video]:max-h-[130px] video`,children:[(0,Z.jsx)(`video`,{controls:!0,preload:`metadata`,src:o}),(0,Z.jsx)(`small`,{children:e.name||n(`chat:chatMessage.generatedVideo`)})]},r):(0,Z.jsxs)(`a`,{className:`message-file-attachment [.message-attachments_&]:inline-flex [.message-attachments_&]:items-center [.message-attachments_&]:gap-[5px] [.message-attachments_&]:[border:1px_solid_var(--stroke)] [.message-attachments_&]:rounded-[var(--r-xs)] [.message-attachments_&]:bg-[var(--solid)] [.message-attachments_&]:p-[5px_7px] [.message-attachments_&]:text-[var(--text-tertiary)] [.message-attachments_&]:text-[13px] [.message-attachments_&]:no-underline`,href:e.downloadUrl||void 0,children:[(0,Z.jsx)(he,{size:12}),e.name||n(`chat:chatMessage.fileAttachment`)]},r)})}),r&&(0,li.createPortal)((0,Z.jsx)(eo,{images:r.images,index:r.index,onClose:()=>i(null),onNavigate:e=>i(t=>t&&{...t,index:e})}),document.body)]})}function no({sessionId:e,entryId:t}){let{t:n}=x(),[r,i]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[h,g]=(0,X.useState)(``);(0,X.useEffect)(()=>{if(!r)return;let n=!0;return d(!0),g(``),a.getSessionTree(e).then(e=>{if(!n)return;let r=e.nodes.find(e=>e.id===t)?.label||``;s(r),l(r)}).catch(e=>n&&g($(e))).finally(()=>n&&d(!1)),()=>{n=!1}},[t,r,e]);let _=async()=>{if(!(f||u)){p(!0),g(``);try{let n=(await a.setSessionTreeLabel(e,t,o)).nodes.find(e=>e.id===t)?.label||``;s(n),l(n),i(!1)}catch(e){g($(e))}finally{p(!1)}}},v=async()=>{if(!(f||u)){p(!0),g(``);try{let n=(await a.setSessionTreeLabel(e,t,``)).nodes.find(e=>e.id===t)?.label||``;s(n),l(n),i(!1)}catch(e){g($(e))}finally{p(!1)}}};return(0,Z.jsxs)(vi,{open:r,onOpenChange:i,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(yi,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,className:c?`bg-surface-hover text-brand`:void 0,"aria-label":n(`chat:chatMessage.labelThisTurn`),"data-pisper-label-entry":t,children:(0,Z.jsx)(K,{size:14})})})}),(0,Z.jsx)(U,{side:`top`,sideOffset:6,children:n(`chat:chatMessage.labelThisTurn`)})]}),(0,Z.jsx)(bi,{className:`message-label-popover [&_form]:grid [&_form]:gap-[10px] [&_[data-slot='popover-title']]:text-[12px]`,align:`end`,sideOffset:6,children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),_()},children:[(0,Z.jsx)(xi,{children:n(`chat:sessionTree.nodeLabel`)}),(0,Z.jsx)(Ne,{autoFocus:!0,value:o,maxLength:80,disabled:u||f,placeholder:n(`chat:sessionTree.labelPlaceholder`),onChange:e=>s(e.target.value)}),h&&(0,Z.jsx)(`small`,{className:`danger-text`,children:h}),(0,Z.jsxs)(`div`,{className:`message-label-actions flex items-center justify-between gap-[8px]`,children:[(0,Z.jsx)(m,{type:`button`,size:`icon-sm`,variant:`ghost`,title:n(`chat:sessionTree.removeLabel`),"aria-label":n(`chat:sessionTree.removeLabel`),disabled:u||f,onClick:()=>void v(),children:(0,Z.jsx)(Ae,{})}),(0,Z.jsxs)(m,{className:`message-label-save [.message-label-actions_&]:min-w-[104px] [.message-label-actions_&]:text-[var(--primary-foreground)]`,type:`submit`,disabled:u||f,children:[f?(0,Z.jsx)(ge,{className:`animate-spin`}):(0,Z.jsx)(fe,{}),n(f?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]})]})]})})]})}function ro(e,t){return e.sessionId===t.sessionId&&e.message===t.message&&e.agentState===t.agentState&&e.showRunActivity===t.showRunActivity&&e.runProps===t.runProps&&e.sessionStreaming===t.sessionStreaming&&e.onBranchFromHere===t.onBranchFromHere&&e.onCreateChildSession===t.onCreateChildSession}var io=(0,X.memo)(function({sessionId:e,message:t,agentState:n,showRunActivity:r,runProps:i,sessionStreaming:a,onBranchFromHere:o,onCreateChildSession:s}){let{t:c}=x(),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=!!t.streaming,h=t.text||(r?``:String(t.error||``));return(0,Z.jsxs)($a,{from:t.role===`agent`?`assistant`:`user`,className:`message [&.user]:items-end [&.user_>_span]:hidden [&.agent]:grid [&.agent]:grid-cols-[24px_minmax(0,1fr)] [&.agent]:[align-items:start] [&.agent]:gap-x-[12px] [&_>_span]:flex [&_>_span]:items-center [&_>_span]:gap-[5px] [&_>_span]:p-0 [&_>_span]:text-[var(--text-muted)] [&_>_span]:text-[12px] [&_>_span]:font-[600] [&.agent_>_span]:[grid-column:1] [&.agent_>_span]:[grid-row:1] [&.agent_>_span]:justify-center [&.agent_>_span]:pt-[4px] @max-[470px]:[&.agent]:grid-cols-[22px_minmax(0,1fr)] @max-[470px]:[&.agent]:gap-x-[9px] flex w-[min(900px,100%)] flex-col items-start gap-[6px] [margin:0_auto_30px] ${t.role} ${t.error?`has-error`:``}`,"data-pisper-message-id":t.id,"data-pisper-role":t.role,"data-pisper-streaming":p||void 0,"data-pisper-error":t.error?`true`:void 0,children:[(0,Z.jsx)(`span`,{children:t.role===`agent`?(0,Z.jsx)(`span`,{className:`agent-message-mark [&[data-state='thinking']]:opacity-100 [&[data-state='thinking']]:[animation:agent-message-pulse_1.8s_ease-in-out_infinite] [&[data-state='waiting']]:opacity-[.9] grid w-[22px] h-[22px] place-items-center rounded-[var(--r-xs)] text-[var(--text-muted)] opacity-[.72] [transition:opacity_var(--d1)_var(--ease-out),_transform_var(--d1)_var(--ease-out)]`,"data-state":n,"aria-label":`Pisper`,children:(0,Z.jsx)(ut,{size:20})}):`You`}),(0,Z.jsxs)(`div`,{className:`message-content [.message.agent_&]:w-full [.message.agent_&]:[grid-column:2] [.message.agent_&]:[grid-row:1] [.message.user_&]:w-[fit-content] [.message.user_&]:max-w-[76%] @max-[700px]:[.message.user_&]:max-w-[86%] @max-[470px]:[.message.user_&]:max-w-[92%] max-[650px]:[.message.user_&]:max-w-[86%] relative min-w-0`,children:[r&&i&&(0,Z.jsx)(Za,{...i}),h&&(0,Z.jsx)(bt,{streaming:p,children:h}),t.attachments&&t.attachments.length>0&&(0,Z.jsx)(to,{attachments:t.attachments})]}),t.role===`agent`&&t.turnBoundaryEntryId&&!p&&(0,Z.jsxs)(`div`,{className:`chat-history-actions [&_button]:grid [&_button]:w-[30px] [&_button]:h-[30px] [&_button]:min-h-[30px] [&_button]:place-items-center [&_button]:border-0 [&_button]:rounded-[var(--r-xs)] [&_button]:bg-transparent [&_button]:text-[var(--text-muted)] [&_button:hover]:bg-[var(--solid)] [&_button:hover]:text-[var(--text)] [&_button.active]:bg-[var(--star-soft)] [&_button.active]:text-[var(--star-strong)] [&_button.danger:hover]:bg-[var(--danger-soft)] [&_button.danger:hover]:text-[var(--danger)] max-[650px]:pr-[4px] flex items-center gap-[2px] [padding-right:8px] message-actions`,style:{gridColumn:2,gridRow:2,paddingRight:0},children:[(0,Z.jsx)(no,{sessionId:e,entryId:t.turnBoundaryEntryId}),(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.deriveFromHere`),"data-pisper-derive-entry":t.turnBoundaryEntryId,disabled:l||d||a,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){u(!0);try{await o(e)}finally{u(!1)}}},children:l?(0,Z.jsx)(ge,{className:`animate-spin`,size:14}):(0,Z.jsx)(Vn,{size:14})})}),(0,Z.jsx)(U,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.deriveFromHere`)})]}),(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":c(`chat:chatMessage.createChildChat`),"data-pisper-child-entry":t.turnBoundaryEntryId,disabled:l||d,onClick:async()=>{let e=t.turnBoundaryEntryId;if(e){f(!0);try{await s(e)}finally{f(!1)}}},children:d?(0,Z.jsx)(ge,{className:`animate-spin`,size:14}):(0,Z.jsx)(qn,{size:14})})}),(0,Z.jsx)(U,{side:`top`,sideOffset:6,children:c(`chat:chatMessage.createChildChat`)})]})]})]})},ro);function ao(e,t){return e.message===t.message}(0,X.memo)(function({message:e}){return(0,Z.jsxs)($a,{from:e.role===`agent`?`assistant`:`user`,className:`[&_>_span]:pt-[5px] [&_>_span]:text-[var(--text-muted)] [&_>_span]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_>_span]:text-[13px] [&_>_span]:font-[600] [&_>_span]:[text-transform:uppercase] [&.agent_>_span::before]:[content:'✦'] [&.agent_>_span::before]:mr-[4px] [&.agent_>_span::before]:text-[var(--star)] [&_.markdown-body]:rounded-[var(--r-xs)] [&_.markdown-body]:bg-[var(--surface-subtle)] [&_.markdown-body]:[padding:6px_8px] [&_.markdown-body]:text-[13px] [&_.markdown-body]:leading-[1.45] [&_.markdown-body]:[overflow-wrap:anywhere] [&.agent_.markdown-body]:bg-[var(--accent-soft)] [&_.markdown-body_pre]:max-h-[130px] [&_.markdown-body_pre]:[padding:7px] grid grid-cols-[34px_minmax(0,1fr)] gap-[6px] [margin-bottom:6px] [align-items:start] ${e.role}`,"data-pisper-message-id":e.id,"data-pisper-role":e.role,"data-pisper-streaming":e.streaming||void 0,children:[(0,Z.jsx)(`span`,{children:e.role===`agent`?`Pisper`:`You`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(e.text||!e.streaming)&&(0,Z.jsx)(bt,{streaming:e.streaming,children:e.text}),e.attachments&&e.attachments.length>0&&(0,Z.jsx)(to,{attachments:e.attachments,compact:!0})]})]})},ao);function oo(e,t){let n=t?.borderBoxSize?.[0];return Math.ceil(n?.blockSize??e.getBoundingClientRect().height)}function so(e,t,n){let[r,i]=(0,X.useState)(0);return(0,X.useLayoutEffect)(()=>{let r=n.current;if(!e||!r)return;let a=()=>{let t=Math.max(0,r.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop);i(e=>Math.abs(e-t)<1?e:t)};a();let o=typeof ResizeObserver>`u`?null:new ResizeObserver(a);return o?.observe(e),t.current&&o?.observe(t.current),window.addEventListener(`resize`,a),()=>{o?.disconnect(),window.removeEventListener(`resize`,a)}},[n,t,e]),r}var co=(0,X.memo)(function({sessionId:e,messages:t,streaming:n,latestRunProps:r,scrollElement:i,prefixRef:a,targetEntryId:o,onContentSizeChange:s,onTargetScroll:c,onTargetLocated:l,onBranchFromHere:u,onCreateChildSession:d}){let f=(0,X.useRef)(null),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(t);h.current=t;let g=so(i,a,f),_=(0,X.useCallback)(e=>h.current[e]?.id??`transcript-message-${e}`,[]),v=(0,X.useCallback)(()=>Ji(i?.clientWidth),[i]),y=ya({count:t.length,getScrollElement:()=>i,getItemKey:_,estimateSize:v,measureElement:oo,overscan:6,scrollMargin:g,useAnimationFrameWithResizeObserver:!0}),b=y.getVirtualItems(),x=y.getTotalSize();return(0,X.useLayoutEffect)(()=>{s()},[s,x]),(0,X.useEffect)(()=>{if(!o)return;let e=t.findIndex(e=>e.turnBoundaryEntryId===o);if(e<0)return;c(),y.scrollToIndex(e,{align:`center`}),m(o);let n=window.requestAnimationFrame(()=>{y.scrollToIndex(e,{align:`center`}),l(o)});return()=>window.cancelAnimationFrame(n)},[t,l,c,o,y]),(0,X.useEffect)(()=>{if(!p)return;let e=window.setTimeout(()=>m(``),2200);return()=>window.clearTimeout(e)},[p]),(0,Z.jsx)(`div`,{className:`relative w-full`,"data-pisper-transcript-size":t.length,"data-pisper-rendered-count":b.length,ref:f,style:{height:`${x}px`},children:b.map(i=>{let a=t[i.index];if(!a)return null;let o=a.role===`agent`&&i.index===t.length-1,s=a.streaming||o&&n?`thinking`:o&&!a.error?`waiting`:`idle`,c=wr(a,o,r);return(0,Z.jsx)(`div`,{className:`virtual-transcript-item absolute left-0 [display:flow-root] w-full rounded-[var(--r-sm)] ${a.turnBoundaryEntryId===p?`targeted [.virtual-transcript-item&]:bg-[var(--star-soft)] [.virtual-transcript-item&]:shadow-[inset_3px_0_0_var(--star-strong)]`:``}`,"data-index":i.index,"data-pisper-target-entry":a.turnBoundaryEntryId===p?a.turnBoundaryEntryId:void 0,"data-pisper-virtual-item":a.id,ref:y.measureElement,style:{top:`${i.start-g}px`},children:(0,Z.jsx)(io,{sessionId:e,message:a,agentState:s,showRunActivity:!!c,runProps:c,sessionStreaming:n,onBranchFromHere:u,onCreateChildSession:d})},i.key)})})}),lo=(0,X.lazy)(()=>i(()=>import(`./WelcomeEffects-DYsg0gqD.js`),__vite__mapDeps([8,1,2,3,4,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,6])));function uo({children:e,title:t}){return(0,Z.jsxs)(`div`,{className:`agent-welcome-content grid w-full max-w-[680px] place-items-center [padding:12px_20px_30px]`,children:[(0,Z.jsx)(`div`,{className:`[animation:transcript-stage-enter_.5s_var(--ease-out)_both]`,children:(0,Z.jsx)(Tt,{})}),(0,Z.jsx)(`h2`,{className:`text-[var(--accent-strong)]`,children:t}),e]})}function fo({label:e}){return(0,Z.jsxs)(`div`,{className:`session-history-loading grid min-h-[100%] place-content-center justify-items-center gap-[24px] text-[var(--text-muted)] [animation:transcript-stage-enter_.18s_var(--ease-out)_both]`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-[10px]`,children:[(0,Z.jsx)(`span`,{className:`grid h-[34px] w-[34px] place-items-center rounded-[11px] border border-[color-mix(in_srgb,#A855F7_24%,var(--stroke))] bg-[var(--solid)] shadow-[var(--sh-1)]`,children:(0,Z.jsx)(ut,{size:19})}),(0,Z.jsx)(`strong`,{className:`text-[13px] font-[650] text-[var(--text-soft)]`,children:e}),(0,Z.jsxs)(`span`,{className:`flex items-end gap-[3px] pb-[3px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_infinite]`}),(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.16s_infinite]`}),(0,Z.jsx)(`i`,{className:`block h-[4px] w-[4px] rounded-full bg-[#A855F7] [animation:agent-thinking-dot_1.2s_ease-in-out_.32s_infinite]`})]})]}),(0,Z.jsxs)(`div`,{className:`grid w-[min(560px,78vw)] gap-[12px]`,"aria-hidden":`true`,children:[(0,Z.jsx)(`div`,{className:`h-[52px] w-[68%] rounded-[16px_16px_16px_5px] border border-[var(--stroke-soft)] bg-[var(--surface-muted)] [animation:agent-message-pulse_1.9s_ease-in-out_infinite]`}),(0,Z.jsx)(`div`,{className:`h-[40px] w-[46%] justify-self-end rounded-[16px_16px_5px_16px] bg-[var(--user-bubble-bg)] opacity-[.14] [animation:agent-message-pulse_1.9s_ease-in-out_.25s_infinite]`}),(0,Z.jsx)(`div`,{className:`h-[46px] w-[58%] rounded-[16px_16px_16px_5px] border border-[var(--stroke-soft)] bg-[var(--surface-muted)] [animation:agent-message-pulse_1.9s_ease-in-out_.5s_infinite]`})]})]})}function po(e,t){return[{icon:me,label:e(`chat:focusSession.explainCode`),prompt:e(`chat:focusSession.explainHowThisCodeWorks`)},{icon:z,label:e(`chat:focusSession.writeTests`),prompt:e(`chat:focusSession.writeUnitTestsForTheFollowingCode`)},{icon:R,label:e(`chat:focusSession.refactor`),prompt:e(`chat:focusSession.refactorThisCodeAndExplainTheImprovements`)},{icon:Mn,label:e(`chat:focusSession.findABug`),prompt:e(`chat:focusSession.helpMeLocateAndFixThisBug`)},{icon:Rn,label:e(`chat:focusSession.summarize`),prompt:e(`chat:focusSession.summarizeContentAndExtractKeyPoints`)},...t?[{icon:Wn,label:e(`chat:focusSession.makeAPlan`),prompt:e(`chat:focusSession.makeAClearActionablePlanForThisGoal`)}]:[],{icon:Un,label:e(`chat:focusSession.organizeInformation`),prompt:e(`chat:focusSession.organizeThisInformationIntoAClearStructure`)},{icon:Qn,label:e(`chat:focusSession.findIssues`),prompt:e(`chat:focusSession.reviewThisContentAndSuggestImprovements`)}]}function mo({sessionId:e,messages:t,transcriptLoadState:n=`ready`,messageStart:r,hasOlder:i,loadingOlder:a,olderError:o,currentActivity:s,team:c,activityFeed:l,tools:u,thinkingText:d,compaction:f,streaming:p,runStartedAt:h,lastActivityAt:g,runFinishedAt:_,runStopped:v,runNotice:y,error:b,scrollRequest:S,cwd:C,lineage:w,switchingCwd:T,onLoadOlder:E,onBranchFromHere:D,onCreateChildSession:O,onPromptSelect:k,onWorkspace:A}){let{t:j,language:M}=x(),N=Be(e=>e.capabilities),P=J(N,`plans`),F=(0,X.useRef)(null),I=(0,X.useRef)(null),[L,R]=(0,X.useState)(()=>Xe(e)),z=t[t.length-1],ee=Math.floor((z?.text?.length||0)/64),te=Bi(l),B=Math.floor(String(d||``).length/128),{scrollRef:V,scrollElement:ne,setScrollRef:re,hasUnread:ie,scrollToBottom:ae,maintainBottom:oe,pauseFollowing:se}=Ii(`${e}:${z?.id||``}:${ee}:${B}:${z?.attachments?.length||0}:${te}:${f?.status||``}:${f?.finishedAt||``}:${b||``}:${p?`1`:`0`}`,{resetKey:`${e}:${n}`}),H=(0,X.useMemo)(()=>({streaming:p,text:z?.role===`agent`?z.text:``,currentActivity:s,team:c,activityFeed:l,tools:u,thinkingText:d,compaction:f,error:b||(z?.role===`agent`?z.error:``),stopped:v,notice:y,startedAt:h,lastActivityAt:g,finishedAt:_}),[p,z,s,c,l,u,d,f,b,v,y,h,g,_]),U=(0,X.useCallback)(async()=>{let e=V.current;!e||!i||a||F.current||(se(),F.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop},await E?.()||(F.current=null))},[i,a,E,se,V]),W=(0,X.useCallback)(e=>{e.currentTarget.scrollTop<=96&&U()},[U]);(0,X.useLayoutEffect)(()=>{let e=F.current,t=V.current;!e||!t||(t.scrollTop=Yi(e,t.scrollHeight),F.current=null)},[r,V]),(0,X.useEffect)(()=>{R(Xe(e));let t=t=>{let n=t.detail;n?.sessionId===e&&n.targetEntryId&&R(n.targetEntryId)};return window.addEventListener(ze,t),()=>window.removeEventListener(ze,t)},[e]),(0,X.useEffect)(()=>{if(!(!L||r==null)&&!t.some(e=>e.turnBoundaryEntryId===L)&&!a){if(i){U();return}Ve(e,L),R(``)}},[i,U,a,r,t,e,L]),(0,X.useEffect)(()=>{S&&ae(`smooth`)},[S,ae]);let ce=(0,X.useMemo)(()=>{let e=new Date().getHours();return[j(e>=23||e<5?`chat:focusSession.timeLateNight`:e<11?`chat:focusSession.timeMorning`:e<14?`chat:focusSession.timeLunch`:e<18?`chat:focusSession.timeAfternoon`:`chat:focusSession.timeEvening`),...[...J(N,`plugins`)?[j(`chat:focusSession.feelLikeBuildingAPlugin`),j(`chat:focusSession.letAgentWriteItsOwnTool`)]:[],...J(N,`mcp`)?[j(`chat:focusSession.wireUpAnMcpServer`)]:[],...J(N,`schedules`)?[j(`chat:focusSession.scheduleTheRepetitiveWork`)]:[],...J(N,`workflows`)?[j(`chat:focusSession.turnRepeatedWorkIntoAWorkflow`)]:[],...J(N,`multiAgent`)?[j(`chat:focusSession.branchOutAndRunInParallel`)]:[],...J(N,`memory`)?[j(`chat:focusSession.letMemoryRememberYou`)]:[]].sort(()=>Math.random()-.5).slice(0,3)]},[N,j]),le=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{children:j(`chat:focusSession.readyToWorkWithTheCurrentDirectoryAndHelpCompleteTheTask`)}),(0,Z.jsxs)(`button`,{type:`button`,className:`welcome-workspace [&_>_svg]:flex-none [&_>_span]:flex-none [&_>_strong]:min-w-0 [&_>_strong]:overflow-hidden [&_>_strong]:text-[var(--text-soft)] [&_>_strong]:text-[12.5px] [&_>_strong]:text-ellipsis [&_>_small]:flex-none [&_>_small]:ml-[3px] [&_>_small]:text-[var(--accent-strong)] [&_>_small]:text-[12px] [&_>_small]:font-[700] hover:border-[var(--stroke-hover)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] [&:hover_>_strong]:text-[var(--text)] focus-visible:[outline:2px_solid_var(--brand-blue)] focus-visible:[outline-offset:1px] disabled:[cursor:wait] disabled:opacity-[.62] @max-[470px]:max-w-[100%] @max-[470px]:[&_>_span]:hidden flex max-w-[min(460px,100%)] min-h-[36px] items-center gap-[7px] overflow-hidden [margin-top:18px] border border-[var(--stroke)] rounded-[var(--r-pill)] bg-[var(--solid)] [padding:6px_14px] text-[var(--text-muted)] text-[12.5px] whitespace-nowrap shadow-[var(--sh-1)] [transition:background_var(--d1)_var(--ease-out),_color_var(--d1)_var(--ease-out),_border-color_var(--d1)_var(--ease-out)]`,"data-target-cursor":!0,title:C,"aria-label":j(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:C||Ye(C,M)}),onClick:A,disabled:T,children:[T?(0,Z.jsx)(q,{className:`animate-spin`,size:14}):(0,Z.jsx)(Le,{size:14}),(0,Z.jsx)(`span`,{children:j(`chat:focusSession.workingDirectory`)}),(0,Z.jsx)(`strong`,{children:Ye(C,M)}),(0,Z.jsx)(`small`,{children:j(`chat:focusSession.changeDirectory`)})]}),(0,Z.jsx)(`div`,{className:`welcome-chips flex max-w-[560px] flex-wrap justify-center gap-[9px] [margin-top:24px]`,children:po(j,P).map(e=>(0,Z.jsxs)(`button`,{type:`button`,"data-target-cursor":!0,onClick:()=>k(e.prompt),className:`group inline-flex min-h-[38px] items-center gap-[7px] rounded-[var(--r-pill)] border border-[var(--stroke)] bg-[var(--solid)] px-[16px] text-[13px] font-[620] text-[var(--text-soft)] shadow-[var(--sh-1)] [transition:all_var(--d1)_var(--ease-out)] hover:-translate-y-[1px] hover:border-[color-mix(in_srgb,#A855F7_45%,var(--stroke))] hover:text-[var(--text)] hover:shadow-[0_10px_24px_-16px_rgba(168,85,247,.5)]`,children:[(0,Z.jsx)(e.icon,{size:14,className:`text-[var(--text-muted)] [transition:color_var(--d1)_var(--ease-out)] group-hover:text-[#A855F7]`}),e.label]},e.label))})]});return(0,Z.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`transcript [.focus-session.has-conversation_&]:p-[30px_max(24px,calc((100%_-_900px)/2))] [.focus-session.has-conversation_&]:[scroll-padding-bottom:32px] @max-[700px]:p-[20px_14px] @max-[700px]:[.focus-session.has-conversation_&]:p-[24px_16px] @max-[470px]:[padding-inline:10px] max-[650px]:p-[20px_14px] min-h-0 h-full flex-1 overflow-auto overscroll-contain scroll-auto [overflow-anchor:none] m-0 border-0 [padding:26px_max(24px,calc((100%_-_960px)/2))] [padding-bottom:70px] [scroll-padding-bottom:70px]`,"data-pisper-transcript-state":n,"aria-busy":n===`loading`,ref:re,onScroll:W,tabIndex:0,children:[(0,Z.jsxs)(`div`,{className:`[display:flow-root] w-full`,ref:I,children:[w?.parentSessionId&&(0,Z.jsxs)(`div`,{className:`history-page-loader flex w-[min(960px,100%)] min-h-[42px] items-center justify-center gap-[7px] [margin:0_auto_18px] text-[var(--text-muted)] text-[12px] session-lineage`,"data-pisper-parent-session":w.parentSessionId,children:[(0,Z.jsx)(Vn,{size:13}),(0,Z.jsx)(`span`,{children:j(`chat:focusSession.derivedFromSession`,{name:w.sourceSessionName||j(`chat:focusSession.unknownSourceSession`)})})]}),(i||a||o)&&(0,Z.jsx)(`div`,{className:`history-page-loader flex w-[min(960px,100%)] min-h-[42px] items-center justify-center gap-[7px] [margin:0_auto_18px] text-[var(--text-muted)] text-[12px]`,children:o?(0,Z.jsxs)(m,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:U,children:[(0,Z.jsx)(q,{size:13}),j(`chat:focusSession.retryOlderMessages`)]}):a?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(q,{className:`animate-spin`,size:14}),j(`chat:focusSession.loadingOlderMessages`)]}):(0,Z.jsxs)(m,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,onClick:U,children:[(0,Z.jsx)(Dn,{className:`history-up-arrow [.history-page-loader_&]:[transform:rotate(180deg)]`,size:14}),j(`chat:focusSession.loadOlderMessages`)]})})]}),n===`loading`&&(0,Z.jsx)(fo,{label:j(`chat:focusSession.loadingConversationHistory`)}),n===`ready`&&!t.length&&(0,Z.jsx)(`div`,{className:`agent-welcome [[data-mobile-keyboard='open']_&]:pointer-events-none [[data-mobile-keyboard-transition='opening']_&]:pointer-events-none [[data-mobile-keyboard-transition='closing']_&]:pointer-events-none [&_h2]:mt-[18px] [&_h2]:text-[clamp(28px,_3vw,_38px)] [&_h2]:font-[800] [&_h2]:leading-[1.2] [&_h2]:tracking-[-.02em] [&_p]:max-w-[600px] [&_p]:mt-[14px] [&_p]:text-[15px] [&_p]:leading-[1.75] relative grid min-h-[100%] place-content-center justify-items-center overflow-hidden text-[var(--text-muted)] text-center`,children:(0,Z.jsx)(X.Suspense,{fallback:(0,Z.jsx)(uo,{title:ce[0],children:le}),children:(0,Z.jsx)(lo,{titles:ce,children:le})})}),n===`ready`&&t.length>0&&(0,Z.jsx)(`div`,{className:`[animation:transcript-reveal-enter_.22s_var(--ease-out)_both]`,children:(0,Z.jsx)(co,{sessionId:e,messages:t,streaming:p,latestRunProps:H,scrollElement:ne,prefixRef:I,targetEntryId:L,onContentSizeChange:oe,onTargetScroll:se,onTargetLocated:t=>{Ve(e,t),R(``)},onBranchFromHere:D,onCreateChildSession:O},e)}),b&&(0,Z.jsxs)(`div`,{className:`flex w-[min(960px,100%)] items-center gap-[7px] [margin:8px_auto] rounded-[var(--r-sm)] bg-[var(--danger-soft)] text-[var(--danger)] [padding:9px_11px] text-[13px]`,children:[(0,Z.jsx)(et,{size:14}),b]})]}),ie&&(0,Z.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-[6px] z-[5] flex justify-center`,children:(0,Z.jsxs)(m,{type:`button`,variant:`outline`,size:`lg`,className:`pointer-events-auto bg-surface-subtle min-h-[32px] [border-color:var(--accent-border)] text-[var(--star-strong)] shadow-[0_8px_18px_-14px_var(--shadow)]`,onClick:()=>ae(`smooth`),children:[(0,Z.jsx)(Dn,{size:14}),j(`chat:focusSession.newContent`)]})})]})}function ho(e){let t=String(e||``).trim().split(` `)[0];if(t.startsWith(`"`)&&t.endsWith(`"`))try{t=JSON.parse(t)}catch{}return t===`/dev/null`?``:t.replace(/^[ab]\//,``)}function go(e){let t=e.match(/^diff --git "a\/(.+)" "b\/(.+)"$/);if(t)return ho(`b/${t[2]}`);let n=e.match(/^diff --git a\/(.+) b\/(.+)$/);return n?ho(`b/${n[2]}`):``}function _o(){return{lineNumber:null,text:``,tone:`empty`}}function vo(e){let t=e.match(/^@@\s+-(\d+)(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s+@@/);return{oldLine:Number(t?.[1])||0,newLine:Number(t?.[2])||0}}function yo(e){let t=String(e||``).replace(/\r\n/g,`
5
+ `).split(`
6
+ `),n=[],r=null,i=null,a=0,o=0,s=[],c=[],l=()=>{if(!i||!s.length&&!c.length)return;let e=Math.max(s.length,c.length);for(let t=0;t<e;t+=1){let e=s[t],n=c[t];i.rows.push({kind:`pair`,old:e?{lineNumber:e.lineNumber,text:e.text,tone:`deleted`}:_o(),next:n?{lineNumber:n.lineNumber,text:n.text,tone:`added`}:_o()})}s=[],c=[]},u=()=>{l(),i=null},d=()=>{u(),r&&=(r.path=r.newPath||r.oldPath||r.path,n.push(r),null)};for(let e of t){if(e.startsWith(`diff --git `)){d(),r={oldPath:``,newPath:``,path:go(e),metadata:[],hunks:[]};continue}if(r){if(e.startsWith(`@@ `)){u();let t=vo(e);a=t.oldLine,o=t.newLine,i={header:e,rows:[]},r.hunks.push(i);continue}if(i){if(e.startsWith(`-`))s.push({lineNumber:a,text:e.slice(1)}),a+=1;else if(e.startsWith(`+`))c.push({lineNumber:o,text:e.slice(1)}),o+=1;else if(l(),e.startsWith(` `)){let t=e.slice(1);i.rows.push({kind:`pair`,old:{lineNumber:a,text:t,tone:`context`},next:{lineNumber:o,text:t,tone:`context`}}),a+=1,o+=1}else e.startsWith(`\\ `)&&i.rows.push({kind:`meta`,text:e.slice(2)});continue}e.startsWith(`--- `)?r.oldPath=ho(e.slice(4)):e.startsWith(`+++ `)?r.newPath=ho(e.slice(4)):e.trim()&&r.metadata.push(e)}}return d(),n}function bo({side:e,cell:t}){let n=t.tone===`deleted`?`−`:t.tone===`added`?`+`:` `;return(0,Z.jsxs)(`div`,{className:`git-diff-cell grid min-w-0 min-h-[24px] grid-cols-[44px_20px_minmax(0,1fr)] [border-bottom:1px_solid_var(--stroke-soft)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[11px] leading-[1.55] [&.next]:[border-left:1px_solid_var(--stroke)] [&.deleted]:bg-[var(--danger-soft)] [&.added]:bg-[var(--success-soft)] [&.empty]:bg-[var(--surface-muted)] [&.context]:bg-[var(--solid)] [&_code]:block [&_code]:min-w-0 [&_code]:p-[3px_8px_3px_2px] [&_code]:text-[var(--text)] [&_code]:font-[inherit] [&_code]:whitespace-pre-wrap [&_code]:[overflow-wrap:anywhere] ${e} ${t.tone}`,children:[(0,Z.jsx)(`span`,{className:`block [padding:3px_7px_3px_4px] [border-right:1px_solid_var(--stroke-soft)] text-[var(--text-muted)] text-right select-none`,children:t.lineNumber??``}),(0,Z.jsx)(`span`,{className:`git-diff-line-marker [.git-diff-cell.deleted_&]:text-[var(--danger)] [.git-diff-cell.added_&]:text-[var(--success)] block [padding:3px_4px] text-[var(--text-muted)] text-center select-none`,"aria-hidden":`true`,children:t.tone===`empty`?``:n}),(0,Z.jsx)(`code`,{children:t.text||`\xA0`})]})}function xo({file:e,scrollElement:t}){let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(0),a=(0,X.useMemo)(()=>e.hunks.flatMap((e,t)=>[{kind:`header`,hunkIndex:t,header:e.header},...e.rows.map((e,n)=>({kind:`row`,hunkIndex:t,rowIndex:n,row:e}))]),[e.hunks]);(0,X.useLayoutEffect)(()=>{let e=n.current;if(!t||!e)return;let r=()=>{let n=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);i(e=>Math.abs(e-n)<1?e:n)};r();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return a?.observe(t),a?.observe(e),()=>a?.disconnect()},[t]);let o=ya({count:a.length,getScrollElement:()=>t,estimateSize:()=>25,getItemKey:e=>{let t=a[e];return t.kind===`header`?`hunk-${t.hunkIndex}`:`row-${t.hunkIndex}-${t.rowIndex}`},measureElement:e=>Math.ceil(e.getBoundingClientRect().height),overscan:12,scrollMargin:r}),s=o.getVirtualItems();return(0,Z.jsx)(`div`,{className:`relative min-w-[880px] w-full`,"data-pisper-diff-row-count":a.length,"data-pisper-rendered-count":s.length,ref:n,style:{height:`${o.getTotalSize()}px`},children:s.map(e=>{let t=a[e.index];return(0,Z.jsx)(`div`,{className:`absolute left-0 w-full`,"data-index":e.index,ref:o.measureElement,style:{top:`${e.start-r}px`},children:t.kind===`header`?(0,Z.jsx)(`div`,{className:`git-diff-hunk-header [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--blue-soft)] p-[4px_10px] text-[var(--brand-blue-strong)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px] [white-space:pre]`,children:t.header}):t.row.kind===`meta`?(0,Z.jsx)(`div`,{className:`git-diff-row-meta [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--blue-soft)] p-[4px_10px] text-[var(--brand-blue-strong)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px] [white-space:pre] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:t.row.text}):(0,Z.jsxs)(`div`,{className:`grid min-w-[880px] grid-cols-[minmax(440px,1fr)_minmax(440px,1fr)]`,children:[(0,Z.jsx)(bo,{side:`old`,cell:t.row.old}),(0,Z.jsx)(bo,{side:`next`,cell:t.row.next})]})},e.key)})})}function So(e){let t=e.path.replace(/\\/g,`/`),n=t.split(`/`),r=n.pop()||t,i=0,a=0;for(let t of e.hunks)for(let e of t.rows)e.kind===`pair`&&(e.next.tone===`added`&&(i+=1),e.old.tone===`deleted`&&(a+=1));let o=e.metadata.join(`
7
+ `),s=/(?:^|\n)new file mode /.test(o)||!e.oldPath&&e.newPath?`added`:/(?:^|\n)deleted file mode /.test(o)||!e.newPath&&e.oldPath?`deleted`:/(?:^|\n)rename (?:from|to) /.test(o)||e.oldPath&&e.newPath&&e.oldPath!==e.newPath?`renamed`:`modified`;return{file:e,name:r,directory:n.join(`/`),added:i,deleted:a,status:s}}function Co(e){return e===`added`?`A`:e===`deleted`?`D`:e===`renamed`?`R`:`M`}function wo({diff:e,truncated:t,onClose:n}){let{t:r}=x(),i=(0,X.useMemo)(()=>yo(e),[e]),a=(0,X.useMemo)(()=>i.map(So),[i]),[o,s]=(0,X.useState)(0),[c,l]=(0,X.useState)(null),u=Math.min(o,Math.max(a.length-1,0)),d=a[u];(0,X.useEffect)(()=>{let e=document.body.style.overflow,t=e=>{e.key===`Escape`&&n()};return document.body.style.overflow=`hidden`,document.addEventListener(`keydown`,t),()=>{document.body.style.overflow=e,document.removeEventListener(`keydown`,t)}},[n]);let f=e=>{s(e),c?.scrollTo({top:0,left:0})};return(0,li.createPortal)((0,Z.jsx)(`div`,{className:`git-diff-dialog-backdrop max-[760px]:p-[10px] fixed z-[120] inset-0 grid place-items-center bg-[rgb(0_0_0/.48)] [padding:24px] [backdrop-filter:blur(3px)]`,role:`presentation`,onMouseDown:e=>e.target===e.currentTarget&&n(),children:(0,Z.jsxs)(`section`,{className:`git-diff-dialog max-[760px]:w-[calc(100vw_-_20px)] max-[760px]:h-[calc(100vh_-_20px)] flex w-[min(1180px,calc(100vw_-_48px))] h-[min(820px,calc(100vh_-_48px))] min-w-0 min-h-0 flex-col overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-lg)] bg-[var(--solid)] shadow-[0_28px_90px_-24px_rgb(0_0_0/.65)]`,role:`dialog`,"aria-modal":`true`,"aria-label":r(`chat:focusSession.gitViewDiff`),children:[(0,Z.jsxs)(`header`,{className:`git-diff-dialog-head [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] grid min-h-[54px] flex-none grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[10px] [border-bottom:1px_solid_var(--stroke)] [padding:8px_12px]`,children:[(0,Z.jsx)(`span`,{className:`grid w-[34px] h-[34px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)]`,children:(0,Z.jsx)(Ln,{size:17})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:r(`chat:focusSession.gitViewDiff`)}),(0,Z.jsx)(`small`,{children:r(`chat:focusSession.gitDiffFileCount`,{count:i.length})})]}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,title:r(`chat:focusSession.gitCloseDiff`),"aria-label":r(`chat:focusSession.gitCloseDiff`),onClick:n,children:(0,Z.jsx)(Me,{size:17})})]}),a.length?(0,Z.jsxs)(`div`,{className:`git-diff-layout max-[760px]:grid-rows-[minmax(112px,26vh)_minmax(0,1fr)] max-[760px]:grid-cols-[minmax(0,1fr)] grid min-w-0 min-h-0 flex-1 grid-cols-[252px_minmax(0,1fr)] overflow-hidden`,children:[(0,Z.jsxs)(`nav`,{className:`git-diff-file-nav max-[760px]:[border-right:0] max-[760px]:[border-bottom:1px_solid_var(--stroke)] flex min-w-0 min-h-0 flex-col overflow-hidden [border-right:1px_solid_var(--stroke)] bg-[var(--surface-muted)]`,"aria-label":r(`chat:focusSession.gitDiffChangedFiles`),children:[(0,Z.jsx)(`strong`,{className:`git-diff-file-nav-title max-[760px]:[padding-block:7px_5px] flex-none [padding:10px_12px_8px] text-[var(--text-muted)] text-[10px] font-[700] tracking-[.055em] [text-transform:uppercase]`,children:r(`chat:focusSession.gitDiffChangedFiles`)}),(0,Z.jsx)(`div`,{className:`git-diff-file-nav-list max-[760px]:pb-[6px] min-h-0 flex-1 overflow-x-hidden overflow-y-auto [padding:0_6px_8px]`,children:a.map((e,t)=>{let n=t===u;return(0,Z.jsxs)(`button`,{type:`button`,className:`git-diff-file-nav-item hover:bg-[var(--surface-hover)] hover:text-[var(--text)] [&.selected]:bg-[var(--accent-soft)] [&.selected]:text-[var(--text)] [&.selected]:shadow-[inset_2px_0_var(--star-strong)] grid w-full min-h-[42px] grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-[7px] border-0 rounded-[var(--r-sm)] bg-transparent [padding:5px_7px] text-[var(--text-secondary)] text-left cursor-pointer ${e.status} ${n?`selected`:``}`,title:e.file.path,"aria-current":n?`true`:void 0,onClick:()=>f(t),children:[(0,Z.jsx)(`span`,{className:`git-diff-file-status font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[11px] font-[750] text-center [.git-diff-file-nav-item.added_&]:text-[var(--success)] [.git-diff-file-nav-item.deleted_&]:text-[var(--danger)] [.git-diff-file-nav-item.renamed_&]:text-[var(--warning-strong)] [.git-diff-file-nav-item.modified_&]:text-[var(--star-strong)]`,"aria-hidden":`true`,children:Co(e.status)}),(0,Z.jsxs)(`span`,{className:`git-diff-file-name [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[11px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[9px] flex min-w-0 flex-col gap-[1px]`,children:[(0,Z.jsx)(`strong`,{children:e.name}),e.directory&&(0,Z.jsx)(`small`,{children:e.directory})]}),(0,Z.jsxs)(`span`,{className:`git-diff-file-stats inline-flex items-center gap-[4px] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[9px] [&_em]:[font-style:normal]`,"aria-hidden":`true`,children:[e.added>0&&(0,Z.jsxs)(`em`,{className:`added [.git-diff-file-stats_&]:text-[var(--success)]`,children:[`+`,e.added]}),e.deleted>0&&(0,Z.jsxs)(`em`,{className:`deleted [.git-diff-file-stats_&]:text-[var(--danger)]`,children:[`−`,e.deleted]})]})]},`${e.file.path}-${t}`)})})]}),(0,Z.jsxs)(`div`,{className:`min-w-0 min-h-0 overflow-auto bg-[var(--surface-subtle)] [padding:12px]`,ref:l,children:[t&&(0,Z.jsx)(`div`,{className:`[margin:0_0_12px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] [padding:8px_10px] text-[var(--warning-strong)] text-[11px]`,children:r(`chat:focusSession.gitDiffTruncated`)}),d&&(0,Z.jsxs)(`section`,{className:`min-w-[880px] [overflow:clip] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)]`,children:[(0,Z.jsxs)(`header`,{className:`git-diff-file-head [&_>_svg]:text-[var(--star-strong)] [&_strong]:overflow-hidden [&_strong]:font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] [&_strong]:text-[12px] [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:max-w-[300px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap sticky z-[3] top-0 grid min-h-[38px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] [border-bottom:1px_solid_var(--stroke)] bg-[var(--solid)] [padding:7px_10px]`,children:[(0,Z.jsx)(Ln,{size:14}),(0,Z.jsx)(`strong`,{title:d.file.path,children:d.file.path}),d.file.oldPath&&d.file.newPath&&d.file.oldPath!==d.file.newPath&&(0,Z.jsx)(`small`,{title:d.file.oldPath,children:d.file.oldPath})]}),d.file.metadata.length>0&&(0,Z.jsx)(`div`,{className:`git-diff-file-meta [border-bottom:1px_solid_var(--stroke-soft)] bg-[var(--surface-muted)] p-[5px_10px] text-[var(--text-muted)] font-[ui-monospace,SFMono-Regular,Consolas,'Liberation_Mono',monospace] text-[10px]`,children:d.file.metadata.join(` · `)}),d.file.hunks.length>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`git-diff-column-head [&_span]:p-[5px_10px] [&_span_+_span]:[border-left:1px_solid_var(--stroke)] sticky z-[2] [top:38px] grid grid-cols-[1fr_1fr] [border-bottom:1px_solid_var(--stroke)] bg-[var(--surface-muted)] text-[var(--text-muted)] text-[10px] font-[650] [text-transform:uppercase]`,children:[(0,Z.jsx)(`span`,{children:r(`chat:focusSession.gitDiffOriginal`)}),(0,Z.jsx)(`span`,{children:r(`chat:focusSession.gitDiffModified`)})]}),(0,Z.jsx)(xo,{file:d.file,scrollElement:c})]}):(0,Z.jsx)(`div`,{className:`[padding:28px_16px] text-[var(--text-muted)] text-[12px] text-center`,children:r(`chat:focusSession.gitDiffNoTextChanges`)})]},d.file.path)]})]}):(0,Z.jsx)(`div`,{className:`min-w-0 min-h-0 flex-1 bg-[var(--surface-subtle)] overflow-auto [padding:12px]`,children:(0,Z.jsx)(`div`,{className:`[border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:20px] text-[var(--text-muted)] whitespace-pre-wrap`,children:e||r(`chat:focusSession.gitDiffUnavailable`)})})]})}),document.body)}var To=`Agent changes`;function Eo(e){return e instanceof Error?e.message:String(e)}function Do({sessionId:e,streaming:t}){let{t:n,language:r}=x(),[i,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),[p,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(``),[v,y]=(0,X.useState)(null),[b,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(``),T=(0,X.useRef)(null),E=(0,X.useRef)(null),D=(0,X.useCallback)(async()=>{if(e){u(!0),S(``);try{let t=await a.getVcsChanges(e);y(t)}catch(e){S(Eo(e))}finally{u(!1)}}},[e]);(0,X.useEffect)(()=>{if(!i)return;D();let e=e=>{let t=e.target instanceof Node?e.target:null;!T.current?.contains(t)&&!E.current?.contains(t)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i,D]),(0,X.useEffect)(()=>{t||D().catch(()=>{})},[t,D]);let O=async t=>{if(!(!e||d)){if(t===`revert`&&!p){h(!0);return}f(t),S(``),w(``);try{let r;t===`commit`?(r=await a.commitVcsChanges(e,g.trim()||To),_(``),w(n(`chat:focusSession.gitCommitted`))):t===`push`?(r=await a.pushVcsChanges(e),w(n(`chat:focusSession.gitPushed`))):(r=await a.revertVcsChanges(e),h(!1),w(n(`chat:focusSession.gitReverted`))),y(r)}catch(e){S(Eo(e))}finally{f(null)}}},k=(v?.vcs||(v?.isRepo?`git`:``))===`svn`,A=v?.isRepo?v.files.length:0,j=A>0,M=!!(!k&&v?.isRepo&&(v.ahead??0)>0),N=!!d,P=k?n(`chat:focusSession.vcsSvnWorkspace`):v?.branch||n(`chat:focusSession.gitDetachedHead`),F=v?.isRepo?`${n(`chat:focusSession.gitChanges`)}${v.branch?` · ${v.branch}`:``}${k?` · ${n(`chat:focusSession.vcsSvnWorkspace`)}`:``}${j?` · ${n(`chat:focusSession.gitFilesChanged`,{count:A})}`:``}`:n(`chat:focusSession.gitChanges`);return(0,Z.jsxs)(`div`,{ref:T,className:`git-changes-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative flex-none w-[38px] h-[38px] text-[var(--text-tertiary)] ${i?`open`:``} ${j?`active`:``}`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`git-changes-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.git-changes-select.open_&]:border-[var(--accent-border)] [.git-changes-select.open_&]:bg-[var(--accent-soft)] [.git-changes-select.open_&]:text-[var(--star-strong)] [.git-changes-select.active_&]:text-[var(--star-strong)] [&_>_i]:absolute [&_>_i]:top-[-4px] [&_>_i]:right-[-6px] [&_>_i]:min-w-[15px] [&_>_i]:rounded-[var(--r-pill)] [&_>_i]:bg-[var(--star-strong)] [&_>_i]:p-[1px_4px] [&_>_i]:text-[var(--on-accent)] [&_>_i]:text-[9px] [&_>_i]:[font-style:normal] [&_>_i]:font-[700] [&_>_i]:leading-[1.3] [&_>_i]:text-center @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative grid w-full h-full place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit cursor-pointer`,title:F,"aria-label":F,"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!e,onClick:()=>o(e=>!e),children:[(0,Z.jsx)(ne,{size:14}),j&&(0,Z.jsx)(`i`,{children:A>99?`99+`:A})]}),(0,Z.jsxs)(fi,{open:i,anchorRef:T,menuRef:E,className:`anchored-popup-menu git-changes-menu w-[min(340px,calc(100vw_-_28px))] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)]`,role:`dialog`,ariaLabel:n(`chat:focusSession.gitChanges`),children:[(0,Z.jsxs)(`div`,{className:`git-changes-menu-head hover:bg-[var(--accent-soft)] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[12px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap grid min-h-[44px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] rounded-[var(--r-sm)] [padding:6px_7px]`,children:[(0,Z.jsx)(`span`,{className:`git-changes-menu-icon grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] ${j?`bg-[var(--star-soft)] text-[var(--star-strong)]`:`bg-[var(--surface-muted)] text-[var(--text-muted)]`}`,children:(0,Z.jsx)(ne,{size:15})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n(`chat:focusSession.gitChanges`)}),(0,Z.jsx)(`small`,{title:v?.cwd||``,children:v?.isRepo?P:l?n(`chat:focusSession.gitLoading`):b&&!v?n(`chat:focusSession.gitLoadFailed`):v?.gitAvailable===!1&&v?.svnAvailable===!1?n(`chat:focusSession.gitUnavailable`):`${n(`chat:focusSession.gitNotARepository`)}${v?.cwd?` · ${Ye(v.cwd,r)}`:``}`})]}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,title:n(`chat:focusSession.gitRefresh`),"aria-label":n(`chat:focusSession.gitRefresh`),disabled:l||N,onClick:()=>void D(),children:(0,Z.jsx)(q,{className:l?`animate-spin`:``,size:13})})]}),b&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:b}),!b&&v?.error&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--danger,_#d64545)] text-[11px]`,children:v.error}),C&&!b&&(0,Z.jsx)(`p`,{className:`[margin:2px_7px_4px] text-[var(--success,_#2e9e63)] text-[11px]`,children:C}),v?.isRepo&&(0,Z.jsxs)(Z.Fragment,{children:[j?(0,Z.jsxs)(`div`,{className:`git-changes-file-list [&_>_small]:p-[3px_5px] [&_>_small]:text-[var(--text-muted)] flex max-h-[168px] flex-col gap-[1px] [margin:2px_4px] overflow-y-auto`,children:[v.files.slice(0,60).map(e=>(0,Z.jsxs)(`div`,{className:`git-changes-file hover:bg-[var(--accent-soft)] [&_>_span]:overflow-hidden [&_>_span]:text-[var(--text-secondary)] [&_>_span]:text-ellipsis [&_>_span]:whitespace-nowrap grid grid-cols-[26px_minmax(0,1fr)] items-center gap-[6px] rounded-[var(--r-sm)] [padding:3px_5px] text-[11px]`,children:[(0,Z.jsx)(`code`,{className:`text-[var(--star-strong)] text-[10px] font-[700]`,children:e.status}),(0,Z.jsx)(`span`,{title:e.path,children:e.path})]},`${e.status}-${e.path}`)),v.files.length>60&&(0,Z.jsx)(`small`,{children:n(`chat:focusSession.gitMoreFiles`,{count:v.files.length-60})})]}):(0,Z.jsx)(`p`,{className:`[margin:4px_7px] text-[var(--text-muted)] text-[11px]`,children:n(`chat:focusSession.gitNoChanges`)}),j&&(0,Z.jsxs)(`div`,{className:`git-changes-commit-row [&_input]:w-full [&_input]:min-w-0 [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--surface-muted)] [&_input]:p-[5px_7px] [&_input]:text-inherit [&_input]:text-[12px] [&_input:focus]:border-[var(--focus)] [&_input:focus]:[outline:none] grid grid-cols-[minmax(0,1fr)_auto] gap-[6px] [margin:4px_7px]`,children:[(0,Z.jsx)(`input`,{value:g,placeholder:n(`chat:focusSession.gitCommitMessagePlaceholder`),onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),O(`commit`))}}),(0,Z.jsxs)(m,{type:`button`,disabled:N||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitCommit`),onClick:()=>void O(`commit`),children:[d===`commit`?(0,Z.jsx)(q,{className:`animate-spin`,size:12}):(0,Z.jsx)(Bn,{size:12}),n(`chat:focusSession.gitCommit`)]})]}),j&&(0,Z.jsxs)(`button`,{type:`button`,className:`git-changes-view-diff hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] flex w-[calc(100%_-_14px)] min-h-[30px] items-center gap-[7px] [margin:4px_7px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] bg-[var(--surface-muted)] [padding:5px_8px] text-[var(--text-secondary)] text-[11px] font-[600] cursor-pointer`,onClick:()=>{c(!0),o(!1)},children:[(0,Z.jsx)(Ln,{size:13}),n(`chat:focusSession.gitViewDiff`)]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-[6px] [margin:5px_7px_6px]`,children:[!k&&(0,Z.jsxs)(m,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N||!M&&!j,title:M?n(`chat:focusSession.gitPushAhead`,{count:v?.ahead||0}):n(`chat:focusSession.gitPush`),onClick:()=>void O(`push`),children:[d===`push`?(0,Z.jsx)(q,{className:`animate-spin`,size:12}):(0,Z.jsx)(ar,{size:12}),n(`chat:focusSession.gitPush`),M?` ↑${v?.ahead}`:``]}),p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(m,{type:`button`,variant:`destructive`,disabled:N||t,title:n(t?`chat:focusSession.gitWaitForRunToFinish`:`chat:focusSession.gitConfirmRevert`),onClick:()=>void O(`revert`),children:[d===`revert`?(0,Z.jsx)(q,{className:`animate-spin`,size:12}):(0,Z.jsx)(fe,{size:12}),n(`chat:focusSession.gitConfirmRevert`)]}),(0,Z.jsxs)(m,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N,onClick:()=>h(!1),children:[(0,Z.jsx)(Me,{size:12}),n(`chat:focusSession.gitCancel`)]})]}):(0,Z.jsxs)(m,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:N||t||!j,title:n(k?`chat:focusSession.vcsRevertDescription`:`chat:focusSession.gitRevertDescription`),onClick:()=>void O(`revert`),children:[(0,Z.jsx)(ir,{size:12}),n(`chat:focusSession.gitRevert`)]})]})]})]}),s&&v&&(0,Z.jsx)(wo,{diff:v.diff||``,truncated:v.diffTruncated,onClose:()=>c(!1)})]})}var Oo=8;function ko(e,t){(0,X.useLayoutEffect)(()=>{if(!e)return;let n=()=>{let e=t.current;if(!e)return;e.style.setProperty(`--menu-x-offset`,`0px`),e.style.setProperty(`--menu-y-offset`,`0px`),e.style.removeProperty(`max-height`),e.style.removeProperty(`overflow-y`);let n=Oo,r=Oo,i=window.innerWidth-Oo,a=window.innerHeight-Oo,o=e.parentElement;for(;o;){let e=getComputedStyle(o);if(/(auto|hidden|scroll|clip)/.test(`${e.overflowX} ${e.overflowY}`)){let e=o.getBoundingClientRect();n=Math.max(n,e.left+Oo),r=Math.max(r,e.top+Oo),i=Math.min(i,e.right-Oo),a=Math.min(a,e.bottom-Oo)}o=o.parentElement}let s=Math.max(120,a-r),c=e.getBoundingClientRect();c.height>s&&(e.style.maxHeight=`${s}px`,e.style.overflowY=`auto`,c=e.getBoundingClientRect());let l=c.right>i?i-c.right:c.left<n?n-c.left:0,u=c.bottom>a?a-c.bottom:c.top<r?r-c.top:0;e.style.setProperty(`--menu-x-offset`,`${l}px`),e.style.setProperty(`--menu-y-offset`,`${u}px`)};return n(),window.addEventListener(`resize`,n),()=>window.removeEventListener(`resize`,n)},[t,e])}var Ao=1e3;function jo({mode:e,goal:t,tokenBudget:n,onTokenBudgetChange:r,onSaveTokenBudget:i,onChange:a,teamAvailable:o=!1,disabled:s=!1}){let{t:c}=x(),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),h=(0,X.useRef)(null),g=t?.status===`active`,_=!!t?.id,v=g?t?.mode===`team`&&o?`team`:`goal`:e,y=v===`team`?t?.teamTokenBudget:t?.tokenBudget,b=y==null?null:Number(y)>0?Number(y):null,S=n!==b,C=[{value:`plan`,label:c(`chat:focusSession.planMode`),description:c(`chat:focusSession.planModeDescription`),icon:Gn},{value:`goal`,label:c(`chat:focusSession.goalMode`),description:c(`chat:focusSession.goalModeDescription`),icon:nr},...o?[{value:`team`,label:c(`chat:focusSession.teamMode`),description:c(`chat:focusSession.teamModeDescription`),icon:sr}]:[]],w=C.find(e=>e.value===v)||C[0],T=w.icon,E=v===`plan`?w.description:g?c(v===`team`?`chat:focusSession.runningAsTeam`:`chat:focusSession.runningAutonomously`):t?.status===`paused`?c(`chat:focusSession.theNextMessageWillResumeTheGoal`):t?.status===`complete`?c(`chat:focusSession.goalComplete`):t?.status===`budget_limited`?c(`chat:focusSession.goalReachedItsBudget`):c(`chat:focusSession.theNextMessageWillStartAGoal`),D=v===`plan`?w.description:E,O=c(`chat:focusSession.goalTokenBudgetUnlimited`),k=_?b==null?c(`chat:focusSession.usedUnlimitedGoalTokens`,{used:Y(t?.tokensUsed)}):c(`chat:focusSession.usedBudgetTokensUsed`,{used:t?.tokensUsed||0,budget:b||0}):``,A=[c(`chat:focusSession.executionMode`),w.label,D,k].filter(Boolean).join(` · `);(0,X.useEffect)(()=>{if(!l)return;let e=e=>{let t=e.target instanceof Node?e.target:null;p.current?.contains(t)||u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]),ko(l,h);let j=async()=>{if(!(d||!S||!_||!i)){f(!0);try{await i(n)}finally{f(!1)}}};return(0,Z.jsxs)(`div`,{ref:p,className:`task-execution-mode-select [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] relative w-[38px] h-[38px] text-[var(--text-tertiary)] ${l?`open`:``} ${v===`plan`?``:`active`}`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`task-execution-mode-trigger hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] [.task-execution-mode-select.open_&]:border-[var(--accent-border)] [.task-execution-mode-select.open_&]:bg-[var(--accent-soft)] [.task-execution-mode-select.open_&]:text-[var(--star-strong)] [.task-execution-mode-select.active_&]:text-[var(--star-strong)] grid w-full h-full place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-inherit cursor-pointer disabled:cursor-not-allowed disabled:opacity-[.55]`,title:A,"aria-label":A,"aria-haspopup":`menu`,"aria-expanded":l,disabled:s,onClick:()=>u(e=>!e),children:(0,Z.jsx)(T,{size:14})}),l&&(0,Z.jsxs)(`div`,{ref:h,className:`task-execution-mode-menu [translate:var(--menu-x-offset,_0px)_var(--menu-y-offset,_0px)] [&_strong]:text-[12px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[11px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_p]:m-[1px_7px_4px_47px] [&_p]:text-[var(--text-muted)] [&_p]:text-[11px] max-[650px]:[.focus-composer_&]:right-[auto] max-[650px]:[.focus-composer_&]:left-0 max-[650px]:[.focus-composer_&]:w-[min(270px,calc(100vw_-_76px))] absolute z-[35] [bottom:calc(100%_+_8px)] left-0 w-[min(270px,calc(100vw_-_28px))] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)]`,role:`menu`,"aria-label":c(`chat:focusSession.executionMode`),children:[(0,Z.jsx)(`div`,{className:`[padding:6px_8px_4px] text-[var(--text-muted)] text-[11px] font-[700] tracking-[.04em] [text-transform:uppercase]`,children:c(`chat:focusSession.executionMode`)}),C.map(e=>{let t=e.icon,n=e.value===v;return(0,Z.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":n,className:`task-execution-mode-option hover:bg-[var(--accent-soft)] [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[2px] grid w-full min-h-[48px] grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[8px] border-0 rounded-[var(--r-sm)] bg-transparent [padding:6px_7px] text-left ${n?`bg-[var(--accent-soft)]`:``}`,onClick:()=>{a(e.value),u(!1)},children:[(0,Z.jsx)(`span`,{className:`grid w-[32px] h-[32px] place-items-center rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(t,{size:14})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.label}),(0,Z.jsx)(`small`,{children:e.description})]}),n&&(0,Z.jsx)(fe,{size:13})]},e.value)}),(v===`goal`||v===`team`||_)&&(0,Z.jsxs)(Z.Fragment,{children:[k&&(0,Z.jsx)(`p`,{children:k}),(0,Z.jsxs)(`div`,{className:`goal-mode-budget-row [&_label]:text-[var(--text-secondary)] [&_label]:text-[11px] [&_label]:font-[600] [&_input]:w-full [&_input]:min-w-0 [&_input]:[border:1px_solid_var(--stroke)] [&_input]:rounded-[var(--r-sm)] [&_input]:bg-[var(--surface-muted)] [&_input]:p-[5px_7px] [&_input]:text-inherit [&_input]:text-[12px] [&_input:focus]:border-[var(--focus)] [&_input:focus]:[outline:none] grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-[6px] [margin:2px_7px_2px]`,children:[(0,Z.jsx)(`label`,{htmlFor:`goal-token-budget-input`,children:c(v===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`)}),(0,Z.jsx)(`input`,{id:`goal-token-budget-input`,type:`number`,min:Ao,step:1e3,value:n??``,placeholder:O,"aria-label":c(v===`team`?`chat:focusSession.teamTokenBudget`:`chat:focusSession.goalTokenBudget`),disabled:d,onChange:e=>{let t=e.target.value.trim();if(!t){r(null);return}let n=Number(t);Number.isFinite(n)&&r(Math.max(Ao,Math.round(n)))}}),_&&S&&(0,Z.jsxs)(m,{type:`button`,variant:`outline`,className:`bg-surface-subtle`,disabled:d,onClick:()=>void j(),children:[d?(0,Z.jsx)(q,{className:`animate-spin`,size:12}):(0,Z.jsx)(fe,{size:12}),c(`chat:focusSession.goalBudgetSave`)]})]}),(0,Z.jsx)(`small`,{className:`block [margin:0_7px_5px] text-[var(--text-muted)] text-[10px]`,children:c(v===`team`?`chat:focusSession.teamTokenBudgetHint`:_?`chat:focusSession.goalTokenBudgetUpdateHint`:`chat:focusSession.goalTokenBudgetHint`)})]})]})]})}function Mo({session:e,canSplit:t,canClose:n=!0,streaming:r,switchingCwd:i,onSplitLeft:a,onSplitRight:o,onSplitTop:s,onSplitBottom:c,onClosePanel:l,onWorkspace:u,onRename:d,onSessionTree:f}){let{t:p,language:h}=x(),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(`top`),b=(0,X.useRef)(null),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useCallback)(()=>{_(!1),C.current?.focus()},[]);(0,X.useEffect)(()=>{if(!g)return;let e=e=>{let t=e.target instanceof Node?e.target:null;!b.current?.contains(t)&&!S.current?.contains(t)&&_(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]);let T=e=>{_(!1),e?.()},E=[[be,p(`chat:focusSession.splitToLeft`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheLeft`),a],[_e,p(`chat:focusSession.splitToRight`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheRight`),o],[ye,p(`chat:focusSession.splitToTop`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheTop`),s],[ve,p(`chat:focusSession.splitToBottom`),p(`chat:focusSession.moveTheCurrentTabIntoANewGroupOnTheBottom`),c]];return(0,Z.jsxs)(`div`,{ref:b,className:`relative flex-none`,children:[(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon`,ref:C,title:p(`chat:focusSession.chatActions`),"aria-label":p(`chat:focusSession.openChatActionsMenu`),"aria-haspopup":`menu`,"aria-expanded":g,disabled:!e,onClick:()=>{g||y(b.current?.closest(`.focus-composer, .composer-tool-tray`)?`top`:`bottom`),_(e=>!e)},children:(0,Z.jsx)(ee,{size:17})}),(0,Z.jsxs)(fi,{open:g,anchorRef:b,menuRef:S,placement:v,align:`end`,onClose:w,className:`anchored-popup-menu permission-mode-menu session-actions-menu [&_>_button]:grid [&_>_button]:w-full [&_>_button]:min-h-[48px] [&_>_button]:grid-cols-[auto_minmax(0,1fr)_auto] [&_>_button]:items-center [&_>_button]:gap-[8px] [&_>_button]:border-0 [&_>_button]:rounded-[var(--r-sm)] [&_>_button]:bg-transparent [&_>_button]:text-[var(--text)] [&_>_button]:p-[6px_7px] [&_>_button]:text-left [&_>_button:hover]:bg-[var(--accent-soft)] [&_>_button.active]:bg-[var(--accent-soft)] [&_>_button_>_span:nth-child(2)]:flex [&_>_button_>_span:nth-child(2)]:min-w-0 [&_>_button_>_span:nth-child(2)]:flex-col [&_>_button_>_span:nth-child(2)]:gap-[2px] [&_strong]:text-[13px] [&_small]:text-[var(--text-muted)] [&_small]:text-[13px] [&_small]:leading-[1.4] [&_>_button_>_svg]:text-[var(--star-strong)] w-[250px] max-w-[calc(100vw_-_16px)] overflow-hidden [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:5px] shadow-[0_18px_42px_-18px_var(--menu-shadow)] [&_>_button:disabled]:[cursor:not-allowed] [&_>_button:disabled]:opacity-[.5]`,role:`menu`,children:[E.map(([e,n,r,i])=>(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:!t,onClick:()=>T(i),children:[(0,Z.jsx)(e,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n}),(0,Z.jsx)(`small`,{children:t?r:p(`chat:focusSession.thisGroupHasOnlyOneChat`)})]})]},n)),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:r||i,onClick:()=>T(u),children:[(0,Z.jsx)(Le,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.setWorkingDirectory`)}),(0,Z.jsx)(`small`,{children:r?p(`chat:focusSession.cannotSwitchWhileTheAgentIsRunning`):Ye(e?.cwd,h)})]})]}),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:r,onClick:()=>T(f),children:[(0,Z.jsx)(rr,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:sessionTree.menu`)}),(0,Z.jsx)(`small`,{children:p(r?`chat:sessionTree.waitForRun`:`chat:sessionTree.menuDescription`)})]})]}),(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>T(d),children:[(0,Z.jsx)(Se,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.renameChat`)}),(0,Z.jsx)(`small`,{children:e?.name||p(`chat:focusSession.newChat`)})]})]}),n&&(0,Z.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>T(l),children:[(0,Z.jsx)(Me,{size:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:p(`chat:focusSession.closeTab`)}),(0,Z.jsx)(`small`,{children:p(`chat:focusSession.keepTheHistoryAndCloseOnlyThisView`)})]})]})]})]})}var No=new Set([`user`,`assistant`,`summary`,`compaction`,`position`]),Po=new Set([`tool`,`tool-call`]);function Fo(e){let t=[],n=new Map;for(let r of e){let e=r.parentId?n.get(r.parentId):void 0,i={...r,children:[]};n.set(r.id,i),e?e.children.push(i):t.push(i)}return t}function Io(e){let t=[],n=[...e].reverse();for(;n.length>0;){let e=n.pop();if(e){t.push(e);for(let t=e.children.length-1;t>=0;--t)n.push(e.children[t])}}return t}function Lo(e,t){let n=[],r=new Map;for(let i of Io(e)){let e=i.parentId&&r.get(i.parentId)||null;if(!t(i)){r.set(i.id,e);continue}let a={...i,children:[]};r.set(i.id,a),e?e.children.push(a):n.push(a)}return n}function Ro(e){let t=[e],n=e;for(;n.children.length===1;)n=n.children[0],t.push(n);let r={id:e.id,nodes:t,children:[],active:t.some(e=>e.active)},i=[{segment:r,children:n.children}];for(;i.length>0;){let e=i.pop();if(e)for(let t of e.children){let n=[t],r=t;for(;r.children.length===1;)r=r.children[0],n.push(r);let a={id:t.id,nodes:n,children:[],active:n.some(e=>e.active)};e.segment.children.push(a),i.push({segment:a,children:r.children})}}return r}function zo(e){return e.kind===`user`?or:e.kind===`assistant`?Ue:e.kind===`tool`||e.kind===`tool-call`?je:e.kind===`settings`?De:e.kind===`label`?K:e.kind===`summary`||e.kind===`compaction`?Rn:e.kind===`position`?ne:e.label?jn:ft}function Bo({nodes:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let o=ya({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>64,getItemKey:t=>e[t]?.id??`mobile-tree-node-${t}`,overscan:12,useAnimationFrameWithResizeObserver:!0});return(0,X.useEffect)(()=>{if(!n)return;let t=e.findIndex(e=>e.id===n);t>=0&&o.scrollToIndex(t,{align:`center`})},[e,n,o]),(0,Z.jsx)(`div`,{className:`relative w-full`,style:{height:`${o.getTotalSize()}px`},children:o.getVirtualItems().map(t=>{let o=e[t.index],s=zo(o);return(0,Z.jsx)(`div`,{className:`absolute top-0 left-0 w-full px-[12px] py-[4px]`,style:{transform:`translateY(${t.start}px)`},children:(0,Z.jsxs)(`button`,{type:`button`,className:`session-tree-node hover:border-[var(--stroke-hover)] hover:bg-[var(--solid)] [&.selected]:border-[var(--focus)] [&.selected]:bg-[var(--solid)] [&.selected]:shadow-[0_0_0_2px_var(--focus-ring)] grid min-h-[56px] w-full grid-cols-[34px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)] p-[7px_9px_7px_4px] text-left ${o.id===n?` selected`:``}${o.active?` active`:``}${o.leaf?` leaf`:``}`,"data-kind":o.kind,"data-pisper-tree-entry":o.id,onClick:()=>a(o.id),children:[(0,Z.jsx)(`span`,{className:`session-tree-marker [.session-tree-node[data-kind='user']_&]:bg-[var(--star-soft)] [.session-tree-node[data-kind='user']_&]:text-[var(--star-strong)] [.session-tree-node[data-kind='assistant']_&]:bg-[var(--brand-blue-soft)] [.session-tree-node[data-kind='assistant']_&]:text-[var(--brand-blue-strong)] [.session-tree-node[data-kind='tool']_&]:bg-[var(--warning-soft)] [.session-tree-node[data-kind='tool']_&]:text-[var(--warning-strong)] [.session-tree-node.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] grid size-[28px] place-items-center justify-self-center [border:2px_solid_var(--surface-subtle)] rounded-full bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(s,{size:14})}),(0,Z.jsxs)(`span`,{className:`session-tree-node-copy flex min-w-0 flex-col gap-[2px] [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_small]:text-[10px] [&_small]:text-[var(--text-muted)] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650]`,children:[(0,Z.jsx)(`strong`,{children:o.label||o.text||r(o)}),(0,Z.jsx)(`small`,{children:o.label&&o.text?o.text:r(o)})]}),(0,Z.jsxs)(`span`,{className:`session-tree-node-state [.session-tree-node.active_&]:text-[var(--brand-blue-strong)] [.session-tree-node.leaf_&]:text-[var(--brand-blue-strong)] inline-flex items-center gap-[4px] text-[9px] text-[var(--text-muted)] [text-transform:uppercase]`,children:[o.label&&(0,Z.jsx)(jn,{size:12}),i(o)]})]})},t.key)})})}function Vo({segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a}){let{nodes:o,children:s}=e,c=o.length>120,l=ya({count:o.length,getScrollElement:()=>t.current,estimateSize:()=>56,getItemKey:e=>o[e]?.id??`tree-node-${e}`,overscan:12,scrollMargin:26,enabled:c,useAnimationFrameWithResizeObserver:!0}),u=e=>{let t=zo(e);return(0,Z.jsxs)(`button`,{type:`button`,className:`session-tree-node hover:border-[var(--stroke-hover)] hover:bg-[var(--solid)] [&.selected]:border-[var(--focus)] [&.selected]:bg-[var(--solid)] [&.selected]:shadow-[0_0_0_2px_var(--focus-ring),0_8px_20px_-18px_var(--shadow)] relative z-[1] grid w-[220px] min-h-[48px] grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[color-mix(in_srgb,var(--solid)_94%,transparent)] text-[var(--text)] [padding:6px_8px_6px_2px] text-left shadow-[0_4px_14px_-13px_var(--shadow)] cursor-pointer ${e.id===n?` selected`:``}${e.active?` active`:``}${e.leaf?` leaf`:``}`,"data-kind":e.kind,"data-pisper-tree-entry":e.id,onClick:()=>a(e.id),children:[(0,Z.jsx)(`span`,{className:`session-tree-marker [.session-tree-node[data-kind='user']_&]:bg-[var(--star-soft)] [.session-tree-node[data-kind='user']_&]:text-[var(--star-strong)] [.session-tree-node[data-kind='assistant']_&]:bg-[var(--brand-blue-soft)] [.session-tree-node[data-kind='assistant']_&]:text-[var(--brand-blue-strong)] [.session-tree-node[data-kind='tool']_&]:bg-[var(--warning-soft)] [.session-tree-node[data-kind='tool']_&]:text-[var(--warning-strong)] [.session-tree-node[data-kind='summary']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='summary']_&]:text-[var(--violet-strong)] [.session-tree-node[data-kind='compaction']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='compaction']_&]:text-[var(--violet-strong)] [.session-tree-node.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] [.session-tree-mark.active_&]:border-[var(--brand-blue-border)] [.session-tree-mark.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] relative z-[2] grid w-[26px] h-[26px] place-items-center [justify-self:center] [border:2px_solid_var(--surface-subtle)] rounded-[50%] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:(0,Z.jsx)(t,{size:14})}),(0,Z.jsxs)(`span`,{className:`session-tree-node-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] flex min-w-0 flex-col gap-[2px]`,children:[(0,Z.jsx)(`strong`,{children:e.label||e.text||r(e)}),(0,Z.jsx)(`small`,{children:e.label&&e.text?e.text:r(e)})]}),(0,Z.jsxs)(`span`,{className:`session-tree-node-state [.session-tree-node.active_&]:text-[var(--brand-blue-strong)] [.session-tree-node.leaf_&]:text-[var(--brand-blue-strong)] inline-flex min-w-0 items-center gap-[4px] text-[var(--text-muted)] text-[9px] [text-transform:uppercase]`,children:[e.label&&(0,Z.jsx)(jn,{size:12}),i(e)]})]},e.id)};return(0,X.useEffect)(()=>{if(!c||!n)return;let e=o.findIndex(e=>e.id===n);e<0||l.scrollToIndex(e,{align:`center`})},[n,o,c,l]),(0,Z.jsxs)(`div`,{className:`session-tree-segment relative flex min-w-[220px] flex-col items-center ${e.active?` active`:``}`,children:[(0,Z.jsx)(`div`,{className:`session-tree-track before:absolute before:z-[0] before:top-[22px] before:bottom-[22px] before:left-[50%] before:w-[2px] before:rounded-[var(--r-pill)] before:bg-[var(--stroke)] before:[content:''] before:[transform:translateX(-1px)] [.session-tree-segment.active_>_&::before]:bg-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] relative z-[1] grid w-[220px] gap-[8px]`,children:c?(0,Z.jsx)(`div`,{className:`relative w-[220px]`,style:{height:`${l.getTotalSize()}px`},children:l.getVirtualItems().map(e=>(0,Z.jsx)(`div`,{className:`absolute top-0 left-0 w-[220px]`,style:{top:`${e.start-26}px`},children:u(o[e.index])},e.key))}):o.map(u)}),s.length>0&&(0,Z.jsx)(`div`,{className:`session-tree-children before:absolute before:top-0 before:left-[50%] before:w-[2px] before:h-[14px] before:rounded-[var(--r-pill)] before:bg-[var(--stroke)] before:[content:''] before:[transform:translateX(-1px)] [.session-tree-segment.active_>_&::before]:bg-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] relative flex items-start justify-center [margin-top:0] [padding-top:28px]`,children:s.map(e=>(0,Z.jsx)(`div`,{className:`session-tree-child before:absolute before:top-0 before:w-[50%] before:h-[14px] before:[border-top:2px_solid_var(--stroke)] before:[content:''] after:absolute after:top-0 after:w-[50%] after:h-[14px] after:[border-top:2px_solid_var(--stroke)] after:[content:''] before:right-[50%] after:left-[50%] after:[border-left:2px_solid_var(--stroke)] [&:first-child::before]:[border-top-color:transparent] [&:last-child::after]:[border-top-color:transparent] [&.active::before]:border-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] [&.active::after]:border-[color-mix(in_srgb,var(--brand-blue)_64%,var(--stroke))] [&.active:first-child::before]:[border-top-color:transparent] [&.active:last-child::after]:[border-top-color:transparent] relative flex [padding:14px_12px_0]${e.active?` active`:``}`,children:(0,Z.jsx)(Vo,{segment:e,viewportRef:t,selectedId:n,typeLabel:r,stateLabel:i,onSelect:a})},e.id))})]})}function Ho({view:e,onViewChange:t,query:n,onQueryChange:r,loading:i,error:a,mobileLayout:o,viewportRef:s,segments:c,visibleNodes:l,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p,visibleMarks:m,marksLoading:h,openingMark:g,onOpenMark:_}){let{t:v,language:y}=x(),b=e=>{let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(y,{dateStyle:`medium`,timeStyle:`short`}).format(t):v(`navigation:appOverlays.unknownTime`)};return(0,Z.jsxs)(`div`,{className:`chat-resource-browser flex min-h-0 min-w-0 flex-col bg-transparent session-tree-browser`,children:[(0,Z.jsx)(lt,{className:`chat-resource-tabs w-full [padding:12px_12px_0] session-tree-tabs [&_[data-slot='tabs-list']]:grid [&_[data-slot='tabs-list']]:h-[36px] [&_[data-slot='tabs-list']]:w-full [&_[data-slot='tabs-list']]:grid-cols-[repeat(4,minmax(0,1fr))] [&_[data-slot='tabs-list']]:[border:1px_solid_var(--stroke-soft)] [&_[data-slot='tabs-list']]:rounded-[var(--r-sm)] [&_[data-slot='tabs-list']]:bg-[var(--surface-muted)] [&_[data-slot='tabs-trigger']]:min-w-0 [&_[data-slot='tabs-trigger']]:gap-[5px] [&_[data-slot='tabs-trigger']]:rounded-[var(--r-xs)] [&_[data-slot='tabs-trigger']]:[padding-inline:6px] [&_[data-slot='tabs-trigger']]:text-[11px] [&_[data-slot='tabs-trigger'][data-state='active']]:bg-[var(--solid)] [&_[data-slot='tabs-trigger'][data-state='active']]:text-[var(--text)]`,value:e,onValueChange:e=>t(e),children:(0,Z.jsxs)(Ze,{children:[(0,Z.jsx)($e,{value:`conversation`,children:v(`chat:sessionTree.conversation`)}),(0,Z.jsx)($e,{value:`labeled`,children:v(`chat:sessionTree.labeled`)}),(0,Z.jsx)($e,{value:`all`,children:v(`chat:sessionTree.all`)}),(0,Z.jsx)($e,{value:`marks`,children:v(`chat:sessionTree.allMarks`)})]})}),(0,Z.jsxs)(`label`,{className:`chat-resource-search [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_2px_var(--focus-ring)] [&_input]:w-full [&_input]:h-[36px] [&_input]:border-0 [&_input]:[outline:0]! [&_input]:bg-transparent [&_input]:text-[var(--text)] [&_input]:text-[13px] flex items-center gap-[7px] [margin-top:8px] [border:1px_solid_var(--stroke)] rounded-[var(--r-sm)] [padding:0_10px] text-[var(--text-muted)] flex-none [margin:8px_12px_0] bg-[var(--solid)]`,children:[(0,Z.jsx)(dt,{size:15}),(0,Z.jsx)(`input`,{value:n,disabled:!!g,onChange:e=>r(e.target.value),placeholder:v(`chat:sessionTree.searchPlaceholder`)})]}),e===`marks`?(0,Z.jsxs)(`div`,{className:`flex min-w-0 min-h-0 [flex:1_1_0] flex-col gap-[8px] overflow-auto [overscroll-behavior:contain] [padding:12px_14px]`,"data-testid":`session-tree-marks-list`,children:[a&&(0,Z.jsx)(`p`,{className:`danger-text [margin:0_2px]`,children:a}),h?(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:v(`chat:sessionTree.loadingMarks`)}):m.length?m.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`session-tree-mark hover:border-[var(--stroke-hover)] hover:bg-[var(--solid)] [&.active]:border-[var(--brand-blue-border)] [&_>_em]:rounded-[var(--r-xs)] [&_>_em]:bg-[var(--brand-blue-soft)] [&_>_em]:text-[var(--brand-blue-strong)] [&_>_em]:p-[2px_6px] [&_>_em]:text-[10px] [&_>_em]:[font-style:normal] grid grid-cols-[30px_minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[color-mix(in_srgb,var(--solid)_94%,transparent)] text-[var(--text)] [padding:8px_10px_8px_4px] text-left cursor-pointer ${e.active?` active`:``}`,disabled:!!g,"aria-busy":g===e,onClick:()=>_(e),children:[(0,Z.jsx)(`span`,{className:`session-tree-marker [.session-tree-node[data-kind='user']_&]:bg-[var(--star-soft)] [.session-tree-node[data-kind='user']_&]:text-[var(--star-strong)] [.session-tree-node[data-kind='assistant']_&]:bg-[var(--brand-blue-soft)] [.session-tree-node[data-kind='assistant']_&]:text-[var(--brand-blue-strong)] [.session-tree-node[data-kind='tool']_&]:bg-[var(--warning-soft)] [.session-tree-node[data-kind='tool']_&]:text-[var(--warning-strong)] [.session-tree-node[data-kind='summary']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='summary']_&]:text-[var(--violet-strong)] [.session-tree-node[data-kind='compaction']_&]:bg-[var(--violet-soft)] [.session-tree-node[data-kind='compaction']_&]:text-[var(--violet-strong)] [.session-tree-node.active_&]:border-[var(--brand-blue-border)] [.session-tree-node.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] [.session-tree-node.leaf_&]:bg-[var(--star)] [.session-tree-node.leaf_&]:text-[var(--on-accent)] [.session-tree-mark.active_&]:border-[var(--brand-blue-border)] [.session-tree-mark.active_&]:shadow-[0_0_0_2px_var(--brand-blue-soft)] relative z-[2] grid w-[26px] h-[26px] place-items-center [justify-self:center] [border:2px_solid_var(--surface-subtle)] rounded-[50%] bg-[var(--surface-muted)] text-[var(--text-muted)]`,children:g===e?(0,Z.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":`true`}):(0,Z.jsx)(K,{size:14})}),(0,Z.jsxs)(`span`,{className:`session-tree-node-copy [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_strong]:font-[650] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] flex min-w-0 flex-col gap-[2px]`,children:[(0,Z.jsx)(`strong`,{children:e.label}),(0,Z.jsx)(`small`,{children:e.sessionName||v(`navigation:appOverlays.untitledChat`)}),(0,Z.jsx)(`small`,{children:v(`chat:sessionTree.markTimes`,{sessionTime:b(e.sessionModified),nodeTime:b(e.nodeTimestamp)})})]}),g===e?(0,Z.jsx)(`em`,{children:v(`chat:sessionTree.navigating`)}):e.active&&(0,Z.jsx)(`em`,{children:v(`chat:sessionTree.markActive`)})]},`${e.sessionId}:${e.entryId}`)):(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:v(`chat:sessionTree.noMarksYet`)})]}):(0,Z.jsx)(`div`,{className:`min-w-0 min-h-0 [flex:1_1_0] overflow-auto [overscroll-behavior:contain] [scrollbar-gutter:stable]`,"data-testid":`session-tree-list`,ref:s,children:c.length>0?o?(0,Z.jsx)(Bo,{nodes:l,viewportRef:s,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p}):(0,Z.jsx)(`div`,{className:`session-tree-canvas flex w-[max-content] min-w-[100%] items-start justify-center gap-[36px] [padding:26px_28px_48px]`,children:c.map(e=>(0,Z.jsx)(Vo,{segment:e,viewportRef:s,selectedId:u,typeLabel:d,stateLabel:f,onSelect:p},e.id))}):(0,Z.jsx)(`p`,{className:`grid min-h-[180px] place-items-center text-[var(--text-muted)] text-[12px]`,children:i?v(`chat:sessionTree.loading`):a||v(`chat:sessionTree.empty`)})})]})}function Uo({mobileLayout:e,selected:t,loading:n,error:r,streaming:i,dataStreaming:a,parentSession:o,parentEntryId:s,childSessions:c,canLabel:l,canDerive:u,label:d,summarize:f,savingLabel:p,creatingChild:h,navigating:g,openingRelatedId:_,typeLabel:v,stateLabel:y,onBackToList:b,onLabelChange:S,onSummarizeChange:C,onSaveLabel:w,onRemoveLabel:T,onCreateChild:E,onNavigate:D,onRefresh:O,onOpenRelated:k}){let{t:A,language:j}=x();return(0,Z.jsxs)(`div`,{className:`chat-resource-config flex min-h-0 min-w-0 flex-col gap-[16px] overflow-y-auto [overscroll-behavior:contain] [padding:18px] session-tree-inspector [&_>_p]:m-[auto] [&_>_p]:text-[12px] [&_>_p]:text-[var(--text-muted)] [&_strong]:text-[14px] [&_p]:text-[12px] [&_p]:text-[var(--text-muted)] ${e?`bg-[var(--solid)]`:`[margin:12px_12px_12px_0] rounded-[var(--r-md)] bg-[color-mix(in_srgb,var(--solid)_88%,var(--surface-subtle))] shadow-[0_10px_28px_-26px_var(--shadow)]`}`,children:[e&&(0,Z.jsx)(`div`,{className:`sticky top-0 z-[2] -mx-[6px] -mt-[8px] flex border-b border-[var(--stroke-soft)] bg-[var(--solid)] px-[2px] pb-[8px]`,children:(0,Z.jsxs)(m,{variant:`ghost`,className:`min-h-[40px] justify-start px-[8px]`,onClick:b,children:[(0,Z.jsx)(Nn,{size:17}),A(`chat:sessionTree.backToNodes`)]})}),t?(0,Z.jsxs)(Z.Fragment,{children:[(o||c.length>0)&&(0,Z.jsxs)(`div`,{className:`session-tree-lineage [&_>_strong]:text-[12px] [&_>_strong]:font-[650] [&_button]:justify-start [&_button]:text-left [&_button]:text-[11px] flex flex-col gap-[6px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:12px]`,children:[(0,Z.jsx)(`strong`,{children:A(`chat:sessionTree.conversationLineage`)}),o&&(0,Z.jsxs)(m,{variant:`outline`,disabled:!!_,onClick:()=>k(o,s),children:[(0,Z.jsx)(ft,{size:13}),A(`chat:sessionTree.returnToOriginalChat`,{name:o.name||A(`chat:chatPage.newChat`)})]}),c.map(e=>(0,Z.jsxs)(m,{variant:`outline`,disabled:!!_,onClick:()=>k(e),children:[(0,Z.jsx)(ft,{size:13}),A(`chat:sessionTree.openSeparateChat`,{name:e.name||A(`chat:chatPage.newChat`)})]},e.id))]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`span`,{className:`session-tree-selection-kind [&_em]:rounded-[var(--r-xs)] [&_em]:bg-[var(--brand-blue-soft)] [&_em]:text-[var(--brand-blue-strong)] [&_em]:p-[2px_5px] [&_em]:[font-style:normal] flex items-center justify-between gap-[8px] text-[var(--text-muted)] text-[10px] [text-transform:uppercase]`,children:[v(t),y(t)&&(0,Z.jsx)(`em`,{children:y(t)})]}),(0,Z.jsx)(`strong`,{children:t.label||v(t)}),(0,Z.jsx)(`p`,{children:t.text||A(`chat:sessionTree.noPreview`)})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-inputs [&_label]:grid [&_label]:gap-[5px] [&_label]:text-[12px] [&_label]:font-[600] [&_input[type='checkbox']]:w-[16px] [&_input[type='checkbox']]:h-[16px] [&_input[type='checkbox']]:[accent-color:var(--blue)] flex flex-col gap-[11px]`,children:[l&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`span`,{children:A(`chat:sessionTree.nodeLabel`)}),(0,Z.jsx)(Ne,{value:d,maxLength:80,placeholder:A(`chat:sessionTree.labelPlaceholder`),onChange:e=>S(e.target.value)})]}),(0,Z.jsxs)(m,{variant:`outline`,disabled:p||i||a,onClick:w,children:[(0,Z.jsx)(K,{size:14}),A(p?`chat:sessionTree.savingLabel`:`chat:sessionTree.saveLabel`)]}),!!t.label&&(0,Z.jsxs)(m,{variant:`outline`,disabled:p||i||a,onClick:T,children:[(0,Z.jsx)(Ae,{size:14}),A(`chat:sessionTree.removeLabel`)]})]}),l&&(0,Z.jsxs)(m,{variant:`outline`,disabled:h||i||a,onClick:E,children:[(0,Z.jsx)(qn,{size:14}),A(h?`chat:sessionTree.creatingChildChat`:`chat:sessionTree.createChildChat`)]}),u&&(0,Z.jsxs)(`label`,{className:`session-tree-summary-option [&_small]:[grid-column:1/-1] [&_small]:text-[var(--text-muted)] [&_small]:font-[400] [&_small]:leading-[1.45] grid-cols-[minmax(0,1fr)_auto] items-center`,children:[(0,Z.jsx)(`span`,{children:A(`chat:sessionTree.abandonedBranchSummary`)}),(0,Z.jsx)(`input`,{type:`checkbox`,checked:f,disabled:t.leaf||i||a,onChange:e=>C(e.target.checked)}),(0,Z.jsx)(`small`,{children:A(`chat:sessionTree.abandonedBranchSummaryHint`)})]})]}),u&&(0,Z.jsx)(`p`,{children:A(`chat:sessionTree.sideEffectsRemain`)}),t.timestamp&&(0,Z.jsx)(`p`,{children:new Intl.DateTimeFormat(j,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.timestamp))}),r&&(0,Z.jsx)(`p`,{className:`danger-text`,children:r}),u&&(0,Z.jsxs)(m,{className:`chat-resource-confirm hover:bg-[var(--star-hover)] hover:text-[var(--on-accent)] min-w-[112px] min-h-[36px] self-start bg-[var(--star)] text-[var(--on-accent)] font-[650]`,disabled:g||t.leaf||i||a,onClick:D,children:[(0,Z.jsx)(ne,{size:15}),g?A(`chat:sessionTree.navigating`):t.leaf?A(`chat:sessionTree.currentPosition`):A(`chat:sessionTree.continueFromNode`)]})]}):(0,Z.jsx)(`p`,{children:n?A(`chat:sessionTree.loading`):r||A(`chat:sessionTree.chooseNode`)}),r&&!t&&(0,Z.jsx)(m,{variant:`outline`,onClick:O,children:A(`chat:sessionTree.retry`)})]})}function Wo({open:e,sessionId:t,streaming:n,onClose:r,onNavigated:i,onCreateChildSession:o}){let{t:s,language:c}=x(),l=Ee(),u=E(),d=l||u,[f,p]=(0,X.useState)(null),[h,g]=(0,X.useState)([]),[_,v]=(0,X.useState)(`conversation`),[y,b]=(0,X.useState)(`list`),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(``),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(null),[L,R]=(0,X.useState)(!1),[z,ee]=(0,X.useState)(!1),[te,B]=(0,X.useState)(!1),[V,ne]=(0,X.useState)(!1),[re,ie]=(0,X.useState)(!1),[ae,oe]=(0,X.useState)(``),[se,H]=(0,X.useState)(``),U=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!e||!t)return;let n=!1;return v(`conversation`),b(`list`),C(``),ee(!0),H(``),Promise.all([a.getSessionTree(t),a.listSessions()]).then(([e,t])=>{n||(p(e),g(t.sessions||[]),T(e.leafId||e.nodes[0]?.id||``))}).catch(e=>{n||H($(e))}).finally(()=>{n||ee(!1)}),()=>{n=!0}},[e,t]),(0,X.useEffect)(()=>{e||(p(null),g([]),T(``),b(`list`),O(``),I(null),R(!1),H(``))},[e]),(0,X.useEffect)(()=>{if(!e||_!==`marks`||j)return;let t=!0;return P(!0),H(``),a.listSessionTreeLabels(500).then(e=>{t&&(A(e.labels||[]),M(!0))}).catch(e=>t&&H($(e))).finally(()=>t&&P(!1)),()=>{t=!1}},[e,_,j]);let W=(0,X.useMemo)(()=>{let e=S.trim().toLocaleLowerCase(c);return e?k.filter(t=>`${t.label} ${t.sessionName}`.toLocaleLowerCase(c).includes(e)):k},[k,c,S]),ce=async e=>{if(!F){I(e),H(``);try{e.active||await a.navigateSessionTreeTarget(e.sessionId,e.entryId),Pe(e.sessionId,`open`,e.entryId),r()}catch(e){H($(e)),I(null)}}},le=(0,X.useMemo)(()=>Fo(f?.nodes||[]),[f]),ue=(0,X.useCallback)(e=>({user:s(`chat:sessionTree.userMessage`),assistant:s(`chat:sessionTree.agentMessage`),tool:s(`chat:sessionTree.toolResult`),"tool-call":s(`chat:sessionTree.toolCall`),summary:s(`chat:sessionTree.branchSummary`),compaction:s(`chat:sessionTree.compactionSummary`),settings:s(`chat:sessionTree.settingsChange`),label:s(`chat:sessionTree.labelChange`),position:s(`chat:sessionTree.branchPosition`),extension:s(`chat:sessionTree.extensionEntry`),metadata:s(`chat:sessionTree.metadataEntry`),message:s(`chat:sessionTree.message`)})[e.kind]||e.type,[s]),de=(0,X.useMemo)(()=>{let e=S.trim().toLocaleLowerCase(c);return Lo(le,t=>(_===`conversation`?No.has(t.kind):_!==`labeled`||t.label)?!e||`${t.label} ${t.text} ${ue(t)}`.toLocaleLowerCase(c).includes(e):!1)},[le,c,S,ue,_]),fe=(0,X.useMemo)(()=>de.map(Ro),[de]),pe=(0,X.useMemo)(()=>Io(de),[de]),G=(0,X.useMemo)(()=>Io(le),[le]).find(e=>e.id===w)||null,me=f?.lineage?.parentSessionId?h.find(e=>e.id===f.lineage?.parentSessionId):null,he=(f?.lineage?.childSessionIds||[]).map(e=>h.find(t=>t.id===e)).filter(e=>!!e),ge=G?.kind===`assistant`&&G.status===`completed`,_e=ge,ve=G?!Po.has(G.kind):!1;(0,X.useEffect)(()=>{O(G?.label||``),R(!1)},[G?.id,G?.label]),(0,X.useEffect)(()=>{if(w&&pe.some(e=>e.id===w))return;let e=[...pe].reverse().find(e=>e.active);T(e?.id||pe[0]?.id||``)},[w,pe]),(0,X.useEffect)(()=>{if(!e||!w)return;let t=requestAnimationFrame(()=>{document.querySelector(`[data-testid="session-tree-list"] .session-tree-node.selected`)?.scrollIntoView({block:`center`})});return()=>cancelAnimationFrame(t)},[e,S,w,_,pe.length]);let ye=async()=>{ee(!0),H(``);try{let e=await a.getSessionTree(t);p(e),T(e.leafId||e.nodes[0]?.id||``)}catch(e){H($(e))}finally{ee(!1)}},be=async()=>{if(!(!G||te)){B(!0),H(``);try{p(await a.setSessionTreeLabel(t,G.id,D))}catch(e){H($(e))}finally{B(!1)}}},xe=async()=>{if(!(!G||te)){B(!0),H(``);try{p(await a.setSessionTreeLabel(t,G.id,``))}catch(e){H($(e))}finally{B(!1)}}},Se=async()=>{if(!(!G||!_e||re)){ie(!0),H(``);try{await o(G.id),r()}catch(e){H($(e))}finally{ie(!1)}}},Ce=async(e,t=``)=>{if(!(!e.id||ae)){oe(e.id),H(``);try{t&&await a.navigateSessionTreeTarget(e.id,t),Pe(e.id,`open`,t),r()}catch(e){H($(e))}finally{oe(``)}}},we=async()=>{if(!(!G||V||G.leaf||n||f?.streaming)){ne(!0),H(``);try{let e=await a.navigateSessionTree(t,G.id,L);p(e),e.cancelled||(await i(e.editorText),r())}catch(e){H($(e))}finally{ne(!1)}}},Te=e=>e.leaf?s(`chat:sessionTree.current`):e.branchPoint?s(`chat:sessionTree.fork`):e.active?s(`chat:sessionTree.active`):``;return(0,Z.jsx)(rt,{open:e,onOpenChange:e=>!e&&r(),children:(0,Z.jsxs)(Fe,{className:`chat-resource-dialog grid-rows-[auto_minmax(0,1fr)] overflow-hidden session-tree-dialog ${d?`!h-[calc(100dvh_-_16px)] !w-[calc(100vw_-_16px)] !max-w-none !gap-0 !p-0`:`!h-[min(760px,calc(100dvh_-_32px))] !w-[min(1120px,calc(100vw_-_32px))] !max-w-[1120px]`}`,showCloseButton:!1,children:[(0,Z.jsxs)(`div`,{className:`chat-resource-head flex items-start justify-between gap-[16px] [border-bottom:1px_solid_var(--stroke-soft)] session-tree-head [&_[data-slot='dialog-description']]:mt-[3px] [&_[data-slot='dialog-description']]:text-[12px] [&_[data-slot='dialog-title']]:text-[16px] ${d?`p-[14px]`:`[padding:17px_18px_14px]`}`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`session-tree-title [&_>_span]:grid [&_>_span]:w-[30px] [&_>_span]:h-[30px] [&_>_span]:place-items-center [&_>_span]:rounded-[var(--r-sm)] [&_>_span]:bg-[var(--success-soft)] [&_>_span]:text-[var(--success)] flex items-center gap-[9px]`,children:[(0,Z.jsx)(`span`,{children:(0,Z.jsx)(rr,{size:17})}),(0,Z.jsx)(Ke,{children:s(`chat:sessionTree.title`)})]}),(0,Z.jsx)(tt,{children:s(`chat:sessionTree.description`,{nodes:f?.nodeCount||0,branches:f?.branchCount||0})})]}),(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":s(`common:ui.closeDialog`),title:s(`common:ui.closeDialog`),onClick:r,children:(0,Z.jsx)(Me,{size:17})})]}),(0,Z.jsxs)(`div`,{className:`chat-resource-body grid min-h-0 overflow-hidden bg-[var(--surface-subtle)] session-tree-layout ${d?`grid-cols-1 grid-rows-[minmax(0,1fr)]`:`!grid-cols-[minmax(0,1fr)_292px]`}`,children:[(!d||y===`list`)&&(0,Z.jsx)(Ho,{view:_,onViewChange:e=>{v(e),b(`list`)},query:S,onQueryChange:C,loading:z,error:se,mobileLayout:d,viewportRef:U,segments:fe,visibleNodes:pe,selectedId:w,typeLabel:ue,stateLabel:Te,onSelect:e=>{T(e),d&&b(`detail`)},visibleMarks:W,marksLoading:N,openingMark:F,onOpenMark:e=>void ce(e)}),_!==`marks`&&(!d||y===`detail`)&&(0,Z.jsx)(Uo,{mobileLayout:d,selected:G,loading:z,error:se,streaming:n,dataStreaming:!!f?.streaming,parentSession:me??null,parentEntryId:f?.lineage?.sourceEntryId||``,childSessions:he,canLabel:ge,canDerive:ve,label:D,summarize:L,savingLabel:te,creatingChild:re,navigating:V,openingRelatedId:ae,typeLabel:ue,stateLabel:Te,onBackToList:()=>b(`list`),onLabelChange:O,onSummarizeChange:R,onSaveLabel:()=>void be(),onRemoveLabel:()=>void xe(),onCreateChild:()=>void Se(),onNavigate:()=>void we(),onRefresh:()=>void ye(),onOpenRelated:(e,t)=>void Ce(e,t??``)})]})]})})}function Go({visible:e,open:t,sessionId:n,streaming:r,revision:i,pulseToken:o,onOpenChange:s,onNavigated:c,onCreateChildSession:l}){let{t:u}=x(),[d,f]=(0,X.useState)(0),[p,h]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!o)return;h(!0);let e=window.setTimeout(()=>h(!1),1800);return()=>window.clearTimeout(e)},[o]),(0,X.useEffect)(()=>{if(!e||r)return;let t=!0;return a.getSessionTree(n).then(e=>t&&f(e.branchCount||0)).catch(()=>{}),()=>{t=!1}},[i,n,r,e]),e?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(m,{type:`button`,variant:`ghost`,size:`icon`,className:`focus-session-tree-entry hover:border-[var(--brand-blue-border)] hover:bg-[var(--solid)] hover:text-[var(--brand-blue-strong)] [&_>_span]:text-[11px] [&_>_span]:font-[650] [&_>_span]:whitespace-nowrap [&_i]:grid [&_i]:min-w-[17px] [&_i]:h-[17px] [&_i]:place-items-center [&_i]:rounded-[var(--r-pill)] [&_i]:bg-[var(--brand-blue-soft)] [&_i]:text-[var(--brand-blue-strong)] [&_i]:p-[0_4px] [&_i]:text-[9px] [&_i]:[font-style:normal] [&_i]:[font-variant-numeric:tabular-nums] absolute z-[6] [top:12px] [right:18px] inline-flex w-auto min-w-[32px] h-[32px] items-center gap-[6px] [border:1px_solid_var(--stroke)] rounded-[var(--r-pill)] bg-[color-mix(in_srgb,var(--solid)_90%,transparent)] text-[var(--text-muted)] [padding:0_10px_0_8px] shadow-[var(--sh-1)] [backdrop-filter:blur(10px)] motion-reduce:[animation:none] ${p?`[animation:session-tree-new-node-pulse_1.8s_var(--ease-out)]`:``}`,title:u(`chat:sessionTree.menuDescription`),"data-pisper-recall-pulse":p||void 0,"aria-label":u(`chat:sessionTree.menu`),"aria-haspopup":`dialog`,"aria-expanded":t,onClick:()=>s(!0),children:[(0,Z.jsx)(rr,{size:16}),(0,Z.jsx)(`span`,{children:u(`chat:sessionTree.menu`)}),d>0&&(0,Z.jsx)(`i`,{children:d})]}),(0,Z.jsx)(Wo,{open:t,sessionId:n,streaming:r,onClose:()=>s(!1),onNavigated:c,onCreateChildSession:l})]}):null}function Ko(e){return[`running`,`waiting_approval`].includes(String(e.status||``))}function qo(e,t){return t(e===`running`?`chat:workflowRun.running`:e===`waiting_approval`?`chat:workflowRun.waitingApproval`:e===`completed`?`chat:workflowRun.completed`:e===`failed`?`chat:workflowRun.failed`:e===`cancelled`?`chat:workflowRun.stopped`:`chat:workflowRun.interrupted`)}function Jo({sessionId:e}){let{t}=x(),[n,r]=(0,X.useState)([]),[i,o]=(0,X.useState)(``),s=(0,X.useCallback)(async()=>{try{let t=await a.getSessionWorkflowRuns(e);r(t.runs||[])}catch{}},[e]);return(0,X.useEffect)(()=>{s();let e=window.setInterval(s,1500);return()=>window.clearInterval(e)},[s]),n.length?(0,Z.jsx)(`div`,{className:`flex max-h-[210px] flex-col gap-[5px] overflow-auto`,children:[...n].sort((e,t)=>Date.parse(t.startedAt)-Date.parse(e.startedAt)).slice(0,5).map(e=>{let n=i===e.id,r=Math.round((Number(e.completedNodes)||0)/Math.max(1,Number(e.totalNodes)||1)*100);return(0,Z.jsxs)(`div`,{className:`session-workflow-run [&.failed]:border-[color-mix(in_srgb,var(--danger)_40%,var(--stroke-soft))] [&.waiting_approval]:border-[color-mix(in_srgb,var(--warning)_45%,var(--stroke-soft))] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-sm)] bg-[var(--solid)] ${e.status}`,children:[(0,Z.jsxs)(`button`,{className:`session-workflow-summary [&_>_span:nth-child(2)]:flex [&_>_span:nth-child(2)]:min-w-0 [&_>_span:nth-child(2)]:flex-col [&_>_span:nth-child(2)]:gap-[1px] [&_strong]:overflow-hidden [&_strong]:text-ellipsis [&_strong]:whitespace-nowrap [&_small]:overflow-hidden [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_strong]:text-[12px] [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_[data-slot='progress']]:h-[4px] max-[650px]:grid-cols-[28px_minmax(0,1fr)_16px] max-[650px]:[&_[data-slot='progress']]:[grid-column:2/4] grid w-full grid-cols-[28px_minmax(120px,1fr)_minmax(80px,160px)_16px] items-center gap-[9px] border-0 bg-transparent [padding:7px_9px] text-[var(--text)] text-left cursor-pointer`,onClick:()=>o(n?``:e.id),children:[(0,Z.jsx)(`span`,{className:`list-icon [.chat-resource-list_&]:grid [.chat-resource-list_&]:w-[28px] [.chat-resource-list_&]:h-[28px] [.chat-resource-list_&]:place-items-center [.chat-resource-list_&]:rounded-[var(--r-sm)] [.chat-resource-list_&]:bg-[var(--surface-subtle)] [.chat-resource-list_&]:text-[var(--star-strong)] [.session-workflow-summary_&]:grid [.session-workflow-summary_&]:w-[28px] [.session-workflow-summary_&]:h-[28px] [.session-workflow-summary_&]:place-items-center [.session-workflow-summary_&]:rounded-[var(--r-sm)] [.session-workflow-summary_&]:bg-[var(--surface-subtle)] [.session-workflow-summary_&]:text-[var(--star-strong)] grid w-[27px] h-[27px] place-items-center rounded-[var(--r-sm)] bg-[var(--accent-soft)] text-[var(--star-strong)] [.workflow-template-gallery_&]:grid [.workflow-template-gallery_&]:w-[32px] [.workflow-template-gallery_&]:h-[32px] [.workflow-template-gallery_&]:place-items-center [.workflow-template-gallery_&]:rounded-[var(--r-sm)] [.workflow-template-gallery_&]:bg-[var(--surface-subtle)] [.workflow-template-gallery_&]:text-[var(--star-strong)]`,children:(0,Z.jsx)(Te,{size:14})}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:e.workflowName}),(0,Z.jsxs)(`small`,{children:[qo(e.status,t),` · v`,e.workflowRevision||1]})]}),(0,Z.jsx)(ie,{value:e.status===`completed`?100:r}),n?(0,Z.jsx)(pe,{size:14}):(0,Z.jsx)(Ie,{size:14})]}),n&&(0,Z.jsxs)(`div`,{className:`session-workflow-detail [&_>_p]:text-[var(--text-muted)] [&_>_p]:text-[11px] max-[650px]:pl-[12px] flex flex-col gap-[5px] [border-top:1px_solid_var(--stroke-soft)] [padding:7px_9px_9px_46px]`,children:[e.sourceMessage&&(0,Z.jsxs)(`div`,{className:`session-workflow-context [&_strong]:text-[var(--text-muted)] [&_strong]:text-[10px] [&_strong]:[text-transform:uppercase] [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:m-0 [&_p]:text-[var(--text-secondary)] [&_p]:text-[11px] [&_p]:leading-[1.45] [&_p]:whitespace-pre-wrap [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:m-0 [&_pre]:text-[var(--text-secondary)] [&_pre]:text-[11px] [&_pre]:leading-[1.45] [&_pre]:whitespace-pre-wrap [&_pre]:[overflow-wrap:anywhere] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--surface-subtle)] [&_pre]:p-[5px_6px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] grid min-w-0 gap-[3px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:6px]`,children:[(0,Z.jsx)(`strong`,{children:t(`chat:workflowRun.request`)}),(0,Z.jsx)(`p`,{children:e.sourceMessage})]}),e.inputs&&Object.keys(e.inputs).length>0&&(0,Z.jsxs)(`div`,{className:`session-workflow-context [&_strong]:text-[var(--text-muted)] [&_strong]:text-[10px] [&_strong]:[text-transform:uppercase] [&_p]:max-h-[84px] [&_p]:overflow-auto [&_p]:m-0 [&_p]:text-[var(--text-secondary)] [&_p]:text-[11px] [&_p]:leading-[1.45] [&_p]:whitespace-pre-wrap [&_p]:[overflow-wrap:anywhere] [&_pre]:max-h-[84px] [&_pre]:overflow-auto [&_pre]:m-0 [&_pre]:text-[var(--text-secondary)] [&_pre]:text-[11px] [&_pre]:leading-[1.45] [&_pre]:whitespace-pre-wrap [&_pre]:[overflow-wrap:anywhere] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--surface-subtle)] [&_pre]:p-[5px_6px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] grid min-w-0 gap-[3px] [border-bottom:1px_solid_var(--stroke-soft)] [padding-bottom:6px]`,children:[(0,Z.jsx)(`strong`,{children:t(`chat:workflowRun.inputs`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(e.inputs,null,2)})]}),(e.nodes||[]).map(n=>(0,Z.jsxs)(`div`,{className:`session-workflow-node [&.completed]:text-[var(--success)] [&.failed]:text-[var(--danger)] [&_>_span]:flex [&_>_span]:min-w-0 [&_>_span]:flex-col [&_strong]:text-[var(--text)] [&_strong]:text-[11px] [&_small]:overflow-hidden [&_small]:text-[var(--text-muted)] [&_small]:text-[10px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_>_div]:flex [&_>_div]:gap-[4px] grid grid-cols-[15px_minmax(0,1fr)_auto] items-center gap-[6px] min-h-[24px] text-[var(--text-muted)] ${n.status}`,children:[n.status===`completed`?(0,Z.jsx)(fe,{size:13}):n.status===`failed`?(0,Z.jsx)(re,{size:13}):n.status===`running`?(0,Z.jsx)(q,{className:`animate-spin`,size:13}):(0,Z.jsx)(ke,{size:11}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:n.label}),(n.error||n.summary)&&(0,Z.jsx)(`small`,{children:n.error||n.summary})]}),n.status===`waiting_approval`&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(m,{size:`xs`,onClick:async()=>{await a.resolveWorkflowApproval(e.id,n.id,!0),await s()},children:t(`chat:workflowRun.approve`)}),(0,Z.jsx)(m,{size:`xs`,variant:`destructive`,onClick:async()=>{await a.resolveWorkflowApproval(e.id,n.id,!1),await s()},children:t(`chat:workflowRun.reject`)})]})]},n.id)),(e.error||e.summary)&&(0,Z.jsx)(`p`,{children:e.error||e.summary}),Ko(e)&&(0,Z.jsxs)(m,{size:`xs`,variant:`destructive`,onClick:async()=>{await a.stopWorkflowRun(e.id),await s()},children:[(0,Z.jsx)(ke,{"data-icon":`inline-start`}),t(`chat:workflowRun.stop`)]})]})]},e.id)})}):null}(0,X.lazy)(()=>i(()=>import(`./ClickSpark-BhxL8WOQ.js`).then(e=>({default:e.ClickSpark})),__vite__mapDeps([30,1,2,3,4,6])));var Yo=(0,X.createContext)(null),Xo=({className:e,approval:t,state:n,...r})=>{let i=(0,X.useMemo)(()=>({approval:t,state:n}),[t,n]);return!t||n===`input-streaming`||n===`input-available`?null:(0,Z.jsx)(Yo.Provider,{value:i,children:(0,Z.jsx)(St,{className:ce(`flex flex-col gap-2`,e),...r})})};function Zo({approvals:e,onResolve:t,compact:n=!1}){let{t:r}=x(),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(!1),l=e[0];if((0,X.useEffect)(()=>s(!1),[l?.id]),!l)return null;let u=l.fileChange,d=typeof u?.diff==`string`?u.diff:``,f=async e=>{if(!c.current){c.current=!0,a(!0);try{await t(l.id,e)}finally{c.current=!1,a(!1)}}};return(0,Z.jsxs)(Xo,{approval:{id:l.id},state:`approval-requested`,className:`tool-approval [&_>_div:first-child]:flex [&_>_div:first-child]:min-w-0 [&_>_div:first-child]:items-center [&_>_div:first-child]:gap-[8px] [&_>_div:first-child_>_span]:flex [&_>_div:first-child_>_span]:min-w-0 [&_>_div:first-child_>_span]:flex-col [&_>_div:first-child_>_span]:gap-[2px] [&_strong]:text-[13px] [&_small]:overflow-hidden [&_small]:text-[13px] [&_small]:text-ellipsis [&_small]:whitespace-nowrap [&_details]:min-w-0 [&_details]:text-[13px] [&_summary]:cursor-pointer [&_pre]:max-h-[130px] [&_pre]:overflow-auto [&_pre]:mt-[6px] [&_pre]:rounded-[var(--r-xs)] [&_pre]:bg-[var(--warning-code-bg)] [&_pre]:text-[var(--warning-soft)] [&_pre]:p-[8px] [&_pre]:font-[ui-monospace,_SFMono-Regular,_Consolas,_'Liberation_Mono',_monospace] [&_pre]:text-[13px] [&_pre]:whitespace-pre-wrap [&.compact]:grid-cols-[minmax(0,1fr)_auto] [&.compact]:p-[6px_7px] [&.compact_strong]:text-[13px] [&.compact_small]:text-[13px] grid grid-cols-[minmax(0,1fr)_auto] items-center gap-[8px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--warning-soft)] text-[var(--warning-strong)] [padding:9px_10px] ${n?`compact`:``}`,"data-pisper-approval-id":l.id,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(Oe,{size:n?12:15}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{children:r(`chat:focusSession.toolRequestsApproval`,{tool:l.toolName})}),(0,Z.jsxs)(`small`,{children:[l.reason,e.length>1?` · ${r(`chat:focusSession.countMoreWaiting`,{count:e.length-1})}`:``]})]})]}),!n&&(0,Z.jsxs)(`div`,{className:`flex [grid-column:1/-1] items-center gap-[10px]`,children:[d&&(0,Z.jsxs)(`button`,{type:`button`,className:`tool-approval-view-diff hover:border-[var(--accent-border)] hover:bg-[var(--accent-soft)] hover:text-[var(--star-strong)] inline-flex min-h-[28px] flex-none items-center gap-[6px] [border:1px_solid_var(--warning-border)] rounded-[var(--r-sm)] bg-[var(--surface-muted)] [padding:4px_7px] text-[var(--text-secondary)] text-[12px] font-[600] cursor-pointer`,onClick:()=>s(!0),children:[(0,Z.jsx)(Ln,{size:13}),r(`chat:focusSession.gitViewDiff`)]}),(0,Z.jsxs)(`details`,{children:[(0,Z.jsx)(`summary`,{children:r(`chat:focusSession.viewCallArguments`)}),(0,Z.jsx)(`pre`,{children:JSON.stringify(l.args,null,2)})]})]}),(0,Z.jsxs)(`div`,{className:`flex gap-[5px]`,children:[(0,Z.jsx)(m,{type:`button`,variant:`outline`,size:`lg`,className:`bg-surface-subtle`,disabled:i,onClick:()=>f(!1),children:r(`chat:focusSession.deny`)}),(0,Z.jsxs)(m,{type:`button`,size:`lg`,disabled:i,onClick:()=>f(!0),children:[i?(0,Z.jsx)(q,{className:`animate-spin`,size:12}):(0,Z.jsx)(fe,{size:12}),r(`chat:focusSession.allow`)]})]}),o&&(0,Z.jsx)(wo,{diff:d,truncated:!!u?.truncated,onClose:()=>s(!1)})]})}function Qo({notify:e,onOpenModelSettings:t,onInsertPrompt:n}){let{t:r}=x(),i=async()=>{try{let i=await u(`/api/visual/models`);i.image||i.video?n(r(`chat:focusSession.visualPromptTemplate`)):(e?.(r(`chat:focusSession.configureVisualModelFirst`)),t?.())}catch{n(r(`chat:focusSession.visualPromptTemplate`))}};return(0,Z.jsx)(`button`,{type:`button`,className:`visual-entry-trigger [.focus-composer_&]:h-[38px] [.focus-composer_&]:border-0 [.focus-composer_&]:rounded-[var(--r-sm)] [.focus-composer_&]:bg-[var(--surface-subtle)] [.focus-composer_&]:text-[12px] [.focus-composer_&]:w-[38px] [.focus-composer_&]:min-w-[38px] [.focus-session.has-conversation_.focus-composer_&]:w-[36px] [.focus-session.has-conversation_.focus-composer_&]:min-w-[36px] [.focus-session.has-conversation_.focus-composer_&]:h-[36px] relative grid place-items-center border-0 rounded-[var(--r-xs)] bg-transparent text-[var(--text-muted)] cursor-pointer hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)]`,title:r(`chat:focusSession.generateImage`),"aria-label":r(`chat:focusSession.generateImage`),onClick:()=>void i(),children:(0,Z.jsx)(Hn,{size:16})})}function $o(e){return(e.target instanceof Element?e.target:null)?.closest(`[data-shortcut-recorder], [role="dialog"], [role="alertdialog"], [role="menu"], [role="listbox"], .xterm, .terminal-xterm, .terminal-panel, [data-terminal]`)?!0:Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>e.getClientRects().length>0)}function es(e){let t=(0,X.useRef)(e);t.current=e;let{enabled:n,binding:r}=e;(0,X.useEffect)(()=>{if(!n||!r)return;let e=null,i=null,a=()=>{e=null,i&&(i=null,t.current.onCancel())},o=n=>{if(i&&n.key===`Escape`&&!n.isComposing){a(),n.preventDefault();return}!t.current.enabled||n.defaultPrevented||n.isComposing||n.keyCode===229||n.repeat||e||document.visibilityState===`hidden`||$o(n)||!gt(n,r)||(e=n.code,t.current.onStart()&&(i={code:n.code,ctrl:n.ctrlKey,meta:n.metaKey,alt:n.altKey,shift:n.shiftKey},n.preventDefault()))},s=n=>{n.code===e&&(e=null),i&&(n.code===i.code||i.ctrl&&(!n.ctrlKey||n.code.startsWith(`Control`))||i.meta&&(!n.metaKey||n.code.startsWith(`Meta`))||i.alt&&(!n.altKey||n.code.startsWith(`Alt`))||i.shift&&(!n.shiftKey||n.code.startsWith(`Shift`)))&&(i=null,t.current.onRelease())},c=()=>{document.visibilityState===`hidden`&&a()};return window.addEventListener(`keydown`,o),window.addEventListener(`keyup`,s,!0),window.addEventListener(`blur`,a),document.addEventListener(`visibilitychange`,c),()=>{window.removeEventListener(`keydown`,o),window.removeEventListener(`keyup`,s,!0),window.removeEventListener(`blur`,a),document.removeEventListener(`visibilitychange`,c),a()}},[n,r])}function ts(e){if(!e.length)return 0;let t=0;for(let n=0;n<e.length;n+=1)t+=e[n]*e[n];let n=Math.sqrt(t/e.length);return n<.0056?0:Math.min(1,Math.sqrt(n)*2.6)}function ns(e=.35){let t=0;return{push(n){return t=t*(1-e)+n*e,t},reset(){t=0}}}function rs(e,t=140){let n=e.trim();return n.length>t?`${n.slice(0,t-1)}…`:n}var is=16e3,as=20,os=is*as/1e3;function ss(e,{onsetMs:t=80,minVoicedMs:n=160,silenceMs:r=900}={}){for(let e of[t,n,r])if(!Number.isFinite(e)||e<=0)throw Error(`Invalid VAD endpoint duration`);let i=e(),a=new Int16Array(os),o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=()=>u&&c*as>=n;return{get hasSpeech(){return p()},acceptPcm(e){if(f||d)return!1;for(let n=0;n<e.length;n+=1){let f=Number.isFinite(e[n])?Math.max(-1,Math.min(1,e[n])):0;if(a[o++]=f*(f<0?32768:32767),o!==os)continue;o=0;let m=i.processFrame(a);if(m<0)throw Error(`VAD frame processing failed`);if(m===1)s+=1,c+=1,l=0,s*as>=t&&(u=!0);else if(s=0,l+=1,u||(c=0),l*as>=r){if(p())return d=!0,!0;u=!1,c=0}}return!1},reset(){f||(i.destroy(),i=e(),o=s=c=l=0,u=d=!1,a.fill(0))},dispose(){f||(f=!0,o=0,i.destroy())}}}async function cs(e={}){let{default:t,VADMode:n}=await i(async()=>{let{default:e,VADMode:t}=await import(`./embedded-D2rqyswH.js`);return{default:e,VADMode:t}},[]),r=await t();return ss(()=>new r(e.mode??n.AGGRESSIVE,is),e)}var ls=()=>new DOMException(`Speech setup cancelled.`,`AbortError`);function us(e){let[t,n]=(0,X.useState)(null),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1),[c,l]=(0,X.useState)(``),u=(0,X.useRef)(null),d=(0,X.useRef)(!1),f=(0,X.useRef)(0),p=(0,X.useRef)(0),m=(0,X.useRef)(0),h=(0,X.useRef)(e);h.current=e;let g=(0,X.useCallback)(e=>{f.current++,p.current++;let t=u.current;u.current=null,t&&(t.signal.removeEventListener(`abort`,t.abort),e?t.reject(e):t.resolve()),d.current&&(i(!1),o(!1))},[]),_=(0,X.useCallback)(e=>{d.current&&(n(e),l(``),u.current&&Pt(e,h.current).every(e=>e.status===`installed`)&&g())},[g]),v=(0,X.useCallback)(async e=>{let t=f.current,n=++p.current,r=()=>d.current&&t===f.current&&n===p.current&&!e?.aborted;try{let t=await Dt(e);r()&&_(t)}catch(e){if(r())throw e}},[_]);(0,X.useEffect)(()=>(d.current=!0,v().catch(()=>{}),()=>{d.current=!1,g(ls())}),[g,v]),(0,X.useEffect)(()=>{if(!r)return;let e=new AbortController,t,n=async()=>{try{await v(e.signal)}catch(t){e.signal.aborted||l(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||(t=setTimeout(()=>void n(),750))}};return n(),()=>{e.abort(),clearTimeout(t)}},[r,v]);let y=(0,X.useCallback)(async e=>{if(s(e),!d.current)throw ls();g(ls());let t=++p.current;return new Promise((n,r)=>{let a=()=>{u.current===o&&g(e.reason||ls())},o={signal:e,abort:a,resolve:n,reject:r};if(u.current=o,e.addEventListener(`abort`,a,{once:!0}),e.aborted){a();return}Dt(e).then(n=>{!d.current||u.current!==o||e.aborted||(t===p.current&&_(n),u.current===o&&i(!0))},e=>{u.current===o&&g(e)})})},[_,g]),b=(0,X.useCallback)(async e=>{let t=f.current,n=++m.current,r=()=>d.current&&t===f.current&&n===m.current;o(!0),l(``);try{await e(),r()&&await v()}catch(e){r()&&l(e instanceof Error?e.message:String(e))}finally{r()&&o(!1)}},[v]);return{catalog:t,open:r,loading:a,error:c,selectedVoice:t?.defaults.voice||``,ensureReady:y,models:t?Pt(t,e):[],show:()=>{g(ls()),i(!0),l(``)},close:()=>g(ls()),download:e=>b(()=>Mt(e)),cancelDownload:e=>b(()=>jt(e)),downloadAll:()=>b(async()=>{if(t)for(let e of Pt(t,h.current))[`installed`,`downloading`,`verifying`].includes(e.status)||await Mt(e.id)})}}var ds=8388608;function fs(e,t){return s(t),new Promise((n,r)=>{let i=()=>r(c(t));t.addEventListener(`abort`,i,{once:!0}),e.then(n,r).finally(()=>t.removeEventListener(`abort`,i))})}var ps=10,ms=500;async function hs(e,t,n,r){for(let i=0;;i+=1){let a=await fetch(`/api/speech/synthesize`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e,voiceId:t,requestId:n}),signal:r});if(a.status!==409||i>=ps)return a;let o=await a.json().catch(()=>({}));if(!o.error||!/busy/i.test(o.error))return a;await fs(new Promise(e=>setTimeout(e,ms)),r)}}async function gs(e){if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Speech synthesis failed (${e.status}).`)}if(!e.headers.get(`content-type`)?.startsWith(`audio/wav`)||!e.body)throw Error(`Invalid speech audio response.`);let t=e.body.getReader(),n=[],r=0;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;if(r+=i.byteLength,r>ds)throw Error(`Speech audio exceeds the supported limit.`);n.push(i)}}finally{await t.cancel().catch(()=>{}),t.releaseLock()}if(r<44)throw Error(`Speech audio is empty.`);let i=new Uint8Array(r),a=0;for(let e of n)i.set(e,a),a+=e.length;return i.buffer}async function _s(e,t,n,r){s(n);let i=o(n);try{await vs(e,t,i,r)}finally{i.abort(new DOMException(`Speech playback ended.`,`AbortError`)),i.dispose()}}async function vs(e,t,n,r){let{signal:a}=n,{speechSegments:c}=await fs(i(()=>import(`./speech-text-Js_tr4qo.js`),__vite__mapDeps([31,32,1,2,11,4,33,34,35])),a);s(a);let l=(typeof e==`string`?(async function*(){yield*c(e)})():(await fs(i(()=>import(`./speech-stream-text-Bf0UhZti.js`),__vite__mapDeps([36,14,32,1,2,11,4,33,34,35,31])),a)).streamingSpeechSegments(e,a))[Symbol.asyncIterator](),d=!!window.__PISPER_MOBILE_APP__,f=new Set,p,m,h,g=e=>{(d?kt(`mobile_cancel_speech`,{requestId:e}):u(`/api/speech/cancel`,{method:`POST`,body:{requestId:e},timeout:3e3})).catch(()=>{})},_=()=>{for(let e of f)g(e);try{m?.stop()}catch{}h?.(a.reason||new DOMException(`Speech playback cancelled.`,`AbortError`))};a.addEventListener(`abort`,_,{once:!0});let v=e=>{s(a);let n=crypto.randomUUID();f.add(n);let r=(async()=>{if(d){let r=await kt(`mobile_synthesize_speech`,{text:e,voiceId:t,requestId:n});if(a.aborted&&(g(n),s(a)),!r||typeof r.audioId!=`string`||!r.audioId.trim()||r.audioId.length>128||!Number.isInteger(r.sampleRate)||r.sampleRate<8e3||r.sampleRate>48e3||!Number.isFinite(r.durationMs)||r.durationMs<=0||r.durationMs>45e3)throw Error(`Invalid native speech audio.`);return{requestId:n,native:r}}let r=o(a,6e4);try{let i=await hs(e,t,n,r.signal);return{requestId:n,wav:await gs(i)}}finally{r.dispose()}})();return r.catch(()=>{}),r};try{if(!d){p=new AudioContext({sampleRate:24e3});let e;try{await fs(Promise.race([p.resume(),new Promise((t,n)=>{e=setTimeout(()=>n(Error(`Audio playback is unavailable.`)),5e3)})]),a)}finally{clearTimeout(e)}}let e=async()=>{let e=await fs(l.next(),a);return e.done?void 0:v(e.value)},t=e(),n=!1;for(;;){let i=await fs(t,a);if(s(a),!i)break;if(t=e(),t.catch(()=>{}),n=!0,r?.(),i.native){if((await fs(kt(`mobile_play_speech`,{audioId:i.native.audioId,requestId:i.requestId}),a))?.completed!==!0)throw Error(`Speech playback was interrupted.`)}else{let e=await fs(p.decodeAudioData(i.wav),a);if(s(a),e.numberOfChannels!==1||!Number.isFinite(e.duration)||e.duration<=0||e.duration>45)throw Error(`Invalid speech audio duration.`);let t=p.createBufferSource();m=t,t.buffer=e,t.connect(p.destination);try{await new Promise((e,n)=>{h=n,t.onended=()=>e(),t.start()})}finally{h=void 0,t.onended=null,t.disconnect(),m=void 0}}f.delete(i.requestId),s(a)}if(!n)throw Error(`The reply has no speakable text.`)}finally{a.removeEventListener(`abort`,_),n.abort(new DOMException(`Speech playback ended.`,`AbortError`)),l.return?.(void 0).catch(()=>{});for(let e of f)g(e);try{m?.stop()}catch{}await p?.close().catch(()=>{})}}var ys={schemaVersion:1,scope:`Offline license texts and provenance notices for the catalogued speech resources and local derivatives. This document is not legal advice, commercial-use clearance, a complete training-data rights audit, or approval for redistribution or formal release. Packaging this small notice file does not package the large models or resolve pending obligations. Native sherpa binaries and their compiled or embedded dependencies require a separate license/linkage and source-delivery audit; switching TTS models does not prove the binaries contain no GPL components or satisfy their obligations.`,licenseIdsMeaning:`References identify retained license documents applicable to the described components or their stated source projects. Multiple references are not alternative dual-license choices and are not a complete SPDX expression. A repository declaration does not relicense unrelated bundled data.`,statusDefinitions:{confirmed:`The specific content or source match described in summary was verified; this is not a whole-chain rights guarantee.`,declared:`An upstream license declaration supports the classification, without a complete reproducible provenance proof.`,pending:`The listed provenance, rights, or distribution obligations remain unresolved even where a license declaration exists.`},pathScopes:{model:`Paths are relative to the original downloaded model root. A terminal /** matches every descendant; all other paths are exact.`,shared:`Paths are relative to the application's shared resource root.`},licenses:[{id:`apache-2.0`,name:`Apache License 2.0 (X-ASR source text)`,text:` Apache License
8
+ Version 2.0, January 2004
9
+ http://www.apache.org/licenses/
10
+
11
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
12
+
13
+ 1. Definitions.
14
+
15
+ "License" shall mean the terms and conditions for use, reproduction,
16
+ and distribution as defined by Sections 1 through 9 of this document.
17
+
18
+ "Licensor" shall mean the copyright owner or entity authorized by
19
+ the copyright owner that is granting the License.
20
+
21
+ "Legal Entity" shall mean the union of the acting entity and all
22
+ other entities that control, are controlled by, or are under common
23
+ control with that entity. For the purposes of this definition,
24
+ "control" means (i) the power, direct or indirect, to cause the
25
+ direction or management of such entity, whether by contract or
26
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
27
+ outstanding shares, or (iii) beneficial ownership of such entity.
28
+
29
+ "You" (or "Your") shall mean an individual or Legal Entity
30
+ exercising permissions granted by this License.
31
+
32
+ "Source" form shall mean the preferred form for making modifications,
33
+ including but not limited to software source code, documentation
34
+ source, and configuration files.
35
+
36
+ "Object" form shall mean any form resulting from mechanical
37
+ transformation or translation of a Source form, including but
38
+ not limited to compiled object code, generated documentation,
39
+ and conversions to other media types.
40
+
41
+ "Work" shall mean the work of authorship, whether in Source or
42
+ Object form, made available under the License, as indicated by a
43
+ copyright notice that is included in or attached to the work
44
+ (an example is provided in the Appendix below).
45
+
46
+ "Derivative Works" shall mean any work, whether in Source or Object
47
+ form, that is based on (or derived from) the Work and for which the
48
+ editorial revisions, annotations, elaborations, or other modifications
49
+ represent, as a whole, an original work of authorship. For the purposes
50
+ of this License, Derivative Works shall not include works that remain
51
+ separable from, or merely link (or bind by name) to the interfaces of,
52
+ the Work and Derivative Works thereof.
53
+
54
+ "Contribution" shall mean any work of authorship, including
55
+ the original version of the Work and any modifications or additions
56
+ to that Work or Derivative Works thereof, that is intentionally
57
+ submitted to Licensor for inclusion in the Work by the copyright owner
58
+ or by an individual or Legal Entity authorized to submit on behalf of
59
+ the copyright owner. For the purposes of this definition, "submitted"
60
+ means any form of electronic, verbal, or written communication sent
61
+ to the Licensor or its representatives, including but not limited to
62
+ communication on electronic mailing lists, source code control systems,
63
+ and issue tracking systems that are managed by, or on behalf of, the
64
+ Licensor for the purpose of discussing and improving the Work, but
65
+ excluding communication that is conspicuously marked or otherwise
66
+ designated in writing by the copyright owner as "Not a Contribution."
67
+
68
+ "Contributor" shall mean Licensor and any individual or Legal Entity
69
+ on behalf of whom a Contribution has been received by Licensor and
70
+ subsequently incorporated within the Work.
71
+
72
+ 2. Grant of Copyright License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ copyright license to reproduce, prepare Derivative Works of,
76
+ publicly display, publicly perform, sublicense, and distribute the
77
+ Work and such Derivative Works in Source or Object form.
78
+
79
+ 3. Grant of Patent License. Subject to the terms and conditions of
80
+ this License, each Contributor hereby grants to You a perpetual,
81
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
82
+ (except as stated in this section) patent license to make, have made,
83
+ use, offer to sell, sell, import, and otherwise transfer the Work,
84
+ where such license applies only to those patent claims licensable
85
+ by such Contributor that are necessarily infringed by their
86
+ Contribution(s) alone or by combination of their Contribution(s)
87
+ with the Work to which such Contribution(s) was submitted. If You
88
+ institute patent litigation against any entity (including a
89
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
90
+ or a Contribution incorporated within the Work constitutes direct
91
+ or contributory patent infringement, then any patent licenses
92
+ granted to You under this License for that Work shall terminate
93
+ as of the date such litigation is filed.
94
+
95
+ 4. Redistribution. You may reproduce and distribute copies of the
96
+ Work or Derivative Works thereof in any medium, with or without
97
+ modifications, and in Source or Object form, provided that You
98
+ meet the following conditions:
99
+
100
+ (a) You must give any other recipients of the Work or
101
+ Derivative Works a copy of this License; and
102
+
103
+ (b) You must cause any modified files to carry prominent notices
104
+ stating that You changed the files; and
105
+
106
+ (c) You must retain, in the Source form of any Derivative Works
107
+ that You distribute, all copyright, patent, trademark, and
108
+ attribution notices from the Source form of the Work,
109
+ excluding those notices that do not pertain to any part of
110
+ the Derivative Works; and
111
+
112
+ (d) If the Work includes a "NOTICE" text file as part of its
113
+ distribution, then any Derivative Works that You distribute must
114
+ include a readable copy of the attribution notices contained
115
+ within such NOTICE file, excluding those notices that do not
116
+ pertain to any part of the Derivative Works, in at least one
117
+ of the following places: within a NOTICE text file distributed
118
+ as part of the Derivative Works; within the Source form or
119
+ documentation, if provided along with the Derivative Works; or,
120
+ within a display generated by the Derivative Works, if and
121
+ wherever such third-party notices normally appear. The contents
122
+ of the NOTICE file are for informational purposes only and
123
+ do not modify the License. You may add Your own attribution
124
+ notices within Derivative Works that You distribute, alongside
125
+ or as an addendum to the NOTICE text from the Work, provided
126
+ that such additional attribution notices cannot be construed
127
+ as modifying the License.
128
+
129
+ You may add Your own copyright statement to Your modifications and
130
+ may provide additional or different license terms and conditions
131
+ for use, reproduction, or distribution of Your modifications, or
132
+ for any such Derivative Works as a whole, provided Your use,
133
+ reproduction, and distribution of the Work otherwise complies with
134
+ the conditions stated in this License.
135
+
136
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
137
+ any Contribution intentionally submitted for inclusion in the Work
138
+ by You to the Licensor shall be under the terms and conditions of
139
+ this License, without any additional terms or conditions.
140
+ Notwithstanding the above, nothing herein shall supersede or modify
141
+ the terms of any separate license agreement you may have executed
142
+ with Licensor regarding such Contributions.
143
+
144
+ 6. Trademarks. This License does not grant permission to use the trade
145
+ names, trademarks, service marks, or product names of the Licensor,
146
+ except as required for reasonable and customary use in describing the
147
+ origin of the Work and reproducing the content of the NOTICE file.
148
+
149
+ 7. Disclaimer of Warranty. Unless required by applicable law or
150
+ agreed to in writing, Licensor provides the Work (and each
151
+ Contributor provides its Contributions) on an "AS IS" BASIS,
152
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
153
+ implied, including, without limitation, any warranties or conditions
154
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
155
+ PARTICULAR PURPOSE. You are solely responsible for determining the
156
+ appropriateness of using or redistributing the Work and assume any
157
+ risks associated with Your exercise of permissions under this License.
158
+
159
+ 8. Limitation of Liability. In no event and under no legal theory,
160
+ whether in tort (including negligence), contract, or otherwise,
161
+ unless required by applicable law (such as deliberate and grossly
162
+ negligent acts) or agreed to in writing, shall any Contributor be
163
+ liable to You for damages, including any direct, indirect, special,
164
+ incidental, or consequential damages of any character arising as a
165
+ result of this License or out of the use or inability to use the
166
+ Work (including but not limited to damages for loss of goodwill,
167
+ work stoppage, computer failure or malfunction, or any and all
168
+ other commercial damages or losses), even if such Contributor
169
+ has been advised of the possibility of such damages.
170
+
171
+ 9. Accepting Warranty or Additional Liability. While redistributing
172
+ the Work or Derivative Works thereof, You may choose to offer,
173
+ and charge a fee for, acceptance of support, warranty, indemnity,
174
+ or other liability obligations and/or rights consistent with this
175
+ License. However, in accepting such obligations, You may act only
176
+ on Your own behalf and on Your sole responsibility, not on behalf
177
+ of any other Contributor, and only if You agree to indemnify,
178
+ defend, and hold each Contributor harmless for any liability
179
+ incurred by, or claims asserted against, such Contributor by reason
180
+ of your accepting any such warranty or additional liability.
181
+
182
+ END OF TERMS AND CONDITIONS
183
+
184
+ APPENDIX: How to apply the Apache License to your work.
185
+
186
+ To apply the Apache License to your work, attach the following
187
+ boilerplate notice, with the fields enclosed by brackets "[]"
188
+ replaced with your own identifying information. (Don't include
189
+ the brackets!) The text should be enclosed in the appropriate
190
+ comment syntax for the file format. We also recommend that a
191
+ file or class name and description of purpose be included on the
192
+ same "printed page" as the copyright notice for easier
193
+ identification within third-party archives.
194
+
195
+ Copyright [yyyy] [name of copyright owner]
196
+
197
+ Licensed under the Apache License, Version 2.0 (the "License");
198
+ you may not use this file except in compliance with the License.
199
+ You may obtain a copy of the License at
200
+
201
+ http://www.apache.org/licenses/LICENSE-2.0
202
+
203
+ Unless required by applicable law or agreed to in writing, software
204
+ distributed under the License is distributed on an "AS IS" BASIS,
205
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
206
+ See the License for the specific language governing permissions and
207
+ limitations under the License.
208
+ `,sourceUrl:`https://raw.githubusercontent.com/Gilgamesh-J/X-ASR/838297cd47fed858e6cf72eaf5a52f948a3edd73/LICENSE`,sha256:`c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4`},{id:`mit-melo`,name:`MIT License (MeloTTS source and conversion package)`,text:`Copyright (c) 2024 MyShell.ai
209
+
210
+ Permission is hereby granted, free of charge, to any person obtaining a copy
211
+ of this software and associated documentation files (the "Software"), to deal
212
+ in the Software without restriction, including without limitation the rights
213
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
214
+ copies of the Software, and to permit persons to whom the Software is
215
+ furnished to do so, subject to the following conditions:
216
+
217
+ The above copyright notice and this permission notice shall be included in all
218
+ copies or substantial portions of the Software.
219
+
220
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
222
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
224
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
225
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
226
+ SOFTWARE.`,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{id:`apache-2.0-sherpa`,name:`Apache License 2.0 (sherpa conversion code; FST source declaration)`,text:`
227
+ Apache License
228
+ Version 2.0, January 2004
229
+ http://www.apache.org/licenses/
230
+
231
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
232
+
233
+ 1. Definitions.
234
+
235
+ "License" shall mean the terms and conditions for use, reproduction,
236
+ and distribution as defined by Sections 1 through 9 of this document.
237
+
238
+ "Licensor" shall mean the copyright owner or entity authorized by
239
+ the copyright owner that is granting the License.
240
+
241
+ "Legal Entity" shall mean the union of the acting entity and all
242
+ other entities that control, are controlled by, or are under common
243
+ control with that entity. For the purposes of this definition,
244
+ "control" means (i) the power, direct or indirect, to cause the
245
+ direction or management of such entity, whether by contract or
246
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
247
+ outstanding shares, or (iii) beneficial ownership of such entity.
248
+
249
+ "You" (or "Your") shall mean an individual or Legal Entity
250
+ exercising permissions granted by this License.
251
+
252
+ "Source" form shall mean the preferred form for making modifications,
253
+ including but not limited to software source code, documentation
254
+ source, and configuration files.
255
+
256
+ "Object" form shall mean any form resulting from mechanical
257
+ transformation or translation of a Source form, including but
258
+ not limited to compiled object code, generated documentation,
259
+ and conversions to other media types.
260
+
261
+ "Work" shall mean the work of authorship, whether in Source or
262
+ Object form, made available under the License, as indicated by a
263
+ copyright notice that is included in or attached to the work
264
+ (an example is provided in the Appendix below).
265
+
266
+ "Derivative Works" shall mean any work, whether in Source or Object
267
+ form, that is based on (or derived from) the Work and for which the
268
+ editorial revisions, annotations, elaborations, or other modifications
269
+ represent, as a whole, an original work of authorship. For the purposes
270
+ of this License, Derivative Works shall not include works that remain
271
+ separable from, or merely link (or bind by name) to the interfaces of,
272
+ the Work and Derivative Works thereof.
273
+
274
+ "Contribution" shall mean any work of authorship, including
275
+ the original version of the Work and any modifications or additions
276
+ to that Work or Derivative Works thereof, that is intentionally
277
+ submitted to Licensor for inclusion in the Work by the copyright owner
278
+ or by an individual or Legal Entity authorized to submit on behalf of
279
+ the copyright owner. For the purposes of this definition, "submitted"
280
+ means any form of electronic, verbal, or written communication sent
281
+ to the Licensor or its representatives, including but not limited to
282
+ communication on electronic mailing lists, source code control systems,
283
+ and issue tracking systems that are managed by, or on behalf of, the
284
+ Licensor for the purpose of discussing and improving the Work, but
285
+ excluding communication that is conspicuously marked or otherwise
286
+ designated in writing by the copyright owner as "Not a Contribution."
287
+
288
+ "Contributor" shall mean Licensor and any individual or Legal Entity
289
+ on behalf of whom a Contribution has been received by Licensor and
290
+ subsequently incorporated within the Work.
291
+
292
+ 2. Grant of Copyright License. Subject to the terms and conditions of
293
+ this License, each Contributor hereby grants to You a perpetual,
294
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
295
+ copyright license to reproduce, prepare Derivative Works of,
296
+ publicly display, publicly perform, sublicense, and distribute the
297
+ Work and such Derivative Works in Source or Object form.
298
+
299
+ 3. Grant of Patent License. Subject to the terms and conditions of
300
+ this License, each Contributor hereby grants to You a perpetual,
301
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
302
+ (except as stated in this section) patent license to make, have made,
303
+ use, offer to sell, sell, import, and otherwise transfer the Work,
304
+ where such license applies only to those patent claims licensable
305
+ by such Contributor that are necessarily infringed by their
306
+ Contribution(s) alone or by combination of their Contribution(s)
307
+ with the Work to which such Contribution(s) was submitted. If You
308
+ institute patent litigation against any entity (including a
309
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
310
+ or a Contribution incorporated within the Work constitutes direct
311
+ or contributory patent infringement, then any patent licenses
312
+ granted to You under this License for that Work shall terminate
313
+ as of the date such litigation is filed.
314
+
315
+ 4. Redistribution. You may reproduce and distribute copies of the
316
+ Work or Derivative Works thereof in any medium, with or without
317
+ modifications, and in Source or Object form, provided that You
318
+ meet the following conditions:
319
+
320
+ (a) You must give any other recipients of the Work or
321
+ Derivative Works a copy of this License; and
322
+
323
+ (b) You must cause any modified files to carry prominent notices
324
+ stating that You changed the files; and
325
+
326
+ (c) You must retain, in the Source form of any Derivative Works
327
+ that You distribute, all copyright, patent, trademark, and
328
+ attribution notices from the Source form of the Work,
329
+ excluding those notices that do not pertain to any part of
330
+ the Derivative Works; and
331
+
332
+ (d) If the Work includes a "NOTICE" text file as part of its
333
+ distribution, then any Derivative Works that You distribute must
334
+ include a readable copy of the attribution notices contained
335
+ within such NOTICE file, excluding those notices that do not
336
+ pertain to any part of the Derivative Works, in at least one
337
+ of the following places: within a NOTICE text file distributed
338
+ as part of the Derivative Works; within the Source form or
339
+ documentation, if provided along with the Derivative Works; or,
340
+ within a display generated by the Derivative Works, if and
341
+ wherever such third-party notices normally appear. The contents
342
+ of the NOTICE file are for informational purposes only and
343
+ do not modify the License. You may add Your own attribution
344
+ notices within Derivative Works that You distribute, alongside
345
+ or as an addendum to the NOTICE text from the Work, provided
346
+ that such additional attribution notices cannot be construed
347
+ as modifying the License.
348
+
349
+ You may add Your own copyright statement to Your modifications and
350
+ may provide additional or different license terms and conditions
351
+ for use, reproduction, or distribution of Your modifications, or
352
+ for any such Derivative Works as a whole, provided Your use,
353
+ reproduction, and distribution of the Work otherwise complies with
354
+ the conditions stated in this License.
355
+
356
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
357
+ any Contribution intentionally submitted for inclusion in the Work
358
+ by You to the Licensor shall be under the terms and conditions of
359
+ this License, without any additional terms or conditions.
360
+ Notwithstanding the above, nothing herein shall supersede or modify
361
+ the terms of any separate license agreement you may have executed
362
+ with Licensor regarding such Contributions.
363
+
364
+ 6. Trademarks. This License does not grant permission to use the trade
365
+ names, trademarks, service marks, or product names of the Licensor,
366
+ except as required for reasonable and customary use in describing the
367
+ origin of the Work and reproducing the content of the NOTICE file.
368
+
369
+ 7. Disclaimer of Warranty. Unless required by applicable law or
370
+ agreed to in writing, Licensor provides the Work (and each
371
+ Contributor provides its Contributions) on an "AS IS" BASIS,
372
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
373
+ implied, including, without limitation, any warranties or conditions
374
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
375
+ PARTICULAR PURPOSE. You are solely responsible for determining the
376
+ appropriateness of using or redistributing the Work and assume any
377
+ risks associated with Your exercise of permissions under this License.
378
+
379
+ 8. Limitation of Liability. In no event and under no legal theory,
380
+ whether in tort (including negligence), contract, or otherwise,
381
+ unless required by applicable law (such as deliberate and grossly
382
+ negligent acts) or agreed to in writing, shall any Contributor be
383
+ liable to You for damages, including any direct, indirect, special,
384
+ incidental, or consequential damages of any character arising as a
385
+ result of this License or out of the use or inability to use the
386
+ Work (including but not limited to damages for loss of goodwill,
387
+ work stoppage, computer failure or malfunction, or any and all
388
+ other commercial damages or losses), even if such Contributor
389
+ has been advised of the possibility of such damages.
390
+
391
+ 9. Accepting Warranty or Additional Liability. While redistributing
392
+ the Work or Derivative Works thereof, You may choose to offer,
393
+ and charge a fee for, acceptance of support, warranty, indemnity,
394
+ or other liability obligations and/or rights consistent with this
395
+ License. However, in accepting such obligations, You may act only
396
+ on Your own behalf and on Your sole responsibility, not on behalf
397
+ of any other Contributor, and only if You agree to indemnify,
398
+ defend, and hold each Contributor harmless for any liability
399
+ incurred by, or claims asserted against, such Contributor by reason
400
+ of your accepting any such warranty or additional liability.
401
+
402
+ END OF TERMS AND CONDITIONS
403
+
404
+ APPENDIX: How to apply the Apache License to your work.
405
+
406
+ To apply the Apache License to your work, attach the following
407
+ boilerplate notice, with the fields enclosed by brackets "[]"
408
+ replaced with your own identifying information. (Don't include
409
+ the brackets!) The text should be enclosed in the appropriate
410
+ comment syntax for the file format. We also recommend that a
411
+ file or class name and description of purpose be included on the
412
+ same "printed page" as the copyright notice for easier
413
+ identification within third-party archives.
414
+
415
+ Copyright [yyyy] [name of copyright owner]
416
+
417
+ Licensed under the Apache License, Version 2.0 (the "License");
418
+ you may not use this file except in compliance with the License.
419
+ You may obtain a copy of the License at
420
+
421
+ http://www.apache.org/licenses/LICENSE-2.0
422
+
423
+ Unless required by applicable law or agreed to in writing, software
424
+ distributed under the License is distributed on an "AS IS" BASIS,
425
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
426
+ See the License for the specific language governing permissions and
427
+ limitations under the License.
428
+ `,sourceUrl:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`},{id:`mit-cppjieba`,name:`MIT License (CppJieba release source)`,text:`The MIT License (MIT)
429
+
430
+ Copyright (c) 2013
431
+
432
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
433
+ this software and associated documentation files (the "Software"), to deal in
434
+ the Software without restriction, including without limitation the rights to
435
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
436
+ the Software, and to permit persons to whom the Software is furnished to do so,
437
+ subject to the following conditions:
438
+
439
+ The above copyright notice and this permission notice shall be included in all
440
+ copies or substantial portions of the Software.
441
+
442
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
443
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
444
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
445
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
446
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
447
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
448
+ `,sourceUrl:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{id:`mit-pypinyin`,name:`MIT License (pypinyin project; historical data provenance pending)`,text:`The MIT License (MIT)
449
+
450
+ Copyright (c) 2016 mozillazg, 闲耘 <hotoo.cn@gmail.com>
451
+
452
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
453
+ this software and associated documentation files (the "Software"), to deal in
454
+ the Software without restriction, including without limitation the rights to
455
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
456
+ the Software, and to permit persons to whom the Software is furnished to do so,
457
+ subject to the following conditions:
458
+
459
+ The above copyright notice and this permission notice shall be included in all
460
+ copies or substantial portions of the Software.
461
+
462
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
463
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
464
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
465
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
466
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
467
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
468
+ `,sourceUrl:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{id:`cmudict-0.6-1998`,name:`CMU Pronouncing Dictionary 0.6 historical permission and attribution notice (1998)`,text:`## Date: August 8, 1998
469
+ ##
470
+ ## The Carnegie Mellon Pronouncing Dictionary [cmudict.0.6] is Copyright 1998
471
+ ## by Carnegie Mellon University. Use of this dictionary, for any research or
472
+ ## commercial purpose, is completely unrestricted. If you make use of or
473
+ ## redistribute this material, we would appreciate acknowlegement of its
474
+ ## origin.
475
+ ##
476
+ ## cmudict.0.6 is the fifth release of cmudict, first released as cmudict.0.1
477
+ ## in September of 1993. There was no generally available public release
478
+ ## of version 0.5.
479
+ ##
480
+ ## See the README in this directory before you use this dictionary.
481
+ ##
482
+ ## Thanks to Bill Huggins at BBN; Bill Fisher at NIST; Alex Hauptman,
483
+ ## Alex Rudnicky, Jack Mostow, Roni Rosenfeld, Richard Stern,
484
+ ## Matthew Siegler, Kevin Lenzo, Maxine Eskenazi, Mosur Ravishankar,
485
+ ## Eric Thayer, Kristie Seymore, and Raj Reddy at CMU; Lin Chase at
486
+ ## LIMSI; Doug Paul at MIT Lincoln Labs; Ben Serridge at MIT SLS; Murray
487
+ ## Spiegel at Bellcore; Tony Robinson at Cambridge UK; David Bowness of
488
+ ## CAE Electronics Ltd. and CRIM; Stephen Hocking; Jerry Quinn at BNR
489
+ ## Canada, and Marshal Midden for bringing to our attention problems and
490
+ ## inadequacies with the first releases. Most special thanks to Bob Weide
491
+ ## for all his work on prior versions of the dictionary.
492
+ ##
493
+ ## We welcome input from users and will continue to acknowledge such input
494
+ ## in subsequent releases. If I failed to acknowledge your input in this
495
+ ## release, please remind me and I will update these comments. If I failed to
496
+ ## fix things that you brought to my attention, please remind me and have
497
+ ## patience. If I actually fixed things that you brought to my attention and
498
+ ## you appreciate it, I wouldn't mind a pat on the back.
499
+ ##
500
+ ## This version differs from previous releases of cmudict most significantly
501
+ ## in the addition of new words from the common ARPA tasks for 1996 and 1997.
502
+ ##
503
+ ## There are undoubtedly still errors and inconsistencies in this dictionary
504
+ ## so keep your eyes open for problems and mail them to me.
505
+ ##
506
+ ## We hope this dictionary is an improvement over cmudict.0.4.
507
+ ##
508
+ ## email: cmudict@cs.cmu.edu
509
+ ## web: http://www.speech.cs.cmu.edu/cgi-bin/cmudict
510
+ ## ftp: ftp://ftp.cs.cmu.edu/project/speech/dict/
511
+ ##
512
+ ## Thank you for your continued interest in the CMU Pronouncing
513
+ ## Dictionary. Further addictions and improvements are planned
514
+ ## for forthcoming releases.
515
+ ##
516
+ `,sourceUrl:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`08ee91f3c05c55160bdc599247ba53e5de8cc2597766fdb22b54a81cb24dd954`}],models:[{id:`x-asr-480ms-int8`,revision:`2026-06-05`,attribution:`X-ASR by Gilgamesh-J / GilgameshWind; trained using icefall and deployed with sherpa-onnx. The locked HF model card expressly covers model artifacts and declares Apache-2.0. The separately discovered GitHub license commit is not the locked HF revision. No root LICENSE or NOTICE was listed in the inspected HF tree; this is not proof that every historical distribution lacks NOTICE. Retain applicable upstream notices when found.`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-x-asr-480ms-streaming-zipformer-transducer-zh-en-punct-int8-2026-06-05.tar.bz2`,sha256:`fa5f63d618e5a01526e275a358bb7772e403f84808a4769fba52cffd8160bf74`},groups:[{id:`xasr-weights`,pathScope:`model`,paths:[`encoder.int8.onnx`,`decoder.onnx`,`joiner.int8.onnx`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Apache-2.0 is explicitly declared for X-ASR model artifacts. The sherpa export script describes icefall streaming ONNX export and INT8 quantization; installed file hashes match the catalog, but the 2026-06-05 archive-to-checkpoint/build identity is not established.`,pendingReasons:[`Exact checkpoint and source commits used to build the 2026-06-05 INT8 archive remain unverified; the export script downloads moving main URLs. Training-data rights are not fully audited.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR token resource, not the SentencePiece or sherpa software. The punctuation export block downloads X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/tokens.txt. Catalog content SHA256: b818a60878b9aae978cbb8ad594acbd403d76d1af2e31ef4197c84e2dbdba27c.`,pendingReasons:[`The historical source revision for the token file in the 2026-06-05 archive is not pinned by the export script.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe`,pathScope:`model`,paths:[`bpe.model`],licenseIds:[`apache-2.0`],status:`pending`,summary:`X-ASR BPE resource. The export script renames X-ASR-zh-en/zipformer/data/lang_5000_with_punctuation/bpe_punc.model to bpe.model. Its license classification comes from X-ASR, not from the software that reads the SentencePiece format.`,pendingReasons:[`The historical BPE source commit and exact archive build provenance remain unverified.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/v1.13.7/scripts/zipformer-transducer/x-asr/export-streaming.sh`,sha256:`63b018fe72a29e9a41c6d4e358085b5ad1614e021c0d9f3c05a2d11f1dff0d81`}]},{id:`xasr-bpe-vocab`,pathScope:`shared`,paths:[`speech-resources/xasr-bpe.vocab`],licenseIds:[`apache-2.0`],status:`pending`,summary:`Modified by Pisper: extracted the ordered SentencePiece pieces and scores as UTF-8 piece<TAB>score<LF> lines. This local text derivative retains the source resource license classification; it is not newly licensed as Pisper-owned model data. Original and derived hashes and generator are bound by xasr-bpe-extraction below.`,pendingReasons:[`The source BPE historical provenance remains pending as described in xasr-bpe. A text extraction does not resolve upstream rights.`],evidence:[{url:`https://hf-mirror.com/GilgameshWind/X-ASR-zh-en/resolve/689ff18c584d29910da37b6fe904db0c1489c9d1/README.md`,sha256:`7acc6f439d3e39e46de4298ccf8a8f6a483fdc5f9f5d08e61422b63760ec37b1`}]}],modifications:[{id:`xasr-bpe-extraction`,groupIds:[`xasr-bpe-vocab`],modifiedBy:`Pisper`,summary:`Local BPE text extraction, not retraining. The generator identity records the inspected repository implementation, not a claim about a historical upstream build date.`,source:{path:`bpe.model`,bytes:119265,sha256:`f87a38025a5fdd1e4e9591f6a44bb81295097ce0b80df6f4ab9f44e52c64ca5f`},derived:{path:`speech-resources/xasr-bpe.vocab`,bytes:61562,sha256:`01381aa0c3065832cb8d7462d529e3079a99be56c955ce93b4cb9b78e8aa34e5`},generator:{path:`scripts/speech-bpe.mjs`,sha256:`a1c85731aa3e0be89f04acc79830db784a9d43edb8af9f4fb723bb45bd725786`,method:`sentencePieceModelToVocab decodes ordered protobuf ModelProto.pieces and emits each piece, a tab, its finite score, and a newline without changing the BPE model.`}}]},{id:`vits-melo-tts-zh_en`,revision:`a0d5c6a264c0ef92d70d8661d8cc502d79627cd6`,archive:{url:`https://github.com/k2-fsa/sherpa-onnx/releases/download/tts-models/vits-melo-tts-zh_en.tar.bz2`,bytes:167006755,sha256:`e58351ed7149f290a54534538badd4077cdbe6fddc964b24d0bee870415d1514`},attribution:`MeloTTS by MyShell.ai; sherpa-onnx ONNX conversion. The retained software license is Copyright (c) 2024 MyShell.ai, MIT. The neural-weight repository separately declares MIT; dictionary and FST resources have separate declarations and pending provenance. Pisper selects the original single female voice via public sid 0 and uses the same original FP32 ONNX, tokens, mixed-language lexicon, dictionary and normalization files on Desktop, Android and iOS. No retraining, quantization, graph/metadata patch or voice-subset derivative is made. The unused new_heteronym.fst and 133-byte model.int8.onnx Git LFS pointer in the transport archive are drained but not installed; retained model files are unchanged. These choices do not imply upstream/speaker endorsement, redistribution approval or completed native-platform acceptance.`,groups:[{id:`melo-weights`,pathScope:`model`,paths:[`model.onnx`],licenseIds:[`mit-melo`],status:`pending`,summary:`The myshell-ai/MeloTTS-Chinese model card at af5d207a364ea4208c6f589c89f57f88414bdd16 declares license: mit for the model repository; this is separate evidence from the MeloTTS software MIT license. The sherpa conversion package carries the exact MyShell.ai MIT text, and original ONNX metadata declares MIT license, melo-vits version 2, Chinese + English, n_speakers=1 and speaker_id=1. The conversion README explicitly describes a single female Chinese+English speaker. sherpa maps public sid 0 to the internal metadata speaker_id; Pisper does not change the graph, metadata or speaker embedding.`,pendingReasons:[`Exact historical checkpoint, training/conversion commits and reproducible archive build identity have not been established; the inspected conversion workflow uses moving upstream references. Training-data permissions, individual speaker consent and applicable personality/publicity rights are not fully audited. The discovered model card revision is evidence of a declaration, not proof of the historical conversion input.`],evidence:[{url:`https://hf-mirror.com/myshell-ai/MeloTTS-Chinese/resolve/af5d207a364ea4208c6f589c89f57f88414bdd16/README.md`,sha256:`40b5b860bacbb3947cbef838719e660d2fe4961eba5b484290b4bedc0253e208`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/run.sh`,sha256:`e2afb98d9028eded2983f780468337fc019a8306db926f89e3bdeed18af867bb`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/sherpa-onnx/csrc/offline-tts-vits-model.cc`,sha256:`060907349036d63b60d035843defe7078b83c8099e0d4de323446c7db0d653d0`}]},{id:`melo-tokens`,pathScope:`model`,paths:[`tokens.txt`],licenseIds:[`mit-melo`,`apache-2.0-sherpa`],status:`declared`,summary:`The sherpa Melo export writes enumerated model.hps symbols to tokens.txt. The original 655-byte token file is retained unchanged. Melo software is MIT; sherpa conversion code is Apache-2.0. These code declarations do not independently establish all underlying training-data rights.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-cppjieba-dictionary`,pathScope:`model`,paths:[`dict/hmm_model.utf8`,`dict/idf.utf8`,`dict/jieba.dict.utf8`,`dict/pos_dict/char_state_tab.utf8`,`dict/pos_dict/prob_emit.utf8`,`dict/pos_dict/prob_start.utf8`,`dict/pos_dict/prob_trans.utf8`,`dict/README.md`,`dict/stop_words.utf8`],licenseIds:[`mit-cppjieba`],status:`confirmed`,summary:`Nine ordinary dictionary/README files are byte-identical to the separately HTTPS-downloaded CppJieba sherpa-onnx-2024-04-19 dict archive. The exact release source MIT license retains Copyright (c) 2013. This confirms the documented source-content match, not a whole-chain data-rights guarantee. The small Melo user.dict.utf8 is separately classified and is NOT the 829194-byte pypinyin-derived user dictionary from that source archive.`,pendingReasons:[],evidence:[{url:`https://ghfast.top/https://github.com/csukuangfj/cppjieba/releases/download/sherpa-onnx-2024-04-19/dict.tar.bz2`,sha256:`35c3877c9b9221a5b2d69bbf57d5dbf1ccbe5b7684c60eb42f93db6b2d494f26`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`}]},{id:`melo-user-dictionary`,pathScope:`model`,paths:[`dict/user.dict.utf8`],licenseIds:[`mit-cppjieba`,`mit-melo`],status:`pending`,summary:`Melo ships an unchanged 49-byte user dictionary containing four entries. It matches the locked Melo HF file but differs from the separately downloaded CppJieba release user dictionary. The package MIT text and CppJieba project MIT declaration are retained as source declarations, not proof that either automatically licenses every edit. This file is not attributed to the unrelated historical pypinyin-derived dictionary.`,pendingReasons:[`The exact historical source commit, modifier and license coverage for this 49-byte replacement have not been identified. Retain applicable modifier notices when established.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://raw.githubusercontent.com/csukuangfj/cppjieba/f03dd931a00330c279c8590275850fd1f6749a18/LICENSE`,sha256:`ba898a14f729ba5e9965da34e3eecd5edd3795f2cc5d7c923b815ba79bb851b0`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://huggingface.co/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/dict/user.dict.utf8`,sha256:`495bbf49270408a1234690e1e6a97328f30a482a7a72aa769e8a12e8714b0c62`}]},{id:`melo-english-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`cmudict-0.6-1998`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The English portion is generated by the sherpa Melo export from melo.text.english.eng_dict and refine_syllables, lowercasing words and adding language tone offsets plus kaldi/SF entries. The inspected Melo source reads cmudict.rep or a cached pickle. cmudict.rep contains its own Copyright 1998 Carnegie Mellon University unrestricted research/commercial permission and attribution notice, retained verbatim in cmudict-0.6-1998. This is NOT a substitution of a modern CMUdict BSD license. The retained notice hash covers the complete original comment header; the evidence hash covers the complete 3969309-byte source file. No package script or pickle was executed.`,pendingReasons:[`The precise historical dictionary/cache inputs and all intervening modifications used for this lexicon have not been pinned or reproduced. Trace cached-data equivalence and retain applicable original and modifier notices.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/english.py`,sha256:`28527f574511bfc13fe1f2f6bbb5bfe4072c06e1c7e9b69598138aef81b9905b`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/melo/text/cmudict.rep`,sha256:`d127b5ce8b8e695732701e8efde04b9b0fa11991218b1fb9d21bd0c9264636aa`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-chinese-lexicon`,pathScope:`model`,paths:[`lexicon.txt`],licenseIds:[`mit-pypinyin`,`mit-melo`,`apache-2.0-sherpa`],status:`pending`,summary:`The Chinese portion is generated by the sherpa Melo export from pypinyin character/phrase dictionaries, lazy_pinyin and the Melo pinyin-to-symbol map. Melo code is MIT, sherpa conversion code Apache-2.0, and pypinyin declares MIT. Those software declarations do not relicense external dictionary inputs. The same 6837671-byte mixed-language lexicon is used unchanged on every platform.`,pendingReasons:[`Pin historical pypinyin versions, character/phrase JSON data and Melo phoneme mapping, reproduce the output and trace the actual underlying source-data terms. No particular Zdic, CC-CEDICT or Unihan license is asserted without proof of the actual input chain.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/scripts/melo-tts/export-onnx.py`,sha256:`c0be7727d59ad6ceaf39e909b4560b57e704091c69ac3fab6f2f2abfd931c916`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/pinyin_dict.py`,sha256:`245c1f70509432b289cde1f938157cd5ff1372d1d083b577d5fab72b4dfcda08`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/pypinyin/phrases_dict.py`,sha256:`3f6f39bbca68d8d1676ea463cd4620b934b03160cc5042fb9d9007b8f3a80b9e`},{url:`https://raw.githubusercontent.com/mozillazg/python-pinyin/8595294b1a97845e30f11ecfdb3caa4e61ac3988/LICENSE.txt`,sha256:`1e6c90014b4912815c296ee64bb6f6280af47e6d4c5d80e86232dfc5defe764c`},{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`}]},{id:`melo-normalization-fsts`,pathScope:`model`,paths:[`date.fst`,`number.fst`,`phone.fst`],licenseIds:[`apache-2.0-sherpa`],status:`pending`,summary:`All three FSTs are byte-identical to the separately downloaded data/date.fst, data/number.fst and data/phone.fst at csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06 revision 57345c004e13ed640e408c4c29ab56187b18f065, the source repository named by the Melo packaging workflow. That source model card declares Apache-2.0; the full Apache text is retained from sherpa. Neither the OpenFst software license nor the Melo neural-weight MIT declaration independently grants rights to these FST data.`,pendingReasons:[`Exact editable generation rules, compiler/source revisions, underlying data provenance and applicable author/modifier notices remain unverified. No standalone FST LICENSE/NOTICE or complete reproducible source chain was found in the inspected source tree.`],evidence:[{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/.github/workflows/export-melo-tts-to-onnx.yaml`,sha256:`fc90fc412fd6f3c8a7d593743372a077dd63b2c8ce0780ed9c3a7e05cc8b659e`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/README.md`,sha256:`98b45ea81164d1e1a1dd82255207053b15cd6c69d922a1c5cf3387ce604d4b74`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/date.fst`,sha256:`eb8aa079ae3cb81d8f4404992f39d61a0cb990947512b5b8d1e54d1f6980e718`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/number.fst`,sha256:`743f402181fcfebf76cc2f0546b71fa26476e626fbe4e460fb7b4c3a7a8bd5bd`},{url:`https://hf-mirror.com/csukuangfj/icefall-tts-aishell3-vits-low-2024-04-06/resolve/57345c004e13ed640e408c4c29ab56187b18f065/data/phone.fst`,sha256:`1ac2b6fa56b1442320c4de7db08353bab8963a2b57f365eebcdd3a2d3562f8d7`},{url:`https://raw.githubusercontent.com/k2-fsa/sherpa-onnx/917bed95c8e5c7c18aa4d69fea42e9ef8ef0a60e/LICENSE`,sha256:`cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30`}]},{id:`melo-package-notices`,pathScope:`model`,paths:[`LICENSE`,`README.md`],licenseIds:[`mit-melo`],status:`confirmed`,summary:`LICENSE is byte-identical to the original MyShell.ai MIT text (Copyright (c) 2024 MyShell.ai), including its exact final newline behavior. README explicitly identifies the single female Chinese+English speaker. The package-level MIT file is not a blanket grant for every bundled dictionary or FST. No upstream NOTICE was listed in the inspected conversion and weight repository trees; this is not proof that none ever existed.`,pendingReasons:[],evidence:[{url:`https://raw.githubusercontent.com/myshell-ai/MeloTTS/209145371cff8fc3bd60d7be902ea69cbdb7965a/LICENSE`,sha256:`88a50e5a02bbc2a5c2f084dc19da751aa97b1690f5fda76cd8005c8634d1ca70`},{url:`https://hf-mirror.com/csukuangfj/vits-melo-tts-zh_en/resolve/a0d5c6a264c0ef92d70d8661d8cc502d79627cd6/README.md`,sha256:`ae6e44dead53dfdbd5b4a77106226f3118eb910222b46cb5533a3860773fc6c7`}]}],modifications:[]}]},bs=ys,xs=e=>ys.models.some(t=>t.id===e);function Ss({modelId:e,modelName:t,returnFocus:n,onClose:r}){let{t:i}=x(),a=bs.models.find(t=>t.id===e);if(!a)return null;let o=new Set(a.groups.flatMap(e=>e.licenseIds)),s=bs.licenses.filter(e=>o.has(e.id));return(0,Z.jsx)(rt,{open:!0,onOpenChange:e=>{e||r()},children:(0,Z.jsxs)(Fe,{className:`z-[130] max-h-[85dvh] min-w-0 grid-cols-1 overflow-y-auto rounded-lg sm:max-w-2xl`,overlayClassName:`z-[129]`,onEscapeKeyDown:e=>e.stopPropagation(),onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus()},children:[(0,Z.jsxs)(We,{children:[(0,Z.jsx)(Ke,{children:i(`chat:speechModels.notices`)}),(0,Z.jsxs)(tt,{className:`break-words`,children:[t,` (`,a.revision,`)`]})]}),(0,Z.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:bs.scope}),(0,Z.jsx)(`p`,{className:`break-words text-sm text-muted-foreground`,children:bs.licenseIdsMeaning}),(0,Z.jsx)(`div`,{className:`min-w-0 divide-y`,children:a.groups.map(e=>(0,Z.jsxs)(`details`,{className:`min-w-0 py-3`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.id,e.status===`pending`&&(0,Z.jsx)(`span`,{className:`ml-2 text-xs font-normal text-amber-700 dark:text-amber-400`,children:i(`chat:speechModels.provenancePending`)})]}),(0,Z.jsxs)(`div`,{className:`mt-3 min-w-0 space-y-3 text-sm`,children:[(0,Z.jsx)(`p`,{className:`break-words`,children:e.summary}),e.pendingReasons.map(e=>(0,Z.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e},e)),(0,Z.jsx)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:JSON.stringify({pathScope:e.pathScope,paths:e.paths,licenseIds:e.licenseIds,evidence:e.evidence},null,2)})]})]},e.id))}),(0,Z.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i(`chat:speechModels.modifications`)}),(0,Z.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-all text-xs`,children:JSON.stringify(a.modifications,null,2)})]}),s.map(e=>(0,Z.jsxs)(`details`,{className:`min-w-0 border-t pt-3`,children:[(0,Z.jsxs)(`summary`,{className:`cursor-pointer break-words text-sm font-medium`,children:[e.name,` (`,e.id,`)`]}),(0,Z.jsx)(`pre`,{className:`mt-3 whitespace-pre-wrap break-words text-xs`,children:e.text})]},e.id)),(0,Z.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{size:`icon-sm`,variant:`outline`,onClick:()=>{let e=new Blob([JSON.stringify({...bs,models:[a],licenses:s},null,2)],{type:`application/json;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${a.id}-notices.json`,n.click(),window.setTimeout(()=>URL.revokeObjectURL(t),0)},"aria-label":i(`chat:speechModels.downloadNotices`),children:(0,Z.jsx)(Ge,{})})}),(0,Z.jsx)(U,{children:i(`chat:speechModels.downloadNotices`)})]})})]})})}var Cs=e=>`${new Intl.NumberFormat(void 0,{maximumFractionDigits:1}).format(e/1048576)} MiB`;function ws({manager:e,onClose:t}){let{t:n}=x(),[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(null),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=()=>{l.current?.abort(),l.current=null,i(!1)};(0,X.useEffect)(()=>(e.open||(l.current?.abort(),l.current=null,i(!1),c(null)),()=>{l.current?.abort(),l.current=null}),[e.open]);let f={"not-installed":n(`chat:speechModels.notInstalled`),downloading:n(`chat:speechModels.downloading`),verifying:n(`chat:speechModels.verifying`),installed:n(`chat:speechModels.installed`),cancelled:n(`chat:speechModels.cancelled`),error:n(`chat:speechModels.failed`)},p=e.models.flatMap(e=>e.voices||[]),h=p.find(t=>t.id===e.selectedVoice),g=e.models.some(e=>e.kind===`tts`&&e.status===`installed`),_=e.models.filter(e=>e.status!==`installed`),v=_.some(e=>[`downloading`,`verifying`].includes(e.status)),y=()=>{c(null),d(),e.close(),t()},b=async()=>{if(l.current){d();return}if(!h||!g||_.length)return;let e=new AbortController;l.current=e,i(!0),o(``);try{await _s(h.language===`en`?n(`chat:speechModels.previewEnglish`):n(`chat:speechModels.previewChinese`),h.id,e.signal)}catch(t){e.signal.aborted||o(t instanceof Error?t.message:String(t))}finally{l.current===e&&(l.current=null,i(!1))}};return(0,Z.jsxs)(rt,{open:e.open,onOpenChange:e=>{e||y()},children:[(0,Z.jsxs)(Fe,{className:`z-[110] max-h-[85dvh] overflow-y-auto rounded-lg sm:max-w-md`,overlayClassName:`z-[109]`,onEscapeKeyDown:e=>e.stopPropagation(),children:[(0,Z.jsxs)(We,{children:[(0,Z.jsx)(Ke,{children:n(`chat:speechModels.title`)}),(0,Z.jsx)(tt,{className:`sr-only`,children:n(`chat:speechModels.title`)})]}),!e.catalog&&!e.error&&(0,Z.jsx)(ge,{className:`mx-auto my-4 size-5 animate-spin`,"aria-label":n(`chat:speechModels.loading`)}),(0,Z.jsx)(`div`,{className:`min-w-0 divide-y`,children:e.models.map(t=>{let r=[`downloading`,`verifying`].includes(t.status),i=t.totalBytes?Math.min(100,Math.floor(t.downloadedBytes/t.totalBytes*100)):0,a=t.license?.url.startsWith(`https://`)?t.license.url:void 0;return(0,Z.jsxs)(`section`,{className:`min-w-0 space-y-2 py-3 first:pt-0`,"aria-label":t.name,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t.kind===`asr`?n(`chat:speechModels.recognition`):n(`chat:speechModels.synthesis`)}),(0,Z.jsx)(`div`,{className:`break-words font-medium`,children:t.name})]}),t.status===`installed`?(0,Z.jsx)(it,{className:`size-5 shrink-0 text-emerald-600 dark:text-emerald-400`,"aria-label":f.installed}):(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{size:`icon-sm`,variant:`outline`,disabled:e.loading,onClick:()=>{r?e.cancelDownload(t.id):e.download(t.id)},"aria-label":n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`),children:r?(0,Z.jsx)(ke,{}):(0,Z.jsx)(Ge,{})})}),(0,Z.jsx)(U,{children:n(r?`chat:speechModels.cancelDownload`:`chat:speechModels.download`)})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:f[t.status]}),(0,Z.jsx)(`span`,{className:`tabular-nums`,children:r?`${Cs(t.downloadedBytes)} / ${Cs(t.totalBytes)}`:Cs(t.totalBytes)})]}),r&&(0,Z.jsx)(ie,{value:i,"aria-label":t.name,"aria-valuenow":i,"aria-valuemin":0,"aria-valuemax":100}),t.error&&(0,Z.jsx)(`p`,{role:`alert`,className:`break-words text-xs text-destructive`,children:t.error}),t.license&&(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,Z.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:`block break-words text-[11px] text-muted-foreground underline underline-offset-2`,children:t.license.name}),xs(t.id)&&(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{size:`icon-sm`,variant:`ghost`,"aria-label":n(`chat:speechModels.notices`),onClick:e=>{u.current=e.currentTarget,d(),c(t)},children:(0,Z.jsx)(An,{})})}),(0,Z.jsx)(U,{children:n(`chat:speechModels.notices`)})]})]})]},t.id)})}),p.length>0&&(0,Z.jsx)(`div`,{className:`space-y-2 border-t pt-3`,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 text-sm`,children:n(`chat:speechModels.voice`)}),(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{size:`icon`,variant:`outline`,disabled:!g||_.length>0,onClick:()=>void b(),"aria-label":n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`),children:r?(0,Z.jsx)(ke,{}):(0,Z.jsx)(Ce,{})})}),(0,Z.jsx)(U,{children:n(r?`chat:speechModels.stopPreview`:`chat:speechModels.preview`)})]})]})}),(e.error||a)&&(0,Z.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-destructive`,children:e.error||a}),(0,Z.jsx)(`div`,{className:`flex justify-end border-t pt-3`,children:_.length?(0,Z.jsxs)(m,{disabled:e.loading||v,onClick:()=>void e.downloadAll(),children:[(0,Z.jsx)(Ge,{}),n(`chat:speechModels.downloadAll`)]}):(0,Z.jsx)(m,{disabled:!e.catalog,onClick:y,children:n(`chat:speechModels.done`)})})]}),e.open&&s&&(0,Z.jsx)(Ss,{modelId:s.id,modelName:s.name,returnFocus:u,onClose:()=>c(null)})]})}var Ts=16e3,Es=Ts*60;function Ds(e,t){let n=window.__TAURI__?.core?.invoke??window.__TAURI_INTERNALS__?.invoke;return n?n(e,t):Promise.reject(Error(`移动端原生桥不可用。`))}async function Os(){if(!(typeof window>`u`||!window.__PISPER_MOBILE_APP__)&&(await Ds(`mobile_request_microphone_permission`)).state!==`granted`)throw Error(`microphone_permission_denied`)}async function ks(e){let t=await e.text().catch(()=>``);try{return JSON.parse(t).error||`语音转写失败 (${e.status})`}catch{return t||`语音转写失败 (${e.status})`}}function As(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Float32Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var js=class{chatSessionId;chunks=[];pending=[];listeners=new Set;controller=null;sessionId=``;nativeRequestId=``;legacy=!1;flushTimer=0;sendChain=Promise.resolve();finished=!1;retainedSamples=0;terms=[];initializing=null;constructor(e=``){this.chatSessionId=e}start(){return this.initializing=this.initialize().catch(async e=>{throw await this.cancel(),e}),this.initializing}async initialize(){this.chunks=[],this.pending=[],this.finished=!1,this.retainedSamples=0;let e=new AbortController;this.controller=e,await l(),s(e.signal);let{loadSpeechHotwords:t,prepareSpeechSession:n}=await i(async()=>{let{loadSpeechHotwords:e,prepareSpeechSession:t}=await import(`./speech-session-C_LNwJvG.js`).then(e=>e.r);return{loadSpeechHotwords:e,prepareSpeechSession:t}},__vite__mapDeps([37,1,11,2,14,13])),{terms:r,hotwords:a}=await t(this.chatSessionId,e.signal);this.terms=r;let c=await n({kinds:[`asr`],hotwords:a},e.signal);if(s(c.signal),c.signal.addEventListener(`abort`,()=>{this.controller===e&&!e.signal.aborted&&this.cancel()},{once:!0}),window.__PISPER_MOBILE_APP__)return;let u=o(e.signal,3e4);try{let t=await fetch(`/api/speech/stream/start`,{method:`POST`,headers:{"X-Pisper-Chat-Session":this.chatSessionId},signal:u.signal});if(!t.ok){if(t.status===404){this.legacy=!0;return}throw Error(await ks(t))}let n=await t.json();if(!n.id)throw Error(`语音识别会话创建失败。`);e.signal.aborted&&(await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":n.id}}).catch(()=>{}),s(e.signal)),this.sessionId=n.id,this.pending.push(...this.chunks.splice(0)),this.retainedSamples=0,this.flushTimer=window.setInterval(()=>void this.flushPending(),1e3)}finally{u.dispose()}}acceptPcm(e){if(!e.length||this.finished)return!1;if(window.__PISPER_MOBILE_APP__||!this.sessionId){let t=Es-this.retainedSamples;if(t<=0)return!0;let n=e.slice(0,t);return this.chunks.push(n),this.retainedSamples+=n.length,this.retainedSamples>=Es}let t=e.slice();return this.sessionId&&!this.legacy?this.pending.push(t):this.chunks.push(t),!1}onPartial(e){return this.listeners.add(e),()=>this.listeners.delete(e)}emitPartial(e){if(e)for(let t of this.listeners)t(e)}flushPending(){return this.sendChain=this.sendChain.then(async()=>{if(!this.sessionId||this.legacy||this.finished||!this.pending.length)return;let e=As(this.pending.splice(0));try{let t=await fetch(`/api/speech/stream/chunk`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ts),"X-Pisper-Speech-Session":this.sessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)return;let n=await t.json();typeof n.text==`string`&&this.emitPartial(n.text.trim())}catch{}}),this.sendChain}async finishStreaming(){window.clearInterval(this.flushTimer),this.flushTimer=0,await this.flushPending(),this.finished=!0;let e=await fetch(`/api/speech/stream/finish`,{method:`POST`,headers:{"X-Pisper-Speech-Session":this.sessionId},signal:this.controller?.signal});if(!e.ok)throw Error(await ks(e));let t=await e.json(),n=typeof t.text==`string`?t.text.trim():``;if(!n)throw Error(`未识别到语音内容。`);return this.emitPartial(n),n}async finishOneShot(e){if(window.__PISPER_MOBILE_APP__){let t=new Uint8Array(e.buffer),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));let i=this.controller;if(!i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);s(i.signal);let a=crypto.randomUUID();this.nativeRequestId=a;let o=await Ds(`mobile_transcribe_pcm`,{pcmBase64:btoa(n),hotwords:Et(this.terms),requestId:a});if(s(i.signal),this.controller!==i)throw new DOMException(`Speech recognition cancelled.`,`AbortError`);let c=Ot(typeof o.text==`string`?o.text.trim():``,this.terms);if(!c)throw Error(`未识别到语音内容。`);return this.emitPartial(c),c}let t=await fetch(`/api/speech/transcribe`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`,"X-Pisper-Sample-Rate":String(Ts),"X-Pisper-Chat-Session":this.chatSessionId},body:e.buffer,signal:this.controller?.signal});if(!t.ok)throw Error(await ks(t));let n=await t.json(),r=typeof n.text==`string`?n.text.trim():``;if(!r)throw Error(`未识别到语音内容。`);return this.emitPartial(r),r}async finish(){if(await this.initializing,!this.controller)throw Error(`语音识别尚未启动。`);if(this.sessionId&&!this.legacy)return this.finishStreaming();this.finished=!0;let e=As(this.chunks);if(!e.length)throw Error(`没有采集到语音。`);return this.finishOneShot(e)}async cancel(){if(this.finished=!0,window.clearInterval(this.flushTimer),this.flushTimer=0,this.controller?.abort(),this.controller=null,this.chunks=[],this.pending=[],this.retainedSamples=0,this.nativeRequestId){let e=this.nativeRequestId;this.nativeRequestId=``,await Ds(`mobile_cancel_speech`,{requestId:e}).catch(()=>{})}if(this.sessionId&&!this.legacy){let e=this.sessionId;this.sessionId=``,await fetch(`/api/speech/stream/cancel`,{method:`POST`,headers:{"X-Pisper-Speech-Session":e}}).catch(()=>{})}}async dispose(){await this.cancel(),this.listeners.clear()}};function Ms({chatSessionId:e=``}={}){return new js(e)}var Ns=`
517
+ class PisperVoiceInputProcessor extends AudioWorkletProcessor {
518
+ constructor(options) {
519
+ super()
520
+ this.targetSampleRate = Number(options?.processorOptions?.targetSampleRate) || 16000
521
+ this.inputSampleRate = sampleRate
522
+ this.ratio = this.inputSampleRate / this.targetSampleRate
523
+ this.inputBuffer = []
524
+ this.readPosition = 0
525
+ this.outputBuffer = []
526
+ }
527
+
528
+ process(inputs, outputs) {
529
+ const channel = inputs[0]?.[0]
530
+ if (channel?.length) {
531
+ for (const sample of channel) this.inputBuffer.push(sample)
532
+ while (this.readPosition + 1 < this.inputBuffer.length) {
533
+ const index = Math.floor(this.readPosition)
534
+ const fraction = this.readPosition - index
535
+ const current = this.inputBuffer[index]
536
+ const next = this.inputBuffer[index + 1]
537
+ this.outputBuffer.push(current + (next - current) * fraction)
538
+ this.readPosition += this.ratio
539
+ }
540
+ const consumed = Math.min(Math.floor(this.readPosition), this.inputBuffer.length)
541
+ if (consumed > 0) {
542
+ this.inputBuffer = this.inputBuffer.slice(consumed)
543
+ this.readPosition -= consumed
544
+ }
545
+ while (this.outputBuffer.length >= 320) {
546
+ const chunk = new Float32Array(this.outputBuffer.splice(0, 320))
547
+ this.port.postMessage(chunk.buffer, [chunk.buffer])
548
+ }
549
+ }
550
+ const output = outputs[0]?.[0]
551
+ if (output) output.fill(0)
552
+ return true
553
+ }
554
+ }
555
+ registerProcessor('pisper-voice-input', PisperVoiceInputProcessor)
556
+ `;async function Ps(e){let t=new Blob([Ns],{type:`application/javascript`}),n=URL.createObjectURL(t);try{await e.audioWorklet.addModule(n)}finally{URL.revokeObjectURL(n)}}async function Fs(e,t){if(s(t),!navigator.mediaDevices?.getUserMedia)throw Error(`当前环境不支持麦克风采集。`);if(!window.AudioContext&&!window.webkitAudioContext)throw Error(`当前环境不支持音频处理。`);let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}),r=null,i=null,a=null,o=null,c=!1,l=null,u=()=>{if(c)return l??Promise.resolve();c=!0,t?.removeEventListener(`abort`,d);for(let e of n.getTracks())e.removeEventListener?.(`ended`,f),e.removeEventListener?.(`mute`,f),e.stop();return l=r?.close().catch(()=>{})??Promise.resolve(),i&&(i.port.onmessage=null,i.port.close()),a?.disconnect(),i?.disconnect(),o?.disconnect(),l},d=()=>{u()},f=()=>{c||(u(),window.dispatchEvent(new Event(`pisper:speech-interrupted`)))},p=()=>{if(s(t),c)throw new DOMException(`Microphone capture was interrupted.`,`AbortError`)};t?.addEventListener(`abort`,d,{once:!0});for(let e of n.getTracks()){if(c)break;e.addEventListener?.(`ended`,f),e.addEventListener?.(`mute`,f),e.readyState===`ended`&&f()}try{p(),r=new(window.AudioContext||window.webkitAudioContext)({latencyHint:`interactive`}),await Ps(r),p(),a=r.createMediaStreamSource(n),i=new AudioWorkletNode(r,`pisper-voice-input`,{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[1],processorOptions:{targetSampleRate:Ts}}),o=r.createGain(),o.gain.value=0,i.port.onmessage=n=>{!c&&!t?.aborted&&e(new Float32Array(n.data))},a.connect(i),i.connect(o),o.connect(r.destination),await r.resume(),p()}catch(e){throw await u(),e}return{stop:u}}var Is=32,Ls=50;function Rs(e,t){if(e instanceof DOMException&&e.name===`NotAllowedError`)return`permission`;let n=typeof e==`string`?e:e instanceof Error?e.message:typeof e==`object`&&e&&`message`in e?String(e.message):``;return n.includes(`microphone_permission_denied`)?`permission`:n||t}function zs({onInsert:e,onLiveText:t,sessionId:n,disabled:r=!1,shortcutEnabled:i=!1}){let{t:a}=x(),o=us([`asr`]),s=_t(e=>e.bindings.voiceInput),[c,l]=(0,X.useState)(`idle`),[u,d]=(0,X.useState)(``),f=(0,X.useRef)(`idle`),p=e=>{f.current=e,l(e)},m=(0,X.useRef)(null),h=(0,X.useRef)(null),g=(0,X.useRef)(null),_=(0,X.useRef)(null),v=(0,X.useRef)(0),y=(0,X.useRef)(0),b=(0,X.useRef)(()=>{}),S=(0,X.useRef)(!1),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=(0,X.useRef)(()=>{}),E=(0,X.useRef)(0),D=(0,X.useRef)(ns()),O=(0,X.useRef)(0),[k,A]=(0,X.useState)([]),j=(0,X.useRef)([]),M=(0,X.useRef)(null),N=(0,X.useRef)(e),P=(0,X.useRef)(t);N.current=e,P.current=t;let F=()=>{window.clearTimeout(y.current),y.current=0},I=async()=>{F();let e=g.current;g.current=null,e?.abort(),_.current?.(),_.current=null,M.current?.dispose(),M.current=null;let t=h.current;h.current=null;let n=m.current;m.current=null,await Promise.allSettled([t?.stop(),n?.dispose()])},L=e=>{console.warn(`[voice-input]`,e),d(e),p(`error`),window.clearTimeout(E.current),E.current=window.setTimeout(()=>{f.current===`error`&&(d(``),p(`idle`))},4e3)},R=()=>{F(),S.current=!1,p(`idle`),d(``)},z=()=>{C.current=null,w.current=null,v.current+=1,I(),P.current?.(null),R()};T.current=z,(0,X.useEffect)(()=>{let e=()=>{(w.current!==v.current||C.current===v.current)&&T.current()},t=()=>{document.visibilityState===`hidden`&&e()},n=()=>T.current();return window.addEventListener(`blur`,e),window.addEventListener(`pisper:speech-interrupted`,n),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`pisper:speech-interrupted`,n),document.removeEventListener(`visibilitychange`,t),window.clearTimeout(E.current),e()}},[n,i,r]),(0,X.useEffect)(()=>{if(c!==`recording`){A([]),j.current=[];return}let e=()=>{let e=performance.now()/1e3,t=O.current,n=j.current,r=[];for(let i=0;i<Is;i+=1){let a=i/31*2-1,o=Math.cos(a*Math.PI/2)**1.3,s=.1+.06*Math.sin(e*2.2+i*.55)+.04*Math.sin(e*3.7+i*.21),c=.75+.5*Math.abs(Math.sin(e*9+i*1.7)),l=Math.min(1,Math.max(.05,s+t*o*c*1.15)),u=n[i]??l,d=l>u?.55:.28;r.push(u+(l-u)*d)}j.current=r,A(r)};e();let t=window.setInterval(e,Ls);return()=>window.clearInterval(t)},[c]);let ee=()=>!r&&(f.current===`idle`||f.current===`error`),te=async()=>{if(!ee())return;let e=++v.current,t=new AbortController;g.current=t,S.current=!1,p(`requesting`),d(``),D.current.reset();let r=Ms({chatSessionId:n});m.current=r,_.current=r.onPartial(e=>{m.current===r&&P.current?.(e)});let i=null,s=async t=>{if(i?.dispose(),i=null,e!==v.current)return;if(t instanceof DOMException&&t.name===`AbortError`){let e=++v.current;if(await I(),e!==v.current)return;R();return}let n=++v.current;if(await I(),n!==v.current)return;let r=Rs(t,a(`chat:voiceInput.failed`));L(r===`permission`?a(`chat:voiceInput.permissionDenied`):r)};try{window.__PISPER_MOBILE_APP__&&(w.current=e);try{await Os()}finally{w.current===e&&(w.current=null)}if(e!==v.current)return;if(window.__PISPER_MOBILE_APP__&&document.visibilityState===`hidden`){z();return}if(await o.ensureReady(t.signal),e!==v.current)return;if(r.start().then(()=>{},()=>s(Error(a(`chat:voiceInput.failed`)))),i=await cs(),e!==v.current){i.dispose();return}M.current=i;let n=i,c=await Fs(t=>{if(e!==v.current)return;O.current=D.current.push(ts(t));let i=n.acceptPcm(t);(r.acceptPcm(t)||i)&&b.current()},t.signal);if(e!==v.current){await c.stop();return}h.current=c,p(`recording`),window.__PISPER_MOBILE_APP__&&(y.current=window.setTimeout(()=>b.current(),6e4))}catch(e){await s(e)}},B=async()=>{if(f.current!==`recording`||S.current)return;C.current=null,S.current=!0,F();let e=++v.current;p(`transcribing`);let t=g.current;g.current=null,t?.abort();let n=h.current;h.current=null;let r=M.current;M.current=null;let i=m.current;try{if(await n?.stop(),e!==v.current)return;if(r&&!r.hasSpeech){if(r.dispose(),P.current?.(null),await I(),e!==v.current)return;R();return}r?.dispose();let t=await i?.finish();if(e!==v.current)return;if(!t)throw Error(a(`chat:voiceInput.empty`));if(N.current(t),await I(),e!==v.current)return;R()}catch(t){if(e!==v.current||(await I(),e!==v.current))return;P.current?.(null);let n=Rs(t,a(`chat:voiceInput.failed`));L(n===`permission`?a(`chat:voiceInput.permissionDenied`):n),S.current=!1}};b.current=()=>void B(),es({enabled:i&&!r,binding:s,onStart:()=>ee()?(te(),C.current=v.current,!0):!1,onRelease:()=>{C.current===v.current&&(h.current?B():z())},onCancel:()=>{C.current===v.current&&z()}});let V=c===`recording`?a(`chat:voiceInput.stop`):c===`requesting`?a(`chat:voiceInput.close`):c===`error`?u:a(`chat:voiceInput.open`),ne=s&&c!==`error`?`${V} (${vt(s)})`:V;return(0,Z.jsxs)(`div`,{className:`relative flex flex-none items-center`,children:[c===`recording`&&(0,li.createPortal)((0,Z.jsx)(`div`,{"aria-hidden":`true`,className:`voice-capsule-pop pointer-events-none fixed bottom-4 left-1/2 z-[80] flex h-10 -translate-x-1/2 items-center gap-[3px] rounded-full border border-[rgba(125,211,252,.35)] bg-[#10141c]/95 px-4`,style:{boxShadow:`0 8px 30px -8px rgba(0,0,0,.55), 0 0 ${14+O.current*26}px rgba(80,180,255,${(.18+O.current*.4).toFixed(3)})`},children:k.map((e,t)=>(0,Z.jsx)(`span`,{className:`w-[3px] rounded-full`,style:{height:`${(3+e*19).toFixed(1)}px`,background:`linear-gradient(180deg, hsl(${210-e*45} 92% ${62+e*10}%), hsl(${222-e*30} 85% ${48+e*8}%))`,transition:`height 70ms linear, background 200ms linear`}},t))}),document.body),c===`error`&&(0,li.createPortal)((0,Z.jsxs)(`button`,{type:`button`,className:`voice-capsule-pop fixed bottom-4 left-1/2 z-[80] flex h-9 max-w-[min(480px,calc(100vw-32px))] -translate-x-1/2 cursor-pointer items-center gap-2 rounded-full border border-[rgba(248,113,113,.4)] bg-[#1c1012]/95 px-4 text-[12px] text-[#fca5a5] shadow-[0_10px_30px_-10px_rgba(0,0,0,.5)]`,onClick:()=>{window.clearTimeout(E.current),d(``),p(`idle`)},children:[(0,Z.jsx)(Jn,{size:13,className:`flex-none`}),(0,Z.jsx)(`span`,{className:`truncate`,children:u})]}),document.body),(0,Z.jsxs)(`button`,{type:`button`,className:`relative grid !size-11 !min-w-11 place-items-center rounded-[var(--r-sm)] border transition-[background-color,color,border-color,box-shadow,transform] duration-200 hover:scale-105 disabled:cursor-not-allowed disabled:opacity-45 ${c===`recording`?`border-[var(--danger)] bg-[var(--danger-soft)] text-[var(--danger-strong)] shadow-[0_0_0_3px_var(--danger-soft)]`:c===`transcribing`||c===`requesting`?`border-transparent bg-[var(--brand-blue-soft)] text-[var(--brand-blue-strong)]`:c===`error`?`border-transparent bg-[var(--danger-soft)] text-[var(--danger-strong)]`:`border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)]`}`,title:ne,"aria-label":a(c===`recording`?`chat:voiceInput.stop`:`chat:voiceInput.open`),"aria-pressed":c===`recording`,disabled:r||c===`transcribing`,onClick:c===`recording`?()=>void B():c===`requesting`?()=>z():()=>void te(),children:[c===`recording`&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`absolute inset-0 animate-ping rounded-[var(--r-sm)] bg-[var(--danger)] opacity-25`}),c===`recording`?(0,Z.jsx)(Jn,{size:17}):c===`transcribing`||c===`requesting`?(0,Z.jsx)(ge,{className:`animate-spin`,size:17}):c===`error`?(0,Z.jsx)(Jn,{size:17}):(0,Z.jsx)(Yn,{size:17})]}),(0,Z.jsx)(ws,{manager:o,onClose:()=>{}})]})}var Bs={idle:{amp:.14,freq:1.7,speed:.22,spike:0,rot:.22,dim:.8,behavior:`calm`},requesting:{amp:.08,freq:1.6,speed:.3,spike:0,rot:.4,dim:.5,behavior:`calm`},listening:{amp:.15,freq:2,speed:.55,spike:.55,rot:.4,dim:1,behavior:`reactive`},transcribing:{amp:.08,freq:1.8,speed:1,spike:0,rot:1.5,dim:.95,behavior:`converge`},thinking:{amp:.2,freq:2.3,speed:.8,spike:0,rot:.85,dim:1,behavior:`swirl`},speaking:{amp:.13,freq:1.9,speed:.5,spike:.1,rot:.35,dim:1,behavior:`beat`},error:{amp:.12,freq:2.2,speed:1.2,spike:0,rot:.1,dim:.9,behavior:`jitter`}},Vs=64,Hs=96,Us=2.6,Ws=Math.PI*2,Gs={dark:{base:[223,233,255],cyan:[89,230,255],magenta:[255,95,210],haloInner:[70,110,170],haloMid:[50,80,140],haloAlpha:.1,composite:`lighter`,alphaBase:.1,alphaFront:.68},light:{base:[34,44,76],cyan:[6,132,180],magenta:[176,48,150],haloInner:[110,140,210],haloMid:[130,160,220],haloAlpha:.16,composite:`source-over`,alphaBase:.18,alphaFront:.85}};function Ks(e,t,n){let r=Math.sin(e*127.1+t*311.7+n*74.7)*43758.5453123;return r-Math.floor(r)}function qs(e){return e*e*(3-2*e)}function Js(e,t,n){let r=Math.floor(e),i=Math.floor(t),a=Math.floor(n),o=qs(e-r),s=qs(t-i),c=qs(n-a),l=0;for(let e=0;e<=1;e+=1)for(let t=0;t<=1;t+=1)for(let n=0;n<=1;n+=1)l+=(e?o:1-o)*(t?s:1-s)*(n?c:1-c)*Ks(r+e,i+t,a+n);return l}function Ys(e){return 1+2.70158*(e-1)**3+1.70158*(e-1)**2}function Xs(e){let t=e*.9%1;return Math.exp(-(((t-.12)*9)**2))+.45*Math.exp(-(((t-.34)*9)**2))}function Zs({stage:e,level:t,size:n=380,dark:r=!0}){let i=(0,X.useRef)(null),a=(0,X.useRef)(e),o=(0,X.useRef)(t),s=(0,X.useRef)(r);return a.current=e,o.current=t,s.current=r,(0,X.useEffect)(()=>{let e=i.current;if(!e)return;let t=e.getContext(`2d`);if(!t)return;let r=Math.min(window.devicePixelRatio||1,2);e.width=n*r,e.height=n*r,t.scale(r,r);let c=new Float32Array(Vs),l=new Float32Array(Vs);for(let e=0;e<Vs;e+=1){let t=-Math.PI/2+(e+.5)/Vs*Math.PI;c[e]=Math.sin(t),l[e]=Math.cos(t)}let u=new Float32Array(Hs),d=new Float32Array(Hs);for(let e=0;e<Hs;e+=1){let t=e/Hs*Ws;u[e]=Math.cos(t),d[e]=Math.sin(t)}let f=n/2,p=n*.31,m=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,h=0,g=performance.now(),_=g,v=0,y=0,b={...Bs[a.current]},x=0,S=0,C=0,w=e=>{let r=Math.min((e-g)/1e3,.05);g=e;let i=Bs[a.current],T=Math.min(1,r*5);b={...i,amp:b.amp+(i.amp-b.amp)*T,freq:b.freq+(i.freq-b.freq)*T,speed:b.speed+(i.speed-b.speed)*T,spike:b.spike+(i.spike-b.spike)*T,rot:b.rot+(i.rot-b.rot)*T,dim:b.dim+(i.dim-b.dim)*T};let E=m?.35:1;v+=r*E,y+=b.rot*r*E,x+=(o.current-x)*Math.min(1,r*14);let D=Math.max(0,x-S-.02);S=x,C=Math.min(.6,C*.02**r+D*2.4);let O=x;b.behavior===`beat`?O=Math.max(.08,.4+.28*Math.abs(Math.sin(v*5.2))*Math.sin(v*1.6)+.12*Math.sin(v*9.1)):b.behavior===`converge`?O=.18:b.behavior===`jitter`?O=.3+.2*Math.sin(v*17):b.behavior!==`reactive`&&(O=.1+.05*Math.sin(v*1.3));let k=Ys(Math.min(1,Math.max(0,(e-_)/900))),A=b.behavior===`beat`?O:Xs(v)*.5+O*.5,j=k*(1+A*.04+C*.1);b.behavior===`converge`&&(j*=.9+.1*Math.sin(v*4.2)),t.clearRect(0,0,n,n);let M=Gs[s.current?`dark`:`light`],N=t.createRadialGradient(f,f,0,f,f,p*1.7);N.addColorStop(0,`rgba(${M.haloInner[0]},${M.haloInner[1]},${M.haloInner[2]},${(M.haloAlpha*b.dim).toFixed(3)})`),N.addColorStop(.6,`rgba(${M.haloMid[0]},${M.haloMid[1]},${M.haloMid[2]},${(M.haloAlpha*.5*b.dim).toFixed(3)})`),N.addColorStop(1,`rgba(0,0,0,0)`),t.fillStyle=N,t.fillRect(0,0,n,n);let P=Math.sin(y),F=Math.cos(y),I=.38,L=Math.sin(I),R=Math.cos(I),z=v*b.speed,ee=b.freq,te=b.amp*j,B=b.spike*(O+C),V=p*j,ne=Math.floor(v*15),re=b.dim*(.72+.5*A)+C*.3;t.globalCompositeOperation=M.composite;for(let e=0;e<Vs;e+=1){let n=c[e],r=l[e];for(let i=0;i<Hs;i+=1){let a=r*u[i],o=n,s=r*d[i],c=Js(a*ee+z,o*ee+z*.7,s*ee)-.5,l=1+c*2*te;b.behavior===`reactive`?l+=Math.max(c,0)**2*1.7*B:b.behavior===`swirl`?l+=.03*Math.sin(9*a+v*4.6):b.behavior===`jitter`&&(l+=.02*(Ks(e*Hs+i,ne,3)-.5));let p=a*l,m=o*l,h=s*l,g=p*F-h*P,_=p*P+h*F,y=m*R-_*L,x=m*L+_*R,S=Us/(Us-x),C=f+g*S*V,w=f+y*S*V,T=(x+1)/2,E=Js(a*1.25+31,o*1.25+z*.12,s*1.25-17),D=M.base;E>.62?D=M.magenta:E<.38&&(D=M.cyan);let O=(M.alphaBase+M.alphaFront*T*T)*re;if(O<.015)continue;let k=(1+1.4*T+B*.4)*(.55+.45*S);t.fillStyle=`rgba(${D[0]},${D[1]},${D[2]},${O.toFixed(3)})`,t.fillRect(C,w,k,k)}}t.globalCompositeOperation=`source-over`,h=requestAnimationFrame(w)};return h=requestAnimationFrame(w),()=>cancelAnimationFrame(h)},[n]),(0,Z.jsx)(`canvas`,{ref:i,className:`pointer-events-none block`,style:{width:n,height:n},"aria-hidden":`true`})}var Qs=new Map;function $s(e,t){let n=Qs.get(e)??new Set;return n.add(t),Qs.set(e,n),()=>{n.delete(t),n.size||Qs.delete(e)}}function ec(e){for(let t of Qs.get(e.sessionId)??[])t(e)}function tc(e,t){let n=t.messages.length-1;for(;n>=0&&t.messages[n].role!==`user`;)--n;let r=t.messages.slice(n+1).filter(e=>e.role===`agent`||e.role===`assistant`),i=r.find(e=>e.streaming)??r.at(-1);ec({sessionId:e,messageId:i?.id??``,prompt:t.messages[n]?.text,startedAt:t.startedAt??void 0,source:`snapshot`,users:t.messages.filter(e=>e.role===`user`),text:i?.text??``,status:t.error||i?.error?`failed`:t.streaming?i?`streaming`:`started`:`completed`,error:t.error||i?.error})}function nc(e){let t=``,n=0,r=!1,i,a,o=()=>{a?.(),a=void 0},l=()=>{i=c(e),o()};return e.addEventListener(`abort`,l,{once:!0}),e.aborted&&l(),{get text(){return t},update(e){if(!(r||i)){if(e.length>32e3)throw Error(`Speech text exceeds the supported limit.`);if(!e.startsWith(t))throw Error(`The streamed speech response was rewritten.`);t=e,o()}},finish(e){r&&e===void 0||(r=!0,e!==void 0&&(i=e),o())},async*[Symbol.asyncIterator](){try{for(;;){if(s(e),i)throw i;if(n<t.length){let e=t.slice(n);n=t.length,yield e}else if(r)return;else await new Promise(e=>{a=e})}}finally{e.removeEventListener(`abort`,l),r=!0,o()}}}}function rc(e){let{t}=x(),n=(0,X.useRef)({...e,t});n.current={...e,t};let[r,i]=(0,X.useState)(`idle`),[a,o]=(0,X.useState)(0),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(0),v=(0,X.useRef)(`idle`),y=(0,X.useRef)(0),b=(0,X.useRef)(null),S=(0,X.useRef)(Promise.resolve()),C=(0,X.useRef)(!1),w=(0,X.useRef)(null),T=(0,X.useRef)(!1),E=(0,X.useRef)(!1),D=(0,X.useRef)(!1),O=(0,X.useRef)({start:async()=>{},commit:async()=>{},stop:()=>{}}),k=(0,X.useCallback)(e=>{v.current=e,i(e)},[]),A=e=>T.current&&n.current.open&&e.sessionId===n.current.sessionId&&b.current===e&&y.current===e.generation&&!e.controller.signal.aborted,j=()=>!!(n.current.streaming||n.current.messages.some(e=>e.streaming));function M(){let e=w.current;w.current=null,e?.controller.abort()}function N(){if(w.current)return w.current.preparing;let e=new AbortController,t=n.current.sessionId,r=(async()=>{C.current||=(await n.current.ensureReady?.(e.signal),s(e.signal),!0);let{hotwords:r}=await Nt(t,e.signal);await At({kinds:[`asr`,`tts`],hotwords:r},e.signal),s(e.signal)})().catch(t=>{throw w.current?.controller===e&&(w.current=null),e.abort(),t});return w.current={controller:e,preparing:r},r}function P(e){window.clearTimeout(e.limitTimer),e.limitTimer=void 0,e.microphone.abort(),e.endpoint?.dispose(),e.endpoint=void 0;let t=e.capture;return e.capture=void 0,t&&(e.captureStopping=t.stop()),e.captureStopping??Promise.resolve()}function F(e){if(e.cleanup)return e.cleanup;e.controller.abort(),e.unsubscribe?.(),e.unsubscribe=void 0,e.responseSubscription?.(),e.responseSubscription=void 0,e.checkOwnership=void 0;let t=P(e),n=e.recognizer;return e.recognizer=void 0,e.cleanup=Promise.allSettled([t,e.capturePending,e.recognizerDisposing,e.playback,n?.dispose()]).then(()=>{}),e.cleanup}function I(){y.current+=1;let e=b.current;if(b.current=null,!e)return;let t=Promise.resolve(),r=n.current.messages.filter(t=>t.role===`user`&&!e.baseline?.has(t.id)),i=n.current.sessionId===e.sessionId&&(r.length>1||r.length===1&&r[0].text?.trim()!==e.prompt);if(e.ownsRun&&!i){e.ownsRun=!1;try{t=Promise.resolve(e.abortRun?.()).catch(()=>{})}catch{}}S.current=Promise.allSettled([S.current,F(e),t]).then(()=>{})}function L(){D.current=!1,I(),k(`idle`),l(``),o(0),d(e=>e.filter(e=>!e.pending))}function R(e,t){if(!A(e))return;let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?t.message:void 0,i=typeof r==`string`&&r.trim()?r:n.current.t(`chat:voiceMode.failed`),a=t instanceof DOMException&&t.name===`NotAllowedError`||i.includes(`microphone_permission_denied`)?n.current.t(`chat:voiceInput.permissionDenied`):i;L(),p(a),k(`error`),n.current.notifyError?.(a)}function z(e){return new Promise(t=>{let n=e.controller.signal,r=()=>{window.clearTimeout(i),n.removeEventListener(`abort`,r),t()},i=window.setTimeout(r,50);n.addEventListener(`abort`,r,{once:!0}),n.aborted&&r()})}async function ee(e,t,r){let i=e.controller.signal,a=nc(i),o,c,l,u=!1,f=!1,p=!1,m=!1,h=!1,g=1/0,_=n=>{let r=n.filter(e=>e.role===`user`&&!t.has(e.id));return r.length>1||r.length===1&&r[0].text?.trim()!==e.prompt};e.checkOwnership=()=>{A(e)&&_(n.current.messages)&&(e.ownsRun=!1,R(e,Error(n.current.t(`chat:voiceMode.failed`))))};let v=e=>{a.update(e),d(t=>t.map(t=>t.id===r?{...t,text:e,pending:!e.trim()}:t))};e.responseSubscription=$s(e.sessionId,r=>{if(!(!A(e)||r.source!==`snapshot`&&t.has(r.messageId)))try{let t=r.source===`snapshot`,i=!!(l&&r.startedAt===l);if(r.users&&_(r.users)||r.prompt!==void 0&&r.prompt.trim()!==e.prompt||c&&r.runId&&c!==r.runId||l&&r.startedAt&&l!==r.startedAt||t&&!i&&!(m&&!r.startedAt&&r.status===`completed`)||!t&&o&&o!==r.messageId)throw e.ownsRun=!1,Error(n.current.t(`chat:voiceMode.failed`));if(m&&t)return;if(c||=r.runId,l||=r.startedAt,r.messageId&&(o=r.messageId),r.status===`recovering`){u=!0;return}if(t&&(u=!0,f=r.status===`streaming`||r.status===`started`),r.status===`started`)return;if(p=!0,r.status===`failed`)throw e.ownsRun=!1,Error(r.error||n.current.t(`chat:voiceMode.failed`));v(r.text),r.status===`completed`&&(m=!0,e.ownsRun=!1,a.finish())}catch(t){a.finish(t),R(e,t)}});let y=Promise.resolve().then(()=>(s(i),n.current.sendPrompt(e.prompt,[],!1,!1,null))).catch(t=>{throw e.ownsRun=!1,a.finish(t),t}).finally(()=>{!p&&!c&&!l&&(e.ownsRun=!1),h=!0,g=Date.now()+15e3}),b=async()=>{for(;A(e);){if(await z(e),!A(e))return;let r=n.current.messages.filter(e=>!t.has(e.id)),i=r.filter(e=>e.role===`user`);if(i.length>1||i.length===1&&i[0].text?.trim()!==e.prompt)throw Error(n.current.t(`chat:voiceMode.failed`));let s=r.filter(e=>e.role===`assistant`||e.role===`agent`),c=s.find(e=>e.error);if(c)throw Error(String(c.error));if(m&&h&&!j())return;let l=s.at(-1);if(!u&&l?.text&&(!p||h&&!j())){if(o&&o!==l.id)throw Error(n.current.t(`chat:voiceMode.failed`));o=l.id,v(l.text)}if(!u&&h&&!j()&&l?.text?.trim()){e.ownsRun=!1,a.finish();return}if(h&&(j()||f)&&(g=Date.now()+15e3),Date.now()>=g)throw Error(n.current.t(`chat:voiceMode.emptyReply`))}};try{e.playback=Promise.resolve().then(()=>n.current.speakText(a,i,()=>{A(e)&&k(`speaking`)})),await Promise.all([y,b(),e.playback])}catch(e){throw a.finish(e),e}finally{e.responseSubscription?.(),e.responseSubscription=void 0,e.checkOwnership=void 0,a.finish()}}async function te(){let e=b.current;if(!e||!A(e)||e.committed||v.current!==`listening`)return;e.committed=!0;let t=e.endpoint?.hasSpeech;k(`transcribing`),o(0);try{if(await P(e),!A(e))return;if(!t){L();return}let r=(await e.recognizer?.finish())?.trim();if(!A(e))return;e.unsubscribe?.(),e.unsubscribe=void 0;let i=e.recognizer;if(e.recognizer=void 0,e.recognizerDisposing=i?.dispose(),await e.recognizerDisposing,!A(e))return;if(l(``),!r)throw Error(n.current.t(`chat:voiceMode.emptyReply`));if(j()){L();return}let a=new Set(n.current.messages.map(e=>e.id));e.baseline=a,e.prompt=r;let o=`voice-agent-${e.generation}`;if(d(t=>[...t.slice(-4),{id:`voice-user-${e.generation}`,role:`user`,text:r},{id:o,role:`agent`,text:``,pending:!0}]),k(`thinking`),e.abortRun=n.current.onAbort,e.ownsRun=!0,await ee(e,a,o),!A(e))return;D.current&&!E.current?(k(`idle`),await O.current.start()):L()}catch(t){R(e,t)}}async function B(){if(!T.current||!n.current.open||E.current||document.hidden||![`idle`,`error`,`speaking`].includes(v.current))return;I();let e={generation:++y.current,sessionId:n.current.sessionId,controller:new AbortController,microphone:new AbortController,permissionPending:!1,committed:!1,commitRequested:!1,ownsRun:!1};b.current=e,D.current=!0,p(``),l(``),o(0),k(`requesting`);let t=ns(),r=0;try{if(await S.current,!A(e)||(await N(),!A(e)))return;if(j()){L();return}e.permissionPending=!0;try{await Os()}finally{e.permissionPending=!1}if(!A(e))return;if(document.hidden||j()){L();return}let n=await cs();if(!A(e)){n.dispose();return}e.endpoint=n;let i=Ms({chatSessionId:e.sessionId});if(e.recognizer=i,e.unsubscribe=i.onPartial(t=>{A(e)&&l(t)}),await i.start(),!A(e)||(e.capturePending=Fs(a=>{if(!(!A(e)||e.committed||e.microphone.signal.aborted))try{let s=t.push(ts(a)),c=performance.now();c-r>=66&&(r=c,o(s));let l=i.acceptPcm(a),u=n.acceptPcm(a);(l||u)&&(e.commitRequested=!0,v.current===`listening`?O.current.commit():e.microphone.abort())}catch(t){R(e,t)}},e.microphone.signal).then(async t=>(!A(e)||e.microphone.signal.aborted?await t.stop():e.capture=t,t)),await e.capturePending,!A(e)))return;if(k(`listening`),e.commitRequested){await O.current.commit();return}e.limitTimer=window.setTimeout(()=>void O.current.commit(),6e4)}catch(t){A(e)&&e.commitRequested&&e.microphone.signal.aborted?(k(`listening`),await O.current.commit()):R(e,t)}}O.current={start:B,commit:te,stop:L};let V=(0,X.useCallback)(()=>O.current.commit(),[]),ne=(0,X.useCallback)(()=>{O.current.stop();let e=y.current;S.current.then(()=>{y.current===e&&T.current&&O.current.start()})},[]),re=(0,X.useCallback)(()=>{v.current===`listening`?O.current.commit():v.current===`thinking`||v.current===`speaking`?ne():(v.current===`idle`||v.current===`error`)&&(E.current=!1,h(!1),O.current.start())},[ne]),ie=(0,X.useCallback)(()=>{let e=!E.current;E.current=e,h(e),e?O.current.stop():O.current.start()},[]),ae=(0,X.useCallback)(()=>{M(),O.current.stop(),p(``),_(0)},[]);return(0,X.useEffect)(()=>{if(!e.open)return;T.current=!0,C.current=!1,E.current=!1,h(!1),d([]),_(0),k(`idle`),O.current.start();let t=()=>{b.current?.permissionPending&&window.__PISPER_MOBILE_APP__||(M(),O.current.stop())},n=()=>{document.hidden&&t()},r=()=>{M(),O.current.stop()};return window.addEventListener(`blur`,t),window.addEventListener(`pisper:speech-interrupted`,r),document.addEventListener(`visibilitychange`,n),()=>{T.current=!1,M(),O.current.stop(),window.removeEventListener(`blur`,t),window.removeEventListener(`pisper:speech-interrupted`,r),document.removeEventListener(`visibilitychange`,n)}},[e.open,e.sessionId,k]),(0,X.useEffect)(()=>{b.current?.checkOwnership?.()},[e.messages,e.streaming]),(0,X.useEffect)(()=>{if(![`listening`,`transcribing`,`thinking`,`speaking`].includes(r))return;let e=window.setInterval(()=>_(e=>e+1),1e3);return()=>window.clearInterval(e)},[r]),{stage:r,level:a,partial:c,turns:u,error:f,muted:m,elapsed:g,toggleMain:re,toggleMute:ie,hangUp:ae,commitListening:V,interrupt:ne}}function ic(e){return{idle:e(`chat:voiceMode.idle`),requesting:e(`chat:voiceMode.requesting`),listening:e(`chat:voiceMode.listening`),transcribing:e(`chat:voiceMode.transcribing`),thinking:e(`chat:voiceMode.thinking`),speaking:e(`chat:voiceMode.speaking`),error:e(`chat:voiceMode.failed`)}}function ac(e){let t=Math.floor(e/60),n=e%60;return`${t.toString().padStart(2,`0`)}:${n.toString().padStart(2,`0`)}`}function oc(){let[e,t]=(0,X.useState)(()=>document.documentElement.dataset.theme!==`light`);return(0,X.useEffect)(()=>{let e=document.documentElement,n=()=>t(e.dataset.theme!==`light`);n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`data-theme`]}),()=>r.disconnect()},[]),e}function sc(e){let[t,n]=(0,X.useState)(()=>typeof window>`u`?380:Math.max(48,Math.min(window.innerWidth*.52,window.innerHeight-304,460)));return(0,X.useEffect)(()=>{if(!e)return;let t=()=>n(Math.max(48,Math.min(window.innerWidth*.52,window.innerHeight-304,460)));return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[e]),Math.floor(t)}function cc({open:e,sessionId:t,messages:n,streaming:r,sendPrompt:i,onAbort:a,onClose:o}){let{t:s}=x(),c=oc(),l=us([`asr`,`tts`]),u=rc({open:e,sessionId:t,messages:n,streaming:r,sendPrompt:i,onAbort:a,ensureReady:l.ensureReady,speakText:(e,t,n)=>_s(e,l.selectedVoice,t,n)}),{stage:d,level:f,partial:p,turns:h,error:g,elapsed:_}=u,v=sc(e),y=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!e)return;let t=document.activeElement;return y.current?.focus({preventScroll:!0}),()=>{t instanceof HTMLElement&&t.isConnected&&t.focus({preventScroll:!0})}},[e]);let b=()=>{try{u.hangUp()}finally{l.close(),o()}},S=d===`listening`||d===`transcribing`||d===`thinking`||d===`speaking`||d===`requesting`;if((0,X.useEffect)(()=>{if(!e)return;let t=e=>{if(!(l.open||e.defaultPrevented||e.isComposing)){if(e.key===`Escape`){e.preventDefault(),b();return}if(e.key===`Tab`){let t=[...y.current?.querySelectorAll(`button:not(:disabled)`)||[]],n=t[0],r=t[t.length-1];e.shiftKey&&(document.activeElement===n||document.activeElement===y.current)?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}e.target instanceof Element&&e.target.closest(`input, textarea, select, button, [contenteditable="true"]`)||e.key===` `&&!e.repeat&&(e.preventDefault(),S?u.hangUp():u.toggleMain())}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,o,S,l.open]),!e)return null;let C=ic(s),w=h[h.length-1],T=d===`listening`&&p?p:w?`${w.role,``}${rs(w.text,120)}`:``,E=d===`error`?g||s(`chat:voiceMode.failed`):C[d];return(0,li.createPortal)((0,Z.jsxs)(`div`,{className:`fixed inset-0 z-[90] grid grid-cols-[minmax(0,1fr)] grid-rows-[minmax(0,1fr)_100px_108px] overflow-hidden select-none pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)] pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)] ${c?`bg-[#030304] text-[#cfe8ff]`:`bg-[#f2f5fa] text-[#1e2c42]`}`,ref:y,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":s(`chat:voiceMode.title`),children:[(0,Z.jsxs)(`header`,{className:`pointer-events-none absolute left-[calc(env(safe-area-inset-left)_+_28px)] top-[calc(env(safe-area-inset-top)_+_24px)] flex items-center gap-3`,children:[(0,Z.jsx)(`span`,{className:`inline-block size-2 rounded-full ${S?`animate-pulse bg-[#59e6ff]`:c?`bg-[#3b4a5c]`:`bg-[#b6c3d4]`}`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`text-[13px] font-bold tracking-[0.42em] ${c?`text-[#9be7ff] [text-shadow:0_0_14px_rgba(89,230,255,.45)]`:`text-[#0d6ac9]`}`,children:`PISPER`})]}),(0,Z.jsxs)(`div`,{className:`absolute top-[calc(env(safe-area-inset-top)_+_16px)] right-[calc(env(safe-area-inset-right)_+_16px)] z-10 flex items-center gap-1`,children:[(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{variant:`ghost`,size:`icon-sm`,"aria-label":s(`chat:speechModels.title`),onClick:()=>{u.hangUp(),l.show()},children:(0,Z.jsx)(On,{})})}),(0,Z.jsx)(U,{children:s(`chat:speechModels.title`)})]}),(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{variant:`ghost`,size:`icon-sm`,className:`size-11 flex-none`,"aria-label":s(`chat:speechModels.close`),onClick:b,children:(0,Z.jsx)(Me,{})})}),(0,Z.jsx)(U,{children:s(`chat:speechModels.close`)})]})]}),(0,Z.jsx)(ws,{manager:l,onClose:()=>u.hangUp()}),(0,Z.jsx)(`div`,{className:`flex min-h-0 items-center justify-center pt-16 pb-6`,children:(0,Z.jsx)(Zs,{stage:d,level:f,size:v,dark:c})}),(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-col items-center justify-center gap-2 px-6 text-center`,children:[(0,Z.jsx)(`div`,{className:`max-w-full text-[11px] font-semibold uppercase tracking-normal ${d===`error`?`max-h-full overflow-y-auto break-words text-[#f87171]`:`line-clamp-2 ${c?`text-[#5f7a94]`:`text-[#7488a0]`}`}`,role:`status`,"aria-live":`polite`,children:E}),(0,Z.jsx)(`p`,{className:`m-0 line-clamp-2 min-h-[22px] max-w-[640px] text-[15px] leading-[1.6] ${c?`text-[#d7e6f7]`:`text-[#24344d]`}`,children:T})]}),(0,Z.jsx)(`div`,{className:`relative flex justify-center pt-3 sm:items-center sm:pt-0`,children:(0,Z.jsx)(`button`,{type:`button`,className:`h-11 cursor-pointer rounded-full border bg-transparent px-9 text-[11px] font-semibold uppercase tracking-[0.3em] transition-[box-shadow,background-color,border-color] duration-300 ${c?`border-[rgba(140,220,255,.4)] text-[#9be7ff] hover:border-[rgba(140,220,255,.8)] hover:bg-[rgba(89,230,255,.08)] hover:shadow-[0_0_28px_rgba(89,230,255,.25)]`:`border-[rgba(13,106,201,.45)] text-[#0d6ac9] hover:border-[rgba(13,106,201,.85)] hover:bg-[rgba(13,106,201,.07)] hover:shadow-[0_0_28px_rgba(13,106,201,.18)]`}`,onClick:()=>S?u.hangUp():u.toggleMain(),children:s(S?`chat:voiceMode.endConversation`:`chat:voiceMode.startConversation`)})}),(0,Z.jsxs)(`div`,{className:`pointer-events-none absolute bottom-[calc(env(safe-area-inset-bottom)_+_12px)] right-[calc(env(safe-area-inset-right)_+_20px)] flex items-center gap-2.5 sm:bottom-[calc(env(safe-area-inset-bottom)_+_36px)] sm:right-[calc(env(safe-area-inset-right)_+_28px)]`,children:[(0,Z.jsx)(`span`,{className:`hidden size-9 place-items-center rounded-full sm:grid bg-[linear-gradient(135deg,#2563eb,#38bdf8)] text-[10px] font-bold text-white shadow-[0_0_18px_rgba(56,189,248,.4)]`,"aria-hidden":`true`,children:S?`●`:`○`}),(0,Z.jsx)(`span`,{className:`font-mono text-[13px] tabular-nums tracking-[0.12em] ${c?`text-[#7d93ad]`:`text-[#61748c]`}`,children:ac(_)})]}),(0,Z.jsx)(`div`,{className:`absolute bottom-[env(safe-area-inset-bottom)] left-[calc(env(safe-area-inset-left)_+_20px)] sm:bottom-[calc(env(safe-area-inset-bottom)_+_36px)] sm:left-[calc(env(safe-area-inset-left)_+_28px)]`,children:(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{variant:`ghost`,size:`icon`,className:`size-11 flex-none`,disabled:!S&&!u.muted,"aria-label":d===`speaking`||d===`thinking`?s(`chat:voiceMode.interrupt`):u.muted?s(`chat:voiceMode.unmute`):s(`chat:voiceMode.mute`),onClick:()=>d===`speaking`||d===`thinking`?u.interrupt():u.toggleMute(),children:d===`speaking`||d===`thinking`?(0,Z.jsx)(ke,{}):u.muted?(0,Z.jsx)(Jn,{}):(0,Z.jsx)(Yn,{})})}),(0,Z.jsx)(U,{children:d===`speaking`||d===`thinking`?s(`chat:voiceMode.interrupt`):u.muted?s(`chat:voiceMode.unmute`):s(`chat:voiceMode.mute`)})]})})]}),document.body)}var lc=({className:e,defaultOpen:t=!0,...n})=>(0,Z.jsx)(te,{className:ce(e),defaultOpen:t,...n});function uc({queuedInputs:e,withdrawingInputIds:t=[],onWithdraw:n}){let{t:r}=x(),i=r(`chat:focusSession.sentToTheRunningAgent`),a=r(`chat:focusSession.withdrawQueuedInput`);return(0,Z.jsx)(lc,{asChild:!0,defaultOpen:!0,children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1 text-xs text-[var(--text-secondary)]`,"data-pisper-queue-size":e.length,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-[11px] font-semibold text-[var(--star-strong)]`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 [overflow-wrap:anywhere]`,children:i}),(0,Z.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:e.length})]}),(0,Z.jsx)(`ul`,{className:`m-0 max-h-36 min-w-0 list-none overflow-x-hidden overflow-y-auto overscroll-contain p-0`,"aria-label":i,tabIndex:e.length>3?0:void 0,children:e.map((e,r)=>{let i=typeof e.id==`string`?e.id:``,o=t.includes(i);return(0,Z.jsxs)(`li`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 border-b border-[var(--stroke-soft)] py-0.5 last:border-0`,children:[(0,Z.jsx)(`span`,{className:`line-clamp-2 min-w-0 whitespace-pre-wrap [overflow-wrap:anywhere]`,title:e.text,children:e.text}),(0,Z.jsxs)(W,{children:[(0,Z.jsx)(H,{asChild:!0,children:(0,Z.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-lg`,className:`rounded-md text-[var(--text-muted)] hover:text-[var(--text)]`,"aria-label":a,"aria-busy":o||void 0,disabled:!i||!n||o,onClick:()=>void n?.(i),children:(0,Z.jsx)(ir,{size:16,"aria-hidden":`true`})})}),(0,Z.jsx)(U,{children:a})]})]},i||`${e.behavior}-${r}`)})})]})})}function dc({invocation:e,onRemove:t}){let{t:n}=x();return(0,Z.jsxs)(`div`,{className:`composer-resource-chip [&.workflow]:border-[var(--success)] [&.workflow]:bg-[var(--success-soft)] [&_button]:grid [&_button]:w-[20px] [&_button]:h-[20px] [&_button]:place-items-center [&_button]:border-0 [&_button]:rounded-[var(--r-xs)] [&_button]:bg-transparent [&_button]:text-[var(--text-muted)] [&_button]:cursor-pointer [&_button:hover]:bg-[var(--surface-hover)] [&_button:hover]:text-[var(--text)] inline-flex min-h-[28px] self-start items-center gap-[6px] [border:1px_solid_var(--blue)] rounded-[var(--r-sm)] bg-[var(--blue-soft)] text-[var(--text)] [padding:4px_6px_4px_8px] text-[12px] font-[600] ${e.kind}`,children:[e.kind===`tool`?(0,Z.jsx)(je,{size:13}):(0,Z.jsx)(V,{size:13}),(0,Z.jsxs)(`span`,{children:[e.kind===`skill`?`Skill`:e.kind===`tool`?n(`chat:resourcePicker.tool`):n(`chat:resourcePicker.workflow`),` `,`· `,e.resourceName]}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":n(`chat:resourcePicker.remove`),onClick:t,children:(0,Z.jsx)(Me,{size:13})})]})}function fc({compaction:e,streaming:t}){let{t:n}=x();return(0,Z.jsxs)(`div`,{className:`focus-composer-status [.focus-session.has-conversation_&.idle]:hidden [&_>_i]:w-[7px] [&_>_i]:h-[7px] [&_>_i]:flex-none [&_>_i]:rounded-[50%] [&_>_i]:bg-[var(--text-muted)] [&.running]:text-[var(--success-strong)] [&.running_>_i]:bg-[var(--success)] [&.running_>_i]:shadow-[0_0_0_3px_var(--success-soft)] [&.running_>_i]:[animation:star-twinkle_1.1s_ease-in-out_infinite] inline-flex min-h-[22px] self-start items-center gap-[7px] [margin:0_0_-2px_5px] [border:1px_solid_var(--stroke-soft)] rounded-[var(--r-pill)] bg-[var(--solid)] [padding:3px_9px_3px_7px] text-[var(--text-muted)] text-[11px] font-[600] shadow-[0_8px_18px_-16px_var(--shadow-strong)] ${e?.active?`compacting [.focus-composer-status&]:text-[var(--warning-strong)] [.focus-composer-status&_>_i]:bg-[var(--warning-strong)] [.focus-composer-status&_>_i]:shadow-[0_0_0_3px_var(--warning-soft)] [.focus-composer-status&_>_i]:[animation:star-twinkle_1.1s_ease-in-out_infinite]`:t?`running`:`idle`}`,role:`status`,"aria-live":`polite`,children:[(0,Z.jsx)(`i`,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:e?.active?n(`chat:focusSession.compactingContext`):n(t?`chat:focusSession.running`:`chat:focusSession.waitingForInput`)})]})}function pc({streaming:e,compactingManually:t,compactionActive:n,disabled:r,onCompact:i}){let{t:a}=x();return(0,Z.jsx)(`button`,{type:`button`,className:`compact-context-trigger [&:hover:not(:disabled)]:border-[var(--accent-border)] [&:hover:not(:disabled)]:bg-[var(--accent-soft)] [&:hover:not(:disabled)]:text-[var(--star-strong)] disabled:[cursor:not-allowed] disabled:opacity-[.5] [.composer-tool-tray_&]:w-[38px] [.composer-tool-tray_&]:min-w-[38px] [.composer-tool-tray_&]:h-[38px] [.composer-tool-tray_&]:flex-none @max-[700px]:[.composer-tool-tray_&]:w-[32px] @max-[700px]:[.composer-tool-tray_&]:min-w-[32px] @max-[700px]:[.composer-tool-tray_&]:h-[32px] @max-[700px]:[.composer-tool-tray_&]:p-0 @max-[470px]:[.composer-tool-tray_&]:w-[28px] @max-[470px]:[.composer-tool-tray_&]:min-w-[28px] @max-[470px]:[.composer-tool-tray_&]:h-[28px] grid w-[38px] h-[38px] flex-none place-items-center [border:1px_solid_transparent] rounded-[var(--r-sm)] bg-[var(--surface-muted)] text-[var(--text-tertiary)] cursor-pointer`,title:a(e?`chat:focusSession.manualCompactionWaitForRun`:t||n?`chat:focusSession.compactingContext`:`chat:focusSession.compactContextNow`),"aria-label":a(`chat:focusSession.compactContextNow`),disabled:r,onClick:i,children:t||n?(0,Z.jsx)(q,{className:`animate-spin`,size:14}):(0,Z.jsx)(Xn,{size:14})})}function mc({streaming:e,queueing:t,disabled:n,onAbort:r}){let{t:i}=x(),a=ht(`sendMessage`),o=i(`chat:focusSession.sendMessage`);return(0,Z.jsx)(`button`,{type:e?`button`:`submit`,className:`send-button grid !size-11 flex-none place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--star)] text-[var(--on-accent)] transition-[var(--d1)] cursor-pointer hover:not(:disabled):bg-[var(--star-hover)] hover:not(:disabled):shadow-[var(--sh-star)] active:not(:disabled):scale-[.96] disabled:cursor-not-allowed disabled:border disabled:border-[var(--stroke)] disabled:bg-[var(--surface-muted)] disabled:text-[var(--text-muted)] ${e?`stop !bg-[var(--danger)] hover:not(:disabled):shadow-[0_0_0_3px_var(--danger-soft)]`:``}`,title:e?i(`chat:focusSession.stop`):a?`${o} (${a})`:o,"aria-label":i(e?`chat:focusSession.stop`:`chat:focusSession.sendMessage`),onClick:e?r:void 0,disabled:n,children:e?(0,Z.jsx)(ke,{size:16,fill:`currentColor`}):t?(0,Z.jsx)(q,{className:`animate-spin`,size:17}):(0,Z.jsx)(we,{size:18})})}var hc=36,gc=40;function _c(e){let[t,n]=(0,X.useState)(1/0);return(0,X.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=t.getBoundingClientRect().width-hc;n(Math.max(0,Math.floor(e/gc)))};if(r(),typeof ResizeObserver>`u`)return window.addEventListener(`resize`,r),()=>window.removeEventListener(`resize`,r);let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}var vc=[`plan`,`goal`,`team`];function yc(e){return vc.includes(e)?e:`plan`}function bc({sessionId:e,runMode:t,goalsAvailable:n,teamAvailable:r,workflowsAvailable:i,goal:a,streaming:o,compaction:s,value:c,selection:l,clearDraft:u,promptRef:d,onCompact:f,onGoalPause:p,onSend:m,onQueue:h,setToolsOpen:g,requestTranscriptBottom:_}){let[v,y]=(0,X.useState)(()=>yc(t)),b=(0,X.useRef)(t);b.current=t;let[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),T=(0,X.useRef)(null),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(!1),[A,j]=(0,X.useState)(null);return(0,X.useEffect)(()=>{y(yc(b.current)),T.current=null,S(null),w(null),D(!1),k(!1),j(null)},[e]),(0,X.useEffect)(()=>{y(yc(t))},[e,t]),(0,X.useEffect)(()=>{n||y(`plan`),!r&&v===`team`&&y(`goal`),!i&&A?.kind===`workflow`&&j(null)},[v,n,A?.kind,r,i]),(0,X.useEffect)(()=>{a?.status===`active`&&y(a.mode===`team`&&r?`team`:`goal`)},[a?.id,a?.mode,a?.status,r]),(0,X.useEffect)(()=>{if(!a?.id){S(null);return}let e=a.mode===`team`?a.teamTokenBudget:a.tokenBudget,t=e==null?null:Number(e),n=t!==null&&Number.isFinite(t)&&t>0?t:null;a.mode===`team`?w(n):S(n)},[a?.id,a?.mode,a?.teamTokenBudget,a?.tokenBudget]),{composerExecutionMode:v,setComposerExecutionMode:y,goalTokenBudget:x,setGoalTokenBudget:S,teamTokenBudget:C,setTeamTokenBudget:w,queueing:E,compactingManually:O,invocation:A,setInvocation:j,requestGoalPause:()=>{if(T.current)return T.current;let e=Promise.resolve().then(()=>p?.());return T.current=e,e.catch(()=>{}),e},compactContext:async()=>{if(!(!f||o||O||s?.active)){k(!0);try{await f()}finally{k(!1)}}},submit:async e=>{if(e.preventDefault(),!c.trim()&&!l.attachments.length&&!A)return;if(o){if(!c.trim()&&!l.attachments.length||E)return;D(!0);let e=await h?.(c,l.attachments,`steer`);if(D(!1),!e)return;u(),y(`plan`),g(!1),_(),d.current&&(d.current.style.height=`auto`);return}let t=T.current;if(t){try{await t}catch{T.current=null;return}T.current=null}else a?.status===`active`&&(v===`plan`||v!==a.mode)&&await p?.();m(c,l.attachments,v===`goal`||v===`team`,v===`team`,v===`team`?C:v===`goal`?x:null,A),_(),u(),y(`plan`),g(!1),j(null),d.current&&(d.current.style.height=`auto`)}}}var xc=[`.composer-tools-trigger`,`.composer-tool-tray-shell`,`.anchored-popup-menu`,`.voice-input-popup`,`.git-diff-dialog-backdrop`,`[data-slot='dialog-content']`,`[data-slot='dialog-overlay']`,`[data-slot='alert-dialog-content']`,`[data-slot='alert-dialog-overlay']`,`[data-slot='popover-content']`,`[data-slot='dropdown-menu-content']`,`[data-slot='dropdown-menu-sub-content']`,`[data-slot='select-content']`,`[data-slot='sheet-content']`,`[data-slot='sheet-overlay']`].join(`, `),Sc=(0,X.memo)(function({session:e,shortcutEnabled:t=!1,messages:n,transcriptLoadState:r=`ready`,messageStart:i,hasOlder:a,loadingOlder:o,olderError:s,model:c,thinkingLevel:l,availableThinkingLevels:u,thinkingStatus:d,thinkingMessage:f,executionMode:p,goal:m,team:h,plan:g,currentActivity:_,activityFeed:v,tools:y,thinkingText:b,queuedInputs:S,withdrawingInputIds:C,compaction:w,contextUsage:T,sessionUsage:D,sessionTreeRevision:O,sessionTreePulse:k,cwd:A,availableModels:j,switchingModel:M,switchingThinking:N,switchingCwd:P,switchingPermission:F,streaming:I,runStartedAt:L,lastActivityAt:R,runFinishedAt:z,runStopped:ee,runNotice:te,approvals:B,error:ne,pendingAsset:re,canSplit:ie,canClosePanel:ae=!0,notify:oe,onOpenModelSettings:se,onAssetConsumed:H,onLoadOlder:U,onModelChange:W,onThinkingLevelChange:ce,onExecutionModeChange:le,onRunModeChange:ue,onCompact:de,onCompactionThresholdChange:fe,onGoalPause:pe,onGoalBudgetChange:G,onApproval:me,onWorkspace:he,onRename:ge,onBranchFromHere:_e,onCreateChildSession:ve,onTreeNavigated:ye,onSplitLeft:be,onSplitRight:xe,onSplitTop:Se,onSplitBottom:Ce,onClosePanel:we,onSend:Te,onQueue:De,onWithdrawQueuedInput:Oe,onAbort:ke}){let{t:K,language:Ae}=x(),je=_t(e=>e.bindings),Ne=ht(`commandPalette`),Pe=Ee(),Fe=E(),Ie=Pe||Fe,Re=Be(e=>e.capabilities),ze=J(Re,`goals`),Ve=J(Re,`multiAgent`),He=J(Re,`plans`),Ue=J(Re,`vcs`),We=J(Re,`workflows`),Ge=J(Re,`visualGeneration`),{value:Ke,updateValue:Je,selection:Xe,clearDraft:q,restoreDraft:Ze}=$r(e.id),[Qe,$e]=(0,X.useState)(!1),[et,tt]=(0,X.useState)(!1),[nt,rt]=(0,X.useState)(!1),[it,at]=(0,X.useState)(!1),[st,lt]=(0,X.useState)(0),ut=Xe.addAttachments,dt=(0,X.useRef)(null),ft=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(!t)return;let e=e=>{!mt(e)&&gt(e,je.focusComposer)&&(e.preventDefault(),dt.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,je.focusComposer]);let Y=(0,X.useRef)(null),vt=(0,X.useRef)(null),yt=(0,X.useRef)(null),bt=_c(Y),xt=mi(e=>e.layout),St=(0,X.useRef)(!1),Ct=r!==`ready`||n.length>0,wt=`composer-tool-tray-${e.id}`,Tt=K(it?`chat:focusSession.collapseQuickActions`:`chat:focusSession.expandQuickActions`),Et=K(Ie?I?`chat:focusSession.addGuidanceForTheRunningAgent`:`chat:focusSession.writeWhatYouWantToAccomplish`:I?`chat:focusSession.runningAgentComposerHint`:`chat:focusSession.composerHint`),Dt=()=>lt(e=>e+1),Ot=e=>{Je(e),requestAnimationFrame(()=>{let e=dt.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})},{composerExecutionMode:kt,setComposerExecutionMode:At,goalTokenBudget:jt,setGoalTokenBudget:Mt,teamTokenBudget:Nt,setTeamTokenBudget:Pt,queueing:Ft,compactingManually:It,invocation:Lt,setInvocation:Rt,requestGoalPause:zt,compactContext:Bt,submit:Vt}=bc({sessionId:e.id,runMode:e.runMode,goalsAvailable:ze,teamAvailable:Ve,workflowsAvailable:We,goal:m,streaming:I,compaction:w,value:Ke,selection:Xe,clearDraft:q,promptRef:dt,onCompact:de,onGoalPause:pe,onSend:Te,onQueue:De,setToolsOpen:at,requestTranscriptBottom:Dt});(0,X.useEffect)(()=>{$e(!1),tt(!1),at(!1)},[e.id]),(0,X.useEffect)(()=>{re&&(ut([re]),H?.())},[re,H,ut]),(0,X.useEffect)(()=>{if(!it)return;let e=e=>{e.key===`Escape`&&at(!1)},t=e=>{let t=e.target;t instanceof Element&&!t.closest(xc)&&at(!1)};return document.addEventListener(`keydown`,e),document.addEventListener(`pointerdown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`pointerdown`,t)}},[it]);let Ht=async e=>{let t=await Oe?.(e);if(!t||!Ze(t))return;let n=dt.current;requestAnimationFrame(()=>{!n||dt.current!==n||!n.isConnected||(n.focus(),n.style.height=`auto`,n.style.height=`${Math.min(n.scrollHeight,220)}px`)})},Ut=e=>{Je(e),requestAnimationFrame(()=>{let e=dt.current;e&&(e.focus(),e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)})},Wt=(0,Z.jsx)(Mo,{session:e,canSplit:ie,canClose:ae,streaming:I,switchingCwd:P,onSplitLeft:be,onSplitRight:xe,onSplitTop:Se,onSplitBottom:Ce,onClosePanel:we,onWorkspace:he,onRename:ge,onSessionTree:()=>tt(!0)}),Gt={attachment:K(`chat:focusSession.addAttachment`),resource:K(`chat:resourcePicker.open`),visual:K(`chat:focusSession.generateImage`),model:K(`chat:focusSession.toolbarModel`),permission:K(`chat:focusSession.approvalMode`),"run-mode":K(`chat:focusSession.executionMode`),thinking:K(`chat:focusSession.currentThinkingLevel`),commands:K(`chat:focusSession.commands`),"git-changes":K(`chat:focusSession.gitChanges`),"compact-context":K(`chat:focusSession.compactContextNow`),"session-actions":K(`chat:focusSession.chatActions`)},Kt={attachment:(0,Z.jsx)(Hr,{cwd:A,selection:Xe}),resource:(0,Z.jsx)(`button`,{type:`button`,className:`resource-picker-trigger grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)]`,title:K(`chat:resourcePicker.open`),"aria-label":K(`chat:resourcePicker.open`),onClick:()=>$e(!0),children:(0,Z.jsx)(V,{size:16})}),visual:Ge?(0,Z.jsx)(Qo,{notify:oe,onOpenModelSettings:se,onInsertPrompt:Ut}):null,model:(0,Z.jsx)(ji,{value:c,models:j,onChange:W,disabled:I||M}),permission:(0,Z.jsx)(Pi,{value:p,onChange:le,disabled:F}),"run-mode":ze?(0,Z.jsx)(jo,{mode:kt,goal:m,teamAvailable:Ve,disabled:I,tokenBudget:kt===`team`?Nt:jt,onTokenBudgetChange:kt===`team`?Pt:Mt,onSaveTokenBudget:e=>G?.(e),onChange:e=>{m?.status===`active`&&(e===`plan`||e!==m.mode)&&zt().catch(()=>{}),At(e),ue(e)}}):null,thinking:(0,Z.jsx)(Mi,{value:l||`medium`,levels:u||[],status:d,message:f,onChange:ce,disabled:I||N||M}),commands:(0,Z.jsxs)(`button`,{type:`button`,className:`command-palette-trigger relative grid size-9 min-w-9 place-items-center rounded-[var(--r-sm)] border-0 bg-[var(--surface-subtle)] text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--star-strong)] [&_kbd]:sr-only`,title:Ne?K(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Ne}):K(`chat:focusSession.commands`),"aria-label":Ne?K(`chat:focusSession.openCommandPaletteShortcut`,{shortcut:Ne}):K(`chat:focusSession.commands`),onClick:qe,children:[(0,Z.jsx)(Pn,{size:16}),(0,Z.jsx)(`kbd`,{children:Ne})]}),"git-changes":Ue?(0,Z.jsx)(Do,{sessionId:e.id,streaming:I}):null,"compact-context":(0,Z.jsx)(pc,{streaming:I,compactingManually:It,compactionActive:!!w?.active,disabled:!de||I||It||!!w?.active||n.length===0,onCompact:()=>void Bt()}),"session-actions":Ct?Wt:null},qt=ci(xt,ti.filter(e=>Kt[e]!==null),bt),Jt=e=>(0,Z.jsx)(`div`,{className:`composer-toolbar-slot grid size-9 min-w-9 flex-none place-items-center overflow-visible [&>button]:!size-9 [&>button]:!min-w-9 [&>div]:!size-9 [&>div]:!min-w-9 [&>div>button]:!size-9 [&_.git-changes-trigger>i]:!right-0.5 [&_.git-changes-trigger>i]:!top-0.5`,"data-composer-tool-id":e,children:Kt[e]},e);return(0,Z.jsxs)(ct,{className:`focus-session [.session-dock-panel_&]:overflow-hidden [.session-dock-panel_&]:min-h-0 [.session-dock-panel_&]:border-0 [.session-dock-panel_&]:rounded-[0] [.session-dock-panel_&]:bg-[var(--panel)] [.session-dock-panel_&]:p-0 [.session-dock-panel_&]:shadow-[none] [[data-theme='dark']_.session-dock-panel_&]:bg-[var(--main-surface-bg)] min-[651px]:[[data-density='compact']_.app-card:not(&)]:p-[10px] max-[650px]:min-h-[460px] max-[650px]:[.session-dock-panel_&]:min-h-0 relative flex h-full min-h-[500px] flex-col ${Ct?`has-conversation`:`is-empty`}`,children:[!Ct&&(0,Z.jsx)(ot,{className:`relative z-4 min-h-12 flex-none items-center border-b border-[var(--stroke-soft)] bg-[var(--panel)] px-3 py-[7px]`,children:(0,Z.jsx)(`div`,{className:`flex [margin-left:auto] items-center gap-[6px]`,children:Wt})}),(0,Z.jsx)(Go,{visible:n.length>0,open:et,sessionId:e.id,streaming:!!I,revision:O,pulseToken:k,onOpenChange:tt,onNavigated:async e=>{e!==null&&Ut(e),await ye?.(),Dt()},onCreateChildSession:e=>ve(e)}),(0,Z.jsx)(mo,{sessionId:e.id,messages:n,transcriptLoadState:r,messageStart:i,hasOlder:a,loadingOlder:o,olderError:s,currentActivity:_,team:h,activityFeed:v,tools:y,thinkingText:b,compaction:w,streaming:I,runStartedAt:L,lastActivityAt:R,runFinishedAt:z,runStopped:ee,runNotice:te,error:ne,scrollRequest:st,cwd:A,lineage:e.lineage,switchingCwd:P,onLoadOlder:U,onBranchFromHere:_e,onCreateChildSession:ve,onPromptSelect:Ut,onWorkspace:he}),(0,Z.jsxs)(`form`,{className:`focus-composer-shell [.focus-session.has-conversation_&]:w-[min(900px,calc(100%_-_48px))] [.focus-session.has-conversation_&]:pt-[8px] @max-[700px]:w-[calc(100%_-_20px)] @max-[700px]:pb-[10px] @max-[700px]:[.focus-session.has-conversation_&]:w-[calc(100%_-_20px)] max-[650px]:w-[calc(100%_-_20px)] max-[650px]:pb-[10px] relative z-20 flex w-[min(960px,calc(100%_-_48px))] flex-none flex-col gap-[7px] [margin:0_auto] [padding:10px_0_0]`,onSubmit:Vt,children:[(0,Z.jsx)(Zo,{approvals:B,onResolve:me}),S.length>0&&(0,Z.jsx)(uc,{queuedInputs:S,withdrawingInputIds:C,onWithdraw:Oe?Ht:void 0}),We&&(0,Z.jsx)(Jo,{sessionId:e.id}),Lt&&(0,Z.jsx)(dc,{invocation:Lt,onRemove:()=>Rt(null)}),(0,Z.jsx)(Ur,{attachments:Xe.attachments,onRemove:Xe.removeAttachment}),Xe.attachmentError&&(0,Z.jsx)(`span`,{className:`text-[var(--danger)] text-[13px]`,children:Xe.attachmentError}),(0,Z.jsx)(fc,{compaction:w,streaming:I}),(0,Z.jsxs)(`div`,{className:`focus-composer [&:focus-within]:border-[var(--focus)] [&:focus-within]:shadow-[0_0_0_3px_var(--focus-ring)] [&_textarea]:w-full [&_textarea]:min-w-0 [&_textarea]:min-h-[48px] [&_textarea]:max-h-[220px] [&_textarea]:[align-self:start] [&_textarea]:resize-none [&_textarea]:overflow-y-auto [&_textarea]:border-0 [&_textarea]:[outline:0]! [&_textarea]:bg-transparent [&_textarea]:p-[5px_6px_8px] [&_textarea]:text-[var(--text)] [&_textarea]:text-[14px] [&_textarea]:leading-[1.5] [.focus-session.has-conversation_&]:shadow-[0_10px_28px_-24px_var(--shadow-strong)] [.focus-session.has-conversation_&_textarea]:min-h-[50px] [.focus-session.has-conversation_&_textarea]:p-[6px_7px_8px] dark:bg-[var(--solid)] dark:text-[var(--text)] @max-[700px]:grid-cols-[70px_36px_36px_auto_minmax(0,1fr)_36px] @max-[700px]:grid-rows-[minmax(48px,1fr)_36px] relative flex min-w-0 flex-col items-stretch gap-[4px] [border:1px_solid_var(--stroke)] rounded-[var(--r-md)] bg-[var(--solid)] [padding:8px] shadow-[0_14px_34px_-24px_var(--shadow-strong)] [transition:border-color_var(--d1)_var(--ease-out),_box-shadow_var(--d2)_var(--ease-out)]`,children:[(0,Z.jsx)(ei,{sessionId:e.id,value:Ke,onChange:Je,inputRef:dt}),(0,Z.jsx)(`textarea`,{ref:dt,rows:1,value:Ke,onChange:e=>{Je(e.target.value),e.currentTarget.style.height=`auto`,e.currentTarget.style.height=`${Math.min(e.currentTarget.scrollHeight,220)}px`},onPaste:Xe.pasteFiles,onCompositionStart:()=>St.current=!0,onCompositionEnd:()=>window.setTimeout(()=>St.current=!1,0),onKeyDown:e=>{!(e.nativeEvent.isComposing||St.current)&&gt(e.nativeEvent,je.sendMessage)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"data-mobile-composer-input":Ie||void 0,enterKeyHint:Ie&&je.sendMessage===`Enter`?`send`:`enter`,placeholder:Et}),(0,Z.jsxs)(`div`,{className:`focus-composer-footer flex min-w-0 items-center gap-1`,children:[(0,Z.jsxs)(`div`,{ref:Y,className:`focus-composer-quick-actions flex min-w-0 flex-1 items-center gap-1`,children:[(0,Z.jsx)(`button`,{ref:vt,type:`button`,className:`composer-tools-trigger grid size-9 min-w-9 flex-none place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] cursor-pointer transition-[background-color,color,border-color,box-shadow] duration-150 hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)] ${it?`active border-[var(--brand-blue)] bg-[var(--brand-blue-soft)] text-[var(--brand-blue-strong)]`:``}`,title:Tt,"aria-label":Tt,"aria-expanded":it,"aria-controls":wt,onClick:()=>at(e=>!e),children:it?(0,Z.jsx)(Me,{size:17}):(0,Z.jsx)(pt,{size:18})}),(0,Z.jsx)(`div`,{className:`focus-composer-visible-tools flex min-w-0 flex-none items-center gap-1`,children:qt.inline.map(Jt)}),(0,Z.jsxs)(pi,{open:it,label:K(`chat:focusSession.quickActions`),trayId:wt,anchorRef:vt,menuRef:yt,children:[qt.overflow.map(Jt),qt.overflow.length>0&&(0,Z.jsx)(`span`,{className:`mx-0.5 h-6 w-px flex-none bg-[var(--stroke-soft)]`,"aria-hidden":`true`}),(0,Z.jsx)(_i,{labels:Gt})]})]}),(0,Z.jsx)(`div`,{className:`focus-composer-secondary flex h-11 min-w-0 flex-none items-center justify-end`,children:(0,Z.jsx)(Ai,{usage:T,onThresholdChange:fe,compact:!0})}),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`grid !size-11 !min-w-11 place-items-center rounded-[var(--r-sm)] border border-transparent bg-[var(--surface-subtle)] text-[var(--text-muted)] transition-[background-color,color,border-color,box-shadow,transform] duration-200 hover:scale-105 hover:border-[var(--brand-blue)] hover:bg-[var(--brand-blue-soft)] hover:text-[var(--brand-blue-strong)]`,title:K(`chat:voiceMode.open`),"aria-label":K(`chat:voiceMode.open`),onClick:()=>rt(!0),children:(0,Z.jsx)(On,{size:17})}),(0,Z.jsx)(zs,{sessionId:e.id,shortcutEnabled:t,onLiveText:e=>{if(e===null){ft.current!==null&&(Ot(ft.current),ft.current=null);return}ft.current===null&&(ft.current=(dt.current?.value??Ke).trimEnd());let t=ft.current;Ot(t&&e?`${t}\n${e}`:t||e)},onInsert:e=>{let t=ft.current??(dt.current?.value??Ke).trimEnd();ft.current=null,Ot(t?`${t}\n${e}`:e),requestAnimationFrame(()=>dt.current?.focus())}})]}),(0,Z.jsx)(mc,{streaming:I,queueing:Ft,disabled:!I&&(Ft||!Ke.trim()&&!Xe.attachments.length&&!Lt),onAbort:ke})]})]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 min-h-[26px] items-center gap-[6px] [margin:0_8px_5px] text-[var(--text-tertiary)]`,children:[Ct&&(0,Z.jsxs)(`button`,{type:`button`,className:`composer-workspace-status [&_span]:min-w-0 [&_span]:overflow-hidden [&_span]:text-ellipsis [&_span]:whitespace-nowrap [&:hover:not(:disabled)]:text-[var(--star-strong)] disabled:opacity-[.55] disabled:[cursor:not-allowed] @max-[470px]:w-[24px] @max-[470px]:p-0 @max-[470px]:justify-center @max-[470px]:[&_span]:hidden inline-flex max-w-[180px] min-w-0 h-[24px] flex-none items-center gap-[4px] overflow-hidden border-0 rounded-[0] bg-transparent [padding:2px_0] text-inherit text-[10px] cursor-pointer`,title:A,"aria-label":K(`chat:focusSession.changeWorkingDirectoryWorkspace`,{workspace:Ye(A,Ae)}),onClick:he,disabled:I||P,children:[(0,Z.jsx)(Le,{size:12}),(0,Z.jsx)(`span`,{children:Ye(A,Ae)})]}),(0,Z.jsx)(ki,{usage:D,plan:He?g:null,compact:Ie})]})]}),(0,Z.jsx)(Wr,{open:Qe,sessionId:e.id,onClose:()=>$e(!1),onSelect:Rt,onCommandSelect:e=>Ut(qr(e,Ke))}),(0,Z.jsx)(cc,{open:nt,sessionId:e.id,sessionName:e.name||e.id,messages:n,streaming:I,sendPrompt:Te,onAbort:ke,onClose:()=>rt(!1)})]})}),Cc=(0,X.createContext)(null),wc=40,Tc=[];function Ec({params:e,api:t}){let n=(0,X.useContext)(Cc),r=e?.sessionId||st(t?.id),[i,a]=(0,X.useState)(()=>t.isVisible),[o,s]=(0,X.useState)(()=>t.isActive);return(0,X.useEffect)(()=>{s(t.isActive);let e=t.onDidActiveChange(({isActive:e})=>s(e));return()=>e.dispose()},[t]),(0,X.useEffect)(()=>{a(t.isVisible);let e=t.onDidVisibilityChange(({isVisible:e})=>a(e));return()=>e.dispose()},[t]),i?(0,Z.jsx)(kc,{sessionId:r,panelId:t.id,shortcutEnabled:o,onFocusCapture:()=>t.setActive(),canSplitPanel:n?.compactDock===!1&&t.group.size>1,canClosePanel:!0}):null}function Dc(){try{let e=JSON.parse(localStorage.getItem(de.mobileSessionTabs)||`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`).slice(-6):[]}catch{return[]}}function Oc({sessionIds:e=[],onSelectSession:t,onCreateSession:n}){let{t:r}=x(),i=(0,X.useContext)(Cc),a=i?.activeId||``,[o,s]=(0,X.useState)(Dc),c=(0,X.useRef)(!1),l=(0,X.useRef)(null),u=(0,X.useMemo)(()=>{let e=new Map(i?.sessions.map(e=>[e.id,e]));return o.flatMap(t=>{let n=e.get(t);return n?[n]:[]})},[i?.sessions,o]),d=i?.sessions.find(e=>e.id===a),f=d&&!u.some(e=>e.id===d.id)?[...u,d]:u,p=d?.id||f[0]?.id||``;(0,X.useEffect)(()=>{let t=new Set(i?.sessions.map(e=>e.id)),n=!c.current&&e.length?e:[];n.length&&(c.current=!0),s(e=>{let r=e.filter(e=>t.has(e));for(let e of[...n,a])e&&t.has(e)&&!r.includes(e)&&r.push(e);let i=r.slice(-6);return i.length===e.length&&i.every((t,n)=>t===e[n])?e:i})},[a,i?.sessions,e]),(0,X.useEffect)(()=>{localStorage.setItem(de.mobileSessionTabs,JSON.stringify(o))},[o]),(0,X.useEffect)(()=>{l.current?.scrollIntoView({block:`nearest`,inline:`center`})},[p]);let m=e=>{let n=Qe(f.map(e=>e.id),e,p);s(n.tabIds),n.activeId!==p&&t(n.activeId)};return(0,Z.jsxs)(`div`,{className:`mobile-session-shell flex h-full min-h-0 min-w-0 flex-col bg-[var(--panel)]`,children:[(0,Z.jsxs)(`nav`,{className:`mobile-session-tabs flex h-[52px] flex-none border-b border-[var(--stroke-soft)] bg-[var(--surface-subtle)]`,role:`tablist`,"aria-label":r(`chat:chatPage.openChats`),children:[(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:f.map(e=>{let n=e.name||r(`chat:chatPage.untitledChat`),i=e.id===p;return(0,Z.jsxs)(`div`,{className:`group relative flex h-full min-w-[148px] max-w-[228px] flex-none items-stretch border-b-[3px] transition-colors ${i?`border-[var(--brand-blue)] bg-[var(--solid)] text-[var(--text)]`:`border-transparent bg-transparent text-[var(--text-secondary)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)]`}`,children:[(0,Z.jsxs)(`button`,{ref:i?l:void 0,type:`button`,role:`tab`,id:`mobile-session-tab-${e.id}`,"aria-selected":i,"aria-controls":`mobile-session-tabpanel`,className:`flex min-w-0 flex-1 items-center gap-2 border-0 bg-transparent py-0 pl-3 text-left text-[13px] focus-visible:z-[1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)] ${i?`font-[650]`:`font-[500]`}`,title:n,onClick:()=>t(e.id),children:[(0,Z.jsx)(ft,{size:15,className:`flex-none`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:n}),e.streaming&&(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 flex-none rounded-full bg-[var(--brand-blue)]`})]}),(0,Z.jsx)(`button`,{type:`button`,className:`grid w-9 flex-none place-items-center border-0 bg-transparent text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:z-[1] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,title:r(`chat:chatPage.closeChat`,{title:n}),"aria-label":r(`chat:chatPage.closeChat`,{title:n}),onClick:()=>m(e.id),children:(0,Z.jsx)(Me,{size:14,"aria-hidden":`true`})})]},e.id)})}),(0,Z.jsx)(`button`,{type:`button`,className:`grid h-full w-[52px] flex-none place-items-center border-0 border-l border-[var(--stroke-soft)] bg-transparent text-[var(--text-muted)] hover:bg-[var(--surface-hover)] hover:text-[var(--text)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--focus)]`,title:r(`chat:chatPage.newChat`),"aria-label":r(`chat:chatPage.newChat`),onClick:()=>void n(),children:(0,Z.jsx)(pt,{size:20,"aria-hidden":`true`})})]}),(0,Z.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,role:`tabpanel`,id:`mobile-session-tabpanel`,"aria-labelledby":p?`mobile-session-tab-${p}`:void 0,children:p?(0,Z.jsx)(kc,{sessionId:p,panelId:``,shortcutEnabled:!0,canSplitPanel:!1,canClosePanel:!1}):(0,Z.jsx)(Ac,{onNewSession:n})})]})}function kc({sessionId:e,panelId:t,shortcutEnabled:n,onFocusCapture:r,canSplitPanel:i,canClosePanel:a}){let o=(0,X.useContext)(Cc),s=o?.subscribeSessionState,c=o?.getSessionState,l=(0,X.useMemo)(()=>t=>s?.(e,t)??(()=>{}),[s,e]),u=(0,X.useMemo)(()=>()=>c?.(e),[c,e]),d=(0,X.useSyncExternalStore)(l,u),f=o?.sessions.find(t=>t.id===e),p=d||hr,m=!!(p.streaming||f?.streaming),h=Tr(d,f),g=d&&Object.hasOwn(d,`team`)?d.team:f?.team??null,_=Er(h,{streaming:m})?h:null,v=o?.sessionTreePulseSessionId===e?o.sessionTreePulseToken:0,y=o?.loadSessionMessages,b=o?.loadSessionThinkingLevel,x=(0,X.useRef)(``);(0,X.useEffect)(()=>{e&&y?.(e,{limit:wc})},[y,e]),(0,X.useEffect)(()=>{!e||!f||!b||m||p.thinkingStatus||(p.availableThinkingLevels||[]).length||x.current!==e&&(x.current=e,b(e))},[b,f,e,p.availableThinkingLevels,p.thinkingStatus,m]);let S=(0,X.useMemo)(()=>({onLoadOlder:()=>o?.loadOlderMessages(e)??!1,onModelChange:t=>o?.switchSessionModel(e,t),onThinkingLevelChange:t=>o?.switchSessionThinkingLevel(e,t),onExecutionModeChange:t=>o?.switchSessionExecutionMode(e,t)??!1,onRunModeChange:t=>o?.switchSessionRunMode(e,t)??!1,onGoalPause:()=>o?.pauseGoal(e),onGoalBudgetChange:t=>o?.setGoalBudget(e,t),onCompact:()=>o?.compactSession(e),onApproval:(t,n)=>o?.resolveToolApproval(e,t,n),onWorkspace:()=>{f&&o?.selectSessionWorkspace(f)},onRename:()=>{f&&o?.renameSession(f)},onBranchFromHere:e=>{if(f)return o?.branchFromEntry(f,e)},onCreateChildSession:e=>{if(f)return o?.createChildSession(f,e)},onTreeNavigated:()=>o?.reloadSessionBranch(e),onSplitLeft:()=>o?.splitDockPanel(t,`left`),onSplitRight:()=>o?.splitDockPanel(t,`right`),onSplitTop:()=>o?.splitDockPanel(t,`above`),onSplitBottom:()=>o?.splitDockPanel(t,`below`),onClosePanel:()=>o?.closeDockPanel(t),onSend:(t,n,r,i,a,s)=>o?.sendPrompt(t,e,n,r,i,a,s),onQueue:(t,n,r)=>o?.queuePrompt(t,e,n,r)??!1,onWithdrawQueuedInput:t=>o?.withdrawQueuedInput(e,t)??Promise.resolve(null),onAbort:()=>o?.abort(e)}),[o,e,f,t]);if(!o||!f)return(0,Z.jsxs)(`div`,{className:`session-dock-missing flex h-full min-h-[180px] items-center justify-center gap-[8px] text-[var(--text-secondary)] text-[12px]`,children:[(0,Z.jsx)(et,{size:16}),o?`Session unavailable`:`Loading session`]});let C=o.pendingAsset?.asset&&(!o.pendingAsset.targetSessionId||o.pendingAsset.targetSessionId===e)?o.pendingAsset.asset:null;return(0,Z.jsx)(`div`,{className:`session-dock-panel w-full h-full min-w-0 min-h-0 overflow-hidden [container-type:inline-size] bg-[var(--panel)]`,onFocusCapture:r,children:(0,Z.jsx)(Sc,{session:f,shortcutEnabled:n,messages:p.messages||Tc,transcriptLoadState:p.loaded?`ready`:p.loading||!p.error?`loading`:`error`,messageStart:p.messageStart,hasOlder:p.hasOlder,loadingOlder:p.loadingOlder,olderError:p.olderError,model:p.model||f.model||o.defaultModel,thinkingLevel:p.thinkingLevel||f.thinkingLevel||`medium`,availableThinkingLevels:p.availableThinkingLevels||Tc,thinkingStatus:p.thinkingStatus||``,thinkingMessage:p.thinkingMessage||``,executionMode:p.executionMode||f.executionMode||`approval-required`,runMode:p.runMode||f.runMode||`plan`,goal:p.goal??f.goal??null,team:g,plan:_,currentActivity:p.currentActivity,activityFeed:p.activityFeed||Tc,tools:p.tools||Tc,thinkingText:p.thinkingText||``,queuedInputs:p.queuedInputs||Tc,withdrawingInputIds:p.withdrawingInputIds||Tc,compaction:p.compaction,contextUsage:p.contextUsage,sessionUsage:p.sessionUsage,sessionTreeRevision:p.sessionTreeRevision,sessionTreePulse:v,cwd:p.cwd||f.cwd,availableModels:o.availableModels,switchingModel:p.switchingModel,switchingThinking:p.switchingThinking,switchingCwd:p.switchingCwd,switchingPermission:p.switchingPermission,streaming:m,runStartedAt:p.runStartedAt,lastActivityAt:p.lastActivityAt,runFinishedAt:p.runFinishedAt,runStopped:p.runStopped,runNotice:p.runNotice,approvals:p.approvals||Tc,error:p.error||(o.activeId===e?o.globalError:``),pendingAsset:C,onAssetConsumed:o.onAssetConsumed,notify:o.notify,onOpenModelSettings:o.openModelSettings,onCompactionThresholdChange:o.setCompactionThreshold,canSplit:i,canClosePanel:a,...S})})}function Ac({onNewSession:e,newSessionShortcut:t}){let{t:n}=x();return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-[180px] flex-col items-center justify-center gap-[8px] text-center text-[12px] text-[var(--text-secondary)]`,children:[(0,Z.jsx)(ft,{size:34}),(0,Z.jsx)(`strong`,{className:`text-[14px] text-[var(--text)]`,children:n(`chat:chatDock.openAChatToBegin`)}),(0,Z.jsx)(`span`,{className:`max-w-[320px] leading-[1.55]`,children:n(`chat:chatDock.openAChatFromTheSessionListOrSplitItInAnyDirection`)}),e?(0,Z.jsxs)(`button`,{type:`button`,className:`mt-[10px] inline-flex cursor-pointer items-center gap-[6px] rounded-[var(--r-sm)] border-0 bg-[var(--brand-blue)] px-[16px] py-[8px] text-[12px] font-[600] text-white transition-colors duration-[var(--d1)] hover:bg-[var(--brand-blue-hover)] focus-visible:outline-[2px] focus-visible:outline-offset-2 focus-visible:outline-[var(--focus)]`,onClick:()=>void e(),children:[(0,Z.jsx)(pt,{size:14,"aria-hidden":`true`}),n(`chat:chatDock.newChat`),t?(0,Z.jsx)(`kbd`,{className:`ml-[2px] rounded-[4px] border border-white/35 bg-white/10 px-[5px] py-[1px] font-sans text-[10px] font-[500] leading-[1.4]`,children:t}):null]}):null]})}var jc=`web-preview`;function Mc(e,t=`Web preview`){try{return new URL(e).hostname.replace(/^www\./i,``)||t}catch{return t}}export{lr as S,br as _,Ec as a,fr as b,tc as c,Ui as d,Wi as f,xr as g,_r as h,Oc as i,$ as l,hr as m,Mc as n,Cc as o,Gi as p,Ac as r,ec as s,jc as t,Qa as u,Sr as v,cr as x,ur as y};