@yuriai/web 0.3.6-beta.8 → 0.3.6

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 (275) hide show
  1. package/README.md +19 -3
  2. package/bin/install-portable.sh +102 -0
  3. package/bin/install-portable.test.js +112 -0
  4. package/bin/lib/DOCUMENTATION.md +2 -0
  5. package/bin/lib/cli-startup.js +7 -2
  6. package/bin/lib/cli-startup.portable.test.js +30 -0
  7. package/bin/lib/commands-serve.js +4 -1
  8. package/bin/lib/commands-update.js +3 -0
  9. package/bin/lib/commands-update.test.js +18 -0
  10. package/dist/assets/{AgentAvatar-COZrpK6y.js → AgentAvatar-BOvjZ-DI.js} +1 -1
  11. package/dist/assets/{AgentSelector-7iPujobN.js → AgentSelector-Dl_zIOMk.js} +1 -1
  12. package/dist/assets/ArchivedSessionsDialog-Cr9Ji-RY.js +1 -0
  13. package/dist/assets/{AssistantConversationSurface-C6tCgfuc.js → AssistantConversationSurface-CLdjNFeJ.js} +3 -3
  14. package/dist/assets/{AssistantSessionCard-BLKXoc6z.js → AssistantSessionCard-BufyrOfo.js} +2 -2
  15. package/dist/assets/{AssistantUnreadBadge-BSWBtgFe.js → AssistantUnreadBadge-Dn9HAEDr.js} +1 -1
  16. package/dist/assets/{AssistantView-YdmEtDcb.js → AssistantView-Cg0wPomu.js} +1 -1
  17. package/dist/assets/{AssistantWorkingAvatar-Cnl5oL-I.js → AssistantWorkingAvatar-1KNjr2A2.js} +1 -1
  18. package/dist/assets/{AssistantsSettingsPage-CqtitUB4.js → AssistantsSettingsPage-DeYfZAYH.js} +1 -1
  19. package/dist/assets/{BinaryFileFallback-ITV09rfY.js → BinaryFileFallback-DfD02fS_.js} +1 -1
  20. package/dist/assets/{BtwPanel-SwSsRp_l.js → BtwPanel-B_2w8P0X.js} +2 -2
  21. package/dist/assets/BusyDots-CAv4ygIO.js +4 -0
  22. package/dist/assets/{ChatContainer-C_-17prp.js → ChatContainer-Dgv075jT.js} +23 -23
  23. package/dist/assets/ChatView-Cr71C0ZB.js +3 -0
  24. package/dist/assets/{DiagramView-DDMO_6X5.js → DiagramView-CTnpBsWU.js} +1 -1
  25. package/dist/assets/{DiffView-DCQrow3l.js → DiffView-j_yWF1Mz.js} +2 -2
  26. package/dist/assets/{DiffViewToggle-uJM3Jn3y.js → DiffViewToggle-CYusbmY5.js} +1 -1
  27. package/dist/assets/{ErrorBoundary-BFXVt5ct.js → ErrorBoundary-yr_JeVdx.js} +1 -1
  28. package/dist/assets/{FadeInOnReveal-CrbIIB5N.js → FadeInOnReveal-C56koblQ.js} +1 -1
  29. package/dist/assets/{GuiPluginMount-FFI3j0Vq.js → GuiPluginMount-CBJiLdzR.js} +1 -1
  30. package/dist/assets/{GuiPluginPage-B9I2nkDa.js → GuiPluginPage-DJa8gFLk.js} +1 -1
  31. package/dist/assets/{GuiPluginSurface-D_IoxXvc.js → GuiPluginSurface-Cc7q80jp.js} +1 -1
  32. package/dist/assets/{GuiPluginTitlebarItems-C4eqm-dM.js → GuiPluginTitlebarItems-rbK3leaL.js} +1 -1
  33. package/dist/assets/{GuiPluginWindow-BMeBjsJ4.js → GuiPluginWindow-Cpg2HYWe.js} +1 -1
  34. package/dist/assets/{Icon-C1m8PihJ.js → Icon-C1rjS64C.js} +1 -1
  35. package/dist/assets/{ImageLoadingPlaceholder-CJmo4kkb.js → ImageLoadingPlaceholder-2hMqBtYh.js} +1 -1
  36. package/dist/assets/{LoadingImage-956pmYDm.js → LoadingImage-Bs-621ZL.js} +1 -1
  37. package/dist/assets/MarkdownRenderer-BZl_T1ng.js +2 -0
  38. package/dist/assets/{MarkdownRendererImpl-B0BDlD7a.js → MarkdownRendererImpl-DiCCNjDr.js} +3 -3
  39. package/dist/assets/{MarkstreamRendererImpl-CNodTwpI.js → MarkstreamRendererImpl-Bzz3OZlX.js} +2 -2
  40. package/dist/assets/{MobileAssistantSettingsPage-DMLyFaSP.js → MobileAssistantSettingsPage-pBhJR2t6.js} +1 -1
  41. package/dist/assets/{MobileAssistantTab-C8r9diC7.js → MobileAssistantTab-Ceo442NF.js} +1 -1
  42. package/dist/assets/{MobileBtwPage-CoQGTHvz.js → MobileBtwPage-DPPmDMA6.js} +1 -1
  43. package/dist/assets/{MobileChangesSurface-CmZpDOwU.js → MobileChangesSurface-DfDoSkTS.js} +1 -1
  44. package/dist/assets/{MobileChatScreen-Db2VIMuY.js → MobileChatScreen-DHTbrnAr.js} +1 -1
  45. package/dist/assets/{MobileDetailNavigation-DX3hD4c-.js → MobileDetailNavigation-e1u1y59T.js} +1 -1
  46. package/dist/assets/{MobileFilesSurface-BERQLtDW.js → MobileFilesSurface-CJoqR3By.js} +2 -2
  47. package/dist/assets/{MobileHtmlNetworkBoundary-5XyCoKjL.js → MobileHtmlNetworkBoundary-GBhYVYvu.js} +2 -2
  48. package/dist/assets/{MobileOverlayPanel-XkMrn5-W.js → MobileOverlayPanel-DzKTKeZX.js} +1 -1
  49. package/dist/assets/{MobileResizableSheet-CcOOlg4R.js → MobileResizableSheet-CkA7qhco.js} +1 -1
  50. package/dist/assets/{MobileSettingsTab-iRC8w_jI.js → MobileSettingsTab-Bv0HsXFH.js} +1 -1
  51. package/dist/assets/{MobileShareBridge-DSL2iOvl.js → MobileShareBridge-B-co2UPE.js} +1 -1
  52. package/dist/assets/{MobileSurface-CkgVejQ3.js → MobileSurface-D63k27t5.js} +1 -1
  53. package/dist/assets/{MobileTabPageHeader-DDqtoIoS.js → MobileTabPageHeader-FmtbGhwq.js} +1 -1
  54. package/dist/assets/{ModelLogo-DK6xHKii.js → ModelLogo-CMnp5fyy.js} +1 -1
  55. package/dist/assets/{ModelSelector-DMmMUIB2.js → ModelSelector-BF4wYwaz.js} +1 -1
  56. package/dist/assets/{MultiRunWindow-B6jL_lNE.js → MultiRunWindow-D0OU63re.js} +1 -1
  57. package/dist/assets/{OnboardingScreen-BCIOJR5C.js → OnboardingScreen-CDHtDQ0k.js} +1 -1
  58. package/dist/assets/{OverlayScrollbar-CbdvcSXs.js → OverlayScrollbar-m1EAqRES.js} +1 -1
  59. package/dist/assets/{PierreDiffViewer-Dn1NIerc.js → PierreDiffViewer-CZk1tZ3K.js} +1 -1
  60. package/dist/assets/{ProviderLogo-CmOgqmZH.js → ProviderLogo-BqQTME35.js} +1 -1
  61. package/dist/assets/{RemoteAssistantSessionCard-BydwHPmQ.js → RemoteAssistantSessionCard-CrbCVhqD.js} +1 -1
  62. package/dist/assets/{RemoteDesktopPanel-q0HrpV8w.js → RemoteDesktopPanel-BzLmzmjb.js} +1 -1
  63. package/dist/assets/ScheduledTasksDialog-DmtcDZHc.js +3 -0
  64. package/dist/assets/{ScrollableOverlay-DIkp2MKc.js → ScrollableOverlay-CEglrXfm.js} +1 -1
  65. package/dist/assets/{SettingsGroup-YUId7nD5.js → SettingsGroup-Bm-l3IIs.js} +1 -1
  66. package/dist/assets/{SettingsView-DLMfj0mQ.js → SettingsView-CYEjDYWC.js} +15 -15
  67. package/dist/assets/{SettingsWindow-DCPFcip-.js → SettingsWindow-CvJsxUyu.js} +1 -1
  68. package/dist/assets/{SetupTourDialog-0bzhfhsY.js → SetupTourDialog-DWaVtkY0.js} +1 -1
  69. package/dist/assets/{SyncActions-8f50jzAU.js → SyncActions-C0gph0P8.js} +1 -1
  70. package/dist/assets/TerminalView-Cm8Ts51w.js +9 -0
  71. package/dist/assets/{TextSelectionMenu-BozjXtuL.js → TextSelectionMenu-Dcv_PdES.js} +2 -2
  72. package/dist/assets/{ToolOutputDialog-BK0D8GxM.js → ToolOutputDialog-QJpQjmqK.js} +2 -2
  73. package/dist/assets/{YuriLogo-KR0TAQlB.js → YuriLogo-BbS_Wj4g.js} +1 -1
  74. package/dist/assets/{YuriWordmark-B0uXpGcz.js → YuriWordmark-CqkcfAJl.js} +1 -1
  75. package/dist/assets/{assistant-attachment-cache-BNDj8_aw.js → assistant-attachment-cache-CIij0OGm.js} +1 -1
  76. package/dist/assets/{assistantMessagePreview-Ccp5_-kq.js → assistantMessagePreview-wmP-d_oa.js} +1 -1
  77. package/dist/assets/{assistantQueries-DDTlQu6m.js → assistantQueries-Dpxq78yP.js} +1 -1
  78. package/dist/assets/{auto-read-context-C8RimaOE.js → auto-read-context-aRn5yhDb.js} +1 -1
  79. package/dist/assets/{capgoAdapter-DvATpyxN.js → capgoAdapter-BSnmtwX8.js} +1 -1
  80. package/dist/assets/{card-alsnQayp.js → card-aoveY4I3.js} +1 -1
  81. package/dist/assets/{chatUpwardIntent-D_Yt_quU.js → chatUpwardIntent-WxxmOppY.js} +1 -1
  82. package/dist/assets/{checkbox-LzFeQCyX.js → checkbox-CljLXON1.js} +1 -1
  83. package/dist/assets/{client-i5Q82JUc.js → client-CmtAKi5B.js} +1 -1
  84. package/dist/assets/{collapsible-HsY9X-Ve.js → collapsible-DkeWKEAb.js} +1 -1
  85. package/dist/assets/{connection-hint-DsbzB6Ms.js → connection-hint-DsKyICgn.js} +1 -1
  86. package/dist/assets/{context-menu-Dpuzxt3o.js → context-menu-XuMa5TsA.js} +1 -1
  87. package/dist/assets/{desktopHosts-DRAWu-NH.js → desktopHosts-COI-czjF.js} +1 -1
  88. package/dist/assets/{desktopRelayRestore-DFWsoSoG.js → desktopRelayRestore-BEPNc7qb.js} +1 -1
  89. package/dist/assets/device-TCHW5U2y.js +2 -0
  90. package/dist/assets/{diagram-COwAj2NM.js → diagram-DFv7Lh0h.js} +1 -1
  91. package/dist/assets/dialog-B6B8FIrL.css +1 -0
  92. package/dist/assets/{dialog-Cv20xnEj.js → dialog-Cx20I73q.js} +1 -1
  93. package/dist/assets/{dropdown-menu-B_P1dDl7.js → dropdown-menu-XdfySbu2.js} +1 -1
  94. package/dist/assets/es-CLAEdHpc.js +15 -0
  95. package/dist/assets/{fileMentionTouchSelection-BRu1cBlZ.js → fileMentionTouchSelection-pXNTKHAc.js} +1 -1
  96. package/dist/assets/{fileReferenceActions-FVCTQlDH.js → fileReferenceActions-wN7mWY3w.js} +1 -1
  97. package/dist/assets/fr-BOB0gfdQ.js +13 -0
  98. package/dist/assets/{gitApi-BH7j-M9u.js → gitApi-LXGRaDt8.js} +1 -1
  99. package/dist/assets/{gitApiHttp-Be5VpQHC.js → gitApiHttp-ZjM4HkSo.js} +2 -2
  100. package/dist/assets/{githubAuthQueries-Dli4cDU7.js → githubAuthQueries-3AJp5LD5.js} +1 -1
  101. package/dist/assets/{historyImportQueries-SUqjfVSc.js → historyImportQueries-B_mfphxe.js} +1 -1
  102. package/dist/assets/host-fTclNJST.js +1 -0
  103. package/dist/assets/{i18n-CBCskgqa.js → i18n-iu4pzqPi.js} +1 -1
  104. package/dist/assets/{icons-BQMGp0ts.js → icons-BWijARKS.js} +1 -1
  105. package/dist/assets/{imageSource-DoyhaY3E.js → imageSource-qzgDdfT4.js} +1 -1
  106. package/dist/assets/{input-CY-NU-bG.js → input-BMYgp87Q.js} +1 -1
  107. package/dist/assets/{input-store-C4dE7Hgl.js → input-store-CzG_3qFv.js} +1 -1
  108. package/dist/assets/insertionBoundaries-bmxIeFzH.js +1 -0
  109. package/dist/assets/ja-CfM9jZ6u.js +15 -0
  110. package/dist/assets/{kbd-DJnHCHPh.js → kbd-6RW-BxuR.js} +1 -1
  111. package/dist/assets/ko-DZOSVPHB.js +15 -0
  112. package/dist/assets/main-B-Wdp6An.js +169 -0
  113. package/dist/assets/main-BLBAaohb.js +2 -0
  114. package/dist/assets/{markdownHeightCache-BAuvVQZt.js → markdownHeightCache-ojT5txMS.js} +1 -1
  115. package/dist/assets/{mcpQueries-lBUNZsO9.js → mcpQueries-BRuytwhB.js} +1 -1
  116. package/dist/assets/miniChat-BsrHy2rU.js +2 -0
  117. package/dist/assets/mobile-B8SHiXyq.js +2 -0
  118. package/dist/assets/{mobileBackNavigation-BzQ0WYuk.js → mobileBackNavigation-CVrR_jtn.js} +1 -1
  119. package/dist/assets/{mobileConnections-CSyrEiXH.js → mobileConnections-iSUwFNqu.js} +2 -2
  120. package/dist/assets/{multirun-BUjPLUCQ.js → multirun-Y3K5yS-8.js} +1 -1
  121. package/dist/assets/{native-config-C-fqN2Cf.js → native-config-tvqKHwCC.js} +1 -1
  122. package/dist/assets/{nativeComposerCover-DT9d7IrX.js → nativeComposerCover-5rYz1E3W.js} +1 -1
  123. package/dist/assets/{navigation-D2V5N7IH.js → navigation-DFmCAq2g.js} +2 -2
  124. package/dist/assets/openRemoteProjectSession-CeSahDtQ.js +1 -0
  125. package/dist/assets/openSessionFromDeepLink-DsZnNy4W.js +2 -0
  126. package/dist/assets/pl-CaT81Sz8.js +15 -0
  127. package/dist/assets/platform-B2ylz14u.js +1 -0
  128. package/dist/assets/{pluginPresentation-CbOzLlWM.js → pluginPresentation-rls1AMJN.js} +2 -2
  129. package/dist/assets/{project-preview-ClK_VQFz.js → project-preview-yQerlKs2.js} +1 -1
  130. package/dist/assets/{projectActions-CD3dKulN.js → projectActions-B11KAI3f.js} +1 -1
  131. package/dist/assets/{prompt-attachment-upload-BG4nBKxi.js → prompt-attachment-upload-BzYqZdzd.js} +1 -1
  132. package/dist/assets/pt-BR-9p1IKCEF.js +15 -0
  133. package/dist/assets/pwa-BrLPfcLk.js +2 -0
  134. package/dist/assets/{queue-abort-optimistic-DcW7tzaK.js → queue-abort-optimistic-CXKdQu_T.js} +1 -1
  135. package/dist/assets/{quota-Cyq21PUF.js → quota-BhdKv_Wc.js} +1 -1
  136. package/dist/assets/{reference-history-BZIwpng4.js → reference-history-Bzn-aPYg.js} +1 -1
  137. package/dist/assets/{remote-input-store-CiwwBt7K.js → remote-input-store-DPw_n0MZ.js} +1 -1
  138. package/dist/assets/{remoteProjectQueries-CuuZggLJ.js → remoteProjectQueries-BQzoY_Y9.js} +1 -1
  139. package/dist/assets/{remoteSessionReference-DAt2R0UC.js → remoteSessionReference-DORvqUYQ.js} +1 -1
  140. package/dist/assets/{renderElectronMiniChatApp-C7YpH2qP.js → renderElectronMiniChatApp-DXKgwBat.js} +2 -2
  141. package/dist/assets/renderMobileApp-CKN6rWxR.js +17 -0
  142. package/dist/assets/{runtime-file-download-RzAqq2xr.js → runtime-file-download-CaeLqIEY.js} +1 -1
  143. package/dist/assets/{runtime-file-resource-COtIWnSi.js → runtime-file-resource-BGZ4tGr5.js} +1 -1
  144. package/dist/assets/{runtimeConfig-Byc5NYTD.js → runtimeConfig-BqUZF6Wt.js} +1 -1
  145. package/dist/assets/runtimeEndpointReset-Bu02gAs3.js +4 -0
  146. package/dist/assets/{scheduledTaskNavigation-DuM1gQ9g.js → scheduledTaskNavigation-r3g3DfXq.js} +1 -1
  147. package/dist/assets/{select-DxI3wkmK.js → select-BPIsJWhM.js} +1 -1
  148. package/dist/assets/{sessionLookup-UJH1iLm2.js → sessionLookup-DZhrkKRI.js} +1 -1
  149. package/dist/assets/{sessionOwnership-W4KQ8CbY.js → sessionOwnership-LoUNVeuJ.js} +1 -1
  150. package/dist/assets/{shortcuts-FWBXko6F.js → shortcuts-DMupfl7l.js} +1 -1
  151. package/dist/assets/{sortable-tabs-strip-Bq5JCAvR.js → sortable-tabs-strip-1bKw81VO.js} +1 -1
  152. package/dist/assets/{speechSettingsQueries-Cybc1zo2.js → speechSettingsQueries-C3JgzCqy.js} +1 -1
  153. package/dist/assets/src-BacdFOCS.css +2 -0
  154. package/dist/assets/{store-BRt8bo0A.js → store-BgsgBTwJ.js} +5 -5
  155. package/dist/assets/{switch-BDwSWOjd.js → switch-B4-v9kvg.js} +1 -1
  156. package/dist/assets/{terminalApi-BMMDklSX.js → terminalApi-wdwb9MVG.js} +1 -1
  157. package/dist/assets/{textarea-BshZJgqE.js → textarea-DExmj0ZR.js} +1 -1
  158. package/dist/assets/{timeFormat-7kWOlby7.js → timeFormat-BlSO2-ws.js} +1 -1
  159. package/dist/assets/{tooltip-Cdy71vjH.js → tooltip-Di-WRJUZ.js} +1 -1
  160. package/dist/assets/{truncated-path-YngMm0g8.js → truncated-path-nKzykV5p.js} +1 -1
  161. package/dist/assets/types-4xeqxklF.js +2 -0
  162. package/dist/assets/ui-BCYkB585.js +13 -0
  163. package/dist/assets/uk-BUSl_Y_1.js +15 -0
  164. package/dist/assets/useAppFontEffects-BCJPQstm.js +7 -0
  165. package/dist/assets/{useAssistantUIStore-LaS5RREA.js → useAssistantUIStore-BUWPTwNV.js} +1 -1
  166. package/dist/assets/{useDesktopWindowControlsLayout-Icn9KYUk.js → useDesktopWindowControlsLayout-BtpyMlOS.js} +1 -1
  167. package/dist/assets/{useDictation-C1sdxoEy.js → useDictation-4HBMkISY.js} +1 -1
  168. package/dist/assets/{useEffectiveDirectory-BnoYSkb7.js → useEffectiveDirectory-BYswRwIv.js} +1 -1
  169. package/dist/assets/useFontPreferences-C4dQT72k.js +1 -0
  170. package/dist/assets/{useGitStore-FAEWrkVE.js → useGitStore-DqBPgmf-.js} +1 -1
  171. package/dist/assets/{useInlineCommentDraftStore-CjyZgWKx.js → useInlineCommentDraftStore-CGJ6dM8d.js} +1 -1
  172. package/dist/assets/useMcpConfigStore-DEcxFuzW.js +1 -0
  173. package/dist/assets/{useMobileSwipeActions-3JgGyG-s.js → useMobileSwipeActions-DqlR4X-T.js} +1 -1
  174. package/dist/assets/useMobileTranscriptSyncHint-BDKcqtq_.js +10 -0
  175. package/dist/assets/{useModelLists-Cz7CBWNr.js → useModelLists-DsFTBlMr.js} +1 -1
  176. package/dist/assets/{useOpenCodeReadiness-DSTj-ijS.js → useOpenCodeReadiness-CHybAoBh.js} +1 -1
  177. package/dist/assets/usePluginsStore-BIBHPK4A.js +1 -0
  178. package/dist/assets/{useProjectGitActions-C0z5ldH7.js → useProjectGitActions-DeFcqi_O.js} +1 -1
  179. package/dist/assets/{useProjectGitStore-C6ZCDvmO.js → useProjectGitStore-JGZk-NCk.js} +1 -1
  180. package/dist/assets/{useProjectRuntimeAPIs-Fi6XrG43.js → useProjectRuntimeAPIs-BMBBtJB-.js} +1 -1
  181. package/dist/assets/{useQuotaStore-yM_EeU_A.js → useQuotaStore-C3qJTiD7.js} +1 -1
  182. package/dist/assets/{useSessionBtwStore-1yHVqSCf.js → useSessionBtwStore-D7P-pknd.js} +1 -1
  183. package/dist/assets/{useStreamingTextThrottle-BbawjMGN.js → useStreamingTextThrottle-CjWAE0oQ.js} +1 -1
  184. package/dist/assets/useTerminalStore-C_QzSEgP.js +1 -0
  185. package/dist/assets/{useUIStore-Dz0bOfkB.js → useUIStore-68ZPpgYA.js} +1 -1
  186. package/dist/assets/worktreeManager-pRvX5dQT.js +1 -0
  187. package/dist/assets/{worktreeSourceBranchPreference-BJrbhZ4m.js → worktreeSourceBranchPreference-B7d3RYcc.js} +1 -1
  188. package/dist/assets/zh-CN-BGKgQtWd.js +15 -0
  189. package/dist/assets/zh-TW-jM5lIKfe.js +15 -0
  190. package/dist/index.html +16 -16
  191. package/dist/mini-chat.html +16 -16
  192. package/dist/mobile.html +2 -2
  193. package/package.json +2 -1
  194. package/server/index.js +22 -10
  195. package/server/lib/assistants/DOCUMENTATION.md +11 -6
  196. package/server/lib/assistants/builtin-skills.js +19 -3
  197. package/server/lib/assistants/builtin-skills.test.js +17 -0
  198. package/server/lib/assistants/contact-tools.js +47 -3
  199. package/server/lib/assistants/contact-tools.test.js +59 -0
  200. package/server/lib/assistants/harness.js +5 -2
  201. package/server/lib/assistants/harness.test.js +1 -1
  202. package/server/lib/assistants/routes.js +1 -0
  203. package/server/lib/assistants/service.js +7 -2
  204. package/server/lib/assistants/yuri-tools.js +1 -1
  205. package/server/lib/assistants/yuri-tools.test.js +1 -1
  206. package/server/lib/gui-customization/DOCUMENTATION.md +32 -7
  207. package/server/lib/gui-customization/projects-client.mjs +1 -1
  208. package/server/lib/gui-customization/projects.js +6 -6
  209. package/server/lib/gui-customization/projects.test.js +13 -2
  210. package/server/lib/gui-customization/remote-connections-client.mjs +1 -1
  211. package/server/lib/gui-customization/remote-connections.js +7 -6
  212. package/server/lib/gui-customization/remote-connections.test.js +17 -0
  213. package/server/lib/gui-customization/session-skill.js +16 -4
  214. package/server/lib/gui-customization/session-skill.test.js +16 -0
  215. package/server/lib/gui-customization/skill/SKILL.md +2 -2
  216. package/server/lib/gui-customization/skill/references/deep-links.md +15 -11
  217. package/server/lib/gui-customization/skill/references/gui-api.md +50 -1
  218. package/server/lib/gui-customization/skill/references/projects.md +19 -0
  219. package/server/lib/gui-customization/skill/references/remote-connections.md +3 -0
  220. package/server/lib/gui-customization/skill-caller.js +18 -0
  221. package/server/lib/host-update/DOCUMENTATION.md +5 -0
  222. package/server/lib/host-update/cli.js +5 -2
  223. package/server/lib/host-update/cli.test.js +15 -2
  224. package/server/lib/opencode/DOCUMENTATION.md +2 -1
  225. package/server/lib/opencode/custom-provider.test.js +41 -0
  226. package/server/lib/opencode/feature-routes-runtime.js +20 -3
  227. package/server/lib/opencode/settings-helpers.js +5 -0
  228. package/server/lib/opencode/settings-helpers.test.js +10 -0
  229. package/server/lib/package-manager.js +14 -0
  230. package/server/lib/package-manager.test.js +7 -0
  231. package/server/lib/portable-installation.js +34 -0
  232. package/server/lib/portable-installation.test.js +38 -0
  233. package/server/lib/session-index/DOCUMENTATION.md +8 -0
  234. package/server/lib/session-index/adopt-unindexed-session.js +46 -0
  235. package/server/lib/session-index/adopt-unindexed-session.test.js +77 -0
  236. package/server/lib/session-index/event-ingest.js +14 -1
  237. package/server/lib/session-index/event-ingest.test.js +18 -0
  238. package/dist/assets/ArchivedSessionsDialog-DLZzsdyB.js +0 -1
  239. package/dist/assets/BusyDots-C2pMtufA.js +0 -4
  240. package/dist/assets/ChatView-CNNGCekk.js +0 -3
  241. package/dist/assets/MarkdownRenderer-GdoxOy4f.js +0 -2
  242. package/dist/assets/ScheduledTasksDialog-DY9GJF-s.js +0 -3
  243. package/dist/assets/TerminalView-B9AFgs54.js +0 -8
  244. package/dist/assets/device-gKeFQDLT.js +0 -2
  245. package/dist/assets/dialog-D9CkSNCA.css +0 -1
  246. package/dist/assets/es-BuXtFKUW.js +0 -15
  247. package/dist/assets/fr-BaZeffY9.js +0 -13
  248. package/dist/assets/host-CgzhgNKF.js +0 -1
  249. package/dist/assets/insertionBoundaries-DUMGOIsz.js +0 -1
  250. package/dist/assets/ja-CGVx5A8U.js +0 -15
  251. package/dist/assets/ko-C663nzbf.js +0 -15
  252. package/dist/assets/main-CSPEphQ0.js +0 -169
  253. package/dist/assets/main-VozcdE4o.js +0 -2
  254. package/dist/assets/miniChat-DuIhQwv6.js +0 -2
  255. package/dist/assets/mobile-zYF3NcbJ.js +0 -2
  256. package/dist/assets/openRemoteProjectSession-Dz9GJCUz.js +0 -1
  257. package/dist/assets/openSessionFromDeepLink-DHu8AmBy.js +0 -2
  258. package/dist/assets/pl-CeBOMwg9.js +0 -15
  259. package/dist/assets/platform-z1TeG-ky.js +0 -1
  260. package/dist/assets/pt-BR-r8268Pk6.js +0 -15
  261. package/dist/assets/pwa-Dc46OTi7.js +0 -2
  262. package/dist/assets/renderMobileApp-DkFS7I4O.js +0 -17
  263. package/dist/assets/runtimeEndpointReset-BOfBQwJk.js +0 -4
  264. package/dist/assets/src-DYCPWwUH.css +0 -2
  265. package/dist/assets/types-CjZZGQvx.js +0 -2
  266. package/dist/assets/ui-DeV7Us1B.js +0 -13
  267. package/dist/assets/uk-CeQ1XJ99.js +0 -15
  268. package/dist/assets/useAppFontEffects-CWZFjoHJ.js +0 -7
  269. package/dist/assets/useFontPreferences-CLUZvRho.js +0 -1
  270. package/dist/assets/useMcpConfigStore-n8Iyj2v9.js +0 -1
  271. package/dist/assets/useMobileTranscriptSyncHint-CgAaYuLF.js +0 -10
  272. package/dist/assets/usePluginsStore-CsChIifx.js +0 -1
  273. package/dist/assets/worktreeManager-XchvRN9O.js +0 -1
  274. package/dist/assets/zh-CN-Bv854olO.js +0 -15
  275. package/dist/assets/zh-TW-gx8cO-Cx.js +0 -15
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,o as n}from"./runtime-switch-DEPKHgdL.js";import{L as r}from"./platform-z1TeG-ky.js";import{a as i,i as a}from"./vendor-zustand-CTekDqaS.js";import{it as o,ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,Ut as u}from"./gitApiHttp-Be5VpQHC.js";import{n as d}from"./vendor-react-BkccXcWz.js";import{r as f}from"./useUIStore-Dz0bOfkB.js";import{B as p,E as m,F as h,G as g,K as _,R as v,U as y,V as b,W as x,X as S,Y as C,Z as w,a as T,f as E,g as D,ht as O,j as k,l as ee,lt as A,mt as j,pt as M,st as N,tt as P}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{c as F,o as I,r as L}from"./vendor-codemirror-lang-angular-Cm7vBE3E.js";import{n as R,r as z}from"./vendor-codemirror-lang-json-DowyFczU.js";import{n as te}from"./vendor-codemirror-lang-markdown-npWBZIoE.js";import{n as ne}from"./vendor-codemirror-lang-python-OPRdU26g.js";import{O as B}from"./vendor-codemirror-legacy-modes-DwltVFbT.js";import{Ba as V,Fa as re,Fi as H,Mi as U,Ti as ie,Yn as W,ar as ae,bt as oe,f as se,io as G,no as K,t as q,un as ce}from"./ui-DeV7Us1B.js";import{n as J}from"./Icon-C1m8PihJ.js";import{t as le}from"./i18n-CBCskgqa.js";import{a as ue,n as de,o as fe,t as pe}from"./dialog-Cv20xnEj.js";import{i as me,n as he,t as ge}from"./tooltip-Cdy71vjH.js";import{n as _e}from"./useThemeSystem-BIXghnHj.js";import{r as ve}from"./device-gKeFQDLT.js";import{n as ye,r as be,t as xe}from"./collapsible-HsY9X-Ve.js";import{t as Se}from"./gitApi-BH7j-M9u.js";import{t as Ce}from"./input-CY-NU-bG.js";import{B as we,G as Te,H as Y,J as X,Q as Ee,U as De,V as Oe,W as ke,h as Ae,n as je}from"./pwa-Dc46OTi7.js";import{t as Me}from"./MobileOverlayPanel-XkMrn5-W.js";import{r as Ne}from"./worktreeManager-XchvRN9O.js";import{a as Pe,n as Fe,r as Ie,t as Le}from"./projectMeta-vIaGFaQr.js";import{r as Re}from"./markdown-worker-oBGEB9Eg.js";import{c as ze,l as Be,o as Ve,r as He}from"./quota-Cyq21PUF.js";import{t as Ue}from"./sessionOwnership-W4KQ8CbY.js";import{n as We,r as Ge}from"./SettingsGroup-YUId7nD5.js";import{t as Ke}from"./ModelSelector-DMmMUIB2.js";import{a as qe,d as Je,o as Ye,s as Xe}from"./vendor-codemirror-commands-5saeUOVY.js";import{a as Ze,c as Qe,i as $e,l as et,o as tt,r as nt,s as rt}from"./vendor-codemirror-search-hZY-L2l8.js";import{n as it,t as at}from"./vendor-replit-codemirror-vim-BmQmU1lR.js";import{t as ot}from"./vendor-codemirror-language-data-B3pLWvv-.js";var st=`/mcp/oauth/callback`,ct=e=>{if(typeof window>`u`)return null;try{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t.length%4==0?``:`=`.repeat(4-t.length%4),r=window.atob(t+n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}catch{return null}},lt=e=>{let t=dt(e.get(`state`));if(t)return t;let n=e.get(`server`);if(typeof n!=`string`||!n.trim())return null;let r=e.get(`directory`);return{name:n.trim(),directory:typeof r==`string`&&r.trim()?r.trim():null}},ut=e=>{let t=e.get(`state`);return typeof t==`string`&&t.trim()||null},dt=e=>{if(typeof e!=`string`||!e.trim())return null;let t=ct(e.trim());if(!t)return null;try{let e=JSON.parse(t);return e?.v!==1||typeof e.n!=`string`||!e.n.trim()?null:{name:e.n.trim(),directory:typeof e.d==`string`&&e.d.trim()?e.d.trim():null}}catch{return null}},Z=e(c(),1),ft=e(o(),1),pt=e=>typeof e==`object`&&!!e&&`updateStatus`in e&&typeof e.updateStatus==`function`,mt=e=>{let t=document.createElement(`div`);t.className=`cm-vim-panel`;let n=at(e);if(!n)return{top:!1,dom:t};n.state.statusbar=t;let r=n.state.vimPlugin;return pt(r)&&r.updateStatus(),{top:!1,dom:t,destroy(){n.state.statusbar===t&&(n.state.statusbar=null)}}};function ht(e){return e?[it(),P.of(mt),_()]:[]}var Q=s(),gt={next:`Next match`,prev:`Previous match`,select:`Select all matches`,replace:`Replace`,replaceAll:`Replace all`,close:`Close`},_t={case:`Match case`,re:`Regular expression`,word:`Match whole word`};function vt(e){let t=e.querySelector(`.cm-search`);if(t){for(let[e,n]of Object.entries(gt)){let r=t.querySelector(`button[name="${e}"]`);r&&!r.title&&(r.title=n)}for(let[e,n]of Object.entries(_t)){let r=t.querySelector(`input[name="${e}"]`)?.parentElement;r&&!r.title&&(r.title=n)}}}var yt=new WeakMap;function bt(e,t){let n=$e(e.state);if(!n.valid)return yt.delete(e),0;let r=yt.get(e);if(!t&&r?.doc===e.state.doc&&r.query.eq(n))return r.total;let i=n.getCursor(e.state),a=0;for(let e=i.next();!e.done;e=i.next())a+=1;return yt.set(e,{query:n,doc:e.state.doc,total:a}),a}function xt(e){let t=$e(e.state);if(!t.valid)return 0;let n=e.state.selection.main,r=t.getCursor(e.state),i=0,a=0;for(let e=r.next();!e.done;e=r.next()){let t=e.value;if(i+=1,a===0&&(a=i),n.from===t.from&&n.to===t.to||n.from<t.to&&n.to>t.from||t.from>=n.head)return i}return a}function St(e,t,n=!1){let r=e.querySelector(`.cm-search`);if(!r)return;let i=r.querySelector(`.cm-search-message`);if(!i){i=document.createElement(`span`),i.className=`cm-search-message`,i.setAttribute(`aria-live`,`polite`);let e=r.querySelector(`button[name="next"]`),t=e?.parentNode===r?e:r.firstChild;r.insertBefore(i,t)}let a=bt(t,n),o=a===0?0:xt(t);i.textContent=a===0?``:`${o}/${a}`}var Ct=new N,wt=new N,Tt=new N,Et=new N,Dt=new N,Ot=new N,kt=new N,At=(e=>e)(Qe.filter(e=>e.run!==Ze)),jt=m,Mt=tt,Nt=nt,Pt=class extends g{id;containerMap;constructor(e,t){super(),this.id=e,this.containerMap=t}toDOM(){let e=this.containerMap.get(this.id);return e||(e=document.createElement(`div`),e.className=`yuri-block-widget`,e.dataset.widgetId=this.id,this.containerMap.set(this.id,e)),e}eq(e){return e.id===this.id}destroy(){}},Ft=(e,t)=>!e||e.length===0?[]:O.define({create(n){let r=new M,i=[...e].sort((e,t)=>e.afterLine-t.afterLine);for(let e of i){let i=n.doc.lines;if(e.afterLine>i)continue;let a=n.doc.line(e.afterLine);r.add(a.to,a.to,b.widget({widget:new Pt(e.id,t),block:!0,side:1}))}return r.finish()},update(e,t){return e.map(t.changes)},provide:e=>y.decorations.from(e)}),It=e=>{if(!e)return[];let t=Math.max(1,e.start),n=Math.max(t,e.end);return x.fromClass(class{decorations;constructor(e){this.decorations=this.build(e)}update(e){(e.docChanged||e.viewportChanged)&&(this.decorations=this.build(e.view))}build(e){let r=new M;for(let i=t;i<=n&&i<=e.state.doc.lines;i+=1){let t=e.state.doc.line(i);r.add(t.from,t.from,b.line({class:`yuri-cm-selected-line`}))}return r.finish()}},{decorations:e=>e.decorations})};function Lt({value:e,onChange:t,extensions:n,className:r,readOnly:i,lineNumbersConfig:a,highlightLines:o,onViewReady:s,onViewDestroy:c,blockWidgets:l,enableSearch:u,searchOpen:d,onSearchOpenChange:f,vimMode:p}){let m=Z.useRef(null),h=Z.useRef(null),g=Z.useRef(e),_=Z.useRef(t),v=Z.useRef(s),b=Z.useRef(c),x=Z.useRef(f),T=Z.useRef(l),E=Z.useRef(p),D=Z.useRef(new Map),[O,ee]=Z.useState([]),j=Z.useCallback(e=>{let t=(e??[]).map(e=>{let t=D.current.get(e.id);return t?{id:e.id,content:e.content,container:t}:null}).filter(e=>e!==null);ee(e=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.content===r.content&&e.container===r.container})?e:t)},[]),M=Z.useCallback(e=>{let t=m.current,n=e??h.current;if(!t||!n)return;let r=n.dom.querySelector(`.cm-gutters`),i=r instanceof HTMLElement?r.getBoundingClientRect().width:0;t.style.setProperty(`--yuri-editor-gutter-width`,`${i}px`)},[]);return Z.useEffect(()=>{g.current=e},[e]),Z.useEffect(()=>{_.current=t},[t]),Z.useEffect(()=>{v.current=s,b.current=c},[s,c]),Z.useEffect(()=>{x.current=f},[f]),Z.useEffect(()=>{T.current=l,j(l)},[l,j]),Z.useEffect(()=>{if(!m.current)return;let e=(()=>{if(typeof document>`u`)return null;let e=document.querySelector(`meta[name="csp-nonce"]`)?.getAttribute(`content`);if(e)return e;let t=window.__YURI_CSP_NONCE__;return typeof t==`string`&&t.length>0?t:null})(),t=A.create({doc:g.current,extensions:[...e?[y.cspNonce.of(e)]:[],C({fixed:!0}),Ct.of(w(a)),Ye(),k.of(` `),kt.of(ht(p)),S.of([Je,...qe,...Xe]),y.updateListener.of(e=>{M(e.view),(e.viewportChanged||e.geometryChanged)&&j(T.current);let t=et(e.startState),n=et(e.state);t!==n&&x.current?.(n);let r=!$e(e.startState).eq($e(e.state));if(n&&(t!==n||r||e.docChanged||e.selectionSet)&&St(e.view.dom,e.view,t!==n||r||e.docChanged),!e.docChanged)return;let i=e.state.doc.toString();g.current=i,_.current(i),j(T.current)}),wt.of(y.editable.of(!i)),Tt.of(n??[]),Et.of(It(o)),Dt.of(Ft(l,D.current)),Ot.of(u?[rt({top:!0}),S.of(At)]:[])]});return h.current=new y({state:t,parent:m.current}),jt(h.current,h.current.state.doc.length,200),h.current.requestMeasure(),requestAnimationFrame(()=>{M(h.current),j(T.current)}),h.current&&v.current?.(h.current),()=>{b.current?.(),h.current?.destroy(),h.current=null,ee([])}},[T,M,j]),Z.useEffect(()=>{let e=h.current;e&&(e.dispatch({effects:[Ct.reconfigure(w(a)),wt.reconfigure(y.editable.of(!i)),Tt.reconfigure(n??[]),Et.reconfigure(It(o)),Dt.reconfigure(Ft(l,D.current)),Ot.reconfigure(u?[rt({top:!0}),S.of(At)]:[])]}),jt(e,e.state.doc.length,200),e.requestMeasure(),requestAnimationFrame(()=>{M(e),j(T.current)}))},[n,o,a,i,l,u,M,j]),Z.useEffect(()=>{let e=h.current;if(!e){E.current=p;return}E.current!==p&&(E.current=p,e.dispatch({effects:kt.reconfigure(ht(p))}))},[p]),Z.useEffect(()=>{let e=h.current;!e||u===!1||(d?(Mt(e),requestAnimationFrame(()=>{vt(e.dom),St(e.dom,e,!0)})):Nt(e))},[d,u]),Z.useEffect(()=>{let t=h.current;if(!t)return;let n=t.state.doc.toString();n!==e&&(t.dispatch({changes:{from:0,to:n.length,insert:e}}),jt(t,t.state.doc.length,300),t.requestMeasure(),requestAnimationFrame(()=>M(t)))},[e,M]),(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{ref:m,className:K(`h-full w-full`,`[&_.cm-editor]:h-full [&_.cm-editor]:w-full`,`[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6`,`[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]`,r)}),O.map(e=>(0,ft.createPortal)(e.content,e.container,e.id))]})}var Rt=E.define(B),zt=z.data.of({commentTokens:{line:`//`,block:{open:`/*`,close:`*/`}}});function Bt(e){let t=e.trim().toLowerCase();switch(t){case`bash`:case`sh`:case`zsh`:case`shell`:case`shellsession`:case`console`:return Rt;case`json`:case`jsonc`:case`json5`:return R().language;case`js`:case`javascript`:return I().language;case`jsx`:return I({jsx:!0}).language;case`ts`:case`typescript`:return I({typescript:!0}).language;case`tsx`:return I({typescript:!0,jsx:!0}).language;case`html`:return L().language;case`css`:return F().language;case`py`:case`python`:return ne().language;case`md`:case`markdown`:case`mdown`:case`mkd`:return te().language;case`heex`:case`eex`:case`leex`:return L().language;default:return ee.matchLanguageName(ot,t,!0)}}var Vt=e=>e.split(`/`).pop()?.toLowerCase()??``,Ht=e=>{let t=Vt(e);return t?ee.matchFilename(ot,t):null},Ut=()=>h(T.define([{tag:[p.heading1,p.heading2,p.heading3,p.heading4,p.heading5,p.heading6],fontWeight:`600`},{tag:p.strong,fontWeight:`600`},{tag:p.emphasis,fontStyle:`italic`},{tag:p.strikethrough,textDecoration:`line-through`},{tag:[p.link,p.url],color:`var(--markdown-link, currentColor)`,textDecoration:`underline`},{tag:p.monospace,color:`var(--markdown-inline-code, currentColor)`,backgroundColor:`var(--markdown-inline-code-bg, transparent)`},{tag:p.quote,color:`var(--markdown-blockquote, currentColor)`,fontStyle:`italic`},{tag:p.list,color:`color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)`},{tag:p.heading,color:`var(--markdown-heading1, currentColor)`}]));function Wt(e){let t=e.toLowerCase();switch(Vt(t)){case`makefile`:case`gnumakefile`:return Rt}let n=t.lastIndexOf(`.`),r=n>=0?t.slice(n+1):``;switch(r){case`ts`:case`tsx`:case`mts`:case`cts`:return I({typescript:!0,jsx:r===`tsx`});case`js`:case`jsx`:case`mjs`:case`cjs`:return I({typescript:!1,jsx:r===`jsx`});case`jsonc`:case`json5`:return[R(),zt];case`json`:case`jsonl`:case`ndjson`:case`geojson`:return R();case`css`:case`scss`:case`sass`:case`less`:return F();case`html`:case`htm`:case`xml`:case`drawio`:case`dio`:return L();case`md`:case`mdx`:case`markdown`:case`mdown`:case`mkd`:return[te({codeLanguages:Bt}),Ut()];case`sh`:case`bash`:case`zsh`:case`fish`:case`env`:return Rt;case`py`:case`pyw`:case`pyi`:return ne();default:return null}}async function Gt(e){let t=Ht(e);if(!t)return null;if(t.support)return t.support;try{return await t.load()}catch{return null}}function Kt(e,t){let n=e.metadata.variant===`dark`,r=e.config?.fonts?.mono||`monospace`,i=e.colors.syntax.highlights||{},a=e.colors.syntax.tokens||{},o=t?.fontSize?`${t.fontSize}px`:`var(--text-code)`,s=y.theme({"&":{backgroundColor:`var(--background)`,color:e.colors.syntax.base.foreground,fontSize:o,lineHeight:`1.5`,position:`relative`},".cm-scroller":{fontFamily:r,backgroundColor:`var(--background)`},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:a.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:a.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:a.boolean||e.colors.syntax.base.number},".cm-builtin":{color:a.functionCall||e.colors.syntax.base.function},".cm-def":{color:a.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:a.variableOther||a.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:a.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:a.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:a.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:a.tag||e.colors.syntax.base.keyword},".cm-link":{color:a.url||e.colors.syntax.base.keyword,textDecoration:`underline`},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:`var(--background)`,color:i.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:`sticky`,paddingRight:`8px`,left:0,zIndex:2,boxShadow:`0 0 0 var(--background)`},".cm-gutter":{backgroundColor:`var(--background)`},".cm-gutterElement":{backgroundColor:`var(--background)`},".cm-lineNumbers":{backgroundColor:`var(--background)`},".cm-lineNumbers .cm-gutterElement":{paddingLeft:`8px`,paddingRight:`8px`,minWidth:`42px`},".cm-activeLineGutter":{color:i.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-foldPlaceholder":{backgroundColor:e.colors.surface.muted,color:e.colors.surface.foreground,borderColor:e.colors.interactive.border},".cm-panels":{backgroundColor:`transparent`,color:e.colors.surface.foreground,position:`absolute`,top:`0`,right:`0`,left:`auto`,width:`auto`,zIndex:10,pointerEvents:`none`},".cm-panels-top":{borderBottom:`none`,position:`absolute`,top:`6px`,right:`14px`,left:`auto`,width:`auto`},".cm-panels-bottom":{position:`static`,width:`100%`,pointerEvents:`auto`},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.colors.surface.mutedForeground,fontFamily:`var(--font-mono)`,fontSize:`12px`,minHeight:`22px`,padding:`2px 8px`},".cm-panel.cm-search":{pointerEvents:`auto`,padding:`4px`,backgroundColor:`color-mix(in srgb, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:`10px`,boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:`auto`,minWidth:`360px`,maxWidth:`480px`},".cm-search":{display:`flex`,flexWrap:`wrap`,alignItems:`center`,gap:`0`,width:`100%`,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`13px`,lineHeight:`1`},".cm-search br":{display:`none`},".cm-search .cm-textfield":{appearance:`none`,height:`26px`,margin:0,padding:`0 8px`,borderRadius:`6px !important`,border:`1px solid ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:`inherit`,fontSize:`12px`,lineHeight:`1`,outline:`none`,transition:`border-color 150ms ease`},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:`1 1 120px`,maxWidth:`calc(100% - 142px)`,minWidth:`100px`},".cm-search label":{order:2,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`1px solid transparent`,backgroundColor:`transparent`,color:`transparent`,cursor:`pointer`,userSelect:`none`,fontSize:`1px`,lineHeight:`0`,overflow:`hidden`,position:`relative`,transition:`background-color 120ms ease, border-color 120ms ease`},".cm-search label:hover":{backgroundColor:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:`none`,WebkitAppearance:`none`,width:`0`,height:`0`,margin:`0`,padding:`0`,border:`none`,position:`absolute`,opacity:`0`,pointerEvents:`none`},".cm-search label::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`13px`,fontWeight:`600`,lineHeight:`1`,fontFamily:`inherit`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:`"Aa"`,fontSize:`12px`,letterSpacing:`-0.5px`},'.cm-search label:has(input[name="re"])::after':{content:`".*"`,fontSize:`13px`,fontFamily:`monospace`},'.cm-search label:has(input[name="word"])::after':{content:`"ab"`,fontSize:`12px`,textDecoration:`underline`,textUnderlineOffset:`2px`},".cm-search .cm-search-message":{order:3,color:e.colors.surface.mutedForeground,backgroundColor:`transparent`,border:`none`,borderRadius:`0`,padding:`0 6px`,fontSize:`11px`,whiteSpace:`nowrap`,lineHeight:`26px`},".cm-search .cm-button":{appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:0,marginLeft:`1px`,padding:0,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:`transparent`,cursor:`pointer`,fontSize:`1px`,fontWeight:`400`,lineHeight:`0`,overflow:`hidden`,position:`relative`,boxShadow:`none`,transition:`background-color 120ms ease`},".cm-search .cm-button::after":{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,fontSize:`15px`,lineHeight:`1`,color:e.colors.surface.mutedForeground,pointerEvents:`none`},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:`none`,boxShadow:`0 0 0 1px ${e.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:`default`,pointerEvents:`none`},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:`2px`},'.cm-search .cm-button[name="prev"]::after':{content:`"↑"`},'.cm-search .cm-button[name="next"]':{order:22,marginTop:`2px`},'.cm-search .cm-button[name="next"]::after':{content:`"↓"`},'.cm-search .cm-button[name="select"]':{order:23,marginTop:`2px`},'.cm-search .cm-button[name="select"]::after':{content:`"≡"`,fontSize:`17px`},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:`none`,WebkitAppearance:`none`,display:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:`26px`,height:`26px`,minWidth:`26px`,flexShrink:`0`,margin:`0 0 0 auto`,padding:`0`,borderRadius:`4px`,border:`none`,backgroundColor:`transparent`,backgroundImage:`none`,color:e.colors.surface.mutedForeground,cursor:`pointer`,fontSize:`16px`,lineHeight:`1`,boxShadow:`none`,position:`relative`,overflow:`visible`,transition:`background-color 120ms ease, color 120ms ease`},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:e.colors.interactive.hover,color:e.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:`2px`},'.cm-search .cm-button[name="replace"]::after':{content:`"⇄"`},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:`2px`},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:`"⇉"`},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:`1 1 100%`,maxWidth:`calc(100% - 142px)`,minWidth:`80px`,marginTop:`2px`},".cm-searchMatch":{backgroundColor:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:`2px`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:`none`}},{dark:n}),c=T.define([{tag:[p.comment,p.docComment,p.meta,p.documentMeta],class:`cm-comment`},{tag:[p.keyword,p.controlKeyword,p.moduleKeyword,p.definitionKeyword,p.modifier],class:`cm-keyword`},{tag:[p.operatorKeyword,p.operator,p.derefOperator,p.updateOperator,p.definitionOperator,p.typeOperator,p.controlOperator,p.logicOperator,p.bitwiseOperator,p.arithmeticOperator,p.compareOperator],class:`cm-operator`},{tag:[p.punctuation,p.separator,p.bracket,p.paren,p.brace,p.squareBracket,p.angleBracket],class:`cm-punctuation`},{tag:[p.string,p.regexp,p.attributeValue,p.special(p.string),p.monospace],class:`cm-string`},{tag:p.escape,class:`cm-string-2`},{tag:[p.number,p.bool,p.atom,p.null,p.self],class:`cm-number`},{tag:[p.function(p.variableName),p.function(p.definition(p.variableName)),p.function(p.propertyName),p.standard(p.variableName),p.special(p.variableName)],class:`cm-builtin`},{tag:p.definition(p.variableName),class:`cm-def`},{tag:[p.variableName,p.local(p.variableName),p.constant(p.variableName),p.literal],class:`cm-variable`},{tag:p.propertyName,class:`cm-property`},{tag:p.attributeName,class:`cm-attribute`},{tag:[p.className,p.typeName,p.namespace],class:`cm-variable-3`},{tag:[p.tagName,p.labelName,p.annotation,p.macroName],class:`cm-tag`},{tag:p.link,class:`cm-link`},{tag:[p.heading,p.heading1,p.heading2,p.heading3,p.heading4,p.heading5,p.heading6],class:`cm-keyword`}]),l=T.define([{tag:[p.comment,p.docComment,p.meta,p.documentMeta],color:e.colors.syntax.base.comment},{tag:[p.keyword,p.controlKeyword,p.moduleKeyword,p.definitionKeyword,p.modifier],color:e.colors.syntax.base.keyword},{tag:[p.operatorKeyword,p.operator,p.derefOperator,p.updateOperator,p.definitionOperator,p.typeOperator,p.controlOperator,p.logicOperator,p.bitwiseOperator,p.arithmeticOperator,p.compareOperator],color:e.colors.syntax.base.operator},{tag:[p.string,p.regexp,p.attributeValue,p.special(p.string),p.monospace],color:e.colors.syntax.base.string},{tag:p.escape,color:a.stringEscape||e.colors.syntax.base.string},{tag:[p.number,p.bool,p.atom,p.null,p.self],color:e.colors.syntax.base.number},{tag:[p.function(p.variableName),p.function(p.definition(p.variableName)),p.function(p.propertyName),p.standard(p.variableName),p.special(p.variableName)],color:e.colors.syntax.base.function},{tag:p.definition(p.variableName),color:a.variableGlobal||e.colors.syntax.base.variable},{tag:[p.variableName,p.local(p.variableName),p.constant(p.variableName),p.literal],color:e.colors.syntax.base.variable},{tag:p.propertyName,color:a.variableProperty||e.colors.syntax.base.variable},{tag:p.attributeName,color:a.variableOther||e.colors.syntax.base.variable},{tag:[p.className,p.typeName,p.namespace],color:e.colors.syntax.base.type},{tag:[p.tagName,p.labelName,p.annotation,p.macroName],color:a.tag||e.colors.syntax.base.keyword},{tag:p.link,color:a.url||e.colors.syntax.base.function,textDecoration:`underline`},{tag:[p.punctuation,p.separator,p.bracket,p.paren,p.brace,p.squareBracket,p.angleBracket],color:a.punctuation||e.colors.syntax.base.comment}]);return t?.syntaxColors===!1?[s]:[s,h(D,{fallback:!0}),h(v),h(c),h(l)]}var qt=180,Jt=j.define(),Yt=1,Xt=2,Zt=4,Qt=new Map,$t=(e,t)=>{let n=`${e}|${t}`,r=Qt.get(n);if(r)return r;let i=``;e&&(i+=`color:${e};`),t&Yt&&(i+=`font-style:italic;`),t&Xt&&(i+=`font-weight:bold;`),t&Zt&&(i+=`text-decoration:underline;`);let a=b.mark({attributes:{style:i}});return Qt.set(n,a),a},en=(e,t)=>{let n=new M,r=e.state.doc,i=Math.min(t.length,r.lines);for(let e=0;e<i;e+=1){let i=t[e];if(!i||i.length===0)continue;let a=r.line(e+1),o=a.from;for(let[e,t,r]of i){if(e<=0)continue;let i=o,s=Math.min(o+e,a.to);o+=e,!(s<=i)&&(!t&&!r||n.add(i,s,$t(t,r)))}}return n.finish()},tn=O.define({create(){return b.none},update(e,t){let n=e.map(t.changes);for(let e of t.effects)e.is(Jt)&&(n=e.value);return n},provide:e=>y.decorations.from(e)}),nn=e=>x.fromClass(class{timer;generation=0;abortController;constructor(e){this.tokenize(e)}update(e){e.docChanged&&this.schedule(e.view)}schedule(e){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(e)},qt)}async tokenize(t){let n=++this.generation;this.abortController?.abort();let r=new AbortController;this.abortController=r;let i=t.state.doc.toString(),a=await Re(i,e.language,e.themeName,e.theme,{signal:r.signal,priority:`visible`});a&&(r.signal.aborted||n===this.generation&&t.state.doc.length===i.length&&t.dispatch({effects:Jt.of(en(t,a))}))}destroy(){this.timer&&clearTimeout(this.timer),this.abortController?.abort(),this.abortController=void 0}}),rn=e=>[tn,nn(e)],an=d(),on=e=>{let t=(0,an.c)(11),{currentMode:n,onToggle:r}=e,i=n===`preview`,a=i?`Switch to edit mode`:`Switch to preview mode`,o=i?`Edit`:`Preview`,s;t[0]===i?s=t[1]:(s=i?(0,Q.jsx)(J,{name:`eye`,className:`size-4`,"aria-hidden":`true`}):(0,Q.jsx)(J,{name:`eye-off`,className:`size-4`,"aria-hidden":`true`}),t[0]=i,t[1]=s);let c;t[2]!==a||t[3]!==r||t[4]!==s?(c=(0,Q.jsx)(me,{asChild:!0,children:(0,Q.jsx)(W,{variant:`ghost`,size:`sm`,onClick:r,"aria-label":a,className:`h-5 w-5 p-0`,children:s})}),t[2]=a,t[3]=r,t[4]=s,t[5]=c):c=t[5];let l;t[6]===o?l=t[7]:(l=(0,Q.jsx)(he,{sideOffset:8,children:o}),t[6]=o,t[7]=l);let u;return t[8]!==c||t[9]!==l?(u=(0,Q.jsxs)(ge,{children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10],u},sn=e=>{let t=(0,an.c)(27),{title:n,settingsItem:r,children:i,collapsible:a,count:o}=e,s=a!==void 0&&a,[c,l]=Z.useState(!1);if(s){let e;t[0]===n?e=t[1]:(e=(0,Q.jsx)(`span`,{className:`typography-ui-label min-w-0 truncate`,children:n}),t[0]=n,t[1]=e);let a;t[2]===o?a=t[3]:(a=o===void 0?null:(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums`,children:o}),t[2]=o,t[3]=a);let s=c?`arrow-down-s`:`arrow-right-s`,u;t[4]===s?u=t[5]:(u=(0,Q.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center`,children:(0,Q.jsx)(J,{name:s,className:`size-4`})}),t[4]=s,t[5]=u);let d;t[6]!==a||t[7]!==u?(d=(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2 text-muted-foreground`,children:[a,u]}),t[6]=a,t[7]=u,t[8]=d):d=t[8];let f;t[9]!==e||t[10]!==d?(f=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row flex items-center gap-2`,children:(0,Q.jsxs)(be,{className:`min-w-0 flex-1 gap-2 p-0 hover:bg-transparent focus-visible:ring-[var(--interactive-focus-ring)]`,children:[e,d]})}),t[9]=e,t[10]=d,t[11]=f):f=t[11];let p;t[12]===i?p=t[13]:(p=(0,Q.jsx)(ye,{keepMounted:!0,children:(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i})}),t[12]=i,t[13]=p);let m;t[14]!==f||t[15]!==p?(m=(0,Q.jsxs)(We,{children:[f,p]}),t[14]=f,t[15]=p,t[16]=m):m=t[16];let h;return t[17]!==c||t[18]!==r||t[19]!==m?(h=(0,Q.jsx)(xe,{open:c,onOpenChange:l,"data-settings-item":r,children:m}),t[17]=c,t[18]=r,t[19]=m,t[20]=h):h=t[20],h}let u;t[21]===i?u=t[22]:(u=(0,Q.jsx)(`div`,{className:`yuri-settings-group-row`,children:i}),t[21]=i,t[22]=u);let d;return t[23]!==r||t[24]!==u||t[25]!==n?(d=(0,Q.jsx)(We,{label:n,itemId:r,children:u}),t[23]=r,t[24]=u,t[25]=n,t[26]=d):d=t[26],d},cn=({projectRef:e=null,collapsible:t=!1})=>{let{t:n}=le(),{isMobile:r,isTablet:i}=ve(),a=r||i,o=V(e=>e.getActiveProject()),s=e?.path??o?.path??null,c=se(e=>e.getWorktreeMetadata),u=oe(),d=l(e=>e.homeDirectory),[f,p]=Z.useState(null),[m,h]=Z.useState([]),[g,_]=Z.useState(!1),v=Z.useMemo(()=>e?.id&&e?.path?{id:e.id,path:e.path}:!o?.id||!s?null:{id:o.id,path:s},[o?.id,s,e?.id,e?.path]),y=Z.useCallback(async()=>{if(!(!v||f===!1))try{let e=await Ne(v);h(e)}catch{}},[v,f]);Z.useEffect(()=>{if(!s)return;let e=!1;return p(null),(async()=>{try{let t=await Se(s);if(e)return;p(t)}catch{}})(),()=>{e=!0}},[s]),Z.useEffect(()=>{if(!v){h([]),_(!1);return}if(f===!1){h([]),_(!1);return}let e=!1;return _(!0),h([]),(async()=>{try{let t=await Ne(v);if(e)return;h(t)}catch{}finally{e||_(!1)}})(),()=>{e=!0}},[v,f]);let b=Z.useCallback(e=>{let t=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t(e.path),r=u.filter(e=>{let r=c(e.id);if(r?.path&&t(r.path)===n)return!0;let i=e.directory;return!!(i&&t(i)===n)}),i=new Set(r.map(e=>e.id)),a=[...H.getState().activeSessions,...H.getState().archivedSessions],o=e=>{let t=a.filter(t=>{let n=t.parentID;return n&&e.has(n)});if(t.length===0)return[];let n=new Set(t.map(e=>e.id));return[...t,...o(n)]},s=o(i),l=new Set,d=[...r,...s].filter(e=>!l.has(e.id)&&(l.add(e.id),!0));ae.requestDelete({sessions:d,mode:`worktree`,worktree:e})},[u,c]),x=Z.useMemo(()=>u.map(e=>e.id).join(`,`),[u]);return Z.useEffect(()=>{f&&s&&y()},[x,f,s,y]),s?f===!1?(0,Q.jsx)(sn,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.gitOnly`)})}):(0,Q.jsx)(sn,{title:n(`settings.yuri.worktrees.list.title`),settingsItem:`projects.worktree`,collapsible:t,count:g?void 0:m.length,children:g?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.list.loading`)}):m.length===0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground/70`,children:n(`settings.yuri.worktrees.list.empty`)}):(0,Q.jsx)(`div`,{className:`w-full space-y-1`,children:m.map(e=>(0,Q.jsxs)(`div`,{className:`group flex w-full items-center gap-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Q.jsx)(`p`,{className:`typography-meta min-w-0 truncate text-foreground`,children:e.label||e.branch||n(`settings.yuri.worktrees.list.detachedHead`)})}),(0,Q.jsx)(`p`,{className:`typography-micro truncate text-muted-foreground/60`,children:G(e.path,d)})]}),(0,Q.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>b(e),className:K(`text-muted-foreground transition-opacity focus-visible:opacity-100`,a?`opacity-100`:`opacity-0 group-hover:opacity-100`),"aria-label":n(`settings.yuri.worktrees.list.deleteWorktreeAria`,{name:e.branch||e.label||e.path}),children:(0,Q.jsx)(J,{name:`delete-bin`,className:`h-4 w-4`})})]},e.path))})}):(0,Q.jsx)(sn,{title:n(`settings.projects.page.section.worktree`),settingsItem:`projects.worktree`,children:(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.yuri.worktrees.state.selectProject`)})})},ln=e=>{let t=(0,an.c)(127),{form:n}=e,{t:r}=le(),{currentTheme:i}=_e(),{name:a,setName:o,icon:s,setIcon:c,color:l,setColor:u,iconBackground:d,setIconBackground:f,parsedDefaultModel:p,handleDefaultModelChange:m,isUploadingIcon:h,isRemovingCustomIcon:g,isDiscoveringIcon:_,pendingRemoveImageIcon:v,setPendingRemoveImageIcon:y,pendingUploadIconPreviewUrl:b,setPreviewImageFailed:x,hasPendingUploadImageIcon:S,hasCustomIcon:C,effectiveHasImageIcon:w,hasRemovableImageIcon:T,showImagePreview:E,fileInputRef:D,handleUploadIcon:O,handleRemoveImageIcon:k,handleDiscoverIcon:ee,currentIconImage:A,project:j}=n;if(!j)return null;let M=l?Fe[l]??null:null,N;t[0]===r?N=t[1]:(N=r(`settings.projects.page.field.projectName`),t[0]=r,t[1]=N);let P;t[2]===o?P=t[3]:(P=e=>o(e.target.value),t[2]=o,t[3]=P);let F;t[4]===r?F=t[5]:(F=r(`settings.projects.page.field.projectNamePlaceholder`),t[4]=r,t[5]=F);let I;t[6]===r?I=t[7]:(I=r(`settings.projects.page.field.projectName`),t[6]=r,t[7]=I);let L;t[8]!==a||t[9]!==P||t[10]!==F||t[11]!==I?(L=(0,Q.jsx)(Ce,{value:a,onChange:P,placeholder:F,"aria-label":I}),t[8]=a,t[9]=P,t[10]=F,t[11]=I,t[12]=L):L=t[12];let R;t[13]!==N||t[14]!==L?(R=(0,Q.jsx)(Ge,{label:N,itemId:`projects.name`,children:L}),t[13]=N,t[14]=L,t[15]=R):R=t[15];let z;t[16]===r?z=t[17]:(z=r(`settings.yuri.defaults.field.defaultModel`),t[16]=r,t[17]=z);let te=p.providerId,ne=p.modelId,B;t[18]===r?B=t[19]:(B=r(`settings.yuri.defaults.option.default`),t[18]=r,t[19]=B);let V;t[20]!==m||t[21]!==p.modelId||t[22]!==p.providerId||t[23]!==B?(V=(0,Q.jsx)(Ke,{providerId:te,modelId:ne,onChange:m,className:`yuri-settings-inline-value`,placeholder:B,showIcon:!1}),t[20]=m,t[21]=p.modelId,t[22]=p.providerId,t[23]=B,t[24]=V):V=t[24];let re;t[25]!==V||t[26]!==z?(re=(0,Q.jsx)(Ge,{label:z,itemId:`projects.default-model`,children:V}),t[25]=V,t[26]=z,t[27]=re):re=t[27];let H;t[28]===r?H=t[29]:(H=r(`settings.projects.page.field.accentColor`),t[28]=r,t[29]=H);let U;t[30]===u?U=t[31]:(U=()=>u(null),t[30]=u,t[31]=U);let ie=l===null,ae;t[32]===r?ae=t[33]:(ae=r(`settings.projects.page.field.none`),t[32]=r,t[33]=ae);let oe;t[34]===r?oe=t[35]:(oe=r(`settings.projects.page.field.none`),t[34]=r,t[35]=oe);let se;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,Q.jsx)(J,{name:`close`,className:`size-4 text-muted-foreground`}),t[36]=se):se=t[36];let G;t[37]!==U||t[38]!==ie||t[39]!==ae||t[40]!==oe?(G=(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:U,"aria-pressed":ie,"aria-label":ae,title:oe,children:se}),t[37]=U,t[38]=ie,t[39]=ae,t[40]=oe,t[41]=G):G=t[41];let K;t[42]!==l||t[43]!==u?(K=Le.map(e=>(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>u(e.key),"aria-pressed":l===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full`,style:{backgroundColor:e.cssVar},children:l===e.key?(0,Q.jsx)(J,{name:`check`,className:`size-3 text-foreground`}):null})},e.key)),t[42]=l,t[43]=u,t[44]=K):K=t[44];let q;t[45]!==G||t[46]!==K?(q=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-2`,children:[G,K]}),t[45]=G,t[46]=K,t[47]=q):q=t[47];let ce;t[48]!==H||t[49]!==q?(ce=(0,Q.jsx)(Ge,{label:H,itemId:`projects.accent-color`,footer:q,children:null}),t[48]=H,t[49]=q,t[50]=ce):ce=t[50];let ue;t[51]===r?ue=t[52]:(ue=r(`settings.projects.page.field.projectIcon`),t[51]=r,t[52]=ue);let de;t[53]===O?de=t[54]:(de=e=>{let t=e.target.files?.[0]??null;O(t),e.currentTarget.value=``},t[53]=O,t[54]=de);let fe;t[55]!==D||t[56]!==de?(fe=(0,Q.jsx)(`input`,{ref:D,type:`file`,accept:`image/png,image/jpeg,image/svg+xml,.png,.jpg,.jpeg,.svg`,className:`hidden`,onChange:de}),t[55]=D,t[56]=de,t[57]=fe):fe=t[57];let pe;t[58]===c?pe=t[59]:(pe=()=>c(null),t[58]=c,t[59]=pe);let me=s===null,he;t[60]===r?he=t[61]:(he=r(`settings.projects.page.field.none`),t[60]=r,t[61]=he);let ge;t[62]===r?ge=t[63]:(ge=r(`settings.projects.page.field.none`),t[62]=r,t[63]=ge);let ve;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ve=(0,Q.jsx)(J,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[64]=ve):ve=t[64];let ye;t[65]!==pe||t[66]!==me||t[67]!==he||t[68]!==ge?(ye=(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:pe,"aria-pressed":me,"aria-label":he,title:ge,children:ve}),t[65]=pe,t[66]=me,t[67]=he,t[68]=ge,t[69]=ye):ye=t[69];let be;t[70]!==M||t[71]!==s||t[72]!==c?(be=Ie.map(e=>{let t=e.Icon;return(0,Q.jsx)(W,{type:`button`,variant:`chip`,size:`icon`,onClick:()=>c(e.key),"aria-pressed":s===e.key,"aria-label":e.label,title:e.label,children:(0,Q.jsx)(J,{name:t,className:`w-4 h-4`,style:M&&s===e.key?{color:M}:void 0})},e.key)}),t[70]=M,t[71]=s,t[72]=c,t[73]=be):be=t[73];let xe;t[74]!==ye||t[75]!==be?(xe=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[ye,be]}),t[74]=ye,t[75]=be,t[76]=xe):xe=t[76];let Se;t[77]!==A||t[78]!==i||t[79]!==w||t[80]!==S||t[81]!==d||t[82]!==b||t[83]!==j||t[84]!==x||t[85]!==E?(Se=w&&E&&(0,Q.jsx)(`div`,{className:`flex items-center gap-2 pt-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-7 w-7 items-center justify-center rounded-md border border-border/60 bg-[var(--surface-elevated)] p-1`,children:(0,Q.jsx)(`span`,{className:`inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]`,style:d?{backgroundColor:d}:void 0,children:S&&b?(0,Q.jsx)(`img`,{src:b,alt:``,className:`h-full w-full object-contain`,draggable:!1,onError:()=>x(!0)}):(0,Q.jsx)(Pe,{project:{...j,iconImage:A??j.iconImage},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:`h-full w-full object-contain`,onError:()=>x(!0)})})})}),t[77]=A,t[78]=i,t[79]=w,t[80]=S,t[81]=d,t[82]=b,t[83]=j,t[84]=x,t[85]=E,t[86]=Se):Se=t[86];let we;t[87]!==w||t[88]!==d||t[89]!==f||t[90]!==r?(we=w&&(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`color`,value:d??`#000000`,onChange:e=>f(e.target.value),className:`h-7 w-9 cursor-pointer rounded border border-border bg-transparent p-1`,"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`)}),(0,Q.jsx)(Ce,{value:d??``,onChange:e=>f(e.target.value),"aria-label":r(`settings.projects.page.field.projectIconBackgroundAria`),placeholder:`#000000`,className:`h-7 w-[8rem]`}),(0,Q.jsx)(W,{type:`button`,size:`icon`,variant:`ghost`,onClick:()=>f(null),"aria-label":r(`settings.projects.page.field.clearIconBackgroundAria`),title:r(`settings.projects.page.field.clearBackground`),disabled:!d,children:(0,Q.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),t[87]=w,t[88]=d,t[89]=f,t[90]=r,t[91]=we):we=t[91];let Te;t[92]!==D||t[93]!==ee||t[94]!==C||t[95]!==_||t[96]!==h||t[97]!==r?(Te=!C&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(W,{size:`xs`,onClick:()=>D.current?.click(),disabled:h,children:r(h?`settings.projects.page.actions.uploading`:`settings.projects.page.actions.uploadIcon`)}),(0,Q.jsx)(W,{size:`xs`,variant:`outline`,onClick:()=>void ee(),disabled:_,children:r(_?`settings.projects.page.actions.discovering`:`settings.projects.page.actions.discoverFavicon`)})]}),t[92]=D,t[93]=ee,t[94]=C,t[95]=_,t[96]=h,t[97]=r,t[98]=Te):Te=t[98];let Y;t[99]!==k||t[100]!==T||t[101]!==g||t[102]!==r?(Y=T&&(0,Q.jsx)(W,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>void k(),disabled:g,children:r(g?`settings.projects.page.actions.removing`:`settings.projects.page.actions.removeProjectIcon`)}),t[99]=k,t[100]=T,t[101]=g,t[102]=r,t[103]=Y):Y=t[103];let X;t[104]!==g||t[105]!==v||t[106]!==y||t[107]!==r?(X=v&&(0,Q.jsx)(W,{size:`xs`,className:`!font-normal`,variant:`outline`,onClick:()=>y(!1),disabled:g,children:r(`settings.projects.page.actions.undoRemove`)}),t[104]=g,t[105]=v,t[106]=y,t[107]=r,t[108]=X):X=t[108];let Ee;t[109]!==Te||t[110]!==Y||t[111]!==X?(Ee=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[Te,Y,X]}),t[109]=Te,t[110]=Y,t[111]=X,t[112]=Ee):Ee=t[112];let De;t[113]!==fe||t[114]!==xe||t[115]!==Se||t[116]!==we||t[117]!==Ee?(De=(0,Q.jsxs)(`div`,{className:`flex w-full flex-col items-start gap-2 pt-2`,children:[fe,xe,Se,we,Ee]}),t[113]=fe,t[114]=xe,t[115]=Se,t[116]=we,t[117]=Ee,t[118]=De):De=t[118];let Oe;t[119]!==ue||t[120]!==De?(Oe=(0,Q.jsx)(Ge,{label:ue,itemId:`projects.icon`,footer:De,children:null}),t[119]=ue,t[120]=De,t[121]=Oe):Oe=t[121];let ke;return t[122]!==re||t[123]!==ce||t[124]!==Oe||t[125]!==R?(ke=(0,Q.jsxs)(We,{children:[R,re,ce,Oe]}),t[122]=re,t[123]=ce,t[124]=Oe,t[125]=R,t[126]=ke):ke=t[126],ke},un=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6})$/,dn=e=>{if(!e)return null;let t=e.trim();return t&&un.test(t)?t.toLowerCase():null},fn=e=>{let{t}=le(),n=V(e=>e.uploadProjectIcon),r=V(e=>e.removeProjectIcon),i=V(e=>e.discoverProjectIcon),a=V(t=>e?t.projects.find(t=>t.id===e.id)?.iconImage??null:null),[o,s]=Z.useState(``),[c,l]=Z.useState(null),[u,d]=Z.useState(null),[f,p]=Z.useState(null),[m,h]=Z.useState(void 0),[g,_]=Z.useState(!1),[v,y]=Z.useState(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(!1),[w,T]=Z.useState(null),[E,D]=Z.useState(null),[O,k]=Z.useState(!1),ee=Z.useRef(null),A=Z.useCallback(()=>{T(null),D(e=>(e&&URL.revokeObjectURL(e),null))},[]),j=e?.id??null;Z.useEffect(()=>{if(!e){s(``),l(null),d(null),p(null),h(void 0);return}s(e.label??``),l(e.icon??null),d(e.color??null),p(e.iconBackground??null),h(e.defaultModel),C(!1),A(),k(!1)},[e,A]),Z.useEffect(()=>()=>{A()},[A]);let M=Z.useMemo(()=>re(m)??{providerId:``,modelId:``},[m]),N=!!e?.iconImage,P=!!(w&&E),F=e?.iconImage?.source===`custom`,I=N&&!S||P,L=I,R=!!(e&&N&&!S),z=!O&&(P||R),te=!!e&&(o.trim()!==(e?.label??``).trim()||c!==(e?.icon??null)||u!==(e?.color??null)||f!==(e?.iconBackground??null)||(m??void 0)!==(e?.defaultModel??void 0)||S||!!w),ne=Z.useCallback((e,t)=>{h(e&&t?`${e}/${t}`:void 0)},[]),B=Z.useCallback(t=>{!e||!t||g||(C(!1),k(!1),T(t),D(e=>(e&&URL.revokeObjectURL(e),URL.createObjectURL(t))))},[g,e]),H=Z.useCallback(()=>{!e||!L||v||(P&&A(),C(!!N),k(!1))},[A,P,L,N,v,e]),U=Z.useCallback(async()=>{if(!(!e||b)){A(),C(!1),k(!1),x(!0);try{let n=await i(e.id);if(!n.ok){q.error(n.error||t(`settings.projects.page.toast.discoverIconFailed`));return}if(n.skipped){q.success(t(`settings.projects.page.toast.customIconAlreadySet`));return}q.success(t(`settings.projects.page.toast.iconDiscovered`))}finally{x(!1)}}},[A,i,b,e,t]),ie=Z.useCallback(async i=>{let a=i?.silent===!0;if(!e)return null;let s=o.trim();if(!s)return null;if(w){_(!0);let r=await n(e.id,w);if(_(!1),!r.ok)return q.error(r.error||t(`settings.projects.page.toast.uploadIconFailed`)),null;a||q.success(t(`settings.projects.page.toast.iconUpdated`)),A(),C(!1)}let l=S&&!!e.iconImage;if(l){y(!0);let n=await r(e.id);if(y(!1),!n.ok)return q.error(n.error||t(`settings.projects.page.toast.removeIconFailed`)),null;a||q.success(t(`settings.projects.page.toast.iconRemoved`)),C(!1),p(null)}return{label:s,icon:c,color:u,iconBackground:dn(l?null:f),defaultModel:m??null}},[A,u,m,c,f,o,S,w,e,r,t,n]);return Z.useEffect(()=>{k(!1)},[j,a?.updatedAt]),{name:o,setName:s,icon:c,setIcon:l,color:u,setColor:d,iconBackground:f,setIconBackground:p,defaultModel:m,parsedDefaultModel:M,handleDefaultModelChange:ne,isUploadingIcon:g,isRemovingCustomIcon:v,isDiscoveringIcon:b,pendingRemoveImageIcon:S,setPendingRemoveImageIcon:C,pendingUploadIconFile:w,pendingUploadIconPreviewUrl:E,previewImageFailed:O,setPreviewImageFailed:k,hasStoredImageIcon:N,hasPendingUploadImageIcon:P,hasCustomIcon:F,effectiveHasImageIcon:I,hasRemovableImageIcon:L,showStoredImagePreview:R,showImagePreview:z,fileInputRef:ee,clearPendingUploadIcon:A,handleUploadIcon:B,handleRemoveImageIcon:H,handleDiscoverIcon:U,hasChanges:te,prepareSaveData:ie,currentIconImage:a,project:e}},pn=450,mn=(e,t)=>{let{t:n}=le(),{hasChanges:r,name:i,icon:a,color:o,iconBackground:s,defaultModel:c,pendingRemoveImageIcon:l,pendingUploadIconFile:u,isUploadingIcon:d,isRemovingCustomIcon:f,prepareSaveData:p}=e,m=Z.useRef(!1);Z.useEffect(()=>{if(!r||!i.trim()||d||f||m.current)return;let e=window.setTimeout(()=>{m.current||(m.current=!0,(async()=>{try{let e=await p({silent:!0});if(e)try{await t(e)}catch{q.error(n(`settings.projects.page.toast.saveFailed`))}}finally{m.current=!1}})())},pn);return()=>{window.clearTimeout(e)}},[o,c,r,a,s,f,d,i,t,l,u,p,n])},hn=e=>{let t=(0,an.c)(22),{project:n,onIdentitySave:r,compact:i}=e,a=i!==void 0&&i,{t:o}=le(),s=fn(n),c;bb0:{if(!n){c=null;break bb0}let e;t[0]!==n.id||t[1]!==n.path?(e={id:n.id,path:n.path},t[0]=n.id,t[1]=n.path,t[2]=e):e=t[2],c=e}let l=c;if(mn(s,r),!n||!l)return null;let u;t[3]!==n.path||t[4]!==o?(u=n.path.split(/[\\/]/).filter(Boolean).at(-1)??o(`settings.projects.page.title.default`),t[3]=n.path,t[4]=o,t[5]=u):u=t[5];let d=u,f;t[6]===d?f=t[7]:(f=(0,Q.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:d}),t[6]=d,t[7]=f);let p;t[8]===n.path?p=t[9]:(p=(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,title:n.path,children:n.path}),t[8]=n.path,t[9]=p);let m;t[10]!==f||t[11]!==p?(m=(0,Q.jsxs)(`div`,{className:`min-w-0 pr-6`,children:[f,p]}),t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;t[13]===s?h=t[14]:(h=(0,Q.jsx)(ln,{form:s}),t[13]=s,t[14]=h);let g;t[15]!==a||t[16]!==l?(g=(0,Q.jsx)(cn,{projectRef:l,collapsible:a}),t[15]=a,t[16]=l,t[17]=g):g=t[17];let _;return t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,Q.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[m,h,g]}),t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_},gn=(e,t)=>t.updatedAtMs-e.updatedAtMs,_n=i((e,t)=>({instances:[],statusesById:{},importCandidates:[],isLoading:!1,isSaving:!1,isImportsLoading:!1,initialized:!1,listenerReady:!1,error:null,load:async()=>{if(!t().isLoading){e({isLoading:!0,error:null});try{let[n,r]=await Promise.all([ke(),X()]),i={};for(let e of r.sort(gn))i[e.id]=e;t().listenerReady||await Ee(t=>{e(e=>({statusesById:{...e.statusesById,[t.id]:t}}))}),e({instances:n.instances,statusesById:i,isLoading:!1,initialized:!0,listenerReady:!0})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:String(t)})}}},loadImports:async()=>{if(!t().isImportsLoading){e({isImportsLoading:!0,error:null});try{e({importCandidates:await De(),isImportsLoading:!1})}catch(t){e({isImportsLoading:!1,error:t instanceof Error?t.message:String(t)})}}},refreshStatuses:async()=>{try{let t=await X(),n={};for(let e of t.sort(gn))n[e.id]=e;e({statusesById:n})}catch(t){e({error:t instanceof Error?t.message:String(t)})}},setInstances:async n=>{e({isSaving:!0,error:null});try{await Te({instances:n}),e({instances:n,isSaving:!1}),await t().refreshStatuses()}catch(t){throw e({isSaving:!1,error:t instanceof Error?t.message:String(t)}),t}},upsertInstance:async e=>{let n=t().instances,r=n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n];await t().setInstances(r)},createFromCommand:async(e,n,r)=>{let i=we(e,n);r&&r.trim()&&(i.nickname=r.trim()),await t().upsertInstance(i)},removeInstance:async n=>{await Y(n).catch(()=>void 0);let r=t().instances.filter(e=>e.id!==n);await t().setInstances(r),e(e=>{let t={...e.statusesById};return delete t[n],{statusesById:t}})},connect:async n=>{e({error:null});try{await Oe(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},disconnect:async n=>{e({error:null});try{await Y(n),await t().refreshStatuses()}catch(t){throw e({error:t instanceof Error?t.message:String(t)}),t}},retry:async e=>{await t().connect(e)},getStatus:e=>t().statusesById[e]||null,clearError:()=>e({error:null})})),vn=e=>{let t=(0,an.c)(20),{percent:n,tonePercent:r,className:i,expectedMarkerPercent:a}=e,o;t[0]===n?o=t[1]:(o=He(n)??0,t[0]=n,t[1]=o);let s=o,c=r??n,l;t[2]===c?l=t[3]:(l=Be(c),t[2]=c,t[3]=l);let u=l,d=a==null?null:Math.max(0,Math.min(100,a)),f;t[4]===u?f=t[5]:(f=u===`critical`?{backgroundColor:`var(--status-error)`}:u===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`},t[4]=u,t[5]=f);let p=f,m;t[6]===i?m=t[7]:(m=K(`relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden`,i),t[6]=i,t[7]=m);let h=`${s}%`,g;t[8]!==p||t[9]!==h?(g={...p,width:h},t[8]=p,t[9]=h,t[10]=g):g=t[10];let _;t[11]!==s||t[12]!==g?(_=(0,Q.jsx)(`div`,{className:`h-full transition-all duration-300`,style:g,role:`progressbar`,"aria-valuenow":s,"aria-valuemin":0,"aria-valuemax":100}),t[11]=s,t[12]=g,t[13]=_):_=t[13];let v;t[14]===d?v=t[15]:(v=d!=null&&d>0&&d<100&&(0,Q.jsx)(`div`,{className:`absolute top-0 h-full w-0.5 bg-foreground`,style:{left:`${d}%`},title:`Expected usage if spread evenly: ${Math.round(d)}% of quota`,"aria-hidden":`true`}),t[14]=d,t[15]=v);let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,Q.jsxs)(`div`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},yn=e=>{let t=(0,an.c)(67),{paceInfo:n,className:r,compact:i}=e,a=i!==void 0&&i,{t:o}=le(),s;t[0]===n.status?s=t[1]:(s=ze(n.status),t[0]=n.status,t[1]=s);let c=s,l;bb0:{switch(n.status){case`on-track`:{let e;t[2]===o?e=t[3]:(e=o(`settings.usage.pace.status.onTrack`),t[2]=o,t[3]=e),l=e;break bb0}case`slightly-fast`:{let e;t[4]===o?e=t[5]:(e=o(`settings.usage.pace.status.slightlyFast`),t[4]=o,t[5]=e),l=e;break bb0}case`too-fast`:{let e;t[6]===o?e=t[7]:(e=o(`settings.usage.pace.status.tooFast`),t[6]=o,t[7]=e),l=e;break bb0}case`exhausted`:{let e;t[8]===o?e=t[9]:(e=o(`settings.usage.pace.status.usedUp`),t[8]=o,t[9]=e),l=e;break bb0}}l=void 0}let u=l,d;t[10]!==n.predictText||t[11]!==o?(d=o(`settings.usage.pace.predictionTooltip`,{prediction:n.predictText}),t[10]=n.predictText,t[11]=o,t[12]=d):d=t[12];let f=d;if(a){let e;t[13]===r?e=t[14]:(e=K(`flex items-center gap-1.5`,r),t[13]=r,t[14]=e);let i;t[15]===c?i=t[16]:(i={backgroundColor:c},t[15]=c,t[16]=i);let a;t[17]!==u||t[18]!==i?(a=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:i,title:u}),t[17]=u,t[18]=i,t[19]=a):a=t[19];let s;t[20]===c?s=t[21]:(s={color:c},t[20]=c,t[21]=s);let l=n.isExhausted?void 0:f,d;t[22]!==n.isExhausted||t[23]!==n.predictText||t[24]!==n.remainingSeconds||t[25]!==o?(d=n.isExhausted?(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.wait`,{duration:Ve(n.remainingSeconds)})}):(0,Q.jsx)(Q.Fragment,{children:o(`settings.usage.pace.prediction`,{prediction:n.predictText})}),t[22]=n.isExhausted,t[23]=n.predictText,t[24]=n.remainingSeconds,t[25]=o,t[26]=d):d=t[26];let p;t[27]!==d||t[28]!==s||t[29]!==l?(p=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:s,title:l,children:d}),t[27]=d,t[28]=s,t[29]=l,t[30]=p):p=t[30];let m;return t[31]!==p||t[32]!==e||t[33]!==a?(m=(0,Q.jsxs)(`div`,{className:e,children:[a,p]}),t[31]=p,t[32]=e,t[33]=a,t[34]=m):m=t[34],m}let p;t[35]===r?p=t[36]:(p=K(`flex items-center justify-between gap-2`,r),t[35]=r,t[36]=p);let m;t[37]!==n.isExhausted||t[38]!==n.paceRateText||t[39]!==o?(m=!n.isExhausted&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:o(`settings.usage.pace.rate`,{rate:n.paceRateText})}),t[37]=n.isExhausted,t[38]=n.paceRateText,t[39]=o,t[40]=m):m=t[40];let h;t[41]===m?h=t[42]:(h=(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:m}),t[41]=m,t[42]=h);let g;t[43]===c?g=t[44]:(g={color:c},t[43]=c,t[44]=g);let _;t[45]!==n.isExhausted||t[46]!==n.predictText||t[47]!==n.remainingSeconds||t[48]!==f||t[49]!==u||t[50]!==o?(_=n.isExhausted?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:u}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.waitSeparator`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:Ve(n.remainingSeconds)})]}):(0,Q.jsxs)(`span`,{title:f,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:o(`settings.usage.pace.predictionLabel`)}),(0,Q.jsx)(`span`,{className:`font-medium`,children:n.predictText})]}),t[45]=n.isExhausted,t[46]=n.predictText,t[47]=n.remainingSeconds,t[48]=f,t[49]=u,t[50]=o,t[51]=_):_=t[51];let v;t[52]!==g||t[53]!==_?(v=(0,Q.jsx)(`span`,{className:`typography-micro tabular-nums`,style:g,children:_}),t[52]=g,t[53]=_,t[54]=v):v=t[54];let y;t[55]===c?y=t[56]:(y={backgroundColor:c},t[55]=c,t[56]=y);let b;t[57]!==u||t[58]!==y?(b=(0,Q.jsx)(`div`,{className:`h-2 w-2 rounded-full flex-shrink-0`,style:y,title:u}),t[57]=u,t[58]=y,t[59]=b):b=t[59];let x;t[60]!==v||t[61]!==b?(x=(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[v,b]}),t[60]=v,t[61]=b,t[62]=x):x=t[62];let S;return t[63]!==x||t[64]!==p||t[65]!==h?(S=(0,Q.jsxs)(`div`,{className:p,children:[h,x]}),t[63]=x,t[64]=p,t[65]=h,t[66]=S):S=t[66],S},bn={displayMode:`browser`,installed:!1,browserTab:!0},xn=new Set,Sn=bn,Cn=!1,wn,Tn=()=>{let e=je();return{displayMode:e,installed:e!==`browser`,browserTab:e===`browser`}},En=()=>(!Cn&&typeof window<`u`&&(Sn=Tn(),Cn=!0),Sn),$=()=>{let e=Tn();Cn=!0,e.displayMode!==Sn.displayMode&&(Sn=e,xn.forEach(e=>e()))},Dn=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=[window.matchMedia(`(display-mode: standalone)`),window.matchMedia(`(display-mode: minimal-ui)`),window.matchMedia(`(display-mode: fullscreen)`),window.matchMedia(`(display-mode: window-controls-overlay)`)];for(let t of e)typeof t.addEventListener==`function`?t.addEventListener(`change`,$):typeof t.addListener==`function`&&t.addListener($);return window.addEventListener(`appinstalled`,$),window.addEventListener(`focus`,$),()=>{for(let t of e)typeof t.removeEventListener==`function`?t.removeEventListener(`change`,$):typeof t.removeListener==`function`&&t.removeListener($);window.removeEventListener(`appinstalled`,$),window.removeEventListener(`focus`,$)}},On=e=>(xn.add(e),wn??=Dn(),$(),()=>{xn.delete(e),xn.size===0&&(wn?.(),wn=void 0)}),kn=()=>Z.useSyncExternalStore(On,En,An);function An(){return bn}var jn=`Yuri`,Mn=i()(a(e=>({sidebarBrandName:jn,setSidebarBrandName:t=>{let n=t.slice(0,64);e(e=>e.sidebarBrandName===n?e:{sidebarBrandName:n})}}),{name:`sidebar-brand-store`,storage:u(),version:3,migrate:(e,t)=>{if(!e||typeof e!=`object`)return e;let n={...e};return t<1&&n.sidebarBrandName===`YEE CODE`&&(n.sidebarBrandName=jn),t<2&&n.sidebarBrandName===`Open Chamber`&&(n.sidebarBrandName=jn),t<3&&(n.sidebarBrandName===`OPEN CHAMBER`||n.sidebarBrandName===`Open Chamber`)&&(n.sidebarBrandName=jn),n}}));typeof window<`u`&&t(e=>{n(e)&&Mn.persist.rehydrate()});var Nn=`__other__`;function Pn(e){return e.time?.updated??e.time?.archived??e.time?.created??0}function Fn({mode:e=`dialog`}){let{t}=le(),{isMobile:n,isTablet:i,hasTouchInput:a}=ve(),o=n||i||a,s=e===`page`,c=f(e=>e.isArchivedSessionsDialogOpen),l=f(e=>e.setArchivedSessionsDialogOpen),u=s||c,d=V(e=>e.projects),p=H(e=>e.archivedSessions),m=se(e=>e.setCurrentSession),h=f(e=>e.setSettingsDialogOpen),[g,_]=Z.useState(!1),[v,y]=Z.useState(null),[b,x]=Z.useState(null);Z.useEffect(()=>{if(!u){y(null),x(null);return}let e=!1;return _(!0),ie().catch(()=>{e||q.error(t(`settings.yuri.archivedSessions.toast.loadFailed`))}).finally(()=>{e||_(!1)}),()=>{e=!0}},[u,t]);let S=Z.useMemo(()=>{let e=d.map(e=>({id:e.id,normalizedPath:e.path})),n=Ue([],e,new Map,r(),p),i=new Map;for(let[e,t]of n.archivedSessionsByProject)i.set(e,[...t].sort((e,t)=>Pn(t)-Pn(e)));let a=new Set;for(let e of i.values())for(let t of e)a.add(t.id);let o=p.filter(e=>!a.has(e.id)).sort((e,t)=>Pn(t)-Pn(e));o.length>0&&i.set(Nn,o);let s=[];for(let e of d){let t=i.get(e.id)??[];t.length!==0&&s.push({projectId:e.id,label:e.label||e.path,path:e.path,sessions:t})}let c=i.get(Nn);return c&&c.length>0&&s.push({projectId:Nn,label:t(`settings.yuri.archivedSessions.otherProjects`),path:null,sessions:c}),s.sort((e,t)=>t.sessions.length-e.sessions.length||e.label.localeCompare(t.label)),s},[p,d,t]),C=p.length,w=v?S.find(e=>e.projectId===v)??null:null,T=Z.useCallback(async e=>{x(e.id);try{await ce(e.id)?q.success(t(`settings.yuri.archivedSessions.toast.restored`)):q.error(t(`settings.yuri.archivedSessions.toast.restoreFailed`))}finally{x(null)}},[t]),E=Z.useCallback(e=>{let t=U(e);m(e.id,t),l(!1),h(!1)},[m,l,h]),D=w?w.label:t(`settings.yuri.archivedSessions.dialog.title`),O=w?w.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:w.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:w.sessions.length}):t(`settings.yuri.archivedSessions.dialog.description`),k=(0,Q.jsxs)(`div`,{className:`yuri-picker-list space-y-3`,children:[w?(0,Q.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`!h-7 !px-2 !font-normal text-muted-foreground`,onClick:()=>y(null),children:[(0,Q.jsx)(J,{name:`arrow-left-s`,className:`mr-1 h-4 w-4`}),t(`settings.yuri.archivedSessions.dialog.backToProjects`)]}):null,g?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 typography-meta text-muted-foreground py-6`,children:[(0,Q.jsx)(J,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),t(`settings.yuri.archivedSessions.dialog.loading`)]}):w?w.sessions.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.emptyProject`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:w.sessions.map(e=>{let n=U(e),r=Pn(e),i=b===e.id;return(0,Q.jsxs)(`div`,{className:`yuri-picker-row flex flex-col gap-2 rounded-lg border border-border/60 px-3 py-2.5 sm:flex-row sm:items-center sm:gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.title||t(`sessions.sidebar.session.untitled`)}),(0,Q.jsxs)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[r>0?Ae(r):null,r>0&&n?` · `:null,n?G(n):null]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,Q.jsx)(W,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>E(e),children:t(`settings.yuri.archivedSessions.actions.preview`)}),(0,Q.jsxs)(W,{type:`button`,variant:`default`,size:`xs`,className:`!font-normal`,disabled:i,onClick:()=>void T(e),children:[i?(0,Q.jsx)(J,{name:`loader-4`,className:`mr-1 h-3.5 w-3.5 animate-spin`}):(0,Q.jsx)(J,{name:`inbox-unarchive`,className:`mr-1 h-3.5 w-3.5`}),t(`settings.yuri.archivedSessions.actions.restore`)]})]})]},e.id)})}):S.length===0?(0,Q.jsx)(`div`,{className:`yuri-picker-empty rounded-lg border border-dashed border-border p-4 typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.dialog.empty`)}):(0,Q.jsx)(`div`,{className:`yuri-picker-rows space-y-1.5`,children:S.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>y(e.projectId),className:K(`yuri-picker-row flex w-full items-center gap-3 rounded-lg border border-border/60 px-3 py-2.5 text-left`,`hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),children:[(0,Q.jsx)(J,{name:`folder`,className:`h-4 w-4 shrink-0 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`yuri-picker-label typography-ui-label font-medium text-foreground truncate`,children:e.label}),e.path?(0,Q.jsx)(`div`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:G(e.path)}):null]}),(0,Q.jsx)(`span`,{className:`typography-meta tabular-nums text-muted-foreground shrink-0`,children:e.sessions.length===1?t(`settings.yuri.archivedSessions.dialog.sessionCountSingle`,{count:e.sessions.length}):t(`settings.yuri.archivedSessions.dialog.sessionCountPlural`,{count:e.sessions.length})}),(0,Q.jsx)(J,{name:`arrow-right-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]},e.projectId))}),!w&&!g&&C>0?(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(C===1?`settings.yuri.archivedSessions.summarySingle`:`settings.yuri.archivedSessions.summaryPlural`,{count:C})}):null]});return s?(0,Q.jsxs)(`div`,{"data-settings-item":`archived-sessions.manage`,className:`yuri-settings-section-stack`,children:[(0,Q.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.yuri.archivedSessions.description`)}),k]}):o?(0,Q.jsx)(Me,{open:c,title:D,onClose:()=>l(!1),contentMaxHeightClassName:`max-h-[min(80vh,640px)]`,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border/40 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:D}),e]}),(0,Q.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:O})]}),children:k}):(0,Q.jsx)(pe,{open:c,onOpenChange:l,children:(0,Q.jsxs)(de,{presentation:`picker`,children:[(0,Q.jsx)(ue,{className:`yuri-picker-header`,children:(0,Q.jsx)(fe,{className:`yuri-picker-title truncate`,children:D})}),k]})})}function In(){let e=(0,an.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(Fn,{mode:`dialog`}),e[0]=t):t=e[0],t}export{ut as _,yn as a,hn as c,Kt as d,Wt as f,lt as g,st as h,kn as i,on as l,Lt as m,Fn as n,vn as o,Gt as p,Mn as r,_n as s,In as t,rn as u};
@@ -1,4 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-CiwwBt7K.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-auth-DA-qfGHk.js","assets/platform-z1TeG-ky.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CTekDqaS.js","assets/vendor-base-ui-wXsskyKm.js","assets/prompt-attachment-upload-BG4nBKxi.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-file-resource-COtIWnSi.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-DIb_ItL-.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/summaries-BQMyJaaw.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-C4dE7Hgl.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{a as r}from"./vendor-zustand-CTekDqaS.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{St as o}from"./gitApiHttp-Be5VpQHC.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as s,R as c,Wt as l,Xt as u,at as d,dr as f,en as p,it as m,n as h,nr as g,on as _,rt as v,tn as y,tr as b}from"./client-i5Q82JUc.js";import{t as x}from"./pathNormalization-ewtPqJWn.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{A as T,E as ee,I as E,R as D,W as O,k}from"./runtime-file-resource-COtIWnSi.js";import{r as te}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as A}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as j}from"./useUIStore-Dz0bOfkB.js";import{s as M}from"./spacedFileMention-Ds4GtgiF.js";import{An as N,Ba as P,Bn as F,Fa as ne,Gi as I,Ir as L,Ji as R,Ki as re,Lr as ie,Pr as ae,Rn as oe,Rr as z,Tt as se,U as B,Ua as V,V as ce,Vn as le,W as ue,Yi as de,Yn as H,Yt as fe,_i as pe,_t as me,dn as he,f as U,ft as ge,gi as _e,gt as ve,hi as ye,ht as be,ir as xe,j as Se,kn as Ce,mi as we,mn as W,mt as Te,ni as Ee,no as G,oi as De,pt as Oe,ri as ke,t as K,ta as Ae,ti as je,ur as Me,ut as Ne,vi as q,vr as J,xt as Pe,zn as Fe}from"./ui-DeV7Us1B.js";import{n as Y}from"./Icon-C1m8PihJ.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-CuuZggLJ.js";import{t as ze}from"./i18n-CBCskgqa.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-DIkp2MKc.js";import{t as He}from"./MobileResizableSheet-CcOOlg4R.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-Cv20xnEj.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-Cdy71vjH.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-B_P1dDl7.js";import{n as et}from"./useProjectRuntimeAPIs-Fi6XrG43.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-BH7j-M9u.js";import{o as at,t as ot}from"./useProjectGitStore-C6ZCDvmO.js";import{t as st}from"./input-CY-NU-bG.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-LzFeQCyX.js";import{t as ut}from"./MobileOverlayPanel-XkMrn5-W.js";import{t as dt}from"./githubAuthQueries-Dli4cDU7.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-XchvRN9O.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-BJrbhZ4m.js";import{s as St}from"./remote-input-store-CiwwBt7K.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-Bq5JCAvR.js";import{f as Tt,m as Et}from"./auto-read-context-C8RimaOE.js";var Dt=2e3,Ot=r((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(a(),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,x(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>O.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=u();if(!n)return!1;let r=n.getTranscript(_(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>z()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=le.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=Pe(),r=B(),i=ce(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=u();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=_(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),c=(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}};oe(a,t),Se(n,t),n.setState(a);for(let n of t)p(e,n)},[i]),d=(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),c(e,t)}return r},[e,c]),m=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=d(n),s=Fe(a.getState()),l=L(),f=F({seen:o,keep:t,limit:l,preserve:s});if(c(n,f),ie()){let e=new Set([t,...o,...s]),r=(u()?.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);c(n,i)}}},[i,e,d,c,r]),g=(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}),c=o.getState(),l=c.session_status?.[t],d=c.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await s(a,t):await y(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=u()?.getTranscript(_(a,t));W({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await J({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:d,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),v=(0,X.useCallback)(async(t,n)=>{await se();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o);m(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=u(),a=_(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,d=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},p=le.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&d.kind!==`unknown`&&m?.status!==`error`&&p&&ae(o,t)){W({directory:o,sessionID:t,store:s,isStale:e});return}let h=!!(r||!l||p),v=Rt({hasSession:p,shouldLoadMessages:h,force:!!r});await Promise.all([v?(async()=>{try{let n=await re(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=I(f(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),h?g(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,m,g,e]),b=te(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,p=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(f)),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});!p||d()||s.setState(e=>{let t=Nt(e.session,p,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;l(_(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),ee=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),E=te(async(r,a)=>{if(!r)return;await se();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),d=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await y(o,r),d())return;W({directory:o,sessionID:r,store:s}),await J({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(u()?.getTranscript(_(o,r)).messageOrder.length??0)>0,isStale:d})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:v,syncSession:v,loadChildren:b,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:E,optimistic:{add:w,remove:T,confirm:ee}}),[v,b,x,S,C,E,w,T,ee])}var Z=S(),Q=i(),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=be(e??``,t),i=ve(e??``,t),a=Ne(e??``,t),o=Oe(e??``,t),s=Te(e??``,t),c=me(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 r=V.getState().remoteSession,i=E(),a=await Re();if(i.assertCurrent(),!a.supported||a.hubId!==e.hubId||!a.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 o=Ie(a);await o.connectHost(e.hostId);let s=o.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),c=E(s),l=xe(s);if(!await l.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let u=await Ee(e,s),f=u.commands,p=Array.isArray(f)?f.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>De(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,h=await l.getGitStatus(e.path),g=await l.getGitBranches(e.path),_=await l.listGitWorktrees(e.path),y=x(e.path),b=_.map(e=>x(e.path)).filter(e=>y===e||y.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=b?y.slice(b.length):``,C=(g.branches?.[h.current]?.tracking||h.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...p?{startCommand:p}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},ee=await l.previewGitWorktree(e.path,T);if(!ee.path)throw Error(`Remote worktree preview missing path`);let D=ye();q(D).catch(()=>void 0);let O=S?`${ee.path.replace(/[\\/]+$/,``)}${S}`:ee.path,k={...s.location,directory:O},te={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:u.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:D,bootstrapPendingDirectory:O,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(k,n.initialPrompt),c.assertCurrent()}catch(e){throw _e(D,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&V.getState().remoteSession===r&&V.getState().openRemoteSession(e,k,null,te);let j=V.getState().remoteSession,M=j?.draft?.pendingWorktreeRequestId===D,N=()=>{if(!n.isSelected()||!M)return!1;let t=V.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===D?(j=t,!0):t===j};try{let r=await l.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`&&u.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),c.assertCurrent(),i=await l.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);c.assertCurrent();let f=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...s.location,directory:f},g={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:f,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||h.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:u.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(f!==O){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await A(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-CiwwBt7K.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,27])),n=e(p),r=t(k,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`);c.assertCurrent()}!n.createSession&&N()&&j&&(V.getState().updateRemoteDraft(j,g,p),j=V.getState().remoteSession),n.createSession||pe(D,f);let _;if(n.createSession)try{let t=o.resolve(p).service(),r=N()?j?.draft?.title??n.title:n.title,i=await t.createSession({title:r},f);_=i.id,c.assertCurrent();let a=await t.getConfig(f).catch(()=>void 0);c.assertCurrent();let s=e.defaultModel||a?.model,l=typeof s==`string`?s:void 0,u=l?.indexOf(`/`)??-1,h=u>0?l.slice(0,u):m(i),g=u>0?l.slice(u+1):v(i),y=a?.default_agent||i.agent,b=typeof y==`string`?y:void 0,x=Ae.getState();h&&g&&x.saveSessionModelSelection(i.id,h,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&h&&g&&(x.saveAgentModelForSession(i.id,b,h,g,p),x.saveAgentModelVariantForSession(i.id,b,h,g,d(i),p))}catch(t){throw await l.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return c.assertCurrent(),n.createSession&&N()&&V.getState().openRemoteSession(e,p,_??null,{...j?.draft,...g}),n.createSession&&pe(D,f),{path:f,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw N()&&j&&V.getState().updateRemoteDraft(j,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),_e(D,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=P.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 ke(e)&&await we(t)},gn=e=>{let t=dn(e),n=P.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=P.getState().projects.find(e=>e.id===t.id)??P.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=R(t.path);await de.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=de.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(de.getState()),Ae.getState())}catch{}},yn=async(e,t,n)=>{let r=U.getState(),i=de.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),o.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=P.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 K.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 K.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 K.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return K.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`,s=U.getState();s.newSessionDraft?.open?s.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:s.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):s.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&&(U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(c.path,{showOverlay:!1}));let l=await je(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return pe(t,u.path),U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=U.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(_e(n,e instanceof Error?e:Error(t)),U.getState().resolvePendingDraftWorktreeTarget(n,null)),U.getState().setDraftBootstrapPendingDirectory(null),K.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=P.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 K.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 K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await je(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 U.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 K.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=G(`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=G(`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)(Y,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=G(`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=G(`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=G(`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=G(`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=G(`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?M(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,ee]=X.useState(!1),[E,D]=X.useState(``),[O,k]=X.useState(!1),[te,A]=X.useState(!1),[j,N]=X.useState(``),[P,F]=X.useState(!1),ne=X.useRef(null),I=X.useId(),L=S??T,R=e=>{S===void 0&&ee(e),x?.(e)},re=X.useCallback(e=>{e.stopPropagation()},[]),ie=o.length>1,ae=!!(g||_),oe=X.useMemo(()=>In(j),[j]),z=X.useMemo(()=>{let e=E.trim();return e?M(m,e,e=>e.label).map(e=>e.item):m},[E,m]),se=X.useMemo(()=>{if(!p)return!1;let e=E.trim();return!e||M([p],e,e=>[e.label,b??``]).length>0},[b,p,E]),B=t=>{if(t===e){R(!1);return}i(t),R(!1),D(``)},V=e=>{g?.(e),R(!1),D(``)},ce=()=>{k(!0),setTimeout(()=>ne.current?.focus(),50)},le=async()=>{if(!(!oe||P)){if(ie){A(!0);return}F(!0);try{await a(oe,o[0]),N(``),k(!1),R(!1)}finally{F(!1)}}},ue=async e=>{if(!(!oe||P)){F(!0);try{await a(oe,e),N(``),k(!1),A(!1),R(!1)}finally{F(!1)}}},de=()=>{A(!1)},fe=()=>{N(``),k(!1),A(!1)};X.useEffect(()=>{L||(D(``),k(!1),A(!1),N(``))},[L]);let pe=u||e||w(`gitView.branch.detachedHead`),me=d??(c?`end`:`start`),he=v??w(`chat.chatInput.worktrees`),U=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":pe,children:(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(H,{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":pe,children:[(0,Q.jsx)(Y,{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:pe}),(0,Q.jsx)(Y,{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:E,onValueChange:D,onKeyDown:re})}),(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:te?(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:de,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{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:oe}),` `,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:()=>ue(e),disabled:P,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:[P?(0,Q.jsx)(Y,{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))})]}):O?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:ne,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:j,onChange:e=>N(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{re(e),e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),fe())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:le,disabled:!oe||P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:P?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:fe,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(Y,{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:E,local:!0,currentBranch:e,branchInfo:r,onCheckout:B}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:E,onCheckout:B}),ae?(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:he}),_?(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(),R(!1),_()},children:U}):null]}),p&&se?(0,Q.jsxs)(jn,{onSelect:()=>V(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:z,selectedDirectory:h,onSelect:V})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>R(!0),"data-popup-open":L?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${I}`,open:L,onOpenChange:R,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:L,onOpenChange:R,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?pe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:me,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=M(t,i,e=>e),o=M(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=E(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})=>E(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=D(),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,O),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 E(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,l=i.pr;if(!s&&!l)return;let u=s?`issue`:`pr`,d=s?.number??l.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:l.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 Me(e,h).state.send({sessionID:r,messageID:c(`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=ee(),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)(T.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)(H,{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)(H,{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)(k,{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=P(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=j(e=>e.isMobile),o=ee(),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=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=P(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([]),[D,O]=X.useState(!1),[k,A]=X.useState(!1),[M,N]=X.useState(null),[F,ne]=X.useState(null),[I,L]=X.useState(null),[R,re]=X.useState(!1),[ie,ae]=X.useState(new Map),[oe,z]=X.useState(1),[se,B]=X.useState(!1),V=X.useRef(0),ce=ct(x,350),le=te(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){O(!0),N(null),z(1),B(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),z(t.page??1),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),z(t.page??1),B(!!t.hasMore))}}catch(e){N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{O(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!ce.trim()){le();return}let t=new AbortController;O(!0),N(null),z(1),B(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:ce.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:ce.trim()}):null;if(!n){O(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),z(e.page??1),B(!!e.hasMore)):`prs`in e&&(e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),z(e.page??1),B(!!e.hasMore))))}).catch(e=>{t.signal.aborted||N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||O(!1)}),()=>t.abort()},[e,_,l,f,d,y,ce,le,i]);let ue=te(async()=>{if(!(!_||!l)&&!(D||k)&&se){A(!0);try{let e=oe+1;if(y===`issues`&&l.issuesList){let t=ce.trim()?await l.issuesList(_,{page:e,query:ce.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),z(t.page??e),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=ce.trim()?await l.prsList(_,{page:e,query:ce.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),z(t.page??e),B(!!t.hasMore))}}catch{}finally{A(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),ne(null),L(null),re(!1),N(null),ae(new Map),z(1),B(!1);return}le()},[e,le]),X.useEffect(()=>{V.current+=1,ae(new Map)},[_,v]);let de=te(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(ie.has(t))return;let n=V.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==V.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ae(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!==V.current)return;ae(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){K.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{ne(e),L(null)},he=e=>{L(e),ne(null)},U=()=>{F?n({type:`issue`,item:F}):I&&n({type:`pr`,item:I,includeDiff:R}),t(!1)},ge=()=>{ne(null),L(null),re(!1)},_e=F||(I?.head&&_?ie.get(Jn(_,I.head))?.isValid!==!1:!1),ve=e=>!e.head||(_?ie.get(Jn(_,e.head)):void 0)?.isValid===!1,ye=(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)(H,{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)(Y,{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:[D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),M&&(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)(Y,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:M})]})}),!D&&!M&&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:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,F?.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`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!D&&!M&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ve(e),n=e.head&&_?ie.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,I?.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`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{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)(Y,{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)(H,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),be=(0,Q.jsxs)(`div`,{className:G(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(F||I)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Y,{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:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&I&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:R,onChange:e=>re(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:G(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(H,{size:`sm`,onClick:U,disabled:!_e,className:G(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?be: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)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(F||I)&&(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)(Y,{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:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:ye}):(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)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),ye,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:be})]})})})}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=P(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=ee(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=j(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=P(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),T=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),E=at(e=>e.fetchBranches),D=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),k=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),te=U(e=>e.availableWorktreesByProject),A=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},O),M=X.useMemo(()=>{if(!h)return new Set;let e=s?A.data??[]:te.get(h)??[];return new Set(e.map(e=>e.name))},[te,h,s,A.data]),N=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!M.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[M]),[F,I]=X.useState(!1),[L,R]=X.useState(!1),[re,ie]=X.useState(!1),[ae,oe]=X.useState(!1),[z,se]=X.useState(!1),[B,ce]=X.useState(``),[le,ue]=X.useState(``),pe=X.useRef(null),me=X.useRef(null),ge=X.useRef(null),_e=X.useRef(null),ve=X.useCallback(e=>{e.stopPropagation()},[]),ye=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},[]),be=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),xe=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;be(t)},[be]),Se=X.useCallback(e=>{let t=ye(e.current);be(t)},[ye,be]),Ce=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:B}),[D,k,B]),W=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:le}),[D,k,le]),Te=B.trim().length>0,Ee=le.trim().length>0,De=Ce.matching.length>0,Oe=W.matching.length>0,Me=!!(h&&a),Ne=X.useCallback(()=>{!h||!a||E(h,a)},[h,a,E]);X.useEffect(()=>{!e||!h||!a||C?.all||E(h,a)},[e,h,a,C?.all,E]),X.useEffect(()=>{!L&&!ae&&ce(``)},[L,ae]),X.useEffect(()=>{!re&&!z&&ue(``)},[re,z]),X.useEffect(()=>{L&&xe(pe),ae&&Se(ge)},[L,ae,B,xe,Se]),X.useEffect(()=>{re&&xe(me),z&&Se(_e)},[re,z,le,xe,Se]);let[q,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Pe,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=de.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=de.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=ne(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=de.getState(),r=ne(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=de.getState(),n=Ae.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){K.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 U.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.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 U.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.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:``}),R(!1),ie(!1),oe(!1),se(!1),ce(``),ue(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=N();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,N]),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||!q.touched||Pe)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,D,k):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,D,k,q.touched,Ie,Pe,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!q.touched||Pe)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,q.touched,Pe]);let it=async()=>{if(!g||!h){K.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){K.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){K.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;P.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,D,k):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:()=>P.getState().activeProjectId===l.id});s.sdk();let g=V.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),K.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=>{K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([je(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,D,k);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 ke(g)&&await we(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await fe(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),he(a.id,e).catch(()=>void 0);try{U.getState().initializeNewYuriSession(a.id,de.getState().agents)}catch{}}else t(!1),Fe(!1);let ee=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});ee&&localStorage.setItem(xt,ee),K.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`);K.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`);K.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&&!q.branchError&&!q.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!q.branchError&&!q.worktreeError)&&!Pe,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(A.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(A.error||l.error)?.message,(0,Q.jsx)(H,{size:`xs`,variant:`ghost`,onClick:()=>{A.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:G(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,className:G(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:G(`gap-1.5`,u&&`flex-1`),children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`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)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{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)(H,{variant:`outline`,size:`sm`,onClick:()=>oe(!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)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:ae,title:i(`session.newWorktree.selectBranch`),onClose:()=>oe(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ge,children:[(0,Q.jsx)(st,{value:B,onChange:e=>ce(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.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:[Te&&De&&(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:Ce.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`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}`))})]}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.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(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`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))})]}),Ce.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(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`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)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{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:G(`h-8`,q.touched&&q.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)(Y,{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)(Y,{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:G(`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)(Y,{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:G(`h-8`,q.touched&&q.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)(H,{variant:`outline`,size:`sm`,onClick:()=>se(!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)(Y,{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:z,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>se(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:_e,children:[(0,Q.jsx)(st,{value:le,onChange:e=>ue(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.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:[Ee&&Oe&&(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:W.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),se(!1)},className:G(`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}`))})]}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.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(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),se(!1)},className:G(`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))})]}),W.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(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),se(!1)},className:G(`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)(Y,{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)(Y,{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)(Y,{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)(Y,{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)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{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:L,onOpenChange:R,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{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:pe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:B,onValueChange:ce,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Te&&De&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ce.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})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Te&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ce.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ce.otherLocal.length>0||Te)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ce.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{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)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{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:G(`h-8`,q.touched&&q.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)(Y,{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)(Y,{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:G(`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)(Y,{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:G(`h-8`,q.touched&&q.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:re,onOpenChange:ie,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{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:me,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:le,onValueChange:ue,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Ee&&Oe&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:W.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Ee&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:W.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(W.otherLocal.length>0||Ee)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:W.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ie(!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)(Y,{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)(Y,{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)(Y,{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:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:`gap-1.5`,children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:F,onOpenChange:I,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`?!g(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`||g(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=Ce(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(!N(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=U(e=>e.currentSessionId),i=U(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=ue(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=U(c),u=Ne(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`&&!b(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=ge(f??``,o??void 0,a??void 0),g=ge(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,x=!!(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=Oe(a??``,o??void 0),w=Te(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),ee=U(T),{phase:E,isWorking:D}=nn(a,o??void 0),O=!!(d.error&&d.index>p.index),k=be(a??``,o??void 0),te=k?.type===`retry`?k.attempt:void 0,A=k?.type===`retry`?k.next:void 0,j=X.useMemo(()=>Kr(S),[S]),M=X.useMemo(()=>{let e=!!(ee&&!ee.acknowledged);return{wasAborted:e,abortActive:e}},[ee]),N=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:D};if(O&&E!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:D};if(M.wasAborted)return{...Fr,wasAborted:!0,abortActive:M.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(x)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=D,t=E===`busy`,r=E===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(j.activePartType===`tool`||j.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:te,next:A,message:k?.type===`retry`?k.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(j.activePartType===`tool`||j.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):j.statusText:null,isGenericStatus:!e||!i&&j.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?j.activePartType:void 0,activeToolName:e&&!i?j.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,O,E,D,x,_,v?.status,y,j,M,te,A,k,n]);return{forming:X.useMemo(()=>({isActive:!s&&!O&&D&&j.activePartType===`text`,characterCount:0}),[s,O,D,j.activePartType]),working:X.useMemo(()=>{if(s||N.wasAborted||N.abortActive)return N;if(l)return{...N,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?N:t?{...N,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...N,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,N,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=G(`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};
@@ -1,3 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{L as n,s as r}from"./platform-z1TeG-ky.js";import{o as i}from"./vendor-zustand-CTekDqaS.js";import{ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{Lt as s,n as c}from"./client-i5Q82JUc.js";import{n as l}from"./pathNormalization-ewtPqJWn.js";import{n as u}from"./vendor-react-BkccXcWz.js";import{o as d,s as f,u as p}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as m,G as h,O as g}from"./runtime-file-resource-COtIWnSi.js";import{h as _,r as v,u as y}from"./vendor-reactuses-core-DjKFMfz7.js";import{n as b,r as x,t as S}from"./useUIStore-Dz0bOfkB.js";import{r as C}from"./vendor-sonner-DX3nfJx4.js";import{Ba as w,Qr as T,U as E,Ua as D,W as O,Yn as k,at as A,f as j,hn as M,ir as N,no as ee,pn as te,pr as ne,to as P,ur as F}from"./ui-DeV7Us1B.js";import{n as I}from"./Icon-C1m8PihJ.js";import{t as L}from"./i18n-CBCskgqa.js";import{n as R}from"./react-CPBNl-S9.js";import{n as z}from"./useEffectiveDirectory-BnoYSkb7.js";import{n as B}from"./useProjectRuntimeAPIs-Fi6XrG43.js";import{a as re,o as ie,r as V,s as ae}from"./useProjectGitStore-C6ZCDvmO.js";import{t as oe}from"./AgentAvatar-COZrpK6y.js";import{i as H,n as U,r as W,t as G}from"./card-alsnQayp.js";import{g as K,h as q,m as J,t as se,v as ce}from"./ChatContainer-C_-17prp.js";import{f as le,g as ue,h as Y,m as X,p as de}from"./ToolOutputDialog-BK0D8GxM.js";var Z=u(),Q=t(o(),1),$=a(),fe=class extends Q.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){this.setState({error:e,errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0})};render(){return this.state.hasError?(0,$.jsx)(`div`,{className:`flex items-center justify-center min-h-screen p-4`,children:(0,$.jsxs)(G,{className:`w-full max-w-md`,children:[(0,$.jsx)(W,{className:`text-center`,children:(0,$.jsxs)(H,{className:`flex items-center justify-center gap-2 text-destructive`,children:[(0,$.jsx)(I,{name:`chat-3`,className:`h-5 w-5`}),this.props.texts.title]})}),(0,$.jsxs)(U,{className:`space-y-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center`,children:this.props.texts.description}),this.props.sessionId&&(0,$.jsxs)(`div`,{className:`text-xs text-muted-foreground text-center`,children:[this.props.texts.sessionLabel,`: `,this.props.sessionId]}),this.state.error&&(0,$.jsxs)(`details`,{className:`text-xs font-mono bg-muted p-3 rounded`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:bg-interactive-hover/80`,children:this.props.texts.detailsSummary}),(0,$.jsx)(`pre`,{className:`mt-2 max-h-48 overflow-auto`,children:this.state.error.toString()})]}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsxs)(k,{onClick:this.handleReset,variant:`outline`,className:`flex-1`,children:[(0,$.jsx)(I,{name:`restart`,className:`h-4 w-4 mr-2`}),this.props.texts.resetAction]})}),(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground text-center`,children:this.props.texts.persistentHint})]})]})}):this.props.children}};function pe(e){let t=(0,Z.c)(22),{t:n}=L(),r;t[0]===n?r=t[1]:(r=n(`chat.errorBoundary.title`),t[0]=n,t[1]=r);let i;t[2]===n?i=t[3]:(i=n(`chat.errorBoundary.description`),t[2]=n,t[3]=i);let a;t[4]===n?a=t[5]:(a=n(`chat.errorBoundary.sessionLabel`),t[4]=n,t[5]=a);let o;t[6]===n?o=t[7]:(o=n(`chat.errorBoundary.detailsSummary`),t[6]=n,t[7]=o);let s;t[8]===n?s=t[9]:(s=n(`chat.errorBoundary.resetAction`),t[8]=n,t[9]=s);let c;t[10]===n?c=t[11]:(c=n(`chat.errorBoundary.persistentHint`),t[10]=n,t[11]=c);let l;t[12]!==r||t[13]!==i||t[14]!==a||t[15]!==o||t[16]!==s||t[17]!==c?(l={title:r,description:i,sessionLabel:a,detailsSummary:o,resetAction:s,persistentHint:c},t[12]=r,t[13]=i,t[14]=a,t[15]=o,t[16]=s,t[17]=c,t[18]=l):l=t[18];let u;return t[19]!==e||t[20]!==l?(u=(0,$.jsx)(fe,{...e,texts:l}),t[19]=e,t[20]=l,t[21]=u):u=t[21],u}var me=1440,he=e=>{let t=(0,Z.c)(10),{isMobile:n,isVSCode:r,directory:i}=e,a=y(`(min-width: ${me}px)`),o;t[0]===i?o=t[1]:(o=i?b(i):``,t[0]=i,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=e=>{let t=S(e,s);return t?.isOpen?(t.tabs.find(e=>e.id===t.activeTabId)??t.tabs[t.tabs.length-1]??null)?.mode!==`chat`:!1},t[2]=s,t[3]=c);let l=x(c),u=x(ge),d;t[4]===s?d=t[5]:(d=e=>e.isRightSidebarOpen&&!!S(e,s)?.isOpen,t[4]=s,t[5]=d);let f=x(d),p=!n&&!r&&!l&&!f,m=p&&a,h=u&&m,g;return t[6]!==m||t[7]!==p||t[8]!==h?(g={visible:h,fits:m,layoutAllows:p},t[6]=m,t[7]=p,t[8]=h,t[9]=g):g=t[9],g};function ge(e){return e.workStatusPanelEnabled}var _e=async({directory:e,sessionID:t,signal:n})=>{let r=await c.getScopedSdkClient(e).session.list({directory:e,parentID:t,limit:200},{signal:n});if(!Array.isArray(r?.data))throw Error(`session.list children returned no data`);return r.data.flatMap(e=>{if(!e?.id)return[];let t=typeof e.title==`string`?e.title:void 0;return[{id:e.id,title:t}]})},ve=(e,t,n={})=>{let r=n.entry,i=n.listChildren??(r?async({directory:e,sessionID:t,signal:n})=>{let i=await r.sdk().session.list({directory:e,parentID:t,limit:200},{signal:n});if(r.sdk(),!Array.isArray(i?.data))throw Error(`session.list children returned no data`);return i.data.map(e=>({id:e.id,title:e.title}))}:_e);return d({queryKey:[...h.workStatusChildren.list(e,t,n.transport),...r?.queryScope??[]],enabled:!!(e&&t),queryFn:({signal:n})=>i({directory:e,sessionID:t,signal:n}),staleTime:5e3,refetchInterval:1e4})},ye=[],be=(...e)=>{let t=K(...e);return t?t.charAt(0).toUpperCase()+t.slice(1):``},xe=(...e)=>{for(let t of e){if(!t||typeof t!=`object`)continue;let e=t.description;if(typeof e!=`string`)continue;let n=e.trim();if(n)return n}return``},Se=e=>e===`pending`||e===`running`,Ce=e=>{let t=[],n=new Set;for(let r of e.messageOrder){let i=e.partsByMessageID[r];if(i)for(let e of i){if(!e?.id||n.has(e.id))continue;if(e.type===`tool`&&J(e.tool)){n.add(e.id);let r=e.state;t.push({id:e.id,sessionID:q(e),label:be(r?.input,r?.metadata,e.metadata),description:xe(r?.input,e.metadata,r?.metadata),running:Se(r?.status)});continue}if(e.type!==`subtask`)continue;let r=e,i=typeof r.taskSessionID==`string`?r.taskSessionID.trim():``,a=typeof r.agent==`string`?r.agent.trim():``,o=typeof r.description==`string`?r.description.trim():``;n.add(e.id),t.push({id:e.id,sessionID:i||void 0,label:a?a.charAt(0).toUpperCase()+a.slice(1):``,description:o,running:Se(r.status)})}}return t.length===0?ye:t},we=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(!r||!i||r.id!==i.id||r.sessionID!==i.sessionID||r.label!==i.label||r.description!==i.description||r.running!==i.running)return!1}return!0},Te=e=>e.childTitle||e.description||e.agent,Ee=e=>({key:e.key,sessionID:e.sessionID,seed:e.key,label:Te(e),phase:e.working?`working`:`done`}),De=(e,t,n)=>{let r=new Map(t.map(e=>[e.id,e])),i=new Set,a=[],o=new Map,s=e=>{let t=e.sessionID;if(!t){a.push(e);return}i.add(t);let n=o.get(t);if(n===void 0){o.set(t,a.length),a.push({...e,key:t,sessionID:t});return}let r=a[n];r&&(a[n]={...r,description:r.description||e.description,agent:r.agent||e.agent,childTitle:e.childTitle||r.childTitle,working:r.working||e.working})};for(let t of e){let e=t.sessionID?r.get(t.sessionID):void 0;s({key:t.id,sessionID:t.sessionID,description:t.description,agent:t.label,childTitle:e?.title?.trim()||``,working:t.running||!!e?.busy||!!(t.sessionID&&n?.has(t.sessionID))})}for(let e of t)i.has(e.id)||s({key:e.id,sessionID:e.id,description:``,agent:``,childTitle:e.title?.trim()||``,working:e.busy});let c=a.map(Ee),l=c.filter(e=>e.phase===`working`),u=c.filter(e=>e.phase===`done`);return l.length===0?u:u.length===0?l:[...l,...u]},Oe=new Set,ke=e=>{if(!e)return``;let t=[];for(let n of Object.keys(e)){let r=e[n]?.type;(r===`busy`||r===`retry`)&&t.push(n)}return t.sort(),t.join(`
2
- `)},Ae=(e,t)=>{let n=(0,Z.c)(4),r;n[0]===t?r=n[1]:(r=e=>t?ke(e.session_status):``,n[0]=t,n[1]=r);let a=i(e,r),o;return n[2]===a?o=n[3]:(o=a?new Set(a.split(`
3
- `)):Oe,n[2]=a,n[3]=o),o},je=(e,t)=>{let n=[];for(let r of e)!r.id||r.parentID!==t||n.push(`${r.id}\u0001${r.title??``}`);return n.join(``)},Me=e=>e?e.split(``).map(e=>{let t=e.indexOf(``);return{id:e.slice(0,t),title:e.slice(t+1)}}):[],Ne=(e,t,n)=>{let r=new Map;for(let t of e)t.id&&r.set(t.id,{id:t.id,title:t.title,busy:n.has(t.id)});for(let e of t??[]){if(!e.id)continue;let t=r.get(e.id),i=e.title?.trim()||t?.title;r.set(e.id,{id:e.id,title:i,busy:n.has(e.id)})}return[...r.values()]},Pe=(e,t)=>{let n=(0,Z.c)(18),r=!!(e&&t),a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a={bootstrap:!1},n[0]=a):a=n[0];let o=E(t||void 0,a),c;n[1]!==r||n[2]!==e?(c=t=>r&&e?je(t.session,e):``,n[1]=r,n[2]=e,n[3]=c):c=n[3];let l=i(o,c),u=t??``,d=e??``,p;n[4]!==u||n[5]!==d?(p=ve(u,d),n[4]=u,n[5]=d,n[6]=p):p=n[6];let m;n[7]!==r||n[8]!==p?(m={...p,enabled:r},n[7]=r,n[8]=p,n[9]=m):m=n[9];let h=f(m),g;n[10]===r?g=n[11]:(g={enabled:r},n[10]=r,n[11]=g);let _=s(e??``,t??``,o,Ce,we,g),v=Ae(o,r),y;bb0:{if(!e){let e;n[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[12]=e):e=n[12],y=e;break bb0}let t;n[13]!==v||n[14]!==l||n[15]!==h.data||n[16]!==_?(t=De(_,Ne(Me(l),h.data,v),v),n[13]=v,n[14]=l,n[15]=h.data,n[16]=_,n[17]=t):t=n[17],y=t}return y},Fe=[],Ie=e=>{let t=(0,Z.c)(11),{sessionId:n,directory:r}=e,i;t[0]===n?i=t[1]:(i=e=>(n?e.todo[n]:void 0)??Fe,t[0]=n,t[1]=i);let a=O(i,r??void 0),o;t[2]===n?o=t[3]:(o=e=>{let t=n?e.session_status?.[n]?.type:void 0;return t===`busy`||t===`retry`},t[2]=n,t[3]=o);let s=O(o,r??void 0),c;t[4]===n?c=t[5]:(c=e=>n?e.sessions[n]?.todos:void 0,t[4]=n,t[5]=c);let l=M(c),u=A(n??``,r??void 0)??(a.length>0?a:l??Fe),d;t[6]===u?d=t[7]:(d=u.filter(ze),t[6]=u,t[7]=d);let f=d,p;return t[8]!==s||t[9]!==f?(p=(0,$.jsx)(Re,{todos:f,isWorking:s}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p},Le=e=>{let t=(0,Z.c)(6),n,r;t[0]===e?(n=t[1],r=t[2]):({remote:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=r?(0,$.jsx)(Re,{...r}):(0,$.jsx)(Ie,{...n}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i},Re=e=>{let t=(0,Z.c)(52),{todos:n,isWorking:r}=e,{t:i}=L(),a=Q.useId(),[o,s]=Q.useState(!0),[c,l]=Q.useState(!1),u,d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{l(!0)},d=[],t[0]=u,t[1]=d):(u=t[0],d=t[1]),Q.useEffect(u,d);let f;t[2]===n?f=t[3]:(f=n.filter(Be),t[2]=n,t[3]=f);let p=f.length,m;t[4]===n?m=t[5]:(m=n.filter(ue),t[4]=n,t[5]=m);let h=m.length,g=Q.useRef(null),_=n.findIndex(Ve),v,y;if(t[6]===_?(v=t[7],y=t[8]):(v=()=>{_<0||g.current?.children[_]?.scrollIntoView?.({block:`nearest`})},y=[_],t[6]=_,t[7]=v,t[8]=y),Q.useEffect(v,y),n.length===0)return null;let b=h===n.length,x=r&&!b,S;t[9]===i?S=t[10]:(S=i(`chat.workStatus.todos.title`),t[9]=i,t[10]=S);let C;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>s(He),t[11]=C):C=t[11];let w=b?`done`:`open`,T=c&&`yuri-todo-icon-pop`,E;t[12]===T?E=t[13]:(E=ee(`inline-flex shrink-0`,T),t[12]=T,t[13]=E);let D;t[14]!==b||t[15]!==p||t[16]!==x||t[17]!==n.length?(D=b?(0,$.jsx)(le,{}):(0,$.jsx)(Y,{done:p,total:n.length,spinning:x}),t[14]=b,t[15]=p,t[16]=x,t[17]=n.length,t[18]=D):D=t[18];let O;t[19]!==E||t[20]!==D||t[21]!==w?(O=(0,$.jsx)(`span`,{className:E,children:D},w),t[19]=E,t[20]=D,t[21]=w,t[22]=O):O=t[22];let A;t[23]===i?A=t[24]:(A=i(`chat.workStatus.todos.title`),t[23]=i,t[24]=A);let j;t[25]===A?j=t[26]:(j=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:A}),t[25]=A,t[26]=j);let M;t[27]!==p||t[28]!==n.length?(M=(0,$.jsx)(de,{done:p,total:n.length,className:`text-[0.92em]`}),t[27]=p,t[28]=n.length,t[29]=M):M=t[29];let N;t[30]!==o||t[31]!==a||t[32]!==O||t[33]!==j||t[34]!==M?(N=(0,$.jsxs)(k,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 px-2 text-left text-[1em] font-normal leading-5 tracking-normal text-muted-foreground [&_svg]:size-3.5`,"aria-expanded":o,"aria-controls":a,onClick:C,children:[O,j,M]}),t[30]=o,t[31]=a,t[32]=O,t[33]=j,t[34]=M,t[35]=N):N=t[35];let te=!o,ne=!o,P=o?`grid-rows-[1fr] opacity-100`:`grid-rows-[0fr] opacity-0`,F;t[36]===P?F=t[37]:(F=ee(`grid min-w-0 transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none`,P),t[36]=P,t[37]=F);let I;t[38]!==r||t[39]!==c||t[40]!==n?(I=(0,$.jsx)(X,{id:void 0,todos:n,isWorking:r,animate:c,listRef:g,rowClassName:`px-2 gap-2 [&_svg]:size-3.5 [&>span:first-child]:w-3.5`,className:`max-h-[15em] min-h-0 overflow-y-auto pt-[0.125em]`}),t[38]=r,t[39]=c,t[40]=n,t[41]=I):I=t[41];let R;t[42]!==a||t[43]!==te||t[44]!==ne||t[45]!==F||t[46]!==I?(R=(0,$.jsx)(`div`,{id:a,"aria-hidden":te,inert:ne,className:F,children:I}),t[42]=a,t[43]=te,t[44]=ne,t[45]=F,t[46]=I,t[47]=R):R=t[47];let z;return t[48]!==N||t[49]!==R||t[50]!==S?(z=(0,$.jsxs)(`div`,{role:`group`,"aria-label":S,className:`mt-2 flex min-w-0 flex-col text-[13px]`,children:[N,R]}),t[48]=N,t[49]=R,t[50]=S,t[51]=z):z=t[51],z};function ze(e){return e.content.length>0}function Be(e){return e.status===`completed`}function Ve(e){return e.status===`in_progress`}function He(e){return!e}var Ue=Q.memo(function(e){let t=(0,Z.c)(19),{host:n,entry:r,input:i}=e,a=Q.useRef(null),o=Q.useRef(null),s;t[0]!==r||t[1]!==n||t[2]!==i?(s=e=>n.mountWorkStatus(r,e,i),t[0]=r,t[1]=n,t[2]=i,t[3]=s):s=t[3];let c=v(s),l;t[4]===c?l=t[5]:(l=()=>{if(!a.current)return;let e=c(a.current);return o.current=e,()=>{o.current=null,e.dispose()}},t[4]=c,t[5]=l);let u;t[6]!==r.generation||t[7]!==r.key||t[8]!==n||t[9]!==i.directory||t[10]!==i.scope||t[11]!==i.sessionId||t[12]!==c?(u=[n,r.key,r.generation,i.sessionId,i.directory,i.scope,c],t[6]=r.generation,t[7]=r.key,t[8]=n,t[9]=i.directory,t[10]=i.scope,t[11]=i.sessionId,t[12]=c,t[13]=u):u=t[13],Q.useLayoutEffect(l,u);let d,f;t[14]===i?(d=t[15],f=t[16]):(d=()=>{o.current?.update(i)},f=[i],t[14]=i,t[15]=d,t[16]=f),Q.useLayoutEffect(d,f);let p;return t[17]===r.key?p=t[18]:(p=(0,$.jsx)(`div`,{ref:a,"data-gui-plugin-mount":`work-status`,"data-gui-work-status":r.key,className:`min-w-0 empty:hidden`}),t[17]=r.key,t[18]=p),p}),We=Q.memo(function(e){let t=(0,Z.c)(9),{host:n,input:r}=e,i=Q.useSyncExternalStore(n.workStatus.subscribe,n.workStatus.getSnapshot,n.workStatus.getSnapshot),a;if(t[0]!==i||t[1]!==n||t[2]!==r){let e;t[4]!==n||t[5]!==r?(e=e=>(0,$.jsx)(Ue,{host:n,entry:e,input:r},e.key),t[4]=n,t[5]=r,t[6]=e):e=t[6],a=i.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a}else a=t[3];let o;return t[7]===a?o=t[8]:(o=(0,$.jsx)($.Fragment,{children:a}),t[7]=a,t[8]=o),o}),Ge=Q.memo(function(e){let t=(0,Z.c)(3),{input:n}=e,r=Q.useContext(R),i;return t[0]!==r||t[1]!==n?(i=r?(0,$.jsx)(We,{host:r,input:n}):null,t[0]=r,t[1]=n,t[2]=i):i=t[2],i}),Ke=[],qe=(e,t)=>{let n=l(e),r=l(t);return!!(n&&r&&(n===r||n.startsWith(`${r}/`)))};function Je(e){let t=(0,Z.c)(103),n=m();if(!n?.entry.location.hostId)throw Error(`Remote work status requires Host scope`);let{entry:r,registry:i}=n,{directory:a,hubId:o}=r.location,s=r.location.hostId,c;t[0]!==r||t[1]!==i?(c=F(i,r),t[0]=r,t[1]=i,t[2]=c):c=t[2];let u=c,h,_;t[3]===u?(h=t[4],_=t[5]):(h=()=>u.retain(),_=[u],t[3]=u,t[4]=h,t[5]=_),Q.useEffect(h,_);let[v,y]=Q.useState(),b;t[6]!==u.state||t[7]!==e?(b=()=>e?u.state.observe(e,y):void 0,t[6]=u.state,t[7]=e,t[8]=b):b=t[8];let x;t[9]!==u||t[10]!==e?(x=[u,e],t[9]=u,t[10]=e,t[11]=x):x=t[11],Q.useEffect(b,x);let S;t[12]!==u.state||t[13]!==e?(S=t=>e?u.state.repository.subscribe(u.state.scope(e),t):et,t[12]=u.state,t[13]=e,t[14]=S):S=t[14];let C=S,T;t[15]!==u.state||t[16]!==e?(T=()=>e?u.state.repository.getTranscript(u.state.scope(e)):null,t[15]=u.state,t[16]=e,t[17]=T):T=t[17];let E=T,O=Q.useSyncExternalStore(C,E,E),k=u.state.subscribeSnapshot,A;t[18]!==u.state||t[19]!==e?(A=()=>u.state.getSnapshot(e??``),t[18]=u.state,t[19]=e,t[20]=A):A=t[20];let j=A,M=Q.useSyncExternalStore(k,j,j),ee=w($e),P=D(Qe),I;t[21]===r?I=t[22]:(I=N(r),t[21]=r,t[22]=I);let L=I,R=ie(Ze),z;if(t[23]!==a||t[24]!==r.queryScope||t[25]!==L){let e;t[27]!==a||t[28]!==L?(e=()=>L.listGitWorktrees(a),t[27]=a,t[28]=L,t[29]=e):e=t[29],z=d({queryKey:[...r.queryScope,`work-status`,`worktrees`],queryFn:e,staleTime:3e4}),t[23]=a,t[24]=r.queryScope,t[25]=L,t[26]=z}else z=t[26];let B=z,re;t[30]===r?re=t[31]:(re=ne(r),t[30]=r,t[31]=re);let V=re,ae=e??``,oe;t[32]!==a||t[33]!==r||t[34]!==ae?(oe=ve(a,ae,{entry:r}),t[32]=a,t[33]=r,t[34]=ae,t[35]=oe):oe=t[35];let H=oe,U=f(B),W=f(V),G=!!e,K;t[36]!==H||t[37]!==G?(K={...H,enabled:G},t[36]=H,t[37]=G,t[38]=K):K=t[38];let q=f(K),J=p(),se;t[39]!==H||t[40]!==J||t[41]!==a||t[42]!==R||t[43]!==L||t[44]!==V||t[45]!==B?(se=async()=>{await Promise.all([J.fetchQuery({...B,staleTime:0}),J.fetchQuery({...V,staleTime:0}),J.fetchQuery({...H,staleTime:0}),R(a,L,{silent:!0})]),y(void 0)},t[39]=H,t[40]=J,t[41]=a,t[42]=R,t[43]=L,t[44]=V,t[45]=B,t[46]=se):se=t[46],g(e,se,y);let ce,le;t[47]!==H.queryKey||t[48]!==J||t[49]!==a||t[50]!==R||t[51]!==L||t[52]!==s||t[53]!==i||t[54]!==V.queryKey||t[55]!==B.queryKey?(ce=()=>i.subscribeEvents(s,e=>{if(e.directory&&l(e.directory)!==l(a))return;let t=e.payload?.type??``;t.startsWith(`session.`)&&!t.startsWith(`session.message.`)&&!t.startsWith(`session.tool.`)&&(/status|execution|retry|idle/.test(t)&&J.invalidateQueries({queryKey:V.queryKey}),/created|updated|renamed|deleted/.test(t)&&J.invalidateQueries({queryKey:H.queryKey})),t.startsWith(`worktree.`)||t===`vcs.branch.updated`?(J.invalidateQueries({queryKey:B.queryKey}),R(a,L,{silent:!0})):/^session\.(execution\.(succeeded|failed|interrupted)|idle)$/.test(t)&&R(a,L,{silent:!0})}),le=[i,s,a,J,V.queryKey,H.queryKey,B.queryKey,R,L],t[47]=H.queryKey,t[48]=J,t[49]=a,t[50]=R,t[51]=L,t[52]=s,t[53]=i,t[54]=V.queryKey,t[55]=B.queryKey,t[56]=ce,t[57]=le):(ce=t[56],le=t[57]),Q.useEffect(ce,le);let ue;if(t[58]!==a||t[59]!==s||t[60]!==o||t[61]!==ee||t[62]!==P||t[63]!==U.data){bb0:{let e;t[65]!==s||t[66]!==o?(e=e=>e.hostId===s&&e.hubId===o,t[65]=s,t[66]=o,t[67]=e):e=t[67];let n=ee.filter(e),r=P&&P.location.hostId===s&&P.location.hubId===o?n.find(e=>e.id===P.projectId):void 0;if(r){ue=r;break bb0}let i;t[68]!==a||t[69]!==U.data?(i=e=>qe(a,e.path)||U.data?.some(t=>l(t.path)===l(e.path)),t[68]=a,t[69]=U.data,t[70]=i):i=t[70],ue=n.filter(i).sort(Xe)[0]}t[58]=a,t[59]=s,t[60]=o,t[61]=ee,t[62]=P,t[63]=U.data,t[64]=ue}else ue=t[64];let Y=ue,X;t[71]!==a||t[72]!==Y?.path||t[73]!==U.data?(X=()=>{let e=U.data?.filter(e=>qe(a,e.path)).sort(Ye)[0];if(e)return{...e,projectDirectory:Y?.path??a,label:e.name,worktreeStatus:`ready`}},t[71]=a,t[72]=Y?.path,t[73]=U.data,t[74]=X):X=t[74],Y?.path;let de;t[75]===X?de=t[76]:(de=X(),t[75]=X,t[76]=de);let $=de,fe;if(t[77]!==q.data||t[78]!==W.data||t[79]!==O){let e;t[81]===W.data?e=t[82]:(e=W.data??{},t[81]=W.data,t[82]=e);let n=new Set(Object.keys(e));fe=De(O?Ce(O):[],(q.data??[]).map(e=>({...e,busy:n.has(e.id)})),n),t[77]=q.data,t[78]=W.data,t[79]=O,t[80]=fe}else fe=t[80];let pe=fe,me;t[83]!==M.session?.revert?.messageID||t[84]!==M.status?.type||t[85]!==O?(me=()=>({todos:(O?te(O,M.session?.revert?.messageID):void 0)??Ke,isWorking:M.status?.type===`busy`||M.status?.type===`retry`}),t[83]=M.session?.revert?.messageID,t[84]=M.status?.type,t[85]=O,t[86]=me):me=t[86],M.session?.revert?.messageID;let he;t[87]===me?he=t[88]:(he=me(),t[87]=me,t[88]=he);let ge=he,_e;t[89]!==q||t[90]!==u.state||t[91]!==e||t[92]!==W||t[93]!==U?(_e=async()=>{y(void 0),await Promise.allSettled([U.refetch(),W.refetch(),q.refetch(),e?u.state.refreshMetadata(e):Promise.resolve()])},t[89]=q,t[90]=u.state,t[91]=e,t[92]=W,t[93]=U,t[94]=_e):_e=t[94];let ye=_e,be=v??U.error??W.error??q.error,xe;return t[95]!==r.key||t[96]!==Y||t[97]!==ge||t[98]!==ye||t[99]!==pe||t[100]!==be||t[101]!==$?(xe={project:Y,worktree:$,subagents:pe,remoteTodos:ge,stateKey:r.key,error:be,retry:ye},t[95]=r.key,t[96]=Y,t[97]=ge,t[98]=ye,t[99]=pe,t[100]=be,t[101]=$,t[102]=xe):xe=t[102],xe}function Ye(e,t){return t.path.length-e.path.length}function Xe(e,t){return t.path.length-e.path.length}function Ze(e){return e.fetchStatus}function Qe(e){return e.remoteSession}function $e(e){return e.projects}function et(){}var tt=`flex w-full min-w-0 items-center justify-start gap-2 text-left text-[13px] font-normal leading-5 tracking-normal text-muted-foreground`,nt=`size-3.5 shrink-0`,rt=`yuri-work-status-action pointer-events-none shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover/copy:pointer-events-auto group-hover/copy:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100`,it=e=>e.split(/[\\/]/).filter(Boolean).pop()||e,at=e=>{let t=(0,Z.c)(3),n=m(),r;return t[0]!==n||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(ot,{...e},n.entry.key):(0,$.jsx)(st,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},ot=Q.memo(function(e){let t=(0,Z.c)(9),{t:n}=L(),r=Je(e.sessionId),i;t[0]!==r||t[1]!==e?(i=(0,$.jsx)(ct,{...e,...r}),t[0]=r,t[1]=e,t[2]=i):i=t[2];let a;t[3]!==r||t[4]!==n?(a=r.error?(0,$.jsxs)(`div`,{role:`status`,className:`px-2 text-xs text-muted-foreground`,title:String(r.error),children:[n(`common.unavailable`),(0,$.jsx)(k,{variant:`ghost`,size:`xs`,onClick:()=>void r.retry(),children:n(`chat.history.retry`)})]}):null,t[3]=r,t[4]=n,t[5]=a):a=t[5];let o;return t[6]!==i||t[7]!==a?(o=(0,$.jsxs)($.Fragment,{children:[i,a]}),t[6]=i,t[7]=a,t[8]=o):o=t[8],o}),st=e=>{let t=(0,Z.c)(16),{sessionId:n,directory:r}=e,i=w(lt),a=j(ut),o;t[0]===n?o=t[1]:(o=e=>n?e.worktreeMetadata.get(n):void 0,t[0]=n,t[1]=o);let s=j(o),c,u;if(t[2]!==a||t[3]!==r||t[4]!==i||t[5]!==s){let e=l(r),n=t=>{let n=l(t);return!!(e&&n&&(e===n||e.startsWith(`${n}/`)))},o=s&&n(s.path)?s:void 0;c=T(i.filter(dt),a,o?.projectDirectory||r);let d=c?a.get(c.path):void 0;u=o??d?.filter(e=>n(e.path)).sort(ft)[0],t[2]=a,t[3]=r,t[4]=i,t[5]=s,t[6]=c,t[7]=u}else c=t[6],u=t[7];let d=u,f;t[8]!==c||t[9]!==d?(f={project:c,worktree:d},t[8]=c,t[9]=d,t[10]=f):f=t[10];let{project:p,worktree:m}=f,h=Pe(n,r),g=p??void 0,_;return t[11]!==e||t[12]!==h||t[13]!==g||t[14]!==m?(_=(0,$.jsx)(ct,{...e,project:g,worktree:m,subagents:h}),t[11]=e,t[12]=h,t[13]=g,t[14]=m,t[15]=_):_=t[15],_},ct=({sessionId:e,directory:t,active:n=!0,placement:r=`inline`,project:i,worktree:a,subagents:o,remoteTodos:s,stateKey:c})=>{let{t:u}=L(),{git:d}=B(),f=m(),p=f?.entry.location.hostId?f.entry:void 0,h=ie(e=>e.ensureStatus),g=re(t),y=V(t),b=ae(t),S=i?.path||a?.projectDirectory||t,w=i?.label?.trim()||(S?it(S):null),T=a&&l(a.path)!==l(S)?a.name?.trim()||it(a.path):null,E=[{phase:`working`,labelKey:`chat.workStatus.subagent.workingCount`,items:o.filter(e=>e.phase===`working`)},{phase:`done`,labelKey:`chat.workStatus.subagent.doneCount`,items:o.filter(e=>e.phase===`done`)}],D=E[0].items,O=(D.length>0?D:o).slice(0,3),[A,j]=Q.useState(!1),M=Q.useId(),N=x(e=>e.setRightSidebarOpen),ee=x(e=>e.openContextPanel),te=x(e=>e.openContextPanelTab),ne=x(e=>e.setRightSidebarTab),[F,R]=Q.useState(null),[,z]=_(()=>R(null),1500,{immediate:!1}),H=v(async(e,t)=>{try{let n=await P(t);if(!n.ok)throw Error(n.error);R(e),z()}catch{C.error(u(`gitView.toast.copyFailed`))}});Q.useEffect(()=>{!t||!d||h(t,d)},[t,h,d]);let U=g?.current||null,W=a?.worktreeStatus===`pending`?0:g?.files.length??0,{additions:G,deletions:K}=Q.useMemo(()=>{let e=0,t=0;for(let n of Object.values(g?.diffStats??{}))e+=n?.insertions??0,t+=n?.deletions??0;return{additions:e,deletions:t}},[g?.diffStats]),q=a?.worktreeStatus===`pending`,J=!q&&!!g&&b!==!1,se=q?`unknown`:b===!1?`not-repository`:J?`ready`:`unknown`,ce=J&&!!g?.diffStats,le=Q.useMemo(()=>({state:se,loading:y,branch:J?U:null,changedFiles:J?W:null,additions:ce?G:null,deletions:ce?K:null}),[se,y,J,U,W,ce,G,K]),ue=Q.useMemo(()=>({sessionId:e,directory:t,placement:r,scope:p,project:S&&w?{id:i?.id,name:w,directory:S}:null,worktree:a?{name:a.name?.trim()||it(a.path),directory:a.path}:null,git:le}),[e,t,r,p,S,w,i?.id,a,le]),Y=U?`branch:${U}`:``,X=a?.path?`worktree:${a.path}`:``,de=!!(Y&&F===Y),Z=!!(X&&F===X),fe=v(()=>{U&&H(Y,U)}),pe=v(()=>{let e=a?.path;e&&H(X,e)}),me=v(()=>{t&&(ee(c??t),ne(`git`),N(!0))});return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[w?(0,$.jsxs)(`div`,{className:`${tt} h-8 px-2`,title:`${u(`chat.workStatus.section.project`)}: ${S}`,children:[(0,$.jsx)(I,{name:`folder`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:w})]}):null,U?(0,$.jsxs)(`div`,{className:`${tt} group/copy h-8 px-2`,title:`${u(`gitView.branch.currentBranchTooltip`)}: ${U}`,children:[(0,$.jsx)(I,{name:`git-branch`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:U}),(0,$.jsx)(k,{variant:`ghost`,size:`xs`,className:rt,"aria-label":u(`chat.workStatus.action.copyBranch`),title:u(de?`contextSidebar.actions.copied`:`chat.workStatus.action.copyBranch`),onClick:fe,children:(0,$.jsx)(I,{name:de?`check`:`file-copy`,className:nt})})]}):null,T?(0,$.jsxs)(`div`,{className:`${tt} group/copy h-8 px-2`,title:`${u(`sessions.sidebar.sessionDialogs.worktree.label`)}: ${a?.path}`,children:[(0,$.jsx)(I,{name:`node-tree`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:T}),(0,$.jsx)(k,{variant:`ghost`,size:`xs`,className:rt,"aria-label":u(`agentManager.detail.actions.copyWorktreePath`),title:u(Z?`contextSidebar.actions.copied`:`agentManager.detail.actions.copyWorktreePath`),onClick:pe,children:(0,$.jsx)(I,{name:Z?`check`:`file-copy`,className:nt})})]}):null,W>0?(0,$.jsxs)(k,{variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${tt}`,title:u(W===1?`chat.workStatus.git.changedFileSingle`:`chat.workStatus.git.changedFilePlural`,{count:W}),"aria-label":u(`chat.workStatus.action.openGit`),onClick:me,children:[(0,$.jsx)(I,{name:`changes`,weight:`medium`,className:nt}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:u(`chat.workStatus.compact.changes`)}),G>0||K>0?(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 gap-1.5 text-[12px] tabular-nums`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-success)]`,children:`+${G}`}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`−${K}`})]}):(0,$.jsx)(`span`,{className:`ml-auto tabular-nums`,children:W})]}):null,n?(0,$.jsx)(Ge,{input:ue}):null,(0,$.jsx)(Le,{sessionId:e,directory:t,remote:s}),o.length>0?(0,$.jsxs)(`div`,{role:`group`,"aria-label":u(`chat.workStatus.section.subagents`),className:`flex min-w-0 flex-col`,children:[(0,$.jsxs)(k,{type:`button`,variant:`ghost`,size:`sm`,className:`yuri-work-status-action ${tt} gap-1.5`,"aria-expanded":A,"aria-controls":M,onClick:()=>j(e=>!e),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 items-center`,children:O.map((e,t)=>{let n=e.label.trim()||u(`chat.workStatus.subagent.untitled`);return(0,$.jsx)(oe,{name:e.seed,label:n,size:14,className:`relative bg-background ring-2 ring-background ${t>0?`-ml-1`:``}`},e.key)})}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-x-1 whitespace-nowrap text-left text-[11px] leading-5 tabular-nums`,children:E.filter(e=>e.items.length>0).map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,$.jsx)(`span`,{children:u(e.labelKey,{count:e.items.length})})]},e.phase))}),(0,$.jsx)(I,{name:A?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 text-muted-foreground opacity-70`})]}),(0,$.jsx)(`div`,{id:M,hidden:!A,className:A?`mt-1 mb-1 flex min-w-0 flex-col gap-1`:`hidden`,children:A?E.filter(e=>e.items.length>0).map(e=>(0,$.jsxs)(`section`,{"aria-label":u(e.labelKey,{count:e.items.length}),className:`flex min-w-0 flex-col gap-1 [&+section]:mt-2`,children:[(0,$.jsx)(`div`,{className:`px-2 py-1 text-[11px] leading-4 text-muted-foreground/70`,children:u(e.labelKey,{count:e.items.length})}),e.items.map(e=>{let n=e.label.trim()||u(`chat.workStatus.subagent.untitled`);return(0,$.jsxs)(k,{variant:`ghost`,size:`sm`,disabled:!e.sessionID||!t,className:`yuri-work-status-action flex w-full min-w-0 items-center justify-start gap-2 text-left text-[12px] font-normal leading-5 text-muted-foreground`,onClick:()=>{!e.sessionID||!t||te(c??t,{mode:`chat`,dedupeKey:`session:${e.sessionID}`,label:n,readOnly:!0})},children:[(0,$.jsx)(oe,{name:e.seed,label:n,size:14}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:n,children:n})]},e.key)})]},e.phase)):null})]}):null]})};function lt(e){return e.projects}function ut(e){return e.availableWorktreesByProject}function dt(e){return!e.hostId}function ft(e,t){return t.path.length-e.path.length}var pt=200,mt=264,ht=e=>{let t=(0,Z.c)(31),{sessionId:n,directory:r,visible:i,overlay:a}=e,o=a!==void 0&&a,{t:s}=L(),c=x(gt),l=Q.useRef(null),[u,d]=Q.useState(i),f,p;t[0]===i?(f=t[1],p=t[2]):(f=()=>{if(i){d(!0);return}let e=window.setTimeout(()=>d(!1),pt);return()=>window.clearTimeout(e)},p=[i],t[0]=i,t[1]=f,t[2]=p),Q.useEffect(f,p);let m,h;t[3]!==o||t[4]!==c||t[5]!==i?(m=()=>{if(!o||!i)return;let e=e=>{let t=e.target instanceof Element?e.target:null;l.current?.contains(t)||t?.closest(`[data-work-status-toggle]`)||c(!1)},t=e=>{e.key===`Escape`&&c(!1)};return document.addEventListener(`pointerdown`,e,!0),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e,!0),document.removeEventListener(`keydown`,t)}},h=[o,c,i],t[3]=o,t[4]=c,t[5]=i,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]===s?g=t[9]:(g=s(`chat.workStatus.ariaLabel`),t[8]=s,t[9]=g);let _=!i,v=!i,y=o?`top-3 z-30 max-h-[calc(100%-1.5rem)] rounded-xl p-2 ${ce}`:`top-2`,b;t[10]===y?b=t[11]:(b=ee(`absolute z-20 flex max-h-[calc(100%-1rem)] flex-col overflow-x-hidden overflow-y-auto scrollbar-hidden bg-transparent`,y),t[10]=y,t[11]=b);let S=o?mt:i?196:0,C=+!!i,w=i?`none`:o?`translateY(-6px)`:`translateX(24px)`,T=o?`opacity, transform`:`none`,E=i?void 0:`none`,D;t[12]!==S||t[13]!==C||t[14]!==w||t[15]!==T||t[16]!==E?(D={right:14,width:S,opacity:C,transform:w,transitionProperty:T,transitionDuration:`${pt}ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`,pointerEvents:E},t[12]=S,t[13]=C,t[14]=w,t[15]=T,t[16]=E,t[17]=D):D=t[17];let O;t[18]!==u||t[19]!==r||t[20]!==o||t[21]!==n||t[22]!==i?(O=i||o&&u?(0,$.jsx)(at,{sessionId:n,directory:r,active:i,placement:o?`popover`:`inline`}):null,t[18]=u,t[19]=r,t[20]=o,t[21]=n,t[22]=i,t[23]=O):O=t[23];let k;return t[24]!==b||t[25]!==D||t[26]!==O||t[27]!==g||t[28]!==_||t[29]!==v?(k=(0,$.jsx)(`aside`,{ref:l,"aria-label":g,"aria-hidden":_,inert:v,className:b,style:D,children:O}),t[24]=b,t[25]=D,t[26]=O,t[27]=g,t[28]=_,t[29]=v,t[30]=k):k=t[30],k};function gt(e){return e.setWorkStatusOverlayOpen}var _t=e({ChatView:()=>yt}),vt=e=>{let t=(0,Z.c)(10),{sessionId:n,directory:r,visible:i,overlay:a,publishVisible:o}=e,s=a!==void 0&&a,c=o!==void 0&&o,l=x(bt),u,d;t[0]!==c||t[1]!==l||t[2]!==i?(u=()=>{if(c)return l(i),()=>l(!1)},d=[c,l,i],t[0]=c,t[1]=l,t[2]=i,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;return t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(f=(0,$.jsx)(ht,{overlay:s,visible:i,sessionId:n,directory:r}),t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=f):f=t[9],f},yt=({readOnly:e=!1,active:t=!0,selectionOverride:i})=>{let a=m(),o=D(e=>e.remoteSession),s=i?.location??(a?.entry.location.hostId?a.entry.location:void 0),c=i?{...i,active:t,...s?{location:s,directory:i.directory??s.directory,sessionId:i.sessionId||(o&&r(o.location)===r(s)?o.sessionId:null)}:{}}:void 0,l=j(e=>e.currentSessionId),u=j(e=>e.currentSessionDirectory),d=j(e=>!!e.newSessionDraft?.open),f=j(e=>!!(e.newSessionDraft?.open&&e.newSessionDraft.pendingUserMessage&&(e.newSessionDraft.draftEstablishing||e.newSessionDraft.draftSubmitting))),p=z(),h=x(e=>e.isMobile),g=x(e=>e.isExpandedInput),_=n(),v=x(e=>e.workStatusPanelEnabled),y=x(e=>e.workStatusOverlayOpen),b=x(e=>e.setWorkStatusPanelFits),S=s&&o&&r(o.location)===r(s)?o:null,C=s?c?.sessionId??S?.sessionId??null:i?.sessionId??l,w=C,T=s?s.directory:i?.directory??u??p??null,{visible:E,fits:O,layoutAllows:k}=he({isMobile:h,isVSCode:_,directory:s?r(s):T}),A=s?!!C:i?!!i.sessionId:d?f:!!C,M=t&&!h&&!_&&!g&&A,N=M&&E,te=M&&v&&!O&&y;return Q.useEffect(()=>(b(M&&O),()=>b(!1)),[O,M,b]),(0,$.jsxs)(`div`,{className:ee(`relative h-full min-h-0 min-w-0`,N&&`yuri-chat-work-status-inline`),style:N?{"--yuri-work-status-reserve":`210px`}:void 0,children:[(0,$.jsx)(`div`,{className:`absolute inset-0 min-h-0 min-w-0`,children:(0,$.jsx)(pe,{sessionId:w||void 0,children:(0,$.jsx)(se,{readOnly:e,active:t,explicitSession:c})})}),M&&k?(0,$.jsx)(vt,{publishVisible:!0,visible:N,sessionId:C,directory:T}):null,M&&v&&!O?(0,$.jsx)(vt,{overlay:!0,visible:te,sessionId:C,directory:T}):null]})};function bt(e){return e.setWorkStatusPanelVisible}export{_t as n,yt as t};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-CNodTwpI.js","assets/rolldown-runtime-hePW80VL.js","assets/platform-z1TeG-ky.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/runtime-file-resource-COtIWnSi.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-DIb_ItL-.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/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-Dz0bOfkB.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/vendor-markstream-react-BqCCtUAV.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/ui-DeV7Us1B.js","assets/gitApiHttp-Be5VpQHC.js","assets/client-i5Q82JUc.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BG4nBKxi.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-CuuZggLJ.js","assets/i18n-CBCskgqa.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-BRt8bo0A.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-C4dE7Hgl.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-LaS5RREA.js","assets/vendor-framer-motion-D5NyyC73.js","assets/tooltip-Cdy71vjH.js","assets/useThemeSystem-BIXghnHj.js","assets/useEffectiveDirectory-BnoYSkb7.js","assets/LoadingImage-956pmYDm.js","assets/ImageLoadingPlaceholder-CJmo4kkb.js","assets/image-loading-DA9JEHD8.css","assets/markdownHeightCache-BAuvVQZt.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-DoyhaY3E.js","assets/FadeInOnReveal-CrbIIB5N.js","assets/useStreamingTextThrottle-BbawjMGN.js","assets/MarkdownRendererImpl-B0BDlD7a.js","assets/vendor-katex-DNVSTX6g.js","assets/themes-BgDJcxRc.js","assets/inlineMessageLinks-DC78iKO5.js","assets/vendor-marked-S3gCOYp1.js","assets/markdownTheme-D84XyNiT.js","assets/vendor-pierre-diffs-B0OmIhMO.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-FVCTQlDH.js","assets/fileReferenceParser-1HHDBUum.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-CTekDqaS.js";import{ot as n,st as r}from"./vendor-base-ui-wXsskyKm.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-BkccXcWz.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{no as o}from"./ui-DeV7Us1B.js";import{t as s}from"./useEffectiveDirectory-BnoYSkb7.js";import{i as c,n as l,t as u}from"./markdownHeightCache-BAuvVQZt.js";var d=i(),f=e(r(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.3.6-beta.8:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},w=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},T=`yuri:markstream-react`,E=e=>C(T,e),D=t(e=>({markstreamReactEnabled:E(),setMarkstreamReactEnabled:t=>{w(T,t),e({markstreamReactEnabled:t})}})),O=null,k=()=>(O??=a(()=>import(`./MarkstreamRendererImpl-CNodTwpI.js`),__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,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87])).catch(e=>{throw O=null,e}),O),A=()=>{k().catch(()=>void 0)},j=null,M=()=>(j??=a(()=>import(`./MarkdownRendererImpl-B0BDlD7a.js`).then(e=>e.n),__vite__mapDeps([65,1,4,3,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,66,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,55,67,56,60,61,62,68,69,70,71,72,73,74,75,76,77,78,79,80,81,63,82,83,84,85,86,87,59])).catch(e=>{throw j=null,e}),j),N=()=>{E()?A():M().catch(()=>void 0)},P=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},F=f.createContext(!0),I=()=>f.useContext(F),L=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),R=n(),z=S(()=>M().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>k().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>M().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=D(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=I(),r=D(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(P,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!L(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!I()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{N as a,F as i,G as n,S as o,L as r,W as t};