@openchamber/web 2.0.4 → 2.1.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 (264) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
  2. package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
  3. package/dist/assets/FilesView-B_NJFLBH.js +17 -0
  4. package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
  5. package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
  6. package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
  7. package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
  8. package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
  9. package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
  10. package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
  11. package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
  12. package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
  13. package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
  14. package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
  15. package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
  16. package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
  17. package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
  18. package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
  19. package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
  20. package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
  21. package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
  22. package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
  23. package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
  24. package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
  26. package/dist/assets/de-D4hpTCNY.js +10 -0
  27. package/dist/assets/es-Bw9m3H62.js +16 -0
  28. package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
  29. package/dist/assets/fr-Bhll42P0.js +14 -0
  30. package/dist/assets/index-Btd2mmYT.js +42 -0
  31. package/dist/assets/index-C-7hQnEc.css +1 -0
  32. package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
  33. package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
  34. package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
  35. package/dist/assets/ja-CsHoT43d.js +16 -0
  36. package/dist/assets/ko-BBNdtFa4.js +16 -0
  37. package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
  38. package/dist/assets/main-kYkr_urz.js +1000 -0
  39. package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
  40. package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
  41. package/dist/assets/mobile-CviaXnnU.js +2 -0
  42. package/dist/assets/nl-DszyktfH.js +16 -0
  43. package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
  44. package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
  45. package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
  46. package/dist/assets/pl-Bk9_mUXc.js +16 -0
  47. package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
  48. package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
  49. package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
  50. package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
  51. package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
  52. package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
  53. package/dist/assets/space-close-C1tL-_0t.js +1 -0
  54. package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
  55. package/dist/assets/tr-C_13w7CX.js +7 -0
  56. package/dist/assets/uk-BZTsG-q_.js +16 -0
  57. package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
  58. package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
  59. package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
  60. package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
  61. package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
  62. package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
  63. package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
  65. package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
  66. package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
  67. package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
  68. package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
  69. package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
  70. package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
  71. package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
  72. package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
  73. package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
  74. package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
  75. package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
  76. package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
  77. package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
  78. package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
  79. package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
  80. package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
  81. package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
  82. package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
  83. package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
  84. package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
  85. package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
  86. package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
  87. package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
  88. package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
  89. package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
  90. package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
  91. package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
  92. package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
  93. package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
  94. package/dist/index.html +4 -4
  95. package/dist/mini-chat.html +4 -4
  96. package/dist/mobile.html +4 -4
  97. package/package.json +4 -4
  98. package/server/index.js +58 -1
  99. package/server/lib/browser-control/DOCUMENTATION.md +8 -1
  100. package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
  101. package/server/lib/dev-tunnel/runtime.js +94 -38
  102. package/server/lib/dev-tunnel/tunnel.test.js +16 -2
  103. package/server/lib/dictation/DOCUMENTATION.md +23 -10
  104. package/server/lib/dictation/audio.js +28 -0
  105. package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
  106. package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
  107. package/server/lib/dictation/local/worker-client.js +28 -10
  108. package/server/lib/dictation/local/worker-process.js +25 -1
  109. package/server/lib/dictation/stream-manager.js +160 -53
  110. package/server/lib/dictation/stream-manager.test.js +108 -7
  111. package/server/lib/enterprise-mode.d.ts +2 -0
  112. package/server/lib/enterprise-mode.js +84 -9
  113. package/server/lib/enterprise-mode.test.js +115 -0
  114. package/server/lib/fs/DOCUMENTATION.md +3 -2
  115. package/server/lib/fs/routes.js +28 -1
  116. package/server/lib/fs/routes.test.js +31 -5
  117. package/server/lib/git/DOCUMENTATION.md +1 -1
  118. package/server/lib/git/service.js +61 -2
  119. package/server/lib/git/service.test.js +141 -0
  120. package/server/lib/github/DOCUMENTATION.md +18 -0
  121. package/server/lib/github/checks-summary.js +76 -0
  122. package/server/lib/github/pr-summaries.js +282 -0
  123. package/server/lib/github/pr-summaries.test.js +209 -0
  124. package/server/lib/github/routes.js +42 -77
  125. package/server/lib/github/routes.test.js +77 -0
  126. package/server/lib/inherited-env.js +51 -0
  127. package/server/lib/inherited-env.test.js +59 -0
  128. package/server/lib/message-search/DOCUMENTATION.md +83 -0
  129. package/server/lib/message-search/indexer.js +336 -0
  130. package/server/lib/message-search/indexer.test.js +341 -0
  131. package/server/lib/message-search/routes.js +92 -0
  132. package/server/lib/message-search/runtime.js +234 -0
  133. package/server/lib/message-search/runtime.test.js +108 -0
  134. package/server/lib/message-search/sqlite.js +74 -0
  135. package/server/lib/message-search/store.js +289 -0
  136. package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
  137. package/server/lib/openchamber-control/actions.js +1 -1
  138. package/server/lib/openchamber-control/service.js +21 -2
  139. package/server/lib/openchamber-control/service.test.js +50 -0
  140. package/server/lib/openchamber-sessions/routes.js +15 -0
  141. package/server/lib/openchamber-sessions/routes.test.js +31 -0
  142. package/server/lib/opencode/DOCUMENTATION.md +43 -38
  143. package/server/lib/opencode/auth.d.ts +24 -0
  144. package/server/lib/opencode/auth.js +130 -66
  145. package/server/lib/opencode/auth.test.js +114 -70
  146. package/server/lib/opencode/compatibility.js +4 -3
  147. package/server/lib/opencode/compatibility.test.js +10 -10
  148. package/server/lib/opencode/feature-routes-runtime.js +3 -0
  149. package/server/lib/opencode/lifecycle.js +21 -12
  150. package/server/lib/opencode/lifecycle.test.js +38 -5
  151. package/server/lib/opencode/provider-source-route.test.js +55 -2
  152. package/server/lib/opencode/routes.js +17 -4
  153. package/server/lib/opencode/settings-helpers.js +6 -0
  154. package/server/lib/opencode/settings-helpers.test.js +1 -1
  155. package/server/lib/opencode/settings-registry.json +16 -0
  156. package/server/lib/opencode/settings-runtime.js +9 -0
  157. package/server/lib/opencode/shutdown-runtime.js +2 -0
  158. package/server/lib/opencode/v1-migration-topup.js +13 -3
  159. package/server/lib/opencode/v2-install.test.js +13 -13
  160. package/server/lib/quota/DOCUMENTATION.md +11 -5
  161. package/server/lib/quota/providers/claude/auth.js +19 -6
  162. package/server/lib/quota/providers/claude/auth.test.js +22 -9
  163. package/server/lib/quota/providers/claude/index.js +3 -3
  164. package/server/lib/quota/providers/claude/index.test.js +3 -2
  165. package/server/lib/quota/providers/cline-pass.js +4 -4
  166. package/server/lib/quota/providers/codex.js +3 -4
  167. package/server/lib/quota/providers/codex.test.js +1 -1
  168. package/server/lib/quota/providers/copilot.js +4 -5
  169. package/server/lib/quota/providers/copilot.test.js +1 -1
  170. package/server/lib/quota/providers/deepseek.js +3 -4
  171. package/server/lib/quota/providers/deepseek.test.js +1 -1
  172. package/server/lib/quota/providers/google/auth.js +1 -3
  173. package/server/lib/quota/providers/google/index.js +3 -2
  174. package/server/lib/quota/providers/hyper.js +4 -4
  175. package/server/lib/quota/providers/index.js +9 -2
  176. package/server/lib/quota/providers/index.test.js +5 -3
  177. package/server/lib/quota/providers/kimi.js +16 -11
  178. package/server/lib/quota/providers/kimi.test.js +81 -38
  179. package/server/lib/quota/providers/minimax-shared.js +3 -4
  180. package/server/lib/quota/providers/nanogpt.js +3 -4
  181. package/server/lib/quota/providers/neuralwatt.js +3 -4
  182. package/server/lib/quota/providers/neuralwatt.test.js +1 -1
  183. package/server/lib/quota/providers/openai.js +2 -8
  184. package/server/lib/quota/providers/opencode-go.js +5 -5
  185. package/server/lib/quota/providers/opencode-go.test.js +1 -1
  186. package/server/lib/quota/providers/openrouter.js +30 -6
  187. package/server/lib/quota/providers/openrouter.test.js +122 -1
  188. package/server/lib/quota/providers/wafer.js +3 -4
  189. package/server/lib/quota/providers/xai.js +12 -12
  190. package/server/lib/quota/providers/zai.js +3 -4
  191. package/server/lib/quota/providers/zai.test.js +1 -1
  192. package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
  193. package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
  194. package/server/lib/quota/routes.js +1 -1
  195. package/server/lib/routing/DOCUMENTATION.md +4 -0
  196. package/server/lib/routing/runtime.js +45 -4
  197. package/server/lib/routing/runtime.test.js +35 -6
  198. package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
  199. package/server/lib/scheduled-tasks/chats-scope.js +50 -0
  200. package/server/lib/scheduled-tasks/runtime.js +57 -23
  201. package/server/lib/scheduled-tasks/runtime.test.js +103 -1
  202. package/server/lib/scheduled-tasks/service.js +37 -29
  203. package/server/lib/scheduled-tasks/service.test.js +39 -0
  204. package/server/lib/spaces/DOCUMENTATION.md +54 -9
  205. package/server/lib/spaces/host.js +24 -3
  206. package/server/lib/spaces/journey.js +111 -11
  207. package/server/lib/spaces/journey.test.js +189 -8
  208. package/server/lib/spaces/places/docker-disk.js +151 -0
  209. package/server/lib/spaces/places/docker-disk.test.js +167 -0
  210. package/server/lib/spaces/places/docker-tools.js +11 -1
  211. package/server/lib/spaces/places/docker.js +4 -2
  212. package/server/lib/spaces/places/fake-docker.js +36 -2
  213. package/server/lib/spaces/routes.js +21 -4
  214. package/server/lib/spaces/routes.test.js +6 -2
  215. package/server/lib/spaces/space-archive.js +275 -0
  216. package/server/lib/spaces/space-archive.test.js +194 -0
  217. package/server/lib/spaces/space-opencode.js +139 -6
  218. package/server/lib/spaces/space-opencode.test.js +82 -1
  219. package/server/lib/spaces/space-records.js +3 -0
  220. package/server/lib/spaces/space-setup.js +10 -5
  221. package/server/lib/spaces/space-setup.test.js +8 -2
  222. package/server/lib/terminal/DOCUMENTATION.md +1 -0
  223. package/server/lib/terminal/runtime.js +6 -1
  224. package/server/lib/terminal/runtime.test.js +19 -0
  225. package/server/lib/tts/routes.js +2 -2
  226. package/server/lib/tts/service.js +8 -8
  227. package/dist/assets/FilesView-CN34wm_N.js +0 -17
  228. package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
  229. package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
  230. package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
  231. package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
  232. package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
  233. package/dist/assets/SettingsWindow-CofS020b.js +0 -1
  234. package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
  235. package/dist/assets/de-DlgBHUAI.js +0 -10
  236. package/dist/assets/es-BC8G41U8.js +0 -16
  237. package/dist/assets/fr-I0z3vVjy.js +0 -14
  238. package/dist/assets/index-CgR5rJq_.js +0 -41
  239. package/dist/assets/index-adyy_sEk.css +0 -1
  240. package/dist/assets/ja-BIElEsY8.js +0 -16
  241. package/dist/assets/ko-DRnnHetA.js +0 -16
  242. package/dist/assets/main-DVX34beR.js +0 -886
  243. package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
  244. package/dist/assets/mobile-BrlBrNfZ.js +0 -2
  245. package/dist/assets/nl-DzUV-kwp.js +0 -16
  246. package/dist/assets/pl-Bb-cb7k7.js +0 -16
  247. package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
  248. package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
  249. package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
  250. package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
  251. package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
  252. package/dist/assets/tr-DXEDSoYO.js +0 -7
  253. package/dist/assets/uk-C8hN--q_.js +0 -16
  254. package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
  255. package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
  256. package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
  257. package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
  258. package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
  259. package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
  260. package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
  261. package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
  262. package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
  263. package/server/lib/opencode/credential-db.js +0 -144
  264. package/server/lib/opencode/credential-db.test.js +0 -104
