@openchamber/web 1.18.3 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/README.md +1 -0
  2. package/dist/assets/{CodeMirrorCommentWidgets-DbUi6I9s.js → CodeMirrorCommentWidgets-DAvopJvy.js} +1 -1
  3. package/dist/assets/{CommitSection-Jc2_hNPE.js → CommitSection-D9cV-qR9.js} +1 -1
  4. package/dist/assets/{DiagramEditor-PCrYHBko.js → DiagramEditor-B9NCadU7.js} +1 -1
  5. package/dist/assets/DiagramView-LKGBwf4G.js +1 -0
  6. package/dist/assets/{DiffView-DEGlNjMH.js → DiffView-BWNq-0ov.js} +2 -2
  7. package/dist/assets/FilesView-DB-Q0Gkz.js +14 -0
  8. package/dist/assets/{GitView-C-n17voy.js → GitView-DsWXqWx3.js} +3 -3
  9. package/dist/assets/{JsonTreeView-BYcgdTOQ.js → JsonTreeView-h4dHASlq.js} +1 -1
  10. package/dist/assets/MarkdownImageGallery-n0ikH-xm.js +1 -0
  11. package/dist/assets/MarkdownRendererImpl-CT2mjx-s.js +12 -0
  12. package/dist/assets/OnboardingScreen-CDjgzxEe.js +1 -0
  13. package/dist/assets/{PatchDiff-Bn7bfgUv.js → PatchDiff-jPKTJje5.js} +1 -1
  14. package/dist/assets/{PierreDiffViewer-D1fWvrUn.js → PierreDiffViewer-D_Gt4A_6.js} +1 -1
  15. package/dist/assets/PlanView-UvuxIl9-.js +4 -0
  16. package/dist/assets/SessionSwitcherDropdown-xKU4LRuQ.js +1 -0
  17. package/dist/assets/SettingsView-3B9VN6Ys.js +28 -0
  18. package/dist/assets/SettingsWindow-CqQNDKNd.js +1 -0
  19. package/dist/assets/{ToolOutputDialog-BtIJkFno.js → ToolOutputDialog-PmjlAxVE.js} +6 -6
  20. package/dist/assets/{ToolPartDiffPreview-i3PQo6_0.js → ToolPartDiffPreview-B34Xw9wq.js} +1 -1
  21. package/dist/assets/{VirtualizedFileDiff-DkcusvMa.js → VirtualizedFileDiff-B37yB9jZ.js} +3 -3
  22. package/dist/assets/{WalkthroughView-Cc5Hd6P5.js → WalkthroughView-Bxun3k66.js} +2 -2
  23. package/dist/assets/{computeVirtualFileMetrics-xPena3W2.js → computeVirtualFileMetrics-DYFv_yZS.js} +2 -2
  24. package/dist/assets/contextPanelEmbeddedChat-BO1wRpaN.js +1 -0
  25. package/dist/assets/de-DbV6CLxv.js +9 -0
  26. package/dist/assets/document-attachments-DFAWlG3U.js +31 -0
  27. package/dist/assets/es-CVDlyzZ4.js +15 -0
  28. package/dist/assets/fr-Czc-p0g-.js +13 -0
  29. package/dist/assets/index-1OhiMDBz.css +1 -0
  30. package/dist/assets/index-BSvmTvZl.js +1 -0
  31. package/dist/assets/index-DzriVon2.js +7 -0
  32. package/dist/assets/{isDiffPlainText-Dudf-dWx.js → isDiffPlainText-DwHKxDYc.js} +1 -1
  33. package/dist/assets/{isFilePlainText-DS4QV1dd.js → isFilePlainText-Dwq6ILxo.js} +1 -1
  34. package/dist/assets/ja-dwc9NM_S.js +15 -0
  35. package/dist/assets/ko-Ds1DZ8FX.js +15 -0
  36. package/dist/assets/{lua-BgMRiT3U.js → lua-VAEuO923.js} +1 -1
  37. package/dist/assets/main-BF51IOVF.js +921 -0
  38. package/dist/assets/{main-C0DyIwTb.js → main-D7UPARut.js} +2 -2
  39. package/dist/assets/markdownCore-BgeBDwD3.js +2 -0
  40. package/dist/assets/{miniChat-CGfrxKpJ.js → miniChat-BISXSGOo.js} +2 -2
  41. package/dist/assets/mobile-BnYxVuvw.js +2 -0
  42. package/dist/assets/{patchFileDiff-C5D1OPCa.js → patchFileDiff-BEDPDypx.js} +2 -2
  43. package/dist/assets/pl-CLiTO7i-.js +15 -0
  44. package/dist/assets/pt-BR-GIimJgpK.js +15 -0
  45. package/dist/assets/renderElectronMiniChatApp-BaOy72Gi.js +2 -0
  46. package/dist/assets/{renderMobileApp-B5HA4qbi.js → renderMobileApp-BiMbzPq9.js} +7 -7
  47. package/dist/assets/runtimeEndpointReset-BMBRhIbf.js +15 -0
  48. package/dist/assets/scheduledTasksApi-01zzfzqH.js +1 -0
  49. package/dist/assets/{shikiHighlight-CmanopUB.js → shikiHighlight-DXYW46vW.js} +1 -1
  50. package/dist/assets/uk-DLfgD1ki.js +15 -0
  51. package/dist/assets/{useAppFontEffects-sHmU5b8u.js → useAppFontEffects-CbzHzFop.js} +139 -142
  52. package/dist/assets/{useInlineCommentController-gt56WkxJ.js → useInlineCommentController-CegKdDXi.js} +2 -2
  53. package/dist/assets/{vendor-base-ui-D_V6hAcE.js → vendor-base-ui-BYlZTzrw.js} +1 -1
  54. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +1 -0
  55. package/dist/assets/vendor-codemirror-commands-B7H_j0iU.js +1 -0
  56. package/dist/assets/{vendor-codemirror-lang-angular-CgY7_gQ1.js → vendor-codemirror-lang-angular-DEPs2M5t.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-cpp-B5Ta4enQ.js → vendor-codemirror-lang-cpp-DhkseaMo.js} +1 -1
  58. package/dist/assets/{vendor-codemirror-lang-css-VgNqFSH-.js → vendor-codemirror-lang-css-O0cZX78y.js} +1 -1
  59. package/dist/assets/{vendor-codemirror-lang-go-LxLz62pp.js → vendor-codemirror-lang-go-fMdQYcON.js} +1 -1
  60. package/dist/assets/vendor-codemirror-lang-html-CfgK872x.js +1 -0
  61. package/dist/assets/{vendor-codemirror-lang-java-Bksi1PH4.js → vendor-codemirror-lang-java-CQj4S3zl.js} +1 -1
  62. package/dist/assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js +13 -0
  63. package/dist/assets/{vendor-codemirror-lang-jinja-C7npuDD7.js → vendor-codemirror-lang-jinja-BmZZv8g-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-json-ryCw7nab.js → vendor-codemirror-lang-json-CMBS2tG9.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-less-BxsZJD6N.js → vendor-codemirror-lang-less-C6Eo8hVS.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-liquid-De6qch10.js → vendor-codemirror-lang-liquid-DSTR47-H.js} +1 -1
  67. package/dist/assets/vendor-codemirror-lang-markdown-BPGOH9ye.js +1 -0
  68. package/dist/assets/{vendor-codemirror-lang-php-Cm1es33p.js → vendor-codemirror-lang-php-DD9udfPH.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-python-N414WYK-.js → vendor-codemirror-lang-python-HahnQaAS.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-rust-C_WuUStH.js → vendor-codemirror-lang-rust-nLTovbjv.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-sass-8UHTCAOM.js → vendor-codemirror-lang-sass-pL2Yc72v.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-sql-CV3sMA5D.js → vendor-codemirror-lang-sql-BVBnan19.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-vue-DzvC1Dhk.js → vendor-codemirror-lang-vue-BqGzJVm1.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-wast-jlr-LDdA.js → vendor-codemirror-lang-wast-B0_m5DqU.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-xml-CrO63OVp.js → vendor-codemirror-lang-xml-Dj3voadT.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-yaml-dxi6CISW.js → vendor-codemirror-lang-yaml-yu-9Z5u7.js} +1 -1
  77. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +3 -0
  78. package/dist/assets/{vendor-codemirror-language-data-Dihw9MtL.js → vendor-codemirror-language-data-CiAYDJXN.js} +2 -2
  79. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +2 -0
  80. package/dist/assets/{vendor-codemirror-state-CNWM3Q8V.js → vendor-codemirror-state-C9awkmn-.js} +5 -5
  81. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +4 -0
  82. package/dist/assets/vendor-replit-codemirror-vim-B2DJlAhT.js +6 -0
  83. package/dist/assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js +34 -0
  84. package/dist/assets/vendor-zod-adaMkgkm.js +39 -0
  85. package/dist/assets/{web-components-BL-Ur2Tb.js → web-components-DCLjCO9n.js} +1 -1
  86. package/dist/assets/zh-CN-DkeP5awK.js +15 -0
  87. package/dist/assets/zh-TW-BocaFm3d.js +15 -0
  88. package/dist/index.html +4 -4
  89. package/dist/mini-chat.html +3 -3
  90. package/dist/mobile.html +3 -3
  91. package/package.json +1 -1
  92. package/server/index.js +116 -3
  93. package/server/lib/agent-memory/actions.js +243 -0
  94. package/server/lib/agent-memory/actions.test.js +343 -0
  95. package/server/lib/agent-memory/feature-flag.js +19 -0
  96. package/server/lib/agent-memory/feature-flag.test.js +38 -0
  97. package/server/lib/agent-memory/project-resolution.js +56 -0
  98. package/server/lib/agent-memory/project-resolution.test.js +85 -0
  99. package/server/lib/agent-memory/routes.http.test.js +270 -0
  100. package/server/lib/agent-memory/routes.js +169 -0
  101. package/server/lib/agent-memory/runtime.js +427 -0
  102. package/server/lib/agent-memory/runtime.test.js +344 -0
  103. package/server/lib/agent-memory/threat-patterns.js +61 -0
  104. package/server/lib/agent-memory/threat-patterns.test.js +61 -0
  105. package/server/lib/agent-tool/DOCUMENTATION.md +14 -0
  106. package/server/lib/agent-tool/runtime.js +63 -13
  107. package/server/lib/agent-tool/runtime.test.js +85 -2
  108. package/server/lib/context-obligatory/runtime.js +34 -3
  109. package/server/lib/context-obligatory/runtime.test.js +114 -0
  110. package/server/lib/dev-tunnel/client.js +20 -1
  111. package/server/lib/dev-tunnel/tunnel.test.js +9 -0
  112. package/server/lib/fs/DOCUMENTATION.md +3 -0
  113. package/server/lib/fs/routes.js +149 -32
  114. package/server/lib/fs/routes.test.js +225 -0
  115. package/server/lib/git/DOCUMENTATION.md +8 -0
  116. package/server/lib/git/service.js +121 -67
  117. package/server/lib/git/service.test.js +129 -0
  118. package/server/lib/github/DOCUMENTATION.md +14 -3
  119. package/server/lib/github/pr-status.js +188 -83
  120. package/server/lib/github/pr-status.test.js +182 -0
  121. package/server/lib/github/routes.js +36 -30
  122. package/server/lib/markdown-image-grants/DOCUMENTATION.md +36 -0
  123. package/server/lib/markdown-image-grants/routes.js +340 -0
  124. package/server/lib/markdown-image-grants/routes.test.js +221 -0
  125. package/server/lib/notifications/template-runtime.js +2 -3
  126. package/server/lib/openchamber-control/action-resolution.test.js +65 -0
  127. package/server/lib/openchamber-control/actions.js +78 -0
  128. package/server/lib/openchamber-control/service.js +7 -0
  129. package/server/lib/openchamber-sessions/routes.js +14 -0
  130. package/server/lib/opencode/DOCUMENTATION.md +6 -4
  131. package/server/lib/opencode/claude-cli-auth.js +60 -0
  132. package/server/lib/opencode/claude-cli-auth.test.js +54 -0
  133. package/server/lib/opencode/feature-routes-runtime.js +22 -0
  134. package/server/lib/opencode/plugins.js +12 -3
  135. package/server/lib/opencode/plugins.test.js +18 -0
  136. package/server/lib/opencode/proxy-agent-wiring.test.js +152 -0
  137. package/server/lib/opencode/proxy.js +116 -6
  138. package/server/lib/opencode/proxy.test.js +158 -1
  139. package/server/lib/opencode/routes.js +4 -1
  140. package/server/lib/opencode/server-startup-runtime.js +22 -1
  141. package/server/lib/opencode/server-startup-runtime.test.js +44 -0
  142. package/server/lib/opencode/settings-helpers.js +11 -0
  143. package/server/lib/opencode/settings-helpers.test.js +35 -0
  144. package/server/lib/opencode/settings-runtime.js +51 -0
  145. package/server/lib/opencode/shared.js +120 -16
  146. package/server/lib/opencode/shared.test.js +185 -1
  147. package/server/lib/project-context/DOCUMENTATION.md +158 -0
  148. package/server/lib/project-context/routes.http.test.js +264 -0
  149. package/server/lib/project-context/routes.js +237 -0
  150. package/server/lib/project-context/runtime.js +667 -0
  151. package/server/lib/project-context/runtime.test.js +498 -0
  152. package/server/lib/quota/DOCUMENTATION.md +16 -1
  153. package/server/lib/quota/providers/claude/auth.js +113 -0
  154. package/server/lib/quota/providers/claude/auth.test.js +117 -0
  155. package/server/lib/quota/providers/claude/index.js +151 -0
  156. package/server/lib/quota/providers/claude/index.test.js +147 -0
  157. package/server/lib/quota/providers/claude/transforms.js +127 -0
  158. package/server/lib/quota/providers/claude/transforms.test.js +82 -0
  159. package/server/lib/quota/providers/command-code.js +90 -0
  160. package/server/lib/quota/providers/command-code.test.js +72 -0
  161. package/server/lib/quota/providers/index.js +22 -2
  162. package/server/lib/quota/providers/index.test.js +10 -1
  163. package/server/lib/quota/utils/formatters.js +2 -1
  164. package/server/lib/scheduled-tasks/runtime.js +21 -2
  165. package/server/lib/session-knowledge/DOCUMENTATION.md +87 -0
  166. package/server/lib/session-knowledge/routes.js +107 -0
  167. package/server/lib/session-knowledge/runtime.js +331 -0
  168. package/server/lib/session-knowledge/runtime.test.js +275 -0
  169. package/server/lib/skills-catalog/DOCUMENTATION.md +22 -22
  170. package/server/lib/skills-catalog/curated-sources.js +1 -1
  171. package/server/lib/skills-catalog/curated-sources.test.js +10 -0
  172. package/server/lib/small-model/index.js +8 -0
  173. package/server/lib/small-model/index.test.js +31 -1
  174. package/server/lib/small-model/routes.js +3 -1
  175. package/dist/assets/DiagramView-CndEcZNu.js +0 -1
  176. package/dist/assets/FilesView-CzUgIvUm.js +0 -14
  177. package/dist/assets/MarkdownImageGallery-DzHwkVIH.js +0 -1
  178. package/dist/assets/MarkdownRendererImpl-DUcIcWgs.js +0 -12
  179. package/dist/assets/OnboardingScreen-BmN0lhk4.js +0 -1
  180. package/dist/assets/PlanView-CWM0iyFk.js +0 -4
  181. package/dist/assets/SessionSwitcherDropdown-Cez-9xRh.js +0 -1
  182. package/dist/assets/SettingsView-Bl1drwPw.js +0 -28
  183. package/dist/assets/SettingsWindow-DL5axjDZ.js +0 -1
  184. package/dist/assets/contextPanelEmbeddedChat-tQekJUAF.js +0 -1
  185. package/dist/assets/de-u7gSnqWs.js +0 -9
  186. package/dist/assets/document-attachments-CX_YaDsu.js +0 -30
  187. package/dist/assets/es-T9O7aAOr.js +0 -15
  188. package/dist/assets/fr-Oor7ewbE.js +0 -13
  189. package/dist/assets/index-CVNuER6G.css +0 -1
  190. package/dist/assets/index-Crz1YOFl.js +0 -1
  191. package/dist/assets/index-iFY_N5aO.js +0 -7
  192. package/dist/assets/ja-DHpqbVmr.js +0 -15
  193. package/dist/assets/ko-CwLkS3nx.js +0 -15
  194. package/dist/assets/main-CAxX6DAN.js +0 -915
  195. package/dist/assets/markdownCore-DhfzuGXu.js +0 -2
  196. package/dist/assets/markdownImageAssets-BTNlRyjd.js +0 -1
  197. package/dist/assets/mobile-DEmhwNcV.js +0 -2
  198. package/dist/assets/pl-CcZILN8q.js +0 -15
  199. package/dist/assets/pt-BR-DYHhVK6o.js +0 -15
  200. package/dist/assets/renderElectronMiniChatApp-Dpbswpom.js +0 -2
  201. package/dist/assets/runtimeEndpointReset-cbahJ3hD.js +0 -13
  202. package/dist/assets/scheduledTasksApi-BxgGWTL8.js +0 -1
  203. package/dist/assets/uk-BA2kZR38.js +0 -15
  204. package/dist/assets/vendor-codemirror-autocomplete-BjbBRsUA.js +0 -1
  205. package/dist/assets/vendor-codemirror-commands-ARAOgp1x.js +0 -1
  206. package/dist/assets/vendor-codemirror-lang-html-B3Qe3OpS.js +0 -1
  207. package/dist/assets/vendor-codemirror-lang-javascript-Bbw3D7r0.js +0 -13
  208. package/dist/assets/vendor-codemirror-lang-markdown-FGQydhTc.js +0 -1
  209. package/dist/assets/vendor-codemirror-language-DUOssd4j.js +0 -3
  210. package/dist/assets/vendor-codemirror-search-8kyQdB3f.js +0 -2
  211. package/dist/assets/vendor-codemirror-view-DSzLbZiS.js +0 -4
  212. package/dist/assets/vendor-replit-codemirror-vim-B0Ecqnlh.js +0 -39
  213. package/dist/assets/zh-CN-dlOQK6v9.js +0 -15
  214. package/dist/assets/zh-TW-BnqQ-WL5.js +0 -15
  215. package/server/lib/quota/providers/claude.js +0 -107
