@jingyi0605/codingns 0.8.0 → 0.8.1

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 (425) hide show
  1. package/dist/public/assets/{AdaptiveButlerPage-BsgVNRAa.js → AdaptiveButlerPage-b7s6F_sd.js} +1 -1
  2. package/dist/public/assets/{App-tPcbyRdS.js → App-B0q8uDA-.js} +3 -3
  3. package/dist/public/assets/{BootstrapPage--MDOigQi.js → BootstrapPage-jFfl7KNK.js} +1 -1
  4. package/dist/public/assets/{ConversationPage-BBss5ED8.js → ConversationPage-sj_rn4q0.js} +1 -1
  5. package/dist/public/assets/{DesktopDetachPreviewPage-CB8DoqwU.js → DesktopDetachPreviewPage-C5c88SOX.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-GtIx5m8K.js → DesktopWindowPage-BdKUZrKG.js} +1 -1
  7. package/dist/public/assets/{FileContextPanel-BcM7AIT4.js → FileContextPanel-lM5mBcfn.js} +1 -1
  8. package/dist/public/assets/{GitSidebar-CMtkaxuI.js → GitSidebar-CmXAhyjo.js} +1 -1
  9. package/dist/public/assets/{MobileCreateSessionSheet-CrFY41_8.js → MobileCreateSessionSheet-CceV0-AH.js} +1 -1
  10. package/dist/public/assets/{MobileTopHeaderFrame-DGVOzXyg.js → MobileTopHeaderFrame-_I0t7cC_.js} +1 -1
  11. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-DLkACTnQ.js → MobileWorkspaceSwitcherHeader-DhaM9fgx.js} +1 -1
  12. package/dist/public/assets/{RelayConnectEntryPage-0MPPjxtQ.js → RelayConnectEntryPage-CMtDWyGS.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-vgOhwus4.js → ServerSettingsModal-Rkgn3jft.js} +1 -1
  14. package/dist/public/assets/{SessionIndexPage-KK626Ra9.js → SessionIndexPage-BOumP3ij.js} +1 -1
  15. package/dist/public/assets/{SettingsPage-B3edBJIo.js → SettingsPage-vx_c-00-.js} +1 -1
  16. package/dist/public/assets/{TerminalManagerPanel-BxlhZp8c.js → TerminalManagerPanel-D9JHCS6d.js} +1 -1
  17. package/dist/public/assets/{TerminalPage-B6Rdhylx.js → TerminalPage-CBIKHI33.js} +1 -1
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-BVLfrpSa.js → TerminalRuntimeFallbackModal-W5NjqFEz.js} +1 -1
  19. package/dist/public/assets/{ToolFilesPage-N_gwwUjD.js → ToolFilesPage-DWtpaN_7.js} +1 -1
  20. package/dist/public/assets/{ToolGitPage-DOcuuWM1.js → ToolGitPage-MpGXsw4_.js} +1 -1
  21. package/dist/public/assets/{ToolProcessesPage-D-FfJ7Re.js → ToolProcessesPage-B1jHQKhZ.js} +1 -1
  22. package/dist/public/assets/{ToolsHomePage-CHfPxd20.js → ToolsHomePage-CJrn8ZFl.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-CTTnfovY.js → WorkbenchLandingPage-CJQ1V5U-.js} +1 -1
  24. package/dist/public/assets/{WorkbenchLayout-CbpJg0g1.js → WorkbenchLayout-D48i71PU.js} +3 -3
  25. package/dist/public/assets/{WorkbenchModal-Bt_1fYmM.js → WorkbenchModal-BYNuMIoV.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-CGKjy4J-.js +1 -0
  27. package/dist/public/assets/{WorkspaceDebugDetailPage-s7yuDIxR.js → WorkspaceDebugDetailPage-DCAYgays.js} +1 -1
  28. package/dist/public/assets/{WorkspaceDetailPage-Cf-gVpqK.js → WorkspaceDetailPage-D5v-nUIi.js} +1 -1
  29. package/dist/public/assets/{WorkspaceHomePage-COf6I8sT.js → WorkspaceHomePage-I5G1p5SR.js} +1 -1
  30. package/dist/public/assets/{client-runtime-manager-DGdKvYzx.js → client-runtime-manager-CdJP7nUp.js} +1 -1
  31. package/dist/public/assets/{file-tree-icon-BeHqeru9.js → file-tree-icon-BFwaPxKs.js} +6 -6
  32. package/dist/public/assets/{index-CuzMc7q2.js → index-CjewzOUG.js} +3 -3
  33. package/dist/public/assets/{index-CcaQt50x.css → index-VVxfF0s5.css} +1 -1
  34. package/dist/public/assets/{login-direct-candidate-resolver-DEP_xCmR.js → login-direct-candidate-resolver-C-mo698r.js} +1 -1
  35. package/dist/public/assets/{model-switch-api-c6kcbBGm.js → model-switch-api-Br0ivfe5.js} +1 -1
  36. package/dist/public/assets/{preferences-service-CV6Ih0BG.js → preferences-service-CnaTvZq2.js} +1 -1
  37. package/dist/public/assets/{realtime-client-CRCx5xBt.js → realtime-client-BlQRqVmm.js} +1 -1
  38. package/dist/public/assets/{relay-entry-C751A-Sm.js → relay-entry-D7OgZZN-.js} +1 -1
  39. package/dist/public/assets/{terminal-runtime-meta-CRAVR-8G.js → terminal-runtime-meta-BCtAYB0E.js} +1 -1
  40. package/dist/public/assets/{useRegisteredDebugTemplates-D6YtNS0r.js → useRegisteredDebugTemplates-CXmxu69X.js} +1 -1
  41. package/dist/public/index.html +2 -2
  42. package/dist/server/main.js +2 -0
  43. package/dist/server/main.js.map +1 -1
  44. package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +1 -0
  45. package/dist/server/modules/assistant-capability/assistant-capability-controller.js +1 -0
  46. package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
  47. package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +1 -0
  48. package/dist/server/modules/assistant-capability/assistant-capability-service.js +1 -0
  49. package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
  50. package/dist/server/modules/browser-runtime/browser-runtime-controller.d.ts +2 -1
  51. package/dist/server/modules/browser-runtime/browser-runtime-controller.js +1 -0
  52. package/dist/server/modules/browser-runtime/browser-runtime-controller.js.map +1 -1
  53. package/dist/server/modules/browser-runtime/browser-runtime-service.d.ts +4 -1
  54. package/dist/server/modules/browser-runtime/browser-runtime-service.js +40 -0
  55. package/dist/server/modules/browser-runtime/browser-runtime-service.js.map +1 -1
  56. package/dist/server/modules/browser-runtime/browser-task-payload.d.ts +2 -0
  57. package/dist/server/modules/browser-runtime/browser-task-payload.js.map +1 -1
  58. package/dist/server/modules/git/git-command-helper-process.js +0 -18
  59. package/dist/server/modules/git/git-command-helper-process.js.map +1 -1
  60. package/dist/server/modules/git/git-command-runner.js +0 -18
  61. package/dist/server/modules/git/git-command-runner.js.map +1 -1
  62. package/dist/server/modules/sessions/session-live-runtime-service.js +46 -3
  63. package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
  64. package/dist/server/modules/sessions/workspace-session-runtime-context-service.d.ts +1 -0
  65. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js +11 -2
  66. package/dist/server/modules/sessions/workspace-session-runtime-context-service.js.map +1 -1
  67. package/dist/server/modules/skills/builtin-skills/codingns-workspace-session/SKILL.md +2 -2
  68. package/dist/server/shared/http/error-handler.js +53 -19
  69. package/dist/server/shared/http/error-handler.js.map +1 -1
  70. package/dist/server/shared/utils/install-console-timestamp-prefix.d.ts +1 -0
  71. package/dist/server/shared/utils/install-console-timestamp-prefix.js +28 -0
  72. package/dist/server/shared/utils/install-console-timestamp-prefix.js.map +1 -0
  73. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.d.ts +42 -0
  74. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js +346 -0
  75. package/node_modules/@codingns/session-sync-core/dist/claude-message-utils.js.map +1 -0
  76. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.d.ts +1 -0
  77. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js +80 -0
  78. package/node_modules/@codingns/session-sync-core/dist/codex-resume-history.js.map +1 -0
  79. package/node_modules/@codingns/session-sync-core/dist/index.d.ts +18 -0
  80. package/node_modules/@codingns/session-sync-core/dist/index.js +19 -0
  81. package/node_modules/@codingns/session-sync-core/dist/index.js.map +1 -0
  82. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.d.ts +18 -0
  83. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js +659 -0
  84. package/node_modules/@codingns/session-sync-core/dist/kimi-message-normalizer.js.map +1 -0
  85. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.d.ts +11 -0
  86. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js +72 -0
  87. package/node_modules/@codingns/session-sync-core/dist/kimi-shared.js.map +1 -0
  88. package/node_modules/@codingns/session-sync-core/dist/patch-builder.d.ts +67 -0
  89. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js +752 -0
  90. package/node_modules/@codingns/session-sync-core/dist/patch-builder.js.map +1 -0
  91. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.d.ts +48 -0
  92. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js +1184 -0
  93. package/node_modules/@codingns/session-sync-core/dist/providers/claude-code.js.map +1 -0
  94. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.d.ts +11 -0
  95. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js +105 -0
  96. package/node_modules/@codingns/session-sync-core/dist/providers/claude-session-store.js.map +1 -0
  97. package/node_modules/@codingns/session-sync-core/dist/providers/codex.d.ts +84 -0
  98. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js +2436 -0
  99. package/node_modules/@codingns/session-sync-core/dist/providers/codex.js.map +1 -0
  100. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.d.ts +47 -0
  101. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js +1480 -0
  102. package/node_modules/@codingns/session-sync-core/dist/providers/gemini.js.map +1 -0
  103. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.d.ts +33 -0
  104. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js +684 -0
  105. package/node_modules/@codingns/session-sync-core/dist/providers/kimi.js.map +1 -0
  106. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.d.ts +9 -0
  107. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js +17 -0
  108. package/node_modules/@codingns/session-sync-core/dist/providers/legna-code.js.map +1 -0
  109. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.d.ts +1 -0
  110. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js +8 -0
  111. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-permissions.js.map +1 -0
  112. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.d.ts +48 -0
  113. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js +373 -0
  114. package/node_modules/@codingns/session-sync-core/dist/providers/opencode-shared.js.map +1 -0
  115. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.d.ts +61 -0
  116. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js +1191 -0
  117. package/node_modules/@codingns/session-sync-core/dist/providers/opencode.js.map +1 -0
  118. package/node_modules/@codingns/session-sync-core/dist/providers/utils.d.ts +27 -0
  119. package/node_modules/@codingns/session-sync-core/dist/providers/utils.js +415 -0
  120. package/node_modules/@codingns/session-sync-core/dist/providers/utils.js.map +1 -0
  121. package/node_modules/@codingns/session-sync-core/dist/registry.d.ts +7 -0
  122. package/node_modules/@codingns/session-sync-core/dist/registry.js +22 -0
  123. package/node_modules/@codingns/session-sync-core/dist/registry.js.map +1 -0
  124. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.d.ts +24 -0
  125. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js +329 -0
  126. package/node_modules/@codingns/session-sync-core/dist/runtime/active-run-registry.js.map +1 -0
  127. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.d.ts +30 -0
  128. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js +939 -0
  129. package/node_modules/@codingns/session-sync-core/dist/runtime/claude-runtime.js.map +1 -0
  130. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.d.ts +1 -0
  131. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js +16 -0
  132. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-permissions.js.map +1 -0
  133. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.d.ts +70 -0
  134. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js +2571 -0
  135. package/node_modules/@codingns/session-sync-core/dist/runtime/codex-runtime.js.map +1 -0
  136. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.d.ts +21 -0
  137. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js +561 -0
  138. package/node_modules/@codingns/session-sync-core/dist/runtime/gemini-runtime.js.map +1 -0
  139. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.d.ts +38 -0
  140. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js +911 -0
  141. package/node_modules/@codingns/session-sync-core/dist/runtime/kimi-runtime.js.map +1 -0
  142. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.d.ts +15 -0
  143. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js +16 -0
  144. package/node_modules/@codingns/session-sync-core/dist/runtime/legna-runtime.js.map +1 -0
  145. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.d.ts +38 -0
  146. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js +970 -0
  147. package/node_modules/@codingns/session-sync-core/dist/runtime/opencode-runtime.js.map +1 -0
  148. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.d.ts +21 -0
  149. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js +168 -0
  150. package/node_modules/@codingns/session-sync-core/dist/runtime/provider-runtime-service.js.map +1 -0
  151. package/node_modules/@codingns/session-sync-core/dist/runtime/types.d.ts +152 -0
  152. package/node_modules/@codingns/session-sync-core/dist/runtime/types.js +2 -0
  153. package/node_modules/@codingns/session-sync-core/dist/runtime/types.js.map +1 -0
  154. package/node_modules/@codingns/session-sync-core/dist/services.d.ts +28 -0
  155. package/node_modules/@codingns/session-sync-core/dist/services.js +148 -0
  156. package/node_modules/@codingns/session-sync-core/dist/services.js.map +1 -0
  157. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.d.ts +6 -0
  158. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js +9 -0
  159. package/node_modules/@codingns/session-sync-core/dist/sqlite/node-sqlite.js.map +1 -0
  160. package/node_modules/@codingns/session-sync-core/dist/types.d.ts +198 -0
  161. package/node_modules/@codingns/session-sync-core/dist/types.js +2 -0
  162. package/node_modules/@codingns/session-sync-core/dist/types.js.map +1 -0
  163. package/node_modules/@codingns/session-sync-core/package.json +33 -0
  164. package/package.json +6 -4
  165. package/vendor/node-pty-fork/LICENSE +69 -0
  166. package/vendor/node-pty-fork/README.md +91 -0
  167. package/vendor/node-pty-fork/binding.gyp +117 -0
  168. package/vendor/node-pty-fork/deps/.editorconfig +2 -0
  169. package/vendor/node-pty-fork/deps/winpty/.drone.yml +17 -0
  170. package/vendor/node-pty-fork/deps/winpty/.gitattributes +19 -0
  171. package/vendor/node-pty-fork/deps/winpty/LICENSE +21 -0
  172. package/vendor/node-pty-fork/deps/winpty/Makefile +166 -0
  173. package/vendor/node-pty-fork/deps/winpty/README.md +151 -0
  174. package/vendor/node-pty-fork/deps/winpty/RELEASES.md +280 -0
  175. package/vendor/node-pty-fork/deps/winpty/VERSION.txt +1 -0
  176. package/vendor/node-pty-fork/deps/winpty/configure +167 -0
  177. package/vendor/node-pty-fork/deps/winpty/misc/BufferResizeTests.cc +90 -0
  178. package/vendor/node-pty-fork/deps/winpty/misc/ChangeScreenBuffer.cc +53 -0
  179. package/vendor/node-pty-fork/deps/winpty/misc/ClearConsole.cc +72 -0
  180. package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.cc +117 -0
  181. package/vendor/node-pty-fork/deps/winpty/misc/ConinMode.ps1 +116 -0
  182. package/vendor/node-pty-fork/deps/winpty/misc/ConoutMode.cc +113 -0
  183. package/vendor/node-pty-fork/deps/winpty/misc/DebugClient.py +42 -0
  184. package/vendor/node-pty-fork/deps/winpty/misc/DebugServer.py +63 -0
  185. package/vendor/node-pty-fork/deps/winpty/misc/DumpLines.py +5 -0
  186. package/vendor/node-pty-fork/deps/winpty/misc/EnableExtendedFlags.txt +46 -0
  187. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Consolas.txt +528 -0
  188. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP437-Lucida.txt +633 -0
  189. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP932.txt +630 -0
  190. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP936.txt +630 -0
  191. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP949.txt +630 -0
  192. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/CP950.txt +630 -0
  193. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/MinimumWindowWidths.txt +16 -0
  194. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Results.txt +4 -0
  195. package/vendor/node-pty-fork/deps/winpty/misc/Font-Report-June2016/Windows10SetFontBugginess.txt +144 -0
  196. package/vendor/node-pty-fork/deps/winpty/misc/FontSurvey.cc +100 -0
  197. package/vendor/node-pty-fork/deps/winpty/misc/FormatChar.h +21 -0
  198. package/vendor/node-pty-fork/deps/winpty/misc/FreezePerfTest.cc +62 -0
  199. package/vendor/node-pty-fork/deps/winpty/misc/GetCh.cc +20 -0
  200. package/vendor/node-pty-fork/deps/winpty/misc/GetConsolePos.cc +41 -0
  201. package/vendor/node-pty-fork/deps/winpty/misc/GetFont.cc +261 -0
  202. package/vendor/node-pty-fork/deps/winpty/misc/IdentifyConsoleWindow.ps1 +51 -0
  203. package/vendor/node-pty-fork/deps/winpty/misc/IsNewConsole.cc +87 -0
  204. package/vendor/node-pty-fork/deps/winpty/misc/MouseInputNotes.txt +90 -0
  205. package/vendor/node-pty-fork/deps/winpty/misc/MoveConsoleWindow.cc +34 -0
  206. package/vendor/node-pty-fork/deps/winpty/misc/Notes.txt +219 -0
  207. package/vendor/node-pty-fork/deps/winpty/misc/OSVersion.cc +27 -0
  208. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferFreezeInactive.cc +101 -0
  209. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest.cc +671 -0
  210. package/vendor/node-pty-fork/deps/winpty/misc/ScreenBufferTest2.cc +151 -0
  211. package/vendor/node-pty-fork/deps/winpty/misc/SelectAllTest.cc +45 -0
  212. package/vendor/node-pty-fork/deps/winpty/misc/SetBufferSize.cc +32 -0
  213. package/vendor/node-pty-fork/deps/winpty/misc/SetCursorPos.cc +10 -0
  214. package/vendor/node-pty-fork/deps/winpty/misc/SetFont.cc +145 -0
  215. package/vendor/node-pty-fork/deps/winpty/misc/SetWindowRect.cc +36 -0
  216. package/vendor/node-pty-fork/deps/winpty/misc/ShowArgv.cc +12 -0
  217. package/vendor/node-pty-fork/deps/winpty/misc/ShowConsoleInput.cc +40 -0
  218. package/vendor/node-pty-fork/deps/winpty/misc/Spew.py +5 -0
  219. package/vendor/node-pty-fork/deps/winpty/misc/TestUtil.cc +172 -0
  220. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeDoubleWidthTest.cc +102 -0
  221. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest1.cc +246 -0
  222. package/vendor/node-pty-fork/deps/winpty/misc/UnicodeWideTest2.cc +130 -0
  223. package/vendor/node-pty-fork/deps/winpty/misc/UnixEcho.cc +89 -0
  224. package/vendor/node-pty-fork/deps/winpty/misc/Utf16Echo.cc +46 -0
  225. package/vendor/node-pty-fork/deps/winpty/misc/VeryLargeRead.cc +122 -0
  226. package/vendor/node-pty-fork/deps/winpty/misc/VkEscapeTest.cc +56 -0
  227. package/vendor/node-pty-fork/deps/winpty/misc/Win10ResizeWhileFrozen.cc +52 -0
  228. package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest1.cc +57 -0
  229. package/vendor/node-pty-fork/deps/winpty/misc/Win10WrapTest2.cc +30 -0
  230. package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo1.cc +26 -0
  231. package/vendor/node-pty-fork/deps/winpty/misc/Win32Echo2.cc +19 -0
  232. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test1.cc +46 -0
  233. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test2.cc +70 -0
  234. package/vendor/node-pty-fork/deps/winpty/misc/Win32Test3.cc +78 -0
  235. package/vendor/node-pty-fork/deps/winpty/misc/Win32Write1.cc +44 -0
  236. package/vendor/node-pty-fork/deps/winpty/misc/WindowsBugCrashReader.cc +27 -0
  237. package/vendor/node-pty-fork/deps/winpty/misc/WriteConsole.cc +106 -0
  238. package/vendor/node-pty-fork/deps/winpty/misc/build32.sh +9 -0
  239. package/vendor/node-pty-fork/deps/winpty/misc/build64.sh +9 -0
  240. package/vendor/node-pty-fork/deps/winpty/misc/color-test.sh +212 -0
  241. package/vendor/node-pty-fork/deps/winpty/misc/font-notes.txt +300 -0
  242. package/vendor/node-pty-fork/deps/winpty/misc/winbug-15048.cc +201 -0
  243. package/vendor/node-pty-fork/deps/winpty/ship/build-pty4j-libpty.bat +36 -0
  244. package/vendor/node-pty-fork/deps/winpty/ship/common_ship.py +53 -0
  245. package/vendor/node-pty-fork/deps/winpty/ship/make_msvc_package.py +165 -0
  246. package/vendor/node-pty-fork/deps/winpty/ship/ship.py +108 -0
  247. package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.cc +605 -0
  248. package/vendor/node-pty-fork/deps/winpty/src/agent/Agent.h +103 -0
  249. package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.cc +84 -0
  250. package/vendor/node-pty-fork/deps/winpty/src/agent/AgentCreateDesktop.h +28 -0
  251. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.cc +632 -0
  252. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleFont.h +28 -0
  253. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.cc +852 -0
  254. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInput.h +109 -0
  255. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.cc +121 -0
  256. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleInputReencoding.h +36 -0
  257. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.cc +152 -0
  258. package/vendor/node-pty-fork/deps/winpty/src/agent/ConsoleLine.h +41 -0
  259. package/vendor/node-pty-fork/deps/winpty/src/agent/Coord.h +87 -0
  260. package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.cc +239 -0
  261. package/vendor/node-pty-fork/deps/winpty/src/agent/DebugShowInput.h +32 -0
  262. package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.cc +422 -0
  263. package/vendor/node-pty-fork/deps/winpty/src/agent/DefaultInputMap.h +28 -0
  264. package/vendor/node-pty-fork/deps/winpty/src/agent/DsrSender.h +30 -0
  265. package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.cc +99 -0
  266. package/vendor/node-pty-fork/deps/winpty/src/agent/EventLoop.h +47 -0
  267. package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.cc +246 -0
  268. package/vendor/node-pty-fork/deps/winpty/src/agent/InputMap.h +114 -0
  269. package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.cc +71 -0
  270. package/vendor/node-pty-fork/deps/winpty/src/agent/LargeConsoleRead.h +68 -0
  271. package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.cc +378 -0
  272. package/vendor/node-pty-fork/deps/winpty/src/agent/NamedPipe.h +125 -0
  273. package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.cc +699 -0
  274. package/vendor/node-pty-fork/deps/winpty/src/agent/Scraper.h +103 -0
  275. package/vendor/node-pty-fork/deps/winpty/src/agent/SimplePool.h +75 -0
  276. package/vendor/node-pty-fork/deps/winpty/src/agent/SmallRect.h +143 -0
  277. package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.cc +535 -0
  278. package/vendor/node-pty-fork/deps/winpty/src/agent/Terminal.h +69 -0
  279. package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncoding.h +157 -0
  280. package/vendor/node-pty-fork/deps/winpty/src/agent/UnicodeEncodingTest.cc +189 -0
  281. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.cc +107 -0
  282. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32Console.h +67 -0
  283. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.cc +193 -0
  284. package/vendor/node-pty-fork/deps/winpty/src/agent/Win32ConsoleBuffer.h +99 -0
  285. package/vendor/node-pty-fork/deps/winpty/src/agent/main.cc +114 -0
  286. package/vendor/node-pty-fork/deps/winpty/src/agent/subdir.mk +61 -0
  287. package/vendor/node-pty-fork/deps/winpty/src/configurations.gypi +60 -0
  288. package/vendor/node-pty-fork/deps/winpty/src/debugserver/DebugServer.cc +117 -0
  289. package/vendor/node-pty-fork/deps/winpty/src/debugserver/subdir.mk +41 -0
  290. package/vendor/node-pty-fork/deps/winpty/src/include/winpty.h +242 -0
  291. package/vendor/node-pty-fork/deps/winpty/src/include/winpty_constants.h +131 -0
  292. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.cc +75 -0
  293. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/AgentLocation.h +28 -0
  294. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/LibWinptyException.h +54 -0
  295. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/WinptyInternal.h +72 -0
  296. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/subdir.mk +46 -0
  297. package/vendor/node-pty-fork/deps/winpty/src/libwinpty/winpty.cc +970 -0
  298. package/vendor/node-pty-fork/deps/winpty/src/shared/AgentMsg.h +38 -0
  299. package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.cc +122 -0
  300. package/vendor/node-pty-fork/deps/winpty/src/shared/BackgroundDesktop.h +73 -0
  301. package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.cc +103 -0
  302. package/vendor/node-pty-fork/deps/winpty/src/shared/Buffer.h +102 -0
  303. package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.cc +187 -0
  304. package/vendor/node-pty-fork/deps/winpty/src/shared/DebugClient.h +38 -0
  305. package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.cc +138 -0
  306. package/vendor/node-pty-fork/deps/winpty/src/shared/GenRandom.h +55 -0
  307. package/vendor/node-pty-fork/deps/winpty/src/shared/GetCommitHash.bat +13 -0
  308. package/vendor/node-pty-fork/deps/winpty/src/shared/Mutex.h +54 -0
  309. package/vendor/node-pty-fork/deps/winpty/src/shared/OsModule.h +63 -0
  310. package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.cc +36 -0
  311. package/vendor/node-pty-fork/deps/winpty/src/shared/OwnedHandle.h +45 -0
  312. package/vendor/node-pty-fork/deps/winpty/src/shared/PrecompiledHeader.h +43 -0
  313. package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilder.h +227 -0
  314. package/vendor/node-pty-fork/deps/winpty/src/shared/StringBuilderTest.cc +114 -0
  315. package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.cc +55 -0
  316. package/vendor/node-pty-fork/deps/winpty/src/shared/StringUtil.h +80 -0
  317. package/vendor/node-pty-fork/deps/winpty/src/shared/TimeMeasurement.h +63 -0
  318. package/vendor/node-pty-fork/deps/winpty/src/shared/UnixCtrlChars.h +45 -0
  319. package/vendor/node-pty-fork/deps/winpty/src/shared/UpdateGenVersion.bat +20 -0
  320. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.cc +460 -0
  321. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsSecurity.h +104 -0
  322. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.cc +252 -0
  323. package/vendor/node-pty-fork/deps/winpty/src/shared/WindowsVersion.h +29 -0
  324. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.cc +55 -0
  325. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyAssert.h +64 -0
  326. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.cc +57 -0
  327. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyException.h +43 -0
  328. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.cc +42 -0
  329. package/vendor/node-pty-fork/deps/winpty/src/shared/WinptyVersion.h +27 -0
  330. package/vendor/node-pty-fork/deps/winpty/src/shared/winpty_snprintf.h +99 -0
  331. package/vendor/node-pty-fork/deps/winpty/src/subdir.mk +5 -0
  332. package/vendor/node-pty-fork/deps/winpty/src/tests/subdir.mk +28 -0
  333. package/vendor/node-pty-fork/deps/winpty/src/tests/trivial_test.cc +158 -0
  334. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.cc +114 -0
  335. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/InputHandler.h +56 -0
  336. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.cc +80 -0
  337. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/OutputHandler.h +53 -0
  338. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.cc +86 -0
  339. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/Util.h +31 -0
  340. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.cc +70 -0
  341. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/WakeupFd.h +42 -0
  342. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/main.cc +729 -0
  343. package/vendor/node-pty-fork/deps/winpty/src/unix-adapter/subdir.mk +41 -0
  344. package/vendor/node-pty-fork/deps/winpty/src/winpty.gyp +206 -0
  345. package/vendor/node-pty-fork/deps/winpty/vcbuild.bat +83 -0
  346. package/vendor/node-pty-fork/lib/conpty_console_list_agent.js +20 -0
  347. package/vendor/node-pty-fork/lib/conpty_console_list_agent.js.map +1 -0
  348. package/vendor/node-pty-fork/lib/eventEmitter2.js +47 -0
  349. package/vendor/node-pty-fork/lib/eventEmitter2.js.map +1 -0
  350. package/vendor/node-pty-fork/lib/eventEmitter2.test.js +30 -0
  351. package/vendor/node-pty-fork/lib/eventEmitter2.test.js.map +1 -0
  352. package/vendor/node-pty-fork/lib/index.js +51 -0
  353. package/vendor/node-pty-fork/lib/index.js.map +1 -0
  354. package/vendor/node-pty-fork/lib/interfaces.js +7 -0
  355. package/vendor/node-pty-fork/lib/interfaces.js.map +1 -0
  356. package/vendor/node-pty-fork/lib/shared/conout.js +11 -0
  357. package/vendor/node-pty-fork/lib/shared/conout.js.map +1 -0
  358. package/vendor/node-pty-fork/lib/terminal.js +190 -0
  359. package/vendor/node-pty-fork/lib/terminal.js.map +1 -0
  360. package/vendor/node-pty-fork/lib/terminal.test.js +139 -0
  361. package/vendor/node-pty-fork/lib/terminal.test.js.map +1 -0
  362. package/vendor/node-pty-fork/lib/testUtils.test.js +28 -0
  363. package/vendor/node-pty-fork/lib/testUtils.test.js.map +1 -0
  364. package/vendor/node-pty-fork/lib/types.js +7 -0
  365. package/vendor/node-pty-fork/lib/types.js.map +1 -0
  366. package/vendor/node-pty-fork/lib/unixTerminal.js +304 -0
  367. package/vendor/node-pty-fork/lib/unixTerminal.js.map +1 -0
  368. package/vendor/node-pty-fork/lib/unixTerminal.test.js +330 -0
  369. package/vendor/node-pty-fork/lib/unixTerminal.test.js.map +1 -0
  370. package/vendor/node-pty-fork/lib/utils.js +17 -0
  371. package/vendor/node-pty-fork/lib/utils.js.map +1 -0
  372. package/vendor/node-pty-fork/lib/windowsConoutConnection.js +122 -0
  373. package/vendor/node-pty-fork/lib/windowsConoutConnection.js.map +1 -0
  374. package/vendor/node-pty-fork/lib/windowsPtyAgent.js +324 -0
  375. package/vendor/node-pty-fork/lib/windowsPtyAgent.js.map +1 -0
  376. package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js +90 -0
  377. package/vendor/node-pty-fork/lib/windowsPtyAgent.test.js.map +1 -0
  378. package/vendor/node-pty-fork/lib/windowsTerminal.js +201 -0
  379. package/vendor/node-pty-fork/lib/windowsTerminal.js.map +1 -0
  380. package/vendor/node-pty-fork/lib/windowsTerminal.test.js +203 -0
  381. package/vendor/node-pty-fork/lib/windowsTerminal.test.js.map +1 -0
  382. package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js +22 -0
  383. package/vendor/node-pty-fork/lib/worker/conoutSocketWorker.js.map +1 -0
  384. package/vendor/node-pty-fork/package.json +35 -0
  385. package/vendor/node-pty-fork/scripts/apply-patches.mjs +341 -0
  386. package/vendor/node-pty-fork/scripts/fetch-upstream.mjs +41 -0
  387. package/vendor/node-pty-fork/scripts/install-smoke.cjs +59 -0
  388. package/vendor/node-pty-fork/scripts/smoke-load.cjs +10 -0
  389. package/vendor/node-pty-fork/scripts/sync-upstream.mjs +29 -0
  390. package/vendor/node-pty-fork/scripts/verify-runtime.cjs +54 -0
  391. package/vendor/node-pty-fork/scripts/verify-runtime.test.cjs +22 -0
  392. package/vendor/node-pty-fork/scripts/verify-tarball.cjs +80 -0
  393. package/vendor/node-pty-fork/src/conpty_console_list_agent.ts +19 -0
  394. package/vendor/node-pty-fork/src/eventEmitter2.test.ts +30 -0
  395. package/vendor/node-pty-fork/src/eventEmitter2.ts +48 -0
  396. package/vendor/node-pty-fork/src/index.ts +51 -0
  397. package/vendor/node-pty-fork/src/interfaces.ts +129 -0
  398. package/vendor/node-pty-fork/src/native.d.ts +56 -0
  399. package/vendor/node-pty-fork/src/shared/conout.ts +15 -0
  400. package/vendor/node-pty-fork/src/terminal.test.ts +119 -0
  401. package/vendor/node-pty-fork/src/terminal.ts +211 -0
  402. package/vendor/node-pty-fork/src/testUtils.test.ts +23 -0
  403. package/vendor/node-pty-fork/src/tsconfig.json +22 -0
  404. package/vendor/node-pty-fork/src/types.ts +15 -0
  405. package/vendor/node-pty-fork/src/unix/pty.cc +826 -0
  406. package/vendor/node-pty-fork/src/unix/spawn-helper.cc +23 -0
  407. package/vendor/node-pty-fork/src/unixTerminal.test.ts +335 -0
  408. package/vendor/node-pty-fork/src/unixTerminal.ts +320 -0
  409. package/vendor/node-pty-fork/src/utils.ts +9 -0
  410. package/vendor/node-pty-fork/src/win/conpty.cc +500 -0
  411. package/vendor/node-pty-fork/src/win/conpty_console_list.cc +43 -0
  412. package/vendor/node-pty-fork/src/win/path_util.cc +73 -0
  413. package/vendor/node-pty-fork/src/win/path_util.h +22 -0
  414. package/vendor/node-pty-fork/src/win/winpty.cc +322 -0
  415. package/vendor/node-pty-fork/src/windowsConoutConnection.ts +79 -0
  416. package/vendor/node-pty-fork/src/windowsPtyAgent.test.ts +94 -0
  417. package/vendor/node-pty-fork/src/windowsPtyAgent.ts +323 -0
  418. package/vendor/node-pty-fork/src/windowsTerminal.test.ts +214 -0
  419. package/vendor/node-pty-fork/src/windowsTerminal.ts +208 -0
  420. package/vendor/node-pty-fork/src/worker/conoutSocketWorker.ts +22 -0
  421. package/vendor/node-pty-fork/typings/node-pty.d.ts +203 -0
  422. package/dist/public/assets/WorkbenchShellRoute-DyaMnPfS.js +0 -1
  423. package/dist/server/modules/channels/wechat-claw-client.d.ts +0 -51
  424. package/dist/server/modules/channels/wechat-claw-client.js +0 -245
  425. package/dist/server/modules/channels/wechat-claw-client.js.map +0 -1
@@ -1 +1 @@
1
- import{b as c,j as i,t as r,A as In}from"./index-CuzMc7q2.js";import{f as ei,e as Ri,g as _i}from"./App-tPcbyRdS.js";import{ar as Ti,u as Fi,h as Ai,v as Li}from"./model-switch-api-c6kcbBGm.js";import{bl as Bi,bm as ti,b as nn,w as ft,bn as Wi,u as $i,a7 as Re,bo as Oi,bp as gt,bq as Ke,br as Hi,bs as zi,bt as Ui,bu as Vi}from"./WorkbenchLayout-CbpJg0g1.js";import{W as $n}from"./WorkbenchModal-Bt_1fYmM.js";import{r as Rt,a as _t,F as Ki}from"./file-tree-icon-BeHqeru9.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-C751A-Sm.js";const Gi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),Xi=["._"];function ut(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function qi(t){const n=t.trim().toLowerCase();return n?Gi.has(n)||Xi.some(l=>n.startsWith(l)):!1}function Tt(t,n,l){return l?[...t]:t.filter(o=>!qi(n(o)))}function Nt(t,n){return Tt(t,l=>l.name,n)}function Yi(t,n){return n?t:Object.entries(t).reduce((l,[o,m])=>(l[o]=Nt(m,!1),l),{})}async function Et(t,n){const[l,o]=await Promise.all([Bi(n),Ti(t)]);return Zi(l.changes,o.items)}function Zi(t,n){const l=new Set(n.map(o=>kt(o.path)));return t.filter(o=>l.has(kt(o.path))||o.oldPath!==null&&l.has(kt(o.oldPath)))}function Ji(t){const n=On("","");for(const l of t){const o=kt(l.path),m=o.split("/").filter(Boolean);let h=n;m.forEach((b,x)=>{const j=m.slice(0,x+1).join("/");if(x===m.length-1){h.children.set(`file:${j}`,{kind:"file",name:b,path:o,change:l});return}const T=`directory:${j}`,M=h.children.get(T);if(M&&M.kind==="directory"){h=M;return}const Q=On(b,j);h.children.set(T,Q),h=Q})}return ai(ii([...n.children.values()]))}function ni(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return ln(t)?`${l} ${n}`:l}function ln(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Dt(t){return t.split("/").filter(Boolean).pop()??t}function kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ii(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ii([...n.children.values()])}:n)}function ai(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=ai(n.children);let o=n.name,m=n.path,h=l;for(;h.length===1&&((b=h[0])==null?void 0:b.kind)==="directory";){const x=h[0];o=`${o}/${x.name}`,m=x.path,h=x.children}return{kind:"directory",name:o,path:m,children:h}})}const Qi=450,Ii=60*1e3,Hn=20,zn=16;function ea({sessionId:t,workspaceId:n,showSystemFiles:l,selectedPath:o,refreshVersion:m,onCountChange:h,onSelectFile:b,onOpenFile:x}){const[j,T]=c.useState("tree"),[M,Q]=c.useState([]),[me,K]=c.useState(!0),[pe,be]=c.useState(!1),[G,ht]=c.useState([]),D=c.useRef(null),At=ti(),{showToast:je}=ei();c.useEffect(()=>{const p=nn(Pt(n,t),Ii);T("tree"),Q(p??[]),K(p===null),be(!1),ht([]),D.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function S(){K(!0);try{const v=await Et(t,n);p||(Q(v),ft(Pt(n,t),v))}catch(v){p||je({title:It(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||K(!1)}}return S(),()=>{p=!0}},[m,t,je,n]);async function Se(){K(!0);try{const p=await Et(t,n);Q(p),ft(Pt(n,t),p)}catch(p){je({title:It(p,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{K(!1)}}async function E(){if(R.length!==0){be(!0);try{await Wi(n,R.map(S=>S.path));const p=await Et(t,n);Q(p),ft(Pt(n,t),p),je({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){je({title:It(p,r("git.stageFailed")),tone:"error"})}finally{be(!1)}}}function F(p){ht(S=>S.includes(p)?S.filter(v=>v!==p):[...S,p])}function X(p){const S=Date.now(),v=D.current;return D.current={filePath:p,timestamp:S},(v==null?void 0:v.filePath)===p&&S-v.timestamp<=Qi}async function $(p,S){if(S&&X(p)){await x(p),D.current=null;return}S||(D.current=null),await b(p)}const ie=c.useMemo(()=>Tt(M,p=>Dt(p.path),l),[M,l]),R=ie.filter(p=>!p.staged),_e=Ji(ie),ae=new Set(G);return c.useEffect(()=>{h==null||h(ie.length)},[h,ie.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:j==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="tree",onClick:()=>T("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:j==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="list",onClick:()=>T("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Se(),disabled:me||pe,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void E(),disabled:pe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ie.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),i.jsx("div",{ref:At,className:"file-tree","data-scrollbar-autohide":"true",children:me?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ie.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):j==="tree"?li({nodes:_e,depth:0,collapsedPathSet:ae,selectedPath:o,onToggleTreePath:F,onFileClick:$}):ta({items:ie,selectedPath:o,onFileClick:$})})]})}function li({nodes:t,depth:n,collapsedPathSet:l,selectedPath:o,onToggleTreePath:m,onFileClick:h}){return t.map(b=>{if(b.kind==="directory"){const x=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Hn+n*zn}px`},onClick:()=>m(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),x?i.jsx("div",{className:"file-tree-children",children:li({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:o,onToggleTreePath:m,onFileClick:h})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Hn+n*zn}px`},onClick:()=>void h(b.change.path,!ln(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(b.name),"aria-hidden":"true",children:Rt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:ni(b.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function ta({items:t,selectedPath:n,onFileClick:l}){return t.map(o=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===o.path,onClick:()=>void l(o.path,!ln(o)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(Dt(o.path)),"aria-hidden":"true",children:Rt(Dt(o.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Dt(o.path)}),i.jsx("span",{className:"file-tree-path",children:ni(o,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),i.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function Pt(t,n){return`file-panel.session-changes.${t}.${n}`}function It(t,n){return t instanceof In?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",na=450,ne=8,Ct=4,ia=176,aa=120,la=300*1e3,sa=60*1e3,Un=1600,ra=220,oa=20,ca=16;function el({className:t,sessionId:n,workspaceId:l,hideHeading:o=!1,hideTabs:m=!1,externalRevealRequest:h=null,externalWindowMode:b=!1,workbenchShellOverrides:x}){var Ln,Bn;const j=$i(),{navigationGroups:T,subscribeFileTree:M,requestFileTreeRefresh:Q,addFileTreeSnapshotListener:me,subscribeGitSnapshot:K,requestGitRefresh:pe,addGitSnapshotListener:be}={...j,...x},[G,ht]=c.useState({}),[D,At]=c.useState([]),[je,Se]=c.useState([]),[E,F]=c.useState(g),[X,$]=c.useState([]),[ie,R]=c.useState(null),[_e,ae]=c.useState(!1),[p,S]=c.useState(!1),[v,mt]=c.useState(!1),[Xe,qe]=c.useState(!1),[A,Ye]=c.useState(""),[Lt,q]=c.useState(null),[pt,bt]=c.useState(!1),[we,Ze]=c.useState(null),[O,Je]=c.useState("workspace"),[rn,Ne]=c.useState(0),[on,Bt]=c.useState(0),[Qe,I]=c.useState(!1),[Ie,L]=c.useState(!1),[le,H]=c.useState(null),[ve,Te]=c.useState(null),[B,Fe]=c.useState(null),[P,Wt]=c.useState(null),[w,et]=c.useState(null),[$t,Ae]=c.useState(""),[cn,un]=c.useState([]),[ee,Ot]=c.useState(!1),[hi,ye]=c.useState(null),fn=c.useId(),se=c.useRef({}),Y=c.useRef({}),_=c.useRef([]),te=c.useRef(g),tt=c.useRef(!1),nt=c.useRef(null),mi=ti(),dn=c.useRef(null),hn=c.useRef(null),Ht=c.useRef(null),mn=c.useRef(null),pn=c.useRef(null),xe=c.useRef(0),re=c.useRef(new Map),{showToast:C}=ei(),it=Ri(),z=Fi(e=>e.showSystemFiles),Le=!!(n!=null&&n.trim()),bn=o&&it.isMobile;c.useEffect(()=>{Re("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=E},[E]);function zt(e){Bt(e),!(!l||!n)&&ft(Yn(l,n),e)}async function vn(){if(!l||!n){zt(0);return}const e=await Et(n,l),a=Tt(e,s=>ut(s.path),z).length;zt(a)}function Ee(e){ht(a=>{const s=typeof e=="function"?e(a):e;return se.current=s,s})}function Be(e){At(a=>{const s=typeof e=="function"?e(a):e;return _.current=s,s})}c.useEffect(()=>{var f,d;if(Gt(),!l){Gt(),tt.current=!1,se.current={},Y.current={},_.current=[],te.current=g,Ee({}),Be([]),Se([]),F(g),qe(!1),Ye(""),q(null),bt(!1),ae(!1),Ot(!1),ye(null),$([]),R(null),H(null),Te(null),Fe(null),et(null),Ae("");return}tt.current=!0;const e=nn(qn(l),la);Re("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),s=Xn((e==null?void 0:e.expandedDirectories)??[],a),u=wt((e==null?void 0:e.treeCache)??{},a,s);se.current=u,Y.current=Zn((e==null?void 0:e.treeRevisionByPath)??{},u),_.current=s,te.current=a,Ee(u),Be(s),Se([]),F(a),ae(!1),S(!1),qe(!1),Ye(""),q(null),bt(!1),queueMicrotask(()=>{tt.current=!1})},[l]),c.useEffect(()=>{if(!h||h.workspaceId!==l)return;const e=()=>{if(pn.current===h.requestId)return;pn.current=h.requestId,Je("workspace"),(h.openViewer?ze(h.filePath):ce(h.filePath)).catch(s=>{C({title:J(s,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(tt.current){queueMicrotask(e);return}e()},[h,ze,ce,C,l]),c.useEffect(()=>{if(l)return me(e=>{e.workspaceId===l&&(Y.current={...Y.current,[e.path]:typeof e.revision=="string"?e.revision:null},Ee(a=>({...a,[e.path]:e.items})),e.path===g&&ae(!1),Se(a=>a.filter(s=>s!==e.path)),Sn(e.path,e.items))})},[me,l]),c.useEffect(()=>()=>{Gt()},[]),c.useEffect(()=>{l&&M(l,tn(_.current,te.current),{knownRevisionByPath:Y.current})},[E,D,M,l]),c.useEffect(()=>{$([]),R(null),Ze(null),ye(null),Ne(0),I(!1),L(!1),H(null),Te(null),Fe(null),et(null),Ae(""),nt.current=null,xe.current+=1},[n]),c.useEffect(()=>{!Le&&O==="session"&&Je("workspace")},[O,Le]),c.useEffect(()=>{m&&O!=="workspace"&&Je("workspace")},[O,m]),c.useEffect(()=>{if(!Qe&&!Ie&&!le)return;function e(s){var y,N,fe;if(!(s.target instanceof Node))return;const u=((y=dn.current)==null?void 0:y.contains(s.target))??!1,f=((N=hn.current)==null?void 0:N.contains(s.target))??!1,d=((fe=Ht.current)==null?void 0:fe.contains(s.target))??!1;!u&&!f&&!d&&(I(!1),L(!1),H(null),Te(null))}function a(s){s.key==="Escape"&&(I(!1),L(!1),H(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Qe,Ie,le]),c.useLayoutEffect(()=>{if(!le||typeof window>"u"){Te(null);return}const e=le;function a(){const u=Ht.current;if(!u)return;const f=u.getBoundingClientRect();Te(va({x:e.positionX,y:e.positionY},{width:f.width||ia,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const s=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[le]),c.useEffect(()=>{if(!l)return;const e=Xn(D,E),a=wt(G,E,e);ft(qn(l),{treeCache:a,treeRevisionByPath:Zn(Y.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,D,G,l]),c.useEffect(()=>{if(tt.current)return;const e=wt(G,E,D);ka(G,e)||Ee(e)},[E,D,G]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const d=Nt(se.current[g]??[],z),y=(f==null?void 0:f.silent)!==!0&&d.length===0;y&&ae(!0),Re("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await Kt(g,{force:!0});e||(Re("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),Ee(fe=>({...wt(fe,te.current,_.current),[g]:N})))}catch(N){!e&&!Jn(N)&&C({title:J(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&ae(!1)}}if(Nt(se.current[g]??[],z).length>0){const f=window.setTimeout(()=>{a&&(M(a,tn(_.current,te.current),{knownRevisionByPath:Y.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[n,z,C,l]),c.useEffect(()=>{if(!l||!n){Bt(0);return}const e=nn(Yn(l,n),sa);Re("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),Bt(e??0);let a=!1;return vn().catch(()=>{}),()=>{a=!0}},[n,rn,z,l]),c.useEffect(()=>{if(!l){un([]);return}const e=l.trim();K(e),pe(e)},[l,K,pe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return be(a=>{var s;a.workspaceId===e&&un(((s=a.status)==null?void 0:s.changes)??[])})},[be,l]);const vt=c.useMemo(()=>Tt(cn,e=>ut(e.path),z),[cn,z]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const s of vt){const u=s.path.replace(/\\/g,"/"),f=s.worktreeStatus??s.stagedStatus??s.status;e.set(u,f);const d=u.split("/");for(let y=1;y<d.length;y++)a.add(d.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:a}},[vt]),De=c.useMemo(()=>Yi(G,z),[z,G]),ke=c.useMemo(()=>Lt===null?null:Nt(Lt,z),[Lt,z]),We=De[g]??[],oe=Xe&&ke!==null,yt=c.useMemo(()=>ee?an(We,De,W.statusByPath,W.changedDirs):We,[W.changedDirs,W.statusByPath,We,ee,De]),pi=c.useMemo(()=>oe?(ke??[]).map(e=>V(e.path,e.kind)):si(yt,De,D,ee,W.statusByPath,W.changedDirs),[D,W.changedDirs,W.statusByPath,oe,ee,ke,De,yt]),$e=((Ln=T.find(e=>e.workspace.id===l))==null?void 0:Ln.workspace)??null,k=Gn(X),Ut=(k==null?void 0:k.path)??null,ge=(k==null?void 0:k.kind)==="file"?k.path:null,xt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),at=c.useMemo(()=>St(X),[X]),Vt=!!($e!=null&&$e.path&&X.length===1&&Ut),yn=X.length===1&&(k==null?void 0:k.kind)==="file",xn=at.length>0,Me=at.length>0,lt=!!(P!=null&&P.items.length&&l),gn=!!l&&X.length===1&&k!==null,Pn=!!((ge?he(ge):E)&&D.length),Cn=P?P.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:P.items.length}):r("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,U=w?Pa(w):null;async function jn(e,a=!1){if(!l)return[];if(!a){const s=se.current[e];if(s)return s}e===g?ae(!0):Se(s=>Mt(s,e));try{const s=await Kt(e,{force:a});return Ee(u=>({...u,[e]:s})),s}catch(s){throw Jn(s)||C({title:J(s,r("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?ae(!1):Se(s=>s.filter(u=>u!==e))}}async function Pe(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,s=(e==null?void 0:e.expandedDirectories)??_.current,u=Da(se.current,a,s);Re("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async y=>{const N=await Kt(y,{force:!0});return[y,N]}))).reduce((y,[N,fe])=>(y[N]=fe,y),{});Re("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),Ee(d)}async function Kt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=se.current[e];if(d)return d}const s=tn(Mt(_.current,e),e||te.current);M(l,s,{knownRevisionByPath:Y.current}),Q(l,[e],{knownRevisionByPath:Y.current});const u=bi(e,Un,{allowCached:(a==null?void 0:a.force)!==!0}),f=Ma(ra).then(async()=>{if(!l)return[];const y=(await Ui(l,e||void 0)).items;return Y.current={...Y.current,[e]:null},Sn(e,y),y});try{return await Promise.race([u,f])}catch(d){if(!fi(d))throw d;return await f}}function bi(e,a=Un,s){const u=se.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const y=window.setTimeout(()=>{vi(e,y),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=re.current.get(e)??[];re.current.set(e,[...N,{resolve:f,reject:d,timerId:y}])})}function Sn(e,a){const s=re.current.get(e)??[];s.length!==0&&(re.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function vi(e,a){const u=(re.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){re.current.delete(e);return}re.current.set(e,u)}function Gt(){for(const[e,a]of re.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});re.current.clear()}function Oe(e){$([e]),R(e.path)}function st(e){F(e.kind==="directory"?e.path:he(e.path))}function yi(e){const a=da(pi,ie,e);$(a),R(e.path),st(e)}function xi(e){const a=fa(X,e),s=Gn(a);$(a),R(e.path),s&&st(s)}function wn(e){Oe(e),st(e)}function He(e,a){if(a!=null&&a.shiftKey){yi(e);return}if(jt(a)){xi(e);return}wn(e)}async function rt(e,a=!1){const s=dt(e,a);if(!s.length){F(g);return}Be(u=>ui(u,s)),F(s[s.length-1]??g);for(const u of s)try{await jn(u)}catch{return}}async function ce(e){const a=V(e,"file");Oe(a),st(a),await rt(e)}async function ze(e){Ze(e),ye(null),nt.current=null,xe.current+=1,ce(e);const a=xe.current,s=e.replace(/\\/g,"/"),u=W.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Oi(l,e,!1);xe.current===a&&ye(f.content||null)}catch{xe.current===a&&ye(null)}}function Nn(e){const a=Date.now(),s=nt.current;return nt.current={filePath:e,timestamp:a},(s==null?void 0:s.filePath)===e&&a-s.timestamp<=na}function Ce(){nt.current=null}async function gi(e,a){const s=V(e,"file");if(a!=null&&a.shiftKey||jt(a)){Ce(),He(s,a);return}if(Nn(e)){await ze(e);return}He(s,a),await rt(e)}function En(){qe(!1),Ye(""),q(null),Ce()}async function Pi(e,a){const s=V(e.path,e.kind);if(a!=null&&a.shiftKey||jt(a)){Ce(),He(s,a);return}if(e.kind==="directory"){En(),He(s,a),await Dn(e.path);return}if(Nn(e.path)){En(),await ze(e.path);return}await ce(e.path)}async function Dn(e){if(Oe(V(e,"directory")),F(e),!_.current.includes(e))try{await jn(e),Be(a=>Mt(a,e))}catch{}}async function kn(e){if(Oe(V(e,"directory")),F(e),_.current.includes(e)){Mn(e);return}await Dn(e)}function Mn(e){Be(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),F(he(e)),$([]),R(null)}async function Rn(){if(!l)return;const e=l;try{if(pe(e),await Pe(),ge&&await rt(ge),oe&&A.trim()){const a=await Ke(e,A.trim());q(a.items)}if(Le&&n)if(O==="session")Ne(a=>a+1);else try{await vn()}catch(a){C({title:J(a,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){C({title:J(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function Ci(e){if(e==null||e.preventDefault(),!l||!A.trim()){q(null);return}bt(!0);try{const a=await Ke(l,A.trim());q(a.items)}catch(a){C({title:J(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{bt(!1)}}function _n(){if(Xe){qe(!1),Ye(""),q(null);return}qe(!0)}function Z(e){L(!1),e()}function Tn(){var e;(e=mn.current)==null||e.click()}async function ji(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const s=ua(a.name);if(!s){C({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Vn(E,k),f=Kn(u,s);mt(!0);try{const y=await Ca(a);await Hi({workspaceId:l,path:f,contentBase64:y}),await Pe(),await ce(f),C({title:r("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(y){C({title:J(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{mt(!1)}}async function Xt(e=ge){if(!(!l||!e)){mt(!0);try{const a=await zi(l,e),s=ja(a.contentBase64);Sa(a.fileName,new Blob([s],{type:"application/octet-stream"})),C({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){C({title:J(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{mt(!1)}}}function Fn(){const e=ge?he(ge):E;!e||!_.current.includes(e)||Mn(e)}function qt(){et(null),Ae("")}function Yt(){p||qt()}function Ue(e,a=Vn(E,k)){if(!l)return;const s=a,u=s?`${s}/`:"";I(!1),L(!1),H(null),et({mode:e,baseDirectory:s}),Ae(u)}function Zt(e=k){!l||!e||(I(!1),L(!1),H(null),et({mode:"rename",target:e}),Ae(e.path))}async function Si(e){if(e==null||e.preventDefault(),!l||!w)return;const a=($t??"").trim();if(a){if(w.mode==="rename"&&Ge(w.target.path)===Ge(a)){Yt();return}S(!0);try{if(w.mode==="rename"){const s=w.target.path,u=V(a,w.target.kind),f=we?ci(we,s,a):null;if(await gt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Wt({...P,items:ga(P.items,s,a)}),qt(),Ce(),await Pe(),w.target.kind==="directory"?(await rt(a,!0),Oe(u),F(a)):await ce(a),f!==we&&(xe.current+=1,Ze(f),ye(null)),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:r("conversation.filePanelRenameSuccess",{name:ut(a)||a}),tone:"success"});return}if(await gt({workspaceId:l,opType:w.mode,dstPath:a,content:w.mode==="create_file"?"":void 0}),qt(),await Pe(),w.mode==="create_directory"?(await rt(a,!0),Oe(V(a,"directory")),F(a)):await ce(a),oe&&A.trim()){const s=await Ke(l,A.trim());q(s.items)}Ne(s=>s+1)}catch(s){C({title:J(s,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{S(!1)}}}function ue(e,a=at){var u;if(a.length===0)return;const s=St(a);Wt({mode:e,items:s}),$(s),R(((u=s[s.length-1])==null?void 0:u.path)??null),C({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:s.length}):r("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),H(null)}async function ot(e=pa(k,E)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:Kn(a,ut(u.path)||u.path)}));S(!0);try{for(const d of s)P.mode==="cut"&&Ge(d.source.path)===Ge(d.destinationPath)||await gt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath});const u=s.map(d=>V(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Wt(null),$(u),R((f==null?void 0:f.path)??null),f&&st(f),Ce(),await Pe({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?he(f.path):te.current,expandedDirectories:_.current}),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await Pe().catch(()=>{}),C({title:J(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{S(!1)}}function Jt(e=at){!e.length||p||(Fe(St(e)),H(null))}async function wi(){var a,s;if(!l||!(B!=null&&B.length))return;const e=St(B);S(!0);try{for(const d of e)await gt({workspaceId:l,opType:"delete",srcPath:d.path});const u=ba(E,e),f=_.current.filter(d=>!e.some(y=>y.kind==="directory"&&Ft(y.path,d)));if(we&&e.some(d=>Ft(d.path,we))&&(xe.current+=1,Ze(null),ye(null)),Fe(null),$([]),R(null),te.current=u,_.current=f,F(u),Be(f),Ce(),await Pe({activeDirectoryPath:u,expandedDirectories:f}),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:ut(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){C({title:J(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{S(!1)}}async function Ve(e,a=k){const s=($e==null?void 0:$e.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!s){I(!1);return}try{const f=xa(s),d=e==="absolute"?ya(s,u,f):Ge(u,f);await wa(d,it),C({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){C({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{I(!1),H(null)}}function Ni(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?D.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){kn(e.path);return}ze(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Xt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||p||v,onSelect:()=>{Ue("create_file",s)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||p||v,onSelect:()=>{Ue("create_directory",s)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||p||v,onSelect:()=>Zt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ue("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ue("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{ot(s)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ve("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ve("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||p||v,onSelect:()=>Jt(a)}]}async function An(e,a){if(it.isMobile)return;e.preventDefault();const s=V(a.path,a.kind),u=xt.has(s.path)?at:[s],f=s.kind==="directory"?s.path:he(s.path);xt.has(s.path)||wn(s);const d=Ni(s,u,f);if(it.isDesktop){await Vi(d);return}it.isWeb&&(I(!1),L(!1),H({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!ha(a)||a.altKey||a.shiftKey||ma(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Me){a.preventDefault(),ue("copy");return}if(s==="x"&&Me){a.preventDefault(),ue("cut");return}s==="v"&&lt&&(a.preventDefault(),ot())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,Me,lt,ue,ot]);function Qt(e,a){return i.jsx(i.Fragment,{children:e.map(s=>{const u=V(s.path,s.kind),f=s.kind==="directory",d=f&&D.includes(s.path),y=f&&je.includes(s.path),N=De[s.path]??[],fe=ee?an(N,De,W.statusByPath,W.changedDirs):N,Di=xt.has(s.path),ki=Ut===s.path,ct=W.statusByPath.get(s.path.replace(/\\/g,"/")),Wn=f&&W.changedDirs.has(s.path.replace(/\\/g,"/")),Mi=(P==null?void 0:P.mode)==="cut"&&P.items.some(de=>de.path===s.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":ki,"data-selected":Di,"data-cut-pending":Mi||void 0,"data-kind":s.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${oa+a*ca}px`},onClick:de=>{if(f){if(de.shiftKey||jt(de)){Ce(),He(u,de);return}Ce(),He(u,de),kn(s.path);return}gi(s.path,de)},onContextMenu:de=>{An(de,s)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(s.name),"aria-hidden":"true",children:Rt(s.name)}),i.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":Wn||void 0,children:s.name}),!f&&ct?i.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&Wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:y&&!N.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):fe.length?Qt(fe,a+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function Ei(e){return i.jsx(i.Fragment,{children:e.map(a=>{const s=a.kind==="directory",u=xt.has(a.path),f=Ut===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{Pi(a,d)},onContextMenu:d=>{An(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),s?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(a.name),"aria-hidden":"true",children:Rt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Ki,{workspaceId:l,filePath:we,open:we!==null,onClose:()=>{xe.current+=1,Ze(null),ye(null)},onSaved:async e=>{await Pe(),await ce(e),Ne(a=>a+1)},diffContent:hi}),o?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),m?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Je("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{Le&&Je("session")},disabled:!Le,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${on}`,children:on})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:mn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void ji(e)}),bn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:hn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Ie,"data-active":Ie,onClick:()=>{I(!1),L(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(Ua,{})]}),Ie?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ue("copy")),disabled:!Me,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ue("cut")),disabled:!Me,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ot()),disabled:!lt||p||v,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),_n()},children:Xe?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Ot(e=>!e)},disabled:vt.length===0,children:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Rn),disabled:_e||p||pt,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Fn()},disabled:!Pn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Tn()},disabled:p||v,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Xt),disabled:!yn||v,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Zt),disabled:!gn||p||v,children:r("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Z(Jt),disabled:!xn||p||v,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ue("create_file")),disabled:p||v,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ue("create_directory")),disabled:p||v,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ve("absolute")),disabled:!Vt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ve("relative")),disabled:!Vt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ue("copy"),disabled:!Me,children:i.jsx(Fa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ue("cut"),disabled:!Me,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void ot(),disabled:!lt||p||v,children:i.jsx(La,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:dn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Qe,"data-active":Qe,onClick:()=>{L(!1),I(e=>!e)},disabled:!Vt,children:i.jsx(Ta,{})}),Qe?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ve("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ve("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Fn,disabled:!Pn,children:i.jsx(Ra,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void Rn(),disabled:_e||p||pt,children:i.jsx(_a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Xe,onClick:_n,disabled:_e,children:i.jsx(Qn,{})}),vt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Ot(e=>!e),children:i.jsx(Va,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Tn,disabled:p||v,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Xt(),disabled:!yn||v,children:i.jsx($a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>Zt(),disabled:!gn||p||v,children:i.jsx(za,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Jt(),disabled:!xn||p||v,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Ue("create_file"),disabled:p||v,children:i.jsx(Ba,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Ue("create_directory"),disabled:p||v,children:i.jsx(Ha,{})})]}),le&&typeof document<"u"?_i.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:Ht,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(ve==null?void 0:ve.left)??Math.max(8,le.positionX)}px`,top:`${(ve==null?void 0:ve.top)??Math.max(8,le.positionY)}px`,maxHeight:ve?`${ve.maxHeight}px`:void 0},children:le.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{H(null),e.onSelect()},children:e.label},e.id))}),document.body):null,Cn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:Cn}):null,Xe?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void Ci(e),children:[i.jsx("input",{value:A,onChange:e=>Ye(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),bn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:i.jsx(Qn,{})})]}):null,i.jsx("div",{ref:mi,className:"file-tree","data-search-mode":oe,"data-scrollbar-autohide":"true",children:_e&&We.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):oe?ke!=null&&ke.length?Ei(ke):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):ee?yt.length?Qt(yt,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):We.length?Qt(We,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:w!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Yt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void Si(e),children:[i.jsx(Ai,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:fn,description:(w==null?void 0:w.mode)==="rename"?w.target.path:(w==null?void 0:w.baseDirectory)||void 0,children:i.jsx("input",{id:fn,type:"text",value:$t??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),i.jsxs(Li,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:Yt,children:r("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!($t??"").trim(),children:p?(U==null?void 0:U.pendingLabel)??r("common.loading"):(U==null?void 0:U.submitLabel)??r("common.save")})]})]})}),i.jsxs($n,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||Fe(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Bn=B[0])==null?void 0:Bn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>Fe(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{wi()},children:p?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):Le&&n?i.jsx(ea,{sessionId:n,workspaceId:l,showSystemFiles:z,selectedPath:ge,refreshVersion:rn,onCountChange:zt,onSelectFile:ce,onOpenFile:ze}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function he(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function dt(t,n=!1){const l=t.split("/").filter(Boolean),o=n?l.length:l.length-1,m=[];for(let h=0;h<o;h+=1)m.push(l.slice(0,h+1).join("/"));return m}function Vn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?he(n.path):g)}function Kn(t,n){return t?`${t}/${n}`:n}function ua(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function V(t,n){return{path:t,kind:n}}function Gn(t){return t[t.length-1]??null}function fa(t,n){return t.findIndex(o=>o.path===n.path)>=0?t.filter(o=>o.path!==n.path):[...t,n]}function da(t,n,l){const o=t.findIndex(x=>x.path===l.path);if(o<0)return[l];const m=n?t.findIndex(x=>x.path===n):o;if(m<0)return[l];const h=Math.min(m,o),b=Math.max(m,o);return t.slice(h,b+1)}function jt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ha(t){return t.ctrlKey||t.metaKey}function ma(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function St(t){const n=[...new Map(t.map(o=>[o.path,o])).values()].sort((o,m)=>o.path.localeCompare(m.path)),l=[];for(const o of n)l.some(m=>m.kind==="directory"&&Ft(m.path,o.path))||l.push(o);return l}function pa(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?he(t.path):n}function ba(t,n){let l=t;for(;l&&n.some(o=>o.kind==="directory"&&Ft(o.path,l));)l=he(l);return l}function si(t,n,l,o,m,h){const b=[];for(const x of t){if(b.push(V(x.path,x.kind)),x.kind!=="directory"||!l.includes(x.path))continue;const j=n[x.path]??[],T=o?an(j,n,m,h):j;b.push(...si(T,n,l,o,m,h))}return b}function va(t,n,l){const o=Math.max(0,l.width),m=Math.max(0,l.height),h=Math.max(0,m-ne*2),b=Math.max(0,o-ne*2),x=Math.min(Math.max(n.width,0),b),j=Math.max(0,m-t.y-Ct-ne),T=Math.max(0,t.y-Ct-ne),M=j<n.height&&T>j,me=en(Math.max(M?T:j,aa),0,h),K=Math.min(Math.max(n.height,0),me),pe=M?t.y-Ct-K:t.y+Ct,be=Math.max(ne,m-ne-K),G=Math.max(ne,o-ne-x);return{top:en(pe,ne,be),left:en(t.x,ne,G),maxHeight:Math.max(0,me)}}function en(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function Ge(t,n="posix"){return t?ri(t,n):"."}function ya(t,n,l){const o=ri(t,l),m=Ge(n,l).replace(/^\.[/\\]?/,"");if(!m)return o;const h=oi(l),b=m.replace(/^[/\\]+/,"");return b?o.endsWith("/")||o.endsWith("\\")?`${o}${b}`:`${o}${h}${b}`:o}function xa(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ri(t,n){return t&&(oi(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function oi(t){return t==="windows"?"\\":"/"}function Ft(t,n){return n===t||n.startsWith(`${t}/`)}function ci(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function ga(t,n,l){return t.map(o=>({...o,path:ci(o.path,n,l)}))}function Pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function Ca(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),o=32768;let m="";for(let h=0;h<l.length;h+=o){const b=l.subarray(h,h+o);m+=String.fromCharCode(...b)}return btoa(m)}function ja(t){const n=atob(t),l=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)l[o]=n.charCodeAt(o);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Sa(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),o=document.createElement("a");o.href=l,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(l)}async function wa(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Na(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function Na(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ea(t,n){return t&&dt(t,!0).every(m=>m in n)?t:g}function Xn(t,n){if(!n)return[];const l=dt(n,!0);return t.filter(o=>l.includes(o))}function wt(t,n,l){const o=sn(n,l);return Object.entries(t).reduce((m,[h,b])=>(o.has(h)&&(m[h]=b),m),{})}function Da(t,n,l){const m=[...sn(n,l)].filter(h=>h===g||h in t);return m.length?m:[g]}function sn(t,n){const l=new Set([g]),o=ui(n,dt(t,!0));for(const m of o){l.add(m);for(const h of dt(m,!0))l.add(h)}return l}function ka(t,n){const l=Object.keys(t),o=Object.keys(n);return l.length!==o.length?!1:l.every(m=>t[m]===n[m])}function Mt(t,n){return t.includes(n)?t:[...t,n]}function ui(t,n){return n.reduce((l,o)=>Mt(l,o),t)}function qn(t){return`file-panel.workspace-tree.${t}`}function Yn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Zn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function tn(t,n){return[...sn(n,t)]}function J(t,n){return t instanceof In?t.message:n}function fi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function Jn(t){return fi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Ma(t){return new Promise(n=>{window.setTimeout(n,t)})}function Ra(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function _a(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function Qn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Ta(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function La(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ha(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Va(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function an(t,n,l,o){const m=[];for(const h of t){const b=h.path.replace(/\\/g,"/");h.kind==="file"?l.has(b)&&m.push(h):di(b,n,l,o)&&m.push(h)}return m}function di(t,n,l,o,m){const h=m??new Set;if(h.has(t))return!1;h.add(t);const b=n[t];if(!b)return o.has(t);for(const x of b){const j=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(l.has(j))return!0}else if(di(j,n,l,o,h))return!0}return!1}export{el as FileContextPanel};
1
+ import{b as c,j as i,t as r,A as In}from"./index-CjewzOUG.js";import{f as ei,e as Ri,g as _i}from"./App-B0q8uDA-.js";import{ar as Ti,u as Fi,h as Ai,v as Li}from"./model-switch-api-Br0ivfe5.js";import{bl as Bi,bm as ti,b as nn,w as ft,bn as Wi,u as $i,a7 as Re,bo as Oi,bp as gt,bq as Ke,br as Hi,bs as zi,bt as Ui,bu as Vi}from"./WorkbenchLayout-D48i71PU.js";import{W as $n}from"./WorkbenchModal-BYNuMIoV.js";import{r as Rt,a as _t,F as Ki}from"./file-tree-icon-BFwaPxKs.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-D7OgZZN-.js";const Gi=new Set([".ds_store","thumbs.db","ehthumbs.db","desktop.ini",".spotlight-v100",".trashes",".fseventsd","__macosx","$recycle.bin","system volume information",".apdisk",".appledouble",".temporaryitems"]),Xi=["._"];function ut(t){return t.split(/[/\\]/).filter(Boolean).pop()??t}function qi(t){const n=t.trim().toLowerCase();return n?Gi.has(n)||Xi.some(l=>n.startsWith(l)):!1}function Tt(t,n,l){return l?[...t]:t.filter(o=>!qi(n(o)))}function Nt(t,n){return Tt(t,l=>l.name,n)}function Yi(t,n){return n?t:Object.entries(t).reduce((l,[o,m])=>(l[o]=Nt(m,!1),l),{})}async function Et(t,n){const[l,o]=await Promise.all([Bi(n),Ti(t)]);return Zi(l.changes,o.items)}function Zi(t,n){const l=new Set(n.map(o=>kt(o.path)));return t.filter(o=>l.has(kt(o.path))||o.oldPath!==null&&l.has(kt(o.oldPath)))}function Ji(t){const n=On("","");for(const l of t){const o=kt(l.path),m=o.split("/").filter(Boolean);let h=n;m.forEach((b,x)=>{const j=m.slice(0,x+1).join("/");if(x===m.length-1){h.children.set(`file:${j}`,{kind:"file",name:b,path:o,change:l});return}const T=`directory:${j}`,M=h.children.get(T);if(M&&M.kind==="directory"){h=M;return}const Q=On(b,j);h.children.set(T,Q),h=Q})}return ai(ii([...n.children.values()]))}function ni(t,n){const l=t.oldPath?`${t.oldPath} -> ${t.path}`:t.path;return ln(t)?`${l} ${n}`:l}function ln(t){return t.status==="D"||t.stagedStatus==="D"||t.worktreeStatus==="D"}function Dt(t){return t.split("/").filter(Boolean).pop()??t}function kt(t){return t.replace(/\\/g,"/").replace(/^\.\//,"").trim()}function On(t,n){return{kind:"directory",name:t,path:n,children:new Map}}function ii(t){return[...t].sort((n,l)=>n.kind!==l.kind?n.kind==="directory"?-1:1:n.name.localeCompare(l.name,"zh-CN")).map(n=>n.kind==="directory"?{kind:"directory",name:n.name,path:n.path,children:ii([...n.children.values()])}:n)}function ai(t){return t.map(n=>{var b;if(n.kind!=="directory")return n;const l=ai(n.children);let o=n.name,m=n.path,h=l;for(;h.length===1&&((b=h[0])==null?void 0:b.kind)==="directory";){const x=h[0];o=`${o}/${x.name}`,m=x.path,h=x.children}return{kind:"directory",name:o,path:m,children:h}})}const Qi=450,Ii=60*1e3,Hn=20,zn=16;function ea({sessionId:t,workspaceId:n,showSystemFiles:l,selectedPath:o,refreshVersion:m,onCountChange:h,onSelectFile:b,onOpenFile:x}){const[j,T]=c.useState("tree"),[M,Q]=c.useState([]),[me,K]=c.useState(!0),[pe,be]=c.useState(!1),[G,ht]=c.useState([]),D=c.useRef(null),At=ti(),{showToast:je}=ei();c.useEffect(()=>{const p=nn(Pt(n,t),Ii);T("tree"),Q(p??[]),K(p===null),be(!1),ht([]),D.current=null},[t,n]),c.useEffect(()=>{let p=!1;async function S(){K(!0);try{const v=await Et(t,n);p||(Q(v),ft(Pt(n,t),v))}catch(v){p||je({title:It(v,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{p||K(!1)}}return S(),()=>{p=!0}},[m,t,je,n]);async function Se(){K(!0);try{const p=await Et(t,n);Q(p),ft(Pt(n,t),p)}catch(p){je({title:It(p,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}finally{K(!1)}}async function E(){if(R.length!==0){be(!0);try{await Wi(n,R.map(S=>S.path));const p=await Et(t,n);Q(p),ft(Pt(n,t),p),je({title:r("conversation.filePanelSessionStageSuccess"),tone:"success"})}catch(p){je({title:It(p,r("git.stageFailed")),tone:"error"})}finally{be(!1)}}}function F(p){ht(S=>S.includes(p)?S.filter(v=>v!==p):[...S,p])}function X(p){const S=Date.now(),v=D.current;return D.current={filePath:p,timestamp:S},(v==null?void 0:v.filePath)===p&&S-v.timestamp<=Qi}async function $(p,S){if(S&&X(p)){await x(p),D.current=null;return}S||(D.current=null),await b(p)}const ie=c.useMemo(()=>Tt(M,p=>Dt(p.path),l),[M,l]),R=ie.filter(p=>!p.staged),_e=Ji(ie),ae=new Set(G);return c.useEffect(()=>{h==null||h(ie.length)},[h,ie.length]),i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"file-panel-session-toolbar",children:[i.jsxs("div",{className:"file-panel-view-modes",role:"tablist","aria-label":r("conversation.filePanelSessionViewLabel"),children:[i.jsx("button",{className:j==="tree"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="tree",onClick:()=>T("tree"),children:r("conversation.filePanelSessionTreeView")}),i.jsx("button",{className:j==="list"?"file-panel-view-button active":"file-panel-view-button",type:"button",role:"tab","aria-selected":j==="list",onClick:()=>T("list"),children:r("conversation.filePanelSessionListView")})]}),i.jsxs("div",{className:"file-panel-session-actions",children:[i.jsx("button",{className:"secondary-button",type:"button",onClick:()=>void Se(),disabled:me||pe,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"primary-button",type:"button",onClick:()=>void E(),disabled:pe||R.length===0,children:r("conversation.filePanelSessionStageAll")})]})]}),i.jsxs("div",{className:"file-panel-session-summary",children:[i.jsx("span",{children:`${r("conversation.filePanelSessionSummary")} ${ie.length}`}),i.jsx("span",{children:`${r("conversation.filePanelSessionUnstagedSummary")} ${R.length}`})]}),i.jsx("div",{ref:At,className:"file-tree","data-scrollbar-autohide":"true",children:me?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionLoading")}):ie.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSessionEmpty")}):j==="tree"?li({nodes:_e,depth:0,collapsedPathSet:ae,selectedPath:o,onToggleTreePath:F,onFileClick:$}):ta({items:ie,selectedPath:o,onFileClick:$})})]})}function li({nodes:t,depth:n,collapsedPathSet:l,selectedPath:o,onToggleTreePath:m,onFileClick:h}){return t.map(b=>{if(b.kind==="directory"){const x=!l.has(b.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-kind":"directory","aria-expanded":x,style:{paddingInlineStart:`${Hn+n*zn}px`},onClick:()=>m(b.path),children:[i.jsx("span",{className:"file-tree-chevron","aria-hidden":"true",children:x?"v":">"}),i.jsx("span",{className:"file-tree-label",children:b.name})]}),x?i.jsx("div",{className:"file-tree-children",children:li({nodes:b.children,depth:n+1,collapsedPathSet:l,selectedPath:o,onToggleTreePath:m,onFileClick:h})}):null]},`session-directory:${b.path}`)}return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-session-change",type:"button","data-active":o===b.change.path,"data-kind":"file",style:{paddingInlineStart:`${Hn+n*zn}px`},onClick:()=>void h(b.change.path,!ln(b.change)),children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(b.name),"aria-hidden":"true",children:Rt(b.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:b.name}),i.jsx("span",{className:"file-tree-path",children:ni(b.change,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":b.change.status,children:b.change.status}),i.jsx("span",{className:"file-session-badge subtle",children:b.change.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-file:${b.path}`)})}function ta({items:t,selectedPath:n,onFileClick:l}){return t.map(o=>i.jsx("div",{className:"file-session-list-item",children:i.jsxs("button",{className:"file-session-list-button",type:"button","data-active":n===o.path,onClick:()=>void l(o.path,!ln(o)),children:[i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(Dt(o.path)),"aria-hidden":"true",children:Rt(Dt(o.path))}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:Dt(o.path)}),i.jsx("span",{className:"file-tree-path",children:ni(o,r("conversation.filePanelSessionDeleted"))})]}),i.jsxs("span",{className:"file-session-item-meta",children:[i.jsx("span",{className:"file-session-badge","data-status":o.status,children:o.status}),i.jsx("span",{className:"file-session-badge subtle",children:o.staged?r("git.stagedLabel"):r("git.workingTreeLabel")})]})]})},`session-list:${o.path}`))}function Pt(t,n){return`file-panel.session-changes.${t}.${n}`}function It(t,n){return t instanceof In?t.message:typeof t=="object"&&t&&"message"in t?String(t.message??n):n}const g="",na=450,ne=8,Ct=4,ia=176,aa=120,la=300*1e3,sa=60*1e3,Un=1600,ra=220,oa=20,ca=16;function el({className:t,sessionId:n,workspaceId:l,hideHeading:o=!1,hideTabs:m=!1,externalRevealRequest:h=null,externalWindowMode:b=!1,workbenchShellOverrides:x}){var Ln,Bn;const j=$i(),{navigationGroups:T,subscribeFileTree:M,requestFileTreeRefresh:Q,addFileTreeSnapshotListener:me,subscribeGitSnapshot:K,requestGitRefresh:pe,addGitSnapshotListener:be}={...j,...x},[G,ht]=c.useState({}),[D,At]=c.useState([]),[je,Se]=c.useState([]),[E,F]=c.useState(g),[X,$]=c.useState([]),[ie,R]=c.useState(null),[_e,ae]=c.useState(!1),[p,S]=c.useState(!1),[v,mt]=c.useState(!1),[Xe,qe]=c.useState(!1),[A,Ye]=c.useState(""),[Lt,q]=c.useState(null),[pt,bt]=c.useState(!1),[we,Ze]=c.useState(null),[O,Je]=c.useState("workspace"),[rn,Ne]=c.useState(0),[on,Bt]=c.useState(0),[Qe,I]=c.useState(!1),[Ie,L]=c.useState(!1),[le,H]=c.useState(null),[ve,Te]=c.useState(null),[B,Fe]=c.useState(null),[P,Wt]=c.useState(null),[w,et]=c.useState(null),[$t,Ae]=c.useState(""),[cn,un]=c.useState([]),[ee,Ot]=c.useState(!1),[hi,ye]=c.useState(null),fn=c.useId(),se=c.useRef({}),Y=c.useRef({}),_=c.useRef([]),te=c.useRef(g),tt=c.useRef(!1),nt=c.useRef(null),mi=ti(),dn=c.useRef(null),hn=c.useRef(null),Ht=c.useRef(null),mn=c.useRef(null),pn=c.useRef(null),xe=c.useRef(0),re=c.useRef(new Map),{showToast:C}=ei(),it=Ri(),z=Fi(e=>e.showSystemFiles),Le=!!(n!=null&&n.trim()),bn=o&&it.isMobile;c.useEffect(()=>{Re("file_panel.props",{sessionId:n,workspaceId:l,externalWindowMode:b})},[b,n,l]),c.useEffect(()=>{te.current=E},[E]);function zt(e){Bt(e),!(!l||!n)&&ft(Yn(l,n),e)}async function vn(){if(!l||!n){zt(0);return}const e=await Et(n,l),a=Tt(e,s=>ut(s.path),z).length;zt(a)}function Ee(e){ht(a=>{const s=typeof e=="function"?e(a):e;return se.current=s,s})}function Be(e){At(a=>{const s=typeof e=="function"?e(a):e;return _.current=s,s})}c.useEffect(()=>{var f,d;if(Gt(),!l){Gt(),tt.current=!1,se.current={},Y.current={},_.current=[],te.current=g,Ee({}),Be([]),Se([]),F(g),qe(!1),Ye(""),q(null),bt(!1),ae(!1),Ot(!1),ye(null),$([]),R(null),H(null),Te(null),Fe(null),et(null),Ae("");return}tt.current=!0;const e=nn(qn(l),la);Re("file_panel.workspace_snapshot",{workspaceId:l,cached:!!e,cachedRootItems:((d=(f=e==null?void 0:e.treeCache)==null?void 0:f[g])==null?void 0:d.length)??0,cachedDirectoryCount:Object.keys((e==null?void 0:e.treeCache)??{}).length});const a=Ea((e==null?void 0:e.activeDirectoryPath)??g,(e==null?void 0:e.treeCache)??{}),s=Xn((e==null?void 0:e.expandedDirectories)??[],a),u=wt((e==null?void 0:e.treeCache)??{},a,s);se.current=u,Y.current=Zn((e==null?void 0:e.treeRevisionByPath)??{},u),_.current=s,te.current=a,Ee(u),Be(s),Se([]),F(a),ae(!1),S(!1),qe(!1),Ye(""),q(null),bt(!1),queueMicrotask(()=>{tt.current=!1})},[l]),c.useEffect(()=>{if(!h||h.workspaceId!==l)return;const e=()=>{if(pn.current===h.requestId)return;pn.current=h.requestId,Je("workspace"),(h.openViewer?ze(h.filePath):ce(h.filePath)).catch(s=>{C({title:J(s,r("conversation.filePanelOpenFailed")),tone:"error"})})};if(tt.current){queueMicrotask(e);return}e()},[h,ze,ce,C,l]),c.useEffect(()=>{if(l)return me(e=>{e.workspaceId===l&&(Y.current={...Y.current,[e.path]:typeof e.revision=="string"?e.revision:null},Ee(a=>({...a,[e.path]:e.items})),e.path===g&&ae(!1),Se(a=>a.filter(s=>s!==e.path)),Sn(e.path,e.items))})},[me,l]),c.useEffect(()=>()=>{Gt()},[]),c.useEffect(()=>{l&&M(l,tn(_.current,te.current),{knownRevisionByPath:Y.current})},[E,D,M,l]),c.useEffect(()=>{$([]),R(null),Ze(null),ye(null),Ne(0),I(!1),L(!1),H(null),Te(null),Fe(null),et(null),Ae(""),nt.current=null,xe.current+=1},[n]),c.useEffect(()=>{!Le&&O==="session"&&Je("workspace")},[O,Le]),c.useEffect(()=>{m&&O!=="workspace"&&Je("workspace")},[O,m]),c.useEffect(()=>{if(!Qe&&!Ie&&!le)return;function e(s){var y,N,fe;if(!(s.target instanceof Node))return;const u=((y=dn.current)==null?void 0:y.contains(s.target))??!1,f=((N=hn.current)==null?void 0:N.contains(s.target))??!1,d=((fe=Ht.current)==null?void 0:fe.contains(s.target))??!1;!u&&!f&&!d&&(I(!1),L(!1),H(null),Te(null))}function a(s){s.key==="Escape"&&(I(!1),L(!1),H(null),Te(null))}return document.addEventListener("pointerdown",e),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",a)}},[Qe,Ie,le]),c.useLayoutEffect(()=>{if(!le||typeof window>"u"){Te(null);return}const e=le;function a(){const u=Ht.current;if(!u)return;const f=u.getBoundingClientRect();Te(va({x:e.positionX,y:e.positionY},{width:f.width||ia,height:f.height||u.scrollHeight||0},{width:window.innerWidth,height:window.innerHeight}))}a();const s=window.requestAnimationFrame(a);return window.addEventListener("resize",a),window.addEventListener("scroll",a,!0),()=>{window.cancelAnimationFrame(s),window.removeEventListener("resize",a),window.removeEventListener("scroll",a,!0)}},[le]),c.useEffect(()=>{if(!l)return;const e=Xn(D,E),a=wt(G,E,e);ft(qn(l),{treeCache:a,treeRevisionByPath:Zn(Y.current,a),expandedDirectories:e,activeDirectoryPath:E})},[E,D,G,l]),c.useEffect(()=>{if(tt.current)return;const e=wt(G,E,D);ka(G,e)||Ee(e)},[E,D,G]),c.useEffect(()=>{let e=!1;const a=(l==null?void 0:l.trim())??null;async function s(f){if(!a)return;const d=Nt(se.current[g]??[],z),y=(f==null?void 0:f.silent)!==!0&&d.length===0;y&&ae(!0),Re("file_panel.load_root_tree.start",{sessionId:n,workspaceId:a,silent:(f==null?void 0:f.silent)===!0,cachedRootItems:d.length});try{const N=await Kt(g,{force:!0});e||(Re("file_panel.load_root_tree.end",{sessionId:n,workspaceId:a,itemCount:N.length}),Ee(fe=>({...wt(fe,te.current,_.current),[g]:N})))}catch(N){!e&&!Jn(N)&&C({title:J(N,r("conversation.filePanelLoadFailed")),tone:"error"})}finally{!e&&y&&ae(!1)}}if(Nt(se.current[g]??[],z).length>0){const f=window.setTimeout(()=>{a&&(M(a,tn(_.current,te.current),{knownRevisionByPath:Y.current}),s({silent:!0}))},1500);return()=>{e=!0,window.clearTimeout(f)}}return s(),()=>{e=!0}},[n,z,C,l]),c.useEffect(()=>{if(!l||!n){Bt(0);return}const e=nn(Yn(l,n),sa);Re("file_panel.session_change_count.snapshot",{sessionId:n,workspaceId:l,cached:e!==null,cachedCount:e}),Bt(e??0);let a=!1;return vn().catch(()=>{}),()=>{a=!0}},[n,rn,z,l]),c.useEffect(()=>{if(!l){un([]);return}const e=l.trim();K(e),pe(e)},[l,K,pe]),c.useEffect(()=>{if(!l)return;const e=l.trim();return be(a=>{var s;a.workspaceId===e&&un(((s=a.status)==null?void 0:s.changes)??[])})},[be,l]);const vt=c.useMemo(()=>Tt(cn,e=>ut(e.path),z),[cn,z]),W=c.useMemo(()=>{const e=new Map,a=new Set;for(const s of vt){const u=s.path.replace(/\\/g,"/"),f=s.worktreeStatus??s.stagedStatus??s.status;e.set(u,f);const d=u.split("/");for(let y=1;y<d.length;y++)a.add(d.slice(0,y).join("/"))}return{statusByPath:e,changedDirs:a}},[vt]),De=c.useMemo(()=>Yi(G,z),[z,G]),ke=c.useMemo(()=>Lt===null?null:Nt(Lt,z),[Lt,z]),We=De[g]??[],oe=Xe&&ke!==null,yt=c.useMemo(()=>ee?an(We,De,W.statusByPath,W.changedDirs):We,[W.changedDirs,W.statusByPath,We,ee,De]),pi=c.useMemo(()=>oe?(ke??[]).map(e=>V(e.path,e.kind)):si(yt,De,D,ee,W.statusByPath,W.changedDirs),[D,W.changedDirs,W.statusByPath,oe,ee,ke,De,yt]),$e=((Ln=T.find(e=>e.workspace.id===l))==null?void 0:Ln.workspace)??null,k=Gn(X),Ut=(k==null?void 0:k.path)??null,ge=(k==null?void 0:k.kind)==="file"?k.path:null,xt=c.useMemo(()=>new Set(X.map(e=>e.path)),[X]),at=c.useMemo(()=>St(X),[X]),Vt=!!($e!=null&&$e.path&&X.length===1&&Ut),yn=X.length===1&&(k==null?void 0:k.kind)==="file",xn=at.length>0,Me=at.length>0,lt=!!(P!=null&&P.items.length&&l),gn=!!l&&X.length===1&&k!==null,Pn=!!((ge?he(ge):E)&&D.length),Cn=P?P.mode==="copy"?r("conversation.filePanelClipboardCopyReady",{count:P.items.length}):r("conversation.filePanelClipboardCutReady",{count:P.items.length}):null,U=w?Pa(w):null;async function jn(e,a=!1){if(!l)return[];if(!a){const s=se.current[e];if(s)return s}e===g?ae(!0):Se(s=>Mt(s,e));try{const s=await Kt(e,{force:a});return Ee(u=>({...u,[e]:s})),s}catch(s){throw Jn(s)||C({title:J(s,r("conversation.filePanelLoadFailed")),tone:"error"}),s}finally{e===g?ae(!1):Se(s=>s.filter(u=>u!==e))}}async function Pe(e){if(!l)return;const a=(e==null?void 0:e.activeDirectoryPath)??te.current,s=(e==null?void 0:e.expandedDirectories)??_.current,u=Da(se.current,a,s);Re("file_panel.refresh_tree_cache.start",{sessionId:n,workspaceId:l,targetDirectories:u});const d=(await Promise.all(u.map(async y=>{const N=await Kt(y,{force:!0});return[y,N]}))).reduce((y,[N,fe])=>(y[N]=fe,y),{});Re("file_panel.refresh_tree_cache.end",{sessionId:n,workspaceId:l,targetDirectories:u,directoryCount:Object.keys(d).length}),Ee(d)}async function Kt(e,a){if(!l)return[];if(!(a!=null&&a.force)){const d=se.current[e];if(d)return d}const s=tn(Mt(_.current,e),e||te.current);M(l,s,{knownRevisionByPath:Y.current}),Q(l,[e],{knownRevisionByPath:Y.current});const u=bi(e,Un,{allowCached:(a==null?void 0:a.force)!==!0}),f=Ma(ra).then(async()=>{if(!l)return[];const y=(await Ui(l,e||void 0)).items;return Y.current={...Y.current,[e]:null},Sn(e,y),y});try{return await Promise.race([u,f])}catch(d){if(!fi(d))throw d;return await f}}function bi(e,a=Un,s){const u=se.current[e];return(s==null?void 0:s.allowCached)!==!1&&u?Promise.resolve(u):new Promise((f,d)=>{const y=window.setTimeout(()=>{vi(e,y),d(new Error(`FILE_TREE_SNAPSHOT_TIMEOUT:${e}`))},a),N=re.current.get(e)??[];re.current.set(e,[...N,{resolve:f,reject:d,timerId:y}])})}function Sn(e,a){const s=re.current.get(e)??[];s.length!==0&&(re.current.delete(e),s.forEach(u=>{window.clearTimeout(u.timerId),u.resolve(a)}))}function vi(e,a){const u=(re.current.get(e)??[]).filter(f=>f.timerId!==a);if(u.length===0){re.current.delete(e);return}re.current.set(e,u)}function Gt(){for(const[e,a]of re.current.entries())a.forEach(s=>{window.clearTimeout(s.timerId),s.reject(new Error(`FILE_TREE_ABORTED:${e}`))});re.current.clear()}function Oe(e){$([e]),R(e.path)}function st(e){F(e.kind==="directory"?e.path:he(e.path))}function yi(e){const a=da(pi,ie,e);$(a),R(e.path),st(e)}function xi(e){const a=fa(X,e),s=Gn(a);$(a),R(e.path),s&&st(s)}function wn(e){Oe(e),st(e)}function He(e,a){if(a!=null&&a.shiftKey){yi(e);return}if(jt(a)){xi(e);return}wn(e)}async function rt(e,a=!1){const s=dt(e,a);if(!s.length){F(g);return}Be(u=>ui(u,s)),F(s[s.length-1]??g);for(const u of s)try{await jn(u)}catch{return}}async function ce(e){const a=V(e,"file");Oe(a),st(a),await rt(e)}async function ze(e){Ze(e),ye(null),nt.current=null,xe.current+=1,ce(e);const a=xe.current,s=e.replace(/\\/g,"/"),u=W.statusByPath.get(s);if(l&&u&&u!=="?"&&u!=="D")try{const f=await Oi(l,e,!1);xe.current===a&&ye(f.content||null)}catch{xe.current===a&&ye(null)}}function Nn(e){const a=Date.now(),s=nt.current;return nt.current={filePath:e,timestamp:a},(s==null?void 0:s.filePath)===e&&a-s.timestamp<=na}function Ce(){nt.current=null}async function gi(e,a){const s=V(e,"file");if(a!=null&&a.shiftKey||jt(a)){Ce(),He(s,a);return}if(Nn(e)){await ze(e);return}He(s,a),await rt(e)}function En(){qe(!1),Ye(""),q(null),Ce()}async function Pi(e,a){const s=V(e.path,e.kind);if(a!=null&&a.shiftKey||jt(a)){Ce(),He(s,a);return}if(e.kind==="directory"){En(),He(s,a),await Dn(e.path);return}if(Nn(e.path)){En(),await ze(e.path);return}await ce(e.path)}async function Dn(e){if(Oe(V(e,"directory")),F(e),!_.current.includes(e))try{await jn(e),Be(a=>Mt(a,e))}catch{}}async function kn(e){if(Oe(V(e,"directory")),F(e),_.current.includes(e)){Mn(e);return}await Dn(e)}function Mn(e){Be(a=>a.filter(s=>s!==e&&!s.startsWith(`${e}/`))),F(he(e)),$([]),R(null)}async function Rn(){if(!l)return;const e=l;try{if(pe(e),await Pe(),ge&&await rt(ge),oe&&A.trim()){const a=await Ke(e,A.trim());q(a.items)}if(Le&&n)if(O==="session")Ne(a=>a+1);else try{await vn()}catch(a){C({title:J(a,r("conversation.filePanelSessionLoadFailed")),tone:"error"})}}catch(a){C({title:J(a,r("conversation.filePanelLoadFailed")),tone:"error"})}}async function Ci(e){if(e==null||e.preventDefault(),!l||!A.trim()){q(null);return}bt(!0);try{const a=await Ke(l,A.trim());q(a.items)}catch(a){C({title:J(a,r("conversation.filePanelSearchFailed")),tone:"error"})}finally{bt(!1)}}function _n(){if(Xe){qe(!1),Ye(""),q(null);return}qe(!0)}function Z(e){L(!1),e()}function Tn(){var e;(e=mn.current)==null||e.click()}async function ji(e){var d;const a=((d=e.target.files)==null?void 0:d[0])??null;if(e.target.value="",!a||!l)return;const s=ua(a.name);if(!s){C({title:r("conversation.filePanelUploadFailed"),tone:"error"});return}const u=Vn(E,k),f=Kn(u,s);mt(!0);try{const y=await Ca(a);await Hi({workspaceId:l,path:f,contentBase64:y}),await Pe(),await ce(f),C({title:r("conversation.filePanelUploadSuccess",{name:s}),tone:"success"})}catch(y){C({title:J(y,r("conversation.filePanelUploadFailed")),tone:"error"})}finally{mt(!1)}}async function Xt(e=ge){if(!(!l||!e)){mt(!0);try{const a=await zi(l,e),s=ja(a.contentBase64);Sa(a.fileName,new Blob([s],{type:"application/octet-stream"})),C({title:r("conversation.filePanelDownloadSuccess",{name:a.fileName}),tone:"success"})}catch(a){C({title:J(a,r("conversation.filePanelDownloadFailed")),tone:"error"})}finally{mt(!1)}}}function Fn(){const e=ge?he(ge):E;!e||!_.current.includes(e)||Mn(e)}function qt(){et(null),Ae("")}function Yt(){p||qt()}function Ue(e,a=Vn(E,k)){if(!l)return;const s=a,u=s?`${s}/`:"";I(!1),L(!1),H(null),et({mode:e,baseDirectory:s}),Ae(u)}function Zt(e=k){!l||!e||(I(!1),L(!1),H(null),et({mode:"rename",target:e}),Ae(e.path))}async function Si(e){if(e==null||e.preventDefault(),!l||!w)return;const a=($t??"").trim();if(a){if(w.mode==="rename"&&Ge(w.target.path)===Ge(a)){Yt();return}S(!0);try{if(w.mode==="rename"){const s=w.target.path,u=V(a,w.target.kind),f=we?ci(we,s,a):null;if(await gt({workspaceId:l,opType:"rename",srcPath:s,dstPath:a}),P&&Wt({...P,items:ga(P.items,s,a)}),qt(),Ce(),await Pe(),w.target.kind==="directory"?(await rt(a,!0),Oe(u),F(a)):await ce(a),f!==we&&(xe.current+=1,Ze(f),ye(null)),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:r("conversation.filePanelRenameSuccess",{name:ut(a)||a}),tone:"success"});return}if(await gt({workspaceId:l,opType:w.mode,dstPath:a,content:w.mode==="create_file"?"":void 0}),qt(),await Pe(),w.mode==="create_directory"?(await rt(a,!0),Oe(V(a,"directory")),F(a)):await ce(a),oe&&A.trim()){const s=await Ke(l,A.trim());q(s.items)}Ne(s=>s+1)}catch(s){C({title:J(s,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{S(!1)}}}function ue(e,a=at){var u;if(a.length===0)return;const s=St(a);Wt({mode:e,items:s}),$(s),R(((u=s[s.length-1])==null?void 0:u.path)??null),C({title:e==="copy"?r("conversation.filePanelCopySelectionSuccess",{count:s.length}):r("conversation.filePanelCutSelectionSuccess",{count:s.length}),tone:"success"}),H(null)}async function ot(e=pa(k,E)){if(!l||!P||!P.items.length)return;const a=e??g,s=P.items.map(u=>({source:u,destinationPath:Kn(a,ut(u.path)||u.path)}));S(!0);try{for(const d of s)P.mode==="cut"&&Ge(d.source.path)===Ge(d.destinationPath)||await gt({workspaceId:l,opType:P.mode==="copy"?"copy":"move",srcPath:d.source.path,dstPath:d.destinationPath});const u=s.map(d=>V(d.destinationPath,d.source.kind)),f=u[u.length-1]??null;if(P.mode==="cut"&&Wt(null),$(u),R((f==null?void 0:f.path)??null),f&&st(f),Ce(),await Pe({activeDirectoryPath:(f==null?void 0:f.kind)==="directory"?f.path:f?he(f.path):te.current,expandedDirectories:_.current}),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:r("conversation.filePanelPasteSuccess",{count:u.length}),tone:"success"}),H(null)}catch(u){await Pe().catch(()=>{}),C({title:J(u,r("conversation.filePanelPasteFailed")),tone:"error"})}finally{S(!1)}}function Jt(e=at){!e.length||p||(Fe(St(e)),H(null))}async function wi(){var a,s;if(!l||!(B!=null&&B.length))return;const e=St(B);S(!0);try{for(const d of e)await gt({workspaceId:l,opType:"delete",srcPath:d.path});const u=ba(E,e),f=_.current.filter(d=>!e.some(y=>y.kind==="directory"&&Ft(y.path,d)));if(we&&e.some(d=>Ft(d.path,we))&&(xe.current+=1,Ze(null),ye(null)),Fe(null),$([]),R(null),te.current=u,_.current=f,F(u),Be(f),Ce(),await Pe({activeDirectoryPath:u,expandedDirectories:f}),oe&&A.trim()){const d=await Ke(l,A.trim());q(d.items)}Ne(d=>d+1),C({title:e.length===1?r("conversation.filePanelDeleteSuccess",{name:ut(((a=e[0])==null?void 0:a.path)??"")||((s=e[0])==null?void 0:s.path)||""}):r("conversation.filePanelDeleteSelectionSuccess",{count:e.length}),tone:"success"})}catch(u){C({title:J(u,r("conversation.filePanelMutateFailed")),tone:"error"})}finally{S(!1)}}async function Ve(e,a=k){const s=($e==null?void 0:$e.path)??"",u=(a==null?void 0:a.path)??null;if(u===null||!s){I(!1);return}try{const f=xa(s),d=e==="absolute"?ya(s,u,f):Ge(u,f);await wa(d,it),C({title:e==="absolute"?r("conversation.filePanelCopyAbsolutePathSuccess"):r("conversation.filePanelCopyRelativePathSuccess"),tone:"success"})}catch(f){C({title:f instanceof Error?f.message:r("conversation.filePanelCopyPathFailed"),tone:"error"})}finally{I(!1),H(null)}}function Ni(e,a,s){return[{id:`open-${e.path}`,label:e.kind==="directory"?D.includes(e.path)?r("conversation.filePanelCollapseDirectory"):r("conversation.filePanelExpandDirectory"):r("conversation.filePanelOpenFile"),onSelect:()=>{if(e.kind==="directory"){kn(e.path);return}ze(e.path)}},{id:`download-${e.path}`,label:r("conversation.filePanelDownload"),disabled:e.kind!=="file"||v,onSelect:()=>{Xt(e.kind==="file"?e.path:null)}},{id:`create-file-${e.path}`,label:r("conversation.filePanelNewFile"),disabled:!l||p||v,onSelect:()=>{Ue("create_file",s)}},{id:`create-directory-${e.path}`,label:r("conversation.filePanelNewDirectory"),disabled:!l||p||v,onSelect:()=>{Ue("create_directory",s)}},{id:`rename-${e.path}`,label:r("conversation.filePanelRenameMove"),disabled:a.length!==1||p||v,onSelect:()=>Zt(e)},{id:`copy-${e.path}`,label:r("conversation.filePanelCopy"),disabled:a.length===0,onSelect:()=>ue("copy",a)},{id:`cut-${e.path}`,label:r("conversation.filePanelCut"),disabled:a.length===0,onSelect:()=>ue("cut",a)},{id:`paste-${e.path}`,label:r("conversation.filePanelPaste"),disabled:!lt,onSelect:()=>{ot(s)}},{id:`copy-relative-${e.path}`,label:r("conversation.filePanelCopyRelativePath"),onSelect:()=>{Ve("relative",e)}},{id:`copy-absolute-${e.path}`,label:r("conversation.filePanelCopyAbsolutePath"),onSelect:()=>{Ve("absolute",e)}},{id:`delete-${e.path}`,label:r("conversation.filePanelDelete"),disabled:a.length===0||p||v,onSelect:()=>Jt(a)}]}async function An(e,a){if(it.isMobile)return;e.preventDefault();const s=V(a.path,a.kind),u=xt.has(s.path)?at:[s],f=s.kind==="directory"?s.path:he(s.path);xt.has(s.path)||wn(s);const d=Ni(s,u,f);if(it.isDesktop){await Vi(d);return}it.isWeb&&(I(!1),L(!1),H({positionX:e.clientX,positionY:e.clientY,items:d}))}c.useEffect(()=>{if(O!=="workspace")return;function e(a){if(!ha(a)||a.altKey||a.shiftKey||ma(a.target))return;const s=a.key.toLowerCase();if(s==="c"&&Me){a.preventDefault(),ue("copy");return}if(s==="x"&&Me){a.preventDefault(),ue("cut");return}s==="v"&&lt&&(a.preventDefault(),ot())}return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[O,Me,lt,ue,ot]);function Qt(e,a){return i.jsx(i.Fragment,{children:e.map(s=>{const u=V(s.path,s.kind),f=s.kind==="directory",d=f&&D.includes(s.path),y=f&&je.includes(s.path),N=De[s.path]??[],fe=ee?an(N,De,W.statusByPath,W.changedDirs):N,Di=xt.has(s.path),ki=Ut===s.path,ct=W.statusByPath.get(s.path.replace(/\\/g,"/")),Wn=f&&W.changedDirs.has(s.path.replace(/\\/g,"/")),Mi=(P==null?void 0:P.mode)==="cut"&&P.items.some(de=>de.path===s.path);return i.jsxs("div",{className:"file-tree-node",children:[i.jsxs("button",{className:"file-tree-item",type:"button","data-active":ki,"data-selected":Di,"data-cut-pending":Mi||void 0,"data-kind":s.kind,"aria-expanded":f?d:void 0,style:{paddingInlineStart:`${oa+a*ca}px`},onClick:de=>{if(f){if(de.shiftKey||jt(de)){Ce(),He(u,de);return}Ce(),He(u,de),kn(s.path);return}gi(s.path,de)},onContextMenu:de=>{An(de,s)},children:[i.jsx("span",{className:`file-tree-chevron${f?"":" is-hidden"}`,"aria-hidden":"true",children:d?"v":">"}),f?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(s.name),"aria-hidden":"true",children:Rt(s.name)}),i.jsx("span",{className:"file-tree-label","data-status":ct??void 0,"data-has-changes":Wn||void 0,children:s.name}),!f&&ct?i.jsx("span",{className:"git-status-badge","data-status":ct,"aria-label":ct,children:ct}):null,f&&Wn?i.jsx("span",{className:"file-tree-dir-badge","aria-hidden":"true"}):null,y?i.jsx("span",{className:"file-tree-meta",children:r("common.loading")}):null]}),f&&d?i.jsx("div",{className:"file-tree-children",children:y&&!N.length?i.jsx("p",{className:"file-tree-empty",children:r("common.loading")}):fe.length?Qt(fe,a+1):i.jsx("p",{className:"file-tree-empty",children:r("conversation.filePanelEmptyDirectory")})}):null]},`${s.kind}-${s.path}`)})})}function Ei(e){return i.jsx(i.Fragment,{children:e.map(a=>{const s=a.kind==="directory",u=xt.has(a.path),f=Ut===a.path;return i.jsx("div",{className:"file-tree-node",children:i.jsxs("button",{className:"file-tree-item is-search-result",type:"button","data-active":f,"data-selected":u,"data-kind":a.kind,onClick:d=>{Pi(a,d)},onContextMenu:d=>{An(d,a)},children:[i.jsx("span",{className:"file-tree-chevron is-hidden","aria-hidden":"true",children:">"}),s?null:i.jsx("span",{className:"git-tree-file-icon","data-kind":_t(a.name),"aria-hidden":"true",children:Rt(a.name)}),i.jsxs("span",{className:"file-tree-label",children:[i.jsx("span",{className:"file-tree-name",children:a.name}),i.jsx("span",{className:"file-tree-path",children:a.path})]})]})},`search-${a.kind}-${a.path}`)})})}return i.jsx("section",{className:["conversation-panel","surface-card","file-panel",t].filter(Boolean).join(" "),"data-testid":"file-context-panel",children:l?i.jsxs(i.Fragment,{children:[i.jsx(Ki,{workspaceId:l,filePath:we,open:we!==null,onClose:()=>{xe.current+=1,Ze(null),ye(null)},onSaved:async e=>{await Pe(),await ce(e),Ne(a=>a+1)},diffContent:hi}),o?null:i.jsx("div",{className:"file-panel-heading-row",children:i.jsx("h2",{className:"file-panel-heading",children:r("conversation.filePanelTitle")})}),m?null:i.jsxs("div",{className:"file-panel-tabs",role:"tablist","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:O==="workspace"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="workspace",onClick:()=>Je("workspace"),children:r("conversation.filePanelWorkspaceTab")}),i.jsxs("button",{className:O==="session"?"file-panel-tab active":"file-panel-tab",type:"button",role:"tab","aria-selected":O==="session",onClick:()=>{Le&&Je("session")},disabled:!Le,children:[r("conversation.filePanelSessionTab"),i.jsx("span",{className:"file-panel-tab-badge","aria-label":`${r("conversation.filePanelSessionTab")} ${on}`,children:on})]})]}),O==="workspace"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:mn,"data-testid":"file-panel-upload-input",type:"file",hidden:!0,onChange:e=>void ji(e)}),bn?i.jsx("div",{className:"file-panel-toolbar file-panel-toolbar-mobile","aria-label":r("conversation.filePanelTitle"),children:i.jsxs("div",{className:"file-mobile-action-shell",ref:hn,children:[i.jsxs("button",{className:"secondary-button file-mobile-action-trigger",type:"button","aria-label":r("conversation.filePanelActionsMenu"),"aria-haspopup":"menu","aria-expanded":Ie,"data-active":Ie,onClick:()=>{I(!1),L(e=>!e)},children:[i.jsx("span",{children:r("conversation.filePanelActionsMenu")}),i.jsx(Ua,{})]}),Ie?i.jsxs("div",{className:"file-mobile-action-menu",role:"menu","aria-label":r("conversation.filePanelActionsMenu"),children:[i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ue("copy")),disabled:!Me,children:r("conversation.filePanelCopy")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ue("cut")),disabled:!Me,children:r("conversation.filePanelCut")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>ot()),disabled:!lt||p||v,children:r("conversation.filePanelPaste")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),_n()},children:Xe?r("conversation.filePanelHideSearch"):r("conversation.filePanelShowSearch")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Ot(e=>!e)},disabled:vt.length===0,children:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Rn),disabled:_e||p||pt,children:r("conversation.filePanelRefresh")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Fn()},disabled:!Pn,children:r("conversation.filePanelCollapseCurrent")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>{L(!1),Tn()},disabled:p||v,children:r("conversation.filePanelUpload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Xt),disabled:!yn||v,children:r("conversation.filePanelDownload")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(Zt),disabled:!gn||p||v,children:r("conversation.filePanelRenameMove")}),i.jsx("button",{className:"file-mobile-action-menu-item danger",type:"button",role:"menuitem",onClick:()=>Z(Jt),disabled:!xn||p||v,children:r("conversation.filePanelDelete")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ue("create_file")),disabled:p||v,children:r("conversation.filePanelNewFile")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ue("create_directory")),disabled:p||v,children:r("conversation.filePanelNewDirectory")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ve("absolute")),disabled:!Vt,children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-mobile-action-menu-item",type:"button",role:"menuitem",onClick:()=>Z(()=>Ve("relative")),disabled:!Vt,children:r("conversation.filePanelCopyRelativePath")})]}):null]})}):i.jsxs("div",{className:"file-panel-toolbar","aria-label":r("conversation.filePanelTitle"),children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopy"),"aria-label":r("conversation.filePanelCopy"),onClick:()=>ue("copy"),disabled:!Me,children:i.jsx(Fa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCut"),"aria-label":r("conversation.filePanelCut"),onClick:()=>ue("cut"),disabled:!Me,children:i.jsx(Aa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelPaste"),"aria-label":r("conversation.filePanelPaste"),onClick:()=>void ot(),disabled:!lt||p||v,children:i.jsx(La,{})}),i.jsxs("div",{className:"file-toolbar-menu-shell",ref:dn,children:[i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCopyPath"),"aria-label":r("conversation.filePanelCopyPath"),"aria-haspopup":"menu","aria-expanded":Qe,"data-active":Qe,onClick:()=>{L(!1),I(e=>!e)},disabled:!Vt,children:i.jsx(Ta,{})}),Qe?i.jsxs("div",{className:"file-toolbar-menu",role:"menu",children:[i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ve("absolute"),children:r("conversation.filePanelCopyAbsolutePath")}),i.jsx("button",{className:"file-toolbar-menu-item",type:"button",role:"menuitem",onClick:()=>void Ve("relative"),children:r("conversation.filePanelCopyRelativePath")})]}):null]}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelCollapseCurrent"),"aria-label":r("conversation.filePanelCollapseCurrent"),onClick:Fn,disabled:!Pn,children:i.jsx(Ra,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRefresh"),"aria-label":r("conversation.filePanelRefresh"),onClick:()=>void Rn(),disabled:_e||p||pt,children:i.jsx(_a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),"data-active":Xe,onClick:_n,disabled:_e,children:i.jsx(Qn,{})}),vt.length>0?i.jsx("button",{className:"file-toolbar-button",type:"button",title:ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"aria-label":ee?r("conversation.filePanelShowAll"):r("conversation.filePanelFilterChanges"),"data-active":ee,onClick:()=>Ot(e=>!e),children:i.jsx(Va,{})}):null,i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelUpload"),"aria-label":r("conversation.filePanelUpload"),onClick:Tn,disabled:p||v,children:i.jsx(Wa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelDownload"),"aria-label":r("conversation.filePanelDownload"),onClick:()=>void Xt(),disabled:!yn||v,children:i.jsx($a,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelRenameMove"),"aria-label":r("conversation.filePanelRenameMove"),onClick:()=>Zt(),disabled:!gn||p||v,children:i.jsx(za,{})}),i.jsx("button",{className:"file-toolbar-button danger",type:"button",title:r("conversation.filePanelDelete"),"aria-label":r("conversation.filePanelDelete"),onClick:()=>Jt(),disabled:!xn||p||v,children:i.jsx(Oa,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewFile"),"aria-label":r("conversation.filePanelNewFile"),onClick:()=>void Ue("create_file"),disabled:p||v,children:i.jsx(Ba,{})}),i.jsx("button",{className:"file-toolbar-button",type:"button",title:r("conversation.filePanelNewDirectory"),"aria-label":r("conversation.filePanelNewDirectory"),onClick:()=>void Ue("create_directory"),disabled:p||v,children:i.jsx(Ha,{})})]}),le&&typeof document<"u"?_i.createPortal(i.jsx("div",{className:"file-web-context-menu",ref:Ht,role:"menu","aria-label":r("conversation.filePanelActionsMenu"),style:{left:`${(ve==null?void 0:ve.left)??Math.max(8,le.positionX)}px`,top:`${(ve==null?void 0:ve.top)??Math.max(8,le.positionY)}px`,maxHeight:ve?`${ve.maxHeight}px`:void 0},children:le.items.map(e=>i.jsx("button",{className:["file-web-context-menu-item",e.label===r("conversation.filePanelDelete")?"danger":""].filter(Boolean).join(" "),type:"button",role:"menuitem",disabled:e.disabled,onClick:()=>{H(null),e.onSelect()},children:e.label},e.id))}),document.body):null,Cn?i.jsx("p",{className:"file-panel-clipboard-status","data-mode":P==null?void 0:P.mode,children:Cn}):null,Xe?i.jsxs("form",{className:"file-toolbar-search",onSubmit:e=>void Ci(e),children:[i.jsx("input",{value:A,onChange:e=>Ye(e.target.value),placeholder:r("conversation.filePanelSearchPlaceholder")}),bn?i.jsx("button",{className:"secondary-button file-mobile-search-submit",type:"submit","aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:r("conversation.filePanelSearchButton")}):i.jsx("button",{className:"file-toolbar-button",type:"submit",title:r("conversation.filePanelSearchButton"),"aria-label":r("conversation.filePanelSearchButton"),disabled:pt,children:i.jsx(Qn,{})})]}):null,i.jsx("div",{ref:mi,className:"file-tree","data-search-mode":oe,"data-scrollbar-autohide":"true",children:_e&&We.length===0?i.jsx("p",{className:"file-tree-status status-text",children:r("common.loading")}):oe?ke!=null&&ke.length?Ei(ke):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelSearchEmpty")}):ee?yt.length?Qt(yt,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelNoChanges")}):We.length?Qt(We,0):i.jsx("p",{className:"file-tree-status status-text",children:r("conversation.filePanelEmptyDirectory")})}),i.jsx($n,{open:w!==null,title:(U==null?void 0:U.title)??"",description:U==null?void 0:U.description,onClose:Yt,children:i.jsxs("form",{className:"workbench-rename-form",onSubmit:e=>void Si(e),children:[i.jsx(Ai,{label:r("conversation.filePanelPathFieldLabel"),htmlFor:fn,description:(w==null?void 0:w.mode)==="rename"?w.target.path:(w==null?void 0:w.baseDirectory)||void 0,children:i.jsx("input",{id:fn,type:"text",value:$t??"",placeholder:r("conversation.filePanelPathFieldPlaceholder"),autoFocus:!0,onChange:e=>Ae(e.target.value)})}),i.jsxs(Li,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:Yt,children:r("common.cancel")}),i.jsx("button",{type:"submit",className:"primary-button",disabled:p||!($t??"").trim(),children:p?(U==null?void 0:U.pendingLabel)??r("common.loading"):(U==null?void 0:U.submitLabel)??r("common.save")})]})]})}),i.jsxs($n,{open:B!==null,title:r("conversation.filePanelDeleteConfirmTitle"),description:r("conversation.filePanelDeleteConfirmDescription"),onClose:()=>{p||Fe(null)},children:[i.jsx("p",{className:"workbench-section-empty",children:B!=null&&B.length?B.length===1?((Bn=B[0])==null?void 0:Bn.kind)==="directory"?r("conversation.filePanelDeleteDirectoryConfirm",{path:B[0].path}):r("conversation.filePanelDeleteFileConfirm",{path:B[0].path}):r("conversation.filePanelDeleteSelectionConfirm",{count:B.length}):""}),i.jsxs("div",{className:"workbench-modal-actions",children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:p,onClick:()=>Fe(null),children:r("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:p,onClick:()=>{wi()},children:p?r("conversation.filePanelDeleting"):r("conversation.filePanelDelete")})]})]})]}):Le&&n?i.jsx(ea,{sessionId:n,workspaceId:l,showSystemFiles:z,selectedPath:ge,refreshVersion:rn,onCountChange:zt,onSelectFile:ce,onOpenFile:ze}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelSessionNoSession")})})]}):i.jsx("section",{className:"file-panel-section",children:i.jsx("p",{className:"status-text",children:r("conversation.filePanelNoWorkspace")})})})}function he(t){return t.includes("/")?t.split("/").slice(0,-1).join("/"):g}function dt(t,n=!1){const l=t.split("/").filter(Boolean),o=n?l.length:l.length-1,m=[];for(let h=0;h<o;h+=1)m.push(l.slice(0,h+1).join("/"));return m}function Vn(t,n){return t||((n==null?void 0:n.kind)==="directory"?n.path:n!=null&&n.path?he(n.path):g)}function Kn(t,n){return t?`${t}/${n}`:n}function ua(t){var n;return((n=t.split(/[/\\]/).pop())==null?void 0:n.trim())??""}function V(t,n){return{path:t,kind:n}}function Gn(t){return t[t.length-1]??null}function fa(t,n){return t.findIndex(o=>o.path===n.path)>=0?t.filter(o=>o.path!==n.path):[...t,n]}function da(t,n,l){const o=t.findIndex(x=>x.path===l.path);if(o<0)return[l];const m=n?t.findIndex(x=>x.path===n):o;if(m<0)return[l];const h=Math.min(m,o),b=Math.max(m,o);return t.slice(h,b+1)}function jt(t){return!!(t!=null&&t.ctrlKey||t!=null&&t.metaKey)}function ha(t){return t.ctrlKey||t.metaKey}function ma(t){if(!(t instanceof HTMLElement))return!1;const n=t.tagName.toLowerCase();return n==="input"||n==="textarea"||n==="select"||t.isContentEditable}function St(t){const n=[...new Map(t.map(o=>[o.path,o])).values()].sort((o,m)=>o.path.localeCompare(m.path)),l=[];for(const o of n)l.some(m=>m.kind==="directory"&&Ft(m.path,o.path))||l.push(o);return l}function pa(t,n){return(t==null?void 0:t.kind)==="directory"?t.path:t!=null&&t.path?he(t.path):n}function ba(t,n){let l=t;for(;l&&n.some(o=>o.kind==="directory"&&Ft(o.path,l));)l=he(l);return l}function si(t,n,l,o,m,h){const b=[];for(const x of t){if(b.push(V(x.path,x.kind)),x.kind!=="directory"||!l.includes(x.path))continue;const j=n[x.path]??[],T=o?an(j,n,m,h):j;b.push(...si(T,n,l,o,m,h))}return b}function va(t,n,l){const o=Math.max(0,l.width),m=Math.max(0,l.height),h=Math.max(0,m-ne*2),b=Math.max(0,o-ne*2),x=Math.min(Math.max(n.width,0),b),j=Math.max(0,m-t.y-Ct-ne),T=Math.max(0,t.y-Ct-ne),M=j<n.height&&T>j,me=en(Math.max(M?T:j,aa),0,h),K=Math.min(Math.max(n.height,0),me),pe=M?t.y-Ct-K:t.y+Ct,be=Math.max(ne,m-ne-K),G=Math.max(ne,o-ne-x);return{top:en(pe,ne,be),left:en(t.x,ne,G),maxHeight:Math.max(0,me)}}function en(t,n,l){return!Number.isFinite(t)||l<n?n:Math.min(Math.max(t,n),l)}function Ge(t,n="posix"){return t?ri(t,n):"."}function ya(t,n,l){const o=ri(t,l),m=Ge(n,l).replace(/^\.[/\\]?/,"");if(!m)return o;const h=oi(l),b=m.replace(/^[/\\]+/,"");return b?o.endsWith("/")||o.endsWith("\\")?`${o}${b}`:`${o}${h}${b}`:o}function xa(t){return/^[a-zA-Z]:[\\/]/.test(t)||t.includes("\\")?"windows":"posix"}function ri(t,n){return t&&(oi(n)==="\\"?t.replace(/\//g,"\\"):t.replace(/\\/g,"/"))}function oi(t){return t==="windows"?"\\":"/"}function Ft(t,n){return n===t||n.startsWith(`${t}/`)}function ci(t,n,l){return t===n?l:t.startsWith(`${n}/`)?`${l}${t.slice(n.length)}`:t}function ga(t,n,l){return t.map(o=>({...o,path:ci(o.path,n,l)}))}function Pa(t){return t.mode==="create_file"?{title:r("conversation.filePanelNewFile"),description:r("conversation.filePanelCreateFileDescription"),submitLabel:r("conversation.filePanelCreateFileSubmit"),pendingLabel:r("conversation.filePanelCreatingFile")}:t.mode==="create_directory"?{title:r("conversation.filePanelNewDirectory"),description:r("conversation.filePanelCreateDirectoryDescription"),submitLabel:r("conversation.filePanelCreateDirectorySubmit"),pendingLabel:r("conversation.filePanelCreatingDirectory")}:{title:r("conversation.filePanelRenameMove"),description:r("conversation.filePanelRenameDescription"),submitLabel:r("conversation.filePanelRenameSubmit"),pendingLabel:r("conversation.filePanelRenaming")}}async function Ca(t){const n=await t.arrayBuffer(),l=new Uint8Array(n),o=32768;let m="";for(let h=0;h<l.length;h+=o){const b=l.subarray(h,h+o);m+=String.fromCharCode(...b)}return btoa(m)}function ja(t){const n=atob(t),l=new Uint8Array(n.length);for(let o=0;o<n.length;o+=1)l[o]=n.charCodeAt(o);return l.buffer.slice(l.byteOffset,l.byteOffset+l.byteLength)}function Sa(t,n){if(typeof document>"u")throw new Error(r("conversation.filePanelDownloadFailed"));const l=window.URL.createObjectURL(n),o=document.createElement("a");o.href=l,o.download=t,document.body.append(o),o.click(),o.remove(),window.URL.revokeObjectURL(l)}async function wa(t,n){var l;if(!(n.isDesktop&&(await n.bridge.writeClipboardText(t)).ok)){if(typeof navigator<"u"&&((l=navigator.clipboard)!=null&&l.writeText))try{await navigator.clipboard.writeText(t);return}catch{}if(!Na(t))throw new Error(r("conversation.filePanelCopyPathFailed"))}}function Na(t){if(typeof document>"u"||typeof document.execCommand!="function")return!1;const n=document.createElement("textarea");n.value=t,n.setAttribute("readonly","true"),n.style.position="fixed",n.style.top="-9999px",n.style.left="-9999px",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(n)}}function Ea(t,n){return t&&dt(t,!0).every(m=>m in n)?t:g}function Xn(t,n){if(!n)return[];const l=dt(n,!0);return t.filter(o=>l.includes(o))}function wt(t,n,l){const o=sn(n,l);return Object.entries(t).reduce((m,[h,b])=>(o.has(h)&&(m[h]=b),m),{})}function Da(t,n,l){const m=[...sn(n,l)].filter(h=>h===g||h in t);return m.length?m:[g]}function sn(t,n){const l=new Set([g]),o=ui(n,dt(t,!0));for(const m of o){l.add(m);for(const h of dt(m,!0))l.add(h)}return l}function ka(t,n){const l=Object.keys(t),o=Object.keys(n);return l.length!==o.length?!1:l.every(m=>t[m]===n[m])}function Mt(t,n){return t.includes(n)?t:[...t,n]}function ui(t,n){return n.reduce((l,o)=>Mt(l,o),t)}function qn(t){return`file-panel.workspace-tree.${t}`}function Yn(t,n){return`file-panel.session-change-count.${t}.${n}`}function Zn(t,n){return Object.fromEntries(Object.keys(n).map(l=>[l,t[l]??null]))}function tn(t,n){return[...sn(n,t)]}function J(t,n){return t instanceof In?t.message:n}function fi(t){return t instanceof Error&&t.message.startsWith("FILE_TREE_SNAPSHOT_TIMEOUT:")}function Jn(t){return fi(t)||t instanceof Error&&t.message.startsWith("FILE_TREE_ABORTED:")}function Ma(t){return new Promise(n=>{window.setTimeout(n,t)})}function Ra(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M2.5 4.5h11v2h-11zM2.5 7.5h7v2h-7zM2.5 10.5h4v2h-4z",fill:"currentColor"})})}function _a(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M12.8 5.2A5.5 5.5 0 1 0 13.5 8h-1.8A3.7 3.7 0 1 1 10.6 5l-1.4 1.4h4V2l-1.4 1.4z",fill:"currentColor"})})}function Qn(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M11.2 10.1l3 3-1.1 1.1-3-3a5 5 0 1 1 1.1-1.1zM6.8 10.3a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z",fill:"currentColor"})})}function Ta(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3.5 4.3h5.2v1.4H4.9v5.4H3.5zm3.8-2.1h5.2v9.5H7.3z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M5.7 10.8h4.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Fa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 2.5h7.5v9H5z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M3.5 5H2.4V13.5H10V12.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Aa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.2 4.2a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm0 5.4a1.4 1.4 0 1 1 0 2.8 1.4 1.4 0 0 1 0-2.8zm1-3.2 6.6 5.6M5.2 9.6l6.6-5.6",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round"})})}function La(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.5h8v10H4zM6 2.2h4v2H6z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M6 7.2h4M6 9.6h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Ba(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 1.5h5l3 3v10H4z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M9 1.5v3h3",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 6.5v5M5.5 9h5",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function Wa(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 5 2.5-2.5L10.5 5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function $a(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M3 11.5v2h10v-2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8 2.5v8",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"m5.5 8.5 2.5 2.5 2.5-2.5",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oa(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.5 4.5h9M6.2 2.5h3.6l.6 1.4H13v1.2H3V3.9h2.6zM5.2 5.7v6.1m2.8-6.1v6.1m2.8-6.1v6.1M4.4 13.5h7.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ha(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M1.8 4.5h4l1.2 1.3h7.2v6.7H1.8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.5 7.2v4M6.5 9.2h4",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function za(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M3.2 11.9h2.2l5.9-5.9-2.2-2.2-5.9 5.9zM8.3 3.8l2.2 2.2M2.8 13.2h10.4",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ua(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"m4 6 4 4 4-4",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})})}function Va(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M1.5 2h13l-5 6v5l-3 1.5V8z",fill:"none",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"})})}function an(t,n,l,o){const m=[];for(const h of t){const b=h.path.replace(/\\/g,"/");h.kind==="file"?l.has(b)&&m.push(h):di(b,n,l,o)&&m.push(h)}return m}function di(t,n,l,o,m){const h=m??new Set;if(h.has(t))return!1;h.add(t);const b=n[t];if(!b)return o.has(t);for(const x of b){const j=x.path.replace(/\\/g,"/");if(x.kind==="file"){if(l.has(j))return!0}else if(di(j,n,l,o,h))return!0}return!1}export{el as FileContextPanel};