@@ -1 +1 @@
1
- import{h7 as q}from"./useAppFontEffects-Dsl_sLrj.js";import{R as x,g as L,r as D,p as W,v as A,a as v,b as M,c as P,d as R,e as V,f as _,h as Q,i as y}from"./computeVirtualFileMetrics-6V1xNpO9.js";import{h as w,i as C,a as k,r as N}from"./isFilePlainText-CBAppvy1.js";import{a as g,i as I,r as $,b as j}from"./isDiffPlainText-1bXcWCrw.js";import{t as K}from"./themeResolver-BmJyTmjJ.js";import{L as S}from"./vendor-lru_map-Tstukz9J.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./index-CgR5rJq_.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-DSZl7jSi.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DnNniUWp.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.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-tanstack-react-virtual--0sBrLRh.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B1EetJur.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.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"./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"./vendor-diff-C3JhlQdm.js";function B(e){const t=[];for(const i of e){const s=x.get(i);if(s==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(s)}return t}function O(e){for(const t of Array.isArray(e)?e:[e])if(!x.has(t))return!1;return!0}async function b(e){const t=[],i=[];for(const s of e){if(s==="text"||s==="ansi")continue;const r=L(s)??D(s);"then"in r?i.push(r):t.push(r)}return i.length>0&&await Promise.all(i).then(s=>{for(const r of s){if(r==null)throw new Error("resolvedLanguages: unable to resolve language");t.push(r)}}),t}function z(e){return K.getResolvedThemes(e)}async function E(e){for(const i of e)W(i);const t=await K.resolveThemes(e);for(let i=0;i<e.length;i++)A(e[i],t[i]);return t}const p=Symbol("IGNORE_RESPONSE");var T=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},G=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=q,useTokenTransformer:s=!1,lineDiffType:r="word-alt",maxLineDiffLength:n=1e3,tokenizeMaxLineLength:a=1e3,preferredHighlighter:o="shiki-js"}){this.options=e,this.preferredHighlighter=o,this.renderOptions={theme:i,useTokenTransformer:s,lineDiffType:r,maxLineDiffLength:n,tokenizeMaxLineLength:a},this.fileCache=new S.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new S.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){const{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??q,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:s=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:r=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:n}=this,a=++this.renderOptionsRequestVersion,o=()=>this.isCurrentLifecycle(n)&&this.renderOptionsRequestVersion===a;try{const h={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:s,tokenizeMaxLineLength:r};if(this.isInitialized()||await this.initialize(),!o()||g(h,this.renderOptions))return;const l=v(e);let u=[];if(M(h.theme,this.renderOptions.theme)||(w(l)?u=z(l):u=await E(l)),!o())return;if(this.highlighter!=null)P(u,this.highlighter);else{const m=await R({themes:l,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!o())return;this.highlighter=m}const H=this.setRenderOptionsOnWorkers(h,u);this.renderOptions=h,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const m of this.themeSubscribers)m.onThemeChange();await H}catch(h){if(h instanceof T||!o())return;throw h}}getFileRenderOptions(){const{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:i}=this.renderOptions;return{theme:t,useTokenTransformer:i,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();const i=[];for(const s of this.workers){if(!s.initialized)throw console.log({managedWorker:s}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((r,n)=>{const a=this.generateRequestId(),o={type:"set-render-options",id:a,request:{type:"set-render-options",id:a,renderOptions:e,resolvedThemes:t},resolve:r,reject:n,requestStart:Date.now()};this.activeTaskById.set(a,o),s.pendingSetupRequestId=a,s.worker.postMessage(o.request)}))}await Promise.all(i)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast==null&&(this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges))}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);const e=this.getStats();for(const t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);const t=this.activeRequestByInstance.get(e);if(t!=null){const i=this.activeTaskById.get(t);c(i)?(this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeActiveTask(i)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){const{lifecycleGeneration:t}=this;this.initialized=new Promise((i,s)=>{(async()=>{try{const r=v(this.renderOptions.theme);let n=[];if(w(r)?n=z(r):n=await E(r),!this.isCurrentLifecycle(t)){i();return}let a=[];if(O(e)?a=B(e):a=await b(e),!this.isCurrentLifecycle(t)){i();return}const[o]=await Promise.all([R({themes:r,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(n,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),i();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),i()}catch(r){if(r instanceof T||!this.isCurrentLifecycle(t)){i();return}this.initialized=!1,this.workersFailed=!0,this.queueBroadcastStateChanges(),s(r)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],s=void 0;this.workers.length>0&&this.terminateWorkers();for(let r=0;r<(this.options.poolSize??8);r++){const n=this.options.workerFactory(),a={worker:n,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:o})=>o)]),customExtensionsVersion:0};n.addEventListener("message",o=>{this.handleWorkerMessage(a,o.data)}),n.addEventListener("error",o=>console.error("Worker error:",o,a)),this.workers.push(a),i.push(new Promise((o,h)=>{const l=this.generateRequestId(),u={type:"initialize",id:l,request:{type:"initialize",id:l,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:void 0,customExtensionMap:s},resolve(){a.initialized=!0,o()},reject:h,requestStart:Date.now()};this.activeTaskById.set(l,u),this.executeTask(a,u)}))}await Promise.all(i)}drainQueue=()=>{if(this._queuedDrain=void 0,!(this.initialized!==!0||this.queuedTasks.length===0)){for(let e=0;e<this.queuedTasks.length;){const t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}const i=F(t),s=this.getAvailableWorker(i);if(s==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,s),this.resolveLanguagesAndExecuteTask(s,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);C(t)||i!=null&&k(i.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}const t=this.getFileResultCache(e),i=this.getFileHighlightKey(e);if(i==null||C(e)||t!=null&&k(t.options,this.getFileRenderOptions()))return;const s=this.getTaskByHighlightKey(i);s!=null?s.primeCache=!0:this.submitCacheTask({type:"file",file:e},i)}getPlainFileAST(e,t,i,s){if(this.highlighter==null){this.queueInitialization();return}return N(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:s})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);I(t)||i!=null&&g(i.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}const t=this.getDiffResultCache(e),i=this.getDiffHighlightKey(e);if(i==null||I(e)||t!=null&&g(t.options,this.getDiffRenderOptions()))return;const s=this.getTaskByHighlightKey(i);s!=null?s.primeCache=!0:this.submitCacheTask({type:"diff",diff:e},i)}getPlainDiffAST(e,t,i,s,r){return this.highlighter!=null?$(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:s,collapsedContextThreshold:r}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{console.error(t)})}cancelActiveWorkerTasks(){const e=new T;for(const t of this.activeTaskById.values())"reject"in t&&t.reject(e)}terminateWorkers(){for(const e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?"waiting":this.initialized!==!0?"initializing":"initialized",totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.getHighlightKeyForRequest(t),s=i!=null?this.getTaskByHighlightKey(i):void 0;if(s!=null){this.detachInstanceFromQueuedTasks(e,s),this.addInstanceToTask(s,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const r=this.generateRequestId(),n=Date.now(),{renderOptionsVersion:a}=this,o=(()=>{switch(t.type){case"file":return{type:"file",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,renderOptionsVersion:a,requestStart:n};case"diff":return{type:"diff",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,renderOptionsVersion:a,requestStart:n}}})();this.enqueueRenderTask(o,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:r}=this,n=(()=>{switch(e.type){case"file":return{type:"file",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,renderOptionsVersion:r,requestStart:s};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,renderOptionsVersion:r,requestStart:s}}})();this.enqueueRenderTask(n)}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,i){try{const s=i.filter(r=>!e.langs.has(r));if(s.length>0&&(O(s)?t.request.resolvedLanguages=B(s):t.request.resolvedLanguages=await b(s)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch{this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){const i=this.activeTaskById.get(t.id);try{if(i==null)throw p;if(t.type==="error"){const s=new Error(t.error);if(t.stack&&(s.stack=t.stack),"reject"in i)i.reject(s);else if(c(i))this.notifyHighlightError(i,s);else throw new Error("handleWorkerMessage: unknown task type");throw s}else switch(t.requestType){case"initialize":if(i.type!=="initialize")throw new Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,i.request),i.resolve();break;case"set-render-options":if(i.type!=="set-render-options")throw new Error("handleWorkerMessage: task/response dont match");i.resolve();break;case"file":{if(i.type!=="file")throw new Error("handleWorkerMessage: task/response dont match");const{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!k(r,this.getFileRenderOptions()))throw p;const{request:n}=i;this.syncCustomExtensionVersion(e,n),n.file.cacheKey!=null&&this.fileCache.set(n.file.cacheKey,{result:s,options:r}),this.notifyFileInstances(i,s,r);break}case"diff":{if(i.type!=="diff")throw new Error("handleWorkerMessage: task/response dont match");const{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!g(r,this.getDiffRenderOptions()))throw p;const{request:n}=i;this.syncCustomExtensionVersion(e,n),n.diff.cacheKey!=null&&this.diffCache.set(n.diff.cacheKey,{result:s,options:r}),this.notifyDiffInstances(i,s,r);break}}}catch(s){s!==p&&console.error(s,i,t)}this.cleanWorkerAndTask(e,i,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain==null&&(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,c(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,i=t?.id){e.requestId===i&&(e.requestId=void 0),e.pendingSetupRequestId===i&&(e.pendingSetupRequestId=void 0),t!=null&&(c(t)&&(this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){U(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(const i of F(t))e.langs.add(i);try{e.worker.postMessage(t.request)}catch(i){console.error("Failed to post message to worker:",i),c(t)?this.notifyHighlightError(t,i):"reject"in t&&t.reject(i),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;const i=Q();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=V())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(const i of this.workers){if(i.requestId!=null||i.pendingSetupRequestId!=null||!i.initialized)continue;if(t=i,e.length===0)break;let s=!0;for(const r of e)if(!i.langs.has(r)){s=!1;break}if(s)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(const t of d(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){const i=this.queuedTaskByInstance.get(e);i==null||i===t||(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeQueuedTask(i))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){const t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){const t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(const e of Array.from(this.activeTaskById.values()))c(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of d(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(const t of d(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of d(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of d(e))this.activeRequestByInstance.get(i)===e.id&&i.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="file"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&_(t,i.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="diff"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&j(i.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){const t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(const e of this.queuedTasks)yield e;for(const e of this.activeTaskById.values())c(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function U(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function F(e){const t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??y(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??y(e.request.diff.name)),t.add(e.request.diff.lang??y(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function c(e){return e?.type==="file"||e?.type==="diff"}function d(e){return e.instances}let f;function Zt({poolOptions:e,highlighterOptions:t}){return f??=new G(e,t),f}function ei(){f!=null&&(f.terminate(),f=void 0)}export{G as WorkerPoolManager,Zt as getOrCreateWorkerPoolSingleton,ei as terminateWorkerPoolSingleton};
1
+ import{hn as q}from"./useAppFontEffects-CeMgbeVa.js";import{R as x,g as L,r as D,p as W,v as A,a as v,b as M,c as P,d as R,e as V,f as _,h as Q,i as y}from"./computeVirtualFileMetrics-BmhViPMt.js";import{h as w,i as C,a as k,r as N}from"./isFilePlainText-n8k0lMTZ.js";import{a as g,i as I,r as $,b as j}from"./isDiffPlainText-CPDhzF1K.js";import{t as K}from"./themeResolver-BmJyTmjJ.js";import{L as S}from"./vendor-lru_map-Tstukz9J.js";import"./vendor-react-BUCujlKS.js";import"./vendor-scheduler-7OC5HNn7.js";import"./index-Btd2mmYT.js";import"./vendor-zod-CxRSdNoV.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-opencode-client-Byb4ZSqI.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-base-ui-DWgyZK2k.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-use-sync-external-store-D6wYuSt-.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-tanstack-react-virtual--0sBrLRh.js";import"./vendor-tanstack-virtual-core-BoA4iGMw.js";import"./vendor-framer-motion-Bq3iTZ6r.js";import"./vendor-motion-dom-DcCgeG69.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./contextPanelEmbeddedChat-CirXEPJq.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-CZcLdzDM.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state--21VQleR.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-8PpN-8l4.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Kgp6fZRE.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DetzHhtC.js";import"./vendor-codemirror-lang-json-CkdBRvqj.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-DY4CGDG2.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CQnNjmg9.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CdG1RXm1.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-B8HKnqZy.js";import"./vendor-codemirror-lang-python-B4MRHRva.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-ConqfjLn.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.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"./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"./vendor-diff-C3JhlQdm.js";function B(e){const t=[];for(const i of e){const s=x.get(i);if(s==null)throw new Error(`getResolvedLanguages: ${i} is not resolved. Please resolve languages before calling getResolvedLanguages`);t.push(s)}return t}function O(e){for(const t of Array.isArray(e)?e:[e])if(!x.has(t))return!1;return!0}async function b(e){const t=[],i=[];for(const s of e){if(s==="text"||s==="ansi")continue;const r=L(s)??D(s);"then"in r?i.push(r):t.push(r)}return i.length>0&&await Promise.all(i).then(s=>{for(const r of s){if(r==null)throw new Error("resolvedLanguages: unable to resolve language");t.push(r)}}),t}function z(e){return K.getResolvedThemes(e)}async function E(e){for(const i of e)W(i);const t=await K.resolveThemes(e);for(let i=0;i<e.length;i++)A(e[i],t[i]);return t}const p=Symbol("IGNORE_RESPONSE");var T=class extends Error{constructor(){super("WorkerPoolManager: operation canceled because the pool terminated")}},G=class{options;highlighter;preferredHighlighter;renderOptions;renderOptionsRequestVersion=0;renderOptionsVersion=0;initialized=!1;workers=[];queuedTasks=[];queuedTaskByInstance=new Map;taskByHighlightKey=new Map;activeTaskById=new Map;activeRequestByInstance=new Map;nextRequestId=0;themeSubscribers=new Set;workersFailed=!1;statSubscribers=new Set;fileCache;diffCache;_queuedBroadcast;lifecycleGeneration=0;constructor(e,{langs:t,theme:i=q,useTokenTransformer:s=!1,lineDiffType:r="word-alt",maxLineDiffLength:n=1e3,tokenizeMaxLineLength:a=1e3,preferredHighlighter:o="shiki-js"}){this.options=e,this.preferredHighlighter=o,this.renderOptions={theme:i,useTokenTransformer:s,lineDiffType:r,maxLineDiffLength:n,tokenizeMaxLineLength:a},this.fileCache=new S.LRUMap(e.totalASTLRUCacheSize??100),this.diffCache=new S.LRUMap(e.totalASTLRUCacheSize??100),this.queueInitialization(t)}isWorkingPool(){return!this.workersFailed}getFileResultCache(e){return e.cacheKey!=null?this.fileCache.get(e.cacheKey):void 0}getDiffResultCache(e){return e.cacheKey!=null?this.diffCache.get(e.cacheKey):void 0}inspectCaches(){const{fileCache:e,diffCache:t}=this;return{fileCache:e,diffCache:t}}evictFileFromCache(e){try{return this.fileCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}evictDiffFromCache(e){try{return this.diffCache.delete(e)!==void 0}finally{this.queueBroadcastStateChanges()}}async setRenderOptions({theme:e=this.renderOptions.theme??q,useTokenTransformer:t=this.renderOptions.useTokenTransformer??!1,lineDiffType:i=this.renderOptions.lineDiffType??"word-alt",maxLineDiffLength:s=this.renderOptions.maxLineDiffLength??1e3,tokenizeMaxLineLength:r=this.renderOptions.tokenizeMaxLineLength??1e3}){const{lifecycleGeneration:n}=this,a=++this.renderOptionsRequestVersion,o=()=>this.isCurrentLifecycle(n)&&this.renderOptionsRequestVersion===a;try{const h={theme:e,useTokenTransformer:t,lineDiffType:i,maxLineDiffLength:s,tokenizeMaxLineLength:r};if(this.isInitialized()||await this.initialize(),!o()||g(h,this.renderOptions))return;const l=v(e);let u=[];if(M(h.theme,this.renderOptions.theme)||(w(l)?u=z(l):u=await E(l)),!o())return;if(this.highlighter!=null)P(u,this.highlighter);else{const m=await R({themes:l,langs:["text"],preferredHighlighter:this.preferredHighlighter});if(!o())return;this.highlighter=m}const H=this.setRenderOptionsOnWorkers(h,u);this.renderOptions=h,this.renderOptionsVersion++,this.diffCache.clear(),this.fileCache.clear(),this.invalidateRenderTasks();for(const m of this.themeSubscribers)m.onThemeChange();await H}catch(h){if(h instanceof T||!o())return;throw h}}getFileRenderOptions(){const{tokenizeMaxLineLength:e,theme:t,useTokenTransformer:i}=this.renderOptions;return{theme:t,useTokenTransformer:i,tokenizeMaxLineLength:e}}getDiffRenderOptions(){return{...this.renderOptions}}async setRenderOptionsOnWorkers(e,t){if(this.workersFailed)return;this.isInitialized()||await this.initialize();const i=[];for(const s of this.workers){if(!s.initialized)throw console.log({managedWorker:s}),new Error("setRenderOptionsOnWorkers: Somehow we have an uninitialized worker");i.push(new Promise((r,n)=>{const a=this.generateRequestId(),o={type:"set-render-options",id:a,request:{type:"set-render-options",id:a,renderOptions:e,resolvedThemes:t},resolve:r,reject:n,requestStart:Date.now()};this.activeTaskById.set(a,o),s.pendingSetupRequestId=a,s.worker.postMessage(o.request)}))}await Promise.all(i)}subscribeToThemeChanges(e){return this.themeSubscribers.add(e),this.queueBroadcastStateChanges(),()=>{this.unsubscribeToThemeChanges(e),this.queueBroadcastStateChanges()}}unsubscribeToThemeChanges(e){this.themeSubscribers.delete(e),this.queueBroadcastStateChanges()}subscribeToStatChanges(e){return this.statSubscribers.add(e),e(this.getStats()),()=>{this.statSubscribers.delete(e)}}queueBroadcastStateChanges(){this._queuedBroadcast==null&&(this._queuedBroadcast=requestAnimationFrame(this._broadcastStateChanges))}_broadcastStateChanges=()=>{this._queuedBroadcast!=null&&(cancelAnimationFrame(this._queuedBroadcast),this._queuedBroadcast=void 0);const e=this.getStats();for(const t of this.statSubscribers)t(e)};cleanUpTasks(e){this.detachInstanceFromQueuedTasks(e);const t=this.activeRequestByInstance.get(e);if(t!=null){const i=this.activeTaskById.get(t);c(i)?(this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeActiveTask(i)):this.activeTaskById.delete(t)}this.activeRequestByInstance.delete(e),this.queueBroadcastStateChanges()}isInitialized(){return this.initialized===!0}async initialize(e=[]){if(this.initialized!==!0)if(this.initialized===!1){const{lifecycleGeneration:t}=this;this.initialized=new Promise((i,s)=>{(async()=>{try{const r=v(this.renderOptions.theme);let n=[];if(w(r)?n=z(r):n=await E(r),!this.isCurrentLifecycle(t)){i();return}let a=[];if(O(e)?a=B(e):a=await b(e),!this.isCurrentLifecycle(t)){i();return}const[o]=await Promise.all([R({themes:r,langs:["text",...e],preferredHighlighter:this.preferredHighlighter}),this.initializeWorkers(n,a)]);if(!this.isCurrentLifecycle(t)){this.terminateWorkers(),i();return}this.highlighter=o,this.initialized=!0,this.diffCache.clear(),this.fileCache.clear(),this.drainQueue(),this.queueBroadcastStateChanges(),i()}catch(r){if(r instanceof T||!this.isCurrentLifecycle(t)){i();return}this.initialized=!1,this.workersFailed=!0,this.queueBroadcastStateChanges(),s(r)}})()}),this.queueBroadcastStateChanges()}else return this.initialized}async initializeWorkers(e,t){this.workersFailed=!1;const i=[],s=void 0;this.workers.length>0&&this.terminateWorkers();for(let r=0;r<(this.options.poolSize??8);r++){const n=this.options.workerFactory(),a={worker:n,requestId:void 0,pendingSetupRequestId:void 0,initialized:!1,langs:new Set(["text",...t.map(({name:o})=>o)]),customExtensionsVersion:0};n.addEventListener("message",o=>{this.handleWorkerMessage(a,o.data)}),n.addEventListener("error",o=>console.error("Worker error:",o,a)),this.workers.push(a),i.push(new Promise((o,h)=>{const l=this.generateRequestId(),u={type:"initialize",id:l,request:{type:"initialize",id:l,renderOptions:this.renderOptions,preferredHighlighter:this.preferredHighlighter,resolvedThemes:e,resolvedLanguages:t,customExtensionsVersion:void 0,customExtensionMap:s},resolve(){a.initialized=!0,o()},reject:h,requestStart:Date.now()};this.activeTaskById.set(l,u),this.executeTask(a,u)}))}await Promise.all(i)}drainQueue=()=>{if(this._queuedDrain=void 0,!(this.initialized!==!0||this.queuedTasks.length===0)){for(let e=0;e<this.queuedTasks.length;){const t=this.queuedTasks[e];if(this.hasActiveRequest(t)){e++;continue}const i=F(t),s=this.getAvailableWorker(i);if(s==null)break;this.queuedTasks.splice(e,1),this.assignWorkerToTask(t,s),this.resolveLanguagesAndExecuteTask(s,t,i)}this.queueBroadcastStateChanges()}};highlightFileAST(e,t){const i=this.getFileResultCache(t);C(t)||i!=null&&k(i.options,this.getFileRenderOptions())||this.hasMatchingFileInstanceTask(e,t)||this.submitTask(e,{type:"file",file:t})}primeFileHighlightCache(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeFileHighlightCache: priming highlight cache requires file.cacheKey; skipping "${e.name}".`);return}const t=this.getFileResultCache(e),i=this.getFileHighlightKey(e);if(i==null||C(e)||t!=null&&k(t.options,this.getFileRenderOptions()))return;const s=this.getTaskByHighlightKey(i);s!=null?s.primeCache=!0:this.submitCacheTask({type:"file",file:e},i)}getPlainFileAST(e,t,i,s){if(this.highlighter==null){this.queueInitialization();return}return N(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,lines:s})}highlightDiffAST(e,t){const i=this.getDiffResultCache(t);I(t)||i!=null&&g(i.options,this.getDiffRenderOptions())||this.hasMatchingDiffInstanceTask(e,t)||this.submitTask(e,{type:"diff",diff:t})}primeDiffHighlightCache(e){if(e.cacheKey==null){console.warn(`WorkerPoolManager.primeDiffHighlightCache: priming highlight cache requires diff.cacheKey; skipping "${e.prevName??e.name}" -> "${e.name}".`);return}const t=this.getDiffResultCache(e),i=this.getDiffHighlightKey(e);if(i==null||I(e)||t!=null&&g(t.options,this.getDiffRenderOptions()))return;const s=this.getTaskByHighlightKey(i);s!=null?s.primeCache=!0:this.submitCacheTask({type:"diff",diff:e},i)}getPlainDiffAST(e,t,i,s,r){return this.highlighter!=null?$(e,this.highlighter,this.renderOptions,{forcePlainText:!0,startingLine:t,totalLines:i,expandedHunks:s,collapsedContextThreshold:r}):void 0}terminate(){this.lifecycleGeneration++,this.cancelActiveWorkerTasks(),this.terminateWorkers(),this.fileCache.clear(),this.diffCache.clear(),this.activeRequestByInstance.clear(),this.queuedTasks.length=0,this.queuedTaskByInstance.clear(),this.taskByHighlightKey.clear(),this.activeTaskById.clear(),this.highlighter=void 0,this.initialized=!1,this.workersFailed=!1,this.queueBroadcastStateChanges()}isCurrentLifecycle(e){return this.lifecycleGeneration===e}queueInitialization(e){this.initialize(e).catch(t=>{console.error(t)})}cancelActiveWorkerTasks(){const e=new T;for(const t of this.activeTaskById.values())"reject"in t&&t.reject(e)}terminateWorkers(){for(const e of this.workers)e.worker.terminate();this.workers.length=0}getStats(){return{managerState:this.initialized===!1?"waiting":this.initialized!==!0?"initializing":"initialized",totalWorkers:this.workers.length,workersFailed:this.workersFailed,busyWorkers:this.workers.filter(e=>e.requestId!=null||e.pendingSetupRequestId!=null).length,queuedTasks:this.queuedTasks.length,activeTasks:this.activeTaskById.size,themeSubscribers:this.themeSubscribers.size,fileCacheSize:this.fileCache.size,diffCacheSize:this.diffCache.size}}submitTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.getHighlightKeyForRequest(t),s=i!=null?this.getTaskByHighlightKey(i):void 0;if(s!=null){this.detachInstanceFromQueuedTasks(e,s),this.addInstanceToTask(s,e),this.queueBroadcastStateChanges();return}this.detachInstanceFromQueuedTasks(e);const r=this.generateRequestId(),n=Date.now(),{renderOptionsVersion:a}=this,o=(()=>{switch(t.type){case"file":return{type:"file",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,renderOptionsVersion:a,requestStart:n};case"diff":return{type:"diff",id:r,request:{...t,id:r},instances:new Set([e]),primeCache:!1,highlightKey:i,renderOptionsVersion:a,requestStart:n}}})();this.enqueueRenderTask(o,e)}submitCacheTask(e,t){this.initialized===!1&&this.queueInitialization();const i=this.generateRequestId(),s=Date.now(),{renderOptionsVersion:r}=this,n=(()=>{switch(e.type){case"file":return{type:"file",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,renderOptionsVersion:r,requestStart:s};case"diff":return{type:"diff",id:i,request:{...e,id:i},instances:new Set,primeCache:!0,highlightKey:t,renderOptionsVersion:r,requestStart:s}}})();this.enqueueRenderTask(n)}enqueueRenderTask(e,t){this.queuedTasks.push(e),t!=null&&this.queuedTaskByInstance.set(t,e),e.highlightKey!=null&&this.taskByHighlightKey.set(e.highlightKey,e),this.queueDrain()}async resolveLanguagesAndExecuteTask(e,t,i){try{const s=i.filter(r=>!e.langs.has(r));if(s.length>0&&(O(s)?t.request.resolvedLanguages=B(s):t.request.resolvedLanguages=await b(s)),!this.activeTaskById.has(t.id)){e.requestId===t.id&&(this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain());return}this.executeTask(e,t)}catch{this.cleanWorkerAndTask(e,t),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}}handleWorkerMessage(e,t){const i=this.activeTaskById.get(t.id);try{if(i==null)throw p;if(t.type==="error"){const s=new Error(t.error);if(t.stack&&(s.stack=t.stack),"reject"in i)i.reject(s);else if(c(i))this.notifyHighlightError(i,s);else throw new Error("handleWorkerMessage: unknown task type");throw s}else switch(t.requestType){case"initialize":if(i.type!=="initialize")throw new Error("handleWorkerMessage: task/response dont match");this.syncCustomExtensionVersion(e,i.request),i.resolve();break;case"set-render-options":if(i.type!=="set-render-options")throw new Error("handleWorkerMessage: task/response dont match");i.resolve();break;case"file":{if(i.type!=="file")throw new Error("handleWorkerMessage: task/response dont match");const{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!k(r,this.getFileRenderOptions()))throw p;const{request:n}=i;this.syncCustomExtensionVersion(e,n),n.file.cacheKey!=null&&this.fileCache.set(n.file.cacheKey,{result:s,options:r}),this.notifyFileInstances(i,s,r);break}case"diff":{if(i.type!=="diff")throw new Error("handleWorkerMessage: task/response dont match");const{result:s,options:r}=t;if(!this.isCurrentRenderTask(i)||!g(r,this.getDiffRenderOptions()))throw p;const{request:n}=i;this.syncCustomExtensionVersion(e,n),n.diff.cacheKey!=null&&this.diffCache.set(n.diff.cacheKey,{result:s,options:r}),this.notifyDiffInstances(i,s,r);break}}}catch(s){s!==p&&console.error(s,i,t)}this.cleanWorkerAndTask(e,i,t.id),this.queueBroadcastStateChanges(),this.queuedTasks.length>0&&this.queueDrain()}_queuedDrain;queueDrain(){this._queuedDrain==null&&(this._queuedDrain=Promise.resolve().then(this.drainQueue),this.queueBroadcastStateChanges())}assignWorkerToTask(e,t){t.requestId=e.id,c(e)&&(this.clearQueuedInstanceRequests(e),this.trackInstanceRequests(e)),this.activeTaskById.set(e.id,e)}cleanWorkerAndTask(e,t,i=t?.id){e.requestId===i&&(e.requestId=void 0),e.pendingSetupRequestId===i&&(e.pendingSetupRequestId=void 0),t!=null&&(c(t)&&(this.clearInstanceRequests(t),this.clearHighlightKey(t)),this.activeTaskById.delete(t.id))}executeTask(e,t){U(t.request)&&this.maybeAttachCustomExtensions(e,t.request),this.activeTaskById.has(t.id)||this.assignWorkerToTask(t,e);for(const i of F(t))e.langs.add(i);try{e.worker.postMessage(t.request)}catch(i){console.error("Failed to post message to worker:",i),c(t)?this.notifyHighlightError(t,i):"reject"in t&&t.reject(i),this.cleanWorkerAndTask(e,t),this.queuedTasks.length>0&&this.queueDrain()}this.queueBroadcastStateChanges()}maybeAttachCustomExtensions(e,t){if(t.customExtensionsVersion!=null)return;const i=Q();e.customExtensionsVersion>=i||(t.customExtensionsVersion=i,t.customExtensionMap=V())}syncCustomExtensionVersion(e,t){t.customExtensionsVersion!=null&&(e.customExtensionsVersion=t.customExtensionsVersion)}getAvailableWorker(e){let t;for(const i of this.workers){if(i.requestId!=null||i.pendingSetupRequestId!=null||!i.initialized)continue;if(t=i,e.length===0)break;let s=!0;for(const r of e)if(!i.langs.has(r)){s=!1;break}if(s)break}return t}getFileHighlightKey(e){if(e.cacheKey!=null)return`file:${e.cacheKey}:${this.renderOptionsVersion}`}getDiffHighlightKey(e){if(e.cacheKey!=null)return`diff:${e.cacheKey}:${this.renderOptionsVersion}`}getHighlightKeyForRequest(e){switch(e.type){case"file":return this.getFileHighlightKey(e.file);case"diff":return this.getDiffHighlightKey(e.diff)}}hasActiveRequest(e){for(const t of d(e))if(this.activeRequestByInstance.has(t))return!0;return!1}addInstanceToTask(e,t){e.type,e.instances.add(t),this.activeTaskById.has(e.id)?this.activeRequestByInstance.set(t,e.id):this.queuedTaskByInstance.set(t,e)}detachInstanceFromQueuedTasks(e,t){const i=this.queuedTaskByInstance.get(e);i==null||i===t||(this.queuedTaskByInstance.delete(e),this.detachInstanceFromRenderTask(i,e),!i.primeCache&&i.instances.size===0&&this.removeQueuedTask(i))}detachInstanceFromRenderTask(e,t){e.type,e.instances.delete(t)}removeQueuedTask(e){const t=this.queuedTasks.indexOf(e);t!==-1&&this.queuedTasks.splice(t,1),this.clearQueuedInstanceRequests(e),this.clearHighlightKey(e)}removeActiveTask(e){this.clearInstanceRequests(e),this.clearHighlightKey(e),this.activeTaskById.delete(e.id)}invalidateRenderTasks(){for(let e=this.queuedTasks.length-1;e>=0;e--){const t=this.queuedTasks[e];t.renderOptionsVersion!==this.renderOptionsVersion&&this.removeQueuedTask(t)}for(const e of Array.from(this.activeTaskById.values()))c(e)&&e.renderOptionsVersion!==this.renderOptionsVersion&&this.removeActiveTask(e)}clearQueuedInstanceRequests(e){for(const t of d(e))this.queuedTaskByInstance.get(t)===e&&this.queuedTaskByInstance.delete(t)}clearHighlightKey(e){e.highlightKey!=null&&this.taskByHighlightKey.get(e.highlightKey)===e&&this.taskByHighlightKey.delete(e.highlightKey)}trackInstanceRequests(e){for(const t of d(e))this.activeRequestByInstance.set(t,e.id)}clearInstanceRequests(e){for(const t of d(e))this.activeRequestByInstance.get(t)===e.id&&this.activeRequestByInstance.delete(t)}notifyFileInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.file,t,i)}notifyDiffInstances(e,t,i){for(const s of e.instances)this.activeRequestByInstance.get(s)===e.id&&s.onHighlightSuccess(e.request.diff,t,i)}notifyHighlightError(e,t){for(const i of d(e))this.activeRequestByInstance.get(i)===e.id&&i.onHighlightError(t)}hasMatchingFileInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="file"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&_(t,i.request.file))return!0;return!1}hasMatchingDiffInstanceTask(e,t){for(const i of this.iterateRenderTasks())if(i.type==="diff"&&this.isCurrentRenderTask(i)&&i.instances.has(e)&&j(i.request.diff,t))return!0;return!1}getTaskByHighlightKey(e){const t=this.taskByHighlightKey.get(e);return t!=null&&this.isCurrentRenderTask(t)?t:void 0}isCurrentRenderTask(e){return e.renderOptionsVersion===this.renderOptionsVersion}*iterateRenderTasks(){for(const e of this.queuedTasks)yield e;for(const e of this.activeTaskById.values())c(e)&&(yield e)}generateRequestId(){return`req_${++this.nextRequestId}`}};function U(e){return e.type==="initialize"||e.type==="file"||e.type==="diff"}function F(e){const t=new Set;if(e.type==="initialize"||e.type==="set-render-options")return[];switch(e.type){case"file":t.add(e.request.file.lang??y(e.request.file.name));break;case"diff":t.add(e.request.diff.lang??y(e.request.diff.name)),t.add(e.request.diff.lang??y(e.request.diff.prevName??"-"));break}return t.delete("text"),Array.from(t)}function c(e){return e?.type==="file"||e?.type==="diff"}function d(e){return e.instances}let f;function Zt({poolOptions:e,highlighterOptions:t}){return f??=new G(e,t),f}function ei(){f!=null&&(f.terminate(),f=void 0)}export{G as WorkerPoolManager,Zt as getOrCreateWorkerPoolSingleton,ei as terminateWorkerPoolSingleton};
@@ -1 +1 @@
1
- import{b as q,x as K,y as G,i as M,z as J,B as W,C as P}from"./computeVirtualFileMetrics-6V1xNpO9.js";import{h7 as j,lf as z}from"./useAppFontEffects-Dsl_sLrj.js";import{d as X,a as Q}from"./vendor-diff-C3JhlQdm.js";function gn(n,e){return n===e||n?.cacheKey!=null&&n.cacheKey===e?.cacheKey}function mn(n,e){return q(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function A({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function T({item:n,arr:e,enableJoin:r,isNeutral:l=!1,isLastItem:f=!1}){const t=e[e.length-1];if(t==null||f||!r){e.push([l?0:1,n.value]);return}const h=t[0]===0;if(l===h||l&&n.value.length===1&&!h){t[1]+=n.value;return}e.push([l?0:1,n.value])}function B({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:f}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=f)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(l),d=Math.min(Math.max(h?.fromStart??0,0),t),i=Math.min(Math.max(h?.fromEnd??0,0),t),u=d+i,o=u>=t;return{fromStart:o?t:d,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-u,0),renderAll:o}}function pn(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-(e.additionLineIndex+e.additionCount),l=n.deletionLines.length-(e.deletionLineIndex+e.deletionCount);return r<=0&&l<=0?!1:r!==l}function Y({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const l=n.additionLines.length-(r.additionLineIndex+r.additionCount),f=n.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(l<=0&&f<=0)return 0;if(l!==f)throw new Error(`${e}: trailing context mismatch (additions=${l}, deletions=${f}) for ${n.name}`);return Math.min(l,f)}function V({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:l,errorPrefix:f}){if(e!==n.hunks.length-1)return;const t=Y({fileDiff:n,errorPrefix:f});if(t<=0)return;if(r===!0||t<=l)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(n.hunks.length),d=Math.min(Math.max(h?.fromStart??0,0),t);return{fromStart:d,fromEnd:0,rangeSize:t,collapsedLines:t-d,renderAll:d>=t}}function $({type:n,metrics:e}){return e.hunkSeparatorHeight??K(n)}function U({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function Z({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function y(n){return n!=="simple"&&n!=="metadata"}function In({type:n,metrics:e,hunkIndex:r,hunkSpecs:l}){if(!Z({type:n,hunkIndex:r,hunkSpecs:l}))return;const f=$({type:n,metrics:e}),t=U({type:n,metrics:e}),h=r>0?t:0,d=t;return{height:f,gapBefore:h,gapAfter:d,totalHeight:h+f+d}}function Cn({type:n,metrics:e}){if(!y(n))return;const r=$({type:n,metrics:e}),l=U({type:n,metrics:e});return{height:r,gapBefore:l,gapAfter:0,totalHeight:l+r}}function nn({diff:n,diffStyle:e,startingLine:r=0,totalLines:l=1/0,expandedHunks:f,collapsedContextThreshold:t=1,callback:h}){const d=en({diff:n,diffStyle:e,startingLine:r,expandedHunks:f,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+l,isWindowedHighlight:r>0||l<1/0,splitCount:d.splitCount,unifiedCount:d.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const u=i.unifiedCount>=r+l,o=i.splitCount>=r+l;return e==="unified"?u:(e==="split"||u)&&o},shouldSkip(u,o){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount+u<r,a=i.splitCount+o<r;return e==="unified"?s:(e==="split"||s)&&a},incrementCounts(u,o){(e==="unified"||e==="both")&&(i.unifiedCount+=u),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(u,o){if(!i.isWindowedHighlight)return!0;const s=i.isInUnifiedWindow(u),a=i.isInSplitWindow(o);return e==="unified"?s:e==="split"?a:s||a},isInUnifiedWindow(u){return!i.isWindowedHighlight||i.unifiedCount>=r-u&&i.unifiedCount<r+l},isInSplitWindow(u){return!i.isWindowedHighlight||i.splitCount>=r-u&&i.splitCount<r+l},emit(u,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),h(u)??!1}};n:for(let u=d.hunkIndex;u<n.hunks.length;u++){let g=function(c,p){return a==null||a.collapsedLines<=0||a.fromStart+a.fromEnd>0?0:e==="unified"?c===o.unifiedLineStart+o.unifiedLineCount-1?a.collapsedLines:0:p===o.splitLineStart+o.splitLineCount-1?a.collapsedLines:0},b=function(){return O?0:(O=!0,s.collapsedLines)};const o=n.hunks[u];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const s=B({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:f,hunkIndex:u,collapsedContextThreshold:t}),a=u===i.finalHunkIndex?V({fileDiff:n,hunkIndex:u,expandedHunks:f,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,m=s.fromStart+s.fromEnd;let O=s.collapsedLines===0;if(i.shouldSkip(m,m))i.incrementCounts(m,m),b();else{let c=o.unifiedLineStart-s.rangeSize,p=o.splitLineStart-s.rangeSize,k=o.deletionLineIndex-s.rangeSize,R=o.additionLineIndex-s.rangeSize,S=o.deletionStart-s.rangeSize,H=o.additionStart-s.rangeSize;if(F(i,s.fromStart,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}))||(c=o.unifiedLineStart-s.fromEnd,p=o.splitLineStart-s.fromEnd,k=o.deletionLineIndex-s.fromEnd,R=o.additionLineIndex-s.fromEnd,S=o.deletionStart-s.fromEnd,H=o.additionStart-s.fromEnd,F(i,s.fromEnd,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}),()=>{b()})))break n}let N=o.unifiedLineStart,w=o.splitLineStart,I=o.deletionLineIndex,C=o.additionLineIndex,L=o.deletionStart,v=o.additionStart;const x=o.hunkContent.at(-1);for(const c of o.hunkContent){if(i.shouldBreak())break n;const p=c===x;if(c.type==="context"){if(i.shouldSkip(c.lines,c.lines))i.incrementCounts(c.lines,c.lines),b();else if(F(i,c.lines,e,k=>{const R=p&&k===c.lines-1,S=N+k,H=w+k;return i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:g(S,H),type:"context",deletionLine:{lineNumber:L+k,lineIndex:I+k,noEOFCR:R&&o.noEOFCRDeletions,unifiedLineIndex:S,splitLineIndex:H},additionLine:{unifiedLineIndex:S,splitLineIndex:H,lineIndex:C+k,lineNumber:v+k,noEOFCR:R&&o.noEOFCRAdditions}})},()=>{b()}))break n;N+=c.lines,w+=c.lines,I+=c.lines,C+=c.lines,L+=c.lines,v+=c.lines}else{const k=Math.max(c.deletions,c.additions),R=c.deletions+c.additions;if(!i.shouldSkip(R,k)){const S=rn(i,c,e);(S[0]?.[0]??0)>0&&b();for(const[H,E]of S)for(let D=H;D<E;D++){const _=g(N+D,e==="unified"?w+(D<c.deletions?D:D-c.deletions):w+D);if(i.emit(sn({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:_,diffStyle:e,index:D,unifiedLineIndex:N,splitLineIndex:w,additionLineIndex:C,deletionLineIndex:I,additionLineNumber:v,deletionLineNumber:L,content:c,isLastContent:p,unifiedCount:R,splitCount:k}),!0))break n}}b(),i.incrementCounts(R,k),N+=R,w+=k,I+=c.deletions,C+=c.additions,L+=c.deletions,v+=c.additions}}if(a!=null){const{collapsedLines:c,fromStart:p,fromEnd:k}=a,R=p+k;if(F(i,R,e,S=>{const H=S===R-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:H?c:0,type:"context-expanded",deletionLine:{lineNumber:L+S,lineIndex:I+S,noEOFCR:!1,unifiedLineIndex:N+S,splitLineIndex:w+S},additionLine:{unifiedLineIndex:N+S,splitLineIndex:w+S,lineIndex:C+S,lineNumber:v+S,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function en({diff:n,diffStyle:e,startingLine:r,expandedHunks:l,collapsedContextThreshold:f}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=tn({diff:n,expandedHunks:l,collapsedContextThreshold:f});let h=0,d=n.hunks.length-1,i=n.hunks.length;for(;h<=d;){const o=h+d>>1,s=t[o+1];if(s==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?s.unifiedCount:s.splitCount)>r?(i=o,d=o-1):h=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const u=t[i];if(u==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:u.splitCount,unifiedCount:u.unifiedCount}}function tn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let l=0,f=0;const t=n.hunks.length-1,h=[{splitCount:0,unifiedCount:0}];for(let d=0;d<n.hunks.length;d++){const i=n.hunks[d];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const u=B({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:d,collapsedContextThreshold:r}),o=u.fromStart+u.fromEnd;l+=o+i.splitLineCount,f+=o+i.unifiedLineCount;const s=d===t?V({fileDiff:n,hunkIndex:d,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(s!=null){const a=s.fromStart+s.fromEnd;l+=a,f+=a}h.push({splitCount:l,unifiedCount:f})}return h}function on(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const l=[];function f(d){const i=Math.max(0,n.viewportStart-d),u=Math.min(e,n.viewportEnd-d);u>i&&l.push([i,u])}if(r!=="split"&&f(n.unifiedCount),r!=="unified"&&f(n.splitCount),l.length===0)return[0,0];let t=l[0][0],h=l[0][1];for(let d=1;d<l.length;d++){const i=l[d];t=Math.min(t,i[0]),h=Math.max(h,i[1])}return[t,h]}function F(n,e,r,l,f,t){const[h,d]=on(n,e,r);h>0&&(n.incrementCounts(h,h),f?.());let i=h;for(;i<e;){if(t?.()===!0)return!0;if(i>=d){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(l(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function rn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const l=r!=="split",f=r!=="unified",t=r==="unified"?"unified":"split",h=[];function d(s,a){if(s+a<=n.viewportStart||s>=n.viewportEnd)return;const m=Math.max(0,n.viewportStart-s),g=Math.min(a,n.viewportEnd-s);return g>m?[m,g]:void 0}function i(s,a){return t==="split"?s:a==="additions"?[s[0]+e.deletions,s[1]+e.deletions]:s}function u(s,a){if(s==null)return;const[m,g]=i(s,a);g>m&&h.push([m,g])}if(l&&(u(d(n.unifiedCount,e.deletions),"deletions"),u(d(n.unifiedCount+e.deletions,e.additions),"additions")),f&&(u(d(n.splitCount,e.deletions),"deletions"),u(d(n.splitCount,e.additions),"additions")),h.length===0)return h;h.sort((s,a)=>s[0]-a[0]);const o=[h[0]];for(const[s,a]of h.slice(1)){const m=o[o.length-1];s<=m[1]?m[1]=Math.max(m[1],a):o.push([s,a])}return o}function sn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,diffStyle:f,index:t,unifiedLineIndex:h,splitLineIndex:d,additionLineIndex:i,deletionLineIndex:u,additionLineNumber:o,deletionLineNumber:s,content:a,isLastContent:m,unifiedCount:g,splitCount:O}){const b=t<a.deletions?h+t:void 0,N=f==="unified"?t>=a.deletions?h+t:void 0:t<a.additions?h+a.deletions+t:void 0,w=f==="unified"?d+(t<a.deletions?t:t-a.deletions):d+t,I=t<a.deletions?u+t:void 0,C=t<a.deletions?s+t:void 0,L=f==="unified"?t>=a.deletions?i+(t-a.deletions):void 0:t<a.additions?i+t:void 0,v=f==="unified"?t>=a.deletions?o+(t-a.deletions):void 0:t<a.additions?o+t:void 0,x=f==="unified"?m&&t===a.deletions-1&&e.noEOFCRDeletions:m&&t===O-1&&e.noEOFCRDeletions,c=f==="unified"?m&&t===g-1&&e.noEOFCRAdditions:m&&t===O-1&&e.noEOFCRAdditions,p=I!=null&&C!=null&&b!=null?{lineNumber:C,lineIndex:I,noEOFCR:x,unifiedLineIndex:b,splitLineIndex:w}:void 0,k=L!=null&&v!=null&&N!=null?{unifiedLineIndex:N,splitLineIndex:w,lineIndex:L,lineNumber:v,noEOFCR:c}:void 0;if(p==null&&k!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:void 0,additionLine:k};if(p!=null&&k==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:void 0};if(p==null||k==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:k}}const ln={forcePlainText:!1};function Ln(n,e,r,{forcePlainText:l,startingLine:f,totalLines:t,expandedHunks:h,collapsedContextThreshold:d=1}=ln){l?(f??=0,t??=1/0):(f=0,t=1/0);const i=f>0||t<1/0,u=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,o=G({theme:r.theme,highlighter:e}),s=l&&!i&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,a={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,g=!l&&!n.isPartial,O=l?h:void 0,b=new Map;function N(I){const C=g?0:I,L=b.get(C)??un();return b.set(C,L),L}function w(I,C,L,v){if(i){let x=L.at(-1);(x==null||x.targetIndex+x.count!==C)&&(x={targetIndex:C,originalOffset:v.length,count:0},L.push(x)),x.count++}v.push(I)}nn({diff:n,diffStyle:"both",startingLine:f,totalLines:t,expandedHunks:i?O:!0,collapsedContextThreshold:d,callback:({hunkIndex:I,additionLine:C,deletionLine:L,type:v})=>{const x=N(I),c=C!=null?C.splitLineIndex:L.splitLineIndex;v==="change"&&C!=null&&L!=null&&an({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[L.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:s,maxLineDiffLength:m}),L!=null&&(w(n.deletionLines[L.lineIndex],L.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:L.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${L.unifiedLineIndex},${c}`})),C!=null&&(w(n.additionLines[C.lineIndex],C.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:L.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${c}`}))}});for(const I of b.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},L={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:x}=dn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:L,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:l?"text":n.lang});if(g){a.deletionLines=v,a.additionLines=x;continue}if(I.deletionSegments.length>0)for(const c of I.deletionSegments)for(let p=0;p<c.count;p++)a.deletionLines[c.targetIndex+p]=v[c.originalOffset+p];else a.deletionLines.push(...v);if(I.additionSegments.length>0)for(const c of I.additionSegments)for(let p=0;p<c.count;p++)a.additionLines[c.targetIndex+p]=x[c.originalOffset+p];else a.additionLines.push(...x)}return{code:a,themeStyles:o,baseThemeType:u}}function an({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:l,deletionDecorations:f,additionDecorations:t,lineDiffType:h,maxLineDiffLength:d}){if(n==null||e==null||h==="none"||(n=z(n),e=z(e),n.length>d||e.length>d))return;const i=h==="char"?X(n,e):Q(n,e),u=[],o=[],s=h==="word-alt",a=i.at(-1);for(const g of i){const O=g===a;!g.added&&!g.removed?(T({item:g,arr:u,enableJoin:s,isNeutral:!0,isLastItem:O}),T({item:g,arr:o,enableJoin:s,isNeutral:!0,isLastItem:O})):g.removed?T({item:g,arr:u,enableJoin:s,isLastItem:O}):T({item:g,arr:o,enableJoin:s,isLastItem:O})}let m=0;for(const g of u)g[0]===1&&f.push(A({line:r,spanStart:m,spanLength:g[1].length})),m+=g[1].length;m=0;for(const g of o)g[0]===1&&t.push(A({line:l,spanStart:m,spanLength:g[1].length})),m+=g[1].length}function un(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function dn({deletionFile:n,additionFile:e,deletionInfo:r,additionInfo:l,highlighter:f,deletionDecorations:t,additionDecorations:h,languageOverride:d,options:{theme:i=j,...u}}){const o=d??M(n.name),s=d??M(e.name),{state:a,transformers:m}=J(u.useTokenTransformer),g=typeof i=="string"?{...u,lang:"text",theme:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0}:{...u,lang:"text",themes:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0};return{deletionLines:n.contents===""?[]:(g.lang=o,a.lineInfo=r,g.decorations=t,P(f.codeToHast(z(n.contents),g))),additionLines:e.contents===""?[]:(g.lang=s,g.decorations=h,a.lineInfo=l,P(f.codeToHast(z(e.contents),g)))}}function xn(n){const e=n.lang??M(n.name),r=n.lang??(n.prevName!=null?M(n.prevName):"text");return e==="text"&&r==="text"}export{mn as a,gn as b,nn as c,B as d,In as e,V as f,Y as g,pn as h,xn as i,Cn as j,Ln as r};
1
+ import{b as q,x as K,y as G,i as M,z as J,B as W,C as P}from"./computeVirtualFileMetrics-BmhViPMt.js";import{hn as j,ly as z}from"./useAppFontEffects-CeMgbeVa.js";import{d as X,a as Q}from"./vendor-diff-C3JhlQdm.js";function gn(n,e){return n===e||n?.cacheKey!=null&&n.cacheKey===e?.cacheKey}function mn(n,e){return q(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function A({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function T({item:n,arr:e,enableJoin:r,isNeutral:l=!1,isLastItem:f=!1}){const t=e[e.length-1];if(t==null||f||!r){e.push([l?0:1,n.value]);return}const h=t[0]===0;if(l===h||l&&n.value.length===1&&!h){t[1]+=n.value;return}e.push([l?0:1,n.value])}function B({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:f}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=f)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(l),d=Math.min(Math.max(h?.fromStart??0,0),t),i=Math.min(Math.max(h?.fromEnd??0,0),t),u=d+i,o=u>=t;return{fromStart:o?t:d,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-u,0),renderAll:o}}function pn(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-(e.additionLineIndex+e.additionCount),l=n.deletionLines.length-(e.deletionLineIndex+e.deletionCount);return r<=0&&l<=0?!1:r!==l}function Y({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const l=n.additionLines.length-(r.additionLineIndex+r.additionCount),f=n.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(l<=0&&f<=0)return 0;if(l!==f)throw new Error(`${e}: trailing context mismatch (additions=${l}, deletions=${f}) for ${n.name}`);return Math.min(l,f)}function V({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:l,errorPrefix:f}){if(e!==n.hunks.length-1)return;const t=Y({fileDiff:n,errorPrefix:f});if(t<=0)return;if(r===!0||t<=l)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(n.hunks.length),d=Math.min(Math.max(h?.fromStart??0,0),t);return{fromStart:d,fromEnd:0,rangeSize:t,collapsedLines:t-d,renderAll:d>=t}}function $({type:n,metrics:e}){return e.hunkSeparatorHeight??K(n)}function U({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function Z({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function y(n){return n!=="simple"&&n!=="metadata"}function In({type:n,metrics:e,hunkIndex:r,hunkSpecs:l}){if(!Z({type:n,hunkIndex:r,hunkSpecs:l}))return;const f=$({type:n,metrics:e}),t=U({type:n,metrics:e}),h=r>0?t:0,d=t;return{height:f,gapBefore:h,gapAfter:d,totalHeight:h+f+d}}function Cn({type:n,metrics:e}){if(!y(n))return;const r=$({type:n,metrics:e}),l=U({type:n,metrics:e});return{height:r,gapBefore:l,gapAfter:0,totalHeight:l+r}}function nn({diff:n,diffStyle:e,startingLine:r=0,totalLines:l=1/0,expandedHunks:f,collapsedContextThreshold:t=1,callback:h}){const d=en({diff:n,diffStyle:e,startingLine:r,expandedHunks:f,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+l,isWindowedHighlight:r>0||l<1/0,splitCount:d.splitCount,unifiedCount:d.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const u=i.unifiedCount>=r+l,o=i.splitCount>=r+l;return e==="unified"?u:(e==="split"||u)&&o},shouldSkip(u,o){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount+u<r,a=i.splitCount+o<r;return e==="unified"?s:(e==="split"||s)&&a},incrementCounts(u,o){(e==="unified"||e==="both")&&(i.unifiedCount+=u),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(u,o){if(!i.isWindowedHighlight)return!0;const s=i.isInUnifiedWindow(u),a=i.isInSplitWindow(o);return e==="unified"?s:e==="split"?a:s||a},isInUnifiedWindow(u){return!i.isWindowedHighlight||i.unifiedCount>=r-u&&i.unifiedCount<r+l},isInSplitWindow(u){return!i.isWindowedHighlight||i.splitCount>=r-u&&i.splitCount<r+l},emit(u,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),h(u)??!1}};n:for(let u=d.hunkIndex;u<n.hunks.length;u++){let g=function(c,p){return a==null||a.collapsedLines<=0||a.fromStart+a.fromEnd>0?0:e==="unified"?c===o.unifiedLineStart+o.unifiedLineCount-1?a.collapsedLines:0:p===o.splitLineStart+o.splitLineCount-1?a.collapsedLines:0},b=function(){return O?0:(O=!0,s.collapsedLines)};const o=n.hunks[u];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const s=B({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:f,hunkIndex:u,collapsedContextThreshold:t}),a=u===i.finalHunkIndex?V({fileDiff:n,hunkIndex:u,expandedHunks:f,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,m=s.fromStart+s.fromEnd;let O=s.collapsedLines===0;if(i.shouldSkip(m,m))i.incrementCounts(m,m),b();else{let c=o.unifiedLineStart-s.rangeSize,p=o.splitLineStart-s.rangeSize,k=o.deletionLineIndex-s.rangeSize,R=o.additionLineIndex-s.rangeSize,S=o.deletionStart-s.rangeSize,H=o.additionStart-s.rangeSize;if(F(i,s.fromStart,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}))||(c=o.unifiedLineStart-s.fromEnd,p=o.splitLineStart-s.fromEnd,k=o.deletionLineIndex-s.fromEnd,R=o.additionLineIndex-s.fromEnd,S=o.deletionStart-s.fromEnd,H=o.additionStart-s.fromEnd,F(i,s.fromEnd,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}),()=>{b()})))break n}let N=o.unifiedLineStart,w=o.splitLineStart,I=o.deletionLineIndex,C=o.additionLineIndex,L=o.deletionStart,v=o.additionStart;const x=o.hunkContent.at(-1);for(const c of o.hunkContent){if(i.shouldBreak())break n;const p=c===x;if(c.type==="context"){if(i.shouldSkip(c.lines,c.lines))i.incrementCounts(c.lines,c.lines),b();else if(F(i,c.lines,e,k=>{const R=p&&k===c.lines-1,S=N+k,H=w+k;return i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:g(S,H),type:"context",deletionLine:{lineNumber:L+k,lineIndex:I+k,noEOFCR:R&&o.noEOFCRDeletions,unifiedLineIndex:S,splitLineIndex:H},additionLine:{unifiedLineIndex:S,splitLineIndex:H,lineIndex:C+k,lineNumber:v+k,noEOFCR:R&&o.noEOFCRAdditions}})},()=>{b()}))break n;N+=c.lines,w+=c.lines,I+=c.lines,C+=c.lines,L+=c.lines,v+=c.lines}else{const k=Math.max(c.deletions,c.additions),R=c.deletions+c.additions;if(!i.shouldSkip(R,k)){const S=rn(i,c,e);(S[0]?.[0]??0)>0&&b();for(const[H,E]of S)for(let D=H;D<E;D++){const _=g(N+D,e==="unified"?w+(D<c.deletions?D:D-c.deletions):w+D);if(i.emit(sn({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:_,diffStyle:e,index:D,unifiedLineIndex:N,splitLineIndex:w,additionLineIndex:C,deletionLineIndex:I,additionLineNumber:v,deletionLineNumber:L,content:c,isLastContent:p,unifiedCount:R,splitCount:k}),!0))break n}}b(),i.incrementCounts(R,k),N+=R,w+=k,I+=c.deletions,C+=c.additions,L+=c.deletions,v+=c.additions}}if(a!=null){const{collapsedLines:c,fromStart:p,fromEnd:k}=a,R=p+k;if(F(i,R,e,S=>{const H=S===R-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:H?c:0,type:"context-expanded",deletionLine:{lineNumber:L+S,lineIndex:I+S,noEOFCR:!1,unifiedLineIndex:N+S,splitLineIndex:w+S},additionLine:{unifiedLineIndex:N+S,splitLineIndex:w+S,lineIndex:C+S,lineNumber:v+S,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function en({diff:n,diffStyle:e,startingLine:r,expandedHunks:l,collapsedContextThreshold:f}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=tn({diff:n,expandedHunks:l,collapsedContextThreshold:f});let h=0,d=n.hunks.length-1,i=n.hunks.length;for(;h<=d;){const o=h+d>>1,s=t[o+1];if(s==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?s.unifiedCount:s.splitCount)>r?(i=o,d=o-1):h=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const u=t[i];if(u==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:u.splitCount,unifiedCount:u.unifiedCount}}function tn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let l=0,f=0;const t=n.hunks.length-1,h=[{splitCount:0,unifiedCount:0}];for(let d=0;d<n.hunks.length;d++){const i=n.hunks[d];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const u=B({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:d,collapsedContextThreshold:r}),o=u.fromStart+u.fromEnd;l+=o+i.splitLineCount,f+=o+i.unifiedLineCount;const s=d===t?V({fileDiff:n,hunkIndex:d,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(s!=null){const a=s.fromStart+s.fromEnd;l+=a,f+=a}h.push({splitCount:l,unifiedCount:f})}return h}function on(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const l=[];function f(d){const i=Math.max(0,n.viewportStart-d),u=Math.min(e,n.viewportEnd-d);u>i&&l.push([i,u])}if(r!=="split"&&f(n.unifiedCount),r!=="unified"&&f(n.splitCount),l.length===0)return[0,0];let t=l[0][0],h=l[0][1];for(let d=1;d<l.length;d++){const i=l[d];t=Math.min(t,i[0]),h=Math.max(h,i[1])}return[t,h]}function F(n,e,r,l,f,t){const[h,d]=on(n,e,r);h>0&&(n.incrementCounts(h,h),f?.());let i=h;for(;i<e;){if(t?.()===!0)return!0;if(i>=d){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(l(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function rn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const l=r!=="split",f=r!=="unified",t=r==="unified"?"unified":"split",h=[];function d(s,a){if(s+a<=n.viewportStart||s>=n.viewportEnd)return;const m=Math.max(0,n.viewportStart-s),g=Math.min(a,n.viewportEnd-s);return g>m?[m,g]:void 0}function i(s,a){return t==="split"?s:a==="additions"?[s[0]+e.deletions,s[1]+e.deletions]:s}function u(s,a){if(s==null)return;const[m,g]=i(s,a);g>m&&h.push([m,g])}if(l&&(u(d(n.unifiedCount,e.deletions),"deletions"),u(d(n.unifiedCount+e.deletions,e.additions),"additions")),f&&(u(d(n.splitCount,e.deletions),"deletions"),u(d(n.splitCount,e.additions),"additions")),h.length===0)return h;h.sort((s,a)=>s[0]-a[0]);const o=[h[0]];for(const[s,a]of h.slice(1)){const m=o[o.length-1];s<=m[1]?m[1]=Math.max(m[1],a):o.push([s,a])}return o}function sn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,diffStyle:f,index:t,unifiedLineIndex:h,splitLineIndex:d,additionLineIndex:i,deletionLineIndex:u,additionLineNumber:o,deletionLineNumber:s,content:a,isLastContent:m,unifiedCount:g,splitCount:O}){const b=t<a.deletions?h+t:void 0,N=f==="unified"?t>=a.deletions?h+t:void 0:t<a.additions?h+a.deletions+t:void 0,w=f==="unified"?d+(t<a.deletions?t:t-a.deletions):d+t,I=t<a.deletions?u+t:void 0,C=t<a.deletions?s+t:void 0,L=f==="unified"?t>=a.deletions?i+(t-a.deletions):void 0:t<a.additions?i+t:void 0,v=f==="unified"?t>=a.deletions?o+(t-a.deletions):void 0:t<a.additions?o+t:void 0,x=f==="unified"?m&&t===a.deletions-1&&e.noEOFCRDeletions:m&&t===O-1&&e.noEOFCRDeletions,c=f==="unified"?m&&t===g-1&&e.noEOFCRAdditions:m&&t===O-1&&e.noEOFCRAdditions,p=I!=null&&C!=null&&b!=null?{lineNumber:C,lineIndex:I,noEOFCR:x,unifiedLineIndex:b,splitLineIndex:w}:void 0,k=L!=null&&v!=null&&N!=null?{unifiedLineIndex:N,splitLineIndex:w,lineIndex:L,lineNumber:v,noEOFCR:c}:void 0;if(p==null&&k!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:void 0,additionLine:k};if(p!=null&&k==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:void 0};if(p==null||k==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:k}}const ln={forcePlainText:!1};function Ln(n,e,r,{forcePlainText:l,startingLine:f,totalLines:t,expandedHunks:h,collapsedContextThreshold:d=1}=ln){l?(f??=0,t??=1/0):(f=0,t=1/0);const i=f>0||t<1/0,u=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,o=G({theme:r.theme,highlighter:e}),s=l&&!i&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,a={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,g=!l&&!n.isPartial,O=l?h:void 0,b=new Map;function N(I){const C=g?0:I,L=b.get(C)??un();return b.set(C,L),L}function w(I,C,L,v){if(i){let x=L.at(-1);(x==null||x.targetIndex+x.count!==C)&&(x={targetIndex:C,originalOffset:v.length,count:0},L.push(x)),x.count++}v.push(I)}nn({diff:n,diffStyle:"both",startingLine:f,totalLines:t,expandedHunks:i?O:!0,collapsedContextThreshold:d,callback:({hunkIndex:I,additionLine:C,deletionLine:L,type:v})=>{const x=N(I),c=C!=null?C.splitLineIndex:L.splitLineIndex;v==="change"&&C!=null&&L!=null&&an({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[L.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:s,maxLineDiffLength:m}),L!=null&&(w(n.deletionLines[L.lineIndex],L.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:L.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${L.unifiedLineIndex},${c}`})),C!=null&&(w(n.additionLines[C.lineIndex],C.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:L.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${c}`}))}});for(const I of b.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},L={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:x}=dn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:L,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:l?"text":n.lang});if(g){a.deletionLines=v,a.additionLines=x;continue}if(I.deletionSegments.length>0)for(const c of I.deletionSegments)for(let p=0;p<c.count;p++)a.deletionLines[c.targetIndex+p]=v[c.originalOffset+p];else a.deletionLines.push(...v);if(I.additionSegments.length>0)for(const c of I.additionSegments)for(let p=0;p<c.count;p++)a.additionLines[c.targetIndex+p]=x[c.originalOffset+p];else a.additionLines.push(...x)}return{code:a,themeStyles:o,baseThemeType:u}}function an({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:l,deletionDecorations:f,additionDecorations:t,lineDiffType:h,maxLineDiffLength:d}){if(n==null||e==null||h==="none"||(n=z(n),e=z(e),n.length>d||e.length>d))return;const i=h==="char"?X(n,e):Q(n,e),u=[],o=[],s=h==="word-alt",a=i.at(-1);for(const g of i){const O=g===a;!g.added&&!g.removed?(T({item:g,arr:u,enableJoin:s,isNeutral:!0,isLastItem:O}),T({item:g,arr:o,enableJoin:s,isNeutral:!0,isLastItem:O})):g.removed?T({item:g,arr:u,enableJoin:s,isLastItem:O}):T({item:g,arr:o,enableJoin:s,isLastItem:O})}let m=0;for(const g of u)g[0]===1&&f.push(A({line:r,spanStart:m,spanLength:g[1].length})),m+=g[1].length;m=0;for(const g of o)g[0]===1&&t.push(A({line:l,spanStart:m,spanLength:g[1].length})),m+=g[1].length}function un(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function dn({deletionFile:n,additionFile:e,deletionInfo:r,additionInfo:l,highlighter:f,deletionDecorations:t,additionDecorations:h,languageOverride:d,options:{theme:i=j,...u}}){const o=d??M(n.name),s=d??M(e.name),{state:a,transformers:m}=J(u.useTokenTransformer),g=typeof i=="string"?{...u,lang:"text",theme:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0}:{...u,lang:"text",themes:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0};return{deletionLines:n.contents===""?[]:(g.lang=o,a.lineInfo=r,g.decorations=t,P(f.codeToHast(z(n.contents),g))),additionLines:e.contents===""?[]:(g.lang=s,g.decorations=h,a.lineInfo=l,P(f.codeToHast(z(e.contents),g)))}}function xn(n){const e=n.lang??M(n.name),r=n.lang??(n.prevName!=null?M(n.prevName):"text");return e==="text"&&r==="text"}export{mn as a,gn as b,nn as c,B as d,In as e,V as f,Y as g,pn as h,xn as i,Cn as j,Ln as r};
@@ -1 +1 @@
1
- import{t as I}from"./themeResolver-BmJyTmjJ.js";import{b as R,z as A,i as y,y as S,C as _,B as T}from"./computeVirtualFileMetrics-6V1xNpO9.js";import{h7 as k}from"./useAppFontEffects-Dsl_sLrj.js";function W(e){return I.hasResolvedThemes(e)}function w(e,t){return R(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}const d=10,g=13;function N(e){const t=[0];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);(r===d||r===g)&&(r===g&&n+1<e.length&&e.charCodeAt(n+1)===d&&n++,t.push(n+1))}return t}function P(e){const t=N(e);return Array.from({length:t.length},(n,r)=>{const i=t[r],s=t[r+1]??e.length;return e.slice(i,s)})}const b={forcePlainText:!1};function D(e,t,{theme:n=k,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:s,startingLine:o,totalLines:a,lines:E}=b){s?(o??=0,a??=1/0):(o=0,a=1/0);const f=o>0||a<1/0,{state:F,transformers:l}=A(i),c=s?"text":e.lang??y(e.name),x=typeof n=="string"?t.getTheme(n).type:void 0,p=S({theme:n,highlighter:t});F.lineInfo=u=>({type:"context",lineIndex:u-1+o,lineNumber:u+o});const C=typeof n=="string"?{lang:c,theme:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:c,themes:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},h=_(t.codeToHast(f?H(E??P(e.contents),o,a):e.contents,C)),m=f?new Array(o):h;return f&&m.push(...h),{code:m,themeStyles:p,baseThemeType:x}}function H(e,t,n){if(e.length===0)return"";const r=Math.min(t+n,e.length);return e.slice(t,r).join("")}function M(e){return(e.lang??y(e.name))==="text"}export{w as a,W as h,M as i,P as l,D as r};
1
+ import{t as I}from"./themeResolver-BmJyTmjJ.js";import{b as R,z as A,i as y,y as S,C as _,B as T}from"./computeVirtualFileMetrics-BmhViPMt.js";import{hn as k}from"./useAppFontEffects-CeMgbeVa.js";function W(e){return I.hasResolvedThemes(e)}function w(e,t){return R(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}const d=10,g=13;function N(e){const t=[0];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);(r===d||r===g)&&(r===g&&n+1<e.length&&e.charCodeAt(n+1)===d&&n++,t.push(n+1))}return t}function P(e){const t=N(e);return Array.from({length:t.length},(n,r)=>{const i=t[r],s=t[r+1]??e.length;return e.slice(i,s)})}const b={forcePlainText:!1};function D(e,t,{theme:n=k,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:s,startingLine:o,totalLines:a,lines:E}=b){s?(o??=0,a??=1/0):(o=0,a=1/0);const f=o>0||a<1/0,{state:F,transformers:l}=A(i),c=s?"text":e.lang??y(e.name),x=typeof n=="string"?t.getTheme(n).type:void 0,p=S({theme:n,highlighter:t});F.lineInfo=u=>({type:"context",lineIndex:u-1+o,lineNumber:u+o});const C=typeof n=="string"?{lang:c,theme:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:c,themes:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},h=_(t.codeToHast(f?H(E??P(e.contents),o,a):e.contents,C)),m=f?new Array(o):h;return f&&m.push(...h),{code:m,themeStyles:p,baseThemeType:x}}function H(e,t,n){if(e.length===0)return"";const r=Math.min(t+n,e.length);return e.slice(t,r).join("")}function M(e){return(e.lang??y(e.name))==="text"}export{w as a,W as h,M as i,P as l,D as r};