@@ -0,0 +1,14 @@
1
+ import{R as n,j as s,f as Gt}from"./vendor-react-BUCujlKS.js";import{Q as Kn,R as Hn,S as qn,T as _n,ai as vi,n as ze,u as he,cT as Xn,B as wi,v as Jn,r as bi,V as yi,e as Qn,cR as Yn,aH as Zn,cS as ea,a as ta}from"./index-DzriVon2.js";import{f as Ds,S as Ts,B as S,h as O,V as sa,L as ra,aV as ia,a0 as na,a1 as aa,b_ as oa,gX as ji,gs as la,t as I,l as Fi,aa as sr,bV as Fs,cq as ca,b as da,gY as rr,ab as Ni,gZ as Ci,bW as Si,bX as ua,fO as fa,g_ as ma,br as ha,g$ as pa,bs as Ii,bt as Oi,bu as Bi,bv as $i,bw as Wi,bx as Ui,I as g,aU as cr,aR as dr,ad as Cs,aT as ur,aQ as Ss,aX as ht,aY as pt,aZ as gt,bU as ir,ac as nr,bQ as ki,by as ga,bz as xa,gq as ar,g as Vs,aS as va,a_ as wa}from"./useAppFontEffects-CbzHzFop.js";import{w as ba,x as ya,y as ja,z as Fa,A as Na}from"./runtimeEndpointReset-BMBRhIbf.js";import{c as Ti,s as Ca,C as Vi,P as or}from"./shikiHighlight-DXYW46vW.js";import{a as Sa}from"./vendor-codemirror-state-C9awkmn-.js";import{E as kt}from"./vendor-codemirror-view-CiLROUVV.js";import{F as ka,J as Ta}from"./JsonTreeView-h4dHASlq.js";import{ensurePierreThemeRegistered as Di,getResolvedShikiTheme as Va}from"./appThemeRegistry-BK0dHKa6.js";import{u as Ns,c as Da,e as Ea}from"./scheduledTasksApi-01zzfzqH.js";import{D as Ra}from"./DiagramEditor-B9NCadU7.js";import{u as Pa,n as Ma}from"./useInlineCommentController-CegKdDXi.js";import{b as za}from"./CodeMirrorCommentWidgets-DAvopJvy.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BYlZTzrw.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-BO1wRpaN.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CiAYDJXN.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CRSgBxjL.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-zod-adaMkgkm.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-DCLjCO9n.js";import"./computeVirtualFileMetrics-DYFv_yZS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-X_7XPoTH.js";import"./isFilePlainText-Dwq6ILxo.js";import"./registerCustomTheme-BBXUCRnG.js";import"./vendor-react-drawio-Ct3Q0DsD.js";const La=(d,e)=>{if(!e)return null;const r=Number.parseInt(d.trim(),10);return!Number.isFinite(r)||r<1?null:Math.min(r,e.state.doc.lines)},Ei=(d,e)=>{const r=d.state.doc.lineAt(e.main.head);return{lineNumber:r.number,character:e.main.head-r.from+1,selection:e}},Ri=(d,e,r)=>{const m=d.state.doc.line(e),x=Math.max(1,Math.min(r,m.length+1)),v=m.from+x-1;d.dispatch({selection:Sa.cursor(v),effects:kt.scrollIntoView(v,{y:"center"})})};function Aa({open:d,onOpenChange:e,view:r,variant:m="overlay"}){const{t:x}=Ds(),[v,y]=n.useState(""),b=n.useRef(null),h=n.useRef(!1),j=n.useRef(null),p=n.useRef(null),F=n.useMemo(()=>La(v,r),[v,r]);n.useEffect(()=>{!d||!r||(h.current=!1,b.current=Ei(r,r.state.selection),y(""))},[d,r]),n.useEffect(()=>{d&&window.requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},[d]),n.useEffect(()=>{if(!(!d||!r||!b.current)){if(F===null){const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})});return}Ri(r,F,b.current.character)}},[F,d,r]);const z=n.useCallback(()=>{if(!r||h.current||!b.current)return;const{selection:o}=b.current;r.dispatch({selection:o,effects:kt.scrollIntoView(o.main.from,{y:"center"})})},[r]),E=n.useCallback(o=>{o||z(),e(o)},[e,z]),N=n.useCallback(()=>{!r||F===null||!b.current||(h.current=!0,Ri(r,F,b.current.character),e(!1),r.focus())},[F,e,r]);n.useEffect(()=>{if(!d)return;const o=W=>{const _=j.current,L=W.target;!_||!(L instanceof Node)||_.contains(L)||E(!1)},q=W=>{W.key==="Escape"&&(W.preventDefault(),E(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",q,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",q,!0)}},[E,d,m]);const R=n.useMemo(()=>{if(!r)return x("goToLineDialog.helper.editorUnavailable");if(F===null){const o=b.current??Ei(r,r.state.selection);return x("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:r.state.doc.lines})}return x("goToLineDialog.helper.goToLine",{line:F})},[F,x,r]);return m==="inline"?d?s.jsxs("div",{ref:j,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(S,{variant:"outline",size:"xs",onClick:N,disabled:!r||F===null,className:"h-6 px-2",children:x("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:j,className:O("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",d?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(Ts,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:v,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),N())},placeholder:x("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:R})]})})}function Ia(d){return!(!d.autoSaveEnabled||!d.isDirty||!d.canWrite||d.isSaving||d.fileLoading||d.isNonEditableBinary||!d.selectedFilePath||d.loadedFilePath!==d.selectedFilePath)}function Oa(d){return d.selectedFilePath?d.isDirty?!(d.fileLoading||d.loadedFilePath!==d.selectedFilePath||d.isNonEditableBinary||d.draftContent===""&&d.fileContent!==""&&d.loadedFilePath!==d.selectedFilePath):!0:!1}const Ba=d=>{const e=M(d);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const r=e.lastIndexOf("/");if(r<0)return e;if(r===0)return"/";const m=e.slice(0,r);return/^[A-Za-z]:$/.test(m)?`${m}/`:m},$a=d=>{const e=Gt.c(8),{label:r,iconDataUrl:m}=d,[x,v]=n.useState(!1);let y;e[0]!==r?(y=r.trim().slice(0,1).toUpperCase()||"?",e[0]=r,e[1]=y):y=e[1];const b=y;if(m&&!x){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>v(!0),e[2]=p):p=e[2];let F;return e[3]!==m?(F=s.jsx("img",{src:m,alt:"",className:"size-4 rounded-sm",onError:p}),e[3]=m,e[4]=F):F=e[4],F}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=O("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let j;return e[6]!==b?(j=s.jsx("span",{className:h,children:b}),e[6]=b,e[7]=j):j=e[7],j},Wa=d=>d.slice().sort((e,r)=>e.type!==r.type?e.type==="directory"?-1:1:e.name.localeCompare(r.name)),M=d=>{if(!d)return"";const e=d.replace(/\\/g,"/"),r=e.startsWith("//");let m=e.replace(/\/+/g,"/");r&&!m.startsWith("//")&&(m=`/${m}`);const x=m==="/",v=/^[A-Za-z]:\/$/.test(m);return!x&&!v&&(m=m.replace(/\/+$/,"")),m},Ua=d=>d.startsWith("/")||d.startsWith("//")||/^[A-Za-z]:\//.test(d),Ut=d=>/^[A-Za-z]:\//.test(d)?d.toLowerCase():d,is=(d,e)=>{const r=M(e),m=M(d);if(!r||!m)return!1;const x=Ut(r),v=Ut(m);return v===x||v.startsWith(`${x}/`)},Pi=(d,e)=>{const r=M(e),m=M(d);if(!is(m,r))return[];const v=m.slice(r.length).replace(/^\//,"").split("/"),y=[];let b=r;for(let h=0;h<v.length-1;h++)b=b?`${b}/${v[h]}`:v[h],y.push(b);return y},ks=(d,e)=>{if(!e)return"";const r=M(e);if(!d||!is(r,d))return r;const m=r.slice(d.length);return m.startsWith("/")?m.slice(1):m},Ga=new Set(["node_modules"]),Ka=d=>{const e=Gt.c(3),{status:r}=d;let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=m):m=e[0];const x=m[r];let v;return e[1]!==x?(v=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:x}}),e[1]=x,e[2]=v):v=e[2],v},Mi=d=>{const e=Gt.c(11),{name:r}=d,m=n.useRef(null),x=n.useRef(null),[v,y]=n.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const z=m.current,E=x.current;if(!z||!E)return;const N=()=>{y(E.scrollWidth>z.clientWidth+1)};N();const R=new ResizeObserver(N);return R.observe(z),R.observe(E),()=>{R.disconnect()}},e[0]=b):b=e[0];let h;e[1]!==r?(h=[r],e[1]=r,e[2]=h):h=e[2],n.useLayoutEffect(b,h);let j;e[3]!==r?(j=s.jsx("span",{ref:x,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:r}),e[3]=r,e[4]=j):j=e[4];let p;e[5]!==r||e[6]!==v?(p=v?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:r}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:r})]}):s.jsx("span",{className:"block min-w-0 truncate",children:r}),e[5]=r,e[6]=v,e[7]=p):p=e[7];let F;return e[8]!==j||e[9]!==p?(F=s.jsxs("span",{ref:m,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[j,p]}),e[8]=j,e[9]=p,e[10]=F):F=e[10],F},Ha=d=>Ga.has(d),qa=d=>{const e=M(d);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},_a=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("is a directory")||r.includes("eisdir")},zi=d=>{const r=(d instanceof Error?d.message:String(d??"")).toLowerCase();return r.includes("file not found")||r.includes("enoent")||r.includes("no such file")||r.includes("does not exist")},rs=2e5,Xa=d=>{let e=0,r=0;for(let m=0;m<d.length;m+=1)d.charCodeAt(m)===10&&(m>0&&d.charCodeAt(m-1)===13?e+=1:r+=1);return e>r?`\r
2
+ `:`
3
+ `},Gi=d=>d.replace(/\r\n/g,`
4
+ `).replace(/\r/g,`
5
+ `),Ja=(d,e)=>{const r=Gi(d);return e===`\r
6
+ `?r.replace(/\n/g,`\r
7
+ `):r},Ki=(d,e)=>s.jsx(Cs,{filePath:d,extension:e}),Li=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Qa=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},lr=d=>{if(!d)return!1;const e=d.toLowerCase().split(".").pop();return e==="html"||e==="htm"},Ya=d=>{const e=Gt.c(76),{node:r,root:m,isExpanded:x,isActive:v,isMobile:y,isBrowserClient:b,alwaysShowActions:h,status:j,badge:p,permissions:F,downloadFile:z,contextMenuPath:E,setContextMenuPath:N,rightClickMenuPath:R,setRightClickMenuPath:o,onSelect:q,onToggle:W,onRevealPath:_,onOpenDialog:L}=d,{t:T}=Ds(),V=r.type==="directory",{canRename:le,canCreateFile:Y,canCreateFolder:Z,canDelete:A,canReveal:ce}=F,Le=!V&&!!z,U=ce&&!b,X=le||Y||Z||A||Le||U;let ee;e[0]!==X||e[1]!==r.path||e[2]!==o?(ee=fe=>{X&&(fe?.preventDefault(),o(r.path))},e[0]=X,e[1]=r.path,e[2]=o,e[3]=ee):ee=e[3];const pe=ee;let te;e[4]!==V||e[5]!==r||e[6]!==q||e[7]!==W?(te=()=>{V?W(r.path):q(r)},e[4]=V,e[5]=r,e[6]=q,e[7]=W,e[8]=te):te=e[8];const ge=te;let de;e[9]!==r.path||e[10]!==N||e[11]!==o?(de=fe=>{fe.stopPropagation(),o(null),N(r.path)},e[9]=r.path,e[10]=N,e[11]=o,e[12]=de):de=e[12];const rt=de;let Tt;e[13]!==Y||e[14]!==Z||e[15]!==A||e[16]!==le||e[17]!==U||e[18]!==z||e[19]!==b||e[20]!==V||e[21]!==r||e[22]!==L||e[23]!==_||e[24]!==m||e[25]!==T?(Tt=fe=>{const{Item:ve,Separator:wt}=fe;return s.jsxs(s.Fragment,{children:[le&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("rename",r)},children:[s.jsx(g,{name:"edit",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),Vs(r.path).then(we=>{if(we.ok){I.success(T("sidebarFilesTree.toast.pathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),s.jsxs(ve,{onClick:C=>{C.stopPropagation();const we=ks(m,r.path)||r.path;Vs(we).then(Je=>{if(Je.ok){I.success(T("filesView.toast.relativePathCopied"));return}I.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(g,{name:"file-copy-2",className:"mr-2 size-4"})," ",T("filesView.tree.menu.copyRelativePath")]}),!V&&z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),z(r.path).catch(we=>{console.error("Download failed:",we),I.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"})," ",T(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),U&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),_(r.path)},children:[s.jsx(g,{name:"folder-received",className:"mr-2 size-4"})," ",T(wa())]}),V&&(Y||Z)&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),Y&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFile",r)},children:[s.jsx(g,{name:"file-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFile")]}),Z&&s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("createFolder",r)},children:[s.jsx(g,{name:"folder-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFolder")]})]}),A&&s.jsxs(s.Fragment,{children:[s.jsx(wt,{}),s.jsxs(ve,{onClick:C=>{C.stopPropagation(),L("delete",r)},className:"text-destructive focus:text-destructive",children:[s.jsx(g,{name:"delete-bin",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[13]=Y,e[14]=Z,e[15]=A,e[16]=le,e[17]=U,e[18]=z,e[19]=b,e[20]=V,e[21]=r,e[22]=L,e[23]=_,e[24]=m,e[25]=T,e[26]=Tt):Tt=e[26];const Xe=Tt,G=R===r.path;let Fe;e[27]!==r.path||e[28]!==o?(Fe=fe=>o(fe?r.path:null),e[27]=r.path,e[28]=o,e[29]=Fe):Fe=e[29];const xt=y?void 0:pe;let Ae;e[30]!==xt?(Ae=s.jsx("div",{className:"group relative flex items-center",onContextMenu:xt}),e[30]=xt,e[31]=Ae):Ae=e[31];const Ie=y?void 0:pe,vt=v?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let xe;e[32]!==vt?(xe=O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",vt),e[32]=vt,e[33]=xe):xe=e[33];let Oe;e[34]!==V||e[35]!==x||e[36]!==r.extension||e[37]!==r.path?(Oe=V?x?s.jsx(g,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(g,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Ki(r.path,r.extension),e[34]=V,e[35]=x,e[36]=r.extension,e[37]=r.path,e[38]=Oe):Oe=e[38];let ue;e[39]!==r.name||e[40]!==r.path?(ue=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:r.path,children:r.name}),e[39]=r.name,e[40]=r.path,e[41]=ue):ue=e[41];let Ne;e[42]!==V||e[43]!==j?(Ne=!V&&j&&s.jsx(Ka,{status:j}),e[42]=V,e[43]=j,e[44]=Ne):Ne=e[44];let it;e[45]!==p||e[46]!==V?(it=V&&p&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[p.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",p.modified]}),p.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",p.added]})]}),e[45]=p,e[46]=V,e[47]=it):it=e[47];let nt;e[48]!==ge||e[49]!==xe||e[50]!==Oe||e[51]!==ue||e[52]!==Ne||e[53]!==it||e[54]!==Ie?(nt=s.jsxs("button",{type:"button",onClick:ge,onContextMenu:Ie,className:xe,children:[Oe,ue,Ne,it]}),e[48]=ge,e[49]=xe,e[50]=Oe,e[51]=ue,e[52]=Ne,e[53]=it,e[54]=Ie,e[55]=nt):nt=e[55];let Be;e[56]!==h||e[57]!==E||e[58]!==rt||e[59]!==X||e[60]!==y||e[61]!==r.path||e[62]!==Xe||e[63]!==N?(Be=X&&s.jsx("div",{className:O("absolute right-1 top-1/2 -translate-y-1/2",h?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(cr,{open:E===r.path,onOpenChange:fe=>N(fe?r.path:null),children:[s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"icon",className:"size-6",onClick:rt,children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})}),s.jsx(ur,{align:"end",side:"bottom",onCloseAutoFocus:()=>N(null),children:Xe({Item:Ss,Separator:va})})]})}),e[56]=h,e[57]=E,e[58]=rt,e[59]=X,e[60]=y,e[61]=r.path,e[62]=Xe,e[63]=N,e[64]=Be):Be=e[64];let $e;e[65]!==nt||e[66]!==Be||e[67]!==Ae?($e=s.jsxs(Fa,{render:Ae,children:[nt,Be]}),e[65]=nt,e[66]=Be,e[67]=Ae,e[68]=$e):$e=e[68];let We;e[69]!==Xe?(We=s.jsx(ba,{className:"min-w-[180px]",children:Xe({Item:ja,Separator:ya})}),e[69]=Xe,e[70]=We):We=e[70];let at;return e[71]!==$e||e[72]!==We||e[73]!==G||e[74]!==Fe?(at=s.jsxs(Na,{open:G,onOpenChange:Fe,children:[$e,We]}),e[71]=$e,e[72]=We,e[73]=G,e[74]=Fe,e[75]=at):at=e[75],at},Za=d=>{const e=Gt.c(83),{activeDialog:r,dialogData:m,dialogInputValue:x,onDialogInputChange:v,isDialogSubmitting:y,onDialogSubmit:b,onClose:h,inputRef:j}=d,{t:p}=Ds(),F=!!r;let z;e[0]!==h?(z=de=>!de&&h(),e[0]=h,e[1]=z):z=e[1];let E;e[2]!==r||e[3]!==p?(E=r==="createFile"&&p("filesView.dialog.createFile.title"),e[2]=r,e[3]=p,e[4]=E):E=e[4];let N;e[5]!==r||e[6]!==p?(N=r==="createFolder"&&p("filesView.dialog.createFolder.title"),e[5]=r,e[6]=p,e[7]=N):N=e[7];let R;e[8]!==r||e[9]!==p?(R=r==="rename"&&p("filesView.dialog.rename.title"),e[8]=r,e[9]=p,e[10]=R):R=e[10];let o;e[11]!==r||e[12]!==p?(o=r==="delete"&&p("filesView.dialog.delete.title"),e[11]=r,e[12]=p,e[13]=o):o=e[13];let q;e[14]!==E||e[15]!==N||e[16]!==R||e[17]!==o?(q=s.jsxs($i,{children:[E,N,R,o]}),e[14]=E,e[15]=N,e[16]=R,e[17]=o,e[18]=q):q=e[18];let W;e[19]!==r||e[20]!==m?.path||e[21]!==p?(W=r==="createFile"&&p("filesView.dialog.createFile.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[19]=r,e[20]=m?.path,e[21]=p,e[22]=W):W=e[22];let _;e[23]!==r||e[24]!==m?.path||e[25]!==p?(_=r==="createFolder"&&p("filesView.dialog.createFolder.description",{path:m?.path??p("filesView.dialog.rootFallback")}),e[23]=r,e[24]=m?.path,e[25]=p,e[26]=_):_=e[26];let L;e[27]!==r||e[28]!==m?.name||e[29]!==p?(L=r==="rename"&&p("filesView.dialog.rename.description",{name:m?.name??""}),e[27]=r,e[28]=m?.name,e[29]=p,e[30]=L):L=e[30];let T;e[31]!==r||e[32]!==m?.name||e[33]!==p?(T=r==="delete"&&p("filesView.dialog.delete.description",{name:m?.name??""}),e[31]=r,e[32]=m?.name,e[33]=p,e[34]=T):T=e[34];let V;e[35]!==L||e[36]!==T||e[37]!==W||e[38]!==_?(V=s.jsxs(Wi,{children:[W,_,L,T]}),e[35]=L,e[36]=T,e[37]=W,e[38]=_,e[39]=V):V=e[39];let le;e[40]!==V||e[41]!==q?(le=s.jsxs(Bi,{children:[q,V]}),e[40]=V,e[41]=q,e[42]=le):le=e[42];let Y;e[43]!==r||e[44]!==x||e[45]!==j||e[46]!==v||e[47]!==b||e[48]!==p?(Y=r!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Ts,{value:x,onChange:de=>v(de.target.value),placeholder:p(r==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:de=>{de.key==="Enter"&&b()},ref:j})}),e[43]=r,e[44]=x,e[45]=j,e[46]=v,e[47]=b,e[48]=p,e[49]=Y):Y=e[49];let Z;e[50]!==p?(Z=p("filesView.dialog.cancel"),e[50]=p,e[51]=Z):Z=e[51];let A;e[52]!==y||e[53]!==h||e[54]!==Z?(A=s.jsx(S,{variant:"outline",onClick:h,disabled:y,children:Z}),e[52]=y,e[53]=h,e[54]=Z,e[55]=A):A=e[55];const ce=r==="delete"?"destructive":"default";let Le;e[56]!==b?(Le=()=>{b()},e[56]=b,e[57]=Le):Le=e[57];let U;e[58]!==r||e[59]!==x||e[60]!==y?(U=y||r!=="delete"&&!x.trim(),e[58]=r,e[59]=x,e[60]=y,e[61]=U):U=e[61];let X;e[62]!==r||e[63]!==y||e[64]!==p?(X=y?s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}):p(r==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=r,e[63]=y,e[64]=p,e[65]=X):X=e[65];let ee;e[66]!==ce||e[67]!==Le||e[68]!==U||e[69]!==X?(ee=s.jsx(S,{variant:ce,onClick:Le,disabled:U,children:X}),e[66]=ce,e[67]=Le,e[68]=U,e[69]=X,e[70]=ee):ee=e[70];let pe;e[71]!==A||e[72]!==ee?(pe=s.jsxs(Ui,{children:[A,ee]}),e[71]=A,e[72]=ee,e[73]=pe):pe=e[73];let te;e[74]!==j||e[75]!==le||e[76]!==Y||e[77]!==pe?(te=s.jsxs(Oi,{initialFocus:j,children:[le,Y,pe]}),e[74]=j,e[75]=le,e[76]=Y,e[77]=pe,e[78]=te):te=e[78];let ge;return e[79]!==F||e[80]!==z||e[81]!==te?(ge=s.jsx(Ii,{open:F,onOpenChange:z,children:te}),e[79]=F,e[80]=z,e[81]=te,e[82]=ge):ge=e[82],ge},Ai=(d,e,r)=>{const m=Gt.c(8),[x,v]=n.useState(""),[y,b]=n.useState(0);let h,j;m[0]!==d||m[1]!==r||m[2]!==e?(h=()=>{if(!d){v("");return}let F=!1;v("");const z=Qn(),E=Yn(z);Zn(z).then(R=>{F||!R||(v(d),e(null))}).catch(R=>{F||(e(R instanceof Error?R.message:r),v(d))});const N=ea(()=>{F||(v(d),b(eo),e(null))});return()=>{F=!0,E(),N()}},j=[d,e,r],m[0]=d,m[1]=r,m[2]=e,m[3]=h,m[4]=j):(h=m[3],j=m[4]),n.useEffect(h,j);let p;return m[5]!==y||m[6]!==x?(p={readyKey:x,nonce:y},m[5]=y,m[6]=x,m[7]=p):p=m[7],p},wc=({mode:d="full"})=>{const{t:e}=Ds(),{files:r,runtime:m}=sa(),{currentTheme:x,availableThemes:v,lightThemeId:y,darkThemeId:b}=ra(),{isMobile:h,isTablet:j,screenWidth:p}=ia(),F=Kn(m.platform),z=h||j,E=Hn(),N=qn(),R=na()??"",o=M(R.trim()),q=d!=="editor-only",W=d==="editor-only"&&!h,_=_n(t=>t.searchFiles),L=aa(R),[T,V]=n.useState(""),le=oa(T,200),Y=n.useRef(null),[Z,A]=n.useState(!1),[ce,Le]=n.useState(!0),[U,X]=n.useState(!1),[ee,pe]=n.useState(!1),[te,ge]=n.useState(!1),de=n.useRef(null),rt=n.useRef(0),Tt=n.useCallback(t=>{rt.current=Math.max(0,rt.current+(t?1:-1))},[]),Xe=n.useCallback(t=>t instanceof Element?t.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);n.useEffect(()=>{if(!te)return;const t=i=>{rt.current>0||Xe(i.target)||de.current&&!de.current.contains(i.target)&&ge(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[Xe,te]);const[G,Fe]=n.useState("edit"),[xt,Ae]=n.useState("edit"),[Ie,vt]=n.useState("tree"),[xe,Oe]=n.useState("edit"),[ue,Ne]=n.useState("preview"),[it,nt]=n.useState(0),Be=n.useRef({}),$e=n.useRef({}),We=n.useRef({}),at=n.useRef({}),fe=n.useMemo(()=>v.find(t=>t.metadata.id===y)??vi(!1),[v,y]),ve=n.useMemo(()=>v.find(t=>t.metadata.id===b)??vi(!0),[v,b]);n.useEffect(()=>{Di(fe),Di(ve)},[fe,ve]);const wt=n.useMemo(()=>[],[]),C=ze(t=>o?t.byRoot[o]?.openPaths??wt:wt),we=ze(t=>o?t.byRoot[o]?.selectedPath??null:null),Je=ze(t=>o?t.byRoot[o]?.expandedPaths??wt:wt),Vt=ze(t=>t.removeOpenPath),ot=ze(t=>t.removeOpenPathsByPrefix),fr=ze(t=>t.removeExpandedPathsByPrefix),se=ze(t=>t.setSelectedPath),mr=ze(t=>t.toggleExpandedPath),ns=ze(t=>t.expandPaths),Dt=n.useCallback(t=>{const i=M(t),a=i.split("/"),c=a[a.length-1]||i,u=c.includes(".")?c.split(".").pop()?.toLowerCase():void 0;return{name:c,path:i,type:"file",extension:u}},[]),Et=n.useMemo(()=>C.map(Dt),[C,Dt]),Es=n.useMemo(()=>{if(we){const t=Ut(we);if(C.some(i=>Ut(i)===t))return we}return C[0]??null},[C,we]),l=n.useMemo(()=>Es?Dt(Es):null,[Es,Dt]),Ue=l?.path??"";n.useEffect(()=>{if(!o||!we)return;const t=Ut(we);C.some(a=>Ut(a)===t)||se(o,C[0]??null)},[C,o,we,se]);const as=!!(o&&Ue&&!is(Ue,o)),hr=as?ji(Ue):void 0,Ce=n.useMemo(()=>({allowOutsideWorkspace:d==="editor-only"&&as,outsideFileGrant:hr,directory:o||void 0}),[d,as,hr,o]),Rs=n.useRef(null),[pr,Hi]=n.useState({left:!1,right:!1}),gr=n.useCallback(()=>{const t=Rs.current;t&&Hi({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),xr=n.useRef(gr);xr.current=gr,n.useEffect(()=>{const t=Rs.current;if(!t)return;const i=()=>xr.current();i(),t.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(t),()=>{t.removeEventListener("scroll",i),a.disconnect()}},[Et.length]);const[vr,Ps]=n.useState({}),[os,Kt]=n.useState({}),Se=n.useRef(new Set),ke=n.useRef(new Set),Qe=n.useRef(new Map),wr=n.useRef(0),[br,ls]=n.useState([]),[qi,cs]=n.useState(!1),[k,H]=n.useState(""),{isPlaying:ds,play:_i,stop:Xi}=la(),[Re,Ye]=n.useState(!1),[Ze,J]=n.useState(null),[Ji,Te]=n.useState(""),[be,K]=n.useState(null),[B,Q]=n.useState(""),[Rt,Ms]=n.useState(!1),[yr,Qi]=n.useState(`
8
+ `),Yi=n.useRef(null),Ge=n.useRef(null),ye=n.useRef(null),lt=n.useRef(""),Ht=n.useRef(""),et=n.useRef(null),jr=n.useRef(null),Ke=n.useRef(null),qt=n.useRef(0),Pt=n.useRef(null),[us,Zi]=n.useState(0),[en,Mt]=n.useState("idle"),[tn,fs]=n.useState(!1),[_t,Fr]=n.useState(!1),re=he(t=>t.autoSaveEnabled),sn=he(t=>t.setAutoSaveEnabled),[zs,zt]=n.useState(!1),Lt=n.useRef(null),Xt=n.useRef(null),Jt=n.useRef(null),bt=n.useRef(!1),Qt=n.useRef(null),Yt=n.useRef(null),Pe=n.useRef(null),rn=n.useRef(null),[nn,Ls]=n.useState(0),At=n.useRef(null),yt=n.useRef({key:"",attempts:0});n.useEffect(()=>()=>{At.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(At.current),At.current=null)},[]);const[jt,As]=n.useState(null),[Ft,an]=n.useState(null),[ct,Nr]=n.useState(""),[on,Is]=n.useState(!1),[ln,cn]=n.useState(null),[dn,un]=n.useState(null),[fn,Cr]=n.useState(!1),[mn,Sr]=n.useState(!1),[hn,Os]=n.useState(!1),kr=!!r.writeFile,Tr=!!r.createDirectory,Vr=!!r.rename,Dr=!!r.delete,Er=!!r.revealPath,pn=Ns(t=>t.availableApps),gn=Ns(t=>t.isCacheStale),Rr=Ns(t=>t.initialize),xn=Ns(t=>t.loadInstalledApps);n.useEffect(()=>{Rr()},[Rr]);const vn=n.useCallback(t=>{r.revealPath&&r.revealPath(t).catch(()=>{I.error(e("sidebarFilesTree.toast.revealFailed"))})},[r,e]),wn=n.useCallback(async t=>{if(!l?.path||await Xn(l.path,t.id,t.appName)||await wi(l.path,t.appName))return;const c=Ba(l.path)||o;c&&await wi(c,t.appName)||I.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,l?.path,e]),Bs=n.useCallback((t,i)=>{As(t),an(i),Nr(t==="rename"&&i.name||""),Is(!1)},[]),[P,Me]=n.useState(null),It=n.useRef(!1),dt=n.useRef(null),[Pr,Ot]=n.useState(!1),He=he(t=>t.setMainTabGuard),qe=he(t=>t.pendingFileNavigation),ms=he(t=>t.setPendingFileNavigation),$s=he(t=>t.pendingFileFocusPath),Ws=he(t=>t.setPendingFileFocusPath),Mr=he(t=>t.shortcutOverrides),zr=he(t=>t.fileEditorKeymap),Zt=Fi(t=>t.settingsDefaultFileViewerPreview),bn=Fi(t=>t.showMessageTTSButtons),Lr=he(t=>t.expandedEditorToolbar);n.useEffect(()=>{const t=()=>{It.current=!1,dt.current=null,Ot(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),n.useEffect(()=>()=>{Qt.current!==null&&window.clearTimeout(Qt.current),Yt.current!==null&&window.clearTimeout(Yt.current)},[]);const yn=n.useCallback((t,i)=>{const a=t.split(`
9
+ `),c=Math.max(1,i.start),u=Math.min(a.length,i.end);return c>u?"":a.slice(c-1,u).join(`
10
+ `)},[]),jn=Pa({source:"file",fileLabel:l?.path??null,language:l?.path&&sr(l.path)||"text",getCodeForRange:t=>yn(k,Ma(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:Ar,commentText:hs,setCommentText:Ir,editingDraftId:ps,setSelection:Or,saveComment:Br,cancel:es,reset:$r,startEdit:Wr,deleteDraft:Ur}=jn;n.useEffect(()=>{Me(null),$r(),He(null),Q(""),Ms(!1)},[l?.path,$r,He]),n.useEffect(()=>{Or(P)},[P,Or]),n.useEffect(()=>{if(!P&&!ps)return;const t=a=>{const c=a.target;c.closest('[data-comment-input="true"]')||c.closest('[data-comment-card="true"]')||c.closest(".cm-gutterElement")||c.closest("[data-sonner-toast]")||c.closest("[data-sonner-toaster]")||hs.trim()||(Me(null),es())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[es,hs,ps,P]);const Gr=n.useCallback((t,i)=>{const a=i??P??void 0;i&&Me(i),Br(t,a),Me(null)},[P,Br]),Kr=n.useCallback((t,i)=>{const a=[];for(const c of i){if(!(c&&typeof c.name=="string"&&c.name.length>0)||!E&&c.name.startsWith(".")||!N&&Ha(c.name))continue;const u=c.name,f=M(c.path||""),w=f?Ua(f)?f:M(`${t}/${f}`):M(`${t}/${u}`),D=c.isDirectory?"directory":"file",$=D==="file"&&u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;a.push({name:u,path:w,type:D,extension:$})}return Wa(a)},[N,E]),Ve=n.useCallback(async t=>{const i=M(t.trim());if(!i||Se.current.has(i)||ke.current.has(i))return;ke.current=new Set(ke.current),ke.current.add(i);const a=wr.current+1;wr.current=a,Qe.current=new Map(Qe.current),Qe.current.set(i,a);const c=()=>Qe.current.get(i)===a;await(r.listDirectory?r.listDirectory(i).then(f=>f.entries.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory}))):Jn.listLocalDirectory(i).then(f=>f.map(w=>({name:w.name,path:w.path,isDirectory:w.isDirectory})))).then(f=>{if(!c())return;const w=Kr(i,f);Se.current=new Set(Se.current),Se.current.add(i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$}),Ps(D=>({...D,[i]:w}))}).catch(f=>{if(!c())return;const w=f instanceof Error?f.message:String(f??"");if(w==="Directory not found"&&o&&i!==o){fr(o,i),Kt(D=>{if(!D[i])return D;const $={...D};return delete $[i],$});return}console.error("Failed to load files directory:",f),Kt(D=>({...D,[i]:w}))}).finally(()=>{c()&&(Qe.current=new Map(Qe.current),Qe.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i))})},[r,Kr,fr,o]),gs=n.useCallback(async()=>{o&&(Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(t=>Object.keys(t).length===0?t:{}),await Ve(o))},[Ve,o]),_e=n.useCallback(async t=>{if(!t){await gs();return}const i=M(t);Se.current=new Set(Se.current),Se.current.delete(i),ke.current=new Set(ke.current),ke.current.delete(i),await Ve(i)},[Ve,gs]),Hr=n.useRef(""),qr=n.useRef("");n.useEffect(()=>{if(!o)return;const t=`${o}|h${E?"1":"0"}|g${N?"1":"0"}`,i=Hr.current!==o,a=qr.current!==t;!i&&!a||(i&&(Hr.current=o,H(""),J(null),Te(""),K(null),A(!1)),a&&(qr.current=t,Se.current=new Set,ke.current=new Set,Qe.current=new Map,Kt({}),Ps(c=>Object.keys(c).length===0?c:{}),Ve(o)))},[Ve,o,N,E]),n.useEffect(()=>{if(!r.listDirectory)return;const t=()=>{if(!document.hidden&&Je.length>0)for(const i of Je)_e(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[Je,r.listDirectory,_e]),n.useEffect(()=>{if(!r.listDirectory||Je.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of Je)_e(i)},8e3);return()=>clearInterval(t)},[Je,r.listDirectory,_e]);const Fn=n.useCallback(async t=>{if(t?.preventDefault(),!Ft||!jt)return;Is(!0);const i=()=>{As(null)},a=u=>{I.error(u)},c=()=>{Is(!1)};if(jt==="createFile"){if(!ct.trim()){a(e("sidebarFilesTree.toast.filenameRequired")),c();return}if(!r.writeFile){a(e("sidebarFilesTree.toast.writeNotSupported")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.writeFile(w,"").then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.fileCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="createFolder"){if(!ct.trim()){a(e("sidebarFilesTree.toast.folderNameRequired")),c();return}const u=Ft.path,f=u?`${u}/`:"",w=M(`${f}${ct.trim()}`);await r.createDirectory(w).then(async D=>{D.success&&(I.success(e("sidebarFilesTree.toast.folderCreated")),await _e(u)),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="rename"){if(!ct.trim()){a(e("sidebarFilesTree.toast.nameRequired")),c();return}if(!r.rename){a(e("sidebarFilesTree.toast.renameNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/"),w=f?`${f}/`:"",D=M(`${w}${ct.trim()}`);await r.rename(u,D).then(async $=>{$.success&&(I.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}if(jt==="delete"){if(!r.delete){a(e("sidebarFilesTree.toast.deleteNotSupported")),c();return}const u=Ft.path,f=u.split("/").slice(0,-1).join("/");await r.delete(u).then(async w=>{w.success&&(I.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await _e(f),o&&ot(o,u),(l?.path===u||l?.path.startsWith(`${u}/`))&&(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1))),i()}).catch(()=>a(e("sidebarFilesTree.toast.operationFailed"))).finally(c);return}c()},[jt,Ft,ct,r,_e,h,ot,o,l?.path,se,e]);n.useEffect(()=>{if(!R){ls([]),cs(!1);return}const t=le.trim();if(!t){ls([]),cs(!1);return}let i=!1;return cs(!0),_(R,t,150,{includeHidden:E,respectGitignore:!N,type:"file"}).then(a=>{if(i)return;const u=a.filter(f=>N||!qa(f.path)).map(f=>({name:f.name,path:M(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));ls(u)}).catch(()=>{i||ls([])}).finally(()=>{i||cs(!1)}),()=>{i=!0}},[R,le,_,E,N]);const _r=n.useCallback(async(t,i)=>{if(r.readFile)return(await r.readFile(t,{...i??{},directory:o||void 0})).content??"";const a=new URLSearchParams({path:t});i?.allowOutsideWorkspace&&a.set("allowOutsideWorkspace","true"),i?.outsideFileGrant&&a.set("outsideFileGrant",i.outsideFileGrant),i?.optional&&a.set("optional","true"),o&&a.set("directory",o);const c=await bi(`/api/fs/read?${a.toString()}`,{cache:i?.optional?"no-store":"default"});if(!c.ok){const u=await c.json().catch(()=>({error:c.statusText}));throw new Error(u.error||e("filesView.error.readFileFailed"))}return c.text()},[r,o,e]),ut=n.useCallback(async(t,i)=>{if(r.statFile){const a=await r.statFile(t,{...i??{},directory:o||void 0});return{path:a.path,size:a.size,mtimeMs:a.mtimeMs}}return null},[r,o]);n.useEffect(()=>{if(!o||!r.statFile||C.length===0)return;let t=!1;const i=[...C];return Promise.all(i.map(async a=>{try{const c=await r.statFile?.(a,{directory:o||void 0});!t&&c&&!c.isFile&&ot(o,a)}catch(c){!t&&zi(c)&&ot(o,a)}})),()=>{t=!0}},[r,C,ot,o]);const Us=n.useMemo(()=>k.length>rs?`${k.slice(0,rs)}
11
+
12
+ … truncated …`:k,[k]),ie=B!==Us,Nt=n.useCallback(async()=>{if(!l||!r.writeFile)return I.error(e("filesView.toast.savingNotSupported")),!1;const t=Fs(l.path)||_t;if(!Oa({selectedFilePath:l.path,loadedFilePath:be,fileLoading:Re,isDirty:ie,draftContent:B,fileContent:k,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${l.path}".`):B===""&&k!==""&&be!==l.path&&console.warn(`[saveDraft] refusing to save empty draft for "${l.path}" (${k.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!ie)return!0;Ms(!0);try{const i=Ja(B,yr);if(!(await r.writeFile(l.path,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;if(H(B),o&&is(l.path,o)){const c=ks(o,l.path);c&&ca.requestGitRefresh({directory:o,paths:[c]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(M(l.path))){const c=da.getState().projects.find(u=>M(u.path)===M(o));if(c)try{await Da(c.id)}catch{I.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return l?.path&&rr(l.path)&&(lt.current=B,Ht.current=B),ut(l.path).then(c=>{c&&(Ke.current=c)}).catch(()=>{}),!0}catch(i){return I.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ms(!1)}},[_t,B,k,Re,r,ie,yr,be,ut,o,l,e]);n.useEffect(()=>{if(!ie){He(null);return}const t=i=>bt.current?(bt.current=!1,!0):(zt(!0),Xt.current=i,!1);return He(t),()=>{he.getState().mainTabGuard===t&&He(null)}},[ie,He]),n.useEffect(()=>{re||(Mt("idle"),Ge.current&&(clearTimeout(Ge.current),Ge.current=null))},[re]);const Xr=1500;n.useEffect(()=>{const t=!!(l&&r.writeFile),i=!!(l?.path&&(Fs(l.path)||_t));if(Ia({autoSaveEnabled:re,isDirty:ie,canWrite:t,isSaving:Rt,fileLoading:Re,selectedFilePath:l?.path,loadedFilePath:be,isNonEditableBinary:i}))return Ge.current=setTimeout(()=>{Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})},Xr),()=>{Ge.current&&(clearTimeout(Ge.current),Ge.current=null)}},[re,_t,B,Re,ie,be,l,r.writeFile,Rt,Nt]),n.useEffect(()=>{Mt("idle")},[l?.path]),n.useEffect(()=>{const t=i=>{ga(i)&&(i.key.toLowerCase()==="s"?(i.preventDefault(),Ge.current&&(clearTimeout(Ge.current),Ge.current=null),Rt||Nt().then(a=>{a&&(Mt("saved"),setTimeout(()=>Mt("idle"),2e3))})):i.key.toLowerCase()==="f"&&(i.preventDefault(),pe(!0)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[Rt,Nt]);const Jr=n.useCallback(async t=>{const i=qt.current+1;qt.current=i;const a=()=>{if(!o)return!1;const je=ze.getState().byRoot[o],oe=je?.selectedPath??je?.openPaths[0]??null;return qt.current===i&&oe===t.path};J(null),Te(""),K(null),Fr(!1);const c=Ni(t.path),u=Ci(t.path),f=Si(t.path),w=Fs(t.path);if(h&&A(!0),m.isDesktop&&c&&!u){H(""),Q(""),Ye(!0);return}if(!m.isDesktop&&c&&!u){H(""),Q(""),K(t.path),Ye(!1);return}if(f){H(""),Q(""),K(t.path),Ye(!1);return}if(w){H(""),Q(""),K(t.path),Ye(!1);return}Ye(!0);const D=ji(t.path),$={allowOutsideWorkspace:d==="editor-only"&&!!o&&!is(t.path,o),outsideFileGrant:D};await _r(t.path,$).then(je=>{if(!a())return;if(ua(je)){Fr(!0),H(""),Q(""),K(t.path);return}const oe=Gi(je);Qi(Xa(je)),H(oe),lt.current=oe,Ht.current=oe,Q(oe.length>rs?`${oe.slice(0,rs)}
13
+
14
+ … truncated …`:oe),K(t.path),ut(t.path,$).then(Ct=>{Ct&&a()&&(Ke.current=Ct)}).catch(()=>{})}).catch(je=>{if(a()){if(_a(je)){if(Ye(!1),o&&se(o,null),J(null),H(""),Q(""),K(null),Ke.current=null,T.trim().length>0&&V(""),h&&A(!1),o){const Ct=[...Pi(t.path,o),t.path];Ct.length>0&&ns(o,Ct);for(const er of Ct)Se.current.has(er)||Ve(er)}return}if(zi(je)){o&&ot(o,t.path),H(""),Q(""),J(null),Ke.current=null,h&&A(!1);return}H(""),Q(""),J(je instanceof Error?je.message:e("filesView.error.readFileFailed")),Ke.current=null}}).finally(()=>{a()&&Ye(!1)})},[ns,h,Ve,d,_r,ut,ot,o,m.isDesktop,T,se,e]),xs=n.useCallback(async(t,i)=>{if(!o)return;const a=Pi(t,o),c=i?[...a,t]:a;c.length>0&&ns(o,c);const u=c.map(f=>{if(!Se.current.has(f))return Ve(f)}).filter(Boolean);await Promise.all(u)},[ns,Ve,o]),Qr=n.useCallback((t,i)=>{const a=i.findIndex(c=>c.path===t);return a===-1||i.length<=1?null:i[a+1]??i[a-1]??null},[]),me=n.useCallback(async t=>{if(bt.current)bt.current=!1;else if(ie){zt(!0),Lt.current=t;return}o&&(se(o,t.path),xs(t.path,!1)),J(null),Te(""),H(""),lt.current="",Ht.current="",Q(""),K(null),h&&A(!0)},[xs,ie,h,o,se]);n.useEffect(()=>{l?.path&&xs(l.path,!1)},[xs,l?.path]),n.useEffect(()=>{if(!l){qt.current+=1,Pt.current=null,Ye(!1);return}if(be===l.path||Pt.current===l.path)return;const t=l.path;Pt.current=t,Jr(l).finally(()=>{Pt.current===t&&(Pt.current=null)})},[us,Jr,be,l]);const Gs=n.useRef(ie);Gs.current=ie,n.useEffect(()=>Ea(({runtimeKey:t,paths:i})=>{const a=l?.path;t!==ta()||!a||Gs.current||!i.includes(M(a))||(qt.current+=1,Pt.current=null,Ke.current=null,Te(""),J(null),K(null),Zi(c=>c+1))}),[l?.path]),n.useEffect(()=>{if(!l?.path||be!==l.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ut(l.path,Ce).then(a=>{if(t||!a)return;const c=Ke.current;if(!c||c.path!==l.path){Ke.current=a;return}const u=a.mtimeMs!==void 0&&c.mtimeMs!==void 0&&a.mtimeMs!==c.mtimeMs,f=a.size!==c.size;!u&&!f||Gs.current||(Ke.current=a,K(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[be,ut,l?.path,Ce]);const Nn=n.useCallback(()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),Q(Us),a){o&&Vt(o,a),l?.path===a&&(t?me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[Us,me,h,Vt,o,l?.path,He,se]),Cn=n.useCallback(async()=>{const t=Lt.current,i=Xt.current,a=Jt.current;if(!await Nt()){bt.current=!1;return}if(Lt.current=null,Xt.current=null,Jt.current=null,bt.current=!0,zt(!1),a){o&&Vt(o,a),l?.path===a&&(t?await me(t):(o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)));return}if(t){await me(t);return}i&&(He(null),he.getState().setActiveMainTab(i))},[me,h,Vt,o,Nt,l?.path,He,se]),Yr=n.useCallback(t=>{const i=l?.path===t,a=Qr(t,Et);if(i&&ie){zt(!0),Lt.current=a,Jt.current=t;return}if(o&&Vt(o,t),!!i){if(a){me(a);return}o&&se(o,null),H(""),J(null),Te(""),K(null),h&&A(!1)}},[Qr,me,ie,h,Et,Vt,o,l?.path,se]),Sn=n.useCallback(t=>{if(C.includes(t))return"open";if(L?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=L.files.find(c=>c.path===i);if(a){if(a.index==="A"||a.working_dir==="?")return"git-added";if(a.index==="D")return"git-deleted";if(a.index==="M"||a.working_dir==="M")return"git-modified"}}return null},[C,L,o]),kn=n.useCallback(t=>{if(!L?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,a=i?`${i}/`:"";let c=0,u=0;for(const f of L.files)f.path.startsWith(a)&&((f.index==="M"||f.working_dir==="M")&&c++,(f.index==="A"||f.working_dir==="?")&&u++);return c+u>0?{modified:c,added:u}:null},[L,o]),Tn=n.useCallback(async t=>{const i=M(t);o&&(mr(o,i),Se.current.has(i)||await Ve(i))},[Ve,o,mr]),Vn=n.useMemo(()=>({canRename:Vr,canCreateFile:kr,canCreateFolder:Tr,canDelete:Dr,canReveal:Er}),[Vr,kr,Tr,Dr,Er]);function Zr(t,i){const a=vr[t]??[];return a.map((c,u)=>{const f=c.type==="directory",w=f&&Je.includes(c.path),D=l?.path===c.path,$=u===a.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),$&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(Ya,{node:c,root:o,isExpanded:w,isActive:D,isMobile:h,isBrowserClient:F,alwaysShowActions:z,status:f?void 0:Sn(c.path),badge:f?kn(c.path):void 0,permissions:Vn,downloadFile:r.downloadFile,contextMenuPath:ln,setContextMenuPath:cn,rightClickMenuPath:dn,setRightClickMenuPath:un,onSelect:me,onToggle:Tn,onRevealPath:vn,onOpenDialog:Bs}),f&&w&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[os[c.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:os[c.path],children:os[c.path]}),s.jsxs(S,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{_e(c.path)},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Zr(c.path,i+1)]})]},c.path)})}const ne=!!(l?.path&&Ni(l.path)),vs=!!(l?.path&&Ci(l.path)),De=!!(l?.path&&Si(l.path)),Ks=!!(l?.path&&(Fs(l.path)||_t)),tt=Ks&&!ne&&!De,ei=n.useMemo(()=>M(qe?.path??""),[qe?.path]),Bt=!!(qe&&ei&&Ue&&Ue===ei&&!Re&&!Ze&&!ne&&!De&&!tt),ft=n.useMemo(()=>ks(o,Ue),[Ue,o]),Dn=!!(l&&(!ne||vs)&&!De&&!tt&&k.length>0),En=!!(l&&ft.length>0),Ee=!!(l&&!as&&!Ks&&!ne&&r.writeFile&&k.length<=rs),mt=!!(l?.path&&Li(l.path)),ts=!!(l?.path&&Qa(l.path)),$t=!!(l?.path&&lr(l.path)),ss=!!(l?.path&&rr(l.path)),Hs=!!(l&&!Ks&&!ne)&&!mt&&!ss&&!($t&&xe==="preview"),Rn=mt&&xt==="edit"||$t&&xe==="edit"||ts&&Ie==="text"||!mt&&!$t&&!ts&&G==="edit",ws=n.useMemo(()=>Ue?fa(Ue):null,[Ue]),[ti,qs]=n.useState(null);n.useEffect(()=>{let t=!1;const i=l?.path;if(!i||ws){qs(null);return}return qs(null),ma(i).then(a=>{t||qs(a)}),()=>{t=!0}},[l?.path,ws]),n.useEffect(()=>{!Ee&&G==="edit"&&Fe("view")},[Ee,G]);const _s="openchamber:files:md-viewer-mode",Xs="openchamber:files:html-viewer-mode",Js="openchamber:files:json-viewer-mode";n.useEffect(()=>{const t=l?.path;if(!t)return;Fe(Be.current[t]??"edit");let i=Zt?"preview":"edit";try{const u=localStorage.getItem(_s);(u==="preview"||u==="edit")&&(i=u)}catch{}Ae($e.current[t]??i);let a=Zt?"preview":"edit";try{const u=localStorage.getItem(Xs);(u==="preview"||u==="edit")&&(a=u)}catch{}Oe(We.current[t]??a),Ne(at.current[t]??(Zt?"preview":"edit"));let c=Zt?"tree":"text";try{const u=localStorage.getItem(Js);(u==="tree"||u==="text")&&(c=u)}catch{}vt(c)},[l?.path,Zt]);const Pn=n.useCallback(t=>{const i=l?.path;i&&(Be.current[i]=t),Fe(t)},[l?.path]),si=n.useCallback(t=>{const i=l?.path;i&&($e.current[i]=t),Ae(t);try{localStorage.setItem(_s,t)}catch{}},[l?.path]),ae=n.useCallback(()=>xt,[xt]),Mn=n.useCallback(t=>{vt(t);try{localStorage.setItem(Js,t)}catch{}},[]),zn=n.useCallback(t=>{const i=l?.path;i&&(We.current[i]=t),Oe(t);try{localStorage.setItem(Xs,t)}catch{}},[l?.path]),Ln=n.useCallback(t=>{const i=l?.path;if(i&&(at.current[i]=t),ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null),t==="edit")Q(lt.current||k),Ne(t);else{lt.current=B;const a=i;Ne("edit"),et.current=requestAnimationFrame(()=>{et.current=requestAnimationFrame(()=>{et.current=null,!(o&&a&&ze.getState().byRoot[o]?.selectedPath!==a)&&(nt(c=>c+1),Ne("preview"))})});return}},[B,k,o,l?.path]),Qs=n.useCallback(async(t,i)=>{if(!r.writeFile||i===Ht.current)return!1;if(!(await r.writeFile(t,i))?.success)return I.error(e("filesView.toast.writeFileFailed")),!1;lt.current=i,Ht.current=i,Q(i);const c=await ut(t,Ce).catch(()=>null);return c&&(Ke.current=c),!0},[r,ut,Ce,e]);n.useEffect(()=>()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),et.current!==null&&(cancelAnimationFrame(et.current),et.current=null)},[ue,l?.path]);const An=n.useCallback(t=>{if(lt.current=t,!re||!l?.path||ue!=="preview"||!r.writeFile)return;ye.current&&clearTimeout(ye.current);const i=l.path;ye.current=setTimeout(()=>{ye.current=null,Qs(i,t).then(a=>{a&&(fs(!0),setTimeout(()=>fs(!1),1500))}).catch(a=>{I.error(a instanceof Error?a.message:e("filesView.toast.saveFailed"))})},Xr)},[re,ue,r.writeFile,Qs,l?.path,e]),In=n.useMemo(()=>ss&&(lt.current||B)||k,[B,k,ss]),ri=n.useCallback(()=>xe,[xe]);n.useEffect(()=>{const t=a=>{const c=a?"preview":"edit",u=a?"tree":"text";for(const f of C)Be.current[f]="edit",Li(f)&&($e.current[f]=c),lr(f)&&(We.current[f]=c),rr(f)&&(at.current[f]=c);Fe("edit"),Ae(c),Oe(c),Ne(c),vt(u);try{localStorage.setItem(_s,c),localStorage.setItem(Xs,c),localStorage.setItem(Js,u)}catch{}},i=a=>{const c=!!a.detail?.enabled;t(c)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[C]),n.useEffect(()=>{if(!qe||!o)return;const t=()=>{typeof window>"u"||At.current===null&&(At.current=window.requestAnimationFrame(()=>{At.current=null,Ls(st=>st+1)}))},i=(st,St)=>{if(st.state.doc.length!==St.length)return!1;if(St.length===0)return!0;const tr=Math.min(128,St.length);if(st.state.sliceDoc(0,tr)!==St.slice(0,tr))return!1;const xi=Math.max(0,St.length-tr);return st.state.sliceDoc(xi,St.length)===St.slice(xi)},a=M(qe.path);if(!a){ms(null),yt.current={key:"",attempts:0};return}const c=`${a}:${qe.line}:${qe.column??1}`;if(yt.current.key!==c&&(yt.current={key:c,attempts:0}),l?.path!==a){if(zs)return;me(Dt(a));return}if(Re||be!==a)return;if(Ze||ne||De||tt){ms(null),yt.current={key:"",attempts:0};return}if(!Ee)return;if(G!=="edit"){Fe("edit");return}const u=Pe.current;if(!u){t();return}if(!i(u,B)){t();return}const f=Math.max(1,Math.min(qe.line,u.state.doc.lines)),w=u.state.doc.line(f),D=Math.max(1,qe.column||1),$=Math.max(0,w.to-w.from),je=Math.min($,D-1),oe=w.from+je;if(!(u.state.selection.main.head===oe)||yt.current.attempts===0){yt.current.attempts+=1,u.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),u.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const st=Pe.current;st&&(st.dispatch({selection:{anchor:oe},effects:kt.scrollIntoView(oe,{y:"center"})}),st.focus())}),ms(null),yt.current={key:"",attempts:0}},[Ee,zs,B,nn,Ze,Re,ne,De,tt,be,me,qe,o,l?.path,ms,G,Dt]),n.useEffect(()=>{if(!$s||!o)return;const t=M($s);if(!t){Ws(null);return}l?.path===t&&(Re||be!==t||(!Ze&&!ne&&!De&&!tt&&Ee&&G==="edit"&&Pe.current?.focus(),Ws(null)))},[Ee,Ze,Re,ne,De,tt,be,$s,o,l?.path,Ws,G]);const Wt=n.useCallback(t=>{if(!h||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const a=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,a-(i.offsetTop+i.height))<=0)return;const u=t.state.selection.main.head,f=t.coordsAtPos(u);if(!f)return;const w=Math.round(i.offsetTop+i.height),$=f.bottom+20-w;$<=0||(t.scrollDOM.scrollTop+=$)},[h]);n.useEffect(()=>{if(!h||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Wt(Pe.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[h,Wt]),n.useEffect(()=>{if(!Ee||G!=="edit"||h)return;const t=ha("open_go_to_line",Mr),i=a=>{const c=a.target;if(c?.closest('[role="dialog"]'))return;const u=!!c?.closest(".cm-editor");c?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!u||!document.activeElement?.closest(".cm-editor")||xa(a,t)&&(a.preventDefault(),Os(!0))};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[Ee,h,Mr,G]);const bs=he(t=>t.editorFontSize),ii=n.useMemo(()=>{if(!l?.path)return[Ti(x,{fontSize:bs})];const t=sr(l.path),i=[Ti(x,t?{syntaxColors:!1,fontSize:bs}:{fontSize:bs})],a=ws??ti;return a&&i.push(a),t&&i.push(Ca({language:t,themeName:x.metadata.id,theme:Va(x)})),ce&&i.push(kt.lineWrapping),h&&i.push(kt.updateListener.of(c=>{c.view.hasFocus&&(c.selectionSet||c.focusChanged||c.viewportChanged||c.geometryChanged)&&window.requestAnimationFrame(()=>{Wt(c.view)})})),i},[x,l?.path,ws,ti,ce,h,Wt,bs]),ni=n.useMemo(()=>({light:fe.metadata.id,dark:ve.metadata.id}),[fe.metadata.id,ve.metadata.id]),ys=l?.path&&De?`${l.path}|${Ce.allowOutsideWorkspace?"outside":"workspace"}|${Ce.outsideFileGrant??""}|${us}`:"",js=l?.path&&$t&&xe==="preview"&&!m.isVSCode?`${l.path}|${us}`:"",ai=e("filesView.error.readFileFailed"),{readyKey:oi,nonce:On}=Ai(js,J,ai),{readyKey:li,nonce:ci}=Ai(ys,J,ai),Bn=!!(js&&oi!==js),di=!!(ys&&li!==ys),ui=l?.path&&ne?vs?`data:${pa(l.path)};utf8,${encodeURIComponent(k)}`:Ji:"",fi=l?.path&&De&&li===ys?yi().authenticatedAsset("/api/fs/raw",{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}):"",mi=n.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:fi,className:"h-full w-full border-0",title:t.name},ci)}),[fi,ci]);n.useEffect(()=>{let t=!1,i="";return(async()=>{if(!l?.path||!ne||vs){Te("");return}J(null),await(r.readFileBinary?r.readFileBinary(l.path,Ce).then(u=>u.dataUrl):(async()=>{const u=await bi("/api/fs/raw",{query:{path:l.path,allowOutsideWorkspace:Ce.allowOutsideWorkspace?"true":void 0,outsideFileGrant:Ce.outsideFileGrant,directory:o||void 0}});if(!u.ok)throw new Error(e("filesView.error.readFileFailed"));const f=await u.blob();return i=URL.createObjectURL(f),t?(URL.revokeObjectURL(i),i="",""):i})()).then(u=>{t||(Te(u),K(l.path))}).catch(u=>{t||(Te(""),J(u instanceof Error?u.message:e("filesView.error.readFileFailed")),K(null))}).finally(()=>{t||Ye(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[us,r,ne,vs,o,l?.path,Ce,e]);const $n=n.useCallback(()=>As(null),[]),Wn=n.useMemo(()=>za({drafts:Ar,editingDraftId:ps,commentText:hs,onTextChange:Ir,selection:P,isDragging:Pr,fileLabel:l?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Gr,onCancel:()=>{Me(null),es()},onEdit:t=>{Wr(t),Me({start:t.startLine,end:t.endLine})},onDelete:Ur}),[es,hs,Ur,ps,Ar,Gr,Pr,P,l?.path,Ir,Wr]),hi=n.useCallback((t,i)=>s.jsx("div",{className:"h-full",children:s.jsx(ka,{file:{name:t.name,contents:i,lang:sr(t.path)||void 0},options:{disableFileHeader:!0,overflow:ce?"wrap":"scroll",theme:ni,themeType:x.metadata.variant==="dark"?"dark":"light"},className:"block h-full w-full",style:{height:"100%"}})}),[x.metadata.variant,ni,ce]),Ys=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!l)return null;const c=i==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",u=(f,w)=>s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:w})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:f})]});return s.jsxs("div",{className:c,children:[Ee&&Rn&&s.jsxs(s.Fragment,{children:[Rt?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(g,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):re&&en==="saved"&&!ie?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(g,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):ie?u(e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{Nt()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(re?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:`${ar()}+S`}),"aria-label":e("filesView.editor.saveAria",{shortcut:`${ar()}+S`}),children:s.jsx(g,{name:"save-3",className:"size-4"})})):null,u(e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>sn(!re),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",re?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(re?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:re?s.jsx(g,{name:"file-check-fill",className:"size-4"}):s.jsx(g,{name:"file-check",className:"size-4"})}))]}),s.jsxs(cr,{onOpenChange:Tt,children:[s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(dr,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(g,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(ur,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[pn.map(f=>s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{wn(f)},children:[s.jsx($a,{label:f.label,iconDataUrl:f.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:f.label})]},f.id)),gn?s.jsxs(Ss,{className:"flex items-center gap-2",onClick:()=>{xn(!0)},children:[s.jsx(g,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!ne&&!De&&!tt&&s.jsxs(s.Fragment,{children:[u(e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Le(!ce),className:O("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",ce?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ce?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(g,{name:"text-wrap",className:"size-4"})})),G==="edit"&&s.jsxs(s.Fragment,{children:[u(e("filesView.editor.findInFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{pe(!ee),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(g,{name:"search",className:"size-4"})})),u(e("filesView.editor.goToLine"),s.jsx(S,{variant:"ghost",size:"sm",onClick:f=>{Os(w=>!w),f.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(g,{name:"menu-fold-2",className:"size-4"})})),s.jsx(Aa,{open:hn,onOpenChange:Os,view:Pe.current,variant:"inline"})]})]}),Hs&&Ee&&!ts&&!$t&&s.jsx(or,{currentMode:G==="view"?"preview":"edit",onToggle:()=>{Pn(G==="view"?"edit":"view")}}),mt&&u(e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})),lr(l?.path??"")&&s.jsx(or,{currentMode:ri(),onToggle:()=>{zn(ri()==="preview"?"edit":"preview")}}),mt&&ae()==="preview"&&bn&&s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx(S,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{ds?Xi():k.trim()&&_i(k)},children:ds?s.jsx(g,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"volume-up",className:"size-4"})})}),s.jsx(gt,{sideOffset:8,children:e(ds?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),ss&&s.jsxs(s.Fragment,{children:[s.jsx(or,{currentMode:ue,onToggle:()=>Ln(ue==="preview"?"edit":"preview")}),ue==="preview"&&s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{const f=jr.current?.getXml();if(ye.current&&(clearTimeout(ye.current),ye.current=null),l?.path&&f){if(!await Qs(l.path,f))return;fs(!0),setTimeout(()=>fs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:tn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"save-3",className:"size-4"})})]}),ts&&u(e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Mn(Ie==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(Ie==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:Ie==="tree"?s.jsx(g,{name:"code-sslash",className:"size-4"}):s.jsx(g,{name:"node-tree",className:"size-4"})})),Dn&&u(e("filesView.editor.copyFileContents"),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(k)).ok?(Cr(!0),Qt.current!==null&&window.clearTimeout(Qt.current),Qt.current=window.setTimeout(()=>{Cr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:fn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"clipboard",className:"size-4"})})),En&&u(e("filesView.editor.copyFilePathTitle",{path:ft}),s.jsx(S,{variant:"ghost",size:"sm",onClick:async()=>{(await Vs(ft)).ok?(Sr(!0),Yt.current!==null&&window.clearTimeout(Yt.current),Yt.current=window.setTimeout(()=>{Sr(!1)},1200)):I.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:ft}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:ft}),children:mn?s.jsx(g,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(g,{name:"file-copy-2",className:"size-4"})})),r.downloadFile&&u(e("filesView.editor.saveFile"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{const f=r.downloadFile;f&&f(l.path).catch(w=>{console.error("Download failed:",w),I.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(g,{name:"download",className:"size-4"})})),t?u(e("filesView.editor.exitFullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(g,{name:"fullscreen-exit",className:"size-4"})})):!h&&d==="full"&&u(e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>X(!U),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(U?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:U?s.jsx(g,{name:"fullscreen-exit",className:"size-4"}):s.jsx(g,{name:"fullscreen",className:"size-4"})}))]})},Zs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Ii,{open:zs,onOpenChange:t=>{t||zt(!0)},children:s.jsxs(Oi,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Bi,{children:[s.jsx($i,{children:e("filesView.unsaved.title")}),s.jsx(Wi,{children:e("filesView.unsaved.description")})]}),s.jsxs(Ui,{children:[s.jsx(S,{variant:"outline",onClick:()=>{Cn()},disabled:Rt,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(S,{variant:"destructive",onClick:Nn,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:O("flex flex-col flex-shrink-0",q&&"border-b border-border/40"),children:[q?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&Z&&s.jsx("button",{type:"button",onClick:()=>A(!1),"aria-label":e("filesView.editor.back"),className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:s.jsx(g,{name:"arrow-left-s",className:"size-5"})}),h?l?s.jsxs(cr,{children:[s.jsx(dr,{asChild:!0,children:s.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":e("filesView.editor.openFilesAria"),children:[s.jsx(Cs,{filePath:l.path,extension:l.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:l.name}),s.jsx(g,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(ur,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs(Ss,{onSelect:a=>{if(a.target.closest("[data-close-open-file]")){a.preventDefault();return}i||me(t)},className:O("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Mi,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:a=>{a.preventDefault(),a.stopPropagation()},onClick:a=>{a.preventDefault(),a.stopPropagation(),Yr(t.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Et.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[pr.left&&s.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),pr.right&&s.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),s.jsx("div",{ref:Rs,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Et.map(t=>{const i=l?.path===t.path;return s.jsxs("div",{title:ks(o,t.path),className:O("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[s.jsx(Cs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||me(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),Yr(t.path)},className:O("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!z&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(g,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,(Lr||h)&&l?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[ft&&!h?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:ft,children:ft}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Ys({layout:"docked"})})]}):null]}),s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[l&&!ee&&!(Lr||h)&&s.jsx("div",{ref:de,className:"absolute right-3 top-3 z-30",onMouseLeave:()=>{rt.current>0||ge(!1)},children:te?Ys():s.jsxs("div",{className:"flex items-center gap-1",children:[mt?s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>si(ae()==="preview"?"edit":"preview"),className:O("size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 shadow-sm transition-colors",ae()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),title:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(g,{name:ae()==="preview"?"eye":"eye-off",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e(ae()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode")})]}):null,s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",onMouseEnter:()=>ge(!0),children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>ge(!0),className:"size-8 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-0 text-muted-foreground shadow-sm hover:text-foreground","aria-label":e("filesView.editor.showControlsAria"),title:e("filesView.editor.controlsTitle"),children:s.jsx(g,{name:"more-2-fill",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.editor.controlsTitle")})]})]})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:l?Re||di?W?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):Ze?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:ui,alt:l?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):l&&ss&&ue==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(Ra,{ref:jr,xml:In,onChange:An},`${l.path}:${it}`)}):l&&ts&&Ie==="tree"?s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(Ta,{jsonString:k,maxHeight:"100%",initiallyExpandedDepth:2})})}):l&&mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-3",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):l&&$t&&xe==="preview"?Bn?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!m.isVSCode&&oi===js?(()=>{const t=l.path.split("/").map(i=>encodeURIComponent(i)).join("/");return yi().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:m.isVSCode?(()=>{const t=l.path.substring(0,l.path.lastIndexOf("/")+1);return t?k.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):k})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},On)}):l&&Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),ref:rn,children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",blockWidgets:Wn,onViewReady:t=>{Pe.current=t,Ls(i=>i+1),window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null),Ls(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:pe,highlightLines:P?{start:Math.min(P.start,P.end),end:Math.max(P.start,P.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.button!==0)return!1;a.preventDefault();const c=t.state.doc.lineAt(i.from).number;if(P&&!a.shiftKey&&Math.min(P.start,P.end)===c&&Math.max(P.start,P.end)===c)return Me(null),es(),It.current=!1,dt.current=null,Ot(!1),!0;if(h&&P&&!a.shiftKey){const u=Math.min(P.start,P.end,c),f=Math.max(P.start,P.end,c);return Me({start:u,end:f}),It.current=!1,dt.current=null,Ot(!1),!0}if(It.current=!0,dt.current=c,Ot(!0),P&&a.shiftKey){const u=Math.min(P.start,c),f=Math.max(P.end,c);Me({start:u,end:f})}else Me({start:c,end:c});return!0},mouseover:(t,i,a)=>{if(!(a instanceof MouseEvent)||a.buttons!==1||!It.current||dt.current===null)return!1;const c=t.state.doc.lineAt(i.from).number,u=Math.min(dt.current,c),f=Math.max(dt.current,c);return Me({start:u,end:f}),Ot(!0),!1},mouseup:()=>(It.current=!1,dt.current=null,Ot(!1),!1)}}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})]})]}),Un=!!(o&&vr[o]),pi=o?os[o]:null,gi=s.jsxs("section",{className:O("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:O("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(g,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Ts,{ref:Y,value:T,onChange:t=>V(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),T.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{V(""),Y.current?.focus()},children:s.jsx(g,{name:"close",className:"size-4"})})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFile",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(g,{name:"file-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>Bs("createFolder",{path:R,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(g,{name:"folder-add",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(ht,{children:[s.jsx(pt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(S,{variant:"ghost",size:"sm",onClick:()=>{gs()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(g,{name:"refresh",className:"size-4"})})})}),s.jsx(gt,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(ir,{outerClassName:"flex-1 min-h-0",className:O("py-2",h?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:qi?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):br.length>0?br.map(t=>{const i=l?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{me(t)},className:O("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Ki(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):pi?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:pi}),s.jsxs(S,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{gs()},children:[s.jsx(g,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Un?Zr(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),Gn=d==="full"&&U&&l&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:Ys({exitFullscreenOnly:!0})}),s.jsx(ir,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:Re||di?W?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):Ze?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:Ze}):ne?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:ui,alt:l.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},l.path)}):De?mi(l):tt?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),r.downloadFile?s.jsxs(S,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=r.downloadFile;!t||!l||t(l.path).catch(i=>{console.error("Download failed:",i),I.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(g,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):mt&&ae()==="preview"?s.jsxs("div",{className:"h-full overflow-auto p-4",children:[k.length>500*1024&&s.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(k.length/1024)})}),s.jsx(nr,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(ki,{content:k,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Hs&&G==="view"?hi(l,B):s.jsxs("div",{className:O("relative h-full",Bt&&"overflow-hidden"),children:[s.jsx("div",{className:O("h-full",Bt&&"invisible"),children:s.jsx(Vi,{value:B,onChange:Q,readOnly:!Ee,vimMode:zr==="vim",extensions:ii,className:"h-full",onViewReady:t=>{Pe.current=t,window.requestAnimationFrame(()=>{Wt(t)})},onViewDestroy:()=>{Pe.current&&(Pe.current=null)}})}),Bt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(g,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Za,{activeDialog:jt,dialogData:Ft,dialogInputValue:ct,onDialogInputChange:Nr,isDialogSubmitting:on,onDialogSubmit:Fn,onClose:$n,inputRef:Yi}),Gn,h?Z?Zs:gi:d==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[p>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:gi}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zs})]})]})};function eo(d){return d+1}export{wc as FilesView};