@aiworker/web 1.22.0 → 1.23.0

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 (415) hide show
  1. package/README.md +4 -4
  2. package/bin/cli.js +14 -4
  3. package/bin/cli.test.js +165 -73
  4. package/bin/lib/cli-api-target.js +2 -2
  5. package/bin/lib/cli-args.js +119 -119
  6. package/bin/lib/cli-lifecycle.js +9 -9
  7. package/bin/lib/cli-network.js +3 -3
  8. package/bin/lib/cli-paths.js +3 -3
  9. package/bin/lib/cli-ports.js +2 -2
  10. package/bin/lib/cli-process.js +4 -4
  11. package/bin/lib/cli-startup.js +64 -15
  12. package/bin/lib/cli-tunnel-profiles.js +1 -1
  13. package/bin/lib/cli-tunnel-utils.js +2 -2
  14. package/bin/lib/commands-connect-url.js +19 -19
  15. package/bin/lib/commands-lifecycle.js +27 -27
  16. package/bin/lib/commands-logs.js +5 -5
  17. package/bin/lib/commands-models.js +1 -1
  18. package/bin/lib/commands-projects.js +1 -1
  19. package/bin/lib/commands-schedule.js +1 -1
  20. package/bin/lib/commands-serve.js +29 -29
  21. package/bin/lib/commands-session.js +1 -1
  22. package/bin/lib/commands-startup.js +45 -10
  23. package/bin/lib/commands-status.js +1 -1
  24. package/bin/lib/commands-tunnel.js +40 -40
  25. package/bin/lib/commands-update.js +1 -1
  26. package/bin/lib/commands-update.test.js +6 -6
  27. package/dist/assets/{CodeMirrorCommentWidgets-B3u7UIcE.js → CodeMirrorCommentWidgets-B1Gizi3a.js} +1 -1
  28. package/dist/assets/DiffView-DXjVsEOw.js +4 -0
  29. package/dist/assets/DirtyBranchSwitchDialog-aig6zJjg.js +1 -0
  30. package/dist/assets/FilesView-CJdG0-wk.js +17 -0
  31. package/dist/assets/GitView-BXsS3jG6.js +6 -0
  32. package/dist/assets/{JsonTreeView-B0BdZEHG.js → JsonTreeView-D_hpXBnF.js} +1 -1
  33. package/dist/assets/LinearIssuesView-BoUiLQG1.js +1 -0
  34. package/dist/assets/MarkdownImageGallery-B_B_a9KS.js +1 -0
  35. package/dist/assets/MarkdownRendererImpl-xgyyLiBM.js +12 -0
  36. package/dist/assets/OnboardingScreen-DIp84OWt.js +1 -0
  37. package/dist/assets/{PatchDiff-DvfqDql7.js → PatchDiff-8p6nLJaU.js} +1 -1
  38. package/dist/assets/PierreDiffViewer-DjC8nTk9.js +161 -0
  39. package/dist/assets/PlanView-CJTmOF6I.js +5 -0
  40. package/dist/assets/SettingsView-DD-JqIJx.js +28 -0
  41. package/dist/assets/{SettingsWindow-i45U1Cy1.js → SettingsWindow-Cpb4hM6q.js} +1 -1
  42. package/dist/assets/SymbolsNerdFontMono-Regular-aK5vsLov.woff2 +0 -0
  43. package/dist/assets/{ToolOutputDialog-BTwyh5OF.js → ToolOutputDialog-DfaKZXNU.js} +6 -6
  44. package/dist/assets/ToolPartDiffPreview-DtZLzrSK.js +8 -0
  45. package/dist/assets/{VirtualizedFileDiff-DD8lDVej.js → VirtualizedFileDiff-C8i9HpTB.js} +1 -1
  46. package/dist/assets/WalkthroughView-DeKMvZlL.js +4 -0
  47. package/dist/assets/{computeVirtualFileMetrics-BMIRgMHv.js → computeVirtualFileMetrics-BBI7ZwrC.js} +2 -2
  48. package/dist/assets/contextPanelEmbeddedChat-BdA6bdky.js +1 -0
  49. package/dist/assets/de-DCrsQ5zS.js +10 -0
  50. package/dist/assets/es-Dwv4YfH6.js +16 -0
  51. package/dist/assets/fr-BCWg4Cnx.js +14 -0
  52. package/dist/assets/ghostty-vt-DdA0Zryv.wasm +0 -0
  53. package/dist/assets/index-B68h5S5B.css +1 -0
  54. package/dist/assets/index-DVwMarHI.js +39 -0
  55. package/dist/assets/{index-CODwDsU_.js → index-jXSK5RrB.js} +1 -1
  56. package/dist/assets/{isDiffPlainText-BqayB8d3.js → isDiffPlainText-B_x_rVon.js} +1 -1
  57. package/dist/assets/{isFilePlainText-QfoiKJNY.js → isFilePlainText-DW_xMer1.js} +1 -1
  58. package/dist/assets/ja-Bruw3RYC.js +16 -0
  59. package/dist/assets/ko-idhXGF8j.js +16 -0
  60. package/dist/assets/main-BkyaQhJX.js +930 -0
  61. package/dist/assets/{main-C5DVOxc6.js → main-CzdPuL0s.js} +2 -2
  62. package/dist/assets/markdownCore-Cn4Tyejo.js +5 -0
  63. package/dist/assets/{miniChat-DUJ4irZc.js → miniChat-CCkqKOLp.js} +2 -2
  64. package/dist/assets/{mobile-CcaxB0n4.js → mobile-mvxTo055.js} +2 -2
  65. package/dist/assets/patchFileDiff-Csk4iNUi.js +13 -0
  66. package/dist/assets/pl-CGZWUqZJ.js +16 -0
  67. package/dist/assets/pt-BR-B8V7u7tA.js +16 -0
  68. package/dist/assets/renderElectronMiniChatApp-BxoyujA5.js +2 -0
  69. package/dist/assets/renderMobileApp-B48CsP4r.js +25 -0
  70. package/dist/assets/runtimeEndpointReset-Bg5gx18H.js +17 -0
  71. package/dist/assets/scheduledTasksApi-BW0Etzwz.js +1 -0
  72. package/dist/assets/{shikiHighlight-DYOWuY65.js → shikiHighlight-CRl0SUC9.js} +1 -1
  73. package/dist/assets/surface-oMvhsog3.js +1 -0
  74. package/dist/assets/tr-BK_KiO2V.js +7 -0
  75. package/dist/assets/uk-CG74xV8N.js +16 -0
  76. package/dist/assets/useAppFontEffects-CPKeOpUo.js +7284 -0
  77. package/dist/assets/useGitComparison-DH220WmO.js +1 -0
  78. package/dist/assets/useInlineCommentController-BiWz4AVb.js +2 -0
  79. package/dist/assets/useRootScrollLock-BS4-kr7P.js +1 -0
  80. package/dist/assets/{vendor-base-ui-BeMD8X_w.js → vendor-base-ui-DdV8vhHn.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-language-data-DFZik9R2.js → vendor-codemirror-language-data-Bg4AEeCr.js} +2 -2
  82. package/dist/assets/vendor-zod-BPAANqvH.js +39 -0
  83. package/dist/assets/{web-components-Bhg83tjf.js → web-components-z7hfnS8n.js} +1 -1
  84. package/dist/assets/zh-CN-T4AXofZI.js +16 -0
  85. package/dist/assets/zh-TW-Dte40sxp.js +16 -0
  86. package/dist/index.html +21 -59
  87. package/dist/mini-chat.html +7 -7
  88. package/dist/mobile.html +5 -5
  89. package/package.json +3 -4
  90. package/server/index.d.ts +15 -0
  91. package/server/index.js +158 -89
  92. package/server/lib/agent-memory/actions.js +2 -2
  93. package/server/lib/agent-memory/feature-flag.js +1 -1
  94. package/server/lib/agent-memory/feature-flag.test.js +8 -8
  95. package/server/lib/agent-memory/routes.js +2 -2
  96. package/server/lib/agent-tool/runtime.js +37 -54
  97. package/server/lib/agent-tool/runtime.test.js +59 -59
  98. package/server/lib/browser-control/broker.js +3 -3
  99. package/server/lib/browser-control/broker.test.js +1 -1
  100. package/server/lib/changelog/update-notes.js +82 -0
  101. package/server/lib/changelog/update-notes.test.js +59 -0
  102. package/server/lib/client-auth/remote-clients.test.js +5 -5
  103. package/server/lib/context-obligatory/runtime.js +7 -7
  104. package/server/lib/context-obligatory/runtime.test.js +5 -5
  105. package/server/lib/data-dir-migration.js +40 -0
  106. package/server/lib/data-dir-migration.test.js +59 -0
  107. package/server/lib/dev-servers/parse.js +2 -2
  108. package/server/lib/dev-servers/parse.test.js +2 -2
  109. package/server/lib/dev-servers/routes.js +1 -1
  110. package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
  111. package/server/lib/dev-tunnel/client.js +1 -1
  112. package/server/lib/dev-tunnel/runtime.js +5 -5
  113. package/server/lib/dev-tunnel/tunnel.test.js +21 -1
  114. package/server/lib/dictation/local/model-catalog.js +1 -1
  115. package/server/lib/dictation/local/worker-process.js +2 -2
  116. package/server/lib/event-stream/directory-ws-bridge.js +1 -1
  117. package/server/lib/event-stream/global-ws-bridge.js +1 -1
  118. package/server/lib/event-stream/protocol.test.js +4 -4
  119. package/server/lib/event-stream/runtime.test.js +18 -18
  120. package/server/lib/fs/DOCUMENTATION.md +5 -0
  121. package/server/lib/fs/routes.js +68 -26
  122. package/server/lib/fs/routes.test.js +208 -22
  123. package/server/lib/git/DOCUMENTATION.md +32 -6
  124. package/server/lib/git/identity-storage.js +1 -1
  125. package/server/lib/git/issue-2746-longpaths.test.js +4 -4
  126. package/server/lib/git/routes.js +41 -5
  127. package/server/lib/git/service.js +300 -224
  128. package/server/lib/git/service.test.js +596 -28
  129. package/server/lib/github/auth.js +8 -8
  130. package/server/lib/github/pr-status.js +1 -1
  131. package/server/lib/github/routes.js +2 -2
  132. package/server/lib/inherited-env.js +17 -10
  133. package/server/lib/inherited-env.test.js +10 -11
  134. package/server/lib/linear/auth.js +8 -8
  135. package/server/lib/linear/auth.test.js +24 -24
  136. package/server/lib/linear/issues.test.js +6 -6
  137. package/server/lib/linear/mapping.test.js +4 -4
  138. package/server/lib/linear/oauth.js +2 -2
  139. package/server/lib/linear/oauth.test.js +14 -14
  140. package/server/lib/linear/routes.js +5 -5
  141. package/server/lib/linear/routes.test.js +16 -16
  142. package/server/lib/linear/status-runtime.test.js +9 -9
  143. package/server/lib/linear/status.js +1 -1
  144. package/server/lib/linear/status.test.js +15 -15
  145. package/server/lib/linear/teams.test.js +4 -4
  146. package/server/lib/magic-prompts/routes.js +2 -2
  147. package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
  148. package/server/lib/mcp-reconnect/runtime.js +122 -0
  149. package/server/lib/mcp-reconnect/runtime.test.js +140 -0
  150. package/server/lib/message-queue/DOCUMENTATION.md +161 -0
  151. package/server/lib/message-queue/runtime.js +870 -0
  152. package/server/lib/message-queue/runtime.test.js +482 -0
  153. package/server/lib/network-defaults.js +23 -0
  154. package/server/lib/network-defaults.test.js +52 -0
  155. package/server/lib/notifications/apns-runtime.js +17 -17
  156. package/server/lib/notifications/apns-runtime.test.js +11 -11
  157. package/server/lib/notifications/emitter-runtime.js +1 -1
  158. package/server/lib/notifications/emitter-runtime.test.js +1 -1
  159. package/server/lib/notifications/push-runtime.js +7 -7
  160. package/server/lib/notifications/routes.js +1 -1
  161. package/server/lib/notifications/runtime.js +1 -1
  162. package/server/lib/openchamber-control/action-resolution.test.js +10 -10
  163. package/server/lib/openchamber-control/actions.js +24 -24
  164. package/server/lib/openchamber-control/error.js +4 -4
  165. package/server/lib/openchamber-control/routes.js +2 -2
  166. package/server/lib/openchamber-control/routes.test.js +5 -5
  167. package/server/lib/openchamber-control/screenshots.js +1 -1
  168. package/server/lib/openchamber-control/screenshots.test.js +1 -1
  169. package/server/lib/openchamber-control/service.js +50 -50
  170. package/server/lib/openchamber-control/service.test.js +5 -5
  171. package/server/lib/openchamber-sessions/routes.js +124 -22
  172. package/server/lib/openchamber-sessions/routes.test.js +99 -11
  173. package/server/lib/opencode/DOCUMENTATION.md +30 -6
  174. package/server/lib/opencode/auth.js +1 -1
  175. package/server/lib/opencode/bootstrap-runtime.js +8 -6
  176. package/server/lib/opencode/cli-options.js +8 -8
  177. package/server/lib/opencode/config-paths.test.js +116 -0
  178. package/server/lib/opencode/core-routes.js +8 -7
  179. package/server/lib/opencode/core-routes.test.js +11 -11
  180. package/server/lib/opencode/env-config.js +5 -5
  181. package/server/lib/opencode/env-config.test.js +7 -7
  182. package/server/lib/opencode/env-runtime.js +10 -10
  183. package/server/lib/opencode/env-runtime.test.js +18 -18
  184. package/server/lib/opencode/feature-routes-runtime.js +19 -12
  185. package/server/lib/opencode/hmr-state-runtime.js +2 -2
  186. package/server/lib/opencode/hmr-state-runtime.test.js +1 -1
  187. package/server/lib/opencode/input-history-scope.js +14 -0
  188. package/server/lib/opencode/lifecycle.js +8 -8
  189. package/server/lib/opencode/lifecycle.test.js +4 -4
  190. package/server/lib/opencode/managed-plugin-config.js +35 -0
  191. package/server/lib/opencode/managed-process-registry.js +3 -3
  192. package/server/lib/opencode/mcp-oauth-callback.test.js +2 -2
  193. package/server/lib/opencode/openchamber-routes.js +79 -19
  194. package/server/lib/opencode/openchamber-routes.test.js +139 -12
  195. package/server/lib/opencode/plugins.js +2 -2
  196. package/server/lib/opencode/plugins.test.js +1 -1
  197. package/server/lib/opencode/project-icon-routes.js +2 -2
  198. package/server/lib/opencode/project-icon-routes.test.js +1 -1
  199. package/server/lib/opencode/providers.js +44 -2
  200. package/server/lib/opencode/providers.test.js +131 -4
  201. package/server/lib/opencode/proxy.js +2 -2
  202. package/server/lib/opencode/pwa-manifest-routes.js +1 -1
  203. package/server/lib/opencode/restart-session-recovery.test.js +1 -1
  204. package/server/lib/opencode/routes-upgrade.test.js +4 -4
  205. package/server/lib/opencode/routes.js +19 -17
  206. package/server/lib/opencode/server-startup-runtime.js +6 -6
  207. package/server/lib/opencode/session-runtime.js +3 -3
  208. package/server/lib/opencode/session-runtime.test.js +6 -6
  209. package/server/lib/opencode/settings-files.js +214 -0
  210. package/server/lib/opencode/settings-helpers.js +116 -44
  211. package/server/lib/opencode/settings-helpers.test.js +354 -12
  212. package/server/lib/opencode/settings-registry.json +747 -0
  213. package/server/lib/opencode/settings-runtime.js +141 -20
  214. package/server/lib/opencode/settings-runtime.test.js +191 -4
  215. package/server/lib/opencode/shared.js +5 -2
  216. package/server/lib/opencode/shared.test.js +7 -7
  217. package/server/lib/opencode/shutdown-runtime.js +2 -0
  218. package/server/lib/opencode/skill-routes.js +2 -1
  219. package/server/lib/opencode/snippets.js +1 -2
  220. package/server/lib/opencode/startup-performance.js +1 -1
  221. package/server/lib/opencode/startup-performance.test.js +6 -6
  222. package/server/lib/opencode/static-routes-runtime.js +8 -8
  223. package/server/lib/opencode/static-routes-runtime.test.js +7 -7
  224. package/server/lib/opencode/upgrade-capability.js +2 -2
  225. package/server/lib/opencode/upgrade-capability.test.js +3 -3
  226. package/server/lib/package-manager.js +17 -42
  227. package/server/lib/package-manager.test.js +19 -19
  228. package/server/lib/permission-auto-accept/runtime.js +1 -1
  229. package/server/lib/project-context/DOCUMENTATION.md +25 -1
  230. package/server/lib/project-context/routes.http.test.js +18 -0
  231. package/server/lib/project-context/routes.js +16 -1
  232. package/server/lib/project-context/runtime.js +248 -23
  233. package/server/lib/project-context/runtime.test.js +106 -3
  234. package/server/lib/projects/DOCUMENTATION.md +76 -0
  235. package/server/lib/projects/project-config.js +144 -11
  236. package/server/lib/projects/project-id.js +17 -0
  237. package/server/lib/projects/project-setup.js +409 -0
  238. package/server/lib/projects/project-setup.test.js +557 -0
  239. package/server/lib/projects/routes.js +59 -0
  240. package/server/lib/quota/DOCUMENTATION.md +40 -2
  241. package/server/lib/quota/credentials/providers.js +4 -0
  242. package/server/lib/quota/credentials/store.js +4 -4
  243. package/server/lib/quota/credentials/store.test.js +8 -8
  244. package/server/lib/quota/index.js +1 -0
  245. package/server/lib/quota/providers/cline-pass.js +125 -0
  246. package/server/lib/quota/providers/cline-pass.test.js +103 -0
  247. package/server/lib/quota/providers/exe-dev.js +75 -0
  248. package/server/lib/quota/providers/exe-dev.test.js +47 -0
  249. package/server/lib/quota/providers/hyper.js +118 -0
  250. package/server/lib/quota/providers/hyper.test.js +126 -0
  251. package/server/lib/quota/providers/index.js +22 -0
  252. package/server/lib/quota/providers/neuralwatt.js +3 -6
  253. package/server/lib/quota/providers/neuralwatt.test.js +7 -7
  254. package/server/lib/quota/providers/ollama-cloud.js +32 -1
  255. package/server/lib/quota/providers/ollama-cloud.test.js +33 -1
  256. package/server/lib/quota/providers/opencode-go.js +3 -2
  257. package/server/lib/quota/providers/opencode-go.test.js +35 -6
  258. package/server/lib/quota/providers/openrouter.js +119 -24
  259. package/server/lib/quota/providers/openrouter.test.js +330 -0
  260. package/server/lib/quota/providers/xai.js +1 -1
  261. package/server/lib/quota/routes.js +2 -0
  262. package/server/lib/quota/utils/auth.js +1 -1
  263. package/server/lib/relay/DOCUMENTATION.md +56 -1
  264. package/server/lib/relay/cross-compat.test.js +26 -0
  265. package/server/lib/relay/downstream-scheduler.js +154 -0
  266. package/server/lib/relay/downstream-scheduler.test.js +162 -0
  267. package/server/lib/relay/e2ee.js +10 -8
  268. package/server/lib/relay/flow-control.test.js +177 -0
  269. package/server/lib/relay/host-client.js +38 -9
  270. package/server/lib/relay/host-client.test.js +9 -1
  271. package/server/lib/relay/host-lock.js +1 -1
  272. package/server/lib/relay/service.js +5 -5
  273. package/server/lib/relay/tunnel-codec.js +9 -0
  274. package/server/lib/relay/tunnel-host.js +69 -18
  275. package/server/lib/relay/tunnel-host.test.js +9 -1
  276. package/server/lib/scheduled-tasks/issue-2710-double-execution.test.js +2 -2
  277. package/server/lib/scheduled-tasks/routes.js +5 -5
  278. package/server/lib/scheduled-tasks/service.js +25 -25
  279. package/server/lib/scheduled-tasks/service.test.js +1 -1
  280. package/server/lib/security/bind-host.js +4 -4
  281. package/server/lib/security/bind-host.test.js +1 -1
  282. package/server/lib/security/request-security.js +11 -5
  283. package/server/lib/security/request-security.test.js +14 -14
  284. package/server/lib/session-assist/runtime.js +15 -18
  285. package/server/lib/session-folders/routes.js +2 -2
  286. package/server/lib/session-folders/routes.test.js +8 -8
  287. package/server/lib/session-goal/DOCUMENTATION.md +20 -7
  288. package/server/lib/session-goal/create.js +4 -2
  289. package/server/lib/session-goal/create.test.js +1 -1
  290. package/server/lib/session-goal/objectives.js +4 -4
  291. package/server/lib/session-goal/routes.js +1 -1
  292. package/server/lib/session-goal/runtime.js +91 -30
  293. package/server/lib/session-goal/runtime.test.js +428 -2
  294. package/server/lib/session-knowledge/runtime.js +11 -11
  295. package/server/lib/session-knowledge/runtime.test.js +5 -5
  296. package/server/lib/skills-catalog/DOCUMENTATION.md +1 -1
  297. package/server/lib/skills-catalog/cache.test.js +2 -2
  298. package/server/lib/skills-catalog/disk-cache.js +5 -5
  299. package/server/lib/skills-catalog/github-meta.test.js +2 -2
  300. package/server/lib/skills-catalog/install.js +3 -2
  301. package/server/lib/small-model/DOCUMENTATION.md +7 -2
  302. package/server/lib/small-model/call.js +18 -7
  303. package/server/lib/small-model/call.test.js +58 -6
  304. package/server/lib/small-model/index.js +12 -16
  305. package/server/lib/small-model/index.test.js +1 -1
  306. package/server/lib/small-model/resolve.js +1 -1
  307. package/server/lib/small-model/resolve.test.js +1 -1
  308. package/server/lib/small-model/routes.js +2 -1
  309. package/server/lib/small-model/runtime-providers.js +15 -7
  310. package/server/lib/small-model/runtime-providers.test.js +7 -1
  311. package/server/lib/system-prompt/runtime.js +3 -22
  312. package/server/lib/system-prompt/runtime.test.js +3 -3
  313. package/server/lib/terminal/DOCUMENTATION.md +14 -10
  314. package/server/lib/terminal/runtime.js +190 -31
  315. package/server/lib/terminal/runtime.test.js +572 -38
  316. package/server/lib/terminal/shells.js +20 -3
  317. package/server/lib/terminal/shells.test.js +33 -2
  318. package/server/lib/tts/base-url.js +3 -3
  319. package/server/lib/tts/routes.test.js +20 -20
  320. package/server/lib/ui-auth/ui-auth.js +12 -9
  321. package/server/lib/ui-auth/ui-auth.test.js +19 -3
  322. package/server/lib/ui-auth/ui-passkeys.js +7 -7
  323. package/server/lib/walkthrough/DOCUMENTATION.md +33 -14
  324. package/server/lib/walkthrough/index.js +1 -0
  325. package/server/lib/walkthrough/jobs.test.js +1 -1
  326. package/server/lib/walkthrough/language.test.js +1 -1
  327. package/server/lib/walkthrough/model-settings.js +11 -15
  328. package/server/lib/walkthrough/model-settings.test.js +1 -1
  329. package/server/lib/walkthrough/prompt.js +3 -1
  330. package/server/lib/walkthrough/pull-request.test.js +5 -5
  331. package/server/lib/walkthrough/reproduce-2607.test.js +2 -2
  332. package/server/lib/walkthrough/routes.test.js +26 -5
  333. package/server/lib/walkthrough/sources.js +23 -2
  334. package/server/lib/walkthrough/store.js +3 -3
  335. package/server/lib/walkthrough/store.test.js +1 -1
  336. package/server/opencode-proxy.test.js +2 -2
  337. package/server/proxy-headers.js +1 -1
  338. package/server/sse-routes.test.js +4 -4
  339. package/README.md.bak +0 -250
  340. package/bin/lib/DOCUMENTATION.md.bak +0 -163
  341. package/dist/assets/CommitSection-SGBCAW0w.js +0 -1
  342. package/dist/assets/DiffView-DluiRSla.js +0 -4
  343. package/dist/assets/FilesView-Bdq8ppva.js +0 -17
  344. package/dist/assets/GitView-Znn7VJcP.js +0 -6
  345. package/dist/assets/LinearIssuesView-jP-hXyac.js +0 -1
  346. package/dist/assets/MarkdownImageGallery-ClOvuZxC.js +0 -1
  347. package/dist/assets/MarkdownRendererImpl-Dt9mjTRN.js +0 -12
  348. package/dist/assets/OnboardingScreen-D2DG7K6b.js +0 -1
  349. package/dist/assets/PierreDiffViewer-B7m3f0d7.js +0 -157
  350. package/dist/assets/PlanView-B0F3BtPZ.js +0 -5
  351. package/dist/assets/SettingsView-BBW-S-gh.js +0 -28
  352. package/dist/assets/ToolPartDiffPreview-CUNe28U1.js +0 -8
  353. package/dist/assets/WalkthroughView-egQgxel3.js +0 -4
  354. package/dist/assets/contextPanelEmbeddedChat-C3fjDbdg.js +0 -1
  355. package/dist/assets/de-C1P6X5Rs.js +0 -9
  356. package/dist/assets/es-CDgaF1_t.js +0 -15
  357. package/dist/assets/fr-Bgxqvvz_.js +0 -13
  358. package/dist/assets/index-C57jT0Sa.css +0 -1
  359. package/dist/assets/index-DW_E3rnL.js +0 -7
  360. package/dist/assets/ja-BDRrEcNP.js +0 -15
  361. package/dist/assets/ko-Ba8sQV79.js +0 -15
  362. package/dist/assets/main-Bv5Pkngh.js +0 -928
  363. package/dist/assets/markdownCore-CZwzz5gw.js +0 -3
  364. package/dist/assets/patchFileDiff-yNfWXN4E.js +0 -10
  365. package/dist/assets/pl-Dioz29BI.js +0 -15
  366. package/dist/assets/pt-BR-DIs6ElwV.js +0 -15
  367. package/dist/assets/renderElectronMiniChatApp-BcKLHXKe.js +0 -2
  368. package/dist/assets/renderMobileApp-D9yQJy0L.js +0 -25
  369. package/dist/assets/runtimeEndpointReset-CjhvxLH0.js +0 -16
  370. package/dist/assets/scheduledTasksApi-DLW0mkQK.js +0 -1
  371. package/dist/assets/tr-DFnMlPxY.js +0 -6
  372. package/dist/assets/uk-ZrCNjM7Y.js +0 -15
  373. package/dist/assets/useAppFontEffects-CjrntdL0.js +0 -7310
  374. package/dist/assets/useInlineCommentController-CDEuSlPH.js +0 -2
  375. package/dist/assets/useRootScrollLock-BHYPkrLv.js +0 -1
  376. package/dist/assets/vendor-ghostty-web-CrxinGGH.js +0 -13
  377. package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
  378. package/dist/assets/zh-CN-iv_AV4EC.js +0 -15
  379. package/dist/assets/zh-TW-CzEUk38j.js +0 -15
  380. package/server/index.d.ts.bak +0 -39
  381. package/server/lib/agent-tool/DOCUMENTATION.md.bak +0 -119
  382. package/server/lib/browser-control/DOCUMENTATION.md.bak +0 -50
  383. package/server/lib/context-obligatory/DOCUMENTATION.md.bak +0 -19
  384. package/server/lib/dev-tunnel/DOCUMENTATION.md.bak +0 -57
  385. package/server/lib/dictation/DOCUMENTATION.md.bak +0 -100
  386. package/server/lib/event-stream/DOCUMENTATION.md.bak +0 -62
  387. package/server/lib/fs/DOCUMENTATION.md.bak +0 -47
  388. package/server/lib/git/DOCUMENTATION.md.bak +0 -193
  389. package/server/lib/github/DOCUMENTATION.md.bak +0 -183
  390. package/server/lib/linear/DOCUMENTATION.md.bak +0 -97
  391. package/server/lib/linear/OAUTH-BROKER-HANDOFF.md.bak +0 -91
  392. package/server/lib/markdown-image-grants/DOCUMENTATION.md.bak +0 -40
  393. package/server/lib/notifications/APNS.md.bak +0 -135
  394. package/server/lib/notifications/DOCUMENTATION.md.bak +0 -138
  395. package/server/lib/openchamber-control/DOCUMENTATION.md.bak +0 -64
  396. package/server/lib/opencode/DOCUMENTATION.md.bak +0 -431
  397. package/server/lib/opencode/managed-process-registry.d.ts.bak +0 -13
  398. package/server/lib/opencode/provider-env-aliases.d.ts.bak +0 -3
  399. package/server/lib/permission-auto-accept/DOCUMENTATION.md.bak +0 -34
  400. package/server/lib/project-context/DOCUMENTATION.md.bak +0 -160
  401. package/server/lib/quota/DOCUMENTATION.md.bak +0 -123
  402. package/server/lib/relay/DOCUMENTATION.md.bak +0 -100
  403. package/server/lib/scheduled-tasks/DOCUMENTATION.md.bak +0 -182
  404. package/server/lib/session-assist/DOCUMENTATION.md.bak +0 -66
  405. package/server/lib/session-goal/DOCUMENTATION.md.bak +0 -213
  406. package/server/lib/session-knowledge/DOCUMENTATION.md.bak +0 -89
  407. package/server/lib/skills-catalog/DOCUMENTATION.md.bak +0 -151
  408. package/server/lib/small-model/DOCUMENTATION.md.bak +0 -212
  409. package/server/lib/system-prompt/DOCUMENTATION.md.bak +0 -36
  410. package/server/lib/terminal/DOCUMENTATION.md.bak +0 -50
  411. package/server/lib/text/DOCUMENTATION.md.bak +0 -35
  412. package/server/lib/tts/DOCUMENTATION.md.bak +0 -147
  413. package/server/lib/tunnels/DOCUMENTATION.md.bak +0 -21
  414. package/server/lib/ui-auth/DOCUMENTATION.md.bak +0 -44
  415. package/server/lib/walkthrough/DOCUMENTATION.md.bak +0 -411
