@yuriai/web 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (276) hide show
  1. package/dist/assets/AgentAvatar-CNOu_vy0.js +1 -0
  2. package/dist/assets/AgentSelector-K5JSbXv3.js +1 -0
  3. package/dist/assets/ArchivedSessionsDialog-CU9RXl8K.js +1 -0
  4. package/dist/assets/AssistantConversationSurface-u3ndSmZP.js +3 -0
  5. package/dist/assets/AssistantSessionCard-MYBAni6A.js +2 -0
  6. package/dist/assets/AssistantUnreadBadge-opyLZlZd.js +1 -0
  7. package/dist/assets/AssistantView-CDPTtrUZ.js +1 -0
  8. package/dist/assets/AssistantWorkingAvatar-Vghb8xlt.js +1 -0
  9. package/dist/assets/AssistantsSettingsPage-Dt4OP3J-.js +1 -0
  10. package/dist/assets/BinaryFileFallback-CJqnlBzh.js +1 -0
  11. package/dist/assets/BtwPanel-DnMW6R43.js +6 -0
  12. package/dist/assets/BusyDots-FXSlMe2F.js +4 -0
  13. package/dist/assets/ChatContainer-Dg9uDBjk.js +65 -0
  14. package/dist/assets/ChatView-AFUNEBdD.js +3 -0
  15. package/dist/assets/{DiagramView-CaefmjA4.js → DiagramView-j7aFp44v.js} +1 -1
  16. package/dist/assets/{DiffView-BaqthIvq.js → DiffView-DZ_gKyTO.js} +2 -2
  17. package/dist/assets/DiffViewToggle-DkxhEUhV.js +1 -0
  18. package/dist/assets/ErrorBoundary-CCH4LiRY.js +1 -0
  19. package/dist/assets/FadeInOnReveal-DO9PZrJL.js +1 -0
  20. package/dist/assets/{GuiPluginMount-Btp3mJT2.js → GuiPluginMount-BCqt2pmM.js} +1 -1
  21. package/dist/assets/GuiPluginPage-BSjWEmIu.js +1 -0
  22. package/dist/assets/GuiPluginSurface-B8QjacMd.js +1 -0
  23. package/dist/assets/GuiPluginTitlebarItems-DfHugxsx.js +1 -0
  24. package/dist/assets/{GuiPluginWindow-BkAFJyFd.js → GuiPluginWindow-CDycMqzT.js} +1 -1
  25. package/dist/assets/Icon-B-w2YKpn.js +1 -0
  26. package/dist/assets/ImageLoadingPlaceholder-DsgRtfYG.js +1 -0
  27. package/dist/assets/{LoadingImage-Df22Rkor.js → LoadingImage-B3IL7hnv.js} +1 -1
  28. package/dist/assets/MarkdownRenderer-CsEylQVj.js +2 -0
  29. package/dist/assets/{MarkdownRendererImpl-BZc_jUrV.js → MarkdownRendererImpl-CPgpkd9b.js} +1 -1
  30. package/dist/assets/MarkstreamRendererImpl-BzK1BO80.js +3 -0
  31. package/dist/assets/{MobileAssistantSettingsPage-BBIiFN2g.js → MobileAssistantSettingsPage-DVpE3b24.js} +1 -1
  32. package/dist/assets/MobileAssistantTab-BbccE67x.js +1 -0
  33. package/dist/assets/{MobileBtwPage-DVZm5hrZ.js → MobileBtwPage-BRN1gAmR.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-CiqsGZsg.js → MobileChangesSurface-BwmSTxeh.js} +2 -2
  35. package/dist/assets/MobileChatScreen-Bf42GrQ8.js +1 -0
  36. package/dist/assets/MobileDetailNavigation-DKWnQoSh.js +1 -0
  37. package/dist/assets/MobileFilesSurface-qkfC06Oh.js +2 -0
  38. package/dist/assets/MobileHtmlNetworkBoundary-BKSYPR9N.js +2 -0
  39. package/dist/assets/MobileOverlayPanel-DcRWQlmf.js +1 -0
  40. package/dist/assets/MobileResizableSheet-CF3Pbot4.js +1 -0
  41. package/dist/assets/{MobileSettingsTab-MmDnxG47.js → MobileSettingsTab-of6zpTsr.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-DAlGSXoj.js → MobileShareBridge-CRq9F1rn.js} +1 -1
  43. package/dist/assets/MobileSurface-DGNomvlu.js +1 -0
  44. package/dist/assets/MobileTabPageHeader-0aJFe3_x.js +1 -0
  45. package/dist/assets/ModelLogo-D27dq-si.js +1 -0
  46. package/dist/assets/ModelSelector-Dg__8QLh.js +1 -0
  47. package/dist/assets/MultiRunWindow-COqSg1Nk.js +1 -0
  48. package/dist/assets/OnboardingScreen-DUNyDwc6.js +1 -0
  49. package/dist/assets/OverlayScrollbar-DS6XJ1HA.js +1 -0
  50. package/dist/assets/{PierreDiffViewer-B1e1H6br.js → PierreDiffViewer-BHwj_6j8.js} +3 -3
  51. package/dist/assets/ProviderLogo-Cm9RNV_U.js +1 -0
  52. package/dist/assets/{RemoteAssistantSessionCard-BgL7oxAK.js → RemoteAssistantSessionCard-DAjHRUrC.js} +1 -1
  53. package/dist/assets/RemoteDesktopPanel-Bays6pHh.js +1 -0
  54. package/dist/assets/ScheduledTasksDialog-DnwBC7cj.js +3 -0
  55. package/dist/assets/ScrollableOverlay-CkX-buJm.js +1 -0
  56. package/dist/assets/SettingsGroup-kZ_faXwL.js +1 -0
  57. package/dist/assets/{SettingsView-CLE6ra3s.js → SettingsView-C62JngPE.js} +13 -13
  58. package/dist/assets/SettingsWindow-Cm8apHAR.js +1 -0
  59. package/dist/assets/SetupTourDialog-W_UeWH-i.js +1 -0
  60. package/dist/assets/{SyncActions-CrOoREWF.js → SyncActions-Blnq08ks.js} +1 -1
  61. package/dist/assets/TerminalView-CMugifkh.js +8 -0
  62. package/dist/assets/TextSelectionMenu-B2fIBlD3.js +11 -0
  63. package/dist/assets/{ToolOutputDialog-DqCCsC-N.js → ToolOutputDialog-DdSUE2kP.js} +1 -1
  64. package/dist/assets/{YuriLogo-Cp6vWDWp.js → YuriLogo-Ceon25sC.js} +1 -1
  65. package/dist/assets/{YuriWordmark-CLGHwobA.js → YuriWordmark-CW53XKgV.js} +1 -1
  66. package/dist/assets/{assistant-attachment-cache-bRIIESGe.js → assistant-attachment-cache-eNT2QtmP.js} +1 -1
  67. package/dist/assets/assistantMessagePreview-C7YAFen1.js +1 -0
  68. package/dist/assets/assistantQueries-DxvTFlpL.js +1 -0
  69. package/dist/assets/{auto-read-context-DVGIDEr6.js → auto-read-context-Ce0o43YI.js} +1 -1
  70. package/dist/assets/{capgoAdapter-94K243Zv.js → capgoAdapter-DQwUA-Nt.js} +1 -1
  71. package/dist/assets/card-D44sTpdY.js +1 -0
  72. package/dist/assets/chatUpwardIntent-CnS7WWRL.js +1 -0
  73. package/dist/assets/checkbox-DaKe0Tlq.js +1 -0
  74. package/dist/assets/{client-B_907PBv.js → client-ITylDDCS.js} +1 -1
  75. package/dist/assets/collapsible-CL3SPnOf.js +1 -0
  76. package/dist/assets/{connection-hint-B-kOWome.js → connection-hint-SMNZFDAe.js} +1 -1
  77. package/dist/assets/context-menu-DZunhC8o.js +1 -0
  78. package/dist/assets/diagram-DFXqN638.js +1 -0
  79. package/dist/assets/dialog-CmjXOKMz.js +1 -0
  80. package/dist/assets/dropdown-menu-BT_66BFT.js +1 -0
  81. package/dist/assets/{fileMentionTouchSelection-BQEUty_A.js → fileMentionTouchSelection-B_62hIQI.js} +1 -1
  82. package/dist/assets/{gitApi-BWsBS_2N.js → gitApi-CBfYFgtd.js} +1 -1
  83. package/dist/assets/{gitApiHttp-Dd-FwgCq.js → gitApiHttp-Bswf6gnl.js} +1 -1
  84. package/dist/assets/githubAuthQueries-C5RxUNL2.js +1 -0
  85. package/dist/assets/historyImportQueries-CZsECryv.js +1 -0
  86. package/dist/assets/{host-ChBHl_Vl.js → host-C7jHgymK.js} +1 -1
  87. package/dist/assets/{i18n-DXc6czdR.js → i18n-Dojvs57M.js} +1 -1
  88. package/dist/assets/{icons-Bd-INsoy.js → icons-D_vRtitD.js} +1 -1
  89. package/dist/assets/{imageSource-BR4C9TuS.js → imageSource-Cq_p4gAe.js} +1 -1
  90. package/dist/assets/input-BllFKOjo.js +1 -0
  91. package/dist/assets/{input-store-BSJBQTMi.js → input-store-dLjM4aiu.js} +1 -1
  92. package/dist/assets/insertionBoundaries-Br0Bdl9R.js +1 -0
  93. package/dist/assets/kbd-CwkasrzN.js +1 -0
  94. package/dist/assets/main-B7wAfq9F.js +2 -0
  95. package/dist/assets/main-DVmi0I-y.js +169 -0
  96. package/dist/assets/{markdownHeightCache-CHGGNhWI.js → markdownHeightCache-RX04MAqu.js} +1 -1
  97. package/dist/assets/mcpQueries-qRW-HQMx.js +1 -0
  98. package/dist/assets/miniChat-D7-JQ1hw.js +2 -0
  99. package/dist/assets/mobile-BFQBDlo9.js +2 -0
  100. package/dist/assets/{mobileBackNavigation-DF_uhF-i.js → mobileBackNavigation-DsDUTnFY.js} +1 -1
  101. package/dist/assets/mobileConnections-PVy2SsQ_.js +2 -0
  102. package/dist/assets/multirun-C2RRF2Q3.js +3 -0
  103. package/dist/assets/{native-config-DSpTDz3F.js → native-config-Czc142JT.js} +1 -1
  104. package/dist/assets/{nativeComposerCover-DXFy97OQ.js → nativeComposerCover-DzEGSyOO.js} +1 -1
  105. package/dist/assets/{navigation-jU0HUH9s.js → navigation-C1v9hIAT.js} +2 -2
  106. package/dist/assets/openRemoteProjectSession-C5z2Juv7.js +1 -0
  107. package/dist/assets/pluginPresentation-p_0sXPMT.js +2 -0
  108. package/dist/assets/{project-preview-BCtFY4Rg.js → project-preview-BcLPKzwg.js} +1 -1
  109. package/dist/assets/{prompt-attachment-upload-B5DHrw6U.js → prompt-attachment-upload-BGppTOgV.js} +1 -1
  110. package/dist/assets/pwa-Br2HZksc.js +2 -0
  111. package/dist/assets/queue-abort-optimistic-DciJN9X1.js +1 -0
  112. package/dist/assets/{quota-CqWNkFzw.js → quota-2PwXAoIg.js} +1 -1
  113. package/dist/assets/{reference-history-DBxnA_fF.js → reference-history-BwtzPAmA.js} +1 -1
  114. package/dist/assets/{remote-input-store-C6UIEZxp.js → remote-input-store-DdjKfpxS.js} +1 -1
  115. package/dist/assets/remoteProjectQueries-BXrXdLjN.js +1 -0
  116. package/dist/assets/{remoteSessionReference-Cug8RfIG.js → remoteSessionReference-XfJOxItc.js} +1 -1
  117. package/dist/assets/renderElectronMiniChatApp-BekZAu-s.js +2 -0
  118. package/dist/assets/renderMobileApp-C5U2cyeq.js +17 -0
  119. package/dist/assets/{runtime-file-download-BWeoSXRb.js → runtime-file-download-1s2Al1t3.js} +1 -1
  120. package/dist/assets/runtime-file-resource-C5kmYlLv.js +6 -0
  121. package/dist/assets/{runtimeConfig-zzeYHX6k.js → runtimeConfig-DzYIc49M.js} +1 -1
  122. package/dist/assets/runtimeEndpointReset-BKLVdNhJ.js +4 -0
  123. package/dist/assets/select-BOtGs1FV.js +1 -0
  124. package/dist/assets/{sessionLookup-4zOaVAuF.js → sessionLookup-BTQ_AtWh.js} +1 -1
  125. package/dist/assets/sessionOwnership-BPfk1qCS.js +2 -0
  126. package/dist/assets/shortcuts-Cu4ioDvH.js +1 -0
  127. package/dist/assets/sortable-tabs-strip-DACGW9sB.js +1 -0
  128. package/dist/assets/speechSettingsQueries-BU-4Axb5.js +1 -0
  129. package/dist/assets/{src-QTj33Z0x.css → src-Dj147H4m.css} +1 -1
  130. package/dist/assets/{store-C1ifDY0C.js → store-DRUKTpV5.js} +1 -1
  131. package/dist/assets/switch-DaUn0G3u.js +1 -0
  132. package/dist/assets/{terminalApi-DXvEquBF.js → terminalApi-ClNhXBA8.js} +1 -1
  133. package/dist/assets/textarea-IhQHekYx.js +1 -0
  134. package/dist/assets/{timeFormat-dCsf2MQv.js → timeFormat-BsuUDWLs.js} +1 -1
  135. package/dist/assets/tooltip-Dw3DApa-.js +1 -0
  136. package/dist/assets/truncated-path-KHrfQ66P.js +1 -0
  137. package/dist/assets/{types-s_oc_LRs.js → types-BBBwzIOU.js} +1 -1
  138. package/dist/assets/ui-CHdferA1.js +13 -0
  139. package/dist/assets/{useAppFontEffects-nvkTSYHB.js → useAppFontEffects-Dw6o6XbA.js} +4 -4
  140. package/dist/assets/useDesktopWindowControlsLayout-DAkTdcAP.js +1 -0
  141. package/dist/assets/{useDictation-CZzAlsW0.js → useDictation-sdgDfATy.js} +1 -1
  142. package/dist/assets/{useEffectiveDirectory-BxolHzt4.js → useEffectiveDirectory-DZqC-2HE.js} +1 -1
  143. package/dist/assets/{useFontPreferences-BiRBKhti.js → useFontPreferences-Bb-bxdL8.js} +1 -1
  144. package/dist/assets/{useGitStore-B641o_o0.js → useGitStore-Bbmai549.js} +1 -1
  145. package/dist/assets/{useInlineCommentDraftStore-B2mkmAZd.js → useInlineCommentDraftStore-DrC99u6A.js} +1 -1
  146. package/dist/assets/useMcpConfigStore-ZsZxSrCt.js +1 -0
  147. package/dist/assets/useMobileSwipeActions-fUp7Bkbn.js +1 -0
  148. package/dist/assets/useMobileTranscriptSyncHint-B4izCfqe.js +10 -0
  149. package/dist/assets/useModelLists-B0qSYDby.js +1 -0
  150. package/dist/assets/useOpenCodeReadiness-B9d-wLZB.js +1 -0
  151. package/dist/assets/usePluginsStore-BLncdNj-.js +1 -0
  152. package/dist/assets/useProjectGitActions-CHMe1ku4.js +1 -0
  153. package/dist/assets/{useProjectGitStore-C1K6WpCe.js → useProjectGitStore-Lz9AV32V.js} +1 -1
  154. package/dist/assets/{useProjectRuntimeAPIs-BItoD9Bt.js → useProjectRuntimeAPIs-D51dVo-V.js} +1 -1
  155. package/dist/assets/useQuotaStore-mZs9LTwx.js +1 -0
  156. package/dist/assets/{useSessionBtwStore-BCHq3UOB.js → useSessionBtwStore-CYaTDkvT.js} +1 -1
  157. package/dist/assets/{useStreamingTextThrottle-DGAjmaMZ.js → useStreamingTextThrottle-ul6e3dUd.js} +1 -1
  158. package/dist/assets/worktreeManager-V6hoSVxH.js +1 -0
  159. package/dist/assets/{worktreeSourceBranchPreference-B5Fldnhm.js → worktreeSourceBranchPreference-MQFPkOZy.js} +1 -1
  160. package/dist/index.html +12 -13
  161. package/dist/mini-chat.html +12 -13
  162. package/dist/mobile.html +2 -2
  163. package/package.json +1 -1
  164. package/server/index.js +1 -0
  165. package/server/lib/gui-customization/DOCUMENTATION.md +22 -1
  166. package/server/lib/gui-customization/projects-client.mjs +14 -3
  167. package/server/lib/gui-customization/projects-lifecycle.js +89 -0
  168. package/server/lib/gui-customization/projects-lifecycle.test.js +199 -0
  169. package/server/lib/gui-customization/projects.js +19 -3
  170. package/server/lib/gui-customization/projects.test.js +6 -0
  171. package/server/lib/gui-customization/session-skill.js +2 -2
  172. package/server/lib/gui-customization/session-skill.test.js +6 -0
  173. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  174. package/server/lib/gui-customization/skill/references/projects.md +30 -0
  175. package/server/lib/opencode/feature-routes-runtime.js +5 -0
  176. package/server/lib/opencode/feature-routes-runtime.test.js +6 -0
  177. package/dist/assets/AgentAvatar-CHCjMxCF.js +0 -1
  178. package/dist/assets/AgentSelector-DpOQ7dyw.js +0 -1
  179. package/dist/assets/ArchivedSessionsDialog-nqnWb-Vc.js +0 -1
  180. package/dist/assets/AssistantConversationSurface-CKXgty02.js +0 -3
  181. package/dist/assets/AssistantSessionCard-C2-2fJul.js +0 -2
  182. package/dist/assets/AssistantUnreadBadge-p9mkpbMC.js +0 -1
  183. package/dist/assets/AssistantView-BR8hsjOv.js +0 -1
  184. package/dist/assets/AssistantWorkingAvatar-CoxhuMvM.js +0 -1
  185. package/dist/assets/AssistantsSettingsPage-Bwid1xE0.js +0 -1
  186. package/dist/assets/BinaryFileFallback-Cb3uP7y1.js +0 -1
  187. package/dist/assets/BtwPanel-9VAdk_qa.js +0 -6
  188. package/dist/assets/BusyDots-DeDkh4Ke.js +0 -4
  189. package/dist/assets/ChatContainer-wP6o_O4K.js +0 -65
  190. package/dist/assets/ChatView-DU_2-cfD.js +0 -3
  191. package/dist/assets/DiffViewToggle-BwJ6MYB7.js +0 -1
  192. package/dist/assets/ErrorBoundary-_5B1xjgZ.js +0 -1
  193. package/dist/assets/FadeInOnReveal-BYHr1gqj.js +0 -1
  194. package/dist/assets/GuiPluginPage-DM_RLx6u.js +0 -1
  195. package/dist/assets/GuiPluginSurface-KiyqqEKU.js +0 -1
  196. package/dist/assets/GuiPluginTitlebarItems-DxFINwbr.js +0 -1
  197. package/dist/assets/Icon-DmykXZL1.js +0 -1
  198. package/dist/assets/ImageLoadingPlaceholder-DgM_EFHn.js +0 -1
  199. package/dist/assets/MarkdownRenderer-D7p9Iflj.js +0 -2
  200. package/dist/assets/MarkstreamRendererImpl-BUk_c3g1.js +0 -3
  201. package/dist/assets/MobileAssistantTab-CMIQansR.js +0 -1
  202. package/dist/assets/MobileChatScreen-DDenVTX8.js +0 -1
  203. package/dist/assets/MobileDetailNavigation-ldTzGo19.js +0 -1
  204. package/dist/assets/MobileFilesSurface-DIVH9aPV.js +0 -2
  205. package/dist/assets/MobileHtmlNetworkBoundary-TBxrF4jJ.js +0 -2
  206. package/dist/assets/MobileOverlayPanel-C36VWWmN.js +0 -1
  207. package/dist/assets/MobileResizableSheet-CqphcaKq.js +0 -1
  208. package/dist/assets/MobileSurface-cmaGf3hZ.js +0 -1
  209. package/dist/assets/MobileTabPageHeader-D6P4K98S.js +0 -1
  210. package/dist/assets/ModelLogo-BkbD514M.js +0 -1
  211. package/dist/assets/ModelSelector-HJmXcB3j.js +0 -1
  212. package/dist/assets/MultiRunWindow-BmxVnblA.js +0 -1
  213. package/dist/assets/OnboardingScreen-DnEtIaxG.js +0 -1
  214. package/dist/assets/OverlayScrollbar-D6vmoMkQ.js +0 -1
  215. package/dist/assets/ProviderLogo-DA98yu7M.js +0 -1
  216. package/dist/assets/RemoteDesktopPanel-DBrEQwpr.js +0 -1
  217. package/dist/assets/ScheduledTasksDialog-BVh0yaZR.js +0 -3
  218. package/dist/assets/ScrollableOverlay-stxT7gLf.js +0 -1
  219. package/dist/assets/SettingsGroup-CvaPYznp.js +0 -1
  220. package/dist/assets/SettingsWindow-DpzeOekS.js +0 -1
  221. package/dist/assets/SetupTourDialog-CY_CU5qU.js +0 -1
  222. package/dist/assets/TerminalView-mO5f0Axl.js +0 -8
  223. package/dist/assets/TextSelectionMenu-VsKriqtT.js +0 -11
  224. package/dist/assets/assistantMessagePreview-DLBvPQtq.js +0 -1
  225. package/dist/assets/assistantQueries-NdPqu6rx.js +0 -1
  226. package/dist/assets/card-DmysoUAV.js +0 -1
  227. package/dist/assets/chatUpwardIntent-tvLWGs9Q.js +0 -1
  228. package/dist/assets/checkbox-BMN5hAVm.js +0 -1
  229. package/dist/assets/collapsible-Z0IjDAMO.js +0 -1
  230. package/dist/assets/context-menu-CKlB6wxo.js +0 -1
  231. package/dist/assets/diagram-CzY6n_4N.js +0 -1
  232. package/dist/assets/dialog-BeFBA6ja.js +0 -1
  233. package/dist/assets/dropdown-menu-BblI9sN2.js +0 -1
  234. package/dist/assets/githubAuthQueries-DqregESf.js +0 -1
  235. package/dist/assets/historyImportQueries-D00KjUT2.js +0 -1
  236. package/dist/assets/input-Cf16qJ6g.js +0 -1
  237. package/dist/assets/insertionBoundaries-BSDUOMHN.js +0 -1
  238. package/dist/assets/kbd-CamdaxHJ.js +0 -1
  239. package/dist/assets/main-CHO9s_kb.js +0 -2
  240. package/dist/assets/main-DAbyAg5_.js +0 -169
  241. package/dist/assets/mcpQueries-1WNtiFYh.js +0 -1
  242. package/dist/assets/miniChat-BZMkNMht.js +0 -2
  243. package/dist/assets/mobile-C9XDDOHq.js +0 -2
  244. package/dist/assets/mobileConnections-DjT1L-_m.js +0 -2
  245. package/dist/assets/multirun-D34EMeEj.js +0 -3
  246. package/dist/assets/openRemoteProjectSession-Bm_nafYw.js +0 -1
  247. package/dist/assets/pluginPresentation-DexqrdQ0.js +0 -2
  248. package/dist/assets/pwa-BaWpUiOR.js +0 -2
  249. package/dist/assets/queue-abort-optimistic-UwpgXn4g.js +0 -1
  250. package/dist/assets/remoteProjectQueries-C8382jM8.js +0 -1
  251. package/dist/assets/renderElectronMiniChatApp-CqrlQAsJ.js +0 -2
  252. package/dist/assets/renderMobileApp-CwcwGOox.js +0 -17
  253. package/dist/assets/runtime-file-resource-Bc_ss-sW.js +0 -2
  254. package/dist/assets/runtimeEndpointReset-DUD-TCLY.js +0 -4
  255. package/dist/assets/select-vZCgcnYG.js +0 -1
  256. package/dist/assets/session-startup-barrier-DT-hIBRf.js +0 -1
  257. package/dist/assets/sessionOwnership-CEkPFbS4.js +0 -2
  258. package/dist/assets/shortcuts-WkN3Gh8v.js +0 -1
  259. package/dist/assets/sortable-tabs-strip-DmtfYPz0.js +0 -1
  260. package/dist/assets/speechSettingsQueries-DQnPLEf3.js +0 -1
  261. package/dist/assets/switch-CNmsFYfY.js +0 -1
  262. package/dist/assets/textarea-ZiXxEOHK.js +0 -1
  263. package/dist/assets/tooltip-CpTbxEOE.js +0 -1
  264. package/dist/assets/truncated-path-CcmWjgCQ.js +0 -1
  265. package/dist/assets/ui-DrAJTWV6.js +0 -13
  266. package/dist/assets/useDesktopWindowControlsLayout-i6qqpMbd.js +0 -1
  267. package/dist/assets/useMcpConfigStore-BUSvv0Bl.js +0 -1
  268. package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +0 -1
  269. package/dist/assets/useMobileTranscriptSyncHint-86i3xO8J.js +0 -10
  270. package/dist/assets/useModelLists-Ca085-di.js +0 -1
  271. package/dist/assets/useOpenCodeReadiness-CsNcdsCJ.js +0 -1
  272. package/dist/assets/usePluginsStore-ZHQOW-R5.js +0 -1
  273. package/dist/assets/useProjectGitActions-1QRsD7Rb.js +0 -1
  274. package/dist/assets/useQuotaStore-CSn2pk3T.js +0 -1
  275. package/dist/assets/worktreeManager-QmahFqHc.js +0 -1
  276. package/dist/assets/yuriEvents-BFrD5fMU.js +0 -5
@@ -0,0 +1,169 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-DdSUE2kP.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DA-qfGHk.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-CiUKDeXd.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-C5kmYlLv.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-C3ewjGgP.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-BYunNOBo.js","assets/runtime-file-download-1s2Al1t3.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/ui-CHdferA1.js","assets/gitApiHttp-Bswf6gnl.js","assets/client-ITylDDCS.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BGppTOgV.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-BXrXdLjN.js","assets/i18n-Dojvs57M.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DRUKTpV5.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-dLjM4aiu.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-CpJZ4Rqs.js","assets/Icon-B-w2YKpn.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-CmjXOKMz.js","assets/dialog-D9CkSNCA.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-DZqC-2HE.js","assets/mobileBackNavigation-DsDUTnFY.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-DsgRtfYG.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-CsEylQVj.js","assets/markdownHeightCache-RX04MAqu.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-Cq_p4gAe.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-DkxhEUhV.js","assets/touch-gestures-DOoBxhz5.js","assets/TerminalView-CMugifkh.js","assets/terminalApi-ClNhXBA8.js","assets/vendor-ghostty-web-DbBrwBII.js","assets/OverlayScrollbar-DS6XJ1HA.js","assets/device-EIfSfSWk.js","assets/useProjectRuntimeAPIs-D51dVo-V.js","assets/sortable-tabs-strip-DACGW9sB.js","assets/vendor-dnd-kit-core-qy5stxu5.js","assets/vendor-dnd-kit-accessibility-u0XSXxKq.js","assets/vendor-dnd-kit-sortable-CiTIuX4o.js","assets/useFontPreferences-Bb-bxdL8.js","assets/project-preview-BcLPKzwg.js","assets/relay-preview-frame-src-BPyz3nXA.js","assets/projectActions-BPmI9_mW.js","assets/DiagramView-j7aFp44v.js","assets/diagram-DFXqN638.js","assets/vendor-react-drawio-C9rszQEJ.js","assets/SettingsView-C62JngPE.js","assets/desktopHosts-BsTrBVja.js","assets/desktopRelayRestore-BxbRKak_.js","assets/vendor-codemirror-autocomplete-C0FrlFqZ.js","assets/ScrollableOverlay-CkX-buJm.js","assets/tooltip-Dw3DApa-.js","assets/react-CPBNl-S9.js","assets/dropdown-menu-BT_66BFT.js","assets/dropdown-menu.styles-BDla58Rm.js","assets/context-menu-DZunhC8o.js","assets/collapsible-CL3SPnOf.js","assets/textarea-IhQHekYx.js","assets/gitApi-CBfYFgtd.js","assets/GuiPluginMount-BCqt2pmM.js","assets/MobileHtmlNetworkBoundary-BKSYPR9N.js","assets/input-BllFKOjo.js","assets/shortcuts-Cu4ioDvH.js","assets/assistantQueries-DxvTFlpL.js","assets/MobileDetailNavigation-DKWnQoSh.js","assets/pwa-Br2HZksc.js","assets/vendor-simplewebauthn-browser-Dwhcdg_5.js","assets/ErrorBoundary-CCH4LiRY.js","assets/card-D44sTpdY.js","assets/ProviderLogo-Cm9RNV_U.js","assets/zhipuai-coding-plan-CcFj8zKy.js","assets/select-BOtGs1FV.js","assets/MobileResizableSheet-CF3Pbot4.js","assets/githubAuthQueries-C5RxUNL2.js","assets/projectMeta-vIaGFaQr.js","assets/timeFormat-BsuUDWLs.js","assets/permission-rules-DoQUXKll.js","assets/useQuotaStore-mZs9LTwx.js","assets/quota-2PwXAoIg.js","assets/router-DXUi1sBd.js","assets/contextPanelEmbeddedChat-Dm5R_b5X.js","assets/sessionOwnership-BPfk1qCS.js","assets/types-BBBwzIOU.js","assets/mcpQueries-qRW-HQMx.js","assets/usePluginsStore-BLncdNj-.js","assets/switch-DaUn0G3u.js","assets/SettingsGroup-kZ_faXwL.js","assets/useMcpConfigStore-ZsZxSrCt.js","assets/native-config-Czc142JT.js","assets/YuriLogo-Ceon25sC.js","assets/MobileTabPageHeader-0aJFe3_x.js","assets/MobileSurface-DGNomvlu.js","assets/GuiPluginWindow-CDycMqzT.js","assets/pluginPresentation-p_0sXPMT.js","assets/ModelLogo-D27dq-si.js","assets/useDictation-sdgDfATy.js","assets/audio-session-BFWjrDbp.js","assets/browserVoiceService-x5Pci8L3.js","assets/speechSettingsQueries-BU-4Axb5.js","assets/pluginPresentation-C0HSdVvS.css","assets/ModelSelector-Dg__8QLh.js","assets/useModelLists-B0qSYDby.js","assets/useOpenCodeReadiness-B9d-wLZB.js","assets/AgentSelector-K5JSbXv3.js","assets/AgentAvatar-CNOu_vy0.js","assets/vendor-dicebear-core-CV95S5Pg.js","assets/vendor-dicebear-styles-C4OfoX7R.js","assets/AssistantsSettingsPage-Dt4OP3J-.js","assets/MobileShareBridge-CRq9F1rn.js","assets/mobileConnections-PVy2SsQ_.js","assets/assistantPresentation-DRbsH1Ej.js","assets/scheduledTaskNavigation-VVTOq9n2.js","assets/vendor-qrcode-D7jBCyl-.js","assets/vendor-dijkstrajs-BAzPDGZM.js","assets/ArchivedSessionsDialog-CU9RXl8K.js","assets/vendor-codemirror-lang-angular-Cm7vBE3E.js","assets/vendor-codemirror-lang-json-DowyFczU.js","assets/vendor-codemirror-lang-markdown-npWBZIoE.js","assets/vendor-codemirror-lang-python-OPRdU26g.js","assets/vendor-codemirror-legacy-modes-DwltVFbT.js","assets/MobileOverlayPanel-DcRWQlmf.js","assets/worktreeManager-V6hoSVxH.js","assets/vendor-codemirror-commands-5saeUOVY.js","assets/vendor-codemirror-search-hZY-L2l8.js","assets/vendor-replit-codemirror-vim-BmQmU1lR.js","assets/vendor-codemirror-language-data-B3pLWvv-.js","assets/vendor-yaml-C9KlJAlj.js","assets/SettingsWindow-Cm8apHAR.js","assets/MultiRunWindow-COqSg1Nk.js","assets/multirun-C2RRF2Q3.js","assets/useGitStore-Bbmai549.js","assets/checkbox-DaKe0Tlq.js","assets/insertionBoundaries-Br0Bdl9R.js","assets/spacedFileMention-Ds4GtgiF.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useDebouncedValue-BHlMPqY8.js","assets/fileMentionTouchSelection-B_62hIQI.js","assets/vendor-fuzzysort-ukaRp9PC.js","assets/fileMentionAutocompleteState-B9411b4o.js","assets/worktreeSourceBranchPreference-MQFPkOZy.js","assets/AssistantView-CDPTtrUZ.js","assets/mobileAppContext-BQgdTp5T.js","assets/AssistantConversationSurface-u3ndSmZP.js","assets/LoadingImage-B3IL7hnv.js","assets/chatUpwardIntent-CnS7WWRL.js","assets/reference-history-BwtzPAmA.js","assets/reference-history-8C8nv-EP.css","assets/vendor-motion-vLNN8EMu.js","assets/assistant-attachment-cache-eNT2QtmP.js","assets/AssistantWorkingAvatar-Vghb8xlt.js","assets/AssistantSessionCard-MYBAni6A.js","assets/sessionLookup-BTQ_AtWh.js","assets/AssistantConversationSurface-B59k-lXE.css","assets/AssistantUnreadBadge-opyLZlZd.js","assets/sortAssistantContacts-CcEdm3mS.js","assets/assistantMessagePreview-C7YAFen1.js","assets/navigation-C1v9hIAT.js","assets/OnboardingScreen-DUNyDwc6.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,i as r,p as i,t as a,v as o,w as s}from"./runtime-auth-DA-qfGHk.js";import{c,f as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./runtime-switch-DEPKHgdL.js";import{n as g}from"./runtime-fetch-V-iMWR8t.js";import{$ as _,A as v,F as y,G as b,H as x,I as S,L as C,P as w,Q as T,R as E,U as D,W as O,X as k,a as A,c as j,ct as M,dt as N,f as P,it as F,j as I,k as L,l as R,lt as z,m as ee,p as B,s as te,st as ne,u as re,ut as ie,v as ae,z as oe}from"./platform-CiUKDeXd.js";import{n as V,t as H}from"./runtimeAPIRegistry-C2VogTny.js";import{d as se,h as U,m as ce,r as le,v as ue}from"./desktopHosts-BsTrBVja.js";import{a as de,i as fe,t as pe}from"./vendor-zustand-CTekDqaS.js";import{A as me,B as he,C as ge,H as _e,M as ve,P as ye,S as be,V as xe,b as Se,it as Ce,j as we,k as Te,ot as Ee,st as De,v as Oe,x as ke,y as Ae,z as je}from"./vendor-base-ui-wXsskyKm.js";import{Ct as Me,Et as Ne,Ft as Pe,Mt as Fe,Pt as Ie,St as W,Tt as Le,an as Re,jt as ze,on as Be,wt as Ve,xt as He}from"./gitApiHttp-Bswf6gnl.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as Ue,r as We,t as Ge}from"./safeStorage-DTOhKN0V.js";import{B as Ke,H as qe,Jt as Je,Rt as Ye,St as Xe,Xt as Ze,Zt as Qe,an as $e,ft as et,ht as tt,mt as nt,n as rt,on as it,qt as at,rn as ot,tn as st,vr as ct,zt as lt}from"./client-ITylDDCS.js";import{P as ut,d as dt,z as ft}from"./prompt-attachment-upload-BGppTOgV.js";import{n as pt,t as mt}from"./vendor-react-BkccXcWz.js";import{f as ht,u as gt}from"./vendor-tanstack-query-core-BSjXNgF_.js";import{n as _t,o as vt,s as yt}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as bt,H as xt,L as St,O as Ct,P as wt,V as Tt,c as Et,q as Dt,r as Ot,s as kt,t as At,y as jt,z as Mt}from"./runtime-file-resource-C5kmYlLv.js";import{a as Nt,n as Pt}from"./path-utils-jGozTg9d.js";import{h as Ft,m as It,r as G}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as Lt}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as Rt,i as zt,o as Bt,r as K,s as Vt,t as Ht}from"./useUIStore-C3ewjGgP.js";import{o as Ut}from"./useMobileHtmlPreviewStore-BYunNOBo.js";import{n as Wt,r as Gt}from"./terminalApi-ClNhXBA8.js";import{a as Kt}from"./types-BBBwzIOU.js";import{t as qt}from"./bootstrap-eLlfzqAI.js";/* empty css */import{U as Jt}from"./vendor-codemirror-autocomplete-C0FrlFqZ.js";import{n as Yt}from"./vendor-pierre-diffs-B0OmIhMO.js";import{$r as Xt,A as Zt,Ai as Qt,Ba as $t,Bi as en,Br as tn,Ct as nn,Di as rn,F as an,Fi as on,Gr as sn,H as cn,Ha as ln,Hr as un,I as dn,Ji as fn,Jr as pn,Kt as mn,Mi as hn,Na as gn,Pi as _n,Pn as vn,Qr as yn,R as bn,S as xn,Si as Sn,Tt as Cn,U as wn,Ua as Tn,Vr as En,W as Dn,Wr as On,Xr as kn,Yi as An,Yn as q,an as jn,ao as Mn,ar as Nn,b as Pn,br as Fn,bt as In,co as Ln,ct as Rn,dt as zn,et as Bn,f as Vn,gn as Hn,h as Un,ht as Wn,in as Gn,io as Kn,it as qn,ji as Jn,k as Yn,ki as Xn,la as Zn,li as Qn,lt as $n,mt as er,no as J,o as tr,oo as nr,ot as rr,p as ir,pi as ar,pt as or,qi as sr,ro as cr,si as lr,so as ur,st as dr,t as Y,ta as fr,to as pr,tt as mr,un as hr,v as gr,wt as _r,x as vr,xt as yr,y as br,yr as xr,yt as Sr,zi as Cr}from"./ui-CHdferA1.js";import{n as X,t as wr}from"./Icon-B-w2YKpn.js";import{d as Tr,h as Er,m as Dr,p as Or}from"./remoteProjectQueries-BXrXdLjN.js";import{a as kr,i as Ar,n as jr,r as Mr,t as Nr}from"./i18n-Dojvs57M.js";import{n as Pr}from"./store-DRUKTpV5.js";import{n as Fr}from"./input-store-dLjM4aiu.js";import{a as Ir,c as Lr,i as Rr,l as zr,o as Br,s as Vr}from"./toolHelpers-iEHVHQ9p.js";import{n as Hr}from"./useAssistantUIStore-CpJZ4Rqs.js";import{n as Ur,t as Wr}from"./ScrollableOverlay-CkX-buJm.js";import{n as Gr,o as Kr}from"./vendor-framer-motion-D5NyyC73.js";import{a as qr,i as Jr,n as Yr,o as Xr,r as Zr,t as Qr}from"./dialog-CmjXOKMz.js";import{i as $r,n as ei,r as ti,t as ni}from"./tooltip-Dw3DApa-.js";import{n as ri,t as ii}from"./useInlineCommentDraftStore-DrC99u6A.js";import{n as ai}from"./useThemeSystem-BIXghnHj.js";import{a as oi,i as si,n as ci,r as li,t as ui}from"./useProjectGitActions-CHMe1ku4.js";import{a as di,r as fi}from"./device-EIfSfSWk.js";import{t as pi}from"./SyncActions-Blnq08ks.js";import{i as mi,n as hi,r as gi,t as _i}from"./dropdown-menu.styles-BDla58Rm.js";import{c as vi,i as yi,n as bi,r as xi,s as Si,t as Ci}from"./dropdown-menu-BT_66BFT.js";import{a as wi,i as Ti,n as Ei,r as Di,t as Oi}from"./context-menu-DZunhC8o.js";import{n as ki,r as Ai,t as ji}from"./collapsible-CL3SPnOf.js";import{a as Mi,i as Ni,n as Pi,o as Fi,r as Ii}from"./PierreDiffViewer-BHwj_6j8.js";import{n as Li,t as Ri}from"./kbd-CwkasrzN.js";import{t as zi}from"./DiffWorkerProvider-VFPkag9y.js";import{n as Bi,t as Vi}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Hi}from"./themes-BgDJcxRc.js";import{n as Ui,t as Wi}from"./useEffectiveDirectory-DZqC-2HE.js";import{n as Gi,t as Ki}from"./useProjectRuntimeAPIs-D51dVo-V.js";import{b as qi,h as Ji,m as Yi}from"./gitApi-CBfYFgtd.js";import{a as Xi,o as Zi,s as Qi}from"./useGitStore-Bbmai549.js";import{a as $i,i as ea,n as ta,o as na,r as ra,s as ia,t as aa}from"./useProjectGitStore-Lz9AV32V.js";import{i as oa,n as sa,r as ca}from"./MobileHtmlNetworkBoundary-BKSYPR9N.js";import{n as la,t as ua}from"./relay-preview-frame-src-BPyz3nXA.js";import{a as da,i as fa,n as pa,r as ma,t as ha}from"./BinaryFileFallback-CJqnlBzh.js";import{t as ga}from"./ImageLoadingPlaceholder-DsgRtfYG.js";import{t as _a}from"./LoadingImage-B3IL7hnv.js";import{t as va}from"./input-BllFKOjo.js";import{n as ya,o as ba}from"./MarkdownRenderer-CsEylQVj.js";import{c as xa,i as Sa,l as Ca,n as wa,o as Ta,s as Ea}from"./shortcuts-Cu4ioDvH.js";import{n as Da,r as Oa}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as ka}from"./useSessionBtwStore-CYaTDkvT.js";import{t as Aa}from"./useDebouncedValue-BHlMPqY8.js";import{m as ja,x as Ma,y as Na}from"./assistantQueries-DxvTFlpL.js";import{A as Pa,C as Fa,D as Ia,E as La,F as Ra,I as za,M as Ba,N as Va,O as Ha,P as Ua,R as Wa,S as Ga,T as Ka,_ as qa,b as Ja,c as Ya,d as Xa,f as Za,g as Qa,h as $a,i as eo,j as to,k as no,l as ro,m as io,n as ao,p as oo,s as so,t as co,u as lo,v as uo,w as fo,x as po,y as mo,z as ho}from"./useAppFontEffects-Dw6o6XbA.js";import{C as go,S as _o,W as vo,_ as yo,c as bo,et as xo,g as So,h as Co,i as wo,m as To,o as Eo,p as Do,s as Oo,u as ko,v as Ao}from"./pwa-Br2HZksc.js";import{t as jo}from"./YuriLogo-Ceon25sC.js";import{t as Mo}from"./card-D44sTpdY.js";import{t as No}from"./ErrorBoundary-CCH4LiRY.js";import{a as Po,n as Fo,o as Io,r as Lo}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{i as Ro,r as zo}from"./connection-hint-SMNZFDAe.js";import{u as Bo}from"./insertionBoundaries-Br0Bdl9R.js";import{t as Vo}from"./ModelLogo-D27dq-si.js";import{_ as Ho,a as Uo,c as Wo,d as Go,f as Ko,i as qo,l as Jo,n as Yo,o as Xo,p as Zo,r as Qo,s as $o,u as es,y as ts}from"./ChatContainer-Dg9uDBjk.js";import{C as ns,i as rs,n as is,r as as}from"./BtwPanel-DnMW6R43.js";import{A as os,D as ss,E as cs,M as ls,O as us,P as ds,T as fs,X as ps,j as ms,k as hs}from"./BusyDots-FXSlMe2F.js";import{_ as gs,i as _s,l as vs,n as ys,s as bs,t as xs,v as Ss}from"./vendor-dnd-kit-core-qy5stxu5.js";import{a as Cs,n as ws,s as Ts,t as Es}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as Ds}from"./MobileOverlayPanel-DcRWQlmf.js";import{t as Os}from"./ProviderLogo-Cm9RNV_U.js";import{d as ks}from"./ToolOutputDialog-DdSUE2kP.js";import{t as As}from"./vendor-motion-vLNN8EMu.js";import{c as js,i as Ms,n as Ns,s as Ps,t as Fs}from"./select-BOtGs1FV.js";import{a as Is}from"./githubAuthQueries-C5RxUNL2.js";import{c as Ls,i as Rs,n as zs,s as Bs}from"./worktreeManager-V6hoSVxH.js";import{t as Vs}from"./sortable-tabs-strip-DACGW9sB.js";import{i as Hs}from"./auto-read-context-Ce0o43YI.js";import{n as Us,t as Ws}from"./timeFormat-BsuUDWLs.js";import{a as Gs,c as Ks,i as qs,n as Js,o as Ys,r as Xs,u as Zs}from"./useQuotaStore-mZs9LTwx.js";import{a as Qs,i as $s,n as ec,s as tc,t as nc}from"./quota-2PwXAoIg.js";import{i as rc,n as ic,r as ac,t as oc}from"./useDesktopWindowControlsLayout-DAkTdcAP.js";import{a as sc,i as cc}from"./sessionLookup-BTQ_AtWh.js";import{n as lc,t as uc}from"./openRemoteProjectSession-C5z2Juv7.js";import{n as dc}from"./useFontPreferences-Bb-bxdL8.js";import{$ as fc,A as pc,At as mc,Bt as hc,C as gc,D as _c,Dt as vc,E as yc,Et as bc,F as xc,Ft as Sc,G as Cc,H as wc,I as Tc,It as Ec,J as Dc,K as Oc,L as kc,Lt as Ac,M as jc,Mt as Mc,N as Nc,Nt as Pc,O as Fc,Ot as Ic,P as Lc,Pt as Rc,Q as zc,R as Bc,Rt as Vc,St as Hc,T as Uc,U as Wc,V as Gc,Vt as Kc,W as qc,X as Jc,Z as Yc,_t as Xc,a as Zc,at as Qc,b as $c,bt as el,et as tl,g as nl,i as rl,it as il,j as al,jt as ol,k as sl,kt as cl,n as ll,nt as ul,o as dl,q as fl,r as pl,rt as ml,s as hl,tt as gl,v as _l,vt as vl,x as yl,xt as bl,y as xl,yt as Sl,z as Cl,zt as wl}from"./runtimeEndpointReset-BKLVdNhJ.js";import{t as Tl}from"./YuriWordmark-CW53XKgV.js";import{_ as El,d as Dl,g as Ol,h as kl,m as Al,p as jl,r as Ml,t as Nl,v as Pl,y as Fl}from"./sessionOwnership-BPfk1qCS.js";import{i as Il,n as Ll}from"./icons-D_vRtitD.js";import{r as Rl,t as zl}from"./navigation-C1v9hIAT.js";import{t as Bl}from"./AssistantUnreadBadge-opyLZlZd.js";import{n as Vl,t as Hl}from"./GuiPluginPage-BSjWEmIu.js";import{d as Ul,i as Wl,n as Gl,r as Kl,u as ql}from"./historyImportQueries-CZsECryv.js";import{n as Jl}from"./ScheduledTasksDialog-DnwBC7cj.js";import{t as Yl}from"./ChatView-AFUNEBdD.js";import{t as Xl}from"./diagram-DFXqN638.js";import{t as Zl}from"./DiffView-DZ_gKyTO.js";import{a as Ql,i as $l,n as eu,o as tu,r as nu,t as ru}from"./multirun-C2RRF2Q3.js";import{_ as iu,a as au,c as ou,d as su,f as cu,g as lu,h as uu,i as du,l as fu,m as pu,o as mu,p as hu,r as gu,s as _u,t as vu,u as yu}from"./ArchivedSessionsDialog-CU9RXl8K.js";import{a as bu,i as xu,n as Su,r as Cu,t as wu}from"./projectActions-BPmI9_mW.js";import{t as Tu}from"./GuiPluginTitlebarItems-DfHugxsx.js";import{t as Eu}from"./vendor-zumer-snapdom-yq9vlCKr.js";import{n as Du,t as Ou}from"./vendor-html-to-image-BDMm2v6d.js";var Z=e(De(),1),ku=mt(),Q=pt(),$=Ee();function Au(e){let t=(0,Q.c)(14),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({size:i,className:n,style:a,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=typeof i==`number`?`${i}px`:i,s=typeof i==`number`?`${i}px`:i,c;t[5]!==a||t[6]!==o||t[7]!==s?(c={width:o,height:s,...a},t[5]=a,t[6]=o,t[7]=s,t[8]=c):c=t[8];let l;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`path`,{d:`M112,148a12,12,0,0,0-12,12v19L69.17,148.2A4,4,0,0,1,68,145.37V97.94a36,36,0,1,0-24,0v47.43a27.81,27.81,0,0,0,8.2,19.8L83,196H64a12,12,0,0,0,0,24h48a12,12,0,0,0,12-12V160A12,12,0,0,0,112,148ZM56,52A12,12,0,1,1,44,64,12,12,0,0,1,56,52ZM212,158.06V110.63a27.81,27.81,0,0,0-8.2-19.8L173,60h19a12,12,0,0,0,0-24H144a12,12,0,0,0-12,12V96a12,12,0,0,0,24,0V77l30.83,30.83a4,4,0,0,1,1.17,2.83v47.43a36,36,0,1,0,24,0ZM200,204a12,12,0,1,1,12-12A12,12,0,0,1,200,204Z`}),t[9]=l):l=t[9];let u;return t[10]!==n||t[11]!==r||t[12]!==c?(u=(0,$.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 256 256`,fill:`currentColor`,className:n,style:c,...r,children:l}),t[10]=n,t[11]=r,t[12]=c,t[13]=u):u=t[13],u}var ju=!1,Mu=0,Nu=new Set,Pu=async()=>{let e=++Mu;try{let t=await I(`desktop_is_window_fullscreen`);if(e!==Mu||t===ju)return;ju=t===!0,Nu.forEach(e=>e())}catch{}},Fu=e=>y()?(Nu.add(e),Nu.size===1&&(window.addEventListener(`yuri:window-resized`,Pu),Pu()),()=>{Nu.delete(e),Nu.size===0&&(window.removeEventListener(`yuri:window-resized`,Pu),Mu++,ju=!1)}):()=>{};function Iu(){return(0,Z.useSyncExternalStore)(Fu,Ru,Lu)}function Lu(){return!1}function Ru(){return ju}function zu(){let e=(0,Q.c)(19),{t}=Nr(),n=K(Wu),r=K(Uu),i=K(Hu),a=K(Vu),o=K(Bu),s=n&&r||i,c;e[0]!==n||e[1]!==r||e[2]!==i||e[3]!==a||e[4]!==o?(c=()=>{if(!r){n||a(!0),o(!i);return}a(!n)},e[0]=n,e[1]=r,e[2]=i,e[3]=a,e[4]=o,e[5]=c):c=e[5];let l=G(c),u;e[6]===t?u=e[7]:(u=t(`header.workStatusPanel.toggleAria`),e[6]=t,e[7]=u);let d;e[8]===t?d=e[9]:(d=t(`header.workStatusPanel.toggleAria`),e[8]=t,e[9]=d);let f=s?`text-foreground`:`text-muted-foreground/50`,p;e[10]===f?p=e[11]:(p=J(`app-region-no-drag size-7`,f),e[10]=f,e[11]=p);let m;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{name:`settings-2`,className:`size-4`}),e[12]=m):m=e[12];let h;return e[13]!==s||e[14]!==u||e[15]!==d||e[16]!==p||e[17]!==l?(h=(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,"data-work-status-toggle":`true`,"aria-pressed":s,"aria-label":u,title:d,onClick:l,className:p,children:m}),e[13]=s,e[14]=u,e[15]=d,e[16]=p,e[17]=l,e[18]=h):h=e[18],h}function Bu(e){return e.setWorkStatusOverlayOpen}function Vu(e){return e.setWorkStatusPanelEnabled}function Hu(e){return e.workStatusOverlayOpen}function Uu(e){return e.workStatusPanelFits}function Wu(e){return e.workStatusPanelEnabled}var Gu=(e,t,n)=>vt({queryKey:[`desktop-host-inventory`,e],queryFn:async({signal:e})=>{let r=await le(),i=new Set(r.sshHostIds??[]);if(r.sshHostIds===void 0&&B()){let e=await vo();for(let t of e.instances)i.add(t.id)}return e.throwIfAborted(),{hosts:r.hosts.filter(e=>ce(e,i)||t===`host:${e.id}`||!!(n&&U(n,se(e)))),sshIds:i}}});function Ku(e){let t=(0,Q.c)(18),{onClick:n,open:r}=e,{t:i}=Nr(),a=Z.useSyncExternalStore(c,u,u),o=K(qu),s=p(),l=h(),d=w(),{data:f}=yt({...Gu(a,s,l),enabled:!o}),m=s.startsWith(`host:`)?s.slice(5):null,g=f?.hosts.find(e=>m?e.id===m:!!(l&&U(l,se(e))));if(d&&!f?.hosts.length&&!f?.sshIds.size)return null;let _=g?ue(g.label):i(d?`desktopHostSwitcher.instance.local`:`desktopHostSwitcher.title`),v=Ra({isLocal:d,isSsh:!!(g&&f?.sshIds.has(g.id)),isRelay:a.startsWith(`relay:`)}),y=ni,b=$r,x=q,S=i(`header.actions.sessionMenu.servicesWithInstance`,{current:_}),C;t[0]===v?C=t[1]:(C=(0,$.jsx)(`span`,{className:`inline-flex h-full w-7 items-center justify-center`,children:(0,$.jsx)(X,{name:v,className:`size-5`})}),t[0]=v,t[1]=C);let T;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(`span`,{className:`inline-flex h-full w-3 items-center justify-center`,children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-2.5`})}),t[2]=T):T=t[2];let E;t[3]!==x||t[4]!==n||t[5]!==r||t[6]!==S||t[7]!==C?(E=(0,$.jsxs)(x,{variant:`ghost`,size:`sm`,className:`app-region-no-drag h-7 w-12 gap-0 self-center rounded-md border border-border/40 px-1 py-0 text-muted-foreground hover:text-foreground`,"aria-label":S,"aria-expanded":r,"aria-haspopup":`menu`,onClick:n,children:[C,T]}),t[3]=x,t[4]=n,t[5]=r,t[6]=S,t[7]=C,t[8]=E):E=t[8];let D;t[9]!==b||t[10]!==E?(D=(0,$.jsx)(b,{asChild:!0,children:E}),t[9]=b,t[10]=E,t[11]=D):D=t[11];let O;t[12]===_?O=t[13]:(O=(0,$.jsx)(ei,{children:_}),t[12]=_,t[13]=O);let k;return t[14]!==y||t[15]!==O||t[16]!==D?(k=(0,$.jsxs)(y,{children:[D,O]}),t[14]=y,t[15]=O,t[16]=D,t[17]=k):k=t[17],k}function qu(e){return e.isSettingsDialogOpen}var Ju=[{id:`finder`,label:`Finder`,appName:`Finder`},{id:`terminal`,label:`Terminal`,appName:`Terminal`},{id:`iterm2`,label:`iTerm2`,appName:`iTerm`},{id:`ghostty`,label:`Ghostty`,appName:`Ghostty`},{id:`vscode`,label:`VS Code`,appName:`Visual Studio Code`},{id:`vscode-insiders`,label:`VS Code Insiders`,appName:`Visual Studio Code - Insiders`},{id:`intellij`,label:`IntelliJ`,appName:`IntelliJ IDEA`},{id:`visual-studio`,label:`Visual Studio`,appName:`Visual Studio`},{id:`cursor`,label:`Cursor`,appName:`Cursor`},{id:`android-studio`,label:`Android Studio`,appName:`Android Studio`},{id:`pycharm`,label:`PyCharm`,appName:`PyCharm`},{id:`xcode`,label:`Xcode`,appName:`Xcode`},{id:`sublime-text`,label:`Sublime`,appName:`Sublime Text`},{id:`webstorm`,label:`WebStorm`,appName:`WebStorm`},{id:`rider`,label:`Rider`,appName:`Rider`},{id:`zed`,label:`Zed`,appName:`Zed`},{id:`wu`,label:`Wu`,appName:`Wu`},{id:`phpstorm`,label:`PhpStorm`,appName:`PhpStorm`},{id:`eclipse`,label:`Eclipse`,appName:`Eclipse`},{id:`windsurf`,label:`Windsurf`,appName:`Windsurf`},{id:`vscodium`,label:`VSCodium`,appName:`VSCodium`},{id:`rustrover`,label:`RustRover`,appName:`RustRover`},{id:`kiro`,label:`Kiro`,appName:`Kiro`},{id:`antigravity`,label:`Antigravity`,appName:`Antigravity`},{id:`trae`,label:`Trae`,appName:`Trae`}],Yu=`finder`,Xu=new Set([`finder`,`terminal`]),Zu=e=>typeof window<`u`&&window.__YURI_PLATFORM__===`win32`&&e.id===`finder`?{...e,label:`Explorer`,appName:`File Explorer`}:e,Qu=e=>{if(!e)return null;let t=Ju.find(t=>t.id===e)??null;return t?Zu(t):null},$u=()=>Ju.filter(e=>Xu.has(e.id)).map(e=>({...Zu(e)})),ed=()=>{if(typeof window>`u`)return Yu;let e=window.localStorage.getItem(`openInAppId`);return e&&Qu(e)?e:Yu},td=!1,nd=!1,rd=!1,id=0,ad=null,od=()=>{ad&&=(clearTimeout(ad),null)},sd=de()((e,t)=>({selectedAppId:ed(),availableApps:$u(),hasLoadedApps:!1,isCacheStale:!1,isScanning:!1,initialize:()=>{if(td||typeof window>`u`)return;td=!0;let n=(t,n=!0)=>{if(!Array.isArray(t)||t.length===0){e({availableApps:$u(),hasLoadedApps:n});return}let r=new Set(t.map(e=>e.name)),i=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0]));e({availableApps:Ju.filter(e=>r.has(e.appName)||Xu.has(e.id)).map(e=>({...Zu(e),iconDataUrl:i.get(e.appName)})),hasLoadedApps:!0})},r=async i=>{if(!y()||nd||t().hasLoadedApps&&!i)return;let a=Ju.map(e=>e.appName);od(),i&&e({hasLoadedApps:!1}),nd=!0,rd=!1,e({isScanning:!0});try{let{apps:t,success:o,hasCache:s,isCacheStale:c}=await ae(a,i),l=o&&!s&&t.length===0&&id<3;if(e({isCacheStale:s?c:!1}),n(t,o?!l:!1),o){if(l){let e=[800,1600,3200][id]??3200;id+=1,rd=!0,ad=setTimeout(()=>{r()},e);return}id=0,rd=!1;return}if(id<3){let e=[1e3,3e3,7e3][id]??7e3;id+=1,rd=!0,ad=setTimeout(()=>{r()},e)}}finally{nd=!1,rd||e({isScanning:!1})}};r(),window.addEventListener(`yuri:settings-synced`,t=>{let n=t.detail,r=n&&typeof n.openInAppId==`string`&&n.openInAppId.length>0&&Qu(n.openInAppId)?n.openInAppId:null;r&&(window.localStorage.setItem(`openInAppId`,r),e({selectedAppId:r}))}),window.addEventListener(`yuri:app-ready`,()=>{r()}),window.addEventListener(`yuri:installed-apps-updated`,t=>{let r=t.detail;Array.isArray(r)&&(id=3,rd=!1,e({isScanning:!1,isCacheStale:!1}),n(r))}),window.__yuriAppReady&&r(),window.setTimeout(()=>{t().hasLoadedApps||r()},5e3)},loadInstalledApps:async n=>{if(td||t().initialize(),!y()||nd||t().hasLoadedApps&&!n)return;let r=Ju.map(e=>e.appName);od(),n&&e({hasLoadedApps:!1}),nd=!0,rd=!1,e({isScanning:!0});try{let{apps:t,hasCache:i,isCacheStale:a}=await ae(r,n),o=new Set(t.map(e=>e.name)),s=new Map(t.map(e=>[e.name,e.iconDataUrl??void 0])),c=Ju.filter(e=>o.has(e.appName)||Xu.has(e.id)).map(e=>({...e,iconDataUrl:s.get(e.appName)}));e({availableApps:c.length>0?c:$u(),hasLoadedApps:c.length>0,isCacheStale:i?a:!1})}finally{nd=!1,rd||e({isScanning:!1})}},selectApp:async t=>{Qu(t)&&(e({selectedAppId:t}),typeof window<`u`&&window.localStorage.setItem(`openInAppId`,t),await Pe({openInAppId:t}))}})),cd=(e=p(),t=u())=>{let n=e.startsWith(`host:`)?e.slice(5):null;return{queryKey:[t,`ssh-editor-apps`,n],enabled:y()&&v()&&n!==null,queryFn:async({signal:e})=>{let t=await I(`desktop_ssh_editor_apps`,{hostId:n});return e.throwIfAborted(),t?{hostId:n,appIds:t.appIds}:null}}},ld=()=>{let e=(0,Q.c)(3),t=(0,Z.useSyncExternalStore)(c,p,ud),n=(0,Z.useSyncExternalStore)(c,u,dd),r;return e[0]!==t||e[1]!==n?(r=cd(t,n),e[0]=t,e[1]=n,e[2]=r):r=e[2],yt(r)};function ud(){return``}function dd(){return``}var fd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAXaSURBVFgJ7VddbBRVFP5mdme6dOnu2tZawOAPjfxU+bGQYCRAsvw8qNGEQPTRJ0I0amL0wfjgA/HBR8KLD8YgDxJEUkVFxSYYTSRii6DQQCMGIQqlW7p0u+zMzo/fuTuzO9Nt0Td94CRn7pl7z5zznZ977y5wh/7jDGiz+T979qD5Ujbfd90xlll+stOF1uI40B1+4HhkjnZk9CgLQ9iXp2/BdcbgVc/h0sAgduywudJEMwLY9Of4ugtW5p3CpL7W1jTN88VmjdQYvnDKF1mczkYuNZLeCVg3X8fa9u+nqzUB2HRpdN2pSseRQknPoUL1Jo2ICTrPGcCzdwPdHENcAnicKRqcAk7cpL5J1r0JlAtPYV1XDETM/FtH3m19r+f5by+XjNX/xnmCX3/cCzydi4CKiC7lw+PArhGgoPPFq/6E0+9vwM6d5VBNpuv03cLNfeNTRh9KnJIiV2/PvSngycC5RD+dE5zb3g7s6QESzAZc2l6wuY9SnWIAxv10r81uU85Vt1FvtpEtlc/SMFUkUofeZ2IBta0DWDmXgkfbyTRz1qAYAMczOz3p1elOxYPyEllj421hdELViPO6Kudk3ia3UGe5ABDbvtnJZ52SdYmCZ3stdeexBabFdeAbYopEowtagVUZqFapBrtAGqpiVaFrGgyjZlrmTD5yEqoEJj4iFMuA62i6L3WPZkAiuHgarZ/vbWSBkTzO2rfTR4XOJVJhjfX44MBn+OTocVWbcF5MalxXPeVL6zYonoGo44YOtDI7qHC1lkL5nHnOc+tJRi3K6iygLNGMjt1A1XVV6iUzOvVtAvMlS2I/yBYlRf8MgA6szmXQ1jDfKhSgjft6DRtrkgarAiAw5nI9v2WDSn+Zxfd9DawGxIlPPQUg0A2HGABfEIYlCDU4+q0d8O+jRzHCCFYy+nu4BaeYAoksBCDrPYsXQQ6iitgiSQaS1FHHtMzFil4DpxTl4UhORSn4WOaaiGsbu4iFRkMnYQlEV0oSJQGQ4FyYgSRDjpqPZcCR6EOOWonIEsBqArAIQOMLzw0VXRRERF2VoA6Atk1+MzsASekMJYgaFEeHR4Cr85lNGntYzgKCYd/NSNIDCXr0ZJ2jwTsjSvEMzFQCCVmKHBRahn2DNb4rDRx8pnbXOOIg0JELLMHOF1AUkaRj1V8c2TookkMS83WK9QCVpRwtf5wCykQWRKDyJ44Ytc452QUV6inmN9IDIv/6y2+YLDuqTywBEHxv8rsoxQC4Fpf4cZ2pbJ4/huxXr0EvFmoRCrAIVymLQ3Eid0GJYPsPfISBLwdwi79YQnCqBNS7LQDP5qYSAKEDypOrX4WVWYLsFy+i9cwh6CUmUKIJI2Gq5cSbnLLw849D2Ld3L4olC1u3P0c1ow5Ozgixa3puWChONG1D3eLZUQOglvng+Vp5dBfseesx5/yHyI4cBTL3wsssRGs2g6/ppHijiMLoNSSMNHofy6Nn6SPsAR02nUoTtrDTSrdoi8CTni55rlOsCf1ypaDxlFMNU1epCV5XL6Y6dmOq+BeS48NIlq7Anpjg5dOFbPdDWLQyj/aubnUKSkMKi3NhkUd4kieYtbRbYS0bFAOQKI8NO363z1RJHmamtnlwhGksxV2w/gl29WRtm8kWtWUnRShLnQvXgDOXmLg2HzlvbDiyHD8Y517YP2i4FtueFPbB9FFqKcyobk4A5y7zquUFa7IXojyHoeXmAFcY755vaI6A56Xsofm/7+cmblBTpOldQ5vs3PJDVS+RVSAaus2SpJTO80t4NTNSOQfCDrtFkBevA0ME6HGvPdDpFlekzm7rf3nFQNRQEwBZTL9warObWfx21Uv1+fx1ERqVNampGoOHpF1tsdp07RnoGMxK1vT97rbK4IP6+Tc+fWXVsahaYGL6VO09d//GXHXr7jVeqmuppqU6ff4x0RO6lqRxgxHJpWKSlcw5eWfjq5rq/CdhaL5l6JWxjDc6bP7w5sn+/uMs2B36H2bgb6v9raK0+o9IAAAAAElFTkSuQmCC`,pd=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAEARoABQAAAAEAAAA+ARsABQAAAAEAAABGASgAAwAAAAEAAgAAh2kABAAAAAEAAABOAAAAAAAAAJAAAAABAAAAkAAAAAEAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAAB+C9pSAAAACXBIWXMAABYlAAAWJQFJUiTwAAABnWlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczpleGlmPSJodHRwOi8vbnMuYWRvYmUuY29tL2V4aWYvMS4wLyI+CiAgICAgICAgIDxleGlmOlBpeGVsWERpbWVuc2lvbj4yNTY8L2V4aWY6UGl4ZWxYRGltZW5zaW9uPgogICAgICAgICA8ZXhpZjpQaXhlbFlEaW1lbnNpb24+MjU2PC9leGlmOlBpeGVsWURpbWVuc2lvbj4KICAgICAgPC9yZGY6RGVzY3JpcHRpb24+CiAgIDwvcmRmOlJERj4KPC94OnhtcG1ldGE+Cl6wHhsAAAQzSURBVFgJ7VZNbBNHFH67Xv9RxwnBDqlUoQglcZK6qSIEJIQWAYJQoVY9IE5RTzn20FMvqdpDesq9B24+NdwthAJCkZChJg1JSOXYQIwQKQIaBdtENbs73t2+N8miGWOcpFHUHniyd97OvJ9v3nv7ZgDe038cAeVd/jOZjC94sKdfU+Bj24G9igpexwYPyiu2bauKqqqirkOTqmrjnIOyFsoyUKDocSCj/7mU7ujoMER5l68JYOFZ4YSiwPjd9O0jjx7ch1KhAJZVAcdx0LxDv3XetYKjggr4I4bzHo8G4aYmONjZBYf6+2dUzfd9PNowJajUZmef/PX5zcWl0rmvvnbQHrra+f/M+S+dqYXs2t3Hz09Ve5UicCmZ3NPb1Zv66btv+65dSULA64WGxkbw+Xx8V9XK9d4pWowxeFUqgW6acHroC/j5l0sLD/PZY98MDf3t6mouQ+On3X1H7/2e7rtOztHpgbY2+CAUgperq+D3+7cNgtLSEA7D0+VluDF5FS7cSff2HT56DF1dd/3KhQTWJ/lclsc8jIrk9IfRURgZGQEvRqNSWa8D2t1W/liXXK8Ro0i0lF0ExaPEXec0SgAqhrm3VCzwdS9GQNd1GBsbg0AgAIlEAlpbW7EYLVF/U56AagieiGwbuhERlSQApmEE8c/XKXxU0fF4HNowFfPz81Aul7edBjLGbeHITANsZga4g42HVAM2Y74KM/kSIQ/izgcHB2FiYgJmZmZ4MZpYULRG5PF4+Bx/2cLDxuhhYUqFLwGoWCaQEBGhNjAa4+Pj/J3SQA6pHpqbm/kcNitIJpOgaZIZvlbrQbZNJvcjSZOZDKhwRKLic4l2Pjc3B8FgkE+trKxAVUN0RWuOZNtCHyJJACj/bgREIZcnA9PT029SQM63unuywSOwUWOuTQmAhfmnlluPxIjUk6u1RrbJh0jyV0Ap2OZnJhrbjOcRqEqBBMDCAtltAORDJAkAVj2mWS5CUXinPDUx+oxFkgBYjO0qANu2wKoqQgkAfgW7C4AiYMmfoQSgwpjj7GYRUh/Q66SAmdisNxql227FfP1bXrRlVExdtCNHwDRLdPkgwmi8OUREhe3y1NLJFpEfbWMNvBRtSI2o+KqYi+zbx4NQwptMCO8E1HjEHYjKm/HknG5FZIsCG4lEoLS2lhP1JAB3bt1KH//s+GJPd3dPJpvlN5kwXiYIhHukisr1eAItXsm6YzGItrTcn5+dvS3qSQBSqVQhFouNnj039CsaCC7mcqDjgbNT6op1AtrU8Wo3Ojk5KaVAOptdR8PDwxf3t7SMvXjxvJNOPP31a35Krt8CXKl3j2SUDip/IAjRaBRaP9z/cHW18GMikbhcrVUTAAm1t7d/NDAwcDIUCvVqmtqkyLe3ajtvvTtg4x3SLpbLa3+kUr9N5fP55beE3k/8HyLwDx2/HIx7q3WfAAAAAElFTkSuQmCC`,md=e=>({...e,fallbackIconDataUrl:e.id===`finder`&&window.__YURI_PLATFORM__!==`win32`?fd:e.id===`terminal`?pd:void 0}),hd=e=>{let t=(0,Q.c)(8),{label:n,iconDataUrl:r,fallbackIconDataUrl:i}=e,[a,o]=Z.useState(!1),s;t[0]===n?s=t[1]:(s=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=s);let c=s,l=r||i;if(l&&!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>o(!0),t[2]=e):e=t[2];let n;return t[3]===l?n=t[4]:(n=(0,$.jsx)(`img`,{src:l,alt:``,className:`h-4 w-4 rounded-sm`,onError:e}),t[3]=l,t[4]=n),n}let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=J(`h-4 w-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=u):u=t[5];let d;return t[6]===c?d=t[7]:(d=(0,$.jsx)(`span`,{className:u,children:c}),t[6]=c,t[7]=d),d},gd=({directory:e,className:t})=>{let{t:n}=Nr(),r=sd(e=>e.selectedAppId),i=sd(e=>e.availableApps),a=sd(e=>e.isCacheStale),o=sd(e=>e.isScanning),s=sd(e=>e.initialize),c=sd(e=>e.loadInstalledApps),l=sd(e=>e.selectApp),{data:u}=ld(),d=Z.useMemo(()=>u?i.filter(e=>u.appIds.includes(e.id)):i,[i,u]);Z.useEffect(()=>{s()},[s]);let f=y()&&w(),p=Z.useMemo(()=>{let e=d.find(e=>e.id===r)??d.find(e=>e.id===`finder`)??d[0];return e?md(e):null},[d,r]);if(!f&&!u||!e)return null;let m=async t=>{try{let r=await b(e,t.id,t.appName,u?.hostId);!r&&!u?await O(e,t.appName):r||Y.error(n(`filesView.toast.openInAppFailed`,{app:t.label}))}catch(e){Y.error(n(String(e).includes(`SSH_EDITOR_CONFIG_REQUIRED`)?`openInApp.errors.sshConfigRequired`:`filesView.toast.openInAppFailed`,{app:t.label}))}},h=async e=>{await l(e.id),await m(e)},g=async()=>{await pr(e)};return(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex h-7 w-12 items-center self-center overflow-hidden rounded-md border border-border/40 px-1`,`hover:bg-interactive-hover transition-colors`,t),children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>void(p?m(p):g()),className:J(`inline-flex h-full w-7 items-center justify-center typography-ui-label font-medium`,`text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,o&&`animate-pulse`),"aria-label":p?n(`openInApp.actions.openInAria`,{app:p.label}):n(`openInApp.actions.copyPath`),children:p?(0,$.jsx)(hd,{label:p.label,iconDataUrl:p.iconDataUrl,fallbackIconDataUrl:p.fallbackIconDataUrl}):(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4`})}),(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-full w-3 items-center justify-center text-muted-foreground`,`hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`),"aria-label":n(`openInApp.actions.chooseAppAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-2.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void g(),children:[(0,$.jsx)(X,{name:`file-copy`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.copyPath`)})]}),(0,$.jsx)(Si,{}),d.map(e=>{let t=md(e);return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void h(e),children:[(0,$.jsx)(hd,{label:e.label,iconDataUrl:e.iconDataUrl,fallbackIconDataUrl:t.fallbackIconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label}),p?.id===e.id?(0,$.jsx)(X,{name:`check`,className:`ml-auto h-4 w-4 text-primary`}):null]},e.id)}),a?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void c(!0),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n(`openInApp.actions.refreshApps`)})]}):null]})]})]})},_d=[{pattern:/^dev(:.*)?$/i},{pattern:/^start(:.*)?$/i},{pattern:/^preview(:.*)?$/i},{pattern:/^serve(:.*)?$/i},{pattern:/^develop(:.*)?$/i}],vd=[`dev`,`start`,`preview`,`serve`];async function yd(e,t,n,r){if(!e)return null;let i=Sd(t);if(i)return{command:i.command,label:i.name||`Start Preview`,actionId:i.id};if(n){let t=Cd(n);if(t){let n=await wd(e,r);return{command:`${n===`npm`?`npm run`:n===`yarn`?`yarn`:n===`pnpm`?`pnpm`:n===`bun`?`bun run --shell=bun`:`npm run`} ${t}`,label:`Start (${t})`}}}if(await bd(e,r)){let e=await xd(r),t=typeof e==`number`&&Number.isFinite(e)&&e>0?e:8e3;return{command:`python3 -m http.server ${t}`,label:`Static preview`,previewUrlHint:`http://127.0.0.1:${t}/`}}return null}async function bd(e,t){let n=await Td(`${e}/index.html`,e,t);return typeof n==`string`&&n.trim().length>0}async function xd(e){if(e){let t=await Mt(e).json(`/api/system/free-port`,{cache:`no-store`});if(!Number.isInteger(t.port)||t.port<1||t.port>65535)throw Error(`Invalid Host preview port`);return t.port}try{let e=await g(`/api/system/free-port`,{cache:`no-store`});if(!e.ok)return null;let t=await e.json().catch(()=>null),n=typeof t?.port==`number`?t.port:null;return n&&Number.isFinite(n)?n:null}catch{return null}}function Sd(e){for(let t of e){let e=`${t.name} ${t.command}`.toLowerCase();if(vd.some(t=>e.includes(t)))return t}return null}function Cd(e){for(let{pattern:t}of _d)for(let n of Object.keys(e))if(t.test(n))return n;return null}async function wd(e,t){let n=await Td(`${e}/package.json`,e,t);if(n)try{let e=JSON.parse(n),t=typeof e.packageManager==`string`?e.packageManager.toLowerCase():``;if(t.startsWith(`bun@`))return`bun`;if(t.startsWith(`pnpm@`))return`pnpm`;if(t.startsWith(`yarn@`))return`yarn`;if(t.startsWith(`npm@`))return`npm`}catch{}for(let[n,r]of[[`bun.lock`,`bun`],[`bun.lockb`,`bun`],[`pnpm-lock.yaml`,`pnpm`],[`yarn.lock`,`yarn`],[`package-lock.json`,`npm`]]){let i=await Td(`${e}/${n}`,e,t);if(typeof i==`string`&&i.trim().length>0)return r}return`npm`}async function Td(e,t,n){if(n){let r=Mt(n),i=await r.fetch(`/api/fs/read`,{query:{path:e,directory:t,optional:`true`},cache:`no-store`});if(i.status===404)return null;if(!i.ok)throw Error(`Failed to read Host preview file (${i.status})`);let a=await i.text();return r.assertCurrent(),i.headers.get(`x-yuri-file-exists`)===`false`?null:a}if(t?.trim())try{let n=new URLSearchParams({path:e,directory:t,optional:`true`}),r=await g(`/api/fs/read?${n.toString()}`,{cache:`no-store`});if(r.ok)return r.text()}catch{}let r=H()?.files;if(r?.readFile)try{let t=await r.readFile(e,{optional:!0});return typeof t?.content==`string`?t.content:null}catch{return null}try{let t=await g(`/api/fs/read?path=${encodeURIComponent(e)}&optional=true`,{cache:`no-store`});return t.ok?t.text():null}catch{return null}}async function Ed(e,t){try{let n=await Td(`${e}/package.json`,e,t);if(n==null)return null;let r=JSON.parse(n).scripts;return r&&typeof r==`object`&&!Array.isArray(r)?r:null}catch(e){if(t)throw e;return null}}var Dd=e=>new Promise(t=>{window.setTimeout(t,e)}),Od=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),kd=/https?:\/\/[^\s<>'"`]+/gi,Ad=`__yuri_auto_discover_preview__`,jd=15e3,Md=e=>{let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);r>=0&&r<=8||r===11||r===12||r>=14&&r<=31||r===127||(t+=e[n])}return t},Nd=e=>{let t=(e||``).trim();if(!t)return null;let n=/^https?:\/\//i.test(t)?t:`http://${t}`;try{let e=new URL(n);return e.protocol!==`http:`&&e.protocol!==`https:`?null:e.toString()}catch{return null}},Pd=e=>{let t=e.replace(Od,``).match(kd);if(!t||t.length===0)return null;let n=t.map(e=>e.replace(/[),.;]+$/,``)).filter(Boolean);if(n.length===0)return null;let r=[];for(let e of n)try{let t=new URL(e);t.port&&t.port.length>0&&r.push({raw:e,parsed:t})}catch{}if(r.length>0){let e=e=>{let{parsed:t}=e,n=t.hostname.toLowerCase(),r=n===`localhost`||n===`127.0.0.1`||n===`0.0.0.0`||n===`::1`,i=t.pathname||`/`,a=i.split(`/`).filter(Boolean).length,o=i===`/`||i===``,s=!!(t.search||t.hash),c=0;return r&&(c+=50),o&&(c+=30),c-=Math.min(a*5,20),s&&(c-=10),c};return r.sort((t,n)=>e(n)-e(t)),r[0]?.parsed.origin??r[0]?.raw??null}return n[0]??null},Fd=e=>{let t=(0,Q.c)(19),n=!!e.projectRef?.hostId,{registry:r}=Dr(n&&!e.scope),i=e.projectRef?.hostId,a;t[0]!==i||t[1]!==r?(a={subscribe:e=>r&&i?r.subscribeHost(i,e):Ld,snapshot:()=>r&&i?r.getHost(i):void 0},t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=a;Z.useSyncExternalStore(o.subscribe,o.snapshot,o.snapshot);let s=e.directory||e.projectRef?.path||``,c;t[3]!==s||t[4]!==e.projectRef||t[5]!==e.scope||t[6]!==r||t[7]!==n?(c=e.scope?r?.hubId===e.scope.location.hubId?r.resolve(e.scope.location):e.scope:n&&r&&r.hubId===e.projectRef?.hubId?r.resolve({hubId:r.hubId,hostId:e.projectRef.hostId,directory:s}):void 0,t[3]=s,t[4]=e.projectRef,t[5]=e.scope,t[6]=r,t[7]=n,t[8]=c):c=t[8];let l=c,u;t[9]!==s||t[10]!==l||t[11]!==e.projectRef?.hostId||t[12]!==e.projectRef?.hubId||t[13]!==n?(u=l?`${l.key}:${l.connectionGeneration}`:n?JSON.stringify([e.projectRef?.hubId,e.projectRef?.hostId,s]):s,t[9]=s,t[10]=l,t[11]=e.projectRef?.hostId,t[12]=e.projectRef?.hubId,t[13]=n,t[14]=u):u=t[14];let d=u,f;return t[15]!==l||t[16]!==d||t[17]!==e?(f=(0,$.jsx)(Id,{...e,scope:l},d),t[15]=l,t[16]=d,t[17]=e,t[18]=f):f=t[18],f},Id=({projectRef:e,directory:t,className:n,compact:r=!1,allowMobile:i=!1,scope:a})=>{let{t:o}=Nr(),{terminal:s,runtime:c}=Tt(),l=Z.useRef(null),u=Z.useRef(!0),d=()=>{if(!u.current)throw new DOMException(`Project action scope superseded`,`AbortError`);if(e?.hostId&&(!a||a.location.hostId!==e.hostId||a.location.hubId!==e.hubId)||a&&a.location.directory!==(t||e?.path||``))throw Error(o(`remoteProjects.host-unavailable`));a&&Mt(a).assertCurrent()},f=G(()=>{if(d(),!a)throw Error(o(`remoteProjects.host-unavailable`));return l.current??=Gt(a)}),p=Z.useMemo(()=>a||e?.hostId?{createSession:e=>f().createTerminalSession(e),sendInput:(e,t)=>f().sendTerminalInput(e,t),close:e=>f().closeTerminal(e)}:s,[a,e?.hostId,s,f]),{isMobile:m}=fi(),h=Z.useMemo(()=>y(),[]),g=_u(e=>e.instances),_=_u(e=>e.load),v=K(e=>e.setBottomTerminalOpen),b=K(e=>e.setActiveMainTab),x=K(e=>e.setSettingsPage),S=K(e=>e.setSettingsDialogOpen),C=K(e=>e.setSettingsProjectsSelectedId),w=K(e=>e.openContextPreview),T=dc(e=>e.sessions),E=dc(e=>e.ensureDirectory),D=dc(e=>e.setTabLabel),O=dc(e=>e.setTabIconKey),k=dc(e=>e.setActiveTab),A=dc(e=>e.setConnecting),j=dc(e=>e.setTabSessionId),M=dc(e=>e.setTabPreviewUrl),N=dc(e=>e.projectActionRuns),P=dc(e=>e.setProjectActionRun),F=dc(e=>e.updateProjectActionRunStatus),I=dc(e=>e.removeProjectActionRun),[L,z]=Z.useState([]),[ee,B]=Z.useState(null),[ne,re]=Z.useState(!1),ie=Z.useRef({}),ae=Z.useRef({}),oe=Z.useRef({}),V=Z.useRef({}),H=Z.useRef(0),se=Z.useRef(new Set),U=e?.id??null,ce=e?.path??``,le=Z.useMemo(()=>U?{id:U,path:ce,hostId:e?.hostId,hubId:e?.hubId}:null,[U,ce,e?.hostId,e?.hubId]);Z.useEffect(()=>{u.current=!0;let e=oe.current,t=V.current;return()=>{u.current=!1,H.current+=1,Object.values(e).forEach(e=>e()),Object.values(t).forEach(e=>window.clearTimeout(e)),l.current?.dispose(),l.current=null}},[a]),Z.useEffect(()=>{!h||a||e?.hostId||_().catch(()=>void 0)},[h,_,a,e?.hostId]);let ue=G(async e=>{await Ut(e)}),de=G(async()=>{if(!le)return;let e=H.current+1;H.current=e,re(!0);try{d();let t=await Xt(le,a);if(H.current!==e)return;let n=t.actions;z(n),B(e=>e===Ad||e&&n.some(t=>t.id===e)?e:null)}catch{if(H.current!==e)return}finally{H.current===e&&re(!1)}}),fe=t||le?.path||``,pe=Z.useMemo(()=>a?R(te({...a.location,directory:fe})):le?.hostId?le.hubId?R(te({hubId:le.hubId,hostId:le.hostId,directory:fe})):``:Cu(fe),[fe,le,a]),me=Z.useMemo(()=>ee?L.find(e=>e.id===ee)??null:null,[L,ee]),he=Z.useMemo(()=>({id:Ad,name:o(`projectActions.actions.autoDiscover`),command:``,icon:`search`,autoOpenUrl:!0}),[o]),ge=!m,_e=Z.useMemo(()=>ge?[he,...L]:L,[L,he,ge]);Z.useEffect(()=>{de()},[de,le,a]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;U&&(t?.projectId&&t.projectId!==U||de())};return window.addEventListener(wu,e),()=>{window.removeEventListener(wu,e)}},[de,U]),Z.useEffect(()=>{ee&&(ee===Ad&&ge||L.some(e=>e.id===ee)||B(null))},[L,ge,ee]),Z.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==pe)continue;let n=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);(!n||n.terminalSessionId!==t.sessionId)&&I(e)}},[pe,N,I,T]),Z.useEffect(()=>{for(let[e,t]of Object.entries(N)){if(t.directory!==pe)continue;let n=ae.current[e]??{lastSeenChunkId:null,openedUrl:!1,tail:``,openInPreview:!1};ae.current[e]=n;let r=_e.find(e=>e.id===t.actionId);if(!r)continue;let i=T.get(t.directory)?.tabs.find(e=>e.id===t.tabId);if(!i||!Array.isArray(i.bufferChunks)||i.bufferChunks.length===0)continue;let s=i.bufferChunks.filter(e=>n.lastSeenChunkId===null||e.id>n.lastSeenChunkId);if(s.length===0)continue;let c=s.map(e=>e.data).join(``),l=`${n.tail}${c}`,u=!n.openedUrl&&r.autoOpenUrl===!0?Pd(l):null;if(n.lastSeenChunkId=s[s.length-1]?.id??n.lastSeenChunkId,n.tail=l.slice(-512),u)if(n.openedUrl=!0,n.openInPreview){let t=N[e];t&&(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!1}),t.status===`waiting-for-preview`&&F(e,`running`),window.clearTimeout(V.current[e]),delete V.current[e],w(t.directory,u))}else a||le?.hostId?(M(t.directory,t.tabId,u,{locked:!1,autoOpened:!0}),w(t.directory,u)):(ue(u),Y.success(o(`projectActions.toast.openedUrlFromOutput`)));ae.current[e]=n}for(let e of Object.keys(ae.current))N[e]||(delete ae.current[e],window.clearTimeout(V.current[e]),delete V.current[e])},[pe,a,le?.hostId,_e,w,ue,N,M,o,T,F]);let ve=G(async(e,t={})=>{if(!pe)throw Error(o(`projectActions.error.noActiveDirectory`));let n=bu(pe,e.id);E(pe);let r=dc.getState(),i=r.getDirectoryState(pe),a=ie.current[n]||null,s=a?!!i?.tabs.some(e=>e.id===a):!1;(!a||!s)&&(a=r.createTab(pe),ie.current[n]=a),D(pe,a,`Action: ${e.name}`),O(pe,a,e.icon||`play`),t.revealTerminal!==!1&&(k(pe,a),v(!0),b(`terminal`));let c=dc.getState().getDirectoryState(pe)?.tabs.find(e=>e.id===a);return{key:n,tabId:a,sessionId:c?.terminalSessionId??null}}),ye=G(async e=>{if(c.isVSCode||!i&&m)return;if(!pe){Y.error(o(`projectActions.error.noActiveDirectoryForAction`));return}let t=bu(pe,e.id),n=N[t];if(!(n&&n.status===`running`)&&!se.current.has(t)){se.current.add(t);try{d();let t=e.id===Ad?await(async()=>{let[e,t]=await Promise.all([Xt({...le,id:le?.id??``,path:fe},a),Ed(fe,a)]),n=await yd(fe,e.actions,t,a);if(!n)throw Error(o(`contextPanel.preview.noDevServer`));return{id:Ad,name:o(`projectActions.actions.autoDiscover`),command:n.command,icon:`search`,autoOpenUrl:!0,openUrl:n.previewUrlHint||``}})():e,n=t.autoOpenUrl===!0&&(t.openUrl||``).trim().length>0;d();let{key:r,tabId:i,sessionId:s}=await ve(t,{revealTerminal:!n&&e.id!==Ad}),c=s,l=!1;if(!c){A(pe,i,!0);try{let e=await p.createSession({cwd:fe});d(),c=e.sessionId,l=!0,j(pe,i,c)}finally{A(pe,i,!1)}}if(!c)throw Error(o(`projectActions.error.failedToCreateTerminalSession`));l&&await Dd(350),d(),t.id===Ad&&(oe.current[r]?.(),A(pe,i,!0),oe.current[r]=(a?f().connectTerminalStream:Wt)(c,e=>{if(u.current){try{d()}catch{return}e.type===`data`&&typeof e.data==`string`&&e.data.length>0&&dc.getState().appendToBuffer(pe,i,e.data),e.type===`exit`&&(dc.getState().setTabLifecycle(pe,i,`exited`),dc.getState().setConnecting(pe,i,!1),dc.getState().removeProjectActionRun(r),delete ae.current[r],oe.current[r]?.(),delete oe.current[r],window.clearTimeout(V.current[r]),delete V.current[r])}},()=>{u.current&&dc.getState().setConnecting(pe,i,!1)},{maxRetries:60,initialRetryDelay:250,maxRetryDelay:2e3,connectionTimeout:5e3}));let m=t.autoOpenUrl===!0&&!a&&h&&(t.desktopOpenSshForward||``).trim().length>0,_=t.autoOpenUrl?Nd(t.openUrl):null,v=t.autoOpenUrl&&h&&!a?xu(t.desktopOpenSshForward,g):null;P({key:r,directory:pe,actionId:t.id,tabId:i,sessionId:c,status:t.id===Ad&&!_?`waiting-for-preview`:`running`}),window.clearTimeout(V.current[r]),delete V.current[r],t.id===Ad&&!_&&(V.current[r]=window.setTimeout(()=>{dc.getState().updateProjectActionRunStatus(r,`running`),delete V.current[r]},jd)),v?(M(pe,i,null,{locked:!0}),ue(v),Y.success(o(`projectActions.toast.openedForwardedUrl`))):_?(M(pe,i,_,{locked:!0,autoOpened:!0}),w(pe,_),Y.success(o(`projectActions.toast.openedActionUrl`))):n?(M(pe,i,null,{locked:!0}),Y.error(o(`projectActions.error.invalidCustomUrlFormat`))):m?(M(pe,i,null,{locked:!0}),Y.error(o(`projectActions.error.selectedDesktopSshForwardUnavailable`))):M(pe,i,null,{locked:!1,autoOpened:!1}),ae.current[r]={lastSeenChunkId:null,openedUrl:!!v||!!_||n,tail:``,openInPreview:t.id===Ad};let y=Md(t.command.trim().replace(/\r\n|\r/g,`
3
+ `));d(),await p.sendInput(c,`${y}\r`)}catch(e){I(t),delete ae.current[t],oe.current[t]?.(),delete oe.current[t],window.clearTimeout(V.current[t]),delete V.current[t],Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`))}finally{se.current.delete(t)}}}),be=G(async e=>{let t=bu(pe,e.id),n=N[t];if(n){F(t,`stopping`);try{await p.sendInput(n.sessionId,``)}catch(e){if(a||le?.hostId){F(t,`running`),Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}}if(await new Promise(e=>{window.setTimeout(e,1e3)}),dc.getState().getDirectoryState(n.directory)?.tabs.find(e=>e.id===n.tabId)?.terminalSessionId===n.sessionId)if(a||le?.hostId){try{d(),await p.close(n.sessionId)}catch(e){F(t,`running`),Y.error(e instanceof Error?e.message:o(`projectActions.error.failedToRunAction`));return}j(n.directory,n.tabId,null)}else{if(typeof p.forceKill==`function`)try{await p.forceKill({sessionId:n.sessionId})}catch{}else try{await p.close(n.sessionId)}catch{}j(n.directory,n.tabId,null)}I(t),delete ae.current[t],oe.current[t]?.(),delete oe.current[t],window.clearTimeout(V.current[t]),delete V.current[t]}}),xe=G(()=>{let e=me??_e[0];if(!e)return;let t=bu(pe,e.id),n=N[t];if(n?.status!==`stopping`){if(n){be(e);return}ye(e)}}),Se=G((e,t=!1)=>{if(B(e.id),!t){ye(e);return}let n=bu(pe,e.id),r=N[n];if(r?.status!==`stopping`){if(r){be(e);return}ye(e)}}),Ce=G(()=>{if(le?.id){if(a||le.hostId){Y.info(o(`remoteProjects.configurationReadOnly`)),x(`remoteInstances`),S(!0);return}C(le.id),x(`projects`),S(!0)}});if(c.isVSCode||!i&&m||!le||!pe)return null;let we=me??_e[0]??null;if(!we)return null;let Te=we.icon||`play`,Ee=we.id===Ad?`search`:Su[Te]||`play`,De=N[bu(pe,we.id)],Oe=De?.status===`stopping`,ke=De?.status===`waiting-for-preview`,Ae=De?T.get(De.directory)?.tabs.find(e=>e.id===De.tabId)?.previewUrl??null:null,je=!!(De&&Ae),Me=()=>{!De||!Ae||w(De.directory,Ae)};return r?(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:ne||Oe,className:J(`app-region-no-drag inline-flex h-9 w-9 items-center justify-center rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] p-2`,`typography-ui-label font-medium text-muted-foreground hover:bg-interactive-hover hover:text-foreground transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`disabled:cursor-not-allowed`,n),onClick:xe,"aria-label":o(De?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:we.name}),children:Oe||ke?(0,$.jsx)(X,{name:`loader-4`,className:`h-5 w-5 animate-spin text-[var(--status-warning)]`}):De?(0,$.jsx)(X,{name:`stop`,className:`h-5 w-5 text-[var(--status-warning)]`}):(0,$.jsx)(X,{name:Ee,className:`h-5 w-5`})}),je?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-7 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.openPreview`),onClick:Me,children:(0,$.jsx)(X,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`app-region-no-drag -ml-1 inline-flex h-9 w-5 items-center justify-center rounded-[10px] text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3.5 w-3.5`})})}),(0,$.jsxs)(bi,{align:`end`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Ce,children:[(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),_e.map(e=>{let t=e.icon||`play`,n=e.id===Ad?`search`:Su[t]||`play`,r=bu(pe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{Se(e,!0)},children:[(0,$.jsx)(X,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(X,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]}):(0,$.jsxs)(`div`,{className:J(`app-region-no-drag inline-flex shrink-0 items-center self-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px]`,`bg-[var(--surface-elevated)] overflow-hidden`,`border border-border/60`,r?`h-9`:`h-7`,n),children:[(0,$.jsx)(`button`,{type:`button`,onClick:xe,disabled:ne||Oe,className:J(`inline-flex h-full items-center justify-center typography-ui-label font-medium text-foreground hover:bg-interactive-hover`,r?`w-9 px-0`:`px-2.5`,`transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed`),"aria-label":o(De?`projectActions.actions.stopNamedAria`:`projectActions.actions.runNamedAria`,{name:we.name}),children:(0,$.jsx)(`span`,{className:`inline-flex h-4 w-4 shrink-0 items-center justify-center`,children:Oe||ke?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-[var(--status-warning)]`}):De?(0,$.jsx)(X,{name:`stop`,className:`h-4 w-4 text-[var(--status-warning)]`}):(0,$.jsx)(X,{name:Ee,className:`h-4 w-4`})})}),je?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Me,className:J(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-foreground`,`hover:bg-interactive-hover transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.openPreview`),children:(0,$.jsx)(X,{name:`global`,className:`h-4 w-4`})})}),(0,$.jsx)(ei,{sideOffset:6,children:o(`projectActions.actions.openPreview`)})]}):null,(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(r?`inline-flex h-full w-8 items-center justify-center`:`inline-flex h-full w-7 items-center justify-center`,`border-l border-[var(--interactive-border)] text-muted-foreground`,`hover:bg-interactive-hover hover:text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),"aria-label":o(`projectActions.actions.chooseActionAria`),children:(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4`})})}),(0,$.jsxs)(bi,{align:`start`,className:`w-52 max-h-[70vh] overflow-y-auto`,children:[(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:Ce,children:[(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`projectActions.actions.addNewAction`)})]}),(0,$.jsx)(Si,{}),_e.map(e=>{let t=e.icon||`play`,n=e.id===Ad?`search`:Su[t]||`play`,r=bu(pe,e.id),i=N[r],a=!!i,o=i?.status===`stopping`;return(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>{Se(e,!0)},children:[(0,$.jsx)(X,{name:n,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:e.name}),o||i?.status===`waiting-for-preview`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-auto h-4 w-4 animate-spin text-[var(--status-warning)]`}):a?(0,$.jsx)(X,{name:`stop`,className:`ml-auto h-4 w-4 text-[var(--status-warning)]`}):null]},e.id)})]})]})]})};function Ld(){}function Rd(e){return e.isOpen&&e.activeTab===e.targetTab?{open:!1,tab:e.activeTab}:{open:!0,tab:e.targetTab}}var zd=`app-region-no-drag inline-flex h-8 w-8 items-center justify-center gap-2 rounded-md typography-ui-label font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:bg-interactive-hover transition-colors`,Bd=`app-region-no-drag inline-flex h-9 w-9 items-center justify-center gap-2 p-2 rounded-md typography-ui-label font-medium text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50 hover:text-foreground hover:bg-interactive-hover transition-colors`,Vd=Z.memo(function(e){let t=(0,Q.c)(17),{visible:n,title:r,ariaLabel:i,onClick:a,className:o,Icon:s,iconClassName:c,pressed:l}=e,u=n===void 0||n,d=l!==void 0&&l;if(!u)return null;let f=o??zd,p=d&&`bg-interactive-selection text-interactive-selection-foreground`,m;t[0]!==f||t[1]!==p?(m=J(f,p),t[0]=f,t[1]=p,t[2]=m):m=t[2];let h=c??`h-[18px] w-[18px]`,g;t[3]!==s||t[4]!==h?(g=(0,$.jsx)(X,{name:s,className:h}),t[3]=s,t[4]=h,t[5]=g):g=t[5];let _;t[6]!==i||t[7]!==a||t[8]!==d||t[9]!==m||t[10]!==g?(_=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:a,"aria-label":i,"aria-pressed":d,className:m,children:g})}),t[6]=i,t[7]=a,t[8]=d,t[9]=m,t[10]=g,t[11]=_):_=t[11];let v;t[12]===r?v=t[13]:(v=(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:r})}),t[12]=r,t[13]=v);let y;return t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(ni,{children:[_,v]}),t[14]=_,t[15]=v,t[16]=y):y=t[16],y}),Hd=Z.memo(function(e){let t=(0,Q.c)(42),{isMobile:n,githubAuthStatus:r,githubAccounts:i,githubAvatarUrl:a,githubLogin:o,isSwitchingGitHubAccount:s,handleGitHubAccountSwitch:c}=e,{t:l}=Nr();if(!r?.connected||n)return null;if(i.length>1){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=J(zd,`h-6 w-6 overflow-hidden rounded-full border border-border/60 bg-muted/80 p-0`),t[0]=e):e=t[0];let n;t[1]!==o||t[2]!==l?(n=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[1]=o,t[2]=l,t[3]=n):n=t[3];let r;t[4]!==a||t[5]!==o||t[6]!==l?(r=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[4]=a,t[5]=o,t[6]=l,t[7]=r):r=t[7];let u;t[8]!==s||t[9]!==n||t[10]!==r?(u=(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:e,title:n,disabled:s,children:r})}),t[8]=s,t[9]=n,t[10]=r,t[11]=u):u=t[11];let d;t[12]===l?d=t[13]:(d=l(`header.github.accountsTitle`),t[12]=l,t[13]=d);let f;t[14]===d?f=t[15]:(f=(0,$.jsx)(yi,{className:`typography-ui-header font-semibold text-foreground`,children:d}),t[14]=d,t[15]=f);let p;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(Si,{}),t[16]=p):p=t[16];let m;if(t[17]!==i||t[18]!==c||t[19]!==s||t[20]!==l){let e;t[22]!==c||t[23]!==s||t[24]!==l?(e=e=>{let t=e.user,n=!!e.current,r=e.source===`gh-cli`?l(`header.github.accountSource.cli`):l(`header.github.accountSource.oauth`);return(0,$.jsxs)(xi,{className:`gap-2`,disabled:s,onSelect:()=>{n||c(e.id)},children:[t?.avatarUrl?(0,$.jsx)(`img`,{src:t.avatarUrl,alt:t.login?l(`header.github.avatarWithLogin`,{login:t.login}):l(`header.github.avatar`),className:`h-6 w-6 rounded-full border border-border/60 bg-muted object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 items-center justify-center rounded-full border border-border/60 bg-muted`,children:(0,$.jsx)(X,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:t?.name?.trim()||t?.login||`GitHub`}),t?.login?(0,$.jsxs)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:t.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]}):null]}),n?(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 text-primary`}):null]},e.id)},t[22]=c,t[23]=s,t[24]=l,t[25]=e):e=t[25],m=i.map(e),t[17]=i,t[18]=c,t[19]=s,t[20]=l,t[21]=m}else m=t[21];let h;t[26]!==f||t[27]!==m?(h=(0,$.jsxs)(bi,{align:`end`,className:`w-64`,children:[f,p,m]}),t[26]=f,t[27]=m,t[28]=h):h=t[28];let g;return t[29]!==u||t[30]!==h?(g=(0,$.jsxs)(Ci,{children:[u,h]}),t[29]=u,t[30]=h,t[31]=g):g=t[31],g}let u;t[32]!==o||t[33]!==l?(u=o?l(`header.github.connectedWithLogin`,{login:o}):l(`header.github.connected`),t[32]=o,t[33]=l,t[34]=u):u=t[34];let d;t[35]!==a||t[36]!==o||t[37]!==l?(d=a?(0,$.jsx)(`img`,{src:a,alt:o?l(`header.github.avatarWithLogin`,{login:o}):l(`header.github.avatar`),className:`h-full w-full object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(X,{name:`github-fill`,className:`h-3.5 w-3.5 text-foreground`}),t[35]=a,t[36]=o,t[37]=l,t[38]=d):d=t[38];let f;return t[39]!==u||t[40]!==d?(f=(0,$.jsx)(`div`,{className:`app-region-no-drag flex h-6 w-6 items-center justify-center overflow-hidden rounded-full border border-border/60 bg-muted/80`,title:u,children:d}),t[39]=u,t[40]=d,t[41]=f):f=t[41],f}),Ud=Z.memo(function(e){let t=(0,Q.c)(52),{isDesktopApp:n,currentInstanceSupportsUpdate:r,isDesktopServicesOpen:i,setIsDesktopServicesOpen:a,refreshCurrentInstanceLabel:o,desktopServicesTab:s,setDesktopServicesTab:c,fetchAllQuotas:l,servicesTabItems:u,quotaLastUpdated:d,quotaDisplayMode:f,quotaDisplayTabItems:p,handleDisplayModeChange:m,handleUsageRefresh:h,isQuotaLoading:g,isUsageRefreshSpinning:_,hasRateLimits:v,rateLimitGroups:y,expandedFamilies:b,toggleFamilyExpanded:x,showPredValues:S,timeFormatPreference:C,anchorRef:w}=e,{t:T}=Nr(),E=Z.useRef(!1),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=e=>{E.current=e},t[0]=D):D=t[0];let O=G(D),k;t[1]!==s||t[2]!==l||t[3]!==d||t[4]!==o||t[5]!==a?(k=(e,t)=>{if(!e&&(t.reason===`trigger-hover`||t.reason===`focus-out`||E.current)){t.cancel();return}a(e),e&&(o(),s===`usage`&&d===null&&l())},t[1]=s,t[2]=l,t[3]=d,t[4]=o,t[5]=a,t[6]=k):k=t[6];let A;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(vi,{asChild:!0,openOnHover:!1,children:(0,$.jsx)(`button`,{type:`button`,"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none absolute h-px w-px overflow-hidden opacity-0`})}),t[7]=A):A=t[7];let j;t[8]!==l||t[9]!==d||t[10]!==c?(j=e=>{if(E.current)return;let t=e;c(t),t===`usage`&&d===null&&l()},t[8]=l,t[9]=d,t[10]=c,t[11]=j):j=t[11];let M;t[12]!==s||t[13]!==u||t[14]!==j?(M=(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)]/60 px-2 pt-1.5 pb-1.5 backdrop-blur-xl backdrop-saturate-150`,children:(0,$.jsx)(`div`,{className:`h-9`,children:(0,$.jsx)(Vs,{items:u,activeId:s,onSelect:j,layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})})}),t[12]=s,t[13]=u,t[14]=j,t[15]=M):M=t[15];let N;t[16]!==r||t[17]!==s||t[18]!==O||t[19]!==n||t[20]!==i||t[21]!==a?(N=n&&s===`instance`?(0,$.jsxs)(`div`,{children:[r&&i?(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)] px-4 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-foreground`,children:`Yuri`}),(0,$.jsx)(Dl,{})]})}):null,(0,$.jsx)(Ua,{embedded:!0,open:i&&s===`instance`,onOpenChange:$d,onHostSwitched:()=>a(!1),onBusyChange:O})]}):null,t[16]=r,t[17]=s,t[18]=O,t[19]=n,t[20]=i,t[21]=a,t[22]=N):N=t[22];let P;t[23]!==s||t[24]!==i?(P=s===`mcp`?(0,$.jsx)(Ac,{active:i&&s===`mcp`}):null,t[23]=s,t[24]=i,t[25]=P):P=t[25];let F;t[26]!==s||t[27]!==b||t[28]!==m||t[29]!==h||t[30]!==v||t[31]!==g||t[32]!==_||t[33]!==f||t[34]!==p||t[35]!==d||t[36]!==y||t[37]!==S||t[38]!==T||t[39]!==C||t[40]!==x?(F=s===`usage`?(0,$.jsxs)(`div`,{className:`overflow-x-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-[var(--interactive-border)] px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:T(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gd(d,C)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-7 w-[10.5rem]`,children:(0,$.jsx)(Vs,{items:p,activeId:f,onSelect:e=>void m(e),layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:h,disabled:g||_,"aria-label":T(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(X,{name:`refresh`,className:J(`h-4 w-4`,_&&`animate-spin`)})})]})]}),v?null:(0,$.jsx)(`div`,{className:`px-4 py-5 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:T(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`space-y-2 px-3 py-2.5`,children:y.map(e=>{let t=b[e.providerId]??[];return(0,$.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??T(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[e.entries.map((t,n)=>{let[r,i]=t,a=Ll(e.entries,n),o=f===`remaining`?i.remainingPercent:i.usedPercent,s=i.disablePace?null:ec(i.usedPercent,i.resetAt,i.windowSeconds,r),c=s?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(s.elapsedRatio):nc(s.elapsedRatio),l=Qs(i.valueLabel,o),u=$s(i.resetAt,i.resetAfterFormatted??i.resetAtFormatted,C);return(0,$.jsxs)(Z.Fragment,{children:[a?(0,$.jsx)(`div`,{className:J(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:a}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(i.label??r)}),u?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label tabular-nums text-foreground`,children:l===`-`?``:l})]}),(0,$.jsx)(mu,{percent:o,tonePercent:i.usedPercent,className:`h-1.5`,expectedMarkerPercent:c}),s&&S?(0,$.jsx)(au,{paceInfo:s,compact:!0}):null]})]},`${e.providerId}-${r}`)}),e.modelFamilies&&e.modelFamilies.length>0?(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(n=>{let r=n.familyId??`other`,i=t.includes(r);return(0,$.jsxs)(ji,{open:i,onOpenChange:()=>x(e.providerId,r),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:n.familyLabel}),i?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:n.models.map(t=>{let[n,r]=t,i=f===`remaining`?r.remainingPercent:r.usedPercent,a=ec(r.usedPercent,r.resetAt,r.windowSeconds),o=a?.dailyAllocationPercent==null?null:f===`remaining`?100-nc(a.elapsedRatio):nc(a.elapsedRatio),s=Qs(r.valueLabel,i);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(n)}),(0,$.jsx)(`span`,{className:`typography-ui-label tabular-nums text-foreground`,children:s===`-`?``:s})]}),(0,$.jsx)(mu,{percent:i,tonePercent:r.usedPercent,className:`h-1.5`,expectedMarkerPercent:o}),a&&S?(0,$.jsx)(au,{paceInfo:a,compact:!0}):null]},`${e.providerId}-${n}`)})})})]},r)})}):null]})]},e.providerId)})})]}):null,t[26]=s,t[27]=b,t[28]=m,t[29]=h,t[30]=v,t[31]=g,t[32]=_,t[33]=f,t[34]=p,t[35]=d,t[36]=y,t[37]=S,t[38]=T,t[39]=C,t[40]=x,t[41]=F):F=t[41];let I;t[42]!==w||t[43]!==M||t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,$.jsxs)(bi,{anchor:w,align:`start`,sideOffset:6,collisionPadding:12,className:`w-[min(27rem,calc(100vw-2rem))] max-h-[75vh] overflow-y-auto bg-[var(--surface-elevated)] p-0 [&_[role=tab]]:capitalize`,children:[M,N,P,F]}),t[42]=w,t[43]=M,t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==i||t[49]!==k||t[50]!==I?(L=(0,$.jsxs)(Ci,{open:i,onOpenChange:k,children:[A,I]}),t[48]=i,t[49]=k,t[50]=I,t[51]=L):L=t[51],L}),Wd=(e,t)=>e===t?!0:!e||!t?!1:e.totalTokens===t.totalTokens&&e.pending===t.pending&&e.percentage===t.percentage&&e.contextLimit===t.contextLimit&&(e.outputLimit??0)===(t.outputLimit??0)&&(e.normalizedOutput??0)===(t.normalizedOutput??0)&&e.thresholdLimit===t.thresholdLimit&&(e.lastMessageId??``)===(t.lastMessageId??``),Gd=(e,t)=>{if(!e)return`-`;try{return Us(e,t,{fallback:`-`})}catch{return`-`}},Kd=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},qd=e=>!e?.isOpen||!Array.isArray(e.tabs)||e.tabs.length===0?null:(e.tabs.find(t=>t.id===e.activeTabId)??e.tabs[e.tabs.length-1])?.mode??null,Jd=e=>{let t=(0,Q.c)(3),n=$t(ef),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Yd,{...e,hostId:n}):(0,$.jsx)(Qd,{...e}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Yd=e=>{let t=(0,Q.c)(11),n,r;t[0]===e?(n=t[1],r=t[2]):({hostId:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=bt(),a=Dr(!0),o=Or(a.registry,n),s;t[3]!==n||t[4]!==a.catalog?.hosts?(s=a.catalog?.hosts.find(e=>e.id===n)?.name??n,t[3]=n,t[4]=a.catalog?.hosts,t[5]=s):s=t[5];let c=s,l=i?.registry??a.registry,u;return t[6]!==c||t[7]!==r||t[8]!==o.data||t[9]!==l?(u=(0,$.jsx)(Qd,{...r,remoteSummaries:o.data,remoteHostName:c,remoteRegistry:l}),t[6]=c,t[7]=r,t[8]=o.data,t[9]=l,t[10]=u):u=t[10],u},Xd=Z.memo(e=>{let t=(0,Q.c)(10),{entry:n,sessionId:r,fallback:i}=e,a;t[0]!==n.queryScope||t[1]!==r?(a=[...n.queryScope,`chat`,r,`session`],t[0]=n.queryScope,t[1]=r,t[2]=a):a=t[2];let o;t[3]===r?o=t[4]:(o=e=>e.id===r&&e.title?.trim()||null,t[3]=r,t[4]=o);let s;t[5]!==a||t[6]!==o?(s={queryKey:a,queryFn:ht,enabled:!1,staleTime:1/0,gcTime:1/0,select:o},t[5]=a,t[6]=o,t[7]=s):s=t[7];let c=yt(s,Dt).data??i,l;return t[8]===c?l=t[9]:(l=(0,$.jsx)($.Fragment,{children:c}),t[8]=c,t[9]=l),l}),Zd=Z.memo(e=>{let t=(0,Q.c)(39),{entry:n,sessionId:r,onClick:i,pressed:a}=e,o=n.location,s=Z.useSyncExternalStore($e,Qe,Qe),c;t[0]===o?c=t[1]:(c=Ze(o),t[0]=o,t[1]=c);let l=c,d;t[2]!==o||t[3]!==l||t[4]!==r?(d=l?it(o,r):null,t[2]=o,t[3]=l,t[4]=r,t[5]=d):d=t[5];let f;t[6]!==s||t[7]!==d?(f={revision:s,scope:d},t[6]=s,t[7]=d,t[8]=f):f=t[8];let p=f.scope,m;t[9]!==l||t[10]!==p?(m=e=>l&&p?l.subscribe(p,e):tf,t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m,g;t[12]!==l||t[13]!==p?(g=()=>l&&p?l.getTranscript(p):null,t[12]=l,t[13]=p,t[14]=g):g=t[14];let _=g,v=Z.useSyncExternalStore(h,_,_),y;t[15]!==n||t[16]!==o.directory?(y=gn(o.directory,u(),n),t[15]=n,t[16]=o.directory,t[17]=y):y=t[17];let b;t[18]===y?b=t[19]:(b={...y,enabled:!1,staleTime:1/0,gcTime:1/0},t[18]=y,t[19]=b);let x=yt(b,Dt),S;t[20]!==o||t[21]!==r?(S=e=>e.getSessionModelSelection(r,o),t[20]=o,t[21]=r,t[22]=S):S=t[22];let C=fr(S),w;bb0:{if(!v){w=null;break bb0}for(let e=v.messageOrder.length-1;e>=0;e--){let t=v.messagesByID[v.messageOrder[e]];if(!t)continue;let n=lt([t],e=>v.partsByMessageID[e]);if(n){w=n;break bb0}}w=null}let T=w,E=T&&`messageId`in T&&v?v.messagesByID[T.messageId]:void 0,D;if(t[23]!==T||t[24]!==E?.modelID||t[25]!==E?.providerID||t[26]!==x.data?.providers||t[27]!==C?.modelId||t[28]!==C?.providerId){let e=x.data?.providers.find(e=>e.id===(C?.providerId??E?.providerID))?.models[C?.modelId??E?.modelID??``];D=Ye(T,e?.limit?.context??0,e?.limit?.output??0),t[23]=T,t[24]=E?.modelID,t[25]=E?.providerID,t[26]=x.data?.providers,t[27]=C?.modelId,t[28]=C?.providerId,t[29]=D}else D=t[29];let O=D;if(!O)return null;let k=O.contextLimit>0?Math.min(999,O.totalTokens/O.contextLimit*100):0,A=O.outputLimit??0,j;return t[30]!==i||t[31]!==a||t[32]!==k||t[33]!==A||t[34]!==O.contextLimit||t[35]!==O.pending||t[36]!==O.percentage||t[37]!==O.totalTokens?(j=(0,$.jsx)(rc,{pending:O.pending,totalTokens:O.totalTokens,percentage:k,colorPercentage:O.percentage,contextLimit:O.contextLimit,outputLimit:A,size:`compact`,appearance:`subtle`,onClick:i,pressed:a}),t[30]=i,t[31]=a,t[32]=k,t[33]=A,t[34]=O.contextLimit,t[35]=O.pending,t[36]=O.percentage,t[37]=O.totalTokens,t[38]=j):j=t[38],j}),Qd=({onToggleLeftDrawer:e,onToggleRightDrawer:t,leftDrawerOpen:r,rightDrawerOpen:i,remoteSummaries:a,remoteHostName:o,remoteRegistry:s})=>{let{t:c}=Nr(),l=K(e=>e.setSessionSwitcherOpen),d=K(e=>e.toggleSidebar),f=K(e=>e.isSidebarOpen),m=K(e=>e.toggleBottomTerminal),_=K(e=>e.toggleContextPanel),v=K(e=>e.openContextOverview),b=K(e=>e.openContextBrowser),x=K(e=>e.closeContextPanel),S=K(e=>e.activeMainTab),C=K(e=>e.setActiveMainTab),T=K(e=>e.shortcutOverrides),D=K(e=>e.timeFormatPreference),O=An(e=>e.getCurrentModel),k=Tt(),A=Vn(e=>!!e.newSessionDraft?.open),j=Vn(e=>e.currentSessionId),M=$t(e=>e.activeProjectId?e.projects.find(t=>t.id===e.activeProjectId)??null:null),N=!!M?.hostId,P=Tn(e=>e.remoteSession),R=M?.hostId&&P?.projectId===M.id&&P.location.hostId===M.hostId&&(!M.hubId||P.location.hubId===M.hubId)?P:null,z=N?R?.sessionId??null:j,B=N?!R?.sessionId:A,ne=zn(N?``:z??``),re=cn(N?null:z),ie=$t(e=>e.projects),ae=Z.useMemo(()=>{if(!N)return re;let e=R?.location.directory??M?.path,t=M?.hubId??s?.hubId,n=M?.hostId;if(!(!e||!t||!n||wt(ie,t,n,e,a?.worktrees)?.id!==M?.id))return a?.directories.find(t=>t.directory===e)?.sessions.find(t=>t.id===z&&t.directory===e)},[N,re,R?.location.directory,M,s?.hubId,ie,a,z]),oe=Z.useMemo(()=>{if(!M)return null;let e=M.path.split(/[\\/]/).filter(Boolean);return e[e.length-1]??null},[M]),V=Xs(e=>e.results),H=Xs(e=>e.fetchAllQuotas),ce=Xs(e=>e.isLoading),de=Xs(e=>e.lastUpdated),fe=Xs(e=>e.displayMode),pe=Xs(e=>e.showPredValues),me=Xs(e=>e.dropdownProviderIds),he=Xs(e=>e.loadSettings),ge=Xs(e=>e.setDisplayMode),{isMobile:_e}=fi(),ve=Is().data??null,ye=Ml(e=>e.setStatus),be=Z.useRef(null),[xe,Se]=Z.useState(()=>typeof window>`u`?!1:y()),Ce=Z.useMemo(()=>ee(),[]),we=xe&&L()===`win32`,Te=di(),Ee=Iu(),De=Z.useMemo(()=>typeof navigator>`u`?!1:/Macintosh|Mac OS X/.test(navigator.userAgent||``),[]),{usesFramelessChrome:Oe,side:ke}=oc(),Ae=Z.useMemo(()=>{if(typeof window>`u`)return null;let e=window.__YURI_MACOS_MAJOR__;if(typeof e==`number`&&Number.isFinite(e)&&e>0)return e;if(typeof navigator>`u`)return null;let t=(navigator.userAgent||``).match(/Mac OS X (\d+)[._](\d+)/);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10);return Number.isNaN(n)?null:n===10?r:n},[]);(0,Z.useEffect)(()=>{typeof window>`u`||Se(y())},[]);let je=O(),Me=je&&typeof je.limit==`object`&&je.limit!==null?je.limit:null,Ne=Me&&typeof Me.context==`number`?Me.context:0,Fe=Me&&typeof Me.output==`number`?Me.output:0,Ie=mr(N?``:z??``,Ne,Fe),W=B?null:Ie,[Le,Re]=Z.useState(null),ze=!z||ne;(0,Z.useEffect)(()=>{if(!z){Re(e=>e===null?e:null);return}if(W){Re(e=>Wd(e,W)?e:W);return}ze&&Re(e=>e===null?e:null)},[W,z,ze]);let Be=K(e=>e.isSessionSwitcherOpen),Ve=ve?.connected?ve.user?.avatarUrl??null:null,He=ve?.connected?ve.user?.login??null:null,Ue=ve?.accounts??[],[We,Ge]=Z.useState(!1),[Ke,qe]=Z.useState(!1),[Je,Ye]=Z.useState(!1),[Xe,Ze]=Z.useState(!1),[Qe,$e]=Z.useState(`Local`),[et,tt]=Z.useState(!1),[nt,rt]=Z.useState(xe?`instance`:`usage`),[it,at]=Z.useState(`usage`);(0,Z.useEffect)(()=>{!xe&&nt===`instance`&&rt(`usage`)},[nt,xe]);let ot=Z.useMemo(()=>E(),[]),st=!ot&&S===`chat`&&!!Le,ct=Le&&Le.contextLimit>0?Math.min(999,Le.totalTokens/Le.contextLimit*100):0,lt=G(async()=>{if(!(typeof window>`u`||!xe))try{if(w()){$e(`Local`),tt(!1);return}let e=u(),t=await le();if(u()!==e)return;let n=h(),r=p(),i=r.startsWith(`host:`)?r.slice(5):null,a=(i?t.hosts.find(e=>e.id===i):void 0)??t.hosts.find(e=>n?U(n,se(e)):!1);if(h()!==n)return;if(tt(!!n),a?.label?.trim()){$e(ue(a.label.trim()));return}$e(`Instance`)}catch{$e(`Local`),tt(!1)}});(0,Z.useEffect)(()=>{lt()},[xe]),Js();let ut=Xs(e=>e.selectedModels),dt=Xs(e=>e.expandedFamilies),ft=Xs(e=>e.toggleFamilyExpanded),pt=Z.useMemo(()=>{let e=[];for(let t of Zs(V)){if(!me.includes(t.id))continue;let n=V.find(e=>e?.providerId===t.id),r=n?.usage?.windows??{},i=n?.usage?.models,a=Il(Object.entries(r),n?.usage?.accounts),o={providerId:t.id,providerName:t.name,entries:a,error:n&&!n.ok&&n.configured?n.error:void 0};if(i&&Object.keys(i).length>0){let e=ut[t.id]??[],n=e.length>0,r=Ys(i,t.id),a=qs(t.id),s=Ks(a);o.modelFamilies=[];for(let t of s){let a=r.get(t.id)??[];if(a.length===0)continue;let s=n?a.filter(t=>e.includes(t)):a;if(s.length===0)continue;let c=[];for(let e of s){let t=i[e];if(t?.windows){let n=Object.entries(t.windows);n.length>0&&c.push([e,n[0][1]])}}c.length>0&&o.modelFamilies.push({familyId:t.id,familyLabel:t.label,models:c})}let l=r.get(null)??[],u=n?l.filter(t=>e.includes(t)):l;if(u.length>0){let e=[];for(let t of u){let n=i[t];if(n?.windows){let r=Object.entries(n.windows);r.length>0&&e.push([t,r[0][1]])}}e.length>0&&o.modelFamilies.push({familyId:null,familyLabel:c(`header.services.modelFamily.other`),models:e})}}(a.length>0||o.modelFamilies&&o.modelFamilies.length>0||o.error)&&e.push(o)}return e},[me,V,ut,c]),mt=pt.length>0;Z.useEffect(()=>{he()},[he]);let ht=Z.useCallback(async e=>{ge(e);try{await Pe({usageDisplayMode:e})}catch(e){console.warn(`Failed to update usage display mode:`,e)}},[ge]),gt=Z.useCallback(()=>{if(Xe)return;Ze(!0);let e=new Promise(e=>setTimeout(e,500));Promise.all([H(),e]).finally(()=>{Ze(!1)})},[H,Xe]),_t=Vn(e=>N||!z?``:e.worktreeMetadata.get(z)?.path??``),vt=Z.useMemo(()=>Kd(_t||``),[_t]),yt=Z.useMemo(()=>Kd((typeof ae?.directory==`string`?ae.directory:``)||``),[ae?.directory]),bt=Vn(e=>e.newSessionDraft?.open?Kd(e.newSessionDraft.bootstrapPendingDirectory??e.newSessionDraft.directoryOverride??``):``),xt=Z.useMemo(()=>N?R?.location.directory??M?.path??``:vt||yt||bt,[N,R?.location.directory,M?.path,bt,yt,vt]),St=Ui(),Ct=R?te(R.location):M?.hostId&&M.hubId?te({hubId:M.hubId,hostId:M.hostId,directory:St??M.path}):``,Et=Z.useMemo(()=>N?Ct:Kd(St||xt||M?.path||``),[N,Ct,M?.path,St,xt]),Dt=K(e=>Ht(e,Et)),Ot=!!Dt?.isOpen,kt=G(()=>_(Et)),At=Z.useMemo(()=>{if(!z)return oe??`Yuri`;let e=ae?.title?.trim();return e&&e.length>0?e:`Untitled Session`},[oe,ae?.title,z]),jt=Z.useMemo(()=>N?xt:Kd(xt||M?.path||``),[N,M?.path,xt]),Mt=Z.useMemo(()=>M?{id:M.id,path:M.path,hostId:M.hostId,hubId:M.hubId}:null,[M]),Nt=Z.useRef(null);Z.useEffect(()=>{!Mt||!jt||(Nt.current={projectRef:Mt,directory:jt})},[jt,Mt]);let Pt=Z.useMemo(()=>Mt&&jt?{projectRef:Mt,directory:jt}:Nt.current,[jt,Mt]),Ft=Z.useCallback(async e=>{if(!(!e||We)){Ge(!0);try{let t=k.github?await k.github.authActivate(e):await(async()=>{let t=await g(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();ye(t)}catch(e){console.error(`Failed to switch GitHub account:`,e)}finally{Ge(!1)}}},[We,k.github,ye]),Lt=Z.useCallback(()=>{if(typeof document>`u`)return;let e=document.activeElement;if(!e)return;let t=e.tagName;(t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable)&&e.blur()},[]),Rt=Z.useCallback(()=>{if(_e){Lt(),l(!Be);return}d()},[Lt,_e,Be,l,d]),zt=Z.useCallback(()=>{N||I(`desktop_open_draft_mini_chat_window`,{directory:Kd(xt||M?.path||``),projectId:M?.id??null,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open draft mini chat window`,e)})},[N,M?.id,M?.path,xt]),Bt=Z.useCallback(()=>{if(!N){if(B){zt();return}z&&I(`desktop_open_session_mini_chat_window`,{sessionId:z,directory:Kd(xt||M?.path||``),apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[header] failed to open session mini chat window`,e)})}},[N,M?.path,z,zt,B,xt]),Vt=Z.useCallback(()=>{let e=Et;if(e){if(qd(Dt)===`context`){x(e);return}v(e)}},[x,Et,Dt,v]),Ut=Z.useMemo(()=>Et?qd(Dt)===`context`:!1,[Et,Dt]),Wt=Z.useCallback(()=>{let e=Et;if(e){if(qd(Dt)===`browser`){x(e);return}b(e)}},[x,Et,Dt,b]),Gt=Z.useMemo(()=>Et?qd(Dt)===`browser`:!1,[Et,Dt]),Kt=zd,qt=Bd,Jt=Z.useMemo(()=>Ke?`services`:r?`sessions`:i?`git`:S,[S,Ke,r,i]),Yt=Z.useCallback(()=>{qe(!1),r&&e&&e(),i&&t&&t(),!e&&Be&&l(!1)},[Be,r,e,t,i,l]),Xt=Z.useCallback(()=>{r||qe(!1),e?.()},[r,e]),Zt=Z.useCallback(()=>{i||qe(!1),t?.()},[t,i]),Qt=Z.useMemo(()=>xe&&De&&!Ee?`5.5rem`:Te?`max(calc(0.75rem + var(--yuri-wco-left-inset, 0px)), 5.5rem)`:(!xe||Oe)&&!ot?`calc(0.75rem + var(--yuri-wco-left-inset, 0px))`:`0.75rem`,[xe,Ee,De,Te,ot,Oe]);(0,Z.useEffect)(()=>{typeof document>`u`||document.documentElement.style.setProperty(`--yuri-titlebar-left-inset`,Qt)},[Qt]);let en=f?`0.75rem`:`var(--yuri-titlebar-left-inset, 0.75rem)`,tn=f?`0px`:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`,nn=Z.useMemo(()=>!xe||!De||Ae===null?``:Ae>=26?`h-12`:Ae<=15?`h-14`:``,[xe,De,Ae]),rn=Z.useMemo(()=>{if(!(xe&&!Oe||ot))return{paddingRight:Ot?`0.75rem`:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,minHeight:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`,height:`max(3rem, var(--yuri-wco-titlebar-height, 0px))`}},[xe,ot,Ot,Oe]),an=G(e=>{if(!e||typeof document>`u`)return;let t=document.documentElement.style,n=`${e}px`;t.getPropertyValue(`--yuri-header-height`)!==n&&t.setProperty(`--yuri-header-height`,n)});It(be,([e])=>{e&&an(e.borderBoxSize[0]?.blockSize??e.target.getBoundingClientRect().height)},{box:`border-box`}),Z.useLayoutEffect(()=>{an(be.current?.getBoundingClientRect().height)},[an,_e,nn]);let on=Z.useCallback(async e=>{let t=e.target;t.closest(`.app-region-no-drag`)||t.closest(`button, a, input, select, textarea`)||e.button===0&&xe&&await F()},[xe]),sn=Z.useMemo(()=>{if(_e){let e=[{id:`chat`,label:c(`layout.mainTab.chat`),icon:`chat-thread`}];return e.push({id:`diff`,label:c(`layout.mainTab.diff`),icon:`diff`},{id:`files`,label:c(`layout.mainTab.files`),icon:`folder-6`},{id:`terminal`,label:c(`layout.mainTab.terminal`),icon:`terminal-box`},{id:`diagram`,label:c(`layout.mainTab.diagram`),icon:`file`}),e}return[]},[_e,c]),ln=Z.useCallback(e=>Sa(Ta(e,T)),[T]);(0,Z.useEffect)(()=>{!_e&&(S===`git`||S===`terminal`||S===`diff`||S===`files`)&&C(`chat`)},[S,_e,C]);let un=Z.useMemo(()=>{let e=[];return xe&&e.push({value:`instance`,label:c(`layout.services.instance`),icon:(0,$.jsx)(X,{name:`connection-local`,className:`h-3.5 w-3.5`})}),e.push({value:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`})},{value:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}),e},[xe,c]),dn=Z.useMemo(()=>un.map(e=>({id:e.value,label:e.label,icon:e.icon})),[un]),fn=Z.useMemo(()=>[{value:`usage`,label:c(`header.services.used`)},{value:`remaining`,label:c(`header.services.remaining`)}],[c]),pn=Z.useMemo(()=>fn.map(e=>({id:e.value,label:e.label})),[fn]),mn=Z.useMemo(()=>[{id:`usage`,label:c(`layout.services.usage`),icon:(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`})},{id:`mcp`,label:`MCP`,icon:(0,$.jsx)(Fl,{className:`h-3.5 w-3.5`})}],[c]);(0,Z.useEffect)(()=>{let e=e=>{if(ur(e)&&!e.shiftKey&&!e.altKey){let t=parseInt(e.key,10);t>=1&&t<=sn.length&&(e.preventDefault(),_e&&(Lt(),Yt()),C(sn[t-1].id))}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Lt,Yt,_e,C,sn]);let hn=G(e=>{rt(e),Ye(!0),lt(),e===`usage`&&de===null&&H()});(0,Z.useEffect)(()=>{let e=e=>{let t=Ta(`toggle_services_menu`,T);if(wa(e,t)){e.preventDefault();let t=Rd({isOpen:Je,activeTab:nt,targetTab:xe?`instance`:`usage`});t.open?hn(t.tab):Ye(!1);return}let n=Ta(`cycle_services_tab`,T);if(wa(e,n)){e.preventDefault();let t=un.map(e=>e.value);if(t.length===0)return;let n=t.indexOf(nt),r=t[n===-1?0:(n+1)%t.length];rt(r),Ye(!0),lt(),r===`usage`&&de===null&&H();return}let r=Ta(`open_usage`,T);if(wa(e,r)){e.preventDefault();let t=Rd({isOpen:Je,activeTab:nt,targetTab:`usage`});t.open?hn(t.tab):Ye(!1);return}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[T,xe,Je,nt,un,de,H,lt,hn]);let gn=e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon,i=e.id===`chat`,a=e=>n?(0,$.jsx)(Au,{size:e}):r?(0,$.jsx)(X,{name:r,className:`h-${e/4} w-${e/4}`}):null,o=(0,$.jsxs)(`button`,{type:`button`,onClick:()=>C(e.id),className:J(`relative flex h-8 items-center gap-2 px-3 rounded-lg typography-ui-label font-medium transition-colors`,t?`app-region-no-drag bg-interactive-selection text-interactive-selection-foreground shadow-none`:`app-region-no-drag text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,i&&!_e&&`min-w-[100px] justify-center`),"aria-label":e.label,"aria-selected":t,role:`tab`,children:[_e?a(20):(0,$.jsxs)($.Fragment,{children:[a(16),(0,$.jsx)(`span`,{className:`header-tab-label`,children:e.label})]}),e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`header-tab-badge typography-micro text-status-info font-medium`,children:e.badge})]});return(0,$.jsx)(Z.Fragment,{children:o},e.id)},_n=!N&&Ce&&(B||!!z),vn=Z.useCallback(e=>{window.setTimeout(e,0)},[]),yn=Z.useCallback(e=>{hn(e)},[hn]),bn=Z.useRef(null),xn=(0,$.jsxs)(`div`,{className:`relative flex shrink-0 items-center`,children:[(0,$.jsx)(`div`,{ref:bn,className:`inline-flex h-8 w-8 shrink-0 items-center justify-center`,children:(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.actions.sessionMenuAria`),className:J(Kt,`text-muted-foreground`),children:(0,$.jsx)(X,{name:`more-2`,className:`h-[18px] w-[18px]`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.actions.sessionMenu`)})})]}),(0,$.jsxs)(bi,{align:`start`,className:`min-w-[14rem]`,children:[_n?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(Bt),children:[(0,$.jsx)(X,{name:`picture-in-picture-2`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(B?`header.actions.newMiniChat`:`header.actions.openSessionMiniChat`)})]}):null,xe?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`instance`)),children:[(0,$.jsx)(X,{name:`stack`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:c(`header.actions.sessionMenu.servicesWithInstance`,{current:Qe})}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ln(`toggle_services_menu`)})]}):null,(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(()=>yn(`usage`)),children:[(0,$.jsx)(X,{name:`timer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.sessionMenu.viewUsage`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ln(`open_usage`)})]}),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(m),children:[(0,$.jsx)(X,{name:`terminal-box`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`header.actions.toggleTerminalPanel`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ln(`toggle_terminal`)})]}),(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>vn(Wt),children:[(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`flex-1`,children:c(`contextPanel.browser.open`)}),Gt?(0,$.jsx)(X,{name:`check`,className:`h-3.5 w-3.5 text-foreground`}):null]})]})]})}),(0,$.jsx)(Ud,{isDesktopApp:xe,currentInstanceSupportsUpdate:et,isDesktopServicesOpen:Je,setIsDesktopServicesOpen:Ye,refreshCurrentInstanceLabel:lt,desktopServicesTab:nt,setDesktopServicesTab:rt,fetchAllQuotas:H,servicesTabItems:dn,quotaLastUpdated:de,quotaDisplayMode:fe,showPredValues:pe,quotaDisplayTabItems:pn,handleDisplayModeChange:ht,handleUsageRefresh:gt,isQuotaLoading:ce,isUsageRefreshSpinning:Xe,hasRateLimits:mt,rateLimitGroups:pt,expandedFamilies:dt,toggleFamilyExpanded:ft,timeFormatPreference:D,anchorRef:bn})]}),Sn=(0,$.jsxs)($.Fragment,{children:[!N&&!_e&&!ot&&S===`chat`?(0,$.jsx)(zu,{}):null,N?null:(0,$.jsx)(gd,{directory:jt}),xe&&(0,$.jsx)(Ku,{open:Je&&nt===`instance`,onClick:()=>hn(`instance`)}),(0,$.jsx)(Vd,{title:c(`header.actions.rightSidebarWithShortcut`,{shortcut:ln(`toggle_right_sidebar`)}),ariaLabel:c(`contextPanel.actions.togglePanel`),pressed:Ot,onClick:kt,className:J(`app-region-no-drag group inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover transition-colors`,Ot?`bg-interactive-selection text-interactive-selection-foreground`:`text-muted-foreground/75 hover:text-foreground`),Icon:`folder-3`,iconClassName:`size-4`}),(0,$.jsx)(Hd,{isMobile:_e,githubAuthStatus:ve,githubAccounts:Ue,githubAvatarUrl:Ve,githubLogin:He,isSwitchingGitHubAccount:We,handleGitHubAccountSwitch:Ft})]}),Cn=()=>(0,$.jsxs)(`div`,{onMouseDown:on,className:J(`app-region-drag relative flex h-12 select-none items-center pr-3`,nn),style:rn,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:[(0,$.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:en}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0 self-stretch transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,style:{width:tn}}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[(0,$.jsxs)(`div`,{className:`app-region-no-drag mr-3 flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(ac,{scopeProjectId:N?M?.id:null,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`sessions.switcher.openAria`),className:`inline-flex h-8 min-w-0 max-w-full items-center rounded-md px-2.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(`span`,{className:`truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground`,children:B?c(`sessions.switcher.draftTitle`):N&&s&&R?.sessionId?(0,$.jsx)(Xd,{entry:s.resolve(R.location),sessionId:R.sessionId,fallback:At},te(R.location)):At})})}),N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex min-w-0 max-w-36 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(X,{name:`computer`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null]}),sn.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 rounded-lg bg-[var(--surface-muted)]/50 p-1`,children:sn.map(e=>gn(e))}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[xn,N&&!ot&&S===`chat`&&s&&R?.sessionId?(0,$.jsx)(Zd,{entry:s.resolve(R.location),sessionId:R.sessionId,onClick:Vt,pressed:Ut},te(R.location)):null,st&&Le?(0,$.jsx)(rc,{pending:Le.pending,totalTokens:Le.totalTokens,percentage:ct,colorPercentage:Le.percentage,contextLimit:Le.contextLimit,outputLimit:Le.outputLimit??0,size:`compact`,appearance:`subtle`,onClick:Vt,pressed:Ut}):null,Sn,(0,$.jsx)(ic,{visible:Oe&&ke===`right`&&!Ot,position:`right`})]})]})]}),wn=()=>(0,$.jsxs)(`div`,{className:`app-region-drag relative flex items-center gap-2 px-3 py-2 select-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[e?(0,$.jsx)(`button`,{type:`button`,onClick:Xt,className:J(qt,Jt===`sessions`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":c(r?`header.actions.closeSessionsAria`:`header.actions.openSessionsAria`),children:(0,$.jsx)(X,{name:`layout-left`,className:`h-5 w-5`})}):Be?(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(!1),className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.backAria`),children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`h-5 w-5`})}):(0,$.jsx)(`button`,{type:`button`,onClick:Rt,className:`app-region-no-drag h-9 w-9 p-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary rounded-md active:bg-interactive-active`,"aria-label":c(`header.actions.openSessionsAria`),children:(0,$.jsx)(X,{name:`play-list-add`,className:`h-5 w-5`})}),!e&&Be&&(0,$.jsx)(`span`,{className:`typography-ui-label font-semibold text-foreground`,children:c(`header.sessions.title`)})]}),(!Be||!!e)&&(0,$.jsxs)($.Fragment,{children:[N?(0,$.jsxs)(`span`,{"data-remote-header-host":M?.hostId,className:`inline-flex max-w-28 shrink-0 items-center gap-1 typography-meta text-muted-foreground`,title:o,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o}),s&&M?.hostId?(0,$.jsx)(zo,{registry:s,hostId:M.hostId}):null]}):null,(0,$.jsx)(`div`,{className:`app-region-no-drag flex min-w-0 flex-1 items-center`,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 overflow-x-auto overflow-y-hidden scrollbar-hidden touch-pan-x overscroll-x-contain`,children:(0,$.jsx)(`div`,{className:`flex w-max items-center gap-1 pr-1`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 rounded-lg bg-[var(--surface-muted)]/50 p-0.5`,role:`tablist`,"aria-label":c(`header.navigation.mainAria`),children:sn.map(e=>{let t=S===e.id,n=e.icon===`diff`,r=n?null:e.icon;return(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{_e&&(Lt(),Yt()),C(e.id)},"aria-label":e.label,"aria-selected":t,role:`tab`,className:J(qt,`relative rounded-lg`,Jt===e.id&&`bg-interactive-selection text-interactive-selection-foreground`),children:[n?(0,$.jsx)(Au,{className:`h-5 w-5`}):r?(0,$.jsx)(X,{name:r,className:`h-5 w-5`}):null,e.badge!==void 0&&e.badge>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 text-[10px] font-semibold text-primary`,children:e.badge}),e.showDot&&(0,$.jsx)(`span`,{className:`absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-primary`,"aria-label":c(`header.changes.availableAria`)})]})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:e.label})})]},e.id)})})})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(Tu,{mobile:!0}),Pt&&(0,$.jsx)(Fd,{projectRef:Pt.projectRef,directory:Pt.directory,compact:!0,allowMobile:!0,className:`h-9`}),(0,$.jsxs)(Ci,{open:Ke,onOpenChange:n=>{n&&(r&&e&&e(),i&&t&&t()),qe(n),n&&de===null&&H()},children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":c(`header.services.viewAria`),className:J(qt,Jt===`services`&&`bg-interactive-selection text-interactive-selection-foreground`),children:(0,$.jsx)(X,{name:`stack`,className:`h-5 w-5`})})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:c(`header.services.title`)})})]}),(0,$.jsx)(bi,{align:`end`,sideOffset:0,positionerClassName:`!fixed !bottom-0 !left-0 !right-0 !top-[var(--yuri-header-height,56px)] !transform-none`,className:`h-full w-screen max-h-none rounded-none border-0 p-0 pt-1 overflow-hidden`,children:(0,$.jsxs)(`div`,{className:`flex h-full flex-col bg-[var(--surface-elevated)]`,children:[(0,$.jsx)(`div`,{className:`sticky top-0 z-20 bg-[var(--surface-elevated)] px-2 py-px`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-0`,children:[(0,$.jsx)(`div`,{className:`h-10 min-w-0 flex-1`,children:(0,$.jsx)(Vs,{items:mn,activeId:it,onSelect:e=>{let t=e;at(t),t===`usage`&&de===null&&H()},layoutMode:`fit`,variant:`active-pill`,activePillInsetClassName:`gap-0.5 px-px py-0`,activePillButtonClassName:`h-8`,className:`h-full`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>qe(!1),className:`inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-interactive-hover`,"aria-label":c(`header.services.closeAria`),children:(0,$.jsx)(X,{name:`close`,className:`h-5 w-5`})})]})}),it===`mcp`&&(0,$.jsx)(Ac,{active:Ke&&it===`mcp`}),it===`usage`&&(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto overflow-x-hidden pb-[calc(4rem+env(safe-area-inset-bottom))]`,children:[(0,$.jsx)(`div`,{className:`border-b border-[var(--interactive-border)]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-header font-semibold text-foreground`,children:c(`header.services.rateLimits`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gd(de,D)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center h-6`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>ht(`usage`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,fe===`usage`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.used`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground typography-ui-label px-0.5`,children:`·`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>ht(`remaining`),className:J(`typography-ui-label px-1 pb-0.5 transition-colors`,fe===`remaining`?`text-foreground border-b-2 border-[var(--primary-base)]`:`text-muted-foreground hover:text-foreground`),children:c(`header.services.remaining`)})]}),(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors`,`hover:text-foreground hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),onClick:gt,disabled:ce||Xe,"aria-label":c(`header.services.refreshRateLimitsAria`),children:(0,$.jsx)(X,{name:`refresh`,className:J(`h-4 w-4`,Xe&&`animate-spin`)})})]})]})}),!mt&&(0,$.jsx)(`div`,{className:`px-4 py-6 text-center`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:c(`header.services.noRateLimits`)})}),(0,$.jsx)(`div`,{className:`py-1`,children:pt.map((e,t)=>(0,$.jsxs)(Z.Fragment,{children:[t>0?(0,$.jsx)(`div`,{className:`mx-4 my-1 border-t border-[var(--interactive-border)]`}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2`,children:[(0,$.jsx)(Os,{providerId:e.providerId,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:e.providerName})]}),e.entries.length===0&&(!e.modelFamilies||e.modelFamilies.length===0)?(0,$.jsx)(`div`,{className:`px-4 pb-2`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:e.error??c(`header.services.noRateLimitsReported`)})}):(0,$.jsxs)(`div`,{className:`space-y-3 px-4 pb-2`,children:[e.entries.map(([t,n],r)=>{let i=Ll(e.entries,r),a=fe===`remaining`?n.remainingPercent:n.usedPercent,o=n.disablePace?null:ec(n.usedPercent,n.resetAt,n.windowSeconds,t),s=o?.dailyAllocationPercent==null?null:fe===`remaining`?100-nc(o.elapsedRatio):nc(o.elapsedRatio),c=Qs(n.valueLabel,a),l=$s(n.resetAt,n.resetAfterFormatted??n.resetAtFormatted,D);return(0,$.jsxs)(Z.Fragment,{children:[i?(0,$.jsx)(`div`,{className:J(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,r>0&&`mt-5 border-t border-[var(--surface-subtle)] pt-3`),children:i}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-1 flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground break-words`,children:tc(n.label??t)}),l?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l}):null]}),(0,$.jsx)(`span`,{className:`min-w-0 max-w-[55%] shrink-0 break-words text-right typography-ui-label text-foreground tabular-nums`,children:c===`-`?``:c})]}),(0,$.jsx)(mu,{percent:a,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:s}),o&&pe?(0,$.jsx)(au,{paceInfo:o,compact:!0}):null]})]},`${e.providerId}-${t}`)}),e.modelFamilies&&e.modelFamilies.length>0&&(0,$.jsx)(`div`,{className:`space-y-0.5`,children:e.modelFamilies.map(t=>{let n=(dt[e.providerId]??[]).includes(t.familyId??`other`);return(0,$.jsxs)(ji,{open:n,onOpenChange:()=>ft(e.providerId,t.familyId??`other`),children:[(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between rounded-md px-1 py-1.5 text-left hover:bg-[var(--interactive-hover)]/50 transition-colors`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground`,children:t.familyLabel}),n?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(ki,{children:(0,$.jsx)(`div`,{className:`space-y-2.5 pb-1 pl-1 pt-1`,children:t.models.map(([t,n])=>{let r=fe===`remaining`?n.remainingPercent:n.usedPercent,i=ec(n.usedPercent,n.resetAt,n.windowSeconds),a=i?.dailyAllocationPercent==null?null:fe===`remaining`?100-nc(i.elapsedRatio):nc(i.elapsedRatio),o=Qs(n.valueLabel,r);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:Gs(t)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground tabular-nums`,children:o===`-`?``:o})]}),(0,$.jsx)(mu,{percent:r,tonePercent:n.usedPercent,className:`h-1.5`,expectedMarkerPercent:a}),i&&pe?(0,$.jsx)(au,{paceInfo:i,compact:!0}):null]},`${e.providerId}-${t}`)})})})]},t.familyId??`other`)})})]})]},e.providerId))})]})]})})]}),t?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:Zt,className:J(qt,`relative`,Jt===`git`&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-label":i?`Close git sidebar`:`Open git sidebar`,children:(0,$.jsx)(X,{name:`layout-right`,className:`h-5 w-5`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:i?`Close git sidebar`:`Open git sidebar`})})]}):null]})]})]}),En=J(`header-safe-area relative z-10 bg-background`,we&&`bg-[var(--surface-background)] backdrop-blur-none`,_e&&`yuri-layout-divider-b`);return(0,$.jsx)($.Fragment,{children:(0,$.jsx)(`header`,{ref:be,className:En,style:{"--padding-scale":`1`},children:_e?wn():Cn()})})};function $d(){}function ef(e){return e.projects.find(t=>t.id===e.activeProjectId)?.hostId}function tf(){}var nf=180,rf=640,af=110,of=e=>{let t=(0,Q.c)(44),{isOpen:n,isMobile:r,children:i}=e,{t:a}=Nr(),o=K(sf),s=K(cf),c=K(lf),l=K(uf),[u,d]=Z.useState(null),[f,p]=Z.useState(!1),m=Z.useRef(null),h=Z.useRef(0),g=Z.useRef(o||300),_=Math.min(rf,Math.max(nf,o||300)),v,y;t[0]===n?(v=t[1],y=t[2]):(v=()=>{n||(d(null),p(!1))},y=[n],t[0]=n,t[1]=v,t[2]=y),Z.useEffect(v,y);let b,x;t[3]!==s||t[4]!==r||t[5]!==n?(b=()=>{if(r||!n||!s)return;let e=()=>{let e=m.current?.parentElement?.getBoundingClientRect().height;if(!e||e<=0)return;let t=Math.max(0,Math.round(e));d(e=>e===t?e:t)};e();let t=m.current?.parentElement;if(!t)return;let i=new ResizeObserver(e);return i.observe(t),()=>{i.disconnect()}},x=[s,r,n],t[3]=s,t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),Z.useEffect(b,x);let S,C;if(t[8]!==s||t[9]!==r||t[10]!==f||t[11]!==c||t[12]!==l?(S=()=>{if(r||!f||s)return;let e=e=>{let t=h.current-e.clientY,n=Math.min(rf,Math.max(nf,g.current+t));c(n)},t=()=>{p(!1),K.getState().bottomTerminalHeight<=af&&l(!1)};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},C=[s,r,f,c,l],t[8]=s,t[9]=r,t[10]=f,t[11]=c,t[12]=l,t[13]=S,t[14]=C):(S=t[13],C=t[14]),Z.useEffect(S,C),r)return null;let w=n?s?Math.max(0,u??_):_:0,T=n&&s,E;t[15]!==w||t[16]!==s||t[17]!==n?(E=e=>{!n||s||(p(!0),h.current=e.clientY,g.current=w,e.preventDefault())},t[15]=w,t[16]=s,t[17]=n,t[18]=E):E=t[18];let D=E,O=T?`absolute inset-x-0 bottom-0 z-40`:`relative`,k=f?`transition-none`:`transition-[height] duration-300 ease-in-out`,A=(!n||T)&&`border-t-0`,j;t[19]!==A||t[20]!==O||t[21]!==k?(j=J(`flex overflow-hidden border-t border-border bg-sidebar`,O,k,A),t[19]=A,t[20]=O,t[21]=k,t[22]=j):j=t[22];let M;t[23]!==w||t[24]!==T?(M=T?{top:0}:{height:`${w}px`,minHeight:`${w}px`,maxHeight:`${w}px`},t[23]=w,t[24]=T,t[25]=M):M=t[25];let N=!n||!s&&w===0,P;t[26]!==D||t[27]!==s||t[28]!==n||t[29]!==f||t[30]!==a?(P=n&&!s&&(0,$.jsx)(`div`,{className:J(`absolute left-0 top-0 z-20 h-[3px] w-full cursor-row-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,f&&`bg-[var(--interactive-border)]`),onPointerDown:D,role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`terminalView.bottomDock.resizeAria`)}),t[26]=D,t[27]=s,t[28]=n,t[29]=f,t[30]=a,t[31]=P):P=t[31];let F=!n&&`pointer-events-none select-none opacity-0`,I;t[32]===F?I=t[33]:(I=J(`relative z-10 flex h-full min-h-0 w-full flex-col transition-opacity duration-300 ease-in-out`,F),t[32]=F,t[33]=I);let L=!n,R;t[34]!==i||t[35]!==I||t[36]!==L?(R=(0,$.jsx)(`div`,{className:I,"aria-hidden":L,children:i}),t[34]=i,t[35]=I,t[36]=L,t[37]=R):R=t[37];let z;return t[38]!==j||t[39]!==M||t[40]!==N||t[41]!==P||t[42]!==R?(z=(0,$.jsxs)(`section`,{ref:m,className:j,style:M,"aria-hidden":N,children:[P,R]}),t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=R,t[43]=z):z=t[43],z};function sf(e){return e.bottomTerminalHeight}function cf(e){return e.isBottomTerminalExpanded}function lf(e){return e.setBottomTerminalHeight}function uf(e){return e.setBottomTerminalOpen}var df=260,ff=260,pf=500,mf=e=>Math.min(pf,Math.max(ff,e)),hf=({isOpen:e,isMobile:t,children:n,className:r,topBar:i})=>{let{t:a}=Nr(),o=K(e=>e.sidebarWidth),s=K(e=>e.setSidebarWidth),[c,l]=Z.useState(!1),u=Z.useRef(0),d=Z.useRef(o||df),f=Z.useRef(null),p=Z.useRef(null),m=Z.useRef(null),h=Z.useRef(null),g=G(e=>{let t=m.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,h.current&&(h.current.style.width=`${e}px`))});if(Z.useEffect(()=>{t&&c&&l(!1)},[t,c]),Z.useEffect(()=>{c||(f.current=null,p.current=null)},[c]),t)return null;let _=Math.min(pf,Math.max(ff,o||df)),v=e?_:0,y=t=>{if(e){try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}p.current=t.pointerId,l(!0),u.current=t.clientX,d.current=v,f.current=v,g(v),t.preventDefault()}},b=e=>{if(t||!c||p.current!==e.pointerId)return;let n=e.clientX-u.current,r=mf(d.current+n);f.current!==r&&(f.current=r,g(r))},x=e=>{if(p.current!==e.pointerId||t)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let n=mf(f.current??v);p.current=null,f.current=null,l(!1),s(n)},S=c?f.current??v:v;return(0,$.jsxs)(`aside`,{ref:m,className:J(`relative flex h-full overflow-hidden yuri-layout-divider-r will-change-[width] motion-reduce:transition-none`,`bg-sidebar yuri-vibrancy-surface`,!e&&`border-r-0`,r),style:{width:`${S}px`,minWidth:`${S}px`,maxWidth:`${S}px`,overflowX:`clip`,transitionProperty:c?`none`:`width, min-width, max-width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||v===0,children:[e&&(0,$.jsx)(`div`,{className:J(`absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,c&&`bg-[var(--interactive-border)]`),onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`sidebar.resize.leftPanelAria`)}),(0,$.jsxs)(`div`,{ref:h,className:J(`relative z-10 flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,c&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),style:{width:`${c?S:_}px`,overflowX:`hidden`},"aria-hidden":!e,children:[i,(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,$.jsx)(No,{children:n})})]})]})},gf=()=>{let e=(0,Q.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={height:`var(--yuri-header-height, 3rem)`},e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag shrink-0`,style:{width:`var(--yuri-titlebar-left-inset, 0.75rem)`}}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex shrink-0`,style:t,children:[n,(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-no-drag shrink-0`,style:{width:`calc(var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}}),(0,$.jsx)(`div`,{"aria-hidden":!0,className:`app-region-drag flex-1`})]}),e[2]=r):r=e[2],r},_f=e=>{let t=(0,Q.c)(26),{className:n}=e,{t:r}=Nr(),i=K(vf),a=gu(yf).trim(),o=a.split(/\s+/).filter(Boolean),s=o.includes(`Yuri`),c=o.some(bf);if(Z.useEffect(()=>{c&&ao()},[c]),o.length===0)return null;let l;t[0]===n?l=t[1]:(l=J(`flex min-w-0 items-center overflow-hidden pb-2 pt-1`,n),t[0]=n,t[1]=l);let u=q,d;t[2]===r?d=t[3]:(d=r(`layout.brand.editName`),t[2]=r,t[3]=d);let f;t[4]===r?f=t[5]:(f=r(`layout.brand.editName`),t[4]=r,t[5]=f);let p;t[6]===i?p=t[7]:(p=()=>i(`appearance`,`appearance.sidebar-brand`),t[6]=i,t[7]=p);let m=o.join(` `),h=a.includes(`Yuri`)?`items-center`:`items-baseline`,g;t[8]===h?g=t[9]:(g=J(`inline-flex min-w-0 gap-[0.28em] overflow-hidden whitespace-nowrap text-foreground`,h),t[8]=h,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={fontFamily:`"Syne", var(--font-sans, system-ui, sans-serif)`,fontSize:`1.0625rem`,fontWeight:700,letterSpacing:`0.08em`,lineHeight:1},t[10]=_):_=t[10];let v=a.includes(`Yuri`)?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex shrink-0 self-center`,children:(0,$.jsx)(jo,{width:24,height:24,className:`size-6`})}):null,y=o.map((e,t)=>(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`inline-flex shrink-0 items-baseline`,!s&&t>0&&`text-primary`),children:e===`Yuri`?(0,$.jsx)(Tl,{width:`2.44814cap`}):e},t)),b;t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==m?(b=(0,$.jsxs)(`span`,{role:`img`,"aria-label":m,className:g,style:_,children:[v,y]}),t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=m,t[16]=b):b=t[16];let x;t[17]!==u||t[18]!==b||t[19]!==d||t[20]!==f||t[21]!==p?(x=(0,$.jsx)(u,{variant:`ghost`,size:`xs`,className:`app-region-no-drag min-w-0 max-w-full justify-start`,"aria-label":d,title:f,onClick:p,children:b}),t[17]=u,t[18]=b,t[19]=d,t[20]=f,t[21]=p,t[22]=x):x=t[22];let S;return t[23]!==l||t[24]!==x?(S=(0,$.jsx)(`div`,{className:l,children:x}),t[23]=l,t[24]=x,t[25]=S):S=t[25],S};function vf(e){return e.openSettingsAtItem}function yf(e){return e.sidebarBrandName}function bf(e){return e!==`Yuri`}var xf=`app-region-no-drag inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground/75 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary hover:bg-interactive-hover hover:text-foreground transition-colors`,Sf=()=>{let e=(0,Q.c)(50),{t}=Nr(),n=$t(Cf),r=Tn(wf),i=n?.hostId&&r?.projectId===n.id&&r.location.hostId===n.hostId&&(!n.hubId||r.location.hubId===n.hubId)?r:null,a;e[0]!==n||e[1]!==i?(a=i?te(i.location):n?.hostId&&n.hubId?te({hubId:n.hubId,hostId:n.hostId,directory:n.path}):n?.path,e[0]=n,e[1]=i,e[2]=a):a=e[2];let o=a,s=K(Tf),c=K(Ef),l=K(Df),u=K(Of),d=gu(kf),f=Z.useRef(null),p=Sa(Ta(`toggle_sidebar`,u)),{usesFramelessChrome:m,side:h}=oc(),g;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=y(),e[3]=g):g=e[3];let _=g,v=!_||!s||!d,b;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=!E()&&!_&&oe(),e[4]=b):b=e[4];let x=b,S=jf,C,w;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{if(typeof document>`u`)return;let e=f.current;if(!e)return;let t=()=>{let t=e.getBoundingClientRect().width;document.documentElement.style.setProperty(`--yuri-titlebar-controls-width`,`${Math.round(t)}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},w=[],e[5]=C,e[6]=w):(C=e[5],w=e[6]),Z.useEffect(C,w);let T=o||void 0,D=x&&s?`${c||260}px`:void 0,O;e[7]===D?O=e[8]:(O={height:`var(--yuri-header-height, 3rem)`,paddingLeft:`var(--yuri-titlebar-left-inset, 0.75rem)`,width:D},e[7]=D,e[8]=O);let k=x&&s&&`w-full justify-between`,A;e[9]===k?A=e[10]:(A=J(`flex items-center gap-2`,k),e[9]=k,e[10]=A);let j;e[11]===s?j=e[12]:(j=x&&s?(0,$.jsx)(_f,{className:`flex min-w-0 items-center p-0 pl-1.5`}):null,e[11]=s,e[12]=j);let M;e[13]!==m||e[14]!==h?(M=m&&h===`left`?(0,$.jsx)(ic,{visible:!0,position:`left`}):null,e[13]=m,e[14]=h,e[15]=M):M=e[15];let N;e[16]!==t||e[17]!==m?(N=m?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:S,"aria-label":t(`header.actions.openAppMenuAria`),className:J(xf,`shrink-0`),children:(0,$.jsx)(X,{name:`menu-2`,className:`h-[18px] w-[18px]`})})}),(0,$.jsx)(ei,{children:(0,$.jsx)(`p`,{children:t(`header.actions.openAppMenu`)})})]}):null,e[16]=t,e[17]=m,e[18]=N):N=e[18];let P;e[19]===v?P=e[20]:(P=v?(0,$.jsx)(Fc,{}):null,e[19]=v,e[20]=P);let F=ni,I;e[21]===t?I=e[22]:(I=t(`header.actions.openSessionsAria`),e[21]=t,e[22]=I);let L,R;e[23]===Symbol.for(`react.memo_cache_sentinel`)?(L=J(xf,`group shrink-0`),R=(0,$.jsx)(X,{name:`layout-left-rounded`,className:`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`}),e[23]=L,e[24]=R):(L=e[23],R=e[24]);let z;e[25]!==I||e[26]!==l?(z=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:l,"aria-label":I,className:L,children:R})}),e[25]=I,e[26]=l,e[27]=z):z=e[27];let ee=ei,B=t(`header.actions.openSessionsWithShortcut`,{shortcut:p}),ne;e[28]===B?ne=e[29]:(ne=(0,$.jsx)(`p`,{children:B}),e[28]=B,e[29]=ne);let re;e[30]!==ee||e[31]!==ne?(re=(0,$.jsx)(ee,{children:ne}),e[30]=ee,e[31]=ne,e[32]=re):re=e[32];let ie;e[33]!==F||e[34]!==z||e[35]!==re?(ie=(0,$.jsxs)(F,{children:[z,re]}),e[33]=F,e[34]=z,e[35]=re,e[36]=ie):ie=e[36];let ae;e[37]!==P||e[38]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[P,ie]}),e[37]=P,e[38]=ie,e[39]=ae):ae=e[39];let V;e[40]!==A||e[41]!==j||e[42]!==M||e[43]!==N||e[44]!==ae?(V=(0,$.jsxs)(`div`,{ref:f,className:A,children:[j,M,N,ae]}),e[40]=A,e[41]=j,e[42]=M,e[43]=N,e[44]=ae,e[45]=V):V=e[45];let H;return e[46]!==V||e[47]!==T||e[48]!==O?(H=(0,$.jsx)(`div`,{"data-titlebar-location":T,className:`app-region-no-drag absolute left-0 top-0 z-30 flex select-none items-center pr-2`,style:O,children:V}),e[46]=V,e[47]=T,e[48]=O,e[49]=H):H=e[49],H};function Cf(e){return e.projects.find(t=>t.id===e.activeProjectId)}function wf(e){return e.remoteSession}function Tf(e){return e.isSidebarOpen}function Ef(e){return e.sidebarWidth}function Df(e){return e.toggleSidebar}function Of(e){return e.shortcutOverrides}function kf(e){return e.sidebarBrandName.trim().length>0}function Af(e){console.warn(`[titlebar] failed to open app menu`,e)}function jf(e){let t=e.currentTarget.getBoundingClientRect();I(`desktop_show_app_menu`,{x:t.left,y:t.bottom}).catch(Af)}var Mf=(e,t)=>{let n=Pt(t,e);return!n||n===`.`||n===t?0:n.split(`/`).filter(Boolean).length},Nf=(e,t,n=10)=>{let r=Nt(e);if(!r||n<1)return[];let i=new Set,a=[];for(let e of Object.values(t))if(e)for(let t of e){if(t.type!==`directory`)continue;let e=Nt(t.path);if(!e||i.has(e))continue;let o=Mf(r,e);o<1||o>n||(i.add(e),a.push(e))}return a},Pf=e=>e.some(e=>!!Nt(e)),Ff=(e,t)=>{let n=new Set(t.map(e=>Nt(e)).filter(Boolean));return e.filter(e=>!n.has(e))},If=(e,t,n)=>t.length===0?e.length===0:Ff(e,t).length>0?!1:t.every(e=>n.has(Nt(e))),Lf=ba(()=>Lt(()=>import(`./ToolOutputDialog-DdSUE2kP.js`).then(e=>e.n),__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]))),Rf=e=>{let t=Vf(e);if(!t)return``;if(t===`/`||/^[A-Za-z]:\/$/.test(t))return t;let n=t.lastIndexOf(`/`);if(n<0)return t;if(n===0)return`/`;let r=t.slice(0,n);return/^[A-Za-z]:$/.test(r)?`${r}/`:r},zf=e=>{let t=(0,Q.c)(8),{label:n,iconDataUrl:r}=e,[i,a]=Z.useState(!1),o;t[0]===n?o=t[1]:(o=n.trim().slice(0,1).toUpperCase()||`?`,t[0]=n,t[1]=o);let s=o;if(r&&!i){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>a(!0),t[2]=e):e=t[2];let n;return t[3]===r?n=t[4]:(n=(0,$.jsx)(`img`,{src:r,alt:``,className:`size-4 rounded-sm`,onError:e}),t[3]=r,t[4]=n),n}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=J(`size-4 rounded-sm flex items-center justify-center`,`bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground`),t[5]=c):c=t[5];let l;return t[6]===s?l=t[7]:(l=(0,$.jsx)(`span`,{className:c,children:s}),t[6]=s,t[7]=l),l},Bf=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Vf=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},Hf=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Uf=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,Wf=(e,t)=>{let n=Vf(t),r=Vf(e);if(!n||!r)return!1;let i=Uf(n),a=Uf(r);return a===i||a.startsWith(`${i}/`)},Gf=(e,t)=>{let n=Vf(t),r=Vf(e);if(!Wf(r,n))return[];let i=r.slice(n.length).replace(/^\//,``).split(`/`),a=[],o=n;for(let e=0;e<i.length-1;e++)o=o?`${o}/${i[e]}`:i[e],a.push(o);return a},Kf=(e,t)=>{if(!t)return``;let n=Vf(t);if(!e||!Wf(n,e))return n;let r=n.slice(e.length);return r.startsWith(`/`)?r.slice(1):r},qf=new Set([`node_modules`]),Jf=e=>{let t=(0,Q.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`size-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Yf=e=>{let t=(0,Q.c)(11),{name:n}=e,r=Z.useRef(null),i=Z.useRef(null),[a,o]=Z.useState(!1),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=r.current,t=i.current;if(!e||!t)return;let n=()=>{o(t.scrollWidth>e.clientWidth+1)};n();let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect()}},t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=[n],t[1]=n,t[2]=c),Z.useLayoutEffect(s,c);let l;t[3]===n?l=t[4]:(l=(0,$.jsx)(`span`,{ref:i,"aria-hidden":`true`,className:`invisible absolute whitespace-nowrap`,children:n}),t[3]=n,t[4]=l);let u;t[5]!==n||t[6]!==a?(u=a?(0,$.jsxs)(`span`,{className:`open-file-name-marquee-track`,children:[(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,children:n}),(0,$.jsx)(`span`,{className:`open-file-name-marquee-item`,"aria-hidden":`true`,children:n})]}):(0,$.jsx)(`span`,{className:`block min-w-0 truncate`,children:n}),t[5]=n,t[6]=a,t[7]=u):u=t[7];let d;return t[8]!==l||t[9]!==u?(d=(0,$.jsxs)(`span`,{ref:r,className:`relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10],d},Xf=e=>qf.has(e),Zf=e=>{let t=Vf(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Qf=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`is a directory`)||t.includes(`eisdir`)},$f=e=>{let t=(e instanceof Error?e.message:String(e??``)).toLowerCase();return t.includes(`file not found`)||t.includes(`enoent`)||t.includes(`no such file`)||t.includes(`does not exist`)},ep=2e5,tp=`yuri:files:auto-save-enabled`,np=e=>{let t=0,n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===10&&(r>0&&e.charCodeAt(r-1)===13?t+=1:n+=1);return t>n?`\r
4
+ `:`
5
+ `},rp=e=>e.replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `),ip=(e,t)=>{let n=rp(e);return t===`\r
8
+ `?n.replace(/\n/g,`\r
9
+ `):n},ap=()=>{if(typeof window>`u`)return!0;try{return window.localStorage.getItem(tp)!==`false`}catch{return!0}},op=(e,t)=>(0,$.jsx)(ri,{filePath:e,extension:t}),sp=e=>{if(!e)return!1;let t=e.toLowerCase().split(`.`).pop();return t===`md`||t===`markdown`},cp=e=>{let t=(0,Q.c)(83),{node:n,root:r,isExpanded:i,isActive:a,isMobile:o,alwaysShowActions:s,status:c,badge:l,permissions:u,downloadFile:d,contextMenuPath:f,setContextMenuPath:p,rightClickMenuPath:m,setRightClickMenuPath:h,onSelect:g,onToggle:_,onRevealPath:v,onOpenDialog:y}=e,{t:b}=Nr(),x=n.type===`directory`,{canRename:S,canCreateFile:C,canCreateFolder:w,canDelete:T,canReveal:E}=u,D;t[0]!==C||t[1]!==w||t[2]!==T||t[3]!==S||t[4]!==E||t[5]!==n.path||t[6]!==h?(D=e=>{!S&&!C&&!w&&!T&&!E||(e?.preventDefault(),h(n.path))},t[0]=C,t[1]=w,t[2]=T,t[3]=S,t[4]=E,t[5]=n.path,t[6]=h,t[7]=D):D=t[7];let O=D,k;t[8]!==x||t[9]!==n||t[10]!==g||t[11]!==_?(k=()=>{x?_(n.path):g(n)},t[8]=x,t[9]=n,t[10]=g,t[11]=_,t[12]=k):k=t[12];let A=k,j;t[13]!==n.path||t[14]!==p||t[15]!==h?(j=e=>{e.stopPropagation(),h(null),p(n.path)},t[13]=n.path,t[14]=p,t[15]=h,t[16]=j):j=t[16];let M=j,N;t[17]!==C||t[18]!==w||t[19]!==T||t[20]!==S||t[21]!==E||t[22]!==d||t[23]!==x||t[24]!==n||t[25]!==y||t[26]!==v||t[27]!==r||t[28]!==b?(N=e=>{let{Item:t,Separator:i}=e;return(0,$.jsxs)($.Fragment,{children:[S&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`rename`,n)},children:[(0,$.jsx)(X,{name:`edit`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.rename`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),pr(n.path).then(e=>{e.ok||Y.error(b(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.copyPath`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation();let t=Kf(r,n.path)||n.path;pr(t).then(e=>{if(e.ok){Y.success(b(`filesView.toast.relativePathCopied`));return}Y.error(b(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy-2`,className:`mr-2 size-4`}),` `,b(`filesView.tree.menu.copyRelativePath`)]}),!x&&d&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),d(n.path).catch(e=>{console.error(`Download failed:`,e),Y.error(b(`sidebarFilesTree.toast.operationFailed`))})},children:[(0,$.jsx)(X,{name:`download`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.save`)]}),E&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),v(n.path)},children:[(0,$.jsx)(X,{name:`folder-received`,className:`mr-2 size-4`}),` `,b(nr())]}),x&&(C||w)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(i,{}),C&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`createFile`,n)},children:[(0,$.jsx)(X,{name:`file-add`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.newFile`)]}),w&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`createFolder`,n)},children:[(0,$.jsx)(X,{name:`folder-add`,className:`mr-2 size-4`}),` `,b(`sidebarFilesTree.menu.newFolder`)]})]}),T&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(i,{}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),y(`delete`,n)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-2 size-4 text-inherit`}),` `,b(`sidebarFilesTree.menu.delete`)]})]})]})},t[17]=C,t[18]=w,t[19]=T,t[20]=S,t[21]=E,t[22]=d,t[23]=x,t[24]=n,t[25]=y,t[26]=v,t[27]=r,t[28]=b,t[29]=N):N=t[29];let P=N,F=m===n.path,I;t[30]!==n.path||t[31]!==h?(I=e=>h(e?n.path:null),t[30]=n.path,t[31]=h,t[32]=I):I=t[32];let L=o?void 0:O,R;t[33]===L?R=t[34]:(R=(0,$.jsx)(`div`,{className:`group relative flex items-center`,onContextMenu:L}),t[33]=L,t[34]=R);let z=o?void 0:O,ee=a?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`,B;t[35]===ee?B=t[36]:(B=J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none`,ee),t[35]=ee,t[36]=B);let te;t[37]!==x||t[38]!==i||t[39]!==n.extension||t[40]!==n.path?(te=x?i?(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-4 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-4 flex-shrink-0 text-muted-foreground`}):op(n.path,n.extension),t[37]=x,t[38]=i,t[39]=n.extension,t[40]=n.path,t[41]=te):te=t[41];let ne;t[42]!==n.name||t[43]!==n.path?(ne=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-meta`,title:n.path,children:n.name}),t[42]=n.name,t[43]=n.path,t[44]=ne):ne=t[44];let re;t[45]!==x||t[46]!==c?(re=!x&&c&&(0,$.jsx)(Jf,{status:c}),t[45]=x,t[46]=c,t[47]=re):re=t[47];let ie;t[48]!==l||t[49]!==x?(ie=x&&l&&(0,$.jsxs)(`span`,{className:`text-xs flex items-center gap-1 ml-auto mr-1`,children:[l.modified>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-warning)]`,children:[`M`,l.modified]}),l.added>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,l.added]})]}),t[48]=l,t[49]=x,t[50]=ie):ie=t[50];let ae;t[51]!==A||t[52]!==B||t[53]!==te||t[54]!==ne||t[55]!==re||t[56]!==ie||t[57]!==z?(ae=(0,$.jsxs)(`button`,{type:`button`,onClick:A,onContextMenu:z,className:B,children:[te,ne,re,ie]}),t[51]=A,t[52]=B,t[53]=te,t[54]=ne,t[55]=re,t[56]=ie,t[57]=z,t[58]=ae):ae=t[58];let oe;t[59]!==s||t[60]!==C||t[61]!==w||t[62]!==T||t[63]!==S||t[64]!==E||t[65]!==f||t[66]!==M||t[67]!==o||t[68]!==n.path||t[69]!==P||t[70]!==p?(oe=(S||C||w||T||E)&&(0,$.jsx)(`div`,{className:J(`absolute right-1 top-1/2 -translate-y-1/2`,s?`opacity-100`:`opacity-0 focus-within:opacity-100 group-hover:opacity-100`),children:(0,$.jsxs)(Ci,{open:f===n.path,onOpenChange:e=>p(e?n.path:null),children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:M,children:(0,$.jsx)(X,{name:`more-2-fill`,className:`size-4`})})}),(0,$.jsx)(bi,{align:`end`,side:`bottom`,onCloseAutoFocus:()=>p(null),children:P({Item:xi,Separator:Si})})]})}),t[59]=s,t[60]=C,t[61]=w,t[62]=T,t[63]=S,t[64]=E,t[65]=f,t[66]=M,t[67]=o,t[68]=n.path,t[69]=P,t[70]=p,t[71]=oe):oe=t[71];let V;t[72]!==ae||t[73]!==oe||t[74]!==R?(V=(0,$.jsxs)(wi,{render:R,children:[ae,oe]}),t[72]=ae,t[73]=oe,t[74]=R,t[75]=V):V=t[75];let H;t[76]===P?H=t[77]:(H=(0,$.jsx)(Ei,{className:`min-w-[180px]`,children:P({Item:Di,Separator:Ti})}),t[76]=P,t[77]=H);let se;return t[78]!==V||t[79]!==H||t[80]!==F||t[81]!==I?(se=(0,$.jsxs)(Oi,{open:F,onOpenChange:I,children:[V,H]}),t[78]=V,t[79]=H,t[80]=F,t[81]=I,t[82]=se):se=t[82],se},lp=e=>{let t=(0,Q.c)(83),{activeDialog:n,dialogData:r,dialogInputValue:i,onDialogInputChange:a,isDialogSubmitting:o,onDialogSubmit:s,onClose:c,inputRef:l}=e,{t:u}=Nr(),d=!!n,f;t[0]===c?f=t[1]:(f=e=>!e&&c(),t[0]=c,t[1]=f);let p;t[2]!==n||t[3]!==u?(p=n===`createFile`&&u(`filesView.dialog.createFile.title`),t[2]=n,t[3]=u,t[4]=p):p=t[4];let m;t[5]!==n||t[6]!==u?(m=n===`createFolder`&&u(`filesView.dialog.createFolder.title`),t[5]=n,t[6]=u,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==u?(h=n===`rename`&&u(`filesView.dialog.rename.title`),t[8]=n,t[9]=u,t[10]=h):h=t[10];let g;t[11]!==n||t[12]!==u?(g=n===`delete`&&u(`filesView.dialog.delete.title`),t[11]=n,t[12]=u,t[13]=g):g=t[13];let _;t[14]!==p||t[15]!==m||t[16]!==h||t[17]!==g?(_=(0,$.jsxs)(Xr,{children:[p,m,h,g]}),t[14]=p,t[15]=m,t[16]=h,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n||t[20]!==r?.path||t[21]!==u?(v=n===`createFile`&&u(`filesView.dialog.createFile.description`,{path:r?.path??u(`filesView.dialog.rootFallback`)}),t[19]=n,t[20]=r?.path,t[21]=u,t[22]=v):v=t[22];let y;t[23]!==n||t[24]!==r?.path||t[25]!==u?(y=n===`createFolder`&&u(`filesView.dialog.createFolder.description`,{path:r?.path??u(`filesView.dialog.rootFallback`)}),t[23]=n,t[24]=r?.path,t[25]=u,t[26]=y):y=t[26];let b;t[27]!==n||t[28]!==r?.name||t[29]!==u?(b=n===`rename`&&u(`filesView.dialog.rename.description`,{name:r?.name??``}),t[27]=n,t[28]=r?.name,t[29]=u,t[30]=b):b=t[30];let x;t[31]!==n||t[32]!==r?.name||t[33]!==u?(x=n===`delete`&&u(`filesView.dialog.delete.description`,{name:r?.name??``}),t[31]=n,t[32]=r?.name,t[33]=u,t[34]=x):x=t[34];let S;t[35]!==b||t[36]!==x||t[37]!==v||t[38]!==y?(S=(0,$.jsxs)(Zr,{children:[v,y,b,x]}),t[35]=b,t[36]=x,t[37]=v,t[38]=y,t[39]=S):S=t[39];let C;t[40]!==S||t[41]!==_?(C=(0,$.jsxs)(qr,{children:[_,S]}),t[40]=S,t[41]=_,t[42]=C):C=t[42];let w;t[43]!==n||t[44]!==i||t[45]!==l||t[46]!==a||t[47]!==s||t[48]!==u?(w=n!==`delete`&&(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsx)(va,{value:i,onChange:e=>a(e.target.value),placeholder:u(n===`rename`?`filesView.dialog.rename.placeholder`:`filesView.dialog.namePlaceholder`),onKeyDown:e=>{e.key===`Enter`&&s()},ref:l})}),t[43]=n,t[44]=i,t[45]=l,t[46]=a,t[47]=s,t[48]=u,t[49]=w):w=t[49];let T;t[50]===u?T=t[51]:(T=u(`filesView.dialog.cancel`),t[50]=u,t[51]=T);let E;t[52]!==o||t[53]!==c||t[54]!==T?(E=(0,$.jsx)(q,{variant:`outline`,onClick:c,disabled:o,children:T}),t[52]=o,t[53]=c,t[54]=T,t[55]=E):E=t[55];let D=n===`delete`?`destructive`:`default`,O;t[56]===s?O=t[57]:(O=()=>void s(),t[56]=s,t[57]=O);let k;t[58]!==n||t[59]!==i||t[60]!==o?(k=o||n!==`delete`&&!i.trim(),t[58]=n,t[59]=i,t[60]=o,t[61]=k):k=t[61];let A;t[62]!==n||t[63]!==o||t[64]!==u?(A=o?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):u(n===`delete`?`filesView.dialog.delete.confirm`:`filesView.dialog.confirm`),t[62]=n,t[63]=o,t[64]=u,t[65]=A):A=t[65];let j;t[66]!==D||t[67]!==O||t[68]!==k||t[69]!==A?(j=(0,$.jsx)(q,{variant:D,onClick:O,disabled:k,children:A}),t[66]=D,t[67]=O,t[68]=k,t[69]=A,t[70]=j):j=t[70];let M;t[71]!==E||t[72]!==j?(M=(0,$.jsxs)(Jr,{children:[E,j]}),t[71]=E,t[72]=j,t[73]=M):M=t[73];let N;t[74]!==l||t[75]!==C||t[76]!==w||t[77]!==M?(N=(0,$.jsxs)(Yr,{initialFocus:l,children:[C,w,M]}),t[74]=l,t[75]=C,t[76]=w,t[77]=M,t[78]=N):N=t[78];let P;return t[79]!==d||t[80]!==f||t[81]!==N?(P=(0,$.jsx)(Qr,{open:d,onOpenChange:f,children:N}),t[79]=d,t[80]=f,t[81]=N,t[82]=P):P=t[82],P},up=(e,t,n)=>e&&!!t&&n===t,dp=(e,t,n)=>{let r=(0,Q.c)(8),[s,c]=Z.useState(``),[l,u]=Z.useState(0),d,f;r[0]!==e||r[1]!==n||r[2]!==t?(d=()=>{if(!e){c(``);return}let r=!1;c(``);let s=h(),l=a(s);i(s).then(n=>{r||!n||(c(e),t(null))}).catch(i=>{r||(t(i instanceof Error?i.message:n),c(e))});let d=o(()=>{r||(c(e),u(mp),t(null))});return()=>{r=!0,l(),d()}},f=[e,t,n],r[0]=e,r[1]=n,r[2]=t,r[3]=d,r[4]=f):(d=r[3],f=r[4]),Z.useEffect(d,f);let p;return r[5]!==l||r[6]!==s?(p={readyKey:s,nonce:l},r[5]=l,r[6]=s,r[7]=p):p=r[7],p},fp=e=>{let t=(0,Q.c)(5),n=bt();if(!n?.entry.location.hostId){let n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(pp,{...e}),t[0]=e,t[1]=n),n}let r;return t[2]!==n.entry.key||t[3]!==e?(r=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(pp,{...e},n.entry.key)})}),t[2]=n.entry.key,t[3]=e,t[4]=r):r=t[4],r},pp=({mode:e=`full`,isActive:t=!0,targetPath:n})=>{let{t:r}=Nr(),{files:i,runtime:a,projectScope:o}=Gi(),{currentTheme:s,availableThemes:c,lightThemeId:l,darkThemeId:d}=ai(),{isMobile:f,isTablet:p,screenWidth:m}=fi({includeScreenWidth:!0}),h=f||p,_=Be(),v=Re(),y=Ki()??``,b=o?y:Vf(y.trim()),x=f||e!==`editor-only`,S=e===`editor-only`&&!f,C=ze(e=>e.searchFiles),T=Zi(y),[E,k]=Z.useState(``),A=Aa(E,200),j=Z.useRef(null),[M,N]=Z.useState(!1),[P,F]=Z.useState(!0),[I,L]=Z.useState(!1),[R,z]=Z.useState(!1),[ee,B]=Z.useState(!1),[ne,re]=Z.useState({open:!1,title:``,content:``}),ie=Z.useRef(null),ae=Z.useRef(0),oe=Z.useCallback(e=>{ae.current=Math.max(0,ae.current+(e?1:-1))},[]),V=Z.useCallback(e=>e instanceof Element&&e.closest(`[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]`)!==null,[]);Z.useEffect(()=>{if(!ee)return;let e=e=>{ae.current>0||V(e.target)||ie.current&&!ie.current.contains(e.target)&&B(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[V,ee]);let[H,se]=Z.useState(`edit`),[U,ce]=Z.useState(`edit`),[le,ue]=Z.useState(`edit`),[de,fe]=Z.useState(`preview`),[pe,me]=Z.useState(0),he=Z.useRef({}),ge=Z.useRef({}),_e=Z.useRef({}),ve=Z.useRef({}),ye=Z.useMemo(()=>c.find(e=>e.metadata.id===l)??Hi(!1),[c,l]),be=Z.useMemo(()=>c.find(e=>e.metadata.id===d)??Hi(!0),[c,d]);Z.useEffect(()=>{Vi(ye),Vi(be)},[ye,be]);let xe=Z.useMemo(()=>[],[]),Se=o?te({...o.location,directory:b||o.location.directory}):b,Ce=Bo(e=>Se?e.byRoot[Se]?.openPaths??xe:xe),we=Bo(e=>Se?e.byRoot[Se]?.selectedPath??null:null),Te=Bo(e=>Se?e.byRoot[Se]?.expandedPaths??xe:xe),{addOpenPath:Ee,removeOpenPath:De,removeOpenPathsByPrefix:Oe,removeExpandedPathsByPrefix:ke,setSelectedPath:Ae,toggleExpandedPath:je,expandPaths:Me}=Z.useMemo(()=>{let e=Bo.getState();return o?{addOpenPath:(t,n,r)=>e.addOpenPath(Se,n,r),removeOpenPath:(t,n)=>e.removeOpenPath(Se,n),removeOpenPathsByPrefix:(t,n)=>e.removeOpenPathsByPrefix(Se,n),removeExpandedPathsByPrefix:(t,n)=>e.removeExpandedPathsByPrefix(Se,n),setSelectedPath:(t,n,r)=>e.setSelectedPath(Se,n,r),toggleExpandedPath:(t,n)=>e.toggleExpandedPath(Se,n),expandPaths:(t,n)=>e.expandPaths(Se,n)}:e},[o,Se]),Ne=Z.useCallback(e=>{let t=Vf(e),n=t.split(`/`),r=n[n.length-1]||t;return{name:r,path:t,type:`file`,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0}},[]),Pe=Z.useMemo(()=>Ce.map(Ne),[Ce,Ne]),Fe=e===`editor-only`&&n?Vf(n):null,Ie=Z.useMemo(()=>{if(Fe)return Fe;if(we){let e=Uf(we);if(Ce.some(t=>Uf(t)===e))return we}return Ce[0]??null},[Fe,Ce,we]),W=Z.useMemo(()=>Ie?Ne(Ie):null,[Ie,Ne]),Le=W?.path??``;Z.useEffect(()=>{if(!b||!we)return;let e=Uf(we);Ce.some(t=>Uf(t)===e)||Ae(b,Ce[0]??null)},[Ce,b,we,Ae]);let Ve=!!(b&&Le&&!Wf(Le,b)),He=Ve?ns(Le):void 0,Ue=Z.useMemo(()=>({allowOutsideWorkspace:e===`editor-only`&&Ve,outsideFileGrant:He,directory:b||void 0}),[e,Ve,He,b]),We=Z.useRef(null),[Ge,Ke]=Z.useState({left:!1,right:!1}),qe=Z.useCallback(()=>{let e=We.current;e&&Ke({left:e.scrollLeft>2,right:e.scrollLeft+e.clientWidth<e.scrollWidth-2})},[]),Je=Z.useRef(qe);Je.current=qe,Z.useEffect(()=>{let e=We.current;if(!e)return;let t=()=>Je.current();t(),e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),()=>{e.removeEventListener(`scroll`,t),n.disconnect()}},[Pe.length]);let[Ye,Xe]=Z.useState({}),[Ze,Qe]=Z.useState({}),$e=Z.useRef(new Set),et=Z.useRef(new Set),tt=Z.useRef(!1),nt=Z.useRef(new Map),it=Z.useRef(0),[at,ot]=Z.useState([]),[st,ct]=Z.useState(!1),[lt,ut]=Z.useState(``),{isPlaying:ft,play:pt,stop:mt}=Hs(),[ht,gt]=Z.useState(!1),[_t,vt]=Z.useState(null),[yt,bt]=Z.useState(``),xt=Z.useRef(``),[St,Ct]=Z.useState(null),wt=ht&&St!==Le,[Tt,Mt]=Z.useState(0),[Nt,Pt]=Z.useState(null),Ft=!!(Le&&Nt===Le),[It,Lt]=Z.useState(null),[Rt,zt]=Z.useState(``),[Bt,Vt]=Z.useState(!1),[Ht,Ut]=Z.useState(`
10
+ `),Wt=Z.useRef(null),Gt=Z.useRef(null),Kt=Z.useRef(null),qt=Z.useRef(``),Xt=Z.useRef(``),Zt=Z.useRef(null),Qt=Z.useRef(null),$t=Z.useRef(null),en=Z.useRef(0),tn=Z.useRef(null),[nn,rn]=Z.useState(`idle`),[an,on]=Z.useState(!1),[sn,cn]=Z.useState(ap),[ln,un]=Z.useState(!1),dn=Z.useRef(null),fn=Z.useRef(null),pn=Z.useRef(null),mn=Z.useRef(!1),hn=Z.useRef(null),gn=Z.useRef(null),_n=Z.useRef(null),vn=Z.useRef(null),[yn,bn]=Z.useState(0),xn=Z.useRef(null),Sn=Z.useRef({key:``,attempts:0});Z.useEffect(()=>()=>{xn.current!==null&&typeof window<`u`&&(window.cancelAnimationFrame(xn.current),xn.current=null)},[]);let[Cn,wn]=Z.useState(null),[Tn,En]=Z.useState(null),[Dn,On]=Z.useState(``),[kn,jn]=Z.useState(!1),[Nn,Pn]=Z.useState(null),[Fn,In]=Z.useState(null),[Ln,Rn]=Z.useState(!1),[zn,Bn]=Z.useState(!1),[Vn,Hn]=Z.useState(!1),[Un,Wn]=Z.useState(null),Gn=Fr(e=>e.addCodeSelectionAttachment),Kn=Fr(e=>e.setPendingInputText),qn=!!i.writeFile,Jn=!!i.createDirectory,Yn=!!i.rename,Xn=!!i.delete,Zn=!!i.revealPath,Qn=sd(e=>e.availableApps),$n=sd(e=>e.isCacheStale),er=sd(e=>e.initialize),tr=sd(e=>e.loadInstalledApps);Z.useEffect(()=>{o||er()},[er,o]);let nr=Z.useCallback(e=>{i.revealPath&&i.revealPath(e).catch(()=>{Y.error(r(`sidebarFilesTree.toast.revealFailed`))})},[i,r]),rr=Z.useCallback(async e=>{if(o||!W?.path||await D(W.path,e.id,e.appName)||await O(W.path,e.appName))return;let t=Rf(W.path)||b;t&&await O(t,e.appName)||Y.error(r(`filesView.toast.openInAppFailed`,{app:e.appName}))},[b,W?.path,r,o]),ir=Z.useCallback((e,t)=>{wn(e),En(t),On(e===`rename`&&t.name||``),jn(!1)},[]),[ar,or]=Z.useState(null),sr=Z.useRef(!1),cr=Z.useRef(null),[lr,dr]=Z.useState(!1),fr=K(e=>e.setMainTabGuard),mr=K(e=>e.pendingFileNavigation),hr=K(e=>e.setPendingFileNavigation),gr=K(e=>e.pendingFileFocusPath),_r=K(e=>e.setPendingFileFocusPath),vr=K(e=>e.pendingFileViewerMode),yr=K(e=>e.setPendingFileViewerMode),br=K(e=>e.fileEditorKeymap),xr=An(e=>e.settingsDefaultFileViewerPreview),Sr=An(e=>e.showMessageTTSButtons);Z.useEffect(()=>{let e=()=>{sr.current=!1,cr.current=null,dr(!1)};return document.addEventListener(`mouseup`,e),()=>document.removeEventListener(`mouseup`,e)},[]),Z.useEffect(()=>()=>{hn.current!==null&&window.clearTimeout(hn.current),gn.current!==null&&window.clearTimeout(gn.current)},[]);let Cr=Z.useCallback((e,t)=>{let n=e.split(`
11
+ `),r=Math.max(1,t.start),i=Math.min(n.length,t.end);return r>i?``:n.slice(r-1,i).join(`
12
+ `)},[]),{drafts:wr,commentText:Tr,setCommentText:Er,editingDraftId:Dr,setSelection:Or,saveComment:kr,cancel:Ar,reset:jr,startEdit:Mr,deleteDraft:Pr}=Fi({source:`file`,fileLabel:W?.path??null,language:W?.path&&Ir(W.path)||`text`,getCodeForRange:e=>Cr(lt,Mi(e)),toStoreRange:e=>({startLine:e.start,endLine:e.end}),fromDraftRange:e=>({start:e.startLine,end:e.endLine})});Z.useEffect(()=>{or(null),jr(),fr(null),zt(``),Vt(!1)},[W?.path,jr,fr]),Z.useEffect(()=>{Or(ar)},[ar,Or]),Z.useEffect(()=>{if(!ar&&!Dr)return;let e=e=>{let t=e.target;t.closest(`[data-comment-input="true"]`)||t.closest(`[data-comment-card="true"]`)||t.closest(`.cm-gutterElement`)||t.closest(`[data-sonner-toast]`)||t.closest(`[data-sonner-toaster]`)||Tr.trim()||(or(null),Ar())},t=setTimeout(()=>{document.addEventListener(`click`,e)},100);return()=>{clearTimeout(t),document.removeEventListener(`click`,e)}},[Ar,Tr,Dr,ar]);let Hr=Z.useCallback((e,t)=>{let n=t??ar??void 0;t&&or(t),kr(e,n),or(null)},[ar,kr]),Ur=Z.useCallback((e,t)=>{let n=[];for(let r of t){if(!(r&&typeof r.name==`string`&&r.name.length>0)||!_&&r.name.startsWith(`.`)||!v&&Xf(r.name))continue;let t=r.name,i=Vf(r.path||``),a=i?Hf(i)?i:Vf(`${e}/${i}`):Vf(`${e}/${t}`),o=r.isDirectory?`directory`:`file`,s=o===`file`&&t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():void 0;n.push({name:t,path:a,type:o,extension:s})}return Bf(n)},[v,_]),Gr=Z.useCallback(async e=>{let t=Vf(e.trim());if(!t||$e.current.has(t)||et.current.has(t))return;et.current=new Set(et.current),et.current.add(t);let n=it.current+1;it.current=n,nt.current=new Map(nt.current),nt.current.set(t,n);let r=()=>nt.current.get(t)===n;await(i.listDirectory?i.listDirectory(t).then(e=>e.entries.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory}))):rt.listLocalDirectory(t).then(e=>e.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory})))).then(e=>{if(!r())return;let n=Ur(t,e);$e.current=new Set($e.current),$e.current.add(t),Qe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),Xe(e=>({...e,[t]:n}))}).catch(e=>{if(!r())return;let n=e instanceof Error?e.message:String(e??``);if(n===`Directory not found`&&b&&t!==b){ke(b,t),Qe(e=>{if(!e[t])return e;let n={...e};return delete n[t],n});return}console.error(`Failed to load files directory:`,e),Qe(e=>({...e,[t]:n}))}).finally(()=>{r()&&(nt.current=new Map(nt.current),nt.current.delete(t),et.current=new Set(et.current),et.current.delete(t))})},[i,Ur,ke,b]),Kr=Z.useCallback(async()=>{b&&($e.current=new Set,et.current=new Set,nt.current=new Map,Qe({}),Xe(e=>Object.keys(e).length===0?e:{}),await Gr(b))},[Gr,b]),ti=Z.useCallback(async e=>{if(!e){await Kr();return}let t=Vf(e);$e.current=new Set($e.current),$e.current.delete(t),et.current=new Set(et.current),et.current.delete(t),await Gr(t)},[Gr,Kr]),ii=Z.useRef(``),oi=Z.useRef(``);Z.useEffect(()=>{if(!b)return;let e=`${b}|h${_?`1`:`0`}|g${v?`1`:`0`}`,t=ii.current!==b,n=oi.current!==e;!t&&!n||(t&&(ii.current=b,ut(``),vt(null),bt(``),Ct(null),N(!1)),n&&(oi.current=e,tt.current=!1,$e.current=new Set,et.current=new Set,nt.current=new Map,Qe({}),Xe(e=>Object.keys(e).length===0?e:{}),Gr(b)))},[Gr,b,v,_]),Z.useEffect(()=>{if(!i.listDirectory)return;let e=()=>{if(!document.hidden&&Te.length>0)for(let e of Te)ti(e)};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Te,i.listDirectory,ti]),Z.useEffect(()=>{if(!b||Te.length===0)return;let e=Te.map(e=>Vf(e)).filter(e=>!!e&&e!==b&&e.startsWith(`${b}/`)&&!$e.current.has(e)&&!et.current.has(e)).sort((e,t)=>e.split(`/`).length-t.split(`/`).length);if(e.length===0)return;let t=!1;return(async()=>{for(let n=0;n<e.length&&!t;n+=3){let t=e.slice(n,n+3);await Promise.all(t.map(e=>Gr(e)))}})(),()=>{t=!0}},[Te,Gr,b]);let si=Z.useCallback(async e=>{if(e?.preventDefault(),!Tn||!Cn)return;jn(!0);let t=()=>{wn(null)},n=e=>{Y.error(e)},a=()=>{jn(!1)};if(Cn===`createFile`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.filenameRequired`)),a();return}if(!i.writeFile){n(r(`sidebarFilesTree.toast.writeNotSupported`)),a();return}let e=Tn.path,o=Vf(`${e?`${e}/`:``}${Dn.trim()}`);await i.writeFile(o,``).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.fileCreated`)),await ti(e)),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`createFolder`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.folderNameRequired`)),a();return}let e=Tn.path,o=Vf(`${e?`${e}/`:``}${Dn.trim()}`);await i.createDirectory(o).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.folderCreated`)),await ti(e)),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`rename`){if(!Dn.trim()){n(r(`sidebarFilesTree.toast.nameRequired`)),a();return}if(!i.rename){n(r(`sidebarFilesTree.toast.renameNotSupported`)),a();return}let e=Tn.path,o=e.split(`/`).slice(0,-1).join(`/`),s=Vf(`${o?`${o}/`:``}${Dn.trim()}`);await i.rename(e,s).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.renamedSuccessfully`)),await ti(o),b&&Oe(b,e),(W?.path===e||W?.path.startsWith(`${e}/`))&&(b&&Ae(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1))),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}if(Cn===`delete`){if(!i.delete){n(r(`sidebarFilesTree.toast.deleteNotSupported`)),a();return}let e=Tn.path,o=e.split(`/`).slice(0,-1).join(`/`);await i.delete(e).then(async n=>{n.success&&(Y.success(r(`sidebarFilesTree.toast.deletedSuccessfully`)),await ti(o),b&&Oe(b,e),(W?.path===e||W?.path.startsWith(`${e}/`))&&(b&&Ae(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1))),t()}).catch(()=>n(r(`sidebarFilesTree.toast.operationFailed`))).finally(a);return}a()},[Cn,Tn,Dn,i,ti,f,Oe,b,W?.path,Ae,r]);Z.useEffect(()=>{if(!y){ot([]),ct(!1);return}let e=A.trim();if(!e){ot([]),ct(!1);return}let t=!1;return ct(!0),(o?Dt.fetchQuery(jt(i,{scope:o,directory:y,query:e,maxResults:150,includeHidden:_,respectGitignore:!v})).then(e=>e.map(e=>({path:e.path,name:e.path.split(/[\\/]/).pop()??e.path,extension:e.path.split(`.`).pop(),relativePath:Kf(b,e.path)}))):C(y,e,150,{includeHidden:_,respectGitignore:!v,type:`file`})).then(e=>{if(t)return;let n=e.filter(e=>v||!Zf(e.path)).map(e=>({name:e.name,path:Vf(e.path),type:`file`,extension:e.extension,relativePath:e.relativePath}));ot(n)}).catch(()=>{t||ot([])}).finally(()=>{t||ct(!1)}),()=>{t=!0}},[y,A,C,_,v,o,i,b]);let ci=Z.useCallback(async(e,t)=>{if(i.readFile)return(await i.readFile(e,{...t??{},directory:b||void 0})).content??``;let n=new URLSearchParams({path:e});t?.allowOutsideWorkspace&&n.set(`allowOutsideWorkspace`,`true`),t?.outsideFileGrant&&n.set(`outsideFileGrant`,t.outsideFileGrant),t?.optional&&n.set(`optional`,`true`),b&&n.set(`directory`,b);let a=await g(`/api/fs/read?${n.toString()}`,{cache:t?.optional?`no-store`:`default`});if(!a.ok){let e=await a.json().catch(()=>({error:a.statusText}));throw Error(e.error||r(`filesView.error.readFileFailed`))}return a.text()},[i,b,r]),li=Z.useCallback(async(e,t)=>{if(i.statFile){let n=await i.statFile(e,{...t??{},directory:b||void 0});return{path:n.path,size:n.size,mtimeMs:n.mtimeMs,isBinary:n.isBinary}}return null},[i,b]);Z.useEffect(()=>{if(!b||!i.statFile||Ce.length===0)return;let e=!1,t=Ce.filter(e=>e!==Le||Lr(e)&&!e.toLowerCase().endsWith(`.svg`)||zr(e));return Promise.all(t.map(async t=>{try{let n=await i.statFile?.(t,{directory:b||void 0});!e&&n&&!n.isFile&&Oe(b,t)}catch(n){!e&&$f(n)&&Oe(b,t)}})),()=>{e=!0}},[i,Ce,Oe,b,Le]);let ui=Z.useMemo(()=>lt.length>ep?`${lt.slice(0,ep)}\n\n… truncated …`:lt,[lt]),di=Rt!==ui,pi=Z.useCallback(async()=>{if(Ft||ht||_t||St!==W?.path)return!1;if(!W||!i.writeFile)return Y.error(r(`filesView.toast.savingNotSupported`)),!1;if(!di)return!0;if(Rt===``&&lt!==``&&St!==W.path)return console.warn(`[saveDraft] refusing to save empty draft for "${W.path}" (${lt.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;Vt(!0);try{let e=ip(Rt,Ht);return(await i.writeFile(W.path,e))?.success?(ut(Rt),W?.path&&Br(W.path)&&(qt.current=Rt,Xt.current=Rt),li(W.path).then(e=>{e&&($t.current=e)}).catch(()=>{}),!0):(Y.error(r(`filesView.toast.writeFileFailed`)),!1)}catch(e){return Y.error(e instanceof Error?e.message:r(`filesView.toast.saveFailed`)),!1}finally{Vt(!1)}},[Rt,lt,i,di,Ht,St,li,W,r,Ft,ht,_t]);Z.useEffect(()=>{if(!di){fr(null);return}let e=(e,t)=>mn.current?(mn.current=!1,!0):(un(!0),fn.current=t??e,!1);return fr(e),()=>{K.getState().mainTabGuard===e&&fr(null)}},[di,fr]),Z.useEffect(()=>{try{window.localStorage.setItem(tp,sn?`true`:`false`)}catch{}},[sn]),Z.useEffect(()=>{sn||(rn(`idle`),Gt.current&&=(clearTimeout(Gt.current),null))},[sn]);let mi=1500;Z.useEffect(()=>{let e=!!(W&&i.writeFile);if(!(!sn||!di||!e||Bt))return Gt.current=setTimeout(()=>{pi().then(e=>{e&&(rn(`saved`),setTimeout(()=>rn(`idle`),2e3))})},mi),()=>{Gt.current&&=(clearTimeout(Gt.current),null)}},[sn,Rt,di,W,i.writeFile,Bt,pi]),Z.useEffect(()=>{rn(`idle`)},[W?.path]),Z.useEffect(()=>{let e=e=>{!ur(e)||e.metaKey&&e.ctrlKey||(e.key.toLowerCase()===`s`?(e.preventDefault(),Gt.current&&=(clearTimeout(Gt.current),null),Bt||pi().then(e=>{e&&(rn(`saved`),setTimeout(()=>rn(`idle`),2e3))})):e.key.toLowerCase()===`f`&&(e.preventDefault(),z(!0)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Bt,pi]);let hi=G(e=>{K.setState(t=>{let n=Vf(t.pendingFileFocusPath??``)===e,r=Vf(t.pendingFileNavigation?.path??``)===e;return!n&&!r?t:{...n?{pendingFileFocusPath:null,pendingFileViewerMode:null}:{},...r?{pendingFileNavigation:null}:{}}})}),gi=G(async t=>{let n=u(),i=en.current+1;en.current=i;let s=()=>{if(!b)return!1;let e=Bo.getState().byRoot[Se],r=Fe??e?.selectedPath??e?.openPaths[0]??null;return en.current===i&&r===t.path&&n===u()},c=Lr(t.path),l=t.path.toLowerCase().endsWith(`.svg`),d=zr(t.path),p=St===t.path&&!c&&!d;if(vt(null),Lt(null),p||(bt(``),Ct(null),Pt(null)),f&&N(!0),(a.isDesktop||o)&&c&&!l){ut(``),zt(``),gt(!0);return}if(!a.isDesktop&&!o&&c&&!l){ut(``),zt(``),Ct(t.path),gt(!1);return}if(d){ut(``),zt(``),Ct(t.path),gt(!1);return}gt(!0);let m=ns(t.path),h={allowOutsideWorkspace:e===`editor-only`&&!!b&&!Wf(t.path,b),outsideFileGrant:m};tn.current=t.path,await li(t.path,h).then(async e=>{if(s()){if(!e)throw Error(r(`filesView.error.readFileFailed`));if($t.current=e,e.isBinary){Pt(t.path),ut(``),zt(``),Ct(t.path),hi(t.path);return}return ci(t.path,h)}}).then(e=>{if(!s()||e===void 0)return;let n=rp(e);p&&Vr(t.path)&&n!==lt&&Mt(e=>e+1),Pt(null),Ut(np(e)),ut(n),qt.current=n,Xt.current=n,zt(n.length>ep?`${n.slice(0,ep)}\n\n… truncated …`:n),Ct(t.path)}).catch(n=>{if(!s())return;if(p&&!$f(n)&&!Qf(n)){Y.error(n instanceof Error?n.message:r(`filesView.error.readFileFailed`));return}hi(t.path),tn.current=null,gt(!1),Lt(t.path),ut(``),zt(``),$t.current=null;let i=n instanceof Error?n.message:r(`filesView.error.readFileFailed`);if(vt(i),e===`editor-only`){b&&Qf(n)?De(b,t.path):b&&$f(n)&&Oe(b,t.path);return}if(Qf(n)){if(b&&De(b,t.path),vt(null),E.trim().length>0&&k(``),f&&N(!1),b){let e=[...Gf(t.path,b),t.path];e.length>0&&Me(b,e);for(let t of e)$e.current.has(t)||Gr(t)}return}if($f(n)){b&&Oe(b,t.path),vt(null),f&&N(!1);return}}).finally(()=>{s()&&(tn.current=null,gt(!1))})}),_i=Z.useCallback(async(e,t)=>{if(!b)return;let n=Gf(e,b),r=t?[...n,e]:n;r.length>0&&Me(b,r);let i=r.map(e=>{if(!$e.current.has(e))return Gr(e)}).filter(Boolean);await Promise.all(i)},[Me,Gr,b]),yi=Z.useCallback((e,t)=>{let n=t.findIndex(t=>t.path===e);return n===-1||t.length<=1?null:t[n+1]??t[n-1]??null},[]),Si=Z.useCallback(async e=>{if(mn.current)mn.current=!1;else if(di){un(!0),dn.current=e;return}b&&(Ae(b,e.path),Ee(b,e.path),_i(e.path,!1)),vt(null),bt(``),ut(``),qt.current=``,Xt.current=``,zt(``),Ct(null),Lt(null),f&&N(!0)},[Ee,_i,di,f,b,Ae]);Z.useEffect(()=>{W?.path&&_i(W.path,!1)},[_i,W?.path]),Z.useEffect(()=>{if(!W){en.current+=1,gt(!1);return}St!==W.path&&It!==W.path&&tn.current!==W.path&&gi(W)},[i,e,b,a.isDesktop,f,gi,St,It,W]),Z.useEffect(()=>()=>{en.current+=1,tn.current=null},[b,Le]);let wi=Z.useRef(di);wi.current=di,Z.useEffect(()=>{let e=W?.path??``;if(!up(t,e,St))return;let n=!1,r=window.setInterval(()=>{document.hidden||li(e,Ue).then(t=>{if(n||!t)return;let r=$t.current;if(!r||r.path!==e){$t.current=t;return}let i=t.mtimeMs!==void 0&&r.mtimeMs!==void 0&&t.mtimeMs!==r.mtimeMs,a=t.size!==r.size;!i&&!a&&t.isBinary===r.isBinary||wi.current||tn.current===e||($t.current=t,W&&gi(W))}).catch(()=>{})},2e3);return()=>{n=!0,window.clearInterval(r)}},[t,St,li,W,Ue,gi]);let Ti=Z.useCallback(()=>{let e=dn.current,t=fn.current,n=pn.current;if(dn.current=null,fn.current=null,pn.current=null,mn.current=!0,un(!1),zt(ui),n){b&&De(b,n),W?.path===n&&(e?Si(e):(b&&Ae(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)));return}if(e){Si(e);return}t&&(fr(null),typeof t==`function`?(mn.current=!1,t()):K.getState().setActiveMainTab(t))},[ui,Si,f,De,b,W?.path,fr,Ae]),Ei=Z.useCallback(async()=>{let e=dn.current,t=fn.current,n=pn.current;if(!await pi()){mn.current=!1;return}if(dn.current=null,fn.current=null,pn.current=null,mn.current=!0,un(!1),n){b&&De(b,n),W?.path===n&&(e?await Si(e):(b&&Ae(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)));return}if(e){await Si(e);return}t&&(fr(null),typeof t==`function`?(mn.current=!1,t()):K.getState().setActiveMainTab(t))},[Si,f,De,b,pi,W?.path,fr,Ae]),Di=G(()=>{if(Bt)return;let e=dn.current;e&&hi(e.path),dn.current=null,fn.current=null,pn.current=null,mn.current=!1,un(!1)}),Oi=G(()=>{!W||ht||(Lt(null),vt(null),Ct(null),gt(!0))}),ki=Z.useCallback(e=>{let t=W?.path===e,n=yi(e,Pe);if(t&&di){un(!0),dn.current=n,pn.current=e;return}if(b&&De(b,e),t){if(n){Si(n);return}b&&Ae(b,null),ut(``),vt(null),bt(``),Ct(null),f&&N(!1)}},[yi,Si,di,f,Pe,De,b,W?.path,Ae]),Ai=Z.useCallback(e=>{if(Ce.includes(e))return`open`;if(T?.files){let t=e.startsWith(b+`/`)?e.slice(b.length+1):e,n=T.files.find(e=>e.path===t);if(n){if(n.index===`A`||n.working_dir===`?`)return`git-added`;if(n.index===`D`)return`git-deleted`;if(n.index===`M`||n.working_dir===`M`)return`git-modified`}}return null},[Ce,T,b]),ji=Z.useCallback(e=>{if(!T?.files)return null;let t=e.startsWith(b+`/`)?e.slice(b.length+1):e,n=t?`${t}/`:``,r=0,i=0;for(let e of T.files)e.path.startsWith(n)&&((e.index===`M`||e.working_dir===`M`)&&r++,(e.index===`A`||e.working_dir===`?`)&&i++);return r+i>0?{modified:r,added:i}:null},[T,b]),Pi=Z.useCallback(async e=>{let t=Vf(e);b&&(je(b,t),$e.current.has(t)||await Gr(t))},[Gr,b,je]),Ri=Z.useMemo(()=>b?Nf(b,Ye):[],[Ye,b]),zi=Z.useMemo(()=>new Set(Te.map(e=>Vf(e))),[Te]),Ui=Pf(Te),Wi=Z.useCallback(()=>{if(b){if(Ui){tt.current=!1,ke(b,b);return}tt.current=!0,Me(b,Ri)}},[Ui,Ri,Me,ke,b]);Z.useEffect(()=>{if(!b||!tt.current)return;let e=Ff(Ri,Te);if(e.length>0){Me(b,e);return}let t=new Set([...$e.current,...Object.keys(Ze)]);If(Ri,Te,t)&&(tt.current=!1)},[Ri,Me,Te,Ze,b]);let qi=Z.useMemo(()=>({canRename:Yn,canCreateFile:qn,canCreateFolder:Jn,canDelete:Xn,canReveal:Zn}),[Yn,qn,Jn,Xn,Zn]);function Ji(e,t){let n=Ye[e]??[];return n.map((e,a)=>{let o=e.type===`directory`,s=o&&zi.has(Vf(e.path)),c=W?.path===e.path,l=a===n.length-1;return(0,$.jsxs)(`li`,{className:`relative`,children:[t>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`absolute top-3.5 left-[-12px] w-3 h-px bg-border/40`}),l&&(0,$.jsx)(`span`,{className:`absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background`})]}),(0,$.jsx)(cp,{node:e,root:b,isExpanded:s,isActive:c,isMobile:f,alwaysShowActions:h,status:o?void 0:Ai(e.path),badge:o?ji(e.path):void 0,permissions:qi,downloadFile:i.downloadFile,contextMenuPath:Nn,setContextMenuPath:Pn,rightClickMenuPath:Fn,setRightClickMenuPath:In,onSelect:Si,onToggle:Pi,onRevealPath:nr,onOpenDialog:ir}),o&&s&&(0,$.jsxs)(`ul`,{className:`flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative`,children:[Ze[e.path]?(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--status-error)]`,title:Ze[e.path],children:Ze[e.path]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`h-6 gap-1`,onClick:()=>void ti(e.path),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`}),r(`filesView.tree.actions.refreshTitle`)]})]}):null,Ji(e.path,t+1)]})]},e.path)})}let Yi=!!(W?.path&&Lr(W.path)),Xi=!!(W?.path&&W.path.toLowerCase().endsWith(`.svg`)),Qi=!!(W?.path&&zr(W.path)),$i=Z.useMemo(()=>Vf(mr?.path??``),[mr?.path]),ea=!!(mr&&$i&&Le&&Le===$i&&!ht&&!_t&&!Yi&&!Qi&&!Ft),ta=Z.useMemo(()=>Kf(b,Le),[Le,b]),na=Z.useCallback(e=>{let t=!e.state.selection.main.empty;if(Hn(e=>e===t?e:t),!t){Wn(null);return}let n=e.state.selection.main,r=e.state.doc.lineAt(n.from).from,i=e.coordsAtPos(r);i&&Wn({x:Math.min(window.innerWidth-240,Math.max(8,i.left)),y:Math.max(8,i.top-8)})},[]),ra=Z.useCallback(()=>{let e=_n.current,t=e?.state.selection.main;if(!e||!t||t.empty||!W)return;let n=e.state.sliceDoc(t.from,t.to),r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(Math.max(t.from,t.to-1)).number,a=r===i?`${r}`:`${r}-${i}`,o=`${W.name}:${a}`;Gn(W.path,o,n),Kn(dt(o),`append-inline`),Wn(null),K.getState().setActiveMainTab(`chat`)},[Gn,W,Kn]),ia=Z.useCallback(e=>{if(!W)return;let t=Math.min(e.start,e.end),n=Math.max(e.start,e.end),r=Rt.split(`
13
+ `).slice(t-1,n).join(`
14
+ `);if(!r)return;let i=t===n?`${t}`:`${t}-${n}`,a=`${W.name}:${i}`;Gn(W.path,a,r),Kn(dt(a),`append-inline`),K.getState().setActiveMainTab(`chat`)},[Gn,Rt,W,Kn]),aa=!!(W&&!Ft&&(!Yi||Xi)&&!Qi&&lt.length>0),sa=!!(W&&ta.length>0),ca=!!(W&&!Ft&&!ht&&!_t&&St===Le&&!Ve&&!Yi&&!Qi&&i.writeFile&&lt.length<=ep),la=!!(!Ft&&W?.path&&sp(W.path)),ua=!!(!Ft&&W?.path&&Vr(W.path)),da=!!(!Ft&&W?.path&&Br(W.path)),fa=!!(W&&!Ft&&!Yi&&!Qi),ba=fa&&!la&&!da&&!(ua&&le===`preview`),xa=la&&U===`edit`||ua&&le===`edit`||!la&&!ua&&H===`edit`,Ca=Z.useMemo(()=>Le?cu(Le):null,[Le]),[Ta,Ea]=Z.useState(null);Z.useEffect(()=>{let e=!1,t=W?.path;if(!t||Ca){Ea(null);return}return Ea(null),hu(t).then(t=>{e||Ea(t)}),()=>{e=!0}},[W?.path,Ca]),Z.useEffect(()=>{!ca&&H===`edit`&&se(`view`)},[ca,H]);let Da=`yuri:files:md-viewer-mode`,Oa=`yuri:files:html-viewer-mode`;Z.useEffect(()=>{let e=W?.path;if(!e)return;se(he.current[e]??`edit`);let t=xr?`preview`:`edit`;try{let e=localStorage.getItem(Da);(e===`preview`||e===`edit`)&&(t=e)}catch{}ce(ge.current[e]??t);let n=xr?`preview`:`edit`;try{let e=localStorage.getItem(Oa);(e===`preview`||e===`edit`)&&(n=e)}catch{}vr&&Vr(e)&&gr===e&&(_e.current[e]=vr,yr(null)),ue(_e.current[e]??n),fe(ve.current[e]??(xr?`preview`:`edit`))},[gr,vr,W?.path,yr,xr]);let ka=Z.useCallback(e=>{let t=W?.path;t&&(he.current[t]=e),se(e)},[W?.path]),ja=Z.useCallback(e=>{let t=W?.path;t&&(ge.current[t]=e),ce(e);try{localStorage.setItem(Da,e)}catch{}},[W?.path]),Ma=Z.useCallback(()=>U,[U]),Na=Z.useCallback(e=>{let t=W?.path;t&&(_e.current[t]=e),ue(e);try{localStorage.setItem(Oa,e)}catch{}},[W?.path]),Pa=Z.useCallback(e=>{let t=W?.path;if(t&&(ve.current[t]=e),Kt.current&&=(clearTimeout(Kt.current),null),Zt.current!==null&&(cancelAnimationFrame(Zt.current),Zt.current=null),e===`edit`)zt(qt.current||lt),fe(e);else{qt.current=Rt;let e=t;fe(`edit`),Zt.current=requestAnimationFrame(()=>{Zt.current=requestAnimationFrame(()=>{Zt.current=null,!(b&&e&&Bo.getState().byRoot[Se]?.selectedPath!==e)&&(me(e=>e+1),fe(`preview`))})});return}},[Rt,lt,b,W?.path,Se]),Fa=Z.useCallback(async(e,t)=>{if(!i.writeFile||t===Xt.current)return!1;if(!(await i.writeFile(e,t))?.success)return Y.error(r(`filesView.toast.writeFileFailed`)),!1;qt.current=t,Xt.current=t,zt(t);let n=await li(e,Ue).catch(()=>null);return n&&($t.current=n),!0},[i,li,Ue,r]);Z.useEffect(()=>()=>{Kt.current&&=(clearTimeout(Kt.current),null),Zt.current!==null&&(cancelAnimationFrame(Zt.current),Zt.current=null)},[de,W?.path]);let Ia=Z.useCallback(e=>{if(qt.current=e,!W?.path||de!==`preview`||!i.writeFile)return;Kt.current&&clearTimeout(Kt.current);let t=W.path;Kt.current=setTimeout(()=>{Kt.current=null,Fa(t,e).then(e=>{e&&(on(!0),setTimeout(()=>on(!1),1500))}).catch(e=>{Y.error(e instanceof Error?e.message:r(`filesView.toast.saveFailed`))})},mi)},[de,i.writeFile,Fa,W?.path,r]),La=Z.useMemo(()=>da&&(qt.current||Rt)||lt,[Rt,lt,da]),Ra=Z.useCallback(()=>le,[le]);Z.useEffect(()=>{let e=e=>{let t=e?`preview`:`edit`;for(let e of Ce)he.current[e]=`edit`,sp(e)&&(ge.current[e]=t),Vr(e)&&(_e.current[e]=t),Br(e)&&(ve.current[e]=t);se(`edit`),ce(t),ue(t),fe(t);try{localStorage.setItem(Da,t),localStorage.setItem(Oa,t)}catch{}},t=t=>{let n=!!t.detail?.enabled;e(n)};return window.addEventListener(`yuri:file-viewer-preview-mode-changed`,t),()=>{window.removeEventListener(`yuri:file-viewer-preview-mode-changed`,t)}},[Ce]),Z.useEffect(()=>{if(!mr||!b)return;let e=()=>{typeof window>`u`||xn.current===null&&(xn.current=window.requestAnimationFrame(()=>{xn.current=null,bn(e=>e+1)}))},t=(e,t)=>{if(e.state.doc.length!==t.length)return!1;if(t.length===0)return!0;let n=Math.min(128,t.length);if(e.state.sliceDoc(0,n)!==t.slice(0,n))return!1;let r=Math.max(0,t.length-n);return e.state.sliceDoc(r,t.length)===t.slice(r)},n=Vf(mr.path);if(It===n){hi(n),Sn.current={key:``,attempts:0};return}if(!n){hr(null),Sn.current={key:``,attempts:0};return}let r=`${n}:${mr.line}:${mr.column??1}`;if(Sn.current.key!==r&&(Sn.current={key:r,attempts:0}),W?.path!==n){if(ln||Fe)return;Si(Ne(n));return}if(ht||St!==n)return;if(_t||Yi||Qi){hr(null),Sn.current={key:``,attempts:0};return}if(!ca)return;if(H!==`edit`){se(`edit`);return}let i=_n.current;if(!i){e();return}if(!t(i,Rt)){e();return}let a=Math.max(1,Math.min(mr.line,i.state.doc.lines)),o=i.state.doc.line(a),s=Math.max(1,mr.column||1),c=Math.max(0,o.to-o.from),l=Math.min(c,s-1),u=o.from+l;if(i.state.selection.main.head!==u||Sn.current.attempts===0){Sn.current.attempts+=1,i.dispatch({selection:{anchor:u},effects:Jt.scrollIntoView(u,{y:`center`})}),i.focus(),e();return}typeof window<`u`&&window.requestAnimationFrame(()=>{let e=_n.current;e&&(e.dispatch({selection:{anchor:u},effects:Jt.scrollIntoView(u,{y:`center`})}),e.focus())}),hr(null),Sn.current={key:``,attempts:0}},[Fe,ca,hi,ln,Rt,yn,_t,It,ht,Yi,Qi,St,Si,mr,b,W?.path,hr,H,Ne]),Z.useEffect(()=>{if(!gr||!b)return;let e=Vf(gr);if(It===e){hi(e);return}if(!e){_r(null);return}if(W?.path!==e){if(ln||Fe)return;Si(Ne(e));return}if(!(ht||St!==e||_t||Yi||Qi)){if(ca&&H===`edit`){let e=_n.current;if(!e)return;e.focus()}_r(null)}},[Fe,ca,hi,ln,_t,It,ht,Si,Yi,Qi,St,gr,b,W?.path,_r,H,Ne]);let za=Z.useCallback(e=>{if(!f||!e||!e.hasFocus||typeof window>`u`)return;let t=window.visualViewport;if(!t)return;let n=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,n-(t.offsetTop+t.height))<=0)return;let r=e.state.selection.main.head,i=e.coordsAtPos(r);if(!i)return;let a=Math.round(t.offsetTop+t.height),o=i.bottom+20-a;o<=0||(e.scrollDOM.scrollTop+=o)},[f]);Z.useEffect(()=>{if(!f||typeof window>`u`)return;let e=()=>{window.requestAnimationFrame(()=>{za(_n.current)})},t=window.visualViewport;return t?.addEventListener(`resize`,e),t?.addEventListener(`scroll`,e,{passive:!0}),document.addEventListener(`selectionchange`,e),()=>{t?.removeEventListener(`resize`,e),t?.removeEventListener(`scroll`,e),document.removeEventListener(`selectionchange`,e)}},[f,za]),Z.useEffect(()=>{if(H!==`edit`||f)return;let e=e=>{let t=e.target;if(t?.closest(`[role="dialog"]`))return;let n=!!t?.closest(`.cm-editor`);if(!(t?.closest(`input, textarea, [contenteditable="true"], [role="textbox"]`)&&!n||!document.activeElement?.closest(`.cm-editor`))&&wa(e,`mod+l`)){let t=_n.current?.state.selection.main;t&&!t.empty&&(e.preventDefault(),ra())}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[ra,f,H]);let Ba=K(e=>e.editorFontSize),Va=Z.useMemo(()=>{if(!W?.path)return[su(s,{fontSize:Ba})];let e=Ir(W.path),t=[su(s,e?{syntaxColors:!1,fontSize:Ba}:{fontSize:Ba})],n=Ca??Ta;return n&&t.push(n),e&&t.push(yu({language:e,themeName:s.metadata.id,theme:Bi(s)})),P&&t.push(Jt.lineWrapping),t.push(Jt.updateListener.of(e=>{(e.selectionSet||e.docChanged)&&na(e.view)})),f&&t.push(Jt.updateListener.of(e=>{e.view.hasFocus&&(e.selectionSet||e.focusChanged||e.viewportChanged||e.geometryChanged)&&window.requestAnimationFrame(()=>{za(e.view)})})),t},[s,W?.path,Ca,Ta,P,f,za,Ba,na]),Ha=Z.useMemo(()=>({light:ye.metadata.id,dark:be.metadata.id}),[ye.metadata.id,be.metadata.id]),Ua=W?.path&&Yi&&!a.isDesktop&&!o&&!Xi?`${W.path}|${Ue.allowOutsideWorkspace?`outside`:`workspace`}|${Ue.outsideFileGrant??``}`:``,Wa=W?.path&&Qi&&!o?`${W.path}|${Ue.allowOutsideWorkspace?`outside`:`workspace`}|${Ue.outsideFileGrant??``}`:``,Ga=r(`filesView.error.readFileFailed`),{readyKey:Ka,nonce:qa}=dp(Ua,vt,Ga),{readyKey:Ja,nonce:Ya}=dp(Wa,vt,Ga),Xa=!!(Ua&&Ka!==Ua),[Za,Qa]=Z.useState(),$a=o&&W?.path&&Qi?JSON.stringify([o.queryScope,W.path]):``;Z.useEffect(()=>{if(!o||!$a||!W?.path)return;let e=new AbortController,t;return Et({path:W.path,scope:o,signal:e.signal,...Ue,directory:b||void 0}).then(n=>{e.signal.aborted||(t=URL.createObjectURL(n),Qa({key:$a,url:t}))}).catch(t=>{e.signal.aborted||vt(t instanceof Error?t.message:Ga)}),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[o,$a,W?.path,Ue,b,Ga]);let eo=!!($a?Za?.key!==$a:Wa&&Ja!==Wa),to=W?.path&&Yi?a.isDesktop||o?Xi?`data:${Rr(W.path)};utf8,${encodeURIComponent(lt)}`:yt:Xi?`data:${Rr(W.path)};utf8,${encodeURIComponent(lt)}`:Ka===Ua?Ot(`/api/fs/raw`,{path:W.path,allowOutsideWorkspace:Ue.allowOutsideWorkspace?`true`:void 0,outsideFileGrant:Ue.outsideFileGrant,directory:b||void 0},o).url:``:``,no=G(e=>{if(!W?.path||!Yi)return;let t=Xi?to:W.path||to;if(!t)return;let n=W.name||W.path;re({open:!0,title:n,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:n,mime:Rr(W.path)},image:{url:t,mimeType:Rr(W.path),filename:n}})}),ro=Z.useCallback(e=>{re(t=>t.open===e?t:{...t,open:e})},[]),io=Z.useCallback((e,t)=>{let n=e.name||r(`filesView.editor.imageAltFallback`);return(0,$.jsx)(`div`,{className:J(`flex items-center justify-center`,t?.fullHeight?`h-full p-4`:`h-full p-3`),children:(0,$.jsx)(`button`,{type:`button`,className:`max-h-full max-w-full cursor-zoom-in rounded-md border-0 bg-transparent p-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,onClick:no,"aria-label":n,disabled:!to,children:(0,$.jsx)(_a,{src:to,alt:n,className:J(`object-contain rounded-md border border-border/30 bg-primary/10`,t?.fullHeight?`max-h-full max-w-full`:`max-h-[70vh] max-w-full`),draggable:!1},qa)})})},[qa,to,no,r]),ao=$a?Za?.key===$a?Za.url:``:W?.path&&Qi&&Ja===Wa?Ot(`/api/fs/raw`,{path:W.path,allowOutsideWorkspace:Ue.allowOutsideWorkspace?`true`:void 0,outsideFileGrant:Ue.outsideFileGrant,directory:b||void 0},o).url:``,oo=Z.useCallback(e=>(0,$.jsx)(`div`,{className:`h-full overflow-hidden bg-[var(--surface-background)]`,children:(0,$.jsx)(`iframe`,{src:ao,className:`h-full w-full border-0`,title:e.name},Ya)}),[ao,Ya]);Z.useEffect(()=>{let e=!1,t,n=async()=>{if(!a.isDesktop&&!o||!W?.path||!Yi||Xi){xt.current&&=(URL.revokeObjectURL(xt.current),``),bt(``);return}vt(null),xt.current&&=(URL.revokeObjectURL(xt.current),``),await(async()=>{if(o){let n=await At(W.path,i.signal,`preview`,o);return e?(n.release(),``):(t=n.release,n.url)}let n=await kt({path:W.path,...Ue,directory:b||void 0,signal:i.signal,scope:o});if(!n.ok)throw Error(r(`filesView.error.readFileFailed`));let a=await n.blob(),s=URL.createObjectURL(a);return e?(URL.revokeObjectURL(s),``):(xt.current=s,s)})().then(t=>{e||(bt(t),Ct(W.path))}).catch(t=>{xt.current&&=(URL.revokeObjectURL(xt.current),``),e||(bt(``),vt(t instanceof Error?t.message:r(`filesView.error.readFileFailed`)),Ct(null))}).finally(()=>{e||gt(!1)})},i=new AbortController;return n(),()=>{e=!0,i.abort(),t?.()}},[i,Yi,Xi,b,a.isDesktop,W?.path,Ue,r,o]),Z.useEffect(()=>()=>{xt.current&&=(URL.revokeObjectURL(xt.current),``)},[]);let so=Z.useCallback(()=>wn(null),[]),co=Z.useMemo(()=>Ni({drafts:wr,editingDraftId:Dr,commentText:Tr,onTextChange:Er,selection:ar,isDragging:lr,fileLabel:W?.path??``,newWidgetId:`files-new-comment-input`,mapDraftToRange:e=>({start:e.startLine,end:e.endLine}),onSave:Hr,onCancel:()=>{or(null),Ar()},onEdit:e=>{Mr(e),or({start:e.startLine,end:e.endLine})},onDelete:Pr,onAddToChat:ia}),[ia,Ar,Tr,Pr,Dr,wr,Hr,lr,ar,W?.path,Er,Mr]),lo=Z.useCallback((e,t)=>(0,$.jsx)(`div`,{className:`h-full`,children:(0,$.jsx)(Yt,{file:{name:e.name,contents:t,lang:Ir(e.path)||void 0},options:{disableFileHeader:!0,overflow:P?`wrap`:`scroll`,theme:Ha,themeType:s.metadata.variant===`dark`?`dark`:`light`},className:`block h-full w-full`,style:{height:`100%`}})}),[s.metadata.variant,Ha,P]),uo=({exitFullscreenOnly:t=!1,previewToggle:n}={})=>{if(!W)return null;let s=(e,t)=>(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:t})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:e})]});return(0,$.jsxs)(`div`,{className:`pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm`,children:[ca&&xa&&(0,$.jsxs)($.Fragment,{children:[Bt?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-1 text-muted-foreground typography-meta`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}),r(`filesView.editor.saving`)]}):sn&&nn===`saved`&&!di?(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta`,children:[(0,$.jsx)(X,{name:`check`,className:`size-3.5`}),r(`filesView.editor.saved`)]}):di?s(r(sn?`filesView.editor.saveNowTitle`:`filesView.editor.saveNowManualTitle`,{shortcut:`${Mn()}+S`}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>void pi(),className:`h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,title:r(sn?`filesView.editor.saveNowTitle`:`filesView.editor.saveNowManualTitle`,{shortcut:`${Mn()}+S`}),"aria-label":r(`filesView.editor.saveAria`,{shortcut:`${Mn()}+S`}),children:(0,$.jsx)(X,{name:`save-3`,className:`size-4`})})):null,s(r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>cn(e=>!e),className:J(`size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,sn?`text-foreground opacity-100`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),"aria-label":r(sn?`filesView.editor.autoSaveOn`:`filesView.editor.manualSave`),"aria-pressed":sn,children:(0,$.jsx)(X,{name:`file-check`,className:`size-4`})}))]}),fa&&Vn?s(`${r(`chat.textSelection.title.addToCurrentChat`)} (${Sa(`mod+l`)})`,(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:ra,className:`h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,title:`${r(`chat.textSelection.title.addToCurrentChat`)} (${Sa(`mod+l`)})`,"aria-label":`${r(`chat.textSelection.title.addToCurrentChat`)} (${Sa(`mod+l`)})`,children:[(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{children:r(`chat.textSelection.actions.addToChat`)}),(0,$.jsx)(Li,{shortcut:Sa(`mod+l`)})]})):null,!o&&a.isDesktop&&w()&&(0,$.jsxs)(Ci,{onOpenChange:oe,children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.openInDesktopApp`),"aria-label":r(`filesView.editor.openInDesktopApp`),children:(0,$.jsx)(X,{name:`file-transfer`,className:`size-4`})})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(`filesView.editor.openInDesktopApp`)})]}),(0,$.jsxs)(bi,{align:`end`,className:`w-56 max-h-[70vh] overflow-y-auto`,children:[Qn.map(e=>(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void rr(e),children:[(0,$.jsx)(zf,{label:e.label,iconDataUrl:e.iconDataUrl}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.label})]},e.id)),$n?(0,$.jsxs)(xi,{className:`flex items-center gap-2`,onClick:()=>void tr(!0),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-4`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`filesView.editor.refreshApps`)})]}):null]})]}),fa&&(0,$.jsxs)($.Fragment,{children:[s(r(P?`filesView.editor.disableLineWrap`:`filesView.editor.enableLineWrap`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>F(!P),className:J(`size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,P?`text-foreground opacity-100`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(P?`filesView.editor.disableLineWrap`:`filesView.editor.enableLineWrap`),children:(0,$.jsx)(X,{name:`text-wrap`,className:`size-4`})})),H===`edit`&&(0,$.jsx)($.Fragment,{children:s(r(`filesView.editor.findInFile`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:e=>{z(!R),e.currentTarget.blur()},className:`size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.findInFile`),children:(0,$.jsx)(X,{name:`search`,className:`size-4`})}))})]}),n,!n&&ba&&ca&&!ua&&(0,$.jsx)(fu,{currentMode:H===`view`?`preview`:`edit`,onToggle:()=>{ka(H===`view`?`edit`:`view`)}}),la&&s(r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ja(Ma()===`preview`?`edit`:`preview`),className:J(`size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]`,Ma()===`preview`?`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]`:`text-muted-foreground opacity-65 hover:opacity-100`),title:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),"aria-label":r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),children:(0,$.jsx)(X,{name:Ma()===`preview`?`eye`:`eye-off`,className:`size-4`})})),Vr(W?.path??``)&&(0,$.jsx)(fu,{currentMode:Ra(),onToggle:()=>{Na(Ra()===`preview`?`edit`:`preview`)}}),la&&Ma()===`preview`&&Sr&&(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent`,"aria-label":r(ft?`filesView.tts.stopSpeaking`:`filesView.tts.readAloud`),onClick:()=>{ft?mt():lt.trim()&&pt(lt)},children:ft?(0,$.jsx)(X,{name:`stop`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`volume-up`,className:`size-4`})})}),(0,$.jsx)(ei,{sideOffset:8,children:r(ft?`filesView.tts.stopSpeaking`:`filesView.tts.readAloud`)})]}),da&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(fu,{currentMode:de,onToggle:()=>Pa(de===`preview`?`edit`:`preview`)}),de===`preview`&&(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{let e=Qt.current?.getXml();if(Kt.current&&=(clearTimeout(Kt.current),null),W?.path&&e){if(!await Fa(W.path,e))return;on(!0),setTimeout(()=>on(!1),1500)}},className:`size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.diagram.saveDiagram`),children:an?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`save-3`,className:`size-4`})})]}),aa&&s(r(`filesView.editor.copyFileContents`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{(await pr(lt)).ok?(Rn(!0),hn.current!==null&&window.clearTimeout(hn.current),hn.current=window.setTimeout(()=>{Rn(!1)},1200)):Y.error(r(`filesView.toast.copyFailed`))},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.copyFileContents`),"aria-label":r(`filesView.editor.copyFileContents`),children:Ln?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`clipboard`,className:`size-4`})})),sa&&s(r(`filesView.editor.copyFilePathTitle`,{path:ta}),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:async()=>{(await pr(ta)).ok?(Bn(!0),gn.current!==null&&window.clearTimeout(gn.current),gn.current=window.setTimeout(()=>{Bn(!1)},1200)):Y.error(r(`filesView.toast.copyFailed`))},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.copyFilePathTitle`,{path:ta}),"aria-label":r(`filesView.editor.copyFilePathTitle`,{path:ta}),children:zn?(0,$.jsx)(X,{name:`check`,className:`size-4 text-[color:var(--status-success)]`}):(0,$.jsx)(X,{name:`file-copy-2`,className:`size-4`})})),i.downloadFile&&s(r(`filesView.editor.saveFile`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>{let e=i.downloadFile;e&&e(W.path).catch(e=>{console.error(`Download failed:`,e),Y.error(r(`sidebarFilesTree.toast.operationFailed`))})},className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.saveFile`),"aria-label":r(`filesView.editor.saveFile`),children:(0,$.jsx)(X,{name:`download`,className:`size-4`})})),t?s(r(`filesView.editor.exitFullscreen`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>L(!1),className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(`filesView.editor.exitFullscreen`),"aria-label":r(`filesView.editor.exitFullscreen`),children:(0,$.jsx)(X,{name:`fullscreen-exit`,className:`size-4`})})):!f&&e===`full`&&s(r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>L(!I),className:`size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent`,title:r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),"aria-label":r(I?`filesView.editor.exitFullscreen`:`filesView.editor.fullscreen`),children:I?(0,$.jsx)(X,{name:`fullscreen-exit`,className:`size-4`}):(0,$.jsx)(X,{name:`fullscreen`,className:`size-4`})}))]})},fo=(0,$.jsx)(pa,{path:W?.path??``,base:b||void 0,active:!!(W&&t&&(!f||M)),children:({preview:e,controls:t})=>(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,children:[(0,$.jsx)(Qr,{open:ln,onOpenChange:e=>{e||Di()},children:(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-md`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:r(`filesView.unsaved.title`)}),(0,$.jsx)(Zr,{children:r(`filesView.unsaved.description`)})]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:Di,disabled:Bt,children:r(`filesView.dialog.cancel`)}),(0,$.jsx)(q,{variant:`outline`,onClick:()=>void Ei(),disabled:Bt,className:`border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]`,children:r(`filesView.unsaved.saveChanges`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:Ti,disabled:Bt,children:r(`filesView.unsaved.discard`)})]})]})}),(0,$.jsx)(`div`,{className:J(`flex flex-col flex-shrink-0`,x&&`border-b border-border/40`),children:x?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center px-3 py-1.5`,children:[f&&M&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>N(!1),"aria-label":r(`filesView.editor.back`),className:`inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(X,{name:`arrow-left-s`,className:`size-5`})}),f?W?(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:`inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium`,"aria-label":r(`filesView.editor.openFilesAria`),children:[(0,$.jsx)(ri,{filePath:W.path,extension:W.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(Yf,{name:W.name}),(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 flex-shrink-0 text-muted-foreground`})]})}),(0,$.jsx)(bi,{align:`start`,className:`w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]`,children:Pe.map(e=>{let t=W?.path===e.path;return(0,$.jsxs)(xi,{onSelect:n=>{if(n.target.closest(`[data-close-open-file]`)){n.preventDefault();return}t||Si(e)},className:J(`flex min-w-0 items-center justify-between gap-2 overflow-hidden`,t&&`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:[(0,$.jsx)(ri,{filePath:e.path,extension:e.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(Yf,{name:e.name})]}),(0,$.jsx)(`button`,{type:`button`,"data-close-open-file":!0,onPointerDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:t=>{t.preventDefault(),t.stopPropagation(),ki(e.path)},className:`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]`,"aria-label":r(`filesView.editor.closeFileAria`,{name:e.name}),children:(0,$.jsx)(X,{name:`close`,className:`size-3.5`})})]},e.path)})})]}):(0,$.jsx)(`div`,{className:`typography-ui-label font-medium truncate`,children:r(`filesView.editor.selectFile`)}):Pe.length>0?(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[Ge.left&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent`}),Ge.right&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent`}),(0,$.jsx)(`div`,{ref:We,className:`flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none`,style:{scrollbarWidth:`none`,msOverflowStyle:`none`},children:Pe.map(e=>{let t=W?.path===e.path;return(0,$.jsxs)(`div`,{title:Kf(b,e.path),className:J(`group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap`,t?`bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]`:`bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]`),children:[(0,$.jsx)(ri,{filePath:e.path,extension:e.extension,className:`size-3.5 flex-shrink-0`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{t||Si(e)},className:`max-w-[12rem] truncate text-left`,children:e.name}),(0,$.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),ki(e.path)},className:J(`rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]`,!t&&!h&&`opacity-0 group-hover:opacity-100`),"aria-label":r(`filesView.editor.closeFileAria`,{name:e.name}),children:(0,$.jsx)(X,{name:`close`,className:`size-3.5`})})]},e.path)})})]}):(0,$.jsx)(`div`,{className:`typography-ui-label font-medium truncate`,children:r(`filesView.editor.selectFile`)})]}):null}),(0,$.jsxs)(`div`,{className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:[e?(0,$.jsx)(`div`,{className:`absolute right-6 top-3 z-30 flex items-center gap-1`,"data-gui-preview-controls":!0,children:t}):null,W&&!e&&!R&&(0,$.jsx)(`div`,{ref:ie,className:`absolute right-3 top-3 z-30`,onMouseLeave:()=>{ae.current>0||B(!1)},children:ee?uo({previewToggle:t}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t,la?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ja(Ma()===`preview`?`edit`:`preview`),className:J(`size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors`,Ma()===`preview`?`bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]`:`text-muted-foreground hover:text-foreground`),"aria-label":r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),title:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`),children:(0,$.jsx)(X,{name:Ma()===`preview`?`eye`:`eye-off`,className:`size-4`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(Ma()===`preview`?`filesView.editor.switchToEditMode`:`filesView.editor.switchToPreviewMode`)})]}):null,(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,onMouseEnter:()=>B(!0),children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>B(!0),className:`size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground`,"aria-label":r(`filesView.editor.showControlsAria`),title:r(`filesView.editor.controlsTitle`),children:(0,$.jsx)(X,{name:`more-2-fill`,className:`size-4`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(`filesView.editor.controlsTitle`)})]})]})}),e??(0,$.jsx)(Wr,{outerClassName:`h-full min-w-0`,className:`h-full min-w-0`,children:W?wt||Xa||eo?Yi?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-3`,children:(0,$.jsx)(ga,{className:`size-48 max-w-full rounded-md`})}):S?(0,$.jsx)(`div`,{className:`p-3`}):(0,$.jsxs)(`div`,{className:`p-3 flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.loading`)]}):_t?(0,$.jsx)(oa,{message:_t,onRetry:It===Le?Oi:void 0}):Ft?(0,$.jsx)(ha,{path:Le},Le):Yi&&W?io(W):Qi?oo(W):W&&da&&de===`preview`?(0,$.jsx)(`div`,{className:`h-full overflow-hidden`,style:{minHeight:`400px`},children:(0,$.jsx)(Xl,{ref:Qt,xml:La,onChange:Ia},`${W.path}:${pe}`)}):W&&la&&Ma()===`preview`?(0,$.jsxs)(`div`,{className:`h-full overflow-auto p-3`,children:[lt.length>512e3&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning`,children:r(`filesView.warning.largeFilePreviewLimited`,{sizeKb:Math.round(lt.length/1024)})}),(0,$.jsx)(No,{fallback:(0,$.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium text-destructive`,children:r(`filesView.error.previewUnavailable`)}),(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`filesView.error.switchToEditMode`)})]}),children:(0,$.jsx)(ya,{content:lt,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})]}):W&&ua&&le===`preview`?(0,$.jsx)(ma,{path:W.path,directory:o?.location.directory??b??``,entry:o,revision:Tt}):W&&ba&&H===`view`?lo(W,Rt):(0,$.jsxs)(`div`,{className:J(`relative h-full`,ea&&`overflow-hidden`),ref:vn,children:[(0,$.jsx)(`div`,{className:J(`h-full`,ea&&`invisible`),children:(0,$.jsx)(pu,{value:Rt,onChange:zt,readOnly:!ca,vimMode:br===`vim`,extensions:Va,className:`h-full`,blockWidgets:co,onViewReady:e=>{_n.current=e,na(e),bn(e=>e+1),window.requestAnimationFrame(()=>{za(e)})},onViewDestroy:()=>{_n.current&&=null,Hn(!1),Wn(null),bn(e=>e+1)},enableSearch:!0,searchOpen:R,onSearchOpenChange:z,highlightLines:ar?{start:Math.min(ar.start,ar.end),end:Math.max(ar.start,ar.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(e,t,n)=>{if(!(n instanceof MouseEvent)||n.button!==0)return!1;n.preventDefault();let r=e.state.doc.lineAt(t.from).number;if(ar&&!n.shiftKey&&Math.min(ar.start,ar.end)===r&&Math.max(ar.start,ar.end)===r)return or(null),Ar(),sr.current=!1,cr.current=null,dr(!1),!0;if(f&&ar&&!n.shiftKey){let e=Math.min(ar.start,ar.end,r),t=Math.max(ar.start,ar.end,r);return or({start:e,end:t}),sr.current=!1,cr.current=null,dr(!1),!0}if(sr.current=!0,cr.current=r,dr(!0),ar&&n.shiftKey){let e=Math.min(ar.start,r),t=Math.max(ar.end,r);or({start:e,end:t})}else or({start:r,end:r});return!0},mouseover:(e,t,n)=>{if(!(n instanceof MouseEvent)||n.buttons!==1||!sr.current||cr.current===null)return!1;let r=e.state.doc.lineAt(t.from).number,i=Math.min(cr.current,r),a=Math.max(cr.current,r);return or({start:i,end:a}),dr(!0),!1},mouseup:()=>(sr.current=!1,cr.current=null,dr(!1),!1)}}})}),ea&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-background`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.openingFileAtChange`)]})})]}):(0,$.jsx)(`div`,{className:`p-3 typography-ui text-muted-foreground`,children:r(`filesView.editor.pickFileFromTree`)})})]})]})}),po=!!(b&&Ye[b]),mo=b?Ze[b]:null,ho=(0,$.jsxs)(`section`,{className:J(`flex min-h-0 flex-col overflow-hidden`,f?`h-full w-full bg-background`:`h-full rounded-xl border border-border/60 bg-background/70`),children:[(0,$.jsx)(`div`,{className:J(`flex flex-col gap-2 py-2`,f?`px-3`:`px-2`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground`}),(0,$.jsx)(va,{ref:j,value:E,onChange:e=>k(e.target.value),placeholder:r(`filesView.tree.search.placeholder`),className:`h-8 pl-8 pr-8 typography-meta`}),E.trim().length>0&&(0,$.jsx)(`button`,{type:`button`,"aria-label":r(`filesView.tree.search.clearAria`),className:`absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground`,onClick:()=>{k(``),j.current?.focus()},children:(0,$.jsx)(X,{name:`close`,className:`size-4`})})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ir(`createFile`,{path:y,type:`directory`}),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.newFileTitle`),"aria-label":r(`filesView.tree.actions.newFileTitle`),children:(0,$.jsx)(X,{name:`file-add`,className:`size-4`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.newFileTitle`)})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>ir(`createFolder`,{path:y,type:`directory`}),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.newFolderTitle`),"aria-label":r(`filesView.tree.actions.newFolderTitle`),children:(0,$.jsx)(X,{name:`folder-add`,className:`size-4`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.newFolderTitle`)})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:()=>void Kr(),className:`size-8 p-0 flex-shrink-0`,title:r(`filesView.tree.actions.refreshTitle`),"aria-label":r(`filesView.tree.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:`size-4`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(`filesView.tree.actions.refreshTitle`)})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:Wi,disabled:Ri.length===0&&Te.length===0,className:`size-8 flex-shrink-0 p-0`,title:r(Ui?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`),"aria-label":r(Ui?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`),children:(0,$.jsx)(X,{name:Ui?`contract-up-down`:`expand-up-down`,className:`size-4`})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:r(Ui?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`)})]})]})}),(0,$.jsx)(Wr,{outerClassName:`flex-1 min-h-0`,className:J(`py-2`,f?`px-3`:`px-2`),children:(0,$.jsx)(`ul`,{className:`flex flex-col`,children:st?(0,$.jsxs)(`li`,{className:`flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.tree.search.searching`)]}):at.length>0?at.map(e=>{let t=W?.path===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void Si(e),className:J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors`,t?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`),children:[op(e.path,e.extension),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-meta`,style:{direction:`rtl`,textAlign:`left`},title:e.path,children:e.relativePath??e.path})]})},e.path)}):mo?(0,$.jsxs)(`li`,{className:`flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:mo}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`w-fit gap-1.5`,onClick:()=>void Kr(),children:[(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`}),r(`filesView.tree.actions.refreshTitle`)]})]}):po?Ji(b,0):(0,$.jsx)(`li`,{className:`px-2 py-1 typography-meta text-muted-foreground`,children:r(`filesView.state.loading`)})})})]}),go=e===`full`&&I&&W&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-50 flex flex-col bg-background`,children:(0,$.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 relative`,children:[(0,$.jsx)(`div`,{className:`absolute right-4 top-4 z-30`,children:uo({exitFullscreenOnly:!0})}),(0,$.jsx)(Wr,{outerClassName:`h-full min-w-0`,className:`h-full min-w-0`,children:wt||Xa||eo?Yi?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,$.jsx)(ga,{className:`size-48 max-w-full rounded-md`})}):S?(0,$.jsx)(`div`,{className:`p-4`}):(0,$.jsxs)(`div`,{className:`p-4 flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),`Loading…`]}):_t?(0,$.jsx)(oa,{message:_t,onRetry:It===Le?Oi:void 0}):Ft?(0,$.jsx)(ha,{path:Le},Le):Yi?io(W,{fullHeight:!0}):Qi?oo(W):la&&Ma()===`preview`?(0,$.jsxs)(`div`,{className:`h-full overflow-auto p-4`,children:[lt.length>512e3&&(0,$.jsx)(`div`,{className:`mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning`,children:r(`filesView.warning.largeFilePreviewLimited`,{sizeKb:Math.round(lt.length/1024)})}),(0,$.jsx)(No,{fallback:(0,$.jsxs)(`div`,{className:`rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 font-medium text-destructive`,children:r(`filesView.error.previewUnavailable`)}),(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r(`filesView.error.switchToEditMode`)})]}),children:(0,$.jsx)(ya,{content:lt,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})]}):ba&&H===`view`?lo(W,Rt):(0,$.jsxs)(`div`,{className:J(`relative h-full`,ea&&`overflow-hidden`),children:[(0,$.jsx)(`div`,{className:J(`h-full`,ea&&`invisible`),children:(0,$.jsx)(pu,{value:Rt,onChange:zt,readOnly:!ca,vimMode:br===`vim`,extensions:Va,className:`h-full`,onViewReady:e=>{_n.current=e,na(e),window.requestAnimationFrame(()=>{za(e)})},onViewDestroy:()=>{_n.current&&=null,Hn(!1),Wn(null)}})}),ea&&(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center bg-background`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 typography-ui text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),r(`filesView.state.openingFileAtChange`)]})})]})})]})});return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden bg-background relative`,children:[(0,$.jsx)(lp,{activeDialog:Cn,dialogData:Tn,dialogInputValue:Dn,onDialogInputChange:On,isDialogSubmitting:kn,onDialogSubmit:si,onClose:so,inputRef:Wt}),go,Un?(0,$.jsx)(Ii,{position:Un,onDismiss:()=>Wn(null),onAddToChat:ra}):null,ne.open?(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Lf,{popup:ne,onOpenChange:ro,isMobile:f})}):null,f?M?fo:ho:e===`editor-only`?(0,$.jsx)(`div`,{className:`flex flex-1 min-h-0 min-w-0 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden bg-background`,children:fo})}):(0,$.jsxs)(`div`,{className:`flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2`,children:[m>=700&&(0,$.jsx)(`div`,{className:`w-72 flex-shrink-0 min-h-0 overflow-hidden`,children:ho}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background`,children:fo})]})]})};function mp(e){return e+1}var hp=e=>e,gp=e=>{let t=hp(e).type;return typeof t==`string`?t:``},_p=e=>{let t=hp(e).tool;return typeof t==`string`?t:``},vp=e=>{let t=hp(e).text;return typeof t==`string`?t:``},yp=e=>{let t=gp(e);return t===`tool`?_p(e).trim().toLowerCase()||`tool`:t||`unknown`},bp=e=>{if(e.length===0)return``;let t=[];for(let n of e){let e=yp(n);t.includes(e)||t.push(e)}return t.join(` + `)},xp=e=>e.replace(/\s+/g,` `).trim(),Sp=e=>{for(let t of e)if(gp(t)===`text`){let e=xp(vp(t));if(e.length===0)continue;return e}let t=e.filter(e=>gp(e)!==`text`).length;return t===0?``:`${t} attachment${t===1?``:`s`}`},Cp=(e,t,n)=>`${n(e)} / ${n(t)}`,wp=(e,t,n,r)=>{let i=Cp(e,t,n);return typeof r==`string`&&r.trim().length>0?`${i} · ${r.trim()}`:i},Tp=e=>{if(e===`12h`)return!0;if(e===`24h`)return!1},Ep=(e,t)=>{if(!e||!Number.isFinite(e))return`-`;let n=Tp(t);return new Date(e).toLocaleString(void 0,{month:`numeric`,day:`numeric`,hour:n===!1?`2-digit`:`numeric`,minute:`2-digit`,...n===void 0?{}:{hour12:n}})},Dp={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},Op={user:0,assistant:0,tool:0,other:0},kp=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?0:e,Ap=e=>{let t=e.info.tokens,n=t===void 0?e.parts.find(e=>e.tokens!==void 0)?.tokens:t;if(typeof n==`number`)return{...Dp,total:kp(n)};if(!n||typeof n!=`object`)return Dp;let r=n,i=kp(r.input),a=kp(r.output),o=kp(r.reasoning),s=kp(r.cache?.read),c=kp(r.cache?.write);return{input:i,output:a,reasoning:o,cacheRead:s,cacheWrite:c,total:i+a+o+s+c}},jp=(...e)=>{for(let t of e)if(typeof t==`string`&&t.trim().length>0)return t;return``},Mp=e=>typeof e==`string`?e.length:typeof e==`number`||typeof e==`boolean`?String(e).length:Array.isArray(e)?e.reduce((e,t)=>e+Mp(t),0):e&&typeof e==`object`?Object.values(e).reduce((e,t)=>e+Mp(t),0):0,Np=(e,t)=>{let n=e,r=typeof n.type==`string`?n.type:``;if(r===`reasoning`)return{...Op,assistant:Mp(n.text)+Mp(n.content)};let i=jp(n.text,n.content,n.value,n.source?.value,n.source?.text?.value);return r===`tool`||t===`tool`?{user:0,assistant:0,tool:Mp(n.input)+Mp(n.output)+Mp(n.error)+Mp(n.call?.input)+Mp(n.call?.output)+Mp(n.call?.error)+Mp(n.raw)+Math.round(Mp(n.metadata)*.25)+Math.round(Mp(n.state)*.1),other:0}:t===`user`?{user:i.length,assistant:0,tool:0,other:0}:t===`assistant`?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Pp=(e,t)=>({user:e.user+t.user,assistant:e.assistant+t.assistant,tool:e.tool+t.tool,other:e.other+t.other}),Fp=e=>{let t=Jo(e.info);return t.isUser?`user`:t.role===`assistant`?`assistant`:t.role===`tool`?`tool`:`other`},Ip=(e,t)=>{if(e.length===0)return{...Op};let n=e.reduce((e,t)=>{let n=Fp(t),r={...Op};for(let e of t.parts)r=Pp(r,Np(e,n));return Pp(e,r)},{...Op});return n.user+=t.length,{user:Math.ceil(n.user/4),assistant:Math.ceil(n.assistant/4),tool:Math.ceil(n.tool/4),other:Math.ceil(n.other/4)}},Lp=e=>e.toLocaleString(jr()),Rp=e=>!Number.isFinite(e)||e<=0?new Intl.NumberFormat(jr(),{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat(jr(),{style:`currency`,currency:`USD`,minimumFractionDigits:e<.01?4:2,maximumFractionDigits:e<.01?4:2}).format(e),zp=(e,t)=>!e||!Number.isFinite(e)?`-`:Ws(e,t,{month:`short`,day:`numeric`,year:`numeric`,hour:`numeric`,minute:`2-digit`}),Bp=(e,t,n)=>{let r=e.find(e=>e.id===t),i=r?.models?.find(e=>e.id===n);return{providerName:r?.name||t||`-`,modelName:i?.name||n||`-`,contextLimit:typeof i?.limit?.context==`number`?i.limit.context:null}},Vp=e=>{let t=(0,Q.c)(3),{active:n}=e,r=n===void 0||n,i=bt(),a;return t[0]!==r||t[1]!==i?(a=i?.entry.location.hostId?(0,$.jsx)(Up,{active:r},i.entry.key):(0,$.jsx)(Hp,{}),t[0]=r,t[1]=i,t[2]=a):a=t[2],a},Hp=()=>{let e=(0,Q.c)(5),t=Vn(Gp),n=In(),r=$n(t??``),i=An(Kp),a;return e[0]!==t||e[1]!==i||e[2]!==r||e[3]!==n?(a=(0,$.jsx)(Wp,{currentSessionId:t,sessions:n,sessionMessages:r,providers:i}),e[0]=t,e[1]=i,e[2]=r,e[3]=n,e[4]=a):a=e[4],a},Up=e=>{let t=(0,Q.c)(58),{active:n}=e,r=bt(),{t:i}=Nr(),a=r.entry,o=Tn(qp),s;t[0]!==a.key||t[1]!==o?(s=o&&te(o.location)===a.key?o.sessionId:null,t[0]=a.key,t[1]=o,t[2]=s):s=t[2];let c=s,l=Z.useSyncExternalStore($e,Qe,Qe),d;t[3]===a.location?d=t[4]:(d=Ze(a.location),t[3]=a.location,t[4]=d);let f=d,p;t[5]!==c||t[6]!==a.location||t[7]!==f?(p=f&&c?it(a.location,c):null,t[5]=c,t[6]=a.location,t[7]=f,t[8]=p):p=t[8];let m;t[9]!==l||t[10]!==p?(m={revision:l,scope:p},t[9]=l,t[10]=p,t[11]=m):m=t[11];let h=m.scope,g;t[12]!==n||t[13]!==f||t[14]!==h?(g=e=>n&&f&&h?f.subscribe(h,e):Jp,t[12]=n,t[13]=f,t[14]=h,t[15]=g):g=t[15];let _=g,v;t[16]!==n||t[17]!==f||t[18]!==h?(v=()=>n&&f&&h?f.getTranscript(h):null,t[16]=n,t[17]=f,t[18]=h,t[19]=v):v=t[19];let y=v,b=Z.useSyncExternalStore(_,y,y),[x,S]=Z.useState(null),C;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>S(e instanceof Error?e.message:String(e)),t[20]=C):C=t[20];let w=G(C),T;t[21]!==c||t[22]!==a||t[23]!==f||t[24]!==h?(T=async()=>{f&&h&&c&&(a.sdk(),await st(a.location,c,{background:!0}),a.sdk()),S(null)},t[21]=c,t[22]=a,t[23]=f,t[24]=h,t[25]=T):T=t[25];let E=G(T);Ct(n?c:null,E,w);let D=Or(r.registry,a.location.hostId,n&&!!c),O;t[26]===a?O=t[27]:(O=gn(a.location.directory,u(),a),t[26]=a,t[27]=O);let k=n&&!!c,A;t[28]!==k||t[29]!==O?(A={...O,enabled:k},t[28]=k,t[29]=O,t[30]=A):A=t[30];let j=yt(A,Dt),M;t[31]===j.data?.providers?M=t[32]:(M=j.data?.providers.map(Yp)??[],t[31]=j.data?.providers,t[32]=M);let N=M,P;t[33]!==a.key||t[34]!==a.location||t[35]!==D.data?.directories?(P=D.data?.directories.find(e=>te({...a.location,directory:e.directory})===a.key)?.sessions??[],t[33]=a.key,t[34]=a.location,t[35]=D.data?.directories,t[36]=P):P=t[36];let F=P,I;t[37]===b?I=t[38]:(I=b?.messageOrder.flatMap(e=>b.messagesByID[e]?[{info:b.messagesByID[e],parts:Array.from(b.partsByMessageID[e]??[])}]:[])??[],t[37]=b,t[38]=I);let L=I,R=x??j.error?.message??D.error?.message,z;t[39]!==j||t[40]!==E||t[41]!==w||t[42]!==D?(z=async()=>{await Promise.all([E(),j.refetch(),D.refetch()]).catch(w)},t[39]=j,t[40]=E,t[41]=w,t[42]=D,t[43]=z):z=t[43],Ro(r.registry,a.location.hostId,n?R:null,z);let ee;t[44]!==c||t[45]!==R||t[46]!==i||t[47]!==b?(ee=c&&!b&&!R?(0,$.jsx)(`div`,{role:`status`,className:`px-4 py-2 typography-meta text-muted-foreground`,children:i(`common.loading`)}):null,t[44]=c,t[45]=R,t[46]=i,t[47]=b,t[48]=ee):ee=t[48];let B;t[49]!==c||t[50]!==N||t[51]!==L||t[52]!==F?(B=(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(Wp,{currentSessionId:c,sessions:F,sessionMessages:L,providers:N})}),t[49]=c,t[50]=N,t[51]=L,t[52]=F,t[53]=B):B=t[53];let ne;return t[54]!==a.key||t[55]!==ee||t[56]!==B?(ne=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,"data-remote-context-location":a.key,children:[ee,B]}),t[54]=a.key,t[55]=ee,t[56]=B,t[57]=ne):ne=t[57],ne},Wp=e=>{let t=(0,Q.c)(262),{currentSessionId:n,sessions:r,sessionMessages:i,providers:a}=e,{t:o}=Nr(),s=K(Xp),c=K(Zp),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={},t[0]=l):l=t[0];let[u,d]=Z.useState(l),[f,p]=Z.useState(null),m=Z.useRef(null),h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null),d(Qp),p(null)},t[1]=h):h=t[1];let g;t[2]===n?g=t[3]:(g=[n],t[2]=n,t[3]=g),Z.useEffect(h,g);let _,v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>()=>{m.current!==null&&(window.clearTimeout(m.current),m.current=null)},v=[],t[4]=_,t[5]=v):(_=t[4],v=t[5]),Z.useEffect(_,v);let y;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(y=async(e,t)=>{(await pr(t)).ok?(p(e),m.current!==null&&window.clearTimeout(m.current),m.current=window.setTimeout(()=>{p(t=>t===e?null:t),m.current=null},2e3)):p(null)},t[6]=y):y=t[6];let b=y,x;t[7]!==n||t[8]!==r?(x=n?r.find(e=>e.id===n)??null:null,t[7]=n,t[8]=r,t[9]=x):x=t[9];let S=x,C,w,T,E,D,O,k,A,j;if(t[10]!==a||t[11]!==i||t[12]!==c){C=i.filter($p);let e;t[22]===i?e=t[23]:(e=i.filter(em),t[22]=i,t[23]=e),j=e;let n=c?Wo(i):null,r=null;for(let e=C.length-1;e>=0;--e){let t=C[e];if(Ap(t).total>0){r=t;break}}k=r?Ap(r):Dp,T=ts({input:k.input,cache:{read:k.cacheRead,write:k.cacheWrite}}),A=C.reduce(tm,0),w=new Map;let o=[];for(let e of n?.turns??[]){let t=e.assistantMessages.map(nm),n=Go(t);for(let t=0;t<n.length;t+=1){let r=n[t],i=e.assistantMessageIds[t];r!==null&&i&&w.set(i,Ko(r))}let r=n[n.length-1]??null;e.completionDisposition!==`active`&&r!==null&&o.push(...t)}let s=es(o);D=s===null?null:Ko(s);let l=r?n?.indexes.messageToTurnId.get(r.info.id):void 0,u=l?n?.indexes.turnById.get(l):void 0,d=u?.assistantMessageIds[u.assistantMessageIds.length-1];E=d?w.get(d)??null:null;let f=r?.info??null;O=Bp(a,f?.providerID||``,f?.modelID||``),t[10]=a,t[11]=i,t[12]=c,t[13]=C,t[14]=w,t[15]=T,t[16]=E,t[17]=D,t[18]=O,t[19]=k,t[20]=A,t[21]=j}else C=t[13],w=t[14],T=t[15],E=t[16],D=t[17],O=t[18],k=t[19],A=t[20],j=t[21];let M=O,N=M.contextLimit,P=N&&N>0?Math.min(999,k.total/N*100):0,F;t[24]===i?F=t[25]:(F=Ip(i,[...i].reverse().find(rm)?.info?.system||``),t[24]=i,t[25]=F);let I=F,L=I.user,R=I.assistant,z=I.tool,ee=Math.max(0,k.input-L-R-z),B=L+R+z+ee,te=i[0]?.info?.time?.created,ne=i.length>0?i[i.length-1]?.info?.time?.created:null,re;t[26]!==S?.title||t[27]!==o?(re=S?.title||o(`contextSidebar.session.untitled`),t[26]=S?.title,t[27]=o,t[28]=re):re=t[28];let ie=S?.time?.created??te??null,ae=ne??S?.time?.created??null,oe=D&&D.length>0?D:null,V=E&&E.length>0?E:null,H;t[29]!==R||t[30]!==ee||t[31]!==z||t[32]!==L?(H={user:L,assistant:R,tool:z,other:ee},t[29]=R,t[30]=ee,t[31]=z,t[32]=L,t[33]=H):H=t[33];let se;t[34]!==C.length||t[35]!==w||t[36]!==B||t[37]!==T||t[38]!==N||t[39]!==M||t[40]!==i.length||t[41]!==re||t[42]!==ie||t[43]!==ae||t[44]!==oe||t[45]!==V||t[46]!==H||t[47]!==k||t[48]!==A||t[49]!==P||t[50]!==j.length?(se={sessionTitle:re,messagesCount:i.length,userMessagesCount:j.length,assistantMessagesCount:C.length,createdAt:ie,lastActivityAt:ae,providerModel:M,tokenBreakdown:k,usagePercent:P,cacheHitRate:T,totalAssistantCost:A,assistantTpsByMessageID:w,sessionTpsLabel:oe,lastAssistantTpsLabel:V,contextLimit:N,breakdown:H,breakdownTotal:B},t[34]=C.length,t[35]=w,t[36]=B,t[37]=T,t[38]=N,t[39]=M,t[40]=i.length,t[41]=re,t[42]=ie,t[43]=ae,t[44]=oe,t[45]=V,t[46]=H,t[47]=k,t[48]=A,t[49]=P,t[50]=j.length,t[51]=se):se=t[51];let U=se;if(!n){let e;t[52]===o?e=t[53]:(e=o(`contextSidebar.empty.openSession`),t[52]=o,t[53]=e);let n;return t[54]===e?n=t[55]:(n=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground`,children:e}),t[54]=e,t[55]=n),n}let ce;t[56]===o?ce=t[57]:(ce=o(`contextSidebar.breakdown.user`),t[56]=o,t[57]=ce);let le;t[58]!==ce||t[59]!==U.breakdown.user?(le={key:`user`,label:ce,value:U.breakdown.user,color:`var(--status-success)`},t[58]=ce,t[59]=U.breakdown.user,t[60]=le):le=t[60];let ue;t[61]===o?ue=t[62]:(ue=o(`contextSidebar.breakdown.assistant`),t[61]=o,t[62]=ue);let de;t[63]!==ue||t[64]!==U.breakdown.assistant?(de={key:`assistant`,label:ue,value:U.breakdown.assistant,color:`var(--primary-base)`},t[63]=ue,t[64]=U.breakdown.assistant,t[65]=de):de=t[65];let fe;t[66]===o?fe=t[67]:(fe=o(`contextSidebar.breakdown.toolCalls`),t[66]=o,t[67]=fe);let pe;t[68]!==fe||t[69]!==U.breakdown.tool?(pe={key:`tool`,label:fe,value:U.breakdown.tool,color:`var(--status-warning)`},t[68]=fe,t[69]=U.breakdown.tool,t[70]=pe):pe=t[70];let me;t[71]===o?me=t[72]:(me=o(`contextSidebar.breakdown.other`),t[71]=o,t[72]=me);let he;t[73]!==me||t[74]!==U.breakdown.other?(he={key:`other`,label:me,value:U.breakdown.other,color:`var(--surface-muted-foreground)`},t[73]=me,t[74]=U.breakdown.other,t[75]=he):he=t[75];let ge;t[76]!==le||t[77]!==de||t[78]!==pe||t[79]!==he?(ge=[le,de,pe,he],t[76]=le,t[77]=de,t[78]=pe,t[79]=he,t[80]=ge):ge=t[80];let _e=ge,ve;t[81]===U.sessionTitle?ve=t[82]:(ve=(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:U.sessionTitle}),t[81]=U.sessionTitle,t[82]=ve);let ye;t[83]!==U.providerModel.modelName||t[84]!==U.providerModel.providerName?(ye=(0,$.jsxs)(`span`,{children:[U.providerModel.providerName,` / `,U.providerModel.modelName]}),t[83]=U.providerModel.modelName,t[84]=U.providerModel.providerName,t[85]=ye):ye=t[85];let be;t[86]!==s||t[87]!==U.createdAt?(be=U.createdAt&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{children:`·`}),(0,$.jsx)(`span`,{children:zp(U.createdAt,s)})]}),t[86]=s,t[87]=U.createdAt,t[88]=be):be=t[88];let xe;t[89]!==ye||t[90]!==be?(xe=(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70`,children:[ye,be]}),t[89]=ye,t[90]=be,t[91]=xe):xe=t[91];let Se;t[92]!==ve||t[93]!==xe?(Se=(0,$.jsxs)(`div`,{className:`mb-6`,children:[ve,xe]}),t[92]=ve,t[93]=xe,t[94]=Se):Se=t[94];let Ce;t[95]===o?Ce=t[96]:(Ce=o(`contextSidebar.section.context`),t[95]=o,t[96]=Ce);let we;t[97]===Ce?we=t[98]:(we=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:Ce}),t[97]=Ce,t[98]=we);let Te;t[99]===U.tokenBreakdown.total?Te=t[100]:(Te=Lp(U.tokenBreakdown.total),t[99]=U.tokenBreakdown.total,t[100]=Te);let Ee;t[101]===U.contextLimit?Ee=t[102]:(Ee=U.contextLimit?` / ${Lp(U.contextLimit)}`:``,t[101]=U.contextLimit,t[102]=Ee);let De;t[103]!==Te||t[104]!==Ee?(De=(0,$.jsxs)(`span`,{className:`typography-micro tabular-nums text-muted-foreground/70`,children:[Te,Ee]}),t[103]=Te,t[104]=Ee,t[105]=De):De=t[105];let Oe;t[106]!==we||t[107]!==De?(Oe=(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[we,De]}),t[106]=we,t[107]=De,t[108]=Oe):Oe=t[108];let ke;t[109]===U.usagePercent?ke=t[110]:(ke=U.usagePercent>0&&(0,$.jsx)(`div`,{className:`rounded-full transition-all duration-300`,style:{width:`${Math.max(.5,U.usagePercent)}%`,backgroundColor:U.usagePercent>80?`var(--status-warning)`:`var(--primary-base)`}}),t[109]=U.usagePercent,t[110]=ke);let Ae;t[111]===ke?Ae=t[112]:(Ae=(0,$.jsx)(`div`,{className:`mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:ke}),t[111]=ke,t[112]=Ae);let je;t[113]!==o||t[114]!==U.usagePercent?(je=o(`contextSidebar.context.percentUsed`,{percent:U.usagePercent.toFixed(1)}),t[113]=o,t[114]=U.usagePercent,t[115]=je):je=t[115];let Me;t[116]===je?Me=t[117]:(Me=(0,$.jsx)(`div`,{className:`mt-1.5 typography-micro font-medium tabular-nums text-foreground/80`,children:je}),t[116]=je,t[117]=Me);let Ne;t[118]!==Oe||t[119]!==Ae||t[120]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5`,children:[Oe,Ae,Me]}),t[118]=Oe,t[119]=Ae,t[120]=Me,t[121]=Ne):Ne=t[121];let Pe;t[122]===o?Pe=t[123]:(Pe=o(`contextSidebar.stats.messages`),t[122]=o,t[123]=Pe);let Fe;t[124]===U.messagesCount?Fe=t[125]:(Fe=Lp(U.messagesCount),t[124]=U.messagesCount,t[125]=Fe);let Ie;t[126]!==Pe||t[127]!==Fe?(Ie={label:Pe,value:Fe},t[126]=Pe,t[127]=Fe,t[128]=Ie):Ie=t[128];let W;t[129]===o?W=t[130]:(W=o(`contextSidebar.stats.user`),t[129]=o,t[130]=W);let Le;t[131]===U.userMessagesCount?Le=t[132]:(Le=Lp(U.userMessagesCount),t[131]=U.userMessagesCount,t[132]=Le);let Re;t[133]!==W||t[134]!==Le?(Re={label:W,value:Le},t[133]=W,t[134]=Le,t[135]=Re):Re=t[135];let ze;t[136]===o?ze=t[137]:(ze=o(`contextSidebar.stats.assistant`),t[136]=o,t[137]=ze);let Be;t[138]===U.assistantMessagesCount?Be=t[139]:(Be=Lp(U.assistantMessagesCount),t[138]=U.assistantMessagesCount,t[139]=Be);let Ve;t[140]!==ze||t[141]!==Be?(Ve={label:ze,value:Be},t[140]=ze,t[141]=Be,t[142]=Ve):Ve=t[142];let He;t[143]!==Ie||t[144]!==Re||t[145]!==Ve?(He=[Ie,Re,Ve],t[143]=Ie,t[144]=Re,t[145]=Ve,t[146]=He):He=t[146];let Ue=He,We;t[147]===Ue?We=t[148]:(We=(0,$.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:Ue.map(im)}),t[147]=Ue,t[148]=We);let Ge=c?`grid-cols-2`:`grid-cols-1`,Ke;t[149]===Ge?Ke=t[150]:(Ke=J(`grid gap-2`,Ge),t[149]=Ge,t[150]=Ke);let qe;t[151]===o?qe=t[152]:(qe=o(`contextSidebar.stats.cost`),t[151]=o,t[152]=qe);let Je;t[153]===qe?Je=t[154]:(Je=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:qe}),t[153]=qe,t[154]=Je);let Ye;t[155]===U.totalAssistantCost?Ye=t[156]:(Ye=Rp(U.totalAssistantCost),t[155]=U.totalAssistantCost,t[156]=Ye);let Xe;t[157]===Ye?Xe=t[158]:(Xe=(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:Ye}),t[157]=Ye,t[158]=Xe);let Ze;t[159]!==Je||t[160]!==Xe?(Ze=(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[Je,Xe]}),t[159]=Je,t[160]=Xe,t[161]=Ze):Ze=t[161];let Qe;t[162]!==c||t[163]!==o||t[164]!==U.sessionTpsLabel?(Qe=c?(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:o(`contextSidebar.stats.sessionTps`)}),(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:U.sessionTpsLabel??`—`})]}):null,t[162]=c,t[163]=o,t[164]=U.sessionTpsLabel,t[165]=Qe):Qe=t[165];let $e;t[166]!==Ke||t[167]!==Ze||t[168]!==Qe?($e=(0,$.jsxs)(`div`,{className:Ke,children:[Ze,Qe]}),t[166]=Ke,t[167]=Ze,t[168]=Qe,t[169]=$e):$e=t[169];let et;t[170]!==We||t[171]!==$e?(et=(0,$.jsxs)(`div`,{className:`mb-5 space-y-2`,children:[We,$e]}),t[170]=We,t[171]=$e,t[172]=et):et=t[172];let tt;t[173]===o?tt=t[174]:(tt=o(`contextSidebar.section.lastAssistantMessage`),t[173]=o,t[174]=tt);let nt;t[175]===tt?nt=t[176]:(nt=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-2.5`,children:tt}),t[175]=tt,t[176]=nt);let rt;t[177]===o?rt=t[178]:(rt=o(`contextSidebar.tokens.input`),t[177]=o,t[178]=rt);let it;t[179]!==rt||t[180]!==U.tokenBreakdown.input?(it={label:rt,value:U.tokenBreakdown.input,format:`count`},t[179]=rt,t[180]=U.tokenBreakdown.input,t[181]=it):it=t[181];let at;t[182]===o?at=t[183]:(at=o(`contextSidebar.tokens.output`),t[182]=o,t[183]=at);let ot;t[184]!==at||t[185]!==U.tokenBreakdown.output?(ot={label:at,value:U.tokenBreakdown.output,format:`count`},t[184]=at,t[185]=U.tokenBreakdown.output,t[186]=ot):ot=t[186];let st;t[187]===o?st=t[188]:(st=o(`contextSidebar.tokens.reasoning`),t[187]=o,t[188]=st);let ct;t[189]!==st||t[190]!==U.tokenBreakdown.reasoning?(ct={label:st,value:U.tokenBreakdown.reasoning,format:`count`},t[189]=st,t[190]=U.tokenBreakdown.reasoning,t[191]=ct):ct=t[191];let lt;t[192]===o?lt=t[193]:(lt=o(`contextSidebar.tokens.cacheRead`),t[192]=o,t[193]=lt);let ut;t[194]!==lt||t[195]!==U.tokenBreakdown.cacheRead?(ut={label:lt,value:U.tokenBreakdown.cacheRead,format:`count`},t[194]=lt,t[195]=U.tokenBreakdown.cacheRead,t[196]=ut):ut=t[196];let dt;t[197]===o?dt=t[198]:(dt=o(`contextSidebar.tokens.cacheWrite`),t[197]=o,t[198]=dt);let ft;t[199]!==dt||t[200]!==U.tokenBreakdown.cacheWrite?(ft={label:dt,value:U.tokenBreakdown.cacheWrite,format:`count`},t[199]=dt,t[200]=U.tokenBreakdown.cacheWrite,t[201]=ft):ft=t[201];let pt;t[202]===o?pt=t[203]:(pt=o(`contextSidebar.tokens.cacheHit`),t[202]=o,t[203]=pt);let mt=U.cacheHitRate.hasInput?U.cacheHitRate.percent:null,ht;t[204]!==pt||t[205]!==mt?(ht={label:pt,value:mt,format:`percent`},t[204]=pt,t[205]=mt,t[206]=ht):ht=t[206];let gt;t[207]!==c||t[208]!==o||t[209]!==U.lastAssistantTpsLabel?(gt=c?[{label:o(`contextSidebar.tokens.tps`),value:U.lastAssistantTpsLabel,format:`text`}]:[],t[207]=c,t[208]=o,t[209]=U.lastAssistantTpsLabel,t[210]=gt):gt=t[210];let _t;t[211]!==it||t[212]!==ot||t[213]!==ct||t[214]!==ut||t[215]!==ft||t[216]!==ht||t[217]!==gt?(_t=(0,$.jsx)(`div`,{className:`grid grid-cols-3 gap-x-4 gap-y-2.5`,children:[it,ot,ct,ut,ft,ht,...gt].map(am)}),t[211]=it,t[212]=ot,t[213]=ct,t[214]=ut,t[215]=ft,t[216]=ht,t[217]=gt,t[218]=_t):_t=t[218];let vt;t[219]!==nt||t[220]!==_t?(vt=(0,$.jsxs)(`div`,{className:`mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5`,children:[nt,_t]}),t[219]=nt,t[220]=_t,t[221]=vt):vt=t[221];let yt;t[222]!==_e||t[223]!==U.breakdownTotal?(yt=(0,$.jsx)(`div`,{className:`flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:_e.map(e=>e.value<=0||U.breakdownTotal<=0?null:(0,$.jsx)(`div`,{style:{width:`${e.value/U.breakdownTotal*100}%`,backgroundColor:e.color}},e.key))}),t[222]=_e,t[223]=U.breakdownTotal,t[224]=yt):yt=t[224];let bt;t[225]!==_e||t[226]!==U.breakdownTotal?(bt=(0,$.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1`,children:_e.map(e=>{let t=U.breakdownTotal>0?e.value/U.breakdownTotal*100:0;return(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full`,style:{backgroundColor:e.color}}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground/70`,children:[e.label,` `,(0,$.jsxs)(`span`,{className:`tabular-nums`,children:[t.toFixed(0),`%`]})]})]},e.key)})}),t[225]=_e,t[226]=U.breakdownTotal,t[227]=bt):bt=t[227];let xt;t[228]!==yt||t[229]!==bt?(xt=(0,$.jsxs)(`div`,{className:`mb-6`,children:[yt,bt]}),t[228]=yt,t[229]=bt,t[230]=xt):xt=t[230];let St;t[231]===o?St=t[232]:(St=o(`contextSidebar.section.rawMessages`),t[231]=o,t[232]=St);let Ct;t[233]===St?Ct=t[234]:(Ct=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:St}),t[233]=St,t[234]=Ct);let wt;if(t[235]!==f||t[236]!==u||t[237]!==i||t[238]!==c||t[239]!==o||t[240]!==s||t[241]!==U.assistantTpsByMessageID){let e;t[243]!==f||t[244]!==u||t[245]!==c||t[246]!==o||t[247]!==s||t[248]!==U.assistantTpsByMessageID?(e=e=>{let t=Jo(e.info).role,n=t===`assistant`,r=t===`user`,i=u[e.info.id]===!0,a=f===e.info.id,l=e.info.time?.created??null,p=bp(e.parts),m=n?Ap({info:e.info,parts:e.parts}):null,h=r?Sp(e.parts):``,g=Ep(l,s),_=p||`—`,v=!c||!n?null:U.assistantTpsByMessageID.get(e.info.id)??null,y=m?wp(m.input,m.output,Lp,v):``,x=t||`unknown`,S=p?`${x}: ${p}`:x,C=i?JSON.stringify({info:e.info,parts:e.parts},null,2):``;return(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70`,children:[(0,$.jsx)(`button`,{type:`button`,className:`w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]`,"aria-expanded":i,onClick:()=>{d(t=>({...t,[e.info.id]:t[e.info.id]!==!0}))},children:(0,$.jsxs)(`div`,{className:`grid items-center gap-x-2 whitespace-nowrap typography-micro`,style:{gridTemplateColumns:n?`minmax(0, 1fr) minmax(7.5rem, max-content) max-content`:`minmax(0, 1fr) max-content`},children:[r?(0,$.jsxs)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`user:`}),` `,h]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:n?_:S}),n&&(0,$.jsx)(`span`,{className:`text-right text-muted-foreground tabular-nums`,children:y})]}),(0,$.jsx)(`span`,{className:`text-right text-muted-foreground`,children:g})]})}),i&&(0,$.jsx)(`div`,{className:`border-t border-[var(--surface-subtle)] p-0`,children:(0,$.jsxs)(`div`,{className:`group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]`,children:[(0,$.jsx)(`div`,{className:`absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100`,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground`,onClick:t=>{t.stopPropagation(),b(e.info.id,C)},"aria-label":o(a?`contextSidebar.actions.copied`:`contextSidebar.actions.copyJson`),title:o(a?`contextSidebar.actions.copied`:`contextSidebar.actions.copy`),children:a?(0,$.jsx)(X,{name:`check`,className:`size-3.5`}):(0,$.jsx)(X,{name:`file-copy`,className:`size-3.5`})})}),(0,$.jsx)(ks,{language:`json`,code:C,style:{margin:0,padding:`0.75rem`,background:`transparent`,fontSize:`var(--text-micro)`,lineHeight:`1.35`},wrap:!0})]})})]},e.info.id)},t[243]=f,t[244]=u,t[245]=c,t[246]=o,t[247]=s,t[248]=U.assistantTpsByMessageID,t[249]=e):e=t[249],wt=[...i].reverse().map(e),t[235]=f,t[236]=u,t[237]=i,t[238]=c,t[239]=o,t[240]=s,t[241]=U.assistantTpsByMessageID,t[242]=wt}else wt=t[242];let Tt;t[250]===wt?Tt=t[251]:(Tt=(0,$.jsx)(`div`,{className:`mt-2.5 space-y-1`,children:wt}),t[250]=wt,t[251]=Tt);let Et;t[252]!==Ct||t[253]!==Tt?(Et=(0,$.jsxs)(`div`,{children:[Ct,Tt]}),t[252]=Ct,t[253]=Tt,t[254]=Et):Et=t[254];let Dt;return t[255]!==Se||t[256]!==Ne||t[257]!==et||t[258]!==vt||t[259]!==xt||t[260]!==Et?(Dt=(0,$.jsx)(`div`,{className:`h-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-[52rem] px-5 py-6`,children:[Se,Ne,et,vt,xt,Et]})}),t[255]=Se,t[256]=Ne,t[257]=et,t[258]=vt,t[259]=xt,t[260]=Et,t[261]=Dt):Dt=t[261],Dt};function Gp(e){return e.currentSessionId}function Kp(e){return e.providers}function qp(e){return e.remoteSession}function Jp(){}function Yp(e){return{...e,models:Object.values(e.models)}}function Xp(e){return e.timeFormatPreference}function Zp(e){return e.showAssistantTps}function Qp(e){return Object.keys(e).length>0?{}:e}function $p(e){return Jo(e.info).role===`assistant`}function em(e){return Jo(e.info).isUser}function tm(e,t){return e+kp(t.info.cost)}function nm(e){let{info:t}=e;return{createdAt:t.time.created,streamedAt:t.time.streamed,outputTokens:t.tokens?.output,reasoningTokens:t.tokens?.reasoning}}function rm(e){return Jo(e.info).isUser&&typeof e.info.system==`string`}function im(e){return(0,$.jsxs)(`div`,{className:`rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:e.label}),(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:e.value})]},e.label)}function am(e){return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:e.label}),(0,$.jsx)(`div`,{className:`mt-0.5 typography-ui-label tabular-nums text-foreground`,children:e.format===`text`?typeof e.value==`string`&&e.value.length>0?e.value:`—`:e.value!==null&&e.value!==void 0?e.format===`percent`?`${Number(e.value).toFixed(1)}%`:Lp(Number(e.value)):`—`})]},e.label)}var om=420,sm=({isOpen:e,children:t,className:n})=>{let{t:r}=Nr(),i=K(e=>e.rightSidebarWidth),a=K(e=>e.setRightSidebarWidth),[o,s]=Z.useState(!1),c=Z.useRef(0),l=Z.useRef(i||om),u=Z.useRef(null),d=Z.useRef(null),f=Z.useRef(null),p=Z.useCallback(e=>Math.min(860,Math.max(240,e)),[]),m=Z.useCallback(e=>{let t=f.current;t&&(t.style.width=`${e}px`,t.style.minWidth=`${e}px`,t.style.maxWidth=`${e}px`,t.style.setProperty(`--yuri-right-sidebar-width`,`${e}px`))},[]),h=Math.min(860,Math.max(240,i||om)),g=e?h:0;Z.useLayoutEffect(()=>{if(o)return;let e=f.current;e&&(e.style.minWidth=``,e.style.maxWidth=``)},[e,o,h]);let _=t=>{if(!e)return;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}d.current=t.pointerId,s(!0),c.current=t.clientX;let n=f.current?.clientWidth||g;l.current=n,u.current=n,m(n),t.preventDefault()},v=e=>{if(!o||d.current!==e.pointerId)return;let t=c.current-e.clientX,n=p(l.current+t);u.current!==n&&(u.current=n,m(n))},y=e=>{if(d.current!==e.pointerId)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=p(u.current??g);d.current=null,u.current=null,s(!1),a(t)},b=o?u.current??g:g;return(0,$.jsxs)(`aside`,{ref:f,className:J(`relative flex h-full overflow-hidden yuri-layout-divider-l will-change-[width] motion-reduce:transition-none`,`bg-sidebar`,!e&&`border-l-0`,n),style:{width:`${b}px`,"--yuri-right-sidebar-width":`${o?b:h}px`,overflowX:`clip`,transitionProperty:o?`none`:`width`,transitionDuration:`200ms`,transitionTimingFunction:`cubic-bezier(0.22, 1, 0.36, 1)`},"aria-hidden":!e||g===0,children:[e&&(0,$.jsx)(`div`,{className:J(`absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors`,o&&`bg-[var(--interactive-border)]`),onPointerDown:_,onPointerMove:v,onPointerUp:y,onPointerCancel:y,role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`sidebar.resize.rightPanelAria`)}),(0,$.jsx)(`div`,{className:J(`relative z-10 flex h-full w-full min-h-0 min-w-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none`,o&&`pointer-events-none`,!e&&`pointer-events-none select-none opacity-0`),"aria-hidden":!e,children:e?t:null})]})},cm=12,lm=[{id:`left`,x:22,y:58,delay:0,radius:120,colorVar:`--status-success`},{id:`center`,x:50,y:42,delay:120,radius:150,colorVar:`--primary-base`},{id:`right`,x:78,y:55,delay:200,radius:130,colorVar:`--status-info`}],um=e=>{let t=(0,Q.c)(18),{isActive:n,burstKey:r,className:i,durationMs:a,bursts:o,onComplete:s}=e,c=r===void 0?0:r,l=a===void 0?900:a,u=o===void 0?lm:o,d=Z.useRef(!1),f,p;t[0]!==n||t[1]!==s?(f=()=>{!n&&d.current&&s?.(),n&&(d.current=!0)},p=[n,s],t[0]=n,t[1]=s,t[2]=f,t[3]=p):(f=t[2],p=t[3]),Z.useEffect(f,p);let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=Array.from({length:cm},dm),t[4]=m):m=t[4];let h=m;if(!n)return null;let g;t[5]===i?g=t[6]:(g=J(`fireworks-overlay pointer-events-none`,i),t[5]=i,t[6]=g);let _;if(t[7]!==c||t[8]!==u||t[9]!==l){let e;t[11]!==c||t[12]!==l?(e=e=>{let t={"--burst-delay":`${e.delay}ms`,"--burst-x":`${e.x}%`,"--burst-y":`${e.y}%`,"--firework-color":`var(${e.colorVar})`,"--firework-duration":`${l}ms`};return(0,$.jsx)(`div`,{className:`firework-burst`,style:t,children:h.map((t,n)=>{let r=t.x*e.radius,i=t.y*e.radius,a={"--translate-x":`${r}px`,"--translate-y":`${i}px`,"--particle-delay":`${t.delay}ms`,color:`var(${e.colorVar})`};return(0,$.jsx)(`span`,{className:`firework-particle`,style:a},`${e.id}-${n}-${c}`)})},`${e.id}-${c}`)},t[11]=c,t[12]=l,t[13]=e):e=t[13],_=u.map(e),t[7]=c,t[8]=u,t[9]=l,t[10]=_}else _=t[10];let v;return t[14]!==c||t[15]!==g||t[16]!==_?(v=(0,$.jsx)(`div`,{className:g,"aria-hidden":`true`,"data-burst-key":c,children:_}),t[14]=c,t[15]=g,t[16]=_,t[17]=v):v=t[17],v};function dm(e,t){let n=Math.PI*2*t/cm;return{x:Math.cos(n),y:Math.sin(n),delay:t*18}}var fm=e=>{let t=(0,Q.c)(13),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{durationMs:r}=n,i=r===void 0?3400:r,a;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(a={isActive:!1,cycle:0},t[2]=a):a=t[2];let[o,s]=Z.useState(a),c=Z.useRef(null),l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{c.current&&=(window.clearTimeout(c.current),null)},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{u(),s(pm)},t[4]=d):d=t[4];let f=d,p;t[5]===i?p=t[6]:(p=()=>{u(),s(mm),c.current=window.setTimeout(()=>{s(hm),c.current=null},i)},t[5]=i,t[6]=p);let m=p,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>()=>u(),g=[u],t[7]=h,t[8]=g):(h=t[7],g=t[8]),Z.useEffect(h,g);let _;return t[9]!==o.cycle||t[10]!==o.isActive||t[11]!==m?(_={isActive:o.isActive,burstKey:o.cycle,triggerFireworks:m,dismissFireworks:f},t[9]=o.cycle,t[10]=o.isActive,t[11]=m,t[12]=_):_=t[12],_};function pm(e){return e.isActive?{...e,isActive:!1}:e}function mm(e){return{isActive:!0,cycle:e.cycle+1}}function hm(e){return e.isActive?{...e,isActive:!1}:e}var gm=Z.createContext(void 0),_m=e=>{let t=(0,Q.c)(10),{children:n}=e,{isActive:r,burstKey:i,triggerFireworks:a,dismissFireworks:o}=fm(),s;t[0]!==o||t[1]!==a?(s={triggerFireworks:a,dismissFireworks:o},t[0]=o,t[1]=a,t[2]=s):s=t[2];let c=s,l;t[3]!==i||t[4]!==r?(l=(0,$.jsx)(um,{isActive:r,burstKey:i}),t[3]=i,t[4]=r,t[5]=l):l=t[5];let u;return t[6]!==n||t[7]!==l||t[8]!==c?(u=(0,$.jsxs)(gm.Provider,{value:c,children:[n,l]}),t[6]=n,t[7]=l,t[8]=c,t[9]=u):u=t[9],u},vm=()=>{let e=Z.useContext(gm);if(!e)throw Error(`useFireworksCelebration must be used within FireworksProvider`);return e},ym=`gitmojiCache`,bm=6048e5,xm=`1`,Sm=`https://raw.githubusercontent.com/carloscuesta/gitmoji/master/packages/gitmojis/src/gitmojis.json`,Cm=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.emoji==`string`&&typeof t.code==`string`&&typeof t.description==`string`},wm=()=>{if(typeof window>`u`)return null;try{let e=window.localStorage.getItem(ym);if(!e)return null;let t=JSON.parse(e);return!t||t.version!==xm||typeof t.fetchedAt!=`number`||!Array.isArray(t.gitmojis)?null:{gitmojis:t.gitmojis.filter(Cm),fetchedAt:t.fetchedAt,version:t.version}}catch{return null}},Tm=e=>{if(!(typeof window>`u`))try{let t={gitmojis:e,fetchedAt:Date.now(),version:xm};window.localStorage.setItem(ym,JSON.stringify(t))}catch{return}},Em=e=>Date.now()-e.fetchedAt<bm,Dm=null,Om=new Set,km=async()=>{if(Dm)return Dm;let e=(async()=>{try{let e=await fetch(Sm);if(!e.ok)throw Error(`Failed to load gitmojis: ${e.statusText}`);let t=await e.json(),n=Array.isArray(t.gitmojis)?t.gitmojis.filter(Cm):[];return Tm(n),Om.forEach(e=>e(n)),n}catch(e){console.warn(`Failed to load gitmoji list:`,e);let t=[];return Om.forEach(e=>e(t)),t}finally{Dm=null}})();return Dm=e,e},Am=e=>{let[t,n]=Z.useState(()=>e?wm()?.gitmojis??[]:[]),[r,i]=Z.useState(!1),a=Z.useRef(e);return a.current=e,Z.useEffect(()=>{if(!e){Om.delete(n),n([]),i(!1);return}let t=wm();if(t&&(n(t.gitmojis),Em(t)))return;Om.add(n),i(!0);let r=!1;return km().finally(()=>{!r&&a.current&&i(!1)}),()=>{r=!0,Om.delete(n)}},[e]),{gitmojis:t,isLoading:r,ensureLoaded:Z.useCallback(async()=>{if(!a.current)return[];if(t.length>0)return t;let e=wm();return e&&Em(e)?e.gitmojis:km()},[t])}},jm=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)};function Mm(e,t,n){let r=(0,Q.c)(5),[i,a]=Z.useState(),o,s;return r[0]!==n||r[1]!==e||r[2]!==t?(o=()=>{if(t){a(void 0);return}if(!e){a(void 0);return}a(void 0);let r=!1;return(async()=>{let[t,i]=await Promise.all([Yi(e),Ji(e)]).catch(Nm);if(r)return;let o=jm(t),s=jm(i);if(!o||!s||s===o)return;let c=n||``,l=s.split(`/`).filter(Boolean).pop()||s;a({source:`sdk`,path:s,projectDirectory:o,branch:c,label:c||l,name:l,worktreeRoot:s,worktreeStatus:`ready`,headState:c?`branch`:`unborn`,worktreeSource:`existing`})})(),()=>{r=!0}},s=[e,t,n],r[0]=n,r[1]=e,r[2]=t,r[3]=o,r[4]=s):(o=r[3],s=r[4]),Z.useEffect(o,s),t??i}function Nm(){return[``,``]}function Pm(e,t,n){let r=(0,Q.c)(15),i=bt(),a=i?.entry.location.hostId?i.entry:void 0,o=Mm(a?void 0:e,a?void 0:t,a?void 0:n),s,c,l;r[0]!==n||r[1]!==e||r[2]!==a?(s=Mt(a),l=yt,c=s.key([`project-worktree-metadata`,e,n]),r[0]=n,r[1]=e,r[2]=a,r[3]=s,r[4]=c,r[5]=l):(s=r[3],c=r[4],l=r[5]);let u=!!(a&&e),d;r[6]!==n||r[7]!==e||r[8]!==a||r[9]!==s?(d=async t=>{let{signal:r}=t;if(!e||!a)throw Error(`Project worktree scope required`);let[i,o]=await Promise.all([`primary-root`,`toplevel`].map(t=>s.json(`/api/git/${t}`,{query:{directory:e},headers:{"x-opencode-directory":e},signal:r})));return!i.root||!o.root||i.root===o.root?null:{source:`sdk`,path:o.root,projectDirectory:i.root,branch:n??``,label:n||o.root,worktreeRoot:o.root,worktreeStatus:`ready`,headState:n?`branch`:`unborn`,worktreeSource:`existing`}},r[6]=n,r[7]=e,r[8]=a,r[9]=s,r[10]=d):d=r[10];let f;r[11]!==c||r[12]!==u||r[13]!==d?(f={queryKey:c,enabled:u,queryFn:d,staleTime:3e4},r[11]=c,r[12]=u,r[13]=d,r[14]=f):f=r[14];let p=l(f);return a?p.data??void 0:o}var Fm=({open:e,onOpenChange:t,directory:n,hasUncommittedChanges:r,hasStagedChanges:i=!1,uncommittedFileCount:a,onChanged:o})=>{let{t:s}=Nr(),{applyGitStash:c,countGitStashFiles:l,dropGitStash:u,listGitStashes:d,popGitStash:f,stashGitChanges:p}=ui(),{isMobile:m}=fi(),[h,g]=Z.useState([]),[_,v]=Z.useState(!1),[y,b]=Z.useState(``),[x,S]=Z.useState(``),[C,w]=Z.useState(null),[T,E]=Z.useState({}),D=Z.useCallback(async()=>{if(n){v(!0);try{let e=await d(n);g(e.stashes),E({})}catch(e){Y.error(e instanceof Error?e.message:s(`gitView.stashes.toast.loadFailed`))}finally{v(!1)}}},[n,s]);Z.useEffect(()=>{e&&D()},[D,e]),Z.useEffect(()=>{if(!e||!n||h.length===0)return;let t=!1,r=h.map(e=>e.ref);return l(n,r).then(e=>{t||E(e.counts)}).catch(()=>void 0),()=>{t=!0}},[n,e,h]);let O=Z.useMemo(()=>{let e=y.trim().toLowerCase();return e?h.filter(t=>`${t.ref} ${t.message} ${t.relativeTime}`.toLowerCase().includes(e)):h},[y,h]),k=Z.useCallback(async e=>{await D(),await o?.(e)},[D,o]),A=async()=>{if(!(!n||C)){w(`create`);try{let e=await p(n,{message:x.trim()||void 0});e.created?(Y.success(s(`gitView.stashes.toast.created`)),S(``)):Y.info(s(`gitView.stashes.toast.noChanges`)),await k({affectsIndex:!!(e.created&&i)})}catch(e){Y.error(e instanceof Error?e.message:s(`gitView.stashes.toast.createFailed`))}finally{w(null)}}},j=async(e,t)=>{if(!(!n||C)&&!(t===`drop`&&!window.confirm(s(`gitView.stashes.confirm.drop`,{ref:e.ref})))){w(`${t}:${e.ref}`);try{t===`apply`&&await c(n,{ref:e.ref}),t===`pop`&&await f(n,{ref:e.ref}),t===`drop`&&await u(n,{ref:e.ref});let r=t===`apply`?`gitView.stashes.toast.applySuccess`:t===`pop`?`gitView.stashes.toast.popSuccess`:`gitView.stashes.toast.dropSuccess`;Y.success(s(r)),await k({affectsIndex:t!==`drop`})}catch(e){let n=t===`apply`?`gitView.stashes.toast.applyFailed`:t===`pop`?`gitView.stashes.toast.popFailed`:`gitView.stashes.toast.dropFailed`;Y.error(e instanceof Error?e.message:s(n)),await k({affectsIndex:t!==`drop`})}finally{w(null)}}},M=C!==null;return(0,$.jsx)(Qr,{open:e,onOpenChange:t,children:(0,$.jsxs)(Yr,{presentation:m?`default`:`picker`,className:m?`max-w-2xl max-h-[70vh] flex flex-col`:void 0,children:[(0,$.jsx)(qr,{className:`yuri-picker-header`,children:(0,$.jsx)(Xr,{className:`yuri-picker-title`,children:s(`gitView.stashes.title`)})}),(0,$.jsxs)(`div`,{className:`yuri-picker-form`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(va,{value:x,onChange:e=>S(e.target.value),placeholder:s(`gitView.stashes.messagePlaceholder`),disabled:M||!r,className:`flex-1`}),(0,$.jsxs)(q,{onClick:A,disabled:!r||M||!n,children:[C===`create`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`inbox-archive`,className:`size-4`}),s(`gitView.stashes.actions.stashCurrentWithCount`,{count:a})]})]}),(0,$.jsx)(`p`,{className:`yuri-picker-meta typography-meta mt-2 text-muted-foreground`,children:s(`gitView.stashes.includeUntrackedHint`)})]}),(0,$.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(va,{value:y,onChange:e=>b(e.target.value),placeholder:s(`gitView.stashes.searchPlaceholder`),className:`pl-9`})]}),(0,$.jsx)(`div`,{className:`yuri-picker-list flex-1 overflow-y-auto`,children:_?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-10 text-muted-foreground`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-5 animate-spin`})}):O.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-muted-foreground`,children:s(y?`gitView.stashes.empty.search`:`gitView.stashes.empty.list`)}):O.map((e,t)=>(0,$.jsxs)(`div`,{className:`yuri-picker-row group flex items-center gap-2 rounded py-1.5 transition-colors hover:bg-interactive-hover/30`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`yuri-picker-label typography-small truncate text-foreground`,children:e.message||s(`gitView.stashes.untitled`)}),(0,$.jsxs)(`p`,{className:`yuri-picker-meta typography-meta truncate text-muted-foreground`,children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{children:t===0&&!y.trim()?s(`gitView.stashes.latestLabel`):s(`gitView.stashes.itemNumber`,{number:t+1})})}),(0,$.jsx)(ei,{sideOffset:6,children:e.ref})]}),` · `,e.relativeTime,` · `,typeof T[e.ref]==`number`?s(`gitView.stashes.fileCount`,{count:T[e.ref]}):s(`gitView.stashes.fileCountLoading`)]})]}),(0,$.jsxs)(`div`,{className:`mr-2 flex shrink-0 items-center gap-1 opacity-100 sm:opacity-0 sm:group-hover:opacity-100`,children:[(0,$.jsx)(Im,{label:s(`gitView.stashes.actions.apply`),loading:C===`apply:${e.ref}`,onClick:()=>j(e,`apply`),disabled:M,children:(0,$.jsx)(X,{name:`inbox-unarchive`,className:`size-4`})}),(0,$.jsx)(Im,{label:s(`gitView.stashes.actions.pop`),loading:C===`pop:${e.ref}`,onClick:()=>j(e,`pop`),disabled:M,children:(0,$.jsx)(X,{name:`inbox-unarchive-fill`,className:`size-4`})}),(0,$.jsx)(Im,{label:s(`gitView.stashes.actions.drop`),loading:C===`drop:${e.ref}`,onClick:()=>j(e,`drop`),disabled:M,destructive:!0,children:(0,$.jsx)(X,{name:`delete-bin`,className:`size-4`})})]})]},e.ref))})]})})},Im=e=>{let t=(0,Q.c)(17),{label:n,loading:r,disabled:i,destructive:a,onClick:o,children:s}=e,c=r||void 0,l=a?`text-[var(--status-error)] hover:text-[var(--status-error)]`:`text-muted-foreground hover:text-foreground`,u;t[0]===l?u=t[1]:(u=J(`flex h-6 w-6 items-center justify-center transition-colors disabled:opacity-50`,l),t[0]=l,t[1]=u);let d;t[2]!==s||t[3]!==r?(d=r?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):s,t[2]=s,t[3]=r,t[4]=d):d=t[4];let f;t[5]!==i||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==u||t[10]!==d?(f=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":n,"aria-busy":c,className:u,onClick:o,disabled:i,children:d})}),t[5]=i,t[6]=n,t[7]=o,t[8]=c,t[9]=u,t[10]=d,t[11]=f):f=t[11];let p;t[12]===n?p=t[13]:(p=(0,$.jsx)(ei,{sideOffset:6,children:n}),t[12]=n,t[13]=p);let m;return t[14]!==f||t[15]!==p?(m=(0,$.jsxs)(ni,{children:[f,p]}),t[14]=f,t[15]=p,t[16]=m):m=t[16],m},Lm=e=>{let t=(0,Q.c)(16),{onOpenStashes:n}=e,{t:r}=Nr(),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(X,{name:`git-commit`,className:`size-10 text-muted-foreground/70 mb-4`}),t[0]=i):i=t[0];let a;t[1]===r?a=t[2]:(a=r(`gitView.empty.cleanTitle`),t[1]=r,t[2]=a);let o;t[3]===a?o=t[4]:(o=(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground mb-1`,children:a}),t[3]=a,t[4]=o);let s;t[5]===r?s=t[6]:(s=r(`gitView.empty.cleanDescription`),t[5]=r,t[6]=s);let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mb-4`,children:s}),t[7]=s,t[8]=c);let l;t[9]!==n||t[10]!==r?(l=n?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`sm`,onClick:n,className:`gap-1.5`,children:[(0,$.jsx)(X,{name:`archive-stack`,className:`size-4`}),r(`gitView.stashes.title`)]}):null,t[9]=n,t[10]=r,t[11]=l):l=t[11];let u;return t[12]!==o||t[13]!==c||t[14]!==l?(u=(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-10 px-4 text-center`,children:[i,o,c,l]}),t[12]=o,t[13]=c,t[14]=l,t[15]=u):u=t[15],u},Rm=8,zm=e=>{let t=(0,Q.c)(18),{laned:n,totalLanes:r,isExpanded:i}=e,{lane:a,color:o,connectors:s}=n,c=Math.max(r,a+1)*Rm+Rm/2,l=Z.useRef(null),u=Z.useRef(null),d;t[0]!==o||t[1]!==s||t[2]!==a||t[3]!==c?(d=()=>{let e=l.current,t=u.current;if(!e||!t)return;let n=e.offsetHeight;if(n===0)return;let r=window.devicePixelRatio||1;t.width=c*r,t.height=n*r;let i=t.getContext(`2d`);if(!i)return;i.scale(r,r),i.clearRect(0,0,c,n);let d=n/2,f=a*Rm+Rm/2,p=getComputedStyle(t),m=p.getPropertyValue(`--surface-muted-foreground`).trim()||p.color,h=e=>{if(!e.startsWith(`var(`))return e;let t=e.slice(4,-1).trim();return p.getPropertyValue(t).trim()||m},g=[...s].sort(Vm);for(let e of g){let t=e.fromLane*Rm+Rm/2,r=e.toLane*Rm+Rm/2,a=e.type===`passing`?.72:e.type===`branch-out`||e.type===`merge-in`?.95:1;i.beginPath(),i.strokeStyle=h(e.color),i.globalAlpha=a,i.lineWidth=1.25,i.lineCap=`round`;bb64:switch(e.type){case`passing`:case`commit-lane`:i.moveTo(t,0),i.lineTo(t,n);break bb64;case`top-stub`:i.moveTo(t,0),i.lineTo(t,d);break bb64;case`bottom-stub`:i.moveTo(t,d),i.lineTo(t,n);break bb64;case`branch-out`:{let e=(d+n)/2;i.moveTo(f,d),i.bezierCurveTo(f,e,r,e,r,n);break bb64}case`merge-in`:{let e=d/2;i.moveTo(t,0),i.bezierCurveTo(t,e,f,e,f,d);break bb64}default:continue}i.stroke(),i.globalAlpha=1}let _=p.getPropertyValue(`--background`).trim()||p.getPropertyValue(`--surface-background`).trim();i.beginPath(),i.arc(f,d,4,0,Math.PI*2),i.fillStyle=h(o),i.fill(),i.beginPath(),i.arc(f,d,5,0,Math.PI*2),i.strokeStyle=_||m,i.lineWidth=2,i.stroke()},t[0]=o,t[1]=s,t[2]=a,t[3]=c,t[4]=d):d=t[4];let f;t[5]!==o||t[6]!==s||t[7]!==i||t[8]!==a||t[9]!==n||t[10]!==r||t[11]!==c?(f=[n,a,o,s,r,i,c],t[5]=o,t[6]=s,t[7]=i,t[8]=a,t[9]=n,t[10]=r,t[11]=c,t[12]=f):f=t[12],Z.useLayoutEffect(d,f);let p;t[13]===c?p=t[14]:(p={width:c,height:`100%`,position:`relative`,flexShrink:0,overflow:`hidden`},t[13]=c,t[14]=p);let m;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`canvas`,{ref:u,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,display:`block`}}),t[15]=m):m=t[15];let h;return t[16]===p?h=t[17]:(h=(0,$.jsx)(`div`,{ref:l,style:p,children:m}),t[16]=p,t[17]=h),h};function Bm(e){return e===`branch-out`||e===`merge-in`}function Vm(e,t){let n=Bm;return!!n(e.type)-+!!n(t.type)}var Hm=15e3,Um=500,Wm=12,Gm=8388608,Km=e=>typeof e==`string`?0:(e.original?.length??0)+(e.modified?.length??0),qm=e=>{if(e.size<=Wm){let t=0;for(let n of e.values())t+=Km(n);if(t<=Gm)return e}let t=Array.from(e.entries()).reverse(),n=new Map,r=0;for(let[e,i]of t){if(n.size>=Wm)continue;let t=Km(i);r+t>Gm&&n.size>0||(n.set(e,i),r+=t)}return new Map(Array.from(n.entries()).reverse())};function Jm(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?e:Ws(n,t,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Ym(e){switch(e){case`A`:return`text-[var(--status-success)]`;case`D`:return`text-[var(--status-error)]`;case`M`:return`text-[var(--status-warning)]`;case`R`:return`text-[var(--status-info)]`;default:return`text-muted-foreground`}}function Xm(e){return e?e.split(`,`).map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.startsWith(`HEAD ->`);return{label:t?e.replace(`HEAD -> `,``):e.replace(`tag: `,``),isHead:t,isTag:e.startsWith(`tag: `)}}):[]}var Zm=Z.memo(({entry:e,mode:t=`history`,laned:n,totalLanes:r,isExpanded:i,onToggle:a,files:o,isLoadingFiles:s,onCopyHash:c,directory:l,onConflict:u,onActionSuccess:d})=>{let{t:f}=Nr(),p=ui(),{getCommitFileDiff:m}=p,h=K(e=>e.timeFormatPreference),g=t===`graph`,[_,v]=Z.useState(null),[y,b]=Z.useState(!1),[x,S]=Z.useState(``),[C,w]=Z.useState(null),[T,E]=Z.useState(new Set),[D,O]=Z.useState(new Map),[k,A]=Z.useState(new Set),j=async()=>{if(l){v(`checkout`);try{await p.checkoutCommit(l,e.hash),Y.success(f(`gitView.history.actions.detachedHead`)),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},M=async()=>{if(!(!l||!x.trim())){v(`createBranch`);try{await p.createBranch(l,x.trim(),e.hash),b(!1),S(``),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},N=async()=>{if(l){v(`cherryPick`);try{let t=await p.cherryPick(l,e.hash);t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`cherry-pick`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},P=async()=>{if(l){v(`revert`);try{let t=await p.revertCommit(l,e.hash);t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`revert`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},F=async(t,n=!1)=>{if(!(!l||_!==null)){v(`reset`);try{await p.resetToCommit(l,e.hash,t,n),d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},I=async()=>{if(!C)return;let e=C;switch(w(null),e){case`checkout`:return j();case`cherryPick`:return N();case`revert`:return P();case`merge`:return L();case`rebase`:return R();case`resetSoft`:return F(`soft`);case`resetMixed`:return F(`mixed`);case`resetHard`:return F(`hard`,!0)}},L=async()=>{if(l){v(`merge`);try{let t=await p.merge(l,{branch:e.hash});t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`merge`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},R=async()=>{if(l){v(`rebase`);try{let t=await p.rebase(l,{onto:e.hash});t.conflict?u?.({conflict:!0,conflictFiles:t.conflictFiles,operation:`rebase`}):d?.()}catch(e){Y.error(String(e.message))}finally{v(null)}}},z=Z.useCallback(async t=>{let n=t.path;if(!l){O(e=>new Map(e).set(n,`error`));return}O(e=>qm(new Map(e).set(n,`loading`)));try{let r=m(l,e.hash,t.path,!1),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${Hm}ms`)),Hm)}),a=await Promise.race([r,i]);O(e=>qm(new Map(e).set(n,a)))}catch{O(e=>new Map(e).set(n,`error`))}},[l,e.hash]),ee=Z.useCallback(async e=>{let t=e.path;if(e.changeType===`R`||e.isBinary){E(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});return}let n=D.get(t);if(T.has(t)&&n&&n!==`error`){E(e=>{let n=new Set(e);return n.delete(t),n});return}E(e=>{let n=new Set(e);return n.add(t),n}),!(n&&n!==`error`)&&(e.insertions+e.deletions>Um&&!k.has(t)||await z(e))},[D,k,z,T]);return(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:J(`w-full flex items-start gap-3 px-3 py-2 text-left transition-colors`,g?`hover:bg-[var(--interactive-hover)]/40`:i?`bg-sidebar/90`:`hover:bg-sidebar/40`),children:[g&&n&&r!==void 0?(0,$.jsx)(`div`,{className:`-my-2 shrink-0 self-stretch`,children:(0,$.jsx)(zm,{laned:n,totalLanes:r,isExpanded:i})}):(0,$.jsx)(`div`,{className:`h-2 w-2 translate-y-2 rounded-full shrink-0`,style:{backgroundColor:`var(--status-success)`},"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[g?(()=>{let t=Xm(e.refs);return t.length>0?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-0.5`,children:t.map(e=>(0,$.jsx)(`span`,{className:J(`inline-flex items-center px-1.5 py-0 typography-micro rounded font-medium`,e.isHead?`bg-[var(--chart-1)] text-[var(--primary-foreground)]`:e.isTag?`bg-[var(--chart-5)] text-[var(--primary-foreground)]`:`bg-[var(--interactive-hover)] text-[var(--foreground)]`),children:e.label},e.label))}):null})():null,(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground line-clamp-1`,children:e.message}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 typography-meta text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 min-w-0 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate min-w-[3ch]`,title:e.author_name,children:e.author_name}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`}),(0,$.jsx)(`span`,{className:`truncate min-w-0`,title:Jm(e.date,h),children:Jm(e.date,h)})]}),(0,$.jsx)(`span`,{className:`shrink-0`,children:`·`}),(0,$.jsx)(`code`,{className:`shrink-0 font-mono`,children:e.hash.slice(0,8)}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`sm`,className:`h-5 px-1 shrink-0`,onClick:t=>{t.stopPropagation(),c(e.hash)},children:(0,$.jsx)(X,{name:`file-copy`,className:`size-3`})})}),(0,$.jsx)(ei,{sideOffset:8,children:f(`gitView.history.copySha`)})]})]})]})]}),i&&(0,$.jsxs)(`div`,{className:`px-3 pb-2 pl-8 border-t border-border/40`,children:[g&&C?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-2 border-b border-border/30 mb-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground flex-1 min-w-0`,children:f(`gitView.history.actions.${C}Confirm`)}),(0,$.jsxs)(q,{variant:`destructive`,size:`xs`,className:`h-6 shrink-0`,disabled:_!==null,onClick:e=>{e.stopPropagation(),I()},children:[_===null?null:(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}),f(`gitView.history.actions.confirmButton`)]}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`h-6 shrink-0`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(null)},children:f(`gitView.history.actions.cancelButton`)})]}):g?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 py-2 border-b border-border/30 mb-2`,children:[(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`checkout`)},children:f(`gitView.history.actions.checkout`)}),y?(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{autoFocus:!0,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&M(),e.key===`Escape`&&(b(!1),S(``))},placeholder:f(`gitView.history.actions.createBranchPlaceholder`),className:`h-6 text-xs px-2 rounded border border-border/60 bg-background min-w-0 w-32`}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:!x.trim()||_!==null,onClick:e=>{e.stopPropagation(),M()},children:[_===`createBranch`?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}):null,f(`gitView.history.actions.createBranchConfirm`)]})]}):(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,onClick:e=>{e.stopPropagation(),b(!0)},children:f(`gitView.history.actions.createBranch`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`cherryPick`)},children:f(`gitView.history.actions.cherryPick`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`revert`)},children:f(`gitView.history.actions.revert`)}),(0,$.jsxs)(Ci,{children:[(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>e.stopPropagation(),children:[_===`reset`?(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin mr-1`}):null,f(`gitView.history.actions.reset`)]})}),(0,$.jsx)(bi,{align:`start`,className:`min-w-max`,children:[`soft`,`mixed`,`hard`].map(e=>(0,$.jsx)(xi,{disabled:_!==null,onSelect:t=>{t.stopPropagation(),w(`reset${e.charAt(0).toUpperCase()+e.slice(1)}`)},children:f(`gitView.history.actions.reset${e.charAt(0).toUpperCase()+e.slice(1)}`)},e))})]}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`merge`)},children:f(`gitView.history.actions.merge`)}),(0,$.jsx)(q,{variant:`outline`,size:`xs`,className:`h-6`,disabled:_!==null,onClick:e=>{e.stopPropagation(),w(`rebase`)},children:f(`gitView.history.actions.rebase`)})]}):null,s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:f(`gitView.history.loadingFiles`)})]}):o.length===0?(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground py-2`,children:f(`gitView.history.noFiles`)}):(0,$.jsx)(`ul`,{className:`space-y-0.5 py-2`,children:o.map(e=>(0,$.jsxs)(`li`,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ee(e),className:J(`w-full flex items-center gap-2 typography-micro text-left cursor-pointer transition-colors rounded px-1`,T.has(e.path)?`bg-sidebar/90`:`hover:bg-sidebar/40`),children:[(0,$.jsx)(`span`,{className:J(`font-semibold w-3 text-center shrink-0`,Ym(e.changeType)),children:e.changeType}),(0,$.jsx)(`span`,{className:`truncate text-foreground min-w-0`,title:e.path,children:e.path}),!e.isBinary&&(0,$.jsxs)(`span`,{className:`shrink-0`,children:[(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,e.insertions]}),(0,$.jsx)(`span`,{className:`text-muted-foreground mx-0.5`,children:`/`}),(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,e.deletions]})]}),e.isBinary&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:f(`gitView.history.binary`)}),(0,$.jsx)(X,{name:T.has(e.path)?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),T.has(e.path)&&(0,$.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded border border-border/40 mx-2 mb-1`,"data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:e.changeType===`R`?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.renamedNoDiff`)}):e.isBinary?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.binaryNoDiff`)}):(()=>{let t=e.insertions+e.deletions;if(!k.has(e.path)&&t>Um)return(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1 px-3 py-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-foreground`,children:f(`gitView.history.largeDiffTitle`,{count:t})}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:f(`gitView.history.largeDiffDescription`)}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,className:`h-6 px-0 text-primary hover:bg-transparent hover:underline`,onClick:()=>{A(t=>new Set(t).add(e.path)),z(e)},children:f(`gitView.history.renderDiffAnyway`)})]});let n=D.get(e.path);return n===`loading`||n===void 0?(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:f(`gitView.history.loadingDiff`)}):n===`error`?(0,$.jsx)(`button`,{type:`button`,onClick:()=>ee(e),className:`w-full text-left px-3 py-2 text-sm text-muted-foreground hover:bg-[var(--interactive-hover)] transition-colors`,children:f(`gitView.history.diffError`)}):(0,$.jsx)(Pi,{original:n.original,modified:n.modified,language:Ir(e.path)||``,fileName:e.path,renderSideBySide:!1,layout:`inline`,enableComments:!1})})()})]},e.path))})]})]})}),Qm=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--chart-5)`,`var(--syntax-keyword)`,`var(--syntax-string)`,`var(--status-info)`];function $m(e){return Qm[e%Qm.length]}function eh(e){if(e.length===0)return[];let t=[],n=[];for(let r=0;r<e.length;r++){let i=e[r],a=[];for(let e=0;e<t.length;e++)t[e]===i.hash&&a.push(e);let o=a.length>0?a[0]:-1;if(o===-1){let e=t.indexOf(null);e===-1?(o=t.length,t.push(null)):o=e}let s=a.slice(1),c=$m(o),l=t[o]===i.hash,u=i.parents.length>0;u?t[o]=i.parents[0]:t[o]=null;let d=[];for(let e=1;e<i.parents.length;e++){let n=i.parents[e],r=t.indexOf(n);if(r!==-1)d.push(r);else{let e=t.indexOf(null),r=e===-1?t.length:e;t[r]=n,r===t.length&&t.push(n),d.push(r)}}let f=[];l&&u?f.push({fromLane:o,toLane:o,color:c,type:`commit-lane`}):l&&!u?f.push({fromLane:o,toLane:o,color:c,type:`top-stub`}):!l&&u&&f.push({fromLane:o,toLane:o,color:c,type:`bottom-stub`});for(let e of s)f.push({fromLane:e,toLane:o,color:$m(e),type:`merge-in`}),t[e]=null;for(let e of d)f.push({fromLane:o,toLane:e,color:$m(e),type:`branch-out`});for(let e=0;e<t.length;e++)t[e]!==null&&e!==o&&(d.includes(e)||f.push({fromLane:e,toLane:e,color:$m(e),type:`passing`}));n.push({commit:i,lane:o,color:c,connectors:f})}return n}var th=[{labelKey:`gitView.history.logSize25`,value:25},{labelKey:`gitView.history.logSize50`,value:50},{labelKey:`gitView.history.logSize100`,value:100}],nh=e=>{let t=(0,Q.c)(84),{mode:n,log:r,isLogLoading:i,logMaxCount:a,onLogMaxCountChange:o,expandedCommitHashes:s,onToggleCommit:c,commitFilesMap:l,loadingCommitHashes:u,onCopyHash:d,directory:f,showHeader:p,contentMaxHeightClassName:m,branchDivider:h,onConflict:g,onActionSuccess:_}=e,v=n===void 0?`history`:n,y=p===void 0||p,b=m===void 0?`max-h-[50vh]`:m,x=h===void 0?null:h,{t:S}=Nr(),[C,w]=Z.useState(!0),T=v===`graph`,E;t[0]!==T||t[1]!==r?(E=T&&r?eh(r.all):[],t[0]=T,t[1]=r,t[2]=E):E=t[2];let D=E,O;t[3]===D?O=t[4]:(O=Math.max(1,...D.map(rh)),t[3]=D,t[4]=O);let k=O,A;t[5]===D?A=t[6]:(A=new Map(D.map(ih)),t[5]=D,t[6]=A);let j=A;if(!r)return null;let M=x!==null&&x.insertBeforeIndex>0&&x.insertBeforeIndex<r.all.length,N=x!==null&&x.insertBeforeIndex===r.all.length,P=M||N,F;t[7]!==x||t[8]!==M||t[9]!==N||t[10]!==r.all?(F=M?r.all.slice(0,x.insertBeforeIndex):N?r.all:[],t[7]=x,t[8]=M,t[9]=N,t[10]=r.all,t[11]=F):F=t[11];let I=F,L;if(t[12]!==x||t[13]!==l||t[14]!==b||t[15]!==f||t[16]!==s||t[17]!==M||t[18]!==P||t[19]!==T||t[20]!==i||t[21]!==j||t[22]!==u||t[23]!==r.all||t[24]!==a||t[25]!==k||t[26]!==v||t[27]!==_||t[28]!==g||t[29]!==d||t[30]!==o||t[31]!==c||t[32]!==S||t[33]!==I){let e=M?r.all.slice(x.insertBeforeIndex):[],n;t[35]===x?.direction?n=t[36]:(n=x?.direction===`down`?(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-3.5`}):(0,$.jsx)(X,{name:`arrow-up`,className:`size-3.5`}),t[35]=x?.direction,t[36]=n);let p=n,m;t[37]!==l||t[38]!==f||t[39]!==s||t[40]!==T||t[41]!==j||t[42]!==u||t[43]!==k||t[44]!==v||t[45]!==_||t[46]!==g||t[47]!==d||t[48]!==c?(m=e=>(0,$.jsx)(`ul`,{className:`divide-y divide-border/60`,children:e.map(e=>(0,$.jsx)(Zm,{entry:e,mode:v,laned:T?j.get(e.hash):void 0,totalLanes:T?k:void 0,isExpanded:s.has(e.hash),onToggle:()=>c(e.hash),files:l.get(e.hash)??[],isLoadingFiles:u.has(e.hash),onCopyHash:d,directory:f,onConflict:g,onActionSuccess:_},e.hash))}),t[37]=l,t[38]=f,t[39]=s,t[40]=T,t[41]=j,t[42]=u,t[43]=k,t[44]=v,t[45]=_,t[46]=g,t[47]=d,t[48]=c,t[49]=m):m=t[49];let h=m,y;t[50]!==i||t[51]!==r.all.length||t[52]!==a||t[53]!==o||t[54]!==S?(y=r.all.length>=a?(0,$.jsx)(`div`,{className:`flex justify-center py-2 border-t border-border/40`,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>o(a+25),disabled:i,className:`px-3 text-muted-foreground hover:text-foreground`,children:i?(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3 animate-spin`}),S(`gitView.history.loadingMore`)]}):S(`gitView.history.loadMore`)})}):null,t[50]=i,t[51]=r.all.length,t[52]=a,t[53]=o,t[54]=S,t[55]=y):y=t[55];let C=y;L=(0,$.jsx)(Wr,{outerClassName:`min-h-0 ${b}`,className:`h-full w-full`,children:r.all.length===0?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:S(`gitView.history.noCommits`)})}):P&&x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0`,children:[I.length>0?(0,$.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:h(I)}):null,(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/60`}),(0,$.jsxs)(`span`,{className:`inline-flex max-w-[80%] items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate`,title:x.branchName,children:x.branchName}),p]}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-border/60`})]}),e.length>0?(0,$.jsx)(`div`,{className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:h(e)}):null]}),C]}):(0,$.jsxs)($.Fragment,{children:[h(r.all),C]})}),t[12]=x,t[13]=l,t[14]=b,t[15]=f,t[16]=s,t[17]=M,t[18]=P,t[19]=T,t[20]=i,t[21]=j,t[22]=u,t[23]=r.all,t[24]=a,t[25]=k,t[26]=v,t[27]=_,t[28]=g,t[29]=d,t[30]=o,t[31]=c,t[32]=S,t[33]=I,t[34]=L}else L=t[34];let R=L;if(!y){if(P){let e;return t[56]===R?e=t[57]:(e=(0,$.jsx)(`section`,{className:`h-full min-h-0`,children:R}),t[56]=R,t[57]=e),e}let e;return t[58]===R?e=t[59]:(e=(0,$.jsx)(`section`,{className:`h-full min-h-0 rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:R}),t[58]=R,t[59]=e),e}let z;t[60]===S?z=t[61]:(z=S(`gitView.history.title`),t[60]=S,t[61]=z);let ee;t[62]===z?ee=t[63]:(ee=(0,$.jsx)(`h3`,{className:`typography-ui-header font-semibold text-foreground`,children:z}),t[62]=z,t[63]=ee);let B;t[64]!==i||t[65]!==C||t[66]!==a||t[67]!==o||t[68]!==S?(B=C&&(0,$.jsx)(`div`,{onClick:ah,onPointerDown:oh,children:(0,$.jsxs)(Fs,{value:String(a),onValueChange:e=>o(Number(e)),disabled:i,children:[(0,$.jsx)(Ps,{size:`sm`,className:`data-[size=sm]:h-auto h-7 min-h-7 w-auto justify-between px-2 py-0`,disabled:i,children:(0,$.jsx)(js,{placeholder:S(`gitView.history.commitsPlaceholder`)})}),(0,$.jsx)(Ns,{children:th.map(e=>(0,$.jsx)(Ms,{value:String(e.value),children:S(e.labelKey)},e.value))})]})}),t[64]=i,t[65]=C,t[66]=a,t[67]=o,t[68]=S,t[69]=B):B=t[69];let te;t[70]===C?te=t[71]:(te=C?(0,$.jsx)(X,{name:`arrow-up-s`,className:`size-4 text-muted-foreground`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`size-4 text-muted-foreground`}),t[70]=C,t[71]=te);let ne;t[72]!==B||t[73]!==te?(ne=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[B,te]}),t[72]=B,t[73]=te,t[74]=ne):ne=t[74];let re;t[75]!==ee||t[76]!==ne?(re=(0,$.jsxs)(Ai,{className:`flex w-full items-center justify-between px-3 h-10 hover:bg-transparent`,children:[ee,ne]}),t[75]=ee,t[76]=ne,t[77]=re):re=t[77];let ie;t[78]===R?ie=t[79]:(ie=(0,$.jsx)(ki,{children:R}),t[78]=R,t[79]=ie);let ae;return t[80]!==C||t[81]!==re||t[82]!==ie?(ae=(0,$.jsxs)(ji,{open:C,onOpenChange:w,className:`rounded-xl border border-border/60 bg-background/70 overflow-hidden`,children:[re,ie]}),t[80]=C,t[81]=re,t[82]=ie,t[83]=ae):ae=t[83],ae};function rh(e){return e.lane+1}function ih(e){return[e.commit.hash,e]}function ah(e){return e.stopPropagation()}function oh(e){return e.stopPropagation()}var sh=e=>{let t=(0,Q.c)(154),{open:n,onOpenChange:r,conflictFiles:i,directory:a,operation:o,onAbort:s,onClearState:c}=e,l;t[0]===i?l=t[1]:(l=i===void 0?[]:i,t[0]=i,t[1]=l);let u=l,{t:d}=Nr(),{getConflictDetails:f}=ui(),p=Vn(ch),m=Vn(lh),h=Fr(uh),g=Fr(dh),_=K(fh),[v,y]=Z.useState(!1),[b,x]=Z.useState(null),[S,C]=Z.useState(null),w;t[2]!==a||t[3]!==f||t[4]!==n||t[5]!==d?(w=()=>{!n||!a||(y(!0),C(null),x(null),f(a).then(e=>{x(e)}).catch(e=>{let t=e instanceof Error?e.message:d(`gitView.conflict.loadFailed`);C(t)}).finally(()=>{y(!1)}))},t[2]=a,t[3]=f,t[4]=n,t[5]=d,t[6]=w):w=t[6];let T;t[7]!==a||t[8]!==n||t[9]!==d?(T=[n,a,d],t[7]=a,t[8]=n,t[9]=d,t[10]=T):T=t[10],Z.useEffect(w,T);let E;t[11]!==b||t[12]!==a||t[13]!==o?(E=async()=>{if(!b)return null;let e=o===`merge`?`merge`:`rebase`,t=b.headInfo||(o===`merge`?`MERGE_HEAD`:`REBASE_HEAD`),n=o===`merge`?`git commit --no-edit`:`git rebase --continue`;return{visibleText:await qi(`git.conflict.resolve.visible`,{operation_label:e,head_ref:t}),instructionsText:await qi(`git.conflict.resolve.instructions`,{operation_label:e,directory:a,operation:o,head_info:b.headInfo||`N/A`,continue_cmd:n}),payloadText:`${e} conflict context (JSON)\n${JSON.stringify({directory:a,operation:b.operation,headInfo:b.headInfo,statusPorcelain:b.statusPorcelain,unmergedFiles:b.unmergedFiles,diff:b.diff},null,2)}`}},t[11]=b,t[12]=a,t[13]=o,t[14]=E):E=t[14];let D=E,O;t[15]!==s||t[16]!==r?(O=()=>{s(),r(!1)},t[15]=s,t[16]=r,t[17]=O):O=t[17];let k=O,A;t[18]!==c||t[19]!==r?(A=()=>{c?.(),r(!1)},t[18]=c,t[19]=r,t[20]=A):A=t[20];let j=A,M;t[21]!==D||t[22]!==m||t[23]!==c||t[24]!==r||t[25]!==_||t[26]!==h||t[27]!==g||t[28]!==d?(M=async()=>{let e=await D();if(!e){Y.error(d(`gitView.conflict.noDetailsAvailable`));return}if(!m){Y.error(d(`gitView.conflict.noActiveSession`),{description:d(`gitView.conflict.noActiveSessionDescription`)});return}h(e.visibleText,`replace`),g([{text:e.instructionsText,synthetic:!0},{text:e.payloadText,synthetic:!0}]),_(`chat`),c?.(),r(!1)},t[21]=D,t[22]=m,t[23]=c,t[24]=r,t[25]=_,t[26]=h,t[27]=g,t[28]=d,t[29]=M):M=t[29];let N=M,P;t[30]!==D||t[31]!==a||t[32]!==c||t[33]!==r||t[34]!==p||t[35]!==_||t[36]!==d?(P=async()=>{let e=await D();if(!e){Y.error(d(`gitView.conflict.noDetailsAvailable`));return}p({directoryOverride:a,initialPrompt:e.visibleText,syntheticParts:[{text:e.instructionsText,synthetic:!0},{text:e.payloadText,synthetic:!0}]}),_(`chat`),c?.(),r(!1)},t[30]=D,t[31]=a,t[32]=c,t[33]=r,t[34]=p,t[35]=_,t[36]=d,t[37]=P):P=t[37];let F=P,I,L,R,z,ee,B,te,ne,re,ie,ae,oe,V,H,se,U,ce,le,ue,de,fe,pe;if(t[38]!==b||t[39]!==u||t[40]!==m||t[41]!==k||t[42]!==j||t[43]!==N||t[44]!==F||t[45]!==v||t[46]!==S||t[47]!==r||t[48]!==n||t[49]!==o||t[50]!==d){let e=d(o===`merge`?`gitView.operation.merge`:`gitView.operation.rebase`),i=b?.unmergedFiles||u;R=Qr,fe=n,pe=r,L=Yr,de=`max-w-md w-[calc(100vw-2rem)]`,H=`flex flex-col gap-4 overflow-hidden`;let a;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(X,{name:`alert`,className:`size-5 shrink-0 text-[var(--status-warning)]`}),t[73]=a):a=t[73];let s=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a,(0,$.jsx)(Xr,{children:d(`gitView.conflict.detectedTitle`,{operation:e})})]}),c;t[74]!==o||t[75]!==d?(c=d(`gitView.conflict.detectedDescription`,{operation:o}),t[74]=o,t[75]=d,t[76]=c):c=t[76];let l;t[77]===c?l=t[78]:(l=(0,$.jsx)(Zr,{children:c}),t[77]=c,t[78]=l),t[79]!==s||t[80]!==l?(se=(0,$.jsxs)(qr,{children:[s,l]}),t[79]=s,t[80]=l,t[81]=se):se=t[81],t[82]!==v||t[83]!==d?(U=v&&(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-4 text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:d(`gitView.conflict.loading`)})]}),t[82]=v,t[83]=d,t[84]=U):U=t[84],t[85]!==S||t[86]!==d?(ce=S&&(0,$.jsx)(`div`,{className:`rounded-lg bg-[var(--status-error-bg)] p-3 text-[var(--status-error)] typography-meta break-words`,children:d(`gitView.conflict.errorLoadingDetails`,{message:S})}),t[85]=S,t[86]=d,t[87]=ce):ce=t[87],t[88]!==i||t[89]!==d?(le=i.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:d(`gitView.conflict.conflictedFiles`)}),(0,$.jsx)(`span`,{className:`typography-micro px-1.5 py-0.5 rounded bg-[var(--surface-elevated)] text-muted-foreground`,children:i.length})]}),(0,$.jsx)(`div`,{className:`bg-[var(--surface-elevated)] rounded-lg p-3 max-h-40 overflow-y-auto overflow-x-hidden`,children:(0,$.jsx)(`ul`,{className:`space-y-1`,children:i.map(ph)})})]}),t[88]=i,t[89]=d,t[90]=le):le=t[90],t[91]!==b||t[92]!==d?(ue=b?.headInfo&&(0,$.jsxs)(`div`,{className:`space-y-1 overflow-hidden`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:d(`gitView.conflict.headInfo`)}),(0,$.jsx)(`div`,{className:`typography-micro text-foreground font-mono bg-[var(--surface-elevated)] rounded-lg p-3 max-h-24 overflow-y-auto break-words whitespace-pre-wrap`,children:b.headInfo})]}),t[91]=b,t[92]=d,t[93]=ue):ue=t[93],ae=`flex flex-col gap-2 pt-2`;let f;t[94]===F?f=t[95]:(f=()=>{F()},t[94]=F,t[95]=f);let p=v||!b,h;t[96]===v?h=t[97]:(h=v?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`add`,className:`size-4`}),t[96]=v,t[97]=h);let g;t[98]===d?g=t[99]:(g=d(`gitView.conflict.resolveNewSession`),t[98]=d,t[99]=g),t[100]!==f||t[101]!==p||t[102]!==h||t[103]!==g?(oe=(0,$.jsxs)(q,{variant:`default`,onClick:f,disabled:p,className:`w-full gap-2`,children:[h,g]}),t[100]=f,t[101]=p,t[102]=h,t[103]=g,t[104]=oe):oe=t[104];let _;t[105]===N?_=t[106]:(_=()=>void N(),t[105]=N,t[106]=_);let y=v||!b||!m,x;t[107]===v?x=t[108]:(x=v?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`chat-1`,className:`size-4`}),t[107]=v,t[108]=x);let C;t[109]===d?C=t[110]:(C=d(`gitView.conflict.resolveCurrentSession`),t[109]=d,t[110]=C),t[111]!==_||t[112]!==y||t[113]!==x||t[114]!==C?(V=(0,$.jsxs)(q,{variant:`outline`,onClick:_,disabled:y,className:`w-full gap-2`,children:[x,C]}),t[111]=_,t[112]=y,t[113]=x,t[114]=C,t[115]=V):V=t[115],re=`flex gap-2 pt-1`;let w;t[116]===d?w=t[117]:(w=d(`gitView.conflict.continueLater`),t[116]=d,t[117]=w),t[118]!==j||t[119]!==w?(ie=(0,$.jsx)(q,{variant:`ghost`,size:`sm`,onClick:j,className:`flex-1`,children:w}),t[118]=j,t[119]=w,t[120]=ie):ie=t[120],I=q,z=`destructive`,ee=`sm`,B=k,te=`flex-1`,ne=d(`gitView.conflict.abortOperation`,{operation:e}),t[38]=b,t[39]=u,t[40]=m,t[41]=k,t[42]=j,t[43]=N,t[44]=F,t[45]=v,t[46]=S,t[47]=r,t[48]=n,t[49]=o,t[50]=d,t[51]=I,t[52]=L,t[53]=R,t[54]=z,t[55]=ee,t[56]=B,t[57]=te,t[58]=ne,t[59]=re,t[60]=ie,t[61]=ae,t[62]=oe,t[63]=V,t[64]=H,t[65]=se,t[66]=U,t[67]=ce,t[68]=le,t[69]=ue,t[70]=de,t[71]=fe,t[72]=pe}else I=t[51],L=t[52],R=t[53],z=t[54],ee=t[55],B=t[56],te=t[57],ne=t[58],re=t[59],ie=t[60],ae=t[61],oe=t[62],V=t[63],H=t[64],se=t[65],U=t[66],ce=t[67],le=t[68],ue=t[69],de=t[70],fe=t[71],pe=t[72];let me;t[121]!==I||t[122]!==z||t[123]!==ee||t[124]!==B||t[125]!==te||t[126]!==ne?(me=(0,$.jsx)(I,{variant:z,size:ee,onClick:B,className:te,children:ne}),t[121]=I,t[122]=z,t[123]=ee,t[124]=B,t[125]=te,t[126]=ne,t[127]=me):me=t[127];let he;t[128]!==re||t[129]!==ie||t[130]!==me?(he=(0,$.jsxs)(`div`,{className:re,children:[ie,me]}),t[128]=re,t[129]=ie,t[130]=me,t[131]=he):he=t[131];let ge;t[132]!==ae||t[133]!==oe||t[134]!==V||t[135]!==he?(ge=(0,$.jsxs)(`div`,{className:ae,children:[oe,V,he]}),t[132]=ae,t[133]=oe,t[134]=V,t[135]=he,t[136]=ge):ge=t[136];let _e;t[137]!==H||t[138]!==se||t[139]!==U||t[140]!==ce||t[141]!==le||t[142]!==ue||t[143]!==ge?(_e=(0,$.jsxs)(`div`,{className:H,children:[se,U,ce,le,ue,ge]}),t[137]=H,t[138]=se,t[139]=U,t[140]=ce,t[141]=le,t[142]=ue,t[143]=ge,t[144]=_e):_e=t[144];let ve;t[145]!==L||t[146]!==de||t[147]!==_e?(ve=(0,$.jsx)(L,{className:de,children:_e}),t[145]=L,t[146]=de,t[147]=_e,t[148]=ve):ve=t[148];let ye;return t[149]!==R||t[150]!==fe||t[151]!==pe||t[152]!==ve?(ye=(0,$.jsx)(R,{open:fe,onOpenChange:pe,children:ve}),t[149]=R,t[150]=fe,t[151]=pe,t[152]=ve,t[153]=ye):ye=t[153],ye};function ch(e){return e.openNewSessionDraft}function lh(e){return e.currentSessionId}function uh(e){return e.setPendingInputText}function dh(e){return e.setPendingSyntheticParts}function fh(e){return e.setActiveMainTab}function ph(e){return(0,$.jsx)(`li`,{className:`typography-micro text-foreground font-mono truncate block`,title:e,children:e},e)}var mh=({mergeInProgress:e,rebaseInProgress:t,onContinue:n,onAbort:r,onResolveWithAI:i,hasUnresolvedConflicts:a=!1,isLoading:o=!1})=>{let{t:s}=Nr(),[c,l]=Z.useState(null),u=e&&e.head,d=t&&(t.headName||t.onto),f=u?`merge`:d?`rebase`:null;if(!f)return null;let p=async()=>{l(`continue`);try{await n()}finally{l(null)}},m=async()=>{l(`abort`);try{await r()}finally{l(null)}},h=c!==null,g=s(f===`merge`?`gitView.operation.merge`:`gitView.operation.rebase`),_=f===`merge`?`git-merge`:`git-branch`,v=``;return e?v=e.message?s(`gitView.operation.mergingMessage`,{message:e.message}):s(`gitView.operation.mergeInProgressWithHead`,{head:e.head}):t&&(v=t.headName?s(`gitView.operation.rebasingOnto`,{headName:t.headName,onto:t.onto||``}):s(`gitView.operation.rebaseInProgress`)),(0,$.jsx)(`div`,{className:`bg-[var(--status-warning-bg)] border border-[var(--status-warning)] rounded-lg p-3 mx-3 mt-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,$.jsx)(X,{name:_,className:`size-4 text-[var(--status-warning)] shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-warning)]`,children:s(`gitView.operation.inProgressTitle`,{operation:g})}),v&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[a&&i&&(0,$.jsxs)(q,{variant:`outline`,size:`sm`,onClick:i,disabled:h||o,className:`gap-1.5`,children:[(0,$.jsx)(X,{name:`sparkling`,className:`size-4`}),s(`gitView.operation.resolveWithAi`)]}),c!==`continue`&&(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,onClick:m,disabled:h||o,className:`gap-1.5`,children:[c===`abort`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`close`,className:`size-4`}),s(`gitView.operation.abort`)]}),!a&&(0,$.jsxs)(q,{variant:`default`,size:`sm`,onClick:p,disabled:h||o,className:`gap-1.5`,children:[c===`continue`?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):(0,$.jsx)(X,{name:`check`,className:`size-4`}),s(`gitView.operation.continue`)]})]}),a&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-warning)]`,children:s(`gitView.operation.resolveConflictsHint`)})]})})},hh=({runMutation:e,onMutationComplete:t,onMutationError:n,onPathsComplete:r,scheduleFlush:i})=>{let a=[],o=!1;return{enqueue:e=>{let t=a[a.length-1];if(t?.directory===e.directory&&t.direction===e.direction){e.paths.forEach(e=>t.paths.add(e));return}a.push(e)},flush:()=>{if(o)return;let s=a.shift();if(!s)return;o=!0;let c={directory:s.directory,direction:s.direction,paths:Array.from(s.paths),rollback:s.rollback};(async()=>{try{await e(c),t(c)}catch(e){n(c,e)}finally{r(c.paths),o=!1,a.length>0&&i()}})()},clear:()=>{a.length=0},size:()=>a.length,isRunning:()=>o}},gh=15e3,_h=40,vh=20,yh={feat:`:sparkles:`,feature:`:sparkles:`,fix:`:bug:`,bug:`:bug:`,hotfix:`:ambulance:`,docs:`:memo:`,documentation:`:memo:`,style:`:lipstick:`,refactor:`:recycle:`,perf:`:zap:`,performance:`:zap:`,test:`:white_check_mark:`,tests:`:white_check_mark:`,build:`:construction_worker:`,ci:`:green_heart:`,chore:`:wrench:`,revert:`:rewind:`,wip:`:construction:`,security:`:lock:`,release:`:bookmark:`,merge:`:twisted_rightwards_arrows:`,mv:`:truck:`,move:`:truck:`,rename:`:truck:`,remove:`:fire:`,delete:`:fire:`,add:`:sparkles:`,create:`:sparkles:`,implement:`:sparkles:`,update:`:recycle:`,improve:`:zap:`,optimize:`:zap:`,upgrade:`:arrow_up:`,downgrade:`:arrow_down:`,deploy:`:rocket:`,init:`:tada:`,initial:`:tada:`},bh=(e,t)=>{let n=e.toLowerCase(),r=n.match(/^([a-z]+)(?:\(.*\))?!?:/);if(r){let e=yh[r[1]];if(e)return t.find(t=>t.code===e)||null}let i=yh[n.split(` `)[0]];return i&&t.find(e=>e.code===i)||null},xh=20,Sh=new Map,Ch=(e,t)=>{if(Sh.delete(e),Sh.set(e,t),Sh.size>xh){let e=Sh.keys().next().value;e!==void 0&&Sh.delete(e)}},wh=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/,``),Th=e=>{let t=e.index?.trim();return!!(t&&t!==`?`)},Eh=e=>{let t=e.working_dir?.trim(),n=e.index?.trim();return!!(t||n===`?`)},Dh=({isActive:e})=>{let{t}=Nr(),{git:n,projectScope:r}=Gi(),{generateCommitMessage:i,getGitWorktreeBootstrapStatus:a}=ui(),o=Ki(),[s,c]=Z.useState(null),[l,u]=Z.useState(!1),d=Vn(e=>e.currentSessionId),f=Tn(e=>e.remoteSession?.sessionId??null),p=r?f:d,m=Vn(e=>e.newSessionDraft),h=r?null:m,g=Vn(e=>e.setDraftBootstrapPendingDirectory),_=Vn(e=>e.worktreeMetadata),v=Vn(e=>e.availableWorktrees),y=wh(o),b=Z.useMemo(()=>{if(!y)return;let e=v.find(e=>wh(e.path)===y);if(e)return e;for(let e of _.values())if(wh(e.path)===y)return e},[v,y,_]),x=Z.useMemo(()=>{if(!r){if(p)return _.get(p)??b;if(h?.open)return b}},[p,b,h?.open,_,r]),S=ia(o??null),C=$i(o??null),w=Pn(e=>p&&!r?e.getAttachment(p):void 0),T=w?br(w):[],E=w&&!w.degraded&&!w.legacy?w.worktreeRoot??void 0:void 0,D=Pm(o,x,C?.current??void 0),O=aa(o??null),k=ea(o??null),A=ra(o??null),M=ta(o??null),{setActiveDirectory:N,fetchAll:P,ensureAll:F,fetchStatus:I,fetchBranches:L,fetchLog:R,setLogMaxCount:z,prefetchDiffs:ee,moveStatusPathsOptimistically:B,restoreStatus:te,bumpIndexRevision:ne}=na(pe(e=>({setActiveDirectory:e.setActiveDirectory,fetchAll:e.fetchAll,ensureAll:e.ensureAll,fetchStatus:e.fetchStatus,fetchBranches:e.fetchBranches,fetchLog:e.fetchLog,setLogMaxCount:e.setLogMaxCount,prefetchDiffs:e.prefetchDiffs,moveStatusPathsOptimistically:e.moveStatusPathsOptimistically,restoreStatus:e.restoreStatus,bumpIndexRevision:e.bumpIndexRevision}))),re=K(e=>e.isMobile),ie=K(e=>e.openContextFileDiff),ae=K(e=>e.navigateToDiff),oe=K(e=>e.setRightSidebarOpen),V=Z.useRef(null),H=Z.useRef(null),se=Z.useRef(null),U=Z.useRef(null),ce=Z.useRef(!0);Z.useEffect(()=>()=>{ce.current=!1},[]);let le=Z.useCallback(()=>{H.current!==null&&(window.clearTimeout(H.current),H.current=null)},[]),ue=Z.useCallback(e=>{le(),H.current=window.setTimeout(()=>{H.current=null,wh(e)===wh(o)&&I(e,n,{silent:!0})},gh)},[le,o,I,n]);Z.useEffect(()=>le,[le]);let de=Z.useCallback(()=>{se.current!==null&&(window.clearTimeout(se.current),se.current=null)},[]),fe=Z.useCallback(()=>{se.current===null&&(se.current=window.setTimeout(()=>{se.current=null,U.current?.()},0))},[]),me=Z.useCallback(async(e,t,r)=>{if(t===`stage`){if(n.stageGitFiles){await n.stageGitFiles(e,r);return}await Promise.all(r.map(t=>n.stageGitFile(e,t)));return}if(n.unstageGitFiles){await n.unstageGitFiles(e,r);return}await Promise.all(r.map(t=>n.unstageGitFile(e,t)))},[n]),he=Z.useMemo(()=>hh({runMutation:({directory:e,direction:t,paths:n})=>me(e,t,n),onMutationComplete:({directory:e})=>{ne(e),ue(e)},onMutationError:({directory:e,direction:n,rollback:r},i)=>{r?.(),ne(e),ue(e);let a=t(n===`stage`?`gitView.toast.stageFileFailed`:`gitView.toast.unstageFileFailed`);Y.error(i instanceof Error?i.message:a)},onPathsComplete:e=>{Ge(t=>{let n=new Set(t);return e.forEach(e=>n.delete(e)),n})},scheduleFlush:fe}),[ne,me,fe,ue,t]);Z.useEffect(()=>(U.current=he.flush,()=>{U.current=null}),[he]),Z.useEffect(()=>()=>he.clear(),[he]),Z.useEffect(()=>de,[de]),Z.useEffect(()=>{if(!e)return;if(!o){c(null),u(!1);return}let t=!1;if(r)return a(o).then(e=>{t||c(e.status)}).catch(()=>{t||c(null)}),()=>{t=!0};let n=Qn(o);n&&c(n.status);let i=ar((e,n)=>{t||wh(e)===wh(o)&&c(n.status)});return a(o).then(e=>{if(t)return;lr(o,e);let n=Qn(o);c(n?.status??e.status)}).catch(()=>{!t&&!Qn(o)&&c(null)}),()=>{t=!0,i()}},[e,o,r,a]),Z.useEffect(()=>{let e=V.current;V.current=s,!(!o||!n)&&(e===`pending`&&s===`ready`&&(u(!0),P(o,n).finally(()=>{window.setTimeout(()=>{u(!1)},1200)})),s===`failed`&&(g(null),u(!1)))},[o,P,n,g,s]);let ge=wh(h?.bootstrapPendingDirectory??null),_e=!!(o&&ge&&ge===wh(o)),ve=!!(o&&(s===`pending`||_e))||l,ye=Z.useMemo(()=>o?Sh.get(r?.key??o)??null:null,[o,r]),be=An(e=>e.settingsGitmojiEnabled),[xe,Se]=Z.useState(null),{gitmojis:Ce}=Am(be);Z.useEffect(()=>{let e=E||D?.projectDirectory;if(!e){Se(null);return}let t=!1;return(r?n.getGitStatus(e).then(e=>e.current??``):Bs(e)).then(e=>{if(t)return;let n=e.trim();Se(n&&n!==`HEAD`?n:null)}).catch(()=>{t||Se(null)}),()=>{t=!0}},[E,D?.projectDirectory,r,n]);let[we,Te]=Z.useState(ye?.commitMessage??``),[Ee,De]=Z.useState([]),[Oe,ke]=Z.useState(!1),Ae=li(C)&&!Oe,[je,Me]=Z.useState(!1),Ne=Z.useRef(null),[Pe,Fe]=Z.useState(null),[Ie,W]=Z.useState(!1),[Le,Re]=Z.useState(null),[ze,Be]=Z.useState(25),{triggerFireworks:Ve}=vm(),[He,Ue]=Z.useState(new Set),[We,Ge]=Z.useState(new Set),[Ke,qe]=Z.useState(!1),[Je,Ye]=Z.useState(!1),[Xe,Ze]=Z.useState(ye?.generatedHighlights??[]),Qe=We.size>0||he.size()>0||he.isRunning(),$e=Z.useCallback(()=>{let e=Ne.current;e&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.scrollTo({top:e.scrollHeight,behavior:`smooth`})})})},[]),et=Z.useCallback(()=>{Ze([])},[]),[tt,nt]=Z.useState(new Set),[rt,it]=Z.useState(new Map),[at,ot]=Z.useState(new Set),st=Z.useRef(rt),ct=Z.useRef(at),[lt,ut]=Z.useState(null),[dt,ft]=Z.useState(null),[pt,mt]=Z.useState(``),[ht,gt]=Z.useState(null),[_t,vt]=Z.useState([]),[yt,bt]=Z.useState(!1),[xt,St]=Z.useState([]),[Ct,wt]=Z.useState(`merge`),[Tt,Et]=Z.useState(null),[Dt,Ot]=Z.useState(!1),[kt,At]=Z.useState(100),jt=Z.useMemo(()=>p?`yuri.conflict:${r?j(r.location,p):p}`:null,[p,r]),Mt=Z.useCallback((e,t,n)=>{if(!jt||typeof window>`u`)return;let r={directory:e,conflictFiles:t,operation:n};window.localStorage.setItem(jt,JSON.stringify(r))},[jt]),Nt=Z.useCallback(()=>{!jt||typeof window>`u`||window.localStorage.removeItem(jt)},[jt]);Z.useEffect(()=>{if(!jt||typeof window>`u`||!o)return;let e=window.localStorage.getItem(jt);if(e)try{let t=JSON.parse(e);if(t.directory!==o){window.localStorage.removeItem(jt);return}St(t.conflictFiles??[]),wt(t.operation??`merge`),bt(!0)}catch{window.localStorage.removeItem(jt)}},[jt,o]);let Pt=Z.useCallback(e=>{pr(e).then(e=>{if(e.ok){Y.success(t(`gitView.toast.commitHashCopied`));return}Y.error(t(`gitView.toast.copyFailed`))})},[t]),Ft=Z.useCallback(e=>{nt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);Z.useEffect(()=>{st.current=rt},[rt]),Z.useEffect(()=>{ct.current=at},[at]),Z.useEffect(()=>{if(!o||!n)return;let e=Array.from(tt).filter(e=>!st.current.has(e)&&!ct.current.has(e));if(e.length===0)return;let t=!1;return ot(t=>{let n=new Set(t);for(let t of e)n.add(t);return ct.current=n,n}),Promise.all(e.map(e=>n.getCommitFiles(o,e).then(t=>({hash:e,files:t.files})).catch(t=>(console.error(`Failed to fetch commit files:`,t),{hash:e,files:[]})))).then(e=>{t||(it(t=>{let n=new Map(t);for(let{hash:t,files:r}of e)n.set(t,r);return st.current=n,n}),ot(t=>{let n=new Set(t);for(let{hash:t}of e)n.delete(t);return ct.current=n,n}))}),()=>{t=!0,ot(t=>{let n=!1,r=new Set(t);for(let t of e)r.delete(t)&&(n=!0);return n?(ct.current=r,r):t})}},[tt,o,n]),Z.useEffect(()=>{o&&Ch(r?.key??o,{directory:o,commitMessage:we,generatedHighlights:Xe})},[we,o,Xe,r?.key]),Z.useEffect(()=>{if(!e)return;if(!o||!n?.getRemoteUrl){ft(null);return}let t=!1;return n.getRemoteUrl(o).then(e=>{t||ft(e)}).catch(()=>{t||ft(null)}),()=>{t=!0}},[e,o,n]);let It=Z.useCallback(async()=>{if(!o||!n?.getRemotes){vt([]);return}try{let e=await n.getRemotes(o);ce.current&&vt(e)}catch{ce.current&&vt([])}},[o,n]);Z.useEffect(()=>{e&&It()},[e,It]),Z.useEffect(()=>{e&&o&&(N(o),F(o,n))},[e,o,N,F,n]),Z.useEffect(()=>{if(e&&o)return Nn.onGitRefreshHint(e=>{wh(e.directory)===wh(o)&&I(o,n)})},[e,o,I,n]);let G=Z.useCallback(async(e=!0)=>{if(o)try{await Promise.all([I(o,n),L(o,n,{force:!0})])}catch(n){if(e){let e=n instanceof Error?n.message:t(`gitView.toast.refreshRepositoryFailed`);Y.error(e)}}},[o,n,I,L,t]),Lt=Z.useCallback(async()=>{o&&await R(o,n,ze)},[o,n,R,ze]),Rt=Z.useMemo(()=>!C||Ae?[]:[...C.files??[]].sort((e,t)=>e.path.localeCompare(t.path)),[C,Ae]),zt=Z.useMemo(()=>Rt.filter(Th),[Rt]),Bt=Z.useMemo(()=>Rt.filter(Eh),[Rt]),{deferredStagedCount:Vt,deferredUnstagedCount:Ht}=Z.useMemo(()=>{if(!Ae||!C)return{deferredStagedCount:0,deferredUnstagedCount:0};let e=0,t=0;for(let n of C.files??[])Th(n)&&(e+=1),Eh(n)&&(t+=1);return{deferredStagedCount:e,deferredUnstagedCount:t}},[Ae,C]);Z.useEffect(()=>{if(!o||Rt.length===0)return;let e=[],t=new Set,r=n=>{!n||t.has(n)||(t.add(n),e.push(n))};if(zt.forEach(e=>r(e.path)),Ee.forEach(r),Rt.slice(0,vh).forEach(e=>r(e.path)),e.length===0)return;let i=window.setTimeout(()=>{ee(o,n,e,{maxFiles:_h})},120);return()=>{window.clearTimeout(i)}},[Rt,o,n,ee,zt,Ee]);let Ut=e=>e?.pushed[0]?.remote||C?.tracking?.split(`/`)[0]||$t.find(e=>e.name===`origin`)?.name||$t[0]?.name||`origin`,Wt=async(e,r)=>{if(o){Fe(e);try{let i=e=>{let t=`${e.name}/`,n=C?.tracking?.startsWith(t)?C.tracking.slice(t.length):void 0;return{remote:e.name,branch:n,rebase:!0}};if(e===`fetch`){if(!r)throw Error(`No remote available for fetch`);await n.gitFetch(o,{remote:r.name}),Y.success(t(`gitView.toast.fetchedFromRemote`,{name:r.name}))}else if(e===`pull`){if(!r)throw Error(`No remote available for pull`);let e=await n.gitPull(o,i(r));Y.success(e.files.length===1?t(`gitView.toast.pulledFilesSingle`,{count:e.files.length,name:r.name}):t(`gitView.toast.pulledFilesPlural`,{count:e.files.length,name:r.name}))}else if(e===`push`){let e=await n.gitPush(o);Y.success(t(`gitView.toast.pushedToUpstream`,{name:Ut(e)}))}else if(e===`sync`){if(!r)throw Error(`No remote available for sync`);let e=0,a=!1;await n.gitFetch(o,{remote:r.name});let s=await n.getGitStatus(o);if((s.behind??0)>0){if((s.files?.length??0)>0){Y.error(t(`gitView.toast.commitOrStashBeforeSync`));return}e=(await n.gitPull(o,i(r))).files.length}((await n.getGitStatus(o)).ahead??0)>0&&(await n.gitPush(o),a=!0),e>0&&a?Y.success(t(e===1?`gitView.toast.syncedPulledSingleAndPushed`:`gitView.toast.syncedPulledPluralAndPushed`,{count:e,name:r.name})):e>0?Y.success(t(e===1?`gitView.toast.pulledFilesSingle`:`gitView.toast.pulledFilesPlural`,{count:e,name:r.name})):a?Y.success(t(`gitView.toast.pushedToUpstream`,{name:r.name})):Y.success(t(`gitView.toast.alreadyUpToDate`))}await G(!1),await Lt()}catch(n){let r=n instanceof Error?n.message:t(`gitView.toast.syncActionFailed`,{action:e===`sync`?t(`gitView.sync.syncChanges`):e===`pull`?t(`gitView.sync.pull`):e});Y.error(r)}finally{Fe(null)}}},Gt=async(e={})=>{if(!o)return;if(!we.trim()){Y.error(t(`gitView.toast.enterCommitMessage`));return}let r=zt.map(e=>e.path).sort();if(r.length===0){Y.error(t(`gitView.toast.stageFileToCommit`));return}let i=e.pushAfter?`commitAndPush`:`commit`;Re(i);try{if(await n.createGitCommit(o,we.trim(),{files:r,stageFiles:[]}),ne(o),Y.success(t(`gitView.toast.commitCreated`)),Te(``),et(),await G(),e.pushAfter){let e=C?.tracking?.split(`/`)[0],r=$t.find(t=>t.name===e)??$t[0];if(!r)throw Error(t(`mobile.changes.noRemote`));Fe(`sync`);let i=`${r.name}/`,a=C?.tracking?.startsWith(i)?C.tracking.slice(i.length):void 0;await n.gitFetch(o,{remote:r.name});let s=await n.getGitStatus(o);if((s.behind??0)>0){if((s.files?.length??0)>0){Y.error(t(`gitView.toast.commitOrStashBeforeSync`)),await G(!1);return}await n.gitPull(o,{remote:r.name,branch:a,rebase:!0})}let c=await n.getGitStatus(o),l;(c.ahead??0)>0&&(l=await n.gitPush(o)),Y.success(t(`gitView.toast.pushedToUpstream`,{name:Ut(l)})),Ve(),await G(!1)}else await G(!1);await Lt()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.createCommitFailed`);Y.error(n)}finally{Re(null),e.pushAfter&&Fe(null)}},Kt=Z.useCallback(async()=>{if(!o)return;let e=zt.map(e=>e.path).sort();if(e.length===0){Y.error(t(`gitView.toast.stageFileToDescribe`));return}console.error(`[git-generation][browser] generate button clicked`,{directory:o,selectedFiles:e.length}),Ye(!0);try{let{message:t}=await i(o,e),n=t.subject?.trim()??``,r=Array.isArray(t.highlights)?t.highlights:[];if(n){let e=n;if(be&&Ce.length>0){let t=bh(n,Ce);if(t){let{code:r,emoji:i}=t;!n.startsWith(r)&&!n.startsWith(i)&&(e=`${r} ${n}`)}}Te(e)}Ze(r),$e()}catch(e){console.error(`[git-generation][browser] GitView generate handler failed`,{message:e instanceof Error?e.message:String(e),error:e});let n=e instanceof Error?e.message:t(`gitView.toast.generateCommitMessageFailed`);Y.error(n)}finally{Ye(!1)}},[o,zt,be,Ce,$e,t,i]),qt=e=>e.reason===`attention`?`${e.attentionReason} in progress`:e.reason===`missing`?`worktree is missing`:`worktree is invalid`,Jt=async(e,r)=>{if(!o||!C)return;let i=gr(w);if(i.length>0){Y.error(t(`gitView.toast.cannotCreateBranch`,{reason:qt(i[0])}));return}let a=C.current??null,s=r?.name??`origin`;try{await n.createBranch(o,e,a??`HEAD`),Y.success(t(`gitView.toast.createdBranch`,{name:e})),await n.checkoutBranch(o,e);let r=!1;try{await n.gitPush(o,{remote:s,branch:e,options:[`--set-upstream`]}),r=!0}catch(e){let n=e instanceof Error?e.message:`Unable to push new branch to ${s}.`;Y.warning(t(`gitView.toast.branchCreatedLocally`),{description:(0,$.jsxs)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:[`Upstream setup failed: `,n]})})}await G(),await Lt(),r&&Y.success(t(`gitView.toast.upstreamSet`,{branch:e,remote:s}))}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.createBranchFailed`);throw Y.error(n),e}},Yt=async(e,r)=>{if(!o)return;let i=gr(w);if(i.length>0){Y.error(t(`gitView.toast.cannotRenameBranch`,{reason:qt(i[0])}));return}try{await n.renameBranch(o,e,r),Y.success(t(`gitView.toast.renamedBranch`,{oldName:e,newName:r})),await G(),await Lt()}catch(n){let i=n instanceof Error?n.message:t(`gitView.toast.renameBranchFailed`,{oldName:e,newName:r});Y.error(i)}},Xt=async e=>{if(!o)return;let r=gr(w);if(r.length>0){Y.error(t(`gitView.toast.cannotCheckout`,{reason:qt(r[0])}));return}let i=e.replace(/^remotes\//,``);if(C?.current!==i)try{await n.checkoutBranch(o,i),Y.success(t(`gitView.toast.checkedOut`,{name:i})),await G(),await Lt()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.checkoutFailed`,{name:i});Y.error(n)}},Zt=Z.useMemo(()=>O?.all?O.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[O]),Qt=Z.useMemo(()=>O?.all?O.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[O]),$t=Z.useMemo(()=>{if(_t.length>0)return _t;let e=new Set,t=C?.tracking?.trim();t&&t.includes(`/`)&&e.add(t.split(`/`)[0]);for(let t of Qt){let n=t.indexOf(`/`);n>0&&e.add(t.slice(0,n))}return e.size===0&&dt&&e.add(`origin`),Array.from(e).map(e=>({name:e,fetchUrl:dt??``,pushUrl:dt??``}))},[_t,Qt,dt,C?.tracking]),en=Z.useMemo(()=>{let e=new Set($t.map(e=>e.name)),t=t=>{if(!t)return``;let n=t.trim();if(!n||n===`HEAD`)return``;if(Zt.includes(n))return n;n.startsWith(`refs/heads/`)&&(n=n.slice(11)),n.startsWith(`heads/`)&&(n=n.slice(6)),n.startsWith(`remotes/`)&&(n=n.slice(8));let r=n.indexOf(`/`);if(r>0){let t=n.slice(0,r);if(e.has(t)){let e=n.slice(r+1).trim();e&&(n=e)}}return n};return t(typeof D?.createdFromBranch==`string`?D.createdFromBranch:``)||t(typeof xe==`string`?xe:``)||(Zt.includes(`main`)?`main`:Zt.includes(`master`)?`master`:Zt.includes(`develop`)?`develop`:`main`)},[$t,Zt,xe,D?.createdFromBranch]),tn=zt.length,nn=C?.current??null;Z.useEffect(()=>{if(!o||!n||!k?.all?.length||!nn||!en||nn===en){ut(null);return}let e=!1;return(async()=>{try{let t=await n.getGitLog(o,{from:en,to:`HEAD`,maxCount:ze});if(e)return;let r=new Set((t?.all??[]).map(e=>e.hash).filter(e=>typeof e==`string`&&e.length>0));if(r.size===0){ut(null);return}let i=k.all.findIndex(e=>!r.has(e.hash));if(i===0){ut(null);return}if(i===-1){ut({insertBeforeIndex:k.all.length,branchName:nn,direction:`up`});return}ut({insertBeforeIndex:i,branchName:nn,direction:`up`})}catch{e||ut(null)}})(),()=>{e=!0}},[en,nn,o,n,k,ze]),Z.useEffect(()=>{Et(null)},[o]),Z.useEffect(()=>{if(ht!==`graph`||!o){ht!==`graph`&&Et(null);return}let e=!1;return Ot(!0),n.getGitLog(o,{maxCount:kt,all:!0}).then(t=>{e||Et(t)}).catch(e=>{console.error(`Failed to fetch graph log:`,e)}).finally(()=>{e||Ot(!1)}),()=>{e=!0}},[ht,o,kt,n]);let rn=Z.useCallback((e,t)=>{if(!o||e.length===0)return;let n=Array.from(new Set(e));Ge(e=>{let t=new Set(e);return n.forEach(e=>t.add(e)),t});let r=B(o,n,t);he.enqueue({directory:o,direction:t,paths:new Set(n),rollback:()=>te(o,r)}),fe()},[o,he,B,te,fe]),an=Z.useCallback(async e=>{if(o){Ue(t=>{let n=new Set(t);return n.add(e),n});try{await n.revertGitFile(o,e,{scope:`working`}),Y.success(t(`gitView.toast.revertedFile`,{path:e})),await G(!1)}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.revertFailed`);Y.error(n)}finally{Ue(t=>{let n=new Set(t);return n.delete(e),n})}}},[o,G,n,t]),on=Z.useCallback(async(e,r,i=`all`)=>{if(!o||e.length===0)return;let a=Array.from(new Set(e));if(Ke||a.some(e=>He.has(e)))return;let s=new Set(zt.map(e=>e.path)),c=i===`all`&&a.some(e=>s.has(e));r&&qe(!0),Ue(e=>{let t=new Set(e);return a.forEach(e=>t.add(e)),t});let l=[];try{if(await Promise.all(a.map(async e=>{try{await n.revertGitFile(o,e,{scope:i})}catch(n){l.push({path:e,message:n instanceof Error?n.message:t(`gitView.toast.revertFailed`)})}})),c&&l.length<a.length&&ne(o),await G(!1),l.length===0)Y.success(a.length===1?t(`gitView.toast.revertedFilesSingle`,{count:a.length}):t(`gitView.toast.revertedFilesPlural`,{count:a.length}));else if(l.length===a.length)Y.error(l[0]?.message||t(`gitView.toast.revertFailed`));else{let e=a.length-l.length;Y.warning(t(e===1?`gitView.toast.revertedSomeSingle`:`gitView.toast.revertedSomePlural`,{success:e,failed:l.length}))}}finally{Ue(e=>{let t=new Set(e);return a.forEach(e=>t.delete(e)),t}),r&&qe(!1)}},[ne,o,n,Ke,G,He,zt,t]),sn=Z.useCallback(async e=>{await on(e,!0)},[on]),cn=Z.useCallback(async e=>{await on(e,!1,`working`)},[on]),ln=Z.useCallback((e,t)=>{if(o&&!re){ie(r?.key??o,e,t);return}ae(e,t),re&&oe(!1)},[o,re,ae,ie,oe,r?.key]),un=Z.useCallback(()=>W(!0),[]),dn=Z.useMemo(()=>{let e=[];return zt.length>0&&e.push({id:`staged`,title:t(`gitView.changes.stagedTitle`),entries:zt,actionSymbol:`-`,actionAllLabel:t(`gitView.changes.unstageAllAria`),getActionLabel:e=>t(`gitView.changes.unstageFileAria`,{path:e}),onActionFile:e=>void rn([e],`unstage`),onActionAll:e=>void rn(e,`unstage`),onViewDiff:e=>ln(e,!0),onRevertFile:an,showRevertActions:!1,accent:!0}),Bt.length>0&&e.push({id:`unstaged`,title:t(`gitView.changes.title`),entries:Bt,actionSymbol:`+`,actionAllLabel:t(`gitView.changes.stageAllAria`),getActionLabel:e=>t(`gitView.changes.stageFileAria`,{path:e}),onActionFile:e=>void rn([e],`stage`),onActionAll:e=>void rn(e,`stage`),onViewDiff:e=>ln(e,!1),onRevertFile:an}),e},[an,ln,rn,zt,t,Bt]),fn=Z.useCallback(e=>{if(e.length===0)return;let t=e.map(e=>e.trim()).filter(Boolean);if(t.length===0){et();return}Te(e=>{let n=e.trim();return`${n}${n.length>0?`
15
+
16
+ `:``}${t.join(`
17
+ `)}`.trim()}),et()},[et]),pn=Z.useCallback((e,t)=>{let n=t||e;Te(r=>{let i=r.trimStart();return i.startsWith(e)||t&&i.startsWith(t)?r:`${n.endsWith(` `)?n:`${n} `}${r}`.trimStart()}),mt(``),Me(!1)},[]),mn=Z.useCallback(async()=>{if(o)try{Ct===`merge`?(await n.abortMerge(o),Y.success(t(`gitView.toast.mergeAborted`))):(await n.abortRebase(o),Y.success(t(`gitView.toast.rebaseAborted`))),Nt(),await G(),await Lt()}catch(e){let t=e instanceof Error?e.message:`Failed to abort ${Ct}`;Y.error(t)}},[o,n,Ct,G,Lt,Nt,t]),hn=Z.useMemo(()=>C?.files?C.files.some(e=>e.index===`U`||e.working_dir===`U`||e.index===`A`&&e.working_dir===`A`||e.index===`D`&&e.working_dir===`D`):!1,[C?.files]),gn=Z.useCallback(async()=>{if(o)try{let e=!!C?.mergeInProgress?.head,r=!!(C?.rebaseInProgress?.headName||C?.rebaseInProgress?.onto);if(e){let e=await n.continueMerge(o);e.conflict?(St(e.conflictFiles??[]),wt(`merge`),bt(!0),Mt(o,e.conflictFiles??[],`merge`),Y.error(t(`gitView.toast.mergeConflictsDetected`))):(Nt(),Y.success(t(`gitView.toast.mergeCompleted`)),await G(),await Lt())}else if(r){let e=await n.continueRebase(o);e.conflict?(St(e.conflictFiles??[]),wt(`rebase`),bt(!0),Mt(o,e.conflictFiles??[],`rebase`),Y.error(t(`gitView.toast.rebaseConflictsDetected`))):(Nt(),Y.success(t(`gitView.toast.rebaseStepCompleted`)),await G(),await Lt())}}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.continueOperationFailed`);Y.error(n)}},[o,n,C,G,Lt,Mt,Nt,t]),_n=Z.useCallback(async()=>{if(o)try{C?.mergeInProgress?.head?(await n.abortMerge(o),Y.success(t(`gitView.toast.mergeAborted`))):(await n.abortRebase(o),Y.success(t(`gitView.toast.rebaseAborted`))),Nt(),await G(),await Lt()}catch(e){let n=e instanceof Error?e.message:t(`gitView.toast.abortOperationFailed`);Y.error(n)}},[o,n,C,G,Lt,Nt,t]),vn=Z.useCallback(()=>{if(!o)return;let e=C?.mergeInProgress?.head?`merge`:`rebase`,t=C?.files?.filter(e=>e.index===`U`||e.working_dir===`U`).map(e=>e.path)??[];t.length>0&&St(t),wt(e),bt(!0)},[o,C]),yn=Z.useCallback(e=>{Be(e),o&&(z(o,e),R(o,n,e))},[o,R,n,z]),bn=Z.useCallback(e=>{At(e)},[]),xn=Z.useCallback(()=>{gt(null),o&&(I(o,n),L(o,n,{force:!0}),R(o,n,ze))},[o,I,L,R,ze,n]),Sn=Z.useCallback(e=>{if(e.conflict){if(e.operation===`cherry-pick`||e.operation===`revert`){Y.error(t(`gitView.history.actions.conflictToastTitle`),{description:t(`gitView.history.actions.conflictToastDescription`,{files:e.conflictFiles?.join(`, `)??`unknown files`})}),o&&(I(o,n),L(o,n,{force:!0}),R(o,n,ze));return}St(e.conflictFiles??[]),wt(e.operation),bt(!0),o&&Mt(o,e.conflictFiles??[],e.operation)}},[t,St,wt,bt,Mt,o,I,L,R,ze,n]);if(!o)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-center`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:t(`gitView.empty.selectSessionOrDirectory`)})});if(S===null||S===!0&&!C)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-ui-label`,children:t(`gitView.loading.checkingRepository`)})]})});if(S===!1)return ve?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-4 text-center`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`mb-3 size-6 animate-spin text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:t(`gitView.empty.worktreeSetupInProgress`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 text-muted-foreground`,children:t(`gitView.empty.worktreeSetupDescription`)})]}):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center px-4 text-center`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`mb-3 size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold text-foreground`,children:t(`gitView.empty.notGitRepository`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 text-muted-foreground`,children:t(`gitView.empty.notGitRepositoryDescription`)}),T.includes(`open-without-worktree-features`)?(0,$.jsx)(`p`,{className:`typography-meta mt-2 text-muted-foreground`,children:t(`gitView.empty.worktreeFeaturesUnavailable`)}):null]});let Cn=C?D?(0,$.jsx)(tl,{currentBranch:C.current,onRename:Yt,iconOnly:!0}):(0,$.jsx)(cs,{currentBranch:C.current,localBranches:Zt,remoteBranches:Qt,branchInfo:O?.branches,onCheckout:Xt,onCreate:Jt,remotes:$t,iconOnly:!0}):null,wn=C?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(pi,{syncAction:Pe,remotes:$t,onSync:e=>Wt(`sync`,e),disabled:!C,aheadCount:C.ahead,behindCount:C.behind,trackingRemoteName:C.tracking?.split(`/`)[0],hasUncommittedChanges:(C.files?.length??0)>0}),(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.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)]`,"aria-label":t(`gitView.header.repositoryViews`),children:(0,$.jsx)(X,{name:`git-repository`,className:`size-3.5`})})})}),(0,$.jsx)(ei,{sideOffset:8,children:t(`gitView.header.repositoryViews`)})]}),(0,$.jsxs)(bi,{align:`end`,children:[(0,$.jsxs)(xi,{onSelect:()=>gt(`history`),children:[(0,$.jsx)(X,{name:`history`,className:`size-4`}),t(`gitView.history.title`)]}),(0,$.jsxs)(xi,{onSelect:()=>gt(`graph`),children:[(0,$.jsx)(X,{name:`git-merge`,className:`size-4`}),t(`gitView.graph.title`)]}),(0,$.jsxs)(xi,{onSelect:un,children:[(0,$.jsx)(X,{name:`archive-stack`,className:`size-4`}),t(`gitView.stashes.title`)]})]})]})]}):null,En=C?(0,$.jsxs)($.Fragment,{children:[Cn,wn]}):null;return(0,$.jsxs)(`div`,{className:J(`flex h-full flex-col overflow-hidden`),children:[o&&(C?.mergeInProgress?.head||C?.rebaseInProgress?.headName||C?.rebaseInProgress?.onto)&&(0,$.jsx)(mh,{mergeInProgress:C?.mergeInProgress,rebaseInProgress:C?.rebaseInProgress,onContinue:gn,onAbort:_n,onResolveWithAI:vn,hasUnresolvedConflicts:hn,isLoading:A}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full min-h-0 flex flex-col`,children:(0,$.jsx)(`div`,{className:J(`min-w-0 min-h-0 h-full flex flex-col`),children:(0,$.jsx)(Wr,{as:Ur,ref:Ne,outerClassName:`flex-1 min-h-0`,className:re?`px-4 pt-2 pb-4`:`px-2 pt-0 pb-0`,disableHorizontal:!0,preventOverscroll:!0,children:(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col gap-2`,children:Ae?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center bg-background pr-2`,children:[(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate font-semibold text-foreground`,re?`typography-ui-label`:`text-xs leading-4`),children:t(`gitView.changes.deferredTitle`,{count:C?.files?.length??0})}),(0,$.jsx)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:En})]}),(0,$.jsx)(si,{stagedCount:Vt,unstagedCount:Ht,onLoad:()=>ke(!0)})]}):(Rt?.length??0)>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,$.jsx)(oi,{compact:!re,groups:dn,diffStats:C?.diffStats,revertingPaths:He,isRevertingAll:Ke,onVisiblePathsChange:De,onRevertAll:sn,onRevertDirectory:cn,headerBackgroundClassName:`bg-background`,headerLeadingActions:Cn,headerActions:wn})}),(0,$.jsx)(ci,{compact:!re,stagedCount:tn,commitMessage:we,onCommitMessageChange:Te,generatedHighlights:Xe,onInsertHighlights:fn,onGenerateMessage:Kt,isGeneratingMessage:Je,onCommit:()=>Gt({pushAfter:!1}),onCommitAndPush:()=>Gt({pushAfter:!0}),commitAction:Le,hasPendingIndexMutation:Qe,gitmojiEnabled:be,onOpenGitmojiPicker:()=>Me(!0)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex h-8 shrink-0 items-center bg-background pr-2`,children:[(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate font-semibold text-foreground`,re?`typography-ui-label`:`text-xs leading-4`),children:t(`gitView.empty.cleanTitle`)}),(0,$.jsx)(`div`,{className:`ml-auto grid shrink-0 grid-flow-col auto-cols-[1.5rem] items-center justify-end`,children:En})]}),(0,$.jsx)(Lm,{onOpenStashes:()=>W(!0)})]})})})})})}),(0,$.jsx)(Qr,{open:ht!==null,onOpenChange:e=>{e||gt(null)},children:(0,$.jsxs)(Yr,{className:`max-w-5xl h-[90vh] max-h-[90vh] flex flex-col overflow-hidden`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:t(ht===`graph`?`gitView.graph.title`:`gitView.history.title`)}),(0,$.jsx)(Zr,{children:t(`gitView.history.dialogDescription`)})]}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0`,children:(0,$.jsx)(nh,{mode:ht===`graph`?`graph`:`history`,log:ht===`graph`?Tt??k:k,isLogLoading:ht===`graph`&&Dt||M,logMaxCount:ht===`graph`?kt:ze,onLogMaxCountChange:ht===`graph`?bn:yn,expandedCommitHashes:tt,onToggleCommit:Ft,commitFilesMap:rt,loadingCommitHashes:at,onCopyHash:Pt,directory:o??void 0,showHeader:!1,contentMaxHeightClassName:`h-full max-h-none`,branchDivider:ht===`graph`?null:lt,onConflict:ht===`graph`?Sn:void 0,onActionSuccess:ht===`graph`?xn:void 0})})]})}),(0,$.jsx)(Fm,{open:Ie,onOpenChange:W,directory:o,hasUncommittedChanges:(C?.files?.length??0)>0,hasStagedChanges:zt.length>0,uncommittedFileCount:C?.files?.length??0,onChanged:async e=>{o&&e?.affectsIndex&&ne(o),await G(!1),await Lt()}}),(0,$.jsx)(Qr,{open:je,onOpenChange:Me,children:(0,$.jsxs)(Yr,{className:`max-w-md p-0 overflow-hidden`,children:[(0,$.jsx)(qr,{className:`px-4 pt-4`,children:(0,$.jsx)(Xr,{children:t(`gitView.gitmoji.title`)})}),(0,$.jsxs)(ss,{className:`h-[420px]`,children:[(0,$.jsx)(os,{placeholder:t(`gitView.gitmoji.searchPlaceholder`),value:pt,onValueChange:mt}),(0,$.jsxs)(ls,{children:[(0,$.jsx)(us,{children:t(`gitView.gitmoji.empty`)}),(0,$.jsx)(hs,{children:(Ce.length===0?[]:Ce.filter(e=>{let t=pt.trim().toLowerCase();return!t||e.emoji.includes(t)||e.code.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)})).map(e=>(0,$.jsxs)(ms,{onSelect:()=>pn(e.emoji,e.code),children:[(0,$.jsx)(`span`,{className:`text-lg`,children:e.emoji}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e.code}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e.description})]},e.code))})]})]})]})}),o&&(0,$.jsx)(sh,{open:yt,onOpenChange:bt,conflictFiles:xt,directory:o,operation:Ct,onAbort:mn,onClearState:Nt})]})},Oh=1,kh=8e3,Ah={refreshAuth:()=>i(),clearUrlAuthToken:r,openSocket:e=>He(l().websocket(Eo(e)))},jh=class{providerId;handlers;dependencies;socket=null;pendingFrame=null;reconnectTimer=null;failures=0;generation=0;disposed=!1;ended=!1;constructor(e,t,n=Ah){this.providerId=e,this.handlers=t,this.dependencies=n}start(){this.handlers.onConnection({status:`connecting`}),this.connect()}dispose(){this.disposed=!0,this.generation+=1,this.cancelReconnect();let e=this.socket;this.socket=null,e?.close()}ack(e){this.send({type:`ack`,seq:e})}sendInput(e){return e.length!==0&&this.send({type:`input`,events:e})}release(){this.send({type:`release`})}resize(e,t){e<1||t<1||this.send({type:`resize`,width:Math.round(e),height:Math.round(t)})}retry(){this.disposed||(this.ended=!1,this.failures=0,this.generation+=1,this.socket?.close(),this.socket=null,this.handlers.onConnection({status:`connecting`}),this.connect())}send(e){let t=this.socket;if(!t||t.readyState!==Oh)return!1;try{return t.send(JSON.stringify(e)),!0}catch{return!1}}async connect(){if(this.disposed||this.ended)return;let e=this.generation;try{await this.dependencies.refreshAuth()}catch{this.scheduleReconnect();return}if(e!==this.generation||this.disposed||this.ended)return;let t;try{t=this.dependencies.openSocket(this.providerId)}catch{this.scheduleReconnect();return}t.binaryType=`arraybuffer`,this.socket=t;let n=!1;t.onopen=()=>{this.socket===t&&(n=!0,this.failures=0,this.pendingFrame=null,this.handlers.onConnection({status:`open`}))},t.onmessage=e=>{this.socket===t&&this.handleMessage(e.data)},t.onerror=()=>{this.dependencies.clearUrlAuthToken()},t.onclose=()=>{this.socket===t&&(this.socket=null),!(this.disposed||this.ended)&&(n&&(this.failures=Math.max(this.failures,1)),this.scheduleReconnect())}}handleMessage(e){if(e instanceof ArrayBuffer){let t=this.pendingFrame;if(this.pendingFrame=null,!t||e.byteLength!==t.bytes)return;this.handlers.onFrame({...t,bytes:e});return}if(typeof e!=`string`)return;let t;try{t=JSON.parse(e)}catch{return}let n=Oo(t);n&&this.applyHostMessage(n)}applyHostMessage(e){if(e.type===`frame`){this.pendingFrame=e;return}if(e.type===`control`){this.handlers.onControl({controller:e.controller,mine:e.mine});return}e.type===`ended`&&(this.ended=!0,this.cancelReconnect(),this.handlers.onConnection({status:`ended`,reason:e.reason}),this.handlers.onEnded?.(e.reason),this.socket?.close())}scheduleReconnect(){if(this.disposed||this.ended||this.reconnectTimer)return;this.failures+=1;let e=this.failures;this.handlers.onConnection({status:`reconnecting`,attempt:e});let t=Math.min(kh,250*2**Math.min(e,5));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}cancelReconnect(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}},Mh=250,Nh=e=>({alt:e.altKey,ctrl:e.ctrlKey,meta:e.metaKey,shift:e.shiftKey}),Ph=e=>(e.metaKey||e.ctrlKey)&&!e.altKey&&e.key.toLowerCase()===`v`,Fh=(e,t)=>new jh(e,t),Ih=({provider:e,clientFactory:t=Fh})=>{let{t:n}=Nr(),r=Z.useRef(null),i=Z.useRef(null),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef([]),c=Z.useRef(null),l=Z.useRef({controller:`none`,mine:!1}),u=Z.useRef(null),[d,f]=Z.useState({status:`connecting`}),[p,m]=Z.useState({controller:`none`,mine:!1}),[h,g]=Z.useState(``),[_,v]=Z.useState(!1),[y,b]=Z.useState(!1),[x,S]=Z.useState(!1),C=G(e=>{l.current=e,m(e)}),w=G(async e=>{let t=i.current,n=a.current;if(!(!t||!n))try{let n=await createImageBitmap(new Blob([e.bytes],{type:e.mime}));(t.width!==e.width||t.height!==e.height)&&(t.width=e.width,t.height=e.height),t.getContext(`2d`)?.drawImage(n,0,0,e.width,e.height),n.close(),o.current={width:e.width,height:e.height},b(!0),g(e.title??``),v(e.agentActive)}catch{}finally{n.ack(e.seq)}}),T=Z.useRef({onFrame:e=>{w(e)},onControl:C,onConnection:f});T.current={onFrame:e=>{w(e)},onControl:C,onConnection:f};let E=Z.useRef(t);E.current=t,Z.useEffect(()=>{if(!e.surface)return;let t=E.current(e.id,{onFrame:e=>{T.current.onFrame(e)},onControl:e=>{T.current.onControl(e)},onConnection:e=>{T.current.onConnection(e)}});return a.current=t,t.start(),()=>{t.dispose(),a.current===t&&(a.current=null),c.current!==null&&cancelAnimationFrame(c.current),c.current=null,s.current=[],o.current=null,b(!1),f({status:`connecting`}),C({controller:`none`,mine:!1})}},[e.id,e.surface,C]);let D=G(()=>{let t=r.current;!t||!e.surface||(u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{u.current=null;let e=t.getBoundingClientRect(),n=window.devicePixelRatio||1,r=Math.round(e.width*n),i=Math.round(e.height*n);r>0&&i>0&&a.current?.resize(r,i)},Mh))});It(e.surface?r:null,D);let O=G(e=>{s.current.push(e),c.current===null&&(c.current=requestAnimationFrame(()=>{c.current=null;let e=s.current;s.current=[],a.current?.sendInput(e)}))}),k=e=>{let t=i.current,n=o.current;if(!t||!n)return null;let r=t.getBoundingClientRect();return r.width===0||r.height===0?null:{x:Math.round((e.clientX-r.left)/r.width*n.width),y:Math.round((e.clientY-r.top)/r.height*n.height)}},A=e=>t=>{if(!y||e===`move`&&t.buttons===0&&!(l.current.controller===`user`&&l.current.mine))return;let n=k(t);n&&(e===`down`?(r.current?.focus(),t.currentTarget.setPointerCapture(t.pointerId)):e===`up`&&t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),t.preventDefault(),O({type:`pointer`,action:e,x:n.x,y:n.y,button:e===`move`?-1:t.button,buttons:t.buttons,modifiers:Nh(t)}))},j=e=>{if(!y)return;let t=k(e);t&&(e.preventDefault(),O({type:`wheel`,x:t.x,y:t.y,deltaX:e.deltaX,deltaY:e.deltaY,modifiers:Nh(e)}))},M=e=>t=>{!y||Ph(t)||(t.preventDefault(),t.stopPropagation(),O({type:`key`,action:e,key:t.key,code:t.code,modifiers:Nh(t)}))},N=e=>{if(!y)return;let t=e.clipboardData.getData(`text/plain`);e.preventDefault(),t&&O({type:`text`,text:t})},P=G(()=>{a.current?.release()}),F=G(()=>{a.current?.retry()});if(!e.surface)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(`layout.browserProvider.noSurface`,{name:e.name})});let I=d.status===`connecting`?`layout.browserProvider.status.connecting`:d.status===`reconnecting`?`layout.browserProvider.status.reconnecting`:d.status===`ended`?d.reason===`service-stopped`?`layout.browserProvider.ended.service-stopped`:d.reason===`extension-unavailable`?`layout.browserProvider.ended.extension-unavailable`:`layout.browserProvider.ended.host-shutdown`:p.controller===`user`?p.mine?`layout.browserProvider.status.youControl`:`layout.browserProvider.status.otherControls`:p.controller===`agent`||_?`layout.browserProvider.status.agentWorking`:x?`layout.browserProvider.status.readyFocused`:`layout.browserProvider.status.ready`,L=p.controller===`user`&&p.mine;return(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center gap-2 border-b border-border px-3`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-foreground`,title:h||e.name,children:h||e.name}),(0,$.jsx)(`span`,{className:J(`shrink-0 truncate text-xs`,L?`text-foreground`:`text-muted-foreground`),"aria-live":`polite`,children:n(I)}),L?(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:P,children:n(`layout.browserProvider.handBack`)}):null,d.status===`ended`?(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:F,children:n(`layout.browserProvider.retry`)}):null]}),(0,$.jsxs)(`div`,{ref:r,tabIndex:0,role:`application`,"aria-label":n(`layout.browserProvider.canvasAria`,{name:e.name}),className:J(`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden outline-none`,x&&`ring-1 ring-inset ring-[var(--interactive-selection-border)]`),onFocus:()=>S(!0),onBlur:()=>S(!1),onKeyDown:M(`down`),onKeyUp:M(`up`),onPaste:N,children:[(0,$.jsx)(`canvas`,{ref:i,className:J(`max-h-full max-w-full`,y?`block`:`hidden`,p.controller===`user`&&!p.mine?`cursor-not-allowed`:`cursor-default`),onPointerDown:A(`down`),onPointerMove:A(`move`),onPointerUp:A(`up`),onWheel:j,onContextMenu:e=>e.preventDefault()}),!y||d.status!==`open`?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:n(d.status===`ended`?d.reason===`service-stopped`?`layout.browserProvider.ended.service-stopped`:d.reason===`extension-unavailable`?`layout.browserProvider.ended.extension-unavailable`:`layout.browserProvider.ended.host-shutdown`:d.status===`reconnecting`?`layout.browserProvider.status.reconnecting`:`layout.browserProvider.status.connecting`)}):null]})]})},Lh=e=>e.slice().sort((e,t)=>e.type===t.type?e.name.localeCompare(t.name):e.type===`directory`?-1:1),Rh=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},zh=(e,t)=>{let n=Rh(t),r=Rh(e).replace(/\/+$/,``);return n===r?`.`:!r||!n.startsWith(`${r}/`)?n:n.slice(r.length+1)},Bh=e=>e.startsWith(`/`)||e.startsWith(`//`)||/^[A-Za-z]:\//.test(e),Vh=new Set([`node_modules`]),Hh=e=>Vh.has(e),Uh=e=>{let t=Rh(e);return t===`node_modules`||t.endsWith(`/node_modules`)||t.includes(`/node_modules/`)},Wh=8,Gh=new Map,Kh=e=>{let t=Gh.get(e);return t?(t.touchedAt=Date.now(),Gh.delete(e),Gh.set(e,t),t):null},qh=e=>{let t=Gh.get(e);if(t)return t.touchedAt=Date.now(),t;if(Gh.size>=Wh){let e=Gh.keys().next().value;e!==void 0&&Gh.delete(e)}let n={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Gh.set(e,n),n},Jh=e=>{Gh.delete(e)},Yh=(e,t)=>(0,$.jsx)(ri,{filePath:e,extension:t,className:`size-3.5`}),Xh=e=>{let t=(0,Q.c)(3),{status:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={open:`var(--status-info)`,modified:`var(--status-warning)`,"git-modified":`var(--status-warning)`,"git-added":`var(--status-success)`,"git-deleted":`var(--status-error)`},t[0]=r):r=t[0];let i=r[n],a;return t[1]===i?a=t[2]:(a=(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:i}}),t[1]=i,t[2]=a),a},Zh=Z.memo(e=>{let t=(0,Q.c)(73),{node:n,root:r,isExpanded:i,isActive:a,status:o,badge:s,permissions:c,downloadFile:l,onSelect:u,onToggle:d,onRevealPath:f,onOpenDialog:p}=e,{t:m}=Nr(),h=n.type===`directory`,{canRename:g,canCreateFile:_,canCreateFolder:v,canDelete:y,canReveal:b}=c,[x,S]=Z.useState(!1),[C,w]=Z.useState(!1),T;t[0]!==_||t[1]!==v||t[2]!==y||t[3]!==g||t[4]!==b?(T=e=>{!g&&!_&&!v&&!y&&!b||(e?.preventDefault(),w(!0))},t[0]=_,t[1]=v,t[2]=y,t[3]=g,t[4]=b,t[5]=T):T=t[5];let E=T,D;t[6]!==h||t[7]!==n||t[8]!==u||t[9]!==d?(D=()=>{h?d(n.path):u(n)},t[6]=h,t[7]=n,t[8]=u,t[9]=d,t[10]=D):D=t[10];let O=D,k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{e.stopPropagation(),w(!1),S(!0)},t[11]=k):k=t[11];let A=k,j;t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==g||t[16]!==b||t[17]!==l||t[18]!==h||t[19]!==n||t[20]!==p||t[21]!==f||t[22]!==m?(j=e=>{let{Item:t,Separator:r}=e;return(0,$.jsxs)($.Fragment,{children:[g&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`rename`,n)},children:[(0,$.jsx)(X,{name:`edit`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.rename`)]}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),pr(n.path).then(e=>{e.ok||Y.error(m(`sidebarFilesTree.toast.copyFailed`))})},children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.copyPath`)]}),!h&&l&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),l(n.path).catch(e=>{console.error(`Download failed:`,e),Y.error(m(`sidebarFilesTree.toast.operationFailed`))})},children:[(0,$.jsx)(X,{name:`download`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.save`)]}),b&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),f(n.path)},children:[(0,$.jsx)(X,{name:`folder-received`,className:`mr-2 h-4 w-4`}),` `,m(nr())]}),h&&(_||v)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(r,{}),_&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`createFile`,n)},children:[(0,$.jsx)(X,{name:`file-add`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.newFile`)]}),v&&(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`createFolder`,n)},children:[(0,$.jsx)(X,{name:`folder-add`,className:`mr-2 h-4 w-4`}),` `,m(`sidebarFilesTree.menu.newFolder`)]})]}),y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(r,{}),(0,$.jsxs)(t,{onClick:e=>{e.stopPropagation(),p(`delete`,n)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-2 h-4 w-4 text-inherit`}),` `,m(`sidebarFilesTree.menu.delete`)]})]})]})},t[12]=_,t[13]=v,t[14]=y,t[15]=g,t[16]=b,t[17]=l,t[18]=h,t[19]=n,t[20]=p,t[21]=f,t[22]=m,t[23]=j):j=t[23];let M=j,N;t[24]!==n.path||t[25]!==r?(N=e=>{let t=zh(r,n.path);!t||t===`.`||(e.dataTransfer.setData(`application/x-yuri-file-path`,t),e.dataTransfer.effectAllowed=`copy`)},t[24]=n.path,t[25]=r,t[26]=N):N=t[26];let P=N,F;t[27]===E?F=t[28]:(F=(0,$.jsx)(`div`,{className:`group relative flex items-center`,onContextMenu:E}),t[27]=E,t[28]=F);let I=a?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`,L;t[29]===I?L=t[30]:(L=J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none`,I,`cursor-grab active:cursor-grabbing`),t[29]=I,t[30]=L);let R;t[31]!==h||t[32]!==i||t[33]!==n.extension||t[34]!==n.path?(R=h?i?(0,$.jsx)(X,{name:`folder-open-fill`,className:`size-3.5 flex-shrink-0 text-muted-foreground`}):(0,$.jsx)(X,{name:`folder-3-fill`,className:`size-3.5 flex-shrink-0 text-muted-foreground`}):Yh(n.path,n.extension),t[31]=h,t[32]=i,t[33]=n.extension,t[34]=n.path,t[35]=R):R=t[35];let z;t[36]!==n.name||t[37]!==n.path?(z=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code`,title:n.path,children:n.name}),t[36]=n.name,t[37]=n.path,t[38]=z):z=t[38];let ee;t[39]!==h||t[40]!==o?(ee=!h&&o&&(0,$.jsx)(Xh,{status:o}),t[39]=h,t[40]=o,t[41]=ee):ee=t[41];let B;t[42]!==s||t[43]!==h?(B=h&&s&&(0,$.jsxs)(`span`,{className:`text-xs flex items-center gap-1 ml-auto mr-1`,children:[s.modified>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-warning)]`,children:[`M`,s.modified]}),s.added>0&&(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,s.added]})]}),t[42]=s,t[43]=h,t[44]=B):B=t[44];let te;t[45]!==E||t[46]!==P||t[47]!==O||t[48]!==z||t[49]!==ee||t[50]!==B||t[51]!==L||t[52]!==R?(te=(0,$.jsxs)(`button`,{type:`button`,onClick:O,onContextMenu:E,draggable:!0,onDragStart:P,className:L,children:[R,z,ee,B]}),t[45]=E,t[46]=P,t[47]=O,t[48]=z,t[49]=ee,t[50]=B,t[51]=L,t[52]=R,t[53]=te):te=t[53];let ne;t[54]!==_||t[55]!==v||t[56]!==y||t[57]!==g||t[58]!==b||t[59]!==x||t[60]!==M||t[61]!==m?(ne=(g||_||v||y||b)&&(0,$.jsx)(`div`,{className:`absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100`,children:(0,$.jsxs)(Ci,{open:x,onOpenChange:S,children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:A,title:m(`sidebarFilesTree.actions.fileMenuTitle`),"aria-label":m(`sidebarFilesTree.actions.fileMenuTitle`),children:(0,$.jsx)(X,{name:`more-2-fill`,className:`h-4 w-4`})})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:m(`sidebarFilesTree.actions.fileMenuTitle`)})]}),(0,$.jsx)(bi,{align:`end`,side:`bottom`,onCloseAutoFocus:()=>S(!1),children:M({Item:xi,Separator:Si})})]})}),t[54]=_,t[55]=v,t[56]=y,t[57]=g,t[58]=b,t[59]=x,t[60]=M,t[61]=m,t[62]=ne):ne=t[62];let re;t[63]!==te||t[64]!==ne||t[65]!==F?(re=(0,$.jsxs)(wi,{render:F,children:[te,ne]}),t[63]=te,t[64]=ne,t[65]=F,t[66]=re):re=t[66];let ie;t[67]===M?ie=t[68]:(ie=(0,$.jsx)(Ei,{className:`min-w-[180px]`,children:M({Item:Di,Separator:Ti})}),t[67]=M,t[68]=ie);let ae;return t[69]!==C||t[70]!==re||t[71]!==ie?(ae=(0,$.jsxs)(Oi,{open:C,onOpenChange:w,children:[re,ie]}),t[69]=C,t[70]=re,t[71]=ie,t[72]=ae):ae=t[72],ae},(e,t)=>e.node===t.node&&e.root===t.root&&e.isExpanded===t.isExpanded&&e.isActive===t.isActive&&e.status===t.status&&e.badge===t.badge&&e.permissions===t.permissions&&e.downloadFile===t.downloadFile&&e.onSelect===t.onSelect&&e.onToggle===t.onToggle&&e.onRevealPath===t.onRevealPath&&e.onOpenDialog===t.onOpenDialog),Qh=()=>{let{t:e}=Nr(),{files:t}=Gi(),n=bt(),r=n?.entry,i=Ui()??``,a=Rh(i.trim()),o=r?.key??a,s=n?.entry.location.hostId?JSON.stringify([n.entry.queryScope,a]):a,c=Be(),l=Re(),u=ze(e=>e.searchFiles),d=K(e=>e.openContextFile),f=$i(i),[p,m]=Z.useState(``),h=Aa(p,200),g=Z.useRef(null),[_,v]=Z.useState([]),[y,b]=Z.useState(!1),[x,S]=Z.useState({}),[C,w]=Z.useState({}),T=Z.useRef(new Set),E=Z.useRef(new Set),D=Z.useRef(null),O=Z.useRef(!1);Z.useEffect(()=>{if(!a){S({}),w({}),T.current=new Set;return}let e=Kh(s);e?(S({...e.childrenByDir}),w({...e.loadErrorsByDir}),T.current=new Set(e.loadedDirs)):(S({}),w({}),T.current=new Set)},[a,s]),Z.useEffect(()=>{if(!a)return;let e=qh(s);e.childrenByDir=x},[a,s,x]),Z.useEffect(()=>{if(!a)return;let e=qh(s);e.loadErrorsByDir=C},[a,s,C]),Z.useEffect(()=>{if(!a)return;let e=qh(s);e.loadedDirs=new Set(T.current)},[a,s,x,C]),Z.useEffect(()=>()=>{if(!a)return;let e=Gh.get(s);e&&e.loadedDirs.size===0&&Object.keys(e.childrenByDir).length===0&&Jh(s)},[a,s]);let k=Z.useMemo(()=>[],[]),A=Z.useMemo(()=>[],[]),j=Bo(e=>a?e.byRoot[o]?.expandedPaths??k:k),M=Bo(e=>a?e.byRoot[o]?.selectedPath??null:null),N=Bo(e=>e.setSelectedPath),P=Bo(e=>e.addOpenPath),F=Bo(e=>e.removeOpenPathsByPrefix),I=Bo(e=>e.removeExpandedPathsByPrefix),L=Bo(e=>e.toggleExpandedPath),R=Bo(e=>e.expandPaths),z=K(e=>a?e.contextPanelByDirectory[o]?.tabs??A:A),ee=Z.useMemo(()=>new Set(z.map(e=>e.mode===`file`?e.targetPath:null).filter(e=>typeof e==`string`&&e.length>0).map(e=>Rh(e))),[z]),[B,te]=Z.useState(null),[ne,re]=Z.useState(null),[ie,ae]=Z.useState(``),[oe,V]=Z.useState(!1),H=!!t.writeFile,se=!!t.createDirectory,U=!!t.rename,ce=!!t.delete,le=!!t.revealPath,ue=Z.useMemo(()=>({canRename:U,canCreateFile:H,canCreateFolder:se,canDelete:ce,canReveal:le}),[U,H,se,ce,le]),de=Z.useCallback(n=>{t.revealPath&&t.revealPath(n).catch(()=>{Y.error(e(`sidebarFilesTree.toast.revealFailed`))})},[t,e]),fe=Z.useCallback((e,t)=>{te(e),re(t),ae(e===`rename`&&t.name||``),V(!1)},[]),pe=Z.useCallback((e,t)=>Lh(t.filter(e=>e&&typeof e.name==`string`&&e.name.length>0).filter(e=>c||!e.name.startsWith(`.`)).filter(e=>l||!Hh(e.name)).map(t=>{let n=t.name,r=Rh(t.path||``),i=r?Bh(r)?r:Rh(`${e}/${r}`):Rh(`${e}/${n}`),a=t.isDirectory?`directory`:`file`;return{name:n,path:i,type:a,extension:a===`file`&&n.includes(`.`)?n.split(`.`).pop()?.toLowerCase():void 0}})),[l,c]),me=Z.useCallback(async(e,n)=>{let i=Rh(e.trim());if(!i||T.current.has(i)||E.current.has(i))return;E.current=new Set(E.current),E.current.add(i);let a=t.listDirectory?t.listDirectory(i).then(e=>e.entries.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory}))):(r?.service()??rt).listLocalDirectory(i).then(e=>e.map(e=>({name:e.name,path:e.path,isDirectory:e.isDirectory})));try{let e=await a;if(n?.())return;let t=pe(i,e);T.current=new Set(T.current),T.current.add(i),w(e=>{if(!e[i])return e;let t={...e};return delete t[i],t}),S(e=>({...e,[i]:t}))}catch(e){if(n?.())return;let t=e instanceof Error?e.message:String(e??``);console.error(`Failed to load sidebar directory:`,e),w(e=>({...e,[i]:t}))}finally{E.current=new Set(E.current),E.current.delete(i)}},[t,pe,r]),he=Z.useCallback(async()=>{if(!a)return;D.current?.abort();let e=new AbortController;D.current=e;try{let t=(Bo.getState().byRoot[o]?.expandedPaths??[]).map(e=>Rh(e)).filter(e=>!!e&&e!==a&&e.startsWith(`${a}/`)),n=[a,...t];T.current=new Set(T.current);for(let e of n)T.current.delete(e);w(e=>{if(Object.keys(e).length===0)return e;let t={...e},r=!1;for(let e of n)e in t&&(delete t[e],r=!0);return r?t:e});let r=()=>e.signal.aborted;await me(a,r);for(let n=0;n<t.length&&!e.signal.aborted;n+=3){let e=t.slice(n,n+3);await Promise.all(e.map(e=>me(e,r)))}}catch(t){if(e.signal.aborted)return;console.error(`Failed to refresh sidebar tree:`,t)}finally{D.current===e&&(D.current=null)}},[me,a,o]),ge=Z.useCallback(async e=>{if(!e){await he();return}let t=Rh(e);T.current=new Set(T.current),T.current.delete(t),E.current=new Set(E.current),E.current.delete(t),await me(t)},[me,he]);Z.useEffect(()=>{a&&(D.current?.abort(),O.current=!1,T.current=new Set,E.current=new Set,w({}),S(e=>Object.keys(e).length===0?e:{}),me(a))},[me,a,c,l]),Z.useEffect(()=>{if(!a||j.length===0)return;let e=j.map(e=>Rh(e)).filter(e=>!!e&&e!==a&&e.startsWith(`${a}/`)&&!T.current.has(e)&&!E.current.has(e)).sort((e,t)=>e.split(`/`).length-t.split(`/`).length);if(e.length===0)return;let t=!1,n=()=>t;return(async()=>{for(let r=0;r<e.length&&!t;r+=3){let t=e.slice(r,r+3);await Promise.all(t.map(e=>me(e,n)))}})(),()=>{t=!0}},[j,me,a]),Z.useEffect(()=>{if(!i){v([]),b(!1);return}let e=h.trim();if(!e){v([]),b(!1);return}let t=!1;b(!0);let n={includeHidden:c,respectGitignore:!l,type:`file`};return(r?.location.hostId?r.service().searchFiles(e,{...n,directory:i,limit:150}):u(i,e,150,n)).then(e=>{if(t)return;let n=e.filter(e=>l||!Uh(e.path)).map(e=>({name:e.name,path:Rh(e.path),type:`file`,extension:e.extension,relativePath:e.relativePath}));v(n)}).catch(()=>{t||v([])}).finally(()=>{t||b(!1)}),()=>{t=!0}},[i,h,u,c,l,r]);let _e=Z.useMemo(()=>{let e=new Map;if(!f?.files)return e;for(let t of f.files)t.index===`A`||t.working_dir===`?`?e.set(t.path,`git-added`):t.index===`D`?e.set(t.path,`git-deleted`):(t.index===`M`||t.working_dir===`M`)&&e.set(t.path,`git-modified`);return e},[f]),ve=Z.useMemo(()=>{let e=new Map;if(!f?.files||!a)return e;for(let t of f.files){let n=t.index===`M`||t.working_dir===`M`,r=t.index===`A`||t.working_dir===`?`;if(!n&&!r)continue;let i=t.path.split(`/`);if(i.length<=1)continue;let o=a;for(let t=0;t<i.length-1;t++){o=`${o}/${i[t]}`;let a=e.get(o);a||(a={modified:0,added:0},e.set(o,a)),n&&a.modified++,r&&a.added++}}return e},[f,a]),ye=Z.useCallback(e=>{if(ee.has(e))return`open`;if(_e.size===0)return null;let t=e.startsWith(a+`/`)?e.slice(a.length+1):e;return _e.get(t)??null},[ee,_e,a]),be=Z.useCallback(e=>{if(ve.size===0)return null;let t=ve.get(e);return t&&t.modified+t.added>0?t:null},[ve]),xe=Z.useCallback(async e=>{if(!a)return;let n=await Mc(t,e.path);if(!n.ok){Y.error(ol(n.reason));return}N(o,e.path),P(o,e.path),d(o,e.path)},[P,t,d,a,o,N]),Se=Z.useCallback(async e=>{let t=Rh(e);a&&(L(o,t),T.current.has(t)||await me(t))},[me,a,o,L]),Ce=Z.useMemo(()=>a?Nf(a,x):[],[x,a]),we=Z.useMemo(()=>new Set(j.map(e=>Rh(e))),[j]),Te=Pf(j),Ee=Z.useCallback(()=>{if(a){if(Te){O.current=!1,I(o,a);return}O.current=!0,R(o,Ce)}},[Te,Ce,R,I,a,o]);Z.useEffect(()=>{if(!a||!O.current)return;let e=Ff(Ce,j);if(e.length>0){R(o,e);return}let t=new Set([...T.current,...Object.keys(C)]);If(Ce,j,t)&&(O.current=!1)},[Ce,R,j,C,a,o]);let De=Z.useCallback(async n=>{if(n?.preventDefault(),!ne||!B)return;V(!0);let r=()=>V(!1),i=()=>te(null);if(B===`createFile`){if(!ie.trim()){Y.error(e(`sidebarFilesTree.toast.filenameRequired`)),r();return}if(!t.writeFile){Y.error(e(`sidebarFilesTree.toast.writeNotSupported`)),r();return}let n=ne.path,a=Rh(`${n?`${n}/`:``}${ie.trim()}`);await t.writeFile(a,``).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.fileCreated`)),await ge(n)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`createFolder`){if(!ie.trim()){Y.error(e(`sidebarFilesTree.toast.folderNameRequired`)),r();return}let n=ne.path,a=Rh(`${n?`${n}/`:``}${ie.trim()}`);await t.createDirectory(a).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.folderCreated`)),await ge(n)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`rename`){if(!ie.trim()){Y.error(e(`sidebarFilesTree.toast.nameRequired`)),r();return}if(!t.rename){Y.error(e(`sidebarFilesTree.toast.renameNotSupported`)),r();return}let n=ne.path,s=n.split(`/`).slice(0,-1).join(`/`),c=Rh(`${s?`${s}/`:``}${ie.trim()}`);await t.rename(n,c).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.renamedSuccessfully`)),await ge(s),a&&F(o,n),(M===n||M&&M.startsWith(`${n}/`))&&N(o,null)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}if(B===`delete`){if(!t.delete){Y.error(e(`sidebarFilesTree.toast.deleteNotSupported`)),r();return}let n=ne.path,s=n.split(`/`).slice(0,-1).join(`/`);await t.delete(n).then(async t=>{t.success&&(Y.success(e(`sidebarFilesTree.toast.deletedSuccessfully`)),await ge(s),a&&F(o,n),(M===n||M&&M.startsWith(n+`/`))&&N(o,null)),i()}).catch(()=>Y.error(e(`sidebarFilesTree.toast.operationFailed`))).finally(r);return}r()},[B,ne,ie,t,ge,F,a,o,M,N,e]);function Oe(n,r){return(x[n]??[]).map(n=>{let i=n.type===`directory`,o=i&&we.has(Rh(n.path)),s=M===n.path;return(0,$.jsxs)(`li`,{className:`relative`,children:[r>0&&(0,$.jsx)(`span`,{className:`absolute top-3 left-[-12px] h-px w-3 bg-border/40`}),(0,$.jsx)(Zh,{node:n,root:a,isExpanded:o,isActive:s,status:i?void 0:ye(n.path),badge:i?be(n.path):void 0,permissions:ue,downloadFile:t.downloadFile,onSelect:xe,onToggle:Se,onRevealPath:de,onOpenDialog:fe}),i&&o&&(0,$.jsxs)(`ul`,{className:`relative ml-3 flex flex-col border-l border-border/40 pl-3`,children:[C[n.path]?(0,$.jsxs)(`li`,{className:`flex items-center gap-2 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--status-error)]`,title:C[n.path],children:C[n.path]}),(0,$.jsxs)(q,{variant:`ghost`,size:`xs`,className:`h-6 gap-1`,onClick:()=>void ge(n.path),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`sidebarFilesTree.actions.refreshTitle`)]})]}):null,Oe(n.path,r+1)]})]},n.path)})}let ke=!!(a&&x[a]),Ae=a?C[a]:null,je=e(Te?`sidebarFilesTree.actions.collapseAllTitle`:`sidebarFilesTree.actions.expandAllTitle`);return(0,$.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 px-2 py-1.5`,"data-sidebar-file-search":!0,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,$.jsx)(va,{ref:g,value:p,onChange:e=>m(e.target.value),placeholder:e(`sidebarFilesTree.search.placeholder`),"aria-label":e(`sidebarFilesTree.search.placeholder`),className:`h-7 rounded-md py-0 pl-7 pr-6 !text-xs leading-4 focus:ring-1 bg-[color-mix(in_srgb,var(--surface-foreground)_2%,var(--background))] hover:[&:not(:focus)]:bg-[color-mix(in_srgb,var(--surface-foreground)_4%,var(--background))]`}),p.trim().length>0?(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`sidebarFilesTree.search.clearAria`),className:`absolute right-1.5 top-1/2 inline-flex size-4 -translate-y-1/2 items-center justify-center text-muted-foreground hover:text-foreground`,onClick:()=>{m(``),g.current?.focus()},children:(0,$.jsx)(X,{name:`close`,className:`size-3`})}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-shrink-0 items-center gap-0.5`,children:[H&&(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>fe(`createFile`,{path:i,type:`directory`}),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.newFileTitle`),"aria-label":e(`sidebarFilesTree.actions.newFileTitle`),children:(0,$.jsx)(X,{name:`file-add`,className:`size-3.5`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.newFileTitle`)})]}),se&&(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>fe(`createFolder`,{path:i,type:`directory`}),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.newFolderTitle`),"aria-label":e(`sidebarFilesTree.actions.newFolderTitle`),children:(0,$.jsx)(X,{name:`folder-add`,className:`size-3.5`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.newFolderTitle`)})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0`,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:()=>void he(),className:`w-6 flex-shrink-0 p-0`,title:e(`sidebarFilesTree.actions.refreshTitle`),"aria-label":e(`sidebarFilesTree.actions.refreshTitle`),children:(0,$.jsx)(X,{name:`refresh`,className:`size-3.5`})})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:e(`sidebarFilesTree.actions.refreshTitle`)})]}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,onClick:Ee,disabled:Ce.length===0&&j.length===0,className:`w-6 flex-shrink-0 p-0`,title:je,"aria-label":je,children:(0,$.jsx)(X,{name:Te?`contract-up-down`:`expand-up-down`,className:`size-3.5`})})}),(0,$.jsx)(ei,{side:`bottom`,sideOffset:6,children:je})]})]})]}),(0,$.jsx)(Wr,{outerClassName:`flex-1 min-h-0`,className:`p-2`,children:(0,$.jsx)(`ul`,{className:`flex flex-col`,children:y?(0,$.jsxs)(`li`,{className:`flex items-center gap-1.5 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),e(`sidebarFilesTree.state.searching`)]}):_.length>0?_.map(e=>{let t=M===e.path;return(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>xe(e),draggable:!0,onDragStart:t=>{let n=e.relativePath||zh(a??``,e.path);!n||n===`.`||(t.dataTransfer.setData(`application/x-yuri-file-path`,n),t.dataTransfer.effectAllowed=`copy`)},className:J(`flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing`,t?`bg-interactive-selection/70`:`hover:bg-interactive-hover/40`),title:e.path,children:[Yh(e.path,e.extension),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-code`,style:{direction:`rtl`,textAlign:`left`},children:e.relativePath??e.path})]})},e.path)}):Ae?(0,$.jsxs)(`li`,{className:`flex flex-col gap-2 px-2 py-1 typography-code text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:Ae}),(0,$.jsxs)(q,{variant:`outline`,size:`xs`,className:`w-fit gap-1.5`,onClick:()=>void he(),children:[(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`sidebarFilesTree.actions.refreshTitle`)]})]}):ke&&a?Oe(a,0):(0,$.jsx)(`li`,{className:`px-2 py-1 typography-code text-muted-foreground`,children:e(`sidebarFilesTree.state.loading`)})})}),(0,$.jsx)(Qr,{open:!!B,onOpenChange:e=>!e&&te(null),children:(0,$.jsxs)(Yr,{children:[(0,$.jsxs)(qr,{children:[(0,$.jsxs)(Xr,{children:[B===`createFile`&&e(`sidebarFilesTree.dialog.createFile.title`),B===`createFolder`&&e(`sidebarFilesTree.dialog.createFolder.title`),B===`rename`&&e(`sidebarFilesTree.dialog.rename.title`),B===`delete`&&e(`sidebarFilesTree.dialog.delete.title`)]}),(0,$.jsxs)(Zr,{children:[B===`createFile`&&e(`sidebarFilesTree.dialog.createFile.description`,{path:ne?.path??e(`sidebarFilesTree.dialog.rootFallback`)}),B===`createFolder`&&e(`sidebarFilesTree.dialog.createFolder.description`,{path:ne?.path??e(`sidebarFilesTree.dialog.rootFallback`)}),B===`rename`&&e(`sidebarFilesTree.dialog.rename.description`,{name:ne?.name??``}),B===`delete`&&e(`sidebarFilesTree.dialog.delete.description`,{name:ne?.name??``})]})]}),B!==`delete`&&(0,$.jsx)(`div`,{className:`py-4`,children:(0,$.jsx)(va,{value:ie,onChange:e=>ae(e.target.value),placeholder:e(B===`rename`?`sidebarFilesTree.dialog.rename.placeholder`:`sidebarFilesTree.dialog.namePlaceholder`),onKeyDown:e=>{e.key===`Enter`&&De()},autoFocus:!0})}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(q,{variant:`outline`,onClick:()=>te(null),disabled:oe,children:e(`sidebarFilesTree.dialog.cancel`)}),(0,$.jsx)(q,{variant:B===`delete`?`destructive`:`default`,onClick:()=>void De(),disabled:oe||B!==`delete`&&!ie.trim(),children:oe?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):e(B===`delete`?`sidebarFilesTree.dialog.delete.confirm`:`sidebarFilesTree.dialog.confirm`)})]})]})})]})},$h=()=>!(typeof document<`u`&&document.hidden||typeof navigator<`u`&&!navigator.onLine);function eg(e,t,n,r){let i=(0,Q.c)(6),{git:a}=Gi(),o=na(tg),s=!!(e&&a&&t&&n===`git`&&r!==`git`),c,l;i[0]!==e||i[1]!==o||i[2]!==a||i[3]!==s?(c=()=>{if(!s||!e||!a)return;o(e,a);let t=window.setInterval(()=>{$h()&&o(e,a)},1e4);return()=>window.clearInterval(t)},l=[s,e,a,o],i[0]=e,i[1]=o,i[2]=a,i[3]=s,i[4]=c,i[5]=l):(c=i[4],l=i[5]),Z.useEffect(c,l)}function tg(e){return e.ensureStatus}var ng=e=>{let t=(0,Q.c)(22),{railVisible:n}=e,{t:r}=Nr(),i=K(ig),a=K(ag),o=K(og),s=K(sg),c=K(cg),l=bt(),u=!l?.entry.location.hostId,d;t[0]===u?d=t[1]:(d={enabled:u},t[0]=u,t[1]=d);let f=wo(d),p,m,h,g;if(t[2]!==f||t[3]!==l?.entry.location.hostId||t[4]!==i||t[5]!==c||t[6]!==a||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==r){let e=Ja({hideGit:c===`git`,showBrowser:!l?.entry.location.hostId&&bo(f.data)}),u=e.includes(a)?a:e[0]??`files`;p=`group`,t[15]===r?m=t[16]:(m=r(`header.actions.toggleRightSidebarAria`),t[15]=r,t[16]=m),h=`inline-flex h-7 items-center overflow-hidden rounded-md border border-border/40 divide-x divide-border/40`,g=e.map(e=>{let t=(n??i)&&u===e,a=r(e===`git`?`layout.rightSidebar.git`:e===`files`?`contextPanel.actions.toggleFileTree`:`layout.rightSidebar.browser`);return(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:J(`h-full w-7 !rounded-none text-muted-foreground hover:text-foreground focus-visible:z-10 focus-visible:ring-inset`,t&&`bg-interactive-selection text-interactive-selection-foreground`),"aria-pressed":t,"aria-label":a,title:a,onClick:()=>{s(e),o(!t)},children:(0,$.jsx)(X,{name:e===`git`?`git-branch`:e===`files`?`list-unordered`:`global`,className:`size-4`})},e)}),t[2]=f,t[3]=l?.entry.location.hostId,t[4]=i,t[5]=c,t[6]=a,t[7]=n,t[8]=o,t[9]=s,t[10]=r,t[11]=p,t[12]=m,t[13]=h,t[14]=g}else p=t[11],m=t[12],h=t[13],g=t[14];let _;return t[17]!==p||t[18]!==m||t[19]!==h||t[20]!==g?(_=(0,$.jsx)(`div`,{role:p,"aria-label":m,className:h,children:g}),t[17]=p,t[18]=m,t[19]=h,t[20]=g,t[21]=_):_=t[21],_},rg=e=>{let t=(0,Q.c)(34),{isActive:n}=e,r=K(lg),i=K(ug),a=Ui(),o=bt(),s=!o?.entry.location.hostId,c;t[0]===s?c=t[1]:(c={enabled:s},t[0]=s,t[1]=c);let l=wo(c),u;t[2]!==l.data?.providers||t[3]!==l.data?.selectedId?(u=l.data?.providers.find(e=>e.id===l.data?.selectedId)??null,t[2]=l.data?.providers,t[3]=l.data?.selectedId,t[4]=u):u=t[4];let d=u,f;t[5]!==l.data||t[6]!==o?.entry.location.hostId?(f=!o?.entry.location.hostId&&bo(l.data),t[5]=l.data,t[6]=o?.entry.location.hostId,t[7]=f):f=t[7];let p=f,m=i===`git`,h;t[8]!==m||t[9]!==p?(h=Ja({hideGit:m,showBrowser:p}),t[8]=m,t[9]=p,t[10]=h):h=t[10];let g=h,_;t[11]!==r||t[12]!==g?(_=g.includes(r)?r:g[0]??`files`,t[11]=r,t[12]=g,t[13]=_):_=t[13];let v=_;eg(a,n,v,i);let y=n&&v===`git`&&!m,b=v!==`git`&&`hidden`,x;t[14]===b?x=t[15]:(x=J(`h-full`,b),t[14]=b,t[15]=x);let S;t[16]===y?S=t[17]:(S=(0,$.jsx)(Dh,{isActive:y}),t[16]=y,t[17]=S);let C;t[18]!==x||t[19]!==S?(C=(0,$.jsx)(`div`,{className:x,children:S}),t[18]=x,t[19]=S,t[20]=C):C=t[20];let w=v!==`files`&&`hidden`,T;t[21]===w?T=t[22]:(T=J(`h-full`,w),t[21]=w,t[22]=T);let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Qh,{}),t[23]=E):E=t[23];let D;t[24]===T?D=t[25]:(D=(0,$.jsx)(`div`,{className:T,children:E}),t[24]=T,t[25]=D);let O;t[26]!==v||t[27]!==d||t[28]!==p?(O=p&&d?(0,$.jsx)(`div`,{className:J(`h-full`,v!==`browser`&&`hidden`),children:(0,$.jsx)(Ih,{provider:d})}):null,t[26]=v,t[27]=d,t[28]=p,t[29]=O):O=t[29];let k;return t[30]!==C||t[31]!==D||t[32]!==O?(k=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-transparent`,children:(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:[C,D,O]})}),t[30]=C,t[31]=D,t[32]=O,t[33]=k):k=t[33],k};function ig(e){return e.isRightSidebarOpen}function ag(e){return e.rightSidebarTab}function og(e){return e.setRightSidebarOpen}function sg(e){return e.setRightSidebarTab}function cg(e){return e.activeMainTab}function lg(e){return e.rightSidebarTab}function ug(e){return e.activeMainTab}var dg=e=>{if(re(e,`local`).hostId)return R(e);let t=e.trim().replace(/\\/g,`/`);if(!t)return``;let n=t.startsWith(`//`),r=t.replace(/\/+$/g,``).replace(/\/+/g,`/`);return n&&!r.startsWith(`//`)?`/${r}`:r||(t.startsWith(`/`)?`/`:``)},fg=()=>`react-surface`,pg=(e,t)=>JSON.stringify([dg(e),t]),mg=(e,t,n,r)=>JSON.stringify([e,t,dg(n),r]),hg=(e,t,n)=>n?t:e===t?e:null,gg=(e,t)=>e.sessionId===t.sessionId&&dg(e.directory)===dg(t.directory),_g=(e,t)=>dg(e)===dg(t),vg=e=>({anchor:e,current:e,stack:[]}),yg=(e,t)=>e??vg(t),bg=(e,t)=>e?.current.sessionId??t,xg=(e,t)=>gg(e.current,t)?e:{...e,current:t,stack:[...e.stack,e.current]},Sg=e=>{let t=e.stack[e.stack.length-1];return t?{...e,current:t,stack:e.stack.slice(0,-1)}:e},Cg=(e,t,n)=>!_g(e.anchor.directory,t.directory)||!_g(e.current.directory,t.directory)||n(t.sessionId,t.directory)===!1?{status:`rejected-cross-directory`,state:e}:{status:`navigated`,state:xg(e,t)},wg=(e,t,n)=>{let r=e[t];if(!r)return{accepted:!1,navigationBySurfaceId:e};let i=Cg(r,n,()=>!0);return i.status===`navigated`?{accepted:!0,navigationBySurfaceId:i.state===r?e:{...e,[t]:i.state}}:{accepted:!1,navigationBySurfaceId:e}},Tg=(e,t)=>{let n=!1,r={};for(let[i,a]of Object.entries(e)){if(!t.has(i)){n=!0;continue}r[i]=a}return n?r:e},Eg=e=>e.directoryMatches?e.error?e.messageCount>0?`partial-error`:`fatal-error`:!e.renderable&&e.requested?`cold-loading`:e.messageCount===0?e.working?`working-empty`:`authoritative-empty`:`transcript`:`directory-mismatch`,Dg=e=>e===`retry`,Og=e=>e.active&&e.visible&&e.messageCount<=0,kg=e=>e?`load-more`:`ensure`,Ag=e=>e.kind===`has-more`,jg=(e,t)=>`${e}\n${t}`,Mg=(e,t,n,r)=>r&&!e.has(jg(t,n)),Ng=(e,t)=>({scrollHeight:e,scrollTop:t}),Pg=(e,t)=>Math.max(0,e.scrollTop+Math.max(0,t-e.scrollHeight)),Fg=(e,t)=>e&&!t,Ig=e=>e,Lg=e=>!e,Rg=e=>!Fg(e.hasMore,e.isLoading)||!Lg(e.historyVirtualized)?null:Ng(e.scrollHeight,e.scrollTop),zg=(e,t,n)=>!!(e&&e.token===t&&e.viewportKey===n),Bg=33554432,Vg=e=>Math.min(Bg,262144+Math.max(0,Math.ceil(e))*64*1024),Hg=e=>Math.min(Bg,Math.max(0,Math.round(Number.isFinite(e)?e:0))),Ug=e=>{let t=Object.values(e.mountedViews),n=t.length,r=t.reduce((e,t)=>e+t.estimatedBytes,0),i=new Set,a=t.filter(t=>t.viewKey!==e.activeViewKey).sort((e,t)=>e.lastAccessed-t.lastAccessed);for(let e of a){if(n<=3&&r<=33554432)break;i.add(e.viewKey),--n,r-=e.estimatedBytes}if(i.size===0)return e;let o={...e.mountedViews};return i.forEach(e=>delete o[e]),{...e,mountedViews:o}},Wg=(e,t)=>{if(t.type===`close-tab`){let n=Object.values(e.mountedViews).filter(e=>e.tabId===t.tabId);if(!e.tabs[t.tabId]&&n.length===0)return e;let r={...e.tabs},i={...e.mountedViews};return delete r[t.tabId],n.forEach(e=>delete i[e.viewKey]),{activeViewKey:n.some(t=>t.viewKey===e.activeViewKey)?null:e.activeViewKey,tabs:r,mountedViews:i}}if(t.type===`activate`){if(t.viewKey===e.activeViewKey)return e;let n=t.viewKey?e.mountedViews[t.viewKey]:void 0;if(t.viewKey&&!n)return e;if(!n)return{...e,activeViewKey:null};let r=n.lastAccessed===t.now?e.mountedViews:{...e.mountedViews,[n.viewKey]:{...n,lastAccessed:t.now}};return Ug({...e,activeViewKey:t.viewKey,mountedViews:r})}if(t.type===`estimate`){let n=e.mountedViews[t.viewKey],r=Hg(t.estimatedBytes);return!n||n.estimatedBytes===r?e:Ug({...e,mountedViews:{...e.mountedViews,[n.viewKey]:{...n,estimatedBytes:r}}})}let n=e.tabs[t.tab.tabId],r=e.mountedViews[t.view.viewKey],i=n&&n.sessionId===t.tab.sessionId&&n.directory===t.tab.directory&&n.title===t.tab.title,a=r&&r.tabId===t.view.tabId&&r.surfaceId===t.view.surfaceId&&r.lastAccessed===t.now;return i&&a&&e.activeViewKey===t.view.viewKey?e:Ug({...e,activeViewKey:t.view.viewKey,tabs:i?e.tabs:{...e.tabs,[t.tab.tabId]:t.tab},mountedViews:{...e.mountedViews,[t.view.viewKey]:{...t.view,estimatedBytes:r?.estimatedBytes??Vg(0),lastAccessed:t.now}}})},Gg=e=>{let t=(0,Q.c)(17),{state:n,error:r,onRetry:i}=e,{t:a}=Nr();if(n===`cold-loading`||n===`working-empty`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`})}),t[0]=e):e=t[0],e}if(n===`fatal-error`||n===`directory-mismatch`){let e;t[1]!==r||t[2]!==a?(e=r||a(`chat.emptyState.opencodeUnreachable`),t[1]=r,t[2]=a,t[3]=e):e=t[3];let o;t[4]===e?o=t[5]:(o=(0,$.jsx)(`div`,{className:`text-center`,children:e}),t[4]=e,t[5]=o);let s;t[6]!==i||t[7]!==n||t[8]!==a?(s=n===`fatal-error`?(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`sm`,onClick:i,children:a(`chat.history.retry`)}):null,t[6]=i,t[7]=n,t[8]=a,t[9]=s):s=t[9];let c;return t[10]!==o||t[11]!==s?(c=(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-sm text-muted-foreground`,children:[o,s]}),t[10]=o,t[11]=s,t[12]=c):c=t[12],c}let o;t[13]===a?o=t[14]:(o=a(`chat.timeline.empty.session`),t[13]=a,t[14]=o);let s;return t[15]===o?s=t[16]:(s=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground`,children:o}),t[15]=o,t[16]=s),s},Kg=e=>{let t=(0,Q.c)(173),{surfaceId:n,sessionId:r,directory:i,active:a,canNavigateBack:o,onNavigateSession:s,onNavigateBack:c,onEstimateBytes:l,syncDirectory:u}=e,{t:d}=Nr(),f=ps(),m,h,g;t[0]!==i||t[1]!==r||t[2]!==n?(h=p(),m=dg(i),g=mg(h,n,m,r),t[0]=i,t[1]=r,t[2]=n,t[3]=m,t[4]=h,t[5]=g):(m=t[3],h=t[4],g=t[5]);let _=g,v=Z.useRef(null),y=Z.useRef(null),b=Z.useRef(0),[x,S]=Z.useState(null),C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=new Set,t[6]=C):C=t[6];let w=Z.useRef(C),T=dr(r,u),E=$n(r,u),D=An(Jg),O;t[7]===E?O=t[8]:(O=Yo(E),t[7]=E,t[8]=O);let k=O,A;bb0:{if(!k.modelId){let e;t[9]===d?e=t[10]:(e=d(`common.unavailable`),t[9]=d,t[10]=e),A=e;break bb0}let e;if(t[11]!==k.modelId||t[12]!==k.providerId||t[13]!==D){let n;t[15]===k.providerId?n=t[16]:(n=e=>e.id===k.providerId,t[15]=k.providerId,t[16]=n);let r=D.find(n);e=r?.models.some(e=>e.id===k.modelId)&&Zn(r,k.modelId)||k.modelId,t[11]=k.modelId,t[12]=k.providerId,t[13]=D,t[14]=e}else e=t[14];A=e}let j=A,M=Wn(r,u),N=rr(r,u).renderable,P;t[17]===r?P=t[18]:(P=e=>!!e.session.find(e=>e.id===r)?.parentID,t[17]=r,t[18]=P);let F=Dn(P,u),[I,L]=Z.useState(null),R,z;t[19]!==F||t[20]!==_?(R=()=>{L(e=>hg(e,_,F))},z=[F,_],t[19]=F,t[20]=_,t[21]=R,t[22]=z):(R=t[21],z=t[22]),Z.useLayoutEffect(R,z);let ee=F||I===_,B=Rn(r,u),te;t[23]===r?te=t[24]:(te=e=>e.streamingMessageIds.get(r)??null,t[23]=r,t[24]=te);let ne=vn(te),re;t[25]===ne?re=t[26]:(re=e=>ne?e.messageStreamStates.get(ne)?.phase??null:null,t[25]=ne,t[26]=re);let ie=vn(re),ae=M?.type===`busy`||M?.type===`retry`,oe;t[27]!==a||t[28]!==r||t[29]!==ae||t[30]!==T||t[31]!==_?(oe={scrollControllerRef:v,enabled:a,currentSessionId:r,viewportKey:_,sessionMessageCount:T,sessionIsWorking:ae,isMobile:!1},t[27]=a,t[28]=r,t[29]=ae,t[30]=T,t[31]=_,t[32]=oe):oe=t[32];let{scrollRef:V,notifyContentChange:H,getAnimationHandlers:se,goToBottom:U,restoreSnapshot:ce,showScrollButton:le}=as(oe),ue;t[33]===U?ue=t[34]:(ue=e=>{U(e===void 0?`instant`:e)},t[33]=U,t[34]=ue);let de=G(ue),fe;t[35]!==r||t[36]!==f?(fe=e=>{f.ensureSessionRenderable(r,Dg(e))},t[35]=r,t[36]=f,t[37]=fe):fe=t[37];let pe=G(fe),me,he;t[38]!==a||t[39]!==pe?(me=()=>{a&&pe(`active`)},he=[a,pe],t[38]=a,t[39]=pe,t[40]=me,t[41]=he):(me=t[40],he=t[41]),Z.useEffect(me,he);let ge,_e;t[42]!==a||t[43]!==pe||t[44]!==T?(ge=()=>{if(typeof window>`u`)return;let e=()=>{let e=document.visibilityState!==`hidden`&&document.hasFocus();Og({active:a,visible:e,messageCount:T})&&pe(`retry`)};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,e),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,e)}},_e=[a,pe,T],t[42]=a,t[43]=pe,t[44]=T,t[45]=ge,t[46]=_e):(ge=t[45],_e=t[46]),Z.useEffect(ge,_e);let ve,ye;t[47]!==l||t[48]!==T||t[49]!==_?(ve=()=>{l?.(_,Vg(T))},ye=[l,T,_],t[47]=l,t[48]=T,t[49]=_,t[50]=ve,t[51]=ye):(ve=t[50],ye=t[51]),Z.useEffect(ve,ye);let be,xe;t[52]!==N||t[53]!==ce||t[54]!==r||t[55]!==_?(be=()=>{if(!Mg(w.current,r,_,N))return;let e=jg(r,_);w.current.add(e),ce()},xe=[N,ce,r,_],t[52]=N,t[53]=ce,t[54]=r,t[55]=_,t[56]=be,t[57]=xe):(be=t[56],xe=t[57]),Z.useEffect(be,xe);let Se;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>{y.current=null,S(null)},t[58]=Se):Se=t[58];let Ce;t[59]===_?Ce=t[60]:(Ce=[_],t[59]=_,t[60]=Ce),Z.useLayoutEffect(Se,Ce);let we;t[61]!==x||t[62]!==V||t[63]!==_?(we=()=>{let e=y.current,t=V.current;if(zg(e,x,_)){if(!t||!Lg(!!v.current?.isHistoryVirtualized())){y.current=null;return}t.scrollTop=Pg(e.anchor,t.scrollHeight),y.current=null}},t[61]=x,t[62]=V,t[63]=_,t[64]=we):we=t[64];let Te;t[65]!==x||t[66]!==V||t[67]!==E||t[68]!==_?(Te=[x,V,E,_],t[65]=x,t[66]=V,t[67]=E,t[68]=_,t[69]=Te):Te=t[69],Z.useLayoutEffect(we,Te);let Ee;t[70]===m?Ee=t[71]:(Ee={directory:m},t[70]=m,t[71]=Ee);let De=Ee,Oe=Sr(r,u).boundary,ke;t[72]===Oe?ke=t[73]:(ke=Ag(Oe),t[72]=Oe,t[73]=ke);let Ae=ke,je;t[74]!==B?.status||t[75]!==De||t[76]!==r||t[77]!==f?(je=B?.status===`loading`||f.isLoading(r,De),t[74]=B?.status,t[75]=De,t[76]=r,t[77]=f,t[78]=je):je=t[78];let Me=je,Ne;t[79]!==m||t[80]!==h||t[81]!==r?(Ne=[`context-panel-load-older`,h,m,r],t[79]=m,t[80]=h,t[81]=r,t[82]=Ne):Ne=t[82];let Pe;t[83]!==Oe||t[84]!==r||t[85]!==u?(Pe=async()=>{Oe.kind===`unknown`&&await at(u,r),await Je(u,r)},t[83]=Oe,t[84]=r,t[85]=u,t[86]=Pe):Pe=t[86];let Fe;t[87]!==Ne||t[88]!==Pe?(Fe={mutationKey:Ne,mutationFn:Pe},t[87]=Ne,t[88]=Pe,t[89]=Fe):Fe=t[89];let Ie=_t(Fe),W=Ie.isPending,Le;t[90]!==Me||t[91]!==Ae||t[92]!==W||t[93]!==Ie||t[94]!==V||t[95]!==d||t[96]!==_?(Le=()=>{if(!Fg(Ae,W||Me)||Ie.isPending)return;let e=b.current+1;b.current=e;let t=V.current,n=t?Rg({hasMore:Ae,isLoading:W,historyVirtualized:!!v.current?.isHistoryVirtualized(),scrollHeight:t.scrollHeight,scrollTop:t.scrollTop}):null;y.current=n?{token:e,viewportKey:_,anchor:n}:null,Ie.mutateAsync().then(()=>{S(e)},()=>{S(e),Y.error(d(`chat.history.loadOlderFailed`))})},t[90]=Me,t[91]=Ae,t[92]=W,t[93]=Ie,t[94]=V,t[95]=d,t[96]=_,t[97]=Le):Le=t[97];let Re=G(Le),ze=B?.status===`error`?B.error:void 0,Be;t[98]!==a||t[99]!==N||t[100]!==ae||t[101]!==E.length||t[102]!==ze?(Be=Eg({directoryMatches:!0,requested:a,renderable:N,messageCount:E.length,working:ae,error:ze}),t[98]=a,t[99]=N,t[100]=ae,t[101]=E.length,t[102]=ze,t[103]=Be):Be=t[103];let Ve=Be,He;t[104]!==a||t[105]!==m||t[106]!==s||t[107]!==r||t[108]!==n?(He={kind:`panel`,surfaceId:n,sessionId:r,directory:m,active:a,capabilities:Da,navigateSession:s},t[104]=a,t[105]=m,t[106]=s,t[107]=r,t[108]=n,t[109]=He):He=t[109];let Ue=He,We;t[110]!==pe||t[111]!==Ae||t[112]!==Re?(We=()=>{if(kg(Ae)===`load-more`){Re();return}pe(`retry`)},t[110]=pe,t[111]=Ae,t[112]=Re,t[113]=We):We=t[113];let Ge=G(We),Ke;t[114]!==B?.error||t[115]!==Ge||t[116]!==d||t[117]!==Ve?(Ke=Ve===`partial-error`?(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 px-3 py-2 text-sm text-[var(--status-error-foreground)]`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:B?.error}),(0,$.jsx)(q,{type:`button`,variant:`secondary`,size:`xs`,onClick:Ge,children:d(`chat.history.retry`)})]}):null,t[114]=B?.error,t[115]=Ge,t[116]=d,t[117]=Ve,t[118]=Ke):Ke=t[118];let qe=Ke,Ye;t[119]!==Ae||t[120]!==W||t[121]!==Re||t[122]!==d?(Ye=Ig(Ae)?(0,$.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,$.jsxs)(q,{type:`button`,variant:`secondary`,size:`sm`,onClick:Re,disabled:W,children:[W?(0,$.jsx)(X,{name:`loader-4`,className:`size-4 animate-spin`}):null,d(`chat.history.loadOlder`)]})}):null,t[119]=Ae,t[120]=W,t[121]=Re,t[122]=d,t[123]=Ye):Ye=t[123];let Xe=Ye,Ze;t[124]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=(0,$.jsx)(`div`,{className:`flex-shrink-0`,style:{height:rs},"aria-hidden":`true`}),t[124]=Ze):Ze=t[124];let Qe=Ze,$e;t[125]===de?$e=t[126]:($e=()=>de(`instant`),t[125]=de,t[126]=$e);let et;t[127]!==ie||t[128]!==se||t[129]!==W||t[130]!==H||t[131]!==V||t[132]!==r||t[133]!==ae||t[134]!==E||t[135]!==ne||t[136]!==u||t[137]!==$e||t[138]!==_?(et=(0,$.jsx)($o,{ref:v,sessionKey:r,virtualizerKey:_,messages:E,sessionIsWorking:ae,activeStreamingMessageId:ne,activeStreamingPhase:ie,onMessageContentChange:H,getAnimationHandlers:se,isLoadingOlder:W,scrollToBottom:$e,scrollRef:V,directory:u,enableSendPark:!1}),t[127]=ie,t[128]=se,t[129]=W,t[130]=H,t[131]=V,t[132]=r,t[133]=ae,t[134]=E,t[135]=ne,t[136]=u,t[137]=$e,t[138]=_,t[139]=et):et=t[139];let tt=et,nt;t[140]===de?nt=t[141]:(nt=()=>de(`smooth`),t[140]=de,t[141]=nt);let rt;t[142]!==le||t[143]!==nt?(rt=(0,$.jsx)(Ho,{visible:le,onClick:nt}),t[142]=le,t[143]=nt,t[144]=rt):rt=t[144];let it=rt,ot;t[145]!==o||t[146]!==c||t[147]!==d?(ot=o?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:c,className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":d(`chat.container.returnToParent.aria`),title:d(`chat.container.returnToParent.title`),children:[(0,$.jsx)(X,{name:`arrow-left`,className:`h-4 w-4`}),d(`chat.container.returnToParent.label`)]}):null,t[145]=o,t[146]=c,t[147]=d,t[148]=ot):ot=t[148];let st;t[149]!==pe||t[150]!==Xe||t[151]!==qe||t[152]!==B?.error||t[153]!==V||t[154]!==it||t[155]!==tt||t[156]!==Ve?(st=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1`,children:Ve===`cold-loading`||Ve===`working-empty`||Ve===`authoritative-empty`||Ve===`fatal-error`?(0,$.jsx)(Gg,{state:Ve,error:B?.error,onRetry:()=>pe(`retry`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ur,{ref:V,className:`absolute inset-0 overflow-y-auto overflow-x-hidden chat-scroll overlay-scrollbar-target`,observeMutations:!1,"data-scroll-shadow":`true`,"data-scrollbar":`chat`,children:(0,$.jsxs)(`div`,{className:`relative min-h-full`,children:[qe,Xe,tt,Qe]})}),it]})}),t[149]=pe,t[150]=Xe,t[151]=qe,t[152]=B?.error,t[153]=V,t[154]=it,t[155]=tt,t[156]=Ve,t[157]=st):st=t[157];let ct;t[158]!==k.agentName||t[159]!==k.modelId||t[160]!==k.providerId||t[161]!==j||t[162]!==ee?(ct=ee?(0,$.jsx)(Qo,{agentName:k.agentName,providerId:k.providerId,modelId:k.modelId,modelName:j}):null,t[158]=k.agentName,t[159]=k.modelId,t[160]=k.providerId,t[161]=j,t[162]=ee,t[163]=ct):ct=t[163];let lt;t[164]!==r||t[165]!==n||t[166]!==ot||t[167]!==st||t[168]!==ct?(lt=(0,$.jsxs)(`div`,{className:`relative flex h-full min-h-0 flex-col bg-background`,"data-context-session-surface":`true`,"data-session-id":r,"data-surface-id":n,children:[ot,st,ct]}),t[164]=r,t[165]=n,t[166]=ot,t[167]=st,t[168]=ct,t[169]=lt):lt=t[169];let ut;return t[170]!==Ue||t[171]!==lt?(ut=(0,$.jsx)(Oa.Provider,{value:Ue,children:lt}),t[170]=Ue,t[171]=lt,t[172]=ut):ut=t[172],ut},qg=e=>{let t=(0,Q.c)(22),n=yr(),{t:r}=Nr(),i;t[0]===e.directory?i=t[1]:(i=dg(e.directory),t[0]=e.directory,t[1]=i);let a=i,o=a===dg(n),s;t[2]!==a||t[3]!==e.active||t[4]!==e.onNavigateSession||t[5]!==e.sessionId||t[6]!==e.surfaceId?(s={kind:`panel`,surfaceId:e.surfaceId,sessionId:e.sessionId,directory:a,active:e.active,capabilities:Da,navigateSession:e.onNavigateSession},t[2]=a,t[3]=e.active,t[4]=e.onNavigateSession,t[5]=e.sessionId,t[6]=e.surfaceId,t[7]=s):s=t[7];let c=s;if(!o){let n=e.sessionId,i=e.surfaceId,a;t[8]===r?a=t[9]:(a=r(`chat.emptyState.opencodeUnreachable`),t[8]=r,t[9]=a);let o;t[10]===a?o=t[11]:(o=(0,$.jsx)(Gg,{state:`directory-mismatch`,onRetry:Yg,error:a}),t[10]=a,t[11]=o);let s;t[12]!==e.sessionId||t[13]!==e.surfaceId||t[14]!==o?(s=(0,$.jsx)(`div`,{className:`h-full`,"data-context-session-surface":`true`,"data-session-id":n,"data-surface-id":i,children:o}),t[12]=e.sessionId,t[13]=e.surfaceId,t[14]=o,t[15]=s):s=t[15];let l;return t[16]!==c||t[17]!==s?(l=(0,$.jsx)(Oa.Provider,{value:c,children:s}),t[16]=c,t[17]=s,t[18]=l):l=t[18],l}let l;return t[19]!==e||t[20]!==n?(l=(0,$.jsx)(Kg,{...e,syncDirectory:n}),t[19]=e,t[20]=n,t[21]=l):l=t[21],l};function Jg(e){return e.providers}function Yg(){}var Xg=e=>{let t=e.trim();if(!t)return`about:blank`;try{let e=new URL(t.includes(`://`)?t:`https://${t}`);return e.protocol!==`http:`&&e.protocol!==`https:`?`about:blank`:e.toString()}catch{return`about:blank`}},Zg=(e,t)=>{let n=Xg(e),r=n===`about:blank`?``:n;return!r||r===t?null:r},Qg=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.x==`number`&&typeof t.y==`number`},$g=e=>!e||typeof e!=`object`?!1:Object.values(e).every(e=>typeof e==`string`),e_=e=>{if(!e||typeof e!=`object`)return!1;let t=e,n=t.bounds;return typeof t.tag==`string`&&typeof t.text==`string`&&typeof t.selector==`string`&&typeof t.path==`string`&&!!n&&typeof n?.x==`number`&&typeof n?.y==`number`&&typeof n?.width==`number`&&typeof n?.height==`number`&&Qg(t.center)&&$g(t.attributes)&&$g(t.computedStyle)&&Array.isArray(t.ancestry)},t_=({pageUrl:e,viewport:t,devicePixelRatio:n,target:r,screenshotAttached:i,intro:a})=>{let o=r.text.trim(),s=Object.entries(r.attributes).map(([e,t])=>`${e}="${t}"`).join(` `),c=r.computedStyle,l=r.bounds,u=r.center,d=a.replace(/[.:]+$/g,``),f=r.ancestry.map(e=>e.selectorPart).join(` > `);return[`${d}:`,`Page: ${e||`preview`}`,`Viewport: ${t.width}x${t.height}, DPR ${n}`,`Screenshot: ${i?`attached`:`not attached`}`,`Element: ${r.tag}`,o?`Text: ${o}`:null,`- Selector: ${r.selector}`,`- Path: ${r.path}`,f?`- Ancestry: ${f}`:null,s?`- Attributes: ${s}`:null,`- Bounds: x=${Math.round(l.x)}, y=${Math.round(l.y)}, width=${Math.round(l.width)}, height=${Math.round(l.height)}`,`- Center: x=${Math.round(u.x)}, y=${Math.round(u.y)}`,`Styles: display=${c.display}; position=${c.position}; font=${c.fontWeight} ${c.fontSize} / ${c.lineHeight} ${c.fontFamily}; color=${c.color}; background=${c.backgroundColor}; z-index=${c.zIndex}`].filter(e=>typeof e==`string`).join(`
18
+ `)},n_=async(e,t,n)=>{let r=Mt(n);if(r.assertCurrent(),typeof window<`u`)try{let n=e.getBoundingClientRect(),i=await I(`desktop_capture_page_rect`,{x:n.left,y:n.top,width:n.width,height:n.height});if(r.assertCurrent(),!i)throw Error(`Desktop screenshot capture is not available`);let a=new Image;await new Promise((e,t)=>{a.onload=()=>e(),a.onerror=()=>t(Error(`Failed to load desktop preview screenshot`)),a.src=`data:${i.mime};base64,${i.base64}`});let o=Math.max(1,a.naturalWidth||i.width||Math.floor(n.width)),s=Math.max(1,a.naturalHeight||i.height||Math.floor(n.height)),c=Math.min(1,1200/o),l=document.createElement(`canvas`);l.width=Math.floor(o*c),l.height=Math.floor(s*c);let u=l.getContext(`2d`);if(!u)return null;u.scale(c,c),u.drawImage(a,0,0,o,s);let d=o/Math.max(1,n.width),f=s/Math.max(1,n.height);u.fillStyle=`rgba(37, 99, 235, 0.28)`,u.strokeStyle=`rgb(37, 99, 235)`,u.lineWidth=Math.max(2,2*d),u.fillRect(t.bounds.x*d,t.bounds.y*f,t.bounds.width*d,t.bounds.height*f),u.strokeRect(t.bounds.x*d,t.bounds.y*f,t.bounds.width*d,t.bounds.height*f);let p=await new Promise(e=>l.toBlob(e,`image/jpeg`,.82));return r.assertCurrent(),p?new File([p],`preview-annotation-${Date.now()}.jpg`,{type:`image/jpeg`}):null}catch(e){return console.warn(`[preview] failed to capture annotation screenshot:`,e),null}let i=await M_(e,t,n);return r.assertCurrent(),i},r_=async(e,t,n,r,i,a)=>{if(!e)return null;try{let o=new Image;await new Promise((t,n)=>{o.onload=()=>t(),o.onerror=()=>n(Error(`Failed to load desktop browser screenshot`)),o.src=`data:image/jpeg;base64,${e}`});let s=Math.max(1,o.naturalWidth||t),c=Math.max(1,o.naturalHeight||n),l=Math.min(1,1200/s),u=document.createElement(`canvas`);u.width=Math.floor(s*l),u.height=Math.floor(c*l);let d=u.getContext(`2d`);if(!d)return null;d.scale(l,l),d.drawImage(o,0,0,s,c);let f=s/Math.max(1,r||s),p=c/Math.max(1,i||c);d.fillStyle=`rgba(37, 99, 235, 0.14)`,d.strokeStyle=`rgb(37, 99, 235)`,d.lineWidth=Math.max(2,2*f),d.fillRect(a.bounds.x*f,a.bounds.y*p,a.bounds.width*f,a.bounds.height*p),d.strokeRect(a.bounds.x*f,a.bounds.y*p,a.bounds.width*f,a.bounds.height*p);let m=await new Promise(e=>u.toBlob(e,`image/jpeg`,.82));return m?new File([m],`browser-annotation-${Date.now()}.jpg`,{type:`image/jpeg`}):null}catch{return null}},i_=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=`,a_=new Map,o_=new Map,s_=3e4,c_=e=>{let t=a_.get(e);return t?t.expiresAt-Date.now()<=s_?(a_.delete(e),null):t:null};function l_(e){let t=e.defaultView??window;try{let n=e.body?t.getComputedStyle(e.body).backgroundColor:``;if(n&&n!==`rgba(0, 0, 0, 0)`&&n!==`transparent`)return n;let r=t.getComputedStyle(e.documentElement).backgroundColor;if(r&&r!==`rgba(0, 0, 0, 0)`&&r!==`transparent`)return r}catch{}return`#ffffff`}var u_=e=>new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(typeof r.result==`string`?r.result:i_),r.onerror=()=>n(r.error??Error(`Failed to read image blob`)),r.readAsDataURL(e)}),d_=async(e,t=.82)=>{let n=await new Promise(n=>e.toBlob(n,`image/jpeg`,t));return n&&(await u_(n)).split(`,`,2)[1]||``},f_=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},p_=(...e)=>{f_()&&[...e]},m_=(e,t=8)=>{let n=[];try{let r=e.querySelectorAll(`*`);for(let e of r){let r=e.scrollTop||0,i=e.scrollLeft||0;if(r<=0&&i<=0)continue;let a=e.tagName.toLowerCase(),o=e.id?`#${e.id}`:``,s=typeof e.className==`string`&&e.className?`.${e.className.trim().split(/\s+/).slice(0,2).join(`.`)}`:``;if(n.push({selector:`${a}${o}${s}`,scrollTop:r,scrollLeft:i,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scrollWidth:e.scrollWidth,scrollHeight:e.scrollHeight}),n.length>=t)break}}catch{}return n},h_=`data-yuri-fixed-pin`,g_=(e,t,n)=>{if(t<=0&&n<=0)return()=>{};let r=e.defaultView;if(!r)return()=>{};let i=[],a=[];try{for(let o of e.querySelectorAll(`*`)){if(r.getComputedStyle(o).position!==`fixed`)continue;let e=o.getBoundingClientRect();if(!(e.width>0&&e.height>0))continue;o.setAttribute(h_,JSON.stringify({top:e.top+n,left:e.left+t,width:e.width,height:e.height})),i.push(o);let s=o.tagName.toLowerCase(),c=typeof o.className==`string`&&o.className?`.${o.className.trim().split(/\s+/).slice(0,2).join(`.`)}`:``;a.push({selector:`${s}${c}`,top:Math.round(e.top),left:Math.round(e.left),width:Math.round(e.width),height:Math.round(e.height)})}}catch{}return p_(`tagged fixed elements`,a),()=>{for(let e of i)try{e.removeAttribute(h_)}catch{}}},__={name:`yuri-fixed-pin`,afterClone(e){let t=e?.clone;if(!(!t||typeof t.querySelectorAll!=`function`))for(let e of t.querySelectorAll(`[${h_}]`)){let t;try{t=JSON.parse(e.getAttribute(h_)||``)}catch{continue}e.style.setProperty(`position`,`absolute`,`important`),e.style.setProperty(`top`,`${t.top}px`,`important`),e.style.setProperty(`left`,`${t.left}px`,`important`),e.style.setProperty(`right`,`auto`,`important`),e.style.setProperty(`bottom`,`auto`,`important`),e.style.setProperty(`width`,`${t.width}px`,`important`),e.style.setProperty(`height`,`${t.height}px`,`important`),e.removeAttribute(h_)}}},v_=`data-yuri-scroll-pin`,y_=e=>{let t=[],n=m_(e,64);try{let n=e.documentElement,r=e.body;for(let i of e.querySelectorAll(`*`)){let e=i.scrollTop||0,a=i.scrollLeft||0;if(e<=0&&a<=0)continue;let o=i!==n&&i!==r;o&&i.setAttribute(v_,JSON.stringify({top:e,left:a})),t.push({el:i,top:e,left:a,tagged:o})}}catch{}return{reapply:()=>{for(let e of t)try{e.el.scrollHeight,e.el.scrollTop!==e.top&&(e.el.scrollTop=e.top),e.el.scrollLeft!==e.left&&(e.el.scrollLeft=e.left)}catch{}},cleanup:()=>{for(let e of t)if(e.tagged)try{e.el.removeAttribute(v_)}catch{}},snapshot:n}},b_={name:`yuri-nested-scroll`,afterClone(e){let t=e?.clone;if(!t||typeof t.querySelectorAll!=`function`)return;let n=t.ownerDocument;if(n)for(let e of t.querySelectorAll(`[${v_}]`)){let t;try{t=JSON.parse(e.getAttribute(v_)||``)}catch{e.removeAttribute(v_);continue}let r=`translate(${-t.left}px, ${-t.top}px)`,i=e.children.length===1&&e.firstElementChild instanceof HTMLElement&&e.firstElementChild.style.willChange===`transform`?e.firstElementChild:null;if(i)i.style.transform=r;else{e.style.overflow=`hidden`;let t=n.createElement(`div`);for(t.style.transform=r,t.style.willChange=`transform`,t.style.display=`inline-block`,t.style.width=`100%`;e.firstChild;)t.appendChild(e.firstChild);e.appendChild(t)}e.removeAttribute(v_)}}},x_=async(e,t)=>{try{let n=await fetch(e,{credentials:t});return n.ok?await u_(await n.blob()):null}catch{return null}},S_=async(e,t)=>{if(e.protocol!==`http:`&&e.protocol!==`https:`)return``;let n=t?JSON.stringify([t.queryScope,e.origin]):e.origin,r=t=>{let n=new URLSearchParams(e.search);return t.previewToken&&n.set(`yuri_preview_token`,t.previewToken),`${t.proxyBasePath}${e.pathname}${n.size?`?${n}`:``}${e.hash}`},i=c_(n);if(i)return r(i);let a=o_.get(n),o=a??(async()=>{try{let r=Mt(t),i=await r.fetch(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({url:e.toString(),allowExternal:!0})});if(!i.ok)return a_.delete(n),null;let a=await i.json();r.assertCurrent();let o=typeof a.proxyBasePath==`string`?a.proxyBasePath:``,s=typeof a.expiresAt==`number`?a.expiresAt:0;if(!o||t&&(!ua(o)||o.startsWith(`/api/hosts/`)&&!o.startsWith(A(t.location.hostId,`/api/preview/proxy/`))))return a_.delete(n),null;let c={proxyBasePath:o,expiresAt:s,...typeof a.previewToken==`string`?{previewToken:a.previewToken}:{}};if(t){for(let[e,t]of a_)t.expiresAt<=Date.now()&&a_.delete(e);for(;a_.size>=64;)a_.delete(a_.keys().next().value)}return a_.set(n,c),c}catch{return a_.delete(n),null}finally{o_.delete(n)}})();a||o_.set(n,o);let s=await o;return s?r(s):``},C_=async(e,t,n)=>{if(!e||e.startsWith(`data:`))return e;try{let r=new URL(e,t.baseURI);if(n&&[`http:`,`https:`].includes(r.protocol)){let e=Mt(n),t=A(n.location.hostId,`/api`).slice(0,-4),i;if(r.pathname.startsWith(`${t}/api/`))i=`${r.pathname.slice(t.length)}${r.search}`;else if(r.origin===window.location.origin&&r.pathname.startsWith(`/api/`)&&!r.pathname.startsWith(`/api/hosts/`))i=`${r.pathname}${r.search}`;else{let e=await S_(r,n);if(!e)return i_;i=e.startsWith(`${t}/api/`)?e.slice(t.length):e}let a=await e.fetch(i);if(!a.ok)return i_;let o=await u_(await a.blob());return e.assertCurrent(),o}if(r.origin===window.location.origin||r.protocol!==`http:`&&r.protocol!==`https:`)return await x_(r.toString(),`include`)??i_;let i=await S_(r);return(i?await x_(i,`include`):null)||(await x_(r.toString(),`omit`)??i_)}catch{return i_}},w_=async(e,t,n)=>{if(!e||e===`none`||!e.includes(`url(`))return e;let r=Array.from(e.matchAll(/url\((['"]?)(.*?)\1\)/g)),i=e;for(let e of r){let r=e[2]||``;if(!r||r.startsWith(`data:`))continue;let a=await C_(r,t,n);i=i.replace(e[0],`url("${a}")`)}return i},T_=e=>e.complete?Promise.resolve():new Promise(t=>{e.addEventListener(`load`,()=>t(),{once:!0}),e.addEventListener(`error`,()=>t(),{once:!0})}),E_=e=>{let t=e.style.cssText;return()=>{e.style.cssText=t}},D_=e=>{let t=Number.parseFloat(e.lineHeight);if(Number.isFinite(t)&&t>0)return t;let n=Number.parseFloat(e.fontSize);return Number.isFinite(n)&&n>0?n*1.2:16},O_=(e,t,n)=>{let r=[],i=e.defaultView??window,a=Array.from(e.querySelectorAll(`button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *`));for(let e of a){let a=e.textContent?.replace(/\s+/g,` `).trim()??``;if(!a||!a.includes(` `))continue;let o=e.getBoundingClientRect();if(o.width<=0||o.height<=0||o.right<0||o.bottom<0||o.left>t||o.top>n)continue;let s=i.getComputedStyle(e);if(s.display===`none`||s.visibility===`hidden`||Number(s.opacity)===0)continue;let c=s.getPropertyValue(`text-wrap`),l=s.getPropertyValue(`text-wrap-mode`),u=s.whiteSpace.includes(`nowrap`)||c===`nowrap`||l===`nowrap`,d=o.height<=D_(s)*1.7;!u&&(!d||o.width>t*.72)||(r.push(E_(e)),e.style.whiteSpace=`nowrap`,e.style.overflowWrap=`normal`,e.style.wordBreak=`normal`,e.style.setProperty(`text-wrap`,`nowrap`),e.style.setProperty(`text-wrap-mode`,`nowrap`))}return()=>{for(let e=r.length-1;e>=0;--e)r[e]?.()}},k_=(e,t,n,r)=>{let i=[],a=e.defaultView??window,o=a.scrollX||e.documentElement.scrollLeft||e.body?.scrollLeft||0,s=a.scrollY||e.documentElement.scrollTop||e.body?.scrollTop||0,c=Array.from(e.querySelectorAll(`*`)).filter(e=>{let r=a.getComputedStyle(e);if(r.position!==`fixed`||r.display===`none`||r.visibility===`hidden`||Number(r.opacity)===0)return!1;let i=e.getBoundingClientRect();return i.width>0&&i.height>0&&i.right>=0&&i.bottom>=0&&i.left<=t&&i.top<=n}).filter((e,t,n)=>!n.some((n,r)=>r<t&&n.contains(e)));for(let e of c){let t=e.getBoundingClientRect(),n=a.getComputedStyle(e),c=Math.ceil(t.width)+8,l=Math.ceil(t.height)+2;r?.add(e),i.push(E_(e)),e.style.position=`absolute`,e.style.top=`${t.top+s}px`,e.style.left=`${t.left+o}px`,e.style.right=`auto`,e.style.bottom=`auto`,e.style.width=`${c}px`,e.style.minWidth=`${c}px`,e.style.height=`${l}px`,e.style.minHeight=`${l}px`,e.style.margin=`0`,e.style.boxSizing=`border-box`,e.style.transform=`none`,n.zIndex!==`auto`&&(e.style.zIndex=n.zIndex)}return()=>{for(let e=i.length-1;e>=0;--e)i[e]?.()}},A_=async(e,t,n,r={})=>{let i=[],a=e.defaultView??window,o=r=>{if(r===e.documentElement||r===e.body)return!0;try{let e=r.getBoundingClientRect();return e.width>0&&e.height>0&&e.right>=0&&e.bottom>=0&&e.left<=t&&e.top<=n}catch{return!1}};if(r.applyLayoutWorkarounds){let r=new WeakSet;i.push(k_(e,t,n,r)),i.push(O_(e,t,n))}let s=new Map;for(let t of Array.from(e.images))s.set(t,t.currentSrc||t.src||t.getAttribute(`src`)||``);let c=Array.from(e.querySelectorAll(`picture`));for(let e of c){let t=Array.from(e.querySelectorAll(`source`));if(t.length===0)continue;let n=t.map(e=>({source:e,srcset:e.getAttribute(`srcset`),sizes:e.getAttribute(`sizes`)}));i.push(()=>{for(let e of n)e.srcset===null?e.source.removeAttribute(`srcset`):e.source.setAttribute(`srcset`,e.srcset),e.sizes===null?e.source.removeAttribute(`sizes`):e.source.setAttribute(`sizes`,e.sizes)});for(let e of t)e.removeAttribute(`srcset`),e.removeAttribute(`sizes`)}let l=Array.from(e.images).filter(e=>o(e));await Promise.all(l.map(async t=>{let n=s.get(t)||t.currentSrc||t.src||t.getAttribute(`src`)||``;if(!n)return;await T_(t);let a=await C_(n,e,r.entry),o={src:t.getAttribute(`src`),srcset:t.getAttribute(`srcset`),sizes:t.getAttribute(`sizes`)};i.push(()=>{o.src===null?t.removeAttribute(`src`):t.setAttribute(`src`,o.src),o.srcset===null?t.removeAttribute(`srcset`):t.setAttribute(`srcset`,o.srcset),o.sizes===null?t.removeAttribute(`sizes`):t.setAttribute(`sizes`,o.sizes)}),t.removeAttribute(`srcset`),t.removeAttribute(`sizes`),t.setAttribute(`src`,a||i_),await T_(t)}));let u=Array.from(e.querySelectorAll(`*`)).filter(o);return await Promise.all(u.map(async t=>{let n=a.getComputedStyle(t).backgroundImage;if(!n||n===`none`||!n.includes(`url(`))return;let o=await w_(n,e,r.entry);if(o===n)return;let s=t.style.backgroundImage;i.push(()=>{t.style.backgroundImage=s}),t.style.backgroundImage=o})),()=>{for(let e=i.length-1;e>=0;--e)try{i[e]?.()}catch{}}};async function j_(e,t,n){try{let r=e.contentWindow,i=e.contentDocument??r?.document,a=i?.documentElement;if(!r||!i||!a)return null;let o=e.getBoundingClientRect(),s=Math.max(1,Math.ceil(r.innerWidth||e.clientWidth||o.width)),c=Math.max(1,Math.ceil(r.innerHeight||e.clientHeight||o.height)),l=i.body,u=i.scrollingElement instanceof HTMLElement?i.scrollingElement:null,d=r.scrollX||0,f=r.scrollY||0,p=r.pageXOffset||0,m=r.pageYOffset||0,h=r.visualViewport?.pageLeft||r.visualViewport?.offsetLeft||0,g=r.visualViewport?.pageTop||r.visualViewport?.offsetTop||0,_=a.scrollLeft||0,v=a.scrollTop||0,y=l?.scrollLeft||0,b=l?.scrollTop||0,x=u?.scrollLeft||0,S=u?.scrollTop||0,C=Math.max(d,p,h,_,y,x),w=Math.max(f,m,g,v,b,S);p_(`scroll sources`,{windowScrollX:d,windowScrollY:f,pageScrollX:p,pageScrollY:m,visualViewportScrollX:h,visualViewportScrollY:g,rootScrollX:_,rootScrollY:v,bodyScrollX:y,bodyScrollY:b,scrollingElementScrollX:x,scrollingElementScrollY:S,scrollingElementTag:u?.tagName?.toLowerCase()??null,resolvedScrollX:C,resolvedScrollY:w,nestedScrolledElements:m_(i)});let T=Math.max(s,a.scrollWidth||0,l?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),E=Math.max(c,a.scrollHeight||0,l?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),D=Math.min(2,Math.max(1,window.devicePixelRatio||1)),O=a.style.scrollBehavior,k=l?.style.scrollBehavior??``;a.style.scrollBehavior=`auto`,l&&(l.style.scrollBehavior=`auto`);let A=y_(i);p_(`nested scroll snapshot`,A.snapshot);let j=()=>{},M=()=>{};try{await i.fonts?.ready.catch(()=>void 0),j=await A_(i,s,c,{applyLayoutWorkarounds:!1,entry:n}),r.scrollTo(C,w),M=g_(i,C,w),A.reapply();let e={backgroundColor:l_(i),cache:`disabled`,dpr:D,embedFonts:!0,fast:!1,height:E,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[__,b_],quality:.82,width:T},o=await(await Eu(a,e)).toCanvas();if(!o.width||!o.height)return null;let l=o.width/Math.max(1,T),u=o.height/Math.max(1,E),d=Math.min(o.width,Math.max(1,Math.round(s*l))),f=Math.min(o.height,Math.max(1,Math.round(c*u))),p=Math.max(0,o.width-d),m=Math.max(0,o.height-f),h=Math.min(p,Math.max(0,Math.round(C*l))),g=Math.min(m,Math.max(0,Math.round(w*u)));p_(`capture geometry`,{viewportWidth:s,viewportHeight:c,captureWidth:T,captureHeight:E,canvasWidth:o.width,canvasHeight:o.height,xScale:l,yScale:u,sourceX:h,sourceY:g,sourceWidth:d,sourceHeight:f});let _=i.createElement(`canvas`);_.width=d,_.height=f;let v=_.getContext(`2d`);if(!v)return null;v.drawImage(o,h,g,d,f,0,0,d,f);let y=await d_(_,.82);return y?await r_(y,s,c,s,c,t):null}finally{M(),A.cleanup(),j(),r.scrollTo(C,w),A.reapply(),a.style.scrollBehavior=O,l&&(l.style.scrollBehavior=k)}}catch(e){return console.warn(`[preview] failed to capture iframe DOM screenshot with snapDOM:`,e),null}}async function M_(e,t,n){let r=await j_(e,t,n);if(r)return r;try{let r=e.contentWindow,i=e.contentDocument??r?.document,a=i?.documentElement;if(!r||!i||!a)return null;let o=e.getBoundingClientRect(),s=Math.max(1,Math.ceil(r.innerWidth||e.clientWidth||o.width)),c=Math.max(1,Math.ceil(r.innerHeight||e.clientHeight||o.height)),l=r.scrollX||i.documentElement.scrollLeft||i.body?.scrollLeft||0,u=r.scrollY||i.documentElement.scrollTop||i.body?.scrollTop||0,d=i.body,f=Math.max(c,a.scrollHeight||0,d?.scrollHeight||0),p=Math.min(2,Math.max(1,window.devicePixelRatio||1)),m=a.style.scrollBehavior,h=d?.style.scrollBehavior??``;a.style.scrollBehavior=`auto`,d&&(d.style.scrollBehavior=`auto`);let g=``,_=()=>{};try{await i.fonts?.ready.catch(()=>void 0),_=await A_(i,s,c,{applyLayoutWorkarounds:!0,entry:n}),r.scrollTo(l,u);let e=await Ou(a).catch(()=>``);g=await Du(a,{quality:.82,pixelRatio:p,width:s,height:c,backgroundColor:l_(i),imagePlaceholder:i_,fontEmbedCSS:e||void 0,style:{transform:`translate(${-l}px, ${-u}px)`,transformOrigin:`top left`,minWidth:`${s}px`,minHeight:`${f}px`},cacheBust:!0})}finally{_(),r.scrollTo(l,u),a.style.scrollBehavior=m,d&&(d.style.scrollBehavior=h)}let v=g.split(`,`,2)[1]||``;return v?await r_(v,s,c,s,c,t):null}catch(e){return console.warn(`[preview] failed to capture iframe DOM screenshot:`,e),null}}var N_=()=>{if(!(typeof window>`u`))return window.__YURI_DESKTOP__?.browserRelay};async function P_(e,n,r){let i=N_();if(!i)throw Error(`Browser network unsupported`);let a=Mt(r),o=d(),s=!1,l,u,f=new AbortController,p=()=>{},m=()=>{},h=()=>{},g=()=>{},_=new Promise((e,t)=>{g=t});_.catch(()=>{});let v=()=>{s||(s=!0,e.removeEventListener(`abort`,b),f.abort(),p(),m(),h(),u?.close(),l&&i.stop(l.scope).catch(()=>{}),g(new DOMException(`Browser runtime ended`,`AbortError`)))},y=e=>{s||(v(),n(e))},b=()=>v(),x=()=>{if(s||e.aborted||o!==d())throw new DOMException(`Browser runtime ended`,`AbortError`);a.assertCurrent(e)},S=setTimeout(()=>y(Error(`Browser Relay timed out`)),2e4);try{x(),e.addEventListener(`abort`,b,{once:!0}),m=c(()=>y(Error(`Browser runtime changed`))),h=t(()=>y(Error(`Browser authorization changed`)));let n=Promise.resolve(),a=0;u=await Promise.race([ca({signal:f.signal,path:A(r?.location.hostId,`/api/gui-network/ws`),openSocket(e){return x(),He(e)},onFailure:()=>y(Error(`Browser Relay disconnected`)),onMessage(e){if(s||!l)return;x();let t=typeof e.data==`string`?e.data:new Uint8Array(e.data),r=typeof t==`string`?t.length*2:t.byteLength;if(a+=r,a>4194304){y(Error(`Browser Relay buffer limit`));return}n=n.then(async()=>{!s&&l&&(x(),await i.write(l.scope,t))}).catch(()=>y(Error(`Browser Relay stream failed`))).finally(()=>{a-=r})}}),_]),x();let o=u.socket;p=i.subscribe(e=>{if(!(s||e.scope!==l?.scope))try{if(x(),o.readyState!==1)throw Error(`Browser Relay disconnected`);o.send(e.data)}catch{y(Error(`Browser Relay disconnected`))}});let d=i.start().then(e=>(s&&i.stop(e.scope).catch(()=>{}),e));if(l=await Promise.race([d,_]),x(),!l.partition.startsWith(`yuri-browser-relay-`))throw Error(`Invalid Browser partition`);return{partition:l.partition,release:v}}catch(e){throw v(),e}finally{clearTimeout(S)}}var F_=()=>!S()||p()===`local`,I_=300,L_=1400,R_=600,z_=24,B_=400,V_=new Map,H_=()=>()=>{},U_=200,W_=(e,t)=>t===`all`?!0:t===`errors`?e.level===`error`||e.level===`runtime`||e.level===`resource`:t===`warnings`?e.level===`warn`:e.level===`log`||e.level===`info`||e.level===`debug`,G_=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+$/g,``);return r=r.replace(/\/+/g,`/`),n&&!r.startsWith(`//`)&&(r=`/${r}`),r===``?t.startsWith(`/`)?`/`:``:r},K_=e=>Number.isFinite(e)?Math.min(L_,Math.max(I_,Math.round(e))):R_,q_=e=>{let t=e?.parentElement?.clientWidth;return!t||t<=0?null:t},J_=(e,t)=>{let n=K_(e),r=q_(t);return r===null?n:Math.min(n,Math.max(1,r))},Y_=(e,t)=>{if(!e)return``;let n=e.replace(/\\/g,`/`),r=t.replace(/\\/g,`/`).replace(/\/+$/,``);return r&&n.startsWith(r+`/`)?n.slice(r.length+1):n},X_=(e,t)=>t(e===`chat`?`contextPanel.mode.chat`:e===`btw`?`chat.btw.title`:e===`file`?`contextPanel.mode.files`:e===`diff`||e===`file-diff`?`contextPanel.mode.diff`:e===`preview`?`contextPanel.mode.preview`:e===`browser`?`contextPanel.mode.browser`:`contextPanel.mode.context`),Z_=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`).trim();if(!t)return null;let n=t.split(`/`).filter(Boolean);return n.length===0?t:n[n.length-1]||null},Q_=(e,t,n)=>{if(e.mode===`chat`){let r=ev(e.dedupeKey);if(r){let e=t.get(r)?.trim();if(e)return e}return e.sessionTitleFallback?.trim()||n(`contextPanel.mode.chat`)}if(e.label)return e.label;if(e.mode===`file`)return Z_(e.targetPath)||n(`contextPanel.mode.files`);if(e.mode===`preview`){let t=e.targetPath;if(t)try{let e=new URL(t);return e.host||e.hostname||n(`contextPanel.mode.preview`)}catch{}return n(`contextPanel.mode.preview`)}return e.mode===`diff`?n(`contextPanel.mode.diff`):e.mode===`file-diff`?Z_(e.targetPath)||n(`contextPanel.mode.diff`):X_(e.mode,n)},$_=e=>{if(e.mode===`file`)return e.targetPath?(0,$.jsx)(ri,{filePath:e.targetPath,className:`h-3.5 w-3.5`}):void 0;if(e.mode===`diff`||e.mode===`file-diff`)return(0,$.jsx)(X,{name:`arrow-left-right`,className:`h-3.5 w-3.5`});if(e.mode===`context`)return(0,$.jsx)(X,{name:`file-list-2`,className:`h-3.5 w-3.5`});if(e.mode===`chat`)return(0,$.jsx)(X,{name:`chat-thread`,className:`h-3.5 w-3.5`});if(e.mode===`preview`)return(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5 text-[var(--status-info)]`});if(e.mode===`browser`)return(0,$.jsx)(X,{name:`global`,className:`h-3.5 w-3.5`})},ev=e=>!e||!e.startsWith(`session:`)?null:e.slice(8).trim()||null,tv=(e,t)=>{if(e.size!==t.size)return!1;for(let[n,r]of e)if(t.get(n)!==r)return!1;return!0},nv=(e,t)=>{if(t.length===0)return V_;let n=new Set(t),r=new Map;for(let t of e){if(!n.has(t.id))continue;let e=t.title?.trim();e&&r.set(t.id,e)}return r.size===0?V_:r},rv=(e,t,n)=>{let r=bt(),i=!!r?.entry.location.hostId,a=wn(r?.entry.location.hostId?void 0:e,{bootstrap:!r?.entry.location.hostId}),o=Z.useRef(V_),s=Z.useRef(t);s.current=t;let c=Z.useSyncExternalStore(i?H_:a.subscribe,Z.useMemo(()=>()=>{if(i)return V_;let e=nv(a.getState().session,s.current);return tv(o.current,e)?o.current:(o.current=e,e)},[i,a]),()=>V_);return Z.useMemo(()=>r?.entry.location.hostId?nv(n??[],t):c,[r?.entry.location.hostId,c,n,t])},iv=`new Promise((resolve) => {
19
+ const existing = document.getElementById('__yuri_desktop_browser_overlay');
20
+ if (existing) existing.remove();
21
+ if (typeof window.__yuriDesktopBrowserCancelInspect === 'function') {
22
+ try { window.__yuriDesktopBrowserCancelInspect(); } catch { /* webview not ready */ }
23
+ }
24
+ const overlay = document.createElement('div');
25
+ overlay.id = '__yuri_desktop_browser_overlay';
26
+ overlay.style.cssText = 'position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #60a5fa;background:rgba(96,165,250,.24);border-radius:3px;display:none;box-sizing:border-box;';
27
+ document.documentElement.appendChild(overlay);
28
+ const cssEscape = (value) => {
29
+ try { return CSS.escape(value); } catch { return String(value).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&'); }
30
+ };
31
+ const selectorPart = (element) => {
32
+ const tag = element.tagName.toLowerCase();
33
+ if (element.id) return tag + '#' + cssEscape(element.id);
34
+ const className = String(element.className || '').trim().split(/\\s+/).filter(Boolean).slice(0, 3).map((part) => '.' + cssEscape(part)).join('');
35
+ return tag + className;
36
+ };
37
+ const metadata = (element) => {
38
+ const rect = element.getBoundingClientRect();
39
+ const style = getComputedStyle(element);
40
+ const ancestry = [];
41
+ let current = element;
42
+ while (current && current.nodeType === Node.ELEMENT_NODE && ancestry.length < 8) {
43
+ ancestry.unshift({ tag: current.tagName.toLowerCase(), id: current.id || undefined, className: typeof current.className === 'string' ? current.className : undefined, selectorPart: selectorPart(current) });
44
+ current = current.parentElement;
45
+ }
46
+ const attrs = {};
47
+ for (const attr of Array.from(element.attributes || []).slice(0, 16)) attrs[attr.name] = attr.value.slice(0, 300);
48
+ const path = ancestry.map((entry) => entry.selectorPart).join(' > ');
49
+ return {
50
+ frame: 'top',
51
+ tag: element.tagName.toLowerCase(),
52
+ text: String(element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 500),
53
+ selector: element.id ? '#' + cssEscape(element.id) : path,
54
+ path,
55
+ bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
56
+ center: { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
57
+ attributes: attrs,
58
+ computedStyle: { display: style.display, position: style.position, fontWeight: style.fontWeight, fontSize: style.fontSize, lineHeight: style.lineHeight, fontFamily: style.fontFamily, color: style.color, backgroundColor: style.backgroundColor, zIndex: style.zIndex },
59
+ ancestry,
60
+ };
61
+ };
62
+ const move = (event) => {
63
+ const element = document.elementFromPoint(event.clientX, event.clientY);
64
+ if (!element || element === overlay || element === document.documentElement || element === document.body) return;
65
+ const rect = element.getBoundingClientRect();
66
+ overlay.style.display = 'block';
67
+ overlay.style.left = rect.left + 'px';
68
+ overlay.style.top = rect.top + 'px';
69
+ overlay.style.width = rect.width + 'px';
70
+ overlay.style.height = rect.height + 'px';
71
+ };
72
+ const cleanup = () => {
73
+ window.removeEventListener('mousemove', move, true);
74
+ window.removeEventListener('click', click, true);
75
+ window.removeEventListener('keydown', keydown, true);
76
+ if (window.__yuriDesktopBrowserCancelInspect === cancel) {
77
+ delete window.__yuriDesktopBrowserCancelInspect;
78
+ }
79
+ };
80
+ const cancel = () => {
81
+ cleanup();
82
+ overlay.remove();
83
+ resolve(null);
84
+ };
85
+ const click = (event) => {
86
+ event.preventDefault();
87
+ event.stopPropagation();
88
+ const element = document.elementFromPoint(event.clientX, event.clientY);
89
+ const result = element ? metadata(element) : null;
90
+ cleanup();
91
+ overlay.remove();
92
+ resolve(result);
93
+ };
94
+ const keydown = (event) => {
95
+ if (event.key !== 'Escape') return;
96
+ cancel();
97
+ };
98
+ window.__yuriDesktopBrowserCancelInspect = cancel;
99
+ window.addEventListener('mousemove', move, true);
100
+ window.addEventListener('click', click, true);
101
+ window.addEventListener('keydown', keydown, true);
102
+ });`,av=`(() => {
103
+ if (typeof window.__yuriDesktopBrowserCancelInspect === 'function') {
104
+ window.__yuriDesktopBrowserCancelInspect();
105
+ return;
106
+ }
107
+ const overlay = document.getElementById('__yuri_desktop_browser_overlay');
108
+ if (overlay) overlay.remove();
109
+ })()`,ov=`(() => {
110
+ if (window.__yuriSameWebviewNavigationInstalled) return;
111
+ window.__yuriSameWebviewNavigationInstalled = true;
112
+
113
+ const navigate = (rawUrl) => {
114
+ if (typeof rawUrl !== 'string' || rawUrl.length === 0) return false;
115
+ try {
116
+ const url = new URL(rawUrl, window.location.href);
117
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
118
+ window.location.assign(url.href);
119
+ return true;
120
+ } catch (_error) {
121
+ return false;
122
+ }
123
+ };
124
+
125
+ const originalOpen = window.open.bind(window);
126
+ window.open = (url, target, features) => {
127
+ if (navigate(url)) return null;
128
+ return originalOpen(url, target, features);
129
+ };
130
+
131
+ document.addEventListener('click', (event) => {
132
+ if (event.defaultPrevented) return;
133
+ const target = event.target;
134
+ if (!(target instanceof Element)) return;
135
+ const anchor = target.closest('a[target="_blank"][href]');
136
+ if (!(anchor instanceof HTMLAnchorElement)) return;
137
+ if (!navigate(anchor.href)) return;
138
+ event.preventDefault();
139
+ event.stopPropagation();
140
+ }, true);
141
+ })()`,sv=async(e,t)=>{let n=e.contentWindow;if(!n)throw Error(`Iframe window is not available`);let r=n.eval.call(n,t);return await Promise.resolve(r)},cv=(e,t)=>e.length<=t?e:`${e.slice(0,t-3)}...`,lv=(e,t)=>{let n=A(e?.location.hostId,`/api/preview/proxy/`);return t.startsWith(n)?t:A(e?.location.hostId,t)},uv=(e,t)=>{let n=A(e?.location.hostId,`/api/preview/proxy/`),r=t.startsWith(n)?t.slice(n.length):t.startsWith(`/api/preview/proxy/`)?t.slice(19):``;return/^[a-f0-9]{16,64}$/i.test(r)},dv=e=>{if(typeof window>`u`)return``;try{return new URL(e||window.location.href,window.location.href).origin}catch{return window.location.origin}},fv=(e,t,n)=>{let r=dv(t);e.postMessage(n,r)},pv=e=>{if(!e)return e;try{let t=new URL(e);return t.searchParams.delete(`yuri_preview_token`),t.searchParams.delete(`yuri_client_token`),t.searchParams.delete(`yuri_url_token`),t.toString()}catch{return e}},mv=({rawUrl:e,onNavigate:t})=>{let n=bt()?.entry,r=n?.fetch??g,{t:a}=Nr(),{currentTheme:o}=ai(),[c,d]=Z.useReducer(e=>e+1,0),[f,p]=Z.useReducer(e=>e+1,0),[m,_]=Z.useState({status:`idle`}),[v,y]=Z.useState(``),b=Z.useRef(null),x=Z.useRef(1),[S,C]=Z.useState(!1),[w,T]=Z.useState(!1),[E,D]=Z.useState(`all`),[O,k]=Z.useState([]),[M,N]=Z.useState(!1),[P,F]=Z.useState(null),I=Vn(e=>e.currentSessionId),L=Vn(e=>e.newSessionDraft?.open),R=Tn(e=>e.remoteSession),z=n&&R&&te(R.location)===n.key?R:null,ee=n?.location.hostId?z?.sessionId??null:I,B=n?.location.hostId?!z?.sessionId:L,ne=ii(e=>e.addDraft),re=Fr(e=>e.addAttachedFile),ie=G(async e=>{if(!n?.location.hostId)return re(e);let t={transportIdentity:u(),location:n.location},r=ee?ft(t,ee):ut(t,`remote-new-session`);await Fr.getState().addDraftLocalAttachment(r,e)}),ae=n?.location.hostId?j(n.location,ee??`draft`):ee??(B?`draft`:null),oe=null;try{oe=e?new URL(e):null}catch{oe=null}let V=oe?oe.hostname===`localhost`||oe.hostname===`127.0.0.1`||oe.hostname===`::1`||oe.hostname===`[::1]`||oe.hostname===`0.0.0.0`:!1,H=V||!!n?.location.hostId,se=oe?oe.hostname===`0.0.0.0`?new URL(oe.toString().replace(`0.0.0.0`,`127.0.0.1`)):oe:null,U=se?se.toString():``,ce=U?n?.location.hostId?`${h()||`same-origin`}|${n.key}|${n.connectionGeneration}|${U}`:`${h()||`same-origin`}|${U}`:``,le=o.metadata.variant;Z.useEffect(()=>{if(!U||!H){_({status:`idle`});return}let e=c_(ce);if(e?.previewToken)return _({status:`ready`,proxyBasePath:e.proxyBasePath,previewToken:e.previewToken,expiresAt:e.expiresAt}),()=>{n?.location.hostId&&a_.delete(ce)};e&&a_.delete(ce);let t=!1;return _({status:`loading`}),(async()=>{try{let e=await r(`/api/preview/targets`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?.location.hostId?{"x-opencode-directory":n.location.directory}:{}},credentials:`include`,body:JSON.stringify({url:U,...n?.location.hostId&&!V?{allowExternal:!0}:{}})});if(!e.ok){a_.delete(ce);let n=await e.json().catch(()=>({})),r=typeof n?.error==`string`?n.error:`HTTP ${e.status}`;t||_({status:`error`,message:r});return}let i=await e.json(),o=typeof i.proxyBasePath==`string`&&uv(n,i.proxyBasePath)?lv(n,i.proxyBasePath):``,s=typeof i.previewToken==`string`?i.previewToken:``,c=typeof i.expiresAt==`number`?i.expiresAt:0;if(!uv(n,o)||!s||!Number.isFinite(c)||c<=Date.now()){a_.delete(ce),t||_({status:`error`,message:a(`contextPanel.preview.proxyError`)});return}if(t)return;n?.sdk(),a_.set(ce,{proxyBasePath:o,previewToken:s,expiresAt:c}),t||_({status:`ready`,proxyBasePath:o,previewToken:s,expiresAt:c})}catch(e){if(a_.delete(ce),!t){let t=e instanceof Error?e.message:String(e);_({status:`error`,message:t})}}})(),()=>{t=!0,n?.location.hostId&&a_.delete(ce)}},[n,r,V,H,ce,f,a,U]);let ue=se&&(se.protocol===`http:`||se.protocol===`https:`)?se.toString():``,de=H&&m.status===`ready`?`${m.proxyBasePath}|${m.previewToken||``}|${c}`:``;Z.useEffect(()=>{if(!de){y(``);return}let e=!1;return y(``),i(h()).then(t=>{!e&&t&&y(de)}).catch(()=>{}),()=>{e=!0}},[de]);let fe=H&&m.status===`ready`&&se&&v===de?(()=>{let e=se.pathname||`/`,t=new URLSearchParams(se.search);t.delete(`yuri_url_token`),t.delete(`yuri_client_token`),t.set(`yuriPreview`,String(c)),t.set(`yuri_preview_token`,m.previewToken||``);let r=t.toString(),i=se.hash||``;return l().authenticatedAsset(lv(n,`${m.proxyBasePath}${e}${r?`?${r}`:``}${i}`))})():``,pe=H&&s()&&da(),[me,he]=Z.useState(``);Z.useEffect(()=>{if(!pe){he(``);return}let e=!1;return he(``),fa().then(t=>{!e&&t&&he(t)}).catch(()=>{e||he(``)}),()=>{e=!0}},[pe,de]);let ge=H?la({relayActive:pe,gatewayOrigin:me||null,authenticatedAssetUrl:fe}):``,_e=pe&&!!fe&&!me,ve=H?_e?``:ge:ue,ye=H?pv(ge||fe):ue,be=H&&(m.status===`loading`||m.status===`idle`||v!==de||_e),xe=H&&m.status===`error`,Se=Z.useCallback(t=>{let r=ae;if(!r){Y.error(a(`contextPanel.preview.inspect.attachNoSession`));return}let i=e||ve||``,o=typeof window<`u`?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},s=typeof window<`u`?window.devicePixelRatio:1;(async()=>{let e=!1;try{let r=b.current,i=r?await n_(r,t,n):null;i&&(await ie(i),e=!0)}catch{e=!1}ne({sessionKey:r,source:`preview-annotation`,fileLabel:i||`preview`,startLine:1,endLine:1,code:t_({pageUrl:i,viewport:o,devicePixelRatio:s,target:t,screenshotAttached:e,intro:a(`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),Y.success(a(`contextPanel.preview.inspect.attached`))})()},[n,ie,ne,ae,ve,e,a]);Z.useEffect(()=>{C(!1),k([]),T(!1),D(`all`),N(!1),F(null),x.current=1},[ve]),Z.useEffect(()=>{let e=b.current?.contentWindow;!S||!e||fv(e,ve||fe,{source:`yuri-preview-parent`,version:1,type:`set-inspect-mode`,enabled:M})},[S,ve,M,fe]),Z.useEffect(()=>{let e=b.current?.contentWindow;!S||!e||fv(e,ve||fe,{source:`yuri-preview-parent`,version:1,type:`set-color-scheme`,scheme:le})},[S,ve,le,fe]),Z.useEffect(()=>{if(!M||typeof window>`u`)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),N(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[M]),Z.useEffect(()=>{if(!H||typeof window>`u`)return;let e=e=>{if(typeof e==`string`)return e;if(e==null)return``;try{return JSON.stringify(e)}catch{return String(e)}},r=e=>{let t=x.current;x.current+=1,k(n=>{let r=[...n,{...e,id:t}];return r.length>U_?r.slice(r.length-U_):r})},i=i=>{if(i.source!==b.current?.contentWindow)return;let o=i.data;if(!(!o||o.source!==`yuri-preview-bridge`||o.version!==1)){if(o.type===`ready`){C(!0);return}if(o.type===`console`){let t=o.level===`error`||o.level===`warn`||o.level===`info`||o.level===`debug`?o.level:`log`,n=Array.isArray(o.args)?o.args.map(e).filter(Boolean):[];r({level:t,message:n.join(` `),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`runtime-error`){let t=e(o.filename),n=typeof o.line==`number`?o.line:null,i=typeof o.column==`number`?o.column:null,s=t?`${t}${n===null?``:`:${n}${i===null?``:`:${i}`}`}`:``,c=e(o.stack);r({level:`runtime`,message:e(o.message)||a(`contextPanel.preview.console.runtimeError`),details:[s,c].filter(Boolean).join(`
142
+ `),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`resource-error`){let t=e(o.tag)||`resource`,n=e(o.url);r({level:`resource`,message:n?`${t}: ${n}`:t,details:e(o.outerHTML),ts:typeof o.ts==`number`?o.ts:Date.now()});return}if(o.type===`hover`){F(e_(o.target)?o.target:null);return}if(o.type===`select`&&e_(o.target)){F(o.target),N(!1),Se(o.target);return}if(o.type===`navigate-preview`){let e=typeof o.url==`string`?o.url:``,r=o.navigation===`external`?`external`:`proxy`;if(e&&r===`external`&&!n?.location.hostId){Ut(e);return}e&&t(e)}}};return window.addEventListener(`message`,i),()=>{window.removeEventListener(`message`,i)}},[n,Se,H,t,a]);let Ce=O.filter(e=>e.level===`error`||e.level===`runtime`||e.level===`resource`).length,we=O.filter(e=>W_(e,E)),Te=Z.useCallback(()=>{let t=[`Preview URL: ${e||ve||``}`,`Events: ${O.length}`,``].join(`
143
+ `),n=O.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
144
+ `);pr(`${t}${n}`).then(e=>{e.ok?Y.success(a(`contextPanel.preview.console.copied`)):Y.error(a(`contextPanel.preview.console.copyFailed`))})},[O,ve,e,a]),Ee=Z.useCallback(()=>{let t=ae;if(!t){Y.error(a(`contextPanel.preview.console.attachNoSession`));return}let n=[`Preview URL: ${e||ve||``}`,`Events: ${O.length}`,``].join(`
145
+ `),r=O.map(e=>{let t=new Date(e.ts).toISOString(),n=e.details?`\n${e.details}`:``;return`[${t}] [${e.level}] ${e.message}${n}`}).join(`
146
+ `);ne({sessionKey:t,source:`preview-console`,fileLabel:e||ve||`preview`,startLine:1,endLine:Math.max(1,O.length),code:`${n}${r}`,language:`text`,text:a(`contextPanel.preview.console.attachAnnotation`)}),Y.success(a(`contextPanel.preview.console.attached`))},[ne,O,ae,ve,e,a]),[De,Oe]=Z.useState(`unknown`),ke=Z.useRef(0),Ae=Z.useRef(0);Z.useEffect(()=>{if(!fe){Oe(`unknown`),ke.current=0,Ae.current=0;return}let e=!1;return ke.current||(ke.current=Date.now(),Ae.current=0),Oe(`unknown`),(async()=>{let t=await(async()=>{try{let e=new URL(fe,window.location.href),t=n?.location.hostId?A(n.location.hostId,`/api`).slice(0,-4):``,i=`${t&&e.pathname.startsWith(t+`/`)?e.pathname.slice(t.length):e.pathname}${e.search}`;return await r(i,{method:`GET`,credentials:`include`,cache:`no-store`,redirect:`manual`})}catch{return null}})();if(e)return;if(!t){Oe(`unreachable`);return}if(t.status===403||t.status===404){a_.delete(ce),_({status:`loading`}),p();return}if(t.status!==502){Oe(`reachable`);return}let i=ke.current||Date.now();if(Date.now()-i<15e3){Oe(`starting`),Ae.current+=1;let t=Ae.current,n=Math.min(2e3,250*2**Math.min(4,t));setTimeout(()=>{e||d()},n).unref?.();return}Oe(`unreachable`)})(),()=>{e=!0}},[n,r,ce,fe,c]);let je=H&&m.status===`ready`&&(De===`unknown`||De===`starting`),Me=H&&m.status===`ready`&&De===`unreachable`,Ne=Z.useCallback(e=>{if(!H||m.status!==`ready`||typeof window>`u`)return;let t=e.currentTarget.contentWindow;if(t)try{let e=t.location,n=dv(ve||fe);if(e.origin!==n||e.pathname.startsWith(m.proxyBasePath))return;let r=`${m.proxyBasePath}${e.pathname}${e.search}${e.hash}`;t.location.replace(r)}catch{}},[ve,H,fe,m]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:ye||e,children:ye||e||a(`contextPanel.preview.empty`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>d(),title:a(`contextPanel.preview.actions.reload`),"aria-label":a(`contextPanel.preview.actions.reload`),disabled:!ve,children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>{ue&&Ut(n?.location.hostId?ve:ue)},title:a(`contextPanel.preview.actions.openExternal`),"aria-label":a(`contextPanel.preview.actions.openExternal`),disabled:n?.location.hostId?!ve:!ue,children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})}),H?(0,$.jsx)(q,{type:`button`,size:`sm`,variant:M?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>N(e=>!e),title:a(`contextPanel.preview.inspect.toggle`),"aria-label":a(`contextPanel.preview.inspect.toggle`),disabled:!S,children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}):null,H?(0,$.jsxs)(q,{type:`button`,size:`sm`,variant:w?`secondary`:`ghost`,className:`h-7 gap-1 px-2`,onClick:()=>T(e=>!e),title:a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),"aria-label":a(S?`contextPanel.preview.console.open`:`contextPanel.preview.console.waiting`),disabled:!S&&O.length===0,children:[(0,$.jsx)(X,{name:`terminal-box`,className:`h-3.5 w-3.5`}),Ce>0?(0,$.jsx)(`span`,{className:`typography-micro text-status-error`,children:Ce}):null]}):null]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[je?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.startingServer`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.startingServerHint`)})]}):Me?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.upstreamUnreachable`)}),(0,$.jsx)(`div`,{className:`text-xs opacity-70`,children:a(`contextPanel.preview.upstreamUnreachableHint`)}),(0,$.jsx)(q,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>d(),children:a(`contextPanel.preview.actions.retry`)})]}):ve&&(!H||De===`reachable`)?(0,$.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,$.jsx)(`iframe`,{ref:b,src:ve,title:a(`contextPanel.preview.iframeTitle`),className:`h-full w-full border-0`,style:{colorScheme:le},onLoad:Ne,sandbox:H?`allow-scripts allow-same-origin allow-forms allow-popups allow-downloads`:`allow-scripts allow-forms`},`${ve}:${c}`),M&&P?(0,$.jsx)(`div`,{className:`pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35`,style:{left:P.bounds.x,top:P.bounds.y,width:P.bounds.width,height:P.bounds.height},children:(0,$.jsxs)(`div`,{className:`absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow`,children:[P.tag,P.text?` · ${P.text}`:``]})}):null]}):be?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.loading`)}):xe?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`contextPanel.preview.proxyError`)}),m.status===`error`?(0,$.jsx)(`div`,{className:`text-center text-xs opacity-70`,children:m.message}):null,(0,$.jsx)(q,{type:`button`,size:`sm`,onClick:()=>p(),children:a(`contextPanel.preview.actions.retry`)})]}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-sm text-muted-foreground`,children:a(`contextPanel.preview.invalidUrl`)}),w?(0,$.jsxs)(`div`,{className:`absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border/50 px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:a(`contextPanel.preview.console.title`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:Ee,disabled:O.length===0,children:a(`contextPanel.preview.console.attach`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:Te,disabled:O.length===0,children:a(`contextPanel.preview.console.copy`)}),(0,$.jsx)(q,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>k([]),disabled:O.length===0,children:a(`contextPanel.preview.console.clear`)})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/30 px-3 py-1.5`,children:[`all`,`errors`,`warnings`,`logs`].map(e=>(0,$.jsx)(q,{type:`button`,size:`xs`,variant:E===e?`secondary`:`ghost`,onClick:()=>D(e),children:a(e===`all`?`contextPanel.preview.console.filter.all`:e===`errors`?`contextPanel.preview.console.filter.errors`:e===`warnings`?`contextPanel.preview.console.filter.warnings`:`contextPanel.preview.console.filter.logs`)},e))}),(0,$.jsx)(`div`,{className:`max-h-64 overflow-auto p-2 typography-code text-xs`,children:O.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.empty`)}):we.length===0?(0,$.jsx)(`div`,{className:`px-2 py-3 text-muted-foreground`,children:a(`contextPanel.preview.console.noFilteredEvents`)}):we.map(e=>(0,$.jsx)(`div`,{className:`border-b border-border/30 px-2 py-1 last:border-b-0`,children:(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:J(`shrink-0 uppercase`,e.level===`error`||e.level===`runtime`||e.level===`resource`?`text-status-error`:e.level===`warn`?`text-status-warning`:`text-muted-foreground`),children:e.level}),(0,$.jsx)(`span`,{className:`min-w-0 break-words text-foreground`,children:e.message})]})},e.id))})]}):null]})]})},hv=()=>typeof window<`u`&&!!window.__YURI_ELECTRON__;function gv(){let e=(0,Q.c)(14),t=bt()?.entry,n=Vn(bv),r=Vn(yv),i=Tn(vv),a;e[0]!==t||e[1]!==i?(a=t&&i&&te(i.location)===t.key?i:null,e[0]=t,e[1]=i,e[2]=a):a=e[2];let o=a,s=t?.location.hostId?o?.sessionId??null:n,c=t?.location.hostId?!o?.sessionId:r,l=Fr(_v),d;e[3]!==l||e[4]!==s||e[5]!==t?(d=async e=>{if(!t?.location.hostId)return l(e);let n={transportIdentity:u(),location:t.location},r=s?ft(n,s):ut(n,`remote-new-session`);await Fr.getState().addDraftLocalAttachment(r,e)},e[3]=l,e[4]=s,e[5]=t,e[6]=d):d=e[6];let f=G(d),p;e[7]!==s||e[8]!==t||e[9]!==c?(p=t?.location.hostId?j(t.location,s??`draft`):s??(c?`draft`:null),e[7]=s,e[8]=t,e[9]=c,e[10]=p):p=e[10];let m=p,h;return e[11]!==f||e[12]!==m?(h={annotationSessionKey:m,addAttachedFile:f},e[11]=f,e[12]=m,e[13]=h):h=e[13],h}function _v(e){return e.addAttachedFile}function vv(e){return e.remoteSession}function yv(e){return e.newSessionDraft?.open}function bv(e){return e.currentSessionId}var xv=({initialUrl:e,directory:t,tabID:n})=>{let r=bt()?.entry,{t:i}=Nr(),a=Z.useRef(null),o=K(e=>e.setContextPanelTabTargetPath),s=Xg(e),c=s===`about:blank`?``:s,[l,u]=Z.useState(c),[d,f]=Z.useState(c),[p,m]=Z.useState(c),[h,g]=Z.useState(()=>c?[c]:[]),[_,v]=Z.useState(()=>c?0:-1),[y,b]=Z.useReducer(e=>e+1,0),[x,S]=Z.useState(!!c),[C,w]=Z.useState(!1),{annotationSessionKey:T,addAttachedFile:E}=gv(),D=ii(e=>e.addDraft),O=Z.useCallback(e=>{!e||e===`about:blank`||!t||!n||o(t,n,e)},[t,n,o]),k=Z.useCallback((e,t)=>{let n=Xg(e),r=n===`about:blank`?``:n;f(r),u(r),t?.inFrame?S(!1):(m(r),S(!!r)),O(r),g(e=>{if(!r)return v(-1),[];if(t?.replaceHistory)return e;let n=_>=0?e.slice(0,_+1):[];if(n[n.length-1]===r)return v(n.length-1),n;let i=[...n,r];return v(i.length-1),i})},[_,O]),A=Z.useRef(d);A.current=d,Z.useEffect(()=>{let t=Zg(e,A.current);t!==null&&k(t)},[e,k]);let j=Z.useCallback(e=>{let t=h[e];t&&(v(e),f(t),m(t),u(t),S(!0),O(t))},[h,O]),M=Z.useCallback(()=>{if(d){S(!0);try{a.current?.contentWindow?.location.reload()}catch{b()}}},[d]),N=p,P=Z.useCallback(async e=>{let t=T;if(!t){Y.error(i(`contextPanel.preview.inspect.attachNoSession`));return}let n=a.current,o=n?.contentWindow,s=n?.getBoundingClientRect(),c={width:Number.isFinite(o?.innerWidth)?o?.innerWidth??s?.width??0:s?.width??0,height:Number.isFinite(o?.innerHeight)?o?.innerHeight??s?.height??0:s?.height??0},l=n?await n_(n,e,r):null,u=!!l;l&&await E(l),D({sessionKey:t,source:`preview-annotation`,fileLabel:d||`browser`,startLine:1,endLine:1,code:t_({pageUrl:d,viewport:c,devicePixelRatio:window.devicePixelRatio||1,target:e,screenshotAttached:u,intro:i(u?`contextPanel.preview.inspect.attachAnnotationWithScreenshot`:`contextPanel.preview.inspect.attachAnnotation`)}),language:`markdown`,text:``}),Y.success(i(`contextPanel.preview.inspect.attached`))},[r,E,D,T,d,i]),F=Z.useCallback(()=>{let e=a.current;e&&sv(e,av).catch(()=>{})},[]);Z.useEffect(()=>{if(!C)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopImmediatePropagation(),w(!1),F())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[F,C]),Z.useEffect(()=>()=>F(),[F]);let I=Z.useCallback(()=>{let e=a.current;if(!(!e||!d)){if(C){w(!1),F();return}w(!0),(async()=>{try{let t=await sv(e,iv);if(w(!1),!t||!e_(t))return;await P(t)}catch{w(!1),Y.error(i(`contextPanel.browser.inspectUnavailable`))}})()}},[P,F,d,C,i]),L=Z.useCallback(()=>{try{let e=a.current?.contentWindow?.location.href||``;e&&e!==`about:blank`&&k(e,{inFrame:!0})}catch{}S(!1)},[k]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:_<=0,onClick:()=>j(_-1),children:(0,$.jsx)(X,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:_<0||_>=h.length-1,onClick:()=>j(_+1),children:(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:M,children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),k(l)},children:(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":i(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(q,{type:`button`,variant:C?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:I,title:i(`contextPanel.preview.inspect.toggle`),"aria-label":i(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,disabled:!d,onClick:()=>void Ut(d),children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[N?(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(`iframe`,{ref:a,src:N,title:i(`contextPanel.browser.empty`),className:`absolute inset-0 h-full w-full border-0 bg-background`,allow:`clipboard-read; clipboard-write; fullscreen`,allowFullScreen:!0,onLoad:L},`${n}:${y}`)}):(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(jo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:i(`contextPanel.browser.empty`)}),(0,$.jsx)(`span`,{className:`max-w-sm typography-micro text-muted-foreground`,children:i(`contextPanel.browser.emptyHint`)}),(0,$.jsx)(`span`,{className:`max-w-md typography-micro leading-relaxed text-status-warning/70`,children:i(`contextPanel.browser.trustNotice`)})]}),x?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:i(`common.loading`)}):null]})]})},Sv=e=>{let t=(0,Q.c)(7),n=bt()?.entry,r=Z.useSyncExternalStore(c,d,d),i;t[0]===n?i=t[1]:(i=(e,t)=>P_(e,t,n),t[0]=n,t[1]=i);let a=i,o=`${r}:${n?.key??``}:${n?.connectionGeneration??0}`,s;return t[2]!==n?.location.hostId||t[3]!==a||t[4]!==e||t[5]!==o?(s=n?.location.hostId||!F_()?(0,$.jsx)(sa,{open:a,children:t=>(0,$.jsx)(Cv,{...e,partition:t.partition})},o):(0,$.jsx)(Cv,{...e},o),t[2]=n?.location.hostId,t[3]=a,t[4]=e,t[5]=o,t[6]=s):s=t[6],s},Cv=({initialUrl:e,directory:t,tabID:n,partition:r=`persist:yuri-browser`})=>{let{t:i}=Nr(),a=Z.useRef(null),o=K(e=>e.setContextPanelTabTargetPath),s=Xg(e),c=s===`about:blank`?``:s,l=Z.useRef(Xg(e)),[u,d]=Z.useState(c),[f,p]=Z.useState(c),[m,h]=Z.useState(!1),[g,_]=Z.useState(!0),v=Z.useRef(null),y=g,b=Z.useCallback(e=>{!e||e===`about:blank`||!t||!n||o(t,n,e)},[t,n,o]),{annotationSessionKey:x,addAttachedFile:S}=gv(),C=ii(e=>e.addDraft);Z.useEffect(()=>{let e=a.current;if(!e)return;let t=()=>{try{let t=e.getURL();t&&t!==`about:blank`&&(p(t),d(t),b(t))}catch{}},n=e=>{let t=e.detail;typeof t?.url==`string`&&t.url&&(p(t.url),d(t.url),b(t.url))},r=()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>_(!0),200)},i=()=>{v.current&&clearTimeout(v.current),_(!1),t()},o=e=>{let t=e.detail;if(t?.disposition===`new-window`||t?.disposition===`foreground-tab`||t?.disposition===`background-tab`){e.preventDefault();let n=a.current;typeof n?.loadURL==`function`&&t.url&&n.loadURL(t.url)}},s=()=>{try{e.executeJavaScript?.(ov,!0).catch(()=>{})}catch{}};e.addEventListener(`did-navigate`,n),e.addEventListener(`did-navigate-in-page`,n),e.addEventListener(`did-start-loading`,r),e.addEventListener(`did-stop-loading`,i),e.addEventListener(`new-window`,o),e.addEventListener(`dom-ready`,s);try{e.isLoading()||(_(!1),t())}catch{}return s(),()=>{v.current&&clearTimeout(v.current),e.removeEventListener(`did-navigate`,n),e.removeEventListener(`did-navigate-in-page`,n),e.removeEventListener(`did-start-loading`,r),e.removeEventListener(`did-stop-loading`,i),e.removeEventListener(`new-window`,o),e.removeEventListener(`dom-ready`,s)}},[b]),Z.useEffect(()=>{let e=setTimeout(()=>_(!1),3e4);return()=>clearTimeout(e)},[]),Z.useEffect(()=>{if(!m)return;let e=e=>{if(e.key!==`Escape`)return;e.preventDefault(),e.stopImmediatePropagation(),h(!1);let t=a.current;try{t?.executeJavaScript?.(av).catch(()=>{})}catch{}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[m]),Z.useEffect(()=>{let e=a.current;return()=>{try{let r=e?.getURL?.();r&&r!==`about:blank`&&o(t,n,r)}catch{}try{e?.executeJavaScript?.(av).catch(()=>{})}catch{}}},[t,n,o]);let w=Z.useCallback(e=>{let t=a.current;if(typeof t?.loadURL!=`function`)return;let n=Xg(e);try{t.loadURL(n)}catch{}},[]),T=Z.useRef(f);T.current=f,Z.useEffect(()=>{let t=Zg(e,T.current);t!==null&&(p(t),d(t),_(!0),w(t))},[e,w]);let E=Z.useCallback(()=>{let e=a.current;if(e){if(m){h(!1);try{e.executeJavaScript?.(av).catch(()=>{})}catch{}return}h(!0),e.executeJavaScript?.(iv,!0).then(async t=>{if(h(!1),!t||!e_(t))return;let n=x;if(!n){Y.error(i(`contextPanel.preview.inspect.attachNoSession`));return}let r=typeof e.getWebContentsId==`function`?e.getWebContentsId():null;if(r==null)return;let a=await kr(`desktop_browser_capture_page`,{webContentsId:r}),o=await e.executeJavaScript?.(`({ width: window.innerWidth, height: window.innerHeight })`,!0).catch(()=>null),s=Number.isFinite(o?.width)?o.width:a.width,c=Number.isFinite(o?.height)?o.height:a.height,l=await r_(a.base64,a.width,a.height,s,c,t),u=!!l;l&&await S(l),C({sessionKey:n,source:`preview-annotation`,fileLabel:f||`browser`,startLine:1,endLine:1,code:t_({pageUrl:f,viewport:{width:s,height:c},devicePixelRatio:window.devicePixelRatio||1,target:t,screenshotAttached:u,intro:i(`contextPanel.preview.inspect.attachAnnotationWithScreenshot`)}),language:`markdown`,text:``}),Y.success(i(`contextPanel.preview.inspect.attached`))}).catch(()=>h(!1))}},[S,C,x,f,m,i]);return(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col bg-background`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-border/40 bg-[var(--surface-background)] px-2 py-1`,children:[(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.goBack?.()}catch{}},children:(0,$.jsx)(X,{name:`arrow-left`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.goForward?.()}catch{}},children:(0,$.jsx)(X,{name:`arrow-right`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>{try{a.current?.reload?.()}catch{}},children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`form`,{className:`min-w-0 flex-1`,onSubmit:e=>{e.preventDefault(),w(u)},children:(0,$.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),className:`h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]`,"aria-label":i(`contextPanel.browser.addressAria`)})}),(0,$.jsx)(q,{type:`button`,variant:m?`secondary`:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:E,title:i(`contextPanel.preview.inspect.toggle`),"aria-label":i(`contextPanel.preview.inspect.toggle`),children:(0,$.jsx)(X,{name:`cursor`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:()=>void Ut(f),children:(0,$.jsx)(X,{name:`external-link`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 bg-background`,children:[(0,$.jsx)(`webview`,{ref:a,src:l.current,partition:r,allowpopups:!0,style:{width:`100%`,height:`100%`,border:`none`}}),(!f||f===`about:blank`)&&!g?(0,$.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center`,children:[(0,$.jsx)(jo,{width:140,height:140,className:`opacity-20`}),(0,$.jsx)(`span`,{className:`typography-ui-header text-muted-foreground`,children:i(`contextPanel.browser.empty`)})]}):null,y?(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground`,children:i(`common.loading`)}):null]})]})},wv=e=>{let t=(0,Q.c)(3),n=bt(),r;return t[0]!==n||t[1]!==e?(r=n?(0,$.jsx)(Tv,{...e},n.entry.key):(0,$.jsx)(cl,{children:(0,$.jsx)(Tv,{...e})}),t[0]=n,t[1]=e,t[2]=r):r=t[2],r},Tv=e=>{let t=(0,Q.c)(3),n=bt(),r;return t[0]!==n?.entry.location.hostId||t[1]!==e?(r=n?.entry.location.hostId?(0,$.jsx)(Ev,{...e}):(0,$.jsx)(Dv,{...e}),t[0]=n?.entry.location.hostId,t[1]=e,t[2]=r):r=t[2],r},Ev=e=>{let t=(0,Q.c)(5),n=bt(),r=Or(n.registry,n.entry.location.hostId),i;t[0]===r.data?.directories?i=t[1]:(i=r.data?.directories.flatMap(Ov)??[],t[0]=r.data?.directories,t[1]=i);let a=i,o;return t[2]!==e||t[3]!==a?(o=(0,$.jsx)(Dv,{...e,remoteSessions:a}),t[2]=e,t[3]=a,t[4]=o):o=t[4],o},Dv=({directory:e,onReservedWidthChange:t,fillAvailableSpace:n=!1,getMaxSplitWidth:r,remoteSessions:i})=>{let{t:a}=Nr(),o=bt(),s=!!o?.entry.location.hostId,c=Vn(e=>e.currentSessionId),l=Tn(e=>e.remoteSession),u=s?l&&te(l.location)===o.entry.key?l.sessionId:null:c,d=Ui()??``,f=e?re(e,o?.entry.location.hubId??`local`).directory:d,m=s?te({...o.entry.location,directory:f}):G_(f),h=K(e=>Ht(e,m)),g=K(e=>m?e.contextToolDiffByDirectory[m]:void 0),_=K(e=>e.closeContextPanel),v=K(e=>e.closeContextPanelTab),y=K(e=>e.openContextPanelTab),b=K(e=>e.toggleContextPanelExpanded),x=K(e=>e.setContextPanelWidth),S=K(e=>e.setActiveContextPanelTab),C=K(e=>e.reorderContextPanelTabs),w=K(e=>e.isRightSidebarOpen),T=K(e=>e.isSidebarOpen),{usesFramelessChrome:E,side:D}=oc(),O=Bo(e=>e.setSelectedPath),k=K(e=>e.openContextPreview),A=K(e=>e.allowPromptingSubagentSessions),{themeMode:j,setThemeMode:M,lightThemeId:N,darkThemeId:P,currentTheme:F}=ai(),I=Z.useMemo(()=>h?.tabs??[],[h?.tabs]),L=I.find(e=>e.id===h?.activeTabId)??I[I.length-1]??null,R=!!h?.isOpen,z=!!h?.expanded,ee=R&&(z||n),B=Z.useRef(null),ne=Z.useRef(!0),[ie,ae]=Z.useState(!0);It(B,([e])=>{if(!e||e.contentRect.width<=0)return;let t=e.contentRect.width<B_;t!==ne.current&&(ne.current=t,ae(t))});let oe=R&&(!L||w&&(!ie||h?.activeView!==`preview`)),V=R&&(!ie||!oe),H=K_(h?.width??R_),se=Z.useMemo(()=>{let e=[];for(let t of I){if(t.mode!==`chat`)continue;let n=ev(t.dedupeKey);n&&!e.includes(n)&&e.push(n)}return e},[I]),U=rv(f||void 0,se,i),[ce,le]=Z.useState(!1),[ue,de]=Z.useState(!1),fe=Z.useRef(0),pe=Z.useRef(H),me=Z.useRef(null),he=Z.useRef(null),ge=Z.useRef({directory:m,width:H});Z.useLayoutEffect(()=>{ce||((ge.current.directory!==m||R&&!ee)&&(ge.current={directory:m,width:H}),t?.(R?z?1/0:H:0))},[m,ee,R,ce,t,z,H]);let _e=Z.useRef(null),ve=Z.useRef(new Map),ye=Z.useRef(new Map),be=Z.useRef(!1),xe=Z.useRef(R),Se=Z.useRef(null),[Ce,we]=Z.useState({}),Te=Z.useRef(Ce);Te.current=Ce;let[Ee,De]=Z.useReducer(Wg,{activeViewKey:null,tabs:{},mountedViews:{}}),Oe=s?`react-surface`:fg(),ke=p(),Ae=Z.useCallback(e=>{let t=Te.current,n=e(t);return n!==t&&(Te.current=n,we(n),!0)},[]),je=Z.useCallback(e=>{if(!m)return;if(K.getState().contextPanelByDirectory[m]?.tabs.find(t=>t.id===e)?.mode===`btw`){let e=u;e&&ka.getState().clear({sessionId:e,directory:f,host:s?o.entry:void 0})}De({type:`close-tab`,tabId:e});let t=pg(m,e);Ae(e=>{if(!e[t])return e;let n={...e};return delete n[t],n}),v(m,e)},[u,f,o,s,v,Ae,m]),Me=Z.useCallback(()=>{de(!0),Se.current!==null&&window.cancelAnimationFrame(Se.current),Se.current=window.requestAnimationFrame(()=>{Se.current=null,de(!1)})},[]);Z.useEffect(()=>()=>{Se.current!==null&&window.cancelAnimationFrame(Se.current)},[]),Z.useLayoutEffect(()=>{let e=xe.current;if(xe.current=R,!R){de(!1);return}e||Me()},[R,Me]),Z.useEffect(()=>{if(!R||be.current){be.current=R;return}let e=window.requestAnimationFrame(()=>{let e=_e.current;e&&!e.contains(document.activeElement)&&e.focus({preventScroll:!0})});return be.current=!0,()=>window.cancelAnimationFrame(e)},[R]);let Ne=G(e=>{let n=_e.current;if(!n)return;let r=J_(e,n);n.style.setProperty(`--yuri-context-panel-width`,`${r}px`),t?.(r)}),Pe=G(e=>{if(!R||!m)return;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}he.current=e.pointerId,le(!0),fe.current=e.clientX;let t=_e.current?.clientWidth||H;pe.current=t,me.current=t,z&&b(m),Ne(t),e.preventDefault()}),Fe=Z.useCallback(e=>{if(!ce||he.current!==e.pointerId)return;let t=fe.current-e.clientX,n=J_(pe.current+t,_e.current);me.current!==n&&(me.current=n,Ne(n))},[Ne,ce]),Ie=Z.useCallback(e=>{if(he.current!==e.pointerId||!m)return;try{e.currentTarget.releasePointerCapture(e.pointerId)}catch{}let t=J_(me.current??H,_e.current);Me(),Ne(t),me.current=t,x(m,t),le(!1),he.current=null},[Ne,m,x,Me,H]);Z.useEffect(()=>{ce||(me.current=null)},[ce]);let W=Z.useCallback(()=>{if(!m)return;let e=u;e&&ka.getState().cancel({sessionId:e,directory:f,host:s?o.entry:void 0}),_(m)},[u,f,o,s,_,m]),Le=G(()=>{if(!m)return;if(!ee){b(m);return}let e=ge.current.width,t=K_(Math.min(e,r?.()??e));t!==H&&x(m,t),z&&b(m)}),Re=Z.useCallback(e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`w`&&L&&m){e.preventDefault(),e.stopPropagation(),je(L.id);return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),W())},[L,je,m,W]);Z.useEffect(()=>{if(!(!m||!L)&&L.mode===`file`&&L.targetPath){O(m,L.targetPath,{allowOutsideRoot:!0});return}},[L,m,O]);let ze=L?.mode===`chat`?L.id:null,Be=bg(ze?Ce[pg(m,ze)]:void 0,ze?ev(L?.dedupeKey):null);Z.useEffect(()=>{if(s||!V||!m||!Be){an(``,null);return}return an(m,Be),()=>{an(``,null)}},[Be,m,V,s]),Z.useEffect(()=>{if(s||!V||!m||!Be||typeof window>`u`)return;let e=()=>{if(document.visibilityState===`hidden`||!document.hasFocus()){dn(m,Be,!1);return}un(Be),dn(m,Be,!0)};e();let t=window.setInterval(e,1e4);return window.addEventListener(`focus`,e),window.addEventListener(`blur`,e),document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),window.removeEventListener(`focus`,e),window.removeEventListener(`blur`,e),document.removeEventListener(`visibilitychange`,e),dn(m,Be,!1)}},[Be,m,V,s]);let Ve=Z.useCallback((e,t,n)=>Po(ye.current,e,t,m||null,n,{mode:j,lightThemeId:N,darkThemeId:P,currentTheme:F}),[F,P,m,N,j]);Z.useEffect(()=>{let e=new Set(I.map(e=>e.id));for(let t of ye.current.keys())e.has(t)||ye.current.delete(t)},[I]);let He=Z.useCallback(e=>{!m||L?.mode!==`diff`&&L?.mode!==`file-diff`||y(m,{mode:L.mode,targetPath:L.targetPath,stagedDiff:e===`staged`,diffScope:e})},[L,m,y]),Ue=Z.useCallback(()=>{if(typeof window>`u`)return;let e={themeMode:j,lightThemeId:N,darkThemeId:P,currentTheme:F};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyThemeSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:theme-sync`,payload:e},window.location.origin)}},[F,P,N,j]),We=Z.useCallback(()=>{if(typeof window>`u`)return;let e={allowPromptingSubagentSessions:A};for(let t of ve.current.values()){let n=t.contentWindow;if(!n)continue;let r=n.__yuriApplyChatSettingsSync;if(typeof r==`function`)try{r(e);continue}catch{}n.postMessage({type:`yuri:chat-settings-sync`,payload:e},window.location.origin)}},[A]),Ge=Z.useCallback(()=>{if(!(typeof window>`u`))for(let[e,t]of ve.current.entries()){let n=t.contentWindow;if(!n)continue;let r={visible:V&&ze===e},i=n.__yuriSetEmbeddedVisibility;if(typeof i==`function`)try{i(r);continue}catch{}n.postMessage({type:Fo,payload:r},window.location.origin)}},[ze,V]);Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{if(e.origin!==window.location.origin||!Array.from(ve.current.values()).some(t=>t.contentWindow===e.source))return;let t=e.data;if(t?.type===`yuri:close-embedded-session-chat`){let t=Array.from(ve.current.entries()).find(([,t])=>t.contentWindow===e.source);t&&m&&je(t[0]);return}if(t?.type===`yuri:chat-settings-request`){We();return}if(t?.type===`yuri:embedded-visibility-request`){Ge();return}if(t?.type!==`yuri:cycle-theme-request`)return;let n=[`light`,`dark`,`system`],r=(n.indexOf(j)+1)%n.length;M(n[r])};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[je,m,We,Ge,M,j]),Z.useLayoutEffect(()=>{I.some(e=>e.mode===`chat`)&&(Ue(),We(),Ge())},[P,N,We,Ge,Ue,I,j]);let Ke=Z.useMemo(()=>I.map(e=>{let t=Q_(e,U,a),n=cv(t,z_),r=Y_(e.targetPath,f);return{id:e.id,label:n,icon:$_(e),title:r?`${t}: ${r}`:t,closeLabel:a(`contextPanel.tab.closeTabAria`,{label:n})}}),[f,U,a,I]),qe=L?.mode===`context`?(0,$.jsx)(Vp,{active:V}):L?.mode===`preview`?(0,$.jsx)(mv,{rawUrl:L.targetPath??``,onNavigate:e=>k(m,e)},`${m}:${o?.entry.connectionGeneration??``}:${L.id}`):(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 p-6 text-center`,children:[(0,$.jsxs)(`div`,{"aria-hidden":`true`,className:`flex h-18 w-24 flex-col overflow-hidden rounded-lg border border-current/35 text-muted-foreground/45`,children:[(0,$.jsx)(`div`,{className:`flex h-3.5 shrink-0 items-end border-b border-current/25 px-2`,children:(0,$.jsx)(`span`,{className:`h-1.5 w-5 rounded-t-sm bg-current/20`})}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-6 shrink-0 flex-col gap-1.5 border-r border-current/25 px-1.5 py-3`,children:[(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/40`}),(0,$.jsx)(`span`,{className:`h-0.5 w-2 rounded-full bg-current/25`}),(0,$.jsx)(`span`,{className:`h-0.5 w-full rounded-full bg-current/25`})]}),(0,$.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,$.jsx)(X,{name:`file-text`,className:`size-7`})})]})]}),(0,$.jsx)(`p`,{className:`typography-ui-label text-muted-foreground`,children:a(`contextPanel.empty.selectFile`)})]}),Je=Z.useMemo(()=>I.filter(e=>e.mode===`chat`),[I]),Ye=Z.useMemo(()=>I.filter(e=>e.mode===`browser`),[I]),Xe=Z.useMemo(()=>I.filter(e=>e.mode===`diff`||e.mode===`file-diff`),[I]),Ze=hv()?Sv:xv,Qe=V&&L?.mode===`browser`&&Ze===Sv;Z.useLayoutEffect(()=>{if(!Qe)return;let e=document.documentElement;return e.setAttribute(`data-yuri-native-browser-visible`,``),()=>e.removeAttribute(`data-yuri-native-browser-visible`)},[Qe]);let $e=Z.useMemo(()=>I.some(e=>e.mode===`file`),[I]),et=L?.mode===`file`,[tt,nt]=Z.useState(null),rt=et?L.targetPath:tt?.directory===m&&I.some(e=>e.mode===`file`&&e.targetPath===tt.path)?tt.path:null;Z.useEffect(()=>{nt(e=>e?.directory===m&&e.path===rt?e:{directory:m,path:rt??null})},[m,rt]);let it=et?L?.fileNotice??null:null;Z.useEffect(()=>{let e=new Set(Je.map(e=>pg(m,e.id)));Ae(t=>{let n=!1,r={};for(let e of Je){let i=ev(e.dedupeKey);if(!i)continue;let a=pg(m,e.id),o=t[a];r[a]=o??vg({sessionId:i,directory:m}),n||=!o}let i=Tg(t,e);return n||=i!==t,n?{...i,...r}:t});for(let t of Object.keys(Ee.tabs))(!e.has(pg(m,t))||Ee.tabs[t]?.directory!==m)&&De({type:`close-tab`,tabId:t})},[Je,Ae,m,Ee.tabs]);let at=ze?pg(m,ze):null,ot=ze?ev(L?.dedupeKey):null,st=at&&ot?yg(Ce[at],{sessionId:ot,directory:m}):void 0,ct=st&&at?mg(ke,at,st.current.directory,st.current.sessionId):null;Z.useLayoutEffect(()=>{if(Oe!==`react-surface`||!R||!ze||!st||!at||!ct){Oe===`react-surface`&&De({type:`activate`,viewKey:null,now:Date.now()});return}Ae(e=>e[at]?e:{...e,[at]:st}),De({type:`touch`,tab:{tabId:ze,sessionId:st.anchor.sessionId,directory:st.anchor.directory},view:{tabId:ze,surfaceId:at,sessionId:st.current.sessionId,directory:st.current.directory,viewKey:ct},now:Date.now()})},[st,at,ze,ct,Oe,Ae,R]);let lt=Z.useCallback((e,t,n)=>{let r=pg(m,e),i=!1;return Ae(e=>{let a=s&&o?te({...o.entry.location,directory:re(n,o.entry.location.hubId).directory}):n,c=wg(e,r,{sessionId:t,directory:a});return i=c.accepted,c.navigationBySurfaceId}),i},[Ae,m,s,o]),ut=Z.useCallback(e=>{let t=pg(m,e);Ae(e=>{let n=e[t];if(!n)return e;let r=Sg(n);return r===n?e:{...e,[t]:r}})},[Ae,m]),dt=(0,$.jsxs)(`header`,{className:J(`app-region-drag flex shrink-0 select-none items-center pl-2`,F.metadata.variant===`light`&&[`[--interactive-hover:color-mix(in_srgb,var(--surface-foreground)_6%,var(--background))]`,`[--interactive-active:color-mix(in_srgb,var(--surface-foreground)_10%,var(--background))]`]),style:{height:`calc(var(--yuri-header-height, 3rem) - 0.75rem * var(--padding-scale, 1))`,minHeight:`calc(max(3rem, var(--yuri-wco-titlebar-height, 0px)) - 0.75rem * var(--padding-scale, 1))`,paddingRight:`calc(0.75rem + var(--yuri-wco-right-inset, 0px))`,...n&&!T?{paddingLeft:`calc(var(--yuri-titlebar-left-inset, 0.75rem) + var(--yuri-titlebar-controls-width, 5.5rem) + 0.5rem)`}:{}},children:[(0,$.jsx)(Vs,{items:Ke,activeId:L?.id??null,onSelect:e=>{m&&S(m,e)},onClose:e=>{je(e)},onReorder:(e,t)=>{m&&C(m,e,t)},layoutMode:`scrollable`,variant:`compact`,className:`app-region-no-drag h-6`}),(0,$.jsxs)(`div`,{className:`app-region-no-drag flex shrink-0 items-center gap-1 pl-1.5`,children:[R?(0,$.jsx)(ng,{railVisible:oe}):null,(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:Le,className:`h-7 w-7 p-0`,title:a(ee?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-label":a(ee?`contextPanel.actions.collapsePanel`:`contextPanel.actions.expandPanel`),"aria-pressed":ee,children:(0,$.jsx)(X,{name:ee?`collapse-diagonal`:`expand-diagonal`,className:`size-4`})}),(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`sm`,onClick:W,className:`h-7 w-7 p-0`,title:a(`contextPanel.actions.closePanel`),"aria-label":a(`contextPanel.actions.closePanel`),children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(ic,{visible:R&&E&&D===`right`,position:`right`})]})]}),ft=R?{width:ee?`100%`:`min(var(--yuri-context-panel-width), 100%)`,minWidth:`min(${I_}px, 100%)`,maxWidth:`100%`,"--yuri-context-panel-width":`${ce?me.current??H:H}px`}:{"--yuri-context-panel-width":`${ce?me.current??H:H}px`,width:0,minWidth:0,maxWidth:0,opacity:0,overflow:`hidden`,visibility:`hidden`};return(0,$.jsxs)(`aside`,{ref:_e,"data-context-panel":`true`,"data-native-browser-visible":Qe?`true`:void 0,tabIndex:-1,inert:!R||void 0,className:J(`flex min-h-0 flex-col overflow-visible bg-transparent`,R&&`py-1.5 pl-1 pr-1.5`,`relative h-full flex-shrink-0`,!R&&`pointer-events-none`,ce||!R||ue||t?`transition-none`:`transition-[width] duration-200 ease-in-out`),onKeyDownCapture:Re,style:ft,children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`div`,{className:`group/preview-resize absolute -left-1 top-0 z-50 h-full w-4 touch-none cursor-col-resize`,onPointerDown:Pe,onPointerMove:Fe,onPointerUp:Ie,onPointerCancel:Ie,role:`separator`,"aria-orientation":`vertical`,"aria-label":a(`contextPanel.actions.resizePanelAria`),"data-context-resize-handle":!0,children:(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(`pointer-events-none absolute left-[2px] top-1/2 h-14 w-[3px] -translate-y-1/2 rounded-full bg-muted-foreground/25 opacity-0 transition-opacity duration-150 group-hover/preview-resize:opacity-100`,ce&&`opacity-100`)})})}),(0,$.jsx)(ei,{side:`right`,sideOffset:4,children:a(`contextPanel.actions.resizePanel`)})]}),(0,$.jsxs)(Vl,{"data-context-panel-surface":!0,children:[dt,it===`turn-diff-outside-workspace`?(0,$.jsx)(`div`,{className:`shrink-0 border-b border-status-info/20 bg-status-info/10 px-3 py-2 typography-meta text-status-info`,children:a(`contextPanel.file.notice.turnDiffOutsideWorkspace`)}):null,(0,$.jsxs)(`div`,{ref:B,className:J(`relative flex min-h-0 flex-1 overflow-hidden`,ce&&`pointer-events-none`),"data-context-layout":ie?`single`:`split`,children:[(0,$.jsx)(`div`,{className:J(`min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,V?`flex`:`hidden`),inert:!V||void 0,"data-context-preview-content":!0,children:(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[$e&&rt?(0,$.jsx)(`div`,{className:J(`absolute inset-0`,et?`block`:`hidden`),children:(0,$.jsx)(fp,{mode:`editor-only`,targetPath:rt,isActive:V&&et},`${m}:${rt??``}`)}):null,Oe===`legacy-iframe`&&Je.map(e=>{let t=ev(e.dedupeKey);if(!t)return null;let n=Ve(e.id,t,e.readOnly);return n?(0,$.jsx)(`iframe`,{ref:t=>{if(!t){ve.current.delete(e.id);return}ve.current.set(e.id,t)},src:n,title:a(`contextPanel.iframe.sessionChatTitle`,{sessionID:t}),className:J(`absolute inset-0 h-full w-full border-0 bg-background`,ze===e.id?`block`:`hidden`),onLoad:()=>{Ue(),We(),Ge()}},e.id):null}),Oe===`react-surface`?Object.values(Ee.mountedViews).map(e=>{let t=Ce[pg(m,e.tabId)],n=V&&ze===e.tabId&&ct===e.viewKey;return(0,$.jsx)(Z.Activity,{name:`context-panel-session-${e.sessionId}`,mode:n?`visible`:`hidden`,children:s&&o?(0,$.jsxs)(`div`,{className:`relative h-full min-h-0`,children:[n&&t?.stack.length?(0,$.jsxs)(q,{type:`button`,variant:`outline`,size:`xs`,onClick:()=>ut(e.tabId),className:`absolute left-3 top-3 z-20 !font-normal bg-[var(--surface-background)]/95`,"aria-label":a(`chat.container.returnToParent.aria`),title:a(`chat.container.returnToParent.title`),children:[(0,$.jsx)(X,{name:`arrow-left`,className:`h-4 w-4`}),a(`chat.container.returnToParent.label`)]}):null,(0,$.jsx)(qo,{location:{...o.entry.location,directory:re(e.directory,o.entry.location.hubId).directory},sessionId:e.sessionId,active:n,readOnly:I.find(t=>t.id===e.tabId)?.readOnly??!0,onNavigateSession:(t,n)=>{lt(e.tabId,t,n)}})]}):(0,$.jsx)(qg,{surfaceId:e.surfaceId,sessionId:e.sessionId,directory:e.directory,active:n,canNavigateBack:n&&!!t?.stack.length,onNavigateSession:(t,n)=>lt(e.tabId,t,n),onNavigateBack:()=>ut(e.tabId),onEstimateBytes:(e,t)=>De({type:`estimate`,viewKey:e,estimatedBytes:t})})},e.viewKey)}):null,I.filter(e=>e.mode===`btw`).map(e=>{let t=V&&L?.id===e.id;return(0,$.jsx)(Z.Activity,{name:`context-panel-btw`,mode:t?`visible`:`hidden`,children:u?(0,$.jsx)(is,{scope:{sessionId:u,directory:f,host:s?o.entry:void 0},hostRegistry:s?o.registry:void 0,active:t}):(0,$.jsx)(`p`,{className:`p-4 text-muted-foreground`,children:a(`chat.btw.sessionRequired`)})},`btw:${m}:${u}:${e.id}`)}),Ye.map(e=>(0,$.jsx)(`div`,{className:J(`absolute inset-0`,L?.id!==e.id&&`hidden`),children:(0,$.jsx)(Ze,{initialUrl:e.targetPath??``,directory:m,tabID:e.id})},`${m}:${o?.entry.connectionGeneration??``}:${e.id}`)),Xe.map(e=>{let t=e.mode===`diff`&&g?.targetPath===e.targetPath&&g.turnMessageId===e.diffTurnMessageId?g.patches:null;return(0,$.jsx)(`div`,{className:J(`absolute inset-0`,L?.id!==e.id&&`hidden`),children:(0,$.jsx)(Zl,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!t,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:e.diffScope??(e.stagedDiff?`staged`:`working`),turnMessageId:e.diffTurnMessageId,sessionId:e.diffSessionId,directory:f,onDiffScopeChange:He,targetFilePath:e.targetPath,targetLine:e.diffTargetLine??null,toolPatches:t,navigationRequestKey:e.touchedAt,flushContent:!0,singleFileView:e.mode===`file-diff`,preloadFullFiles:e.mode===`file-diff`})},e.id)}),L?.mode!==`chat`&&L?.mode!==`btw`&&!et&&L?.mode!==`browser`&&L?.mode!==`diff`&&L?.mode!==`file-diff`?qe:null]})}),(0,$.jsx)(sm,{isOpen:oe,className:J(`!min-w-0 shrink-0 bg-transparent [--layout-chrome-divider-width:1px] [--layout-chrome-divider:color-mix(in_srgb,var(--surface-foreground)_8%,var(--background))]`,ie&&`!transition-none`,ie&&oe?`!w-full !max-w-full !border-l-0 [&>[role=separator]]:hidden`:`!max-w-[50%]`),children:oe?(0,$.jsx)(No,{children:(0,$.jsx)(rg,{isActive:oe})}):null})]})]})]})};function Ov(e){return e.sessions}var kv=350,Av=e=>{let t=(0,Q.c)(26),{children:n,header:r,footer:i}=e,a=Z.useRef(null),o=Z.useRef(0),s=Z.useRef(0),c=Z.useRef(!1),[l,u]=Z.useState(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{if(s.current>0&&o.current<=0)return;let e=s.current>0&&o.current-s.current<kv;e!==c.current&&(c.current=e,u(e))},t[0]=d):d=t[0];let f=G(d),p;t[1]===f?p=t[2]:(p=e=>{s.current=e,f()},t[1]=f,t[2]=p);let m=G(p),h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current-kv,t[3]=h):h=t[3];let g=G(h),_,v;t[4]===f?(_=t[5],v=t[6]):(_=()=>{o.current=a.current?.clientWidth??0,f()},v=[f],t[4]=f,t[5]=_,t[6]=v),Z.useLayoutEffect(_,v);let y;t[7]===f?y=t[8]:(y=e=>{let[t]=e;t&&(o.current=t.contentRect.width,f())},t[7]=f,t[8]=y),It(a,y);let b;t[9]===l?b=t[10]:(b=l?{display:`none`}:{minWidth:`min(${kv}px, 100%)`},t[9]=l,t[10]=b);let x=l||void 0,S;t[11]===n?S=t[12]:(S=(0,$.jsx)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden yuri-layout-divider-t`,"data-primary-chat-content":!0,children:n}),t[11]=n,t[12]=S);let C;t[13]!==i||t[14]!==r||t[15]!==b||t[16]!==x||t[17]!==S?(C=(0,$.jsxs)(`main`,{className:`flex flex-1 min-w-0 flex-col overflow-hidden bg-background relative`,style:b,inert:x,"data-page-scroll-lock":`true`,"data-primary-chat":!0,children:[r,S,i]}),t[13]=i,t[14]=r,t[15]=b,t[16]=x,t[17]=S,t[18]=C):C=t[18];let w;t[19]!==g||t[20]!==m||t[21]!==l?(w=(0,$.jsx)(wv,{onReservedWidthChange:m,fillAvailableSpace:l,getMaxSplitWidth:g}),t[19]=g,t[20]=m,t[21]=l,t[22]=w):w=t[22];let T;return t[23]!==C||t[24]!==w?(T=(0,$.jsxs)(`div`,{ref:a,className:`relative flex flex-1 min-h-0 min-w-0 overflow-hidden`,"data-page-scroll-lock":`true`,"data-chat-area":!0,children:[C,w]}),t[23]=C,t[24]=w,t[25]=T):T=t[25],T},jv=(e,t,n)=>Ca(e)?Ea(e,n).map(Sa):t,Mv=()=>{let e=(0,Q.c)(34),{t}=Nr(),{isMobile:n}=fi(),r=K(Nv),i=K(Pv),a=K(Fv),o;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=xa(),e[0]=o):o=e[0];let s=o,c;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=E(),e[1]=c):c=e[1];let l=c,u,d,f,p,m,h,g,_,v;if(e[2]!==r||e[3]!==n||e[4]!==i||e[5]!==a||e[6]!==t){let o=[{categoryKey:`helpDialog.section.navigationCommands`,items:[{id:`open_command_palette`,descriptionKey:`helpDialog.item.openCommandPalette`,icon:`command`,keys:``},{id:`open_help`,descriptionKey:`helpDialog.item.showKeyboardShortcuts`,icon:`question`,keys:``},{id:`toggle_sidebar`,descriptionKey:`helpDialog.item.toggleSessionSidebar`,icon:`layout-left`,keys:``},{id:`cycle_agent`,keys:``,descriptionKey:`helpDialog.item.cycleAgent`,icon:`ai-agent`},{id:`open_model_selector`,descriptionKey:`helpDialog.item.openModelSelector`,icon:`ai-generate-2`,keys:``},{keys:[`↑↓`],descriptionKey:`helpDialog.item.navigateModels`,icon:`ai-generate-2`},{keys:[`←→`],descriptionKey:`helpDialog.item.adjustThinkingMode`,icon:`brain-ai-3`},{id:`cycle_thinking_variant`,descriptionKey:`helpDialog.item.cycleThinkingVariant`,icon:`brain-ai-3`,keys:``},{keys:[`Shift + ${s} + N`],descriptionKey:`helpDialog.item.newWindow`,icon:`window`}]},{categoryKey:`helpDialog.section.sessionManagement`,items:[{id:`new_chat`,descriptionKey:`helpDialog.item.createNewSession`,icon:`add`,keys:``},{id:`new_chat_worktree`,descriptionKey:`helpDialog.item.createNewWorktreeDraft`,icon:`git-branch`,keys:``},{id:`previous_session`,descriptionKey:`helpDialog.item.previousSession`,icon:`arrow-left`,keys:``},{id:`next_session`,descriptionKey:`helpDialog.item.nextSession`,icon:`arrow-right`,keys:``},{id:`focus_input`,descriptionKey:`helpDialog.item.focusChatInput`,icon:`text`,keys:``},{id:`toggle_prompt_navigator`,descriptionKey:`helpDialog.item.togglePromptNavigator`,icon:`list-unordered`,keys:``},{id:`abort_run`,descriptionKey:`helpDialog.item.abortActiveRun`,icon:`close-circle`,keys:``}]},{categoryKey:`helpDialog.section.leaderChords`,items:[{keys:`Ctrl+X → M`,descriptionKey:`helpDialog.item.leaderOpenModel`,icon:`ai-generate-2`},{keys:`Ctrl+X → A`,descriptionKey:`helpDialog.item.leaderOpenAgent`,icon:`ai-agent`},{keys:`Ctrl+X → N`,descriptionKey:`helpDialog.item.leaderNewSession`,icon:`add`},{keys:`Ctrl+X → C`,descriptionKey:`helpDialog.item.leaderCompact`,icon:`scissors`}]},{categoryKey:`helpDialog.section.panels`,items:[{id:`toggle_right_sidebar`,descriptionKey:`helpDialog.item.toggleRightSidebar`,icon:`layout-right`,keys:``},{id:`open_right_sidebar_git`,descriptionKey:`helpDialog.item.openRightSidebarGitTab`,icon:`git-branch`,keys:``},{id:`open_right_sidebar_files`,descriptionKey:`helpDialog.item.openRightSidebarFilesTab`,icon:`layout-right`,keys:``},{id:`cycle_right_sidebar_tab`,descriptionKey:`helpDialog.item.cycleRightSidebarTab`,icon:`layout-right`,keys:``},{id:`close_context_panel_tab`,descriptionKey:`helpDialog.item.closeContextPanelTab`,icon:`close`,keys:``},{id:`toggle_terminal`,descriptionKey:`helpDialog.item.toggleTerminal`,icon:`window`,keys:``},{id:`new_terminal_tab`,descriptionKey:`helpDialog.item.newTerminalTab`,icon:`terminal-box`,keys:``},{id:`open_new_terminal`,descriptionKey:`helpDialog.item.openNewTerminal`,icon:`terminal-box`,keys:``},{id:`previous_terminal_tab`,descriptionKey:`helpDialog.item.previousTerminalTab`,icon:`arrow-left`,keys:``},{id:`next_terminal_tab`,descriptionKey:`helpDialog.item.nextTerminalTab`,icon:`arrow-right`,keys:``},{id:`toggle_bottom_panel`,descriptionKey:`helpDialog.item.toggleBottomPanel`,icon:`window`,keys:``},{id:`toggle_terminal_expanded`,descriptionKey:`helpDialog.item.toggleTerminalExpanded`,icon:`window`,keys:``}]},{categoryKey:`helpDialog.section.interface`,items:[{id:`cycle_theme`,descriptionKey:`helpDialog.item.cycleTheme`,icon:`palette`,keys:``},{id:`zoom_in`,descriptionKey:`helpDialog.item.zoomIn`,icon:`add`,keys:``},{id:`zoom_out`,descriptionKey:`helpDialog.item.zoomOut`,icon:`subtract`,keys:``},{id:`zoom_reset`,descriptionKey:`helpDialog.item.zoomReset`,icon:`restart`,keys:``},{keys:[`${s} + 1...9`],descriptionKey:`helpDialog.item.switchSession`,icon:`layout-left`},{id:`toggle_services_menu`,descriptionKey:`helpDialog.item.toggleServicesMenu`,icon:`stack`,keys:``},{id:`open_usage`,descriptionKey:`helpDialog.item.openUsage`,icon:`timer`,keys:``},{id:`cycle_services_tab`,descriptionKey:`helpDialog.item.cycleServicesTab`,icon:`stack`,keys:``},{id:`open_settings`,descriptionKey:`helpDialog.item.openSettings`,icon:`settings-3`,keys:``}]}];d=Qr,g=r,_=i,u=Yr,p=n?`default`:`picker`,m=n?`max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden`:void 0;let c;e[16]===t?c=e[17]:(c=t(`helpDialog.title`),e[16]=t,e[17]=c),e[18]===c?h=e[19]:(h=(0,$.jsx)(qr,{className:`yuri-picker-header`,children:(0,$.jsx)(Xr,{className:`yuri-picker-title`,children:c})}),e[18]=c,e[19]=h),f=`yuri-picker-list`,v=(0,$.jsx)(`div`,{children:o.map(e=>(0,$.jsxs)(`div`,{className:`yuri-picker-section`,children:[(0,$.jsx)(`h3`,{className:`yuri-picker-section-title text-muted-foreground`,children:t(e.categoryKey)}),(0,$.jsx)(`div`,{children:e.items.filter(e=>!(l&&e.id===`toggle_prompt_navigator`)).map(e=>{let n=e.id?jv(e.id,Array.isArray(e.keys)?e.keys[0]:e.keys,a):Array.isArray(e.keys)?e.keys:e.keys.split(` / `);return(0,$.jsxs)(`div`,{className:`yuri-picker-row yuri-help-shortcut-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(X,{name:e.icon,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`yuri-picker-label`,children:t(e.descriptionKey)})]}),(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-1`,children:(Array.isArray(n)?n:[n]).map((e,n)=>(0,$.jsxs)(Z.Fragment,{children:[n>0&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground mx-1`,children:t(`helpDialog.keyCombiner.or`)}),(0,$.jsx)(Li,{shortcut:e,variant:`hint`})]},`${e}-${n}`))})]},e.id||e.descriptionKey)})})]},e.categoryKey))}),e[2]=r,e[3]=n,e[4]=i,e[5]=a,e[6]=t,e[7]=u,e[8]=d,e[9]=f,e[10]=p,e[11]=m,e[12]=h,e[13]=g,e[14]=_,e[15]=v}else u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],h=e[12],g=e[13],_=e[14],v=e[15];let y;e[20]!==f||e[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),e[20]=f,e[21]=v,e[22]=y):y=e[22];let b;e[23]!==u||e[24]!==p||e[25]!==m||e[26]!==h||e[27]!==y?(b=(0,$.jsxs)(u,{presentation:p,className:m,children:[h,y]}),e[23]=u,e[24]=p,e[25]=m,e[26]=h,e[27]=y,e[28]=b):b=e[28];let x;return e[29]!==d||e[30]!==b||e[31]!==g||e[32]!==_?(x=(0,$.jsx)(d,{open:g,onOpenChange:_,children:b}),e[29]=d,e[30]=b,e[31]=g,e[32]=_,e[33]=x):x=e[33],x};function Nv(e){return e.isHelpDialogOpen}function Pv(e){return e.setHelpDialogOpen}function Fv(e){return e.shortcutOverrides}var Iv=()=>{let e=(0,Q.c)(32),{t}=Nr(),n=K(Lv),r=K(Rv),i=K(zv),a;e[0]!==i||e[1]!==t?(a=async()=>{if(i){if((await pr(i)).ok){Y.success(t(`openCodeStatusDialog.toast.copiedTitle`),{description:t(`openCodeStatusDialog.toast.copiedDescription`)});return}Y.error(t(`openCodeStatusDialog.toast.copyFailed`))}},e[0]=i,e[1]=t,e[2]=a):a=e[2];let o=a,s;e[3]===t?s=e[4]:(s=t(`openCodeStatusDialog.title`),e[3]=t,e[4]=s);let c;e[5]===s?c=e[6]:(c=(0,$.jsx)(Xr,{children:s}),e[5]=s,e[6]=c);let l;e[7]===t?l=e[8]:(l=t(`openCodeStatusDialog.description`),e[7]=t,e[8]=l);let u;e[9]===l?u=e[10]:(u=(0,$.jsx)(Zr,{children:l}),e[9]=l,e[10]=u);let d;e[11]!==c||e[12]!==u?(d=(0,$.jsxs)(qr,{children:[c,u]}),e[11]=c,e[12]=u,e[13]=d):d=e[13];let f;e[14]===t?f=e[15]:(f=t(`openCodeStatusDialog.actions.copy`),e[14]=t,e[15]=f);let p;e[16]!==o||e[17]!==f?(p=(0,$.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`app-region-no-drag inline-flex h-9 items-center justify-center rounded-md px-3 typography-ui-label font-medium text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:f})}),e[16]=o,e[17]=f,e[18]=p):p=e[18];let m;e[19]!==i||e[20]!==t?(m=i||t(`openCodeStatusDialog.empty.noData`),e[19]=i,e[20]=t,e[21]=m):m=e[21];let h;e[22]===m?h=e[23]:(h=(0,$.jsx)(`pre`,{className:`max-h-[60vh] overflow-auto rounded-lg bg-surface-muted p-4 typography-code text-foreground whitespace-pre-wrap`,children:m}),e[22]=m,e[23]=h);let g;e[24]!==d||e[25]!==p||e[26]!==h?(g=(0,$.jsxs)(Yr,{className:`max-w-2xl`,children:[d,p,h]}),e[24]=d,e[25]=p,e[26]=h,e[27]=g):g=e[27];let _;return e[28]!==n||e[29]!==r||e[30]!==g?(_=(0,$.jsx)(Qr,{open:n,onOpenChange:r,children:g}),e[28]=n,e[29]=r,e[30]=g,e[31]=_):_=e[31],_};function Lv(e){return e.isOpenCodeStatusDialogOpen}function Rv(e){return e.setOpenCodeStatusDialogOpen}function zv(e){return e.openCodeStatusText}function Bv(){let e=(0,Q.c)(2),t=Ma(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Sl,{className:`ml-auto`}):null,e[0]=t,e[1]=n),n}function Vv(){let e=(0,Q.c)(2),t=Na(),n;return e[0]===t?n=e[1]:(n=t?(0,$.jsx)(Sl,{}):null,e[0]=t,e[1]=n),n}var Hv=e=>{let t=(0,Q.c)(12),{normalizedProjects:n,ownership:r,isSessionsLoading:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,foldersMap:s,createFolder:c,addSessionToFolder:l,cleanupSessions:u,enabled:d}=e,f=d===void 0||d,p,m;t[0]!==l||t[1]!==u||t[2]!==c||t[3]!==f||t[4]!==s||t[5]!==o||t[6]!==a||t[7]!==i||t[8]!==n||t[9]!==r?(p=()=>{!f||i||n.forEach(e=>{let t=yo(e.normalizedPath),n=r.archivedSessionsByProject.get(e.id)??[],i=s[t]??[],d=new Map(i.map(Uv));n.forEach(n=>{let r=go(n,e.normalizedPath),i=r.toLowerCase(),a=d.get(i);a||(a=c(t,r),d.set(i,a)),a.sessionIds.includes(n.id)||l(t,a.id,n.id)}),o>0&&u(t,a)})},m=[f,n,r,i,o,a,s,c,l,u],t[0]=l,t[1]=u,t[2]=c,t[3]=f,t[4]=s,t[5]=o,t[6]=a,t[7]=i,t[8]=n,t[9]=r,t[10]=p,t[11]=m):(p=t[10],m=t[11]),Z.useEffect(p,m)};function Uv(e){return[e.name.toLowerCase(),e]}var Wv=e=>{let t=(0,Q.c)(7),{isSessionsLoading:n,fullCatalogSessionIds:r,fullCatalogGeneration:i,normalizedProjects:a,cleanupSessions:o}=e,s,c;t[0]!==o||t[1]!==i||t[2]!==r||t[3]!==n||t[4]!==a?(s=()=>{if(n||i===0)return;let e=Sn.getState().foldersMap;new Set([...Object.keys(e),...a.map(Gv)]).forEach(e=>{o(e,r)})},c=[o,i,r,n,a],t[0]=o,t[1]=i,t[2]=r,t[3]=n,t[4]=a,t[5]=s,t[6]=c):(s=t[5],c=t[6]),Z.useEffect(s,c)};function Gv(e){return yo(e.normalizedPath)}var Kv=Z.memo(function(e){let t=(0,Q.c)(17),{normalizedProjects:n,ownership:r,enabled:i}=e;zc();let a=on(qv),o=on(Jv),s=Vn(Yv),c=Sn(Xv),l=Sn(Zv),u=Sn(Qv),d=Sn($v),f;t[0]!==d||t[1]!==o||t[2]!==a||t[3]!==s||t[4]!==n?(f={normalizedProjects:n,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,cleanupSessions:d},t[0]=d,t[1]=o,t[2]=a,t[3]=s,t[4]=n,t[5]=f):f=t[5],Wv(f);let p;return t[6]!==u||t[7]!==d||t[8]!==l||t[9]!==i||t[10]!==c||t[11]!==o||t[12]!==a||t[13]!==s||t[14]!==n||t[15]!==r?(p={normalizedProjects:n,ownership:r,enabled:i,fullCatalogSessionIds:a,fullCatalogGeneration:o,isSessionsLoading:s,foldersMap:c,createFolder:l,addSessionToFolder:u,cleanupSessions:d},t[6]=u,t[7]=d,t[8]=l,t[9]=i,t[10]=c,t[11]=o,t[12]=a,t[13]=s,t[14]=n,t[15]=r,t[16]=p):p=t[16],Hv(p),null});function qv(e){return e.fullCatalogSessionIds}function Jv(e){return e.fullCatalogGeneration}function Yv(e){return e.isLoading}function Xv(e){return e.foldersMap}function Zv(e){return e.createFolder}function Qv(e){return e.addSessionToFolder}function $v(e){return e.cleanupSessions}var ey=new WeakMap,ty=e=>{let{normalizedProjects:t,getSessionsForProject:n,getArchivedSessionsForProject:r,availableWorktreesByProject:i,projectRepoStatus:a,projectRootBranches:o,lastRepoStatus:s,buildGroupedSessions:c,hasSessionSearchQuery:l,normalizedSessionSearchQuery:u,filterSessionNodesForSearch:d,buildGroupSearchText:f,foldersMap:p}=e,m=Z.useRef([]),h=Z.useMemo(()=>{let e=new Map(m.current.map(e=>[e.project.id,e])),l=t.map(t=>{let l=e.get(t.id),u=To([...n(t.id),...r(t.id)]),d=i.get(t.normalizedPath)??[],f=a.has(t.id)?!!a.get(t.id):s,p=new Map(l?.groups.map(e=>[e.id,e])),m=c(u,t.normalizedPath,d,o.get(t.id)??null,f).map(e=>gt(p.get(e.id),e));return gt(l,{project:t,groups:m})});return l.length===m.current.length&&l.every((e,t)=>e===m.current[t])?m.current:l},[t,n,r,i,a,s,c,o]);Z.useLayoutEffect(()=>{m.current=h},[h]);let g=Z.useMemo(()=>h,[h]),_=Z.useMemo(()=>{if(!l)return ey;let e=new WeakMap,t=e=>e.reduce((e,n)=>e+1+t(n.children),0);return g.forEach(n=>{n.groups.forEach(n=>{let r=d(n.sessions,u),i=t(r),a=f(n).includes(u),o=P(n.directory??null),s=(o?p[o]??[]:[]).filter(e=>e.name.toLowerCase().includes(u)).length;e.set(n,{filteredNodes:r,matchedSessionCount:i,folderNameMatchCount:s,groupMatches:a,hasMatch:a||i>0||s>0})})}),e},[l,g,d,u,f,p]),v=Z.useMemo(()=>l?g.map(e=>({...e,groups:e.groups.filter(e=>_.get(e)?.hasMatch===!0)})).filter(e=>e.groups.length>0):g,[l,g,_]),y=l?v:g;return{projectSections:h,visibleProjectSections:g,groupSearchDataByGroup:_,searchableProjectSections:v,sectionsForRender:y,searchMatchCount:Z.useMemo(()=>l?y.reduce((e,t)=>e+t.groups.reduce((e,t)=>{let n=_.get(t);if(!n)return e;let r=n.folderNameMatchCount+ +!!n.groupMatches;return e+n.matchedSessionCount+r},0),0):0,[l,y,_])}},ny=e=>{let t=(0,Q.c)(26),{projectSections:n,activeProjectId:r,activeSessionByProject:i,setActiveSessionByProject:a,currentSessionId:o,handleSessionSelect:s,newSessionDraftOpen:c,mobileVariant:l,openNewSessionDraft:u,setActiveMainTab:d,setSessionSwitcherOpen:f}=e,p,m;if(t[0]!==n){m=new Map,p=new Map;let e=(t,n,r,i)=>{m.has(t)||m.set(t,new Map);let a=m.get(t);i.forEach(i=>{let o=P(i.worktree?.path??i.session.directory??r??n);a.set(i.session.id,{directory:o}),p.has(t)||p.set(t,{id:i.session.id,directory:o}),i.children.length>0&&e(t,n,o,i.children)})};n.forEach(t=>{t.groups.forEach(n=>{e(t.project.id,t.project.normalizedPath,n.directory,n.sessions)})}),t[0]=n,t[1]=p,t[2]=m}else p=t[1],m=t[2];let h;t[3]!==p||t[4]!==m?(h={metaByProject:m,firstSessionByProject:p},t[3]=p,t[4]=m,t[5]=h):h=t[5];let g=h,_=Z.useRef(null),v,y;t[6]!==r||t[7]!==i||t[8]!==o||t[9]!==s||t[10]!==l||t[11]!==c||t[12]!==u||t[13]!==n||t[14]!==g||t[15]!==d||t[16]!==a||t[17]!==f?(v=()=>{if(!r||c||K.getState().isNewWorktreeDialogOpen||_.current===r)return;let e=n.find(e=>e.project.id===r);if(!e)return;_.current=r;let t=g.metaByProject.get(r);if(o&&t&&t.has(o)){a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t});return}if(o&&t)return;if(!t||t.size===0){d(`chat`),l&&f(!1),u({directoryOverride:e.project.normalizedPath});return}let p=i.get(r),m=p&&t.has(p)?p:null,h=g.firstSessionByProject.get(r)?.id??null,v=m??h;if(!v||v===o)return;let y=t.get(v)?.directory??null;s(v,y,r)},y=[r,i,o,s,c,l,u,n,g,d,f,a],t[6]=r,t[7]=i,t[8]=o,t[9]=s,t[10]=l,t[11]=c,t[12]=u,t[13]=n,t[14]=g,t[15]=d,t[16]=a,t[17]=f,t[18]=v,t[19]=y):(v=t[18],y=t[19]),Z.useLayoutEffect(v,y);let b,x;t[20]!==r||t[21]!==o||t[22]!==g||t[23]!==a?(b=()=>{if(!r||!o)return;let e=g.metaByProject.get(r);!e||!e.has(o)||a(e=>{if(e.get(r)===o)return e;let t=new Map(e);return t.set(r,o),t})},x=[r,o,g,a],t[20]=r,t[21]=o,t[22]=g,t[23]=a,t[24]=b,t[25]=x):(b=t[24],x=t[25]),Z.useEffect(b,x)},ry=e=>{let t=pn(e=>e.orderByProject);return{getOrderedGroups:Z.useMemo(()=>(n,r)=>{let i=e.get(n),a=t[n];if(!i?.length&&!a?.length)return r;let o=new Map(r.map(e=>[e.id,e])),s=[];if(i?.forEach(e=>{let t=o.get(e);t&&(s.push(t),o.delete(e))}),r.forEach(e=>{o.has(e.id)&&s.push(e)}),!a?.length)return s;let c=new Map(a.map((e,t)=>[P(e),t])),l=s.filter(e=>e.worktree&&!e.isMain);l.sort((e,t)=>(c.get(P(e.directory))??2**53-1)-(c.get(P(t.directory))??2**53-1));let u=0;return s.map(e=>e.worktree&&!e.isMain?l[u++]:e)},[e,t])}},iy=e=>{let t=(0,Q.c)(9),{isSessionSearchOpen:n,setIsSessionSearchOpen:r,sessionSearchInputRef:i,sessionSearchContainerRef:a}=e,o,s;t[0]!==n||t[1]!==i?(o=()=>{if(!n||typeof window>`u`)return;let e=window.requestAnimationFrame(()=>{i.current?.focus(),i.current?.select()});return()=>window.cancelAnimationFrame(e)},s=[n,i],t[0]=n,t[1]=i,t[2]=o,t[3]=s):(o=t[2],s=t[3]),Z.useEffect(o,s);let c,l;t[4]!==n||t[5]!==a||t[6]!==r?(c=()=>{if(!n||typeof document>`u`)return;let e=e=>{a.current&&(a.current.contains(e.target)||r(!1))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},l=[n,r,a],t[4]=n,t[5]=a,t[6]=r,t[7]=c,t[8]=l):(c=t[7],l=t[8]),Z.useEffect(c,l)},ay=e=>{let t=(0,Q.c)(42),{t:n}=Nr(),[r,i]=Z.useState(null),a=Z.useRef(null),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>()=>{a.current&&clearTimeout(a.current)},s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),Z.useEffect(o,s);let c;t[2]===e?c=t[3]:(c=(t,n,r)=>{let i=()=>{!e.isSessionSearchOpen&&e.sessionSearchQuery.length===0||(e.setSessionSearchQuery(``),e.setIsSessionSearchOpen(!1))};if(r&&r!==e.activeProjectId&&e.setActiveProjectIdOnly(r),n&&n!==e.currentDirectory&&e.setDirectory(n,{showOverlay:!1}),e.setActiveMainTab(`chat`)){if(e.mobileVariant&&e.setSessionSwitcherOpen(!1),t===e.currentSessionId){e.allowReselect&&e.onSessionSelected?.(t),i();return}e.setCurrentSession(t,n??null),e.onSessionSelected?.(t),i()}},t[2]=e,t[3]=c);let l=c,u;t[4]===e?u=t[5]:(u=(t,n)=>{e.setEditingId(t),e.setEditTitle(n)},t[4]=e,t[5]=u);let d=u,f;t[6]===e?f=t[7]:(f=async t=>{if(!e.editingId)return;let n=(t??e.editTitle).trim();n&&await e.updateSessionTitle(e.editingId,n),e.setEditingId(null),e.setEditTitle(``)},t[6]=e,t[7]=f);let p=f,m;t[8]===e?m=t[9]:(m=()=>{e.setEditingId(null),e.setEditTitle(``)},t[8]=e,t[9]=m);let h=m,g;t[10]!==e||t[11]!==n?(g=async t=>{let r=await e.shareSession(t.id);r&&r.share?.url?Y.success(n(`sessions.sidebar.session.share.successTitle`),{description:n(`sessions.sidebar.session.share.successDescription`)}):Y.error(n(`sessions.sidebar.session.share.error`))},t[10]=e,t[11]=n,t[12]=g):g=t[12];let _=g,v;t[13]===n?v=t[14]:(v=(e,t)=>{pr(e).then(e=>{if(!e.ok){Y.error(n(`sessions.sidebar.session.share.copyUrlError`));return}i(t),a.current&&clearTimeout(a.current),a.current=window.setTimeout(()=>{i(null),a.current=null},2e3)}).catch(()=>{Y.error(n(`sessions.sidebar.session.share.copyUrlError`))})},t[13]=n,t[14]=v);let y=v,b;t[15]!==e||t[16]!==n?(b=async t=>{await e.unshareSession(t)?Y.success(n(`sessions.sidebar.session.unshare.success`)):Y.error(n(`sessions.sidebar.session.unshare.error`))},t[15]=e,t[16]=n,t[17]=b):b=t[17];let x=b,S;t[18]===e.childrenMap?S=t[19]:(S=t=>{let n=[],r=t=>{(e.childrenMap.get(t)??[]).forEach(e=>{n.push(e),r(e.id)})};return r(t),n},t[18]=e.childrenMap,t[19]=S);let C=S,w=sy,T;t[20]!==e||t[21]!==C||t[22]!==n?(T=async(t,r,i)=>{let a=r?.archivedBucket===!0||r?.hardDelete===!0,o=i?.descendantIds??w(C(t.id),a).map(cy);if(o.length===0){if(a){Xc({sessionIds:[t.id],message:n(`sessions.sidebar.session.delete.success`),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}await e.archiveSession(t.id)?vl({sessionIds:[t.id],message:n(`sessions.sidebar.session.archive.success`),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n(`sessions.sidebar.session.archive.undoFailed`)}):Y.error(n(`sessions.sidebar.session.archive.error`));return}let s=[t.id,...o];if(a){Xc({sessionIds:s,message:s.length===1?n(`sessions.sidebar.bulkActions.deletedSingle`,{count:s.length}):n(`sessions.sidebar.bulkActions.deletedPlural`,{count:s.length}),undoLabel:n(`sessions.sidebar.undo`),commitFailedMessage:n(`sessions.sidebar.session.delete.error`)});return}let{archivedIds:c,failedIds:l}=await e.archiveSessions(s);c.length>0&&vl({sessionIds:c,message:c.length===1?n(`sessions.sidebar.bulkActions.archivedSingle`,{count:c.length}):n(`sessions.sidebar.bulkActions.archivedPlural`,{count:c.length}),undoLabel:n(`sessions.sidebar.undo`),settingsLabel:n(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:c.length===1?n(`sessions.sidebar.session.archive.undoFailed`):n(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:c.length})}),l.length>0&&Y.error(l.length===1?n(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:l.length}):n(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:l.length}))},t[20]=e,t[21]=C,t[22]=n,t[23]=T):T=t[23];let E=T,D;t[24]!==e||t[25]!==C||t[26]!==E?(D=(t,n)=>{let r=n?.archivedBucket===!0||n?.hardDelete===!0,i=w(C(t.id),r).map(ly);if(!r||!e.showDeletionDialog||n?.skipConfirm===!0){E(t,n,{descendantIds:i});return}e.setDeleteSessionConfirm({session:t,descendantCount:i.length,descendantIds:i,archivedBucket:r})},t[24]=e,t[25]=C,t[26]=E,t[27]=D):D=t[27];let O=D,k;t[28]!==e||t[29]!==E?(k=async()=>{if(!e.deleteSessionConfirm)return;let{session:t,archivedBucket:n,descendantIds:r}=e.deleteSessionConfirm;e.setDeleteSessionConfirm(null),await E(t,{archivedBucket:n},{descendantIds:r})},t[28]=e,t[29]=E,t[30]=k):k=t[30];let A=k,j;return t[31]!==A||t[32]!==r||t[33]!==h||t[34]!==y||t[35]!==O||t[36]!==p||t[37]!==d||t[38]!==l||t[39]!==_||t[40]!==x?(j={copiedSessionId:r,handleSessionSelect:l,handleSessionDoubleClick:d,handleSaveEdit:p,handleCancelEdit:h,handleShareSession:_,handleCopyShareUrl:y,handleUnshareSession:x,handleDeleteSession:O,confirmDeleteSession:A},t[31]=A,t[32]=r,t[33]=h,t[34]=y,t[35]=O,t[36]=p,t[37]=d,t[38]=l,t[39]=_,t[40]=x,t[41]=j):j=t[41],j};function oy(e){return!e.time?.archived}function sy(e,t){return t?e:e.filter(oy)}function cy(e){return e.id}function ly(e){return e.id}var uy=[`project:active:`,`project:archived:`,`pinned:active:`,`pinned:archived:`],dy=e=>{let{isVSCode:t,safeStorage:n,keys:r,groupOrderByProject:i,activeSessionByProject:a,collapsedGroups:o,setExpandedParents:s,setCollapsedProjects:c}=e,l=Z.useRef(null),u=Z.useRef(null),[d,f]=Z.useState(!1),p=Z.useCallback(()=>{if(t)return;let e=u.current;if(u.current=null,l.current=null,!e)return;let{projects:n}=$t.getState(),r=n.map(t=>({...t,sidebarCollapsed:e.has(t.id)}));Pe({projects:r}).catch(()=>{})},[t]),m=Z.useCallback(e=>{typeof window>`u`||t||(u.current=e,l.current!==null&&window.clearTimeout(l.current),l.current=window.setTimeout(()=>{p()},700))},[t,p]);return Z.useEffect(()=>()=>{typeof window<`u`&&l.current!==null&&window.clearTimeout(l.current),l.current=null,u.current=null},[]),Z.useEffect(()=>{try{let e=n.getItem(r.sessionExpanded);if(e){let t=JSON.parse(e);Array.isArray(t)&&s(new Set(t.filter(e=>typeof e==`string`)))}else{let e=n.getItem(r.sessionExpandedLegacy);if(e){try{let t=JSON.parse(e);if(Array.isArray(t)){let e=new Set;if(t.forEach(t=>{typeof t==`string`&&t.length!==0&&uy.forEach(n=>e.add(`${n}${t}`))}),e.size>0){s(e);try{n.setItem(r.sessionExpanded,JSON.stringify(Array.from(e)))}catch{}}}}catch{}try{n.removeItem?.(r.sessionExpandedLegacy)}catch{}}}let t=n.getItem(r.projectCollapse);if(t){let e=JSON.parse(t);Array.isArray(e)&&c(new Set(e.filter(e=>typeof e==`string`)))}}catch{}finally{f(!0)}},[r.projectCollapse,r.sessionExpanded,r.sessionExpandedLegacy,n,c,s]),Z.useEffect(()=>{try{let e=Object.fromEntries(i.entries());n.setItem(r.groupOrder,JSON.stringify(e))}catch{}},[i,r.groupOrder,n]),Z.useEffect(()=>{try{let e=Object.fromEntries(a.entries());n.setItem(r.projectActiveSession,JSON.stringify(e))}catch{}},[a,r.projectActiveSession,n]),Z.useEffect(()=>{try{n.setItem(r.groupCollapse,JSON.stringify(Array.from(o)))}catch{}},[o,r.groupCollapse,n]),{scheduleCollapsedProjectsPersist:m,hasRestoredProjectCollapse:d}},fy=async(e,t,n)=>{if(e.length===0)return[];let r=Math.max(1,Math.min(t,e.length)),i=Array(e.length),a=0,o=async()=>{for(;;){let t=a;if(a+=1,t>=e.length)return;i[t]=await n(e[t])}};return await Promise.all(Array.from({length:r},()=>o())),i},py=e=>{let{normalizedProjects:t,activeProjectId:n,gitRepoStatus:r,setProjectRepoStatus:i,setProjectRootBranches:a,enabled:o=!0}=e,{git:s}=Tt(),c=Qi(e=>e.ensureStatus),l=Z.useMemo(()=>o?t.filter(e=>e.id===n):[],[n,o,t]);Z.useEffect(()=>{if(!o||!s||l.length===0){if(!o)return;i(e=>e.size===0?e:new Map);return}l.forEach(e=>{c(e.normalizedPath,s)})},[l,o,s,c,i]),Z.useEffect(()=>{let e=new Map;l.forEach(t=>{e.set(t.id,r.get(t.normalizedPath)?.isGitRepo??null)}),i(t=>t.size===e.size&&[...e].every(([e,n])=>t.has(e)&&t.get(e)===n)?t:e)},[l,r,i]);let u=Z.useMemo(()=>l.map(e=>{let t=r.get(e.normalizedPath)?.branch??``;return`${e.id}:${t}`}).join(`|`),[l,r]),d=Z.useRef(new Map),f=Z.useRef(new Map);Z.useEffect(()=>{let e=!1,t=setTimeout(()=>{(async()=>{let t=new Set(l.map(e=>e.id));for(let e of d.current.keys())t.has(e)||(d.current.delete(e),f.current.delete(e));let n=Date.now(),i=l.filter(e=>{let t=r.get(e.normalizedPath);if(t?.isGitRepo===!1)return d.current.delete(e.id),f.current.delete(e.id),!1;if(t?.isGitRepo!==!0||t.branch===null)return!1;let i=t.branch.trim(),a=`${e.normalizedPath}\0${i}`,o=d.current.get(e.id);if(o===a){let t=f.current.get(e.id);return t&&(t.at=n),!1}return!(o!==void 0&&n-(f.current.get(e.id)?.at??0)<3e5)});if(i.length===0)return;let o=await fy(i,2,async e=>{let t=r.get(e.normalizedPath)?.branch?.trim()??``,n=`${e.normalizedPath}\0${t}`,i=await Bs(e.normalizedPath,t?{knownBranch:t}:void 0).catch(()=>null);return{id:e.id,inputKey:n,branch:i}});if(e)return;let s=o.filter(e=>e.branch);if(s.length===0)return;let c=Date.now();a(e=>{let t=e;return s.forEach(({id:n,branch:r})=>{r&&e.get(n)!==r&&(t===e&&(t=new Map(e)),t.set(n,r))}),t}),s.forEach(({id:e,inputKey:t,branch:n})=>{d.current.set(e,t),n&&f.current.set(e,{branch:n,at:c})})})()},150);return()=>{e=!0,clearTimeout(t)}},[l,u,r,a])},my=e=>{let t=(0,Q.c)(7),{ownership:n}=e,r;t[0]===n?r=t[1]:(r=e=>n.sessionsByProject.get(e)??[],t[0]=n,t[1]=r);let i=r,a;t[2]===n?a=t[3]:(a=e=>n.archivedSessionsByProject.get(e)??[],t[2]=n,t[3]=a);let o=a,s;return t[4]!==o||t[5]!==i?(s={getSessionsForProject:i,getArchivedSessionsForProject:o},t[4]=o,t[5]=i,t[6]=s):s=t[6],s},hy=e=>{let t=(0,Q.c)(16),{open:n,onOpenChange:r,project:i,onSave:a}=e,o;t[0]!==i?.label||t[1]!==i?.path?(o=i?.label||i?.path.split(/[\\/]/).filter(Boolean).at(-1),t[0]=i?.label,t[1]=i?.path,t[2]=o):o=t[2];let s;t[3]!==a||t[4]!==n||t[5]!==i?(s=n&&i?(0,$.jsx)(ou,{project:i,onIdentitySave:a,compact:!0}):null,t[3]=a,t[4]=n,t[5]=i,t[6]=s):s=t[6];let c;t[7]===s?c=t[8]:(c=(0,$.jsx)(Wr,{outerClassName:`max-h-[min(85dvh,44rem)]`,disableHorizontal:!0,children:(0,$.jsx)(`div`,{className:`w-full p-4 sm:p-6`,children:s})}),t[7]=s,t[8]=c);let l;t[9]!==o||t[10]!==c?(l=(0,$.jsx)(Yr,{"aria-label":o,className:`yuri-settings-workspace w-full max-w-xl gap-0 overflow-hidden p-0`,children:c}),t[9]=o,t[10]=c,t[11]=l):l=t[11];let u;return t[12]!==r||t[13]!==n||t[14]!==l?(u=(0,$.jsx)(Qr,{open:n,onOpenChange:r,children:l}),t[12]=r,t[13]=n,t[14]=l,t[15]=u):u=t[15],u};function gy(e){let t=(0,Q.c)(36),{t:n}=Nr(),{hideDirectoryControls:r,isSessionSearchOpen:i,setIsSessionSearchOpen:a,sessionSearchInputRef:o,sessionSearchQuery:s,setSessionSearchQuery:c,hasSessionSearchQuery:l,searchMatchCount:u}=e;if(r||!i)return null;let d;t[0]!==l||t[1]!==u||t[2]!==n?(d=l?(0,$.jsx)(`span`,{children:n(u===1?`sessions.sidebar.header.search.matchCountSingle`:`sessions.sidebar.header.search.matchCountPlural`,{count:u})}):(0,$.jsx)(`span`,{}),t[0]=l,t[1]=u,t[2]=n,t[3]=d):d=t[3];let f;t[4]===n?f=t[5]:(f=n(`sessions.sidebar.header.search.escapeHint`),t[4]=n,t[5]=f);let p;t[6]===f?p=t[7]:(p=(0,$.jsx)(`span`,{children:f}),t[6]=f,t[7]=p);let m;t[8]!==d||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between px-0.5 typography-micro text-muted-foreground/80`,children:[d,p]}),t[8]=d,t[9]=p,t[10]=m):m=t[10];let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=e=>c(e.target.value),t[12]=c,t[13]=g);let _;t[14]===n?_=t[15]:(_=n(`sessions.sidebar.header.search.placeholder`),t[14]=n,t[15]=_);let v;t[16]!==l||t[17]!==a||t[18]!==c?(v=e=>{e.key===`Escape`&&(e.stopPropagation(),l?c(``):a(!1))},t[16]=l,t[17]=a,t[18]=c,t[19]=v):v=t[19];let y;t[20]!==o||t[21]!==s||t[22]!==g||t[23]!==_||t[24]!==v?(y=(0,$.jsx)(`input`,{ref:o,value:s,onChange:g,placeholder:_,className:`h-8 w-full rounded-md border border-border bg-transparent pl-8 pr-8 typography-ui-label text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,onKeyDown:v}),t[20]=o,t[21]=s,t[22]=g,t[23]=_,t[24]=v,t[25]=y):y=t[25];let b;t[26]!==s.length||t[27]!==c||t[28]!==n?(b=s.length>0?(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`absolute right-1 top-1/2 inline-flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":n(`sessions.sidebar.header.search.clear`),children:(0,$.jsx)(X,{name:`close`,className:`h-3.5 w-3.5`})}):null,t[26]=s.length,t[27]=c,t[28]=n,t[29]=b):b=t[29];let x;t[30]!==y||t[31]!==b?(x=(0,$.jsxs)(`div`,{className:`relative`,children:[h,y,b]}),t[30]=y,t[31]=b,t[32]=x):x=t[32];let S;return t[33]!==x||t[34]!==m?(S=(0,$.jsx)(`div`,{className:`select-none flex-shrink-0 px-3 py-1`,children:(0,$.jsxs)(`div`,{className:`pb-1`,children:[m,x]})}),t[33]=x,t[34]=m,t[35]=S):S=t[35],S}function _y(e){let t=(0,Q.c)(14),{title:n,accessory:r,isFirst:i,onToggle:a,expanded:o,className:s,titleSlot:c}=e,l=i!==void 0&&i,u=c?l?`pt-1 pb-1.5`:`pt-3 pb-1.5`:l?`pt-1 pb-1`:`pt-4 pb-1`,d;t[0]!==s||t[1]!==u?(d=J(`group/section flex w-full items-center gap-1 px-2`,u,s),t[0]=s,t[1]=u,t[2]=d):d=t[2];let f;t[3]!==o||t[4]!==a||t[5]!==n||t[6]!==c?(f=c?(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:c}):a?(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`group/toggle flex min-w-0 flex-1 items-center gap-1 rounded-md text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-expanded":o,children:[(0,$.jsx)(`span`,{className:`typography-micro font-normal tracking-wide text-muted-foreground/80`,children:n}),(0,$.jsx)(X,{name:o?`arrow-down-s`:`arrow-right-s`,className:`size-3 shrink-0 opacity-0 transition-opacity group-hover/toggle:opacity-100 group-focus-visible/toggle:opacity-100`})]}):(0,$.jsx)(`span`,{className:J(`flex min-w-0 flex-1 items-center gap-1`,`typography-micro font-normal tracking-wide text-muted-foreground/80`),children:n}),t[3]=o,t[4]=a,t[5]=n,t[6]=c,t[7]=f):f=t[7];let p;t[8]===r?p=t[9]:(p=r?(0,$.jsx)(`div`,{className:`ml-auto -mr-2 flex shrink-0 items-center`,children:r}):null,t[8]=r,t[9]=p);let m;return t[10]!==d||t[11]!==f||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:d,children:[f,p]}),t[10]=d,t[11]=f,t[12]=p,t[13]=m):m=t[13],m}function vy(e){let t=(0,Q.c)(60),{items:n,reorderEnabled:r,onSessionsReordered:i,inProgressItems:a,renderSessionNode:o,currentSessionId:s,editingId:c,openSidebarMenuKey:l,headerAccessory:u,onVisibleSessionIdsChange:d,isFirst:f,hideHeader:p}=e,m=r!==void 0&&r,h;t[0]===a?h=t[1]:(h=a===void 0?[]:a,t[0]=a,t[1]=h);let g=h,_=f!==void 0&&f,v=p!==void 0&&p,{t:y}=Nr(),[b,x]=Z.useState(!1),S=b&&!v,C=m&&!c&&n.length>1&&!!i,w;t[2]===n?w=t[3]:(w=n.map(Ey),t[2]=n,t[3]=w);let T=w,E;t[4]===T?E=t[5]:(E=new Map(T.map(Ty)),t[4]=T,t[5]=E);let D=E,O=uo(wy),k,A;t[6]!==S||t[7]!==g||t[8]!==n||t[9]!==d?(k=()=>{if(S){d?.([]);return}d?.([...n.map(Cy),...g.map(Sy)])},A=[S,g,n,d],t[6]=S,t[7]=g,t[8]=n,t[9]=d,t[10]=k,t[11]=A):(k=t[10],A=t[11]),Z.useLayoutEffect(k,A);let j,M;t[12]!==g||t[13]!==n||t[14]!==O?(j=()=>{O&&(n.some(e=>e.node.session.id===O)||g.some(e=>e.node.session.id===O))&&x(!1)},M=[g,n,O],t[12]=g,t[13]=n,t[14]=O,t[15]=j,t[16]=M):(j=t[15],M=t[16]),Z.useLayoutEffect(j,M);let N,P,F,I;if(t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==n||t[21]!==l){let e=[...n,...g].map(xy);F=new Set,pc(e,s,F),I=new Set,pc(e,c,I),N=Nc(e,l,`pinned`,!1),P=new WeakMap;let r=e=>{P.set(e,al(e)),e.children.forEach(r)};e.forEach(r),t[17]=s,t[18]=c,t[19]=g,t[20]=n,t[21]=l,t[22]=N,t[23]=P,t[24]=F,t[25]=I}else N=t[22],P=t[23],F=t[24],I=t[25];let L;t[26]!==N||t[27]!==P||t[28]!==F||t[29]!==I?(L=e=>({subtreeContainsActive:F,subtreeContainsEditing:I,menuOpenSessionId:N,nodeStructureKey:P.get(e)??``,childRenderExtrasFor:L}),t[26]=N,t[27]=P,t[28]=F,t[29]=I,t[30]=L):L=t[30];let R;t[31]!==L||t[32]!==N||t[33]!==P||t[34]!==F||t[35]!==I?(R=e=>({subtreeContainsActive:F,subtreeContainsEditing:I,menuOpenSessionId:N,nodeStructureKey:P.get(e)??``,childRenderExtrasFor:L}),t[31]=L,t[32]=N,t[33]=P,t[34]=F,t[35]=I,t[36]=R):R=t[36];let z=R;if(n.length+g.length===0)return null;let ee;t[37]!==z||t[38]!==o?(ee=e=>e.map(e=>{let t=e.content??o(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`pinned`,z(e.node));return(0,$.jsx)(Z.Fragment,{children:t},e.identity??e.node.session.id)}),t[37]=z,t[38]=o,t[39]=ee):ee=t[39];let B=ee,te=v?void 0:`pb-1`,ne;t[40]!==S||t[41]!==u||t[42]!==v||t[43]!==g.length||t[44]!==_||t[45]!==y?(ne=v?null:(0,$.jsx)(_y,{title:g.length>0?y(`directoryTree.section.pinnedInProgress`):y(`directoryTree.section.pinned`),onToggle:()=>x(by),expanded:!S,isFirst:_,accessory:u}),t[40]=S,t[41]=u,t[42]=v,t[43]=g.length,t[44]=_,t[45]=y,t[46]=ne):ne=t[46];let re;t[47]!==C||t[48]!==S||t[49]!==D||t[50]!==g||t[51]!==n||t[52]!==i||t[53]!==B||t[54]!==T?(re=S?null:(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[C?(0,$.jsx)(Yc,{scopeKey:xc,sessionIds:T,folderIdBySessionId:D,onSessionDroppedOnFolder:yy,onSessionsReordered:(e,t)=>i?.(e,t),children:B(n)}):B(n),B(g)]}),t[47]=C,t[48]=S,t[49]=D,t[50]=g,t[51]=n,t[52]=i,t[53]=B,t[54]=T,t[55]=re):re=t[55];let ie;return t[56]!==te||t[57]!==ne||t[58]!==re?(ie=(0,$.jsx)(ti,{delay:0,closeDelay:150,timeout:600,children:(0,$.jsxs)(`div`,{className:te,children:[ne,re]})}),t[56]=te,t[57]=ne,t[58]=re,t[59]=ie):ie=t[59],ie}function yy(){}function by(e){return!e}function xy(e){return e.node}function Sy(e){return e.node.session.id}function Cy(e){return e.node.session.id}function wy(e){return e.focus?.scope===`pinned`?e.focus.sessionId:null}function Ty(e){return[e,null]}function Ey(e){return e.node.session.id}function Dy(e){let t=(0,Q.c)(41),{collapseAllProjects:n,expandAllProjects:r,buttonClassName:i,iconClassName:a}=e,{t:o}=Nr(),s;t[0]===i?s=t[1]:(s=J(`size-6 p-0 text-muted-foreground`,i),t[0]=i,t[1]=s);let c;t[2]===o?c=t[3]:(c=o(`sessions.sidebar.header.actions.sessionDisplayMode`),t[2]=o,t[3]=c);let l;t[4]===a?l=t[5]:(l=J(`h-3.5 w-3.5`,a),t[4]=a,t[5]=l);let u;t[6]===l?u=t[7]:(u=(0,$.jsx)(X,{name:`more-2-fill`,className:l}),t[6]=l,t[7]=u);let d;t[8]!==s||t[9]!==c||t[10]!==u?(d=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:s,"aria-label":c,onClick:Oy,children:u})})}),t[8]=s,t[9]=c,t[10]=u,t[11]=d):d=t[11];let f;t[12]===o?f=t[13]:(f=o(`sessions.sidebar.header.displayMode.label`),t[12]=o,t[13]=f);let p;t[14]===f?p=t[15]:(p=(0,$.jsx)(ei,{side:`bottom`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f})}),t[14]=f,t[15]=p);let m;t[16]!==d||t[17]!==p?(m=(0,$.jsxs)(ni,{children:[d,p]}),t[16]=d,t[17]=p,t[18]=m):m=t[18];let h;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(X,{name:`contract-up-down`,className:`h-4 w-4`}),t[19]=h):h=t[19];let g;t[20]===o?g=t[21]:(g=o(`sessions.sidebar.header.displayMode.collapseAll`),t[20]=o,t[21]=g);let _;t[22]===g?_=t[23]:(_=(0,$.jsx)(`span`,{children:g}),t[22]=g,t[23]=_);let v;t[24]!==n||t[25]!==_?(v=(0,$.jsxs)(xi,{onClick:n,className:`flex items-center gap-2`,children:[h,_]}),t[24]=n,t[25]=_,t[26]=v):v=t[26];let y;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(X,{name:`expand-up-down`,className:`h-4 w-4`}),t[27]=y):y=t[27];let b;t[28]===o?b=t[29]:(b=o(`sessions.sidebar.header.displayMode.expandAll`),t[28]=o,t[29]=b);let x;t[30]===b?x=t[31]:(x=(0,$.jsx)(`span`,{children:b}),t[30]=b,t[31]=x);let S;t[32]!==r||t[33]!==x?(S=(0,$.jsxs)(xi,{onClick:r,className:`flex items-center gap-2`,children:[y,x]}),t[32]=r,t[33]=x,t[34]=S):S=t[34];let C;t[35]!==v||t[36]!==S?(C=(0,$.jsxs)(bi,{align:`end`,className:`min-w-[160px]`,children:[v,S]}),t[35]=v,t[36]=S,t[37]=C):C=t[37];let w;return t[38]!==C||t[39]!==m?(w=(0,$.jsxs)(Ci,{children:[m,C]}),t[38]=C,t[39]=m,t[40]=w):w=t[40],w}function Oy(e){e.stopPropagation()}var ky=()=>vt({queryKey:[u(),d(),`device-connections`],queryFn:async({signal:e})=>{let t=await g(`/api/client-auth/clients`,{signal:e});if(!t.ok)throw Error(`Device list unavailable`);let n=await t.json();if(!Array.isArray(n.clients))throw Error(`Invalid device list`);if(n.clients.some(e=>typeof e.connected!=`boolean`))throw Error(`Presence unavailable`);return n.clients.filter(e=>!e.revokedAt&&e.connected&&e.clientKind!==`desktop-local`&&e.id!==n.currentClientId)},staleTime:0,retry:!1});function Ay(){let e=(0,Q.c)(53),{t}=Nr(),{clientAuth:n}=Tt(),[r,i]=(0,Z.useState)(!1),a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=ky(),e[0]=a):a=e[0];let o=r&&!!n,s=r?5e3:!1,c;e[1]!==o||e[2]!==s?(c={...a,enabled:o,refetchInterval:s},e[1]=o,e[2]=s,e[3]=c):c=e[3];let l=yt(c),u;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{i(!1);let e=K.getState();e.setSettingsRemoteInstancesSelectedId(null),e.setSettingsPage(`remote-instances`),K.setState({devicePairingRequested:!0}),e.setSettingsDialogOpen(!0)},e[4]=u):u=e[4];let d=G(u);if(!n)return null;let f;e[5]===t?f=e[6]:(f=t(`settings.remoteInstances.quick.title`),e[5]=t,e[6]=f);let p;e[7]===f?p=e[8]:(p=(0,$.jsx)(q,{variant:`ghost`,size:`icon`,className:`group size-7 rounded-md text-foreground/55 hover:bg-interactive-hover hover:text-foreground`,"aria-label":f}),e[7]=f,e[8]=p);let m;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{name:`devices-connected`,className:`size-[18px]`}),e[9]=m):m=e[9];let h;e[10]===p?h=e[11]:(h=(0,$.jsx)(be,{openOnHover:!0,delay:180,closeDelay:200,render:p,children:m}),e[10]=p,e[11]=h);let g;e[12]===t?g=e[13]:(g=t(`settings.remoteInstances.quick.title`),e[12]=t,e[13]=g);let _;e[14]===g?_=e[15]:(_=(0,$.jsx)(Oe,{className:`typography-ui-label font-medium`,children:g}),e[14]=g,e[15]=_);let v;e[16]===l.data?v=e[17]:(v=l.data&&l.data.length>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:l.data.length}):null,e[16]=l.data,e[17]=v);let y;e[18]!==_||e[19]!==v?(y=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 pb-2 pt-4`,children:[_,v]}),e[18]=_,e[19]=v,e[20]=y):y=e[20];let b;e[21]!==l.isPending||e[22]!==t?(b=l.isPending?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`common.loading`)}):null,e[21]=l.isPending,e[22]=t,e[23]=b):b=e[23];let x;e[24]!==l.isError||e[25]!==t?(x=l.isError?(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:t(`settings.remoteInstances.quick.error`)}):null,e[24]=l.isError,e[25]=t,e[26]=x):x=e[26];let S;e[27]!==l.data?.length||e[28]!==l.isError||e[29]!==t?(S=!l.isError&&l.data?.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-5 pb-5 pt-6 text-center`,children:[(0,$.jsx)(X,{name:`devices-connected`,className:`mb-4 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:t(`settings.remoteInstances.clientAuth.state.empty`)}),(0,$.jsx)(`p`,{className:`mt-2 typography-meta leading-relaxed text-muted-foreground`,children:t(`settings.remoteInstances.quick.emptyHint`)})]}):null,e[27]=l.data?.length,e[28]=l.isError,e[29]=t,e[30]=S):S=e[30];let C;e[31]!==l.data||e[32]!==t?(C=l.data?.map(e=>{let n=e.devicePlatform?.toLowerCase();return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl px-3 py-2.5`,children:[(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center text-muted-foreground`,children:(0,$.jsx)(X,{name:n===`ios`?`device-ios`:n===`android`?`device-android`:`device-desktop`,className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`truncate typography-ui-label`,children:e.label}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro text-[var(--status-success)]`,children:t(`desktopHostSwitcher.status.connected`)})]})]},e.id)}),e[31]=l.data,e[32]=t,e[33]=C):C=e[33];let w;e[34]!==b||e[35]!==x||e[36]!==S||e[37]!==C?(w=(0,$.jsxs)(`div`,{className:`max-h-64 space-y-2 overflow-y-auto px-3 pb-2`,"aria-live":`polite`,children:[b,x,S,C]}),e[34]=b,e[35]=x,e[36]=S,e[37]=C,e[38]=w):w=e[38];let T;e[39]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`add`,className:`size-4`}),e[39]=T):T=e[39];let E;e[40]===t?E=e[41]:(E=t(`settings.remoteInstances.clientAuth.actions.addDevice`),e[40]=t,e[41]=E);let D;e[42]!==d||e[43]!==E?(D=(0,$.jsx)(`div`,{className:`px-3 pb-3 pt-1`,children:(0,$.jsxs)(q,{variant:`secondary`,size:`sm`,className:`w-full justify-center gap-2 rounded-xl`,onClick:d,children:[T,E]})}),e[42]=d,e[43]=E,e[44]=D):D=e[44];let O;e[45]!==y||e[46]!==w||e[47]!==D?(O=(0,$.jsx)(ke,{children:(0,$.jsx)(Se,{side:`top`,align:`start`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(Ae,{className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[y,w,D]})})}),e[45]=y,e[46]=w,e[47]=D,e[48]=O):O=e[48];let k;return e[49]!==r||e[50]!==O||e[51]!==h?(k=(0,$.jsxs)(ge,{open:r,onOpenChange:i,children:[h,O]}),e[49]=r,e[50]=O,e[51]=h,e[52]=k):k=e[52],k}function jy(e){let t=(0,Q.c)(11),{task:n}=e,r=n.total>0?Math.min(99,Math.floor(Math.max(0,n.completed)/n.total*100)):void 0,i=`inline-flex size-4 shrink-0 ${n.failed?`text-[var(--status-error)]`:``}`,a=`size-full -rotate-90 ${r===void 0&&!n.failed?`motion-safe:animate-spin`:``}`,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,stroke:`currentColor`,strokeOpacity:`0.2`,strokeWidth:`1.5`}),t[0]=o):o=t[0];let s=100-(r??22),c;t[1]===s?c=t[2]:(c=(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,pathLength:`100`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeDasharray:`100`,strokeDashoffset:s,className:`motion-safe:transition-[stroke-dashoffset] motion-safe:duration-300`}),t[1]=s,t[2]=c);let l;t[3]!==a||t[4]!==c?(l=(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,fill:`none`,"aria-hidden":`true`,className:a,children:[o,c]}),t[3]=a,t[4]=c,t[5]=l):l=t[5];let u;return t[6]!==i||t[7]!==l||t[8]!==n.detail||t[9]!==r?(u=(0,$.jsx)(`span`,{role:`progressbar`,"aria-label":n.detail,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,className:i,children:l}),t[6]=i,t[7]=l,t[8]=n.detail,t[9]=r,t[10]=u):u=t[10],u}function My({task:e}){let{t,locale:n}=Nr(),[r,i]=Z.useState(!1),a=Z.useRef(!1),o=_t({mutationFn:async t=>{try{await(t===`dismiss`?e.dismiss?.():e.resume?.())}finally{a.current=!1}},onError:(t,n)=>{n===`resume`&&e.dismiss&&i(!0)},retry:!1}),s=e=>new Intl.NumberFormat(n).format(e),c=e=>new Intl.NumberFormat(n,{minimumFractionDigits:1,maximumFractionDigits:1}).format(e/1e6),l=e.total>0?Math.min(100,Math.max(0,e.completed/e.total*100)):void 0;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1rem_minmax(0,1fr)_auto] items-center gap-x-2.5 gap-y-2 py-2.5`,"data-background-task":e.id,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:(0,$.jsx)(jy,{task:e})}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e.label}),e.detail!==e.label&&(0,$.jsx)(`span`,{className:`break-words typography-micro text-muted-foreground`,children:e.detail})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.detail,"aria-valuenow":l,"aria-valuemin":0,"aria-valuemax":100,className:`my-1.5 h-1 overflow-hidden rounded-full bg-[var(--surface-subtle)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full ${e.failed?`bg-[var(--status-error)]`:`bg-[var(--primary-base)]`} ${l===void 0?e.failed?`w-1/3`:`w-1/3 motion-safe:animate-pulse`:`motion-safe:transition-[width] motion-safe:duration-300`}`,style:l===void 0?void 0:{width:`${l}%`}})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2 typography-micro tabular-nums text-muted-foreground`,"data-background-task-meta":!0,children:[e.bytes?(0,$.jsx)(`span`,{children:t(e.total>0?`backgroundTasks.downloaded`:`backgroundTasks.downloadedUnknownTotal`,{completed:c(e.completed),total:c(e.total)})}):e.total>0&&!e.hideCounts&&(0,$.jsx)(`span`,{"aria-label":t(`backgroundTasks.processed`,{completed:s(e.completed),total:s(e.total)}),children:`${s(e.completed)} / ${s(e.total)}`}),!!e.failures&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:t(`backgroundTasks.failedCount`,{count:s(e.failures)})})]})]}),e.failed&&e.resume&&(0,$.jsx)(q,{size:`xs`,className:`shrink-0`,disabled:o.isPending,onClick:()=>{a.current||(a.current=!0,o.mutate(r?`dismiss`:`resume`))},children:t(r?o.isPending?`backgroundTasks.removing`:`backgroundTasks.dismiss`:o.isPending?`backgroundTasks.resuming`:`backgroundTasks.resume`)}),e.stale&&(0,$.jsx)(`p`,{className:`col-span-2 col-start-2 typography-micro text-muted-foreground`,children:t(`backgroundTasks.progressUnavailable`)}),o.isError&&(0,$.jsx)(`p`,{role:`alert`,className:`col-span-2 col-start-2 typography-micro text-[var(--status-error)]`,children:t(o.variables===`dismiss`?`backgroundTasks.dismissFailed`:o.error.message===`update_plan_changed`?`backgroundTasks.updateChanged`:o.error.message===`resume_request_missing`?`backgroundTasks.originalSelectionMissing`:`backgroundTasks.resumeFailed`)})]})}var Ny=Z.memo(function(e){let t=(0,Q.c)(4),{compactWithRestart:n}=e,r=n!==void 0&&n,i=Z.useSyncExternalStore(c,d,d),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=u(),t[0]=a):a=t[0];let o=`${a}:${i}`,s;return t[1]!==r||t[2]!==o?(s=(0,$.jsx)(Py,{compactWithRestart:r},o),t[1]=r,t[2]=o,t[3]=s):s=t[3],s});function Py(e){let t=(0,Q.c)(126),{compactWithRestart:n}=e,{t:r,locale:i}=Nr(),[a,o]=Z.useState(!1),s=El(Zy),c=El(Xy),l=El(Yy),f=El(Jy),p=El(qy),m=El(Ky),h=El(Gy),g=u(),_=d(),v=yt({...Kl(g),retry:!1,refetchInterval:Uy}),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y={...Kc(),retry:!1,refetchInterval:Hy},t[0]=y):y=t[0];let b=yt(y),x=Al(g,_),S;t[1]===x?S=t[2]:(S={...x,refetchInterval:Vy},t[1]=x,t[2]=S);let C=yt(S),T;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(T=new Set,t[3]=T):T=t[3];let E=Z.useRef(T),D,O;t[4]!==_||t[5]!==v.data||t[6]!==v.isError||t[7]!==g?(D=()=>{if(!v.data||v.isError)return;let e=new Set(v.data.filter(By).map(zy)),t=[...E.current].some(t=>!e.has(t));E.current=e,t&&g===u()&&_===d()&&ln(g).catch(Ry)},O=[v.data,v.isError,g,_],t[4]=_,t[5]=v.data,t[6]=v.isError,t[7]=g,t[8]=D,t[9]=O):(D=t[8],O=t[9]),Z.useEffect(D,O);let k;if(t[10]!==m||t[11]!==l||t[12]!==h||t[13]!==f||t[14]!==c||t[15]!==s||t[16]!==_||t[17]!==b||t[18]!==v.data||t[19]!==v.isError||t[20]!==r||t[21]!==g||t[22]!==C||t[23]!==p){k=[];for(let e of v.data??[])if(!Ul(e)){let t=ql(e);k.push({id:e.id,label:r(`backgroundTasks.import`),detail:r(e.state===`running`?`historyImport.phase.${t.phase}`:`historyImport.state.${e.state}`),...t,stale:v.isError,failed:e.state!==`running`,failures:e.failures,resume:()=>Wl(e.id,g,_),dismiss:()=>Gl(e.id,g,_)})}if(b.data&&b.data.phase!==`ready`){let e;t[25]===r?e=t[26]:(e=r(`backgroundTasks.index`),t[25]=r,t[26]=e);let n;t[27]===b.data.phase?n=t[28]:(n=[`partial`,`error`].includes(b.data.phase)?`backgroundTasks.indexFailed`:`backgroundTasks.indexing`,t[27]=b.data.phase,t[28]=n);let i;t[29]!==r||t[30]!==n?(i=r(n),t[29]=r,t[30]=n,t[31]=i):i=t[31];let a=b.data.completed,o=b.data.total,s=b.isError,c;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(c=[`partial`,`error`],t[32]=c):c=t[32];let l=c.includes(b.data.phase),u;t[33]!==_||t[34]!==g?(u=()=>hc(g,_),t[33]=_,t[34]=g,t[35]=u):u=t[35];let d;t[36]!==b.data.completed||t[37]!==b.data.failed||t[38]!==b.data.total||t[39]!==b.isError||t[40]!==l||t[41]!==u||t[42]!==e||t[43]!==i?(d={id:`content-index`,label:e,detail:i,completed:a,total:o,stale:s,failed:l,failures:b.data.failed,resume:u},t[36]=b.data.completed,t[37]=b.data.failed,t[38]=b.data.total,t[39]=b.isError,t[40]=l,t[41]=u,t[42]=e,t[43]=i,t[44]=d):d=t[44],k.push(d)}if(s||l){let e;t[45]===r?e=t[46]:(e=r(`backgroundTasks.download`),t[45]=r,t[46]=e);let n=l?`backgroundTasks.downloadFailed`:`updateDialog.status.downloading`,i;t[47]!==r||t[48]!==n?(i=r(n),t[47]=r,t[48]=n,t[49]=i):i=t[49];let a=!!l,o;t[50]!==m||t[51]!==h||t[52]!==a||t[53]!==e||t[54]!==i?(o={id:`client-update`,label:e,detail:i,completed:m,total:h,stale:!1,bytes:!0,failed:a,resume:Ly},t[50]=m,t[51]=h,t[52]=a,t[53]=e,t[54]=i,t[55]=o):o=t[55],k.push(o)}let e=C.data?.operation,n=C.data,i=e?.status===`failed`&&!!n&&!n.checkError&&n.update!==void 0&&n.channel===e.channel&&(n.update?.version!==e.version||n.update.kind!==e.kind);if(e&&!i&&(kl(e)||e.status===`failed`)&&!((s||l||c&&kl(e))&&e.version===(f??p)&&w())){let n=e.id,i;t[56]===r?i=t[57]:(i=r(`backgroundTasks.download`),t[56]=r,t[57]=i);let a=e.status===`failed`?`backgroundTasks.downloadFailed`:e.status===`installing`?`updateDialog.status.installingUpdate`:e.status===`restarting`?`updateDialog.status.serverRestarting`:e.status===`checking`?`updateDialog.status.updating`:`updateDialog.status.downloading`,o;t[58]!==r||t[59]!==a?(o=r(a),t[58]=r,t[59]=a,t[60]=o):o=t[60];let s=`${o} · ${e.version}`,c=e.progress??0,l=e.progress==null?0:100,u=e.status===`failed`,d;t[61]!==_||t[62]!==e||t[63]!==g?(d=()=>Ol(e,g,_),t[61]=_,t[62]=e,t[63]=g,t[64]=d):d=t[64];let f;t[65]!==e.id||t[66]!==s||t[67]!==c||t[68]!==l||t[69]!==u||t[70]!==d||t[71]!==i||t[72]!==C.isError?(f={id:n,label:i,detail:s,completed:c,total:l,stale:C.isError,hideCounts:!0,failed:u,resume:d},t[65]=e.id,t[66]=s,t[67]=c,t[68]=l,t[69]=u,t[70]=d,t[71]=i,t[72]=C.isError,t[73]=f):f=t[73],k.push(f)}t[10]=m,t[11]=l,t[12]=h,t[13]=f,t[14]=c,t[15]=s,t[16]=_,t[17]=b,t[18]=v.data,t[19]=v.isError,t[20]=r,t[21]=g,t[22]=C,t[23]=p,t[24]=k}else k=t[24];if(!k.length&&!a)return null;let A;t[74]===i?A=t[75]:(A=e=>new Intl.NumberFormat(i).format(e),t[74]=i,t[75]=A);let j=A,M=`w-fit min-w-0 shrink text-muted-foreground/60 ${k.length?``:`invisible`}`,N=k.length?``:void 0,P=n&&c&&k.length===1?`icon`:`xs`,F;t[76]===r?F=t[77]:(F=r(`backgroundTasks.title`),t[76]=r,t[77]=F);let I;t[78]!==n||t[79]!==c||t[80]!==r||t[81]!==k[0]||t[82]!==k.length?(I=n&&c?k.length===1?k[0].label:r(`backgroundTasks.title`):void 0,t[78]=n,t[79]=c,t[80]=r,t[81]=k[0],t[82]=k.length,t[83]=I):I=t[83];let L=`max-w-full gap-2 text-[10px] font-normal text-muted-foreground/60 ${n&&c&&k.length===1?`size-7 rounded-md`:``}`,R;t[84]!==P||t[85]!==F||t[86]!==I||t[87]!==L?(R=(0,$.jsx)(q,{variant:`ghost`,size:P,"aria-label":F,title:I,className:L}),t[84]=P,t[85]=F,t[86]=I,t[87]=L,t[88]=R):R=t[88];let z;t[89]===k?z=t[90]:(z=k.map(Iy),t[89]=k,t[90]=z);let ee;t[91]!==n||t[92]!==c||t[93]!==k[0]||t[94]!==k.length?(ee=k.length===1&&!(n&&c)&&(0,$.jsx)(`span`,{className:`truncate`,children:k[0].label}),t[91]=n,t[92]=c,t[93]=k[0],t[94]=k.length,t[95]=ee):ee=t[95];let B;t[96]!==R||t[97]!==z||t[98]!==ee?(B=(0,$.jsxs)(be,{render:R,children:[z,ee]}),t[96]=R,t[97]=z,t[98]=ee,t[99]=B):B=t[99];let te;t[100]!==B||t[101]!==M||t[102]!==N?(te=(0,$.jsx)(`div`,{className:M,"data-sidebar-background-tasks":N,children:B}),t[100]=B,t[101]=M,t[102]=N,t[103]=te):te=t[103];let ne;t[104]===r?ne=t[105]:(ne=r(`backgroundTasks.title`),t[104]=r,t[105]=ne);let re;t[106]===ne?re=t[107]:(re=(0,$.jsx)(Oe,{className:`typography-micro font-medium text-muted-foreground`,children:ne}),t[106]=ne,t[107]=re);let ie;t[108]!==j||t[109]!==k.length?(ie=k.length>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground tabular-nums`,children:j(k.length)}),t[108]=j,t[109]=k.length,t[110]=ie):ie=t[110];let ae;t[111]!==re||t[112]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pb-1 pt-3`,children:[re,ie]}),t[111]=re,t[112]=ie,t[113]=ae):ae=t[113];let oe;t[114]!==r||t[115]!==k?(oe=k.length?k.map(Fy):(0,$.jsx)(`p`,{className:`px-2 py-3 typography-meta text-muted-foreground`,children:r(`backgroundTasks.empty`)}),t[114]=r,t[115]=k,t[116]=oe):oe=t[116];let V;t[117]===oe?V=t[118]:(V=(0,$.jsx)(`div`,{className:`max-h-64 divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] overflow-y-auto px-3 pb-1`,"data-background-task-details":!0,children:oe}),t[117]=oe,t[118]=V);let H;t[119]!==ae||t[120]!==V?(H=(0,$.jsx)(ke,{children:(0,$.jsx)(Se,{side:`top`,align:`center`,sideOffset:10,className:`z-50`,children:(0,$.jsxs)(Ae,{initialFocus:!1,className:`yuri-mobile-overlay-surface yuri-popup-surface w-72 max-w-[calc(100vw-24px)] origin-[var(--transform-origin)] overflow-hidden rounded-2xl outline-none transition-[opacity,transform] duration-150 data-[starting-style]:translate-y-1 data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`,children:[ae,V]})})}),t[119]=ae,t[120]=V,t[121]=H):H=t[121];let se;return t[122]!==a||t[123]!==te||t[124]!==H?(se=(0,$.jsxs)(ge,{open:a,onOpenChange:o,children:[te,H]}),t[122]=a,t[123]=te,t[124]=H,t[125]=se):se=t[125],se}function Fy(e){return(0,$.jsx)(My,{task:e},e.id)}function Iy(e){return(0,$.jsx)(jy,{task:e},e.id)}async function Ly(){if(await El.getState().downloadUpdate({resume:!0}),El.getState().downloadError)throw Error(El.getState().downloadError)}function Ry(){}function zy(e){return e.id}function By(e){return e.state===`running`}function Vy(e){return kl(e.state.data?.operation)?2e3:e.state.error?.message!==`host_update_unsupported`&&15e3}function Hy(e){return e.state.data===null?!1:e.state.data?.phase===`indexing`||e.state.data?.phase===`pending`?3e3:15e3}function Uy(e){return e.state.error?.message===`history_import_unsupported`?!1:e.state.data?.some(Wy)?1e3:15e3}function Wy(e){return e.state===`running`}function Gy(e){return e.progress?.total??0}function Ky(e){return e.progress?.downloaded??0}function qy(e){return e.info?.version}function Jy(e){return e.downloadVersion}function Yy(e){return e.downloadError}function Xy(e){return e.downloaded}function Zy(e){return e.downloading}var Qy=`group size-7 rounded-md text-muted-foreground/75 transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary`,$y=`size-4 text-foreground/55 transition-colors group-hover:text-foreground group-focus-visible:text-foreground`;function eb(e){let t=(0,Q.c)(32),{onOpenUpdate:n,hideDownload:r}=e,{t:i}=Nr(),a=El(ab),o=El(ib),s=El(rb),c=El(nb),l=El(tb),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=[`update`,`restart-to-apply`],t[0]=u):u=t[0];let d;t[1]===c?d=t[2]:(d={mutationKey:u,mutationFn:()=>c(),retry:!1,networkMode:`always`},t[1]=c,t[2]=d);let f=_t(d),p=f.isPending,m=Z.useRef(!1),h;t[3]!==o||t[4]!==n||t[5]!==f||t[6]!==p?(h=()=>{if(o&&!p){if(m.current)return;m.current=!0,f.mutate();return}n()},t[3]=o,t[4]=n,t[5]=f,t[6]=p,t[7]=h):h=t[7];let g=G(h),_;t[8]!==o||t[9]!==a||t[10]!==s||t[11]!==p||t[12]!==i?(_=s||i(a?`updateDialog.status.downloading`:p?`updateDialog.status.updating`:o?`sessions.sidebar.footer.actions.restartUpdate`:`sessions.sidebar.footer.actions.update`),t[8]=o,t[9]=a,t[10]=s,t[11]=p,t[12]=i,t[13]=_):_=t[13];let v=_;if(r&&a)return null;let y=p||void 0,b;t[14]!==o||t[15]!==a||t[16]!==l||t[17]!==p||t[18]!==v?(b=o?(0,$.jsx)(X,{name:`restart`,className:`${$y} ${p?`motion-safe:animate-spin`:``}`}):a?(0,$.jsxs)(`svg`,{viewBox:`0 0 18 18`,className:l===null?`size-4 animate-spin`:`size-4 -rotate-90`,role:`progressbar`,"aria-label":v,"aria-valuenow":l??void 0,"aria-valuemin":0,"aria-valuemax":100,children:[(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.25`,strokeWidth:`2`}),(0,$.jsx)(`circle`,{cx:`9`,cy:`9`,r:`7.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,pathLength:`100`,strokeDasharray:`100`,strokeDashoffset:100-(l===null?25:Math.max(0,Math.min(100,l))),className:`transition-[stroke-dashoffset] duration-300`})]}):(0,$.jsx)(X,{name:`download`,className:$y}),t[14]=o,t[15]=a,t[16]=l,t[17]=p,t[18]=v,t[19]=b):b=t[19];let x;t[20]!==g||t[21]!==p||t[22]!==y||t[23]!==b||t[24]!==v?(x=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:`${Qy} disabled:opacity-100`,onClick:g,disabled:p,"aria-busy":y,"aria-label":v,children:b})}),t[20]=g,t[21]=p,t[22]=y,t[23]=b,t[24]=v,t[25]=x):x=t[25];let S=a&&l!==null?` ${l}%`:``,C;t[26]!==S||t[27]!==v?(C=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsxs)(`p`,{children:[v,S]})}),t[26]=S,t[27]=v,t[28]=C):C=t[28];let w;return t[29]!==x||t[30]!==C?(w=(0,$.jsxs)(ni,{children:[x,C]}),t[29]=x,t[30]=C,t[31]=w):w=t[31],w}function tb(e){return e.progress?.total?Math.round(e.progress.downloaded/e.progress.total*100):null}function nb(e){return e.restartToUpdate}function rb(e){return e.error}function ib(e){return e.downloaded}function ab(e){return e.downloading}function ob(e){let t=(0,Q.c)(19),{onOpenSettings:n,onOpenShortcuts:r,onOpenUpdate:i,showRuntimeButtons:a,showUpdateButton:o}=e,s=a===void 0||a,c=o!==void 0&&o,{t:l}=Nr(),u;t[0]!==n||t[1]!==r||t[2]!==s||t[3]!==l?(u=s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:Qy,onClick:n,"aria-label":l(`sessions.sidebar.footer.actions.settings`),children:(0,$.jsx)(X,{name:`settings-3`,className:$y})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.settings`)})]}),(0,$.jsx)(Ay,{}),(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{type:`button`,variant:`ghost`,size:`icon`,className:Qy,onClick:r,"aria-label":l(`sessions.sidebar.footer.actions.shortcuts`),children:(0,$.jsx)(X,{name:`question`,className:$y})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:l(`sessions.sidebar.footer.actions.shortcuts`)})]})]}):null,t[0]=n,t[1]=r,t[2]=s,t[3]=l,t[4]=u):u=t[4];let d;t[5]!==i||t[6]!==s||t[7]!==c?(d=s?(0,$.jsx)(Ny,{compactWithRestart:!!(c&&i)}):null,t[5]=i,t[6]=s,t[7]=c,t[8]=d):d=t[8];let f;t[9]!==i||t[10]!==s||t[11]!==c?(f=c&&i?(0,$.jsx)(eb,{onOpenUpdate:i,hideDownload:s}):null,t[9]=i,t[10]=s,t[11]=c,t[12]=f):f=t[12];let p;t[13]!==d||t[14]!==f?(p=(0,$.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-1`,children:[d,f]}),t[13]=d,t[14]=f,t[15]=p):p=t[15];let m;return t[16]!==u||t[17]!==p?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-start gap-1 px-2.5 py-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18],m}var sb=1/3,cb=1,lb=({containerScrollTop:e,containerClientHeight:t,containerScrollHeight:n,rowOffsetFromViewportTop:r})=>{let i=e+(r-t*sb),a=Math.max(0,n-t);return Math.min(a,Math.max(0,i))},ub=()=>typeof window>`u`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`,db=e=>{let t=e.closest(`.overlay-scrollbar-target`);if(t)return t;let n=e.parentElement;for(;n&&n!==document.body;){let e=window.getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`||e===`overlay`)return n;n=n.parentElement}return null},fb=(e,t)=>{let n=db(e),r=t?.behavior??ub();if(!n){e.scrollIntoView({block:`nearest`,inline:`nearest`,behavior:r});return}let i=e.getBoundingClientRect(),a=n.getBoundingClientRect().top+n.clientTop,o=a+n.clientHeight;if(i.top>=a&&i.bottom<=o)return;let s=lb({containerScrollTop:n.scrollTop,containerClientHeight:n.clientHeight,containerScrollHeight:n.scrollHeight,rowOffsetFromViewportTop:i.top-a});Math.abs(s-n.scrollTop)<cb||n.scrollTo({top:s,behavior:r})},pb={activationConstraint:{distance:8}},mb={coordinateGetter:Cs},hb=e=>{let t=(0,Q.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(ti,{delay:0,closeDelay:150,timeout:600,children:n}),t[0]=n,t[1]=r),r};function gb(e){let{t}=Nr(),n=new Map((e.remoteProjects??[]).map(e=>[e.id,e])),r=(e.remoteProjects??[]).map(e=>({project:{id:e.id,hostId:e.hostId,normalizedPath:e.path},groups:[]})),i=[...e.sectionsForRender,...r];if(e.projectOrderIds?.length){let t=new Map(e.projectOrderIds.map((e,t)=>[e,t]));i.sort((e,n)=>(t.get(e.project.id)??1/0)-(t.get(n.project.id)??1/0))}let a=r=>{let i=n.get(r);return i?e.hostRegistry?(0,$.jsx)(hl,{project:i,registry:e.hostRegistry,search:e.remoteSearch,mobile:e.mobileVariant,reorderEnabled:e.projectReorderEnabled,onNavigationTargets:e.onRemoteNavigationTargets,onActivityItems:e.onRemoteActivityItems},r):(0,$.jsxs)(`div`,{className:`px-2 py-1 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`span`,{children:[i.label||i.path,` · `,i.hostId]}),(0,$.jsx)(`p`,{role:e.remoteError?`alert`:`status`,children:e.remoteError||t(Tr()?`remoteProjects.state.connecting`:`remoteProjects.unsupported`)})]},r):null},o=Ss(gs(bs,pb),gs(_s,mb)),s=e.hasSessionSearchQuery?null:(0,$.jsx)(_y,{title:t(`sessions.sidebar.projectsTitle`),titleSlot:e.headerSwitch,isFirst:!e.hasLeadingSection,accessory:e.headerAccessory}),c=Z.useRef(null),l=Z.useRef(null);Z.useLayoutEffect(()=>{let t=e.projectRevealTarget;if(!t){l.current=null;return}if(e.mobileVariant||e.showOnlyMainWorkspace||e.hasSessionSearchQuery)return;let n=l.current;if(n?.projectId===t.projectId&&n.revision===t.revision)return;let r=c.current?.querySelector(`[data-sidebar-project-header="${CSS.escape(t.projectId)}"]`);r&&(l.current=t,fb(r))},[e.projectRevealTarget,e.mobileVariant,e.showOnlyMainWorkspace,e.hasSessionSearchQuery,e.sectionsForRender]);let u=Z.useRef(new Map),d=Z.useRef(e.getOrderedGroups);d.current!==e.getOrderedGroups&&(d.current=e.getOrderedGroups,u.current.clear());let f=(t,n)=>{let r=u.current,i=r.get(t);if(i&&i.groups===n)return i.ordered;let a=e.getOrderedGroups(t,n);if(r.set(t,{groups:n,ordered:a}),r.size>256){let e=r.keys().next().value;e!==void 0&&r.delete(e)}return a};return e.sharedSessionsOnly?(0,$.jsx)(hb,{children:(0,$.jsxs)(Wr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,e.tabLeadingContent,e.hasSharedSessions?null:e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState]})}):e.taskContent?(0,$.jsxs)(hb,{children:[(0,$.jsxs)(Wr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,s,e.tabLeadingContent,e.taskContent]}),e.taskFooter]}):e.projectSections.length===0&&r.length===0?(0,$.jsx)(hb,{children:(0,$.jsxs)(Wr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:[e.topContent,s,e.tabLeadingContent,e.emptyState]})}):i.length===0?(0,$.jsx)(hb,{children:(0,$.jsx)(Wr,{useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1`,(e.mobileVariant,``)),children:e.searchEmptyState})}):(0,$.jsx)(hb,{children:(0,$.jsxs)(Wr,{ref:c,useScrollShadow:!0,scrollShadowSize:96,outerClassName:`flex-1 min-h-0`,className:J(`space-y-1 px-3 pb-1 [overflow-anchor:none]`,(e.mobileVariant,``)),children:[e.topContent,e.showOnlyMainWorkspace?(0,$.jsx)(`div`,{className:`space-y-[0.6rem] py-1`,children:(()=>{let r=i.find(t=>t.project.id===e.activeProjectId)??i[0];if(!r)return e.hasSessionSearchQuery?e.searchEmptyState:e.emptyState;if(n.has(r.project.id))return a(r.project.id);let o=r.groups.find(e=>e.isMain&&e.sessions.length>0)??r.groups.find(e=>e.sessions.length>0)??r.groups.find(e=>e.isMain)??r.groups[0];if(!o)return(0,$.jsx)(`div`,{className:ko,children:t(`sessions.sidebar.empty.noSessions.title`)});let s=r.groups.find(e=>e.isArchivedBucket);return[o,...s&&s.id!==o.id?[s]:[]].map(t=>{let n=`${r.project.id}:${t.id}`,i=t.id===o.id;return(0,$.jsx)(Z.Fragment,{children:e.renderGroupSessions(t,n,r.project.id,i,null,!0,c)},n)})})()}):(0,$.jsxs)($.Fragment,{children:[s,e.tabLeadingContent,(0,$.jsxs)(xs,{sensors:o,collisionDetection:vs,onDragEnd:t=>{if(e.isInlineEditing||e.projectSortOrder!==`manual`)return;let{active:n,over:r}=t;!r||n.id===r.id||e.reorderProjects(String(n.id),String(r.id))},children:[(0,$.jsx)(Es,{items:i.map(e=>e.project.id),strategy:Ts,children:i.map(t=>{let r=t.project,i=r.id;return n.has(i)?a(i):(0,$.jsx)(_b,{project:r,orderedGroups:f(i,t.groups),isCollapsed:e.collapsedProjects.has(i),isActiveProject:i===e.activeProjectId,isRepo:!!e.projectRepoStatus.get(i),hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,toggleProject:e.toggleProject,setActiveProjectIdOnly:e.setActiveProjectIdOnly,setActiveMainTab:e.setActiveMainTab,setSessionSwitcherOpen:e.setSessionSwitcherOpen,openNewSessionDraft:e.openNewSessionDraft,openNewWorktreeDialog:e.openNewWorktreeDialog,syncProjectSessions:e.syncProjectSessions,openProjectEditDialog:e.openProjectEditDialog,removeProject:e.removeProject,openSidebarMenuKey:e.openSidebarMenuKey===`project:${i}`?e.openSidebarMenuKey:null,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,projectReorderEnabled:e.projectReorderEnabled,projectSortOrder:e.projectSortOrder,isInlineEditing:e.isInlineEditing,setGroupOrderByProject:e.setGroupOrderByProject,renderGroupSessions:e.renderGroupSessions,scrollContainerRef:c,homeDirectory:e.homeDirectory,hostRegistry:e.hostRegistry},i)})}),(0,$.jsx)(ys,{dropAnimation:null})]})]})]})})}var _b=Z.memo(function(e){let t=(0,Q.c)(111),{t:n}=Nr(),{project:r,orderedGroups:i,isCollapsed:a,renderGroupSessions:o,scrollContainerRef:s,isInlineEditing:c}=e,l=r.id,u;t[0]===r.normalizedPath?u=t[1]:(u=e=>E()?void 0:e.availableWorktreesByProject.get(r.normalizedPath),t[0]=r.normalizedPath,t[1]=u);let d=Vn(u),f;t[2]!==r.normalizedPath||t[3]!==d?(f=[r.normalizedPath,...(d??[]).flatMap(vb)],t[2]=r.normalizedPath,t[3]=d,t[4]=f):f=t[4];let p=f,m;t[5]===p?m=t[6]:(m=e=>p.some(t=>e.loadingDirectories.has(t)),t[5]=p,t[6]=m);let h=on(m),g;t[7]===p?g=t[8]:(g=e=>p.some(t=>e.refreshingDirectories.has(t)),t[7]=p,t[8]=g);let _=on(g),v=Ss(gs(bs,pb)),y;t[9]===i?y=t[10]:(y=i.find(yb)??null,t[9]=i,t[10]=y);let b=y,x;t[11]!==i||t[12]!==b?(x=b?i.filter(e=>e.id!==b.id):i,t[11]=i,t[12]=b,t[13]=x):x=t[13];let S=x,C;t[14]!==l||t[15]!==e?(C=()=>e.toggleProject(l),t[14]=l,t[15]=e,t[16]=C):C=t[16];let w=G(C),T;t[17]!==r.normalizedPath||t[18]!==l||t[19]!==e?(T=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.mobileVariant&&e.setSessionSwitcherOpen(!1),e.openNewSessionDraft({directoryOverride:r.normalizedPath})},t[17]=r.normalizedPath,t[18]=l,t[19]=e,t[20]=T):T=t[20];let D=G(T),O;t[21]!==l||t[22]!==e?(O=()=>{e.isActiveProject||e.setActiveProjectIdOnly(l),e.setActiveMainTab(`chat`),e.openNewWorktreeDialog()},t[21]=l,t[22]=e,t[23]=O):O=t[23];let k=G(O),A;t[24]!==l||t[25]!==e?(A=()=>e.syncProjectSessions(l),t[24]=l,t[25]=e,t[26]=A):A=t[26];let j=G(A),M;t[27]!==l||t[28]!==e?(M=()=>e.openProjectEditDialog(l),t[27]=l,t[28]=e,t[29]=M):M=t[29];let N=G(M),P;t[30]!==l||t[31]!==e?(P=()=>e.removeProject(l),t[30]=l,t[31]=e,t[32]=P):P=t[32];let F=G(P),I;t[33]!==c||t[34]!==S||t[35]!==r.normalizedPath||t[36]!==l||t[37]!==e||t[38]!==b?(I=t=>{if(c)return;let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=S.findIndex(e=>e.id===n.id),o=S.findIndex(e=>e.id===i.id);if(a===-1||o===-1||a===o)return;let s=ws(S,a,o).map(bb),u=b?[b.id,...s]:s,d=new Map(S.map(xb));pn.getState().setWorktreeOrder(l,r.normalizedPath,s.flatMap(e=>{let t=d.get(e);return t?.worktree&&t.directory?[t.directory]:[]})),e.setGroupOrderByProject(e=>new Map(e).set(l,u))},t[33]=c,t[34]=S,t[35]=r.normalizedPath,t[36]=l,t[37]=e,t[38]=b,t[39]=I):I=t[39];let L=G(I),R;t[40]!==l||t[41]!==o||t[42]!==b||t[43]!==s?(R=b?o(b,`${l}:${b.id}`,l,!0,null,void 0,s):null,t[40]=l,t[41]=o,t[42]=b,t[43]=s,t[44]=R):R=t[44];let z;t[45]===S?z=t[46]:(z=S.map(Sb),t[45]=S,t[46]=z);let ee;if(t[47]!==c||t[48]!==S||t[49]!==l||t[50]!==o||t[51]!==s){let e;t[53]!==c||t[54]!==l||t[55]!==o||t[56]!==s?(e=e=>(0,$.jsx)(Cc,{id:e.id,disabled:c,children:t=>o(e,`${l}:${e.id}`,l,!1,t,void 0,s)},e.id),t[53]=c,t[54]=l,t[55]=o,t[56]=s,t[57]=e):e=t[57],ee=S.map(e),t[47]=c,t[48]=S,t[49]=l,t[50]=o,t[51]=s,t[52]=ee}else ee=t[52];let B;t[58]!==z||t[59]!==ee?(B=(0,$.jsx)(Es,{items:z,strategy:Ts,children:ee}),t[58]=z,t[59]=ee,t[60]=B):B=t[60];let te;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(ys,{dropAnimation:null}),t[61]=te):te=t[61];let ne;t[62]!==v||t[63]!==L||t[64]!==R||t[65]!==B?(ne=(0,$.jsxs)(xs,{sensors:v,collisionDetection:vs,onDragEnd:L,children:[R,B,te]}),t[62]=v,t[63]=L,t[64]=R,t[65]=B,t[66]=ne):ne=t[66];let re=ne,ie=e.projectSortOrder!==`manual`,ae=r.hostId,oe=r.remoteState,V=e.hostRegistry,H;t[67]===r.normalizedPath?H=t[68]:(H=cr(r.normalizedPath)||r.normalizedPath,t[67]=r.normalizedPath,t[68]=H);let se;t[69]!==r.normalizedPath||t[70]!==e.homeDirectory?(se=Kn(r.normalizedPath,e.homeDirectory),t[69]=r.normalizedPath,t[70]=e.homeDirectory,t[71]=se):se=t[71];let U=h||_,ce=e.projectReorderEnabled??!1,le=!a,ue=a||void 0,de;t[72]!==re||t[73]!==h||t[74]!==i.length||t[75]!==n?(de=(0,$.jsx)(`div`,{className:`space-y-0 pt-0 pb-0.5`,children:i.length>0?re:h?(0,$.jsx)(`div`,{className:`box-border w-full py-1.5 text-left typography-ui-label font-normal text-muted-foreground/80 animate-pulse select-none`,style:{paddingLeft:Ao(1)},role:`status`,"aria-live":`polite`,children:n(`sessions.sidebar.project.loadingSessions`)}):(0,$.jsx)(`div`,{className:ko,children:n(`sessions.sidebar.empty.noSessions.title`)})}),t[72]=re,t[73]=h,t[74]=i.length,t[75]=n,t[76]=de):de=t[76];let fe;t[77]!==ue||t[78]!==de?(fe=(0,$.jsx)(ki,{"data-sidebar-collapse":!0,className:`h-[var(--collapsible-panel-height)] transition-[height] duration-200 ease-out data-[starting-style]:h-0 data-[ending-style]:h-0 data-[open]:animate-none data-[closed]:animate-none motion-reduce:transition-none`,inert:ue,children:de}),t[77]=ue,t[78]=de,t[79]=fe):fe=t[79];let pe;t[80]!==le||t[81]!==fe?(pe=(0,$.jsx)(ji,{open:le,children:fe}),t[80]=le,t[81]=fe,t[82]=pe):pe=t[82];let me;return t[83]!==a||t[84]!==F||t[85]!==D||t[86]!==k||t[87]!==N||t[88]!==j||t[89]!==w||t[90]!==r.color||t[91]!==r.hostId||t[92]!==r.icon||t[93]!==r.iconImage||t[94]!==r.remoteState||t[95]!==l||t[96]!==e.alwaysShowActions||t[97]!==e.hideDirectoryControls||t[98]!==e.hostRegistry||t[99]!==e.isActiveProject||t[100]!==e.isRepo||t[101]!==e.mobileVariant||t[102]!==e.openSidebarMenuKey||t[103]!==e.setOpenSidebarMenuKey||t[104]!==ie||t[105]!==H||t[106]!==se||t[107]!==U||t[108]!==ce||t[109]!==pe?(me=(0,$.jsx)(Oc,{id:l,disabled:ie,hostId:ae,remoteState:oe,hostRegistry:V,projectLabel:H,projectDescription:se,projectIcon:r.icon,projectColor:r.color,projectIconImage:r.iconImage,isCollapsed:a,isActiveProject:e.isActiveProject,isSessionsLoading:U,isRepo:e.isRepo,hideDirectoryControls:e.hideDirectoryControls,mobileVariant:e.mobileVariant,alwaysShowActions:e.alwaysShowActions,onToggle:w,onNewSession:D,onNewWorktreeSession:k,onSyncSessions:j,onRenameStart:N,onClose:F,showCreateButtons:!0,openSidebarMenuKey:e.openSidebarMenuKey,setOpenSidebarMenuKey:e.setOpenSidebarMenuKey,reorderEnabled:ce,children:pe}),t[83]=a,t[84]=F,t[85]=D,t[86]=k,t[87]=N,t[88]=j,t[89]=w,t[90]=r.color,t[91]=r.hostId,t[92]=r.icon,t[93]=r.iconImage,t[94]=r.remoteState,t[95]=l,t[96]=e.alwaysShowActions,t[97]=e.hideDirectoryControls,t[98]=e.hostRegistry,t[99]=e.isActiveProject,t[100]=e.isRepo,t[101]=e.mobileVariant,t[102]=e.openSidebarMenuKey,t[103]=e.setOpenSidebarMenuKey,t[104]=ie,t[105]=H,t[106]=se,t[107]=U,t[108]=ce,t[109]=pe,t[110]=me):me=t[110],me});function vb(e){let t=P(e.path);return t?[t]:[]}function yb(e){return e.isMain}function bb(e){return e.id}function xb(e){return[e.id,e]}function Sb(e){return e.id}function Cb(e){if(typeof e!=`number`||!Number.isFinite(e))return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:`${t.toLocaleString(jr(),{month:`short`})} ${t.getDate()}, ${t.getFullYear()}, ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function wb(e){if(e.info.role===`user`)return``;let t=typeof e.info.providerID==`string`?e.info.providerID.trim():``,n=typeof e.info.modelID==`string`?e.info.modelID.trim():``;return t&&n?`${t}/${n}`:n||t}function Tb(e){let t=e.info.role===`user`?`User`:`Assistant`,n=Cb(e.info.time?.created),r=wb(e),i=n&&r?`${n} (${r})`:n||r;return i?`**${t}**\n\n*${i}*`:`**${t}**`}function Eb(e){return e.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``)}function Db(e){let t=Tb(e),n=Eb(e.parts).trim();return n?`${t}\n\n${n}`:``}function Ob(e,t){let n=`#`.repeat(Math.min(t+1,6)),r=e.agent?` — ${e.agent}`:``,i=[`${n} Sub-agent: ${e.title}${r}\n\n---\n\n`+e.records.map(Db).filter(Boolean).join(`
147
+
148
+ ---
149
+
150
+ `)];for(let n of e.children)i.push(Ob(n,t+1));return i.join(`
151
+
152
+ ---
153
+
154
+ `)}function kb(e,t,n){let r=`# ${t?.trim()||`Session`}\n\n*Exported on ${new Date().toISOString().split(`T`)[0]}*\n\n---\n\n`+e.map(Db).filter(Boolean).join(`
155
+
156
+ ---
157
+
158
+ `);if(n&&n.length>0){let e=n.map(e=>Ob(e,1)).join(`
159
+
160
+ ---
161
+
162
+ `);r+=`
163
+
164
+ ---
165
+
166
+ `+e}return r}function Ab(e,t){let n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}async function jb(e,t){let n=await _(t,e);if(n)return n;if(!E())return null;try{let n=await H()?.vscode?.saveMarkdown?.({fileName:t,content:e});if(!n||n.saved!==!0)return null;let r=typeof n.path==`string`?n.path.trim():``;return r.length>0?r:null}catch{return null}}async function Mb(e){let t=H()?.files;if(t?.revealPath)try{return!!(await t.revealPath(e))?.success}catch{return!1}return await T(e)?!0:O(e)}function Nb(){return nr()}function Pb(e){return`${(e?.trim()||`session`).normalize(`NFKC`).toLowerCase().replace(/[^\p{L}\p{N}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`session`}-${new Date().toISOString().split(`T`)[0]}.md`}function Fb(e){let t=(0,Q.c)(35),{session:n,title:r,projectLabel:i,project:a,branch:o,directory:s,time:c}=e,{t:l}=Nr(),d;t[0]===s?d=t[1]:(d=e=>s?e.directories.get(s)?.status?.current:void 0,t[0]=s,t[1]=d);let f=Qi(d),m;t[2]!==s||t[3]!==n.model?(m=e=>{let t=n.model;return t?e.directoryScoped[fn(s)]?.providers.find(e=>e.id===t.providerID)?.models.find(e=>e.id===t.id)?.name??t.id:null},t[2]=s,t[3]=n.model,t[4]=m):m=t[4];let g=An(m),_;if(t[5]!==l){let e=Dt.getQueryData([`desktop-host-inventory`,u()]),n=p(),r=h(),i=n.startsWith(`host:`)?n.slice(5):null,a=e?.hosts.find(e=>i?e.id===i:!!(r&&U(r,se(e))));_=a?ue(a.label):w()?l(`desktopHostSwitcher.instance.local`):null,t[5]=l,t[6]=_}else _=t[6];let v=_,y=!!(o&&f&&f!==`HEAD`&&f!==o),b;t[7]===r?b=t[8]:(b=(0,$.jsx)(`div`,{className:`min-w-0 flex-1 break-words typography-ui-label font-medium text-foreground`,children:r}),t[7]=r,t[8]=b);let x;t[9]===c?x=t[10]:(x=(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:c}),t[9]=c,t[10]=x);let S;t[11]!==b||t[12]!==x?(S=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[b,x]}),t[11]=b,t[12]=x,t[13]=S):S=t[13];let C;t[14]!==a||t[15]!==i?(C=i?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(_l,{project:a}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:i})]}):null,t[14]=a,t[15]=i,t[16]=C):C=t[16];let T;t[17]===v?T=t[18]:(T=v?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`computer`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:v})]}):null,t[17]=v,t[18]=T);let E;t[19]===o?E=t[20]:(E=o?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:o})]}):null,t[19]=o,t[20]=E);let D;t[21]!==f||t[22]!==y||t[23]!==l?(D=y?(0,$.jsxs)(`div`,{className:`flex items-start gap-2 typography-meta text-status-warning`,children:[(0,$.jsx)(X,{name:`error-warning`,className:`mt-0.5 size-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:l(`sessions.sidebar.session.hover.differentBranch`,{branch:f??``})})]}):null,t[21]=f,t[22]=y,t[23]=l,t[24]=D):D=t[24];let O;t[25]===g?O=t[26]:(O=g?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 typography-meta text-muted-foreground`,children:[(0,$.jsx)(X,{name:`ai-agent`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 break-words`,children:g})]}):null,t[25]=g,t[26]=O);let k;return t[27]!==n.id||t[28]!==D||t[29]!==O||t[30]!==S||t[31]!==C||t[32]!==T||t[33]!==E?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 text-left`,"data-session-hover-details":n.id,children:[S,C,T,E,D,O]}),t[27]=n.id,t[28]=D,t[29]=O,t[30]=S,t[31]=C,t[32]=T,t[33]=E,t[34]=k):k=t[34],k}var Ib=(e,t)=>{if(!t)return Array.from(e);let n=[],r=new Set;for(let i of e){r.has(i)||(r.add(i),n.push(i));let e=t.get(i);if(e)for(let t of e)r.has(t)||(r.add(t),n.push(t))}return n},Lb=de()((e,t)=>({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null,enable:()=>{t().enabled||e({enabled:!0})},disable:()=>{e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null})},toggleMode:()=>{t().enabled?e({enabled:!1,selectedIds:new Set,scopeKey:null,anchorId:null}):e({enabled:!0})},toggleSelected:(n,r,i)=>{let a=t(),o=new Set(a.selectedIds),s=a.scopeKey,c=a.anchorId;r!==null&&a.scopeKey!==null&&r!==a.scopeKey?(o.clear(),s=r,c=null):s===null&&r!==null&&(s=r);let l=i&&i.length>0?[n,...i]:[n];if(o.has(n)){for(let e of l)o.delete(e);c===n&&(c=null)}else{for(let e of l)o.add(e);c=n}o.size===0?e({selectedIds:o,scopeKey:null,anchorId:null}):e({selectedIds:o,scopeKey:s,anchorId:c})},setRange:(n,r,i,a,o)=>{let s=t();if(i.length===0)return;let c=n&&i.includes(n)?n:i[0],l=i.indexOf(c),u=i.indexOf(r);if(l<0||u<0)return;let[d,f]=l<=u?[l,u]:[u,l],p=Ib(i.slice(d,f+1),o),m=a!==null&&s.scopeKey!==null&&a!==s.scopeKey?new Set:new Set(s.selectedIds);for(let e of p)m.add(e);e({selectedIds:m,scopeKey:a??s.scopeKey,anchorId:c})},replaceAll:(t,n)=>{if(t.length===0){e({selectedIds:new Set,scopeKey:null,anchorId:null});return}e({selectedIds:new Set(t),scopeKey:n,anchorId:t[0]??null})},clear:()=>{e({selectedIds:new Set,scopeKey:null,anchorId:null})},removeMany:n=>{let r=t();if(r.selectedIds.size===0||n.length===0)return;let i=new Set(r.selectedIds);for(let e of n)i.delete(e);i.size!==r.selectedIds.size&&(i.size===0?e({selectedIds:i,scopeKey:null,anchorId:null}):e({selectedIds:i}))}})),Rb=!1,zb=new Set,Bb=!1;function Vb(){for(let e of zb)e()}function Hb(e){Rb!==e&&(Rb=e,Vb())}function Ub(e){e.key===`Shift`&&Hb(!0)}function Wb(e){e.key===`Shift`&&Hb(!1)}function Gb(){Hb(!1)}function Kb(){Bb||typeof window>`u`||(Bb=!0,window.addEventListener(`keydown`,Ub),window.addEventListener(`keyup`,Wb),window.addEventListener(`blur`,Gb))}function qb(e){return Kb(),zb.add(e),()=>{zb.delete(e)}}function Jb(){return Rb}function Yb(){return!1}function Xb(){return(0,Z.useSyncExternalStore)(qb,Jb,Yb)}var Zb=!1,Qb=!1,$b=new Set;function ex(){$b.forEach(e=>e())}function tx(e){Zb!==e&&(Zb=e,ex())}function nx(e){return Ln()?e.key===`Meta`:e.key===`Control`}var rx=(({setVisible:e,schedule:t=(e,t)=>setTimeout(e,t),cancel:n=e=>clearTimeout(e)})=>{let r=!1,i=null,a=()=>{i!==null&&(n(i),i=null)};return{press(){r||(r=!0,a(),i=t(()=>{i=null,r&&e(!0)},500))},release(){r=!1,a(),e(!1)}}})({setVisible:tx});function ix(e){nx(e)&&rx.press()}function ax(){rx.release()}function ox(e){nx(e)&&ax()}function sx(){document.visibilityState!==`visible`&&ax()}function cx(){Qb||typeof window>`u`||(Qb=!0,window.addEventListener(`keydown`,ix),window.addEventListener(`keyup`,ox),window.addEventListener(`blur`,ax),document.addEventListener(`visibilitychange`,sx))}function lx(e){return cx(),$b.add(e),()=>$b.delete(e)}function ux(){return Zb}function dx(){return!1}function fx(){return(0,Z.useSyncExternalStore)(lx,ux,dx)}var px=(e,t,n)=>{let r=e.session.title?.trim()||e.session.id;return`\n\n--- RESULT ${n+1}: ${r} ---\n${t.trim()}\n--- END RESULT ${n+1} ---`},mx=(e,t)=>Vn.getState().getWorktreeMetadata(e)?.projectDirectory??t,hx=e=>e.type===`assistant`?Zo(e.content??[]).trim():``,gx=async e=>{let t=e.directory??void 0,n=nt(e.session.id,t);if(n.length===0&&e.directory){let t=await rt.withDirectory(e.directory,()=>rt.getSdkClient().message.list({sessionID:e.session.id,limit:50})),n=Array.isArray(t.data)?t.data:[];for(let e=n.length-1;e>=0;--e){let t=hx(n[e]);if(t)return t}return``}for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.role===`assistant`)return Zo(tt(r.id,t)).trim()}return``};function _x({session:e,open:t,onOpenChange:n}){let{t:r}=Nr(),i=bn(),a=on(e=>e.activeSessions),o=on(e=>e.archivedSessions),s=An(e=>e.providers),c=An(e=>e.currentProviderId),l=An(e=>e.currentModelId),u=An(e=>e.currentAgentName),[d,f]=Z.useState(c??``),[p,m]=Z.useState(l??``),[h,g]=Z.useState(()=>c&&l?[{providerID:c,modelID:l,instanceId:$l()}]:[]),[_,v]=Z.useState(``),[y,b]=Z.useState(u??``),[x,S]=Z.useState([]),[C,w]=Z.useState(!1),T=Z.useMemo(()=>tu(e.title),[e.title]),E=Z.useMemo(()=>{let t=new Map;for(let e of i)t.set(e.id,e);for(let e of a)t.set(e.id,e);for(let e of o)t.set(e.id,e);return e.id&&t.set(e.id,e),Array.from(t.values())},[a,o,i,e]);Z.useEffect(()=>{if(!t||!T)return;let n=Vn.getState().getDirectoryForSession(e.id),r=mx(e.id,n),i=E.map(e=>{let t=tu(e.title);if(!t||t.groupSlug!==T.groupSlug||t.fusion||(t.runGroup??null)!==(T.runGroup??null))return null;let n=Vn.getState().getDirectoryForSession(e.id)??hn(e),i=mx(e.id,n);return r&&i&&r!==i?null:{session:e,directory:n,projectDirectory:i}}).filter(e=>e!==null).sort((e,t)=>(e.session.time?.created??0)-(t.session.time?.created??0));S(i)},[E,t,T,e.id]);let D=s.find(e=>e.id===d)?.models.find(e=>e.id===p),O=D?.variants?Object.keys(D.variants):[],k=!!(T&&d&&p&&x.length>0&&!C),A=Z.useCallback(e=>{g([e]),f(e.providerID),m(e.modelID),v(``)},[]),j=h[0]?.displayName||h[0]?.modelID||r(`multirun.fusion.model.placeholder`);return(0,$.jsx)(Qr,{open:t,onOpenChange:n,children:(0,$.jsxs)(Yr,{className:`max-w-xl overflow-visible`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:r(`multirun.fusion.title`)}),(0,$.jsx)(Zr,{children:r(`multirun.fusion.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`max-w-full`,children:(0,$.jsx)(nu,{selectedModels:h,onAdd:A,onUpdate:(e,t)=>A(t),onRemove:()=>{g([]),f(``),m(``),v(``)},maxModels:1,addButtonLabel:j,showChips:!1,addButtonClassName:`h-8 w-fit max-w-[min(28rem,calc(100vw-8rem))] justify-start rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`,dropdownSide:`bottom`,dropdownClassName:`w-[min(28rem,calc(100vw-8rem))]`,triggerIcon:d||p?(0,$.jsx)(Vo,{modelId:p,providerId:d,className:`h-3.5 w-3.5 mr-1`}):void 0})}),O.length>0?(0,$.jsxs)(Fs,{value:_||`__default__`,onValueChange:e=>v(e===`__default__`?``:e),children:[(0,$.jsxs)(Ps,{size:`lg`,className:`h-8 w-fit rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] !border-border/80 !bg-[var(--surface-subtle)] hover:!bg-[var(--interactive-hover)]/70 typography-meta font-medium text-foreground px-3 py-1.5`,children:[(0,$.jsx)(X,{name:`brain-ai-3`,className:`h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(js,{children:e=>e===`__default__`?r(`multirun.modelMultiSelect.variant.default`):e})]}),(0,$.jsxs)(Ns,{fitContent:!0,portalToBody:!0,children:[(0,$.jsx)(Ms,{value:`__default__`,children:r(`multirun.modelMultiSelect.variant.default`)}),O.map(e=>(0,$.jsx)(Ms,{value:e,children:e},e))]})]}):null,(0,$.jsx)(eu,{value:y,onChange:b,portalToBody:!0,className:`h-8 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] px-3 py-1.5`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-foreground`,children:r(`multirun.fusion.sources.label`,{count:x.length})}),(0,$.jsx)(`div`,{className:`max-h-56 space-y-1 overflow-auto rounded-lg border border-[var(--interactive-border)] p-1`,children:x.map(e=>{let t=tu(e.session.title);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md px-2 py-1.5 typography-meta`,children:[(0,$.jsx)(Vo,{modelId:t?.modelID,providerId:t?.providerID,className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.session.title||e.session.id}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>S(t=>t.filter(t=>t.session.id!==e.session.id)),className:`text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`})})]},e.session.id)})})]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(q,{variant:`ghost`,onClick:()=>n(!1),children:r(`multirun.fusion.actions.cancel`)}),(0,$.jsx)(q,{onClick:async()=>{if(!(!T||!d||!p)){w(!0);try{let e=await Promise.all(x.map(e=>gx(e))),t=x.map((t,n)=>({source:t,text:e[n]??``})).filter(e=>e.text.trim().length>0);if(t.length===0){Y.error(r(`multirun.fusion.toast.noOutputs`));return}let i=x[0]?.projectDirectory??x[0]?.directory??null,a=Ql(T.groupSlug,d,p,T.runGroup),[o,s]=await Promise.all([qi(`session.fusion.visible`),qi(`session.fusion.instructions`)]),c=await Vn.getState().createSession(a,i,null);if(!c)throw Error(`Failed to create fusion session`);Vn.getState().setCurrentSession(c.id,i),n(!1),await rt.sendMessage({id:c.id,providerID:d,modelID:p,variant:_||void 0,agent:y||void 0,text:o,additionalParts:[{text:s,synthetic:!0},...t.map((e,t)=>({text:px(e.source,e.text,t),synthetic:!0})),{text:`
167
+
168
+ --- FUSION INPUTS END ---
169
+ Now write the final fused answer.`,synthetic:!0}],directory:i??rt.getDirectory()})}catch(e){console.error(`[MultiRunFusion] Failed to start fusion`,e),Y.error(r(`multirun.fusion.toast.failed`))}finally{w(!1)}}},disabled:!k,children:r(C?`multirun.fusion.actions.starting`:`multirun.fusion.actions.start`)})]})]})})}function vx(e){let t=(0,Q.c)(13),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=[`yuri-icon`,n].filter(Boolean),t[3]=n,t[4]=i);let a=i.join(` `),o,s,c,l,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(`path`,{d:`M12 4.5v6.25M12 10.75v3.5M12 10.75H7.25A3.25 3.25 0 0 0 4 14v1.25M12 10.75h4.75A3.25 3.25 0 0 1 20 14v1.25`}),s=(0,$.jsx)(`path`,{d:`M9.25 7.25 12 4.5l2.75 2.75`}),c=(0,$.jsx)(`circle`,{cx:`4`,cy:`17.25`,r:`1.55`}),l=(0,$.jsx)(`circle`,{cx:`12`,cy:`17.25`,r:`1.55`}),u=(0,$.jsx)(`circle`,{cx:`20`,cy:`17.25`,r:`1.55`}),t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;return t[10]!==r||t[11]!==a?(d=(0,$.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:wr,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:a,...r,children:[o,s,c,l,u]}),t[10]=r,t[11]=a,t[12]=d):d=t[12],d}var yx=e(Ce(),1),bx=null,xx=!1,Sx=(e,t=uo.getState().focus)=>e===null?null:typeof e==`string`?t?.sessionId===e?t:$a(e):e,Cx=e=>{typeof window>`u`||(e.commitFrame!==null&&window.cancelAnimationFrame(e.commitFrame),e.paintFrame!==null&&window.cancelAnimationFrame(e.paintFrame),e.fallbackTimer!==null&&window.clearTimeout(e.fallbackTimer))},wx=()=>{bx&&=(Cx(bx),null)},Tx=(e,t)=>{wx(),ir(!0);let n=Sx(e);if(!n)return;xx=!0;let r;try{r=zt(n.sessionId)}finally{xx=!1}bx={commit:t,commitFrame:null,fallbackTimer:null,focus:n,intent:r,paintFrame:null,scheduled:!1},(0,yx.flushSync)(()=>{uo.getState().setFocus(n)}),typeof window<`u`&&(bx.fallbackTimer=window.setTimeout(()=>{Ex(n)},150))},Ex=e=>{let t=bx,n=Sx(e);if(!t||!qa(t.focus,n)||t.scheduled)return;t.scheduled=!0,typeof window<`u`&&t.fallbackTimer!==null&&(window.clearTimeout(t.fallbackTimer),t.fallbackTimer=null);let r=()=>{bx===t&&Rt()===t.intent&&(bx=null,Un(),t.commit())};if(typeof window>`u`){r();return}t.commitFrame=window.requestAnimationFrame(()=>{bx===t&&Rt()===t.intent&&(t.paintFrame=window.requestAnimationFrame(r))})},Dx=e=>{if(bx)return;let t=uo.getState();t.setFocus(Sx(e,t.focus))};Bt(e=>{if(xx)return;let t=bx;if(t?.intent===e)return;t&&wx();let n=uo.getState();n.setFocus(Sx(e.sessionId,n.focus))});var Ox=e=>{let t=[],n=e=>{e.children.forEach(e=>{t.push(e.session.id),n(e)})};return n(e),t},kx=Z.memo(function(e){let t=(0,Q.c)(21),{pinned:n,pinLabel:r,buttonSizeClass:i,iconSizeClass:a,onPointerDown:o,onMouseDown:s,onPin:c}=e,l=n?`text-foreground`:`text-muted-foreground`,u;t[0]!==i||t[1]!==l?(u=J(`inline-flex items-center justify-center rounded-md hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,l,i),t[0]=i,t[1]=l,t[2]=u):u=t[2];let d=n?`pushpin-2-fill`:`pushpin-2`,f=!n&&`rotate-45`,p;t[3]!==a||t[4]!==f?(p=J(a,f),t[3]=a,t[4]=f,t[5]=p):p=t[5];let m;t[6]!==d||t[7]!==p?(m=(0,$.jsx)(X,{name:d,className:p}),t[6]=d,t[7]=p,t[8]=m):m=t[8];let h;t[9]!==s||t[10]!==c||t[11]!==o||t[12]!==r||t[13]!==u||t[14]!==m?(h=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:u,"aria-label":r,onPointerDown:o,onMouseDown:s,onClick:c,onKeyDown:Hx,children:m})}),t[9]=s,t[10]=c,t[11]=o,t[12]=r,t[13]=u,t[14]=m,t[15]=h):h=t[15];let g;t[16]===r?g=t[17]:(g=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:r}),t[16]=r,t[17]=g);let _;return t[18]!==h||t[19]!==g?(_=(0,$.jsxs)(ni,{children:[h,g]}),t[18]=h,t[19]=g,t[20]=_):_=t[20],_}),Ax=Z.memo(function(e){let t=(0,Q.c)(24),{archiveLabel:n,deleteLabel:r,deleteOnly:i,restore:a,buttonSizeClass:o,iconSizeClass:s,revealClassName:c,onPointerDown:l,onMouseDown:u,onArchive:d,onDelete:f}=e,p=i!==void 0&&i,m=a!==void 0&&a,h=Xb(),g=p||h,_=g?r:n,v;t[0]!==p||t[1]!==d||t[2]!==f||t[3]!==h?(v=e=>{if(p||h||e.shiftKey){f(e);return}d(e)},t[0]=p,t[1]=d,t[2]=f,t[3]=h,t[4]=v):v=t[4];let y=v,b=g?`text-destructive hover:text-destructive hover:bg-[color-mix(in_srgb,var(--status-error)_12%,transparent)]`:`text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,x;t[5]!==o||t[6]!==c||t[7]!==b?(x=J(`inline-flex items-center justify-center rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,b,o,c),t[5]=o,t[6]=c,t[7]=b,t[8]=x):x=t[8];let S=g?`delete-bin`:m?`undo-2`:`inbox-archive`,C;t[9]!==s||t[10]!==S?(C=(0,$.jsx)(X,{name:S,className:s}),t[9]=s,t[10]=S,t[11]=C):C=t[11];let w;t[12]!==y||t[13]!==_||t[14]!==u||t[15]!==l||t[16]!==x||t[17]!==C?(w=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:x,"aria-label":_,onPointerDown:l,onMouseDown:u,onClick:y,onKeyDown:Ux,children:C})}),t[12]=y,t[13]=_,t[14]=u,t[15]=l,t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]===_?T=t[20]:(T=(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:_}),t[19]=_,t[20]=T);let E;return t[21]!==w||t[22]!==T?(E=(0,$.jsxs)(ni,{children:[w,T]}),t[21]=w,t[22]=T,t[23]=E):E=t[23],E}),jx=Z.memo(function(e){let t=(0,Q.c)(3),{number:n}=e;if(!fx())return null;let r=Ln()?`⌘${n}`:`Ctrl+${n}`,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(Ri,{"data-sidebar-shortcut-number":n,variant:`hint`,"aria-hidden":`true`,children:r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i});function Mx(e){let{t}=Nr(),{node:r,depth:i=0,groupDirectory:a,projectId:o,archivedBucket:s=!1,pinnedSessionIds:c,expandedParents:l,hasSessionSearchQuery:u,normalizedSessionSearchQuery:d,editingId:f,setEditingId:p,editTitle:m,setEditTitle:g,handleSaveEdit:_,handleCancelEdit:v,toggleParent:y,handleSessionSelect:b,togglePinnedSession:x,handleShareSession:S,copiedSessionId:C,handleCopyShareUrl:w,handleUnshareSession:T,setOpenSidebarMenuKey:D,renamingFolderId:O,getFoldersForScope:k,getSessionFolderId:A,removeSessionFromFolder:j,addSessionToFolder:M,createFolderAndStartRename:N,handleDeleteSession:F,mobileVariant:L,alwaysShowActions:R,renderSessionNode:z,secondaryMeta:B,renderContext:te=`project`,subtreeContainsActive:ne,subtreeContainsEditing:re,menuOpenSessionId:ie,childRenderExtrasFor:ae,liveSessionById:oe,shortcutNumber:V=null,settledSessionIds:H,setSessionSettled:se}=e,U=!!B?.projectLabel,ce=!!B?.branchLabel,le=tn(e=>e.displayMode),ue=Z.useMemo(()=>E(),[]),de=le===`minimal`||ue,fe=Z.useMemo(()=>ee(),[]),pe=Z.useContext(xt),ge=ue?`group-hover:opacity-100 group-hover:pointer-events-auto`:`group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`,be=ue,Se=te===`pinned`&&c.has(r.session.id),Ce=!Se&&!s&&!L&&!B?.slim,Ee=`h-5 w-5`,De=`h-3.5 w-3.5`,Oe=(Ce||Se?1:0)+ +!!be+1,ke=Oe>=3?`group-hover:pr-18 group-focus-within:pr-18`:Oe>=2?`group-hover:pr-12 group-focus-within:pr-12`:`group-hover:pr-7 group-focus-within:pr-7`,Ae=R?ue?ke:Oe>=2?`pr-12`:`pr-8`:ke,Me=Z.useRef(!1),Ne=Z.useRef(!1),[Pe,Fe]=Z.useState(!1),Ie=Z.useRef(f);Ie.current=f;let W=Z.useRef(null),[Le,Re]=Z.useState(m),[ze,Be]=Z.useState(f===r.session.id),Ve=Z.useRef(null),He=Z.useRef(null),Ue=Z.useRef(null),We=r.session,Ge=oe.get(We.id)??We,Ke=!!Ge.metadata?.yuri?.assistant,qe=P(We.directory??null)??P(a??null),Je=wn(qe??void 0,{bootstrap:!1}),Ye=ps(),Qe=Lb(e=>e.enabled),$e=Lb(Z.useMemo(()=>e=>e.selectedIds.has(We.id),[We.id])),et=Lb(e=>e.toggleSelected),tt=Lb(e=>e.setRange),[nt,rt]=Z.useState(!1),[at,st]=Z.useState(!0),[ct,lt]=Z.useState(!1),[ut,dt]=Z.useState(!1),ft=`${te}:${s?`archived`:`active`}:${We.id}`,pt=vr(Z.useMemo(()=>e=>!!e.sessionMemoryState.get(xn(We.id))?.isZombie,[We.id])),mt=Bn(We.id),ht=or(We.id,qe??void 0,{bootstrap:!1}),gt=er(We.id,qe??void 0,{bootstrap:!1}),_t=Z.useMemo(()=>({scope:te,sessionId:We.id,projectId:o??null}),[o,te,We.id]),vt=Z.useMemo(()=>Qa(_t)??``,[_t]),yt=Z.useRef(null),bt=uo(Z.useMemo(()=>e=>qa(e.focus,_t),[_t]));Z.useLayoutEffect(()=>{if(!bt)return;let e=yt.current;e&&(L?e.scrollIntoView({block:`nearest`,inline:`nearest`}):fb(e)),Ex(_t)},[bt,L,_t]);let St=Ge.title||t(`sessions.sidebar.session.untitled`),Ct=cc(sc(Ge)),wt=Ge.metadata?.yuri?.titleRefresh,Tt=typeof wt?.lastError==`string`?wt.lastError:null,Et=typeof wt?.failedAt==`number`?wt.failedAt:null;Z.useEffect(()=>{!Tt||Et===null||console.warn(`[session-title] generation failed for ${We.id}: ${Tt}`)},[We.id,Tt,Et]);let Dt=typeof wt?.generationExpiresAt==`number`&&Number.isFinite(wt.generationExpiresAt)?wt.generationExpiresAt:0,[Ot,kt]=Z.useState(0),At=Z.useMemo(()=>Math.max(0,Dt-Date.now()),[Dt]),[,jt,Mt]=Ft(()=>kt(Dt),At,{immediate:!1}),Nt=wt?.isGenerating===!0;Z.useEffect(()=>(Nt&&Dt>Date.now()&&jt(),Mt),[Nt,Dt,jt,Mt]);let Pt=r.children.length>0||!!(Ge.hasChildren??We.hasChildren),It=c.has(We.id),Lt=!!H?.has(We.id),Rt=ft,zt=u?!0:l.has(Rt),Bt=!!Ge.parentID,K=te===`pinned`,Vt=sn(We.id),Ht=Vt>0&&!Bt,Ut=sr(Ge)||Date.now(),Wt=So(Ut),Gt=Co(Ut),[Kt,qt]=Z.useState(!1),[Jt,Yt]=Z.useState(!1),Xt=Kt,Qt=Z.useMemo(()=>tu(Ge.title)!==null,[Ge.title]),[$t,en]=Z.useState(!1),nn=Z.useMemo(()=>Ox(r).length,[r]),rn=G(e=>{let t=qe??``,n=(Ze()??ot(t,Je)).getTranscript(it(t,e)),r=Je.getState().session.find(t=>t.id===e)?.revert?.messageID;return Zt({sessionID:e,messages:Xe(n),parts:n.partsByMessageID,revertMessageID:r}).list}),an=G(async e=>{let n=[],r=0;for(let i of e)try{await Ye.ensureSessionRenderable(i.session.id);let e=rn(i.session.id),a=i.session.title||t(`sessions.sidebar.session.export.untitledSubagent`),o=i.session.agent,s=await an(i.children);r+=s.skipped,n.push({title:a,agent:o,records:e,children:s.children})}catch{r+=Ox(i).length+1}return{children:n,skipped:r}}),on=G(e=>{e<=0||Y.warning(t(e===1?`sessions.sidebar.session.export.skippedSubtaskSingle`:`sessions.sidebar.session.export.skippedSubtaskMany`,{count:e}))}),cn=G(async e=>{if(!qe){Y.error(t(`sessions.sidebar.session.export.nothingToExport`));return}await Ye.ensureSessionRenderable(We.id);let n=rn(We.id);if(n.length===0){Y.error(t(`sessions.sidebar.session.export.nothingToExport`));return}let i,a=0;if(e&&r.children.length>0){let e=await an(r.children);i=e.children,a=e.skipped}let o=kb(n,Ge.title??null,i),s=Pb(Ge.title??null),c=await jb(o,s);if(c){Y.success(t(`sessions.sidebar.session.export.success`),{action:{label:t(Nb()),onClick:()=>{Mb(c).then(e=>{e||Y.error(t(`sessions.sidebar.session.export.failedRevealPath`))})}}}),on(a);return}Ab(o,s),Y.success(t(`sessions.sidebar.session.export.success`)),on(a)}),ln=G(async()=>{if(r.children.length>0){st(!0),rt(!0);return}await cn(!1)}),dn=G(()=>{qe&&I(`desktop_open_session_mini_chat_window`,{sessionId:We.id,directory:qe,apiBaseUrl:h(),clientToken:n()}).catch(e=>{console.warn(`[session-sidebar] failed to open mini chat window`,e)})});Z.useLayoutEffect(()=>{if(f!==We.id){ze&&Be(!1),Ve.current===We.id&&(Ve.current=null);return}!ze||Ve.current===We.id||(Ve.current=We.id,Re(m),queueMicrotask(()=>Ue.current?.select()))},[f,m,We.id,ze]);let fn=G(e=>{if(!e&&W.current){let{id:e,title:t}=W.current;W.current=null,Be(!0),p(e),g(t)}}),pn=G(e=>{qt(e)}),mn=G(e=>{e.preventDefault(),e.stopPropagation()}),hn=G(e=>{e.preventDefault(),e.stopPropagation()}),gn=G(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(We.id)}),_n=!!se&&!!(B?.card||B?.slim)&&!s&&!Bt,vn=G(e=>{if(e.preventDefault(),e.stopPropagation(),D(null),_n&&se){se(We.id,!Lt);return}F(We,{archivedBucket:s})}),yn=G(e=>{e.preventDefault(),e.stopPropagation(),D(null),F(We,{archivedBucket:s,hardDelete:!0,skipConfirm:!0})}),bn=G(e=>{e.preventDefault(),e.stopPropagation(),D(null),x(We.id)}),Sn=G(()=>{!qe||ct||(lt(!0),(async()=>{try{await Ye.refreshSessionTranscript(We.id,{directory:qe}),Y.success(t(`sessions.sidebar.session.menu.refreshTranscriptSuccess`))}catch{Y.error(t(`sessions.sidebar.session.menu.refreshTranscriptFailed`))}finally{lt(!1)}})())}),Cn=G(e=>{e.preventDefault(),e.stopPropagation()}),Tn=G(e=>{e.preventDefault(),e.stopPropagation()}),Dn=G(e=>{e.preventDefault(),e.stopPropagation(),pe?.vscode?.executeCommand(`yuri.openSessionInEditor`,We.id,St)}),On=G(e=>{if(Me.current){Me.current=!1;return}if(Qe){if(e?.preventDefault(),e?.stopPropagation(),e?.shiftKey){let e=(typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[]).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0),t=Lb.getState().anchorId,n=new Map;n.set(We.id,Ox(r)),tt(t,We.id,e,qe??null,n);return}et(We.id,qe??null,Ox(r));return}b(We.id,qe,o,te)}),kn=G(e=>{if(e.defaultPrevented||e.target?.closest(`button, a, input, [role="menuitem"], [role="menu"]`))return;On(e);let t=e.currentTarget.querySelector(`[data-session-title]`);t&&!L&&(t.focus({preventScroll:!0}),Ne.current=!0)}),An=G(e=>{(e.button===2||e.button===0&&e.ctrlKey&&!Qe)&&(Me.current=!0)}),jn=G(e=>{Ne.current=e.pointerType===`mouse`,L&&e.pointerType===`touch`&&Fe(!0)}),Mn=G(e=>{L&&e.pointerType===`touch`&&Fe(!1)}),Nn=G(e=>{e.key!==`Enter`||!Ne.current||(e.preventDefault(),e.stopPropagation(),Be(!0),p(We.id),g(St))}),Pn=G(e=>{if(On(e),!Ne.current)return;let t=e.currentTarget;window.requestAnimationFrame(()=>{Ne.current=!0,t.focus({preventScroll:!0})})}),Fn=G(()=>{Ne.current=!1}),In=G(()=>{!zt&&!ut&&(dt(!0),Ye.loadChildren(We.id,qe).catch(()=>Y.error(t(`sessions.sidebar.session.subsessions.loadFailed`))).finally(()=>dt(!1))),y(Rt)});if(f===We.id&&ze){let e=async()=>{v();try{await Gn(We.id)}catch(e){console.warn(`[session-sidebar] failed to request smart title:`,e)}};return(0,$.jsx)(`div`,{className:`group relative my-0.5 flex items-center rounded-lg py-1.5 pr-2`,style:{paddingLeft:Ao(i)},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0`,children:[(0,$.jsxs)(`form`,{ref:He,className:`flex w-full items-center gap-2`,onSubmit:e=>{e.preventDefault(),_(Le)},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||v()},children:[(0,$.jsx)(`input`,{ref:Ue,value:Le,onChange:e=>Re(e.target.value),className:`flex-1 min-w-0 bg-transparent typography-ui-label outline-none placeholder:text-muted-foreground`,autoFocus:!0,placeholder:t(`sessions.sidebar.session.menu.rename`),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){v();return}}}),(0,$.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:()=>{e()},"aria-label":t(`sessions.sidebar.session.rename.smartTitle`),title:t(`sessions.sidebar.session.rename.smartTitle`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`ai-generate-2`,className:`size-3.5`})}),(0,$.jsx)(`button`,{type:`submit`,onMouseDown:e=>e.preventDefault(),"aria-label":t(`sessions.sidebar.session.rename.save`),title:t(`sessions.sidebar.session.rename.save`),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(X,{name:`check`,className:`size-3.5`})})]}),de?null:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-3 text-muted-foreground/60 min-w-0 overflow-hidden leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[Pt&&!K&&!Bt?(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center flex-shrink-0`,children:zt?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,$.jsx)(`span`,{className:`flex-shrink-0`,children:Wt}),U?(0,$.jsx)(`span`,{className:`truncate`,children:B?.projectLabel}):null,ce?(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:B?.branchLabel})]}):null]})})]})},We.id)}let Ln=mt,Rn=Nt&&Dt>Date.now()&&Ot!==Dt,zn=ht.length,Vn=gt.length>0,Un=!Vn&&!Ln&&Ht,Wn=!!B?.card,Kn=!!B?.slim,qn=Vn||zn>0,Jn=!qn&&Ln,Yn=bt||$e,Xn=Wn&&Un,Zn=!Wn&&(Vn||Ln||Un),Qn=t(Vn?`sessions.sidebar.session.status.questionRequired`:`sessions.sidebar.session.status.permissionRequired`),$n=B?.runStartedAt??null,tr=qn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none text-status-warning`,"aria-label":Qn,title:Qn,children:[(0,$.jsx)(X,{name:Vn?`question`:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:Qn})]}):Jn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium leading-none tabular-nums text-status-info`,title:t(`sessions.sidebar.session.status.active`),children:[(0,$.jsx)(Sl,{size:10,arcColor:`var(--status-info)`}),$n===null?null:(0,$.jsx)(xl,{startedAt:$n})]}):(0,$.jsx)(`span`,{className:J(`text-[10px] leading-none tabular-nums`,Yn?`text-foreground/70`:`text-muted-foreground/70`),children:Gt}),nr=!R||ue,rr=nr?J(`group-hover:invisible group-focus-within:invisible`,Xt&&`invisible`):Xt?`invisible`:``,ir=Vn?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.questionRequired`),title:t(`sessions.sidebar.session.status.questionRequired`),children:(0,$.jsx)(X,{name:`question`,className:`h-3.5 w-3.5 text-primary`})}):Ln?(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.active`),title:t(`sessions.sidebar.session.status.active`),children:(0,$.jsx)(Sl,{})}):(0,$.jsx)(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center`,"aria-label":t(`sessions.sidebar.session.status.unread`),title:t(`sessions.sidebar.session.status.unread`),children:(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-[var(--status-info)]`})}),ar=!K&&!Bt&&Pt,cr=ar&&!R&&!ut,lr=Ao(Math.max(0,i-1)),ur=ar?(0,$.jsx)(`span`,{role:`button`,tabIndex:0,"aria-expanded":zt,"aria-busy":ut,onClick:e=>{e.stopPropagation(),e.currentTarget.blur(),In()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),In())},style:{minWidth:14,minHeight:14,left:lr},className:J(`absolute inline-flex h-3.5 w-3.5 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-opacity`,de?`top-1/2 -translate-y-1/2`:`top-[14.5px] -translate-y-1/2`,cr?`opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto`:``),"aria-label":t(zt?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:ut?(0,$.jsx)(Sl,{size:12}):zt?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,dr=pt?(0,$.jsx)(X,{name:`error-warning`,className:`h-4 w-4 text-status-warning`}):null,fr=(0,$.jsx)(he,{children:(0,$.jsx)(je,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-content`,finalFocus:()=>!(O||Ie.current),style:{color:`var(--surface-elevated-foreground)`},className:J(hi,`yuri-session-context-menu min-w-[180px]`),children:(({Item:e,Separator:n,Sub:r,SubTrigger:i,SubContent:a})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:()=>x(We.id),className:`[&>svg]:mr-1`,children:[It?(0,$.jsx)(X,{name:`unpin`,className:`mr-1 h-4 w-4`}):(0,$.jsx)(X,{name:`pushpin`,className:`mr-1 h-4 w-4`}),t(It?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`)]}),Bt?null:(0,$.jsxs)(e,{onClick:()=>{Vt>0?un(We.id):En(We.id,qe||void 0).catch(()=>Y.error(t(`sessions.sidebar.session.menu.markUnreadFailed`)))},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:Vt>0?`mail-open`:`mail`,className:`mr-1 h-4 w-4`}),t(Vt>0?`sessions.sidebar.session.menu.markRead`:`sessions.sidebar.session.menu.markUnread`)]}),(0,$.jsxs)(e,{onClick:()=>{W.current={id:We.id,title:St}},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`pencil-ai`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.rename`)]}),Hn()&&!Ge.share?(0,$.jsxs)(e,{onClick:()=>S(Ge),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`share-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.share`)]}):Hn()&&Ge.share?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:()=>{Ge.share?.url&&w(Ge.share.url,We.id)},className:`[&>svg]:mr-1`,children:C===We.id?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`check`,className:`mr-1 h-4 w-4`,style:{color:`var(--status-success)`}}),t(`sessions.sidebar.session.menu.copied`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`file-copy`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.copyLink`)]})}),(0,$.jsxs)(e,{onClick:()=>T(We.id),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`link-unlink-m`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unshare`)]})]}):null,(0,$.jsxs)(e,{onClick:()=>{ln()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`download`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.exportMarkdown`)]}),(0,$.jsxs)(e,{disabled:!qe||ct,onClick:()=>{Sn()},className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`refresh`,className:J(`mr-1 h-4 w-4`,ct&&`animate-spin`)}),t(`sessions.sidebar.session.menu.refreshTranscript`)]}),Qt?(0,$.jsxs)(e,{onClick:()=>en(!0),className:`[&>svg]:mr-1`,children:[(0,$.jsx)(vx,{className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.runFusion`)]}):null,qe&&!s?(()=>{let o=k(qe),s=A(qe,We.id);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(n,{}),(0,$.jsxs)(r,{children:[(0,$.jsxs)(i,{className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`}),t(`sessions.sidebar.folders.moveToFolder`)]}),(0,$.jsxs)(a,{className:`min-w-[180px]`,children:[o.length===0?(0,$.jsx)(e,{disabled:!0,className:`text-muted-foreground`,children:t(`sessions.sidebar.folders.none`)}):o.map(t=>(0,$.jsxs)(e,{onClick:()=>{s===t.id?j(qe,We.id):M(qe,t.id,We.id)},children:[(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:t.name}),s===t.id?(0,$.jsx)(X,{name:`check`,className:`ml-2 h-3.5 w-3.5 text-primary flex-shrink-0`}):null]},t.id)),(0,$.jsx)(n,{}),(0,$.jsxs)(e,{onClick:()=>{let e=N(qe);e&&M(qe,e.id,We.id)},children:[(0,$.jsx)(X,{name:`add`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.folders.newFolderEllipsis`)]}),s?(0,$.jsxs)(e,{onClick:()=>{j(qe,We.id)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]})]})})():null,fe?(0,$.jsxs)(e,{disabled:!qe,onClick:dn,className:`[&>svg]:mr-1`,children:[(0,$.jsx)(X,{name:`window`,className:`mr-1 h-4 w-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:t(`sessions.sidebar.session.menu.openMiniChatWindow`)})]}):null,(0,$.jsx)(n,{}),s?null:_n&&Lt?(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>se?.(We.id,!1),children:[(0,$.jsx)(X,{name:`undo-2`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.session.menu.unsettle`)]}):(0,$.jsxs)(e,{className:`[&>svg]:mr-1`,onClick:()=>_n&&se?se(We.id,!0):F(We,{archivedBucket:s}),children:[(0,$.jsx)(X,{name:`inbox-archive`,className:`mr-1 h-4 w-4`}),t(`sessions.sidebar.bulkActions.archive`)]}),(0,$.jsxs)(e,{className:`text-destructive/80 focus:text-destructive/80 [&>svg]:mr-1`,onClick:()=>F(We,{archivedBucket:s,hardDelete:!0}),children:[(0,$.jsx)(X,{name:`delete-bin`,className:`mr-1 h-4 w-4 text-inherit`}),t(`sessions.sidebar.bulkActions.delete`)]})]}))({Item:({className:e,...t})=>(0,$.jsx)(_e,{className:J(_i,e),...t}),Separator:({className:e,...t})=>(0,$.jsx)(ve,{className:J(gi,e),...t}),Sub:ye,SubTrigger:({className:e,children:t,...n})=>(0,$.jsxs)(we,{className:J(mi,e),...n,children:[t,(0,$.jsx)(X,{name:`arrow-right-s`,className:`ml-auto size-3.5`})]}),SubContent:({className:e,children:t,...n})=>(0,$.jsx)(he,{children:(0,$.jsx)(je,{className:`app-region-no-drag z-50`,children:(0,$.jsx)(xe,{"data-slot":`dropdown-menu-sub-content`,style:{color:`var(--surface-elevated-foreground)`},className:J(hi,`yuri-session-context-menu`,e),...n,children:t})})})})})})});return(0,$.jsxs)(Z.Fragment,{children:[(0,$.jsx)(Jc,{sessionId:We.id,sessionDirectory:qe??null,sessionTitle:St,children:(0,$.jsxs)(me,{open:Kt,onOpenChange:pn,onOpenChangeComplete:fn,children:[(0,$.jsxs)(Te,{render:(0,$.jsx)(Wc,{ref:yt,active:bt,selected:$e,"data-session-row":We.id,"data-session-scope":qe??``,"data-session-focus-scope":te,"data-session-focus-key":vt,"data-session-project-id":o??``,"data-session-archived":s?`1`:`0`,"data-session-depth":i,onClick:kn,className:J(bt&&!$e&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,$e&&`bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] dark:bg-[color-mix(in_srgb,var(--surface-foreground)_11%,transparent)]`,!bt&&!$e&&`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_3.5%,transparent)] dark:hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Kn&&`py-1`)}),children:[ur,(0,$.jsx)(wc,{depth:i,children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,$.jsxs)(ni,{onOpenChange:Yt,children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsxs)(qc,{type:`button`,"data-session-title":!0,onPointerDown:jn,onPointerUp:Mn,onPointerCancel:Mn,onMouseDown:An,onKeyDown:Nn,onBlur:Fn,onClick:Pn,onDoubleClick:e=>{e.stopPropagation(),!L&&ee()&&dn()},className:J(Pe&&`bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)]`,Wn&&`gap-0.5`,!Wn&&Ae),children:[Wn?(0,$.jsxs)(`div`,{className:J(`flex h-5 w-full min-w-0 items-center gap-1 overflow-hidden`,Ae),children:[(0,$.jsx)(_l,{project:B?.project}),Xn&&!qn?(0,$.jsx)($c,{}):null,(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate typography-micro leading-4`,Yn?`text-foreground/80`:`text-muted-foreground`),children:B?.projectLabel}),(0,$.jsx)(`span`,{className:J(`shrink-0`,rr),children:tr})]}):null,(0,$.jsxs)(`div`,{className:`flex w-full items-center min-w-0 flex-1 gap-1 overflow-hidden`,children:[Kn?(0,$.jsx)(_l,{project:B?.project}):null,(0,$.jsx)(`div`,{className:J(`block min-w-0 flex-1 truncate text-foreground`,Kn?`typography-meta`:`typography-ui-label`,Kn&&!Yn&&`text-muted-foreground`,Xn?`font-medium`:`font-normal`,Rn&&`animate-text-shimmer`),"aria-busy":Rn||void 0,children:_o(St,d)}),Ct?(0,$.jsx)(`span`,{className:`shrink-0 typography-micro tabular-nums text-muted-foreground`,children:Ct}):null,Kn?(0,$.jsx)(`span`,{className:J(`shrink-0 text-[10px] leading-none tabular-nums text-muted-foreground/70`,rr),children:Gt}):null,Ke?(0,$.jsx)(X,{name:`ai-agent`,className:`size-3 shrink-0 text-muted-foreground`,"aria-label":`Assistant`}):null,zn>0&&!Wn?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1 py-0.5 text-[0.7rem] text-destructive flex-shrink-0`,title:t(`sessions.sidebar.session.status.permissionRequired`),"aria-label":t(`sessions.sidebar.session.status.permissionRequired`),children:[(0,$.jsx)(X,{name:`shield`,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`leading-none`,children:zn})]}):null,Zn?(0,$.jsx)(`span`,{className:J(`inline-flex shrink-0 items-center justify-center transition-none`,nr?J(`group-hover:hidden group-focus-within:hidden`,Xt?`hidden`:``):Xt?`invisible`:``),children:ir}):null,V?(0,$.jsx)(jx,{number:V}):null]}),Wn?(0,$.jsxs)(`div`,{className:J(`flex h-4 w-full min-w-0 items-center gap-1 overflow-hidden text-[10px] leading-4`,Yn?`text-foreground/60`:`text-muted-foreground/60`),children:[ce?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B?.branchLabel})]}):B?.branchState===`loading`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`git-branch`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 animate-pulse truncate`,children:t(`common.loading`)})]}):B?.pathLabel?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`inline-flex size-3.5 shrink-0 items-center justify-center`,children:(0,$.jsx)(X,{name:`folder-open`,className:`size-2.5`})}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:B.pathLabel})]}):(0,$.jsx)(`span`,{className:`flex-1`}),It?(0,$.jsx)(X,{name:`pushpin-2-fill`,className:`size-2.5 shrink-0`,"aria-label":t(`sessions.sidebar.session.actions.pinned`)}):null]}):null]})}),ue?null:(0,$.jsx)(ei,{side:`right`,align:`start`,sideOffset:8,className:`w-64 max-w-[min(16rem,calc(100vw-2rem))] px-3 py-2.5 text-left shadow-md`,children:Jt?(0,$.jsx)(Fb,{session:Ge,title:St,time:Gt,projectLabel:B?.projectLabel,project:B?.project,branch:r.worktree?.branch??B?.branchLabel,directory:qe}):null})]})})}),dr&&!L?(0,$.jsx)(`div`,{className:J(`absolute top-1/2 -translate-y-1/2 z-10`,de?`right-0`:`right-[30px]`),children:dr}):null,(0,$.jsxs)(Gc,{visible:Xt||R&&!ue,className:J(`absolute right-1 top-1/2 z-10 flex -translate-y-1/2 items-center gap-1 transition-none group-has-[[data-sidebar-shortcut-number]]:hidden`,Xt||R&&!ue?`opacity-100`:J(`opacity-0`,ge),Wn&&`top-1.5 translate-y-0`),children:[Ce?(0,$.jsx)(kx,{pinned:It,pinLabel:t(It?`sessions.sidebar.session.menu.unpin`:`sessions.sidebar.session.menu.pin`),buttonSizeClass:Ee,iconSizeClass:De,onPointerDown:mn,onMouseDown:hn,onPin:gn}):null,Se?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex items-center justify-center rounded-md text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Ee),"aria-label":t(`sessions.sidebar.session.actions.pinned`),onPointerDown:mn,onMouseDown:hn,onClick:bn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(X,{name:`pushpin-2-fill`,className:De})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.pinned`)})]}):null,be?(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:J(`inline-flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-[color-mix(in_srgb,var(--surface-foreground)_8%,transparent)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 transition-none`,Ee),"aria-label":t(`sessions.sidebar.session.actions.openInEditor`),onPointerDown:Cn,onMouseDown:Tn,onClick:Dn,onKeyDown:e=>e.stopPropagation(),children:(0,$.jsx)(X,{name:`external-link`,className:De})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,className:`rounded-md px-1.5 py-0.5 typography-micro`,children:t(`sessions.sidebar.session.actions.openInEditor`)})]}):null,(0,$.jsx)(Ax,{archiveLabel:t(_n&&Lt?`sessions.sidebar.session.menu.unsettle`:`sessions.sidebar.bulkActions.archive`),restore:_n&&Lt,deleteLabel:t(`sessions.sidebar.bulkActions.delete`),deleteOnly:s===!0,buttonSizeClass:Ee,iconSizeClass:De,revealClassName:de&&!R&&!Xt?J(`opacity-0`,ge):`opacity-100`,onPointerDown:mn,onMouseDown:hn,onArchive:vn,onDelete:yn})]})]}),fr]})}),!K&&Pt&&zt?r.children.map(e=>{let t=ae?ae(e):{subtreeContainsActive:ne,subtreeContainsEditing:re,menuOpenSessionId:ie,nodeStructureKey:``};return z(e,i+1,qe??a,o,s,void 0,te,t)}):null,(0,$.jsx)(Qr,{open:nt,onOpenChange:rt,children:(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(qr,{children:[(0,$.jsx)(Xr,{children:t(`sessions.sidebar.session.export.dialog.title`)}),(0,$.jsx)(Zr,{children:t(nn===1?`sessions.sidebar.session.export.dialog.descriptionSingle`:`sessions.sidebar.session.export.dialog.descriptionMany`,{count:nn})})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-ui-label cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:at,onChange:e=>st(e.target.checked),className:`h-4 w-4 rounded border-border accent-primary`}),t(`sessions.sidebar.session.export.dialog.includeSubtasks`)]}),(0,$.jsxs)(Jr,{children:[(0,$.jsx)(q,{type:`button`,onClick:()=>rt(!1),variant:`outline`,size:`sm`,children:t(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{type:`button`,onClick:()=>{rt(!1),cn(at)},size:`sm`,children:t(`sessions.sidebar.session.export.dialog.confirm`)})]})]})}),Qt?(0,$.jsx)(_x,{session:Ge,open:$t,onOpenChange:en}):null]},We.id)}var Nx=e=>P(e.session.directory??null),Px=(e,t)=>(e?.projectLabel??null)===(t?.projectLabel??null)&&(e?.branchLabel??null)===(t?.branchLabel??null)&&!!e?.card==!!t?.card&&!!e?.slim==!!t?.slim&&(e?.branchState??null)===(t?.branchState??null)&&(e?.pathLabel??null)===(t?.pathLabel??null)&&(e?.project??null)===(t?.project??null)&&(e?.runStartedAt??null)===(t?.runStartedAt??null),Fx=e=>{if(!e.openSidebarMenuKey)return null;let t=e.archivedBucket?`archived`:`active`,n=`${e.renderContext??`project`}:${t}:`;return e.openSidebarMenuKey.startsWith(n)?e.openSidebarMenuKey.slice(n.length):null},Ix=e=>e.menuOpenSessionId??Fx(e),Lx=(e,t,n)=>t?n.has(e.node.session.id)?!0:jc(e.node,t):!1,Rx=(e,t,n,r,i)=>{if(e.session.id!==t.session.id)return!0;let a=i(e);if(n.has(a)!==r.has(a)||e.children.length!==t.children.length)return!0;for(let a=0;a<e.children.length;a+=1)if(Rx(e.children[a],t.children[a],n,r,i))return!0;return!1},zx=(e,t,n,r)=>{if(e.session.id!==t.session.id)return!0;let i=e.session.id,a=n.get(i)??e.session,o=r.get(i)??t.session;if(a!==o&&Lc(a)!==Lc(o)||e.children.length!==t.children.length)return!0;for(let i=0;i<e.children.length;i+=1)if(zx(e.children[i],t.children[i],n,r))return!0;return!1},Bx=(e,t)=>{if(e.hasSessionSearchQuery||t.hasSessionSearchQuery)return!1;let n=e.archivedBucket?`archived`:`active`,r=t.archivedBucket?`archived`:`active`;return Rx(e.node,t.node,e.expandedParents,t.expandedParents,t=>`${e.renderContext??`project`}:${n}:${t.session.id}`)||Rx(e.node,t.node,e.expandedParents,t.expandedParents,e=>`${t.renderContext??`project`}:${r}:${e.session.id}`)},Vx=Z.memo(Mx,(e,t)=>{if(e.node.session.id!==t.node.session.id||e.depth!==t.depth||e.groupDirectory!==t.groupDirectory||e.projectId!==t.projectId||e.archivedBucket!==t.archivedBucket||(e.renderContext??`project`)!==(t.renderContext??`project`)||e.mobileVariant!==t.mobileVariant||e.alwaysShowActions!==t.alwaysShowActions||e.shortcutNumber!==t.shortcutNumber||e.hasSessionSearchQuery!==t.hasSessionSearchQuery||e.normalizedSessionSearchQuery!==t.normalizedSessionSearchQuery||e.notifyOnSubtasks!==t.notifyOnSubtasks||e.nodeStructureKey!==t.nodeStructureKey||e.node.session.hasChildren!==t.node.session.hasChildren||Nx(e.node)!==Nx(t.node)||!Px(e.secondaryMeta,t.secondaryMeta)||e.liveSessionById!==t.liveSessionById&&zx(e.node,t.node,e.liveSessionById,t.liveSessionById)||e.pinnedSessionIds!==t.pinnedSessionIds&&Rx(e.node,t.node,e.pinnedSessionIds,t.pinnedSessionIds,e=>e.session.id)||e.settledSessionIds!==t.settledSessionIds&&e.settledSessionIds?.has(e.node.session.id)!==t.settledSessionIds?.has(t.node.session.id)||e.setSessionSettled!==t.setSessionSettled||e.expandedParents!==t.expandedParents&&Bx(e,t)||e.currentSessionId!==t.currentSessionId&&(Lx(e,e.currentSessionId,e.subtreeContainsActive)||Lx(t,t.currentSessionId,t.subtreeContainsActive))||e.editingId!==t.editingId&&(Lx(e,e.editingId,e.subtreeContainsEditing)||Lx(t,t.editingId,t.subtreeContainsEditing))||e.editTitle!==t.editTitle&&(Lx(e,e.editingId,e.subtreeContainsEditing)||Lx(t,t.editingId,t.subtreeContainsEditing))||e.copiedSessionId!==t.copiedSessionId&&(jc(e.node,e.copiedSessionId)||jc(t.node,t.copiedSessionId)))return!1;if(e.openSidebarMenuKey!==t.openSidebarMenuKey){let n=Ix(e),r=Ix(t);if(jc(e.node,n)||jc(t.node,r))return!1}if(e.renamingFolderId!==t.renamingFolderId){let n=Ix(e),r=Ix(t);if(jc(e.node,n)||jc(t.node,r))return!1}return e.setEditingId===t.setEditingId&&e.setEditTitle===t.setEditTitle&&e.handleSaveEdit===t.handleSaveEdit&&e.handleCancelEdit===t.handleCancelEdit&&e.toggleParent===t.toggleParent&&e.handleSessionSelect===t.handleSessionSelect&&e.handleSessionDoubleClick===t.handleSessionDoubleClick&&e.togglePinnedSession===t.togglePinnedSession&&e.handleShareSession===t.handleShareSession&&e.handleCopyShareUrl===t.handleCopyShareUrl&&e.handleUnshareSession===t.handleUnshareSession&&e.setOpenSidebarMenuKey===t.setOpenSidebarMenuKey&&e.getFoldersForScope===t.getFoldersForScope&&e.getSessionFolderId===t.getSessionFolderId&&e.removeSessionFromFolder===t.removeSessionFromFolder&&e.addSessionToFolder===t.addSessionToFolder&&e.createFolderAndStartRename===t.createFolderAndStartRename&&e.handleDeleteSession===t.handleDeleteSession&&e.renderSessionNode===t.renderSessionNode});function Hx(e){return e.stopPropagation()}function Ux(e){return e.stopPropagation()}function Wx(e){let t=(0,Q.c)(71),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==i||t[1]!==n||t[2]!==r){let e=n(`sessions.sidebar.session.untitled`);d=Qr,g=!!r,t[13]===i?_=t[14]:(_=e=>{e||i(null)},t[13]=i,t[14]=_),u=Yr,m=!1,h=`max-w-sm gap-5`,l=qr;let a;t[15]!==n||t[16]!==r?.archivedBucket?(a=r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.title`):n(`sessions.sidebar.dialogs.archiveSession.title`),t[15]=n,t[16]=r?.archivedBucket,t[17]=a):a=t[17],t[18]===a?p=t[19]:(p=(0,$.jsx)(Xr,{children:a}),t[18]=a,t[19]=p),c=Zr,f=r&&r.descendantCount>0?r.archivedBucket?r.descendantCount===1?n(`sessions.sidebar.dialogs.deleteSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.deleteSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r.descendantCount===1?n(`sessions.sidebar.dialogs.archiveSession.withOneSubtask`,{sessionTitle:r.session.title||e,count:r.descendantCount}):n(`sessions.sidebar.dialogs.archiveSession.withManySubtasks`,{sessionTitle:r.session.title||e,count:r.descendantCount}):r?.archivedBucket?n(`sessions.sidebar.dialogs.deleteSession.single`,{sessionTitle:r?.session.title||e}):n(`sessions.sidebar.dialogs.archiveSession.single`,{sessionTitle:r?.session.title||e}),t[0]=i,t[1]=n,t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d,t[7]=f,t[8]=p,t[9]=m,t[10]=h,t[11]=g,t[12]=_}else c=t[3],l=t[4],u=t[5],d=t[6],f=t[7],p=t[8],m=t[9],h=t[10],g=t[11],_=t[12];let v;t[20]!==c||t[21]!==f?(v=(0,$.jsx)(c,{children:f}),t[20]=c,t[21]=f,t[22]=v):v=t[22];let y;t[23]!==l||t[24]!==p||t[25]!==v?(y=(0,$.jsxs)(l,{children:[p,v]}),t[23]=l,t[24]=p,t[25]=v,t[26]=y):y=t[26];let b;t[27]!==o||t[28]!==a?(b=()=>o(!a),t[27]=o,t[28]=a,t[29]=b):b=t[29];let x=!a,S;t[30]===a?S=t[31]:(S=a?(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[30]=a,t[31]=S);let C;t[32]===n?C=t[33]:(C=n(`sessions.sidebar.dialogs.neverAsk`),t[32]=n,t[33]=C);let w;t[34]!==S||t[35]!==C||t[36]!==b||t[37]!==x?(w=(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":x,children:[S,C]}),t[34]=S,t[35]=C,t[36]=b,t[37]=x,t[38]=w):w=t[38];let T;t[39]===i?T=t[40]:(T=()=>i(null),t[39]=i,t[40]=T);let E;t[41]===n?E=t[42]:(E=n(`sessions.sidebar.dialogs.cancel`),t[41]=n,t[42]=E);let D;t[43]!==T||t[44]!==E?(D=(0,$.jsx)(`button`,{type:`button`,onClick:T,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:E}),t[43]=T,t[44]=E,t[45]=D):D=t[45];let O;t[46]===s?O=t[47]:(O=()=>void s(),t[46]=s,t[47]=O);let k;t[48]!==n||t[49]!==r?.archivedBucket?(k=r?.archivedBucket?n(`sessions.sidebar.bulkActions.delete`):n(`sessions.sidebar.bulkActions.archive`),t[48]=n,t[49]=r?.archivedBucket,t[50]=k):k=t[50];let A;t[51]!==O||t[52]!==k?(A=(0,$.jsx)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:k}),t[51]=O,t[52]=k,t[53]=A):A=t[53];let j;t[54]!==D||t[55]!==A?(j=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,A]}),t[54]=D,t[55]=A,t[56]=j):j=t[56];let M;t[57]!==w||t[58]!==j?(M=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[w,j]}),t[57]=w,t[58]=j,t[59]=M):M=t[59];let N;t[60]!==u||t[61]!==m||t[62]!==M||t[63]!==h||t[64]!==y?(N=(0,$.jsxs)(u,{showCloseButton:m,className:h,children:[y,M]}),t[60]=u,t[61]=m,t[62]=M,t[63]=h,t[64]=y,t[65]=N):N=t[65];let P;return t[66]!==d||t[67]!==N||t[68]!==g||t[69]!==_?(P=(0,$.jsx)(d,{open:g,onOpenChange:_,children:N}),t[66]=d,t[67]=N,t[68]=g,t[69]=_,t[70]=P):P=t[70],P}function Gx(e){let t=(0,Q.c)(57),{t:n}=Nr(),{value:r,setValue:i,showDeletionDialog:a,setShowDeletionDialog:o,onConfirm:s}=e,c=r?.archivedBucket===!0,l=r?.sessionCount??0,u;t[0]!==c||t[1]!==l||t[2]!==n?(u=n(c?l===1?`sessions.sidebar.dialogs.deleteSession.title`:`sessions.sidebar.dialogs.deleteSessions.title`:l===1?`sessions.sidebar.dialogs.archiveSession.title`:`sessions.sidebar.dialogs.archiveSessions.title`),t[0]=c,t[1]=l,t[2]=n,t[3]=u):u=t[3];let d=u,f;t[4]!==c||t[5]!==l||t[6]!==n?(f=n(c?l===1?`sessions.sidebar.dialogs.deleteSessions.singleDescription`:`sessions.sidebar.dialogs.deleteSessions.pluralDescription`:l===1?`sessions.sidebar.dialogs.archiveSessions.singleDescription`:`sessions.sidebar.dialogs.archiveSessions.pluralDescription`,{count:l}),t[4]=c,t[5]=l,t[6]=n,t[7]=f):f=t[7];let p=f,m=!!r,h;t[8]===i?h=t[9]:(h=e=>{e||i(null)},t[8]=i,t[9]=h);let g;t[10]===d?g=t[11]:(g=(0,$.jsx)(Xr,{children:d}),t[10]=d,t[11]=g);let _;t[12]===p?_=t[13]:(_=(0,$.jsx)(Zr,{children:p}),t[12]=p,t[13]=_);let v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(qr,{children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==o||t[18]!==a?(y=()=>o(!a),t[17]=o,t[18]=a,t[19]=y):y=t[19];let b=!a,x;t[20]===a?x=t[21]:(x=a?(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}),t[20]=a,t[21]=x);let S;t[22]===n?S=t[23]:(S=n(`sessions.sidebar.dialogs.neverAsk`),t[22]=n,t[23]=S);let C;t[24]!==S||t[25]!==y||t[26]!==b||t[27]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,onClick:y,className:`inline-flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":b,children:[x,S]}),t[24]=S,t[25]=y,t[26]=b,t[27]=x,t[28]=C):C=t[28];let w;t[29]===i?w=t[30]:(w=()=>i(null),t[29]=i,t[30]=w);let T;t[31]===n?T=t[32]:(T=n(`sessions.sidebar.dialogs.cancel`),t[31]=n,t[32]=T);let E;t[33]!==w||t[34]!==T?(E=(0,$.jsx)(`button`,{type:`button`,onClick:w,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:T}),t[33]=w,t[34]=T,t[35]=E):E=t[35];let D;t[36]===s?D=t[37]:(D=()=>void s(),t[36]=s,t[37]=D);let O;t[38]!==c||t[39]!==n?(O=n(c?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[38]=c,t[39]=n,t[40]=O):O=t[40];let k;t[41]!==D||t[42]!==O?(k=(0,$.jsx)(`button`,{type:`button`,onClick:D,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:O}),t[41]=D,t[42]=O,t[43]=k):k=t[43];let A;t[44]!==E||t[45]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[E,k]}),t[44]=E,t[45]=k,t[46]=A):A=t[46];let j;t[47]!==C||t[48]!==A?(j=(0,$.jsxs)(Jr,{className:`w-full sm:items-center sm:justify-between`,children:[C,A]}),t[47]=C,t[48]=A,t[49]=j):j=t[49];let M;t[50]!==j||t[51]!==v?(M=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[v,j]}),t[50]=j,t[51]=v,t[52]=M):M=t[52];let N;return t[53]!==m||t[54]!==M||t[55]!==h?(N=(0,$.jsx)(Qr,{open:m,onOpenChange:h,children:M}),t[53]=m,t[54]=M,t[55]=h,t[56]=N):N=t[56],N}function Kx(e){let t=(0,Q.c)(36),{t:n}=Nr(),{value:r,setValue:i,onConfirm:a}=e,o=!!r,s;t[0]===i?s=t[1]:(s=e=>{e||i(null)},t[0]=i,t[1]=s);let c;t[2]===n?c=t[3]:(c=n(`sessions.sidebar.dialogs.deleteFolder.title`),t[2]=n,t[3]=c);let l;t[4]===c?l=t[5]:(l=(0,$.jsx)(Xr,{children:c}),t[4]=c,t[5]=l);let u;t[6]!==n||t[7]!==r?(u=r&&(r.subFolderCount>0||r.sessionCount>0)?r.subFolderCount>0?r.subFolderCount===1?n(`sessions.sidebar.dialogs.deleteFolder.withOneSubfolder`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withManySubfolders`,{folderName:r.folderName,count:r.subFolderCount}):n(`sessions.sidebar.dialogs.deleteFolder.withContentsNoSubfolders`,{folderName:r.folderName}):n(`sessions.sidebar.dialogs.deleteFolder.single`,{folderName:r?.folderName??``}),t[6]=n,t[7]=r,t[8]=u):u=t[8];let d;t[9]===u?d=t[10]:(d=(0,$.jsx)(Zr,{children:u}),t[9]=u,t[10]=d);let f;t[11]!==l||t[12]!==d?(f=(0,$.jsxs)(qr,{children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===i?p=t[15]:(p=()=>i(null),t[14]=i,t[15]=p);let m;t[16]===n?m=t[17]:(m=n(`sessions.sidebar.dialogs.cancel`),t[16]=n,t[17]=m);let h;t[18]!==p||t[19]!==m?(h=(0,$.jsx)(`button`,{type:`button`,onClick:p,className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:m}),t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===n?g=t[22]:(g=n(`sessions.sidebar.bulkActions.delete`),t[21]=n,t[22]=g);let _;t[23]!==a||t[24]!==g?(_=(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`inline-flex h-8 items-center justify-center rounded-md bg-destructive px-3 typography-ui-label text-destructive-foreground hover:bg-destructive/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`,children:g}),t[23]=a,t[24]=g,t[25]=_):_=t[25];let v;t[26]!==_||t[27]!==h?(v=(0,$.jsxs)(Jr,{children:[h,_]}),t[26]=_,t[27]=h,t[28]=v):v=t[28];let y;t[29]!==v||t[30]!==f?(y=(0,$.jsxs)(Yr,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[f,v]}),t[29]=v,t[30]=f,t[31]=y):y=t[31];let b;return t[32]!==o||t[33]!==s||t[34]!==y?(b=(0,$.jsx)(Qr,{open:o,onOpenChange:s,children:y}),t[32]=o,t[33]=s,t[34]=y,t[35]=b):b=t[35],b}var qx=e=>{let t=(0,Q.c)(46),{selectedCount:n,scopeKey:r,scopeFolders:i,archivedBucket:a,onMoveToFolder:o,onCreateFolderAndMove:s,onRemoveFromFolder:c,canRemoveFromFolder:l,onDelete:u,onDone:d}=e,{t:f}=Nr(),p=!!r&&!a,m;t[0]!==a||t[1]!==f?(m=f(a?`sessions.sidebar.bulkActions.delete`:`sessions.sidebar.bulkActions.archive`),t[0]=a,t[1]=f,t[2]=m):m=t[2];let h=m,g;t[3]!==n||t[4]!==f?(g=f(`sessions.sidebar.bulkActions.selectedCount`,{count:n}),t[3]=n,t[4]=f,t[5]=g):g=t[5];let _;t[6]===g?_=t[7]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground whitespace-nowrap`,children:g}),t[6]=g,t[7]=_);let v;t[8]!==p||t[9]!==l||t[10]!==s||t[11]!==o||t[12]!==c||t[13]!==i||t[14]!==f?(v=p?(0,$.jsxs)(Ci,{children:[(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(vi,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":f(`sessions.sidebar.bulkActions.moveToFolder`),children:(0,$.jsx)(X,{name:`folder`,className:`h-4 w-4`})})})}),(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:f(`sessions.sidebar.bulkActions.moveToFolder`)})})]}),(0,$.jsxs)(bi,{align:`end`,className:`min-w-[180px]`,children:[i.length===0?(0,$.jsx)(xi,{disabled:!0,className:`text-muted-foreground`,children:f(`sessions.sidebar.folders.none`)}):i.map(e=>(0,$.jsx)(xi,{onClick:()=>o(e.id),children:(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:e.name})},e.id)),(0,$.jsx)(Si,{}),(0,$.jsxs)(xi,{onClick:s,children:[(0,$.jsx)(X,{name:`add`,className:`mr-1 h-4 w-4`}),f(`sessions.sidebar.folders.newFolderEllipsis`)]}),l?(0,$.jsxs)(xi,{onClick:c,className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(X,{name:`close`,className:`mr-1 h-4 w-4 text-inherit`}),f(`sessions.sidebar.folders.removeFromFolder`)]}):null]})]}):null,t[8]=p,t[9]=l,t[10]=s,t[11]=o,t[12]=c,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(y=J(`inline-flex h-7 w-7 items-center justify-center rounded-md text-destructive hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive/50`),t[16]=y):y=t[16];let b;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(X,{name:`delete-bin`,className:`h-4 w-4`}),t[17]=b):b=t[17];let x;t[18]!==h||t[19]!==u?(x=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:u,className:y,"aria-label":h,children:b})}),t[18]=h,t[19]=u,t[20]=x):x=t[20];let S;t[21]===h?S=t[22]:(S=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:h})}),t[21]=h,t[22]=S);let C;t[23]!==x||t[24]!==S?(C=(0,$.jsxs)(ni,{children:[x,S]}),t[23]=x,t[24]=S,t[25]=C):C=t[25];let w;t[26]===f?w=t[27]:(w=f(`sessions.sidebar.header.actions.exitSelection`),t[26]=f,t[27]=w);let T;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`}),t[28]=T):T=t[28];let E;t[29]!==d||t[30]!==w?(E=(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,onClick:d,className:`inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":w,children:T})}),t[29]=d,t[30]=w,t[31]=E):E=t[31];let D;t[32]===f?D=t[33]:(D=f(`sessions.sidebar.header.actions.exitSelection`),t[32]=f,t[33]=D);let O;t[34]===D?O=t[35]:(O=(0,$.jsx)(ei,{side:`top`,sideOffset:4,children:(0,$.jsx)(`p`,{children:D})}),t[34]=D,t[35]=O);let k;t[36]!==E||t[37]!==O?(k=(0,$.jsxs)(ni,{children:[E,O]}),t[36]=E,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==k||t[40]!==v||t[41]!==C?(A=(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[v,C,k]}),t[39]=k,t[40]=v,t[41]=C,t[42]=A):A=t[42];let j;return t[43]!==A||t[44]!==_?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-t border-border px-2.5 py-1.5`,children:[_,A]}),t[43]=A,t[44]=_,t[45]=j):j=t[45],j},Jx=e=>{let{t}=Nr(),{isInlineEditing:n,showDeletionDialog:r,foldersMap:i,addSessionsToFolder:a,removeSessionsFromFolders:o,createFolderAndStartRename:s,archiveSessions:c,setBulkDeleteConfirm:l}=e,u=Lb(e=>e.enabled),d=Lb(e=>e.selectedIds.size),f=d>0,p=Lb(e=>e.selectedIds),m=Lb(e=>e.scopeKey),h=Z.useCallback(()=>{Lb.getState().toggleMode()},[]),g=Z.useCallback(()=>{Lb.getState().disable()},[]),_=Z.useMemo(()=>{if(!f||typeof document>`u`)return!1;let e=!1,t=!1;for(let n of p){let r=document.querySelectorAll(`[data-session-row="${CSS.escape(n)}"]`);for(let n of r)n.getAttribute(`data-session-archived`)===`1`?t=!0:e=!0}return t&&!e},[f,p]),v=Z.useMemo(()=>{if(m)return m;if(!f||typeof document>`u`)return null;for(let e of p){let t=document.querySelector(`[data-session-row="${CSS.escape(e)}"]`)?.getAttribute(`data-session-scope`);if(t&&t.length>0)return t}return null},[f,p,m]),y=Z.useMemo(()=>v?i[v]??[]:[],[i,v]),b=Z.useMemo(()=>{if(!v||!f)return!1;let e=i[v]??[];for(let t of e)for(let e of t.sessionIds)if(p.has(e))return!0;return!1},[i,v,f,p]),x=Z.useCallback(e=>{!v||!f||a(v,e,Array.from(p))},[a,p,v,f]),S=Z.useCallback(()=>{if(!v||!f)return;let e=s(v);e&&a(v,e.id,Array.from(p))},[a,s,p,v,f]),C=Z.useCallback(()=>{!v||!f||o(v,Array.from(p))},[o,p,v,f]),w=Z.useCallback(async()=>{let e=Array.from(p);if(e.length!==0){if(_)Xc({sessionIds:e,message:e.length===1?t(`sessions.sidebar.bulkActions.deletedSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.deletedPlural`,{count:e.length}),undoLabel:t(`sessions.sidebar.undo`),commitFailedMessage:e.length===1?t(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:e.length}):t(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:e.length})});else{let{archivedIds:n,failedIds:r}=await c(e);n.length>0&&vl({sessionIds:n,message:n.length===1?t(`sessions.sidebar.bulkActions.archivedSingle`,{count:n.length}):t(`sessions.sidebar.bulkActions.archivedPlural`,{count:n.length}),undoLabel:t(`sessions.sidebar.undo`),settingsLabel:t(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:n.length===1?t(`sessions.sidebar.session.archive.undoFailed`):t(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:n.length})}),r.length>0&&Y.error(r.length===1?t(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:r.length}):t(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:r.length}))}Lb.getState().clear()}},[c,_,p,t]),T=Z.useCallback(()=>{if(!f)return;let e=p.size;if(!_||!r){w();return}l({sessionCount:e,archivedBucket:_})},[_,w,p,r,l,f]),E=Z.useCallback(async()=>{l(null),await w()},[w]);return Z.useEffect(()=>{if(!u)return;let e=typeof navigator<`u`&&/Macintosh|Mac OS X/.test(navigator.userAgent||``),t=t=>{if(n)return;let r=t.target;if(r&&(r.tagName===`INPUT`||r.tagName===`TEXTAREA`||r.isContentEditable))return;let i=e?t.metaKey:t.ctrlKey;if(t.key===`Escape`){t.preventDefault(),Lb.getState().disable();return}if(i&&t.key===`Backspace`){t.preventDefault(),T();return}if(i&&(t.key===`a`||t.key===`A`)){let e=typeof document<`u`?Array.from(document.querySelectorAll(`[data-session-row]`)):[];if(e.length===0)return;t.preventDefault();let n=Lb.getState().scopeKey??e[0]?.getAttribute(`data-session-scope`)??null,r=e.filter(e=>!n||e.getAttribute(`data-session-scope`)===n).map(e=>e.getAttribute(`data-session-row`)).filter(e=>typeof e==`string`&&e.length>0);if(r.length===0)return;Lb.getState().replaceAll(r,n||null)}};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[T,n,u]),{selectionModeEnabled:u,hasSelection:f,selectedIdsSize:d,bulkScopeIsArchived:_,derivedSelectionScope:v,bulkScopeFolders:y,bulkCanRemoveFromFolder:b,handleToggleSelectionMode:h,handleExitSelectionMode:g,handleBulkMoveToFolder:x,handleBulkCreateFolderAndMove:S,handleBulkRemoveFromFolder:C,handleBulkDelete:T,confirmBulkDelete:E}},Yx=[{id:`tasks`,icon:`list-check-2`,labelKey:`sessions.sidebar.view.tasks`},{id:`projects`,icon:`folder-tree`,labelKey:`sessions.sidebar.projectsTitle`}],Xx=Z.memo(function(e){let t=(0,Q.c)(9),{value:n,onChange:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`sessions.sidebar.view.aria`),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=Yx.map(e=>{let t=n===e.id,a=i(e.labelKey);return(0,$.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"aria-label":a,title:a,onClick:()=>r(e.id),className:J(`relative flex h-6 items-center rounded-full text-[12px] font-medium leading-none`,`pl-1.5 transition-[background-color,color,box-shadow,padding] duration-200 ease-out motion-reduce:transition-none`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,t?`bg-background pr-2.5 text-foreground shadow-sm`:`pr-1.5 text-muted-foreground hover:text-foreground`),children:[(0,$.jsx)(X,{name:e.icon,className:`size-4 shrink-0`}),(0,$.jsx)(`span`,{"aria-hidden":!t,className:J(`grid transition-[grid-template-columns,margin,opacity] duration-200 ease-out motion-reduce:transition-none`,t?`ml-1.5 grid-cols-[1fr] opacity-100`:`ml-0 grid-cols-[0fr] opacity-0`),children:(0,$.jsx)(`span`,{className:`min-w-0 overflow-hidden whitespace-nowrap`,children:a})})]},e.id)}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":a,className:`-ml-2 inline-flex h-7 items-center rounded-full bg-[color-mix(in_srgb,var(--surface-foreground)_7%,transparent)] p-0.5`,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),Zx=e=>{let t=(0,Q.c)(2),{count:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`span`,{className:`mr-2 typography-micro tabular-nums text-muted-foreground/70`,children:n}),t[0]=n,t[1]=r),r};function Qx(e){let t=(0,Q.c)(19),{items:n,renderTaskRow:r,onSessionsReordered:i}=e,{t:a}=Nr(),o;t[0]===n.active?o=t[1]:(o=n.active.map(eS),t[0]=n.active,t[1]=o);let s=o,c;t[2]===s?c=t[3]:(c=new Map(s.map($x)),t[2]=s,t[3]=c);let l=c;if(n.active.length===0){let e;t[4]===a?e=t[5]:(e=a(`sessions.sidebar.task.empty`),t[4]=a,t[5]=e);let n;return t[6]===e?n=t[7]:(n=(0,$.jsx)(`div`,{className:`space-y-0.5`,children:(0,$.jsx)(`div`,{className:ko,children:e})}),t[6]=e,t[7]=n),n}let u;t[8]!==n.active||t[9]!==r?(u=n.active.map(r),t[8]=n.active,t[9]=r,t[10]=u):u=t[10];let d=u,f;t[11]!==l||t[12]!==n.active.length||t[13]!==i||t[14]!==d||t[15]!==s?(f=i&&n.active.length>1?(0,$.jsx)(Yc,{scopeKey:`task-active`,sessionIds:s,folderIdBySessionId:l,onSessionDroppedOnFolder:tS,onSessionsReordered:i,children:d}):d,t[11]=l,t[12]=n.active.length,t[13]=i,t[14]=d,t[15]=s,t[16]=f):f=t[16];let p;return t[17]===f?p=t[18]:(p=(0,$.jsx)(`div`,{className:`space-y-0.5`,children:f}),t[17]=f,t[18]=p),p}function $x(e){return[e,null]}function eS(e){return e.node.session.id}var tS=()=>{};function nS(e){let t=(0,Q.c)(20),{items:n,open:r,onToggle:i,onShowMore:a,renderTaskRow:o}=e,{t:s}=Nr();if(n.settledTotal===0)return null;let c=n.settledTotal-n.settled.length,l=Math.min(30,c),u;t[0]===s?u=t[1]:(u=s(`sessions.sidebar.task.shelf.settled`),t[0]=s,t[1]=u);let d;t[2]===n.settledTotal?d=t[3]:(d=(0,$.jsx)(Zx,{count:n.settledTotal}),t[2]=n.settledTotal,t[3]=d);let f;t[4]!==i||t[5]!==r||t[6]!==u||t[7]!==d?(f=(0,$.jsx)(_y,{title:u,onToggle:i,expanded:r,className:`pt-2 pb-1`,accessory:d}),t[4]=i,t[5]=r,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==n.settled||t[10]!==l||t[11]!==a||t[12]!==r||t[13]!==c||t[14]!==o||t[15]!==s?(p=r?(0,$.jsxs)(`div`,{className:`max-h-[40vh] space-y-px overflow-y-auto overscroll-contain`,children:[n.settled.map(o),c>0?(0,$.jsx)(`button`,{type:`button`,onClick:a,className:`${ko} rounded-md hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:s(l===1?`sessions.sidebar.group.showMoreSingle`:`sessions.sidebar.group.showMorePlural`,{count:l})}):null]}):null,t[9]=n.settled,t[10]=l,t[11]=a,t[12]=r,t[13]=c,t[14]=o,t[15]=s,t[16]=p):p=t[16];let m;return t[17]!==f||t[18]!==p?(m=(0,$.jsxs)(`div`,{className:`shrink-0 px-3 pb-1`,children:[f,p]}),t[17]=f,t[18]=p,t[19]=m):m=t[19],m}var rS={ids:[],baseline:{}},iS=(e,t)=>e!==void 0&&t!==void 0&&e.activityAt===t.activityAt&&e.running===t.running&&e.attention===t.attention,aS=(e,t,n,r)=>{if(r.ids.length===0)return e;let i=new Map;for(let n of e)i.set(t(n),n);let a=[],o=new Set;for(let e of r.ids){let t=i.get(e);!t||o.has(e)||!iS(r.baseline[e],n(t))||(a.push(t),o.add(e))}if(a.length<2)return e;let s=0,c=e.map(e=>o.has(t(e))?a[s++]:e);return c.every((t,n)=>t===e[n])?e:c},oS=(e,t,n,r)=>{let i=e.indexOf(t),a=e.indexOf(n);if(i<0||a<0||i===a)return null;let o=[...e];o.splice(i,1),o.splice(a,0,t);let s={};for(let e of o){let t=r(e);t&&(s[e]=t)}return{ids:o,baseline:s}},sS=(e,t,n)=>{let r=[],i=new Set,a=e=>{let t=P(e??null);!t||i.has(t)||(i.add(t),r.push(t))};if(a(e),a(n?.workspaceRoot),a(n?.currentDirectory),n?.includeWorktrees!==!1)for(let e of t)a(e.path);return r},cS=(e,t,n,r)=>{let i=e.filter(e=>e.sessionId===t);if(i.length===0)return null;if(n){let e=i.find(e=>e.projectId===n);if(e)return e}if(r){let e=i.find(e=>e.projectId===r);if(e)return e}return i[0]??null},lS=({currentSessionId:e,focus:t,pinnedFocuses:n,projectFocuses:r,fallbackProjectId:i})=>{if(!e)return null;let a=t?.sessionId===e,o=a?t.projectId:null,s=cS(r,e,o,i)??{scope:`project`,sessionId:e,projectId:i};return!a||t.scope===`project`?s:cS(n,e,o,i)??s};function uS(e,t,n=null){if(!e||e.scope!==`project`||!e.sessionId)return null;if(e.projectId){let n=t.find(t=>t.sessionId===e.sessionId&&t.projectId===e.projectId);if(n)return n}if(n){let r=t.find(t=>t.sessionId===e.sessionId&&t.projectId===n);if(r)return r}return t.find(t=>t.sessionId===e.sessionId)??null}var dS=`yuri.sessions.sidebarView`,fS=`yuri.sessions.projectCollapse`,pS=`yuri.sessions.groupOrder`,mS=`yuri.sessions.groupCollapse`,hS=`yuri.sessions.activeSessionByProject`,gS=`yuri.sessions.expandedParents.v2`,_S=`yuri.sessions.expandedParents`,vS=ct(Ue()),yS=e=>{try{let t=vS.getItem(e);if(!t)return new Set;let n=JSON.parse(t);return new Set(Array.isArray(n)?n.filter(e=>typeof e==`string`):[])}catch{return new Set}},bS=e=>{try{let t=vS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{typeof t==`string`&&t.length>0&&r.set(e,t)}),r}catch{return new Map}},xS=e=>{try{let t=vS.getItem(e);if(!t)return new Map;let n=JSON.parse(t),r=new Map;return!n||typeof n!=`object`||Array.isArray(n)||Object.entries(n).forEach(([e,t])=>{Array.isArray(t)&&r.set(e,t.filter(e=>typeof e==`string`))}),r}catch{return new Map}},SS=(e,t,n)=>{let r=new Set;for(let t of e){let e=P(t.path)?.toLowerCase();e&&r.add(e)}if(n?.includeWorktrees===!1)return r;for(let e of t.values())for(let t of e){let e=P(t.path)?.toLowerCase();e&&r.add(e)}return r},CS=(e,t,n)=>{if(e.time?.archived)return!0;let r=P(hn(e))?.toLowerCase();return r?t.size===0?n?.allowEmptyDirectorySet??!0:t.has(r):n?.allowUnknownDirectory??!0},wS=new Set,TS=[],ES={},DS=(e,t)=>{let n=Z.useRef(e);return n.current=e,Z.useMemo(()=>(...e)=>n.current(...e),[t])},OS=Z.memo(function(e){let t=(0,Q.c)(3),{onOpenChange:n}=e,r=El(pe(AS)),i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(jl,{open:!0,onOpenChange:n,...r}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}),kS=Z.memo(function({mobileVariant:e=!1,onSessionSelected:t,allowReselect:n=!1,hideDirectoryControls:r=!1,showOnlyMainWorkspace:i=!1,isVisible:a=!0}){let{t:o}=Nr(),[s,l]=Z.useState(!1),[u,d]=Z.useState(!1),[f,p]=Z.useState(``),h=Z.useRef(null),g=Z.useRef(null),[_,v]=Z.useState(null),[b,x]=Z.useState(``),[S,C]=Z.useState(null),[w,T]=Z.useState(new Set),D=Z.useMemo(()=>vS,[]),[O,k]=Z.useState(new Set),[A,j]=Z.useState(new Map),[M,N]=Z.useState(new Map),F=K(e=>e.isNewWorktreeDialogOpen),I=K(e=>e.setNewWorktreeDialogOpen),[L,R]=Z.useState(null),[z,ee]=Z.useState(null),[B,te]=Z.useState(``),[ne,re]=Z.useState(null),[ie,ae]=Z.useState(null),[oe,V]=Z.useState(null),H=Cr(),se=en(),U=rl(),ce=Zc(),le=pl(),ue=qn(),de=K(e=>e.sidebarView),fe=K(e=>e.setSidebarView);Z.useEffect(()=>{let e=Ue().getItem(dS);e!==null&&(Ue().removeItem(dS),K.getState().sidebarView===`projects`&&yc(e)!==`projects`&&fe(yc(e)))},[fe]);let[pe,me]=Z.useState({settledOpen:!1,settledLimit:30}),he=Z.useRef(new Map),ge=Z.useRef(new Map),_e=G(e=>{fe(e),Pe({sidebarView:e})}),[ve,ye]=Z.useState(()=>yS(mS)),[be,xe]=Z.useState(()=>xS(pS)),[Se,Ce]=Z.useState(()=>bS(hS)),we=Z.useRef(null);Z.useEffect(()=>c(e=>{m(e)&&(we.current=null,ye(yS(mS)),xe(xS(pS)),Ce(bS(hS)),k(yS(fS)),T(yS(gS)))}),[]);let[Te,Ee]=Z.useState(new Map),De=Z.useRef(0),Oe=W(e=>e.homeDirectory),ke=W(e=>e.currentDirectory),Ae=W(e=>e.setDirectory),je=$t(e=>e.projects),Me=Z.useMemo(()=>je.filter(e=>!e.hostId),[je]),Ne=Z.useMemo(()=>je.filter(e=>e.hostId).map(Er),[je]),[Fe,Ie]=Z.useState(()=>new Map),Le=G((e,t)=>{Ie(n=>{if(!t.length&&!n.has(e))return n;let r=new Map(n);return t.length?r.set(e,t):r.delete(e),r})}),Re=Dc(a),[ze,Be]=Z.useState(new Map),Ve=G((e,t)=>{Be(n=>JSON.stringify(n.get(e))===JSON.stringify(t)?n:new Map(n).set(e,t))}),He=$t(e=>e.activeProjectId),We=$t(e=>e.removeProject),Ge=$t(e=>e.setActiveProjectIdOnly),Ke=$t(e=>e.updateProjectMeta),qe=$t(e=>e.reorderProjectsById),Je=K(e=>e.setActiveMainTab),Ye=K(e=>e.activeMainTab),Xe=ja(),Ze=K(e=>e.setSettingsDialogOpen),Qe=K(e=>e.toggleHelpDialog),$e=K(e=>e.setSessionSwitcherOpen),et=K(e=>e.setScheduledTasksDialogOpen),tt=K(e=>e.notifyOnSubtasks),nt=K(e=>e.showDeletionDialog),rt=K(e=>e.setShowDeletionDialog),it=Aa(f,120),at=Z.useMemo(()=>it.trim().toLowerCase(),[it]),ot=at.length>0,st=El(e=>e.available&&(e.runtimeType===`desktop`||e.runtimeType===`web`)),ct=Sn(e=>e.collapsedFolderIds),lt=Sn(e=>e.foldersMap),ut=Sn(e=>e.sessionOrderByScope),dt=Sn(e=>e.sessionOrderActivityByScope),ft=Sn(e=>e.getFoldersForScope),pt=Sn(e=>e.createFolder),mt=Sn(e=>e.renameFolder),ht=Sn(e=>e.deleteFolder),gt=Sn(e=>e.addSessionToFolder),_t=Sn(e=>e.addSessionsToFolder),vt=Sn(e=>e.removeSessionFromFolder),yt=Sn(e=>e.removeSessionsFromFolders),bt=Sn(e=>e.toggleFolderCollapse),xt=Sn(e=>e.getSessionFolderId),Ct=Sn(e=>e.reorderSessions);iy({isSessionSearchOpen:a&&u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchContainerRef:h});let wt=Z.useMemo(()=>new Map,[]),Tt=bn({enabled:a,includeChildren:!0}),Et=bc({enabled:a}),Dt=vc({enabled:a}),Ot=On(e=>a?e.index.session.unseenCount:ES),kt=Z.useMemo(()=>E(),[]),At=on(e=>e.status),jt=on(e=>e.activeSessions),Mt=on(e=>e.archivedSessions),Nt=on(e=>e.loadingDirectories.size>0||e.refreshingDirectories.size>0),Pt=on(e=>e.archivedLoadingDirectories),Ft=Z.useDeferredValue(jt),It=Z.useDeferredValue(Mt),Lt=Vn(e=>e.currentSessionId),Vt=Tn(e=>e.remoteSession!==null)?null:Lt,Ht=uo(e=>e.focus),Ut=Z.useSyncExternalStore(Bt,Rt,Rt),Wt=Vn(e=>!!e.newSessionDraft?.open),Gt=Vn(e=>e.newSessionDraft?.open&&!e.currentSessionId?e.newSessionDraft.selectedProjectId??null:null),Kt=Z.useMemo(()=>!e&&Ye===`chat`&&Gt&&Ut.sessionId===null?{projectId:Gt,revision:Ut.revision}:null,[e,Ye,Gt,Ut]),qt=Vn(e=>e.setCurrentSession),Jt=Vn(e=>e.updateSessionTitle),Yt=Vn(e=>e.shareSession),Xt=Vn(e=>e.unshareSession),Zt=Vn(e=>e.worktreeMetadata),nn=Vn(e=>e.availableWorktreesByProject),an=Vn(e=>e.openNewSessionDraft),sn=G(t=>{let n=Ne.find(e=>e.id===(t?.selectedProjectId??$t.getState().activeProjectId));if(n){uc(n,e).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}Tn.getState().clearRemoteSession(),an(t),kt&&window.dispatchEvent(new CustomEvent(`yuri:navigate`,{detail:{view:`chat`}}))}),cn=Z.useMemo(()=>SS(Me,nn,{includeWorktrees:!kt}),[nn,kt,Me]),ln=Z.useMemo(()=>{let e=new Map(Tt.map(e=>[e.id,e])),t=Ft.map(t=>{let n=e.get(t.id);return n?Xn(n,t):t}),n=new Set(t.map(e=>e.id));return Tt.forEach(e=>{n.has(e.id)||t.push(e)}),t.filter(e=>CS(e,cn,{allowUnknownDirectory:!kt,allowEmptyDirectorySet:!kt}))},[Ft,kt,cn,Tt]),un=Z.useMemo(()=>Tt.map(e=>{let t=P(e.directory??null)??``;return`${e.id}:${e.title??``}:${+!!e.time?.archived}:${t}`}).join(`|`),[Tt]),dn=Z.useRef(Tt);Z.useEffect(()=>{dn.current=Tt},[un,Tt]);let fn=Z.useMemo(()=>new Map(Tt.map(e=>[e.id,e])),[Tt]);Z.useEffect(()=>{let e=null,t=St(t=>{t.type===`scheduled-task-ran`&&(e&&clearTimeout(e),e=setTimeout(()=>{let e=$t.getState().projects.find(e=>e.id===t.projectId),n=P(e?.path??null);if(!n)return;let r=[n];(Vn.getState().availableWorktreesByProject.get(n)??[]).forEach(e=>{let t=P(e.path);t&&r.push(t)}),Jn(r,dn.current)},500))});return()=>{e&&clearTimeout(e),t()}},[]);let pn=Z.useMemo(()=>y(),[]),mn=gu(e=>e.sidebarBrandName.trim().length>0),{isTablet:gn,isDesktop:vn}=fi(),yn=e||gn,{buildGroupSearchText:xn,filterSessionNodesForSearch:Cn,buildGroupedSessions:wn}=fl({homeDirectory:Oe,worktreeMetadata:Zt,pinnedSessionIds:H,gitBranches:wt,isVSCode:kt}),{scheduleCollapsedProjectsPersist:En,hasRestoredProjectCollapse:Dn}=dy({isVSCode:kt,safeStorage:D,keys:{sessionExpanded:gS,sessionExpandedLegacy:_S,projectCollapse:fS,groupOrder:pS,projectActiveSession:hS,groupCollapse:mS},groupOrderByProject:be,activeSessionByProject:Se,collapsedGroups:ve,setExpandedParents:T,setCollapsedProjects:k}),kn=Z.useMemo(()=>[...ln].sort((e,t)=>Do(e,t,H)),[ln,H]),An=Z.useMemo(()=>{let e=new Map;return kn.forEach(t=>{let n=t.parentID;if(!n)return;let r=e.get(n)??[];r.push(t),e.set(n,r)}),e.forEach(e=>e.sort((e,t)=>Do(e,t,H))),e},[kn,H]),jn=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noSessions.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noSessions.description`)})]}),Mn=Z.useMemo(()=>Me.find(e=>e.id===S)??null,[Me,S]),Pn=Z.useCallback(e=>{S&&Ke(S,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},[S,Ke]),Fn=Z.useCallback(()=>{I(!0)},[I]),In=Z.useCallback((t,n)=>{if(Je(`chat`),e&&$e(!1),!n?.remote){if(n?.sessionId){qt(n.sessionId,t);return}an({directoryOverride:t,preserveDirectoryOverride:!0})}},[e,an,Je,qt,$e]),Ln=G(()=>{let e=El.getState();if(e.available&&e.info){l(!0);return}e.checkForUpdates().then(()=>{let{available:e,error:t}=El.getState();if(t){Y.error(o(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}if(!e){Y.success(o(`sessions.sidebar.updateCheck.latestVersion`));return}l(!0)})}),Rn=Z.useCallback(()=>{e&&$e(!1),Ze(!0)},[e,$e,Ze]),zn=G(()=>{let t=Ne.find(e=>e.id===$t.getState().activeProjectId);if(t){uc(t,e).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}Tn.getState().clearRemoteSession(),Je(`chat`),an(),e&&$e(!1)}),Bn=Z.useCallback(()=>{if(!e){Je(`schedule`);return}et(!0),$e(!1)},[e,Je,et,$e]),Hn=Z.useCallback(()=>{Hr(),e&&$e(!1)},[e,$e]),Un=Vn(e=>e.archiveSession),Wn=Vn(e=>e.archiveSessions),{copiedSessionId:Gn,handleSessionSelect:Yn,handleSessionDoubleClick:Zn,handleSaveEdit:Qn,handleCancelEdit:$n,handleShareSession:er,handleCopyShareUrl:tr,handleUnshareSession:nr,handleDeleteSession:rr,confirmDeleteSession:ir}=ay({activeProjectId:He,currentDirectory:ke,currentSessionId:Vt,mobileVariant:e,allowReselect:n,onSessionSelected:t,isSessionSearchOpen:u,sessionSearchQuery:f,setSessionSearchQuery:p,setIsSessionSearchOpen:d,setActiveProjectIdOnly:Ge,setDirectory:Ae,setActiveMainTab:Je,setSessionSwitcherOpen:$e,setCurrentSession:qt,updateSessionTitle:Jt,shareSession:Yt,unshareSession:Xt,archiveSession:Un,archiveSessions:Wn,childrenMap:An,showDeletionDialog:nt,setDeleteSessionConfirm:re,deleteSessionConfirm:ne,setEditingId:v,setEditTitle:x,editingId:_,editTitle:b}),ar=Z.useCallback((e,t,n,r=`project`)=>{Tn.getState().clearRemoteSession();let i={sessionId:e,scope:r,projectId:n??null};if(e===Vt){zt(e),Dx(i),Yn(e,t,n);return}Tx(i,()=>Yn(e,t,n))},[Yn,Vt]);Z.useEffect(()=>()=>{wx()},[]);let or=Z.useCallback(()=>{if(!ie)return;let{scopeKey:e,folderId:t}=ie;ae(null),ht(e,t)},[ie,ht]);Z.useEffect(()=>{if(!Vt)return;let e=ln.find(e=>e.id===Vt)?.parentID;if(!e)return;let t=[`project:active:${e}`,`project:archived:${e}`,`recent:active:${e}`,`recent:archived:${e}`];T(e=>{if(t.every(t=>e.has(t)))return e;let n=new Set(e);t.forEach(e=>n.add(e));try{D.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return n})},[Vt,ln,D]);let lr=Z.useCallback(e=>{T(t=>{let n=new Set(t);n.has(e)?n.delete(e):n.add(e);try{D.setItem(gS,JSON.stringify(Array.from(n)))}catch{}return n})},[D]),ur=Z.useCallback((e,t)=>{if(!e)return null;t&&ct.has(t)&&bt(t);let n=pt(e,o(`sessions.sidebar.folder.newFolderName`),t);return ee(n.id),te(n.name),n},[ct,bt,pt,o]),dr=G(ar),fr=G(Zn),pr=G(Qn),mr=G($n),gr=G(er),_r=G(tr),vr=G(nr),yr=G(rr),br=G(ur),xr=G((e,t,n,r)=>{let i=Hc(),a=Math.max(i,n)+7;if(N(e=>{let r=Math.max(i,e.get(t)??i,n),a=new Map(e);return a.set(t,r+7),a}),e.isArchivedBucket||a<r)return;let o=P(e.directory??null);if(!o)return;let s=on.getState().activePaginationByDirectory.get(o);s?.hasMore&&!s.loadingMore&&rn(o)}),Sr=G(e=>{N(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})}),wr=G(e=>{N(t=>{let n=!1,r=new Map(t),i=`${e}:`;for(let e of r.keys())e.startsWith(i)&&(r.delete(e),n=!0);return n?r:t})}),Tr=Z.useMemo(()=>e=>{let t=Me.find(t=>t.id===e),n=P(t?.path??null);if(!n)return[];let r=[n];return kt||(nn.get(n)??[]).forEach(e=>{let t=P(e.path);t&&r.push(t)}),r},[nn,kt,Me]),Dr=G(e=>{let t=Tr(e);if(t.length===0)return;let n=on.getState().loadedDirectories,r=t.filter(e=>!n.has(e));r.length!==0&&Jn(r,dn.current)}),Or=G(e=>{let t=Me.find(t=>t.id===e);t&&(async()=>{let e=[];if(!kt)try{e=(await zs({id:t.id,path:t.path})).worktrees}catch(n){console.warn(`[SessionSidebar] Worktree refresh before session sync failed:`,n);let r=P(t.path);e=r?Vn.getState().availableWorktreesByProject.get(r)??[]:[]}let n=sS(t.path,e,{currentDirectory:ke,workspaceRoot:t.path,includeWorktrees:!kt});n.length!==0&&await _n(n,dn.current)})()});Z.useEffect(()=>{if(!Dn)return;let e=on.getState(),t=Me.flatMap(t=>O.has(t.id)?[]:Tr(t.id).filter(t=>!e.loadedDirectories.has(t)&&!e.loadingDirectories.has(t)&&!e.refreshingDirectories.has(t)));t.length>0&&Jn(t,dn.current)},[O,Tr,Dn,Me]);let kr=G(()=>{De.current=Date.now()+150,N(new Map),k(()=>{let e=new Set(Me.map(e=>e.id));try{D.setItem(fS,JSON.stringify(Array.from(e)))}catch{}return kt||En(e),e})}),Ar=G(()=>{De.current=Date.now()+150,N(new Map),k(()=>{let e=new Set;try{D.setItem(fS,JSON.stringify([]))}catch{}return kt||En(e),e});let e=on.getState().loadedDirectories,t=Me.flatMap(t=>Tr(t.id).filter(t=>!e.has(t)));t.length>0&&Jn(t,dn.current)}),jr=G(e=>{De.current=Date.now()+150,wr(e),k(t=>{let n=new Set(t);n.has(e)?(n.delete(e),queueMicrotask(()=>Dr(e))):n.add(e);try{D.setItem(fS,JSON.stringify(Array.from(n)))}catch{}return kt||En(n),n})}),Mr=G(e=>{De.current=Date.now()+150,Dr(e),k(t=>{if(!t.has(e))return t;let n=new Set(t);n.delete(e);try{D.setItem(fS,JSON.stringify(Array.from(n)))}catch{}return kt||En(n),n})}),Pr=Z.useMemo(()=>Me.map(e=>({...e,normalizedPath:P(e.path)})).filter(e=>!!e.normalizedPath),[Me]),Fr=Z.useMemo(()=>new Map(Pr.map(e=>[e.id,cr(e.normalizedPath)||e.normalizedPath])),[Pr]),Ir=Z.useMemo(()=>Pr.map(e=>e.normalizedPath),[Pr]),Lr=Z.useMemo(()=>{let e=new Set(Pr.map(e=>e.normalizedPath));if(!kt)for(let t of nn.values())for(let n of t){let t=P(n.path);t&&e.add(t)}return[...e].sort()},[nn,kt,Pr]),Rr=Z.useRef(null);Z.useEffect(()=>{let e=new Set(Lr),t=Rr.current;if(Rr.current=e,!t)return;let n=Lr.filter(e=>!t.has(e));if(n.length===0)return;let r=on.getState().loadedDirectories,i=P(ke),a=Pr.find(e=>e.id===He)??Pr.find(e=>e.normalizedPath===i)??null,o=new Set;i&&o.add(i),a?.normalizedPath&&(o.add(a.normalizedPath),kt||(nn.get(a.normalizedPath)??[]).forEach(e=>{let t=P(e.path);t&&o.add(t)}));let s=n.filter(e=>o.has(e)&&!r.has(e));s.length!==0&&Jn(s,dn.current)},[He,nn,ke,kt,Pr,Lr]);let zr=Xi(a?Ir:TS);py({normalizedProjects:Pr,activeProjectId:He,gitRepoStatus:zr,setProjectRepoStatus:j,setProjectRootBranches:Ee,enabled:a});let Br=Z.useMemo(()=>Nl(ln,Pr,nn,kt,It),[It,nn,kt,Pr,ln]),{getSessionsForProject:Vr,getArchivedSessionsForProject:Ur}=my({ownership:Br}),Wr=Nt||At===`idle`||At===`loading`,Gr=Z.useRef(!1);He&&A.has(He)&&(Gr.current=!!A.get(He));let Kr=tn(e=>e.projectSortOrder),qr=Z.useMemo(()=>nl(Pr,Kr),[Pr,Kr]),{projectSections:Jr,groupSearchDataByGroup:Yr,sectionsForRender:Xr,searchMatchCount:Zr}=ty({normalizedProjects:qr,getSessionsForProject:Vr,getArchivedSessionsForProject:Ur,availableWorktreesByProject:nn,projectRepoStatus:A,projectRootBranches:Te,lastRepoStatus:Gr.current,buildGroupedSessions:wn,hasSessionSearchQuery:ot,normalizedSessionSearchQuery:at,filterSessionNodesForSearch:Cn,buildGroupSearchText:xn,foldersMap:lt}),Qr=(0,$.jsxs)(`div`,{className:`py-6 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-semibold`,children:o(`sessions.sidebar.empty.noMatches.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1`,children:o(`sessions.sidebar.empty.noMatches.description`)})]});ny({projectSections:Jr,activeProjectId:He,activeSessionByProject:Se,setActiveSessionByProject:Ce,currentSessionId:Vt,handleSessionSelect:Yn,newSessionDraftOpen:Wt,mobileVariant:e,openNewSessionDraft:an,setActiveMainTab:Je,setSessionSwitcherOpen:$e});let{getOrderedGroups:$r}=ry(be),ei=Z.useRef(!1);Z.useEffect(()=>{if(ei.current||Jr.length===0)return;let e=Jr.flatMap(e=>e.groups.filter(e=>e.isArchivedBucket).map(t=>`${e.project.id}:${t.id}`));e.length>0&&ye(t=>new Set([...t,...e])),ei.current=!0},[Jr]);let ti=Z.useMemo(()=>{let e=new Map,t=new Map;return Jr.forEach(n=>{let r=cr(n.project.normalizedPath)||n.project.normalizedPath;n.groups.forEach(i=>{let a=i.branch&&i.branch!==`HEAD`&&i.branch!==r?i.branch:null,o={projectLabel:r,branchLabel:a},s=r=>{r.forEach(r=>{let a=n.project.normalizedPath.length;a<(t.get(r.session.id)??-1)||(e.set(r.session.id,{node:r,projectId:n.project.id,groupDirectory:i.directory,secondaryMeta:o}),t.set(r.session.id,a),r.children.length>0&&s(r.children))})};s(i.sessions)})}),e},[Jr]);Z.useLayoutEffect(()=>{if(!Vt){Dx(null);return}let e=uo.getState().focus;if(e?.sessionId===Vt){e.scope===`project`&&!e.projectId&&Dx({...e,projectId:ti.get(Vt)?.projectId??null});return}Dx({scope:`project`,sessionId:Vt,projectId:ti.get(Vt)?.projectId??null})},[Vt,ti]);let ni=Z.useMemo(()=>kt?[]:Tc(ln,H,ut[xc]),[kt,H,ln,ut]),ri=G((e,t)=>{_||Ct(xc,ci.map(e=>e.node.session.id),e,t,{}).catch(()=>Y.error(o(`sessions.order.saveFailed`)))}),ii=Z.useMemo(()=>ot?[]:kc(ln,H,Dt,Ot),[ot,H,Dt,ln,Ot]),{pinnedItems:ai,inProgressItems:oi}=Z.useMemo(()=>{let e=e=>{let t=ti.get(e.id),n=P(e.directory??null),r={session:e,children:[],worktree:Zt.get(e.id)??null};if(ot&&Cn([r],at).length===0)return null;let i=Br.bySessionId.get(e.id),a=i?qr.find(e=>e.id===i.projectId):void 0,o=a?cr(a.normalizedPath)||a.normalizedPath:t?.secondaryMeta?.projectLabel??null,s=Cl({projectLabel:o,owner:i,sessionWorktree:Zt.get(e.id)??null,worktrees:a?nn.get(a.normalizedPath)??[]:[],projectRootBranch:i?Te.get(i.projectId)??(a?zr.get(a.normalizedPath)?.branch:null)??null:null,isVSCode:kt})??t?.secondaryMeta??null;return{node:r,projectId:i?.projectId??t?.projectId??null,groupDirectory:i?.scopeDirectory??t?.groupDirectory??n,secondaryMeta:s}},t=t=>t.map(e).filter(e=>e!==null);return{pinnedItems:kt?[]:t(ni),inProgressItems:t(ii)}},[nn,Cn,zr,ot,ii,kt,at,ni,Te,Br,ti,qr,Zt]),si=Z.useMemo(()=>Ne.flatMap(e=>Fe.get(e.id)??[]),[Ne,Fe]),ci=Z.useMemo(()=>Bc([...ai,...si.filter(e=>e.pinned)],e=>e.node.session.id,ut[xc]),[ai,si,ut]),li=Z.useMemo(()=>[...oi,...si.filter(e=>!e.pinned)].sort((e,t)=>sr(t.node.session)-sr(e.node.session)),[oi,si]),ui=!e&&!kt&&!r&&!i,di=ui&&de===`tasks`&&!ot,pi=yl(Dt,a&&ui),[mi,hi]=Z.useState(rS),gi=Z.useMemo(()=>di?gc({sessions:ln,pinnedSessionIds:H,settledSessionIds:U,indexedSessionIds:ce?.indexedIds??null,settledAtBySessionId:ce?.settledAtById,runningSessionIds:Dt,pendingRequestSessionIds:ue,unseenBySession:Ot}):null,[ue,H,Dt,ln,U,ce,di,Ot]),_i=Z.useMemo(()=>{let e=gi?.settled.filter(e=>!U.has(e.id));return e?.length?new Set([...U,...e.map(e=>e.id)]):U},[gi,U]),vi=G(e=>({activityAt:sr(e),running:Dt.has(e.id),attention:_c(e.id,ue,Ot)})),yi=Z.useMemo(()=>{if(!gi)return null;let e=aS(gi.active,e=>e.id,vi,mi);return e===gi.active?gi:{...gi,active:e}},[gi,vi,mi]),bi=G((e,t)=>{if(_||!yi)return;let n=new Map(yi.active.map(e=>[e.id,e])),r=oS(yi.active.map(e=>e.id),e,t,e=>{let t=n.get(e);return t?vi(t):void 0});r&&hi(r)}),xi=G((e,t,n)=>{if(!di||Ye!==`chat`||Vt!==e||Rt()!==n)return;let r=[...ni,...yi?.active??[]].filter(t=>t.id!==e),i=r.find(e=>e.id===t)??r[0];if(!i){wx(),Dx(null),an();return}let a=Br.bySessionId.get(i.id);ar(i.id,a?.scopeDirectory??P(i.directory??null),a?.projectId??null,H.has(i.id)?`pinned`:`project`)}),Si=G((e,t)=>{if(!t&&gi?.settled.some(t=>t.id===e&&t.time?.archived)){hr(e);return}if(!t||!di||Vt!==e){le(e,t);return}let n=[...ni,...yi?.active??[]],r=n.findIndex(t=>t.id===e),i=n[r+1]??n[r-1],a=Rt();le(e,!0,{onSuccess:()=>xi(e,i?.id??null,a)})}),Ci=ui?Si:void 0,wi=Z.useMemo(()=>{if(!yi)return null;let e=o(`sessions.sidebar.task.unassigned`),t=new Map(qr.map(e=>[e.id,cr(e.normalizedPath)||e.normalizedPath])),n=ge.current,r=new Map(qr.map(e=>[e.id,e.normalizedPath])),i=new Map;for(let e of qr){let t=n.get(e.id),r=t&&t.icon===e.icon&&t.color===e.color&&t.iconImage?.mime===e.iconImage?.mime&&t.iconImage?.updatedAt===e.iconImage?.updatedAt&&t.iconImage?.source===e.iconImage?.source?t:{id:e.id,icon:e.icon,color:e.color,iconImage:e.iconImage};n.set(e.id,r),i.set(e.id,r)}let a=he.current,s=new Map,c=n=>o=>{let c=Br.bySessionId.get(o.id),l=ti.get(o.id),u=c?.projectId??l?.projectId??null,d=c?.scopeDirectory??l?.groupDirectory??P(o.directory??null),f=c?i.get(c.projectId)??null:null,p=c&&t.get(c.projectId)||e,m=c?r.get(c.projectId)??null:null,h=m?zr.get(m):void 0,g=Zt.get(o.id)??null,_=(l?.secondaryMeta?.branchLabel??(c?Te.get(c.projectId):null)??h?.branch??g?.branch??null)?.trim()||null,v=_&&_!==`HEAD`&&_!==p?_:null,y=v?null:!m||h?.isGitRepo===!1?`no-git`:`loading`,b=y===`no-git`&&m?Kn(m,Oe):null,x=g,S=n?pi.get(o.id)??null:null,C=a.get(o.id);if(C&&C.session===o&&C.card===n&&C.projectId===u&&C.groupDirectory===d&&C.projectLabel===p&&C.branchLabel===v&&C.branchState===y&&C.pathLabel===b&&C.worktree===x&&C.project===f&&C.runStartedAt===S)return s.set(o.id,C),C.item;let w={node:{session:o,children:[],worktree:x},projectId:u,groupDirectory:d,secondaryMeta:{projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,card:n,slim:!n,project:f,runStartedAt:S}};return s.set(o.id,{session:o,card:n,projectId:u,groupDirectory:d,projectLabel:p,branchLabel:v,branchState:y,pathLabel:b,worktree:x,project:f,runStartedAt:S,item:w}),w},l=pe.settledOpen?yi.settled.slice(0,pe.settledLimit):[],u={pinned:ni.map(c(!0)),active:yi.active.map(c(!0)),settled:l.map(c(!1)),settledTotal:yi.settled.length};return he.current=s,u},[zr,Oe,ni,Te,pi,Br,ti,qr,o,yi,pe.settledLimit,pe.settledOpen,Zt]),Ti=Z.useMemo(()=>{if(!wi)return ci;let e=new Map(wi.pinned.map(e=>[e.node.session.id,e]));return ci.map(t=>e.get(t.node.session.id)??t)},[ci,wi]),Ei=Z.useMemo(()=>{if(!yi||!wi)return[];let e=new Map([...wi.active,...wi.settled].map(e=>[e.node.session.id,e]));return Uc(yi,pe).flatMap((t,n)=>{let r=e.get(t.id);return r?[{scope:`project`,sessionId:t.id,projectId:r.projectId,directory:P(hn(t))??r.groupDirectory??null,visibleIndex:n}]:[]})},[yi,wi,pe]),Di=Z.useMemo(()=>Xr.map(e=>({...e,groups:e.groups.filter(e=>!e.isArchivedBucket)})),[Xr]),Oi=Z.useMemo(()=>{let e=ot?Di.map(e=>({...e,groups:e.groups.map(e=>({...e,sessions:Yr.get(e)?.filteredNodes??[]}))})):Di;if(!i)return e;let t=e.find(e=>e.project.id===He)??e[0];if(!t)return[];let n=t.groups.find(e=>e.isMain&&e.sessions.length>0)??t.groups.find(e=>e.sessions.length>0)??t.groups.find(e=>e.isMain)??t.groups[0];return n?[{...t,groups:[n]}]:[]},[He,Yr,ot,Di,i]),ki=Z.useMemo(()=>el({sections:Oi,foldersMap:lt,getOrderedGroups:$r,pinnedSessionIds:H,sessionOrderByScope:ut,sessionOrderActivityByScope:dt}),[lt,$r,Oi,H,dt,ut]),Ai=Z.useMemo(()=>bl({targets:ki,collapsedProjectIds:O,collapsedGroupKeys:ve,collapsedFolderIds:ct,visibleSessionCountByGroup:M,defaultVisibleSessionCount:Hc(),hasSessionSearchQuery:ot,alwaysVisibleSessionIds:Et}),[Et,ct,ve,O,ot,ki,M]),ji=Z.useMemo(()=>ot?[]:(di?ci:[...ci,...li]).map((e,t)=>{let n=e.node.session;return{scope:`pinned`,sessionId:n.id,projectId:e.projectId,directory:P(hn(n))??e.groupDirectory??null,visibleIndex:t}}),[ot,li,ci,di]),[Mi,Ni]=Z.useState(null),Pi=Z.useCallback(e=>{Ni(t=>t&&t.length===e.length&&t.every((t,n)=>t===e[n])?t:[...e])},[]),Fi=Z.useMemo(()=>{if(!Mi)return ji;let e=new Set(Mi);return ji.filter(t=>e.has(t.sessionId))},[ji,Mi]),Ii=Z.useMemo(()=>!a&&we.current?we.current:{pinned:Fi,project:di?Ei:Ai},[a,Ei,di,Fi,Ai]);Z.useLayoutEffect(()=>{a&&(we.current=Ii)},[a,Ii]);let Li=Z.useMemo(()=>e?[]:so({pinnedTargets:Ii.pinned,projectTargets:di?Ii.project:je.flatMap(e=>e.hostId?ze.get(e.id)??[]:Ii.project.filter(t=>t.projectId===e.id))}),[e,di,Ii,je,ze]),Ri=Z.useCallback(t=>{let n=Ne.find(e=>e.id===t.projectId);if(n&&Re.registry){let r=Fe.get(n.id)?.find(e=>e.identity===t.sessionId);lc(n,Re.registry,r?.remoteSessionId??t.sessionId,t.directory??n.path,e);return}Je(`chat`),$e(!1),t.scope===`project`&&t.projectId&&Ge(t.projectId),ar(t.sessionId,t.directory,t.projectId,t.scope)},[ar,Je,Ge,$e,Ne,Re.registry,Fe,e]);Z.useLayoutEffect(()=>ro({targets:Li,activate:Ri}),[Ri,Li]);let zi=Z.useMemo(()=>{let e=new Map;return Li.forEach(t=>{let n=Qa({scope:t.scope,sessionId:t.sessionId,projectId:t.projectId});n&&e.set(n,Ya(Li,t)??0)}),e},[Li]),Bi=Z.useMemo(()=>{if(!Vt||ot)return[];let e=[],t=(n,r)=>{if(n.session.id===Vt){e.push({scope:`pinned`,sessionId:Vt,projectId:r});return}n.children.forEach(e=>t(e,r))};return ci.forEach(e=>t(e.node,e.projectId)),oi.forEach(e=>t(e.node,e.projectId)),e},[Vt,ot,oi,ci]),Vi=Z.useMemo(()=>{if(!Vt)return[];let e=[],t=(n,r)=>{if(n.session.id===Vt){e.push({scope:`project`,sessionId:Vt,projectId:r});return}n.children.forEach(e=>t(e,r))};return Jr.forEach(e=>{e.groups.forEach(n=>{n.sessions.forEach(n=>t(n,e.project.id))})}),e},[Vt,Jr]);Z.useLayoutEffect(()=>io({pinned:Ii.pinned,project:Ii.project}),[Ii]),Z.useLayoutEffect(()=>{!a||Wr||Dx(lS({currentSessionId:Vt,focus:Ht,pinnedFocuses:Bi,projectFocuses:Vi,fallbackProjectId:Vt?ti.get(Vt)?.projectId??null:null}))},[Vt,a,Wr,Vi,Bi,Ht,ti]);let Hi=Z.useMemo(()=>{let e=Ht?.sessionId?ti.get(Ht.sessionId)?.projectId??null:null;return uS(Ht,ki,e)},[ki,Ht,ti]),Ui=Z.useRef(null),Wi=Z.useRef(null);Z.useEffect(()=>{Wi.current&&Wi.current!==Vt&&(Wi.current=null)},[Vt]),Z.useLayoutEffect(()=>{if(!Hi?.projectId)return;let e=Hi.sessionId,t=Ut.sessionId===e;if(!(!t&&Vt!==e)){if(t){if(Ui.current===Ut.revision)return;Ui.current=Ut.revision,Wi.current=e}else{if(Wi.current===e)return;Wi.current=e}if(Mr(Hi.projectId),Hi.groupKey&&ye(e=>{if(!e.has(Hi.groupKey))return e;let t=new Set(e);return t.delete(Hi.groupKey),t}),Hi.folderAncestorIds?.forEach(e=>{let t=Sn.getState();t.collapsedFolderIds.has(e)&&t.toggleFolderCollapse(e)}),Hi.groupKey&&Hi.visibleIndex!==void 0){let e=Hi.visibleIndex+1;N(t=>{if((t.get(Hi.groupKey)??0)>=e)return t;let n=new Map(t);return n.set(Hi.groupKey,e),n})}}},[Vt,Hi,Ut]);let Gi=DS((t,n=0,r,i,a=!1,o,s=`project`,c)=>(0,$.jsx)(Vx,{node:t,depth:n,groupDirectory:r,projectId:i,archivedBucket:a,currentSessionId:Vt,pinnedSessionIds:H,settledSessionIds:_i,setSessionSettled:Ci,expandedParents:w,hasSessionSearchQuery:ot,normalizedSessionSearchQuery:at,notifyOnSubtasks:tt,editingId:_,setEditingId:v,editTitle:b,setEditTitle:x,handleSaveEdit:pr,handleCancelEdit:mr,toggleParent:lr,handleSessionSelect:dr,handleSessionDoubleClick:fr,togglePinnedSession:se,handleShareSession:gr,copiedSessionId:Gn,handleCopyShareUrl:_r,handleUnshareSession:vr,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,renamingFolderId:z,getFoldersForScope:ft,getSessionFolderId:xt,removeSessionFromFolder:vt,addSessionToFolder:gt,createFolderAndStartRename:br,handleDeleteSession:yr,mobileVariant:e,alwaysShowActions:yn,renderSessionNode:Gi,secondaryMeta:o,renderContext:s,subtreeContainsActive:c?.subtreeContainsActive??wS,subtreeContainsEditing:c?.subtreeContainsEditing??wS,menuOpenSessionId:c?.menuOpenSessionId??null,nodeStructureKey:c?.nodeStructureKey??``,childRenderExtrasFor:c?.childRenderExtrasFor,liveSessionById:fn,shortcutNumber:zi.get(Qa({scope:s,sessionId:t.session.id,projectId:i??null})??``)??null},`${s}:${i??``}:${t.session.id}`),JSON.stringify([...zi])),Ki=Z.useCallback(e=>{Sr(e),ye(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[Sr]),qi=Z.useCallback(e=>{let t=Tr(e);if(t.length===0)return;let n=on.getState(),r=t.filter(e=>!n.archivedLoadedDirectories.has(e));r.length>0&&Qt(r)},[Tr]),Ji=G((e,t,n,r,i)=>{let a=e.folderScopeKey??P(e.directory??null);a&&Ct(a,t,n,r,i).catch(()=>Y.error(o(`sessions.order.saveFailed`)))}),Yi=G((e,t,n)=>{e.isArchivedBucket&&ve.has(t)&&n&&qi(n),Ki(t)}),Zi=Z.useMemo(()=>(t,n,r,i,a,o,s)=>(0,$.jsx)(sl,{group:t,groupKey:n,isArchivedLoading:!!(t.isArchivedBucket&&r&&Tr(r).some(e=>Pt.has(e))),projectId:r,projectLabel:r?Fr.get(r)??null:null,hideGroupLabel:i,compactBodyPadding:o,hasSessionSearchQuery:ot,normalizedSessionSearchQuery:at,groupSearchDataByGroup:Yr,visibleSessionCount:M.get(n),collapsedGroups:ve,collapsedFolderIds:ct,toggleFolderCollapse:bt,renameFolder:mt,deleteFolder:ht,showDeletionDialog:nt,setDeleteFolderConfirm:ae,renderSessionNode:Gi,projectRepoStatus:A,lastRepoStatus:Gr.current,showMoreGroupSessions:xr,resetGroupSessionLimit:Sr,mobileVariant:e,alwaysShowActions:yn,activeProjectId:He,setActiveProjectIdOnly:Ge,setActiveMainTab:Je,setSessionSwitcherOpen:$e,openNewSessionDraft:sn,addSessionToFolder:gt,createFolderAndStartRename:br,renamingFolderId:z,renameFolderDraft:B,setRenameFolderDraft:te,setRenamingFolderId:ee,pinnedSessionIds:H,expandedParents:w,sessionOrderByScope:ut,sessionOrderActivityByScope:dt,onReorderSessions:Ji,currentSessionId:Vt,shortcutTargetSessionId:Hi?.groupKey===n?Hi.sessionId:null,shortcutTargetVisibleIndex:Hi?.groupKey===n?Hi.visibleIndex??null:null,editingId:_,editTitle:b,openSidebarMenuKey:L,liveSessionById:fn,alwaysVisibleSessionIds:Et,onToggleCollapsedGroup:Yi,dragHandleProps:a,scrollContainerRef:s}),[ot,at,Yr,Fr,Pt,Tr,M,ve,ct,bt,mt,ht,nt,Gi,A,xr,Sr,e,yn,He,Ge,Je,$e,sn,gt,br,z,B,H,w,ut,dt,Ji,Vt,Hi,_,b,L,fn,Et,Yi]),Qi=di?(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`mr-1 size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.newSession`),title:o(`sessions.sidebar.header.actions.newSession`),onClick:zn,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})}):null,$i=ui?(0,$.jsx)(Xx,{value:de,onChange:_e}):void 0,ea=e=>Gi(e.node,0,e.groupDirectory,e.projectId,!1,e.secondaryMeta,`project`),ta=di&&wi?(0,$.jsx)(Qx,{items:wi,renderTaskRow:ea,onSessionsReordered:bi}):void 0,na=di&&wi?(0,$.jsx)(nS,{items:wi,open:pe.settledOpen,onToggle:()=>me(e=>({...e,settledOpen:!e.settledOpen,settledLimit:30})),onShowMore:()=>me(e=>({...e,settledLimit:e.settledLimit+30})),renderTaskRow:ea}):void 0,ra=r?null:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Dy,{collapseAllProjects:kr,expandAllProjects:Ar}),(0,$.jsx)(q,{variant:`ghost`,size:`xs`,className:`size-6 p-0 text-muted-foreground`,"aria-label":o(`sessions.sidebar.header.actions.addProject`),title:o(`sessions.sidebar.header.actions.addProject`),onClick:Nn.requestDirectoryDialog,children:(0,$.jsx)(X,{name:`add`,className:`size-4`})})]}),ia=pn&&mn&&!kt&&!ot?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(_f,{className:`min-w-0 flex-1`}),(0,$.jsx)(Fc,{className:`ml-auto shrink-0`})]})}):null,aa=!kt&&!ot,oa=aa&&vn&&!e,sa=di?[]:li,ca=!ot&&(ci.length>0||sa.length>0),la=(0,$.jsxs)(`div`,{className:`space-y-0.5 py-1`,children:[(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,e&&`h-11`),onClick:zn,children:[(0,$.jsx)(X,{name:`chat-new`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.newSession`)})]}),(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ye===`schedule`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Bn,children:[(0,$.jsx)(X,{name:`time`,className:`size-4`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`sessions.sidebar.header.actions.scheduledTasks`)}),a?(0,$.jsx)(Bv,{}):null]}),Xe.data?.supported&&Xe.data?.enabled?(0,$.jsxs)(q,{variant:`ghost`,size:`sm`,className:J(`w-full justify-start px-2 font-normal`,Ye===`assistant`&&`bg-interactive-selection text-interactive-selection-foreground`,e&&`h-11`),onClick:Hn,children:[(0,$.jsx)(dl,{className:`size-4 shrink-0 [&[data-assistant-navigation-avatar]]:scale-125`}),(0,$.jsx)(`span`,{className:`truncate`,children:o(`assistants.title`)}),(0,$.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(Bl,{className:`h-3.5 min-w-3.5 px-1 text-[10px]`}),a?(0,$.jsx)(Vv,{}):null]})]}):null,(0,$.jsx)(Tu,{sidebar:!0,mobile:e})]}),ua=ui&&!ot,da=ca?(0,$.jsx)(vy,{isFirst:ua,hideHeader:di,items:Ti,reorderEnabled:!0,onSessionsReordered:ri,inProgressItems:sa,renderSessionNode:Gi,currentSessionId:Vt,editingId:_,openSidebarMenuKey:L,onVisibleSessionIdsChange:Pi}):null,fa=aa&&!oa||ca&&!ua?(0,$.jsxs)($.Fragment,{children:[aa&&!oa?(0,$.jsxs)($.Fragment,{children:[e&&mn?(0,$.jsx)(_f,{}):null,la]}):null,ua?null:da]}):null,pa=!!(z||_||S),{selectionModeEnabled:ma,hasSelection:ha,selectedIdsSize:ga,bulkScopeIsArchived:_a,derivedSelectionScope:va,bulkScopeFolders:ya,bulkCanRemoveFromFolder:ba,handleExitSelectionMode:xa,handleBulkMoveToFolder:Sa,handleBulkCreateFolderAndMove:Ca,handleBulkRemoveFromFolder:wa,handleBulkDelete:Ta,confirmBulkDelete:Ea}=Jx({isInlineEditing:pa,showDeletionDialog:nt,foldersMap:lt,addSessionsToFolder:_t,removeSessionsFromFolders:yt,createFolderAndStartRename:ur,archiveSessions:Wn,setBulkDeleteConfirm:V});return(0,$.jsxs)(`div`,{ref:h,className:J(`yuri-session-sidebar relative flex h-full flex-col text-foreground overflow-x-hidden`,e?``:`bg-transparent`),children:[(0,$.jsx)(gy,{hideDirectoryControls:r,isSessionSearchOpen:u,setIsSessionSearchOpen:d,sessionSearchInputRef:g,sessionSearchQuery:f,setSessionSearchQuery:p,hasSessionSearchQuery:ot,searchMatchCount:Zr}),ia,oa?(0,$.jsx)(`div`,{className:`shrink-0 px-3`,children:la}):null,a?(0,$.jsx)(gb,{remoteProjects:Ne,hostRegistry:Re.registry,projectOrderIds:nl(je,Kr).map(e=>e.id),onRemoteActivityItems:Le,remoteSearch:f,remoteError:Re.catalog.error?.message,onRemoteNavigationTargets:Ve,topContent:fa,tabLeadingContent:ua?da:void 0,hasLeadingSection:fa!==null&&!ua&&(ci.length>0||oi.length>0),headerAccessory:di?Qi:ra,headerSwitch:$i,taskContent:ta,taskFooter:na,sectionsForRender:Di,projectSections:Jr,activeProjectId:He,projectRevealTarget:Kt,showOnlyMainWorkspace:i,hasSessionSearchQuery:ot,emptyState:jn,searchEmptyState:Qr,renderGroupSessions:Zi,homeDirectory:Oe,collapsedProjects:O,hideDirectoryControls:r,projectRepoStatus:A,mobileVariant:e,alwaysShowActions:yn,toggleProject:jr,setActiveProjectIdOnly:Ge,setActiveMainTab:Je,setSessionSwitcherOpen:$e,openNewSessionDraft:sn,openNewWorktreeDialog:Fn,syncProjectSessions:Or,openProjectEditDialog:C,removeProject:We,projectReorderEnabled:Kr===`manual`,reorderProjects:qe,projectSortOrder:Kr,getOrderedGroups:$r,setGroupOrderByProject:xe,openSidebarMenuKey:L,setOpenSidebarMenuKey:R,isInlineEditing:pa}):null,ma&&ha?(0,$.jsx)(qx,{selectedCount:ga,scopeKey:va,scopeFolders:ya,archivedBucket:_a,onMoveToFolder:Sa,onCreateFolderAndMove:Ca,onRemoveFromFolder:wa,canRemoveFromFolder:ba,onDelete:Ta,onDone:xa}):null,(0,$.jsx)(Kv,{normalizedProjects:Pr,ownership:Br,enabled:a}),(0,$.jsx)(ob,{onOpenSettings:Rn,onOpenShortcuts:Qe,onOpenUpdate:Ln,showRuntimeButtons:!kt,showUpdateButton:st}),s?(0,$.jsx)(OS,{onOpenChange:l}):null,Mn?(0,$.jsx)(hy,{open:!0,onOpenChange:e=>{e||C(null)},project:Mn,onSave:Pn}):null,F?(0,$.jsx)(fs,{open:!0,onOpenChange:I,onWorktreeCreated:In}):null,(0,$.jsx)(gl,{}),(0,$.jsx)(vu,{}),(0,$.jsx)(Wx,{value:ne,setValue:re,showDeletionDialog:nt,setShowDeletionDialog:rt,onConfirm:ir}),(0,$.jsx)(Kx,{value:ie,setValue:ae,onConfirm:or}),(0,$.jsx)(Gx,{value:oe,setValue:V,showDeletionDialog:nt,setShowDeletionDialog:rt,onConfirm:Ea})]})});function AS(e){return{info:e.info,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,error:e.error,runtimeType:e.runtimeType,onDownload:e.downloadUpdate,onRestart:e.restartToUpdate}}var jS=e=>e?(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:e}):void 0,MS=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.replace(/\/+$/,``)},NS=()=>{let{t:e}=Nr(),[t,n]=Z.useState(!1),[r,i]=Z.useState(),[a,o]=Z.useState(null),[s,c]=Z.useState([]),[l,u]=Z.useState(!1),[d,f]=Z.useState(!1),[p,m]=Z.useState(!1),[h,g]=Z.useState(!1),[_,v]=Z.useState(new Set),y=Vn(e=>e.getWorktreeMetadata),b=Vn(e=>e.newSessionDraft),x=Vn(e=>e.setNewSessionDraftTarget),S=Vn(e=>e.setDraftBootstrapPendingDirectory),C=mn,w=Vn(e=>e.archiveSessions),T=K(e=>e.showDeletionDialog),E=K(e=>e.setShowDeletionDialog),D=W(e=>e.currentDirectory),O=W(e=>e.homeDirectory),k=$t(e=>e.projects),A=$t(e=>e.activeProjectId),{isMobile:j,isTablet:M,hasTouchInput:N}=fi(),P=j||M||N,F=Z.useMemo(()=>MS((A?k.find(e=>e.id===A)??null:null)?.path??D),[A,D,k]),I=Z.useCallback(e=>{let t=MS(e.projectDirectory)||F;return{id:(k.find(e=>MS(e.path)===t)??null)?.id??`path:${t}`,path:t}},[F,k]),L=h&&_.size>0,R=Z.useMemo(()=>{let e=a?.worktree;return e&&typeof e.branch==`string`&&e.branch.trim().length>0?!0:s.length>0&&s.every(({metadata:e})=>typeof e.branch==`string`&&e.branch.trim().length>0)},[a?.worktree,s]),z=a?.mode===`worktree`,ee=z,B=p||!z||!R,te=p||!z,ne=Z.useCallback(e=>{o({sessions:e.sessions,dateLabel:e.dateLabel,mode:e.mode??`session`,worktree:e.worktree??null})},[]),re=Z.useCallback(()=>{o(null),c([]),u(!1),f(!1),m(!1),g(!1),v(new Set)},[]),ie=Z.useCallback(t=>{if(t.sessions.length===0)return;let n=t.sessions.map(e=>e.id);Xc({sessionIds:n,message:n.length===1?e(`sessions.sidebar.session.delete.success`):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.session.delete.error`):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})})},[e]);Z.useEffect(()=>Nn.onDeleteRequest(e=>{if(!T&&(e.mode??`session`)===`session`){ie(e);return}ne(e)}),[ne,T,ie]),Z.useEffect(()=>Nn.onDirectoryRequest(({origin:e})=>{i(e),n(!0)}),[]),Z.useEffect(()=>{if(!a){c([]),u(!1),f(!1),g(!1),v(new Set);return}let e=a.sessions.map(e=>{let t=y(e.id);return t?{session:e,metadata:t}:null}).filter(e=>!!e);c(e),u(!1),g(!1),v(new Set);let t=new Map;if(a.worktree?.path&&t.set(MS(a.worktree.path),a.worktree),e.forEach(({metadata:e})=>{e.path&&t.set(MS(e.path),e)}),t.size===0){g(!0);return}let n=!1;return(async()=>{let e=new Map,r=new Set;await Promise.all(Array.from(t.entries()).map(async([t,n])=>{try{let i=await Ls(n.path);e.set(t,i),i?.isDirty&&r.add(t)}catch{n.status&&(e.set(t,n.status),n.status.isDirty&&r.add(t))}})).catch(e=>{console.warn(`Failed to inspect worktree status before deletion:`,e)}),!n&&(v(r),g(!0),o(t=>{if(!t?.worktree?.path)return t;let n=MS(t.worktree.path),r=e.get(n);if(!r)return t;let i=t.worktree.status;return i?.isDirty===r.isDirty&&i?.ahead===r.ahead&&i?.behind===r.behind&&i?.upstream===r.upstream?t:{...t,worktree:{...t.worktree,status:r}}}),c(t=>t.map(t=>{let n=MS(t.metadata.path),r=e.get(n);return r?{session:t.session,metadata:{...t.metadata,status:r}}:t})))})(),()=>{n=!0}},[a,y]),Z.useEffect(()=>{R||u(!1)},[R]);let ae=Z.useCallback(async(t,n)=>{let r=l&&R,i=I(t),a=MS(t.path),o=MS(i.path);try{await Rs(i,t,{deleteRemoteBranch:r,deleteLocalBranch:n});let e=MS(b?.directoryOverride);return b?.open&&a&&e===a&&o&&(S(null),x({projectId:i.id,directoryOverride:o},{force:!0})),MS(D)===a&&o&&W.getState().setDirectory(o,{showOverlay:!1}),!0}catch(t){return Y.error(e(`sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle`),{description:jS(t instanceof Error?t.message:e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),!1}},[R,D,l,I,b?.directoryOverride,b?.open,S,x,e]),oe=Z.useCallback((t,n)=>{let r=l&&R;(async()=>{if(!await ae(t,n))return;let i=e(r?`sessions.sidebar.sessionDialogs.worktree.removedWithRemote`:`sessions.sidebar.sessionDialogs.worktree.removed`);Y.success(e(`sessions.sidebar.sessionDialogs.worktree.removedTitle`),{description:jS(i)})})()},[R,l,ae,e]),V=Z.useCallback(async()=>{if(a){m(!0);try{let t=ee&&d;if(a.sessions.length===0&&z&&a.worktree){oe(a.worktree,t),re();return}if(a.sessions.length===1){let t=a.sessions[0];if(z){if(!await C(t.id)){Y.error(e(`sessions.sidebar.session.archive.error`)),m(!1);return}vl({sessionIds:[t.id],message:e(`sessions.sidebar.session.archive.success`),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:e(`sessions.sidebar.session.archive.undoFailed`)})}else Xc({sessionIds:[t.id],message:e(`sessions.sidebar.session.delete.success`),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:e(`sessions.sidebar.session.delete.error`)})}else{let n=a.sessions.map(e=>e.id),r=[],i=[];if(z){let e=await w(n);r=e.archivedIds,i=e.failedIds}else Xc({sessionIds:n,message:n.length===1?e(`sessions.sidebar.bulkActions.deletedSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.deletedPlural`,{count:n.length}),undoLabel:e(`sessions.sidebar.undo`),commitFailedMessage:n.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:n.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:n.length})}),r=n,i=[];if(z&&a.worktree&&i.length===0&&oe(a.worktree,t),z&&r.length>0&&vl({sessionIds:r,message:r.length===1?e(`sessions.sidebar.bulkActions.archivedSingle`,{count:r.length}):e(`sessions.sidebar.bulkActions.archivedPlural`,{count:r.length}),undoLabel:e(`sessions.sidebar.undo`),settingsLabel:e(`settings.yuri.archivedSessions.actions.view`),undoFailedMessage:r.length===1?e(`sessions.sidebar.session.archive.undoFailed`):e(`sessions.sidebar.bulkActions.archiveUndoFailed`,{count:r.length})}),i.length>0&&(Y.error(z?i.length===1?e(`sessions.sidebar.bulkActions.failedArchiveSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedArchivePlural`,{count:i.length}):i.length===1?e(`sessions.sidebar.bulkActions.failedDeleteSingle`,{count:i.length}):e(`sessions.sidebar.bulkActions.failedDeletePlural`,{count:i.length}),{description:jS(e(`sessions.sidebar.dialogs.deleteResult.tryAgain`))}),r.length===0)){m(!1);return}}z&&a.sessions.length===1&&a.worktree&&oe(a.worktree,t),re()}finally{m(!1)}}},[a,d,C,w,re,ee,z,oe,e]),H=a?.worktree??s[0]?.metadata??null,se=a?a.mode===`worktree`?a.sessions.length===0?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionNoLinked`):a.sessions.length===1?e(`sessions.sidebar.dialogs.worktreeDelete.descriptionOneLinked`,{count:a.sessions.length}):e(`sessions.sidebar.dialogs.worktreeDelete.descriptionManyLinked`,{count:a.sessions.length}):a.sessions.length===1?a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionOneWithDate`,{dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionOne`):a.dateLabel?e(`sessions.sidebar.dialogs.sessionDelete.descriptionManyWithDate`,{count:a.sessions.length,dateLabel:a.dateLabel}):e(`sessions.sidebar.dialogs.sessionDelete.descriptionMany`,{count:a.sessions.length}):``,U=a?(0,$.jsxs)(`div`,{className:J(z?`space-y-3`:`space-y-2`),children:[a.sessions.length>0&&(0,$.jsxs)(`div`,{className:J(z?`rounded-lg bg-muted/30 p-3`:`space-y-1.5 rounded-xl border border-border/40 bg-sidebar/60 p-3`),children:[z&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:a.sessions.length===1?e(`sessions.sidebar.sessionDialogs.linkedSessionSingle`):e(`sessions.sidebar.sessionDialogs.linkedSessionPlural`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:a.sessions.length})]}),(0,$.jsxs)(`ul`,{className:J(z?`mt-2 space-y-1`:`space-y-0.5`),children:[a.sessions.slice(0,5).map(t=>(0,$.jsxs)(`li`,{className:J(z?`flex items-center gap-2 rounded-md px-2.5 py-1.5 text-sm text-muted-foreground`:`typography-micro text-muted-foreground/80`),children:[(0,$.jsx)(`span`,{className:J(!z&&`hidden`),children:`•`}),(0,$.jsx)(`span`,{className:`truncate`,children:t.title||e(`sessions.sidebar.session.untitled`)})]},t.id)),a.sessions.length>5&&(0,$.jsx)(`li`,{className:J(z?`px-2.5 py-1 text-xs text-muted-foreground/70`:`typography-micro text-muted-foreground/70`),children:e(`sessions.sidebar.dialogs.sessionList.more`,{count:a.sessions.length-5})})]})]}),z?(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-muted/30 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e(`sessions.sidebar.sessionDialogs.worktree.label`)}),H?.label?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70`,children:H.label}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/80 break-all`,children:H?Kn(H.path,O):e(`sessions.sidebar.sessionDialogs.worktree.pathUnavailable`)}),L&&(0,$.jsx)(`p`,{className:`typography-micro text-status-warning`,children:e(`sessions.sidebar.sessionDialogs.worktree.uncommittedWarning`)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/60 p-3`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:e(`sessions.sidebar.sessionDialogs.delete.note`)})})]}):null,ce=z?R?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{B||u(e=>!e)},disabled:B,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,B?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[l?(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteRemoteBranch`)]}):(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`,children:e(`sessions.sidebar.sessionDialogs.actions.remoteBranchInfoUnavailable`)}):null,le=z?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{te||f(e=>!e)},disabled:te,className:J(`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-muted-foreground transition-colors`,te?`cursor-not-allowed opacity-60`:`hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`),children:[d?(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}),e(`sessions.sidebar.sessionDialogs.actions.deleteLocalBranch`)]}):null,ue=z?(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[le,ce]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:re,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:V,disabled:p,children:e(p?`sessions.sidebar.sessionDialogs.actions.deleting`:`sessions.sidebar.sessionDialogs.actions.deleteWorktree`)})]})]}):(0,$.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(!T),className:`inline-flex items-center gap-1.5 typography-meta text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary/50`,"aria-pressed":!T,children:[T?(0,$.jsx)(X,{name:`checkbox-blank`,className:`size-4`}):(0,$.jsx)(X,{name:`checkbox`,className:`size-4 text-primary`}),e(`sessions.sidebar.dialogs.neverAsk`)]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{variant:`ghost`,onClick:re,disabled:p,children:e(`sessions.sidebar.dialogs.cancel`)}),(0,$.jsx)(q,{variant:`destructive`,onClick:V,disabled:p,children:p?e(`sessions.sidebar.sessionDialogs.actions.deleting`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`)})]})]}),de=z?e(`sessions.sidebar.sessionDialogs.actions.deleteWorktree`):a?.sessions.length===1?e(`sessions.sidebar.dialogs.deleteSession.titleAction`):e(`sessions.sidebar.dialogs.deleteSessions.titleAction`);return(0,$.jsxs)($.Fragment,{children:[P?(0,$.jsx)(Ds,{open:!!a,onClose:()=>{p||re()},title:de,footer:(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:ue}),children:(0,$.jsxs)(`div`,{className:`space-y-2 pb-2`,children:[se&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground/80`,children:se}),U]})}):(0,$.jsx)(Qr,{open:!!a,onOpenChange:e=>{if(!e){if(p)return;re()}},children:(0,$.jsxs)(Yr,{className:J(z?`max-w-xl max-h-[70vh] flex flex-col overflow-hidden gap-3`:`max-w-[min(520px,100vw-2rem)] space-y-2 pb-2`),children:[(0,$.jsxs)(qr,{children:[(0,$.jsxs)(Xr,{className:J(z&&`flex items-center gap-2`),children:[z&&(0,$.jsx)(X,{name:`delete-bin`,className:`h-5 w-5`}),de]}),se&&(0,$.jsx)(Zr,{children:se})]}),(0,$.jsx)(`div`,{className:J(z&&`flex-1 min-h-0 overflow-y-auto space-y-2`),children:U}),(0,$.jsx)(Jr,{className:`mt-2 gap-2 pt-1 pb-1`,children:ue})]})}),(0,$.jsx)(fc,{open:t,onOpenChange:n,origin:r})]})},PS=Z.createContext(null),FS=e=>{let t=(0,Q.c)(3),{children:n,value:r}=e,i;return t[0]!==n||t[1]!==r?(i=(0,$.jsx)(PS.Provider,{value:r,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i},IS=ba(()=>Lt(()=>import(`./TerminalView-CMugifkh.js`).then(e=>({default:e.TerminalView})),__vite__mapDeps([82,1,4,2,5,3,6,7,8,9,21,22,23,20,24,25,18,83,38,39,40,41,42,13,10,12,11,14,15,16,17,19,43,84,37,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,85,65,86,68,87,88,89,90,91,92,93,94,95]))),LS=ba(()=>Lt(()=>import(`./DiagramView-j7aFp44v.js`).then(e=>({default:e.DiagramView})),__vite__mapDeps([96,1,3,2,9,11,12,13,4,5,6,7,8,10,14,15,16,17,18,19,20,21,22,23,24,25,44,58,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,53,54,55,56,57,68,87,83,97,98]))),RS=ba(()=>Lt(()=>import(`./SettingsView-C62JngPE.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([99,1,2,3,4,5,6,7,8,100,101,22,9,38,23,20,24,39,40,41,42,13,10,12,11,14,15,16,17,18,19,21,25,43,102,44,37,45,46,47,48,49,50,51,52,53,54,55,56,57,58,103,85,62,63,104,65,105,86,106,107,108,109,110,66,27,28,29,30,31,32,33,34,35,36,111,69,70,71,112,113,114,74,68,75,76,115,116,117,118,119,120,121,122,123,124,125,59,60,126,127,88,89,90,91,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,61,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,79,175,176,177,178,179]))),zS=ba(()=>Lt(()=>import(`./SettingsWindow-Cm8apHAR.js`).then(e=>({default:e.SettingsWindow})),__vite__mapDeps([180,1,9,10,37,2,5,3,4,6,7,8,22,38,23,20,24,39,40,41,42,13,12,11,14,15,16,17,18,19,21,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,99,100,101,102,58,103,85,62,63,104,65,105,86,106,107,108,109,110,66,27,28,29,30,31,32,33,34,35,36,111,69,70,71,112,113,114,74,68,75,76,115,116,117,118,119,120,121,122,123,124,125,59,60,126,127,88,89,90,91,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,61,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,79,175,176,177,178,179]))),BS=ba(()=>Lt(()=>import(`./MultiRunWindow-COqSg1Nk.js`).then(e=>({default:e.MultiRunWindow})),__vite__mapDeps([181,1,9,10,37,2,5,3,4,6,7,8,22,38,23,20,24,39,40,41,42,13,12,11,14,15,16,17,18,19,21,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,182,103,85,104,86,109,110,111,183,114,184,185,186,187,188,157,59,65,70,76,158,159,189,190,191,147,123,154,61,89,90,91,122,124,125,60,174,192,127]))),VS=ba(()=>Lt(()=>import(`./AssistantView-CDPTtrUZ.js`).then(e=>({default:e.AssistantView})),__vite__mapDeps([193,1,3,2,9,10,15,16,17,21,5,6,7,8,22,23,20,24,25,18,37,4,38,39,40,41,42,13,12,11,14,19,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,194,86,116,163,117,195,103,85,59,72,73,196,74,68,75,76,77,161,62,63,71,162,157,65,70,158,159,197,125,60,110,189,190,191,186,187,198,67,148,149,199,200,201,202,203,204,164,132,133,205,206,207,208,108,107]))),HS=()=>{let e=K(e=>e.isSidebarOpen),t=K(e=>e.isRightSidebarOpen),n=K(e=>e.isBottomTerminalOpen),r=K(e=>e.setRightSidebarOpen),i=K(e=>e.setBottomTerminalOpen),a=K(e=>e.activeMainTab),o=K(e=>e.setIsMobile),s=K(e=>e.isSessionSwitcherOpen),c=K(e=>e.isSettingsDialogOpen),l=K(e=>e.setSettingsDialogOpen),u=K(e=>e.isMultiRunLauncherOpen),d=K(e=>e.setMultiRunLauncherOpen),[f,p]=Z.useState(c),[m,h]=Z.useState(u);c&&!f&&p(!0),u&&!m&&h(!0);let{isMobile:g,isTablet:_}=fi(),v=Z.useRef(!1),y=Z.useRef(!1),[b,x]=Z.useState(!1),[S,C]=Z.useState(!1),[w,T]=Z.useState(!1),[E,D]=Z.useState(!1),O=Z.useCallback(e=>{x(e),K.getState().setSessionSwitcherOpen(e)},[]),k=Z.useRef(!1),A=Z.useRef(typeof window>`u`?0:window.innerWidth),j=Gr(-A.current),M=(0,Z.useRef)(0),N=Gr(A.current),P=(0,Z.useRef)(0);(0,Z.useEffect)(()=>{g&&(M.current=window.innerWidth,P.current=window.innerWidth)},[g]),(0,Z.useEffect)(()=>{if(!g){T(!1);return}b&&T(!0),Kr(j,b?0:-M.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[b,g,j]),(0,Z.useEffect)(()=>{if(!g){D(!1);return}k.current=S,S&&D(!0),Kr(N,S?0:P.current,{type:`spring`,stiffness:400,damping:35,mass:.8})},[g,S,N]),(0,Z.useEffect)(()=>{if(g)return j.on(`change`,e=>{let t=M.current||A.current,n=b||e>-t+.5;T(e=>e===n?e:n)})},[g,j,b]),(0,Z.useEffect)(()=>{if(g)return N.on(`change`,e=>{let t=P.current||A.current,n=S||e<t-.5;D(e=>e===n?e:n)})},[g,S,N]),(0,Z.useEffect)(()=>{g&&!s&&b&&O(!1)},[s,g,b,O]),(0,Z.useEffect)(()=>{if(!g){y.current=!1;return}y.current||(y.current=!0,O(!1),C(!1),K.getState().isRightSidebarOpen&&r(!1))},[g,O,r]),(0,Z.useEffect)(()=>{if(!g||a!==`chat`||b||S||c)return;let e=!1,t,n=r=>{t=window.setTimeout(()=>{if(e)return;let t=Vn.getState(),r=K.getState();if(!(r.activeMainTab!==`chat`||r.isSettingsDialogOpen||t.currentSessionId||t.newSessionDraft?.open)){if(t.isLoading){n(250);return}t.openNewSessionDraft()}},r)};return n(500),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[a,g,c,b,S]),(0,Z.useEffect)(()=>{!g||!c||(O(!1),C(!1),t&&r(!1))},[g,c,t,O,r]),Z.useEffect(()=>{K.getState().isMobile!==g&&o(g)},[g,o]),Z.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,K.getState().updateProportionalSidebarWidths()}))};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),e!==void 0&&window.cancelAnimationFrame(e)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e,t=()=>{let e=K.getState(),t=window.innerHeight;!g&&!_&&(t<640?e.isBottomTerminalOpen&&(i(!1),v.current=!0):t>=700&&v.current&&(i(!0),v.current=!1))},n=()=>{e===void 0&&(e=window.requestAnimationFrame(()=>{e=void 0,t()}))};return t(),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`resize`,n),e!==void 0&&window.cancelAnimationFrame(e)}},[g,_,i]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=K.subscribe((e,t)=>{let n=window.innerHeight>=700;e.isBottomTerminalOpen!==t.isBottomTerminalOpen&&n&&(v.current=!1)});return()=>{e()}},[g,_,i]);let F=Z.useCallback(()=>{b&&O(!1),C(!S)},[b,S,O]),I=Z.useMemo(()=>{switch(a){case`git`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Dh,{isActive:!S})});case`diff`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Zl,{})});case`terminal`:return n?null:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(IS,{})});case`files`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(fp,{})});case`diagram`:return(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(LS,{})});default:return null}},[a,n,S]),L=a===`schedule`,R=a===`assistant`,z=a===`plugin`,ee=L||R||z,B=a===`chat`,te=!ee&&!c;return(0,$.jsx)(zi,{children:(0,$.jsxs)(`div`,{"data-page-scroll-lock":`true`,className:J(`main-content-safe-area`,g?`flex h-[100dvh] flex-col`:`relative flex h-[100dvh]`,`bg-background`),children:[(0,$.jsx)(mc,{}),(0,$.jsx)(Mv,{}),(0,$.jsx)(Iv,{}),(0,$.jsx)(NS,{}),(0,$.jsx)(Vc,{}),g?(0,$.jsxs)(FS,{value:{leftDrawerOpen:b,rightDrawerOpen:S,toggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},toggleRightDrawer:F,leftDrawerX:j,rightDrawerX:N,leftDrawerWidth:M,rightDrawerWidth:P,setMobileLeftDrawerOpen:O,setRightSidebarOpen:C},children:[!c&&!ee&&(0,$.jsx)(Jd,{onToggleLeftDrawer:()=>{let e=!b;S&&C(!1),O(e)},onToggleRightDrawer:()=>{F()},leftDrawerOpen:b,rightDrawerOpen:S}),(0,$.jsx)(`div`,{"data-page-scroll-lock":`true`,className:J(`flex flex-1 overflow-hidden relative`,c&&`hidden`),children:(0,$.jsxs)(`main`,{className:`w-full h-full overflow-hidden bg-background relative`,"data-page-scroll-lock":`true`,children:[L&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Jl,{})})})}),R&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(VS,{})})})}),te&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(cl,{children:(0,$.jsx)(No,{children:(0,$.jsx)(Yl,{})})})}),te&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(cl,{children:(0,$.jsx)(No,{children:I})})}),u&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(No,{children:(0,$.jsx)(ru,{onCreated:()=>d(!1),onCancel:()=>d(!1)})})}),(0,$.jsx)(As.div,{className:J(`absolute inset-0 z-20 bg-sidebar`,!w&&`pointer-events-none invisible`),"data-page-scroll-lock":`true`,style:{x:j},"aria-hidden":!b,children:(0,$.jsx)(No,{children:(0,$.jsx)(kS,{mobileVariant:!0,isVisible:w})})}),E&&(0,$.jsx)(As.div,{className:`absolute inset-0 z-20 bg-sidebar`,"data-page-scroll-lock":`true`,style:{x:N},"aria-hidden":!S,children:(0,$.jsx)(No,{children:(0,$.jsx)(cl,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(Dh,{isActive:S})})})})})]})}),c&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,style:{paddingTop:`var(--yuri-safe-area-top, 0px)`},children:(0,$.jsx)(No,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(RS,{onClose:()=>l(!1)})})})}),(0,$.jsx)(No,{children:(0,$.jsx)(Qc,{})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Sf,{}),(0,$.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,"data-page-scroll-lock":`true`,children:[(0,$.jsx)(hf,{isOpen:e,isMobile:g,className:`border-border/50`,topBar:(0,$.jsx)(gf,{}),children:(0,$.jsx)(kS,{isVisible:e})}),(0,$.jsx)(`div`,{className:`relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:ee?(0,$.jsx)(`main`,{className:`flex-1 overflow-hidden bg-background`,"data-page-scroll-lock":`true`,children:(0,$.jsx)(No,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:z?(0,$.jsx)(Hl,{}):R?(0,$.jsx)(VS,{}):(0,$.jsx)(Jl,{})})})}):(0,$.jsx)(cl,{children:(0,$.jsxs)(Av,{header:(0,$.jsx)(Jd,{}),footer:(0,$.jsx)(of,{isOpen:n,isMobile:g,children:n?(0,$.jsx)(No,{children:(0,$.jsx)(Z.Suspense,{fallback:null,children:(0,$.jsx)(IS,{})})}):null}),children:[te&&(0,$.jsx)(`div`,{className:J(`absolute inset-0`,!B&&`invisible`),children:(0,$.jsx)(No,{children:(0,$.jsx)(Yl,{})})}),te&&I&&(0,$.jsx)(`div`,{className:`absolute inset-0`,children:(0,$.jsx)(No,{children:I})})]})})})]}),(0,$.jsx)(Z.Suspense,{fallback:null,children:f&&(0,$.jsx)(zS,{open:c,onOpenChange:l})}),(0,$.jsx)(Z.Suspense,{fallback:null,children:m&&(0,$.jsx)(BS,{open:u,onOpenChange:d})})]})]})})},US=9e4,WS=15e3,GS=3e5,KS=[2e3,5e3],qS=6e4,JS=12e4,YS=3e5,XS=4,ZS=432e5,QS=`yuri.github-pr-status`,$S=e=>e===`closed`||e===`merged`,eC=e=>{let t=e?.checks;return t?t.state===`pending`||t.pending>0:!1},tC=(e,t,n)=>`${e}::${t}`,nC=new Map,rC=new Map,iC=new Set,aC=new Map,oC=2,sC=0,cC=[],lC=()=>sC<oC?(sC+=1,Promise.resolve()):new Promise(e=>{cC.push(e)}),uC=()=>{let e=cC.shift();if(e){e();return}sC=Math.max(0,sC-1)},dC=()=>({status:null,isLoading:!1,error:null,isInitialStatusResolved:!1,lastRefreshAt:0,lastDiscoveryPollAt:0,watchers:0,params:null,identity:null,resolvedRemoteName:null}),fC=e=>e?.params?.directory&&e.params.branch?{directory:e.params.directory,branch:e.params.branch,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null}:!e?.identity?.directory||!e.identity.branch?null:e.identity,pC=e=>{let t=fC(e);return!t?.directory||!t.branch?null:`${t.directory}::${t.branch}`},mC=(e,t)=>Object.entries(e).filter(([,e])=>pC(e)===t).map(([e])=>e),hC=(e,t)=>{let n=t.remoteName??e.params?.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null;return{...e,params:e.params?{...e.params,...t,remoteName:n}:{...t,remoteName:n},identity:{directory:t.directory,branch:t.branch,remoteName:n}}},gC=e=>!e?.params?.canShow||!e.params.github?.prStatus?null:{...e.params,remoteName:e.params.remoteName??e.resolvedRemoteName??e.identity?.remoteName??null},_C=(e,t,n)=>{let r=mC(e,t),i=r.map(t=>gC(e[t])).filter(e=>!!e);if(i.length===0)return null;let a=gC(e[n]);if(a&&pC(e[n])===t)return a;let o=r.map(t=>e[t]).find(e=>!!(e?.resolvedRemoteName&&gC(e)));return o?gC(o):i.find(e=>!!e.remoteName)||(i[0]??null)},vC=e=>({status:e.status,isInitialStatusResolved:e.isInitialStatusResolved,lastRefreshAt:e.lastRefreshAt,lastDiscoveryPollAt:e.lastDiscoveryPollAt,identity:fC(e),resolvedRemoteName:e.resolvedRemoteName??e.status?.resolvedRemoteName??null}),yC=e=>({...dC(),status:e?.status??null,isInitialStatusResolved:e?.isInitialStatusResolved??!1,lastRefreshAt:e?.lastRefreshAt??0,lastDiscoveryPollAt:e?.lastDiscoveryPollAt??0,identity:e?.identity??null,resolvedRemoteName:e?.resolvedRemoteName??e?.status?.resolvedRemoteName??null}),bC=de()(fe((e,t)=>({entries:{},activeRequestCount:0,totalRequestCount:0,ensureEntry:t=>{e(e=>e.entries[t]?e:{entries:{...e.entries,[t]:dC()}})},setParams:(t,n)=>{e(e=>{let r=e.entries[t]??dC();return{entries:{...e.entries,[t]:hC(r,n)}}})},startWatching:n=>{if(e(e=>{let t=e.entries[n]??dC();return{entries:{...e.entries,[n]:{...t,watchers:t.watchers+1}}}}),nC.has(n))return;let r=e=>{let r=window.setTimeout(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let e=t().entries[n];!e||e.watchers<=0||e.status?.pr||t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0})},e),i=rC.get(n)??[];i.push(r),rC.set(n,i)};t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0}),KS.forEach(e=>r(e));let i=window.setInterval(()=>{if(typeof document<`u`&&document.visibilityState!==`visible`)return;let r=t().entries[n];if(!(!r||r.watchers<=0)){if(!r.status?.pr){let i=Date.now();if(i-r.lastDiscoveryPollAt<GS)return;e(e=>{let t=e.entries[n];return t?{entries:{...e.entries,[n]:{...t,lastDiscoveryPollAt:i}}}:e}),t().refresh(n,{force:!0,silent:!0,markInitialResolved:!0});return}$S(r.status?.pr?.state)||Date.now()-r.lastRefreshAt<(eC(r.status)?qS:r.status?.checks&&r.status.checks.state!==`pending`?YS:JS)||t().refresh(n,{force:!0,onlyExistingPr:!0,silent:!0,markInitialResolved:!0})}},WS);nC.set(n,i)},stopWatching:n=>{e(e=>{let t=e.entries[n];if(!t)return e;let r=Math.max(0,t.watchers-1);return{entries:{...e.entries,[n]:{...t,watchers:r}}}});let r=t().entries[n];if(r&&r.watchers>0)return;let i=nC.get(n);typeof i==`number`&&window.clearInterval(i),nC.delete(n);let a=rC.get(n);a&&a.length>0&&a.forEach(e=>{window.clearTimeout(e)}),rC.delete(n)},refresh:async(n,r)=>{let i=t(),a=i.entries[n],o=pC(a);if(!a||!o)return;let s=mC(i.entries,o),c=s.some(e=>!!i.entries[e]?.status?.pr);if(r?.onlyExistingPr&&!c)return;let l=aC.get(o)??0;if(!r?.force&&Date.now()-l<US||iC.has(o))return;let u=_C(i.entries,o,n);if(u){if(iC.add(o),aC.set(o,Date.now()),e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,lastRefreshAt:Date.now(),isLoading:!r?.silent||n.isLoading,error:null})}),{entries:t}}),u.githubAuthChecked&&u.githubConnected===!1){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:{connected:!1},error:null,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),iC.delete(o);return}if(!u.github?.prStatus){e(e=>{let t={...e.entries};return s.forEach(e=>{let n=t[e];n&&(t[e]={...n,status:null,error:`GitHub runtime API unavailable`,isLoading:r?.silent?n.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||n.isInitialStatusResolved})}),{entries:t}}),iC.delete(o);return}try{e(e=>({...e,activeRequestCount:e.activeRequestCount+1,totalRequestCount:e.totalRequestCount+1})),await lC();let t;try{t=await u.github.prStatus(u.directory,u.branch,u.remoteName??void 0,{force:r?.force})}finally{uC()}e(e=>{let n={...e.entries};return s.forEach(e=>{let i=n[e];if(!i)return;let a=i.status?.pr,o=t.pr,s=o&&a&&o.number===a.number&&(!o.body||!o.body.trim())&&typeof a.body==`string`&&a.body.trim().length>0&&o&&a?.body?{...t,pr:{...o,body:a.body}}:t,c=s.resolvedRemoteName??i.resolvedRemoteName??u.remoteName??null,l=fC(i)??{directory:u.directory,branch:u.branch,remoteName:u.remoteName??null};n[e]={...i,status:s,error:null,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved,resolvedRemoteName:c,identity:{...l,remoteName:c??l.remoteName??null}}}),{entries:n}})}catch(t){let n=t instanceof Error?t.message:String(t);e(e=>{let t={...e.entries};return s.forEach(e=>{let i=t[e];i&&(t[e]={...i,error:n||`Failed to load PR status`,isLoading:r?.silent?i.isLoading:!1,isInitialStatusResolved:r?.markInitialResolved!==!1||i.isInitialStatusResolved})}),{entries:t}})}finally{iC.delete(o),e(e=>({...e,activeRequestCount:Math.max(0,e.activeRequestCount-1)}))}}},refreshTargets:async(e,n)=>{await fy(Array.from(new Set(e.map(e=>{let t=e.directory.trim(),n=e.branch.trim();return!t||!n?null:tC(t,n,e.remoteName??null)}).filter(e=>!!e))),XS,e=>t().refresh(e,n))},updateStatus:(t,n)=>{e(e=>{let r=e.entries[t]??dC();return{entries:{...e.entries,[t]:{...r,status:n(r.status)}}}})}}),{name:QS,storage:Ge(),partialize:e=>({entries:Object.fromEntries(Object.entries(e.entries).filter(([,e])=>{let t=fC(e);if(!t?.directory||!t.branch)return!1;let n=Math.max(e.lastRefreshAt,e.lastDiscoveryPollAt);return n===0||Date.now()-n<ZS}).map(([e,t])=>[e,vC(t)]))}),merge:(e,t)=>{let n=e?.entries??{};return{...t,entries:Object.fromEntries(Object.entries(n).map(([e,t])=>[e,yC(t)]))}}})),xC=e=>{if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;return t<60?`${t.toFixed(1)}s`:`${Math.floor(t/60)}m ${Math.round(t%60)}s`},SC=e=>{let t=(0,Q.c)(8),{label:n,value:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:n}),t[1]=n,t[2]=a);let o;t[3]===r?o=t[4]:(o=(0,$.jsx)(`div`,{className:`typography-markdown font-semibold text-[var(--surface-foreground)]`,children:r}),t[3]=r,t[4]=o);let s;return t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-md p-2`,style:i,children:[a,o]}),t[5]=a,t[6]=o,t[7]=s):s=t[7],s},CC=e=>{let t=(0,Q.c)(43),{title:n,snapshot:r,emptyLabel:i}=e,{t:a}=Nr(),o;if(t[0]!==i||t[1]!==r.durationMs||t[2]!==r.entries||t[3]!==r.lastUpdatedAt||t[4]!==r.startedAt||t[5]!==a||t[6]!==n){let e=r.entries.slice(0,12),s;t[8]===r.entries?s=t[9]:(s=r.entries.reduce(TC,0),t[8]=r.entries,t[9]=s);let c=s,l;t[10]===n?l=t[11]:(l=(0,$.jsx)(`div`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:n}),t[10]=n,t[11]=l);let u;t[12]!==r.durationMs||t[13]!==r.startedAt||t[14]!==a?(u=r.startedAt?xC(r.durationMs):a(`memoryDebugPanel.common.idle`),t[12]=r.durationMs,t[13]=r.startedAt,t[14]=a,t[15]=u):u=t[15];let d;t[16]===u?d=t[17]:(d=(0,$.jsx)(`div`,{className:`typography-meta text-[var(--surface-muted-foreground)]`,children:u}),t[16]=u,t[17]=d);let f;t[18]!==l||t[19]!==d?(f=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[l,d]}),t[18]=l,t[19]=d,t[20]=f):f=t[20];let p;t[21]===a?p=t[22]:(p=a(`memoryDebugPanel.metric.metrics`),t[21]=a,t[22]=p);let m;t[23]!==r.entries.length||t[24]!==p?(m=(0,$.jsx)(SC,{label:p,value:r.entries.length}),t[23]=r.entries.length,t[24]=p,t[25]=m):m=t[25];let h;t[26]===a?h=t[27]:(h=a(`memoryDebugPanel.metric.samples`),t[26]=a,t[27]=h);let g;t[28]!==h||t[29]!==c?(g=(0,$.jsx)(SC,{label:h,value:c}),t[28]=h,t[29]=c,t[30]=g):g=t[30];let _;t[31]===a?_=t[32]:(_=a(`memoryDebugPanel.metric.lastUpdate`),t[31]=a,t[32]=_);let v;t[33]!==r.lastUpdatedAt||t[34]!==a?(v=r.lastUpdatedAt?a(`memoryDebugPanel.common.live`):a(`memoryDebugPanel.common.notAvailable`),t[33]=r.lastUpdatedAt,t[34]=a,t[35]=v):v=t[35];let y;t[36]!==_||t[37]!==v?(y=(0,$.jsx)(SC,{label:_,value:v}),t[36]=_,t[37]=v,t[38]=y):y=t[38];let b;t[39]!==g||t[40]!==y||t[41]!==m?(b=(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[m,g,y]}),t[39]=g,t[40]=y,t[41]=m,t[42]=b):b=t[42],o=(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-[var(--interactive-border)] pt-2 first:border-t-0 first:pt-0`,children:[f,b,e.length===0?(0,$.jsx)(`div`,{className:`rounded-md p-3 typography-meta text-[var(--surface-muted-foreground)]`,style:{backgroundColor:`color-mix(in srgb, var(--surface-muted) 45%, transparent)`},children:i}):(0,$.jsx)(Wr,{outerClassName:`max-h-64`,className:`pr-1`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`rounded-md border border-[var(--interactive-border)] p-2`,style:{backgroundColor:`color-mix(in srgb, var(--surface-elevated) 88%, transparent)`},children:[(0,$.jsx)(`div`,{className:`typography-meta font-medium text-[var(--surface-foreground)] break-all`,children:e.metric}),(0,$.jsxs)(`div`,{className:`mt-1 grid grid-cols-4 gap-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.countValue`,{value:e.count})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.avgValue`,{value:e.avg})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.maxValue`,{value:e.max})}),(0,$.jsx)(`span`,{children:a(`memoryDebugPanel.metric.totalValue`,{value:e.total})})]})]},e.metric))})})]}),t[0]=i,t[1]=r.durationMs,t[2]=r.entries,t[3]=r.lastUpdatedAt,t[4]=r.startedAt,t[5]=a,t[6]=n,t[7]=o}else o=t[7];return o},wC=e=>{let t=(0,Q.c)(104),{onClose:n}=e,{t:r}=Nr(),[i,a]=Z.useState(`memory`),[o,s]=Z.useState(`idle`),c=Vn(EC),l=vr(DC),u=In(),d=yr(),[f,p]=Z.useState(OC),m,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>$e(()=>{p(Qe())}),h=[],t[0]=m,t[1]=h):(m=t[0],h=t[1]),Z.useEffect(m,h);let g;if(t[2]!==d||t[3]!==u){bb0:{let e=Ze(),t={};if(!e){g=t;break bb0}let n=e.getCacheBudget?.(),r=n?n.listCanonical().map(kC):u.map(e=>({directory:d,sessionID:e.id}));for(let n of r){if(d&&n.directory!==d)continue;let r=e.getTranscript(it(n.directory,n.sessionID));t[n.sessionID]=r.messageOrder.map(e=>r.messagesByID[e]).filter(AC)}g=t}t[2]=d,t[3]=u,t[4]=g}else g=t[4];let _=g,v=bC(jC),[y,b]=Z.useState(MC),[x,S]=Z.useState(NC),C;t[5]===y.entries?C=t[6]:(C=new Map,y.entries.forEach(e=>{C.set(e.metric,e.count)}),t[5]=y.entries,t[6]=C);let w;t[7]===C?w=t[8]:(w=C.get(`ui.message_list.render`)??0,t[7]=C,t[8]=w);let T;t[9]===C?T=t[10]:(T=C.get(`ui.message_list.render.streaming`)??0,t[9]=C,t[10]=T);let E;t[11]===C?E=t[12]:(E=C.get(`ui.chat_message.render`)??0,t[11]=C,t[12]=E);let D;t[13]===C?D=t[14]:(D=C.get(`ui.chat_message.render.streaming`)??0,t[13]=C,t[14]=D);let O;t[15]===C?O=t[16]:(O=C.get(`ui.chat_message.render.static_during_stream`)??0,t[15]=C,t[16]=O);let k;t[17]===C?k=t[18]:(k=C.get(`ui.chat_message.render.static_outside_active_turn_during_stream`)??0,t[17]=C,t[18]=k);let A;t[19]!==w||t[20]!==T||t[21]!==E||t[22]!==D||t[23]!==O||t[24]!==k?(A={messageListRender:w,messageListRenderStreaming:T,chatMessageRender:E,chatMessageRenderStreaming:D,chatMessageRenderStaticDuringStream:O,chatMessageRenderStaticOutsideActiveTurnDuringStream:k},t[19]=w,t[20]=T,t[21]=E,t[22]=D,t[23]=O,t[24]=k,t[25]=A):A=t[25];let j=A,M,N;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>{let e=()=>{b(Me()),S(Ve())};e();let t=window.setInterval(e,500);return()=>window.clearInterval(t)},N=[],t[26]=M,t[27]=N):(M=t[26],N=t[27]),Z.useEffect(M,N);let P,F;t[28]===o?(P=t[29],F=t[30]):(P=()=>{if(o===`idle`)return;let e=window.setTimeout(()=>{s(`idle`)},1500);return()=>window.clearTimeout(e)},F=[o],t[28]=o,t[29]=P,t[30]=F),Z.useEffect(P,F);let I=0,L=0,R=0;for(let e of Object.keys(_)){let t=_[e]??[];L+=t.length;for(let e of t)e.role===`user`?R+=1:e.role===`assistant`&&(I+=1)}let z;t[31]!==I||t[32]!==L||t[33]!==R?(z={assistant:I,total:L,user:R},t[31]=I,t[32]=L,t[33]=R,t[34]=z):z=t[34];let ee=z,B;if(t[35]!==c||t[36]!==_||t[37]!==l||t[38]!==u||t[39]!==r){let e;t[41]!==c||t[42]!==_||t[43]!==l||t[44]!==r?(e=e=>{let t=_[e.id]??[],n=0,i=0;for(let e of t)e.role===`user`?i+=1:e.role===`assistant`&&(n+=1);let a=l.get(e.id);return{id:e.id,title:e.title||r(`memoryDebugPanel.common.untitled`),assistantMessageCount:n,messageCount:t.length,userMessageCount:i,isStreaming:a?.isStreaming||!1,isZombie:a?.isZombie||!1,backgroundCount:a?.backgroundMessageCount||0,lastAccessed:a?.lastAccessedAt||0,isCurrent:e.id===c}},t[41]=c,t[42]=_,t[43]=l,t[44]=r,t[45]=e):e=t[45],B=u.map(e).sort(PC),t[35]=c,t[36]=_,t[37]=l,t[38]=u,t[39]=r,t[40]=B}else B=t[40];let te=B,ne;t[46]===_?ne=t[47]:(ne=Object.keys(_),t[46]=_,t[47]=ne);let re=ne.length,ie;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(ie=async()=>{try{let e={generatedAt:new Date().toISOString(),ui:Me(),vscode:Ve()};await navigator.clipboard.writeText(JSON.stringify(e,null,2)),s(`copied`)}catch{s(`error`)}},t[48]=ie):ie=t[48];let ae=ie,oe;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(oe={backgroundColor:`color-mix(in srgb, var(--surface-background) 94%, transparent)`},t[49]=oe):oe=t[49];let V;t[50]===i?V=t[51]:(V=i===`memory`?(0,$.jsx)(X,{name:`database-2`,className:`h-4 w-4 text-[var(--surface-foreground)]`}):(0,$.jsx)(X,{name:`bar-chart-box`,className:`h-4 w-4 text-[var(--surface-foreground)]`}),t[50]=i,t[51]=V);let H;t[52]===r?H=t[53]:(H=r(`memoryDebugPanel.title`),t[52]=r,t[53]=H);let se;t[54]===H?se=t[55]:(se=(0,$.jsx)(`h3`,{className:`typography-ui-label font-semibold text-[var(--surface-foreground)]`,children:H}),t[54]=H,t[55]=se);let U;t[56]!==V||t[57]!==se?(U=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[V,se]}),t[56]=V,t[57]=se,t[58]=U):U=t[58];let ce;t[59]===i?ce=t[60]:(ce=i===`streaming`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(q,{size:`xs`,variant:`ghost`,onClick:ae,children:(0,$.jsx)(X,{name:`file-copy`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(q,{size:`xs`,variant:`ghost`,onClick:()=>{Le(),b(Me()),S(Ve())},children:(0,$.jsx)(X,{name:`refresh`,className:`h-3.5 w-3.5`})})]}):null,t[59]=i,t[60]=ce);let le;t[61]===n?le=t[62]:(le=n?(0,$.jsx)(q,{size:`icon`,variant:`ghost`,className:`h-6 w-6`,onClick:n,children:(0,$.jsx)(X,{name:`close`,className:`h-4 w-4`})}):null,t[61]=n,t[62]=le);let ue;t[63]!==ce||t[64]!==le?(ue=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[ce,le]}),t[63]=ce,t[64]=le,t[65]=ue):ue=t[65];let de;t[66]!==U||t[67]!==ue?(de=(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[U,ue]}),t[66]=U,t[67]=ue,t[68]=de):de=t[68];let fe;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(fe={backgroundColor:`color-mix(in srgb, var(--surface-muted) 55%, transparent)`},t[69]=fe):fe=t[69];let pe=i===`memory`?`secondary`:`ghost`,me;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(me=()=>a(`memory`),t[70]=me):me=t[70];let he;t[71]===r?he=t[72]:(he=r(`memoryDebugPanel.tabs.memory`),t[71]=r,t[72]=he);let ge;t[73]!==pe||t[74]!==he?(ge=(0,$.jsx)(q,{size:`sm`,variant:pe,className:`flex-1`,onClick:me,children:he}),t[73]=pe,t[74]=he,t[75]=ge):ge=t[75];let _e=i===`streaming`?`secondary`:`ghost`,ve;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ve=()=>a(`streaming`),t[76]=ve):ve=t[76];let ye;t[77]===r?ye=t[78]:(ye=r(`memoryDebugPanel.tabs.streaming`),t[77]=r,t[78]=ye);let be;t[79]!==_e||t[80]!==ye?(be=(0,$.jsx)(q,{size:`sm`,variant:_e,className:`flex-1`,onClick:ve,children:ye}),t[79]=_e,t[80]=ye,t[81]=be):be=t[81];let xe;t[82]!==ge||t[83]!==be?(xe=(0,$.jsxs)(`div`,{className:`mb-3 flex gap-1 rounded-md p-1`,style:fe,children:[ge,be]}),t[82]=ge,t[83]=be,t[84]=xe):xe=t[84];let Se;t[85]!==i||t[86]!==re||t[87]!==o||t[88]!==c||t[89]!==_||t[90]!==ee||t[91]!==l||t[92]!==te||t[93]!==u||t[94]!==j||t[95]!==y||t[96]!==r||t[97]!==v||t[98]!==x?(Se=i===`memory`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 typography-meta`,children:[(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.totalMessages`),value:ee.total}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.cachedSessions`),value:`${re} / ${Uo.MAX_SESSIONS}`}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.userMessages`),value:ee.user}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.assistantMessages`),value:ee.assistant})]}),(0,$.jsxs)(`div`,{className:`typography-meta space-y-1 border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.viewportWindow`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.messagesValue`,{count:Xo()})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.zombieTimeout`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.minutesValue`,{count:Uo.ZOMBIE_TIMEOUT/1e3/60})})]}),(0,$.jsxs)(`div`,{className:`flex justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.githubTotalRequests`)}),(0,$.jsx)(`span`,{className:`text-[var(--surface-foreground)]`,children:v})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--interactive-border)] pt-2`,children:[(0,$.jsx)(`div`,{className:`mb-1 typography-meta font-semibold text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.section.sessionsInMemory`)}),(0,$.jsx)(Wr,{outerClassName:`max-h-48`,className:`space-y-1 pr-1`,children:te.map(e=>(0,$.jsxs)(`div`,{className:`typography-meta flex items-center justify-between rounded p-1.5`,style:{backgroundColor:e.isCurrent?`color-mix(in srgb, var(--interactive-selection) 22%, transparent)`:`color-mix(in srgb, var(--surface-muted) 35%, transparent)`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate text-[var(--surface-foreground)]`,children:e.title}),e.isStreaming?(0,$.jsx)(X,{name:`pulse`,className:`h-3 w-3 animate-pulse text-[var(--status-info)]`}):null,e.isZombie?(0,$.jsx)(`span`,{className:`text-[var(--status-warning)]`,children:`!`}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-muted-foreground)]`,children:r(`memoryDebugPanel.metric.roleMsgsValue`,{assistant:e.assistantMessageCount,user:e.userMessageCount})}),(0,$.jsx)(`span`,{className:`font-mono text-[var(--surface-foreground)]`,children:r(`memoryDebugPanel.metric.msgsValue`,{count:e.messageCount})}),e.backgroundCount>0?(0,$.jsxs)(`span`,{className:`text-[var(--status-info)]`,children:[`+`,e.backgroundCount]}):null]})]},e.id))})]}),(0,$.jsx)(`div`,{className:`flex gap-2 border-t border-[var(--interactive-border)] pt-2`,children:(0,$.jsxs)(ni,{children:[(0,$.jsx)($r,{asChild:!0,children:(0,$.jsx)(q,{size:`sm`,variant:`outline`,className:`typography-meta`,onClick:()=>{u.map(FC),Object.keys(_),te.map(IC),Object.fromEntries(l)},children:r(`memoryDebugPanel.actions.logState`)})}),(0,$.jsx)(ei,{side:`top`,children:r(`memoryDebugPanel.tooltip.logCurrentState`)})]})})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-md border border-[var(--interactive-border)] px-3 py-2 typography-meta text-[var(--surface-muted-foreground)]`,children:[(0,$.jsx)(`span`,{children:r(o===`copied`?`memoryDebugPanel.streaming.copy.copied`:o===`error`?`memoryDebugPanel.streaming.copy.failed`:`memoryDebugPanel.streaming.copy.hint`)}),(0,$.jsx)(q,{size:`xs`,variant:`outline`,onClick:ae,children:r(`memoryDebugPanel.actions.copyJson`)})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.uiMetrics`),value:y.entries.length}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.vscodeMetrics`),value:x.entries.length}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.messageListRenders`),value:j.messageListRender}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.messageListStreamRenders`),value:j.messageListRenderStreaming}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.chatMessageRenders`),value:j.chatMessageRender}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.chatMessageStreamRenders`),value:j.chatMessageRenderStreaming}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.chatMessageStaticDuringStream`),value:j.chatMessageRenderStaticDuringStream}),(0,$.jsx)(SC,{label:r(`memoryDebugPanel.metric.chatMessageStaticOutsideActiveTurn`),value:j.chatMessageRenderStaticOutsideActiveTurnDuringStream})]}),(0,$.jsx)(CC,{title:r(`memoryDebugPanel.section.uiStreamingMetrics`),snapshot:y,emptyLabel:r(`memoryDebugPanel.section.noUiSamples`)}),x.entries.length>0?(0,$.jsx)(CC,{title:r(`memoryDebugPanel.section.vscodeBridgeMetrics`),snapshot:x,emptyLabel:r(`memoryDebugPanel.section.noVscodeSamples`)}):null]}),t[85]=i,t[86]=re,t[87]=o,t[88]=c,t[89]=_,t[90]=ee,t[91]=l,t[92]=te,t[93]=u,t[94]=j,t[95]=y,t[96]=r,t[97]=v,t[98]=x,t[99]=Se):Se=t[99];let Ce;return t[100]!==de||t[101]!==xe||t[102]!==Se?(Ce=(0,$.jsxs)(Mo,{className:`fixed bottom-4 right-4 z-50 w-[28rem] p-4 shadow-none bottom-safe-area`,style:oe,children:[de,xe,Se]}),t[100]=de,t[101]=xe,t[102]=Se,t[103]=Ce):Ce=t[103],Ce};function TC(e,t){return e+t.count}function EC(e){return e.currentSessionId}function DC(e){return e.sessionMemoryState}function OC(){return Qe()}function kC(e){return e.scope}function AC(e){return!!e}function jC(e){return e.totalRequestCount}function MC(){return Me()}function NC(){return Ve()}function PC(e,t){return t.lastAccessed-e.lastAccessed}function FC(e){return{id:e.id,title:e.title}}function IC(e){return{id:e.id,title:e.title,total:e.messageCount,user:e.userMessageCount,assistant:e.assistantMessageCount}}var LC=()=>{let{isMobile:e,closeActiveContextPanelTab:t}=K.getState();if(e)return;let n=Wi();n&&t(n)||ee()&&I(`desktop_close_current_window`).catch(e=>{console.warn(`[menu-actions] failed to close current window`,e)})},RC=()=>{if(typeof document>`u`)return``;let e=document.activeElement;if(e instanceof HTMLTextAreaElement)return e.value.slice(e.selectionStart??0,e.selectionEnd??0);if(e instanceof HTMLInputElement){let t=e.type?.toLowerCase()??`text`;if([`text`,`search`,`url`,`tel`,`password`].includes(t))return e.value.slice(e.selectionStart??0,e.selectionEnd??0)}return e instanceof HTMLElement&&e.isContentEditable?e.ownerDocument.defaultView?.getSelection?.()?.toString()??``:``},zC=async()=>{let e=RC()||window.getSelection()?.toString()||``;if(!e.trim())return!1;try{if(typeof navigator<`u`&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}return document.execCommand(`copy`)},BC=`yuri:menu-action`,VC=`yuri:check-for-updates`,HC=e=>typeof e?.listen==`function`?`bridge`:`dom`,UC=e=>{let t=Vn(e=>e.openNewSessionDraft),n=K(e=>e.toggleCommandPalette),r=K(e=>e.setCommandPaletteOpen),i=K(e=>e.toggleHelpDialog),a=K(e=>e.toggleSidebar),o=K(e=>e.setSessionSwitcherOpen),s=K(e=>e.setActiveMainTab),c=K(e=>e.setSettingsDialogOpen),l=K(e=>e.setSettingsPage),u=K(e=>e.setAboutDialogOpen),d=K(e=>e.toggleContextPanel),f=K(e=>e.setRightSidebarOpen),p=K(e=>e.setRightSidebarTab),m=K(e=>e.toggleBottomTerminal),h=K(e=>e.setBottomTerminalExpanded),g=El(e=>e.checkForUpdates),{setThemeMode:_}=ai(),{t:v}=Nr(),y=Z.useRef(!1),b=typeof window>`u`?null:window.__YURI_DESKTOP__,x=HC(b),S=Z.useCallback(()=>{y.current||(y.current=!0,g().then(()=>{let{available:e,error:t}=El.getState();if(t){Y.error(v(`sessions.sidebar.updateCheck.errorTitle`),{description:t});return}e||Y.success(v(`sessions.sidebar.updateCheck.latestVersion`))}).finally(()=>{y.current=!1}))},[g,v]),C=Z.useCallback(()=>{Nn.requestDirectoryDialog()},[]),w=Z.useCallback(e=>{oo(e,Vn.getState().currentSessionId,e=>{s(`chat`),o(!1),Vn.getState().setCurrentSession(e.sessionId,e.directory)})},[s,o]),T=Z.useCallback(e=>{let{activeProjectId:t,projects:n,setActiveProject:r}=$t.getState();if(n.length===0)return;let i=n.findIndex(e=>e.id===t),a=e>0?0:n.length-1;i>=0&&(a=(i+e+n.length)%n.length);let o=n[a];o&&r(o.id)},[]),E=Z.useCallback(g=>{switch(g){case`about`:u(!0);break;case`settings`:c(!0);break;case`switch-instance`:l(`remote-instances`),c(!0);break;case`command-palette`:n();break;case`quick-open`:r(!0);break;case`new-session`:s(`chat`),o(!1),t();break;case`new-worktree-session`:s(`chat`),o(!1),ds();break;case`change-workspace`:C();break;case`close-tab-or-window`:LC();break;case`toggle-right-sidebar`:{let e=Wi();e&&d(e);break}case`open-right-sidebar-git`:{let e=Wi();e&&K.getState().openContextPanel(e),f(!0),p(`git`);break}case`open-right-sidebar-files`:{let e=Wi();e&&K.getState().openContextPanel(e),f(!0),p(`files`);break}case`toggle-terminal`:m();break;case`toggle-terminal-expanded`:h(!K.getState().isBottomTerminalExpanded);break;case`copy`:{let e=new Event(`yuri:copy`,{cancelable:!0});window.dispatchEvent(e)&&zC();break}case`theme-light`:_(`light`);break;case`theme-dark`:_(`dark`);break;case`theme-system`:_(`system`);break;case`toggle-sidebar`:a();break;case`toggle-memory-debug`:e?.();break;case`zoom-in`:Xa();break;case`zoom-out`:Za();break;case`zoom-reset`:lo();break;case`go-back`:W.getState().goBack();break;case`go-forward`:W.getState().goForward();break;case`previous-session`:w(-1);break;case`next-session`:w(1);break;case`previous-project`:T(-1);break;case`next-project`:T(1);break;case`help-dialog`:i();break;case`download-logs`:mo().catch(()=>{Y.error(`Failed to collect OpenCode status`)})}},[C,T,w,e,t,u,s,o,r,c,l,h,f,p,_,m,n,i,d,a]);Z.useEffect(()=>{if(x!==`dom`)return;let e=e=>{let t=e.detail;t&&E(t)},t=()=>{S()};return window.addEventListener(BC,e),window.addEventListener(VC,t),()=>{window.removeEventListener(BC,e),window.removeEventListener(VC,t)}},[E,S,x]),Z.useEffect(()=>{if(x!==`bridge`)return;let e=b?.listen;if(typeof e!=`function`)return;let t=null,n=null;return e(`yuri:menu-action`,e=>{let t=e?.payload;typeof t==`string`&&E(t)}).then(e=>{t=e}).catch(()=>{}),e(`yuri:check-for-updates`,S).then(e=>{n=e}).catch(()=>{}),()=>{(async()=>{try{let e=t?.();e instanceof Promise&&await e}catch{}try{let e=n?.();e instanceof Promise&&await e}catch{}})()}},[b,E,S,x])},WC=(e,t)=>e<t?-1:+(e>t),GC=e=>JSON.stringify([...e.entries()].map(([e,t])=>[e,[...new Set(t)].sort(WC)]).sort(([e],[t])=>WC(e,t)));async function KC({targets:e,isReady:t,fetchStatus:n,applySnapshot:r,concurrency:i=2,isDisposed:a=()=>!1}){if(!t()||a())return;let o=[...e.entries()],s=0,c=Math.min(Math.max(1,i),o.length),l=async()=>{for(;s<o.length&&t()&&!a();){let e=o[s];if(s+=1,!e)return;let[t,i]=e,c=await n(t);c===null||a()||r(t,c,i)}};await Promise.all(Array.from({length:c},()=>l()))}var qC=`yuri:tray-action`,JC=3e4,YC=120,XC=20,ZC=()=>{if(typeof window>`u`)return!1;let e=window.__YURI_PLATFORM__;return e===`darwin`||e===`win32`},QC=e=>{let t=typeof e.permission==`string`?e.permission:`Permission`,n=Array.isArray(e.patterns)?e.patterns.find(e=>typeof e==`string`&&e.trim()):``;return n?`${t}: ${n}`:t},$C=e=>{let t=Array.isArray(e.questions)?e.questions[0]:void 0;return t?.header||t?.question||`Question`},ew=e=>sr(e),tw=e=>{let t=e.replace(/\\/g,`/`).replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},nw=(e,t,n,r)=>{if(!e)return``;let i=yn(t,n,e),a=tw(i?i.path:e),o=kn(e),s=o&&r.get(o)||``;if(!s){for(let[e,t]of Qi.getState().directories)if(kn(e)===o){s=t.status?.current??``;break}}if(!s)for(let e of n.values()){let t=e.find(e=>kn(e.path)===o);if(t?.branch){s=t.branch;break}}return s?`${a} · ${s}`:a},rw=()=>{let{results:e,dropdownProviderIds:t,displayMode:n}=Xs.getState(),r=n===`remaining`?`remaining`:`usage`;if(!t.length)return{mode:r,groups:[]};let i=new Map(e.map(e=>[e?.providerId,e])),a=[];for(let n of Zs(e)){if(!t.includes(n.id))continue;let e=i.get(n.id);if(!e||e.configured!==!0)continue;let o=[];for(let[t,n]of Object.entries(e.usage?.windows??{})){let e=r===`remaining`?n.remainingPercent:n.usedPercent;o.push({label:tc(n.label??t),value:Qs(n.valueLabel,e)})}let s=!e.ok&&e.error?e.error:o.length===0?`No rate limits reported`:null;a.push({provider:n.name,rows:o,status:s})}return{mode:r,groups:a}},iw=async()=>{try{if(w())return`Local Yuri`;let e=window.__YURI_LOCAL_ORIGIN__||window.location.origin,t=h();if(t&&U(t,e))return`Local Yuri`;let n=(await le()).hosts.find(e=>t?U(t,se(e)):!1);return n?.label?.trim()?ue(n.label.trim()):`Instance`}catch{return``}},aw=()=>{let e=new Map,t=new Map,n=[],r=new Map,i;try{i=et()}catch{return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}}for(let[a,o]of i.children.entries()){let i=o.getState(),s=typeof i.vcs?.branch==`string`?i.vcs.branch:typeof i.vcs?.branch?.current==`string`?i.vcs.branch.current:``;s&&t.set(kn(a)??a,s);for(let e of i.session)!e?.id||!e.title||r.set(e.id,e.title);for(let[t,n]of Object.entries(i.session_status??{})){let r=n?.type,i=r===`busy`?`busy`:r===`retry`?`retry`:`idle`,a=e.get(t);(!a||a===`idle`)&&e.set(t,i)}for(let[e,t]of Object.entries(i.permission??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`permission`,id:r.id,sessionId:t,sessionTitle:``,label:QC(r),directory:a})}for(let[e,t]of Object.entries(i.question??{}))for(let r of t??[]){if(!r?.id)continue;let t=r.sessionID||e;n.push({kind:`question`,id:r.id,sessionId:t,sessionTitle:``,label:$C(r),directory:a})}}return{statusById:e,branchByDirectory:t,approvals:n,titleById:r}},ow=()=>{let e=on.getState().activeSessions,t=new Set;e.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>ew(t)-ew(e)).slice(0,XC).forEach(e=>{let n=hn(e);n&&t.add(n)});let n=new Map;for(let r of e){if(!r?.id)continue;let e=hn(r);if(!e||!t.has(e))continue;let i=n.get(e)??[];i.push(r.id),n.set(e,i)}return n},sw=e=>{let t=aw(),n=On.getState().index.session,r=on.getState().activeSessions,i=new Map(t.titleById),a=new Map;for(let e of r)if(e?.id&&(e.title&&i.set(e.id,e.title),e.parentID)){let t=a.get(e.parentID)??[];t.push(e.id),a.set(e.parentID,t)}let o=e=>{let t=[],n=[...a.get(e)??[]],r=new Set;for(;n.length;){let e=n.pop();r.has(e)||(r.add(e),t.push(e),n.push(...a.get(e)??[]))}return t},s=Fn.getState().statusById,c=e=>{let n=t.statusById.get(e);return n&&n!==`idle`?n:s.get(e)?.status??n??`idle`},l=e=>{let t=e.map(e=>c(e));return t.includes(`busy`)?`busy`:t.includes(`retry`)?`retry`:`idle`},u=$t.getState().projects,d=Vn.getState().availableWorktreesByProject,f=r.filter(e=>e?.id&&!e.parentID).slice().sort((e,t)=>ew(t)-ew(e)).slice(0,XC).map(e=>{let r=[e.id,...o(e.id)],i=hn(e)??``;return{id:e.id,title:e.title||`Untitled session`,status:l(r),branch:i?t.branchByDirectory.get(i)??``:``,unseen:n.unseenCount[e.id]??0,hasError:n.unseenHasError[e.id]??!1,directory:i,subtitle:nw(i,u,d,t.branchByDirectory)}}),p=t.approvals.map(e=>({...e,sessionTitle:i.get(e.sessionId)||``})),m=K.getState(),h=0;if(m.dockBadgeEnabled)for(let e of r)!e?.id||e.parentID||(n.unseenCount[e.id]??0)>0&&(h+=1);return{sessions:f,approvals:p,instanceName:e,usage:rw(),dockBadgeCount:h}},cw=()=>{Z.useEffect(()=>{if(!ZC()||!ee())return;let e=!1,t=``,n=null,r=``,i=()=>{if(e)return;let n=sw(r),i=JSON.stringify(n);i!==t&&(t=i,I(`desktop_tray_update`,n))};iw().then(t=>{e||(r=t,i())});let a=null,o=``,s=()=>{let e=An.getState();return e.isConnected&&e.connectionPhase===`connected`},c=()=>{if(a)return a;let t=ow();return o=GC(t),a=KC({targets:t,isReady:s,concurrency:2,isDisposed:()=>e,fetchStatus:async()=>{try{let e=await rt.getSdkClient().session.active();if(!e||typeof e!=`object`||Array.isArray(e))return null;let t={};for(let[n,r]of Object.entries(e))r?.type===`running`&&(t[n]={type:`busy`});return t}catch{return null}},applySnapshot:(e,t,n)=>{xr(e,t,[...n])}}).finally(()=>{a=null;let t=ow();!e&&s()&&GC(t)!==o&&c()}),a},l=()=>{e||n!==null||(n=window.setTimeout(()=>{n=null,i()},YC))},u=new Map,d=()=>{if(e)return;let t;try{t=et()}catch{return}let n=new Set;for(let[e,r]of t.children.entries())n.add(e),u.has(e)||u.set(e,r.subscribe(()=>l()));for(let[e,t]of u)n.has(e)||(t(),u.delete(e))},f=null;try{f=et().subscribeRegistry(()=>{d(),l()})}catch{}d();let p=On.subscribe(()=>l()),m=on.subscribe(()=>{l(),s()&&GC(ow())!==o&&c()}),h=$t.subscribe(()=>l()),g=Vn.subscribe(()=>l()),_=Qi.subscribe(()=>l()),v=K.subscribe(()=>l()),y=Fn.subscribe(()=>l()),b=s(),x=An.subscribe(()=>{let e=s();e&&!b&&c(),b=e});b&&c();let S=Xs.subscribe(()=>l());Xs.getState().loadSettings().then(()=>{if(e)return;let{dropdownProviderIds:t,results:n}=Xs.getState();t.length>0&&t.some(e=>!n.some(t=>t?.providerId===e))&&Xs.getState().fetchAllQuotas()});let C=window.setInterval(()=>{let e=Xs.getState();e.autoRefresh&&e.dropdownProviderIds.length>0&&e.fetchAllQuotas()},Math.max(3e4,Xs.getState().refreshIntervalMs||6e4)),w=window.setInterval(()=>{d(),i()},JC);return i(),()=>{e=!0,n!==null&&window.clearTimeout(n),window.clearInterval(w),window.clearInterval(C),p(),m(),h(),g(),_(),v(),y(),x(),S(),f?.();for(let e of u.values())e();u.clear()}},[]),Z.useEffect(()=>{if(!ZC()||typeof window>`u`)return;let e=window.__YURI_DESKTOP__?.listen;if(typeof e!=`function`)return;let t=e=>{e.type===`respond-permission`&&jn(e.sessionId,e.id,e.response).catch(()=>{Y.error(`Failed to respond to permission request`)})},n=null;return e(qC,e=>{let n=e?.payload;!n||typeof n!=`object`||typeof n.type!=`string`||t(n)}).then(e=>{n=e}).catch(()=>{}),()=>{try{let e=n?.();e instanceof Promise&&e.catch(()=>{})}catch{}}},[])},lw=`/api/notifications/stream`,uw=()=>typeof document>`u`||document.visibilityState===`visible`&&document.hasFocus(),dw=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=t.properties&&typeof t.properties==`object`?t.properties:null;return t.type!==`yuri:notification`||!n?null:{title:typeof n.title==`string`?n.title:void 0,body:typeof n.body==`string`?n.body:void 0,tag:typeof n.tag==`string`?n.tag:void 0,requireHidden:n.requireHidden===!0||n.requireHidden!==!1&&void 0}},fw=e=>{let t=(0,Q.c)(3),n=e?.enabled??!0,r,i;t[0]===n?(r=t[1],i=t[2]):(r=()=>{if(!n||y()||!oe()||typeof window>`u`||typeof EventSource>`u`)return;let e=new EventSource(l().sse(lw));return e.onmessage=pw,()=>{e.close()}},i=[n],t[0]=n,t[1]=r,t[2]=i),Z.useEffect(r,i)};function pw(e){let t;try{t=JSON.parse(e.data)}catch{return}let n=K.getState();if(!n.nativeNotificationsEnabled)return;let r=dw(t);r&&((r.requireHidden??n.notificationMode!==`always`)&&uw()||H()?.notifications?.notifyAgentCompletion(r))}var mw=`pwa-install-toast-shown`,hw=`pwa-install-toast-dismissed`,gw=()=>{let e=(0,Q.c)(6),{browserTab:t}=du(),{t:n}=Nr(),r=Z.useRef(n),i,a;e[0]===n?(i=e[1],a=e[2]):(i=()=>{r.current=n},a=[n],e[0]=n,e[1]=i,e[2]=a),Z.useEffect(i,a);let o,s;e[3]===t?(o=e[4],s=e[5]):(o=()=>{if(typeof window>`u`||!oe()||!t)return;let e=null,n=null,i=()=>{n!==null&&(Y.dismiss(n),n=null)},a=async()=>{if(!e)return;let t=e;e=null,i(),await t.prompt();let{outcome:n}=await t.userChoice;n===`accepted`&&Y.success(r.current(`pwa.installPrompt.started`))},o=t=>{let o=t;if(typeof o.prompt!=`function`)return;o.preventDefault(),e=o;let s=Ue(),c=We();Ec({dismissed:s.getItem(hw),sessionShown:c.getItem(mw),hasActiveToast:n!==null})&&(c.setItem(mw,`true`),n=Y.info(r.current(`pwa.installPrompt.description`),{duration:1/0,action:{label:r.current(`pwa.installPrompt.action`),onClick:()=>{a()}},cancel:{label:r.current(`pwa.installPrompt.dismiss`),onClick:()=>{Ue().setItem(hw,`true`),i()}}}))},s=()=>{e=null,i(),Y.success(r.current(`pwa.installPrompt.installed`))};return window.addEventListener(`beforeinstallprompt`,o),window.addEventListener(`appinstalled`,s),()=>{i(),window.removeEventListener(`beforeinstallprompt`,o),window.removeEventListener(`appinstalled`,s)}},s=[t],e[3]=t,e[4]=o,e[5]=s),Z.useEffect(o,s)},_w=0;function vw(e){let t=typeof e?.sessionId==`string`?e.sessionId.trim():``;if(!t)return;let n=++_w,r=typeof e?.directory==`string`&&e.directory.trim().length>0?e.directory.trim():null;if(K.getState().setActiveMainTab(`chat`),e.hostId||e.hubId||e.instanceId){if(!e.hostId||!e.hubId||!r)return;Lt(async()=>{let{applyRemoteProjectRoute:e}=await import(`./navigation-C1v9hIAT.js`).then(e=>e.n);return{applyRemoteProjectRoute:e}},__vite__mapDeps([209,1,3,2,13,4,5,6,7,8,9,10,12,11,14,15,16,17,18,19,20,37,22,38,23,24,39,40,41,42,21,25,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57])).then(({applyRemoteProjectRoute:i})=>{if(n===_w)return i({sessionId:t,directory:r,hostId:e.hostId,hubId:e.hubId,...e.instanceId?{instanceId:e.instanceId}:{},isNewSession:!1},()=>n===_w)}).catch(()=>console.warn(`[remote-session] Notification navigation failed`));return}Vn.getState().setCurrentSession(t,r)}var yw=({open:e,onOpenChange:t})=>{let{t:n}=Nr(),[r,i]=Z.useState(null),[a,o]=Z.useState(null);Z.useEffect(()=>{e&&(async()=>{try{let e=await g(`/api/system/info`);if(e.ok){let t=await e.json();if(typeof t.yuriVersion==`string`&&t.yuriVersion.trim()){i(t.yuriVersion);return}}}catch{}i(await Ar())})()},[e]),Z.useEffect(()=>{if(!e)return;let t=!1;return(async()=>{try{let e=await g(`/api/opencode/upgrade-status`,{headers:{Accept:`application/json`}});if(!e.ok)return;let n=await e.json().catch(()=>null),r=typeof n?.currentVersion==`string`?n.currentVersion.trim():``;!t&&r&&o(r)}catch{}})(),()=>{t=!0}},[e]);let s=r;return(0,$.jsx)(Qr,{open:e,onOpenChange:t,children:(0,$.jsx)(Yr,{className:`max-w-xs p-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsx)(jo,{width:48,height:48}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Yuri`}),(0,$.jsxs)(`div`,{className:`space-y-0.5 typography-meta text-muted-foreground`,children:[s&&(0,$.jsx)(`p`,{children:n(`aboutDialog.yuriVersionLabel`,{version:s})}),a&&(0,$.jsx)(`p`,{children:n(`aboutDialog.openCodeVersionLabel`,{version:a})})]})]}),(0,$.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri`,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(X,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]})}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground/60`,children:n(`aboutDialog.footerNote`)})]})})})},bw=(e,t)=>{let n=e.get(t);return typeof n==`string`&&n.trim()||null},xw=(e,t)=>{let n=e instanceof Error?e.message:t;return/oauth state required/i.test(n)?`Authorization session expired or was cleared during reload. Return to Yuri and click Authorize again.`:n},Sw=()=>{let e=Pl(e=>e.completeAuth),[t,n]=Z.useState(`working`),[r,i]=Z.useState(`Completing MCP authorization...`);return Z.useEffect(()=>{if(typeof window>`u`){n(`error`),i(`Browser context unavailable.`);return}let t=new URLSearchParams(window.location.search),r=bw(t,`code`),a=lu(t),o=iu(t),s=bw(t,`error`),c=bw(t,`error_description`);if(s){o&&g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(c??s);return}(async()=>{try{if(!r)throw Error(`Missing OAuth authorization code. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);let t=a;if(!t&&o){let e=await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`);if(e.ok){let n=await e.json().catch(()=>null);n?.name?.trim()&&(t={name:n.name.trim(),directory:typeof n.directory==`string`&&n.directory.trim()?n.directory.trim():null})}}if(!t?.name)throw Error(`Authorization session details were not available. Start authorization again from MCP Settings or paste the returned code into Yuri manually.`);await e(t.name,r,t.directory),o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`success`),i(`Authorization completed. You can close this tab and return to Yuri.`)}catch(e){o&&await g(`/api/mcp/auth/pending?state=${encodeURIComponent(o)}`,{method:`DELETE`}).catch(()=>void 0),n(`error`),i(xw(e,`Failed to complete MCP authorization.`))}})()},[e]),(0,$.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-background px-6 py-12 text-foreground`,children:(0,$.jsxs)(`div`,{className:`w-full max-w-xl rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-8 shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 text-center`,children:[(0,$.jsx)(`div`,{className:t===`error`?`text-[var(--status-error)]`:t===`success`?`text-[var(--status-success)]`:`text-[var(--status-info)]`,children:(0,$.jsx)(`h1`,{className:`typography-hero font-semibold`,children:t===`working`?`Completing Authorization`:t===`success`?`Authorization Complete`:`Authorization Failed`})}),(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:r})]}),t!==`working`&&(0,$.jsx)(`div`,{className:`mt-8 flex justify-center`,children:(0,$.jsx)(q,{type:`button`,onClick:()=>{typeof window>`u`||window.location.replace(`/`)},children:`Return to Yuri`})})]})})},Cw=()=>{let e=on(e=>e.startupSyncProgress.active),t=on(e=>e.startupSyncProgress.phase),n=on(e=>e.startupSyncProgress.completed),r=on(e=>e.startupSyncProgress.total),{locale:i,t:a}=Nr(),[o,s]=Z.useState(!0),c=qt(i).startingApi;Z.useEffect(()=>{let e=!1,t=async()=>{try{let t=await(await g(`/health`,{signal:AbortSignal.timeout(4e3)})).json().catch(()=>null);if(e)return;let n=t?.openCodeStarting===!0||t?.isOpenCodeReady!==!0&&!t?.lastOpenCodeError;s(n)}catch{e||s(!0)}};t();let n=window.setInterval(()=>{t()},750);return()=>{e=!0,window.clearInterval(n)}},[]);let l=r>0?Math.round(n/r*100):0,u=t===`restoring`?a(`common.loading`):a(`sessions.startupSync.progress`,{completed:n,total:r});return Z.useLayoutEffect(()=>{let t=document.getElementById(`startup-session-progress`),i=document.getElementById(`startup-session-progress-track`),s=document.getElementById(`startup-session-progress-fill`),d=document.getElementById(`startup-session-progress-text`);if(!(!t||!i||!s||!d)){if(e){t.hidden=!1,s.style.width=`${l}%`,i.setAttribute(`aria-label`,a(`sessions.startupSync.title`)),i.setAttribute(`aria-valuemax`,String(Math.max(r,1))),i.setAttribute(`aria-valuenow`,String(n)),i.setAttribute(`aria-valuetext`,u),d.textContent=u;return}if(o){t.hidden=!1,s.style.width=`30%`,i.setAttribute(`aria-label`,c),i.setAttribute(`aria-valuetext`,c),d.textContent=c;return}t.hidden=!0}},[e,n,o,l,u,c,a,r]),null},ww=(e,t,n,r=350)=>n?Math.max(0,r-Math.max(0,t-e)):null;function Tw(e){let t=(0,Q.c)(21),{transition:n,ready:r}=e,{t:i}=Nr(),a=xo(!0),[o,s]=Z.useState(0),c=n.epoch>o,l=a||c,u,d;if(t[0]!==c||t[1]!==a||t[2]!==r||t[3]!==n.epoch||t[4]!==n.startedAt?(u=()=>{if(!c||a)return;let e=ww(n.startedAt,Date.now(),r);if(e===null)return;let t=window.setTimeout(()=>{s(e=>Math.max(e,n.epoch))},e);return()=>window.clearTimeout(t)},d=[c,a,r,n.epoch,n.startedAt],t[0]=c,t[1]=a,t[2]=r,t[3]=n.epoch,t[4]=n.startedAt,t[5]=u,t[6]=d):(u=t[5],d=t[6]),Z.useEffect(u,d),!l)return null;let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 opacity-70`,"aria-hidden":`true`,children:[(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-[28rem] -translate-x-1/2 -translate-y-1/2 rounded-full border border-[var(--interactive-border)]/40`}),(0,$.jsx)(`div`,{className:`absolute left-1/2 top-1/2 size-72 -translate-x-1/2 -translate-y-1/2 rounded-full bg-[var(--interactive-selection)]/10 blur-3xl`})]}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(`div`,{className:`mb-7 flex size-28 items-center justify-center rounded-[2rem] border border-[var(--interactive-border)]/60 bg-[var(--surface-elevated)]/75 shadow-2xl shadow-background/40`,children:(0,$.jsx)(jo,{width:76,height:76,isAnimated:!0})}),t[8]=p):p=t[8];let m;t[9]===i?m=t[10]:(m=i(`desktopHostSwitcher.transition.title`),t[9]=i,t[10]=m);let h;t[11]===m?h=t[12]:(h=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:m}),t[11]=m,t[12]=h);let g;t[13]===i?g=t[14]:(g=i(`desktopHostSwitcher.transition.description`),t[13]=i,t[14]=g);let _;t[15]===g?_=t[16]:(_=(0,$.jsx)(`p`,{className:`mt-2 typography-body text-muted-foreground`,children:g}),t[15]=g,t[16]=_);let v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`div`,{className:`mt-7 h-1 w-28 overflow-hidden rounded-full bg-[var(--surface-muted)]`,"aria-hidden":`true`,children:(0,$.jsx)(`div`,{className:`h-full w-1/2 animate-pulse rounded-full bg-[var(--status-info)] motion-reduce:animate-none`})}),t[17]=v):v=t[17];let y;return t[18]!==h||t[19]!==_?(y=(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[9998] flex items-center justify-center overflow-hidden bg-background/95 px-6 backdrop-blur-xl`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:[f,(0,$.jsxs)(`div`,{className:`relative flex max-w-md animate-in flex-col items-center text-center fade-in zoom-in-95 duration-300 motion-reduce:animate-none`,children:[p,h,_,v]})]}),t[18]=h,t[19]=_,t[20]=y):y=t[20],y}var Ew=ba(()=>Lt(()=>import(`./OnboardingScreen-DUNyDwc6.js`).then(e=>({default:e.OnboardingScreen})),__vite__mapDeps([210,1,4,2,5,3,6,7,8,100,9,38,22,23,20,24,39,40,41,42,13,10,12,11,14,15,16,17,18,19,21,25,43,37,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,62,63,114,142,65]))),Dw=36e5,Ow=12e5,kw=()=>{let e=(0,Q.c)(3),t=K(Iw),n=K(Lw),r;return e[0]!==t||e[1]!==n?(r=(0,$.jsx)(yw,{open:t,onOpenChange:n}),e[0]=t,e[1]=n,e[2]=r):r=e[2],r},Aw=e=>{let t=(0,Q.c)(21),{onRetry:n,isRetrying:r}=e,{t:i}=Nr(),a;t[0]===i?a=t[1]:(a=i(`startup.initRecovery.title`),t[0]=i,t[1]=a);let o;t[2]===a?o=t[3]:(o=(0,$.jsx)(`h1`,{className:`typography-title text-foreground`,children:a}),t[2]=a,t[3]=o);let s;t[4]===i?s=t[5]:(s=i(`startup.initRecovery.description`),t[4]=i,t[5]=s);let c;t[6]===s?c=t[7]:(c=(0,$.jsx)(`p`,{className:`typography-body text-muted-foreground`,children:s}),t[6]=s,t[7]=c);let l;t[8]!==o||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[o,c]}),t[8]=o,t[9]=c,t[10]=l):l=t[10];let u;t[11]!==r||t[12]!==i?(u=i(r?`startup.initRecovery.retrying`:`startup.initRecovery.retry`),t[11]=r,t[12]=i,t[13]=u):u=t[13];let d;t[14]!==r||t[15]!==n||t[16]!==u?(d=(0,$.jsx)(q,{type:`button`,onClick:n,disabled:r,children:u}),t[14]=r,t[15]=n,t[16]=u,t[17]=d):d=t[17];let f;return t[18]!==l||t[19]!==d?(f=(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center bg-background px-6 text-foreground`,children:(0,$.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-4 text-center`,children:[l,d]})}),t[18]=l,t[19]=d,t[20]=f):f=t[20],f},jw=e=>e?e.replace(/\\/g,`/`).replace(/\/+$/g,``):``,Mw=()=>{if(typeof window>`u`||!Io())return null;let e=new URLSearchParams(window.location.search),t=e.get(`sessionId`),n=typeof t==`string`?t.trim():``;if(!n)return null;let r=e.get(`directory`);return{sessionId:n,directory:typeof r==`string`&&r.trim().length>0?r.trim():null,readOnly:e.get(`readOnly`)===`1`||e.get(`readOnly`)===`true`}},Nw=()=>typeof window>`u`?!1:window.location.pathname===uu,Pw=e=>{let t=(0,Q.c)(22),{embeddedSessionChat:n,isVSCodeRuntime:r,embeddedBackgroundWorkEnabled:i}=e,a=W(Rw),o=Vn(zw),s=Vn(Bw),c=ps(),l=Z.useRef(null),u;t[0]===n.directory?u=t[1]:(u=jw(n.directory),t[0]=n.directory,t[1]=u);let d=u,f;t[2]===a?f=t[3]:(f=jw(a),t[2]=a,t[3]=f);let p=f,m,h;if(t[4]!==p||t[5]!==o||t[6]!==n.directory||t[7]!==n.sessionId||t[8]!==d||t[9]!==r||t[10]!==s||t[11]!==c?(m=()=>{if(r||d&&p!==d)return;let e=`${d}\n${n.sessionId}`;l.current===e&&o||(l.current=e,s(n.sessionId,n.directory),c.ensureSessionRenderable(n.sessionId,!0))},h=[p,o,n.directory,n.sessionId,d,r,s,c],t[4]=p,t[5]=o,t[6]=n.directory,t[7]=n.sessionId,t[8]=d,t[9]=r,t[10]=s,t[11]=c,t[12]=m,t[13]=h):(m=t[12],h=t[13]),Z.useEffect(m,h),d&&p!==d)return null;let g;t[14]===i?g=t[15]:(g=(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:i}),t[14]=i,t[15]=g);let _;t[16]===n.readOnly?_=t[17]:(_=(0,$.jsx)(Yl,{readOnly:n.readOnly}),t[16]=n.readOnly,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Fa,{}),t[18]=v):v=t[18];let y;return t[19]!==g||t[20]!==_?(y=(0,$.jsxs)($.Fragment,{children:[g,_,v]}),t[19]=g,t[20]=_,t[21]=y):y=t[21],y};function Fw({apis:e}){Z.useEffect(()=>{Ke(`App:mounted`),qe()},[]),Z.useEffect(()=>tr(),[]);let t=An(e=>e.initializeApp),n=An(e=>e.isInitialized),r=An(e=>e.isConnected),i=Vn(e=>e.error),a=Vn(e=>e.clearError),o=Vn(e=>!(e.newSessionDraft?.open&&e.currentSessionId===null)),s=W(e=>e.currentDirectory),l=W(e=>e.setDirectory),u=W(e=>e.isSwitchingDirectory),[d,p]=Z.useState(!1),m=Ml(e=>e.refreshStatus),[h,g]=Z.useState(()=>e.runtime.isVSCode),[_,v]=Z.useState(!1),[b,S]=Z.useState(!1),[T,E]=Z.useState(0),[D,O]=Z.useState(0),[A,j]=Z.useState({epoch:0,startedAt:0}),[P,F]=Z.useState(!1),L=Z.useRef(!1),R=K(e=>e.wideChatLayoutEnabled),ee=K(e=>e.mobileKeyboardMode),B=Z.useMemo(()=>y(),[]),te=on(e=>e.hasCachedSessionIndex),re=on(e=>e.hasHydratedSessionIndex),[ae,oe]=Z.useState(()=>M()),[H,se]=Z.useState(()=>{let e=z();return e===null?null:ie({isDesktopShell:!0,bootOutcome:e})}),U=Z.useRef(!1),ce=Z.useMemo(()=>Mw(),[]),le=!ce||_,ue=Z.useMemo(()=>Nw(),[]);Z.useEffect(()=>(Ne(d),()=>{Ne(!1)}),[d]),Z.useEffect(()=>{Vt(ee)},[ee]),Z.useEffect(()=>{g(e.runtime.isVSCode)},[e.runtime.isVSCode]),Z.useEffect(()=>{let e=za(e=>{f(e)&&(B&&j(e=>({epoch:e.epoch+1,startedAt:Date.now()})),ll(e),O(e=>e+1),S(!1),E(e=>e+1))}),t=c(t=>e.schedule(t));return()=>{t(),e.cancel()}},[B]),Z.useEffect(()=>(document.documentElement.classList.toggle(`wide-chat-layout`,R),()=>{document.documentElement.classList.remove(`wide-chat-layout`)}),[R]),Z.useEffect(()=>(V(e),()=>V(null)),[e]),Z.useEffect(()=>{if(ce)return;let t=!1;return Cn().then(()=>{t||m(e.github,{force:!0})}),()=>{t=!0}},[e.github,ce,m]),co();let de=ae===`valid`,fe=H?.screen===`main`,[pe,me]=Z.useState(!1);Z.useEffect(()=>{if(!le||!ne({isDesktopShell:B,isInitialized:B&&fe?te||n&&re:n,bootOutcomeKnown:de,bootViewIsMain:fe}))return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t?(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove(),me(!0)},300)):me(!0)},150);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,B,n,de,fe,te,re]),Z.useEffect(()=>{if(!B||ae!==`malformed`)return;let e=document.getElementById(`initial-loading`);e&&(e.textContent=`Desktop startup failed — please restart the app.`)},[B,ae]),Z.useEffect(()=>{if(!le||B)return;let e,t=setTimeout(()=>{let t=document.getElementById(`initial-loading`);t&&!n&&(t.classList.add(`fade-out`),e=setTimeout(()=>{t.remove()},300))},5e3);return()=>{clearTimeout(t),e&&clearTimeout(e)}},[le,B,n]),Z.useEffect(()=>{if(!le||h)return;let e=!1;return Cn().then(()=>{if(!e)return t()}),()=>{e=!0}},[le,t,h]),Z.useEffect(()=>{if(!le||h||n)return;let e=!0,t,r=0,i=1e3,a=async()=>{if(!e)return;if(r>=10){S(!0);return}let n=An.getState();if(n.isInitialized){S(!1);return}if(r+=1,await Cn(),!e)return;await n.initializeApp();let o=An.getState();if(!e)return;if(o.isInitialized){S(!1);return}if(r>=10){S(!0);return}let s=Math.min(i*2**(r-1),16e3);t=setTimeout(a,s)};return t=setTimeout(a,i),()=>{e=!1,t&&clearTimeout(t)}},[le,T,n,h]),Z.useEffect(()=>{le&&n&&S(!1)},[le,n]),Z.useEffect(()=>{if(!le||!b)return;let e=document.getElementById(`initial-loading`);if(e){e.classList.add(`fade-out`);let t=setTimeout(()=>{e.remove()},300);return()=>clearTimeout(t)}},[le,b]),Ka({enabled:le&&!h,source:`startupRecovery`}),Z.useEffect(()=>{u||h||r&&rt.setDirectory(s)},[s,u,r,h]),Z.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{let t=e?.visible===!0;v(t)},t=t=>{if(t.origin!==window.location.origin)return;let n=t.data;n?.type===`yuri:embedded-visibility`&&e(n.payload)},n=window;return n.__yuriSetEmbeddedVisibility=e,window.addEventListener(`message`,t),window.parent&&window.parent!==window&&window.parent.postMessage({type:Lo},window.location.origin),()=>{window.removeEventListener(`message`,t),n.__yuriSetEmbeddedVisibility===e&&delete n.__yuriSetEmbeddedVisibility}},[ce]),Z.useEffect(()=>{!ce?.directory||h||s!==ce.directory&&l(ce.directory,{showOverlay:!1})},[s,ce,h,l]),Z.useEffect(()=>{if(!ce||typeof window>`u`)return;let e=e=>{e.storageArea===window.localStorage&&e.key===`ui-store`&&K.persist.rehydrate()};return window.addEventListener(`storage`,e),()=>{window.removeEventListener(`storage`,e)}},[ce]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail;vw(t??{})},t=e=>{let t=e.detail?.assistantID;typeof t==`string`&&t.trim()&&Hr(t.trim())},n=e=>{let t=e.detail,n=t?.projectID,r=t?.taskID;n&&r&&Lt(async()=>{let{openScheduledTask:e}=await import(`./scheduledTaskNavigation-VVTOq9n2.js`).then(e=>e.n);return{openScheduledTask:e}},__vite__mapDeps([164,1,21,5,3,2,6,7,8,22,9,23,20,24,25,18,132,133])).then(({openScheduledTask:e})=>e(n,r))};return window.addEventListener(`yuri:open-session`,e),window.addEventListener(`yuri:open-assistant`,t),window.addEventListener(`yuri:open-scheduled-task`,n),()=>{window.removeEventListener(`yuri:open-session`,e),window.removeEventListener(`yuri:open-assistant`,t),window.removeEventListener(`yuri:open-scheduled-task`,n)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{let e=W.getState().currentDirectory,{activeProjectId:t,projects:n}=$t.getState(),r=n.find(e=>e.id===t)??null;I(`desktop_open_draft_mini_chat_window`,{directory:e||r?.path||``,projectId:r?.id??null})};return window.addEventListener(`yuri:open-mini-chat`,e),()=>window.removeEventListener(`yuri:open-mini-chat`,e)},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=()=>{if(Tn.getState().remoteSession)return;let e=Vn.getState().currentSessionId;e&&un(e)};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=0,t=t=>{let n=++e,r=t.detail,i=typeof r?.directory==`string`&&r.directory.trim().length>0?r.directory.trim():null,a=typeof r?.projectId==`string`&&r.projectId.trim().length>0?r.projectId.trim():null,o=typeof r?.initialPrompt==`string`&&r.initialPrompt.trim().length>0?r.initialPrompt.trim():void 0;K.getState().setActiveMainTab(`chat`),K.getState().setSessionSwitcherOpen(!1);let s=$t.getState(),c=s.projects.find(e=>e.id===(a??(i?null:s.activeProjectId)));if(r?.hostId){let t=Tn.getState().remoteSession,c=s.activeProjectId;zl({sessionId:null,isNewSession:!0,hostId:r.hostId,hubId:r.hubId,directory:i,projectId:a},()=>n===e&&Tn.getState().remoteSession===t&&$t.getState().activeProjectId===c).then(async e=>{if(!e)return;let t=Tn.getState().remoteSession;o&&t&&await Rl(t.location,o)}).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}if(c?.hostId&&c.hubId){let e={hubId:c.hubId,hostId:c.hostId,directory:c.path};s.setActiveProjectIdOnly(c.id),Tn.getState().openRemoteSession(c,e,null),o&&Rl(e,o).catch(e=>Y.error(e instanceof Error?e.message:String(e)));return}Tn.getState().clearRemoteSession(),Vn.getState().openNewSessionDraft({selectedProjectId:a,directoryOverride:i,preserveDirectoryOverride:!!i,ensureProjectForDirectory:!!i,initialPrompt:o})};return window.addEventListener(`yuri:open-draft-session`,t),()=>{e+=1,window.removeEventListener(`yuri:open-draft-session`,t)}},[]),Z.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{let t=e.detail,n=typeof t?.projectPath==`string`?t.projectPath.trim():``;if(!n)return;let r=$t.getState(),i=r.projects.find(e=>!e.hostId&&e.path===n);i?r.setActiveProject(i.id):r.addProject(n)};return window.addEventListener(`yuri:open-project`,e),()=>window.removeEventListener(`yuri:open-project`,e)},[]),Z.useEffect(()=>{typeof window>`u`||!le||!n||u||U.current||(U.current=!0,window.__yuriAppReady=!0,window.dispatchEvent(new Event(`yuri:app-ready`)))},[le,n,u]),Ga({enabled:le}),fw({enabled:le}),gw(),po(),ml(),UC(G(()=>{p(e=>!e)})),Z.useEffect(()=>{C()&&Kt().then(async e=>{e&&await x(e)}).catch(console.warn)},[]),Z.useEffect(()=>{if(!n||!C()||L.current)return;L.current=!0;let e=!1,t=null,r=null;El.getState().subscribeDesktopUpdateEvents().then(t=>{if(e){t();return}r=t});let i=()=>{let e=El.getState();e.checking||e.checkForUpdates()},a=n=>{t=window.setTimeout(()=>{e||(document.visibilityState===`visible`&&i(),a(Dw))},n)},o=()=>{if(e||document.visibilityState!==`visible`)return;let t=El.getState().lastChecked;t!=null&&Date.now()-t<Ow||i()};return a(0),window.addEventListener(`focus`,o),()=>{e=!0,t!==null&&window.clearTimeout(t),window.removeEventListener(`focus`,o),r&&r()}},[n]),cw(),Z.useEffect(()=>{if(ce)return;let e=e=>{ur(e)&&e.shiftKey&&!e.altKey&&(e.code===`KeyD`||e.key.toLowerCase()===`d`)&&(e.preventDefault(),p(e=>!e))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ce]),Z.useEffect(()=>{ce||i&&setTimeout(()=>a(),5e3)},[a,ce,i]),Z.useEffect(()=>{if(!B||ae!==`not-injected`)return;let e=!1,t=0,n=()=>{if(e)return;t++;let r=M();if(r!==`not-injected`){if(e=!0,oe(r),r===`valid`){let e=z();e&&se(ie({isDesktopShell:!0,bootOutcome:e}))}return}let i=Math.min(200*1.1**t,2e3);if(t>=50){let e=document.getElementById(`initial-loading`);e&&!e.textContent?.includes(`taking longer`)&&(e.textContent=`Desktop startup is taking longer than expected...`)}window.setTimeout(n,i)};return window.setTimeout(n,200),()=>{e=!0}},[B,ae]);let he=G(async()=>{if(N({isDesktopShell:y(),isDesktopLocalOriginActive:w()})){await k();return}window.location.reload()}),ge=G(async()=>{if(!P){S(!1),F(!0);try{await Cn(),await An.getState().initializeApp()}finally{F(!1)}An.getState().isInitialized||E(e=>e+1)}}),_e=e=>{if(e.screen===`recovery`)return e.variant};if(B&&H&&H.screen!==`main`){if(H.screen===`chooser`)return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Ew,{mode:`first-launch`,onCliAvailable:he,onChooseRemote:()=>{}})})})});let e=_e(H),t=H.screen===`recovery`&&`url`in H?H.url:void 0;return(0,$.jsx)(No,{children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-transparent`,children:(0,$.jsx)(Z.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-full`}),children:(0,$.jsx)(Ew,{mode:`recovery`,recoveryVariant:e,recoveryHostUrl:t,recoveryHostLabel:void 0,onCliAvailable:he})})})})}if(ce)return _r(),(0,$.jsx)(No,{children:(0,$.jsx)(Yn,{sdk:rt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsx)(`div`,{className:`h-full text-foreground bg-background`,children:(0,$.jsx)(Pw,{embeddedSessionChat:ce,isVSCodeRuntime:h,embeddedBackgroundWorkEnabled:le})})})})},D)});if(ue)return(0,$.jsx)(No,{children:(0,$.jsx)(Sw,{})});if(b&&!n&&!h&&!ce)return(0,$.jsx)(No,{children:(0,$.jsx)(Aw,{onRetry:()=>{ge()},isRetrying:P})});let ve=!n&&!B;return(0,$.jsx)(No,{children:(0,$.jsx)(Yn,{sdk:rt.getSdkClient(),directory:s||``,bootstrapDirectory:o,children:(0,$.jsx)(fo,{apis:e,children:(0,$.jsx)(il,{ready:pe&&n&&le,children:(0,$.jsx)(_m,{children:(0,$.jsx)(ti,{delayDuration:300,skipDelayDuration:150,children:(0,$.jsxs)(`div`,{className:B?`h-full text-foreground bg-transparent`:`h-full text-foreground bg-background`,children:[(0,$.jsx)(eo,{embeddedBackgroundWorkEnabled:le}),(0,$.jsx)(ul,{}),(0,$.jsx)(Ic,{}),(0,$.jsx)(Sc,{}),(0,$.jsx)(HS,{}),B&&(0,$.jsx)(Tw,{transition:A,ready:n&&r}),(0,$.jsx)(Cw,{}),(0,$.jsx)(Fa,{}),!ve&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pc,{}),(0,$.jsx)(Rc,{}),(0,$.jsx)(wl,{}),(0,$.jsx)(kw,{}),d&&(0,$.jsx)(wC,{onClose:()=>p(!1)})]})]})})})})})},D)})}function Iw(e){return e.isAboutDialogOpen}function Lw(e){return e.setAboutDialogOpen}function Rw(e){return e.currentDirectory}function zw(e){return e.currentSessionId}function Bw(e){return e.setCurrentSession}if(typeof window<`u`&&!window.__YURI_REFRESH_DEBUG_INSTALLED__){window.__YURI_REFRESH_DEBUG_INSTALLED__=!0;let e=performance.getEntriesByType(`navigation`)[0];console.warn(`[refresh-debug] renderer-entry`,{navigationType:e?.type??`unknown`,protocol:window.location.protocol}),window.addEventListener(`beforeunload`,()=>{console.warn(`[refresh-debug] beforeunload`,{visibilityState:document.visibilityState})}),window.addEventListener(`pagehide`,e=>{console.warn(`[refresh-debug] pagehide`,{persisted:e.persisted})})}var Vw=typeof window<`u`&&window.__YURI_RUNTIME_APIS__||(()=>{throw Error(`Runtime APIs not provided for legacy UI entrypoint.`)})();Pr(),y()&&nn(),Wa({runtimeKey:p(),initializeAppearance:Fe,syncSettings:Ie,applyDirectory:ho,startWatchers:()=>{no(),Ha(),Ia()},onError:(e,t)=>{console.error(e===`appearance`?`[main] appearance init failed:`:`[main] settings init failed:`,t)}});var Hw=document.getElementById(`root`);if(!Hw)throw Error(`Root element not found`);(0,ku.createRoot)(Hw).render((0,$.jsx)(Z.StrictMode,{children:(0,$.jsx)(La,{children:(0,$.jsx)(Mr,{children:(0,$.jsx)(Pa,{children:(0,$.jsx)(to,{children:(0,$.jsx)(Ba,{children:(0,$.jsx)(Va,{children:(0,$.jsx)(Fw,{apis:Vw})})})})})})})}));