@yuriai/web 0.3.4 → 0.3.6-beta.5

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 (293) hide show
  1. package/dist/assets/AgentAvatar-BaKbuiEG.js +1 -0
  2. package/dist/assets/AgentSelector-BXLvdwk0.js +1 -0
  3. package/dist/assets/ArchivedSessionsDialog-wIl8A7HL.js +1 -0
  4. package/dist/assets/AssistantConversationSurface-DRwJ4zWe.js +3 -0
  5. package/dist/assets/AssistantSessionCard-D1AZs8JQ.js +2 -0
  6. package/dist/assets/AssistantUnreadBadge-4aoNcXVG.js +1 -0
  7. package/dist/assets/AssistantView-CG0DnE1H.js +1 -0
  8. package/dist/assets/AssistantWorkingAvatar-uOBMRhP_.js +1 -0
  9. package/dist/assets/AssistantsSettingsPage-DIWJVEf8.js +1 -0
  10. package/dist/assets/BinaryFileFallback-BH_-EIjs.js +1 -0
  11. package/dist/assets/BtwPanel-DRdap4Qu.js +6 -0
  12. package/dist/assets/BusyDots-BGjLnIPh.js +4 -0
  13. package/dist/assets/ChatContainer-BtfbvM1R.js +65 -0
  14. package/dist/assets/ChatView-CUwLwCFl.js +3 -0
  15. package/dist/assets/{DiagramView-DGnmjS2b.js → DiagramView-CRZFpG4-.js} +1 -1
  16. package/dist/assets/{DiffView-Bbit6OZ8.js → DiffView-4Z0aCFfu.js} +2 -2
  17. package/dist/assets/DiffViewToggle-DYSI03aW.js +1 -0
  18. package/dist/assets/ErrorBoundary-CinEsvgD.js +1 -0
  19. package/dist/assets/FadeInOnReveal-P-c7VO7Q.js +1 -0
  20. package/dist/assets/{GuiPluginMount-TC5FELtQ.js → GuiPluginMount-DtJaOBdU.js} +1 -1
  21. package/dist/assets/GuiPluginPage-DSeGfoT6.js +1 -0
  22. package/dist/assets/GuiPluginSurface-357Sz83f.js +1 -0
  23. package/dist/assets/GuiPluginTitlebarItems-XIPpX6DU.js +1 -0
  24. package/dist/assets/{GuiPluginWindow-BkAFJyFd.js → GuiPluginWindow-ICodvkoO.js} +1 -1
  25. package/dist/assets/Icon-CeG6IExS.js +1 -0
  26. package/dist/assets/ImageLoadingPlaceholder-zzKCgcZz.js +1 -0
  27. package/dist/assets/{LoadingImage-Df22Rkor.js → LoadingImage-B4Icoej_.js} +1 -1
  28. package/dist/assets/MarkdownRenderer-Bjm6Wld2.js +2 -0
  29. package/dist/assets/{MarkdownRendererImpl-D8q0FMnr.js → MarkdownRendererImpl-BdOA-vAV.js} +1 -1
  30. package/dist/assets/MarkstreamRendererImpl-j30G11Dc.js +3 -0
  31. package/dist/assets/{MobileAssistantSettingsPage-Dgq5FMho.js → MobileAssistantSettingsPage-CGK1ceah.js} +1 -1
  32. package/dist/assets/MobileAssistantTab-ZugumKSY.js +1 -0
  33. package/dist/assets/{MobileBtwPage-DQUkSO6N.js → MobileBtwPage-afopNi2T.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-DsYNmAuM.js → MobileChangesSurface-C3mhr7en.js} +2 -2
  35. package/dist/assets/MobileChatScreen-ByOiuFAV.js +1 -0
  36. package/dist/assets/MobileDetailNavigation-IQDDP6TO.js +1 -0
  37. package/dist/assets/MobileFilesSurface-Bia8vPcg.js +2 -0
  38. package/dist/assets/MobileHtmlNetworkBoundary-DCiTI-t-.js +2 -0
  39. package/dist/assets/MobileOverlayPanel-D0W5tjrd.js +1 -0
  40. package/dist/assets/MobileResizableSheet-0fdiGkg0.js +1 -0
  41. package/dist/assets/{MobileSettingsTab-DaTtRHo1.js → MobileSettingsTab-iPLVIfcN.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-CZpFYmiy.js → MobileShareBridge-DzcR4Knr.js} +1 -1
  43. package/dist/assets/MobileSurface-B1fG72a-.js +1 -0
  44. package/dist/assets/MobileTabPageHeader-BFKAUrAU.js +1 -0
  45. package/dist/assets/ModelLogo-CYR-ynHM.js +1 -0
  46. package/dist/assets/ModelSelector-B3h2Xy64.js +1 -0
  47. package/dist/assets/MultiRunWindow-C8S7H7Md.js +1 -0
  48. package/dist/assets/OnboardingScreen-D7fZQm8c.js +1 -0
  49. package/dist/assets/OverlayScrollbar-C5v7GRZi.js +1 -0
  50. package/dist/assets/{PierreDiffViewer-DVKsdwJR.js → PierreDiffViewer-CxRfGY_b.js} +3 -3
  51. package/dist/assets/ProviderLogo-zqjvjfIK.js +1 -0
  52. package/dist/assets/{RemoteAssistantSessionCard-DAoFvZht.js → RemoteAssistantSessionCard-B284CHHf.js} +1 -1
  53. package/dist/assets/RemoteDesktopPanel-CREalB4m.js +1 -0
  54. package/dist/assets/ScheduledTasksDialog-YAy5JZVs.js +3 -0
  55. package/dist/assets/ScrollableOverlay-BGOUZmbS.js +1 -0
  56. package/dist/assets/SettingsGroup-BoEy2EFq.js +1 -0
  57. package/dist/assets/{SettingsView-DEU94-h1.js → SettingsView-cLTUC0DF.js} +13 -13
  58. package/dist/assets/SettingsWindow-Kp2ClVgJ.js +1 -0
  59. package/dist/assets/SetupTourDialog-DNb6i2Z1.js +1 -0
  60. package/dist/assets/{SyncActions-CrOoREWF.js → SyncActions-D7uIFrJB.js} +1 -1
  61. package/dist/assets/TerminalView-viydTW0Q.js +8 -0
  62. package/dist/assets/TextSelectionMenu-B3RIGNm7.js +11 -0
  63. package/dist/assets/{ToolOutputDialog-DpaaQ1uZ.js → ToolOutputDialog-CoGamWCH.js} +1 -1
  64. package/dist/assets/{YuriLogo-Cp6vWDWp.js → YuriLogo-_1Inxw8P.js} +1 -1
  65. package/dist/assets/{YuriWordmark-CLGHwobA.js → YuriWordmark-CW53XKgV.js} +1 -1
  66. package/dist/assets/{assistant-attachment-cache-bRIIESGe.js → assistant-attachment-cache-eNT2QtmP.js} +1 -1
  67. package/dist/assets/assistantMessagePreview-CDdckvGJ.js +1 -0
  68. package/dist/assets/assistantQueries-DKqpPYqd.js +1 -0
  69. package/dist/assets/{auto-read-context-ClBUErN2.js → auto-read-context-G7T0GxFZ.js} +1 -1
  70. package/dist/assets/{capgoAdapter-pfQJmvW2.js → capgoAdapter-Cu4rw1AP.js} +1 -1
  71. package/dist/assets/card-BBxZ1WhJ.js +1 -0
  72. package/dist/assets/chatUpwardIntent-DmVhPEhT.js +1 -0
  73. package/dist/assets/checkbox-D9uVg1CM.js +1 -0
  74. package/dist/assets/{client-B_907PBv.js → client-ITylDDCS.js} +1 -1
  75. package/dist/assets/collapsible-_BAnUguY.js +1 -0
  76. package/dist/assets/{connection-hint-B-kOWome.js → connection-hint-BnhKxvRb.js} +1 -1
  77. package/dist/assets/context-menu-j9GOycjo.js +1 -0
  78. package/dist/assets/diagram-B4DOrQoy.js +1 -0
  79. package/dist/assets/dialog-CZlghHCF.js +1 -0
  80. package/dist/assets/dropdown-menu-C-MjrLjA.js +1 -0
  81. package/dist/assets/{es-DqYZgeC6.js → es-BxH-QWNw.js} +1 -1
  82. package/dist/assets/{fileMentionTouchSelection-BQEUty_A.js → fileMentionTouchSelection-Dv6PCS5x.js} +1 -1
  83. package/dist/assets/{fileReferenceActions-TmbrIHBI.js → fileReferenceActions-B2jCazPJ.js} +1 -1
  84. package/dist/assets/{fr-BHaun7Zq.js → fr-BuXhxsLA.js} +1 -1
  85. package/dist/assets/{gitApi-CoVwjIDy.js → gitApi-BnZcCLpz.js} +1 -1
  86. package/dist/assets/gitApiHttp-DF1ID314.js +3 -0
  87. package/dist/assets/githubAuthQueries-C5RxUNL2.js +1 -0
  88. package/dist/assets/historyImportQueries-CZsECryv.js +1 -0
  89. package/dist/assets/{host-ChBHl_Vl.js → host-C7jHgymK.js} +1 -1
  90. package/dist/assets/{i18n-DXc6czdR.js → i18n-BcqhT5IQ.js} +1 -1
  91. package/dist/assets/{icons-Bd-INsoy.js → icons-BjKhmiUB.js} +1 -1
  92. package/dist/assets/{imageSource-BR4C9TuS.js → imageSource-Cq_p4gAe.js} +1 -1
  93. package/dist/assets/input-CK6ESZJN.js +1 -0
  94. package/dist/assets/{input-store-BSJBQTMi.js → input-store-dLjM4aiu.js} +1 -1
  95. package/dist/assets/insertionBoundaries-CD1bfNQI.js +1 -0
  96. package/dist/assets/{ja-BGNugvrx.js → ja-qWngDHZr.js} +1 -1
  97. package/dist/assets/kbd-DqpD1Z1W.js +1 -0
  98. package/dist/assets/{ko-CGbNBfDe.js → ko-CSKPW13b.js} +1 -1
  99. package/dist/assets/main-buUrzK21.js +2 -0
  100. package/dist/assets/main-wnAp11Lg.js +169 -0
  101. package/dist/assets/{markdownHeightCache-CHGGNhWI.js → markdownHeightCache-B5NINUfB.js} +1 -1
  102. package/dist/assets/mcpQueries-CEyM57ph.js +1 -0
  103. package/dist/assets/miniChat-DDuanxyB.js +2 -0
  104. package/dist/assets/mobile-CL1PHr-g.js +2 -0
  105. package/dist/assets/{mobileBackNavigation-C94n2eLT.js → mobileBackNavigation-Cqz28R4e.js} +1 -1
  106. package/dist/assets/mobileConnections-DBVkkjN_.js +2 -0
  107. package/dist/assets/multirun-CG2iQzs1.js +3 -0
  108. package/dist/assets/{native-config-DVg8_Zx1.js → native-config-q8-2XVGB.js} +1 -1
  109. package/dist/assets/{nativeComposerCover-Bhv1EKPT.js → nativeComposerCover-X18Rxy9s.js} +1 -1
  110. package/dist/assets/{navigation-D1klsD7k.js → navigation-B17JP7Nc.js} +2 -2
  111. package/dist/assets/openRemoteProjectSession-B2oJdHC6.js +1 -0
  112. package/dist/assets/{pl-k8-4URiE.js → pl-ON0IoadC.js} +1 -1
  113. package/dist/assets/pluginPresentation-OcngX2e8.js +2 -0
  114. package/dist/assets/{project-preview-BCtFY4Rg.js → project-preview-BcLPKzwg.js} +1 -1
  115. package/dist/assets/{prompt-attachment-upload-B5DHrw6U.js → prompt-attachment-upload-BGppTOgV.js} +1 -1
  116. package/dist/assets/{pt-BR-DdwCzXBH.js → pt-BR-BAekLJyC.js} +1 -1
  117. package/dist/assets/pwa-dfKnHt2U.js +2 -0
  118. package/dist/assets/queue-abort-optimistic-CIugRVbT.js +1 -0
  119. package/dist/assets/{quota-CqWNkFzw.js → quota-BpQX7Pfg.js} +1 -1
  120. package/dist/assets/{reference-history-IEuzG8KC.js → reference-history-Dk7Uz1e9.js} +1 -1
  121. package/dist/assets/{remote-input-store-C6UIEZxp.js → remote-input-store-DdjKfpxS.js} +1 -1
  122. package/dist/assets/remoteProjectQueries-BXrXdLjN.js +1 -0
  123. package/dist/assets/{remoteSessionReference-ex07CtrZ.js → remoteSessionReference-DL-cFaU4.js} +1 -1
  124. package/dist/assets/renderElectronMiniChatApp-D-qMtvJ5.js +2 -0
  125. package/dist/assets/renderMobileApp-DE4dovZy.js +17 -0
  126. package/dist/assets/{runtime-file-download-BWeoSXRb.js → runtime-file-download-1s2Al1t3.js} +1 -1
  127. package/dist/assets/runtime-file-resource-C5kmYlLv.js +6 -0
  128. package/dist/assets/{runtimeConfig-CyvlrO58.js → runtimeConfig-Bto7mqiH.js} +1 -1
  129. package/dist/assets/runtimeEndpointReset-C41HR0MC.js +4 -0
  130. package/dist/assets/{scheduledTaskNavigation-VVTOq9n2.js → scheduledTaskNavigation-qCB0nuyR.js} +1 -1
  131. package/dist/assets/select-DsqFxij6.js +1 -0
  132. package/dist/assets/{sessionLookup-DQOiycHr.js → sessionLookup-BL43L4KX.js} +1 -1
  133. package/dist/assets/sessionOwnership-CoFyzErn.js +2 -0
  134. package/dist/assets/shortcuts-CS2j7q63.js +1 -0
  135. package/dist/assets/sortable-tabs-strip-DiIB2-kp.js +1 -0
  136. package/dist/assets/speechSettingsQueries-DXlNIuv5.js +1 -0
  137. package/dist/assets/src-DYCPWwUH.css +2 -0
  138. package/dist/assets/{store-C1ifDY0C.js → store-BHq6XijA.js} +3 -3
  139. package/dist/assets/switch-C-h9UNYt.js +1 -0
  140. package/dist/assets/{terminalApi-DXvEquBF.js → terminalApi-2TIqWX2z.js} +1 -1
  141. package/dist/assets/textarea-DjSTlLEk.js +1 -0
  142. package/dist/assets/{timeFormat-dCsf2MQv.js → timeFormat-CPklO4G4.js} +1 -1
  143. package/dist/assets/tooltip-mPnbOruE.js +1 -0
  144. package/dist/assets/truncated-path-DJ1GdoM1.js +1 -0
  145. package/dist/assets/types-DjjmI1B9.js +2 -0
  146. package/dist/assets/ui-Cd2-HQSa.js +13 -0
  147. package/dist/assets/{uk-DU-7fAP4.js → uk-CV7mskVO.js} +1 -1
  148. package/dist/assets/{useAppFontEffects-rbTKcF0f.js → useAppFontEffects-mOLMhLug.js} +5 -5
  149. package/dist/assets/{useAssistantUIStore-CpJZ4Rqs.js → useAssistantUIStore-AI2LkqlQ.js} +1 -1
  150. package/dist/assets/useDesktopWindowControlsLayout-BC62ly7f.js +1 -0
  151. package/dist/assets/{useDictation-CZzAlsW0.js → useDictation-D8v7PflM.js} +1 -1
  152. package/dist/assets/{useEffectiveDirectory-DiJBIfai.js → useEffectiveDirectory-CCVmwzs7.js} +1 -1
  153. package/dist/assets/{useFontPreferences-BiRBKhti.js → useFontPreferences-DB18Mtz6.js} +1 -1
  154. package/dist/assets/{useGitStore-Bv8xmXDa.js → useGitStore-Bab2zave.js} +1 -1
  155. package/dist/assets/{useInlineCommentDraftStore-B2mkmAZd.js → useInlineCommentDraftStore-DAYe4P_i.js} +1 -1
  156. package/dist/assets/useMcpConfigStore-BJm6513j.js +1 -0
  157. package/dist/assets/useMobileSwipeActions-D0WXnZEj.js +1 -0
  158. package/dist/assets/useMobileTranscriptSyncHint-CG4nKZAr.js +10 -0
  159. package/dist/assets/useModelLists-BimLCgIE.js +1 -0
  160. package/dist/assets/useOpenCodeReadiness-DXkY7-Jm.js +1 -0
  161. package/dist/assets/usePluginsStore-C69K4oDx.js +1 -0
  162. package/dist/assets/useProjectGitActions-DVpxGjd_.js +1 -0
  163. package/dist/assets/{useProjectGitStore-DzU2pvrH.js → useProjectGitStore-tqdyts8E.js} +1 -1
  164. package/dist/assets/{useProjectRuntimeAPIs-tjGuODhu.js → useProjectRuntimeAPIs-3ykZWBEc.js} +1 -1
  165. package/dist/assets/useQuotaStore-B3QxYEfM.js +1 -0
  166. package/dist/assets/{useSessionBtwStore-CwvlMabN.js → useSessionBtwStore-LV6b9oRF.js} +1 -1
  167. package/dist/assets/{useStreamingTextThrottle-C9SaKeil.js → useStreamingTextThrottle-ClWAbNdQ.js} +1 -1
  168. package/dist/assets/{useUIStore-C3ewjGgP.js → useUIStore-Dzf_W6hZ.js} +1 -1
  169. package/dist/assets/worktreeManager-CZpGApxy.js +1 -0
  170. package/dist/assets/{worktreeSourceBranchPreference-CuLKwxkx.js → worktreeSourceBranchPreference-CyrpQH5R.js} +1 -1
  171. package/dist/assets/{zh-CN-DOHH7nht.js → zh-CN-D9xdLrNm.js} +1 -1
  172. package/dist/assets/{zh-TW-t1qlXGOg.js → zh-TW-Dyiv4-Dr.js} +1 -1
  173. package/dist/index.html +13 -14
  174. package/dist/mini-chat.html +13 -14
  175. package/dist/mobile.html +2 -2
  176. package/package.json +1 -1
  177. package/server/index.js +1 -0
  178. package/server/lib/gui-customization/DOCUMENTATION.md +22 -1
  179. package/server/lib/gui-customization/projects-client.mjs +14 -3
  180. package/server/lib/gui-customization/projects-lifecycle.js +89 -0
  181. package/server/lib/gui-customization/projects-lifecycle.test.js +199 -0
  182. package/server/lib/gui-customization/projects.js +19 -3
  183. package/server/lib/gui-customization/projects.test.js +6 -0
  184. package/server/lib/gui-customization/session-skill.js +2 -2
  185. package/server/lib/gui-customization/session-skill.test.js +6 -0
  186. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  187. package/server/lib/gui-customization/skill/references/projects.md +30 -0
  188. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  189. package/server/lib/opencode/feature-routes-runtime.test.js +6 -0
  190. package/server/lib/opencode/settings-helpers.js +4 -0
  191. package/dist/assets/AgentAvatar-CHCjMxCF.js +0 -1
  192. package/dist/assets/AgentSelector-uBoLtut8.js +0 -1
  193. package/dist/assets/ArchivedSessionsDialog-DZcicxVO.js +0 -1
  194. package/dist/assets/AssistantConversationSurface-36aP0hRf.js +0 -3
  195. package/dist/assets/AssistantSessionCard-CZ-1oJiE.js +0 -2
  196. package/dist/assets/AssistantUnreadBadge-p9mkpbMC.js +0 -1
  197. package/dist/assets/AssistantView-8fyAae7J.js +0 -1
  198. package/dist/assets/AssistantWorkingAvatar-CoxhuMvM.js +0 -1
  199. package/dist/assets/AssistantsSettingsPage-DD6spbXz.js +0 -1
  200. package/dist/assets/BinaryFileFallback-DgYaMG9f.js +0 -1
  201. package/dist/assets/BtwPanel-BkobGcf3.js +0 -6
  202. package/dist/assets/BusyDots-COTTwItx.js +0 -4
  203. package/dist/assets/ChatContainer-BfQ7RXwY.js +0 -65
  204. package/dist/assets/ChatView-ByMRjY1h.js +0 -3
  205. package/dist/assets/DiffViewToggle-BwJ6MYB7.js +0 -1
  206. package/dist/assets/ErrorBoundary-D7QcwhmL.js +0 -1
  207. package/dist/assets/FadeInOnReveal-B3uT04YJ.js +0 -1
  208. package/dist/assets/GuiPluginPage-BPjU8N49.js +0 -1
  209. package/dist/assets/GuiPluginSurface-CYPH6XzX.js +0 -1
  210. package/dist/assets/GuiPluginTitlebarItems-DxFINwbr.js +0 -1
  211. package/dist/assets/Icon-DmykXZL1.js +0 -1
  212. package/dist/assets/ImageLoadingPlaceholder-DgM_EFHn.js +0 -1
  213. package/dist/assets/MarkdownRenderer-VvziwyJB.js +0 -2
  214. package/dist/assets/MarkstreamRendererImpl-U_m_ZKG7.js +0 -3
  215. package/dist/assets/MobileAssistantTab-CMIQansR.js +0 -1
  216. package/dist/assets/MobileChatScreen-p356_BCN.js +0 -1
  217. package/dist/assets/MobileDetailNavigation-ldTzGo19.js +0 -1
  218. package/dist/assets/MobileFilesSurface-CF3EW_SK.js +0 -2
  219. package/dist/assets/MobileHtmlNetworkBoundary-DlPF4iPS.js +0 -2
  220. package/dist/assets/MobileOverlayPanel-C36VWWmN.js +0 -1
  221. package/dist/assets/MobileResizableSheet-CqphcaKq.js +0 -1
  222. package/dist/assets/MobileSurface-cmaGf3hZ.js +0 -1
  223. package/dist/assets/MobileTabPageHeader-D6P4K98S.js +0 -1
  224. package/dist/assets/ModelLogo-BkbD514M.js +0 -1
  225. package/dist/assets/ModelSelector-EmtltPnd.js +0 -1
  226. package/dist/assets/MultiRunWindow-CeSxAB8w.js +0 -1
  227. package/dist/assets/OnboardingScreen-BubjTNcy.js +0 -1
  228. package/dist/assets/OverlayScrollbar-D6vmoMkQ.js +0 -1
  229. package/dist/assets/ProviderLogo-DA98yu7M.js +0 -1
  230. package/dist/assets/RemoteDesktopPanel-f3vRj4ZP.js +0 -1
  231. package/dist/assets/ScheduledTasksDialog-D_hBP47Y.js +0 -3
  232. package/dist/assets/ScrollableOverlay-stxT7gLf.js +0 -1
  233. package/dist/assets/SettingsGroup-CvaPYznp.js +0 -1
  234. package/dist/assets/SettingsWindow-DMVAV_el.js +0 -1
  235. package/dist/assets/SetupTourDialog-BlR7FJvd.js +0 -1
  236. package/dist/assets/TerminalView-Xcwp3SG1.js +0 -8
  237. package/dist/assets/TextSelectionMenu-h8iUeNzE.js +0 -11
  238. package/dist/assets/assistantMessagePreview-DLBvPQtq.js +0 -1
  239. package/dist/assets/assistantQueries-NdPqu6rx.js +0 -1
  240. package/dist/assets/card-DmysoUAV.js +0 -1
  241. package/dist/assets/chatUpwardIntent-B2NrGMm-.js +0 -1
  242. package/dist/assets/checkbox-BMN5hAVm.js +0 -1
  243. package/dist/assets/collapsible-Z0IjDAMO.js +0 -1
  244. package/dist/assets/context-menu-CKlB6wxo.js +0 -1
  245. package/dist/assets/diagram-CzY6n_4N.js +0 -1
  246. package/dist/assets/dialog-BeFBA6ja.js +0 -1
  247. package/dist/assets/dropdown-menu-BblI9sN2.js +0 -1
  248. package/dist/assets/gitApiHttp-Dd-FwgCq.js +0 -3
  249. package/dist/assets/githubAuthQueries-DqregESf.js +0 -1
  250. package/dist/assets/historyImportQueries-D00KjUT2.js +0 -1
  251. package/dist/assets/input-Cf16qJ6g.js +0 -1
  252. package/dist/assets/insertionBoundaries-Btqgsu1M.js +0 -1
  253. package/dist/assets/kbd-CamdaxHJ.js +0 -1
  254. package/dist/assets/main-CXH2hObl.js +0 -169
  255. package/dist/assets/main-ClH7cLKr.js +0 -2
  256. package/dist/assets/mcpQueries-Rmp1BKeo.js +0 -1
  257. package/dist/assets/miniChat-B_Bw6udu.js +0 -2
  258. package/dist/assets/mobile-BR73yoNi.js +0 -2
  259. package/dist/assets/mobileConnections-x07fHO_5.js +0 -2
  260. package/dist/assets/multirun-CKQymP08.js +0 -3
  261. package/dist/assets/openRemoteProjectSession-DNr74gHD.js +0 -1
  262. package/dist/assets/pluginPresentation-DtyC8NF2.js +0 -2
  263. package/dist/assets/pwa-CtDladgB.js +0 -2
  264. package/dist/assets/queue-abort-optimistic-DFbWDRKT.js +0 -1
  265. package/dist/assets/remoteProjectQueries-C8382jM8.js +0 -1
  266. package/dist/assets/renderElectronMiniChatApp-DM9y9qXo.js +0 -2
  267. package/dist/assets/renderMobileApp-DqpPYtZI.js +0 -17
  268. package/dist/assets/runtime-file-resource-Bc_ss-sW.js +0 -2
  269. package/dist/assets/runtimeEndpointReset-C0zNrsI9.js +0 -4
  270. package/dist/assets/select-vZCgcnYG.js +0 -1
  271. package/dist/assets/session-startup-barrier-DT-hIBRf.js +0 -1
  272. package/dist/assets/sessionOwnership-BjhXe6pi.js +0 -2
  273. package/dist/assets/shortcuts-WkN3Gh8v.js +0 -1
  274. package/dist/assets/sortable-tabs-strip-DmtfYPz0.js +0 -1
  275. package/dist/assets/speechSettingsQueries-BmkXNn4w.js +0 -1
  276. package/dist/assets/src-QTj33Z0x.css +0 -2
  277. package/dist/assets/switch-CNmsFYfY.js +0 -1
  278. package/dist/assets/textarea-ZiXxEOHK.js +0 -1
  279. package/dist/assets/tooltip-CpTbxEOE.js +0 -1
  280. package/dist/assets/truncated-path-CcmWjgCQ.js +0 -1
  281. package/dist/assets/types-DpcA-uDW.js +0 -2
  282. package/dist/assets/ui-ee2iN869.js +0 -13
  283. package/dist/assets/useDesktopWindowControlsLayout-BOkRz-p9.js +0 -1
  284. package/dist/assets/useMcpConfigStore-DKTl0PvE.js +0 -1
  285. package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +0 -1
  286. package/dist/assets/useMobileTranscriptSyncHint-DM8WG7kz.js +0 -10
  287. package/dist/assets/useModelLists-Bf60FIJu.js +0 -1
  288. package/dist/assets/useOpenCodeReadiness-Dm6BjA1T.js +0 -1
  289. package/dist/assets/usePluginsStore-Du4WlceO.js +0 -1
  290. package/dist/assets/useProjectGitActions-D3B9ma9z.js +0 -1
  291. package/dist/assets/useQuotaStore-CSn2pk3T.js +0 -1
  292. package/dist/assets/worktreeManager-DGu8M01Z.js +0 -1
  293. package/dist/assets/yuriEvents-BFrD5fMU.js +0 -5