@@ -0,0 +1,4 @@
1
+ import{R as i,f as $e,j as n}from"./vendor-react-BUCujlKS.js";import{u as le,K as Ae,a as Ne}from"./index-DVwMarHI.js";import{b as bn,u as vn,a as jn,B as Sn,C as Nn,h as kn,e as Cn,g as Rn,i as Fn,f as Dn}from"./patchFileDiff-Csk4iNUi.js";import{c as An,b as Vn,i as En,u as Ln,a as Tn,d as Mn}from"./useGitComparison-DH220WmO.js";import{f as Te,B as ke,I as M,h as xe,W as It,ac as Bn,ad as In,bb as Pn,ag as On,ae as zn,ah as _n,ai as ce,y as Rt,k as Hn,cK as Pt,t as Ke,i1 as Kn,av as Ge,a7 as Gn,a8 as $n,a9 as Wn,hS as Ot,i2 as qn,aw as zt,fP as Un,at as nt,au as Jn,bR as _t,ap as Xn,ar as Yn,as as Qn,ao as Zn}from"./useAppFontEffects-CPKeOpUo.js";import{c as es,b as ts}from"./runtimeEndpointReset-Bg5gx18H.js";import{P as ns}from"./PierreDiffViewer-DjC8nTk9.js";import{u as ss,v as rs,g as is,W as os}from"./main-BkyaQhJX.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BPAANqvH.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./VirtualizedFileDiff-C8i9HpTB.js";import"./web-components-z7hfnS8n.js";import"./computeVirtualFileMetrics-BBI7ZwrC.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-B_x_rVon.js";import"./vendor-diff-C3JhlQdm.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DdV8vhHn.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Bg4AEeCr.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-BiWz4AVb.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./useRootScrollLock-BS4-kr7P.js";import"./scheduledTasksApi-BW0Etzwz.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const as=i.memo(function(e){const s=$e.c(13),{index:l,staged:p,busyHunk:f,disabled:y,onAction:S}=e,{t:u}=Te();let g;s[0]!==p?(g=p?["unstage"]:["discard","stage"],s[0]=p,s[1]=g):g=s[1];const N=g;let d;s[2]===Symbol.for("react.memo_cache_sentinel")?(d={top:"var(--oc-hunk-action-offset, 0.25rem)"},s[2]=d):d=s[2];let D;s[3]!==N||s[4]!==f||s[5]!==y||s[6]!==l||s[7]!==S||s[8]!==u?(D=n.jsx("div",{className:"pointer-events-auto flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:N.map(k=>{const m=u(k==="stage"?"diffView.hunk.stageTitle":k==="unstage"?"diffView.hunk.unstageTitle":"diffView.hunk.discardTitle",{index:l+1}),A=f?.index===l&&f.action===k;return n.jsx(ke,{variant:"ghost",size:"xs",className:xe("rounded-full bg-transparent text-muted-foreground hover:bg-transparent hover:text-foreground",k==="discard"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",k==="stage"&&"text-[var(--status-success)] hover:text-[var(--status-success)]"),disabled:y||f!==null,title:m,"aria-label":m,onPointerDown:ls,onClick:ne=>{ne.stopPropagation(),S(l,k)},children:n.jsx(M,{name:A?"loader-4":k==="stage"?"add":"arrow-go-back",className:xe(k==="stage"?"size-4":"size-3.5",A&&"animate-spin")})},k)})}),s[3]=N,s[4]=f,s[5]=y,s[6]=l,s[7]=S,s[8]=u,s[9]=D):D=s[9];let w;return s[10]!==l||s[11]!==D?(w=n.jsx("div",{className:"pointer-events-none absolute right-3 z-20",style:d,"data-hunk-actions":l,children:D}),s[10]=l,s[11]=D,s[12]=w):w=s[12],w});function ls(a){return a.stopPropagation()}const Ft=(a,e)=>{if(e.length===0)return null;let s=null,l=null;for(const f of e)f.top<=a?(!s||f.top>s.top)&&(s=f):(!l||f.top<l.top)&&(l=f);const p=s??l;return p?{path:p.path,topOffset:p.top-a}:null},cs=(a,e,s,l)=>Math.min(Math.max(0,l),Math.max(0,a+s-e)),Dt=a=>{if(!a)return null;const e=a.split(`
2
+ `);let s=null;for(const l of e){const p=l.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(p){const f=Number.parseInt(p[1]??"",10);s=Number.isFinite(f)&&f>=1?f:null;continue}if(s!==null){if(l.startsWith(" ")){s+=1;continue}if(l.startsWith("+"))return s;if(l.startsWith("-"))return Math.max(1,s)}}return null},us=1100,ds=15e3,At=500,Vt=300,Ht=1e6,ft=3,fs=a=>a<=6?a:a<=12?6:a<=25?4:2,Et={status:"loading"},ms=3,ps=i.memo(()=>{const a=$e.c(4),{t:e}=Te();let s;a[0]!==e?(s=e("diffView.binary.unavailable"),a[0]=e,a[1]=s):s=a[1];let l;return a[2]!==s?(l=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:s})}),a[2]=s,a[3]=l):l=a[3],l}),Kt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},hs=Kt.M,gs=a=>{const e=a.index?.trim(),s=a.working_dir?.trim();return e&&e!=="?"?e.charAt(0):s?s.charAt(0):e?.charAt(0)||s?.charAt(0)||"M"},Gt=a=>{const e=gs(a);return Kt[e]??hs},xs=a=>{const{index:e,working_dir:s}=a;return e==="A"||s==="A"||e==="?"||s==="?"},Lt=a=>{const e=a.index?.trim();return!!(e&&e!=="?")},Tt=a=>!!a.working_dir?.trim()||a.index==="?",ys=(a,e)=>Un(a,e),Mt=a=>(a||"").replace(/\\/g,"/").replace(/\/+$/,""),Bt=(a,e)=>{const s=a.split(`
3
+ `),l=e.split(`
4
+ `),p=Math.min(s.length,l.length);for(let f=0;f<p;f+=1)if(s[f]!==l[f])return f+1;return l.length>s.length?s.length+1:s.length>l.length?Math.max(1,l.length):1},ws=a=>Array.isArray(a)?a.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],bs=a=>a==="added"?"A":a==="deleted"?"D":"M",mt=(a,e,s)=>Fn(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:s}:{original:"",modified:"",patch:e,fileDiff:Dn(a,e),contextMode:s},$t=(a,e,s)=>{const l=a??0,p=e??0;return!l&&!p?null:n.jsxs("span",{className:xe("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",s?.className),children:[l?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",l]}):null,p?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",p]}):null]})},vs=i.memo(a=>{const e=$e.c(63),{scope:s,workingCount:l,stagedCount:p,turnCount:f,branchCount:y,commitCount:S,showCommitOption:u,showBranchOption:g,onScopeChange:N}=a,{t:d}=Te(),[D,w]=i.useState(!1),k=s==="staged"?p:s==="turn"?f:s==="branch"?y??0:s==="commit"?S??0:l;let m;e[0]!==s||e[1]!==d?(m=d(s==="staged"?"diffView.scope.staged":s==="turn"?"diffView.scope.lastTurn":s==="branch"?"diffView.scope.branch":s==="commit"?"commitComparison.mode":"diffView.scope.changed"),e[0]=s,e[1]=d,e[2]=m):m=e[2];const A=m;let ne;e[3]!==d?(ne=d("diffView.scope.selectorAria"),e[3]=d,e[4]=ne):ne=e[4];let X;e[5]!==k?(X=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",k]}),e[5]=k,e[6]=X):X=e[6];let ue;e[7]!==A||e[8]!==X?(ue=n.jsxs("span",{className:"whitespace-nowrap",children:[A,X]}),e[7]=A,e[8]=X,e[9]=ue):ue=e[9];let F;e[10]===Symbol.for("react.memo_cache_sentinel")?(F=n.jsx(M,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=F):F=e[10];let b;e[11]!==ne||e[12]!==ue?(b=n.jsx(Xn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":ne,children:[ue,F]})}),e[11]=ne,e[12]=ue,e[13]=b):b=e[13];let z;e[14]!==N?(z=q=>{(q==="working"||q==="staged"||q==="turn"||q==="branch"||q==="commit")&&(N?.(q),w(!1))},e[14]=N,e[15]=z):z=e[15];let se;e[16]!==d?(se=d("diffView.scope.changed"),e[16]=d,e[17]=se):se=e[17];let re;e[18]!==se?(re=n.jsx("span",{children:se}),e[18]=se,e[19]=re):re=e[19];let pe;e[20]!==l?(pe=n.jsx("span",{className:"typography-meta text-muted-foreground",children:l}),e[20]=l,e[21]=pe):pe=e[21];let Y;e[22]!==pe||e[23]!==re?(Y=n.jsx(nt,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[re,pe]})}),e[22]=pe,e[23]=re,e[24]=Y):Y=e[24];let de;e[25]!==d?(de=d("diffView.scope.staged"),e[25]=d,e[26]=de):de=e[26];let Q;e[27]!==de?(Q=n.jsx("span",{children:de}),e[27]=de,e[28]=Q):Q=e[28];let $;e[29]!==p?($=n.jsx("span",{className:"typography-meta text-muted-foreground",children:p}),e[29]=p,e[30]=$):$=e[30];let I;e[31]!==Q||e[32]!==$?(I=n.jsx(nt,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[Q,$]})}),e[31]=Q,e[32]=$,e[33]=I):I=e[33];let P;e[34]!==d?(P=d("diffView.scope.lastTurn"),e[34]=d,e[35]=P):P=e[35];let T;e[36]!==P?(T=n.jsx("span",{children:P}),e[36]=P,e[37]=T):T=e[37];let B;e[38]!==f?(B=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=B):B=e[39];let Z;e[40]!==T||e[41]!==B?(Z=n.jsx(nt,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[T,B]})}),e[40]=T,e[41]=B,e[42]=Z):Z=e[42];let ee;e[43]!==y||e[44]!==g||e[45]!==d?(ee=g?n.jsx(nt,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:d("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:y??"…"})]})}):null,e[43]=y,e[44]=g,e[45]=d,e[46]=ee):ee=e[46];let V;e[47]!==S||e[48]!==u||e[49]!==d?(V=u&&n.jsx(nt,{value:"commit",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:d("commitComparison.mode")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:S??"…"})]})}),e[47]=S,e[48]=u,e[49]=d,e[50]=V):V=e[50];let W;e[51]!==s||e[52]!==Y||e[53]!==I||e[54]!==Z||e[55]!==ee||e[56]!==V||e[57]!==z?(W=n.jsx(Yn,{align:"start",className:"w-40",children:n.jsxs(Qn,{value:s,onValueChange:z,children:[Y,I,Z,ee,V]})}),e[51]=s,e[52]=Y,e[53]=I,e[54]=Z,e[55]=ee,e[56]=V,e[57]=z,e[58]=W):W=e[58];let he;return e[59]!==D||e[60]!==W||e[61]!==b?(he=n.jsxs(Zn,{open:D,onOpenChange:w,children:[b,W]}),e[59]=D,e[60]=W,e[61]=b,e[62]=he):he=e[62],he}),js=i.memo(a=>{const e=$e.c(11),{changedFiles:s,selectedFile:l,onSelectFile:p}=a,{t:f}=Te();if(s.length===0)return null;let y;if(e[0]!==s||e[1]!==p||e[2]!==l||e[3]!==f){let u;e[5]!==p||e[6]!==l||e[7]!==f?(u=g=>{const N=Gt(g),d=l===g.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>p(g.path),className:xe("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",d?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(zt,{filePath:g.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:N.color},title:f(N.descriptionKey),"aria-label":f(N.descriptionKey),children:N.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:g.path,children:g.path}),$t(g.insertions,g.deletions)]})},g.path)},e[5]=p,e[6]=l,e[7]=f,e[8]=u):u=e[8],y=s.map(u),e[0]=s,e[1]=p,e[2]=l,e[3]=f,e[4]=y}else y=e[4];let S;return e[9]!==y?(S=n.jsx(_t,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:y})}),e[9]=y,e[10]=S):S=e[10],S}),Ss=i.memo(a=>{const e=$e.c(20),{filePath:s,diff:l,renderSideBySide:p}=a,{t:f}=Te(),y=l.original.length>0,S=l.modified.length>0,u=p?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",g=p?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N={contain:"layout"},e[0]=N):N=e[0];let d;e[1]!==l.original||e[2]!==s||e[3]!==y||e[4]!==g||e[5]!==p||e[6]!==f?(d=y&&n.jsxs("div",{className:g,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:l.original,alt:f("diffView.image.originalAlt",{path:s}),className:p?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=l.original,e[2]=s,e[3]=y,e[4]=g,e[5]=p,e[6]=f,e[7]=d):d=e[7];let D;e[8]!==l.modified||e[9]!==s||e[10]!==S||e[11]!==y||e[12]!==g||e[13]!==p||e[14]!==f?(D=S&&n.jsxs("div",{className:g,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(y?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:l.modified,alt:f("diffView.image.modifiedAlt",{path:s}),className:p?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=l.modified,e[9]=s,e[10]=S,e[11]=y,e[12]=g,e[13]=p,e[14]=f,e[15]=D):D=e[15];let w;return e[16]!==u||e[17]!==d||e[18]!==D?(w=n.jsx("div",{className:"w-full overflow-auto p-4",style:N,children:n.jsxs("div",{className:u,children:[d,D]})}),e[16]=u,e[17]=d,e[18]=D,e[19]=w):w=e[19],w}),Ns=i.memo(a=>{const e=$e.c(17),{filePath:s,diff:l,renderSideBySide:p,wrapLines:f,hunkActions:y}=a;let S;e[0]!==s?(S=Jn(s)||"text",e[0]=s,e[1]=S):S=e[1];const u=S;if(l.isBinary){let d;return e[2]===Symbol.for("react.memo_cache_sentinel")?(d=n.jsx(ps,{}),e[2]=d):d=e[2],d}if(Ge(s)){let d;return e[3]!==l||e[4]!==s||e[5]!==p?(d=n.jsx(Ss,{filePath:s,diff:l,renderSideBySide:p}),e[3]=l,e[4]=s,e[5]=p,e[6]=d):d=e[6],d}let g;e[7]===Symbol.for("react.memo_cache_sentinel")?(g={contain:"layout"},e[7]=g):g=e[7];let N;return e[8]!==l.fileDiff||e[9]!==l.modified||e[10]!==l.original||e[11]!==s||e[12]!==y||e[13]!==u||e[14]!==p||e[15]!==f?(N=n.jsx("div",{className:"w-full",style:g,children:n.jsx(ns,{original:l.original,modified:l.modified,fileDiff:l.fileDiff,language:u,fileName:s,renderSideBySide:p,wrapLines:f,layout:"inline",hunkActions:y})}),e[8]=l.fileDiff,e[9]=l.modified,e[10]=l.original,e[11]=s,e[12]=y,e[13]=u,e[14]=p,e[15]=f,e[16]=N):N=e[16],N}),ks=i.memo(({directory:a,file:e,layout:s,wrapLines:l,isSelected:p,isExpanded:f,isMounted:y,onSelect:S,onExpandedChange:u,registerSectionRef:g,showOpenInEditorAction:N=!1,isOpeningInEditor:d=!1,onOpenInEditor:D,staged:w=!1,loadFullFiles:k=!1,initialDiffData:m=null,comparisonDiff:A,onRetryComparisonDiff:ne,readOnlyActions:X=!1,hunkActionsEnabled:ue=!1})=>{const{t:F}=Te(),{git:b}=It(),z=ce(i.useCallback(x=>x.directories.get(a)?.diffCache.get(e.path)??null,[a,e.path])),se=ce(x=>x.setDiff),re=ce(x=>x.fetchStatus),pe=le(x=>x.setDiffFileLayout),[Y,de]=i.useState(0),[Q,$]=i.useState(null),[I,P]=i.useState(!1),T=A?A.status==="error"?A.message:null:Q,B=A?A.status==="loading":I,[Z,ee]=i.useState(null),V=i.useRef(!1),[W,he]=i.useState(null),[q,fe]=i.useState(!1),[We,qe]=i.useState(null),[Me,Ve]=i.useState(null),ye=i.useRef(null),ot=i.useRef(null),Ce=i.useMemo(()=>Gt(e),[e]),Be=s==="side-by-side",Ee=k?"full":"patch",c=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,_=ue&&!X&&!m&&!A&&!Ge(e.path),we=JSON.stringify([Ne(),a,e.path,w,c,Y]),H=W?.scope===we?W.patch:null,K=i.useMemo(()=>A?A.status==="ready"?A.data:null:m||(w?Me:We||(z?{original:z.original,modified:z.modified,isBinary:z.isBinary,contextMode:"full"}:null)),[A,z,m,We,w,Me]),Ue=K?.contextMode===Ee,Je=i.useCallback(x=>{ot.current=x,g(e.path,x)},[e.path,g]),Xe=i.useCallback(x=>{u(e.path,x)},[e.path,u]),Ye=i.useCallback(()=>{S(e.path)},[e.path,S]);i.useEffect(()=>{w?Ve(null):qe(null),$(null),ye.current=null},[c,w]),i.useEffect(()=>{if(!f||!y||Q)return;if(!a||A||m||K&&Ue&&(!_||H!==null)){ye.current=null,P(!1);return}const x=`${a}::${e.path}::${w?"staged":"unstaged"}::${c}::${Ee}::${Y}`;if(ye.current===x)return;ye.current=x,$(null),P(!0);let E=!1;const ie=Ne(),Oe=k?Ht:ft,U=Ge(e.path)?b.getGitFileDiff(a,{path:e.path,staged:w}):!k&&H!==null?Promise.resolve({diff:H}):b.getGitDiff(a,{path:e.path,staged:w,contextLines:Oe}),at=_&&k&&H===null?b.getGitDiff(a,{path:e.path,staged:w,contextLines:ft}).then(C=>C.diff):Promise.resolve(H),Re=Promise.all([U,at]),Fe=ds;let me;const O=new Promise((C,oe)=>{me=setTimeout(()=>oe(new Error(`Timed out after ${Fe}ms`)),Fe)});return Promise.race([Re,O]).then(([C,oe])=>{if(E||ie!==Ne())return;const be="diff"in C&&!k?C.diff:oe;if(_&&k&&be!==null&&/^@@\s/m.test(be)&&"diff"in C&&C.diff!==be&&!kn(C.diff,be))throw he(null),new Error(F("diffView.hunk.unavailable"));if(_&&be!==null&&he({scope:we,patch:be}),"diff"in C){const ve=mt(e.path,C.diff,Ee);w?Ve(ve):qe(ve)}else{const ve={original:C.original??"",modified:C.modified??"",isBinary:C.isBinary,contextMode:"full"};w?Ve(ve):se(a,e.path,ve,ie)}P(!1)}).catch(C=>{if(E||ie!==Ne())return;const oe=C instanceof Error?C.message:String(C);$(oe),P(!1)}).finally(()=>clearTimeout(me)),()=>{E=!0,clearTimeout(me),ye.current===x&&(ye.current=null)}},[H,_,we,A,Ee,K,Ue,Y,a,e.path,c,b,m,f,y,k,Q,se,w,F]);const Qe=i.useCallback(()=>{Xe(!f),Ye()},[Xe,Ye,f]),Ie=i.useCallback(()=>{$(null),he(null),qe(null),Ve(null),ye.current=null,de(x=>x+1)},[]),Ze=i.useCallback(async(x,E)=>{if(!a||!_||B||T||V.current||Z!==null)return;const ie=H?Cn(H,x):null;if(!ie){Ke.error(F("diffView.hunk.unavailable"));return}if(w&&E!=="unstage"||!w&&E==="unstage")return;V.current=!0;const Oe=Ne();ee({index:x,action:E});try{const U=E==="stage"?b.stageGitHunk:E==="unstage"?b.unstageGitHunk:b.revertGitHunk;if(!U){Ke.error(F("diffView.hunk.unsupported"));return}if(await U(a,e.path,ie),Oe!==Ne())return;Ie(),Pt.requestGitRefresh({directory:a,paths:[e.path]}),await re(a,b)}catch(U){if(Oe!==Ne())return;Ie(),Ke.error(U instanceof Error&&U.message?U.message:F("diffView.hunk.unavailable"))}finally{V.current=!1,ee(U=>U?.index===x&&U.action===E?null:U)}},[H,_,B,T,a,re,e.path,b,Z,Ie,w,F]),ge=i.useMemo(()=>_&&H!==null?Rn(H):[],[H,_]),Pe=i.useCallback(x=>n.jsx(as,{index:x,staged:w,busyHunk:Z,disabled:B||!!T,onAction:Ze}),[T,Ze,Z,B,w]),et=i.useMemo(()=>ge.length>0?{anchors:ge,render:Pe}:void 0,[ge,Pe]);return n.jsxs("div",{ref:Je,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Qe,onKeyDown:x=>{x.target===x.currentTarget&&(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),Qe())},className:xe("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",p?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?n.jsx(M,{name:"arrow-down-s",className:"size-4"}):n.jsx(M,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:Ce.color},title:F(Ce.descriptionKey),"aria-label":F(Ce.descriptionKey),children:Ce.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(zt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const x=e.path.lastIndexOf("/");if(x===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const E=e.path.slice(0,x),ie=e.path.slice(x+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:E}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:ie})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[$t(e.insertions,e.deletions),N&&D?n.jsx(ke,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:F("diffView.actions.openFileInEditorAtChange"),onClick:x=>{x.stopPropagation(),D(e.path,K)},disabled:d,children:d?n.jsx(M,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(M,{name:"edit",className:"size-3.5"})}):null,n.jsx(Ot,{mode:Be?"side-by-side":"unified",onModeChange:x=>{const E=x==="side-by-side"?"side-by-side":"inline";pe(e.path,E)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!y&&!T?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,T?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:T}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>A?ne?.():Ie(),children:F("diffView.actions.retry")})]}):null,y&&B&&!K&&!T?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),F("diffView.state.loadingDiff")]}):null,y&&K&&!q&&e.insertions+e.deletions>At?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:F("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:F("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>fe(!0),children:F("diffView.actions.renderAnyway")})]}):null,y&&K&&(q||e.insertions+e.deletions<=At)?n.jsx(n.Fragment,{children:n.jsx(Ns,{filePath:e.path,diff:K,renderSideBySide:Be,wrapLines:l,hunkActions:et})}):null]})]})}),Hi=({hideStackedFileSidebar:a=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:s=!1,showOpenInEditorAction:l=!1,diffScope:p="all",onDiffScopeChange:f,targetFilePath:y=null,flushContent:S=!1})=>{const{t:u}=Te(),{git:g,files:N}=It(),d=Bn(),{rootIsGitRepo:D,gitDirectory:w,nestedRepos:k}=In(d??null),m=w??d,A=le(t=>t.openContextSurface),ne=ss(t=>t.requestSource),{screenWidth:X,isMobile:ue}=Pn(),F=On(m??null),b=zn(m??null),z=_n(m??null),se=ce(t=>t.setActiveDirectory),re=ce(t=>t.ensureStatus),pe=ce(t=>t.selectNestedRepo),Y=ce(t=>t.fetchStatus),de=ce(t=>t.fetchBranches),Q=ce(t=>t.clearDiffCache),$=ce(t=>t.setDiff),[I,P]=i.useState(null),[T,B]=i.useState(!1),[Z,ee]=i.useState(null),[V,W]=i.useState(()=>new Set),[he,q]=i.useState(()=>new Set),[fe,We]=i.useState(!1),[qe,Me]=i.useState(0),[Ve,ye]=i.useState(()=>new Map),[ot,Ce]=i.useState(!1),[Be,Ee]=i.useState(!1),[c,_]=i.useState(p);i.useEffect(()=>{_(p)},[p]);const we=le(t=>t.pendingDiffFile),H=le(t=>t.pendingDiffStaged),K=le(t=>t.pendingDiffScope),Ue=le(t=>t.setPendingDiffFile),Je=le(t=>t.diffLayoutPreference),Xe=le(t=>t.diffFileLayout),Ye=le(t=>t.setDiffFileLayout),Qe=le(t=>t.diffWrapLines),Ie=le(t=>t.setDiffWrapLines),Ze=le(t=>t.openContextFileAtLine),ge=Rt(t=>t.currentSessionId),Pe=Hn(ge??"",d??void 0),et=Qe,x=c==="staged"?!0:c==="working"?!1:null,E=x??T,ie=ue||X<=768,Oe=!!ge&&c!=="turn"&&c!=="commit"&&!ie&&!Ae(),U=c!=="turn"&&!ie&&!Ae(),at=!a&&!ie&&X>=1024,Re=i.useRef(null),Fe=i.useRef(new Map),me=i.useRef(null),O=i.useRef(null),C=i.useRef(!1),oe=i.useRef(null),be=i.useRef(null),ve=i.useRef(null),lt=i.useRef(null),pt=i.useCallback(()=>{const t=Re.current;if(!t)return null;const r=t.getBoundingClientRect().top,o=[];for(const[h,v]of Fe.current)v&&o.push({path:h,top:v.getBoundingClientRect().top});return Ft(r,o)},[]),ze=i.useCallback(()=>{me.current=null,C.current=!1,ee(null),O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null)},[]),_e=i.useCallback(t=>{W(r=>{if(r.has(t))return r;const o=new Set(r);return o.add(t),o})},[]),tt=i.useMemo(()=>{for(let t=Pe.length-1;t>=0;t-=1){const r=Pe[t];if(r.role==="user")return ws(r.summary?.diffs)}return[]},[Pe]),Wt=i.useMemo(()=>{const t=new Map;for(const r of tt)if(r.file){if(typeof r.patch=="string"){t.set(r.file,mt(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[tt]),qt=i.useMemo(()=>b?.files?b.files.filter(Tt).length:0,[b]),Ut=i.useMemo(()=>b?.files?b.files.filter(Lt).length:0,[b]),Jt=tt.length,J=b?.current??null,De=bn(m??null,J,c==="commit"&&!Ae()),Le=De.selectedCommit?.hash??null;i.useEffect(()=>{c==="commit"&&Ae()&&(_("working"),f?.("working"))},[c,f]);const He=ce(t=>m?t.directories.get(m)?.branches??null:null),Xt=ce(t=>m?t.directories.get(m)?.isLoadingBranches??!1:!1),Yt=i.useCallback(()=>{m&&de(m,g)},[m,de,g]),Qt=An(m??null,F!==!1,Xt,!!He,Yt,ms),ht=i.useMemo(()=>{const t=b?.tracking?.trim().split("/")[0];return(t&&He?.defaultBranches?.[t])??He?.defaultBranches?.origin??null},[He,b?.tracking]),gt=!Ae()&&Vn(J,ht),Zt=b!==null,xt=Ae()||Qt||En(J,ht,Zt,He!==null),en=vn(t=>t.setOverride),{base:je,resolved:tn,revision:yt}=jn(m??null,J,gt&&c==="branch"),[nn,sn]=i.useState(0);i.useEffect(()=>{const t=Mn(c,!xt);t!==c&&(_(t),t==="working"&&f?.("working"))},[c,xt,f]);const rn=i.useMemo(()=>c==="commit"&&Le?{kind:"commit",hash:Le}:c==="branch"&&je&&J?{kind:"branch",baseRef:je,headRef:J}:null,[c,je,J,Le]),Se=Ln(m??null,rn,!Ae(),c==="branch"?yt:""),{fetchDiff:wt}=Se,st=c==="commit"?Se.files:null,bt=c==="commit"?Se.error:null,rt=c==="branch"?Se.files:null,vt=c==="branch"?Se.error:null,jt=Se.files?Se.key:null,on=i.useMemo(()=>c==="branch"||c==="commit"?Array.from(V).sort().join("\0"):"",[c,V]),an=i.useCallback(async t=>{try{const r=await wt(t,fe?Ht:ft);return{status:"ready",data:mt(t,r.diff,fe?"full":"patch")}}catch(r){return{status:"error",message:r instanceof Error?r.message:u("diffView.state.failedToLoadDiff")}}},[wt,fe,u]),ln=Tn(jt,on,jt?an:null,Et,JSON.stringify([c==="branch"?yt:"",nn,fe])),cn=rt?.length??null,j=i.useMemo(()=>{if(c==="commit")return(st??[]).map(o=>({path:o.path,index:"",working_dir:o.status,insertions:o.insertions,deletions:o.deletions,isNew:o.status==="A"}));if(c==="branch")return(rt??[]).map(o=>({path:o.path,index:"",working_dir:o.status,insertions:0,deletions:0,isNew:o.status==="A"})).sort((o,h)=>o.path.localeCompare(h.path));if(c==="turn")return tt.map(o=>({path:o.file??"",index:"",working_dir:bs(o.status),insertions:o.additions??0,deletions:o.deletions??0,isNew:o.status==="added"})).filter(o=>o.path).sort((o,h)=>o.path.localeCompare(h.path));if(!b?.files)return[];const t=b.diffStats??{},r=c==="staged"?Lt:c==="working"?Tt:()=>!0;return b.files.filter(r).map(o=>({...o,insertions:t[o.path]?.insertions??0,deletions:t[o.path]?.deletions??0,isNew:xs(o)})).sort((o,h)=>o.path.localeCompare(h.path))},[c,rt,st,tt,b]),ct=i.useMemo(()=>j.map(t=>t.path).join("\0"),[j]);i.useEffect(()=>{const t=ct?ct.split("\0"):[],r=new Set(t),o=`${m??""}:${c}:${e?"collapsed":"default"}`,h=be.current!==o;be.current=o,W(v=>{if(h){const L=e?0:fs(t.length);return new Set(t.slice(0,L))}let G=!1;const R=new Set;for(const L of v){if(!r.has(L)){G=!0;continue}R.add(L)}return G?R:v}),q(v=>{if(h)return new Set;let G=!1;const R=new Set;for(const L of v){if(!r.has(L)){G=!0;continue}R.add(L)}return G?R:v})},[c,ct,m,e]);const St=i.useCallback(()=>{oe.current=null;const t=Re.current;if(!t)return;const r=t.getBoundingClientRect(),o=r.top-Vt,h=r.bottom+Vt,v={},G=[];for(const[R,L]of Fe.current){if(!L)continue;const te=L.getBoundingClientRect();G.push({path:R,top:te.top}),V.has(R)&&(te.bottom<o||te.top>h||(v[R]=!0))}ve.current=Ft(r.top,G),q(R=>{let L=!1;const te=new Set(R);for(const Ct of Object.keys(v))te.has(Ct)||(te.add(Ct),L=!0);return L?te:R})},[V]),ae=i.useCallback(()=>{typeof window>"u"||oe.current===null&&(oe.current=window.requestAnimationFrame(St))},[St]);i.useEffect(()=>{const t=Re.current;if(t)return ae(),t.addEventListener("scroll",ae,{passive:!0}),window.addEventListener("resize",ae),()=>{t.removeEventListener("scroll",ae),window.removeEventListener("resize",ae),oe.current!==null&&(window.cancelAnimationFrame(oe.current),oe.current=null)}},[j,V,ae]);const ut=i.useCallback(t=>{const r=Xe[t.path];if(r)return r;if(Je==="inline")return"inline";if(Je==="side-by-side")return"side-by-side";const o=X<us;return t.isNew||o?"inline":"side-by-side"},[Xe,Je,X]),Nt=i.useMemo(()=>j.length===0?null:j.every(t=>ut(t)==="side-by-side")?"side-by-side":"inline",[j,ut]);i.useEffect(()=>{m&&(se(m),re(m,g))},[m,se,re,g]),i.useEffect(()=>{if(m)return Pt.onGitRefreshHint(t=>{Mt(t.directory)===Mt(m)&&(t.paths?.length&&(lt.current=pt()??ve.current,Q(m,t.paths),ye(r=>{const o=new Map(r);for(const h of t.paths??[])o.set(h,(o.get(h)??0)+1);return o})),Y(m,g,{silent:!0}))})},[pt,Q,m,Y,g]),i.useLayoutEffect(()=>{const t=lt.current;if(!t)return;lt.current=null;const r=Re.current,o=Fe.current.get(t.path);if(!r||!o)return;const h=r.getBoundingClientRect().top,v=o.getBoundingClientRect().top-h;r.scrollTop=cs(r.scrollTop,t.topOffset,v,r.scrollHeight-r.clientHeight),ve.current=t},[Ve]),i.useEffect(()=>{c!=="all"&&!K||we&&(K&&_(K),P(we),B(K==="staged"||!K&&H),Ue(null),C.current=!0,me.current=we,_e(we),Me(t=>t+1))},[c,_e,we,K,H,Ue]),i.useEffect(()=>{if(c==="all")return;const t=y?.trim();t&&(P(t),B(c==="staged"),C.current=!0,me.current=t,_e(t),Me(r=>r+1))},[c,_e,y]),i.useEffect(()=>{if(!I)return;j.some(r=>r.path===I)||(P(null),B(!1))},[j,I]);const un=i.useCallback((t,r)=>{const o=Fe.current;r?o.set(t,r):o.delete(t),ae()},[ae]),dn=i.useCallback((t,r)=>{ze(),W(o=>{const h=o.has(t);if(r===h)return o;const v=new Set(o);return r?v.add(t):v.delete(t),v}),r||q(o=>{if(!o.has(t))return o;const h=new Set(o);return h.delete(t),h}),ae()},[ze,ae]),fn=i.useCallback(()=>{ze(),W(t=>t.size>0?new Set:new Set(j.map(r=>r.path))),q(new Set),ae()},[ze,j,ae]),mn=i.useCallback(async t=>{if(!ge)return;const r=Rt.getState().getDirectoryForSession(ge)||d||"";if(!r){Ke.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}Ee(!0);try{await Kn({originalSessionID:ge,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),Ce(!1)}catch(o){console.error("[review-flow] failed to start review flow",o),Ke.error(o instanceof Error?o.message:u("diffView.reviewDialog.toast.startFailed"))}finally{Ee(!1)}},[ge,d,u]),it=i.useCallback(t=>{const r=Fe.current.get(t),o=Re.current;if(!r||!o)return!1;const h=r.getBoundingClientRect().top-o.getBoundingClientRect().top;return o.scrollTo({top:o.scrollTop+h,behavior:"auto"}),!0},[]);i.useEffect(()=>{if(!me.current)return;let r=0;const o=20;let h=!1;const v=(R=!0)=>{h||(h=!0,me.current=null,C.current=!1,R&&ee(null),O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null))},G=()=>{if(h){O.current=null;return}const R=me.current;if(!R){v(),O.current=null;return}if(!it(R)){r+=1,r<o?O.current=window.requestAnimationFrame(G):(v(),O.current=null);return}if(s&&C.current){ee(R),v(!1);return}v()};return O.current=window.requestAnimationFrame(G),()=>{h=!0,O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null)}},[s,qe,it]);const pn=i.useCallback(t=>{},[]),dt=i.useCallback(t=>{ze(),P(t),B(!1),C.current=!0,me.current=t,_e(t),Me(r=>r+1),it(t)},[ze,_e,it]);i.useEffect(()=>{const t=r=>{if(!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const o=r.target;if(o instanceof HTMLElement&&(o.isContentEditable||o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.closest('[role="dialog"]'))||j.length===0)return;const h=r.key==="ArrowDown"?1:-1,v=I?j.findIndex(L=>L.path===I):-1,G=v===-1?h>0?0:j.length-1:v+h,R=j[G];R&&(r.preventDefault(),dt(R.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[j,I,dt]);const hn=i.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";j.forEach(o=>{Ye(o.path,r)})},[j,Ye]),[gn,kt]=i.useState(null),xn=i.useCallback(async(t,r)=>{if(!m||!t)return;kt(t);const o=Ne();try{let h=null;if(r?.patch&&!r.isBinary&&!Ge(t)?h=Dt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Ge(t)&&(h=Bt(r.original,r.modified)),h===null)try{const te=await g.getGitDiff(m,{path:t,staged:E,contextLines:3});h=Dt(te.diff)}catch{h=null}let v=r;if(h===null||!v){const te=await g.getGitFileDiff(m,{path:t,staged:E});v={original:te.original??"",modified:te.modified??"",isBinary:te.isBinary},E||$(m,t,v,o)}const G=h??(v.isBinary||Ge(t)?1:Bt(v.original,v.modified)),R=ys(m,t),L=await rs(N,R,{directory:m});if(!L.ok){Ke.error(is(L.reason));return}Ze(m,R,G,1)}finally{kt(h=>h===t?null:h)}},[E,m,N,g,Ze,$]),yn=()=>{if(!m)return null;const t=r=>x!==null?x:T&&r===I;return n.jsxs("div",{className:xe("flex min-w-0 flex-1 min-h-0 h-full",S?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[at&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:j.length})]}),n.jsx(js,{changedFiles:j,selectedFile:null,onSelectFile:dt})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(_t,{ref:Re,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:j.map(r=>n.jsx(ks,{directory:m,file:r,layout:ut(r),wrapLines:et,isSelected:!1,isExpanded:V.has(r.path),isMounted:he.has(r.path)||r.path===Z,onSelect:pn,onExpandedChange:dn,registerSectionRef:un,showOpenInEditorAction:l&&c!=="turn",isOpeningInEditor:gn===r.path,onOpenInEditor:(o,h)=>{xn(o,h)},staged:t(r.path),loadFullFiles:fe,readOnlyActions:c==="branch"||c==="commit",hunkActionsEnabled:c==="all"||c==="working"||c==="staged",comparisonDiff:c==="branch"||c==="commit"?ln.get(r.path)??Et:void 0,onRetryComparisonDiff:()=>sn(o=>o+1),initialDiffData:c==="turn"?Wt.get(r.path)??null:null},`${Ne()}:${m}:${r.path}:${Ve.get(r.path)??0}`))})})})]})},wn=()=>{if(!m)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(c!=="turn"&&z&&!b)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(c!=="turn"&&F===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(c==="commit"){if(bt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 p-6 text-center",children:[n.jsx("p",{className:"typography-meta text-muted-foreground",children:bt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Se.refresh()},children:u("diffView.actions.retry")})]});if(!Le&&!De.loading)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:De.error??u("commitComparison.noCommits")});if(!st)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingDiff")]})}if(c==="branch"){if(!tn)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!je)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(M,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("gitView.pr.toast.baseBranchRequired")})]});if(vt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:vt}),n.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{Se.refresh()},children:u("diffView.actions.retry")})]});if(rt===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return j.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:c==="turn"?u("diffView.state.noLastTurnChanges"):c==="commit"?u("commitComparison.emptyDiff"):c==="branch"&&je?u("diffView.branch.empty",{base:ts(je)}):u("diffView.state.cleanWorkingTree")}):yn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[D===!1&&Array.isArray(k)&&k.length>0?n.jsx(es,{repositories:k,selectedRepository:w??null,onSelectRepository:t=>{d&&pe(d,t)},repositoryRoot:d??void 0}):null,!ue&&(c!=="all"?n.jsx(vs,{scope:c,workingCount:qt,stagedCount:Ut,turnCount:Jt,branchCount:cn,commitCount:st?.length??null,showCommitOption:!Ae(),showBranchOption:gt,onScopeChange:t=>{_(t),f?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:z&&!b?u("diffView.state.loadingChanges"):j.length===1?u("diffView.summary.changedFilesSingle",{count:j.length}):u("diffView.summary.changedFilesPlural",{count:j.length})})})),c==="branch"&&n.jsx(Sn,{branches:He?.all??[],currentBranch:J,base:je,onSelect:t=>{m&&J&&en(m,J,t)}},JSON.stringify([m,J])),c==="commit"&&n.jsx(Nn,{commits:De.commits,selectedHash:Le,loading:De.loading,error:De.error,onSelect:De.select,onRefresh:()=>{De.refresh()}},JSON.stringify([m,J])),j.length>0&&n.jsxs(ke,{variant:"ghost",size:"sm",onClick:fn,className:xe("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:V.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(M,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:V.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),j.length>0&&Oe&&n.jsxs(ke,{variant:"default",size:"sm",onClick:()=>Ce(!0),disabled:Be,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[Be?n.jsx(M,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(M,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),j.length>0&&U&&n.jsxs(ke,{variant:"outline",size:"sm",onClick:()=>{const t=m??"";ne(t,c==="commit"&&Le?{kind:"commit",hash:Le}:c==="branch"&&je&&J?{kind:"branch",baseRef:je,headRef:J}:{kind:"working-tree",scope:c==="staged"||c==="working"?c:"all"}),A(t,"walkthrough")},className:xe("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",os),"aria-label":u("walkthrough.action.open"),children:[n.jsx(M,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),j.length>0&&n.jsxs(Gn,{children:[n.jsx($n,{asChild:!0,children:n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>We(t=>!t),"aria-pressed":fe,"aria-label":u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:xe("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",fe&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(M,{name:"file-download",className:"size-4"})})}),n.jsx(Wn,{children:n.jsx("p",{children:u(fe?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),j.length>0&&n.jsx(ke,{variant:"ghost",size:"sm",onClick:()=>Ie(!Qe),className:xe("h-5 w-5 p-0 transition-opacity",et?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(et?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(M,{name:"text-wrap",className:"size-4"})}),Nt&&n.jsx(Ot,{mode:Nt==="side-by-side"?"side-by-side":"unified",onModeChange:hn})]}),n.jsx(qn,{open:ot,onOpenChange:Ce,projectDirectory:m??null,submitting:Be,onConfirm:mn}),wn()]})};export{Hi as DiffView,ks as MultiFileDiffEntry};
@@ -0,0 +1 @@
1
+ import{R as N,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as ze}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as J,aw as Ee,a7 as be,a8 as ye,I as E,a9 as we,h as Z,B as Y,a2 as Te,hc as Ie,bL as fe,bM as ue,bN as pe,bO as ge,bP as xe,bQ as ve,bb as Me,c5 as Pe,t as ae}from"./useAppFontEffects-CPKeOpUo.js";import{u as ke}from"./index-DVwMarHI.js";const Se={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Re=Se.M;function Fe(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function He(p){const e=Fe(p);return Se[e]??Re}const $e=N.memo(function(e){const t=oe.c(58),{file:r,actionLabel:w,actionSymbol:x,onAction:g,onViewDiff:d,onRevert:a,isReverting:h,stats:S,rowPaddingClassName:f,indentPx:b,actionAtStart:V,showRevert:k}=e,v=b===void 0?0:b,o=V===void 0?!1:V,j=k===void 0?!0:k;let c;t[0]!==r?(c=He(r),t[0]=r,t[1]=c):c=t[1];const u=c,{t:I}=J(),H=u.description,R=S?.insertions??0,A=S?.deletions??0;let z;t[2]!==g||t[3]!==d?(z=U=>{U.key===" "?(U.preventDefault(),g()):U.key==="Enter"&&(U.preventDefault(),d())},t[2]=g,t[3]=d,t[4]=z):z=t[4];const T=z;let M;t[5]!==g?(M=U=>{U.preventDefault(),U.stopPropagation(),g()},t[5]=g,t[6]=M):M=t[6];const y=M;let $;t[7]!==a?($=U=>{U.preventDefault(),U.stopPropagation(),a()},t[7]=a,t[8]=$):$=t[8];const W=$;let L;t[9]!==w||t[10]!==x||t[11]!==y?(L=s.jsx("button",{type:"button",onClick:y,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":w,title:w,children:x}),t[9]=w,t[10]=x,t[11]=y,t[12]=L):L=t[12];const F=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${f??"px-3"}`;let P;t[13]!==v?(P=v>0?{paddingLeft:`${v}px`}:void 0,t[13]=v,t[14]=P):P=t[14];const q=o?F:null;let K;t[15]!==u.color?(K={color:u.color},t[15]=u.color,t[16]=K):K=t[16];let O;t[17]!==u.code||t[18]!==H||t[19]!==K?(O=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:H,"aria-label":H,children:u.code}),t[17]=u.code,t[18]=H,t[19]=K,t[20]=O):O=t[20];let G;t[21]!==r.path?(G=s.jsx(Ee,{filePath:r.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=r.path,t[22]=G):G=t[22];let _;if(t[23]!==r.path){e:{const U=r.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],_=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:r.path,children:r.path});break e}const Ae=r.path.slice(0,U),De=r.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const ce=s.jsx("span",{className:"text-foreground",children:De.slice(1)});let ie;t[28]!==ce?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,ce]}),t[28]=ce,t[29]=ie):ie=t[29],_=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:r.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:Ae}),ie]})}t[23]=r.path,t[24]=_}else _=t[24];let Q;t[30]===Symbol.for("react.memo_cache_sentinel")?(Q={color:"var(--status-success)"},t[30]=Q):Q=t[30];let i;t[31]!==R?(i=s.jsxs("span",{style:Q,children:["+",R]}),t[31]=R,t[32]=i):i=t[32];let n,l;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),l={color:"var(--status-error)"},t[33]=n,t[34]=l):(n=t[33],l=t[34]);let m;t[35]!==A?(m=s.jsxs("span",{style:l,children:["-",A]}),t[35]=A,t[36]=m):m=t[36];let D;t[37]!==i||t[38]!==m?(D=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,m]}),t[37]=i,t[38]=m,t[39]=D):D=t[39];let C;t[40]!==r.path||t[41]!==W||t[42]!==h||t[43]!==j||t[44]!==I?(C=j?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:h,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":I("gitView.changes.revertFileAria",{path:r.path}),children:h?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(we,{sideOffset:8,children:I("gitView.changes.revertFileTooltip")})]}):null,t[40]=r.path,t[41]=W,t[42]=h,t[43]=j,t[44]=I,t[45]=C):C=t[45];const B=o?null:F;let ee;return t[46]!==T||t[47]!==d||t[48]!==P||t[49]!==q||t[50]!==O||t[51]!==G||t[52]!==_||t[53]!==D||t[54]!==C||t[55]!==B||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:d,onKeyDown:T,style:P,children:[q,O,G,_,D,C,B]}),t[46]=T,t[47]=d,t[48]=P,t[49]=q,t[50]=O,t[51]=G,t[52]=_,t[53]=D,t[54]=C,t[55]=B,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Ve=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),Ne=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Le=p=>{const e=Ne("","");for(const t of p){const r=Ve(t.path);if(!r)continue;const x=r.split("/").filter(Boolean).slice(0,-1);let g=e;if(g.files.push(t),x.length>0){let d="";for(const a of x){d=d?`${d}/${a}`:a;const h=g.children.get(a);if(h){h.files.push(t),g=h;continue}const S=Ne(d,a);S.files.push(t),g.children.set(a,S),g=S}}g.directFiles.push(t)}return e},Oe=(p,e)=>{const t=[],r=(w,x)=>{const g=Array.from(w.children.values()).sort((a,h)=>a.path.localeCompare(h.path));for(const a of g)t.push({key:a.id,kind:"directory",depth:x,directory:a}),e.has(a.path)&&r(a,x+1);const d=[...w.directFiles].sort((a,h)=>a.path.localeCompare(h.path));for(const a of d)t.push({key:`file:${Ve(a.path)}`,kind:"file",depth:x,file:a})};return r(p,0),t},Ge=1e3,Ce=34,de=30,le="pl-0 pr-2",me=(p,e)=>`${p} ${e}`,Qe=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:r=!1,headerBackgroundClassName:w="bg-sidebar",onVisiblePathsChange:x,onRevertAll:g,onRevertDirectory:d})=>{const{t:a}=J(),h=N.useRef(null),f=ke(i=>i.gitChangesViewMode)==="tree",b=N.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,k]=N.useState(new Set),[v,o]=N.useState(new Set),[j,c]=N.useState(!1),[u,I]=N.useState(null),H=N.useMemo(()=>b.map(i=>Le(i.entries)),[b]),R=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{Array.from(H[l]?.children.values()??[]).forEach(m=>{i.push(me(n.id,m.path))})}),i},[H,b]);N.useEffect(()=>{f&&o(i=>{const n=new Set,l=new Set(R);return i.forEach(m=>{(m.slice(m.indexOf(" ")+1).includes("/")||l.has(m))&&n.add(m)}),R.forEach(m=>n.add(m)),n})},[f,R]);const A=N.useMemo(()=>{const i=[];return b.forEach((n,l)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:l}),!V.has(n.id)){if(f){const m=new Set;v.forEach(C=>{C.startsWith(`${n.id} `)&&m.add(C.slice(n.id.length+1))}),Oe(H[l],m).forEach(C=>{C.kind==="file"?i.push({type:"file",key:`${n.id}:${C.key}`,groupIndex:l,file:C.file,depth:C.depth}):i.push({type:"directory",key:`${n.id}:${C.key}`,groupIndex:l,directory:C.directory,depth:C.depth})});return}n.entries.forEach(m=>{i.push({type:"file",key:`${n.id}:file:${m.path}`,groupIndex:l,file:m,depth:0})})}}),g&&b.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,v,f,g,H,b]),z=A.length,T=z>=Ge,M=ze({count:z,enabled:T,getScrollElement:()=>h.current,estimateSize:()=>Ce,overscan:12,getItemKey:i=>A[i]?.key??i}),y=M.getVirtualItems(),$=N.useMemo(()=>{if(!T)return 0;const i=h.current?.scrollTop??0;return y.find(l=>l.end>i)?.index??0},[T,y,h]);N.useEffect(()=>{if(!x)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(z===0){x([]);return}if(!T){const n=[];for(const l of A)if(l.type==="file"&&(n.push(l.file.path),n.length>=de))break;x(n);return}x(A.slice($,$+Math.ceil((h.current?.clientHeight??0)/Ce)+de).map(n=>i(n)).filter(n=>!!n).slice(0,de))},[x,z,A,T,$]);const W=N.useCallback(i=>{k(n=>{const l=new Set(n);return l.has(i)?l.delete(i):l.add(i),l})},[]),L=N.useCallback((i,n)=>{o(l=>{const m=new Set(l),D=me(i,n);return m.has(D)?m.delete(D):m.add(D),m})},[]),F=N.useMemo(()=>{const i=new Set;return b.forEach(n=>n.entries.forEach(l=>i.add(l.path))),Array.from(i)},[b]),X=F.length,P=u?r||u.paths.some(i=>t.has(i)):!1,q=N.useCallback(async()=>{!g||r||F.length===0||(await g(F),c(!1))},[F,r,g]),K=N.useCallback(async()=>{!d||!u||P||(await d(u.paths),I(null))},[P,d,u]),O=N.useCallback((i,n)=>{const l=V.has(i.id),m=i.entries.length;return s.jsxs("div",{className:Z("sticky top-0 z-10 flex items-center gap-2 py-2",w,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(D=>D.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!l,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:m}),s.jsx(E,{name:"arrow-down-s",className:Z("size-3.5 shrink-0 text-muted-foreground transition-transform",l&&"-rotate-90")})]})]})},[V,w,W]),G=N.useCallback((i,n,l)=>{const m=v.has(me(i.id,n.path)),D=n.files.map(B=>B.path),C=r||D.some(B=>t.has(B));return s.jsxs("div",{className:Z("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${l*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":m?a("gitView.changes.collapseDirectoryAria",{path:n.path}):a("gitView.changes.expandDirectoryAria",{path:n.path}),children:[m?s.jsx(E,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx(E,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&d?s.jsx("button",{type:"button",onClick:()=>I({path:n.path,paths:D,count:D.length}),disabled:C,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":a("gitView.changes.revertDirectoryAria",{path:n.path}),title:a("gitView.changes.revertDirectoryTooltip"),children:C?s.jsx(E,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx(E,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(B=>B.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:a(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[v,r,d,t,a,L]),_=N.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:Z("flex justify-end py-2",le),children:s.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>c(!0),disabled:r,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx(E,{name:"arrow-go-back",className:"size-3.5"}),a("gitView.changes.revertAll")]})});const l=b[i.groupIndex];if(!l)return null;if(i.type==="header")return O(l,n);if(i.type==="directory")return G(l,i.directory,i.depth);const m=i.file;return s.jsx($e,{file:m,actionLabel:l.getActionLabel(m.path),actionSymbol:l.actionSymbol,onAction:()=>l.onActionFile(m.path),stats:e?.[m.path],onViewDiff:()=>l.onViewDiff(m.path),onRevert:()=>l.onRevertFile(m.path),isReverting:t.has(m.path)||r,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!f,showRevert:l.showRevertActions!==!1})},[e,r,f,G,O,t,a,b]),Q=N.useCallback(i=>{const n=A[i],l=A[i-1];return!n||!l||n.type!=="file"&&n.type!=="directory"||l.type!=="file"&&l.type!=="directory"?!1:l.groupIndex===n.groupIndex},[A]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Te,{ref:h,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:T?s.jsx("div",{style:{height:M.getTotalSize(),position:"relative"},children:y.map(i=>{const n=A[i.index];return n?s.jsx("div",{"data-index":i.index,ref:M.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:Z(Q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":a("gitView.changes.changedFilesAria"),children:A.map((i,n)=>s.jsx("div",{className:Z("relative",Q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:_(i,n===0)},i.key))})}),s.jsx(Ie,{containerRef:h,disableHorizontal:!0})]}),s.jsx(fe,{open:j,onOpenChange:i=>{!r&&!i&&c(!1)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertAllDialogTitle")}),s.jsx(xe,{children:X===1?a("gitView.changes.revertAllDescriptionSingle",{count:X}):a("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>c(!1),disabled:r,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{q()},disabled:r,children:a(r?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(fe,{open:!!u,onOpenChange:i=>{!P&&!i&&I(null)},children:s.jsxs(ue,{className:"max-w-md",children:[s.jsxs(pe,{children:[s.jsx(ge,{children:a("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(xe,{children:u?u.count===1?a("gitView.changes.revertDirectoryDescriptionSingle",{count:u.count,path:u.path}):a("gitView.changes.revertDirectoryDescriptionPlural",{count:u.count,path:u.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Y,{variant:"outline",size:"sm",onClick:()=>I(null),disabled:P,children:a("gitView.common.cancel")}),s.jsx(Y,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:P||!u,children:a(P?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,re=200,Ke=p=>{const e=oe.c(23),{value:t,onChange:r,onSubmit:w,placeholder:x,disabled:g,hasTouchInput:d,isMobile:a}=p,h=g===void 0?!1:g,S=d===void 0?!1:d,f=a===void 0?!1:a,{t:b}=J(),V=N.useRef(null),k=ke(_e);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const y=V.current;if(!y)return;const $=document.activeElement===y,W=()=>{y.style.height=`${he}px`;const F=y.scrollHeight,X=Math.min(Math.max(F,he),re);y.style.height=`${X}px`,y.style.overflowY=F>re?"auto":"hidden",F>re&&!$&&(y.scrollTop=y.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=v):v=e[0];let o;e[1]!==t?(o=[t],e[1]=t,e[2]=o):o=e[2],N.useLayoutEffect(v,o);let j;e[3]!==r?(j=y=>r(y.target.value),e[3]=r,e[4]=j):j=e[4];let c;e[5]!==w?(c=y=>{y.key==="Enter"&&(y.metaKey||y.ctrlKey)&&!y.shiftKey&&!y.altKey&&(y.preventDefault(),w?.())},e[5]=w,e[6]=c):c=e[6];let u;e[7]!==x||e[8]!==b?(u=x??b("gitView.commit.messagePlaceholder"),e[7]=x,e[8]=b,e[9]=u):u=e[9];const I=S?"on":"off",H=S?"sentences":"off",R=f||k,A=h&&"opacity-50";let z;e[10]!==A?(z=Z("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",A),e[10]=A,e[11]=z):z=e[11];let T;e[12]===Symbol.for("react.memo_cache_sentinel")?(T={minHeight:he,maxHeight:re},e[12]=T):T=e[12];let M;return e[13]!==h||e[14]!==H||e[15]!==R||e[16]!==z||e[17]!==j||e[18]!==c||e[19]!==u||e[20]!==I||e[21]!==t?(M=s.jsx("textarea",{ref:V,value:t,onChange:j,onKeyDown:c,placeholder:u,rows:1,disabled:h,autoCorrect:I,autoCapitalize:H,spellCheck:R,className:z,style:T}),e[13]=h,e[14]=H,e[15]=R,e[16]=z,e[17]=j,e[18]=c,e[19]=u,e[20]=I,e[21]=t,e[22]=M):M=e[22],M};function _e(p){return p.inputSpellcheckEnabled}const Be=p=>{const e=oe.c(30),{highlights:t,onInsert:r}=p,{t:w}=J();if(t.length===0)return null;let x;e[0]!==t||e[1]!==r?(x=()=>{r(t)},e[0]=t,e[1]=r,e[2]=x):x=e[2];const g=x;let d;e[3]!==w?(d=w("gitView.commit.aiHighlights.title"),e[3]=w,e[4]=d):d=e[4];let a;e[5]!==d?(a=s.jsx("p",{className:"typography-micro text-muted-foreground",children:d}),e[5]=d,e[6]=a):a=e[6];let h;e[7]!==w?(h=w("gitView.commit.aiHighlights.insertAria"),e[7]=w,e[8]=h):h=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(E,{name:"arrow-down",className:"size-4"}),e[9]=S):S=e[9];let f;e[10]!==g||e[11]!==h?(f=s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"ghost",size:"icon",className:"size-6",onClick:g,"aria-label":h,children:S})}),e[10]=g,e[11]=h,e[12]=f):f=e[12];let b;e[13]!==w?(b=w("gitView.commit.aiHighlights.insertTooltip"),e[13]=w,e[14]=b):b=e[14];let V;e[15]!==b?(V=s.jsx(we,{sideOffset:8,children:b}),e[15]=b,e[16]=V):V=e[16];let k;e[17]!==f||e[18]!==V?(k=s.jsxs(be,{children:[f,V]}),e[17]=f,e[18]=V,e[19]=k):k=e[19];let v;e[20]!==a||e[21]!==k?(v=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[a,k]}),e[20]=a,e[21]=k,e[22]=v):v=e[22];let o;e[23]!==t?(o=t.map(Ue),e[23]=t,e[24]=o):o=e[24];let j;e[25]!==o?(j=s.jsx("ul",{className:"space-y-1",children:o}),e[25]=o,e[26]=j):j=e[26];let c;return e[27]!==v||e[28]!==j?(c=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[v,j]}),e[27]=v,e[28]=j,e[29]=c):c=e[29],c};function Ue(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const Ze=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:r,onCommitMessageChange:w,generatedHighlights:x,onInsertHighlights:g,onGenerateMessage:d,isGeneratingMessage:a,onCommit:h,onCommitAndPush:S,commitAction:f,hasPendingIndexMutation:b,gitmojiEnabled:V,onOpenGitmojiPicker:k}=p,v=b===void 0?!1:b,{t:o}=J(),j=t>0;let c;e[0]!==f||e[1]!==r||e[2]!==v||e[3]!==j?(c=r.trim()&&j&&f===null&&!v,e[0]=f,e[1]=r,e[2]=v,e[3]=j,e[4]=c):c=e[4];const u=c,{isMobile:I,hasTouchInput:H}=Me();let R;e[5]!==o?(R=o("gitView.commit.title"),e[5]=o,e[6]=R):R=e[6];let A;e[7]!==R?(A=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:R}),e[7]=R,e[8]=A):A=e[8];let z;e[9]!==j||e[10]!==o?(z=j?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:o("gitView.commit.stageFilesHint")}),e[9]=j,e[10]=o,e[11]=z):z=e[11];let T;e[12]!==A||e[13]!==z?(T=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[A,z]}),e[12]=A,e[13]=z,e[14]=T):T=e[14];let M;e[15]!==x||e[16]!==g?(M=s.jsx(Be,{highlights:x,onInsert:g}),e[15]=x,e[16]=g,e[17]=M):M=e[17];let y;e[18]!==u||e[19]!==a||e[20]!==h?(y=()=>{u&&!a&&h()},e[18]=u,e[19]=a,e[20]=h,e[21]=y):y=e[21];let $;e[22]!==o?($=o("gitView.commit.messagePlaceholder"),e[22]=o,e[23]=$):$=e[23];const W=f!==null;let L;e[24]!==r||e[25]!==H||e[26]!==I||e[27]!==w||e[28]!==W||e[29]!==y||e[30]!==$?(L=s.jsx(Ke,{value:r,onChange:w,onSubmit:y,placeholder:$,disabled:W,hasTouchInput:H,isMobile:I}),e[24]=r,e[25]=H,e[26]=I,e[27]=w,e[28]=W,e[29]=y,e[30]=$,e[31]=L):L=e[31];let F;e[32]!==V||e[33]!==k||e[34]!==o?(F=V&&s.jsxs(Y,{variant:"outline",size:"sm",onClick:k,className:"w-fit",type:"button",children:[s.jsx(E,{name:"emotion-happy",className:"size-4"}),o("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=k,e[34]=o,e[35]=F):F=e[35];const X=a||f!==null||v||t===0;let P;e[36]!==o?(P=o("gitView.commit.generateAria"),e[36]=o,e[37]=P):P=e[37];let q;e[38]!==a?(q=a?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=a,e[39]=q):q=e[39];let K;e[40]!==o?(K=o("gitView.commit.generate"),e[40]=o,e[41]=K):K=e[41];let O;e[42]!==K?(O=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=O):O=e[43];let G;e[44]!==d||e[45]!==X||e[46]!==P||e[47]!==q||e[48]!==O?(G=s.jsxs(Y,{variant:"outline",size:"sm",onClick:d,disabled:X,type:"button","aria-label":P,className:"commit-actions__btn",children:[q,O]}),e[44]=d,e[45]=X,e[46]=P,e[47]=q,e[48]=O,e[49]=G):G=e[49];let _;e[50]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("div",{className:"flex-1"}),e[50]=_):_=e[50];const Q=!u||a;let i;e[51]!==o?(i=o("gitView.commit.commitAria"),e[51]=o,e[52]=i):i=e[52];let n;e[53]!==f||e[54]!==o?(n=f==="commit"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:o("gitView.commit.commit")})]}),e[53]=f,e[54]=o,e[55]=n):n=e[55];let l;e[56]!==h||e[57]!==Q||e[58]!==i||e[59]!==n?(l=s.jsx(Y,{size:"sm",variant:"outline",onClick:h,disabled:Q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=h,e[57]=Q,e[58]=i,e[59]=n,e[60]=l):l=e[60];let m;e[61]!==u||e[62]!==f||e[63]!==a||e[64]!==I||e[65]!==S||e[66]!==o?(m=I?s.jsxs(be,{children:[s.jsx(ye,{asChild:!0,children:s.jsx(Y,{variant:"default",size:"sm",onClick:()=>S(),disabled:!u||a,className:"h-7 w-7 p-0","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(we,{side:"top",children:s.jsx("p",{children:o("gitView.commit.push")})})]}):s.jsx(Y,{size:"sm",variant:"default",onClick:()=>S(),disabled:!u||a,className:"commit-actions__btn","aria-label":o("gitView.commit.pushAria"),children:f==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx(E,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:o("gitView.commit.push")})]})}),e[61]=u,e[62]=f,e[63]=a,e[64]=I,e[65]=S,e[66]=o,e[67]=m):m=e[67];let D;e[68]!==G||e[69]!==l||e[70]!==m?(D=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[G,_,l,m]}),e[68]=G,e[69]=l,e[70]=m,e[71]=D):D=e[71];let C;e[72]!==L||e[73]!==F||e[74]!==D||e[75]!==M?(C=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[M,L,F,D]}),e[72]=L,e[73]=F,e[74]=D,e[75]=M,e[76]=C):C=e[76];let B;return e[77]!==C||e[78]!==T?(B=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[T,C]}),e[77]=C,e[78]=T,e[79]=B):B=e[79],B},Je=({open:p,onOpenChange:e,targetBranch:t,changedFileCount:r,onCommitAndSwitch:w,onGenerateMessage:x,onRevertAndSwitch:g})=>{const{t:d}=J(),[a,h]=N.useState(""),[S,f]=N.useState(null),[b,V]=N.useState(!1),k=S!==null;N.useEffect(()=>{p||(h(""),V(!1))},[p]);const v=async()=>{f("generate");try{const c=await x();c&&h(c)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},o=async()=>{f("commit");try{let c=a.trim();if(!c){if(c=(await x()).trim(),!c){ae.error(d("gitView.toast.enterCommitMessage"));return}h(c)}await w(c,b)}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}},j=async()=>{f("revert");try{await g()}catch(c){ae.error(c instanceof Error?c.message:d("gitView.dirtySwitch.actionFailed"))}finally{f(null)}};return s.jsx(fe,{open:p,onOpenChange:c=>{k||e(c)},children:s.jsx(ue,{className:"max-w-md w-[calc(100vw-2rem)]",children:s.jsxs("div",{className:"flex flex-col gap-4",children:[s.jsxs(pe,{children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(E,{name:"alert",className:"size-5 shrink-0 text-[var(--status-warning)]"}),s.jsx(ge,{children:d("gitView.dirtySwitch.title")})]}),s.jsx(xe,{children:r===1?d("gitView.dirtySwitch.descriptionSingle",{branch:t}):d("gitView.dirtySwitch.descriptionPlural",{branch:t,count:r})})]}),s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border/60 px-3 py-2 focus-within:border-border",children:[s.jsx("input",{value:a,onChange:c=>h(c.target.value),placeholder:d("gitView.commit.messagePlaceholder"),disabled:k,onKeyDown:c=>{c.key==="Enter"&&!k&&(c.preventDefault(),o())},className:"min-w-0 flex-1 bg-transparent typography-meta text-foreground outline-none placeholder:text-muted-foreground"}),s.jsx("button",{type:"button",onClick:()=>{v()},disabled:k,"aria-label":d("gitView.commit.generate"),title:d("gitView.commit.generate"),className:"shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50",children:S==="generate"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx(E,{name:"ai-generate-2",className:"size-4 text-primary"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Pe,{checked:b,onChange:V,disabled:k,ariaLabel:d("gitView.dirtySwitch.pushAfterCommit")}),s.jsx("span",{className:"typography-ui-label text-foreground cursor-pointer select-none",onClick:()=>!k&&V(!b),children:d("gitView.dirtySwitch.pushAfterCommit")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[s.jsxs(Y,{variant:"destructive",size:"sm",onClick:()=>{j()},disabled:k,className:"gap-2",children:[S==="revert"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.revertAndSwitch")]}),s.jsxs(Y,{variant:"default",size:"sm",onClick:()=>{o()},disabled:k,className:"gap-2",children:[S==="commit"?s.jsx(E,{name:"loader-4",className:"size-4 animate-spin"}):null,d("gitView.dirtySwitch.commitAndSwitch")]})]})]})})})};export{Qe as C,Je as D,Ze as a};
@@ -0,0 +1,17 @@
1
+ import{f as ot,R as s,c as Ws,j as r,r as at}from"./vendor-react-BUCujlKS.js";import{Z as Pa,_ as Ma,$ as Da,a0 as za,t as Xe,a as Us,u as vt,dA as La,G as Ks,A as Aa,h as Hs,a5 as qs,e as Ia,dy as Oa,a4 as Ba,dz as $a}from"./index-DVwMarHI.js";import{f as Ht,y as Gs,ac as gi,bY as _a,h as q,hI as Wa,fw as Ua,T as lr,B as O,I as F,W as Ka,N as Ha,bb as qa,ae as Ga,cc as Xa,eg as Xs,hJ as Js,hK as Ja,h6 as Qa,fx as Ya,t as Q,l as Qs,au as pn,c7 as or,cK as Za,b as eo,hL as Dr,bK as to,av as gn,hM as Ys,c8 as Zs,c9 as ei,gm as ro,hN as no,hO as so,hP as io,bL as vi,bM as xi,bN as wi,bO as bi,bP as yi,bQ as ji,ao as jn,ap as Fn,aw as Ar,ar as Nn,b9 as Ir,bR as vn,ax as xn,c4 as ti,a7 as Ot,a8 as Bt,a9 as $t,bI as ao,bJ as oo,g as Br,ba as lo,bl as co}from"./useAppFontEffects-CPKeOpUo.js";import{a9 as uo,J as fo,K as mo,L as ho,M as po,Q as go}from"./runtimeEndpointReset-Bg5gx18H.js";import{c as ri,s as vo,P as wn,C as xo}from"./shikiHighlight-CRl0SUC9.js";import{a as wo}from"./vendor-codemirror-state-C9awkmn-.js";import{E as Nt}from"./vendor-codemirror-view-CiLROUVV.js";import{V as bo,J as yo,F as jo}from"./JsonTreeView-D_hpXBnF.js";import{ensurePierreThemeRegistered as ni,getResolvedShikiTheme as Fo}from"./appThemeRegistry-BK0dHKa6.js";import{V as No,W as Co}from"./Virtualizer-CZlLSacm.js";import{V as So}from"./Virtualizer-D_a8gKmg.js";import{u as zr,c as ko,e as Ro}from"./scheduledTasksApi-BW0Etzwz.js";import{D as To}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Eo,u as Vo,n as Po}from"./useInlineCommentController-BiWz4AVb.js";import{b as Mo}from"./CodeMirrorCommentWidgets-B1Gizi3a.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BPAANqvH.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-DdV8vhHn.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-Bg4AEeCr.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-z7hfnS8n.js";import"./computeVirtualFileMetrics-BBI7ZwrC.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isFilePlainText-DW_xMer1.js";import"./registerCustomTheme-BBXUCRnG.js";function si(a){const e=ot.c(41),{containerRef:n,filePath:d,fileContent:x}=a,{t:g}=Ht(),w=Gs($o),v=Gs(Bo),f=gi(),j=_a(Oo),[m,y]=s.useState(null),[N,S]=s.useState(""),[C,T]=s.useState(!1),o=s.useRef(!1),E=s.useRef(null),D=s.useRef(null),[A,V]=s.useState(null);let P;e[0]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{y(null),S(""),T(!1),o.current=!1,D.current=null,V(null)},e[0]=P):P=e[0];const M=P;let k,I;e[1]!==n?(k=()=>{const $=n.current;if(!$)return;const H=()=>{if(o.current)return;const ne=window.getSelection(),ke=ne?.toString().trim()??"";if(!ne||!ke||ne.rangeCount===0){M();return}const oe=ne.getRangeAt(0);if(!$.contains(oe.commonAncestorContainer)){M();return}const le=oe.getBoundingClientRect();D.current=oe.cloneRange(),S(ke),y({x:le.left+le.width/2,y:le.top-10})},re=ne=>{E.current?.contains(ne.target)||o.current&&M()};return document.addEventListener("selectionchange",H),document.addEventListener("pointerdown",re),()=>{document.removeEventListener("selectionchange",H),document.removeEventListener("pointerdown",re)}},I=[n,M],e[1]=n,e[2]=k,e[3]=I):(k=e[2],I=e[3]),s.useEffect(k,I);let _;e[4]!==x?(_=$=>{const H=de=>x.slice(0,de).split(`
2
+ `).length,re=Ao,ne=(de,Ve)=>{for(const Pe of re(de)){const Re=x.indexOf(Pe,Ve);if(Re>=0)return Re}return-1},ke=$.length>=8?x.indexOf($):-1;if(ke>=0){const de=H(ke);return{start:de,end:de+$.split(`
3
+ `).length-1}}const oe=$.split(`
4
+ `).map(Lo).filter(Boolean);if(oe.length===0)return null;const le=ne(oe[0],0);if(le<0)return null;const be=H(le);if(oe.length===1)return{start:be,end:be};const Ee=ne(oe[oe.length-1],le);return Ee<0?null:{start:be,end:Math.max(be,H(Ee))}},e[4]=x,e[5]=_):_=e[5];const L=_;let X;e[6]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{const $=D.current;if(!$){V(null);return}V(Wa($))},e[6]=X):X=e[6];const Ce=X;let W,Y;e[7]!==C?(W=()=>{if(!C)return;let $=null;const H=()=>{$===null&&($=window.requestAnimationFrame(()=>{$=null,Ce()}))};return document.addEventListener("scroll",H,{capture:!0,passive:!0}),window.addEventListener("resize",H),()=>{$!==null&&window.cancelAnimationFrame($),document.removeEventListener("scroll",H,{capture:!0}),window.removeEventListener("resize",H)}},Y=[C,Ce],e[7]=C,e[8]=W,e[9]=Y):(W=e[8],Y=e[9]),s.useEffect(W,Y);let ee;e[10]!==N?(ee=()=>{N&&(T(!0),o.current=!0,Ce(),window.getSelection()?.removeAllRanges())},e[10]=N,e[11]=ee):ee=e[11];const ce=ee;let te;e[12]!==j||e[13]!==w||e[14]!==f||e[15]!==d||e[16]!==v||e[17]!==L||e[18]!==N?(te=$=>{const H=w??(v?"draft":null);if(!N||!H||!f){M();return}const re=L(N);j({directory:f,sessionKey:H},{source:"file-quote",fileLabel:d,startLine:re?.start??0,endLine:re?.end??0,code:N,language:"",text:$.trim()}),M(),queueMicrotask(zo)},e[12]=j,e[13]=w,e[14]=f,e[15]=d,e[16]=v,e[17]=L,e[18]=N,e[19]=te):te=e[19];const Se=te;if(!m)return null;let B;e[20]!==C||e[21]!==L||e[22]!==N?(B=C?L(N):null,e[20]=C,e[21]=L,e[22]=N,e[23]=B):B=e[23];const ve=B;let xe;e[24]!==m.x||e[25]!==m.y?(xe={left:m.x,top:m.y,transform:"translate(-50%, -100%)"},e[24]=m.x,e[25]=m.y,e[26]=xe):xe=e[26];let ue;e[27]!==C||e[28]!==A?(ue=C&&A&&A.length>0?Ws.createPortal(r.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:A.map(Do)}),document.body):null,e[27]=C,e[28]=A,e[29]=ue):ue=e[29];let ae;e[30]!==C||e[31]!==d||e[32]!==ve||e[33]!==ce||e[34]!==Se||e[35]!==g?(ae=C?r.jsx("div",{className:"w-[min(420px,80vw)]",children:r.jsx(Eo,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Se,onCancel:M})}):r.jsx("div",{className:q("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:r.jsx("button",{type:"button",onClick:ce,className:q("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:g("chat.textSelection.title.commentOnSelection"),children:g("chat.textSelection.actions.comment")})}),e[30]=C,e[31]=d,e[32]=ve,e[33]=ce,e[34]=Se,e[35]=g,e[36]=ae):ae=e[36];let we;return e[37]!==xe||e[38]!==ue||e[39]!==ae?(we=Ws.createPortal(r.jsxs("div",{ref:E,className:"fixed z-50",style:xe,children:[ue,ae]}),document.body),e[37]=xe,e[38]=ue,e[39]=ae,e[40]=we):we=e[40],we}function Do(a,e){return r.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function zo(){Ua()}function Lo(a){return a.trim()}function Ao(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Io)}function Io(a){return a.length>=8}function Oo(a){return a.addDraft}function Bo(a){return a.newSessionDraft?.open}function $o(a){return a.currentSessionId}const _o=(a,e)=>{if(!e)return null;const n=Number.parseInt(a.trim(),10);return!Number.isFinite(n)||n<1?null:Math.min(n,e.state.doc.lines)},ii=(a,e)=>{const n=a.state.doc.lineAt(e.main.head);return{lineNumber:n.number,character:e.main.head-n.from+1,selection:e}},ai=(a,e,n)=>{const d=a.state.doc.line(e),x=Math.max(1,Math.min(n,d.length+1)),g=d.from+x-1;a.dispatch({selection:wo.cursor(g),effects:Nt.scrollIntoView(g,{y:"center"})})};function Wo({open:a,onOpenChange:e,view:n,variant:d="overlay"}){const{t:x}=Ht(),[g,w]=s.useState(""),v=s.useRef(null),f=s.useRef(!1),j=s.useRef(null),m=s.useRef(null),y=s.useMemo(()=>_o(g,n),[g,n]);s.useEffect(()=>{!a||!n||(f.current=!1,v.current=ii(n,n.state.selection),w(""))},[a,n]),s.useEffect(()=>{a&&window.requestAnimationFrame(()=>{m.current?.focus(),m.current?.select()})},[a]),s.useEffect(()=>{if(!(!a||!n||!v.current)){if(y===null){const{selection:o}=v.current;n.dispatch({selection:o,effects:Nt.scrollIntoView(o.main.from,{y:"center"})});return}ai(n,y,v.current.character)}},[y,a,n]);const N=s.useCallback(()=>{if(!n||f.current||!v.current)return;const{selection:o}=v.current;n.dispatch({selection:o,effects:Nt.scrollIntoView(o.main.from,{y:"center"})})},[n]),S=s.useCallback(o=>{o||N(),e(o)},[e,N]),C=s.useCallback(()=>{!n||y===null||!v.current||(f.current=!0,ai(n,y,v.current.character),e(!1),n.focus())},[y,e,n]);s.useEffect(()=>{if(!a)return;const o=D=>{const A=j.current,V=D.target;!A||!(V instanceof Node)||A.contains(V)||S(!1)},E=D=>{D.key==="Escape"&&(D.preventDefault(),S(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",E,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",E,!0)}},[S,a,d]);const T=s.useMemo(()=>{if(!n)return x("goToLineDialog.helper.editorUnavailable");if(y===null){const o=v.current??ii(n,n.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:n.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:y})},[y,x,n]);return d==="inline"?a?r.jsxs("div",{ref:j,className:"ml-1 flex h-6 items-center gap-1",children:[r.jsx(lr,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>w(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),r.jsx(O,{variant:"outline",size:"xs",onClick:C,disabled:!n||y===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:r.jsx("div",{ref:j,className:q("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:r.jsxs("div",{className:"min-w-0",children:[r.jsx(lr,{ref:m,type:"number",min:1,step:1,inputMode:"numeric",value:g,onChange:o=>w(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),C())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),r.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:T})]})})}const Uo=(a,e)=>{const n=e.trim().toLowerCase(),d=[];if(!n)return d;const x=a.toLowerCase();let g=0;for(;;){const w=x.indexOf(n,g);if(w===-1)break;d.push({start:w,end:w+n.length}),g=w+n.length}return d},_r="data-md-find",bn="data-md-find-current",Fi="rounded-[2px] bg-status-warning/30 text-foreground",Ko="rounded-[2px] bg-status-warning/60 text-foreground",Ho=120,qo=a=>a instanceof Element&&a.hasAttribute(_r),Go=a=>a.target instanceof Element&&a.target.hasAttribute(_r)?!0:[...a.addedNodes].some(e=>qo(e)),Ni=a=>{const e=new Set;a.querySelectorAll(`mark[${_r}]`).forEach(n=>{const d=n.parentNode;d&&(d.replaceChild(document.createTextNode(n.textContent??""),n),e.add(d))}),e.forEach(n=>n.normalize())},Xo=(a,e)=>{Ni(a);const n=e.trim().toLowerCase();if(!n)return[];const d=[],x=document.createTreeWalker(a,NodeFilter.SHOW_TEXT,{acceptNode(w){const v=w.parentElement;return!v||v.closest("svg, script, style")?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}}),g=[];for(;x.nextNode();){const w=x.currentNode;w instanceof Text&&g.push(w)}for(const w of g){const v=w.nodeValue??"";if(!v)continue;const f=Uo(v,n);if(f.length===0)continue;const j=w.parentNode;if(!j)continue;const m=document.createDocumentFragment();let y=0;for(const N of f){N.start>y&&m.appendChild(document.createTextNode(v.slice(y,N.start)));const S=document.createElement("mark");S.setAttribute(_r,""),S.className=Fi,S.textContent=v.slice(N.start,N.end),m.appendChild(S),d.push(S),y=N.end}y<v.length&&m.appendChild(document.createTextNode(v.slice(y))),j.replaceChild(m,w)}return d},oi=({containerRef:a,open:e,onOpenChange:n,focusNonce:d,className:x})=>{const{t:g}=Ht(),[w,v]=s.useState(""),[f,j]=s.useState(0),[m,y]=s.useState(0),N=s.useRef(null),S=s.useRef([]),C=s.useRef(w);C.current=w;const T=s.useRef(null),o=s.useRef(null),E=s.useCallback((k,I=!1)=>{const _=a.current;if(!_){S.current=[],j(0),y(0);return}S.current=Xo(_,k);const L=S.current.length;j(L),y(X=>!I||L===0?0:Math.min(X,L-1))},[a]),D=s.useCallback((k,I=!1)=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{T.current=null,E(k,I)},Ho)},[E]);s.useEffect(()=>()=>{T.current&&clearTimeout(T.current)},[]);const A=s.useCallback(()=>{n(!1);const k=o.current;o.current=null,k?.isConnected&&k.focus()},[n]);s.useEffect(()=>{const k=a.current;if(!e||!k)return;const I=new MutationObserver(_=>{!C.current.trim()||!_.some(X=>!Go(X))||D(C.current,!0)});return I.observe(k,{childList:!0,subtree:!0,characterData:!0}),()=>{I.disconnect(),Ni(k)}},[a,e,D]),s.useEffect(()=>{if(!e)return;const k=document.activeElement;k instanceof HTMLElement&&!o.current&&(o.current=k),N.current?.focus()},[e]),s.useEffect(()=>{e&&d>0&&(N.current?.focus(),N.current?.select())},[e,d]),s.useEffect(()=>{const k=a.current;if(!k||(k.querySelectorAll(`mark[${bn}]`).forEach(_=>{_.removeAttribute(bn),_.className=Fi}),f===0))return;const I=S.current[Math.min(Math.max(m,0),f-1)];I&&(I.setAttribute(bn,""),I.className=Ko,I.scrollIntoView({block:"nearest"}))},[a,m,f]);const V=s.useCallback(()=>{y(k=>f===0?0:(k+1)%f)},[f]),P=s.useCallback(()=>{y(k=>f===0?0:(k-1+f)%f)},[f]),M=s.useCallback(k=>{k.key==="Enter"?(k.preventDefault(),k.shiftKey?P():V()):k.key==="Escape"&&(k.preventDefault(),A())},[A,V,P]);return e?r.jsxs("div",{className:q("absolute right-3 top-3 z-10 flex items-center gap-1 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-1.5 py-1 shadow-lg",x),children:[r.jsx(F,{name:"search",className:"ml-0.5 size-3.5 text-muted-foreground"}),r.jsx(lr,{ref:N,value:w,onChange:k=>{v(k.target.value),D(k.target.value)},onKeyDown:M,placeholder:g("filesView.preview.find.placeholder"),"aria-label":g("filesView.preview.find.placeholder"),className:"h-7 w-40 rounded-md px-2 py-0 text-sm md:w-56"}),r.jsx("span",{className:"min-w-12 px-1 text-center typography-micro text-muted-foreground tabular-nums","aria-live":"polite","aria-label":f>0?g("filesView.preview.find.countAria",{current:m+1,total:f}):g("filesView.preview.find.noMatches"),children:w.trim()&&f===0?g("filesView.preview.find.noMatches"):f>0?`${m+1}/${f}`:""}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:P,title:g("filesView.preview.find.previousAria"),"aria-label":g("filesView.preview.find.previousAria"),disabled:f===0,children:r.jsx(F,{name:"arrow-up",className:"size-3.5"})}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:V,title:g("filesView.preview.find.nextAria"),"aria-label":g("filesView.preview.find.nextAria"),disabled:f===0,children:r.jsx(F,{name:"arrow-down",className:"size-3.5"})}),r.jsx(O,{type:"button",variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground",onClick:A,title:g("filesView.preview.find.closeAria"),"aria-label":g("filesView.preview.find.closeAria"),children:r.jsx(F,{name:"close",className:"size-3.5"})})]}):null},Jo=a=>{let e=!0;return{poll:async()=>{if(!e||a.isDirty())return!1;const n=a.getLoadedContent(),d=a.getLoadedRevision();try{const x=await a.readContent();if(!e||a.isDirty()||d!==a.getLoadedRevision())return!1;if(x===n)return!0;const g=await a.readContent();return!e||a.isDirty()||g!==x||d!==a.getLoadedRevision()?!1:(a.applyContent(x),!0)}catch{return!1}},dispose:()=>{e=!1}}},Qo=1,Yo=(a,e)=>e.size!==a.size||e.mtimeMs!==void 0&&a.mtimeMs!==void 0&&Math.abs(e.mtimeMs-a.mtimeMs)>=Qo;function li(){const a=ot.c(8),[e]=at.useState(Zo),n=at.useRef(!1);let d;a[0]!==e?(d=f=>{if(f==null){e.cleanUp(),n.current=!1;return}n.current||(n.current=!0,e.setup(f,f.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const x=d;let g,w;a[2]!==e?(g=()=>()=>{n.current=!1,e.cleanUp()},w=[e],a[2]=e,a[3]=g,a[4]=w):(g=a[3],w=a[4]),at.useLayoutEffect(g,w);let v;return a[5]!==x||a[6]!==e?(v={virtualizer:e,setScroller:x},a[5]=x,a[6]=e,a[7]=v):v=a[7],v}function Zo(){return new So}const _t=new Map,el=100;function Lr(a){const[e,n]=at.useState(null),d=at.useRef(null),x=at.useRef(null),g=at.useRef(null),w=at.useCallback((v,f)=>{v&&f instanceof bo&&(g.current={key:a,file:f,node:v});const j=d.current,m=x.current,y=()=>{d.current===j&&(j?.(),m?.())};f?queueMicrotask(y):y()},[a]);return at.useLayoutEffect(()=>{if(!e||!a)return;const v=_t.get(a)??{top:0,left:0};let f=!0;const j=()=>g.current?.key===a?g.current.file:null,m=E=>g.current?.key===a?g.current.node.shadowRoot?.querySelector(`[data-line][data-line-index="${E-1}"]`):null,y=()=>{S.disconnect(),C.disconnect()},N=()=>{if(!f)return;const E=j(),D=v.line&&E?.getLinePosition(v.line.number),A=v.line&&m(v.line.number);let V=v.top;v.line&&D&&(V=(E?.top??0)+D.top-v.line.offset),v.line&&A&&(V=e.scrollTop+A.getBoundingClientRect().top-e.getBoundingClientRect().top-v.line.offset),e.scrollTop=V,e.scrollLeft=v.left,(!v.line||A)&&Math.abs(e.scrollTop-V)<1&&Math.abs(e.scrollLeft-v.left)<1&&(f=!1,y())},S=new ResizeObserver(N),C=new MutationObserver(()=>{if(f){for(const E of e.children)S.observe(E);N()}});S.observe(e);for(const E of e.children)S.observe(E);C.observe(e,{childList:!0,subtree:!0});const T=()=>{if(f)return;const E=j(),D=E?.getNumericScrollAnchor(e.scrollTop-(E.top??0)),A=D&&m(D.lineNumber),V=A?A.getBoundingClientRect().top-e.getBoundingClientRect().top:null;if(_t.delete(a),_t.set(a,{top:e.scrollTop,left:e.scrollLeft,line:D&&V!==null&&V>=0&&V<e.clientHeight?{number:D.lineNumber,offset:V}:void 0}),_t.size>el){const P=_t.keys().next().value;P!==void 0&&_t.delete(P)}},o=()=>{f=!1,y()};return d.current=N,x.current=T,N(),e.addEventListener("scroll",T,{passive:!0}),e.addEventListener("wheel",o,{passive:!0}),e.addEventListener("touchstart",o,{passive:!0}),e.addEventListener("pointerdown",o,{passive:!0}),e.addEventListener("keydown",o),()=>{d.current=null,x.current=null,g.current?.key===a&&(g.current=null),y(),e.removeEventListener("scroll",T),e.removeEventListener("wheel",o),e.removeEventListener("touchstart",o),e.removeEventListener("pointerdown",o),e.removeEventListener("keydown",o)}},[a,e]),{setScroller:n,restore:w}}function tl(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function rl(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const nl='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function ci(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const sl=s.forwardRef(function({xml:e,readOnly:n,className:d,onChange:x},g){const w=s.useRef(e),v=s.useRef(null),f=s.useRef(!1),[j,m]=s.useState(ci),y=s.useRef(e),N=s.useRef(e);N.current!==e&&(N.current=e,y.current=e,w.current=e);const S=s.useRef(j);S.current!==j&&(S.current=j,y.current=w.current);const C=s.useRef(null);s.useEffect(()=>{const E=()=>m(ci());E();const D=new MutationObserver(E);return D.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>D.disconnect()},[]),s.useEffect(()=>{const E=setTimeout(()=>{C.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(E)},[]),s.useImperativeHandle(g,()=>({getXml:()=>w.current}));const T=s.useCallback(()=>{!e&&!f.current&&(f.current=!0,setTimeout(()=>{v.current?.template({})},500))},[e]),o=s.useCallback(E=>{w.current=E.xml,x?.(E.xml)},[x]);return r.jsx("div",{ref:C,className:q("h-full w-full",d),children:r.jsx(To,{ref:v,xml:y.current||nl,autosave:!0,urlParameters:{ui:n?"simple":j?"dark":"kennedy",spin:!0,libraries:!n,chrome:n,nav:n,layers:n,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:T,onAutoSave:o},j?"dark":"light")})}),il=a=>{const e=K(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const n=e.lastIndexOf("/");if(n<0)return e;if(n===0)return"/";const d=e.slice(0,n);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},al=a=>{const e=ot.c(8),{label:n,iconDataUrl:d}=a,[x,g]=s.useState(!1);let w;e[0]!==n?(w=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=w):w=e[1];const v=w;if(d&&!x){let m;e[2]===Symbol.for("react.memo_cache_sentinel")?(m=()=>g(!0),e[2]=m):m=e[2];let y;return e[3]!==d?(y=r.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:m}),e[3]=d,e[4]=y):y=e[4],y}let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=q("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=f):f=e[5];let j;return e[6]!==v?(j=r.jsx("span",{className:f,children:v}),e[6]=v,e[7]=j):j=e[7],j},ol=a=>a.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),K=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),n=e.startsWith("//");let d=e.replace(/\/+/g,"/");n&&!d.startsWith("//")&&(d=`/${d}`);const x=d==="/",g=/^[A-Za-z]:\/$/.test(d);return!x&&!g&&(d=d.replace(/\/+$/,"")),d},ll=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Kt=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,$r=(a,e)=>{const n=K(e),d=K(a);if(!n||!d)return!1;const x=Kt(n),g=Kt(d);return g===x||g.startsWith(`${x}/`)},ui=(a,e)=>{const n=K(e),d=K(a);if(!$r(d,n))return[];const g=d.slice(n.length).replace(/^\//,"").split("/"),w=[];let v=n;for(let f=0;f<g.length-1;f++)v=v?`${v}/${g[f]}`:g[f],w.push(v);return w},Or=(a,e)=>{if(!e)return"";const n=K(e);if(!a||!$r(n,a))return n;const d=n.slice(a.length);return d.startsWith("/")?d.slice(1):d},cl=new Set(["node_modules"]),ul=a=>{const e=ot.c(3),{status:n}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const x=d[n];let g;return e[1]!==x?(g=r.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=g):g=e[2],g},di=a=>{const e=ot.c(11),{name:n}=a,d=s.useRef(null),x=s.useRef(null),[g,w]=s.useState(!1);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const N=d.current,S=x.current;if(!N||!S)return;const C=()=>{w(S.scrollWidth>N.clientWidth+1)};C();const T=new ResizeObserver(C);return T.observe(N),T.observe(S),()=>{T.disconnect()}},e[0]=v):v=e[0];let f;e[1]!==n?(f=[n],e[1]=n,e[2]=f):f=e[2],s.useLayoutEffect(v,f);let j;e[3]!==n?(j=r.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:n}),e[3]=n,e[4]=j):j=e[4];let m;e[5]!==n||e[6]!==g?(m=g?r.jsxs("span",{className:"open-file-name-marquee-track",children:[r.jsx("span",{className:"open-file-name-marquee-item",children:n}),r.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:n})]}):r.jsx("span",{className:"block min-w-0 truncate",children:n}),e[5]=n,e[6]=g,e[7]=m):m=e[7];let y;return e[8]!==j||e[9]!==m?(y=r.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,m]}),e[8]=j,e[9]=m,e[10]=y):y=e[10],y},dl=a=>cl.has(a),fl=a=>{const e=K(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},ml=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("is a directory")||n.includes("eisdir")},fi=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("file not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")},Wt=2e5,hl=2e5;function pl(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let n=2166136261;for(let d=0;d<e.length;d+=1)n^=e.charCodeAt(d),n=n+((n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24))>>>0;return`${a.length}:${n.toString(16)}`}const gl=a=>{let e=0,n=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:n+=1);return e>n?`\r
5
+ `:`
6
+ `},Ci=a=>a.replace(/\r\n/g,`
7
+ `).replace(/\r/g,`
8
+ `),vl=(a,e)=>{const n=Ci(a);return e===`\r
9
+ `?n.replace(/\n/g,`\r
10
+ `):n},Si=(a,e)=>r.jsx(Ar,{filePath:a,extension:e}),mi=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},xl=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},yn=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},wl=a=>{const e=ot.c(76),{node:n,root:d,isExpanded:x,isActive:g,isMobile:w,isBrowserClient:v,alwaysShowActions:f,status:j,badge:m,permissions:y,downloadFile:N,contextMenuPath:S,setContextMenuPath:C,rightClickMenuPath:T,setRightClickMenuPath:o,onSelect:E,onToggle:D,onRevealPath:A,onOpenDialog:V}=a,{t:P}=Ht(),M=n.type==="directory",{canRename:k,canCreateFile:I,canCreateFolder:_,canDelete:L,canReveal:X}=y,Ce=!M&&!!N,W=X&&!v,Y=k||I||_||L||Ce||W;let ee;e[0]!==Y||e[1]!==n.path||e[2]!==o?(ee=fe=>{Y&&(fe?.preventDefault(),o(n.path))},e[0]=Y,e[1]=n.path,e[2]=o,e[3]=ee):ee=e[3];const ce=ee;let te;e[4]!==M||e[5]!==n||e[6]!==E||e[7]!==D?(te=()=>{M?D(n.path):E(n)},e[4]=M,e[5]=n,e[6]=E,e[7]=D,e[8]=te):te=e[8];const Se=te;let B;e[9]!==n.path||e[10]!==C||e[11]!==o?(B=fe=>{fe.stopPropagation(),o(null),C(n.path)},e[9]=n.path,e[10]=C,e[11]=o,e[12]=B):B=e[12];const ve=B;let xe;e[13]!==I||e[14]!==_||e[15]!==L||e[16]!==k||e[17]!==W||e[18]!==N||e[19]!==v||e[20]!==M||e[21]!==n||e[22]!==V||e[23]!==A||e[24]!==d||e[25]!==P?(xe=fe=>{const{Item:pe,Separator:tt}=fe;return r.jsxs(r.Fragment,{children:[k&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("rename",n)},children:[r.jsx(F,{name:"edit",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.rename")]}),r.jsxs(pe,{onClick:G=>{G.stopPropagation(),Br(n.path).then(lt=>{if(lt.ok){Q.success(P("sidebarFilesTree.toast.pathCopied"));return}Q.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.copyPath")]}),r.jsxs(pe,{onClick:G=>{G.stopPropagation();const lt=Or(d,n.path)||n.path;Br(lt).then(me=>{if(me.ok){Q.success(P("filesView.toast.relativePathCopied"));return}Q.error(P("sidebarFilesTree.toast.copyFailed"))})},children:[r.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ",P("filesView.tree.menu.copyRelativePath")]}),!M&&N&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),N(n.path).catch(lt=>{console.error("Download failed:",lt),Q.error(P("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"})," ",P(v?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),W&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),A(n.path)},children:[r.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",P(co())]}),M&&(I||_)&&r.jsxs(r.Fragment,{children:[r.jsx(tt,{}),I&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("createFile",n)},children:[r.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFile")]}),_&&r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("createFolder",n)},children:[r.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.newFolder")]})]}),L&&r.jsxs(r.Fragment,{children:[r.jsx(tt,{}),r.jsxs(pe,{onClick:G=>{G.stopPropagation(),V("delete",n)},className:"text-destructive focus:text-destructive",children:[r.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ",P("sidebarFilesTree.menu.delete")]})]})]})},e[13]=I,e[14]=_,e[15]=L,e[16]=k,e[17]=W,e[18]=N,e[19]=v,e[20]=M,e[21]=n,e[22]=V,e[23]=A,e[24]=d,e[25]=P,e[26]=xe):xe=e[26];const ue=xe,ae=T===n.path;let we;e[27]!==n.path||e[28]!==o?(we=fe=>o(fe?n.path:null),e[27]=n.path,e[28]=o,e[29]=we):we=e[29];const $=w?void 0:ce;let H;e[30]!==$?(H=r.jsx("div",{className:"group relative flex items-center",onContextMenu:$}),e[30]=$,e[31]=H):H=e[31];const re=w?void 0:ce,ne=g?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let ke;e[32]!==ne?(ke=q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ne),e[32]=ne,e[33]=ke):ke=e[33];let oe;e[34]!==M||e[35]!==x||e[36]!==n.extension||e[37]!==n.path?(oe=M?x?r.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):r.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Si(n.path,n.extension),e[34]=M,e[35]=x,e[36]=n.extension,e[37]=n.path,e[38]=oe):oe=e[38];let le;e[39]!==n.name||e[40]!==n.path?(le=r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[39]=n.name,e[40]=n.path,e[41]=le):le=e[41];let be;e[42]!==M||e[43]!==j?(be=!M&&j&&r.jsx(ul,{status:j}),e[42]=M,e[43]=j,e[44]=be):be=e[44];let Ee;e[45]!==m||e[46]!==M?(Ee=M&&m&&r.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[m.modified>0&&r.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",m.modified]}),m.added>0&&r.jsxs("span",{className:"text-[var(--status-success)]",children:["+",m.added]})]}),e[45]=m,e[46]=M,e[47]=Ee):Ee=e[47];let de;e[48]!==Se||e[49]!==ke||e[50]!==oe||e[51]!==le||e[52]!==be||e[53]!==Ee||e[54]!==re?(de=r.jsxs("button",{type:"button",onClick:Se,onContextMenu:re,className:ke,children:[oe,le,be,Ee]}),e[48]=Se,e[49]=ke,e[50]=oe,e[51]=le,e[52]=be,e[53]=Ee,e[54]=re,e[55]=de):de=e[55];let Ve;e[56]!==f||e[57]!==S||e[58]!==ve||e[59]!==Y||e[60]!==w||e[61]!==n.path||e[62]!==ue||e[63]!==C?(Ve=Y&&r.jsx("div",{className:q("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:r.jsxs(jn,{open:S===n.path,onOpenChange:fe=>C(fe?n.path:null),children:[r.jsx(Fn,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:r.jsx(F,{name:"more-2-fill",className:"size-4"})})}),r.jsx(Nn,{align:"end",side:"bottom",onCloseAutoFocus:()=>C(null),children:ue({Item:Ir,Separator:lo})})]})}),e[56]=f,e[57]=S,e[58]=ve,e[59]=Y,e[60]=w,e[61]=n.path,e[62]=ue,e[63]=C,e[64]=Ve):Ve=e[64];let Pe;e[65]!==de||e[66]!==Ve||e[67]!==H?(Pe=r.jsxs(po,{render:H,children:[de,Ve]}),e[65]=de,e[66]=Ve,e[67]=H,e[68]=Pe):Pe=e[68];let Re;e[69]!==ue?(Re=r.jsx(fo,{className:"min-w-[180px]",children:ue({Item:ho,Separator:mo})}),e[69]=ue,e[70]=Re):Re=e[70];let Z;return e[71]!==Pe||e[72]!==Re||e[73]!==ae||e[74]!==we?(Z=r.jsxs(go,{open:ae,onOpenChange:we,children:[Pe,Re]}),e[71]=Pe,e[72]=Re,e[73]=ae,e[74]=we,e[75]=Z):Z=e[75],Z},bl=a=>{const e=ot.c(83),{activeDialog:n,dialogData:d,dialogInputValue:x,onDialogInputChange:g,isDialogSubmitting:w,onDialogSubmit:v,onClose:f,inputRef:j}=a,{t:m}=Ht(),y=!!n;let N;e[0]!==f?(N=B=>!B&&f(),e[0]=f,e[1]=N):N=e[1];let S;e[2]!==n||e[3]!==m?(S=n==="createFile"&&m("filesView.dialog.createFile.title"),e[2]=n,e[3]=m,e[4]=S):S=e[4];let C;e[5]!==n||e[6]!==m?(C=n==="createFolder"&&m("filesView.dialog.createFolder.title"),e[5]=n,e[6]=m,e[7]=C):C=e[7];let T;e[8]!==n||e[9]!==m?(T=n==="rename"&&m("filesView.dialog.rename.title"),e[8]=n,e[9]=m,e[10]=T):T=e[10];let o;e[11]!==n||e[12]!==m?(o=n==="delete"&&m("filesView.dialog.delete.title"),e[11]=n,e[12]=m,e[13]=o):o=e[13];let E;e[14]!==S||e[15]!==C||e[16]!==T||e[17]!==o?(E=r.jsxs(bi,{children:[S,C,T,o]}),e[14]=S,e[15]=C,e[16]=T,e[17]=o,e[18]=E):E=e[18];let D;e[19]!==n||e[20]!==d?.path||e[21]!==m?(D=n==="createFile"&&m("filesView.dialog.createFile.description",{path:d?.path??m("filesView.dialog.rootFallback")}),e[19]=n,e[20]=d?.path,e[21]=m,e[22]=D):D=e[22];let A;e[23]!==n||e[24]!==d?.path||e[25]!==m?(A=n==="createFolder"&&m("filesView.dialog.createFolder.description",{path:d?.path??m("filesView.dialog.rootFallback")}),e[23]=n,e[24]=d?.path,e[25]=m,e[26]=A):A=e[26];let V;e[27]!==n||e[28]!==d?.name||e[29]!==m?(V=n==="rename"&&m("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=n,e[28]=d?.name,e[29]=m,e[30]=V):V=e[30];let P;e[31]!==n||e[32]!==d?.name||e[33]!==m?(P=n==="delete"&&m("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=n,e[32]=d?.name,e[33]=m,e[34]=P):P=e[34];let M;e[35]!==V||e[36]!==P||e[37]!==D||e[38]!==A?(M=r.jsxs(yi,{children:[D,A,V,P]}),e[35]=V,e[36]=P,e[37]=D,e[38]=A,e[39]=M):M=e[39];let k;e[40]!==M||e[41]!==E?(k=r.jsxs(wi,{children:[E,M]}),e[40]=M,e[41]=E,e[42]=k):k=e[42];let I;e[43]!==n||e[44]!==x||e[45]!==j||e[46]!==g||e[47]!==v||e[48]!==m?(I=n!=="delete"&&r.jsx("div",{className:"py-4",children:r.jsx(lr,{value:x,onChange:B=>g(B.target.value),placeholder:m(n==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:B=>{B.key==="Enter"&&v()},ref:j})}),e[43]=n,e[44]=x,e[45]=j,e[46]=g,e[47]=v,e[48]=m,e[49]=I):I=e[49];let _;e[50]!==m?(_=m("filesView.dialog.cancel"),e[50]=m,e[51]=_):_=e[51];let L;e[52]!==w||e[53]!==f||e[54]!==_?(L=r.jsx(O,{variant:"outline",onClick:f,disabled:w,children:_}),e[52]=w,e[53]=f,e[54]=_,e[55]=L):L=e[55];const X=n==="delete"?"destructive":"default";let Ce;e[56]!==v?(Ce=()=>{v()},e[56]=v,e[57]=Ce):Ce=e[57];let W;e[58]!==n||e[59]!==x||e[60]!==w?(W=w||n!=="delete"&&!x.trim(),e[58]=n,e[59]=x,e[60]=w,e[61]=W):W=e[61];let Y;e[62]!==n||e[63]!==w||e[64]!==m?(Y=w?r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):m(n==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=n,e[63]=w,e[64]=m,e[65]=Y):Y=e[65];let ee;e[66]!==X||e[67]!==Ce||e[68]!==W||e[69]!==Y?(ee=r.jsx(O,{variant:X,onClick:Ce,disabled:W,children:Y}),e[66]=X,e[67]=Ce,e[68]=W,e[69]=Y,e[70]=ee):ee=e[70];let ce;e[71]!==L||e[72]!==ee?(ce=r.jsxs(ji,{children:[L,ee]}),e[71]=L,e[72]=ee,e[73]=ce):ce=e[73];let te;e[74]!==j||e[75]!==k||e[76]!==I||e[77]!==ce?(te=r.jsxs(xi,{initialFocus:j,children:[k,I,ce]}),e[74]=j,e[75]=k,e[76]=I,e[77]=ce,e[78]=te):te=e[78];let Se;return e[79]!==y||e[80]!==N||e[81]!==te?(Se=r.jsx(vi,{open:y,onOpenChange:N,children:te}),e[79]=y,e[80]=N,e[81]=te,e[82]=Se):Se=e[82],Se},Ut=new Map,yl=100,hi=a=>{const e=ot.c(13);let n,d,x;e[0]!==a?({positionKey:d,onViewReady:n,...x}=a,e[0]=a,e[1]=n,e[2]=d,e[3]=x):(n=e[1],d=e[2],x=e[3]);const g=s.useRef(null);let w,v;e[4]!==d?(w=()=>()=>{const m=g.current;if(!m)return;const{anchor:y,head:N}=m.state.selection.main;if(Ut.delete(d),Ut.set(d,{scroll:m.scrollSnapshot(),anchor:y,head:N}),Ut.size>yl){const S=Ut.keys().next().value;S!==void 0&&Ut.delete(S)}},v=[d],e[4]=d,e[5]=w,e[6]=v):(w=e[5],v=e[6]),s.useLayoutEffect(w,v);let f;e[7]!==n||e[8]!==d?(f=m=>{g.current=m;const y=Ut.get(d);y&&m.dispatch({selection:{anchor:Math.min(y.anchor,m.state.doc.length),head:Math.min(y.head,m.state.doc.length)},effects:y.scroll}),n?.(m)},e[7]=n,e[8]=d,e[9]=f):f=e[9];let j;return e[10]!==x||e[11]!==f?(j=r.jsx(xo,{...x,onViewReady:f}),e[10]=x,e[11]=f,e[12]=j):j=e[12],j},pi=(a,e,n)=>{const d=ot.c(8),[x,g]=s.useState(""),[w,v]=s.useState(0);let f,j;d[0]!==a||d[1]!==n||d[2]!==e?(f=()=>{if(!a){g("");return}let y=!1;g("");const N=Ia(),S=Oa(N);Ba(N).then(T=>{y||!T||(g(a),e(null))}).catch(T=>{y||(e(T instanceof Error?T.message:n),g(a))});const C=$a(()=>{y||(g(a),v(jl),e(null))});return()=>{y=!0,S(),C()}},j=[a,e,n],d[0]=a,d[1]=n,d[2]=e,d[3]=f,d[4]=j):(f=d[3],j=d[4]),s.useEffect(f,j);let m;return d[5]!==w||d[6]!==x?(m={readyKey:x,nonce:w},d[5]=w,d[6]=x,d[7]=m):m=d[7],m},Wu=({mode:a="full"})=>{const{t:e}=Ht(),{files:n,runtime:d}=Ka(),{currentTheme:x,availableThemes:g,lightThemeId:w,darkThemeId:v}=Ha(),{isMobile:f,isTablet:j,screenWidth:m}=qa(),y=Pa(d.platform),N=f||j,S=Ma(),C=Da(),T=gi()??"",o=K(T.trim()),E=a!=="editor-only",D=a==="editor-only"&&!f,A=za(t=>t.searchFiles),V=Ga(T),[P,M]=s.useState(""),k=Xa(P,200),I=s.useRef(null),[_,L]=s.useState(!1),[X,Ce]=s.useState(!0),[W,Y]=s.useState(!1),[ee,ce]=s.useState(!1),te=s.useRef(0),Se=s.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[B,ve]=s.useState("edit"),[xe,ue]=s.useState("edit"),[ae,we]=s.useState("tree"),[$,H]=s.useState("edit"),[re,ne]=s.useState("preview"),[ke,oe]=s.useState(0),le=s.useRef({}),be=s.useRef({}),Ee=s.useRef({}),de=s.useRef({}),Ve=s.useMemo(()=>g.find(t=>t.metadata.id===w)??Xs(!1),[g,w]),Pe=s.useMemo(()=>g.find(t=>t.metadata.id===v)??Xs(!0),[g,v]);s.useEffect(()=>{ni(Ve),ni(Pe)},[Ve,Pe]);const Re=s.useMemo(()=>[],[]),Z=Xe(t=>o?t.byRoot[o]?.openPaths??Re:Re),fe=Xe(t=>o?t.byRoot[o]?.selectedPath??null:null),pe=Xe(t=>o?t.byRoot[o]?.expandedPaths??Re:Re),tt=Xe(t=>t.removeOpenPath),G=Xe(t=>t.removeOpenPathsByPrefix),lt=Xe(t=>t.removeExpandedPathsByPrefix),me=Xe(t=>t.setSelectedPath),Cn=Xe(t=>t.toggleExpandedPath),cr=Xe(t=>t.expandPaths),Ct=s.useCallback(t=>{const i=K(t),l=i.split("/"),u=l[l.length-1]||i,p=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:p}},[]),St=s.useMemo(()=>Z.map(Ct),[Z,Ct]),Wr=s.useMemo(()=>{if(fe){const t=Kt(fe);if(Z.some(i=>Kt(i)===t))return fe}return Z[0]??null},[Z,fe]),c=s.useMemo(()=>Wr?Ct(Wr):null,[Wr,Ct]),_e=c?.path??"",[,ki]=s.useState(0);s.useEffect(()=>{if(!o||!fe)return;const t=Kt(fe);Z.some(l=>Kt(l)===t)||me(o,Z[0]??null)},[Z,o,fe,me]);const ur=!!(o&&_e&&!$r(_e,o)),Sn=ur?Js(_e):void 0,xt=s.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ur,outsideFileGrant:Sn,directory:o||void 0}),[a,ur,Sn,o]),Je=s.useCallback(async t=>{const i=Js(t),l=await Ja(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&ki(u=>u+1),l},[a,o]),Ur=s.useRef(null),[kn,Ri]=s.useState({left:!1,right:!1}),Rn=s.useCallback(()=>{const t=Ur.current;t&&Ri({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),Tn=s.useRef(Rn);Tn.current=Rn,s.useEffect(()=>{const t=Ur.current;if(!t)return;const i=()=>Tn.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[St.length]);const[En,Kr]=s.useState({}),[dr,qt]=s.useState({}),Ae=s.useRef(new Set),Ie=s.useRef(new Set),rt=s.useRef(new Map),Vn=s.useRef(0),[Pn,fr]=s.useState([]),[Ti,mr]=s.useState(!1),[z,he]=s.useState(""),{isPlaying:hr,play:Ei,stop:Vi}=Qa(),[Me,ct]=s.useState(!1),[Qe,ge]=s.useState(null),[Pi,Oe]=s.useState(""),[ye,se]=s.useState(null),ut=JSON.stringify([Us(),o,ye]),[ie,je]=s.useState(""),[Gt,Hr]=s.useState(!1),[Mn,Mi]=s.useState(`
11
+ `),Di=s.useRef(null),Ye=s.useRef(null),De=s.useRef(null),dt=s.useRef(""),Xt=s.useRef(""),nt=s.useRef(null),Dn=s.useRef(null),We=s.useRef(null),qr=s.useRef(""),Gr=s.useRef(0),Jt=s.useRef(0),kt=s.useRef(null),[pr,zi]=s.useState(0),[Li,Rt]=s.useState("idle"),[Ai,gr]=s.useState(!1),[wt,zn]=s.useState(!1),Fe=vt(t=>t.autoSaveEnabled),Ii=vt(t=>t.setAutoSaveEnabled),[Xr,Qt]=s.useState(!1),Tt=s.useRef(null),Yt=s.useRef(null),Zt=s.useRef(!1),er=s.useRef(null),tr=s.useRef(null),Ue=s.useRef(null),vr=s.useRef(null),[Oi,Jr]=s.useState(0),Et=s.useRef(null),bt=s.useRef({key:"",attempts:0});s.useEffect(()=>()=>{Et.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Et.current),Et.current=null)},[]);const[yt,Qr]=s.useState(null),[jt,Bi]=s.useState(null),[ft,Ln]=s.useState(""),[$i,Yr]=s.useState(!1),[_i,Wi]=s.useState(null),[Ui,Ki]=s.useState(null),[Hi,An]=s.useState(!1),[qi,In]=s.useState(!1),[Gi,Zr]=s.useState(!1),[On,xr]=s.useState(!1),[Bn,$n]=s.useState(0),wr=s.useRef(null),br=s.useCallback(t=>{const i=t?.currentTarget??wr.current;if(!i)return;const l=document.activeElement;l&&l!==document.body&&l!==i&&(Ya(l)||i.contains(l))||i.focus({preventScroll:!0})},[]),yr=s.useRef(null),_n=!!n.writeFile,Wn=!!n.createDirectory,Un=!!n.rename,Kn=!!n.delete,Hn=!!n.revealPath,Xi=zr(t=>t.availableApps),Ji=zr(t=>t.isCacheStale),qn=zr(t=>t.initialize),Qi=zr(t=>t.loadInstalledApps);s.useEffect(()=>{qn()},[qn]);const Yi=s.useCallback(t=>{n.revealPath&&n.revealPath(t).catch(()=>{Q.error(e("sidebarFilesTree.toast.revealFailed"))})},[n,e]),Zi=s.useCallback(async t=>{if(!c?.path||await La(c.path,t.id,t.appName)||await Ks(c.path,t.appName))return;const u=il(c.path)||o;u&&await Ks(u,t.appName)||Q.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),en=s.useCallback((t,i)=>{Qr(t),Bi(i),Ln(t==="rename"&&i.name||""),Yr(!1)},[]),[U,Ke]=s.useState(null),Vt=s.useRef(!1),mt=s.useRef(null),[Gn,Pt]=s.useState(!1),Ze=vt(t=>t.pendingFileNavigation),jr=vt(t=>t.setPendingFileNavigation),tn=vt(t=>t.pendingFileFocusPath),rn=vt(t=>t.setPendingFileFocusPath),Xn=vt(t=>t.fileEditorKeymap),rr=Qs(t=>t.settingsDefaultFileViewerPreview),ea=Qs(t=>t.showMessageTTSButtons);s.useEffect(()=>{const t=()=>{Vt.current=!1,mt.current=null,Pt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),s.useEffect(()=>()=>{er.current!==null&&window.clearTimeout(er.current),tr.current!==null&&window.clearTimeout(tr.current)},[]);const ta=s.useCallback((t,i)=>{const l=t.split(`
12
+ `),u=Math.max(1,i.start),p=Math.min(l.length,i.end);return u>p?"":l.slice(u-1,p).join(`
13
+ `)},[]),Jn=s.useRef(null),ra=Vo({source:"file",fileLabel:c?.path??null,language:c?.path&&pn(c.path)||"text",getCodeForRange:t=>ta(z,Po(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Qn,commentText:Fr,setCommentText:Yn,editingDraftId:Nr,setSelection:Zn,saveComment:es,cancel:nr,reset:ts,startEdit:rs,deleteDraft:ns}=ra;s.useEffect(()=>{Ke(null),ts(),je(""),Hr(!1)},[c?.path,ts]),s.useEffect(()=>{Zn(U)},[U,Zn]),s.useEffect(()=>{if(!U&&!Nr)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||Fr.trim()||(Ke(null),nr())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[nr,Fr,Nr,U]);const ss=s.useCallback((t,i)=>{const l=i??U??void 0;i&&Ke(i),es(t,l),Ke(null)},[U,es]),is=s.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!S&&u.name.startsWith(".")||!C&&dl(u.name))continue;const p=u.name,h=K(u.path||""),b=h?ll(h)?h:K(`${t}/${h}`):K(`${t}/${p}`),R=u.isDirectory?"directory":"file",J=R==="file"&&p.includes(".")?p.split(".").pop()?.toLowerCase():void 0;l.push({name:p,path:b,type:R,extension:J})}return ol(l)},[C,S]),Be=s.useCallback(async t=>{const i=K(t.trim());if(!i||Ae.current.has(i)||Ie.current.has(i))return;Ie.current=new Set(Ie.current),Ie.current.add(i);const l=Vn.current+1;Vn.current=l,rt.current=new Map(rt.current),rt.current.set(i,l);const u=()=>rt.current.get(i)===l;await(n.listDirectory?n.listDirectory(i).then(h=>h.entries.map(b=>({name:b.name,path:b.path,isDirectory:b.isDirectory}))):Aa.listLocalDirectory(i).then(h=>h.map(b=>({name:b.name,path:b.path,isDirectory:b.isDirectory})))).then(h=>{if(!u())return;const b=is(i,h);Ae.current=new Set(Ae.current),Ae.current.add(i),qt(R=>{if(!R[i])return R;const J={...R};return delete J[i],J}),Kr(R=>({...R,[i]:b}))}).catch(h=>{if(!u())return;const b=h instanceof Error?h.message:String(h??"");if(b==="Directory not found"&&o&&i!==o){lt(o,i),qt(R=>{if(!R[i])return R;const J={...R};return delete J[i],J});return}console.error("Failed to load files directory:",h),qt(R=>({...R,[i]:b}))}).finally(()=>{u()&&(rt.current=new Map(rt.current),rt.current.delete(i),Ie.current=new Set(Ie.current),Ie.current.delete(i))})},[n,is,lt,o]),Cr=s.useCallback(async()=>{o&&(Ae.current=new Set,Ie.current=new Set,rt.current=new Map,qt({}),Kr(t=>Object.keys(t).length===0?t:{}),await Be(o))},[Be,o]),et=s.useCallback(async t=>{if(!t){await Cr();return}const i=K(t);Ae.current=new Set(Ae.current),Ae.current.delete(i),Ie.current=new Set(Ie.current),Ie.current.delete(i),await Be(i)},[Be,Cr]),as=s.useRef(""),os=s.useRef("");s.useEffect(()=>{if(!o)return;const t=`${o}|h${S?"1":"0"}|g${C?"1":"0"}`,i=as.current!==o,l=os.current!==t;!i&&!l||(i&&(as.current=o,he(""),ge(null),Oe(""),se(null),L(!1)),l&&(os.current=t,Ae.current=new Set,Ie.current=new Set,rt.current=new Map,qt({}),Kr(u=>Object.keys(u).length===0?u:{}),Be(o)))},[Be,o,C,S]),s.useEffect(()=>{if(!n.listDirectory)return;const t=()=>{if(!document.hidden&&pe.length>0)for(const i of pe)et(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[pe,n.listDirectory,et]),s.useEffect(()=>{if(!n.listDirectory||pe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of pe)et(i)},8e3);return()=>clearInterval(t)},[pe,n.listDirectory,et]);const na=s.useCallback(async t=>{if(t?.preventDefault(),!jt||!yt)return;Yr(!0);const i=()=>{Qr(null)},l=p=>{Q.error(p)},u=()=>{Yr(!1)};if(yt==="createFile"){if(!ft.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!n.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const p=jt.path,h=p?`${p}/`:"",b=K(`${h}${ft.trim()}`);await n.writeFile(b,"").then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.fileCreated")),await et(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="createFolder"){if(!ft.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const p=jt.path,h=p?`${p}/`:"",b=K(`${h}${ft.trim()}`);await n.createDirectory(b).then(async R=>{R.success&&(Q.success(e("sidebarFilesTree.toast.folderCreated")),await et(p)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="rename"){if(!ft.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!n.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const p=jt.path,h=p.split("/").slice(0,-1).join("/"),b=h?`${h}/`:"",R=K(`${b}${ft.trim()}`);await n.rename(p,R).then(async J=>{J.success&&(Q.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await et(h),o&&G(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(yt==="delete"){if(!n.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const p=jt.path,h=p.split("/").slice(0,-1).join("/");await n.delete(p).then(async b=>{b.success&&(Q.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await et(h),o&&G(o,p),(c?.path===p||c?.path.startsWith(`${p}/`))&&(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[yt,jt,ft,n,et,f,G,o,c?.path,me,e]);s.useEffect(()=>{if(!T){fr([]),mr(!1);return}const t=k.trim();if(!t){fr([]),mr(!1);return}let i=!1;return mr(!0),A(T,t,150,{includeHidden:S,respectGitignore:!C,type:"file"}).then(l=>{if(i)return;const p=l.filter(h=>C||!fl(h.path)).map(h=>({name:h.name,path:K(h.path),type:"file",extension:h.extension,relativePath:h.relativePath}));fr(p)}).catch(()=>{i||fr([])}).finally(()=>{i||mr(!1)}),()=>{i=!0}},[T,k,A,S,C]);const Sr=s.useCallback(async(t,i)=>{const l=await Je(t);if(n.readFile)return(await n.readFile(t,{...l,directory:o||void 0,...i})).content??"";const u=new URLSearchParams({path:t});l.allowOutsideWorkspace&&u.set("allowOutsideWorkspace","true"),l.outsideFileGrant&&u.set("outsideFileGrant",l.outsideFileGrant),o&&u.set("directory",o);const p=await Hs(`/api/fs/read?${u.toString()}`,i?.fresh?{cache:"no-store"}:void 0);if(!p.ok){const h=await p.json().catch(()=>({error:p.statusText}));throw new Error(h.error||e("filesView.error.readFileFailed"))}return p.text()},[n,Je,o,e]),ht=s.useCallback(async t=>{if(n.statFile){const i=await Je(t),l=await n.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[n,Je,o]);s.useEffect(()=>{if(!o||!n.statFile||Z.length===0)return;let t=!1;const i=[...Z];return Promise.all(i.map(async l=>{try{const u=await Je(l),p=await n.statFile?.(l,{...u,directory:o||void 0});!t&&p&&!p.isFile&&G(o,l)}catch(u){!t&&fi(u)&&G(o,l)}})),()=>{t=!0}},[n,Z,G,Je,o]);const nn=s.useMemo(()=>z.length>Wt?`${z.slice(0,Wt)}
14
+
15
+ … truncated …`:z,[z]),ze=ie!==nn,Mt=s.useCallback(async()=>{if(!c||!n.writeFile)return Q.error(e("filesView.toast.savingNotSupported")),!1;const t=or(c.path)||wt;if(!rl({selectedFilePath:c.path,loadedFilePath:ye,fileLoading:Me,isDirty:ze,draftContent:ie,fileContent:z,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):ie===""&&z!==""&&ye!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${z.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!ze)return!0;Hr(!0);try{const i=vl(ie,Mn);if(!(await n.writeFile(c.path,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;if(he(ie),qr.current=i,Gr.current+=1,o&&$r(c.path,o)){const u=Or(o,c.path);u&&Za.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(K(c.path))){const u=eo.getState().projects.find(p=>K(p.path)===K(o));if(u)try{await ko(u.id)}catch{Q.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&Dr(c.path)&&(dt.current=ie,Xt.current=ie),ht(c.path).then(u=>{u&&(We.current=u)}).catch(()=>{}),!0}catch(i){return Q.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Hr(!1)}},[wt,ie,z,Me,n,ze,Mn,ye,ht,o,c,e]);s.useEffect(()=>{Fe||(Rt("idle"),Ye.current&&(clearTimeout(Ye.current),Ye.current=null))},[Fe]);const ls=1500;s.useEffect(()=>{const t=!!(c&&n.writeFile),i=!!(c?.path&&(or(c.path)||wt));if(tl({autoSaveEnabled:Fe,isDirty:ze,canWrite:t,isSaving:Gt,fileLoading:Me,selectedFilePath:c?.path,loadedFilePath:ye,isNonEditableBinary:i}))return Ye.current=setTimeout(()=>{Mt().then(l=>{l&&(Rt("saved"),setTimeout(()=>Rt("idle"),2e3))})},ls),()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)}},[Fe,wt,ie,Me,ze,ye,c,n.writeFile,Gt,Mt]),s.useEffect(()=>{Rt("idle")},[c?.path]),to({save_file:t=>{if(!(t.target instanceof Node)||!vr.current?.contains(t.target))return!1;Ye.current&&(clearTimeout(Ye.current),Ye.current=null),Gt||Mt().then(i=>{i&&(Rt("saved"),setTimeout(()=>Rt("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node))return!1;if(qe&&Le()==="preview"){if(f||!(W?yr.current:wr.current)?.contains(t.target))return!1;xr(!0),$n(l=>l+1);return}if(!vr.current?.contains(t.target))return!1;ce(!0)}});const Dt=s.useCallback(t=>{const i=Ci(t);qr.current=t,Gr.current+=1,Mi(gl(t)),he(i),dt.current=i,Xt.current=i,je(i.length>Wt?`${i.slice(0,Wt)}
16
+
17
+ … truncated …`:i)},[]),cs=s.useCallback(async t=>{const i=Jt.current+1;Jt.current=i;const l=()=>{if(!o)return!1;const R=Xe.getState().byRoot[o],J=R?.selectedPath??R?.openPaths[0]??null;return Jt.current===i&&J===t.path};if(ge(null),Oe(""),se(null),zn(!1),ct(!0),await Je(t.path),!l())return;const u=gn(t.path),p=Ys(t.path),h=Zs(t.path),b=or(t.path);if(f&&L(!0),d.isDesktop&&u&&!p){he(""),je("");return}if(!d.isDesktop&&u&&!p){he(""),je(""),se(t.path),ct(!1);return}if(h){he(""),je(""),se(t.path),ct(!1);return}if(b){he(""),je(""),se(t.path),ct(!1);return}await Sr(t.path).then(R=>{if(l()){if(ei(R)){zn(!0),he(""),je(""),se(t.path);return}Dt(R),se(t.path),ht(t.path).then(J=>{J&&l()&&(We.current=J)}).catch(()=>{})}}).catch(R=>{if(l()){if(ml(R)){if(ct(!1),o&&me(o,null),ge(null),he(""),je(""),se(null),We.current=null,P.trim().length>0&&M(""),f&&L(!1),o){const ar=[...ui(t.path,o),t.path];ar.length>0&&cr(o,ar);for(const gt of ar)Ae.current.has(gt)||Be(gt)}return}if(fi(R)){o&&G(o,t.path),he(""),je(""),ge(null),We.current=null,f&&L(!1);return}he(""),je(""),ge(R instanceof Error?R.message:e("filesView.error.readFileFailed")),We.current=null}}).finally(()=>{l()&&ct(!1)})},[Dt,cr,f,Be,Sr,ht,G,Je,o,d.isDesktop,P,me,e]),kr=s.useCallback(async(t,i)=>{if(!o)return;const l=ui(t,o),u=i?[...l,t]:l;u.length>0&&cr(o,u);const p=u.map(h=>{if(!Ae.current.has(h))return Be(h)}).filter(Boolean);await Promise.all(p)},[cr,Be,o]),us=s.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Te=s.useCallback(async t=>{if(Zt.current)Zt.current=!1;else if(ze){Qt(!0),Tt.current=t;return}o&&(me(o,t.path),kr(t.path,!1)),ge(null),Oe(""),he(""),dt.current="",Xt.current="",je(""),se(null),f&&L(!0)},[kr,ze,f,o,me]);s.useEffect(()=>{c?.path&&kr(c.path,!1)},[kr,c?.path]),s.useEffect(()=>{if(!c){Jt.current+=1,kt.current=null,ct(!1);return}if(ye===c.path||kt.current===c.path)return;const t=c.path;kt.current=t,cs(c).finally(()=>{kt.current===t&&(kt.current=null)})},[pr,cs,ye,c]);const Rr=s.useRef(ze);Rr.current=ze,s.useEffect(()=>Ro(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==Us()||!l||Rr.current||!i.includes(K(l))||(Jt.current+=1,kt.current=null,We.current=null,Oe(""),ge(null),se(null),zi(u=>u+1))}),[c?.path]),s.useEffect(()=>{if(!c?.path||ye!==c.path)return;const t=c.path,i=()=>Rr.current||Dr(t)&&dt.current!==Xt.current,l=!or(t)&&!gn(t)&&!wt?Jo({readContent:()=>Sr(t,{fresh:!0}),getLoadedContent:()=>qr.current,getLoadedRevision:()=>Gr.current,isDirty:i,applyContent:b=>{if(ei(b)){se(null);return}Dt(b)}}):null;let u=!1,p=!1;const h=window.setInterval(()=>{document.hidden||p||(p=!0,ht(t).then(async b=>{if(u||!b)return;const R=We.current;if(!R||R.path!==t){We.current=b;return}if(Yo(R,b)){if(l&&b.size<=hl){await l.poll()&&!u&&(We.current=b);return}Rr.current||(We.current=b,se(null))}}).catch(()=>{}).finally(()=>{p=!1}))},2e3);return()=>{u=!0,l?.dispose(),window.clearInterval(h)}},[Dt,wt,ye,Sr,ht,c?.path]);const sa=s.useCallback(()=>{const t=Tt.current,i=Yt.current;if(Tt.current=null,Yt.current=null,Zt.current=!0,Qt(!1),je(nn),i){o&&tt(o,i),c?.path===i&&(t?Te(t):(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)));return}if(t){Te(t);return}},[nn,Te,f,tt,o,c?.path,me]),ia=s.useCallback(async()=>{const t=Tt.current,i=Yt.current;if(!await Mt()){Zt.current=!1;return}if(Tt.current=null,Yt.current=null,Zt.current=!0,Qt(!1),i){o&&tt(o,i),c?.path===i&&(t?await Te(t):(o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)));return}if(t){await Te(t);return}},[Te,f,tt,o,Mt,c?.path,me]),ds=s.useCallback(t=>{const i=c?.path===t,l=us(t,St);if(i&&ze){Qt(!0),Tt.current=l,Yt.current=t;return}if(o&&tt(o,t),!!i){if(l){Te(l);return}o&&me(o,null),he(""),ge(null),Oe(""),se(null),f&&L(!1)}},[us,Te,ze,f,St,tt,o,c?.path,me]),aa=s.useCallback(t=>{if(Z.includes(t))return"open";if(V?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=V.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Z,V,o]),oa=s.useCallback(t=>{if(!V?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,p=0;for(const h of V.files)h.path.startsWith(l)&&((h.index==="M"||h.working_dir==="M")&&u++,(h.index==="A"||h.working_dir==="?")&&p++);return u+p>0?{modified:u,added:p}:null},[V,o]),la=s.useCallback(async t=>{const i=K(t);o&&(Cn(o,i),Ae.current.has(i)||await Be(i))},[Be,o,Cn]),ca=s.useMemo(()=>({canRename:Un,canCreateFile:_n,canCreateFolder:Wn,canDelete:Kn,canReveal:Hn}),[Un,_n,Wn,Kn,Hn]);function fs(t,i){const l=En[t]??[];return l.map((u,p)=>{const h=u.type==="directory",b=h&&pe.includes(u.path),R=c?.path===u.path,J=p===l.length-1;return r.jsxs("li",{className:"relative",children:[i>0&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),J&&r.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),r.jsx(wl,{node:u,root:o,isExpanded:b,isActive:R,isMobile:f,isBrowserClient:y,alwaysShowActions:N,status:h?void 0:aa(u.path),badge:h?oa(u.path):void 0,permissions:ca,downloadFile:n.downloadFile,contextMenuPath:_i,setContextMenuPath:Wi,rightClickMenuPath:Ui,setRightClickMenuPath:Ki,onSelect:Te,onToggle:la,onRevealPath:Yi,onOpenDialog:en}),h&&b&&r.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[dr[u.path]?r.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:dr[u.path],children:dr[u.path]}),r.jsxs(O,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{et(u.path)},children:[r.jsx(F,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,fs(u.path,i+1)]})]},u.path)})}const Ne=!!(c?.path&&gn(c.path)),Tr=!!(c?.path&&Ys(c.path)),$e=!!(c?.path&&Zs(c.path)),sn=!!(c?.path&&(or(c.path)||wt)),st=sn&&!Ne&&!$e,ms=s.useMemo(()=>K(Ze?.path??""),[Ze?.path]),zt=!!(Ze&&ms&&_e&&_e===ms&&!Me&&!Qe&&!Ne&&!$e&&!st),pt=s.useMemo(()=>Or(o,_e),[_e,o]),ua=!!(c&&(!Ne||Tr)&&!$e&&!st&&z.length>0),da=!!(c&&pt.length>0),He=!!(c&&!ur&&!sn&&!Ne&&n.writeFile&&z.length<=Wt),qe=!!(c?.path&&mi(c.path)),Lt=!!(c?.path&&xl(c.path)),At=!!(c?.path&&yn(c.path)),sr=!!(c?.path&&Dr(c.path)),Er=!!(c&&!sn&&!Ne)&&!qe&&!sr&&!(At&&$==="preview"),fa=qe&&xe==="edit"||At&&$==="edit"||Lt&&ae==="text"||!qe&&!At&&!Lt&&B==="edit",Vr=s.useMemo(()=>_e?ro(_e):null,[_e]),[hs,an]=s.useState(null);s.useEffect(()=>{let t=!1;const i=c?.path;if(!i||Vr){an(null);return}return an(null),no(i).then(l=>{t||an(l)}),()=>{t=!0}},[c?.path,Vr]),s.useEffect(()=>{!He&&B==="edit"&&ve("view")},[He,B]);const on="aiworker:files:md-viewer-mode",ln="aiworker:files:html-viewer-mode",cn="aiworker:files:json-viewer-mode";s.useEffect(()=>{const t=c?.path;if(!t)return;ve(le.current[t]??"edit");let i=rr?"preview":"edit";try{const p=localStorage.getItem(on);(p==="preview"||p==="edit")&&(i=p)}catch{}ue(be.current[t]??i);let l=rr?"preview":"edit";try{const p=localStorage.getItem(ln);(p==="preview"||p==="edit")&&(l=p)}catch{}H(Ee.current[t]??l),ne(de.current[t]??(rr?"preview":"edit"));let u=rr?"tree":"text";try{const p=localStorage.getItem(cn);(p==="tree"||p==="text")&&(u=p)}catch{}we(u)},[c?.path,rr]);const ma=s.useCallback(t=>{const i=c?.path;i&&(le.current[i]=t),ve(t)},[c?.path]),ha=s.useCallback(t=>{const i=c?.path;i&&(be.current[i]=t),ue(t);try{localStorage.setItem(on,t)}catch{}},[c?.path]),Le=s.useCallback(()=>xe,[xe]),ps=c&&qe&&Le()==="preview"&&!Me?c.path:null;s.useEffect(()=>{!ps||f||br()},[br,W,f,ps]);const pa=s.useCallback(t=>{we(t);try{localStorage.setItem(cn,t)}catch{}},[]),ga=s.useCallback(t=>{const i=c?.path;i&&(Ee.current[i]=t),H(t);try{localStorage.setItem(ln,t)}catch{}},[c?.path]),va=s.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),De.current&&(clearTimeout(De.current),De.current=null),nt.current!==null&&(cancelAnimationFrame(nt.current),nt.current=null),t==="edit")je(dt.current||z),ne(t);else{dt.current=ie;const l=i;ne("edit"),nt.current=requestAnimationFrame(()=>{nt.current=requestAnimationFrame(()=>{nt.current=null,!(o&&l&&Xe.getState().byRoot[o]?.selectedPath!==l)&&(oe(u=>u+1),ne("preview"))})});return}},[ie,z,o,c?.path]),un=s.useCallback(async(t,i)=>{if(!n.writeFile||i===Xt.current)return!1;if(!(await n.writeFile(t,i))?.success)return Q.error(e("filesView.toast.writeFileFailed")),!1;Dt(i);const u=await ht(t).catch(()=>null);return u&&(We.current=u),!0},[Dt,n,ht,e]);s.useEffect(()=>()=>{De.current&&(clearTimeout(De.current),De.current=null),nt.current!==null&&(cancelAnimationFrame(nt.current),nt.current=null)},[re,c?.path]);const xa=s.useCallback(t=>{if(dt.current=t,!Fe||!c?.path||re!=="preview"||!n.writeFile)return;De.current&&clearTimeout(De.current);const i=c.path;De.current=setTimeout(()=>{De.current=null,un(i,t).then(l=>{l&&(gr(!0),setTimeout(()=>gr(!1),1500))}).catch(l=>{Q.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},ls)},[Fe,re,n.writeFile,un,c?.path,e]),wa=s.useMemo(()=>sr&&(dt.current||ie)||z,[ie,z,sr]),gs=s.useCallback(()=>$,[$]);s.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",p=l?"tree":"text";for(const h of Z)le.current[h]="edit",mi(h)&&(be.current[h]=u),yn(h)&&(Ee.current[h]=u),Dr(h)&&(de.current[h]=u);ve("edit"),ue(u),H(u),ne(u),we(p);try{localStorage.setItem(on,u),localStorage.setItem(ln,u),localStorage.setItem(cn,p)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("aiworker:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("aiworker:file-viewer-preview-mode-changed",i)}},[Z]),s.useEffect(()=>{if(!Ze||!o)return;const t=()=>{typeof window>"u"||Et.current===null&&(Et.current=window.requestAnimationFrame(()=>{Et.current=null,Jr(it=>it+1)}))},i=(it,Ft)=>{if(it.state.doc.length!==Ft.length)return!1;if(Ft.length===0)return!0;const hn=Math.min(128,Ft.length);if(it.state.sliceDoc(0,hn)!==Ft.slice(0,hn))return!1;const _s=Math.max(0,Ft.length-hn);return it.state.sliceDoc(_s,Ft.length)===Ft.slice(_s)},l=K(Ze.path);if(!l){jr(null),bt.current={key:"",attempts:0};return}const u=`${l}:${Ze.line}:${Ze.column??1}`;if(bt.current.key!==u&&(bt.current={key:u,attempts:0}),c?.path!==l){if(Xr)return;Te(Ct(l));return}if(Me||ye!==l)return;if(Qe||Ne||$e||st){jr(null),bt.current={key:"",attempts:0};return}if(!He)return;if(B!=="edit"){ve("edit");return}const p=Ue.current;if(!p){t();return}if(!i(p,ie)){t();return}const h=Math.max(1,Math.min(Ze.line,p.state.doc.lines)),b=p.state.doc.line(h),R=Math.max(1,Ze.column||1),J=Math.max(0,b.to-b.from),ar=Math.min(J,R-1),gt=b.from+ar;if(!(p.state.selection.main.head===gt)||bt.current.attempts===0){bt.current.attempts+=1,p.dispatch({selection:{anchor:gt},effects:Nt.scrollIntoView(gt,{y:"center"})}),p.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const it=Ue.current;it&&(it.dispatch({selection:{anchor:gt},effects:Nt.scrollIntoView(gt,{y:"center"})}),it.focus())}),jr(null),bt.current={key:"",attempts:0}},[He,Xr,ie,Oi,Qe,Me,Ne,$e,st,ye,Te,Ze,o,c?.path,jr,B,Ct]),s.useEffect(()=>{if(!tn||!o)return;const t=K(tn);if(!t){rn(null);return}c?.path===t&&(Me||ye!==t||(!Qe&&!Ne&&!$e&&!st&&He&&B==="edit"&&Ue.current?.focus(),rn(null)))},[He,Qe,Me,Ne,$e,st,ye,tn,o,c?.path,rn,B]);const It=s.useCallback(t=>{if(!f||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const p=t.state.selection.main.head,h=t.coordsAtPos(p);if(!h)return;const b=Math.round(i.offsetTop+i.height),J=h.bottom+20-b;J<=0||(t.scrollDOM.scrollTop+=J)},[f]);s.useEffect(()=>{if(!f||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{It(Ue.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[f,It]),so("open_go_to_line",t=>{if(!He||B!=="edit"||f)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!vr.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;Zr(!0)});const Pr=vt(t=>t.editorFontSize),vs=s.useMemo(()=>{if(!c?.path)return[ri(x,{fontSize:Pr})];const t=pn(c.path),i=[ri(x,t?{syntaxColors:!1,fontSize:Pr}:{fontSize:Pr})],l=Vr??hs;return l&&i.push(l),t&&i.push(vo({language:t,themeName:x.metadata.id,theme:Fo(x)})),X&&i.push(Nt.lineWrapping),f&&i.push(Nt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{It(u.view)})})),i},[x,c?.path,Vr,hs,X,f,It,Pr]),xs=s.useMemo(()=>({light:Ve.metadata.id,dark:Pe.metadata.id}),[Ve.metadata.id,Pe.metadata.id]),ir=c?.path&&$e&&(!xt.allowOutsideWorkspace||xt.outsideFileGrant)?`${c.path}|${xt.allowOutsideWorkspace?"outside":"workspace"}|${xt.outsideFileGrant??""}|${pr}`:"",Mr=c?.path&&At&&$==="preview"&&!d.isVSCode?`${c.path}|${pr}`:"",ws=e("filesView.error.readFileFailed"),{readyKey:bs,nonce:ba}=pi(Mr,ge,ws),{readyKey:ys,nonce:js}=pi(ir,ge,ws),ya=!!(Mr&&bs!==Mr),Fs=!!(ir&&ys!==ir),Ns=c?.path&&Ne?Tr?`data:${io(c.path)};utf8,${encodeURIComponent(z)}`:Pi:"",Cs=c?.path&&$e&&ir&&ys===ir?qs().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:xt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:xt.outsideFileGrant,directory:o||void 0}):"",Ss=s.useCallback(t=>r.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:r.jsx("iframe",{src:Cs,className:"h-full w-full border-0",title:t.name},js)}),[Cs,js]);s.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Ne||Tr){Oe("");return}ge(null);const u=await Je(c.path);if(t)return;await(n.readFileBinary?n.readFileBinary(c.path,u).then(h=>h.dataUrl):(async()=>{const h=await Hs("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!h.ok)throw new Error(e("filesView.error.readFileFailed"));const b=await h.blob();return i=URL.createObjectURL(b),t?(URL.revokeObjectURL(i),i="",""):i})()).then(h=>{t||(Oe(h),se(c.path))}).catch(h=>{t||(Oe(""),ge(h instanceof Error?h.message:e("filesView.error.readFileFailed")),se(null))}).finally(()=>{t||ct(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[pr,n,Ne,Tr,Je,o,c?.path,xt,e]);const ja=s.useCallback(()=>Qr(null),[]),Fa=s.useMemo(()=>Mo({drafts:Qn,editingDraftId:Nr,commentText:Fr,onTextChange:Yn,selection:U,isDragging:Gn,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:ss,onCancel:()=>{Ke(null),nr()},onEdit:t=>{rs(t),Ke({start:t.startLine,end:t.endLine})},onDelete:ns}),[nr,Fr,ns,Nr,Qn,ss,Gn,U,c?.path,Yn,rs]),ks=li(),Rs=li(),Ts=!Me&&!Qe&&ye===_e,Es=Ts&&Er&&B==="view"&&!(Lt&&ae==="tree"),Vs=Ts&&qe&&Le()==="preview",{setScroller:Ps,restore:Na}=Lr(Es?`${ut}:code`:null),{setScroller:Ms,restore:Ca}=Lr(Es?`${ut}:code:fullscreen`:null),{setScroller:Ds}=Lr(Vs?`${ut}:markdown`:null),{setScroller:zs}=Lr(Vs?`${ut}:markdown:fullscreen`:null),{setScroller:Ls}=ks,{setScroller:As}=Rs,Sa=s.useCallback(t=>{Ls(t),Ps(t)},[Ls,Ps]),ka=s.useCallback(t=>{As(t),Ms(t)},[As,Ms]),Ra=s.useCallback(t=>{Jn.current=t,wr.current=t,Ds(t)},[Ds]),Ta=s.useCallback(t=>{yr.current=t,zs(t)},[zs]),dn=uo("unified"),Ge=z.length>Wt,fn=s.useMemo(()=>Ge?pl(z):void 0,[z,Ge]),Is=s.useCallback((t,i,l,u)=>{const p={name:t.name,contents:i,lang:pn(t.path)||void 0},h=b=>r.jsx(jo,{file:Ge&&fn?{...p,cacheKey:`${t.path}:${fn}`}:p,options:{disableFileHeader:!0,overflow:X?"wrap":"scroll",theme:xs,themeType:x.metadata.variant==="dark"?"dark":"light",onPostRender:u},className:Ge?"block w-full":"block h-full w-full",style:Ge?void 0:{height:"100%"}},b);return Ge?r.jsx("div",{className:"h-full",children:r.jsx(No.Provider,{value:l.virtualizer,children:r.jsx(Co.Provider,{value:dn,children:h(`${t.path}:${dn?"pool":"pending"}`)})})}):r.jsx("div",{className:"h-full",children:h(t.path)})},[x.metadata.variant,Ge,fn,xs,dn,X]),Os=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=ao(oo("save_file")),p=l?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",h=(b,R)=>r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:R})}),r.jsx($t,{side:"bottom",sideOffset:6,children:b})]});return r.jsxs("div",{className:p,children:[He&&fa&&r.jsxs(r.Fragment,{children:[Gt?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[r.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):Fe&&Li==="saved"&&!ze?r.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[r.jsx(F,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ze?h(e(Fe?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{Mt()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(Fe?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:r.jsx(F,{name:"save-3",className:"size-4"})})):null,h(e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Ii(!Fe),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Fe?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(Fe?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:Fe?r.jsx(F,{name:"file-check-fill",className:"size-4"}):r.jsx(F,{name:"file-check",className:"size-4"})}))]}),r.jsxs(jn,{onOpenChange:Se,children:[r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex",children:r.jsx(Fn,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:r.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),r.jsxs(Nn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[Xi.map(b=>r.jsxs(Ir,{className:"flex items-center gap-2",onClick:()=>{Zi(b)},children:[r.jsx(al,{label:b.label,iconDataUrl:b.iconDataUrl}),r.jsx("span",{className:"typography-ui-label text-foreground",children:b.label})]},b.id)),Ji?r.jsxs(Ir,{className:"flex items-center gap-2",onClick:()=>{Qi(!0)},children:[r.jsx(F,{name:"refresh",className:"size-4"}),r.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Ne&&!$e&&!st&&r.jsxs(r.Fragment,{children:[h(e(X?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Ce(!X),className:q("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",X?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(X?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:r.jsx(F,{name:"text-wrap",className:"size-4"})})),B==="edit"&&r.jsxs(r.Fragment,{children:[h(e("filesView.editor.findInFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:b=>{ce(!ee),b.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:r.jsx(F,{name:"search",className:"size-4"})})),h(e("filesView.editor.goToLine"),r.jsx(O,{variant:"ghost",size:"sm",onClick:b=>{Zr(R=>!R),b.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:r.jsx(F,{name:"menu-fold-2",className:"size-4"})})),r.jsx(Wo,{open:Gi,onOpenChange:Zr,view:Ue.current,variant:"inline"})]})]}),Er&&He&&!Lt&&!At&&r.jsx(wn,{currentMode:B==="view"?"preview":"edit",onToggle:()=>{ma(B==="view"?"edit":"view")}}),qe&&h(e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>ha(Le()==="preview"?"edit":"preview"),className:q("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",Le()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(Le()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:r.jsx(F,{name:Le()==="preview"?"eye":"eye-off",className:"size-4"})})),yn(c?.path??"")&&r.jsx(wn,{currentMode:gs(),onToggle:()=>{ga(gs()==="preview"?"edit":"preview")}}),qe&&Le()==="preview"&&h(e("filesView.editor.findInFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{xr(!0),$n(b=>b+1)},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:r.jsx(F,{name:"search",className:"size-4"})})),qe&&Le()==="preview"&&ea&&r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx(O,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(hr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{hr?Vi():z.trim()&&Ei(z)},children:hr?r.jsx(F,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"volume-up",className:"size-4"})})}),r.jsx($t,{sideOffset:8,children:e(hr?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),sr&&r.jsxs(r.Fragment,{children:[r.jsx(wn,{currentMode:re,onToggle:()=>va(re==="preview"?"edit":"preview")}),re==="preview"&&r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{const b=Dn.current?.getXml();if(De.current&&(clearTimeout(De.current),De.current=null),c?.path&&b){if(!await un(c.path,b))return;gr(!0),setTimeout(()=>gr(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:Ai?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"save-3",className:"size-4"})})]}),Lt&&h(e(ae==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>pa(ae==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ae==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ae==="tree"?r.jsx(F,{name:"code-sslash",className:"size-4"}):r.jsx(F,{name:"node-tree",className:"size-4"})})),ua&&h(e("filesView.editor.copyFileContents"),r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{(await Br(z)).ok?(An(!0),er.current!==null&&window.clearTimeout(er.current),er.current=window.setTimeout(()=>{An(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:Hi?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"clipboard",className:"size-4"})})),da&&h(e("filesView.editor.copyFilePathTitle",{path:pt}),r.jsx(O,{variant:"ghost",size:"sm",onClick:async()=>{(await Br(pt)).ok?(In(!0),tr.current!==null&&window.clearTimeout(tr.current),tr.current=window.setTimeout(()=>{In(!1)},1200)):Q.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:pt}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:pt}),children:qi?r.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):r.jsx(F,{name:"file-copy-2",className:"size-4"})})),n.downloadFile&&h(e("filesView.editor.saveFile"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{const b=n.downloadFile;b&&b(c.path).catch(R=>{console.error("Download failed:",R),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:r.jsx(F,{name:"download",className:"size-4"})})),t?h(e("filesView.editor.exitFullscreen"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:r.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!f&&a==="full"&&h(e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>Y(!W),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(W?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:W?r.jsx(F,{name:"fullscreen-exit",className:"size-4"}):r.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},mn=r.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[r.jsx(vi,{open:Xr,onOpenChange:t=>{t||Qt(!0)},children:r.jsxs(xi,{showCloseButton:!1,className:"max-w-md",children:[r.jsxs(wi,{children:[r.jsx(bi,{children:e("filesView.unsaved.title")}),r.jsx(yi,{children:e("filesView.unsaved.description")})]}),r.jsxs(ji,{children:[r.jsx(O,{variant:"outline",onClick:()=>{ia()},disabled:Gt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),r.jsx(O,{variant:"destructive",onClick:sa,children:e("filesView.unsaved.discard")})]})]})}),r.jsxs("div",{className:q("flex flex-col flex-shrink-0",E&&"border-b border-border/40"),children:[E?r.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[f&&_&&r.jsx("button",{type:"button",onClick:()=>L(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:r.jsx(F,{name:"arrow-left-s",className:"size-5"})}),f?c?r.jsxs(jn,{children:[r.jsx(Fn,{asChild:!0,children:r.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[r.jsx(Ar,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(di,{name:c.name}),r.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),r.jsx(Nn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:St.map(t=>{const i=c?.path===t.path;return r.jsxs(Ir,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Te(t)},className:q("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[r.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[r.jsx(Ar,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),r.jsx(di,{name:t.name})]}),r.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),ds(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:r.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):St.length>0?r.jsxs("div",{className:"relative min-w-0 flex-1",children:[kn.left&&r.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),kn.right&&r.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),r.jsx("div",{ref:Ur,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:St.map(t=>{const i=c?.path===t.path;return r.jsxs("div",{title:Or(o,t.path),className:q("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[r.jsx(Ar,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),r.jsx("button",{type:"button",onClick:()=>{i||Te(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),r.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),ds(t.path)},className:q("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!N&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:r.jsx(F,{name:"close",className:"size-3.5"})})]},t.path)})})]}):r.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?r.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[pt&&!f?r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:pt,children:pt}):null,r.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Os({layout:"docked"})})]}):null]}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:r.jsx(vn,{ref:Sa,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ge&&"[overflow-anchor:none]"),children:c?Me||Fs?D?r.jsx("div",{className:"p-3"}):r.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Qe?r.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Qe}):Ne?r.jsx("div",{className:"flex h-full items-center justify-center p-3",children:r.jsx("img",{src:Ns,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):$e?Ss(c):st?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?r.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&sr&&re==="preview"?r.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:r.jsx(sl,{ref:Dn,xml:wa,onChange:xa},`${c.path}:${ke}`)}):c&&Lt&&ae==="tree"?r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:r.jsx("div",{className:"h-full overflow-auto",children:r.jsx(yo,{jsonString:z,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&qe&&Le()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3 outline-none",tabIndex:-1,onMouseDown:br,ref:Ra,children:[r.jsx(si,{containerRef:Jn,filePath:c.path,fileContent:z}),z.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(z.length/1024)})}),r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:r.jsx(ti,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),!W&&r.jsx(oi,{containerRef:wr,open:On,onOpenChange:xr,focusNonce:Bn})]}):c&&At&&$==="preview"?ya?r.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):r.jsx("div",{className:"h-full overflow-hidden",children:r.jsx("iframe",{src:!d.isVSCode&&bs===Mr?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return qs().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?z.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):z})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},ba)}):c&&Er&&B==="view"?Is(c,Ge?z:ie,ks,Na):r.jsxs("div",{className:q("relative h-full",zt&&"overflow-hidden"),ref:vr,children:[r.jsx("div",{className:q("h-full",zt&&"invisible"),children:r.jsx(hi,{positionKey:ut,value:ie,onChange:je,readOnly:!He,vimMode:Xn==="vim",extensions:vs,className:"h-full",blockWidgets:Fa,onViewReady:t=>{Ue.current=t,Jr(i=>i+1),window.requestAnimationFrame(()=>{It(t)})},onViewDestroy:()=>{Ue.current&&(Ue.current=null),Jr(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:ce,highlightLines:U?{start:Math.min(U.start,U.end),end:Math.max(U.start,U.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(U&&!l.shiftKey&&Math.min(U.start,U.end)===u&&Math.max(U.start,U.end)===u)return Ke(null),nr(),Vt.current=!1,mt.current=null,Pt(!1),!0;if(f&&U&&!l.shiftKey){const p=Math.min(U.start,U.end,u),h=Math.max(U.start,U.end,u);return Ke({start:p,end:h}),Vt.current=!1,mt.current=null,Pt(!1),!0}if(Vt.current=!0,mt.current=u,Pt(!0),U&&l.shiftKey){const p=Math.min(U.start,u),h=Math.max(U.end,u);Ke({start:p,end:h})}else Ke({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Vt.current||mt.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,p=Math.min(mt.current,u),h=Math.max(mt.current,u);return Ke({start:p,end:h}),Pt(!0),!1},mouseup:()=>(Vt.current=!1,mt.current=null,Pt(!1),!1)}}},ut)}),zt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):r.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),Ea=!!(o&&En[o]),Bs=o?dr[o]:null,$s=r.jsxs("section",{className:q("flex min-h-0 flex-col overflow-hidden",f?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[r.jsx("div",{className:q("flex flex-col gap-2 py-2",f?"px-3":"px-2"),children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("div",{className:"relative flex-1 min-w-0",children:[r.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),r.jsx(lr,{ref:I,value:P,onChange:t=>M(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),P.trim().length>0&&r.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{M(""),I.current?.focus()},children:r.jsx(F,{name:"close",className:"size-4"})})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>en("createFile",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:r.jsx(F,{name:"file-add",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>en("createFolder",{path:T,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:r.jsx(F,{name:"folder-add",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),r.jsxs(Ot,{children:[r.jsx(Bt,{asChild:!0,children:r.jsx("span",{className:"inline-flex flex-shrink-0",children:r.jsx(O,{variant:"ghost",size:"sm",onClick:()=>{Cr()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:r.jsx(F,{name:"refresh",className:"size-4"})})})}),r.jsx($t,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),r.jsx(vn,{outerClassName:"flex-1 min-h-0",className:q("py-2",f?"px-3":"px-2"),children:r.jsx("ul",{className:"flex flex-col",children:Ti?r.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):Pn.length>0?Pn.map(t=>{const i=c?.path===t.path;return r.jsx("li",{children:r.jsxs("button",{type:"button",onClick:()=>{Te(t)},className:q("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Si(t.path,t.extension),r.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):Bs?r.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[r.jsx("span",{className:"text-[var(--status-error)]",children:Bs}),r.jsxs(O,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{Cr()},children:[r.jsx(F,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Ea?fs(o,0):r.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Va=a==="full"&&W&&c&&r.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:r.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[r.jsx("div",{className:"absolute right-4 top-4 z-30",children:Os({exitFullscreenOnly:!0})}),r.jsx(vn,{ref:ka,outerClassName:"h-full min-w-0",className:q("h-full min-w-0",Ge&&"[overflow-anchor:none]"),children:Me||Fs?D?r.jsx("div",{className:"p-4"}):r.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Qe?r.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Qe}):Ne?r.jsx("div",{className:"flex h-full items-center justify-center p-4",children:r.jsx("img",{src:Ns,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):$e?Ss(c):st?r.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[r.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),r.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?r.jsxs(O,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),Q.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[r.jsx(F,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):qe&&Le()==="preview"?r.jsxs("div",{className:"relative h-full min-h-0",children:[r.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4 outline-none",tabIndex:-1,onMouseDown:br,ref:Ta,children:[c?r.jsx(si,{containerRef:yr,filePath:c.path,fileContent:z}):null,z.length>500*1024&&r.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(z.length/1024)})}),r.jsx(xn,{fallback:r.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[r.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),r.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:r.jsx(ti,{content:z,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}),r.jsx(oi,{containerRef:yr,open:On,onOpenChange:xr,focusNonce:Bn,className:"right-4 top-16"})]}):Er&&B==="view"?Is(c,Ge?z:ie,Rs,Ca):r.jsxs("div",{className:q("relative h-full",zt&&"overflow-hidden"),children:[r.jsx("div",{className:q("h-full",zt&&"invisible"),children:r.jsx(hi,{positionKey:`${ut}:fullscreen`,value:ie,onChange:je,readOnly:!He,vimMode:Xn==="vim",extensions:vs,className:"h-full",onViewReady:t=>{Ue.current=t,window.requestAnimationFrame(()=>{It(t)})},onViewDestroy:()=>{Ue.current&&(Ue.current=null)}},`${ut}:fullscreen`)}),zt&&r.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:r.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[r.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return r.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[r.jsx(bl,{activeDialog:yt,dialogData:jt,dialogInputValue:ft,onDialogInputChange:Ln,isDialogSubmitting:$i,onDialogSubmit:na,onClose:ja,inputRef:Di}),Va,f?_?mn:$s:a==="editor-only"?r.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:mn})}):r.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[m>=700&&r.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:$s}),r.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:mn})]})]})};function jl(a){return a+1}export{Wu as FilesView};