@yuriai/web 0.3.6-beta.14 → 0.3.6-beta.15

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 (190) hide show
  1. package/dist/assets/{AgentAvatar-5tMBB3OP.js → AgentAvatar-DmUeOy5j.js} +1 -1
  2. package/dist/assets/{AgentSelector-Cb7GNCSr.js → AgentSelector-p1Ai0tlg.js} +1 -1
  3. package/dist/assets/{ArchivedSessionsDialog-8gBAWGWJ.js → ArchivedSessionsDialog-Bjd3hgS2.js} +1 -1
  4. package/dist/assets/{AssistantConversationSurface-DBgTUUEt.js → AssistantConversationSurface-CTYtqGK_.js} +3 -3
  5. package/dist/assets/{AssistantSessionCard-_yFsx4WB.js → AssistantSessionCard-CX8zzXnW.js} +2 -2
  6. package/dist/assets/{AssistantUnreadBadge-a2u_bBfi.js → AssistantUnreadBadge-Nhei_TuI.js} +1 -1
  7. package/dist/assets/{AssistantView-BxqHaArC.js → AssistantView-BvmJC0q9.js} +1 -1
  8. package/dist/assets/{AssistantWorkingAvatar-DHZVN5kD.js → AssistantWorkingAvatar-BKPxjA77.js} +1 -1
  9. package/dist/assets/{AssistantsSettingsPage-CCG2-SGj.js → AssistantsSettingsPage-CPYKT5su.js} +1 -1
  10. package/dist/assets/{BinaryFileFallback-DyOwcZlP.js → BinaryFileFallback-DAmQpBO1.js} +1 -1
  11. package/dist/assets/{BtwPanel-BhJA_qnp.js → BtwPanel-BQgdeqj4.js} +2 -2
  12. package/dist/assets/BusyDots-CyVVXNMc.js +4 -0
  13. package/dist/assets/{ChatContainer-vX0hPadC.js → ChatContainer-_6gB1Tiu.js} +21 -21
  14. package/dist/assets/ChatView-DfPX2ADw.js +3 -0
  15. package/dist/assets/{DiagramView-XjJTNa7h.js → DiagramView-BAZPsxz1.js} +1 -1
  16. package/dist/assets/{DiffView-B6_7v5dX.js → DiffView-B_03bICv.js} +1 -1
  17. package/dist/assets/{DiffViewToggle-as2OeoZV.js → DiffViewToggle-CI-tbUKa.js} +1 -1
  18. package/dist/assets/{ErrorBoundary-6AeJc3yJ.js → ErrorBoundary-B1yQx4PN.js} +1 -1
  19. package/dist/assets/{FadeInOnReveal-BKAakuxD.js → FadeInOnReveal-CyF7ie8o.js} +1 -1
  20. package/dist/assets/{GuiPluginMount-DlrUvFjg.js → GuiPluginMount-jUR5ZEw-.js} +1 -1
  21. package/dist/assets/{GuiPluginPage-DsBH_Y2M.js → GuiPluginPage-Du-pLMlp.js} +1 -1
  22. package/dist/assets/{GuiPluginSurface-BisC0s24.js → GuiPluginSurface-hCEJJ4PF.js} +1 -1
  23. package/dist/assets/{GuiPluginTitlebarItems-CraVxzKU.js → GuiPluginTitlebarItems-DrOGcHI0.js} +1 -1
  24. package/dist/assets/{GuiPluginWindow-DjrDed9m.js → GuiPluginWindow-CDiqRDYz.js} +1 -1
  25. package/dist/assets/{Icon-zB0u-x9G.js → Icon-D4ELZTbQ.js} +1 -1
  26. package/dist/assets/{ImageLoadingPlaceholder-COr72scf.js → ImageLoadingPlaceholder-BKk1qYNK.js} +1 -1
  27. package/dist/assets/{LoadingImage-DCyqFHPY.js → LoadingImage-BWknOYgx.js} +1 -1
  28. package/dist/assets/{MarkdownRenderer-YxMjOHQg.js → MarkdownRenderer-B8pnxnuP.js} +2 -2
  29. package/dist/assets/{MarkdownRendererImpl-FJ3saBi-.js → MarkdownRendererImpl-HvxkLk8k.js} +3 -3
  30. package/dist/assets/{MarkstreamRendererImpl-69EMw8mz.js → MarkstreamRendererImpl-oBJscGhT.js} +1 -1
  31. package/dist/assets/{MobileAssistantSettingsPage-BoH-3iPc.js → MobileAssistantSettingsPage-ADZ_zb24.js} +1 -1
  32. package/dist/assets/{MobileAssistantTab-59nMj5dF.js → MobileAssistantTab-D2B1DhXn.js} +1 -1
  33. package/dist/assets/{MobileBtwPage-EwMOy6Vg.js → MobileBtwPage-D9AHKfUL.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-BfMWp6TX.js → MobileChangesSurface-C-fS41BA.js} +1 -1
  35. package/dist/assets/{MobileChatScreen-CZDiNi7M.js → MobileChatScreen-CpjY3NfP.js} +1 -1
  36. package/dist/assets/{MobileDetailNavigation-DKv1HfQX.js → MobileDetailNavigation-DyEDDj7j.js} +1 -1
  37. package/dist/assets/{MobileFilesSurface-BiK7LCem.js → MobileFilesSurface-i1CdOJt_.js} +2 -2
  38. package/dist/assets/{MobileHtmlNetworkBoundary-BXh_BJ93.js → MobileHtmlNetworkBoundary-B0eGttNW.js} +2 -2
  39. package/dist/assets/{MobileOverlayPanel-Pr-vLaIF.js → MobileOverlayPanel-BRsSjQB0.js} +1 -1
  40. package/dist/assets/{MobileResizableSheet-O2gv2sCB.js → MobileResizableSheet-Iz6IOJIC.js} +1 -1
  41. package/dist/assets/{MobileSettingsTab-DadXop75.js → MobileSettingsTab-IFxVifD4.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-CaiscA4w.js → MobileShareBridge-CYupKqbK.js} +1 -1
  43. package/dist/assets/{MobileSurface-B_2aVFm1.js → MobileSurface-Dj0XqWPS.js} +1 -1
  44. package/dist/assets/{MobileTabPageHeader-T0zUz7Wl.js → MobileTabPageHeader-DyDjEHij.js} +1 -1
  45. package/dist/assets/{ModelLogo-C1Vv7gz6.js → ModelLogo-Ddsuaz2-.js} +1 -1
  46. package/dist/assets/{ModelSelector-BP_s_VhY.js → ModelSelector-BLqwVn9h.js} +1 -1
  47. package/dist/assets/{MultiRunWindow--tNVFKUJ.js → MultiRunWindow-DOpqKyhx.js} +1 -1
  48. package/dist/assets/{OnboardingScreen-DMdy73Dq.js → OnboardingScreen-CyYxHZ27.js} +1 -1
  49. package/dist/assets/{OverlayScrollbar-n5T49w2e.js → OverlayScrollbar-DdK6iB_P.js} +1 -1
  50. package/dist/assets/{PierreDiffViewer-i3OsvUKm.js → PierreDiffViewer-DnLcVaQ_.js} +1 -1
  51. package/dist/assets/{ProviderLogo-D-ldwq0G.js → ProviderLogo-ClFNH0bR.js} +1 -1
  52. package/dist/assets/{RemoteAssistantSessionCard-CNpcgVmv.js → RemoteAssistantSessionCard-Bf3dzN6s.js} +1 -1
  53. package/dist/assets/{RemoteDesktopPanel-hTuLKJZb.js → RemoteDesktopPanel-CYrH1ew9.js} +1 -1
  54. package/dist/assets/ScheduledTasksDialog-Cjl3xt0U.js +3 -0
  55. package/dist/assets/{ScrollableOverlay-DAMUOn67.js → ScrollableOverlay-CpChvNBP.js} +1 -1
  56. package/dist/assets/{SettingsGroup-CwMJmhq2.js → SettingsGroup-DiF6MwFq.js} +1 -1
  57. package/dist/assets/{SettingsView-bYWNjHtA.js → SettingsView-BG9k0S0n.js} +10 -10
  58. package/dist/assets/{SettingsWindow-D0ZzAXW0.js → SettingsWindow-CZqmOqJh.js} +1 -1
  59. package/dist/assets/{SetupTourDialog-CgM5YonA.js → SetupTourDialog-Dm893t6A.js} +1 -1
  60. package/dist/assets/{SyncActions-Ct2yZTbg.js → SyncActions-DxL0WqMS.js} +1 -1
  61. package/dist/assets/{TerminalView-BU5w40RA.js → TerminalView-Cm_Az2IR.js} +3 -3
  62. package/dist/assets/{TextSelectionMenu-a7yyDz5R.js → TextSelectionMenu-C-QA2JSI.js} +2 -2
  63. package/dist/assets/{ToolOutputDialog-CGYnrXVV.js → ToolOutputDialog-IbK1m1cQ.js} +2 -2
  64. package/dist/assets/{YuriLogo-Cexwa29m.js → YuriLogo-CdbCjzA8.js} +1 -1
  65. package/dist/assets/{YuriWordmark-Bn5KdqMC.js → YuriWordmark-rISEHjrd.js} +1 -1
  66. package/dist/assets/{assistant-attachment-cache-Y7yhlQcv.js → assistant-attachment-cache-BsIYVOYw.js} +1 -1
  67. package/dist/assets/{assistantMessagePreview-BXNdMDW-.js → assistantMessagePreview-DbTwPLzY.js} +1 -1
  68. package/dist/assets/{assistantQueries-DkAmjFg7.js → assistantQueries-DJyuR5Cm.js} +1 -1
  69. package/dist/assets/{auto-read-context-DLilPZMl.js → auto-read-context-B0niCh-F.js} +1 -1
  70. package/dist/assets/{capgoAdapter-DaIrgBjp.js → capgoAdapter-CXshem6r.js} +1 -1
  71. package/dist/assets/{card-CXE0ffyH.js → card-BCtykvi_.js} +1 -1
  72. package/dist/assets/{chatUpwardIntent-DRFjEP4t.js → chatUpwardIntent-DR7dxJwx.js} +1 -1
  73. package/dist/assets/{checkbox-hYuewn9u.js → checkbox-DsB97EEi.js} +1 -1
  74. package/dist/assets/{client-QcYZg8_d.js → client-BuCd-T7s.js} +1 -1
  75. package/dist/assets/{collapsible-C4a0ndbm.js → collapsible-acYUve5w.js} +1 -1
  76. package/dist/assets/{connection-hint-Ci6c4iij.js → connection-hint-BYkEkoO4.js} +1 -1
  77. package/dist/assets/{context-menu-D73tnkiI.js → context-menu-HoHZ2sEw.js} +1 -1
  78. package/dist/assets/{desktopHosts-DFa3lf0i.js → desktopHosts-COI-czjF.js} +1 -1
  79. package/dist/assets/{desktopRelayRestore-CGq-Ylgq.js → desktopRelayRestore-BEPNc7qb.js} +1 -1
  80. package/dist/assets/device-TCHW5U2y.js +2 -0
  81. package/dist/assets/{diagram-B2X1oieg.js → diagram-Bp_Qevoe.js} +1 -1
  82. package/dist/assets/{dialog-B2Po85oU.js → dialog-CeXUC0Ej.js} +1 -1
  83. package/dist/assets/{dropdown-menu-vW7wfT5z.js → dropdown-menu-CwcXAdvN.js} +1 -1
  84. package/dist/assets/{fileMentionTouchSelection-B73h0W0P.js → fileMentionTouchSelection-vrvxc508.js} +1 -1
  85. package/dist/assets/{fileReferenceActions-DEUhs_7h.js → fileReferenceActions-wN7mWY3w.js} +1 -1
  86. package/dist/assets/{gitApi-DG2Gj6gC.js → gitApi-Di_eB3Io.js} +1 -1
  87. package/dist/assets/{gitApiHttp-C8AU1uiY.js → gitApiHttp-CrPYe9Oc.js} +2 -2
  88. package/dist/assets/{githubAuthQueries-IJPWBo0B.js → githubAuthQueries-CTTiXZ9q.js} +1 -1
  89. package/dist/assets/{historyImportQueries-B3QBdaKo.js → historyImportQueries-B4DVAuxZ.js} +1 -1
  90. package/dist/assets/{host-DchPrZpw.js → host-BjnskVUP.js} +1 -1
  91. package/dist/assets/{i18n-WsU03nwB.js → i18n-CYty_Jft.js} +1 -1
  92. package/dist/assets/{icons-6sA6AOaU.js → icons-P6A_c8tb.js} +1 -1
  93. package/dist/assets/{imageSource-B39pFDdo.js → imageSource-BquIRnWW.js} +1 -1
  94. package/dist/assets/{input-BpDiYSsP.js → input-CozXpDTq.js} +1 -1
  95. package/dist/assets/{input-store-PqhVEhUI.js → input-store-BtvRZZcg.js} +1 -1
  96. package/dist/assets/insertionBoundaries-Cw7x86o4.js +1 -0
  97. package/dist/assets/{kbd-Dd1lM8OM.js → kbd-DPRFdABo.js} +1 -1
  98. package/dist/assets/{main-BtqqLSTt.js → main-CmWGNM6N.js} +2 -2
  99. package/dist/assets/main-DxvrNIsv.js +169 -0
  100. package/dist/assets/{markdownHeightCache-BzWUzccz.js → markdownHeightCache-BIB64pXI.js} +1 -1
  101. package/dist/assets/{mcpQueries-8frBxd65.js → mcpQueries-WWAWy_n9.js} +1 -1
  102. package/dist/assets/miniChat-CA9XT4K1.js +2 -0
  103. package/dist/assets/mobile-BKQlIKz3.js +2 -0
  104. package/dist/assets/{mobileBackNavigation-Ch0aK3t9.js → mobileBackNavigation-CX_MC0oM.js} +1 -1
  105. package/dist/assets/{mobileConnections-Bay_JNn0.js → mobileConnections-DuohwVoG.js} +2 -2
  106. package/dist/assets/{multirun-CQ2v1-nW.js → multirun-DXO3dw9u.js} +1 -1
  107. package/dist/assets/{native-config-B8eHFnvv.js → native-config-C_hqdruM.js} +1 -1
  108. package/dist/assets/{nativeComposerCover--wSR2Iru.js → nativeComposerCover-Cyi4eoBm.js} +1 -1
  109. package/dist/assets/{navigation-33oih6q2.js → navigation-Bxjv649w.js} +2 -2
  110. package/dist/assets/openRemoteProjectSession-W9p1SC1j.js +1 -0
  111. package/dist/assets/openSessionFromDeepLink-CeiBnoBN.js +2 -0
  112. package/dist/assets/platform-B2ylz14u.js +1 -0
  113. package/dist/assets/{pluginPresentation-BqcbcLYL.js → pluginPresentation-CWyI_3os.js} +2 -2
  114. package/dist/assets/{project-preview-CIkGbBPZ.js → project-preview-Dq--046z.js} +1 -1
  115. package/dist/assets/{projectActions-D84EVh3q.js → projectActions-B11KAI3f.js} +1 -1
  116. package/dist/assets/{prompt-attachment-upload-D1c308Ba.js → prompt-attachment-upload-m0vbcftI.js} +1 -1
  117. package/dist/assets/{pwa-JM_Ia4Qo.js → pwa-RpFKwS6l.js} +2 -2
  118. package/dist/assets/{queue-abort-optimistic-BspQeOrZ.js → queue-abort-optimistic-B624kCyc.js} +1 -1
  119. package/dist/assets/{quota-C7uYEfoX.js → quota-CNmk_bQD.js} +1 -1
  120. package/dist/assets/{reference-history-DuOv6xPy.js → reference-history-xOIH7D3x.js} +1 -1
  121. package/dist/assets/{remote-input-store-CquhCIoR.js → remote-input-store-CE88ZLsw.js} +1 -1
  122. package/dist/assets/{remoteProjectQueries-BunVM5PM.js → remoteProjectQueries-zO4jYbru.js} +1 -1
  123. package/dist/assets/{remoteSessionReference-brIKt6ea.js → remoteSessionReference-CNows8Mw.js} +1 -1
  124. package/dist/assets/{renderElectronMiniChatApp-1iiZ6q0N.js → renderElectronMiniChatApp-C0VEQ1ge.js} +2 -2
  125. package/dist/assets/renderMobileApp-ByzqYif5.js +17 -0
  126. package/dist/assets/{runtime-file-download-wMVtKk2v.js → runtime-file-download-CzZ_VAoB.js} +1 -1
  127. package/dist/assets/{runtime-file-resource-DKJJoOOc.js → runtime-file-resource-9kLrAtnQ.js} +1 -1
  128. package/dist/assets/{runtimeConfig-qjNoqcXT.js → runtimeConfig-CnEfMg7l.js} +1 -1
  129. package/dist/assets/runtimeEndpointReset-DFqTJZ0I.js +4 -0
  130. package/dist/assets/{scheduledTaskNavigation-DpfZSGu8.js → scheduledTaskNavigation-r3g3DfXq.js} +1 -1
  131. package/dist/assets/{select-Ojd202kE.js → select-B2UkBeQN.js} +1 -1
  132. package/dist/assets/sessionLookup-DCk6ryrM.js +1 -0
  133. package/dist/assets/{sessionOwnership-Nqb7MQgW.js → sessionOwnership-BAee5GI3.js} +1 -1
  134. package/dist/assets/{shortcuts-BOzfBNF8.js → shortcuts-CiFlt2ws.js} +1 -1
  135. package/dist/assets/{sortable-tabs-strip-DlQjS9bw.js → sortable-tabs-strip-Doz9wEki.js} +1 -1
  136. package/dist/assets/{speechSettingsQueries-DzDLUBnb.js → speechSettingsQueries-DxCvZVJ0.js} +1 -1
  137. package/dist/assets/{switch-BN9zvb0m.js → switch-YSNGU195.js} +1 -1
  138. package/dist/assets/{terminalApi-D2ECmoAo.js → terminalApi-CsTh04jY.js} +1 -1
  139. package/dist/assets/{textarea-ChLN9tnA.js → textarea-DxGZoBdI.js} +1 -1
  140. package/dist/assets/{timeFormat-D1hdmWbu.js → timeFormat-fIpRkrOb.js} +1 -1
  141. package/dist/assets/{tooltip-Cdsa-YWG.js → tooltip-D2BtRCgs.js} +1 -1
  142. package/dist/assets/{truncated-path-DjN9DJvh.js → truncated-path-ouBMaMLS.js} +1 -1
  143. package/dist/assets/{types-DHO20zYy.js → types-B-Io5z5w.js} +1 -1
  144. package/dist/assets/ui-BwSpLYDL.js +13 -0
  145. package/dist/assets/useAppFontEffects-Cuirbagj.js +7 -0
  146. package/dist/assets/{useAssistantUIStore-DEiMjSqf.js → useAssistantUIStore-BUWPTwNV.js} +1 -1
  147. package/dist/assets/{useDesktopWindowControlsLayout-OdYH5vsn.js → useDesktopWindowControlsLayout-BBO7snRO.js} +1 -1
  148. package/dist/assets/{useDictation-DUR68U4T.js → useDictation-C81KyPa6.js} +1 -1
  149. package/dist/assets/{useEffectiveDirectory-DNVTRp-B.js → useEffectiveDirectory-DeoADFfu.js} +1 -1
  150. package/dist/assets/{useFontPreferences-BY0TXvWI.js → useFontPreferences-DyMUXTQC.js} +1 -1
  151. package/dist/assets/{useGitStore-DsxzluvZ.js → useGitStore-BVToTkFp.js} +1 -1
  152. package/dist/assets/{useInlineCommentDraftStore-DU-yffqD.js → useInlineCommentDraftStore-BN8BgIUL.js} +1 -1
  153. package/dist/assets/useMcpConfigStore-CFUCk1mM.js +1 -0
  154. package/dist/assets/{useMobileSwipeActions-rPGl_HNn.js → useMobileSwipeActions-l0OHTMa8.js} +1 -1
  155. package/dist/assets/useMobileTranscriptSyncHint-LoxQ23zb.js +10 -0
  156. package/dist/assets/{useModelLists-xVEEc-e7.js → useModelLists-RMIHCaOi.js} +1 -1
  157. package/dist/assets/{useOpenCodeReadiness-C5D4297L.js → useOpenCodeReadiness-Cw5UOeLB.js} +1 -1
  158. package/dist/assets/{usePluginsStore-DEctn121.js → usePluginsStore-Cnj8I3MZ.js} +1 -1
  159. package/dist/assets/{useProjectGitActions-D7yZSor5.js → useProjectGitActions-D9TZc59T.js} +1 -1
  160. package/dist/assets/{useProjectGitStore-DFz9Eb6v.js → useProjectGitStore-qcnLHK_q.js} +1 -1
  161. package/dist/assets/{useProjectRuntimeAPIs-TALa4FqO.js → useProjectRuntimeAPIs-BoNGczR0.js} +1 -1
  162. package/dist/assets/{useQuotaStore-BqPJ1nzk.js → useQuotaStore-B4FEz0gR.js} +1 -1
  163. package/dist/assets/{useSessionBtwStore-DAQVlbuf.js → useSessionBtwStore-DD2dFcs5.js} +1 -1
  164. package/dist/assets/{useStreamingTextThrottle-BpC1BNz_.js → useStreamingTextThrottle-Cj6xIVZf.js} +1 -1
  165. package/dist/assets/{useUIStore-P32bzAJc.js → useUIStore-68ZPpgYA.js} +1 -1
  166. package/dist/assets/{worktreeManager-D56glCi_.js → worktreeManager-CnxL8GZi.js} +1 -1
  167. package/dist/assets/{worktreeSourceBranchPreference-CNtT0ymW.js → worktreeSourceBranchPreference-ii7ydXPw.js} +1 -1
  168. package/dist/index.html +15 -15
  169. package/dist/mini-chat.html +15 -15
  170. package/dist/mobile.html +1 -1
  171. package/package.json +1 -1
  172. package/server/lib/gui-customization/skill/references/deep-links.md +6 -6
  173. package/dist/assets/BusyDots-B9Zv4OUg.js +0 -4
  174. package/dist/assets/ChatView-OJAZBsfN.js +0 -3
  175. package/dist/assets/ScheduledTasksDialog-dgU5OpBK.js +0 -3
  176. package/dist/assets/device-CtdJ8KBJ.js +0 -2
  177. package/dist/assets/insertionBoundaries-Cu6Djn8S.js +0 -1
  178. package/dist/assets/main-CdUAbE7p.js +0 -169
  179. package/dist/assets/miniChat-C7JCQrXA.js +0 -2
  180. package/dist/assets/mobile-CcIasitd.js +0 -2
  181. package/dist/assets/openRemoteProjectSession-B94TYao_.js +0 -1
  182. package/dist/assets/openSessionFromDeepLink-C9jS-EIM.js +0 -2
  183. package/dist/assets/platform-CNdx57HN.js +0 -1
  184. package/dist/assets/renderMobileApp-CdTenU5H.js +0 -17
  185. package/dist/assets/runtimeEndpointReset-DKchBECK.js +0 -4
  186. package/dist/assets/sessionLookup-D299jmfx.js +0 -1
  187. package/dist/assets/ui-CU6n15y3.js +0 -13
  188. package/dist/assets/useAppFontEffects-Bqt4cv2k.js +0 -7
  189. package/dist/assets/useMcpConfigStore-al7LZT72.js +0 -1
  190. package/dist/assets/useMobileTranscriptSyncHint-BVvgdcp4.js +0 -10
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Q as n,et as r,ot as i,rt as a,st as o,tt as s}from"./vendor-base-ui-wXsskyKm.js";import{n as c}from"./vendor-react-BkccXcWz.js";import{no as l}from"./ui-CU6n15y3.js";import{t as u}from"./i18n-WsU03nwB.js";import{SettingsView as d}from"./SettingsView-bYWNjHtA.js";var f=c(),p=e(o(),1),m=i(),h=e=>{let i=(0,f.c)(19),{open:o,onOpenChange:c}=e,{t:h}=u(),_=p.useId(),v=g,y;i[0]===c?y=i[1]:(y=e=>{!e&&v()||c(e)},i[0]=c,i[1]=y);let b;i[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(a,{className:l(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),i[2]=b):b=i[2];let x;i[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),i[3]=x):x=i[3];let S;i[4]===h?S=i[5]:(S=h(`settings.window.description`),i[4]=h,i[5]=S);let C;i[6]!==_||i[7]!==S?(C=(0,m.jsx)(s,{id:_,className:`sr-only`,children:S}),i[6]=_,i[7]=S,i[8]=C):C=i[8];let w;i[9]===c?w=i[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),i[9]=c,i[10]=w);let T;i[11]!==_||i[12]!==C||i[13]!==w?(T=(0,m.jsxs)(t,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),i[11]=_,i[12]=C,i[13]=w,i[14]=T):T=i[14];let E;return i[15]!==o||i[16]!==y||i[17]!==T?(E=(0,m.jsx)(n,{open:o,onOpenChange:y,children:T}),i[15]=o,i[16]=y,i[17]=T,i[18]=E):E=i[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{$ as t,Q as n,et as r,ot as i,rt as a,st as o,tt as s}from"./vendor-base-ui-wXsskyKm.js";import{n as c}from"./vendor-react-BkccXcWz.js";import{ro as l}from"./ui-BwSpLYDL.js";import{t as u}from"./i18n-CYty_Jft.js";import{SettingsView as d}from"./SettingsView-BG9k0S0n.js";var f=c(),p=e(o(),1),m=i(),h=e=>{let i=(0,f.c)(19),{open:o,onOpenChange:c}=e,{t:h}=u(),_=p.useId(),v=g,y;i[0]===c?y=i[1]:(y=e=>{!e&&v()||c(e)},i[0]=c,i[1]=y);let b;i[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,m.jsx)(a,{className:l(`fixed inset-0 z-50 bg-black/50 dark:bg-black/75`,`transition-opacity duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[ending-style]:opacity-0`)}),i[2]=b):b=i[2];let x;i[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`relative pointer-events-auto`,`w-[90vw] max-w-[1200px] h-[85vh] max-h-[900px]`,`rounded-xl border shadow-none overflow-hidden origin-center`,`bg-background`,`transition-all duration-150 ease-out`,`data-[starting-style]:opacity-0 data-[starting-style]:scale-[0.98]`,`data-[ending-style]:opacity-0 data-[ending-style]:scale-[0.98]`,`data-[nested-dialog-open]:brightness-[0.55] dark:data-[nested-dialog-open]:brightness-[0.4]`),i[3]=x):x=i[3];let S;i[4]===h?S=i[5]:(S=h(`settings.window.description`),i[4]=h,i[5]=S);let C;i[6]!==_||i[7]!==S?(C=(0,m.jsx)(s,{id:_,className:`sr-only`,children:S}),i[6]=_,i[7]=S,i[8]=C):C=i[8];let w;i[9]===c?w=i[10]:(w=(0,m.jsx)(d,{onClose:()=>c(!1),isWindowed:!0}),i[9]=c,i[10]=w);let T;i[11]!==_||i[12]!==C||i[13]!==w?(T=(0,m.jsxs)(t,{children:[b,(0,m.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center pointer-events-none`,children:(0,m.jsxs)(r,{"aria-describedby":_,className:x,children:[C,w]})})]}),i[11]=_,i[12]=C,i[13]=w,i[14]=T):T=i[14];let E;return i[15]!==o||i[16]!==y||i[17]!==T?(E=(0,m.jsx)(n,{open:o,onOpenChange:y,children:T}),i[15]=o,i[16]=y,i[17]=T,i[18]=E):E=i[18],E};function g(){return typeof document>`u`?!1:!!document.querySelector(`[data-slot="dropdown-menu-content"][data-open], [data-slot="select-content"][data-open]`)}export{h as SettingsWindow};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{s as o}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{W as s}from"./runtime-file-resource-DKJJoOOc.js";import{r as c}from"./vendor-reactuses-core-DjKFMfz7.js";import{Na as l,Yi as u,Yn as d,no as f}from"./ui-CU6n15y3.js";import{n as p}from"./Icon-zB0u-x9G.js";import{t as m}from"./i18n-WsU03nwB.js";import{a as h,n as g,o as _,t as v}from"./dialog-B2Po85oU.js";import{n as y}from"./MarkdownRenderer-YxMjOHQg.js";import{t as b}from"./checkbox-hYuewn9u.js";import{t as x}from"./YuriLogo-Cexwa29m.js";import{a as S,i as C}from"./ModelLogo-C1Vv7gz6.js";import{l as w}from"./zhipuai-coding-plan-CcFj8zKy.js";import{t as T}from"./ProviderLogo-D-ldwq0G.js";import{n as E}from"./speechSettingsQueries-DzDLUBnb.js";import{n as D,t as O}from"./YuriWordmark-Bn5KdqMC.js";import{n as k}from"./SettingsGroup-CwMJmhq2.js";import{a as A,c as j,n as M,r as N,t as P}from"./usePluginsStore-DEctn121.js";import{a as F,l as I,n as ee,o as te,r as L,t as R}from"./pluginPresentation-BqcbcLYL.js";import{a as z,c as ne,d as re,l as B,o as V,s as ie,t as H,u as U}from"./historyImportQueries-B3QBdaKo.js";var W=e(i(),1),G=a(),K=[{name:`Magpie`,spec:`opencode-magpie-plugin`},{name:`Eficy`,spec:`@eficy/opencode2-plugin`},{name:`yee-profile`,spec:`@yee94/opencode-profile`}];function ae(e,t){return e.some(e=>e.parsedKind===`npm`&&R(e.spec).name===t)}async function q(e,t){let n=[];for(let r of new Set(e)){if(!t.current())throw Error(`Runtime changed`);try{let e=await t.list();if(!t.current())throw Error(`Runtime changed`);ae(e,r)||(await t.create(r)).ok||n.push(r)}catch{n.push(r)}}if(!t.current())throw Error(`Runtime changed`);return{failed:n}}function oe(e,r,i){let a=t(),o=n();return q(e,{current:()=>!i.aborted&&o===n()&&a===t(),list:async()=>(await s.fetchQuery({...N(r,a),staleTime:0})).entries,create:e=>P.getState().createEntry({spec:e,scope:`user`})})}var J=`data:image/svg+xml,%3csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'/%3e%3c/svg%3e`,Y=`data:image/svg+xml,%3csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'/%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23codex-gradient)'/%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='codex-gradient'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'/%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'/%3e%3cstop%20offset='1'%20stop-color='%233941FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,X=r(),se={claude:J,codex:Y,cursor:S,dsh:C,opencode:w};function ce({onBusy:e,directory:r=null,onPrimaryChange:i,onComplete:a}){let{t:o,locale:s}=m(),l=t(),u=n(),[h,g]=W.useState([]),[_,v]=W.useState(!1),[y,x]=W.useState(null),S=V(),C=S.data?.state===`running`,w=ie(S.isSuccess&&!C),T=ne(w.data?.id,r,`${S.data?.id??``}:${S.data?.state??``}`,!C&&!w.isFetching&&!w.isError),E=W.useRef(null),D=W.useRef(!1),O=W.useRef(null),k=W.useRef(null),A=c(e),j=c(e=>i?.(e)),M=c((e,t)=>g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e)));W.useEffect(()=>{let e=new AbortController;return E.current=e,()=>{e.abort(),A(!1)}},[l,u,A]);let N=W.useMemo(()=>{let e=B.map(e=>({...e,sessions:[]}));for(let t of w.data?.sessions??[]){let n=e.find(e=>e.id===t.source);n&&n.sessions.length<5&&n.sessions.push(t)}return e.filter(e=>e.sessions.length)},[w.data]),P=!!(O.current&&S.data?.id===O.current&&re(S.data)),F=_||!C&&!P&&(w.isFetching||!w.data||w.isError||S.isError);W.useEffect(()=>{j({disabled:F,background:C})},[F,C,j]);let I=()=>!E.current?.signal.aborted&&l===t()&&u===n(),ee=async e=>{if(!(D.current||!E.current)){D.current=!0,v(!0),A(!0),x(null);try{await e(E.current.signal)}catch(e){I()&&x(e instanceof Error&&/^[a-z_]+$/.test(e.message)?e.message:`import_failed`)}finally{D.current=!1,I()&&(v(!1),A(!1))}}},te=()=>ee(async e=>{if(F)return;if(C||P){I()&&a?.();return}if(!h.length){I()&&a?.();return}let t=await z(h,r,e,l,u);I()&&(O.current=t.id,k.current?.scrollIntoView({block:`start`}))}),L=w.error??S.error,R=y||(L instanceof Error&&/^[a-z_]+$/.test(L.message)?L.message:w.isError||S.isError?`import_failed`:null),G=W.useMemo(()=>new Intl.DateTimeFormat(s,{month:`short`,day:`numeric`}),[s]),K=S.data?U(S.data):null,ae=W.useMemo(()=>new Intl.NumberFormat(s),[s]),q=(e,t)=>{let n=w.data?.counts?.[e],r=n?.value;if(r==null||w.isError)return null;let i=ae.format(r),a=o(n?.approximate?`historyImport.estimatedCount`:`historyImport.sourceCount`,{count:i});return(0,X.jsx)(`span`,{id:t,"data-history-count":e,className:`yuri-import-source-count`,title:a,"aria-label":a,children:w.isFetching?(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`,"aria-label":o(`historyImport.scanning`)}):`${n?.approximate?`≈ `:``}${i}`})};return(0,X.jsxs)(`form`,{id:`yuri-tour-import`,className:`yuri-history-import`,"data-history-import":!0,onSubmit:e=>{e.preventDefault(),te()},children:[(0,X.jsx)(`h2`,{ref:k,className:`yuri-import-heading`,children:o(`historyImport.heading`)}),(0,X.jsx)(`p`,{className:`yuri-import-subtitle`,children:o(`historyImport.deduplication`)}),S.data&&!re(S.data)&&(C||O.current===S.data.id)&&(0,X.jsxs)(`div`,{className:`yuri-import-job`,role:`status`,children:[(0,X.jsx)(p,{name:C?`loader-4`:`error-warning`,className:f(`size-4`,C&&`animate-spin`)}),(0,X.jsx)(`span`,{children:o(C&&K?`historyImport.phase.${K.phase}`:`historyImport.state.${S.data.state}`)}),K&&K.total>0&&(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[K.completed,` / `,K.total]}),C&&(0,X.jsx)(d,{variant:`ghost`,size:`icon`,disabled:_,"aria-label":o(`historyImport.cancel`),title:o(`historyImport.cancel`),onClick:()=>void ee(async e=>{await H(S.data.id,e,l),I()&&await S.refetch()}),children:(0,X.jsx)(p,{name:`stop`,className:`size-4`})}),C&&K&&(0,X.jsx)(`progress`,{value:K.total?K.completed:void 0,max:K.total||1,"aria-label":o(`historyImport.progress`)}),S.data.progress?.code&&(0,X.jsxs)(`p`,{role:`alert`,children:[o(`historyImport.failed`),` `,(0,X.jsx)(`code`,{children:S.data.progress.code})]}),S.data.results.some(e=>e.status===`failed`||e.project===`failed`||e.index===`failed`)&&(0,X.jsxs)(`p`,{role:`alert`,children:[o(`historyImport.failed`),[...new Set(S.data.results.filter(e=>e.status===`failed`&&e.code).map(e=>e.code))].map(e=>(0,X.jsxs)(`code`,{children:[` `,e]},e))]})]}),(0,X.jsx)(`div`,{className:`yuri-import-source-grid`,"aria-label":o(`historyImport.sources`),children:B.map(e=>{let t=w.data?.installations?.[e.id],n=o(t===!0?`historyImport.installed`:t===!1?`historyImport.notDetected`:`historyImport.installationUnknown`),r=w.data?.counts?.[e.id]?.value!=null&&!w.isError?` history-import-count-${e.id}`:``;return(0,X.jsxs)(d,{variant:`ghost`,"data-history-source":e.id,className:f(`yuri-import-source-card`,(e.id===`cursor`||e.id===`opencode`)&&`yuri-import-source-cursor`),disabled:_||C,"aria-pressed":h.includes(e.id),"aria-label":e.name,"aria-describedby":`history-import-installed-${e.id}${r}`,onClick:()=>M(e.id,!h.includes(e.id)),children:[(0,X.jsxs)(`span`,{className:`yuri-import-logo-wrap`,children:[(0,X.jsx)(`img`,{src:se[e.id],alt:``,draggable:!1,className:`yuri-import-source-logo`}),(0,X.jsx)(`span`,{id:`history-import-installed-${e.id}`,role:`img`,"aria-label":n,title:n,"data-installed":t===!0?`true`:t===!1?`false`:`unknown`,className:`yuri-import-installation`})]}),(0,X.jsx)(`span`,{className:`yuri-import-source-name`,children:e.name}),q(e.id,`history-import-count-${e.id}`),(0,X.jsx)(`span`,{className:`yuri-import-source-check`,"aria-hidden":`true`,children:(0,X.jsx)(p,{name:`check`,className:`size-3`})})]},e.id)})}),R&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsxs)(`p`,{children:[o(R===`history_import_unsupported`?`historyImport.unsupported`:`historyImport.failed`),` `,(0,X.jsx)(`code`,{children:R})]}),(w.isError||S.isError)&&(0,X.jsx)(d,{variant:`ghost`,size:`xs`,disabled:w.isFetching||S.isFetching,onClick:()=>{Promise.all([w.refetch(),S.refetch()])},children:o(`settings.plugins.status.retry`)})]}),w.data&&!w.isFetching&&!w.isError&&!w.data.sessions.length&&!w.data.errors.length&&(0,X.jsx)(`p`,{className:`yuri-tour-feedback`,children:o(`historyImport.empty`)}),N.length>0&&(0,X.jsxs)(`section`,{"aria-label":o(`historyImport.sessions`),children:[(0,X.jsx)(`div`,{className:`yuri-import-list-heading`,children:o(`historyImport.sessions`)}),(0,X.jsx)(`div`,{className:`yuri-import-preview-groups`,children:N.map(e=>(0,X.jsxs)(`section`,{"aria-label":e.name,"data-source-selected":h.includes(e.id),children:[(0,X.jsxs)(`div`,{className:`yuri-import-preview-heading`,children:[(0,X.jsx)(`h3`,{children:e.name}),q(e.id),(0,X.jsx)(b,{checked:h.includes(e.id),disabled:_||C,ariaLabel:e.name,onChange:t=>M(e.id,t)})]}),(0,X.jsx)(`ul`,{className:`yuri-import-session-grid`,children:e.sessions.map(e=>(0,X.jsxs)(`li`,{"data-history-session":e.key,className:f(`yuri-import-session-card`,(e.source===`cursor`||e.source===`opencode`)&&`yuri-import-source-cursor`),title:e.title,children:[(0,X.jsx)(`img`,{src:se[e.source],alt:``,draggable:!1,className:`yuri-import-session-logo`}),(0,X.jsxs)(`span`,{className:`yuri-import-session-copy`,children:[(0,X.jsxs)(`span`,{className:`yuri-import-session-heading`,children:[(0,X.jsx)(`span`,{className:`yuri-import-session-title`,children:e.title}),!T.isError&&T.data?.states[e.key]===`imported`&&(0,X.jsx)(`span`,{className:`yuri-import-session-imported`,"data-history-imported":!0,children:o(`historyImport.alreadyImported`)}),e.updated&&e.updated>0?(0,X.jsx)(`time`,{dateTime:new Date(e.updated).toISOString(),children:G.format(e.updated)}):null]}),e.excerpt&&(0,X.jsx)(`span`,{className:`yuri-import-session-excerpt`,children:e.excerpt})]})]},e.key))})]},e.id))})]})]})}var Z=K.map(e=>e.spec),le=[`tour.models`,`tour.plugins`,`tour.import`,`tour.voice`],ue=[{id:`openai`,name:`OpenAI`},{id:`anthropic`,name:`Anthropic`},{id:`google`,name:`Google Gemini`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`deepseek`,name:`DeepSeek`},{id:`openrouter`,name:`OpenRouter`}];function de(e){let t=(0,G.c)(48),{index:n,info:r,installed:i,selected:a,onSelect:o,onReadme:s}=e,{t:c}=m(),l=K[n],u=r?.kind===`npm-ok`?r:void 0,h=a&&`yuri-tour-card-selected`,g;t[0]===h?g=t[1]:(g=f(`yuri-tour-plugin yuri-tour-select-card`,h),t[0]=h,t[1]=g);let _;t[2]===a?_=t[3]:(_=a&&(0,X.jsx)(p,{name:`check`,className:`size-5`}),t[2]=a,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,X.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:_}),t[4]=_,t[5]=v);let y;t[6]!==o||t[7]!==l.name||t[8]!==a||t[9]!==v?(y=(0,X.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":l.name,"aria-pressed":a,onClick:o,children:v}),t[6]=o,t[7]=l.name,t[8]=a,t[9]=v,t[10]=y):y=t[10];let b=u?.icon,x;t[11]!==l.name||t[12]!==b?(x=(0,X.jsx)(I,{name:l.name,src:b,size:30}),t[11]=l.name,t[12]=b,t[13]=x):x=t[13];let S;t[14]===l.name?S=t[15]:(S=(0,X.jsx)(`h3`,{className:`typography-ui-label font-medium`,children:l.name}),t[14]=l.name,t[15]=S);let C;t[16]===l.spec?C=t[17]:(C=(0,X.jsx)(`p`,{className:`break-all typography-micro text-muted-foreground`,children:l.spec}),t[16]=l.spec,t[17]=C);let w;t[18]!==S||t[19]!==C?(w=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]===u?T=t[22]:(T=u?.latestVersion&&(0,X.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u.latestVersion}),t[21]=u,t[22]=T);let E;t[23]!==w||t[24]!==T||t[25]!==x?(E=(0,X.jsxs)(`div`,{className:`flex items-start gap-3 pr-10`,children:[x,w,T]}),t[23]=w,t[24]=T,t[25]=x,t[26]=E):E=t[26];let D;t[27]!==r||t[28]!==u?.description||t[29]!==c?(D=u?.description||c(r?`tour.metadataUnavailable`:`common.loading`),t[27]=r,t[28]=u?.description,t[29]=c,t[30]=D):D=t[30];let O;t[31]===D?O=t[32]:(O=(0,X.jsx)(`p`,{className:`flex-1 typography-meta text-muted-foreground`,children:D}),t[31]=D,t[32]=O);let k=!u,A;t[33]!==s||t[34]!==k?(A=(0,X.jsx)(d,{size:`xs`,variant:`ghost`,className:`yuri-tour-card-link`,disabled:k,onClick:s,children:`README`}),t[33]=s,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==c?(j=i&&(0,X.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(`tour.saved`)}),t[36]=i,t[37]=c,t[38]=j):j=t[38];let M;t[39]!==A||t[40]!==j?(M=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41];let N;return t[42]!==E||t[43]!==O||t[44]!==M||t[45]!==g||t[46]!==y?(N=(0,X.jsxs)(`section`,{className:g,children:[y,E,O,M]}),t[42]=E,t[43]=O,t[44]=M,t[45]=g,t[46]=y,t[47]=N):N=t[47],N}function fe(e){let t=(0,G.c)(28),{settings:n,onComplete:r,onBusy:i}=e,{t:a}=m(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={voiceProvider:`volcengine`,sttProvider:`volcengine`,dictationEnabled:!0,showMessageTTSButtons:!0},t[0]=o):o=t[0];let s=L(n,o),l=c(i),u,d;t[1]!==s.saving||t[2]!==l?(u=()=>(l(s.saving),()=>l(!1)),d=[s.saving,l],t[1]=s.saving,t[2]=l,t[3]=u,t[4]=d):(u=t[3],d=t[4]),W.useEffect(u,d);let f;t[5]!==s||t[6]!==r||t[7]!==n.configured?(f=async e=>{e.preventDefault(),!(!n.configured&&!s.draft.apiKey?.trim())&&(await s.save())?.configured&&r()},t[5]=s,t[6]=r,t[7]=n.configured,t[8]=f):f=t[8];let p=f,h;t[9]===p?h=t[10]:(h=e=>void p(e),t[9]=p,t[10]=h);let g;t[11]===a?g=t[12]:(g=a(`settings.voice.volcengine.name`),t[11]=a,t[12]=g);let _,v;t[13]===s?(_=t[14],v=t[15]):(_=(0,X.jsx)(F,{mode:`tts`,form:s}),v=(0,X.jsx)(F,{mode:`asr`,form:s,showCredentials:!1}),t[13]=s,t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==_||t[18]!==v?(y=(0,X.jsxs)(k,{label:g,children:[_,v]}),t[16]=g,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==s.draft||t[21]!==n.configured||t[22]!==a?(b=!n.configured&&!s.draft.apiKey?.trim()&&(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`settings.providers.page.toast.apiKeyRequired`)}),t[20]=s.draft,t[21]=n.configured,t[22]=a,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==h||t[26]!==y?(x=(0,X.jsxs)(`form`,{id:`yuri-tour-voice`,onSubmit:h,className:`yuri-settings-section-stack`,children:[y,b]}),t[24]=b,t[25]=h,t[26]=y,t[27]=x):x=t[27],x}function pe({runtime:e,onClose:r}){let{t:i}=m(),a=A(),c=D(t=>t.progress[e]?.step??0),[b,S]=W.useState(`magpie`),[C,w]=W.useState(),[k,N]=W.useState(Z.slice(1)),[P,F]=W.useState(`tour`),[I,L]=W.useState(null),[R,z]=W.useState(!1),[ne,re]=W.useState({disabled:!0}),[B,V]=W.useState(null),ie=n(),H=t(),U=W.useRef(null),G=W.useRef(!1);W.useEffect(()=>{let e=new AbortController;return U.current=e,()=>e.abort()},[]);let q=j(),J=o({...M(a,Z.slice(1),!1,H,!0),enabled:c===1}),Y=o({...E(H),enabled:c===3}),se=q.data?.entries??[],pe=e=>{let t=u.getState(),n=e&&t.providers.some(t=>t.id===e);S(`other`),w(n?void 0:e),t.setSelectedProvider(n?e:`__add_provider__`),F(`providers`)},Q=()=>!U.current?.signal.aborted&&ie===n()&&H===t(),$=t=>{F(`tour`),V(null),D.getState().move(e,t)},me=()=>{Q()&&r()},he=()=>{c===3?me():$(c+1)},ge=async()=>{if(c===2){he();return}if(!(G.current||R||!U.current)){G.current=!0,z(!0),V(null);try{let e=c===0?b===`magpie`?[Z[0]]:[]:k;if(e.length){let t=await oe(e,a,U.current.signal);if(!Q())return;if(t.failed.length){V(i(`tour.saveFailed`,{names:t.failed.join(`, `)}));return}}if(c===0&&b===`other`){let e=await s.fetchQuery({...l(a,H),staleTime:0});if(!Q())return;if(e.partial||!e.providers.some(e=>Object.keys(e.models).length>0)){V(i(`tour.noModels`));return}await u.getState().loadProviders({directory:a,forceRefresh:!0,source:`setup-tour`})}Q()&&he()}catch{Q()&&V(i(`tour.operationFailed`))}finally{G.current=!1,Q()&&z(!1)}}},_e=()=>{I===null?P===`tour`?c>0&&$(c-1):F(`tour`):L(null)},ve=I===null?void 0:J.data?.[Z[I]],ye=ve?.kind===`npm-ok`?ve.readme:void 0;return(0,X.jsx)(v,{open:!0,onOpenChange:e=>{!e&&!R&&(I!==null||P!==`tour`?_e():me())},children:(0,X.jsxs)(g,{className:`yuri-setup-tour yuri-settings-workspace`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,X.jsx)(`div`,{className:`yuri-tour-watermark`,"aria-hidden":`true`,children:(0,X.jsx)(x,{width:440,height:440})}),(0,X.jsx)(h,{children:(0,X.jsxs)(_,{className:`yuri-tour-title`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`👋`}),i(`tour.title`).split(`Yuri`).map((e,t)=>(0,X.jsxs)(W.Fragment,{children:[t>0&&(0,X.jsx)(O,{width:`2.05em`}),(0,X.jsx)(`span`,{children:e.trim()})]},t))]})}),(0,X.jsxs)(`div`,{className:`yuri-tour-body`,children:[(0,X.jsx)(`nav`,{className:`yuri-tour-progress`,"aria-label":i(`tour.title`),children:le.map((e,t)=>(0,X.jsxs)(d,{variant:`ghost`,size:`lg`,disabled:R,"aria-current":c===t?`step`:void 0,onClick:()=>{L(null),$(t)},children:[(0,X.jsx)(`span`,{className:`yuri-tour-number`,"aria-hidden":`true`,children:String(t+1).padStart(2,`0`)}),(0,X.jsx)(`span`,{children:i(e)})]},e))}),(0,X.jsx)(`div`,{className:f(`yuri-tour-content`,P===`providers`&&I===null&&`yuri-tour-provider-content`),children:(0,X.jsxs)(`fieldset`,{disabled:R,className:`contents`,children:[I===null?P===`providers`?(0,X.jsx)(te,{initialConnectionId:C}):P===`voice`&&Y.data?(0,X.jsx)(fe,{settings:Y.data,onComplete:me,onBusy:z}):P===`asr`||P===`tts`?(0,X.jsx)(ee,{section:P}):(0,X.jsxs)(X.Fragment,{children:[c<2&&(c===1&&J.isError||q.isError)&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsx)(`p`,{children:i(`tour.metadataUnavailable`)}),(0,X.jsx)(d,{size:`xs`,onClick:()=>{c===1&&J.refetch(),q.refetch()},children:i(`settings.plugins.status.retry`)})]}),c===0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:f(`yuri-tour-magpie yuri-tour-select-card`,b===`magpie`&&`yuri-tour-card-selected`),children:[(0,X.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":`Magpie`,"aria-pressed":b===`magpie`,onClick:()=>S(b===`magpie`?`other`:`magpie`),children:(0,X.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:b===`magpie`&&(0,X.jsx)(p,{name:`check`,className:`size-5`})})}),(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-3 pr-10`,children:[(0,X.jsx)(T,{providerId:`magpie`,alt:`Magpie`,className:`size-8 shrink-0`}),(0,X.jsx)(`span`,{className:`typography-ui-label`,children:`Magpie`}),(0,X.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.magpieDescription`)}),(0,X.jsxs)(`a`,{className:`yuri-tour-card-link typography-meta text-muted-foreground underline`,href:`https://usemagpie.ai/docs/start`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,X.jsxs)(`div`,{className:`yuri-tour-provider-heading`,children:[(0,X.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`OpenCode`}),(0,X.jsxs)(`a`,{className:`typography-meta text-muted-foreground underline`,href:`https://opencode.ai/docs/providers/`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,X.jsx)(`div`,{className:`yuri-tour-provider-grid`,children:ue.map(e=>(0,X.jsxs)(d,{variant:`ghost`,className:`yuri-tour-provider-choice`,onClick:()=>pe(e.id),children:[(0,X.jsx)(T,{providerId:e.id,alt:e.name,className:`size-6 shrink-0`}),(0,X.jsx)(`span`,{children:e.name})]},e.id))}),(0,X.jsxs)(d,{className:`mt-3`,size:`sm`,variant:`ghost`,onClick:()=>pe(),children:[i(`tour.otherProvider`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]}),c===1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`yuri-tour-plugins`,children:[1,2].map(e=>(0,X.jsx)(de,{index:e,info:J.data?.[Z[e]],installed:ae(se,Z[e]),selected:k.includes(Z[e]),onSelect:()=>N(t=>t.includes(Z[e])?t.filter(t=>t!==Z[e]):[...t,Z[e]]),onReadme:()=>L(e)},e))}),(0,X.jsxs)(`a`,{className:`mt-4 inline-block typography-meta text-muted-foreground underline underline-offset-4 hover:text-foreground`,href:`https://opencode.ai/docs/ecosystem/#plugins`,target:`_blank`,rel:`noopener noreferrer`,children:[i(`tour.morePlugins`),` ↗`]})]}),c===2&&(0,X.jsx)(ce,{onBusy:z,directory:a,onPrimaryChange:re,onComplete:()=>$(3)}),c===3&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`yuri-tour-voice-intro`,children:[(0,X.jsx)(`h2`,{children:i(`tour.voiceHeading`)}),(0,X.jsx)(`p`,{children:i(`tour.voiceIntro`)})]}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-capabilities`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(p,{name:`mic`,className:`yuri-tour-voice-icon`}),(0,X.jsx)(`h3`,{children:i(`settings.voice.page.section.speechRecognition`)}),(0,X.jsx)(`p`,{children:i(`tour.dictationDescription`)}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`computer`}),i(`settings.voice.page.provider.local`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`server`}),i(`settings.voice.page.provider.server`)]})]}),(0,X.jsxs)(d,{size:`sm`,onClick:()=>F(`asr`),children:[i(`tour.configureInput`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(p,{name:`volume-up`,className:`yuri-tour-voice-icon`}),(0,X.jsx)(`h3`,{children:i(`tour.readAloudTitle`)}),(0,X.jsx)(`p`,{children:i(`tour.readAloudDescription`)}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(T,{providerId:`openai`,alt:`OpenAI`,className:`size-4`}),`OpenAI`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`computer`}),i(`settings.voice.page.provider.browser`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`cloud`}),i(`settings.voice.page.provider.custom`)]})]}),(0,X.jsxs)(d,{size:`sm`,onClick:()=>F(`tts`),children:[i(`tour.configureReadAloud`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]})]}),(0,X.jsxs)(`section`,{className:`yuri-tour-voice-recommendation`,children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-6 shrink-0`}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{children:i(`settings.voice.volcengine.name`)}),(0,X.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,X.jsx)(`p`,{children:i(`tour.voiceAllowance`)})]}),(0,X.jsx)(d,{disabled:!Y.data,size:`sm`,onClick:()=>F(`voice`),children:i(`tour.configureVoice`)})]}),Y.isError&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsx)(`p`,{children:i(`settings.voice.volcengine.loadFailed`)}),(0,X.jsx)(d,{size:`xs`,onClick:()=>void Y.refetch(),children:i(`settings.voice.volcengine.retry`)})]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`h3`,{className:`typography-ui-label mb-4`,children:[K[I].name,` · README`]}),ye?(0,X.jsx)(y,{content:ye,enableFileReferences:!1}):(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.metadataUnavailable`)})]}),B&&I===null&&(0,X.jsx)(`p`,{role:`alert`,className:`yuri-tour-feedback`,children:B})]})})]}),(0,X.jsxs)(`footer`,{className:`yuri-tour-footer`,children:[(P!==`tour`||I!==null)&&(0,X.jsx)(d,{variant:`ghost`,size:`sm`,disabled:R,onClick:_e,children:i(`onboarding.common.actions.back`)}),I===null&&(0,X.jsxs)(`div`,{className:`ml-auto flex flex-wrap justify-end gap-2`,children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,disabled:R,onClick:he,children:i(`tour.later`)}),c===2?(0,X.jsxs)(d,{size:`sm`,type:`submit`,form:`yuri-tour-import`,disabled:R||ne.disabled,"aria-busy":R,children:[R&&(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`}),i(ne.background?`historyImport.background`:`historyImport.next`)]}):c===3?(0,X.jsx)(d,{size:`sm`,disabled:R,type:P===`voice`?`submit`:`button`,form:P===`voice`?`yuri-tour-voice`:void 0,onClick:P===`voice`?void 0:me,children:i(P===`voice`?`settings.common.actions.saveChanges`:`tour.finish`)}):(0,X.jsxs)(d,{size:`sm`,disabled:R||c<2&&(!q.data||q.isError),"aria-busy":R,onClick:()=>void ge(),children:[R&&(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`}),i(`tour.continue`)]})]})]})]})})}export{pe as SetupTourDialog};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{s as o}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{W as s}from"./runtime-file-resource-9kLrAtnQ.js";import{r as c}from"./vendor-reactuses-core-DjKFMfz7.js";import{Pa as l,Xi as u,Yn as d,ro as f}from"./ui-BwSpLYDL.js";import{n as p}from"./Icon-D4ELZTbQ.js";import{t as m}from"./i18n-CYty_Jft.js";import{a as h,n as g,o as _,t as v}from"./dialog-CeXUC0Ej.js";import{n as y}from"./MarkdownRenderer-B8pnxnuP.js";import{t as b}from"./checkbox-DsB97EEi.js";import{t as x}from"./YuriLogo-CdbCjzA8.js";import{a as S,i as C}from"./ModelLogo-Ddsuaz2-.js";import{l as w}from"./zhipuai-coding-plan-CcFj8zKy.js";import{t as T}from"./ProviderLogo-ClFNH0bR.js";import{n as E}from"./speechSettingsQueries-DxCvZVJ0.js";import{n as D,t as O}from"./YuriWordmark-rISEHjrd.js";import{n as k}from"./SettingsGroup-DiF6MwFq.js";import{a as A,c as j,n as M,r as N,t as P}from"./usePluginsStore-Cnj8I3MZ.js";import{a as F,l as I,n as ee,o as te,r as L,t as R}from"./pluginPresentation-CWyI_3os.js";import{a as z,c as ne,d as re,l as B,o as V,s as ie,t as H,u as U}from"./historyImportQueries-B4DVAuxZ.js";var W=e(i(),1),G=a(),K=[{name:`Magpie`,spec:`opencode-magpie-plugin`},{name:`Eficy`,spec:`@eficy/opencode2-plugin`},{name:`yee-profile`,spec:`@yee94/opencode-profile`}];function ae(e,t){return e.some(e=>e.parsedKind===`npm`&&R(e.spec).name===t)}async function q(e,t){let n=[];for(let r of new Set(e)){if(!t.current())throw Error(`Runtime changed`);try{let e=await t.list();if(!t.current())throw Error(`Runtime changed`);ae(e,r)||(await t.create(r)).ok||n.push(r)}catch{n.push(r)}}if(!t.current())throw Error(`Runtime changed`);return{failed:n}}function oe(e,r,i){let a=t(),o=n();return q(e,{current:()=>!i.aborted&&o===n()&&a===t(),list:async()=>(await s.fetchQuery({...N(r,a),staleTime:0})).entries,create:e=>P.getState().createEntry({spec:e,scope:`user`})})}var J=`data:image/svg+xml,%3csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%20Code%3c/title%3e%3cpath%20clip-rule='evenodd'%20d='M20.998%2010.949H24v3.102h-3v3.028h-1.487V20H18v-2.921h-1.487V20H15v-2.921H9V20H7.488v-2.921H6V20H4.487v-2.921H3V14.05H0V10.95h3V5h17.998v5.949zM6%2010.949h1.488V8.102H6v2.847zm10.51%200H18V8.102h-1.49v2.847z'%20fill='%23D97757'%20fill-rule='evenodd'/%3e%3c/svg%3e`,Y=`data:image/svg+xml,%3csvg%20viewBox='0%200%2024%2024'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eCodex%3c/title%3e%3cpath%20d='M19.503%200H4.496A4.496%204.496%200%20000%204.496v15.007A4.496%204.496%200%20004.496%2024h15.007A4.496%204.496%200%200024%2019.503V4.496A4.496%204.496%200%200019.503%200z'%20fill='%23fff'/%3e%3cpath%20d='M9.064%203.344a4.578%204.578%200%20012.285-.312c1%20.115%201.891.54%202.673%201.275.01.01.024.017.037.021a.09.09%200%2000.043%200%204.55%204.55%200%20013.046.275l.047.022.116.057a4.581%204.581%200%20012.188%202.399c.209.51.313%201.041.315%201.595a4.24%204.24%200%2001-.134%201.223.123.123%200%2000.03.115c.594.607.988%201.33%201.183%202.17.289%201.425-.007%202.71-.887%203.854l-.136.166a4.548%204.548%200%2001-2.201%201.388.123.123%200%2000-.081.076c-.191.551-.383%201.023-.74%201.494-.9%201.187-2.222%201.846-3.711%201.838-1.187-.006-2.239-.44-3.157-1.302a.107.107%200%2000-.105-.024c-.388.125-.78.143-1.204.138a4.441%204.441%200%2001-1.945-.466%204.544%204.544%200%2001-1.61-1.335c-.152-.202-.303-.392-.414-.617a5.81%205.81%200%2001-.37-.961%204.582%204.582%200%2001-.014-2.298.124.124%200%2000.006-.056.085.085%200%2000-.027-.048%204.467%204.467%200%2001-1.034-1.651%203.896%203.896%200%2001-.251-1.192%205.189%205.189%200%2001.141-1.6c.337-1.112.982-1.985%201.933-2.618.212-.141.413-.251.601-.33.215-.089.43-.164.646-.227a.098.098%200%2000.065-.066%204.51%204.51%200%2001.829-1.615%204.535%204.535%200%20011.837-1.388zm3.482%2010.565a.637.637%200%20000%201.272h3.636a.637.637%200%20100-1.272h-3.636zM8.462%209.23a.637.637%200%2000-1.106.631l1.272%202.224-1.266%202.136a.636.636%200%20101.095.649l1.454-2.455a.636.636%200%2000.005-.64L8.462%209.23z'%20fill='url(%23codex-gradient)'/%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='codex-gradient'%20x1='12'%20x2='12'%20y1='3'%20y2='21'%3e%3cstop%20stop-color='%23B1A7FF'/%3e%3cstop%20offset='.5'%20stop-color='%237A9DFF'/%3e%3cstop%20offset='1'%20stop-color='%233941FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,X=r(),se={claude:J,codex:Y,cursor:S,dsh:C,opencode:w};function ce({onBusy:e,directory:r=null,onPrimaryChange:i,onComplete:a}){let{t:o,locale:s}=m(),l=t(),u=n(),[h,g]=W.useState([]),[_,v]=W.useState(!1),[y,x]=W.useState(null),S=V(),C=S.data?.state===`running`,w=ie(S.isSuccess&&!C),T=ne(w.data?.id,r,`${S.data?.id??``}:${S.data?.state??``}`,!C&&!w.isFetching&&!w.isError),E=W.useRef(null),D=W.useRef(!1),O=W.useRef(null),k=W.useRef(null),A=c(e),j=c(e=>i?.(e)),M=c((e,t)=>g(n=>t?n.includes(e)?n:[...n,e]:n.filter(t=>t!==e)));W.useEffect(()=>{let e=new AbortController;return E.current=e,()=>{e.abort(),A(!1)}},[l,u,A]);let N=W.useMemo(()=>{let e=B.map(e=>({...e,sessions:[]}));for(let t of w.data?.sessions??[]){let n=e.find(e=>e.id===t.source);n&&n.sessions.length<5&&n.sessions.push(t)}return e.filter(e=>e.sessions.length)},[w.data]),P=!!(O.current&&S.data?.id===O.current&&re(S.data)),F=_||!C&&!P&&(w.isFetching||!w.data||w.isError||S.isError);W.useEffect(()=>{j({disabled:F,background:C})},[F,C,j]);let I=()=>!E.current?.signal.aborted&&l===t()&&u===n(),ee=async e=>{if(!(D.current||!E.current)){D.current=!0,v(!0),A(!0),x(null);try{await e(E.current.signal)}catch(e){I()&&x(e instanceof Error&&/^[a-z_]+$/.test(e.message)?e.message:`import_failed`)}finally{D.current=!1,I()&&(v(!1),A(!1))}}},te=()=>ee(async e=>{if(F)return;if(C||P){I()&&a?.();return}if(!h.length){I()&&a?.();return}let t=await z(h,r,e,l,u);I()&&(O.current=t.id,k.current?.scrollIntoView({block:`start`}))}),L=w.error??S.error,R=y||(L instanceof Error&&/^[a-z_]+$/.test(L.message)?L.message:w.isError||S.isError?`import_failed`:null),G=W.useMemo(()=>new Intl.DateTimeFormat(s,{month:`short`,day:`numeric`}),[s]),K=S.data?U(S.data):null,ae=W.useMemo(()=>new Intl.NumberFormat(s),[s]),q=(e,t)=>{let n=w.data?.counts?.[e],r=n?.value;if(r==null||w.isError)return null;let i=ae.format(r),a=o(n?.approximate?`historyImport.estimatedCount`:`historyImport.sourceCount`,{count:i});return(0,X.jsx)(`span`,{id:t,"data-history-count":e,className:`yuri-import-source-count`,title:a,"aria-label":a,children:w.isFetching?(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`,"aria-label":o(`historyImport.scanning`)}):`${n?.approximate?`≈ `:``}${i}`})};return(0,X.jsxs)(`form`,{id:`yuri-tour-import`,className:`yuri-history-import`,"data-history-import":!0,onSubmit:e=>{e.preventDefault(),te()},children:[(0,X.jsx)(`h2`,{ref:k,className:`yuri-import-heading`,children:o(`historyImport.heading`)}),(0,X.jsx)(`p`,{className:`yuri-import-subtitle`,children:o(`historyImport.deduplication`)}),S.data&&!re(S.data)&&(C||O.current===S.data.id)&&(0,X.jsxs)(`div`,{className:`yuri-import-job`,role:`status`,children:[(0,X.jsx)(p,{name:C?`loader-4`:`error-warning`,className:f(`size-4`,C&&`animate-spin`)}),(0,X.jsx)(`span`,{children:o(C&&K?`historyImport.phase.${K.phase}`:`historyImport.state.${S.data.state}`)}),K&&K.total>0&&(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[K.completed,` / `,K.total]}),C&&(0,X.jsx)(d,{variant:`ghost`,size:`icon`,disabled:_,"aria-label":o(`historyImport.cancel`),title:o(`historyImport.cancel`),onClick:()=>void ee(async e=>{await H(S.data.id,e,l),I()&&await S.refetch()}),children:(0,X.jsx)(p,{name:`stop`,className:`size-4`})}),C&&K&&(0,X.jsx)(`progress`,{value:K.total?K.completed:void 0,max:K.total||1,"aria-label":o(`historyImport.progress`)}),S.data.progress?.code&&(0,X.jsxs)(`p`,{role:`alert`,children:[o(`historyImport.failed`),` `,(0,X.jsx)(`code`,{children:S.data.progress.code})]}),S.data.results.some(e=>e.status===`failed`||e.project===`failed`||e.index===`failed`)&&(0,X.jsxs)(`p`,{role:`alert`,children:[o(`historyImport.failed`),[...new Set(S.data.results.filter(e=>e.status===`failed`&&e.code).map(e=>e.code))].map(e=>(0,X.jsxs)(`code`,{children:[` `,e]},e))]})]}),(0,X.jsx)(`div`,{className:`yuri-import-source-grid`,"aria-label":o(`historyImport.sources`),children:B.map(e=>{let t=w.data?.installations?.[e.id],n=o(t===!0?`historyImport.installed`:t===!1?`historyImport.notDetected`:`historyImport.installationUnknown`),r=w.data?.counts?.[e.id]?.value!=null&&!w.isError?` history-import-count-${e.id}`:``;return(0,X.jsxs)(d,{variant:`ghost`,"data-history-source":e.id,className:f(`yuri-import-source-card`,(e.id===`cursor`||e.id===`opencode`)&&`yuri-import-source-cursor`),disabled:_||C,"aria-pressed":h.includes(e.id),"aria-label":e.name,"aria-describedby":`history-import-installed-${e.id}${r}`,onClick:()=>M(e.id,!h.includes(e.id)),children:[(0,X.jsxs)(`span`,{className:`yuri-import-logo-wrap`,children:[(0,X.jsx)(`img`,{src:se[e.id],alt:``,draggable:!1,className:`yuri-import-source-logo`}),(0,X.jsx)(`span`,{id:`history-import-installed-${e.id}`,role:`img`,"aria-label":n,title:n,"data-installed":t===!0?`true`:t===!1?`false`:`unknown`,className:`yuri-import-installation`})]}),(0,X.jsx)(`span`,{className:`yuri-import-source-name`,children:e.name}),q(e.id,`history-import-count-${e.id}`),(0,X.jsx)(`span`,{className:`yuri-import-source-check`,"aria-hidden":`true`,children:(0,X.jsx)(p,{name:`check`,className:`size-3`})})]},e.id)})}),R&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsxs)(`p`,{children:[o(R===`history_import_unsupported`?`historyImport.unsupported`:`historyImport.failed`),` `,(0,X.jsx)(`code`,{children:R})]}),(w.isError||S.isError)&&(0,X.jsx)(d,{variant:`ghost`,size:`xs`,disabled:w.isFetching||S.isFetching,onClick:()=>{Promise.all([w.refetch(),S.refetch()])},children:o(`settings.plugins.status.retry`)})]}),w.data&&!w.isFetching&&!w.isError&&!w.data.sessions.length&&!w.data.errors.length&&(0,X.jsx)(`p`,{className:`yuri-tour-feedback`,children:o(`historyImport.empty`)}),N.length>0&&(0,X.jsxs)(`section`,{"aria-label":o(`historyImport.sessions`),children:[(0,X.jsx)(`div`,{className:`yuri-import-list-heading`,children:o(`historyImport.sessions`)}),(0,X.jsx)(`div`,{className:`yuri-import-preview-groups`,children:N.map(e=>(0,X.jsxs)(`section`,{"aria-label":e.name,"data-source-selected":h.includes(e.id),children:[(0,X.jsxs)(`div`,{className:`yuri-import-preview-heading`,children:[(0,X.jsx)(`h3`,{children:e.name}),q(e.id),(0,X.jsx)(b,{checked:h.includes(e.id),disabled:_||C,ariaLabel:e.name,onChange:t=>M(e.id,t)})]}),(0,X.jsx)(`ul`,{className:`yuri-import-session-grid`,children:e.sessions.map(e=>(0,X.jsxs)(`li`,{"data-history-session":e.key,className:f(`yuri-import-session-card`,(e.source===`cursor`||e.source===`opencode`)&&`yuri-import-source-cursor`),title:e.title,children:[(0,X.jsx)(`img`,{src:se[e.source],alt:``,draggable:!1,className:`yuri-import-session-logo`}),(0,X.jsxs)(`span`,{className:`yuri-import-session-copy`,children:[(0,X.jsxs)(`span`,{className:`yuri-import-session-heading`,children:[(0,X.jsx)(`span`,{className:`yuri-import-session-title`,children:e.title}),!T.isError&&T.data?.states[e.key]===`imported`&&(0,X.jsx)(`span`,{className:`yuri-import-session-imported`,"data-history-imported":!0,children:o(`historyImport.alreadyImported`)}),e.updated&&e.updated>0?(0,X.jsx)(`time`,{dateTime:new Date(e.updated).toISOString(),children:G.format(e.updated)}):null]}),e.excerpt&&(0,X.jsx)(`span`,{className:`yuri-import-session-excerpt`,children:e.excerpt})]})]},e.key))})]},e.id))})]})]})}var Z=K.map(e=>e.spec),le=[`tour.models`,`tour.plugins`,`tour.import`,`tour.voice`],ue=[{id:`openai`,name:`OpenAI`},{id:`anthropic`,name:`Anthropic`},{id:`google`,name:`Google Gemini`},{id:`github-copilot`,name:`GitHub Copilot`},{id:`deepseek`,name:`DeepSeek`},{id:`openrouter`,name:`OpenRouter`}];function de(e){let t=(0,G.c)(48),{index:n,info:r,installed:i,selected:a,onSelect:o,onReadme:s}=e,{t:c}=m(),l=K[n],u=r?.kind===`npm-ok`?r:void 0,h=a&&`yuri-tour-card-selected`,g;t[0]===h?g=t[1]:(g=f(`yuri-tour-plugin yuri-tour-select-card`,h),t[0]=h,t[1]=g);let _;t[2]===a?_=t[3]:(_=a&&(0,X.jsx)(p,{name:`check`,className:`size-5`}),t[2]=a,t[3]=_);let v;t[4]===_?v=t[5]:(v=(0,X.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:_}),t[4]=_,t[5]=v);let y;t[6]!==o||t[7]!==l.name||t[8]!==a||t[9]!==v?(y=(0,X.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":l.name,"aria-pressed":a,onClick:o,children:v}),t[6]=o,t[7]=l.name,t[8]=a,t[9]=v,t[10]=y):y=t[10];let b=u?.icon,x;t[11]!==l.name||t[12]!==b?(x=(0,X.jsx)(I,{name:l.name,src:b,size:30}),t[11]=l.name,t[12]=b,t[13]=x):x=t[13];let S;t[14]===l.name?S=t[15]:(S=(0,X.jsx)(`h3`,{className:`typography-ui-label font-medium`,children:l.name}),t[14]=l.name,t[15]=S);let C;t[16]===l.spec?C=t[17]:(C=(0,X.jsx)(`p`,{className:`break-all typography-micro text-muted-foreground`,children:l.spec}),t[16]=l.spec,t[17]=C);let w;t[18]!==S||t[19]!==C?(w=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C]}),t[18]=S,t[19]=C,t[20]=w):w=t[20];let T;t[21]===u?T=t[22]:(T=u?.latestVersion&&(0,X.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:u.latestVersion}),t[21]=u,t[22]=T);let E;t[23]!==w||t[24]!==T||t[25]!==x?(E=(0,X.jsxs)(`div`,{className:`flex items-start gap-3 pr-10`,children:[x,w,T]}),t[23]=w,t[24]=T,t[25]=x,t[26]=E):E=t[26];let D;t[27]!==r||t[28]!==u?.description||t[29]!==c?(D=u?.description||c(r?`tour.metadataUnavailable`:`common.loading`),t[27]=r,t[28]=u?.description,t[29]=c,t[30]=D):D=t[30];let O;t[31]===D?O=t[32]:(O=(0,X.jsx)(`p`,{className:`flex-1 typography-meta text-muted-foreground`,children:D}),t[31]=D,t[32]=O);let k=!u,A;t[33]!==s||t[34]!==k?(A=(0,X.jsx)(d,{size:`xs`,variant:`ghost`,className:`yuri-tour-card-link`,disabled:k,onClick:s,children:`README`}),t[33]=s,t[34]=k,t[35]=A):A=t[35];let j;t[36]!==i||t[37]!==c?(j=i&&(0,X.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(`tour.saved`)}),t[36]=i,t[37]=c,t[38]=j):j=t[38];let M;t[39]!==A||t[40]!==j?(M=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,j]}),t[39]=A,t[40]=j,t[41]=M):M=t[41];let N;return t[42]!==E||t[43]!==O||t[44]!==M||t[45]!==g||t[46]!==y?(N=(0,X.jsxs)(`section`,{className:g,children:[y,E,O,M]}),t[42]=E,t[43]=O,t[44]=M,t[45]=g,t[46]=y,t[47]=N):N=t[47],N}function fe(e){let t=(0,G.c)(28),{settings:n,onComplete:r,onBusy:i}=e,{t:a}=m(),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={voiceProvider:`volcengine`,sttProvider:`volcengine`,dictationEnabled:!0,showMessageTTSButtons:!0},t[0]=o):o=t[0];let s=L(n,o),l=c(i),u,d;t[1]!==s.saving||t[2]!==l?(u=()=>(l(s.saving),()=>l(!1)),d=[s.saving,l],t[1]=s.saving,t[2]=l,t[3]=u,t[4]=d):(u=t[3],d=t[4]),W.useEffect(u,d);let f;t[5]!==s||t[6]!==r||t[7]!==n.configured?(f=async e=>{e.preventDefault(),!(!n.configured&&!s.draft.apiKey?.trim())&&(await s.save())?.configured&&r()},t[5]=s,t[6]=r,t[7]=n.configured,t[8]=f):f=t[8];let p=f,h;t[9]===p?h=t[10]:(h=e=>void p(e),t[9]=p,t[10]=h);let g;t[11]===a?g=t[12]:(g=a(`settings.voice.volcengine.name`),t[11]=a,t[12]=g);let _,v;t[13]===s?(_=t[14],v=t[15]):(_=(0,X.jsx)(F,{mode:`tts`,form:s}),v=(0,X.jsx)(F,{mode:`asr`,form:s,showCredentials:!1}),t[13]=s,t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==_||t[18]!==v?(y=(0,X.jsxs)(k,{label:g,children:[_,v]}),t[16]=g,t[17]=_,t[18]=v,t[19]=y):y=t[19];let b;t[20]!==s.draft||t[21]!==n.configured||t[22]!==a?(b=!n.configured&&!s.draft.apiKey?.trim()&&(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`settings.providers.page.toast.apiKeyRequired`)}),t[20]=s.draft,t[21]=n.configured,t[22]=a,t[23]=b):b=t[23];let x;return t[24]!==b||t[25]!==h||t[26]!==y?(x=(0,X.jsxs)(`form`,{id:`yuri-tour-voice`,onSubmit:h,className:`yuri-settings-section-stack`,children:[y,b]}),t[24]=b,t[25]=h,t[26]=y,t[27]=x):x=t[27],x}function pe({runtime:e,onClose:r}){let{t:i}=m(),a=A(),c=D(t=>t.progress[e]?.step??0),[b,S]=W.useState(`magpie`),[C,w]=W.useState(),[k,N]=W.useState(Z.slice(1)),[P,F]=W.useState(`tour`),[I,L]=W.useState(null),[R,z]=W.useState(!1),[ne,re]=W.useState({disabled:!0}),[B,V]=W.useState(null),ie=n(),H=t(),U=W.useRef(null),G=W.useRef(!1);W.useEffect(()=>{let e=new AbortController;return U.current=e,()=>e.abort()},[]);let q=j(),J=o({...M(a,Z.slice(1),!1,H,!0),enabled:c===1}),Y=o({...E(H),enabled:c===3}),se=q.data?.entries??[],pe=e=>{let t=u.getState(),n=e&&t.providers.some(t=>t.id===e);S(`other`),w(n?void 0:e),t.setSelectedProvider(n?e:`__add_provider__`),F(`providers`)},Q=()=>!U.current?.signal.aborted&&ie===n()&&H===t(),$=t=>{F(`tour`),V(null),D.getState().move(e,t)},me=()=>{Q()&&r()},he=()=>{c===3?me():$(c+1)},ge=async()=>{if(c===2){he();return}if(!(G.current||R||!U.current)){G.current=!0,z(!0),V(null);try{let e=c===0?b===`magpie`?[Z[0]]:[]:k;if(e.length){let t=await oe(e,a,U.current.signal);if(!Q())return;if(t.failed.length){V(i(`tour.saveFailed`,{names:t.failed.join(`, `)}));return}}if(c===0&&b===`other`){let e=await s.fetchQuery({...l(a,H),staleTime:0});if(!Q())return;if(e.partial||!e.providers.some(e=>Object.keys(e.models).length>0)){V(i(`tour.noModels`));return}await u.getState().loadProviders({directory:a,forceRefresh:!0,source:`setup-tour`})}Q()&&he()}catch{Q()&&V(i(`tour.operationFailed`))}finally{G.current=!1,Q()&&z(!1)}}},_e=()=>{I===null?P===`tour`?c>0&&$(c-1):F(`tour`):L(null)},ve=I===null?void 0:J.data?.[Z[I]],ye=ve?.kind===`npm-ok`?ve.readme:void 0;return(0,X.jsx)(v,{open:!0,onOpenChange:e=>{!e&&!R&&(I!==null||P!==`tour`?_e():me())},children:(0,X.jsxs)(g,{className:`yuri-setup-tour yuri-settings-workspace`,showCloseButton:!1,"aria-describedby":void 0,children:[(0,X.jsx)(`div`,{className:`yuri-tour-watermark`,"aria-hidden":`true`,children:(0,X.jsx)(x,{width:440,height:440})}),(0,X.jsx)(h,{children:(0,X.jsxs)(_,{className:`yuri-tour-title`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`👋`}),i(`tour.title`).split(`Yuri`).map((e,t)=>(0,X.jsxs)(W.Fragment,{children:[t>0&&(0,X.jsx)(O,{width:`2.05em`}),(0,X.jsx)(`span`,{children:e.trim()})]},t))]})}),(0,X.jsxs)(`div`,{className:`yuri-tour-body`,children:[(0,X.jsx)(`nav`,{className:`yuri-tour-progress`,"aria-label":i(`tour.title`),children:le.map((e,t)=>(0,X.jsxs)(d,{variant:`ghost`,size:`lg`,disabled:R,"aria-current":c===t?`step`:void 0,onClick:()=>{L(null),$(t)},children:[(0,X.jsx)(`span`,{className:`yuri-tour-number`,"aria-hidden":`true`,children:String(t+1).padStart(2,`0`)}),(0,X.jsx)(`span`,{children:i(e)})]},e))}),(0,X.jsx)(`div`,{className:f(`yuri-tour-content`,P===`providers`&&I===null&&`yuri-tour-provider-content`),children:(0,X.jsxs)(`fieldset`,{disabled:R,className:`contents`,children:[I===null?P===`providers`?(0,X.jsx)(te,{initialConnectionId:C}):P===`voice`&&Y.data?(0,X.jsx)(fe,{settings:Y.data,onComplete:me,onBusy:z}):P===`asr`||P===`tts`?(0,X.jsx)(ee,{section:P}):(0,X.jsxs)(X.Fragment,{children:[c<2&&(c===1&&J.isError||q.isError)&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsx)(`p`,{children:i(`tour.metadataUnavailable`)}),(0,X.jsx)(d,{size:`xs`,onClick:()=>{c===1&&J.refetch(),q.refetch()},children:i(`settings.plugins.status.retry`)})]}),c===0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:f(`yuri-tour-magpie yuri-tour-select-card`,b===`magpie`&&`yuri-tour-card-selected`),children:[(0,X.jsx)(d,{variant:`ghost`,className:`yuri-tour-card-toggle`,"aria-label":`Magpie`,"aria-pressed":b===`magpie`,onClick:()=>S(b===`magpie`?`other`:`magpie`),children:(0,X.jsx)(`span`,{className:`yuri-tour-card-check`,"aria-hidden":`true`,children:b===`magpie`&&(0,X.jsx)(p,{name:`check`,className:`size-5`})})}),(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-3 pr-10`,children:[(0,X.jsx)(T,{providerId:`magpie`,alt:`Magpie`,className:`size-8 shrink-0`}),(0,X.jsx)(`span`,{className:`typography-ui-label`,children:`Magpie`}),(0,X.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.magpieDescription`)}),(0,X.jsxs)(`a`,{className:`yuri-tour-card-link typography-meta text-muted-foreground underline`,href:`https://usemagpie.ai/docs/start`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,X.jsxs)(`div`,{className:`yuri-tour-provider-heading`,children:[(0,X.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`OpenCode`}),(0,X.jsxs)(`a`,{className:`typography-meta text-muted-foreground underline`,href:`https://opencode.ai/docs/providers/`,target:`_blank`,rel:`noreferrer`,children:[i(`tour.docs`),` ↗`]})]}),(0,X.jsx)(`div`,{className:`yuri-tour-provider-grid`,children:ue.map(e=>(0,X.jsxs)(d,{variant:`ghost`,className:`yuri-tour-provider-choice`,onClick:()=>pe(e.id),children:[(0,X.jsx)(T,{providerId:e.id,alt:e.name,className:`size-6 shrink-0`}),(0,X.jsx)(`span`,{children:e.name})]},e.id))}),(0,X.jsxs)(d,{className:`mt-3`,size:`sm`,variant:`ghost`,onClick:()=>pe(),children:[i(`tour.otherProvider`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]}),c===1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`yuri-tour-plugins`,children:[1,2].map(e=>(0,X.jsx)(de,{index:e,info:J.data?.[Z[e]],installed:ae(se,Z[e]),selected:k.includes(Z[e]),onSelect:()=>N(t=>t.includes(Z[e])?t.filter(t=>t!==Z[e]):[...t,Z[e]]),onReadme:()=>L(e)},e))}),(0,X.jsxs)(`a`,{className:`mt-4 inline-block typography-meta text-muted-foreground underline underline-offset-4 hover:text-foreground`,href:`https://opencode.ai/docs/ecosystem/#plugins`,target:`_blank`,rel:`noopener noreferrer`,children:[i(`tour.morePlugins`),` ↗`]})]}),c===2&&(0,X.jsx)(ce,{onBusy:z,directory:a,onPrimaryChange:re,onComplete:()=>$(3)}),c===3&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`yuri-tour-voice-intro`,children:[(0,X.jsx)(`h2`,{children:i(`tour.voiceHeading`)}),(0,X.jsx)(`p`,{children:i(`tour.voiceIntro`)})]}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-capabilities`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(p,{name:`mic`,className:`yuri-tour-voice-icon`}),(0,X.jsx)(`h3`,{children:i(`settings.voice.page.section.speechRecognition`)}),(0,X.jsx)(`p`,{children:i(`tour.dictationDescription`)}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`computer`}),i(`settings.voice.page.provider.local`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`server`}),i(`settings.voice.page.provider.server`)]})]}),(0,X.jsxs)(d,{size:`sm`,onClick:()=>F(`asr`),children:[i(`tour.configureInput`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(p,{name:`volume-up`,className:`yuri-tour-voice-icon`}),(0,X.jsx)(`h3`,{children:i(`tour.readAloudTitle`)}),(0,X.jsx)(`p`,{children:i(`tour.readAloudDescription`)}),(0,X.jsxs)(`div`,{className:`yuri-tour-voice-services`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-4`}),i(`settings.voice.volcengine.name`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(T,{providerId:`openai`,alt:`OpenAI`,className:`size-4`}),`OpenAI`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`computer`}),i(`settings.voice.page.provider.browser`)]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(p,{name:`cloud`}),i(`settings.voice.page.provider.custom`)]})]}),(0,X.jsxs)(d,{size:`sm`,onClick:()=>F(`tts`),children:[i(`tour.configureReadAloud`),(0,X.jsx)(p,{name:`arrow-right-s`,className:`size-4`})]})]})]}),(0,X.jsxs)(`section`,{className:`yuri-tour-voice-recommendation`,children:[(0,X.jsx)(`img`,{src:`data:image/svg+xml,%3csvg%20height='24'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='24'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eDoubao%3c/title%3e%3cpath%20d='M5.31%2015.756c.172-3.75%201.883-5.999%202.549-6.739-3.26%202.058-5.425%205.658-6.358%208.308v1.12C1.501%2021.513%204.226%2024%207.59%2024a6.59%206.59%200%20002.2-.375c.353-.12.7-.248%201.039-.378.913-.899%201.65-1.91%202.243-2.992-4.877%202.431-7.974.072-7.763-4.5l.002.001z'%20fill='%231E37FC'%3e%3c/path%3e%3cpath%20d='M22.57%2010.283c-1.212-.901-4.109-2.404-7.397-2.8.295%203.792.093%208.766-2.1%2012.773a12.782%2012.782%200%2001-2.244%202.992c3.764-1.448%206.746-3.457%208.596-5.219%202.82-2.683%203.353-5.178%203.361-6.66a2.737%202.737%200%2000-.216-1.084v-.002z'%20fill='%2337E1BE'%3e%3c/path%3e%3cpath%20d='M14.303%201.867C12.955.7%2011.248%200%209.39%200%207.532%200%205.883.677%204.545%201.807%202.791%203.29%201.627%205.557%201.5%208.125v9.201c.932-2.65%203.097-6.25%206.357-8.307.5-.318%201.025-.595%201.569-.829%201.883-.801%203.878-.932%205.746-.706-.222-2.83-.718-5.002-.87-5.617h.001z'%20fill='%23A569FF'%3e%3c/path%3e%3cpath%20d='M17.305%204.961a199.47%20199.47%200%2001-1.08-1.094c-.202-.213-.398-.419-.586-.622l-1.333-1.378c.151.615.648%202.786.869%205.617%203.288.395%206.185%201.898%207.396%202.8-1.306-1.275-3.475-3.487-5.266-5.323z'%20fill='%231E37FC'%3e%3c/path%3e%3c/svg%3e`,alt:``,className:`size-6 shrink-0`}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{children:i(`settings.voice.volcengine.name`)}),(0,X.jsx)(`span`,{className:`yuri-tour-recommended`,children:i(`tour.recommended`)})]}),(0,X.jsx)(`p`,{children:i(`tour.voiceAllowance`)})]}),(0,X.jsx)(d,{disabled:!Y.data,size:`sm`,onClick:()=>F(`voice`),children:i(`tour.configureVoice`)})]}),Y.isError&&(0,X.jsxs)(`div`,{role:`alert`,className:`yuri-tour-feedback`,children:[(0,X.jsx)(`p`,{children:i(`settings.voice.volcengine.loadFailed`)}),(0,X.jsx)(d,{size:`xs`,onClick:()=>void Y.refetch(),children:i(`settings.voice.volcengine.retry`)})]})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`h3`,{className:`typography-ui-label mb-4`,children:[K[I].name,` · README`]}),ye?(0,X.jsx)(y,{content:ye,enableFileReferences:!1}):(0,X.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:i(`tour.metadataUnavailable`)})]}),B&&I===null&&(0,X.jsx)(`p`,{role:`alert`,className:`yuri-tour-feedback`,children:B})]})})]}),(0,X.jsxs)(`footer`,{className:`yuri-tour-footer`,children:[(P!==`tour`||I!==null)&&(0,X.jsx)(d,{variant:`ghost`,size:`sm`,disabled:R,onClick:_e,children:i(`onboarding.common.actions.back`)}),I===null&&(0,X.jsxs)(`div`,{className:`ml-auto flex flex-wrap justify-end gap-2`,children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,disabled:R,onClick:he,children:i(`tour.later`)}),c===2?(0,X.jsxs)(d,{size:`sm`,type:`submit`,form:`yuri-tour-import`,disabled:R||ne.disabled,"aria-busy":R,children:[R&&(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`}),i(ne.background?`historyImport.background`:`historyImport.next`)]}):c===3?(0,X.jsx)(d,{size:`sm`,disabled:R,type:P===`voice`?`submit`:`button`,form:P===`voice`?`yuri-tour-voice`:void 0,onClick:P===`voice`?void 0:me,children:i(P===`voice`?`settings.common.actions.saveChanges`:`tour.finish`)}):(0,X.jsxs)(d,{size:`sm`,disabled:R||c<2&&(!q.data||q.isError),"aria-busy":R,onClick:()=>void ge(),children:[R&&(0,X.jsx)(p,{name:`loader-4`,className:`size-3 animate-spin`}),i(`tour.continue`)]})]})]})]})})}export{pe as SetupTourDialog};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{n as r}from"./Icon-zB0u-x9G.js";import{t as i}from"./i18n-WsU03nwB.js";import{i as a,n as o,t as s}from"./tooltip-Cdsa-YWG.js";var c=n();t();var l=e(),u=e=>{let t=(0,c.c)(38),{syncAction:n,remotes:u,onSync:d,disabled:f,aheadCount:p,behindCount:m,trackingRemoteName:h,hasUncommittedChanges:g}=e,_;t[0]===u?_=t[1]:(_=u===void 0?[]:u,t[0]=u,t[1]=_);let v=_,y=p===void 0?0:p,b=m===void 0?0:m,x=g!==void 0&&g,{t:S}=i(),C;t[2]!==v||t[3]!==h?(C=v.find(e=>e.name===h)??v[0],t[2]=v,t[3]=h,t[4]=C):C=t[4];let w=C,T=b>0&&x,E=f||n!==null||!w||T,D=y>0||b>0,O;t[5]!==y||t[6]!==b||t[7]!==T||t[8]!==D||t[9]!==S||t[10]!==w?(O=T?S(`gitView.sync.commitOrStashTooltip`):w?D?S(`gitView.sync.syncChangesTooltip`,{ahead:y,behind:b}):S(`gitView.sync.syncChanges`):S(`gitView.sync.noRemoteTooltip`),t[5]=y,t[6]=b,t[7]=T,t[8]=D,t[9]=S,t[10]=w,t[11]=O):O=t[11];let k=O,A;t[12]!==d||t[13]!==w?(A=()=>{w&&d(w)},t[12]=d,t[13]=w,t[14]=A):A=t[14];let j=A,M=D?0:void 0,N;t[15]!==y||t[16]!==b||t[17]!==D||t[18]!==S?(N=D?S(`gitView.sync.syncChangesTooltip`,{ahead:y,behind:b}):S(`gitView.sync.syncChanges`),t[15]=y,t[16]=b,t[17]=D,t[18]=S,t[19]=N):N=t[19];let P;t[20]===n?P=t[21]:(P=n===`sync`?(0,l.jsx)(r,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,l.jsx)(r,{name:`refresh`,className:`size-3.5`}),t[20]=n,t[21]=P);let F;t[22]===D?F=t[23]:(F=D?(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-0.5 top-0 size-1 rounded-full bg-[var(--status-error)] ring-1 ring-[var(--surface-background)]`}):null,t[22]=D,t[23]=F);let I;t[24]!==P||t[25]!==F?(I=(0,l.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[P,F]}),t[24]=P,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==j||t[28]!==E||t[29]!==N||t[30]!==I?(L=(0,l.jsx)(a,{asChild:!0,children:(0,l.jsx)(`button`,{type:`button`,onClick:j,disabled:E,className:`inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded px-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":N,children:I})}),t[27]=j,t[28]=E,t[29]=N,t[30]=I,t[31]=L):L=t[31];let R;t[32]===k?R=t[33]:(R=(0,l.jsx)(o,{side:`bottom`,sideOffset:8,children:k}),t[32]=k,t[33]=R);let z;return t[34]!==L||t[35]!==R||t[36]!==M?(z=(0,l.jsxs)(s,{delayDuration:M,children:[L,R]}),t[34]=L,t[35]=R,t[36]=M,t[37]=z):z=t[37],z};export{u as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{n as r}from"./Icon-D4ELZTbQ.js";import{t as i}from"./i18n-CYty_Jft.js";import{i as a,n as o,t as s}from"./tooltip-D2BtRCgs.js";var c=n();t();var l=e(),u=e=>{let t=(0,c.c)(38),{syncAction:n,remotes:u,onSync:d,disabled:f,aheadCount:p,behindCount:m,trackingRemoteName:h,hasUncommittedChanges:g}=e,_;t[0]===u?_=t[1]:(_=u===void 0?[]:u,t[0]=u,t[1]=_);let v=_,y=p===void 0?0:p,b=m===void 0?0:m,x=g!==void 0&&g,{t:S}=i(),C;t[2]!==v||t[3]!==h?(C=v.find(e=>e.name===h)??v[0],t[2]=v,t[3]=h,t[4]=C):C=t[4];let w=C,T=b>0&&x,E=f||n!==null||!w||T,D=y>0||b>0,O;t[5]!==y||t[6]!==b||t[7]!==T||t[8]!==D||t[9]!==S||t[10]!==w?(O=T?S(`gitView.sync.commitOrStashTooltip`):w?D?S(`gitView.sync.syncChangesTooltip`,{ahead:y,behind:b}):S(`gitView.sync.syncChanges`):S(`gitView.sync.noRemoteTooltip`),t[5]=y,t[6]=b,t[7]=T,t[8]=D,t[9]=S,t[10]=w,t[11]=O):O=t[11];let k=O,A;t[12]!==d||t[13]!==w?(A=()=>{w&&d(w)},t[12]=d,t[13]=w,t[14]=A):A=t[14];let j=A,M=D?0:void 0,N;t[15]!==y||t[16]!==b||t[17]!==D||t[18]!==S?(N=D?S(`gitView.sync.syncChangesTooltip`,{ahead:y,behind:b}):S(`gitView.sync.syncChanges`),t[15]=y,t[16]=b,t[17]=D,t[18]=S,t[19]=N):N=t[19];let P;t[20]===n?P=t[21]:(P=n===`sync`?(0,l.jsx)(r,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,l.jsx)(r,{name:`refresh`,className:`size-3.5`}),t[20]=n,t[21]=P);let F;t[22]===D?F=t[23]:(F=D?(0,l.jsx)(`span`,{"aria-hidden":`true`,className:`absolute -right-0.5 top-0 size-1 rounded-full bg-[var(--status-error)] ring-1 ring-[var(--surface-background)]`}):null,t[22]=D,t[23]=F);let I;t[24]!==P||t[25]!==F?(I=(0,l.jsxs)(`span`,{className:`relative flex size-3.5 shrink-0`,children:[P,F]}),t[24]=P,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==j||t[28]!==E||t[29]!==N||t[30]!==I?(L=(0,l.jsx)(a,{asChild:!0,children:(0,l.jsx)(`button`,{type:`button`,onClick:j,disabled:E,className:`inline-flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded px-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":N,children:I})}),t[27]=j,t[28]=E,t[29]=N,t[30]=I,t[31]=L):L=t[31];let R;t[32]===k?R=t[33]:(R=(0,l.jsx)(o,{side:`bottom`,sideOffset:8,children:k}),t[32]=k,t[33]=R);let z;return t[34]!==L||t[35]!==R||t[36]!==M?(z=(0,l.jsxs)(s,{delayDuration:M,children:[L,R]}),t[34]=L,t[35]=R,t[36]=M,t[37]=z):z=t[37],z};export{u as t};
@@ -1,8 +1,8 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-V-iMWR8t.js";import{F as n,s as r}from"./platform-CNdx57HN.js";import{it as i,ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{f as s,p as c,r as l}from"./useUIStore-P32bzAJc.js";import{s as u}from"./terminalApi-D2ECmoAo.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{Yn as p,f as m,no as h,to as g}from"./ui-CU6n15y3.js";import{n as _}from"./Icon-zB0u-x9G.js";import{t as v}from"./i18n-WsU03nwB.js";import{t as y}from"./OverlayScrollbar-n5T49w2e.js";import{n as b}from"./useThemeSystem-BIXghnHj.js";import{r as te}from"./device-CtdJ8KBJ.js";import{n as x}from"./useEffectiveDirectory-DNVTRp-B.js";import{n as ne}from"./useProjectRuntimeAPIs-TALa4FqO.js";import{t as re}from"./sortable-tabs-strip-DlQjS9bw.js";import{n as S,t as C}from"./useFontPreferences-BY0TXvWI.js";import{t as ie}from"./project-preview-CIkGbBPZ.js";import{n as ae}from"./projectActions-D84EVh3q.js";var w=e(o(),1);function oe(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function se(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var ce=e(i(),1),T=a(),E=null;function D(){return E||=f.load(),E}function O(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var k=w.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:u=!0},f)=>{let{t:p}=v(),m=w.useRef(null),_=w.useRef(null),b=w.useRef(null),te=w.useRef(null),x=w.useRef(n),ne=w.useRef(r),re=w.useRef(null),S=w.useRef(``),C=w.useRef(null),ie=w.useRef(!1),ae=w.useRef(null),oe=w.useRef(!0),E=w.useRef(null),k=w.useRef(null),le=w.useRef(0),ue=w.useRef(null),de=w.useRef(null),A=w.useRef(!1),j=w.useRef(!1),M=w.useRef(null),N=w.useRef(null),fe=w.useRef(null),pe=w.useRef(``),me=w.useRef(null),P=w.useRef(!c),he=w.useRef(u),[,ge]=w.useReducer(e=>e+1,0),[_e,ve]=w.useReducer(e=>e+1,0);x.current=n,ne.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;w.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=w.useCallback(()=>{if(!F)return;let e=m.current,t=ue.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[F]),I=w.useCallback(e=>{if(me.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),me.current=e;return}t.options&&(t.options.cursorBlink=e,me.current=e)}catch{}},[]),L=F&&ye,R=w.useCallback((e,t)=>{let n=L?de.current:ue.current,r=m.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[L]),z=w.useCallback(()=>{if(F){R(),I(!0);return}b.current?.focus(),I(!0)},[R,I,F]),B=w.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=w.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=w.useCallback(e=>{if(typeof window>`u`||L)return;fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null);let t=0,n=()=>{fe.current=window.setTimeout(()=>{fe.current=null;let r=B(e);if(!r){if(t+=1,t<3){n();return}return}let i=pe.current;pe.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);w.useEffect(()=>{let e=m.current;if(!F||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}R()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,F,R]);let Se=w.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=w.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=m.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=w.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await g(e)},[H,Se]),W=w.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);w.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{W()&&(e.preventDefault(),U())};return window.addEventListener(`yuri:copy`,e),()=>{window.removeEventListener(`yuri:copy`,e)}},[U,W]);let G=w.useCallback(()=>{S.current=``,C.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(C.current),C.current=null,ie.current=!1,ae.current=null},[]),K=w.useCallback(()=>{let e=te.current,t=b.current,n=m.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=re.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(re.current=n,ne.current(n.cols,n.rows))}catch{}},[]),Ce=w.useCallback(()=>{if(ie.current)return;let e=b.current;if(!e){G();return}if(!S.current)return;let t=S.current;S.current=``,ie.current=!0,e.write(t,()=>{ie.current=!1,S.current&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())})},[G]),we=w.useCallback(()=>{C.current===null&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())},[Ce]),Te=w.useCallback(e=>{e&&(S.current+=e,we())},[we]),Ee=w.useCallback(()=>{if(E.current?.(),E.current=null,k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),!c){le.current=0;return}let e=m.current;if(!e)return;let t=b.current;if(!t)return;le.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){F?R(n.clientX,n.clientY):c&&!P.current&&(P.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let m=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=m,e.style.overscrollBehaviorY=g};return}let g=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},v=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];F?R(t?.clientX,t?.clientY):c&&!P.current&&(P.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,v,h),e.addEventListener(`touchcancel`,v,h);let y=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,v,h),e.removeEventListener(`touchcancel`,v,h),e.style.touchAction=y,e.style.overscrollBehaviorY=te}},[c,F,R,o]);w.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=m.current;if(!p)return;if(p.tabIndex=F?-1:0,F){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{R()}),f=()=>{t.focus=e}}let h=()=>{I(!0)},g=()=>{I(!1)},v=e=>{let t=e.target;if(t&&p.contains(t)){if(F&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),R()},0),I(!1);return}if(c&&!P.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),I(!1);return}I(!0);return}I(!1)},y=()=>{I(!1)},ne=null;return(async()=>{try{let f=await D();if(e)return;let m=se(a,o,i,f,!1),v=new d(m);oe.current=!0,F&&(v.focus=()=>{});let y=v;if(typeof y.scrollToBottom==`function`){let e=y.scrollToBottom.bind(y);y.scrollToBottom=()=>{oe.current&&e()},l=()=>{y.scrollToBottom=e}}let re=new ee;if(t=v,b.current=v,te.current=re,v.loadAddon(re),v.open(p),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,ne=v.textarea??p.querySelector(`textarea`),ne&&(ne.addEventListener(`focus`,h),ne.addEventListener(`blur`,g)),be(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{be()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let S=O(p);S?(S.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),_.current=S,ge()):_.current=null,K();let C=re;typeof C.observeResize==`function`&&C.observeResize(),Ee(),s=[v.onData(e=>{x.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();oe.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){oe.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,v,!0),window.addEventListener(`blur`,y),()=>{e=!0,E.current?.(),E.current=null,document.removeEventListener(`focusin`,v,!0),window.removeEventListener(`blur`,y),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,ne&&(ne.removeEventListener(`focus`,h),ne.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),b.current=null,te.current=null,_.current=null,re.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),w.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),re.current=null,K())},[e,_e,K,G]),w.useEffect(()=>{l&&b.current&&z()},[l,z,e,_e]),w.useEffect(()=>(Ee(),()=>{E.current?.(),E.current=null}),[Ee,e]),w.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){ae.current!==null&&(e.reset(),G(),K());return}let n=ae.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&Te(r.map(e=>e.data).join(``)),ae.current=t[t.length-1].id},[t,_e,Te,K,G]),w.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=w.useCallback(e=>{if(!F)return;let t=m.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[F]),q=w.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(N.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){A.current=!0;return}if(!n&&r){if(A.current)return;e.preventDefault(),x.current(r),M.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertText`&&r){if(A.current)return;e.preventDefault(),x.current(r),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertLineBreak`){if(A.current)return;e.preventDefault(),x.current(`\r`),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`deleteContentBackward`){if(A.current)return;e.preventDefault(),x.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=w.useCallback(e=>{let t=e.currentTarget;if(N.current=typeof performance<`u`?performance.now():Date.now(),A.current)return;if(j.current){let e=M.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){j.current=!1,V(t);return}j.current=!1}let n=B(t);if(!n)return;pe.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),V(t),pe.current=``},[V,B]),J=w.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&W()){e.preventDefault(),U();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(String.fromCharCode(t.charCodeAt(0)-64)),V(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),V(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),x.current(i),V(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=M.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),x.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=w.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=w.useCallback(e=>{let t=e.currentTarget;A.current=!1;let n=e.data||B(t);if(N.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=w.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Z={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,T.jsxs)(`div`,{ref:m,className:h(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":F?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!F||c)&&!W()){let t=e.touches?.[0];R(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(F){if(W())return;R(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,ce.createPortal)((0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`input`,{ref:de,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`block`:`none`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X}),(0,T.jsx)(`textarea`,{ref:ue,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`none`:`block`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X})]}),document.body):null,_.current&&!c?(0,T.jsx)(y,{containerRef:_,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});k.displayName=`TerminalViewport`;var le=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),ue=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,de=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,A=/Serving HTTP on .*? port (\d{2,5})/i,j=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),M=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(j.has(e)){t=t.slice(0,-1);continue}break}return t},N=e=>{let t=M(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},fe=e=>{if(!e)return null;let t=e.replace(le,``),n=t.match(A);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
2
- `);for(let e of r){if(!de.test(e))continue;let t=Array.from(e.matchAll(ue));if(t.length!==0)return N((t.find(e=>{try{return!!new URL(N(e[1])).port}catch{return!1}})??t[0])[1])}return null},pe=async(e,n=1500)=>{if(!e||typeof window>`u`)return!1;let r;try{r=new URL(e)}catch{return!1}if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=r.hostname.toLowerCase();if(i!==`localhost`&&i!==`127.0.0.1`&&i!==`0.0.0.0`&&i!==`::1`&&i!==`::`)return!1;let a=new AbortController,o=window.setTimeout(()=>a.abort(),n);try{let e=await t(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:r.toString()}),cache:`no-store`,signal:a.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},me={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},P={ctrl:`5`,cmd:`3`},he={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},ge={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},_e=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${P[t]}A`;case`arrow-down`:return`\u001b[1;${P[t]}B`;case`arrow-right`:return`\u001b[1;${P[t]}C`;case`arrow-left`:return`\u001b[1;${P[t]}D`}return me[e]??null},ve=()=>{let{t:e}=v(),{terminal:t,runtime:i,projectScope:a}=ne(),{currentTheme:o}=b(),{monoFont:d}=C(),f=l(e=>e.terminalFontSize),ee=l(e=>e.bottomTerminalHeight),g=l(e=>e.isBottomTerminalExpanded),{isMobile:y,isTablet:se,hasTouchOnlyPointer:ce}=te(),E=y||se,D=(E||ce)&&i.platform===`web`,O=i.platform!==`vscode`,le=l(e=>e.showTerminalQuickKeysOnDesktop),ue=!n()&&(E||le),de=m(e=>e.currentSessionId),A=m(e=>e.newSessionDraft),j=!!a||de!==null||A?.open===!0,M=x()??null??a?.location.directory??null,N=a?r({...a.location,directory:M??a.location.directory}):M,me=S(e=>e.sessions),P=S(e=>e.hasHydrated),ve=S(e=>e.ensureDirectory),ye=S(e=>e.createTab),F=S(e=>e.setActiveTab),be=S(e=>e.closeTab),I=w.useMemo(()=>a?async(e,n)=>{await be(e,n,t.close)}:be,[a,t,be]),L=S(e=>e.setTabSessionId),R=S(e=>e.setTabLifecycle),z=S(e=>e.setConnecting),B=S(e=>e.appendToBuffer),V=S(e=>e.setTabPreviewUrl),xe=S(e=>e.clearBuffer),Se=l(e=>e.openContextPreview),H=w.useMemo(()=>{if(N)return me.get(N)},[me,N]),U=w.useMemo(()=>H?O?H.activeTabId??H.tabs[0]?.id??null:H.tabs[0]?.id??null:null,[H,O]),W=w.useMemo(()=>{if(H)return U?H.tabs.find(e=>e.id===U)??H.tabs[0]:H.tabs[0]},[H,U]),G=w.useMemo(()=>(H?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?ae[t.iconKey]??`terminal`:`terminal`;return(0,T.jsx)(_,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[H?.tabs,e]),K=W?.terminalSessionId??null,Ce=W?.lifecycle??`idle`,we=W?.bufferChunks??[],Te=W?.isConnecting??!1,Ee=W?.previewUrl??null,[De,q]=w.useState(null),[Oe,J]=w.useState(!1),[ke,Y]=w.useState(!1),[X,Z]=w.useState(null),[Ae,je]=w.useState(!1),[Me,Ne]=w.useState(0),Pe=w.useRef(null),Fe=w.useRef(null),Ie=w.useRef(U),Le=w.useRef(K),Re=w.useRef(N),ze=w.useRef(null),Be=w.useRef(null),Ve=w.useRef(!1),He=w.useRef(!1),Ue=w.useRef(null),We=w.useRef(null),Ge=w.useRef(new Set),Ke=w.useRef(!1),qe=w.useRef(``),Je=w.useRef(new Set),Ye=w.useRef(0),Xe=w.useCallback(()=>{qe.current=``,Je.current.clear(),Ye.current+=1},[]),Ze=w.useCallback(()=>{D||typeof document<`u`&&!document.hasFocus()||ze.current?.focus()},[D]),Qe=w.useCallback(()=>{D||ze.current?.focus()},[D]);w.useEffect(()=>{if(!P||Ke.current)return;Ke.current=!0;let e=new Set;for(let[,t]of S.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ge.current=e},[P]);let $e=l(e=>e.activeMainTab),et=l(e=>e.isBottomTerminalOpen),tt=l(e=>e.setBottomTerminalOpen),nt=l(e=>e.setBottomTerminalExpanded),rt=$e===`terminal`,Q=rt||et,[it,at]=w.useState(Q);w.useEffect(()=>{!Q||i.platform===`vscode`||a||u()},[Q,i.platform,a]),w.useEffect(()=>{Q&&at(!0)},[Q]),w.useEffect(()=>{He.current=Q},[Q]),w.useEffect(()=>{Le.current=K},[K]),w.useEffect(()=>{Ie.current=U,Xe()},[U,Xe]),w.useEffect(()=>{Re.current=N},[N]),w.useEffect(()=>{!ue&&X!==null&&Z(null)},[ue,X,Z]),w.useEffect(()=>{!K&&X!==null&&Z(null)},[K,X,Z]);let $=w.useCallback(()=>{Pe.current?.(),Pe.current=null,Fe.current=null,Ue.current=null,Y(!1)},[]);w.useEffect(()=>()=>{$(),Le.current=null},[$]),w.useEffect(()=>($(),$),[t,$]);let ot=w.useCallback((e,t,n)=>{if(!n)return;let r=`${qe.current}${n}`.replace(/\r\n|\r/g,`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-V-iMWR8t.js";import{I as n,s as r}from"./platform-B2ylz14u.js";import{it as i,ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{f as s,p as c,r as l}from"./useUIStore-68ZPpgYA.js";import{s as u}from"./terminalApi-CsTh04jY.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{Yn as p,f as m,no as h,ro as g}from"./ui-BwSpLYDL.js";import{n as _}from"./Icon-D4ELZTbQ.js";import{t as v}from"./i18n-CYty_Jft.js";import{t as y}from"./OverlayScrollbar-DdK6iB_P.js";import{n as b}from"./useThemeSystem-BIXghnHj.js";import{r as te}from"./device-TCHW5U2y.js";import{n as x}from"./useEffectiveDirectory-DeoADFfu.js";import{n as ne}from"./useProjectRuntimeAPIs-BoNGczR0.js";import{t as re}from"./sortable-tabs-strip-Doz9wEki.js";import{n as S,t as C}from"./useFontPreferences-DyMUXTQC.js";import{t as ie}from"./project-preview-Dq--046z.js";import{n as ae}from"./projectActions-B11KAI3f.js";var w=e(o(),1);function oe(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function se(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var ce=e(i(),1),T=a(),E=null;function D(){return E||=f.load(),E}function O(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var k=w.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:u=!0},f)=>{let{t:p}=v(),m=w.useRef(null),_=w.useRef(null),b=w.useRef(null),te=w.useRef(null),x=w.useRef(n),ne=w.useRef(r),re=w.useRef(null),S=w.useRef(``),C=w.useRef(null),ie=w.useRef(!1),ae=w.useRef(null),oe=w.useRef(!0),E=w.useRef(null),k=w.useRef(null),le=w.useRef(0),ue=w.useRef(null),de=w.useRef(null),A=w.useRef(!1),j=w.useRef(!1),M=w.useRef(null),N=w.useRef(null),fe=w.useRef(null),pe=w.useRef(``),me=w.useRef(null),P=w.useRef(!c),he=w.useRef(u),[,ge]=w.useReducer(e=>e+1,0),[_e,ve]=w.useReducer(e=>e+1,0);x.current=n,ne.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;w.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=w.useCallback(()=>{if(!F)return;let e=m.current,t=ue.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[F]),I=w.useCallback(e=>{if(me.current===e)return;let t=b.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),me.current=e;return}t.options&&(t.options.cursorBlink=e,me.current=e)}catch{}},[]),L=F&&ye,R=w.useCallback((e,t)=>{let n=L?de.current:ue.current,r=m.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[L]),z=w.useCallback(()=>{if(F){R(),I(!0);return}b.current?.focus(),I(!0)},[R,I,F]),B=w.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=w.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=w.useCallback(e=>{if(typeof window>`u`||L)return;fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null);let t=0,n=()=>{fe.current=window.setTimeout(()=>{fe.current=null;let r=B(e);if(!r){if(t+=1,t<3){n();return}return}let i=pe.current;pe.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);w.useEffect(()=>{let e=m.current;if(!F||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}R()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,F,R]);let Se=w.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=w.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=m.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=w.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await h(e)},[H,Se]),W=w.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);w.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{W()&&(e.preventDefault(),U())};return window.addEventListener(`yuri:copy`,e),()=>{window.removeEventListener(`yuri:copy`,e)}},[U,W]);let G=w.useCallback(()=>{S.current=``,C.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(C.current),C.current=null,ie.current=!1,ae.current=null},[]),K=w.useCallback(()=>{let e=te.current,t=b.current,n=m.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=re.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(re.current=n,ne.current(n.cols,n.rows))}catch{}},[]),Ce=w.useCallback(()=>{if(ie.current)return;let e=b.current;if(!e){G();return}if(!S.current)return;let t=S.current;S.current=``,ie.current=!0,e.write(t,()=>{ie.current=!1,S.current&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())})},[G]),we=w.useCallback(()=>{C.current===null&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())},[Ce]),Te=w.useCallback(e=>{e&&(S.current+=e,we())},[we]),Ee=w.useCallback(()=>{if(E.current?.(),E.current=null,k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),!c){le.current=0;return}let e=m.current;if(!e)return;let t=b.current;if(!t)return;le.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},h={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){F?R(n.clientX,n.clientY):c&&!P.current&&(P.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let m=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=m,e.style.overscrollBehaviorY=g};return}let g=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},_=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},v=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];F?R(t?.clientX,t?.clientY):c&&!P.current&&(P.current=!0,b.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,v,h),e.addEventListener(`touchcancel`,v,h);let y=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,v,h),e.removeEventListener(`touchcancel`,v,h),e.style.touchAction=y,e.style.overscrollBehaviorY=te}},[c,F,R,o]);w.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=m.current;if(!p)return;if(p.tabIndex=F?-1:0,F){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{R()}),f=()=>{t.focus=e}}let h=()=>{I(!0)},g=()=>{I(!1)},v=e=>{let t=e.target;if(t&&p.contains(t)){if(F&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),R()},0),I(!1);return}if(c&&!P.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),I(!1);return}I(!0);return}I(!1)},y=()=>{I(!1)},ne=null;return(async()=>{try{let f=await D();if(e)return;let m=se(a,o,i,f,!1),v=new d(m);oe.current=!0,F&&(v.focus=()=>{});let y=v;if(typeof y.scrollToBottom==`function`){let e=y.scrollToBottom.bind(y);y.scrollToBottom=()=>{oe.current&&e()},l=()=>{y.scrollToBottom=e}}let re=new ee;if(t=v,b.current=v,te.current=re,v.loadAddon(re),v.open(p),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,ne=v.textarea??p.querySelector(`textarea`),ne&&(ne.addEventListener(`focus`,h),ne.addEventListener(`blur`,g)),be(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{be()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let S=O(p);S?(S.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),_.current=S,ge()):_.current=null,K();let C=re;typeof C.observeResize==`function`&&C.observeResize(),Ee(),s=[v.onData(e=>{x.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();oe.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){oe.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,v,!0),window.addEventListener(`blur`,y),()=>{e=!0,E.current?.(),E.current=null,document.removeEventListener(`focusin`,v,!0),window.removeEventListener(`blur`,y),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,ne&&(ne.removeEventListener(`focus`,h),ne.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),b.current=null,te.current=null,_.current=null,re.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),w.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),re.current=null,K())},[e,_e,K,G]),w.useEffect(()=>{l&&b.current&&z()},[l,z,e,_e]),w.useEffect(()=>(Ee(),()=>{E.current?.(),E.current=null}),[Ee,e]),w.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){ae.current!==null&&(e.reset(),G(),K());return}let n=ae.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&Te(r.map(e=>e.data).join(``)),ae.current=t[t.length-1].id},[t,_e,Te,K,G]),w.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=w.useCallback(e=>{if(!F)return;let t=m.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[F]),q=w.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(N.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){A.current=!0;return}if(!n&&r){if(A.current)return;e.preventDefault(),x.current(r),M.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertText`&&r){if(A.current)return;e.preventDefault(),x.current(r),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertLineBreak`){if(A.current)return;e.preventDefault(),x.current(`\r`),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`deleteContentBackward`){if(A.current)return;e.preventDefault(),x.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=w.useCallback(e=>{let t=e.currentTarget;if(N.current=typeof performance<`u`?performance.now():Date.now(),A.current)return;if(j.current){let e=M.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){j.current=!1,V(t);return}j.current=!1}let n=B(t);if(!n)return;pe.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),V(t),pe.current=``},[V,B]),J=w.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&W()){e.preventDefault(),U();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(String.fromCharCode(t.charCodeAt(0)-64)),V(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),x.current(`\x1B`+e.key),V(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),x.current(i),V(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=M.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),x.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=w.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=w.useCallback(e=>{let t=e.currentTarget;A.current=!1;let n=e.data||B(t);if(N.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);x.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=w.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.current(n)},[]),Z={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,T.jsxs)(`div`,{ref:m,className:g(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":F?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!F||c)&&!W()){let t=e.touches?.[0];R(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(F){if(W())return;R(e.clientX,e.clientY)}else b.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,ce.createPortal)((0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(`input`,{ref:de,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`block`:`none`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X}),(0,T.jsx)(`textarea`,{ref:ue,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`none`:`block`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X})]}),document.body):null,_.current&&!c?(0,T.jsx)(y,{containerRef:_,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});k.displayName=`TerminalViewport`;var le=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),ue=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,de=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,A=/Serving HTTP on .*? port (\d{2,5})/i,j=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),M=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(j.has(e)){t=t.slice(0,-1);continue}break}return t},N=e=>{let t=M(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},fe=e=>{if(!e)return null;let t=e.replace(le,``),n=t.match(A);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
2
+ `);for(let e of r){if(!de.test(e))continue;let t=Array.from(e.matchAll(ue));if(t.length!==0)return N((t.find(e=>{try{return!!new URL(N(e[1])).port}catch{return!1}})??t[0])[1])}return null},pe=async(e,n=1500)=>{if(!e||typeof window>`u`)return!1;let r;try{r=new URL(e)}catch{return!1}if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=r.hostname.toLowerCase();if(i!==`localhost`&&i!==`127.0.0.1`&&i!==`0.0.0.0`&&i!==`::1`&&i!==`::`)return!1;let a=new AbortController,o=window.setTimeout(()=>a.abort(),n);try{let e=await t(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:r.toString()}),cache:`no-store`,signal:a.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},me={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},P={ctrl:`5`,cmd:`3`},he={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},ge={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},_e=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${P[t]}A`;case`arrow-down`:return`\u001b[1;${P[t]}B`;case`arrow-right`:return`\u001b[1;${P[t]}C`;case`arrow-left`:return`\u001b[1;${P[t]}D`}return me[e]??null},ve=()=>{let{t:e}=v(),{terminal:t,runtime:i,projectScope:a}=ne(),{currentTheme:o}=b(),{monoFont:d}=C(),f=l(e=>e.terminalFontSize),ee=l(e=>e.bottomTerminalHeight),h=l(e=>e.isBottomTerminalExpanded),{isMobile:y,isTablet:se,hasTouchOnlyPointer:ce}=te(),E=y||se,D=(E||ce)&&i.platform===`web`,O=i.platform!==`vscode`,le=l(e=>e.showTerminalQuickKeysOnDesktop),ue=!n()&&(E||le),de=m(e=>e.currentSessionId),A=m(e=>e.newSessionDraft),j=!!a||de!==null||A?.open===!0,M=x()??null??a?.location.directory??null,N=a?r({...a.location,directory:M??a.location.directory}):M,me=S(e=>e.sessions),P=S(e=>e.hasHydrated),ve=S(e=>e.ensureDirectory),ye=S(e=>e.createTab),F=S(e=>e.setActiveTab),be=S(e=>e.closeTab),I=w.useMemo(()=>a?async(e,n)=>{await be(e,n,t.close)}:be,[a,t,be]),L=S(e=>e.setTabSessionId),R=S(e=>e.setTabLifecycle),z=S(e=>e.setConnecting),B=S(e=>e.appendToBuffer),V=S(e=>e.setTabPreviewUrl),xe=S(e=>e.clearBuffer),Se=l(e=>e.openContextPreview),H=w.useMemo(()=>{if(N)return me.get(N)},[me,N]),U=w.useMemo(()=>H?O?H.activeTabId??H.tabs[0]?.id??null:H.tabs[0]?.id??null:null,[H,O]),W=w.useMemo(()=>{if(H)return U?H.tabs.find(e=>e.id===U)??H.tabs[0]:H.tabs[0]},[H,U]),G=w.useMemo(()=>(H?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?ae[t.iconKey]??`terminal`:`terminal`;return(0,T.jsx)(_,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[H?.tabs,e]),K=W?.terminalSessionId??null,Ce=W?.lifecycle??`idle`,we=W?.bufferChunks??[],Te=W?.isConnecting??!1,Ee=W?.previewUrl??null,[De,q]=w.useState(null),[Oe,J]=w.useState(!1),[ke,Y]=w.useState(!1),[X,Z]=w.useState(null),[Ae,je]=w.useState(!1),[Me,Ne]=w.useState(0),Pe=w.useRef(null),Fe=w.useRef(null),Ie=w.useRef(U),Le=w.useRef(K),Re=w.useRef(N),ze=w.useRef(null),Be=w.useRef(null),Ve=w.useRef(!1),He=w.useRef(!1),Ue=w.useRef(null),We=w.useRef(null),Ge=w.useRef(new Set),Ke=w.useRef(!1),qe=w.useRef(``),Je=w.useRef(new Set),Ye=w.useRef(0),Xe=w.useCallback(()=>{qe.current=``,Je.current.clear(),Ye.current+=1},[]),Ze=w.useCallback(()=>{D||typeof document<`u`&&!document.hasFocus()||ze.current?.focus()},[D]),Qe=w.useCallback(()=>{D||ze.current?.focus()},[D]);w.useEffect(()=>{if(!P||Ke.current)return;Ke.current=!0;let e=new Set;for(let[,t]of S.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ge.current=e},[P]);let $e=l(e=>e.activeMainTab),et=l(e=>e.isBottomTerminalOpen),tt=l(e=>e.setBottomTerminalOpen),nt=l(e=>e.setBottomTerminalExpanded),rt=$e===`terminal`,Q=rt||et,[it,at]=w.useState(Q);w.useEffect(()=>{!Q||i.platform===`vscode`||a||u()},[Q,i.platform,a]),w.useEffect(()=>{Q&&at(!0)},[Q]),w.useEffect(()=>{He.current=Q},[Q]),w.useEffect(()=>{Le.current=K},[K]),w.useEffect(()=>{Ie.current=U,Xe()},[U,Xe]),w.useEffect(()=>{Re.current=N},[N]),w.useEffect(()=>{!ue&&X!==null&&Z(null)},[ue,X,Z]),w.useEffect(()=>{!K&&X!==null&&Z(null)},[K,X,Z]);let $=w.useCallback(()=>{Pe.current?.(),Pe.current=null,Fe.current=null,Ue.current=null,Y(!1)},[]);w.useEffect(()=>()=>{$(),Le.current=null},[$]),w.useEffect(()=>($(),$),[t,$]);let ot=w.useCallback((e,t,n)=>{if(!n)return;let r=`${qe.current}${n}`.replace(/\r\n|\r/g,`
3
3
  `),i=r.split(`
4
4
  `),o=r.endsWith(`
5
5
  `)?i.join(`
6
6
  `):i.slice(0,-1).join(`
7
7
  `);if(qe.current=r.endsWith(`
8
- `)?``:(i[i.length-1]??``).slice(-1024),!o)return;let s=fe(o);if(!s||Je.current.has(s))return;let c=Ye.current;Je.current.add(s),(a?ie(a,s):pe(s)).then(n=>{if(Je.current.delete(s),!n||Ye.current!==c)return;let r=S.getState().getDirectoryState(e)?.tabs.find(e=>e.id===t);!r||r.previewUrlLocked||r.previewUrl===s||V(e,t,s,{locked:!1,autoOpened:!1})})},[V,a]),st=w.useCallback((n,r,i,a=he,o=!1)=>{if(Fe.current===i)return;$(),Fe.current=i;let s=t.connect(i,{onEvent:a=>{if(Fe.current===i)switch(a.type){case`connected`:Ue.current=i,z(n,r,!1),q(null),J(!1),Y(!1),Ze(),We.current===i&&(We.current=null,t.sendInput(i,`\r`).catch(()=>{}));break;case`reconnecting`:q(null),J(!1),Y(!0);break;case`data`:a.data&&(B(n,r,a.data),ot(n,r,a.data));break;case`exit`:{let t=typeof a.exitCode==`number`?a.exitCode:null,i=typeof a.signal==`number`?a.signal:null,o=!!(S.getState().getDirectoryState(n)?.tabs.find(e=>e.id===r))?.label?.startsWith(`Action:`);B(n,r,e(`terminalView.stream.processExitedMessage`,{exitCodeSegment:t===null?``:e(`terminalView.stream.processExitedWithCode`,{exitCode:t}),signalSegment:i===null?``:e(`terminalView.stream.processExitedWithSignal`,{signal:i})})),R(n,r,`exited`),L(n,r,null),z(n,r,!1),q(o?null:e(`terminalView.error.sessionEnded`)),J(!1),Y(!1),$();break}}},onError:(t,a)=>{if(Fe.current===i){if(!a){q(null),J(!1);return}if(/session not found/i.test(t.message)||o){Y(!1),q(null),J(!1),z(n,r,!0),xe(n,r),R(n,r,`idle`),L(n,r,null),$();return}Y(!1),q(e(`terminalView.error.connectionFailed`,{message:t.message})),J(!0),z(n,r,!1),xe(n,r),R(n,r,`exited`),L(n,r,null),$()}}},a);Pe.current=()=>{s.close(),Fe.current=null}},[B,xe,$,Ze,ot,z,R,L,e,t]);w.useEffect(()=>{let n=!1;if(!(!P||!it)){if(!N){q(e(j?`terminalView.empty.noWorkingDirectory`:`terminalView.empty.selectSession`));return}return(async()=>{let r=N;if(!Re.current||Re.current!==r)return;ve(r);let i=S.getState().getDirectoryState(r);if(!i||i.tabs.length===0)return;let a=O?i.activeTabId??i.tabs[0]?.id??null:i.tabs[0]?.id??null;if(!a)return;let o=i.tabs.find(e=>e.id===a)??i.tabs[0],s=o?.terminalSessionId??null,c=o?.lifecycle??`idle`,l=!!o?.label?.startsWith(`Action:`),u=(o?.bufferLength??0)>0||(o?.bufferChunks?.length??0)>0;if(s)return;if(c===`exited`){z(r,a,!1);return}if(l&&u){z(r,a,!1);return}let d=Be.current;if(!(!d&&He.current)){q(null),J(!1),Y(!1),z(r,a,!0);try{let e=await t.createSession({cwd:M??``,cols:d?.cols,rows:d?.rows});if(!(!n&&Re.current===r&&Ie.current===a)){try{await t.close(e.sessionId)}catch{}return}if(S.getState().getDirectoryState(r)?.tabs.find(e=>e.id===a)?.terminalSessionId){try{await t.close(e.sessionId)}catch{}return}L(r,a,e.sessionId)}catch(t){n||(q(t instanceof Error?t.message:e(`terminalView.error.startSessionFailed`)),J(!0),Y(!1),z(r,a,!1))}}})(),()=>{n=!0}}},[j,N,M,K,Ce,U,it,Me,O,P,ve,z,L,e,t]);let ct=w.useRef(st);ct.current=st;let lt=w.useRef($);lt.current=$,w.useEffect(()=>{if(!P||!it)return;if(!N){lt.current();return}let e=N,t=S.getState().getDirectoryState(e);if(!t||t.tabs.length===0){lt.current();return}let n=O?t.activeTabId??t.tabs[0]?.id??null:t.tabs[0]?.id??null;if(!n){lt.current();return}let r=t.tabs.find(e=>e.id===n)??t.tabs[0],i=r?.terminalSessionId??null;if(!i){lt.current(),Le.current=null;return}if(Fe.current===i&&Pe.current){Le.current=i;return}Le.current=i;let a=Ge.current.has(i),o=a&&(r?.bufferLength??0)===0&&(r?.bufferChunks?.length??0)===0;a&&Ge.current.delete(i),o&&(We.current=i),ct.current(e,n,i,a?ge:he,a)},[N,K,U,O,it,P,t]),w.useEffect(()=>{if(!Q||D)return;if(typeof window>`u`){Ze();return}let e=window.requestAnimationFrame(()=>{Ze()});return()=>{window.cancelAnimationFrame(e)}},[U,Ze,Q,D]);let ut=w.useCallback(async()=>{if(!N||Ae)return;let t=S.getState().getDirectoryState(N),n=O?U??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(n){je(!0),q(null),J(!1),Y(!1),$(),xe(N,n),Xe();try{await I(N,n)}catch(t){q(t instanceof Error?t.message:e(`terminalView.error.restartFailed`)),J(!0),Y(!1)}finally{je(!1)}}},[U,xe,I,$,N,O,Ae,Xe,e]),dt=w.useCallback(async()=>{await ut()},[ut]),ft=w.useCallback(()=>{if(!N)return;let e=ye(N);F(N,e),q(null),J(!1),Y(!1),$()},[ye,$,N,F]),pt=w.useCallback(e=>{N&&(F(N,e),q(null),J(!1),Y(!1),$())},[$,N,F]),mt=w.useCallback(e=>{N&&(e===U&&$(),q(null),J(!1),Y(!1),I(N,e))},[U,I,$,N]),ht=w.useCallback(n=>{if(!n||ke)return;let r=n,i=!1;if(X&&n.length>0){let e=n[0];if(e.length===1&&/[a-zA-Z]/.test(e)){let t=e.toUpperCase();(X===`ctrl`||X===`cmd`)&&(r=String.fromCharCode(t.charCodeAt(0)&31),i=!0)}i||=!0}let a=Le.current;!a||Ue.current!==a||(t.sendInput(a,r).catch(t=>{ke||q(t instanceof Error?t.message:e(`terminalView.error.sendInputFailed`))}),i&&(Z(null),Qe()))},[X,Qe,ke,Z,e,t]),gt=w.useCallback((e,n)=>{let r=Be.current;if((!r||r.cols!==e||r.rows!==n)&&(Be.current={cols:e,rows:n}),Ve.current||(Ve.current=!0,Ne(e=>e+1)),!He.current)return;let i=Le.current;!i||Ue.current!==i||t.resize({sessionId:i,cols:e,rows:n}).catch(()=>{})},[t]),_t=w.useCallback(e=>{Z(t=>t===e?null:e),Qe()},[Qe,Z]),vt=w.useCallback(e=>{let t=_e(e,X);t&&(ht(t),Z(null),Qe())},[X,Qe,ht,Z]);w.useEffect(()=>{if(!ue||!X||!K)return;let e=e=>{if(e.repeat)return;let t=e.key;if(!t||t===`Control`||t===`Meta`||t===`Alt`||t===`Shift`)return;let n=t.length===1?t.toLowerCase():t,r=e.code??``,i=r.startsWith(`Key`)&&r.length===4?r.slice(3).toUpperCase():null,a=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():i,o={Tab:`tab`,Enter:`enter`,ArrowUp:`arrow-up`,ArrowDown:`arrow-down`,ArrowLeft:`arrow-left`,ArrowRight:`arrow-right`,Escape:`esc`,tab:`tab`,enter:`enter`,arrowup:`arrow-up`,arrowdown:`arrow-down`,arrowleft:`arrow-left`,arrowright:`arrow-right`,escape:`esc`};if(n in o){e.preventDefault(),e.stopPropagation(),vt(o[n]);return}if(X===`ctrl`&&a&&a.length===1&&a>=`A`&&a<=`Z`){let t=String.fromCharCode(a.charCodeAt(0)&31);e.preventDefault(),e.stopPropagation(),ht(t),Z(null),Qe()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[X,vt,ht,Qe,ue,Z,K]);let yt=w.useMemo(()=>{let e=s[c].stack;if(typeof window>`u`)return(s[d]??s[`system-mono`]).stack;let t=window.getComputedStyle(document.documentElement).getPropertyValue(`--font-family-mono`);return t&&t.trim().length>0?t.trim():(s[d]??s[`system-mono`]).stack??e},[d]),bt=w.useMemo(()=>oe(o),[o]),xt=w.useMemo(()=>`${N??`no-dir`}::${U??`no-tab`}`,[N,U]);if(w.useEffect(()=>{if(!Q||D)return;let e=ze.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t(),Ze()}),n=[220,400].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[Ze,Q,D,xt,K]),w.useEffect(()=>{if(D||!Q||!et)return;let e=ze.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t()}),n=[0,80,180,320].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[ee,g,et,Q,D]),!j)return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground`,children:e(`terminalView.empty.selectSession`)});if(!N)return(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground`,children:[(0,T.jsx)(`p`,{children:e(`terminalView.empty.noWorkingDirectoryForSession`)}),(0,T.jsx)(p,{onClick:ut,size:`sm`,children:e(`terminalView.actions.retry`)})]});let St=!K||Te||Ae||ke,Ct=it,wt=!E&&et&&!rt,Tt=(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>vt(`esc`),disabled:St,children:e(`terminalView.quickKeys.escape`)}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`tab`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-right`,className:`h-4 w-4`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.tabAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`ctrl`,className:`h-6 w-9 p-0`,onClick:()=>_t(`ctrl`),disabled:St,children:[(0,T.jsx)(`span`,{className:`text-xs font-medium`,children:e(`terminalView.quickKeys.controlLabel`)}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.controlModifierAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`cmd`,className:`h-6 w-9 p-0`,onClick:()=>_t(`cmd`),disabled:St,children:[(0,T.jsx)(_,{name:`command`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.commandModifierAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-up`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-up`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowUpAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-left`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-left`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowLeftAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-down`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-down`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowDownAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-right`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-right`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowRightAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`enter`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-go-back`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.enterAria`)})]})]});return(0,T.jsxs)(`div`,{"data-terminal-view":`true`,className:`flex h-full flex-col overflow-hidden bg-[var(--surface-background)]`,children:[(0,T.jsxs)(`div`,{className:h(`app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs`,E?`px-3 py-1.5`:`pl-3 pr-1.5 py-1`),children:[O&&H?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 pr-1`,children:[(0,T.jsx)(`div`,{className:h(`min-w-0 flex-1`,E?`h-8`:`h-7`),children:(0,T.jsx)(re,{items:G,activeId:U,onSelect:pt,onClose:mt,layoutMode:`scrollable`,variant:`default`,className:`h-full bg-transparent`})}),(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,className:h(`shrink-0`,E?`h-8 w-8 p-0`:`h-7 w-7 p-0`),onClick:ft,title:e(`terminalView.tabs.newTabTitle`),children:(0,T.jsx)(_,{name:`add`,className:`${E?`h-[18px] w-[18px]`:`h-4 w-4`}`})}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-visible`,children:[Ee?(0,T.jsxs)(p,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 shrink-0 gap-1 px-2`,onClick:()=>{N&&Se(N,Ee)},title:e(`terminalView.preview.openTitle`),children:[(0,T.jsx)(_,{name:`global`,className:`h-3.5 w-3.5 shrink-0`}),(0,T.jsx)(`span`,{className:`whitespace-nowrap`,children:e(`terminalView.preview.open`)})]}):null,wt?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>nt(!g),className:h(`shrink-0 p-0`,y?`h-8 w-8`:`h-7 w-7`),title:e(g?`terminalView.bottomDock.restoreTitle`:`terminalView.bottomDock.expandTitle`),"aria-label":e(g?`terminalView.bottomDock.restoreAria`:`terminalView.bottomDock.expandAria`),children:g?(0,T.jsx)(_,{name:`fullscreen-exit`,className:`h-4 w-4`}):(0,T.jsx)(_,{name:`fullscreen`,className:`h-4 w-4`})}),(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>tt(!1),className:h(`shrink-0 p-0`,y?`h-8 w-8`:`h-7 w-7`),title:e(`terminalView.bottomDock.closeTitle`),"aria-label":e(`terminalView.bottomDock.closeAria`),children:(0,T.jsx)(_,{name:`close`,className:`h-4 w-4`})})]}):null]})]}):null,!y&&ue&&O&&H?(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1`,children:Tt}):null,ue&&(y||!O||!H)?(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:Tt}):null]}),(0,T.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,style:{backgroundColor:bt.background},children:[(0,T.jsx)(`div`,{className:`h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4`,children:Ct?(0,T.jsx)(k,{ref:e=>{ze.current=e},sessionKey:xt,chunks:we,onInput:ht,onResize:gt,theme:bt,fontFamily:yt,fontSize:f,enableTouchScroll:D,autoFocus:!D&&Q,isVisible:Q},xt):null}),!ke&&De&&(0,T.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2`,children:[(0,T.jsx)(`span`,{children:De}),Oe&&y&&(0,T.jsx)(p,{size:`sm`,variant:`secondary`,className:`h-6 px-2 py-0 text-xs`,onClick:dt,disabled:Ae,title:e(`terminalView.actions.hardRestartTitle`),type:`button`,children:e(`terminalView.actions.hardRestart`)})]})]})]})};export{ve as TerminalView};
8
+ `)?``:(i[i.length-1]??``).slice(-1024),!o)return;let s=fe(o);if(!s||Je.current.has(s))return;let c=Ye.current;Je.current.add(s),(a?ie(a,s):pe(s)).then(n=>{if(Je.current.delete(s),!n||Ye.current!==c)return;let r=S.getState().getDirectoryState(e)?.tabs.find(e=>e.id===t);!r||r.previewUrlLocked||r.previewUrl===s||V(e,t,s,{locked:!1,autoOpened:!1})})},[V,a]),st=w.useCallback((n,r,i,a=he,o=!1)=>{if(Fe.current===i)return;$(),Fe.current=i;let s=t.connect(i,{onEvent:a=>{if(Fe.current===i)switch(a.type){case`connected`:Ue.current=i,z(n,r,!1),q(null),J(!1),Y(!1),Ze(),We.current===i&&(We.current=null,t.sendInput(i,`\r`).catch(()=>{}));break;case`reconnecting`:q(null),J(!1),Y(!0);break;case`data`:a.data&&(B(n,r,a.data),ot(n,r,a.data));break;case`exit`:{let t=typeof a.exitCode==`number`?a.exitCode:null,i=typeof a.signal==`number`?a.signal:null,o=!!(S.getState().getDirectoryState(n)?.tabs.find(e=>e.id===r))?.label?.startsWith(`Action:`);B(n,r,e(`terminalView.stream.processExitedMessage`,{exitCodeSegment:t===null?``:e(`terminalView.stream.processExitedWithCode`,{exitCode:t}),signalSegment:i===null?``:e(`terminalView.stream.processExitedWithSignal`,{signal:i})})),R(n,r,`exited`),L(n,r,null),z(n,r,!1),q(o?null:e(`terminalView.error.sessionEnded`)),J(!1),Y(!1),$();break}}},onError:(t,a)=>{if(Fe.current===i){if(!a){q(null),J(!1);return}if(/session not found/i.test(t.message)||o){Y(!1),q(null),J(!1),z(n,r,!0),xe(n,r),R(n,r,`idle`),L(n,r,null),$();return}Y(!1),q(e(`terminalView.error.connectionFailed`,{message:t.message})),J(!0),z(n,r,!1),xe(n,r),R(n,r,`exited`),L(n,r,null),$()}}},a);Pe.current=()=>{s.close(),Fe.current=null}},[B,xe,$,Ze,ot,z,R,L,e,t]);w.useEffect(()=>{let n=!1;if(!(!P||!it)){if(!N){q(e(j?`terminalView.empty.noWorkingDirectory`:`terminalView.empty.selectSession`));return}return(async()=>{let r=N;if(!Re.current||Re.current!==r)return;ve(r);let i=S.getState().getDirectoryState(r);if(!i||i.tabs.length===0)return;let a=O?i.activeTabId??i.tabs[0]?.id??null:i.tabs[0]?.id??null;if(!a)return;let o=i.tabs.find(e=>e.id===a)??i.tabs[0],s=o?.terminalSessionId??null,c=o?.lifecycle??`idle`,l=!!o?.label?.startsWith(`Action:`),u=(o?.bufferLength??0)>0||(o?.bufferChunks?.length??0)>0;if(s)return;if(c===`exited`){z(r,a,!1);return}if(l&&u){z(r,a,!1);return}let d=Be.current;if(!(!d&&He.current)){q(null),J(!1),Y(!1),z(r,a,!0);try{let e=await t.createSession({cwd:M??``,cols:d?.cols,rows:d?.rows});if(!(!n&&Re.current===r&&Ie.current===a)){try{await t.close(e.sessionId)}catch{}return}if(S.getState().getDirectoryState(r)?.tabs.find(e=>e.id===a)?.terminalSessionId){try{await t.close(e.sessionId)}catch{}return}L(r,a,e.sessionId)}catch(t){n||(q(t instanceof Error?t.message:e(`terminalView.error.startSessionFailed`)),J(!0),Y(!1),z(r,a,!1))}}})(),()=>{n=!0}}},[j,N,M,K,Ce,U,it,Me,O,P,ve,z,L,e,t]);let ct=w.useRef(st);ct.current=st;let lt=w.useRef($);lt.current=$,w.useEffect(()=>{if(!P||!it)return;if(!N){lt.current();return}let e=N,t=S.getState().getDirectoryState(e);if(!t||t.tabs.length===0){lt.current();return}let n=O?t.activeTabId??t.tabs[0]?.id??null:t.tabs[0]?.id??null;if(!n){lt.current();return}let r=t.tabs.find(e=>e.id===n)??t.tabs[0],i=r?.terminalSessionId??null;if(!i){lt.current(),Le.current=null;return}if(Fe.current===i&&Pe.current){Le.current=i;return}Le.current=i;let a=Ge.current.has(i),o=a&&(r?.bufferLength??0)===0&&(r?.bufferChunks?.length??0)===0;a&&Ge.current.delete(i),o&&(We.current=i),ct.current(e,n,i,a?ge:he,a)},[N,K,U,O,it,P,t]),w.useEffect(()=>{if(!Q||D)return;if(typeof window>`u`){Ze();return}let e=window.requestAnimationFrame(()=>{Ze()});return()=>{window.cancelAnimationFrame(e)}},[U,Ze,Q,D]);let ut=w.useCallback(async()=>{if(!N||Ae)return;let t=S.getState().getDirectoryState(N),n=O?U??t?.activeTabId??t?.tabs[0]?.id??null:t?.tabs[0]?.id??null;if(n){je(!0),q(null),J(!1),Y(!1),$(),xe(N,n),Xe();try{await I(N,n)}catch(t){q(t instanceof Error?t.message:e(`terminalView.error.restartFailed`)),J(!0),Y(!1)}finally{je(!1)}}},[U,xe,I,$,N,O,Ae,Xe,e]),dt=w.useCallback(async()=>{await ut()},[ut]),ft=w.useCallback(()=>{if(!N)return;let e=ye(N);F(N,e),q(null),J(!1),Y(!1),$()},[ye,$,N,F]),pt=w.useCallback(e=>{N&&(F(N,e),q(null),J(!1),Y(!1),$())},[$,N,F]),mt=w.useCallback(e=>{N&&(e===U&&$(),q(null),J(!1),Y(!1),I(N,e))},[U,I,$,N]),ht=w.useCallback(n=>{if(!n||ke)return;let r=n,i=!1;if(X&&n.length>0){let e=n[0];if(e.length===1&&/[a-zA-Z]/.test(e)){let t=e.toUpperCase();(X===`ctrl`||X===`cmd`)&&(r=String.fromCharCode(t.charCodeAt(0)&31),i=!0)}i||=!0}let a=Le.current;!a||Ue.current!==a||(t.sendInput(a,r).catch(t=>{ke||q(t instanceof Error?t.message:e(`terminalView.error.sendInputFailed`))}),i&&(Z(null),Qe()))},[X,Qe,ke,Z,e,t]),gt=w.useCallback((e,n)=>{let r=Be.current;if((!r||r.cols!==e||r.rows!==n)&&(Be.current={cols:e,rows:n}),Ve.current||(Ve.current=!0,Ne(e=>e+1)),!He.current)return;let i=Le.current;!i||Ue.current!==i||t.resize({sessionId:i,cols:e,rows:n}).catch(()=>{})},[t]),_t=w.useCallback(e=>{Z(t=>t===e?null:e),Qe()},[Qe,Z]),vt=w.useCallback(e=>{let t=_e(e,X);t&&(ht(t),Z(null),Qe())},[X,Qe,ht,Z]);w.useEffect(()=>{if(!ue||!X||!K)return;let e=e=>{if(e.repeat)return;let t=e.key;if(!t||t===`Control`||t===`Meta`||t===`Alt`||t===`Shift`)return;let n=t.length===1?t.toLowerCase():t,r=e.code??``,i=r.startsWith(`Key`)&&r.length===4?r.slice(3).toUpperCase():null,a=t.length===1&&/[a-zA-Z]/.test(t)?t.toUpperCase():i,o={Tab:`tab`,Enter:`enter`,ArrowUp:`arrow-up`,ArrowDown:`arrow-down`,ArrowLeft:`arrow-left`,ArrowRight:`arrow-right`,Escape:`esc`,tab:`tab`,enter:`enter`,arrowup:`arrow-up`,arrowdown:`arrow-down`,arrowleft:`arrow-left`,arrowright:`arrow-right`,escape:`esc`};if(n in o){e.preventDefault(),e.stopPropagation(),vt(o[n]);return}if(X===`ctrl`&&a&&a.length===1&&a>=`A`&&a<=`Z`){let t=String.fromCharCode(a.charCodeAt(0)&31);e.preventDefault(),e.stopPropagation(),ht(t),Z(null),Qe()}};return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[X,vt,ht,Qe,ue,Z,K]);let yt=w.useMemo(()=>{let e=s[c].stack;if(typeof window>`u`)return(s[d]??s[`system-mono`]).stack;let t=window.getComputedStyle(document.documentElement).getPropertyValue(`--font-family-mono`);return t&&t.trim().length>0?t.trim():(s[d]??s[`system-mono`]).stack??e},[d]),bt=w.useMemo(()=>oe(o),[o]),xt=w.useMemo(()=>`${N??`no-dir`}::${U??`no-tab`}`,[N,U]);if(w.useEffect(()=>{if(!Q||D)return;let e=ze.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t(),Ze()}),n=[220,400].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[Ze,Q,D,xt,K]),w.useEffect(()=>{if(D||!Q||!et)return;let e=ze.current;if(!e)return;let t=()=>{e.fit()};if(typeof window<`u`){let e=window.requestAnimationFrame(()=>{t()}),n=[0,80,180,320].map(e=>window.setTimeout(t,e));return()=>{window.cancelAnimationFrame(e),n.forEach(e=>window.clearTimeout(e))}}t()},[ee,h,et,Q,D]),!j)return(0,T.jsx)(`div`,{className:`flex h-full items-center justify-center p-4 text-center text-sm text-muted-foreground`,children:e(`terminalView.empty.selectSession`)});if(!N)return(0,T.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-4 text-center text-sm text-muted-foreground`,children:[(0,T.jsx)(`p`,{children:e(`terminalView.empty.noWorkingDirectoryForSession`)}),(0,T.jsx)(p,{onClick:ut,size:`sm`,children:e(`terminalView.actions.retry`)})]});let St=!K||Te||Ae||ke,Ct=it,wt=!E&&et&&!rt,Tt=(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 px-2 text-xs`,onClick:()=>vt(`esc`),disabled:St,children:e(`terminalView.quickKeys.escape`)}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`tab`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-right`,className:`h-4 w-4`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.tabAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`ctrl`,className:`h-6 w-9 p-0`,onClick:()=>_t(`ctrl`),disabled:St,children:[(0,T.jsx)(`span`,{className:`text-xs font-medium`,children:e(`terminalView.quickKeys.controlLabel`)}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.controlModifierAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`chip`,"aria-pressed":X===`cmd`,className:`h-6 w-9 p-0`,onClick:()=>_t(`cmd`),disabled:St,children:[(0,T.jsx)(_,{name:`command`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.commandModifierAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-up`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-up`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowUpAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-left`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-left`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowLeftAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-down`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-down`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowDownAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`arrow-right`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-right`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.arrowRightAria`)})]}),(0,T.jsxs)(p,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 w-9 p-0`,onClick:()=>vt(`enter`),disabled:St,children:[(0,T.jsx)(_,{name:`arrow-go-back`}),(0,T.jsx)(`span`,{className:`sr-only`,children:e(`terminalView.quickKeys.enterAria`)})]})]});return(0,T.jsxs)(`div`,{"data-terminal-view":`true`,className:`flex h-full flex-col overflow-hidden bg-[var(--surface-background)]`,children:[(0,T.jsxs)(`div`,{className:g(`app-region-no-drag sticky top-0 z-20 shrink-0 bg-[var(--surface-background)] text-xs`,E?`px-3 py-1.5`:`pl-3 pr-1.5 py-1`),children:[O&&H?(0,T.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 pr-1`,children:[(0,T.jsx)(`div`,{className:g(`min-w-0 flex-1`,E?`h-8`:`h-7`),children:(0,T.jsx)(re,{items:G,activeId:U,onSelect:pt,onClose:mt,layoutMode:`scrollable`,variant:`default`,className:`h-full bg-transparent`})}),(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,className:g(`shrink-0`,E?`h-8 w-8 p-0`:`h-7 w-7 p-0`),onClick:ft,title:e(`terminalView.tabs.newTabTitle`),children:(0,T.jsx)(_,{name:`add`,className:`${E?`h-[18px] w-[18px]`:`h-4 w-4`}`})}),(0,T.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-visible`,children:[Ee?(0,T.jsxs)(p,{type:`button`,size:`xs`,variant:`outline`,className:`h-6 shrink-0 gap-1 px-2`,onClick:()=>{N&&Se(N,Ee)},title:e(`terminalView.preview.openTitle`),children:[(0,T.jsx)(_,{name:`global`,className:`h-3.5 w-3.5 shrink-0`}),(0,T.jsx)(`span`,{className:`whitespace-nowrap`,children:e(`terminalView.preview.open`)})]}):null,wt?(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>nt(!h),className:g(`shrink-0 p-0`,y?`h-8 w-8`:`h-7 w-7`),title:e(h?`terminalView.bottomDock.restoreTitle`:`terminalView.bottomDock.expandTitle`),"aria-label":e(h?`terminalView.bottomDock.restoreAria`:`terminalView.bottomDock.expandAria`),children:h?(0,T.jsx)(_,{name:`fullscreen-exit`,className:`h-4 w-4`}):(0,T.jsx)(_,{name:`fullscreen`,className:`h-4 w-4`})}),(0,T.jsx)(p,{type:`button`,size:`xs`,variant:`ghost`,onClick:()=>tt(!1),className:g(`shrink-0 p-0`,y?`h-8 w-8`:`h-7 w-7`),title:e(`terminalView.bottomDock.closeTitle`),"aria-label":e(`terminalView.bottomDock.closeAria`),children:(0,T.jsx)(_,{name:`close`,className:`h-4 w-4`})})]}):null]})]}):null,!y&&ue&&O&&H?(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1 pl-1 pr-1`,children:Tt}):null,ue&&(y||!O||!H)?(0,T.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:Tt}):null]}),(0,T.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,style:{backgroundColor:bt.background},children:[(0,T.jsx)(`div`,{className:`h-full w-full box-border pl-4 pr-1.5 pt-3 pb-4`,children:Ct?(0,T.jsx)(k,{ref:e=>{ze.current=e},sessionKey:xt,chunks:we,onInput:ht,onResize:gt,theme:bt,fontFamily:yt,fontSize:f,enableTouchScroll:D,autoFocus:!D&&Q,isVisible:Q},xt):null}),!ke&&De&&(0,T.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 bg-[var(--status-error-background)] px-3 py-2 text-xs text-[var(--status-error-foreground)] flex items-center justify-between gap-2`,children:[(0,T.jsx)(`span`,{children:De}),Oe&&y&&(0,T.jsx)(p,{size:`sm`,variant:`secondary`,className:`h-6 px-2 py-0 text-xs`,onClick:dt,disabled:Ae,title:e(`terminalView.actions.hardRestartTitle`),type:`button`,children:e(`terminalView.actions.hardRestart`)})]})]})]})};export{ve as TerminalView};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./platform-CNdx57HN.js";import{a as n}from"./vendor-zustand-CTekDqaS.js";import{it as r,ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{E as o}from"./runtime-file-resource-DKJJoOOc.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-P32bzAJc.js";import{Yn as ee,co as d,f,jt as p,no as te}from"./ui-CU6n15y3.js";import{t as ne}from"./i18n-WsU03nwB.js";import{n as re}from"./useEffectiveDirectory-DNVTRp-B.js";import{s as m}from"./mobileBackNavigation-Ch0aK3t9.js";import{i as h,n as g}from"./shortcuts-BOzfBNF8.js";import{a as ie,c as _,l as v,s as ae,u as oe}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as se}from"./useSessionBtwStore-DAQVlbuf.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover--wSR2Iru.js";var x=e(a(),1),S=e(r(),1),C=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},w=n(e=>({quotesByKey:{},addQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t]??_,i=v(r,n);return i===r?e:{quotesByKey:{...e.quotesByKey,[t]:i}}}),removeQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t];if(!r||n<0||n>=r.length)return e;let i=r.filter((e,t)=>t!==n);return{quotesByKey:i.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:i}}}),removeLast:t=>e(e=>{let n=e.quotesByKey[t];if(!n||n.length===0)return e;let r=n.slice(0,-1);return{quotesByKey:r.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:r}}}),clear:t=>e(e=>({quotesByKey:C(e.quotesByKey,t)})),restore:(t,n)=>e(e=>n.length===0?{quotesByKey:C(e.quotesByKey,t)}:{quotesByKey:{...e.quotesByKey,[t]:n}})})),T=e=>t=>e?t.quotesByKey[e]??_:_,E=()=>{typeof window>`u`||window.requestAnimationFrame(()=>{document.querySelector(`[data-btw-composer] textarea`)?.focus()})},D=e=>{let t=e.directory??null;p({sessionId:e.sessionId,directory:t})?y(b):u.getState().openContextPanelTab(t??``,{mode:`btw`}),E()},O=e=>{let t=Number.isFinite(e.cssInsetPx)?Math.max(0,e.cssInsetPx):0,n=e.visualHeight,r=n==null||!Number.isFinite(n)?0:Math.max(0,e.innerHeight-n-(e.visualOffsetTop??0));return Math.max(t,r)},k=e=>{let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.max(0,t):0},A=48,j=88,M=e=>{let t=e.composer;if(t&&t.height>=A&&t.width>=A)return{left:t.left,top:t.top,width:t.width,height:t.height};let n=e.nativeComposerHeightPx>=A?e.nativeComposerHeightPx:e.lastHeightPx>=A?e.lastHeightPx:j,r=Math.max(0,e.keyboardOverlapPx);return{left:0,top:Math.max(0,e.viewportHeight-r-n),width:Math.max(0,e.viewportWidth),height:n}},N=i(),P=8,F=`mod+l`,I=`mod+shift+s`,L=[`⌃`,`⌥`,`⇧`,`⌘`],ue=e=>{let t=h(e).split(` + `);if(!d())return t.join(`+`);let n=t[t.length-1];return[...t.slice(0,-1).sort((e,t)=>L.indexOf(e)-L.indexOf(t)),n].join(``)},de=280,R=()=>{if(typeof document>`u`)return null;let e=null;for(let t of document.querySelectorAll(`.yuri-mobile-composer`)){let n=window.getComputedStyle(t);if(n.display===`none`||n.visibility===`hidden`)continue;let r=t.getBoundingClientRect();r.height<48||r.width<48||r.bottom<0||r.top>window.innerHeight||(!e||r.bottom>e.top+e.height)&&(e={left:r.left,top:r.top,width:r.width,height:r.height})}return e},fe=e=>{let t=document.documentElement,n=window.visualViewport;return M({composer:R(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,keyboardOverlapPx:O({cssInsetPx:k(t.style.getPropertyValue(`--yuri-keyboard-inset`)),innerHeight:window.innerHeight,visualHeight:n?.height,visualOffsetTop:n?.offsetTop}),nativeComposerHeightPx:k(t.style.getPropertyValue(m)),lastHeightPx:e})},z=null;l(()=>{typeof window<`u`&&!document.activeElement?.matches(`textarea[data-chat-input="true"]`)&&window.getSelection()?.removeAllRanges(),z?.()});var B=new Set(`address.article.aside.blockquote.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.ul`.split(`.`)),V=e=>e.replace(/\r\n?/g,`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./platform-B2ylz14u.js";import{a as n}from"./vendor-zustand-CTekDqaS.js";import{it as r,ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{E as o}from"./runtime-file-resource-9kLrAtnQ.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-68ZPpgYA.js";import{Yn as ee,f as d,jt as f,lo as p,ro as te}from"./ui-BwSpLYDL.js";import{t as ne}from"./i18n-CYty_Jft.js";import{n as re}from"./useEffectiveDirectory-DeoADFfu.js";import{s as m}from"./mobileBackNavigation-CX_MC0oM.js";import{i as h,n as g}from"./shortcuts-CiFlt2ws.js";import{a as ie,c as _,l as v,s as ae,u as oe}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as se}from"./useSessionBtwStore-DD2dFcs5.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover-Cyi4eoBm.js";var x=e(a(),1),S=e(r(),1),C=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},w=n(e=>({quotesByKey:{},addQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t]??_,i=v(r,n);return i===r?e:{quotesByKey:{...e.quotesByKey,[t]:i}}}),removeQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t];if(!r||n<0||n>=r.length)return e;let i=r.filter((e,t)=>t!==n);return{quotesByKey:i.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:i}}}),removeLast:t=>e(e=>{let n=e.quotesByKey[t];if(!n||n.length===0)return e;let r=n.slice(0,-1);return{quotesByKey:r.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:r}}}),clear:t=>e(e=>({quotesByKey:C(e.quotesByKey,t)})),restore:(t,n)=>e(e=>n.length===0?{quotesByKey:C(e.quotesByKey,t)}:{quotesByKey:{...e.quotesByKey,[t]:n}})})),T=e=>t=>e?t.quotesByKey[e]??_:_,E=()=>{typeof window>`u`||window.requestAnimationFrame(()=>{document.querySelector(`[data-btw-composer] textarea`)?.focus()})},D=e=>{let t=e.directory??null;f({sessionId:e.sessionId,directory:t})?y(b):u.getState().openContextPanelTab(t??``,{mode:`btw`}),E()},O=e=>{let t=Number.isFinite(e.cssInsetPx)?Math.max(0,e.cssInsetPx):0,n=e.visualHeight,r=n==null||!Number.isFinite(n)?0:Math.max(0,e.innerHeight-n-(e.visualOffsetTop??0));return Math.max(t,r)},k=e=>{let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.max(0,t):0},A=48,j=88,M=e=>{let t=e.composer;if(t&&t.height>=A&&t.width>=A)return{left:t.left,top:t.top,width:t.width,height:t.height};let n=e.nativeComposerHeightPx>=A?e.nativeComposerHeightPx:e.lastHeightPx>=A?e.lastHeightPx:j,r=Math.max(0,e.keyboardOverlapPx);return{left:0,top:Math.max(0,e.viewportHeight-r-n),width:Math.max(0,e.viewportWidth),height:n}},N=i(),P=8,F=`mod+l`,I=`mod+shift+s`,L=[`⌃`,`⌥`,`⇧`,`⌘`],ue=e=>{let t=h(e).split(` + `);if(!p())return t.join(`+`);let n=t[t.length-1];return[...t.slice(0,-1).sort((e,t)=>L.indexOf(e)-L.indexOf(t)),n].join(``)},de=280,R=()=>{if(typeof document>`u`)return null;let e=null;for(let t of document.querySelectorAll(`.yuri-mobile-composer`)){let n=window.getComputedStyle(t);if(n.display===`none`||n.visibility===`hidden`)continue;let r=t.getBoundingClientRect();r.height<48||r.width<48||r.bottom<0||r.top>window.innerHeight||(!e||r.bottom>e.top+e.height)&&(e={left:r.left,top:r.top,width:r.width,height:r.height})}return e},fe=e=>{let t=document.documentElement,n=window.visualViewport;return M({composer:R(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,keyboardOverlapPx:O({cssInsetPx:k(t.style.getPropertyValue(`--yuri-keyboard-inset`)),innerHeight:window.innerHeight,visualHeight:n?.height,visualOffsetTop:n?.offsetTop}),nativeComposerHeightPx:k(t.style.getPropertyValue(m)),lastHeightPx:e})},z=null;l(()=>{typeof window<`u`&&!document.activeElement?.matches(`textarea[data-chat-input="true"]`)&&window.getSelection()?.removeAllRanges(),z?.()});var B=new Set(`address.article.aside.blockquote.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.ul`.split(`.`)),V=e=>e.replace(/\r\n?/g,`
2
2
  `),H=e=>V(e).trim(),U=(e,t)=>{if(e.contains(t))return!0;let n=t instanceof ShadowRoot?t:t.getRootNode();return n instanceof ShadowRoot&&e.contains(n.host)},W=e=>{let t=[],n=e=>{for(let r of e.querySelectorAll(`*`))r.shadowRoot&&(t.push(r.shadowRoot),n(r.shadowRoot))};return n(e),t},G=(e,t)=>{let n=W(t),r=e.getComposedRanges?.({shadowRoots:n})[0];if(r){let e=document.createRange();if(e.setStart(r.startContainer,r.startOffset),e.setEnd(r.endContainer,r.endOffset),U(t,e.commonAncestorContainer))return e}if(e.rangeCount===0)return null;let i=e.getRangeAt(0);return U(t,i.commonAncestorContainer)?i:null},K=e=>e.replace(/\s+/g,` `).trim(),q=e=>{if(e.nodeType===Node.TEXT_NODE)return K(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e,n=t.tagName.toLowerCase(),r=Array.from(t.childNodes).map(e=>q(e)).join(``).replace(/\s+/g,` `).trim();if(!r&&n!==`br`)return``;if(n===`br`)return`
3
3
  `;if(n===`strong`||n===`b`)return`**${r}**`;if(n===`em`||n===`i`)return`*${r}*`;if(n===`code`)return`\`${r.replace(/`/g,"\\`")}\``;if(n===`a`){let e=t.getAttribute(`href`);return e?`[${r}](${e})`:r}return r},J=(e,t)=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.tagName.toLowerCase()===`li`).map((e,n)=>{let r=t?`${n+1}. `:`- `,i=Array.from(e.childNodes).map(e=>q(e)).join(``).replace(/\s+/g,` `).trim();return i?`${r}${i}`:``}).filter(Boolean).join(`
4
4
  `),Y=e=>{if(e.nodeType===Node.TEXT_NODE)return H(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e,n=t.tagName.toLowerCase();if(n===`pre`){let e=t.querySelector(`code`);return`\`\`\`${((e?.className||``).match(/language-([\w-]+)/)?.[1]||``).trim()}\n${V(e?.textContent||t.textContent||``).replace(/\n$/,``)}\n\`\`\``}if(n===`code`){let e=V(t.textContent||``).trim();return e?`\`${e.replace(/`/g,"\\`")}\``:``}if(n===`ul`)return J(t,!1);if(n===`ol`)return J(t,!0);if(n===`blockquote`)return H(Array.from(t.childNodes).map(e=>Y(e)).join(`
@@ -8,4 +8,4 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./platform
8
8
 
9
9
  `):H(Array.from(t.childNodes).map(e=>q(e)).join(``))},X=e=>Array.from(e.childNodes).every(e=>{if(e.nodeType===Node.TEXT_NODE||e.nodeType!==Node.ELEMENT_NODE)return!0;let t=e;return!B.has(t.tagName.toLowerCase())}),Z=(e,t)=>{let n=e.cloneContents();if(X(n)){let e=H(Array.from(n.childNodes).map(e=>q(e)).join(``));if(e)return e}return Array.from(n.childNodes).map(e=>Y(e)).filter(e=>e.length>0).join(`
10
10
 
11
- `).trim()||H(t)},Q=({containerRef:e})=>{let{t:n}=ne(),[r,i]=x.useState({x:0,y:0,show:!1}),[a,l]=x.useState(``),d=x.useRef(!1),[p,m]=x.useState(!1),h=x.useRef(null),_=x.useRef(de),v=x.useRef(null),y=x.useRef(null),b=x.useRef(null),C=x.useRef(!1),T=x.useRef(0),[E,O]=x.useState(null),k=f(e=>e.currentSessionId),A=re()??null,j=u(e=>e.isMobile),M=ae(),L=o(),R=L?.entry.location.hostId?L.entry:void 0,B=R?M.sessionId:k,V=ie(M).textSelectionMutation,U=M.kind===`primary`&&!!B;x.useEffect(()=>{C.current=r.show},[r.show]);let K=x.useCallback(()=>{v.current=null,z===K&&(z=null),b.current!==null&&(window.clearTimeout(b.current),b.current=null),y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null),C.current&&=(m(!1),i(e=>({...e,show:!1})),l(``),!1)},[]);x.useLayoutEffect(()=>K,[K]);let q=x.useCallback(e=>{if(typeof window>`u`)return e;let t=window.innerWidth,n=_.current/2,r=P+n,i=t-P-n;return r>i?t/2:Math.min(Math.max(e,r),i)},[]),J=x.useCallback(()=>{if(!v.current)return;z!==K&&(z?.(),z=K);let{markdownText:e,rect:t}=v.current,n=!r.show,a=j?t.left+t.width/2:q(t.left+t.width/2),o=t.top-10;l(e),i({x:a,y:o,show:!0}),C.current=!0,n&&(m(!0),y.current!==null&&window.cancelAnimationFrame(y.current),y.current=window.requestAnimationFrame(()=>{m(!1),y.current=null}))},[q,K,j,r.show]);x.useLayoutEffect(()=>{if(!r.show||j||!h.current)return;let e=h.current.offsetWidth;!Number.isFinite(e)||e<=0||e===_.current||(_.current=e,i(e=>({...e,x:q(e.x)})))},[q,j,r.show]),x.useEffect(()=>{if(!r.show||j)return;let e=()=>{i(e=>({...e,x:q(e.x)}))};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[q,j,r.show]);let Y=x.useCallback(()=>{let t=window.getSelection(),n=e.current;if(!t||!n){d.current||K();return}let r=H(t.toString());if(!r){d.current||K();return}let i=G(t,n);if(!i){d.current||K();return}let a=i.getBoundingClientRect();v.current={plainText:r,markdownText:Z(i,r),rect:a},d.current||J()},[e,K,J]);x.useEffect(()=>{let t=e.current;if(!t)return;let n=()=>{d.current=!0,K()},r=()=>{d.current=!1,b.current!==null&&window.clearTimeout(b.current);let e=c();b.current=window.setTimeout(()=>{b.current=null,c()===e&&Y()},10)},i=new Set,a=()=>{for(let e of W(t))i.has(e)||(i.add(e),e.addEventListener(`selectionchange`,Y))};a();let o=new MutationObserver(a);o.observe(t,{childList:!0,subtree:!0}),document.addEventListener(`selectionchange`,Y),t.addEventListener(`mousedown`,n),document.addEventListener(`mouseup`,r);let s=e=>{h.current&&!h.current.contains(e.target)&&!window.getSelection()?.toString().trim()&&K()};return document.addEventListener(`mousedown`,s),()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null),o.disconnect();for(let e of i)e.removeEventListener(`selectionchange`,Y);document.removeEventListener(`selectionchange`,Y),t.removeEventListener(`mousedown`,n),document.removeEventListener(`mouseup`,r),document.removeEventListener(`mousedown`,s)}},[e,Y,K,J]),x.useLayoutEffect(()=>{if(!j||!r.show){T.current=0,O(null);return}let e=ce(le),t=0,n=0,i=()=>{let e=fe(T.current);T.current=e.height,O(t=>t&&t.left===e.left&&t.top===e.top&&t.width===e.width&&t.height===e.height?t:e)},a=e=>{i(),e<n&&(t=window.requestAnimationFrame(a))},o=()=>{n=performance.now()+320,window.cancelAnimationFrame(t),t=window.requestAnimationFrame(a)};i(),o();let s=window.visualViewport;return s?.addEventListener(`resize`,o),s?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o),window.addEventListener(`yuri:keyboard-anim`,o),window.addEventListener(`yuri:keyboard-settled`,o),()=>{window.cancelAnimationFrame(t),s?.removeEventListener(`resize`,o),s?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),window.removeEventListener(`yuri:keyboard-anim`,o),window.removeEventListener(`yuri:keyboard-settled`,o),e()}},[j,r.show]),x.useEffect(()=>{if(!r.show)return;let e=e=>{h.current&&e.target instanceof Node&&h.current.contains(e.target)||K()};return window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>{window.removeEventListener(`scroll`,e,!0)}},[r.show,K]);let X=()=>{K(),window.getSelection()?.removeAllRanges()},Q=s(e=>{if(!e)return;let n=f.getState().newSessionDraft.draftID,r=oe(R&&B?t(R.location,B):B,n);r&&(w.getState().addQuote(r,e),X(),requestAnimationFrame(()=>{Array.from(document.querySelectorAll(`textarea[data-chat-input="true"]`)).find(e=>!e.disabled&&e.getClientRects().length>0&&!e.closest(`[data-btw-composer]`))?.focus({preventScroll:!0})}))}),$=s(e=>{if(!e||!B)return;let t={sessionId:B,directory:R?.location.directory??A,host:R};se.getState().addQuote(t,e),X(),D(t)});if(x.useEffect(()=>{if(!V)return;let t=t=>{let n=g(t,F),r=U&&g(t,I);if(!n&&!r)return;let i=window.getSelection(),a=e.current;if(!i||!a||!i.toString().trim())return;let o=G(i,a);if(!o)return;t.preventDefault(),t.stopPropagation();let s=Z(o,i.toString());n?Q(s):$(s)};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[Q,$,U,V,e]),!r.show||!V)return null;let pe=[{id:`chat`,label:n(`chat.textSelection.actions.addToChat`),shortcut:F,run:()=>Q(a)},...U?[{id:`side`,label:n(`chat.textSelection.actions.addToSideChat`),shortcut:I,run:()=>$(a)}]:[]];if(j){let e=E??{left:0,top:Math.max(0,window.innerHeight-88),width:window.innerWidth,height:88};return(0,S.createPortal)((0,N.jsx)(`div`,{ref:h,"data-text-selection-menu":!0,className:te(`fixed z-50 flex items-center justify-center gap-2 bg-background px-4`,`transition-opacity duration-200 ease-out`,p?`opacity-0`:`opacity-100`),style:{left:e.left,top:e.top,width:e.width,height:e.height,paddingBottom:`max(0.75rem, var(--yuri-safe-area-bottom-visual, env(safe-area-inset-bottom, 0px)))`},onPointerDown:e=>{e.preventDefault()},children:pe.map(e=>(0,N.jsx)(ee,{type:`button`,variant:`secondary`,size:`sm`,onClick:e.run,className:`max-w-[11rem] min-w-0`,children:(0,N.jsx)(`span`,{className:`truncate`,children:e.label})},e.id))}),document.body)}return(0,S.createPortal)((0,N.jsx)(`div`,{ref:h,"data-text-selection-menu":!0,className:`fixed z-50`,style:{left:r.x,top:r.y,transform:`translate(-50%, -100%)`},children:(0,N.jsx)(`div`,{className:te(`flex items-center gap-0.5 whitespace-nowrap rounded-lg p-0.5`,`border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-sm`,`transition-[opacity,transform] duration-200 ease-out will-change-[opacity,transform]`,p?`opacity-0 translate-y-[4px]`:`opacity-100 translate-y-0`),children:pe.map((e,t)=>(0,N.jsxs)(x.Fragment,{children:[t>0?(0,N.jsx)(`div`,{className:`h-3 w-px shrink-0 bg-[var(--interactive-border)]`}):null,(0,N.jsxs)(`button`,{type:`button`,onClick:e.run,className:`flex h-6 items-center gap-1.5 rounded-md px-2 typography-meta text-[var(--surface-foreground)] transition-colors duration-150 hover:bg-[var(--interactive-hover)]`,children:[(0,N.jsx)(`span`,{children:e.label}),(0,N.jsx)(`span`,{className:`tracking-[0.08em] text-[var(--surface-muted-foreground)]`,"aria-hidden":`true`,children:ue(e.shortcut)})]})]},e.id))})}),document.body)};export{w as i,D as n,T as r,Q as t};
11
+ `).trim()||H(t)},Q=({containerRef:e})=>{let{t:n}=ne(),[r,i]=x.useState({x:0,y:0,show:!1}),[a,l]=x.useState(``),f=x.useRef(!1),[p,m]=x.useState(!1),h=x.useRef(null),_=x.useRef(de),v=x.useRef(null),y=x.useRef(null),b=x.useRef(null),C=x.useRef(!1),T=x.useRef(0),[E,O]=x.useState(null),k=d(e=>e.currentSessionId),A=re()??null,j=u(e=>e.isMobile),M=ae(),L=o(),R=L?.entry.location.hostId?L.entry:void 0,B=R?M.sessionId:k,V=ie(M).textSelectionMutation,U=M.kind===`primary`&&!!B;x.useEffect(()=>{C.current=r.show},[r.show]);let K=x.useCallback(()=>{v.current=null,z===K&&(z=null),b.current!==null&&(window.clearTimeout(b.current),b.current=null),y.current!==null&&(window.cancelAnimationFrame(y.current),y.current=null),C.current&&=(m(!1),i(e=>({...e,show:!1})),l(``),!1)},[]);x.useLayoutEffect(()=>K,[K]);let q=x.useCallback(e=>{if(typeof window>`u`)return e;let t=window.innerWidth,n=_.current/2,r=P+n,i=t-P-n;return r>i?t/2:Math.min(Math.max(e,r),i)},[]),J=x.useCallback(()=>{if(!v.current)return;z!==K&&(z?.(),z=K);let{markdownText:e,rect:t}=v.current,n=!r.show,a=j?t.left+t.width/2:q(t.left+t.width/2),o=t.top-10;l(e),i({x:a,y:o,show:!0}),C.current=!0,n&&(m(!0),y.current!==null&&window.cancelAnimationFrame(y.current),y.current=window.requestAnimationFrame(()=>{m(!1),y.current=null}))},[q,K,j,r.show]);x.useLayoutEffect(()=>{if(!r.show||j||!h.current)return;let e=h.current.offsetWidth;!Number.isFinite(e)||e<=0||e===_.current||(_.current=e,i(e=>({...e,x:q(e.x)})))},[q,j,r.show]),x.useEffect(()=>{if(!r.show||j)return;let e=()=>{i(e=>({...e,x:q(e.x)}))};return window.addEventListener(`resize`,e),()=>{window.removeEventListener(`resize`,e)}},[q,j,r.show]);let Y=x.useCallback(()=>{let t=window.getSelection(),n=e.current;if(!t||!n){f.current||K();return}let r=H(t.toString());if(!r){f.current||K();return}let i=G(t,n);if(!i){f.current||K();return}let a=i.getBoundingClientRect();v.current={plainText:r,markdownText:Z(i,r),rect:a},f.current||J()},[e,K,J]);x.useEffect(()=>{let t=e.current;if(!t)return;let n=()=>{f.current=!0,K()},r=()=>{f.current=!1,b.current!==null&&window.clearTimeout(b.current);let e=c();b.current=window.setTimeout(()=>{b.current=null,c()===e&&Y()},10)},i=new Set,a=()=>{for(let e of W(t))i.has(e)||(i.add(e),e.addEventListener(`selectionchange`,Y))};a();let o=new MutationObserver(a);o.observe(t,{childList:!0,subtree:!0}),document.addEventListener(`selectionchange`,Y),t.addEventListener(`mousedown`,n),document.addEventListener(`mouseup`,r);let s=e=>{h.current&&!h.current.contains(e.target)&&!window.getSelection()?.toString().trim()&&K()};return document.addEventListener(`mousedown`,s),()=>{b.current!==null&&(window.clearTimeout(b.current),b.current=null),o.disconnect();for(let e of i)e.removeEventListener(`selectionchange`,Y);document.removeEventListener(`selectionchange`,Y),t.removeEventListener(`mousedown`,n),document.removeEventListener(`mouseup`,r),document.removeEventListener(`mousedown`,s)}},[e,Y,K,J]),x.useLayoutEffect(()=>{if(!j||!r.show){T.current=0,O(null);return}let e=ce(le),t=0,n=0,i=()=>{let e=fe(T.current);T.current=e.height,O(t=>t&&t.left===e.left&&t.top===e.top&&t.width===e.width&&t.height===e.height?t:e)},a=e=>{i(),e<n&&(t=window.requestAnimationFrame(a))},o=()=>{n=performance.now()+320,window.cancelAnimationFrame(t),t=window.requestAnimationFrame(a)};i(),o();let s=window.visualViewport;return s?.addEventListener(`resize`,o),s?.addEventListener(`scroll`,o),window.addEventListener(`resize`,o),window.addEventListener(`yuri:keyboard-anim`,o),window.addEventListener(`yuri:keyboard-settled`,o),()=>{window.cancelAnimationFrame(t),s?.removeEventListener(`resize`,o),s?.removeEventListener(`scroll`,o),window.removeEventListener(`resize`,o),window.removeEventListener(`yuri:keyboard-anim`,o),window.removeEventListener(`yuri:keyboard-settled`,o),e()}},[j,r.show]),x.useEffect(()=>{if(!r.show)return;let e=e=>{h.current&&e.target instanceof Node&&h.current.contains(e.target)||K()};return window.addEventListener(`scroll`,e,{capture:!0,passive:!0}),()=>{window.removeEventListener(`scroll`,e,!0)}},[r.show,K]);let X=()=>{K(),window.getSelection()?.removeAllRanges()},Q=s(e=>{if(!e)return;let n=d.getState().newSessionDraft.draftID,r=oe(R&&B?t(R.location,B):B,n);r&&(w.getState().addQuote(r,e),X(),requestAnimationFrame(()=>{Array.from(document.querySelectorAll(`textarea[data-chat-input="true"]`)).find(e=>!e.disabled&&e.getClientRects().length>0&&!e.closest(`[data-btw-composer]`))?.focus({preventScroll:!0})}))}),$=s(e=>{if(!e||!B)return;let t={sessionId:B,directory:R?.location.directory??A,host:R};se.getState().addQuote(t,e),X(),D(t)});if(x.useEffect(()=>{if(!V)return;let t=t=>{let n=g(t,F),r=U&&g(t,I);if(!n&&!r)return;let i=window.getSelection(),a=e.current;if(!i||!a||!i.toString().trim())return;let o=G(i,a);if(!o)return;t.preventDefault(),t.stopPropagation();let s=Z(o,i.toString());n?Q(s):$(s)};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[Q,$,U,V,e]),!r.show||!V)return null;let pe=[{id:`chat`,label:n(`chat.textSelection.actions.addToChat`),shortcut:F,run:()=>Q(a)},...U?[{id:`side`,label:n(`chat.textSelection.actions.addToSideChat`),shortcut:I,run:()=>$(a)}]:[]];if(j){let e=E??{left:0,top:Math.max(0,window.innerHeight-88),width:window.innerWidth,height:88};return(0,S.createPortal)((0,N.jsx)(`div`,{ref:h,"data-text-selection-menu":!0,className:te(`fixed z-50 flex items-center justify-center gap-2 bg-background px-4`,`transition-opacity duration-200 ease-out`,p?`opacity-0`:`opacity-100`),style:{left:e.left,top:e.top,width:e.width,height:e.height,paddingBottom:`max(0.75rem, var(--yuri-safe-area-bottom-visual, env(safe-area-inset-bottom, 0px)))`},onPointerDown:e=>{e.preventDefault()},children:pe.map(e=>(0,N.jsx)(ee,{type:`button`,variant:`secondary`,size:`sm`,onClick:e.run,className:`max-w-[11rem] min-w-0`,children:(0,N.jsx)(`span`,{className:`truncate`,children:e.label})},e.id))}),document.body)}return(0,S.createPortal)((0,N.jsx)(`div`,{ref:h,"data-text-selection-menu":!0,className:`fixed z-50`,style:{left:r.x,top:r.y,transform:`translate(-50%, -100%)`},children:(0,N.jsx)(`div`,{className:te(`flex items-center gap-0.5 whitespace-nowrap rounded-lg p-0.5`,`border border-[var(--interactive-border)] bg-[var(--surface-elevated)] shadow-sm`,`transition-[opacity,transform] duration-200 ease-out will-change-[opacity,transform]`,p?`opacity-0 translate-y-[4px]`:`opacity-100 translate-y-0`),children:pe.map((e,t)=>(0,N.jsxs)(x.Fragment,{children:[t>0?(0,N.jsx)(`div`,{className:`h-3 w-px shrink-0 bg-[var(--interactive-border)]`}):null,(0,N.jsxs)(`button`,{type:`button`,onClick:e.run,className:`flex h-6 items-center gap-1.5 rounded-md px-2 typography-meta text-[var(--surface-foreground)] transition-colors duration-150 hover:bg-[var(--interactive-hover)]`,children:[(0,N.jsx)(`span`,{children:e.label}),(0,N.jsx)(`span`,{className:`tracking-[0.08em] text-[var(--surface-muted-foreground)]`,"aria-hidden":`true`,children:ue(e.shortcut)})]})]},e.id))})}),document.body)};export{w as i,D as n,T as r,Q as t};