@@ -1,6 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{d as t,q as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{U as a,X as o,lt as s}from"./client-B_907PBv.js";import{T as c,c as l,l as u,u as d,y as f}from"./prompt-attachment-upload-B5DHrw6U.js";import{n as p}from"./vendor-react-BkccXcWz.js";import{E as m,k as h}from"./runtime-file-resource-Bc_ss-sW.js";import{a as g,i as _,t as v}from"./path-utils-jGozTg9d.js";import{i as y,m as b,r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-C3ewjGgP.js";import{r as C}from"./vendor-sonner-DX3nfJx4.js";import{i as w,r as T,t as E}from"./spacedFileMention-Ds4GtgiF.js";import{i as D,o as O}from"./session-startup-barrier-DT-hIBRf.js";import{n as k}from"./Icon-DmykXZL1.js";import{Cn as A,Dn as j,Hi as M,Ja as N,Tt as P,ma as F,na as ee,t as I,wn as L,x as R}from"./ui-ee2iN869.js";import{n as te,t as z}from"./i18n-DXc6czdR.js";import{i as B,t as V}from"./store-C1ifDY0C.js";import{t as H}from"./MobileResizableSheet-CqphcaKq.js";import{t as U}from"./vendor-framer-motion-D5NyyC73.js";import{i as W,n as G,t as K}from"./tooltip-CpTbxEOE.js";import{r as q}from"./device-EIfSfSWk.js";import{c as ne,n as re,r as ie,t as ae}from"./dropdown-menu-BblI9sN2.js";import{n as oe}from"./useEffectiveDirectory-DiJBIfai.js";import{n as se,t as J}from"./MarkdownRenderer-VvziwyJB.js";import{a as ce,p as le,s as ue}from"./SessionSurfaceContext-BP4NCKp6.js";import{a as de,n as fe,o as Y,r as X,t as pe}from"./useSessionBtwStore-CwvlMabN.js";import{i as me,n as Z,o as he}from"./nativeComposerCover-Bhv1EKPT.js";import{i as ge,n as _e,r as ve,t as ye}from"./chatUpwardIntent-B2NrGMm-.js";import{t as be}from"./ModelLogo-BkbD514M.js";import{a as xe,n as Se,r as Ce,t as we}from"./inlineMessageLinks-DC78iKO5.js";import{t as Te}from"./vendor-motion-vLNN8EMu.js";import{d as Ee,i as De,l as Oe,n as ke,o as Ae,p as je,s as Me}from"./auto-read-context-ClBUErN2.js";import{n as Ne}from"./vendor-marked-S3gCOYp1.js";import{n as Pe}from"./timeFormat-dCsf2MQv.js";var Q=e(i(),1),Fe=p(),$=r();function Ie(e){let t=(0,Fe.c)(11),{kind:n,active:r,className:i}=e,a;t[0]===i?a=t[1]:(a=O(`relative inline-flex shrink-0 items-center justify-center`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`pointer-events-none absolute -inset-1.5 rounded-full bg-[var(--voice-active-fill)]/15 motion-safe:animate-pulse motion-safe:[animation-duration:2.4s]`}),(0,$.jsx)(`span`,{className:`pointer-events-none absolute -inset-1 rounded-full bg-[var(--voice-active-fill)]/25 motion-safe:animate-pulse motion-safe:[animation-delay:300ms] motion-safe:[animation-duration:2.4s]`}),(0,$.jsx)(`span`,{className:`pointer-events-none absolute -inset-0.5 rounded-full bg-[var(--voice-active-fill)]`})]}),t[2]=r,t[3]=o);let s;t[4]!==r||t[5]!==n?(s=n===`mic`?r?(0,$.jsx)(k,{name:`mic-fill`,className:`relative size-full p-0.5 text-[var(--primary-foreground)]`}):(0,$.jsx)(k,{name:`mic`,className:`relative size-full`}):r?(0,$.jsx)(k,{name:`volume-up-fill`,className:`relative size-full p-0.5 text-[var(--primary-foreground)]`}):(0,$.jsx)(k,{name:`volume-up`,weight:`medium`,className:`relative size-full`}),t[4]=r,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,$.jsxs)(`span`,{"aria-hidden":`true`,className:a,children:[o,s]}),t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c}function Le(e){let t=(0,Fe.c)(9),{quotes:n,onRemove:r,removeLabel:i}=e;if(n.length===0)return null;let a;if(t[0]!==r||t[1]!==n||t[2]!==i){let e;t[4]!==r||t[5]!==i?(e=(e,t)=>(0,$.jsxs)(`div`,{"data-composer-quote-chip":!0,className:`flex min-w-0 items-center gap-1 rounded-md bg-[var(--surface-muted)] py-0.5 pl-2 pr-0.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate border-l-2 border-border pl-2 typography-meta text-muted-foreground`,children:e.replace(/\s+/g,` `)}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>r(t),"aria-label":i,children:(0,$.jsx)(k,{name:`close`,className:`size-3`})})]},e),t[4]=r,t[5]=i,t[6]=e):e=t[6],a=n.map(e),t[0]=r,t[1]=n,t[2]=i,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)(`div`,{className:`flex flex-col gap-1 px-3 pt-3`,"data-composer-quote-list":!0,children:a}),t[7]=a,t[8]=o),o}var Re=`text-[var(--primary)]`,ze=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i,Be=/(^|\s)\/(\u2003)?([A-Za-z0-9][A-Za-z0-9_-]*)/g,Ve=c(),He=/\[command:([^\]\r\n]+)\]/g,Ue=/(^|[\s([{])(@session:([A-Za-z0-9_-]+))(?=$|[\s)\]},.!?;:])/g,We=/@([^\s]+)/g,Ge=` `,Ke=e=>e.replaceAll(`\\`,`/`).split(`/`).at(-1)?.replace(/\.md$/,``)??``,qe=e=>e.trim().toLowerCase(),Je=(e,t)=>{let n=t>0?e[t-1]:null;return!n||/(\s|\(|\)|\[|\]|\{|\}|"|'|`|,|\.|;|:)/.test(n)},Ye=e=>!w(e)&&(e.includes(`/`)||e.includes(`\\`)||e.includes(`.`)),Xe=(e,t)=>{e.push(t)},Ze={kind:`skill`,priority:120,shouldScan:e=>e.includes(`/`)||e.includes(`@`)||e.includes(`[skill:`),detect:(e,t)=>{let n=[],r=t.skillNames;Ve.lastIndex=0;let i;for(;(i=Ve.exec(e))!==null;){let e=i[1];Xe(n,{start:i.index,end:i.index+i[0].length,kind:`skill`,raw:i[0],label:`@${e}`,payload:{kind:`skill`,skillName:e}})}if(!r||r.size===0)return n;let a=new Map(Array.from(r,e=>[e.toLowerCase(),e]));for(Be.lastIndex=0;(i=Be.exec(e))!==null;){let t=i[2]??``,r=i[3]||``,o=a.get(r.toLowerCase());if(!o)continue;let s=i.index+i[1].length,c=s+1+t.length+r.length;n.some(e=>e.start<c&&e.end>s)||Xe(n,{start:s,end:c,kind:`skill`,raw:e.slice(s,c),label:`/${o}`,payload:{kind:`skill`,skillName:o}})}let o=t.agentNames,s=/(^|\s)@(\u2003)?([^\s)\]},.!?;:]+)(?=$|[\s)\]},.!?;:])/gu;for(;(i=s.exec(e))!==null;){let t=i[2]??``,r=i[3]||``,s=a.get(r.toLowerCase());if(!s||o?.has(r.toLowerCase()))continue;let c=i.index+i[1].length,l=c+1+t.length+r.length;n.some(e=>e.start<l&&e.end>c)||Xe(n,{start:c,end:l,kind:`skill`,raw:e.slice(c,l),label:`@${s}`,payload:{kind:`skill`,skillName:s}})}return n},decorate:e=>{let t=e.payload.kind===`skill`?e.payload.skillName:e.label.slice(1);return{kind:`skill`,label:e.label,icon:`book-open`,className:Re,href:Ce(t),skillName:t}}},Qe={kind:`command`,priority:115,shouldScan:(e,t)=>e.includes(`[command:`)||!!t.commandNames?.size&&e.includes(`/`),detect:(e,t)=>{let n=[];He.lastIndex=0;let r;for(;(r=He.exec(e))!==null;){let e=r[1],t=Ke(e);t&&Xe(n,{start:r.index,end:r.index+r[0].length,kind:`command`,raw:r[0],label:`/${t}`,payload:{kind:`command`,commandName:t,reference:e}})}let i=t.commandNames;if(!i||i.size===0)return n;let a=new Map(Array.from(i,e=>[e.toLowerCase(),e]));for(Be.lastIndex=0;(r=Be.exec(e))!==null;){let t=r[2]??``,i=r[3]||``,o=a.get(i.toLowerCase());if(!o)continue;let s=r.index+r[1].length,c=s+1+t.length+i.length;n.some(e=>e.start<c&&e.end>s)||Xe(n,{start:s,end:c,kind:`command`,raw:e.slice(s,c),label:`/${o}`,payload:{kind:`command`,commandName:o}})}return n},decorate:e=>({kind:`command`,label:e.label,icon:`command`,className:Re})},$e={kind:`image`,priority:110,shouldScan:e=>e.includes(`[`),detect:(e,t)=>{let n=[],r=0;for(;r<e.length;){let i=e.indexOf(`[`,r);if(i===-1)break;let a=e.indexOf(`]`,i+1);if(a===-1)break;if(e[a+1]===`(`){r=a+1;continue}let o=f(e.slice(i+1,a)).trim(),s=qe(o),c=t.citationIcons?.get(s),l=!c&&ze.test(o),u=c??(l?`image`:null);if(!u){r=a+1;continue}let d=t.citationDisplayNames?.get(s)??(u===`image`&&o.replaceAll(`\\`,`/`).split(`/`).at(-1)||o);Xe(n,{start:i,end:a+1,kind:u,raw:e.slice(i,a+1),label:d,payload:u===`image`?{kind:`image`,filename:d}:{kind:`attachment`,filename:d}}),r=a+1}return n},decorate:e=>{let t=e.payload.kind===`image`||e.payload.kind===`attachment`?e.payload.filename:e.label;return{kind:e.kind===`attachment`?`attachment`:`image`,label:t,icon:e.kind===`attachment`?`attachment-2`:`file-image`,className:Re,filename:t}}},et={kind:`session`,priority:105,shouldScan:e=>e.includes(`@`),detect:(e,t)=>{let n=[];Ue.lastIndex=0;let r;for(;(r=Ue.exec(e))!==null;){let i=r[3],a=r.index+r[1].length,o=a+r[2].length,s=t.sessionTitles?.get(i)??i;Xe(n,{start:a,end:o,kind:`session`,raw:e.slice(a,o),label:s,payload:{kind:`session`,sessionId:i,sessionLabel:s}})}let i=[...t.sessionMentions??[]].filter(e=>e.sessionLabel.length>0).sort((e,t)=>t.sessionLabel.length-e.sessionLabel.length);for(let t of i){let r=[`@${Ge}${t.sessionLabel}`,`@${t.sessionLabel}`];for(let i of r){let r=e.indexOf(i);for(;r!==-1;){let a=r+i.length,o=r===0||/[\s([{]/.test(e[r-1]),s=a===e.length||/[\s)\]},.!?;:]/.test(e[a]),c=n.some(e=>e.start<a&&e.end>r);o&&s&&!c&&Xe(n,{start:r,end:a,kind:`session`,raw:e.slice(r,a),label:t.sessionLabel,payload:{kind:`session`,sessionId:t.sessionId,sessionLabel:t.sessionLabel}}),r=e.indexOf(i,a)}}}return n},decorate:e=>{let t=e.payload.kind===`session`?e.payload.sessionId:void 0;return{kind:`session`,label:e.payload.kind===`session`?e.payload.sessionLabel:e.label,icon:`chat-thread`,className:Re,sessionId:t}}},tt={kind:`file`,priority:100,shouldScan:e=>e.includes(`@`),detect:(e,t)=>{let n=[],r=t.agentNames,i=t.filePaths,a=t.allowPathHeuristics===!0;We.lastIndex=0;let o;for(;(o=We.exec(e))!==null;){let t=o.index;if(!Je(e,t)||o[1].startsWith(`session:`))continue;let s=E(e,t,i)??(a?T(e,t):null);if(s&&(s.value.includes(` `)||s.value.includes(` `))){let r=e.slice(t,s.end);Xe(n,{start:t,end:s.end,kind:`file`,raw:r,label:r,payload:{kind:`file`,path:s.value}}),We.lastIndex=s.end;continue}let c=o[1].trim().replace(/[),.;:!?`"'>]+$/g,``);if(!c)continue;let l=t+1+c.length,u=e.slice(t,l);if(r?.has(c.toLowerCase())){Xe(n,{start:t,end:l,kind:`agent`,raw:u,label:u,payload:{kind:`agent`,agentName:c}});continue}let d=c.replace(/\\/g,`/`).replace(/^\.\//,``);(i?.has(c)||i?.has(d)||i?.has(d.replace(/^\/+/,``))||a&&Ye(c))&&Xe(n,{start:t,end:l,kind:`file`,raw:u,label:u,payload:{kind:`file`,path:c}})}return n},decorate:e=>{if(e.kind===`agent`&&e.payload.kind===`agent`)return{kind:`agent`,label:e.label,icon:null,className:Re,href:we(e.payload.agentName),agentName:e.payload.agentName};let t=e.payload.kind===`file`?e.payload.path:e.label;return{kind:`file`,label:e.label,icon:null,className:Re,path:t}}},nt=[Ze,Qe,$e,et,tt],rt=(e,t=nt)=>{let n=t.find(t=>t.kind===e.kind)??t.find(t=>t.decorate(e).kind===e.kind);return n?n.decorate(e):e.kind===`image`||e.kind===`attachment`?$e.decorate(e):e.kind===`agent`?tt.decorate(e):{kind:e.kind,label:e.label,icon:null,className:Re}},it=[`/`,`[`,`@`],at=e=>{if(!e)return!1;for(let t of it)if(e.includes(t))return!0;return!1},ot=(e,t)=>{if(e.length<=1)return e;let n=[...e].sort((e,n)=>{let r=(t.get(n)??0)-(t.get(e)??0);return r===0?e.start===n.start?n.end-n.start-(e.end-e.start):e.start-n.start:r}),r=[];for(let e of n)r.some(t=>e.start<t.end&&e.end>t.start)||r.push(e);return r.sort((e,t)=>e.start-t.start||e.end-t.end)},st=(e,t={},n=nt)=>{if(!at(e))return[];let r=[],i=new Map;for(let a of n)if(a.shouldScan(e,t))for(let n of a.detect(e,t))r.push(n),i.set(n,a.priority);return ot(r,i)},ct=(e,t,n=nt)=>{if(!e)return[];if(t.length===0)return[{type:`text`,text:e}];let r=[],i=0;for(let a of t)a.start<i||a.end<=a.start||a.end>e.length||(a.start>i&&r.push({type:`text`,text:e.slice(i,a.start)}),r.push({type:`reference`,span:a,decoration:rt(a,n)}),i=a.end);return i<e.length&&r.push({type:`text`,text:e.slice(i)}),r.length>0?r:[{type:`text`,text:e}]},lt=(e,t={},n=nt)=>{if(!at(e))return null;let r=st(e,t,n);return r.length===0?null:ct(e,r,n)},ut=/\.(?:png|jpe?g|gif|webp|svg|avif|bmp|heic|heif|tiff?)$/i,dt=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e)||e.startsWith(`\\\\`),ft=(e,t)=>!!t?.startsWith(`image/`)||ut.test(e),pt=e=>{let t=new Map;if(!e||e.length===0)return t;for(let n of e){if(n.type!==`file`)continue;let e=typeof n.filename==`string`?n.filename.trim():``;if(!e)continue;let r=e.toLowerCase(),i=typeof n.mime==`string`?n.mime:void 0;t.set(r,ft(e,i)?`image`:`attachment`)}return t},mt=e=>{let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`[`,n);if(r===-1)break;let i=e.indexOf(`]`,r+1);if(i===-1)break;if(e[i+1]===`(`){n=i+1;continue}let a=f(e.slice(r+1,i)).trim();dt(a)&&ut.test(a)&&t.push(a),n=i+1}return t},ht=(e,t)=>{let n=pt(e),r=new Map;if(!t||!e?.length)return{icons:n,displayNames:r};let i=[];for(let t of e){if(t.type!==`file`)continue;let e=typeof t.filename==`string`?t.filename.trim():``;e&&ft(e,typeof t.mime==`string`?t.mime:void 0)&&i.push(e)}if(i.length===0)return{icons:n,displayNames:r};let a=mt(t),o=(e,t)=>{let i=e.toLowerCase();r.set(i,t),n.set(i,`image`)};if(i.length===1){for(let e of a)o(e,i[0]);return{icons:n,displayNames:r}}return a.forEach((e,t)=>{let n=i[t];n&&o(e,n)}),{icons:n,displayNames:r}},gt=e=>{switch(e.kind){case`session`:return{trigger:`@`,icon:`chat-thread`,label:e.label};case`skill`:return{trigger:e.label.startsWith(`/`)?`/`:`@`,icon:`book-open`,label:e.label.replace(/^[@/]/,``)};case`command`:return{trigger:`/`,icon:`command`,label:e.label.replace(/^\//,``)};case`image`:return{trigger:`[`,icon:`file-image`,label:e.label,suffix:`]`};case`attachment`:return{trigger:`[`,icon:`attachment-2`,label:e.label,suffix:`]`};case`file`:case`agent`:return}},_t=e=>{let t=(0,Fe.c)(28),{decoration:n,onOpenSkill:r,interactive:i}=e,a=i===void 0||i,o;t[0]===n?o=t[1]:(o=gt(n),t[0]=n,t[1]=o);let s=o,c=s?.icon??n.icon,f=s?.label??n.label,p=s?`${s.trigger}${d}`:d,m=n.kind===`file`?`whitespace-pre-wrap break-words`:`whitespace-nowrap`,h;t[2]!==n.className||t[3]!==m?(h=O(m,n.className),t[2]=n.className,t[3]=m,t[4]=h):h=t[4];let g;t[5]!==c||t[6]!==p?(g=c?(0,$.jsxs)(`span`,{className:`relative inline-block shrink-0 align-baseline`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`text-transparent`,children:p}),(0,$.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 inline-flex items-center justify-center`,style:{left:l,right:l},children:(0,$.jsx)(k,{name:c,className:O(u,`shrink-0`),"aria-hidden":`true`})})]}):null,t[5]=c,t[6]=p,t[7]=g):g=t[7];let _;t[8]!==n.kind||t[9]!==f||t[10]!==h||t[11]!==g?(_=(0,$.jsxs)(`span`,{className:h,"data-message-reference-kind":n.kind,children:[g,f]}),t[8]=n.kind,t[9]=f,t[10]=h,t[11]=g,t[12]=_):_=t[12];let v=_;if(!a)return v;if(n.kind===`skill`&&n.skillName&&r){let e;t[13]!==n.skillName||t[14]!==r?(e=e=>{e.stopPropagation(),r(n.skillName)},t[13]=n.skillName,t[14]=r,t[15]=e):e=t[15];let i;return t[16]!==v||t[17]!==n.skillName||t[18]!==e?(i=(0,$.jsx)(`button`,{type:`button`,className:`inline hover:underline`,"data-skill-name":n.skillName,onClick:e,children:v}),t[16]=v,t[17]=n.skillName,t[18]=e,t[19]=i):i=t[19],i}if(n.kind===`agent`&&n.href){let e;t[20]!==n.agentName||t[21]!==n.label?(e=n.agentName||n.label.replace(/^@/,``),t[20]=n.agentName,t[21]=n.label,t[22]=e):e=t[22];let r;t[23]===e?r=t[24]:(r=Se(e),t[23]=e,t[24]=r);let i;return t[25]!==v||t[26]!==r?(i=(0,$.jsx)(`a`,{href:r,className:`inline hover:underline`,target:`_blank`,rel:`noopener noreferrer`,"data-yuri-agent-mention":`true`,onClick:vt,children:v}),t[25]=v,t[26]=r,t[27]=i):i=t[27],i}return v};_t.displayName=`MessageReferenceChip`;function vt(e){return e.stopPropagation()}var yt=Q.createContext(`default`),bt=()=>Q.useContext(yt),xt=(0,Q.createContext)(null),St=`GitHub issue context (JSON)`,Ct=`GitHub pull request context (JSON)`,wt=`The user referenced these OpenCode sessions (id, title, owning directory).`,Tt=e=>typeof e==`number`&&Number.isFinite(e)&&e>0,Et=(e,t)=>{let n=e.trimStart();if(!n.startsWith(t))return null;let r=n.indexOf(`{`);if(r<0)return null;try{return JSON.parse(n.slice(r))}catch{return null}},Dt=e=>{let t=Et(e,St);if(t){let e=t.issue,n=e?.number,r=e?.title,i=e?.url;return!Tt(n)||typeof r!=`string`||typeof i!=`string`?null:{type:`file`,mime:`application/vnd.github.issue-link`,filename:`Issue #${n}: ${r}`,url:i}}let n=Et(e,Ct);if(n){let e=n.pr,t=e?.number,r=e?.title,i=e?.url;return!Tt(t)||typeof r!=`string`||typeof i!=`string`?null:{type:`file`,mime:`application/vnd.github.pull-request-link`,filename:`PR #${t}: ${r}`,url:i}}return null},Ot=e=>!!e.trim().startsWith(`The following tool was executed by the user`),kt=e=>e.trimStart().startsWith(`Continue working toward the active session goal.`),At=e=>e.trim()===`/compact`,jt=e=>e.flatMap(e=>{if(e.type===`compaction`)return[];if(e.type===`text`){let t=e.text;if(typeof t==`string`){let n=L(t);if(n.trim().length===0||kt(n)||At(n)||n.trimStart().startsWith(wt)||n.includes(`<system-reminder>`)&&a(n).length===0)return[];n!==t&&(e={...e,text:n})}}if(e.synthetic!==!0)return[e];if(e.type!==`text`)return[];let t=e.text;if(typeof t!=`string`)return[];let n=t.trimStart();return Ot(t)||n.startsWith(St)||n.startsWith(Ct)?[e]:[]}).map(e=>{let t=e;if(t.type===`text`){let n=typeof t.text==`string`?t.text.trim():``;if(t.synthetic===!0){let e=Dt(n);if(e)return e}if(n.startsWith(`The following tool was executed by the user`))return{...e,type:`text`,text:`/shell`};if(n.includes(`<system-reminder>`))return{...e,type:`text`,text:a(n)}}return e}),Mt=e=>e.some(e=>{if(e.type===`text`)return!je(e);if(e.type===`file`){let t=e,n=typeof t.mime==`string`?t.mime:``,r=typeof t.url==`string`?t.url:``;return(!!n||!!r)&&!!r&&!o(e)}return!0}),Nt=e=>e?.length?Mt(jt(e)):!1;function Pt(e,t){return JSON.stringify([e,t])}function Ft(e){return new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),`giu`)}var It=new WeakMap;function Lt(e){return e.map(e=>{if(e.type===`image`||e.type===`html`||e.type===`def`)return``;if(e.type===`space`||e.type===`br`||e.type===`hr`)return`
2
- `;if(e.type===`code`||e.type===`codespan`)return e.text;if(e.type===`list`)return e.items.map(e=>Lt(e.tokens)).join(`
3
- `);if(e.type===`table`)return[e.header,...e.rows].map(e=>e.map(e=>Lt(e.tokens)).join(` `)).join(`
4
- `);let t=`tokens`in e?e.tokens:void 0;if(t)return Lt(t)+([`paragraph`,`heading`,`blockquote`].includes(e.type)?`
5
- `:``);let n=`text`in e&&typeof e.text==`string`?e.text:``;if(!n.includes(`&`)||typeof document>`u`)return n;let r=document.createElement(`textarea`);return r.innerHTML=n.replace(/</g,`&lt;`),r.value}).join(``)}function Rt(e){let t=It.get(e);if(t!==void 0)return t;let n=Lt(Ne.lex(e.text));return It.set(e,n),n}function zt(e){let t=Ft(e),n=new WeakMap;return r=>{if(!e.trim())return[];let i=[],a=new Set,o=new Map(r.map(e=>[e.info.id,e]));for(let s of r){let r=o.get(s.info.id);if(a.has(r.info.id))continue;a.add(r.info.id);let c=n.get(r.parts);if(!c){c=[];let i=Ee(r.info.role===`user`?jt(r.parts):r.parts);for(let n of i){if(n.type!==`text`||n.ignored)continue;let i=0;for(let a of Rt(n).matchAll(t))c.push({messageId:r.info.id,partId:n.id,occurrence:i++,query:e})}n.set(r.parts,c)}for(let e of c)i.push(e)}return i}}function Bt(e,t){if(!t.trim())return[];let n=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=[],i=``,a;for(;a=n.nextNode();){let e=a;if(e.parentElement?.closest(`button, [aria-hidden="true"], [hidden], [data-md-code-line-numbers]`))continue;let t=i.length;i+=e.data,r.push({node:e,start:t,end:i.length})}let o=[],s=0;for(let n of i.matchAll(Ft(t))){let t=n.index,i=t+n[0].length;for(;s<r.length&&r[s].end<=t;)s++;let a=r[s],c=s;for(;c<r.length&&r[c].end<i;)c++;let l=r[c];if(!a||!l)continue;let u=e.ownerDocument.createRange();u.setStart(a.node,t-a.start),u.setEnd(l.node,i-l.start),o.push(u)}return o}var Vt=6e5,Ht=new Map,Ut=e=>{let t=g(e);if(!t)return;let n=Ht.get(t);if(n){if(n.expiresAt<=Date.now()){Ht.delete(t);return}return n.outsideFileGrant}},Wt=(e,t,n)=>{let r=g(e);!r||!t||Ht.set(r,{outsideFileGrant:t,expiresAt:typeof n==`number`&&Number.isFinite(n)?n:Date.now()+Vt})},Gt=async(e,t)=>{let r=g(e);if(!r||!t||_(r,t))return;let i=Ut(r);if(i)return i;let a=await n(r);if(!(!a.success||!a.path||!a.outsideFileGrant))return Wt(a.path,a.outsideFileGrant),g(a.path)!==r&&Wt(r,a.outsideFileGrant),a.outsideFileGrant},Kt=/(^|\s)\/([a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?)/g,qt=/(```[\s\S]*?```|~~~[\s\S]*?~~~)/g,Jt=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#x27;`),Yt=(e,t)=>e.split(qt).map((e,n)=>n%2==1?e:t(e)).join(``),Xt=e=>Yt(e,e=>e.replace(/ *\n/g,`
6
- `)),Zt=({textContent:e,agentMention:t,skillNames:n,decorateInlineReferences:r=!0})=>{let i=Yt(e,Jt);if(r){if(t?.token&&i.includes(t.token)){let e=`[${t.token}](${we(t.name)})`;i=i.replace(t.token,e)}i=i.replace(Kt,(e,t,r)=>n.has(r)?`${t}[/${r}](${Ce(r)})`:e)}return Xt(i)},Qt=e=>(Kt.lastIndex=0,Kt.test(e)||e.includes(`[skill:`)),$t=e=>{if(typeof window>`u`)return!1;let t=window.getSelection();if(!t||t.isCollapsed||t.rangeCount===0)return!1;let n=t.getRangeAt(0);return e.contains(n.startContainer)||e.contains(n.endContainer)},en=Q.memo(e=>{let t=(0,Fe.c)(96),{part:n,messageId:r,agentMention:i,messageParts:a,variant:o}=e,c=(o===void 0?`message`:o)===`preview`,l=Q.useContext(xt),u=!c&&l?.messageId===r&&l.partId===n.id,f=n,p=f.text,h=typeof p==`string`?p:f.content||f.value||``,y;t[0]===h?y=t[1]:(y=le(h),t[0]=h,t[1]=y);let b=y,C=b?b.body:h,[w,T]=Q.useState(!1),[E,D]=Q.useState(!1),M;t[2]===c?M=t[3]:(M=e=>!c&&e.collapsibleUserMessages,t[2]=c,t[3]=M);let N=S(M),P=oe(),ee=m(),I=ee?.entry.location.hostId?ee.entry:void 0,L;t[4]===C?L=t[5]:(L=Qt(C),t[4]=C,t[5]=L);let R;t[6]!==P||t[7]!==L?(R={directory:P,enabled:L},t[6]=P,t[7]=L,t[8]=R):R=t[8];let te=F(R),B;t[9]===te.data?B=t[10]:(B=te.data??[],t[9]=te.data,t[10]=B);let V=B,H=S(tn),{t:U}=z(),W=N&&!w&&!u,G=Q.useRef(null),K;t[11]===V?K=t[12]:(K=new Map(V.map(nn)),t[11]=V,t[12]=K);let q=K,ne;t[13]!==a||t[14]!==C?(ne=ht(a,C),t[13]=a,t[14]=C,t[15]=ne):ne=t[15];let re=ne,ie;if(t[16]!==I||t[17]!==a||t[18]!==C){let e=new Map;for(let t of a??[]){if(t.type!==`text`||!j(t))continue;let n=t.text;if(typeof n==`string`)for(let t of A(n))e.set(t.id,{sessionId:t.id,sessionLabel:t.title||t.id})}if(!I&&C.includes(`@`))for(let[t,n]of s()){let r=typeof n.title==`string`?n.title.trim():``;!r||e.has(t)||(C.includes(`@${r}`)||C.includes(`@${d}${r}`))&&e.set(t,{sessionId:t,sessionLabel:r})}ie=Array.from(e.values()),t[16]=I,t[17]=a,t[18]=C,t[19]=ie}else ie=t[19];let ae=ie,J;t[20]!==P||t[21]!==I||t[22]!==H||t[23]!==q?(J=e=>{let t=q.get(e),n=typeof t?.path==`string`?t.path:``,r=g(n);if(!r||r===`<built-in>`)return;let i=r.toLowerCase().endsWith(`/skill.md`)?r:`${r}/SKILL.md`,a=P||v(``,i)||`/`,o=()=>{H(I?.key??a,i)};if(!I&&P&&!_(i,P)){Gt(i,P).then(o);return}o()},t[20]=P,t[21]=I,t[22]=H,t[23]=q,t[24]=J):J=t[24];let ce=x(J),ue;t[25]!==N||t[26]!==w?(ue=()=>{let e=G.current;if(!e||!N)return;let t=()=>{N&&!w&&e.scrollHeight>e.clientHeight&&D(!0)};D(!1),t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[25]=N,t[26]=w,t[27]=ue):ue=t[27];let de;t[28]!==N||t[29]!==w||t[30]!==C?(de=[N,C,w],t[28]=N,t[29]=w,t[30]=C,t[31]=de):de=t[31],Q.useEffect(ue,de);let fe,Y;t[32]===N?(fe=t[33],Y=t[34]):(fe=()=>{N||(T(!1),D(!1))},Y=[N],t[32]=N,t[33]=fe,t[34]=Y),Q.useEffect(fe,Y);let X;t[35]!==N||t[36]!==w||t[37]!==c||t[38]!==E||t[39]!==ce?(X=e=>{if(c)return;let t=e.target,n=(t?.closest(`[data-skill-name]`))?.dataset.skillName??xe(t?.closest(`a[href]`)?.getAttribute(`href`));if(n){e.preventDefault(),e.stopPropagation(),ce(n);return}let r=G.current;r&&($t(r)||N&&!w&&E&&T(!0))},t[35]=N,t[36]=w,t[37]=c,t[38]=E,t[39]=ce,t[40]=X):X=t[40];let pe=x(X),me;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(me=e=>{e.stopPropagation(),T(!1)},t[41]=me):me=t[41];let Z=x(me),he;t[42]!==i||t[43]!==re.displayNames||t[44]!==re.icons||t[45]!==ae||t[46]!==q||t[47]!==C?(he=lt(C,{skillNames:new Set(q.keys()),citationIcons:re.icons,citationDisplayNames:re.displayNames,sessionMentions:ae,agentNames:i?.name?new Set([i.name.toLowerCase(),i.token.replace(/^@/,``).toLowerCase()]):void 0,allowPathHeuristics:!0}),t[42]=i,t[43]=re.displayNames,t[44]=re.icons,t[45]=ae,t[46]=q,t[47]=C,t[48]=he):he=t[48];let ge=he,_e;t[49]!==i||t[50]!==ge||t[51]!==q||t[52]!==C?(_e=Zt({textContent:C,agentMention:i,skillNames:new Set(q.keys()),decorateInlineReferences:!ge}),t[49]=i,t[50]=ge,t[51]=q,t[52]=C,t[53]=_e):_e=t[53];let ve=_e,ye;t[54]===W?ye=t[55]:(ye=(e,t)=>{if(!e)return null;let n=Zt({textContent:e,skillNames:new Set,decorateInlineReferences:!1});return(0,$.jsx)(se,{content:n,className:O(`inline w-auto align-baseline [&_.markdown-content]:contents [&_.markdown-content_p]:inline [&_[data-markdown-size-spacer]]:inline`,`[&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0`,W&&[`[&_.markdown-content>*]:my-0`,`[&_[data-component='markdown-code']]:my-0`,`[&_[data-component='markdown-code']]:inline`,`[&_[data-component='markdown-code']]:border-0`,`[&_[data-component='markdown-code']]:bg-transparent`,`[&_[data-component='markdown-code']>*:first-child]:hidden`,`[&_[data-component='markdown-code']>div]:inline`,`[&_[data-component='markdown-code']>div]:p-0`,`[&_[data-component='markdown-code']_pre]:inline`,`[&_[data-component='markdown-code']_code]:inline`,`[&_[data-md-code-line-numbers]]:hidden`]),disableLinkSafety:!0,enableFileReferences:!1},t)},t[54]=W,t[55]=ye);let be=ye,Se;t[56]!==c||t[57]!==ce||t[58]!==be?(Se=e=>e.map((e,t)=>e.type===`text`?be(e.text,`text-${t}`):(0,$.jsx)(_t,{decoration:e.decoration,onOpenSkill:ce,interactive:!c},`ref-${t}-${e.span.start}`)),t[56]=c,t[57]=ce,t[58]=be,t[59]=Se):Se=t[59];let Ce=Se;if((!C||C.trim().length===0)&&!b?.quotes.length)return null;let we=W&&E,Te=n.id||`${r}-user-text`,Ee;t[60]!==c||t[61]!==r||t[62]!==n.id?(Ee=c?void 0:Pt(r,n.id),t[60]=c,t[61]=r,t[62]=n.id,t[63]=Ee):Ee=t[63];let De=we?`true`:void 0,Oe;t[64]!==N||t[65]!==Z||t[66]!==w||t[67]!==U?(Oe=N&&w&&(0,$.jsx)(`button`,{type:`button`,onClick:Z,className:`absolute top-0 right-0 z-10 flex items-center justify-center rounded-sm bg-[var(--surface-elevated)] p-0.5 text-[var(--surface-mutedForeground)] hover:text-[var(--surface-foreground)] hover:bg-[var(--interactive-hover)] transition-colors`,"aria-label":U(`chat.message.userText.collapseAria`),children:(0,$.jsx)(k,{name:`arrow-up-s`,className:`h-3.5 w-3.5`})}),t[64]=N,t[65]=Z,t[66]=w,t[67]=U,t[68]=Oe):Oe=t[68];let ke;t[69]!==r||t[70]!==n.id||t[71]!==b||t[72]!==U?(ke=b&&b.quotes.length>0?(0,$.jsx)(`div`,{className:`mb-2 flex flex-col gap-1`,"data-conversation-quotes":!0,"aria-label":U(`chat.message.conversationQuotesLabel`),children:b.quotes.map((e,t)=>(0,$.jsx)(`p`,{"data-conversation-quote":!0,className:`m-0 whitespace-pre-wrap break-words border-l-2 border-border pl-3 typography-meta text-muted-foreground`,children:e},`${n.id||r}-quote-${t}`))}):null,t[69]=r,t[70]=n.id,t[71]=b,t[72]=U,t[73]=ke):ke=t[73];let Ae;t[74]!==N||t[75]!==pe||t[76]!==W||t[77]!==w||t[78]!==c||t[79]!==E||t[80]!==ve||t[81]!==ge||t[82]!==Ce||t[83]!==C?(Ae=C.trim().length>0?(0,$.jsx)(`div`,{className:O(`break-words font-sans`,c?`typography-meta`:`typography-markdown-body`,w&&`pb-3`,W&&`line-clamp-10`,N&&E&&!w&&`cursor-pointer`),"data-user-message-collapse":W?`true`:void 0,ref:G,onClick:pe,children:ge?Ce(ge):(0,$.jsx)(se,{content:ve,className:O(`[&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0`,W&&[`[&_.markdown-content>*]:my-0`,`[&_[data-component='markdown-code']]:my-0`,`[&_[data-component='markdown-code']]:inline`,`[&_[data-component='markdown-code']]:border-0`,`[&_[data-component='markdown-code']]:bg-transparent`,`[&_[data-component='markdown-code']>*:first-child]:hidden`,`[&_[data-component='markdown-code']>div]:inline`,`[&_[data-component='markdown-code']>div]:p-0`,`[&_[data-component='markdown-code']_pre]:inline`,`[&_[data-component='markdown-code']_code]:inline`,`[&_[data-md-code-line-numbers]]:hidden`]),disableLinkSafety:!0,enableFileReferences:!1})}):null,t[74]=N,t[75]=pe,t[76]=W,t[77]=w,t[78]=c,t[79]=E,t[80]=ve,t[81]=ge,t[82]=Ce,t[83]=C,t[84]=Ae):Ae=t[84];let je;t[85]!==we||t[86]!==U?(je=we&&(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,className:`yuri-user-text-expand flex cursor-pointer items-center justify-start gap-1 text-left font-sans typography-markdown-body text-muted-foreground`,"aria-expanded":!1,onClick:()=>T(!0),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(!0))},children:[U(`chat.message.userText.showMore`),(0,$.jsx)(k,{name:`arrow-down-s`,className:`size-[1em] shrink-0`})]}),t[85]=we,t[86]=U,t[87]=je):je=t[87];let Me;return t[88]!==Te||t[89]!==Ee||t[90]!==De||t[91]!==Oe||t[92]!==ke||t[93]!==Ae||t[94]!==je?(Me=(0,$.jsxs)(`div`,{className:`relative`,"data-transcript-search-part":Ee,"data-user-message-clamp":De,children:[Oe,ke,Ae,je]},Te),t[88]=Te,t[89]=Ee,t[90]=De,t[91]=Oe,t[92]=ke,t[93]=Ae,t[94]=je,t[95]=Me):Me=t[95],Me});function tn(e){return e.openContextFile}function nn(e){return[e.name,e]}function rn(e){let t=(0,Fe.c)(8),{isShellResult:n,children:r}=e,i=n!==void 0&&n,a;t[0]===i?a=t[1]:(a=i?void 0:{backgroundColor:`var(--chat-user-message-bg)`,borderRadius:`var(--radius-xl)`,borderBottomRightRadius:`var(--radius-sm)`},t[0]=i,t[1]=a);let o=i?`min-w-0 text-left`:`px-3 py-1.5 shadow-none`,s=i?void 0:`true`,c=i?`true`:void 0,l;return t[2]!==r||t[3]!==a||t[4]!==o||t[5]!==s||t[6]!==c?(l=(0,$.jsx)(`div`,{style:a,className:o,"data-user-message-bubble":s,"data-shell-result":c,children:r}),t[2]=r,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l):l=t[7],l}var an=144,on=null,sn=new Set,cn=!1,ln=null;function un(){for(let e of sn)e()}function dn(){return on}function fn(){return ln}function pn(e){return sn.add(e),()=>{sn.delete(e)}}function mn(e,t){let n=Q.useSyncExternalStore(pn,dn,fn);return t&&n===e}function hn(e){!e||on===e||(on=e,un())}function gn(e){on!==null&&(e&&on!==e||(on=null,un()))}function _n(e){return e instanceof Element?e.closest(`[data-message-id]`)?.getAttribute(`data-message-id`)??null:null}function vn(){cn||typeof document>`u`||(cn=!0,document.addEventListener(`pointerdown`,e=>{on&&_n(e.target)!==on&&gn()},!0))}function yn(e,t){vn();let n=0,r=0,i=!1,a=e=>{e.button===0&&(i=!0,n=e.clientX,r=e.clientY)},o=e=>{if(!i)return;i=!1;let a=e.clientX-n,o=e.clientY-r;a*a+o*o>an||hn(t)},s=()=>{i=!1};return e.addEventListener(`pointerdown`,a),e.addEventListener(`pointerup`,o),e.addEventListener(`pointercancel`,s),()=>{e.removeEventListener(`pointerdown`,a),e.removeEventListener(`pointerup`,o),e.removeEventListener(`pointercancel`,s),gn(t)}}var bn=`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,xn=`size-3.5!`,Sn=`medium`,Cn=`flex items-center gap-2`,wn={containerType:`inline-size`,containerName:`message-footer`},Tn=`${Cn} -ml-[5px]`,En=`mt-2.5 mb-3 flex flex-wrap items-center gap-3`,Dn=`mt-1.5 mb-2 flex flex-wrap items-center gap-3`,On=`flex w-max max-w-full flex-none flex-wrap items-center gap-2 text-muted-foreground`,kn=`h-3.5 items-center gap-1 text-[11px] leading-none tabular-nums text-muted-foreground`,An=`inline-flex ${kn}`,jn=`size-3.5!`,Mn=e=>{let t=(0,Fe.c)(6),{messageId:n,label:r,focusReveal:i}=e,a=mn(n,i),o=i?a?`inline-flex`:`hidden`:`hidden yuri-message-hover-time`,s;t[0]===o?s=t[1]:(s=O(kn,`whitespace-nowrap`,o),t[0]=o,t[1]=s);let c=i?a?`true`:`false`:void 0,l;return t[2]!==r||t[3]!==s||t[4]!==c?(l=(0,$.jsx)(`span`,{className:s,"data-message-time":``,"data-message-time-visible":c,children:r}),t[2]=r,t[3]=s,t[4]=c,t[5]=l):l=t[5],l},Nn=e=>{let t=(0,Fe.c)(16),{label:n}=e,{t:r}=z(),i;t[0]!==n||t[1]!==r?(i=r(`chat.messageBody.meta.tpsAria`,{rate:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(k,{weight:Sn,name:`pulse`,className:jn}),t[3]=a):a=t[3];let o;t[4]===n?o=t[5]:(o=(0,$.jsx)(`span`,{className:`message-footer__label`,children:n}),t[4]=n,t[5]=o);let s;t[6]!==i||t[7]!==o?(s=(0,$.jsx)(W,{asChild:!0,children:(0,$.jsxs)(`span`,{className:An,"aria-label":i,children:[a,o]})}),t[6]=i,t[7]=o,t[8]=s):s=t[8];let c;t[9]===r?c=t[10]:(c=r(`chat.messageBody.meta.tpsTooltip`),t[9]=r,t[10]=c);let l;t[11]===c?l=t[12]:(l=(0,$.jsx)(G,{children:c}),t[11]=c,t[12]=l);let u;return t[13]!==s||t[14]!==l?(u=(0,$.jsxs)(K,{children:[s,l]}),t[13]=s,t[14]=l,t[15]=u):u=t[15],u},Pn=Q.memo(function(e){let t=(0,Fe.c)(22),{messageId:n,isMobile:r,actions:i,tps:a,duration:o,timestamp:s,activity:c,trailing:l,animateReveal:u}=e,d=u!==void 0&&u,f=U(),p=r?Dn:En,m;t[0]!==d||t[1]!==f?(m=d&&!f?{opacity:0}:!1,t[0]=d,t[1]=f,t[2]=m):m=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h={opacity:1},t[3]=h):h=t[3];let g=f?0:.35,_;t[4]===g?_=t[5]:(_={duration:g,ease:`easeOut`},t[4]=g,t[5]=_);let v;t[6]===i?v=t[7]:(v=i?(0,$.jsx)(`div`,{className:Tn,"data-message-action-group":`true`,children:i}):null,t[6]=i,t[7]=v);let y;t[8]!==c||t[9]!==o||t[10]!==r||t[11]!==n||t[12]!==s||t[13]!==a?(y=a||o||s||c?(0,$.jsxs)(`div`,{className:On,children:[a||o?(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 whitespace-nowrap`,children:[a?(0,$.jsx)(Nn,{label:a}):null,o?(0,$.jsxs)(K,{children:[(0,$.jsx)(W,{asChild:!0,children:(0,$.jsxs)(`span`,{className:An,children:[(0,$.jsx)(k,{weight:Sn,name:`hourglass`,className:jn}),(0,$.jsx)(`span`,{className:`message-footer__label`,children:o})]})}),(0,$.jsx)(G,{children:o})]}):null]}):null,c,s?(0,$.jsx)(Mn,{messageId:n,label:s,focusReveal:r}):null]}):null,t[8]=c,t[9]=o,t[10]=r,t[11]=n,t[12]=s,t[13]=a,t[14]=y):y=t[14];let b;return t[15]!==p||t[16]!==m||t[17]!==_||t[18]!==v||t[19]!==y||t[20]!==l?(b=(0,$.jsxs)(Te.div,{className:p,initial:m,animate:h,transition:_,"data-message-footer":`true`,style:wn,children:[v,y,l]}),t[15]=p,t[16]=m,t[17]=_,t[18]=v,t[19]=y,t[20]=l,t[21]=b):b=t[21],b}),Fn=Q.memo(e=>{let t=(0,Fe.c)(73),{messageId:n,hasCopyableText:r,isTouchContext:i,onCopyMessage:a,ttsText:o,sessionId:s,allowSourceSession:c}=e,l=c===void 0||c,{t:u}=z(),d=bt(),f=ue(),p;t[0]===f?p=t[1]:(p=ce(f),t[0]=f,t[1]=p);let m=p,{isPlaying:h,play:g,stop:_,canResume:v}=De(),y=Q.useContext(ke),b=!!(y&&y.sessionId===s&&y.messageId===n),S=h||b,w=M(In),T=M(Ln),[E,A]=Q.useState(!1),[j,N]=Q.useState(!1),[P,F]=Q.useState(!1),ee=Q.useRef(null),I=Q.useRef(null),L=Q.useRef(null),R=!!a,te=f.sessionId||s,B=!!(l&&te&&f.directory&&m.openSourceSession&&d!==`mini-chat`),V;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{I.current!==null&&typeof window<`u`&&(window.clearTimeout(I.current),I.current=null)},t[2]=V):V=t[2];let H=x(V),U;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{L.current!==null&&typeof window<`u`&&(window.clearTimeout(L.current),L.current=null)},t[3]=U):U=t[3];let q=x(U),oe,se;t[4]!==q||t[5]!==H?(oe=()=>()=>{H(),q()},se=[q,H],t[4]=q,t[5]=H,t[6]=oe,t[7]=se):(oe=t[6],se=t[7]),Q.useEffect(oe,se);let J,le;t[8]!==R||t[9]!==q||t[10]!==H||t[11]!==r?(J=()=>{(!r||!R)&&(A(!1),N(!1),H(),q())},le=[R,q,H,r],t[8]=R,t[9]=q,t[10]=H,t[11]=r,t[12]=J,t[13]=le):(J=t[12],le=t[13]),Q.useEffect(J,le);let de;t[14]!==R||t[15]!==H||t[16]!==r||t[17]!==i?(de=()=>{!i||!R||!r||typeof window>`u`||(H(),A(!0),I.current=window.setTimeout(()=>{A(!1),I.current=null},1800))},t[14]=R,t[15]=H,t[16]=r,t[17]=i,t[18]=de):de=t[18];let fe=x(de),Y;t[19]!==q||t[20]!==r||t[21]!==i||t[22]!==a||t[23]!==fe?(Y=async e=>{!a||!r||(e.stopPropagation(),e.preventDefault(),await a()!==!1&&(q(),N(!0),typeof window<`u`&&(L.current=window.setTimeout(()=>{N(!1),L.current=null},2e3)),i&&fe()))},t[19]=q,t[20]=r,t[21]=i,t[22]=a,t[23]=fe,t[24]=Y):Y=t[24];let X=x(Y),pe;t[25]!==l||t[26]!==s||t[27]!==f?(pe=e=>{e.stopPropagation(),e.preventDefault();let t=f.sessionId||s;!l||!t||!f.directory||!f.openSourceSession||f.openSourceSession(t,f.directory)},t[25]=l,t[26]=s,t[27]=f,t[28]=pe):pe=t[28];let me=x(pe),Z;bb0:{if(S){let e;t[29]===u?e=t[30]:(e=u(`chat.messageBody.tts.stopSpeaking`),t[29]=u,t[30]=e),Z=e;break bb0}let e=T===`browser`?`Browser`:T===`openai`?`OpenAI`:T===`openai-compatible`?`Custom`:`Say`,n;t[31]!==e||t[32]!==u?(n=u(`chat.messageBody.tts.readAloudWithProvider`,{provider:e}),t[31]=e,t[32]=u,t[33]=n):n=t[33],Z=n}let he=Z,ge;t[34]!==g||t[35]!==u||t[36]!==o?(ge=e=>{let t=e!==void 0&&e;if(F(!1),!o.trim())return;let n=ee.current?.closest(`[data-message-text-export-root]`)??void 0;g(o,e=>{e&&C.error(u(`chat.messageBody.tts.failed`))},{target:n,restart:t})},t[34]=g,t[35]=u,t[36]=o,t[37]=ge):ge=t[37];let _e=x(ge),ve;t[38]!==y||t[39]!==v||t[40]!==b||t[41]!==S||t[42]!==_e||t[43]!==_||t[44]!==o?(ve=(e,t)=>{if(!e){F(!1);return}if(S){t.cancel(),b&&y?.stop(),_();return}let n=ee.current?.closest(`[data-message-text-export-root]`)??void 0;if(v(o,n)){F(!0);return}t.cancel(),_e()},t[38]=y,t[39]=v,t[40]=b,t[41]=S,t[42]=_e,t[43]=_,t[44]=o,t[45]=ve):ve=t[45];let ye=x(ve),be;t[46]!==E||t[47]!==X||t[48]!==r||t[49]!==j||t[50]!==a||t[51]!==u?(be=a&&(0,$.jsxs)(K,{children:[(0,$.jsx)(W,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,"data-visible":E||j?`true`:void 0,className:O(`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,!r&&`opacity-50`),disabled:!r,"aria-label":u(`chat.messageBody.actions.copyMessageAria`),"aria-hidden":!r,onPointerDown:Rn,onClick:e=>{X(e)},onFocus:()=>{r&&A(!0)},onBlur:()=>{j||A(!1)},children:j?(0,$.jsx)(k,{weight:`medium`,name:`check`,className:O(`size-3.5!`,`text-[color:var(--status-success)]`)}):(0,$.jsx)(k,{weight:`medium`,name:`file-copy`,className:`size-3.5!`})})}),(0,$.jsx)(G,{sideOffset:6,children:u(`chat.messageBody.actions.copyAnswer`)})]}),t[46]=E,t[47]=X,t[48]=r,t[49]=j,t[50]=a,t[51]=u,t[52]=be):be=t[52];let xe;t[53]!==B||t[54]!==me||t[55]!==u?(xe=B?(0,$.jsxs)(K,{children:[(0,$.jsx)(W,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,className:bn,"aria-label":u(`chat.messageBody.actions.openSourceSessionAria`),onPointerDown:zn,onClick:me,children:(0,$.jsx)(k,{weight:Sn,name:`target`,className:xn})})}),(0,$.jsx)(G,{sideOffset:6,children:u(`chat.messageBody.actions.openSourceSession`)})]}):null,t[53]=B,t[54]=me,t[55]=u,t[56]=xe):xe=t[56];let Se;t[57]!==d||t[58]!==ye||t[59]!==r||t[60]!==S||t[61]!==i||t[62]!==he||t[63]!==w||t[64]!==_e||t[65]!==u||t[66]!==P||t[67]!==o?(Se=d!==`mini-chat`&&w&&r&&o.trim()&&(0,$.jsxs)(ae,{open:P&&!S,onOpenChange:ye,modal:!1,children:[(0,$.jsxs)(K,{children:[(0,$.jsx)(W,{asChild:!0,children:(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(D,{ref:ee,type:`button`,variant:`ghost`,size:`icon`,className:O(`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,`!bg-transparent shadow-none`,S?`text-[var(--primary-base)]`:`hover:text-foreground/80`),"aria-label":u(S?`chat.messageBody.tts.stopSpeaking`:`chat.messageBody.tts.readAloud`),"aria-pressed":S,onPointerDown:Bn,onClick:Vn,children:(0,$.jsx)(Ie,{kind:`speaker`,active:S,className:`size-3.5!`})})})}),(0,$.jsx)(G,{sideOffset:6,children:he})]}),(0,$.jsxs)(re,{side:`top`,align:`start`,sideOffset:6,onClick:Hn,children:[(0,$.jsxs)(ie,{className:i?`min-h-11 px-3`:void 0,onSelect:()=>_e(!1),children:[(0,$.jsx)(k,{name:`play`,weight:`medium`,className:`size-4`}),u(`chat.messageBody.tts.resume`)]}),(0,$.jsxs)(ie,{className:i?`min-h-11 px-3`:void 0,onSelect:()=>_e(!0),children:[(0,$.jsx)(k,{name:`restart`,weight:`medium`,className:`size-4`}),u(`chat.messageBody.tts.restart`)]})]})]}),t[57]=d,t[58]=ye,t[59]=r,t[60]=S,t[61]=i,t[62]=he,t[63]=w,t[64]=_e,t[65]=u,t[66]=P,t[67]=o,t[68]=Se):Se=t[68];let Ce;return t[69]!==be||t[70]!==xe||t[71]!==Se?(Ce=(0,$.jsxs)($.Fragment,{children:[be,xe,Se]}),t[69]=be,t[70]=xe,t[71]=Se,t[72]=Ce):Ce=t[72],Ce});function In(e){return e.showMessageTTSButtons}function Ln(e){return e.voiceProvider}function Rn(e){return e.stopPropagation()}function zn(e){return e.stopPropagation()}function Bn(e){return e.stopPropagation()}function Vn(e){return e.stopPropagation()}function Hn(e){return e.stopPropagation()}var Un=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),Wn=(e,t)=>{let n=new Date(t);return n.setDate(t.getDate()-1),Un(e,n)},Gn=e=>Number.isFinite(e)&&!Number.isNaN(new Date(e).getTime()),Kn=e=>String(e).padStart(2,`0`),qn=e=>{let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.round(t),r=Math.floor(n/86400),i=Math.floor(n%86400/3600),a=Math.floor(n%3600/60),o=n%60;return[r>0?`${r}d`:``,i>0?`${i}h`:``,a>0?`${a}m`:``,o>0?`${o}s`:``].filter(Boolean).join(` `)},Jn=e=>{if(!Gn(e))return``;let t=new Date(e);return`${t.getFullYear()}-${Kn(t.getMonth()+1)}-${Kn(t.getDate())} ${Kn(t.getHours())}:${Kn(t.getMinutes())}`},Yn=(e,t)=>{if(!Gn(e))return``;let n=new Date(e),r=new Date,i=Pe(n,t),a=te(),o=B.getState().dictionary;if(Un(n,r))return i;if(Wn(n,r))return V(o,`common.date.yesterdayWithTime`,{time:i});let s=`${n.toLocaleString(a,{month:`short`})} ${n.getDate()}`;return n.getFullYear()===r.getFullYear()?`${s}, ${i}`:`${s}, ${n.getFullYear()}, ${i}`},Xn={onPointerEnter:e=>{e.pointerType!==`touch`&&e.currentTarget.setAttribute(`data-message-hovered`,``)},onPointerLeave:e=>{e.currentTarget.removeAttribute(`data-message-hovered`)},onPointerCancel:e=>{e.currentTarget.removeAttribute(`data-message-hovered`)}},Zn=class e{static instance;sessionStartTimes=new Map;seenMessageIds=new Set;messageCreationTimes=new Map;constructor(){}static getInstance(){return e.instance||=new e,e.instance}recordSessionStart(e){this.sessionStartTimes.set(e,Date.now())}getSessionStartTime(e){return this.sessionStartTimes.get(e)}shouldAnimateMessage(e,t){if(e.role!==`assistant`||this.seenMessageIds.has(e.id))return!1;let n=this.sessionStartTimes.get(t);if(!n)return this.seenMessageIds.add(e.id),this.messageCreationTimes.set(e.id,e.time.created),!1;let r=e.time.created>n-5e3;return r||(this.seenMessageIds.add(e.id),this.messageCreationTimes.set(e.id,e.time.created)),r}clearSession(e){this.sessionStartTimes.delete(e)}hasSessionTiming(e){return this.sessionStartTimes.has(e)}hasBeenAnimated(e){return this.seenMessageIds.has(e)}markMessageAsAnimated(e,t){this.seenMessageIds.add(e),this.messageCreationTimes.set(e,t)}clearAll(){this.sessionStartTimes.clear(),this.seenMessageIds.clear(),this.messageCreationTimes.clear()}getDebugInfo(){return{sessionStartTimes:new Map(this.sessionStartTimes),seenMessageIds:new Set(this.seenMessageIds),messageCreationTimes:new Map(this.messageCreationTimes)}}},Qn=100,$n=(e,t)=>{if(e.length===0)return;let n=0,r=e.length-1,i=0;for(;n<=r;){let a=n+r>>1,o=e[a]?.top;if(o===void 0)break;if(o<=t){i=a,n=a+1;continue}r=a-1}return e[i]?.id},er=e=>{let t=e.raf??requestAnimationFrame,n=e.caf??cancelAnimationFrame,r=e.ResizeObserver??globalThis.ResizeObserver,i=e.MutationObserver??globalThis.MutationObserver,a,o,s,c,l,u=!0,d=new Map,f=[],p=()=>{c===void 0&&(c=t(()=>{c=void 0,h()}))},m=()=>{let e=a;if(!e){f=[],u=!1;return}let t=e.getBoundingClientRect().top;f=[...d].map(([n,r])=>({id:n,top:r.getBoundingClientRect().top-t+e.scrollTop})),f.sort((e,t)=>e.top-t.top),u=!1},h=()=>{let t=a;if(!t)return;u&&m();let n=$n(f,t.scrollTop+Qn);!n||n===l||(l=n,e.onActive(n))},g=()=>{let e=a;if(e){if(o?.disconnect(),o=void 0,r){o=new r(()=>{m(),p()}),o.observe(e);for(let e of d.values())o.observe(e)}if(s?.disconnect(),s=void 0,i&&!r){s=new i(()=>{u=!0,p()});let t={subtree:!0,childList:!0};r||(t.characterData=!0,t.characterDataOldValue=!1),s.observe(e,t)}u=!0,p()}},_=e=>{a!==e&&(a=e,l=void 0,g())},v=(e,t)=>{let n=d.get(t);n&&n!==e&&o?.unobserve(n),d.set(t,e),o&&o.observe(e),u=!0,p()},y=e=>{let t=d.get(e);t&&(o?.unobserve(t),d.delete(e),u=!0,p())},b=()=>{u=!0,p()},x=()=>{for(let e of d.values())o?.unobserve(e);d.clear(),f=[],l=void 0,u=!0};return{setContainer:_,register:v,unregister:y,onScroll:p,markDirty:b,clear:x,destroy:()=>{c!==void 0&&n(c),c=void 0,x(),o?.disconnect(),s?.disconnect(),o=void 0,s=void 0,a=void 0},getActiveId:()=>l}},tr=10,nr=`${tr}vh`,rr=`56px`;`${rr}`;var ir=(e,t)=>e?56:t<=0?96:Math.max(48,tr/100*t),ar=(e,t)=>({sessionId:e,viewportKey:t}),or=(e,t)=>e?.sessionId===t?.sessionId&&e?.viewportKey===t?.viewportKey,sr=(e,t)=>or(e,t),cr=(e,t,n)=>({identity:e,anchor:t,scrollPosition:n}),lr=150,ur=1500,dr=2,fr=350,pr=600,mr=8e3,hr=24,gr=2,_r=(e,t)=>e<t,vr=()=>typeof performance<`u`?performance.now():Date.now(),yr=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),br=e=>e.scrollHeight-e.scrollTop-e.clientHeight,xr=e=>br(yr(e)),Sr=e=>e.scrollHeight-e.clientHeight>1,Cr=(e,t)=>br(e)<=ir(t,e.clientHeight),wr=({enabled:e=!0,scrollControllerRef:t,currentSessionId:n,viewportKey:r,sessionMessageCount:i,sessionIsWorking:a,isMobile:o,onActiveTurnChange:s,onUpwardUserIntent:c})=>{let l=Q.useRef(null),[u,d]=Q.useState(null),f=Q.useRef(null),[p,m]=Q.useState(`following`),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[S,C]=Q.useState(!1),w=Q.useRef(`following`),T=Q.useRef(o);T.current=o;let E=Q.useRef(i);E.current=i;let D=Q.useRef(ar(n,r));D.current=ar(n,r);let O=Q.useRef(null),k=Q.useRef(null),A=Q.useRef(null),j=Q.useRef(0),M=Q.useRef(null),N=Q.useRef(null),P=Q.useRef(0),F=Q.useRef(!1),ee=Q.useRef(null),I=Q.useRef(!1),L=Q.useRef(null),te=Q.useRef(0),z=Q.useRef(!1),B=Q.useRef(null),V=Q.useRef(null),H=x(()=>{te.current=vr()+450,V.current=null}),U=Q.useRef(0),W=Q.useRef(!1),G=Q.useRef(null),K=Q.useRef(null),q=Q.useRef(0),ne=Q.useRef(!1),re=Q.useRef(null),ie=Q.useRef(null),ae=Q.useRef(null),oe=R(e=>e.updateViewportAnchor);Q.useLayoutEffect(()=>{l.current!==f.current&&(f.current=l.current,d(l.current))});let se=x(e=>{w.current!==e&&(w.current=e,m(e))}),J=x(e=>{k.current={top:Math.max(0,e.scrollHeight-e.clientHeight),time:vr()},A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{k.current=null,A.current=null},ur)}),ce=x(e=>{let t=k.current;return t?vr()-t.time>ur?(k.current=null,!1):Math.abs(e.scrollTop-t.top)<dr:!1}),le=x(()=>vr()<P.current),ue=x(()=>{W.current=!1,G.current&&=(clearTimeout(G.current),null),K.current&&=(clearTimeout(K.current),null)}),de=x(()=>{G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{G.current=null,ue()},pr)}),fe=x(()=>{let e=l.current;e&&(W.current=!0,q.current=e.scrollHeight,de(),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{K.current=null,ue()},mr))}),Y=x(e=>{let t=l.current;if(!t){g(!1),v(!1);return}let n=e??yr(t),r=Sr(n);if(g(r),!r){v(!1);return}let i=w.current===`released`&&!Cr(n,T.current);v(i)}),X=x(()=>{j.current+=1,M.current!==null&&typeof window<`u`&&(window.cancelAnimationFrame(M.current),M.current=null),N.current?.(),N.current=null});Q.useEffect(()=>()=>X(),[u]);let pe=x(()=>{if(!e)return;let n=l.current;if(!n)return;if(X(),t?.current?.scrollToBottom({behavior:`auto`,reveal:!1})){J(n),Y();return}let r=j.current,i=n.style.overflowX,a=n.style.overflowY,o=n.style.scrollBehavior;n.style.scrollBehavior=`auto`,n.style.overflow=`hidden`,n.scrollTop=n.scrollHeight,n.scrollHeight,n.style.overflowX=i,n.style.overflowY=a,n.style.scrollBehavior=o;let s=()=>{J(n),n.scrollTop=n.scrollHeight,U.current=n.scrollTop};if(s(),Y(),typeof window>`u`)return;let c=0,u=()=>{_r(vr(),te.current)||X()};n.addEventListener(`touchstart`,u,{passive:!0,once:!0}),N.current=()=>n.removeEventListener(`touchstart`,u);let d=()=>{if(r===j.current){if(xr(n)>gr&&s(),c+=1,c>=hr){M.current=null,N.current?.(),N.current=null,Y();return}M.current=window.requestAnimationFrame(d)}};M.current=window.requestAnimationFrame(d)}),me=x(e=>{let n=l.current;if(n&&(J(n),!t?.current?.scrollToBottom({behavior:e,reveal:!1}))){if(e===`smooth`){n.scrollTo({top:n.scrollHeight,behavior:e});return}n.scrollTop=n.scrollHeight}}),Z=x((t,n=`auto`)=>{if(!e)return;let r=l.current;if(t&&w.current!==`following`&&se(`following`),r&&!(!t&&w.current!==`following`)){if(xr(r)<dr){J(r);return}me(t?n:`auto`)}}),he=x(e=>{let t=l.current;if(!t)return;let n=e??yr(t);Sr(n)&&w.current!==`released`&&(se(`released`),Y(n))}),ge=x((e=`instant`,n)=>{if(z.current=!1,ne.current=!1,se(`following`),ue(),X(),t?.current?.scrollToBottom({behavior:e===`smooth`?`smooth`:`auto`,...n})){let e=l.current;e&&J(e),Y();return}if(e===`instant`){pe();return}X(),Z(!0,`smooth`),Y()}),be=x(()=>{ne.current=!1,Z(!0)}),xe=x(()=>{z.current=!1,X(),t?.current?.cancelScroll(),ue(),se(`released`),Y()}),Se=x(()=>{let t=Ae(),n=l.current;if(!e||!n||!t||!n.contains(t.target)||!t.following||!t.range||V.current)return;let r=yr(n);if(!Sr(r))return;let i=t.range.getBoundingClientRect?.();if(!i||!i.height)return;let a=n.getBoundingClientRect(),o=r.clientHeight*.2,s=Math.min(i.height,r.clientHeight-o*2);if(i.top>=a.top+o&&i.top+s<=a.bottom-o)return;let c=(r.clientHeight-s)/2,u=Math.min(r.scrollHeight-r.clientHeight,Math.max(0,r.scrollTop+i.top-a.top-c));Math.abs(u-r.scrollTop)<=1||(xe(),n.scrollTo({top:u,behavior:window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`instant`:`smooth`}),U.current=n.scrollTop)});Q.useEffect(()=>(Se(),Oe(Se)),[e,u,Se]);let Ce=x(()=>{ne.current=!0,xe()}),we=x(()=>{ne.current=!1}),Te=Q.useRef(c);Te.current=c;let Ee=x(()=>{l.current&&Me(l.current),!_r(vr(),te.current)&&(z.current=!1,X(),t?.current?.cancelScroll(),ue(),he())}),De=x(()=>{te.current=0,Ee(),Te.current?.()}),ke=x(()=>{re.current!==null&&(clearTimeout(re.current),re.current=null);let e=ie.current;if(e){if(!e.identity.sessionId){ie.current=null;return}oe(e.identity.sessionId,e.anchor,e.scrollPosition,e.identity.viewportKey),ie.current=null}}),je=x(()=>{let e=D.current;if(!e.sessionId)return;let t=l.current;if(!t)return;let{scrollTop:n,scrollHeight:r,clientHeight:i}=t,a=r>0?(n+i/2)/r:0,o=Math.floor(a*E.current);ie.current=cr(e,o,{scrollTop:n,scrollHeight:r,clientHeight:i}),re.current===null&&(re.current=setTimeout(()=>{re.current=null,ke()},lr))}),Ne=x(()=>{ke()}),Pe=x(async(e=D.current)=>{if(!e.sessionId||w.current===`released`&&or(e,O.current))return!1;ne.current=!1;let t=l.current;return t?(ae.current=null,se(`following`),H(),T.current?pe():Z(!0),U.current=t.scrollTop,fe(),Y(),!1):(ae.current=e,se(`following`),!1)});Q.useEffect(()=>{let e=D.current,t=O.current;or(e,t)||(ke(),X(),H(),O.current=e,z.current=!1,B.current=null,k.current=null,U.current=0,ue(),ne.current=!1,se(`following`),ae.current=null,n&&n!==t?.sessionId&&Zn.getInstance().recordSessionStart(n))},[n,r]),Q.useEffect(()=>{a&&!ne.current&&w.current===`following`&&Z(!0)},[a]),Q.useEffect(()=>{C(p===`following`&&a)},[p,a]),Q.useLayoutEffect(()=>{if(!u)return;let e=ae.current;e&&sr(e,D.current)&&Pe(e)},[u,n,r]);let Fe=x(()=>{let e=l.current;if(!e)return;let t=yr(e),n=U.current;U.current=t.scrollTop;let r=t.scrollTop>n+.5,i=Math.abs(t.scrollTop-n)<.5;Y(t);let a=Ae();if(a&&e.contains(a.target)){je();return}if(ne.current){je();return}if(Sr(t)){if(Cr(t,T.current)){let e=Math.min(n,Math.max(0,t.scrollHeight-t.clientHeight));if(t.scrollTop<e-.5){Ee(),je();return}(w.current===`following`||r&&z.current)&&(se(`following`),z.current=!1),je();return}if(w.current===`following`&&(ce(e)||le()||i)){F.current||Z(!1),je();return}(w.current===`following`||!r)&&Ee(),je()}});Q.useEffect(()=>{!e||!u||(U.current=u.scrollTop)},[u,e]);let $=x(e=>{let t=l.current;if(t){if(e.deltaY!==0&&Me(t),e.deltaY>0){_e(t,e.target)||(z.current=!0);return}e.deltaY>=0||ve(t,e.target)||De()}}),Ie=x(e=>{z.current=!1;let t=e.touches.item(0);V.current=t?{x:t.clientX,y:t.clientY,dx:0,dy:0}:null}),Le=x(e=>{let t=l.current,n=e.touches.item(0);if(!n){V.current=null;return}let r=V.current;if(!r)return;let i=n.clientY-r.y,a=i*r.dy<0,o=(a?0:r.dx)+n.clientX-r.x,s=(a?0:r.dy)+i;if(V.current={x:n.clientX,y:n.clientY,dx:o,dy:s},!(Math.abs(o)>=Math.abs(s))&&t){if(Math.abs(s)>2&&Me(t),s<-2){_e(t,e.target)||(z.current=!0);return}if(!(s<=0)){if(ve(t,e.target)){V.current.dx=0,V.current.dy=0;return}s<=2||De()}}}),Re=x(()=>{V.current=null}),ze=x(e=>{let t=e.target;if(!(e.defaultPrevented||t instanceof HTMLElement&&(t.isContentEditable||t.closest(`input, textarea, select`)))){if(l.current&&[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&Me(l.current),!e.altKey&&!e.ctrlKey&&!e.metaKey&&[`ArrowDown`,`PageDown`,`End`].includes(e.key)){let e=l.current;e&&!_e(e,t)&&(z.current=!0);return}ye(e)&&De()}}),Be=x(e=>{let t=e.target;t instanceof Element&&t.closest(`[data-overlay-scrollbar-thumb]`)&&(te.current=0,Ee(),B.current={id:e.pointerId,y:e.clientY})}),Ve=x(e=>{let t=B.current;!t||t.id!==e.pointerId||(e.clientY!==t.y&&(z.current=e.clientY>t.y),t.y=e.clientY)}),He=x(()=>{B.current=null}),Ue=x(()=>{z.current=!1}),We=Q.useMemo(()=>()=>void 0,[]),Ge=e&&u?u:We,Ke=Q.useMemo(()=>({passive:!0}),[]);y(`scroll`,Fe,Ge,Ke),y(`scrollend`,Ue,Ge,Ke),Q.useEffect(()=>{if(!e||!u)return;let t={passive:!0,capture:!0};return u.addEventListener(`wheel`,$,t),u.addEventListener(`touchstart`,Ie,t),u.addEventListener(`touchmove`,Le,t),u.addEventListener(`touchend`,Re,t),u.addEventListener(`touchcancel`,Re,t),()=>{u.removeEventListener(`wheel`,$,t),u.removeEventListener(`touchstart`,Ie,t),u.removeEventListener(`touchmove`,Le,t),u.removeEventListener(`touchend`,Re,t),u.removeEventListener(`touchcancel`,Re,t)}},[e,u]),y(`keydown`,ze,Ge),y(`pointermove`,Ve,e&&typeof window<`u`?window:We,!0),y(`pointerup`,He,e&&typeof window<`u`?window:We,!0),y(`pointercancel`,He,e&&typeof window<`u`?window:We,!0),y(`pointerdown`,Be,e&&typeof window<`u`?window:We,!0);let qe=x(()=>{let e=l.current;if(F.current){Y(e?yr(e):void 0);return}if(ne.current){Y(e?yr(e):void 0);return}if(!e){Y(void 0);return}let t=yr(e),n=ee.current;if(n?.element===e&&n.height!==t.clientHeight&&(ee.current=null,w.current===`released`)){e.scrollTop=Math.max(0,n.top+n.height-t.clientHeight),J(e),Y(yr(e));return}if(!Sr(t)){Y(t);return}if(Y(t),W.current){let n=t.scrollHeight>q.current+1;q.current=t.scrollHeight,br(t)<=dr?J(e):Z(!0),n&&de();return}if(w.current===`following`){if(br(t)<=dr){J(e);return}Z(!1)}}),Je=typeof ResizeObserver<`u`,Ye=Je&&e?u:null,Xe=Je&&e&&u&&u.firstElementChild instanceof Element?u.firstElementChild:null;b(Ye,qe),b(Xe,qe);let Ze=x(()=>{L.current!==null&&(clearTimeout(L.current),L.current=null)}),Qe=x(e=>{F.current=!0,typeof e==`number`&&e>0?P.current=vr()+e+fr:P.current=Math.max(P.current,vr()+fr)}),$e=x(e=>{let t=e.detail;if(t){if(t.open===!0){Qe(),Ze(),L.current=setTimeout(()=>{L.current=null,I.current||(F.current=!1)},1500);return}Ze(),Qe()}}),et=x(e=>{let t=e.detail;t&&(Ze(),Qe(t.durationMs),t.nativeResize&&(F.current=!1))}),tt=x(e=>{let t=e.detail;if(Ze(),t?.nativeResize){I.current=t.open===!0,F.current=!1,P.current=vr()+fr,qe();return}t?.open===!0?(I.current=!0,F.current=!0):(I.current=!1,F.current=!0,L.current=setTimeout(()=>{L.current=null,I.current||(F.current=!1)},fr)),Y()}),nt=e&&typeof window<`u`?window:We;y(`yuri:keyboard-native-layout`,()=>{let e=l.current;ee.current=e?{element:e,top:e.scrollTop,height:e.clientHeight}:null},nt),y(`yuri:keyboard-intent`,$e,nt),y(`yuri:keyboard-anim`,et,nt),y(`yuri:keyboard-settled`,tt,nt),Q.useEffect(()=>{if(!(!e||typeof window>`u`))return()=>{Ze(),ee.current=null,F.current=!1,I.current=!1}},[e]),Q.useEffect(()=>{e&&Y()},[e,i]);let rt=x(t=>{if(e){if(t===`animation`&&(P.current=vr()+fr),Y(),W.current){Z(!0),de();return}w.current===`following`&&Z(!1)}}),it=Q.useRef(new Map),at=x(t=>{let n=it.current.get(t);if(n)return n;let r=()=>{e&&w.current===`following`&&Z(!1)},i={onChunk:r,onComplete:()=>{e&&Y()},onStreamingCandidate:()=>{},onAnimationStart:()=>{},onAnimatedHeightChange:r,onReservationCancelled:()=>{},onReasoningBlock:()=>{}};return it.current.set(t,i),i});Q.useEffect(()=>()=>{A.current&&=(clearTimeout(A.current),null),X(),ue(),ke(),re.current!==null&&(clearTimeout(re.current),re.current=null)},[]);let ot=x(e=>{s?.(e)}),st=!!s;return Q.useEffect(()=>{if(!e||!st)return;let t=u;if(!t)return;let n=null,r=er({onActive:e=>{e!==n&&(n=e,ot(e))}});r.setContainer(t);let i=new Map,a=e=>{let t=e.dataset.turnId;return t?(i.set(t,e),r.register(e,t),!0):!1},o=e=>{let t=e.dataset.turnId;return!t||i.get(t)!==e?!1:(i.delete(t),r.unregister(t),!0)},s=e=>{if(!(e instanceof HTMLElement))return[];let t=[];return e.matches(`[data-turn-id]`)&&t.push(e),e.querySelectorAll(`[data-turn-id]`).forEach(e=>t.push(e)),t};t.querySelectorAll(`[data-turn-id]`).forEach(a),r.markDirty();let c=new MutationObserver(e=>{let t=!1;e.forEach(e=>{e.removedNodes.forEach(e=>{s(e).forEach(e=>{o(e)&&(t=!0)})}),e.addedNodes.forEach(e=>{s(e).forEach(e=>{a(e)&&(t=!0)})})}),t&&r.markDirty()});c.observe(t,{subtree:!0,childList:!0});let l=()=>r.onScroll();return t.addEventListener(`scroll`,l,{passive:!0}),()=>{t.removeEventListener(`scroll`,l),c.disconnect(),r.destroy()}},[u,e,st]),{scrollRef:l,state:p,isPinned:p===`following`,isOverflowing:h,isFollowingProgrammatically:S,showScrollButton:_,notifyContentChange:rt,getAnimationHandlers:at,goToBottom:ge,scrollToBottomOnSend:be,releaseAutoFollow:xe,beginHistoryViewportPreservation:Ce,endHistoryViewportPreservation:we,saveSnapshotNow:Ne,restoreSnapshot:Pe}},Tr=`1.5rem`,Er=`box-border w-full whitespace-pre-wrap break-words px-3 typography-markdown [font-family:inherit] [font-style:inherit] [font-weight:inherit] leading-[inherit] tracking-[inherit] md:typography-ui-label pt-4 pb-2`,Dr=`box-border w-full whitespace-pre-wrap break-words px-3 py-2.5 typography-markdown [font-family:inherit] [font-style:inherit] [font-weight:inherit] leading-[inherit] tracking-[inherit]`,Or=Q.memo(function(e){let t=(0,Fe.c)(58),{turn:n,isLast:r,sessionId:i,directory:a,isMobile:o}=e,{t:s}=z(),{hasTouchInput:c}=q(),l=`btw:${i}:${n.id}`,u=`${l}:question`,d;t[0]!==n.question||t[1]!==n.quotes?(d=fe({quotes:n.quotes,question:n.question}),t[0]=n.question,t[1]=n.quotes,t[2]=d):d=t[2];let f;t[3]!==u||t[4]!==i||t[5]!==d?(f={id:u,sessionID:i,messageID:u,type:`text`,text:d},t[3]=u,t[4]=i,t[5]=d,t[6]=f):f=t[6];let p=f,m=Q.useRef(null),h,g;t[7]!==o||t[8]!==l?(h=()=>{if(o&&m.current)return yn(m.current,l)},g=[o,l],t[7]=o,t[8]=l,t[9]=h,t[10]=g):(h=t[9],g=t[10]),Q.useEffect(h,g);let _;t[11]!==s||t[12]!==n.error?(_=n.error===`empty response`||n.error===`session.btw failed`?s(`chat.btw.failed`):n.error,t[11]=s,t[12]=n.error,t[13]=_):_=t[13];let v=_,y=!n.pending&&!n.error&&!n.answer,b;t[14]!==s||t[15]!==n.answer?(b=async()=>{let e=await N(n.answer);return e.ok||I.error(s(`filesView.toast.copyFailed`)),e.ok},t[14]=s,t[15]=n.answer,t[16]=b):b=t[16];let S=x(b),C;t[17]!==o||t[18]!==u||t[19]!==p?(C=(0,$.jsx)(`div`,{className:`relative flex justify-end`,children:(0,$.jsx)(`div`,{className:`max-w-[85%]`,children:(0,$.jsx)(rn,{children:(0,$.jsx)(`div`,{className:`overflow-x-hidden overflow-y-hidden leading-relaxed text-foreground/90 text-base`,children:(0,$.jsx)(en,{part:p,messageId:u,isMobile:o})})})})}),t[17]=o,t[18]=u,t[19]=p,t[20]=C):C=t[20];let w;t[21]!==s||t[22]!==n.pending?(w=n.pending?(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,$.jsx)(k,{name:`loader-4`,className:`size-3.5 animate-spin`,"aria-hidden":`true`}),s(`chat.btw.pending`)]}):null,t[21]=s,t[22]=n.pending,t[23]=w):w=t[23];let T;t[24]===v?T=t[25]:(T=v?(0,$.jsxs)(`p`,{role:`alert`,className:`whitespace-pre-wrap break-words typography-meta text-muted-foreground`,children:[(0,$.jsx)(k,{name:`error-warning`,className:`mr-1.5 inline size-3.5 align-[-2px] text-[var(--status-error)]/85`,"aria-hidden":`true`}),v]}):null,t[24]=v,t[25]=T);let E;t[26]!==y||t[27]!==s?(E=y?(0,$.jsx)(`p`,{role:`status`,className:`typography-meta text-muted-foreground`,children:s(`chat.btw.cancelled`)}):null,t[26]=y,t[27]=s,t[28]=E):E=t[28];let O;t[29]!==l||t[30]!==n.answer?(O=n.answer?(0,$.jsx)(`div`,{"data-speech-content":`true`,children:(0,$.jsx)(J,{content:n.answer,messageId:l,isAnimated:!1,isStreaming:!1,variant:`assistant`,enableFileReferences:!1})}):null,t[29]=l,t[30]=n.answer,t[31]=O):O=t[31];let A;t[32]!==y||t[33]!==S||t[34]!==a||t[35]!==v||t[36]!==c||t[37]!==r||t[38]!==o||t[39]!==l||t[40]!==i||t[41]!==s||t[42]!==n.answer||t[43]!==n.completedAt||t[44]!==n.durationMs||t[45]!==n.pending?(A=!n.pending&&(n.answer||r&&(v||y))?(0,$.jsx)(Pn,{messageId:l,isMobile:o,duration:n.answer&&typeof n.durationMs==`number`&&Number.isFinite(n.durationMs)&&n.durationMs>=0?qn(n.durationMs):null,timestamp:n.answer&&typeof n.completedAt==`number`&&n.completedAt>0?Jn(n.completedAt):null,actions:(0,$.jsxs)($.Fragment,{children:[n.answer?(0,$.jsx)(Fn,{messageId:l,hasCopyableText:!0,isTouchContext:c||o,onCopyMessage:S,ttsText:n.answer,allowSourceSession:!1}):null,r?(0,$.jsxs)(K,{children:[(0,$.jsx)(W,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,className:bn,onPointerDown:Ir,onClick:()=>void Y.getState().retry({sessionId:i,directory:a}),"aria-label":s(`contextPanel.preview.actions.retry`),children:(0,$.jsx)(k,{name:`refresh`,weight:Sn,className:xn})})}),(0,$.jsx)(G,{sideOffset:6,children:s(`contextPanel.preview.actions.retry`)})]}):null]})}):null,t[32]=y,t[33]=S,t[34]=a,t[35]=v,t[36]=c,t[37]=r,t[38]=o,t[39]=l,t[40]=i,t[41]=s,t[42]=n.answer,t[43]=n.completedAt,t[44]=n.durationMs,t[45]=n.pending,t[46]=A):A=t[46];let j;t[47]!==l||t[48]!==O||t[49]!==A?(j=(0,$.jsxs)(`div`,{ref:m,"data-message-id":l,"data-message-text-export-root":`true`,"data-speech-identity":l,...Xn,className:`min-w-0 text-foreground yuri-message-hover-scope`,children:[O,A]}),t[47]=l,t[48]=O,t[49]=A,t[50]=j):j=t[50];let M;return t[51]!==E||t[52]!==j||t[53]!==C||t[54]!==w||t[55]!==T||t[56]!==n.id?(M=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,"data-btw-turn":n.id,children:[C,w,T,E,j]}),t[51]=E,t[52]=j,t[53]=C,t[54]=w,t[55]=T,t[56]=n.id,t[57]=M):M=t[57],M});function kr(e){let t=(0,Fe.c)(64),{scope:n,pending:r,quotes:i,foot:a}=e,{t:o}=z(),s;t[0]===n?s=t[1]:(s=e=>e.sendSelection[X(n)],t[0]=n,t[1]=s);let c=Y(s),l;t[2]!==n||t[3]!==c?(l=c??de(n),t[2]=n,t[3]=c,t[4]=l):l=t[4];let u=l,d=M(Ar),f;bb0:{if(!u?.providerID||!u?.modelID){f=null;break bb0}let e;if(t[5]!==d||t[6]!==u.modelID||t[7]!==u.providerID){let n;t[9]===u.providerID?n=t[10]:(n=e=>e.id===u.providerID,t[9]=u.providerID,t[10]=n);let r=d.find(n);e=ee(r,u.modelID)||u.modelID,t[5]=d,t[6]=u.modelID,t[7]=u.providerID,t[8]=e}else e=t[8];f=e}let p=f,[m,h]=Q.useState(``),g=Q.useRef(null),_,v;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>{let e=window.requestAnimationFrame(()=>{g.current?.focus({preventScroll:!0})});return()=>window.cancelAnimationFrame(e)},v=[],t[11]=_,t[12]=v):(_=t[11],v=t[12]),Q.useEffect(_,v);let y;t[13]!==m||t[14]!==r||t[15]!==n?(y=()=>{let e=m.trim();!e||r||(h(``),Y.getState().ask(n,e))},t[13]=m,t[14]=r,t[15]=n,t[16]=y):y=t[16];let b=x(y),S;t[17]!==p||t[18]!==u?(S=u&&p?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-lg px-2.5 py-1`,"aria-label":p,children:[(0,$.jsx)(be,{modelId:u.modelID,providerId:u.providerID,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-meta font-medium text-foreground`,children:p})]}):null,t[17]=p,t[18]=u,t[19]=S):S=t[19];let C=S,w=a!==`panel`,T=w?`yuri-mobile-composer`:`pb-3`,E=a===`page`?`bottom-safe-area`:``,D;t[20]!==T||t[21]!==E?(D=[`shrink-0 px-3 pt-1`,T,E].filter(Boolean),t[20]=T,t[21]=E,t[22]=D):D=t[22];let O=D.join(` `),k;t[23]===b?k=t[24]:(k=e=>{e.preventDefault(),b()},t[23]=b,t[24]=k);let A;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>h(e),t[25]=A):A=t[25];let j;t[26]===n?j=t[27]:(j=()=>Y.getState().cancel(n),t[26]=n,t[27]=j);let N;t[28]===o?N=t[29]:(N=o(`chat.btw.placeholder`),t[28]=o,t[29]=N);let P;t[30]===o?P=t[31]:(P=o(`chat.chatInput.actions.sendMessageAria`),t[30]=o,t[31]=P);let F;t[32]===o?F=t[33]:(F=o(`chat.statusRow.actions.stopGeneratingAria`),t[32]=o,t[33]=F);let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I={autoFocus:!0},t[34]=I):I=t[34];let L=w?`relative z-10 yuri-mobile-composer-surface`:`relative z-10`,R;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(R={borderRadius:Tr},t[35]=R):R=t[35];let te=w?Dr:Er,B;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(B={borderTopLeftRadius:Tr,borderTopRightRadius:Tr},t[36]=B):B=t[36];let V;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(V={borderBottomLeftRadius:Tr,borderBottomRightRadius:Tr},t[37]=V):V=t[37];let H;t[38]===o?H=t[39]:(H=o(`chat.btw.removeQuoteAria`),t[38]=o,t[39]=H);let U;t[40]===n?U=t[41]:(U=e=>Y.getState().removeQuote(n,e),t[40]=n,t[41]=U);let W;t[42]!==i||t[43]!==H||t[44]!==U?(W=(0,$.jsx)(Le,{quotes:i,removeLabel:H,onRemove:U}),t[42]=i,t[43]=H,t[44]=U,t[45]=W):W=t[45];let G;t[46]!==m||t[47]!==w||t[48]!==C||t[49]!==r||t[50]!==b||t[51]!==j||t[52]!==N||t[53]!==P||t[54]!==F||t[55]!==L||t[56]!==te||t[57]!==W?(G=(0,$.jsx)(ge,{value:m,onChange:A,onSubmit:b,onStop:j,pending:r,disableInputWhilePending:!1,isMobile:w,placeholder:N,sendLabel:P,stopLabel:F,inputRef:g,textareaProps:I,leftControls:C,className:L,style:R,textLayoutClassName:te,inputStyle:B,footerClassName:`z-30 bg-transparent flex-shrink-0 px-2.5 py-1.5`,footerStyle:V,inputHeader:W}),t[46]=m,t[47]=w,t[48]=C,t[49]=r,t[50]=b,t[51]=j,t[52]=N,t[53]=P,t[54]=F,t[55]=L,t[56]=te,t[57]=W,t[58]=G):G=t[58];let K;return t[59]!==a||t[60]!==O||t[61]!==k||t[62]!==G?(K=(0,$.jsx)(`form`,{"data-btw-composer":!0,"data-btw-composer-foot":a,className:O,onSubmit:k,children:G}),t[59]=a,t[60]=O,t[61]=k,t[62]=G,t[63]=K):K=t[63],K}function Ar(e){return e.providers}function jr(e){let t=(0,Fe.c)(49),{scope:n,foot:r,active:i,hostRegistry:a}=e,o=r===void 0?`panel`:r,s=i===void 0||i,{t:c}=z(),l;t[0]===n?l=t[1]:(l=X(n),t[0]=n,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d=e=>(e.entries[u]??pe).turns,t[2]=u,t[3]=d);let f=Y(d),p;t[4]===u?p=t[5]:(p=e=>(e.entries[u]??pe).quotes,t[4]=u,t[5]=p);let m=Y(p),g;t[6]===f?g=t[7]:(g=f.some(Mr),t[6]=f,t[7]=g);let _=g,v=`btw:${u}`,y=o!==`panel`,b;t[8]!==s||t[9]!==_||t[10]!==n.sessionId||t[11]!==v||t[12]!==y||t[13]!==f.length?(b={enabled:s,currentSessionId:n.sessionId,viewportKey:v,sessionMessageCount:f.length,sessionIsWorking:_,isMobile:y},t[8]=s,t[9]=_,t[10]=n.sessionId,t[11]=v,t[12]=y,t[13]=f.length,t[14]=b):b=t[14];let{scrollRef:x,notifyContentChange:S}=wr(b),C=f[f.length-1],w;t[15]===S?w=t[16]:(w=()=>{S(`structural`)},t[15]=S,t[16]=w);let T=C?.answer,E=C?.pending,D;t[17]!==S||t[18]!==T||t[19]!==E||t[20]!==f.length?(D=[f.length,T,E,S],t[17]=S,t[18]=T,t[19]=E,t[20]=f.length,t[21]=D):D=t[21],Q.useLayoutEffect(w,D);let O;t[22]===c?O=t[23]:(O=c(`chat.btw.title`),t[22]=c,t[23]=O);let k;t[24]!==o||t[25]!==n.directory||t[26]!==n.sessionId||t[27]!==c||t[28]!==f?(k=f.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:c(`chat.btw.description`)}):f.map((e,t)=>(0,$.jsx)(Or,{turn:e,isLast:t===f.length-1,sessionId:n.sessionId,directory:n.directory,isMobile:o!==`panel`},e.id)),t[24]=o,t[25]=n.directory,t[26]=n.sessionId,t[27]=c,t[28]=f,t[29]=k):k=t[29];let A;t[30]===k?A=t[31]:(A=(0,$.jsx)(`div`,{className:`flex flex-col gap-5`,children:k}),t[30]=k,t[31]=A);let j;t[32]!==x||t[33]!==A?(j=(0,$.jsx)(`div`,{ref:x,"data-btw-transcript":!0,className:`overlay-scrollbar-container min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3`,children:A}),t[32]=x,t[33]=A,t[34]=j):j=t[34];let M;t[35]!==o||t[36]!==u||t[37]!==_||t[38]!==m||t[39]!==n?(M=(0,$.jsx)(kr,{scope:n,pending:_,quotes:m,foot:o},u),t[35]=o,t[36]=u,t[37]=_,t[38]=m,t[39]=n,t[40]=M):M=t[40];let N;t[41]!==O||t[42]!==j||t[43]!==M?(N=(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 min-w-0 flex-col text-foreground`,"aria-label":O,children:[j,M]}),t[41]=O,t[42]=j,t[43]=M,t[44]=N):N=t[44];let P=N,F;return t[45]!==a||t[46]!==P||t[47]!==n.host?(F=n.host&&a?(0,$.jsx)(h,{registry:a,location:n.host.location,children:P}):P,t[45]=a,t[46]=P,t[47]=n.host,t[48]=F):F=t[48],F}function Mr(e){return e.pending}function Nr(e){let n=(0,Fe.c)(53),{scope:r,active:i,mobile:a}=e,{t:o}=z(),{sessionId:s,directory:c}=r,l;n[0]===r?l=n[1]:(l=X(r),n[0]=r,n[1]=l);let u=l,d;n[2]===c?d=n[3]:(d=t(c),n[2]=c,n[3]=d);let f=d,p;n[4]===f?p=n[5]:(p=e=>e.contextPanelByDirectory[f],n[4]=f,n[5]=p);let m=S(p),h;n[6]!==i||n[7]!==m?(h=i&&!!(m?.isOpen&&m.tabs.find(e=>e.id===m.activeTabId)?.mode===`btw`),n[6]=i,n[7]=m,n[8]=h):h=n[8];let g=h,_;n[9]===m?_=n[10]:(_=m?.isOpen&&m.tabs.some(Fr),n[9]=m,n[10]=_);let v=!!_,y;n[11]!==u||n[12]!==v?(y={key:u,retained:v},n[11]=u,n[12]=v,n[13]=y):y=n[13];let b=Q.useRef(y),C,w;n[14]!==u||n[15]!==v||n[16]!==c||n[17]!==s?(C=()=>{let e={sessionId:s,directory:c},t=b.current;b.current={key:u,retained:v},t.key===u&&t.retained&&!v&&Y.getState().clear(e)},w=[u,v,s,c],n[14]=u,n[15]=v,n[16]=c,n[17]=s,n[18]=C,n[19]=w):(C=n[18],w=n[19]),Q.useEffect(C,w);let T=Q.useRef(null),E,D;n[20]!==i||n[21]!==u||n[22]!==c||n[23]!==s?(D=()=>{let e={sessionId:s,directory:c},t={key:u,active:i};T.current=t;let n=()=>P({sessionId:s,directory:c??null});return!i&&!n()&&Y.getState().cancel(e),()=>{let r=Y.getState().entries[u];queueMicrotask(()=>{let i=T.current;i!==t&&i?.key===u&&i.active||n()||X(e)===u&&Y.getState().entries[u]===r&&Y.getState().cancel(e)})}},E=[u,i,s,c],n[20]=i,n[21]=u,n[22]=c,n[23]=s,n[24]=E,n[25]=D):(E=n[24],D=n[25]),Q.useEffect(D,E);let O;n[26]!==f||n[27]!==r?(O=()=>{Y.getState().clear(r),S.getState().closeContextPanel(f)},n[26]=f,n[27]=r,n[28]=O):O=n[28];let k=x(O),A,j;if(n[29]!==a||n[30]!==g?(A=()=>{if(!a||!g){he(Z);return}return me(Z),Pr},j=[a,g],n[29]=a,n[30]=g,n[31]=A,n[32]=j):(A=n[31],j=n[32]),Q.useEffect(A,j),!a)return null;let M;n[33]===k?M=n[34]:(M=e=>{e||k()},n[33]=k,n[34]=M);let N;n[35]===o?N=n[36]:(N=o(`chat.btw.title`),n[35]=o,n[36]=N);let F;n[37]===o?F=n[38]:(F=o(`chat.btw.title`),n[37]=o,n[38]=F);let ee;n[39]===o?ee=n[40]:(ee=o(`gitView.common.close`),n[39]=o,n[40]=ee);let I;n[41]===o?I=n[42]:(I=o(`chat.btw.resize`),n[41]=o,n[42]=I);let L;n[43]===r?L=n[44]:(L=(0,$.jsx)(jr,{scope:r,foot:`sheet`}),n[43]=r,n[44]=L);let R;return n[45]!==g||n[46]!==M||n[47]!==N||n[48]!==F||n[49]!==ee||n[50]!==I||n[51]!==L?(R=(0,$.jsx)(H,{id:`session-btw`,open:g,onOpenChange:M,title:N,ariaLabel:F,closeAriaLabel:ee,resizeAriaLabel:I,children:L}),n[45]=g,n[46]=M,n[47]=N,n[48]=F,n[49]=ee,n[50]=I,n[51]=L,n[52]=R):R=n[52],R}function Pr(){return he(Z)}function Fr(e){return e.mode===`btw`}function Ir(e){return e.stopPropagation()}export{xt as A,Ut as C,Nt as D,Pt as E,lt as F,st as I,Le as L,yt as M,_t as N,Mt as O,pt as P,Ie as R,Gt as S,Bt as T,An as _,rr as a,rn as b,Jn as c,Fn as d,Pn as f,Sn as g,xn as h,nr as i,bt as j,jt as k,Yn as l,bn as m,jr as n,Zn as o,Cn as p,wr as r,Xn as s,Nr as t,qn as u,jn as v,zt as w,en as x,yn as y};
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-C6UIEZxp.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-auth-DA-qfGHk.js","assets/platform-CiUKDeXd.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CTekDqaS.js","assets/vendor-base-ui-wXsskyKm.js","assets/prompt-attachment-upload-B5DHrw6U.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-file-resource-Bc_ss-sW.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/yuriEvents-BFrD5fMU.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/input-store-BSJBQTMi.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/uuid-D-SDZijH.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{d as r}from"./platform-CiUKDeXd.js";import{a as i}from"./vendor-zustand-CTekDqaS.js";import{ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{St as s}from"./gitApiHttp-Dd-FwgCq.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as c,R as l,Wt as u,Xt as d,at as f,dr as p,en as m,it as h,n as g,nr as _,on as v,rt as y,tn as b,tr as x}from"./client-B_907PBv.js";import{n as S}from"./vendor-react-BkccXcWz.js";import{o as C,s as w}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as T}from"./yuriEvents-BFrD5fMU.js";import{A as E,E as D,I as O,R as k,k as A}from"./runtime-file-resource-Bc_ss-sW.js";import{r as ee}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as j}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as M}from"./useUIStore-C3ewjGgP.js";import{s as N}from"./spacedFileMention-Ds4GtgiF.js";import{i as P,o as F,r as I}from"./session-startup-barrier-DT-hIBRf.js";import{n as L}from"./Icon-DmykXZL1.js";import{$r as R,Ar as te,B as z,Dr as B,En as V,Fn as ne,Gt as re,H as ie,Hi as H,Ia as U,In as ae,Ji as oe,Jr as se,Na as ce,Nn as W,Oa as le,Pn as ue,Ri as de,Tn as fe,U as pe,Vi as me,Xr as he,Yr as ge,Zn as _e,bt as ve,ci as ye,di as be,dr as xe,dt as Se,f as G,ft as Ce,gt as we,ht as Te,j as Ee,jr as De,kr as Oe,li as ke,lt as Ae,mt as je,pt as Me,rr as K,si as Ne,sn as Pe,t as q,ui as J,un as Y,zi as Fe}from"./ui-ee2iN869.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-C8382jM8.js";import{t as ze}from"./i18n-DXc6czdR.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-stxT7gLf.js";import{t as He}from"./MobileResizableSheet-CqphcaKq.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-BeFBA6ja.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-CpTbxEOE.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-BblI9sN2.js";import{n as et}from"./useProjectRuntimeAPIs-tjGuODhu.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-CoVwjIDy.js";import{o as at,t as ot}from"./useProjectGitStore-DzU2pvrH.js";import{t as st}from"./input-Cf16qJ6g.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-BMN5hAVm.js";import{t as ut}from"./MobileOverlayPanel-C36VWWmN.js";import{t as dt}from"./githubAuthQueries-DqregESf.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-DGu8M01Z.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-CuLKwxkx.js";import{s as St}from"./remote-input-store-C6UIEZxp.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-DmtfYPz0.js";import{f as Tt,m as Et}from"./auto-read-context-ClBUErN2.js";var Dt=2e3,Ot=i((e,t)=>({pending:!1,expiresAt:null,arm:(t=Dt)=>{let n=Date.now()+t;return e({pending:!0,expiresAt:n}),n},clear:()=>{!t().pending&&t().expiresAt===null||e({pending:!1,expiresAt:null})}})),X=e(o(),1),kt=new class{inFlightByScope=new WeakMap;generationByScope=new WeakMap;run(e){let t=this.inFlightByScope.get(e.scope);t||(t=new Map,this.inFlightByScope.set(e.scope,t));let n=t.get(e.key);if(n)return n;let r=this.generationByScope.get(e.scope);r||(r=new Map,this.generationByScope.set(e.scope,r));let i=(r.get(e.key)??0)+1;r.set(e.key,i);let a=e.request(()=>r?.get(e.key)!==i);return t.set(e.key,a),a.finally(()=>{t?.get(e.key)===a&&t.delete(e.key)}).catch(()=>{}),a}},At=e=>C({queryKey:[e.transport,`sessionChildren`,e.generation,r(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>T.fetchQuery(At(e)),Mt=(e,t)=>e.id<t.id?-1:+(e.id>t.id),Nt=(e,t,n)=>{let r=new Set(e.map(e=>e.id)),i=t.filter(e=>!e?.id||r.has(e.id)||e.parentID!==n?!1:(r.add(e.id),!0));return i.length===0?e:[...e,...i].sort(Mt)},Pt=30,Ft=new Map;function It(e,t=!1){return{limit:e.loadedTurns,cursor:e.kind===`has-more`?e.cursor:void 0,complete:e.kind===`exhausted`,loading:t}}function Lt(e,t){let n=d();if(!n)return!1;let r=n.getTranscript(v(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>De()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=ae.search(r,t,e=>e.id);i.found?r[i.index]=n:r.splice(i.index,0,n),e.setState({session:r})}function Bt(){let e=ve(),r=ie(),i=z(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=d();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=v(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),s=(0,X.useCallback)((e,t)=>{if(t.length===0)return;let n=i.getChild(e);if(!n)return;let r=n.getState(),a={session_status:{...r.session_status},session_status_observed_at:{...r.session_status_observed_at},session_error_at:{...r.session_error_at},session_diff:{...r.session_diff},todo:{...r.todo},permission:{...r.permission},question:{...r.question}};W(a,t),Ee(n,t),n.setState(a);for(let n of t)m(e,n)},[i]),l=(0,X.useCallback)((t=e)=>{let n=Ft.get(t);if(n)return Ft.delete(t),Ft.set(t,n),n;let r=new Set;for(Ft.set(t,r);Ft.size>Pt;){let e=Ft.keys().next().value;if(!e)break;let t=[...Ft.get(e)??[]];Ft.delete(e),s(e,t)}return r},[e,s]),f=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=l(n),c=ue(a.getState()),u=Oe(),f=ne({seen:o,keep:t,limit:u,preserve:c});if(s(n,f),te()){let e=new Set([t,...o,...c]),r=(d()?.getCacheBudget?.().listCanonical({directory:n})??[]).map(e=>e.scope.sessionID),i=(r.length>0?r:Array.from(o)).filter(r=>r===t||e.has(r)?!1:Lt(n,r));if(i.length>0){for(let e of i)o.delete(e);s(n,i)}}},[i,e,l,s,r]),h=(0,X.useCallback)(async(t,n)=>{let a=n?.directory??e;if(!t||!a||a===`global`)return;let o=a===e?r:i.ensureChild(a,{bootstrap:!1}),s=o.getState(),l=s.session_status?.[t],u=s.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await c(a,t):await b(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=d()?.getTranscript(v(a,t));Y({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await xe({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:u,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),_=(0,X.useCallback)(async(t,n)=>{await I();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o);f(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=d(),a=v(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,u=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},f=ae.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&u.kind!==`unknown`&&m?.status!==`error`&&f&&B(o,t)){Y({directory:o,sessionID:t,store:s,isStale:e});return}let g=!!(r||!l||f),_=Rt({hasSession:f,shouldLoadMessages:g,force:!!r});await Promise.all([_?(async()=>{try{let n=await Fe(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=de(p(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),g?h(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,f,h,e]),y=ee(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,f=await jt({transport:u,generation:l,directory:o,sessionID:r,request:async e=>{let i=[],a=new Set,s;do{if(e.throwIfAborted(),l!==n()||u!==t())throw new DOMException(`Session children runtime changed`,`AbortError`);let d=await c.session.list(s?{cursor:s,limit:50}:{directory:o,parentID:r,limit:50},{signal:e});if(!Array.isArray(d?.data))throw Error(`session.list children returned no data`);if(i.push(...d.data.map(p)),d.data.length<50)break;if(s=d.cursor?.next??void 0,!s||a.has(s))throw Error(`session.list children pagination did not advance`);a.add(s)}while(s);return i}}).catch(e=>{if(d())return null;throw e});!f||d()||s.setState(e=>{let t=Nt(e.session,f,r);return t===e.session?e:{session:t,limit:Math.max(e.limit,t.length)}})}),x=(0,X.useCallback)((t,n)=>{let r=o(t,n?.directory??e);return!r.complete&&!!r.cursor},[e,o]),S=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).loading,[e,o]),C=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).complete,[e,o]),w=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),E=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),D=ee(async(r,a)=>{if(!r)return;await I();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),u=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await b(o,r),u())return;Y({directory:o,sessionID:r,store:s}),await xe({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(d()?.getTranscript(v(o,r)).messageOrder.length??0)>0,isStale:u})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:_,syncSession:_,loadChildren:y,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:D,optimistic:{add:w,remove:T,confirm:E}}),[_,y,x,S,C,D,w,T,E])}var Z=S(),Q=a(),Vt=(e,t)=>{if(!e)return t;let n=e.ready&&!e.loading;return{modelsReady:!e.error&&(e.modelsReady??n),agentsReady:!e.error&&(e.agentsReady??n)}},Ht=e=>{let t=e?.variants;if(!t)return[];if(Array.isArray(t)){let e=[],n=new Set;for(let r of t){let t=typeof r==`string`?r:r&&typeof r==`object`&&!Array.isArray(r)&&typeof r.id==`string`?r.id:``;!t||n.has(t)||(n.add(t),e.push(t))}return e}return typeof t==`object`?Object.keys(t):[]},Ut=(e,t,n,r)=>{if(e.providerID!==n||e.modelID!==r||t?.variantsReady===!1)return[];if(t?.variants)return[...t.variants];let i=(t?.providers?.find(e=>e.id===n))?.models?.find(e=>e.id===r);return Ht(i)},Wt=()=>!0,Gt=(e,t)=>(e.commandPolicy??Wt)(t),Kt=X.createContext(null),qt=()=>X.useContext(Kt),Jt=e=>e,Yt=(e,t)=>t??e,Xt=e=>{if(e.kind!==`primary`&&(!e.sessionID||!e.directory||!e.draftKey||!e.transportIdentity||!Number.isSafeInteger(e.runtimeGeneration)||!e.resources||typeof e.resources.busy!=`boolean`||!e.activity||!e.commands||!e.shortcuts))throw Error(`chat-input-secondary-surface-incomplete`)},Zt=(e,t)=>e.kind===`secondary`?e.resources?.busy??!1:t,Qt=e=>!e.sessionID||!e.directory?null:{deliveryTarget:e.deliveryTarget,sessionID:e.queueSessionID??e.sessionID,directory:e.directory,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration},$t=(e,t,n)=>{if(e.kind===`secondary`){if(!e.commands)throw Error(`chat-input-secondary-commands-incomplete`);return e.commands}return e.commands?e.commands:{sessionID:e.sessionID,hasMessages:t,hasNewDraft:n}},en={phase:`idle`,isWorking:!1,isBusy:!1,isCooldown:!1},tn=e=>e.hasPendingAssistant?e.messages.some(e=>e.role===`assistant`&&typeof e.time?.completed==`number`):!1;function nn(e,t){let n=(0,Z.c)(6),r=je(e??``,t),i=Te(e??``,t),a=Ae(e??``,t),o=Ce(e??``,t),s=Me(e??``,t),c=we(t),l;bb0:{if(!e){l=en;break bb0}if(o.length>0||s.length>0){l=en;break bb0}let t=r?.type??`idle`,u=a[a.length-1],d=!!(u&&u.role===`assistant`&&typeof u.time?.completed!=`number`),f=a,p;n[0]!==d||n[1]!==f?(p=tn({messages:f,hasPendingAssistant:d}),n[0]=d,n[1]=f,n[2]=p):p=n[2];let m=p,h=u?.time?.created,g=!!(m&&typeof c==`number`&&typeof h==`number`&&h<=c),_=r!==void 0,v=_&&t!==`idle`,y=v||m&&!g;if(_&&!v&&(!m||_&&!v&&typeof i==`number`&&typeof h==`number`&&h<=i)){l=en;break bb0}if(!y){l=en;break bb0}let b=v?t:`busy`,x=t===`busy`||!v&&m,S;n[3]!==b||n[4]!==x?(S={phase:b,isWorking:!0,isBusy:x,isCooldown:!1},n[3]=b,n[4]=x,n[5]=S):S=n[5],l=S}return l}var rn=`data-mobile-overlay-active`,an=e=>Array.from(e).some(e=>e.getAttribute(rn)!==`false`),on=`artful.bionic.cosmic.disco.focal.groovy.jammy.kinetic.lunar.noble.bold.brave.calm.eager.gentle.happy.keen.lively.merry.swift.warm.wise.bright.clever.daring.agile.crisp.fresh.lucid.quick.sharp.vivid.zealous`.split(`.`),sn=`aardvark.beaver.chipmunk.dolphin.falcon.gopher.hedgehog.jackal.koala.lemur.mongoose.narwhal.otter.pangolin.quokka.raccoon.salamander.toucan.walrus.yak.zebra.badger.condor.dingo.egret.ferret.gecko.heron.iguana`.split(`.`);function cn(){return`${on[Math.floor(Math.random()*on.length)]}-${sn[Math.floor(Math.random()*sn.length)]}`}function ln(e){let t=cn();return e&&e.trim()?`${e.trim().replace(/\/+$/,``)}/${t}`:t}async function un(e,t,n){if(!e.hostId||!e.hubId)throw Error(`Remote Project Host scope is unavailable`);let i=U.getState().remoteSession,a=O(),o=await Re();if(a.assertCurrent(),!o.supported||o.hubId!==e.hubId||!o.projects.some(t=>t.id===e.id&&t.hostId===e.hostId&&t.path===e.path))throw Error(`Remote Project is not referenced by the current Hub`);let s=Ie(o);await s.connectHost(e.hostId);let c=s.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),l=O(c),u=_e(c);if(!await u.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let d=await ge(e,c),p=d.commands,m=Array.isArray(p)?p.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>R(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,g=await u.getGitStatus(e.path),_=await u.getGitBranches(e.path),v=await u.listGitWorktrees(e.path),b=r(e.path),x=v.map(e=>r(e.path)).filter(e=>b===e||b.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=x?b.slice(x.length):``,C=(_.branches?.[g.current]?.tracking||g.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...m?{startCommand:m}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},E=await u.previewGitWorktree(e.path,T);if(!E.path)throw Error(`Remote worktree preview missing path`);let D=ye();be(D).catch(()=>void 0);let k=S?`${E.path.replace(/[\\/]+$/,``)}${S}`:E.path,A={...c.location,directory:k},ee={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:d.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:D,bootstrapPendingDirectory:k,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(A,n.initialPrompt),l.assertCurrent()}catch(e){throw ke(D,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&U.getState().remoteSession===i&&U.getState().openRemoteSession(e,A,null,ee);let M=U.getState().remoteSession,N=M?.draft?.pendingWorktreeRequestId===D,P=()=>{if(!n.isSelected()||!N)return!1;let t=U.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===D?(M=t,!0):t===M};try{let r=await u.createGitWorktree(e.path,T);if(!r.path||!r.name)throw Error(`Remote worktree create missing name/path`);let i=r.bootstrapStatus,a=Date.now()+12e4;for(;i?.status===`pending`&&d.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),l.assertCurrent(),i=await u.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);l.assertCurrent();let o=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...c.location,directory:o},m={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:o,worktreeRoot:r.path,projectDirectory:e.path,relativePath:S.replace(/^\//,``)||void 0,branch:r.branch,label:r.branch||r.name,source:`sdk`,worktreeSource:`created-for-session`,headState:r.branch?`branch`:`unborn`,worktreeStatus:i?.status===`pending`?`pending`:`ready`,createdFromBranch:n.createdFromBranch||g.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:d.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(o!==k){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await j(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-C6UIEZxp.js`).then(e=>e.a);return{getRemoteInputStore:e,remoteSessionDraftKey:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26])),n=e(p),r=t(A,null),i=n.getState().getDraft(r),a=await n.getState().moveDraftWithAttachments(r,t(p,null),i?.revision);if(i&&!a)throw Error(`Remote draft changed while the worktree target was being finalized; the original draft was retained`);l.assertCurrent()}!n.createSession&&P()&&M&&(U.getState().updateRemoteDraft(M,m,p),M=U.getState().remoteSession),n.createSession||J(D,o);let _;if(n.createSession)try{let t=s.resolve(p).service(),r=P()?M?.draft?.title??n.title:n.title,i=await t.createSession({title:r},o);_=i.id,l.assertCurrent();let a=await t.getConfig(o).catch(()=>void 0);l.assertCurrent();let c=e.defaultModel||a?.model,u=typeof c==`string`?c:void 0,d=u?.indexOf(`/`)??-1,m=d>0?u.slice(0,d):h(i),g=d>0?u.slice(d+1):y(i),v=a?.default_agent||i.agent,b=typeof v==`string`?v:void 0,x=oe.getState();m&&g&&x.saveSessionModelSelection(i.id,m,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&m&&g&&(x.saveAgentModelForSession(i.id,b,m,g,p),x.saveAgentModelVariantForSession(i.id,b,m,g,f(i),p))}catch(t){throw await u.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return l.assertCurrent(),n.createSession&&P()&&U.getState().openRemoteSession(e,p,_??null,{...M?.draft,...m}),n.createSession&&J(D,o),{path:o,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw P()&&M&&U.getState().updateRemoteDraft(M,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),ke(D,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=ce.getState().getActiveProject();return t?.id===e.id&&t?.hostId===e.hostId&&t?.hubId===e.hubId&&t?.path===e.path},pn=e=>({agentName:e.currentAgentName,providerId:e.currentProviderId,modelId:e.currentModelId,variant:e.currentVariant}),mn=(e,t,n)=>{let r=t.agentName?.trim()||void 0,i=t.providerId?.trim()||void 0,a=t.modelId?.trim()||void 0;!r||!i||!a||(n.saveSessionAgentSelection(e,r),n.saveSessionModelSelection(e,i,a),n.saveAgentModelForSession(e,r,i,a),n.saveAgentModelVariantForSession(e,r,i,a,t.variant))},hn=async(e,t)=>{await he(e)&&await Ne(t)},gn=e=>{let t=dn(e),n=ce.getState().projects;if(n.length===0)return null;let r=n.filter(e=>{if(e.hostId)return!1;let n=dn(e.path);return t===n||t.startsWith(`${n}/`)}).sort((e,t)=>dn(t.path).length-dn(e.path).length)[0];return r?{id:r.id,path:r.path}:null},_n=!1,vn=async(e,t)=>{try{let n=ce.getState().projects.find(e=>e.id===t.id)??ce.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=me(t.path);await H.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=H.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(H.getState()),oe.getState())}catch{}},yn=async(e,t,n)=>{let r=G.getState(),i=H.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),s.getState().setDirectory(t.path,{showOverlay:!1})},bn=e=>e.trim().replace(/^remotes\//,``).replace(/[^A-Za-z0-9._/-]+/g,`-`).replace(/\/+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`worktree`,xn=async e=>{if(_n)return null;let t=ce.getState().getActiveProject();if(t?.hostId){_n=!0;let n=fn(t);try{let r=e?.existingBranch?.trim().replace(/^remotes\//,``),i=r?bn(r):ln();return(await un(t,{mode:r?`existing`:`new`,worktreeName:i,...r?{existingBranch:r}:{branchName:i}},{...e,isSelected:n})).path}catch(e){return q.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}finally{_n=!1}}let n=e?.projectDirectory?.trim()||t?.path;if(!n)return q.error(`No active project`,{description:`Please select a project first.`}),null;let r=gn(n)??(t?.path?{id:t.id,path:t.path}:null);if(!r)return q.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return q.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;_n=!0;try{let t=ye(),n=e?.existingBranch?.trim().replace(/^remotes\//,``)||``,i=n?bn(n):ln(),a=n?`existing`:`new`,o=G.getState();o.newSessionDraft?.open?o.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:o.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):o.openNewSessionDraft({selectedProjectId:r.id,directoryOverride:r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt});let c=await nt(r.path,{mode:a,...a===`new`?{branchName:i,worktreeName:i}:{existingBranch:n,worktreeName:i}}).catch(()=>null);c?.path&&(G.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(c.path,{showOverlay:!1}));let l=await se(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return J(t,u.path),G.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=G.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(ke(n,e instanceof Error?e:Error(t)),G.getState().resolvePendingDraftWorktreeTarget(n,null)),G.getState().setDraftBootstrapPendingDirectory(null),q.error(`Failed to create worktree`,{description:t}),null}finally{_n=!1}};async function Sn(){return xn()}async function Cn(e){let t=e.branch?.trim();return t?xn({existingBranch:t,projectDirectory:e.projectDirectory,initialPrompt:e.initialPrompt,title:e.title}):null}async function wn(e,t,n,r){if(_n)return null;_n=!0;try{let i=ce.getState().getActiveProject();if(i?.hostId){let e=fn(i);try{if(!t.trim())throw Error(`Branch name is required`);let a=await un(i,{mode:`new`,branchName:t.trim(),worktreeName:r?.worktreeName||t.trim(),startRef:n?.trim()||`HEAD`,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl},{createSession:!0,isSelected:e,kind:r?.kind,createdFromBranch:r?.createdFromBranch});if(!a.id)throw Error(`Could not create a remote session for the worktree`);return{id:a.id,branch:a.branch,path:a.path}}catch(e){return q.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}}let a=n?.trim()||`HEAD`,o=t?.trim();if(!o)throw Error(`Branch name is required`);let s=r?.kind??`standard`,c=gn(e);if(!c)throw Error(`Project is not registered in Yuri`);let l=!1;try{l=await rt(c.path)}catch{}if(!l)return q.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await se(c),d=await mt(c.path);try{let e=await _t(c,{preferredName:o,mode:`new`,branchName:o,worktreeName:r?.worktreeName||o,startRef:a,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl,setupCommands:u,returnAfterDirectoryCreated:r?.returnAfterDirectoryCreated}),t={...e,createdFromBranch:r?.createdFromBranch||d||a,kind:s};await hn(c,e.worktreeRoot??e.path);let n=await G.getState().createSession(void 0,e.path);if(!n)throw await pt(c,e,{deleteLocalBranch:!0}).catch(()=>void 0),Error(`Could not create a session for the worktree.`);return await yn(n.id,t,c),{id:n.id,branch:e.branch||o,path:e.path}}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree session`;return q.error(`Failed to create worktree`,{description:t}),null}}finally{_n=!1}}function Tn(e){let t=(0,Z.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,style:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a={color:`var(--surface-elevated-foreground)`,...i},t[4]=i,t[5]=a);let o;t[6]===n?o=t[7]:(o=F(`flex h-full w-full flex-col overflow-hidden rounded-xl`,n),t[6]=n,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Q.jsx)(Ct,{"data-slot":`command`,style:a,className:o,...r}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var En=X.forwardRef((e,t)=>{let n=(0,Z.c)(16),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=(a===void 0?`default`:a)===`mobileGlass`?`yuri-mobile-glass-control rounded-full`:`bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,s;n[4]===o?s=n[5]:(s=F(`flex h-8 items-center gap-2 rounded-lg px-3`,o),n[4]=o,n[5]=s);let c;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(L,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=F(`placeholder:text-muted-foreground flex h-8 w-full bg-transparent typography-meta outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,r),n[7]=r,n[8]=l);let u;n[9]!==i||n[10]!==t||n[11]!==l?(u=(0,Q.jsx)(Ct.Input,{ref:t,"data-slot":`command-input`,className:l,...i}),n[9]=i,n[10]=t,n[11]=l,n[12]=u):u=n[12];let d;return n[13]!==s||n[14]!==u?(d=(0,Q.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{"data-slot":`command-input-field`,className:s,children:[c,u]})}),n[13]=s,n[14]=u,n[15]=d):d=n[15],d});En.displayName=`CommandInput`;function Dn(e){let t=(0,Z.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,scrollbarClassName:o,disableHorizontal:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=F(`scroll-py-1 overflow-x-hidden h-full min-h-0`,r),t[6]=r,t[7]=s);let c=o??`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,l=i??!0,u;return t[8]!==n||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(Ve,{as:Ct.List,"data-slot":`command-list`,outerClassName:`max-h-[min(600px,calc(100vh-10rem))] overflow-x-hidden p-0 w-full h-full min-h-0`,className:s,scrollbarClassName:c,disableHorizontal:l,...a,children:n}),t[8]=n,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function On(e){let t=(0,Z.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Ct.Empty,{"data-slot":`command-empty`,className:`py-6 text-center typography-ui-label`,...n}),t[2]=n,t[3]=r),r}function kn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typography-meta [&_[cmdk-group-heading]]:font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`bg-border -mx-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Separator,{"data-slot":`command-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=F(`data-[selected=true]:bg-interactive-selection data-[selected=true]:text-interactive-selection-foreground data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 typography-meta outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,Z.c)(27),{branches:n,search:r,local:i,currentBranch:a,branchInfo:o,onCheckout:s}=e,{t:c}=ze(),l;if(t[0]!==n||t[1]!==r){let e=r.trim();l=e?N(n,e,Pn).map(Nn):n,t[0]=n,t[1]=r,t[2]=l}else l=t[2];let u=l,d=i?`gitView.branch.localBranches`:`gitView.branch.remoteBranches`,f;t[3]!==c||t[4]!==d?(f=c(d),t[3]=c,t[4]=d,t[5]=f):f=t[5];let p;if(t[6]!==o||t[7]!==a||t[8]!==u||t[9]!==i||t[10]!==s||t[11]!==c){let e;t[13]!==o||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==c?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>s(e),children:[i?(0,Q.jsxs)(`span`,{className:`flex flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),(o?.[e]?.ahead||o?.[e]?.behind)&&(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[o[e].ahead||0,` ahead ·`,` `,o[e].behind||0,` behind`]})]}):(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),i&&a===e&&(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:c(`gitView.branch.currentBadge`)})]},`${i?`local`:`remote`}-${e}`),t[13]=o,t[14]=a,t[15]=i,t[16]=s,t[17]=c,t[18]=e):e=t[18],p=u.map(e),t[6]=o,t[7]=a,t[8]=u,t[9]=i,t[10]=s,t[11]=c,t[12]=p}else p=t[12];let m;t[19]!==u.length||t[20]!==i||t[21]!==c?(m=u.length===0&&(0,Q.jsx)(jn,{disabled:!0,className:`justify-center`,children:(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(i?`gitView.branch.noLocalBranches`:`gitView.branch.noRemoteBranches`)})}),t[19]=u.length,t[20]=i,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Q.jsxs)(kn,{heading:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Nn(e){return e.item}function Pn(e){return e}function Fn(e){let t=(0,Z.c)(9),{options:n,selectedDirectory:r,onSelect:i}=e,{t:a}=ze(),o;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>i(e.value),children:[(0,Q.jsxs)(`span`,{className:`truncate typography-ui-label text-foreground`,children:[e.pending?`⏳ `:``,e.label]}),r===e.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:a(`gitView.branch.currentBadge`)}):null]},`worktree-${e.value}`),t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else o=t[4];return o}var In=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ln=({currentBranch:e,localBranches:t,remoteBranches:n,branchInfo:r,onCheckout:i,onCreate:a,remotes:o=[],disabled:s=!1,iconOnly:c=!1,trigger:l,triggerLabel:u,contentAlign:d,hideTooltip:f=!1,projectRootOption:p=null,worktreeOptions:m=[],selectedDirectory:h=null,onSelectDirectory:g,onCreateWorktree:_,worktreesLabel:v,worktreeNewLabel:y,projectRootLabel:b,onOpenChange:x,open:S,presentation:C=`dropdown`})=>{let{t:w}=ze(),[T,E]=X.useState(!1),[D,O]=X.useState(``),[k,A]=X.useState(!1),[ee,j]=X.useState(!1),[M,F]=X.useState(``),[I,R]=X.useState(!1),te=X.useRef(null),z=X.useId(),B=S??T,V=e=>{S===void 0&&E(e),x?.(e)},ne=X.useCallback(e=>{e.stopPropagation()},[]),re=o.length>1,ie=!!(g||_),H=X.useMemo(()=>In(M),[M]),U=X.useMemo(()=>{let e=D.trim();return e?N(m,e,e=>e.label).map(e=>e.item):m},[D,m]),ae=X.useMemo(()=>{if(!p)return!1;let e=D.trim();return!e||N([p],e,e=>[e.label,b??``]).length>0},[b,p,D]),oe=t=>{if(t===e){V(!1);return}i(t),V(!1),O(``)},se=e=>{g?.(e),V(!1),O(``)},ce=()=>{A(!0),setTimeout(()=>te.current?.focus(),50)},W=async()=>{if(!(!H||I)){if(re){j(!0);return}R(!0);try{await a(H,o[0]),F(``),A(!1),V(!1)}finally{R(!1)}}},le=async e=>{if(!(!H||I)){R(!0);try{await a(H,e),F(``),A(!1),j(!1),V(!1)}finally{R(!1)}}},ue=()=>{j(!1)},de=()=>{F(``),A(!1),j(!1)};X.useEffect(()=>{B||(O(``),A(!1),j(!1),F(``))},[B]);let fe=u||e||w(`gitView.branch.detachedHead`),pe=d??(c?`end`:`start`),me=v??w(`chat.chatInput.worktrees`),he=y??w(`chat.chatInput.worktreeNew`),ge=b??w(`chat.chatInput.projectRoot`),_e=c?(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,disabled:s,"aria-label":fe,children:(0,Q.jsx)(L,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(P,{variant:`ghost`,size:`xs`,className:`h-6 min-w-0 max-w-full justify-start gap-1 px-0 hover:bg-transparent`,disabled:s,"aria-label":fe,children:[(0,Q.jsx)(L,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate typography-ui-label font-semibold text-left text-foreground`,children:fe}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),ve=(0,Q.jsx)(Ze,{asChild:!0,disabled:s,children:l??_e}),ye=(0,Q.jsxs)(Tn,{className:`h-full min-h-0`,children:[(0,Q.jsx)(`div`,{"data-mobile-sheet-no-dismiss":C===`mobile-sheet`?``:void 0,children:(0,Q.jsx)(En,{placeholder:w(`gitView.branch.searchPlaceholder`),value:D,onValueChange:O,onKeyDown:ne})}),(0,Q.jsxs)(Dn,{scrollbarClassName:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,disableHorizontal:!0,children:[(0,Q.jsx)(On,{children:w(`gitView.branch.empty`)}),(0,Q.jsx)(kn,{children:ee?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:ue,disabled:I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(L,{name:`arrow-left`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[w(`gitView.branch.pushToPrefix`),` `,(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:H}),` `,w(`gitView.branch.pushToSuffix`)]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>le(e),disabled:I,className:`flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[I?(0,Q.jsx)(L,{name:`loader-4`,className:`inline size-3 mr-1.5 animate-spin`}):null,e.name]}),(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground truncate max-w-full`,children:e.pushUrl})]},e.name))})]}):k?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:te,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:M,onChange:e=>F(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{ne(e),e.key===`Enter`?(e.preventDefault(),W()):e.key===`Escape`&&(e.preventDefault(),de())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:W,disabled:!H||I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:I?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:I,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(L,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(L,{name:`add`,className:`size-4`}),(0,Q.jsx)(`span`,{children:w(`gitView.branch.create`)})]})}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:t,search:D,local:!0,currentBranch:e,branchInfo:r,onCheckout:oe}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:D,onCheckout:oe}),ie?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{}),(0,Q.jsxs)(kn,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground typography-meta`,children:me}),_?(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer text-muted-foreground typography-meta hover:text-foreground`,onPointerDown:e=>{e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),V(!1),_()},children:he}):null]}),p&&ae?(0,Q.jsxs)(jn,{onSelect:()=>se(p.value),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ge}),(0,Q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:p.label})]}),h===p.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:w(`gitView.branch.currentBadge`)}):null]}):null,(0,Q.jsx)(Fn,{options:U,selectedDirectory:h,onSelect:se})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>V(!0),"data-popup-open":B?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${z}`,open:B,onOpenChange:V,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:B,onOpenChange:V,children:[f||l?ve:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:ve}),(0,Q.jsx)(Ye,{sideOffset:8,children:c?fe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:pe,className:`w-72 p-0 max-h-[60vh] flex flex-col`,children:ye})]})};function Rn(e){let{localBranches:t,remoteBranches:n,query:r}=e,i=r.trim();if(!i)return{matching:[],otherLocal:t,otherRemote:n};let a=N(t,i,e=>e),o=N(n,i,e=>e),s=new Set(a.map(e=>e.item)),c=new Set(o.map(e=>e.item));return{matching:[...a.map(e=>({label:e.item,value:e.item,source:`local`,score:e.score})),...o.map(e=>({label:e.item,value:`remotes/${e.item}`,source:`remote`,score:e.score}))].sort((e,t)=>e.score===t.score?e.source===t.source?e.label.length===t.label.length?e.label.localeCompare(t.label,void 0,{sensitivity:`accent`}):e.label.length-t.label.length:e.source===`local`?-1:1:e.score-t.score).map(({label:e,value:t,source:n})=>({label:e,value:t,source:n})),otherLocal:t.filter(e=>!s.has(e)),otherRemote:n.filter(e=>!c.has(e))}}function zn(e){let t=O(e),n=(e,n={})=>t.json(`/api/github/${e}`,{query:n}),r=e=>e?{owner:e.owner,repo:e.repo}:{};return{authStatus:()=>n(`auth/status`),issuesList:(e,t)=>n(`issues/list`,{directory:e,page:t?.page,query:t?.query}),prsList:(e,t)=>n(`pulls/list`,{directory:e,page:t?.page,query:t?.query}),issueGet:(e,t,i)=>n(`issues/get`,{directory:e,number:t,...r(i?.sourceRepo)}),issueComments:(e,t,i)=>n(`issues/comments`,{directory:e,number:t,...r(i?.sourceRepo)}),prContext:(e,t,i)=>n(`pulls/context`,{directory:e,number:t,...r(i?.sourceRepo),diff:i?.includeDiff?`1`:void 0,checkDetails:i?.includeCheckDetails?`1`:void 0})}}var Bn=e=>({queryKey:[...e.queryScope,`worktree-dialog`,`github-auth`],queryFn:({signal:t})=>O(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=k(),i=e?void 0:r.github,a;n[0]!==e||n[1]!==i?(a=e?zn(e):i,n[0]=e,n[1]=i,n[2]=a):a=n[2];let o=a,s;n[3]!==e||n[4]!==r?(s=e?Bn(e):dt(r.github),n[3]=e,n[4]=r,n[5]=s):s=n[5];let c;n[6]!==t||n[7]!==s?(c={...s,enabled:t},n[6]=t,n[7]=s,n[8]=c):c=n[8];let l=w(c,T),u;return n[9]!==l||n[10]!==o?(u={github:o,auth:l},n[9]=l,n[10]=o,n[11]=u):u=n[11],u}async function Hn(e,t,n={}){let r=await O(e).json(`/api/magic-prompts`);return(typeof r.overrides?.[t]==`string`?r.overrides[t]:it(t)).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]??``:``)}async function Un(e,t,n,r,i,a){let o=zn(t),s=i.issue,c=i.pr;if(!s&&!c)return;let u=s?`issue`:`pr`,d=s?.number??c.number,f=await Hn(t,`github.${u}.review.visible`,{[`${u}_number`]:String(d)}),p=await Hn(t,`github.${u}.review.instructions`),m;if(s){let e=await o.issueGet(t.location.directory,d,{sourceRepo:s.sourceRepo}),n=await o.issueComments(t.location.directory,d,{sourceRepo:s.sourceRepo});if(e.connected===!1||!e.issue||n.connected===!1)throw Error(a);m=`GitHub issue context (JSON)\n${JSON.stringify({repo:e.repo??null,issue:e.issue,comments:n.comments??[]},null,2)}`}else{let e=await o.prContext(t.location.directory,d,{sourceRepo:c.sourceRepo,includeDiff:i.includeDiff,includeCheckDetails:!1});if(e.connected===!1||!e.pr)throw Error(a);m=`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`}t.sdk();let h=e.resolve({...t.location,directory:n});await K(e,h).state.send({sessionID:r,messageID:l(`msg`),text:[f,p,m].join(`
3
-
4
- `)})}function Wn(e){let t=(0,Z.c)(41),{project:n,open:r,onClose:i,children:a}=e,o=D(),s=n?.hostId&&o&&o.entry.location.hubId===n.hubId&&o.entry.location.hostId===n.hostId&&o.entry.location.directory===n.path,c=Le(!!(r&&n?.hostId&&!s)),{t:l}=ze();if(!n?.hostId){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(E.Provider,{value:null,children:a}),t[0]=a,t[1]=e),e}if(s)return a;if(!r)return null;if(!c.registry||c.registry.hubId!==n.hubId){let e;t[2]===i?e=t[3]:(e=e=>{e||i()},t[2]=i,t[3]=e);let n;t[4]===l?n=t[5]:(n=l(`session.newWorktree.title`),t[4]=l,t[5]=n);let r;t[6]===n?r=t[7]:(r=(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:n})}),t[6]=n,t[7]=r);let a=c.isPending?`status`:`alert`,o;t[8]!==c.error?.message||t[9]!==c.isPending||t[10]!==l?(o=c.isPending?l(`remoteProjects.running`):c.error?.message||l(`remoteProjects.host-unavailable`),t[8]=c.error?.message,t[9]=c.isPending,t[10]=l,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,Q.jsx)(`p`,{role:a,children:o}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let u;t[15]===l?u=t[16]:(u=l(`session.newWorktree.actions.cancel`),t[15]=l,t[16]=u);let d;t[17]!==i||t[18]!==u?(d=(0,Q.jsx)(P,{onClick:i,children:u}),t[17]=i,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==c.isPending||t[21]!==l?(f=c.isPending?null:(0,Q.jsx)(P,{onClick:Gn,children:l(`remoteProjects.retry`)}),t[20]=c.isPending,t[21]=l,t[22]=f):f=t[22];let p;t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(We,{children:[d,f]}),t[23]=d,t[24]=f,t[25]=p):p=t[25];let m;t[26]!==p||t[27]!==r||t[28]!==s?(m=(0,Q.jsxs)(Ge,{children:[r,s,p]}),t[26]=p,t[27]=r,t[28]=s,t[29]=m):m=t[29];let h;return t[30]!==e||t[31]!==m?(h=(0,Q.jsx)(qe,{open:!0,onOpenChange:e,children:m}),t[30]=e,t[31]=m,t[32]=h):h=t[32],h}let u;t[33]!==n.hostId||t[34]!==n.hubId||t[35]!==n.path?(u={hubId:n.hubId,hostId:n.hostId,directory:n.path},t[33]=n.hostId,t[34]=n.hubId,t[35]=n.path,t[36]=u):u=t[36];let d;return t[37]!==a||t[38]!==c.registry||t[39]!==u?(d=(0,Q.jsx)(A,{registry:c.registry,location:u,children:a}),t[37]=a,t[38]=c.registry,t[39]=u,t[40]=d):d=t[40],d}function Gn(){Re().catch(Kn)}function Kn(){}var qn=(e,t,n)=>{let r=n??t;return r?e.find(e=>e.id===r)??null:null};function Jn(e,t){return`${e}\0${t}`}function Yn(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=ce(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(Xn,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Xn({open:e,onOpenChange:t,onSelect:n,projectId:r}){let{t:i}=ze(),a=M(e=>e.isMobile),o=D(),s=o?.entry.location.hostId?o.entry:void 0,{git:c}=et(),{github:l,auth:u}=Vn(s,e),d=u.data??null,f=u.isFetched,p=M(e=>e.setSettingsDialogOpen),m=M(e=>e.setSettingsPage),h=ce(e=>qn(e.projects,e.activeProjectId,r)),g=h?.id??null,_=h?.path??null,v=X.useMemo(()=>_&&g?{id:g,path:_,hostId:h?.hostId,hubId:h?.hubId}:null,[g,_,h?.hostId,h?.hubId]),[y,b]=X.useState(`issues`),[x,S]=X.useState(``),[C,w]=X.useState([]),[T,E]=X.useState([]),[O,k]=X.useState(!1),[A,j]=X.useState(!1),[N,I]=X.useState(null),[R,te]=X.useState(null),[z,B]=X.useState(null),[V,ne]=X.useState(!1),[re,ie]=X.useState(new Map),[H,U]=X.useState(1),[ae,oe]=X.useState(!1),se=X.useRef(0),W=ct(x,350),le=ee(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){k(!0),I(null),U(1),oe(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),U(t.page??1),oe(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),U(t.page??1),oe(!!t.hasMore))}}catch(e){I(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{k(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!W.trim()){le();return}let t=new AbortController;k(!0),I(null),U(1),oe(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:W.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:W.trim()}):null;if(!n){k(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),U(e.page??1),oe(!!e.hasMore)):`prs`in e&&(e.connected===!1?(I(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),U(e.page??1),oe(!!e.hasMore))))}).catch(e=>{t.signal.aborted||I(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||k(!1)}),()=>t.abort()},[e,_,l,f,d,y,W,le,i]);let ue=ee(async()=>{if(!(!_||!l)&&!(O||A)&&ae){j(!0);try{let e=H+1;if(y===`issues`&&l.issuesList){let t=W.trim()?await l.issuesList(_,{page:e,query:W.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),U(t.page??e),oe(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=W.trim()?await l.prsList(_,{page:e,query:W.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),U(t.page??e),oe(!!t.hasMore))}}catch{}finally{j(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),te(null),B(null),ne(!1),I(null),ie(new Map),U(1),oe(!1);return}le()},[e,le]),X.useEffect(()=>{se.current+=1,ie(new Map)},[_,v]);let de=ee(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(re.has(t))return;let n=se.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==se.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ie(e=>new Map(e).set(t,{isValid:!o,error:o?i(o.code===`branch_exists`?`session.githubIntegration.validation.branchAlreadyExists`:`session.githubIntegration.validation.branchAlreadyCheckedOut`):null}))}catch{if(n!==se.current)return;ie(e=>new Map(e).set(t,{isValid:!1,error:i(`session.githubIntegration.validation.failed`)}))}});X.useEffect(()=>{!e||y!==`prs`||T.forEach(e=>{e.head&&de(e.head)})},[e,y,T,_,v,de]);let fe=f&&d?.connected===!0,pe=()=>{if(s){q.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{te(e),B(null)},he=e=>{B(e),te(null)},ge=()=>{R?n({type:`issue`,item:R}):z&&n({type:`pr`,item:z,includeDiff:V}),t(!1)},_e=()=>{te(null),B(null),ne(!1)},ve=R||(z?.head&&_?re.get(Jn(_,z.head))?.isValid!==!1:!1),ye=e=>!e.head||(_?re.get(Jn(_,e.head)):void 0)?.isValid===!1,be=(0,Q.jsxs)(Q.Fragment,{children:[s&&u.error?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-small text-destructive`,children:[u.error.message,(0,Q.jsx)(P,{variant:`ghost`,size:`xs`,onClick:()=>{u.refetch()},children:i(`remoteProjects.retry`)})]}):null,fe?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,Q.jsx)(L,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(st,{value:x,onChange:e=>S(e.target.value),placeholder:i(y===`issues`?`session.githubIntegration.search.issuesPlaceholder`:`session.githubIntegration.search.prsPlaceholder`),className:`h-8 pl-9`})]}),(0,Q.jsx)(`div`,{className:`yuri-picker-list mt-2 h-[300px] overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[O&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),N&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive`,children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:N})]})}),!O&&!N&&y===`issues`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[C.length>0?C.map(e=>(0,Q.jsx)(`button`,{onClick:()=>me(e),className:F(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,R?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-2`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noIssuesFound`)}),ae&&!A&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),A&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!O&&!N&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ye(e),n=e.head&&_?re.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:F(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,z?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:t?`opacity-50 cursor-not-allowed`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-1`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[e.head,` → `,e.base]}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null,t&&n?.error&&(0,Q.jsx)(`span`,{className:`typography-micro text-destructive`,children:n.error})]})]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noPullRequestsFound`)}),ae&&!A&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),A&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(L,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 gap-4`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-12 w-12 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:i(`session.githubIntegration.connect.title`)}),(0,Q.jsx)(`p`,{className:`typography-small text-muted-foreground mt-1`,children:i(`session.githubIntegration.connect.description`)})]}),(0,Q.jsx)(P,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),xe=(0,Q.jsxs)(`div`,{className:F(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:F(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(R||z)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate max-w-[150px]`,children:R?i(`session.githubIntegration.selected.issueNumber`,{number:R.number}):i(`session.githubIntegration.selected.prNumber`,{number:z?.number??``})}),(0,Q.jsx)(`button`,{onClick:_e,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&z&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:V,onChange:e=>ne(e),ariaLabel:i(`session.githubIntegration.includeDiffAria`)}),(0,Q.jsx)(`span`,{className:`typography-small text-foreground`,children:i(`session.githubIntegration.includeDiff`)})]})]}),(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:F(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(P,{size:`sm`,onClick:ge,disabled:!ve,className:F(a&&`flex-1`),children:i(`session.githubIntegration.actions.select`)})]})]});return(0,Q.jsx)(Q.Fragment,{children:a?(0,Q.jsx)(ut,{open:e,title:i(`session.githubIntegration.title`),onClose:()=>t(!1),footer:fe?xe:void 0,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 border-b border-border/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:i(`session.githubIntegration.title`)}),e]}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(L,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(R||z)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate flex-1`,children:R?i(`session.githubIntegration.selected.issueNumber`,{number:R.number}):i(`session.githubIntegration.selected.prNumber`,{number:z?.number??``})}),(0,Q.jsx)(`button`,{onClick:_e,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:be}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{presentation:`picker`,children:[(0,Q.jsx)(Ue,{className:`yuri-picker-header`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Q.jsx)(Ke,{className:`yuri-picker-title`,children:i(`session.githubIntegration.title`)}),(0,Q.jsx)(`div`,{className:`w-[220px]`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(L,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),be,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:xe})]})})})}var Zn=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),$=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``).split(`/`).join(`-`).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80),Qn=e=>String(e||``).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`pr-head`,$n=(e,t,n)=>{let r=Zn(e.head||``);if(!r)throw Error(`PR head branch is missing`);if(t.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};let i=n.find(e=>{let t=e.indexOf(`/`);return t<=0||t>=e.length-1?!1:e.slice(t+1)===r});if(i){let e=i.indexOf(`/`),t=i.slice(0,e);return{existingBranch:`remotes/${i}`,setUpstream:!0,upstreamRemote:t,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${t}/${r}`}}let a=String(e.headLabel||``).split(`:`)[0]?.trim(),o=`pr-${Qn(e.headRepo?.owner||a||`pr-head`)}`,s=e.headRepo?.sshUrl||e.headRepo?.cloneUrl||``;if(!s)throw Error(`PR head repository URL is unavailable`);return{existingBranch:`remotes/${o}/${r}`,setUpstream:!0,upstreamRemote:o,upstreamBranch:r,ensureRemoteName:o,ensureRemoteUrl:s,sourceLabel:`${o}/${r}`}},er=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`},tr=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function nr(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=ce(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(rr,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function rr({open:e,onOpenChange:t,onWorktreeCreated:n,projectId:r}){let{t:i}=ze(),{git:a}=et(),o=D(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=M(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=ce(e=>qn(e.projects,e.activeProjectId,r)),h=m?.path??null,g=X.useMemo(()=>h&&m?{id:m.id,path:h,hostId:m.hostId,hubId:m.hubId}:null,[m,h]),[_,v]=X.useState(`new-branch`),[y,b]=X.useState({branchName:``,worktreeName:``,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,S]=X.useState({selectedBranch:``,worktreeName:``}),C=ot(h),E=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),O=at(e=>e.fetchBranches),k=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),A=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),ee=G(e=>e.availableWorktreesByProject),j=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},T),N=X.useMemo(()=>{if(!h)return new Set;let e=s?j.data??[]:ee.get(h)??[];return new Set(e.map(e=>e.name))},[ee,h,s,j.data]),I=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!N.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[N]),[R,te]=X.useState(!1),[z,B]=X.useState(!1),[V,ne]=X.useState(!1),[ie,ae]=X.useState(!1),[W,ue]=X.useState(!1),[de,fe]=X.useState(``),[pe,me]=X.useState(``),ge=X.useRef(null),_e=X.useRef(null),ve=X.useRef(null),ye=X.useRef(null),be=X.useCallback(e=>{e.stopPropagation()},[]),xe=X.useCallback(e=>{let t=e;for(;t&&t!==document.body;){let{overflowY:e}=window.getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null},[]),Se=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),Ce=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;Se(t)},[Se]),we=X.useCallback(e=>{let t=xe(e.current);Se(t)},[xe,Se]),Te=X.useMemo(()=>Rn({localBranches:k,remoteBranches:A,query:de}),[k,A,de]),Ee=X.useMemo(()=>Rn({localBranches:k,remoteBranches:A,query:pe}),[k,A,pe]),De=de.trim().length>0,Oe=pe.trim().length>0,ke=Te.matching.length>0,Ae=Ee.matching.length>0,je=!!(h&&a),Me=X.useCallback(()=>{!h||!a||O(h,a)},[h,a,O]);X.useEffect(()=>{!e||!h||!a||C?.all||O(h,a)},[e,h,a,C?.all,O]),X.useEffect(()=>{!z&&!ie&&fe(``)},[z,ie]),X.useEffect(()=>{!V&&!W&&me(``)},[V,W]),X.useEffect(()=>{z&&Ce(ge),ie&&we(ve)},[z,ie,de,Ce,we]),X.useEffect(()=>{V&&Ce(_e),W&&we(ye)},[V,W,pe,Ce,we]);let[K,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Y,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=H.getState(),t=e.getVisibleAgents();if(e.settingsDefaultAgent){let n=t.find(t=>t.name===e.settingsDefaultAgent);if(n)return n.name}return t.find(e=>e.name===`build`)?.name||t[0]?.name},[]),Be=X.useCallback(()=>{let e=H.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=le(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=H.getState(),r=le(n.settingsDefaultModel??n.opencodeDefaultModel),i=r?.providerId===e&&r.modelId===t?r.variant??n.settingsDefaultVariant:void 0,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0;return i??a},[]),Ye=X.useCallback(async e=>{if(!h||!c)return;let t=H.getState(),n=oe.getState().lastUsedProvider,r=Be(),a=r?.providerID||t.currentProviderId||n?.providerID,o=r?.modelID||t.currentModelId||n?.modelID,s=Re()||t.currentAgentName||void 0;if(!a||!o){q.error(i(`session.newWorktree.error.noModelSelected`));return}let l=Je(a,o);if(e.issue){if(!c.issueGet||!c.issueComments)return;let t=await c.issueGet(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(t.connected===!1||!t.repo||!t.issue)throw Error(`Failed to load issue context`);let n=await c.issueComments(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(n.connected===!1)throw Error(`Failed to load issue comments`);let r=await tt(`github.issue.review.visible`,{issue_number:String(e.issue.number)}),u=await tt(`github.issue.review.instructions`),d=er({repo:t.repo,issue:t.issue,comments:n.comments??[]});await G.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),q.success(i(`session.newWorktree.toast.sessionFromIssue`));return}if(e.pr){if(!c.prContext)return;let t=await c.prContext(h,e.pr.number,{sourceRepo:e.pr.sourceRepo??null,includeDiff:e.includeDiff,includeCheckDetails:!1});if(t.connected===!1||!t.repo||!t.pr)throw Error(`Failed to load PR context`);let n=await tt(`github.pr.review.visible`,{pr_number:String(e.pr.number)}),r=await tt(`github.pr.review.instructions`),u=tr(t);await G.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),q.success(i(`session.newWorktree.toast.sessionFromPr`))}},[c,h,Re,Be,Je,i]),Xe=_===`new-branch`?y:x;X.useEffect(()=>{if(!e||!C?.all||!h||y.sourceBranch)return;let t=y.sourceBranch,n=!1;return(async()=>{try{let e=s?(await a.getGitStatus(h)).current:await mt(h).catch(()=>null);if(n)return;let r=localStorage.getItem(xt),{sourceBranch:i,shouldClearSavedSourceBranch:o}=vt({branches:C.all,savedSourceBranch:r,rootBranch:e});if(o&&localStorage.removeItem(xt),n||t)return;i&&b(e=>({...e,sourceBranch:i}))}catch{}})(),()=>{n=!0}},[e,C?.all,h,y.sourceBranch,s,a]),X.useLayoutEffect(()=>{if(!e)return;v(`new-branch`),S({selectedBranch:``,worktreeName:``}),B(!1),ne(!1),ae(!1),ue(!1),fe(``),me(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=I();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,I]),X.useEffect(()=>{if(_!==`new-branch`||!y.isSyncingWorktreeName)return;let e=$(Zn(y.branchName));b(t=>({...t,worktreeName:e}))},[_,y.branchName,y.isSyncingWorktreeName]);let nt=X.useCallback(async()=>{if(!g||!K.touched||Y)return;Ie&&Ie.abort();let e=new AbortController;Le(e),J(e=>({...e,isValidating:!0}));try{let t=_===`new-branch`?y.branchName:x.selectedBranch,n=Xe.worktreeName,r=Zn(t),o=$(n),c=null,l=null;if(r||(c=i(`session.newWorktree.error.branchNameRequired`)),o||(l=i(`session.newWorktree.error.worktreeDirectoryRequired`)),r&&o){let t=_===`new-branch`?y.linkedPr:null,n=t?$n(t,k,A):null,i={mode:_===`existing-branch`||n?`existing`:`new`,branchName:r,worktreeName:o,existingBranch:n?.existingBranch??(_===`existing-branch`?r:void 0),...n?.ensureRemoteName?{ensureRemoteName:n.ensureRemoteName}:{},...n?.ensureRemoteUrl?{ensureRemoteUrl:n.ensureRemoteUrl}:{}},u=s?await a.validateGitWorktree(h,i):await ft(g,i);if(e.signal.aborted)return;u.ok||u.errors.forEach(e=>{if(e.code===`worktree_exists`){l??=e.message;return}e.code.startsWith(`branch_`)&&(c??=e.message)})}e.signal.aborted||J(e=>({...e,isValidating:!1,branchError:c,worktreeError:l}))}catch{e.signal.aborted||J(e=>({...e,isValidating:!1}))}},[s,a,h,g,_,y.branchName,y.linkedPr,x.selectedBranch,Xe.worktreeName,k,A,K.touched,Ie,Y,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!K.touched||Y)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,K.touched,Y]);let it=async()=>{if(!g||!h){q.error(i(`session.newWorktree.error.noActiveProject`));return}J(e=>({...e,touched:!0}));let e=_===`new-branch`?y.branchName:x.selectedBranch,r=Xe.worktreeName,a=Zn(e),c=$(r);if(!a){q.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){q.error(i(`session.newWorktree.error.worktreeDirectoryRequired`));return}Ie&&(Ie.abort(),Le(null)),J(e=>({...e,isValidating:!1,branchError:null,worktreeError:null})),Fe(!0);try{let e=_===`new-branch`?y.linkedPr:null,r=_===`new-branch`?y.linkedIssue:null,l=_===`new-branch`?y.linkedPr:null,u=_===`new-branch`&&y.includePrDiff,d=!!(r||l);if(s&&o&&m?.hostId){let l=m;ce.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,k,A):null,p=r?`#${r.number} ${r.title}`.trim():e?`#${e.number} ${e.title}`.trim():void 0,h=await un(l,{mode:f||_===`existing-branch`?`existing`:`new`,worktreeName:c,branchName:_===`new-branch`?a:void 0,existingBranch:f?.existingBranch??(_===`existing-branch`?a:void 0),..._===`new-branch`&&!f&&y.sourceBranch?{startRef:y.sourceBranch}:{},...f?{setUpstream:f.setUpstream,upstreamRemote:f.upstreamRemote,upstreamBranch:f.upstreamBranch,...f.ensureRemoteName?{ensureRemoteName:f.ensureRemoteName}:{},...f.ensureRemoteUrl?{ensureRemoteUrl:f.ensureRemoteUrl}:{}}:{}},{title:p,createSession:d,kind:e?`pr`:`standard`,createdFromBranch:f?.sourceLabel??y.sourceBranch,isSelected:()=>ce.getState().activeProjectId===l.id});s.sdk();let g=U.getState().remoteSession;g?.projectId===l.id&&g.location.hubId===s.location.hubId&&g.location.hostId===s.location.hostId&&g.location.directory===h.path&&g.sessionId===(h.id??null)&&n?.(h.path,{...h.id?{sessionId:h.id}:{},remote:!0}),t(!1),q.success(i(`session.newWorktree.toast.worktreeCreated`)),h.id&&d&&Un(o.registry,s,h.path,h.id,{issue:r,pr:e,includeDiff:u},i(`session.newWorktree.error.sendGitHubContextFailed`)).catch(e=>{q.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([se(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,k,A);return b=t.sourceLabel,{preferredName:a||c,mode:`existing`,branchName:a,worktreeName:c,existingBranch:t.existingBranch,setupCommands:f,setUpstream:t.setUpstream,upstreamRemote:t.upstreamRemote,upstreamBranch:t.upstreamBranch,returnAfterDirectoryCreated:!0,...t.ensureRemoteName?{ensureRemoteName:t.ensureRemoteName}:{},...t.ensureRemoteUrl?{ensureRemoteUrl:t.ensureRemoteUrl}:{}}}return b=_===`new-branch`?v:``,{preferredName:a||c,mode:_===`existing-branch`?`existing`:`new`,branchName:_===`existing-branch`?void 0:a,worktreeName:c,existingBranch:_===`existing-branch`?a:void 0,setupCommands:f,returnAfterDirectoryCreated:!0,...v&&_===`new-branch`?{startRef:v}:{}}})(),C=await yt(h,S,{resolvedRootTrackingRemote:p}),w=await ht(g,C),T=null;if(d){await he(g)&&await Ne(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await re(e,w.path,null);if(!a?.id)throw Error(`Failed to create session`);T=a.id,n?.(w.path,{sessionId:T}),t(!1),Fe(!1),Pe(a.id,e).catch(()=>void 0);try{G.getState().initializeNewYuriSession(a.id,H.getState().agents)}catch{}}else t(!1),Fe(!1);let E=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});E&&localStorage.setItem(xt,E),q.success(i(`session.newWorktree.toast.worktreeCreated`),{description:i(`session.newWorktree.toast.worktreeCreatedDescription`,{target:`${w.branch||w.name}${b?` ${i(`session.newWorktree.fromSource`,{source:b})}`:``}`})}),T?Ye({sessionId:T,directory:w.path,issue:r,pr:l,includeDiff:u}).catch(e=>{let t=e instanceof Error?e.message:i(`session.newWorktree.error.sendGitHubContextFailed`);q.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:t})}):n?.(w.path)}catch(e){let t=e instanceof Error?e.message:i(`session.newWorktree.error.createWorktreeFailed`);q.error(i(`session.newWorktree.error.createWorktreeFailed`),{description:t})}finally{Fe(!1)}},ct=e=>{v(e),J(e=>({...e,touched:!1,branchError:null,worktreeError:null}))},lt=e=>{if(!e){b(e=>({...e,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:``}));return}if(e.type===`issue`){let t=e.item,n=`issue-${t.number}-${cn()}`;b(e=>({...e,linkedIssue:t,linkedPr:null,includePrDiff:!1,branchName:n,worktreeName:$(n),isSyncingWorktreeName:!0}))}else if(e.type===`pr`){let t=e.item;b(n=>({...n,linkedPr:t,linkedIssue:null,includePrDiff:e.includeDiff??!1,branchName:t.head,worktreeName:$(t.head),isSyncingWorktreeName:!0}))}},dt=p&&f?.connected===!0,pt=(_===`existing-branch`?!!x.selectedBranch&&!!x.worktreeName&&!K.branchError&&!K.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!K.branchError&&!K.worktreeError)&&!Y,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(j.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(j.error||l.error)?.message,(0,Q.jsx)(P,{size:`xs`,variant:`ghost`,onClick:()=>{j.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:F(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:K.touched&&(K.branchError||K.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:K.branchError||K.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:F(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Y,className:F(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(P,{size:`sm`,onClick:it,disabled:!pt||Y,className:F(`gap-1.5`,u&&`flex-1`),children:[Y&&(0,Q.jsx)(L,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Y?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(He,{id:`new-worktree-sheet-${d}`,open:e,onOpenChange:t,title:(0,Q.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`session.newWorktree.title`)}),ariaLabel:i(`session.newWorktree.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`overscroll-contain px-4 pb-4 pt-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mb-4`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(L,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>ae(!0),className:`flex-1 justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:x.selectedBranch?`text-foreground`:`text-muted-foreground`,children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(L,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Me,disabled:!je||E,title:i(`session.newWorktree.fetchBranches`),children:E?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:ie,title:i(`session.newWorktree.selectBranch`),onClose:()=>ae(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ve,children:[(0,Q.jsx)(st,{value:de,onChange:e=>fe(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),E?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[De&&ke&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Te.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),ae(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),De&&!ke&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Te.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(De?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Te.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),ae(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Te.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(De?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Te.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),ae(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>te(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(L,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:F(`h-8`,K.touched&&K.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:F(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(L,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:F(`h-8`,K.touched&&K.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>ue(!0),className:`w-full justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:y.sourceBranch?`text-foreground`:`text-muted-foreground`,children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(L,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})}),(0,Q.jsx)(ut,{open:W,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>ue(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ye,children:[(0,Q.jsx)(st,{value:pe,onChange:e=>me(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),E?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Oe&&Ae&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ee.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),ue(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Oe&&!Ae&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ee.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Oe?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ee.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),ue(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Ee.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Oe?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ee.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ue(!1)},className:F(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(L,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-3 pt-2`,children:Ct})]})}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{className:`max-w-lg max-h-[80vh] flex flex-col`,children:[(0,Q.jsx)(Ue,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Ke,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(L,{name:`git-branch`,className:`h-5 w-5`}),i(`session.newWorktree.title`)]}),(0,Q.jsx)(`div`,{className:`w-[280px] shrink-0`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(L,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(L,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto mt-2 space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)($e,{open:z,onOpenChange:B,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:F(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,sideOffset:6,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:ge,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:de,onValueChange:fe,onKeyDown:be}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:E?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[De&&ke&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Te.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),De&&!ke&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Te.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[De&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(De?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Te.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Te.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Te.otherLocal.length>0||De)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(De?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Te.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),B(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(P,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Me,disabled:!je||E,title:i(`session.newWorktree.fetchBranches`),children:E?(0,Q.jsx)(L,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(L,{name:`refresh`,className:`size-4`})})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,onClick:()=>te(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(L,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:F(`h-8`,K.touched&&K.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(L,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:F(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(L,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:F(`h-8`,K.touched&&K.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)($e,{open:V,onOpenChange:ne,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(P,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:F(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(L,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:_e,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:pe,onValueChange:me,onKeyDown:be}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:E?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):k.length===0&&A.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Oe&&Ae&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ee.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ne(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Oe&&!Ae&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ee.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Oe&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Oe?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ee.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ne(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ee.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ee.otherLocal.length>0||Oe)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Oe?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ee.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ne(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(L,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(L,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(L,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]}),(0,Q.jsxs)(We,{className:`mt-1 flex items-center justify-between`,children:[St,(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 text-destructive`,children:K.touched&&(K.branchError||K.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(L,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:K.branchError||K.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(P,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Y,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(P,{size:`sm`,onClick:it,disabled:!pt||Y,className:`gap-1.5`,children:[Y&&(0,Q.jsx)(L,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Y?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:R,onOpenChange:te,onSelect:lt})]})}var ir=null,ar=new Set,or=()=>{for(let e of ar)e()},sr=e=>e===`chat`||e===`assistant`,cr=()=>ir,lr=e=>{ir!==e&&(ir=e,or())},ur=e=>{ir&&(e&&ir.surfaceID!==e||(ir=null,or()))},dr=(e,t)=>{if(e.transportIdentity!==t.transportIdentity||e.runtimeGeneration!==t.runtimeGeneration)throw Error(`chat-input-delivery-runtime-stale`)},fr=e=>{let t=e.options?.delivery===`steer`?`steer`:e.options?.delivery===`queue`?`queue`:void 0,n={...t?{delivery:t}:{},...e.options?.commitStagedMessageEdit===void 0?{}:{commitStagedMessageEdit:e.options.commitStagedMessageEdit},...e.options?.messageID?{messageID:e.options.messageID}:{},...e.options?.ticket?{ticket:e.options.ticket}:{}},r=e.options?.sessionId??e.sessionID??void 0;if(!r)return n;let i=e.options?.directoryHint===void 0?e.directory||null:e.options.directoryHint;return{...n,sessionId:r,directoryHint:i}},pr=(e,t,n={})=>({operation:t,surfaceID:e.surfaceID,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration,sessionID:e.sessionID,directory:e.directory??``,draftKey:e.draftKey,deliveryTarget:e.deliveryTarget,...n}),mr=e=>{if(!e.active||!e.draftKey||!e.directory)return null;let t=e.activity?.phase??`idle`,n=e.activity?.canAbort??(t===`busy`||t===`retry`);return{send:async t=>{let n=pr(e,`send`,t);return await e.selection.flush(),e.kind===`secondary`&&await e.shortcuts.submit(),e.backend.send(n)},sendQueued:async(t,n={})=>{let{manual:r,...i}=n,a=pr(e,`send`,i),o=Qt(e);if(await e.selection.flush(),!o)throw Error(`chat-input-queue-scope-incomplete`);return e.backend.sendQueued({...a,queueItemID:t,manual:r,queueScope:o})},create:async()=>{let t=pr(e,`create`);return await e.selection.flush(),e.backend.create(t)},compact:async t=>{let n=pr(e,`compact`,t);return await e.selection.flush(),e.backend.compact(n)},abort:async()=>{let t=pr(e,`abort`);return await e.selection.flush(),e.backend.abort(t)},queueScope:Qt(e),canAbort:n,canQueue:t===`busy`||t===`retry`,allowsCommand:t=>Gt(e,{name:t,source:`yuri`}),shortcut:async(t,n=1)=>{if(e.kind===`secondary`){t===`cycle`?await e.shortcuts.cycle(n):t===`new`?await e.shortcuts.new():t===`abort`?await e.shortcuts.abort():await e.shortcuts.submit();return}if(t===`abort`){let t=pr(e,`abort`);await e.selection.flush(),await e.backend.abort(t);return}if(t===`new`){let t=pr(e,`create`);await e.selection.flush(),await e.backend.create(t);return}t!==`submit`&&await e.shortcuts?.cycle(n)},resources:e.resources??null}},hr=e=>e.type===`tool`&&e.metadata?.providerExecuted===!0,gr=e=>{if(e.type!==`tool`)return!1;let t=e.state;return t?.status===`error`&&t.metadata?.interrupted===!0},_r=e=>e.type!==`tool`||hr(e)?!1:!gr(e),vr=e=>{let t=0;for(let n of e)_r(n)&&(t+=1);return t},yr=(e,t)=>e===`stop`&&vr(t)===0,br=e=>{if(e.type!==`text`||e.synthetic===!0)return!1;let t=e.text;return typeof t==`string`&&Tt(t)},xr=e=>{if(vr(e)!==0)return-1;for(let t=e.length-1;t>=0;--t){let n=e[t];if(br(n))return t;if(n.type===`tool`||n.type===`reasoning`||n.type===`file`||n.type===`agent`||n.type===`subtask`)break}return-1},Sr=(e,t,n)=>{if(n||!yr(e,t))return!1;for(let e of t)if(br(e))return!0;return!1},Cr=e=>e===`streaming`||e===`cooldown`,wr=e=>e.parts.some(br),Tr=e=>Cr(e.streamPhase)?wr(e):!1,Er=e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``},Dr=e=>{let t=e?.type;return t===`compaction`?!_(e):t===`text`&&Er(e).trim()===`/compact`},Or=e=>e?e.some(e=>Dr(e)):!1,kr=e=>Or(e.parts),Ar=e=>e?Or(e.sourceParts)||Or(e.parts):!1,jr=e=>{if(!kr(e))return e;let t=!1,n=e.parts.map(e=>e?.type!==`compaction`||_(e)?e:(t=!0,{type:`text`,text:`/compact`})),r=e.info.clientRole!==`user`;return!t&&!r?e:{...e,info:r?{...e.info,clientRole:`user`}:e.info,parts:t?n:e.parts}},Mr=e=>{let t=Et(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},Nr=new WeakMap,Pr=e=>{let t=Nr.get(e);if(t)return t;let n=jr(Mr(e)),r=n.parts,i=fe(r),a=i===r?n:{...n,parts:i,sourceParts:r};return Nr.set(e,a),a},Fr={activity:`idle`,hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:null,turnStartedAt:void 0},Ir=[],Lr=`\0`,Rr=new Set([`edit`,`write`,`apply_patch`]),zr={read:`chat.assistantStatus.readingFile`,write:`chat.assistantStatus.writingFile`,edit:`chat.assistantStatus.editingFile`,apply_patch:`chat.assistantStatus.applyingPatch`,bash:`chat.assistantStatus.runningCommand`,grep:`chat.assistantStatus.searchingContent`,glob:`chat.assistantStatus.findingFiles`,list:`chat.assistantStatus.listingDirectory`,task:`chat.assistantStatus.delegatingTask`,webfetch:`chat.assistantStatus.fetchingUrl`,websearch:`chat.assistantStatus.searchingWeb`,codesearch:`chat.assistantStatus.webCodeSearch`,todowrite:`chat.assistantStatus.updatingTodos`,todoread:`chat.assistantStatus.readingTodos`,skill:`chat.assistantStatus.learningSkill`,question:`chat.assistantStatus.askingQuestion`,execute:`chat.assistantStatus.executing`,session_rename:`chat.assistantStatus.renamingSession`,session_move:`chat.assistantStatus.movingSession`,browser:`chat.assistantStatus.usingBrowser`},Br=[`chat.assistantStatus.working`,`chat.assistantStatus.processing`,`chat.assistantStatus.preparing`,`chat.assistantStatus.warmingUp`,`chat.assistantStatus.gearsTurning`,`chat.assistantStatus.computing`,`chat.assistantStatus.calculating`,`chat.assistantStatus.analyzing`,`chat.assistantStatus.wheelsSpinning`,`chat.assistantStatus.calibrating`,`chat.assistantStatus.synthesizing`,`chat.assistantStatus.connectingDots`,`chat.assistantStatus.inspectingLogic`,`chat.assistantStatus.weighingOptions`],Vr=(e,t)=>{let n=zr[Be(e)];return n?t(n):t(`chat.assistantStatus.usingTool`,{tool:e})},Hr=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},Ur=(e,t)=>t(Br[Hr(e)%Br.length]??`chat.assistantStatus.working`),Wr=(e,t,n)=>{let r,i;if(!V(e))for(let t=e.length-1;t>=0;--t){let n=e[t];if(n)switch(n.type){case`reasoning`:{let e=n.time??Xr(n);(!e||e.end===void 0)&&!r&&(r=`reasoning`);break}case`tool`:{let e=n.state?.status;if((e===`running`||e===`pending`)&&!r){let e=Be(Zr(n));Rr.has(e)?(r=`editing`,i=e):(r=`tool`,i=e)}break}case`text`:{let e=Yr(n)??``;if(typeof e==`string`&&e.trim().length>0){let e=Xr(n);(!e||e.end===void 0)&&!r&&(r=`text`)}break}}}let a=r===void 0,o=r===`editing`?n(`chat.assistantStatus.editingFile`):r===`tool`&&i?Vr(i,n):r===`reasoning`?n(`chat.assistantStatus.thinking`):r===`text`?n(`chat.assistantStatus.composing`):Ur(t,n);return{activePartType:r,activeToolName:i,statusText:o,isGenericStatus:a}},Gr=e=>[e.activePartType??``,e.activeToolName??``,e.statusText,e.isGenericStatus?`1`:`0`].join(Lr),Kr=e=>{let[t,n,r=`working`,i]=e.split(Lr);return{activePartType:t===`text`||t===`tool`||t===`reasoning`||t===`editing`?t:void 0,activeToolName:n||void 0,statusText:r,isGenericStatus:i===`1`}},qr=e=>e.type===`reasoning`,Jr=e=>e.type===`text`,Yr=e=>{if(Jr(e))return e.text;let t=e;if(typeof t.text==`string`)return t.text;if(typeof t.content==`string`)return t.content;if(typeof t.value==`string`)return t.value},Xr=e=>(Jr(e)||qr(e),e.time),Zr=e=>{if(e.tool)return e.tool;let t=e;return typeof t.name==`string`?t.name:`tool`};function Qr(e,t){let{t:n}=ze(),r=G(e=>e.currentSessionId),i=G(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=pe(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=G(c),u=Ae(a??``,o??void 0),d=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`assistant`)return{id:t.id,index:e,finish:t.finish,error:t.error,isCompaction:t.clientRole===`compaction`,startedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,finish:void 0,error:void 0,isCompaction:!1,startedAt:void 0}},[u]),f=d.id,p=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`user`&&!x(t))return{id:t.id,index:e,turnStartedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,turnStartedAt:void 0}},[u]),m=p.id,h=Se(f??``,o??void 0,a??void 0),g=Se(m??``,o??void 0,a??void 0),_=!!m&&Or(g),v=d.isCompaction&&d.index>p.index?h.find(e=>e.type===`compaction`):void 0,y=v?.reason===`manual`?d.startedAt:p.turnStartedAt,b=!!(f&&d.index>p.index&&(v?v.status===`failed`||v.reason===`manual`&&v.status===`completed`:Sr(d.finish,h,d.error))),S=X.useMemo(()=>{let e=`${a??``}:${f??``}`;return Gr(Wr(f&&!d.error&&d.index>p.index?h:Ir,e,n))},[a,f,d.error,d.index,p.index,h,n]),C=Ce(a??``,o??void 0),w=Me(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),E=G(T),{phase:D,isWorking:O}=nn(a,o??void 0),k=!!(d.error&&d.index>p.index),A=je(a??``,o??void 0),ee=A?.type===`retry`?A.attempt:void 0,j=A?.type===`retry`?A.next:void 0,M=X.useMemo(()=>Kr(S),[S]),N=X.useMemo(()=>{let e=!!(E&&!E.acknowledged);return{wasAborted:e,abortActive:e}},[E]),P=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:O};if(k&&D!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:O};if(N.wasAborted)return{...Fr,wasAborted:!0,abortActive:N.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(b)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=O,t=D===`busy`,r=D===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(M.activePartType===`tool`||M.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:ee,next:j,message:A?.type===`retry`?A.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(M.activePartType===`tool`||M.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):M.statusText:null,isGenericStatus:!e||!i&&M.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?M.activePartType:void 0,activeToolName:e&&!i?M.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,k,D,O,b,_,v?.status,y,M,N,ee,j,A,n]);return{forming:X.useMemo(()=>({isActive:!s&&!k&&O&&M.activePartType===`text`,characterCount:0}),[s,k,O,M.activePartType]),working:X.useMemo(()=>{if(s||P.wasAborted||P.abortActive)return P;if(l)return{...P,activity:`streaming`,hasWorkingContext:!0,isWorking:!0,isStreaming:!0,isCooldown:!1,lifecyclePhase:`streaming`,statusText:n(`chat.assistantStatus.sendingMessage`),isGenericStatus:!1,isWaitingForPermission:!1,canAbort:!0,activePartType:void 0,activeToolName:void 0,isComplete:!1,isTurnSettled:!1,retryInfo:null};let e=C.length>0,t=w.length>0;return!e&&!t?P:t?{...P,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...P,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,P,l,C,w,n])}}var $r=`--yuri-mobile-header-collapse`,ei=e=>e.closest(`.mobile-chat-screen`)?.querySelector(`:scope > [data-yuri-collapsible-header="true"]`)??null,ti=e=>{e.style.removeProperty($r),delete e.dataset.yuriHeaderCollapsePhase,delete e.dataset.yuriHeaderCollapseRest},ni=(e,t,n)=>{let r=String(t.progress),i=t.phase,a=t.rest===`compact`?`collapsed`:`expanded`;return n?.phase!==i&&(e.dataset.yuriHeaderCollapsePhase=i,i===`snapping`&&n&&n.phase!==`snapping`&&e.offsetWidth),n?.progress!==r&&e.style.setProperty($r,r),n?.rest!==a&&(e.dataset.yuriHeaderCollapseRest=a),{progress:r,phase:i,rest:a}},ri=e=>{let t=e.startsWith(`#`)?e.slice(1):e;if(!t)return null;let n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:`turn`,id:n[1]};let r=t.match(/^message-(.+)$/);return r?.[1]?{kind:`message`,id:r[1]}:null},ii=(e,t,n)=>{if(n===0||e.length===0)return{kind:`noop`};let r=t?e.indexOf(t):e.length-1,i=(r>=0?r:e.length-1)+n;if(i>=e.length)return{kind:`resume`};let a=e[Math.max(0,i)];return a?{kind:`turn`,turnId:a}:{kind:`noop`}},ai=e=>{if(typeof window>`u`)return;let t=e?`#${e}`:``,n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,``,n),e&&window.dispatchEvent(new HashChangeEvent(`hashchange`))},oi=e=>{e&&ai(`message-${e}`)},si=e=>{let t=(0,Z.c)(29),{sessionId:n,turnIds:r,activeTurnId:i,scrollToTurn:a,scrollToMessage:o,resumeToBottom:s}=e,c=X.useRef(r),l=X.useRef(i),u,d;t[0]===r?(u=t[1],d=t[2]):(u=()=>{c.current=r},d=[r],t[0]=r,t[1]=u,t[2]=d),X.useEffect(u,d);let f,p;t[3]===i?(f=t[4],p=t[5]):(f=()=>{l.current=i},p=[i],t[3]=i,t[4]=f,t[5]=p),X.useEffect(f,p);let m;t[6]===a?m=t[7]:(m=async(e,t)=>e?(t?.updateHash!==!1&&ai(`turn-${e}`),a(e,{behavior:t?.behavior})):!1,t[6]=a,t[7]=m);let h=m,g;t[8]===o?g=t[9]:(g=async(e,t)=>e?(t?.updateHash!==!1&&ai(`message-${e}`),o(e,{behavior:t?.behavior})):!1,t[8]=o,t[9]=g);let _=g,v;t[10]!==s||t[11]!==h?(v=async(e,t)=>{let n=c.current,r=ii(n,l.current,e);if(r.kind===`noop`)return e===0;if(r.kind===`resume`){if(t?.resumePastEnd===!1){let e=n[n.length-1];return e?h(e,{behavior:`auto`}):!1}return ai(null),s(),!0}return h(r.turnId,{behavior:`auto`})},t[10]=s,t[11]=h,t[12]=v):v=t[12];let y=v,b;t[13]===s?b=t[14]:(b=()=>{ai(null),s()},t[13]=s,t[14]=b);let x=b,S;t[15]!==_||t[16]!==h||t[17]!==n?(S=()=>{if(!n||typeof window>`u`)return;let e=()=>{let e=ri(window.location.hash);if(e){if(e.kind===`turn`){h(e.id,{behavior:`auto`,updateHash:!1});return}_(e.id,{behavior:`auto`,updateHash:!1})}};return e(),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`hashchange`,e)}},t[15]=_,t[16]=h,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==_||t[20]!==h||t[21]!==n||t[22]!==r.length?(C=[n,_,h,r.length],t[19]=_,t[20]=h,t[21]=n,t[22]=r.length,t[23]=C):C=t[23],X.useEffect(S,C);let w;return t[24]!==x||t[25]!==y||t[26]!==_||t[27]!==h?(w={scrollToTurnId:h,scrollToMessageId:_,scrollByTurnOffset:y,resumeToLatest:x},t[24]=x,t[25]=y,t[26]=_,t[27]=h,t[28]=w):w=t[28],w},ci=[0,200,400],li=e=>{let t=(0,Z.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=F(`inline-flex`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=ci.map(ui),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsxs)(Q.Fragment,{children:[`\xA0`,(0,Q.jsx)(`span`,{className:r,"aria-hidden":`true`,children:i})]}),t[3]=r,t[4]=a),a};function ui(e){return(0,Q.jsx)(`span`,{className:`animate-busy-pulse`,style:{animationDelay:`${e}ms`},children:`.`},e)}export{En as A,Xt as B,sr as C,Tn as D,Ln as E,wn as F,Ut as G,Vt as H,cn as I,qt as J,Yt as K,rn as L,Dn as M,Cn as N,On as O,Sn as P,Ot as Q,an as R,cr as S,nr as T,$t as U,Gt as V,Zt as W,Bt as X,Jt as Y,Dt as Z,Tr as _,ti as a,fr as b,Qr as c,wr as d,vr as f,br as g,yr as h,$r as i,jn as j,kn as k,Pr as l,Sr as m,oi as n,ni as o,xr as p,Ht as q,si as r,ei as s,li as t,Ar as u,dr as v,lr as w,ur as x,mr as y,nn as z};